extwee 2.2.6 → 2.3.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/.github/workflows/dependabot-automerge.yml +23 -0
- package/.github/workflows/nodejs.yml +4 -1
- package/README.md +9 -0
- package/SECURITY.md +1 -1
- package/build/extwee.web.min.js +2 -0
- package/build/extwee.web.min.js.LICENSE.txt +1 -0
- package/extwee.config.json +6 -0
- package/extwee.config.md +67 -0
- package/package.json +22 -22
- package/src/CLI/CommandLineProcessing.js +196 -0
- package/src/CLI/ProcessConfig/loadStoryFormat.js +102 -0
- package/src/CLI/ProcessConfig/readDirectories.js +46 -0
- package/src/CLI/ProcessConfig.js +175 -0
- package/src/CLI/isDirectory.js +27 -0
- package/src/CLI/isFile.js +28 -0
- package/src/Config/parser.js +30 -8
- package/src/Passage.js +17 -2
- package/src/Story.js +92 -1
- package/src/extwee.js +20 -195
- package/test/Config/Config.test.js +40 -10
- package/test/Config/files/full.json +8 -0
- package/test/Config/files/valid.json +4 -3
- package/test/Config/isDirectory.test.js +44 -0
- package/test/Config/isFile.test.js +50 -0
- package/test/Config/loadStoryFormat.test.js +101 -0
- package/test/Config/readDirectories.test.js +68 -0
- package/test/Objects/Passage.test.js +5 -0
- package/test/Objects/Story.test.js +131 -0
- package/test/TWS/Parse.test.js +0 -22
- package/test/Web/window.Extwee.test.js +85 -0
- package/types/Story.d.ts +25 -0
- package/types/index.d.ts +4 -2
- package/types/src/CLI/CommandLineProcessing.d.ts +8 -0
- package/types/src/CLI/ProcessConfig/loadStoryFormat.d.ts +20 -0
- package/types/src/CLI/ProcessConfig/readDirectories.d.ts +9 -0
- package/types/src/CLI/ProcessConfig.d.ts +12 -0
- package/types/src/CLI/isDirectory.d.ts +1 -0
- package/types/src/CLI/isFile.d.ts +1 -0
- package/types/src/Config/parser.d.ts +6 -0
- package/types/src/Config/reader.d.ts +11 -0
- package/types/src/IFID/generate.d.ts +14 -0
- package/types/src/JSON/parse.d.ts +44 -1
- package/types/src/Passage.d.ts +49 -4
- package/types/src/Story.d.ts +110 -16
- package/types/src/StoryFormat/compile.d.ts +8 -0
- package/types/src/StoryFormat/parse.d.ts +46 -3
- package/types/src/StoryFormat.d.ts +69 -38
- package/types/src/TWS/parse.d.ts +3 -3
- package/types/src/Twee/parse.d.ts +3 -4
- package/types/src/Twine1HTML/compile.d.ts +3 -1
- package/types/src/Twine1HTML/parse.d.ts +3 -4
- package/types/src/Twine2ArchiveHTML/compile.d.ts +8 -0
- package/types/src/Twine2ArchiveHTML/parse.d.ts +31 -1
- package/types/src/Twine2HTML/compile.d.ts +7 -2
- package/types/src/Twine2HTML/parse.d.ts +12 -9
- package/index.html +0 -22
- package/test/TWS/TWSParser/Example1.tws +0 -150
|
@@ -1,6 +1,36 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Parse
|
|
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
|
|
3
5
|
* @param {string} content - Content to parse for Twine 2 HTML elements.
|
|
6
|
+
* @throws {TypeError} - Content is not a string!
|
|
4
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
|
+
* // ]
|
|
5
35
|
*/
|
|
6
36
|
export function parse(content: string): any[];
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
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
|
|
3
5
|
* @param {Story} story - Story object to write.
|
|
4
6
|
* @param {StoryFormat} storyFormat - StoryFormat to write.
|
|
5
|
-
* @returns {string} Twine 2 HTML.
|
|
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.
|
|
6
11
|
*/
|
|
7
12
|
export function compile(story: Story, storyFormat: StoryFormat): string;
|
|
8
|
-
import Story from '../Story.js';
|
|
13
|
+
import { Story } from '../Story.js';
|
|
9
14
|
import StoryFormat from '../StoryFormat.js';
|
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
export default parse;
|
|
2
1
|
/**
|
|
3
2
|
* Parse Twine 2 HTML into Story object.
|
|
4
3
|
*
|
|
5
4
|
* See: Twine 2 HTML Output Specification
|
|
6
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
|
|
7
12
|
* @param {string} content - Twine 2 HTML content to parse.
|
|
8
|
-
* @returns {Story} Story
|
|
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!
|
|
9
18
|
*/
|
|
10
19
|
export function parse(content: string): Story;
|
|
11
|
-
|
|
12
|
-
* Try to escape Twine 2 meta-characters.
|
|
13
|
-
* @param {string} result - Text to parse.
|
|
14
|
-
* @returns {string} Escaped characters.
|
|
15
|
-
*/
|
|
16
|
-
export function escapeMetacharacters(result: string): string;
|
|
17
|
-
import Story from '../Story.js';
|
|
20
|
+
import { Story } from '../Story.js';
|
package/index.html
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<title>Document</title>
|
|
6
|
-
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
|
|
7
|
-
<meta name="description" content="Description">
|
|
8
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
|
|
9
|
-
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify@4/lib/themes/vue.css">
|
|
10
|
-
</head>
|
|
11
|
-
<body>
|
|
12
|
-
<div id="app"></div>
|
|
13
|
-
<script>
|
|
14
|
-
window.$docsify = {
|
|
15
|
-
name: '',
|
|
16
|
-
repo: ''
|
|
17
|
-
}
|
|
18
|
-
</script>
|
|
19
|
-
<!-- Docsify v4 -->
|
|
20
|
-
<script src="//cdn.jsdelivr.net/npm/docsify@4"></script>
|
|
21
|
-
</body>
|
|
22
|
-
</html>
|
|
@@ -1,150 +0,0 @@
|
|
|
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.
|