@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.
Files changed (87) hide show
  1. package/dist/main/app/app.js +5 -25
  2. package/dist/main/app/native-overview.d.ts +27 -0
  3. package/dist/main/app/native-overview.js +44 -0
  4. package/dist/main/index.bundle.js +1217 -735
  5. package/dist/main/ipc/bridge-router.d.ts +8 -0
  6. package/dist/main/ipc/bridge-router.js +526 -173
  7. package/dist/main/ipc/project-fs.js +39 -21
  8. package/dist/main/services/automation/handlers/app.js +143 -109
  9. package/dist/main/services/console-forward/index.d.ts +12 -1
  10. package/dist/main/services/console-forward/index.js +99 -1
  11. package/dist/main/services/diagnostics/index.d.ts +49 -0
  12. package/dist/main/services/diagnostics/index.js +61 -0
  13. package/dist/main/services/mcp/tools/simulator-tools.js +118 -97
  14. package/dist/main/services/network-forward/dispatch-batch.d.ts +22 -0
  15. package/dist/main/services/network-forward/dispatch-batch.js +21 -0
  16. package/dist/main/services/network-forward/index.js +37 -20
  17. package/dist/main/services/notifications/renderer-notifier.d.ts +39 -0
  18. package/dist/main/services/notifications/renderer-notifier.js +4 -1
  19. package/dist/main/services/projects/create-project-service.js +54 -34
  20. package/dist/main/services/projects/project-repository.js +2 -1
  21. package/dist/main/services/projects/types.d.ts +1 -32
  22. package/dist/main/services/service-console/console-api.js +36 -27
  23. package/dist/main/services/simulator-temp-files/disk.js +109 -86
  24. package/dist/main/services/views/simulator-session-policy.js +17 -0
  25. package/dist/main/services/workbench-coi-server.js +58 -45
  26. package/dist/main/services/workbench-context.d.ts +10 -0
  27. package/dist/main/services/workspace/workspace-service.js +12 -3
  28. package/dist/main/utils/logger.d.ts +5 -12
  29. package/dist/main/utils/logger.js +5 -45
  30. package/dist/main/windows/service-host-window/create.d.ts +15 -1
  31. package/dist/main/windows/service-host-window/create.js +11 -3
  32. package/dist/preload/instrumentation/wxml-extract.js +94 -62
  33. package/dist/preload/runtime/main-api-runner.d.ts +1 -1
  34. package/dist/preload/shared/api-compat.js +18 -55
  35. package/dist/preload/windows/host-toolbar-runtime.cjs.map +2 -2
  36. package/dist/preload/windows/main.cjs +284 -565
  37. package/dist/preload/windows/main.cjs.map +2 -2
  38. package/dist/preload/windows/simulator.cjs +154 -83
  39. package/dist/preload/windows/simulator.cjs.map +3 -3
  40. package/dist/preload/windows/simulator.js +154 -83
  41. package/dist/render-host/render-inspect.js +63 -52
  42. package/dist/renderer/assets/index-BwzPwCmM.js +49 -0
  43. package/dist/renderer/assets/{input-Cjk0wSEh.js → input-CTb_le7F.js} +2 -2
  44. package/dist/renderer/assets/ipc-transport-BPWIV5hA.css +1 -0
  45. package/dist/renderer/assets/{ipc-transport-OZS-KmOW.js → ipc-transport-Ck5Xa8Tu.js} +2 -2
  46. package/dist/renderer/assets/popover-B1Zu2UQu.js +2 -0
  47. package/dist/renderer/assets/{select-BQDXi5ih.js → select-ozSk5Pt6.js} +2 -2
  48. package/dist/renderer/assets/{settings-tP3Px2KR.js → settings-CNwGOI22.js} +2 -2
  49. package/dist/renderer/assets/settings-api-DMbMp1Eq.js +2 -0
  50. package/dist/renderer/assets/workbenchSettings-Cr4EHo5w.js +8 -0
  51. package/dist/renderer/entries/main/index.html +6 -6
  52. package/dist/renderer/entries/popover/index.html +5 -5
  53. package/dist/renderer/entries/settings/index.html +5 -5
  54. package/dist/renderer/entries/workbench-settings/index.html +4 -4
  55. package/dist/shared/appdata-accumulator.js +53 -48
  56. package/dist/shared/bridge-channels.d.ts +22 -0
  57. package/dist/shared/ipc-channels.d.ts +3 -0
  58. package/dist/shared/ipc-channels.js +9 -0
  59. package/dist/shared/open-in-editor-resource-path.d.ts +56 -0
  60. package/dist/shared/open-in-editor-resource-path.js +133 -0
  61. package/dist/shared/open-in-editor.d.ts +2 -9
  62. package/dist/shared/open-in-editor.js +8 -93
  63. package/dist/shared/request-core.d.ts +84 -0
  64. package/dist/shared/request-core.js +168 -0
  65. package/dist/shared/simulator-api-metadata.d.ts +22 -17
  66. package/dist/shared/simulator-api-metadata.js +36 -0
  67. package/dist/shared/types.d.ts +20 -4
  68. package/dist/simulator/assets/{device-shell-CUl0ILfn.js → device-shell-C-wcFq3Z.js} +2 -2
  69. package/dist/simulator/assets/{jsx-runtime-CDK-o-S0.js → jsx-runtime-BDTY6fEq.js} +2 -2
  70. package/dist/simulator/assets/simulator-DU3-fS3v.js +10 -0
  71. package/dist/simulator/assets/simulator-mini-app-DzfMfnVM.js +2 -0
  72. package/dist/simulator/simulator.html +2 -2
  73. package/dist/vscode-workbench/assets/__vite-browser-external-CXi6Kz9W.js +1 -0
  74. package/dist/vscode-workbench/assets/{dist-CS7SQP3K.js → dist-TpGpmMGi.js} +3 -3
  75. package/dist/vscode-workbench/assets/{iconv-lite-umd-D3q-1-o6.js → iconv-lite-umd-C9tiCAJa.js} +1 -1
  76. package/dist/vscode-workbench/assets/{index-zjigpZ25.js → index-DJ1HyMZ7.js} +20 -22
  77. package/dist/vscode-workbench/assets/{jschardet-Cu4ufeHq.js → jschardet-DE1jV513.js} +1 -1
  78. package/dist/vscode-workbench/index.html +1 -1
  79. package/package.json +6 -6
  80. package/dist/renderer/assets/index-B-Dqb7G0.js +0 -49
  81. package/dist/renderer/assets/ipc-transport-D5dKIti1.css +0 -1
  82. package/dist/renderer/assets/popover-CQVvOe90.js +0 -2
  83. package/dist/renderer/assets/settings-api-B6x2mhaD.js +0 -2
  84. package/dist/renderer/assets/workbenchSettings-Bim9ol9R.js +0 -8
  85. package/dist/simulator/assets/simulator-Dz8iGcgy.js +0 -10
  86. package/dist/simulator/assets/simulator-mini-app-Bt639XL_.js +0 -2
  87. 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 decodeWorkerMessage(message) {
385
- let payload = message;
386
- if (typeof payload === "string") {
387
- try {
388
- payload = JSON.parse(payload);
389
- } catch {
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
- const body = record.body;
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
- let payload = message;
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
- const controller = new AbortController();
747
- const method = (opts.method || "GET").toUpperCase();
748
- let requestUrl = opts.url;
749
- const init = {
750
- method,
751
- headers: { "Content-Type": "application/json", ...opts.header || {} },
752
- signal: controller.signal
753
- };
754
- if (method === "GET" && opts.data && typeof opts.data === "object") {
755
- const url = new URL(requestUrl, window.location.href);
756
- Object.entries(opts.data).forEach(([key, value]) => {
757
- url.searchParams.append(key, String(value));
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
- const timeoutId = Number(opts.timeout) > 0 ? window.setTimeout(() => controller.abort(), Number(opts.timeout)) : null;
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() {