@archie/devtools 0.0.21 → 0.0.23
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 +6 -0
- package/dist/client/client.d.mts +3 -1
- package/dist/client/client.d.ts +3 -1
- package/dist/client/client.js +289 -142
- package/dist/client/client.mjs +252 -104
- package/dist/index.d.mts +182 -1
- package/dist/index.d.ts +182 -1
- package/dist/index.js +343 -47
- package/dist/index.mjs +343 -47
- package/dist/inspector.standalone.js +145 -6
- package/package.json +2 -3
package/dist/client/client.js
CHANGED
|
@@ -38,7 +38,7 @@ __export(client_exports, {
|
|
|
38
38
|
module.exports = __toCommonJS(client_exports);
|
|
39
39
|
|
|
40
40
|
// src/client/dnd/DndProvider.tsx
|
|
41
|
-
var
|
|
41
|
+
var import_react18 = require("react");
|
|
42
42
|
|
|
43
43
|
// node_modules/@dnd-kit/core/dist/core.esm.js
|
|
44
44
|
var import_react3 = __toESM(require("react"));
|
|
@@ -4147,6 +4147,12 @@ var FIBER_KEY_PREFIX = "__reactFiber$";
|
|
|
4147
4147
|
var PROPS_KEY_PREFIX = "__reactProps$";
|
|
4148
4148
|
var metaCache = /* @__PURE__ */ new WeakMap();
|
|
4149
4149
|
var directMetaCache = /* @__PURE__ */ new WeakMap();
|
|
4150
|
+
function readEditorMetaValue(value) {
|
|
4151
|
+
if (typeof value === "function") {
|
|
4152
|
+
return value();
|
|
4153
|
+
}
|
|
4154
|
+
return value ?? null;
|
|
4155
|
+
}
|
|
4150
4156
|
function hasEditorMetaInFiberChain(fiber) {
|
|
4151
4157
|
let current = fiber;
|
|
4152
4158
|
while (current) {
|
|
@@ -4262,8 +4268,8 @@ function getDirectEditorMeta(el) {
|
|
|
4262
4268
|
const selection = getFiberSelectionFromElement(el);
|
|
4263
4269
|
const cached = readFiberAwareCache(directMetaCache, el, selection);
|
|
4264
4270
|
if (cached !== void 0) return cached;
|
|
4265
|
-
const meta = selection.fiber?.memoizedProps?.__editorMeta;
|
|
4266
|
-
return writeFiberAwareCache(directMetaCache, el, selection, meta
|
|
4271
|
+
const meta = readEditorMetaValue(selection.fiber?.memoizedProps?.__editorMeta);
|
|
4272
|
+
return writeFiberAwareCache(directMetaCache, el, selection, meta);
|
|
4267
4273
|
}
|
|
4268
4274
|
function getEditorMeta(el) {
|
|
4269
4275
|
const selection = getFiberSelectionFromElement(el);
|
|
@@ -4271,7 +4277,7 @@ function getEditorMeta(el) {
|
|
|
4271
4277
|
if (cached !== void 0) return cached;
|
|
4272
4278
|
let fiber = selection.fiber;
|
|
4273
4279
|
while (fiber) {
|
|
4274
|
-
const meta = fiber.memoizedProps?.__editorMeta;
|
|
4280
|
+
const meta = readEditorMetaValue(fiber.memoizedProps?.__editorMeta);
|
|
4275
4281
|
if (meta) {
|
|
4276
4282
|
return writeFiberAwareCache(metaCache, el, selection, meta);
|
|
4277
4283
|
}
|
|
@@ -4315,6 +4321,9 @@ function findMetaOwnerElement(el) {
|
|
|
4315
4321
|
}
|
|
4316
4322
|
function resolveHostElementFromFiberChain(el) {
|
|
4317
4323
|
if (shouldIgnoreAsVirtualRuntime(el)) return null;
|
|
4324
|
+
if (el.hasAttribute("data-dnd-force-allow")) {
|
|
4325
|
+
return el;
|
|
4326
|
+
}
|
|
4318
4327
|
const directMeta = getDirectEditorMeta(el);
|
|
4319
4328
|
const ownerMeta = directMeta ?? getEditorMeta(el);
|
|
4320
4329
|
if (isPassthroughMeta(ownerMeta)) {
|
|
@@ -4670,8 +4679,8 @@ function buildEmptyArrangeSessionState() {
|
|
|
4670
4679
|
var useDesignModeStore = create((set, get) => ({
|
|
4671
4680
|
// UI state
|
|
4672
4681
|
enabled: false,
|
|
4673
|
-
hoveredSelector: null,
|
|
4674
4682
|
selectedSelector: null,
|
|
4683
|
+
inspectorSelectedNodeIds: [],
|
|
4675
4684
|
historyMode: "local",
|
|
4676
4685
|
inspectorTheme: DEFAULT_INSPECTOR_THEME,
|
|
4677
4686
|
canUndo: false,
|
|
@@ -4687,16 +4696,23 @@ var useDesignModeStore = create((set, get) => ({
|
|
|
4687
4696
|
// UI actions
|
|
4688
4697
|
toggle: () => set((s) => ({ enabled: !s.enabled, ...buildEmptyArrangeSessionState() })),
|
|
4689
4698
|
setEnabled: (enabled) => set({ enabled }),
|
|
4690
|
-
setHovered: (selector) => set({ hoveredSelector: selector }),
|
|
4691
4699
|
setSelected: (selector) => set({ selectedSelector: selector }),
|
|
4700
|
+
setInspectorSelection: (nodeIds) => {
|
|
4701
|
+
const next = nodeIds.filter((id) => typeof id === "string" && id.length > 0);
|
|
4702
|
+
const prev = get().inspectorSelectedNodeIds;
|
|
4703
|
+
if (prev.length === next.length && prev.every((id, i) => id === next[i])) {
|
|
4704
|
+
return;
|
|
4705
|
+
}
|
|
4706
|
+
set({ inspectorSelectedNodeIds: next });
|
|
4707
|
+
},
|
|
4692
4708
|
setHistoryMode: (historyMode) => set({ historyMode }),
|
|
4693
4709
|
setInspectorTheme: (theme) => set((s) => ({ inspectorTheme: mergeInspectorTheme({ ...s.inspectorTheme, ...theme }) })),
|
|
4694
4710
|
setHistoryAvailability: (canUndo, canRedo) => set({ canUndo, canRedo }),
|
|
4695
4711
|
requestUndo: () => set((s) => ({ undoRequestId: s.undoRequestId + 1 })),
|
|
4696
4712
|
requestRedo: () => set((s) => ({ redoRequestId: s.redoRequestId + 1 })),
|
|
4697
4713
|
resetAll: () => set({
|
|
4698
|
-
hoveredSelector: null,
|
|
4699
4714
|
selectedSelector: null,
|
|
4715
|
+
inspectorSelectedNodeIds: [],
|
|
4700
4716
|
canUndo: false,
|
|
4701
4717
|
canRedo: false
|
|
4702
4718
|
}),
|
|
@@ -4814,9 +4830,13 @@ var useDesignModeStore = create((set, get) => ({
|
|
|
4814
4830
|
inspectorRef,
|
|
4815
4831
|
displayName,
|
|
4816
4832
|
html,
|
|
4833
|
+
tsxCode,
|
|
4834
|
+
tsxImports,
|
|
4817
4835
|
containerId,
|
|
4818
4836
|
containerNodeKey,
|
|
4819
|
-
index
|
|
4837
|
+
index,
|
|
4838
|
+
beforeSiblingInspectorRef,
|
|
4839
|
+
beforeSiblingNodeKey
|
|
4820
4840
|
}) => {
|
|
4821
4841
|
const now = Date.now();
|
|
4822
4842
|
const normalizedOperationId = operationId ?? buildFallbackOperationId(now, nodeId);
|
|
@@ -4828,9 +4848,13 @@ var useDesignModeStore = create((set, get) => ({
|
|
|
4828
4848
|
inspectorRef,
|
|
4829
4849
|
displayName,
|
|
4830
4850
|
html,
|
|
4851
|
+
tsxCode: tsxCode ?? null,
|
|
4852
|
+
tsxImports: tsxImports ?? null,
|
|
4831
4853
|
containerId,
|
|
4832
4854
|
containerNodeKey,
|
|
4833
4855
|
index,
|
|
4856
|
+
beforeSiblingInspectorRef: beforeSiblingInspectorRef ?? null,
|
|
4857
|
+
beforeSiblingNodeKey: beforeSiblingNodeKey ?? null,
|
|
4834
4858
|
at: now
|
|
4835
4859
|
};
|
|
4836
4860
|
set((s) => {
|
|
@@ -4908,7 +4932,7 @@ var useDesignModeStore = create((set, get) => ({
|
|
|
4908
4932
|
}));
|
|
4909
4933
|
|
|
4910
4934
|
// src/client/dnd/design-mode/DesignModeOverlay.tsx
|
|
4911
|
-
var
|
|
4935
|
+
var import_react16 = require("react");
|
|
4912
4936
|
|
|
4913
4937
|
// src/client/dnd/design-mode/useElementScanner.ts
|
|
4914
4938
|
var import_react6 = require("react");
|
|
@@ -5071,7 +5095,7 @@ function projectUsageMeta(el) {
|
|
|
5071
5095
|
const owner = getEditorMetaOwnerFiber(el);
|
|
5072
5096
|
if (!owner) return null;
|
|
5073
5097
|
if (getSingleHostElement(owner) !== el) return null;
|
|
5074
|
-
return owner.memoizedProps?.__editorMeta
|
|
5098
|
+
return readEditorMetaValue(owner.memoizedProps?.__editorMeta);
|
|
5075
5099
|
}
|
|
5076
5100
|
function isRuntimeVisualInternal(el) {
|
|
5077
5101
|
if (shouldIgnoreAsVirtualRuntime(el)) return true;
|
|
@@ -5437,14 +5461,14 @@ function handlePosition(dir) {
|
|
|
5437
5461
|
};
|
|
5438
5462
|
return positions[dir];
|
|
5439
5463
|
}
|
|
5440
|
-
function getOutlineStyle(rect, isSelected,
|
|
5464
|
+
function getOutlineStyle(rect, isSelected, inspectorTheme) {
|
|
5441
5465
|
return {
|
|
5442
5466
|
...OUTLINE_BASE_STYLE,
|
|
5443
5467
|
left: rect.left,
|
|
5444
5468
|
top: rect.top,
|
|
5445
5469
|
width: rect.width,
|
|
5446
5470
|
height: rect.height,
|
|
5447
|
-
border: isSelected ? `2px solid ${inspectorTheme.accent}` :
|
|
5471
|
+
border: isSelected ? `2px solid ${inspectorTheme.accent}` : `1px dashed ${inspectorTheme.shared}`,
|
|
5448
5472
|
backgroundColor: isSelected ? inspectorTheme.accentSoft : "transparent"
|
|
5449
5473
|
};
|
|
5450
5474
|
}
|
|
@@ -5474,11 +5498,13 @@ function ElementHighlight({
|
|
|
5474
5498
|
elements,
|
|
5475
5499
|
draggingNodeId,
|
|
5476
5500
|
activeEl,
|
|
5501
|
+
arrangeSelectedNodeId,
|
|
5502
|
+
externalDragActive,
|
|
5477
5503
|
onResizeHandlePointerDown
|
|
5478
5504
|
}) {
|
|
5479
|
-
const hoveredSelector = useDesignModeStore((s) => s.hoveredSelector);
|
|
5480
|
-
const selectedSelector = useDesignModeStore((s) => s.selectedSelector);
|
|
5481
5505
|
const inspectorTheme = useDesignModeStore((s) => s.inspectorTheme);
|
|
5506
|
+
const internalDragInProgress = draggingNodeId !== null;
|
|
5507
|
+
const overlayVisible = arrangeSelectedNodeId !== null || internalDragInProgress;
|
|
5482
5508
|
const containerRef = (0, import_react7.useRef)(null);
|
|
5483
5509
|
const rafRef = (0, import_react7.useRef)(0);
|
|
5484
5510
|
const syncPositions = (0, import_react7.useCallback)(() => {
|
|
@@ -5502,7 +5528,6 @@ function ElementHighlight({
|
|
|
5502
5528
|
}
|
|
5503
5529
|
}, [elements]);
|
|
5504
5530
|
(0, import_react7.useEffect)(() => {
|
|
5505
|
-
if (draggingNodeId) return;
|
|
5506
5531
|
let running = true;
|
|
5507
5532
|
const loop = () => {
|
|
5508
5533
|
if (!running) return;
|
|
@@ -5514,8 +5539,9 @@ function ElementHighlight({
|
|
|
5514
5539
|
running = false;
|
|
5515
5540
|
cancelAnimationFrame(rafRef.current);
|
|
5516
5541
|
};
|
|
5517
|
-
}, [syncPositions
|
|
5518
|
-
if (
|
|
5542
|
+
}, [syncPositions]);
|
|
5543
|
+
if (!overlayVisible) return null;
|
|
5544
|
+
if (externalDragActive) return null;
|
|
5519
5545
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
5520
5546
|
"div",
|
|
5521
5547
|
{
|
|
@@ -5525,10 +5551,10 @@ function ElementHighlight({
|
|
|
5525
5551
|
children: elements.map((el) => {
|
|
5526
5552
|
if (el.nodeId === draggingNodeId) return null;
|
|
5527
5553
|
if (activeEl && activeEl !== el.element && activeEl.contains(el.element)) return null;
|
|
5528
|
-
const
|
|
5529
|
-
|
|
5554
|
+
const isSelected = el.nodeId === arrangeSelectedNodeId;
|
|
5555
|
+
if (!isSelected && !internalDragInProgress) return null;
|
|
5530
5556
|
const rect = el.element.getBoundingClientRect();
|
|
5531
|
-
const showLabel =
|
|
5557
|
+
const showLabel = isSelected;
|
|
5532
5558
|
const labelTop = isSelected ? Math.max(0, rect.top - 20) : rect.top;
|
|
5533
5559
|
const labelLeft = isSelected ? rect.left + 12 : rect.left;
|
|
5534
5560
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
|
|
@@ -5537,7 +5563,7 @@ function ElementHighlight({
|
|
|
5537
5563
|
{
|
|
5538
5564
|
"data-outline-for": el.nodeId,
|
|
5539
5565
|
"data-design-mode-ui": true,
|
|
5540
|
-
style: getOutlineStyle(rect, isSelected,
|
|
5566
|
+
style: getOutlineStyle(rect, isSelected, inspectorTheme),
|
|
5541
5567
|
children: isSelected && HANDLES.map((dir) => {
|
|
5542
5568
|
const pos = handlePosition(dir);
|
|
5543
5569
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
@@ -5832,6 +5858,57 @@ function buildRectSlotRect(children, nodeMap, cRect, i, n, rows) {
|
|
|
5832
5858
|
};
|
|
5833
5859
|
}
|
|
5834
5860
|
|
|
5861
|
+
// src/client/dnd/design-mode/inserted-descendants.ts
|
|
5862
|
+
var NON_DRAGGABLE_DESCENDANT_TAGS = /* @__PURE__ */ new Set([
|
|
5863
|
+
// SVG internals — the whole <svg> is the unit; its parts must stay together.
|
|
5864
|
+
"svg",
|
|
5865
|
+
"path",
|
|
5866
|
+
"circle",
|
|
5867
|
+
"rect",
|
|
5868
|
+
"line",
|
|
5869
|
+
"polyline",
|
|
5870
|
+
"polygon",
|
|
5871
|
+
"g",
|
|
5872
|
+
"defs",
|
|
5873
|
+
"use",
|
|
5874
|
+
// <select>/<option>: options live inside their <select>, never standalone.
|
|
5875
|
+
"option",
|
|
5876
|
+
"optgroup",
|
|
5877
|
+
// Table internals: only meaningful in their <table> tree.
|
|
5878
|
+
"caption",
|
|
5879
|
+
"thead",
|
|
5880
|
+
"tbody",
|
|
5881
|
+
"tfoot",
|
|
5882
|
+
"tr",
|
|
5883
|
+
"th",
|
|
5884
|
+
"td",
|
|
5885
|
+
"col",
|
|
5886
|
+
"colgroup",
|
|
5887
|
+
// Self-closing inline atoms with no draggable surface.
|
|
5888
|
+
"br",
|
|
5889
|
+
"wbr",
|
|
5890
|
+
"hr",
|
|
5891
|
+
// Non-rendered metadata.
|
|
5892
|
+
"script",
|
|
5893
|
+
"style",
|
|
5894
|
+
"meta",
|
|
5895
|
+
"link",
|
|
5896
|
+
"title",
|
|
5897
|
+
"noscript",
|
|
5898
|
+
// Replaced media controls handled by their parent player.
|
|
5899
|
+
"source",
|
|
5900
|
+
"track"
|
|
5901
|
+
]);
|
|
5902
|
+
function markInsertedDescendants(root) {
|
|
5903
|
+
const descendants = root.querySelectorAll("*");
|
|
5904
|
+
for (const node of descendants) {
|
|
5905
|
+
const tag = node.tagName.toLowerCase();
|
|
5906
|
+
if (NON_DRAGGABLE_DESCENDANT_TAGS.has(tag)) continue;
|
|
5907
|
+
node.setAttribute("data-dnd-force-allow", "");
|
|
5908
|
+
node.setAttribute("data-dnd-moved", "");
|
|
5909
|
+
}
|
|
5910
|
+
}
|
|
5911
|
+
|
|
5835
5912
|
// src/client/dnd/design-mode/history.ts
|
|
5836
5913
|
function applyInsertCommand(command, direction, resolveNodeElement) {
|
|
5837
5914
|
if (direction === "undo") {
|
|
@@ -5854,6 +5931,7 @@ function applyInsertCommand(command, direction, resolveNodeElement) {
|
|
|
5854
5931
|
(c) => c instanceof HTMLElement
|
|
5855
5932
|
);
|
|
5856
5933
|
container.insertBefore(newEl, kids[command.index] ?? null);
|
|
5934
|
+
markInsertedDescendants(newEl);
|
|
5857
5935
|
return true;
|
|
5858
5936
|
}
|
|
5859
5937
|
var DEFAULT_LIMIT = 300;
|
|
@@ -6379,6 +6457,8 @@ function serializeArrangeChange(event, index) {
|
|
|
6379
6457
|
containerId: event.kind === "insert" ? event.containerId : void 0,
|
|
6380
6458
|
containerNodeKey: event.kind === "insert" ? event.containerNodeKey : void 0,
|
|
6381
6459
|
insertIndex: event.kind === "insert" ? event.index : void 0,
|
|
6460
|
+
beforeSiblingInspectorRef: event.kind === "insert" ? event.beforeSiblingInspectorRef : void 0,
|
|
6461
|
+
beforeSiblingNodeKey: event.kind === "insert" ? event.beforeSiblingNodeKey : void 0,
|
|
6382
6462
|
summary: summarizeEditorChangeEvent(event),
|
|
6383
6463
|
at: event.at
|
|
6384
6464
|
};
|
|
@@ -6676,50 +6756,8 @@ function useOverlayRefs(undoRequestId, redoRequestId) {
|
|
|
6676
6756
|
}), []);
|
|
6677
6757
|
}
|
|
6678
6758
|
|
|
6679
|
-
// src/client/dnd/design-mode/useHoverDetection.ts
|
|
6680
|
-
var import_react12 = require("react");
|
|
6681
|
-
function useHoverDetection({
|
|
6682
|
-
enabled,
|
|
6683
|
-
activeDrag,
|
|
6684
|
-
elementsRef,
|
|
6685
|
-
setHovered
|
|
6686
|
-
}) {
|
|
6687
|
-
(0, import_react12.useEffect)(() => {
|
|
6688
|
-
if (!enabled) {
|
|
6689
|
-
setHovered(null);
|
|
6690
|
-
return;
|
|
6691
|
-
}
|
|
6692
|
-
let lastNodeId = null;
|
|
6693
|
-
const fn = (e) => {
|
|
6694
|
-
if (activeDrag) return;
|
|
6695
|
-
let best = null;
|
|
6696
|
-
let bestArea = Infinity;
|
|
6697
|
-
for (const sc of elementsRef.current) {
|
|
6698
|
-
const r = sc.rect;
|
|
6699
|
-
if (e.clientX >= r.left && e.clientX <= r.right && e.clientY >= r.top && e.clientY <= r.bottom) {
|
|
6700
|
-
const a = r.width * r.height;
|
|
6701
|
-
if (a < bestArea) {
|
|
6702
|
-
bestArea = a;
|
|
6703
|
-
best = sc;
|
|
6704
|
-
}
|
|
6705
|
-
}
|
|
6706
|
-
}
|
|
6707
|
-
const nodeId = best?.nodeId ?? null;
|
|
6708
|
-
if (nodeId !== lastNodeId) {
|
|
6709
|
-
lastNodeId = nodeId;
|
|
6710
|
-
setHovered(nodeId);
|
|
6711
|
-
}
|
|
6712
|
-
};
|
|
6713
|
-
document.addEventListener("mousemove", fn);
|
|
6714
|
-
return () => {
|
|
6715
|
-
document.removeEventListener("mousemove", fn);
|
|
6716
|
-
setHovered(null);
|
|
6717
|
-
};
|
|
6718
|
-
}, [enabled, setHovered, activeDrag]);
|
|
6719
|
-
}
|
|
6720
|
-
|
|
6721
6759
|
// src/client/dnd/design-mode/useDragVisualLoop.ts
|
|
6722
|
-
var
|
|
6760
|
+
var import_react12 = require("react");
|
|
6723
6761
|
|
|
6724
6762
|
// src/client/dnd/design-mode/quadtree.ts
|
|
6725
6763
|
function overlaps(a, b) {
|
|
@@ -7608,7 +7646,7 @@ function useDragVisualLoop({
|
|
|
7608
7646
|
setInsideRect,
|
|
7609
7647
|
setDropLine
|
|
7610
7648
|
}) {
|
|
7611
|
-
(0,
|
|
7649
|
+
(0, import_react12.useEffect)(() => {
|
|
7612
7650
|
const engine = refs.engineRef.current;
|
|
7613
7651
|
const snapshot = refs.snapshotRef.current;
|
|
7614
7652
|
if (!activeDrag || !engine || !snapshot) return;
|
|
@@ -7838,7 +7876,7 @@ function useDragVisualLoop({
|
|
|
7838
7876
|
}
|
|
7839
7877
|
|
|
7840
7878
|
// src/client/dnd/design-mode/useDragLifecycle.ts
|
|
7841
|
-
var
|
|
7879
|
+
var import_react13 = require("react");
|
|
7842
7880
|
function buildRuntimeIdentityLocal(nodeId, resolveNodeElement, effectiveLaneSnapshot) {
|
|
7843
7881
|
if (!nodeId) return null;
|
|
7844
7882
|
const element = resolveNodeElement(nodeId);
|
|
@@ -8023,8 +8061,8 @@ function useDragLifecycle({
|
|
|
8023
8061
|
setInsideRect,
|
|
8024
8062
|
setDropLine
|
|
8025
8063
|
}) {
|
|
8026
|
-
const [activeDrag, setActiveDrag] = (0,
|
|
8027
|
-
const clearDragState = (0,
|
|
8064
|
+
const [activeDrag, setActiveDrag] = (0, import_react13.useState)(null);
|
|
8065
|
+
const clearDragState = (0, import_react13.useCallback)(() => {
|
|
8028
8066
|
refs.animatorRef.current.clear();
|
|
8029
8067
|
const activeEl = refs.activeElRef.current;
|
|
8030
8068
|
refs.activeElRef.current = null;
|
|
@@ -8051,7 +8089,7 @@ function useDragLifecycle({
|
|
|
8051
8089
|
setActiveDrag(null);
|
|
8052
8090
|
resume();
|
|
8053
8091
|
}, [clearCommitLaneCache, resume]);
|
|
8054
|
-
const classifyCommandType = (0,
|
|
8092
|
+
const classifyCommandType = (0, import_react13.useCallback)((from, to, isNest) => {
|
|
8055
8093
|
if (isNest) return "nest";
|
|
8056
8094
|
if (from.parentNodeId === to.parentNodeId) return "reorder";
|
|
8057
8095
|
if (from.parentNodeId) {
|
|
@@ -8061,7 +8099,7 @@ function useDragLifecycle({
|
|
|
8061
8099
|
}
|
|
8062
8100
|
return "moveCrossContainer";
|
|
8063
8101
|
}, [resolveNodeElement]);
|
|
8064
|
-
const handleDragStart = (0,
|
|
8102
|
+
const handleDragStart = (0, import_react13.useCallback)(({ active }) => {
|
|
8065
8103
|
if (refs.resizeSessionRef.current || Date.now() < refs.resizeDragBlockUntilRef.current) return;
|
|
8066
8104
|
const activeId = active.id;
|
|
8067
8105
|
const found = refs.draggableNodeMapRef.current.get(activeId) ?? refs.nodeMapRef.current.get(activeId);
|
|
@@ -8117,7 +8155,7 @@ function useDragLifecycle({
|
|
|
8117
8155
|
element: anchorScanned.element
|
|
8118
8156
|
});
|
|
8119
8157
|
}, [clearCommitLaneCache, getCommitLaneSnapshot, getCurrentCommitPlacement, pause, selectElement]);
|
|
8120
|
-
const handleDragEnd = (0,
|
|
8158
|
+
const handleDragEnd = (0, import_react13.useCallback)(({ active }) => {
|
|
8121
8159
|
const activeEl = refs.activeElRef.current;
|
|
8122
8160
|
const fallbackActiveId = active.id;
|
|
8123
8161
|
const dragSession = refs.dragSessionAnchorRef.current;
|
|
@@ -8223,14 +8261,14 @@ function useDragLifecycle({
|
|
|
8223
8261
|
clearDragState();
|
|
8224
8262
|
syncHistoryAvailability();
|
|
8225
8263
|
}, [applyCommand, classifyCommandType, clearDragState, getCurrentCommitPlacement, recordMoveChange, resolveNodeElement, selectElement, syncHistoryAvailability]);
|
|
8226
|
-
const handleDragCancel = (0,
|
|
8264
|
+
const handleDragCancel = (0, import_react13.useCallback)(() => {
|
|
8227
8265
|
clearDragState();
|
|
8228
8266
|
}, [clearDragState]);
|
|
8229
8267
|
return { activeDrag, handleDragStart, handleDragEnd, handleDragCancel };
|
|
8230
8268
|
}
|
|
8231
8269
|
|
|
8232
8270
|
// src/client/dnd/design-mode/useResizeSession.ts
|
|
8233
|
-
var
|
|
8271
|
+
var import_react14 = require("react");
|
|
8234
8272
|
var RESIZE_POINTER_TOLERANCE_PX = 2;
|
|
8235
8273
|
var RESIZE_DRAG_BLOCK_MS = 180;
|
|
8236
8274
|
var RESIZE_MIN = 24;
|
|
@@ -8241,7 +8279,7 @@ function useResizeSession({
|
|
|
8241
8279
|
recordResizeChange,
|
|
8242
8280
|
syncHistoryAvailability
|
|
8243
8281
|
}) {
|
|
8244
|
-
const handleResizeHandlePointerDown = (0,
|
|
8282
|
+
const handleResizeHandlePointerDown = (0, import_react14.useCallback)((e, nodeId, dir) => {
|
|
8245
8283
|
if (refs.resizeSessionRef.current) return;
|
|
8246
8284
|
const selectedEl = refs.nodeMapRef.current.get(nodeId)?.element ?? document.querySelector(`[data-dnd-node-id="${nodeId}"]`);
|
|
8247
8285
|
if (!selectedEl) return;
|
|
@@ -8287,7 +8325,7 @@ function useResizeSession({
|
|
|
8287
8325
|
};
|
|
8288
8326
|
pointerTarget?.setPointerCapture?.(e.pointerId);
|
|
8289
8327
|
}, []);
|
|
8290
|
-
const handleResizePointerMove = (0,
|
|
8328
|
+
const handleResizePointerMove = (0, import_react14.useCallback)((e) => {
|
|
8291
8329
|
const session = refs.resizeSessionRef.current;
|
|
8292
8330
|
if (!session || e.pointerId !== session.pointerId) return;
|
|
8293
8331
|
const dx = e.clientX - session.startX;
|
|
@@ -8333,7 +8371,7 @@ function useResizeSession({
|
|
|
8333
8371
|
element.style.width = `${Math.round(Math.min(newW, window.innerWidth))}px`;
|
|
8334
8372
|
element.style.height = `${Math.round(Math.min(newH, window.innerHeight))}px`;
|
|
8335
8373
|
}, []);
|
|
8336
|
-
const handleResizePointerUp = (0,
|
|
8374
|
+
const handleResizePointerUp = (0, import_react14.useCallback)((e) => {
|
|
8337
8375
|
const session = refs.resizeSessionRef.current;
|
|
8338
8376
|
if (!session || e.pointerId !== session.pointerId) return;
|
|
8339
8377
|
refs.resizeSessionRef.current = null;
|
|
@@ -8402,7 +8440,7 @@ function useResizeSession({
|
|
|
8402
8440
|
});
|
|
8403
8441
|
syncHistoryAvailability();
|
|
8404
8442
|
}, [applyCommand, recordResizeChange, syncHistoryAvailability]);
|
|
8405
|
-
(0,
|
|
8443
|
+
(0, import_react14.useEffect)(() => {
|
|
8406
8444
|
if (!enabled) return;
|
|
8407
8445
|
const handleResizePointerCancel = (e) => {
|
|
8408
8446
|
const session = refs.resizeSessionRef.current;
|
|
@@ -8427,8 +8465,13 @@ function useResizeSession({
|
|
|
8427
8465
|
}
|
|
8428
8466
|
|
|
8429
8467
|
// src/client/dnd/design-mode/useExternalDragLoop.ts
|
|
8430
|
-
var
|
|
8468
|
+
var import_react15 = require("react");
|
|
8431
8469
|
var EXTERNAL_DRAG_ACTIVE_ID = "__external-drag-placeholder__";
|
|
8470
|
+
var insertNodeIdCounter = 0;
|
|
8471
|
+
function nextInsertNodeId() {
|
|
8472
|
+
insertNodeIdCounter += 1;
|
|
8473
|
+
return `insert:${Date.now()}:${insertNodeIdCounter}`;
|
|
8474
|
+
}
|
|
8432
8475
|
function useExternalDragLoop({
|
|
8433
8476
|
externalDrag,
|
|
8434
8477
|
refs,
|
|
@@ -8436,9 +8479,9 @@ function useExternalDragLoop({
|
|
|
8436
8479
|
resolveNodeElement,
|
|
8437
8480
|
setDropLine
|
|
8438
8481
|
}) {
|
|
8439
|
-
const engineRef = (0,
|
|
8440
|
-
const lastIntentRef = (0,
|
|
8441
|
-
(0,
|
|
8482
|
+
const engineRef = (0, import_react15.useRef)(null);
|
|
8483
|
+
const lastIntentRef = (0, import_react15.useRef)(null);
|
|
8484
|
+
(0, import_react15.useEffect)(() => {
|
|
8442
8485
|
if (!externalDrag) {
|
|
8443
8486
|
engineRef.current = null;
|
|
8444
8487
|
lastIntentRef.current = null;
|
|
@@ -8528,7 +8571,7 @@ function commitExternalDrop(x, y, engine, component, refs, resolveNodeElement, s
|
|
|
8528
8571
|
setDropLine(null);
|
|
8529
8572
|
return;
|
|
8530
8573
|
}
|
|
8531
|
-
const nodeId =
|
|
8574
|
+
const nodeId = nextInsertNodeId();
|
|
8532
8575
|
newElement.setAttribute(DND_NODE_ID_ATTR, nodeId);
|
|
8533
8576
|
newElement.setAttribute("data-dnd-force-allow", "");
|
|
8534
8577
|
newElement.setAttribute("data-dnd-moved", "");
|
|
@@ -8537,6 +8580,23 @@ function commitExternalDrop(x, y, engine, component, refs, resolveNodeElement, s
|
|
|
8537
8580
|
);
|
|
8538
8581
|
const beforeChild = children[intent.index] ?? null;
|
|
8539
8582
|
containerEl.insertBefore(newElement, beforeChild);
|
|
8583
|
+
markInsertedDescendants(newElement);
|
|
8584
|
+
const postInsertChildren = Array.from(containerEl.children).filter(
|
|
8585
|
+
(child) => child instanceof HTMLElement
|
|
8586
|
+
);
|
|
8587
|
+
let beforeSiblingEl = null;
|
|
8588
|
+
let beforeSiblingNodeId = null;
|
|
8589
|
+
const startIdx = postInsertChildren.indexOf(newElement) + 1;
|
|
8590
|
+
for (let i = startIdx; i < postInsertChildren.length; i += 1) {
|
|
8591
|
+
const candidate = postInsertChildren[i];
|
|
8592
|
+
const candidateNodeId = candidate.getAttribute(DND_NODE_ID_ATTR);
|
|
8593
|
+
if (!candidateNodeId) continue;
|
|
8594
|
+
const isEarlierInsert = candidateNodeId.startsWith("insert:");
|
|
8595
|
+
if (!isEarlierInsert && !getInspectorRefFromElement(candidate)) continue;
|
|
8596
|
+
beforeSiblingEl = candidate;
|
|
8597
|
+
beforeSiblingNodeId = candidateNodeId;
|
|
8598
|
+
break;
|
|
8599
|
+
}
|
|
8540
8600
|
const insertCommand = {
|
|
8541
8601
|
type: "insert",
|
|
8542
8602
|
nodeId,
|
|
@@ -8562,6 +8622,15 @@ function commitExternalDrop(x, y, engine, component, refs, resolveNodeElement, s
|
|
|
8562
8622
|
inspectorRef: getInspectorRefFromElement(containerEl)
|
|
8563
8623
|
};
|
|
8564
8624
|
}
|
|
8625
|
+
let beforeSiblingIdentity = null;
|
|
8626
|
+
if (beforeSiblingEl && beforeSiblingNodeId) {
|
|
8627
|
+
beforeSiblingIdentity = {
|
|
8628
|
+
nodeId: beforeSiblingNodeId,
|
|
8629
|
+
nodeKey: getNodeKeyFromElement(beforeSiblingEl),
|
|
8630
|
+
selector: buildNodeSelector(beforeSiblingNodeId),
|
|
8631
|
+
inspectorRef: getInspectorRefFromElement(beforeSiblingEl)
|
|
8632
|
+
};
|
|
8633
|
+
}
|
|
8565
8634
|
const operationId = `${insertCommand.at}:${nodeId}`;
|
|
8566
8635
|
useDesignModeStore.getState().recordInsertChange({
|
|
8567
8636
|
operationId,
|
|
@@ -8570,9 +8639,13 @@ function commitExternalDrop(x, y, engine, component, refs, resolveNodeElement, s
|
|
|
8570
8639
|
inspectorRef,
|
|
8571
8640
|
displayName: component.displayName,
|
|
8572
8641
|
html: component.html,
|
|
8642
|
+
tsxCode: component.tsxCode ?? null,
|
|
8643
|
+
tsxImports: component.tsxImports ?? null,
|
|
8573
8644
|
containerId: intent.containerId,
|
|
8574
8645
|
containerNodeKey,
|
|
8575
|
-
index: intent.index
|
|
8646
|
+
index: intent.index,
|
|
8647
|
+
beforeSiblingInspectorRef: beforeSiblingIdentity?.inspectorRef ?? null,
|
|
8648
|
+
beforeSiblingNodeKey: beforeSiblingIdentity?.nodeKey ?? null
|
|
8576
8649
|
});
|
|
8577
8650
|
dispatchRuntimeEvent({
|
|
8578
8651
|
type: "element-inserted",
|
|
@@ -8581,8 +8654,11 @@ function commitExternalDrop(x, y, engine, component, refs, resolveNodeElement, s
|
|
|
8581
8654
|
nodeKey,
|
|
8582
8655
|
displayName: component.displayName,
|
|
8583
8656
|
html: component.html,
|
|
8657
|
+
tsxCode: component.tsxCode ?? null,
|
|
8658
|
+
tsxImports: component.tsxImports ?? null,
|
|
8584
8659
|
container: containerIdentity,
|
|
8585
|
-
index: intent.index
|
|
8660
|
+
index: intent.index,
|
|
8661
|
+
beforeSibling: beforeSiblingIdentity
|
|
8586
8662
|
});
|
|
8587
8663
|
}
|
|
8588
8664
|
setDropLine(null);
|
|
@@ -8633,12 +8709,16 @@ function HitArea({
|
|
|
8633
8709
|
selectedNodeId,
|
|
8634
8710
|
onResizeHandlePointerDown
|
|
8635
8711
|
}) {
|
|
8636
|
-
const
|
|
8637
|
-
|
|
8712
|
+
const isSelected = scanned.nodeId === selectedNodeId;
|
|
8713
|
+
const { setNodeRef, listeners, attributes, isDragging } = useDraggable({
|
|
8714
|
+
id: scanned.nodeId,
|
|
8715
|
+
disabled: !isSelected
|
|
8716
|
+
});
|
|
8717
|
+
(0, import_react16.useEffect)(() => {
|
|
8638
8718
|
setNodeRef(scanned.element);
|
|
8639
8719
|
return () => setNodeRef(null);
|
|
8640
8720
|
}, [setNodeRef, scanned.element]);
|
|
8641
|
-
(0,
|
|
8721
|
+
(0, import_react16.useLayoutEffect)(() => {
|
|
8642
8722
|
const el = scanned.element;
|
|
8643
8723
|
if (isDragging) {
|
|
8644
8724
|
el.style.opacity = "0";
|
|
@@ -8646,16 +8726,26 @@ function HitArea({
|
|
|
8646
8726
|
el.style.removeProperty("opacity");
|
|
8647
8727
|
}
|
|
8648
8728
|
}, [isDragging, scanned.element]);
|
|
8649
|
-
(0,
|
|
8729
|
+
(0, import_react16.useEffect)(() => () => {
|
|
8650
8730
|
scanned.element.style.removeProperty("opacity");
|
|
8651
8731
|
scanned.element.style.removeProperty("transform");
|
|
8652
8732
|
scanned.element.style.removeProperty("transition");
|
|
8653
8733
|
scanned.element.style.removeProperty("will-change");
|
|
8654
8734
|
}, [scanned.element]);
|
|
8655
|
-
const divRef = (0,
|
|
8656
|
-
const [hoverResizeHandle, setHoverResizeHandle] = (0,
|
|
8657
|
-
const
|
|
8658
|
-
(0,
|
|
8735
|
+
const divRef = (0, import_react16.useRef)(null);
|
|
8736
|
+
const [hoverResizeHandle, setHoverResizeHandle] = (0, import_react16.useState)(null);
|
|
8737
|
+
const justDraggedRef = (0, import_react16.useRef)(false);
|
|
8738
|
+
(0, import_react16.useEffect)(() => {
|
|
8739
|
+
if (isDragging) {
|
|
8740
|
+
justDraggedRef.current = true;
|
|
8741
|
+
return;
|
|
8742
|
+
}
|
|
8743
|
+
const id = window.setTimeout(() => {
|
|
8744
|
+
justDraggedRef.current = false;
|
|
8745
|
+
}, 0);
|
|
8746
|
+
return () => window.clearTimeout(id);
|
|
8747
|
+
}, [isDragging]);
|
|
8748
|
+
(0, import_react16.useEffect)(() => {
|
|
8659
8749
|
const div = divRef.current;
|
|
8660
8750
|
if (!div) return;
|
|
8661
8751
|
const onWheel = (e) => {
|
|
@@ -8671,7 +8761,7 @@ function HitArea({
|
|
|
8671
8761
|
return () => div.removeEventListener("wheel", onWheel);
|
|
8672
8762
|
}, []);
|
|
8673
8763
|
const { left, top, width, height } = scanned.rect;
|
|
8674
|
-
const cursor = isDragging ? "grabbing" : isSelected
|
|
8764
|
+
const cursor = isDragging ? "grabbing" : !isSelected ? "default" : hoverResizeHandle ? resizeCursorFromHandle(hoverResizeHandle) : "grab";
|
|
8675
8765
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
8676
8766
|
"div",
|
|
8677
8767
|
{
|
|
@@ -8702,6 +8792,35 @@ function HitArea({
|
|
|
8702
8792
|
...attributes,
|
|
8703
8793
|
...listeners,
|
|
8704
8794
|
onClick: (e) => {
|
|
8795
|
+
if (justDraggedRef.current) {
|
|
8796
|
+
e.preventDefault();
|
|
8797
|
+
e.stopPropagation();
|
|
8798
|
+
return;
|
|
8799
|
+
}
|
|
8800
|
+
const stack = document.elementsFromPoint(e.clientX, e.clientY);
|
|
8801
|
+
for (const candidate of stack) {
|
|
8802
|
+
if (!(candidate instanceof HTMLElement)) continue;
|
|
8803
|
+
if (candidate.hasAttribute("data-design-mode-ui")) continue;
|
|
8804
|
+
if (candidate === scanned.element) break;
|
|
8805
|
+
const candidateNodeId = candidate.getAttribute("data-dnd-node-id");
|
|
8806
|
+
if (candidateNodeId && candidateNodeId !== scanned.nodeId) {
|
|
8807
|
+
e.preventDefault();
|
|
8808
|
+
e.stopPropagation();
|
|
8809
|
+
candidate.dispatchEvent(
|
|
8810
|
+
new MouseEvent("mousedown", {
|
|
8811
|
+
bubbles: true,
|
|
8812
|
+
cancelable: true,
|
|
8813
|
+
clientX: e.clientX,
|
|
8814
|
+
clientY: e.clientY,
|
|
8815
|
+
metaKey: e.metaKey,
|
|
8816
|
+
ctrlKey: e.ctrlKey,
|
|
8817
|
+
shiftKey: e.shiftKey,
|
|
8818
|
+
altKey: e.altKey
|
|
8819
|
+
})
|
|
8820
|
+
);
|
|
8821
|
+
return;
|
|
8822
|
+
}
|
|
8823
|
+
}
|
|
8705
8824
|
e.preventDefault();
|
|
8706
8825
|
e.stopPropagation();
|
|
8707
8826
|
onActivate(scanned.nodeId);
|
|
@@ -8712,9 +8831,11 @@ function HitArea({
|
|
|
8712
8831
|
function DesignModeOverlay() {
|
|
8713
8832
|
const enabled = useDesignModeStore((s) => s.enabled);
|
|
8714
8833
|
const historyMode = useDesignModeStore((s) => s.historyMode);
|
|
8715
|
-
const setHovered = useDesignModeStore((s) => s.setHovered);
|
|
8716
8834
|
const selectElement = useDesignModeStore((s) => s.setSelected);
|
|
8717
|
-
const
|
|
8835
|
+
const inspectorSelectedNodeIds = useDesignModeStore(
|
|
8836
|
+
(s) => s.inspectorSelectedNodeIds
|
|
8837
|
+
);
|
|
8838
|
+
const arrangeSelectedNodeId = inspectorSelectedNodeIds.length === 1 ? inspectorSelectedNodeIds[0] : null;
|
|
8718
8839
|
const setHistoryAvailability = useDesignModeStore((s) => s.setHistoryAvailability);
|
|
8719
8840
|
const undoRequestId = useDesignModeStore((s) => s.undoRequestId);
|
|
8720
8841
|
const redoRequestId = useDesignModeStore((s) => s.redoRequestId);
|
|
@@ -8728,28 +8849,35 @@ function DesignModeOverlay() {
|
|
|
8728
8849
|
const exportChangesForAI = useDesignModeStore((s) => s.exportChangesForAI);
|
|
8729
8850
|
const externalDrag = useDesignModeStore((s) => s.externalDrag);
|
|
8730
8851
|
const { elements, pause, resume } = useElementScanner(enabled);
|
|
8731
|
-
const nodeMap = (0,
|
|
8852
|
+
const nodeMap = (0, import_react16.useMemo)(() => {
|
|
8732
8853
|
const m = /* @__PURE__ */ new Map();
|
|
8733
8854
|
for (const el of elements) m.set(el.nodeId, el);
|
|
8734
8855
|
return m;
|
|
8735
8856
|
}, [elements]);
|
|
8736
|
-
const draggableElements = (0,
|
|
8857
|
+
const draggableElements = (0, import_react16.useMemo)(() => {
|
|
8737
8858
|
if (elements.length === 0) return [];
|
|
8738
8859
|
const projection = buildProjection(elements);
|
|
8739
8860
|
return collectDraggableAnchors(elements, projection, nodeMap).filter(
|
|
8740
8861
|
(el) => el.draggable !== false
|
|
8741
8862
|
);
|
|
8742
8863
|
}, [elements, nodeMap]);
|
|
8864
|
+
const arrangeHitAreaElement = (0, import_react16.useMemo)(() => {
|
|
8865
|
+
if (!arrangeSelectedNodeId) return null;
|
|
8866
|
+
if (externalDrag) return null;
|
|
8867
|
+
return draggableElements.find(
|
|
8868
|
+
(candidate) => candidate.nodeId === arrangeSelectedNodeId
|
|
8869
|
+
) ?? null;
|
|
8870
|
+
}, [arrangeSelectedNodeId, externalDrag, draggableElements]);
|
|
8743
8871
|
const refs = useOverlayRefs(undoRequestId, redoRequestId);
|
|
8744
8872
|
refs.elementsRef.current = elements;
|
|
8745
8873
|
refs.nodeMapRef.current = nodeMap;
|
|
8746
|
-
(0,
|
|
8874
|
+
(0, import_react16.useEffect)(() => {
|
|
8747
8875
|
const m = /* @__PURE__ */ new Map();
|
|
8748
8876
|
for (const el of draggableElements) m.set(el.nodeId, el);
|
|
8749
8877
|
refs.draggableNodeMapRef.current = m;
|
|
8750
8878
|
}, [draggableElements]);
|
|
8751
|
-
const [grabFeedback, setGrabFeedback] = (0,
|
|
8752
|
-
(0,
|
|
8879
|
+
const [grabFeedback, setGrabFeedback] = (0, import_react16.useState)(null);
|
|
8880
|
+
(0, import_react16.useEffect)(() => {
|
|
8753
8881
|
if (!enabled) return;
|
|
8754
8882
|
const onPointerDown = (e) => {
|
|
8755
8883
|
if (!shouldShowGrabFeedback(
|
|
@@ -8763,21 +8891,21 @@ function DesignModeOverlay() {
|
|
|
8763
8891
|
document.addEventListener("pointerdown", onPointerDown, true);
|
|
8764
8892
|
return () => document.removeEventListener("pointerdown", onPointerDown, true);
|
|
8765
8893
|
}, [enabled]);
|
|
8766
|
-
(0,
|
|
8894
|
+
(0, import_react16.useEffect)(() => {
|
|
8767
8895
|
if (!grabFeedback) return;
|
|
8768
8896
|
const t = setTimeout(() => setGrabFeedback(null), 1400);
|
|
8769
8897
|
return () => clearTimeout(t);
|
|
8770
8898
|
}, [grabFeedback]);
|
|
8771
|
-
const resolveNodeElement = (0,
|
|
8899
|
+
const resolveNodeElement = (0, import_react16.useCallback)((nodeId) => {
|
|
8772
8900
|
const known = refs.nodeMapRef.current.get(nodeId)?.element;
|
|
8773
8901
|
if (known) return known;
|
|
8774
8902
|
return document.querySelector(buildNodeSelector(nodeId));
|
|
8775
8903
|
}, []);
|
|
8776
|
-
const clearCommitLaneCache = (0,
|
|
8904
|
+
const clearCommitLaneCache = (0, import_react16.useCallback)(() => {
|
|
8777
8905
|
refs.commitLaneCacheRef.current.clear();
|
|
8778
8906
|
refs.sourceCommitLaneRef.current = null;
|
|
8779
8907
|
}, []);
|
|
8780
|
-
const getCommitLaneSnapshot = (0,
|
|
8908
|
+
const getCommitLaneSnapshot = (0, import_react16.useCallback)((laneContainerId) => {
|
|
8781
8909
|
if (!laneContainerId) return null;
|
|
8782
8910
|
if (refs.commitLaneCacheRef.current.has(laneContainerId)) {
|
|
8783
8911
|
return refs.commitLaneCacheRef.current.get(laneContainerId) ?? null;
|
|
@@ -8786,11 +8914,11 @@ function DesignModeOverlay() {
|
|
|
8786
8914
|
refs.commitLaneCacheRef.current.set(laneContainerId, snapshot);
|
|
8787
8915
|
return snapshot;
|
|
8788
8916
|
}, []);
|
|
8789
|
-
const getCurrentCommitPlacement = (0,
|
|
8917
|
+
const getCurrentCommitPlacement = (0, import_react16.useCallback)((anchorNodeId, laneContainerId) => {
|
|
8790
8918
|
const lane = getCommitLaneSnapshot(laneContainerId);
|
|
8791
8919
|
return resolveCurrentCommitPlacement(lane, anchorNodeId);
|
|
8792
8920
|
}, [getCommitLaneSnapshot]);
|
|
8793
|
-
const applyCommand = (0,
|
|
8921
|
+
const applyCommand = (0, import_react16.useCallback)((command, direction) => {
|
|
8794
8922
|
if (command.type === "resize") {
|
|
8795
8923
|
const resCmd = command;
|
|
8796
8924
|
const targetId = resCmd.targetNodeId ?? resCmd.nodeId;
|
|
@@ -8813,28 +8941,28 @@ function DesignModeOverlay() {
|
|
|
8813
8941
|
clearCommitLaneCache();
|
|
8814
8942
|
return true;
|
|
8815
8943
|
}, [clearCommitLaneCache, resolveNodeElement]);
|
|
8816
|
-
const syncHistoryAvailability = (0,
|
|
8944
|
+
const syncHistoryAvailability = (0, import_react16.useCallback)(() => {
|
|
8817
8945
|
if (historyMode === "host") {
|
|
8818
8946
|
setHistoryAvailability(false, false);
|
|
8819
8947
|
return;
|
|
8820
8948
|
}
|
|
8821
8949
|
setHistoryAvailability(refs.historyRef.current.canUndo(), refs.historyRef.current.canRedo());
|
|
8822
8950
|
}, [historyMode, setHistoryAvailability]);
|
|
8823
|
-
(0,
|
|
8951
|
+
(0, import_react16.useEffect)(() => {
|
|
8824
8952
|
refs.historyRef.current.clear();
|
|
8825
8953
|
syncHistoryAvailability();
|
|
8826
8954
|
}, [enabled, syncHistoryAvailability]);
|
|
8827
8955
|
const sensors = useSensors(
|
|
8828
8956
|
useSensor(PointerSensor, { activationConstraint: { distance: 8 } })
|
|
8829
8957
|
);
|
|
8830
|
-
const collisionDetection = (0,
|
|
8958
|
+
const collisionDetection = (0, import_react16.useCallback)(
|
|
8831
8959
|
(args) => createDesignModeCollisionDetection(refs.blockedContainerIdsRef.current)(args),
|
|
8832
8960
|
[]
|
|
8833
8961
|
// eslint-disable-line react-hooks/exhaustive-deps -- refs are stable
|
|
8834
8962
|
);
|
|
8835
|
-
const [insideRect, setInsideRect] = (0,
|
|
8836
|
-
const [dropLine, setDropLine] = (0,
|
|
8837
|
-
(0,
|
|
8963
|
+
const [insideRect, setInsideRect] = (0, import_react16.useState)(null);
|
|
8964
|
+
const [dropLine, setDropLine] = (0, import_react16.useState)(null);
|
|
8965
|
+
(0, import_react16.useEffect)(() => {
|
|
8838
8966
|
if (!enabled) return;
|
|
8839
8967
|
const fn = (e) => {
|
|
8840
8968
|
refs.mouseRef.current = { x: e.clientX, y: e.clientY };
|
|
@@ -8842,7 +8970,7 @@ function DesignModeOverlay() {
|
|
|
8842
8970
|
window.addEventListener("pointermove", fn, { capture: true, passive: true });
|
|
8843
8971
|
return () => window.removeEventListener("pointermove", fn, { capture: true });
|
|
8844
8972
|
}, [enabled]);
|
|
8845
|
-
(0,
|
|
8973
|
+
(0, import_react16.useEffect)(() => {
|
|
8846
8974
|
if (!enabled) return;
|
|
8847
8975
|
if (historyMode !== "local") return;
|
|
8848
8976
|
const onKeyDown = (e) => {
|
|
@@ -8871,7 +8999,7 @@ function DesignModeOverlay() {
|
|
|
8871
8999
|
setInsideRect,
|
|
8872
9000
|
setDropLine
|
|
8873
9001
|
});
|
|
8874
|
-
(0,
|
|
9002
|
+
(0, import_react16.useEffect)(() => {
|
|
8875
9003
|
if (!enabled || activeDrag) return;
|
|
8876
9004
|
if (undoRequestId === refs.processedUndoIdRef.current) return;
|
|
8877
9005
|
refs.processedUndoIdRef.current = undoRequestId;
|
|
@@ -8888,7 +9016,7 @@ function DesignModeOverlay() {
|
|
|
8888
9016
|
});
|
|
8889
9017
|
syncHistoryAvailability();
|
|
8890
9018
|
}, [undoRequestId, enabled, activeDrag, applyCommand, resume, selectElement, syncHistoryAvailability, undoLastChange]);
|
|
8891
|
-
(0,
|
|
9019
|
+
(0, import_react16.useEffect)(() => {
|
|
8892
9020
|
if (!enabled || activeDrag || historyMode !== "local") return;
|
|
8893
9021
|
if (redoRequestId === refs.processedRedoIdRef.current) return;
|
|
8894
9022
|
refs.processedRedoIdRef.current = redoRequestId;
|
|
@@ -8900,18 +9028,18 @@ function DesignModeOverlay() {
|
|
|
8900
9028
|
}
|
|
8901
9029
|
syncHistoryAvailability();
|
|
8902
9030
|
}, [redoRequestId, enabled, activeDrag, applyCommand, historyMode, resume, selectElement, syncHistoryAvailability, redoLastChange]);
|
|
8903
|
-
(0,
|
|
9031
|
+
(0, import_react16.useEffect)(() => {
|
|
8904
9032
|
syncHistoryAvailability();
|
|
8905
9033
|
}, [syncHistoryAvailability]);
|
|
8906
|
-
(0,
|
|
9034
|
+
(0, import_react16.useEffect)(() => {
|
|
8907
9035
|
dispatchRuntimeEvent({
|
|
8908
9036
|
type: "design-mode-changed",
|
|
8909
9037
|
mode: enabled ? "design" : "off"
|
|
8910
9038
|
});
|
|
8911
9039
|
}, [enabled]);
|
|
8912
|
-
(0,
|
|
9040
|
+
(0, import_react16.useEffect)(() => {
|
|
8913
9041
|
const aiOutput = exportChangesForAI();
|
|
8914
|
-
const updatedAt =
|
|
9042
|
+
const updatedAt = Date.now();
|
|
8915
9043
|
dispatchRuntimeEvent({
|
|
8916
9044
|
type: "arrange-session-changed",
|
|
8917
9045
|
session: buildArrangeSessionSnapshot({
|
|
@@ -8922,12 +9050,11 @@ function DesignModeOverlay() {
|
|
|
8922
9050
|
})
|
|
8923
9051
|
});
|
|
8924
9052
|
}, [enabled, exportChangesForAI, orderedChanges]);
|
|
8925
|
-
(0,
|
|
9053
|
+
(0, import_react16.useEffect)(() => {
|
|
8926
9054
|
if (!enabled) return;
|
|
8927
9055
|
document.body.classList.add("design-mode-active");
|
|
8928
9056
|
return () => document.body.classList.remove("design-mode-active");
|
|
8929
9057
|
}, [enabled]);
|
|
8930
|
-
useHoverDetection({ enabled, activeDrag, elementsRef: refs.elementsRef, setHovered });
|
|
8931
9058
|
useDesignModeAutoScroll({
|
|
8932
9059
|
active: !!activeDrag,
|
|
8933
9060
|
mouseRef: refs.mouseRef,
|
|
@@ -8966,19 +9093,21 @@ function DesignModeOverlay() {
|
|
|
8966
9093
|
elements,
|
|
8967
9094
|
draggingNodeId: activeDrag?.nodeId ?? null,
|
|
8968
9095
|
activeEl: refs.activeElRef.current,
|
|
9096
|
+
arrangeSelectedNodeId,
|
|
9097
|
+
externalDragActive: externalDrag !== null,
|
|
8969
9098
|
onResizeHandlePointerDown: handleResizeHandlePointerDown
|
|
8970
9099
|
}
|
|
8971
9100
|
),
|
|
8972
|
-
|
|
9101
|
+
arrangeHitAreaElement && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
8973
9102
|
HitArea,
|
|
8974
9103
|
{
|
|
8975
|
-
scanned:
|
|
9104
|
+
scanned: arrangeHitAreaElement,
|
|
8976
9105
|
onActivate: selectElement,
|
|
8977
|
-
selectedNodeId:
|
|
9106
|
+
selectedNodeId: arrangeHitAreaElement.nodeId,
|
|
8978
9107
|
onResizeHandlePointerDown: handleResizeHandlePointerDown
|
|
8979
9108
|
},
|
|
8980
|
-
|
|
8981
|
-
)
|
|
9109
|
+
arrangeHitAreaElement.nodeId
|
|
9110
|
+
),
|
|
8982
9111
|
grabFeedback ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
8983
9112
|
"div",
|
|
8984
9113
|
{
|
|
@@ -9045,8 +9174,8 @@ function DesignModeOverlay() {
|
|
|
9045
9174
|
}
|
|
9046
9175
|
|
|
9047
9176
|
// src/client/dnd/design-mode/DesignModeErrorBoundary.tsx
|
|
9048
|
-
var
|
|
9049
|
-
var DesignModeErrorBoundary = class extends
|
|
9177
|
+
var import_react17 = __toESM(require("react"));
|
|
9178
|
+
var DesignModeErrorBoundary = class extends import_react17.default.Component {
|
|
9050
9179
|
constructor(props) {
|
|
9051
9180
|
super(props);
|
|
9052
9181
|
this.state = { hasError: false };
|
|
@@ -9087,13 +9216,13 @@ function DndProvider({ children }) {
|
|
|
9087
9216
|
const setHistoryMode = useDesignModeStore((s) => s.setHistoryMode);
|
|
9088
9217
|
const setInspectorTheme = useDesignModeStore((s) => s.setInspectorTheme);
|
|
9089
9218
|
const requestUndo = useDesignModeStore((s) => s.requestUndo);
|
|
9090
|
-
const transitionDesignMode = (0,
|
|
9219
|
+
const transitionDesignMode = (0, import_react18.useCallback)((nextEnabled) => {
|
|
9091
9220
|
const designModeState = useDesignModeStore.getState();
|
|
9092
9221
|
if (designModeState.enabled === nextEnabled) return;
|
|
9093
9222
|
designModeState.resetArrangeSession();
|
|
9094
9223
|
designModeState.setEnabled(nextEnabled);
|
|
9095
9224
|
}, []);
|
|
9096
|
-
(0,
|
|
9225
|
+
(0, import_react18.useEffect)(() => {
|
|
9097
9226
|
const handleKeyDown = (e) => {
|
|
9098
9227
|
if (e.ctrlKey && e.shiftKey && e.key === "D") {
|
|
9099
9228
|
e.preventDefault();
|
|
@@ -9103,7 +9232,7 @@ function DndProvider({ children }) {
|
|
|
9103
9232
|
window.addEventListener("keydown", handleKeyDown);
|
|
9104
9233
|
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
9105
9234
|
}, [transitionDesignMode]);
|
|
9106
|
-
(0,
|
|
9235
|
+
(0, import_react18.useEffect)(() => {
|
|
9107
9236
|
const handleHostCommand = (event) => {
|
|
9108
9237
|
const detail = event.detail;
|
|
9109
9238
|
if (!detail || typeof detail !== "object") return;
|
|
@@ -9162,10 +9291,29 @@ function DndProvider({ children }) {
|
|
|
9162
9291
|
setInspectorTheme,
|
|
9163
9292
|
requestUndo
|
|
9164
9293
|
]);
|
|
9294
|
+
(0, import_react18.useEffect)(() => {
|
|
9295
|
+
const bridgeWindow = window;
|
|
9296
|
+
const bridge = {
|
|
9297
|
+
setInspectorSelection: (nodeIds) => {
|
|
9298
|
+
useDesignModeStore.getState().setInspectorSelection(nodeIds);
|
|
9299
|
+
}
|
|
9300
|
+
};
|
|
9301
|
+
bridgeWindow.__ARCHIE_DESIGN_MODE__ = bridge;
|
|
9302
|
+
const pending = bridgeWindow.__ARCHIE_DESIGN_MODE_PENDING__;
|
|
9303
|
+
if (Array.isArray(pending)) {
|
|
9304
|
+
bridge.setInspectorSelection(pending);
|
|
9305
|
+
delete bridgeWindow.__ARCHIE_DESIGN_MODE_PENDING__;
|
|
9306
|
+
}
|
|
9307
|
+
return () => {
|
|
9308
|
+
if (bridgeWindow.__ARCHIE_DESIGN_MODE__ === bridge) {
|
|
9309
|
+
delete bridgeWindow.__ARCHIE_DESIGN_MODE__;
|
|
9310
|
+
}
|
|
9311
|
+
};
|
|
9312
|
+
}, []);
|
|
9165
9313
|
const pointerSensor = useSensor(PointerSensor, { activationConstraint: { distance: 8 } });
|
|
9166
9314
|
const keyboardSensor = useSensor(KeyboardSensor, { coordinateGetter: sortableKeyboardCoordinates });
|
|
9167
9315
|
const sensors = useSensors(pointerSensor, keyboardSensor);
|
|
9168
|
-
const handleDragStart = (0,
|
|
9316
|
+
const handleDragStart = (0, import_react18.useCallback)(
|
|
9169
9317
|
(event) => {
|
|
9170
9318
|
const { active } = event;
|
|
9171
9319
|
const element = document.querySelector(`[data-canvas-node="${active.id}"]`);
|
|
@@ -9173,7 +9321,7 @@ function DndProvider({ children }) {
|
|
|
9173
9321
|
},
|
|
9174
9322
|
[setActive]
|
|
9175
9323
|
);
|
|
9176
|
-
const handleDragEnd = (0,
|
|
9324
|
+
const handleDragEnd = (0, import_react18.useCallback)(
|
|
9177
9325
|
(event) => {
|
|
9178
9326
|
const { active, over } = event;
|
|
9179
9327
|
const dragEndEvent = {
|
|
@@ -9189,7 +9337,7 @@ function DndProvider({ children }) {
|
|
|
9189
9337
|
},
|
|
9190
9338
|
[dragEndHandlers, setActive]
|
|
9191
9339
|
);
|
|
9192
|
-
const handleDesignModeCrash = (0,
|
|
9340
|
+
const handleDesignModeCrash = (0, import_react18.useCallback)(() => {
|
|
9193
9341
|
const designModeState = useDesignModeStore.getState();
|
|
9194
9342
|
designModeState.resetAll();
|
|
9195
9343
|
designModeState.resetArrangeSession();
|
|
@@ -9233,13 +9381,12 @@ function DndProvider({ children }) {
|
|
|
9233
9381
|
}
|
|
9234
9382
|
|
|
9235
9383
|
// src/client/useArchieDevToolsRuntime.ts
|
|
9236
|
-
var
|
|
9384
|
+
var import_react20 = require("react");
|
|
9237
9385
|
|
|
9238
9386
|
// src/client/archieLocalInspectorEnv.ts
|
|
9239
|
-
var import_meta = {};
|
|
9240
9387
|
function readArchieLocalInspectorFlag() {
|
|
9241
9388
|
try {
|
|
9242
|
-
return
|
|
9389
|
+
return false;
|
|
9243
9390
|
} catch {
|
|
9244
9391
|
return false;
|
|
9245
9392
|
}
|
|
@@ -9424,13 +9571,13 @@ function setupArchieRouteListener(router) {
|
|
|
9424
9571
|
}
|
|
9425
9572
|
|
|
9426
9573
|
// src/client/runtime/domMetaSanitizer.ts
|
|
9427
|
-
var
|
|
9574
|
+
var import_react19 = __toESM(require("react"));
|
|
9428
9575
|
var _installed = false;
|
|
9429
9576
|
function installDomMetaSanitizer() {
|
|
9430
9577
|
if (_installed) return;
|
|
9431
9578
|
_installed = true;
|
|
9432
|
-
const _origCE =
|
|
9433
|
-
|
|
9579
|
+
const _origCE = import_react19.default.createElement.bind(import_react19.default);
|
|
9580
|
+
import_react19.default.createElement = function patchedCreateElement(type, props, ...children) {
|
|
9434
9581
|
if (typeof type === "string" && props != null && "__editorMeta" in props) {
|
|
9435
9582
|
const { __editorMeta: _stripped, ...rest } = props;
|
|
9436
9583
|
return _origCE(type, rest, ...children);
|
|
@@ -9458,9 +9605,9 @@ function useArchieDevToolsRuntime({
|
|
|
9458
9605
|
inspectorOptions
|
|
9459
9606
|
}) {
|
|
9460
9607
|
const stableOptionsKey = JSON.stringify(inspectorOptions ?? null);
|
|
9461
|
-
const inspectorOptionsRef = (0,
|
|
9608
|
+
const inspectorOptionsRef = (0, import_react20.useRef)(inspectorOptions);
|
|
9462
9609
|
inspectorOptionsRef.current = inspectorOptions;
|
|
9463
|
-
(0,
|
|
9610
|
+
(0, import_react20.useEffect)(() => {
|
|
9464
9611
|
if (process.env.NODE_ENV !== "development") {
|
|
9465
9612
|
return;
|
|
9466
9613
|
}
|