@archie/devtools 0.1.9 → 0.1.11
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/dist/client/client.js
CHANGED
|
@@ -5335,6 +5335,17 @@ var MIN_WIDTH = 40;
|
|
|
5335
5335
|
var MIN_HEIGHT = 20;
|
|
5336
5336
|
var INTERACTIVE_MIN = 8;
|
|
5337
5337
|
var MAX_DEPTH = 12;
|
|
5338
|
+
var COLLAPSED_CONTAINER_HIT_MIN = 24;
|
|
5339
|
+
function collapsedContainerHitRect(el, rect) {
|
|
5340
|
+
if (el.children.length > 0 || el.textContent?.trim()) return null;
|
|
5341
|
+
if (getDirectEditorMeta(el)?.containerKind !== "plain") return null;
|
|
5342
|
+
if (el.getClientRects().length === 0) return null;
|
|
5343
|
+
const width = Math.max(rect.width, COLLAPSED_CONTAINER_HIT_MIN);
|
|
5344
|
+
const height = Math.max(rect.height, COLLAPSED_CONTAINER_HIT_MIN);
|
|
5345
|
+
const left = rect.left + rect.width / 2 - width / 2;
|
|
5346
|
+
const top = rect.top + rect.height / 2 - height / 2;
|
|
5347
|
+
return new DOMRect(left, top, width, height);
|
|
5348
|
+
}
|
|
5338
5349
|
var _runtimeNodeIdMap = /* @__PURE__ */ new WeakMap();
|
|
5339
5350
|
var _runtimeNodeIdCounter = 0;
|
|
5340
5351
|
function getRuntimeNodeId(el) {
|
|
@@ -5486,7 +5497,8 @@ function scanElements(root, depth = 0, usedNodeIds = /* @__PURE__ */ new Set(),
|
|
|
5486
5497
|
const nodeId2 = resolveStableNodeId(el, usedNodeIds);
|
|
5487
5498
|
usedNodeIds.add(nodeId2);
|
|
5488
5499
|
el.setAttribute(DND_NODE_ID_ATTR, nodeId2);
|
|
5489
|
-
|
|
5500
|
+
const collapsedHitRect = isZeroRect && !isSvgRoot ? collapsedContainerHitRect(el, rect) : null;
|
|
5501
|
+
if (isZeroRect && !collapsedHitRect) {
|
|
5490
5502
|
resolvedUnreported.add(el);
|
|
5491
5503
|
} else {
|
|
5492
5504
|
seenResolvedHosts.add(el);
|
|
@@ -5503,7 +5515,7 @@ function scanElements(root, depth = 0, usedNodeIds = /* @__PURE__ */ new Set(),
|
|
|
5503
5515
|
resolvedHostSelector: selector,
|
|
5504
5516
|
resolutionKind: "direct-host",
|
|
5505
5517
|
label: getLabel(el),
|
|
5506
|
-
rect,
|
|
5518
|
+
rect: collapsedHitRect ?? rect,
|
|
5507
5519
|
containerStrategy: parentEl2 && isFlexOrGridParent(parentEl2) ? resolveContainerStrategy(parentEl2) : null,
|
|
5508
5520
|
eligibilitySource: smallEligibility,
|
|
5509
5521
|
draggable: false,
|
|
@@ -7407,7 +7419,7 @@ function computeSlotBoundaryPoint(slot, container, projectionTree) {
|
|
|
7407
7419
|
{
|
|
7408
7420
|
let lineY;
|
|
7409
7421
|
if (n === 0) {
|
|
7410
|
-
lineY = container.rect.top;
|
|
7422
|
+
lineY = container.rect.top + container.rect.height / 2;
|
|
7411
7423
|
} else if (i === 0) {
|
|
7412
7424
|
lineY = nodeRect(children[0])?.top ?? container.rect.top;
|
|
7413
7425
|
} else if (i >= n) {
|
|
@@ -7912,6 +7924,7 @@ function createDragIntentEngine(projection, activeId, options) {
|
|
|
7912
7924
|
// src/client/dnd/design-mode/drop-line.ts
|
|
7913
7925
|
var DROP_LINE_THICKNESS_PX = 2;
|
|
7914
7926
|
var DROP_LINE_MIN_LENGTH_PX = 40;
|
|
7927
|
+
var EMPTY_CONTAINER_INSET_PX = 8;
|
|
7915
7928
|
function slotDropLine(slot, container, projectionTree, sdx, sdy) {
|
|
7916
7929
|
const T = DROP_LINE_THICKNESS_PX;
|
|
7917
7930
|
const MIN = DROP_LINE_MIN_LENGTH_PX;
|
|
@@ -7945,6 +7958,14 @@ function slotDropLine(slot, container, projectionTree, sdx, sdy) {
|
|
|
7945
7958
|
};
|
|
7946
7959
|
}
|
|
7947
7960
|
}
|
|
7961
|
+
if (container.children.length === 0 && container.rect.width > 2 * EMPTY_CONTAINER_INSET_PX + MIN) {
|
|
7962
|
+
return {
|
|
7963
|
+
x: container.rect.left + EMPTY_CONTAINER_INSET_PX - sdx,
|
|
7964
|
+
y: bp.y - sdy - T / 2,
|
|
7965
|
+
width: container.rect.width - 2 * EMPTY_CONTAINER_INSET_PX,
|
|
7966
|
+
height: T
|
|
7967
|
+
};
|
|
7968
|
+
}
|
|
7948
7969
|
return {
|
|
7949
7970
|
x: container.rect.left - sdx,
|
|
7950
7971
|
y: bp.y - sdy - T / 2,
|
|
@@ -8154,6 +8175,27 @@ function computeAllowNest(nestPreview, isLargeDraggedNode, rowLocked) {
|
|
|
8154
8175
|
const childId = nestPreview.slotId.split("::nest::")[1] ?? "";
|
|
8155
8176
|
return !!childId && !isLargeDraggedNode;
|
|
8156
8177
|
}
|
|
8178
|
+
function resolveContainerHold(params) {
|
|
8179
|
+
const { intent, previousIntent, sourceContainerId, projection, x, y } = params;
|
|
8180
|
+
if (intent.mode !== "reorder" || previousIntent?.mode !== "reorder") return intent;
|
|
8181
|
+
if (previousIntent.containerId === intent.containerId) return intent;
|
|
8182
|
+
if (intent.containerId === sourceContainerId) return intent;
|
|
8183
|
+
if (isProjectedDescendant(intent.containerId, previousIntent.containerId, projection.projectionTree)) {
|
|
8184
|
+
return intent;
|
|
8185
|
+
}
|
|
8186
|
+
const prev = projection.containerIndex.get(previousIntent.containerId);
|
|
8187
|
+
if (!prev) return intent;
|
|
8188
|
+
const inPrevExpanded = x >= prev.rect.left - CONTAINER_SWITCH_HYSTERESIS && x <= prev.rect.right + CONTAINER_SWITCH_HYSTERESIS && y >= prev.rect.top - CONTAINER_SWITCH_HYSTERESIS && y <= prev.rect.bottom + CONTAINER_SWITCH_HYSTERESIS;
|
|
8189
|
+
return inPrevExpanded ? previousIntent : intent;
|
|
8190
|
+
}
|
|
8191
|
+
function isProjectedDescendant(id, ancestorId, tree) {
|
|
8192
|
+
let parentId = tree.get(id)?.parentId ?? null;
|
|
8193
|
+
while (parentId) {
|
|
8194
|
+
if (parentId === ancestorId) return true;
|
|
8195
|
+
parentId = tree.get(parentId)?.parentId ?? null;
|
|
8196
|
+
}
|
|
8197
|
+
return false;
|
|
8198
|
+
}
|
|
8157
8199
|
function useDragVisualLoop({
|
|
8158
8200
|
activeDrag,
|
|
8159
8201
|
refs,
|
|
@@ -8245,15 +8287,14 @@ function useDragVisualLoop({
|
|
|
8245
8287
|
rafId = requestAnimationFrame(tick);
|
|
8246
8288
|
return;
|
|
8247
8289
|
}
|
|
8248
|
-
|
|
8249
|
-
|
|
8250
|
-
|
|
8251
|
-
|
|
8252
|
-
|
|
8253
|
-
|
|
8254
|
-
|
|
8255
|
-
|
|
8256
|
-
}
|
|
8290
|
+
intent = resolveContainerHold({
|
|
8291
|
+
intent,
|
|
8292
|
+
previousIntent: refs.lastIntentRef.current,
|
|
8293
|
+
sourceContainerId: refs.sourceContainerIdRef.current,
|
|
8294
|
+
projection: refs.projectionRef.current,
|
|
8295
|
+
x: adjustedPx,
|
|
8296
|
+
y: adjustedPy
|
|
8297
|
+
});
|
|
8257
8298
|
if (intent.mode === "nest") {
|
|
8258
8299
|
setTargetPlane("nest");
|
|
8259
8300
|
const targetId = intent.slotId.split("::nest::")[1] ?? "";
|
|
@@ -10230,7 +10271,7 @@ function isPreviewOrigin(origin) {
|
|
|
10230
10271
|
var DEFAULT_SCRIPT_ID = "archie-inspector-script";
|
|
10231
10272
|
var R2_INSPECTOR_BASE_URL = "https://pub-bf238c278d9644b39ec34ecaca1d315c.r2.dev";
|
|
10232
10273
|
function readBuildVersion() {
|
|
10233
|
-
return "0.1.
|
|
10274
|
+
return "0.1.11" ? "0.1.11" : null;
|
|
10234
10275
|
}
|
|
10235
10276
|
var REMOTE_INSPECTOR_VERSION = readBuildVersion();
|
|
10236
10277
|
var isRemoteInspectorUrlVersioned = REMOTE_INSPECTOR_VERSION !== null;
|
package/dist/client/client.mjs
CHANGED
|
@@ -5300,6 +5300,17 @@ var MIN_WIDTH = 40;
|
|
|
5300
5300
|
var MIN_HEIGHT = 20;
|
|
5301
5301
|
var INTERACTIVE_MIN = 8;
|
|
5302
5302
|
var MAX_DEPTH = 12;
|
|
5303
|
+
var COLLAPSED_CONTAINER_HIT_MIN = 24;
|
|
5304
|
+
function collapsedContainerHitRect(el, rect) {
|
|
5305
|
+
if (el.children.length > 0 || el.textContent?.trim()) return null;
|
|
5306
|
+
if (getDirectEditorMeta(el)?.containerKind !== "plain") return null;
|
|
5307
|
+
if (el.getClientRects().length === 0) return null;
|
|
5308
|
+
const width = Math.max(rect.width, COLLAPSED_CONTAINER_HIT_MIN);
|
|
5309
|
+
const height = Math.max(rect.height, COLLAPSED_CONTAINER_HIT_MIN);
|
|
5310
|
+
const left = rect.left + rect.width / 2 - width / 2;
|
|
5311
|
+
const top = rect.top + rect.height / 2 - height / 2;
|
|
5312
|
+
return new DOMRect(left, top, width, height);
|
|
5313
|
+
}
|
|
5303
5314
|
var _runtimeNodeIdMap = /* @__PURE__ */ new WeakMap();
|
|
5304
5315
|
var _runtimeNodeIdCounter = 0;
|
|
5305
5316
|
function getRuntimeNodeId(el) {
|
|
@@ -5451,7 +5462,8 @@ function scanElements(root, depth = 0, usedNodeIds = /* @__PURE__ */ new Set(),
|
|
|
5451
5462
|
const nodeId2 = resolveStableNodeId(el, usedNodeIds);
|
|
5452
5463
|
usedNodeIds.add(nodeId2);
|
|
5453
5464
|
el.setAttribute(DND_NODE_ID_ATTR, nodeId2);
|
|
5454
|
-
|
|
5465
|
+
const collapsedHitRect = isZeroRect && !isSvgRoot ? collapsedContainerHitRect(el, rect) : null;
|
|
5466
|
+
if (isZeroRect && !collapsedHitRect) {
|
|
5455
5467
|
resolvedUnreported.add(el);
|
|
5456
5468
|
} else {
|
|
5457
5469
|
seenResolvedHosts.add(el);
|
|
@@ -5468,7 +5480,7 @@ function scanElements(root, depth = 0, usedNodeIds = /* @__PURE__ */ new Set(),
|
|
|
5468
5480
|
resolvedHostSelector: selector,
|
|
5469
5481
|
resolutionKind: "direct-host",
|
|
5470
5482
|
label: getLabel(el),
|
|
5471
|
-
rect,
|
|
5483
|
+
rect: collapsedHitRect ?? rect,
|
|
5472
5484
|
containerStrategy: parentEl2 && isFlexOrGridParent(parentEl2) ? resolveContainerStrategy(parentEl2) : null,
|
|
5473
5485
|
eligibilitySource: smallEligibility,
|
|
5474
5486
|
draggable: false,
|
|
@@ -7372,7 +7384,7 @@ function computeSlotBoundaryPoint(slot, container, projectionTree) {
|
|
|
7372
7384
|
{
|
|
7373
7385
|
let lineY;
|
|
7374
7386
|
if (n === 0) {
|
|
7375
|
-
lineY = container.rect.top;
|
|
7387
|
+
lineY = container.rect.top + container.rect.height / 2;
|
|
7376
7388
|
} else if (i === 0) {
|
|
7377
7389
|
lineY = nodeRect(children[0])?.top ?? container.rect.top;
|
|
7378
7390
|
} else if (i >= n) {
|
|
@@ -7877,6 +7889,7 @@ function createDragIntentEngine(projection, activeId, options) {
|
|
|
7877
7889
|
// src/client/dnd/design-mode/drop-line.ts
|
|
7878
7890
|
var DROP_LINE_THICKNESS_PX = 2;
|
|
7879
7891
|
var DROP_LINE_MIN_LENGTH_PX = 40;
|
|
7892
|
+
var EMPTY_CONTAINER_INSET_PX = 8;
|
|
7880
7893
|
function slotDropLine(slot, container, projectionTree, sdx, sdy) {
|
|
7881
7894
|
const T = DROP_LINE_THICKNESS_PX;
|
|
7882
7895
|
const MIN = DROP_LINE_MIN_LENGTH_PX;
|
|
@@ -7910,6 +7923,14 @@ function slotDropLine(slot, container, projectionTree, sdx, sdy) {
|
|
|
7910
7923
|
};
|
|
7911
7924
|
}
|
|
7912
7925
|
}
|
|
7926
|
+
if (container.children.length === 0 && container.rect.width > 2 * EMPTY_CONTAINER_INSET_PX + MIN) {
|
|
7927
|
+
return {
|
|
7928
|
+
x: container.rect.left + EMPTY_CONTAINER_INSET_PX - sdx,
|
|
7929
|
+
y: bp.y - sdy - T / 2,
|
|
7930
|
+
width: container.rect.width - 2 * EMPTY_CONTAINER_INSET_PX,
|
|
7931
|
+
height: T
|
|
7932
|
+
};
|
|
7933
|
+
}
|
|
7913
7934
|
return {
|
|
7914
7935
|
x: container.rect.left - sdx,
|
|
7915
7936
|
y: bp.y - sdy - T / 2,
|
|
@@ -8119,6 +8140,27 @@ function computeAllowNest(nestPreview, isLargeDraggedNode, rowLocked) {
|
|
|
8119
8140
|
const childId = nestPreview.slotId.split("::nest::")[1] ?? "";
|
|
8120
8141
|
return !!childId && !isLargeDraggedNode;
|
|
8121
8142
|
}
|
|
8143
|
+
function resolveContainerHold(params) {
|
|
8144
|
+
const { intent, previousIntent, sourceContainerId, projection, x, y } = params;
|
|
8145
|
+
if (intent.mode !== "reorder" || previousIntent?.mode !== "reorder") return intent;
|
|
8146
|
+
if (previousIntent.containerId === intent.containerId) return intent;
|
|
8147
|
+
if (intent.containerId === sourceContainerId) return intent;
|
|
8148
|
+
if (isProjectedDescendant(intent.containerId, previousIntent.containerId, projection.projectionTree)) {
|
|
8149
|
+
return intent;
|
|
8150
|
+
}
|
|
8151
|
+
const prev = projection.containerIndex.get(previousIntent.containerId);
|
|
8152
|
+
if (!prev) return intent;
|
|
8153
|
+
const inPrevExpanded = x >= prev.rect.left - CONTAINER_SWITCH_HYSTERESIS && x <= prev.rect.right + CONTAINER_SWITCH_HYSTERESIS && y >= prev.rect.top - CONTAINER_SWITCH_HYSTERESIS && y <= prev.rect.bottom + CONTAINER_SWITCH_HYSTERESIS;
|
|
8154
|
+
return inPrevExpanded ? previousIntent : intent;
|
|
8155
|
+
}
|
|
8156
|
+
function isProjectedDescendant(id, ancestorId, tree) {
|
|
8157
|
+
let parentId = tree.get(id)?.parentId ?? null;
|
|
8158
|
+
while (parentId) {
|
|
8159
|
+
if (parentId === ancestorId) return true;
|
|
8160
|
+
parentId = tree.get(parentId)?.parentId ?? null;
|
|
8161
|
+
}
|
|
8162
|
+
return false;
|
|
8163
|
+
}
|
|
8122
8164
|
function useDragVisualLoop({
|
|
8123
8165
|
activeDrag,
|
|
8124
8166
|
refs,
|
|
@@ -8210,15 +8252,14 @@ function useDragVisualLoop({
|
|
|
8210
8252
|
rafId = requestAnimationFrame(tick);
|
|
8211
8253
|
return;
|
|
8212
8254
|
}
|
|
8213
|
-
|
|
8214
|
-
|
|
8215
|
-
|
|
8216
|
-
|
|
8217
|
-
|
|
8218
|
-
|
|
8219
|
-
|
|
8220
|
-
|
|
8221
|
-
}
|
|
8255
|
+
intent = resolveContainerHold({
|
|
8256
|
+
intent,
|
|
8257
|
+
previousIntent: refs.lastIntentRef.current,
|
|
8258
|
+
sourceContainerId: refs.sourceContainerIdRef.current,
|
|
8259
|
+
projection: refs.projectionRef.current,
|
|
8260
|
+
x: adjustedPx,
|
|
8261
|
+
y: adjustedPy
|
|
8262
|
+
});
|
|
8222
8263
|
if (intent.mode === "nest") {
|
|
8223
8264
|
setTargetPlane("nest");
|
|
8224
8265
|
const targetId = intent.slotId.split("::nest::")[1] ?? "";
|
|
@@ -10195,7 +10236,7 @@ function isPreviewOrigin(origin) {
|
|
|
10195
10236
|
var DEFAULT_SCRIPT_ID = "archie-inspector-script";
|
|
10196
10237
|
var R2_INSPECTOR_BASE_URL = "https://pub-bf238c278d9644b39ec34ecaca1d315c.r2.dev";
|
|
10197
10238
|
function readBuildVersion() {
|
|
10198
|
-
return "0.1.
|
|
10239
|
+
return "0.1.11" ? "0.1.11" : null;
|
|
10199
10240
|
}
|
|
10200
10241
|
var REMOTE_INSPECTOR_VERSION = readBuildVersion();
|
|
10201
10242
|
var isRemoteInspectorUrlVersioned = REMOTE_INSPECTOR_VERSION !== null;
|
|
@@ -2139,6 +2139,10 @@
|
|
|
2139
2139
|
vidIdentity: true,
|
|
2140
2140
|
nodeMeta: true,
|
|
2141
2141
|
refusals: true,
|
|
2142
|
+
// Host -> runtime `SELECT {vid}` (alias `SELECT_ELEMENT_BY_VID`)
|
|
2143
|
+
// re-selects a node by its stamped `data-vid`, e.g. after the
|
|
2144
|
+
// iframe reloaded and lost the selection.
|
|
2145
|
+
selectByVid: true,
|
|
2142
2146
|
},
|
|
2143
2147
|
}
|
|
2144
2148
|
}
|
|
@@ -2198,9 +2202,27 @@
|
|
|
2198
2202
|
}
|
|
2199
2203
|
if (meta && meta.componentName) nodeMeta.component = meta.componentName
|
|
2200
2204
|
if (meta && meta.lockReason) nodeMeta.lockReason = meta.lockReason
|
|
2205
|
+
if (nodeMeta.isKitOrigin) {
|
|
2206
|
+
var usage = resolveScreenUsageMeta(el)
|
|
2207
|
+
if (usage && usage.vid !== vid) {
|
|
2208
|
+
nodeMeta.usageVid = usage.vid
|
|
2209
|
+
if (usage.file) nodeMeta.usageFile = usage.file
|
|
2210
|
+
}
|
|
2211
|
+
}
|
|
2201
2212
|
return nodeMeta
|
|
2202
2213
|
}
|
|
2203
2214
|
|
|
2215
|
+
// The nearest non-template meta above `el` (the screen-file usage of
|
|
2216
|
+
// the kit instance owning it) when it carries a valid vid, else null.
|
|
2217
|
+
function resolveScreenUsageMeta(el) {
|
|
2218
|
+
var owner = getUsageMetaOwnerFiberFromElement(el)
|
|
2219
|
+
var usage = owner && resolveEditorMetaValue(owner.memoizedProps.__editorMeta)
|
|
2220
|
+
if (usage && typeof usage.vid === "string" && VID_PATTERN.test(usage.vid)) {
|
|
2221
|
+
return usage
|
|
2222
|
+
}
|
|
2223
|
+
return null
|
|
2224
|
+
}
|
|
2225
|
+
|
|
2204
2226
|
/**
|
|
2205
2227
|
* Emit `REFUSED` (vid-identity migration) instead of letting a
|
|
2206
2228
|
* drag/drop the runtime's own policy would reject proceed silently —
|
|
@@ -2283,6 +2305,53 @@
|
|
|
2283
2305
|
var inspectorCleanupMap = new WeakMap()
|
|
2284
2306
|
var BADGE_UPDATE_DELAY_MS = 50
|
|
2285
2307
|
|
|
2308
|
+
// Host-driven selection by `data-vid`: same end state as a single
|
|
2309
|
+
// user click (styles, `selectedElements`, design-mode sync, an
|
|
2310
|
+
// `ELEMENT_SELECTED` carrying `extractMetadata`). Silent when the vid
|
|
2311
|
+
// is malformed or nothing renders it.
|
|
2312
|
+
function selectElementByVid(vid) {
|
|
2313
|
+
if (typeof vid !== "string" || !VID_PATTERN.test(vid)) return
|
|
2314
|
+
var target = safeQuerySelector('[data-vid="' + vid + '"]')
|
|
2315
|
+
if (!target || !isValidContentElement(target)) {
|
|
2316
|
+
inspectorLog("[Inspector] SELECT: no element for vid", vid)
|
|
2317
|
+
return
|
|
2318
|
+
}
|
|
2319
|
+
|
|
2320
|
+
removeHighlight()
|
|
2321
|
+
var previousSelection = selectedElements.slice()
|
|
2322
|
+
previousSelection.forEach(function (el) {
|
|
2323
|
+
removeInspectorStyles(el)
|
|
2324
|
+
cleanupElementListeners(el)
|
|
2325
|
+
})
|
|
2326
|
+
selectedElements = [target]
|
|
2327
|
+
selectedElement = target
|
|
2328
|
+
window._inspectorSelectedElement = target
|
|
2329
|
+
if (window.__ARCHIE_INSPECTOR__)
|
|
2330
|
+
window.__ARCHIE_INSPECTOR__.selectedElement = target
|
|
2331
|
+
isElementSelected = true
|
|
2332
|
+
|
|
2333
|
+
applyInspectorStyles(target)
|
|
2334
|
+
createSelectedBadge(target)
|
|
2335
|
+
updateSharedHighlights()
|
|
2336
|
+
setupBadgePositionListeners(target)
|
|
2337
|
+
|
|
2338
|
+
var rect = target.getBoundingClientRect()
|
|
2339
|
+
var offscreen =
|
|
2340
|
+
rect.bottom < 0 ||
|
|
2341
|
+
rect.right < 0 ||
|
|
2342
|
+
rect.top > window.innerHeight ||
|
|
2343
|
+
rect.left > window.innerWidth
|
|
2344
|
+
if (offscreen && typeof target.scrollIntoView === "function") {
|
|
2345
|
+
target.scrollIntoView({ block: "center", inline: "nearest" })
|
|
2346
|
+
}
|
|
2347
|
+
|
|
2348
|
+
postMessageToParent({
|
|
2349
|
+
type: "ELEMENT_SELECTED",
|
|
2350
|
+
metadata: extractMetadata(target),
|
|
2351
|
+
})
|
|
2352
|
+
publishSelectionToDesignMode()
|
|
2353
|
+
}
|
|
2354
|
+
|
|
2286
2355
|
/**
|
|
2287
2356
|
* Bridge to design-mode store: publish current inspector selection as
|
|
2288
2357
|
* DND nodeIds so arrange overlay knows when to show resize handles +
|
|
@@ -5059,6 +5128,12 @@
|
|
|
5059
5128
|
metadata: metadata,
|
|
5060
5129
|
})
|
|
5061
5130
|
}
|
|
5131
|
+
} else if (
|
|
5132
|
+
event.data &&
|
|
5133
|
+
(event.data.type === "SELECT" ||
|
|
5134
|
+
event.data.type === "SELECT_ELEMENT_BY_VID")
|
|
5135
|
+
) {
|
|
5136
|
+
selectElementByVid(event.data.vid)
|
|
5062
5137
|
} else if (event.data && event.data.type === "HIDE_SELECTED_ELEMENT") {
|
|
5063
5138
|
if (selectedElement) {
|
|
5064
5139
|
deleteElementCleanup(selectedElement)
|
|
@@ -2139,6 +2139,10 @@
|
|
|
2139
2139
|
vidIdentity: true,
|
|
2140
2140
|
nodeMeta: true,
|
|
2141
2141
|
refusals: true,
|
|
2142
|
+
// Host -> runtime `SELECT {vid}` (alias `SELECT_ELEMENT_BY_VID`)
|
|
2143
|
+
// re-selects a node by its stamped `data-vid`, e.g. after the
|
|
2144
|
+
// iframe reloaded and lost the selection.
|
|
2145
|
+
selectByVid: true,
|
|
2142
2146
|
},
|
|
2143
2147
|
}
|
|
2144
2148
|
}
|
|
@@ -2198,9 +2202,27 @@
|
|
|
2198
2202
|
}
|
|
2199
2203
|
if (meta && meta.componentName) nodeMeta.component = meta.componentName
|
|
2200
2204
|
if (meta && meta.lockReason) nodeMeta.lockReason = meta.lockReason
|
|
2205
|
+
if (nodeMeta.isKitOrigin) {
|
|
2206
|
+
var usage = resolveScreenUsageMeta(el)
|
|
2207
|
+
if (usage && usage.vid !== vid) {
|
|
2208
|
+
nodeMeta.usageVid = usage.vid
|
|
2209
|
+
if (usage.file) nodeMeta.usageFile = usage.file
|
|
2210
|
+
}
|
|
2211
|
+
}
|
|
2201
2212
|
return nodeMeta
|
|
2202
2213
|
}
|
|
2203
2214
|
|
|
2215
|
+
// The nearest non-template meta above `el` (the screen-file usage of
|
|
2216
|
+
// the kit instance owning it) when it carries a valid vid, else null.
|
|
2217
|
+
function resolveScreenUsageMeta(el) {
|
|
2218
|
+
var owner = getUsageMetaOwnerFiberFromElement(el)
|
|
2219
|
+
var usage = owner && resolveEditorMetaValue(owner.memoizedProps.__editorMeta)
|
|
2220
|
+
if (usage && typeof usage.vid === "string" && VID_PATTERN.test(usage.vid)) {
|
|
2221
|
+
return usage
|
|
2222
|
+
}
|
|
2223
|
+
return null
|
|
2224
|
+
}
|
|
2225
|
+
|
|
2204
2226
|
/**
|
|
2205
2227
|
* Emit `REFUSED` (vid-identity migration) instead of letting a
|
|
2206
2228
|
* drag/drop the runtime's own policy would reject proceed silently —
|
|
@@ -2283,6 +2305,53 @@
|
|
|
2283
2305
|
var inspectorCleanupMap = new WeakMap()
|
|
2284
2306
|
var BADGE_UPDATE_DELAY_MS = 50
|
|
2285
2307
|
|
|
2308
|
+
// Host-driven selection by `data-vid`: same end state as a single
|
|
2309
|
+
// user click (styles, `selectedElements`, design-mode sync, an
|
|
2310
|
+
// `ELEMENT_SELECTED` carrying `extractMetadata`). Silent when the vid
|
|
2311
|
+
// is malformed or nothing renders it.
|
|
2312
|
+
function selectElementByVid(vid) {
|
|
2313
|
+
if (typeof vid !== "string" || !VID_PATTERN.test(vid)) return
|
|
2314
|
+
var target = safeQuerySelector('[data-vid="' + vid + '"]')
|
|
2315
|
+
if (!target || !isValidContentElement(target)) {
|
|
2316
|
+
inspectorLog("[Inspector] SELECT: no element for vid", vid)
|
|
2317
|
+
return
|
|
2318
|
+
}
|
|
2319
|
+
|
|
2320
|
+
removeHighlight()
|
|
2321
|
+
var previousSelection = selectedElements.slice()
|
|
2322
|
+
previousSelection.forEach(function (el) {
|
|
2323
|
+
removeInspectorStyles(el)
|
|
2324
|
+
cleanupElementListeners(el)
|
|
2325
|
+
})
|
|
2326
|
+
selectedElements = [target]
|
|
2327
|
+
selectedElement = target
|
|
2328
|
+
window._inspectorSelectedElement = target
|
|
2329
|
+
if (window.__ARCHIE_INSPECTOR__)
|
|
2330
|
+
window.__ARCHIE_INSPECTOR__.selectedElement = target
|
|
2331
|
+
isElementSelected = true
|
|
2332
|
+
|
|
2333
|
+
applyInspectorStyles(target)
|
|
2334
|
+
createSelectedBadge(target)
|
|
2335
|
+
updateSharedHighlights()
|
|
2336
|
+
setupBadgePositionListeners(target)
|
|
2337
|
+
|
|
2338
|
+
var rect = target.getBoundingClientRect()
|
|
2339
|
+
var offscreen =
|
|
2340
|
+
rect.bottom < 0 ||
|
|
2341
|
+
rect.right < 0 ||
|
|
2342
|
+
rect.top > window.innerHeight ||
|
|
2343
|
+
rect.left > window.innerWidth
|
|
2344
|
+
if (offscreen && typeof target.scrollIntoView === "function") {
|
|
2345
|
+
target.scrollIntoView({ block: "center", inline: "nearest" })
|
|
2346
|
+
}
|
|
2347
|
+
|
|
2348
|
+
postMessageToParent({
|
|
2349
|
+
type: "ELEMENT_SELECTED",
|
|
2350
|
+
metadata: extractMetadata(target),
|
|
2351
|
+
})
|
|
2352
|
+
publishSelectionToDesignMode()
|
|
2353
|
+
}
|
|
2354
|
+
|
|
2286
2355
|
/**
|
|
2287
2356
|
* Bridge to design-mode store: publish current inspector selection as
|
|
2288
2357
|
* DND nodeIds so arrange overlay knows when to show resize handles +
|
|
@@ -5059,6 +5128,12 @@
|
|
|
5059
5128
|
metadata: metadata,
|
|
5060
5129
|
})
|
|
5061
5130
|
}
|
|
5131
|
+
} else if (
|
|
5132
|
+
event.data &&
|
|
5133
|
+
(event.data.type === "SELECT" ||
|
|
5134
|
+
event.data.type === "SELECT_ELEMENT_BY_VID")
|
|
5135
|
+
) {
|
|
5136
|
+
selectElementByVid(event.data.vid)
|
|
5062
5137
|
} else if (event.data && event.data.type === "HIDE_SELECTED_ELEMENT") {
|
|
5063
5138
|
if (selectedElement) {
|
|
5064
5139
|
deleteElementCleanup(selectedElement)
|