jssm 5.113.0 → 5.119.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/README.md +31 -7
- package/custom-elements.json +138 -0
- package/dist/cdn/viz.js +24901 -0
- package/dist/deno/README.md +31 -7
- package/dist/deno/jssm.d.ts +70 -5
- package/dist/deno/jssm.js +1 -1
- package/dist/deno/jssm_constants.d.ts +58 -1
- package/dist/deno/jssm_viz.d.ts +57 -7
- package/dist/deno/version.d.ts +13 -1
- 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/viz.define.js +6 -0
- package/dist/wc/viz.js +135 -0
- package/jssm.es5.d.cts +143 -4
- package/jssm.es6.d.ts +143 -4
- package/jssm_viz.es5.d.cts +127 -10
- package/jssm_viz.es6.d.ts +127 -10
- package/package.json +36 -6
package/dist/wc/viz.js
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { css, LitElement, html } from 'lit';
|
|
2
|
+
import { property, state } from 'lit/decorators.js';
|
|
3
|
+
import { unsafeHTML } from 'lit/directives/unsafe-html.js';
|
|
4
|
+
import { fsl_to_svg_string } from 'jssm/viz';
|
|
5
|
+
|
|
6
|
+
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
7
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
9
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
10
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Normalize an arbitrary thrown value into a {@link JssmVizErrorDetail}.
|
|
14
|
+
* Accepts anything (Error instances, JssmErrors with `.location`, plain
|
|
15
|
+
* strings, etc.) and always produces a string `message`.
|
|
16
|
+
*
|
|
17
|
+
* ```typescript
|
|
18
|
+
* normalize_viz_error(new Error('boom'));
|
|
19
|
+
* // => { message: 'boom', location: undefined }
|
|
20
|
+
*
|
|
21
|
+
* normalize_viz_error({ message: 'parse failed', location: { line: 1 } });
|
|
22
|
+
* // => { message: 'parse failed', location: { line: 1 } }
|
|
23
|
+
*
|
|
24
|
+
* normalize_viz_error('bare string failure');
|
|
25
|
+
* // => { message: 'bare string failure', location: undefined }
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @param e The thrown value to normalize.
|
|
29
|
+
* @returns A `{ message, location }` object suitable for use as the
|
|
30
|
+
* `detail` of a `viz-error` `CustomEvent`.
|
|
31
|
+
*/
|
|
32
|
+
function normalize_viz_error(e) {
|
|
33
|
+
if (typeof e === 'object' && e !== null) {
|
|
34
|
+
const rec = e;
|
|
35
|
+
const raw_message = rec.message;
|
|
36
|
+
const message = (typeof raw_message === 'string' && raw_message.length > 0)
|
|
37
|
+
? raw_message
|
|
38
|
+
: String(e);
|
|
39
|
+
return { message, location: rec.location };
|
|
40
|
+
}
|
|
41
|
+
return { message: String(e), location: undefined };
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Web component that renders a jssm machine as inline SVG.
|
|
45
|
+
*
|
|
46
|
+
* @element jssm-viz
|
|
47
|
+
* @cssproperty [--jssm-viz-min-height=100px] - Minimum height of the rendered SVG container.
|
|
48
|
+
* @fires {CustomEvent<{ message: string; location?: unknown }>} viz-error - Fires when the FSL source fails to parse or render.
|
|
49
|
+
*/
|
|
50
|
+
class JssmViz extends LitElement {
|
|
51
|
+
constructor() {
|
|
52
|
+
super(...arguments);
|
|
53
|
+
/** FSL source to render. */
|
|
54
|
+
this.fsl = '';
|
|
55
|
+
/** Optional Graphviz layout engine override (e.g. 'dot', 'neato'). */
|
|
56
|
+
this.engine = undefined;
|
|
57
|
+
this._svg = '';
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Lit lifecycle hook. Triggers an async SVG render whenever `fsl` or
|
|
61
|
+
* `engine` change.
|
|
62
|
+
*
|
|
63
|
+
* @param changed - Map of changed reactive properties supplied by Lit.
|
|
64
|
+
*/
|
|
65
|
+
willUpdate(changed) {
|
|
66
|
+
if (changed.has('fsl') || changed.has('engine')) {
|
|
67
|
+
this._renderSvg();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Render the current `fsl` source to an SVG string via the headless
|
|
72
|
+
* `fsl_to_svg_string` pipeline. Updates `_svg` on success; emits a
|
|
73
|
+
* `viz-error` `CustomEvent` on failure. Guards against stale results
|
|
74
|
+
* when `fsl` changes mid-flight.
|
|
75
|
+
*
|
|
76
|
+
* @returns A promise that resolves once the render attempt has finished.
|
|
77
|
+
*/
|
|
78
|
+
async _renderSvg() {
|
|
79
|
+
const source = this.fsl;
|
|
80
|
+
if (!source) {
|
|
81
|
+
this._svg = '';
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
try {
|
|
85
|
+
const result = await fsl_to_svg_string(source, this.engine ? { engine: this.engine } : undefined);
|
|
86
|
+
// Guard against stale results: only commit if fsl has not changed since this render started.
|
|
87
|
+
if (this.fsl === source) {
|
|
88
|
+
this._svg = result;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
catch (e) {
|
|
92
|
+
this._svg = '';
|
|
93
|
+
this.dispatchEvent(new CustomEvent('viz-error', {
|
|
94
|
+
detail: normalize_viz_error(e),
|
|
95
|
+
bubbles: true,
|
|
96
|
+
composed: true,
|
|
97
|
+
}));
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Lit render method. Injects the most recent SVG string into the shadow
|
|
102
|
+
* tree via the `unsafeHTML` directive.
|
|
103
|
+
*
|
|
104
|
+
* SVG content originates from `@viz-js/viz` (Graphviz WASM), which emits
|
|
105
|
+
* sanitized SVG. `unsafeHTML` is required because Lit's template-literal
|
|
106
|
+
* interpolation otherwise escapes the markup as text. The directive name
|
|
107
|
+
* makes the trust boundary explicit at the call site.
|
|
108
|
+
*
|
|
109
|
+
* @returns A Lit `TemplateResult` wrapping the SVG in a `.container` div.
|
|
110
|
+
*/
|
|
111
|
+
render() {
|
|
112
|
+
return html `<div class="container">${unsafeHTML(this._svg)}</div>`;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
JssmViz.styles = css `
|
|
116
|
+
:host {
|
|
117
|
+
display: block;
|
|
118
|
+
min-height: var(--jssm-viz-min-height, 100px);
|
|
119
|
+
}
|
|
120
|
+
.container {
|
|
121
|
+
width: 100%;
|
|
122
|
+
height: 100%;
|
|
123
|
+
}
|
|
124
|
+
`;
|
|
125
|
+
__decorate([
|
|
126
|
+
property({ type: String })
|
|
127
|
+
], JssmViz.prototype, "fsl", void 0);
|
|
128
|
+
__decorate([
|
|
129
|
+
property({ type: String })
|
|
130
|
+
], JssmViz.prototype, "engine", void 0);
|
|
131
|
+
__decorate([
|
|
132
|
+
state()
|
|
133
|
+
], JssmViz.prototype, "_svg", void 0);
|
|
134
|
+
|
|
135
|
+
export { JssmViz, normalize_viz_error };
|
package/jssm.es5.d.cts
CHANGED
|
@@ -973,6 +973,63 @@ declare const shapes$1: string[];
|
|
|
973
973
|
*
|
|
974
974
|
*/
|
|
975
975
|
declare const named_colors$1: string[];
|
|
976
|
+
/*******
|
|
977
|
+
*
|
|
978
|
+
* Character ranges accepted by the FSL grammar for identifier and label
|
|
979
|
+
* tokens. Each entry is an inclusive `{from, to}` range of single Unicode
|
|
980
|
+
* characters. Single-character entries (e.g. `.`) appear with `from === to`.
|
|
981
|
+
*
|
|
982
|
+
* These are intended for tooling, validators, and editors that need to know
|
|
983
|
+
* which characters are legal in a given FSL token position without re-parsing
|
|
984
|
+
* the PEG grammar.
|
|
985
|
+
*
|
|
986
|
+
*/
|
|
987
|
+
/**
|
|
988
|
+
* Inclusive character ranges accepted by `AtomLetter` — i.e., the characters
|
|
989
|
+
* legal in any but the first position of an FSL state name (atom).
|
|
990
|
+
*
|
|
991
|
+
* Includes ASCII digits/letters and the symbols
|
|
992
|
+
* `.`, `+`, `_`, `^`, `(`, `)`, `*`, `&`, `$`, `#`, `@`, `!`, `?`, `,`,
|
|
993
|
+
* plus the high-Unicode range `U+0080`–`U+FFFF`.
|
|
994
|
+
*
|
|
995
|
+
* @example
|
|
996
|
+
* state_name_chars.some(r => 'A' >= r.from && 'A' <= r.to); // true
|
|
997
|
+
*/
|
|
998
|
+
declare const state_name_chars$1: ReadonlyArray<{
|
|
999
|
+
from: string;
|
|
1000
|
+
to: string;
|
|
1001
|
+
}>;
|
|
1002
|
+
/**
|
|
1003
|
+
* Inclusive character ranges accepted by `AtomFirstLetter` — i.e., the
|
|
1004
|
+
* characters legal in the first position of an FSL state name (atom).
|
|
1005
|
+
*
|
|
1006
|
+
* Notably narrower than {@link state_name_chars}: omits `+`, `(`, `)`, `&`,
|
|
1007
|
+
* `#`, `@`. Includes ASCII digits/letters, `.`, `_`, `!`, `$`, `^`, `*`,
|
|
1008
|
+
* `?`, `,`, and the high-Unicode range `U+0080`–`U+FFFF`.
|
|
1009
|
+
*
|
|
1010
|
+
* @example
|
|
1011
|
+
* state_name_first_chars.some(r => '+' >= r.from && '+' <= r.to); // false
|
|
1012
|
+
*/
|
|
1013
|
+
declare const state_name_first_chars$1: ReadonlyArray<{
|
|
1014
|
+
from: string;
|
|
1015
|
+
to: string;
|
|
1016
|
+
}>;
|
|
1017
|
+
/**
|
|
1018
|
+
* Inclusive character ranges accepted by `ActionLabelUnescaped` — i.e., the
|
|
1019
|
+
* characters legal inside a single-quoted action label without escaping.
|
|
1020
|
+
* Space (`U+0020`) is included; the apostrophe `'` (`U+0027`) is explicitly
|
|
1021
|
+
* excluded since it terminates the label.
|
|
1022
|
+
*
|
|
1023
|
+
* Three ranges: `U+0020`–`U+0026`, `U+0028`–`U+005B`, `U+005D`–`U+FFFF`.
|
|
1024
|
+
*
|
|
1025
|
+
* @example
|
|
1026
|
+
* action_label_chars.some(r => ' ' >= r.from && ' ' <= r.to); // true
|
|
1027
|
+
* action_label_chars.some(r => "'" >= r.from && "'" <= r.to); // false
|
|
1028
|
+
*/
|
|
1029
|
+
declare const action_label_chars$1: ReadonlyArray<{
|
|
1030
|
+
from: string;
|
|
1031
|
+
to: string;
|
|
1032
|
+
}>;
|
|
976
1033
|
|
|
977
1034
|
declare const jssm_constants_d_E: typeof E;
|
|
978
1035
|
declare const jssm_constants_d_Epsilon: typeof Epsilon;
|
|
@@ -1010,13 +1067,27 @@ declare namespace jssm_constants_d {
|
|
|
1010
1067
|
jssm_constants_d_PosInfinity as PosInfinity,
|
|
1011
1068
|
jssm_constants_d_Root2 as Root2,
|
|
1012
1069
|
jssm_constants_d_RootHalf as RootHalf,
|
|
1070
|
+
action_label_chars$1 as action_label_chars,
|
|
1013
1071
|
gviz_shapes$1 as gviz_shapes,
|
|
1014
1072
|
named_colors$1 as named_colors,
|
|
1015
1073
|
shapes$1 as shapes,
|
|
1074
|
+
state_name_chars$1 as state_name_chars,
|
|
1075
|
+
state_name_first_chars$1 as state_name_first_chars,
|
|
1016
1076
|
};
|
|
1017
1077
|
}
|
|
1018
1078
|
|
|
1079
|
+
/**
|
|
1080
|
+
* The published semantic version of the jssm package this build was cut from.
|
|
1081
|
+
* Mirrored from `package.json` by `src/buildjs/makever.cjs` at build time.
|
|
1082
|
+
* Useful for runtime diagnostics and for embedding in serialized machine
|
|
1083
|
+
* snapshots so that deserializers can detect version-skew.
|
|
1084
|
+
*/
|
|
1019
1085
|
declare const version: string;
|
|
1086
|
+
/**
|
|
1087
|
+
* The Unix epoch timestamp (in milliseconds) at which this build was produced,
|
|
1088
|
+
* written by `src/buildjs/makever.cjs`. Useful for distinguishing builds
|
|
1089
|
+
* with the same `version` string during development, and for diagnostic logs.
|
|
1090
|
+
*/
|
|
1020
1091
|
declare const build_time: number;
|
|
1021
1092
|
|
|
1022
1093
|
declare type StateType = string;
|
|
@@ -1024,6 +1095,18 @@ declare type StateType = string;
|
|
|
1024
1095
|
declare const shapes: string[];
|
|
1025
1096
|
declare const gviz_shapes: string[];
|
|
1026
1097
|
declare const named_colors: string[];
|
|
1098
|
+
declare const state_name_chars: readonly {
|
|
1099
|
+
from: string;
|
|
1100
|
+
to: string;
|
|
1101
|
+
}[];
|
|
1102
|
+
declare const state_name_first_chars: readonly {
|
|
1103
|
+
from: string;
|
|
1104
|
+
to: string;
|
|
1105
|
+
}[];
|
|
1106
|
+
declare const action_label_chars: readonly {
|
|
1107
|
+
from: string;
|
|
1108
|
+
to: string;
|
|
1109
|
+
}[];
|
|
1027
1110
|
|
|
1028
1111
|
/*********
|
|
1029
1112
|
*
|
|
@@ -1704,6 +1787,49 @@ declare class Machine<mDT> {
|
|
|
1704
1787
|
* @returns An array of theme name strings.
|
|
1705
1788
|
*/
|
|
1706
1789
|
all_themes(): FslTheme[];
|
|
1790
|
+
/** List the character ranges accepted by the FSL grammar in any but the
|
|
1791
|
+
* first position of a state name (atom). Each entry is an inclusive
|
|
1792
|
+
* `{from, to}` range of single Unicode characters.
|
|
1793
|
+
*
|
|
1794
|
+
* @returns An array of `{from, to}` inclusive character ranges.
|
|
1795
|
+
*
|
|
1796
|
+
* @example
|
|
1797
|
+
* const m = sm`a -> b;`;
|
|
1798
|
+
* m.all_state_name_chars().some(r => '+' >= r.from && '+' <= r.to); // true
|
|
1799
|
+
*/
|
|
1800
|
+
all_state_name_chars(): ReadonlyArray<{
|
|
1801
|
+
from: string;
|
|
1802
|
+
to: string;
|
|
1803
|
+
}>;
|
|
1804
|
+
/** List the character ranges accepted by the FSL grammar in the first
|
|
1805
|
+
* position of a state name (atom). Narrower than
|
|
1806
|
+
* {@link all_state_name_chars}: notably omits `+`, `(`, `)`, `&`, `#`, `@`.
|
|
1807
|
+
*
|
|
1808
|
+
* @returns An array of `{from, to}` inclusive character ranges.
|
|
1809
|
+
*
|
|
1810
|
+
* @example
|
|
1811
|
+
* const m = sm`a -> b;`;
|
|
1812
|
+
* m.all_state_name_first_chars().some(r => '+' >= r.from && '+' <= r.to); // false
|
|
1813
|
+
*/
|
|
1814
|
+
all_state_name_first_chars(): ReadonlyArray<{
|
|
1815
|
+
from: string;
|
|
1816
|
+
to: string;
|
|
1817
|
+
}>;
|
|
1818
|
+
/** List the character ranges accepted inside a single-quoted FSL action
|
|
1819
|
+
* label without escaping. Space is allowed; the apostrophe `'` is
|
|
1820
|
+
* explicitly excluded since it terminates the label.
|
|
1821
|
+
*
|
|
1822
|
+
* @returns An array of `{from, to}` inclusive character ranges.
|
|
1823
|
+
*
|
|
1824
|
+
* @example
|
|
1825
|
+
* const m = sm`a -> b;`;
|
|
1826
|
+
* m.all_action_label_chars().some(r => ' ' >= r.from && ' ' <= r.to); // true
|
|
1827
|
+
* m.all_action_label_chars().some(r => "'" >= r.from && "'" <= r.to); // false
|
|
1828
|
+
*/
|
|
1829
|
+
all_action_label_chars(): ReadonlyArray<{
|
|
1830
|
+
from: string;
|
|
1831
|
+
to: string;
|
|
1832
|
+
}>;
|
|
1707
1833
|
/** Get the active theme(s) for this machine. Always stored as an array
|
|
1708
1834
|
* internally; the union return type exists for setter compatibility.
|
|
1709
1835
|
* @returns The current theme or array of themes.
|
|
@@ -1797,10 +1923,23 @@ declare class Machine<mDT> {
|
|
|
1797
1923
|
*
|
|
1798
1924
|
*/
|
|
1799
1925
|
list_exits(whichState?: StateType): Array<StateType>;
|
|
1800
|
-
/** Get the transitions available from a state
|
|
1801
|
-
*
|
|
1926
|
+
/** Get the transitions available from a state for use by the probabilistic
|
|
1927
|
+
* walk system.
|
|
1928
|
+
*
|
|
1929
|
+
* If any exit declares a `probability`, only those probability-bearing
|
|
1930
|
+
* exits are returned, so that non-probability peers cannot dilute the
|
|
1931
|
+
* declared distribution. If no exit declares a `probability`, every
|
|
1932
|
+
* legal (non-forced) exit is returned, which `weighted_rand_select`
|
|
1933
|
+
* treats as equal weight. Forced-only exits (`~>`) are always excluded,
|
|
1934
|
+
* since they cannot be taken by an ordinary `transition()` call.
|
|
1935
|
+
*
|
|
1936
|
+
* Fixes StoneCypher/fsl#1325, in which the function previously returned
|
|
1937
|
+
* every exit unconditionally — including forced-only exits and exits
|
|
1938
|
+
* with no `probability`, which distorted the weighted distribution.
|
|
1939
|
+
*
|
|
1802
1940
|
* @param whichState - The state to inspect.
|
|
1803
|
-
* @returns An array of {@link JssmTransition} edges exiting the state
|
|
1941
|
+
* @returns An array of {@link JssmTransition} edges exiting the state,
|
|
1942
|
+
* filtered as described above. May be empty.
|
|
1804
1943
|
* @throws {JssmError} If the state does not exist.
|
|
1805
1944
|
*/
|
|
1806
1945
|
probable_exits_for(whichState: StateType): Array<JssmTransition<StateType, mDT>>;
|
|
@@ -2891,4 +3030,4 @@ declare function abstract_everything_hook_step<mDT>(maybe_hook: EverythingHookHa
|
|
|
2891
3030
|
*/
|
|
2892
3031
|
declare function deserialize<mDT>(machine_string: string, ser: JssmSerialization<mDT>): Machine<mDT>;
|
|
2893
3032
|
|
|
2894
|
-
export { FslDirections, Machine, abstract_everything_hook_step, abstract_hook_step, arrow_direction, arrow_left_kind, arrow_right_kind, build_time, compile, jssm_constants_d as constants, deserialize, find_repeated, from, gen_splitmix32, gviz_shapes, histograph, is_hook_complex_result, is_hook_rejection, make, named_colors, wrap_parse as parse, seq, shapes, sleep, sm, state_style_condense, transfer_state_properties, unique, version, weighted_histo_key, weighted_rand_select, weighted_sample_select };
|
|
3033
|
+
export { FslDirections, Machine, abstract_everything_hook_step, abstract_hook_step, action_label_chars, arrow_direction, arrow_left_kind, arrow_right_kind, build_time, compile, jssm_constants_d as constants, deserialize, find_repeated, from, gen_splitmix32, gviz_shapes, histograph, is_hook_complex_result, is_hook_rejection, make, named_colors, wrap_parse as parse, seq, shapes, sleep, sm, state_name_chars, state_name_first_chars, state_style_condense, transfer_state_properties, unique, version, weighted_histo_key, weighted_rand_select, weighted_sample_select };
|
package/jssm.es6.d.ts
CHANGED
|
@@ -973,6 +973,63 @@ declare const shapes$1: string[];
|
|
|
973
973
|
*
|
|
974
974
|
*/
|
|
975
975
|
declare const named_colors$1: string[];
|
|
976
|
+
/*******
|
|
977
|
+
*
|
|
978
|
+
* Character ranges accepted by the FSL grammar for identifier and label
|
|
979
|
+
* tokens. Each entry is an inclusive `{from, to}` range of single Unicode
|
|
980
|
+
* characters. Single-character entries (e.g. `.`) appear with `from === to`.
|
|
981
|
+
*
|
|
982
|
+
* These are intended for tooling, validators, and editors that need to know
|
|
983
|
+
* which characters are legal in a given FSL token position without re-parsing
|
|
984
|
+
* the PEG grammar.
|
|
985
|
+
*
|
|
986
|
+
*/
|
|
987
|
+
/**
|
|
988
|
+
* Inclusive character ranges accepted by `AtomLetter` — i.e., the characters
|
|
989
|
+
* legal in any but the first position of an FSL state name (atom).
|
|
990
|
+
*
|
|
991
|
+
* Includes ASCII digits/letters and the symbols
|
|
992
|
+
* `.`, `+`, `_`, `^`, `(`, `)`, `*`, `&`, `$`, `#`, `@`, `!`, `?`, `,`,
|
|
993
|
+
* plus the high-Unicode range `U+0080`–`U+FFFF`.
|
|
994
|
+
*
|
|
995
|
+
* @example
|
|
996
|
+
* state_name_chars.some(r => 'A' >= r.from && 'A' <= r.to); // true
|
|
997
|
+
*/
|
|
998
|
+
declare const state_name_chars$1: ReadonlyArray<{
|
|
999
|
+
from: string;
|
|
1000
|
+
to: string;
|
|
1001
|
+
}>;
|
|
1002
|
+
/**
|
|
1003
|
+
* Inclusive character ranges accepted by `AtomFirstLetter` — i.e., the
|
|
1004
|
+
* characters legal in the first position of an FSL state name (atom).
|
|
1005
|
+
*
|
|
1006
|
+
* Notably narrower than {@link state_name_chars}: omits `+`, `(`, `)`, `&`,
|
|
1007
|
+
* `#`, `@`. Includes ASCII digits/letters, `.`, `_`, `!`, `$`, `^`, `*`,
|
|
1008
|
+
* `?`, `,`, and the high-Unicode range `U+0080`–`U+FFFF`.
|
|
1009
|
+
*
|
|
1010
|
+
* @example
|
|
1011
|
+
* state_name_first_chars.some(r => '+' >= r.from && '+' <= r.to); // false
|
|
1012
|
+
*/
|
|
1013
|
+
declare const state_name_first_chars$1: ReadonlyArray<{
|
|
1014
|
+
from: string;
|
|
1015
|
+
to: string;
|
|
1016
|
+
}>;
|
|
1017
|
+
/**
|
|
1018
|
+
* Inclusive character ranges accepted by `ActionLabelUnescaped` — i.e., the
|
|
1019
|
+
* characters legal inside a single-quoted action label without escaping.
|
|
1020
|
+
* Space (`U+0020`) is included; the apostrophe `'` (`U+0027`) is explicitly
|
|
1021
|
+
* excluded since it terminates the label.
|
|
1022
|
+
*
|
|
1023
|
+
* Three ranges: `U+0020`–`U+0026`, `U+0028`–`U+005B`, `U+005D`–`U+FFFF`.
|
|
1024
|
+
*
|
|
1025
|
+
* @example
|
|
1026
|
+
* action_label_chars.some(r => ' ' >= r.from && ' ' <= r.to); // true
|
|
1027
|
+
* action_label_chars.some(r => "'" >= r.from && "'" <= r.to); // false
|
|
1028
|
+
*/
|
|
1029
|
+
declare const action_label_chars$1: ReadonlyArray<{
|
|
1030
|
+
from: string;
|
|
1031
|
+
to: string;
|
|
1032
|
+
}>;
|
|
976
1033
|
|
|
977
1034
|
declare const jssm_constants_d_E: typeof E;
|
|
978
1035
|
declare const jssm_constants_d_Epsilon: typeof Epsilon;
|
|
@@ -1010,13 +1067,27 @@ declare namespace jssm_constants_d {
|
|
|
1010
1067
|
jssm_constants_d_PosInfinity as PosInfinity,
|
|
1011
1068
|
jssm_constants_d_Root2 as Root2,
|
|
1012
1069
|
jssm_constants_d_RootHalf as RootHalf,
|
|
1070
|
+
action_label_chars$1 as action_label_chars,
|
|
1013
1071
|
gviz_shapes$1 as gviz_shapes,
|
|
1014
1072
|
named_colors$1 as named_colors,
|
|
1015
1073
|
shapes$1 as shapes,
|
|
1074
|
+
state_name_chars$1 as state_name_chars,
|
|
1075
|
+
state_name_first_chars$1 as state_name_first_chars,
|
|
1016
1076
|
};
|
|
1017
1077
|
}
|
|
1018
1078
|
|
|
1079
|
+
/**
|
|
1080
|
+
* The published semantic version of the jssm package this build was cut from.
|
|
1081
|
+
* Mirrored from `package.json` by `src/buildjs/makever.cjs` at build time.
|
|
1082
|
+
* Useful for runtime diagnostics and for embedding in serialized machine
|
|
1083
|
+
* snapshots so that deserializers can detect version-skew.
|
|
1084
|
+
*/
|
|
1019
1085
|
declare const version: string;
|
|
1086
|
+
/**
|
|
1087
|
+
* The Unix epoch timestamp (in milliseconds) at which this build was produced,
|
|
1088
|
+
* written by `src/buildjs/makever.cjs`. Useful for distinguishing builds
|
|
1089
|
+
* with the same `version` string during development, and for diagnostic logs.
|
|
1090
|
+
*/
|
|
1020
1091
|
declare const build_time: number;
|
|
1021
1092
|
|
|
1022
1093
|
declare type StateType = string;
|
|
@@ -1024,6 +1095,18 @@ declare type StateType = string;
|
|
|
1024
1095
|
declare const shapes: string[];
|
|
1025
1096
|
declare const gviz_shapes: string[];
|
|
1026
1097
|
declare const named_colors: string[];
|
|
1098
|
+
declare const state_name_chars: readonly {
|
|
1099
|
+
from: string;
|
|
1100
|
+
to: string;
|
|
1101
|
+
}[];
|
|
1102
|
+
declare const state_name_first_chars: readonly {
|
|
1103
|
+
from: string;
|
|
1104
|
+
to: string;
|
|
1105
|
+
}[];
|
|
1106
|
+
declare const action_label_chars: readonly {
|
|
1107
|
+
from: string;
|
|
1108
|
+
to: string;
|
|
1109
|
+
}[];
|
|
1027
1110
|
|
|
1028
1111
|
/*********
|
|
1029
1112
|
*
|
|
@@ -1704,6 +1787,49 @@ declare class Machine<mDT> {
|
|
|
1704
1787
|
* @returns An array of theme name strings.
|
|
1705
1788
|
*/
|
|
1706
1789
|
all_themes(): FslTheme[];
|
|
1790
|
+
/** List the character ranges accepted by the FSL grammar in any but the
|
|
1791
|
+
* first position of a state name (atom). Each entry is an inclusive
|
|
1792
|
+
* `{from, to}` range of single Unicode characters.
|
|
1793
|
+
*
|
|
1794
|
+
* @returns An array of `{from, to}` inclusive character ranges.
|
|
1795
|
+
*
|
|
1796
|
+
* @example
|
|
1797
|
+
* const m = sm`a -> b;`;
|
|
1798
|
+
* m.all_state_name_chars().some(r => '+' >= r.from && '+' <= r.to); // true
|
|
1799
|
+
*/
|
|
1800
|
+
all_state_name_chars(): ReadonlyArray<{
|
|
1801
|
+
from: string;
|
|
1802
|
+
to: string;
|
|
1803
|
+
}>;
|
|
1804
|
+
/** List the character ranges accepted by the FSL grammar in the first
|
|
1805
|
+
* position of a state name (atom). Narrower than
|
|
1806
|
+
* {@link all_state_name_chars}: notably omits `+`, `(`, `)`, `&`, `#`, `@`.
|
|
1807
|
+
*
|
|
1808
|
+
* @returns An array of `{from, to}` inclusive character ranges.
|
|
1809
|
+
*
|
|
1810
|
+
* @example
|
|
1811
|
+
* const m = sm`a -> b;`;
|
|
1812
|
+
* m.all_state_name_first_chars().some(r => '+' >= r.from && '+' <= r.to); // false
|
|
1813
|
+
*/
|
|
1814
|
+
all_state_name_first_chars(): ReadonlyArray<{
|
|
1815
|
+
from: string;
|
|
1816
|
+
to: string;
|
|
1817
|
+
}>;
|
|
1818
|
+
/** List the character ranges accepted inside a single-quoted FSL action
|
|
1819
|
+
* label without escaping. Space is allowed; the apostrophe `'` is
|
|
1820
|
+
* explicitly excluded since it terminates the label.
|
|
1821
|
+
*
|
|
1822
|
+
* @returns An array of `{from, to}` inclusive character ranges.
|
|
1823
|
+
*
|
|
1824
|
+
* @example
|
|
1825
|
+
* const m = sm`a -> b;`;
|
|
1826
|
+
* m.all_action_label_chars().some(r => ' ' >= r.from && ' ' <= r.to); // true
|
|
1827
|
+
* m.all_action_label_chars().some(r => "'" >= r.from && "'" <= r.to); // false
|
|
1828
|
+
*/
|
|
1829
|
+
all_action_label_chars(): ReadonlyArray<{
|
|
1830
|
+
from: string;
|
|
1831
|
+
to: string;
|
|
1832
|
+
}>;
|
|
1707
1833
|
/** Get the active theme(s) for this machine. Always stored as an array
|
|
1708
1834
|
* internally; the union return type exists for setter compatibility.
|
|
1709
1835
|
* @returns The current theme or array of themes.
|
|
@@ -1797,10 +1923,23 @@ declare class Machine<mDT> {
|
|
|
1797
1923
|
*
|
|
1798
1924
|
*/
|
|
1799
1925
|
list_exits(whichState?: StateType): Array<StateType>;
|
|
1800
|
-
/** Get the transitions available from a state
|
|
1801
|
-
*
|
|
1926
|
+
/** Get the transitions available from a state for use by the probabilistic
|
|
1927
|
+
* walk system.
|
|
1928
|
+
*
|
|
1929
|
+
* If any exit declares a `probability`, only those probability-bearing
|
|
1930
|
+
* exits are returned, so that non-probability peers cannot dilute the
|
|
1931
|
+
* declared distribution. If no exit declares a `probability`, every
|
|
1932
|
+
* legal (non-forced) exit is returned, which `weighted_rand_select`
|
|
1933
|
+
* treats as equal weight. Forced-only exits (`~>`) are always excluded,
|
|
1934
|
+
* since they cannot be taken by an ordinary `transition()` call.
|
|
1935
|
+
*
|
|
1936
|
+
* Fixes StoneCypher/fsl#1325, in which the function previously returned
|
|
1937
|
+
* every exit unconditionally — including forced-only exits and exits
|
|
1938
|
+
* with no `probability`, which distorted the weighted distribution.
|
|
1939
|
+
*
|
|
1802
1940
|
* @param whichState - The state to inspect.
|
|
1803
|
-
* @returns An array of {@link JssmTransition} edges exiting the state
|
|
1941
|
+
* @returns An array of {@link JssmTransition} edges exiting the state,
|
|
1942
|
+
* filtered as described above. May be empty.
|
|
1804
1943
|
* @throws {JssmError} If the state does not exist.
|
|
1805
1944
|
*/
|
|
1806
1945
|
probable_exits_for(whichState: StateType): Array<JssmTransition<StateType, mDT>>;
|
|
@@ -2891,4 +3030,4 @@ declare function abstract_everything_hook_step<mDT>(maybe_hook: EverythingHookHa
|
|
|
2891
3030
|
*/
|
|
2892
3031
|
declare function deserialize<mDT>(machine_string: string, ser: JssmSerialization<mDT>): Machine<mDT>;
|
|
2893
3032
|
|
|
2894
|
-
export { FslDirections, Machine, abstract_everything_hook_step, abstract_hook_step, arrow_direction, arrow_left_kind, arrow_right_kind, build_time, compile, jssm_constants_d as constants, deserialize, find_repeated, from, gen_splitmix32, gviz_shapes, histograph, is_hook_complex_result, is_hook_rejection, make, named_colors, wrap_parse as parse, seq, shapes, sleep, sm, state_style_condense, transfer_state_properties, unique, version, weighted_histo_key, weighted_rand_select, weighted_sample_select };
|
|
3033
|
+
export { FslDirections, Machine, abstract_everything_hook_step, abstract_hook_step, action_label_chars, arrow_direction, arrow_left_kind, arrow_right_kind, build_time, compile, jssm_constants_d as constants, deserialize, find_repeated, from, gen_splitmix32, gviz_shapes, histograph, is_hook_complex_result, is_hook_rejection, make, named_colors, wrap_parse as parse, seq, shapes, sleep, sm, state_name_chars, state_name_first_chars, state_style_condense, transfer_state_properties, unique, version, weighted_histo_key, weighted_rand_select, weighted_sample_select };
|