@dimina-kit/devtools 0.4.0-dev.20260728110120 → 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 (105) hide show
  1. package/README.md +68 -0
  2. package/dist/main/api.d.ts +1 -0
  3. package/dist/main/app/app.d.ts +3 -0
  4. package/dist/main/app/app.js +15 -0
  5. package/dist/main/app/bootstrap.d.ts +8 -5
  6. package/dist/main/app/bootstrap.js +15 -15
  7. package/dist/main/index.bundle.js +2359 -5132
  8. package/dist/main/ipc/app-lifecycle.d.ts +1 -31
  9. package/dist/main/ipc/app-lifecycle.js +1 -53
  10. package/dist/main/ipc/bridge-router.d.ts +19 -152
  11. package/dist/main/ipc/bridge-router.js +28 -2186
  12. package/dist/main/ipc/page-scroll.d.ts +1 -13
  13. package/dist/main/ipc/page-scroll.js +1 -16
  14. package/dist/main/ipc/session-listener-bag.d.ts +1 -40
  15. package/dist/main/ipc/session-listener-bag.js +1 -39
  16. package/dist/main/services/console-forward/index.d.ts +1 -60
  17. package/dist/main/services/console-forward/index.js +1 -225
  18. package/dist/main/services/console-forward/internal-log.d.ts +1 -10
  19. package/dist/main/services/console-forward/internal-log.js +1 -22
  20. package/dist/main/services/diagnostics/index.d.ts +1 -58
  21. package/dist/main/services/diagnostics/index.js +1 -60
  22. package/dist/main/services/dimina-resource-server.d.ts +1 -6
  23. package/dist/main/services/dimina-resource-server.js +1 -98
  24. package/dist/main/services/network-forward/index.d.ts +15 -3
  25. package/dist/main/services/network-forward/index.js +30 -4
  26. package/dist/main/services/network-forward/websocket.d.ts +36 -0
  27. package/dist/main/services/network-forward/websocket.js +120 -0
  28. package/dist/main/services/service-host-pool/pool.d.ts +1 -196
  29. package/dist/main/services/service-host-pool/pool.js +1 -363
  30. package/dist/main/services/simulator/custom-apis.d.ts +1 -42
  31. package/dist/main/services/simulator/custom-apis.js +1 -46
  32. package/dist/main/services/simulator/referer.d.ts +1 -9
  33. package/dist/main/services/simulator/referer.js +1 -19
  34. package/dist/main/services/simulator/ui-extensions.d.ts +13 -0
  35. package/dist/main/services/simulator/ui-extensions.js +166 -0
  36. package/dist/main/services/simulator-storage/service-storage-ops.d.ts +1 -39
  37. package/dist/main/services/simulator-storage/service-storage-ops.js +1 -66
  38. package/dist/main/services/simulator-temp-files/disk.d.ts +1 -54
  39. package/dist/main/services/simulator-temp-files/disk.js +1 -237
  40. package/dist/main/services/simulator-temp-files/fs-channels.d.ts +1 -68
  41. package/dist/main/services/simulator-temp-files/fs-channels.js +1 -107
  42. package/dist/main/services/simulator-temp-files/index.d.ts +1 -32
  43. package/dist/main/services/simulator-temp-files/index.js +1 -181
  44. package/dist/main/services/simulator-temp-files/request-handler.d.ts +1 -29
  45. package/dist/main/services/simulator-temp-files/request-handler.js +1 -177
  46. package/dist/main/services/simulator-temp-files/resolver.d.ts +1 -21
  47. package/dist/main/services/simulator-temp-files/resolver.js +1 -21
  48. package/dist/main/services/simulator-temp-files/store.d.ts +1 -13
  49. package/dist/main/services/simulator-temp-files/store.js +1 -23
  50. package/dist/main/services/views/miniapp-partition.d.ts +1 -89
  51. package/dist/main/services/views/miniapp-partition.js +1 -158
  52. package/dist/main/services/views/native-simulator-view.js +3 -0
  53. package/dist/main/services/views/simulator-session-policy.d.ts +1 -27
  54. package/dist/main/services/views/simulator-session-policy.js +1 -98
  55. package/dist/main/services/views/view-manager.d.ts +5 -0
  56. package/dist/main/services/workbench-context.d.ts +10 -1
  57. package/dist/main/services/workbench-context.js +20 -0
  58. package/dist/main/utils/ipc-registry.d.ts +21 -3
  59. package/dist/main/utils/ipc-registry.js +26 -23
  60. package/dist/main/utils/paths.d.ts +14 -0
  61. package/dist/main/utils/paths.js +14 -0
  62. package/dist/main/windows/service-host-window/create.d.ts +1 -92
  63. package/dist/main/windows/service-host-window/create.js +1 -154
  64. package/dist/native-host/render/render.js +51 -52
  65. package/dist/native-host/service/service.js +2 -2
  66. package/dist/preload/index.d.ts +2 -0
  67. package/dist/preload/index.js +1 -0
  68. package/dist/preload/runtime/clipboard.d.ts +6 -0
  69. package/dist/preload/runtime/clipboard.js +12 -0
  70. package/dist/preload/runtime/native-host.js +4 -10
  71. package/dist/preload/windows/host-toolbar-runtime.cjs.map +2 -2
  72. package/dist/preload/windows/main.cjs +46 -126
  73. package/dist/preload/windows/main.cjs.map +3 -3
  74. package/dist/preload/windows/simulator.cjs +83 -56
  75. package/dist/preload/windows/simulator.cjs.map +4 -4
  76. package/dist/preload/windows/simulator.js +83 -56
  77. package/dist/renderer/assets/{index-BJlFbXHb.js → index-BBg3YI5b.js} +2 -2
  78. package/dist/renderer/entries/main/index.html +1 -1
  79. package/dist/shared/bridge-channels.d.ts +1 -419
  80. package/dist/shared/bridge-channels.js +1 -89
  81. package/dist/shared/dmb-resource-url.d.ts +2 -0
  82. package/dist/shared/dmb-resource-url.js +2 -0
  83. package/dist/shared/ipc-channels.d.ts +2 -32
  84. package/dist/shared/ipc-channels.js +2 -5
  85. package/dist/shared/request-core.d.ts +1 -83
  86. package/dist/shared/request-core.js +1 -167
  87. package/dist/shared/simulator-ui.d.ts +61 -0
  88. package/dist/shared/simulator-ui.js +12 -0
  89. package/dist/shared/types.d.ts +7 -0
  90. package/dist/simulator/assets/device-shell-B03OuytR.js +2 -0
  91. package/dist/simulator/assets/device-shell-DbC5ccs8.css +1 -0
  92. package/dist/simulator/assets/{jsx-runtime-BDTY6fEq.js → jsx-runtime-hBv-rHqQ.js} +2 -2
  93. package/dist/simulator/assets/{simulator-CRyLSz1N.js → simulator-DpdXUf--.js} +5 -5
  94. package/dist/simulator/simulator.html +2 -2
  95. package/dist/simulator/temp-files.d.ts +29 -0
  96. package/dist/simulator/temp-files.js +79 -0
  97. package/dist/simulator/types.d.ts +43 -0
  98. package/dist/simulator/types.js +2 -0
  99. package/package.json +10 -5
  100. package/dist/shared/simulator-api-metadata.d.ts +0 -26
  101. package/dist/shared/simulator-api-metadata.js +0 -59
  102. package/dist/shared/vpath.d.ts +0 -42
  103. package/dist/shared/vpath.js +0 -105
  104. package/dist/simulator/assets/device-shell-DOy53Y0s.css +0 -1
  105. package/dist/simulator/assets/device-shell-Sbkjw8Nb.js +0 -2
