@delurio/cli 0.10.0 → 0.11.0
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/CHANGELOG.md +9 -0
- package/NOTICE +7 -0
- package/README.md +14 -13
- package/js/changes.d.ts +17 -0
- package/js/cli.js +6 -0
- package/{dist → js}/edges.d.ts +2 -2
- package/js/edges.js +40 -0
- package/js/expr.js +25 -0
- package/js/graph.js +59 -0
- package/{dist → js}/html.d.ts +6 -6
- package/js/html.js +13 -0
- package/js/internal.js +408 -0
- package/js/kit.js +54 -0
- package/{dist → js}/model.d.ts +2 -2
- package/js/model.js +136 -0
- package/js/native.cjs +46 -0
- package/js/native.d.cts +322 -0
- package/{dist → js}/nav.d.ts +1 -1
- package/js/nav.js +70 -0
- package/js/needs.js +30 -0
- package/{dist → js}/spine.d.ts +3 -3
- package/js/spine.js +22 -0
- package/{dist → js}/starts.d.ts +1 -3
- package/{dist → js}/story.d.ts +2 -2
- package/js/story.js +22 -0
- package/{dist → js}/wireframe.d.ts +2 -2
- package/js/wireframe.js +29 -0
- package/js/yaml.d.ts +20 -0
- package/js/yaml.js +40 -0
- package/package.json +40 -24
- package/dist/anchors.d.ts +0 -29
- package/dist/anchors.js +0 -160
- package/dist/changes.d.ts +0 -25
- package/dist/changes.js +0 -101
- package/dist/check.d.ts +0 -23
- package/dist/check.js +0 -649
- package/dist/cli.d.ts +0 -2
- package/dist/cli.js +0 -194
- package/dist/compare.d.ts +0 -34
- package/dist/compare.js +0 -143
- package/dist/diff-flow.d.ts +0 -33
- package/dist/diff-flow.js +0 -547
- package/dist/diff-nav.d.ts +0 -20
- package/dist/diff-nav.js +0 -401
- package/dist/diff.d.ts +0 -25
- package/dist/diff.js +0 -331
- package/dist/domain-names.d.ts +0 -18
- package/dist/domain-names.js +0 -124
- package/dist/domain.d.ts +0 -25
- package/dist/domain.js +0 -110
- package/dist/edges.js +0 -120
- package/dist/expr.js +0 -157
- package/dist/graph.js +0 -236
- package/dist/html.js +0 -311
- package/dist/index-page.d.ts +0 -12
- package/dist/index-page.js +0 -50
- package/dist/invokes.d.ts +0 -10
- package/dist/invokes.js +0 -67
- package/dist/kit.js +0 -711
- package/dist/mermaid.d.ts +0 -3
- package/dist/mermaid.js +0 -50
- package/dist/model.js +0 -608
- package/dist/nav-page.d.ts +0 -15
- package/dist/nav-page.js +0 -283
- package/dist/nav.js +0 -578
- package/dist/needs.js +0 -335
- package/dist/pan.d.ts +0 -2
- package/dist/pan.js +0 -252
- package/dist/schemas.d.ts +0 -15
- package/dist/schemas.js +0 -316
- package/dist/spine.js +0 -156
- package/dist/starts.js +0 -88
- package/dist/story.js +0 -109
- package/dist/tutorial-check.d.ts +0 -9
- package/dist/tutorial-check.js +0 -297
- package/dist/ui-check.d.ts +0 -8
- package/dist/ui-check.js +0 -142
- package/dist/watch.d.ts +0 -5
- package/dist/watch.js +0 -114
- package/dist/wireframe.js +0 -276
- package/dist/yaml.d.ts +0 -19
- package/dist/yaml.js +0 -134
- /package/{dist → js}/expr.d.ts +0 -0
- /package/{dist → js}/graph.d.ts +0 -0
- /package/{dist → js}/kit.d.ts +0 -0
- /package/{dist → js}/needs.d.ts +0 -0
package/js/native.d.cts
ADDED
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
/* auto-generated by NAPI-RS */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* an exploration the addon holds for the JavaScript object explore() gave; V8 is told how much memory it holds, so
|
|
6
|
+
* that an unread exploration is collected as soon as a JavaScript one of its size would be
|
|
7
|
+
*/
|
|
8
|
+
export declare class NativeExploration {
|
|
9
|
+
starts(): number
|
|
10
|
+
size(): number
|
|
11
|
+
taken(): Array<string>
|
|
12
|
+
/** `atState` as JSON entries */
|
|
13
|
+
atState(): string
|
|
14
|
+
/** `branchCounts` as JSON entries */
|
|
15
|
+
branchCounts(): string
|
|
16
|
+
configs(): ConfigsOut
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** a graph the addon holds for the JavaScript object it was read into (js/internal.js keeps the pair) */
|
|
20
|
+
export declare class NativeGraph {
|
|
21
|
+
/** a graph object a caller built (a copy of a loaded one, say), read from its JSON */
|
|
22
|
+
constructor(text: string)
|
|
23
|
+
/** the graph as the object `load` gave */
|
|
24
|
+
json(): string
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export declare class NativeKit {
|
|
28
|
+
/** a kit object a caller built, read from its JSON */
|
|
29
|
+
constructor(text: string)
|
|
30
|
+
/** the kit as the object `loadKit` gives */
|
|
31
|
+
json(): string
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export declare class NativeModel {
|
|
35
|
+
/** the model of a flow the addon holds (js/internal.js reads each flow object once) */
|
|
36
|
+
constructor(flow: NativeValue)
|
|
37
|
+
vars(): Array<string>
|
|
38
|
+
/** for each variable, the place of each of its values (`flow.context[v].values`) in its table */
|
|
39
|
+
domainCodes(): Array<Array<number>>
|
|
40
|
+
/** the variables that start from any of their values (`initial: any`), by position */
|
|
41
|
+
anyVars(): Array<number>
|
|
42
|
+
/** the value at a place of a variable's table, as JSON; undefined as None */
|
|
43
|
+
valueAt(var: number, code: number): string | null
|
|
44
|
+
/** the place of a value in a variable's table, added when no table holds it (undefined: None) */
|
|
45
|
+
codeOf(var: number, value?: string | undefined | null): number
|
|
46
|
+
steps(state: string, ctx: Uint16Array): StepsOut
|
|
47
|
+
initials(): CtxList
|
|
48
|
+
test(expr: string, state: string, ctx: Uint16Array): boolean
|
|
49
|
+
/** `value(expr, state, ctx)`, as JSON */
|
|
50
|
+
value(expr: string, state: string, ctx: Uint16Array): string
|
|
51
|
+
pure(src: string): boolean
|
|
52
|
+
/** `inState(src, state)`, as JSON; undefined as None */
|
|
53
|
+
inState(src: string, state: string): string | null
|
|
54
|
+
/** what `tester(expr)` throws before it is run: nothing, or the error of an expression that cannot be read */
|
|
55
|
+
tester(expr: string): void
|
|
56
|
+
/** the place `placeError` gives an error without one that `steps(state, ctx)` threw, as JSON */
|
|
57
|
+
placeOf(message: string, state: string, ctx: Uint16Array): string | null
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export declare class NativeNav {
|
|
61
|
+
/** a navigation graph object a caller built, read from its JSON */
|
|
62
|
+
constructor(text: string)
|
|
63
|
+
/** the graph as the object `loadNav` gives */
|
|
64
|
+
json(): string
|
|
65
|
+
warnings(): Array<string>
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** any value of a graph file the addon holds for its JavaScript object (a flow, read once for many calls) */
|
|
69
|
+
export declare class NativeValue {
|
|
70
|
+
constructor(text: string)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** `alternatives(spec)`, as JSON */
|
|
74
|
+
export declare function alternativesOf(spec?: string | undefined | null): string
|
|
75
|
+
|
|
76
|
+
/** `checkAssertions(m, ex)`, as JSON */
|
|
77
|
+
export declare function checkAssertions(m: NativeModel, ex: NativeExploration): string
|
|
78
|
+
|
|
79
|
+
/** `checkGoals(g, views)`, as JSON */
|
|
80
|
+
export declare function checkGoals(g: NativeNav, views: string): string
|
|
81
|
+
|
|
82
|
+
/** `checkNeeds(files, app)`, as JSON */
|
|
83
|
+
export declare function checkNeeds(files: Array<string>, app?: string | undefined | null): string
|
|
84
|
+
|
|
85
|
+
/** `collectEdges(g, ex)`, as JSON */
|
|
86
|
+
export declare function collectEdges(g: NativeGraph, ex: NativeExploration): string
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* an exploration's pairs, each list one entry per pair: the state and the event as places in `names` (event 0 is
|
|
90
|
+
* null, k is names[k - 1]), the parent as its position (-1 for a start), the contexts one after the other
|
|
91
|
+
*/
|
|
92
|
+
export interface ConfigsOut {
|
|
93
|
+
names: Array<string>
|
|
94
|
+
state: Uint32Array
|
|
95
|
+
parent: Int32Array
|
|
96
|
+
event: Uint32Array
|
|
97
|
+
ctx: Uint16Array
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** `cover(m, by, from, keep)`, as JSON */
|
|
101
|
+
export declare function cover(m: NativeModel, by: string, from?: Uint16Array | undefined | null, count?: number | undefined | null, keep?: ((arg: KeepArgs) => number) | undefined | null): string
|
|
102
|
+
|
|
103
|
+
/** contexts, one after the other */
|
|
104
|
+
export interface CtxList {
|
|
105
|
+
count: number
|
|
106
|
+
ctx: Uint16Array
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** `drawWith(kit, component, f, warn)` */
|
|
110
|
+
export declare function drawWith(kit: NativeKit, component: string, fill: string, warn: (arg: string) => void): string | null
|
|
111
|
+
|
|
112
|
+
/** `BY`, as JSON */
|
|
113
|
+
export declare function edgesConstants(): string
|
|
114
|
+
|
|
115
|
+
/** `evaluate(e, lookup)`, as JSON: `lookup` gives each name's value as JSON (a trapped one gives null once it threw) */
|
|
116
|
+
export declare function evaluate(e: string, lookup: (arg: string) => string): string
|
|
117
|
+
|
|
118
|
+
/** `exitLine(st)` */
|
|
119
|
+
export declare function exitLine(st?: string | undefined | null): string
|
|
120
|
+
|
|
121
|
+
/** `explore(m, from, keep)` */
|
|
122
|
+
export declare function explore(m: NativeModel, from?: Uint16Array | undefined | null, count?: number | undefined | null, keep?: ((arg: KeepArgs) => number) | undefined | null): NativeExploration
|
|
123
|
+
|
|
124
|
+
/** `finalPaths(m, ex)`, as JSON */
|
|
125
|
+
export declare function finalPaths(m: NativeModel, ex: NativeExploration): string
|
|
126
|
+
|
|
127
|
+
/** `findings(g, views, goals)`, as JSON */
|
|
128
|
+
export declare function findings(g: NativeNav, views: string, goals: string): string
|
|
129
|
+
|
|
130
|
+
/** `focusAfter(ui, from, to, pressed)`, as JSON (null when nothing has the focus) */
|
|
131
|
+
export declare function focusAfterStep(ui: string, from: string | undefined | null, to: string, pressed?: string | undefined | null): string
|
|
132
|
+
|
|
133
|
+
/** `frameLevel(e)`, the entry as JSON */
|
|
134
|
+
export declare function frameLevel(entry: string): boolean
|
|
135
|
+
|
|
136
|
+
/** `frameReached(g, v, frame)`, the view as JSON */
|
|
137
|
+
export declare function frameReached(g: NativeNav, view: string, frame: string): boolean
|
|
138
|
+
|
|
139
|
+
/** OPENER and CHECKABLE */
|
|
140
|
+
export declare function graphConstants(): string
|
|
141
|
+
|
|
142
|
+
/** `guardCodes(g, src, depth)` */
|
|
143
|
+
export declare function guardCodes(g: NativeNav, src: string, depth?: number | undefined | null): Array<string>
|
|
144
|
+
|
|
145
|
+
/** `holds(g, p, expr)` */
|
|
146
|
+
export declare function holds(g: NativeNav, persona: string, expr?: string | undefined | null): boolean
|
|
147
|
+
|
|
148
|
+
export declare function humanize(id: string): string
|
|
149
|
+
|
|
150
|
+
/** `identifiers(e)`, in the order the expression reads them */
|
|
151
|
+
export declare function identifiers(e: string): Array<string>
|
|
152
|
+
|
|
153
|
+
/** `isDialog(n)` */
|
|
154
|
+
export declare function isDialogNode(node?: string | undefined | null): boolean
|
|
155
|
+
|
|
156
|
+
/** `keyAt(text, path)`, as JSON */
|
|
157
|
+
export declare function keyAt(text: string, path: Array<string>): string
|
|
158
|
+
|
|
159
|
+
/** `kindOf(g, name)` */
|
|
160
|
+
export declare function kindOf(g: NativeGraph, name: string): string
|
|
161
|
+
|
|
162
|
+
/** `kitCss(kit, target)` */
|
|
163
|
+
export declare function kitCss(kit: NativeKit, target: string): string
|
|
164
|
+
|
|
165
|
+
/** `kitStageScript(kit)` */
|
|
166
|
+
export declare function kitStageScript(kit: NativeKit): string
|
|
167
|
+
|
|
168
|
+
/** `lineAndColumn(text, offset)`, as JSON */
|
|
169
|
+
export declare function lineAndColumn(text: string, offset: number): string
|
|
170
|
+
|
|
171
|
+
/** `load(dir, read, exists)` */
|
|
172
|
+
export declare function load(dir: string, read: (arg: string) => ReadOut, exists: (arg: string) => number): NativeGraph
|
|
173
|
+
|
|
174
|
+
/** `loadKit(path)` */
|
|
175
|
+
export declare function loadKit(path: string): NativeKit
|
|
176
|
+
|
|
177
|
+
/** `loadNav(dir, locale, read)` */
|
|
178
|
+
export declare function loadNav(dir: string, locale: string | undefined | null, read: (arg: string) => ReadOut): NativeNav
|
|
179
|
+
|
|
180
|
+
/** `mainStoryIndex(g, ex)` */
|
|
181
|
+
export declare function mainStoryIndex(g: NativeGraph, ex: NativeExploration): number | null
|
|
182
|
+
|
|
183
|
+
/** `mark(html, id, chips)` */
|
|
184
|
+
export declare function mark(html: string, id: string, chips: string): string
|
|
185
|
+
|
|
186
|
+
/** `menuRows(g, views)`, as JSON */
|
|
187
|
+
export declare function menuRows(g: NativeNav, views: string): string
|
|
188
|
+
|
|
189
|
+
/** `narrate(g, m, steps)`, as JSON */
|
|
190
|
+
export declare function narrate(g: NativeGraph, m: NativeModel, steps: PathSteps): string
|
|
191
|
+
|
|
192
|
+
/** `pathTo(reach, page)`, the reach as JSON entries; the entries of the way as JSON */
|
|
193
|
+
export declare function navPathTo(reach: string, page: string): string
|
|
194
|
+
|
|
195
|
+
/** NEEDS_FILE and GAPS_FILE */
|
|
196
|
+
export declare function needsConstants(): string
|
|
197
|
+
|
|
198
|
+
/** `nodeLine(g, name)` */
|
|
199
|
+
export declare function nodeLine(g: NativeGraph, name: string): string
|
|
200
|
+
|
|
201
|
+
/** `nodeTexts(g, id, warn)` */
|
|
202
|
+
export declare function nodeTexts(g: NativeGraph, id: string, warn: (arg: string) => void): Array<string>
|
|
203
|
+
|
|
204
|
+
/** `CSS` */
|
|
205
|
+
export declare function pageCss(): string
|
|
206
|
+
|
|
207
|
+
/** `callLine(a)` and `renderPage(p)`: not in the npm package */
|
|
208
|
+
export declare function pageNotPorted(name: string): void
|
|
209
|
+
|
|
210
|
+
/** `parseExpr(src)`, as JSON */
|
|
211
|
+
export declare function parseExpr(src: string): string
|
|
212
|
+
|
|
213
|
+
/** `parsingOnce(run)`: `run` is a trapped callback that keeps its own result */
|
|
214
|
+
export declare function parsingOnce(run: () => void): void
|
|
215
|
+
|
|
216
|
+
export interface PathSteps {
|
|
217
|
+
state: Array<string>
|
|
218
|
+
event: Array<string | undefined | null>
|
|
219
|
+
taken: Array<string | undefined | null>
|
|
220
|
+
ctx: Uint16Array
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/** `pathTo(m, ex, index)`, as JSON */
|
|
224
|
+
export declare function pathTo(m: NativeModel, ex: NativeExploration, index: number): string
|
|
225
|
+
|
|
226
|
+
/** `plain(g, key)` */
|
|
227
|
+
export declare function plain(g: NativeGraph, key: string): string
|
|
228
|
+
|
|
229
|
+
/** `planned(needs)`, as JSON entries of its two Maps */
|
|
230
|
+
export declare function planned(needs?: string | undefined | null): string
|
|
231
|
+
|
|
232
|
+
/** `pressLabel(g, state, event)` */
|
|
233
|
+
export declare function pressLabel(g: NativeGraph, state: string, event: string): string | null
|
|
234
|
+
|
|
235
|
+
/** `readNeeds(dir)`, as JSON (null when the folder has none) */
|
|
236
|
+
export declare function readNeeds(dir: string): string
|
|
237
|
+
|
|
238
|
+
/** what a trapped reader gives: the text it read, or the message of what it threw */
|
|
239
|
+
export interface ReadOut {
|
|
240
|
+
ok?: string
|
|
241
|
+
thrown?: string
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* `readYaml(text)`, as JSON. Its error is the library's YAMLParseError: the place the parser gives it (`pos`, as
|
|
246
|
+
* offsets, and `linePos`) is added to the error, as the library's error has it
|
|
247
|
+
*/
|
|
248
|
+
export declare function readYaml(text: string): string
|
|
249
|
+
|
|
250
|
+
/** `refusedFor(g, p, page)` */
|
|
251
|
+
export declare function refusedFor(g: NativeNav, persona: string, page: string): boolean
|
|
252
|
+
|
|
253
|
+
/** `renderCheckScreens(g, kit, warn)`, as JSON */
|
|
254
|
+
export declare function renderCheckScreens(g: NativeGraph, kit: NativeKit | undefined | null, warn: (arg: string) => void): string
|
|
255
|
+
|
|
256
|
+
/** `renderScreens(g, warn, kit)` */
|
|
257
|
+
export declare function renderScreens(g: NativeGraph, warn: (arg: string) => void, kit?: NativeKit | undefined | null): string
|
|
258
|
+
|
|
259
|
+
/** `renderStageScreen(g, state, reveal, warn, kit)` */
|
|
260
|
+
export declare function renderStageScreen(g: NativeGraph, state: string, reveal: Array<string>, warn: (arg: string) => void, kit?: NativeKit | undefined | null): string
|
|
261
|
+
|
|
262
|
+
/** `resolveKit(graphDir, uiKit, flagValue)` */
|
|
263
|
+
export declare function resolveKit(graphDir: string, uiKit?: string | undefined | null, flagValue?: string | undefined | null): NativeKit | null
|
|
264
|
+
|
|
265
|
+
/** `responseLine(r)` */
|
|
266
|
+
export declare function responseLine(r: string): string
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* `delurio <args>`, the whole command line, in this process: its exit code. What it writes goes to the process's
|
|
270
|
+
* own stdout and stderr, flushed before it returns (nothing of Rust's runs after, to flush them at exit).
|
|
271
|
+
*/
|
|
272
|
+
export declare function runCli(args: Array<string>): number
|
|
273
|
+
|
|
274
|
+
/** `shownIn(n, state)` */
|
|
275
|
+
export declare function shownInState(node: string, state: string): boolean
|
|
276
|
+
|
|
277
|
+
/** the graph `renderSpine` hands elkjs, as JSON */
|
|
278
|
+
export declare function spineGraph(g: NativeGraph, ex: NativeExploration, view: string, story?: Array<string> | undefined | null): string
|
|
279
|
+
|
|
280
|
+
/** the SVG `renderSpine` gives, from the layout elkjs gave back (as JSON) */
|
|
281
|
+
export declare function spineSvg(g: NativeGraph, ex: NativeExploration, view: string, story: Array<string> | undefined | null, laid: string): string
|
|
282
|
+
|
|
283
|
+
/** `stepsByEvents(m, main)` */
|
|
284
|
+
export declare function stepsByEvents(m: NativeModel, main?: string | undefined | null): PathSteps | null
|
|
285
|
+
|
|
286
|
+
/** the steps out of a pair: one entry per step in each list, the contexts one after the other */
|
|
287
|
+
export interface StepsOut {
|
|
288
|
+
event: Array<string | undefined | null>
|
|
289
|
+
target: Array<string>
|
|
290
|
+
taken: Array<string>
|
|
291
|
+
ctx: Uint16Array
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/** `stepsTo(m, ex, index)` */
|
|
295
|
+
export declare function stepsTo(m: NativeModel, ex: NativeExploration, index: number): PathSteps
|
|
296
|
+
|
|
297
|
+
/** the warnings the YAML reader met since the last call (the library hands each to `process.emitWarning`), as JSON */
|
|
298
|
+
export declare function takeYamlWarnings(): string
|
|
299
|
+
|
|
300
|
+
/** `titleOf(flow, state)` */
|
|
301
|
+
export declare function titleOfState(flow: NativeValue, state: string): string
|
|
302
|
+
|
|
303
|
+
/** `transitionPath(state, st, event, i)` */
|
|
304
|
+
export declare function transitionPathOf(state: string, st: string, event: string | undefined | null, i: number): Array<string>
|
|
305
|
+
|
|
306
|
+
/** `transitionsOf(flow)` */
|
|
307
|
+
export declare function transitionsOf(flow: NativeValue): Array<string>
|
|
308
|
+
|
|
309
|
+
/** `unsupported(text)`, as JSON (null when nothing is) */
|
|
310
|
+
export declare function unsupported(text: string): string
|
|
311
|
+
|
|
312
|
+
/** the version of the checker the addon was built from */
|
|
313
|
+
export declare function version(): string
|
|
314
|
+
|
|
315
|
+
/** `viewOf(g, p)`, as JSON */
|
|
316
|
+
export declare function viewOf(g: NativeNav, persona: string): string
|
|
317
|
+
|
|
318
|
+
/** `walk(g, p)`, as JSON entries */
|
|
319
|
+
export declare function walk(g: NativeNav, persona: string): string
|
|
320
|
+
|
|
321
|
+
/** `wrap(text, max)` */
|
|
322
|
+
export declare function wrap(text: string, max: number): Array<string>
|
package/{dist → js}/nav.d.ts
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Value } from './expr.
|
|
1
|
+
import type { Value } from './expr.js';
|
|
2
2
|
export type PageKind = 'screen' | 'placeholder' | 'missing' | 'redirect' | 'external';
|
|
3
3
|
export type FrameId = string;
|
|
4
4
|
export type How = 'auto' | 'menu' | 'picker' | 'user' | 'link' | 'button';
|
package/js/nav.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// A navigation graph (SPEC.md §6): the pages of an app, the ways between them, who may open them, and the walks each
|
|
2
|
+
// persona takes. The checker is the Rust one (crates/delurio-core/src/nav.rs); a graph loadNav read stays in the
|
|
3
|
+
// addon for the object it gave, and what the addon gives back names the graph's own entries, goals and personas.
|
|
4
|
+
import { readFileSync } from 'node:fs';
|
|
5
|
+
import { join } from 'node:path';
|
|
6
|
+
import { Trap, call, json, native, nativeNav, rememberNav, warnings } from './internal.js';
|
|
7
|
+
|
|
8
|
+
export const frameLevel = (e) => native.frameLevel(json(e));
|
|
9
|
+
|
|
10
|
+
export function loadNav(dir, locale, read = (file) => readFileSync(join(dir, file), 'utf8')) {
|
|
11
|
+
const t = new Trap();
|
|
12
|
+
try {
|
|
13
|
+
const n = call(t, () => native.loadNav(String(dir), locale ?? undefined, t.reader(read)));
|
|
14
|
+
return { g: rememberNav(JSON.parse(n.json()), n), warnings: n.warnings() };
|
|
15
|
+
} finally {
|
|
16
|
+
warnings();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function holds(g, p, expr) {
|
|
21
|
+
return call(null, () => native.holds(nativeNav(g), json(p), expr ?? undefined));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const refusedFor = (g, p, page) => call(null, () => native.refusedFor(nativeNav(g), json(p), String(page)));
|
|
25
|
+
|
|
26
|
+
// a reach as the addon gives it, its entry the graph's own
|
|
27
|
+
const reachOf = (g, r) => ({ page: r.page, clicks: r.clicks, via: r.via === null ? null : (g.entries[r.via] ?? null), prev: r.prev, usesData: r.usesData, byAddress: r.byAddress });
|
|
28
|
+
|
|
29
|
+
// a view as the addon reads it: its reach as the entries of the Map
|
|
30
|
+
const viewJson = (v) => ({ persona: v.persona, reach: v.reach instanceof Map ? [...v.reach] : Object.entries(v.reach ?? {}), standing: v.standing, landing: v.landing });
|
|
31
|
+
|
|
32
|
+
// Fewest clicks from "start"; ties go to the entry written first.
|
|
33
|
+
export function walk(g, p) {
|
|
34
|
+
const entries = JSON.parse(call(null, () => native.walk(nativeNav(g), json(p))));
|
|
35
|
+
return new Map(entries.map(([k, r]) => [k, reachOf(g, r)]));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function pathTo(reach, page) {
|
|
39
|
+
const list = [...reach];
|
|
40
|
+
const way = JSON.parse(native.navPathTo(JSON.stringify(list), String(page)));
|
|
41
|
+
return way.map((k) => (k === null ? undefined : list[k][1].via));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function viewOf(g, p) {
|
|
45
|
+
const v = JSON.parse(call(null, () => native.viewOf(nativeNav(g), json(p))));
|
|
46
|
+
return { persona: p, reach: new Map(v.reach.map(([k, r]) => [k, reachOf(g, r)])), standing: Object.fromEntries(v.standing), landing: v.landing };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export const frameReached = (g, v, frame) => native.frameReached(nativeNav(g), JSON.stringify(viewJson(v)), String(frame));
|
|
50
|
+
|
|
51
|
+
// One row per menu entry written in the graph; a column per persona.
|
|
52
|
+
export function menuRows(g, views) {
|
|
53
|
+
const rows = JSON.parse(call(null, () => native.menuRows(nativeNav(g), JSON.stringify(views.map(viewJson)))));
|
|
54
|
+
return rows.map((r) => ({ spec: r.spec, frame: r.frame, entry: r.entry === null ? undefined : g.entries[r.entry], frameKnown: r.frameKnown, cells: r.cells }));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function checkGoals(g, views) {
|
|
58
|
+
const checks = JSON.parse(call(null, () => native.checkGoals(nativeNav(g), JSON.stringify(views.map(viewJson)))));
|
|
59
|
+
return checks.map((c) => ({ goal: c.goal === null ? undefined : g.goals[c.goal], persona: c.persona === null ? undefined : views[c.persona].persona, outcome: c.outcome, clicks: c.clicks }));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function findings(g, views, goals) {
|
|
63
|
+
const checks = goals.map((c) => ({ goal: c.goal, persona: c.persona, outcome: c.outcome, clicks: c.clicks }));
|
|
64
|
+
return JSON.parse(call(null, () => native.findings(nativeNav(g), JSON.stringify(views.map(viewJson)), JSON.stringify(checks))));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// the permission codes a guard asks `'code' in held` about, named guards followed
|
|
68
|
+
export function guardCodes(g, src, depth = 0) {
|
|
69
|
+
return new Set(call(null, () => native.guardCodes(nativeNav(g), String(src), depth)));
|
|
70
|
+
}
|
package/js/needs.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// A flow's needs held to their evidence, and a product's gaps to its needs (SPEC.md §13). The checker is the Rust one
|
|
2
|
+
// (crates/delurio-core/src/needs.rs).
|
|
3
|
+
import { call, json, native, warnings } from './internal.js';
|
|
4
|
+
|
|
5
|
+
const constants = JSON.parse(native.needsConstants());
|
|
6
|
+
|
|
7
|
+
export const NEEDS_FILE = constants.NEEDS_FILE;
|
|
8
|
+
export const GAPS_FILE = constants.GAPS_FILE;
|
|
9
|
+
|
|
10
|
+
export function readNeeds(dir) {
|
|
11
|
+
try {
|
|
12
|
+
return JSON.parse(call(null, () => native.readNeeds(String(dir))));
|
|
13
|
+
} finally {
|
|
14
|
+
warnings();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// what only missing needs name: the states and the nodes a walk leaves out, each with the needs that name it
|
|
19
|
+
export function planned(needs) {
|
|
20
|
+
const p = JSON.parse(native.planned(needs === null || needs === undefined ? undefined : json(needs)));
|
|
21
|
+
return { states: new Map(p.states), nodes: new Map(p.nodes) };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function checkNeeds(files, app) {
|
|
25
|
+
try {
|
|
26
|
+
return JSON.parse(native.checkNeeds([...files].map(String), app ?? undefined));
|
|
27
|
+
} finally {
|
|
28
|
+
warnings();
|
|
29
|
+
}
|
|
30
|
+
}
|
package/{dist → js}/spine.d.ts
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Graph } from './graph.
|
|
2
|
-
import type { Exploration } from './model.
|
|
3
|
-
import type { PathStep } from './story.
|
|
1
|
+
import type { Graph } from './graph.js';
|
|
2
|
+
import type { Exploration } from './model.js';
|
|
3
|
+
import type { PathStep } from './story.js';
|
|
4
4
|
export type View = 'main' | 'full';
|
|
5
5
|
/**
|
|
6
6
|
* The flow's diagram as an SVG. Every state's group carries `data-state`, and every edge and its label `data-from` and
|
package/js/spine.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// The flow's diagram as an SVG, laid out by elkjs: the graph handed to elkjs and the SVG drawn from its layout are the
|
|
2
|
+
// Rust checker's (crates/delurio-page/src/spine.rs); the layout is Node's own elkjs, the one delurio's dashboard lays
|
|
3
|
+
// its diagrams out with, so both give the same positions.
|
|
4
|
+
import ElkModule from 'elkjs/lib/elk.bundled.js';
|
|
5
|
+
import { call, native, nativeExploration, nativeGraph } from './internal.js';
|
|
6
|
+
|
|
7
|
+
// elkjs ships CommonJS: under Node ESM the default import is module.exports, which is the constructor
|
|
8
|
+
const Elk = ElkModule;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The flow's diagram as an SVG. Every state's group carries `data-state`, and every edge and its label `data-from` and
|
|
12
|
+
* `data-to`: one edge is drawn per pair of states, its label holding every transition between them. `story`: the
|
|
13
|
+
* states to draw as the story (`on-main`), in order.
|
|
14
|
+
*/
|
|
15
|
+
export async function renderSpine(g, ex, view, story) {
|
|
16
|
+
const n = nativeGraph(g);
|
|
17
|
+
const x = nativeExploration(ex);
|
|
18
|
+
const states = story === null || story === undefined ? undefined : story.map((s) => String(s.state));
|
|
19
|
+
const root = JSON.parse(call(null, () => native.spineGraph(n, x, String(view), states)));
|
|
20
|
+
const laid = await new Elk().layout(root);
|
|
21
|
+
return call(null, () => native.spineSvg(n, x, String(view), states, JSON.stringify(laid)));
|
|
22
|
+
}
|
package/{dist → js}/starts.d.ts
RENAMED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import type { Exploration, Model } from './model.ts';
|
|
1
|
+
// types only, for html.d.ts: what a flow hands over when it starts another (the module is internal to the checker)
|
|
3
2
|
export interface HandOver {
|
|
4
3
|
from: string;
|
|
5
4
|
event: string | null;
|
|
@@ -8,4 +7,3 @@ export interface HandOver {
|
|
|
8
7
|
found: boolean;
|
|
9
8
|
problems: string[];
|
|
10
9
|
}
|
|
11
|
-
export declare function checkStarts(g: Graph, m: Model, ex: Exploration): HandOver[];
|
package/{dist → js}/story.d.ts
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Graph, Scalar } from './graph.
|
|
2
|
-
import type { Exploration, Model } from './model.
|
|
1
|
+
import type { Graph, Scalar } from './graph.js';
|
|
2
|
+
import type { Exploration, Model } from './model.js';
|
|
3
3
|
export interface PathStep {
|
|
4
4
|
state: string;
|
|
5
5
|
ctx: Scalar[];
|
package/js/story.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// A flow's stories: the steps to a situation the exploration reached, the main story the graph declares, and either
|
|
2
|
+
// told in plain words. The checker is the Rust one (crates/delurio-core/src/story.rs).
|
|
3
|
+
import { call, json, native, nativeExploration, nativeGraph, nativeModel, pathSteps, pathStepsOf } from './internal.js';
|
|
4
|
+
|
|
5
|
+
export function stepsTo(m, ex, index) {
|
|
6
|
+
return pathStepsOf(m, call(null, () => native.stepsTo(nativeModel(m), nativeExploration(ex), index)));
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// The main story the graph declares: from a starting situation, send the events in order (`always` rules run by themselves).
|
|
10
|
+
export function stepsByEvents(m, main) {
|
|
11
|
+
const p = call(null, () => native.stepsByEvents(nativeModel(m), main === undefined ? undefined : json(main)));
|
|
12
|
+
return p === null || p === undefined ? null : pathStepsOf(m, p);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// The first success exit reachable through at least one screen: the story a person expects to read first.
|
|
16
|
+
export function mainStoryIndex(g, ex) {
|
|
17
|
+
return native.mainStoryIndex(nativeGraph(g), nativeExploration(ex)) ?? null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function narrate(g, m, steps) {
|
|
21
|
+
return JSON.parse(native.narrate(nativeGraph(g), nativeModel(m), pathSteps(m, steps)));
|
|
22
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Graph } from './graph.
|
|
2
|
-
import type { Kit } from './kit.
|
|
1
|
+
import type { Graph } from './graph.js';
|
|
2
|
+
import type { Kit } from './kit.js';
|
|
3
3
|
type Warn = (message: string) => void;
|
|
4
4
|
export declare function renderScreens(g: Graph, warn: Warn, kit?: Kit | null): string;
|
|
5
5
|
export declare function renderStageScreen(g: Graph, state: string, reveal: string[], warn: Warn, kit?: Kit | null): string;
|
package/js/wireframe.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// A flow's screens as wireframes, drawn with the fixed components or with a kit. The checker is the Rust one
|
|
2
|
+
// (crates/delurio-core/src/wireframe.rs).
|
|
3
|
+
import { Trap, call, native, nativeGraph, nativeKit } from './internal.js';
|
|
4
|
+
|
|
5
|
+
export function renderScreens(g, warn, kit = null) {
|
|
6
|
+
const t = new Trap();
|
|
7
|
+
return call(t, () => native.renderScreens(nativeGraph(g), t.warner(warn), nativeKit(kit)));
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// One state's screen for the tutorial stage. Nodes that depend on a flag (`when`) appear only when named in `reveal`.
|
|
11
|
+
export function renderStageScreen(g, state, reveal, warn, kit = null) {
|
|
12
|
+
const t = new Trap();
|
|
13
|
+
return call(t, () => native.renderStageScreen(nativeGraph(g), String(state), [...(reveal ?? [])].map(String), t.warner(warn), nativeKit(kit)));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// For `kit check`: every screen with all its nodes (flags revealed, no annotations), and what each node must expose.
|
|
17
|
+
export function renderCheckScreens(g, kit, warn) {
|
|
18
|
+
const t = new Trap();
|
|
19
|
+
const out = JSON.parse(call(t, () => native.renderCheckScreens(nativeGraph(g), nativeKit(kit), t.warner(warn))));
|
|
20
|
+
return {
|
|
21
|
+
html: out.html,
|
|
22
|
+
expected: out.expected.map((e) => ({ state: e.state, id: e.id, index: e.index, role: e.role, ...('roleGiven' in e ? { roleGiven: e.roleGiven } : {}), name: e.name, disabled: e.disabled })),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function nodeTexts(g, id, warn) {
|
|
27
|
+
const t = new Trap();
|
|
28
|
+
return call(t, () => native.nodeTexts(nativeGraph(g), String(id), t.warner(warn)));
|
|
29
|
+
}
|
package/js/yaml.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** the code of a YAML error, as the yaml library 2.9.1 names it */
|
|
2
|
+
type ErrorCode = 'ALIAS_PROPS' | 'BAD_ALIAS' | 'BAD_DIRECTIVE' | 'BAD_DQ_ESCAPE' | 'BAD_INDENT' | 'BAD_PROP_ORDER' | 'BAD_SCALAR_START' | 'BLOCK_AS_IMPLICIT_KEY' | 'BLOCK_IN_FLOW' | 'DUPLICATE_KEY' | 'IMPOSSIBLE' | 'KEY_OVER_1024_CHARS' | 'MISSING_CHAR' | 'MULTILINE_IMPLICIT_KEY' | 'MULTIPLE_ANCHORS' | 'MULTIPLE_DOCS' | 'MULTIPLE_TAGS' | 'NON_STRING_KEY' | 'RESOURCE_EXHAUSTION' | 'TAB_AS_INDENT' | 'TAG_RESOLVE_FAILED' | 'UNEXPECTED_TOKEN' | 'BAD_COLLECTION_TYPE';
|
|
3
|
+
export interface Unsupported {
|
|
4
|
+
offset: number;
|
|
5
|
+
line: number;
|
|
6
|
+
column: number;
|
|
7
|
+
code: ErrorCode;
|
|
8
|
+
message: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function lineAndColumn(text: string, offset: number): {
|
|
11
|
+
line: number;
|
|
12
|
+
column: number;
|
|
13
|
+
};
|
|
14
|
+
export declare function unsupported(text: string): Unsupported | null;
|
|
15
|
+
export declare function parsingOnce<T>(run: () => T): T;
|
|
16
|
+
export declare function readYaml(text: string): unknown;
|
|
17
|
+
export declare function keyAt(text: string, path: string[]): {
|
|
18
|
+
line: number;
|
|
19
|
+
column: number;
|
|
20
|
+
};
|
package/js/yaml.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// YAML as delurio reads it (SPEC.md §1): YAML 1.2 without anchors, aliases, tags, or keys that are lists or maps.
|
|
2
|
+
// The reader is the Rust port of the yaml library 2.9.1 (crates/delurio-core/src/yaml).
|
|
3
|
+
import { Trap, call, native, warnings } from './internal.js';
|
|
4
|
+
|
|
5
|
+
// the 1-based line and column of an offset into the text
|
|
6
|
+
export function lineAndColumn(text, offset) {
|
|
7
|
+
return JSON.parse(native.lineAndColumn(String(text), Number(offset)));
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// the first place in the text, by offset, that delurio does not read; null when there is none
|
|
11
|
+
export function unsupported(text) {
|
|
12
|
+
return JSON.parse(native.unsupported(String(text)));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// `run`, with every text it reads through `readYaml` or `keyAt` parsed once; the same as `run` alone otherwise
|
|
16
|
+
export function parsingOnce(run) {
|
|
17
|
+
const t = new Trap();
|
|
18
|
+
let out;
|
|
19
|
+
native.parsingOnce(
|
|
20
|
+
t.runner(() => {
|
|
21
|
+
out = run();
|
|
22
|
+
}),
|
|
23
|
+
);
|
|
24
|
+
if (t.threw) throw t.error;
|
|
25
|
+
return out;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// the value of a graph file's text: the yaml library's `parse`, once nothing unsupported is found
|
|
29
|
+
export function readYaml(text) {
|
|
30
|
+
try {
|
|
31
|
+
return JSON.parse(call(null, () => native.readYaml(String(text))));
|
|
32
|
+
} finally {
|
|
33
|
+
warnings();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// the 1-based line and column of the key at `path` in a YAML text (of the item, for a list index), else the file's start
|
|
38
|
+
export function keyAt(text, path) {
|
|
39
|
+
return JSON.parse(native.keyAt(String(text), [...path].map(String)));
|
|
40
|
+
}
|