@dimina-kit/devtools 0.3.2-dev.20260611063505 → 0.3.2-dev.20260611135124

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 (84) hide show
  1. package/README.md +53 -40
  2. package/dist/main/api.d.ts +4 -2
  3. package/dist/main/api.js +5 -1
  4. package/dist/main/app/app.d.ts +1 -5
  5. package/dist/main/app/app.js +4 -19
  6. package/dist/main/index.bundle.js +238 -392
  7. package/dist/main/ipc/app.d.ts +1 -1
  8. package/dist/main/ipc/app.js +0 -7
  9. package/dist/main/ipc/index.d.ts +0 -2
  10. package/dist/main/ipc/index.js +0 -2
  11. package/dist/main/ipc/settings.d.ts +1 -1
  12. package/dist/main/ipc/settings.js +1 -13
  13. package/dist/main/ipc/simulator-module.d.ts +3 -3
  14. package/dist/main/ipc/simulator-module.js +3 -7
  15. package/dist/main/ipc/simulator.js +1 -12
  16. package/dist/main/runtime/miniapp-runtime.d.ts +138 -28
  17. package/dist/main/runtime/miniapp-runtime.js +6 -11
  18. package/dist/main/services/layout/index.d.ts +0 -11
  19. package/dist/main/services/layout/index.js +0 -23
  20. package/dist/main/services/notifications/renderer-notifier.d.ts +0 -6
  21. package/dist/main/services/notifications/renderer-notifier.js +1 -10
  22. package/dist/main/services/service-host-pool/pool.d.ts +5 -4
  23. package/dist/main/services/views/host-toolbar-port-channel.d.ts +93 -0
  24. package/dist/main/services/views/host-toolbar-port-channel.js +169 -0
  25. package/dist/main/services/views/host-toolbar-session-runtime.d.ts +35 -0
  26. package/dist/main/services/views/host-toolbar-session-runtime.js +55 -0
  27. package/dist/main/services/views/view-manager.d.ts +68 -39
  28. package/dist/main/services/views/view-manager.js +143 -182
  29. package/dist/main/services/workbench-context.d.ts +6 -26
  30. package/dist/main/services/workbench-context.js +0 -14
  31. package/dist/main/services/workspace/workspace-service.js +7 -13
  32. package/dist/main/utils/paths.d.ts +11 -2
  33. package/dist/main/utils/paths.js +11 -2
  34. package/dist/preload/index.d.ts +15 -0
  35. package/dist/preload/index.js +15 -0
  36. package/dist/preload/runtime/host-toolbar-port.d.ts +44 -0
  37. package/dist/preload/runtime/host-toolbar-port.js +127 -0
  38. package/dist/preload/runtime/host-toolbar-runtime.d.ts +41 -0
  39. package/dist/preload/runtime/host-toolbar-runtime.js +49 -0
  40. package/dist/preload/windows/{host-toolbar.cjs → host-toolbar-runtime.cjs} +94 -3
  41. package/dist/preload/windows/host-toolbar-runtime.cjs.map +7 -0
  42. package/dist/preload/windows/host-toolbar-runtime.d.ts +2 -0
  43. package/dist/preload/windows/host-toolbar-runtime.js +13 -0
  44. package/dist/preload/windows/simulator.cjs +0 -2
  45. package/dist/preload/windows/simulator.cjs.map +2 -2
  46. package/dist/preload/windows/simulator.js +0 -2
  47. package/dist/renderer/assets/constants-DI382mTP.js +2 -0
  48. package/dist/renderer/assets/index-DLzjz1wv.js +50 -0
  49. package/dist/renderer/assets/{input-CFHmbOgz.js → input-6fpCXV-n.js} +2 -2
  50. package/dist/renderer/assets/ipc-transport-Bs8Sf1B2.css +1 -0
  51. package/dist/renderer/assets/{ipc-transport-BkKKww3u.js → ipc-transport-D22e4dv7.js} +6 -6
  52. package/dist/renderer/assets/popover-CdGdKkkc.js +2 -0
  53. package/dist/renderer/assets/select-X0sbjwdP.js +2 -0
  54. package/dist/renderer/assets/{settings-Cl4IcWnG.js → settings-CS4jYaCw.js} +2 -2
  55. package/dist/renderer/assets/settings-api-CCWTAao_.js +2 -0
  56. package/dist/renderer/assets/workbenchSettings-Bpzaj3bm.js +8 -0
  57. package/dist/renderer/entries/main/index.html +7 -6
  58. package/dist/renderer/entries/popover/index.html +6 -6
  59. package/dist/renderer/entries/settings/index.html +5 -5
  60. package/dist/renderer/entries/workbench-settings/index.html +5 -5
  61. package/dist/shared/constants.d.ts +18 -0
  62. package/dist/shared/constants.js +18 -0
  63. package/dist/shared/ipc-channels.d.ts +10 -23
  64. package/dist/shared/ipc-channels.js +13 -34
  65. package/dist/shared/ipc-schemas.d.ts +0 -12
  66. package/dist/shared/ipc-schemas.js +0 -12
  67. package/dist/shared/types.d.ts +14 -67
  68. package/package.json +6 -6
  69. package/dist/main/ipc/panels.d.ts +0 -4
  70. package/dist/main/ipc/panels.js +0 -46
  71. package/dist/main/ipc/toolbar.d.ts +0 -4
  72. package/dist/main/ipc/toolbar.js +0 -21
  73. package/dist/main/services/toolbar/toolbar-store.d.ts +0 -23
  74. package/dist/main/services/toolbar/toolbar-store.js +0 -40
  75. package/dist/preload/windows/host-toolbar.cjs.map +0 -7
  76. package/dist/preload/windows/host-toolbar.d.ts +0 -2
  77. package/dist/preload/windows/host-toolbar.js +0 -12
  78. package/dist/renderer/assets/constants-CLAQX6VZ.js +0 -2
  79. package/dist/renderer/assets/index-CZQOpCvg.js +0 -50
  80. package/dist/renderer/assets/ipc-transport-Bv_BVu4T.css +0 -1
  81. package/dist/renderer/assets/popover-h1M7n3tt.js +0 -2
  82. package/dist/renderer/assets/select-kj0n1oYf.js +0 -2
  83. package/dist/renderer/assets/settings-api-CCwo2eOi.js +0 -2
  84. package/dist/renderer/assets/workbenchSettings-BzlpQnve.js +0 -8
@@ -10,6 +10,8 @@ import { app as app2, protocol } from "electron";
10
10
  // src/shared/constants.ts
11
11
  var DEFAULT_CDP_PORT = 9222;
12
12
  var DEFAULT_SCENE = 1001;
13
+ var HEADER_H = 40;
14
+ var HOST_TOOLBAR_RUNTIME_MARKER = "--dimina-host-toolbar";
13
15
 
14
16
  // src/main/services/settings/index.ts
15
17
  import { app, nativeTheme } from "electron";