@@ -26,7 +26,7 @@
26
26
  overflow: hidden;
27
27
  }
28
28
  </style>
29
- <script type="module" crossorigin src="../../assets/index-BJlFbXHb.js"></script>
29
+ <script type="module" crossorigin src="../../assets/index-BBg3YI5b.js"></script>
30
30
  <link rel="modulepreload" crossorigin href="../../assets/ipc-transport-B3EpmfNS.js">
31
31
  <link rel="modulepreload" crossorigin href="../../assets/input-xdmfv-eH.js">
32
32
  <link rel="modulepreload" crossorigin href="../../assets/select-CD9CJyhI.js">
@@ -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
@@ -1,90 +1,2 @@
1
- export const BRIDGE_CHANNELS = {
2
- SPAWN: 'dmb:spawn',
3
- DISPOSE: 'dmb:dispose',
4
- PAGE_OPEN: 'dmb:page:open',
5
- PAGE_CLOSE: 'dmb:page:close',
6
- PAGE_LIFECYCLE: 'dmb:page:lifecycle',
7
- NAV_CALLBACK: 'dmb:nav:callback',
8
- SERVICE_INVOKE: 'dmb:service:invoke',
9
- SERVICE_PUBLISH: 'dmb:service:publish',
10
- RENDER_INVOKE: 'dmb:render:invoke',
11
- RENDER_PUBLISH: 'dmb:render:publish',
12
- TO_SERVICE: 'dmb:to-service',
13
- TO_RENDER: 'dmb:to-render',
14
- SIMULATOR_API: 'dmb:simulator-api',
15
- /** simulator → main: ack of an API_CALL request (carries success/fail args). */
16
- API_RESPONSE: 'dmb:api:response',
17
- /**
18
- * simulator webview preload → main (sendSync): "is native-host mode on?".
19
- * The guest preload can't read the launch `process.env`, so it asks main
20
- * (which can) at install time. Reply is `e.returnValue = boolean`.
21
- */
22
- NATIVE_HOST_ENABLED: 'dmb:native-host-enabled',
23
- /**
24
- * simulator (DeviceShell) → main: the visible top-of-stack page bridgeId.
25
- * Main has no z-order concept — the active page lives only in DeviceShell's
26
- * ShellState — so devtools panels / automation that must target "the current
27
- * page's render webContents" resolve it through this signal. Fire-and-forget.
28
- */
29
- ACTIVE_PAGE: 'dmb:active-page',
30
- /**
31
- * simulator (DeviceShell) → main: the FULL ordered page stack (bottom→top)
32
- * whenever it changes. Main has no stack of its own (it only learns the
33
- * active bridgeId via ACTIVE_PAGE), so automation's `App.getPageStack` needs
34
- * this to report multi-page stacks. Fire-and-forget.
35
- */
36
- PAGE_STACK: 'dmb:page-stack',
37
- };
38
- export const SIMULATOR_EVENTS = {
39
- DOM_READY: 'simulator:dom-ready',
40
- NAV_BAR: 'simulator:navigation-bar',
41
- NAV_ACTION: 'simulator:nav-action',
42
- TAB_ACTION: 'simulator:tab-action',
43
- /** main → simulator: invoke a wx.* API on the simulator-resident MiniApp. */
44
- API_CALL: 'simulator:api-call',
45
- /**
46
- * main → simulator: the renderer toolbar picked a different device. Carries a
47
- * NativeDeviceInfo; DeviceShell resizes the bezel + re-renders status bar /
48
- * notch. The race-free INITIAL device rides NativeHostConfig.device (read
49
- * synchronously at preload bridge-install); this event covers live changes.
50
- */
51
- DEVICE_CHANGE: 'simulator:device-change',
52
- /**
53
- * main → simulator: a watcher rebuild finished; boot a NEW app session for
54
- * the carried url ({@link RelaunchPayload}) IN PLACE, keeping the live
55
- * DeviceShell painted, and swap once the new session's root page reports
56
- * DOM_READY (ready-then-swap soft reload). Main sends this only when the
57
- * shell is live+ready; otherwise the renderer falls back to the hard
58
- * attachNativeSimulator rebuild.
59
- */
60
- RELAUNCH: 'simulator:relaunch',
61
- };
62
- export const CHANNELS = BRIDGE_CHANNELS;
63
- /**
64
- * Map the renderer's logical device metrics onto the subset of a
65
- * HostEnvSnapshot the service-host window's `getSystemInfoSync` consumes.
66
- * `windowHeight` excludes the status bar (the page area); `windowWidth` has no
67
- * horizontal chrome. Zoom is intentionally absent — it is a display scale, not
68
- * a logical-size change.
69
- *
70
- * Single source of truth for the device→host-env mapping, shared by the live
71
- * `SetDeviceInfo` IPC path (main/ipc/simulator.ts) and the per-spawn host-env
72
- * seeding (main/ipc/bridge-router.ts). Keeping them identical guarantees a
73
- * service-host RESPAWN after a device change reports the same dims the live
74
- * update pushed — otherwise a respawn would silently revert to the boot device.
75
- */
76
- export function deviceInfoToHostEnv(d) {
77
- return {
78
- brand: d.brand,
79
- model: d.model,
80
- system: d.system,
81
- platform: d.platform,
82
- pixelRatio: d.pixelRatio,
83
- screenWidth: d.screenWidth,
84
- screenHeight: d.screenHeight,
85
- windowWidth: d.screenWidth,
86
- windowHeight: Math.max(0, d.screenHeight - d.statusBarHeight),
87
- statusBarHeight: d.statusBarHeight,
88
- };
89
- }
1
+ export * from '@dimina-kit/electron-runtime/shared/bridge-channels';
90
2
  //# sourceMappingURL=bridge-channels.js.map
