@dimina-kit/devtools 0.3.0 → 0.3.1-dev.20260515105504
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 +103 -41
- package/dist/main/api.d.ts +6 -2
- package/dist/main/api.js +5 -2
- package/dist/main/app/app.d.ts +1 -1
- package/dist/main/app/app.js +71 -36
- package/dist/main/app/launch.d.ts +2 -2
- package/dist/main/app/launch.js +6 -3
- package/dist/main/index.bundle.js +1134 -300
- package/dist/main/ipc/app.d.ts +2 -1
- package/dist/main/ipc/app.js +5 -4
- package/dist/main/ipc/index.d.ts +5 -4
- package/dist/main/ipc/index.js +5 -4
- package/dist/main/ipc/panels.d.ts +2 -1
- package/dist/main/ipc/panels.js +14 -9
- package/dist/main/ipc/popover.d.ts +4 -1
- package/dist/main/ipc/popover.js +15 -5
- package/dist/main/ipc/projects.d.ts +4 -1
- package/dist/main/ipc/projects.js +42 -5
- package/dist/main/ipc/session.d.ts +4 -1
- package/dist/main/ipc/session.js +26 -6
- package/dist/main/ipc/settings.d.ts +4 -1
- package/dist/main/ipc/settings.js +30 -17
- package/dist/main/ipc/simulator-module.d.ts +8 -0
- package/dist/main/ipc/simulator-module.js +19 -0
- package/dist/main/ipc/simulator.d.ts +2 -1
- package/dist/main/ipc/simulator.js +29 -15
- package/dist/main/ipc/toolbar.d.ts +2 -1
- package/dist/main/ipc/toolbar.js +3 -2
- package/dist/main/services/automation/index.js +88 -13
- package/dist/main/services/default-adapter.js +1 -3
- package/dist/main/services/mcp/server.d.ts +2 -1
- package/dist/main/services/mcp/server.js +5 -0
- package/dist/main/services/module.d.ts +18 -0
- package/dist/main/services/module.js +2 -0
- package/dist/main/services/notifications/renderer-notifier.d.ts +2 -0
- package/dist/main/services/projects/project-repository.d.ts +1 -0
- package/dist/main/services/projects/project-repository.js +3 -0
- package/dist/main/services/settings/index.d.ts +4 -0
- package/dist/main/services/settings/index.js +12 -1
- package/dist/main/services/simulator/custom-apis.d.ts +10 -0
- package/dist/main/services/simulator/custom-apis.js +26 -0
- package/dist/main/services/simulator/dir.d.ts +1 -1
- package/dist/main/services/simulator/dir.js +1 -4
- package/dist/main/services/simulator-storage/index.d.ts +22 -1
- package/dist/main/services/simulator-storage/index.js +390 -84
- package/dist/main/services/update/update-manager.d.ts +16 -1
- package/dist/main/services/update/update-manager.js +18 -15
- package/dist/main/services/views/view-manager.d.ts +4 -0
- package/dist/main/services/views/view-manager.js +33 -2
- package/dist/main/services/window-service.d.ts +24 -0
- package/dist/main/services/window-service.js +26 -0
- package/dist/main/services/workbench-context.d.ts +15 -0
- package/dist/main/services/workbench-context.js +6 -0
- package/dist/main/services/workspace/workspace-service.d.ts +1 -0
- package/dist/main/services/workspace/workspace-service.js +7 -3
- package/dist/main/simulator-apis.d.ts +23 -0
- package/dist/main/simulator-apis.js +24 -0
- package/dist/main/utils/disposable.d.ts +13 -0
- package/dist/main/utils/disposable.js +60 -0
- package/dist/main/utils/ipc-registry.d.ts +39 -0
- package/dist/main/utils/ipc-registry.js +109 -0
- package/dist/main/utils/ipc-schema.d.ts +28 -0
- package/dist/main/utils/ipc-schema.js +38 -0
- package/dist/main/utils/paths.d.ts +8 -0
- package/dist/main/utils/paths.js +33 -4
- package/dist/main/utils/sender-policy.d.ts +23 -0
- package/dist/main/utils/sender-policy.js +42 -0
- package/dist/main/windows/main-window/create.d.ts +6 -0
- package/dist/main/windows/main-window/create.js +65 -9
- package/dist/main/windows/main-window/events.d.ts +2 -1
- package/dist/main/windows/main-window/events.js +25 -2
- package/dist/main/windows/navigation-hardening.d.ts +24 -0
- package/dist/main/windows/navigation-hardening.js +55 -0
- package/dist/main/windows/settings-window/create.js +11 -1
- package/dist/preload/index.d.ts +17 -0
- package/dist/preload/index.js +17 -0
- package/dist/preload/instrumentation/app-data.js +178 -19
- package/dist/preload/instrumentation/wxml-extract.js +134 -3
- package/dist/preload/runtime/bridge.d.ts +3 -1
- package/dist/preload/runtime/bridge.js +55 -4
- package/dist/preload/runtime/custom-apis.d.ts +6 -0
- package/dist/preload/runtime/custom-apis.js +18 -0
- package/dist/preload/runtime/host.d.ts +1 -0
- package/dist/preload/runtime/host.js +13 -0
- package/dist/preload/shared/types.d.ts +2 -1
- package/dist/preload/windows/main.cjs +47 -0
- package/dist/preload/windows/main.cjs.map +7 -0
- package/dist/preload/windows/simulator.js +274 -25
- package/dist/renderer/assets/index-DW_0thr-.js +46 -0
- package/dist/renderer/assets/{input-VLotwer2.js → input-C5M5Wxn6.js} +2 -2
- package/dist/renderer/assets/{ipc-transport-COKIC6Ny.js → ipc-transport-CUsl-fS2.js} +6 -6
- package/dist/renderer/assets/ipc-transport-CltRuvhi.css +1 -0
- package/dist/renderer/assets/{popover-Dn0RwMLI.js → popover-BSBPVO0o.js} +2 -2
- package/dist/renderer/assets/{select-DzIsLaKX.js → select-B1tF3UAc.js} +2 -2
- package/dist/renderer/assets/{settings-CD-dacWB.js → settings-7w54H6p-.js} +2 -2
- package/dist/renderer/assets/settings-api-BjJalghB.js +2 -0
- package/dist/renderer/assets/workbenchSettings-q2_-nc8t.js +8 -0
- package/dist/renderer/entries/main/index.html +12 -5
- package/dist/renderer/entries/popover/index.html +7 -5
- package/dist/renderer/entries/settings/index.html +7 -5
- package/dist/renderer/entries/workbench-settings/index.html +6 -4
- package/dist/shared/ipc-channels.d.ts +45 -0
- package/dist/shared/ipc-channels.js +28 -0
- package/dist/shared/ipc-schemas.d.ts +113 -0
- package/dist/shared/ipc-schemas.js +128 -0
- package/dist/shared/types.d.ts +2 -0
- package/dist/simulator/assets/simulator-DL6kOCq-.js +9 -0
- package/dist/simulator/simulator.html +1 -1
- package/package.json +11 -27
- package/dist/preload/windows/main.d.ts +0 -6
- package/dist/preload/windows/main.js +0 -6
- package/dist/renderer/assets/index-D_HFRqZA.js +0 -46
- package/dist/renderer/assets/ipc-transport-6Gy3FXIL.css +0 -1
- package/dist/renderer/assets/settings-api-BV9MPckG.js +0 -2
- package/dist/renderer/assets/workbenchSettings-ClwgsvJL.js +0 -8
- package/dist/simulator/assets/simulator-C1eHXnuq.js +0 -9
|
@@ -10,6 +10,32 @@ var state = {
|
|
|
10
10
|
};
|
|
11
11
|
var highlightOverlay = null;
|
|
12
12
|
var exposedApi = null;
|
|
13
|
+
var SYNTHETIC_SID_PREFIX = "devtools-";
|
|
14
|
+
var syntheticSidByEl = /* @__PURE__ */ new WeakMap();
|
|
15
|
+
var elBySyntheticSid = /* @__PURE__ */ new Map();
|
|
16
|
+
var nextSyntheticSid = 1;
|
|
17
|
+
function registerSyntheticSid(el) {
|
|
18
|
+
const existing = syntheticSidByEl.get(el);
|
|
19
|
+
if (existing) return existing;
|
|
20
|
+
const synthetic = `${SYNTHETIC_SID_PREFIX}${nextSyntheticSid++}`;
|
|
21
|
+
syntheticSidByEl.set(el, synthetic);
|
|
22
|
+
elBySyntheticSid.set(synthetic, new WeakRef(el));
|
|
23
|
+
return synthetic;
|
|
24
|
+
}
|
|
25
|
+
function findElementBySid(doc, sid) {
|
|
26
|
+
if (sid.startsWith(SYNTHETIC_SID_PREFIX)) {
|
|
27
|
+
const ref = elBySyntheticSid.get(sid);
|
|
28
|
+
if (!ref) return null;
|
|
29
|
+
const el = ref.deref();
|
|
30
|
+
if (!el || !el.isConnected) {
|
|
31
|
+
elBySyntheticSid.delete(sid);
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
if (el.ownerDocument !== doc) return null;
|
|
35
|
+
return el;
|
|
36
|
+
}
|
|
37
|
+
return doc.querySelector(`[data-sid="${CSS.escape(sid)}"]`);
|
|
38
|
+
}
|
|
13
39
|
function clone(value) {
|
|
14
40
|
try {
|
|
15
41
|
return JSON.parse(JSON.stringify(value));
|
|
@@ -25,16 +51,17 @@ function ensureOverlay(doc) {
|
|
|
25
51
|
if (highlightOverlay && highlightOverlay.ownerDocument === doc) return highlightOverlay;
|
|
26
52
|
highlightOverlay = doc.createElement("div");
|
|
27
53
|
highlightOverlay.id = "__simulator-highlight";
|
|
28
|
-
highlightOverlay.style.cssText = "position:fixed;pointer-events:none;z-index:999999;border:2px solid #1a73e8;background:rgba(26,115,232,0.12);transition:all 0.1s ease;display:none;border-radius:2px;";
|
|
54
|
+
highlightOverlay.style.cssText = "position:fixed;pointer-events:none;z-index:999999;border:2px solid #1a73e8;background:rgba(26,115,232,0.12);transition:all 0.1s ease;display:none;border-radius:2px;box-sizing:border-box;";
|
|
29
55
|
doc.body.appendChild(highlightOverlay);
|
|
30
56
|
return highlightOverlay;
|
|
31
57
|
}
|
|
32
58
|
function highlightElement(sid) {
|
|
59
|
+
if (!sid) return null;
|
|
33
60
|
const iframe = getPageIframe();
|
|
34
|
-
if (!iframe?.contentDocument) return;
|
|
61
|
+
if (!iframe?.contentDocument) return null;
|
|
35
62
|
const doc = iframe.contentDocument;
|
|
36
|
-
const el = doc
|
|
37
|
-
if (!el) return;
|
|
63
|
+
const el = findElementBySid(doc, sid);
|
|
64
|
+
if (!el) return null;
|
|
38
65
|
const rect = el.getBoundingClientRect();
|
|
39
66
|
const overlay = ensureOverlay(doc);
|
|
40
67
|
overlay.style.left = `${rect.left}px`;
|
|
@@ -42,6 +69,22 @@ function highlightElement(sid) {
|
|
|
42
69
|
overlay.style.width = `${rect.width}px`;
|
|
43
70
|
overlay.style.height = `${rect.height}px`;
|
|
44
71
|
overlay.style.display = "block";
|
|
72
|
+
const style = el.ownerDocument.defaultView?.getComputedStyle(el);
|
|
73
|
+
if (!style) return null;
|
|
74
|
+
return {
|
|
75
|
+
sid,
|
|
76
|
+
rect: { x: rect.x, y: rect.y, width: rect.width, height: rect.height },
|
|
77
|
+
style: {
|
|
78
|
+
display: style.display,
|
|
79
|
+
position: style.position,
|
|
80
|
+
boxSizing: style.boxSizing,
|
|
81
|
+
margin: style.margin,
|
|
82
|
+
padding: style.padding,
|
|
83
|
+
color: style.color,
|
|
84
|
+
backgroundColor: style.backgroundColor,
|
|
85
|
+
fontSize: style.fontSize
|
|
86
|
+
}
|
|
87
|
+
};
|
|
45
88
|
}
|
|
46
89
|
function unhighlightElement() {
|
|
47
90
|
if (highlightOverlay) highlightOverlay.style.display = "none";
|
|
@@ -130,6 +173,9 @@ function installSimulatorBridge() {
|
|
|
130
173
|
};
|
|
131
174
|
}
|
|
132
175
|
|
|
176
|
+
// src/preload/runtime/custom-apis.ts
|
|
177
|
+
var import_electron2 = require("electron");
|
|
178
|
+
|
|
133
179
|
// src/shared/ipc-channels.ts
|
|
134
180
|
var SimulatorChannel = {
|
|
135
181
|
Attach: "simulator:attach",
|
|
@@ -141,11 +187,48 @@ var SimulatorChannel = {
|
|
|
141
187
|
AppData: "simulator:appdata",
|
|
142
188
|
AppDataAll: "simulator:appdata-all"
|
|
143
189
|
};
|
|
190
|
+
var SimulatorCustomApiChannel = {
|
|
191
|
+
List: "simulator:custom-apis:list",
|
|
192
|
+
Invoke: "simulator:custom-apis:invoke"
|
|
193
|
+
};
|
|
194
|
+
var BridgeChannel = {
|
|
195
|
+
WxmlRefreshRequest: "wxml:refresh:request",
|
|
196
|
+
AppDataGetAllRequest: "appdata:getAll:request",
|
|
197
|
+
AppDataGetAllResponse: "appdata:getAll:response"
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
// src/preload/runtime/custom-apis.ts
|
|
201
|
+
function buildBridge() {
|
|
202
|
+
return {
|
|
203
|
+
list: () => import_electron2.ipcRenderer.invoke(SimulatorCustomApiChannel.List),
|
|
204
|
+
invoke: (name, params) => import_electron2.ipcRenderer.invoke(SimulatorCustomApiChannel.Invoke, name, params)
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
function installCustomApisBridge() {
|
|
208
|
+
const bridge = buildBridge();
|
|
209
|
+
try {
|
|
210
|
+
import_electron2.contextBridge.exposeInMainWorld("__diminaCustomApis", bridge);
|
|
211
|
+
} catch {
|
|
212
|
+
window.__diminaCustomApis = bridge;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
144
215
|
|
|
145
216
|
// src/preload/runtime/host.ts
|
|
146
|
-
var
|
|
217
|
+
var import_electron3 = require("electron");
|
|
147
218
|
function sendToHost(channel, data) {
|
|
148
|
-
|
|
219
|
+
import_electron3.ipcRenderer.sendToHost(channel, data);
|
|
220
|
+
}
|
|
221
|
+
function onHostMessage(channel, handler) {
|
|
222
|
+
let active = true;
|
|
223
|
+
const wrapped = (_event, ...args) => {
|
|
224
|
+
if (!active) return;
|
|
225
|
+
handler(...args);
|
|
226
|
+
};
|
|
227
|
+
import_electron3.ipcRenderer.on(channel, wrapped);
|
|
228
|
+
return () => {
|
|
229
|
+
active = false;
|
|
230
|
+
import_electron3.ipcRenderer.removeListener(channel, wrapped);
|
|
231
|
+
};
|
|
149
232
|
}
|
|
150
233
|
function safeSerialize(val) {
|
|
151
234
|
if (val === null || val === void 0) return val;
|
|
@@ -229,13 +312,46 @@ function createDisposableSet() {
|
|
|
229
312
|
|
|
230
313
|
// src/preload/instrumentation/app-data.ts
|
|
231
314
|
var appDataCache = /* @__PURE__ */ new Map();
|
|
315
|
+
var bridgeOrder = [];
|
|
316
|
+
var bridgePagePath = /* @__PURE__ */ new Map();
|
|
317
|
+
function recordBridge(bridgeId) {
|
|
318
|
+
if (!bridgeOrder.includes(bridgeId)) bridgeOrder.push(bridgeId);
|
|
319
|
+
}
|
|
320
|
+
function buildSnapshot() {
|
|
321
|
+
const bridges = [];
|
|
322
|
+
for (const id of bridgeOrder) {
|
|
323
|
+
bridges.push({ id, pagePath: bridgePagePath.get(id) ?? null });
|
|
324
|
+
}
|
|
325
|
+
const entries = {};
|
|
326
|
+
for (const [key, entry] of appDataCache) {
|
|
327
|
+
const slash = key.indexOf("/");
|
|
328
|
+
if (slash < 0) continue;
|
|
329
|
+
const bridgeId = key.slice(0, slash);
|
|
330
|
+
const moduleId = key.slice(slash + 1);
|
|
331
|
+
if (!entries[bridgeId]) entries[bridgeId] = {};
|
|
332
|
+
const displayKey = entry.componentPath ?? moduleId;
|
|
333
|
+
entries[bridgeId][displayKey] = entry.data;
|
|
334
|
+
}
|
|
335
|
+
return { bridges, entries };
|
|
336
|
+
}
|
|
232
337
|
function publishSnapshot() {
|
|
233
338
|
const data = {};
|
|
234
|
-
for (const [key,
|
|
235
|
-
data[key] =
|
|
339
|
+
for (const [key, entry] of appDataCache) {
|
|
340
|
+
data[key] = entry.data;
|
|
236
341
|
}
|
|
237
342
|
setAppDataSnapshot(data);
|
|
238
343
|
}
|
|
344
|
+
function clearBridge(bridgeId) {
|
|
345
|
+
const prefix = `${bridgeId}/`;
|
|
346
|
+
for (const key of [...appDataCache.keys()]) {
|
|
347
|
+
if (key.startsWith(prefix)) appDataCache.delete(key);
|
|
348
|
+
}
|
|
349
|
+
const idx = bridgeOrder.indexOf(bridgeId);
|
|
350
|
+
if (idx >= 0) bridgeOrder.splice(idx, 1);
|
|
351
|
+
bridgePagePath.delete(bridgeId);
|
|
352
|
+
publishSnapshot();
|
|
353
|
+
sendToHost(SimulatorChannel.AppDataAll, buildSnapshot());
|
|
354
|
+
}
|
|
239
355
|
function decodeWorkerMessage(message) {
|
|
240
356
|
let payload = message;
|
|
241
357
|
if (typeof payload === "string") {
|
|
@@ -245,9 +361,61 @@ function decodeWorkerMessage(message) {
|
|
|
245
361
|
return null;
|
|
246
362
|
}
|
|
247
363
|
}
|
|
364
|
+
if (!payload || typeof payload !== "object") return null;
|
|
248
365
|
const record = payload;
|
|
249
|
-
if (record
|
|
250
|
-
|
|
366
|
+
if (record.type === "ub") {
|
|
367
|
+
const body = record.body;
|
|
368
|
+
if (!body || typeof body !== "object") return null;
|
|
369
|
+
if (typeof body.bridgeId !== "string" || !Array.isArray(body.updates)) return null;
|
|
370
|
+
const out = [];
|
|
371
|
+
for (const u of body.updates) {
|
|
372
|
+
if (!u || typeof u.moduleId !== "string") continue;
|
|
373
|
+
if (!u.moduleId.startsWith("page_")) continue;
|
|
374
|
+
out.push({ mode: "patch", bridgeId: body.bridgeId, moduleId: u.moduleId, data: u.data });
|
|
375
|
+
}
|
|
376
|
+
return out.length > 0 ? out : null;
|
|
377
|
+
}
|
|
378
|
+
if (typeof record.type === "string" && record.type.startsWith("page_")) {
|
|
379
|
+
const body = record.body;
|
|
380
|
+
if (!body || typeof body !== "object") return null;
|
|
381
|
+
if (typeof body.bridgeId !== "string" || typeof body.path !== "string") return null;
|
|
382
|
+
if (!body.data || typeof body.data !== "object") return null;
|
|
383
|
+
return [{
|
|
384
|
+
mode: "init",
|
|
385
|
+
bridgeId: body.bridgeId,
|
|
386
|
+
moduleId: record.type,
|
|
387
|
+
componentPath: body.path,
|
|
388
|
+
data: body.data
|
|
389
|
+
}];
|
|
390
|
+
}
|
|
391
|
+
return null;
|
|
392
|
+
}
|
|
393
|
+
function decodeOutgoingMessage(message) {
|
|
394
|
+
let payload = message;
|
|
395
|
+
if (typeof payload === "string") {
|
|
396
|
+
try {
|
|
397
|
+
payload = JSON.parse(payload);
|
|
398
|
+
} catch {
|
|
399
|
+
return null;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
if (!payload || typeof payload !== "object") return null;
|
|
403
|
+
const r = payload;
|
|
404
|
+
if (typeof r.type !== "string") return null;
|
|
405
|
+
return {
|
|
406
|
+
type: r.type,
|
|
407
|
+
bridgeId: typeof r.body?.bridgeId === "string" ? r.body.bridgeId : void 0
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
function instrumentPostMessage(worker) {
|
|
411
|
+
const orig = worker.postMessage.bind(worker);
|
|
412
|
+
worker.postMessage = function(msg, ...rest) {
|
|
413
|
+
const decoded = decodeOutgoingMessage(msg);
|
|
414
|
+
if (decoded?.type === "pageUnload" && decoded.bridgeId) {
|
|
415
|
+
clearBridge(decoded.bridgeId);
|
|
416
|
+
}
|
|
417
|
+
return orig(msg, ...rest);
|
|
418
|
+
};
|
|
251
419
|
}
|
|
252
420
|
function createInstrumentedWorker(OriginalWorker) {
|
|
253
421
|
function InstrumentedWorker(scriptURL, options) {
|
|
@@ -257,14 +425,20 @@ function createInstrumentedWorker(OriginalWorker) {
|
|
|
257
425
|
[resolvedScriptURL, options],
|
|
258
426
|
new.target ?? InstrumentedWorker
|
|
259
427
|
);
|
|
428
|
+
instrumentPostMessage(worker);
|
|
260
429
|
worker.addEventListener("message", (event) => {
|
|
261
|
-
const
|
|
262
|
-
if (!
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
430
|
+
const entries = decodeWorkerMessage(event.data);
|
|
431
|
+
if (!entries) return;
|
|
432
|
+
for (const entry of entries) {
|
|
433
|
+
const hookBody = {
|
|
434
|
+
bridgeId: entry.bridgeId,
|
|
435
|
+
moduleId: entry.moduleId,
|
|
436
|
+
data: entry.data,
|
|
437
|
+
mode: entry.mode
|
|
438
|
+
};
|
|
439
|
+
if (entry.mode === "init") hookBody.componentPath = entry.componentPath;
|
|
440
|
+
window.__simulatorHook?.appData(hookBody);
|
|
441
|
+
}
|
|
268
442
|
});
|
|
269
443
|
return worker;
|
|
270
444
|
}
|
|
@@ -282,12 +456,27 @@ function installAppDataInstrumentation() {
|
|
|
282
456
|
window.__simulatorHook = {
|
|
283
457
|
appData: (body) => {
|
|
284
458
|
const record = body;
|
|
285
|
-
if (record?.bridgeId
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
459
|
+
if (!record?.bridgeId || !record?.moduleId) return;
|
|
460
|
+
if (record.mode !== "init" && !bridgePagePath.has(record.bridgeId)) return;
|
|
461
|
+
const key = `${record.bridgeId}/${record.moduleId}`;
|
|
462
|
+
const prev = appDataCache.get(key);
|
|
463
|
+
const incoming = record.data && typeof record.data === "object" ? record.data : {};
|
|
464
|
+
const merged = record.mode === "init" ? { ...incoming } : { ...prev?.data ?? {}, ...incoming };
|
|
465
|
+
const componentPath = record.componentPath ?? prev?.componentPath;
|
|
466
|
+
const next = componentPath !== void 0 ? { componentPath, data: merged } : { data: merged };
|
|
467
|
+
appDataCache.set(key, next);
|
|
468
|
+
recordBridge(record.bridgeId);
|
|
469
|
+
if (record.mode === "init" && record.moduleId.startsWith("page_") && record.componentPath) {
|
|
470
|
+
bridgePagePath.set(record.bridgeId, record.componentPath);
|
|
289
471
|
}
|
|
290
|
-
|
|
472
|
+
publishSnapshot();
|
|
473
|
+
const payload = {
|
|
474
|
+
bridgeId: record.bridgeId,
|
|
475
|
+
moduleId: record.moduleId,
|
|
476
|
+
data: merged
|
|
477
|
+
};
|
|
478
|
+
if (componentPath !== void 0) payload.componentPath = componentPath;
|
|
479
|
+
sendToHost(SimulatorChannel.AppData, payload);
|
|
291
480
|
}
|
|
292
481
|
};
|
|
293
482
|
Object.defineProperty(window, "Worker", {
|
|
@@ -295,6 +484,9 @@ function installAppDataInstrumentation() {
|
|
|
295
484
|
writable: true,
|
|
296
485
|
value: createInstrumentedWorker(OriginalWorker)
|
|
297
486
|
});
|
|
487
|
+
disposables2.add(
|
|
488
|
+
onHostMessage(BridgeChannel.AppDataGetAllRequest, () => sendAllAppData())
|
|
489
|
+
);
|
|
298
490
|
publishSnapshot();
|
|
299
491
|
disposables2.add(() => {
|
|
300
492
|
if (originalDescriptor) {
|
|
@@ -312,6 +504,8 @@ function installAppDataInstrumentation() {
|
|
|
312
504
|
});
|
|
313
505
|
disposables2.add(() => {
|
|
314
506
|
appDataCache.clear();
|
|
507
|
+
bridgeOrder.length = 0;
|
|
508
|
+
bridgePagePath.clear();
|
|
315
509
|
clearAppDataSnapshot();
|
|
316
510
|
publishSnapshot();
|
|
317
511
|
});
|
|
@@ -319,6 +513,10 @@ function installAppDataInstrumentation() {
|
|
|
319
513
|
disposables2.disposeAll();
|
|
320
514
|
};
|
|
321
515
|
}
|
|
516
|
+
function sendAllAppData() {
|
|
517
|
+
publishSnapshot();
|
|
518
|
+
sendToHost(SimulatorChannel.AppDataAll, buildSnapshot());
|
|
519
|
+
}
|
|
322
520
|
|
|
323
521
|
// src/preload/shared/constants.ts
|
|
324
522
|
var WXML_DEBOUNCE_MS = 300;
|
|
@@ -356,9 +554,22 @@ function resolveTemplateNameFromParent(instance) {
|
|
|
356
554
|
}
|
|
357
555
|
return null;
|
|
358
556
|
}
|
|
557
|
+
function pascalToKebab(name) {
|
|
558
|
+
return name.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
559
|
+
}
|
|
560
|
+
function resolvePagePath(instance) {
|
|
561
|
+
const proxy = instance.proxy;
|
|
562
|
+
if (proxy?.__page__ !== true) return null;
|
|
563
|
+
const provides = instance.provides;
|
|
564
|
+
const path = provides?.path;
|
|
565
|
+
if (typeof path !== "string" || !path) return null;
|
|
566
|
+
return path.startsWith("/") ? path.slice(1) : path;
|
|
567
|
+
}
|
|
359
568
|
function resolveTagName(instance) {
|
|
360
569
|
const type = instance.type;
|
|
361
570
|
if (!type) return "unknown";
|
|
571
|
+
const pagePath = resolvePagePath(instance);
|
|
572
|
+
if (pagePath) return pagePath;
|
|
362
573
|
if (typeof type.__tagName === "string") return type.__tagName;
|
|
363
574
|
const name = type.__name || type.name;
|
|
364
575
|
if (!name) {
|
|
@@ -368,7 +579,8 @@ function resolveTagName(instance) {
|
|
|
368
579
|
}
|
|
369
580
|
if (name === "dd-page") return "page";
|
|
370
581
|
if (name.startsWith("dd-")) return name.slice(3);
|
|
371
|
-
if (name.startsWith("Dd") && name.length > 2) return name.slice(2)
|
|
582
|
+
if (name.startsWith("Dd") && name.length > 2) return pascalToKebab(name.slice(2));
|
|
583
|
+
if (/^[A-Z]/.test(name)) return pascalToKebab(name);
|
|
372
584
|
return name;
|
|
373
585
|
}
|
|
374
586
|
function extractProps(instance) {
|
|
@@ -398,7 +610,10 @@ function isInternalElement(vnode) {
|
|
|
398
610
|
function getElementSid(instance) {
|
|
399
611
|
const subTree = instance.subTree;
|
|
400
612
|
const el = subTree?.el;
|
|
401
|
-
|
|
613
|
+
if (!el?.getAttribute) return void 0;
|
|
614
|
+
const sid = el.getAttribute("data-sid");
|
|
615
|
+
if (sid) return sid;
|
|
616
|
+
return registerSyntheticSid(el);
|
|
402
617
|
}
|
|
403
618
|
function isTransparentComponent(instance, tagName) {
|
|
404
619
|
if (tagName === "unknown") return true;
|
|
@@ -413,8 +628,17 @@ function isTransparentComponent(instance, tagName) {
|
|
|
413
628
|
}
|
|
414
629
|
return false;
|
|
415
630
|
}
|
|
631
|
+
function isCommentVNode(vnode) {
|
|
632
|
+
const type = vnode.type;
|
|
633
|
+
if (typeof type !== "symbol") return false;
|
|
634
|
+
const desc = type.description;
|
|
635
|
+
if (desc === "Comment" || desc === "v-cmt") return true;
|
|
636
|
+
const children = typeof vnode.children === "string" ? vnode.children : "";
|
|
637
|
+
return /^v-(if|else|else-if|for)$/.test(children);
|
|
638
|
+
}
|
|
416
639
|
function extractChildrenFromVNode(vnode, depth) {
|
|
417
640
|
if (!vnode || depth > 50) return [];
|
|
641
|
+
if (isCommentVNode(vnode)) return [];
|
|
418
642
|
if (vnode.component) {
|
|
419
643
|
const result2 = walkInstance(vnode.component, depth + 1);
|
|
420
644
|
return result2 ? Array.isArray(result2) ? result2 : [result2] : [];
|
|
@@ -465,6 +689,30 @@ function extractChildrenFromVNode(vnode, depth) {
|
|
|
465
689
|
}
|
|
466
690
|
return result;
|
|
467
691
|
}
|
|
692
|
+
function unwrapCustomComponent(node) {
|
|
693
|
+
if (node.tagName !== "wrapper") return node;
|
|
694
|
+
const path = node.attrs?.name;
|
|
695
|
+
if (typeof path !== "string" || !path.startsWith("/")) return node;
|
|
696
|
+
const stripped = path.replace(/^\//, "");
|
|
697
|
+
const withoutIndex = stripped.endsWith("/index") ? stripped.slice(0, -"/index".length) : stripped;
|
|
698
|
+
const recovered = withoutIndex || stripped;
|
|
699
|
+
if (!recovered || recovered === "index") return node;
|
|
700
|
+
const nextAttrs = {};
|
|
701
|
+
for (const [k, v] of Object.entries(node.attrs)) {
|
|
702
|
+
if (k === "name") continue;
|
|
703
|
+
nextAttrs[k] = v;
|
|
704
|
+
}
|
|
705
|
+
return { ...node, tagName: recovered, attrs: nextAttrs };
|
|
706
|
+
}
|
|
707
|
+
function wrapInShadowRoot(node) {
|
|
708
|
+
if (!node.tagName.includes("/")) return node;
|
|
709
|
+
if (node.children.length === 0) return node;
|
|
710
|
+
if (node.children[0]?.tagName === "#shadow-root") return node;
|
|
711
|
+
return {
|
|
712
|
+
...node,
|
|
713
|
+
children: [{ tagName: "#shadow-root", attrs: {}, children: node.children }]
|
|
714
|
+
};
|
|
715
|
+
}
|
|
468
716
|
function walkInstance(instance, depth) {
|
|
469
717
|
if (depth > 50) return null;
|
|
470
718
|
const tagName = resolveTagName(instance);
|
|
@@ -473,7 +721,7 @@ function walkInstance(instance, depth) {
|
|
|
473
721
|
const node = { tagName, attrs: extractProps(instance), children };
|
|
474
722
|
const sid = getElementSid(instance);
|
|
475
723
|
if (sid) node.sid = sid;
|
|
476
|
-
return node;
|
|
724
|
+
return wrapInShadowRoot(unwrapCustomComponent(node));
|
|
477
725
|
}
|
|
478
726
|
|
|
479
727
|
// src/preload/instrumentation/wxml.ts
|
|
@@ -855,6 +1103,7 @@ function setupApiCompatHook() {
|
|
|
855
1103
|
// src/preload/windows/simulator.ts
|
|
856
1104
|
setupApiCompatHook();
|
|
857
1105
|
installSimulatorBridge();
|
|
1106
|
+
installCustomApisBridge();
|
|
858
1107
|
installConsoleInstrumentation();
|
|
859
1108
|
installAppDataInstrumentation();
|
|
860
1109
|
installWxmlInstrumentation();
|