extwee 2.0.6 → 2.2.0
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.
- package/.eslintrc.json +25 -25
- package/.github/FUNDING.yml +3 -0
- package/.github/dependabot.yml +11 -0
- package/.github/workflows/nodejs.yml +25 -24
- package/.travis.yml +13 -13
- package/CODE_OF_CONDUCT.md +82 -82
- package/LICENSE +21 -21
- package/README.md +173 -36
- package/SECURITY.md +12 -12
- package/babel.config.json +18 -22
- package/build/extwee +0 -0
- package/build/extwee.exe +0 -0
- package/build/extwee.web.min.js +2 -0
- package/build/extwee.web.min.js.LICENSE.txt +1 -0
- package/docs/.nojekyll +0 -0
- package/docs/README.md +167 -0
- package/docs/_sidebar.md +19 -0
- package/docs/examples/dynamicPassages.md +28 -0
- package/docs/examples/jsonToTwee.md +23 -0
- package/docs/examples/twsToTwee.md +25 -0
- package/docs/formats/json.md +17 -0
- package/docs/formats/twee.md +13 -0
- package/docs/formats/twine1HTML.md +13 -0
- package/docs/formats/twine2ArchiveHTML.md +13 -0
- package/docs/formats/twine2HTML.md +13 -0
- package/docs/formats/tws.md +9 -0
- package/docs/index.html +26 -0
- package/docs/install/binaries.md +9 -0
- package/docs/install/npm.md +20 -0
- package/docs/install/npx.md +9 -0
- package/docs/objects/passage.md +47 -0
- package/docs/objects/story.md +70 -0
- package/docs/objects/storyformat.md +27 -0
- package/index.html +22 -0
- package/index.js +29 -31
- package/package.json +65 -58
- package/src/JSON/parse.js +128 -0
- package/src/Passage.js +298 -202
- package/src/Story.js +650 -523
- package/src/StoryFormat/parse.js +134 -0
- package/src/StoryFormat.js +259 -300
- package/src/TWS/parse.js +86 -0
- package/src/Twee/parse.js +157 -0
- package/src/Twine1HTML/compile.js +58 -0
- package/src/Twine1HTML/parse.js +134 -0
- package/src/Twine2ArchiveHTML/compile.js +36 -0
- package/src/Twine2ArchiveHTML/parse.js +49 -0
- package/src/Twine2HTML/compile.js +35 -0
- package/src/Twine2HTML/parse.js +348 -0
- package/src/extwee.js +206 -0
- package/test/CLI/CLI.test.js +49 -0
- package/test/CLI/files/example.json +1 -0
- package/test/CLI/files/example6.twee +22 -0
- package/test/{Roundtrip → CLI/files}/harlowe.js +2 -2
- package/test/CLI/{input.html → files/input.html} +47 -47
- package/test/CLI/files/output/test.twee +0 -0
- package/test/CLI/{tweeExample.twee → files/tweeExample.twee} +17 -17
- package/test/CLI/files/twine1/LICENSE.txt +32 -0
- package/test/CLI/files/twine1/code.js +5 -0
- package/test/CLI/files/twine1/engine.js +43 -0
- package/test/CLI/files/twine1/header.html +325 -0
- package/test/CLI/files/twine1Test.html +371 -0
- package/test/CLI/{twineExample.html → files/twineExample.html} +16 -15
- package/test/JSON/JSON.Parse.test.js +316 -0
- package/test/Passage.test.js +175 -104
- package/test/Roundtrip/{Example1.html → Files/Example1.html} +63 -63
- package/test/Roundtrip/Files/LICENSE +19 -0
- package/test/Roundtrip/Files/example1.twee +10 -0
- package/test/Roundtrip/{example2.twee → Files/example2.twee} +27 -18
- package/test/Roundtrip/{example4.twee → Files/example4.twee} +27 -27
- package/test/{StoryFormatParser → Roundtrip/Files}/harlowe.js +2 -2
- package/test/Roundtrip/{round.html → Files/round.html} +6 -4
- package/test/Roundtrip/Roundtrip.test.js +54 -0
- package/test/Story.test.js +638 -423
- package/test/StoryFormat/StoryFormat.Parse.test.js +91 -0
- package/test/{StoryFormatParser → StoryFormat/StoryFormatParser}/example.js +3 -3
- package/test/{StoryFormatParser → StoryFormat/StoryFormatParser}/example2.js +3 -3
- package/test/{CLI → StoryFormat/StoryFormatParser}/harlowe.js +2 -2
- package/test/StoryFormat.test.js +152 -152
- package/test/TWS/Parse.test.js +78 -0
- package/test/TWS/TWSParser/Example1.tws +150 -0
- package/test/TWS/TWSParser/Example5.tws +414 -0
- package/test/TWS/TWSParser/noscale.tws +0 -0
- package/test/TWS/TWSParser/nostory.tws +0 -0
- package/test/Twee/Twee.Parse.test.js +76 -0
- package/test/{TweeParser → Twee/TweeParser}/emptytags.twee +2 -2
- package/test/{TweeParser → Twee/TweeParser}/example.twee +32 -32
- package/test/{TweeParser → Twee/TweeParser}/missing.twee +19 -19
- package/test/{TweeParser → Twee/TweeParser}/multipleScriptPassages.twee +19 -19
- package/test/{TweeParser → Twee/TweeParser}/multipleStyleTag.twee +19 -19
- package/test/{TweeParser → Twee/TweeParser}/multipletags.twee +10 -10
- package/test/{TweeParser → Twee/TweeParser}/noTitle.twee +2 -2
- package/test/{TweeParser → Twee/TweeParser}/notes.twee +16 -16
- package/test/{TweeParser → Twee/TweeParser}/pasagemetadataerror.twee +2 -2
- package/test/{TweeParser → Twee/TweeParser}/scriptPassage.twee +16 -16
- package/test/{TweeParser → Twee/TweeParser}/singletag.twee +13 -13
- package/test/{TweeParser → Twee/TweeParser}/startMetadata.twee +14 -14
- package/test/{TweeParser → Twee/TweeParser}/storydataerror.twee +25 -25
- package/test/{TweeParser → Twee/TweeParser}/stylePassage.twee +16 -16
- package/test/{Story → Twee/TweeParser}/test.twee +25 -25
- package/test/Twine1HTML/Twine1HTML.Compile.test.js +180 -0
- package/test/Twine1HTML/Twine1HTML.Parse.test.js +183 -0
- package/test/Twine1HTML/Twine1HTMLCompiler/Twine1/LICENSE +674 -0
- package/test/Twine1HTML/Twine1HTMLCompiler/Twine1/engine.js +43 -0
- package/test/Twine1HTML/Twine1HTMLCompiler/Twine1/jquery.js +4 -0
- package/test/Twine1HTML/Twine1HTMLCompiler/Twine1/modernizr.js +4 -0
- package/test/Twine1HTML/Twine1HTMLCompiler/engineTest.html +1 -0
- package/test/Twine1HTML/Twine1HTMLCompiler/jonah-1.4.2/LICENSE +32 -0
- package/test/Twine1HTML/Twine1HTMLCompiler/jonah-1.4.2/code.js +4 -0
- package/test/Twine1HTML/Twine1HTMLCompiler/jonah-1.4.2/header.html +327 -0
- package/test/Twine1HTML/Twine1HTMLCompiler/test.html +0 -0
- package/test/Twine1HTML/Twine1HTMLCompiler/test1.html +6 -0
- package/test/Twine1HTML/Twine1HTMLCompiler/test2.html +6 -0
- package/test/Twine1HTML/Twine1HTMLCompiler/test3.html +43 -0
- package/test/Twine1HTML/Twine1HTMLCompiler/test4.html +372 -0
- package/test/Twine1HTML/Twine1HTMLCompiler/test5.html +372 -0
- package/test/Twine2ArchiveHTML/Twine2ArchiveHTML.Compile.test.js +35 -0
- package/test/Twine2ArchiveHTML/Twine2ArchiveHTML.Parse.test.js +25 -0
- package/test/Twine2ArchiveHTML/Twine2ArchiveHTMLCompiler/test1.html +6 -0
- package/test/Twine2ArchiveHTML/Twine2ArchiveHTMLParser/test1.html +3 -0
- package/test/Twine2HTML/Twine2HTML.Compile.test.js +224 -0
- package/test/Twine2HTML/Twine2HTML.Parse.test.js +172 -0
- package/test/{HTMLWriter → Twine2HTML/Twine2HTMLCompiler}/creator.html +4 -4
- package/test/{CLI → Twine2HTML/Twine2HTMLCompiler}/example6.twee +15 -15
- package/test/{HTMLWriter → Twine2HTML/Twine2HTMLCompiler}/missingStoryTitle.twee +29 -29
- package/test/{HTMLWriter → Twine2HTML/Twine2HTMLCompiler}/test2.html +10 -8
- package/test/{HTMLWriter → Twine2HTML/Twine2HTMLCompiler}/test3.html +1 -1
- package/test/{HTMLWriter → Twine2HTML/Twine2HTMLCompiler}/test4.html +4 -4
- package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/Example1.html +52 -52
- package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/Tags.html +15 -15
- package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/lyingStartnode.html +15 -15
- package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/lyingTagColors.html +48 -48
- package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/missingCreator.html +11 -11
- package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/missingCreatorVersion.html +11 -11
- package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/missingFormat.html +11 -11
- package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/missingFormatVersion.html +11 -11
- package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/missingIFID.html +11 -11
- package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/missingName.html +33 -33
- package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/missingPID.html +15 -15
- package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/missingPassageName.html +15 -15
- package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/missingPassageTags.html +15 -15
- package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/missingPosition.html +15 -15
- package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/missingScript.html +14 -14
- package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/missingSize.html +35 -35
- package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/missingStartnode.html +11 -11
- package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/missingStyle.html +14 -14
- package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/missingZoom.html +11 -11
- package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/twineExample.html +23 -23
- package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/twineExample2.html +15 -15
- package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/twineExample3.html +15 -15
- package/web-index.js +29 -0
- package/webpack.config.js +12 -0
- package/bin/extwee.js +0 -47
- package/src/FileReader.js +0 -33
- package/src/HTMLParser.js +0 -345
- package/src/HTMLWriter.js +0 -231
- package/src/StoryFormatParser.js +0 -142
- package/src/TweeParser.js +0 -161
- package/src/TweeWriter.js +0 -121
- package/story-formats/chapbook-1.2.0/format.js +0 -1
- package/story-formats/chapbook-1.2.0/logo.svg +0 -1
- package/story-formats/harlowe-1.2.4/format.js +0 -1
- package/story-formats/harlowe-1.2.4/icon.svg +0 -78
- package/story-formats/harlowe-2.1.0/format.js +0 -2
- package/story-formats/harlowe-2.1.0/icon.svg +0 -78
- package/story-formats/harlowe-3.1.0/format.js +0 -3
- package/story-formats/harlowe-3.1.0/icon.svg +0 -78
- package/story-formats/paperthin-1.0.0/format.js +0 -1
- package/story-formats/paperthin-1.0.0/icon.svg +0 -5
- package/story-formats/snowman-1.4.0/format.js +0 -1
- package/story-formats/snowman-1.4.0/icon.svg +0 -436
- package/story-formats/snowman-2.0.2/format.js +0 -1
- package/story-formats/snowman-2.0.2/icon.svg +0 -436
- package/story-formats/sugarcube-1.0.35/LICENSE +0 -23
- package/story-formats/sugarcube-1.0.35/format.js +0 -1
- package/story-formats/sugarcube-1.0.35/icon.svg +0 -56
- package/story-formats/sugarcube-2.31.1/LICENSE +0 -22
- package/story-formats/sugarcube-2.31.1/format.js +0 -1
- package/story-formats/sugarcube-2.31.1/icon.svg +0 -56
- package/test/CLI/test2.html +0 -45
- package/test/CLI.test.js +0 -30
- package/test/FileReader/t1.txt +0 -1
- package/test/FileReader.test.js +0 -14
- package/test/HTMLParser.test.js +0 -177
- package/test/HTMLWriter/example6.twee +0 -16
- package/test/HTMLWriter.test.js +0 -287
- package/test/Roundtrip/example1.twee +0 -21
- package/test/Roundtrip.test.js +0 -48
- package/test/Story/startmeta.twee +0 -29
- package/test/StoryFormatParser.test.js +0 -91
- package/test/TweeParser/test.twee +0 -25
- package/test/TweeParser.test.js +0 -79
- package/test/TweeWriter/test1.twee +0 -18
- package/test/TweeWriter/test3.twee +0 -12
- package/test/TweeWriter/test4.twee +0 -14
- package/test/TweeWriter/test5.twee +0 -20
- package/test/TweeWriter/test6.twee +0 -15
- package/test/TweeWriter/test7.twee +0 -15
- package/test/TweeWriter.test.js +0 -107
- /package/test/CLI/{test.twee → files/test.twee} +0 -0
- /package/test/{StoryFormatParser → StoryFormat/StoryFormatParser}/format.js +0 -0
- /package/test/{StoryFormatParser → StoryFormat/StoryFormatParser}/format_doublename.js +0 -0
- /package/test/{StoryFormatParser → StoryFormat/StoryFormatParser}/missingAuthor.js +0 -0
- /package/test/{StoryFormatParser → StoryFormat/StoryFormatParser}/missingDescription.js +0 -0
- /package/test/{StoryFormatParser → StoryFormat/StoryFormatParser}/missingImage.js +0 -0
- /package/test/{StoryFormatParser → StoryFormat/StoryFormatParser}/missingLicense.js +0 -0
- /package/test/{StoryFormatParser → StoryFormat/StoryFormatParser}/missingName.js +0 -0
- /package/test/{StoryFormatParser → StoryFormat/StoryFormatParser}/missingProofing.js +0 -0
- /package/test/{StoryFormatParser → StoryFormat/StoryFormatParser}/missingSource.js +0 -0
- /package/test/{StoryFormatParser → StoryFormat/StoryFormatParser}/missingURL.js +0 -0
- /package/test/{StoryFormatParser → StoryFormat/StoryFormatParser}/missingVersion.js +0 -0
- /package/test/{StoryFormatParser → StoryFormat/StoryFormatParser}/versionWrong.js +0 -0
- /package/test/{HTMLWriter → Twine2HTML/Twine2HTMLCompiler}/TestTags.html +0 -0
- /package/test/{HTMLWriter → Twine2HTML/Twine2HTMLCompiler}/test11.html +0 -0
- /package/test/{HTMLWriter → Twine2HTML/Twine2HTMLCompiler}/test6.html +0 -0
- /package/test/{HTMLParser → Twine2HTML/Twine2HTMLParser}/tagColors.html +0 -0
package/test/StoryFormat.test.js
CHANGED
|
@@ -1,152 +1,152 @@
|
|
|
1
|
-
import StoryFormat from '../src/StoryFormat.js';
|
|
2
|
-
|
|
3
|
-
describe('StoryFormat', () => {
|
|
4
|
-
describe('
|
|
5
|
-
it('Should create default values', () => {
|
|
6
|
-
const sf = new StoryFormat();
|
|
7
|
-
expect(sf.name).toBe('');
|
|
8
|
-
expect(sf.version).toBe('');
|
|
9
|
-
expect(sf.author).toBe('');
|
|
10
|
-
expect(sf.image).toBe('');
|
|
11
|
-
expect(sf.url).toBe('');
|
|
12
|
-
expect(sf.license).toBe('');
|
|
13
|
-
expect(sf.proofing).toBe(false);
|
|
14
|
-
expect(sf.source).toBe('');
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
describe('name', () => {
|
|
19
|
-
it('Set new String', () => {
|
|
20
|
-
const sf = new StoryFormat();
|
|
21
|
-
sf.name = 'New';
|
|
22
|
-
expect(sf.name).toBe('New');
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('Throw error if non-String', () => {
|
|
26
|
-
const sf = new StoryFormat();
|
|
27
|
-
expect(() => {
|
|
28
|
-
sf.name = 1;
|
|
29
|
-
}).toThrow();
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
describe('version', () => {
|
|
34
|
-
it('Set new String', () => {
|
|
35
|
-
const sf = new StoryFormat();
|
|
36
|
-
sf.version = 'New';
|
|
37
|
-
expect(sf.version).toBe('New');
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('Throw error if non-String', () => {
|
|
41
|
-
const sf = new StoryFormat();
|
|
42
|
-
expect(() => {
|
|
43
|
-
sf.version = 1;
|
|
44
|
-
}).toThrow();
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
describe('author', () => {
|
|
49
|
-
it('Set new String', () => {
|
|
50
|
-
const sf = new StoryFormat();
|
|
51
|
-
sf.author = 'New';
|
|
52
|
-
expect(sf.author).toBe('New');
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('Throw error if non-String', () => {
|
|
56
|
-
const sf = new StoryFormat();
|
|
57
|
-
expect(() => {
|
|
58
|
-
sf.author = 1;
|
|
59
|
-
}).toThrow();
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
describe('image', () => {
|
|
64
|
-
it('Set new String', () => {
|
|
65
|
-
const sf = new StoryFormat();
|
|
66
|
-
sf.image = 'New';
|
|
67
|
-
expect(sf.image).toBe('New');
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it('Throw error if non-String', () => {
|
|
71
|
-
const sf = new StoryFormat();
|
|
72
|
-
expect(() => {
|
|
73
|
-
sf.image = 1;
|
|
74
|
-
}).toThrow();
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
describe('url', () => {
|
|
79
|
-
it('Set new String', () => {
|
|
80
|
-
const sf = new StoryFormat();
|
|
81
|
-
sf.url = 'New';
|
|
82
|
-
expect(sf.url).toBe('New');
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it('Throw error if non-String', () => {
|
|
86
|
-
const sf = new StoryFormat();
|
|
87
|
-
expect(() => {
|
|
88
|
-
sf.url = 1;
|
|
89
|
-
}).toThrow();
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
describe('license', () => {
|
|
94
|
-
it('Set new String', () => {
|
|
95
|
-
const sf = new StoryFormat();
|
|
96
|
-
sf.license = 'New';
|
|
97
|
-
expect(sf.license).toBe('New');
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
it('Throw error if non-String', () => {
|
|
101
|
-
const sf = new StoryFormat();
|
|
102
|
-
expect(() => {
|
|
103
|
-
sf.license = 1;
|
|
104
|
-
}).toThrow();
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
describe('proofing', () => {
|
|
109
|
-
it('Set new String', () => {
|
|
110
|
-
const sf = new StoryFormat();
|
|
111
|
-
sf.proofing = true;
|
|
112
|
-
expect(sf.proofing).toBe(true);
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
it('Throw error if non-String', () => {
|
|
116
|
-
const sf = new StoryFormat();
|
|
117
|
-
expect(() => {
|
|
118
|
-
sf.proofing = 1;
|
|
119
|
-
}).toThrow();
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
describe('source', () => {
|
|
124
|
-
it('Set new String', () => {
|
|
125
|
-
const sf = new StoryFormat();
|
|
126
|
-
sf.source = 'New';
|
|
127
|
-
expect(sf.source).toBe('New');
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
it('Throw error if non-String', () => {
|
|
131
|
-
const sf = new StoryFormat();
|
|
132
|
-
expect(() => {
|
|
133
|
-
sf.source = 1;
|
|
134
|
-
}).toThrow();
|
|
135
|
-
});
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
describe('description', () => {
|
|
139
|
-
it('Set new String', () => {
|
|
140
|
-
const sf = new StoryFormat();
|
|
141
|
-
sf.description = 'New';
|
|
142
|
-
expect(sf.description).toBe('New');
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
it('Throw error if non-String', () => {
|
|
146
|
-
const sf = new StoryFormat();
|
|
147
|
-
expect(() => {
|
|
148
|
-
sf.description = 1;
|
|
149
|
-
}).toThrow();
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
});
|
|
1
|
+
import StoryFormat from '../src/StoryFormat.js';
|
|
2
|
+
|
|
3
|
+
describe('StoryFormat', () => {
|
|
4
|
+
describe('constructor()', () => {
|
|
5
|
+
it('Should create default values', () => {
|
|
6
|
+
const sf = new StoryFormat();
|
|
7
|
+
expect(sf.name).toBe('Untitled Story Format');
|
|
8
|
+
expect(sf.version).toBe('');
|
|
9
|
+
expect(sf.author).toBe('');
|
|
10
|
+
expect(sf.image).toBe('');
|
|
11
|
+
expect(sf.url).toBe('');
|
|
12
|
+
expect(sf.license).toBe('');
|
|
13
|
+
expect(sf.proofing).toBe(false);
|
|
14
|
+
expect(sf.source).toBe('');
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
describe('name', () => {
|
|
19
|
+
it('Set new String', () => {
|
|
20
|
+
const sf = new StoryFormat();
|
|
21
|
+
sf.name = 'New';
|
|
22
|
+
expect(sf.name).toBe('New');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('Throw error if non-String', () => {
|
|
26
|
+
const sf = new StoryFormat();
|
|
27
|
+
expect(() => {
|
|
28
|
+
sf.name = 1;
|
|
29
|
+
}).toThrow();
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
describe('version', () => {
|
|
34
|
+
it('Set new String', () => {
|
|
35
|
+
const sf = new StoryFormat();
|
|
36
|
+
sf.version = 'New';
|
|
37
|
+
expect(sf.version).toBe('New');
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('Throw error if non-String', () => {
|
|
41
|
+
const sf = new StoryFormat();
|
|
42
|
+
expect(() => {
|
|
43
|
+
sf.version = 1;
|
|
44
|
+
}).toThrow();
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
describe('author', () => {
|
|
49
|
+
it('Set new String', () => {
|
|
50
|
+
const sf = new StoryFormat();
|
|
51
|
+
sf.author = 'New';
|
|
52
|
+
expect(sf.author).toBe('New');
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('Throw error if non-String', () => {
|
|
56
|
+
const sf = new StoryFormat();
|
|
57
|
+
expect(() => {
|
|
58
|
+
sf.author = 1;
|
|
59
|
+
}).toThrow();
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
describe('image', () => {
|
|
64
|
+
it('Set new String', () => {
|
|
65
|
+
const sf = new StoryFormat();
|
|
66
|
+
sf.image = 'New';
|
|
67
|
+
expect(sf.image).toBe('New');
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('Throw error if non-String', () => {
|
|
71
|
+
const sf = new StoryFormat();
|
|
72
|
+
expect(() => {
|
|
73
|
+
sf.image = 1;
|
|
74
|
+
}).toThrow();
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
describe('url', () => {
|
|
79
|
+
it('Set new String', () => {
|
|
80
|
+
const sf = new StoryFormat();
|
|
81
|
+
sf.url = 'New';
|
|
82
|
+
expect(sf.url).toBe('New');
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('Throw error if non-String', () => {
|
|
86
|
+
const sf = new StoryFormat();
|
|
87
|
+
expect(() => {
|
|
88
|
+
sf.url = 1;
|
|
89
|
+
}).toThrow();
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
describe('license', () => {
|
|
94
|
+
it('Set new String', () => {
|
|
95
|
+
const sf = new StoryFormat();
|
|
96
|
+
sf.license = 'New';
|
|
97
|
+
expect(sf.license).toBe('New');
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('Throw error if non-String', () => {
|
|
101
|
+
const sf = new StoryFormat();
|
|
102
|
+
expect(() => {
|
|
103
|
+
sf.license = 1;
|
|
104
|
+
}).toThrow();
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
describe('proofing', () => {
|
|
109
|
+
it('Set new String', () => {
|
|
110
|
+
const sf = new StoryFormat();
|
|
111
|
+
sf.proofing = true;
|
|
112
|
+
expect(sf.proofing).toBe(true);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it('Throw error if non-String', () => {
|
|
116
|
+
const sf = new StoryFormat();
|
|
117
|
+
expect(() => {
|
|
118
|
+
sf.proofing = 1;
|
|
119
|
+
}).toThrow();
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
describe('source', () => {
|
|
124
|
+
it('Set new String', () => {
|
|
125
|
+
const sf = new StoryFormat();
|
|
126
|
+
sf.source = 'New';
|
|
127
|
+
expect(sf.source).toBe('New');
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it('Throw error if non-String', () => {
|
|
131
|
+
const sf = new StoryFormat();
|
|
132
|
+
expect(() => {
|
|
133
|
+
sf.source = 1;
|
|
134
|
+
}).toThrow();
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
describe('description', () => {
|
|
139
|
+
it('Set new String', () => {
|
|
140
|
+
const sf = new StoryFormat();
|
|
141
|
+
sf.description = 'New';
|
|
142
|
+
expect(sf.description).toBe('New');
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it('Throw error if non-String', () => {
|
|
146
|
+
const sf = new StoryFormat();
|
|
147
|
+
expect(() => {
|
|
148
|
+
sf.description = 1;
|
|
149
|
+
}).toThrow();
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
});
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import { parse as parseTWS } from '../../src/TWS/parse.js';
|
|
3
|
+
|
|
4
|
+
describe('TWSParser', () => {
|
|
5
|
+
describe('#parse()', () => {
|
|
6
|
+
it('Should throw error if input is not Buffer', function () {
|
|
7
|
+
expect(() => { parseTWS(0); }).toThrow();
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
describe('Story parsing', function () {
|
|
11
|
+
let r = null;
|
|
12
|
+
|
|
13
|
+
beforeAll(() => {
|
|
14
|
+
const contents = fs.readFileSync('test/TWS/TWSParser/Example1.tws', 'binary');
|
|
15
|
+
const b = Buffer.from(contents, 'binary');
|
|
16
|
+
r = parseTWS(b);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('Should parse StoryTitle', function () {
|
|
20
|
+
expect(r.name).toBe('Untitled Story');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('Should parse zoom', function () {
|
|
24
|
+
expect(r.zoom).toBe(1);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('Should parse start passage', function () {
|
|
28
|
+
expect(r.start).toBe('Start');
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
describe('Passage parsing', function () {
|
|
33
|
+
let r = null;
|
|
34
|
+
|
|
35
|
+
beforeAll(() => {
|
|
36
|
+
const contents = fs.readFileSync('test/TWS/TWSParser/Example5.tws', 'binary');
|
|
37
|
+
const b = Buffer.from(contents, 'binary');
|
|
38
|
+
r = parseTWS(b);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('Should parse passage - tags', function () {
|
|
42
|
+
const p = r.getPassageByName('Untitled Passage 1');
|
|
43
|
+
expect(p.tags.length).toBe(3);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('Should parse passage - text', function () {
|
|
47
|
+
const p = r.getPassageByName('Untitled Passage 2');
|
|
48
|
+
expect(p.text).toBe('dd');
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('Should set Story start (to start passage)', function () {
|
|
52
|
+
expect(r.start).toBe('Start');
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
describe('Exceptions and parsing issues', function () {
|
|
57
|
+
it('Should throw error if parsing a Buffer but not pickle data', function () {
|
|
58
|
+
const contents = 'Test';
|
|
59
|
+
const b = Buffer.from(contents);
|
|
60
|
+
expect(() => { parseTWS(b); }).toThrow();
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('Should create default Story object if pickle data but not TWS data', function () {
|
|
64
|
+
const contents = fs.readFileSync('test/TWS/TWSParser/nostory.tws', 'binary');
|
|
65
|
+
const b = Buffer.from(contents, 'binary');
|
|
66
|
+
const r = parseTWS(b);
|
|
67
|
+
expect(r.size()).toBe(0);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('Should parse storyPanel but no scale', function () {
|
|
71
|
+
const contents = fs.readFileSync('test/TWS/TWSParser/noscale.tws', 'binary');
|
|
72
|
+
const b = Buffer.from(contents, 'binary');
|
|
73
|
+
const r = parseTWS(b);
|
|
74
|
+
expect(r.zoom).toBe(0);
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
});
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
(dp0
|
|
2
|
+
S'buildDestination'
|
|
3
|
+
p1
|
|
4
|
+
S''
|
|
5
|
+
p2
|
|
6
|
+
sS'saveDestination'
|
|
7
|
+
p3
|
|
8
|
+
V\u005c\u005cMac\u005cDropbox\u005cExample1.tws
|
|
9
|
+
p4
|
|
10
|
+
sS'metadata'
|
|
11
|
+
p5
|
|
12
|
+
(dp6
|
|
13
|
+
sS'target'
|
|
14
|
+
p7
|
|
15
|
+
S'sugarcane'
|
|
16
|
+
p8
|
|
17
|
+
sS'storyPanel'
|
|
18
|
+
p9
|
|
19
|
+
(dp10
|
|
20
|
+
S'widgets'
|
|
21
|
+
p11
|
|
22
|
+
(lp12
|
|
23
|
+
(dp13
|
|
24
|
+
S'selected'
|
|
25
|
+
p14
|
|
26
|
+
I00
|
|
27
|
+
sS'pos'
|
|
28
|
+
p15
|
|
29
|
+
(lp16
|
|
30
|
+
I10
|
|
31
|
+
aI10
|
|
32
|
+
asS'passage'
|
|
33
|
+
p17
|
|
34
|
+
(itiddlywiki
|
|
35
|
+
Tiddler
|
|
36
|
+
p18
|
|
37
|
+
(dp20
|
|
38
|
+
S'text'
|
|
39
|
+
p21
|
|
40
|
+
S'Your story will display this passage first. Edit it by double clicking it.'
|
|
41
|
+
p22
|
|
42
|
+
sS'title'
|
|
43
|
+
p23
|
|
44
|
+
S'Start'
|
|
45
|
+
p24
|
|
46
|
+
sS'modified'
|
|
47
|
+
p25
|
|
48
|
+
ctime
|
|
49
|
+
struct_time
|
|
50
|
+
p26
|
|
51
|
+
((I2023
|
|
52
|
+
I9
|
|
53
|
+
I3
|
|
54
|
+
I14
|
|
55
|
+
I38
|
|
56
|
+
I52
|
|
57
|
+
I6
|
|
58
|
+
I246
|
|
59
|
+
I1
|
|
60
|
+
tp27
|
|
61
|
+
(dp28
|
|
62
|
+
tp29
|
|
63
|
+
Rp30
|
|
64
|
+
sS'tags'
|
|
65
|
+
p31
|
|
66
|
+
(lp32
|
|
67
|
+
sS'created'
|
|
68
|
+
p33
|
|
69
|
+
g30
|
|
70
|
+
sbsa(dp34
|
|
71
|
+
g14
|
|
72
|
+
I00
|
|
73
|
+
sg15
|
|
74
|
+
(lp35
|
|
75
|
+
I10
|
|
76
|
+
aI150
|
|
77
|
+
asg17
|
|
78
|
+
(itiddlywiki
|
|
79
|
+
Tiddler
|
|
80
|
+
p36
|
|
81
|
+
(dp37
|
|
82
|
+
g21
|
|
83
|
+
S'Untitled Story'
|
|
84
|
+
p38
|
|
85
|
+
sg23
|
|
86
|
+
S'StoryTitle'
|
|
87
|
+
p39
|
|
88
|
+
sg25
|
|
89
|
+
g26
|
|
90
|
+
((I2023
|
|
91
|
+
I9
|
|
92
|
+
I3
|
|
93
|
+
I14
|
|
94
|
+
I38
|
|
95
|
+
I52
|
|
96
|
+
I6
|
|
97
|
+
I246
|
|
98
|
+
I1
|
|
99
|
+
tp40
|
|
100
|
+
(dp41
|
|
101
|
+
tp42
|
|
102
|
+
Rp43
|
|
103
|
+
sg31
|
|
104
|
+
(lp44
|
|
105
|
+
sg33
|
|
106
|
+
g43
|
|
107
|
+
sbsa(dp45
|
|
108
|
+
g14
|
|
109
|
+
I00
|
|
110
|
+
sg15
|
|
111
|
+
(lp46
|
|
112
|
+
I10
|
|
113
|
+
aI290
|
|
114
|
+
asg17
|
|
115
|
+
(itiddlywiki
|
|
116
|
+
Tiddler
|
|
117
|
+
p47
|
|
118
|
+
(dp48
|
|
119
|
+
g21
|
|
120
|
+
S'Anonymous'
|
|
121
|
+
p49
|
|
122
|
+
sg23
|
|
123
|
+
S'StoryAuthor'
|
|
124
|
+
p50
|
|
125
|
+
sg25
|
|
126
|
+
g26
|
|
127
|
+
((I2023
|
|
128
|
+
I9
|
|
129
|
+
I3
|
|
130
|
+
I14
|
|
131
|
+
I38
|
|
132
|
+
I52
|
|
133
|
+
I6
|
|
134
|
+
I246
|
|
135
|
+
I1
|
|
136
|
+
tp51
|
|
137
|
+
(dp52
|
|
138
|
+
tp53
|
|
139
|
+
Rp54
|
|
140
|
+
sg31
|
|
141
|
+
(lp55
|
|
142
|
+
sg33
|
|
143
|
+
g54
|
|
144
|
+
sbsasS'scale'
|
|
145
|
+
p56
|
|
146
|
+
I1
|
|
147
|
+
sS'snapping'
|
|
148
|
+
p57
|
|
149
|
+
I00
|
|
150
|
+
ss.
|