questmark 0.0.24 → 0.0.29
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/cjs/QuestVM.d.ts +2 -1
- package/dist/cjs/parseMarkdown.js +38 -39
- package/dist/mjs/QuestVM.d.ts +2 -1
- package/dist/mjs/parseMarkdown.js +1 -2
- package/package.json +2 -2
package/dist/cjs/QuestVM.d.ts
CHANGED
|
@@ -13,8 +13,7 @@ const unist_util_visit_parents_1 = __importDefault(require("unist-util-visit-par
|
|
|
13
13
|
const unist_util_visit_1 = __importDefault(require("unist-util-visit"));
|
|
14
14
|
const unist_builder_1 = __importDefault(require("unist-builder"));
|
|
15
15
|
require("array-flat-polyfill");
|
|
16
|
-
const tzo_1 =
|
|
17
|
-
const { Tokenizer, pushString, pushNumber, invokeFunction } = tzo_1.default;
|
|
16
|
+
const tzo_1 = require("tzo");
|
|
18
17
|
var NoLinkBehaviour;
|
|
19
18
|
(function (NoLinkBehaviour) {
|
|
20
19
|
NoLinkBehaviour[NoLinkBehaviour["EXIT"] = 0] = "EXIT";
|
|
@@ -22,7 +21,7 @@ var NoLinkBehaviour;
|
|
|
22
21
|
})(NoLinkBehaviour = exports.NoLinkBehaviour || (exports.NoLinkBehaviour = {}));
|
|
23
22
|
function parseMarkdown(file_contents) {
|
|
24
23
|
const tree = mdast_util_from_markdown_1.default(file_contents);
|
|
25
|
-
const tokenizer = new Tokenizer();
|
|
24
|
+
const tokenizer = new tzo_1.Tokenizer();
|
|
26
25
|
const root = unist_builder_1.default('questmarkDocument', { options: {} }, []);
|
|
27
26
|
let last_once_directive_nr = 0;
|
|
28
27
|
let noLinkBehaviour = NoLinkBehaviour.LOOPBACK_TO_OPTIONS;
|
|
@@ -195,18 +194,18 @@ function parseMarkdown(file_contents) {
|
|
|
195
194
|
if (node.options["initial-context"]) {
|
|
196
195
|
Object.entries(node.options["initial-context"]).forEach(entry => {
|
|
197
196
|
if (typeof entry[1] === "string") {
|
|
198
|
-
q(pushString(entry[1]));
|
|
197
|
+
q(tzo_1.pushString(entry[1]));
|
|
199
198
|
}
|
|
200
199
|
else if (typeof entry[1] === "number") {
|
|
201
|
-
q(pushNumber(entry[1]));
|
|
200
|
+
q(tzo_1.pushNumber(entry[1]));
|
|
202
201
|
}
|
|
203
|
-
q(pushString(entry[0]));
|
|
204
|
-
q(invokeFunction("setContext"));
|
|
202
|
+
q(tzo_1.pushString(entry[0]));
|
|
203
|
+
q(tzo_1.invokeFunction("setContext"));
|
|
205
204
|
});
|
|
206
205
|
}
|
|
207
206
|
if (node.options["initial-state"]) {
|
|
208
|
-
q(pushString(node.options["initial-state"]));
|
|
209
|
-
q(invokeFunction("goto"));
|
|
207
|
+
q(tzo_1.pushString(node.options["initial-state"]));
|
|
208
|
+
q(tzo_1.invokeFunction("goto"));
|
|
210
209
|
}
|
|
211
210
|
if (node.options["options"]) {
|
|
212
211
|
if (node.options["options"]["no_link_behaviour"]) {
|
|
@@ -244,10 +243,10 @@ function parseMarkdown(file_contents) {
|
|
|
244
243
|
last_once_directive_nr += 1;
|
|
245
244
|
}
|
|
246
245
|
if (has_once_directive) {
|
|
247
|
-
q(pushString(once_directive_name));
|
|
248
|
-
q(invokeFunction("hasContext"));
|
|
249
|
-
q(invokeFunction("jz"));
|
|
250
|
-
q(invokeFunction("{")); // once directive block start
|
|
246
|
+
q(tzo_1.pushString(once_directive_name));
|
|
247
|
+
q(tzo_1.invokeFunction("hasContext"));
|
|
248
|
+
q(tzo_1.invokeFunction("jz"));
|
|
249
|
+
q(tzo_1.invokeFunction("{")); // once directive block start
|
|
251
250
|
}
|
|
252
251
|
if (option.preconditionChildren !== null) {
|
|
253
252
|
has_precondition = true;
|
|
@@ -261,25 +260,25 @@ function parseMarkdown(file_contents) {
|
|
|
261
260
|
});
|
|
262
261
|
}
|
|
263
262
|
if (has_precondition) {
|
|
264
|
-
q(invokeFunction("jgz"));
|
|
265
|
-
q(invokeFunction("{")); // precondition block start
|
|
263
|
+
q(tzo_1.invokeFunction("jgz"));
|
|
264
|
+
q(tzo_1.invokeFunction("{")); // precondition block start
|
|
266
265
|
}
|
|
267
266
|
if (option.text !== null) {
|
|
268
267
|
if (option.text.includes("`")) {
|
|
269
268
|
// TODO: support inlineCode in options. Can do via `concat`.
|
|
270
269
|
console.warn("WARN: Option text contains a backtick. Inline code elements in option blocks is currently not supported!");
|
|
271
270
|
}
|
|
272
|
-
q(pushString(option.text));
|
|
271
|
+
q(tzo_1.pushString(option.text));
|
|
273
272
|
}
|
|
274
|
-
q(invokeFunction("ppc")); // push address of effect body to stack
|
|
275
|
-
q(pushNumber(4));
|
|
276
|
-
q(invokeFunction("+"));
|
|
277
|
-
q(invokeFunction("{")); // effect body start
|
|
273
|
+
q(tzo_1.invokeFunction("ppc")); // push address of effect body to stack
|
|
274
|
+
q(tzo_1.pushNumber(4));
|
|
275
|
+
q(tzo_1.invokeFunction("+"));
|
|
276
|
+
q(tzo_1.invokeFunction("{")); // effect body start
|
|
278
277
|
if (has_once_directive) {
|
|
279
278
|
// set the once directive context variable immediatley
|
|
280
|
-
q(pushNumber(1));
|
|
281
|
-
q(pushString(once_directive_name));
|
|
282
|
-
q(invokeFunction("setContext"));
|
|
279
|
+
q(tzo_1.pushNumber(1));
|
|
280
|
+
q(tzo_1.pushString(once_directive_name));
|
|
281
|
+
q(tzo_1.invokeFunction("setContext"));
|
|
283
282
|
}
|
|
284
283
|
if (option.effectChildren !== null) {
|
|
285
284
|
option.effectChildren.forEach(child => {
|
|
@@ -295,35 +294,35 @@ function parseMarkdown(file_contents) {
|
|
|
295
294
|
instructions.forEach(i => q(i));
|
|
296
295
|
}
|
|
297
296
|
else {
|
|
298
|
-
q(pushString(fixText(child)));
|
|
299
|
-
q(invokeFunction("emit"));
|
|
297
|
+
q(tzo_1.pushString(fixText(child)));
|
|
298
|
+
q(tzo_1.invokeFunction("emit"));
|
|
300
299
|
}
|
|
301
300
|
});
|
|
302
301
|
}
|
|
303
302
|
if (option.link !== null) {
|
|
304
|
-
q(pushString(option.link.substr(1)));
|
|
305
|
-
q(invokeFunction("goto"));
|
|
303
|
+
q(tzo_1.pushString(option.link.substr(1)));
|
|
304
|
+
q(tzo_1.invokeFunction("goto"));
|
|
306
305
|
}
|
|
307
306
|
if (noLinkBehaviour === NoLinkBehaviour.LOOPBACK_TO_OPTIONS) {
|
|
308
|
-
q(pushString(nodeOptionsLabel)); // ensure that options with no link or "goto" effect loop back to the options
|
|
309
|
-
q(invokeFunction("goto"));
|
|
307
|
+
q(tzo_1.pushString(nodeOptionsLabel)); // ensure that options with no link or "goto" effect loop back to the options
|
|
308
|
+
q(tzo_1.invokeFunction("goto"));
|
|
310
309
|
}
|
|
311
310
|
else if (noLinkBehaviour === NoLinkBehaviour.EXIT) {
|
|
312
|
-
q(invokeFunction("exit")); // ensure that options with no effect or link cause the VM to exit
|
|
311
|
+
q(tzo_1.invokeFunction("exit")); // ensure that options with no effect or link cause the VM to exit
|
|
313
312
|
}
|
|
314
|
-
q(invokeFunction("}")); // effect body end
|
|
315
|
-
q(invokeFunction("response"));
|
|
313
|
+
q(tzo_1.invokeFunction("}")); // effect body end
|
|
314
|
+
q(tzo_1.invokeFunction("response"));
|
|
316
315
|
if (has_once_directive) {
|
|
317
316
|
// when there was a once directive, ensure we close its block
|
|
318
|
-
q(invokeFunction("}")); // once directive block end
|
|
317
|
+
q(tzo_1.invokeFunction("}")); // once directive block end
|
|
319
318
|
}
|
|
320
319
|
if (has_precondition) {
|
|
321
320
|
// when there was a precondition, ensure we close the precondition block
|
|
322
|
-
q(invokeFunction("}")); // precondition block end
|
|
321
|
+
q(tzo_1.invokeFunction("}")); // precondition block end
|
|
323
322
|
}
|
|
324
323
|
});
|
|
325
|
-
q(invokeFunction("getResponse")); // getResponse is expected to pause the VM and push the relevant programlist index onto the stack
|
|
326
|
-
q(invokeFunction("goto")); // goto whatever was pushed onto the stack by getResponse
|
|
324
|
+
q(tzo_1.invokeFunction("getResponse")); // getResponse is expected to pause the VM and push the relevant programlist index onto the stack
|
|
325
|
+
q(tzo_1.invokeFunction("goto")); // goto whatever was pushed onto the stack by getResponse
|
|
327
326
|
return "skip";
|
|
328
327
|
// children have been parsed earlier
|
|
329
328
|
break;
|
|
@@ -337,15 +336,15 @@ function parseMarkdown(file_contents) {
|
|
|
337
336
|
instructions.forEach(i => q(i));
|
|
338
337
|
break;
|
|
339
338
|
case "text":
|
|
340
|
-
q(pushString(fixText(node)));
|
|
341
|
-
q(invokeFunction("emit"));
|
|
339
|
+
q(tzo_1.pushString(fixText(node)));
|
|
340
|
+
q(tzo_1.invokeFunction("emit"));
|
|
342
341
|
break;
|
|
343
342
|
default:
|
|
344
343
|
break;
|
|
345
344
|
}
|
|
346
345
|
};
|
|
347
346
|
unist_util_visit_1.default(root, visitorFunc);
|
|
348
|
-
q(invokeFunction("exit")); // ensure we always exit at the end
|
|
347
|
+
q(tzo_1.invokeFunction("exit")); // ensure we always exit at the end
|
|
349
348
|
return {
|
|
350
349
|
parsedMDFile: unist_util_remove_position_1.default(root, true),
|
|
351
350
|
qvmState
|
package/dist/mjs/QuestVM.d.ts
CHANGED
|
@@ -7,8 +7,7 @@ import visitParents from "unist-util-visit-parents";
|
|
|
7
7
|
import visit from "unist-util-visit";
|
|
8
8
|
import u from "unist-builder";
|
|
9
9
|
import 'array-flat-polyfill';
|
|
10
|
-
import
|
|
11
|
-
const { Tokenizer, pushString, pushNumber, invokeFunction } = pkg;
|
|
10
|
+
import { Tokenizer, pushString, pushNumber, invokeFunction } from "tzo";
|
|
12
11
|
export var NoLinkBehaviour;
|
|
13
12
|
(function (NoLinkBehaviour) {
|
|
14
13
|
NoLinkBehaviour[NoLinkBehaviour["EXIT"] = 0] = "EXIT";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "questmark",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.29",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/mjs/index.js",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"mdast": "^3.0.0",
|
|
30
30
|
"mdast-util-from-markdown": "^0.1.1",
|
|
31
31
|
"node-fetch": "^2.6.5",
|
|
32
|
-
"tzo": "^1.0.
|
|
32
|
+
"tzo": "^1.0.14",
|
|
33
33
|
"unist-builder": "^2.0.3",
|
|
34
34
|
"unist-util-filter": "^2.0.2",
|
|
35
35
|
"unist-util-find-after": "^3.0.0",
|