@dimina-kit/devtools 0.4.0-dev.20260728110120 → 0.4.0-dev.20260731100034

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 (105) hide show
  1. package/README.md +68 -0
  2. package/dist/main/api.d.ts +1 -0
  3. package/dist/main/app/app.d.ts +3 -0
  4. package/dist/main/app/app.js +15 -0
  5. package/dist/main/app/bootstrap.d.ts +8 -5
  6. package/dist/main/app/bootstrap.js +15 -15
  7. package/dist/main/index.bundle.js +2359 -5132
  8. package/dist/main/ipc/app-lifecycle.d.ts +1 -31
  9. package/dist/main/ipc/app-lifecycle.js +1 -53
  10. package/dist/main/ipc/bridge-router.d.ts +19 -152
  11. package/dist/main/ipc/bridge-router.js +28 -2186
  12. package/dist/main/ipc/page-scroll.d.ts +1 -13
  13. package/dist/main/ipc/page-scroll.js +1 -16
  14. package/dist/main/ipc/session-listener-bag.d.ts +1 -40
  15. package/dist/main/ipc/session-listener-bag.js +1 -39
  16. package/dist/main/services/console-forward/index.d.ts +1 -60
  17. package/dist/main/services/console-forward/index.js +1 -225
  18. package/dist/main/services/console-forward/internal-log.d.ts +1 -10
  19. package/dist/main/services/console-forward/internal-log.js +1 -22
  20. package/dist/main/services/diagnostics/index.d.ts +1 -58
  21. package/dist/main/services/diagnostics/index.js +1 -60
  22. package/dist/main/services/dimina-resource-server.d.ts +1 -6
  23. package/dist/main/services/dimina-resource-server.js +1 -98
  24. package/dist/main/services/network-forward/index.d.ts +15 -3
  25. package/dist/main/services/network-forward/index.js +30 -4
  26. package/dist/main/services/network-forward/websocket.d.ts +36 -0
  27. package/dist/main/services/network-forward/websocket.js +120 -0
  28. package/dist/main/services/service-host-pool/pool.d.ts +1 -196
  29. package/dist/main/services/service-host-pool/pool.js +1 -363
  30. package/dist/main/services/simulator/custom-apis.d.ts +1 -42
  31. package/dist/main/services/simulator/custom-apis.js +1 -46
  32. package/dist/main/services/simulator/referer.d.ts +1 -9
  33. package/dist/main/services/simulator/referer.js +1 -19
  34. package/dist/main/services/simulator/ui-extensions.d.ts +13 -0
  35. package/dist/main/services/simulator/ui-extensions.js +166 -0
  36. package/dist/main/services/simulator-storage/service-storage-ops.d.ts +1 -39
  37. package/dist/main/services/simulator-storage/service-storage-ops.js +1 -66
  38. package/dist/main/services/simulator-temp-files/disk.d.ts +1 -54
  39. package/dist/main/services/simulator-temp-files/disk.js +1 -237
  40. package/dist/main/services/simulator-temp-files/fs-channels.d.ts +1 -68
  41. package/dist/main/services/simulator-temp-files/fs-channels.js +1 -107
  42. package/dist/main/services/simulator-temp-files/index.d.ts +1 -32
  43. package/dist/main/services/simulator-temp-files/index.js +1 -181
  44. package/dist/main/services/simulator-temp-files/request-handler.d.ts +1 -29
  45. package/dist/main/services/simulator-temp-files/request-handler.js +1 -177
  46. package/dist/main/services/simulator-temp-files/resolver.d.ts +1 -21
  47. package/dist/main/services/simulator-temp-files/resolver.js +1 -21
  48. package/dist/main/services/simulator-temp-files/store.d.ts +1 -13
  49. package/dist/main/services/simulator-temp-files/store.js +1 -23
  50. package/dist/main/services/views/miniapp-partition.d.ts +1 -89
  51. package/dist/main/services/views/miniapp-partition.js +1 -158
  52. package/dist/main/services/views/native-simulator-view.js +3 -0
  53. package/dist/main/services/views/simulator-session-policy.d.ts +1 -27
  54. package/dist/main/services/views/simulator-session-policy.js +1 -98
  55. package/dist/main/services/views/view-manager.d.ts +5 -0
  56. package/dist/main/services/workbench-context.d.ts +10 -1
  57. package/dist/main/services/workbench-context.js +20 -0
  58. package/dist/main/utils/ipc-registry.d.ts +21 -3
  59. package/dist/main/utils/ipc-registry.js +26 -23
  60. package/dist/main/utils/paths.d.ts +14 -0
  61. package/dist/main/utils/paths.js +14 -0
  62. package/dist/main/windows/service-host-window/create.d.ts +1 -92
  63. package/dist/main/windows/service-host-window/create.js +1 -154
  64. package/dist/native-host/render/render.js +51 -52
  65. package/dist/native-host/service/service.js +2 -2
  66. package/dist/preload/index.d.ts +2 -0
  67. package/dist/preload/index.js +1 -0
  68. package/dist/preload/runtime/clipboard.d.ts +6 -0
  69. package/dist/preload/runtime/clipboard.js +12 -0
  70. package/dist/preload/runtime/native-host.js +4 -10
  71. package/dist/preload/windows/host-toolbar-runtime.cjs.map +2 -2
  72. package/dist/preload/windows/main.cjs +46 -126
  73. package/dist/preload/windows/main.cjs.map +3 -3
  74. package/dist/preload/windows/simulator.cjs +83 -56
  75. package/dist/preload/windows/simulator.cjs.map +4 -4
  76. package/dist/preload/windows/simulator.js +83 -56
  77. package/dist/renderer/assets/{index-BJlFbXHb.js → index-BBg3YI5b.js} +2 -2
  78. package/dist/renderer/entries/main/index.html +1 -1
  79. package/dist/shared/bridge-channels.d.ts +1 -419
  80. package/dist/shared/bridge-channels.js +1 -89
  81. package/dist/shared/dmb-resource-url.d.ts +2 -0
  82. package/dist/shared/dmb-resource-url.js +2 -0
  83. package/dist/shared/ipc-channels.d.ts +2 -32
  84. package/dist/shared/ipc-channels.js +2 -5
  85. package/dist/shared/request-core.d.ts +1 -83
  86. package/dist/shared/request-core.js +1 -167
  87. package/dist/shared/simulator-ui.d.ts +61 -0
  88. package/dist/shared/simulator-ui.js +12 -0
  89. package/dist/shared/types.d.ts +7 -0
  90. package/dist/simulator/assets/device-shell-B03OuytR.js +2 -0
  91. package/dist/simulator/assets/device-shell-DbC5ccs8.css +1 -0
  92. package/dist/simulator/assets/{jsx-runtime-BDTY6fEq.js → jsx-runtime-hBv-rHqQ.js} +2 -2
  93. package/dist/simulator/assets/{simulator-CRyLSz1N.js → simulator-DpdXUf--.js} +5 -5
  94. package/dist/simulator/simulator.html +2 -2
  95. package/dist/simulator/temp-files.d.ts +29 -0
  96. package/dist/simulator/temp-files.js +79 -0
  97. package/dist/simulator/types.d.ts +43 -0
  98. package/dist/simulator/types.js +2 -0
  99. package/package.json +10 -5
  100. package/dist/shared/simulator-api-metadata.d.ts +0 -26
  101. package/dist/shared/simulator-api-metadata.js +0 -59
  102. package/dist/shared/vpath.d.ts +0 -42
  103. package/dist/shared/vpath.js +0 -105
  104. package/dist/simulator/assets/device-shell-DOy53Y0s.css +0 -1
  105. package/dist/simulator/assets/device-shell-Sbkjw8Nb.js +0 -2
@@ -6,8 +6,8 @@
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
7
  <title>Dimina DevTools Simulator</title>
8
8
  <style>html, body { overflow: hidden; height: 100%; margin: 0; }</style>
9
- <script type="module" crossorigin src="/simulator/assets/simulator-CRyLSz1N.js"></script>
10
- <link rel="modulepreload" crossorigin href="/simulator/assets/jsx-runtime-BDTY6fEq.js">
9
+ <script type="module" crossorigin src="/simulator/assets/simulator-DpdXUf--.js"></script>
10
+ <link rel="modulepreload" crossorigin href="/simulator/assets/jsx-runtime-hBv-rHqQ.js">
11
11
  <link rel="modulepreload" crossorigin href="/simulator/assets/bridge-channels-zhsumfky.js">
12
12
  </head>
