jssm 5.139.0 → 5.141.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 +7 -7
- package/custom-elements.json +232 -6
- package/dist/cdn/instance.js +235 -33
- package/dist/cdn/viz.js +145 -5
- package/dist/cli/fsl-render.cjs +1 -1
- package/dist/cli/fsl.cjs +1 -1
- package/dist/deno/README.md +7 -7
- package/dist/deno/jssm.js +1 -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/instance.js +234 -32
- package/dist/wc/viz.define.js +3 -3
- package/dist/wc/viz.js +132 -2
- package/package.json +1 -1
package/dist/cdn/viz.js
CHANGED
|
@@ -21352,7 +21352,7 @@ var constants = /*#__PURE__*/Object.freeze({
|
|
|
21352
21352
|
* Useful for runtime diagnostics and for embedding in serialized machine
|
|
21353
21353
|
* snapshots so that deserializers can detect version-skew.
|
|
21354
21354
|
*/
|
|
21355
|
-
const version = "5.
|
|
21355
|
+
const version = "5.141.0";
|
|
21356
21356
|
|
|
21357
21357
|
// whargarbl lots of these return arrays could/should be sets
|
|
21358
21358
|
const { state_name_chars, state_name_first_chars, action_label_chars } = constants;
|
|
@@ -25705,6 +25705,16 @@ async function dot_to_svg(dot, options) {
|
|
|
25705
25705
|
async function fsl_to_svg_string(fsl, opts = {}) {
|
|
25706
25706
|
return dot_to_svg(fsl_to_dot(fsl, opts), opts);
|
|
25707
25707
|
}
|
|
25708
|
+
/**
|
|
25709
|
+
* Render a {@link jssm.Machine} to SVG.
|
|
25710
|
+
*
|
|
25711
|
+
* @param u_jssm The machine to render.
|
|
25712
|
+
* @param opts Optional render flags. See {@link VizRenderOpts}.
|
|
25713
|
+
* @returns A promise resolving to an SVG XML string.
|
|
25714
|
+
*/
|
|
25715
|
+
async function machine_to_svg_string(u_jssm, opts = {}) {
|
|
25716
|
+
return dot_to_svg(machine_to_dot(u_jssm, opts));
|
|
25717
|
+
}
|
|
25708
25718
|
|
|
25709
25719
|
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
25710
25720
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -25746,6 +25756,17 @@ function normalize_viz_error(e) {
|
|
|
25746
25756
|
/**
|
|
25747
25757
|
* Web component that renders a jssm machine as inline SVG.
|
|
25748
25758
|
*
|
|
25759
|
+
* Two operating modes:
|
|
25760
|
+
*
|
|
25761
|
+
* 1. **Standalone** (no parent `<jssm-instance>` ancestor): render from
|
|
25762
|
+
* the element's own `fsl=""` attribute / property. Re-renders on
|
|
25763
|
+
* attribute change.
|
|
25764
|
+
* 2. **Nested** (inside a `<jssm-instance>` ancestor, found via
|
|
25765
|
+
* `closest('jssm-instance')` at `connectedCallback`): bind to the
|
|
25766
|
+
* parent's machine and re-render on every `transition` event. The
|
|
25767
|
+
* element's own `fsl` attribute is ignored in this mode; supplying it
|
|
25768
|
+
* emits a `console.warn` for developer feedback.
|
|
25769
|
+
*
|
|
25749
25770
|
* @element jssm-viz
|
|
25750
25771
|
* @cssproperty [--jssm-viz-min-height=100px] - Minimum height of the rendered SVG container.
|
|
25751
25772
|
* @fires {CustomEvent<{ message: string; location?: unknown }>} viz-error - Fires when the FSL source fails to parse or render.
|
|
@@ -25758,18 +25779,137 @@ class JssmViz extends i$1 {
|
|
|
25758
25779
|
/** Optional Graphviz layout engine override (e.g. 'dot', 'neato'). */
|
|
25759
25780
|
this.engine = undefined;
|
|
25760
25781
|
this._svg = '';
|
|
25782
|
+
/**
|
|
25783
|
+
* Parent `<jssm-instance>` host reference, set in `connectedCallback`
|
|
25784
|
+
* when a parent is found. When non-null the viz is in nested mode and
|
|
25785
|
+
* renders the parent's machine instead of its own `fsl` attribute.
|
|
25786
|
+
*/
|
|
25787
|
+
this._parent_host = null;
|
|
25788
|
+
/**
|
|
25789
|
+
* Unsubscribe callback returned from `host.machine.on('transition', ...)`.
|
|
25790
|
+
* Held so `disconnectedCallback` can release the subscription.
|
|
25791
|
+
*/
|
|
25792
|
+
this._parent_sub = null;
|
|
25761
25793
|
}
|
|
25762
25794
|
/**
|
|
25763
25795
|
* Lit lifecycle hook. Triggers an async SVG render whenever `fsl` or
|
|
25764
|
-
* `engine` change.
|
|
25796
|
+
* `engine` change — but only in standalone mode. In nested mode the
|
|
25797
|
+
* `fsl` attribute is ignored; renders are driven by the parent machine's
|
|
25798
|
+
* transition events instead.
|
|
25765
25799
|
*
|
|
25766
25800
|
* @param changed - Map of changed reactive properties supplied by Lit.
|
|
25767
25801
|
*/
|
|
25768
25802
|
willUpdate(changed) {
|
|
25803
|
+
if (this._parent_host !== null) {
|
|
25804
|
+
// Nested mode: ignore `fsl` attr changes; renders come from the
|
|
25805
|
+
// parent's transition events. `engine` changes still re-render
|
|
25806
|
+
// because they apply to whichever source is in use.
|
|
25807
|
+
if (changed.has('engine')) {
|
|
25808
|
+
this._rerenderFromHostMachine();
|
|
25809
|
+
}
|
|
25810
|
+
return;
|
|
25811
|
+
}
|
|
25769
25812
|
if (changed.has('fsl') || changed.has('engine')) {
|
|
25770
25813
|
this._renderSvg();
|
|
25771
25814
|
}
|
|
25772
25815
|
}
|
|
25816
|
+
/**
|
|
25817
|
+
* Web Components lifecycle hook. Walks up to find a parent
|
|
25818
|
+
* `<jssm-instance>` ancestor; if found, switches into nested mode and
|
|
25819
|
+
* subscribes to the parent machine's `transition` events. Otherwise
|
|
25820
|
+
* leaves standalone behavior intact.
|
|
25821
|
+
*
|
|
25822
|
+
* Subscription setup is deferred via `customElements.whenDefined` so the
|
|
25823
|
+
* parent has had a chance to upgrade and construct its machine before
|
|
25824
|
+
* we touch `host.machine`.
|
|
25825
|
+
*/
|
|
25826
|
+
connectedCallback() {
|
|
25827
|
+
super.connectedCallback();
|
|
25828
|
+
const host = this.closest('jssm-instance');
|
|
25829
|
+
if (host === null) {
|
|
25830
|
+
return; // standalone: existing behavior, willUpdate handles render
|
|
25831
|
+
}
|
|
25832
|
+
// Conflicting-configuration feedback: nested viz with its own `fsl`
|
|
25833
|
+
// attribute is almost certainly a bug. Warn but proceed — the parent
|
|
25834
|
+
// owns the machine.
|
|
25835
|
+
if (typeof this.fsl === 'string' && this.fsl.trim().length > 0) {
|
|
25836
|
+
// eslint-disable-next-line no-console
|
|
25837
|
+
console.warn('<jssm-viz>: `fsl` ignored when nested inside <jssm-instance>; parent owns the machine');
|
|
25838
|
+
}
|
|
25839
|
+
this._parent_host = host;
|
|
25840
|
+
// Defer to whenDefined so a not-yet-upgraded host has its machine
|
|
25841
|
+
// available before we access `host.machine` (which throws when called
|
|
25842
|
+
// pre-connection).
|
|
25843
|
+
void customElements.whenDefined('jssm-instance').then(() => {
|
|
25844
|
+
// Re-check the host is still attached and the viz still belongs to
|
|
25845
|
+
// it — disconnection between the deferred resolution and now is
|
|
25846
|
+
// legal and should not error.
|
|
25847
|
+
if (this._parent_host !== host) {
|
|
25848
|
+
return;
|
|
25849
|
+
}
|
|
25850
|
+
try {
|
|
25851
|
+
this._parent_sub = host.machine.on('transition', () => {
|
|
25852
|
+
this._rerenderFromHostMachine();
|
|
25853
|
+
});
|
|
25854
|
+
}
|
|
25855
|
+
catch (e) {
|
|
25856
|
+
// The parent existed but its machine wasn't ready / threw. Emit
|
|
25857
|
+
// a viz-error so the consumer learns about it instead of silently
|
|
25858
|
+
// showing nothing.
|
|
25859
|
+
this.dispatchEvent(new CustomEvent('viz-error', {
|
|
25860
|
+
detail: normalize_viz_error(e),
|
|
25861
|
+
bubbles: true,
|
|
25862
|
+
composed: true,
|
|
25863
|
+
}));
|
|
25864
|
+
return;
|
|
25865
|
+
}
|
|
25866
|
+
this._rerenderFromHostMachine();
|
|
25867
|
+
});
|
|
25868
|
+
}
|
|
25869
|
+
/**
|
|
25870
|
+
* Web Components lifecycle hook. Releases any installed
|
|
25871
|
+
* parent-transition subscription and clears the host reference so a
|
|
25872
|
+
* subsequent re-attach goes through the full `connectedCallback` path
|
|
25873
|
+
* again.
|
|
25874
|
+
*/
|
|
25875
|
+
disconnectedCallback() {
|
|
25876
|
+
super.disconnectedCallback();
|
|
25877
|
+
if (this._parent_sub !== null) {
|
|
25878
|
+
this._parent_sub();
|
|
25879
|
+
this._parent_sub = null;
|
|
25880
|
+
}
|
|
25881
|
+
this._parent_host = null;
|
|
25882
|
+
}
|
|
25883
|
+
/**
|
|
25884
|
+
* Nested-mode render path. Renders the bound parent's machine via the
|
|
25885
|
+
* {@link machine_to_svg_string} pipeline and commits the result to
|
|
25886
|
+
* `_svg`. On failure emits a `viz-error` `CustomEvent` and clears the
|
|
25887
|
+
* SVG.
|
|
25888
|
+
*
|
|
25889
|
+
* @returns A promise that resolves once the render attempt has finished.
|
|
25890
|
+
*/
|
|
25891
|
+
async _rerenderFromHostMachine() {
|
|
25892
|
+
const host = this._parent_host;
|
|
25893
|
+
if (host === null) {
|
|
25894
|
+
return;
|
|
25895
|
+
}
|
|
25896
|
+
try {
|
|
25897
|
+
const m = host.machine;
|
|
25898
|
+
const result = await machine_to_svg_string(m, this.engine ? { engine: this.engine } : undefined);
|
|
25899
|
+
// Guard against the parent disappearing mid-render.
|
|
25900
|
+
if (this._parent_host === host) {
|
|
25901
|
+
this._svg = result;
|
|
25902
|
+
}
|
|
25903
|
+
}
|
|
25904
|
+
catch (e) {
|
|
25905
|
+
this._svg = '';
|
|
25906
|
+
this.dispatchEvent(new CustomEvent('viz-error', {
|
|
25907
|
+
detail: normalize_viz_error(e),
|
|
25908
|
+
bubbles: true,
|
|
25909
|
+
composed: true,
|
|
25910
|
+
}));
|
|
25911
|
+
}
|
|
25912
|
+
}
|
|
25773
25913
|
/**
|
|
25774
25914
|
* Render the current `fsl` source to an SVG string via the headless
|
|
25775
25915
|
* `fsl_to_svg_string` pipeline. Updates `_svg` on success; emits a
|
|
@@ -25843,9 +25983,9 @@ __decorate([
|
|
|
25843
25983
|
*
|
|
25844
25984
|
* Both tags render identically; `<fsl-viz>` is provided as an alternative
|
|
25845
25985
|
* spelling for users whose mental model is "FSL viz" rather than "jssm
|
|
25846
|
-
* viz".
|
|
25847
|
-
*
|
|
25848
|
-
*
|
|
25986
|
+
* viz". Parent-context binding for both tags lives on the shared
|
|
25987
|
+
* `JssmViz` base class (see {@link JssmViz}); the synonym inherits it
|
|
25988
|
+
* automatically.
|
|
25849
25989
|
*/
|
|
25850
25990
|
class FslViz extends JssmViz {
|
|
25851
25991
|
}
|