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

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 (104) 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 +2207 -5152
  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/mcp/target-manager.js +5 -1
  22. package/dist/main/services/network-forward/index.d.ts +15 -3
  23. package/dist/main/services/network-forward/index.js +30 -4
  24. package/dist/main/services/network-forward/websocket.d.ts +36 -0
  25. package/dist/main/services/network-forward/websocket.js +120 -0
  26. package/dist/main/services/service-host-pool/pool.d.ts +1 -196
  27. package/dist/main/services/service-host-pool/pool.js +1 -363
  28. package/dist/main/services/simulator/custom-apis.d.ts +1 -42
  29. package/dist/main/services/simulator/custom-apis.js +1 -46
  30. package/dist/main/services/simulator/referer.d.ts +1 -9
  31. package/dist/main/services/simulator/referer.js +1 -19
  32. package/dist/main/services/simulator-storage/service-storage-ops.d.ts +1 -39
  33. package/dist/main/services/simulator-storage/service-storage-ops.js +1 -66
  34. package/dist/main/services/simulator-temp-files/disk.d.ts +1 -54
  35. package/dist/main/services/simulator-temp-files/disk.js +1 -237
  36. package/dist/main/services/simulator-temp-files/fs-channels.d.ts +1 -68
  37. package/dist/main/services/simulator-temp-files/fs-channels.js +1 -107
  38. package/dist/main/services/simulator-temp-files/index.d.ts +1 -32
  39. package/dist/main/services/simulator-temp-files/index.js +1 -181
  40. package/dist/main/services/simulator-temp-files/request-handler.d.ts +1 -29
  41. package/dist/main/services/simulator-temp-files/request-handler.js +1 -177
  42. package/dist/main/services/simulator-temp-files/resolver.d.ts +1 -21
  43. package/dist/main/services/simulator-temp-files/resolver.js +1 -21
  44. package/dist/main/services/simulator-temp-files/store.d.ts +1 -13
  45. package/dist/main/services/simulator-temp-files/store.js +1 -23
  46. package/dist/main/services/views/miniapp-partition.d.ts +1 -89
  47. package/dist/main/services/views/miniapp-partition.js +1 -158
  48. package/dist/main/services/views/simulator-session-policy.d.ts +1 -27
  49. package/dist/main/services/views/simulator-session-policy.js +1 -98
  50. package/dist/main/services/workbench-context.d.ts +4 -1
  51. package/dist/main/services/workbench-context.js +17 -0
  52. package/dist/main/utils/ipc-registry.d.ts +21 -3
  53. package/dist/main/utils/ipc-registry.js +26 -23
  54. package/dist/main/utils/paths.d.ts +14 -0
  55. package/dist/main/utils/paths.js +14 -0
  56. package/dist/main/windows/service-host-window/create.d.ts +1 -92
  57. package/dist/main/windows/service-host-window/create.js +1 -154
  58. package/dist/native-host/common/common.js +154 -58
  59. package/dist/native-host/container/pageFrame.css +1 -1
  60. package/dist/native-host/render/render.js +6611 -3312
  61. package/dist/native-host/service/service.js +2 -2
  62. package/dist/preload/index.d.ts +2 -0
  63. package/dist/preload/index.js +1 -0
  64. package/dist/preload/runtime/clipboard.d.ts +6 -0
  65. package/dist/preload/runtime/clipboard.js +12 -0
  66. package/dist/preload/runtime/native-host.d.ts +2 -0
  67. package/dist/preload/runtime/native-host.js +5 -10
  68. package/dist/preload/runtime/node-bindings.d.ts +18 -0
  69. package/dist/preload/runtime/node-bindings.js +44 -0
  70. package/dist/preload/windows/host-toolbar-runtime.cjs.map +2 -2
  71. package/dist/preload/windows/main.cjs +1195 -897
  72. package/dist/preload/windows/main.cjs.map +4 -4
  73. package/dist/preload/windows/simulator.cjs +149 -60
  74. package/dist/preload/windows/simulator.cjs.map +4 -4
  75. package/dist/preload/windows/simulator.js +149 -60
  76. package/dist/render-host/pageFrame.html +3 -3
  77. package/dist/shared/bridge-channels.d.ts +1 -419
  78. package/dist/shared/bridge-channels.js +1 -89
  79. package/dist/shared/dmb-resource-url.d.ts +2 -0
  80. package/dist/shared/dmb-resource-url.js +2 -0
  81. package/dist/shared/ipc-channels.d.ts +2 -32
  82. package/dist/shared/ipc-channels.js +2 -5
  83. package/dist/shared/node-bindings.d.ts +2 -0
  84. package/dist/shared/node-bindings.js +2 -0
  85. package/dist/shared/request-core.d.ts +1 -83
  86. package/dist/shared/request-core.js +1 -167
  87. package/dist/simulator/assets/device-shell-Cw7c-IkG.js +2 -0
  88. package/dist/simulator/assets/{device-shell-BHz1v3Yo.css → device-shell-DbC5ccs8.css} +1 -1
  89. package/dist/simulator/assets/{jsx-runtime-hBv-rHqQ.js → jsx-runtime-DkKmJyBb.js} +2 -2
  90. package/dist/simulator/assets/simulator-COIE6R49.js +10 -0
  91. package/dist/simulator/assets/simulator-mini-app-BLn7XV8e.js +2 -0
  92. package/dist/simulator/simulator.html +2 -2
  93. package/dist/simulator/temp-files.d.ts +29 -0
  94. package/dist/simulator/temp-files.js +79 -0
  95. package/dist/simulator/types.d.ts +43 -0
  96. package/dist/simulator/types.js +2 -0
  97. package/package.json +6 -5
  98. package/dist/shared/simulator-api-metadata.d.ts +0 -26
  99. package/dist/shared/simulator-api-metadata.js +0 -59
  100. package/dist/shared/vpath.d.ts +0 -42
  101. package/dist/shared/vpath.js +0 -105
  102. package/dist/simulator/assets/device-shell-CH_DMYaz.js +0 -2
  103. package/dist/simulator/assets/simulator-DXraYerh.js +0 -10
  104. package/dist/simulator/assets/simulator-mini-app-w1Bhwkld.js +0 -2
