@tts-tools/xmlbundle
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

TTS Tools - XML Bundle

xmlbundle is a module to bundle and unbundle XML UI files from Tabletop Simulator. It mimics the behavior for XML files of the TTS Atom plugin.

Installation

npm install -D @tts-tools/xmlbundle

Usage

To bundle a XML UI, use the bundle function from the xmlbundle module. It takes the XML content as a string and the include directory where additional files can be found and returns the bundled XML.

Files can be included by adding <Include src="file_path" /> into the XML. file_path is a relative path starting from the given include directory. It can contain the ending .xml at the end, but that's not a requirement.

When an included file also contains includes, the path of the included file will be used as the root path to search for those additional includes.

Examples

Simple

Given a file named main.xml with the following content:

<Panel id="main" />

This bundling call:

import { bundle } from "@tts-tools/xmlbundle";

const input = '<Include src="main" />';

const bundled = bundle(input, "<include_directory>");
console.log(bundled);

Will result in this output:

<!-- include main -->
<Panel id="main">
<!-- include main -->

The reverse happens during unbundle (but it won't create the file).

Nested

Given the following directory structure:

<include_directory>
├─ main.xml
└─ nested
   ├─ main.xml
   └─ index.xml

And those XML Files:

main.xml:

<Include src="nested/index>

nested/index.xml:

<Include src="main" />

nested/main.xml

<Panel id="nested_main" />

Bundling the content of main.xml will result in this output:

<!-- include nested/index -->
<!-- include main -->
<Panel id="nested_main" />
<!-- include main -->
<!-- include nested/index -->

Copyright and License

No rights reserved.

The author has dedicated the work to the Commons by waiving all of his or her rights to the work worldwide under copyright law and all related or neighboring legal rights he or she had in the work, to the extent allowable by law.

Works under CC0 do not require attribution. When citing the work, you should not imply endorsement by the author.

Package Sidebar

Install

npm i @tts-tools/xmlbundle

Weekly Downloads

1

Version

1.0.3

License

CC0-1.0

Unpacked Size

15.5 kB

Total Files

9

Last publish

Collaborators

  • sebaestschjin