@@ -314,8 +316,6 @@ var SimulatorChannel = {
314
316
  // mini-app sees the selected device without a relaunch.
315
317
  SetDeviceInfo: "simulator:set-device-info",
316
318
  Detach: "simulator:detach",
317
- Resize: "simulator:resize",
318
- SetVisible: "simulator:setVisible",
319
319
  Console: "simulator:console",
320
320
  // Main → renderer push of the visible top-of-stack page route whenever the
321
321
  // mini-app navigates (navigateTo / switchTab / back). Payload: the page path
@@ -332,7 +332,6 @@ var ServiceHostChannel = {
332
332
  HostEnvUpdate: "service-host:host-env:update"
333
333
  };
334
334
  var SimulatorCustomApiChannel = {
335
- List: "simulator:custom-apis:list",
336
335
  Invoke: "simulator:custom-apis:invoke"
337
336
  };
338
337
  var SimulatorCustomApiBridgeChannel = {
@@ -352,9 +351,6 @@ var SimulatorElementChannel = {
352
351
  Inspect: "simulator:element:inspect",
353
352
  Clear: "simulator:element:clear"
354
353
  };
355
- var WorkbenchRuntimeChannel = {
356
- GetNativeHost: "workbench:runtime:native-host"
357
- };
358
354
  var SimulatorWxmlChannel = {
359
355
  GetSnapshot: "simulator:wxml:snapshot",
360
356
  Event: "simulator:wxml:event"
@@ -369,7 +365,6 @@ var WorkbenchSettingsChannel = {
369
365
  SetTheme: "workbenchSettings:setTheme",
370
366
  GetCdpStatus: "workbenchSettings:getCdpStatus",
371
367
  GetMcpStatus: "workbenchSettings:getMcpStatus",
372
- SetVisible: "workbenchSettings:setVisible",
373
368
  Init: "workbenchSettings:init"
374
369
  };
375
370
  var ProjectChannel = {
@@ -416,12 +411,6 @@ var ProjectsChannel = {
416
411
  var DialogChannel = {
417
412
  OpenDirectory: "dialog:openDirectory"
418
413
  };
419
- var PanelChannel = {
420
- List: "panel:list",
421
- Eval: "panel:eval",
422
- Select: "panel:select",
423
- SelectSimulator: "panel:selectSimulator"
424
- };
425
414
  var ViewChannel = {
426
415
  /** Update the simulator DevTools view's bounds (or hide if w/h = 0). */
427
416
  SimulatorDevtoolsBounds: "view:simulator:devtools-bounds",
@@ -437,6 +426,16 @@ var ViewChannel = {
437
426
  * `{ axis: 'block', extent }`. fire-and-forget (send), NOT invoke.
438
427
  */
439
428
  HostToolbarAdvertiseHeight: "view:host-toolbar:advertise-height",
429
+ /**
430
+ * main → host-toolbar WCV renderer: per-load MessagePort handshake for the
431
+ * gated narrow channel. On every toolbar `did-finish-load` main creates a
432
+ * `MessageChannelMain` and transfers port2 here
433
+ * (`wc.postMessage(HostToolbarPort, null, [port2])`); the session-resident
434
+ * toolbar runtime preload receives it via `event.ports[0]` and bridges it to
435
+ * the page as `window.diminaHostToolbar`. Envelope both directions:
436
+ * `{ channel: string, payload: unknown }`.
437
+ */
438
+ HostToolbarPort: "view:host-toolbar:port",
440
439
  /**
441
440
  * main → main-window renderer: push the reserved host-toolbar height so the
442
441
  * renderer placeholder div resizes (closing the dynamic-height loop).
@@ -450,19 +449,11 @@ var PopoverChannel = {
450
449
  Closed: "popover:closed",
451
450
  Init: "popover:init"
452
451
  };
453
- var ToolbarChannel = {
454
- GetActions: "toolbar:getActions",
455
- ActionsChanged: "toolbar:actionsChanged",
456
- /** Invoke a toolbar action by id: `invoke(Invoke, actionId)`. */
457
- Invoke: "toolbar:invoke"
458
- };
459
452
  var WindowChannel = {
460
453
  NavigateBack: "window:navigateBack"
461
454
  };
462
455
  var AppChannel = {
463
- GetPreloadPath: "app:getPreloadPath",
464
- GetBranding: "app:getBranding",
465
- GetHeaderHeight: "app:getHeaderHeight"
456
+ GetBranding: "app:getBranding"
466
457
  };
467
458
  var AutomationChannel = {
468
459
  GetPort: "automation:port"
@@ -471,9 +462,7 @@ var SettingsChannel = {
471
462
  SetVisible: "settings:setVisible",
472
463
  ConfigChanged: "settings:configChanged",
473
464
  ProjectSettingsChanged: "settings:projectSettingsChanged",
474
- Init: "settings:init",
475
- Closed: "settings:closed",
476
- Changed: "settings:changed"
465
+ Init: "settings:init"
477
466
  };
478
467
  var UpdateChannel = {
479
468
  Check: "updates:check",
@@ -751,8 +740,8 @@ function registerProjectFsIpc(ctx) {
751
740
  }
752
741
 
753
742
  // src/main/app/app.ts
754
- import { app as app14, BrowserWindow as BrowserWindow7, nativeImage, session as session3 } from "electron";
755
- import fs11 from "fs";
743
+ import { app as app14, BrowserWindow as BrowserWindow7, nativeImage, session as session4 } from "electron";
744
+ import fs10 from "fs";
756
745
  import path20 from "path";
757
746
 
758
747
  // src/main/utils/paths.ts
@@ -780,9 +769,9 @@ function cjsSiblingPreloadPath(preloadPath) {
780
769
  return preloadPath.endsWith(".js") ? preloadPath.slice(0, -".js".length) + ".cjs" : preloadPath;
781
770
  }
782
771
  var mainPreloadPath = path3.join(devtoolsPackageRoot, "dist/preload/windows/main.cjs");
783
- var hostToolbarPreloadPath = path3.join(
772
+ var hostToolbarRuntimePreloadPath = path3.join(
784
773
  devtoolsPackageRoot,
785
- "dist/preload/windows/host-toolbar.cjs"
774
+ "dist/preload/windows/host-toolbar-runtime.cjs"
786
775
  );
787
776
  var simulatorDir = path3.join(devtoolsPackageRoot, "dist/simulator");
788
777
 
@@ -980,21 +969,12 @@ function createRendererNotifier(ctx) {
980
969
  windowNavigateBack() {
981
970
  sendToMain(WindowChannel.NavigateBack);
982
971
  },
983
- settingsClosed() {
984
- sendToMain(SettingsChannel.Closed);
985
- },
986
- settingsChanged(config) {
987
- sendToMain(SettingsChannel.Changed, config);
988
- },
989
972
  popoverClosed() {
990
973
  sendToMain(PopoverChannel.Closed);
991
974
  },
992
975
  popoverRelaunch(config) {
993
976
  sendToMain(PopoverChannel.Relaunch, config);
994
977
  },
995
- toolbarActionsChanged() {
996
- sendToMain(ToolbarChannel.ActionsChanged);
997
- },
998
978
  hostToolbarHeightChanged(height) {
999
979
  sendToMain(ViewChannel.HostToolbarHeightChanged, height);
1000
980
  },
@@ -1531,22 +1511,6 @@ function installElementsForward(deps) {
1531
1511
  }
1532
1512
 
1533
1513
  // src/main/services/layout/index.ts
1534
- var SPLITTER_W = 4;
1535
- function getRightX(simWidth) {
1536
- return simWidth + SPLITTER_W;
1537
- }
1538
- function computeRightPanelBounds(contentWidth, contentHeight, simWidth, headerHeight) {
1539
- const x = getRightX(simWidth);
1540
- return {
1541
- x,
1542
- y: headerHeight,
1543
- width: Math.max(1, contentWidth - x),
1544
- height: Math.max(1, contentHeight - headerHeight)
1545
- };
1546
- }
1547
- function computeSimulatorBounds(contentWidth, contentHeight, simWidth, headerHeight) {
1548
- return computeRightPanelBounds(contentWidth, contentHeight, simWidth, headerHeight);
1549
- }
1550
1514
  function computeNativeSimulatorViewParams(rect, zoomPercent) {
1551
1515
  const zoomFactor = zoomPercent / 100;
1552
1516
  return {
@@ -1664,6 +1628,118 @@ function configureMiniappSession(partition) {
1664
1628
  return sess;
1665
1629
  }
1666
1630
 
1631
+ // src/main/services/views/host-toolbar-session-runtime.ts
1632
+ import { session as session2 } from "electron";
1633
+ var refCount = 0;
1634
+ var registrationId = null;
1635
+ function acquireHostToolbarSessionRuntime() {
1636
+ if (refCount === 0) {
1637
+ registrationId = session2.defaultSession.registerPreloadScript({
1638
+ type: "frame",
1639
+ filePath: hostToolbarRuntimePreloadPath
1640
+ });
1641
+ }
1642
+ refCount++;
1643
+ }
1644
+ function releaseHostToolbarSessionRuntime() {
1645
+ if (refCount === 0) return;
1646
+ refCount--;
1647
+ if (refCount === 0 && registrationId !== null) {
1648
+ session2.defaultSession.unregisterPreloadScript(registrationId);
1649
+ registrationId = null;
1650
+ }
1651
+ }
1652
+
1653
+ // src/main/services/views/host-toolbar-port-channel.ts
1654
+ import { MessageChannelMain } from "electron";
1655
+ function createHostToolbarPortChannel(opts) {
1656
+ let activePort = null;
1657
+ let activeWc = null;
1658
+ let disposed = false;
1659
+ const handlers2 = [];
1660
+ function dispatch(data) {
1661
+ if (typeof data !== "object" || data === null) return;
1662
+ const { channel, payload } = data;
1663
+ if (typeof channel !== "string") return;
1664
+ for (const entry of [...handlers2]) {
1665
+ if (entry.channel === channel) entry.handler(payload);
1666
+ }
1667
+ }
1668
+ function dropActivePort(close) {
1669
+ const port = activePort;
1670
+ activePort = null;
1671
+ activeWc = null;
1672
+ if (close && port) {
1673
+ try {
1674
+ port.close();
1675
+ } catch {
1676
+ }
1677
+ }
1678
+ }
1679
+ function handshake(wc) {
1680
+ if (disposed) return;
1681
+ if (!opts.isCurrent(wc)) return;
1682
+ dropActivePort(true);
1683
+ const { port1, port2 } = new MessageChannelMain();
1684
+ port1.on("message", (event) => {
1685
+ dispatch(event.data);
1686
+ });
1687
+ port1.on("close", () => {
1688
+ if (activePort === port1) dropActivePort(false);
1689
+ });
1690
+ wc.postMessage(ViewChannel.HostToolbarPort, null, [port2]);
1691
+ port1.start();
1692
+ activePort = port1;
1693
+ activeWc = wc;
1694
+ }
1695
+ return {
1696
+ attach(wc) {
1697
+ wc.on("did-finish-load", () => handshake(wc));
1698
+ wc.on(
1699
+ "did-start-navigation",
1700
+ (details, _url, isInPlace, isMainFramePositional) => {
1701
+ if (activeWc !== wc) return;
1702
+ const isSameDocument = typeof details?.isSameDocument === "boolean" ? details.isSameDocument : isInPlace;
1703
+ const isMainFrame = typeof details?.isMainFrame === "boolean" ? details.isMainFrame : isMainFramePositional;
1704
+ if (isSameDocument || !isMainFrame) return;
1705
+ dropActivePort(true);
1706
+ }
1707
+ );
1708
+ wc.on("destroyed", () => {
1709
+ if (activeWc === wc) dropActivePort(true);
1710
+ });
1711
+ },
1712
+ invalidate() {
1713
+ dropActivePort(true);
1714
+ },
1715
+ onMessage(channel, handler) {
1716
+ if (typeof channel !== "string" || channel === "") {
1717
+ throw new TypeError(
1718
+ "hostToolbar.onMessage: channel must be a non-empty string"
1719
+ );
1720
+ }
1721
+ const entry = { channel, handler };
1722
+ handlers2.push(entry);
1723
+ return {
1724
+ dispose() {
1725
+ const i = handlers2.indexOf(entry);
1726
+ if (i >= 0) handlers2.splice(i, 1);
1727
+ }
1728
+ };
1729
+ },
1730
+ send(channel, payload) {
1731
+ if (!activePort) return false;
1732
+ activePort.postMessage({ channel, payload });
1733
+ return true;
1734
+ },
1735
+ dispose() {
1736
+ disposed = true;
1737
+ dropActivePort(true);
1738
+ handlers2.length = 0;
1739
+ }
1740
+ };
1741
+ }
1742
+
1667
1743
  // src/shared/simulator-route.ts
1668
1744
  function decodePageSpec(value) {
1669
1745
  const qIdx = value.indexOf("?");
@@ -1701,7 +1777,6 @@ function parseRoute(url) {
1701
1777
 
1702
1778
  // src/main/services/views/view-manager.ts
1703
1779
  function createViewManager(ctx) {
1704
- const headerHeight = ctx.headerHeight ?? 40;
1705
1780
  const safeArea = createSafeAreaController({ connections: ctx.connections });
1706
1781
  let simulatorView = null;
1707
1782
  let simulatorViewAdded = false;
@@ -1713,7 +1788,6 @@ function createViewManager(ctx) {
1713
1788
  let settingsView = null;
1714
1789
  let settingsViewAdded = false;
1715
1790
  let popoverView = null;
1716
- let lastSimWidth = 375;
1717
1791
  let simulatorWebContentsId = null;
1718
1792
  let nativeDevtoolsSourceWc = null;
1719
1793
  let unsubscribeNativeRenderEvents = null;
@@ -1724,6 +1798,11 @@ function createViewManager(ctx) {
1724
1798
  let hostToolbarView = null;
1725
1799
  let hostToolbarPreloadOverride = null;
1726
1800
  let hostToolbarViewAdded = false;
1801
+ let hostToolbarRuntimeAcquired = false;
1802
+ let hostToolbarHeightMode = "auto";
1803
+ const hostToolbarPort = createHostToolbarPortChannel({
1804
+ isCurrent: (wc) => liveHostToolbarWebContents() === wc
1805
+ });
1727
1806
  function destroyViewInternal(view) {
1728
1807
  if (!view) return;
1729
1808
  if (!ctx.windows.mainWindow.isDestroyed()) {
@@ -1739,17 +1818,6 @@ function createViewManager(ctx) {
1739
1818
  } catch {
1740
1819
  }
1741
1820
  }
1742
- function applySimulatorBounds(simWidth) {
1743
- if (!simulatorView || ctx.windows.mainWindow.isDestroyed()) return;
1744
- if (simulatorBoundsOverride) {
1745
- simulatorView.setBounds(simulatorBoundsOverride);
1746
- return;
1747
- }
1748
- const [w = 0, h = 0] = ctx.windows.mainWindow.getContentSize();
1749
- simulatorView.setBounds(
1750
- computeSimulatorBounds(w, h, simWidth, headerHeight)
1751
- );
1752
- }
1753
1821
  function isHidden(b) {
1754
1822
  return b.width <= 0 || b.height <= 0;
1755
1823
  }
@@ -1773,8 +1841,13 @@ function createViewManager(ctx) {
1773
1841
  }
1774
1842
  simulatorView.setBounds(bounds);
1775
1843
  }
1844
+ function liveHostToolbarWebContents() {
1845
+ const wc = hostToolbarView?.webContents;
1846
+ if (!wc || wc.isDestroyed()) return null;
1847
+ return wc;
1848
+ }
1776
1849
  function ensureHostToolbarView() {
1777
- if (hostToolbarView && !hostToolbarView.webContents.isDestroyed()) {
1850
+ if (hostToolbarView && liveHostToolbarWebContents()) {
1778
1851
  return hostToolbarView;
1779
1852
  }
1780
1853
  if (hostToolbarView && hostToolbarViewAdded) {
@@ -1784,21 +1857,22 @@ function createViewManager(ctx) {
1784
1857
  }
1785
1858
  hostToolbarViewAdded = false;
1786
1859
  }
1787
- const view = new WebContentsView2({
1788
- webPreferences: {
1789
- nodeIntegration: false,
1790
- contextIsolation: true,
1791
- sandbox: false,
1792
- // Default: the reverse size-advertiser preload that measures the host
1793
- // content's intrinsic height and posts it on the advertise channel so
1794
- // main reserves exactly that strip height (dynamic height via
1795
- // ViewAnchor). When the host-shell supplies its own toolbar preload
1796
- // (workbench config.toolbar.preloadPath), use that instead — the host
1797
- // owns the bridge and may install the advertiser itself.
1798
- preload: hostToolbarPreloadOverride ?? hostToolbarPreloadPath
1799
- }
1800
- });
1860
+ if (!hostToolbarRuntimeAcquired) {
1861
+ acquireHostToolbarSessionRuntime();
1862
+ hostToolbarRuntimeAcquired = true;
1863
+ }
1864
+ const webPreferences = {
1865
+ nodeIntegration: false,
1866
+ contextIsolation: true,
1867
+ sandbox: false,
1868
+ additionalArguments: [HOST_TOOLBAR_RUNTIME_MARKER]
1869
+ };
1870
+ if (hostToolbarPreloadOverride !== null) {
1871
+ webPreferences.preload = hostToolbarPreloadOverride;
1872
+ }
1873
+ const view = new WebContentsView2({ webPreferences });
1801
1874
  hostToolbarView = view;
1875
+ hostToolbarPort.attach(view.webContents);
1802
1876
  try {
1803
1877
  view.setBackgroundColor("#121212");
1804
1878
  } catch {
@@ -1812,7 +1886,7 @@ function createViewManager(ctx) {
1812
1886
  function setHostToolbarBounds(bounds) {
1813
1887
  if (ctx.windows.mainWindow.isDestroyed()) return;
1814
1888
  if (isHidden(bounds)) {
1815
- if (hostToolbarView && hostToolbarViewAdded && !hostToolbarView.webContents.isDestroyed()) {
1889
+ if (hostToolbarView && hostToolbarViewAdded && liveHostToolbarWebContents()) {
1816
1890
  try {
1817
1891
  ctx.windows.mainWindow.contentView.removeChildView(hostToolbarView);
1818
1892
  } catch {
@@ -1829,6 +1903,7 @@ function createViewManager(ctx) {
1829
1903
  view.setBounds(bounds);
1830
1904
  }
1831
1905
  function setHostToolbarHeight(extent) {
1906
+ if (hostToolbarHeightMode !== "auto") return;
1832
1907
  ctx.notify.hostToolbarHeightChanged(extent);
1833
1908
  }
1834
1909
  function hideHostToolbar() {
@@ -1844,33 +1919,45 @@ function createViewManager(ctx) {
1844
1919
  const hostToolbar = {
1845
1920
  async loadURL(url) {
1846
1921
  const view = ensureHostToolbarView();
1922
+ hostToolbarPort.invalidate();
1847
1923
  await view.webContents.loadURL(url);
1848
1924
  },
1849
1925
  async loadFile(filePath) {
1850
1926
  const view = ensureHostToolbarView();
1927
+ hostToolbarPort.invalidate();
1851
1928
  await view.webContents.loadFile(filePath);
1852
1929
  },
1853
1930
  get webContents() {
1854
- if (!hostToolbarView) return null;
1855
- if (hostToolbarView.webContents.isDestroyed()) return null;
1856
- return hostToolbarView.webContents;
1931
+ return liveHostToolbarWebContents();
1857
1932
  },
1858
1933
  hide() {
1859
1934
  hideHostToolbar();
1860
1935
  },
1861
1936
  setPreloadPath(path22) {
1862
1937
  hostToolbarPreloadOverride = path22;
1938
+ },
1939
+ setHeightMode(mode) {
1940
+ hostToolbarHeightMode = mode;
1941
+ if (mode !== "auto") {
1942
+ ctx.notify.hostToolbarHeightChanged(mode.fixed);
1943
+ }
1944
+ },
1945
+ onMessage(channel, handler) {
1946
+ return hostToolbarPort.onMessage(channel, handler);
1947
+ },
1948
+ send(channel, payload) {
1949
+ return hostToolbarPort.send(channel, payload);
1863
1950
  }
1864
1951
  };
1865
1952
  function applySettingsBounds() {
1866
1953
  if (!settingsView || ctx.windows.mainWindow.isDestroyed()) return;
1867
1954
  const [w = 0, h = 0] = ctx.windows.mainWindow.getContentSize();
1868
- settingsView.setBounds(computeSettingsBounds(w, h, headerHeight));
1955
+ settingsView.setBounds(computeSettingsBounds(w, h, HEADER_H));
1869
1956
  }
1870
1957
  function applyPopoverBounds() {
1871
1958
  if (!popoverView || ctx.windows.mainWindow.isDestroyed()) return;
1872
1959
  const [w = 0, h = 0] = ctx.windows.mainWindow.getContentSize();
1873
- popoverView.setBounds(computePopoverBounds(w, h, headerHeight));
1960
+ popoverView.setBounds(computePopoverBounds(w, h, HEADER_H));
1874
1961
  }
1875
1962
  function clearNativeDevtoolsRetry() {
1876
1963
  nativeDevtoolsRetryToken++;
@@ -2031,71 +2118,10 @@ function createViewManager(ctx) {
2031
2118
  if (event.kind !== "activePage" && event.kind !== "domReady") return;
2032
2119
  followNativeDevtoolsServiceHost(event.appId);
2033
2120
  }
2034
- function attachSimulator(simWcId, simWidth) {
2035
- const sim = webContents.fromId(simWcId);
2036
- if (!sim) {
2037
- console.error("[workbench] attachSimulator \u2014 simWc not found for id", simWcId);
2038
- return;
2039
- }
2040
- lastSimWidth = simWidth;
2041
- simulatorWebContentsId = simWcId;
2042
- if (simulatorView) {
2043
- hideSimulator();
2044
- try {
2045
- if (!simulatorView.webContents.isDestroyed()) {
2046
- simulatorView.webContents.close();
2047
- }
2048
- } catch {
2049
- }
2050
- simulatorView = null;
2051
- }
2052
- simulatorView = new WebContentsView2();
2053
- sim.setDevToolsWebContents(simulatorView.webContents);
2054
- sim.openDevTools({ mode: "detach", activate: false });
2055
- const devtoolsWc = simulatorView.webContents;
2056
- customizeDevtoolsTabs(devtoolsWc);
2057
- devtoolsWc.once("dom-ready", () => {
2058
- devtoolsWc.executeJavaScript(`
2059
- (function() {
2060
- try { localStorage.setItem('panel-selectedTab', '"console"') } catch {}
2061
- let tries = 0
2062
- const timer = setInterval(() => {
2063
- tries++
2064
- try {
2065
- const UI = globalThis.UI
2066
- const vm = UI && UI.ViewManager && typeof UI.ViewManager.instance === 'function'
2067
- ? UI.ViewManager.instance()
2068
- : null
2069
- if (vm && typeof vm.showView === 'function') {
2070
- vm.showView('console')
2071
- clearInterval(timer)
2072
- return
2073
- }
2074
- } catch {}
2075
- if (tries > 80) clearInterval(timer)
2076
- }, 50)
2077
- })()
2078
- `).catch(() => {
2079
- });
2080
- });
2081
- if (getDefaultTab(ctx) === "simulator") {
2082
- if (simulatorBoundsOverride) {
2083
- if (!isHidden(simulatorBoundsOverride)) {
2084
- ctx.windows.mainWindow.contentView.addChildView(simulatorView);
2085
- simulatorViewAdded = true;
2086
- simulatorView.setBounds(simulatorBoundsOverride);
2087
- }
2088
- } else {
2089
- ctx.windows.mainWindow.contentView.addChildView(simulatorView);
2090
- simulatorViewAdded = true;
2091
- applySimulatorBounds(simWidth);
2092
- }
2093
- }
2094
- }
2095
- function attachNativeSimulatorDevtoolsHost(simWidth) {
2121
+ function attachNativeSimulatorDevtoolsHost() {
2096
2122
  stopFollowingNativeServiceHost();
2097
2123
  if (simulatorView) {
2098
- hideSimulator();
2124
+ removeSimulatorDevtoolsView();
2099
2125
  try {
2100
2126
  if (!simulatorView.webContents.isDestroyed()) {
2101
2127
  simulatorView.webContents.close();
@@ -2145,18 +2171,10 @@ function createViewManager(ctx) {
2145
2171
  `).catch(() => {
2146
2172
  });
2147
2173
  });
2148
- if (getDefaultTab(ctx) === "simulator") {
2149
- if (simulatorBoundsOverride) {
2150
- if (!isHidden(simulatorBoundsOverride)) {
2151
- ctx.windows.mainWindow.contentView.addChildView(simulatorView);
2152
- simulatorViewAdded = true;
2153
- simulatorView.setBounds(simulatorBoundsOverride);
2154
- }
2155
- } else {
2156
- ctx.windows.mainWindow.contentView.addChildView(simulatorView);
2157
- simulatorViewAdded = true;
2158
- applySimulatorBounds(simWidth);
2159
- }
2174
+ if (simulatorBoundsOverride && !isHidden(simulatorBoundsOverride)) {
2175
+ ctx.windows.mainWindow.contentView.addChildView(simulatorView);
2176
+ simulatorViewAdded = true;
2177
+ simulatorView.setBounds(simulatorBoundsOverride);
2160
2178
  }
2161
2179
  if (ctx.bridge?.isNativeHost()) {
2162
2180
  unsubscribeNativeRenderEvents = ctx.bridge.onRenderEvent(onNativeRenderEvent);
@@ -2188,12 +2206,11 @@ function createViewManager(ctx) {
2188
2206
  ipcMain2.on(SimulatorCustomApiBridgeChannel.Request, handler);
2189
2207
  ctx.connections.acquire(simWc).own(detachNativeCustomApiBridge);
2190
2208
  }
2191
- function attachNativeSimulator(simulatorUrl, simWidth) {
2209
+ function attachNativeSimulator(simulatorUrl, _simWidth) {
2192
2210
  if (!ctx.preloadPath) {
2193
2211
  console.error("[workbench] attachNativeSimulator \u2014 preloadPath unset; cannot mount native simulator");
2194
2212
  return;
2195
2213
  }
2196
- lastSimWidth = simWidth;
2197
2214
  if (nativeSimulatorView) {
2198
2215
  detachNativeCustomApiBridge();
2199
2216
  if (nativeSimulatorViewAdded) {
@@ -2285,7 +2302,7 @@ function createViewManager(ctx) {
2285
2302
  if (lastRendererRect) {
2286
2303
  setNativeSimulatorViewBounds(lastRendererRect);
2287
2304
  }
2288
- attachNativeSimulatorDevtoolsHost(simWidth);
2305
+ attachNativeSimulatorDevtoolsHost();
2289
2306
  }
2290
2307
  function detachSimulator() {
2291
2308
  stopFollowingNativeServiceHost();
@@ -2324,21 +2341,12 @@ function createViewManager(ctx) {
2324
2341
  simulatorBoundsOverride = null;
2325
2342
  lastRendererRect = null;
2326
2343
  }
2327
- function showSimulator(simWidth) {
2328
- lastSimWidth = simWidth;
2329
- if (!simulatorView) return;
2330
- if (!simulatorViewAdded) {
2331
- ctx.windows.mainWindow.contentView.addChildView(simulatorView);
2332
- simulatorViewAdded = true;
2333
- }
2334
- applySimulatorBounds(simWidth);
2335
- }
2336
- function hideSimulator() {
2344
+ function removeSimulatorDevtoolsView() {
2337
2345
  if (simulatorView && simulatorViewAdded) {
2338
2346
  try {
2339
2347
  ctx.windows.mainWindow.contentView.removeChildView(simulatorView);
2340
2348
  } catch (e) {
2341
- console.error("[workbench] hideSimulator error", e);
2349
+ console.error("[workbench] removeSimulatorDevtoolsView error", e);
2342
2350
  }
2343
2351
  simulatorViewAdded = false;
2344
2352
  }
@@ -2403,8 +2411,6 @@ function createViewManager(ctx) {
2403
2411
  }
2404
2412
  }
2405
2413
  function repositionAll() {
2406
- if (simulatorView && simulatorViewAdded)
2407
- applySimulatorBounds(lastSimWidth);
2408
2414
  if (settingsView && settingsViewAdded)
2409
2415
  applySettingsBounds();
2410
2416
  if (popoverView)
@@ -2412,9 +2418,14 @@ function createViewManager(ctx) {
2412
2418
  }
2413
2419
  function disposeAll() {
2414
2420
  detachSimulator();
2421
+ hostToolbarPort.dispose();
2415
2422
  destroyViewInternal(hostToolbarView);
2416
2423
  hostToolbarView = null;
2417
2424
  hostToolbarViewAdded = false;
2425
+ if (hostToolbarRuntimeAcquired) {
2426
+ releaseHostToolbarSessionRuntime();
2427
+ hostToolbarRuntimeAcquired = false;
2428
+ }
2418
2429
  safeArea.dispose();
2419
2430
  }
2420
2431
  function setNativeSimulatorViewBounds(params) {
@@ -2451,27 +2462,13 @@ function createViewManager(ctx) {
2451
2462
  } catch {
2452
2463
  }
2453
2464
  }
2454
- function resize(simWidth) {
2455
- lastSimWidth = simWidth;
2456
- if (simulatorViewAdded) applySimulatorBounds(simWidth);
2465
+ function resize(_simWidth) {
2457
2466
  if (settingsViewAdded) applySettingsBounds();
2458
2467
  }
2459
- function setVisible(visible, simWidth) {
2460
- lastSimWidth = simWidth;
2461
- if (!simulatorView) return;
2462
- if (visible && !simulatorViewAdded) {
2463
- showSimulator(simWidth);
2464
- } else if (!visible) {
2465
- hideSimulator();
2466
- }
2467
- }
2468
2468
  return {
2469
- attachSimulator,
2470
2469
  attachNativeSimulator,
2471
2470
  detachSimulator,
2472
2471
  reapplySafeArea: (device) => safeArea.reapplyAll(device),
2473
- showSimulator,
2474
- hideSimulator,
2475
2472
  showSettings,
2476
2473
  hideSettings,
2477
2474
  showPopover,
@@ -2484,9 +2481,6 @@ function createViewManager(ctx) {
2484
2481
  const wc = webContents.fromId(simulatorWebContentsId);
2485
2482
  return wc && !wc.isDestroyed() ? wc : null;
2486
2483
  },
2487
- getLastSimWidth: () => lastSimWidth,
2488
- isSimulatorAdded: () => simulatorViewAdded,
2489
- hasSimulatorView: () => simulatorView !== null,
2490
2484
  getSettingsWebContents: () => {
2491
2485
  if (!settingsView) return null;
2492
2486
  if (settingsView.webContents.isDestroyed()) return null;
@@ -2502,14 +2496,9 @@ function createViewManager(ctx) {
2502
2496
  if (popoverView.webContents.isDestroyed()) return null;
2503
2497
  return popoverView.webContents.id;
2504
2498
  },
2505
- getHostToolbarWebContentsId: () => {
2506
- if (!hostToolbarView) return null;
2507
- if (hostToolbarView.webContents.isDestroyed()) return null;
2508
- return hostToolbarView.webContents.id;
2509
- },
2499
+ getHostToolbarWebContentsId: () => liveHostToolbarWebContents()?.id ?? null,
2510
2500
  setNativeSimulatorViewBounds,
2511
2501
  resize,
2512
- setVisible,
2513
2502
  setSimulatorDevtoolsBounds,
2514
2503
  setHostToolbarBounds,
2515
2504
  setHostToolbarHeight,
@@ -2727,11 +2716,11 @@ function createWorkspaceService(ctx) {
2727
2716
  }
2728
2717
  async function disposeSession() {
2729
2718
  if (!currentSession) return;
2730
- const session4 = currentSession;
2719
+ const session5 = currentSession;
2731
2720
  currentSession = null;
2732
2721
  try {
2733
2722
  await Promise.race([
2734
- session4.close(),
2723
+ session5.close(),
2735
2724
  new Promise(
2736
2725
  (_, reject) => setTimeout(() => reject(new Error("session close timed out")), 5e3)
2737
2726
  )
@@ -2740,8 +2729,8 @@ function createWorkspaceService(ctx) {
2740
2729
  console.error("[workspace] session close failed:", err);
2741
2730
  }
2742
2731
  }
2743
- function applyRefererFromSession(session4) {
2744
- const appInfo = session4.appInfo;
2732
+ function applyRefererFromSession(session5) {
2733
+ const appInfo = session5.appInfo;
2745
2734
  if (appInfo && typeof appInfo.appId === "string" && appInfo.appId.length > 0) {
2746
2735
  setSimulatorServicewechatReferer(
2747
2736
  appInfo.appId,
@@ -2762,26 +2751,20 @@ function createWorkspaceService(ctx) {
2762
2751
  },
2763
2752
  validateProjectDir: async (dirPath) => provider.validateProjectDir ? provider.validateProjectDir(dirPath) : null,
2764
2753
  async openProject(projectPath) {
2754
+ clearSimulatorServicewechatReferer();
2755
+ await disposeSession();
2756
+ currentProjectPath = "";
2757
+ lastClosedProjectPath = "";
2765
2758
  const dirError = provider.validateProjectDir ? await provider.validateProjectDir(projectPath) : null;
2766
2759
  if (dirError) {
2767
2760
  sendStatus("error", dirError);
2768
2761
  return { success: false, error: dirError };
2769
2762
  }
2770
- const gate = ctx.beforeOpenProject ? await ctx.beforeOpenProject(projectPath) : void 0;
2771
- if (gate && !gate.allow) {
2772
- const message = gate.userMessage ?? gate.reason;
2773
- sendStatus("error", message);
2774
- return { success: false, error: message };
2775
- }
2776
- clearSimulatorServicewechatReferer();
2777
- await disposeSession();
2778
- currentProjectPath = "";
2779
- lastClosedProjectPath = "";
2780
2763
  sendStatus("compiling", "\u6B63\u5728\u7F16\u8BD1...");
2781
2764
  const { compile } = loadWorkbenchSettings();
2782
- let session4;
2765
+ let session5;
2783
2766
  try {
2784
- session4 = await ctx.adapter.openProject({
2767
+ session5 = await ctx.adapter.openProject({
2785
2768
  projectPath,
2786
2769
  sourcemap: true,
2787
2770
  watch: compile.watch,
@@ -2793,17 +2776,17 @@ function createWorkspaceService(ctx) {
2793
2776
  sendStatus("error", String(err));
2794
2777
  return { success: false, error: String(err) };
2795
2778
  }
2796
- currentSession = session4;
2779
+ currentSession = session5;
2797
2780
  currentProjectPath = projectPath;
2798
2781
  bestEffort("updateLastOpened", () => {
2799
2782
  if (provider.updateLastOpened) provider.updateLastOpened(projectPath);
2800
2783
  });
2801
- bestEffort("sendStatus", () => sendStatus("ready", gate?.statusMessage ?? "\u7F16\u8BD1\u5B8C\u6210"));
2802
- bestEffort("applyReferer", () => applyRefererFromSession(session4));
2784
+ bestEffort("sendStatus", () => sendStatus("ready", "\u7F16\u8BD1\u5B8C\u6210"));
2785
+ bestEffort("applyReferer", () => applyRefererFromSession(session5));
2803
2786
  return {
2804
2787
  success: true,
2805
- port: session4.port,
2806
- appInfo: session4.appInfo
2788
+ port: session5.port,
2789
+ appInfo: session5.appInfo
2807
2790
  };
2808
2791
  },
2809
2792
  async closeProject() {
@@ -2899,41 +2882,6 @@ function createLocalProjectsProvider() {
2899
2882
  };
2900
2883
  }
2901
2884
 
2902
- // src/main/services/toolbar/toolbar-store.ts
2903
- function toPublicAction(action) {
2904
- const projected = {
2905
- id: action.id,
2906
- label: action.label
2907
- };
2908
- if (action.kind) projected.kind = action.kind;
2909
- if (action.placement) projected.placement = action.placement;
2910
- if (action.icon) projected.icon = action.icon;
2911
- if (action.displayInitial) projected.displayInitial = action.displayInitial;
2912
- if (action.avatarUrl) projected.avatarUrl = action.avatarUrl;
2913
- return projected;
2914
- }
2915
- function createToolbarStore() {
2916
- let actions = [];
2917
- return {
2918
- set(next) {
2919
- const seen = /* @__PURE__ */ new Set();
2920
- for (const action of next) {
2921
- if (seen.has(action.id)) {
2922
- throw new Error(`Duplicate toolbar action id "${action.id}"`);
2923
- }
2924
- seen.add(action.id);
2925
- }
2926
- actions = next.slice();
2927
- },
2928
- list() {
2929
- return actions.map(toPublicAction);
2930
- },
2931
- getHandler(id) {
2932
- return actions.find((a) => a.id === id)?.handler;
2933
- }
2934
- };
2935
- }
2936
-
2937
2885
  // src/main/services/projects/templates.ts
2938
2886
  function resolveTemplates(builtin, injected, mode) {
2939
2887
  let kept;
@@ -2979,30 +2927,19 @@ var BUILTIN_TEMPLATES = [
2979
2927
  ];
2980
2928
 
2981
2929
  // src/main/services/workbench-context.ts
2982
- function hasBuiltinPanel(ctx, panelId) {
2983
- return ctx.panels.includes(panelId);
2984
- }
2985
- function getDefaultTab(ctx) {
2986
- if (hasBuiltinPanel(ctx, "console")) return "simulator";
2987
- if (ctx.panels.length > 0) return ctx.panels[0];
2988
- return "simulator";
2989
- }
2990
2930
  function createWorkbenchContext(opts) {
2991
2931
  const ctx = {
2992
2932
  adapter: opts.adapter ?? defaultAdapter,
2993
2933
  preloadPath: opts.preloadPath,
2994
2934
  rendererDir: opts.rendererDir,
2995
- panels: opts.panels ?? ["wxml", "console", "appdata", "storage"],
2996
2935
  apiNamespaces: opts.apiNamespaces ?? [],
2997
2936
  appName: opts.appName ?? "Dimina DevTools",
2998
- headerHeight: opts.headerHeight ?? 40,
2999
2937
  brandingProvider: opts.brandingProvider
3000
2938
  };
3001
2939
  ctx.registry = new DisposableRegistry3();
3002
2940
  ctx.connections = createConnectionRegistry();
3003
2941
  ctx.trustedWindowSenderIds = /* @__PURE__ */ new Map();
3004
2942
  ctx.simulatorApis = createSimulatorApiRegistry();
3005
- ctx.toolbar = createToolbarStore();
3006
2943
  ctx.windows = createWindowService(opts.mainWindow);
3007
2944
  ctx.views = createViewManager(ctx);
3008
2945
  ctx.notify = createRendererNotifier(ctx);
@@ -3096,15 +3033,10 @@ function installAppMenu(ctx) {
3096
3033
  }
3097
3034
 
3098
3035
  // src/main/ipc/app.ts
3099
- import fs6 from "fs";
3100
3036
  function registerAppIpc(ctx) {
3101
- return new IpcRegistry(ctx.senderPolicy).handle(AppChannel.GetPreloadPath, () => {
3102
- return `file://${fs6.realpathSync(ctx.preloadPath)}`;
3103
- }).handle(AppChannel.GetBranding, async () => {
3037
+ return new IpcRegistry(ctx.senderPolicy).handle(AppChannel.GetBranding, async () => {
3104
3038
  if (ctx.brandingProvider) return ctx.brandingProvider();
3105
3039
  return { appName: ctx.appName };
3106
- }).handle(AppChannel.GetHeaderHeight, () => {
3107
- return ctx.headerHeight;
3108
3040
  });
3109
3041
  }
3110
3042
 
@@ -3114,7 +3046,6 @@ var AbsolutePath = z2.string().min(1).refine(
3114
3046
  (p) => p.startsWith("/") || /^[a-zA-Z]:\\/.test(p) || /^[a-zA-Z]:\//.test(p),
3115
3047
  "must be an absolute path"
3116
3048
  );
3117
- var PanelEvalSchema = z2.tuple([z2.string().min(1).max(5e4)]);
3118
3049
  var ProjectsAddSchema = z2.tuple([AbsolutePath]);
3119
3050
  var ProjectOpenSchema = z2.tuple([AbsolutePath]);
3120
3051
  var CompileConfigShape = z2.looseObject({
@@ -3134,7 +3065,6 @@ var SimulatorAttachNativeSchema = z2.tuple([
3134
3065
  }),
3135
3066
  SimWidth
3136
3067
  ]);
3137
- var SimulatorResizeSchema = z2.tuple([SimWidth]);
3138
3068
  var SimulatorSetNativeBoundsSchema = z2.tuple([
3139
3069
  z2.object({
3140
3070
  x: z2.number().finite(),
@@ -3179,12 +3109,10 @@ var HostToolbarAdvertiseHeightSchema = z2.tuple([
3179
3109
  extent: NonNegInt
3180
3110
  })
3181
3111
  ]);
3182
- var SimulatorSetVisibleSchema = z2.tuple([z2.boolean(), SimWidth]);
3183
3112
  var SimulatorCustomApiInvokeSchema = z2.tuple([
3184
3113
  z2.string().min(1).max(256),
3185
3114
  z2.unknown()
3186
3115
  ]);
3187
- var ToolbarInvokeSchema = z2.tuple([z2.string().min(1).max(256)]);
3188
3116
  var ProjectGetPagesSchema = z2.tuple([AbsolutePath]);
3189
3117
  var ProjectGetCompileConfigSchema = z2.tuple([AbsolutePath]);
3190
3118
  var ProjectsRemoveSchema = z2.tuple([AbsolutePath]);
@@ -3208,7 +3136,6 @@ var WorkbenchSettingsSaveSchema = z2.tuple([
3208
3136
  var WorkbenchSettingsSetThemeSchema = z2.tuple([
3209
3137
  z2.enum(["system", "light", "dark"])
3210
3138
  ]);
3211
- var WorkbenchSettingsSetVisibleSchema = z2.tuple([z2.boolean()]);
3212
3139
  var SettingsSetVisibleSchema = z2.tuple([z2.boolean()]);
3213
3140
  var SettingsConfigChangedSchema = z2.tuple([CompileConfigShape]);
3214
3141
  var PopoverRelaunchSchema = z2.tuple([CompileConfigShape]);
@@ -3217,7 +3144,6 @@ var SettingsProjectSettingsChangedSchema = z2.tuple([
3217
3144
  uploadWithSourceMap: z2.boolean().optional()
3218
3145
  })
3219
3146
  ]);
3220
- var PanelSelectSchema = z2.tuple([z2.string().min(1).max(200)]);
3221
3147
  var ProjectCaptureThumbnailSchema = z2.tuple([AbsolutePath]);
3222
3148
  var ProjectGetThumbnailSchema = z2.tuple([AbsolutePath]);
3223
3149
 
@@ -3296,9 +3222,6 @@ function registerSimulatorIpc(ctx) {
3296
3222
  ctx.views.attachNativeSimulator(simulatorUrl, simWidth);
3297
3223
  }).handle(SimulatorChannel.Detach, () => {
3298
3224
  ctx.views.detachSimulator();
3299
- }).handle(SimulatorChannel.Resize, (_, ...args) => {
3300
- const [simWidth] = validate(SimulatorChannel.Resize, SimulatorResizeSchema, args);
3301
- ctx.views.resize(simWidth);
3302
3225
  }).handle(SimulatorChannel.SetNativeBounds, (_, ...args) => {
3303
3226
  const [p] = validate(SimulatorChannel.SetNativeBounds, SimulatorSetNativeBoundsSchema, args);
3304
3227
  ctx.views.setNativeSimulatorViewBounds(p);
@@ -3310,48 +3233,12 @@ function registerSimulatorIpc(ctx) {
3310
3233
  if (serviceWc && !serviceWc.isDestroyed()) {
3311
3234
  serviceWc.send(ServiceHostChannel.HostEnvUpdate, deviceInfoToHostEnv(device));
3312
3235
  }
3313
- }).handle(SimulatorChannel.SetVisible, (_, ...args) => {
3314
- const [visible, simWidth] = validate(SimulatorChannel.SetVisible, SimulatorSetVisibleSchema, args);
3315
- ctx.views.setVisible(visible, simWidth);
3316
- }).handle(SimulatorCustomApiChannel.List, () => {
3317
- return ctx.simulatorApis.list();
3318
3236
  }).handle(SimulatorCustomApiChannel.Invoke, (_, ...args) => {
3319
3237
  const [name, params] = validate(SimulatorCustomApiChannel.Invoke, SimulatorCustomApiInvokeSchema, args);
3320
3238
  return ctx.simulatorApis.invoke(name, params);
3321
3239
  });
3322
3240
  }
3323
3241
 
3324
- // src/main/ipc/panels.ts
3325
- var BUILTIN_PANELS = [
3326
- { id: "wxml", label: "WXML" },
3327
- { id: "appdata", label: "AppData" },
3328
- { id: "storage", label: "Storage" }
3329
- ];
3330
- function registerPanelsIpc(ctx) {
3331
- return new IpcRegistry(ctx.senderPolicy).handle(PanelChannel.List, () => {
3332
- return BUILTIN_PANELS.filter((p) => ctx.panels.includes(p.id));
3333
- }).handle(PanelChannel.Eval, async (_event, ...args) => {
3334
- const [expression] = validate(PanelChannel.Eval, PanelEvalSchema, args);
3335
- if (!ctx.workspace.hasActiveSession()) return void 0;
3336
- const sim = ctx.views.getSimulatorWebContents();
3337
- if (!sim) return void 0;
3338
- try {
3339
- return await sim.executeJavaScript(expression);
3340
- } catch {
3341
- return void 0;
3342
- }
3343
- }).handle(PanelChannel.Select, (_event, ...args) => {
3344
- validate(PanelChannel.Select, PanelSelectSchema, args);
3345
- if (ctx.views.hasSimulatorView() && ctx.views.isSimulatorAdded()) {
3346
- ctx.views.hideSimulator();
3347
- }
3348
- }).handle(PanelChannel.SelectSimulator, () => {
3349
- if (ctx.views.hasSimulatorView() && !ctx.views.isSimulatorAdded()) {
3350
- ctx.views.showSimulator(ctx.views.getLastSimWidth());
3351
- }
3352
- }).handle(WorkbenchRuntimeChannel.GetNativeHost, () => true);
3353
- }
3354
-
3355
3242
  // src/main/ipc/popover.ts
3356
3243
  function registerPopoverIpc(ctx) {
3357
3244
  return new IpcRegistry(ctx.senderPolicy).handle(PopoverChannel.Show, (_event, ...args) => {
@@ -3374,7 +3261,7 @@ import { app as app7, dialog } from "electron";
3374
3261
  import path12 from "path";
3375
3262
 
3376
3263
  // src/main/services/projects/create-project-service.ts
3377
- import fs7 from "node:fs";
3264
+ import fs6 from "node:fs";
3378
3265
  import path11 from "node:path";
3379
3266
  var DEFAULT_TEMPLATE_ID = "blank";
3380
3267
  async function createProject(input, ctx) {
@@ -3386,12 +3273,12 @@ async function createProject(input, ctx) {
3386
3273
  if (!target || typeof target !== "string") {
3387
3274
  throw new Error("Project path is required");
3388
3275
  }
3389
- if (fs7.existsSync(target)) {
3390
- const stat = fs7.statSync(target);
3276
+ if (fs6.existsSync(target)) {
3277
+ const stat = fs6.statSync(target);
3391
3278
  if (!stat.isDirectory()) {
3392
3279
  throw new Error(`Project path exists and is not a directory: ${target}`);
3393
3280
  }
3394
- const entries = fs7.readdirSync(target);
3281
+ const entries = fs6.readdirSync(target);
3395
3282
  if (entries.length > 0) {
3396
3283
  throw new Error(
3397
3284
  `Project path is not empty (refusing to overwrite): ${target}`
@@ -3408,31 +3295,31 @@ async function createProject(input, ctx) {
3408
3295
  `Template '${templateId}' has neither a source directory nor a generate function`
3409
3296
  );
3410
3297
  }
3411
- fs7.mkdirSync(target, { recursive: true });
3298
+ fs6.mkdirSync(target, { recursive: true });
3412
3299
  if (template.generate) {
3413
3300
  await template.generate(target, { name });
3414
3301
  } else if (template.source) {
3415
- if (!fs7.existsSync(template.source.path)) {
3302
+ if (!fs6.existsSync(template.source.path)) {
3416
3303
  throw new Error(
3417
3304
  `Template source missing on disk: ${template.source.path}`
3418
3305
  );
3419
3306
  }
3420
- fs7.cpSync(template.source.path, target, {
3307
+ fs6.cpSync(template.source.path, target, {
3421
3308
  recursive: true,
3422
3309
  force: true
3423
3310
  });
3424
3311
  }
3425
3312
  const cfgPath = path11.join(target, "project.config.json");
3426
3313
  let cfg = {};
3427
- if (fs7.existsSync(cfgPath)) {
3314
+ if (fs6.existsSync(cfgPath)) {
3428
3315
  try {
3429
- cfg = JSON.parse(fs7.readFileSync(cfgPath, "utf-8"));
3316
+ cfg = JSON.parse(fs6.readFileSync(cfgPath, "utf-8"));
3430
3317
  } catch {
3431
3318
  cfg = {};
3432
3319
  }
3433
3320
  }
3434
3321
  cfg.projectname = name;
3435
- fs7.writeFileSync(cfgPath, JSON.stringify(cfg, null, 2));
3322
+ fs6.writeFileSync(cfgPath, JSON.stringify(cfg, null, 2));
3436
3323
  const created = await ctx.projectsProvider.addProject(target);
3437
3324
  return created;
3438
3325
  }
@@ -3636,17 +3523,6 @@ function registerSettingsIpc(ctx) {
3636
3523
  activePort: runtime.port,
3637
3524
  error: runtime.error
3638
3525
  };
3639
- }).handle(WorkbenchSettingsChannel.SetVisible, async (_, ...args) => {
3640
- const [visible] = validate(
3641
- WorkbenchSettingsChannel.SetVisible,
3642
- WorkbenchSettingsSetVisibleSchema,
3643
- args
3644
- );
3645
- if (visible) {
3646
- await openSettingsWindow(ctx);
3647
- } else {
3648
- ctx.windows.closeSettingsWindow();
3649
- }
3650
3526
  }).handle(SettingsChannel.SetVisible, async (_, ...args) => {
3651
3527
  const [visible] = validate(SettingsChannel.SetVisible, SettingsSetVisibleSchema, args);
3652
3528
  if (visible) {
@@ -3659,7 +3535,6 @@ function registerSettingsIpc(ctx) {
3659
3535
  });
3660
3536
  } else {
3661
3537
  ctx.views.hideSettings();
3662
- ctx.notify.settingsClosed();
3663
3538
  }
3664
3539
  }).on(SettingsChannel.ConfigChanged, async (_, ...args) => {
3665
3540
  const [config] = validate(
@@ -3671,7 +3546,6 @@ function registerSettingsIpc(ctx) {
3671
3546
  if (projectPath) {
3672
3547
  await ctx.workspace.saveCompileConfig(projectPath, config);
3673
3548
  }
3674
- ctx.notify.settingsChanged(config);
3675
3549
  }).on(SettingsChannel.ProjectSettingsChanged, (_, ...args) => {
3676
3550
  const [patch] = validate(
3677
3551
  SettingsChannel.ProjectSettingsChanged,
@@ -3688,20 +3562,6 @@ var settingsModule = {
3688
3562
  setup: (ctx) => registerSettingsIpc(ctx)
3689
3563
  };
3690
3564
 
3691
- // src/main/ipc/toolbar.ts
3692
- function registerToolbarIpc(ctx) {
3693
- return new IpcRegistry(ctx.senderPolicy).handle(ToolbarChannel.GetActions, () => {
3694
- return ctx.toolbar.list();
3695
- }).handle(ToolbarChannel.Invoke, async (_, ...args) => {
3696
- const [id] = validate(ToolbarChannel.Invoke, ToolbarInvokeSchema, args);
3697
- const handler = ctx.toolbar.getHandler(id);
3698
- if (!handler) {
3699
- throw new Error(`Toolbar action "${id}" is not registered`);
3700
- }
3701
- await handler();
3702
- });
3703
- }
3704
-
3705
3565
  // src/main/ipc/simulator-module.ts
3706
3566
  import { DisposableRegistry as DisposableRegistry6 } from "@dimina-kit/electron-deck/main";
3707
3567
 
@@ -3721,7 +3581,7 @@ import { createDebugTap } from "@dimina-kit/electron-deck/main";
3721
3581
 
3722
3582
  // src/main/services/dimina-resource-server.ts
3723
3583
  import http from "node:http";
3724
- import fs8 from "node:fs";
3584
+ import fs7 from "node:fs";
3725
3585
  import path13 from "node:path";
3726
3586
  var MIME_TYPES = {
3727
3587
  ".css": "text/css; charset=utf-8",
@@ -3779,7 +3639,7 @@ async function handleRequest(root, req, res) {
3779
3639
  return;
3780
3640
  }
3781
3641
  try {
3782
- const stat = await fs8.promises.stat(filePath);
3642
+ const stat = await fs7.promises.stat(filePath);
3783
3643
  if (!stat.isFile()) {
3784
3644
  res.writeHead(404);
3785
3645
  res.end("Not Found");
@@ -3794,7 +3654,7 @@ async function handleRequest(root, req, res) {
3794
3654
  res.end();
3795
3655
  return;
3796
3656
  }
3797
- fs8.createReadStream(filePath).pipe(res);
3657
+ fs7.createReadStream(filePath).pipe(res);
3798
3658
  } catch {
3799
3659
  res.writeHead(404);
3800
3660
  res.end("Not Found");
@@ -5841,8 +5701,6 @@ var simulatorModule = {
5841
5701
  setup: (ctx) => {
5842
5702
  const reg = new DisposableRegistry6();
5843
5703
  reg.add(registerSimulatorIpc(ctx));
5844
- reg.add(registerPanelsIpc(ctx));
5845
- reg.add(registerToolbarIpc(ctx));
5846
5704
  reg.add(registerViewsIpc(ctx));
5847
5705
  installBridgeRouter(ctx);
5848
5706
  return reg;
@@ -8073,7 +7931,7 @@ function resolveVPath(url) {
8073
7931
  }
8074
7932
 
8075
7933
  // src/main/services/simulator-temp-files/disk.ts
8076
- import fs9 from "node:fs/promises";
7934
+ import fs8 from "node:fs/promises";
8077
7935
  import path18 from "node:path";
8078
7936
  var EXT_MIME = {
8079
7937
  ".txt": "text/plain",
@@ -8154,7 +8012,7 @@ function etagOf(mtimeMs, size) {
8154
8012
  return `W/"${Math.floor(mtimeMs)}-${size}"`;
8155
8013
  }
8156
8014
  async function readDiskFile(realPath, opts) {
8157
- const handle = await fs9.open(realPath, "r");
8015
+ const handle = await fs8.open(realPath, "r");
8158
8016
  try {
8159
8017
  const st = await handle.stat();
8160
8018
  const totalSize = st.size;
@@ -8209,15 +8067,15 @@ async function readDiskFile(realPath, opts) {
8209
8067
  }
8210
8068
  async function writeDiskFile(realPath, bytes) {
8211
8069
  const buf = Buffer.isBuffer(bytes) ? bytes : Buffer.from(new Uint8Array(bytes));
8212
- await fs9.mkdir(path18.dirname(realPath), { recursive: true });
8213
- await fs9.writeFile(realPath, buf);
8070
+ await fs8.mkdir(path18.dirname(realPath), { recursive: true });
8071
+ await fs8.writeFile(realPath, buf);
8214
8072
  }
8215
8073
  async function readDiskDir(realPath) {
8216
- const entries = await fs9.readdir(realPath);
8074
+ const entries = await fs8.readdir(realPath);
8217
8075
  return entries;
8218
8076
  }
8219
8077
  async function statDiskFile(realPath) {
8220
- const st = await fs9.stat(realPath);
8078
+ const st = await fs8.stat(realPath);
8221
8079
  return {
8222
8080
  size: st.size,
8223
8081
  mtime: Math.floor(st.mtimeMs),
@@ -8350,14 +8208,14 @@ async function handleDifileRequest(ctx, req) {
8350
8208
  }
8351
8209
 
8352
8210
  // src/main/services/simulator-temp-files/fs-channels.ts
8353
- import fs10 from "node:fs/promises";
8211
+ import fs9 from "node:fs/promises";
8354
8212
  import path19 from "node:path";
8355
8213
  async function enforceSandbox(realPath) {
8356
8214
  if (typeof realPath !== "string" || realPath.length === 0) {
8357
8215
  throw new Error("sandbox: realPath must be a non-empty string");
8358
8216
  }
8359
8217
  const base = sandboxBase();
8360
- const baseReal = await fs10.realpath(base).catch(() => base);
8218
+ const baseReal = await fs9.realpath(base).catch(() => base);
8361
8219
  const normalized = path19.normalize(realPath);
8362
8220
  if (normalized !== base && !normalized.startsWith(base + path19.sep)) {
8363
8221
  throw new Error("sandbox: realPath escapes the user-data base");
@@ -8365,7 +8223,7 @@ async function enforceSandbox(realPath) {
8365
8223
  let probe = normalized;
8366
8224
  while (probe !== path19.parse(probe).root) {
8367
8225
  try {
8368
- const resolved = await fs10.realpath(probe);
8226
+ const resolved = await fs9.realpath(probe);
8369
8227
  if (resolved !== baseReal && !resolved.startsWith(baseReal + path19.sep)) {
8370
8228
  throw new Error("sandbox: realPath escapes the user-data base via symlink");
8371
8229
  }
@@ -8405,12 +8263,12 @@ async function handleFsReaddir(req) {
8405
8263
  }
8406
8264
  async function handleFsUnlink(req) {
8407
8265
  const safe = await enforceSandbox(req.realPath);
8408
- await fs10.unlink(safe);
8266
+ await fs9.unlink(safe);
8409
8267
  return { ok: true };
8410
8268
  }
8411
8269
  async function handleFsMkdir(req) {
8412
8270
  const safe = await enforceSandbox(req.realPath);
8413
- await fs10.mkdir(safe, { recursive: !!req.recursive });
8271
+ await fs9.mkdir(safe, { recursive: !!req.recursive });
8414
8272
  return { ok: true };
8415
8273
  }
8416
8274
 
@@ -8545,7 +8403,7 @@ function setupSimulatorTempFiles(simSession) {
8545
8403
  }
8546
8404
 
8547
8405
  // src/main/services/views/simulator-session-policy.ts
8548
- import { session as session2 } from "electron";
8406
+ import { session as session3 } from "electron";
8549
8407
  import { toDisposable as toDisposable7 } from "@dimina-kit/electron-deck/main";
8550
8408
  function applySimulatorWebRequestPolicy(simulatorSession) {
8551
8409
  simulatorSession.webRequest.onBeforeSendHeaders((details, callback) => {
@@ -8577,7 +8435,7 @@ function setupSimulatorSessionPolicy() {
8577
8435
  configured.add(sess);
8578
8436
  applySimulatorWebRequestPolicy(sess);
8579
8437
  }
8580
- install(session2.fromPartition(SHARED_MINIAPP_PARTITION));
8438
+ install(session3.fromPartition(SHARED_MINIAPP_PARTITION));
8581
8439
  const unregister = registerMiniappSessionConfigurator((sess) => install(sess));
8582
8440
  return toDisposable7(() => {
8583
8441
  unregister();
@@ -8774,10 +8632,8 @@ function createContext(config, mainWindow, rendererDir2) {
8774
8632
  adapter: config.adapter,
8775
8633
  preloadPath: config.preloadPath ?? defaultPreloadPath,
8776
8634
  rendererDir: rendererDir2,
8777
- panels: config.panels,
8778
8635
  appName: config.appName,
8779
8636
  apiNamespaces: config.apiNamespaces,
8780
- headerHeight: config.headerHeight,
8781
8637
  brandingProvider: config.brandingProvider,
8782
8638
  // The host-supplied ProjectsProvider / template types in `shared/types`
8783
8639
  // are structurally compatible with the main-process equivalents —
@@ -8801,7 +8657,6 @@ function toMenuContext(context) {
8801
8657
  delete menuContext.senderPolicy;
8802
8658
  delete menuContext.trustedWindowSenderIds;
8803
8659
  delete menuContext.simulatorApis;
8804
- delete menuContext.toolbar;
8805
8660
  return menuContext;
8806
8661
  }
8807
8662
  function installMenu(config, mainWindow, context) {
@@ -8856,7 +8711,7 @@ function enableDevRendererAutoReload(rendererDir2) {
8856
8711
  });
8857
8712
  }
8858
8713
  let reloadTimer = null;
8859
- const watcher = fs11.watch(rendererDir2, { recursive: true }, () => {
8714
+ const watcher = fs10.watch(rendererDir2, { recursive: true }, () => {
8860
8715
  if (reloadTimer) clearTimeout(reloadTimer);
8861
8716
  reloadTimer = setTimeout(() => {
8862
8717
  for (const win of BrowserWindow7.getAllWindows()) {
@@ -8893,7 +8748,7 @@ async function createDevtoolsRuntime(config = {}) {
8893
8748
  context.registry.add(setupSimulatorSessionPolicy());
8894
8749
  context.registry.add(installThemeBackgroundSync());
8895
8750
  registerBuiltinModules(config, context);
8896
- const simSession = session3.fromPartition(SHARED_MINIAPP_PARTITION);
8751
+ const simSession = session4.fromPartition(SHARED_MINIAPP_PARTITION);
8897
8752
  context.registry.add(setupSimulatorTempFiles(simSession));
8898
8753
  installMenu(config, mainWindow, context);
8899
8754
  const hostIpc = new IpcRegistry(context.senderPolicy);
@@ -8907,17 +8762,8 @@ async function createDevtoolsRuntime(config = {}) {
8907
8762
  // teardown, so a single dispose leaves no dead entry behind.
8908
8763
  registerTrustedWindow: (win) => context.registry.add(registerTrustedWindow(context, win)),
8909
8764
  registerSimulatorApi: (name, handler) => context.registry.add(toDisposable8(context.simulatorApis.register(name, handler))),
8910
- toolbar: {
8911
- set: (actions) => {
8912
- context.toolbar.set(actions);
8913
- context.notify.toolbarActionsChanged();
8914
- }
8915
- },
8916
8765
  dispose: () => disposeContext(context)
8917
8766
  };
8918
- if (config.onBeforeOpenProject) {
8919
- context.beforeOpenProject = (projectPath) => config.onBeforeOpenProject({ projectPath, instance });
8920
- }
8921
8767
  if (config.onSetup) {
8922
8768
  await config.onSetup(instance);
8923
8769
  }
@@ -8936,8 +8782,8 @@ async function createDevtoolsRuntime(config = {}) {
8936
8782
  const mcp = setupMcp();
8937
8783
  if (mcp) context.registry.add(mcp);
8938
8784
  const getActiveAppId = () => {
8939
- const session4 = context.workspace.getSession();
8940
- const appInfo = session4?.appInfo;
8785
+ const session5 = context.workspace.getSession();
8786
+ const appInfo = session5?.appInfo;
8941
8787
  return appInfo?.appId ?? null;
8942
8788
  };
8943
8789
  if (context.bridge?.isNativeHost()) {