jssm 5.159.0 → 5.159.2

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/jssm.cli.d.cts CHANGED
@@ -1,8 +1,20 @@
1
1
  /**
2
- * Render targets supported in v1. Future targets (mermaid, plantuml, scxml,
3
- * ascii, fsl) will be added in v0.2+.
2
+ * The render targets supported in v1, in canonical order (the CLI `--target`
3
+ * enum and `--help` list order). This tuple is the single runtime source of
4
+ * truth: both the {@link RenderTarget} type and the `fsl-render` CLI's
5
+ * `--target` enum derive from it, so a new target is declared in exactly one
6
+ * place. Future targets (mermaid, plantuml, scxml, ascii, fsl) land here in
7
+ * v0.2+.
8
+ *
9
+ * @example
10
+ * RENDER_TARGETS.includes('gif' as RenderTarget); // true
11
+ */
12
+ declare const RENDER_TARGETS: readonly ["svg", "dot", "png", "jpeg", "html", "gif"];
13
+ /**
14
+ * A render target the CLI and library can produce. Derived from
15
+ * {@link RENDER_TARGETS} so the type can never drift from the runtime enum.
4
16
  */
5
- declare type RenderTarget = 'svg' | 'dot' | 'png' | 'jpeg' | 'html' | 'gif';
17
+ declare type RenderTarget = typeof RENDER_TARGETS[number];
6
18
  /**
7
19
  * Options accepted by `render()` and `renderSet()`.
8
20
  *
package/jssm.cli.d.ts CHANGED
@@ -1,8 +1,20 @@
1
1
  /**
2
- * Render targets supported in v1. Future targets (mermaid, plantuml, scxml,
3
- * ascii, fsl) will be added in v0.2+.
2
+ * The render targets supported in v1, in canonical order (the CLI `--target`
3
+ * enum and `--help` list order). This tuple is the single runtime source of
4
+ * truth: both the {@link RenderTarget} type and the `fsl-render` CLI's
5
+ * `--target` enum derive from it, so a new target is declared in exactly one
6
+ * place. Future targets (mermaid, plantuml, scxml, ascii, fsl) land here in
7
+ * v0.2+.
8
+ *
9
+ * @example
10
+ * RENDER_TARGETS.includes('gif' as RenderTarget); // true
11
+ */
12
+ declare const RENDER_TARGETS: readonly ["svg", "dot", "png", "jpeg", "html", "gif"];
13
+ /**
14
+ * A render target the CLI and library can produce. Derived from
15
+ * {@link RENDER_TARGETS} so the type can never drift from the runtime enum.
4
16
  */
5
- declare type RenderTarget = 'svg' | 'dot' | 'png' | 'jpeg' | 'html' | 'gif';
17
+ declare type RenderTarget = typeof RENDER_TARGETS[number];
6
18
  /**
7
19
  * Options accepted by `render()` and `renderSet()`.
8
20
  *
package/jssm.fence.d.ts CHANGED
@@ -156,8 +156,9 @@ interface GifOptions {
156
156
  * @param frames - At least one frame; all with identical width/height and
157
157
  * `rgba.length === 4 · width · height`.
158
158
  *
159
- * @throws {JssmError} on zero frames, mismatched dimensions, or an rgba
160
- * buffer whose length contradicts its stated dimensions.
159
+ * @throws {JssmError} on zero frames, a zero-width or zero-height frame,
160
+ * mismatched dimensions, or an rgba buffer whose length contradicts its
161
+ * stated dimensions.
161
162
  *
162
163
  * @example
163
164
  * const red = { rgba: new Uint8Array([255,0,0,255]), width: 1, height: 1 };
@@ -3888,6 +3888,24 @@ declare function vc(col: string): string;
3888
3888
  * @internal
3889
3889
  */
3890
3890
  declare function doublequote(txt: string): string;
3891
+ /**
3892
+ * Reverse {@link doublequote}: turn DOT's `\"` escape back into the literal
3893
+ * `"` that graphviz renders into SVG `<text>` content. Used by
3894
+ * {@link state_svg_label_texts} to reconstruct a node's on-screen label from
3895
+ * the DOT label it was handed, so the fence renderer keys against exactly what
3896
+ * was drawn.
3897
+ *
3898
+ * ```typescript
3899
+ * undoublequote('a\\"b'); // 'a"b'
3900
+ * undoublequote('safe'); // 'safe'
3901
+ * ```
3902
+ *
3903
+ * @param txt A DOT-escaped attribute string (as produced by `doublequote`).
3904
+ * @returns The string with every `\"` collapsed back to `"`.
3905
+ *
3906
+ * @internal
3907
+ */
3908
+ declare function undoublequote(txt: string): string;
3891
3909
  /**
3892
3910
  * Convert a state name into a URL-friendly slug suitable for use as the
3893
3911
  * body of a dot/SVG node identifier. The transformation is:
@@ -4282,6 +4300,50 @@ declare type VizRenderOpts = {
4282
4300
  * @internal
4283
4301
  */