@@ -0,0 +1,2 @@
1
+ export * from '@dimina-kit/electron-runtime/shared/dmb-resource-url';
2
+ //# sourceMappingURL=dmb-resource-url.d.ts.map
@@ -0,0 +1,2 @@
1
+ export * from '@dimina-kit/electron-runtime/shared/dmb-resource-url';
2
+ //# sourceMappingURL=dmb-resource-url.js.map
@@ -14,34 +14,7 @@ export declare const SimulatorChannel: {
14
14
  readonly CurrentPage: "simulator:current-page";
15
15
  };
16
16
  /** iPhone bezel cutout family driving the device-shell notch visual. */
17
- export type NotchType = 'none' | 'notch' | 'dynamic-island';
18
- /** Per-device safe-area insets in CSS px (portrait). */
19
- export interface SafeAreaInsets {
20
- top: number;
21
- right: number;
22
- bottom: number;
23
- left: number;
24
- }
25
- /**
26
- * Logical device metrics pushed by the renderer device dropdown under
27
- * native-host (`SimulatorChannel.SetDeviceInfo`). Mirrors a row of the renderer
28
- * `DEVICES` table; main maps it onto a `HostEnvSnapshot` for the service-host
29
- * window so `wx.getSystemInfoSync()` reflects the selected device, relays it to
30
- * the simulator WCV (DeviceShell: bezel size + status bar + notch), and drives
31
- * the CSS `env(safe-area-inset-*)` override on render-host guests.
32
- */
33
- export interface NativeDeviceInfo {
34
- brand: string;
35
- model: string;
36
- system: string;
37
- platform: string;
38
- pixelRatio: number;
39
- screenWidth: number;
40
- screenHeight: number;
41
- statusBarHeight: number;
42
- notchType: NotchType;
43
- safeAreaInsets: SafeAreaInsets;
44
- }
17
+ export type { NativeDeviceInfo, NotchType, SafeAreaInsets, } from '@dimina-kit/electron-runtime';
45
18
  export declare const ServiceHostChannel: {
46
19
  /**
47
20
  * NATIVE-HOST ONLY. Live-update the service-host window's host-env snapshot
@@ -62,10 +35,7 @@ export declare const ServiceHostChannel: {
62
35
  export declare const SimulatorCustomApiChannel: {
63
36
  readonly Invoke: "simulator:custom-apis:invoke";
64
37
  };
65
- export declare const SimulatorCustomApiBridgeChannel: {
66
- readonly Request: "simulator:custom-apis:bridge-request";
67
- readonly Response: "simulator:custom-apis:bridge-response";
68
- };
38
+ export { SimulatorCustomApiBridgeChannel, } from '@dimina-kit/electron-runtime/shared/bridge-channels';
69
39
  export declare const SimulatorStorageChannel: {
70
40
  readonly GetSnapshot: "simulator:storage:snapshot";
71
41
  readonly GetActivePrefix: "simulator:storage:activePrefix";
@@ -68,11 +68,8 @@ export const SimulatorCustomApiChannel = {
68
68
  // `<webview>.send`, no longer exists — native-host is the sole runtime.)
69
69
  //
70
70
  // Request/response are correlated by `id` so multiple concurrent invokes can
71
- // be in flight at once.
72
- export const SimulatorCustomApiBridgeChannel = {
73
- Request: 'simulator:custom-apis:bridge-request',
74
- Response: 'simulator:custom-apis:bridge-response',
75
- };
71
+ // be in flight at once. The standalone runtime owns the wire contract.
72
+ export { SimulatorCustomApiBridgeChannel, } from '@dimina-kit/electron-runtime/shared/bridge-channels';
76
73
  // ── Storage (CDP-backed; main process attaches the debugger to the
77
74
  // simulator guest and forwards DOMStorage events to the renderer) ──
78
75
  export const SimulatorStorageChannel = {
@@ -1,84 +1,2 @@
1
- /**
2
- * Single authoritative implementation of wx.request network semantics, shared
3
- * by every request surface (simulator `directRequest`, preload api-compat
4
- * `wx.request` shim). Keeping the semantics in one module is what prevents the
5
- * surfaces from drifting apart on the core contract.
6
- *
7
- * The contract (official wx.request semantics):
8
- * - success vs fail is decided ONLY by whether a server response was
9
- * received. Any HTTP response — 200, 401, 500 — resolves via `success`
10
- * with `{ data, statusCode, header, errMsg: 'request:ok' }`; callers
11
- * branch on `statusCode` (e.g. 401 → re-login).
12
- * - `fail` fires only for network-layer failures and always carries a
13
- * non-empty errMsg: 'request:fail timeout' (deadline hit),
14
- * 'request:fail abort' (caller aborted), 'request:fail <reason>' (DNS/
15
- * connection/protocol errors).
16
- * - `timeout` defaults to 60000ms (the wx default) when omitted or
17
- * non-positive — a request never hangs indefinitely.
18
- * - `dataType` (default 'json') controls body decoding: 'json' attempts
19
- * JSON.parse with raw-text fallback; anything else keeps raw text.
20
- * `responseType: 'arraybuffer'` (or the legacy `dataType: 'arraybuffer'`
21
- * spelling) yields an ArrayBuffer instead.
22
- * - Outgoing headers merge case-insensitively via `Headers` so a caller's
23
- * `content-type` in any casing wins exactly once; the `application/json`
24
- * default applies only when the caller supplied none. Plain-object merges
25
- * would keep both casings as distinct keys and comma-join them on the wire.
26
- * - GET/HEAD serialize object `data` into URL query params (no body);
27
- * other methods send string data verbatim, form-encode objects under
28
- * application/x-www-form-urlencoded, and JSON-encode otherwise.
29
- * - `complete` fires exactly once, after success or fail, with that same
30
- * result object.
31
- *
32
- * Not provided: `cookies` on the success result — fetch() cannot read
33
- * Set-Cookie response headers, so surfacing a fabricated list would lie.
34
- */
35
- export interface RequestSuccessResult {
36
- data: unknown;
37
- statusCode: number;
38
- header: Record<string, string>;
39
- errMsg: 'request:ok';
40
- }
41
- export interface RequestFailResult {
42
- errMsg: string;
43
- errno?: number;
44
- }
45
- export interface RequestHandle {
46
- abort(): void;
47
- }
48
- export interface RequestCoreOptions {
49
- url: string;
50
- data?: unknown;
51
- header?: Record<string, string>;
52
- timeout?: number;
53
- method?: string;
54
- dataType?: string;
55
- responseType?: string;
56
- }
57
- export interface RequestCoreCallbacks {
58
- success?: (res: RequestSuccessResult) => void;
59
- fail?: (err: RequestFailResult) => void;
60
- complete?: (res: RequestSuccessResult | RequestFailResult) => void;
61
- }
62
- /**
63
- * The wx.request default timeout budget. Exported as the single source of
64
- * truth for every layer that reasons about a request's time budget — the
65
- * bridge-router watchdog (apiCallWatchdogMs in simulator-api-metadata.ts)
66
- * derives its window from this so the two cannot drift apart.
67
- */
68
- export declare const DEFAULT_REQUEST_TIMEOUT_MS = 60000;
69
- /**
70
- * Largest delay setTimeout honours (2^31-1 ms). Anything above overflows the
71
- * signed-32-bit timer register and fires ~immediately (~1ms) instead of late —
72
- * so an oversized caller timeout must be rejected, never passed through.
73
- */
74
- export declare const MAX_TIMEOUT_MS = 2147483647;
75
- /**
76
- * Resolve a caller-supplied wx timeout into a usable budget: a finite positive
77
- * number within setTimeout's range is honoured; anything else (absent, 0,
78
- * negative, NaN, Infinity, overflowing) falls back to the wx default. Shared
79
- * by performRequest and the bridge-router watchdog (apiCallWatchdogMs) so the
80
- * two layers can never disagree on what a valid timeout is.
81
- */
82
- export declare function resolveTimeoutBudgetMs(timeout: unknown): number;
83
- export declare function performRequest(opts: RequestCoreOptions, callbacks: RequestCoreCallbacks): RequestHandle;
1
+ export * from '@dimina-kit/electron-runtime/shared/request-core';
84
2
  //# sourceMappingURL=request-core.d.ts.map