@dimina-kit/devtools 0.3.2-dev.20260611060732 → 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 (83) hide show
  1. package/README.md +51 -25
  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 -16
  6. package/dist/main/index.bundle.js +233 -366
  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 +5 -20
  30. package/dist/main/services/workbench-context.js +0 -14
  31. package/dist/main/utils/paths.d.ts +11 -2
  32. package/dist/main/utils/paths.js +11 -2
  33. package/dist/preload/index.d.ts +15 -0
  34. package/dist/preload/index.js +15 -0
  35. package/dist/preload/runtime/host-toolbar-port.d.ts +44 -0
  36. package/dist/preload/runtime/host-toolbar-port.js +127 -0
  37. package/dist/preload/runtime/host-toolbar-runtime.d.ts +41 -0
  38. package/dist/preload/runtime/host-toolbar-runtime.js +49 -0
  39. package/dist/preload/windows/{host-toolbar.cjs → host-toolbar-runtime.cjs} +94 -3
  40. package/dist/preload/windows/host-toolbar-runtime.cjs.map +7 -0
  41. package/dist/preload/windows/host-toolbar-runtime.d.ts +2 -0
  42. package/dist/preload/windows/host-toolbar-runtime.js +13 -0
  43. package/dist/preload/windows/simulator.cjs +0 -2
  44. package/dist/preload/windows/simulator.cjs.map +2 -2
  45. package/dist/preload/windows/simulator.js +0 -2
  46. package/dist/renderer/assets/constants-DI382mTP.js +2 -0
  47. package/dist/renderer/assets/index-DLzjz1wv.js +50 -0
  48. package/dist/renderer/assets/{input-QGx6FFX1.js → input-6fpCXV-n.js} +2 -2
  49. package/dist/renderer/assets/ipc-transport-Bs8Sf1B2.css +1 -0
  50. package/dist/renderer/assets/{ipc-transport-DvZvwK-Z.js → ipc-transport-D22e4dv7.js} +6 -6
  51. package/dist/renderer/assets/popover-CdGdKkkc.js +2 -0
  52. package/dist/renderer/assets/select-X0sbjwdP.js +2 -0
  53. package/dist/renderer/assets/{settings-DpAbTJyF.js → settings-CS4jYaCw.js} +2 -2
  54. package/dist/renderer/assets/settings-api-CCWTAao_.js +2 -0
  55. package/dist/renderer/assets/workbenchSettings-Bpzaj3bm.js +8 -0
  56. package/dist/renderer/entries/main/index.html +7 -6
  57. package/dist/renderer/entries/popover/index.html +6 -6
  58. package/dist/renderer/entries/settings/index.html +5 -5
  59. package/dist/renderer/entries/workbench-settings/index.html +5 -5
  60. package/dist/shared/constants.d.ts +18 -0
  61. package/dist/shared/constants.js +18 -0
  62. package/dist/shared/ipc-channels.d.ts +10 -23
  63. package/dist/shared/ipc-channels.js +13 -34
  64. package/dist/shared/ipc-schemas.d.ts +0 -12
  65. package/dist/shared/ipc-schemas.js +0 -12
  66. package/dist/shared/types.d.ts +14 -30
  67. package/package.json +8 -8
  68. package/dist/main/ipc/panels.d.ts +0 -4
  69. package/dist/main/ipc/panels.js +0 -46
  70. package/dist/main/ipc/toolbar.d.ts +0 -4
  71. package/dist/main/ipc/toolbar.js +0 -21
  72. package/dist/main/services/toolbar/toolbar-store.d.ts +0 -23
  73. package/dist/main/services/toolbar/toolbar-store.js +0 -23
  74. package/dist/preload/windows/host-toolbar.cjs.map +0 -7
  75. package/dist/preload/windows/host-toolbar.d.ts +0 -2
  76. package/dist/preload/windows/host-toolbar.js +0 -12
  77. package/dist/renderer/assets/constants-CLAQX6VZ.js +0 -2
  78. package/dist/renderer/assets/index-CcJKzatF.js +0 -50
  79. package/dist/renderer/assets/ipc-transport-BT4QYQqu.css +0 -1
  80. package/dist/renderer/assets/popover-BOH1If1J.js +0 -2
  81. package/dist/renderer/assets/select-C7JQ8G5N.js +0 -2
  82. package/dist/renderer/assets/settings-api-RD2IZF53.js +0 -2
  83. package/dist/renderer/assets/workbenchSettings-CNJX4Qna.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,
