@tinyactors/scxmljs 0.1.0 → 0.2.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.
Files changed (51) hide show
  1. package/README.md +11 -4
  2. package/dist/explorer/element.d.ts +5 -3
  3. package/dist/explorer/element.js +523 -262
  4. package/dist/explorer/element.js.map +1 -1
  5. package/dist/explorer/strings.d.ts +41 -23
  6. package/dist/explorer/strings.js +24 -15
  7. package/dist/explorer/strings.js.map +1 -1
  8. package/dist/explorer/styles.d.ts +9 -1
  9. package/dist/explorer/styles.js +291 -150
  10. package/dist/explorer/styles.js.map +1 -1
  11. package/dist/explorer.d.ts +1 -0
  12. package/dist/index.d.ts +1 -0
  13. package/dist/model.d.ts +4 -1
  14. package/dist/model.js +7 -1
  15. package/dist/model.js.map +1 -1
  16. package/dist/session.d.ts +22 -9
  17. package/dist/session.js +53 -13
  18. package/dist/session.js.map +1 -1
  19. package/dist/themes/tinyactors.css +1 -0
  20. package/dist/trusted.d.ts +1 -0
  21. package/dist/ui/icons.d.ts +31 -0
  22. package/dist/ui/icons.js +186 -0
  23. package/dist/ui/icons.js.map +1 -0
  24. package/dist/ui/notation.d.ts +53 -0
  25. package/dist/ui/notation.js +117 -0
  26. package/dist/ui/notation.js.map +1 -0
  27. package/dist/ui/svg.d.ts +4 -0
  28. package/dist/ui/svg.js +26 -0
  29. package/dist/ui/svg.js.map +1 -1
  30. package/dist/ui/theme.d.ts +1 -1
  31. package/dist/ui/theme.js +6 -0
  32. package/dist/ui/theme.js.map +1 -1
  33. package/dist/view/describe.d.ts +17 -0
  34. package/dist/view/describe.js +49 -0
  35. package/dist/view/describe.js.map +1 -0
  36. package/dist/view/element.d.ts +39 -9
  37. package/dist/view/element.js +723 -86
  38. package/dist/view/element.js.map +1 -1
  39. package/dist/view/layout.d.ts +20 -0
  40. package/dist/view/layout.js +205 -29
  41. package/dist/view/layout.js.map +1 -1
  42. package/dist/view/strings.d.ts +34 -8
  43. package/dist/view/strings.js +19 -6
  44. package/dist/view/strings.js.map +1 -1
  45. package/dist/view/styles.d.ts +1 -1
  46. package/dist/view/styles.js +107 -21
  47. package/dist/view/styles.js.map +1 -1
  48. package/dist/view.d.ts +8 -4
  49. package/dist/view.js +6 -3
  50. package/dist/view.js.map +1 -1
  51. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"theme.js","sourceRoot":"","sources":["../../src/ui/theme.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,gHAAgH;AAChH,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAC;AAEhC,MAAM,CAAC,MAAM,SAAS,GAAG,SAAS,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8ElC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,GAAW;IACnC,MAAM,IAAI,GAAG,IAAI,OAAO,EAAuC,CAAC;IAChE,OAAO,GAAG,EAAE;QACV,IAAI,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QACpC,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,KAAK,GAAG,IAAI,aAAa,EAAE,CAAC;YAC5B,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;YACvB,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;QACjC,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;AACJ,CAAC;AAED,gGAAgG;AAChG,MAAM,CAAC,MAAM,UAAU,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC;AAE/C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,cAAc,GAAwC;IACjE,CAAC,YAAY,EAAE,YAAY,EAAE,GAAG,CAAC;IACjC,CAAC,YAAY,EAAE,iBAAiB,EAAE,GAAG,CAAC;IACtC,CAAC,kBAAkB,EAAE,iB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AC,CAAC,CAAC,CAAC,CAAC,CAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAE,CAAC;IAClD,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["/**\n * Shared theme for the scxmljs custom elements (`<scxml-explorer>`, and\n * `<scxml-view>` once it moves into the package).\n *\n * Theming contract: every visual decision reads a public `--scxml-*` custom\n * property (set them on `scxml-explorer`, or anywhere above it). Unset ones\n * fall back to the neutral default theme below, which follows the page's\n * light/dark preference via `light-dark()` and `color-scheme`. Internally the\n * shadow DOM uses short private aliases (`--x-*`); they are not part of the API.\n *\n * No fonts are loaded: the defaults are system font stacks.\n */\n/** One breakpoint for every element: at or below this width (px) the elements switch to their narrow layout. */\nexport const NARROW_WIDTH = 760;\n\nexport const THEME_CSS = /* css */ `\n:host {\n /* follow the page: while --scxml-color-scheme is unset this is invalid, so color-scheme\n inherits and light-dark() below matches the page. Set it to \"light dark\" to follow the OS. */\n color-scheme: var(--scxml-color-scheme);\n /* text */\n --x-fg1: var(--scxml-fg, light-dark(#1c1c21, #ececf1));\n --x-fg2: var(--scxml-fg-muted, light-dark(#484852, #bcbcc6));\n --x-fg3: var(--scxml-fg-subtle, light-dark(#6a6a75, #90909b));\n --x-fg4: var(--scxml-fg-faint, light-dark(#85858f, #777781)); /* graphics only (≥3:1), never text */\n /* surfaces */\n --x-bg: var(--scxml-bg, light-dark(#f6f6f8, #141417));\n --x-s1: var(--scxml-surface, light-dark(#ffffff, #1c1c20));\n --x-s2: var(--scxml-surface-2, light-dark(#f0f0f3, #242429));\n --x-s3: var(--scxml-surface-3, light-dark(#e5e5ea, #2e2e34));\n /* lines */\n --x-b1: var(--scxml-border, light-dark(#e6e6eb, #2a2a30));\n --x-b2: var(--scxml-border-2, light-dark(#d3d3da, #393940));\n --x-strong: var(--scxml-border-strong, light-dark(#8b8b96, #6c6c77));\n /* the one accent */\n --x-accent: var(--scxml-accent, light-dark(#3d5bd9, #8fa3ff));\n --x-accent-fg: var(--scxml-accent-text, light-dark(#2f49b8, #aebcff));\n --x-accent-subtle: var(--scxml-accent-subtle, light-dark(#e9edfc, #252c4c));\n --x-on-accent: var(--scxml-on-accent, light-dark(#ffffff, #10132b));\n /* lifecycle */\n --x-run: var(--scxml-running, light-dark(#26733a, #6fd48a));\n --x-run-bg: var(--scxml-running-bg, light-dark(#e5f3e9, #1a3123));\n --x-wait: var(--scxml-waiting, light-dark(#a8560a, #ffb46b));\n --x-wait-bg: var(--scxml-waiting-bg, light-dark(#fdf0e1, #382815));\n --x-done: var(--scxml-done, light-dark(#48566b, #a7b5c9));\n --x-done-bg: var(--scxml-done-bg, light-dark(#e9edf3, #242b35));\n --x-err: var(--scxml-error, light-dark(#c2332f, #ff8a84));\n /* type */\n --x-sans: var(--scxml-font-sans, system-ui, -apple-system, \"Segoe UI\", Roboto, sans-serif);\n --x-mono: var(--scxml-font-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);\n --x-serif: var(--scxml-font-display, var(--x-sans));\n --x-display-weight: var(--scxml-display-weight, 600);\n /* shape and motion */\n --x-r: var(--scxml-radius, 4px);\n --x-dur: var(--scxml-duration, 140ms);\n --x-row: var(--scxml-row-height, 30px);\n color: var(--x-fg1); font: 400 13px/1.4 var(--x-sans);\n}\n* { box-sizing: border-box; }\nbutton { font: inherit; color: inherit; }\n:focus-visible { outline: 2px solid var(--x-accent); outline-offset: 1px; }\n\n/* ── primitives shared by the elements ─────────────────── */\n.search { display: flex; gap: 6px; padding: 0 12px 8px; flex: none; }\n.search input[type=\"search\"] {\n flex: 1; min-width: 0; height: 28px; padding: 0 8px; font: 12px var(--x-mono); color: var(--x-fg1);\n background: var(--x-s1); border: 1px solid var(--x-b2); border-radius: var(--x-r);\n}\n.search input[type=\"search\"]:focus { border-color: var(--x-accent); }\n.toggle { display: inline-flex; align-items: center; gap: 4px; font: 11px var(--x-sans); color: var(--x-fg3); white-space: nowrap; cursor: pointer; }\n.badge { display: inline-block; font: 500 10px/1 var(--x-mono); letter-spacing: .06em; text-transform: uppercase; padding: 3px 5px; border-radius: var(--x-r); white-space: nowrap; }\n.badge.run { color: var(--x-run); background: var(--x-run-bg); }\n.badge.wait { color: var(--x-wait); background: var(--x-wait-bg); }\n.badge.done { color: var(--x-done); background: var(--x-done-bg); }\n.badge.muted { color: var(--x-fg3); background: var(--x-s2); }\n.count { font: 500 11px var(--x-mono); color: var(--x-fg3); font-variant-numeric: tabular-nums; }\n.chip {\n display: inline-flex; align-items: center; gap: 4px; max-width: 100%; border: 1px solid var(--x-b2); background: var(--x-s1);\n border-radius: 999px; padding: 2px 8px; font: 11.5px/1.4 var(--x-mono); color: var(--x-accent-fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;\n}\n.chip:hover { border-color: var(--x-accent); background: var(--x-accent-subtle); }\n.chip.muted { color: var(--x-fg3); cursor: default; }\n.chip.muted:hover { border-color: var(--x-b2); background: var(--x-s1); }\n.more { border: 0; background: none; padding: 2px 4px; font: 500 11px var(--x-mono); color: var(--x-fg3); cursor: pointer; }\n.more:hover { color: var(--x-accent-fg); }\n.kind { display: inline-grid; place-items: center; width: 16px; height: 16px; flex: none; font: 11px/1 var(--x-mono); color: var(--x-fg3); }\n.empty { color: var(--x-fg3); padding: 16px 12px; font-style: italic; }\nh2.title { font: var(--x-display-weight) 24px/1.15 var(--x-serif); letter-spacing: -.01em; margin: 6px 0 2px; }\n.subtitle { color: var(--x-fg3); font: 12px var(--x-sans); margin: 0 0 14px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }\n.section-title { display: flex; align-items: center; gap: 8px; margin: 18px 0 8px; font: 500 10.5px var(--x-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--x-fg3); }\n.section-title::after { content: \"\"; flex: 1; border-top: 1px solid var(--x-b1); }\n\n@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }\n`;\n\n/**\n * A constructable stylesheet, created on first use (so modules can be\n * imported where there is no DOM) and shared by every shadow root that\n * adopts it (browsers share the parsed sheet). One per realm: a sheet can\n * only be adopted by documents of the realm whose `CSSStyleSheet` made it.\n */\nexport function lazySheet(css: string): () => CSSStyleSheet {\n const made = new WeakMap<typeof CSSStyleSheet, CSSStyleSheet>();\n return () => {\n let sheet = made.get(CSSStyleSheet);\n if (!sheet) {\n sheet = new CSSStyleSheet();\n sheet.replaceSync(css);\n made.set(CSSStyleSheet, sheet);\n }\n return sheet;\n };\n}\n\n/** The shared theme as one constructable stylesheet, adopted by every element's shadow root. */\nexport const themeSheet = lazySheet(THEME_CSS);\n\n/**\n * Colour pairs every theme must keep readable, as public token names:\n * [foreground, background, minimum WCAG contrast]. Text needs 4.5:1 (AA);\n * `--scxml-fg-faint` and `--scxml-border-strong` are for graphics only and need 3:1.\n * Checked for the neutral theme by the package tests and for the Tinyactors\n * mapping by the playground tests.\n */\nexport const CONTRAST_PAIRS: readonly [string, string, number][] = [\n [\"--scxml-fg\", \"--scxml-bg\", 4.5],\n [\"--scxml-fg\", \"--scxml-surface\", 4.5],\n [\"--scxml-fg-muted\", \"--scxml-surface\", 4.5],\n [\"--scxml-fg-muted\", \"--scxml-surface-2\", 4.5],\n [\"--scxml-fg-subtle\", \"--scxml-bg\", 4.5],\n [\"--scxml-fg-subtle\", \"--scxml-surface\", 4.5],\n [\"--scxml-fg-subtle\", \"--scxml-surface-2\", 4.5],\n [\"--scxml-accent-text\", \"--scxml-bg\", 4.5],\n [\"--scxml-accent-text\", \"--scxml-surface\", 4.5],\n [\"--scxml-accent-text\", \"--scxml-accent-subtle\", 4.5],\n [\"--scxml-on-accent\", \"--scxml-accent\", 4.5],\n [\"--scxml-running\", \"--scxml-bg\", 4.5],\n [\"--scxml-running\", \"--scxml-surface\", 4.5],\n [\"--scxml-running\", \"--scxml-running-bg\", 4.5],\n [\"--scxml-waiting\", \"--scxml-surface\", 4.5],\n [\"--scxml-waiting\", \"--scxml-waiting-bg\", 4.5],\n [\"--scxml-done\", \"--scxml-done-bg\", 4.5],\n [\"--scxml-error\", \"--scxml-surface\", 4.5],\n [\"--scxml-fg-faint\", \"--scxml-surface\", 3],\n [\"--scxml-fg-faint\", \"--scxml-surface-2\", 3],\n [\"--scxml-border-strong\", \"--scxml-surface\", 3],\n];\n\n/** The neutral theme's colours for one scheme, keyed by public token name (parsed from THEME_CSS). */\nexport function neutralPalette(scheme: \"light\" | \"dark\"): Record<string, string> {\n const out: Record<string, string> = {};\n for (const m of THEME_CSS.matchAll(/var\\((--scxml-[\\w-]+),\\s*light-dark\\((#[0-9a-f]{3,6}),\\s*(#[0-9a-f]{3,6})\\)\\)/gi))\n out[m[1]!] = scheme === \"light\" ? m[2]! : m[3]!;\n return out;\n}\n"]}
1
+ {"version":3,"file":"theme.js","sourceRoot":"","sources":["../../src/ui/theme.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,gHAAgH;AAChH,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAC;AAEhC,MAAM,CAAC,MAAM,SAAS,GAAG,SAAS,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+ElC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,GAAW;IACnC,MAAM,IAAI,GAAG,IAAI,OAAO,EAAuC,CAAC;IAChE,OAAO,GAAG,EAAE;QACV,IAAI,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QACpC,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,KAAK,GAAG,IAAI,aAAa,EAAE,CAAC;YAC5B,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;YACvB,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;QACjC,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;AACJ,CAAC;AAED,gGAAgG;AAChG,MAAM,CAAC,MAAM,UAAU,GAAG,SAAS,CAAC,S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IAC1C,CAAC,kBAAkB,EAAE,iBAAiB,EAAE,CAAC,CAAC;IAC1C,CAAC,kBAAkB,EAAE,mBAAmB,EAAE,CAAC,CAAC;IAC5C,CAAC,uBAAuB,EAAE,iBAAiB,EAAE,CAAC,CAAC;CAChD,CAAC;AAEF,sGAAsG;AACtG,MAAM,UAAU,cAAc,CAAC,MAAwB;IACrD,MAAM,GAAG,GAA2B,EAAE,CAAC;IACvC,KAAK,MAAM,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC,iFAAiF,CAAC;QACnH,GAAG,CAAC,CAAC,CAAC,CAAC,CAAE,CAAC,GAAG,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAE,CAAC;IAClD,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["/**\n * Shared theme for the scxmljs custom elements (`<scxml-explorer>`, and\n * `<scxml-view>` once it moves into the package).\n *\n * Theming contract: every visual decision reads a public `--scxml-*` custom\n * property (set them on `scxml-explorer`, or anywhere above it). Unset ones\n * fall back to the neutral default theme below, which follows the page's\n * light/dark preference via `light-dark()` and `color-scheme`. Internally the\n * shadow DOM uses short private aliases (`--x-*`); they are not part of the API.\n *\n * No fonts are loaded: the defaults are system font stacks.\n */\n/** One breakpoint for every element: at or below this width (px) the elements switch to their narrow layout. */\nexport const NARROW_WIDTH = 760;\n\nexport const THEME_CSS = /* css */ `\n:host {\n /* follow the page: while --scxml-color-scheme is unset this is invalid, so color-scheme\n inherits and light-dark() below matches the page. Set it to \"light dark\" to follow the OS. */\n color-scheme: var(--scxml-color-scheme);\n /* text */\n --x-fg1: var(--scxml-fg, light-dark(#1c1c21, #ececf1));\n --x-fg2: var(--scxml-fg-muted, light-dark(#484852, #bcbcc6));\n --x-fg3: var(--scxml-fg-subtle, light-dark(#6a6a75, #90909b));\n --x-fg4: var(--scxml-fg-faint, light-dark(#85858f, #777781)); /* graphics only (≥3:1), never text */\n /* surfaces */\n --x-bg: var(--scxml-bg, light-dark(#f6f6f8, #141417));\n --x-s1: var(--scxml-surface, light-dark(#ffffff, #1c1c20));\n --x-s2: var(--scxml-surface-2, light-dark(#f0f0f3, #242429));\n --x-s3: var(--scxml-surface-3, light-dark(#e5e5ea, #2e2e34));\n /* lines */\n --x-b1: var(--scxml-border, light-dark(#e6e6eb, #2a2a30));\n --x-b2: var(--scxml-border-2, light-dark(#d3d3da, #393940));\n --x-strong: var(--scxml-border-strong, light-dark(#8b8b96, #6c6c77));\n /* the one accent */\n --x-accent: var(--scxml-accent, light-dark(#3d5bd9, #8fa3ff));\n --x-accent-fg: var(--scxml-accent-text, light-dark(#2f49b8, #aebcff));\n --x-accent-subtle: var(--scxml-accent-subtle, light-dark(#e9edfc, #252c4c));\n --x-on-accent: var(--scxml-on-accent, light-dark(#ffffff, #10132b));\n /* lifecycle */\n --x-run: var(--scxml-running, light-dark(#26733a, #6fd48a));\n --x-run-bg: var(--scxml-running-bg, light-dark(#e5f3e9, #1a3123));\n --x-wait: var(--scxml-waiting, light-dark(#a8560a, #ffb46b));\n --x-wait-bg: var(--scxml-waiting-bg, light-dark(#fdf0e1, #382815));\n --x-done: var(--scxml-done, light-dark(#48566b, #a7b5c9));\n --x-done-bg: var(--scxml-done-bg, light-dark(#e9edf3, #242b35));\n --x-err: var(--scxml-error, light-dark(#c2332f, #ff8a84));\n --x-err-bg: var(--scxml-error-bg, light-dark(#fbeceb, #3a1c1b));\n /* type */\n --x-sans: var(--scxml-font-sans, system-ui, -apple-system, \"Segoe UI\", Roboto, sans-serif);\n --x-mono: var(--scxml-font-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);\n --x-serif: var(--scxml-font-display, var(--x-sans));\n --x-display-weight: var(--scxml-display-weight, 600);\n /* shape and motion */\n --x-r: var(--scxml-radius, 4px);\n --x-dur: var(--scxml-duration, 140ms);\n --x-row: var(--scxml-row-height, 30px);\n color: var(--x-fg1); font: 400 13px/1.4 var(--x-sans);\n}\n* { box-sizing: border-box; }\nbutton { font: inherit; color: inherit; }\n:focus-visible { outline: 2px solid var(--x-accent); outline-offset: 1px; }\n\n/* ── primitives shared by the elements ─────────────────── */\n.search { display: flex; gap: 6px; padding: 0 12px 8px; flex: none; }\n.search input[type=\"search\"] {\n flex: 1; min-width: 0; height: 28px; padding: 0 8px; font: 12px var(--x-mono); color: var(--x-fg1);\n background: var(--x-s1); border: 1px solid var(--x-b2); border-radius: var(--x-r);\n}\n.search input[type=\"search\"]:focus { border-color: var(--x-accent); }\n.toggle { display: inline-flex; align-items: center; gap: 4px; font: 11px var(--x-sans); color: var(--x-fg3); white-space: nowrap; cursor: pointer; }\n.badge { display: inline-block; font: 500 10px/1 var(--x-mono); letter-spacing: .06em; text-transform: uppercase; padding: 3px 5px; border-radius: var(--x-r); white-space: nowrap; }\n.badge.run { color: var(--x-run); background: var(--x-run-bg); }\n.badge.wait { color: var(--x-wait); background: var(--x-wait-bg); }\n.badge.done { color: var(--x-done); background: var(--x-done-bg); }\n.badge.muted { color: var(--x-fg3); background: var(--x-s2); }\n.count { font: 500 11px var(--x-mono); color: var(--x-fg3); font-variant-numeric: tabular-nums; }\n.chip {\n display: inline-flex; align-items: center; gap: 4px; max-width: 100%; border: 1px solid var(--x-b2); background: var(--x-s1);\n border-radius: 999px; padding: 2px 8px; font: 11.5px/1.4 var(--x-mono); color: var(--x-accent-fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;\n}\n.chip:hover { border-color: var(--x-accent); background: var(--x-accent-subtle); }\n.chip.muted { color: var(--x-fg3); cursor: default; }\n.chip.muted:hover { border-color: var(--x-b2); background: var(--x-s1); }\n.more { border: 0; background: none; padding: 2px 4px; font: 500 11px var(--x-mono); color: var(--x-fg3); cursor: pointer; }\n.more:hover { color: var(--x-accent-fg); }\n.kind { display: inline-grid; place-items: center; width: 16px; height: 16px; flex: none; font: 11px/1 var(--x-mono); color: var(--x-fg3); }\n.empty { color: var(--x-fg3); padding: 16px 12px; font-style: italic; }\nh2.title { font: var(--x-display-weight) 24px/1.15 var(--x-serif); letter-spacing: -.01em; margin: 6px 0 2px; }\n.subtitle { color: var(--x-fg3); font: 12px var(--x-sans); margin: 0 0 14px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }\n.section-title { display: flex; align-items: center; gap: 8px; margin: 18px 0 8px; font: 500 10.5px var(--x-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--x-fg3); }\n.section-title::after { content: \"\"; flex: 1; border-top: 1px solid var(--x-b1); }\n\n@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }\n`;\n\n/**\n * A constructable stylesheet, created on first use (so modules can be\n * imported where there is no DOM) and shared by every shadow root that\n * adopts it (browsers share the parsed sheet). One per realm: a sheet can\n * only be adopted by documents of the realm whose `CSSStyleSheet` made it.\n */\nexport function lazySheet(css: string): () => CSSStyleSheet {\n const made = new WeakMap<typeof CSSStyleSheet, CSSStyleSheet>();\n return () => {\n let sheet = made.get(CSSStyleSheet);\n if (!sheet) {\n sheet = new CSSStyleSheet();\n sheet.replaceSync(css);\n made.set(CSSStyleSheet, sheet);\n }\n return sheet;\n };\n}\n\n/** The shared theme as one constructable stylesheet, adopted by every element's shadow root. */\nexport const themeSheet = lazySheet(THEME_CSS);\n\n/**\n * Colour pairs every theme must keep readable, as public token names:\n * [foreground, background, minimum WCAG contrast]. Text needs 4.5:1 (AA);\n * `--scxml-fg-faint` and `--scxml-border-strong` are for graphics only and need 3:1.\n * Checked for the neutral theme by the package tests and for the Tinyactors\n * mapping by the playground tests.\n */\nexport const CONTRAST_PAIRS: readonly [string, string, number][] = [\n [\"--scxml-fg\", \"--scxml-bg\", 4.5],\n [\"--scxml-fg\", \"--scxml-surface\", 4.5],\n [\"--scxml-fg-muted\", \"--scxml-surface\", 4.5],\n [\"--scxml-fg-muted\", \"--scxml-surface-2\", 4.5],\n [\"--scxml-fg-subtle\", \"--scxml-bg\", 4.5],\n [\"--scxml-fg-subtle\", \"--scxml-surface\", 4.5],\n [\"--scxml-fg-subtle\", \"--scxml-surface-2\", 4.5],\n [\"--scxml-accent-text\", \"--scxml-bg\", 4.5],\n [\"--scxml-accent-text\", \"--scxml-surface\", 4.5],\n [\"--scxml-accent-text\", \"--scxml-accent-subtle\", 4.5],\n [\"--scxml-on-accent\", \"--scxml-accent\", 4.5],\n [\"--scxml-running\", \"--scxml-bg\", 4.5],\n [\"--scxml-running\", \"--scxml-surface\", 4.5],\n [\"--scxml-running\", \"--scxml-running-bg\", 4.5],\n [\"--scxml-waiting\", \"--scxml-surface\", 4.5],\n [\"--scxml-waiting\", \"--scxml-waiting-bg\", 4.5],\n [\"--scxml-done\", \"--scxml-done-bg\", 4.5],\n // event names: a completion or an error in plain text, or on its tinted chip\n [\"--scxml-done\", \"--scxml-bg\", 4.5],\n [\"--scxml-done\", \"--scxml-surface\", 4.5],\n [\"--scxml-error\", \"--scxml-surface\", 4.5],\n [\"--scxml-error\", \"--scxml-bg\", 4.5],\n [\"--scxml-error\", \"--scxml-error-bg\", 4.5],\n [\"--scxml-fg-faint\", \"--scxml-surface\", 3],\n [\"--scxml-fg-faint\", \"--scxml-surface-2\", 3],\n [\"--scxml-border-strong\", \"--scxml-surface\", 3],\n];\n\n/** The neutral theme's colours for one scheme, keyed by public token name (parsed from THEME_CSS). */\nexport function neutralPalette(scheme: \"light\" | \"dark\"): Record<string, string> {\n const out: Record<string, string> = {};\n for (const m of THEME_CSS.matchAll(/var\\((--scxml-[\\w-]+),\\s*light-dark\\((#[0-9a-f]{3,6}),\\s*(#[0-9a-f]{3,6})\\)\\)/gi))\n out[m[1]!] = scheme === \"light\" ? m[2]! : m[3]!;\n return out;\n}\n"]}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * What a state is about, from the chart's own source: the XML comments right
3
+ * before it (only whitespace in between). Pure DOM reading, no layout.
4
+ *
5
+ * <!-- Waiting for the customer to pay. --> ← describes "awaiting"
6
+ * <state id="awaiting">
7
+ * <!-- every reminder is logged --> ← describes the transition, not "awaiting"
8
+ * <transition event="remind" type="internal">…</transition>
9
+ * </state>
10
+ *
11
+ * A comment documents the element after it, so comments inside a state are
12
+ * about its transitions or children. Section dividers lose their rules:
13
+ * `<!-- ── intake: validate, screen ──── -->` reads "intake: validate, screen".
14
+ */
15
+ import type { StateNode } from "../model.js";
16
+ /** A state's documentation comments, dedented and joined by blank lines; `undefined` when it has none. */
17
+ export declare function sourceDescription(state: StateNode): string | undefined;
@@ -0,0 +1,49 @@
1
+ const COMMENT = 8;
2
+ const TEXT = 3;
3
+ const blank = (n) => n.nodeType === TEXT && !(n.nodeValue ?? "").trim();
4
+ /** A run of rule characters, as in `<!-- ── section ───── -->` or `<!-- ===== -->`. */
5
+ const RULE = "[\\-‐-―─━═~=*#_+]{2,}";
6
+ const LEADING_RULE = new RegExp(`^\\s*${RULE}\\s*`);
7
+ const TRAILING_RULE = new RegExp(`\\s*${RULE}\\s*$`);
8
+ /** A state's documentation comments, dedented and joined by blank lines; `undefined` when it has none. */
9
+ export function sourceDescription(state) {
10
+ const el = state.element;
11
+ if (!el || state.kind === "scxml")
12
+ return undefined;
13
+ const before = [];
14
+ for (let n = el.previousSibling; n && (n.nodeType === COMMENT || blank(n)); n = n.previousSibling)
15
+ if (n.nodeType === COMMENT)
16
+ before.unshift(n.nodeValue ?? "");
17
+ const parts = before.map((c) => dedent(undecorate(c))).filter(Boolean);
18
+ return parts.length ? parts.join("\n\n") : undefined;
19
+ }
20
+ /** Remove divider rules: lines that are only a rule, and rules around a line's text. */
21
+ function undecorate(text) {
22
+ return text
23
+ .split(/\r\n?|\n/)
24
+ .map((line) => {
25
+ const bare = line.replace(LEADING_RULE, (m) => m.replace(/\S/g, "")).replace(TRAILING_RULE, "");
26
+ return bare.trim() ? bare : "";
27
+ })
28
+ .join("\n");
29
+ }
30
+ /** Trim a comment and remove the indentation its lines share (a first line right after `<!--` doesn't count). */
31
+ function dedent(text) {
32
+ const lines = text.replace(/\r\n?/g, "\n").split("\n");
33
+ const flush = !!lines[0]?.trim();
34
+ if (flush)
35
+ lines[0] = lines[0].trim();
36
+ while (lines.length && !lines[0].trim())
37
+ lines.shift();
38
+ while (lines.length && !lines[lines.length - 1].trim())
39
+ lines.pop();
40
+ if (!lines.length)
41
+ return "";
42
+ const measured = (flush ? lines.slice(1) : lines).filter((l) => l.trim());
43
+ const indent = measured.length ? Math.min(...measured.map((l) => l.match(/^[ \t]*/)[0].length)) : 0;
44
+ return lines
45
+ .map((l, i) => (flush && i === 0 ? l : l.slice(indent).trimEnd()))
46
+ .join("\n")
47
+ .trim();
48
+ }
49
+ //# sourceMappingURL=describe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"describe.js","sourceRoot":"","sources":["../../src/view/describe.ts"],"names":[],"mappings":"AAgBA,MAAM,OAAO,GAAG,CAAC,CAAC;AAClB,MAAM,IAAI,GAAG,CAAC,CAAC;AAEf,MAAM,KAAK,GAAG,CAAC,CAAO,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;AAC9E,uFAAuF;AACvF,MAAM,IAAI,GAAG,uBAAuB,CAAC;AACrC,MAAM,YAAY,GAAG,IAAI,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,CAAC;AACpD,MAAM,aAAa,GAAG,IAAI,MAAM,CAAC,OAAO,IAAI,OAAO,CAAC,CAAC;AAErD,0GAA0G;AAC1G,MAAM,UAAU,iBAAiB,CAAC,KAAgB;IAChD,MAAM,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC;IACzB,IAAI,CAAC,EAAE,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO;QAAE,OAAO,SAAS,CAAC;IACpD,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,KAAK,IAAI,CAAC,GAAG,EAAE,CAAC,eAAe,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ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E,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAE,CAAC,IAAI,EAAE,CAAC;IACvC,OAAO,KAAK,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,CAAC,CAAE,CAAC,IAAI,EAAE;QAAE,KAAK,CAAC,KAAK,EAAE,CAAC;IACxD,OAAO,KAAK,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAE,CAAC,IAAI,EAAE;QAAE,KAAK,CAAC,GAAG,EAAE,CAAC;IACrE,IAAI,CAAC,KAAK,CAAC,MAAM;QAAE,OAAO,EAAE,CAAC;IAC7B,MAAM,QAAQ,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAC1E,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACrG,OAAO,KAAK;SACT,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;SACjE,IAAI,CAAC,IAAI,CAAC;SACV,IAAI,EAAE,CAAC;AACZ,CAAC","sourcesContent":["/**\n * What a state is about, from the chart's own source: the XML comments right\n * before it (only whitespace in between). Pure DOM reading, no layout.\n *\n * <!-- Waiting for the customer to pay. --> ← describes \"awaiting\"\n * <state id=\"awaiting\">\n * <!-- every reminder is logged --> ← describes the transition, not \"awaiting\"\n * <transition event=\"remind\" type=\"internal\">…</transition>\n * </state>\n *\n * A comment documents the element after it, so comments inside a state are\n * about its transitions or children. Section dividers lose their rules:\n * `<!-- ── intake: validate, screen ──── -->` reads \"intake: validate, screen\".\n */\nimport type { StateNode } from \"../model.ts\";\n\nconst COMMENT = 8;\nconst TEXT = 3;\n\nconst blank = (n: Node) => n.nodeType === TEXT && !(n.nodeValue ?? \"\").trim();\n/** A run of rule characters, as in `<!-- ── section ───── -->` or `<!-- ===== -->`. */\nconst RULE = \"[\\\\-‐-―─━═~=*#_+]{2,}\";\nconst LEADING_RULE = new RegExp(`^\\\\s*${RULE}\\\\s*`);\nconst TRAILING_RULE = new RegExp(`\\\\s*${RULE}\\\\s*$`);\n\n/** A state's documentation comments, dedented and joined by blank lines; `undefined` when it has none. */\nexport function sourceDescription(state: StateNode): string | undefined {\n const el = state.element;\n if (!el || state.kind === \"scxml\") return undefined;\n const before: string[] = [];\n for (let n = el.previousSibling; n && (n.nodeType === COMMENT || blank(n)); n = n.previousSibling)\n if (n.nodeType === COMMENT) before.unshift(n.nodeValue ?? \"\");\n const parts = before.map((c) => dedent(undecorate(c))).filter(Boolean);\n return parts.length ? parts.join(\"\\n\\n\") : undefined;\n}\n\n/** Remove divider rules: lines that are only a rule, and rules around a line's text. */\nfunction undecorate(text: string): string {\n return text\n .split(/\\r\\n?|\\n/)\n .map((line) => {\n const bare = line.replace(LEADING_RULE, (m) => m.replace(/\\S/g, \"\")).replace(TRAILING_RULE, \"\");\n return bare.trim() ? bare : \"\";\n })\n .join(\"\\n\");\n}\n\n/** Trim a comment and remove the indentation its lines share (a first line right after `<!--` doesn't count). */\nfunction dedent(text: string): string {\n const lines = text.replace(/\\r\\n?/g, \"\\n\").split(\"\\n\");\n const flush = !!lines[0]?.trim();\n if (flush) lines[0] = lines[0]!.trim();\n while (lines.length && !lines[0]!.trim()) lines.shift();\n while (lines.length && !lines[lines.length - 1]!.trim()) lines.pop();\n if (!lines.length) return \"\";\n const measured = (flush ? lines.slice(1) : lines).filter((l) => l.trim());\n const indent = measured.length ? Math.min(...measured.map((l) => l.match(/^[ \\t]*/)![0].length)) : 0;\n return lines\n .map((l, i) => (flush && i === 0 ? l : l.slice(indent).trimEnd()))\n .join(\"\\n\")\n .trim();\n}\n"]}
@@ -19,16 +19,24 @@
19
19
  *
20
20
  * Attributes: `src`, `trusted`, `autostart` ("false" = draw without running),
21
21
  * `interactive` ("false" = labels aren't buttons), `data` (JSON initial values
22
- * for `<data>`), `direction` ("auto" | "right" | "down"), `max-states` (fold
22
+ * for `<data>`), `direction` ("down" (default) | "right" | "auto"), `max-states` (fold
23
23
  * large charts beyond this many boxes, default 150), `announce`
24
24
  * ("all" | "sends" | "off"), `fit` (scale down to the element's width),
25
- * `warnings` ("off" hides the list of authoring warnings — see `model.warnings`).
25
+ * `warnings` ("off" hides the list of authoring warnings — see `model.warnings`),
26
+ * `event-data` (JSON object from event names to the data a label click sends,
27
+ * e.g. `{"login": {"user": "ada"}}`).
26
28
  *
27
29
  * Properties: `session` (a host-created session; the element then creates,
28
30
  * starts and disposes nothing), `options` (extra SessionOptions for sessions
29
31
  * the element creates: I/O processors, invokers, loader…), `clock` (e.g. a
30
32
  * PlaybackClock: shows play / pause / step controls), `strings`, `source`
31
- * (SCXML text instead of `src`), `model`, and `reload()`.
33
+ * (SCXML text instead of `src`), `model`, `descriptions` (what each state is
34
+ * about, shown by its help button; XML comments in the source otherwise),
35
+ * `zoom`, and `reload()`.
36
+ *
37
+ * Navigation: the diagram zooms (the toolbar, Ctrl/⌘ + wheel, pinch, `+` `-`
38
+ * `0` while the canvas is focused) and pans (drag, or scroll); every compound
39
+ * and parallel state folds and unfolds with its chevron.
32
40
  *
33
41
  * Events (bubbling, composed): `scxml-load` { session, model },
34
42
  * `scxml-error` { message, problems?, error }, `scxml-send` { session, name }
@@ -38,11 +46,11 @@
38
46
  * `state` (+ `atomic` `compound` `parallel` `parallel-region` `final`
39
47
  * `history` `collapsed` `active`), `state-name`, `transition` / `edge-label`
40
48
  * (+ `live` `fired`), `event`, `cond`, `internal`, `edge` (+ `live` `fired`),
41
- * `initial`, `expand`, `collapse`, `notice`, `error`, `controls`, `play`,
42
- * `step`, `speeds`, `clock`, `warnings`, `warning`.
49
+ * `initial`, `expand`, `collapse`, `help`, `help-popover`, `zoom`, `notice`,
50
+ * `error`, `controls`, `play`, `step`, `speeds`, `clock`, `warnings`, `warning`.
43
51
  */
44
52
  import { type Clock } from "../clock.js";
45
- import { type Model } from "../model.js";
53
+ import { type Model, type StateNode } from "../model.js";
46
54
  import { SCXMLSession, type SessionOptions } from "../session.js";
47
55
  import { type Direction } from "./layout.js";
48
56
  import { type ViewStrings } from "./strings.js";
@@ -62,16 +70,28 @@ export interface ViewErrorDetail {
62
70
  /** the underlying error (an `SCXMLValidationError`, `SCXMLParseError`, `ViewSourceError`, fetch error…) */
63
71
  error: unknown;
64
72
  }
65
- /** `scxml-send`: a transition label is about to send its event. Cancelable (`preventDefault()` stops it). */
73
+ /**
74
+ * `scxml-send`: a transition label is about to send its event. Cancelable
75
+ * (`preventDefault()` stops it). Listeners may set `data`: it's sent as the
76
+ * event's data (it starts as the value from the `event-data` attribute).
77
+ */
66
78
  export interface ViewSendDetail {
67
79
  /** the session the event goes to */
68
80
  session: SCXMLSession;
69
81
  /** the event name */
70
82
  name: string;
83
+ /** the event data to send; writable */
84
+ data?: unknown;
71
85
  }
86
+ /**
87
+ * What each state is about, for its help popover: an object from state ids to
88
+ * text, or a function of the state. Wins over the chart's XML comments;
89
+ * return `undefined` to fall back to them.
90
+ */
91
+ export type ViewDescriptions = Record<string, string> | ((state: StateNode) => string | null | undefined);
72
92
  /** SessionOptions for sessions the element creates (its own clock comes from the `clock` property). */
73
93
  export type ViewOptions = Omit<SessionOptions, "clock">;
74
- /** Layout direction: layers left to right, top to bottom, or `auto` (down below the 760px breakpoint). */
94
+ /** Layout direction: layers top to bottom (the default), left to right, or `auto` (right above the 760px breakpoint, down below it). */
75
95
  export type ViewDirection = Direction | "auto";
76
96
  /** What the live region announces: every step and sent event, only sent events, or nothing. */
77
97
  export type ViewAnnounce = "all" | "sends" | "off";
@@ -107,7 +127,7 @@ export declare class ScxmlView extends ElementBase {
107
127
  get interactive(): boolean;
108
128
  /** Sets the `interactive` attribute. */
109
129
  set interactive(v: boolean);
110
- /** "right" (layers left to right), "down", or "auto" (down when narrower than the shared breakpoint). */
130
+ /** "down" (layers top to bottom, the default), "right", or "auto" (down when narrower than the shared breakpoint, right otherwise). */
111
131
  get direction(): ViewDirection;
112
132
  /** Sets the `direction` attribute (re-lays out). */
113
133
  set direction(v: ViewDirection);
@@ -149,6 +169,16 @@ export declare class ScxmlView extends ElementBase {
149
169
  get strings(): ViewStrings;
150
170
  /** Translate: a partial object; unset keys keep their English default. */
151
171
  set strings(s: Partial<ViewStrings>);
172
+ /** What each state is about (its help popover): an object from state ids to text, or a function of the state. Overrides the chart's XML comments. */
173
+ get descriptions(): ViewDescriptions | undefined;
174
+ /** Set what states are about; `undefined` goes back to the chart's XML comments only. */
175
+ set descriptions(d: ViewDescriptions | undefined);
176
+ /** What a state's help popover explains: `descriptions` first, then the XML comments documenting it in the source. */
177
+ describe(state: StateNode): string | undefined;
178
+ /** The diagram's scale (1 = actual size). Reading it gives the scale in use; setting a number zooms, `null` goes back to automatic. */
179
+ get zoom(): number;
180
+ /** Zoom to this scale (clamped to 0.15–4), or `null` for the automatic scale (fitted to the element's width, see `fit`). */
181
+ set zoom(scale: number | null);
152
182
  /** Load the chart again (re-reading `src` / inline source) and start a fresh session. */
153
183
  reload(): void;
154
184
  /** Custom-element lifecycle (called by the browser): loads the chart when first connected. */