squiffy-compiler 6.0.1 → 7.0.0-beta.11

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.
Files changed (62) hide show
  1. package/README.md +10 -2
  2. package/dist/analyse.d.ts +96 -0
  3. package/dist/analyse.js +951 -0
  4. package/dist/compiler.d.ts +32 -40
  5. package/dist/compiler.js +26 -691
  6. package/dist/css-urls.d.ts +4 -0
  7. package/dist/css-urls.js +59 -0
  8. package/dist/emit.d.ts +71 -0
  9. package/dist/emit.js +192 -0
  10. package/dist/helpers.d.ts +1 -0
  11. package/dist/helpers.js +14 -0
  12. package/dist/ignore.d.ts +8 -0
  13. package/dist/ignore.js +71 -0
  14. package/dist/infix-expressions.d.ts +19 -0
  15. package/dist/infix-expressions.js +713 -0
  16. package/dist/language-service.d.ts +90 -0
  17. package/dist/language-service.js +883 -0
  18. package/dist/node.d.ts +23 -0
  19. package/dist/node.js +122 -0
  20. package/dist/parse.d.ts +22 -0
  21. package/dist/parse.js +316 -0
  22. package/dist/project.d.ts +129 -0
  23. package/dist/project.js +488 -0
  24. package/dist/quest/aslx.d.ts +51 -0
  25. package/dist/quest/aslx.js +184 -0
  26. package/dist/quest/convert.d.ts +20 -0
  27. package/dist/quest/convert.js +552 -0
  28. package/dist/quest/script.d.ts +92 -0
  29. package/dist/quest/script.js +453 -0
  30. package/dist/quest/scripts.d.ts +24 -0
  31. package/dist/quest/scripts.js +506 -0
  32. package/dist/quest/text.d.ts +18 -0
  33. package/dist/quest/text.js +323 -0
  34. package/dist/section-labels.d.ts +4 -0
  35. package/dist/section-labels.js +64 -0
  36. package/dist/setters.d.ts +49 -0
  37. package/dist/setters.js +477 -0
  38. package/dist/story-graph.d.ts +71 -0
  39. package/dist/story-graph.js +445 -0
  40. package/dist/syntax.d.ts +198 -0
  41. package/dist/syntax.js +8 -0
  42. package/dist/templates.d.ts +17 -0
  43. package/dist/templates.js +180 -0
  44. package/dist/text.d.ts +44 -0
  45. package/dist/text.js +348 -0
  46. package/dist/twine/audio.d.ts +21 -0
  47. package/dist/twine/audio.js +80 -0
  48. package/dist/twine/convert.d.ts +131 -0
  49. package/dist/twine/convert.js +1057 -0
  50. package/dist/twine/expression.d.ts +88 -0
  51. package/dist/twine/expression.js +318 -0
  52. package/dist/twine/harlowe.d.ts +27 -0
  53. package/dist/twine/harlowe.js +2341 -0
  54. package/dist/twine/settings.d.ts +9 -0
  55. package/dist/twine/settings.js +322 -0
  56. package/dist/twine/story.d.ts +24 -0
  57. package/dist/twine/story.js +231 -0
  58. package/dist/twine/sugarcube.d.ts +40 -0
  59. package/dist/twine/sugarcube.js +2172 -0
  60. package/dist/v5.js +2 -1
  61. package/package.json +35 -6
  62. package/syntaxes/squiffy.tmLanguage.json +1003 -0