@@ -1,32 +1,2 @@
1
- /**
2
- * Per-app-session registry for the app-level lifecycle listeners registered
3
- * from the mini-program service layer: `wx.onAppShow` / `onAppHide` / `onError`
4
- * (and their `off*` removers).
5
- *
6
- * These arrive as keep subscriptions — `wx.onAppShow(cb)` encodes `cb` as a
7
- * persistent callback id in `params.success` (service `callback.store(fn,
8
- * keep=true)`), so the router stores the id here and re-fires it via
9
- * `sendCallback` on every app foreground / background / error.
10
- *
11
- * `wx.offAppShow(cb)` re-encodes the SAME `cb`: with `keep=true`,
12
- * `callback.store` dedups by function and returns the original evtId, so `off*`
13
- * carries that id and removes exactly that listener. `wx.offAppShow()` with no
14
- * argument carries no id and clears every listener of the event (WeChat
15
- * contract).
16
- */
17
- export type AppLifecycleEvent = 'onAppShow' | 'onAppHide' | 'onError';
18
- export interface AppLifecycleController {
19
- /** Store a keep callback id for an event. Null/undefined ids are ignored. */
20
- register(appSessionId: string, event: AppLifecycleEvent, callbackId: unknown): void;
21
- /**
22
- * Remove a listener. With `callbackId`, removes only that id; without one,
23
- * clears every listener of the event for the session.
24
- */
25
- unregister(appSessionId: string, event: AppLifecycleEvent, callbackId?: unknown): void;
26
- /** Snapshot of the registered callback ids (empty for unknown session/event). */
27
- listeners(appSessionId: string, event: AppLifecycleEvent): unknown[];
28
- /** Drop all listeners for a torn-down session. */
29
- dispose(appSessionId: string): void;
30
- }
31
- export declare function createAppLifecycleController(): AppLifecycleController;
1
+ export * from '@dimina-kit/electron-runtime/main/app-lifecycle';
32
2
  //# sourceMappingURL=app-lifecycle.d.ts.map