4284
4302
  declare function node_block_for<T>(u_jssm: Machine<T>, l_states: string[], state_index: Map<string, string>, state_kinds: Map<string, StateKind>, hide_labels: boolean, mode: RenderGroups): string;
4303
+ /**
4304
+ * The per-state group-chip map that {@link node_block_for} appends to labels
4305
+ * in a given render mode. Mirrors that function's mode dispatch and calls the
4306
+ * very same chip sources — {@link chips_for_all_groups} for `'chips'`,
4307
+ * {@link plan_cluster_groups} (with identical inputs) for `'cluster'` — so a
4308
+ * reconstructed label can never disagree with the one graphviz was handed.
4309
+ * `'off'`, and any machine that declares no groups, yields an empty map.
4310
+ *
4311
+ * @internal
4312
+ */
4313
+ declare function chips_for_render_mode<T>(u_jssm: Machine<T>, l_states: string[], mode: RenderGroups): Map<string, string[]>;
4314
+ /**
4315
+ * The exact text graphviz places in each state's SVG `<text>` element(s) when
4316
+ * a machine is rendered via {@link machine_to_dot} / {@link fsl_to_svg_string}:
4317
+ * the state's display text plus any group chips the node builder appends, with
4318
+ * DOT's `\"` escaping undone (SVG carries the literal character). A label that
4319
+ * wraps across lines becomes several `<text>` elements; this returns the lines
4320
+ * joined by `\n`, exactly how {@link extract_state_fills} reads them back — so
4321
+ * the derived key and the extracted key meet at the same string.
4322
+ *
4323
+ * This is the single source of truth the static fence renderer keys its
4324
+ * highlight and recolor lookups against, so those lookups can never drift from
4325
+ * what was actually drawn — plain labels, group chips, and multi-line wraps
4326
+ * alike. It is built by running the node builder's own
4327
+ * `label_with_chips(doublequote(display_text), chips)` and inverting the one
4328
+ * escaping step, so it follows any change to the label format for free.
4329
+ *
4330
+ * @param u_jssm The machine being rendered.
4331
+ * @param opts Render flags; only `render_groups` affects the label text
4332
+ * (default `'cluster'`, matching `fsl_to_svg_string`).
4333
+ * @returns A map from each state name to its rendered SVG label text.
4334
+ *
4335
+ * ```typescript
4336
+ * import { sm } from 'jssm';
4337
+ * import { state_svg_label_texts } from 'jssm/viz';
4338
+ *
4339
+ * // a state in two groups renders a chip suffix in its node label
4340
+ * state_svg_label_texts(sm`&g1 : [a b]; &g2 : [a]; a -> b;`).get('a'); // 'a [g1]'
4341
+ * state_svg_label_texts(sm`a -> b;`).get('a'); // 'a'
4342
+ * ```
4343
+ *
4344
+ * @see extract_state_fills
4345
+ */
4346
+ declare function state_svg_label_texts<T>(u_jssm: Machine<T>, opts?: VizRenderOpts): Map<string, string>;
4285
4347
  /**
4286
4348
  * Render a {@link jssm.Machine} as a graphviz dot string.
4287
4349
  *
@@ -4416,6 +4478,7 @@ declare const _test: {
4416
4478
  style_for_state: typeof style_for_state;
4417
4479
  cluster_id_for: typeof cluster_id_for;
4418
4480
  label_with_chips: typeof label_with_chips;
4481
+ undoublequote: typeof undoublequote;
4419
4482
  group_parent_map: typeof group_parent_map;
4420
4483
  group_ancestry: typeof group_ancestry;
4421
4484
  primary_group_for: typeof primary_group_for;
@@ -4423,6 +4486,7 @@ declare const _test: {
4423
4486
  groups_to_subgraph_string: typeof groups_to_subgraph_string;
4424
4487
  chips_for_all_groups: typeof chips_for_all_groups;
4425
4488
  node_block_for: typeof node_block_for;
4489
+ chips_for_render_mode: typeof chips_for_render_mode;
4426
4490
  edge_attr_for: typeof edge_attr_for;
4427
4491
  edge_defaults_body: typeof edge_defaults_body;
4428
4492
  graph_attr_for: typeof graph_attr_for;
@@ -4430,5 +4494,5 @@ declare const _test: {
4430
4494
  graph_bg_color_from_config: typeof graph_bg_color_from_config;
4431
4495
  };
4432
4496
 
4433
- export { _test, build_time, configure, dot, dot_to_svg, fsl_to_dot, fsl_to_svg_element, fsl_to_svg_string, machine_to_dot, machine_to_svg_element, machine_to_svg_string, version };
4497
+ export { _test, build_time, configure, dot, dot_to_svg, fsl_to_dot, fsl_to_svg_element, fsl_to_svg_string, machine_to_dot, machine_to_svg_element, machine_to_svg_string, state_svg_label_texts, version };
4434
4498
  export type { RenderGroups, VizRenderOpts };
package/jssm_viz.es6.d.ts CHANGED
@@ -3888,6 +3888,24 @@ declare function vc(col: string): string;
3888
3888
  * @internal
3889
3889
  */
