squiffy-compiler 6.0.0-alpha.1 → 6.0.0-alpha.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.
- package/dist/compiler.d.ts +3 -3
- package/dist/compiler.js +11 -9
- package/package.json +4 -3
package/dist/compiler.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const SQUIFFY_VERSION = "6.0.0-alpha.
|
|
1
|
+
export declare const SQUIFFY_VERSION = "6.0.0-alpha.2";
|
|
2
2
|
export interface Output {
|
|
3
3
|
story: OutputStory;
|
|
4
4
|
js: string[][];
|
|
@@ -23,7 +23,7 @@ interface OutputPassage {
|
|
|
23
23
|
jsIndex?: number;
|
|
24
24
|
}
|
|
25
25
|
interface CompilerSettings {
|
|
26
|
-
scriptBaseFilename
|
|
26
|
+
scriptBaseFilename?: string;
|
|
27
27
|
script: string;
|
|
28
28
|
onWarning?: (message: string) => void;
|
|
29
29
|
externalFiles?: ExternalFiles;
|
|
@@ -41,7 +41,7 @@ interface UiInfo {
|
|
|
41
41
|
export interface CompileSuccess {
|
|
42
42
|
success: true;
|
|
43
43
|
output: Output;
|
|
44
|
-
getJs: () => Promise<string>;
|
|
44
|
+
getJs: (excludeHeader?: boolean) => Promise<string>;
|
|
45
45
|
getUiInfo: () => UiInfo;
|
|
46
46
|
}
|
|
47
47
|
export interface CompileError {
|
package/dist/compiler.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import * as marked from 'marked';
|
|
2
|
-
export const SQUIFFY_VERSION = '6.0.0-alpha.
|
|
2
|
+
export const SQUIFFY_VERSION = '6.0.0-alpha.2';
|
|
3
3
|
export async function compile(settings) {
|
|
4
4
|
const story = new Story(settings.scriptBaseFilename);
|
|
5
5
|
const errors = [];
|
|
6
|
-
async function getJs(storyData) {
|
|
6
|
+
async function getJs(storyData, excludeHeader) {
|
|
7
7
|
const outputJs = [];
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
if (!excludeHeader) {
|
|
9
|
+
outputJs.push(`// Created with Squiffy ${SQUIFFY_VERSION}`);
|
|
10
|
+
outputJs.push('// https://github.com/textadventures/squiffy');
|
|
11
|
+
}
|
|
10
12
|
outputJs.push('export const story = {};');
|
|
11
13
|
outputJs.push(`story.id = ${JSON.stringify(storyData.story.id, null, 4)};`);
|
|
12
14
|
outputJs.push(`story.start = ${JSON.stringify(storyData.story.start, null, 4)};`);
|
|
@@ -334,11 +336,11 @@ export async function compile(settings) {
|
|
|
334
336
|
;
|
|
335
337
|
function writeJs(outputJsFile, tabCount, js) {
|
|
336
338
|
var tabs = new Array(tabCount + 1).join('\t');
|
|
337
|
-
outputJsFile.push(`${tabs}
|
|
339
|
+
outputJsFile.push(`${tabs}(squiffy, get, set) => {`);
|
|
338
340
|
for (const jsLine of js) {
|
|
339
|
-
outputJsFile.push(`${tabs}\t${jsLine}
|
|
341
|
+
outputJsFile.push(`${tabs}\t${jsLine}`);
|
|
340
342
|
}
|
|
341
|
-
outputJsFile.push(`${tabs}}
|
|
343
|
+
outputJsFile.push(`${tabs}},`);
|
|
342
344
|
}
|
|
343
345
|
;
|
|
344
346
|
const success = await processFileText(settings.script, settings.scriptBaseFilename, true);
|
|
@@ -347,8 +349,8 @@ export async function compile(settings) {
|
|
|
347
349
|
return {
|
|
348
350
|
success: true,
|
|
349
351
|
output: storyData,
|
|
350
|
-
getJs: () => {
|
|
351
|
-
return getJs(storyData);
|
|
352
|
+
getJs: (excludeHeader) => {
|
|
353
|
+
return getJs(storyData, excludeHeader || false);
|
|
352
354
|
},
|
|
353
355
|
getUiInfo: () => {
|
|
354
356
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "squiffy-compiler",
|
|
3
|
-
"version": "6.0.0-alpha.
|
|
3
|
+
"version": "6.0.0-alpha.3",
|
|
4
4
|
"description": "A tool for creating multiple-choice interactive stories",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"marked": "^13.0.2"
|
|
@@ -24,8 +24,9 @@
|
|
|
24
24
|
"vitest": "^2.1.1"
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
|
-
"test": "vitest",
|
|
28
|
-
"build": "tsc"
|
|
27
|
+
"test": "vitest --run",
|
|
28
|
+
"build": "tsc",
|
|
29
|
+
"prepublishOnly": "npm run build && npm run test"
|
|
29
30
|
},
|
|
30
31
|
"main": "dist/compiler.js",
|
|
31
32
|
"types": "dist/compiler.d.ts",
|