@dimina-kit/devtools 0.3.2-dev.20260522110734 → 0.3.2-dev.20260522142649

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 (54) hide show
  1. package/README.md +90 -155
  2. package/dist/main/api.d.ts +3 -11
  3. package/dist/main/api.js +2 -13
  4. package/dist/main/app/app.d.ts +14 -1
  5. package/dist/main/app/app.js +93 -2
  6. package/dist/main/index.bundle.js +140 -52
  7. package/dist/main/ipc/app.d.ts +1 -1
  8. package/dist/main/ipc/app.js +3 -0
  9. package/dist/main/ipc/simulator.d.ts +1 -1
  10. package/dist/main/ipc/simulator.js +2 -3
  11. package/dist/main/ipc/toolbar.d.ts +1 -1
  12. package/dist/main/ipc/toolbar.js +14 -4
  13. package/dist/main/services/layout/index.d.ts +4 -10
  14. package/dist/main/services/layout/index.js +11 -19
  15. package/dist/main/services/module.d.ts +1 -2
  16. package/dist/main/services/simulator/custom-apis.d.ts +0 -1
  17. package/dist/main/services/simulator/custom-apis.js +0 -1
  18. package/dist/main/services/toolbar/toolbar-store.d.ts +23 -0
  19. package/dist/main/services/toolbar/toolbar-store.js +23 -0
  20. package/dist/main/services/views/view-manager.d.ts +6 -0
  21. package/dist/main/services/views/view-manager.js +6 -3
  22. package/dist/main/services/workbench-context.d.ts +40 -14
  23. package/dist/main/services/workbench-context.js +6 -1
  24. package/dist/main/utils/disposable.d.ts +5 -0
  25. package/dist/main/utils/disposable.js +7 -0
  26. package/dist/main/utils/ipc-registry.js +5 -1
  27. package/dist/main/utils/sender-policy.d.ts +4 -1
  28. package/dist/main/utils/sender-policy.js +6 -0
  29. package/dist/preload/runtime/custom-apis.js +72 -1
  30. package/dist/preload/windows/simulator.js +41 -1
  31. package/dist/renderer/assets/index-4lkyF644.js +46 -0
  32. package/dist/renderer/assets/{input-CoWcfa8u.js → input-D4byFOLS.js} +2 -2
  33. package/dist/renderer/assets/{ipc-transport-Cd2xPrsa.js → ipc-transport-BzPzxPwf.js} +2 -2
  34. package/dist/renderer/assets/{popover-Nq5gT9DO.js → popover-cxKrg_os.js} +2 -2
  35. package/dist/renderer/assets/{select-By5KH-UG.js → select-BgSkkdHW.js} +2 -2
  36. package/dist/renderer/assets/{settings-api-Do0_Smq1.js → settings-api-BXCw9vOZ.js} +2 -2
  37. package/dist/renderer/assets/{settings-Dj_N70qR.js → settings-oD2K1jdT.js} +2 -2
  38. package/dist/renderer/assets/{workbenchSettings-CazSLGYt.js → workbenchSettings-CTNBpTft.js} +2 -2
  39. package/dist/renderer/entries/main/index.html +4 -4
  40. package/dist/renderer/entries/popover/index.html +4 -4
  41. package/dist/renderer/entries/settings/index.html +4 -4
  42. package/dist/renderer/entries/workbench-settings/index.html +3 -3
  43. package/dist/shared/ipc-channels.d.ts +3 -2
  44. package/dist/shared/ipc-channels.js +4 -3
  45. package/dist/shared/ipc-schemas.d.ts +2 -0
  46. package/dist/shared/ipc-schemas.js +2 -0
  47. package/dist/shared/types.d.ts +55 -3
  48. package/dist/simulator/assets/simulator-CILbo0Ji.js +9 -0
  49. package/dist/simulator/simulator.html +1 -1
  50. package/package.json +3 -35
  51. package/dist/main/simulator-apis.d.ts +0 -23
  52. package/dist/main/simulator-apis.js +0 -24
  53. package/dist/renderer/assets/index-D8VFYBh-.js +0 -46
  54. package/dist/simulator/assets/simulator-CZc88Jeh.js +0 -9
@@ -10,10 +10,10 @@
10
10
  -->
11
11
  <meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob: http: https:; font-src 'self' data:; media-src 'self' blob: http: https:; connect-src 'self' http: https: ws: wss:;" />
12
12
  <title>Dimina DevTools</title>
