@dimina-kit/devtools 0.3.2-dev.20260525152421 → 0.3.2-dev.20260610082053
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.
- package/README.md +43 -40
- package/dist/main/api.d.ts +0 -1
- package/dist/main/api.js +5 -1
- package/dist/main/app/app.d.ts +15 -5
- package/dist/main/app/app.js +247 -110
- package/dist/main/app/bootstrap.d.ts +16 -0
- package/dist/main/app/bootstrap.js +20 -0
- package/dist/main/app/launch.d.ts +8 -4
- package/dist/main/app/launch.js +9 -4
- package/dist/main/index.bundle.js +6607 -2102
- package/dist/main/index.js +9 -1
- package/dist/main/ipc/app.d.ts +1 -1
- package/dist/main/ipc/bridge-router.d.ts +61 -0
- package/dist/main/ipc/bridge-router.js +1300 -0
- package/dist/main/ipc/panels.d.ts +1 -1
- package/dist/main/ipc/panels.js +6 -2
- package/dist/main/ipc/popover.d.ts +1 -1
- package/dist/main/ipc/project-fs.d.ts +57 -0
- package/dist/main/ipc/project-fs.js +448 -0
- package/dist/main/ipc/projects.d.ts +1 -1
- package/dist/main/ipc/session.d.ts +1 -1
- package/dist/main/ipc/settings.d.ts +1 -1
- package/dist/main/ipc/simulator-module.d.ts +6 -0
- package/dist/main/ipc/simulator-module.js +11 -1
- package/dist/main/ipc/simulator.d.ts +2 -2
- package/dist/main/ipc/simulator.js +49 -5
- package/dist/main/ipc/toolbar.d.ts +1 -1
- package/dist/main/ipc/views.d.ts +19 -0
- package/dist/main/ipc/views.js +65 -0
- package/dist/main/runtime/devtools-backend.d.ts +17 -0
- package/dist/main/runtime/devtools-backend.js +49 -0
- package/dist/main/runtime/miniapp-runtime.d.ts +39 -0
- package/dist/main/runtime/miniapp-runtime.js +17 -0
- package/dist/main/services/automation/exec.d.ts +27 -2
- package/dist/main/services/automation/exec.js +37 -3
- package/dist/main/services/automation/handlers/app.js +127 -11
- package/dist/main/services/automation/handlers/page.js +36 -19
- package/dist/main/services/automation/index.js +40 -13
- package/dist/main/services/automation/wait-active-page.d.ts +56 -0
- package/dist/main/services/automation/wait-active-page.js +71 -0
- package/dist/main/services/console-forward/index.d.ts +36 -0
- package/dist/main/services/console-forward/index.js +81 -0
- package/dist/main/services/dimina-resource-server.d.ts +7 -0
- package/dist/main/services/dimina-resource-server.js +99 -0
- package/dist/main/services/elements-forward/index.d.ts +66 -0
- package/dist/main/services/elements-forward/index.js +583 -0
- package/dist/main/services/layout/index.d.ts +23 -1
- package/dist/main/services/layout/index.js +28 -3
- package/dist/main/services/mcp/index.d.ts +1 -0
- package/dist/main/services/mcp/index.js +3 -0
- package/dist/main/services/mcp/server.d.ts +1 -1
- package/dist/main/services/mcp/server.js +1 -1
- package/dist/main/services/mcp/target-manager.d.ts +35 -0
- package/dist/main/services/mcp/target-manager.js +63 -1
- package/dist/main/services/mcp/tools/context-tools.js +15 -1
- package/dist/main/services/module.d.ts +1 -1
- package/dist/main/services/network-forward/index.d.ts +190 -0
- package/dist/main/services/network-forward/index.js +765 -0
- package/dist/main/services/notifications/renderer-notifier.d.ts +11 -0
- package/dist/main/services/notifications/renderer-notifier.js +7 -1
- package/dist/main/services/render-inspect/index.d.ts +41 -0
- package/dist/main/services/render-inspect/index.js +88 -0
- package/dist/main/services/safe-area/index.d.ts +17 -0
- package/dist/main/services/safe-area/index.js +59 -0
- package/dist/main/services/service-host-pool/pool.d.ts +197 -0
- package/dist/main/services/service-host-pool/pool.js +364 -0
- package/dist/main/services/simulator/custom-apis.d.ts +34 -0
- package/dist/main/services/simulator/custom-apis.js +22 -0
- package/dist/main/services/simulator-appdata/index.d.ts +35 -0
- package/dist/main/services/simulator-appdata/index.js +71 -0
- package/dist/main/services/simulator-current-page/index.d.ts +24 -0
- package/dist/main/services/simulator-current-page/index.js +19 -0
- package/dist/main/services/simulator-storage/index.d.ts +37 -2
- package/dist/main/services/simulator-storage/index.js +209 -32
- package/dist/main/services/simulator-storage/service-storage-ops.d.ts +40 -0
- package/dist/main/services/simulator-storage/service-storage-ops.js +67 -0
- package/dist/main/services/simulator-temp-files/fs-channels.js +1 -1
- package/dist/main/services/simulator-temp-files/index.d.ts +1 -1
- package/dist/main/services/simulator-temp-files/index.js +1 -1
- package/dist/main/services/simulator-temp-files/request-handler.js +1 -1
- package/dist/main/services/simulator-wxml/index.d.ts +29 -0
- package/dist/main/services/simulator-wxml/index.js +28 -0
- package/dist/main/services/update/update-manager.d.ts +10 -0
- package/dist/main/services/update/update-manager.js +16 -3
- package/dist/main/services/views/devtools-tabs.d.ts +47 -0
- package/dist/main/services/views/devtools-tabs.js +95 -0
- package/dist/main/services/views/view-manager.d.ts +142 -4
- package/dist/main/services/views/view-manager.js +909 -17
- package/dist/main/services/workbench-context.d.ts +66 -1
- package/dist/main/services/workbench-context.js +6 -1
- package/dist/main/services/workspace/workspace-service.d.ts +8 -0
- package/dist/main/services/workspace/workspace-service.js +12 -0
- package/dist/main/utils/ipc-registry.d.ts +11 -2
- package/dist/main/utils/ipc-registry.js +63 -3
- package/dist/main/utils/paths.d.ts +15 -0
- package/dist/main/utils/paths.js +19 -0
- package/dist/main/utils/sender-policy.d.ts +9 -3
- package/dist/main/utils/sender-policy.js +18 -4
- package/dist/main/utils/theme.d.ts +1 -1
- package/dist/main/utils/theme.js +1 -1
- package/dist/main/windows/main-window/create.d.ts +0 -6
- package/dist/main/windows/main-window/create.js +11 -59
- package/dist/main/windows/main-window/events.d.ts +1 -1
- package/dist/main/windows/main-window/events.js +1 -1
- package/dist/main/windows/service-host-window/create.d.ts +52 -0
- package/dist/main/windows/service-host-window/create.js +112 -0
- package/dist/native-host/common/common.js +368 -0
- package/dist/native-host/container/pageFrame.css +1 -0
- package/dist/native-host/render/render.js +9334 -0
- package/dist/native-host/service/service.js +6 -0
- package/dist/preload/index.d.ts +2 -0
- package/dist/preload/index.js +6 -0
- package/dist/preload/instrumentation/app-data.d.ts +18 -20
- package/dist/preload/instrumentation/app-data.js +23 -160
- package/dist/preload/instrumentation/wxml-extract.d.ts +1 -1
- package/dist/preload/instrumentation/wxml-extract.js +1 -1
- package/dist/preload/runtime/bridge.d.ts +3 -8
- package/dist/preload/runtime/bridge.js +2 -32
- package/dist/preload/runtime/custom-apis.js +20 -17
- package/dist/preload/runtime/host-toolbar-advertiser.d.ts +27 -0
- package/dist/preload/runtime/host-toolbar-advertiser.js +55 -0
- package/dist/preload/runtime/main-api-runner.d.ts +9 -0
- package/dist/preload/runtime/main-api-runner.js +85 -0
- package/dist/preload/runtime/native-host.d.ts +43 -0
- package/dist/preload/runtime/native-host.js +83 -0
- package/dist/preload/shared/expose.d.ts +10 -5
- package/dist/preload/shared/expose.js +29 -11
- package/dist/preload/shared/sid-registry.d.ts +11 -0
- package/dist/preload/shared/sid-registry.js +38 -0
- package/dist/preload/windows/host-toolbar.cjs +161 -0
- package/dist/preload/windows/host-toolbar.cjs.map +7 -0
- package/dist/preload/windows/host-toolbar.d.ts +2 -0
- package/dist/preload/windows/host-toolbar.js +12 -0
- package/dist/preload/windows/main.cjs +1939 -0
- package/dist/preload/windows/main.cjs.map +4 -4
- package/dist/preload/windows/simulator.cjs +925 -0
- package/dist/preload/windows/simulator.cjs.map +7 -0
- package/dist/preload/windows/simulator.js +243 -573
- package/dist/render-host/pageFrame.html +29 -0
- package/dist/render-host/preload.cjs +154 -0
- package/dist/render-host/render-inspect.js +295 -0
- package/dist/renderer/assets/abap-DiwvWnMr.js +2 -0
- package/dist/renderer/assets/apex-CmtZjKlf.js +2 -0
- package/dist/renderer/assets/azcli-DL2My_i-.js +2 -0
- package/dist/renderer/assets/bat-B-nC98wG.js +2 -0
- package/dist/renderer/assets/bicep-Ju5MwOgh.js +3 -0
- package/dist/renderer/assets/cameligo-8Eu1TyBr.js +2 -0
- package/dist/renderer/assets/chunk-DPI0Y_ll.js +1 -0
- package/dist/renderer/assets/clojure-u-RpMkH3.js +2 -0
- package/dist/renderer/assets/codicon-ngg6Pgfi.ttf +0 -0
- package/dist/renderer/assets/coffee-CdA7bbTe.js +2 -0
- package/dist/renderer/assets/constants-CLAQX6VZ.js +2 -0
- package/dist/renderer/assets/cpp-CzNFP8ks.js +2 -0
- package/dist/renderer/assets/csharp-j1LThmcE.js +2 -0
- package/dist/renderer/assets/csp-CLRC61y6.js +2 -0
- package/dist/renderer/assets/css-r6rC_7P2.js +4 -0
- package/dist/renderer/assets/css.worker-DyDu5ynT.js +90 -0
- package/dist/renderer/assets/cssMode-BCBgxrnA.js +2 -0
- package/dist/renderer/assets/cypher-CW08XVUh.js +2 -0
- package/dist/renderer/assets/dart-Cs9aL5T_.js +2 -0
- package/dist/renderer/assets/dockerfile-BWM0M184.js +2 -0
- package/dist/renderer/assets/ecl-MJJuer5P.js +2 -0
- package/dist/renderer/assets/editor-CWI9TnMM.css +1 -0
- package/dist/renderer/assets/editor.api2-BTaYmRq7.js +873 -0
- package/dist/renderer/assets/editor.worker-Dpt_xPrs.js +27 -0
- package/dist/renderer/assets/elixir-D2AIuXqn.js +2 -0
- package/dist/renderer/assets/flow9-B2H24giC.js +2 -0
- package/dist/renderer/assets/freemarker2-DGDGzimW.js +4 -0
- package/dist/renderer/assets/fsharp-CMk2OIJN.js +2 -0
- package/dist/renderer/assets/go-BrMkuJg0.js +2 -0
- package/dist/renderer/assets/graphql-PSR1UKGv.js +2 -0
- package/dist/renderer/assets/handlebars-bOHhw3EG.js +2 -0
- package/dist/renderer/assets/hcl-DAQrbDOW.js +2 -0
- package/dist/renderer/assets/html-BMyuX0_c.js +2 -0
- package/dist/renderer/assets/html.worker-IWNXhnIC.js +503 -0
- package/dist/renderer/assets/htmlMode-DR4kXJ7l.js +2 -0
- package/dist/renderer/assets/index-CcJKzatF.js +50 -0
- package/dist/renderer/assets/ini-0TG5BxW0.js +2 -0
- package/dist/renderer/assets/input-QGx6FFX1.js +2 -0
- package/dist/renderer/assets/ipc-transport-BT4QYQqu.css +1 -0
- package/dist/renderer/assets/{ipc-transport-BzPzxPwf.js → ipc-transport-DvZvwK-Z.js} +5 -5
- package/dist/renderer/assets/java-rgorz17v.js +2 -0
- package/dist/renderer/assets/javascript-Bu-tl1P7.js +2 -0
- package/dist/renderer/assets/json.worker-c4h5s80L.js +59 -0
- package/dist/renderer/assets/jsonMode-MQV_ffLR.js +8 -0
- package/dist/renderer/assets/julia-C8VMdHm8.js +2 -0
- package/dist/renderer/assets/kotlin-AhhC4Qhm.js +2 -0
- package/dist/renderer/assets/less-Cgca25AP.js +3 -0
- package/dist/renderer/assets/lexon-D0GHdBaw.js +2 -0
- package/dist/renderer/assets/liquid-ClkfOvhB.js +2 -0
- package/dist/renderer/assets/lspLanguageFeatures-Bke_4Ie9.js +5 -0
- package/dist/renderer/assets/lua-DmRsNG-P.js +2 -0
- package/dist/renderer/assets/m3-BgL5dNKT.js +2 -0
- package/dist/renderer/assets/markdown-BuJfycGS.js +2 -0
- package/dist/renderer/assets/mdx-RZdUskPu.js +2 -0
- package/dist/renderer/assets/mips-C9m_93PR.js +2 -0
- package/dist/renderer/assets/monaco.contribution-B7rUMaEv.js +3 -0
- package/dist/renderer/assets/msdax-CpFHC9OI.js +2 -0
- package/dist/renderer/assets/mysql-qFvltsqN.js +2 -0
- package/dist/renderer/assets/objective-c-Bnmr858J.js +2 -0
- package/dist/renderer/assets/pascal-WP0_D5AO.js +2 -0
- package/dist/renderer/assets/pascaligo-Blom4Rij.js +2 -0
- package/dist/renderer/assets/perl-B-vk8g64.js +2 -0
- package/dist/renderer/assets/pgsql-Cgvz6v67.js +2 -0
- package/dist/renderer/assets/php-8a3Lrw9m.js +2 -0
- package/dist/renderer/assets/pla-DuFqEZ8V.js +2 -0
- package/dist/renderer/assets/popover-BOH1If1J.js +2 -0
- package/dist/renderer/assets/postiats-DkLtSgkp.js +2 -0
- package/dist/renderer/assets/powerquery-BJ1aNepW.js +2 -0
- package/dist/renderer/assets/powershell-rE98k687.js +2 -0
- package/dist/renderer/assets/protobuf-CUheFacr.js +3 -0
- package/dist/renderer/assets/pug-LDcAMD8w.js +2 -0
- package/dist/renderer/assets/python-Cobrm_-8.js +2 -0
- package/dist/renderer/assets/qsharp-DUKSQoR1.js +2 -0
- package/dist/renderer/assets/r-D-QApv87.js +2 -0
- package/dist/renderer/assets/razor-BEUIQFNJ.js +2 -0
- package/dist/renderer/assets/redis-SXdDyWR9.js +2 -0
- package/dist/renderer/assets/redshift-Y6lsCryn.js +2 -0
- package/dist/renderer/assets/restructuredtext-edObr9a8.js +2 -0
- package/dist/renderer/assets/ruby-CNnUfF-8.js +2 -0
- package/dist/renderer/assets/rust-IHUZWzBr.js +2 -0
- package/dist/renderer/assets/sb-DrUvY44N.js +2 -0
- package/dist/renderer/assets/scala-B4hbXGLM.js +2 -0
- package/dist/renderer/assets/scheme-BGrd12j3.js +2 -0
- package/dist/renderer/assets/scss-x5G1ES4U.js +4 -0
- package/dist/renderer/assets/select-C7JQ8G5N.js +2 -0
- package/dist/renderer/assets/settings-DpAbTJyF.js +2 -0
- package/dist/renderer/assets/{settings-api-BXCw9vOZ.js → settings-api-RD2IZF53.js} +2 -2
- package/dist/renderer/assets/shell-DOehe2Y8.js +2 -0
- package/dist/renderer/assets/solidity-BeRvcwWV.js +2 -0
- package/dist/renderer/assets/sophia-DZbkUNjy.js +2 -0
- package/dist/renderer/assets/sparql-B7_oi5-h.js +2 -0
- package/dist/renderer/assets/sql-CTlsFWVE.js +2 -0
- package/dist/renderer/assets/st-DJVEJdPE.js +2 -0
- package/dist/renderer/assets/swift-CwhT3fYa.js +2 -0
- package/dist/renderer/assets/systemverilog-BQN63pkN.js +2 -0
- package/dist/renderer/assets/tcl-DqwfpskA.js +2 -0
- package/dist/renderer/assets/ts.worker-BwM5Ha3L.js +67720 -0
- package/dist/renderer/assets/tsMode-BHa7dl9v.js +12 -0
- package/dist/renderer/assets/twig-BiyenUgc.js +2 -0
- package/dist/renderer/assets/typescript-15aT0Yj8.js +2 -0
- package/dist/renderer/assets/typespec-CWOJribt.js +2 -0
- package/dist/renderer/assets/vb-Cq5F87m3.js +2 -0
- package/dist/renderer/assets/wgsl-BAvW2lVr.js +299 -0
- package/dist/renderer/assets/workbenchSettings-CNJX4Qna.js +8 -0
- package/dist/renderer/assets/workers-CRBS0W-v.js +2 -0
- package/dist/renderer/assets/xml-bR2Zh-HV.js +2 -0
- package/dist/renderer/assets/yaml-Bdk54Qrb.js +2 -0
- package/dist/renderer/entries/main/index.html +29 -6
- package/dist/renderer/entries/popover/index.html +7 -6
- package/dist/renderer/entries/settings/index.html +6 -5
- package/dist/renderer/entries/workbench-settings/index.html +6 -5
- package/dist/service-host/preload.cjs +254 -0
- package/dist/service-host/service.html +10 -0
- package/dist/service-host/sourcemap-rewrite.cjs +58 -0
- package/dist/service-host/sync-api-patch.js +20 -0
- package/dist/service-host/sync-impls/menu-button.js +16 -0
- package/dist/service-host/sync-impls/storage.js +50 -0
- package/dist/service-host/sync-impls/system-info.js +54 -0
- package/dist/shared/appdata-accumulator.d.ts +95 -0
- package/dist/shared/appdata-accumulator.js +213 -0
- package/dist/shared/bridge-channels.d.ts +364 -0
- package/dist/shared/bridge-channels.js +54 -0
- package/dist/shared/constants.d.ts +0 -4
- package/dist/shared/constants.js +0 -4
- package/dist/shared/ipc-channels.d.ts +108 -1
- package/dist/shared/ipc-channels.js +127 -10
- package/dist/shared/ipc-schemas.d.ts +65 -2
- package/dist/shared/ipc-schemas.js +79 -3
- package/dist/shared/open-in-editor.d.ts +71 -0
- package/dist/shared/open-in-editor.js +138 -0
- package/dist/shared/simulator-api-metadata.d.ts +21 -0
- package/dist/shared/simulator-api-metadata.js +23 -0
- package/dist/shared/types.d.ts +2 -2
- package/dist/shared/vpath.d.ts +42 -0
- package/dist/shared/vpath.js +105 -0
- package/dist/simulator/assets/device-shell-DsdcNEkt.css +1 -0
- package/dist/simulator/assets/device-shell-vwYSOVrh.js +2 -0
- package/dist/simulator/assets/jsx-runtime-P6ZegaOf.js +2 -0
- package/dist/simulator/assets/simulator-DddliUL5.js +10 -0
- package/dist/simulator/assets/simulator-mini-app-BDNu5n26.js +2 -0
- package/dist/simulator/device-shell/menu-button-geometry.js +8 -0
- package/dist/simulator/simulator.html +2 -112
- package/package.json +9 -9
- package/dist/main/utils/disposable.d.ts +0 -18
- package/dist/main/utils/disposable.js +0 -67
- package/dist/renderer/assets/constants-DI382mTP.js +0 -2
- package/dist/renderer/assets/index-4lkyF644.js +0 -46
- package/dist/renderer/assets/input-D4byFOLS.js +0 -2
- package/dist/renderer/assets/ipc-transport-DqbRdZNO.css +0 -1
- package/dist/renderer/assets/popover-cxKrg_os.js +0 -2
- package/dist/renderer/assets/select-BgSkkdHW.js +0 -2
- package/dist/renderer/assets/settings-oD2K1jdT.js +0 -2
- package/dist/renderer/assets/workbenchSettings-CTNBpTft.js +0 -8
- package/dist/simulator/assets/simulator-CVOFTpSj.js +0 -9
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared, pure helpers for the "click a console file link → open the built-in
|
|
3
|
+
* Monaco editor" pipeline (native-host).
|
|
4
|
+
*
|
|
5
|
+
* The right-panel console is the embedded Chromium DevTools front-end inspecting
|
|
6
|
+
* the service host. When a sourcemap maps a console frame back to source, the
|
|
7
|
+
* front-end can be made to route a source-link click through an "open resource
|
|
8
|
+
* handler" instead of its own Sources panel (the same hook IDEs use to integrate
|
|
9
|
+
* with Chrome DevTools). Our handler can't talk IPC directly from the closed
|
|
10
|
+
* DevTools realm, so it encodes the target as a sentinel URL and asks the
|
|
11
|
+
* front-end to "open" it; Electron surfaces that as a `devtools-open-url` event
|
|
12
|
+
* on the inspected webContents, which main decodes here.
|
|
13
|
+
*
|
|
14
|
+
* This module owns ONLY the pure string/URL logic (encode + decode + map a
|
|
15
|
+
* DevTools resource URL to a project-relative path). It has no electron / DOM /
|
|
16
|
+
* node deps so it is unit-testable and shared by main + the injected front-end
|
|
17
|
+
* snippet's expectations.
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* Sentinel scheme for the encoded "open in editor" request. A bare custom scheme
|
|
21
|
+
* (no `//authority`) keeps the encoded payload entirely in the URL's path/query,
|
|
22
|
+
* which `InspectorFrontendHost.openInNewTab` forwards verbatim to Electron's
|
|
23
|
+
* `devtools-open-url` event.
|
|
24
|
+
*/
|
|
25
|
+
export const OPEN_IN_EDITOR_SCHEME = 'dimina-open-in-editor';
|
|
26
|
+
/**
|
|
27
|
+
* Encode an open-in-editor request as a sentinel URL the DevTools front-end can
|
|
28
|
+
* hand to `InspectorFrontendHost.openInNewTab(...)`. All fields ride in the
|
|
29
|
+
* query string so no value is ever interpolated into a path segment.
|
|
30
|
+
*/
|
|
31
|
+
export function encodeOpenInEditorUrl(req) {
|
|
32
|
+
const params = new URLSearchParams();
|
|
33
|
+
params.set('u', req.url);
|
|
34
|
+
if (typeof req.line === 'number' && Number.isFinite(req.line)) {
|
|
35
|
+
params.set('l', String(Math.trunc(req.line)));
|
|
36
|
+
}
|
|
37
|
+
if (typeof req.column === 'number' && Number.isFinite(req.column)) {
|
|
38
|
+
params.set('c', String(Math.trunc(req.column)));
|
|
39
|
+
}
|
|
40
|
+
return `${OPEN_IN_EDITOR_SCHEME}:?${params.toString()}`;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Decode a sentinel URL produced by `encodeOpenInEditorUrl`. Returns null for
|
|
44
|
+
* any URL that is not our sentinel scheme (so a real "open in new tab" link the
|
|
45
|
+
* user clicked is left to Electron's default external-open path).
|
|
46
|
+
*/
|
|
47
|
+
export function decodeOpenInEditorUrl(raw) {
|
|
48
|
+
if (typeof raw !== 'string')
|
|
49
|
+
return null;
|
|
50
|
+
const prefix = `${OPEN_IN_EDITOR_SCHEME}:`;
|
|
51
|
+
if (!raw.startsWith(prefix))
|
|
52
|
+
return null;
|
|
53
|
+
// Strip the scheme; tolerate an optional leading `?` on the query.
|
|
54
|
+
let query = raw.slice(prefix.length);
|
|
55
|
+
if (query.startsWith('?'))
|
|
56
|
+
query = query.slice(1);
|
|
57
|
+
const params = new URLSearchParams(query);
|
|
58
|
+
const url = params.get('u');
|
|
59
|
+
if (!url)
|
|
60
|
+
return null;
|
|
61
|
+
const out = { url };
|
|
62
|
+
const l = params.get('l');
|
|
63
|
+
const c = params.get('c');
|
|
64
|
+
if (l !== null && l !== '') {
|
|
65
|
+
const n = Number(l);
|
|
66
|
+
if (Number.isFinite(n))
|
|
67
|
+
out.line = Math.trunc(n);
|
|
68
|
+
}
|
|
69
|
+
if (c !== null && c !== '') {
|
|
70
|
+
const n = Number(c);
|
|
71
|
+
if (Number.isFinite(n))
|
|
72
|
+
out.column = Math.trunc(n);
|
|
73
|
+
}
|
|
74
|
+
return out;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Map a DevTools resource URL to a PROJECT-RELATIVE source path (POSIX, no
|
|
78
|
+
* leading slash) — the same key the in-renderer Monaco editor opens files by
|
|
79
|
+
* (`joinPosix(root, rel)` → `project:fs:readFile`).
|
|
80
|
+
*
|
|
81
|
+
* The compiler emits each `logic.js.map` with `sources` = the project-relative
|
|
82
|
+
* source path (e.g. `pages/home/home.js`, or `subpkg/pages/x/x.js` for a sub-
|
|
83
|
+
* package — both already rooted at the project). DevTools resolves those against
|
|
84
|
+
* the map URL on the dev server, producing
|
|
85
|
+
* `http://127.0.0.1:<port>/<appId>/<source-path>`. So recovering the project-
|
|
86
|
+
* relative path is exactly: strip the origin, then strip the FIRST path segment
|
|
87
|
+
* (the `<appId>` the dev server namespaces the bundle under). What remains is
|
|
88
|
+
* the source path the compiler recorded, which is the editor's open key — this
|
|
89
|
+
* holds for both the main package and sub-packages without needing the project's
|
|
90
|
+
* appId / root threaded in.
|
|
91
|
+
*
|
|
92
|
+
* @param resourceUrl The absolute URL DevTools reported for the clicked source.
|
|
93
|
+
* @param expectedOrigin Optional dev-server origin to gate on
|
|
94
|
+
* (`http://127.0.0.1:<port>`); when given, a URL from a different origin (a
|
|
95
|
+
* framework/`webpack://`/`node:` frame) returns null instead of mis-mapping.
|
|
96
|
+
* @returns the project-relative POSIX path, or null when the URL is not a
|
|
97
|
+
* mappable dev-server source.
|
|
98
|
+
*/
|
|
99
|
+
export function resourceUrlToProjectRelativePath(resourceUrl, expectedOrigin) {
|
|
100
|
+
if (typeof resourceUrl !== 'string' || !resourceUrl)
|
|
101
|
+
return null;
|
|
102
|
+
let resource;
|
|
103
|
+
try {
|
|
104
|
+
resource = new URL(resourceUrl);
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
// Only http(s) dev-server sources map to project files; schemes like
|
|
110
|
+
// `webpack://`, `node:`, `data:` are framework/runtime frames with no file.
|
|
111
|
+
if (resource.protocol !== 'http:' && resource.protocol !== 'https:')
|
|
112
|
+
return null;
|
|
113
|
+
if (expectedOrigin) {
|
|
114
|
+
let base;
|
|
115
|
+
try {
|
|
116
|
+
base = new URL(expectedOrigin);
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
if (resource.origin !== base.origin)
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
// pathname is `/<appId>/<source-path>`. Drop the leading appId segment; the
|
|
125
|
+
// remainder, percent-decoded per segment, is the project-relative path.
|
|
126
|
+
const segments = resource.pathname.split('/').filter(Boolean).map((s) => {
|
|
127
|
+
try {
|
|
128
|
+
return decodeURIComponent(s);
|
|
129
|
+
}
|
|
130
|
+
catch {
|
|
131
|
+
return s;
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
if (segments.length < 2)
|
|
135
|
+
return null;
|
|
136
|
+
return segments.slice(1).join('/');
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=open-in-editor.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Persistent (subscription) simulator APIs — a call that, once made, keeps
|
|
3
|
+
* delivering a response on every underlying event instead of settling once.
|
|
4
|
+
*
|
|
5
|
+
* The dimina service runtime strips `keep` / `evtId` / `success` before the
|
|
6
|
+
* call leaves the service host (it stores them service-local in
|
|
7
|
+
* `callback.store`), so by the time `audioListen` reaches the container its
|
|
8
|
+
* `keep: true` intent is gone and it would degrade to a one-shot call —
|
|
9
|
+
* dropping every audio DOM event after the first. The container and router
|
|
10
|
+
* therefore recognise these APIs by NAME and treat them as persistent
|
|
11
|
+
* regardless of the (stripped) params.
|
|
12
|
+
*
|
|
13
|
+
* Currently only `audioListen` — the InnerAudioContext DOM-event bridge
|
|
14
|
+
* (canplay / play / pause / ended / error / timeupdate / waiting / seeking /
|
|
15
|
+
* seeked). Add any new subscription API here: this is the single source of
|
|
16
|
+
* truth, consumed by `bridge-router` (skip the one-shot timeout, keep-alive
|
|
17
|
+
* responses) and `run-api-async` (no premature settle, re-fire on every event).
|
|
18
|
+
*/
|
|
19
|
+
export declare const PERSISTENT_SIMULATOR_APIS: ReadonlySet<string>;
|
|
20
|
+
export declare function isPersistentSimulatorApi(name: string): boolean;
|
|
21
|
+
//# sourceMappingURL=simulator-api-metadata.d.ts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Persistent (subscription) simulator APIs — a call that, once made, keeps
|
|
3
|
+
* delivering a response on every underlying event instead of settling once.
|
|
4
|
+
*
|
|
5
|
+
* The dimina service runtime strips `keep` / `evtId` / `success` before the
|
|
6
|
+
* call leaves the service host (it stores them service-local in
|
|
7
|
+
* `callback.store`), so by the time `audioListen` reaches the container its
|
|
8
|
+
* `keep: true` intent is gone and it would degrade to a one-shot call —
|
|
9
|
+
* dropping every audio DOM event after the first. The container and router
|
|
10
|
+
* therefore recognise these APIs by NAME and treat them as persistent
|
|
11
|
+
* regardless of the (stripped) params.
|
|
12
|
+
*
|
|
13
|
+
* Currently only `audioListen` — the InnerAudioContext DOM-event bridge
|
|
14
|
+
* (canplay / play / pause / ended / error / timeupdate / waiting / seeking /
|
|
15
|
+
* seeked). Add any new subscription API here: this is the single source of
|
|
16
|
+
* truth, consumed by `bridge-router` (skip the one-shot timeout, keep-alive
|
|
17
|
+
* responses) and `run-api-async` (no premature settle, re-fire on every event).
|
|
18
|
+
*/
|
|
19
|
+
export const PERSISTENT_SIMULATOR_APIS = new Set(['audioListen']);
|
|
20
|
+
export function isPersistentSimulatorApi(name) {
|
|
21
|
+
return PERSISTENT_SIMULATOR_APIS.has(name);
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=simulator-api-metadata.js.map
|
package/dist/shared/types.d.ts
CHANGED
|
@@ -115,14 +115,14 @@ export interface WorkbenchHostInstance {
|
|
|
115
115
|
* when it closes; the returned Disposable evicts it explicitly and is also
|
|
116
116
|
* registered into `context.registry` for context-scoped cleanup.
|
|
117
117
|
*/
|
|
118
|
-
registerTrustedWindow(win: import('electron').BrowserWindow): import('
|
|
118
|
+
registerTrustedWindow(win: import('electron').BrowserWindow): import('@dimina-kit/electron-deck/main').Disposable;
|
|
119
119
|
/**
|
|
120
120
|
* Registers a simulator custom API into THIS context's registry, callable
|
|
121
121
|
* from mini-program code as `wx.<name>(params)`. The registration joins
|
|
122
122
|
* `context.registry`, so it is released when the context is disposed.
|
|
123
123
|
* The returned Disposable removes only the registration it created.
|
|
124
124
|
*/
|
|
125
|
-
registerSimulatorApi(name: string, handler: SimulatorApiHandler): import('
|
|
125
|
+
registerSimulatorApi(name: string, handler: SimulatorApiHandler): import('@dimina-kit/electron-deck/main').Disposable;
|
|
126
126
|
/**
|
|
127
127
|
* Per-context toolbar surface. `set()` atomically replaces the whole table
|
|
128
128
|
* of toolbar actions stored on THIS context (duplicate `id` → throws),
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase 0 vpath resolver.
|
|
3
|
+
*
|
|
4
|
+
* Spec: `docs/file-system.md` §3.3 — single resolver shared by every FSM
|
|
5
|
+
* entry, the renderer-side temp store, and (Phase 1) the main-process
|
|
6
|
+
* protocol.handle / disk reader.
|
|
7
|
+
*
|
|
8
|
+
* resolveVPath(url): { kind, writable, realPath? } | null
|
|
9
|
+
*
|
|
10
|
+
* - `difile://_tmp/<id>` → kind=tmp, writable=false, no realPath
|
|
11
|
+
* - `difile://_store/<id>` → kind=store, writable=false, realPath in base
|
|
12
|
+
* - `difile://<rel>` → kind=usr, writable=true, realPath in base
|
|
13
|
+
*
|
|
14
|
+
* Security invariants (the resolver returns `null` instead of throwing):
|
|
15
|
+
* - any non-`difile://` scheme is rejected outright;
|
|
16
|
+
* - any `..` segment (raw or URL-encoded) is rejected before canonicalize;
|
|
17
|
+
* - after `path.normalize` the resulting `realPath` MUST stay inside the
|
|
18
|
+
* sandbox base; otherwise `null`;
|
|
19
|
+
* - reserved prefixes `_tmp/` and `_store/` are case-sensitive — `_TMP/`,
|
|
20
|
+
* `_Tmp/`, etc. fall through to the user-data namespace.
|
|
21
|
+
*/
|
|
22
|
+
export type VPathKind = 'tmp' | 'store' | 'usr';
|
|
23
|
+
export interface ResolvedVPath {
|
|
24
|
+
kind: VPathKind;
|
|
25
|
+
/** `tmp` and `store` are runtime-owned and read-only; `usr` is writable. */
|
|
26
|
+
writable: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Canonical local path on disk for `store` / `usr` kinds (always within the
|
|
29
|
+
* USER_DATA_PATH base directory after canonicalize). `tmp` kind has no
|
|
30
|
+
* realPath — the bytes live in the renderer-side Blob Map.
|
|
31
|
+
*/
|
|
32
|
+
realPath?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* USER_DATA_PATH sandbox base. Looked up dynamically on every call so test
|
|
36
|
+
* doubles (e.g. monkey-patching `os.homedir`) and the `DIMINA_HOME` env
|
|
37
|
+
* override apply per invocation. The env override exists for headless test
|
|
38
|
+
* affordance and to keep the renderer/main store sharing one base.
|
|
39
|
+
*/
|
|
40
|
+
export declare function sandboxBase(): string;
|
|
41
|
+
export declare function resolveVPath(url: unknown): ResolvedVPath | null;
|
|
42
|
+
//# sourceMappingURL=vpath.d.ts.map
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase 0 vpath resolver.
|
|
3
|
+
*
|
|
4
|
+
* Spec: `docs/file-system.md` §3.3 — single resolver shared by every FSM
|
|
5
|
+
* entry, the renderer-side temp store, and (Phase 1) the main-process
|
|
6
|
+
* protocol.handle / disk reader.
|
|
7
|
+
*
|
|
8
|
+
* resolveVPath(url): { kind, writable, realPath? } | null
|
|
9
|
+
*
|
|
10
|
+
* - `difile://_tmp/<id>` → kind=tmp, writable=false, no realPath
|
|
11
|
+
* - `difile://_store/<id>` → kind=store, writable=false, realPath in base
|
|
12
|
+
* - `difile://<rel>` → kind=usr, writable=true, realPath in base
|
|
13
|
+
*
|
|
14
|
+
* Security invariants (the resolver returns `null` instead of throwing):
|
|
15
|
+
* - any non-`difile://` scheme is rejected outright;
|
|
16
|
+
* - any `..` segment (raw or URL-encoded) is rejected before canonicalize;
|
|
17
|
+
* - after `path.normalize` the resulting `realPath` MUST stay inside the
|
|
18
|
+
* sandbox base; otherwise `null`;
|
|
19
|
+
* - reserved prefixes `_tmp/` and `_store/` are case-sensitive — `_TMP/`,
|
|
20
|
+
* `_Tmp/`, etc. fall through to the user-data namespace.
|
|
21
|
+
*/
|
|
22
|
+
// Main-process (Node ESM) resolves these natively. Simulator (vite browser
|
|
23
|
+
// bundle) externalizes node builtins as no-op stubs — that's safe here only
|
|
24
|
+
// because the simulator never enters the `store`/`usr` branches below
|
|
25
|
+
// (renderer-side FSM forwards disk-backed reads/writes to main via IPC).
|
|
26
|
+
import os from 'node:os';
|
|
27
|
+
import path from 'node:path';
|
|
28
|
+
const DIFILE_PREFIX = 'difile://';
|
|
29
|
+
/**
|
|
30
|
+
* USER_DATA_PATH sandbox base. Looked up dynamically on every call so test
|
|
31
|
+
* doubles (e.g. monkey-patching `os.homedir`) and the `DIMINA_HOME` env
|
|
32
|
+
* override apply per invocation. The env override exists for headless test
|
|
33
|
+
* affordance and to keep the renderer/main store sharing one base.
|
|
34
|
+
*/
|
|
35
|
+
export function sandboxBase() {
|
|
36
|
+
const env = (typeof process !== 'undefined' && process.env && process.env.DIMINA_HOME) || '';
|
|
37
|
+
if (env) {
|
|
38
|
+
return path.join(env, 'files');
|
|
39
|
+
}
|
|
40
|
+
return path.join(os.homedir(), '.dimina', 'files');
|
|
41
|
+
}
|
|
42
|
+
export function resolveVPath(url) {
|
|
43
|
+
if (typeof url !== 'string')
|
|
44
|
+
return null;
|
|
45
|
+
if (!url.startsWith(DIFILE_PREFIX))
|
|
46
|
+
return null;
|
|
47
|
+
const raw = url.slice(DIFILE_PREFIX.length);
|
|
48
|
+
if (raw.length === 0)
|
|
49
|
+
return null;
|
|
50
|
+
// Decode URL-encoded sequences first so `%2e%2e` style escapes are caught
|
|
51
|
+
// by the segment check below.
|
|
52
|
+
let decoded;
|
|
53
|
+
try {
|
|
54
|
+
decoded = decodeURIComponent(raw);
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
// Reject NUL bytes (raw or %00) — Node `fs.*` throws TypeError on a NUL
|
|
60
|
+
// in the path, bypassing the API's `fail` callback and crashing the
|
|
61
|
+
// renderer. Pull the rejection up to the validator.
|
|
62
|
+
if (decoded.includes('\0'))
|
|
63
|
+
return null;
|
|
64
|
+
// Developer convention: `wx.env.USER_DATA_PATH = 'difile://'` so a write
|
|
65
|
+
// like `${USER_DATA_PATH}/foo.txt` produces `difile:///foo.txt`. Strip
|
|
66
|
+
// leading slashes so that path-joins cleanly under the sandbox base.
|
|
67
|
+
decoded = decoded.replace(/^[/\\]+/, '');
|
|
68
|
+
if (decoded.length === 0)
|
|
69
|
+
return null;
|
|
70
|
+
// Reject any '..' or '.' segment after decoding. We split on both '/' and
|
|
71
|
+
// '\\' so Windows-style separators cannot smuggle a traversal segment past
|
|
72
|
+
// the validator on POSIX hosts.
|
|
73
|
+
const segments = decoded.split(/[/\\]+/);
|
|
74
|
+
if (segments.some(s => s === '..' || s === '.'))
|
|
75
|
+
return null;
|
|
76
|
+
// Classify by reserved prefix (case-sensitive — `_TMP/` is a user file).
|
|
77
|
+
let kind;
|
|
78
|
+
let writable;
|
|
79
|
+
if (decoded.startsWith('_tmp/')) {
|
|
80
|
+
kind = 'tmp';
|
|
81
|
+
writable = false;
|
|
82
|
+
}
|
|
83
|
+
else if (decoded.startsWith('_store/')) {
|
|
84
|
+
kind = 'store';
|
|
85
|
+
writable = false;
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
kind = 'usr';
|
|
89
|
+
writable = true;
|
|
90
|
+
}
|
|
91
|
+
// `tmp` lives in the renderer Blob Map — no realPath.
|
|
92
|
+
if (kind === 'tmp') {
|
|
93
|
+
return { kind, writable };
|
|
94
|
+
}
|
|
95
|
+
// `store` / `usr`: anchor under the sandbox base and assert containment
|
|
96
|
+
// after normalization. Defense in depth against any traversal that the
|
|
97
|
+
// segment check above missed (e.g. backslash trickery on POSIX).
|
|
98
|
+
const base = sandboxBase();
|
|
99
|
+
const joined = path.join(base, decoded);
|
|
100
|
+
const normalized = path.normalize(joined);
|
|
101
|
+
if (normalized !== base && !normalized.startsWith(base + path.sep))
|
|
102
|
+
return null;
|
|
103
|
+
return { kind, writable, realPath: normalized };
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=vpath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.menu-capsule{-webkit-backdrop-filter:blur(4px);box-sizing:border-box;pointer-events:none;background:#fff9;border:.5px solid #00000014;border-radius:16px;align-items:center;display:flex;position:absolute;overflow:hidden}.menu-capsule--white{color:#fff;background:#ffffff26;border-color:#fff6}.menu-capsule--black{color:#000;background:#ffffffd9;border-color:#00000014}.menu-capsule__more,.menu-capsule__close{flex:1;justify-content:center;align-items:center;display:flex}.menu-capsule__more{gap:3px}.menu-capsule__more span{background:currentColor;border-radius:50%;width:4px;height:4px}.menu-capsule__divider{opacity:.4;background:currentColor;width:.5px;height:16px}.menu-capsule__close svg{color:currentColor}.nav-bar{box-sizing:border-box;flex-direction:column;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,PingFang SC,sans-serif;display:flex;position:relative}.nav-bar--custom{z-index:200;pointer-events:none;position:absolute;top:0;left:0;right:0;background-color:#0000!important}.nav-bar--custom .menu-capsule{pointer-events:auto}.nav-bar__row{align-items:center;padding:0 12px;display:flex;position:relative}.nav-bar__leading{z-index:1;align-items:center;gap:6px;display:flex;position:absolute;top:0;bottom:0;left:8px}.nav-bar__back,.nav-bar__home{cursor:pointer;width:32px;height:32px;color:inherit;background:0 0;border:0;justify-content:center;align-items:center;padding:0;display:flex}.nav-bar__title{flex:1;align-items:center;gap:6px;min-width:0;font-size:17px;font-weight:500;display:flex}.nav-bar__title--center{justify-content:center}.nav-bar__title--left{justify-content:flex-start;padding-left:48px}.nav-bar__title-text{text-overflow:ellipsis;white-space:nowrap;max-width:60%;overflow:hidden}.nav-bar__spinner{border:2px solid;border-right-color:#0000;border-radius:50%;width:14px;height:14px;animation:.8s linear infinite nav-bar-spin}@keyframes nav-bar-spin{to{transform:rotate(360deg)}}.device-statusbar{z-index:300;box-sizing:border-box;pointer-events:none;letter-spacing:.2px;justify-content:space-between;align-items:center;padding:0 28px;font:600 14px/1 -apple-system,BlinkMacSystemFont,SF Pro Text,Segoe UI,sans-serif;display:flex;position:absolute;top:0;left:0;right:0}.device-statusbar__time{font-variant-numeric:tabular-nums}.device-statusbar__notch{background:#000;position:absolute;left:50%;transform:translate(-50%)}.device-statusbar__icons{align-items:center;gap:6px;display:inline-flex}.device-statusbar__signal,.device-statusbar__wifi,.device-statusbar__battery{background:currentColor;display:block}.device-statusbar__signal{width:17px;height:11px;-webkit-mask:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 17 11'><rect x='0' y='8' width='3' height='3' rx='1'/><rect x='4.5' y='6' width='3' height='5' rx='1'/><rect x='9' y='3' width='3' height='8' rx='1'/><rect x='13.5' y='0' width='3' height='11' rx='1'/></svg>") 50%/contain no-repeat;mask:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 17 11'><rect x='0' y='8' width='3' height='3' rx='1'/><rect x='4.5' y='6' width='3' height='5' rx='1'/><rect x='9' y='3' width='3' height='8' rx='1'/><rect x='13.5' y='0' width='3' height='11' rx='1'/></svg>") 50%/contain no-repeat}.device-statusbar__wifi{border-radius:1px;width:16px;height:11px;-webkit-mask:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 11'><path d='M8 2.2c2.3 0 4.4.9 6 2.4l-1.4 1.5C11.4 4.9 9.8 4.2 8 4.2S4.6 4.9 3.4 6.1L2 4.6C3.6 3.1 5.7 2.2 8 2.2zm0 3.5c1.3 0 2.5.5 3.4 1.4L10 8.6c-.5-.5-1.2-.8-2-.8s-1.5.3-2 .8L4.6 7.1C5.5 6.2 6.7 5.7 8 5.7zm0 3.3l1.4 1.4c-.4.4-.9.6-1.4.6s-1-.2-1.4-.6L8 9z'/></svg>") 50%/contain no-repeat;mask:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 11'><path d='M8 2.2c2.3 0 4.4.9 6 2.4l-1.4 1.5C11.4 4.9 9.8 4.2 8 4.2S4.6 4.9 3.4 6.1L2 4.6C3.6 3.1 5.7 2.2 8 2.2zm0 3.5c1.3 0 2.5.5 3.4 1.4L10 8.6c-.5-.5-1.2-.8-2-.8s-1.5.3-2 .8L4.6 7.1C5.5 6.2 6.7 5.7 8 5.7zm0 3.3l1.4 1.4c-.4.4-.9.6-1.4.6s-1-.2-1.4-.6L8 9z'/></svg>") 50%/contain no-repeat}.device-statusbar__battery{background:0 0;border:1px solid;border-radius:3px;width:25px;height:12px;position:relative}.device-statusbar__battery:before{content:"";background:currentColor;border-radius:1px;position:absolute;inset:2px 8px 2px 2px}.device-statusbar__battery:after{content:"";background:currentColor;border-radius:0 1px 1px 0;width:2px;position:absolute;top:3px;bottom:3px;right:-3px}.dmb-tab-bar{width:100%;height:50px;padding-bottom:env(safe-area-inset-bottom,0px);box-sizing:content-box;z-index:9;border-top:1px solid #e0e0e0;flex-shrink:0;justify-content:space-around;align-items:stretch;display:flex}.dmb-tab-bar__item{cursor:pointer;font:inherit;color:inherit;background:0 0;border:0;outline:none;flex-direction:column;flex:1;justify-content:center;align-items:center;padding:4px 0 2px;display:flex;position:relative}.dmb-tab-bar__item:focus-visible{outline-offset:-2px;outline:2px solid #1890ff}.dmb-tab-bar__icon-slot{justify-content:center;align-items:center;width:24px;height:24px;margin-bottom:2px;display:flex}.dmb-tab-bar__icon{-o-object-fit:contain;object-fit:contain;max-width:100%;max-height:100%}.dmb-tab-bar__text{-webkit-user-select:none;user-select:none;font-size:11px;line-height:1}.dmb-tab-bar__badge{color:#fff;text-align:center;background:#f43f5e;border-radius:8px;min-width:16px;height:16px;padding:0 4px;font-size:10px;line-height:16px;position:absolute;top:0;right:calc(50% - 22px)}.dmb-tab-bar__red-dot{background:#f43f5e;border-radius:50%;width:8px;height:8px;position:absolute;top:4px;right:calc(50% - 16px)}.device-shell-root{color:#101418;box-sizing:border-box;background:#121212;width:100%;height:100vh;padding:24px;display:flex;overflow:auto}.device-shell{background:#f8fafc;border:1px solid #1014182e;border-radius:38px;flex-direction:column;flex:none;min-height:0;margin:auto;display:flex;position:relative;overflow:hidden;box-shadow:0 18px 50px #10141838}.device-shell__status-bar{letter-spacing:0;color:#111827;background:#f8fafc;flex:0 0 42px;justify-content:space-between;align-items:center;padding:0 28px;font:600 13px/1 system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif;display:flex}.device-shell__status-icons{align-items:center;gap:5px;display:inline-flex}.device-shell__status-icons span{background:#111827;display:block}.device-shell__status-icons span:first-child{border-radius:2px;width:16px;height:10px}.device-shell__status-icons span:nth-child(2){border-radius:50%;width:12px;height:12px}.device-shell__status-icons span:nth-child(3){border-radius:3px;width:20px;height:10px}.device-shell__viewport{background:#fff;flex:auto;min-height:0;position:relative}.device-shell__webview{background:#fff;border:0;width:100%;height:100%;display:block;position:absolute;inset:0}.device-shell__home-indicator{background:#f8fafc;flex:0 0 28px;position:relative}.device-shell__home-indicator:before{content:"";background:#111827;border-radius:999px;width:118px;height:4px;position:absolute;bottom:10px;left:50%;transform:translate(-50%)}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{n as e,t}from"./jsx-runtime-P6ZegaOf.js";var n=e(),r={DOM_READY:`simulator:dom-ready`,NAV_BAR:`simulator:navigation-bar`,NAV_ACTION:`simulator:nav-action`,TAB_ACTION:`simulator:tab-action`,API_CALL:`simulator:api-call`,DEVICE_CHANGE:`simulator:device-change`},i=new Set([`audioListen`]);function a(e){return i.has(e)}function o(e,t,n,r){let i=e.apiRegistry[t];if(!i)return r({ok:!1,errMsg:`${t}:fail no handler`}),Promise.resolve();let o=a(t)||(n&&typeof n==`object`&&!Array.isArray(n)?n.keep===!0:!1);return new Promise(a=>{let s=!1,c=e=>{if(s){o&&e.ok&&r({...e,keep:!0});return}s=!0,r(o&&e.ok?{...e,keep:!0}:e),a()},l=Symbol(`sim-cb-success`),u=Symbol(`sim-cb-fail`),d=Symbol(`sim-cb-complete`),f=Object.create(e);f.createCallbackFunction=e=>{if(e!=null)return(...n)=>{let r=n[0];e===l?c({ok:!0,result:r}):e===u&&c({ok:!1,errMsg:r&&typeof r==`object`&&`errMsg`in r?String(r.errMsg):`${t}:fail`,result:r})}};let p=n&&typeof n==`object`&&!Array.isArray(n)?{...n}:{},m=p.success!==void 0&&p.success!==null,h=p.fail!==void 0&&p.fail!==null,g=p.complete!==void 0&&p.complete!==null;p.success=l,p.fail=u,g&&(p.complete=d);try{let e=i.call(f,p);if(e&&typeof e.then==`function`){Promise.resolve(e).then(e=>c({ok:!0,result:e}),e=>{c({ok:!1,errMsg:`${t}:fail ${e instanceof Error?e.message:String(e)}`})});return}!m&&!h&&(o?a():c({ok:!0,result:e}))}catch(e){c({ok:!1,errMsg:`${t}:fail ${e instanceof Error?e.message:String(e)}`})}})}var s=t();function c({platform:e,statusBarHeight:t,textStyle:n}){let r=e===`ios`?87:95,i=t+(e===`ios`?4:6),a=e===`ios`?7:10;return(0,s.jsxs)(`div`,{className:`menu-capsule menu-capsule--${n}`,style:{width:r,height:32,top:i,right:a},"aria-hidden":`true`,children:[(0,s.jsxs)(`div`,{className:`menu-capsule__more`,children:[(0,s.jsx)(`span`,{}),(0,s.jsx)(`span`,{}),(0,s.jsx)(`span`,{})]}),(0,s.jsx)(`div`,{className:`menu-capsule__divider`}),(0,s.jsx)(`div`,{className:`menu-capsule__close`,children:(0,s.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`12`,height:`12`,"aria-hidden":`true`,children:(0,s.jsx)(`path`,{d:`M4 4l8 8M12 4l-8 8`,stroke:`currentColor`,strokeWidth:`1.5`,fill:`none`,strokeLinecap:`round`})})})]})}var l={linear:`linear`,easeIn:`ease-in`,easeOut:`ease-out`,easeInOut:`ease-in-out`};function u({state:e,stackDepth:t,platform:r,statusBarHeight:i,navBarHeight:a,onBack:o,onHome:u}){let d=(0,n.useMemo)(()=>{if(!e.colorAnimation||e.colorAnimation.durationMs<=0)return;let t=l[e.colorAnimation.timingFunc]??`linear`;return`background-color ${e.colorAnimation.durationMs}ms ${t}, color ${e.colorAnimation.durationMs}ms ${t}`},[e.colorAnimation]),f=e.style===`custom`,p=t>1,m=!p&&e.homeButtonVisible,h=r===`ios`?`center`:`left`,g={backgroundColor:e.backgroundColor,color:e.textStyle===`white`?`#ffffff`:`#000000`,height:i+a,paddingTop:i,transition:d};return(0,s.jsxs)(`header`,{className:`nav-bar nav-bar--${r} nav-bar--${e.textStyle}${f?` nav-bar--custom`:``}`,style:g,"aria-hidden":f,children:[!f&&(0,s.jsxs)(`div`,{className:`nav-bar__row`,style:{height:a,justifyContent:h===`center`?`center`:`flex-start`},children:[(p||m)&&(0,s.jsxs)(`div`,{className:`nav-bar__leading`,children:[p&&(0,s.jsx)(`button`,{type:`button`,className:`nav-bar__back`,"aria-label":`Back`,onClick:o,children:(0,s.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`24`,height:`24`,"aria-hidden":`true`,children:(0,s.jsx)(`path`,{d:`M15 18l-6-6 6-6`,stroke:`currentColor`,strokeWidth:`2`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`})})}),m&&(0,s.jsx)(`button`,{type:`button`,className:`nav-bar__home`,"aria-label":`Home`,onClick:u,children:(0,s.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`22`,height:`22`,"aria-hidden":`true`,children:(0,s.jsx)(`path`,{d:`M3 12l9-9 9 9M5 10v10h14V10`,stroke:`currentColor`,strokeWidth:`2`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`})})})]}),(0,s.jsxs)(`div`,{className:`nav-bar__title nav-bar__title--${h}`,style:{color:e.textStyle===`white`?`#ffffff`:`#000000`},children:[e.loading&&(0,s.jsx)(`span`,{className:`nav-bar__spinner`,"aria-hidden":`true`}),(0,s.jsx)(`span`,{className:`nav-bar__title-text`,children:e.title})]})]}),(0,s.jsx)(c,{platform:r,statusBarHeight:i,textStyle:e.textStyle})]})}function d(e){return{title:e?.title??``,backgroundColor:e?.backgroundColor??`#000000`,textStyle:e?.textStyle??`white`,style:e?.style??`default`,loading:e?.loading??!1,homeButtonVisible:e?.homeButtonVisible??!1,colorAnimation:e?.colorAnimation}}function f(e){switch(e){case`notch`:return{width:164,height:30,top:0,bottomOnly:!0};case`dynamic-island`:return{width:124,height:36,top:11,bottomOnly:!1};default:return null}}function p({height:e,notchType:t,textStyle:n}){let r=f(t);return(0,s.jsxs)(`div`,{className:`device-statusbar`,style:{height:e,color:n===`black`?`#000000`:`#ffffff`},"aria-hidden":`true`,children:[(0,s.jsx)(`span`,{className:`device-statusbar__time`,children:`9:41`}),r&&(0,s.jsx)(`div`,{className:`device-statusbar__notch`,style:{width:r.width,height:r.height,top:r.top,borderRadius:r.bottomOnly?`0 0 ${Math.round(r.height*.6)}px ${Math.round(r.height*.6)}px`:`${r.height/2}px`}}),(0,s.jsxs)(`div`,{className:`device-statusbar__icons`,children:[(0,s.jsx)(`span`,{className:`device-statusbar__signal`}),(0,s.jsx)(`span`,{className:`device-statusbar__wifi`}),(0,s.jsx)(`span`,{className:`device-statusbar__battery`})]})]})}function m({state:e,currentPath:t,resourceBaseUrl:n,appId:r,onSwitch:i}){if(!e.config||!e.visible)return null;let{color:a,selectedColor:o,backgroundColor:c,borderStyle:l,list:u}=e.config,d=a||`#999999`,f=o||`#1890ff`;return(0,s.jsx)(`div`,{className:`dmb-tab-bar`,style:{backgroundColor:c||`#ffffff`,borderTopColor:l===`white`?`#ffffff`:`#e0e0e0`},role:`tablist`,"aria-label":`TabBar`,children:u.map((a,o)=>{let c=h(a.pagePath),l=c===t,u=g(l?a.selectedIconPath??a.iconPath:a.iconPath,n,r),p=e.badges[o]??``,m=e.redDots[o]??!1;return(0,s.jsxs)(`button`,{type:`button`,className:`dmb-tab-bar__item${l?` is-selected`:``}`,role:`tab`,"aria-selected":l,onClick:()=>i(c),children:[u&&(0,s.jsx)(`span`,{className:`dmb-tab-bar__icon-slot`,children:(0,s.jsx)(`img`,{className:`dmb-tab-bar__icon`,src:u,alt:``,onError:e=>{e.currentTarget.style.display=`none`}})}),(0,s.jsx)(`span`,{className:`dmb-tab-bar__text`,style:{color:l?f:d},children:a.text||``}),p&&(0,s.jsx)(`span`,{className:`dmb-tab-bar__badge`,children:p}),!p&&m&&(0,s.jsx)(`span`,{className:`dmb-tab-bar__red-dot`})]},`${c}-${o}`)})})}function h(e){return e?e.replace(/^\/+/,``):``}function g(e,t,n){if(!e)return null;let r=e.trim();if(!r)return null;if(/^(?:data:|blob:|https?:|\/\/)/i.test(r))return r;if(!t)return null;let i=r.replace(/^\/+/,``).replace(/^\.\//,``);return i.startsWith(`${n}/`)?_(t,i.slice(n.length+1)):_(t,i)}function _(e,t){return`${e.endsWith(`/`)?e:`${e}/`}${t.replace(/^\/+/,``)}`}function v(e){if(!e)return{config:null,visible:!1,badges:[],redDots:[]};let t=e.list.length;return{config:y(e),visible:!0,badges:Array.from({length:t},()=>``),redDots:Array.from({length:t},()=>!1)}}function y(e){return{...e,list:e.list.map(e=>({...e}))}}function b(e,t){switch(t.kind){case`reset`:return{state:v(t.config),ok:!0,errMsg:`reset:ok`};case`visibility`:return{state:{...e,visible:t.visible},ok:!0,errMsg:t.visible?`showTabBar:ok`:`hideTabBar:ok`};case`apply`:return x(e,t.name,t.params)}}function x(e,t,n){if(!e.config)return{state:e,ok:!1,errMsg:`${t}:fail tabBar not configured`};switch(t){case`setTabBarStyle`:return S(e,n);case`setTabBarItem`:return C(e,n);case`showTabBar`:return{state:{...e,visible:!0},ok:!0,errMsg:`showTabBar:ok`};case`hideTabBar`:return{state:{...e,visible:!1},ok:!0,errMsg:`hideTabBar:ok`};case`setTabBarBadge`:return w(e,n);case`removeTabBarBadge`:return T(e,n);case`showTabBarRedDot`:return E(e,n,!0);case`hideTabBarRedDot`:return E(e,n,!1)}}function S(e,t){if(!e.config)return{state:e,ok:!1,errMsg:`setTabBarStyle:fail tabBar not configured`};let n={...e.config},r=(e,t)=>{let r=O(t);r&&(n[e]=r)};return r(`color`,t.color),r(`selectedColor`,t.selectedColor),r(`backgroundColor`,t.backgroundColor),(t.borderStyle===`black`||t.borderStyle===`white`)&&(n.borderStyle=t.borderStyle),{state:{...e,config:n},ok:!0,errMsg:`setTabBarStyle:ok`}}function C(e,t){let n=D(e,t);if(n.err)return{state:e,ok:!1,errMsg:`setTabBarItem:fail ${n.err}`};if(!e.config)return{state:e,ok:!1,errMsg:`setTabBarItem:fail tabBar not configured`};let r=e.config.list[n.index],i={...r,text:typeof t.text==`string`?t.text:r.text,iconPath:typeof t.iconPath==`string`?t.iconPath:r.iconPath,selectedIconPath:typeof t.selectedIconPath==`string`?t.selectedIconPath:r.selectedIconPath},a=[...e.config.list];return a[n.index]=i,{state:{...e,config:{...e.config,list:a}},ok:!0,errMsg:`setTabBarItem:ok`}}function w(e,t){let n=D(e,t);if(n.err)return{state:e,ok:!1,errMsg:`setTabBarBadge:fail ${n.err}`};let r=[...e.badges];r[n.index]=String(t.text??``);let i=[...e.redDots];return i[n.index]=!1,{state:{...e,badges:r,redDots:i},ok:!0,errMsg:`setTabBarBadge:ok`}}function T(e,t){let n=D(e,t);if(n.err)return{state:e,ok:!1,errMsg:`removeTabBarBadge:fail ${n.err}`};let r=[...e.badges];return r[n.index]=``,{state:{...e,badges:r},ok:!0,errMsg:`removeTabBarBadge:ok`}}function E(e,t,n){let r=D(e,t);if(r.err)return{state:e,ok:!1,errMsg:`${n?`showTabBarRedDot`:`hideTabBarRedDot`}:fail ${r.err}`};let i=[...e.redDots];i[r.index]=n;let a=[...e.badges];return n&&(a[r.index]=``),{state:{...e,redDots:i,badges:a},ok:!0,errMsg:`${n?`showTabBarRedDot`:`hideTabBarRedDot`}:ok`}}function D(e,t){let n=e.config?.list??[],r=t.index,i=Number(r);return n.length?r==null||!Number.isInteger(i)||i<0||i>=n.length?{index:-1,err:`invalid index ${r}`}:{index:i,err:null}:{index:-1,err:`tabBar not configured`}}function O(e){if(typeof e!=`string`)return null;let t=e.trim();return!t||t.length>64?null:/[<>"';{}()\\]/.test(t)?/^(?:rgb|rgba|hsl|hsla)\(\s*[\d.,%\s/-]+\)$/i.test(t)?t:null:t}function k(e){return e?e.replace(/^\/+/,``):``}function A(e){let[t,n]=(typeof e==`string`?e:``).split(`?`),r={};if(n)for(let e of n.split(`&`)){if(!e)continue;let t=e.indexOf(`=`),n=t>=0?e.slice(0,t):e,i=t>=0?e.slice(t+1):``;n&&(r[decodeURIComponent(n)]=decodeURIComponent(i))}return{pagePath:k(t),query:r}}function j(e){let t={};return e.isTab&&(t[e.pagePath]=[e]),{stack:[e],tabStacks:t,currentTabPath:e.isTab?e.pagePath:null}}function M(e){return e.currentTabPath?{...e.tabStacks,[e.currentTabPath]:[...e.stack]}:e.tabStacks}function N(e,t){let n=e.stack[e.stack.length-1],r=[...e.stack,t];return{next:{...e,stack:r,tabStacks:e.currentTabPath?{...e.tabStacks,[e.currentTabPath]:r}:e.tabStacks},effects:n?[{kind:`lifecycle`,bridgeId:n.bridgeId,event:`pageHide`}]:[]}}function P(e,t){if(e.stack.length<=1)return{error:`no page to back`};let n=Math.min(Math.max(1,Number.isFinite(t)?t:1),e.stack.length-1),r=e.stack.slice(e.stack.length-n),i=e.stack.slice(0,e.stack.length-n),a=i[i.length-1],o={...e,stack:i,tabStacks:e.currentTabPath?{...e.tabStacks,[e.currentTabPath]:i}:e.tabStacks,currentTabPath:a.isTab?a.pagePath:e.currentTabPath},s=[];for(let e of r)s.push({kind:`lifecycle`,bridgeId:e.bridgeId,event:`pageUnload`}),s.push({kind:`closePage`,bridgeId:e.bridgeId});return s.push({kind:`lifecycle`,bridgeId:a.bridgeId,event:`pageShow`}),{next:o,effects:s}}function F(e,t){let n=e.stack[e.stack.length-1],r=[...e.stack.slice(0,e.stack.length-1),t],i={...e,stack:r,tabStacks:e.currentTabPath?{...e.tabStacks,[e.currentTabPath]:r}:e.tabStacks},a=[];return n&&(a.push({kind:`lifecycle`,bridgeId:n.bridgeId,event:`pageUnload`}),a.push({kind:`closePage`,bridgeId:n.bridgeId})),{next:i,effects:a}}function I(e,t){let n=new Set;for(let t of e.stack)n.add(t.bridgeId);for(let t of Object.values(e.tabStacks))for(let e of t)n.add(e.bridgeId);n.delete(t.bridgeId);let r=t.isTab?{[t.pagePath]:[t]}:{},i={stack:[t],tabStacks:r,currentTabPath:t.isTab?t.pagePath:null},a=[];for(let e of n)a.push({kind:`lifecycle`,bridgeId:e,event:`pageUnload`}),a.push({kind:`closePage`,bridgeId:e});return{next:i,effects:a}}function L(e,t,n){let r=e.stack[e.stack.length-1],i=M(e),a,o=i[t];if(o&&o.length>0)a=o;else if(n)a=[n];else throw Error(`[page-stack] switchTab to ${t} requires either a cached substack or a freshly-opened entry`);let s={...e,stack:a,tabStacks:{...i,[t]:a},currentTabPath:t},c=a[a.length-1],l=[];return r&&r.bridgeId!==c.bridgeId&&l.push({kind:`lifecycle`,bridgeId:r.bridgeId,event:`pageHide`}),n||l.push({kind:`lifecycle`,bridgeId:c.bridgeId,event:`pageShow`}),{next:s,effects:l}}function R(e){let t=new Map,n=e.stack[e.stack.length-1]?.bridgeId;for(let r of e.stack)t.set(r.bridgeId,{entry:r,visible:r.bridgeId===n});for(let n of Object.values(e.tabStacks))for(let e of n)t.has(e.bridgeId)||t.set(e.bridgeId,{entry:e,visible:!1});return Array.from(t.values())}function z(e,t){let n=e.navigationBarBackgroundColor??`#ffffff`,r=e.navigationBarTextStyle??`black`,i=e.navigationStyle??`default`;return d({title:e.navigationBarTitleText??t,backgroundColor:n,textStyle:r,style:i,homeButtonVisible:e.homeButton===!0})}function B(e,t,n){switch(t){case`setNavigationBarTitle`:return{...e,title:typeof n.title==`string`?n.title:e.title};case`setNavigationBarColor`:return H(e,n);case`showNavigationBarLoading`:return{...e,loading:!0};case`hideNavigationBarLoading`:return{...e,loading:!1};case`hideHomeButton`:return{...e,homeButtonVisible:!1};default:return e}}var V=[`linear`,`easeIn`,`easeOut`,`easeInOut`];function H(e,t){let n=typeof t.frontColor==`string`?t.frontColor.toLowerCase():void 0,r=n===`#ffffff`?`white`:n===`#000000`?`black`:e.textStyle,i=typeof t.backgroundColor==`string`?t.backgroundColor:e.backgroundColor,a=(()=>{let e=t.animation;if(!e||typeof e!=`object`)return;let n=e,r=typeof n.duration==`number`&&Number.isFinite(n.duration)?Math.max(0,n.duration):0,i=typeof n.timingFunc==`string`?n.timingFunc:`linear`;return{durationMs:r,timingFunc:V.includes(i)?i:`linear`}})();return{...e,textStyle:r,backgroundColor:i,colorAnimation:a}}function U(e,t,n){let r=e=>e.bridgeId===t?{...e,navBar:n(e.navBar)}:e,i=e.stack.map(r),a={};for(let[t,n]of Object.entries(e.tabStacks))a[t]=n.map(r);return{...e,stack:i,tabStacks:a}}var W=44,G=24,K=44;function q({miniApp:e,bridgeId:t,platform:i=`ios`}){let[a,c]=(0,n.useState)(()=>e.getInitialDevice());(0,n.useEffect)(()=>e.onSimulatorEvent(r.DEVICE_CHANGE,c),[e]);let l=a?.safeAreaInsets.top??(i===`ios`?W:G),d=a?.safeAreaInsets.bottom??0,f=a?.notchType??`none`,h=(0,n.useMemo)(()=>e.getRenderPreloadUrl(),[e]),g=(0,n.useMemo)(()=>e.getTabBarConfig(),[e]),_=(0,n.useMemo)(()=>({bridgeId:t,pagePath:k(e.pagePath),query:{...e.query},isTab:!!e.getTabBarConfig()?.list.some(t=>k(t.pagePath)===k(e.pagePath)),windowConfig:e.rootWindowConfig??{},navBar:z(e.rootWindowConfig??{},e.appId)}),[e,t]),[{shell:y,tabBar:x},S]=(0,n.useState)(()=>({shell:j(_),tabBar:v(g)})),C=(0,n.useRef)({shell:y,tabBar:x});(0,n.useEffect)(()=>{C.current={shell:y,tabBar:x}},[y,x]);let w=(0,n.useCallback)(t=>{for(let n of t)n.kind===`lifecycle`?e.notifyLifecycle(n.bridgeId,n.event):n.kind===`closePage`&&e.closePage(n.bridgeId)},[e]);(0,n.useEffect)(()=>e.onSimulatorEvent(r.NAV_BAR,e=>{S(t=>({...t,shell:U(t.shell,e.bridgeId,t=>B(t,e.name,e.params))}))}),[e]),(0,n.useEffect)(()=>e.onSimulatorEvent(r.TAB_ACTION,t=>{let n=b(C.current.tabBar,{kind:`apply`,name:t.name,params:t.params});S(e=>({...e,tabBar:n.state})),e.notifyNavCallback({ok:n.ok,errMsg:n.errMsg,callbacks:t.callbacks})}),[e]);let T=(0,n.useCallback)(async t=>{let n=(n,r)=>e.notifyNavCallback({ok:n,errMsg:r,callbacks:t.callbacks});try{switch(t.name){case`navigateTo`:await J(e,C,S,w,t,n);break;case`navigateBack`:Y(C,S,w,t,n);break;case`redirectTo`:await X(e,C,S,w,t,n);break;case`reLaunch`:await Z(e,C,S,w,t,n);break;case`switchTab`:await Q(e,C,S,w,t,n);break}}catch(e){n(!1,`${t.name}:fail ${e instanceof Error?e.message:String(e)}`)}},[e,w]);(0,n.useEffect)(()=>e.onSimulatorEvent(r.NAV_ACTION,e=>{T(e)}),[T,e]),(0,n.useEffect)(()=>e.onSimulatorEvent(r.API_CALL,t=>{o(e,t.name,t.params,n=>{e.notifyApiResponse({requestId:t.requestId,ok:n.ok,result:n.result,errMsg:n.errMsg,keep:n.keep})})}),[e]);let E=(0,n.useCallback)(()=>{if(C.current.shell.stack.length<=1)return;let t=C.current.shell.stack;T({appSessionId:e.appSessionId??``,bridgeId:t[t.length-1].bridgeId,name:`navigateBack`,params:{delta:1},callbacks:{}})},[e,T]),D=(0,n.useCallback)(t=>{let n=C.current.shell;t===n.currentTabPath&&n.stack.length===1||T({appSessionId:e.appSessionId??``,bridgeId:n.stack[n.stack.length-1].bridgeId,name:`switchTab`,params:{url:`/${t}`},callbacks:{}})},[e,T]),O=y.stack[y.stack.length-1],A=R(y);return(0,n.useEffect)(()=>{e.notifyActivePage(O.bridgeId)},[e,O.bridgeId]),(0,n.useEffect)(()=>{e.notifyPageStack(y.stack.map(e=>({pagePath:e.pagePath,query:e.query})))},[e,y.stack]),(0,s.jsx)(`main`,{className:`device-shell-root`,children:(0,s.jsxs)(`section`,{className:`device-shell`,"aria-label":`Dimina simulator`,style:a?{width:a.screenWidth,height:a.screenHeight}:void 0,children:[(0,s.jsx)(p,{height:l,notchType:f,textStyle:O.navBar.textStyle}),(0,s.jsx)(u,{state:O.navBar,stackDepth:y.stack.length,platform:i,statusBarHeight:l,navBarHeight:K,onBack:E}),(0,s.jsx)(`div`,{className:`device-shell__viewport`,children:A.map(({entry:t,visible:n})=>(0,s.jsx)(`webview`,{className:`device-shell__webview`,src:e.createRenderHostUrl(t.bridgeId,t.pagePath),preload:h,partition:`persist:simulator`,allowpopups:`true`,style:{display:n?`flex`:`none`,zIndex:n?100:1}},t.bridgeId))}),O.isTab&&(0,s.jsx)(m,{state:x,currentPath:y.currentTabPath,resourceBaseUrl:e.resourceBaseUrl,appId:e.appId,onSwitch:D}),d>0&&(0,s.jsx)(`div`,{className:`device-shell__home-indicator`,style:{flexBasis:d},"aria-hidden":`true`})]})})}async function J(e,t,n,r,i,a){let{pagePath:o,query:s}=A(i.params.url);if(!o){a(!1,`navigateTo:fail invalid url`);return}if(e.getTabBarConfig()?.list.some(e=>k(e.pagePath)===o)){a(!1,`navigateTo:fail can not navigateTo a tabbar page`);return}let c=await e.openPage(o,s),l={bridgeId:c.bridgeId,pagePath:c.pagePath,query:s,isTab:c.isTab,windowConfig:c.windowConfig,navBar:z(c.windowConfig,e.appId)},{next:u,effects:d}=N(t.current.shell,l);n(e=>({...e,shell:u})),r(d),a(!0,`navigateTo:ok`)}function Y(e,t,n,r,i){let a=r.params.delta,o=Number.isFinite(Number(a))?Number(a):1,s=P(e.current.shell,o);if(`error`in s){i(!1,`navigateBack:fail ${s.error}`);return}t(e=>({...e,shell:s.next})),n(s.effects),i(!0,`navigateBack:ok`)}async function X(e,t,n,r,i,a){let{pagePath:o,query:s}=A(i.params.url);if(!o){a(!1,`redirectTo:fail invalid url`);return}if(e.getTabBarConfig()?.list.some(e=>k(e.pagePath)===o)){a(!1,`redirectTo:fail can not redirectTo a tabbar page`);return}let c=await e.openPage(o,s),l={bridgeId:c.bridgeId,pagePath:c.pagePath,query:s,isTab:c.isTab,windowConfig:c.windowConfig,navBar:z(c.windowConfig,e.appId)},{next:u,effects:d}=F(t.current.shell,l);n(e=>({...e,shell:u})),r(d),a(!0,`redirectTo:ok`)}async function Z(e,t,n,r,i,a){let{pagePath:o,query:s}=A(i.params.url);if(!o){a(!1,`reLaunch:fail invalid url`);return}let c=await e.openPage(o,s),l={bridgeId:c.bridgeId,pagePath:c.pagePath,query:s,isTab:c.isTab,windowConfig:c.windowConfig,navBar:z(c.windowConfig,e.appId)},{next:u,effects:d}=I(t.current.shell,l);n(e=>({...e,shell:u})),r(d),a(!0,`reLaunch:ok`)}async function Q(e,t,n,r,i,a){let{pagePath:o}=A(i.params.url);if(!o){a(!1,`switchTab:fail invalid url`);return}if(!e.getTabBarConfig()?.list.some(e=>k(e.pagePath)===o)){a(!1,`switchTab:fail not a tabBar page: ${o}`);return}let s=t.current.shell.tabStacks[o],c=null;if(!s||s.length===0){let t=await e.openPage(o,{});c={bridgeId:t.bridgeId,pagePath:t.pagePath,query:{},isTab:!0,windowConfig:t.windowConfig,navBar:z(t.windowConfig,e.appId)}}let{next:l,effects:u}=L(t.current.shell,o,c);n(e=>({...e,shell:l})),r(u),a(!0,`switchTab:ok`)}export{q as DeviceShell};
|
|
2
|
+
//# sourceMappingURL=device-shell-vwYSOVrh.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n)),l=(e=>typeof require<`u`?require:typeof Proxy<`u`?new Proxy(e,{get:(e,t)=>(typeof require<`u`?require:e)[t]}):e)(function(e){if(typeof require<`u`)return require.apply(this,arguments);throw Error('Calling `require` for "'+e+"\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.")}),u=o((e=>{var t=Symbol.for(`react.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.provider`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.iterator;function p(e){return typeof e!=`object`||!e?null:(e=f&&e[f]||e[`@@iterator`],typeof e==`function`?e:null)}var m={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},h=Object.assign,g={};function _(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||m}_.prototype.isReactComponent={},_.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`setState(...): takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},_.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function v(){}v.prototype=_.prototype;function y(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||m}var b=y.prototype=new v;b.constructor=y,h(b,_.prototype),b.isPureReactComponent=!0;var x=Array.isArray,S=Object.prototype.hasOwnProperty,C={current:null},w={key:!0,ref:!0,__self:!0,__source:!0};function T(e,n,r){var i,a={},o=null,s=null;if(n!=null)for(i in n.ref!==void 0&&(s=n.ref),n.key!==void 0&&(o=``+n.key),n)S.call(n,i)&&!w.hasOwnProperty(i)&&(a[i]=n[i]);var c=arguments.length-2;if(c===1)a.children=r;else if(1<c){for(var l=Array(c),u=0;u<c;u++)l[u]=arguments[u+2];a.children=l}if(e&&e.defaultProps)for(i in c=e.defaultProps,c)a[i]===void 0&&(a[i]=c[i]);return{$$typeof:t,type:e,key:o,ref:s,props:a,_owner:C.current}}function E(e,n){return{$$typeof:t,type:e.type,key:n,ref:e.ref,props:e.props,_owner:e._owner}}function D(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function O(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var k=/\/+/g;function A(e,t){return typeof e==`object`&&e&&e.key!=null?O(``+e.key):t.toString(36)}function j(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0}}if(c)return c=e,o=o(c),e=a===``?`.`+A(c,0):a,x(o)?(i=``,e!=null&&(i=e.replace(k,`$&/`)+`/`),j(o,r,i,``,function(e){return e})):o!=null&&(D(o)&&(o=E(o,i+(!o.key||c&&c.key===o.key?``:(``+o.key).replace(k,`$&/`)+`/`)+e)),r.push(o)),1;if(c=0,a=a===``?`.`:a+`:`,x(e))for(var l=0;l<e.length;l++){s=e[l];var u=a+A(s,l);c+=j(s,r,i,u,o)}else if(u=p(e),typeof u==`function`)for(e=u.call(e),l=0;!(s=e.next()).done;)s=s.value,u=a+A(s,l++),c+=j(s,r,i,u,o);else if(s===`object`)throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`);return c}function M(e,t,n){if(e==null)return e;var r=[],i=0;return j(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function N(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t)},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var P={current:null},F={transition:null},I={ReactCurrentDispatcher:P,ReactCurrentBatchConfig:F,ReactCurrentOwner:C};function L(){throw Error(`act(...) is not supported in production builds of React.`)}e.Children={map:M,forEach:function(e,t,n){M(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return M(e,function(){t++}),t},toArray:function(e){return M(e,function(e){return e})||[]},only:function(e){if(!D(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}},e.Component=_,e.Fragment=r,e.Profiler=a,e.PureComponent=y,e.StrictMode=i,e.Suspense=l,e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=I,e.act=L,e.cloneElement=function(e,n,r){if(e==null)throw Error(`React.cloneElement(...): The argument must be a React element, but you passed `+e+`.`);var i=h({},e.props),a=e.key,o=e.ref,s=e._owner;if(n!=null){if(n.ref!==void 0&&(o=n.ref,s=C.current),n.key!==void 0&&(a=``+n.key),e.type&&e.type.defaultProps)var c=e.type.defaultProps;for(l in n)S.call(n,l)&&!w.hasOwnProperty(l)&&(i[l]=n[l]===void 0&&c!==void 0?c[l]:n[l])}var l=arguments.length-2;if(l===1)i.children=r;else if(1<l){c=Array(l);for(var u=0;u<l;u++)c[u]=arguments[u+2];i.children=c}return{$$typeof:t,type:e.type,key:a,ref:o,props:i,_owner:s}},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:o,_context:e},e.Consumer=e},e.createElement=T,e.createFactory=function(e){var t=T.bind(null,e);return t.type=e,t},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=D,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:N}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=F.transition;F.transition={};try{e()}finally{F.transition=t}},e.unstable_act=L,e.useCallback=function(e,t){return P.current.useCallback(e,t)},e.useContext=function(e){return P.current.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e){return P.current.useDeferredValue(e)},e.useEffect=function(e,t){return P.current.useEffect(e,t)},e.useId=function(){return P.current.useId()},e.useImperativeHandle=function(e,t,n){return P.current.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return P.current.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return P.current.useLayoutEffect(e,t)},e.useMemo=function(e,t){return P.current.useMemo(e,t)},e.useReducer=function(e,t,n){return P.current.useReducer(e,t,n)},e.useRef=function(e){return P.current.useRef(e)},e.useState=function(e){return P.current.useState(e)},e.useSyncExternalStore=function(e,t,n){return P.current.useSyncExternalStore(e,t,n)},e.useTransition=function(){return P.current.useTransition()},e.version=`18.3.1`})),d=o(((e,t)=>{t.exports=u()})),f=o((e=>{var t=d(),n=Symbol.for(`react.element`),r=Object.prototype.hasOwnProperty,i=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function o(e,t,o){var s,c={},l=null,u=null;for(s in o!==void 0&&(l=``+o),t.key!==void 0&&(l=``+t.key),t.ref!==void 0&&(u=t.ref),t)r.call(t,s)&&!a.hasOwnProperty(s)&&(c[s]=t[s]);if(e&&e.defaultProps)for(s in t=e.defaultProps,t)c[s]===void 0&&(c[s]=t[s]);return{$$typeof:n,type:e,key:l,ref:u,props:c,_owner:i.current}}e.jsx=o,e.jsxs=o})),p=o(((e,t)=>{t.exports=f()}));export{c as a,l as i,d as n,o as r,p as t};
|
|
2
|
+
//# sourceMappingURL=jsx-runtime-P6ZegaOf.js.map
|