@tinyactors/scxmljs 0.2.0-dev.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.
- package/README.md +9 -9
- package/dist/explorer/element.d.ts +5 -3
- package/dist/explorer/element.js +523 -262
- package/dist/explorer/element.js.map +1 -1
- package/dist/explorer/strings.d.ts +41 -23
- package/dist/explorer/strings.js +24 -15
- package/dist/explorer/strings.js.map +1 -1
- package/dist/explorer/styles.d.ts +9 -1
- package/dist/explorer/styles.js +291 -150
- package/dist/explorer/styles.js.map +1 -1
- package/dist/explorer.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/model.d.ts +4 -1
- package/dist/model.js +7 -1
- package/dist/model.js.map +1 -1
- package/dist/session.d.ts +22 -9
- package/dist/session.js +53 -13
- package/dist/session.js.map +1 -1
- package/dist/themes/tinyactors.css +1 -0
- package/dist/trusted.d.ts +1 -0
- package/dist/ui/icons.d.ts +31 -0
- package/dist/ui/icons.js +186 -0
- package/dist/ui/icons.js.map +1 -0
- package/dist/ui/notation.d.ts +53 -0
- package/dist/ui/notation.js +117 -0
- package/dist/ui/notation.js.map +1 -0
- package/dist/ui/svg.d.ts +4 -0
- package/dist/ui/svg.js +26 -0
- package/dist/ui/svg.js.map +1 -1
- package/dist/ui/theme.d.ts +1 -1
- package/dist/ui/theme.js +6 -0
- package/dist/ui/theme.js.map +1 -1
- package/dist/view/describe.d.ts +17 -0
- package/dist/view/describe.js +49 -0
- package/dist/view/describe.js.map +1 -0
- package/dist/view/element.d.ts +39 -9
- package/dist/view/element.js +723 -86
- package/dist/view/element.js.map +1 -1
- package/dist/view/layout.d.ts +20 -0
- package/dist/view/layout.js +205 -29
- package/dist/view/layout.js.map +1 -1
- package/dist/view/strings.d.ts +34 -8
- package/dist/view/strings.js +19 -6
- package/dist/view/strings.js.map +1 -1
- package/dist/view/styles.d.ts +1 -1
- package/dist/view/styles.js +107 -21
- package/dist/view/styles.js.map +1 -1
- package/dist/view.d.ts +8 -4
- package/dist/view.js +6 -3
- package/dist/view.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../src/explorer/styles.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,CAAC;AACxB,MAAM,CAAC,MAAM,YAAY,GAAG,SAAS,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;kCAyBJ,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kCAqCZ,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kCA4KZ,YAAY;;;;;;;;;;;;;;;;;;;;CAoB7C,CAAC","sourcesContent":["/**\n * Layout and component styles of <scxml-explorer>. Colours, type and shape\n * come from the shared theme (src/ui/theme.ts): the `--scxml-*` token\n * contract with neutral defaults, adopted before this sheet. Below\n * NARROW_WIDTH (shared with the element and `<scxml-view>`) the explorer\n * shows one pane with tabs.\n */\nimport { NARROW_WIDTH } from \"../ui/theme.ts\";\n\nexport { NARROW_WIDTH };\nexport const EXPLORER_CSS = /* css */ `\n:host {\n display: block; container-type: inline-size; container-name: explorer;\n background: var(--x-bg);\n border: 1px solid var(--x-b2); border-radius: var(--x-r); overflow: hidden;\n height: var(--scxml-height, min(860px, calc(100dvh - 32px)));\n}\n/* ── shell ─────────────────────────────────────────────── */\n.shell { display: grid; grid-template-rows: auto auto 1fr; grid-template-columns: minmax(0, 1fr); height: 100%; }\n.shell > .playback[hidden] { display: none; }\n.playback {\n display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; padding: 6px 12px;\n background: var(--x-s2); border-bottom: 1px solid var(--x-b2); font: 12px var(--x-sans); color: var(--x-fg2);\n}\n.playback .play, .playback .step {\n height: 28px; padding: 0 12px; border-radius: var(--x-r); cursor: pointer; font: 500 12.5px var(--x-sans);\n border: 1px solid var(--x-b2); background: var(--x-s1); color: var(--x-fg1);\n}\n.playback .play { min-width: 86px; background: var(--x-accent); border-color: var(--x-accent); color: var(--x-on-accent); }\n.playback .play[aria-pressed=\"true\"] { background: var(--x-s1); color: var(--x-fg1); border-color: var(--x-b2); }\n.playback .step:hover:not(:disabled) { border-color: var(--x-accent); color: var(--x-accent-fg); }\n.playback .step:disabled { opacity: .45; cursor: default; }\n.playback .clock-time { font: 500 12px var(--x-mono); color: var(--x-fg1); font-variant-numeric: tabular-nums; min-width: 8ch; }\n.playback .clock-queue { font: 11.5px var(--x-mono); color: var(--x-fg3); }\n.playback .last-step { flex: 1 1 200px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 11.5px var(--x-mono); color: var(--x-accent-fg); text-align: right; }\n@container explorer (max-width: ${NARROW_WIDTH}px) {\n .playback { gap: 6px 8px; padding: 6px 10px; }\n .playback .last-step { flex-basis: 100%; text-align: left; }\n .playback .clock-queue { display: none; }\n}\n.top {\n display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 6px 12px;\n background: var(--x-s1); border-bottom: 1px solid var(--x-b2);\n}\n.levels { display: inline-flex; border: 1px solid var(--x-b2); border-radius: var(--x-r); overflow: hidden; flex: none; }\n.levels button { border: 0; background: none; padding: 4px 10px; cursor: pointer; font: 500 11px/1.4 var(--x-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--x-fg3); }\n.levels button[aria-pressed=\"true\"] { background: var(--x-accent); color: var(--x-on-accent); }\n.crumbs { display: flex; align-items: center; gap: 2px; min-width: 0; flex: 1; overflow: hidden; }\n.crumbs button { border: 0; background: none; padding: 3px 5px; border-radius: var(--x-r); cursor: pointer; color: var(--x-fg2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 22ch; }\n.crumbs button:hover { background: var(--x-s2); color: var(--x-fg1); }\n.crumbs button[aria-current] { color: var(--x-fg1); font-weight: 600; }\n.crumbs .sep { color: var(--x-fg4); flex: none; }\n.follow { display: inline-flex; align-items: center; gap: 6px; flex: none; cursor: pointer; color: var(--x-fg2); font: 500 11px var(--x-mono); letter-spacing: .08em; text-transform: uppercase; border: 1px solid var(--x-b2); border-radius: 999px; padding: 3px 10px; background: none; }\n/* off: a hollow ring; on: a filled dot (shape, not only colour) */\n.follow::before { content: \"\"; width: 7px; height: 7px; border-radius: 50%; box-sizing: border-box; border: 1.5px solid var(--x-fg3); background: transparent; }\n.follow[aria-pressed=\"true\"] { color: var(--x-run); border-color: color-mix(in srgb, var(--x-run) 40%, transparent); }\n.follow[aria-pressed=\"true\"]::before { border-color: var(--x-run); background: var(--x-run); box-shadow: 0 0 0 3px color-mix(in srgb, var(--x-run) 20%, transparent); }\n\n.body { display: grid; grid-template-columns: minmax(220px, 280px) minmax(0, 1fr) minmax(280px, 360px); min-height: 0; }\n.pane { min-height: 0; min-width: 0; display: flex; flex-direction: column; }\n.pane + .pane { border-left: 1px solid var(--x-b2); }\n.pane-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px 8px; flex: none; }\n.pane-title { font: 500 10.5px/1 var(--x-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--x-fg3); flex: 1; }\n.pane-scroll { overflow: auto; min-height: 0; flex: 1; overscroll-behavior: contain; }\n.center { background: var(--x-bg); }\n.center .pane-scroll { padding: 4px 16px 24px; }\n.inspector { background: var(--x-s1); }\n.tree-pane { background: var(--x-s1); }\n.tabs { display: none; }\n.events-strip { display: none; }\n\n/* narrow container: one pane at a time, bottom tabs, sticky events strip */\n@container explorer (max-width: ${NARROW_WIDTH}px) {\n .body { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto auto; }\n .pane { display: none; }\n .pane + .pane { border-left: 0; }\n .pane[data-tab-active] { display: flex; }\n .tabs { display: flex; border-top: 1px solid var(--x-b2); background: var(--x-s1); }\n .tabs button { flex: 1; border: 0; background: none; padding: 9px 4px 10px; cursor: pointer; font: 500 10.5px var(--x-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--x-fg3); }\n .tabs button[aria-selected=\"true\"] { color: var(--x-accent-fg); box-shadow: inset 0 2px 0 var(--x-accent); }\n .events-strip { display: flex; gap: 6px; padding: 8px 12px; min-width: 0; overflow-x: auto; background: var(--x-s1); border-top: 1px solid var(--x-b1); scrollbar-width: none; }\n .events-strip > * { flex: none; max-width: 70vw; }\n .crumbs { overflow-x: auto; scrollbar-width: none; }\n .crumbs button { max-width: 14ch; }\n .levels { display: none; }\n .center .pane-scroll { padding: 4px 12px 20px; }\n}\n\n/* ── tree (windowed) ───────────────────────────────────── */\n.tree-viewport { position: relative; }\n.tree-row {\n position: absolute; left: 0; right: 0; height: var(--x-row); display: flex; align-items: center; gap: 2px;\n padding-right: 8px; cursor: pointer; white-space: nowrap; border-left: 2px solid transparent;\n}\n.tree-row:hover { background: var(--x-s2); }\n.tree-row[aria-selected=\"true\"] { background: var(--x-accent-subtle); border-left-color: var(--x-accent); }\n.tree-row .twisty { width: 18px; height: 18px; flex: none; border: 0; background: none; padding: 0; cursor: pointer; color: var(--x-fg3); font-size: 10px; }\n.tree-row .twisty[hidden] { visibility: hidden; display: inline-block; }\n.tree-row .name { overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }\n.tree-row.path .name { font-weight: 600; }\n.tree-row.active .name { color: var(--x-run); font-weight: 600; }\n.tree-row.match .name { text-decoration: underline; text-decoration-color: var(--x-accent); text-underline-offset: 3px; }\n.tree-row .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--x-run); flex: none; margin-left: 4px; }\n.tree-row:focus-visible { outline-offset: -2px; }\n\n/* ── focus ─────────────────────────────────────────────── */\n.mode { display: inline-flex; border: 1px solid var(--x-b2); border-radius: var(--x-r); overflow: hidden; }\n.mode button { border: 0; background: none; padding: 3px 8px; cursor: pointer; font: 11px var(--x-sans); color: var(--x-fg3); }\n.mode button[aria-pressed=\"true\"] { background: var(--x-s3); color: var(--x-fg1); }\n.diagram { position: relative; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(150px, 230px); justify-content: start; gap: 22px 128px; align-items: start; padding: 6px 2px 10px 16px; }\n.rank { display: flex; flex-direction: column; gap: 14px; }\n.edges { position: absolute; inset: 0; pointer-events: none; overflow: visible; }\n.edges path { fill: none; stroke: var(--x-fg4); stroke-width: 1.25; }\n.edges path.live { stroke: var(--x-accent); stroke-width: 1.75; }\n.edges path.back { stroke-dasharray: 4 3; }\n.edges marker path { fill: context-stroke; stroke: none; }\n.edge-label {\n position: absolute; transform: translate(-50%, -50%); z-index: 1; pointer-events: auto;\n font: 11px/1.3 var(--x-mono); background: var(--x-bg); color: var(--x-fg2); padding: 1px 6px; border: 1px solid var(--x-b1); border-radius: 999px; white-space: nowrap; max-width: 120px; overflow: hidden; text-overflow: ellipsis; cursor: help;\n}\n.edge-label.live { color: var(--x-accent-fg); border-color: color-mix(in srgb, var(--x-accent) 40%, transparent); }\n/* labels that found no free spot collapse to their event count and open on hover / focus */\n.edge-label .short { display: none; }\n.edge-label.collapsed .full { display: none; }\n.edge-label.collapsed .short { display: inline; }\n.edge-label.collapsed:is(:hover, :focus-visible) { z-index: 3; max-width: 240px; }\n.edge-label.collapsed:is(:hover, :focus-visible) .full { display: inline; }\n.edge-label.collapsed:is(:hover, :focus-visible) .short { display: none; }\n\n.card {\n position: relative; background: var(--x-s1); border: 1px solid var(--x-strong); border-radius: var(--x-r);\n padding: 8px 10px 9px; display: grid; gap: 5px; cursor: pointer; transition: border-color var(--x-dur), background var(--x-dur), box-shadow var(--x-dur);\n}\n.card:hover { box-shadow: 0 1px 0 var(--x-b2), 0 4px 14px rgba(40, 30, 20, .08); }\n.card.path { border-color: var(--x-run); box-shadow: inset 0 0 0 1px var(--x-run); }\n.card.active { background: var(--x-run-bg); }\n.card.waiting { border-color: var(--x-wait); box-shadow: inset 0 0 0 1px var(--x-wait); background: var(--x-wait-bg); }\n.card.final { border-radius: 999px; border-style: double; border-width: 3px; padding: 5px 14px; }\n.card.selected { outline: 2px solid var(--x-accent); outline-offset: 2px; }\n.card-head { display: flex; align-items: center; gap: 6px; min-width: 0; }\n.card-head .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }\n.card.path .card-head .name { color: var(--x-run); }\n.card.waiting .card-head .name { color: var(--x-wait); }\n.card .meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; color: var(--x-fg3); font-size: 11.5px; }\n.card .events { display: flex; gap: 4px; flex-wrap: wrap; }\n.card .events .chip { font-size: 10.5px; padding: 1px 6px; }\n.drill { border: 0; background: none; padding: 0; cursor: pointer; color: var(--x-accent-fg); font: 500 11.5px var(--x-sans); }\n.drill:hover { text-decoration: underline; }\n.initial-mark { position: absolute; left: -13px; top: 13px; width: 8px; height: 8px; border-radius: 50%; background: var(--x-fg1); }\n.initial-mark::after { content: \"\"; position: absolute; left: 8px; top: 3.5px; width: 5px; border-top: 1.5px solid var(--x-fg1); }\n\n.lanes { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }\n.lane { border: 1px dashed var(--x-strong); border-radius: var(--x-r); background: var(--x-s1); padding: 8px 10px; min-width: 0; }\n.lane.path { border-color: var(--x-run); border-style: solid; }\n.lane-head { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }\n.lane-head .name { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }\n.lane.path .lane-head .name { color: var(--x-run); }\n.lane-row { display: flex; align-items: center; gap: 6px; padding: 3px 6px; margin: 0 -6px; border-radius: var(--x-r); cursor: pointer; }\n.lane-row:hover { background: var(--x-s2); }\n.lane-row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.lane-row.active .name { color: var(--x-run); font-weight: 600; }\n\n.list { display: grid; gap: 1px; background: var(--x-b1); border: 1px solid var(--x-b1); border-radius: var(--x-r); overflow: hidden; }\n.list-row { display: grid; grid-template-columns: 16px minmax(0, 1fr) auto; gap: 4px 8px; align-items: center; padding: 7px 10px; background: var(--x-s1); cursor: pointer; }\n.list-row:hover { background: var(--x-s2); }\n.list-row.path { background: color-mix(in srgb, var(--x-run-bg) 55%, var(--x-s1)); }\n.list-row .name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.list-row.path .name { color: var(--x-run); font-weight: 600; }\n.list-row .sub { grid-column: 2 / -1; display: flex; gap: 4px; flex-wrap: wrap; color: var(--x-fg3); font-size: 11.5px; }\n.list-group { font: 500 10.5px var(--x-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--x-fg3); padding: 8px 10px 4px; background: var(--x-bg); }\n\n.doors { display: grid; gap: 6px; }\n.door { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 10px; align-items: baseline; padding: 6px 10px; border: 1px solid var(--x-b1); border-left: 3px solid var(--x-strong); border-radius: var(--x-r); background: var(--x-s1); cursor: pointer; }\n.door:hover { border-color: var(--x-b2); border-left-color: var(--x-accent); }\n.door .arrow { font: 13px var(--x-mono); color: var(--x-fg3); }\n.door .where { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.door .where small { font-weight: 400; color: var(--x-fg3); }\n.door .events { grid-column: 2; display: flex; gap: 4px; flex-wrap: wrap; }\n.door.live { border-left-color: var(--x-accent); }\n\n/* ── events ────────────────────────────────────────────── */\n.scopes { display: flex; gap: 4px; padding: 0 12px 8px; flex-wrap: wrap; }\n.scopes button { border: 1px solid var(--x-b2); background: none; border-radius: 999px; padding: 2px 9px; cursor: pointer; font: 11.5px var(--x-sans); color: var(--x-fg2); }\n.scopes button[aria-pressed=\"true\"] { background: var(--x-fg1); color: var(--x-s1); border-color: var(--x-fg1); }\n.ev-group > summary { display: flex; align-items: center; gap: 8px; list-style: none; cursor: pointer; padding: 7px 12px; font: 500 11px var(--x-mono); letter-spacing: .06em; color: var(--x-fg2); border-top: 1px solid var(--x-b1); }\n.ev-group > summary::-webkit-details-marker { display: none; }\n.ev-group > summary::before { content: \"▸\"; font-size: 9px; color: var(--x-fg4); transition: transform var(--x-dur); }\n.ev-group[open] > summary::before { transform: rotate(90deg); }\n.ev-group > summary .count { margin-left: auto; }\n.ev-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 8px; padding: 6px 12px 7px 26px; align-items: center; }\n.ev-row:hover { background: var(--x-s2); }\n.ev-row .ev { font: 500 12px var(--x-mono); color: var(--x-accent-fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.ev-row .how { grid-column: 1; color: var(--x-fg3); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.ev-row .how .guard { font: 11px var(--x-mono); color: var(--x-wait); }\n.ev-row .send { grid-row: 1 / span 2; grid-column: 2; border: 1px solid var(--x-b2); background: var(--x-s1); border-radius: var(--x-r); height: 26px; padding: 0 9px; cursor: pointer; font: 500 12px var(--x-sans); }\n.ev-row .send:hover { border-color: var(--x-accent); color: var(--x-accent-fg); }\n.ev-row .send:disabled { opacity: .45; cursor: default; }\n.ev-row .scope-tag { font: 500 10px var(--x-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--x-fg3); border: 1px solid var(--x-b2); border-radius: var(--x-r); padding: 0 4px; margin-right: 4px; }\n.ev-row.scope-inherited .ev { color: var(--x-fg2); }\n.ev-row.scope-elsewhere .ev { color: var(--x-fg3); }\n.data-field { display: flex; gap: 6px; align-items: center; padding: 0 12px 8px; }\n.data-field span { font: 500 10px var(--x-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--x-fg3); }\n.data-field input { flex: 1; min-width: 0; height: 26px; padding: 0 8px; font: 11.5px var(--x-mono); border: 1px solid var(--x-b2); border-radius: var(--x-r); background: var(--x-s1); color: var(--x-fg1); }\n\n/* ── detail ────────────────────────────────────────────── */\n.detail { padding: 0 12px 16px; }\n.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; font-size: 12.5px; margin: 0; }\n.kv dt { color: var(--x-fg3); }\n.kv dd { margin: 0; font-family: var(--x-mono); font-size: 12px; overflow-wrap: anywhere; }\ntable.tx { width: 100%; border-collapse: collapse; font-size: 12px; }\ntable.tx th { text-align: left; font: 500 10px var(--x-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--x-fg3); padding: 4px 6px; border-bottom: 1px solid var(--x-b2); position: sticky; top: 0; background: var(--x-s1); }\ntable.tx td { padding: 5px 6px; border-bottom: 1px solid var(--x-b1); vertical-align: top; }\ntable.tx td.ev { font-family: var(--x-mono); color: var(--x-accent-fg); overflow-wrap: anywhere; }\ntable.tx td.cond { font-family: var(--x-mono); color: var(--x-wait); font-size: 11px; overflow-wrap: anywhere; }\ntable.tx td.to { overflow-wrap: anywhere; }\n.actions { margin: 0; padding: 0; list-style: none; font: 12px var(--x-mono); color: var(--x-fg2); display: grid; gap: 2px; }\n.actions b { font: 500 10px var(--x-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--x-fg3); margin-right: 6px; }\n\n/* ── system ────────────────────────────────────────────── */\n.system { position: relative; display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 16px 72px; align-items: start; }\n.system .col { display: grid; gap: 10px; align-content: start; min-width: 0; }\n.system .col-title { font: 500 10.5px var(--x-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--x-fg3); display: flex; gap: 8px; align-items: center; }\n.machine { margin-left: calc(var(--depth, 0) * 18px); }\n.machine.compact { grid-template-columns: minmax(0, 1fr) minmax(0, 40%); align-items: center; padding: 5px 10px; }\n.machine.compact .leaves { text-align: right; }\n.machine .leaves { font: 11.5px var(--x-mono); color: var(--x-run); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.machine .from { color: var(--x-fg3); font-size: 11.5px; }\n.service .type { font: 11px var(--x-mono); color: var(--x-fg3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.links { position: absolute; inset: 0; pointer-events: none; overflow: visible; }\n.links path { fill: none; stroke: var(--x-b2); stroke-width: 1.25; }\n.links path.invoke { stroke: var(--x-fg4); stroke-dasharray: 3 3; }\n.links path.hot { stroke: var(--x-accent); stroke-width: 2; }\n.talks { display: flex; gap: 4px; flex-wrap: wrap; }\n.pulse { animation: pulse 1.2s ease-out; }\n@keyframes pulse { from { box-shadow: 0 0 0 0 color-mix(in srgb, var(--x-accent) 45%, transparent); } to { box-shadow: 0 0 0 8px transparent; } }\n.traffic { list-style: none; margin: 0; padding: 0; font: 11.5px/1.4 var(--x-mono); }\n.traffic li { display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: 6px; padding: 4px 0; border-bottom: 1px solid var(--x-b1); }\n.traffic .dir { color: var(--x-fg3); }\n\n/* ── accessibility ─────────────────────────────────────── */\n.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }\n.card:focus-visible, .list-row:focus-visible, .lane-row:focus-visible, .door:focus-visible { outline: 2px solid var(--x-accent); outline-offset: 2px; }\n.lane-head .name { border: 0; background: none; padding: 0; text-align: left; font: inherit; font-weight: 600; }\n\n@container explorer (max-width: ${NARROW_WIDTH}px) {\n .system { grid-template-columns: 1fr; gap: 12px; }\n .links { display: none; }\n .diagram { grid-auto-flow: row; grid-auto-columns: auto; }\n}\n.detail ul.warnings { margin: 0; padding: 0 0 0 16px; display: grid; gap: 4px; font: 12px/1.45 var(--x-sans); color: var(--x-fg1); }\n.detail ul.warnings li::marker { color: var(--x-wait); content: \"⚠ \"; }\n\n/* WCAG 2.2 target size: every control is at least 24px tall */\n.chip, .drill, .more { min-height: 24px; }\n.drill, .more { min-width: 24px; }\n/* the state name is the card's / row's primary button: it looks like text */\nbutton.select {\n all: unset; box-sizing: border-box; cursor: pointer; min-height: 24px; display: inline-flex; align-items: center;\n overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1;\n}\nbutton.select:focus-visible { outline: 2px solid var(--x-accent); outline-offset: 2px; border-radius: var(--x-r); }\n\n/* right-to-left pages: disclosure triangles point the other way */\n:host(:dir(rtl)) .twisty { transform: scaleX(-1); }\n`;\n"]}
|
|
1
|
+
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../src/explorer/styles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,CAAC;AACxB,MAAM,CAAC,MAAM,YAAY,GAAG,SAAS,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kCA8WJ,YAAY;;;;;;;;;;;;;;;;;;;;;CAqB7C,CAAC","sourcesContent":["/**\n * Layout and component styles of <scxml-explorer>. Colours, type and shape\n * come from the shared theme (src/ui/theme.ts): the `--scxml-*` token\n * contract with neutral defaults, adopted before this sheet. Below\n * NARROW_WIDTH (shared with the element and `<scxml-view>`) the explorer\n * shows one pane with tabs.\n *\n * One focus, everything else quieter:\n * - colour carries meaning only: `--x-run` is \"active\", `--x-wait` is\n * \"just happened\" (the last step's arrows and the state it left);\n * `--x-accent` is kept for keyboard focus\n * - spacing on a 4 / 8 px scale; type in 11, 12, 13, 15 and 22 px;\n * labels in sentence case, not letter-spaced capitals\n * - hairlines between rows instead of boxes around them\n */\nimport { NARROW_WIDTH } from \"../ui/theme.ts\";\n\nexport { NARROW_WIDTH };\nexport const EXPLORER_CSS = /* css */ `\n:host {\n display: block; container-type: inline-size; container-name: explorer;\n background: var(--x-bg);\n border: 1px solid var(--x-b2); border-radius: var(--x-r); overflow: hidden;\n height: var(--scxml-height, min(860px, calc(100dvh - 32px)));\n}\n[hidden] { display: none !important; }\n\n/* ── shared type: quiet labels, one title, small counts ─── */\n.pane-title, .list-group, .col-title, .section-title, .data-field summary, .ev-group > summary, table.tx th, .actions b, .does .label, .row-detail .label {\n font: 600 11px/1.3 var(--x-sans); letter-spacing: 0; text-transform: none; color: var(--x-fg3);\n}\nh2.title { font-size: 22px; margin: 8px 0 4px; }\nh2.title.small { font: 600 15px/1.3 var(--x-sans); letter-spacing: 0; }\n.subtitle { font: 12px var(--x-sans); color: var(--x-fg3); gap: 8px; margin: 0 0 4px; }\n.section-title { margin: 24px 0 4px; }\n.section-title::after { display: none; }\n.count { font: 11px var(--x-sans); color: var(--x-fg3); }\n.status { font: 12px var(--x-sans); color: var(--x-fg3); }\n.status.active { color: var(--x-run); }\n.spacer { flex: 1; }\n.chip { color: var(--x-fg2); border-color: var(--x-b1); font-size: 12px; }\n.chip:hover { color: var(--x-fg1); border-color: var(--x-strong); background: var(--x-s1); }\n.more { font: 12px var(--x-sans); }\n.more:hover { color: var(--x-fg1); text-decoration: underline; }\n.drill { border: 0; background: none; padding: 0; cursor: pointer; color: var(--x-fg2); font: 12px var(--x-sans); white-space: nowrap; }\n.drill:hover { color: var(--x-fg1); text-decoration: underline; }\n.kind { font: 11px var(--x-mono); color: var(--x-fg3); flex: none; }\n\n/* ── shell: the focus fills it; the panels float over it, like a map's ──\n panels (wide) tree on the left, inspector on the right\n panel one panel on the left: the tree, and the inspector as its second page\n sheet (narrow) the same panel as a bottom sheet: low (head + accepted events), half, full\n Playback sits in the bottom-left corner of what the panels leave free, Follow in the bottom-right. */\n.shell {\n --panel-w: 340px; --panel-w-start: 280px; --panel-w-end: 340px; --gap: 12px;\n position: relative; height: 100%;\n}\n.stage { position: relative; height: 100%; overflow: hidden; }\n.pane { min-height: 0; min-width: 0; display: flex; flex-direction: column; }\n.pane-head { display: flex; align-items: center; gap: 8px; padding: 12px 12px 8px; flex: none; }\n.pane-title { flex: 1; }\n.pane-scroll { overflow: auto; min-height: 0; flex: 1; overscroll-behavior: contain; }\n.center { position: absolute; inset: 0; background: var(--x-bg); }\n/* the focus keeps its content clear of the panels and the corners */\n.center .pane-scroll { padding: 16px 24px 72px; }\n.shell[data-layout=\"panels\"] .center .pane-scroll {\n padding-left: calc(var(--panel-w-start) + 2 * var(--gap) + 12px); padding-right: calc(var(--panel-w-end) + 2 * var(--gap) + 12px);\n}\n.shell[data-layout=\"panels\"][data-level=\"system\"] .center .pane-scroll { padding-left: 24px; }\n.shell[data-layout=\"panel\"] .center .pane-scroll { padding-left: calc(var(--panel-w) + 2 * var(--gap) + 12px); }\n.shell[data-layout=\"sheet\"] .center .pane-scroll { padding: 12px 12px calc(var(--sheet-h, 88px) + 64px); }\n\n/* ── panels: solid, a hairline and a soft edge, inset like the corners ── */\n.panel {\n position: absolute; z-index: 2; box-sizing: border-box; display: flex; flex-direction: column; min-height: 0; overflow: hidden;\n background: var(--x-s1); border: 1px solid var(--x-b2); border-radius: calc(var(--x-r) + 4px);\n box-shadow: 0 1px 3px color-mix(in srgb, var(--x-fg1) 14%, transparent);\n}\n.shell[data-layout=\"panels\"] .panel { top: var(--gap); bottom: var(--gap); left: var(--gap); width: var(--panel-w-start); }\n.shell[data-layout=\"panels\"] .side-panel { left: auto; right: var(--gap); width: var(--panel-w-end); }\n/* the System level has no tree: with two panels, the left one has nothing to show */\n.shell[data-layout=\"panels\"][data-level=\"system\"] .panel:not(.side-panel) { display: none; }\n.shell:not([data-layout=\"panels\"]) .side-panel { display: none; }\n.shell[data-layout=\"panel\"] .panel { top: var(--gap); bottom: var(--gap); left: var(--gap); width: var(--panel-w); }\n.panel-head {\n display: flex; align-items: center; gap: 4px 8px; flex-wrap: wrap; flex: none; padding: 8px 12px;\n border-bottom: 1px solid var(--x-b1);\n}\n.panel-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }\n.panel-body > .pane, .side-panel > .pane { flex: 1; }\n.mode { display: inline-flex; gap: 2px; flex: none; }\n.mode button, .scopes button {\n border: 0; background: none; padding: 2px 8px; min-height: 24px; border-radius: var(--x-r); cursor: pointer;\n font: 500 12px var(--x-sans); color: var(--x-fg3);\n}\n.mode button:hover, .scopes button:hover { color: var(--x-fg1); }\n.mode button[aria-pressed=\"true\"], .scopes button[aria-pressed=\"true\"] { background: var(--x-s3); color: var(--x-fg1); }\n.crumbs { display: flex; align-items: center; gap: 2px; min-width: 0; flex: 1 1 100%; overflow-x: auto; scrollbar-width: none; }\n.crumbs button { border: 0; background: none; padding: 2px 4px; min-height: 24px; border-radius: var(--x-r); cursor: pointer; color: var(--x-fg3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 22ch; }\n.crumbs button:hover { background: var(--x-s2); color: var(--x-fg1); }\n.crumbs button[aria-current] { color: var(--x-fg1); font-weight: 600; }\n.crumbs .sep { color: var(--x-fg4); flex: none; }\n\n/* one panel: a page at a time, with links between them */\n.shell:not([data-layout=\"panels\"])[data-page=\"tree\"] .panel-body .inspector,\n.shell:not([data-layout=\"panels\"])[data-page=\"inspector\"] .panel-body .tree-pane { display: none; }\n.shell[data-level=\"system\"] .tree-pane { display: none; }\n.to-inspector, .back { border: 0; background: none; padding: 2px 6px; min-height: 24px; border-radius: var(--x-r); cursor: pointer; font: 500 12px var(--x-sans); color: var(--x-fg2); white-space: nowrap; }\n.to-inspector:hover, .back:hover { background: var(--x-s2); color: var(--x-fg1); }\n.page-back { padding: 8px 8px 0; }\n.shell[data-layout=\"panels\"] .to-inspector, .shell[data-layout=\"panels\"] .page-back { display: none; }\n\n/* ── the sheet (narrow) ── */\n.sheet-handle { display: none; }\n.events-strip { display: none; }\n.shell[data-layout=\"sheet\"] .panel {\n left: 0; right: 0; bottom: 0; height: 88px; border-bottom: 0; border-radius: 12px 12px 0 0; transition: height var(--x-dur);\n}\n.shell[data-layout=\"sheet\"] .panel.dragging { transition: none; }\n.shell[data-layout=\"sheet\"][data-sheet=\"half\"] .panel { height: 50%; }\n.shell[data-layout=\"sheet\"][data-sheet=\"full\"] .panel { height: calc(100% - 8px); }\n.shell[data-layout=\"sheet\"] .sheet-handle {\n display: grid; place-items: center; flex: none; width: 100%; height: 22px; padding: 0; border: 0; background: none; cursor: grab; touch-action: none;\n}\n.shell[data-layout=\"sheet\"] .sheet-handle::before { content: \"\"; width: 36px; height: 5px; border-radius: 3px; background: var(--x-b2); }\n.shell[data-layout=\"sheet\"] .sheet-handle:focus-visible { outline: 2px solid var(--x-accent); outline-offset: -2px; }\n.shell[data-layout=\"sheet\"] .panel-head { padding-top: 0; touch-action: none; }\n.shell[data-layout=\"sheet\"] .crumbs button { max-width: 14ch; }\n/* low: its head and the accepted events, nothing else */\n.shell[data-layout=\"sheet\"][data-sheet=\"low\"] .panel-body { display: none; }\n.shell[data-layout=\"sheet\"][data-sheet=\"low\"] .events-strip {\n display: flex; gap: 4px; padding: 8px 12px; min-width: 0; overflow-x: auto; scrollbar-width: none;\n}\n.events-strip > * { flex: none; max-width: 70vw; }\n\n/* ── corners: playback (bottom left) and Follow (bottom right), clear of the panels ── */\n.corner { position: absolute; z-index: 3; bottom: var(--gap); }\n.corner-start { left: var(--gap); }\n.corner-end { right: var(--gap); }\n.shell[data-layout=\"panels\"]:not([data-level=\"system\"]) .corner-start { left: calc(var(--panel-w-start) + 2 * var(--gap)); }\n.shell[data-layout=\"panels\"] .corner-end { right: calc(var(--panel-w-end) + 2 * var(--gap)); }\n.shell[data-layout=\"panel\"] .corner-start { left: calc(var(--panel-w) + 2 * var(--gap)); }\n.shell[data-layout=\"sheet\"] .corner { bottom: calc(var(--sheet-h, 88px) + var(--gap)); }\n.playback, .follow {\n box-sizing: border-box; height: 36px; display: flex; align-items: center; gap: 2px; padding: 0 3px;\n background: var(--x-s1); border: 1px solid var(--x-b2); border-radius: 999px;\n box-shadow: 0 1px 2px color-mix(in srgb, var(--x-fg1) 12%, transparent);\n}\n.playback .play, .playback .step, .playback .speeds {\n height: 30px; padding: 0 10px; border: 0; border-radius: 999px; background: none; cursor: pointer; font: 500 12px var(--x-sans); color: var(--x-fg1);\n}\n.playback .play { color: var(--x-accent-fg); }\n.playback .play:hover, .playback .step:hover:not(:disabled), .playback .speeds:hover { background: var(--x-s2); }\n.playback .step:disabled { opacity: .45; cursor: default; }\n.playback .speeds { padding: 0 6px; }\n.playback .clock-time { font: 12px var(--x-mono); color: var(--x-fg3); font-variant-numeric: tabular-nums; min-width: 9ch; padding: 0 10px 0 4px; cursor: help; }\n.follow { gap: 6px; padding: 0 14px 0 11px; cursor: pointer; color: var(--x-fg2); font: 500 12px var(--x-sans); }\n.follow:hover { color: var(--x-fg1); background: var(--x-s2); }\n.follow .icon { display: block; flex: none; }\n.follow[aria-pressed=\"true\"] { color: var(--x-run); }\n.follow:focus-visible, .playback button:focus-visible, .playback select:focus-visible { outline: 2px solid var(--x-accent); outline-offset: 1px; }\n/* the sheet: Follow is its crosshair, centred (its name stays its accessible name), so both corners fit a phone */\n.shell[data-layout=\"sheet\"] .follow { width: 36px; padding: 0; justify-content: center; }\n.shell[data-layout=\"sheet\"] .follow-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }\n@media (pointer: coarse) {\n .playback, .follow { height: 44px; }\n .shell[data-layout=\"sheet\"] .follow { width: 44px; }\n .playback .play, .playback .step, .playback .speeds { height: 40px; }\n}\n@media (prefers-reduced-motion: reduce) { .shell[data-layout=\"sheet\"] .panel { transition: none; } }\n.inspector, .tree-pane { background: none; }\n\n/* ── the title row: the breadcrumb (places above) over the focus's name, then its controls ── */\n.title-row { display: flex; align-items: flex-end; gap: 8px 12px; flex-wrap: wrap; margin-bottom: 12px; }\n.place { flex: 1 1 auto; min-width: 0; }\n.place .crumbs { flex: none; margin-bottom: 2px; }\n.place .crumbs .sep:last-child { display: none; }\n.place h2.title { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.mode .icon-toggle, .filter {\n display: inline-grid; place-items: center; width: 30px; height: 28px; padding: 0; border: 0; border-radius: var(--x-r);\n background: none; color: var(--x-fg3); cursor: pointer;\n}\n.mode .icon-toggle:hover, .filter:hover { color: var(--x-fg1); background: var(--x-s2); }\n.mode .icon-toggle[aria-pressed=\"true\"], .filter[aria-pressed=\"true\"] { color: var(--x-fg1); background: var(--x-s3); }\n.mode .icon-toggle:focus-visible, .filter:focus-visible { outline: 2px solid var(--x-accent); outline-offset: 1px; }\n.search { display: flex; align-items: center; gap: 4px; }\n/* a container's size: the layers glyph and the number; the way inside */\n.drill.inside { display: inline-flex; align-items: center; gap: 4px; color: var(--x-fg3); font: 12px var(--x-sans); font-variant-numeric: tabular-nums; }\n.drill.inside:hover { color: var(--x-fg1); text-decoration: none; }\n.row-head .does-glyphs, .card .does-glyphs { margin-left: auto; }\n.row-head .does-glyphs + .drill.inside { margin-left: 12px; }\n.tx .glyph-diamond, .how .glyph-diamond { color: var(--x-fg3); }\n.guard .glyph { margin-right: 4px; }\n.playback .play, .playback .step { display: inline-grid; place-items: center; min-width: 32px; padding: 0 8px; }\n\n/* ── tree (windowed) ───────────────────────────────────── */\n.tree-viewport { position: relative; }\n.tree-row {\n position: absolute; left: 0; right: 0; height: var(--x-row); display: flex; align-items: center; gap: 4px;\n padding-right: 8px; cursor: pointer; white-space: nowrap; border-left: 2px solid transparent; color: var(--x-fg2);\n}\n.tree-row:hover { background: var(--x-s2); color: var(--x-fg1); }\n.tree-row[aria-selected=\"true\"] { background: var(--x-s2); color: var(--x-fg1); border-left-color: var(--x-fg3); }\n.tree-row .twisty { width: 16px; height: 16px; flex: none; border: 0; background: none; padding: 0; cursor: pointer; color: var(--x-fg3); font-size: 10px; }\n.tree-row .twisty[hidden] { visibility: hidden; display: inline-block !important; }\n.tree-row .name { overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }\n.tree-row.path { color: var(--x-fg1); }\n.tree-row.path .name { font-weight: 600; }\n.tree-row.active { border-left-color: var(--x-run); }\n.tree-row.active .name { color: var(--x-run); }\n.tree-row.match .name { text-decoration: underline; text-decoration-color: var(--x-fg3); text-underline-offset: 3px; }\n.tree-row:focus-visible { outline-offset: -2px; }\n\n/* ── focus ─────────────────────────────────────────────── */\n.diagram { position: relative; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(150px, 230px); justify-content: start; gap: 24px 128px; align-items: start; padding: 8px 0 8px 16px; }\n.rank { display: flex; flex-direction: column; gap: 16px; }\n.edges { position: absolute; inset: 0; pointer-events: none; overflow: visible; }\n.edges path { fill: none; stroke: var(--x-fg4); stroke-width: 1.25; }\n.edges path.live { stroke: var(--x-run); stroke-width: 1.5; }\n.edges path.fired { stroke: var(--x-wait); stroke-width: 2; }\n.edges path.back { stroke-dasharray: 4 3; }\n.edges marker path { fill: context-stroke; stroke: none; }\n.edge-label {\n position: absolute; transform: translate(-50%, -50%); z-index: 1; pointer-events: auto;\n font: 11px/1.3 var(--x-mono); background: var(--x-bg); color: var(--x-fg3); padding: 1px 4px; border-radius: var(--x-r); white-space: nowrap; max-width: 120px; overflow: hidden; text-overflow: ellipsis; cursor: help;\n}\n.edge-label.live { color: var(--x-fg1); }\n.edge-label.fired { color: var(--x-wait); }\n/* labels that found no free spot collapse to their event count and open on hover / focus */\n.edge-label .short { display: none; }\n.edge-label.collapsed .full { display: none; }\n.edge-label.collapsed .short { display: inline; }\n.edge-label.collapsed:is(:hover, :focus-visible) { z-index: 3; max-width: 240px; }\n.edge-label.collapsed:is(:hover, :focus-visible) .full { display: inline; }\n.edge-label.collapsed:is(:hover, :focus-visible) .short { display: none; }\n\n.card {\n position: relative; background: var(--x-s1); border: 1px solid var(--x-b2); border-radius: var(--x-r);\n padding: 8px 12px; display: grid; gap: 4px; cursor: pointer; transition: border-color var(--x-dur), background var(--x-dur);\n}\n.card:hover { border-color: var(--x-strong); }\n.card.path { border-color: var(--x-run); }\n.card.active { background: var(--x-run-bg); box-shadow: inset 0 0 0 1px var(--x-run); }\n.card.visited { border-style: dashed; border-color: var(--x-wait); }\n.card.final { border-radius: 999px; border-style: double; border-width: 3px; padding: 4px 16px; }\n.card.selected { outline: 2px solid var(--x-fg3); outline-offset: 2px; }\n.card-head { display: flex; align-items: center; gap: 8px; min-width: 0; }\n.card-head .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }\n.card.path .card-head .name { color: var(--x-run); }\n.card .meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; color: var(--x-fg3); font-size: 12px; }\n.card .meta .status { color: var(--x-run); }\n.initial-mark { position: absolute; left: -13px; top: 13px; width: 8px; height: 8px; border-radius: 50%; background: var(--x-fg1); }\n.initial-mark::after { content: \"\"; position: absolute; left: 8px; top: 3.5px; width: 5px; border-top: 1.5px solid var(--x-fg1); }\n\n.lanes { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }\n.lane { border: 1px solid var(--x-b1); border-radius: var(--x-r); background: var(--x-s1); padding: 8px 12px; min-width: 0; }\n.lane-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }\n.lane-head .name { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; min-height: 24px; }\n.lane-row { display: flex; align-items: center; gap: 8px; min-height: 28px; padding: 0 8px; margin: 0 -8px; border-left: 2px solid transparent; cursor: pointer; color: var(--x-fg2); }\n.lane-row:hover { background: var(--x-s2); color: var(--x-fg1); }\n.lane-row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.lane-row.active { border-left-color: var(--x-run); }\n.lane-row.active .name { color: var(--x-run); font-weight: 600; }\n.lane-row.visited { border-left: 2px dashed var(--x-wait); }\n\n/* the list: one row per state, hairlines between */\n.list { display: grid; }\n.list-group { padding: 16px 0 4px; }\n.list-group:first-child { padding-top: 0; }\n.list-row {\n display: grid; gap: 4px; padding: 8px 12px; cursor: pointer; min-width: 0;\n border-left: 2px solid transparent; border-top: 1px solid var(--x-b1);\n}\n.list-group + .list-row { border-top-color: transparent; }\n.list-row:hover { background: var(--x-s2); }\n.list-row.path { border-left-color: var(--x-run); }\n.list-row.active { background: color-mix(in srgb, var(--x-run-bg) 70%, transparent); }\n.list-row.visited { border-left: 2px dashed var(--x-wait); }\n.list-row.open { background: var(--x-s1); }\n.row-head { display: flex; align-items: center; gap: 8px; min-width: 0; }\n.list-row .name { font-weight: 500; }\n.list-row .name[aria-expanded]::after { content: \"▸\"; font-size: 10px; color: var(--x-fg3); margin-left: 8px; transition: transform var(--x-dur); }\n.list-row .name[aria-expanded=\"true\"]::after { transform: rotate(90deg); }\n.list-row.path .name { color: var(--x-run); font-weight: 600; }\n.row-head .drill { margin-left: auto; }\n.visited-mark { font: 11px var(--x-sans); color: var(--x-wait); white-space: nowrap; }\n.does { font: 12px var(--x-mono); color: var(--x-fg2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.exits { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; font-size: 12px; min-width: 0; }\n.exits.all { flex-direction: column; align-items: flex-start; }\n.tx { display: inline-flex; align-items: baseline; gap: 4px; min-width: 0; max-width: 100%; color: var(--x-fg3); }\n/* the events shrink (their namespaces are cut from the left), the target never */\n.tx .ev { display: inline-flex; align-items: baseline; gap: 6px; flex: 0 1 auto; font: 12px var(--x-mono); color: var(--x-fg1); min-width: 0; overflow: hidden; white-space: nowrap; }\n.tx.auto .ev { font-family: var(--x-sans); font-style: italic; color: var(--x-fg3); }\n.tx .to { flex: none; white-space: nowrap; }\n.tx .guard { font: italic 11px var(--x-mono); color: var(--x-fg3); overflow-wrap: anywhere; }\n.tx.fired .ev, .tx.fired .to { color: var(--x-wait); }\n.tx-item { display: inline-flex; min-width: 0; max-width: 100%; }\n/* while the state is active its events can be sent from the row */\nbutton.tx {\n align-items: center; min-height: 24px; padding: 0 8px; border: 1px solid color-mix(in srgb, var(--x-run) 45%, var(--x-b2)); border-radius: 999px;\n background: var(--x-s1); cursor: pointer; font: 12px var(--x-sans);\n}\nbutton.tx:hover { background: var(--x-run-bg); border-color: var(--x-run); }\nbutton.tx.fired { border-color: var(--x-wait); }\n.row-detail { display: grid; gap: 8px; justify-items: start; padding-top: 4px; cursor: auto; }\n.row-detail .from { margin: 0; font-size: 12px; color: var(--x-fg2); }\n\n.doors { display: grid; }\n.doors { margin-top: 16px; }\n.door {\n display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 0 8px; align-items: center;\n padding: 8px 12px; border-top: 1px solid var(--x-b1); cursor: pointer; color: var(--x-fg2);\n}\n.door:first-child { border-top-color: transparent; }\n.door:hover { background: var(--x-s2); color: var(--x-fg1); }\n.door .where { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.door.live .where { color: var(--x-fg1); }\n.door .glyph { color: var(--x-fg3); }\n.door .events { display: inline-flex; align-items: center; gap: 4px; justify-content: flex-end; font: 12px var(--x-mono); color: var(--x-fg3); min-width: 0; overflow: hidden; white-space: nowrap; max-width: 28ch; }\n\n/* ── events ────────────────────────────────────────────── */\n.scopes { display: flex; gap: 4px; padding: 0 12px 8px; flex-wrap: wrap; }\n.ev-group > summary { display: flex; align-items: center; gap: 8px; list-style: none; cursor: pointer; padding: 8px 12px; color: var(--x-fg2); border-top: 1px solid var(--x-b1); }\n.ev-group > summary::-webkit-details-marker { display: none; }\n.ev-group[open] > summary::before { transform: rotate(90deg); }\n.ev-group > summary .count { margin-left: auto; }\n.ev-row { display: grid; gap: 2px; padding: 4px 12px 8px 24px; justify-items: start; }\n.ev-row:hover { background: var(--x-s2); }\n/* the event's name is its send button */\n.ev-row .ev {\n max-width: 100%; min-height: 24px; padding: 0 8px; border: 1px solid var(--x-b2); border-radius: 999px; background: var(--x-s1);\n font: 500 12px var(--x-mono); color: var(--x-fg1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer;\n}\n.ev-row .ev:hover:not(:disabled) { border-color: var(--x-run); background: var(--x-run-bg); }\n.ev-row .ev:disabled { cursor: default; color: var(--x-fg3); border-style: dashed; }\n.ev-row.scope-elsewhere .ev { color: var(--x-fg2); border-style: dashed; }\n.ev-row .how { max-width: 100%; color: var(--x-fg3); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.ev-row .how .guard { font: italic 11px var(--x-mono); }\n.data-field { padding: 0 12px 8px; }\n.data-field summary { cursor: pointer; width: max-content; min-height: 24px; display: flex; align-items: center; gap: 8px; list-style: none; }\n.data-field summary::-webkit-details-marker { display: none; }\n.data-field summary::before, .data-field[open] summary::before { transform: rotate(90deg); }\n.data-field input { width: 100%; height: 28px; margin-top: 4px; padding: 0 8px; font: 12px var(--x-mono); border: 1px solid var(--x-b2); border-radius: var(--x-r); background: var(--x-s1); color: var(--x-fg1); }\n\n/* ── detail ────────────────────────────────────────────── */\n.detail { padding: 0 12px 16px; }\n.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; font-size: 12px; margin: 0; }\n.kv dt { color: var(--x-fg3); }\n.kv dd { margin: 0; font-family: var(--x-mono); overflow-wrap: anywhere; }\ntable.tx { width: 100%; border-collapse: collapse; font-size: 12px; }\ntable.tx th { text-align: left; padding: 4px; border-bottom: 1px solid var(--x-b2); position: sticky; top: 0; background: var(--x-s1); }\ntable.tx td { padding: 4px; border-bottom: 1px solid var(--x-b1); vertical-align: top; }\ntable.tx td.ev { font-family: var(--x-mono); overflow-wrap: anywhere; }\ntable.tx td.cond { font: italic 11px var(--x-mono); color: var(--x-fg3); overflow-wrap: anywhere; }\ntable.tx td.to { overflow-wrap: anywhere; }\n.actions { margin: 0; padding: 0; list-style: none; font: 12px var(--x-mono); color: var(--x-fg2); display: grid; gap: 4px; }\n.actions b { margin-right: 8px; }\n\n/* ── system ────────────────────────────────────────────── */\n.system { position: relative; display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 16px 72px; align-items: start; }\n.system .col { display: grid; gap: 8px; align-content: start; min-width: 0; }\n.machine { margin-left: calc(var(--depth, 0) * 16px); }\n.card.machine.path { border-color: var(--x-b2); }\n.card.machine.path .card-head .name { color: var(--x-fg1); }\n.machine.compact { grid-template-columns: minmax(0, 1fr) minmax(0, 40%); align-items: center; padding: 4px 12px; }\n.machine.compact .leaves { text-align: right; }\n.machine .leaves { font: 12px var(--x-mono); color: var(--x-run); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.machine .from { color: var(--x-fg3); font-size: 12px; }\n.links { position: absolute; inset: 0; pointer-events: none; overflow: visible; }\n.links path { fill: none; stroke: var(--x-b2); stroke-width: 1.25; }\n.links path.invoke { stroke: var(--x-fg4); stroke-dasharray: 3 3; }\n.links path.hot { stroke: var(--x-wait); stroke-width: 2; }\n.talks { display: flex; gap: 4px; flex-wrap: wrap; }\n.pulse { animation: pulse 1.2s ease-out; }\n@keyframes pulse { from { box-shadow: 0 0 0 0 color-mix(in srgb, var(--x-wait) 45%, transparent); } to { box-shadow: 0 0 0 8px transparent; } }\n.traffic { list-style: none; margin: 0; padding: 0; font: 12px/1.4 var(--x-mono); }\n.traffic li { display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--x-b1); }\n.traffic .dir { color: var(--x-fg3); }\n\n/* ── accessibility ─────────────────────────────────────── */\n.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }\n.card:focus-visible, .list-row:focus-visible, .lane-row:focus-visible, .door:focus-visible { outline: 2px solid var(--x-accent); outline-offset: 2px; }\n.lane-head .name { border: 0; background: none; padding: 0; text-align: left; font: inherit; font-weight: 600; }\n\n@container explorer (max-width: ${NARROW_WIDTH}px) {\n .system { grid-template-columns: 1fr; gap: 12px; }\n .links { display: none; }\n .diagram { grid-auto-flow: row; grid-auto-columns: auto; }\n}\n.detail ul.warnings { margin: 0; padding: 0 0 0 16px; display: grid; gap: 4px; font: 12px/1.45 var(--x-sans); color: var(--x-fg1); }\n.detail ul.warnings li::marker { color: var(--x-wait); content: \"⚠ \"; }\n\n/* WCAG 2.2 target size: every control is at least 24px tall */\n.chip, .drill, .more { min-height: 24px; }\n.drill, .more { min-width: 24px; }\n/* the state name is the card's / row's primary button: it looks like text */\nbutton.select {\n all: unset; box-sizing: border-box; cursor: pointer; min-height: 24px; display: inline-flex; align-items: center;\n overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 0 1 auto;\n}\n.card button.select { flex: 1; }\nbutton.select:focus-visible { outline: 2px solid var(--x-accent); outline-offset: 2px; border-radius: var(--x-r); }\n\n/* right-to-left pages: disclosure triangles point the other way */\n:host(:dir(rtl)) .twisty { transform: scaleX(-1); }\n`;\n"]}
|
package/dist/explorer.d.ts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/model.d.ts
CHANGED
|
@@ -119,7 +119,8 @@ export declare class SCXMLValidationError extends Error {
|
|
|
119
119
|
export declare class SCXMLParseError extends Error {
|
|
120
120
|
readonly code: "SCXML_PARSE" | "SCXML_NO_DOMPARSER";
|
|
121
121
|
/**
|
|
122
|
-
* @param code `SCXML_PARSE`: the text isn't well-formed XML (or has no `<scxml>` root)
|
|
122
|
+
* @param code `SCXML_PARSE`: the text isn't well-formed XML (or has no `<scxml>` root), or the
|
|
123
|
+
* `DOMParser` doesn't implement XML namespaces;
|
|
123
124
|
* `SCXML_NO_DOMPARSER`: there is no `DOMParser` (outside browsers: pass `domParser`).
|
|
124
125
|
*/
|
|
125
126
|
constructor(code: "SCXML_PARSE" | "SCXML_NO_DOMPARSER", message: string);
|
|
@@ -151,6 +152,8 @@ export declare function scxmlChildren(el: Element, ns: string | null): Element[]
|
|
|
151
152
|
/**
|
|
152
153
|
* Compile an `<scxml>` element. `src` attributes on `<script>` and `<data>`
|
|
153
154
|
* are fetched with `loader`; the result is synchronous when the loader is.
|
|
155
|
+
*
|
|
156
|
+
* @throws {TypeError} when given text: parse it first with `parseSCXML()`.
|
|
154
157
|
*/
|
|
155
158
|
export declare function compile(root: Element, opts?: {
|
|
156
159
|
loader?: Loader;
|
package/dist/model.js
CHANGED
|
@@ -25,7 +25,8 @@ export class SCXMLValidationError extends Error {
|
|
|
25
25
|
export class SCXMLParseError extends Error {
|
|
26
26
|
code;
|
|
27
27
|
/**
|
|
28
|
-
* @param code `SCXML_PARSE`: the text isn't well-formed XML (or has no `<scxml>` root)
|
|
28
|
+
* @param code `SCXML_PARSE`: the text isn't well-formed XML (or has no `<scxml>` root), or the
|
|
29
|
+
* `DOMParser` doesn't implement XML namespaces;
|
|
29
30
|
* `SCXML_NO_DOMPARSER`: there is no `DOMParser` (outside browsers: pass `domParser`).
|
|
30
31
|
*/
|
|
31
32
|
constructor(code, message) {
|
|
@@ -66,8 +67,13 @@ export function scxmlChildren(el, ns) {
|
|
|
66
67
|
/**
|
|
67
68
|
* Compile an `<scxml>` element. `src` attributes on `<script>` and `<data>`
|
|
68
69
|
* are fetched with `loader`; the result is synchronous when the loader is.
|
|
70
|
+
*
|
|
71
|
+
* @throws {TypeError} when given text: parse it first with `parseSCXML()`.
|
|
69
72
|
*/
|
|
70
73
|
export function compile(root, opts = {}) {
|
|
74
|
+
if (typeof root === "string")
|
|
75
|
+
throw new TypeError("compile() takes the parsed <scxml> Element, not SCXML text: parse it first with parseSCXML(text, domParser), " +
|
|
76
|
+
"or pass the text to createSession()");
|
|
71
77
|
const model = build(root);
|
|
72
78
|
const pending = [];
|
|
73
79
|
for (const el of [...model.scripts, ...scriptsIn(model), ...model.allData]) {
|
package/dist/model.js.map
CHANGED
|
@@ -1 +1 @@
|
|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AE,GAAG,CAAC;wBAAE,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC;oBACtD,IAAI,GAAG,IAAI,GAAG,CAAC,IAAI,KAAK,UAAU;wBAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,KAAK,cAAc,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,EAAE,6BAA6B,CAAC,CAAC;gBAC3H,CAAC;YACH,CAAC;IACL,CAAC;IAED,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,KAAK,QAAQ,CAAC,CAAC;IACrE,IAAI,QAAQ,CAAC,MAAM;QAAE,MAAM,IAAI,oBAAoB,CAAC,QAAQ,CAAC,CAAC;IAE9D,MAAM,KAAK,GAAU;QACnB,EAAE;QACF,IAAI;QACJ,MAAM;QACN,IAAI;QACJ,SAAS;QACT,oBAAoB;QACpB,IAAI,EAAE,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,EAAE;QACvC,OAAO,EAAE,OAAO,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO;QAC9C,OAAO;QACP,OAAO;QACP,SAAS,EAAE,IAAI,GAAG,EAAE;QACpB,QAAQ,EAAE,EAAE;KACb,CAAC;IACF,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;IAC7B,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,UAAU,CAAC,EAAW;IAC7B,OAAO,EAAE,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC;AAC5E,CAAC","sourcesContent":["/**\n * Compiles an `<scxml>` DOM element into an immutable, validated model.\n *\n * The model keeps a reference to every source element, so renderers can map\n * live state back onto the document. Validation follows the constraints of\n * spec §3 (ids, targets, initial states, history, executable content);\n * a non-conformant document raises `SCXMLValidationError` listing every problem.\n */\nimport { type Diagnostic, lint } from \"./diagnostics.ts\";\nimport { SCXML_NS } from \"./events.ts\";\n\n/** The element a state node was compiled from (`scxml` is the root). */\nexport type StateKind = \"scxml\" | \"state\" | \"parallel\" | \"final\" | \"history\";\n\n/**\n * A state of a compiled chart. Every node keeps its source `element`, so\n * renderers can map live state back onto the document.\n */\nexport interface StateNode {\n /** Which element it is. */\n kind: StateKind;\n /** The `id` attribute, or a generated one (see `generatedId`). */\n id: string;\n /** True when the author omitted `id` and one was generated (spec §3.14). */\n generatedId: boolean;\n /** The source element (`<state>`, `<parallel>`, …). */\n element: Element;\n /** The containing state; `null` for the root. */\n parent: StateNode | null;\n /** `<state>`, `<parallel>` and `<final>` children — spec `getChildStates`. */\n children: StateNode[];\n /** `<history>` children. */\n history: StateNode[];\n /** Document order. */\n order: number;\n /** Nesting depth: the root is 0. */\n depth: number;\n /** Its `<transition>`s, in document order. */\n transitions: TransitionNode[];\n /** Each `<onentry>` / `<onexit>` element is a separate executable block. */\n onentry: Element[];\n /** The `<onexit>` blocks, in document order. */\n onexit: Element[];\n /** Its `<invoke>`s, in document order. */\n invokes: InvokeNode[];\n /** `<data>` elements of this state's own `<datamodel>`. */\n data: Element[];\n /** Initial transition, for compound states and `<scxml>`. */\n initial: TransitionNode | null;\n /** For `<history>` nodes: whether it remembers only direct children (`shallow`) or the full descendant configuration (`deep`). */\n historyType?: \"shallow\" | \"deep\";\n /** For `<final>` states: the `<donedata>` element, if any. */\n donedata: Element | null;\n}\n\n/** A transition of a compiled chart. */\nexport interface TransitionNode {\n /** `null` for initial transitions synthesised from an `initial` attribute or default. */\n element: Element | null;\n /** The state it belongs to. */\n source: StateNode;\n /** The event descriptors of the `event` attribute (empty for eventless transitions). */\n events: string[];\n /** The `cond` expression, or `null`. */\n cond: string | null;\n /** The targets (empty for targetless transitions). */\n targets: StateNode[];\n /** The `type` attribute: `internal` doesn't exit its source state when the targets are its descendants. */\n type: \"internal\" | \"external\";\n /** Document order. */\n order: number;\n}\n\n/** An `<invoke>` of a compiled chart. */\nexport interface InvokeNode {\n /** The `<invoke>` element. */\n element: Element;\n /** The state it belongs to (invoked while that state is active). */\n state: StateNode;\n /** Document order. */\n order: number;\n /** The `autoforward` attribute: external events are forwarded to the invoked service. */\n autoforward: boolean;\n /** The `<finalize>` element, if any. */\n finalize: Element | null;\n}\n\n/** A compiled, validated chart. Sessions only read it, so one model can serve many sessions. */\nexport interface Model {\n /** The SCXML namespace the document uses. */\n ns: string | null;\n /** The `<scxml>` element's node. */\n root: StateNode;\n /** All states (including history and the root) in document order. */\n states: StateNode[];\n /** States by id (generated ids included). */\n byId: Map<string, StateNode>;\n /** States by source element. */\n byElement: Map<Element, StateNode>;\n /** Transitions by source `<transition>` element. */\n transitionsByElement: Map<Element, TransitionNode>;\n /** The `<scxml name>` attribute (`\"\"` when absent). */\n name: string;\n /** The `binding` attribute: when `<data>` is initialised. */\n binding: \"early\" | \"late\";\n /** `<script>` children of `<scxml>`. */\n scripts: Element[];\n /** Every `<data>` element, document order. */\n allData: Element[];\n /** Pre-loaded `src` contents for `<script src>` and `<data src>` (value: text, or an Error). */\n resources: Map<Element, string | Error>;\n /** Likely mistakes that are still valid SCXML (see `Diagnostic`); empty for most charts. */\n warnings: Diagnostic[];\n}\n\n/** The document isn't valid SCXML. `problems` lists every problem found. */\nexport class SCXMLValidationError extends Error {\n /** Always `\"SCXML_INVALID\"`. */\n readonly code = \"SCXML_INVALID\" as const;\n /** Every problem found, one line each (they are also listed in `message`). */\n readonly problems: string[];\n /** @param problems every problem found, one line each */\n constructor(problems: string[]) {\n super(`Invalid SCXML document:\\n - ${problems.join(\"\\n - \")}`);\n this.problems = problems;\n this.name = \"SCXMLValidationError\";\n }\n}\n\n/** SCXML text couldn't be parsed (or there is no `DOMParser` to parse it with). */\nexport class SCXMLParseError extends Error {\n /**\n * @param code `SCXML_PARSE`: the text isn't well-formed XML (or has no `<scxml>` root);\n * `SCXML_NO_DOMPARSER`: there is no `DOMParser` (outside browsers: pass `domParser`).\n */\n constructor(\n readonly code: \"SCXML_PARSE\" | \"SCXML_NO_DOMPARSER\",\n message: string,\n ) {\n super(message);\n this.name = \"SCXMLParseError\";\n }\n}\n\n/** Resolves `src` attributes (`<script>`, `<data>`, `<invoke>`) to their text; may be synchronous. */\nexport type Loader = (src: string) => string | Promise<string>;\n\nconst EXECUTABLE = new Set([\"raise\", \"if\", \"elseif\", \"else\", \"foreach\", \"log\", \"assign\", \"script\", \"send\", \"cancel\"]);\n\n// ─────────────────────────────── queries ───────────────────────────────\n\n/** A state without child states (or a `<final>`). */\nexport const isAtomic = (s: StateNode) => s.kind === \"final\" || (s.kind === \"state\" && s.children.length === 0);\n/** A `<state>` with child states. */\nexport const isCompound = (s: StateNode) => s.kind === \"state\" && s.children.length > 0;\nexport const isCompoundOrRoot = (s: StateNode) => s.kind === \"scxml\" || isCompound(s);\n\n/** True when `a` is a proper descendant of `b`. */\nexport function isDescendant(a: StateNode, b: StateNode): boolean {\n for (let p = a.parent; p; p = p.parent) if (p === b) return true;\n return false;\n}\n\n/** Ancestors of `s` up to (excluding) `upTo`; with `upTo = null`, up to and including the root. */\nexport function properAncestors(s: StateNode, upTo: StateNode | null): StateNode[] {\n const out: StateNode[] = [];\n for (let p = s.parent; p && p !== upTo; p = p.parent) out.push(p);\n return out;\n}\n\n/** A comparator for `Array.sort`: document order. */\nexport const documentOrder = (a: { order: number }, b: { order: number }) => a.order - b.order;\nexport const exitOrder = (a: { order: number }, b: { order: number }) => b.order - a.order;\n\n/** SCXML-namespace child elements (foreign elements are ignored everywhere). */\nexport function scxmlChildren(el: Element, ns: string | null): Element[] {\n return Array.from(el.children).filter((c) => c.namespaceURI === ns);\n}\n\n// ─────────────────────────────── compile ───────────────────────────────\n\n/**\n * Compile an `<scxml>` element. `src` attributes on `<script>` and `<data>`\n * are fetched with `loader`; the result is synchronous when the loader is.\n */\nexport function compile(root: Element, opts: { loader?: Loader } = {}): Model | Promise<Model> {\n const model = build(root);\n const pending: Promise<void>[] = [];\n for (const el of [...model.scripts, ...scriptsIn(model), ...model.allData]) {\n const src = el.getAttribute(\"src\");\n if (src == null) continue;\n if (!opts.loader) {\n model.resources.set(el, new Error(`no loader to fetch \"${src}\"`));\n continue;\n }\n try {\n const r = opts.loader(src);\n if (typeof r === \"string\") model.resources.set(el, r);\n else\n pending.push(\n r.then(\n (text) => void model.resources.set(el, text),\n (e) => void model.resources.set(el, toError(e)),\n ),\n );\n } catch (e) {\n model.resources.set(el, toError(e));\n }\n }\n const finish = () => {\n // a <script src> that cannot be fetched makes the document invalid (spec §5.8)\n const bad = [...model.resources].filter(([el, v]) => el.localName === \"script\" && v instanceof Error);\n if (bad.length)\n throw new SCXMLValidationError(bad.map(([el, v]) => `<script src=\"${el.getAttribute(\"src\")}\">: ${(v as Error).message}`));\n return model;\n };\n return pending.length ? Promise.all(pending).then(finish) : finish();\n}\n\nfunction scriptsIn(model: Model): Element[] {\n const out: Element[] = [];\n const walk = (el: Element) => {\n for (const c of scxmlChildren(el, model.ns)) {\n if (c.localName === \"script\" && el !== model.root.element) out.push(c);\n if (c.localName !== \"content\") walk(c); // don't descend into inline child documents\n }\n };\n walk(model.root.element);\n return out;\n}\n\nfunction toError(e: unknown) {\n return e instanceof Error ? e : new Error(String(e));\n}\n\nfunction build(rootEl: Element): Model {\n const problems: string[] = [];\n const ns = rootEl.namespaceURI;\n if (rootEl.localName !== \"scxml\") throw new SCXMLValidationError([`root element is <${rootEl.localName}>, expected <scxml>`]);\n if (ns !== SCXML_NS) problems.push(`<scxml> must be in the namespace ${SCXML_NS} (found ${ns ?? \"none\"})`);\n const dm = rootEl.getAttribute(\"datamodel\");\n // \"null\" (spec B.1) is a subset: its only expressions are In(), which the ECMAScript engine evaluates\n if (dm != null && dm !== \"ecmascript\" && dm !== \"null\") problems.push(`unsupported datamodel \"${dm}\" (supported: \"ecmascript\", \"null\")`);\n if (dm === \"null\") {\n const forbidden = [\"data\", \"assign\", \"script\", \"foreach\"];\n for (const name of forbidden)\n if (rootEl.getElementsByTagNameNS(SCXML_NS, name).length) problems.push(`<${name}> is not available in the null data model`);\n }\n const binding = rootEl.getAttribute(\"binding\") ?? \"early\";\n if (binding !== \"early\" && binding !== \"late\") problems.push(`invalid binding \"${binding}\"`);\n\n let order = 0;\n const states: StateNode[] = [];\n const byElement = new Map<Element, StateNode>();\n const transitionsByElement = new Map<Element, TransitionNode>();\n const allData: Element[] = [];\n const kids = (el: Element) => scxmlChildren(el, ns);\n const pendingTargets: { t: TransitionNode; attr: string; where: string }[] = [];\n\n const makeState = (el: Element, kind: StateKind, parent: StateNode | null): StateNode => {\n const s: StateNode = {\n kind,\n id: el.getAttribute(\"id\") ?? \"\",\n generatedId: false,\n element: el,\n parent,\n children: [],\n history: [],\n order: order++,\n depth: parent ? parent.depth + 1 : 0,\n transitions: [],\n onentry: [],\n onexit: [],\n invokes: [],\n data: [],\n initial: null,\n donedata: null,\n };\n states.push(s);\n byElement.set(el, s);\n const where = () => `<${el.localName}${s.id ? ` id=\"${s.id}\"` : \"\"}>`;\n\n if (kind === \"history\") {\n const type = el.getAttribute(\"type\") ?? \"shallow\";\n if (type !== \"shallow\" && type !== \"deep\") problems.push(`${where()}: invalid history type \"${type}\"`);\n s.historyType = type === \"deep\" ? \"deep\" : \"shallow\";\n }\n\n for (const c of kids(el)) {\n const name = c.localName;\n switch (name) {\n case \"state\":\n case \"parallel\":\n case \"final\":\n if (kind === \"final\" || kind === \"history\") problems.push(`${where()} cannot contain <${name}>`);\n s.children.push(makeState(c, name, s));\n break;\n case \"history\":\n if (kind !== \"state\" && kind !== \"parallel\") problems.push(`${where()} cannot contain <history>`);\n s.history.push(makeState(c, \"history\", s));\n break;\n case \"transition\": {\n if (kind === \"final\" || kind === \"scxml\") problems.push(`${where()} cannot contain <transition>`);\n const t = makeTransition(c, s);\n s.transitions.push(t);\n checkExecutable(c, `${where()} <transition>`);\n break;\n }\n case \"initial\": {\n order++;\n const ts = kids(c).filter((x) => x.localName === \"transition\");\n if (ts.length !== 1) problems.push(`${where()} <initial> must contain exactly one <transition>`);\n if (ts[0]) {\n const t = makeTransition(ts[0], s);\n if (t.events.length || t.cond) problems.push(`${where()} <initial> transition must not have event or cond`);\n if (!ts[0].getAttribute(\"target\")) problems.push(`${where()} <initial> transition needs a target`);\n if (s.initial) problems.push(`${where()} has more than one initial specification`);\n t.type = \"internal\"; // same object: its targets are resolved below\n s.initial = t;\n checkExecutable(ts[0], `${where()} <initial>`);\n }\n break;\n }\n case \"onentry\":\n order++;\n s.onentry.push(c);\n checkExecutable(c, `${where()} <onentry>`);\n break;\n case \"onexit\":\n order++;\n s.onexit.push(c);\n checkExecutable(c, `${where()} <onexit>`);\n break;\n case \"datamodel\":\n order++;\n for (const d of kids(c)) {\n if (d.localName !== \"data\") {\n problems.push(`<datamodel> may only contain <data>, found <${d.localName}>`);\n continue;\n }\n order++;\n if (!d.getAttribute(\"id\")) problems.push(`<data> requires an id`);\n const sources = [\"expr\", \"src\"].filter((a) => d.hasAttribute(a)).length + (hasContent(d) ? 1 : 0);\n if (sources > 1) problems.push(`<data id=\"${d.getAttribute(\"id\")}\"> may have only one of expr, src, or content`);\n s.data.push(d);\n allData.push(d);\n }\n break;\n case \"invoke\":\n if (kind === \"scxml\" || kind === \"final\" || kind === \"history\") problems.push(`${where()} cannot contain <invoke>`);\n s.invokes.push(makeInvoke(c, s));\n break;\n case \"donedata\":\n if (kind !== \"final\") problems.push(`<donedata> is only allowed in <final>`);\n s.donedata = c;\n break;\n case \"script\":\n if (kind !== \"scxml\") problems.push(`${where()}: <script> directly inside a state is not allowed`);\n checkScript(c);\n order++;\n break;\n default:\n problems.push(`${where()}: unexpected <${name}>`);\n }\n }\n if (kind === \"state\" && s.children.length === 0 && el.hasAttribute(\"initial\"))\n problems.push(`${where()}: atomic state cannot have an initial attribute`);\n if (kind === \"state\" && el.hasAttribute(\"initial\") && s.initial)\n problems.push(`${where()}: has both an initial attribute and an <initial> element`);\n if (kind === \"history\") {\n if (s.transitions.length > 1) problems.push(`${where()} must have at most one <transition>`);\n const t = s.transitions[0];\n if (t && (t.events.length || t.cond)) problems.push(`${where()} default transition must not have event or cond`);\n }\n return s;\n };\n\n const makeTransition = (el: Element, source: StateNode): TransitionNode => {\n const t: TransitionNode = {\n element: el,\n source,\n events: (el.getAttribute(\"event\") ?? \"\").split(/\\s+/).filter(Boolean),\n cond: el.getAttribute(\"cond\"),\n targets: [],\n type: el.getAttribute(\"type\") === \"internal\" ? \"internal\" : \"external\",\n order: order++,\n };\n const type = el.getAttribute(\"type\");\n if (type != null && type !== \"internal\" && type !== \"external\") problems.push(`<transition> has invalid type \"${type}\"`);\n if (!el.hasAttribute(\"event\") && !el.hasAttribute(\"cond\") && !el.hasAttribute(\"target\") && source.kind !== \"history\")\n problems.push(`<transition> in \"${source.id}\" needs at least one of event, cond, or target`);\n const target = el.getAttribute(\"target\");\n if (target != null) pendingTargets.push({ t, attr: target, where: `transition in \"${source.id || \"(anonymous)\"}\"` });\n transitionsByElement.set(el, t);\n return t;\n };\n\n const makeInvoke = (el: Element, state: StateNode): InvokeNode => {\n const o = order++;\n const exclusive = (a: string, b: string) => {\n if (el.hasAttribute(a) && el.hasAttribute(b)) problems.push(`<invoke> may not have both ${a} and ${b}`);\n };\n exclusive(\"type\", \"typeexpr\");\n exclusive(\"src\", \"srcexpr\");\n exclusive(\"id\", \"idlocation\");\n const content = kids(el).filter((c) => c.localName === \"content\");\n if (content.length > 1) problems.push(`<invoke> may contain at most one <content>`);\n if (content.length && (el.hasAttribute(\"src\") || el.hasAttribute(\"srcexpr\")))\n problems.push(`<invoke> may not have both src and <content>`);\n const params = kids(el).filter((c) => c.localName === \"param\");\n if (params.length && el.hasAttribute(\"namelist\")) problems.push(`<invoke> may not have both namelist and <param>`);\n const finalize = kids(el).find((c) => c.localName === \"finalize\") ?? null;\n if (finalize) checkExecutable(finalize, \"<finalize>\");\n return { element: el, state, order: o, autoforward: el.getAttribute(\"autoforward\") === \"true\", finalize };\n };\n\n const checkScript = (el: Element) => {\n if (el.hasAttribute(\"src\") && (el.textContent ?? \"\").trim()) problems.push(`<script> may not have both src and content`);\n };\n\n const checkExecutable = (block: Element, where: string) => {\n for (const c of kids(block)) {\n const n = c.localName;\n // the <initial>/<finalize>/<transition> containers hold executable content directly\n if (!EXECUTABLE.has(n)) {\n problems.push(`${where}: <${n}> is not executable content`);\n continue;\n }\n order++;\n if ((n === \"elseif\" || n === \"else\") && block.localName !== \"if\") problems.push(`${where}: <${n}> outside <if>`);\n if ((n === \"if\" || n === \"elseif\") && !c.hasAttribute(\"cond\")) problems.push(`${where}: <${n}> requires cond`);\n if (n === \"raise\" && !c.getAttribute(\"event\")) problems.push(`${where}: <raise> requires event`);\n if (n === \"assign\" && !c.getAttribute(\"location\")) problems.push(`${where}: <assign> requires location`);\n if (n === \"foreach\" && (!c.hasAttribute(\"array\") || !c.hasAttribute(\"item\")))\n problems.push(`${where}: <foreach> requires array and item`);\n if (n === \"script\") checkScript(c);\n if (n === \"send\") {\n for (const [a, b] of [\n [\"event\", \"eventexpr\"],\n [\"target\", \"targetexpr\"],\n [\"type\", \"typeexpr\"],\n [\"id\", \"idlocation\"],\n [\"delay\", \"delayexpr\"],\n ])\n if (c.hasAttribute(a!) && c.hasAttribute(b!)) problems.push(`${where}: <send> may not have both ${a} and ${b}`);\n const hasContentEl = kids(c).some((x) => x.localName === \"content\");\n if (hasContentEl && (c.hasAttribute(\"namelist\") || kids(c).some((x) => x.localName === \"param\")))\n problems.push(`${where}: <send> may not combine <content> with namelist or <param>`);\n if (hasContentEl && !c.hasAttribute(\"event\") && !c.hasAttribute(\"eventexpr\")) {\n /* allowed: content-only sends to external processors */\n }\n }\n if (n === \"cancel\" && !c.hasAttribute(\"sendid\") && !c.hasAttribute(\"sendidexpr\"))\n problems.push(`${where}: <cancel> requires sendid or sendidexpr`);\n if (n === \"if\" || n === \"foreach\") checkExecutable(c, where);\n }\n };\n\n const root = makeState(rootEl, \"scxml\", null);\n\n // ids: explicit ones must be unique; missing ones are generated\n const byId = new Map<string, StateNode>();\n for (const s of states) {\n if (!s.id) continue;\n if (byId.has(s.id)) problems.push(`duplicate id \"${s.id}\"`);\n byId.set(s.id, s);\n }\n let gen = 0;\n for (const s of states) {\n if (s.id || s.kind === \"scxml\") continue;\n let id: string;\n do id = `__${s.kind}${++gen}`;\n while (byId.has(id));\n s.id = id;\n s.generatedId = true;\n byId.set(id, s);\n }\n\n const resolve = (ids: string, where: string): StateNode[] =>\n ids\n .split(/\\s+/)\n .filter(Boolean)\n .flatMap((id) => {\n const s = byId.get(id);\n if (!s || s.kind === \"scxml\") {\n problems.push(`${where}: unknown target \"${id}\"`);\n return [];\n }\n return [s];\n });\n\n for (const { t, attr, where } of pendingTargets) t.targets = resolve(attr, where);\n\n // initial transitions\n for (const s of states) {\n if (!(s.kind === \"scxml\" || isCompound(s))) continue;\n const attr = s.element.getAttribute(\"initial\");\n if (attr != null) {\n s.initial = {\n element: null,\n source: s,\n events: [],\n cond: null,\n targets: resolve(attr, `initial of \"${s.id || \"scxml\"}\"`),\n type: \"internal\",\n order: s.order,\n };\n } else if (!s.initial) {\n const first = s.children[0];\n s.initial = { element: null, source: s, events: [], cond: null, targets: first ? [first] : [], type: \"internal\", order: s.order };\n }\n for (const t of s.initial.targets)\n if (!isDescendant(t, s)) problems.push(`initial target \"${t.id}\" is not a descendant of \"${s.id || \"scxml\"}\"`);\n checkLegalTargets(s.initial.targets, `initial of \"${s.id || \"scxml\"}\"`);\n }\n if (root.children.length === 0) problems.push(`<scxml> has no states`);\n\n // history default transitions\n for (const h of states.filter((s) => s.kind === \"history\")) {\n const t = h.transitions[0];\n if (!t) {\n problems.push(`history \"${h.id}\" needs a default <transition>`);\n continue;\n }\n if (!t.targets.length) problems.push(`history \"${h.id}\" default transition needs a target`);\n for (const target of t.targets) {\n const ok = h.historyType === \"deep\" ? isDescendant(target, h.parent!) : target.parent === h.parent && target.kind !== \"history\";\n if (!ok)\n problems.push(\n `history \"${h.id}\" default target \"${target.id}\" is not a ${h.historyType === \"deep\" ? \"descendant\" : \"child\"} of its parent`,\n );\n }\n }\n for (const s of states) for (const t of s.transitions) checkLegalTargets(t.targets, `transition in \"${s.id}\"`);\n\n function checkLegalTargets(ts: StateNode[], where: string) {\n // no target may be an ancestor of another, and at most one target per compound state (spec §3.11)\n for (const a of ts)\n for (const b of ts) {\n if (a === b) continue;\n if (isDescendant(a, b)) problems.push(`${where}: targets \"${b.id}\" and \"${a.id}\" are nested`);\n else if (a.order < b.order) {\n let lca = a.parent;\n while (lca && !isDescendant(b, lca)) lca = lca.parent;\n if (lca && lca.kind !== \"parallel\") problems.push(`${where}: targets \"${a.id}\" and \"${b.id}\" cannot be active together`);\n }\n }\n }\n\n const scripts = kids(rootEl).filter((c) => c.localName === \"script\");\n if (problems.length) throw new SCXMLValidationError(problems);\n\n const model: Model = {\n ns,\n root,\n states,\n byId,\n byElement,\n transitionsByElement,\n name: rootEl.getAttribute(\"name\") ?? \"\",\n binding: binding === \"late\" ? \"late\" : \"early\",\n scripts,\n allData,\n resources: new Map(),\n warnings: [],\n };\n model.warnings = lint(model);\n return model;\n}\n\nfunction hasContent(el: Element) {\n return el.children.length > 0 || (el.textContent ?? \"\").trim().length > 0;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAmB,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AA0GvC,4EAA4E;AAC5E,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAC7C,gCAAgC;IACvB,IAAI,GAAG,eAAwB,CAAC;IACzC,8EAA8E;IACrE,QAAQ,CAAW;IAC5B,yDAAyD;IACzD,YAAY,QAAkB;QAC5B,KAAK,CAAC,gCAAgC,QAAQ,CAAC,IAAI,CAAC,QAA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C,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,KAAK,QAAQ,CAAC,CAAC;IACrE,IAAI,QAAQ,CAAC,MAAM;QAAE,MAAM,IAAI,oBAAoB,CAAC,QAAQ,CAAC,CAAC;IAE9D,MAAM,KAAK,GAAU;QACnB,EAAE;QACF,IAAI;QACJ,MAAM;QACN,IAAI;QACJ,SAAS;QACT,oBAAoB;QACpB,IAAI,EAAE,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,EAAE;QACvC,OAAO,EAAE,OAAO,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO;QAC9C,OAAO;QACP,OAAO;QACP,SAAS,EAAE,IAAI,GAAG,EAAE;QACpB,QAAQ,EAAE,EAAE;KACb,CAAC;IACF,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;IAC7B,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,UAAU,CAAC,EAAW;IAC7B,OAAO,EAAE,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC;AAC5E,CAAC","sourcesContent":["/**\n * Compiles an `<scxml>` DOM element into an immutable, validated model.\n *\n * The model keeps a reference to every source element, so renderers can map\n * live state back onto the document. Validation follows the constraints of\n * spec §3 (ids, targets, initial states, history, executable content);\n * a non-conformant document raises `SCXMLValidationError` listing every problem.\n */\nimport { type Diagnostic, lint } from \"./diagnostics.ts\";\nimport { SCXML_NS } from \"./events.ts\";\n\n/** The element a state node was compiled from (`scxml` is the root). */\nexport type StateKind = \"scxml\" | \"state\" | \"parallel\" | \"final\" | \"history\";\n\n/**\n * A state of a compiled chart. Every node keeps its source `element`, so\n * renderers can map live state back onto the document.\n */\nexport interface StateNode {\n /** Which element it is. */\n kind: StateKind;\n /** The `id` attribute, or a generated one (see `generatedId`). */\n id: string;\n /** True when the author omitted `id` and one was generated (spec §3.14). */\n generatedId: boolean;\n /** The source element (`<state>`, `<parallel>`, …). */\n element: Element;\n /** The containing state; `null` for the root. */\n parent: StateNode | null;\n /** `<state>`, `<parallel>` and `<final>` children — spec `getChildStates`. */\n children: StateNode[];\n /** `<history>` children. */\n history: StateNode[];\n /** Document order. */\n order: number;\n /** Nesting depth: the root is 0. */\n depth: number;\n /** Its `<transition>`s, in document order. */\n transitions: TransitionNode[];\n /** Each `<onentry>` / `<onexit>` element is a separate executable block. */\n onentry: Element[];\n /** The `<onexit>` blocks, in document order. */\n onexit: Element[];\n /** Its `<invoke>`s, in document order. */\n invokes: InvokeNode[];\n /** `<data>` elements of this state's own `<datamodel>`. */\n data: Element[];\n /** Initial transition, for compound states and `<scxml>`. */\n initial: TransitionNode | null;\n /** For `<history>` nodes: whether it remembers only direct children (`shallow`) or the full descendant configuration (`deep`). */\n historyType?: \"shallow\" | \"deep\";\n /** For `<final>` states: the `<donedata>` element, if any. */\n donedata: Element | null;\n}\n\n/** A transition of a compiled chart. */\nexport interface TransitionNode {\n /** `null` for initial transitions synthesised from an `initial` attribute or default. */\n element: Element | null;\n /** The state it belongs to. */\n source: StateNode;\n /** The event descriptors of the `event` attribute (empty for eventless transitions). */\n events: string[];\n /** The `cond` expression, or `null`. */\n cond: string | null;\n /** The targets (empty for targetless transitions). */\n targets: StateNode[];\n /** The `type` attribute: `internal` doesn't exit its source state when the targets are its descendants. */\n type: \"internal\" | \"external\";\n /** Document order. */\n order: number;\n}\n\n/** An `<invoke>` of a compiled chart. */\nexport interface InvokeNode {\n /** The `<invoke>` element. */\n element: Element;\n /** The state it belongs to (invoked while that state is active). */\n state: StateNode;\n /** Document order. */\n order: number;\n /** The `autoforward` attribute: external events are forwarded to the invoked service. */\n autoforward: boolean;\n /** The `<finalize>` element, if any. */\n finalize: Element | null;\n}\n\n/** A compiled, validated chart. Sessions only read it, so one model can serve many sessions. */\nexport interface Model {\n /** The SCXML namespace the document uses. */\n ns: string | null;\n /** The `<scxml>` element's node. */\n root: StateNode;\n /** All states (including history and the root) in document order. */\n states: StateNode[];\n /** States by id (generated ids included). */\n byId: Map<string, StateNode>;\n /** States by source element. */\n byElement: Map<Element, StateNode>;\n /** Transitions by source `<transition>` element. */\n transitionsByElement: Map<Element, TransitionNode>;\n /** The `<scxml name>` attribute (`\"\"` when absent). */\n name: string;\n /** The `binding` attribute: when `<data>` is initialised. */\n binding: \"early\" | \"late\";\n /** `<script>` children of `<scxml>`. */\n scripts: Element[];\n /** Every `<data>` element, document order. */\n allData: Element[];\n /** Pre-loaded `src` contents for `<script src>` and `<data src>` (value: text, or an Error). */\n resources: Map<Element, string | Error>;\n /** Likely mistakes that are still valid SCXML (see `Diagnostic`); empty for most charts. */\n warnings: Diagnostic[];\n}\n\n/** The document isn't valid SCXML. `problems` lists every problem found. */\nexport class SCXMLValidationError extends Error {\n /** Always `\"SCXML_INVALID\"`. */\n readonly code = \"SCXML_INVALID\" as const;\n /** Every problem found, one line each (they are also listed in `message`). */\n readonly problems: string[];\n /** @param problems every problem found, one line each */\n constructor(problems: string[]) {\n super(`Invalid SCXML document:\\n - ${problems.join(\"\\n - \")}`);\n this.problems = problems;\n this.name = \"SCXMLValidationError\";\n }\n}\n\n/** SCXML text couldn't be parsed (or there is no `DOMParser` to parse it with). */\nexport class SCXMLParseError extends Error {\n /**\n * @param code `SCXML_PARSE`: the text isn't well-formed XML (or has no `<scxml>` root), or the\n * `DOMParser` doesn't implement XML namespaces;\n * `SCXML_NO_DOMPARSER`: there is no `DOMParser` (outside browsers: pass `domParser`).\n */\n constructor(\n readonly code: \"SCXML_PARSE\" | \"SCXML_NO_DOMPARSER\",\n message: string,\n ) {\n super(message);\n this.name = \"SCXMLParseError\";\n }\n}\n\n/** Resolves `src` attributes (`<script>`, `<data>`, `<invoke>`) to their text; may be synchronous. */\nexport type Loader = (src: string) => string | Promise<string>;\n\nconst EXECUTABLE = new Set([\"raise\", \"if\", \"elseif\", \"else\", \"foreach\", \"log\", \"assign\", \"script\", \"send\", \"cancel\"]);\n\n// ─────────────────────────────── queries ───────────────────────────────\n\n/** A state without child states (or a `<final>`). */\nexport const isAtomic = (s: StateNode) => s.kind === \"final\" || (s.kind === \"state\" && s.children.length === 0);\n/** A `<state>` with child states. */\nexport const isCompound = (s: StateNode) => s.kind === \"state\" && s.children.length > 0;\nexport const isCompoundOrRoot = (s: StateNode) => s.kind === \"scxml\" || isCompound(s);\n\n/** True when `a` is a proper descendant of `b`. */\nexport function isDescendant(a: StateNode, b: StateNode): boolean {\n for (let p = a.parent; p; p = p.parent) if (p === b) return true;\n return false;\n}\n\n/** Ancestors of `s` up to (excluding) `upTo`; with `upTo = null`, up to and including the root. */\nexport function properAncestors(s: StateNode, upTo: StateNode | null): StateNode[] {\n const out: StateNode[] = [];\n for (let p = s.parent; p && p !== upTo; p = p.parent) out.push(p);\n return out;\n}\n\n/** A comparator for `Array.sort`: document order. */\nexport const documentOrder = (a: { order: number }, b: { order: number }) => a.order - b.order;\nexport const exitOrder = (a: { order: number }, b: { order: number }) => b.order - a.order;\n\n/** SCXML-namespace child elements (foreign elements are ignored everywhere). */\nexport function scxmlChildren(el: Element, ns: string | null): Element[] {\n return Array.from(el.children).filter((c) => c.namespaceURI === ns);\n}\n\n// ─────────────────────────────── compile ───────────────────────────────\n\n/**\n * Compile an `<scxml>` element. `src` attributes on `<script>` and `<data>`\n * are fetched with `loader`; the result is synchronous when the loader is.\n *\n * @throws {TypeError} when given text: parse it first with `parseSCXML()`.\n */\nexport function compile(root: Element, opts: { loader?: Loader } = {}): Model | Promise<Model> {\n if (typeof root === \"string\")\n throw new TypeError(\n \"compile() takes the parsed <scxml> Element, not SCXML text: parse it first with parseSCXML(text, domParser), \" +\n \"or pass the text to createSession()\",\n );\n const model = build(root);\n const pending: Promise<void>[] = [];\n for (const el of [...model.scripts, ...scriptsIn(model), ...model.allData]) {\n const src = el.getAttribute(\"src\");\n if (src == null) continue;\n if (!opts.loader) {\n model.resources.set(el, new Error(`no loader to fetch \"${src}\"`));\n continue;\n }\n try {\n const r = opts.loader(src);\n if (typeof r === \"string\") model.resources.set(el, r);\n else\n pending.push(\n r.then(\n (text) => void model.resources.set(el, text),\n (e) => void model.resources.set(el, toError(e)),\n ),\n );\n } catch (e) {\n model.resources.set(el, toError(e));\n }\n }\n const finish = () => {\n // a <script src> that cannot be fetched makes the document invalid (spec §5.8)\n const bad = [...model.resources].filter(([el, v]) => el.localName === \"script\" && v instanceof Error);\n if (bad.length)\n throw new SCXMLValidationError(bad.map(([el, v]) => `<script src=\"${el.getAttribute(\"src\")}\">: ${(v as Error).message}`));\n return model;\n };\n return pending.length ? Promise.all(pending).then(finish) : finish();\n}\n\nfunction scriptsIn(model: Model): Element[] {\n const out: Element[] = [];\n const walk = (el: Element) => {\n for (const c of scxmlChildren(el, model.ns)) {\n if (c.localName === \"script\" && el !== model.root.element) out.push(c);\n if (c.localName !== \"content\") walk(c); // don't descend into inline child documents\n }\n };\n walk(model.root.element);\n return out;\n}\n\nfunction toError(e: unknown) {\n return e instanceof Error ? e : new Error(String(e));\n}\n\nfunction build(rootEl: Element): Model {\n const problems: string[] = [];\n const ns = rootEl.namespaceURI;\n if (rootEl.localName !== \"scxml\") throw new SCXMLValidationError([`root element is <${rootEl.localName}>, expected <scxml>`]);\n if (ns !== SCXML_NS) problems.push(`<scxml> must be in the namespace ${SCXML_NS} (found ${ns ?? \"none\"})`);\n const dm = rootEl.getAttribute(\"datamodel\");\n // \"null\" (spec B.1) is a subset: its only expressions are In(), which the ECMAScript engine evaluates\n if (dm != null && dm !== \"ecmascript\" && dm !== \"null\") problems.push(`unsupported datamodel \"${dm}\" (supported: \"ecmascript\", \"null\")`);\n if (dm === \"null\") {\n const forbidden = [\"data\", \"assign\", \"script\", \"foreach\"];\n for (const name of forbidden)\n if (rootEl.getElementsByTagNameNS(SCXML_NS, name).length) problems.push(`<${name}> is not available in the null data model`);\n }\n const binding = rootEl.getAttribute(\"binding\") ?? \"early\";\n if (binding !== \"early\" && binding !== \"late\") problems.push(`invalid binding \"${binding}\"`);\n\n let order = 0;\n const states: StateNode[] = [];\n const byElement = new Map<Element, StateNode>();\n const transitionsByElement = new Map<Element, TransitionNode>();\n const allData: Element[] = [];\n const kids = (el: Element) => scxmlChildren(el, ns);\n const pendingTargets: { t: TransitionNode; attr: string; where: string }[] = [];\n\n const makeState = (el: Element, kind: StateKind, parent: StateNode | null): StateNode => {\n const s: StateNode = {\n kind,\n id: el.getAttribute(\"id\") ?? \"\",\n generatedId: false,\n element: el,\n parent,\n children: [],\n history: [],\n order: order++,\n depth: parent ? parent.depth + 1 : 0,\n transitions: [],\n onentry: [],\n onexit: [],\n invokes: [],\n data: [],\n initial: null,\n donedata: null,\n };\n states.push(s);\n byElement.set(el, s);\n const where = () => `<${el.localName}${s.id ? ` id=\"${s.id}\"` : \"\"}>`;\n\n if (kind === \"history\") {\n const type = el.getAttribute(\"type\") ?? \"shallow\";\n if (type !== \"shallow\" && type !== \"deep\") problems.push(`${where()}: invalid history type \"${type}\"`);\n s.historyType = type === \"deep\" ? \"deep\" : \"shallow\";\n }\n\n for (const c of kids(el)) {\n const name = c.localName;\n switch (name) {\n case \"state\":\n case \"parallel\":\n case \"final\":\n if (kind === \"final\" || kind === \"history\") problems.push(`${where()} cannot contain <${name}>`);\n s.children.push(makeState(c, name, s));\n break;\n case \"history\":\n if (kind !== \"state\" && kind !== \"parallel\") problems.push(`${where()} cannot contain <history>`);\n s.history.push(makeState(c, \"history\", s));\n break;\n case \"transition\": {\n if (kind === \"final\" || kind === \"scxml\") problems.push(`${where()} cannot contain <transition>`);\n const t = makeTransition(c, s);\n s.transitions.push(t);\n checkExecutable(c, `${where()} <transition>`);\n break;\n }\n case \"initial\": {\n order++;\n const ts = kids(c).filter((x) => x.localName === \"transition\");\n if (ts.length !== 1) problems.push(`${where()} <initial> must contain exactly one <transition>`);\n if (ts[0]) {\n const t = makeTransition(ts[0], s);\n if (t.events.length || t.cond) problems.push(`${where()} <initial> transition must not have event or cond`);\n if (!ts[0].getAttribute(\"target\")) problems.push(`${where()} <initial> transition needs a target`);\n if (s.initial) problems.push(`${where()} has more than one initial specification`);\n t.type = \"internal\"; // same object: its targets are resolved below\n s.initial = t;\n checkExecutable(ts[0], `${where()} <initial>`);\n }\n break;\n }\n case \"onentry\":\n order++;\n s.onentry.push(c);\n checkExecutable(c, `${where()} <onentry>`);\n break;\n case \"onexit\":\n order++;\n s.onexit.push(c);\n checkExecutable(c, `${where()} <onexit>`);\n break;\n case \"datamodel\":\n order++;\n for (const d of kids(c)) {\n if (d.localName !== \"data\") {\n problems.push(`<datamodel> may only contain <data>, found <${d.localName}>`);\n continue;\n }\n order++;\n if (!d.getAttribute(\"id\")) problems.push(`<data> requires an id`);\n const sources = [\"expr\", \"src\"].filter((a) => d.hasAttribute(a)).length + (hasContent(d) ? 1 : 0);\n if (sources > 1) problems.push(`<data id=\"${d.getAttribute(\"id\")}\"> may have only one of expr, src, or content`);\n s.data.push(d);\n allData.push(d);\n }\n break;\n case \"invoke\":\n if (kind === \"scxml\" || kind === \"final\" || kind === \"history\") problems.push(`${where()} cannot contain <invoke>`);\n s.invokes.push(makeInvoke(c, s));\n break;\n case \"donedata\":\n if (kind !== \"final\") problems.push(`<donedata> is only allowed in <final>`);\n s.donedata = c;\n break;\n case \"script\":\n if (kind !== \"scxml\") problems.push(`${where()}: <script> directly inside a state is not allowed`);\n checkScript(c);\n order++;\n break;\n default:\n problems.push(`${where()}: unexpected <${name}>`);\n }\n }\n if (kind === \"state\" && s.children.length === 0 && el.hasAttribute(\"initial\"))\n problems.push(`${where()}: atomic state cannot have an initial attribute`);\n if (kind === \"state\" && el.hasAttribute(\"initial\") && s.initial)\n problems.push(`${where()}: has both an initial attribute and an <initial> element`);\n if (kind === \"history\") {\n if (s.transitions.length > 1) problems.push(`${where()} must have at most one <transition>`);\n const t = s.transitions[0];\n if (t && (t.events.length || t.cond)) problems.push(`${where()} default transition must not have event or cond`);\n }\n return s;\n };\n\n const makeTransition = (el: Element, source: StateNode): TransitionNode => {\n const t: TransitionNode = {\n element: el,\n source,\n events: (el.getAttribute(\"event\") ?? \"\").split(/\\s+/).filter(Boolean),\n cond: el.getAttribute(\"cond\"),\n targets: [],\n type: el.getAttribute(\"type\") === \"internal\" ? \"internal\" : \"external\",\n order: order++,\n };\n const type = el.getAttribute(\"type\");\n if (type != null && type !== \"internal\" && type !== \"external\") problems.push(`<transition> has invalid type \"${type}\"`);\n if (!el.hasAttribute(\"event\") && !el.hasAttribute(\"cond\") && !el.hasAttribute(\"target\") && source.kind !== \"history\")\n problems.push(`<transition> in \"${source.id}\" needs at least one of event, cond, or target`);\n const target = el.getAttribute(\"target\");\n if (target != null) pendingTargets.push({ t, attr: target, where: `transition in \"${source.id || \"(anonymous)\"}\"` });\n transitionsByElement.set(el, t);\n return t;\n };\n\n const makeInvoke = (el: Element, state: StateNode): InvokeNode => {\n const o = order++;\n const exclusive = (a: string, b: string) => {\n if (el.hasAttribute(a) && el.hasAttribute(b)) problems.push(`<invoke> may not have both ${a} and ${b}`);\n };\n exclusive(\"type\", \"typeexpr\");\n exclusive(\"src\", \"srcexpr\");\n exclusive(\"id\", \"idlocation\");\n const content = kids(el).filter((c) => c.localName === \"content\");\n if (content.length > 1) problems.push(`<invoke> may contain at most one <content>`);\n if (content.length && (el.hasAttribute(\"src\") || el.hasAttribute(\"srcexpr\")))\n problems.push(`<invoke> may not have both src and <content>`);\n const params = kids(el).filter((c) => c.localName === \"param\");\n if (params.length && el.hasAttribute(\"namelist\")) problems.push(`<invoke> may not have both namelist and <param>`);\n const finalize = kids(el).find((c) => c.localName === \"finalize\") ?? null;\n if (finalize) checkExecutable(finalize, \"<finalize>\");\n return { element: el, state, order: o, autoforward: el.getAttribute(\"autoforward\") === \"true\", finalize };\n };\n\n const checkScript = (el: Element) => {\n if (el.hasAttribute(\"src\") && (el.textContent ?? \"\").trim()) problems.push(`<script> may not have both src and content`);\n };\n\n const checkExecutable = (block: Element, where: string) => {\n for (const c of kids(block)) {\n const n = c.localName;\n // the <initial>/<finalize>/<transition> containers hold executable content directly\n if (!EXECUTABLE.has(n)) {\n problems.push(`${where}: <${n}> is not executable content`);\n continue;\n }\n order++;\n if ((n === \"elseif\" || n === \"else\") && block.localName !== \"if\") problems.push(`${where}: <${n}> outside <if>`);\n if ((n === \"if\" || n === \"elseif\") && !c.hasAttribute(\"cond\")) problems.push(`${where}: <${n}> requires cond`);\n if (n === \"raise\" && !c.getAttribute(\"event\")) problems.push(`${where}: <raise> requires event`);\n if (n === \"assign\" && !c.getAttribute(\"location\")) problems.push(`${where}: <assign> requires location`);\n if (n === \"foreach\" && (!c.hasAttribute(\"array\") || !c.hasAttribute(\"item\")))\n problems.push(`${where}: <foreach> requires array and item`);\n if (n === \"script\") checkScript(c);\n if (n === \"send\") {\n for (const [a, b] of [\n [\"event\", \"eventexpr\"],\n [\"target\", \"targetexpr\"],\n [\"type\", \"typeexpr\"],\n [\"id\", \"idlocation\"],\n [\"delay\", \"delayexpr\"],\n ])\n if (c.hasAttribute(a!) && c.hasAttribute(b!)) problems.push(`${where}: <send> may not have both ${a} and ${b}`);\n const hasContentEl = kids(c).some((x) => x.localName === \"content\");\n if (hasContentEl && (c.hasAttribute(\"namelist\") || kids(c).some((x) => x.localName === \"param\")))\n problems.push(`${where}: <send> may not combine <content> with namelist or <param>`);\n if (hasContentEl && !c.hasAttribute(\"event\") && !c.hasAttribute(\"eventexpr\")) {\n /* allowed: content-only sends to external processors */\n }\n }\n if (n === \"cancel\" && !c.hasAttribute(\"sendid\") && !c.hasAttribute(\"sendidexpr\"))\n problems.push(`${where}: <cancel> requires sendid or sendidexpr`);\n if (n === \"if\" || n === \"foreach\") checkExecutable(c, where);\n }\n };\n\n const root = makeState(rootEl, \"scxml\", null);\n\n // ids: explicit ones must be unique; missing ones are generated\n const byId = new Map<string, StateNode>();\n for (const s of states) {\n if (!s.id) continue;\n if (byId.has(s.id)) problems.push(`duplicate id \"${s.id}\"`);\n byId.set(s.id, s);\n }\n let gen = 0;\n for (const s of states) {\n if (s.id || s.kind === \"scxml\") continue;\n let id: string;\n do id = `__${s.kind}${++gen}`;\n while (byId.has(id));\n s.id = id;\n s.generatedId = true;\n byId.set(id, s);\n }\n\n const resolve = (ids: string, where: string): StateNode[] =>\n ids\n .split(/\\s+/)\n .filter(Boolean)\n .flatMap((id) => {\n const s = byId.get(id);\n if (!s || s.kind === \"scxml\") {\n problems.push(`${where}: unknown target \"${id}\"`);\n return [];\n }\n return [s];\n });\n\n for (const { t, attr, where } of pendingTargets) t.targets = resolve(attr, where);\n\n // initial transitions\n for (const s of states) {\n if (!(s.kind === \"scxml\" || isCompound(s))) continue;\n const attr = s.element.getAttribute(\"initial\");\n if (attr != null) {\n s.initial = {\n element: null,\n source: s,\n events: [],\n cond: null,\n targets: resolve(attr, `initial of \"${s.id || \"scxml\"}\"`),\n type: \"internal\",\n order: s.order,\n };\n } else if (!s.initial) {\n const first = s.children[0];\n s.initial = { element: null, source: s, events: [], cond: null, targets: first ? [first] : [], type: \"internal\", order: s.order };\n }\n for (const t of s.initial.targets)\n if (!isDescendant(t, s)) problems.push(`initial target \"${t.id}\" is not a descendant of \"${s.id || \"scxml\"}\"`);\n checkLegalTargets(s.initial.targets, `initial of \"${s.id || \"scxml\"}\"`);\n }\n if (root.children.length === 0) problems.push(`<scxml> has no states`);\n\n // history default transitions\n for (const h of states.filter((s) => s.kind === \"history\")) {\n const t = h.transitions[0];\n if (!t) {\n problems.push(`history \"${h.id}\" needs a default <transition>`);\n continue;\n }\n if (!t.targets.length) problems.push(`history \"${h.id}\" default transition needs a target`);\n for (const target of t.targets) {\n const ok = h.historyType === \"deep\" ? isDescendant(target, h.parent!) : target.parent === h.parent && target.kind !== \"history\";\n if (!ok)\n problems.push(\n `history \"${h.id}\" default target \"${target.id}\" is not a ${h.historyType === \"deep\" ? \"descendant\" : \"child\"} of its parent`,\n );\n }\n }\n for (const s of states) for (const t of s.transitions) checkLegalTargets(t.targets, `transition in \"${s.id}\"`);\n\n function checkLegalTargets(ts: StateNode[], where: string) {\n // no target may be an ancestor of another, and at most one target per compound state (spec §3.11)\n for (const a of ts)\n for (const b of ts) {\n if (a === b) continue;\n if (isDescendant(a, b)) problems.push(`${where}: targets \"${b.id}\" and \"${a.id}\" are nested`);\n else if (a.order < b.order) {\n let lca = a.parent;\n while (lca && !isDescendant(b, lca)) lca = lca.parent;\n if (lca && lca.kind !== \"parallel\") problems.push(`${where}: targets \"${a.id}\" and \"${b.id}\" cannot be active together`);\n }\n }\n }\n\n const scripts = kids(rootEl).filter((c) => c.localName === \"script\");\n if (problems.length) throw new SCXMLValidationError(problems);\n\n const model: Model = {\n ns,\n root,\n states,\n byId,\n byElement,\n transitionsByElement,\n name: rootEl.getAttribute(\"name\") ?? \"\",\n binding: binding === \"late\" ? \"late\" : \"early\",\n scripts,\n allData,\n resources: new Map(),\n warnings: [],\n };\n model.warnings = lint(model);\n return model;\n}\n\nfunction hasContent(el: Element) {\n return el.children.length > 0 || (el.textContent ?? \"\").trim().length > 0;\n}\n"]}
|
package/dist/session.d.ts
CHANGED
|
@@ -81,9 +81,10 @@ export interface InvokeContext {
|
|
|
81
81
|
export type Invoker = (ctx: InvokeContext) => InvokedService | Promise<InvokedService>;
|
|
82
82
|
/**
|
|
83
83
|
* A `DOMParser`: the browser's, or one from a DOM implementation such as
|
|
84
|
-
* happy-dom
|
|
85
|
-
*
|
|
86
|
-
*
|
|
84
|
+
* happy-dom. Only `parseFromString` is used, and its result only needs to
|
|
85
|
+
* behave like a standard XML `Document`, XML namespaces included (linkedom's
|
|
86
|
+
* doesn't); the return type is `unknown` so any implementation's own
|
|
87
|
+
* `Document` type is accepted without a cast.
|
|
87
88
|
*/
|
|
88
89
|
export interface DOMParserLike {
|
|
89
90
|
/** Parse `source` as the given MIME type (the session asks for `application/xml`). */
|
|
@@ -162,10 +163,12 @@ export interface SessionOptions {
|
|
|
162
163
|
* Parse SCXML text into its `<scxml>` element.
|
|
163
164
|
*
|
|
164
165
|
* Browsers have a `DOMParser`; Node, Bun and Deno don't, so pass one there
|
|
165
|
-
* (any standards-compliant implementation, e.g. happy-dom's
|
|
166
|
+
* (any standards-compliant XML implementation, e.g. happy-dom's; linkedom's
|
|
167
|
+
* ignores XML namespaces, so it can't read SCXML).
|
|
166
168
|
*
|
|
167
169
|
* @throws {SCXMLParseError} `code: "SCXML_NO_DOMPARSER"` when no parser is
|
|
168
|
-
* available, `code: "SCXML_PARSE"` when the text isn't well-formed XML
|
|
170
|
+
* available, `code: "SCXML_PARSE"` when the text isn't well-formed XML or
|
|
171
|
+
* the parser doesn't implement XML namespaces.
|
|
169
172
|
*/
|
|
170
173
|
export declare function parseSCXML(source: string, domParser?: DOMParserLike): Element;
|
|
171
174
|
/**
|
|
@@ -245,8 +248,13 @@ export declare class SCXMLSession extends EventTarget {
|
|
|
245
248
|
get configuration(): StateNode[];
|
|
246
249
|
/** The ids of the active states, document order. */
|
|
247
250
|
activeStateIds(): string[];
|
|
248
|
-
/**
|
|
251
|
+
/**
|
|
252
|
+
* Whether the state with this id is active.
|
|
253
|
+
*
|
|
254
|
+
* @throws {RangeError} when the chart has no state with this id.
|
|
255
|
+
*/
|
|
249
256
|
isActive(id: string): boolean;
|
|
257
|
+
private stateById;
|
|
250
258
|
/** Whether this state node is active. */
|
|
251
259
|
isActiveNode(s: StateNode): boolean;
|
|
252
260
|
/** Active invocations: what `<invoke>` started and is still running, with the child session for SCXML invokes. */
|
|
@@ -268,7 +276,11 @@ export declare class SCXMLSession extends EventTarget {
|
|
|
268
276
|
* are not included. After `dispose()` it returns `{}`.
|
|
269
277
|
*/
|
|
270
278
|
snapshot(): Record<string, unknown>;
|
|
271
|
-
/**
|
|
279
|
+
/**
|
|
280
|
+
* Enqueue an external event. Events sent before `start()` wait in the queue
|
|
281
|
+
* and are processed, in order, once the session starts; events sent after
|
|
282
|
+
* it has terminated are dropped.
|
|
283
|
+
*/
|
|
272
284
|
send(name: string, data?: unknown): void;
|
|
273
285
|
/** `interpret()` — spec Appendix D. */
|
|
274
286
|
start(): this;
|
|
@@ -283,7 +295,7 @@ export declare class SCXMLSession extends EventTarget {
|
|
|
283
295
|
* listeners installed by `connect()` / `bind()` and attributes set by
|
|
284
296
|
* `reflect`, frees the data model context and leaves the session registry.
|
|
285
297
|
* `done` resolves (with `undefined` if it hadn't finished). Safe to call
|
|
286
|
-
* more than once; the session can't be used afterwards.
|
|
298
|
+
* more than once; the session can't be used afterwards (`start()` throws).
|
|
287
299
|
*/
|
|
288
300
|
dispose(): void;
|
|
289
301
|
/** True when the session was ended by `cancel()` / `dispose()` rather than by reaching a final state. */
|
|
@@ -327,7 +339,8 @@ export declare class SCXMLSession extends EventTarget {
|
|
|
327
339
|
* (the configuration is cleared right after that, per the spec).
|
|
328
340
|
*
|
|
329
341
|
* `what`: a state id (active), several ids (all active) or a predicate.
|
|
330
|
-
* Rejects with `
|
|
342
|
+
* Rejects with a `RangeError` at once when an id names no state of the
|
|
343
|
+
* chart, with `options.signal.reason` on abort, a `TimeoutError`
|
|
331
344
|
* DOMException after `timeoutMs` (measured on the session's clock), or an
|
|
332
345
|
* Error when the session terminates first.
|
|
333
346
|
*/
|