@dimina-kit/devtools 0.3.2-dev.20260524104239 → 0.3.2-dev.20260525152421

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.
@@ -1,5 +1,5 @@
1
- import { setupCdpPort } from './bootstrap.js';
2
- import { app, BrowserWindow, nativeImage } from 'electron';
1
+ import { setupCdpPort, registerDifileScheme } from './bootstrap.js';
2
+ import { app, BrowserWindow, nativeImage, session } from 'electron';
3
3
  import fs from 'fs';
4
4
  import path from 'path';
5
5
  import { rendererDir as defaultRendererDir, defaultPreloadPath } from '../utils/paths.js';
@@ -13,6 +13,7 @@ import { registerAppIpc, popoverModule, projectsModule, sessionModule, settingsM
13
13
  import { startAutomationServer } from '../services/automation/index.js';
14
14
  import { startMcpServer } from '../services/mcp/index.js';
15
15
  import { setupSimulatorStorage } from '../services/simulator-storage/index.js';
16
+ import { setupSimulatorTempFiles } from '../services/simulator-temp-files/index.js';
16
17
  import { UpdateManager } from '../services/update/index.js';
17
18
  import { toDisposable } from '../utils/disposable.js';
18
19
  import { IpcRegistry } from '../utils/ipc-registry.js';
@@ -259,6 +260,9 @@ export function createWorkbenchApp(config = {}) {
259
260
  let setupPromise = null;
260
261
  let appEventsRegistered = false;
261
262
  setupCdpPort();
263
+ // Privileged scheme registration must run before `app.whenReady` —
264
+ // registering it later throws.
265
+ registerDifileScheme();
262
266
  async function setup() {
263
267
  if (setupPromise)
264
268
  return setupPromise;
@@ -273,6 +277,13 @@ export function createWorkbenchApp(config = {}) {
273
277
  // creation-time color (see installThemeBackgroundSync).
274
278
  context.registry.add(installThemeBackgroundSync());
275
279
  registerBuiltinModules(config, context);
280
+ // Wire the simulator-side difile:// protocol handler + temp-file IPC
281
+ // before host onSetup so any host-driven simulator boot sees the
282
+ // protocol live. The module installs its own narrow sender-policy
283
+ // (simulator-session-only) — see file header — because the default
284
+ // workbench policy intentionally rejects the simulator <webview>.
285
+ const simSession = session.fromPartition('persist:simulator');
286
+ context.registry.add(setupSimulatorTempFiles(simSession));
276
287
  installMenu(config, mainWindow, context);
277
288
  // Gated custom-IPC surface for the host. Bound to ctx.senderPolicy so
278
289
  // host channels go through the same gateway as built-in IPC, and
@@ -1,3 +1,12 @@
1
+ /**
2
+ * Register `difile://` as a privileged scheme so `simSession.protocol.handle`
3
+ * can serve `difile://devtools/{uuid}` URLs from the simulator webview without
4
+ * tripping CSP / fetch-API restrictions. Must be called before `app.whenReady`.
5
+ *
6
+ * Idempotent — subsequent calls are no-ops because Electron throws if the same
7
+ * scheme is registered twice.
8
+ */
9
+ export declare function registerDifileScheme(): void;
1
10
  /**
2
11
  * Suppress EPIPE errors on stdout/stderr.
3
12
  * Call at the very top of your entry file, before any imports that may write.
@@ -1,6 +1,33 @@
1
- import { app } from 'electron';
1
+ import { app, protocol } from 'electron';
2
2
  import { DEFAULT_CDP_PORT } from '../../shared/constants.js';
3
3
  import { loadWorkbenchSettings } from '../services/settings/index.js';
4
+ let difileSchemeRegistered = false;
5
+ /**
6
+ * Register `difile://` as a privileged scheme so `simSession.protocol.handle`
7
+ * can serve `difile://devtools/{uuid}` URLs from the simulator webview without
8
+ * tripping CSP / fetch-API restrictions. Must be called before `app.whenReady`.
9
+ *
10
+ * Idempotent — subsequent calls are no-ops because Electron throws if the same
11
+ * scheme is registered twice.
12
+ */
13
+ export function registerDifileScheme() {
14
+ if (difileSchemeRegistered)
15
+ return;
16
+ difileSchemeRegistered = true;
17
+ protocol.registerSchemesAsPrivileged([
18
+ {
19
+ scheme: 'difile',
20
+ privileges: {
21
+ standard: true,
22
+ secure: true,
23
+ supportFetchAPI: true,
24
+ stream: true,
25
+ bypassCSP: true,
26
+ corsEnabled: true,
27
+ },
28
+ },
29
+ ]);
30
+ }
4
31
  /**
5
32
  * Suppress EPIPE errors on stdout/stderr.
6
33
  * Call at the very top of your entry file, before any imports that may write.