@archie/devtools 0.0.24 → 0.0.26

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.
@@ -9595,15 +9595,14 @@ function installDomMetaSanitizer() {
9595
9595
  _origError(msg, ...rest);
9596
9596
  };
9597
9597
  }
9598
- installDomMetaSanitizer();
9599
9598
 
9600
9599
  // src/client/useArchieDevToolsRuntime.ts
9601
- installDomMetaSanitizer();
9602
9600
  function useArchieDevToolsRuntime({
9603
9601
  router,
9604
9602
  inspector,
9605
9603
  inspectorOptions
9606
9604
  }) {
9605
+ installDomMetaSanitizer();
9607
9606
  const stableOptionsKey = JSON.stringify(inspectorOptions ?? null);
9608
9607
  const inspectorOptionsRef = (0, import_react20.useRef)(inspectorOptions);
9609
9608
  inspectorOptionsRef.current = inspectorOptions;
@@ -9560,15 +9560,14 @@ function installDomMetaSanitizer() {
9560
9560
  _origError(msg, ...rest);
9561
9561
  };
9562
9562
  }
9563
- installDomMetaSanitizer();
9564
9563
 
9565
9564
  // src/client/useArchieDevToolsRuntime.ts
9566
- installDomMetaSanitizer();
9567
9565
  function useArchieDevToolsRuntime({
9568
9566
  router,
9569
9567
  inspector,
9570
9568
  inspectorOptions
9571
9569
  }) {
9570
+ installDomMetaSanitizer();
9572
9571
  const stableOptionsKey = JSON.stringify(inspectorOptions ?? null);
9573
9572
  const inspectorOptionsRef = useRef11(inspectorOptions);
9574
9573
  inspectorOptionsRef.current = inspectorOptions;
@@ -424,6 +424,35 @@
424
424
  }
425
425
  }
426
426
 
