jssm 5.162.11 → 5.162.13
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/README.md +8 -7
- package/custom-elements.json +52 -10
- package/dist/cdn/instance.js +1 -1
- package/dist/cdn/viz.js +17 -1
- package/dist/cli/fsl-export-system-prompt.cjs +1 -1
- package/dist/cli/fsl-render.cjs +1 -1
- package/dist/cli/fsl.cjs +1 -1
- package/dist/cli/lib.cjs +1 -1
- package/dist/cli/lib.mjs +1 -1
- package/dist/deno/README.md +8 -7
- package/dist/deno/fsl_markdown_fence.d.ts +20 -3
- package/dist/deno/jssm.d.ts +14 -1
- package/dist/deno/jssm.js +1 -1
- package/dist/deno/jssm_compiler.d.ts +21 -4
- package/dist/deno/jssm_types.d.ts +27 -1
- package/dist/deno/jssm_viz.d.ts +66 -9
- package/dist/fence/fence.js +83 -32
- package/dist/jssm.es5.cjs +1 -1
- package/dist/jssm.es5.iife.js +1 -1
- package/dist/jssm.es6.mjs +1 -1
- package/dist/jssm_viz.cjs +1 -1
- package/dist/jssm_viz.iife.cjs +1 -1
- package/dist/jssm_viz.mjs +1 -1
- package/dist/wc/instance.js +69 -23
- package/dist/wc/viz.js +54 -9
- package/dist/wc/widgets.define.js +4 -2
- package/dist/wc/widgets.js +196 -43
- package/jssm.es5.d.cts +80 -8
- package/jssm.es6.d.ts +80 -8
- package/jssm.fence.d.ts +13 -1
- package/jssm_viz.es5.d.cts +79 -10
- package/jssm_viz.es6.d.ts +79 -10
- package/package.json +2 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { JssmTransition, JssmCompileSe, JssmCompileSeStart, JssmParseTree, JssmGenericConfig, JssmGroupRegistry, FslSourceLocation } from './jssm_types.js';
|
|
1
|
+
import { JssmTransition, JssmCompileSe, JssmCompileSeStart, JssmParseTree, JssmParseOptions, JssmGenericConfig, JssmGroupRegistry, FslSourceLocation } from './jssm_types.js';
|
|
2
2
|
/*********
|
|
3
3
|
*
|
|
4
4
|
* Returns the source span of the `n`-th parse-tree node (1-based) matching
|
|
@@ -123,14 +123,31 @@ declare function makeTransition<StateType, mDT>(this_se: JssmCompileSe<StateType
|
|
|
123
123
|
* `wrap_parse` itself is an internal convenience method for alting out an
|
|
124
124
|
* object as the options call. Not generally meant for external use.
|
|
125
125
|
*
|
|
126
|
+
* @typeParam StateType The type of state names in the resulting tree; the
|
|
127
|
+
* grammar itself always produces `string`s, so only
|
|
128
|
+
* override this when threading a caller's own state
|
|
129
|
+
* naming through to {@link compile}.
|
|
130
|
+
* @typeParam mDT The type of the machine data member; usually omitted.
|
|
131
|
+
*
|
|
126
132
|
* @param input The FSL code to be evaluated
|
|
127
133
|
*
|
|
128
|
-
* @param options Things to control about the
|
|
134
|
+
* @param options Things to control about the parse. Pass
|
|
129
135
|
* `{ locations: true }` to enable opt-in source location
|
|
130
|
-
* tracking on every AST node.
|
|
136
|
+
* tracking on every AST node. When omitted, an empty options
|
|
137
|
+
* object is passed through to the parser.
|
|
138
|
+
*
|
|
139
|
+
* @returns The machine's intermediate representation: a flat
|
|
140
|
+
* {@link JssmParseTree} with one node per top-level FSL statement.
|
|
141
|
+
*
|
|
142
|
+
* @throws {SyntaxError} The generated PEG.js parser's `SyntaxError` when
|
|
143
|
+
* `input` is not valid FSL.
|
|
144
|
+
*
|
|
145
|
+
* @see {@link compile}
|
|
146
|
+
* @see {@link make}
|
|
147
|
+
* @see {@link JssmParseOptions}
|
|
131
148
|
*
|
|
132
149
|
*/
|
|
133
|
-
declare function wrap_parse(input: string, options?:
|
|
150
|
+
declare function wrap_parse<StateType = string, mDT = unknown>(input: string, options?: JssmParseOptions): JssmParseTree<StateType, mDT>;
|
|
134
151
|
/*********
|
|
135
152
|
*
|
|
136
153
|
* Builds the ordered {@link JssmGroupRegistry} from every `named_list` node
|
|
@@ -407,6 +407,32 @@ type FslSourceLocation = {
|
|
|
407
407
|
start: FslSourcePoint;
|
|
408
408
|
end: FslSourcePoint;
|
|
409
409
|
};
|
|
410
|
+
/**
|
|
411
|
+
* Options accepted by the FSL parser and its {@link wrap_parse} wrapper
|
|
412
|
+
* (exported from the package as `parse`). Exists so the two-argument parse
|
|
413
|
+
* call is typed against what the parser actually reads, instead of a bare
|
|
414
|
+
* `object`.
|
|
415
|
+
*
|
|
416
|
+
* - `locations` — when `true`, the grammar attaches a `loc` field of type
|
|
417
|
+
* {@link FslSourceLocation} (plus curated `*_loc` token sub-spans) to every
|
|
418
|
+
* AST node. When absent or `false`, the tree is byte-for-byte identical to
|
|
419
|
+
* the historical location-free output.
|
|
420
|
+
*
|
|
421
|
+
* - `startRule` — honored by the generated PEG.js boilerplate, which throws
|
|
422
|
+
* on any rule name it doesn't expose. This grammar exposes only its
|
|
423
|
+
* default rule, `Document`, so the field is only useful for explicitness.
|
|
424
|
+
*
|
|
425
|
+
* ```typescript
|
|
426
|
+
* const [t] = parse('a -> b;', { locations: true });
|
|
427
|
+
* // t.loc === { start: { offset: 0, line: 1, column: 1 },
|
|
428
|
+
* // end: { offset: 7, line: 1, column: 8 } }
|
|
429
|
+
* ```
|
|
430
|
+
* @see FslSourceLocation
|
|
431
|
+
*/
|
|
432
|
+
type JssmParseOptions = {
|
|
433
|
+
locations?: boolean;
|
|
434
|
+
startRule?: 'Document';
|
|
435
|
+
};
|
|
410
436
|
/**
|
|
411
437
|
* A single key/value pair from an FSL `state X: { ... };` block, in the
|
|
412
438
|
* raw form produced by the parser before being condensed into a
|
|
@@ -1345,4 +1371,4 @@ type JssmEventHandler<mDT, Ev extends JssmEventName> = (detail: JssmEventDetailM
|
|
|
1345
1371
|
* removes the subscription. Calling it more than once is a no-op.
|
|
1346
1372
|
*/
|
|
1347
1373
|
type JssmUnsubscribe = () => void;
|
|
1348
|
-
export { JssmColor, JssmShape, JssmTransition, JssmTransitions, JssmTransitionList, JssmTransitionRule, JssmArrow, JssmArrowKind, JssmArrowDirection, JssmGenericConfig, JssmEditorConfig, JssmStochasticMode, JssmStochasticOptions, JssmStochasticRun, JssmStochasticSummary, JssmGenericState, JssmGenericMachine, JssmParseTree, JssmCompileSe, JssmCompileSeStart, JssmCompileRule, JssmPermitted, JssmPermittedOpt, JssmResult, JssmStateDeclaration, JssmStateDeclarationRule, JssmStateConfig, JssmStateStyleKey, JssmStateStyleKeyList, JssmGraphDefaultEdgeColor, JssmTransitionStyleKey, JssmTransitionConfig, JssmGraphAliasKey, JssmGraphStyleKey, JssmGraphConfig, JssmBaseTheme, JssmTheme, JssmLayout, JssmHistory, JssmSerialization, JssmPropertyDefinition, JssmAllowsOverride, JssmAllowIslands, JssmDefaultSize, JssmParsedSemver, JssmGroupRef, JssmGroupMemberRef, JssmGroupRegistry, JssmHookDeclaration, JssmBoundaryHooks, JssmGroupHooks, JssmStateHooks, JssmParseFunctionType, JssmMachineInternalState, JssmErrorExtendedInfo, FslDirections, FslDirection, FslThemes, FslTheme, FslSourcePoint, FslSourceLocation, HookDescription, HookHandler, HookContext, HookResult, HookComplexResult, EverythingHookContext, EverythingHookHandler, PostEverythingHookHandler, HookPhase, HookTargetScope, HookTarget, HookBoundaryKind, HookRegistryEntry, HookQuery, JssmEventName, JssmEventDetailMap, JssmEventFilterMap, JssmEventFilter, JssmEventHandler, JssmUnsubscribe, JssmTransitionEventDetail, JssmRejectionEventDetail, JssmActionEventDetail, JssmEntryEventDetail, JssmExitEventDetail, JssmTerminalEventDetail, JssmCompleteEventDetail, JssmErrorEventDetail, JssmDataChangeEventDetail, JssmOverrideEventDetail, JssmTimeoutEventDetail, JssmHookLifecycleEventDetail, JssmRng };
|
|
1374
|
+
export { JssmColor, JssmShape, JssmTransition, JssmTransitions, JssmTransitionList, JssmTransitionRule, JssmArrow, JssmArrowKind, JssmArrowDirection, JssmGenericConfig, JssmEditorConfig, JssmStochasticMode, JssmStochasticOptions, JssmStochasticRun, JssmStochasticSummary, JssmGenericState, JssmGenericMachine, JssmParseTree, JssmParseOptions, JssmCompileSe, JssmCompileSeStart, JssmCompileRule, JssmPermitted, JssmPermittedOpt, JssmResult, JssmStateDeclaration, JssmStateDeclarationRule, JssmStateConfig, JssmStateStyleKey, JssmStateStyleKeyList, JssmGraphDefaultEdgeColor, JssmTransitionStyleKey, JssmTransitionConfig, JssmGraphAliasKey, JssmGraphStyleKey, JssmGraphConfig, JssmBaseTheme, JssmTheme, JssmLayout, JssmHistory, JssmSerialization, JssmPropertyDefinition, JssmAllowsOverride, JssmAllowIslands, JssmDefaultSize, JssmParsedSemver, JssmGroupRef, JssmGroupMemberRef, JssmGroupRegistry, JssmHookDeclaration, JssmBoundaryHooks, JssmGroupHooks, JssmStateHooks, JssmParseFunctionType, JssmMachineInternalState, JssmErrorExtendedInfo, FslDirections, FslDirection, FslThemes, FslTheme, FslSourcePoint, FslSourceLocation, HookDescription, HookHandler, HookContext, HookResult, HookComplexResult, EverythingHookContext, EverythingHookHandler, PostEverythingHookHandler, HookPhase, HookTargetScope, HookTarget, HookBoundaryKind, HookRegistryEntry, HookQuery, JssmEventName, JssmEventDetailMap, JssmEventFilterMap, JssmEventFilter, JssmEventHandler, JssmUnsubscribe, JssmTransitionEventDetail, JssmRejectionEventDetail, JssmActionEventDetail, JssmEntryEventDetail, JssmExitEventDetail, JssmTerminalEventDetail, JssmCompleteEventDetail, JssmErrorEventDetail, JssmDataChangeEventDetail, JssmOverrideEventDetail, JssmTimeoutEventDetail, JssmHookLifecycleEventDetail, JssmRng };
|
package/dist/deno/jssm_viz.d.ts
CHANGED
|
@@ -16,11 +16,48 @@ import type { JssmGroupMemberRef, JssmTransitionConfig, JssmGraphConfig } from '
|
|
|
16
16
|
*/
|
|
17
17
|
type RenderGroups = 'cluster' | 'chips' | 'off';
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
19
|
+
* The Graphviz engine surface jssm/viz actually consumes: one ready-to-use
|
|
20
|
+
* object with a `renderString(dot, options)` method. This is the contract
|
|
21
|
+
* for {@link configure}`({ viz })` injection — a *direct adapter*, not a
|
|
22
|
+
* factory: the caller instantiates (and, if needed, awaits) their engine
|
|
23
|
+
* themselves, then hands over the finished object. `renderString` receives
|
|
24
|
+
* the dot source and an options object whose members jssm/viz uses are
|
|
25
|
+
* `format` (always `'svg'`) and `engine` (a Graphviz layout engine name,
|
|
26
|
+
* when the caller of a render function supplied one); it may return the
|
|
27
|
+
* output string synchronously (like `@viz-js/viz`) or as a promise (like
|
|
28
|
+
* asm.js `viz.js` 2.x), and jssm/viz awaits either.
|
|
22
29
|
*
|
|
23
|
-
*
|
|
30
|
+
* ```typescript
|
|
31
|
+
* import { instance } from '@viz-js/viz';
|
|
32
|
+
* configure({ viz: await instance() }); // the default engine, injected by hand
|
|
33
|
+
* ```
|
|
34
|
+
* @see configure
|
|
35
|
+
*/
|
|
36
|
+
type VizEngine = {
|
|
37
|
+
renderString: (dot: string, options?: {
|
|
38
|
+
format?: string;
|
|
39
|
+
engine?: string;
|
|
40
|
+
}) => string | Promise<string>;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Inject runtime configuration for jssm/viz — a custom `DOMParser`
|
|
44
|
+
* constructor for the `*_svg_element` functions, a replacement Graphviz
|
|
45
|
+
* engine for every render path, or both.
|
|
46
|
+
*
|
|
47
|
+
* Each key is handled independently. Idempotent — last call wins per key;
|
|
48
|
+
* an omitted (or `undefined`) key leaves any earlier injection for that key
|
|
49
|
+
* in place, so neither injection can be un-set. No-op if called with no
|
|
50
|
+
* recognized keys.
|
|
51
|
+
*
|
|
52
|
+
* Precedence differs by key, on purpose:
|
|
53
|
+
*
|
|
54
|
+
* - `DOMParser` is a *fallback* — `globalThis.DOMParser` (browsers, jsdom
|
|
55
|
+
* test environments) still wins when present.
|
|
56
|
+
* - `viz` is an *override* — once injected it is used for every render, and
|
|
57
|
+
* the default `@viz-js/viz` import is never even attempted. This is what
|
|
58
|
+
* lets WASM-hostile environments (strict-CSP webviews such as VS Code's
|
|
59
|
+
* markdown preview) supply an asm.js Graphviz build at runtime, without
|
|
60
|
+
* bundler aliasing. See {@link VizEngine} for the exact contract.
|
|
24
61
|
*
|
|
25
62
|
* ```typescript
|
|
26
63
|
* // Node, with jsdom:
|
|
@@ -30,13 +67,27 @@ type RenderGroups = 'cluster' | 'chips' | 'off';
|
|
|
30
67
|
* configure({ DOMParser: new JSDOM().window.DOMParser });
|
|
31
68
|
* const el = await fsl_to_svg_element('a -> b;');
|
|
32
69
|
* ```
|
|
70
|
+
*
|
|
71
|
+
* ```typescript
|
|
72
|
+
* // strict-CSP webview, with an asm.js Graphviz:
|
|
73
|
+
* import { configure, fsl_to_svg_string } from 'jssm/viz';
|
|
74
|
+
*
|
|
75
|
+
* configure({ viz: my_asm_graphviz }); // anything with renderString(dot, opts)
|
|
76
|
+
* const svg = await fsl_to_svg_string('a -> b;');
|
|
77
|
+
* ```
|
|
33
78
|
* @param opts Configuration overrides.
|
|
34
79
|
* @param opts.DOMParser Constructor compatible with the WHATWG `DOMParser`
|
|
35
80
|
* interface. Used as a fallback when `globalThis.DOMParser` is undefined.
|
|
81
|
+
* @param opts.viz A ready-to-use Graphviz engine implementing
|
|
82
|
+
* {@link VizEngine} (`renderString(dot, opts)`). Overrides the default
|
|
83
|
+
* `@viz-js/viz` engine for all subsequent renders.
|
|
36
84
|
* @throws {JssmError} if `DOMParser` is provided and is not a constructor.
|
|
85
|
+
* @throws {JssmError} if `viz` is provided and lacks a callable `renderString`.
|
|
86
|
+
* @see VizEngine
|
|
37
87
|
*/
|
|
38
88
|
declare function configure(opts: {
|
|
39
89
|
DOMParser?: typeof globalThis.DOMParser;
|
|
90
|
+
viz?: VizEngine;
|
|
40
91
|
}): void;
|
|
41
92
|
/**
|
|
42
93
|
* Look up a color from the default viz palette by key, returning empty
|
|
@@ -94,9 +145,14 @@ declare function undoublequote(txt: string): string;
|
|
|
94
145
|
* slug_for('!!!'); // ''
|
|
95
146
|
* slug_for(' Foo Bar '); // 'foo-bar'
|
|
96
147
|
* ```
|
|
148
|
+
* Exported so consumers which must match rendered SVG node `<title>`s back
|
|
149
|
+
* to state names (notably `FslViz.highlightTrace`, fsl#1935) can slug with
|
|
150
|
+
* the *same* function the dot generator used, rather than a drifting copy.
|
|
151
|
+
*
|
|
97
152
|
* @param state The state name to slugify.
|
|
98
153
|
* @returns The lowercase hyphen-separated slug, or empty string if none of
|
|
99
154
|
* the characters were retainable.
|
|
155
|
+
* @see slug_states
|
|
100
156
|
* @internal
|
|
101
157
|
*/
|
|
102
158
|
declare function slug_for(state: string): string;
|
|
@@ -534,9 +590,10 @@ declare function machine_to_dot<T>(u_jssm: jssm.Machine<T>, opts?: VizRenderOpts
|
|
|
534
590
|
*/
|
|
535
591
|
declare function fsl_to_dot(fsl: string, opts?: VizRenderOpts): string;
|
|
536
592
|
/**
|
|
537
|
-
* Render a graphviz dot source string to SVG using `@viz-js/viz
|
|
538
|
-
*
|
|
539
|
-
*
|
|
593
|
+
* Render a graphviz dot source string to SVG using `@viz-js/viz`, or the
|
|
594
|
+
* engine injected via {@link configure}`({ viz })` when one is set. The
|
|
595
|
+
* default viz instance is lazy-initialized on first call and cached for
|
|
596
|
+
* the lifetime of the module; an injected engine bypasses it entirely.
|
|
540
597
|
*
|
|
541
598
|
* ```typescript
|
|
542
599
|
* const svg = await dot_to_svg('digraph G { a -> b }');
|
|
@@ -593,8 +650,8 @@ declare function machine_to_svg_element<T>(u_jssm: jssm.Machine<T>, opts?: VizRe
|
|
|
593
650
|
* @deprecated Use {@link machine_to_dot} instead.
|
|
594
651
|
*/
|
|
595
652
|
declare function dot<T>(machine: jssm.Machine<T>): string;
|
|
596
|
-
export { configure, dot, dot_to_svg, fsl_to_dot, fsl_to_svg_string, fsl_to_svg_element, machine_to_dot, machine_to_svg_string, machine_to_svg_element, state_svg_label_texts, };
|
|
597
|
-
export type { VizRenderOpts, RenderGroups };
|
|
653
|
+
export { configure, dot, dot_to_svg, fsl_to_dot, fsl_to_svg_string, fsl_to_svg_element, machine_to_dot, machine_to_svg_string, machine_to_svg_element, state_svg_label_texts, slug_for, };
|
|
654
|
+
export type { VizRenderOpts, RenderGroups, VizEngine };
|
|
598
655
|
/** @internal */
|
|
599
656
|
export declare const _test: {
|
|
600
657
|
doublequote: typeof doublequote;
|
package/dist/fence/fence.js
CHANGED
|
@@ -22444,11 +22444,28 @@ function makeTransition(this_se, from, to, isRight, _wasList, _wasIndex) {
|
|
|
22444
22444
|
* `wrap_parse` itself is an internal convenience method for alting out an
|
|
22445
22445
|
* object as the options call. Not generally meant for external use.
|
|
22446
22446
|
*
|
|
22447
|
+
* @typeParam StateType The type of state names in the resulting tree; the
|
|
22448
|
+
* grammar itself always produces `string`s, so only
|
|
22449
|
+
* override this when threading a caller's own state
|
|
22450
|
+
* naming through to {@link compile}.
|
|
22451
|
+
* @typeParam mDT The type of the machine data member; usually omitted.
|
|
22452
|
+
*
|
|
22447
22453
|
* @param input The FSL code to be evaluated
|
|
22448
22454
|
*
|
|
22449
|
-
* @param options Things to control about the
|
|
22455
|
+
* @param options Things to control about the parse. Pass
|
|
22450
22456
|
* `{ locations: true }` to enable opt-in source location
|
|
22451
|
-
* tracking on every AST node.
|
|
22457
|
+
* tracking on every AST node. When omitted, an empty options
|
|
22458
|
+
* object is passed through to the parser.
|
|
22459
|
+
*
|
|
22460
|
+
* @returns The machine's intermediate representation: a flat
|
|
22461
|
+
* {@link JssmParseTree} with one node per top-level FSL statement.
|
|
22462
|
+
*
|
|
22463
|
+
* @throws {SyntaxError} The generated PEG.js parser's `SyntaxError` when
|
|
22464
|
+
* `input` is not valid FSL.
|
|
22465
|
+
*
|
|
22466
|
+
* @see {@link compile}
|
|
22467
|
+
* @see {@link make}
|
|
22468
|
+
* @see {@link JssmParseOptions}
|
|
22452
22469
|
*
|
|
22453
22470
|
*/
|
|
22454
22471
|
function wrap_parse(input, options) {
|
|
@@ -24206,7 +24223,7 @@ function fslSemanticSpans(text) {
|
|
|
24206
24223
|
* Useful for runtime diagnostics and for embedding in serialized machine
|
|
24207
24224
|
* snapshots so that deserializers can detect version-skew.
|
|
24208
24225
|
*/
|
|
24209
|
-
const version = "5.162.
|
|
24226
|
+
const version = "5.162.13";
|
|
24210
24227
|
|
|
24211
24228
|
/**
|
|
24212
24229
|
* The FSL Markdown fence convention parser — pure, host-agnostic logic that
|
|
@@ -24252,7 +24269,7 @@ const INTERACTIVE_PARTS$1 = new Set(['editor', 'actions', 'toolbar', 'info-panel
|
|
|
24252
24269
|
/**
|
|
24253
24270
|
* Parse a dimension value like `300`, `120px`, or `100%` into a
|
|
24254
24271
|
* {@link FenceDimension}. A bare number is pixels.
|
|
24255
|
-
* @param raw The value portion of a `width=`/`height=` token.
|
|
24272
|
+
* @param raw The value portion of a `width=`/`height=`/`max-width=`/`max-height=` token.
|
|
24256
24273
|
* @returns The parsed dimension, or `null` if malformed.
|
|
24257
24274
|
* @example parse_dimension('300') // => { value: 300, unit: 'px' }
|
|
24258
24275
|
* @example parse_dimension('100%') // => { value: 100, unit: 'percent' }
|
|
@@ -24270,13 +24287,18 @@ const IDE_LAYOUT = ['title', 'image', 'actions', 'info-panel', 'toolbar', 'edito
|
|
|
24270
24287
|
/**
|
|
24271
24288
|
* Parse a fence info string into a {@link FenceDescriptor}. The first token is
|
|
24272
24289
|
* the (already-validated) language and is ignored; remaining tokens are
|
|
24273
|
-
* classified as parts, image formats, the `ide` macro, or
|
|
24274
|
-
* options
|
|
24290
|
+
* classified as parts, image formats, the `ide` macro, or the dimension
|
|
24291
|
+
* options `width`/`height` (exact size) and `max-width`/`max-height`
|
|
24292
|
+
* (upper bounds on natural size — see {@link FenceDescriptor} for the
|
|
24293
|
+
* precedence rule when both appear on one axis). All four dimension tokens
|
|
24294
|
+
* share one value syntax: a bare number (pixels), `<n>px`, or `<n>%`.
|
|
24295
|
+
* Unrecognized or conflicting tokens are dropped and recorded in
|
|
24275
24296
|
* `notes` rather than throwing, so a host can render forward-compatibly.
|
|
24276
24297
|
* @param info The full fence info string, e.g. `'fsl image code width=300'`.
|
|
24277
24298
|
* @returns The validated descriptor; `notes` lists anything ignored or overridden.
|
|
24278
24299
|
* @example parse_fence_info('fsl').parts // => ['image', 'code']
|
|
24279
24300
|
* @example parse_fence_info('fsl code image').parts // => ['code', 'image']
|
|
24301
|
+
* @example parse_fence_info('fsl image max-width=300 max-height=50%').max_width // => { value: 300, unit: 'px' }
|
|
24280
24302
|
*/
|
|
24281
24303
|
function parse_fence_info(info) {
|
|
24282
24304
|
const tokens = info.trim().split(/\s+/).filter(Boolean);
|
|
@@ -24285,9 +24307,14 @@ function parse_fence_info(info) {
|
|
|
24285
24307
|
const notes = [];
|
|
24286
24308
|
let format = 'svg';
|
|
24287
24309
|
let format_set = false;
|
|
24288
|
-
let width = null;
|
|
24289
|
-
let height = null;
|
|
24290
24310
|
let ide = false;
|
|
24311
|
+
// the four dimension tokens share one assignment path, keyed by token name
|
|
24312
|
+
const dims = {
|
|
24313
|
+
'width': null,
|
|
24314
|
+
'height': null,
|
|
24315
|
+
'max-width': null,
|
|
24316
|
+
'max-height': null,
|
|
24317
|
+
};
|
|
24291
24318
|
for (const arg of args) {
|
|
24292
24319
|
if (arg === 'ide') {
|
|
24293
24320
|
ide = true;
|
|
@@ -24313,7 +24340,7 @@ function parse_fence_info(info) {
|
|
|
24313
24340
|
}
|
|
24314
24341
|
continue;
|
|
24315
24342
|
}
|
|
24316
|
-
if (arg.startsWith('width=') || arg.startsWith('height=')) {
|
|
24343
|
+
if (arg.startsWith('width=') || arg.startsWith('height=') || arg.startsWith('max-width=') || arg.startsWith('max-height=')) {
|
|
24317
24344
|
const eq = arg.indexOf('=');
|
|
24318
24345
|
const key = arg.slice(0, eq);
|
|
24319
24346
|
const raw = arg.slice(eq + 1);
|
|
@@ -24321,11 +24348,8 @@ function parse_fence_info(info) {
|
|
|
24321
24348
|
if (dim === null) {
|
|
24322
24349
|
notes.push(`invalid ${key} value "${raw}" ignored`);
|
|
24323
24350
|
}
|
|
24324
|
-
else if (key === 'width') {
|
|
24325
|
-
width = dim;
|
|
24326
|
-
}
|
|
24327
24351
|
else {
|
|
24328
|
-
|
|
24352
|
+
dims[key] = dim;
|
|
24329
24353
|
}
|
|
24330
24354
|
continue;
|
|
24331
24355
|
}
|
|
@@ -24350,8 +24374,10 @@ function parse_fence_info(info) {
|
|
|
24350
24374
|
parts,
|
|
24351
24375
|
ide,
|
|
24352
24376
|
format,
|
|
24353
|
-
width,
|
|
24354
|
-
height,
|
|
24377
|
+
width: dims.width,
|
|
24378
|
+
height: dims.height,
|
|
24379
|
+
max_width: dims['max-width'],
|
|
24380
|
+
max_height: dims['max-height'],
|
|
24355
24381
|
interactive,
|
|
24356
24382
|
notes
|
|
24357
24383
|
};
|
|
@@ -26425,6 +26451,12 @@ class Machine {
|
|
|
26425
26451
|
* {@link Machine.transition}, so it fires no hooks, mutates no machine
|
|
26426
26452
|
* state, and touches no `data`. A state with no probabilistic exits
|
|
26427
26453
|
* (a terminal, or a forced-only `~>` state) ends the walk.
|
|
26454
|
+
*
|
|
26455
|
+
* Terminality is checked before the first transition and after every
|
|
26456
|
+
* transition. A terminal start therefore completes with length zero even
|
|
26457
|
+
* when `max_steps` is zero, and a terminal reached on the final permitted
|
|
26458
|
+
* transition is completed rather than step-capped.
|
|
26459
|
+
*
|
|
26428
26460
|
* @param start - State to begin the walk from.
|
|
26429
26461
|
* @param max_steps - Maximum transitions before the walk is step-capped.
|
|
26430
26462
|
* @param exit_memo - Per-run-set cache of {@link Machine.probable_exits_for}
|
|
@@ -26443,22 +26475,25 @@ class Machine {
|
|
|
26443
26475
|
const states = [start];
|
|
26444
26476
|
const edges = [];
|
|
26445
26477
|
let cur = start;
|
|
26446
|
-
let
|
|
26447
|
-
|
|
26448
|
-
|
|
26478
|
+
let exits = exit_memo.get(cur);
|
|
26479
|
+
if (exits === undefined) {
|
|
26480
|
+
exits = this.probable_exits_for(cur);
|
|
26481
|
+
this._assert_selectable_exit_pool(cur, exits);
|
|
26482
|
+
exit_memo.set(cur, exits);
|
|
26483
|
+
}
|
|
26484
|
+
let terminated = exits.length === 0;
|
|
26485
|
+
for (let step = 0; step < max_steps && !terminated; step++) {
|
|
26486
|
+
const selected = weighted_rand_select(exits, undefined, this._rng);
|
|
26487
|
+
edges.push(`${cur}→${selected.to}`);
|
|
26488
|
+
cur = selected.to;
|
|
26489
|
+
states.push(cur);
|
|
26490
|
+
exits = exit_memo.get(cur);
|
|
26449
26491
|
if (exits === undefined) {
|
|
26450
26492
|
exits = this.probable_exits_for(cur);
|
|
26451
26493
|
this._assert_selectable_exit_pool(cur, exits);
|
|
26452
26494
|
exit_memo.set(cur, exits);
|
|
26453
26495
|
}
|
|
26454
|
-
|
|
26455
|
-
terminated = true;
|
|
26456
|
-
break;
|
|
26457
|
-
}
|
|
26458
|
-
const selected = weighted_rand_select(exits, undefined, this._rng);
|
|
26459
|
-
edges.push(`${cur}→${selected.to}`);
|
|
26460
|
-
cur = selected.to;
|
|
26461
|
-
states.push(cur);
|
|
26496
|
+
terminated = exits.length === 0;
|
|
26462
26497
|
}
|
|
26463
26498
|
return { states, edges, length: states.length - 1, terminated };
|
|
26464
26499
|
}
|
|
@@ -26469,7 +26504,9 @@ class Machine {
|
|
|
26469
26504
|
* current state, each ending at a terminal or after `max_steps`. In
|
|
26470
26505
|
* `steady_state` mode yields exactly one walk of `max_steps` steps. This
|
|
26471
26506
|
* is the lazy engine behind {@link Machine.stochastic_summary}; the
|
|
26472
|
-
* fsl-stochastic panel drives it across animation frames.
|
|
26507
|
+
* fsl-stochastic panel drives it across animation frames. A walk already
|
|
26508
|
+
* at a terminal is reported as terminated with length zero, including when
|
|
26509
|
+
* `max_steps` is zero.
|
|
26473
26510
|
*
|
|
26474
26511
|
* Passing `seed` reseeds the machine for reproducible runs. Unlike
|
|
26475
26512
|
* {@link Machine.stochastic_summary}, the generator does NOT restore the
|
|
@@ -26508,6 +26545,10 @@ class Machine {
|
|
|
26508
26545
|
* per-run `path_lengths`, `terminal_reached`, and `capped`; `steady_state`
|
|
26509
26546
|
* mode runs one long walk and omits those fields.
|
|
26510
26547
|
*
|
|
26548
|
+
* Monte-Carlo runs count as `terminal_reached` when they start at a
|
|
26549
|
+
* terminal or reach one on the final permitted transition. Terminal
|
|
26550
|
+
* starts contribute zero to `path_lengths`, even when `max_steps` is zero.
|
|
26551
|
+
*
|
|
26511
26552
|
* Timing (`after`) decorations and data-guard conditions are not modeled
|
|
26512
26553
|
* by this sampler; it walks the probabilistic graph topology.
|
|
26513
26554
|
* @param opts - {@link JssmStochasticOptions}. `runs` defaults to the
|
|
@@ -29880,8 +29921,12 @@ const default_viz_colors = {
|
|
|
29880
29921
|
*/
|
|
29881
29922
|
let viz_instance = null;
|
|
29882
29923
|
/**
|
|
29883
|
-
* Returns
|
|
29884
|
-
*
|
|
29924
|
+
* Returns the Graphviz engine the render path should use: the engine
|
|
29925
|
+
* injected via {@link configure}`({ viz })` when one is set (checked
|
|
29926
|
+
* *before* the default import, so the `@viz-js/viz` WASM module is never
|
|
29927
|
+
* even loaded in environments that injected their own); otherwise a cached
|
|
29928
|
+
* `@viz-js/viz` instance, lazily instantiated on first call. Internal
|
|
29929
|
+
* helper for the rendering functions.
|
|
29885
29930
|
* @internal
|
|
29886
29931
|
*/
|
|
29887
29932
|
async function get_viz() {
|
|
@@ -29955,9 +30000,14 @@ function undoublequote(txt) {
|
|
|
29955
30000
|
* slug_for('!!!'); // ''
|
|
29956
30001
|
* slug_for(' Foo Bar '); // 'foo-bar'
|
|
29957
30002
|
* ```
|
|
30003
|
+
* Exported so consumers which must match rendered SVG node `<title>`s back
|
|
30004
|
+
* to state names (notably `FslViz.highlightTrace`, fsl#1935) can slug with
|
|
30005
|
+
* the *same* function the dot generator used, rather than a drifting copy.
|
|
30006
|
+
*
|
|
29958
30007
|
* @param state The state name to slugify.
|
|
29959
30008
|
* @returns The lowercase hyphen-separated slug, or empty string if none of
|
|
29960
30009
|
* the characters were retainable.
|
|
30010
|
+
* @see slug_states
|
|
29961
30011
|
* @internal
|
|
29962
30012
|
*/
|
|
29963
30013
|
function slug_for(state) {
|
|
@@ -30979,9 +31029,10 @@ function fsl_to_dot(fsl, opts = {}) {
|
|
|
30979
31029
|
return machine_to_dot(sm `${fsl}`, opts);
|
|
30980
31030
|
}
|
|
30981
31031
|
/**
|
|
30982
|
-
* Render a graphviz dot source string to SVG using `@viz-js/viz
|
|
30983
|
-
*
|
|
30984
|
-
*
|
|
31032
|
+
* Render a graphviz dot source string to SVG using `@viz-js/viz`, or the
|
|
31033
|
+
* engine injected via {@link configure}`({ viz })` when one is set. The
|
|
31034
|
+
* default viz instance is lazy-initialized on first call and cached for
|
|
31035
|
+
* the lifetime of the module; an injected engine bypasses it entirely.
|
|
30985
31036
|
*
|
|
30986
31037
|
* ```typescript
|
|
30987
31038
|
* const svg = await dot_to_svg('digraph G { a -> b }');
|