package/dist/node.d.ts ADDED
@@ -0,0 +1,23 @@
1
+ import { type PageStrings, type Panel, type PlayerSetting } from "./project.js";
2
+ export interface StoryOnDisk {
3
+ mainFile: string;
4
+ storyFiles?: string[];
5
+ projectFile?: string;
6
+ note?: string;
7
+ expressions: boolean;
8
+ backButton?: boolean;
9
+ strings?: PageStrings;
10
+ saveButton?: boolean;
11
+ projectId?: string;
12
+ panels?: Panel[];
13
+ settings?: PlayerSetting[];
14
+ persistent?: string[];
15
+ }
16
+ export declare class StoryNotFoundError extends Error {
17
+ }
18
+ export interface FindStoryOptions {
19
+ skip?: string[];
20
+ }
21
+ export declare const listSquiffyFiles: (folder: string) => Promise<string[]>;
22
+ export declare const listStoryFiles: (folder: string) => Promise<string[]>;
23
+ export declare function findStory(input: string, options?: FindStoryOptions): Promise<StoryOnDisk>;
package/dist/node.js ADDED
@@ -0,0 +1,122 @@
1
+ /// <reference types="node" />
2
+ // Finding a story on disk, for the CLI and the Vite plugin. This is the only part of the compiler
3
+ // that touches the file system, and it's a separate entry point (squiffy-compiler/node), so the
4
+ // rest of the compiler stays free of Node dependencies.
5
+ import fs from "fs/promises";
6
+ import path from "path";
7
+ import { getStoryFiles, isAlwaysSkipped, isSquiffyPath, isStoryFilePath, parseProjectFile, PROJECT_FILENAME, storyFileList, } from "./project.js";
8
+ // A problem finding the story, with a message to show the author as is
9
+ export class StoryNotFoundError extends Error {
10
+ }
11
+ const exists = async (filename) => {
12
+ try {
13
+ await fs.access(filename);
14
+ return true;
15
+ }
16
+ catch {
17
+ return false;
18
+ }
19
+ };
20
+ const isDirectory = async (filename) => {
21
+ try {
22
+ return (await fs.stat(filename)).isDirectory();
23
+ }
24
+ catch {
25
+ return false;
26
+ }
27
+ };
28
+ // The nearest squiffy.json in a folder or the folders above it
29
+ async function findProjectFile(folder) {
30
+ for (let dir = path.resolve(folder);; dir = path.dirname(dir)) {
31
+ const candidate = path.join(dir, PROJECT_FILENAME);
32
+ if (await exists(candidate))
33
+ return candidate;
34
+ if (path.dirname(dir) == dir)
35
+ return undefined;
36
+ }
37
+ }
38
+ // Every .squiffy file in a folder and its subfolders, relative to it with "/" separators, without
39
+ // looking inside the folders that are never part of a story.
40
+ export const listSquiffyFiles = (folder) => listFiles(folder, isSquiffyPath);
41
+ // Every .squiffy, .css and .js file in a folder and its subfolders, as listSquiffyFiles, and any
42
+ // index.html, which getStoryFiles needs to see to leave out an old build
43
+ export const listStoryFiles = (folder) => listFiles(folder, name => isStoryFilePath(name) || name == "index.html");
44
+ async function listFiles(folder, include) {
45
+ const result = [];
46
+ const walk = async (relative) => {
47
+ const entries = await fs.readdir(path.join(folder, relative), { withFileTypes: true });
48
+ for (const entry of entries) {
49
+ const child = relative ? `${relative}/${entry.name}` : entry.name;
50
+ if (entry.isDirectory()) {
51
+ if (!isAlwaysSkipped(`${child}/x`))
52
+ await walk(child);
53
+ }
54
+ else if (include(entry.name)) {
55
+ result.push(child);
56
+ }
57
+ }
58
+ };
59
+ await walk("");
60
+ return result;
61
+ }
62
+ async function readProject(projectFile) {
63
+ const parsed = parseProjectFile(await fs.readFile(projectFile, "utf8"));
64
+ if (!parsed.success) {
65
+ throw new StoryNotFoundError(`${parsed.error} (${projectFile})`);
66
+ }
67
+ return parsed.project;
68
+ }
69
+ async function folderStory(projectFile, options) {
70
+ const root = path.dirname(projectFile);
71
+ const project = await readProject(projectFile);
72
+ const mainFile = path.resolve(root, project.main);
73
+ if (!await exists(mainFile)) {
74
+ throw new StoryNotFoundError(`The main file in ${projectFile}, ${project.main}, doesn't exist.`);
75
+ }
76
+ // Absolute paths to skip are made relative to the project, and any outside it are ignored
77
+ const skip = (options.skip ?? []).map(file => path.isAbsolute(file) ? path.relative(root, file).split(path.sep).join("/") : file)
78
+ .filter(file => file && !file.startsWith("..") && !path.isAbsolute(file));
79
+ const story = getStoryFiles(project, await listStoryFiles(root), skip);
80
+ return {
81
+ mainFile, storyFiles: storyFileList(story).map(file => path.resolve(root, file)), projectFile, expressions: true,
82
+ ...(project.backButton !== undefined ? { backButton: project.backButton } : {}),
83
+ ...(project.strings !== undefined ? { strings: project.strings } : {}),
84
+ ...(project.saveButton !== undefined ? { saveButton: project.saveButton } : {}),
85
+ ...(project.id !== undefined ? { projectId: project.id } : {}),
86
+ ...(project.panels !== undefined ? { panels: project.panels } : {}),
87
+ ...(project.settings !== undefined ? { settings: project.settings } : {}),
88
+ ...(project.persistent !== undefined ? { persistent: project.persistent } : {}),
89
+ };
90
+ }
91
+ // Finds the story to build from what the author gave: a folder with a squiffy.json in it, or a
92
+ // .squiffy file.
93
+ //
94
+ // - A folder builds the project in its squiffy.json.
95
+ // - A project's main file (with a squiffy.json in its folder or above) builds the project.
96
+ // - Any other .squiffy file builds just that file and its @imports, as it would with no
97
+ // squiffy.json, with a note saying so. So several stories can share a folder.
98
+ export async function findStory(input, options = {}) {
99
+ const resolved = path.resolve(input);
100
+ if (await isDirectory(resolved)) {
101
+ const projectFile = path.join(resolved, PROJECT_FILENAME);
102
+ if (!await exists(projectFile)) {
103
+ throw new StoryNotFoundError(`There's no ${PROJECT_FILENAME} in ${resolved}. Give the story's .squiffy file instead, or add a ${PROJECT_FILENAME} to make the folder one story.`);
104
+ }
105
+ return folderStory(projectFile, options);
106
+ }
107
+ if (!await exists(resolved)) {
108
+ throw new StoryNotFoundError(`${input} doesn't exist.`);
109
+ }
110
+ const projectFile = await findProjectFile(path.dirname(resolved));
111
+ if (!projectFile)
112
+ return { mainFile: resolved, expressions: false };
113
+ const project = await readProject(projectFile);
114
+ if (path.resolve(path.dirname(projectFile), project.main) == resolved) {
115
+ return folderStory(projectFile, options);
116
+ }
117
+ return {
118
+ mainFile: resolved,
119
+ note: `Building just ${path.basename(resolved)}, as it isn't the main file in ${projectFile} (${project.main}).`,
120
+ expressions: true,
121
+ };
122
+ }
@@ -0,0 +1,22 @@
1
+ import type { SquiffyFile } from "./syntax.js";
2
+ export declare const lineRegexes: {
3
+ section: RegExp;
4
+ snippet: RegExp;
5
+ passage: RegExp;
6
+ title: RegExp;
7
+ import: RegExp;
8
+ start: RegExp;
9
+ attributes: RegExp;
10
+ unset: RegExp;
11
+ inc: RegExp;
12
+ dec: RegExp;
13
+ js: RegExp;
14
+ continue: RegExp;
15
+ ui: RegExp;
16
+ music: RegExp;
17
+ sound: RegExp;
18
+ class: RegExp;
19
+ tag: RegExp;
20
+ transition: RegExp;
21
+ };
22
+ export declare function parse(text: string, filename?: string): SquiffyFile;
package/dist/parse.js ADDED
@@ -0,0 +1,316 @@
1
+ import { positionMapper, transformText } from "./text.js";
2
+ export const lineRegexes = {
3
+ section: /^\[\[(.*)\]\]:$/,
4
+ snippet: /^\[snippet:\s*(.+)\]:$/,
5
+ passage: /^\[(.*)\]:$/,
6
+ title: /^@title (.*)$/,
7
+ import: /^@import (.*)$/,
8
+ start: /^@start (.*)$/,
9
+ attributes: /^@set (.*)$/,
10
+ unset: /^@unset (.*)$/,
11
+ inc: /^@inc (\S+)(?: (\d+))?$/,
12
+ dec: /^@dec (\S+)(?: (\d+))?$/,
13
+ js: /^(\t| {4})(.*)$/,
14
+ continue: /^\+\+\+(.*)$/,
15
+ ui: /^@ui (.*)$/,
16
+ music: /^@music (.*)$/,
17
+ sound: /^@sound (.*)$/,
18
+ class: /^@class (.*)$/,
19
+ tag: /^@tag (.*)$/,
20
+ transition: /^@(transition|leave) (\S+)(?: (\S+))?$/,
21
+ };
22
+ // Parses one .squiffy file into a syntax tree. This never fails: problems such as a passage
23
+ // with no section are reported by analyse(), which knows how the file fits into the story.
24
+ //
25
+ // Each line is classified exactly as the compiler always has (see the if/else chain below,
26
+ // whose order matters). The tree is grouped as if this is the story's main file: in an imported
27
+ // file, content before the first section is ignored, and analyse() deals with that.
28
+ export function parse(text, filename) {
29
+ const lines = text.replace(/\r/g, "").split("\n");
30
+ const lineRange = (line) => ({
31
+ start: { line, character: 0 },
32
+ end: { line, character: lines[line].length },
33
+ });
34
+ // The range of a substring of a line, found by searching from the end, since every
35
+ // value this is used for runs to the end of the (trimmed) line.
36
+ const valueRange = (line, value) => {
37
+ const trimmedEnd = lines[line].trimEnd().length;
38
+ const start = Math.max(0, trimmedEnd - value.length);
39
+ return { start: { line, character: start }, end: { line, character: start + value.length } };
40
+ };
41
+ const nameRange = (line, name, prefix) => {
42
+ const lineText = lines[line];
43
+ const start = lineText.indexOf(name, lineText.indexOf(prefix) + prefix.length);
44
+ return { start: { line, character: start }, end: { line, character: start + name.length } };
45
+ };
46
+ const preamble = newSection("preamble", { start: { line: 0, character: 0 }, end: { line: 0, character: 0 } });
47
+ const file = {
48
+ type: "file",
49
+ filename,
50
+ range: { start: { line: 0, character: 0 }, end: { line: lines.length - 1, character: lines[lines.length - 1].length } },
51
+ preamble,
52
+ sections: [],
53
+ };
54
+ let section = preamble;
55
+ let passage = null;
56
+ let snippet = null;
57
+ const snippetLines = [];
58
+ // Whether the compiler would have a current section at this point. In the main file, content
59
+ // before any section header creates the "_default" section.
60
+ let haveSection = false;
61
+ let textStarted = false;
62
+ let inUiBlock = false;
63
+ const endSnippet = () => {
64
+ if (snippet) {
65
+ snippet.content = snippetLines.join("\n");
66
+ snippetLines.length = 0;
67
+ snippet = null;
68
+ }
69
+ };
70
+ const startSection = (node) => {
71
+ endSnippet();
72
+ section = node;
73
+ passage = null;
74
+ file.sections.push(node);
75
+ };
76
+ const add = (node) => {
77
+ (passage ?? section).body.push(node);
78
+ };
79
+ for (let i = 0; i < lines.length; i++) {
80
+ const line = lines[i];
81
+ const stripLine = line.trim();
82
+ const range = lineRange(i);
83
+ const match = {};
84
+ for (const key of Object.keys(lineRegexes)) {
85
+ const result = lineRegexes[key].exec(key == "js" ? line : stripLine);
86
+ if (result) {
87
+ match[key] = result;
88
+ }
89
+ }
90
+ if (match.snippet) {
91
+ endSnippet();
92
+ const name = match.snippet[1];
93
+ snippet = {
94
+ type: "snippet",
95
+ name,
96
+ nameRange: nameRange(i, name, "snippet:"),
97
+ header: { type: "snippet-header", name, range },
98
+ range,
99
+ content: "",
100
+ };
101
+ file.sections.push(snippet);
102
+ passage = null;
103
+ haveSection = false;
104
+ textStarted = false;
105
+ }
106
+ else if (match.section) {
107
+ const name = match.section[1];
108
+ const node = newSection("named", range);
109
+ node.name = name;
110
+ node.nameRange = nameRange(i, name, "[[");
111
+ node.header = { type: "section-header", name, range };
112
+ startSection(node);
113
+ haveSection = true;
114
+ textStarted = false;
115
+ }
116
+ else if (snippet) {
117
+ snippetLines.push(line);
118
+ }
119
+ else if (match.passage) {
120
+ const name = match.passage[1];
121
+ const header = { type: "passage-header", name, range };
122
+ passage = {
123
+ type: "passage",
124
+ name,
125
+ nameRange: nameRange(i, name, "["),
126
+ header,
127
+ range,
128
+ body: [],
129
+ links: [],
130
+ embeds: [],
131
+ gotos: [], deactivates: [],
132
+ };
133
+ section.passages.push(passage);
134
+ textStarted = false;
135
+ }
136
+ else if (match.continue) {
137
+ const node = newSection("continue", range);
138
+ node.header = { type: "continue", text: match.continue[1], range };
139
+ startSection(node);
140
+ haveSection = true;
141
+ textStarted = false;
142
+ }
143
+ else if (stripLine == "---") {
144
+ inUiBlock = false;
145
+ if (!haveSection) {
146
+ add({ type: "separator", range });
147
+ }
148
+ else {
149
+ const node = newSection("separator", range);
150
+ node.header = { type: "separator", range };
151
+ startSection(node);
152
+ textStarted = false;
153
+ }
154
+ }
155
+ else if (stripLine == "@ui") {
156
+ inUiBlock = true;
157
+ add({ type: "ui-block-start", range });
158
+ }
159
+ else if (match.ui) {
160
+ add({ type: "ui-file", path: match.ui[1], pathRange: valueRange(i, match.ui[1]), range });
161
+ }
162
+ else if (stripLine == "@clear") {
163
+ if (!passage)
164
+ haveSection = true;
165
+ add({ type: "clear", range });
166
+ }
167
+ else if (stripLine == "@repeat") {
168
+ add({ type: "repeat", range });
169
+ }
170
+ else if (stripLine == "@end") {
171
+ if (!passage)
172
+ haveSection = true;
173
+ add({ type: "end", range });
174
+ }
175
+ else if (match.title) {
176
+ add({ type: "title", value: match.title[1], valueRange: valueRange(i, match.title[1]), range });
177
+ }
178
+ else if (match.start) {
179
+ add({ type: "start", value: match.start[1], valueRange: valueRange(i, match.start[1]), range });
180
+ }
181
+ else if (match.import) {
182
+ add({ type: "import", pattern: match.import[1], patternRange: valueRange(i, match.import[1]), range });
183
+ }
184
+ else if (match.music || match.sound) {
185
+ if (!passage)
186
+ haveSection = true;
187
+ const value = (match.music ?? match.sound)[1];
188
+ add({ type: "sound", directive: match.music ? "music" : "sound", value, valueRange: valueRange(i, value), range });
189
+ }
190
+ else if (match.class) {
191
+ if (!passage)
192
+ haveSection = true;
193
+ add({ type: "class", value: match.class[1], valueRange: valueRange(i, match.class[1]), range });
194
+ }
195
+ else if (match.tag) {
196
+ if (!passage)
197
+ haveSection = true;
198
+ add({ type: "tag", value: match.tag[1], valueRange: valueRange(i, match.tag[1]), range });
199
+ }
200
+ else if (match.transition) {
201
+ if (!passage)
202
+ haveSection = true;
203
+ const [, directive, value, time] = match.transition;
204
+ const start = line.indexOf(value, line.indexOf("@") + directive.length + 1);
205
+ add({
206
+ type: "transition",
207
+ directive: directive,
208
+ value,
209
+ valueRange: { start: { line: i, character: start }, end: { line: i, character: start + value.length } },
210
+ ...(time === undefined ? {} : { time }),
211
+ range,
212
+ });
213
+ }
214
+ else if (match.attributes || match.unset) {
215
+ haveSection = true;
216
+ const value = (match.attributes ?? match.unset)[1];
217
+ add({ type: "attribute", directive: match.attributes ? "set" : "unset", value, valueRange: valueRange(i, value), range });
218
+ }
219
+ else if (match.inc || match.dec) {
220
+ haveSection = true;
221
+ const m = (match.inc ?? match.dec);
222
+ const value = m[1];
223
+ const start = line.indexOf(value, line.indexOf("@") + 4);
224
+ add({
225
+ type: "attribute",
226
+ directive: match.inc ? "inc" : "dec",
227
+ value,
228
+ valueRange: { start: { line: i, character: start }, end: { line: i, character: start + value.length } },
229
+ ...(m[2] === undefined ? {} : { amount: m[2] }),
230
+ range,
231
+ });
232
+ }
233
+ else if (!textStarted && match.js) {
234
+ if (!inUiBlock && !passage)
235
+ haveSection = true;
236
+ const indent = match.js[1].length;
237
+ add({
238
+ type: "js",
239
+ code: match.js[2],
240
+ codeRange: { start: { line: i, character: indent }, end: { line: i, character: line.length } },
241
+ range,
242
+ });
243
+ }
244
+ else if (textStarted || stripLine.length > 0) {
245
+ add({ type: "text", text: line, range });
246
+ if (!inUiBlock) {
247
+ if (!passage)
248
+ haveSection = true;
249
+ textStarted = true;
250
+ }
251
+ }
252
+ // Otherwise it's a blank line before any text, which is ignored.
253
+ const end = range.end;
254
+ if (snippet)
255
+ snippet.range = { start: snippet.range.start, end };
256
+ else {
257
+ section.range = { start: section.range.start, end };
258
+ if (passage)
259
+ passage.range = { start: passage.range.start, end };
260
+ }
261
+ }
262
+ endSnippet();
263
+ for (const s of [preamble, ...file.sections]) {
264
+ if (s.type != "section")
265
+ continue;
266
+ findLinks(s, lines);
267
+ for (const p of s.passages) {
268
+ findLinks(p, lines);
269
+ }
270
+ }
271
+ return file;
272
+ }
273
+ function newSection(kind, range) {
274
+ return { type: "section", kind, range, body: [], passages: [], links: [], embeds: [], gotos: [], deactivates: [] };
275
+ }
276
+ // Fills in the links, embeds and gotos in a section's or passage's text.
277
+ function findLinks(node, lines) {
278
+ const textNodes = node.body.filter((n) => n.type == "text");
279
+ if (!textNodes.length)
280
+ return;
281
+ const sources = textNodes.map(n => ({ line: n.range.start.line, length: lines[n.range.start.line].length }));
282
+ const toPosition = positionMapper(sources, textNodes.map(n => n.text.length));
283
+ const toRange = (start, end) => ({ start: toPosition(start), end: toPosition(end) });
284
+ // Which section comes next isn't known until the story is analysed, but all that matters
285
+ // here is that there is one, so that [[text>]] is treated as a link. Link
286
+ // targets can have brackets in them, as in a story with a squiffy.json, whether or not this
287
+ // one has one: the two only differ when a target has a "(" in it.
288
+ const result = transformText(textNodes.map(n => n.text).join("\n"), () => "", true);
289
+ node.links = result.links.map((link) => ({
290
+ type: "link",
291
+ linkType: link.linkType,
292
+ form: link.form,
293
+ ...(link.text === undefined ? {} : { text: link.text }),
294
+ target: link.target,
295
+ range: toRange(link.start, link.end),
296
+ targetRange: toRange(link.targetStart, link.targetEnd),
297
+ }));
298
+ node.embeds = result.embeds.map((embed) => ({
299
+ type: "embed",
300
+ name: embed.name,
301
+ range: toRange(embed.start, embed.end),
302
+ nameRange: toRange(embed.nameStart, embed.nameEnd),
303
+ }));
304
+ node.gotos = result.gotos.map((goto) => ({
305
+ type: "goto",
306
+ name: goto.name,
307
+ range: toRange(goto.start, goto.end),
308
+ nameRange: toRange(goto.nameStart, goto.nameEnd),
309
+ }));
310
+ node.deactivates = result.deactivates.map((deactivate) => ({
311
+ type: "deactivate",
312
+ name: deactivate.name,
313
+ range: toRange(deactivate.start, deactivate.end),
314
+ nameRange: toRange(deactivate.nameStart, deactivate.nameEnd),
315
+ }));
316
+ }
@@ -0,0 +1,129 @@
1
+ export declare const PROJECT_FILENAME = "squiffy.json";
2
+ export declare const PROJECT_FILE_VERSION = 1;
3
+ export declare const PROJECT_SCHEMA_URL = "https://squiffystory.com/schema/squiffy.json";
4
+ export interface ProjectFile {
5
+ version: number;
6
+ id?: string;
7
+ main: string;
8
+ exclude: string[];
9
+ map?: MapPositions;
10
+ backButton?: boolean;
11
+ saveButton?: boolean;
12
+ strings?: PageStrings;
13
+ panels?: Panel[];
14
+ settings?: PlayerSetting[];
15
+ persistent?: string[];
16
+ }
17
+ export type PlayerSetting = PlayerSettingBase & {
18
+ type: "toggle";
19
+ default?: boolean;
20
+ } | PlayerSettingBase & {
21
+ type: "list";
22
+ options: PlayerSettingOption[];
23
+ default?: string;
24
+ } | PlayerSettingBase & {
25
+ type: "range";
26
+ min: number;
27
+ max: number;
28
+ step?: number;
29
+ default?: number;
30
+ };
31
+ interface PlayerSettingBase {
32
+ name: string;
33
+ label: string;
34
+ description?: string;
35
+ }
36
+ export interface PlayerSettingOption {
37
+ value: string;
38
+ label: string;
39
+ }
40
+ export declare const PLAYER_SETTING_TYPES: readonly ["toggle", "list", "range"];
41
+ export declare const PANEL_ICONS: readonly ["bag", "person", "map", "help", "info", "list", "book", "star", "heart"];
42
+ export type PanelIcon = typeof PANEL_ICONS[number];
43
+ export interface Panel {
44
+ passage: string;
45
+ label: string;
46
+ position?: "side" | "button";
47
+ icon?: PanelIcon;
48
+ }
49
+ export type PageStringName = keyof typeof PAGE_STRINGS;
50
+ export type PageStrings = Partial<Record<PageStringName, string>>;
51
+ export declare const PAGE_STRINGS: {
52
+ back: string;
53
+ restart: string;
54
+ restartConfirm: string;
55
+ switchToDark: string;
56
+ switchToLight: string;
57
+ mute: string;
58
+ unmute: string;
59
+ saves: string;
60
+ saveName: string;
61
+ save: string;
62
+ noSaves: string;
63
+ savedGame: string;
64
+ savedToday: string;
65
+ savedYesterday: string;
66
+ load: string;
67
+ loadConfirm: string;
68
+ saveOptions: string;
69
+ overwrite: string;
70
+ overwriteConfirm: string;
71
+ rename: string;
72
+ newName: string;
73
+ saveToFile: string;
74
+ loadFromFile: string;
75
+ delete: string;
76
+ deleteConfirm: string;
77
+ cancel: string;
78
+ close: string;
79
+ wrongStory: string;
80
+ notASave: string;
81
+ cantSave: string;
82
+ settings: string;
83
+ resetSettings: string;
84
+ };
85
+ export interface MapPositions {
86
+ sections: Record<string, [number, number]>;
87
+ passages: Record<string, Record<string, [number, number]>>;
88
+ }
89
+ export type ParsedProjectFile = {
90
+ success: true;
91
+ project: ProjectFile;
92
+ } | {
93
+ success: false;
94
+ error: string;
95
+ };
96
+ export declare function parseProjectFile(text: string): ParsedProjectFile;
97
+ export declare function globToRegExp(pattern: string): RegExp;
98
+ export declare function isExcluded(path: string, exclude: string[]): boolean;
99
+ export declare function isAlwaysSkipped(path: string): boolean;
100
+ export declare const BUILD_FOLDER = "build";
101
+ export declare const isSquiffyPath: (path: string) => boolean;
102
+ export declare const isStylesheetPath: (path: string) => boolean;
103
+ export declare const isScriptPath: (path: string) => boolean;
104
+ export declare const isStoryFilePath: (path: string) => boolean;
105
+ export interface StoryFiles {
106
+ main: string;
107
+ included: string[];
108
+ stylesheets: string[];
109
+ scripts: string[];
110
+ excluded: string[];
111
+ }
112
+ export declare const comparePaths: (a: string, b: string) => 1 | 0 | -1;
113
+ export declare function getStoryFiles(project: ProjectFile, paths: Iterable<string>, skip?: string[]): StoryFiles;
114
+ export declare const storyFileList: (story: StoryFiles) => string[];
115
+ export declare function formatProjectFile(project: {
116
+ main: string;
117
+ exclude?: string[];
118
+ map?: MapPositions;
119
+ id?: string;
120
+ panels?: Panel[];
121
+ settings?: PlayerSetting[];
122
+ persistent?: string[];
123
+ }): string;
124
+ export declare function updateProjectFile(text: string, changes: {
125
+ main?: string;
126
+ exclude?: string[];
127
+ map?: MapPositions;
128
+ }): string | undefined;
129
+ export {};