3890
3890
  declare function doublequote(txt: string): string;
3891
+ /**
3892
+ * Reverse {@link doublequote}: turn DOT's `\"` escape back into the literal
3893
+ * `"` that graphviz renders into SVG `<text>` content. Used by
3894
+ * {@link state_svg_label_texts} to reconstruct a node's on-screen label from
3895
+ * the DOT label it was handed, so the fence renderer keys against exactly what
3896
+ * was drawn.
3897
+ *
3898
+ * ```typescript
3899
+ * undoublequote('a\\"b'); // 'a"b'
3900
+ * undoublequote('safe'); // 'safe'
3901
+ * ```
3902
+ *
3903
+ * @param txt A DOT-escaped attribute string (as produced by `doublequote`).
3904
+ * @returns The string with every `\"` collapsed back to `"`.
3905
+ *
3906
+ * @internal
3907
+ */
3908
+ declare function undoublequote(txt: string): string;
3891
3909
  /**
3892
3910
  * Convert a state name into a URL-friendly slug suitable for use as the
3893
3911
  * body of a dot/SVG node identifier. The transformation is:
@@ -4282,6 +4300,50 @@ declare type VizRenderOpts = {
4282
4300
  * @internal
4283
4301
  */
4284
4302
  declare function node_block_for<T>(u_jssm: Machine<T>, l_states: string[], state_index: Map<string, string>, state_kinds: Map<string, StateKind>, hide_labels: boolean, mode: RenderGroups): string;