13
13
 
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Devtools simulator temp-file registry.
3
+ *
4
+ * The simulator hands `chooseImage` / `chooseMedia` / `chooseVideo` /
5
+ * `compressImage` etc. results back to mini-program code as paths. Historically
6
+ * those paths were `blob:` URLs allocated via `URL.createObjectURL`, but the
7
+ * blob: scheme is local-to-the-renderer and cannot be served back into the
8
+ * webview's `persist:simulator` session through a `protocol.handle`. We switched
9
+ * to a custom `difile://_tmp/{uuid}` scheme so the main process can
10
+ * register a single `difile://` protocol handler and stream the bytes for any
11
+ * path, regardless of which renderer originally produced it.
12
+ *
13
+ * To keep the renderer-side cache and the main-process byte store in sync,
14
+ * `setTempFileSink` lets the preload bridge inject a sink that mirrors every
15
+ * `write` / `revoke` / `revokeAll` over IPC. Tests inject a stub sink.
16
+ */
17
+ export interface TempFileSink {
18
+ write(path: string, blob: Blob): void;
19
+ revoke(path: string): void;
20
+ revokeAll(): void;
21
+ }
22
+ export declare function setTempFileSink(sink: TempFileSink | null): void;
23
+ export declare function createTempFilePath(blob: Blob): string;
24
+ export declare function registerTempFilePath(path: string, blob: Blob): void;
25
+ export declare function revokeTempFilePath(path: string): void;
26
+ export declare function revokeAllTempFilePaths(): void;
27
+ export declare function resolveTempFilePath(path: string): Promise<Blob>;
28
+ export declare function getTempFileName(path: string, blob: Blob, fallback?: string): string;
29
+ //# sourceMappingURL=temp-files.d.ts.map
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Devtools simulator temp-file registry.
3
+ *
4
+ * The simulator hands `chooseImage` / `chooseMedia` / `chooseVideo` /
5
+ * `compressImage` etc. results back to mini-program code as paths. Historically
6
+ * those paths were `blob:` URLs allocated via `URL.createObjectURL`, but the
7
+ * blob: scheme is local-to-the-renderer and cannot be served back into the
8
+ * webview's `persist:simulator` session through a `protocol.handle`. We switched
9
+ * to a custom `difile://_tmp/{uuid}` scheme so the main process can
10
+ * register a single `difile://` protocol handler and stream the bytes for any
11
+ * path, regardless of which renderer originally produced it.
12
+ *
13
+ * To keep the renderer-side cache and the main-process byte store in sync,
14
+ * `setTempFileSink` lets the preload bridge inject a sink that mirrors every
15
+ * `write` / `revoke` / `revokeAll` over IPC. Tests inject a stub sink.
16
+ */
17
+ const tempFiles = new Map();
18
+ let activeSink = null;
19
+ export function setTempFileSink(sink) {
20
+ activeSink = sink;
21
+ }
22
+ function cryptoRandomId() {
23
+ const c = globalThis.crypto;
24
+ if (c && typeof c.randomUUID === 'function')
25
+ return c.randomUUID();
26
+ return `${Date.now()}-${Math.random().toString(36).slice(2)}`;
27
+ }
28
+ export function createTempFilePath(blob) {
29
+ const path = `difile://_tmp/${cryptoRandomId()}`;
30
+ tempFiles.set(path, blob);
31
+ activeSink?.write(path, blob);
32
+ return path;
33
+ }
34
+ export function registerTempFilePath(path, blob) {
35
+ tempFiles.set(path, blob);
36
+ activeSink?.write(path, blob);
37
+ }
38
+ export function revokeTempFilePath(path) {
39
+ tempFiles.delete(path);
40
+ activeSink?.revoke(path);
41
+ }
42
+ export function revokeAllTempFilePaths() {
43
+ tempFiles.clear();
44
+ activeSink?.revokeAll();
45
+ }
46
+ export async function resolveTempFilePath(path) {
47
+ const cached = tempFiles.get(path);
48
+ if (cached)
49
+ return cached;
50
+ const response = await fetch(path);
51
+ if (!response.ok) {
52
+ throw new Error(`无法读取文件 ${path}`);
53
+ }
54
+ const blob = await response.blob();
55
+ // Cache the freshly fetched blob in-memory so subsequent reads are local.
56
+ // We bypass `registerTempFilePath` deliberately: this is a renderer-only
57
+ // cache fill, the main-process store already has the bytes (otherwise the
58
+ // fetch would not have returned them), so triggering sink.write would
59
+ // produce a redundant IPC.
60
+ tempFiles.set(path, blob);
61
+ return blob;
62
+ }
63
+ export function getTempFileName(path, blob, fallback = 'file') {
64
+ const named = blob;
65
+ if (typeof named.name === 'string' && named.name.trim()) {
66
+ return named.name;
67
+ }
68
+ try {
69
+ const url = new URL(path, window.location.href);
70
+ const segment = url.pathname.split('/').filter(Boolean).pop();
71
+ if (segment)
72
+ return decodeURIComponent(segment);
73
+ }
74
+ catch {
75
+ // Fall through to the caller-provided fallback.
76
+ }
77
+ return fallback;
78
+ }
79
+ //# sourceMappingURL=temp-files.js.map
@@ -0,0 +1,43 @@
1
+ /** Callback type used by API functions */
2
+ export type Callback = (...args: unknown[]) => void;
3
+ /**
4
+ * Metric fallbacks derived from the CURRENTLY emulated device. Provided by
5
+ * SimulatorMiniApp.getDeviceMetrics() so the simulator-resident wx.* handlers
6
+ * (readWindowMetrics in simulator-api.ts) report the selected device instead
7
+ * of a hardcoded rect when neither `window.__deviceInfo` nor a host DOM rect
8
+ * is available.
9
+ */
10
+ export interface DeviceMetrics {
11
+ pixelRatio: number;
12
+ screenWidth: number;
13
+ screenHeight: number;
14
+ statusBarHeight: number;
15
+ /** Per-edge safe-area insets (portrait). Single source of truth for the
16
+ * bottom inset — there is no separate `safeAreaBottom` field. */
17
+ safeAreaInsets: {
18
+ top: number;
19
+ right: number;
20
+ bottom: number;
21
+ left: number;
22
+ };
23
+ }
24
+ /**
25
+ * Context (`this`) available to each registered miniapp API handler.
26
+ * Bound by AppManager.registerApi → MiniApp.invokeApi.
27
+ */
28
+ export interface MiniAppContext {
29
+ createCallbackFunction(fn: unknown): Callback | undefined;
30
+ appId: string;
31
+ parent?: {
32
+ el?: Element;
33
+ getStatusBarRect?: () => {
34
+ height: number;
35
+ };
36
+ };
37
+ /**
38
+ * Current device metric fallbacks (SimulatorMiniApp implements this; legacy
39
+ * or mock contexts without it keep the pre-device fallback behavior).
40
+ */
41
+ getDeviceMetrics?(): DeviceMetrics;
42
+ }
43
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dimina-kit/devtools",
3
- "version": "0.4.0-dev.20260728110120",
3
+ "version": "0.4.0-dev.20260731100034",
4
4
  "description": "Dimina DevTools - modular developer tools for mini app debugging",
5
5
  "keywords": [
6
6
  "dimina",
@@ -37,6 +37,7 @@
37
37
  ".": "./dist/main/api.js",
38
38
  "./launch": "./dist/main/app/launch.js",
39
39
  "./types": "./dist/shared/types.js",
40
+ "./simulator-ui": "./dist/shared/simulator-ui.js",
40
41
  "./context": "./dist/main/services/workbench-context.js",
41
42
  "./projects-provider": "./dist/main/services/projects/index.js",
42
43
  "./create-window": "./dist/main/windows/main-window/index.js",
@@ -53,6 +54,9 @@
53
54
  "types": [
54
55
  "dist/shared/types.d.ts"
55
56
  ],
57
+ "simulator-ui": [
58
+ "dist/shared/simulator-ui.d.ts"
59
+ ],
56
60
  "context": [
57
61
  "dist/main/services/workbench-context.d.ts"
58
62
  ],
@@ -85,10 +89,11 @@
85
89
  "chrome-remote-interface": "^0.34.0",
86
90
  "ws": "^8.20.0",
87
91
  "zod": "^4.3.6",
88
- "@dimina-kit/devkit": "0.1.2-dev.20260728110120",
89
- "@dimina-kit/electron-deck": "0.1.0-dev.20260728110120",
90
- "@dimina-kit/view-anchor": "0.1.0-dev.20260728110120",
91
- "@dimina-kit/inspect": "0.4.0-dev.20260728110120"
92
+ "@dimina-kit/devkit": "0.1.2-dev.20260731100034",
93
+ "@dimina-kit/electron-deck": "0.1.0-dev.20260731100034",
94
+ "@dimina-kit/electron-runtime": "0.1.0-dev.20260731100034",
95
+ "@dimina-kit/view-anchor": "0.1.0-dev.20260731100034",
96
+ "@dimina-kit/inspect": "0.4.0-dev.20260731100034"
92
97
  },
