@mojir/dvala 0.0.18 → 0.0.24
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/cli/cli.js +68 -20
- package/package.json +35 -25
package/dist/cli/cli.js
CHANGED
|
@@ -478,7 +478,7 @@ function findAllOccurrences(input, pattern) {
|
|
|
478
478
|
}
|
|
479
479
|
//#endregion
|
|
480
480
|
//#region package.json
|
|
481
|
-
var version = "0.0.
|
|
481
|
+
var version = "0.0.24";
|
|
482
482
|
//#endregion
|
|
483
483
|
//#region src/typeGuards/string.ts
|
|
484
484
|
function isString(value, options = {}) {
|
|
@@ -5232,7 +5232,7 @@ function generateDocString(reference) {
|
|
|
5232
5232
|
${argStrings(reference).join("\n ")}
|
|
5233
5233
|
|
|
5234
5234
|
Examples:
|
|
5235
|
-
${reference.examples.map((example) => smartTrim(example, 4)).join("\n\n")}`);
|
|
5235
|
+
${reference.examples.map((example) => smartTrim(typeof example === "string" ? example : example.code, 4)).join("\n\n")}`);
|
|
5236
5236
|
}
|
|
5237
5237
|
function isEffectRef(ref) {
|
|
5238
5238
|
return "effect" in ref;
|
|
@@ -24391,7 +24391,13 @@ const standardEffects = {
|
|
|
24391
24391
|
description: "Value to print."
|
|
24392
24392
|
} },
|
|
24393
24393
|
variants: [{ argumentNames: ["value"] }],
|
|
24394
|
-
examples: [
|
|
24394
|
+
examples: [{
|
|
24395
|
+
code: "perform(effect(dvala.io.print), \"hello\")",
|
|
24396
|
+
noRun: true
|
|
24397
|
+
}, {
|
|
24398
|
+
code: "perform(effect(dvala.io.print), 42)",
|
|
24399
|
+
noRun: true
|
|
24400
|
+
}],
|
|
24395
24401
|
seeAlso: [
|
|
24396
24402
|
"-effect-dvala.io.println",
|
|
24397
24403
|
"-effect-dvala.io.error",
|
|
@@ -24413,7 +24419,13 @@ const standardEffects = {
|
|
|
24413
24419
|
description: "Value to print."
|
|
24414
24420
|
} },
|
|
24415
24421
|
variants: [{ argumentNames: ["value"] }],
|
|
24416
|
-
examples: [
|
|
24422
|
+
examples: [{
|
|
24423
|
+
code: "perform(effect(dvala.io.println), \"hello\")",
|
|
24424
|
+
noRun: true
|
|
24425
|
+
}, {
|
|
24426
|
+
code: "perform(effect(dvala.io.println), [1, 2, 3])",
|
|
24427
|
+
noRun: true
|
|
24428
|
+
}],
|
|
24417
24429
|
seeAlso: [
|
|
24418
24430
|
"-effect-dvala.io.print",
|
|
24419
24431
|
"-effect-dvala.io.error",
|
|
@@ -24445,7 +24457,10 @@ const standardEffects = {
|
|
|
24445
24457
|
description: "Value to write to stderr."
|
|
24446
24458
|
} },
|
|
24447
24459
|
variants: [{ argumentNames: ["value"] }],
|
|
24448
|
-
examples: [
|
|
24460
|
+
examples: [{
|
|
24461
|
+
code: "perform(effect(dvala.io.error), \"something went wrong\")",
|
|
24462
|
+
noRun: true
|
|
24463
|
+
}],
|
|
24449
24464
|
seeAlso: [
|
|
24450
24465
|
"-effect-dvala.io.print",
|
|
24451
24466
|
"-effect-dvala.io.println",
|
|
@@ -25331,14 +25346,11 @@ function deriveEffectReference() {
|
|
|
25331
25346
|
return result;
|
|
25332
25347
|
}
|
|
25333
25348
|
const effectReference = deriveEffectReference();
|
|
25334
|
-
|
|
25349
|
+
sortByCategory({
|
|
25335
25350
|
...apiReference,
|
|
25336
25351
|
...moduleReference,
|
|
25337
25352
|
...effectReference
|
|
25338
25353
|
});
|
|
25339
|
-
Object.values(allReference).forEach((ref) => {
|
|
25340
|
-
ref.title = ref.title.replace(/"/g, """);
|
|
25341
|
-
});
|
|
25342
25354
|
function sortByCategory(ref) {
|
|
25343
25355
|
return Object.fromEntries(Object.entries(ref).sort(([keyA, refA], [keyB, refB]) => {
|
|
25344
25356
|
const catA = refA.category === "special-expression" ? "" : refA.category;
|
|
@@ -28110,6 +28122,22 @@ var ResumeFromSignal = class {
|
|
|
28110
28122
|
function isResumeFromSignal(value) {
|
|
28111
28123
|
return value instanceof ResumeFromSignal;
|
|
28112
28124
|
}
|
|
28125
|
+
/**
|
|
28126
|
+
* Thrown (as a promise rejection) by `halt()` inside a host handler.
|
|
28127
|
+
* Caught by the effect trampoline loop — NOT by Dvala-level try/catch.
|
|
28128
|
+
* Terminates execution immediately and returns a halted result.
|
|
28129
|
+
*/
|
|
28130
|
+
var HaltSignal = class {
|
|
28131
|
+
_brand = "HaltSignal";
|
|
28132
|
+
constructor(value, snapshots, nextSnapshotIndex) {
|
|
28133
|
+
this.value = value;
|
|
28134
|
+
this.snapshots = snapshots;
|
|
28135
|
+
this.nextSnapshotIndex = nextSnapshotIndex;
|
|
28136
|
+
}
|
|
28137
|
+
};
|
|
28138
|
+
function isHaltSignal(value) {
|
|
28139
|
+
return value instanceof HaltSignal;
|
|
28140
|
+
}
|
|
28113
28141
|
//#endregion
|
|
28114
28142
|
//#region src/evaluator/effectRef.ts
|
|
28115
28143
|
const internMap = /* @__PURE__ */ new Map();
|
|
@@ -30671,6 +30699,8 @@ function dispatchHostHandler(effectName, matchingHandlers, args, k, signal, sour
|
|
|
30671
30699
|
}
|
|
30672
30700
|
function tryHandler(index) {
|
|
30673
30701
|
if (index >= matchingHandlers.length) {
|
|
30702
|
+
const standardHandler = getStandardEffectHandler(effectName);
|
|
30703
|
+
if (standardHandler) return standardHandler(args, k, sourceCodeInfo);
|
|
30674
30704
|
if (effectName === "dvala.error") throw new UserDefinedError(typeof argsArray[0] === "string" ? argsArray[0] : String(argsArray[0] ?? "Unknown error"), sourceCodeInfo);
|
|
30675
30705
|
if (effectName === "dvala.checkpoint") return {
|
|
30676
30706
|
type: "Value",
|
|
@@ -30679,11 +30709,7 @@ function dispatchHostHandler(effectName, matchingHandlers, args, k, signal, sour
|
|
|
30679
30709
|
};
|
|
30680
30710
|
throw new DvalaError(`Unhandled effect: '${effectName}'`, sourceCodeInfo);
|
|
30681
30711
|
}
|
|
30682
|
-
const [
|
|
30683
|
-
if (pattern === "*") {
|
|
30684
|
-
const standardHandler = getStandardEffectHandler(effectName);
|
|
30685
|
-
if (standardHandler) return standardHandler(args, k, sourceCodeInfo);
|
|
30686
|
-
}
|
|
30712
|
+
const [_pattern, handler] = matchingHandlers[index];
|
|
30687
30713
|
let outcome;
|
|
30688
30714
|
let settled = false;
|
|
30689
30715
|
function assertNotSettled(operation) {
|
|
@@ -30758,10 +30784,17 @@ function dispatchHostHandler(effectName, matchingHandlers, args, k, signal, sour
|
|
|
30758
30784
|
kind: "throw",
|
|
30759
30785
|
error: new ResumeFromSignal(found.continuation, value, found.index)
|
|
30760
30786
|
};
|
|
30787
|
+
},
|
|
30788
|
+
halt: (value = null) => {
|
|
30789
|
+
assertNotSettled("halt");
|
|
30790
|
+
outcome = {
|
|
30791
|
+
kind: "throw",
|
|
30792
|
+
error: new HaltSignal(value, snapshotState ? snapshotState.snapshots : [], snapshotState ? snapshotState.nextSnapshotIndex : 0)
|
|
30793
|
+
};
|
|
30761
30794
|
}
|
|
30762
30795
|
});
|
|
30763
30796
|
if (!(handlerResult instanceof Promise)) {
|
|
30764
|
-
if (!outcome) throw new DvalaError(`Effect handler for '${effectName}' did not call resume(), fail(), suspend(), or next()`, sourceCodeInfo);
|
|
30797
|
+
if (!outcome) throw new DvalaError(`Effect handler for '${effectName}' did not call resume(), fail(), suspend(), halt(), or next()`, sourceCodeInfo);
|
|
30765
30798
|
return resolveOutcome(outcome, index + 1);
|
|
30766
30799
|
}
|
|
30767
30800
|
if (outcome) {
|
|
@@ -30769,11 +30802,11 @@ function dispatchHostHandler(effectName, matchingHandlers, args, k, signal, sour
|
|
|
30769
30802
|
return resolveOutcome(outcome, index + 1);
|
|
30770
30803
|
}
|
|
30771
30804
|
return handlerResult.then(() => {
|
|
30772
|
-
if (!outcome) throw new DvalaError(`Effect handler for '${effectName}' did not call resume(), fail(), suspend(), or next()`, sourceCodeInfo);
|
|
30805
|
+
if (!outcome) throw new DvalaError(`Effect handler for '${effectName}' did not call resume(), fail(), suspend(), halt(), or next()`, sourceCodeInfo);
|
|
30773
30806
|
return resolveOutcome(outcome, index + 1);
|
|
30774
30807
|
}, (e) => {
|
|
30775
30808
|
if (outcome) return resolveOutcome(outcome, index + 1);
|
|
30776
|
-
if (isSuspensionSignal(e) || isResumeFromSignal(e)) throw e;
|
|
30809
|
+
if (isSuspensionSignal(e) || isResumeFromSignal(e) || isHaltSignal(e)) throw e;
|
|
30777
30810
|
return {
|
|
30778
30811
|
type: "Error",
|
|
30779
30812
|
error: e instanceof DvalaError ? e : new DvalaError(e instanceof Error ? e : `${e}`, sourceCodeInfo),
|
|
@@ -31697,7 +31730,7 @@ function tick(step, handlers, signal, snapshotState) {
|
|
|
31697
31730
|
}
|
|
31698
31731
|
}
|
|
31699
31732
|
} catch (error) {
|
|
31700
|
-
if (isSuspensionSignal(error)) throw error;
|
|
31733
|
+
if (isSuspensionSignal(error) || isHaltSignal(error)) throw error;
|
|
31701
31734
|
if (error instanceof DvalaError) {
|
|
31702
31735
|
const effectStep = tryDispatchDvalaError(error, step.type === "Value" ? step.k.slice(1) : step.k, handlers, signal, snapshotState);
|
|
31703
31736
|
if (effectStep !== null) return effectStep;
|
|
@@ -31833,8 +31866,9 @@ async function runEffectLoop(initial, handlers, signal, initialSnapshotState, ma
|
|
|
31833
31866
|
const continuation = serializeTerminalSnapshot(snapshotState.snapshots, snapshotState.nextSnapshotIndex);
|
|
31834
31867
|
const meta = {};
|
|
31835
31868
|
if (options?.error) meta.error = options.error.toJSON();
|
|
31869
|
+
if (options?.halted) meta.halted = true;
|
|
31836
31870
|
if (options?.result !== void 0) meta.result = options.result;
|
|
31837
|
-
const message = options?.error ? "Run failed with error" : "Run completed successfully";
|
|
31871
|
+
const message = options?.error ? "Run failed with error" : options?.halted ? "Program halted" : "Run completed successfully";
|
|
31838
31872
|
return createSnapshot({
|
|
31839
31873
|
continuation,
|
|
31840
31874
|
timestamp: Date.now(),
|
|
@@ -31901,6 +31935,20 @@ async function runEffectLoop(initial, handlers, signal, initialSnapshotState, ma
|
|
|
31901
31935
|
effectArgs: error.effectArgs
|
|
31902
31936
|
})
|
|
31903
31937
|
};
|
|
31938
|
+
if (isHaltSignal(error)) {
|
|
31939
|
+
const snapshot = createTerminalSnapshot({
|
|
31940
|
+
result: error.value,
|
|
31941
|
+
halted: true
|
|
31942
|
+
});
|
|
31943
|
+
return snapshot ? {
|
|
31944
|
+
type: "halted",
|
|
31945
|
+
value: error.value,
|
|
31946
|
+
snapshot
|
|
31947
|
+
} : {
|
|
31948
|
+
type: "halted",
|
|
31949
|
+
value: error.value
|
|
31950
|
+
};
|
|
31951
|
+
}
|
|
31904
31952
|
if (error instanceof DvalaError) {
|
|
31905
31953
|
const snapshot = createTerminalSnapshot({ error });
|
|
31906
31954
|
return snapshot ? {
|
|
@@ -33910,7 +33958,7 @@ function getArgumentInfo(fmt, reference) {
|
|
|
33910
33958
|
const dvala = createDvala({ debug: false });
|
|
33911
33959
|
function getCliFunctionExamples(fmt, reference) {
|
|
33912
33960
|
const { examples } = reference;
|
|
33913
|
-
return examples.map((example) => example.trim()).map((example) => {
|
|
33961
|
+
return examples.map((example) => (typeof example === "string" ? example : example.code).trim()).map((example) => {
|
|
33914
33962
|
const oldLog = console.log;
|
|
33915
33963
|
console.log = function() {};
|
|
33916
33964
|
let result;
|
package/package.json
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mojir/dvala",
|
|
3
|
-
"
|
|
4
|
-
|
|
3
|
+
"overrides": {
|
|
4
|
+
"file-type": "^21.3.2"
|
|
5
|
+
},
|
|
6
|
+
"version": "0.0.24",
|
|
7
|
+
"description": "A suspendable, time-traveling functional language for JavaScript with algebraic effects",
|
|
5
8
|
"author": "Albert Mojir",
|
|
6
9
|
"license": "MIT",
|
|
7
10
|
"repository": {
|
|
@@ -9,15 +12,21 @@
|
|
|
9
12
|
"url": "git+https://github.com/mojir/dvala.git"
|
|
10
13
|
},
|
|
11
14
|
"keywords": [
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
15
|
+
"dvala",
|
|
16
|
+
"functional",
|
|
17
|
+
"programming-language",
|
|
18
|
+
"interpreter",
|
|
19
|
+
"suspendable",
|
|
20
|
+
"resumable",
|
|
21
|
+
"algebraic-effects",
|
|
22
|
+
"time-travel",
|
|
23
|
+
"pure",
|
|
24
|
+
"immutable",
|
|
25
|
+
"expression-language",
|
|
26
|
+
"typescript",
|
|
27
|
+
"javascript",
|
|
28
|
+
"lisp",
|
|
29
|
+
"clojure"
|
|
21
30
|
],
|
|
22
31
|
"exports": {
|
|
23
32
|
".": {
|
|
@@ -124,8 +133,8 @@
|
|
|
124
133
|
"lint:no-fix": "wireit",
|
|
125
134
|
"typecheck": "wireit",
|
|
126
135
|
"typecheck:watch": "tsc -p ./tsconfig.compile.json --noEmit --watch",
|
|
127
|
-
"check": "npm install && npm run lint && npm run typecheck && npm run test && npm run build",
|
|
128
|
-
"check:no-fix": "npm run lint:no-fix && npm run typecheck && npm run test",
|
|
136
|
+
"check": "npm install && npm run lint && npm run typecheck && npm run test && npm run build && [ -n \"$CI\" ] || npm run test:e2e",
|
|
137
|
+
"check:no-fix": "npm run lint:no-fix && npm run typecheck && npm run test && [ -n \"$CI\" ] || npm run test:e2e",
|
|
129
138
|
"clean": "npm run clean-dvala && npm run clean-playground && rm -rf .wireit coverage test-results vscode-dvala/out",
|
|
130
139
|
"clean-dvala": "rm -rf dist build",
|
|
131
140
|
"clean-playground": "rm -rf playground-builder/build playground-www/build",
|
|
@@ -136,7 +145,7 @@
|
|
|
136
145
|
"build-playground": "wireit",
|
|
137
146
|
"build-vscode-ext": "wireit",
|
|
138
147
|
"dvala": "node ./dist/cli/cli.js",
|
|
139
|
-
"dev": "npx serve docs -p 9901",
|
|
148
|
+
"dev": "npx serve docs -p 9901 --single",
|
|
140
149
|
"test:e2e": "npx playwright test",
|
|
141
150
|
"test:e2e:prod": "E2E_BASE_URL=https://mojir.github.io/dvala npx playwright test",
|
|
142
151
|
"test:e2e:headed": "npx playwright test --headed",
|
|
@@ -145,25 +154,22 @@
|
|
|
145
154
|
"mcp:inspect": "npx @modelcontextprotocol/inspector node ./dist/mcp-server/server.js"
|
|
146
155
|
},
|
|
147
156
|
"devDependencies": {
|
|
148
|
-
"@antfu/eslint-config": "^7.7.0",
|
|
149
157
|
"@eslint/js": "^10.0.1",
|
|
150
|
-
"@mermaid-js/mermaid-cli": "^11.12.0",
|
|
151
158
|
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
152
159
|
"@playwright/test": "^1.58.2",
|
|
153
160
|
"@stylistic/eslint-plugin": "^5.10.0",
|
|
154
|
-
"@types/node": "^25.
|
|
155
|
-
"@types/vscode": "^1.
|
|
156
|
-
"@vitest/coverage-v8": "^4.0
|
|
161
|
+
"@types/node": "^25.5.0",
|
|
162
|
+
"@types/vscode": "^1.110.0",
|
|
163
|
+
"@vitest/coverage-v8": "^4.1.0",
|
|
157
164
|
"@vscode/vsce": "^3.7.1",
|
|
158
|
-
"esbuild": "^0.27.
|
|
165
|
+
"esbuild": "^0.27.4",
|
|
159
166
|
"eslint": "^10.0.3",
|
|
160
|
-
"open-cli": "8.0.0",
|
|
161
|
-
"rolldown": "^1.0.0-rc.
|
|
167
|
+
"open-cli": "^8.0.0",
|
|
168
|
+
"rolldown": "^1.0.0-rc.9",
|
|
162
169
|
"serve": "^14.2.6",
|
|
163
|
-
"tslib": "^2.8.1",
|
|
164
170
|
"typescript": "^5.9.3",
|
|
165
|
-
"typescript-eslint": "^8.
|
|
166
|
-
"vitest": "^4.0
|
|
171
|
+
"typescript-eslint": "^8.57.1",
|
|
172
|
+
"vitest": "^4.1.0",
|
|
167
173
|
"wireit": "^0.14.12",
|
|
168
174
|
"zod": "^4.3.6"
|
|
169
175
|
},
|
|
@@ -298,6 +304,7 @@
|
|
|
298
304
|
"src/**",
|
|
299
305
|
"common/**",
|
|
300
306
|
"reference/**/*.ts",
|
|
307
|
+
"tutorials/**",
|
|
301
308
|
"rolldown.config.playground-builder.mjs",
|
|
302
309
|
"rolldown.config.playground-www.mjs",
|
|
303
310
|
"rolldown.plugins.mjs",
|
|
@@ -326,5 +333,8 @@
|
|
|
326
333
|
],
|
|
327
334
|
"clean": "if-file-deleted"
|
|
328
335
|
}
|
|
336
|
+
},
|
|
337
|
+
"dependencies": {
|
|
338
|
+
"marked": "^17.0.4"
|
|
329
339
|
}
|
|
330
340
|
}
|