13
- <script type="module" crossorigin src="../../assets/index-D8VFYBh-.js"></script>
14
- <link rel="modulepreload" crossorigin href="../../assets/ipc-transport-Cd2xPrsa.js">
15
- <link rel="modulepreload" crossorigin href="../../assets/input-CoWcfa8u.js">
16
- <link rel="modulepreload" crossorigin href="../../assets/select-By5KH-UG.js">
13
+ <script type="module" crossorigin src="../../assets/index-4lkyF644.js"></script>
14
+ <link rel="modulepreload" crossorigin href="../../assets/ipc-transport-BzPzxPwf.js">
15
+ <link rel="modulepreload" crossorigin href="../../assets/input-D4byFOLS.js">
16
+ <link rel="modulepreload" crossorigin href="../../assets/select-BgSkkdHW.js">
17
17
  <link rel="modulepreload" crossorigin href="../../assets/constants-DI382mTP.js">
18
18
  <link rel="stylesheet" crossorigin href="../../assets/ipc-transport-DqbRdZNO.css">
19
19
  </head>
@@ -8,10 +8,10 @@
8
8
  <style>
9
9
  html, body { margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; background: transparent !important; }
10
10
  </style>
11
- <script type="module" crossorigin src="../../assets/popover-Nq5gT9DO.js"></script>
12
- <link rel="modulepreload" crossorigin href="../../assets/ipc-transport-Cd2xPrsa.js">
13
- <link rel="modulepreload" crossorigin href="../../assets/input-CoWcfa8u.js">
14
- <link rel="modulepreload" crossorigin href="../../assets/select-By5KH-UG.js">
11
+ <script type="module" crossorigin src="../../assets/popover-cxKrg_os.js"></script>
12
+ <link rel="modulepreload" crossorigin href="../../assets/ipc-transport-BzPzxPwf.js">
13
+ <link rel="modulepreload" crossorigin href="../../assets/input-D4byFOLS.js">
14
+ <link rel="modulepreload" crossorigin href="../../assets/select-BgSkkdHW.js">
15
15
  <link rel="modulepreload" crossorigin href="../../assets/constants-DI382mTP.js">
16
16
  <link rel="stylesheet" crossorigin href="../../assets/ipc-transport-DqbRdZNO.css">
17
17
  </head>
@@ -5,10 +5,10 @@
5
5
  <!-- See main/index.html for CSP rationale. -->
6
6
  <meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob: http: https:; font-src 'self' data:; media-src 'self' blob: http: https:; connect-src 'self' http: https: ws: wss:;" />
7
7
  <title>Settings</title>
8
- <script type="module" crossorigin src="../../assets/settings-Dj_N70qR.js"></script>
9
- <link rel="modulepreload" crossorigin href="../../assets/ipc-transport-Cd2xPrsa.js">
10
- <link rel="modulepreload" crossorigin href="../../assets/input-CoWcfa8u.js">
11
- <link rel="modulepreload" crossorigin href="../../assets/settings-api-Do0_Smq1.js">
8
+ <script type="module" crossorigin src="../../assets/settings-oD2K1jdT.js"></script>
9
+ <link rel="modulepreload" crossorigin href="../../assets/ipc-transport-BzPzxPwf.js">
10
+ <link rel="modulepreload" crossorigin href="../../assets/input-D4byFOLS.js">
11
+ <link rel="modulepreload" crossorigin href="../../assets/settings-api-BXCw9vOZ.js">
12
12
  <link rel="stylesheet" crossorigin href="../../assets/ipc-transport-DqbRdZNO.css">
13
13
  </head>
14
14
  <body>
@@ -6,9 +6,9 @@
6
6
  <!-- See entries/main/index.html for CSP rationale. -->
7
7
  <meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob: http: https:; font-src 'self' data:; media-src 'self' blob: http: https:; connect-src 'self' http: https: ws: wss:;" />
8
8
  <title>开发工具设置</title>
9
- <script type="module" crossorigin src="../../assets/workbenchSettings-CazSLGYt.js"></script>
10
- <link rel="modulepreload" crossorigin href="../../assets/ipc-transport-Cd2xPrsa.js">
11
- <link rel="modulepreload" crossorigin href="../../assets/settings-api-Do0_Smq1.js">
9
+ <script type="module" crossorigin src="../../assets/workbenchSettings-CTNBpTft.js"></script>
10
+ <link rel="modulepreload" crossorigin href="../../assets/ipc-transport-BzPzxPwf.js">
11
+ <link rel="modulepreload" crossorigin href="../../assets/settings-api-BXCw9vOZ.js">
12
12
  <link rel="modulepreload" crossorigin href="../../assets/constants-DI382mTP.js">
13
13
  <link rel="stylesheet" crossorigin href="../../assets/ipc-transport-DqbRdZNO.css">
14
14
  </head>
