@listen-fire/movement-lang 0.15.1 → 0.15.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/catalog/types.d.ts +3 -0
- package/dist/checker/standard_library.d.ts +2 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -1
- package/dist/language_version_value.d.ts +1 -1
- package/dist/language_version_value.js +1 -1
- package/dist/service/description.d.ts +103 -0
- package/dist/service/description.js +142 -0
- package/dist/wasm/loader.d.ts +22 -0
- package/dist/wasm/loader.js +57 -7
- package/dist/wasm/movement.wasm +0 -0
- package/dist/wasm/movement_parser.wasm +0 -0
- package/package.json +1 -1
package/dist/catalog/types.d.ts
CHANGED
|
@@ -985,6 +985,9 @@ export interface CollectionSchema extends EdgeListening {
|
|
|
985
985
|
cursor?: boolean;
|
|
986
986
|
identity?: string;
|
|
987
987
|
version?: string;
|
|
988
|
+
/** What the module says of what lands here, where the type has no position
|
|
989
|
+
* to say it on (one known only by what is written to it). */
|
|
990
|
+
description?: string;
|
|
988
991
|
}
|
|
989
992
|
/**
|
|
990
993
|
* The schema of a constructed instance — produced per construction because
|
|
@@ -13,8 +13,8 @@ export interface StandardBuiltin {
|
|
|
13
13
|
* table (`surfaceTable`) gives the name an author writes. */
|
|
14
14
|
name: string;
|
|
15
15
|
params: readonly StandardBuiltinParam[];
|
|
16
|
-
/** What a call gives back, as
|
|
17
|
-
*
|
|
16
|
+
/** What a call gives back, as a program writes a type (`text[]`,
|
|
17
|
+
* `text | null`), or `derived`: it follows from the arguments. */
|
|
18
18
|
returns: string;
|
|
19
19
|
/** One line for listings. `RETIRED — …` for a built-in kept only so old
|
|
20
20
|
* automations still read. */
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export * from './parser/ast';
|
|
|
3
3
|
export * from './parser/await_words';
|
|
4
4
|
export * from './parser/scan';
|
|
5
5
|
export * from './parser/parse';
|
|
6
|
-
export { MovementParserNotReady, assertParserReady, callJudgeArrival, callLandingMisfits, callLandingNode, callListenIdentity, initEngine, initParser, isParserReady, openEngineSegment, type EngineSegment, } from './wasm/loader';
|
|
6
|
+
export { MovementParserNotReady, assertParserReady, callJudgeArrival, callLandingMisfits, callLandingNode, callListenIdentity, EngineStackRanOut, initEngine, initParser, isParserReady, openEngineSegment, type EngineSegment, } from './wasm/loader';
|
|
7
7
|
export * from './expression/bridge';
|
|
8
8
|
export * from './expression/chunk';
|
|
9
9
|
export * from './expression/file_value';
|
|
@@ -19,4 +19,5 @@ export * from './checker/standard_library';
|
|
|
19
19
|
export type { MExpr } from './parser/expression/tree';
|
|
20
20
|
export * from './service/snapshot';
|
|
21
21
|
export * from './service/language_service';
|
|
22
|
+
export * from './service/description';
|
|
22
23
|
export * from './language_version';
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.openEngineSegment = exports.isParserReady = exports.initParser = exports.initEngine = exports.callListenIdentity = exports.callLandingNode = exports.callLandingMisfits = exports.callJudgeArrival = exports.assertParserReady = exports.MovementParserNotReady = void 0;
|
|
17
|
+
exports.openEngineSegment = exports.isParserReady = exports.initParser = exports.initEngine = exports.EngineStackRanOut = exports.callListenIdentity = exports.callLandingNode = exports.callLandingMisfits = exports.callJudgeArrival = exports.assertParserReady = exports.MovementParserNotReady = void 0;
|
|
18
18
|
__exportStar(require("./never"), exports);
|
|
19
19
|
__exportStar(require("./parser/ast"), exports);
|
|
20
20
|
__exportStar(require("./parser/await_words"), exports);
|
|
@@ -27,6 +27,7 @@ Object.defineProperty(exports, "callJudgeArrival", { enumerable: true, get: func
|
|
|
27
27
|
Object.defineProperty(exports, "callLandingMisfits", { enumerable: true, get: function () { return loader_1.callLandingMisfits; } });
|
|
28
28
|
Object.defineProperty(exports, "callLandingNode", { enumerable: true, get: function () { return loader_1.callLandingNode; } });
|
|
29
29
|
Object.defineProperty(exports, "callListenIdentity", { enumerable: true, get: function () { return loader_1.callListenIdentity; } });
|
|
30
|
+
Object.defineProperty(exports, "EngineStackRanOut", { enumerable: true, get: function () { return loader_1.EngineStackRanOut; } });
|
|
30
31
|
Object.defineProperty(exports, "initEngine", { enumerable: true, get: function () { return loader_1.initEngine; } });
|
|
31
32
|
Object.defineProperty(exports, "initParser", { enumerable: true, get: function () { return loader_1.initParser; } });
|
|
32
33
|
Object.defineProperty(exports, "isParserReady", { enumerable: true, get: function () { return loader_1.isParserReady; } });
|
|
@@ -45,4 +46,5 @@ __exportStar(require("./checker/story_analysis"), exports);
|
|
|
45
46
|
__exportStar(require("./checker/standard_library"), exports);
|
|
46
47
|
__exportStar(require("./service/snapshot"), exports);
|
|
47
48
|
__exportStar(require("./service/language_service"), exports);
|
|
49
|
+
__exportStar(require("./service/description"), exports);
|
|
48
50
|
__exportStar(require("./language_version"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PACKAGE_VERSION = "0.15.
|
|
1
|
+
export declare const PACKAGE_VERSION = "0.15.3";
|
|
@@ -5,4 +5,4 @@ exports.PACKAGE_VERSION = void 0;
|
|
|
5
5
|
// scripts/build-packages.cjs (a source and its build sit at different depths
|
|
6
6
|
// beside package.json, so neither can require it by one relative path).
|
|
7
7
|
// __test__/language_version.unit.test.ts holds it equal to package.json.
|
|
8
|
-
exports.PACKAGE_VERSION = '0.15.
|
|
8
|
+
exports.PACKAGE_VERSION = '0.15.3';
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { CatalogSnapshot } from './snapshot';
|
|
2
|
+
/** How much of a place to show. Absent: all of it. */
|
|
3
|
+
export interface Showing {
|
|
4
|
+
/** At most this many fields per list: required first, then identifying. */
|
|
5
|
+
fields?: number;
|
|
6
|
+
/** At most this many options per enum, the rest counted (`"a" | "b" | …+3`). */
|
|
7
|
+
enumOptions?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface DescriptionLevels {
|
|
10
|
+
/** How much of the place itself. */
|
|
11
|
+
showing?: Showing;
|
|
12
|
+
/** How much of where each of its edges lands. */
|
|
13
|
+
landings?: Showing;
|
|
14
|
+
}
|
|
15
|
+
export interface DescribedField {
|
|
16
|
+
name: string;
|
|
17
|
+
/** The whole field as the catalog writes it: `` `Message Id`!* text ``,
|
|
18
|
+
* `` `Reply Markup` json (write only) ``. */
|
|
19
|
+
written: string;
|
|
20
|
+
/** Its name and marks alone, as a write's field list writes it: `Text!`. */
|
|
21
|
+
markedName: string;
|
|
22
|
+
/** Its type as a program writes it. */
|
|
23
|
+
type: string;
|
|
24
|
+
required: boolean;
|
|
25
|
+
identifying: boolean;
|
|
26
|
+
readOnly: boolean;
|
|
27
|
+
/** A field only a write gives, on a type that can be read. */
|
|
28
|
+
writeOnly: boolean;
|
|
29
|
+
/** A read's WHERE must set it with `==`. */
|
|
30
|
+
pinned: boolean;
|
|
31
|
+
description?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface DescribedFields {
|
|
34
|
+
shown: DescribedField[];
|
|
35
|
+
/** How many `Showing.fields` left out. */
|
|
36
|
+
cut: number;
|
|
37
|
+
}
|
|
38
|
+
export interface DescribedEdge {
|
|
39
|
+
name: string;
|
|
40
|
+
/** The hop alone, as a walk writes it: ``-[:`Linked Users`]->``. */
|
|
41
|
+
step: string;
|
|
42
|
+
/** The hop, where it lands and what it can do: ``-[:Replies]-> Message [w]``. */
|
|
43
|
+
hop: string;
|
|
44
|
+
/** The type it lands on; null where its members land apart. */
|
|
45
|
+
target: string | null;
|
|
46
|
+
read: boolean;
|
|
47
|
+
write: boolean;
|
|
48
|
+
fires: boolean;
|
|
49
|
+
description?: string;
|
|
50
|
+
/** What a write along it takes, where one can be written. */
|
|
51
|
+
writes?: DescribedFields;
|
|
52
|
+
/** Where it lands, one level deep: its own edges carry no landing. */
|
|
53
|
+
lands?: DescribedPlace;
|
|
54
|
+
}
|
|
55
|
+
export type Known = 'whole' | 'open' | 'undescribed';
|
|
56
|
+
export interface DescribedPlace {
|
|
57
|
+
/** The type's name as its module shows it. */
|
|
58
|
+
name: string;
|
|
59
|
+
description?: string;
|
|
60
|
+
/** `open`: its module has fields no description names; `undescribed`: nothing has looked at it. */
|
|
61
|
+
known: Known;
|
|
62
|
+
/** What it may be, where it is one of several types. */
|
|
63
|
+
members: string[];
|
|
64
|
+
fields: DescribedFields;
|
|
65
|
+
edges: DescribedEdge[];
|
|
66
|
+
}
|
|
67
|
+
export interface DescribedDiagnostic {
|
|
68
|
+
code: string;
|
|
69
|
+
message: string;
|
|
70
|
+
severity: 'error' | 'warning' | 'info';
|
|
71
|
+
}
|
|
72
|
+
/** Every connection a snapshot describes, at its root. */
|
|
73
|
+
export interface CatalogDescription {
|
|
74
|
+
/** The notation's one line, said once at the top of a text in it. */
|
|
75
|
+
legend: string;
|
|
76
|
+
connections: Array<{
|
|
77
|
+
adapter: string;
|
|
78
|
+
key: string;
|
|
79
|
+
place: DescribedPlace;
|
|
80
|
+
}>;
|
|
81
|
+
}
|
|
82
|
+
/** The one connection or place an address names. */
|
|
83
|
+
export interface AddressDescription {
|
|
84
|
+
legend: string;
|
|
85
|
+
diagnostics: DescribedDiagnostic[];
|
|
86
|
+
/** Null where a diagnostic is an error, or nothing describes where it lands. */
|
|
87
|
+
place: DescribedPlace | null;
|
|
88
|
+
/** An address with no walk: each record type the connection holds, by the
|
|
89
|
+
* name a program's type writes (`<c-[:Message]->>`). */
|
|
90
|
+
records?: Array<{
|
|
91
|
+
name: string;
|
|
92
|
+
place: DescribedPlace;
|
|
93
|
+
}>;
|
|
94
|
+
}
|
|
95
|
+
/** Every connection `snapshot` describes, each at its root with where each of its edges lands. */
|
|
96
|
+
export declare function describeCatalog(snapshot: CatalogSnapshot, levels?: DescriptionLevels): CatalogDescription;
|
|
97
|
+
/**
|
|
98
|
+
* The connection or place `address` names, written as `listen-fire catalog
|
|
99
|
+
* '<address>'` takes one (`'@lf/slack:team_workspace-[:Channels]->'`): read,
|
|
100
|
+
* checked and walked by the checker, so a misspelt edge comes back as its
|
|
101
|
+
* diagnostic.
|
|
102
|
+
*/
|
|
103
|
+
export declare function describeAddress(snapshot: CatalogSnapshot, address: string, levels?: DescriptionLevels): AddressDescription;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// What a catalog holds, as the one description every tool reads
|
|
3
|
+
// (crates/movement-checker/src/description.rs), through the movement
|
|
4
|
+
// artifact's `describe_query` export. Every name, type, hop and mark arrives
|
|
5
|
+
// spelled as `listen-fire catalog` spells it: a caller chooses how much to
|
|
6
|
+
// show (`Showing`) and lays the parts out, and never spells one itself.
|
|
7
|
+
//
|
|
8
|
+
// It loads with the engine artifact, which a browser never downloads.
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.describeCatalog = describeCatalog;
|
|
11
|
+
exports.describeAddress = describeAddress;
|
|
12
|
+
const loader_1 = require("../wasm/loader");
|
|
13
|
+
const rust_checker_1 = require("../checker/rust_checker");
|
|
14
|
+
/** Every connection `snapshot` describes, each at its root with where each of its edges lands. */
|
|
15
|
+
function describeCatalog(snapshot, levels = {}) {
|
|
16
|
+
const answer = ask(snapshot, levels);
|
|
17
|
+
if (!isRecord(answer) || !Array.isArray(answer.connections))
|
|
18
|
+
throw malformed('catalog description', answer);
|
|
19
|
+
return {
|
|
20
|
+
legend: stringOf(answer.legend, 'legend'),
|
|
21
|
+
connections: answer.connections.map((connection) => {
|
|
22
|
+
if (!isRecord(connection))
|
|
23
|
+
throw malformed('connection', connection);
|
|
24
|
+
return { adapter: stringOf(connection.adapter, 'adapter'), key: stringOf(connection.key, 'key'), place: placeOf(connection.place) };
|
|
25
|
+
}),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The connection or place `address` names, written as `listen-fire catalog
|
|
30
|
+
* '<address>'` takes one (`'@lf/slack:team_workspace-[:Channels]->'`): read,
|
|
31
|
+
* checked and walked by the checker, so a misspelt edge comes back as its
|
|
32
|
+
* diagnostic.
|
|
33
|
+
*/
|
|
34
|
+
function describeAddress(snapshot, address, levels = {}) {
|
|
35
|
+
const answer = ask(snapshot, { address, ...levels });
|
|
36
|
+
if (!isRecord(answer) || !Array.isArray(answer.diagnostics))
|
|
37
|
+
throw malformed('address description', answer);
|
|
38
|
+
const records = answer.records;
|
|
39
|
+
if (records !== undefined && !Array.isArray(records))
|
|
40
|
+
throw malformed('record types', records);
|
|
41
|
+
return {
|
|
42
|
+
legend: stringOf(answer.legend, 'legend'),
|
|
43
|
+
diagnostics: answer.diagnostics.map(diagnosticOf),
|
|
44
|
+
place: answer.place === null ? null : placeOf(answer.place),
|
|
45
|
+
...(records !== undefined
|
|
46
|
+
? {
|
|
47
|
+
records: records.map((record) => {
|
|
48
|
+
if (!isRecord(record))
|
|
49
|
+
throw malformed('record type', record);
|
|
50
|
+
return { name: stringOf(record.name, 'record type name'), place: placeOf(record.place) };
|
|
51
|
+
}),
|
|
52
|
+
}
|
|
53
|
+
: {}),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function ask(snapshot, request) {
|
|
57
|
+
const reply = (0, loader_1.callDescribeQuery)(JSON.stringify(snapshot), JSON.stringify(request));
|
|
58
|
+
if (!reply.ok)
|
|
59
|
+
throw rust_checker_1.RustCheckRefused.of(reply.json);
|
|
60
|
+
return reply.json;
|
|
61
|
+
}
|
|
62
|
+
function placeOf(value) {
|
|
63
|
+
if (!isRecord(value) || !Array.isArray(value.members) || !Array.isArray(value.edges))
|
|
64
|
+
throw malformed('place', value);
|
|
65
|
+
return {
|
|
66
|
+
name: stringOf(value.name, 'place name'),
|
|
67
|
+
...optionalString(value.description, 'place description'),
|
|
68
|
+
known: knownOf(value.known),
|
|
69
|
+
members: value.members.map((member) => stringOf(member, 'member')),
|
|
70
|
+
fields: fieldsOf(value.fields),
|
|
71
|
+
edges: value.edges.map(edgeOf),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function knownOf(value) {
|
|
75
|
+
if (value === 'whole' || value === 'open' || value === 'undescribed')
|
|
76
|
+
return value;
|
|
77
|
+
throw malformed('known', value);
|
|
78
|
+
}
|
|
79
|
+
function fieldsOf(value) {
|
|
80
|
+
if (!isRecord(value) || !Array.isArray(value.shown) || typeof value.cut !== 'number')
|
|
81
|
+
throw malformed('field list', value);
|
|
82
|
+
return { shown: value.shown.map(fieldOf), cut: value.cut };
|
|
83
|
+
}
|
|
84
|
+
function fieldOf(value) {
|
|
85
|
+
if (!isRecord(value))
|
|
86
|
+
throw malformed('field', value);
|
|
87
|
+
return {
|
|
88
|
+
name: stringOf(value.name, 'field name'),
|
|
89
|
+
written: stringOf(value.written, 'field'),
|
|
90
|
+
markedName: stringOf(value.markedName, 'field name and marks'),
|
|
91
|
+
type: stringOf(value.type, 'field type'),
|
|
92
|
+
required: booleanOf(value.required, 'required'),
|
|
93
|
+
identifying: booleanOf(value.identifying, 'identifying'),
|
|
94
|
+
readOnly: booleanOf(value.readOnly, 'readOnly'),
|
|
95
|
+
writeOnly: booleanOf(value.writeOnly, 'writeOnly'),
|
|
96
|
+
pinned: booleanOf(value.pinned, 'pinned'),
|
|
97
|
+
...optionalString(value.description, 'field description'),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function edgeOf(value) {
|
|
101
|
+
if (!isRecord(value) || (value.target !== null && typeof value.target !== 'string'))
|
|
102
|
+
throw malformed('edge', value);
|
|
103
|
+
return {
|
|
104
|
+
name: stringOf(value.name, 'edge name'),
|
|
105
|
+
step: stringOf(value.step, 'step'),
|
|
106
|
+
hop: stringOf(value.hop, 'hop'),
|
|
107
|
+
target: value.target,
|
|
108
|
+
read: booleanOf(value.read, 'read'),
|
|
109
|
+
write: booleanOf(value.write, 'write'),
|
|
110
|
+
fires: booleanOf(value.fires, 'fires'),
|
|
111
|
+
...optionalString(value.description, 'edge description'),
|
|
112
|
+
...(value.writes !== undefined ? { writes: fieldsOf(value.writes) } : {}),
|
|
113
|
+
...(value.lands !== undefined ? { lands: placeOf(value.lands) } : {}),
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
function diagnosticOf(value) {
|
|
117
|
+
if (!isRecord(value))
|
|
118
|
+
throw malformed('diagnostic', value);
|
|
119
|
+
const { severity } = value;
|
|
120
|
+
if (severity !== 'error' && severity !== 'warning' && severity !== 'info')
|
|
121
|
+
throw malformed('severity', severity);
|
|
122
|
+
return { code: stringOf(value.code, 'code'), message: stringOf(value.message, 'message'), severity };
|
|
123
|
+
}
|
|
124
|
+
function stringOf(value, what) {
|
|
125
|
+
if (typeof value !== 'string')
|
|
126
|
+
throw malformed(what, value);
|
|
127
|
+
return value;
|
|
128
|
+
}
|
|
129
|
+
function booleanOf(value, what) {
|
|
130
|
+
if (typeof value !== 'boolean')
|
|
131
|
+
throw malformed(what, value);
|
|
132
|
+
return value;
|
|
133
|
+
}
|
|
134
|
+
function optionalString(value, what) {
|
|
135
|
+
return value === undefined ? {} : { description: stringOf(value, what) };
|
|
136
|
+
}
|
|
137
|
+
function isRecord(value) {
|
|
138
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
139
|
+
}
|
|
140
|
+
function malformed(what, value) {
|
|
141
|
+
return new Error(`the describing query answered a ${what} that is not one: ${JSON.stringify(value)?.slice(0, 200)}`);
|
|
142
|
+
}
|
package/dist/wasm/loader.d.ts
CHANGED
|
@@ -140,6 +140,19 @@ export declare function callLanguageQuery(source: string, snapshotJson: string,
|
|
|
140
140
|
ok: boolean;
|
|
141
141
|
json: unknown;
|
|
142
142
|
};
|
|
143
|
+
/**
|
|
144
|
+
* The describing query (crates/movement-language/src/describe.rs
|
|
145
|
+
* `describe_query`): the snapshot and the request as JSON, and the reply —
|
|
146
|
+
* what the snapshot holds, or the one connection or place an address names,
|
|
147
|
+
* as the description value — or `{error}` for a snapshot or a request that
|
|
148
|
+
* does not read.
|
|
149
|
+
*
|
|
150
|
+
* @internal Used by the description's wrapper (service/description.ts).
|
|
151
|
+
*/
|
|
152
|
+
export declare function callDescribeQuery(snapshotJson: string, requestJson: string): {
|
|
153
|
+
ok: boolean;
|
|
154
|
+
json: unknown;
|
|
155
|
+
};
|
|
143
156
|
/**
|
|
144
157
|
* The checker's story analysis (crates/movement-checker/src/story.rs
|
|
145
158
|
* `story_analysis`): `callCheckProgram`'s inputs, and the reply —
|
|
@@ -202,6 +215,15 @@ export declare function callLandingMisfits(inputJson: string): {
|
|
|
202
215
|
ok: boolean;
|
|
203
216
|
json: unknown;
|
|
204
217
|
};
|
|
218
|
+
/**
|
|
219
|
+
* An engine segment ended by V8's stack running out under it, which is not the
|
|
220
|
+
* engine crashing: nothing in it went wrong but how deep the movement went. The
|
|
221
|
+
* instance goes with it, as with a trap.
|
|
222
|
+
*/
|
|
223
|
+
export declare class EngineStackRanOut extends Error {
|
|
224
|
+
readonly call: string;
|
|
225
|
+
constructor(call: string);
|
|
226
|
+
}
|
|
205
227
|
/**
|
|
206
228
|
* One engine segment's conversation (crates/movement-engine/src/abi.rs):
|
|
207
229
|
* `start` and `answer` each return the next step as `{ok: true, json}` —
|
package/dist/wasm/loader.js
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
// Every instance imports `movement_env.call`: the environment services the
|
|
21
21
|
// engine asks JavaScript for mid-evaluation (env_services.ts).
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
exports.MovementParserNotReady = void 0;
|
|
23
|
+
exports.EngineStackRanOut = exports.MovementParserNotReady = void 0;
|
|
24
24
|
exports.initParser = initParser;
|
|
25
25
|
exports.isParserReady = isParserReady;
|
|
26
26
|
exports.assertParserReady = assertParserReady;
|
|
@@ -35,6 +35,7 @@ exports.callStandardLibrary = callStandardLibrary;
|
|
|
35
35
|
exports.callLanguageVersion = callLanguageVersion;
|
|
36
36
|
exports.callLanguageStanding = callLanguageStanding;
|
|
37
37
|
exports.callLanguageQuery = callLanguageQuery;
|
|
38
|
+
exports.callDescribeQuery = callDescribeQuery;
|
|
38
39
|
exports.callStoryAnalysis = callStoryAnalysis;
|
|
39
40
|
exports.callJudgeArrival = callJudgeArrival;
|
|
40
41
|
exports.callListenIdentity = callListenIdentity;
|
|
@@ -202,6 +203,18 @@ function callLanguageStanding(pin) {
|
|
|
202
203
|
function callLanguageQuery(source, snapshotJson, queryJson) {
|
|
203
204
|
return callChecker('language_query', [source, snapshotJson, queryJson], []);
|
|
204
205
|
}
|
|
206
|
+
/**
|
|
207
|
+
* The describing query (crates/movement-language/src/describe.rs
|
|
208
|
+
* `describe_query`): the snapshot and the request as JSON, and the reply —
|
|
209
|
+
* what the snapshot holds, or the one connection or place an address names,
|
|
210
|
+
* as the description value — or `{error}` for a snapshot or a request that
|
|
211
|
+
* does not read.
|
|
212
|
+
*
|
|
213
|
+
* @internal Used by the description's wrapper (service/description.ts).
|
|
214
|
+
*/
|
|
215
|
+
function callDescribeQuery(snapshotJson, requestJson) {
|
|
216
|
+
return callChecker('describe_query', [snapshotJson, requestJson], []);
|
|
217
|
+
}
|
|
205
218
|
/**
|
|
206
219
|
* The checker's story analysis (crates/movement-checker/src/story.rs
|
|
207
220
|
* `story_analysis`): `callCheckProgram`'s inputs, and the reply —
|
|
@@ -295,6 +308,26 @@ function call(fn, inputs, extra) {
|
|
|
295
308
|
}
|
|
296
309
|
return statusReply(reply, `movement parser returned unknown status %s from ${fn}`);
|
|
297
310
|
}
|
|
311
|
+
/** What V8 throws through an instance when its own stack runs out. By its
|
|
312
|
+
* message, since the class is another realm's where a test runner's is (and
|
|
313
|
+
* an engine that words it otherwise, as Bun's does, reads as a crash). */
|
|
314
|
+
function isStackOverflow(error) {
|
|
315
|
+
return error instanceof Error && error.name === 'RangeError' && error.message === 'Maximum call stack size exceeded';
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* An engine segment ended by V8's stack running out under it, which is not the
|
|
319
|
+
* engine crashing: nothing in it went wrong but how deep the movement went. The
|
|
320
|
+
* instance goes with it, as with a trap.
|
|
321
|
+
*/
|
|
322
|
+
class EngineStackRanOut extends Error {
|
|
323
|
+
call;
|
|
324
|
+
constructor(call) {
|
|
325
|
+
super(`the movement engine ran out of stack in ${call}`);
|
|
326
|
+
this.call = call;
|
|
327
|
+
this.name = 'EngineStackRanOut';
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
exports.EngineStackRanOut = EngineStackRanOut;
|
|
298
331
|
/** A call that trapped; `detail` is the trap and the panic message, if any. */
|
|
299
332
|
class WasmTrap extends Error {
|
|
300
333
|
trapped;
|
|
@@ -382,6 +415,8 @@ function openEngineSegment() {
|
|
|
382
415
|
if (!(trap instanceof WasmTrap))
|
|
383
416
|
throw trap;
|
|
384
417
|
state = 'trapped';
|
|
418
|
+
if (isStackOverflow(trap.trapped))
|
|
419
|
+
throw new EngineStackRanOut(fn);
|
|
385
420
|
throw new Error(`movement engine crashed in ${fn}: ${trap.detail}`, { cause: trap.trapped });
|
|
386
421
|
}
|
|
387
422
|
};
|
|
@@ -389,9 +424,19 @@ function openEngineSegment() {
|
|
|
389
424
|
start: inputJson => step('engine_start', inputJson, (pairs, slots) => exports.start(...pairs, slots, slots + 4)),
|
|
390
425
|
answer: (id, answerJson) => step('engine_answer', answerJson, (pairs, slots) => exports.answer(id, ...pairs, slots, slots + 4)),
|
|
391
426
|
finish: () => {
|
|
392
|
-
|
|
393
|
-
exports.finish();
|
|
427
|
+
const open = state === 'open';
|
|
394
428
|
state = 'finished';
|
|
429
|
+
if (!open)
|
|
430
|
+
return;
|
|
431
|
+
try {
|
|
432
|
+
exports.finish();
|
|
433
|
+
}
|
|
434
|
+
catch (error) {
|
|
435
|
+
// Letting go of calls open as deep as the stack held. The instance is
|
|
436
|
+
// never used again, so what it did not get to goes with its memory.
|
|
437
|
+
if (!isStackOverflow(error))
|
|
438
|
+
throw error;
|
|
439
|
+
}
|
|
395
440
|
},
|
|
396
441
|
};
|
|
397
442
|
}
|
|
@@ -438,16 +483,20 @@ function newInstance(module) {
|
|
|
438
483
|
read ??= exportReader(raw, 'movement engine');
|
|
439
484
|
const exports = read;
|
|
440
485
|
let status = OK;
|
|
441
|
-
let
|
|
486
|
+
let bytes;
|
|
442
487
|
try {
|
|
443
488
|
const request = JSON.parse(decoder.decode(memoryBytes(exports).slice(requestPtr, requestPtr + requestLen)));
|
|
444
|
-
|
|
489
|
+
bytes = encoder.encode(JSON.stringify((0, env_services_1.answerEnvRequest)(request)));
|
|
445
490
|
}
|
|
446
491
|
catch (error) {
|
|
492
|
+
// Whatever the host's answer throws, its own stack overflow included
|
|
493
|
+
// (a service recursing on a deep value), is a failed answer. From in
|
|
494
|
+
// here the host's recursion cannot be told from the engine's frames
|
|
495
|
+
// having filled V8's stack; the engine's running out surfaces from its
|
|
496
|
+
// call, at the next frame that needs stack.
|
|
447
497
|
status = ERROR;
|
|
448
|
-
|
|
498
|
+
bytes = encoder.encode(JSON.stringify({ error: { message: error instanceof Error ? error.message : String(error) } }));
|
|
449
499
|
}
|
|
450
|
-
const bytes = encoder.encode(JSON.stringify(reply));
|
|
451
500
|
const ptr = exports.buffers.alloc(bytes.length);
|
|
452
501
|
memoryBytes(exports).set(bytes, ptr);
|
|
453
502
|
const view = new DataView(memoryBuffer(exports));
|
|
@@ -482,6 +531,7 @@ function readExports(raw) {
|
|
|
482
531
|
'language_version',
|
|
483
532
|
'language_standing',
|
|
484
533
|
'language_query',
|
|
534
|
+
'describe_query',
|
|
485
535
|
'story_analysis',
|
|
486
536
|
'judge_arrival',
|
|
487
537
|
'listen_identity',
|
package/dist/wasm/movement.wasm
CHANGED
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@listen-fire/movement-lang",
|
|
3
3
|
"license": "Apache-2.0",
|
|
4
|
-
"version": "0.15.
|
|
4
|
+
"version": "0.15.3",
|
|
5
5
|
"description": "The data-movement language: the wasm parser, checker and engine with their loader and bindings, the version rule, the expression AST and the types the contracts name",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=22.23.4 <23"
|