@@ -2773,9 +2762,9 @@ function createWorkspaceService(ctx) {
2773
2762
  }
2774
2763
  sendStatus("compiling", "\u6B63\u5728\u7F16\u8BD1...");
2775
2764
  const { compile } = loadWorkbenchSettings();
2776
- let session4;
2765
+ let session5;
2777
2766
  try {
2778
- session4 = await ctx.adapter.openProject({
2767
+ session5 = await ctx.adapter.openProject({
2779
2768
  projectPath,
2780
2769
  sourcemap: true,
2781
2770
  watch: compile.watch,
@@ -2787,17 +2776,17 @@ function createWorkspaceService(ctx) {
2787
2776
  sendStatus("error", String(err));
2788
2777
  return { success: false, error: String(err) };
2789
2778
  }
2790
- currentSession = session4;
2779
+ currentSession = session5;
2791
2780
  currentProjectPath = projectPath;
2792
2781
  bestEffort("updateLastOpened", () => {
2793
2782
  if (provider.updateLastOpened) provider.updateLastOpened(projectPath);
2794
2783
  });
2795
2784
  bestEffort("sendStatus", () => sendStatus("ready", "\u7F16\u8BD1\u5B8C\u6210"));
2796
- bestEffort("applyReferer", () => applyRefererFromSession(session4));
2785
+ bestEffort("applyReferer", () => applyRefererFromSession(session5));
2797
2786
  return {
2798
2787
  success: true,
2799
- port: session4.port,
2800
- appInfo: session4.appInfo
2788
+ port: session5.port,
2789
+ appInfo: session5.appInfo
2801
2790
  };
2802
2791
  },
2803
2792
  async closeProject() {
@@ -2893,29 +2882,6 @@ function createLocalProjectsProvider() {
2893
2882
  };
2894
2883
  }
2895
2884
 
2896
- // src/main/services/toolbar/toolbar-store.ts
2897
- function createToolbarStore() {
2898
- let actions = [];
2899
- return {
2900
- set(next) {
2901
- const seen = /* @__PURE__ */ new Set();
2902
- for (const action of next) {
2903
- if (seen.has(action.id)) {
2904
- throw new Error(`Duplicate toolbar action id "${action.id}"`);
2905
- }
2906
- seen.add(action.id);
2907
- }
2908
- actions = next.slice();
2909
- },
2910
- list() {
2911
- return actions.map(({ id, label }) => ({ id, label }));
2912
- },
2913
- getHandler(id) {
2914
- return actions.find((a) => a.id === id)?.handler;
2915
- }
2916
- };
2917
- }
2918
-
2919
2885
  // src/main/services/projects/templates.ts
2920
2886
  function resolveTemplates(builtin, injected, mode) {
2921
2887
  let kept;
@@ -2961,30 +2927,19 @@ var BUILTIN_TEMPLATES = [
2961
2927
  ];
2962
2928
 
2963
2929
  // src/main/services/workbench-context.ts
2964
- function hasBuiltinPanel(ctx, panelId) {
2965
- return ctx.panels.includes(panelId);
2966
- }
2967
- function getDefaultTab(ctx) {
2968
- if (hasBuiltinPanel(ctx, "console")) return "simulator";
2969
- if (ctx.panels.length > 0) return ctx.panels[0];
2970
- return "simulator";
2971
- }
2972
2930
  function createWorkbenchContext(opts) {
2973
2931
  const ctx = {
2974
2932
  adapter: opts.adapter ?? defaultAdapter,
2975
2933
  preloadPath: opts.preloadPath,
2976
2934
  rendererDir: opts.rendererDir,
2977
- panels: opts.panels ?? ["wxml", "console", "appdata", "storage"],
2978
2935
  apiNamespaces: opts.apiNamespaces ?? [],
2979
2936
  appName: opts.appName ?? "Dimina DevTools",
2980
- headerHeight: opts.headerHeight ?? 40,
2981
2937
  brandingProvider: opts.brandingProvider
2982
2938
  };
2983
2939
  ctx.registry = new DisposableRegistry3();
2984
2940
  ctx.connections = createConnectionRegistry();
2985
2941
  ctx.trustedWindowSenderIds = /* @__PURE__ */ new Map();
2986
2942
  ctx.simulatorApis = createSimulatorApiRegistry();
2987
- ctx.toolbar = createToolbarStore();
2988
2943
  ctx.windows = createWindowService(opts.mainWindow);
2989
2944
  ctx.views = createViewManager(ctx);
2990
2945
  ctx.notify = createRendererNotifier(ctx);
@@ -3078,15 +3033,10 @@ function installAppMenu(ctx) {
3078
3033
  }
3079
3034
 
3080
3035
  // src/main/ipc/app.ts
3081
- import fs6 from "fs";
3082
3036
  function registerAppIpc(ctx) {
3083
- return new IpcRegistry(ctx.senderPolicy).handle(AppChannel.GetPreloadPath, () => {
3084
- return `file://${fs6.realpathSync(ctx.preloadPath)}`;
3085
- }).handle(AppChannel.GetBranding, async () => {
3037
+ return new IpcRegistry(ctx.senderPolicy).handle(AppChannel.GetBranding, async () => {
3086
3038
  if (ctx.brandingProvider) return ctx.brandingProvider();
3087
3039
  return { appName: ctx.appName };
3088
- }).handle(AppChannel.GetHeaderHeight, () => {
3089
- return ctx.headerHeight;
3090
3040
  });
3091
3041
  }
3092
3042
 
@@ -3096,7 +3046,6 @@ var AbsolutePath = z2.string().min(1).refine(
3096
3046
  (p) => p.startsWith("/") || /^[a-zA-Z]:\\/.test(p) || /^[a-zA-Z]:\//.test(p),
3097
3047
  "must be an absolute path"
3098
3048
  );
3099
- var PanelEvalSchema = z2.tuple([z2.string().min(1).max(5e4)]);
3100
3049
  var ProjectsAddSchema = z2.tuple([AbsolutePath]);
3101
3050
  var ProjectOpenSchema = z2.tuple([AbsolutePath]);
3102
3051
  var CompileConfigShape = z2.looseObject({
@@ -3116,7 +3065,6 @@ var SimulatorAttachNativeSchema = z2.tuple([
3116
3065
  }),
3117
3066
  SimWidth
3118
3067
  ]);
3119
- var SimulatorResizeSchema = z2.tuple([SimWidth]);
3120
3068
  var SimulatorSetNativeBoundsSchema = z2.tuple([
3121
3069
  z2.object({
3122
3070
  x: z2.number().finite(),
@@ -3161,12 +3109,10 @@ var HostToolbarAdvertiseHeightSchema = z2.tuple([
3161
3109
  extent: NonNegInt
3162
3110
  })
3163
3111
  ]);
3164
- var SimulatorSetVisibleSchema = z2.tuple([z2.boolean(), SimWidth]);
3165
3112
  var SimulatorCustomApiInvokeSchema = z2.tuple([
3166
3113
  z2.string().min(1).max(256),
3167
3114
  z2.unknown()
3168
3115
  ]);
3169
- var ToolbarInvokeSchema = z2.tuple([z2.string().min(1).max(256)]);
3170
3116
  var ProjectGetPagesSchema = z2.tuple([AbsolutePath]);
3171
3117
  var ProjectGetCompileConfigSchema = z2.tuple([AbsolutePath]);
3172
3118
  var ProjectsRemoveSchema = z2.tuple([AbsolutePath]);
@@ -3190,7 +3136,6 @@ var WorkbenchSettingsSaveSchema = z2.tuple([
3190
3136
  var WorkbenchSettingsSetThemeSchema = z2.tuple([
3191
3137
  z2.enum(["system", "light", "dark"])
3192
3138
  ]);
3193
- var WorkbenchSettingsSetVisibleSchema = z2.tuple([z2.boolean()]);
3194
3139
  var SettingsSetVisibleSchema = z2.tuple([z2.boolean()]);
3195
3140
  var SettingsConfigChangedSchema = z2.tuple([CompileConfigShape]);
3196
3141
  var PopoverRelaunchSchema = z2.tuple([CompileConfigShape]);
@@ -3199,7 +3144,6 @@ var SettingsProjectSettingsChangedSchema = z2.tuple([
3199
3144
  uploadWithSourceMap: z2.boolean().optional()
3200
3145
  })
3201
3146
  ]);
3202
- var PanelSelectSchema = z2.tuple([z2.string().min(1).max(200)]);
3203
3147
  var ProjectCaptureThumbnailSchema = z2.tuple([AbsolutePath]);
3204
3148
  var ProjectGetThumbnailSchema = z2.tuple([AbsolutePath]);
3205
3149
 
@@ -3278,9 +3222,6 @@ function registerSimulatorIpc(ctx) {
3278
3222
  ctx.views.attachNativeSimulator(simulatorUrl, simWidth);
3279
3223
  }).handle(SimulatorChannel.Detach, () => {
3280
3224
  ctx.views.detachSimulator();
3281
- }).handle(SimulatorChannel.Resize, (_, ...args) => {
3282
- const [simWidth] = validate(SimulatorChannel.Resize, SimulatorResizeSchema, args);
3283
- ctx.views.resize(simWidth);
3284
3225
  }).handle(SimulatorChannel.SetNativeBounds, (_, ...args) => {
3285
3226
  const [p] = validate(SimulatorChannel.SetNativeBounds, SimulatorSetNativeBoundsSchema, args);
3286
3227
  ctx.views.setNativeSimulatorViewBounds(p);
@@ -3292,48 +3233,12 @@ function registerSimulatorIpc(ctx) {
3292
3233
  if (serviceWc && !serviceWc.isDestroyed()) {
3293
3234
  serviceWc.send(ServiceHostChannel.HostEnvUpdate, deviceInfoToHostEnv(device));
3294
3235
  }
3295
- }).handle(SimulatorChannel.SetVisible, (_, ...args) => {
3296
- const [visible, simWidth] = validate(SimulatorChannel.SetVisible, SimulatorSetVisibleSchema, args);
3297
- ctx.views.setVisible(visible, simWidth);
3298
- }).handle(SimulatorCustomApiChannel.List, () => {
3299
- return ctx.simulatorApis.list();
3300
3236
  }).handle(SimulatorCustomApiChannel.Invoke, (_, ...args) => {
3301
3237
  const [name, params] = validate(SimulatorCustomApiChannel.Invoke, SimulatorCustomApiInvokeSchema, args);
3302
3238
  return ctx.simulatorApis.invoke(name, params);
3303
3239
  });
3304
3240
  }
3305
3241
 
3306
- // src/main/ipc/panels.ts
3307
- var BUILTIN_PANELS = [
3308
- { id: "wxml", label: "WXML" },
3309
- { id: "appdata", label: "AppData" },
3310
- { id: "storage", label: "Storage" }
3311
- ];
3312
- function registerPanelsIpc(ctx) {
3313
- return new IpcRegistry(ctx.senderPolicy).handle(PanelChannel.List, () => {
3314
- return BUILTIN_PANELS.filter((p) => ctx.panels.includes(p.id));
3315
- }).handle(PanelChannel.Eval, async (_event, ...args) => {
3316
- const [expression] = validate(PanelChannel.Eval, PanelEvalSchema, args);
3317
- if (!ctx.workspace.hasActiveSession()) return void 0;
3318
- const sim = ctx.views.getSimulatorWebContents();
3319
- if (!sim) return void 0;
3320
- try {
3321
- return await sim.executeJavaScript(expression);
3322
- } catch {
3323
- return void 0;
3324
- }
3325
- }).handle(PanelChannel.Select, (_event, ...args) => {
3326
- validate(PanelChannel.Select, PanelSelectSchema, args);
3327
- if (ctx.views.hasSimulatorView() && ctx.views.isSimulatorAdded()) {
3328
- ctx.views.hideSimulator();
3329
- }
3330
- }).handle(PanelChannel.SelectSimulator, () => {
3331
- if (ctx.views.hasSimulatorView() && !ctx.views.isSimulatorAdded()) {
3332
- ctx.views.showSimulator(ctx.views.getLastSimWidth());
3333
- }
3334
- }).handle(WorkbenchRuntimeChannel.GetNativeHost, () => true);
3335
- }
3336
-
3337
3242
  // src/main/ipc/popover.ts
3338
3243
  function registerPopoverIpc(ctx) {
3339
3244
  return new IpcRegistry(ctx.senderPolicy).handle(PopoverChannel.Show, (_event, ...args) => {
@@ -3356,7 +3261,7 @@ import { app as app7, dialog } from "electron";
3356
3261
  import path12 from "path";
3357
3262
 
3358
3263
  // src/main/services/projects/create-project-service.ts
3359
- import fs7 from "node:fs";
3264
+ import fs6 from "node:fs";
3360
3265
  import path11 from "node:path";
3361
3266
  var DEFAULT_TEMPLATE_ID = "blank";
3362
3267
  async function createProject(input, ctx) {
@@ -3368,12 +3273,12 @@ async function createProject(input, ctx) {
3368
3273
  if (!target || typeof target !== "string") {
3369
3274
  throw new Error("Project path is required");
3370
3275
  }
3371
- if (fs7.existsSync(target)) {
3372
- const stat = fs7.statSync(target);
3276
+ if (fs6.existsSync(target)) {
3277
+ const stat = fs6.statSync(target);
3373
3278
  if (!stat.isDirectory()) {
3374
3279
  throw new Error(`Project path exists and is not a directory: ${target}`);
3375
3280
  }
3376
- const entries = fs7.readdirSync(target);
3281
+ const entries = fs6.readdirSync(target);
3377
3282
  if (entries.length > 0) {
3378
3283
  throw new Error(
3379
3284
  `Project path is not empty (refusing to overwrite): ${target}`
@@ -3390,31 +3295,31 @@ async function createProject(input, ctx) {
3390
3295
  `Template '${templateId}' has neither a source directory nor a generate function`
3391
3296
  );
3392
3297
  }
3393
- fs7.mkdirSync(target, { recursive: true });
3298
+ fs6.mkdirSync(target, { recursive: true });
3394
3299
  if (template.generate) {
3395
3300
  await template.generate(target, { name });
3396
3301
  } else if (template.source) {
3397
- if (!fs7.existsSync(template.source.path)) {
3302
+ if (!fs6.existsSync(template.source.path)) {
3398
3303
  throw new Error(
3399
3304
  `Template source missing on disk: ${template.source.path}`
3400
3305
  );
3401
3306
  }
3402
- fs7.cpSync(template.source.path, target, {
3307
+ fs6.cpSync(template.source.path, target, {
3403
3308
  recursive: true,
3404
3309
  force: true
3405
3310
  });
3406
3311
  }
3407
3312
  const cfgPath = path11.join(target, "project.config.json");
3408
3313
  let cfg = {};
3409
- if (fs7.existsSync(cfgPath)) {
3314
+ if (fs6.existsSync(cfgPath)) {
3410
3315
  try {
3411
- cfg = JSON.parse(fs7.readFileSync(cfgPath, "utf-8"));
3316
+ cfg = JSON.parse(fs6.readFileSync(cfgPath, "utf-8"));
3412
3317
  } catch {
3413
3318
  cfg = {};
3414
3319
  }
3415
3320
  }
3416
3321
  cfg.projectname = name;
3417
- fs7.writeFileSync(cfgPath, JSON.stringify(cfg, null, 2));
3322
+ fs6.writeFileSync(cfgPath, JSON.stringify(cfg, null, 2));
3418
3323
  const created = await ctx.projectsProvider.addProject(target);
3419
3324
  return created;
3420
3325
  }
@@ -3618,17 +3523,6 @@ function registerSettingsIpc(ctx) {
3618
3523
  activePort: runtime.port,
3619
3524
  error: runtime.error
3620
3525
  };
3621
- }).handle(WorkbenchSettingsChannel.SetVisible, async (_, ...args) => {
3622
- const [visible] = validate(
3623
- WorkbenchSettingsChannel.SetVisible,
3624
- WorkbenchSettingsSetVisibleSchema,
3625
- args
3626
- );
3627
- if (visible) {
3628
- await openSettingsWindow(ctx);
3629
- } else {
3630
- ctx.windows.closeSettingsWindow();
3631
- }
3632
3526
  }).handle(SettingsChannel.SetVisible, async (_, ...args) => {
3633
3527
  const [visible] = validate(SettingsChannel.SetVisible, SettingsSetVisibleSchema, args);
3634
3528
  if (visible) {
@@ -3641,7 +3535,6 @@ function registerSettingsIpc(ctx) {
3641
3535
  });
3642
3536
  } else {
3643
3537
  ctx.views.hideSettings();
3644
- ctx.notify.settingsClosed();
3645
3538
  }
3646
3539
  }).on(SettingsChannel.ConfigChanged, async (_, ...args) => {
3647
3540
  const [config] = validate(
@@ -3653,7 +3546,6 @@ function registerSettingsIpc(ctx) {
3653
3546
  if (projectPath) {
3654
3547
  await ctx.workspace.saveCompileConfig(projectPath, config);
3655
3548
  }
3656
- ctx.notify.settingsChanged(config);
3657
3549
  }).on(SettingsChannel.ProjectSettingsChanged, (_, ...args) => {
3658
3550
  const [patch] = validate(
3659
3551
  SettingsChannel.ProjectSettingsChanged,
@@ -3670,20 +3562,6 @@ var settingsModule = {
3670
3562
  setup: (ctx) => registerSettingsIpc(ctx)
3671
3563
  };
3672
3564
 
3673
- // src/main/ipc/toolbar.ts
3674
- function registerToolbarIpc(ctx) {
3675
- return new IpcRegistry(ctx.senderPolicy).handle(ToolbarChannel.GetActions, () => {
3676
- return ctx.toolbar.list();
3677
- }).handle(ToolbarChannel.Invoke, async (_, ...args) => {
3678
- const [id] = validate(ToolbarChannel.Invoke, ToolbarInvokeSchema, args);
3679
- const handler = ctx.toolbar.getHandler(id);
3680
- if (!handler) {
3681
- throw new Error(`Toolbar action "${id}" is not registered`);
3682
- }
3683
- await handler();
3684
- });
3685
- }
3686
-
3687
3565
  // src/main/ipc/simulator-module.ts
3688
3566
  import { DisposableRegistry as DisposableRegistry6 } from "@dimina-kit/electron-deck/main";
3689
3567
 
@@ -3703,7 +3581,7 @@ import { createDebugTap } from "@dimina-kit/electron-deck/main";
3703
3581
 
3704
3582
  // src/main/services/dimina-resource-server.ts
3705
3583
  import http from "node:http";
3706
- import fs8 from "node:fs";
3584
+ import fs7 from "node:fs";
3707
3585
  import path13 from "node:path";
3708
3586
  var MIME_TYPES = {
3709
3587
  ".css": "text/css; charset=utf-8",
@@ -3761,7 +3639,7 @@ async function handleRequest(root, req, res) {
3761
3639
  return;
3762
3640
  }
3763
3641
  try {
3764
- const stat = await fs8.promises.stat(filePath);
3642
+ const stat = await fs7.promises.stat(filePath);
3765
3643
  if (!stat.isFile()) {
3766
3644
  res.writeHead(404);
3767
3645
  res.end("Not Found");
@@ -3776,7 +3654,7 @@ async function handleRequest(root, req, res) {
3776
3654
  res.end();
3777
3655
  return;
3778
3656
  }
3779
- fs8.createReadStream(filePath).pipe(res);
3657
+ fs7.createReadStream(filePath).pipe(res);
3780
3658
  } catch {
3781
3659
  res.writeHead(404);
3782
3660
  res.end("Not Found");
@@ -5823,8 +5701,6 @@ var simulatorModule = {
5823
5701
  setup: (ctx) => {
5824
5702
  const reg = new DisposableRegistry6();
5825
5703
  reg.add(registerSimulatorIpc(ctx));
5826
- reg.add(registerPanelsIpc(ctx));
5827
- reg.add(registerToolbarIpc(ctx));
5828
5704
  reg.add(registerViewsIpc(ctx));
5829
5705
  installBridgeRouter(ctx);
5830
5706
  return reg;
@@ -8055,7 +7931,7 @@ function resolveVPath(url) {
8055
7931
  }
8056
7932
 
8057
7933
  // src/main/services/simulator-temp-files/disk.ts
8058
- import fs9 from "node:fs/promises";
7934
+ import fs8 from "node:fs/promises";
8059
7935
  import path18 from "node:path";
8060
7936
  var EXT_MIME = {
8061
7937
  ".txt": "text/plain",
@@ -8136,7 +8012,7 @@ function etagOf(mtimeMs, size) {
8136
8012
  return `W/"${Math.floor(mtimeMs)}-${size}"`;
8137
8013
  }
8138
8014
  async function readDiskFile(realPath, opts) {
8139
- const handle = await fs9.open(realPath, "r");
8015
+ const handle = await fs8.open(realPath, "r");
8140
8016
  try {
8141
8017
  const st = await handle.stat();
8142
8018
  const totalSize = st.size;
@@ -8191,15 +8067,15 @@ async function readDiskFile(realPath, opts) {
8191
8067
  }
8192
8068
  async function writeDiskFile(realPath, bytes) {
8193
8069
  const buf = Buffer.isBuffer(bytes) ? bytes : Buffer.from(new Uint8Array(bytes));
8194
- await fs9.mkdir(path18.dirname(realPath), { recursive: true });
8195
- await fs9.writeFile(realPath, buf);
8070
+ await fs8.mkdir(path18.dirname(realPath), { recursive: true });
8071
+ await fs8.writeFile(realPath, buf);
8196
8072
  }
8197
8073
  async function readDiskDir(realPath) {
8198
- const entries = await fs9.readdir(realPath);
8074
+ const entries = await fs8.readdir(realPath);
8199
8075
  return entries;
8200
8076
  }
8201
8077
  async function statDiskFile(realPath) {
8202
- const st = await fs9.stat(realPath);
8078
+ const st = await fs8.stat(realPath);
8203
8079
  return {
8204
8080
  size: st.size,
8205
8081
  mtime: Math.floor(st.mtimeMs),
@@ -8332,14 +8208,14 @@ async function handleDifileRequest(ctx, req) {
8332
8208
  }
8333
8209
 
8334
8210
  // src/main/services/simulator-temp-files/fs-channels.ts
8335
- import fs10 from "node:fs/promises";
8211
+ import fs9 from "node:fs/promises";
8336
8212
  import path19 from "node:path";
8337
8213
  async function enforceSandbox(realPath) {
8338
8214
  if (typeof realPath !== "string" || realPath.length === 0) {
8339
8215
  throw new Error("sandbox: realPath must be a non-empty string");
8340
8216
  }
8341
8217
  const base = sandboxBase();
8342
- const baseReal = await fs10.realpath(base).catch(() => base);
8218
+ const baseReal = await fs9.realpath(base).catch(() => base);
8343
8219
  const normalized = path19.normalize(realPath);
8344
8220
  if (normalized !== base && !normalized.startsWith(base + path19.sep)) {
8345
8221
  throw new Error("sandbox: realPath escapes the user-data base");
@@ -8347,7 +8223,7 @@ async function enforceSandbox(realPath) {
8347
8223
  let probe = normalized;
8348
8224
  while (probe !== path19.parse(probe).root) {
8349
8225
  try {
8350
- const resolved = await fs10.realpath(probe);
8226
+ const resolved = await fs9.realpath(probe);
8351
8227
  if (resolved !== baseReal && !resolved.startsWith(baseReal + path19.sep)) {
8352
8228
  throw new Error("sandbox: realPath escapes the user-data base via symlink");
8353
8229
  }
@@ -8387,12 +8263,12 @@ async function handleFsReaddir(req) {
8387
8263
  }
8388
8264
  async function handleFsUnlink(req) {
8389
8265
  const safe = await enforceSandbox(req.realPath);
8390
- await fs10.unlink(safe);
8266
+ await fs9.unlink(safe);
8391
8267
  return { ok: true };
8392
8268
  }
8393
8269
  async function handleFsMkdir(req) {
8394
8270
  const safe = await enforceSandbox(req.realPath);
8395
- await fs10.mkdir(safe, { recursive: !!req.recursive });
8271
+ await fs9.mkdir(safe, { recursive: !!req.recursive });
8396
8272
  return { ok: true };
8397
8273
  }
8398
8274
 
@@ -8527,7 +8403,7 @@ function setupSimulatorTempFiles(simSession) {
8527
8403
  }
8528
8404
 
8529
8405
  // src/main/services/views/simulator-session-policy.ts
8530
- import { session as session2 } from "electron";
8406
+ import { session as session3 } from "electron";
8531
8407
  import { toDisposable as toDisposable7 } from "@dimina-kit/electron-deck/main";
8532
8408
  function applySimulatorWebRequestPolicy(simulatorSession) {
8533
8409
  simulatorSession.webRequest.onBeforeSendHeaders((details, callback) => {
@@ -8559,7 +8435,7 @@ function setupSimulatorSessionPolicy() {
8559
8435
  configured.add(sess);
8560
8436
  applySimulatorWebRequestPolicy(sess);
8561
8437
  }
8562
- install(session2.fromPartition(SHARED_MINIAPP_PARTITION));
8438
+ install(session3.fromPartition(SHARED_MINIAPP_PARTITION));
8563
8439
  const unregister = registerMiniappSessionConfigurator((sess) => install(sess));
8564
8440
  return toDisposable7(() => {
8565
8441
  unregister();
@@ -8756,10 +8632,8 @@ function createContext(config, mainWindow, rendererDir2) {
8756
8632
  adapter: config.adapter,
8757
8633
  preloadPath: config.preloadPath ?? defaultPreloadPath,
8758
8634
  rendererDir: rendererDir2,
8759
- panels: config.panels,
8760
8635
  appName: config.appName,
8761
8636
  apiNamespaces: config.apiNamespaces,
8762
- headerHeight: config.headerHeight,
8763
8637
  brandingProvider: config.brandingProvider,
8764
8638
  // The host-supplied ProjectsProvider / template types in `shared/types`
8765
8639
  // are structurally compatible with the main-process equivalents —
@@ -8783,7 +8657,6 @@ function toMenuContext(context) {
8783
8657
  delete menuContext.senderPolicy;
8784
8658
  delete menuContext.trustedWindowSenderIds;
8785
8659
  delete menuContext.simulatorApis;
8786
- delete menuContext.toolbar;
8787
8660
  return menuContext;
8788
8661
  }
8789
8662
  function installMenu(config, mainWindow, context) {
@@ -8838,7 +8711,7 @@ function enableDevRendererAutoReload(rendererDir2) {
8838
8711
  });
8839
8712
  }
8840
8713
  let reloadTimer = null;
8841
- const watcher = fs11.watch(rendererDir2, { recursive: true }, () => {
8714
+ const watcher = fs10.watch(rendererDir2, { recursive: true }, () => {
8842
8715
  if (reloadTimer) clearTimeout(reloadTimer);
8843
8716
  reloadTimer = setTimeout(() => {
8844
8717
  for (const win of BrowserWindow7.getAllWindows()) {
@@ -8875,7 +8748,7 @@ async function createDevtoolsRuntime(config = {}) {
8875
8748
  context.registry.add(setupSimulatorSessionPolicy());
8876
8749
  context.registry.add(installThemeBackgroundSync());
8877
8750
  registerBuiltinModules(config, context);
8878
- const simSession = session3.fromPartition(SHARED_MINIAPP_PARTITION);
8751
+ const simSession = session4.fromPartition(SHARED_MINIAPP_PARTITION);
8879
8752
  context.registry.add(setupSimulatorTempFiles(simSession));
8880
8753
  installMenu(config, mainWindow, context);
8881
8754
  const hostIpc = new IpcRegistry(context.senderPolicy);
@@ -8889,12 +8762,6 @@ async function createDevtoolsRuntime(config = {}) {
8889
8762
  // teardown, so a single dispose leaves no dead entry behind.
8890
8763
  registerTrustedWindow: (win) => context.registry.add(registerTrustedWindow(context, win)),
8891
8764
  registerSimulatorApi: (name, handler) => context.registry.add(toDisposable8(context.simulatorApis.register(name, handler))),
8892
- toolbar: {
8893
- set: (actions) => {
8894
- context.toolbar.set(actions);
8895
- context.notify.toolbarActionsChanged();
8896
- }
8897
- },
8898
8765
  dispose: () => disposeContext(context)
8899
8766
  };
8900
8767
  if (config.onSetup) {
@@ -8915,8 +8782,8 @@ async function createDevtoolsRuntime(config = {}) {
8915
8782
  const mcp = setupMcp();
8916
8783
  if (mcp) context.registry.add(mcp);
8917
8784
  const getActiveAppId = () => {
8918
- const session4 = context.workspace.getSession();
8919
- const appInfo = session4?.appInfo;
8785
+ const session5 = context.workspace.getSession();
8786
+ const appInfo = session5?.appInfo;
8920
8787
  return appInfo?.appId ?? null;
8921
8788
  };
8922
8789
  if (context.bridge?.isNativeHost()) {