@@ -133,8 +133,8 @@ export declare const PopoverChannel: {
133
133
  export declare const ToolbarChannel: {
134
134
  readonly GetActions: "toolbar:getActions";
135
135
  readonly ActionsChanged: "toolbar:actionsChanged";
136
- /** Prefix for dynamic action channels: `toolbar:action:${actionId}` */
137
- readonly ActionPrefix: "toolbar:action:";
136
+ /** Invoke a toolbar action by id: `invoke(Invoke, actionId)`. */
137
+ readonly Invoke: "toolbar:invoke";
138
138
  };
139
139
  export declare const WindowChannel: {
140
140
  readonly NavigateBack: "window:navigateBack";
@@ -142,6 +142,7 @@ export declare const WindowChannel: {
142
142
  export declare const AppChannel: {
143
143
  readonly GetPreloadPath: "app:getPreloadPath";
144
144
  readonly GetBranding: "app:getBranding";
145
+ readonly GetHeaderHeight: "app:getHeaderHeight";
145
146
  };
146
147
  export declare const MiniappSnapshotChannel: {
147
148
  readonly Push: "miniapp-snapshot:push";
@@ -14,7 +14,7 @@ export const SimulatorChannel = {
14
14
  Console: 'simulator:console',
15
15
  };
16
16
  // ── Custom simulator APIs (downstream-registered, main-process handlers) ──
17
- // list: simulator queries the names registered via @dimina-kit/devtools/simulator-apis.
17
+ // list: simulator queries the names registered via instance.registerSimulatorApi().
18
18
  // invoke: simulator forwards an API call to the registry; result/reject propagates.
19
19
  //
20
20
  // These are ipcMain.handle channels invoked by the **main-window renderer**
@@ -111,8 +111,8 @@ export const PopoverChannel = {
111
111
  export const ToolbarChannel = {
112
112
  GetActions: 'toolbar:getActions',
113
113
  ActionsChanged: 'toolbar:actionsChanged',
114
- /** Prefix for dynamic action channels: `toolbar:action:${actionId}` */
115
- ActionPrefix: 'toolbar:action:',
114
+ /** Invoke a toolbar action by id: `invoke(Invoke, actionId)`. */
115
+ Invoke: 'toolbar:invoke',
116
116
  };
117
117
  // ── Window ───────────────────────────────────────────────────────────────
118
118
  export const WindowChannel = {
@@ -122,6 +122,7 @@ export const WindowChannel = {
122
122
  export const AppChannel = {
123
123
  GetPreloadPath: 'app:getPreloadPath',
124
124
  GetBranding: 'app:getBranding',
125
+ GetHeaderHeight: 'app:getHeaderHeight',
125
126
  };
126
127
  // ── miniappSnapshot (unified panel snapshot framework) ───────────────────
127
128
  //
@@ -38,6 +38,8 @@ export declare const SimulatorSetVisibleSchema: z.ZodTuple<[z.ZodBoolean, z.ZodN
38
38
  * name is a non-empty bounded string (cheap DoS guard) and accept any payload.
39
39
  */
40
40
  export declare const SimulatorCustomApiInvokeSchema: z.ZodTuple<[z.ZodString, z.ZodUnknown], null>;
41
+ /** toolbar:invoke — a non-empty bounded toolbar action id. */
42
+ export declare const ToolbarInvokeSchema: z.ZodTuple<[z.ZodString], null>;
41
43
  /** project:getPages — absolute project path. */
42
44
  export declare const ProjectGetPagesSchema: z.ZodTuple<[z.ZodString], null>;
43
45
  /** project:getCompileConfig — absolute project path. */
@@ -69,6 +69,8 @@ export const SimulatorCustomApiInvokeSchema = z.tuple([
69
69
  z.string().min(1).max(256),
70
70
  z.unknown(),
71
71
  ]);
72
+ /** toolbar:invoke — a non-empty bounded toolbar action id. */
73
+ export const ToolbarInvokeSchema = z.tuple([z.string().min(1).max(256)]);
72
74
  /** project:getPages — absolute project path. */
73
75
  export const ProjectGetPagesSchema = z.tuple([AbsolutePath]);
74
76
  /** project:getCompileConfig — absolute project path. */
@@ -1,4 +1,14 @@
1
1
  import type { OpenProjectOptions } from '@dimina-kit/devkit';
2
+ import type { SimulatorApiHandler } from '../main/services/simulator/custom-apis.js';
3
+ import type { WorkbenchContext } from '../main/services/workbench-context.js';
4
+ /**
5
+ * The narrowed view of `WorkbenchContext` handed to a host `menuBuilder`.
6
+ * Strips the internal pipeline fields (`registry`, `senderPolicy`,
7
+ * `trustedWindowSenderIds`, `simulatorApis`, `toolbar`) so a menu builder can
8
+ * read menu-relevant state (workspace, views, windows, notify, appName, …)
9
+ * without reaching into devtools-internal plumbing.
10
+ */
11
+ export type MenuContext = Omit<WorkbenchContext, 'registry' | 'senderPolicy' | 'trustedWindowSenderIds' | 'simulatorApis' | 'toolbar'>;
2
12
  export interface AppInfo {
3
13
  appName?: string;
4
14
  [key: string]: unknown;
@@ -13,10 +23,24 @@ export interface CompilationAdapter {
13
23
  }
14
24
  export type BuiltinPanelId = 'wxml' | 'console' | 'appdata' | 'storage';
15
25
  export type BuiltinModuleId = 'projects' | 'session' | 'simulator' | 'popover' | 'settings';
26
+ /**
27
+ * Cross-IPC / renderer shape of a toolbar action. Carries no `handler` — the
28
+ * handler is non-serialisable and never crosses the IPC boundary.
29
+ */
16
30
  export interface ToolbarAction {
17
31
  id: string;
18
32
  label: string;
19
33
  }
34
+ /**
35
+ * Host-facing toolbar action passed to `instance.toolbar.set()`. Includes the
36
+ * `handler` (kept main-process side); only `{id,label}` is projected to the
37
+ * renderer.
38
+ */
39
+ export interface ToolbarActionInput {
40
+ id: string;
41
+ label: string;
42
+ handler: () => void | Promise<void>;
43
+ }
20
44
  export interface WorkbenchConfig {
21
45
  /** Window title, default 'Dimina DevTools' */
22
46
  appName?: string;
@@ -34,8 +58,8 @@ export interface WorkbenchConfig {
34
58
  }> | {
35
59
  appName: string;
36
60
  };
37
- /** Provider for toolbar actions shown above the compile toolbar */
38
- toolbarActions?: () => Promise<ToolbarAction[]> | ToolbarAction[];
61
+ /** Header bar height in px, used for view layout. Default 40. */
62
+ headerHeight?: number;
39
63
  }
40
64
  export interface CompileConfig {
41
65
  startPage: string;
@@ -79,6 +103,34 @@ export interface UpdateChecker {
79
103
  export interface WorkbenchHostInstance {
80
104
  mainWindow: import('electron').BrowserWindow;
81
105
  context: import('../main/services/workbench-context.js').WorkbenchContext;
106
+ /**
107
+ * Gated custom-IPC registration surface. Channels registered through this
108
+ * `IpcRegistry` are bound to `context.senderPolicy` and torn down with the
109
+ * context. This is the only supported path for host custom IPC.
110
+ */
111
+ readonly ipc: import('../main/utils/ipc-registry.js').IpcRegistry;
112
+ /**
113
+ * Adds a host-owned BrowserWindow's renderer to the trusted-sender set so
114
+ * its `instance.ipc` calls pass the gateway. The window is auto-evicted
115
+ * when it closes; the returned Disposable evicts it explicitly and is also
116
+ * registered into `context.registry` for context-scoped cleanup.
117
+ */
118
+ registerTrustedWindow(win: import('electron').BrowserWindow): import('../main/utils/disposable.js').Disposable;
119
+ /**
120
+ * Registers a simulator custom API into THIS context's registry, callable
121
+ * from mini-program code as `wx.<name>(params)`. The registration joins
122
+ * `context.registry`, so it is released when the context is disposed.
123
+ * The returned Disposable removes only the registration it created.
124
+ */
125
+ registerSimulatorApi(name: string, handler: SimulatorApiHandler): import('../main/utils/disposable.js').Disposable;
126
+ /**
127
+ * Per-context toolbar surface. `set()` atomically replaces the whole table
128
+ * of toolbar actions stored on THIS context (duplicate `id` → throws),
129
+ * then notifies the renderer to re-fetch.
130
+ */
131
+ readonly toolbar: {
132
+ set(actions: ToolbarActionInput[]): void;
133
+ };
82
134
  }
83
135
  /**
84
136
  * Pluggable backend for the project-list panel. Hosts may supply this to
@@ -127,7 +179,7 @@ export interface WorkbenchAppConfig extends WorkbenchConfig {
127
179
  /** Absolute path to a window/taskbar icon (png or ico). macOS uses the app bundle icon. */
128
180
  icon?: string;
129
181
  /** Custom menu builder. Should call Menu.setApplicationMenu(). If omitted, the default dimina-devtools menu is installed. */
130
- menuBuilder?: (mainWindow: import('electron').BrowserWindow, context: WorkbenchHostInstance['context']) => void;
182
+ menuBuilder?: (mainWindow: import('electron').BrowserWindow, menuContext: MenuContext) => void;
131
183
  /** Called after window and context are created but before start() resolves. Use to register custom IPC handlers. */
132
184
  onSetup?: (instance: WorkbenchHostInstance) => void | Promise<void>;
133
185
  /** Called before window close when a session is active. Session disposal happens automatically after this hook. */