squiffy-compiler 6.0.0-alpha.1 → 6.0.0-alpha.15

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/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014-2024 Alex Warren, textadventures.co.uk and contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
@@ -1,4 +1,4 @@
1
- export declare const SQUIFFY_VERSION = "6.0.0-alpha.0";
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: string;
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.0';
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
- outputJs.push(`// Created with Squiffy ${SQUIFFY_VERSION}`);
9
- outputJs.push('// https://github.com/textadventures/squiffy');
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}function() {\n`);
339
+ outputJsFile.push(`${tabs}(squiffy, get, set) => {`);
338
340
  for (const jsLine of js) {
339
- outputJsFile.push(`${tabs}\t${jsLine}\n`);
341
+ outputJsFile.push(`${tabs}\t${jsLine}`);
340
342
  }
341
- outputJsFile.push(`${tabs}},\n`);
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,9 +1,9 @@
1
1
  {
2
2
  "name": "squiffy-compiler",
3
- "version": "6.0.0-alpha.1",
3
+ "version": "6.0.0-alpha.15",
4
4
  "description": "A tool for creating multiple-choice interactive stories",
5
5
  "dependencies": {
6
- "marked": "^13.0.2"
6
+ "marked": "^16.1.2"
7
7
  },
8
8
  "author": "Alex Warren",
9
9
  "contributors": [
@@ -18,19 +18,21 @@
18
18
  "license": "MIT",
19
19
  "preferGlobal": true,
20
20
  "devDependencies": {
21
- "@types/node": "^22.5.5",
22
- "glob": "^11.0.0",
23
- "typescript": "^5.6.2",
24
- "vitest": "^2.1.1"
21
+ "@types/node": "^24.3.0",
22
+ "glob": "^11.0.3",
23
+ "typescript": "^5.9.2",
24
+ "vitest": "^3.2.4"
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",
32
33
  "files": [
33
34
  "dist"
34
35
  ],
35
- "type": "module"
36
+ "type": "module",
37
+ "gitHead": "a326d226beb6121dcdf528e97d287deba553fe39"
36
38
  }