93
98
  "devDependencies": {
94
99
  "@playwright/test": "^1.59.1",
@@ -1,26 +0,0 @@
1
- export declare const PERSISTENT_SIMULATOR_APIS: ReadonlySet<string>;
2
- export declare function isPersistentSimulatorApi(name: string): boolean;
3
- /**
4
- * APIs whose one-shot call legitimately runs as long as the caller's wx
5
- * network timeout budget (`params.timeout`, default 60000ms) — the simulator
6
- * handler answers when the network answers, not within a fixed router window.
7
- */
8
- export declare const NETWORK_BUDGET_SIMULATOR_APIS: ReadonlySet<string>;
9
- /**
10
- * Flat watchdog window for forwarded one-shot calls whose handler is expected
11
- * to answer promptly; it guards against a missing handler / dead seam.
12
- */
13
- export declare const API_CALL_WATCHDOG_MS = 5000;
14
- /**
15
- * How long bridge-router's one-shot "no handler" watchdog waits before
16
- * tearing a forwarded simulator-API call down.
17
- *
18
- * Network-budget APIs get their wx timeout budget plus the flat window as
19
- * forwarding grace: the handler owns the real deadline (performRequest emits
20
- * `request:fail timeout` at the budget), so the watchdog only has to catch
21
- * the case where no verdict ever comes back. A flat 5s window here would
22
- * kill any HTTP call slower than 5s and drop its late — perfectly valid —
23
- * response. Every other API keeps the flat window.
24
- */
25
- export declare function apiCallWatchdogMs(name: string, params: Record<string, unknown> | undefined): number;
26
- //# sourceMappingURL=simulator-api-metadata.d.ts.map
@@ -1,59 +0,0 @@
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
- import { MAX_TIMEOUT_MS, resolveTimeoutBudgetMs } from './request-core.js';
20
- export const PERSISTENT_SIMULATOR_APIS = new Set(['audioListen']);
21
- export function isPersistentSimulatorApi(name) {
22
- return PERSISTENT_SIMULATOR_APIS.has(name);
23
- }
24
- /**
25
- * APIs whose one-shot call legitimately runs as long as the caller's wx
26
- * network timeout budget (`params.timeout`, default 60000ms) — the simulator
27
- * handler answers when the network answers, not within a fixed router window.
28
- */
29
- export const NETWORK_BUDGET_SIMULATOR_APIS = new Set([
30
- 'request',
31
- 'downloadFile',
32
- 'uploadFile',
33
- ]);
34
- /**
35
- * Flat watchdog window for forwarded one-shot calls whose handler is expected
36
- * to answer promptly; it guards against a missing handler / dead seam.
37
- */
38
- export const API_CALL_WATCHDOG_MS = 5_000;
39
- /**
40
- * How long bridge-router's one-shot "no handler" watchdog waits before
41
- * tearing a forwarded simulator-API call down.
42
- *
43
- * Network-budget APIs get their wx timeout budget plus the flat window as
44
- * forwarding grace: the handler owns the real deadline (performRequest emits
45
- * `request:fail timeout` at the budget), so the watchdog only has to catch
46
- * the case where no verdict ever comes back. A flat 5s window here would
47
- * kill any HTTP call slower than 5s and drop its late — perfectly valid —
48
- * response. Every other API keeps the flat window.
49
- */
50
- export function apiCallWatchdogMs(name, params) {
51
- if (!NETWORK_BUDGET_SIMULATOR_APIS.has(name))
52
- return API_CALL_WATCHDOG_MS;
53
- // resolveTimeoutBudgetMs rejects non-finite/oversized caller timeouts, and
54
- // the final clamp keeps budget+grace inside setTimeout's range — an
55
- // overflowing delay would wrap to ~1ms and fire the watchdog immediately.
56
- const budget = resolveTimeoutBudgetMs(params?.timeout);
57
- return Math.min(budget + API_CALL_WATCHDOG_MS, MAX_TIMEOUT_MS);
58
- }
59
- //# sourceMappingURL=simulator-api-metadata.js.map
@@ -1,42 +0,0 @@
1
- /**
2
- * vpath resolver.
3
- *
4
- * Spec: `docs/file-system.md` — single resolver shared by every FSM
5
- * entry, the renderer-side temp store, and 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
@@ -1,105 +0,0 @@
1
- /**
2
- * vpath resolver.
3
- *
4
- * Spec: `docs/file-system.md` — single resolver shared by every FSM
5
- * entry, the renderer-side temp store, and 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
@@ -1 +0,0 @@
1
- .menu-capsule{box-sizing:border-box;color:#1f1f1f;pointer-events:none;background:#fff;border:.5px solid #e5e5e5;border-radius:16px;align-items:center;display:flex;position:absolute;overflow:hidden;box-shadow:0 1px 2px #00000014}.menu-capsule__more,.menu-capsule__close{flex:1;justify-content:center;align-items:center;display:flex}.menu-capsule__more{pointer-events:auto;cursor:pointer;gap:1px}.menu-capsule__dot{background:currentColor;border-radius:50%}.menu-capsule__dot--side{width:4px;height:4px}.menu-capsule__dot--mid{width:6.4px;height:6.4px}.menu-capsule__divider{background:#e9e9e9;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{box-sizing:content-box;z-index:9;border-top:1px solid #e0e0e0;flex-shrink:0;justify-content:space-around;align-items:stretch;width:100%;height:50px;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)}.dmui-publish{z-index:300;pointer-events:auto;background:#fff;flex-direction:column;display:flex;position:absolute;inset:0}.dmui-publish__nav{border-bottom:.5px solid #f2f2f2;flex-shrink:0;align-items:center;height:44px;padding:0 12px;display:flex}.dmui-publish__back{cursor:pointer;color:#333;background:0 0;border:0;flex-shrink:0;justify-content:center;align-items:center;width:32px;height:32px;padding:0;display:flex}.dmui-publish__island-chip{flex:1;justify-content:center;align-items:center;gap:4px;min-width:0;display:flex}.dmui-publish__chip-avatar{-o-object-fit:cover;object-fit:cover;border-radius:4px;flex-shrink:0;width:16px;height:16px}.dmui-publish__chip-avatar--placeholder{background:#e5e7eb}.dmui-publish__chip-name{color:#333;text-overflow:ellipsis;white-space:nowrap;max-width:100px;font:500 14px/1 system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif;overflow:hidden}.dmui-publish__chip-tag{color:#999;border:.5px solid #ddd;border-radius:2px;flex-shrink:0;padding:1px 4px;font:400 10px/1 system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}.dmui-publish__submit{color:#fff;cursor:pointer;background:#222;border:0;border-radius:14px;flex-shrink:0;height:28px;padding:0 16px;font:500 13px/28px system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}.dmui-publish__submit--disabled{cursor:default;background:#ccc}.dmui-publish__body{flex:1;padding:16px;overflow-y:auto}.dmui-publish__images{gap:8px;margin-bottom:16px;display:flex;overflow-x:auto}.dmui-publish__image-add{cursor:pointer;background:#fafafa;border:1px dashed #ddd;border-radius:8px;flex-shrink:0;justify-content:center;align-items:center;width:72px;height:72px;display:flex}.dmui-publish__title{color:#333;box-sizing:border-box;border:0;border-bottom:.5px solid #f2f2f2;outline:none;width:100%;padding:12px 0;font:500 16px/1.4 system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif;display:block}.dmui-publish__title::placeholder{color:#ccc;font-weight:400}.dmui-publish__content{color:#333;resize:none;box-sizing:border-box;border:0;outline:none;width:100%;min-height:180px;padding:12px 0;font:400 15px/1.6 system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif;display:block}.dmui-publish__content::placeholder{color:#ccc}.dmui-publish__toolbar{border-top:.5px solid #f2f2f2;flex-shrink:0;justify-content:space-between;align-items:center;padding:8px 16px;display:flex}.dmui-publish__count{color:#999;font:400 12px/1 system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}.dmui-publish__privacy{color:#666;cursor:pointer;background:0 0;border:0;padding:4px 8px;font:400 12px/1 system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}.dmui-overlay{z-index:300;pointer-events:none;justify-content:center;align-items:center;display:flex;position:absolute;inset:0}.dmui-mask{pointer-events:auto;background:#00000080;position:absolute;inset:0}.dmui-mask--transparent{background:0 0}.dmui-toast{color:#fff;pointer-events:none;box-sizing:border-box;background:#000000bf;border-radius:10px;flex-direction:column;justify-content:center;align-items:center;gap:12px;min-width:120px;max-width:70%;padding:20px;display:flex;position:relative}.dmui-toast--text{border-radius:8px;min-width:0;padding:12px 18px}.dmui-toast__title{text-align:center;word-break:break-word;font:400 14px/1.4 system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}.dmui-toast__icon{fill:none;stroke:#fff;stroke-width:2.4px;stroke-linecap:round;stroke-linejoin:round;width:40px;height:40px}.dmui-toast__image{-o-object-fit:contain;object-fit:contain;width:40px;height:40px}.dmui-toast__spinner{border:3px solid #ffffff4d;border-top-color:#fff;border-radius:50%;width:36px;height:36px;animation:.8s linear infinite dmui-spin}@keyframes dmui-spin{to{transform:rotate(360deg)}}.dmui-modal{pointer-events:auto;box-sizing:border-box;background:#fff;border-radius:12px;width:280px;max-width:80%;padding-top:24px;position:relative;overflow:hidden}.dmui-modal__title{color:#111827;text-align:center;padding:0 24px;font:600 17px/1.4 system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}.dmui-modal__content{color:#6b7280;text-align:center;max-height:200px;padding:8px 24px 20px;font:400 15px/1.5 system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif;overflow-y:auto}.dmui-modal__input{box-sizing:border-box;border:1px solid #e5e7eb;border-radius:4px;width:calc(100% - 48px);margin:16px 24px 20px;padding:6px 8px;font-size:15px;display:block}.dmui-modal__actions{border-top:1px solid #e5e7eb;display:flex}.dmui-modal__button{cursor:pointer;background:0 0;border:0;flex:1;padding:14px 0;font:400 17px/1 system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}.dmui-modal__button+.dmui-modal__button{border-left:1px solid #e5e7eb}.dmui-overlay:has(.dmui-action-sheet){align-items:flex-end}.dmui-action-sheet{pointer-events:auto;box-sizing:border-box;width:100%;padding:8px;position:relative}.dmui-action-sheet__items{background:#fff;border-radius:12px;overflow:hidden}.dmui-action-sheet__item{text-align:center;cursor:pointer;background:0 0;border:0;width:100%;padding:16px 0;font:400 17px/1 system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif;display:block}.dmui-action-sheet__item+.dmui-action-sheet__item{border-top:1px solid #ececec}.dmui-action-sheet__cancel{color:#111827;cursor:pointer;background:#fff;border:0;border-radius:12px;width:100%;margin-top:8px;padding:16px 0;font:600 17px/1 system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif;display:block}.dmui-overlay:has(.dmui-half-sheet){align-items:flex-end}.dmui-half-sheet{pointer-events:auto;background:#fff;border-radius:12px 12px 0 0;flex-direction:column;width:100%;animation:.3s ease-out dmui-slide-up;display:flex;position:relative}@keyframes dmui-slide-up{0%{transform:translateY(100%)}to{transform:translateY(0)}}.dmui-half-sheet__title{color:#202020;text-align:center;padding:20px 20px 16px;font:400 16px/1.4 system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}.dmui-half-sheet__divider{background:#f2f2f2;height:.5px}.dmui-half-sheet__row{align-items:center;padding:16px 20px;display:flex}.dmui-half-sheet__avatar{-o-object-fit:cover;object-fit:cover;border-radius:8px;flex-shrink:0;width:44px;height:44px}.dmui-half-sheet__info{flex:1;min-width:0;margin-left:12px}.dmui-half-sheet__name{color:#202020;text-overflow:ellipsis;white-space:nowrap;font:500 16px/1.4 system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif;overflow:hidden}.dmui-half-sheet__members{color:#999;margin-top:4px;font:400 12px/1.4 system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}.dmui-half-sheet__join{color:#fff;cursor:pointer;background:#222;border:0;border-radius:18px;flex-shrink:0;height:36px;padding:0 20px;font:400 14px/36px system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}.dmui-half-sheet__cancel{color:#999;text-align:center;cursor:pointer;background:0 0;border:0;padding:16px 0;font:400 16px/1 system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}.dmui-overlay:has(.dmui-bottom-sheet){align-items:flex-end}.dmui-bottom-sheet{pointer-events:auto;background:#fff;border-radius:16px 16px 0 0;flex-direction:column;width:100%;animation:.3s ease-out dmui-slide-up;display:flex;position:relative}.dmui-bottom-sheet__title{color:#202020;text-align:center;padding:20px 20px 16px;font:400 16px/1.4 system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}.dmui-bottom-sheet__divider{background:#f2f2f2;height:.5px}.dmui-bottom-sheet__grid{flex-wrap:wrap;gap:16px;padding:16px 20px;display:flex}.dmui-bottom-sheet__grid-item{cursor:pointer;background:0 0;border:0;flex-direction:column;align-items:center;gap:8px;min-width:56px;padding:0;display:flex}.dmui-bottom-sheet__icon-circle{background:#f5f5f5;border-radius:50%;justify-content:center;align-items:center;width:50px;height:50px;font-size:22px;display:flex}.dmui-bottom-sheet__icon-img{width:32px;height:32px}.dmui-bottom-sheet__item-label{color:#333;font:400 12px/1.4 system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}.dmui-bottom-sheet__cancel{color:#999;text-align:center;cursor:pointer;background:0 0;border:0;padding:16px 0;font:400 16px/1 system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}.dmui-capsule-menu__header{align-items:center;padding:20px 20px 16px;display:flex}.dmui-capsule-menu__avatar{-o-object-fit:cover;object-fit:cover;border-radius:10px;flex-shrink:0;width:48px;height:48px}.dmui-capsule-menu__avatar--placeholder{background:#e5e7eb}.dmui-capsule-menu__app-info{flex:1;min-width:0;margin-left:12px}.dmui-capsule-menu__app-name{color:#202020;text-overflow:ellipsis;white-space:nowrap;font:500 16px/1.4 system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif;overflow:hidden}.dmui-capsule-menu__app-version{color:#999;margin-top:4px;font:400 12px/1.4 system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}.device-shell-root{color:#101418;box-sizing:border-box;background:#121212;width:100%;height:100vh;padding:24px;display:flex;overflow:auto}@media (prefers-color-scheme:light){.device-shell-root{background:#e8e8e8}}.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{pointer-events:none;z-index:200;position:absolute;bottom:0;left:0;right:0}.device-shell__home-indicator:before{content:"";background:#111827;border-radius:999px;width:118px;height:4px;position:absolute;bottom:8px;left:50%;transform:translate(-50%)}
@@ -1,2 +0,0 @@
1
- import{i as e,n as t,t as n}from"./jsx-runtime-BDTY6fEq.js";import{t as r}from"./bridge-channels-zhsumfky.js";var i=e(),a=new Set([`audioListen`]);function o(e){return a.has(e)}function s(e,t,n,r){let i=e.apiRegistry[t];if(!i)return r({ok:!1,errMsg:`${t}:fail no handler`}),Promise.resolve();let a=o(t)||(n&&typeof n==`object`&&!Array.isArray(n)?n.keep===!0:!1);return new Promise(o=>{let s=!1,c=e=>{if(s){a&&e.ok&&r({...e,keep:!0});return}s=!0,r(a&&e.ok?{...e,keep:!0}:e),o()},l=Symbol(`sim-cb-success`),u=Symbol(`sim-cb-fail`),d=Symbol(`sim-cb-complete`),f=!1,p=Object.create(e);p.createCallbackFunction=e=>{if(e!=null)return(e===l||e===u)&&(f=!0),(...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}):e===d&&!a&&c({ok:!0,result:r})}};let m=n&&typeof n==`object`&&!Array.isArray(n)?{...n}:{};m.success=l,m.fail=u,m.complete=d;try{let e=i.call(p,m);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}if(s)return;if(a){o();return}if(f){o();return}c({ok:!0,result:e})}catch(e){c({ok:!1,errMsg:`${t}:fail ${e instanceof Error?e.message:String(e)}`})}})}var c={ios:44,android:64};function l(e){return(c[e]-32)/2}var u=n();function d({platform:e,statusBarHeight:t,onMoreClick:n}){return(0,u.jsxs)(`div`,{className:`menu-capsule`,style:{width:87,height:32,top:t+l(e),right:10},"aria-hidden":`true`,children:[(0,u.jsxs)(`div`,{className:`menu-capsule__more`,onClick:n,children:[(0,u.jsx)(`span`,{className:`menu-capsule__dot menu-capsule__dot--side`}),(0,u.jsx)(`span`,{className:`menu-capsule__dot menu-capsule__dot--mid`}),(0,u.jsx)(`span`,{className:`menu-capsule__dot menu-capsule__dot--side`})]}),(0,u.jsx)(`div`,{className:`menu-capsule__divider`}),(0,u.jsx)(`div`,{className:`menu-capsule__close`,children:(0,u.jsxs)(`svg`,{viewBox:`0 0 22 22`,width:`22`,height:`22`,"aria-hidden":`true`,children:[(0,u.jsx)(`circle`,{cx:`11`,cy:`11`,r:`7.8`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.4`}),(0,u.jsx)(`circle`,{cx:`11`,cy:`11`,r:`3.1`,fill:`currentColor`})]})})]})}var f={linear:`linear`,easeIn:`ease-in`,easeOut:`ease-out`,easeInOut:`ease-in-out`},p={ios:`M17.51 3.87L15.73 2.1 5.84 12l9.9 9.9 1.77-1.77L9.38 12l8.13-8.13z`,android:`M15.41 16.59L10.83 12l4.58-4.59L14 6l-6 6 6 6 1.41-1.41z`};function m({state:e,stackDepth:t,platform:n,statusBarHeight:r,navBarHeight:a,onBack:o,onHome:s,onMoreClick:c}){let l=(0,i.useMemo)(()=>{if(!e.colorAnimation||e.colorAnimation.durationMs<=0)return;let t=f[e.colorAnimation.timingFunc]??`linear`;return`background-color ${e.colorAnimation.durationMs}ms ${t}, color ${e.colorAnimation.durationMs}ms ${t}`},[e.colorAnimation]),m=e.style===`custom`,h=t>1,g=!h&&e.homeButtonVisible,_=n===`ios`?`center`:`left`,v=n===`android`?30:24,y={backgroundColor:e.backgroundColor,color:e.textStyle===`white`?`#ffffff`:`#000000`,height:r+a,paddingTop:r,transition:l};return(0,u.jsxs)(`header`,{className:`nav-bar nav-bar--${n} nav-bar--${e.textStyle}${m?` nav-bar--custom`:``}`,style:y,"aria-hidden":m,children:[!m&&(0,u.jsxs)(`div`,{className:`nav-bar__row`,style:{height:a,justifyContent:_===`center`?`center`:`flex-start`},children:[(h||g)&&(0,u.jsxs)(`div`,{className:`nav-bar__leading`,children:[h&&(0,u.jsx)(`button`,{type:`button`,className:`nav-bar__back`,"aria-label":`Back`,onClick:o,children:(0,u.jsx)(`svg`,{viewBox:`0 0 24 24`,width:v,height:v,"aria-hidden":`true`,children:(0,u.jsx)(`path`,{d:p[n],fill:`currentColor`})})}),g&&(0,u.jsx)(`button`,{type:`button`,className:`nav-bar__home`,"aria-label":`Home`,onClick:s,children:(0,u.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`22`,height:`22`,"aria-hidden":`true`,children:(0,u.jsx)(`path`,{d:`M3 12l9-9 9 9M5 10v10h14V10`,stroke:`currentColor`,strokeWidth:`2`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`})})})]}),(0,u.jsxs)(`div`,{className:`nav-bar__title nav-bar__title--${_}`,style:{color:e.textStyle===`white`?`#ffffff`:`#000000`},children:[e.loading&&(0,u.jsx)(`span`,{className:`nav-bar__spinner`,"aria-hidden":`true`}),(0,u.jsx)(`span`,{className:`nav-bar__title-text`,children:e.title})]})]}),(0,u.jsx)(d,{platform:n,statusBarHeight:r,onMoreClick:c})]})}function h(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 g(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 _({height:e,notchType:t,textStyle:n}){let r=g(t);return(0,u.jsxs)(`div`,{className:`device-statusbar`,style:{height:e,color:n===`black`?`#000000`:`#ffffff`},"aria-hidden":`true`,children:[(0,u.jsx)(`span`,{className:`device-statusbar__time`,children:`9:41`}),r&&(0,u.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,u.jsxs)(`div`,{className:`device-statusbar__icons`,children:[(0,u.jsx)(`span`,{className:`device-statusbar__signal`}),(0,u.jsx)(`span`,{className:`device-statusbar__wifi`}),(0,u.jsx)(`span`,{className:`device-statusbar__battery`})]})]})}function v({state:e,currentPath:t,resourceBaseUrl:n,appId:r,onSwitch:i,bottomInset:a=0}){if(!e.config||!e.visible)return null;let{color:o,selectedColor:s,backgroundColor:c,borderStyle:l,list:d}=e.config,f=o||`#999999`,p=s||`#1890ff`;return(0,u.jsx)(`div`,{className:`dmb-tab-bar`,style:{backgroundColor:c||`#ffffff`,borderTopColor:l===`white`?`#ffffff`:`#e0e0e0`,paddingBottom:a},role:`tablist`,"aria-label":`TabBar`,children:d.map((a,o)=>{let s=y(a.pagePath),c=s===t,l=b(c?a.selectedIconPath??a.iconPath:a.iconPath,n,r),d=e.badges[o]??``,m=e.redDots[o]??!1;return(0,u.jsxs)(`button`,{type:`button`,className:`dmb-tab-bar__item${c?` is-selected`:``}`,role:`tab`,"aria-selected":c,onClick:()=>i(s),children:[l&&(0,u.jsx)(`span`,{className:`dmb-tab-bar__icon-slot`,children:(0,u.jsx)(`img`,{className:`dmb-tab-bar__icon`,src:l,alt:``,onError:e=>{e.currentTarget.style.display=`none`}})}),(0,u.jsx)(`span`,{className:`dmb-tab-bar__text`,style:{color:c?p:f},children:a.text||``}),d&&(0,u.jsx)(`span`,{className:`dmb-tab-bar__badge`,children:d}),!d&&m&&(0,u.jsx)(`span`,{className:`dmb-tab-bar__red-dot`})]},`${s}-${o}`)})})}function y(e){return e?e.replace(/^\/+/,``):``}function b(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}/`)?x(t,i):x(t,`${n}/main/${i}`)}function x(e,t){return`${e.endsWith(`/`)?e:`${e}/`}${t.replace(/^\/+/,``)}`}var S=`data:image/svg+xml,%3csvg%20width='32'%20height='32'%20viewBox='0%200%2032%2032'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M23.1221%2013.3855C23.1221%2018.5302%2018.2862%2022.7007%2012.321%2022.7007C10.9486%2022.7007%209.63581%2022.48%208.42807%2022.0774C7.60996%2022.48%204.89408%2023.8264%204.89408%2023.8264C4.89408%2023.8264%205.25692%2022.0774%205.51715%2020.6206C3.07834%2018.9126%201.52002%2016.306%201.52002%2013.3855C1.52002%208.241%206.35572%204.07031%2012.321%204.07031C18.2862%204.07031%2023.1221%208.241%2023.1221%2013.3855Z'%20fill='url(%23paint0_radial_87227_8743)'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M12.2446%2019.4912C12.2446%2023.6844%2016.326%2027.0838%2021.3605%2027.0838C22.5189%2027.0838%2023.6267%2026.9038%2024.646%2026.5756C25.4567%2026.9038%2027.6286%2028.0012%2027.6286%2028.0012C27.6286%2028.0012%2027.3134%2026.3862%2027.103%2025.3882C29.1612%2023.9961%2030.4764%2021.8715%2030.4764%2019.4912C30.4764%2015.2977%2026.3951%2011.8984%2021.3605%2011.8984C16.326%2011.8984%2012.2446%2015.2977%2012.2446%2019.4912Z'%20fill='url(%23paint1_radial_87227_8743)'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M8.45121%208.49023C9.2684%208.49023%209.93086%209.14537%209.93086%209.95365C9.93086%2010.7618%209.2684%2011.4171%208.45121%2011.4171C7.63403%2011.4171%206.97168%2010.7618%206.97168%209.95365C6.97168%209.14537%207.63403%208.49023%208.45121%208.49023Z'%20fill='url(%23paint2_linear_87227_8743)'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M16.2077%208.49023C17.0247%208.49023%2017.6872%209.14537%2017.6872%209.95365C17.6872%2010.7618%2017.0247%2011.4171%2016.2077%2011.4171C15.3905%2011.4171%2014.728%2010.7618%2014.728%209.95365C14.728%209.14537%2015.3905%208.49023%2016.2077%208.49023Z'%20fill='url(%23paint3_linear_87227_8743)'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M19.402%2016.9363C19.402%2017.6636%2018.8059%2018.2533%2018.0704%2018.2533C17.3349%2018.2533%2016.7388%2017.6636%2016.7388%2016.9363C16.7388%2016.2089%2017.3349%2015.6191%2018.0704%2015.6191C18.8059%2015.6191%2019.402%2016.2089%2019.402%2016.9363Z'%20fill='url(%23paint4_linear_87227_8743)'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M24.6296%2015.6191C25.3649%2015.6191%2025.9611%2016.2089%2025.9611%2016.9363C25.9611%2017.6636%2025.3649%2018.2533%2024.6296%2018.2533C23.8942%2018.2533%2023.2979%2017.6636%2023.2979%2016.9363C23.2979%2016.2089%2023.8942%2015.6191%2024.6296%2015.6191Z'%20fill='url(%23paint5_linear_87227_8743)'/%3e%3cdefs%3e%3cradialGradient%20id='paint0_radial_87227_8743'%20cx='0'%20cy='0'%20r='1'%20gradientUnits='userSpaceOnUse'%20gradientTransform='translate(12.321%204.07031)%20rotate(90)%20scale(25.1081%2027.4541)'%3e%3cstop%20stop-color='%2395FF00'/%3e%3cstop%20offset='1'%20stop-color='%2369CC15'/%3e%3c/radialGradient%3e%3cradialGradient%20id='paint1_radial_87227_8743'%20cx='0'%20cy='0'%20r='1'%20gradientUnits='userSpaceOnUse'%20gradientTransform='translate(21.3441%2011.8984)%20rotate(90)%20scale(15.2975%2017.2945)'%3e%3cstop%20stop-color='white'/%3e%3cstop%20offset='1'%20stop-color='%23DFEAEB'/%3e%3c/radialGradient%3e%3clinearGradient%20id='paint2_linear_87227_8743'%20x1='6.97168'%20y1='8.49023'%20x2='6.97168'%20y2='11.4171'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%231F9E47'/%3e%3cstop%20offset='1'%20stop-color='%230C7B2F'/%3e%3c/linearGradient%3e%3clinearGradient%20id='paint3_linear_87227_8743'%20x1='14.728'%20y1='8.49023'%20x2='14.728'%20y2='11.4171'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%231F9E47'/%3e%3cstop%20offset='1'%20stop-color='%230C7B2F'/%3e%3c/linearGradient%3e%3clinearGradient%20id='paint4_linear_87227_8743'%20x1='16.7388'%20y1='15.6191'%20x2='16.7388'%20y2='18.2533'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%235C7564'/%3e%3cstop%20offset='1'%20stop-color='%23495E4F'/%3e%3c/linearGradient%3e%3clinearGradient%20id='paint5_linear_87227_8743'%20x1='23.2979'%20y1='15.6191'%20x2='23.2979'%20y2='18.2533'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%23607B68'/%3e%3cstop%20offset='1'%20stop-color='%23495E4F'/%3e%3c/linearGradient%3e%3c/defs%3e%3c/svg%3e`,C=`data:image/svg+xml,%3csvg%20width='32'%20height='32'%20viewBox='0%200%2032%2032'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M16%203C23.1797%203%2029%208.82027%2029%2016C29%2023.1796%2023.1797%2029%2016%2029C8.82027%2029%203%2023.1796%203%2016C3%208.82027%208.82027%203%2016%203ZM16.1243%2011.9418C18.3423%2011.9418%2020.1402%2013.7398%2020.1402%2015.9578C20.1402%2018.1756%2018.3423%2019.9737%2016.1243%2019.9737C13.9064%2019.9737%2012.1084%2018.1756%2012.1084%2015.9578C12.1084%2013.7398%2013.9064%2011.9418%2016.1243%2011.9418Z'%20fill='white'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M27.2082%2011.9995L19%2019.9898L27.3144%2019.9995C27.3144%2019.9995%2028.9256%2016.3089%2027.2082%2011.9995Z'%20fill='%235E9FF1'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M27%2020.9995H15L21.0382%2026.9995C21.0382%2026.9995%2025.0194%2025.4292%2027%2020.9995Z'%20fill='%2367E4EE'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M20%2027.1955L12.0097%2018.9995L12%2027.349C12%2027.349%2015.6906%2028.9102%2020%2027.1955Z'%20fill='%236DEE63'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M11%2026.9995V14.9995L5%2021.1662C5%2021.1662%206.63005%2025.0188%2011%2026.9995Z'%20fill='%23BEEE65'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M4.81275%2019.9995L13%2012.0092L4.62657%2011.9995C4.62657%2011.9995%203.09985%2015.6901%204.81275%2019.9995Z'%20fill='%23F0DC63'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M5%2010.9995H17L10.7953%204.99951C10.7953%204.99951%206.98064%206.62957%205%2010.9995Z'%20fill='%23EDB262'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M12%204.80358L19.9903%2012.9995L20%204.65008C20%204.65008%2016.3094%203.08878%2012%204.80358Z'%20fill='%23F1775B'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M21%204.99951V16.9995L27%2010.9995C27%2010.9995%2025.4298%206.9801%2021%204.99951Z'%20fill='%236961EC'/%3e%3c/svg%3e`,w=`data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M21.3485%202.17401C19.7864%200.611917%2017.2537%200.611917%2015.6916%202.17401L11.2336%206.63201L12.6478%208.04622L17.1058%203.58823C17.8869%202.80718%2019.1532%202.80718%2019.9343%203.58823L20.412%204.06598C21.1931%204.84703%2021.1931%206.11336%2020.412%206.89441L14.4202%2012.8863C13.6391%2013.6673%2012.3728%2013.6673%2011.5917%2012.8863L10.7628%2012.0573L9.3486%2013.4715L10.1775%2014.3005C11.7396%2015.8626%2014.2723%2015.8626%2015.8344%2014.3005L21.8262%208.30862C23.3883%206.74652%2023.3883%204.21386%2021.8262%202.65177L21.3485%202.17401ZM2.77902%2021.8258C4.34112%2023.3879%206.87378%2023.3879%208.43588%2021.8258L12.8913%2017.3704L11.4771%2015.9562L7.02166%2020.4116C6.24062%2021.1926%204.97429%2021.1926%204.19324%2020.4116L3.58798%2019.8063C2.80694%2019.0253%202.80694%2017.759%203.58798%2016.9779L9.57583%2010.9901C10.3569%2010.209%2011.6232%2010.209%2012.4043%2010.9901L13.3129%2011.8987L14.7271%2010.4845L13.8185%209.57586C12.2564%208.01376%209.72372%208.01376%208.16162%209.57586L2.17377%2015.5637C0.611673%2017.1258%200.611673%2019.6585%202.17377%2021.2206L2.77902%2021.8258Z'%20fill='%232B263B'/%3e%3c/svg%3e`,T=`data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M12%201H11V2V14.5858L5.70719%209.2929L4.29297%2010.7071L11.2223%2017.6365C11.6518%2018.066%2012.3483%2018.066%2012.7779%2017.6365L19.7072%2010.7071L18.293%209.2929L13%2014.5859V2V1H12ZM3.5%2020.5001V16.7501H1.5V20.5001C1.5%2021.6047%202.39543%2022.5001%203.5%2022.5001H20.5C21.6046%2022.5001%2022.5%2021.6047%2022.5%2020.5001V16.7501H20.5V20.5001H3.5Z'%20fill='%232B263B'/%3e%3c/svg%3e`,E=50,D=3e3;function O({dialog:e}){let[t,n]=(0,i.useState)(``),[r,a]=(0,i.useState)(``),[o,s]=(0,i.useState)(!0),c=r.trim().length>0;return(0,u.jsxs)(`div`,{className:`dmui-publish`,children:[(0,u.jsxs)(`div`,{className:`dmui-publish__nav`,children:[(0,u.jsx)(`button`,{type:`button`,className:`dmui-publish__back`,onClick:()=>e.onResult(!1),children:(0,u.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`20`,height:`20`,children:(0,u.jsx)(`path`,{d:`M15 19l-7-7 7-7`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})})}),(0,u.jsxs)(`div`,{className:`dmui-publish__island-chip`,children:[e.islandImage?(0,u.jsx)(`img`,{className:`dmui-publish__chip-avatar`,src:e.islandImage,alt:``}):(0,u.jsx)(`div`,{className:`dmui-publish__chip-avatar dmui-publish__chip-avatar--placeholder`}),(0,u.jsx)(`span`,{className:`dmui-publish__chip-name`,children:e.islandName||`未命名岛`}),(0,u.jsx)(`span`,{className:`dmui-publish__chip-tag`,children:`岛`})]}),(0,u.jsx)(`button`,{type:`button`,className:`dmui-publish__submit${c?``:` dmui-publish__submit--disabled`}`,disabled:!c,onClick:()=>e.onResult(!0),children:`发布`})]}),(0,u.jsxs)(`div`,{className:`dmui-publish__body`,children:[(0,u.jsx)(`div`,{className:`dmui-publish__images`,children:(0,u.jsx)(`div`,{className:`dmui-publish__image-add`,children:(0,u.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`24`,height:`24`,children:(0,u.jsx)(`path`,{d:`M12 5v14M5 12h14`,fill:`none`,stroke:`#999`,strokeWidth:`2`,strokeLinecap:`round`})})})}),(0,u.jsx)(`input`,{className:`dmui-publish__title`,placeholder:`标题 (50字以内)`,value:t,maxLength:E,onChange:e=>n(e.target.value)}),(0,u.jsx)(`textarea`,{className:`dmui-publish__content`,placeholder:`写下你的想法...`,value:r,maxLength:D,onChange:e=>a(e.target.value)})]}),(0,u.jsxs)(`div`,{className:`dmui-publish__toolbar`,children:[(0,u.jsxs)(`span`,{className:`dmui-publish__count`,children:[r.length,`/`,D]}),(0,u.jsx)(`button`,{type:`button`,className:`dmui-publish__privacy`,onClick:()=>s(!o),children:o?`公开`:`私密`})]})]})}function ee(){let[{toast:e,dialog:n},r]=(0,i.useState)(()=>t.getState());return(0,i.useEffect)(()=>t.subscribe(r),[]),(0,u.jsxs)(u.Fragment,{children:[e&&(0,u.jsx)(k,{toast:e}),n?.kind===`modal`&&(0,u.jsx)(j,{dialog:n}),n?.kind===`actionSheet`&&(0,u.jsx)(M,{dialog:n}),n?.kind===`halfSheet`&&(0,u.jsx)(N,{dialog:n}),n?.kind===`capsuleMenu`&&(0,u.jsx)(te,{dialog:n}),n?.kind===`share`&&(0,u.jsx)(ne,{dialog:n}),n?.kind===`openPost`&&(0,u.jsx)(O,{dialog:n})]})}function k({toast:e}){(0,i.useEffect)(()=>{if(!Number.isFinite(e.duration))return;let n=window.setTimeout(()=>t.dismissToast(e),e.duration);return()=>window.clearTimeout(n)},[e]);let n=e.icon!==`none`||!!e.image;return(0,u.jsxs)(`div`,{className:`dmui-overlay`,"aria-live":`polite`,children:[e.mask&&(0,u.jsx)(`div`,{className:`dmui-mask dmui-mask--transparent`}),(0,u.jsxs)(`div`,{className:`dmui-toast${n?``:` dmui-toast--text`}`,role:`alert`,children:[e.image?(0,u.jsx)(`img`,{className:`dmui-toast__image`,src:e.image,alt:``}):(0,u.jsx)(A,{icon:e.icon}),e.title&&(0,u.jsx)(`div`,{className:`dmui-toast__title`,children:e.title})]})]})}function A({icon:e}){return e===`success`?(0,u.jsx)(`svg`,{className:`dmui-toast__icon`,viewBox:`0 0 24 24`,"aria-hidden":`true`,children:(0,u.jsx)(`path`,{d:`M5 13l4 4L19 7`})}):e===`error`?(0,u.jsx)(`svg`,{className:`dmui-toast__icon`,viewBox:`0 0 24 24`,"aria-hidden":`true`,children:(0,u.jsx)(`path`,{d:`M6 6l12 12M18 6L6 18`})}):e===`loading`?(0,u.jsx)(`span`,{className:`dmui-toast__spinner`,"aria-hidden":`true`}):null}function j({dialog:e}){let[t,n]=(0,i.useState)(``),r=(0,i.useRef)(null);return(0,i.useEffect)(()=>{e.editable&&r.current?.focus()},[e.editable]),(0,u.jsxs)(`div`,{className:`dmui-overlay`,children:[(0,u.jsx)(`div`,{className:`dmui-mask`}),(0,u.jsxs)(`div`,{className:`dmui-modal`,role:`dialog`,"aria-modal":`true`,children:[e.title&&(0,u.jsx)(`div`,{className:`dmui-modal__title`,children:e.title}),e.editable?(0,u.jsx)(`input`,{ref:r,className:`dmui-modal__input`,value:t,placeholder:e.placeholderText,onChange:e=>n(e.target.value)}):e.content&&(0,u.jsx)(`div`,{className:`dmui-modal__content`,children:e.content}),(0,u.jsxs)(`div`,{className:`dmui-modal__actions`,children:[e.showCancel&&(0,u.jsx)(`button`,{type:`button`,className:`dmui-modal__button`,style:{color:e.cancelColor},onClick:()=>e.onResult(!1),children:e.cancelText}),(0,u.jsx)(`button`,{type:`button`,className:`dmui-modal__button`,style:{color:e.confirmColor},onClick:()=>e.onResult(!0,t),children:e.confirmText})]})]})]})}function M({dialog:e}){return(0,u.jsxs)(`div`,{className:`dmui-overlay`,children:[(0,u.jsx)(`div`,{className:`dmui-mask`,onClick:()=>e.onSelect(-1)}),(0,u.jsxs)(`div`,{className:`dmui-action-sheet`,role:`menu`,children:[(0,u.jsx)(`div`,{className:`dmui-action-sheet__items`,children:e.itemList.map((t,n)=>(0,u.jsx)(`button`,{type:`button`,className:`dmui-action-sheet__item`,style:{color:e.itemColor},onClick:()=>e.onSelect(n),children:t},n))}),(0,u.jsx)(`button`,{type:`button`,className:`dmui-action-sheet__cancel`,onClick:()=>e.onSelect(-1),children:`取消`})]})]})}function N({dialog:e}){return(0,u.jsxs)(`div`,{className:`dmui-overlay`,children:[(0,u.jsx)(`div`,{className:`dmui-mask`,onClick:()=>e.onResult(!1)}),(0,u.jsxs)(`div`,{className:`dmui-half-sheet`,role:`dialog`,"aria-modal":`true`,children:[(0,u.jsx)(`div`,{className:`dmui-half-sheet__title`,children:`加入岛即可发布讨论`}),(0,u.jsx)(`div`,{className:`dmui-half-sheet__divider`}),(0,u.jsxs)(`div`,{className:`dmui-half-sheet__row`,children:[e.islandAvatar&&(0,u.jsx)(`img`,{className:`dmui-half-sheet__avatar`,src:e.islandAvatar,alt:``}),(0,u.jsxs)(`div`,{className:`dmui-half-sheet__info`,children:[(0,u.jsx)(`div`,{className:`dmui-half-sheet__name`,children:e.islandName}),(0,u.jsxs)(`div`,{className:`dmui-half-sheet__members`,children:[e.memberCount,`人加入`]})]}),(0,u.jsx)(`button`,{type:`button`,className:`dmui-half-sheet__join`,onClick:()=>e.onResult(!0),children:`加入`})]}),(0,u.jsx)(`div`,{className:`dmui-half-sheet__divider`}),(0,u.jsx)(`button`,{type:`button`,className:`dmui-half-sheet__cancel`,onClick:()=>e.onResult(!1),children:`取消`})]})]})}function te({dialog:e}){return(0,u.jsxs)(`div`,{className:`dmui-overlay`,children:[(0,u.jsx)(`div`,{className:`dmui-mask`,onClick:()=>e.onSelect(-1)}),(0,u.jsxs)(`div`,{className:`dmui-bottom-sheet`,role:`dialog`,"aria-modal":`true`,children:[(0,u.jsxs)(`div`,{className:`dmui-capsule-menu__header`,children:[e.appAvatar?(0,u.jsx)(`img`,{className:`dmui-capsule-menu__avatar`,src:e.appAvatar,alt:``}):(0,u.jsx)(`div`,{className:`dmui-capsule-menu__avatar dmui-capsule-menu__avatar--placeholder`}),(0,u.jsxs)(`div`,{className:`dmui-capsule-menu__app-info`,children:[(0,u.jsx)(`div`,{className:`dmui-capsule-menu__app-name`,children:e.appName}),(0,u.jsxs)(`div`,{className:`dmui-capsule-menu__app-version`,children:[`V`,e.appVersion]})]})]}),(0,u.jsx)(`div`,{className:`dmui-bottom-sheet__divider`}),(0,u.jsx)(`div`,{className:`dmui-bottom-sheet__grid`,children:e.items.map((t,n)=>(0,u.jsxs)(`button`,{type:`button`,className:`dmui-bottom-sheet__grid-item`,onClick:()=>e.onSelect(n),children:[(0,u.jsx)(`div`,{className:`dmui-bottom-sheet__icon-circle`,children:t.icon}),(0,u.jsx)(`div`,{className:`dmui-bottom-sheet__item-label`,children:t.label})]},n))}),(0,u.jsx)(`div`,{className:`dmui-bottom-sheet__divider`}),(0,u.jsx)(`button`,{type:`button`,className:`dmui-bottom-sheet__cancel`,onClick:()=>e.onSelect(-1),children:`取消`})]})]})}var P=[{label:`微信`,icon:S},{label:`朋友圈`,icon:C}];function ne({dialog:e}){let t=e.type===`image`?{label:`保存图片`,icon:T}:{label:`复制链接`,icon:w};return(0,u.jsxs)(`div`,{className:`dmui-overlay`,children:[(0,u.jsx)(`div`,{className:`dmui-mask`,onClick:()=>e.onSelect(-1)}),(0,u.jsxs)(`div`,{className:`dmui-bottom-sheet`,role:`dialog`,"aria-modal":`true`,children:[(0,u.jsx)(`div`,{className:`dmui-bottom-sheet__title`,children:`分享到`}),(0,u.jsx)(`div`,{className:`dmui-bottom-sheet__divider`}),(0,u.jsxs)(`div`,{className:`dmui-bottom-sheet__grid`,children:[P.map((t,n)=>(0,u.jsxs)(`button`,{type:`button`,className:`dmui-bottom-sheet__grid-item`,onClick:()=>e.onSelect(n),children:[(0,u.jsx)(`div`,{className:`dmui-bottom-sheet__icon-circle`,children:(0,u.jsx)(`img`,{className:`dmui-bottom-sheet__icon-img`,src:t.icon,alt:t.label})}),(0,u.jsx)(`div`,{className:`dmui-bottom-sheet__item-label`,children:t.label})]},n)),(0,u.jsxs)(`button`,{type:`button`,className:`dmui-bottom-sheet__grid-item`,onClick:()=>e.onSelect(P.length),children:[(0,u.jsx)(`div`,{className:`dmui-bottom-sheet__icon-circle`,children:(0,u.jsx)(`img`,{className:`dmui-bottom-sheet__icon-img`,src:t.icon,alt:t.label})}),(0,u.jsx)(`div`,{className:`dmui-bottom-sheet__item-label`,children:t.label})]})]}),(0,u.jsx)(`div`,{className:`dmui-bottom-sheet__divider`}),(0,u.jsx)(`button`,{type:`button`,className:`dmui-bottom-sheet__cancel`,onClick:()=>e.onSelect(-1),children:`取消`})]})]})}function F(e,n){let r={kind:`capsuleMenu`,appName:n||`小程序`,appAvatar:``,appVersion:`1.0.0`,items:[{label:`复制链接`,icon:`🔗`}],onSelect(n){n===0&&navigator.clipboard.writeText(`https://qiandao.com/miniapp?appId=${e}`),t.hideDialog()}};t.showDialog(r)}function I(e){if(!e)return{config:null,visible:!1,badges:[],redDots:[]};let t=e.list.length;return{config:L(e),visible:!0,badges:Array.from({length:t},()=>``),redDots:Array.from({length:t},()=>!1)}}function L(e){return{...e,list:e.list.map(e=>({...e}))}}function R(e,t){switch(t.kind){case`reset`:return{state:I(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 z(e,t.name,t.params)}}function z(e,t,n){if(!e.config)return{state:e,ok:!1,errMsg:`${t}:fail tabBar not configured`};switch(t){case`setTabBarStyle`:return B(e,n);case`setTabBarItem`:return V(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 H(e,n);case`removeTabBarBadge`:return U(e,n);case`showTabBarRedDot`:return W(e,n,!0);case`hideTabBarRedDot`:return W(e,n,!1)}}function B(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=K(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 V(e,t){let n=G(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 H(e,t){let n=G(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 U(e,t){let n=G(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 W(e,t,n){let r=G(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 G(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 K(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 q(e){return e?e.replace(/^\/+/,``):``}function J(e){if(!e)return null;let t=e.indexOf(`=`),n=t>=0?e.slice(0,t):e,r=t>=0?e.slice(t+1):``;return n?[decodeURIComponent(n),decodeURIComponent(r)]:null}function Y(e){let t={};for(let n of e.split(`&`)){let e=J(n);e&&(t[e[0]]=e[1])}return t}function X(e){let[t,n]=(typeof e==`string`?e:``).split(`?`);return{pagePath:q(t),query:n?Y(n):{}}}function re(e){let t={};return e.isTab&&(t[e.pagePath]=[e]),{stack:[e],tabStacks:t,currentTabPath:e.isTab?e.pagePath:null}}function ie(e){return e.currentTabPath?{...e.tabStacks,[e.currentTabPath]:[...e.stack]}:e.tabStacks}function ae(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 oe(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 se(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 ce(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 le(e,t,n){let r=e.stack[e.stack.length-1],i=ie(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 ue(e){let t=new Map,n=e.stack[e.stack.length-1]?.bridgeId,r=e=>{t.has(e.bridgeId)||t.set(e.bridgeId,{entry:e,visible:e.bridgeId===n})};for(let t of Object.values(e.tabStacks))for(let e of t)r(e);for(let t of e.stack)r(t);return Array.from(t.values())}function Z(e){return e.backgroundColor??`#ffffff`}function Q(e,t){let n=e.navigationBarBackgroundColor??`#ffffff`,r=e.navigationBarTextStyle??`black`,i=e.navigationStyle??`default`;return h({title:e.navigationBarTitleText??t,backgroundColor:n,textStyle:r,style:i,homeButtonVisible:e.homeButton===!0})}function de(e,t,n){switch(t){case`setNavigationBarTitle`:return{...e,title:typeof n.title==`string`?n.title:e.title};case`setNavigationBarColor`:return pe(e,n);case`showNavigationBarLoading`:return{...e,loading:!0};case`hideNavigationBarLoading`:return{...e,loading:!1};case`hideHomeButton`:return{...e,homeButtonVisible:!1};default:return e}}var fe=[`linear`,`easeIn`,`easeOut`,`easeInOut`];function pe(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:fe.includes(i)?i:`linear`}})();return{...e,textStyle:r,backgroundColor:i,colorAnimation:a}}function me(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 he=44,ge=24,$=44;function _e({miniApp:e,bridgeId:t,platform:n=`ios`}){let[a,o]=(0,i.useState)(()=>e.getInitialDevice());(0,i.useEffect)(()=>e.onSimulatorEvent(r.DEVICE_CHANGE,o),[e]);let c=a?.safeAreaInsets.top??(n===`ios`?he:ge),l=a?.safeAreaInsets.bottom??0,d=a?.notchType??`none`,f=(0,i.useMemo)(()=>e.getRenderPreloadUrl(),[e]),p=(0,i.useMemo)(()=>e.getTabBarConfig(),[e]),h=(0,i.useMemo)(()=>({bridgeId:t,pagePath:q(e.pagePath),query:{...e.query},isTab:!!e.getTabBarConfig()?.list.some(t=>q(t.pagePath)===q(e.pagePath)),windowConfig:e.rootWindowConfig??{},navBar:Q(e.rootWindowConfig??{},e.appId)}),[e,t]),[{shell:g,tabBar:y},b]=(0,i.useState)(()=>({shell:re(h),tabBar:I(p)})),x=(0,i.useRef)({shell:g,tabBar:y});(0,i.useEffect)(()=>{x.current={shell:g,tabBar:y}},[g,y]);let S=(0,i.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,i.useEffect)(()=>e.onSimulatorEvent(r.NAV_BAR,e=>{b(t=>({...t,shell:me(t.shell,e.bridgeId,t=>de(t,e.name,e.params))}))}),[e]),(0,i.useEffect)(()=>e.onSessionEvent(r.TAB_ACTION,t=>{let n=R(x.current.tabBar,{kind:`apply`,name:t.name,params:t.params});b(e=>({...e,tabBar:n.state})),e.notifyNavCallback({ok:n.ok,errMsg:n.errMsg,callbacks:t.callbacks})}),[e]);let C=(0,i.useCallback)(async t=>{let n=(n,r)=>e.notifyNavCallback({ok:n,errMsg:r,callbacks:t.callbacks});try{switch(t.name){case`navigateTo`:await ve(e,x,b,S,t,n);break;case`navigateBack`:ye(x,b,S,t,n);break;case`redirectTo`:await be(e,x,b,S,t,n);break;case`reLaunch`:await xe(e,x,b,S,t,n);break;case`switchTab`:await Se(e,x,b,S,t,n);break}}catch(e){n(!1,`${t.name}:fail ${e instanceof Error?e.message:String(e)}`)}},[e,S]);(0,i.useEffect)(()=>e.onSessionEvent(r.NAV_ACTION,e=>{C(e)}),[C,e]),(0,i.useEffect)(()=>e.onSessionEvent(r.API_CALL,t=>{s(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 w=(0,i.useCallback)(()=>{if(x.current.shell.stack.length<=1)return;let t=x.current.shell.stack;C({appSessionId:e.appSessionId??``,bridgeId:t[t.length-1].bridgeId,name:`navigateBack`,params:{delta:1},callbacks:{}})},[e,C]),T=(0,i.useCallback)(t=>{let n=x.current.shell;t===n.currentTabPath&&n.stack.length===1||C({appSessionId:e.appSessionId??``,bridgeId:n.stack[n.stack.length-1].bridgeId,name:`switchTab`,params:{url:`/${t}`},callbacks:{}})},[e,C]),E=(0,i.useCallback)(()=>{let t=x.current.shell.stack;F(e.appId,t[t.length-1].navBar.title)},[e]),D=g.stack[g.stack.length-1],O=ue(g);return(0,i.useEffect)(()=>{e.notifyActivePage(D.bridgeId)},[e,D.bridgeId]),(0,i.useEffect)(()=>{e.notifyPageStack(g.stack.map(e=>({pagePath:e.pagePath,query:e.query})))},[e,g.stack]),(0,u.jsx)(`main`,{className:`device-shell-root`,children:(0,u.jsxs)(`section`,{className:`device-shell`,"aria-label":`Dimina simulator`,style:a?{width:a.screenWidth,height:a.screenHeight}:void 0,children:[(0,u.jsx)(_,{height:c,notchType:d,textStyle:D.navBar.textStyle}),(0,u.jsx)(m,{state:D.navBar,stackDepth:g.stack.length,platform:n,statusBarHeight:c,navBarHeight:$,onBack:w,onMoreClick:E}),(0,u.jsx)(`div`,{className:`device-shell__viewport`,children:O.map(({entry:t,visible:n})=>(0,u.jsx)(`webview`,{className:`device-shell__webview`,src:e.createRenderHostUrl(t.bridgeId,t.pagePath,t.isTab,Z(t.windowConfig)),preload:f,allowpopups:`true`,style:{display:n?`flex`:`none`,zIndex:n?100:1,backgroundColor:Z(t.windowConfig)}},t.bridgeId))}),D.isTab&&(0,u.jsx)(v,{state:y,currentPath:g.currentTabPath,resourceBaseUrl:e.resourceBaseUrl,appId:e.appId,onSwitch:T,bottomInset:l}),(0,u.jsx)(ee,{}),l>0&&(0,u.jsx)(`div`,{className:`device-shell__home-indicator`,style:{height:l},"aria-hidden":`true`})]})})}async function ve(e,t,n,r,i,a){let{pagePath:o,query:s}=X(i.params.url);if(!o){a(!1,`navigateTo:fail invalid url`);return}if(e.getTabBarConfig()?.list.some(e=>q(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:Q(c.windowConfig,e.appId)},{next:u,effects:d}=ae(t.current.shell,l);n(e=>({...e,shell:u})),r(d),a(!0,`navigateTo:ok`)}function ye(e,t,n,r,i){let a=r.params.delta,o=Number.isFinite(Number(a))?Number(a):1,s=oe(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 be(e,t,n,r,i,a){let{pagePath:o,query:s}=X(i.params.url);if(!o){a(!1,`redirectTo:fail invalid url`);return}if(e.getTabBarConfig()?.list.some(e=>q(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:Q(c.windowConfig,e.appId)},{next:u,effects:d}=se(t.current.shell,l);n(e=>({...e,shell:u})),r(d),a(!0,`redirectTo:ok`)}async function xe(e,t,n,r,i,a){let{pagePath:o,query:s}=X(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:Q(c.windowConfig,e.appId)},{next:u,effects:d}=ce(t.current.shell,l);n(e=>({...e,shell:u})),r(d),a(!0,`reLaunch:ok`)}async function Se(e,t,n,r,i,a){let{pagePath:o}=X(i.params.url);if(!o){a(!1,`switchTab:fail invalid url`);return}if(!e.getTabBarConfig()?.list.some(e=>q(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:Q(t.windowConfig,e.appId)}}let{next:l,effects:u}=le(t.current.shell,o,c);n(e=>({...e,shell:l})),r(u),a(!0,`switchTab:ok`)}export{_e as DeviceShell};
2
- //# sourceMappingURL=device-shell-Sbkjw8Nb.js.map