@@ -1,54 +1,2 @@
1
- /**
2
- * Per-app-session registry for the app-level lifecycle listeners registered
3
- * from the mini-program service layer: `wx.onAppShow` / `onAppHide` / `onError`
4
- * (and their `off*` removers).
5
- *
6
- * These arrive as keep subscriptions — `wx.onAppShow(cb)` encodes `cb` as a
7
- * persistent callback id in `params.success` (service `callback.store(fn,
8
- * keep=true)`), so the router stores the id here and re-fires it via
9
- * `sendCallback` on every app foreground / background / error.
10
- *
11
- * `wx.offAppShow(cb)` re-encodes the SAME `cb`: with `keep=true`,
12
- * `callback.store` dedups by function and returns the original evtId, so `off*`
13
- * carries that id and removes exactly that listener. `wx.offAppShow()` with no
14
- * argument carries no id and clears every listener of the event (WeChat
15
- * contract).
16
- */
17
- export function createAppLifecycleController() {
18
- const sessions = new Map();
19
- return {
20
- register(appSessionId, event, callbackId) {
21
- if (callbackId === undefined || callbackId === null)
22
- return;
23
- let events = sessions.get(appSessionId);
24
- if (!events) {
25
- events = new Map();
26
- sessions.set(appSessionId, events);
27
- }
28
- let ids = events.get(event);
29
- if (!ids) {
30
- ids = new Set();
31
- events.set(event, ids);
32
- }
33
- ids.add(callbackId);
34
- },
35
- unregister(appSessionId, event, callbackId) {
36
- const events = sessions.get(appSessionId);
37
- if (!events)
38
- return;
39
- if (callbackId === undefined || callbackId === null) {
40
- events.delete(event);
41
- return;
42
- }
43
- events.get(event)?.delete(callbackId);
44
- },
45
- listeners(appSessionId, event) {
46
- const ids = sessions.get(appSessionId)?.get(event);
47
- return ids ? Array.from(ids) : [];
48
- },
49
- dispose(appSessionId) {
50
- sessions.delete(appSessionId);
51
- },
52
- };
53
- }
1
+ export * from '@dimina-kit/electron-runtime/main/app-lifecycle';
54
2
  //# sourceMappingURL=app-lifecycle.js.map
@@ -1,155 +1,22 @@
1
- import type { WebContents } from 'electron';
2
- import type { NativeDeviceInfo } from '../../shared/ipc-channels.js';
3
- import type { PageStackEntry } from '../../shared/bridge-channels.js';
4
- import type { WorkbenchContext } from '../services/workbench-context.js';
5
- import type { DebugTap } from '@dimina-kit/electron-deck/main';
1
+ export * from '@dimina-kit/electron-runtime/main/bridge-router';
2
+ import { type RuntimeContext, type RuntimeEvents } from '@dimina-kit/electron-runtime/main/runtime-context';
3
+ import type { SessionRuntimeStatus, SyncStorageChange } from '@dimina-kit/electron-runtime';
4
+ import type { MessageEnvelope } from '../../shared/bridge-channels.js';
5
+ type DevtoolsBridgeContext = Omit<RuntimeContext, 'events'> & {
6
+ events?: RuntimeEvents;
7
+ notify?: {
8
+ sessionRuntimeStatus(payload: SessionRuntimeStatus): void;
9
+ };
10
+ appData?: {
11
+ evictBridge(appId: string, bridgeId: string): void;
12
+ onServiceToRender(appId: string, message: MessageEnvelope): void;
13
+ };
14
+ onServiceStorageChanged?: (appId: string, change: SyncStorageChange) => void;
15
+ };
6
16
  /**
7
- * Watchdog window a spawned session gets to reach `'running'` (root page
8
- * `domReady`) before `handleSpawn`'s launch timer reports `'launch-failed'`
9
- * with `code: 'timeout'`. Exported so tests can assert against the real
10
- * constant instead of a magic number.
17
+ * DevTools compatibility assembly. New contexts already own RuntimeEvents;
18
+ * narrow historical test/downstream contexts are upgraded here so the runtime
19
+ * package itself stays unaware of panels and renderer notifications.
11
20
  */
