@archie/devtools 0.0.45 → 0.0.47

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.
@@ -5222,9 +5222,12 @@ function ensureUniqueNodeId(base, used) {
5222
5222
  return `${base}::${idx}`;
5223
5223
  }
5224
5224
  var INSERT_NODE_ID_PREFIX = "insert:";
5225
+ var INSERT_CHILD_NODE_ID_PREFIX = "insert-child:";
5225
5226
  function resolveStableNodeId(el, used) {
5226
5227
  const persisted = el.getAttribute(DND_NODE_ID_ATTR);
5227
- if (persisted && persisted.startsWith(INSERT_NODE_ID_PREFIX)) return persisted;
5228
+ if (persisted && (persisted.startsWith(INSERT_NODE_ID_PREFIX) || persisted.startsWith(INSERT_CHILD_NODE_ID_PREFIX))) {
5229
+ return persisted;
5230
+ }
5228
5231
  if (persisted && !used.has(persisted)) return persisted;
5229
5232
  const projected = projectUsageMeta(el);
5230
5233
  if (projected) return ensureUniqueNodeId(projected.nodeId, used);
@@ -5541,6 +5544,25 @@ function useElementScanner(enabled) {
5541
5544
  // src/client/dnd/design-mode/ElementHighlight.tsx
5542
5545
  var import_react7 = require("react");
5543
5546
  var import_jsx_runtime2 = require("react/jsx-runtime");
5547
+ function computeLaneKinshipContainerIds({
5548
+ candidateContainerIds,
5549
+ activeContainerId,
5550
+ draggingNodeId,
5551
+ getParentContainerId,
5552
+ getContainerChildren: getContainerChildren2
5553
+ }) {
5554
+ const anchorId = activeContainerId ?? getParentContainerId(draggingNodeId);
5555
+ if (!anchorId) return /* @__PURE__ */ new Set();
5556
+ const parentId = getParentContainerId(anchorId);
5557
+ const kin = /* @__PURE__ */ new Set();
5558
+ if (!parentId) return kin;
5559
+ if (candidateContainerIds.has(parentId)) kin.add(parentId);
5560
+ for (const siblingId of getContainerChildren2(parentId)) {
5561
+ if (siblingId === anchorId) continue;
5562
+ if (candidateContainerIds.has(siblingId)) kin.add(siblingId);
5563
+ }
5564
+ return kin;
5565
+ }
5544
5566
  var HANDLES = ["nw", "n", "ne", "e", "se", "s", "sw", "w"];
5545
5567
  var HANDLE_HIT_SIZE = 24;
5546
5568
  var HANDLE_KNOB_SIZE = 8;
@@ -6128,6 +6150,15 @@ var NON_DRAGGABLE_DESCENDANT_TAGS = /* @__PURE__ */ new Set([
6128
6150
  "source",
6129
6151
  "track"
6130
6152
  ]);
6153
+ var ARCHIE_INSERTED_ATTR = "data-archie-inserted";
6154
+ var INSERT_CHILD_NODE_ID_PREFIX2 = "insert-child:";
6155
+ function sealDescendantNodeId(node) {
6156
+ if (node.hasAttribute("data-dnd-node-id")) return;
6157
+ const marker = node.getAttribute(ARCHIE_INSERTED_ATTR);
6158
+ if (!marker) return;
6159
+ if (marker.includes('"') || marker.includes("'")) return;
6160
+ node.setAttribute("data-dnd-node-id", `${INSERT_CHILD_NODE_ID_PREFIX2}${marker}`);
6161
+ }
6131
6162
  function markInsertedDescendants(root) {
6132
6163
  const descendants = root.querySelectorAll("*");
6133
6164
  for (const node of descendants) {
@@ -6135,6 +6166,7 @@ function markInsertedDescendants(root) {
6135
6166
  if (NON_DRAGGABLE_DESCENDANT_TAGS.has(tag)) continue;
6136
6167
  node.setAttribute("data-dnd-force-allow", "");
6137
6168
  node.setAttribute("data-dnd-moved", "");
6169
+ sealDescendantNodeId(node);
6138
6170
  }
6139
6171
  }
6140
6172
 
@@ -8926,7 +8958,7 @@ function commitExternalDrop(x, y, engine, component, refs, resolveNodeElement, s
8926
8958
  const candidate = postInsertChildren[i];
8927
8959
  const candidateNodeId = candidate.getAttribute(DND_NODE_ID_ATTR);
8928
8960
  if (!candidateNodeId) continue;
8929
- const isEarlierInsert = candidateNodeId.startsWith("insert:");
8961
+ const isEarlierInsert = candidateNodeId.startsWith("insert:") || candidateNodeId.startsWith("insert-child:");
8930
8962
  if (!isEarlierInsert && !getInspectorRefFromElement(candidate)) continue;
8931
8963
  beforeSiblingEl = candidate;
8932
8964
  beforeSiblingNodeId = candidateNodeId;
@@ -9337,21 +9369,33 @@ function DesignModeOverlay() {
9337
9369
  [activeDrag]
9338
9370
  // eslint-disable-line react-hooks/exhaustive-deps -- refs are stable
9339
9371
  );
9372
+ const laneKinshipContainerIds = (0, import_react16.useMemo)(() => {
9373
+ if (!activeDrag || !dropCandidateContainerIds) return null;
9374
+ const engine = refs.engineRef.current;
9375
+ if (!engine) return null;
9376
+ return computeLaneKinshipContainerIds({
9377
+ candidateContainerIds: dropCandidateContainerIds,
9378
+ activeContainerId: activeLaneContainerId,
9379
+ draggingNodeId: activeDrag.nodeId,
9380
+ getParentContainerId: (id) => engine.getNodeParentContainerId(id),
9381
+ getContainerChildren: (id) => engine.getContainerChildren(id)
9382
+ });
9383
+ }, [activeDrag, activeLaneContainerId, dropCandidateContainerIds]);
9340
9384
  const visibleCandidateContainerIds = (0, import_react16.useMemo)(() => {
9341
- if (!dropCandidateContainerIds) return null;
9385
+ if (!laneKinshipContainerIds) return null;
9342
9386
  const rects = refs.snapshotRef.current?.rects;
9343
- if (!rects) return dropCandidateContainerIds;
9387
+ if (!rects) return laneKinshipContainerIds;
9344
9388
  const vw = window.innerWidth;
9345
9389
  const vh = window.innerHeight;
9346
9390
  const visible = /* @__PURE__ */ new Set();
9347
- for (const id of dropCandidateContainerIds) {
9391
+ for (const id of laneKinshipContainerIds) {
9348
9392
  const r = rects.get(id);
9349
9393
  if (!r) continue;
9350
9394
  if (r.right < 0 || r.bottom < 0 || r.left > vw || r.top > vh) continue;
9351
9395
  visible.add(id);
9352
9396
  }
9353
9397
  return visible;
9354
- }, [dropCandidateContainerIds]);
9398
+ }, [laneKinshipContainerIds]);
9355
9399
  const dragGuide = (0, import_react16.useMemo)(() => {
9356
9400
  if (!activeDrag) return null;
9357
9401
  const snapshot = refs.snapshotRef.current;
@@ -9573,6 +9617,7 @@ var combinedCollisionDetection = (args) => {
9573
9617
  // src/client/dnd/DndProvider.tsx
9574
9618
  var import_jsx_runtime5 = require("react/jsx-runtime");
9575
9619
  var externalDragMouse = { x: 0, y: 0, commitRequested: false };
9620
+ var EMPTY_SENSORS = [];
9576
9621
  function DndProvider({ children }) {
9577
9622
  const setActive = useDndStore((s) => s.setActive);
9578
9623
  const dragEndHandlers = useDndStore((s) => s.dragEndHandlers);
@@ -9714,30 +9759,17 @@ function DndProvider({ children }) {
9714
9759
  designModeState.resetArrangeSession();
9715
9760
  designModeState.setEnabled(false);
9716
9761
  }, []);
9717
- if (designModeEnabled) {
9718
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
9719
- children,
9720
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
9721
- DesignModeErrorBoundary,
9722
- {
9723
- onError: handleDesignModeCrash,
9724
- resetKey: designModeEnabled,
9725
- children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DesignModeOverlay, {})
9726
- }
9727
- )
9728
- ] });
9729
- }
9730
9762
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
9731
9763
  DndContext,
9732
9764
  {
9733
- sensors,
9765
+ sensors: designModeEnabled ? EMPTY_SENSORS : sensors,
9734
9766
  collisionDetection: combinedCollisionDetection,
9735
9767
  onDragStart: handleDragStart,
9736
9768
  onDragEnd: handleDragEnd,
9737
9769
  onDragCancel: () => setActive(null),
9738
9770
  children: [
9739
9771
  children,
9740
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DragOverlay2, {}),
9772
+ !designModeEnabled && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DragOverlay2, {}),
9741
9773
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
9742
9774
  DesignModeErrorBoundary,
9743
9775
  {
@@ -5187,9 +5187,12 @@ function ensureUniqueNodeId(base, used) {
5187
5187
  return `${base}::${idx}`;
5188
5188
  }
5189
5189
  var INSERT_NODE_ID_PREFIX = "insert:";
5190
+ var INSERT_CHILD_NODE_ID_PREFIX = "insert-child:";
5190
5191
  function resolveStableNodeId(el, used) {
5191
5192
  const persisted = el.getAttribute(DND_NODE_ID_ATTR);
5192
- if (persisted && persisted.startsWith(INSERT_NODE_ID_PREFIX)) return persisted;
5193
+ if (persisted && (persisted.startsWith(INSERT_NODE_ID_PREFIX) || persisted.startsWith(INSERT_CHILD_NODE_ID_PREFIX))) {
5194
+ return persisted;
5195
+ }
5193
5196
  if (persisted && !used.has(persisted)) return persisted;
5194
5197
  const projected = projectUsageMeta(el);
5195
5198
  if (projected) return ensureUniqueNodeId(projected.nodeId, used);
@@ -5506,6 +5509,25 @@ function useElementScanner(enabled) {
5506
5509
  // src/client/dnd/design-mode/ElementHighlight.tsx
5507
5510
  import { useRef as useRef5, useEffect as useEffect5, useCallback as useCallback5 } from "react";
5508
5511
  import { jsx as jsx2, jsxs } from "react/jsx-runtime";
5512
+ function computeLaneKinshipContainerIds({
5513
+ candidateContainerIds,
5514
+ activeContainerId,
5515
+ draggingNodeId,
5516
+ getParentContainerId,
5517
+ getContainerChildren: getContainerChildren2
5518
+ }) {
5519
+ const anchorId = activeContainerId ?? getParentContainerId(draggingNodeId);
5520
+ if (!anchorId) return /* @__PURE__ */ new Set();
5521
+ const parentId = getParentContainerId(anchorId);
5522
+ const kin = /* @__PURE__ */ new Set();
5523
+ if (!parentId) return kin;
5524
+ if (candidateContainerIds.has(parentId)) kin.add(parentId);
5525
+ for (const siblingId of getContainerChildren2(parentId)) {
5526
+ if (siblingId === anchorId) continue;
5527
+ if (candidateContainerIds.has(siblingId)) kin.add(siblingId);
5528
+ }
5529
+ return kin;
5530
+ }
5509
5531
  var HANDLES = ["nw", "n", "ne", "e", "se", "s", "sw", "w"];
5510
5532
  var HANDLE_HIT_SIZE = 24;
5511
5533
  var HANDLE_KNOB_SIZE = 8;
@@ -6093,6 +6115,15 @@ var NON_DRAGGABLE_DESCENDANT_TAGS = /* @__PURE__ */ new Set([
6093
6115
  "source",
6094
6116
  "track"
6095
6117
  ]);
6118
+ var ARCHIE_INSERTED_ATTR = "data-archie-inserted";
6119
+ var INSERT_CHILD_NODE_ID_PREFIX2 = "insert-child:";
6120
+ function sealDescendantNodeId(node) {
6121
+ if (node.hasAttribute("data-dnd-node-id")) return;
6122
+ const marker = node.getAttribute(ARCHIE_INSERTED_ATTR);
6123
+ if (!marker) return;
6124
+ if (marker.includes('"') || marker.includes("'")) return;
6125
+ node.setAttribute("data-dnd-node-id", `${INSERT_CHILD_NODE_ID_PREFIX2}${marker}`);
6126
+ }
6096
6127
  function markInsertedDescendants(root) {
6097
6128
  const descendants = root.querySelectorAll("*");
6098
6129
  for (const node of descendants) {
@@ -6100,6 +6131,7 @@ function markInsertedDescendants(root) {
6100
6131
  if (NON_DRAGGABLE_DESCENDANT_TAGS.has(tag)) continue;
6101
6132
  node.setAttribute("data-dnd-force-allow", "");
6102
6133
  node.setAttribute("data-dnd-moved", "");
6134
+ sealDescendantNodeId(node);
6103
6135
  }
6104
6136
  }
6105
6137
 
@@ -8891,7 +8923,7 @@ function commitExternalDrop(x, y, engine, component, refs, resolveNodeElement, s
8891
8923
  const candidate = postInsertChildren[i];
8892
8924
  const candidateNodeId = candidate.getAttribute(DND_NODE_ID_ATTR);
8893
8925
  if (!candidateNodeId) continue;
8894
- const isEarlierInsert = candidateNodeId.startsWith("insert:");
8926
+ const isEarlierInsert = candidateNodeId.startsWith("insert:") || candidateNodeId.startsWith("insert-child:");
8895
8927
  if (!isEarlierInsert && !getInspectorRefFromElement(candidate)) continue;
8896
8928
  beforeSiblingEl = candidate;
8897
8929
  beforeSiblingNodeId = candidateNodeId;
@@ -9302,21 +9334,33 @@ function DesignModeOverlay() {
9302
9334
  [activeDrag]
9303
9335
  // eslint-disable-line react-hooks/exhaustive-deps -- refs are stable
9304
9336
  );
9337
+ const laneKinshipContainerIds = useMemo6(() => {
9338
+ if (!activeDrag || !dropCandidateContainerIds) return null;
9339
+ const engine = refs.engineRef.current;
9340
+ if (!engine) return null;
9341
+ return computeLaneKinshipContainerIds({
9342
+ candidateContainerIds: dropCandidateContainerIds,
9343
+ activeContainerId: activeLaneContainerId,
9344
+ draggingNodeId: activeDrag.nodeId,
9345
+ getParentContainerId: (id) => engine.getNodeParentContainerId(id),
9346
+ getContainerChildren: (id) => engine.getContainerChildren(id)
9347
+ });
9348
+ }, [activeDrag, activeLaneContainerId, dropCandidateContainerIds]);
9305
9349
  const visibleCandidateContainerIds = useMemo6(() => {
9306
- if (!dropCandidateContainerIds) return null;
9350
+ if (!laneKinshipContainerIds) return null;
9307
9351
  const rects = refs.snapshotRef.current?.rects;
9308
- if (!rects) return dropCandidateContainerIds;
9352
+ if (!rects) return laneKinshipContainerIds;
9309
9353
  const vw = window.innerWidth;
9310
9354
  const vh = window.innerHeight;
9311
9355
  const visible = /* @__PURE__ */ new Set();
9312
- for (const id of dropCandidateContainerIds) {
9356
+ for (const id of laneKinshipContainerIds) {
9313
9357
  const r = rects.get(id);
9314
9358
  if (!r) continue;
9315
9359
  if (r.right < 0 || r.bottom < 0 || r.left > vw || r.top > vh) continue;
9316
9360
  visible.add(id);
9317
9361
  }
9318
9362
  return visible;
9319
- }, [dropCandidateContainerIds]);
9363
+ }, [laneKinshipContainerIds]);
9320
9364
  const dragGuide = useMemo6(() => {
9321
9365
  if (!activeDrag) return null;
9322
9366
  const snapshot = refs.snapshotRef.current;
@@ -9536,8 +9580,9 @@ var combinedCollisionDetection = (args) => {
9536
9580
  };
9537
9581
 
9538
9582
  // src/client/dnd/DndProvider.tsx
9539
- import { Fragment, jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
9583
+ import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
9540
9584
  var externalDragMouse = { x: 0, y: 0, commitRequested: false };
9585
+ var EMPTY_SENSORS = [];
9541
9586
  function DndProvider({ children }) {
9542
9587
  const setActive = useDndStore((s) => s.setActive);
9543
9588
  const dragEndHandlers = useDndStore((s) => s.dragEndHandlers);
@@ -9679,30 +9724,17 @@ function DndProvider({ children }) {
9679
9724
  designModeState.resetArrangeSession();
9680
9725
  designModeState.setEnabled(false);
9681
9726
  }, []);
9682
- if (designModeEnabled) {
9683
- return /* @__PURE__ */ jsxs4(Fragment, { children: [
9684
- children,
9685
- /* @__PURE__ */ jsx5(
9686
- DesignModeErrorBoundary,
9687
- {
9688
- onError: handleDesignModeCrash,
9689
- resetKey: designModeEnabled,
9690
- children: /* @__PURE__ */ jsx5(DesignModeOverlay, {})
9691
- }
9692
- )
9693
- ] });
9694
- }
9695
9727
  return /* @__PURE__ */ jsxs4(
9696
9728
  DndContext,
9697
9729
  {
9698
- sensors,
9730
+ sensors: designModeEnabled ? EMPTY_SENSORS : sensors,
9699
9731
  collisionDetection: combinedCollisionDetection,
9700
9732
  onDragStart: handleDragStart,
9701
9733
  onDragEnd: handleDragEnd,
9702
9734
  onDragCancel: () => setActive(null),
9703
9735
  children: [
9704
9736
  children,
9705
- /* @__PURE__ */ jsx5(DragOverlay2, {}),
9737
+ !designModeEnabled && /* @__PURE__ */ jsx5(DragOverlay2, {}),
9706
9738
  /* @__PURE__ */ jsx5(
9707
9739
  DesignModeErrorBoundary,
9708
9740
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@archie/devtools",
3
- "version": "0.0.45",
3
+ "version": "0.0.47",
4
4
  "description": "DevTools for Archie generated applications - Route synchronization and editor communication",
5
5
  "repository": {
6
6
  "type": "git",