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/README.md CHANGED
@@ -1,3 +1,11 @@
1
- ## Local development
1
+ # squiffy-compiler
2
2
 
3
- `npm run dev -- examples/helloworld/helloworld.squiffy`
3
+ Compiles Squiffy story files into JavaScript. See [the main README](../README.md) and the [docs](https://squiffystory.com).
4
+
5
+ ## Tests
6
+
7
+ ```bash
8
+ npm test
9
+ ```
10
+
11
+ `test/fixtures/` has a small story for each feature. `compiler.test.ts` compiles each of them, and the complete stories in `../examples`, and compares the output with its snapshots. The fixtures have no `squiffy.json`, so they use Squiffy 6's rules for setters. `warnings/` has stories that should produce warnings.
@@ -0,0 +1,96 @@
1
+ import type { Diagnostic, PassageNode, Range, SectionNode, SquiffyFile } from "./syntax.js";
2
+ import { SourceLine } from "./text.js";
3
+ export interface ExternalFiles {
4
+ getMatchingFilenames(pattern: string): Promise<string[]>;
5
+ getContent(filename: string): Promise<string>;
6
+ getLocalFilename(filename: string): string;
7
+ }
8
+ export interface AnalyseSettings {
9
+ scriptBaseFilename?: string;
10
+ script: string;
11
+ externalFiles?: ExternalFiles;
12
+ parseCache?: ParseCache;
13
+ recover?: boolean;
14
+ storyFiles?: string[];
15
+ expressions?: boolean;
16
+ }
17
+ export declare class ParseCache {
18
+ private files;
19
+ parse(text: string, filename?: string): SquiffyFile;
20
+ }
21
+ export interface SectionSymbol {
22
+ name: string;
23
+ file: string;
24
+ node?: SectionNode;
25
+ passages: PassageSymbol[];
26
+ }
27
+ export interface PassageSymbol {
28
+ name: string;
29
+ node: PassageNode;
30
+ }
31
+ export interface Analysis {
32
+ success: boolean;
33
+ files: SquiffyFile[];
34
+ diagnostics: Diagnostic[];
35
+ sections: SectionSymbol[];
36
+ start: string;
37
+ expressions: boolean;
38
+ stylesheets: string[];
39
+ scripts: string[];
40
+ }
41
+ export declare class Story {
42
+ sections: Record<string, Section>;
43
+ title: string;
44
+ scripts: string[];
45
+ stylesheets: string[];
46
+ start: string;
47
+ id: string | null;
48
+ uiJs: string[];
49
+ constructor();
50
+ addSection(name: string, filename: string | undefined, line: number, node: SectionNode | undefined): Section;
51
+ }
52
+ declare class TextContainer {
53
+ text: string[];
54
+ textSources: SourceLine[];
55
+ js: string[];
56
+ clear: boolean;
57
+ attributes: string[];
58
+ music?: string | null;
59
+ sounds: string[];
60
+ classes: string[];
61
+ tags: string[];
62
+ transition?: string;
63
+ transitionTime?: number;
64
+ leave?: string;
65
+ leaveTime?: number;
66
+ leaveNode?: {
67
+ filename: string | undefined;
68
+ range: Range;
69
+ };
70
+ output: string;
71
+ addText(text: string, source: SourceLine): void;
72
+ }
73
+ export declare class Section extends TextContainer {
74
+ name: string;
75
+ filename: string | undefined;
76
+ line: number;
77
+ node: SectionNode | undefined;
78
+ passages: Record<string, Passage>;
79
+ constructor(name: string, filename: string | undefined, line: number, node: SectionNode | undefined);
80
+ addPassage(name: string, line: number, node: PassageNode): Passage;
81
+ }
82
+ export declare class Passage extends TextContainer {
83
+ name: string;
84
+ line: number;
85
+ node: PassageNode;
86
+ repeat: boolean;
87
+ constructor(name: string, line: number, node: PassageNode);
88
+ }
89
+ export interface AnalysisInternals {
90
+ story: Story;
91
+ legacyErrors: string[];
92
+ legacyWarnings: string[];
93
+ }
94
+ export declare const analysisInternals: WeakMap<Analysis, AnalysisInternals>;
95
+ export declare function analyse(settings: AnalyseSettings): Promise<Analysis>;
96
+ export {};