jssm 5.162.32 → 5.162.34
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 +3 -3
- package/dist/cdn/instance.js +1 -1
- package/dist/cdn/viz.js +1 -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 +3 -3
- package/dist/deno/jssm.d.ts +8 -0
- package/dist/deno/jssm.js +1 -1
- package/dist/fence/fence.js +93 -112
- 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/jssm.es5.d.cts +8 -0
- package/jssm.es6.d.ts +8 -0
- package/jssm.fence.d.ts +8 -0
- package/jssm_viz.es5.d.cts +8 -0
- package/jssm_viz.es6.d.ts +8 -0
- package/package.json +1 -1
package/dist/fence/fence.js
CHANGED
|
@@ -24454,7 +24454,7 @@ function fslSemanticSpans(text) {
|
|
|
24454
24454
|
* Useful for runtime diagnostics and for embedding in serialized machine
|
|
24455
24455
|
* snapshots so that deserializers can detect version-skew.
|
|
24456
24456
|
*/
|
|
24457
|
-
const version = "5.162.
|
|
24457
|
+
const version = "5.162.34";
|
|
24458
24458
|
|
|
24459
24459
|
/**
|
|
24460
24460
|
* The FSL Markdown fence convention parser — pure, host-agnostic logic that
|
|
@@ -24615,18 +24615,12 @@ function parse_fence_info(info) {
|
|
|
24615
24615
|
}
|
|
24616
24616
|
|
|
24617
24617
|
// whargarbl lots of these return arrays could/should be sets
|
|
24618
|
-
var __classPrivateFieldSet = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
24619
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
24620
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
24621
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
24622
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
24623
|
-
};
|
|
24624
24618
|
var __classPrivateFieldGet = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
24625
24619
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
24626
24620
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
24627
24621
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
24628
24622
|
};
|
|
24629
|
-
var _Machine_instances,
|
|
24623
|
+
var _Machine_instances, _Machine_unsubscribe_entry, _Machine_subscribe, _Machine_fire_one, _Machine_has_subscribers, _Machine_fire, _Machine_validate_hook_description, _Machine_recompute_hook_flags, _Machine_fire_hook_rejection, _Machine_fire_boundary_actions, _Machine_resolved_themes, _Machine_individual_state_config, _Machine_groups_by_depth, _Machine_compose_state_config;
|
|
24630
24624
|
const { state_name_chars, state_name_first_chars, action_label_chars } = constants;
|
|
24631
24625
|
const empty_string_set = new Set();
|
|
24632
24626
|
// The spatial fields (besides `handler`, which every hook needs) that each
|
|
@@ -25016,26 +25010,18 @@ class Machine {
|
|
|
25016
25010
|
// whargarbl this badly needs to be broken up, monolith master
|
|
25017
25011
|
constructor({ start_states, end_states = [], failed_outputs = [], initial_state, start_states_no_enforce, complete = [], transitions, machine_author, machine_comment, machine_contributor, machine_definition, machine_language, machine_license, machine_name, machine_version, npm_name, default_size, state_declaration, property_definition, state_property, fsl_version, dot_preamble, arrange_declaration = [], arrange_start_declaration = [], arrange_end_declaration = [], oarrange_declaration = [], farrange_declaration = [], theme = ['default'], flow = 'down', graph_layout = 'dot', instance_name, history, boundary_depth_limit, data, default_state_config, default_active_state_config, default_hooked_state_config, default_terminal_state_config, default_start_state_config, default_end_state_config, default_transition_config, default_graph_config, group_registry, group_metadata, group_hooks, state_hooks, allows_override, config_allows_override, allow_islands, editor_config, rng_seed, time_source, timeout_source, clear_timeout_source }) {
|
|
25018
25012
|
_Machine_instances.add(this);
|
|
25019
|
-
_Machine_states.set(this, void 0);
|
|
25020
|
-
_Machine_edges.set(this, void 0);
|
|
25021
|
-
_Machine_edge_map.set(this, void 0);
|
|
25022
|
-
_Machine_outbound_edge_ids.set(this, void 0); // from -> [edgeIds]; lets edges_between filter only that state's exits instead of the whole _edges array
|
|
25023
|
-
_Machine_named_transitions.set(this, void 0);
|
|
25024
|
-
_Machine_actions.set(this, void 0);
|
|
25025
|
-
_Machine_reverse_actions.set(this, void 0);
|
|
25026
|
-
_Machine_reverse_action_targets.set(this, void 0);
|
|
25027
25013
|
this._time_source = time_source !== null && time_source !== void 0 ? time_source : DEFAULT_TIME_SOURCE;
|
|
25028
25014
|
this._create_started = this._time_source();
|
|
25029
25015
|
this._instance_name = instance_name;
|
|
25030
|
-
|
|
25016
|
+
this._states = new Map();
|
|
25031
25017
|
this._state_declarations = new Map();
|
|
25032
|
-
|
|
25033
|
-
|
|
25034
|
-
|
|
25035
|
-
|
|
25036
|
-
|
|
25037
|
-
|
|
25038
|
-
|
|
25018
|
+
this._edges = [];
|
|
25019
|
+
this._edge_map = new Map();
|
|
25020
|
+
this._outbound_edge_ids = new Map();
|
|
25021
|
+
this._named_transitions = new Map();
|
|
25022
|
+
this._actions = new Map();
|
|
25023
|
+
this._reverse_actions = new Map();
|
|
25024
|
+
this._reverse_action_targets = new Map(); // todo
|
|
25039
25025
|
this._state_interner = new Interner();
|
|
25040
25026
|
this._action_interner = new Interner();
|
|
25041
25027
|
this._state_id = NaN;
|
|
@@ -25239,12 +25225,12 @@ class Machine {
|
|
|
25239
25225
|
throw new JssmError(this, `transition must define 'to': ${JSON.stringify(tr)}`);
|
|
25240
25226
|
}
|
|
25241
25227
|
// get the cursors. what a mess
|
|
25242
|
-
let cursor_from =
|
|
25228
|
+
let cursor_from = this._states.get(tr.from);
|
|
25243
25229
|
if (cursor_from === undefined) {
|
|
25244
25230
|
cursor_from = { name: tr.from, from: [], to: [], complete: complete_set.has(tr.from) };
|
|
25245
25231
|
this._new_state(cursor_from);
|
|
25246
25232
|
}
|
|
25247
|
-
let cursor_to =
|
|
25233
|
+
let cursor_to = this._states.get(tr.to);
|
|
25248
25234
|
if (cursor_to === undefined) {
|
|
25249
25235
|
cursor_to = { name: tr.to, from: [], to: [], complete: complete_set.has(tr.to) };
|
|
25250
25236
|
this._new_state(cursor_to);
|
|
@@ -25279,27 +25265,27 @@ class Machine {
|
|
|
25279
25265
|
slots.add(slot);
|
|
25280
25266
|
}
|
|
25281
25267
|
// add the edge; note its id
|
|
25282
|
-
|
|
25283
|
-
const thisEdgeId =
|
|
25268
|
+
this._edges.push(tr);
|
|
25269
|
+
const thisEdgeId = this._edges.length - 1;
|
|
25284
25270
|
if (tr.forced_only) {
|
|
25285
25271
|
this._has_forced_transitions = true;
|
|
25286
25272
|
}
|
|
25287
25273
|
// guard against repeating a transition name
|
|
25288
25274
|
if (tr.name) {
|
|
25289
|
-
if (
|
|
25275
|
+
if (this._named_transitions.has(tr.name)) {
|
|
25290
25276
|
throw new JssmError(this, `named transition "${JSON.stringify(tr.name)}" already created`);
|
|
25291
25277
|
}
|
|
25292
|
-
|
|
25278
|
+
this._named_transitions.set(tr.name, thisEdgeId);
|
|
25293
25279
|
}
|
|
25294
25280
|
// set up the after mapping, if any
|
|
25295
25281
|
if (tr.after_time) {
|
|
25296
25282
|
this._after_mapping.set(tr.from, [tr.to, tr.after_time]);
|
|
25297
25283
|
}
|
|
25298
25284
|
// set up the mapping, so that edges can be looked up by endpoint pairs
|
|
25299
|
-
let from_mapping =
|
|
25285
|
+
let from_mapping = this._edge_map.get(tr.from);
|
|
25300
25286
|
if (from_mapping === undefined) {
|
|
25301
25287
|
from_mapping = new Map();
|
|
25302
|
-
|
|
25288
|
+
this._edge_map.set(tr.from, from_mapping);
|
|
25303
25289
|
}
|
|
25304
25290
|
// first-declared wins: when several edges share a (from, to) pair (parallel
|
|
25305
25291
|
// action edges, #325), lookup_transition_for resolves to the first one
|
|
@@ -25324,29 +25310,29 @@ class Machine {
|
|
|
25324
25310
|
// is fine for lookup_transition_for but loses information for edges_between when several
|
|
25325
25311
|
// edges share endpoints across distinct actions. This index preserves every edge id and
|
|
25326
25312
|
// lets edges_between scan only one state's exits, not all of _edges.
|
|
25327
|
-
let outbound =
|
|
25313
|
+
let outbound = this._outbound_edge_ids.get(tr.from);
|
|
25328
25314
|
if (!outbound) {
|
|
25329
25315
|
outbound = [];
|
|
25330
|
-
|
|
25316
|
+
this._outbound_edge_ids.set(tr.from, outbound);
|
|
25331
25317
|
}
|
|
25332
25318
|
outbound.push(thisEdgeId);
|
|
25333
25319
|
// set up the action mapping, so that actions can be looked up by origin
|
|
25334
25320
|
if (tr.action) {
|
|
25335
25321
|
// forward mapping first by action name
|
|
25336
|
-
let actionMap =
|
|
25322
|
+
let actionMap = this._actions.get(tr.action);
|
|
25337
25323
|
if (!(actionMap)) {
|
|
25338
25324
|
actionMap = new Map();
|
|
25339
|
-
|
|
25325
|
+
this._actions.set(tr.action, actionMap);
|
|
25340
25326
|
}
|
|
25341
25327
|
if (actionMap.has(tr.from)) {
|
|
25342
25328
|
throw new JssmError(this, `action ${JSON.stringify(tr.action)} already attached to origin ${JSON.stringify(tr.from)}`);
|
|
25343
25329
|
}
|
|
25344
25330
|
actionMap.set(tr.from, thisEdgeId);
|
|
25345
25331
|
// reverse mapping first by state origin name
|
|
25346
|
-
let rActionMap =
|
|
25332
|
+
let rActionMap = this._reverse_actions.get(tr.from);
|
|
25347
25333
|
if (!(rActionMap)) {
|
|
25348
25334
|
rActionMap = new Map();
|
|
25349
|
-
|
|
25335
|
+
this._reverse_actions.set(tr.from, rActionMap);
|
|
25350
25336
|
}
|
|
25351
25337
|
// no need to test for reverse mapping pre-presence;
|
|
25352
25338
|
// forward mapping already covers collisions
|
|
@@ -25355,8 +25341,8 @@ class Machine {
|
|
|
25355
25341
|
const action_id = this._action_interner.intern(tr.action);
|
|
25356
25342
|
this._edge_id_by_action_pair.set(pair_key(action_id, from_id), thisEdgeId);
|
|
25357
25343
|
// reverse mapping first by state target name
|
|
25358
|
-
if (!(
|
|
25359
|
-
|
|
25344
|
+
if (!(this._reverse_action_targets.has(tr.to))) {
|
|
25345
|
+
this._reverse_action_targets.set(tr.to, new Map());
|
|
25360
25346
|
}
|
|
25361
25347
|
/* todo comeback
|
|
25362
25348
|
fundamental problem is roActionMap needs to be a multimap
|
|
@@ -25404,7 +25390,7 @@ class Machine {
|
|
|
25404
25390
|
}
|
|
25405
25391
|
// set initial state either from the specified or the start state list. validate admission behavior.
|
|
25406
25392
|
if (initial_state) {
|
|
25407
|
-
if (!(
|
|
25393
|
+
if (!(this._states.has(initial_state))) {
|
|
25408
25394
|
throw new JssmError(this, `requested start state ${initial_state} does not exist`);
|
|
25409
25395
|
}
|
|
25410
25396
|
if ((!(start_states_no_enforce)) && (!(start_states.includes(initial_state)))) {
|
|
@@ -25459,7 +25445,7 @@ class Machine {
|
|
|
25459
25445
|
}
|
|
25460
25446
|
// assert connectivity constraints imposed by allow_islands
|
|
25461
25447
|
if (this._allow_islands !== true) {
|
|
25462
|
-
const components = find_connected_components(
|
|
25448
|
+
const components = find_connected_components(this._states, this._edges);
|
|
25463
25449
|
if (this._allow_islands === false) {
|
|
25464
25450
|
if (components.length > 1) {
|
|
25465
25451
|
throw new JssmError(this, `allow_islands is false but the state graph has ${components.length} disconnected components`);
|
|
@@ -25480,7 +25466,7 @@ class Machine {
|
|
|
25480
25466
|
for (const declaration of [this._arrange_declaration, this._oarrange_declaration, this._farrange_declaration]) {
|
|
25481
25467
|
for (const arrange_pair of declaration) {
|
|
25482
25468
|
for (const possibleState of arrange_pair) {
|
|
25483
|
-
if (!(
|
|
25469
|
+
if (!(this._states.has(possibleState))) {
|
|
25484
25470
|
throw new JssmError(this, `Cannot arrange state that does not exist "${possibleState}"`);
|
|
25485
25471
|
}
|
|
25486
25472
|
}
|
|
@@ -25495,10 +25481,10 @@ class Machine {
|
|
|
25495
25481
|
*
|
|
25496
25482
|
*/
|
|
25497
25483
|
_new_state(state_config) {
|
|
25498
|
-
if (
|
|
25484
|
+
if (this._states.has(state_config.name)) {
|
|
25499
25485
|
throw new JssmError(this, `state ${JSON.stringify(state_config.name)} already exists`);
|
|
25500
25486
|
}
|
|
25501
|
-
|
|
25487
|
+
this._states.set(state_config.name, state_config);
|
|
25502
25488
|
this._state_interner.intern(state_config.name);
|
|
25503
25489
|
return state_config.name;
|
|
25504
25490
|
}
|
|
@@ -26182,14 +26168,14 @@ class Machine {
|
|
|
26182
26168
|
machine_state() {
|
|
26183
26169
|
return {
|
|
26184
26170
|
internal_state_impl_version: 1,
|
|
26185
|
-
actions:
|
|
26186
|
-
edge_map:
|
|
26187
|
-
edges:
|
|
26188
|
-
named_transitions:
|
|
26189
|
-
reverse_actions:
|
|
26171
|
+
actions: this._actions,
|
|
26172
|
+
edge_map: this._edge_map,
|
|
26173
|
+
edges: this._edges,
|
|
26174
|
+
named_transitions: this._named_transitions,
|
|
26175
|
+
reverse_actions: this._reverse_actions,
|
|
26190
26176
|
// reverse_action_targets : this._reverse_action_targets,
|
|
26191
26177
|
state: this._state,
|
|
26192
|
-
states:
|
|
26178
|
+
states: this._states
|
|
26193
26179
|
};
|
|
26194
26180
|
}
|
|
26195
26181
|
/*********
|
|
@@ -26210,7 +26196,7 @@ class Machine {
|
|
|
26210
26196
|
*
|
|
26211
26197
|
*/
|
|
26212
26198
|
states() {
|
|
26213
|
-
return [...
|
|
26199
|
+
return [...this._states.keys()];
|
|
26214
26200
|
}
|
|
26215
26201
|
/**
|
|
26216
26202
|
* Get the internal state descriptor for a given state name.
|
|
@@ -26219,7 +26205,7 @@ class Machine {
|
|
|
26219
26205
|
* @throws {JssmError} If the state does not exist.
|
|
26220
26206
|
*/
|
|
26221
26207
|
state_for(whichState) {
|
|
26222
|
-
const state =
|
|
26208
|
+
const state = this._states.get(whichState);
|
|
26223
26209
|
if (state) {
|
|
26224
26210
|
return state;
|
|
26225
26211
|
}
|
|
@@ -26246,7 +26232,7 @@ class Machine {
|
|
|
26246
26232
|
*
|
|
26247
26233
|
*/
|
|
26248
26234
|
has_state(whichState) {
|
|
26249
|
-
return
|
|
26235
|
+
return this._states.has(whichState);
|
|
26250
26236
|
}
|
|
26251
26237
|
/*********
|
|
26252
26238
|
*
|
|
@@ -26284,21 +26270,21 @@ class Machine {
|
|
|
26284
26270
|
*
|
|
26285
26271
|
*/
|
|
26286
26272
|
list_edges() {
|
|
26287
|
-
return
|
|
26273
|
+
return this._edges;
|
|
26288
26274
|
}
|
|
26289
26275
|
/**
|
|
26290
26276
|
* Get the map of named transitions (transitions with explicit names).
|
|
26291
26277
|
* @returns A `Map` from transition name to edge index.
|
|
26292
26278
|
*/
|
|
26293
26279
|
list_named_transitions() {
|
|
26294
|
-
return
|
|
26280
|
+
return this._named_transitions;
|
|
26295
26281
|
}
|
|
26296
26282
|
/**
|
|
26297
26283
|
* List all distinct action names defined anywhere in the machine.
|
|
26298
26284
|
* @returns An array of action name strings.
|
|
26299
26285
|
*/
|
|
26300
26286
|
list_actions() {
|
|
26301
|
-
return [...
|
|
26287
|
+
return [...this._actions.keys()];
|
|
26302
26288
|
}
|
|
26303
26289
|
/**
|
|
26304
26290
|
* Whether any actions are defined on this machine.
|
|
@@ -26306,7 +26292,7 @@ class Machine {
|
|
|
26306
26292
|
*/
|
|
26307
26293
|
get uses_actions() {
|
|
26308
26294
|
// Map.size answers emptiness without materializing the key list
|
|
26309
|
-
return
|
|
26295
|
+
return this._actions.size > 0;
|
|
26310
26296
|
}
|
|
26311
26297
|
/**
|
|
26312
26298
|
* Whether any forced (`~>`) transitions exist in this machine.
|
|
@@ -26472,7 +26458,7 @@ class Machine {
|
|
|
26472
26458
|
* such transition exists.
|
|
26473
26459
|
*/
|
|
26474
26460
|
get_transition_by_state_names(from, to) {
|
|
26475
|
-
const emg =
|
|
26461
|
+
const emg = this._edge_map.get(from);
|
|
26476
26462
|
return emg ? emg.get(to) : undefined;
|
|
26477
26463
|
}
|
|
26478
26464
|
/**
|
|
@@ -26483,7 +26469,7 @@ class Machine {
|
|
|
26483
26469
|
*/
|
|
26484
26470
|
lookup_transition_for(from, to) {
|
|
26485
26471
|
const id = this.get_transition_by_state_names(from, to);
|
|
26486
|
-
return ((id === undefined) || (id === null)) ? undefined :
|
|
26472
|
+
return ((id === undefined) || (id === null)) ? undefined : this._edges[id];
|
|
26487
26473
|
}
|
|
26488
26474
|
/********
|
|
26489
26475
|
*
|
|
@@ -26532,7 +26518,7 @@ class Machine {
|
|
|
26532
26518
|
*/
|
|
26533
26519
|
list_entrances(whichState = this.state()) {
|
|
26534
26520
|
var _a, _b;
|
|
26535
|
-
const guaranteed = ((_a =
|
|
26521
|
+
const guaranteed = ((_a = this._states.get(whichState)) !== null && _a !== void 0 ? _a : { from: undefined });
|
|
26536
26522
|
return (_b = guaranteed.from) !== null && _b !== void 0 ? _b : [];
|
|
26537
26523
|
}
|
|
26538
26524
|
/********
|
|
@@ -26558,7 +26544,7 @@ class Machine {
|
|
|
26558
26544
|
*/
|
|
26559
26545
|
list_exits(whichState = this.state()) {
|
|
26560
26546
|
var _a, _b;
|
|
26561
|
-
const guaranteed = ((_a =
|
|
26547
|
+
const guaranteed = ((_a = this._states.get(whichState)) !== null && _a !== void 0 ? _a : { to: undefined });
|
|
26562
26548
|
return (_b = guaranteed.to) !== null && _b !== void 0 ? _b : [];
|
|
26563
26549
|
}
|
|
26564
26550
|
/**
|
|
@@ -26581,7 +26567,7 @@ class Machine {
|
|
|
26581
26567
|
* @throws {JssmError} If the state does not exist.
|
|
26582
26568
|
*/
|
|
26583
26569
|
probable_exits_for(whichState) {
|
|
26584
|
-
const wstate =
|
|
26570
|
+
const wstate = this._states.get(whichState);
|
|
26585
26571
|
if (!(wstate)) {
|
|
26586
26572
|
throw new JssmError(this, `No such state ${JSON.stringify(whichState)} in probable_exits_for`);
|
|
26587
26573
|
}
|
|
@@ -26594,12 +26580,12 @@ class Machine {
|
|
|
26594
26580
|
// lookup_transition_for. wstate.to is non-empty only when at least one
|
|
26595
26581
|
// outbound edge exists, and every outbound edge creates the from-side
|
|
26596
26582
|
// mapping at construction — so emg is defined whenever the loop runs.
|
|
26597
|
-
const emg =
|
|
26583
|
+
const emg = this._edge_map.get(whichState);
|
|
26598
26584
|
for (const ws of wstate.to) {
|
|
26599
26585
|
// wstate.to is built from the same edge set _edge_map indexes, so the
|
|
26600
26586
|
// per-target get cannot miss; the guard mirrors the old defensive
|
|
26601
26587
|
// .filter(Boolean) and is equally unreachable.
|
|
26602
|
-
const edge =
|
|
26588
|
+
const edge = this._edges[emg.get(ws)];
|
|
26603
26589
|
/* v8 ignore next */
|
|
26604
26590
|
if (!edge) {
|
|
26605
26591
|
continue;
|
|
@@ -26902,7 +26888,7 @@ class Machine {
|
|
|
26902
26888
|
*
|
|
26903
26889
|
*/
|
|
26904
26890
|
actions(whichState = this.state()) {
|
|
26905
|
-
const wstate =
|
|
26891
|
+
const wstate = this._reverse_actions.get(whichState);
|
|
26906
26892
|
if (wstate) {
|
|
26907
26893
|
return [...wstate.keys()];
|
|
26908
26894
|
}
|
|
@@ -26934,7 +26920,7 @@ class Machine {
|
|
|
26934
26920
|
*
|
|
26935
26921
|
*/
|
|
26936
26922
|
list_states_having_action(whichState) {
|
|
26937
|
-
const wstate =
|
|
26923
|
+
const wstate = this._actions.get(whichState);
|
|
26938
26924
|
if (wstate) {
|
|
26939
26925
|
return [...wstate.keys()];
|
|
26940
26926
|
}
|
|
@@ -26967,7 +26953,7 @@ class Machine {
|
|
|
26967
26953
|
* expect(() => m.list_exit_actions('z')).toThrow();
|
|
26968
26954
|
*/
|
|
26969
26955
|
list_exit_actions(whichState = this.state()) {
|
|
26970
|
-
const ra_base =
|
|
26956
|
+
const ra_base = this._reverse_actions.get(whichState);
|
|
26971
26957
|
if (!(ra_base)) {
|
|
26972
26958
|
if (this.has_state(whichState)) {
|
|
26973
26959
|
return [];
|
|
@@ -26986,7 +26972,7 @@ class Machine {
|
|
|
26986
26972
|
* @throws {JssmError} If the state does not exist.
|
|
26987
26973
|
*/
|
|
26988
26974
|
probable_action_exits(whichState = this.state()) {
|
|
26989
|
-
const ra_base =
|
|
26975
|
+
const ra_base = this._reverse_actions.get(whichState);
|
|
26990
26976
|
if (!(ra_base)) {
|
|
26991
26977
|
if (this.has_state(whichState)) {
|
|
26992
26978
|
return [];
|
|
@@ -26999,7 +26985,7 @@ class Machine {
|
|
|
26999
26985
|
ra_base.forEach((edgeId, action) => {
|
|
27000
26986
|
exits.push({
|
|
27001
26987
|
action,
|
|
27002
|
-
probability:
|
|
26988
|
+
probability: this._edges[edgeId].probability
|
|
27003
26989
|
});
|
|
27004
26990
|
});
|
|
27005
26991
|
return exits;
|
|
@@ -27182,7 +27168,7 @@ class Machine {
|
|
|
27182
27168
|
* @throws {JssmError} If the state does not exist.
|
|
27183
27169
|
*/
|
|
27184
27170
|
state_is_complete(whichState) {
|
|
27185
|
-
const wstate =
|
|
27171
|
+
const wstate = this._states.get(whichState);
|
|
27186
27172
|
if (wstate) {
|
|
27187
27173
|
return wstate.complete;
|
|
27188
27174
|
}
|
|
@@ -28003,11 +27989,11 @@ class Machine {
|
|
|
28003
27989
|
if (to_id === undefined) {
|
|
28004
27990
|
return [];
|
|
28005
27991
|
}
|
|
28006
|
-
const outbound = (_a =
|
|
27992
|
+
const outbound = (_a = this._outbound_edge_ids.get(from)) !== null && _a !== void 0 ? _a : [];
|
|
28007
27993
|
const result = [];
|
|
28008
27994
|
for (const edgeId of outbound) {
|
|
28009
27995
|
if (this._edge_to_ids[edgeId] === to_id) {
|
|
28010
|
-
result.push(
|
|
27996
|
+
result.push(this._edges[edgeId]);
|
|
28011
27997
|
}
|
|
28012
27998
|
}
|
|
28013
27999
|
return result;
|
|
@@ -28052,7 +28038,7 @@ class Machine {
|
|
|
28052
28038
|
// data, an explicit `undefined` clears it (StoneCypher/fsl#1264)
|
|
28053
28039
|
const dataProvided = arguments.length >= 2;
|
|
28054
28040
|
if (this.allows_override) {
|
|
28055
|
-
if (
|
|
28041
|
+
if (this._states.has(newState)) {
|
|
28056
28042
|
const fromState = this._state;
|
|
28057
28043
|
const oldData = this._data;
|
|
28058
28044
|
this._state = newState;
|
|
@@ -28180,7 +28166,7 @@ class Machine {
|
|
|
28180
28166
|
const aid = this._action_interner.id_of(newStateOrAction);
|
|
28181
28167
|
const edgeId = (aid === undefined) ? undefined : this._edge_id_by_action_pair.get(pair_key(aid, this._state_id));
|
|
28182
28168
|
if (edgeId !== undefined) {
|
|
28183
|
-
const edge =
|
|
28169
|
+
const edge = this._edges[edgeId];
|
|
28184
28170
|
valid = true;
|
|
28185
28171
|
trans_type = edge.kind;
|
|
28186
28172
|
newState = edge.to;
|
|
@@ -28194,7 +28180,7 @@ class Machine {
|
|
|
28194
28180
|
// be forced_only (truthiness, matching the old refusal exactly)
|
|
28195
28181
|
const to_id = this._state_interner.id_of(newStateOrAction);
|
|
28196
28182
|
const edgeId = (to_id === undefined) ? undefined : this._edge_id_by_pair.get(pair_key(this._state_id, to_id));
|
|
28197
|
-
if ((edgeId !== undefined) && (!(
|
|
28183
|
+
if ((edgeId !== undefined) && (!(this._edges[edgeId].forced_only))) {
|
|
28198
28184
|
if (this._has_transition_hooks || this._has_post_transition_hooks) {
|
|
28199
28185
|
// kind of the dispatched edge. _edge_id_by_pair and _edge_map are
|
|
28200
28186
|
// both first-declared-wins for parallel (from, to) pairs (see the
|
|
@@ -28204,7 +28190,7 @@ class Machine {
|
|
|
28204
28190
|
// Direct read replaces the O(out-degree) object-deref scan; the
|
|
28205
28191
|
// first-declared-kind semantics are pinned by the parallel-edge
|
|
28206
28192
|
// transition-kind hook spec. #735
|
|
28207
|
-
trans_type =
|
|
28193
|
+
trans_type = this._edges[edgeId].kind;
|
|
28208
28194
|
}
|
|
28209
28195
|
valid = true;
|
|
28210
28196
|
newState = newStateOrAction;
|
|
@@ -28361,42 +28347,37 @@ class Machine {
|
|
|
28361
28347
|
}
|
|
28362
28348
|
}
|
|
28363
28349
|
// 7. edge type hook
|
|
28364
|
-
|
|
28365
|
-
|
|
28366
|
-
|
|
28367
|
-
|
|
28368
|
-
|
|
28369
|
-
|
|
28370
|
-
|
|
28371
|
-
|
|
28372
|
-
|
|
28373
|
-
data_changed = true;
|
|
28374
|
-
}
|
|
28375
|
-
break;
|
|
28350
|
+
// 7a. standard transition hook
|
|
28351
|
+
if (trans_type === 'legal') {
|
|
28352
|
+
const outcome = abstract_hook_step(this._standard_transition_hook, hook_args);
|
|
28353
|
+
if (!outcome.pass) {
|
|
28354
|
+
__classPrivateFieldGet(this, _Machine_instances, "m", _Machine_fire_hook_rejection).call(this, 'standard transition', fromState, newState, fromAction, oldData, newData, wasForced);
|
|
28355
|
+
return false;
|
|
28356
|
+
}
|
|
28357
|
+
if (_update_hook_fields(hook_args, outcome)) {
|
|
28358
|
+
data_changed = true;
|
|
28376
28359
|
}
|
|
28377
28360
|
// 7b. main type hook
|
|
28378
|
-
|
|
28379
|
-
|
|
28380
|
-
|
|
28381
|
-
|
|
28382
|
-
|
|
28383
|
-
|
|
28384
|
-
|
|
28385
|
-
|
|
28386
|
-
|
|
28387
|
-
break;
|
|
28361
|
+
}
|
|
28362
|
+
else if (trans_type === 'main') {
|
|
28363
|
+
const outcome = abstract_hook_step(this._main_transition_hook, hook_args);
|
|
28364
|
+
if (!outcome.pass) {
|
|
28365
|
+
__classPrivateFieldGet(this, _Machine_instances, "m", _Machine_fire_hook_rejection).call(this, 'main transition', fromState, newState, fromAction, oldData, newData, wasForced);
|
|
28366
|
+
return false;
|
|
28367
|
+
}
|
|
28368
|
+
if (_update_hook_fields(hook_args, outcome)) {
|
|
28369
|
+
data_changed = true;
|
|
28388
28370
|
}
|
|
28389
28371
|
// 7c. forced transition hook
|
|
28390
|
-
|
|
28391
|
-
|
|
28392
|
-
|
|
28393
|
-
|
|
28394
|
-
|
|
28395
|
-
|
|
28396
|
-
|
|
28397
|
-
|
|
28398
|
-
|
|
28399
|
-
break;
|
|
28372
|
+
}
|
|
28373
|
+
else if (trans_type === 'forced') {
|
|
28374
|
+
const outcome = abstract_hook_step(this._forced_transition_hook, hook_args);
|
|
28375
|
+
if (!outcome.pass) {
|
|
28376
|
+
__classPrivateFieldGet(this, _Machine_instances, "m", _Machine_fire_hook_rejection).call(this, 'forced transition', fromState, newState, fromAction, oldData, newData, wasForced);
|
|
28377
|
+
return false;
|
|
28378
|
+
}
|
|
28379
|
+
if (_update_hook_fields(hook_args, outcome)) {
|
|
28380
|
+
data_changed = true;
|
|
28400
28381
|
}
|
|
28401
28382
|
}
|
|
28402
28383
|
// 8. entry hook
|
|
@@ -28623,7 +28604,7 @@ class Machine {
|
|
|
28623
28604
|
// here, and the public state_is_terminal / state_is_complete pair would
|
|
28624
28605
|
// each redo has_state plus its own map walk. Same predicates:
|
|
28625
28606
|
// terminal = no exits, complete = the constructor-set flag. #735
|
|
28626
|
-
const new_state_rec =
|
|
28607
|
+
const new_state_rec = this._states.get(newState);
|
|
28627
28608
|
if ((new_state_rec.to.length === 0) && __classPrivateFieldGet(this, _Machine_instances, "m", _Machine_has_subscribers).call(this, 'terminal')) {
|
|
28628
28609
|
__classPrivateFieldGet(this, _Machine_instances, "m", _Machine_fire).call(this, 'terminal', { state: newState, data: newData_after });
|
|
28629
28610
|
}
|
|
@@ -29490,7 +29471,7 @@ class Machine {
|
|
|
29490
29471
|
if ((idx === undefined) || (idx === null)) {
|
|
29491
29472
|
throw new JssmError(this, `No such action ${JSON.stringify(action)}`);
|
|
29492
29473
|
}
|
|
29493
|
-
return
|
|
29474
|
+
return this._edges[idx];
|
|
29494
29475
|
}
|
|
29495
29476
|
/**
|
|
29496
29477
|
* Check whether an action is available from the current state.
|
|
@@ -29640,7 +29621,7 @@ class Machine {
|
|
|
29640
29621
|
return sm(template_strings, ...remainder);
|
|
29641
29622
|
}
|
|
29642
29623
|
}
|
|
29643
|
-
|
|
29624
|
+
_Machine_instances = new WeakSet(), _Machine_unsubscribe_entry = function _Machine_unsubscribe_entry(set, entry) {
|
|
29644
29625
|
if (set.delete(entry)) {
|
|
29645
29626
|
this._event_listener_count--;
|
|
29646
29627
|
}
|