@dimina-kit/devtools 0.4.0-dev.20260702182435 → 0.4.0-dev.20260703101348
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/app/app.js +5 -25
- package/dist/main/app/native-overview.d.ts +27 -0
- package/dist/main/app/native-overview.js +44 -0
- package/dist/main/index.bundle.js +1217 -735
- package/dist/main/ipc/bridge-router.d.ts +8 -0
- package/dist/main/ipc/bridge-router.js +526 -173
- package/dist/main/ipc/project-fs.js +39 -21
- package/dist/main/services/automation/handlers/app.js +143 -109
- package/dist/main/services/console-forward/index.d.ts +12 -1
- package/dist/main/services/console-forward/index.js +99 -1
- package/dist/main/services/diagnostics/index.d.ts +49 -0
- package/dist/main/services/diagnostics/index.js +61 -0
- package/dist/main/services/mcp/tools/simulator-tools.js +118 -97
- package/dist/main/services/network-forward/dispatch-batch.d.ts +22 -0
- package/dist/main/services/network-forward/dispatch-batch.js +21 -0
- package/dist/main/services/network-forward/index.js +37 -20
- package/dist/main/services/notifications/renderer-notifier.d.ts +39 -0
- package/dist/main/services/notifications/renderer-notifier.js +4 -1
- package/dist/main/services/projects/create-project-service.js +54 -34
- package/dist/main/services/projects/project-repository.js +2 -1
- package/dist/main/services/projects/types.d.ts +1 -32
- package/dist/main/services/service-console/console-api.js +36 -27
- package/dist/main/services/simulator-temp-files/disk.js +109 -86
- package/dist/main/services/views/simulator-session-policy.js +17 -0
- package/dist/main/services/workbench-coi-server.js +58 -45
- package/dist/main/services/workbench-context.d.ts +10 -0
- package/dist/main/services/workspace/workspace-service.js +12 -3
- package/dist/main/utils/logger.d.ts +5 -12
- package/dist/main/utils/logger.js +5 -45
- package/dist/main/windows/service-host-window/create.d.ts +15 -1
- package/dist/main/windows/service-host-window/create.js +11 -3
- package/dist/preload/instrumentation/wxml-extract.js +94 -62
- package/dist/preload/runtime/main-api-runner.d.ts +1 -1
- package/dist/preload/shared/api-compat.js +18 -55
- package/dist/preload/windows/host-toolbar-runtime.cjs.map +2 -2
- package/dist/preload/windows/main.cjs +284 -565
- package/dist/preload/windows/main.cjs.map +2 -2
- package/dist/preload/windows/simulator.cjs +154 -83
- package/dist/preload/windows/simulator.cjs.map +3 -3
- package/dist/preload/windows/simulator.js +154 -83
- package/dist/render-host/render-inspect.js +63 -52
- package/dist/renderer/assets/index-BwzPwCmM.js +49 -0
- package/dist/renderer/assets/{input-Cjk0wSEh.js → input-CTb_le7F.js} +2 -2
- package/dist/renderer/assets/ipc-transport-BPWIV5hA.css +1 -0
- package/dist/renderer/assets/{ipc-transport-OZS-KmOW.js → ipc-transport-Ck5Xa8Tu.js} +2 -2
- package/dist/renderer/assets/popover-B1Zu2UQu.js +2 -0
- package/dist/renderer/assets/{select-BQDXi5ih.js → select-ozSk5Pt6.js} +2 -2
- package/dist/renderer/assets/{settings-tP3Px2KR.js → settings-CNwGOI22.js} +2 -2
- package/dist/renderer/assets/settings-api-DMbMp1Eq.js +2 -0
- package/dist/renderer/assets/workbenchSettings-Cr4EHo5w.js +8 -0
- 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/appdata-accumulator.js +53 -48
- package/dist/shared/bridge-channels.d.ts +22 -0
- package/dist/shared/ipc-channels.d.ts +3 -0
- package/dist/shared/ipc-channels.js +9 -0
- package/dist/shared/open-in-editor-resource-path.d.ts +56 -0
- package/dist/shared/open-in-editor-resource-path.js +133 -0
- package/dist/shared/open-in-editor.d.ts +2 -9
- package/dist/shared/open-in-editor.js +8 -93
- package/dist/shared/request-core.d.ts +84 -0
- package/dist/shared/request-core.js +168 -0
- package/dist/shared/simulator-api-metadata.d.ts +22 -17
- package/dist/shared/simulator-api-metadata.js +36 -0
- package/dist/shared/types.d.ts +20 -4
- package/dist/simulator/assets/{device-shell-CUl0ILfn.js → device-shell-C-wcFq3Z.js} +2 -2
- package/dist/simulator/assets/{jsx-runtime-CDK-o-S0.js → jsx-runtime-BDTY6fEq.js} +2 -2
- package/dist/simulator/assets/simulator-DU3-fS3v.js +10 -0
- package/dist/simulator/assets/simulator-mini-app-DzfMfnVM.js +2 -0
- package/dist/simulator/simulator.html +2 -2
- package/dist/vscode-workbench/assets/__vite-browser-external-CXi6Kz9W.js +1 -0
- package/dist/vscode-workbench/assets/{dist-CS7SQP3K.js → dist-TpGpmMGi.js} +3 -3
- package/dist/vscode-workbench/assets/{iconv-lite-umd-D3q-1-o6.js → iconv-lite-umd-C9tiCAJa.js} +1 -1
- package/dist/vscode-workbench/assets/{index-zjigpZ25.js → index-DJ1HyMZ7.js} +20 -22
- package/dist/vscode-workbench/assets/{jschardet-Cu4ufeHq.js → jschardet-DE1jV513.js} +1 -1
- package/dist/vscode-workbench/index.html +1 -1
- package/package.json +6 -6
- package/dist/renderer/assets/index-B-Dqb7G0.js +0 -49
- package/dist/renderer/assets/ipc-transport-D5dKIti1.css +0 -1
- package/dist/renderer/assets/popover-CQVvOe90.js +0 -2
- package/dist/renderer/assets/settings-api-B6x2mhaD.js +0 -2
- package/dist/renderer/assets/workbenchSettings-Bim9ol9R.js +0 -8
- package/dist/simulator/assets/simulator-Dz8iGcgy.js +0 -10
- package/dist/simulator/assets/simulator-mini-app-Bt639XL_.js +0 -2
- package/dist/vscode-workbench/assets/__vite-browser-external-B0DTNerG.js +0 -1
|
@@ -381,53 +381,51 @@ function installConsoleInstrumentation() {
|
|
|
381
381
|
}
|
|
382
382
|
|
|
383
383
|
// src/shared/appdata-accumulator.ts
|
|
384
|
-
function
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
return null;
|
|
391
|
-
}
|
|
384
|
+
function parseMessagePayload(message) {
|
|
385
|
+
if (typeof message !== "string") return message;
|
|
386
|
+
try {
|
|
387
|
+
return JSON.parse(message);
|
|
388
|
+
} catch {
|
|
389
|
+
return null;
|
|
392
390
|
}
|
|
391
|
+
}
|
|
392
|
+
function decodeUpdateBatchBody(rawBody) {
|
|
393
|
+
const body = rawBody;
|
|
394
|
+
if (!body || typeof body !== "object") return null;
|
|
395
|
+
if (typeof body.bridgeId !== "string" || !Array.isArray(body.updates)) return null;
|
|
396
|
+
const out = [];
|
|
397
|
+
for (const u of body.updates) {
|
|
398
|
+
if (!u || typeof u.moduleId !== "string") continue;
|
|
399
|
+
if (!u.moduleId.startsWith("page_")) continue;
|
|
400
|
+
out.push({ mode: "patch", bridgeId: body.bridgeId, moduleId: u.moduleId, data: u.data });
|
|
401
|
+
}
|
|
402
|
+
return out.length > 0 ? out : null;
|
|
403
|
+
}
|
|
404
|
+
function decodePageInitBody(moduleId, rawBody) {
|
|
405
|
+
const body = rawBody;
|
|
406
|
+
if (!body || typeof body !== "object") return null;
|
|
407
|
+
if (typeof body.bridgeId !== "string" || typeof body.path !== "string") return null;
|
|
408
|
+
if (!body.data || typeof body.data !== "object") return null;
|
|
409
|
+
return [{
|
|
410
|
+
mode: "init",
|
|
411
|
+
bridgeId: body.bridgeId,
|
|
412
|
+
moduleId,
|
|
413
|
+
componentPath: body.path,
|
|
414
|
+
data: body.data
|
|
415
|
+
}];
|
|
416
|
+
}
|
|
417
|
+
function decodeWorkerMessage(message) {
|
|
418
|
+
const payload = parseMessagePayload(message);
|
|
393
419
|
if (!payload || typeof payload !== "object") return null;
|
|
394
420
|
const record = payload;
|
|
395
|
-
if (record.type === "ub")
|
|
396
|
-
const body = record.body;
|
|
397
|
-
if (!body || typeof body !== "object") return null;
|
|
398
|
-
if (typeof body.bridgeId !== "string" || !Array.isArray(body.updates)) return null;
|
|
399
|
-
const out = [];
|
|
400
|
-
for (const u of body.updates) {
|
|
401
|
-
if (!u || typeof u.moduleId !== "string") continue;
|
|
402
|
-
if (!u.moduleId.startsWith("page_")) continue;
|
|
403
|
-
out.push({ mode: "patch", bridgeId: body.bridgeId, moduleId: u.moduleId, data: u.data });
|
|
404
|
-
}
|
|
405
|
-
return out.length > 0 ? out : null;
|
|
406
|
-
}
|
|
421
|
+
if (record.type === "ub") return decodeUpdateBatchBody(record.body);
|
|
407
422
|
if (typeof record.type === "string" && record.type.startsWith("page_")) {
|
|
408
|
-
|
|
409
|
-
if (!body || typeof body !== "object") return null;
|
|
410
|
-
if (typeof body.bridgeId !== "string" || typeof body.path !== "string") return null;
|
|
411
|
-
if (!body.data || typeof body.data !== "object") return null;
|
|
412
|
-
return [{
|
|
413
|
-
mode: "init",
|
|
414
|
-
bridgeId: body.bridgeId,
|
|
415
|
-
moduleId: record.type,
|
|
416
|
-
componentPath: body.path,
|
|
417
|
-
data: body.data
|
|
418
|
-
}];
|
|
423
|
+
return decodePageInitBody(record.type, record.body);
|
|
419
424
|
}
|
|
420
425
|
return null;
|
|
421
426
|
}
|
|
422
427
|
function decodeOutgoingMessage(message) {
|
|
423
|
-
|
|
424
|
-
if (typeof payload === "string") {
|
|
425
|
-
try {
|
|
426
|
-
payload = JSON.parse(payload);
|
|
427
|
-
} catch {
|
|
428
|
-
return null;
|
|
429
|
-
}
|
|
430
|
-
}
|
|
428
|
+
const payload = parseMessagePayload(message);
|
|
431
429
|
if (!payload || typeof payload !== "object") return null;
|
|
432
430
|
const r = payload;
|
|
433
431
|
if (typeof r.type !== "string") return null;
|
|
@@ -626,6 +624,108 @@ function createAppDataSource() {
|
|
|
626
624
|
};
|
|
627
625
|
}
|
|
628
626
|
|
|
627
|
+
// src/shared/request-core.ts
|
|
628
|
+
var DEFAULT_REQUEST_TIMEOUT_MS = 6e4;
|
|
629
|
+
var MAX_TIMEOUT_MS = 2147483647;
|
|
630
|
+
function resolveTimeoutBudgetMs(timeout) {
|
|
631
|
+
const t = Number(timeout);
|
|
632
|
+
return Number.isFinite(t) && t > 0 && t <= MAX_TIMEOUT_MS ? t : DEFAULT_REQUEST_TIMEOUT_MS;
|
|
633
|
+
}
|
|
634
|
+
function buildHeaders(header) {
|
|
635
|
+
const headers = new Headers();
|
|
636
|
+
for (const [key, value] of Object.entries(header ?? {})) {
|
|
637
|
+
if (value != null) headers.set(key, String(value));
|
|
638
|
+
}
|
|
639
|
+
if (!headers.has("content-type")) headers.set("content-type", "application/json");
|
|
640
|
+
return headers;
|
|
641
|
+
}
|
|
642
|
+
function appendQueryParams(url, data) {
|
|
643
|
+
const base = typeof location !== "undefined" ? location.href : void 0;
|
|
644
|
+
const resolved = new URL(url, base);
|
|
645
|
+
for (const [key, value] of Object.entries(data)) {
|
|
646
|
+
resolved.searchParams.append(key, String(value));
|
|
647
|
+
}
|
|
648
|
+
return resolved.toString();
|
|
649
|
+
}
|
|
650
|
+
function encodeBody(data, contentType) {
|
|
651
|
+
if (typeof data === "string") return data;
|
|
652
|
+
if (contentType.includes("application/x-www-form-urlencoded")) {
|
|
653
|
+
const form = new URLSearchParams();
|
|
654
|
+
for (const [key, value] of Object.entries(data)) {
|
|
655
|
+
form.append(key, String(value));
|
|
656
|
+
}
|
|
657
|
+
return form.toString();
|
|
658
|
+
}
|
|
659
|
+
return JSON.stringify(data);
|
|
660
|
+
}
|
|
661
|
+
async function decodeResponseData(response, dataType, responseType) {
|
|
662
|
+
if (responseType === "arraybuffer" || dataType === "arraybuffer") {
|
|
663
|
+
return response.arrayBuffer();
|
|
664
|
+
}
|
|
665
|
+
const text = await response.text();
|
|
666
|
+
if (dataType !== "json") return text;
|
|
667
|
+
try {
|
|
668
|
+
return JSON.parse(text);
|
|
669
|
+
} catch {
|
|
670
|
+
return text;
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
function performRequest(opts, callbacks) {
|
|
674
|
+
const method = (opts.method || "GET").toUpperCase();
|
|
675
|
+
const canHaveBody = method !== "GET" && method !== "HEAD";
|
|
676
|
+
const headers = buildHeaders(opts.header);
|
|
677
|
+
let url = opts.url;
|
|
678
|
+
const init = { method, headers };
|
|
679
|
+
if (!canHaveBody) {
|
|
680
|
+
if (opts.data && typeof opts.data === "object") {
|
|
681
|
+
url = appendQueryParams(url, opts.data);
|
|
682
|
+
}
|
|
683
|
+
} else if (opts.data != null) {
|
|
684
|
+
init.body = encodeBody(opts.data, headers.get("content-type") ?? "");
|
|
685
|
+
}
|
|
686
|
+
const controller = new AbortController();
|
|
687
|
+
init.signal = controller.signal;
|
|
688
|
+
let settled = false;
|
|
689
|
+
function settleSuccess(res) {
|
|
690
|
+
if (settled) return;
|
|
691
|
+
settled = true;
|
|
692
|
+
clearTimeout(timer);
|
|
693
|
+
callbacks.success?.(res);
|
|
694
|
+
callbacks.complete?.(res);
|
|
695
|
+
}
|
|
696
|
+
function settleFail(err) {
|
|
697
|
+
if (settled) return;
|
|
698
|
+
settled = true;
|
|
699
|
+
clearTimeout(timer);
|
|
700
|
+
callbacks.fail?.(err);
|
|
701
|
+
callbacks.complete?.(err);
|
|
702
|
+
}
|
|
703
|
+
const timeoutMs = resolveTimeoutBudgetMs(opts.timeout);
|
|
704
|
+
const timer = setTimeout(() => {
|
|
705
|
+
settleFail({ errMsg: "request:fail timeout" });
|
|
706
|
+
controller.abort();
|
|
707
|
+
}, timeoutMs);
|
|
708
|
+
const dataType = opts.dataType ?? "json";
|
|
709
|
+
const responseType = opts.responseType ?? "text";
|
|
710
|
+
fetch(url, init).then(async (response) => {
|
|
711
|
+
const header = {};
|
|
712
|
+
response.headers.forEach((value, key) => {
|
|
713
|
+
header[key] = value;
|
|
714
|
+
});
|
|
715
|
+
const data = await decodeResponseData(response, dataType, responseType);
|
|
716
|
+
settleSuccess({ data, statusCode: response.status, header, errMsg: "request:ok" });
|
|
717
|
+
}).catch((error) => {
|
|
718
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
719
|
+
settleFail({ errMsg: `request:fail ${reason || "network error"}` });
|
|
720
|
+
});
|
|
721
|
+
return {
|
|
722
|
+
abort() {
|
|
723
|
+
settleFail({ errMsg: "request:fail abort" });
|
|
724
|
+
controller.abort();
|
|
725
|
+
}
|
|
726
|
+
};
|
|
727
|
+
}
|
|
728
|
+
|
|
629
729
|
// src/preload/shared/api-compat.ts
|
|
630
730
|
function call(fn, payload) {
|
|
631
731
|
try {
|
|
@@ -742,51 +842,22 @@ function ensureWxApi(wx) {
|
|
|
742
842
|
};
|
|
743
843
|
}
|
|
744
844
|
if (typeof wx.request !== "function") {
|
|
745
|
-
wx.request = (opts) =>
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
requestUrl = url.toString();
|
|
760
|
-
} else if (opts.data != null) {
|
|
761
|
-
init.body = typeof opts.data === "string" ? opts.data : JSON.stringify(opts.data);
|
|
845
|
+
wx.request = (opts) => performRequest(
|
|
846
|
+
{
|
|
847
|
+
url: opts.url,
|
|
848
|
+
data: opts.data,
|
|
849
|
+
header: opts.header,
|
|
850
|
+
timeout: opts.timeout,
|
|
851
|
+
method: opts.method,
|
|
852
|
+
dataType: opts.dataType,
|
|
853
|
+
responseType: opts.responseType
|
|
854
|
+
},
|
|
855
|
+
{
|
|
856
|
+
success: (res) => call(opts.success, res),
|
|
857
|
+
fail: (err) => call(opts.fail, err),
|
|
858
|
+
complete: (res) => call(opts.complete, res)
|
|
762
859
|
}
|
|
763
|
-
|
|
764
|
-
fetch(requestUrl, init).then(async (response) => {
|
|
765
|
-
const headers = Object.fromEntries(response.headers.entries());
|
|
766
|
-
let data;
|
|
767
|
-
if (opts.dataType === "arraybuffer") data = await response.arrayBuffer();
|
|
768
|
-
else {
|
|
769
|
-
const text = await response.text();
|
|
770
|
-
if (opts.dataType === "text") data = text;
|
|
771
|
-
else {
|
|
772
|
-
try {
|
|
773
|
-
data = JSON.parse(text);
|
|
774
|
-
} catch {
|
|
775
|
-
data = text;
|
|
776
|
-
}
|
|
777
|
-
}
|
|
778
|
-
}
|
|
779
|
-
call(opts.success, { data, statusCode: response.status, header: headers, errMsg: "request:ok" });
|
|
780
|
-
}).catch((error) => {
|
|
781
|
-
call(opts.fail, { errMsg: `request:fail ${error instanceof Error ? error.message : String(error)}` });
|
|
782
|
-
}).finally(() => {
|
|
783
|
-
if (timeoutId != null) window.clearTimeout(timeoutId);
|
|
784
|
-
call(opts.complete, void 0);
|
|
785
|
-
});
|
|
786
|
-
return {
|
|
787
|
-
abort: () => controller.abort()
|
|
788
|
-
};
|
|
789
|
-
};
|
|
860
|
+
);
|
|
790
861
|
}
|
|
791
862
|
}
|
|
792
863
|
function setupApiCompatHook() {
|
|
@@ -99,20 +99,32 @@
|
|
|
99
99
|
if (/^[A-Z]/.test(name)) return pascalToKebab(name);
|
|
100
100
|
return name;
|
|
101
101
|
}
|
|
102
|
+
function isSkippedProp(key, value) {
|
|
103
|
+
if (typeof value === "function" || value === void 0) return true;
|
|
104
|
+
if (key === "data" || key.startsWith("__")) return true;
|
|
105
|
+
return typeof value === "boolean" && !value;
|
|
106
|
+
}
|
|
107
|
+
function cleanClassAttr(value) {
|
|
108
|
+
return value.split(/\s+/).filter((c) => !c.startsWith("dd-")).join(" ");
|
|
109
|
+
}
|
|
110
|
+
function stringifyPropValue(value) {
|
|
111
|
+
return typeof value === "object" ? JSON.stringify(value) : String(value);
|
|
112
|
+
}
|
|
113
|
+
function assignProp(out, key, value) {
|
|
114
|
+
if (isSkippedProp(key, value)) return;
|
|
115
|
+
if (key === "class" && typeof value === "string") {
|
|
116
|
+
const cleaned = cleanClassAttr(value);
|
|
117
|
+
if (cleaned) out[key] = cleaned;
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
out[key] = stringifyPropValue(value);
|
|
121
|
+
}
|
|
102
122
|
function extractProps(instance) {
|
|
103
123
|
const out = {};
|
|
104
124
|
for (const raw of [instance.props, instance.attrs]) {
|
|
105
125
|
if (!raw) continue;
|
|
106
126
|
for (const [k, v] of Object.entries(raw)) {
|
|
107
|
-
|
|
108
|
-
if (k === "data" || k.startsWith("__")) continue;
|
|
109
|
-
if (typeof v === "boolean" && !v) continue;
|
|
110
|
-
if (k === "class" && typeof v === "string") {
|
|
111
|
-
const cleaned = v.split(/\s+/).filter((c) => !c.startsWith("dd-")).join(" ");
|
|
112
|
-
if (cleaned) out[k] = cleaned;
|
|
113
|
-
continue;
|
|
114
|
-
}
|
|
115
|
-
out[k] = typeof v === "object" ? JSON.stringify(v) : String(v);
|
|
127
|
+
assignProp(out, k, v);
|
|
116
128
|
}
|
|
117
129
|
}
|
|
118
130
|
return out;
|
|
@@ -153,56 +165,55 @@
|
|
|
153
165
|
const children = typeof vnode.children === "string" ? vnode.children : "";
|
|
154
166
|
return /^v-(if|else|else-if|for)$/.test(children);
|
|
155
167
|
}
|
|
168
|
+
function textNode(text) {
|
|
169
|
+
return { tagName: "#text", attrs: {}, children: [], text };
|
|
170
|
+
}
|
|
171
|
+
function childrenFromComponentVNode(component, depth) {
|
|
172
|
+
const result = walkInstance(component, depth + 1);
|
|
173
|
+
if (!result) return [];
|
|
174
|
+
return Array.isArray(result) ? result : [result];
|
|
175
|
+
}
|
|
176
|
+
function childrenFromSuspenseVNode(suspense, depth) {
|
|
177
|
+
const activeBranch = suspense.activeBranch;
|
|
178
|
+
return activeBranch ? extractChildrenFromVNode(activeBranch, depth + 1) : [];
|
|
179
|
+
}
|
|
180
|
+
function directTextChild(vnode) {
|
|
181
|
+
if (typeof vnode.children !== "string" || !vnode.children.trim()) return null;
|
|
182
|
+
const vnodeType = vnode.type;
|
|
183
|
+
if (typeof vnodeType !== "symbol" && typeof vnodeType !== "string") return null;
|
|
184
|
+
return [textNode(vnode.children.trim())];
|
|
185
|
+
}
|
|
186
|
+
function textChildEntry(child) {
|
|
187
|
+
const trimmed = child.trim();
|
|
188
|
+
return trimmed ? [textNode(trimmed)] : [];
|
|
189
|
+
}
|
|
190
|
+
function domTypedChildEntries(c, depth) {
|
|
191
|
+
if (isInternalElement(c)) return extractChildrenFromVNode(c, depth + 1);
|
|
192
|
+
if (typeof c.children === "string" && c.children.trim()) return [textNode(c.children.trim())];
|
|
193
|
+
return extractChildrenFromVNode(c, depth + 1);
|
|
194
|
+
}
|
|
195
|
+
function extractChildEntry(child, depth) {
|
|
196
|
+
if (!child) return [];
|
|
197
|
+
if (typeof child === "string") return textChildEntry(child);
|
|
198
|
+
if (typeof child !== "object") return [];
|
|
199
|
+
const c = child;
|
|
200
|
+
if (c.component) return childrenFromComponentVNode(c.component, depth);
|
|
201
|
+
if (typeof c.type === "symbol") return extractChildrenFromVNode(c, depth + 1);
|
|
202
|
+
if (typeof c.type === "string") return domTypedChildEntries(c, depth);
|
|
203
|
+
return extractChildrenFromVNode(c, depth + 1);
|
|
204
|
+
}
|
|
156
205
|
function extractChildrenFromVNode(vnode, depth) {
|
|
157
206
|
if (!vnode || depth > 50) return [];
|
|
158
207
|
if (isCommentVNode(vnode)) return [];
|
|
159
|
-
if (vnode.component)
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
if (vnode.suspense) {
|
|
164
|
-
const suspense = vnode.suspense;
|
|
165
|
-
const activeBranch = suspense.activeBranch;
|
|
166
|
-
return activeBranch ? extractChildrenFromVNode(activeBranch, depth + 1) : [];
|
|
167
|
-
}
|
|
168
|
-
if (typeof vnode.children === "string" && vnode.children.trim()) {
|
|
169
|
-
const vnodeType = vnode.type;
|
|
170
|
-
if (typeof vnodeType === "symbol" || typeof vnodeType === "string") {
|
|
171
|
-
return [{ tagName: "#text", attrs: {}, children: [], text: vnode.children.trim() }];
|
|
172
|
-
}
|
|
173
|
-
}
|
|
208
|
+
if (vnode.component) return childrenFromComponentVNode(vnode.component, depth);
|
|
209
|
+
if (vnode.suspense) return childrenFromSuspenseVNode(vnode.suspense, depth);
|
|
210
|
+
const directText = directTextChild(vnode);
|
|
211
|
+
if (directText) return directText;
|
|
174
212
|
const kids = vnode.children;
|
|
175
213
|
if (!Array.isArray(kids)) return [];
|
|
176
214
|
const result = [];
|
|
177
215
|
for (const child of kids) {
|
|
178
|
-
|
|
179
|
-
if (typeof child === "string") {
|
|
180
|
-
const trimmed = child.trim();
|
|
181
|
-
if (trimmed) result.push({ tagName: "#text", attrs: {}, children: [], text: trimmed });
|
|
182
|
-
continue;
|
|
183
|
-
}
|
|
184
|
-
if (typeof child !== "object") continue;
|
|
185
|
-
const c = child;
|
|
186
|
-
if (c.component) {
|
|
187
|
-
const walked = walkInstance(c.component, depth + 1);
|
|
188
|
-
if (walked) result.push(...Array.isArray(walked) ? walked : [walked]);
|
|
189
|
-
continue;
|
|
190
|
-
}
|
|
191
|
-
if (typeof c.type === "symbol") {
|
|
192
|
-
result.push(...extractChildrenFromVNode(c, depth + 1));
|
|
193
|
-
continue;
|
|
194
|
-
}
|
|
195
|
-
if (typeof c.type === "string") {
|
|
196
|
-
if (isInternalElement(c)) {
|
|
197
|
-
result.push(...extractChildrenFromVNode(c, depth + 1));
|
|
198
|
-
} else if (typeof c.children === "string" && c.children.trim()) {
|
|
199
|
-
result.push({ tagName: "#text", attrs: {}, children: [], text: c.children.trim() });
|
|
200
|
-
} else {
|
|
201
|
-
result.push(...extractChildrenFromVNode(c, depth + 1));
|
|
202
|
-
}
|
|
203
|
-
continue;
|
|
204
|
-
}
|
|
205
|
-
result.push(...extractChildrenFromVNode(c, depth + 1));
|
|
216
|
+
result.push(...extractChildEntry(child, depth));
|
|
206
217
|
}
|
|
207
218
|
return result;
|
|
208
219
|
}
|