@nanobpm/urban 0.52.0 → 0.53.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 +47 -20
- package/dist/runtime/core/events.d.ts +135 -0
- package/dist/runtime/core/events.js +329 -0
- package/dist/runtime/core/extensions.d.ts +131 -0
- package/dist/runtime/core/extensions.js +137 -0
- package/dist/runtime/core/glob.d.ts +7 -6
- package/dist/runtime/core/glob.js +16 -14
- package/dist/runtime/core/host.d.ts +4 -1
- package/dist/runtime/core/modules/agent.d.ts +17 -0
- package/dist/runtime/core/modules/agent.js +63 -0
- package/dist/runtime/core/modules/deploy.d.ts +8 -5
- package/dist/runtime/core/modules/deploy.js +62 -16
- package/dist/runtime/core/modules/pages.js +397 -20
- package/dist/runtime/core/modules/surfaces.js +8 -0
- package/dist/runtime/core/phase.d.ts +168 -0
- package/dist/runtime/core/phase.js +367 -0
- package/dist/runtime/core/runtime.d.ts +17 -0
- package/dist/runtime/core/runtime.js +30 -0
- package/dist/runtime/index.d.ts +6 -0
- package/dist/runtime/index.js +7 -0
- package/dist/toolkit/derivers/system-brief.d.ts +62 -0
- package/dist/toolkit/derivers/system-brief.js +156 -0
- package/dist/toolkit/gen.d.ts +5 -5
- package/dist/toolkit/gen.js +20 -14
- package/dist/toolkit/index.d.ts +5 -0
- package/dist/toolkit/index.js +3 -0
- package/dist/toolkit/models.d.ts +4 -3
- package/dist/toolkit/models.js +4 -3
- package/package.json +1 -1
- package/src/runtime/core/events.test.ts +382 -0
- package/src/runtime/core/events.ts +370 -0
- package/src/runtime/core/extensions.test.ts +378 -0
- package/src/runtime/core/extensions.ts +276 -0
- package/src/runtime/core/glob.ts +15 -12
- package/src/runtime/core/host.ts +4 -1
- package/src/runtime/core/modules/agent.test.ts +104 -0
- package/src/runtime/core/modules/agent.ts +76 -0
- package/src/runtime/core/modules/deploy.test.ts +84 -16
- package/src/runtime/core/modules/deploy.ts +59 -16
- package/src/runtime/core/modules/pages.test.ts +309 -5
- package/src/runtime/core/modules/pages.ts +398 -20
- package/src/runtime/core/modules/surfaces.ts +9 -0
- package/src/runtime/core/phase.test.ts +350 -0
- package/src/runtime/core/phase.ts +526 -0
- package/src/runtime/core/runtime.extensions.test.ts +151 -0
- package/src/runtime/core/runtime.ts +49 -0
- package/src/runtime/devserver.test.ts +3 -0
- package/src/runtime/index.ts +57 -0
- package/src/toolkit/derivers/system-brief.test.ts +150 -0
- package/src/toolkit/derivers/system-brief.ts +210 -0
- package/src/toolkit/gen.test.ts +28 -4
- package/src/toolkit/gen.ts +20 -13
- package/src/toolkit/index.ts +14 -0
- package/src/toolkit/models.ts +4 -3
|
@@ -484,6 +484,14 @@ function rendererShell(homePage: string, apiDocsPath?: string): string {
|
|
|
484
484
|
// console, so the defaults below stand on their own: dark by default, light when
|
|
485
485
|
// the OS asks for it and nothing has themed us. `--pc-*` are kept as thin
|
|
486
486
|
// aliases so existing class rules re-resolve through the shared tokens.
|
|
487
|
+
// The single mobile breakpoint (max-width) for the urban responsive primitive
|
|
488
|
+
// (#268). ONE source of truth: it is interpolated into both the shell CSS
|
|
489
|
+
// `@media` query (which drives the pure-CSS card flip / nav collapse / button
|
|
490
|
+
// stacking) AND the runtime's `matchMedia` mode-switch (which only Tier-2's
|
|
491
|
+
// optional page-level `mobile` layout variant needs), so the two can never
|
|
492
|
+
// drift apart on where "narrow" begins.
|
|
493
|
+
const MOBILE_MAX_WIDTH = "640px";
|
|
494
|
+
|
|
487
495
|
const RENDERER_CSS = `
|
|
488
496
|
:root {
|
|
489
497
|
color-scheme: dark;
|
|
@@ -579,6 +587,30 @@ table.pc-grid th { font-weight:600; color:var(--nano-text-muted); }
|
|
|
579
587
|
.pc-count-badge { color:var(--nano-text); background:var(--nano-inset); border:1px solid var(--nano-edge); font-weight:600; }
|
|
580
588
|
:root[data-appearance="light"] .pc-badge-warn { color:#fff; }
|
|
581
589
|
@media (prefers-color-scheme: light) { :root:not([data-appearance]) .pc-badge-warn { color:#fff; } }
|
|
590
|
+
/* Pipeline / stepper cell (issue #265): a per-row, multi-stage horizontal
|
|
591
|
+
progress track rendered by pipelineCell. Only the track/stage chrome lives
|
|
592
|
+
here (the .pc-pipe classes); the active-stage badge and locus links reuse the
|
|
593
|
+
.pc-badge and .pc-link classes.
|
|
594
|
+
All colours come from the shared --nano-* tokens so light/dark themes work.
|
|
595
|
+
Stage treatments: done = filled/ok-tinted, active = lit accent, active+ok =
|
|
596
|
+
success (✓), active+failed = danger (✕), active+blocked = warn (⊘), upcoming =
|
|
597
|
+
faint/ghosted, skip (not-in-path) = dashed. */
|
|
598
|
+
.pc-pipe { display:flex; align-items:center; flex-wrap:wrap; gap:.15rem; font-size:.8rem; }
|
|
599
|
+
.pc-pipe-stage { display:inline-flex; align-items:center; gap:.3rem; padding:.12rem .5rem; border:1px solid var(--nano-edge); border-radius:999px; background:transparent; color:var(--nano-text-muted); white-space:nowrap; }
|
|
600
|
+
.pc-pipe-label { color:inherit; }
|
|
601
|
+
.pc-pipe-mark { font-weight:700; line-height:1; }
|
|
602
|
+
.pc-pipe-conn { flex:0 0 auto; width:.9rem; height:2px; border-radius:1px; background:var(--nano-edge); }
|
|
603
|
+
.pc-pipe-conn.filled { background:var(--nano-ok); }
|
|
604
|
+
.pc-pipe-done { color:var(--nano-text); border-color:var(--nano-ok); background:var(--nano-hover); }
|
|
605
|
+
.pc-pipe-active { color:var(--nano-text); font-weight:650; border-color:var(--nano-accent); background:var(--nano-hover); box-shadow:0 0 0 1px var(--nano-accent) inset; }
|
|
606
|
+
.pc-pipe-active.pc-pipe-ok { border-color:var(--nano-ok); box-shadow:0 0 0 1px var(--nano-ok) inset; }
|
|
607
|
+
.pc-pipe-active.pc-pipe-ok .pc-pipe-mark { color:var(--nano-ok); }
|
|
608
|
+
.pc-pipe-active.pc-pipe-failed { border-color:var(--nano-danger); box-shadow:0 0 0 1px var(--nano-danger) inset; }
|
|
609
|
+
.pc-pipe-active.pc-pipe-failed .pc-pipe-mark { color:var(--nano-danger); }
|
|
610
|
+
.pc-pipe-active.pc-pipe-blocked { border-color:var(--nano-warn); box-shadow:0 0 0 1px var(--nano-warn) inset; }
|
|
611
|
+
.pc-pipe-active.pc-pipe-blocked .pc-pipe-mark { color:var(--nano-warn); }
|
|
612
|
+
.pc-pipe-upcoming { color:var(--nano-text-faint); border-color:var(--nano-edge); opacity:.75; }
|
|
613
|
+
.pc-pipe-skip { color:var(--nano-text-faint); border-style:dashed; opacity:.6; }
|
|
582
614
|
.pc-child { margin:.6rem 0; }
|
|
583
615
|
.pc-child-title { font-size:.8rem; font-weight:600; color:var(--nano-text-muted); margin-bottom:.25rem; }
|
|
584
616
|
.pc-transcript { white-space:pre-wrap; max-height:22rem; overflow:auto; background:var(--nano-inset); padding:.5rem; border-radius:.4rem; font-size:.8rem; margin-top:.4rem; }
|
|
@@ -626,6 +658,79 @@ table.pc-grid th { font-weight:600; color:var(--nano-text-muted); }
|
|
|
626
658
|
.pc-nav-link.active { background:var(--nano-accent); color:var(--nano-on-accent); }
|
|
627
659
|
.pc-nav-icon { line-height:1; }
|
|
628
660
|
.pc-nav-empty { color:var(--nano-text-faint); font-size:.85rem; padding:.4rem .7rem; }
|
|
661
|
+
/* The per-row mobile "More" toggle (revealing mobile:{priority:"hidden"} columns)
|
|
662
|
+
only exists for the card view — hidden on the desktop table, shown by the
|
|
663
|
+
mobile @media below. Base-hidden here so a grid renders byte-for-byte
|
|
664
|
+
unchanged on desktop even when it carries hidden-column hints. */
|
|
665
|
+
.pc-mcard-toggle { display:none; }
|
|
666
|
+
/* ── Urban responsive / mobile primitive (#268) ──────────────────────────
|
|
667
|
+
Below MOBILE_MAX_WIDTH every app adapts to a phone with ZERO page-schema
|
|
668
|
+
change. The dense dataGrid — the one primitive CSS alone can't reflow — flips
|
|
669
|
+
from a wide <table> to a stacked card list purely from the per-cell
|
|
670
|
+
'data-label' the renderer already stamps on (no JS branching): thead is
|
|
671
|
+
hidden, each <tr> becomes a bordered card and each <td> a full-width
|
|
672
|
+
label:value line whose label is the column header. The nav collapses to a
|
|
673
|
+
thumb-reachable scrollable bottom bar, buttons/form actions go full-width
|
|
674
|
+
single column, and text reflows on its own. The breakpoint is interpolated
|
|
675
|
+
from the shared MOBILE_MAX_WIDTH constant so it can't drift from the runtime's
|
|
676
|
+
matchMedia. */
|
|
677
|
+
@media (max-width:${MOBILE_MAX_WIDTH}) {
|
|
678
|
+
body { padding:1rem; }
|
|
679
|
+
/* dataGrid → card list. Once cells are display:block the fixed colgroup width
|
|
680
|
+
is irrelevant, so a wide table stops overflowing the phone. table-layout is
|
|
681
|
+
reset to auto so the block cells size to content. */
|
|
682
|
+
table.pc-grid { table-layout:auto; }
|
|
683
|
+
table.pc-grid, table.pc-grid tbody, table.pc-grid tr, table.pc-grid td { display:block; width:auto; }
|
|
684
|
+
table.pc-grid colgroup, table.pc-grid thead { display:none; }
|
|
685
|
+
table.pc-grid tr { border:1px solid var(--nano-edge); border-radius:.6rem; padding:.55rem .75rem; margin:.6rem 0; background:var(--nano-panel); }
|
|
686
|
+
table.pc-grid td { border-bottom:0; padding:.15rem 0; display:flex; gap:.75rem; justify-content:space-between; align-items:baseline; }
|
|
687
|
+
/* label:value — the column header (data-label) prefixes the value as a muted
|
|
688
|
+
caption on the same line. Suppressed for the title, chip, actions and any
|
|
689
|
+
colspan (group/empty/error) cells below. */
|
|
690
|
+
table.pc-grid td[data-label]::before { content:attr(data-label); color:var(--nano-text-muted); font-size:.72rem; font-weight:600; text-transform:uppercase; letter-spacing:.03em; flex:0 0 auto; }
|
|
691
|
+
/* The derived (or mobile:{priority:"primary"}-hinted) card title leads the
|
|
692
|
+
card: larger, full width, no label caption. */
|
|
693
|
+
table.pc-grid td.pc-mcell-primary { display:block; font-size:1rem; font-weight:650; padding-top:.15rem; }
|
|
694
|
+
table.pc-grid td.pc-mcell-primary::before { content:none; }
|
|
695
|
+
/* A badge column becomes a left-aligned status chip with no caption. */
|
|
696
|
+
table.pc-grid td.pc-mcell-chip { justify-content:flex-start; }
|
|
697
|
+
table.pc-grid td.pc-mcell-chip::before { content:none; }
|
|
698
|
+
/* An empty badge cell (row value blank) still carries the chip class but has no
|
|
699
|
+
child content; without this it renders as a blank flex row (padding/gap) that
|
|
700
|
+
leaves a stray empty line in the card. Collapse those empty chip cells (#268). */
|
|
701
|
+
table.pc-grid td.pc-mcell-chip:empty { display:none; }
|
|
702
|
+
/* Low-value (mobile:{priority:"hidden"}) columns drop off the card until the
|
|
703
|
+
row's "More" toggle opens them; on desktop they render as normal columns. */
|
|
704
|
+
table.pc-grid td.pc-mcell-hidden { display:none; }
|
|
705
|
+
table.pc-grid tr.pc-open td.pc-mcell-hidden { display:flex; }
|
|
706
|
+
.pc-mcard-toggle { display:block; padding:.3rem 0 0; }
|
|
707
|
+
.pc-mcard-toggle .pc-more { width:100%; margin-right:0; }
|
|
708
|
+
/* Row actions stack full-width under the card body. */
|
|
709
|
+
table.pc-grid td.pc-row-actions { display:flex; flex-wrap:wrap; gap:.4rem; text-align:left; padding-top:.45rem; white-space:normal; }
|
|
710
|
+
table.pc-grid td.pc-row-actions::before { content:none; }
|
|
711
|
+
table.pc-grid td.pc-row-actions .pc-btn { flex:1 1 auto; margin-right:0; }
|
|
712
|
+
/* Group-header + empty/error rows span the full card width with no caption. */
|
|
713
|
+
table.pc-grid td[colspan] { display:block; }
|
|
714
|
+
table.pc-grid td[colspan]::before { content:none; }
|
|
715
|
+
.pc-group-header td { padding:0; }
|
|
716
|
+
/* Nav → horizontally-scrollable bar (bar) / inline stack (rail). The bar keeps
|
|
717
|
+
its normal top-of-flow position and scrolls sideways when the pages overflow;
|
|
718
|
+
an opt-in sticky bar stays pinned to the top via the desktop .pc-sticky rule
|
|
719
|
+
(top:0). A rail drops its fixed side column and flows inline. */
|
|
720
|
+
.pc-layout { display:block; }
|
|
721
|
+
.pc-rail-wrap { position:static; flex-basis:auto; width:auto; margin:0 0 1rem; }
|
|
722
|
+
.pc-rail .pc-nav-items { flex-direction:row; flex-wrap:wrap; }
|
|
723
|
+
.pc-bar { flex-wrap:nowrap; overflow-x:auto; }
|
|
724
|
+
.pc-bar.pc-sticky { position:sticky; }
|
|
725
|
+
.pc-bar .pc-nav-items { flex-wrap:nowrap; }
|
|
726
|
+
.pc-nav-link { white-space:nowrap; }
|
|
727
|
+
.pc-tabs { overflow-x:auto; }
|
|
728
|
+
/* Buttons / form actions go full-width single-column. */
|
|
729
|
+
.pc-buttonrow .pc-btn, .pc-card .pc-btn { width:100%; }
|
|
730
|
+
.pc-modal { max-width:100%; }
|
|
731
|
+
.pc-modal-actions { flex-direction:column; }
|
|
732
|
+
.pc-modal-actions .pc-btn { width:100%; }
|
|
733
|
+
}
|
|
629
734
|
`;
|
|
630
735
|
|
|
631
736
|
// The schema-driven browser renderer (ADR 0042 §3). Plain ES module string served at
|
|
@@ -636,6 +741,14 @@ const RENDERER_JS = String.raw`
|
|
|
636
741
|
const root = document.getElementById("page");
|
|
637
742
|
const HOME = root.dataset.home || "home";
|
|
638
743
|
|
|
744
|
+
// Single mobile breakpoint, interpolated from the same MOBILE_MAX_WIDTH constant
|
|
745
|
+
// as the shell CSS @media so the JS mode-switch and the pure-CSS card flip can
|
|
746
|
+
// never drift on where "narrow" begins (#268). Only Tier-2 (an optional
|
|
747
|
+
// page-level 'mobile' layout variant) needs this JS switch — the dataGrid card
|
|
748
|
+
// flip, nav collapse and button/form stacking are all pure CSS + data-label.
|
|
749
|
+
const MOBILE_MQ = window.matchMedia("(max-width:${MOBILE_MAX_WIDTH})");
|
|
750
|
+
function isNarrow() { return MOBILE_MQ.matches; }
|
|
751
|
+
|
|
639
752
|
// ── Multi-page routing (hash-based, reverse-proxy safe) ──────────────────
|
|
640
753
|
// Pages are selected by the URL fragment (#/<page>) so navigation never hits
|
|
641
754
|
// the server and works identically at the origin root and under the Nano
|
|
@@ -674,6 +787,12 @@ let CURRENT = currentPage();
|
|
|
674
787
|
// this) and to {{param}} text interpolation, so one page template can scope
|
|
675
788
|
// every section to a selected entity (e.g. an epic's plan_key).
|
|
676
789
|
let PARAM = parseRoute().param;
|
|
790
|
+
// Monotonic render token. renderPage() is async and fires from both hashchange
|
|
791
|
+
// and the matchMedia viewport-crossing handler, so two invocations can overlap
|
|
792
|
+
// and their fetches resolve out of order. Each render captures the token it
|
|
793
|
+
// bumped to; after its await it only touches the DOM if it is still the latest,
|
|
794
|
+
// so a stale navigation/viewport render can't overwrite a newer one.
|
|
795
|
+
let renderSeq = 0;
|
|
677
796
|
|
|
678
797
|
// Per-render teardown. Each dataGrid registers its poll interval + pc:refresh
|
|
679
798
|
// listener here; navigating to another page runs every disposer before the new
|
|
@@ -1058,7 +1177,45 @@ function renderButton(node) {
|
|
|
1058
1177
|
// width/weight — see buildColgroup — to give the clip a bounded column). The
|
|
1059
1178
|
// subtitle is ALWAYS plain DOM text, never an href source. With none of these
|
|
1060
1179
|
// set the cell is a single inline node exactly as before (see cellTd).
|
|
1061
|
-
|
|
1180
|
+
// Build an in-app hash route to another page, scoped to a row key: #/<page>/<key>.
|
|
1181
|
+
// The page id is validated against the safe-id charset and the key must be
|
|
1182
|
+
// non-empty (after trimming); either failing yields "" (no link). The key is
|
|
1183
|
+
// URL-encoded into the route's param tail, which parseRoute() decodes back
|
|
1184
|
+
// verbatim, so row data can't smuggle a path or scheme. SINGLE source of truth
|
|
1185
|
+
// for the page-link href so the grid's link cell and the pipeline locus link
|
|
1186
|
+
// (issue #265) can't drift on how the route is built.
|
|
1187
|
+
function pageHashHref(page, key) {
|
|
1188
|
+
const keyStr = key == null ? "" : String(key).trim();
|
|
1189
|
+
if (!safePageId(page) || keyStr === "") return "";
|
|
1190
|
+
return "#/" + encodeURIComponent(page) + "/" + encodeURIComponent(keyStr);
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1193
|
+
// Coerce a not-in-path value (issue #265) into a Set of stage keys. Accepts an
|
|
1194
|
+
// array of keys or a comma/whitespace-separated string; null/undefined → empty
|
|
1195
|
+
// set. Used to mark the stages a given row skips (dashed/omitted).
|
|
1196
|
+
function toStageSet(v) {
|
|
1197
|
+
// Trim + drop-empties on BOTH inputs so array entries with stray whitespace
|
|
1198
|
+
// (e.g. from CSV/JSON munging) match stages[].key just like the string path.
|
|
1199
|
+
if (Array.isArray(v)) return new Set(v.map((s) => String(s).trim()).filter((s) => s !== ""));
|
|
1200
|
+
if (v == null) return new Set();
|
|
1201
|
+
return new Set(String(v).split(/[\s,]+/).filter((s) => s !== ""));
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
function gridCell(col, row, role) {
|
|
1205
|
+
// Mobile card attributes stamped on every td so a dataGrid can flip to a
|
|
1206
|
+
// stacked card list below the breakpoint with no JS branching (#268):
|
|
1207
|
+
// 'data-label' drives the pure-CSS label:value line (the column header, or a
|
|
1208
|
+
// mobile:{label} override), and the role class picks the card region (title /
|
|
1209
|
+
// status chip / secondary field / hidden). The role is derived by convention
|
|
1210
|
+
// (classifyColumns) and refinable per-column via col.mobile.priority.
|
|
1211
|
+
const mrole = role || "secondary";
|
|
1212
|
+
const mlabel =
|
|
1213
|
+
col.mobile && typeof col.mobile.label === "string"
|
|
1214
|
+
? col.mobile.label
|
|
1215
|
+
: col.header != null
|
|
1216
|
+
? String(col.header)
|
|
1217
|
+
: String(col.field == null ? "" : col.field);
|
|
1218
|
+
const mob = { class: "pc-mcell pc-mcell-" + mrole, "data-label": mlabel };
|
|
1062
1219
|
// Raw single-field value: drives the badge presence gate + tooltip and any
|
|
1063
1220
|
// field-derived defaults. Kept separate from the (possibly templated) display
|
|
1064
1221
|
// text so a template never re-lights or blanks a badge.
|
|
@@ -1077,13 +1234,17 @@ function gridCell(col, row) {
|
|
|
1077
1234
|
// field text is also mirrored into aria-label so assistive tech announces
|
|
1078
1235
|
// the incident/status text (the visible "1" glyph alone is not meaningful).
|
|
1079
1236
|
if (col.badge) {
|
|
1080
|
-
|
|
1237
|
+
// Even when blank, stamp data-label (the "every td carries data-label"
|
|
1238
|
+
// invariant): the cell still collapses on mobile via the pc-mcell-chip:empty
|
|
1239
|
+
// rule (attributes don't defeat :empty), so this keeps empty and non-empty
|
|
1240
|
+
// badge cells consistent without re-lighting the label.
|
|
1241
|
+
if (rawText.trim() === "") return el("td", { class: "pc-mcell pc-mcell-chip", "data-label": mlabel });
|
|
1081
1242
|
const t = col.badge.tone;
|
|
1082
1243
|
const tone = t === "warn" || t === "ok" || t === "info" ? t : "danger";
|
|
1083
1244
|
const label = col.badge.label == null ? "1" : String(col.badge.label);
|
|
1084
1245
|
return el(
|
|
1085
1246
|
"td",
|
|
1086
|
-
|
|
1247
|
+
mob,
|
|
1087
1248
|
el("span", { class: "pc-badge pc-badge-" + tone, title: rawText, "aria-label": rawText }, label),
|
|
1088
1249
|
);
|
|
1089
1250
|
}
|
|
@@ -1096,6 +1257,14 @@ function gridCell(col, row) {
|
|
|
1096
1257
|
col.subtitleField != null && row[col.subtitleField] != null ? String(row[col.subtitleField]) : "";
|
|
1097
1258
|
const subText = typeof col.subtitleTemplate === "string" ? interpTemplate(col.subtitleTemplate, row) : subRaw;
|
|
1098
1259
|
const truncate = col.truncate === true;
|
|
1260
|
+
// pipeline (issue #265): a dataGrid column declaring kind:"pipeline" renders
|
|
1261
|
+
// the ordered stages as a per-row horizontal progress track (upstream-filled
|
|
1262
|
+
// → active-lit → downstream-ghosted, not-in-path dashed). It owns the whole
|
|
1263
|
+
// cell, so it returns here before the link chain below. Gated purely on the
|
|
1264
|
+
// discriminator so every existing column mode is untouched when it is absent;
|
|
1265
|
+
// unknown/missing pipeline config degrades to plain cell text (never throws),
|
|
1266
|
+
// exactly as an unrecognised link.kind falls back today.
|
|
1267
|
+
if (col.kind === "pipeline") return pipelineCell(col, row, text, subText, truncate, mob);
|
|
1099
1268
|
// Primary inline content: an anchor for a valid link mode (checked in the same
|
|
1100
1269
|
// badge < linkField < link(page) < link(processExplorer) precedence as before),
|
|
1101
1270
|
// else the plain display text. Each link mode only claims the cell while
|
|
@@ -1109,16 +1278,13 @@ function gridCell(col, row) {
|
|
|
1109
1278
|
}
|
|
1110
1279
|
}
|
|
1111
1280
|
if (primary === text && col.link && col.link.kind === "page" && col.link.page && col.link.keyField) {
|
|
1112
|
-
// An in-app link to another page, scoped to this row: #/<page>/<key>.
|
|
1113
|
-
//
|
|
1114
|
-
// param tail, which parseRoute() decodes back verbatim; the page id is
|
|
1281
|
+
// An in-app link to another page, scoped to this row: #/<page>/<key>. Built
|
|
1282
|
+
// via pageHashHref (the single source of truth for the route): the page id is
|
|
1115
1283
|
// validated against the safe-id charset and the key must be non-empty, so a
|
|
1116
1284
|
// blank/keyless cell stays plain text. Navigation is a pure hash change
|
|
1117
1285
|
// (no new tab, no server hit) — the SPA router re-renders in place.
|
|
1118
|
-
const
|
|
1119
|
-
|
|
1120
|
-
if (text !== "" && safePageId(col.link.page) && keyStr !== "") {
|
|
1121
|
-
const href = "#/" + encodeURIComponent(col.link.page) + "/" + encodeURIComponent(keyStr);
|
|
1286
|
+
const href = pageHashHref(col.link.page, row[col.link.keyField]);
|
|
1287
|
+
if (text !== "" && href !== "") {
|
|
1122
1288
|
primary = el("a", { class: "pc-link", href }, text);
|
|
1123
1289
|
}
|
|
1124
1290
|
}
|
|
@@ -1145,7 +1311,7 @@ function gridCell(col, row) {
|
|
|
1145
1311
|
}, text);
|
|
1146
1312
|
}
|
|
1147
1313
|
}
|
|
1148
|
-
return cellTd(primary, text, subText, truncate);
|
|
1314
|
+
return cellTd(primary, text, subText, truncate, mob);
|
|
1149
1315
|
}
|
|
1150
1316
|
|
|
1151
1317
|
// Compose a grid <td> from its primary inline content (a string or an anchor),
|
|
@@ -1160,9 +1326,12 @@ function gridCell(col, row) {
|
|
|
1160
1326
|
// aria-label= are ALSO mirrored onto it: HTML does not inherit those to
|
|
1161
1327
|
// descendants, so hovering the link text or naming the anchor for assistive tech
|
|
1162
1328
|
// would otherwise miss the full value the wrapper carries. The subtitle is set as
|
|
1163
|
-
// DOM text only — never an href.
|
|
1164
|
-
|
|
1165
|
-
|
|
1329
|
+
// DOM text only — never an href. 'tdAttrs' (the mobile card attrs: data-label +
|
|
1330
|
+
// role class, see gridCell) is applied to whichever <td> shape is returned so
|
|
1331
|
+
// the CSS-only card flip labels every cell identically (#268).
|
|
1332
|
+
function cellTd(primary, primaryText, subText, truncate, tdAttrs) {
|
|
1333
|
+
const td = tdAttrs || {};
|
|
1334
|
+
if (subText === "" && !truncate) return el("td", td, primary);
|
|
1166
1335
|
const mainAttrs = { class: "pc-cell-main" + (truncate ? " pc-truncate" : "") };
|
|
1167
1336
|
if (truncate && primaryText !== "") {
|
|
1168
1337
|
mainAttrs.title = primaryText; mainAttrs["aria-label"] = primaryText;
|
|
@@ -1171,10 +1340,178 @@ function cellTd(primary, primaryText, subText, truncate) {
|
|
|
1171
1340
|
}
|
|
1172
1341
|
}
|
|
1173
1342
|
const main = el("div", mainAttrs, primary);
|
|
1174
|
-
if (subText === "") return el("td",
|
|
1343
|
+
if (subText === "") return el("td", td, main);
|
|
1175
1344
|
const subAttrs = { class: "pc-cell-sub" + (truncate ? " pc-truncate" : "") };
|
|
1176
1345
|
if (truncate) { subAttrs.title = subText; subAttrs["aria-label"] = subText; }
|
|
1177
|
-
return el("td",
|
|
1346
|
+
return el("td", td, main, el("div", subAttrs, subText));
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
// Classify each grid column into a mobile-card region so a dataGrid flips to a
|
|
1350
|
+
// stacked card list below the breakpoint with ZERO page-schema change (#268).
|
|
1351
|
+
// Convention (Tier 0): the first non-badge column is the card title (primary), a
|
|
1352
|
+
// badge column is a status chip, and everything else is a secondary label:value
|
|
1353
|
+
// row. Tier 1 refines it — a column may carry mobile:{priority:"primary" |
|
|
1354
|
+
// "secondary" | "hidden"}: an explicit "primary" suppresses the auto title pick
|
|
1355
|
+
// so a later column can lead the card, "hidden" drops the column off the card
|
|
1356
|
+
// (behind the row's "More" toggle), and "secondary" forces a plain field row.
|
|
1357
|
+
function classifyColumns(cols) {
|
|
1358
|
+
const list = cols || [];
|
|
1359
|
+
const explicitPrimary = list.some((c) => c && c.mobile && c.mobile.priority === "primary");
|
|
1360
|
+
let titleTaken = explicitPrimary;
|
|
1361
|
+
return list.map((col) => {
|
|
1362
|
+
const pr = col && col.mobile ? col.mobile.priority : null;
|
|
1363
|
+
if (pr === "primary") return "primary";
|
|
1364
|
+
if (pr === "secondary") return "secondary";
|
|
1365
|
+
if (pr === "hidden") return "hidden";
|
|
1366
|
+
if (col && col.badge) return "chip";
|
|
1367
|
+
if (!titleTaken) { titleTaken = true; return "primary"; }
|
|
1368
|
+
return "secondary";
|
|
1369
|
+
});
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
// Per-row mobile "More" toggle cell: reveals the mobile:{priority:"hidden"} columns
|
|
1373
|
+
// a narrow viewport drops off the card. The cell is base-hidden (display:none) so
|
|
1374
|
+
// the desktop table is byte-for-byte unchanged; clicking flips .pc-open on the row,
|
|
1375
|
+
// swaps the label, and updates aria-expanded so the reveal state is exposed to
|
|
1376
|
+
// assistive tech (#268). One implementation shared by the top-level grid and child
|
|
1377
|
+
// grids so the affordance — and its accessibility — can't drift between them.
|
|
1378
|
+
function mobileMoreCell(tr) {
|
|
1379
|
+
const moreBtn = el("button",
|
|
1380
|
+
{ class: "pc-btn pc-btn-sm pc-btn-ghost pc-more", type: "button", "aria-expanded": "false" }, "More");
|
|
1381
|
+
moreBtn.addEventListener("click", () => {
|
|
1382
|
+
const open = tr.classList.toggle("pc-open");
|
|
1383
|
+
moreBtn.textContent = open ? "Less" : "More";
|
|
1384
|
+
moreBtn.setAttribute("aria-expanded", String(open));
|
|
1385
|
+
});
|
|
1386
|
+
return el("td", { class: "pc-mcard-toggle" }, moreBtn);
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1389
|
+
// Pipeline / stepper cell (issue #265) — a dataGrid column with kind:"pipeline"
|
|
1390
|
+
// renders a per-row, multi-stage horizontal progress track. It is RENDER-ONLY:
|
|
1391
|
+
// stage state is read straight from the row fields the app supplies; no
|
|
1392
|
+
// app-specific stage derivation lives here. Column config (all fields are the
|
|
1393
|
+
// NAMES of row fields, mirroring the issue sketch):
|
|
1394
|
+
// { kind:"pipeline",
|
|
1395
|
+
// stages:[{key,label},...], // ordered stage definitions (required)
|
|
1396
|
+
// activeField:"stage", // row field → the current stage's key
|
|
1397
|
+
// stateField:"stage_state", // row field → ok | active | failed | blocked
|
|
1398
|
+
// badgeField:"attention", // optional row field → badge text shown on the active stage
|
|
1399
|
+
// notInPathField:"skipped", // optional row field → stages this row skips
|
|
1400
|
+
// notInPath:["converging"], // static fallback used only when no field given
|
|
1401
|
+
// locus:{ field:"pr_key", stage?:"<key>",
|
|
1402
|
+
// link:{ kind:"page", page:"home" } } } // optional out-link
|
|
1403
|
+
// Rendering: stages BEFORE the active one are filled/completed, the active stage
|
|
1404
|
+
// is lit (its treatment driven by stateField — success ✓ vs failure ✕ vs blocked
|
|
1405
|
+
// ⊘ are made unmistakably distinct), in-path stages AFTER it are ghosted, and any
|
|
1406
|
+
// stage in the row's not-in-path set is dashed. Reuses the .pc-badge and .pc-link
|
|
1407
|
+
// classes and the shared pageHashHref route builder — no parallel implementations. Unknown or
|
|
1408
|
+
// missing config (no stages array) degrades gracefully to plain cell text.
|
|
1409
|
+
function pipelineCell(col, row, text, subText, truncate, tdAttrs) {
|
|
1410
|
+
// Drop null/undefined entries defensively: a schema with a hole must still
|
|
1411
|
+
// render (never throws on s.key) — same graceful-degradation goal as below.
|
|
1412
|
+
const stages = Array.isArray(col.stages) ? col.stages.filter((s) => s != null) : [];
|
|
1413
|
+
// Graceful fallback: an unrecognised/empty pipeline config renders plain text,
|
|
1414
|
+
// exactly like an unknown link.kind — never throws.
|
|
1415
|
+
if (stages.length === 0) return cellTd(text, text, subText, truncate, tdAttrs);
|
|
1416
|
+
// The current stage's key, matched against stages[].key to find the active index.
|
|
1417
|
+
// The row value is trimmed for consistency with the other row-derived keys
|
|
1418
|
+
// (pageHashHref, toStageSet), so a whitespace-padded value still matches its stage
|
|
1419
|
+
// instead of leaving the whole track rendered as upcoming.
|
|
1420
|
+
// Stage keys identify a single stage, so stop at the first match: the result is
|
|
1421
|
+
// deterministic even if a config accidentally repeats a key, and we avoid scanning
|
|
1422
|
+
// the remaining stages on every row.
|
|
1423
|
+
const activeKey = col.activeField != null && row[col.activeField] != null ? String(row[col.activeField]).trim() : "";
|
|
1424
|
+
let activeIdx = -1;
|
|
1425
|
+
for (let i = 0; i < stages.length; i++) {
|
|
1426
|
+
if (String(stages[i].key) === activeKey) {
|
|
1427
|
+
activeIdx = i;
|
|
1428
|
+
break;
|
|
1429
|
+
}
|
|
1430
|
+
}
|
|
1431
|
+
// The active stage's state drives its lit/failed/blocked treatment. Anything
|
|
1432
|
+
// outside the allow-list (or absent) is treated as an in-progress "active".
|
|
1433
|
+
const stRaw = col.stateField != null && row[col.stateField] != null ? String(row[col.stateField]) : "";
|
|
1434
|
+
const state = stRaw === "ok" || stRaw === "failed" || stRaw === "blocked" ? stRaw : "active";
|
|
1435
|
+
// Not-in-path (skipped) stages: driven per-row from notInPathField when given,
|
|
1436
|
+
// else the static notInPath config (per the issue: "per row, from a field").
|
|
1437
|
+
const skip =
|
|
1438
|
+
col.notInPathField != null && row[col.notInPathField] != null
|
|
1439
|
+
? toStageSet(row[col.notInPathField])
|
|
1440
|
+
: toStageSet(col.notInPath);
|
|
1441
|
+
// Optional active-stage badge (escalation/attention → warn, blocked/failure →
|
|
1442
|
+
// danger), reusing .pc-badge tone classes — no new badge styles. The badge text
|
|
1443
|
+
// is a single row-level value (row[badgeField]) shown only on the active stage.
|
|
1444
|
+
const badgeText = col.badgeField != null && row[col.badgeField] != null ? String(row[col.badgeField]) : "";
|
|
1445
|
+
const badgeTone = state === "failed" || state === "blocked" ? "danger" : "warn";
|
|
1446
|
+
// Optional locus out-link: the relevant stage (default the active one, or
|
|
1447
|
+
// locus.stage by key) becomes an in-app page link when the row's locus key is
|
|
1448
|
+
// non-empty. Href comes from the shared pageHashHref builder (safePageId guard,
|
|
1449
|
+
// encodeURIComponent) — a blank key yields "" so the stage stays plain.
|
|
1450
|
+
const locus = col.locus;
|
|
1451
|
+
const locusKey = locus && locus.field != null && row[locus.field] != null ? String(row[locus.field]) : "";
|
|
1452
|
+
const locusHref =
|
|
1453
|
+
locus && locus.link && locus.link.kind === "page" && locus.link.page ? pageHashHref(locus.link.page, locusKey) : "";
|
|
1454
|
+
const track = el("div", {
|
|
1455
|
+
class: "pc-pipe",
|
|
1456
|
+
role: "list",
|
|
1457
|
+
"aria-label": "Progress" + (activeIdx >= 0 ? ": " + labelOf(stages[activeIdx]) : ""),
|
|
1458
|
+
});
|
|
1459
|
+
for (let i = 0; i < stages.length; i++) {
|
|
1460
|
+
const s = stages[i];
|
|
1461
|
+
// Active wins over skip: if the active stage's key is also in the not-in-path
|
|
1462
|
+
// set, it must still render as the current step (active styling + aria-current),
|
|
1463
|
+
// never as skipped. Excluding activeIdx here keeps that precedence consistent
|
|
1464
|
+
// across the stage class, the aria-current mark, and the connector fill below.
|
|
1465
|
+
const skipped = i !== activeIdx && skip.has(String(s.key));
|
|
1466
|
+
// Connector between adjacent stages; filled up to and including the active
|
|
1467
|
+
// stage, but never across a not-in-path stage — a skipped predecessor breaks
|
|
1468
|
+
// the fill so we don't visually imply it was on the path.
|
|
1469
|
+
if (i > 0) {
|
|
1470
|
+
const filled =
|
|
1471
|
+
activeIdx >= 0 && i <= activeIdx && !skipped && !skip.has(String(stages[i - 1].key)) ? " filled" : "";
|
|
1472
|
+
track.append(el("span", { class: "pc-pipe-conn" + filled, "aria-hidden": "true" }));
|
|
1473
|
+
}
|
|
1474
|
+
let cls;
|
|
1475
|
+
let word;
|
|
1476
|
+
let glyph = "";
|
|
1477
|
+
let current = false;
|
|
1478
|
+
if (skipped) {
|
|
1479
|
+
cls = "pc-pipe-skip"; word = "skipped";
|
|
1480
|
+
} else if (activeIdx >= 0 && i < activeIdx) {
|
|
1481
|
+
cls = "pc-pipe-done"; word = "completed";
|
|
1482
|
+
} else if (i === activeIdx) {
|
|
1483
|
+
current = true;
|
|
1484
|
+
if (state === "failed") { cls = "pc-pipe-active pc-pipe-failed"; word = "failed"; glyph = "\u2715"; }
|
|
1485
|
+
else if (state === "blocked") { cls = "pc-pipe-active pc-pipe-blocked"; word = "blocked"; glyph = "\u2298"; }
|
|
1486
|
+
else if (state === "ok") { cls = "pc-pipe-active pc-pipe-ok"; word = "done"; glyph = "\u2713"; }
|
|
1487
|
+
else { cls = "pc-pipe-active"; word = "current"; }
|
|
1488
|
+
} else {
|
|
1489
|
+
cls = "pc-pipe-upcoming"; word = "upcoming";
|
|
1490
|
+
}
|
|
1491
|
+
const isLocus = locusHref !== "" && (locus.stage != null ? String(s.key) === String(locus.stage) : i === activeIdx);
|
|
1492
|
+
const label = labelOf(s);
|
|
1493
|
+
const labelNode = isLocus
|
|
1494
|
+
? el("a", { class: "pc-link pc-pipe-label", href: locusHref }, label)
|
|
1495
|
+
: el("span", { class: "pc-pipe-label" }, label);
|
|
1496
|
+
const attrs = { class: "pc-pipe-stage " + cls, role: "listitem", "aria-label": label + " \u2014 " + word };
|
|
1497
|
+
if (current) attrs["aria-current"] = "step";
|
|
1498
|
+
const stage = el("span", attrs, labelNode);
|
|
1499
|
+
if (glyph !== "") stage.append(el("span", { class: "pc-pipe-mark", "aria-hidden": "true" }, glyph));
|
|
1500
|
+
if (current && badgeText.trim() !== "") {
|
|
1501
|
+
stage.append(el("span", { class: "pc-badge pc-badge-" + badgeTone, title: badgeText, "aria-label": badgeText }, badgeText));
|
|
1502
|
+
}
|
|
1503
|
+
track.append(stage);
|
|
1504
|
+
}
|
|
1505
|
+
// The mobile card attrs (data-label + role class, #268) stamped by gridCell are
|
|
1506
|
+
// merged onto the pipeline <td> too, alongside its own pc-pipe-cell class, so a
|
|
1507
|
+
// pipeline column labels and classifies identically under the CSS-only card flip.
|
|
1508
|
+
const cellAttrs = { ...(tdAttrs || {}), class: (tdAttrs && tdAttrs.class ? tdAttrs.class + " " : "") + "pc-pipe-cell" };
|
|
1509
|
+
return el("td", cellAttrs, track);
|
|
1510
|
+
}
|
|
1511
|
+
|
|
1512
|
+
// A stage's visible label: its declared label, else its key as a fallback.
|
|
1513
|
+
function labelOf(stage) {
|
|
1514
|
+
return stage.label == null ? String(stage.key) : String(stage.label);
|
|
1178
1515
|
}
|
|
1179
1516
|
|
|
1180
1517
|
// Parse a "<number>%" width into its numeric percentage, or null if the string
|
|
@@ -1412,6 +1749,12 @@ function renderDataGrid(node) {
|
|
|
1412
1749
|
card.append(h2);
|
|
1413
1750
|
}
|
|
1414
1751
|
const cols = p.columns || [];
|
|
1752
|
+
// Mobile card roles per column (derived by convention, refined by
|
|
1753
|
+
// col.mobile.priority) so the grid can flip to a stacked card list on a phone
|
|
1754
|
+
// (#268). 'hasHidden' gates the per-row "More" toggle that reveals the columns
|
|
1755
|
+
// a mobile:{priority:"hidden"} hint drops off the card.
|
|
1756
|
+
const roles = classifyColumns(cols);
|
|
1757
|
+
const hasHidden = roles.indexOf("hidden") >= 0;
|
|
1415
1758
|
const tabs = p.tabs || [];
|
|
1416
1759
|
const rowActions = p.rowActions || [];
|
|
1417
1760
|
const detail = p.detail || null;
|
|
@@ -1535,6 +1878,8 @@ function renderDataGrid(node) {
|
|
|
1535
1878
|
const wrap = el("div", { class: "pc-child" });
|
|
1536
1879
|
if (cg.title) wrap.append(el("div", { class: "pc-child-title" }, cg.title));
|
|
1537
1880
|
const ccols = cg.columns || [];
|
|
1881
|
+
const croles = classifyColumns(ccols);
|
|
1882
|
+
const chasHidden = croles.indexOf("hidden") >= 0;
|
|
1538
1883
|
const cbody = el("tbody", {});
|
|
1539
1884
|
const ccolgroup = buildColgroup(ccols, cg.lazyField ? 1 : 0);
|
|
1540
1885
|
const cthead = el("thead", {}, el("tr", {}, ...ccols.map((c) => el("th", {}, c.header || c.field)),
|
|
@@ -1551,7 +1896,7 @@ function renderDataGrid(node) {
|
|
|
1551
1896
|
cbody.append(el("tr", {}, el("td", { colspan: cspan }, "None")));
|
|
1552
1897
|
}
|
|
1553
1898
|
for (const cr of rows) {
|
|
1554
|
-
const cells = ccols.map((c) => gridCell(c, cr));
|
|
1899
|
+
const cells = ccols.map((c, i) => gridCell(c, cr, croles[i]));
|
|
1555
1900
|
if (cg.lazyField) {
|
|
1556
1901
|
const lf = cg.lazyField;
|
|
1557
1902
|
const has = cr[lf.field] != null && String(cr[lf.field]).trim() !== "";
|
|
@@ -1568,7 +1913,13 @@ function renderDataGrid(node) {
|
|
|
1568
1913
|
}
|
|
1569
1914
|
cells.push(cell);
|
|
1570
1915
|
}
|
|
1571
|
-
|
|
1916
|
+
// Child grids classify columns into the same mobile roles (including
|
|
1917
|
+
// "hidden") as the top-level grid, so they need the same per-row "More"
|
|
1918
|
+
// toggle — without it a mobile:{priority:"hidden"} child column would be
|
|
1919
|
+
// permanently unreachable on a narrow viewport (#268).
|
|
1920
|
+
const ctr = el("tr", {}, ...cells);
|
|
1921
|
+
if (chasHidden) ctr.append(mobileMoreCell(ctr));
|
|
1922
|
+
cbody.append(ctr);
|
|
1572
1923
|
}
|
|
1573
1924
|
} catch (e) {
|
|
1574
1925
|
cbody.append(el("tr", {}, el("td", { colspan: cspan }, String(e.message || e))));
|
|
@@ -1605,7 +1956,7 @@ function renderDataGrid(node) {
|
|
|
1605
1956
|
}
|
|
1606
1957
|
|
|
1607
1958
|
function renderRow(row, sink) {
|
|
1608
|
-
const cells = cols.map((c) => gridCell(c, row));
|
|
1959
|
+
const cells = cols.map((c, i) => gridCell(c, row, roles[i]));
|
|
1609
1960
|
const key = rowKeyOf(row);
|
|
1610
1961
|
let toggle = null;
|
|
1611
1962
|
if (hasExtra) {
|
|
@@ -1620,7 +1971,12 @@ function renderDataGrid(node) {
|
|
|
1620
1971
|
}
|
|
1621
1972
|
cells.push(actionCell);
|
|
1622
1973
|
}
|
|
1974
|
+
// Per-row "More" toggle: only when a mobile:{priority:"hidden"} hint drops
|
|
1975
|
+
// columns off the card. Appended after the <tr> is built (the toggle wires a
|
|
1976
|
+
// click against its own row) and shared with child grids via mobileMoreCell so
|
|
1977
|
+
// the reveal affordance and its aria state can't drift (#268).
|
|
1623
1978
|
const tr = el("tr", {}, ...cells);
|
|
1979
|
+
if (hasHidden) tr.append(mobileMoreCell(tr));
|
|
1624
1980
|
tbody.append(tr);
|
|
1625
1981
|
// When grouping, the caller collects every <tr> this row produced (the data
|
|
1626
1982
|
// row plus any detail row) so a group header can hide/show them as one unit.
|
|
@@ -1951,19 +2307,31 @@ function makeCollapsible(node, card) {
|
|
|
1951
2307
|
return container;
|
|
1952
2308
|
}
|
|
1953
2309
|
|
|
2310
|
+
// Tier-2 escape hatch (#268): a page may declare a distinct 'mobile' layout
|
|
2311
|
+
// variant — its own node list — for the rare case the derived card flip isn't
|
|
2312
|
+
// enough (reorder/omit sections, swap a dense grid for a summary card). It is
|
|
2313
|
+
// used ONLY on a narrow viewport; the default 'nodes' render everywhere else,
|
|
2314
|
+
// and anything malformed falls back to them, so the variant is purely additive.
|
|
2315
|
+
function pickNodes(doc) {
|
|
2316
|
+
if (isNarrow() && doc && doc.mobile && Array.isArray(doc.mobile.nodes)) return doc.mobile.nodes;
|
|
2317
|
+
return (doc && doc.nodes) || [];
|
|
2318
|
+
}
|
|
2319
|
+
|
|
1954
2320
|
// Render the page named by the current hash route. A rail nav is lifted into a
|
|
1955
2321
|
// left <aside> and the rest of the nodes flow into a content column; otherwise
|
|
1956
2322
|
// (bar nav or none) nodes render in document order. Re-runs on every hashchange,
|
|
1957
2323
|
// tearing down the previous page's grid polls first.
|
|
1958
2324
|
async function renderPage() {
|
|
1959
2325
|
teardown();
|
|
2326
|
+
const mySeq = ++renderSeq;
|
|
1960
2327
|
const route = parseRoute();
|
|
1961
2328
|
CURRENT = route.page;
|
|
1962
2329
|
PARAM = route.param;
|
|
1963
2330
|
try {
|
|
1964
2331
|
const doc = await getJSON("/app/pages/" + encodeURIComponent(CURRENT));
|
|
2332
|
+
if (mySeq !== renderSeq) return;
|
|
1965
2333
|
document.title = (doc && doc.title) || "Urban App";
|
|
1966
|
-
const nodes = (doc
|
|
2334
|
+
const nodes = pickNodes(doc);
|
|
1967
2335
|
const built = nodes.map((n) => ({ n, node: makeCollapsible(n, (RENDERERS[n.type] || (() => el("div")))(n)) }));
|
|
1968
2336
|
const rail = built.find((b) => b.n.type === "nav" && b.n.props && b.n.props.variant === "rail");
|
|
1969
2337
|
if (rail) {
|
|
@@ -1974,10 +2342,20 @@ async function renderPage() {
|
|
|
1974
2342
|
root.replaceChildren(...built.map((b) => b.node));
|
|
1975
2343
|
}
|
|
1976
2344
|
} catch (e) {
|
|
2345
|
+
if (mySeq !== renderSeq) return;
|
|
1977
2346
|
root.replaceChildren(el("p", { class: "pc-msg err" }, "Failed to load page: " + String((e && e.message) || e)));
|
|
1978
2347
|
}
|
|
1979
2348
|
}
|
|
1980
2349
|
window.addEventListener("hashchange", renderPage);
|
|
2350
|
+
// Re-render when the viewport crosses the mobile breakpoint so a Tier-2 'mobile'
|
|
2351
|
+
// variant swaps in/out on rotation or a window resize (the grid card flip, nav
|
|
2352
|
+
// collapse and button stacking are pure CSS and need no re-render). teardown()
|
|
2353
|
+
// inside renderPage stops the outgoing page's grid polls first. Prefer the modern
|
|
2354
|
+
// addEventListener but fall back to the deprecated addListener so older Safari/iOS
|
|
2355
|
+
// (< 14), where MediaQueryList.addEventListener is unimplemented, still swaps the
|
|
2356
|
+
// Tier-2 variant on rotation/resize instead of silently failing to register.
|
|
2357
|
+
if (typeof MOBILE_MQ.addEventListener === "function") MOBILE_MQ.addEventListener("change", renderPage);
|
|
2358
|
+
else if (typeof MOBILE_MQ.addListener === "function") MOBILE_MQ.addListener(renderPage);
|
|
1981
2359
|
renderPage();
|
|
1982
2360
|
`;
|
|
1983
2361
|
|
|
@@ -11,6 +11,7 @@ import type { AppApi, RuntimeContext } from "../context.ts";
|
|
|
11
11
|
import { presentFormIdentifier } from "../host.ts";
|
|
12
12
|
import { html, json, noContent, normalizeRoutePath, type Route } from "../router.ts";
|
|
13
13
|
import { mountActions } from "./actions.ts";
|
|
14
|
+
import { mountAgent } from "./agent.ts";
|
|
14
15
|
import { mountApi } from "./api.ts";
|
|
15
16
|
import { mountPages } from "./pages.ts";
|
|
16
17
|
|
|
@@ -299,6 +300,14 @@ export function mountSurfaces(ctx: RuntimeContext, app: AppApi): SurfacesHandle
|
|
|
299
300
|
enabled.push("api");
|
|
300
301
|
}
|
|
301
302
|
|
|
303
|
+
// The app-scoped institutional-memory brief (ADR 0060 §2): `/app/agent` + `/app/agent.json`,
|
|
304
|
+
// the app-level mirror of the node `/agent`. Mounted unconditionally (before the generic pages
|
|
305
|
+
// routes, though its exact paths never collide) — the brief is a property of the app's models,
|
|
306
|
+
// not an opt-in surface, and reads through to the `urban gen`-derived artifacts.
|
|
307
|
+
const agent = mountAgent(ctx);
|
|
308
|
+
routes.push(...agent.routes);
|
|
309
|
+
enabled.push("agent@/app/agent");
|
|
310
|
+
|
|
302
311
|
// The pages surface (the schema-driven page runtime) mounts its own routes.
|
|
303
312
|
const pages = mountPages(ctx, app);
|
|
304
313
|
if (pages.routes.length > 0) {
|