12
- export declare const LAUNCH_TIMEOUT_MS = 20000;
13
- /** Default timeout for a simulator-forwarded API call. */
14
- /**
15
- * Accessor over the bridge-router's private `RouterState`, stashed on
16
- * `ctx.bridge` so other main-process services (simulator-storage, automation,
17
- * appdata) can resolve live WebContents handles without owning router state.
18
- * All getters resolve fresh each call (the pre-warm pool can swap windows on
19
- * respawn, so cached handles go stale).
20
- */
21
- /**
22
- * Render-side activity worth re-reading panel data on: a page's DOM mounted
23
- * (`domReady`), the visible page changed (`activePage`), or the active page's
24
- * DOM mutated in place (`domMutated`, from the render-guest MutationObserver).
25
- * Panels that pull from the active render guest (WXML/element-inspect) subscribe
26
- * via `BridgeRouterHandle.onRenderEvent` so they can refresh without polling.
27
- */
28
- export interface RenderEvent {
29
- kind: 'domReady' | 'activePage' | 'domMutated';
30
- appId: string;
31
- bridgeId: string;
32
- /** activePage only: the now-visible page's route (bare pagePath), if known.
33
- * Lets the current-page panel push the route without a separate lookup. */
34
- pagePath?: string;
35
- }
36
- /**
37
- * Fires once per app session, the moment its hidden SERVICE HOST window's
38
- * `service.html` document has `did-finish-load`'d — i.e. `serviceWcId` is
39
- * GUARANTEED resolvable via `webContents.fromId(serviceWcId)` right now. This
40
- * is document readiness, NOT mini-app runtime readiness: `injectLogicBundle`
41
- * and the service's own `serviceResourceLoaded` handshake both happen AFTER
42
- * this fires (see `bootServiceHost`) — a consumer that needs "the mini-app
43
- * has actually booted" must not treat this as that signal.
44
- *
45
- * Exists so a consumer that needs to act on the service host wc THE MOMENT it
46
- * becomes resolvable (e.g. attaching the right-panel DevTools front-end) has
47
- * a real event to react to instead of polling `getServiceWc(appId)` on a
48
- * fixed retry budget and silently giving up if that budget is exhausted
49
- * before the wc resolves under load — the bug this event was added to fix
50
- * (see `native-simulator-devtools-host.ts`'s `onServiceHostReady` subscriber).
51
- *
52
- * `appId`-keyed resolution (`getServiceWc(appId)`) is NOT equivalent to this
53
- * event during same-app respawn overlap — `getServiceWc` returns the MOST
54
- * RECENT live session for that appId, which may not be the specific session
55
- * that just fired this event. Consumers that must target the EXACT session
56
- * should resolve `serviceWcId` directly rather than re-resolving by `appId`.
57
- */
58
- export interface ServiceHostReadyEvent {
59
- appId: string;
60
- appSessionId: string;
61
- serviceWcId: number;
62
- }
63
- /**
64
- * Point-in-time counts of every resource class RouterState owns. Leak coverage
65
- * (unit + e2e) asserts EXACT equality of this ledger around a churn cycle —
66
- * coarse memory sampling cannot see a leaked listener or a stale map entry, so
67
- * the owner of the bookkeeping reports precise counts instead.
68
- */
69
- export interface BridgeResourceCensus {
70
- appSessions: number;
71
- pageSessions: number;
72
- serviceWcBindings: number;
73
- /** Distinct live simulator webContents currently hosting ≥1 session. */
74
- simulatorWcs: number;
75
- /** Total session memberships across all simulator wcs. */
76
- simulatorWcBindings: number;
77
- renderWcBindings: number;
78
- pendingApiCalls: number;
79
- /**
80
- * `listenerCount('destroyed')` per unique live simulator wc (keyed by wc id).
81
- * One teardown hook per live session — a count above the hosted-session count
82
- * is the one-dead-listener-per-soft-reload leak class.
83
- */
84
- simulatorDestroyedListeners: Record<number, number>;
85
- }
86
- export interface BridgeRouterHandle {
87
- /** Whether native-host mode is on (main is the source of truth). */
88
- isNativeHost(): boolean;
89
- /** The render-host `<webview>` WebContents for a page bridgeId, or null. */
90
- resolveRenderWc(bridgeId: string): WebContents | null;
91
- /** The hidden service-host window WebContents for the active (or named) app. */
92
- getServiceWc(appId?: string): WebContents | null;
93
- /** The service-host window WebContents for the app that owns a page bridgeId,
94
- * or null. Lets render-side consumers (console forwarder) target the matching
95
- * app's service host even with multiple sessions open. */
96
- getServiceWcForBridge(bridgeId: string): WebContents | null;
97
- /** The visible page's render WebContents for the active (or named) app. */
98
- getActiveRenderWc(appId?: string): WebContents | null;
99
- /** The visible top-of-stack page bridgeId for the active (or named) app. */
100
- getActiveBridgeId(appId?: string): string | null;
101
- /** The full ordered page stack (bottom→top) reported by DeviceShell, or null
102
- * before the first PAGE_STACK signal. Optional: only the native-host bridge
103
- * provides it (the default path derives the stack from the simulator URL). */
104
- getPageStack?(appId?: string): PageStackEntry[] | null;
105
- /** The current (or named) app session's resource-server baseUrl (serves
106
- * that session's framework js/css), or null when no matching session
107
- * exists. Per-session, never a global singleton — see AppSession.resourceBaseUrl. */
108
- getResourceBaseUrl?(appId?: string): string | null;
109
- /** Subscribe to render-side activity (domReady / active-page change). */
110
- onRenderEvent(listener: (event: RenderEvent) => void): () => void;
111
- /** Subscribe to a service host's `did-finish-load` readiness (see
112
- * `ServiceHostReadyEvent`'s doc comment). A subscriber registering after
113
- * the still-live session's event already fired gets a missed-signal
114
- * catch-up — it never needs to poll. */
115
- onServiceHostReady(listener: (event: ServiceHostReadyEvent) => void): () => void;
116
- /** The currently-selected device (renderer toolbar), or null pre-selection. */
117
- getDevice(): NativeDeviceInfo | null;
118
- /** Cache the selected device + push DEVICE_CHANGE to the live simulator WC(s). */
119
- setDevice(device: NativeDeviceInfo): void;
120
- /**
121
- * Deterministically tear down every app session bound to the given simulator
122
- * WebContentsView id (project close / DeviceShell respawn). The session
123
- * mappings are cleared, the render-host guest webContents are closed, and the
124
- * service-host window is closed/released — synchronously, instead of waiting
125
- * on the WCV's async `'destroyed'` cascade — so the next project never
126
- * re-resolves or screenshots the outgoing project's render guest. Idempotent
127
- * with the `simulatorWc.once('destroyed')` hook (`disposeAppSession`
128
- * early-returns once a session is gone). Optional so partial test mocks of the
129
- * handle need not stub it.
130
- *
131
- * The synchronous prefix of the underlying disposeAppSession clears every map
132
- * + closes the render guests + the service window before it awaits, so the
133
- * bridge is clean the moment this is called. The returned promise resolves
134
- * after the async tail (pool.release / resourceServer.close) so the lifecycle
135
- * owner can sequence a reopen after full teardown. NOTE: disposeAppSession
136
- * catches and logs pool/resource-release failures internally, so the promise
137
- * resolves rather than rejecting on those — it is a completion signal, not an
138
- * error channel.
139
- */
140
- disposeSessionsForSimulator?(simulatorWcId: number): Promise<void>;
141
- /**
142
- * The router's resource ledger (see BridgeResourceCensus). Optional so the
143
- * many partial BridgeRouterHandle test mocks don't each have to stub it.
144
- */
145
- census?(): BridgeResourceCensus;
146
- /**
147
- * The flag-gated debugTap (see foundation.md) over the bridge message stream. Exposed so a
148
- * hidden devtools panel / automation can read `.entries()` when
149
- * `DIMINA_DEBUG_TAP=1`; a no-op snapshot otherwise. Optional so the many
150
- * partial `BridgeRouterHandle` test mocks don't each have to stub it.
151
- */
152
- debugTap?: DebugTap;
153
- }
154
- export declare function installBridgeRouter(ctx: WorkbenchContext): void;
21
+ export declare function installBridgeRouter(ctx: DevtoolsBridgeContext): void;
155
22
  //# sourceMappingURL=bridge-router.d.ts.map