routegraph 0.0.0-stage → 0.1.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/AGENTS.md +42 -0
- package/CHANGELOG.md +18 -0
- package/CLAUDE.md +11 -0
- package/LICENSE +21 -0
- package/README.md +439 -2
- package/dist/index.d.mts +793 -0
- package/dist/index.d.ts +793 -0
- package/dist/index.js +2107 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2046 -0
- package/dist/index.mjs.map +1 -0
- package/examples/app.navgraph +166 -0
- package/examples/app.navschema +19 -0
- package/llms.txt +106 -0
- package/package.json +74 -4
- package/schemas/navschema-v1.schema.json +50 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,793 @@
|
|
|
1
|
+
/** Core shared types for AppNav. Everything here is plain data and JSON friendly. */
|
|
2
|
+
type JsonPrimitive = string | number | boolean | null;
|
|
3
|
+
type JsonValue = JsonPrimitive | JsonValue[] | {
|
|
4
|
+
[key: string]: JsonValue;
|
|
5
|
+
};
|
|
6
|
+
type JsonObject = {
|
|
7
|
+
[key: string]: JsonValue;
|
|
8
|
+
};
|
|
9
|
+
type VariableType = "string" | "number" | "boolean" | "null" | "object" | "array" | "any";
|
|
10
|
+
declare const VARIABLE_TYPES: readonly VariableType[];
|
|
11
|
+
type DiagnosticSeverity = "error" | "warning";
|
|
12
|
+
interface Diagnostic {
|
|
13
|
+
severity: DiagnosticSeverity;
|
|
14
|
+
code: string;
|
|
15
|
+
message: string;
|
|
16
|
+
file?: string;
|
|
17
|
+
line?: number;
|
|
18
|
+
column?: number;
|
|
19
|
+
/** Screen, edge, variable or action identifiers involved. */
|
|
20
|
+
ids?: string[];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Payload shapes for the built in actions. This is a convenience for typed
|
|
24
|
+
* narrowing (see `isAction`). Custom schemas can supply their own map through
|
|
25
|
+
* the generic parameter of `isAction`.
|
|
26
|
+
*/
|
|
27
|
+
interface DefaultActionMap {
|
|
28
|
+
TAP: {
|
|
29
|
+
target: string;
|
|
30
|
+
waitFor?: string;
|
|
31
|
+
timeoutMs?: number;
|
|
32
|
+
match?: JsonObject;
|
|
33
|
+
index?: number;
|
|
34
|
+
};
|
|
35
|
+
LONG_PRESS: {
|
|
36
|
+
target: string;
|
|
37
|
+
durationMs?: number;
|
|
38
|
+
};
|
|
39
|
+
TYPE: {
|
|
40
|
+
target: string;
|
|
41
|
+
text: string;
|
|
42
|
+
clearFirst?: boolean;
|
|
43
|
+
};
|
|
44
|
+
SWIPE: {
|
|
45
|
+
direction: "up" | "down" | "left" | "right";
|
|
46
|
+
target?: string;
|
|
47
|
+
distance?: number;
|
|
48
|
+
};
|
|
49
|
+
SCROLL: {
|
|
50
|
+
target?: string;
|
|
51
|
+
to?: string;
|
|
52
|
+
direction?: "up" | "down" | "left" | "right";
|
|
53
|
+
};
|
|
54
|
+
BACK: Record<string, never>;
|
|
55
|
+
WAIT: {
|
|
56
|
+
until?: string;
|
|
57
|
+
durationMs?: number;
|
|
58
|
+
timeoutMs?: number;
|
|
59
|
+
};
|
|
60
|
+
SET_STATE: {
|
|
61
|
+
key: string;
|
|
62
|
+
value: JsonValue;
|
|
63
|
+
};
|
|
64
|
+
ASSERT: {
|
|
65
|
+
condition: string;
|
|
66
|
+
message?: string;
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/** Any object whose keys are action types and whose values are payload shapes. */
|
|
70
|
+
type ActionMap = {
|
|
71
|
+
[type: string]: object;
|
|
72
|
+
};
|
|
73
|
+
interface Screen {
|
|
74
|
+
readonly id: string;
|
|
75
|
+
readonly name: string;
|
|
76
|
+
readonly meta: JsonObject;
|
|
77
|
+
/** Declaration order, used for deterministic tie breaking. */
|
|
78
|
+
readonly index: number;
|
|
79
|
+
}
|
|
80
|
+
interface ActionDeclaration {
|
|
81
|
+
readonly type: string;
|
|
82
|
+
readonly data: JsonObject;
|
|
83
|
+
readonly line?: number;
|
|
84
|
+
readonly column?: number;
|
|
85
|
+
}
|
|
86
|
+
interface Condition {
|
|
87
|
+
readonly source: string;
|
|
88
|
+
readonly ast: ConditionNode;
|
|
89
|
+
}
|
|
90
|
+
type ConditionNode = {
|
|
91
|
+
type: "literal";
|
|
92
|
+
value: JsonValue;
|
|
93
|
+
} | {
|
|
94
|
+
type: "ref";
|
|
95
|
+
path: string[];
|
|
96
|
+
} | {
|
|
97
|
+
type: "not";
|
|
98
|
+
arg: ConditionNode;
|
|
99
|
+
} | {
|
|
100
|
+
type: "and";
|
|
101
|
+
left: ConditionNode;
|
|
102
|
+
right: ConditionNode;
|
|
103
|
+
} | {
|
|
104
|
+
type: "or";
|
|
105
|
+
left: ConditionNode;
|
|
106
|
+
right: ConditionNode;
|
|
107
|
+
} | {
|
|
108
|
+
type: "compare";
|
|
109
|
+
op: string;
|
|
110
|
+
left: ConditionNode;
|
|
111
|
+
right: ConditionNode;
|
|
112
|
+
};
|
|
113
|
+
interface Edge {
|
|
114
|
+
readonly id: string;
|
|
115
|
+
readonly from: string;
|
|
116
|
+
readonly to: string;
|
|
117
|
+
readonly cost: number;
|
|
118
|
+
readonly condition?: Condition;
|
|
119
|
+
readonly actions: readonly ActionDeclaration[];
|
|
120
|
+
readonly meta: JsonObject;
|
|
121
|
+
/** Declaration order, used for deterministic tie breaking. */
|
|
122
|
+
readonly index: number;
|
|
123
|
+
readonly line?: number;
|
|
124
|
+
readonly column?: number;
|
|
125
|
+
}
|
|
126
|
+
interface VariableDeclaration {
|
|
127
|
+
readonly name: string;
|
|
128
|
+
readonly type: VariableType;
|
|
129
|
+
readonly hasDefault: boolean;
|
|
130
|
+
readonly default?: JsonValue;
|
|
131
|
+
readonly line?: number;
|
|
132
|
+
readonly column?: number;
|
|
133
|
+
}
|
|
134
|
+
/** Parsed but unvalidated edge as written in the source. */
|
|
135
|
+
interface RawEdge {
|
|
136
|
+
id?: string;
|
|
137
|
+
from: string;
|
|
138
|
+
to: string;
|
|
139
|
+
cost?: number;
|
|
140
|
+
condition?: string;
|
|
141
|
+
actions: ActionDeclaration[];
|
|
142
|
+
meta: JsonObject;
|
|
143
|
+
line: number;
|
|
144
|
+
column: number;
|
|
145
|
+
}
|
|
146
|
+
interface RawScreen {
|
|
147
|
+
id: string;
|
|
148
|
+
name: string;
|
|
149
|
+
meta: JsonObject;
|
|
150
|
+
line: number;
|
|
151
|
+
column: number;
|
|
152
|
+
}
|
|
153
|
+
/** Intermediate representation produced by `parseGraph`. */
|
|
154
|
+
interface Graph {
|
|
155
|
+
version: number;
|
|
156
|
+
app?: string;
|
|
157
|
+
file?: string;
|
|
158
|
+
variables: VariableDeclaration[];
|
|
159
|
+
screens: RawScreen[];
|
|
160
|
+
edges: RawEdge[];
|
|
161
|
+
hasEnd: boolean;
|
|
162
|
+
}
|
|
163
|
+
type ReadFile = (path: string) => Promise<string>;
|
|
164
|
+
|
|
165
|
+
interface ErrorLocation {
|
|
166
|
+
file?: string;
|
|
167
|
+
line?: number;
|
|
168
|
+
column?: number;
|
|
169
|
+
ids?: string[];
|
|
170
|
+
}
|
|
171
|
+
/** Base class for every error thrown by AppNav. */
|
|
172
|
+
declare class AppNavError extends Error {
|
|
173
|
+
readonly code: string;
|
|
174
|
+
readonly file?: string;
|
|
175
|
+
readonly line?: number;
|
|
176
|
+
readonly column?: number;
|
|
177
|
+
readonly ids?: string[];
|
|
178
|
+
readonly cause?: unknown;
|
|
179
|
+
constructor(code: string, message: string, location?: ErrorLocation, cause?: unknown);
|
|
180
|
+
}
|
|
181
|
+
declare class ParseError extends AppNavError {
|
|
182
|
+
constructor(message: string, location?: ErrorLocation, code?: string);
|
|
183
|
+
}
|
|
184
|
+
declare class UnsupportedVersionError extends AppNavError {
|
|
185
|
+
constructor(version: string | number, location?: ErrorLocation);
|
|
186
|
+
}
|
|
187
|
+
declare class ValidationError extends AppNavError {
|
|
188
|
+
readonly diagnostics: Diagnostic[];
|
|
189
|
+
constructor(diagnostics: Diagnostic[], file?: string);
|
|
190
|
+
}
|
|
191
|
+
declare class SchemaError extends AppNavError {
|
|
192
|
+
constructor(message: string, ids?: string[]);
|
|
193
|
+
}
|
|
194
|
+
declare class VariableError extends AppNavError {
|
|
195
|
+
constructor(message: string, location?: ErrorLocation, code?: string);
|
|
196
|
+
}
|
|
197
|
+
declare class ConditionError extends AppNavError {
|
|
198
|
+
constructor(message: string, location?: ErrorLocation, code?: string);
|
|
199
|
+
}
|
|
200
|
+
declare class UnknownScreenError extends AppNavError {
|
|
201
|
+
constructor(id: string);
|
|
202
|
+
}
|
|
203
|
+
declare class NoPathError extends AppNavError {
|
|
204
|
+
readonly from: string;
|
|
205
|
+
readonly to: string;
|
|
206
|
+
constructor(from: string, to: string, algorithm: string);
|
|
207
|
+
}
|
|
208
|
+
declare class ExtensionError extends AppNavError {
|
|
209
|
+
readonly extension: string;
|
|
210
|
+
constructor(extension: string, message: string, cause?: unknown, ids?: string[]);
|
|
211
|
+
}
|
|
212
|
+
/** Thrown by the synchronous builders when an extension returns a promise. */
|
|
213
|
+
declare class AsyncExtensionError extends AppNavError {
|
|
214
|
+
constructor(what: string);
|
|
215
|
+
}
|
|
216
|
+
declare class ActionHandlerError extends AppNavError {
|
|
217
|
+
constructor(code: string, message: string, ids?: string[], cause?: unknown);
|
|
218
|
+
}
|
|
219
|
+
declare class FileLoadError extends AppNavError {
|
|
220
|
+
constructor(message: string, path?: string, cause?: unknown);
|
|
221
|
+
}
|
|
222
|
+
declare function toDiagnostic(err: AppNavError, severity?: "error" | "warning"): Diagnostic;
|
|
223
|
+
|
|
224
|
+
declare const SUPPORTED_GRAPH_VERSIONS: readonly number[];
|
|
225
|
+
interface ParseOptions {
|
|
226
|
+
/** File name used in error messages. */
|
|
227
|
+
file?: string;
|
|
228
|
+
/** Override the accepted NAVGRAPH versions. */
|
|
229
|
+
supportedVersions?: readonly number[];
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Parse `.navgraph` source text into a Graph. This performs syntax checks only;
|
|
233
|
+
* run `validateGraph` (or `indexGraph`) for semantic checks.
|
|
234
|
+
*
|
|
235
|
+
* Grammar summary:
|
|
236
|
+
* document := "NAVGRAPH/" int item* ["END"]
|
|
237
|
+
* item := app | var | screen | edge
|
|
238
|
+
* app := "APP" string
|
|
239
|
+
* var := "VAR" NAME ":" type ["=" json]
|
|
240
|
+
* screen := "SCREEN" id string [json-object]
|
|
241
|
+
* edge := id "->" id ["[" attr ("," attr)* "]"] ["{" action* "}"]
|
|
242
|
+
* action := "DO" TYPE [json-object]
|
|
243
|
+
* Comments start with # and run to the end of the line. Whitespace between
|
|
244
|
+
* tokens is insignificant except that VAR, SCREEN and APP end at a line break.
|
|
245
|
+
*/
|
|
246
|
+
declare function parseGraph(text: string, options?: ParseOptions): Graph;
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Safe condition language. No eval, no JS.
|
|
250
|
+
*
|
|
251
|
+
* expr := or
|
|
252
|
+
* or := and (("||" | "or") and)*
|
|
253
|
+
* and := not (("&&" | "and") not)*
|
|
254
|
+
* not := ("!" | "not") not | compare
|
|
255
|
+
* compare := primary [op primary] op: == != < <= > >= or a word operator
|
|
256
|
+
* primary := string | number | true | false | null | path | "(" expr ")"
|
|
257
|
+
* path := ident ("." ident)*
|
|
258
|
+
*
|
|
259
|
+
* Unknown values: a path that resolves to nothing is `undefined`. Undefined is
|
|
260
|
+
* falsy, every comparison with undefined is false except "!=" which is true.
|
|
261
|
+
* Set `strict` to throw instead.
|
|
262
|
+
*/
|
|
263
|
+
type ConditionOperator = (left: JsonValue | undefined, right: JsonValue | undefined) => boolean;
|
|
264
|
+
interface ConditionContext {
|
|
265
|
+
variables?: Readonly<Record<string, JsonValue>>;
|
|
266
|
+
state?: Readonly<Record<string, unknown>>;
|
|
267
|
+
}
|
|
268
|
+
interface ConditionOptions {
|
|
269
|
+
/** Extra word operators, e.g. { startsWith: (a, b) => ... }. */
|
|
270
|
+
operators?: Readonly<Record<string, ConditionOperator>>;
|
|
271
|
+
/** Throw on unknown paths instead of treating them as undefined. */
|
|
272
|
+
strict?: boolean;
|
|
273
|
+
}
|
|
274
|
+
declare const BUILTIN_OPERATORS: Readonly<Record<string, ConditionOperator>>;
|
|
275
|
+
/** Parse a condition expression into an AST. Throws ConditionError on bad syntax. */
|
|
276
|
+
declare function parseCondition(source: string): Condition;
|
|
277
|
+
/** All paths referenced by a condition, as dotted strings. */
|
|
278
|
+
declare function conditionRefs(node: ConditionNode, out?: string[]): string[];
|
|
279
|
+
/** Evaluate a parsed condition against a context. */
|
|
280
|
+
declare function evaluateCondition(condition: Condition | ConditionNode, ctx?: ConditionContext, options?: ConditionOptions): boolean;
|
|
281
|
+
|
|
282
|
+
type VariableScope = Readonly<Record<string, JsonValue>>;
|
|
283
|
+
interface ScopeInputs {
|
|
284
|
+
/** Route inputs. Override graph defaults. */
|
|
285
|
+
variables?: Readonly<Record<string, JsonValue>>;
|
|
286
|
+
/** Runtime values discovered during execution. Override route inputs. */
|
|
287
|
+
runtime?: Readonly<Record<string, JsonValue>>;
|
|
288
|
+
/** When true, values for undeclared variables are rejected. */
|
|
289
|
+
strict?: boolean;
|
|
290
|
+
}
|
|
291
|
+
type Segment = {
|
|
292
|
+
kind: "text";
|
|
293
|
+
value: string;
|
|
294
|
+
} | {
|
|
295
|
+
kind: "var";
|
|
296
|
+
name: string;
|
|
297
|
+
};
|
|
298
|
+
/**
|
|
299
|
+
* Tokenise a template string. `$NAME$` is a reference, `$$` is a literal `$`.
|
|
300
|
+
* A lone `$` that does not form a reference is kept as text.
|
|
301
|
+
*/
|
|
302
|
+
declare function parseTemplate(input: string): Segment[];
|
|
303
|
+
/** Names of all variables referenced anywhere inside a JSON value (strings only, not keys). */
|
|
304
|
+
declare function collectReferences(value: JsonValue, out?: Set<string>): Set<string>;
|
|
305
|
+
declare function typeOfValue(v: unknown): VariableType;
|
|
306
|
+
declare function matchesType(v: unknown, type: VariableType): boolean;
|
|
307
|
+
/**
|
|
308
|
+
* Build the effective variable scope.
|
|
309
|
+
* Precedence, lowest to highest: graph defaults, route inputs, runtime values.
|
|
310
|
+
* Every supplied value for a declared variable is type checked.
|
|
311
|
+
*/
|
|
312
|
+
declare function buildScope(declarations: Readonly<Record<string, VariableDeclaration>>, inputs?: ScopeInputs): VariableScope;
|
|
313
|
+
/** Resolve `$VAR$` references inside a JSON value. Returns a new value; the input is untouched. */
|
|
314
|
+
declare function resolveValue(value: JsonValue, scope: VariableScope, declarations?: Readonly<Record<string, VariableDeclaration>>, where?: {
|
|
315
|
+
ids?: string[];
|
|
316
|
+
}): JsonValue;
|
|
317
|
+
|
|
318
|
+
type PropertyType = "string" | "number" | "integer" | "boolean" | "null" | "object" | "array" | "any";
|
|
319
|
+
interface PropertySchema {
|
|
320
|
+
type?: PropertyType | PropertyType[];
|
|
321
|
+
description?: string;
|
|
322
|
+
enum?: JsonValue[];
|
|
323
|
+
minimum?: number;
|
|
324
|
+
maximum?: number;
|
|
325
|
+
/** For objects. */
|
|
326
|
+
required?: string[];
|
|
327
|
+
properties?: Record<string, PropertySchema>;
|
|
328
|
+
additionalProperties?: boolean | PropertySchema;
|
|
329
|
+
/** For arrays. */
|
|
330
|
+
items?: PropertySchema;
|
|
331
|
+
}
|
|
332
|
+
interface ActionDefinition extends PropertySchema {
|
|
333
|
+
description?: string;
|
|
334
|
+
}
|
|
335
|
+
interface SchemaDefinition {
|
|
336
|
+
$schema?: string;
|
|
337
|
+
schemaVersion: 1;
|
|
338
|
+
name?: string;
|
|
339
|
+
/** "default", the name of a registered schema, or a file path when using loadSchema(). */
|
|
340
|
+
extends?: string;
|
|
341
|
+
/** Inherited action names this schema intentionally redefines. */
|
|
342
|
+
overrides?: string[];
|
|
343
|
+
/** Inherited action names this schema intentionally removes. */
|
|
344
|
+
remove?: string[];
|
|
345
|
+
actions?: Record<string, ActionDefinition>;
|
|
346
|
+
/** Validation for custom edge attributes such as [label="x"]. */
|
|
347
|
+
edgeMetadata?: Record<string, PropertySchema>;
|
|
348
|
+
/** Validation for SCREEN metadata objects. */
|
|
349
|
+
screenMetadata?: Record<string, PropertySchema>;
|
|
350
|
+
}
|
|
351
|
+
interface ResolvedSchema {
|
|
352
|
+
readonly schemaVersion: 1;
|
|
353
|
+
readonly name: string;
|
|
354
|
+
readonly actions: Readonly<Record<string, ActionDefinition>>;
|
|
355
|
+
readonly edgeMetadata: Readonly<Record<string, PropertySchema>>;
|
|
356
|
+
readonly screenMetadata: Readonly<Record<string, PropertySchema>>;
|
|
357
|
+
}
|
|
358
|
+
declare const DEFAULT_SCHEMA_DEFINITION: SchemaDefinition;
|
|
359
|
+
/** Resolve a schema definition, applying `extends`. Synchronous; `extends` must be "default" or registered. */
|
|
360
|
+
declare function resolveSchema(def: SchemaDefinition, parent?: ResolvedSchema): ResolvedSchema;
|
|
361
|
+
declare function getDefaultSchema(): ResolvedSchema;
|
|
362
|
+
/** Register a named schema so other schemas can `extends` it. */
|
|
363
|
+
declare function registerSchema(name: string, schema: SchemaDefinition | ResolvedSchema): ResolvedSchema;
|
|
364
|
+
declare function unregisterSchema(name: string): boolean;
|
|
365
|
+
interface LoadSchemaOptions {
|
|
366
|
+
readFile?: ReadFile;
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Load a schema. Accepts nothing (the default schema), a definition object, an
|
|
370
|
+
* already resolved schema, or a file path (JSON). File based `extends` chains work.
|
|
371
|
+
*/
|
|
372
|
+
declare function loadSchema(input?: string | SchemaDefinition | ResolvedSchema, options?: LoadSchemaOptions): Promise<ResolvedSchema>;
|
|
373
|
+
interface ValidationContext {
|
|
374
|
+
declarations?: Readonly<Record<string, VariableDeclaration>>;
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Validate a JSON value against a PropertySchema. Strings that are exactly one
|
|
378
|
+
* `$VAR$` reference are checked against the variable's declared type instead of
|
|
379
|
+
* the string value. Returns a list of human readable problems.
|
|
380
|
+
*/
|
|
381
|
+
declare function validateAgainst(value: unknown, schema: PropertySchema, path: string, ctx?: ValidationContext): string[];
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Default file reader. Uses Node's built in fs when it is available and
|
|
385
|
+
* otherwise explains how to supply a reader. React Native has no filesystem
|
|
386
|
+
* access by default, so pass `readFile` (for example from expo-file-system or
|
|
387
|
+
* react-native-fs) or use the in-memory APIs such as `indexTreeFromText`.
|
|
388
|
+
*/
|
|
389
|
+
declare const defaultReadFile: ReadFile;
|
|
390
|
+
|
|
391
|
+
interface ValidateOptions {
|
|
392
|
+
/** Require condition identifiers to be declared VARs. Default false (unknown names are looked up in app state). */
|
|
393
|
+
strictConditions?: boolean;
|
|
394
|
+
/** Allow `$NAME$` references to variables that are not declared. Default false. */
|
|
395
|
+
allowUndeclaredVariables?: boolean;
|
|
396
|
+
/** Extra word operators permitted in conditions. */
|
|
397
|
+
conditionOperators?: Readonly<Record<string, ConditionOperator>>;
|
|
398
|
+
}
|
|
399
|
+
interface ValidationResult {
|
|
400
|
+
ok: boolean;
|
|
401
|
+
errors: Diagnostic[];
|
|
402
|
+
warnings: Diagnostic[];
|
|
403
|
+
diagnostics: Diagnostic[];
|
|
404
|
+
}
|
|
405
|
+
/** Semantic validation of a parsed graph. Never throws for graph problems. */
|
|
406
|
+
declare function validateGraph(graph: Graph, schema?: SchemaDefinition | ResolvedSchema, options?: ValidateOptions): ValidationResult;
|
|
407
|
+
/** Throws a ValidationError when the result has errors. */
|
|
408
|
+
declare function assertValid(result: ValidationResult, file?: string): void;
|
|
409
|
+
interface IndexOptions extends ParseOptions, ValidateOptions {
|
|
410
|
+
/** A schema object, or a resolved schema. For file paths use indexTree(). */
|
|
411
|
+
schema?: SchemaDefinition | ResolvedSchema;
|
|
412
|
+
/** Cost applied to edges that do not declare one. Default 1. */
|
|
413
|
+
defaultCost?: number;
|
|
414
|
+
/** "throw" (default) raises ValidationError. "collect" keeps going and records tree.diagnostics. */
|
|
415
|
+
diagnostics?: "throw" | "collect";
|
|
416
|
+
}
|
|
417
|
+
interface IndexFileOptions extends Omit<IndexOptions, "schema"> {
|
|
418
|
+
/** Schema object, resolved schema, or path to a .navschema JSON file. */
|
|
419
|
+
schema?: string | SchemaDefinition | ResolvedSchema;
|
|
420
|
+
/** Custom file reader. Required in runtimes without Node's fs (React Native). */
|
|
421
|
+
readFile?: ReadFile;
|
|
422
|
+
}
|
|
423
|
+
/** Methods and data shared by every tree. */
|
|
424
|
+
declare class NavigationTree {
|
|
425
|
+
readonly app?: string;
|
|
426
|
+
readonly version: number;
|
|
427
|
+
readonly file?: string;
|
|
428
|
+
readonly schema: ResolvedSchema;
|
|
429
|
+
readonly variables: Readonly<Record<string, VariableDeclaration>>;
|
|
430
|
+
readonly screens: ReadonlyMap<string, Screen>;
|
|
431
|
+
readonly edges: readonly Edge[];
|
|
432
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
433
|
+
private readonly adjacency;
|
|
434
|
+
private readonly reverse;
|
|
435
|
+
constructor(parts: {
|
|
436
|
+
app?: string;
|
|
437
|
+
version: number;
|
|
438
|
+
file?: string;
|
|
439
|
+
schema: ResolvedSchema;
|
|
440
|
+
variables: Record<string, VariableDeclaration>;
|
|
441
|
+
screens: Map<string, Screen>;
|
|
442
|
+
edges: Edge[];
|
|
443
|
+
diagnostics: Diagnostic[];
|
|
444
|
+
});
|
|
445
|
+
/** Authoritative lookup. Throws UnknownScreenError when missing. */
|
|
446
|
+
screen(id: string): Screen;
|
|
447
|
+
hasScreen(id: string): boolean;
|
|
448
|
+
/** Edges leaving a screen, in declaration order. */
|
|
449
|
+
outgoing(id: string): readonly Edge[];
|
|
450
|
+
incoming(id: string): readonly Edge[];
|
|
451
|
+
edge(id: string): Edge | undefined;
|
|
452
|
+
/** Plain JSON snapshot of the graph. */
|
|
453
|
+
toJSON(): JsonObject;
|
|
454
|
+
}
|
|
455
|
+
type Reserved = keyof NavigationTree;
|
|
456
|
+
/**
|
|
457
|
+
* A tree plus `tree.<screenId>` shortcuts. Provide the ids as a type argument
|
|
458
|
+
* for typed shortcuts: `indexTree<"home" | "cart">(...)`. Without a type
|
|
459
|
+
* argument only the core API is typed; use `tree.screen("id")`.
|
|
460
|
+
*/
|
|
461
|
+
type NavTree<Id extends string = string> = NavigationTree & (string extends Id ? unknown : {
|
|
462
|
+
readonly [K in Exclude<Id, Reserved | "constructor" | "__proto__">]: Screen;
|
|
463
|
+
});
|
|
464
|
+
declare function indexGraph<Id extends string = string>(graph: Graph, options?: IndexOptions): NavTree<Id>;
|
|
465
|
+
/** Synchronous: parse, validate and index graph text that is already in memory. */
|
|
466
|
+
declare function indexTreeFromText<Id extends string = string>(text: string, options?: IndexOptions): NavTree<Id>;
|
|
467
|
+
/** Async: read a .navgraph file (and optional schema file), then parse, validate and index it. */
|
|
468
|
+
declare function indexTree<Id extends string = string>(path: string, options?: IndexFileOptions): Promise<NavTree<Id>>;
|
|
469
|
+
|
|
470
|
+
declare const ASTAR: "astar";
|
|
471
|
+
declare const DIJKSTRA: "dijkstra";
|
|
472
|
+
declare const BFS: "bfs";
|
|
473
|
+
type BuiltinAlgorithm = typeof ASTAR | typeof DIJKSTRA | typeof BFS;
|
|
474
|
+
type Heuristic = (from: Screen, goal: Screen, tree: NavigationTree) => number;
|
|
475
|
+
interface SearchContext {
|
|
476
|
+
readonly tree: NavigationTree;
|
|
477
|
+
readonly start: Screen;
|
|
478
|
+
readonly goal: Screen;
|
|
479
|
+
/** Traversable edges leaving a screen, already filtered by conditions, in declaration order. */
|
|
480
|
+
neighbors(screen: Screen): readonly Edge[];
|
|
481
|
+
/** Validated edge cost. */
|
|
482
|
+
cost(edge: Edge): number;
|
|
483
|
+
heuristic(screen: Screen): number;
|
|
484
|
+
}
|
|
485
|
+
interface SearchResult {
|
|
486
|
+
edges: Edge[];
|
|
487
|
+
cost: number;
|
|
488
|
+
visited: number;
|
|
489
|
+
}
|
|
490
|
+
/** A pathfinding algorithm. Return undefined when the goal is unreachable. */
|
|
491
|
+
type PathfindingAlgorithm = (ctx: SearchContext) => SearchResult | undefined;
|
|
492
|
+
type AlgorithmRef = BuiltinAlgorithm | (string & {}) | PathfindingAlgorithm;
|
|
493
|
+
interface PathOptions {
|
|
494
|
+
/** Route input variables. Used for condition evaluation and stored on the path. */
|
|
495
|
+
variables?: Readonly<Record<string, JsonValue>>;
|
|
496
|
+
/** Runtime values. Override route inputs. */
|
|
497
|
+
runtime?: Readonly<Record<string, JsonValue>>;
|
|
498
|
+
/** Application state looked up by conditions when a name is not a variable. */
|
|
499
|
+
state?: Readonly<Record<string, unknown>>;
|
|
500
|
+
/** Heuristic for A*. Must be admissible for optimal routes. Default 0. */
|
|
501
|
+
heuristic?: Heuristic;
|
|
502
|
+
/** Override the cost of an edge, for example to penalise risky transitions. Must return a finite number >= 0. */
|
|
503
|
+
costFn?: (edge: Edge) => number;
|
|
504
|
+
/** Extra veto on edges. Return false to exclude an edge. */
|
|
505
|
+
edgeFilter?: (edge: Edge) => boolean;
|
|
506
|
+
/** Extra word operators for conditions. */
|
|
507
|
+
conditionOperators?: Readonly<Record<string, ConditionOperator>>;
|
|
508
|
+
/** Throw when a condition refers to an unknown value. Default false. */
|
|
509
|
+
strictConditions?: boolean;
|
|
510
|
+
/** Reject route variables that are not declared in the graph. */
|
|
511
|
+
strictVariables?: boolean;
|
|
512
|
+
}
|
|
513
|
+
interface Path {
|
|
514
|
+
readonly from: string;
|
|
515
|
+
readonly to: string;
|
|
516
|
+
/** Screen ids in order, including both ends. */
|
|
517
|
+
readonly screens: string[];
|
|
518
|
+
readonly edges: Edge[];
|
|
519
|
+
readonly cost: number;
|
|
520
|
+
readonly algorithm: string;
|
|
521
|
+
/** Number of nodes expanded by the search. */
|
|
522
|
+
readonly visited: number;
|
|
523
|
+
/** Route variables supplied to calculatePath. */
|
|
524
|
+
readonly variables: Record<string, JsonValue>;
|
|
525
|
+
/** Owning tree (not enumerable, so JSON.stringify(path) stays clean). */
|
|
526
|
+
readonly tree: NavigationTree;
|
|
527
|
+
}
|
|
528
|
+
type PathResult = {
|
|
529
|
+
ok: true;
|
|
530
|
+
path: Path;
|
|
531
|
+
} | {
|
|
532
|
+
ok: false;
|
|
533
|
+
error: NoPathError;
|
|
534
|
+
};
|
|
535
|
+
/** Register a custom algorithm so it can be selected by name. */
|
|
536
|
+
declare function registerAlgorithm(name: string, fn: PathfindingAlgorithm): void;
|
|
537
|
+
/**
|
|
538
|
+
* Compute a route between two screens without throwing for "no route".
|
|
539
|
+
* Unknown screens and invalid options still throw.
|
|
540
|
+
*/
|
|
541
|
+
declare function tryCalculatePath(tree: NavigationTree, start: string | Screen, end: string | Screen, algorithm?: AlgorithmRef, options?: PathOptions): PathResult;
|
|
542
|
+
/** Compute a route. Throws NoPathError when the destination is unreachable. */
|
|
543
|
+
declare function calculatePath(tree: NavigationTree, start: string | Screen, end: string | Screen, algorithm?: AlgorithmRef, options?: PathOptions): Path;
|
|
544
|
+
/** Ids of every screen reachable from `start` under the given conditions (BFS). */
|
|
545
|
+
declare function findReachable(tree: NavigationTree, start: string | Screen, options?: PathOptions): string[];
|
|
546
|
+
|
|
547
|
+
type MaybePromise<T> = T | PromiseLike<T>;
|
|
548
|
+
type HookResult<Out> = Out | void | undefined;
|
|
549
|
+
type Hook<Ctx, Out> = (ctx: Ctx) => MaybePromise<HookResult<Out>>;
|
|
550
|
+
interface BaseContext<V extends JsonObject> {
|
|
551
|
+
/** Extension name. */
|
|
552
|
+
readonly name: string;
|
|
553
|
+
/** Extension local configuration merged with per build overrides. */
|
|
554
|
+
readonly variables: Readonly<V>;
|
|
555
|
+
/** Resolved route variables (graph defaults, route inputs, runtime). */
|
|
556
|
+
readonly routeVariables: Readonly<Record<string, JsonValue>>;
|
|
557
|
+
readonly tree: NavigationTree;
|
|
558
|
+
readonly path: Path;
|
|
559
|
+
/** Outputs of extensions listed in `dependsOn`, for this same node. */
|
|
560
|
+
readonly outputs: Readonly<Record<string, JsonValue>>;
|
|
561
|
+
}
|
|
562
|
+
interface ActionContext<V extends JsonObject = JsonObject> extends BaseContext<V> {
|
|
563
|
+
readonly action: Readonly<InstructionAction>;
|
|
564
|
+
readonly actionIndex: number;
|
|
565
|
+
readonly step: Readonly<InstructionStep>;
|
|
566
|
+
readonly edge: Edge;
|
|
567
|
+
readonly from: Screen;
|
|
568
|
+
readonly to: Screen;
|
|
569
|
+
}
|
|
570
|
+
interface StepContext<V extends JsonObject = JsonObject> extends BaseContext<V> {
|
|
571
|
+
/** The step with action level extension output already attached. */
|
|
572
|
+
readonly step: Readonly<InstructionStep>;
|
|
573
|
+
readonly edge: Edge;
|
|
574
|
+
readonly from: Screen;
|
|
575
|
+
readonly to: Screen;
|
|
576
|
+
}
|
|
577
|
+
interface RouteContext<V extends JsonObject = JsonObject> extends BaseContext<V> {
|
|
578
|
+
/** The full instruction tree with action and step output already attached. */
|
|
579
|
+
readonly instructions: Readonly<Instructions>;
|
|
580
|
+
readonly from: Screen;
|
|
581
|
+
readonly to: Screen;
|
|
582
|
+
}
|
|
583
|
+
interface ExtensionDefinition<N extends string = string, Out extends JsonValue = JsonValue, V extends JsonObject = JsonObject> {
|
|
584
|
+
name: N;
|
|
585
|
+
/** Local configuration. Never mutates graph or route variables. */
|
|
586
|
+
variables?: V;
|
|
587
|
+
/** Names of extensions whose output for the same node this one reads via `ctx.outputs`. */
|
|
588
|
+
dependsOn?: readonly string[];
|
|
589
|
+
/** Shorthand for `action`. Called once per action. */
|
|
590
|
+
run?: Hook<ActionContext<V>, Out>;
|
|
591
|
+
action?: Hook<ActionContext<V>, Out>;
|
|
592
|
+
/** Called once per screen to screen transition, after its actions. */
|
|
593
|
+
step?: Hook<StepContext<V>, Out>;
|
|
594
|
+
/** Called once after every step has been built. */
|
|
595
|
+
route?: Hook<RouteContext<V>, Out>;
|
|
596
|
+
/** Optional output check. Return true, or a string describing the problem. */
|
|
597
|
+
validate?: (output: Out) => boolean | string;
|
|
598
|
+
}
|
|
599
|
+
/** Definition without a name, for the inline object form. */
|
|
600
|
+
type InlineExtension<Out extends JsonValue = JsonValue, V extends JsonObject = JsonObject> = Omit<ExtensionDefinition<string, Out, V>, "name">;
|
|
601
|
+
declare const OUTPUT: unique symbol;
|
|
602
|
+
interface Extension<N extends string = string, Out extends JsonValue = JsonValue, V extends JsonObject = JsonObject> {
|
|
603
|
+
readonly name: N;
|
|
604
|
+
readonly variables: Readonly<V>;
|
|
605
|
+
readonly dependsOn: readonly string[];
|
|
606
|
+
readonly hooks: {
|
|
607
|
+
readonly action?: Hook<ActionContext<V>, Out>;
|
|
608
|
+
readonly step?: Hook<StepContext<V>, Out>;
|
|
609
|
+
readonly route?: Hook<RouteContext<V>, Out>;
|
|
610
|
+
};
|
|
611
|
+
readonly validate?: (output: Out) => boolean | string;
|
|
612
|
+
/** Type only marker used by `getExtensionOutput`. */
|
|
613
|
+
readonly [OUTPUT]?: Out;
|
|
614
|
+
}
|
|
615
|
+
type AnyExtension = Extension<any, any, any>;
|
|
616
|
+
type OutputOf<E> = E extends Extension<any, infer O, any> ? O : never;
|
|
617
|
+
type NameOf<E> = E extends Extension<infer N, any, any> ? N : never;
|
|
618
|
+
/** Hooks that return nothing infer `never`; treat that as "any JSON value". */
|
|
619
|
+
type OutputOrJson<Out> = [Out] extends [never] ? JsonValue : Out;
|
|
620
|
+
type ExtensionsInput = readonly AnyExtension[] | Readonly<Record<string, InlineExtension<JsonValue, JsonObject>>>;
|
|
621
|
+
/** Validate and create a reusable extension definition. */
|
|
622
|
+
declare function defineExtension<N extends string, Out extends JsonValue = JsonValue, V extends JsonObject = JsonObject>(definition: ExtensionDefinition<N, Out, V>): Extension<N, OutputOrJson<Out>, V>;
|
|
623
|
+
/** Normalise the array or inline-object forms into an ordered, dependency sorted list. */
|
|
624
|
+
declare function normalizeExtensions(input: ExtensionsInput | undefined): AnyExtension[];
|
|
625
|
+
/** Typed read of an extension's output from any node (action, step or the route). */
|
|
626
|
+
declare function getExtensionOutput<E extends AnyExtension>(node: {
|
|
627
|
+
readonly extensions: Readonly<Record<string, JsonValue>>;
|
|
628
|
+
}, extension: E): OutputOf<E> | undefined;
|
|
629
|
+
|
|
630
|
+
interface InstructionAction<T extends string = string, D extends JsonObject = JsonObject> {
|
|
631
|
+
type: T;
|
|
632
|
+
/** Resolved payload, with all `$VAR$` references substituted. */
|
|
633
|
+
data: D;
|
|
634
|
+
/** Extension output, keyed by extension name. */
|
|
635
|
+
extensions: Record<string, JsonValue>;
|
|
636
|
+
/** Original payload before substitution. Only present with `includeUnresolved`. */
|
|
637
|
+
unresolved?: JsonObject;
|
|
638
|
+
}
|
|
639
|
+
interface InstructionStep {
|
|
640
|
+
n: number;
|
|
641
|
+
from: string;
|
|
642
|
+
to: string;
|
|
643
|
+
/** Id of the graph edge this step traverses. */
|
|
644
|
+
edge: string;
|
|
645
|
+
cost: number;
|
|
646
|
+
actions: InstructionAction[];
|
|
647
|
+
extensions: Record<string, JsonValue>;
|
|
648
|
+
}
|
|
649
|
+
interface Instructions {
|
|
650
|
+
from: string;
|
|
651
|
+
to: string;
|
|
652
|
+
path: string[];
|
|
653
|
+
steps: InstructionStep[];
|
|
654
|
+
cost: number;
|
|
655
|
+
/** Route level extension output. */
|
|
656
|
+
extensions: Record<string, JsonValue>;
|
|
657
|
+
meta: {
|
|
658
|
+
app?: string;
|
|
659
|
+
algorithm: string;
|
|
660
|
+
generator: string;
|
|
661
|
+
};
|
|
662
|
+
/** Present only when `onError: "collect"` swallowed extension failures. */
|
|
663
|
+
warnings?: Diagnostic[];
|
|
664
|
+
}
|
|
665
|
+
interface BuildOptions {
|
|
666
|
+
/** Route inputs. Override graph defaults and anything stored on the path. */
|
|
667
|
+
variables?: Readonly<Record<string, JsonValue>>;
|
|
668
|
+
/** Runtime values. Override route inputs. */
|
|
669
|
+
runtime?: Readonly<Record<string, JsonValue>>;
|
|
670
|
+
/** Extensions as an array of defineExtension() results, or an inline map keyed by name. */
|
|
671
|
+
extensions?: ExtensionsInput;
|
|
672
|
+
/** Per extension configuration overrides, keyed by extension name. */
|
|
673
|
+
extensionVariables?: Readonly<Record<string, JsonObject>>;
|
|
674
|
+
/** "throw" (default) fails on the first extension error. "collect" records warnings and continues. */
|
|
675
|
+
onError?: "throw" | "collect";
|
|
676
|
+
/** Keep the original unresolved payload on each action as `unresolved`. */
|
|
677
|
+
includeUnresolved?: boolean;
|
|
678
|
+
/** Reject route variables that are not declared in the graph. */
|
|
679
|
+
strictVariables?: boolean;
|
|
680
|
+
}
|
|
681
|
+
/**
|
|
682
|
+
* Build the instruction tree. Always returns a promise and awaits async
|
|
683
|
+
* extension hooks. Use `buildInstructionsSync` when every hook is synchronous.
|
|
684
|
+
*/
|
|
685
|
+
declare function buildInstructions(path: Path, options?: BuildOptions): Promise<Instructions>;
|
|
686
|
+
/**
|
|
687
|
+
* Synchronous variant. Throws AsyncExtensionError if any hook returns a promise.
|
|
688
|
+
*/
|
|
689
|
+
declare function buildInstructionsSync(path: Path, options?: BuildOptions): Instructions;
|
|
690
|
+
/**
|
|
691
|
+
* Narrow an action to a known type with a typed payload. Works with the
|
|
692
|
+
* built in actions out of the box; pass your own map as the first type
|
|
693
|
+
* argument for custom actions: `isAction<MyActions, "SCAN_QR">(a, "SCAN_QR")`.
|
|
694
|
+
*/
|
|
695
|
+
declare function isAction<M extends object = DefaultActionMap, K extends keyof M & string = keyof M & string>(action: InstructionAction, type: K): action is InstructionAction<K, M[K] & JsonObject>;
|
|
696
|
+
|
|
697
|
+
/**
|
|
698
|
+
* Optional, opt-in execution layer. AppNav core never runs actions. Register
|
|
699
|
+
* handlers explicitly by action type and pass generated instructions in.
|
|
700
|
+
*/
|
|
701
|
+
interface HandlerContext<Ctx = unknown> {
|
|
702
|
+
readonly action: Readonly<InstructionAction>;
|
|
703
|
+
readonly step: Readonly<InstructionStep>;
|
|
704
|
+
readonly instructions: Readonly<Instructions>;
|
|
705
|
+
/** Caller supplied runtime context (navigation ref, driver, test harness, ...). */
|
|
706
|
+
readonly context: Ctx;
|
|
707
|
+
readonly attempt: number;
|
|
708
|
+
readonly signal?: AbortSignal;
|
|
709
|
+
}
|
|
710
|
+
type ActionHandler<Ctx = unknown, R = unknown> = (ctx: HandlerContext<Ctx>) => R | PromiseLike<R>;
|
|
711
|
+
interface HandlerOptions {
|
|
712
|
+
/** Async execution only. Fails the attempt after this many milliseconds. */
|
|
713
|
+
timeoutMs?: number;
|
|
714
|
+
/** Extra attempts after the first failure. Default 0. */
|
|
715
|
+
retries?: number;
|
|
716
|
+
/** Async execution only. Delay between attempts. Default 0. */
|
|
717
|
+
retryDelayMs?: number;
|
|
718
|
+
}
|
|
719
|
+
interface ExecuteOptions<Ctx = unknown> {
|
|
720
|
+
context?: Ctx;
|
|
721
|
+
/** Keep running after a failed action. Default false. */
|
|
722
|
+
continueOnError?: boolean;
|
|
723
|
+
/** Skip actions without a handler instead of failing. Default false. */
|
|
724
|
+
skipUnhandled?: boolean;
|
|
725
|
+
signal?: AbortSignal;
|
|
726
|
+
onAction?: (result: ActionResult, step: InstructionStep) => void;
|
|
727
|
+
}
|
|
728
|
+
interface ActionResult {
|
|
729
|
+
stepN: number;
|
|
730
|
+
actionIndex: number;
|
|
731
|
+
type: string;
|
|
732
|
+
status: "ok" | "error" | "skipped";
|
|
733
|
+
value?: unknown;
|
|
734
|
+
error?: unknown;
|
|
735
|
+
attempts: number;
|
|
736
|
+
}
|
|
737
|
+
interface ExecutionResult {
|
|
738
|
+
ok: boolean;
|
|
739
|
+
results: ActionResult[];
|
|
740
|
+
}
|
|
741
|
+
declare class Runtime<Ctx = unknown> {
|
|
742
|
+
private readonly handlers;
|
|
743
|
+
register<T extends string = string>(type: T, handler: ActionHandler<Ctx>, options?: HandlerOptions): this;
|
|
744
|
+
unregister(type: string): boolean;
|
|
745
|
+
has(type: string): boolean;
|
|
746
|
+
/** Run instructions. Awaits async handlers and honours timeouts, retries and abort signals. */
|
|
747
|
+
execute(instructions: Instructions, options?: ExecuteOptions<Ctx>): Promise<ExecutionResult>;
|
|
748
|
+
/** Run instructions with synchronous handlers only. Throws AsyncExtensionError if a handler returns a promise. */
|
|
749
|
+
executeSync(instructions: Instructions, options?: ExecuteOptions<Ctx>): ExecutionResult;
|
|
750
|
+
private job;
|
|
751
|
+
}
|
|
752
|
+
declare function createRuntime<Ctx = unknown>(handlers?: Record<string, ActionHandler<Ctx> | {
|
|
753
|
+
handler: ActionHandler<Ctx>;
|
|
754
|
+
options?: HandlerOptions;
|
|
755
|
+
}>): Runtime<Ctx>;
|
|
756
|
+
/** Shared runtime used by `registerActionHandler` for apps that prefer a global registry. */
|
|
757
|
+
declare const defaultRuntime: Runtime<unknown>;
|
|
758
|
+
declare function registerActionHandler<T extends string = string>(type: T, handler: ActionHandler<unknown>, options?: HandlerOptions): void;
|
|
759
|
+
|
|
760
|
+
declare const AppNavNamespace_ASTAR: typeof ASTAR;
|
|
761
|
+
declare const AppNavNamespace_BFS: typeof BFS;
|
|
762
|
+
declare const AppNavNamespace_DIJKSTRA: typeof DIJKSTRA;
|
|
763
|
+
declare const AppNavNamespace_assertValid: typeof assertValid;
|
|
764
|
+
declare const AppNavNamespace_buildInstructions: typeof buildInstructions;
|
|
765
|
+
declare const AppNavNamespace_buildInstructionsSync: typeof buildInstructionsSync;
|
|
766
|
+
declare const AppNavNamespace_calculatePath: typeof calculatePath;
|
|
767
|
+
declare const AppNavNamespace_createRuntime: typeof createRuntime;
|
|
768
|
+
declare const AppNavNamespace_defineExtension: typeof defineExtension;
|
|
769
|
+
declare const AppNavNamespace_evaluateCondition: typeof evaluateCondition;
|
|
770
|
+
declare const AppNavNamespace_findReachable: typeof findReachable;
|
|
771
|
+
declare const AppNavNamespace_getExtensionOutput: typeof getExtensionOutput;
|
|
772
|
+
declare const AppNavNamespace_indexGraph: typeof indexGraph;
|
|
773
|
+
declare const AppNavNamespace_indexTree: typeof indexTree;
|
|
774
|
+
declare const AppNavNamespace_indexTreeFromText: typeof indexTreeFromText;
|
|
775
|
+
declare const AppNavNamespace_isAction: typeof isAction;
|
|
776
|
+
declare const AppNavNamespace_loadSchema: typeof loadSchema;
|
|
777
|
+
declare const AppNavNamespace_parseCondition: typeof parseCondition;
|
|
778
|
+
declare const AppNavNamespace_parseGraph: typeof parseGraph;
|
|
779
|
+
declare const AppNavNamespace_registerActionHandler: typeof registerActionHandler;
|
|
780
|
+
declare const AppNavNamespace_registerAlgorithm: typeof registerAlgorithm;
|
|
781
|
+
declare const AppNavNamespace_registerSchema: typeof registerSchema;
|
|
782
|
+
declare const AppNavNamespace_resolveSchema: typeof resolveSchema;
|
|
783
|
+
declare const AppNavNamespace_tryCalculatePath: typeof tryCalculatePath;
|
|
784
|
+
declare const AppNavNamespace_validateGraph: typeof validateGraph;
|
|
785
|
+
declare namespace AppNavNamespace {
|
|
786
|
+
export { AppNavNamespace_ASTAR as ASTAR, AppNavNamespace_BFS as BFS, AppNavNamespace_DIJKSTRA as DIJKSTRA, AppNavNamespace_assertValid as assertValid, AppNavNamespace_buildInstructions as buildInstructions, AppNavNamespace_buildInstructionsSync as buildInstructionsSync, AppNavNamespace_calculatePath as calculatePath, AppNavNamespace_createRuntime as createRuntime, AppNavNamespace_defineExtension as defineExtension, AppNavNamespace_evaluateCondition as evaluateCondition, AppNavNamespace_findReachable as findReachable, AppNavNamespace_getExtensionOutput as getExtensionOutput, AppNavNamespace_indexGraph as indexGraph, AppNavNamespace_indexTree as indexTree, AppNavNamespace_indexTreeFromText as indexTreeFromText, AppNavNamespace_isAction as isAction, AppNavNamespace_loadSchema as loadSchema, AppNavNamespace_parseCondition as parseCondition, AppNavNamespace_parseGraph as parseGraph, AppNavNamespace_registerActionHandler as registerActionHandler, AppNavNamespace_registerAlgorithm as registerAlgorithm, AppNavNamespace_registerSchema as registerSchema, AppNavNamespace_resolveSchema as resolveSchema, AppNavNamespace_tryCalculatePath as tryCalculatePath, AppNavNamespace_validateGraph as validateGraph };
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
/** Namespace object for `import { AppNav } from "routegraph"`. */
|
|
790
|
+
declare const AppNav: typeof AppNavNamespace;
|
|
791
|
+
declare const VERSION = "0.1.0";
|
|
792
|
+
|
|
793
|
+
export { ASTAR, type ActionContext, type ActionDeclaration, type ActionDefinition, type ActionHandler, ActionHandlerError, type ActionMap, type ActionResult, type AlgorithmRef, type AnyExtension, AppNav, AppNavError, AsyncExtensionError, BFS, BUILTIN_OPERATORS, type BuildOptions, type BuiltinAlgorithm, type Condition, type ConditionContext, ConditionError, type ConditionNode, type ConditionOperator, type ConditionOptions, DEFAULT_SCHEMA_DEFINITION, DIJKSTRA, type DefaultActionMap, type Diagnostic, type DiagnosticSeverity, type Edge, type ErrorLocation, type ExecuteOptions, type ExecutionResult, type Extension, type ExtensionDefinition, ExtensionError, type ExtensionsInput, FileLoadError, type Graph, type HandlerContext, type HandlerOptions, type Heuristic, type Hook, type IndexFileOptions, type IndexOptions, type InlineExtension, type InstructionAction, type InstructionStep, type Instructions, type JsonObject, type JsonPrimitive, type JsonValue, type LoadSchemaOptions, type NameOf, type NavTree, NavigationTree, NoPathError, type OutputOf, ParseError, type ParseOptions, type Path, type PathOptions, type PathResult, type PathfindingAlgorithm, type PropertySchema, type PropertyType, type RawEdge, type RawScreen, type ReadFile, type ResolvedSchema, type RouteContext, Runtime, SUPPORTED_GRAPH_VERSIONS, type SchemaDefinition, SchemaError, type ScopeInputs, type Screen, type SearchContext, type SearchResult, type StepContext, UnknownScreenError, UnsupportedVersionError, VARIABLE_TYPES, VERSION, type ValidateOptions, ValidationError, type ValidationResult, type VariableDeclaration, VariableError, type VariableScope, type VariableType, assertValid, buildInstructions, buildInstructionsSync, buildScope, calculatePath, collectReferences, conditionRefs, createRuntime, defaultReadFile, defaultRuntime, defineExtension, evaluateCondition, findReachable, getDefaultSchema, getExtensionOutput, indexGraph, indexTree, indexTreeFromText, isAction, loadSchema, matchesType, normalizeExtensions, parseCondition, parseGraph, parseTemplate, registerActionHandler, registerAlgorithm, registerSchema, resolveSchema, resolveValue, toDiagnostic, tryCalculatePath, typeOfValue, unregisterSchema, validateAgainst, validateGraph };
|