@dimina-kit/devtools 0.4.0-dev.20260710085051 → 0.4.0-dev.20260711062001
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/main/services/render-inspect/index.d.ts +1 -1
- package/dist/preload/instrumentation/wxml.js +1 -1
- package/dist/preload/runtime/bridge.d.ts +3 -3
- package/dist/preload/runtime/bridge.js +2 -2
- package/dist/preload/windows/host-toolbar-runtime.cjs.map +2 -2
- package/dist/preload/windows/simulator.cjs +12 -4
- package/dist/preload/windows/simulator.cjs.map +3 -3
- package/dist/preload/windows/simulator.js +12 -4
- package/dist/render-host/render-inspect.js +189 -88
- package/dist/renderer/assets/index-WbvXdhWQ.js +49 -0
- package/dist/renderer/assets/{input-CTb_le7F.js → input-COtRON-n.js} +2 -2
- package/dist/renderer/assets/{ipc-transport-BPWIV5hA.css → ipc-transport-CNvORIEX.css} +1 -1
- package/dist/renderer/assets/{ipc-transport-Ck5Xa8Tu.js → ipc-transport-SuI2rOB_.js} +1 -1
- package/dist/renderer/assets/{popover-B1Zu2UQu.js → popover-B73T3z-m.js} +2 -2
- package/dist/renderer/assets/{select-ozSk5Pt6.js → select-Bwb8O0Mf.js} +2 -2
- package/dist/renderer/assets/{settings-CNwGOI22.js → settings-BispnvJU.js} +2 -2
- package/dist/renderer/assets/{settings-api-DMbMp1Eq.js → settings-api-HIBz8BFz.js} +2 -2
- package/dist/renderer/assets/{workbenchSettings-C6w5S2ZY.js → workbenchSettings-CtRBr7gS.js} +2 -2
- package/dist/renderer/entries/main/index.html +6 -6
- package/dist/renderer/entries/popover/index.html +5 -5
- package/dist/renderer/entries/settings/index.html +5 -5
- package/dist/renderer/entries/workbench-settings/index.html +4 -4
- package/dist/shared/ipc-channels.d.ts +2 -44
- package/package.json +5 -4
- package/dist/preload/instrumentation/wxml-extract.d.ts +0 -11
- package/dist/preload/instrumentation/wxml-extract.js +0 -382
- package/dist/preload/shared/sid-registry.d.ts +0 -11
- package/dist/preload/shared/sid-registry.js +0 -38
- package/dist/renderer/assets/index-BjCKGJDg.js +0 -49
|
@@ -30,22 +30,30 @@ function getActivePageIframe() {
|
|
|
30
30
|
return iframes.length > 0 ? iframes[iframes.length - 1] : null;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
//
|
|
33
|
+
// ../inspect/dist/sid-registry.js
|
|
34
34
|
var SYNTHETIC_SID_PREFIX = "devtools-";
|
|
35
35
|
var elBySyntheticSid = /* @__PURE__ */ new Map();
|
|
36
36
|
function findElementBySid(doc, sid) {
|
|
37
37
|
if (sid.startsWith(SYNTHETIC_SID_PREFIX)) {
|
|
38
38
|
const ref = elBySyntheticSid.get(sid);
|
|
39
|
-
if (!ref)
|
|
39
|
+
if (!ref)
|
|
40
|
+
return null;
|
|
40
41
|
const el = ref.deref();
|
|
41
42
|
if (!el || !el.isConnected) {
|
|
42
43
|
elBySyntheticSid.delete(sid);
|
|
43
44
|
return null;
|
|
44
45
|
}
|
|
45
|
-
if (el.ownerDocument !== doc)
|
|
46
|
+
if (el.ownerDocument !== doc)
|
|
47
|
+
return null;
|
|
46
48
|
return el;
|
|
47
49
|
}
|
|
48
|
-
return doc.querySelector(`[data-sid="${
|
|
50
|
+
return doc.querySelector(`[data-sid="${escapeForAttrSelector(sid)}"]`);
|
|
51
|
+
}
|
|
52
|
+
function escapeForAttrSelector(value) {
|
|
53
|
+
const impl = globalThis.CSS?.escape;
|
|
54
|
+
if (impl)
|
|
55
|
+
return impl(value);
|
|
56
|
+
return value.replace(/[\\"]/g, "\\$&");
|
|
49
57
|
}
|
|
50
58
|
|
|
51
59
|
// src/preload/runtime/bridge.ts
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
(() => {
|
|
3
|
-
//
|
|
3
|
+
// ../inspect/dist/sid-registry.js
|
|
4
4
|
var SYNTHETIC_SID_PREFIX = "devtools-";
|
|
5
5
|
var syntheticSidByEl = /* @__PURE__ */ new WeakMap();
|
|
6
6
|
var elBySyntheticSid = /* @__PURE__ */ new Map();
|
|
7
7
|
var nextSyntheticSid = 1;
|
|
8
8
|
function registerSyntheticSid(el) {
|
|
9
9
|
const existing = syntheticSidByEl.get(el);
|
|
10
|
-
if (existing)
|
|
10
|
+
if (existing)
|
|
11
|
+
return existing;
|
|
11
12
|
const synthetic = `${SYNTHETIC_SID_PREFIX}${nextSyntheticSid++}`;
|
|
12
13
|
syntheticSidByEl.set(el, synthetic);
|
|
13
14
|
elBySyntheticSid.set(synthetic, new WeakRef(el));
|
|
@@ -16,19 +17,27 @@
|
|
|
16
17
|
function findElementBySid(doc, sid) {
|
|
17
18
|
if (sid.startsWith(SYNTHETIC_SID_PREFIX)) {
|
|
18
19
|
const ref = elBySyntheticSid.get(sid);
|
|
19
|
-
if (!ref)
|
|
20
|
+
if (!ref)
|
|
21
|
+
return null;
|
|
20
22
|
const el = ref.deref();
|
|
21
23
|
if (!el || !el.isConnected) {
|
|
22
24
|
elBySyntheticSid.delete(sid);
|
|
23
25
|
return null;
|
|
24
26
|
}
|
|
25
|
-
if (el.ownerDocument !== doc)
|
|
27
|
+
if (el.ownerDocument !== doc)
|
|
28
|
+
return null;
|
|
26
29
|
return el;
|
|
27
30
|
}
|
|
28
|
-
return doc.querySelector(`[data-sid="${
|
|
31
|
+
return doc.querySelector(`[data-sid="${escapeForAttrSelector(sid)}"]`);
|
|
32
|
+
}
|
|
33
|
+
function escapeForAttrSelector(value) {
|
|
34
|
+
const impl = globalThis.CSS?.escape;
|
|
35
|
+
if (impl)
|
|
36
|
+
return impl(value);
|
|
37
|
+
return value.replace(/[\\"]/g, "\\$&");
|
|
29
38
|
}
|
|
30
39
|
|
|
31
|
-
//
|
|
40
|
+
// ../inspect/dist/wxml-extract.js
|
|
32
41
|
var INTERNAL_CLASSES = /* @__PURE__ */ new Set([
|
|
33
42
|
"dd-swiper-wrapper",
|
|
34
43
|
"dd-swiper-slides",
|
|
@@ -50,13 +59,16 @@
|
|
|
50
59
|
const components = parentType?.components;
|
|
51
60
|
if (components) {
|
|
52
61
|
for (const [regName, comp] of Object.entries(components)) {
|
|
53
|
-
if (comp === instance.type)
|
|
62
|
+
if (comp === instance.type)
|
|
63
|
+
return normalizeRegisteredName(regName);
|
|
54
64
|
}
|
|
55
65
|
}
|
|
56
66
|
const appComponents = instance.appContext?.components;
|
|
57
|
-
if (!appComponents)
|
|
67
|
+
if (!appComponents)
|
|
68
|
+
return null;
|
|
58
69
|
for (const [regName, comp] of Object.entries(appComponents)) {
|
|
59
|
-
if (comp === instance.type)
|
|
70
|
+
if (comp === instance.type)
|
|
71
|
+
return normalizeRegisteredName(regName);
|
|
60
72
|
}
|
|
61
73
|
return null;
|
|
62
74
|
}
|
|
@@ -65,43 +77,58 @@
|
|
|
65
77
|
}
|
|
66
78
|
function resolvePagePath(instance) {
|
|
67
79
|
const proxy = instance.proxy;
|
|
68
|
-
if (proxy?.__page__ !== true)
|
|
80
|
+
if (proxy?.__page__ !== true)
|
|
81
|
+
return null;
|
|
69
82
|
const provides = instance.provides;
|
|
70
83
|
const path = provides?.path;
|
|
71
|
-
if (typeof path !== "string" || !path)
|
|
84
|
+
if (typeof path !== "string" || !path)
|
|
85
|
+
return null;
|
|
72
86
|
return path.startsWith("/") ? path.slice(1) : path;
|
|
73
87
|
}
|
|
74
88
|
function resolveComponentPath(instance) {
|
|
75
89
|
const provides = instance.provides;
|
|
76
90
|
const path = provides?.path;
|
|
77
|
-
if (typeof path !== "string" || !path)
|
|
91
|
+
if (typeof path !== "string" || !path)
|
|
92
|
+
return null;
|
|
78
93
|
const parent = instance.parent;
|
|
79
94
|
const parentProvides = parent?.provides;
|
|
80
|
-
if (path === parentProvides?.path)
|
|
95
|
+
if (path === parentProvides?.path)
|
|
96
|
+
return null;
|
|
81
97
|
return path.startsWith("/") ? path.slice(1) : path;
|
|
82
98
|
}
|
|
83
99
|
function resolveTagName(instance) {
|
|
84
100
|
const type = instance.type;
|
|
85
|
-
if (!type)
|
|
101
|
+
if (!type)
|
|
102
|
+
return "unknown";
|
|
86
103
|
const pagePath = resolvePagePath(instance);
|
|
87
|
-
if (pagePath)
|
|
104
|
+
if (pagePath)
|
|
105
|
+
return pagePath;
|
|
88
106
|
const componentPath = resolveComponentPath(instance);
|
|
89
|
-
if (componentPath)
|
|
90
|
-
|
|
107
|
+
if (componentPath)
|
|
108
|
+
return componentPath;
|
|
109
|
+
if (typeof type.__tagName === "string")
|
|
110
|
+
return type.__tagName;
|
|
91
111
|
const name = type.__name || type.name;
|
|
92
112
|
if (!name) {
|
|
93
|
-
if (type.__scopeId)
|
|
113
|
+
if (type.__scopeId)
|
|
114
|
+
return resolveTemplateNameFromParent(instance) || "template";
|
|
94
115
|
return "unknown";
|
|
95
116
|
}
|
|
96
|
-
if (name === "dd-page")
|
|
97
|
-
|
|
98
|
-
if (name.startsWith("
|
|
99
|
-
|
|
117
|
+
if (name === "dd-page")
|
|
118
|
+
return "page";
|
|
119
|
+
if (name.startsWith("dd-"))
|
|
120
|
+
return name.slice(3);
|
|
121
|
+
if (name.startsWith("Dd") && name.length > 2)
|
|
122
|
+
return pascalToKebab(name.slice(2));
|
|
123
|
+
if (/^[A-Z]/.test(name))
|
|
124
|
+
return pascalToKebab(name);
|
|
100
125
|
return name;
|
|
101
126
|
}
|
|
102
127
|
function isSkippedProp(key, value) {
|
|
103
|
-
if (typeof value === "function" || value === void 0)
|
|
104
|
-
|
|
128
|
+
if (typeof value === "function" || value === void 0)
|
|
129
|
+
return true;
|
|
130
|
+
if (key === "data" || key.startsWith("__"))
|
|
131
|
+
return true;
|
|
105
132
|
return typeof value === "boolean" && !value;
|
|
106
133
|
}
|
|
107
134
|
function cleanClassAttr(value) {
|
|
@@ -111,10 +138,12 @@
|
|
|
111
138
|
return typeof value === "object" ? JSON.stringify(value) : String(value);
|
|
112
139
|
}
|
|
113
140
|
function assignProp(out, key, value) {
|
|
114
|
-
if (isSkippedProp(key, value))
|
|
141
|
+
if (isSkippedProp(key, value))
|
|
142
|
+
return;
|
|
115
143
|
if (key === "class" && typeof value === "string") {
|
|
116
144
|
const cleaned = cleanClassAttr(value);
|
|
117
|
-
if (cleaned)
|
|
145
|
+
if (cleaned)
|
|
146
|
+
out[key] = cleaned;
|
|
118
147
|
return;
|
|
119
148
|
}
|
|
120
149
|
out[key] = stringifyPropValue(value);
|
|
@@ -122,7 +151,8 @@
|
|
|
122
151
|
function extractProps(instance) {
|
|
123
152
|
const out = {};
|
|
124
153
|
for (const raw of [instance.props, instance.attrs]) {
|
|
125
|
-
if (!raw)
|
|
154
|
+
if (!raw)
|
|
155
|
+
continue;
|
|
126
156
|
for (const [k, v] of Object.entries(raw)) {
|
|
127
157
|
assignProp(out, k, v);
|
|
128
158
|
}
|
|
@@ -131,37 +161,46 @@
|
|
|
131
161
|
}
|
|
132
162
|
function isInternalElement(vnode) {
|
|
133
163
|
const props = vnode.props;
|
|
134
|
-
if (!props)
|
|
164
|
+
if (!props)
|
|
165
|
+
return false;
|
|
135
166
|
const cls = String(props.class || "");
|
|
136
167
|
return cls.split(/\s+/).some((c) => INTERNAL_CLASSES.has(c));
|
|
137
168
|
}
|
|
138
169
|
function getElementSid(instance) {
|
|
139
170
|
const subTree = instance.subTree;
|
|
140
171
|
const el = subTree?.el;
|
|
141
|
-
if (!el?.getAttribute)
|
|
172
|
+
if (!el?.getAttribute)
|
|
173
|
+
return void 0;
|
|
142
174
|
const sid = el.getAttribute("data-sid");
|
|
143
|
-
if (sid)
|
|
175
|
+
if (sid)
|
|
176
|
+
return sid;
|
|
144
177
|
return registerSyntheticSid(el);
|
|
145
178
|
}
|
|
146
179
|
function isTransparentComponent(instance, tagName) {
|
|
147
|
-
if (tagName === "unknown")
|
|
148
|
-
|
|
180
|
+
if (tagName === "unknown")
|
|
181
|
+
return true;
|
|
182
|
+
if (FRAMEWORK_TEMPLATE_RE.test(tagName))
|
|
183
|
+
return true;
|
|
149
184
|
if (tagName === "template") {
|
|
150
185
|
const props = instance.props;
|
|
151
186
|
const is = props?.is;
|
|
152
|
-
if (is && FRAMEWORK_TEMPLATE_RE.test(is))
|
|
187
|
+
if (is && FRAMEWORK_TEMPLATE_RE.test(is))
|
|
188
|
+
return true;
|
|
153
189
|
if (!is) {
|
|
154
190
|
const type = instance.type;
|
|
155
|
-
if (type?.__scopeId && !type.components)
|
|
191
|
+
if (type?.__scopeId && !type.components)
|
|
192
|
+
return true;
|
|
156
193
|
}
|
|
157
194
|
}
|
|
158
195
|
return false;
|
|
159
196
|
}
|
|
160
197
|
function isCommentVNode(vnode) {
|
|
161
198
|
const type = vnode.type;
|
|
162
|
-
if (typeof type !== "symbol")
|
|
199
|
+
if (typeof type !== "symbol")
|
|
200
|
+
return false;
|
|
163
201
|
const desc = type.description;
|
|
164
|
-
if (desc === "Comment" || desc === "v-cmt")
|
|
202
|
+
if (desc === "Comment" || desc === "v-cmt")
|
|
203
|
+
return true;
|
|
165
204
|
const children = typeof vnode.children === "string" ? vnode.children : "";
|
|
166
205
|
return /^v-(if|else|else-if|for)$/.test(children);
|
|
167
206
|
}
|
|
@@ -170,7 +209,8 @@
|
|
|
170
209
|
}
|
|
171
210
|
function childrenFromComponentVNode(component, depth) {
|
|
172
211
|
const result = walkInstance(component, depth + 1);
|
|
173
|
-
if (!result)
|
|
212
|
+
if (!result)
|
|
213
|
+
return [];
|
|
174
214
|
return Array.isArray(result) ? result : [result];
|
|
175
215
|
}
|
|
176
216
|
function childrenFromSuspenseVNode(suspense, depth) {
|
|
@@ -178,9 +218,11 @@
|
|
|
178
218
|
return activeBranch ? extractChildrenFromVNode(activeBranch, depth + 1) : [];
|
|
179
219
|
}
|
|
180
220
|
function directTextChild(vnode) {
|
|
181
|
-
if (typeof vnode.children !== "string" || !vnode.children.trim())
|
|
221
|
+
if (typeof vnode.children !== "string" || !vnode.children.trim())
|
|
222
|
+
return null;
|
|
182
223
|
const vnodeType = vnode.type;
|
|
183
|
-
if (typeof vnodeType !== "symbol" && typeof vnodeType !== "string")
|
|
224
|
+
if (typeof vnodeType !== "symbol" && typeof vnodeType !== "string")
|
|
225
|
+
return null;
|
|
184
226
|
return [textNode(vnode.children.trim())];
|
|
185
227
|
}
|
|
186
228
|
function textChildEntry(child) {
|
|
@@ -188,29 +230,43 @@
|
|
|
188
230
|
return trimmed ? [textNode(trimmed)] : [];
|
|
189
231
|
}
|
|
190
232
|
function domTypedChildEntries(c, depth) {
|
|
191
|
-
if (isInternalElement(c))
|
|
192
|
-
|
|
233
|
+
if (isInternalElement(c))
|
|
234
|
+
return extractChildrenFromVNode(c, depth + 1);
|
|
235
|
+
if (typeof c.children === "string" && c.children.trim())
|
|
236
|
+
return [textNode(c.children.trim())];
|
|
193
237
|
return extractChildrenFromVNode(c, depth + 1);
|
|
194
238
|
}
|
|
195
239
|
function extractChildEntry(child, depth) {
|
|
196
|
-
if (!child)
|
|
197
|
-
|
|
198
|
-
if (typeof child
|
|
240
|
+
if (!child)
|
|
241
|
+
return [];
|
|
242
|
+
if (typeof child === "string")
|
|
243
|
+
return textChildEntry(child);
|
|
244
|
+
if (typeof child !== "object")
|
|
245
|
+
return [];
|
|
199
246
|
const c = child;
|
|
200
|
-
if (c.component)
|
|
201
|
-
|
|
202
|
-
if (typeof c.type === "
|
|
247
|
+
if (c.component)
|
|
248
|
+
return childrenFromComponentVNode(c.component, depth);
|
|
249
|
+
if (typeof c.type === "symbol")
|
|
250
|
+
return extractChildrenFromVNode(c, depth + 1);
|
|
251
|
+
if (typeof c.type === "string")
|
|
252
|
+
return domTypedChildEntries(c, depth);
|
|
203
253
|
return extractChildrenFromVNode(c, depth + 1);
|
|
204
254
|
}
|
|
205
255
|
function extractChildrenFromVNode(vnode, depth) {
|
|
206
|
-
if (!vnode || depth > 50)
|
|
207
|
-
|
|
208
|
-
if (
|
|
209
|
-
|
|
256
|
+
if (!vnode || depth > 50)
|
|
257
|
+
return [];
|
|
258
|
+
if (isCommentVNode(vnode))
|
|
259
|
+
return [];
|
|
260
|
+
if (vnode.component)
|
|
261
|
+
return childrenFromComponentVNode(vnode.component, depth);
|
|
262
|
+
if (vnode.suspense)
|
|
263
|
+
return childrenFromSuspenseVNode(vnode.suspense, depth);
|
|
210
264
|
const directText = directTextChild(vnode);
|
|
211
|
-
if (directText)
|
|
265
|
+
if (directText)
|
|
266
|
+
return directText;
|
|
212
267
|
const kids = vnode.children;
|
|
213
|
-
if (!Array.isArray(kids))
|
|
268
|
+
if (!Array.isArray(kids))
|
|
269
|
+
return [];
|
|
214
270
|
const result = [];
|
|
215
271
|
for (const child of kids) {
|
|
216
272
|
result.push(...extractChildEntry(child, depth));
|
|
@@ -218,50 +274,64 @@
|
|
|
218
274
|
return result;
|
|
219
275
|
}
|
|
220
276
|
function unwrapCustomComponent(node) {
|
|
221
|
-
if (node.tagName !== "wrapper")
|
|
277
|
+
if (node.tagName !== "wrapper")
|
|
278
|
+
return node;
|
|
222
279
|
const path = node.attrs?.name;
|
|
223
|
-
if (typeof path !== "string" || !path.startsWith("/"))
|
|
280
|
+
if (typeof path !== "string" || !path.startsWith("/"))
|
|
281
|
+
return node;
|
|
224
282
|
const stripped = path.replace(/^\//, "");
|
|
225
283
|
const withoutIndex = stripped.endsWith("/index") ? stripped.slice(0, -"/index".length) : stripped;
|
|
226
284
|
const recovered = withoutIndex || stripped;
|
|
227
|
-
if (!recovered || recovered === "index")
|
|
285
|
+
if (!recovered || recovered === "index")
|
|
286
|
+
return node;
|
|
228
287
|
const nextAttrs = {};
|
|
229
288
|
for (const [k, v] of Object.entries(node.attrs)) {
|
|
230
|
-
if (k === "name")
|
|
289
|
+
if (k === "name")
|
|
290
|
+
continue;
|
|
231
291
|
nextAttrs[k] = v;
|
|
232
292
|
}
|
|
233
293
|
return { ...node, tagName: recovered, attrs: nextAttrs };
|
|
234
294
|
}
|
|
235
295
|
function wrapInShadowRoot(node) {
|
|
236
|
-
if (!node.tagName.includes("/"))
|
|
237
|
-
|
|
238
|
-
if (node.children
|
|
296
|
+
if (!node.tagName.includes("/"))
|
|
297
|
+
return node;
|
|
298
|
+
if (node.children.length === 0)
|
|
299
|
+
return node;
|
|
300
|
+
if (node.children[0]?.tagName === "#shadow-root")
|
|
301
|
+
return node;
|
|
239
302
|
return {
|
|
240
303
|
...node,
|
|
241
304
|
children: [{ tagName: "#shadow-root", attrs: {}, children: node.children }]
|
|
242
305
|
};
|
|
243
306
|
}
|
|
244
307
|
function walkInstance(instance, depth) {
|
|
245
|
-
if (depth > 50)
|
|
308
|
+
if (depth > 50)
|
|
309
|
+
return null;
|
|
246
310
|
const tagName = resolveTagName(instance);
|
|
247
311
|
const children = extractChildrenFromVNode(instance.subTree, depth);
|
|
248
|
-
if (isTransparentComponent(instance, tagName))
|
|
312
|
+
if (isTransparentComponent(instance, tagName))
|
|
313
|
+
return children.length > 0 ? children : null;
|
|
249
314
|
const node = { tagName, attrs: extractProps(instance), children };
|
|
250
315
|
const sid = getElementSid(instance);
|
|
251
|
-
if (sid)
|
|
316
|
+
if (sid)
|
|
317
|
+
node.sid = sid;
|
|
252
318
|
return wrapInShadowRoot(unwrapCustomComponent(node));
|
|
253
319
|
}
|
|
254
320
|
|
|
255
|
-
//
|
|
256
|
-
var
|
|
257
|
-
|
|
258
|
-
|
|
321
|
+
// ../inspect/dist/inspector.js
|
|
322
|
+
var DEFAULT_DEBOUNCE_MS = 200;
|
|
323
|
+
function createWxmlInspector(options = {}) {
|
|
324
|
+
const doc = options.document ?? globalThis.document;
|
|
325
|
+
const debounceMs = options.debounceMs ?? DEFAULT_DEBOUNCE_MS;
|
|
326
|
+
const onMutated = options.onMutated;
|
|
259
327
|
const getVueApp = () => {
|
|
260
328
|
try {
|
|
261
|
-
const body =
|
|
329
|
+
const body = doc?.body;
|
|
262
330
|
const app = body?.__vue_app__;
|
|
263
|
-
if (!app)
|
|
264
|
-
|
|
331
|
+
if (!app)
|
|
332
|
+
return null;
|
|
333
|
+
if (app._instance)
|
|
334
|
+
return app._instance;
|
|
265
335
|
const container = app._container;
|
|
266
336
|
const vnode = container?._vnode;
|
|
267
337
|
return vnode?.component ?? null;
|
|
@@ -271,21 +341,26 @@
|
|
|
271
341
|
};
|
|
272
342
|
const getWxml = () => {
|
|
273
343
|
const instance = getVueApp();
|
|
274
|
-
if (!instance)
|
|
344
|
+
if (!instance)
|
|
345
|
+
return null;
|
|
275
346
|
const tree = walkInstance(instance, 0);
|
|
276
|
-
if (!tree)
|
|
347
|
+
if (!tree)
|
|
348
|
+
return null;
|
|
277
349
|
return Array.isArray(tree) ? { tagName: "#fragment", attrs: {}, children: tree } : tree;
|
|
278
350
|
};
|
|
279
351
|
const elementFor = (sid) => {
|
|
280
|
-
if (!sid)
|
|
281
|
-
|
|
352
|
+
if (!sid)
|
|
353
|
+
return null;
|
|
354
|
+
return findElementBySid(doc, sid);
|
|
282
355
|
};
|
|
283
356
|
const highlightElement = (sid) => {
|
|
284
357
|
const el = elementFor(sid);
|
|
285
|
-
if (!el)
|
|
358
|
+
if (!el)
|
|
359
|
+
return null;
|
|
286
360
|
const rect = el.getBoundingClientRect();
|
|
287
361
|
const style = el.ownerDocument.defaultView?.getComputedStyle(el);
|
|
288
|
-
if (!style)
|
|
362
|
+
if (!style)
|
|
363
|
+
return null;
|
|
289
364
|
return {
|
|
290
365
|
sid,
|
|
291
366
|
rect: { x: rect.x, y: rect.y, width: rect.width, height: rect.height },
|
|
@@ -301,32 +376,35 @@
|
|
|
301
376
|
}
|
|
302
377
|
};
|
|
303
378
|
};
|
|
304
|
-
const unhighlightElement = () => {
|
|
305
|
-
};
|
|
306
379
|
let observer = null;
|
|
307
380
|
let debounceTimer = null;
|
|
308
381
|
const notifyMutated = () => {
|
|
309
382
|
debounceTimer = null;
|
|
310
|
-
|
|
383
|
+
onMutated?.();
|
|
311
384
|
};
|
|
312
|
-
const
|
|
385
|
+
const setObserving = (on) => {
|
|
313
386
|
if (on) {
|
|
314
|
-
if (observer)
|
|
387
|
+
if (observer)
|
|
388
|
+
return;
|
|
315
389
|
observer = new MutationObserver(() => {
|
|
316
|
-
if (debounceTimer !== null)
|
|
317
|
-
|
|
390
|
+
if (debounceTimer !== null)
|
|
391
|
+
clearTimeout(debounceTimer);
|
|
392
|
+
debounceTimer = setTimeout(notifyMutated, debounceMs);
|
|
318
393
|
});
|
|
319
394
|
const begin = () => {
|
|
320
|
-
if (!observer || !
|
|
321
|
-
|
|
395
|
+
if (!observer || !doc.body)
|
|
396
|
+
return;
|
|
397
|
+
observer.observe(doc.body, {
|
|
322
398
|
childList: true,
|
|
323
399
|
subtree: true,
|
|
324
400
|
attributes: true,
|
|
325
401
|
characterData: true
|
|
326
402
|
});
|
|
327
403
|
};
|
|
328
|
-
if (
|
|
329
|
-
|
|
404
|
+
if (doc.body)
|
|
405
|
+
begin();
|
|
406
|
+
else
|
|
407
|
+
doc.addEventListener("DOMContentLoaded", begin, { once: true });
|
|
330
408
|
} else {
|
|
331
409
|
if (debounceTimer !== null) {
|
|
332
410
|
clearTimeout(debounceTimer);
|
|
@@ -336,6 +414,29 @@
|
|
|
336
414
|
observer = null;
|
|
337
415
|
}
|
|
338
416
|
};
|
|
339
|
-
|
|
417
|
+
return {
|
|
418
|
+
getWxml,
|
|
419
|
+
highlightElement,
|
|
420
|
+
elementFor,
|
|
421
|
+
setObserving,
|
|
422
|
+
dispose: () => setObserving(false)
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
// src/render-host/render-inspect.ts
|
|
427
|
+
var g = globalThis;
|
|
428
|
+
if (!g.__diminaRenderInspect) {
|
|
429
|
+
const inspector = createWxmlInspector({
|
|
430
|
+
onMutated: () => g.DiminaRenderBridge?.invoke({ type: "wxmlChanged", target: "container", body: {} })
|
|
431
|
+
});
|
|
432
|
+
const unhighlightElement = () => {
|
|
433
|
+
};
|
|
434
|
+
g.__diminaRenderInspect = {
|
|
435
|
+
getWxml: inspector.getWxml,
|
|
436
|
+
highlightElement: inspector.highlightElement,
|
|
437
|
+
elementFor: inspector.elementFor,
|
|
438
|
+
unhighlightElement,
|
|
439
|
+
setWxmlObserving: inspector.setObserving
|
|
440
|
+
};
|
|
340
441
|
}
|
|
341
442
|
})();
|