extwee 2.2.2 → 2.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,121 @@
1
+ /**
2
+ * StoryFormat representing a Twine 2 story format.
3
+ *
4
+ * This class has type checking on all of its properties.
5
+ * If a property is set to a value of the wrong type, a TypeError will be thrown.
6
+ *
7
+ * @see {@link https://github.com/iftechfoundation/twine-specs/blob/master/twine-2-storyformats-spec.md Twine 2 Story Formats Specification}
8
+ *
9
+ * @class
10
+ * @classdesc A class representing a Twine 2 story format.
11
+ * @property {string} name - The name of the story format.
12
+ * @property {string} version - The semantic version of the story format.
13
+ * @property {string} description - The description of the story format.
14
+ * @property {string} author - The author of the story format.
15
+ * @property {string} image - The image of the story format.
16
+ * @property {string} url - The URL of the story format.
17
+ * @property {string} license - The license of the story format.
18
+ * @property {boolean} proofing - The proofing of the story format.
19
+ * @property {string} source - The source of the story format.
20
+ * @example
21
+ * const sf = new StoryFormat();
22
+ * sf.name = 'New';
23
+ * sf.version = '1.0.0';
24
+ * sf.description = 'New';
25
+ * sf.author = 'New';
26
+ * sf.image = 'New';
27
+ * sf.url = 'New';
28
+ * sf.license = 'New';
29
+ * sf.proofing = true;
30
+ * sf.source = 'New';
31
+ */
32
+ export default class StoryFormat {
33
+ /**
34
+ * @param {string} n - Replacement name.
35
+ */
36
+ set name(n: string);
37
+ /**
38
+ * Name
39
+ * @returns {string} Name.
40
+ */
41
+ get name(): string;
42
+ /**
43
+ * @param {string} n - Replacement version.
44
+ */
45
+ set version(n: string);
46
+ /**
47
+ * Version.
48
+ * @returns {string} Version.
49
+ */
50
+ get version(): string;
51
+ /**
52
+ * @param {string} d - Replacement description.
53
+ */
54
+ set description(d: string);
55
+ /**
56
+ * Description.
57
+ * @returns {string} Description.
58
+ */
59
+ get description(): string;
60
+ /**
61
+ * @param {string} a - Replacement author.
62
+ */
63
+ set author(a: string);
64
+ /**
65
+ * Author.
66
+ * @returns {string} Author.
67
+ */
68
+ get author(): string;
69
+ /**
70
+ * @param {string} i - Replacement image.
71
+ */
72
+ set image(i: string);
73
+ /**
74
+ * Image.
75
+ * @returns {string} Image.
76
+ */
77
+ get image(): string;
78
+ /**
79
+ * @param {string} u - Replacement URL.
80
+ */
81
+ set url(u: string);
82
+ /**
83
+ * URL.
84
+ * @returns {string} URL.
85
+ */
86
+ get url(): string;
87
+ /**
88
+ * @param {string} l - Replacement license.
89
+ */
90
+ set license(l: string);
91
+ /**
92
+ * License.
93
+ * @returns {string} License.
94
+ */
95
+ get license(): string;
96
+ /**
97
+ * @param {boolean} p - Replacement proofing.
98
+ */
99
+ set proofing(p: boolean);
100
+ /**
101
+ * Proofing.
102
+ * @returns {boolean} Proofing.
103
+ */
104
+ get proofing(): boolean;
105
+ /**
106
+ * @param {string} s - Replacement source.
107
+ */
108
+ set source(s: string);
109
+ /**
110
+ * Source.
111
+ * @returns {string} Source.
112
+ */
113
+ get source(): string;
114
+ /**
115
+ * Produces a string representation of the story format object.
116
+ * @method toString
117
+ * @returns {string} - A string representation of the story format.
118
+ */
119
+ toString(): string;
120
+ #private;
121
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Parse TWS file (as Buffer) into Story.
3
+ * Unless it throws an error, it will return a Story object.
4
+ * @see {@link https://github.com/iftechfoundation/twine-specs/blob/master/twine-1-htmloutput-doc.md Twine 1 HTML Documentation}
5
+ * @function parse
6
+ * @param {Buffer} binaryFileContents - File contents to parse as Buffer.
7
+ * @returns {Story} Story object.
8
+ */
9
+ export function parse(binaryFileContents: Buffer): Story;
10
+ import { Story } from '../Story.js';
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Parses Twee 3 text into a Story object.
3
+ * @see {@link https://github.com/iftechfoundation/twine-specs/blob/master/twee-3-specification.md Twee 3 Specification}
4
+ * @function parse
5
+ * @param {string} fileContents - File contents to parse
6
+ * @returns {Story} story
7
+ */
8
+ export function parse(fileContents: string): Story;
9
+ import { Story } from '../Story.js';
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Write a combination of Story object, `engine.js` (from Twine 1), `header.html`, and optional `code.js`.
3
+ * @see {@link https://github.com/iftechfoundation/twine-specs/blob/master/twine-1-htmloutput-doc.md Twine 1 HTML Documentation}
4
+ * @function compile
5
+ * @param {Story} story - Story object to write.
6
+ * @param {string} engine - Source of `engine.js` file from Twine 1.
7
+ * @param {string} header - `header.html` content for Twine 1 story format.
8
+ * @param {string} name - Name of the story format (needed for `code.js` inclusion).
9
+ * @param {string} codeJS - `code.js` content with additional JavaScript.
10
+ * @param {object} config - Limited configuration object acting in place of `StorySettings`.
11
+ * @param {string} config.jquery - jQuery source.
12
+ * @param {string} config.modernizr - Modernizr source.
13
+ * @returns {string} Twine 1 HTML.
14
+ */
15
+ export function compile(story: Story, engine?: string, header?: string, name?: string, codeJS?: string, config?: {
16
+ jquery: string;
17
+ modernizr: string;
18
+ }): string;
19
+ import { Story } from '../Story.js';
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Parses Twine 1 HTML into a Story object.
3
+ * @see {@link https://github.com/iftechfoundation/twine-specs/blob/master/twine-1-htmloutput-doc.md Twine 1 HTML Documentation}
4
+ * @function parse
5
+ * @param {string} content - Twine 1 HTML content to parse.
6
+ * @returns {Story} Story object
7
+ */
8
+ export function parse(content: string): Story;
9
+ import { Story } from '../Story.js';
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Write array of Story objects into Twine 2 Archive HTML.
3
+ * @see {@link https://github.com/iftechfoundation/twine-specs/blob/master/twine-2-archive-spec.md Twine 2 Archive Specification}
4
+ * @function compile
5
+ * @param {Array} stories - Array of Story objects.
6
+ * @returns {string} Twine 2 Archive HTML.
7
+ * @example
8
+ * const story1 = new Story();
9
+ * const story2 = new Story();
10
+ * const stories = [story1, story2];
11
+ * console.log(compile(stories));
12
+ * // => '<tw-storydata name="Untitled" startnode="1" creator="Twine" creator-version="2.3.9" ifid="A1B2C3D4-E5F6-G7H8-I9J0-K1L2M3N4O5P6" zoom="1" format="Harlowe" format-version="3.1.0" options="" hidden><style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style><script role="script" id="twine-user-script" type="text/twine-javascript"></script><tw-passagedata pid="1" name="Untitled Passage" tags="" position="0,0" size="100,100"></tw-passagedata></tw-storydata>\n\n<tw-storydata name="Untitled" startnode="1" creator="Twine" creator-version="2.3.9" ifid="A1B2C3D4-E5F6-G7H8-I9J0-K1L2M3N4O5P6" zoom="1" format="Harlowe" format-version="3.1.0" options="" hidden><style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style><script role="script" id="twine-user-script" type="text/twine-javascript"></script><tw-passagedata pid="1" name="Untitled Passage" tags="" position="0,0" size="100,100"></tw-passagedata></tw-storydata>\n\n'
13
+ */
14
+ export function compile(stories: any[]): string;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Parse Twine 2 Archive HTML and returns an array of story objects.
3
+ * @see {@link https://github.com/iftechfoundation/twine-specs/blob/master/twine-2-archive-spec.md Twine 2 Archive Specification}
4
+ * @function parse
5
+ * @param {string} content - Content to parse for Twine 2 HTML elements.
6
+ * @throws {TypeError} - Content is not a string!
7
+ * @returns {Array} Array of stories found in content.
8
+ * @example
9
+ * const content = '<tw-storydata name="Untitled" startnode="1" creator="Twine" creator-version="2.3.9" ifid="A1B2C3D4-E5F6-G7H8-I9J0-K1L2M3N4O5P6" zoom="1" format="Harlowe" format-version="3.1.0" options="" hidden><style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style><script role="script" id="twine-user-script" type="text/twine-javascript"></script><tw-passagedata pid="1" name="Untitled Passage" tags="" position="0,0" size="100,100"></tw-passagedata></tw-storydata>';
10
+ * console.log(parse(content));
11
+ * // => [
12
+ * // Story {
13
+ * // name: 'Untitled',
14
+ * // startnode: '1',
15
+ * // creator: 'Twine',
16
+ * // creatorVersion: '2.3.9',
17
+ * // ifid: 'A1B2C3D4-E5F6-G7H8-I9J0-K1L2M3N4O5P6',
18
+ * // zoom: '1',
19
+ * // format: 'Harlowe',
20
+ * // formatVersion: '3.1.0',
21
+ * // options: '',
22
+ * // hidden: '',
23
+ * // passages: [
24
+ * // Passage {
25
+ * // pid: '1',
26
+ * // name: 'Untitled Passage',
27
+ * // tags: '',
28
+ * // position: '0,0',
29
+ * // size: '100,100',
30
+ * // text: ''
31
+ * // }
32
+ * // ]
33
+ * // }
34
+ * // ]
35
+ */
36
+ export function parse(content: string): any[];
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Write a combination of Story + StoryFormat into Twine 2 HTML file.
3
+ * @see {@link https://github.com/iftechfoundation/twine-specs/blob/master/twine-2-htmloutput-spec.md Twine 2 HTML Output Specification}
4
+ * @function compile
5
+ * @param {Story} story - Story object to write.
6
+ * @param {StoryFormat} storyFormat - StoryFormat to write.
7
+ * @returns {string} Twine 2 HTML based on StoryFormat and Story.
8
+ * @throws {Error} If story is not instance of Story.
9
+ * @throws {Error} If storyFormat is not instance of StoryFormat.
10
+ * @throws {Error} If storyFormat.source is empty string.
11
+ */
12
+ export function compile(story: Story, storyFormat: StoryFormat): string;
13
+ import { Story } from '../Story.js';
14
+ import StoryFormat from '../StoryFormat.js';
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Parse Twine 2 HTML into Story object.
3
+ *
4
+ * See: Twine 2 HTML Output Specification
5
+ * (https://github.com/iftechfoundation/twine-specs/blob/master/twine-2-htmloutput-spec.md)
6
+ *
7
+ * Produces warnings for:
8
+ * - Missing name attribute on `<tw-storydata>` element.
9
+ * - Missing IFID attribute on `<tw-storydata>` element.
10
+ * - Malformed IFID attribute on `<tw-storydata>` element.
11
+ * @function parse
12
+ * @param {string} content - Twine 2 HTML content to parse.
13
+ * @returns {Story} Story object based on Twine 2 HTML content.
14
+ * @throws {TypeError} Content is not a string.
15
+ * @throws {Error} Not Twine 2 HTML content!
16
+ * @throws {Error} Cannot parse passage data without name!
17
+ * @throws {Error} Passages are required to have PID!
18
+ */
19
+ export function parse(content: string): Story;
20
+ import { Story } from '../Story.js';