4303
+ /**
4304
+ * The per-state group-chip map that {@link node_block_for} appends to labels
4305
+ * in a given render mode. Mirrors that function's mode dispatch and calls the
4306
+ * very same chip sources — {@link chips_for_all_groups} for `'chips'`,
4307
+ * {@link plan_cluster_groups} (with identical inputs) for `'cluster'` — so a
4308
+ * reconstructed label can never disagree with the one graphviz was handed.
4309
+ * `'off'`, and any machine that declares no groups, yields an empty map.
4310
+ *
4311
+ * @internal
4312
+ */
4313
+ declare function chips_for_render_mode<T>(u_jssm: Machine<T>, l_states: string[], mode: RenderGroups): Map<string, string[]>;
4314
+ /**
4315
+ * The exact text graphviz places in each state's SVG `<text>` element(s) when
4316
+ * a machine is rendered via {@link machine_to_dot} / {@link fsl_to_svg_string}:
4317
+ * the state's display text plus any group chips the node builder appends, with
4318
+ * DOT's `\"` escaping undone (SVG carries the literal character). A label that
4319
+ * wraps across lines becomes several `<text>` elements; this returns the lines
4320
+ * joined by `\n`, exactly how {@link extract_state_fills} reads them back — so
4321
+ * the derived key and the extracted key meet at the same string.
4322
+ *
4323
+ * This is the single source of truth the static fence renderer keys its
4324
+ * highlight and recolor lookups against, so those lookups can never drift from
4325
+ * what was actually drawn — plain labels, group chips, and multi-line wraps
4326
+ * alike. It is built by running the node builder's own
4327
+ * `label_with_chips(doublequote(display_text), chips)` and inverting the one
4328
+ * escaping step, so it follows any change to the label format for free.
4329
+ *
4330
+ * @param u_jssm The machine being rendered.
4331
+ * @param opts Render flags; only `render_groups` affects the label text
4332
+ * (default `'cluster'`, matching `fsl_to_svg_string`).
4333
+ * @returns A map from each state name to its rendered SVG label text.
4334
+ *
4335
+ * ```typescript
4336
+ * import { sm } from 'jssm';
4337
+ * import { state_svg_label_texts } from 'jssm/viz';
4338
+ *
4339
+ * // a state in two groups renders a chip suffix in its node label
4340
+ * state_svg_label_texts(sm`&g1 : [a b]; &g2 : [a]; a -> b;`).get('a'); // 'a [g1]'
4341
+ * state_svg_label_texts(sm`a -> b;`).get('a'); // 'a'
4342
+ * ```
4343
+ *
4344
+ * @see extract_state_fills
4345
+ */
4346
+ declare function state_svg_label_texts<T>(u_jssm: Machine<T>, opts?: VizRenderOpts): Map<string, string>;
4285
4347
  /**
4286
4348
  * Render a {@link jssm.Machine} as a graphviz dot string.
4287
4349
  *
@@ -4416,6 +4478,7 @@ declare const _test: {
4416
4478
  style_for_state: typeof style_for_state;
4417
4479
  cluster_id_for: typeof cluster_id_for;
4418
4480
  label_with_chips: typeof label_with_chips;
4481
+ undoublequote: typeof undoublequote;
4419
4482
  group_parent_map: typeof group_parent_map;
4420
4483
  group_ancestry: typeof group_ancestry;
4421
4484
  primary_group_for: typeof primary_group_for;
@@ -4423,6 +4486,7 @@ declare const _test: {
4423
4486
  groups_to_subgraph_string: typeof groups_to_subgraph_string;
4424
4487
  chips_for_all_groups: typeof chips_for_all_groups;
4425
4488
  node_block_for: typeof node_block_for;
4489
+ chips_for_render_mode: typeof chips_for_render_mode;
4426
4490
  edge_attr_for: typeof edge_attr_for;
4427
4491
  edge_defaults_body: typeof edge_defaults_body;
4428
4492
  graph_attr_for: typeof graph_attr_for;
@@ -4430,5 +4494,5 @@ declare const _test: {
4430
4494
  graph_bg_color_from_config: typeof graph_bg_color_from_config;
4431
4495
  };
4432
4496
 
4433
- export { _test, build_time, configure, dot, dot_to_svg, fsl_to_dot, fsl_to_svg_element, fsl_to_svg_string, machine_to_dot, machine_to_svg_element, machine_to_svg_string, version };
4497
+ export { _test, build_time, configure, dot, dot_to_svg, fsl_to_dot, fsl_to_svg_element, fsl_to_svg_string, machine_to_dot, machine_to_svg_element, machine_to_svg_string, state_svg_label_texts, version };
4434
4498
  export type { RenderGroups, VizRenderOpts };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jssm",
3
- "version": "5.159.0",
3
+ "version": "5.159.2",
4
4
  "engines": {
5
5
  "node": ">=10.0.0"
6
6
  },
@@ -352,8 +352,12 @@
352
352
  "reduce-to-639-1": "^1.1.0"
353
353
  },
354
354
  "peerDependencies": {
355
+ "@codemirror/autocomplete": ">=6",
356
+ "@codemirror/commands": ">=6",
355
357
  "@codemirror/language": ">=6",
358
+ "@codemirror/lint": ">=6",
356
359
  "@codemirror/state": ">=6",
360
+ "@codemirror/view": ">=6 <6.43.3 || >6.43.4",
357
361
  "@lezer/highlight": ">=1",
358
362
  "lit": ">=3"
359
363
  },
@@ -361,13 +365,22 @@
361
365
  "lit": {
362
366
  "optional": true
363
367
  },
368
+ "@codemirror/autocomplete": {
369
+ "optional": true
370
+ },
371
+ "@codemirror/commands": {
372
+ "optional": true
373
+ },
364
374
  "@codemirror/language": {
365
375
  "optional": true
366
376
  },
377
+ "@codemirror/lint": {
378
+ "optional": true
379
+ },
367
380
  "@codemirror/state": {
368
381
  "optional": true
369
382
  },
370
- "@lezer/highlight": {
383
+ "@codemirror/view": {
371
384
  "optional": true
372
385
  }
373
386
  },