@dimina-kit/devtools 0.4.0-dev.20260729062524 → 0.4.0-dev.20260731100034

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 (91) hide show
  1. package/dist/main/app/app.js +7 -0
  2. package/dist/main/app/bootstrap.d.ts +8 -5
  3. package/dist/main/app/bootstrap.js +15 -15
  4. package/dist/main/index.bundle.js +2199 -5151
  5. package/dist/main/ipc/app-lifecycle.d.ts +1 -31
  6. package/dist/main/ipc/app-lifecycle.js +1 -53
  7. package/dist/main/ipc/bridge-router.d.ts +19 -152
  8. package/dist/main/ipc/bridge-router.js +28 -2186
  9. package/dist/main/ipc/page-scroll.d.ts +1 -13
  10. package/dist/main/ipc/page-scroll.js +1 -16
  11. package/dist/main/ipc/session-listener-bag.d.ts +1 -40
  12. package/dist/main/ipc/session-listener-bag.js +1 -39
  13. package/dist/main/services/console-forward/index.d.ts +1 -60
  14. package/dist/main/services/console-forward/index.js +1 -225
  15. package/dist/main/services/console-forward/internal-log.d.ts +1 -10
  16. package/dist/main/services/console-forward/internal-log.js +1 -22
  17. package/dist/main/services/diagnostics/index.d.ts +1 -58
  18. package/dist/main/services/diagnostics/index.js +1 -60
  19. package/dist/main/services/dimina-resource-server.d.ts +1 -6
  20. package/dist/main/services/dimina-resource-server.js +1 -98
  21. package/dist/main/services/network-forward/index.d.ts +15 -3
  22. package/dist/main/services/network-forward/index.js +30 -4
  23. package/dist/main/services/network-forward/websocket.d.ts +36 -0
  24. package/dist/main/services/network-forward/websocket.js +120 -0
  25. package/dist/main/services/service-host-pool/pool.d.ts +1 -196
  26. package/dist/main/services/service-host-pool/pool.js +1 -363
  27. package/dist/main/services/simulator/custom-apis.d.ts +1 -42
  28. package/dist/main/services/simulator/custom-apis.js +1 -46
  29. package/dist/main/services/simulator/referer.d.ts +1 -9
  30. package/dist/main/services/simulator/referer.js +1 -19
  31. package/dist/main/services/simulator-storage/service-storage-ops.d.ts +1 -39
  32. package/dist/main/services/simulator-storage/service-storage-ops.js +1 -66
  33. package/dist/main/services/simulator-temp-files/disk.d.ts +1 -54
  34. package/dist/main/services/simulator-temp-files/disk.js +1 -237
  35. package/dist/main/services/simulator-temp-files/fs-channels.d.ts +1 -68
  36. package/dist/main/services/simulator-temp-files/fs-channels.js +1 -107
  37. package/dist/main/services/simulator-temp-files/index.d.ts +1 -32
  38. package/dist/main/services/simulator-temp-files/index.js +1 -181
  39. package/dist/main/services/simulator-temp-files/request-handler.d.ts +1 -29
  40. package/dist/main/services/simulator-temp-files/request-handler.js +1 -177
  41. package/dist/main/services/simulator-temp-files/resolver.d.ts +1 -21
  42. package/dist/main/services/simulator-temp-files/resolver.js +1 -21
  43. package/dist/main/services/simulator-temp-files/store.d.ts +1 -13
  44. package/dist/main/services/simulator-temp-files/store.js +1 -23
  45. package/dist/main/services/views/miniapp-partition.d.ts +1 -89
  46. package/dist/main/services/views/miniapp-partition.js +1 -158
  47. package/dist/main/services/views/simulator-session-policy.d.ts +1 -27
  48. package/dist/main/services/views/simulator-session-policy.js +1 -98
  49. package/dist/main/services/workbench-context.d.ts +4 -1
  50. package/dist/main/services/workbench-context.js +17 -0
  51. package/dist/main/utils/ipc-registry.d.ts +21 -3
  52. package/dist/main/utils/ipc-registry.js +26 -23
  53. package/dist/main/utils/paths.d.ts +14 -0
  54. package/dist/main/utils/paths.js +14 -0
  55. package/dist/main/windows/service-host-window/create.d.ts +1 -92
  56. package/dist/main/windows/service-host-window/create.js +1 -154
  57. package/dist/native-host/render/render.js +51 -52
  58. package/dist/native-host/service/service.js +2 -2
  59. package/dist/preload/index.d.ts +2 -0
  60. package/dist/preload/index.js +1 -0
  61. package/dist/preload/runtime/clipboard.d.ts +6 -0
  62. package/dist/preload/runtime/clipboard.js +12 -0
  63. package/dist/preload/runtime/native-host.js +4 -10
  64. package/dist/preload/windows/host-toolbar-runtime.cjs.map +2 -2
  65. package/dist/preload/windows/main.cjs +46 -30
  66. package/dist/preload/windows/main.cjs.map +3 -3
  67. package/dist/preload/windows/simulator.cjs +83 -56
  68. package/dist/preload/windows/simulator.cjs.map +4 -4
  69. package/dist/preload/windows/simulator.js +83 -56
  70. package/dist/shared/bridge-channels.d.ts +1 -419
  71. package/dist/shared/bridge-channels.js +1 -89
  72. package/dist/shared/dmb-resource-url.d.ts +2 -0
  73. package/dist/shared/dmb-resource-url.js +2 -0
  74. package/dist/shared/ipc-channels.d.ts +2 -32
  75. package/dist/shared/ipc-channels.js +2 -5
  76. package/dist/shared/request-core.d.ts +1 -83
  77. package/dist/shared/request-core.js +1 -167
  78. package/dist/simulator/assets/device-shell-B03OuytR.js +2 -0
  79. package/dist/simulator/assets/{device-shell-BHz1v3Yo.css → device-shell-DbC5ccs8.css} +1 -1
  80. package/dist/simulator/assets/{simulator-DXraYerh.js → simulator-DpdXUf--.js} +5 -5
  81. package/dist/simulator/simulator.html +1 -1
  82. package/dist/simulator/temp-files.d.ts +29 -0
  83. package/dist/simulator/temp-files.js +79 -0
  84. package/dist/simulator/types.d.ts +43 -0
  85. package/dist/simulator/types.js +2 -0
  86. package/package.json +6 -5
  87. package/dist/shared/simulator-api-metadata.d.ts +0 -26
  88. package/dist/shared/simulator-api-metadata.js +0 -59
  89. package/dist/shared/vpath.d.ts +0 -42
  90. package/dist/shared/vpath.js +0 -105
  91. package/dist/simulator/assets/device-shell-CH_DMYaz.js +0 -2
