@dimina-kit/devtools 0.4.0-dev.20260703101348 → 0.4.0-dev.20260706064107

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.
@@ -11,6 +11,7 @@ import { isAppQuitting } from './lifecycle.js';
11
11
  import { resolveNativeAppDataKeys, resolveNativeStorageOverview } from './native-overview.js';
12
12
  // eslint-disable-next-line no-restricted-syntax -- grandfathered(workbench-context): shrink-only
13
13
  import { createWorkbenchContext } from '../services/workbench-context.js';
14
+ import { setupCompileWorkerStandby } from '../services/compile-standby.js';
14
15
  import { loadWorkbenchSettings, applyTheme } from '../services/settings/index.js';
15
16
  import { installAppMenu } from '../menu/index.js';
16
17
  import { registerAppIpc, popoverModule, projectsModule, sessionModule, settingsModule, simulatorModule, } from '../ipc/index.js';
@@ -369,6 +370,11 @@ export async function createDevtoolsRuntime(config = {}) {
369
370
  // backgroundColor on theme change — windows otherwise keep the stale
370
371
  // creation-time color (see installThemeBackgroundSync).
371
372
  context.registry.add(installThemeBackgroundSync());
373
+ // Warm-standby compile worker: only meaningful for the devkit-backed
374
+ // default adapter (a host-injected adapter has no devkit fork to adopt the
375
+ // spare). Registered into the registry so the spare dies with the context.
376
+ if (!config.adapter)
377
+ context.registry.add(setupCompileWorkerStandby(context));
372
378
  registerBuiltinModules(config, context);
373
379
  // Wire the simulator-side difile:// protocol handler + temp-file IPC
374
380
  // before host onSetup so any host-driven simulator boot sees the
@@ -4391,6 +4391,55 @@ function createWorkbenchContext(opts) {
4391
4391
  return ctx;
4392
4392
  }
4393
4393
 
4394
+ // src/main/services/compile-standby.ts
4395
+ var EVENT_SEVERITY = {
4396
+ "spawned": "info",
4397
+ "prewarmed": "info",
4398
+ "adopted": "info",
4399
+ "died": "warn",
4400
+ "health-check-failed": "warn",
4401
+ "degraded": "error"
4402
+ };
4403
+ function setupCompileWorkerStandby(ctx, deps = {}) {
4404
+ const loadDevkit = deps.loadDevkit ?? (() => import("@dimina-kit/devkit"));
4405
+ let manager = null;
4406
+ let disposed = false;
4407
+ const forward = (ev) => {
4408
+ try {
4409
+ const detail = [
4410
+ `compile standby ${ev.type}`,
4411
+ typeof ev.pid === "number" ? `pid=${ev.pid}` : null,
4412
+ ev.reason ? `\u2014 ${ev.reason}` : null
4413
+ ].filter(Boolean).join(" ");
4414
+ ctx.diagnostics?.report({
4415
+ severity: EVENT_SEVERITY[ev.type] ?? "info",
4416
+ code: "compile-standby",
4417
+ message: detail
4418
+ });
4419
+ } catch {
4420
+ }
4421
+ };
4422
+ void (async () => {
4423
+ let enable;
4424
+ try {
4425
+ const devkit = await loadDevkit();
4426
+ enable = devkit.enableCompileWorkerStandby;
4427
+ } catch {
4428
+ return;
4429
+ }
4430
+ if (typeof enable !== "function") return;
4431
+ manager = enable({ onEvent: forward });
4432
+ if (disposed) void manager.dispose();
4433
+ })();
4434
+ return {
4435
+ dispose: async () => {
4436
+ if (disposed) return;
4437
+ disposed = true;
4438
+ await manager?.dispose();
4439
+ }
4440
+ };
4441
+ }
4442
+
4394
4443
  // src/main/menu/index.ts
4395
4444
  import { Menu } from "electron";
4396
4445
  function installAppMenu(ctx) {
@@ -11379,6 +11428,7 @@ async function createDevtoolsRuntime(config = {}) {
11379
11428
  context.registry.add(registerProjectFsIpc(context));
11380
11429
  context.registry.add(setupSimulatorSessionPolicy());
11381
11430
  context.registry.add(installThemeBackgroundSync());
11431
+ if (!config.adapter) context.registry.add(setupCompileWorkerStandby(context));
11382
11432
  registerBuiltinModules(config, context);
11383
11433
  const simSession = session4.fromPartition(SHARED_MINIAPP_PARTITION);
11384
11434
  context.registry.add(setupSimulatorTempFiles(simSession));
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Wires devkit's warm-standby compile worker into the devtools runtime.
3
+ *
4
+ * While no project is open, devkit keeps one project-agnostic compile worker
5
+ * forked + prewarmed; every openProject adopts it so the first compile skips
6
+ * fork + compiler import (~1.6s). This module owns exactly the glue devtools
7
+ * needs on top: turn the accelerator on at boot, mirror its lifecycle events
8
+ * onto the diagnostics bus (a user-machine bug report then carries the whole
9
+ * standby story), and shut it down with the context.
10
+ *
11
+ * Failure-transparent by design: if devkit is missing or predates the standby
12
+ * API, the accelerator silently stays off — compilation itself is untouched
13
+ * (the adapter falls back to devkit's normal cold-fork path, or the host runs
14
+ * its own adapter entirely).
15
+ */
16
+ import type { DiagnosticsBus } from './diagnostics/index.js';
17
+ export interface CompileStandbyDeps {
18
+ /** Test hook: replaces the dynamic import('@dimina-kit/devkit'). */
19
+ loadDevkit?: () => Promise<unknown>;
20
+ }
21
+ export declare function setupCompileWorkerStandby(ctx: {
22
+ diagnostics?: DiagnosticsBus;
23
+ }, deps?: CompileStandbyDeps): {
24
+ dispose: () => Promise<void>;
25
+ };
26
+ //# sourceMappingURL=compile-standby.d.ts.map
@@ -0,0 +1,57 @@
1
+ const EVENT_SEVERITY = {
2
+ 'spawned': 'info',
3
+ 'prewarmed': 'info',
4
+ 'adopted': 'info',
5
+ 'died': 'warn',
6
+ 'health-check-failed': 'warn',
7
+ 'degraded': 'error',
8
+ };
9
+ export function setupCompileWorkerStandby(ctx, deps = {}) {
10
+ const loadDevkit = deps.loadDevkit ?? (() => import('@dimina-kit/devkit'));
11
+ let manager = null;
12
+ let disposed = false;
13
+ const forward = (ev) => {
14
+ try {
15
+ const detail = [
16
+ `compile standby ${ev.type}`,
17
+ typeof ev.pid === 'number' ? `pid=${ev.pid}` : null,
18
+ ev.reason ? `— ${ev.reason}` : null,
19
+ ].filter(Boolean).join(' ');
20
+ ctx.diagnostics?.report({
21
+ severity: EVENT_SEVERITY[ev.type] ?? 'info',
22
+ code: 'compile-standby',
23
+ message: detail,
24
+ });
25
+ }
26
+ catch {
27
+ // telemetry must never break the standby
28
+ }
29
+ };
30
+ void (async () => {
31
+ let enable;
32
+ try {
33
+ const devkit = await loadDevkit();
34
+ enable = devkit.enableCompileWorkerStandby;
35
+ }
36
+ catch {
37
+ // devkit unavailable — the accelerator quietly stays off.
38
+ return;
39
+ }
40
+ if (typeof enable !== 'function')
41
+ return;
42
+ manager = enable({ onEvent: forward });
43
+ // A teardown that raced the async load wins: the manager is disposed the
44
+ // moment it exists, so a quitting app can never leak a fresh spare.
45
+ if (disposed)
46
+ void manager.dispose();
47
+ })();
48
+ return {
49
+ dispose: async () => {
50
+ if (disposed)
51
+ return;
52
+ disposed = true;
53
+ await manager?.dispose();
54
+ },
55
+ };
56
+ }
57
+ //# sourceMappingURL=compile-standby.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dimina-kit/devtools",
3
- "version": "0.4.0-dev.20260703101348",
3
+ "version": "0.4.0-dev.20260706064107",
4
4
  "description": "Dimina DevTools - modular developer tools for mini app debugging",
5
5
  "keywords": [
6
6
  "dimina",
@@ -85,9 +85,9 @@
85
85
  "chrome-remote-interface": "^0.34.0",
86
86
  "ws": "^8.20.0",
87
87
  "zod": "^4.3.6",
88
- "@dimina-kit/devkit": "0.1.2-dev.20260703101348",
89
- "@dimina-kit/view-anchor": "0.1.0-dev.20260703101348",
90
- "@dimina-kit/electron-deck": "0.1.0-dev.20260703101348"
88
+ "@dimina-kit/electron-deck": "0.1.0-dev.20260706064107",
89
+ "@dimina-kit/view-anchor": "0.1.0-dev.20260706064107",
90
+ "@dimina-kit/devkit": "0.1.2-dev.20260706064107"
91
91
  },
92
92
  "devDependencies": {
93
93
  "@playwright/test": "^1.59.1",
@@ -131,9 +131,9 @@
131
131
  "typescript": "5.9.2",
132
132
  "vite": "^8.0.8",
133
133
  "vitest": "^4.1.4",
134
- "@dimina-kit/workbench": "0.1.0",
135
134
  "@dimina-kit/eslint-config": "0.1.0",
136
- "@dimina-kit/typescript-config": "0.1.0"
135
+ "@dimina-kit/typescript-config": "0.1.0",
136
+ "@dimina-kit/workbench": "0.1.0"
137
137
  },
138
138
  "peerDependencies": {
139
139
  "electron": ">=36"
@@ -157,7 +157,7 @@
157
157
  "build:core": "pnpm --filter @dimina-kit/devkit build",
158
158
  "check-types": "tsc --noEmit",
159
159
  "lint": "eslint . --max-warnings 0",
160
- "test": "vitest run",
160
+ "test": "vitest run --reporter=default --reporter=json --outputFile.json=test-report.json --coverage.enabled --coverage.reporter=json-summary --coverage.reportsDirectory=coverage",
161
161
  "test:dev": "vitest",
162
162
  "test:coverage": "vitest run --coverage",
163
163
  "test:e2e": "playwright test",