427
+ // ARCH-906 — the DURABLE `data-agent-id` anchors on the ANCESTOR chain,
428
+ // innermost first. This is a DOM-attribute walk, not a fiber walk (no twin
429
+ // in fiber-bridge.ts to mirror): it reads the semantic anchors the render
430
+ // stamps (`row:<id>`, `data:<Entity>`, `screen:<slug>`, `job:<id>`) and
431
+ // forwards them so the host can resolve a slice DATA cell.
432
+ //
433
+ // WHY THE ANCESTOR CHAIN, and why it is not `editorInstance`. Clicking a
434
+ // table cell resolves the INNERMOST collection — the `<td key={c.key}>` map
435
+ // — so `editorInstance.fiberKey` already carries the FIELD. The ROW it
436
+ // belongs to lives one level up on `<tr data-agent-id="row:<id>">`, and the
437
+ // ENTITY on a container above that (`data-agent-id="data:<Entity>"`).
438
+ // Neither can be the innermost collection key, so the host cannot recover
439
+ // them from `editorInstance` — it needs the ancestor anchors verbatim.
440
+ // Strict ancestors only (the selected node's own anchor is already in
441
+ // `attributes`); the host picks the nearest `row:`/`data:` by namespace.
442
+ var MAX_ANCHOR_CHAIN = 24
443
+ function collectAncestorAnchors(el) {
444
+ var anchors = []
445
+ var node = el && el.parentElement ? el.parentElement : null
446
+ for (var depth = 0; node && depth < MAX_ANCHOR_CHAIN; depth++) {
447
+ if (node.nodeType === 1 && typeof node.getAttribute === "function") {
448
+ var id = node.getAttribute("data-agent-id")
449
+ if (typeof id === "string" && id !== "") anchors.push(id)
450
+ }
451
+ node = node.parentElement
452
+ }
453
+ return anchors
454
+ }
455
+
427
456
  if (window._inspectorSharedTargetObserver) {
428
457
  try {
429
458
  window._inspectorSharedTargetObserver.disconnect()
@@ -1655,6 +1684,30 @@
1655
1684
  // misread by the host as a stale mode (see runtimeBridgeHandler).
1656
1685
  var hostCommandedEditorMode = "off"
1657
1686
 
1687
+ // ARCH-886 — per-page runtime feature-detection for the unified
1688
+ // inspect+arrange coexistence. This inspector build is served fresh
1689
+ // from the CDN (same URL, overwritten in place — see
1690
+ // docs/deploy-order.md) to EVERY published prototype, old and new
1691
+ // alike, so it cannot assume the PAGE it is currently inspecting was
1692
+ // built with a @archie/devtools new enough to understand
1693
+ // `set-design-mode`'s unified role. The page's own DndProvider
1694
+ // registers `window.__ARCHIE_DESIGN_MODE__` synchronously on mount —
1695
+ // well before a user can trigger SET_EDITOR_MODE from the host — so
1696
+ // its presence at message-handling time is an accurate, live,
1697
+ // per-page signal (no version number or capability handshake needed).
1698
+ // Pages built before this bridge existed (pre-PR#12, e.g. the 0.0.21
1699
+ // release) already handle the legacy `set-design-mode` command (that
1700
+ // handler predates the bridge and is unchanged by it) — so
1701
+ // unconditionally dispatching it there does not no-op, it ARMS that
1702
+ // page's design-mode/arrange overlay with no selection routing,
1703
+ // producing a second, uncoordinated hit-area layer on top of the
1704
+ // inspector's own hover/selection UI. Gating on the bridge avoids
1705
+ // that: an old page just gets clean inspect-only behavior, same as
1706
+ // before unification shipped.
1707
+ function pageSupportsUnifiedDesignMode() {
1708
+ return typeof window.__ARCHIE_DESIGN_MODE__ !== "undefined"
1709
+ }
1710
+
1658
1711
  function setEditorModeFromHost(mode, options) {
1659
1712
  var historyMode =
1660
1713
  options && options.hostControlledHistory ? "host" : "local"
@@ -1675,11 +1728,14 @@
1675
1728
  hostCommandedEditorMode = mode === "inspect" || mode === "design" ? mode : "off"
1676
1729
 
1677
1730
  if (mode === "inspect") {
1678
- // Unified mode: visual editor (inspect) + arrange (design) coexist.
1679
- // The arrange overlay stays passive until the inspector publishes a
1731
+ // Unified mode: visual editor (inspect) + arrange (design) coexist
1732
+ // — gated on pageSupportsUnifiedDesignMode() (ARCH-886). The
1733
+ // arrange overlay stays passive until the inspector publishes a
1680
1734
  // single-element selection (via publishSelectionToDesignMode), at
1681
1735
  // which point it lights up the resize/drag controls on that element.
1682
- dispatchHostCommand({ type: "set-design-mode", enabled: true })
1736
+ if (pageSupportsUnifiedDesignMode()) {
1737
+ dispatchHostCommand({ type: "set-design-mode", enabled: true })
1738
+ }
1683
1739
  if (isInspecting) {
1684
1740
  // Recovery re-send (focus/visibility/online): the session is
1685
1741
  // already live. Activating again would wipe the user's current
@@ -2240,6 +2296,13 @@
2240
2296
  editorMeta ? editorMeta.element : element
2241
2297
  ),
2242
2298
  editorInstance: resolveInstanceIdentity(element),
2299
+ // ARCH-906 — the ancestor `data-agent-id` chain (innermost first). A
2300
+ // slice DATA cell needs the ROW id (`row:<id>` on the `<tr>`) and the
2301
+ // ENTITY (`data:<Entity>` above it), neither of which is the innermost
2302
+ // collection key `editorInstance` carries. Plain string data, so an
2303
+ // already-published copy of this script forwards it unchanged through
2304
+ // structured clone; a host that does not read it is unaffected.
2305
+ ancestorAnchors: collectAncestorAnchors(element),
2243
2306
  computedStyles: {
2244
2307
  display: computed.display,
2245
2308
  position: computed.position,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@archie/devtools",
3
- "version": "0.0.24",
3
+ "version": "0.0.26",
4
4
  "description": "DevTools for Archie generated applications - Route synchronization and editor communication",
5
5
  "repository": {
6
6
  "type": "git",