@@ -341,6 +341,49 @@ function installSimulatorBridge() {
341
341
  // src/preload/runtime/custom-apis.ts
342
342
  var import_electron2 = require("electron");
343
343
 
344
+ // ../dimina-electron-runtime/dist/shared/bridge-channels.js
345
+ var BRIDGE_CHANNELS = {
346
+ SPAWN: "dmb:spawn",
347
+ DISPOSE: "dmb:dispose",
348
+ PAGE_OPEN: "dmb:page:open",
349
+ PAGE_CLOSE: "dmb:page:close",
350
+ PAGE_LIFECYCLE: "dmb:page:lifecycle",
351
+ NAV_CALLBACK: "dmb:nav:callback",
352
+ SERVICE_INVOKE: "dmb:service:invoke",
353
+ SERVICE_PUBLISH: "dmb:service:publish",
354
+ RENDER_INVOKE: "dmb:render:invoke",
355
+ RENDER_PUBLISH: "dmb:render:publish",
356
+ TO_SERVICE: "dmb:to-service",
357
+ TO_RENDER: "dmb:to-render",
358
+ SIMULATOR_API: "dmb:simulator-api",
359
+ /** simulator → main: ack of an API_CALL request (carries success/fail args). */
360
+ API_RESPONSE: "dmb:api:response",
361
+ /**
362
+ * simulator webview preload → main (sendSync): "is native-host mode on?".
363
+ * The guest preload can't read the launch `process.env`, so it asks main
364
+ * (which can) at install time. Reply is `e.returnValue = boolean`.
365
+ */
366
+ NATIVE_HOST_ENABLED: "dmb:native-host-enabled",
367
+ /**
368
+ * simulator (DeviceShell) → main: the visible top-of-stack page bridgeId.
369
+ * Main has no z-order concept — the active page lives only in DeviceShell's
370
+ * ShellState — so devtools panels / automation that must target "the current
371
+ * page's render webContents" resolve it through this signal. Fire-and-forget.
372
+ */
373
+ ACTIVE_PAGE: "dmb:active-page",
374
+ /**
375
+ * simulator (DeviceShell) → main: the FULL ordered page stack (bottom→top)
376
+ * whenever it changes. Main has no stack of its own (it only learns the
377
+ * active bridgeId via ACTIVE_PAGE), so automation's `App.getPageStack` needs
378
+ * this to report multi-page stacks. Fire-and-forget.
379
+ */
380
+ PAGE_STACK: "dmb:page-stack"
381
+ };
382
+ var SimulatorCustomApiBridgeChannel = {
383
+ Request: "simulator:custom-apis:bridge-request",
384
+ Response: "simulator:custom-apis:bridge-response"
385
+ };
386
+
344
387
  // src/shared/ipc-channels.ts
345
388
  var SimulatorChannel = {
346
389
  // Ask main to create the simulator as a top-level WebContentsView (so nested
@@ -365,10 +408,6 @@ var SimulatorChannel = {
365
408
  // string (same bare format as `getCurrentPagePath`), or '' when unknown.
366
409
  CurrentPage: "simulator:current-page"
367
410
  };
368
- var SimulatorCustomApiBridgeChannel = {
369
- Request: "simulator:custom-apis:bridge-request",
370
- Response: "simulator:custom-apis:bridge-response"
371
- };
372
411
 
373
412
  // src/preload/runtime/custom-apis.ts
374
413
  var LIST_RETRY_INTERVAL_MS = 150;
@@ -654,7 +693,7 @@ function createAppDataSource() {
654
693
  };
655
694
  }
656
695
 
657
- // src/shared/request-core.ts
696
+ // ../dimina-electron-runtime/dist/shared/request-core.js
658
697
  var DEFAULT_REQUEST_TIMEOUT_MS = 6e4;
659
698
  var MAX_TIMEOUT_MS = 2147483647;
660
699
  function resolveTimeoutBudgetMs(timeout) {
@@ -664,9 +703,11 @@ function resolveTimeoutBudgetMs(timeout) {
664
703
  function buildHeaders(header) {
665
704
  const headers = new Headers();
666
705
  for (const [key, value] of Object.entries(header ?? {})) {
667
- if (value != null) headers.set(key, String(value));
706
+ if (value != null)
707
+ headers.set(key, String(value));
668
708
  }
669
- if (!headers.has("content-type")) headers.set("content-type", "application/json");
709
+ if (!headers.has("content-type"))
710
+ headers.set("content-type", "application/json");
670
711
  return headers;
671
712
  }
672
713
  function appendQueryParams(url, data) {
@@ -678,7 +719,8 @@ function appendQueryParams(url, data) {
678
719
  return resolved.toString();
679
720
  }
680
721
  function encodeBody(data, contentType) {
681
- if (typeof data === "string") return data;
722
+ if (typeof data === "string")
723
+ return data;
682
724
  if (contentType.includes("application/x-www-form-urlencoded")) {
683
725
  const form = new URLSearchParams();
684
726
  for (const [key, value] of Object.entries(data)) {
@@ -693,7 +735,8 @@ async function decodeResponseData(response, dataType, responseType) {
693
735
  return response.arrayBuffer();
694
736
  }
695
737
  const text = await response.text();
696
- if (dataType !== "json") return text;
738
+ if (dataType !== "json")
739
+ return text;
697
740
  try {
698
741
  return JSON.parse(text);
699
742
  } catch {
@@ -717,14 +760,16 @@ function performRequest(opts, callbacks) {
717
760
  init.signal = controller.signal;
718
761
  let settled = false;
719
762
  function settleSuccess(res) {
720
- if (settled) return;
763
+ if (settled)
764
+ return;
721
765
  settled = true;
722
766
  clearTimeout(timer);
723
767
  callbacks.success?.(res);
724
768
  callbacks.complete?.(res);
725
769
  }
726
770
  function settleFail(err) {
727
- if (settled) return;
771
+ if (settled)
772
+ return;
728
773
  settled = true;
729
774
  clearTimeout(timer);
730
775
  callbacks.fail?.(err);
@@ -909,44 +954,19 @@ function setupApiCompatHook() {
909
954
  // src/preload/runtime/native-host.ts
910
955
  var import_electron5 = require("electron");
911
956
 
912
- // src/shared/bridge-channels.ts
913
- var BRIDGE_CHANNELS = {
914
- SPAWN: "dmb:spawn",
915
- DISPOSE: "dmb:dispose",
916
- PAGE_OPEN: "dmb:page:open",
917
- PAGE_CLOSE: "dmb:page:close",
918
- PAGE_LIFECYCLE: "dmb:page:lifecycle",
919
- NAV_CALLBACK: "dmb:nav:callback",
920
- SERVICE_INVOKE: "dmb:service:invoke",
921
- SERVICE_PUBLISH: "dmb:service:publish",
922
- RENDER_INVOKE: "dmb:render:invoke",
923
- RENDER_PUBLISH: "dmb:render:publish",
924
- TO_SERVICE: "dmb:to-service",
925
- TO_RENDER: "dmb:to-render",
926
- SIMULATOR_API: "dmb:simulator-api",
927
- /** simulator → main: ack of an API_CALL request (carries success/fail args). */
928
- API_RESPONSE: "dmb:api:response",
929
- /**
930
- * simulator webview preload → main (sendSync): "is native-host mode on?".
931
- * The guest preload can't read the launch `process.env`, so it asks main
932
- * (which can) at install time. Reply is `e.returnValue = boolean`.
933
- */
934
- NATIVE_HOST_ENABLED: "dmb:native-host-enabled",
935
- /**
936
- * simulator (DeviceShell) → main: the visible top-of-stack page bridgeId.
937
- * Main has no z-order concept — the active page lives only in DeviceShell's
938
- * ShellState — so devtools panels / automation that must target "the current
939
- * page's render webContents" resolve it through this signal. Fire-and-forget.
940
- */
941
- ACTIVE_PAGE: "dmb:active-page",
942
- /**
943
- * simulator (DeviceShell) → main: the FULL ordered page stack (bottom→top)
944
- * whenever it changes. Main has no stack of its own (it only learns the
945
- * active bridgeId via ACTIVE_PAGE), so automation's `App.getPageStack` needs
946
- * this to report multi-page stacks. Fire-and-forget.
947
- */
948
- PAGE_STACK: "dmb:page-stack"
949
- };
957
+ // ../dimina-electron-runtime/dist/shared/dmb-resource-url.js
958
+ var DMB_SDK_PREFIX = "/__sdk__/";
959
+ function buildRenderHostDocumentUrl(opts) {
960
+ const url = new URL(`dmb-resource://${opts.bridgeId}${DMB_SDK_PREFIX}render-host/pageFrame.html`);
961
+ url.searchParams.set("bridgeId", opts.bridgeId);
962
+ url.searchParams.set("appId", opts.appId);
963
+ url.searchParams.set("pagePath", opts.pagePath);
964
+ if (opts.isTab)
965
+ url.searchParams.set("isTab", "1");
966
+ if (opts.backgroundColor)
967
+ url.searchParams.set("bgColor", opts.backgroundColor);
968
+ return url.toString();
969
+ }
950
970
 
951
971
  // src/preload/runtime/native-host.ts
952
972
  function queryNativeHostConfig() {
@@ -990,13 +1010,7 @@ function buildBridge2(cfg) {
990
1010
  import_electron5.ipcRenderer.send(BRIDGE_CHANNELS.PAGE_STACK, payload);
991
1011
  },
992
1012
  createRenderHostUrl(opts) {
993
- const url = new URL(cfg.renderHostHtmlUrl);
994
- url.searchParams.set("bridgeId", opts.bridgeId);
995
- url.searchParams.set("appId", opts.appId);
996
- url.searchParams.set("pagePath", opts.pagePath);
997
- if (opts.isTab) url.searchParams.set("isTab", "1");
998
- if (opts.backgroundColor) url.searchParams.set("bgColor", opts.backgroundColor);
999
- return url.toString();
1013
+ return buildRenderHostDocumentUrl(opts);
1000
1014
  },
1001
1015
  renderPreloadUrl: cfg.renderPreloadUrl,
1002
1016
  device: cfg.device,
@@ -1017,12 +1031,25 @@ function installNativeHostBridge() {
1017
1031
  return exposeOnMainWorld("__diminaNativeHost", buildBridge2(cfg));
1018
1032
  }
1019
1033
 
1034
+ // src/preload/runtime/clipboard.ts
1035
+ var import_electron6 = require("electron");
1036
+ function buildBridge3() {
1037
+ return {
1038
+ readText: () => import_electron6.clipboard.readText(),
1039
+ writeText: (text) => import_electron6.clipboard.writeText(text)
1040
+ };
1041
+ }
1042
+ function installClipboardBridge() {
1043
+ return exposeOnMainWorld("__diminaClipboard", buildBridge3());
1044
+ }
1045
+
1020
1046
  // src/preload/windows/simulator.ts
1021
1047
  setupApiCompatHook();
1022
1048
  installSimulatorBridge();
1023
1049
  installCustomApisBridge();
1024
1050
  installTempFileBridge();
1025
1051
  installConsoleInstrumentation();
1052
+ installClipboardBridge();
1026
1053
  installNativeHostBridge();
1027
1054
  createAppDataSource().start(() => {
1028
1055
  });
@@ -1,420 +1,2 @@
1
- import type { NativeDeviceInfo } from './ipc-channels.js';
2
- export declare const BRIDGE_CHANNELS: {
3
- readonly SPAWN: "dmb:spawn";
4
- readonly DISPOSE: "dmb:dispose";
5
- readonly PAGE_OPEN: "dmb:page:open";
6
- readonly PAGE_CLOSE: "dmb:page:close";
7
- readonly PAGE_LIFECYCLE: "dmb:page:lifecycle";
8
- readonly NAV_CALLBACK: "dmb:nav:callback";
9
- readonly SERVICE_INVOKE: "dmb:service:invoke";
10
- readonly SERVICE_PUBLISH: "dmb:service:publish";
11
- readonly RENDER_INVOKE: "dmb:render:invoke";
12
- readonly RENDER_PUBLISH: "dmb:render:publish";
13
- readonly TO_SERVICE: "dmb:to-service";
14
- readonly TO_RENDER: "dmb:to-render";
15
- readonly SIMULATOR_API: "dmb:simulator-api";
16
- /** simulator → main: ack of an API_CALL request (carries success/fail args). */
17
- readonly API_RESPONSE: "dmb:api:response";
18
- /**
19
- * simulator webview preload → main (sendSync): "is native-host mode on?".
20
- * The guest preload can't read the launch `process.env`, so it asks main
21
- * (which can) at install time. Reply is `e.returnValue = boolean`.
22
- */
23
- readonly NATIVE_HOST_ENABLED: "dmb:native-host-enabled";
24
- /**
25
- * simulator (DeviceShell) → main: the visible top-of-stack page bridgeId.
26
- * Main has no z-order concept — the active page lives only in DeviceShell's
27
- * ShellState — so devtools panels / automation that must target "the current
28
- * page's render webContents" resolve it through this signal. Fire-and-forget.
29
- */
30
- readonly ACTIVE_PAGE: "dmb:active-page";
31
- /**
32
- * simulator (DeviceShell) → main: the FULL ordered page stack (bottom→top)
33
- * whenever it changes. Main has no stack of its own (it only learns the
34
- * active bridgeId via ACTIVE_PAGE), so automation's `App.getPageStack` needs
35
- * this to report multi-page stacks. Fire-and-forget.
36
- */
37
- readonly PAGE_STACK: "dmb:page-stack";
38
- };
39
- export declare const SIMULATOR_EVENTS: {
40
- readonly DOM_READY: "simulator:dom-ready";
41
- readonly NAV_BAR: "simulator:navigation-bar";
42
- readonly NAV_ACTION: "simulator:nav-action";
43
- readonly TAB_ACTION: "simulator:tab-action";
44
- /** main → simulator: invoke a wx.* API on the simulator-resident MiniApp. */
45
- readonly API_CALL: "simulator:api-call";
46
- /**
47
- * main → simulator: the renderer toolbar picked a different device. Carries a
48
- * NativeDeviceInfo; DeviceShell resizes the bezel + re-renders status bar /
49
- * notch. The race-free INITIAL device rides NativeHostConfig.device (read
50
- * synchronously at preload bridge-install); this event covers live changes.
51
- */
52
- readonly DEVICE_CHANGE: "simulator:device-change";
53
- /**
54
- * main → simulator: a watcher rebuild finished; boot a NEW app session for
55
- * the carried url ({@link RelaunchPayload}) IN PLACE, keeping the live
56
- * DeviceShell painted, and swap once the new session's root page reports
57
- * DOM_READY (ready-then-swap soft reload). Main sends this only when the
58
- * shell is live+ready; otherwise the renderer falls back to the hard
59
- * attachNativeSimulator rebuild.
60
- */
61
- readonly RELAUNCH: "simulator:relaunch";
62
- };
63
- /**
64
- * `simulator:relaunch` payload. `url` is a full simulator URL (same format as
65
- * the simulator page's own location / AttachNative), carrying the appId and
66
- * the page route the new session must boot at.
67
- */
68
- export interface RelaunchPayload {
69
- url: string;
70
- }
71
- export declare const CHANNELS: {
72
- readonly SPAWN: "dmb:spawn";
73
- readonly DISPOSE: "dmb:dispose";
74
- readonly PAGE_OPEN: "dmb:page:open";
75
- readonly PAGE_CLOSE: "dmb:page:close";
76
- readonly PAGE_LIFECYCLE: "dmb:page:lifecycle";
77
- readonly NAV_CALLBACK: "dmb:nav:callback";
78
- readonly SERVICE_INVOKE: "dmb:service:invoke";
79
- readonly SERVICE_PUBLISH: "dmb:service:publish";
80
- readonly RENDER_INVOKE: "dmb:render:invoke";
81
- readonly RENDER_PUBLISH: "dmb:render:publish";
82
- readonly TO_SERVICE: "dmb:to-service";
83
- readonly TO_RENDER: "dmb:to-render";
84
- readonly SIMULATOR_API: "dmb:simulator-api";
85
- /** simulator → main: ack of an API_CALL request (carries success/fail args). */
86
- readonly API_RESPONSE: "dmb:api:response";
87
- /**
88
- * simulator webview preload → main (sendSync): "is native-host mode on?".
89
- * The guest preload can't read the launch `process.env`, so it asks main
90
- * (which can) at install time. Reply is `e.returnValue = boolean`.
91
- */
92
- readonly NATIVE_HOST_ENABLED: "dmb:native-host-enabled";
93
- /**
94
- * simulator (DeviceShell) → main: the visible top-of-stack page bridgeId.
95
- * Main has no z-order concept — the active page lives only in DeviceShell's
96
- * ShellState — so devtools panels / automation that must target "the current
97
- * page's render webContents" resolve it through this signal. Fire-and-forget.
98
- */
99
- readonly ACTIVE_PAGE: "dmb:active-page";
100
- /**
101
- * simulator (DeviceShell) → main: the FULL ordered page stack (bottom→top)
102
- * whenever it changes. Main has no stack of its own (it only learns the
103
- * active bridgeId via ACTIVE_PAGE), so automation's `App.getPageStack` needs
104
- * this to report multi-page stacks. Fire-and-forget.
105
- */
106
- readonly PAGE_STACK: "dmb:page-stack";
107
- };
108
- /**
109
- * Reply to a `NATIVE_HOST_ENABLED` sendSync. Main supplies the render-host
110
- * file:// URLs (computed with node:path/url, which the simulator webview's
111
- * preload lacks) so the preload can build the native-host bridge.
112
- */
113
- export interface NativeHostConfig {
114
- enabled: boolean;
115
- renderHostHtmlUrl: string;
116
- renderPreloadUrl: string;
117
- /**
118
- * The currently-selected device, if the renderer already pushed it before the
119
- * simulator WCV's preload installed (it does — SetDeviceInfo precedes
120
- * AttachNative). DeviceShell reads this as its initial device so it never
121
- * mounts with the wrong bezel size while waiting for the first DEVICE_CHANGE.
122
- * Absent only on the pre-spawn default path.
123
- */
124
- device?: NativeDeviceInfo;
125
- }
126
- export type BridgeChannel = typeof BRIDGE_CHANNELS[keyof typeof BRIDGE_CHANNELS];
127
- export type BridgeTarget = 'service' | 'render' | 'container';
128
- export type BridgeMessageType = 'loadResource' | 'serviceResourceLoaded' | 'renderResourceLoaded' | 'resourceLoaded' | 'firstRender' | 'appShow' | 'appHide' | 'stackShow' | 'stackHide' | 'pageShow' | 'pageHide' | 'pageReady' | 'pageUnload' | 'pageScroll' | 'pageResize' | 'pageRouteDone' | 'mC' | 'mR' | 'mU' | 't' | 'u' | 'ub' | 'triggerCallback' | 'invokeAPI' | 'h5SdkAction' | 'componentError' | 'domReady' | 'print' | 'renderHostReady' | 'serviceHostError' | string;
129
- export interface MessageEnvelope<TBody extends Record<string, unknown> = Record<string, unknown>> {
130
- type: BridgeMessageType;
131
- target: BridgeTarget;
132
- body: TBody;
133
- }
134
- export interface HostEnvSnapshot {
135
- brand: string;
136
- model: string;
137
- platform: string;
138
- system: string;
139
- version: string;
140
- SDKVersion: string;
141
- pixelRatio: number;
142
- screenWidth: number;
143
- screenHeight: number;
144
- windowWidth: number;
145
- windowHeight: number;
146
- statusBarHeight: number;
147
- language: string;
148
- theme: string;
149
- [key: string]: unknown;
150
- }
151
- /**
152
- * Map the renderer's logical device metrics onto the subset of a
153
- * HostEnvSnapshot the service-host window's `getSystemInfoSync` consumes.
154
- * `windowHeight` excludes the status bar (the page area); `windowWidth` has no
155
- * horizontal chrome. Zoom is intentionally absent — it is a display scale, not
156
- * a logical-size change.
157
- *
158
- * Single source of truth for the device→host-env mapping, shared by the live
159
- * `SetDeviceInfo` IPC path (main/ipc/simulator.ts) and the per-spawn host-env
160
- * seeding (main/ipc/bridge-router.ts). Keeping them identical guarantees a
161
- * service-host RESPAWN after a device change reports the same dims the live
162
- * update pushed — otherwise a respawn would silently revert to the boot device.
163
- */
164
- export declare function deviceInfoToHostEnv(d: NativeDeviceInfo): Partial<HostEnvSnapshot>;
165
- /**
166
- * Subset of WeChat page `window` config plus tabBar list, parsed from
167
- * `app-config.json` (`{app:{window,tabBar,pages,entryPagePath}, modules:{[pagePath]:{...flat page.json fields,root?}}}`).
168
- * `modules[pagePath]` is FLAT — the compiler assigns the page's own `.json` file
169
- * content as-is (see `dimina/fe/packages/compiler/src/env.js` `collectionPageJson()`),
170
- * not wrapped under a `.window` key. Mirrors mergePageConfig in dimina-fe:
171
- * page-level keys override app-level.
172
- */
173
- export interface PageWindowConfig {
174
- navigationBarTitleText?: string;
175
- navigationBarBackgroundColor?: string;
176
- navigationBarTextStyle?: 'black' | 'white';
177
- navigationStyle?: 'default' | 'custom';
178
- homeButton?: boolean;
179
- backgroundColor?: string;
180
- backgroundTextStyle?: 'dark' | 'light';
181
- enablePullDownRefresh?: boolean;
182
- disableScroll?: boolean;
183
- [key: string]: unknown;
184
- }
185
- export interface TabBarItem {
186
- pagePath: string;
187
- text?: string;
188
- iconPath?: string;
189
- selectedIconPath?: string;
190
- }
191
- export interface TabBarConfig {
192
- color?: string;
193
- selectedColor?: string;
194
- backgroundColor?: string;
195
- borderStyle?: 'black' | 'white';
196
- position?: 'bottom' | 'top';
197
- custom?: boolean;
198
- list: TabBarItem[];
199
- }
200
- export interface AppManifest {
201
- entryPagePath: string;
202
- pages: string[];
203
- tabBar?: TabBarConfig;
204
- /**
205
- * Provenance of this manifest: `'app-config'` when built from a real
206
- * compiled `app-config.json` (its `pages` list is authoritative, so mount
207
- * gates can validate membership against it); `'fallback'` when
208
- * app-config.json was unreachable and the manifest is a single-page stand-in
209
- * built from the spawn request. Mount gates only enforce against
210
- * `'app-config'` — a `'fallback'` manifest has no compiled truth to check
211
- * membership against, so it must let every page/nav target through.
212
- */
213
- source: 'app-config' | 'fallback';
214
- }
215
- export interface SpawnRequest {
216
- simulatorWcId?: number;
217
- appId: string;
218
- bridgeId?: string;
219
- pagePath?: string;
220
- scene?: number;
221
- query?: Record<string, unknown>;
222
- apiNamespaces?: string[];
223
- hostEnvSnapshot?: Partial<HostEnvSnapshot>;
224
- pkgRoot?: string;
225
- root?: string;
226
- /**
227
- * Base URL of the dev server that serves the compiled mini-app, i.e. the
228
- * SAME origin the simulator page was loaded from (`http://localhost:<port>/`).
229
- * The dev server statically serves `<appId>/<root>/…` (app-config.json,
230
- * logic.js, page bundles, styles) — exactly what the default dimina-fe
231
- * `<webview>` fetches. The native-host render + service hosts source every
232
- * resource from here, so we don't need a second resource server or a local
233
- * compiled-output path. Trailing slash expected.
234
- */
235
- resourceBaseUrl?: string;
236
- }
237
- export interface SpawnResult {
238
- appSessionId: string;
239
- bridgeId: string;
240
- /** The pagePath originally requested (unchanged even when a fallback applied — see `resolvedPagePath`). */
241
- pagePath: string;
242
- /**
243
- * The pagePath the root PageSession was ACTUALLY spawned with. Equal to
244
- * `pagePath` unless `pageFallbackApplied` is true, in which case the request
245
- * was absent from `manifest.pages` and this is `manifest.entryPagePath`
246
- * (or `manifest.pages[0]` when even that isn't a member). Callers that cache
247
- * "the current page" (e.g. `SimulatorMiniApp`) must reconcile against this,
248
- * not the original request.
249
- */
250
- resolvedPagePath: string;
251
- /** Whether `resolvedPagePath` differs from the request because it was absent from the compiled manifest. Always false for a `'fallback'` manifest (nothing to validate against). */
252
- pageFallbackApplied: boolean;
253
- serviceWcId: number;
254
- resourceBaseUrl: string;
255
- manifest: AppManifest;
256
- rootWindowConfig: PageWindowConfig;
257
- }
258
- export interface PageOpenRequest {
259
- appSessionId: string;
260
- pagePath: string;
261
- query?: Record<string, unknown>;
262
- bridgeId?: string;
263
- }
264
- export interface PageOpenResult {
265
- bridgeId: string;
266
- pagePath: string;
267
- windowConfig: PageWindowConfig;
268
- isTab: boolean;
269
- }
270
- export interface PageClosePayload {
271
- bridgeId: string;
272
- }
273
- export interface DisposePayload {
274
- /** AppSession root bridgeId (legacy) or any page bridgeId. */
275
- bridgeId: string;
276
- }
277
- export type PageLifecycleEvent = 'pageShow' | 'pageHide' | 'pageUnload' | 'stackShow' | 'stackHide' | 'appShow' | 'appHide';
278
- export interface PageLifecyclePayload {
279
- appSessionId: string;
280
- bridgeId: string;
281
- event: PageLifecycleEvent;
282
- }
283
- /**
284
- * Sent by simulator after a routing action (navigateTo etc.) completes so the
285
- * main process can call sendCallback() against the original service-issued
286
- * success/fail/complete ids.
287
- */
288
- export interface NavCallbackPayload {
289
- appSessionId: string;
290
- ok: boolean;
291
- errMsg: string;
292
- callbacks: {
293
- success?: unknown;
294
- fail?: unknown;
295
- complete?: unknown;
296
- };
297
- }
298
- export interface ServiceInvokePayload {
299
- bridgeId: string;
300
- msg: MessageEnvelope;
301
- }
302
- export interface ServicePublishPayload {
303
- bridgeId: string;
304
- targetBridgeId?: string;
305
- msg: MessageEnvelope;
306
- }
307
- /**
308
- * `dmb:active-page` — simulator (DeviceShell) → main. Records which page is the
309
- * visible top-of-stack so main-side services (WXML/element-inspect, automation)
310
- * can resolve "the active page's render webContents" by bridgeId.
311
- */
312
- export interface ActivePagePayload {
313
- appSessionId: string;
314
- bridgeId: string;
315
- }
316
- /**
317
- * `dmb:page-stack` — simulator (DeviceShell) → main. The full ordered page
318
- * stack (bottom→top) so `App.getPageStack` can report multi-page stacks.
319
- */
320
- export interface PageStackEntry {
321
- pagePath: string;
322
- query: Record<string, unknown>;
323
- }
324
- export interface PageStackPayload {
325
- appSessionId: string;
326
- stack: PageStackEntry[];
327
- }
328
- export interface RenderInvokePayload {
329
- bridgeId: string;
330
- msg: MessageEnvelope;
331
- }
332
- export interface RenderPublishPayload {
333
- bridgeId: string;
334
- msg: MessageEnvelope;
335
- }
336
- export interface ToServicePayload {
337
- msg: MessageEnvelope;
338
- }
339
- export interface ToRenderPayload {
340
- msg: MessageEnvelope;
341
- }
342
- export interface SimulatorApiInvokePayload {
343
- bridgeId: string;
344
- name: string;
345
- params: unknown;
346
- }
347
- /**
348
- * `simulator:nav-action` — main → simulator window, carries router/tabBar
349
- * intentions. Simulator owns the visual stack state and decides whether to
350
- * push/pop webviews; it then calls back PAGE_LIFECYCLE + NAV_CALLBACK.
351
- */
352
- export interface NavActionPayload {
353
- appSessionId: string;
354
- bridgeId: string;
355
- name: 'navigateTo' | 'navigateBack' | 'redirectTo' | 'reLaunch' | 'switchTab';
356
- params: Record<string, unknown>;
357
- callbacks: {
358
- success?: unknown;
359
- fail?: unknown;
360
- complete?: unknown;
361
- };
362
- }
363
- /**
364
- * `simulator:api-call` — main → simulator. Fallback path used when an
365
- * invokeAPI name is not registered in the main-process `ctx.simulatorApis`
366
- * registry: the simulator-resident MiniApp owns the wx.* handler (it can
367
- * read DOM, open file pickers, etc.), so we forward the call there and wait
368
- * for an `API_RESPONSE` ack.
369
- */
370
- export interface ApiCallPayload {
371
- appSessionId: string;
372
- bridgeId: string;
373
- requestId: string;
374
- name: string;
375
- params: Record<string, unknown>;
376
- callbacks: {
377
- success?: unknown;
378
- fail?: unknown;
379
- complete?: unknown;
380
- };
381
- }
382
- /**
383
- * `dmb:api:response` — simulator → main. Ack for an `API_CALL`. Main looks
384
- * up `requestId` in its pending map and fires the original service-side
385
- * success/fail/complete callbacks accordingly.
386
- */
387
- export interface ApiResponsePayload {
388
- appSessionId: string;
389
- requestId: string;
390
- ok: boolean;
391
- /** Argument the simulator-side success/fail callback was invoked with. */
392
- result?: unknown;
393
- errMsg?: string;
394
- /**
395
- * Persistent-subscription marker (`keep: true` APIs, e.g.
396
- * `audioListen`). When set, this response is one of potentially many
397
- * fires of the same subscription: main re-fires the service-side success
398
- * callback but keeps the pendingApiCall alive (does not delete it or fire
399
- * `complete`) so subsequent fires of the same `requestId` are delivered.
400
- * Cleanup happens on page/app teardown instead.
401
- */
402
- keep?: boolean;
403
- }
404
- /**
405
- * `simulator:tab-action` — main → simulator window, carries dynamic TabBar
406
- * API calls. Simulator updates TabBar React state and acknowledges via
407
- * NAV_CALLBACK so the service-side wx.* callback fires.
408
- */
409
- export interface TabActionPayload {
410
- appSessionId: string;
411
- bridgeId: string;
412
- name: 'setTabBarStyle' | 'setTabBarItem' | 'showTabBar' | 'hideTabBar' | 'setTabBarBadge' | 'removeTabBarBadge' | 'showTabBarRedDot' | 'hideTabBarRedDot';
413
- params: Record<string, unknown>;
414
- callbacks: {
415
- success?: unknown;
416
- fail?: unknown;
417
- complete?: unknown;
418
- };
419
- }
1
+ export * from '@dimina-kit/electron-runtime/shared/bridge-channels';
420
2
  //# sourceMappingURL=bridge-channels.d.ts.map