@skillbuilder/miniapp-simulator 0.0.0-stage → 0.2.0

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 (229) hide show
  1. package/README.md +263 -2
  2. package/assets/phones/Nexus-5X.png +0 -0
  3. package/assets/phones/iPhone-14ProMax.png +0 -0
  4. package/assets/rednote-preview/cover/homebar-1439.jpg +0 -0
  5. package/assets/rednote-preview/cover/homebar-1679.jpg +0 -0
  6. package/assets/rednote-preview/cover/homebar-1919.jpg +0 -0
  7. package/assets/rednote-preview/cover/homebar-2284.jpg +0 -0
  8. package/assets/rednote-preview/cover/homebar-2285.jpg +0 -0
  9. package/assets/rednote-preview/cover/like.png +0 -0
  10. package/assets/rednote-preview/cover/play.png +0 -0
  11. package/assets/rednote-preview/cover/topbar-1439.jpg +0 -0
  12. package/assets/rednote-preview/cover/topbar-1679.jpg +0 -0
  13. package/assets/rednote-preview/cover/topbar-1919.jpg +0 -0
  14. package/assets/rednote-preview/cover/topbar-2284.jpg +0 -0
  15. package/assets/rednote-preview/cover/topbar-2285.jpg +0 -0
  16. package/assets/workbench/index.html +77 -0
  17. package/dist/sw/miniapp-simulator-service-worker.js +971 -0
  18. package/dist/sw/miniapp-simulator-service-worker.min.js +1 -0
  19. package/docs/consumer-guide.md +143 -0
  20. package/docs/electron-review.md +21 -0
  21. package/docs/external-cli-workbench.md +195 -0
  22. package/docs/file-system-design.md +334 -0
  23. package/docs/host-external-api.md +235 -0
  24. package/docs/iframe-service-worker.md +190 -0
  25. package/docs/local-dev.md +106 -0
  26. package/docs/npm-integration-verification.md +35 -0
  27. package/docs/remote-architecture.md +404 -0
  28. package/docs/remote-load-observability.md +268 -0
  29. package/docs/remote-usage.md +371 -0
  30. package/docs/request-design.md +247 -0
  31. package/docs/sdk-usage.md +260 -0
  32. package/docs/server-playground-https-debugging.md +150 -0
  33. package/docs/storage-api-design.md +275 -0
  34. package/docs/tracker.md +339 -0
  35. package/docs/worker-runtime.md +62 -0
  36. package/lib/business-line-CMb3ehRn.mjs +15 -0
  37. package/lib/client-CO-UjIY3.mjs +775 -0
  38. package/lib/index-B5oixYXr.mjs +574 -0
  39. package/lib/index.js +10763 -0
  40. package/lib/preload/webview-preload.js +37 -0
  41. package/lib/remote-client.js +11 -0
  42. package/lib/types/business-line.d.ts +7 -0
  43. package/lib/types/capabilities/constants.d.ts +29 -0
  44. package/lib/types/capabilities/csp-snippet.d.ts +34 -0
  45. package/lib/types/capabilities/launch-options.d.ts +7 -0
  46. package/lib/types/capabilities/performance-policy.d.ts +5 -0
  47. package/lib/types/capabilities/security-head-snippet.d.ts +21 -0
  48. package/lib/types/capabilities/security.d.ts +25 -0
  49. package/lib/types/capabilities/style-snippet.d.ts +2 -0
  50. package/lib/types/core/controllers/game-playtest.d.ts +9 -0
  51. package/lib/types/core/controllers/gesture.d.ts +8 -0
  52. package/lib/types/core/controllers/host-api.d.ts +19 -0
  53. package/lib/types/core/controllers/index.d.ts +11 -0
  54. package/lib/types/core/controllers/inspector.d.ts +20 -0
  55. package/lib/types/core/controllers/note-preview.d.ts +9 -0
  56. package/lib/types/core/controllers/permission-sheet.d.ts +7 -0
  57. package/lib/types/core/controllers/widget-cover.d.ts +12 -0
  58. package/lib/types/core/lifecycle.d.ts +7 -0
  59. package/lib/types/core/options.d.ts +33 -0
  60. package/lib/types/core/simulator.d.ts +9 -0
  61. package/lib/types/errors.d.ts +11 -0
  62. package/lib/types/event-bus.d.ts +15 -0
  63. package/lib/types/gesture/host-bus.d.ts +113 -0
  64. package/lib/types/gesture/index.d.ts +27 -0
  65. package/lib/types/gesture/plugins/double-tap.d.ts +10 -0
  66. package/lib/types/gesture/plugins/index.d.ts +27 -0
  67. package/lib/types/gesture/plugins/long-press.d.ts +13 -0
  68. package/lib/types/gesture/plugins/multi-touch-hint.d.ts +11 -0
  69. package/lib/types/gesture/plugins/multi-touch-switch.d.ts +18 -0
  70. package/lib/types/gesture/plugins/selection-disabler.d.ts +11 -0
  71. package/lib/types/gesture/plugins/tap.d.ts +11 -0
  72. package/lib/types/gesture/plugins/touch-emitter.d.ts +11 -0
  73. package/lib/types/gesture/plugins/wheel-scroll.d.ts +11 -0
  74. package/lib/types/gesture/receiver-runtime.d.ts +10 -0
  75. package/lib/types/gesture/receiver-runtime.impl.d.ts +6 -0
  76. package/lib/types/gesture/touch-cursor.d.ts +78 -0
  77. package/lib/types/gesture/touch-dot.d.ts +12 -0
  78. package/lib/types/gesture/types.d.ts +206 -0
  79. package/lib/types/host/shadow-host.d.ts +40 -0
  80. package/lib/types/index.d.ts +56 -0
  81. package/lib/types/injection/guest-log-mark.d.ts +7 -0
  82. package/lib/types/injection/head-builder.d.ts +4 -0
  83. package/lib/types/injection/index.d.ts +19 -0
  84. package/lib/types/injection/modules/console-forward.d.ts +2 -0
  85. package/lib/types/injection/modules/gesture.d.ts +6 -0
  86. package/lib/types/injection/modules/inspector-guest-runtime.d.ts +5 -0
  87. package/lib/types/injection/modules/inspector-pause-runtime.d.ts +6 -0
  88. package/lib/types/injection/modules/inspector.d.ts +8 -0
  89. package/lib/types/injection/modules/jsapi-channel.d.ts +9 -0
  90. package/lib/types/injection/modules/jsapi.d.ts +22 -0
  91. package/lib/types/injection/modules/render-done.d.ts +2 -0
  92. package/lib/types/injection/modules/resource-guard.d.ts +7 -0
  93. package/lib/types/injection/modules/scroll-containment.d.ts +3 -0
  94. package/lib/types/injection/modules/security.d.ts +3 -0
  95. package/lib/types/injection/modules/widget-snapshot.d.ts +13 -0
  96. package/lib/types/injection/preload-builder.d.ts +41 -0
  97. package/lib/types/injection/registry.d.ts +20 -0
  98. package/lib/types/injection/types.d.ts +45 -0
  99. package/lib/types/inspector/host-inspector.d.ts +108 -0
  100. package/lib/types/inspector/index.d.ts +8 -0
  101. package/lib/types/inspector/selector.d.ts +18 -0
  102. package/lib/types/native-ui/devtools/CapabilitiesView.d.ts +18 -0
  103. package/lib/types/native-ui/devtools/DevtoolsPanel.d.ts +24 -0
  104. package/lib/types/native-ui/devtools/LogsView.d.ts +17 -0
  105. package/lib/types/native-ui/devtools/dom.d.ts +40 -0
  106. package/lib/types/native-ui/devtools/index.d.ts +19 -0
  107. package/lib/types/native-ui/devtools/log-entry.d.ts +8 -0
  108. package/lib/types/native-ui/devtools/shortcut.d.ts +12 -0
  109. package/lib/types/native-ui/devtools/tokens.d.ts +14 -0
  110. package/lib/types/native-ui/devtools/types.d.ts +51 -0
  111. package/lib/types/native-ui/index.d.ts +17 -0
  112. package/lib/types/native-ui/note-publish/defaults.d.ts +40 -0
  113. package/lib/types/native-ui/note-publish/index.d.ts +2 -0
  114. package/lib/types/native-ui/note-publish/miniapp-note-publish.d.ts +15 -0
  115. package/lib/types/native-ui/note-publish/note-publish-host.d.ts +15 -0
  116. package/lib/types/native-ui/note-publish/view-data.d.ts +21 -0
  117. package/lib/types/native-ui/permission-sheet/defaults.d.ts +12 -0
  118. package/lib/types/native-ui/permission-sheet/index.d.ts +4 -0
  119. package/lib/types/native-ui/permission-sheet/miniapp-permission-sheet.d.ts +19 -0
  120. package/lib/types/native-ui/permission-sheet/permission-sheet-host.d.ts +23 -0
  121. package/lib/types/native-ui/permission-sheet/types.d.ts +8 -0
  122. package/lib/types/native-ui/rednote-preview/chrome-tone.d.ts +44 -0
  123. package/lib/types/native-ui/rednote-preview/defaults.d.ts +30 -0
  124. package/lib/types/native-ui/rednote-preview/half-sheet-drag.d.ts +61 -0
  125. package/lib/types/native-ui/rednote-preview/index.d.ts +2 -0
  126. package/lib/types/native-ui/rednote-preview/register.d.ts +7 -0
  127. package/lib/types/native-ui/rednote-preview/styles.d.ts +4 -0
  128. package/lib/types/native-ui/rednote-preview/xhs-note-detail-shell.d.ts +70 -0
  129. package/lib/types/native-ui/rednote-preview/xhs-note-half-sheet.d.ts +100 -0
  130. package/lib/types/native-ui/rednote-preview/xhs-profile-shell.d.ts +31 -0
  131. package/lib/types/native-ui/toast/frame-toast-host.d.ts +18 -0
  132. package/lib/types/native-ui/toast/index.d.ts +19 -0
  133. package/lib/types/presets.d.ts +11 -0
  134. package/lib/types/remote/client.d.ts +89 -0
  135. package/lib/types/remote/jsapi-config.d.ts +9 -0
  136. package/lib/types/remote/load-timing.d.ts +46 -0
  137. package/lib/types/remote/protocol.d.ts +165 -0
  138. package/lib/types/remote/review-launch.d.ts +6 -0
  139. package/lib/types/remote/runtime-entry.d.ts +1 -0
  140. package/lib/types/remote/runtime.d.ts +14 -0
  141. package/lib/types/remote/simulator-prompt.d.ts +9 -0
  142. package/lib/types/remote/widget-snapshot-guest-runtime.d.ts +1 -0
  143. package/lib/types/remote-client.d.ts +5 -0
  144. package/lib/types/renderer/base.d.ts +8 -0
  145. package/lib/types/renderer/content-host/iframe-content-host.d.ts +84 -0
  146. package/lib/types/renderer/content-host/index.d.ts +3 -0
  147. package/lib/types/renderer/content-host/types.d.ts +89 -0
  148. package/lib/types/renderer/content-host/webview-content-host.d.ts +53 -0
  149. package/lib/types/renderer/iframe.d.ts +93 -0
  150. package/lib/types/renderer/index.d.ts +2 -0
  151. package/lib/types/renderer/rednote-shell.d.ts +73 -0
  152. package/lib/types/renderer/webview.d.ts +59 -0
  153. package/lib/types/runtime/context.d.ts +31 -0
  154. package/lib/types/runtime/jsapi-modules/context.d.ts +19 -0
  155. package/lib/types/runtime/jsapi-modules/filesystem.d.ts +19 -0
  156. package/lib/types/runtime/jsapi-modules/index.d.ts +9 -0
  157. package/lib/types/runtime/jsapi-modules/interaction.d.ts +4 -0
  158. package/lib/types/runtime/jsapi-modules/location.d.ts +3 -0
  159. package/lib/types/runtime/jsapi-modules/media.d.ts +13 -0
  160. package/lib/types/runtime/jsapi-modules/network.d.ts +3 -0
  161. package/lib/types/runtime/jsapi-modules/storage.d.ts +26 -0
  162. package/lib/types/runtime/jsapi-modules/system.d.ts +4 -0
  163. package/lib/types/runtime/jsapi-modules/types.d.ts +21 -0
  164. package/lib/types/runtime/jsapi-modules/window-info.d.ts +43 -0
  165. package/lib/types/runtime/request/host-request.d.ts +13 -0
  166. package/lib/types/runtime/request/request-manager-frame.d.ts +29 -0
  167. package/lib/types/runtime/request/request-runtime.d.ts +26 -0
  168. package/lib/types/runtime/request/request-types.d.ts +26 -0
  169. package/lib/types/runtime/request/sse-text-framer.d.ts +16 -0
  170. package/lib/types/seal-config.d.ts +134 -0
  171. package/lib/types/sw/index.d.ts +9 -0
  172. package/lib/types/sw/parse-raw.d.ts +34 -0
  173. package/lib/types/sw/protocol.d.ts +19 -0
  174. package/lib/types/sw/served-entry.d.ts +9 -0
  175. package/lib/types/sw/service-worker-content-host.d.ts +11 -0
  176. package/lib/types/sw/service-worker-host.d.ts +74 -0
  177. package/lib/types/sw/service-worker-renderer.d.ts +10 -0
  178. package/lib/types/sw/worker/fs-codec.d.ts +23 -0
  179. package/lib/types/sw/worker/fs-ops.d.ts +22 -0
  180. package/lib/types/sw/worker/fs-store.d.ts +29 -0
  181. package/lib/types/sw/worker/globals.d.ts +50 -0
  182. package/lib/types/sw/worker/main.d.ts +6 -0
  183. package/lib/types/sw/worker/mime.d.ts +2 -0
  184. package/lib/types/sw/worker/mount-store.d.ts +48 -0
  185. package/lib/types/sw/worker/paths.d.ts +4 -0
  186. package/lib/types/sw/worker/serve.d.ts +13 -0
  187. package/lib/types/tracker/constants.d.ts +14 -0
  188. package/lib/types/tracker/default-tracker.d.ts +19 -0
  189. package/lib/types/tracker/index.d.ts +70 -0
  190. package/lib/types/transport/bridge-protocol.d.ts +78 -0
  191. package/lib/types/transport/iframe-transport.d.ts +39 -0
  192. package/lib/types/transport/index.d.ts +14 -0
  193. package/lib/types/transport/jsapi-bridge-messages.d.ts +36 -0
  194. package/lib/types/transport/types.d.ts +48 -0
  195. package/lib/types/transport/webview-transport.d.ts +52 -0
  196. package/lib/types/types/events.d.ts +130 -0
  197. package/lib/types/types/index.d.ts +11 -0
  198. package/lib/types/types/inspector.d.ts +172 -0
  199. package/lib/types/types/jsapi.d.ts +18 -0
  200. package/lib/types/types/options.d.ts +851 -0
  201. package/lib/types/types/renderer.d.ts +145 -0
  202. package/lib/types/utils/ancestor-scroll.d.ts +11 -0
  203. package/lib/types/utils/error-svg.d.ts +12 -0
  204. package/lib/types/utils/frameless-shell.d.ts +114 -0
  205. package/lib/types/utils/miniapp-chrome-svg.d.ts +47 -0
  206. package/lib/types/utils/package-constants.d.ts +8 -0
  207. package/lib/types/utils/screenshot.d.ts +14 -0
  208. package/lib/types/utils/simulator-pc-guard.d.ts +10 -0
  209. package/lib/types/utils/stage-fit.d.ts +6 -0
  210. package/lib/types/utils/touch-emulate.d.ts +26 -0
  211. package/lib/types/utils/zip-entry.d.ts +13 -0
  212. package/lib/types/workbench/index.d.ts +63 -0
  213. package/lib/types/workbench/preview-transition.d.ts +8 -0
  214. package/lib/types/workbench/server/artifact.d.ts +8 -0
  215. package/lib/types/workbench/server/index.d.ts +19 -0
  216. package/lib/types/workbench/server/watch.d.ts +6 -0
  217. package/lib/types/workbench/view.d.ts +36 -0
  218. package/lib/types/worker/adapters/csp-policy.d.ts +7 -0
  219. package/lib/types/worker/adapters/host-lifecycle.d.ts +5 -0
  220. package/lib/types/worker/adapters/mount-recovery.d.ts +2 -0
  221. package/lib/types/worker/adapters/package-policy.d.ts +12 -0
  222. package/lib/types/worker/adapters/page-lifecycle.d.ts +1 -0
  223. package/lib/types/worker/adapters/protocol.d.ts +49 -0
  224. package/lib/types/worker/adapters/scripts.d.ts +2 -0
  225. package/lib/types/worker/adapters/service-worker.d.ts +2 -0
  226. package/lib/workbench-server.mjs +183 -0
  227. package/lib/workbench.js +1404 -0
  228. package/package.json +61 -4
  229. package/scripts/mock-cli-dev.mjs +52 -0
@@ -0,0 +1,37 @@
1
+ (function() {
2
+ if (!(typeof window > "u")) {
3
+ var r = "__miniAppWebviewChannelInjected__";
4
+ if (!window[r]) {
5
+ window[r] = !0;
6
+ var n = null;
7
+ try {
8
+ n = require("electron").ipcRenderer;
9
+ } catch {
10
+ return;
11
+ }
12
+ if (n) {
13
+ var i = "mas:msg";
14
+ window.addEventListener("message", function(t) {
15
+ var e = t.data;
16
+ if (!(!e || typeof e != "object") && typeof e.type == "string")
17
+ try {
18
+ n.sendToHost(i, e);
19
+ } catch {
20
+ }
21
+ }), console.info("[mini-app-sdk][guest] webview-preload 通道桥接已注入"), n.on(i, function(t, e) {
22
+ if (!(!e || typeof e != "object"))
23
+ try {
24
+ e.type && console.info("[mini-app-sdk][guest] preload 收到宿主消息", e.type), window.dispatchEvent(
25
+ new MessageEvent("message", { data: e, source: window })
26
+ );
27
+ } catch {
28
+ try {
29
+ window.postMessage(e, "*");
30
+ } catch {
31
+ }
32
+ }
33
+ });
34
+ }
35
+ }
36
+ }
37
+ })();
@@ -0,0 +1,11 @@
1
+ import { R as r, a as O, c as e } from "./client-CO-UjIY3.mjs";
2
+ import { B as s, M as _ } from "./business-line-CMb3ehRn.mjs";
3
+ import { M } from "./index-B5oixYXr.mjs";
4
+ export {
5
+ s as BusinessLine,
6
+ _ as MINIAPP_SCREENSHOT_ERROR_CODE,
7
+ M as MiniAppJsApiErrorCode,
8
+ r as REMOTE_INSPECTOR_PAUSE_RUNTIME_CAPABILITY,
9
+ O as REMOTE_SIMULATOR_PROTOCOL_VERSION,
10
+ e as createRemoteMiniAppSimulator
11
+ };
@@ -0,0 +1,7 @@
1
+ /** 模拟器支持的业务线;用于远端策略、启动参数和 AI 网关路由。 */
2
+ export declare enum BusinessLine {
3
+ skillDesignable = "skill-designable",
4
+ creator = "creator",
5
+ mars = "mars",
6
+ dev = "dev"
7
+ }
@@ -0,0 +1,29 @@
1
+ import type { CspDirective } from "../types";
2
+ /**
3
+ * CSP 逐指令默认表。`freeze: true` = 锁死,忽略消费方一切覆盖(安全底线)。
4
+ *
5
+ * - 资源类(script/style/img/font/media):按资源类型配置 `'self'`、`data:`、`blob:`。
6
+ * - 请求类(connect-src):仅 `'self'`,消费方按需增加接口域名。
7
+ * - worker-src:默认关闭,Worker 开关启用时允许同源资源。
8
+ * - `base-uri`:仅 `'self'`(跨域远程入口的 `<base href>` 由构建时内部补入口 origin)。
9
+ * - `'none'` 四项:禁插件 / 禁表单外发 / 禁子 frame,锁死。
10
+ */
11
+ export declare const DEFAULT_CSP_DIRECTIVES: Record<CspDirective, {
12
+ freeze: boolean;
13
+ default: Record<string, boolean>;
14
+ }>;
15
+ /** iframe `sandbox` 默认标志表(`true` 的 flag 生效,消费方可传 `false` 关掉)。 */
16
+ export declare const DEFAULT_SANDBOX_FLAGS_MAP: Record<string, boolean>;
17
+ /**
18
+ * iframe `allow`:委托 Permissions Policy `camera`、`microphone`、`autoplay`(值为 `*`)。
19
+ * 未列出的能力不向子 frame 主动放权。
20
+ */
21
+ export declare const DEFAULT_IFRAME_ALLOW_MAP: Record<string, string | string[] | boolean>;
22
+ /**
23
+ * 子文档 `<meta http-equiv="Permissions-Policy">` 默认表(`feature → allowlist`)。
24
+ * `false` → `feature=()`(禁用);`"self"` → `feature=(self)`(仅本文档)。
25
+ *
26
+ * 对齐 MiniTool WebView 安全策略 §3.1「禁用(需实现)」+ 纵深防御项。
27
+ * 「文件选择 / 相册」依赖 sandbox `allow-forms`,不体现在本 header 字段里。
28
+ */
29
+ export declare const DEFAULT_PERMISSIONS_POLICY_MAP: Record<string, boolean | string | string[]>;
@@ -0,0 +1,34 @@
1
+ import type { CspDirective } from "../types";
2
+ export interface BuildContentSecurityPolicyOptions {
3
+ /** 当前包会话是否开放 Worker;资源响应层负责下发 Worker CSP。 */
4
+ workerEnabled?: boolean;
5
+ /**
6
+ * 合并后的逐指令 token 表(来自 normalized `security.cspDirectives`)。
7
+ * 缺省时用内部默认表。
8
+ */
9
+ directives?: Record<CspDirective, Record<string, boolean>>;
10
+ /**
11
+ * 当前加载的 app URL。其 origin 会被追加进所有非 freeze 指令——
12
+ * 远程 loadApp / SW 虚拟入口的 `<base href>` 与绝对 URL 子资源解析所需(SW 同源即 'self')。
13
+ */
14
+ appUrl?: string;
15
+ /**
16
+ * 额外内部放行源(如 SW 远程代理的远程 origin:其绝对 URL 引用的资源不经 SW、浏览器直连)。
17
+ * 非消费方 API——追加进所有非 freeze 指令。
18
+ */
19
+ extraOrigins?: string[];
20
+ /** 跨站 iframe 模式下精确放行的宿主 origin;仅用于 frame-ancestors。 */
21
+ frameAncestors?: string[];
22
+ /** 传入时 script-src 用 `'nonce-xxx'` 放行注入脚本。 */
23
+ scriptNonce?: string;
24
+ }
25
+ /**
26
+ * 构建 CSP(对齐 MiniTool §5.4),SW / webview 模式共用同一套控制。
27
+ *
28
+ * 逐指令:freeze 指令(`'none'` 那几个)用默认表锁死;其余取合并后的 token 表,
29
+ * 并在构建时按 appUrl 做内部增强(追加跨域资源 origin)。
30
+ */
31
+ export declare function buildDefaultContentSecurityPolicy(options?: BuildContentSecurityPolicyOptions): string;
32
+ export declare function buildContentSecurityPolicyMetaSnippet(options?: BuildContentSecurityPolicyOptions): string;
33
+ /** 生成一次注入用的随机 CSP nonce(16 字节 → base64)。 */
34
+ export declare function generateCspNonce(): string;
@@ -0,0 +1,7 @@
1
+ /** 容器与 JS SDK 之间的私有启动参数全局名。 */
2
+ export declare const LAUNCH_OPTIONS_GLOBAL_KEY = "$xhs";
3
+ export declare const DEFAULT_USER_DATA_PATH = "";
4
+ /** 模拟器提供的最小启动参数。 */
5
+ export declare function buildSimulatorLaunchOptions(appId?: string, userDataPath?: string, gateways?: Record<string, string>, businessLine?: string): Record<string, unknown>;
6
+ /** 构建在 JS SDK 前执行的启动参数注入脚本。 */
7
+ export declare function buildLaunchOptionsGlobalSource(appId?: string, userDataPath?: string, gateways?: Record<string, string>, businessLine?: string): string;
@@ -0,0 +1,5 @@
1
+ /** Default resource limits applied by the simulator runtime. */
2
+ export declare const DEFAULT_MINIAPP_PERFORMANCE_POLICY: {
3
+ readonly maxHeapUsedBytes: number;
4
+ readonly heapSampleIntervalMs: 1000;
5
+ };
@@ -0,0 +1,21 @@
1
+ import { type MiniAppCapability } from "../seal-config";
2
+ import type { CspDirective } from "../types";
3
+ import type { WorkerGuardConfig } from "../worker/adapters/protocol";
4
+ export interface BuildSecurityMetaSnippetOptions {
5
+ /** 已解析的 Permissions-Policy meta 内容串(来自 normalized security.permissionsPolicy)。 */
6
+ permissionsPolicy?: string;
7
+ /** 合并后的 CSP 逐指令 token 表。 */
8
+ cspDirectives?: Record<CspDirective, Record<string, boolean>>;
9
+ /** 是否注入 CSP meta,默认 true。SW 模式传 false(CSP 改由响应头下发)。 */
10
+ csp?: boolean;
11
+ /** 当前加载的 app URL,用于 CSP 内部增强(跨域 base/资源 origin)。 */
12
+ appUrl?: string;
13
+ /** 额外内部放行源(SW 远程代理 origin)。 */
14
+ extraOrigins?: string[];
15
+ /** CSP nonce,透传给 CSP meta 的 script-src。 */
16
+ scriptNonce?: string;
17
+ }
18
+ /** 安全 meta:Permissions-Policy → CSP(`csp:false` 时不出,改走响应头)。 */
19
+ export declare function buildSecurityMetaSnippet(options?: BuildSecurityMetaSnippetOptions): string;
20
+ /** seal 裸源:宿主配置(早于 IIFE)+ 静态 seal 文件 + Worker 生命周期接线。 */
21
+ export declare function buildSealScriptSource(sealAllow?: ReadonlyArray<MiniAppCapability>, workerContext?: WorkerGuardConfig): string;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * 安全配置的「token 合并表」解析与序列化工具,以及 zip 路径穿越校验。
3
+ *
4
+ * 合并语义统一:`{ ...默认表, ...消费方表 }` → 按各字段值语义序列化成最终串。
5
+ */
6
+ /**
7
+ * §6.2:拒绝 zip 路径穿越条目。
8
+ * @returns 规范化后的相对路径,非法则返回 null
9
+ */
10
+ export declare function assertSafeZipEntryPath(entryPath: string): string | null;
11
+ /** 取 `Record<token, boolean>` 中值为 `true` 的键(用于 sandbox / CSP 等布尔 token 表)。 */
12
+ export declare function resolveTokenMap(map: Record<string, boolean>): string[];
13
+ /** 解析 iframe `sandbox` 标志表为属性串(取值为 `true` 的 flag 按空格拼接)。 */
14
+ export declare function resolveSandboxFlags(map: Record<string, boolean>): string;
15
+ /**
16
+ * 序列化 iframe `allow` 表(`feature → allowlist`)为属性串,如 `camera *; microphone 'self'`。
17
+ * 值为 `false` 的 feature 丢弃;`true` 视为 `*`;string / string[] 为 allowlist。
18
+ */
19
+ export declare function serializeIframeAllow(map: Record<string, string | string[] | boolean>): string;
20
+ /**
21
+ * 序列化 Permissions-Policy 表(`feature → allowlist`)为 meta 内容串,如 `geolocation=(), camera=(self)`。
22
+ * `true` → `feature=*`(放行全部);`false` → `feature=()`(禁用);string / string[] → `feature=(self "origin")`。
23
+ * allowlist 内含 `*` → `feature=*`。
24
+ */
25
+ export declare function serializePermissionsPolicy(map: Record<string, boolean | string | string[]>): string;
@@ -0,0 +1,2 @@
1
+ /** 模拟器固定的子文档基线样式。 */
2
+ export declare function buildStyleSnippet(): string;
@@ -0,0 +1,9 @@
1
+ import type { MiniAppGamePlaytestController, RendererAdapter } from "../../types";
2
+ export interface GamePlaytestControllerDeps {
3
+ getRenderer(): RendererAdapter | null;
4
+ }
5
+ /**
6
+ * `simulator.gamePlaytest`:只允许调用版本化游戏桥的固定方法,避免对消费方暴露任意
7
+ * iframe/window/electron executeJavaScript 能力。
8
+ */
9
+ export declare function createGamePlaytestController(deps: GamePlaytestControllerDeps): MiniAppGamePlaytestController;
@@ -0,0 +1,8 @@
1
+ import type { GestureHostPluginLike, MiniAppGestureController, RendererAdapter } from "../../types";
2
+ export interface GestureControllerDeps {
3
+ /** 持久化的用户自定义 gesture plugin:跨 reload / renderer 重建保留 */
4
+ gesturePlugins: Map<string, GestureHostPluginLike>;
5
+ getRenderer(): RendererAdapter | null;
6
+ }
7
+ /** `simulator.gesture` 控制器:注册 / 卸载手势 plugin 并同步到当前 renderer。 */
8
+ export declare function createGestureController(deps: GestureControllerDeps): MiniAppGestureController;
@@ -0,0 +1,19 @@
1
+ import type { MiniAppHostApiController, MiniAppHostApiEntry, RendererAdapter } from "../../types";
2
+ export interface HostApiControllerDeps {
3
+ /**
4
+ * 宿主能力 map:构造时来自 `options.hostApi`,控制器在其上做增删。
5
+ * 这个 map **不会**注册到 bridge.handlers;由 bridge 内置 jsapi handler 按需查询。
6
+ */
7
+ hostApiMap: Record<string, MiniAppHostApiEntry>;
8
+ getRenderer(): RendererAdapter | null;
9
+ }
10
+ /**
11
+ * `simulator.hostApi` 控制器:增删宿主能力 map + 主动 emit 事件。
12
+ *
13
+ * 设计要点:
14
+ * - hostApi 与 bridge handlers 是两个分离的概念:bridge handler 是 jsapi 实现,
15
+ * hostApi 是 jsapi 实现内部可调用的"宿主能力"。
16
+ * - 因此 `set/remove/clear/has` 只操作内部 map,不下推到 bridge;
17
+ * `emit` 主动推送事件给小应用,直接走 `renderer.bridge`。
18
+ */
19
+ export declare function createHostApiController(deps: HostApiControllerDeps): MiniAppHostApiController;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Controllers 模块 —— `simulator` 上挂载的运行时控制器(hostApi / gesture / notePreview /
3
+ * permissionSheet)。每个控制器以工厂函数形式注入所需的可变状态访问器,主类只负责编排。
4
+ */
5
+ export { createHostApiController, type HostApiControllerDeps } from "./host-api";
6
+ export { createGestureController, type GestureControllerDeps } from "./gesture";
7
+ export { createGamePlaytestController, type GamePlaytestControllerDeps } from "./game-playtest";
8
+ export { createInspectorController, type InspectorControllerDeps } from "./inspector";
9
+ export { createPermissionSheetController, type PermissionSheetControllerDeps, } from "./permission-sheet";
10
+ export { createNotePreviewController, type NotePreviewControllerDeps } from "./note-preview";
11
+ export { createWidgetCoverController, type WidgetCoverControllerDeps } from "./widget-cover";
@@ -0,0 +1,20 @@
1
+ import type { MiniAppInspectorController, MiniAppInspectorSelectionMode, RendererAdapter } from "../../types";
2
+ export interface InspectorControllerDeps {
3
+ getRenderer(): RendererAdapter | null;
4
+ /** 读持久化的开启状态(跨 reload / renderer 重建保留) */
5
+ isEnabled(): boolean;
6
+ /** 写持久化的开启状态 */
7
+ setEnabled(value: boolean): void;
8
+ /** 读写持久化的单选 / 多选模式 */
9
+ getSelectionMode(): MiniAppInspectorSelectionMode;
10
+ setSelectionMode(mode: MiniAppInspectorSelectionMode): void;
11
+ /** 状态变化时向 EventBus emit `inspectorChange` */
12
+ emitChange(enabled: boolean): void;
13
+ }
14
+ /**
15
+ * `simulator.inspector` 控制器:开关可视化元素选取模式。
16
+ *
17
+ * 状态持久化在主类(`setEnabled`),renderer 重建(load/reload)后由主类自动重应用,
18
+ * 与 gesture plugin 的持久化语义一致。renderer 未实现选取(webview / 未 mount)时方法为 no-op。
19
+ */
20
+ export declare function createInspectorController(deps: InspectorControllerDeps): MiniAppInspectorController;
@@ -0,0 +1,9 @@
1
+ import type { MiniAppNotePreviewController, NormalizedMiniAppSimulatorOptions } from "../../types";
2
+ export interface NotePreviewControllerDeps {
3
+ getOptions(): NormalizedMiniAppSimulatorOptions;
4
+ setOptions(next: NormalizedMiniAppSimulatorOptions): void;
5
+ /** 把最新 notePreview / rednoteDetail 同步到当前 renderer 壳层 */
6
+ syncRednote(): void;
7
+ }
8
+ /** `simulator.notePreview` 控制器:运行时增量更新壳层笔记数据(无需 reload)。 */
9
+ export declare function createNotePreviewController(deps: NotePreviewControllerDeps): MiniAppNotePreviewController;
@@ -0,0 +1,7 @@
1
+ import type { MiniAppPermissionSheetController, RendererAdapter } from "../../types";
2
+ export interface PermissionSheetControllerDeps {
3
+ getRenderer(): RendererAdapter | null;
4
+ onResult?(type: string, result: string): void;
5
+ }
6
+ /** `simulator.permissionSheet` 控制器:转发到当前 renderer 的授权弹窗(无渲染器时为 no-op)。 */
7
+ export declare function createPermissionSheetController(deps: PermissionSheetControllerDeps): MiniAppPermissionSheetController;
@@ -0,0 +1,12 @@
1
+ import type { MiniAppWidgetCoverController, NormalizedMiniAppSimulatorOptions } from "../../types";
2
+ export interface WidgetCoverControllerDeps {
3
+ getOptions(): NormalizedMiniAppSimulatorOptions;
4
+ setOptions(next: NormalizedMiniAppSimulatorOptions): void;
5
+ /** 把 widgetCover 同步到当前 renderer 壳层(笔记尾卡 + 个人页卡片) */
6
+ syncWidgetCover(): void;
7
+ }
8
+ /**
9
+ * `simulator.widgetCover` 控制器:更新小工具封面(title / cover 部分覆盖),
10
+ * 笔记轮播尾卡与个人页「作品 → 小工具」卡片两处生效。
11
+ */
12
+ export declare function createWidgetCoverController(deps: WidgetCoverControllerDeps): MiniAppWidgetCoverController;
@@ -0,0 +1,7 @@
1
+ import type { MiniAppSimulatorStatus } from "../types";
2
+ export declare class LifecycleState {
3
+ private current;
4
+ get status(): MiniAppSimulatorStatus;
5
+ transitionTo(next: MiniAppSimulatorStatus): void;
6
+ assertActive(): void;
7
+ }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * 配置解析与归一化(原 params/{normalize,url-builder}.ts 合并而来)。
3
+ *
4
+ * - parseViewport —— "WxH" 字符串 → viewport
5
+ * - normalizeSimulatorOptions —— options → 归一化后内部使用的形态
6
+ * - buildMiniAppUrl —— appUrl + options.query → 完整 url
7
+ */
8
+ import type { MiniAppSecurityOptions, MiniAppSimulatorOptions, MiniAppViewport, NormalizedMiniAppSecurityOptions, NormalizedMiniAppSimulatorOptions } from "../types";
9
+ /**
10
+ * 深合并 security 补丁:把归一化后的当前值(map 形态)与增量补丁合并成一份
11
+ * `MiniAppSecurityOptions`,供 `normalizeSimulatorOptions` 再次归一化(幂等)。
12
+ * cspDirectives 需逐指令浅合并,使配置补丁能正确累积。
13
+ */
14
+ export declare function mergeSecurity(current: NormalizedMiniAppSecurityOptions, patch: MiniAppSecurityOptions | undefined): MiniAppSecurityOptions;
15
+ /**
16
+ * normalize 上下文:由 simulator 在创建 shadow host 后注入。
17
+ * - `container`:渲染器实际挂载点(stage)
18
+ * - `stageFitBounds`:stageFit 默认可用区域(bounds)
19
+ */
20
+ export interface NormalizeSimulatorContext {
21
+ container: HTMLElement;
22
+ stageFitBounds: HTMLElement;
23
+ }
24
+ /**
25
+ * 内部配置形态:公开选项 + 仅内部可设置的 `appUrl`(入口由 loadApp / loadZip / loadFiles 写入,不对外暴露)。
26
+ */
27
+ export type MiniAppSimulatorInternalOptions = MiniAppSimulatorOptions & {
28
+ appUrl?: string;
29
+ };
30
+ export declare function normalizeSimulatorOptions(options: Omit<MiniAppSimulatorInternalOptions, "mount" | "shadow">, context: NormalizeSimulatorContext): NormalizedMiniAppSimulatorOptions;
31
+ /** 解析 "390x844" 形态的 viewport 字符串;非法返回 undefined。 */
32
+ export declare function parseViewport(value?: string): MiniAppViewport | undefined;
33
+ export declare function buildMiniAppUrl(appUrl: string, query?: Record<string, string | number | boolean | undefined | null>): string;
@@ -0,0 +1,9 @@
1
+ import type { MiniAppSimulator as MiniAppSimulatorInterface, MiniAppSimulatorOptions } from "../types";
2
+ export declare function createMiniAppSimulator(options: MiniAppSimulatorOptions): MiniAppSimulatorInterface;
3
+ /** @internal 远程 Runtime 注入服务端托管资源;不属于接入方配置。 */
4
+ export declare function createRuntimeMiniAppSimulator(options: MiniAppSimulatorOptions, runtimeOptions: {
5
+ requestManagerFrameUrl: string;
6
+ gateways?: Record<string, string>;
7
+ businessLine?: string;
8
+ trackerContext?: () => Record<string, string | number | undefined>;
9
+ }): MiniAppSimulatorInterface;
@@ -0,0 +1,11 @@
1
+ import type { MiniAppErrorCode } from "./types";
2
+ export declare class MiniAppSimulatorError extends Error {
3
+ readonly code: MiniAppErrorCode;
4
+ readonly url?: string;
5
+ readonly cause?: unknown;
6
+ constructor(code: MiniAppErrorCode, message: string, options?: {
7
+ url?: string;
8
+ cause?: unknown;
9
+ });
10
+ }
11
+ export declare function toMiniAppSimulatorError(error: unknown, fallbackCode: MiniAppErrorCode): MiniAppSimulatorError;
@@ -0,0 +1,15 @@
1
+ import type { MiniAppEventHandler, MiniAppEventMap, MiniAppEventName } from "./types";
2
+ /** `'*'` 通配监听器签名:收到任意事件时被调用,含事件名与原 payload */
3
+ export type MiniAppWildcardHandler = (event: MiniAppEventName, payload: MiniAppEventMap[MiniAppEventName]) => void;
4
+ export declare class EventBus {
5
+ private readonly listeners;
6
+ /** 通配监听器集合(订阅所有事件,常用于宿主侧埋点 / tracker) */
7
+ private readonly wildcardListeners;
8
+ on<E extends MiniAppEventName>(event: E, handler: MiniAppEventHandler<E>): () => void;
9
+ on(event: "*", handler: MiniAppWildcardHandler): () => void;
10
+ once<E extends MiniAppEventName>(event: E, handler: MiniAppEventHandler<E>): () => void;
11
+ off<E extends MiniAppEventName>(event: E, handler: MiniAppEventHandler<E>): void;
12
+ off(event: "*", handler: MiniAppWildcardHandler): void;
13
+ emit<E extends MiniAppEventName>(event: E, payload: MiniAppEventMap[E]): void;
14
+ clear(): void;
15
+ }
@@ -0,0 +1,113 @@
1
+ /**
2
+ * GestureHostBus — 父窗口侧的事件源 + 调度器。
3
+ *
4
+ * 职责:
5
+ * 1. 创建 overlay div 并挂到 iframe 屏幕区域上方
6
+ * 2. 监听原始 mouse/wheel/keyboard/blur 事件,转换为 PointerSnapshot
7
+ * 3. 调度给所有注册的 GestureHostPlugin
8
+ * 4. 提供共享状态、send / emit / hook 等 plugin 协作机制
9
+ *
10
+ * Plugin 通过 `install(ctx)` 订阅事件并往 iframe 发协议消息。
11
+ */
12
+ import type { GestureDispatchInput, GestureDispatchResult, GestureGuestChannel, GestureHostPlugin, GestureSharedState } from "./types";
13
+ export interface GestureHostBusOptions {
14
+ /** 内容载体元素(iframe 或 webview);仅用于坐标换算与聚焦 */
15
+ element: HTMLElement;
16
+ /** host↔guest 介质通道(发送/回包/聚焦/cursor),由各 ContentHost 注入 */
17
+ channel: GestureGuestChannel;
18
+ /** overlay 挂载位置,一般是载体父容器(手机壳屏幕层或 screenEl) */
19
+ mountTarget: HTMLElement;
20
+ /**
21
+ * 悬停指示(圆点)跟踪区域,默认同 mountTarget。
22
+ * 半屏详情模式下可设为 contentRoot,使圆点覆盖整台「手机」而非仅 iframe 槽位。
23
+ */
24
+ hoverTrackTarget?: HTMLElement;
25
+ /**
26
+ * 跨 Shadow DOM 边界的移入监听(一般为 shadow host,light DOM)。
27
+ * 首次移入模拟器时尚未产生 mousemove,需靠 mouseenter 立即显示圆点。
28
+ */
29
+ hoverEnterTarget?: HTMLElement;
30
+ debug?: boolean;
31
+ }
32
+ export declare class GestureHostBus {
33
+ private readonly element;
34
+ private readonly channel;
35
+ private readonly overlay;
36
+ private readonly mountTarget;
37
+ /** 悬停 move/leave 监听区域(可与 mountTarget 不同) */
38
+ private readonly hoverTrackTarget;
39
+ /** light DOM 移入边界(shadow host),补 Shadow 穿透场景 */
40
+ private readonly hoverEnterTarget;
41
+ private readonly debug;
42
+ private readonly rawHandlers;
43
+ private readonly logicHandlers;
44
+ private readonly plugins;
45
+ /** 跨 plugin 共享状态 */
46
+ readonly state: GestureSharedState;
47
+ private destroyed;
48
+ /** 当前 mouse 是否正在捕获 mousemove(mousedown 后绑定,mouseup 后解绑) */
49
+ private capturingWindowMove;
50
+ /** 业务 plugin 可临时覆盖 cursor,nul 时回到默认 */
51
+ private overriddenCursor;
52
+ /** 内置手指指针(圆点);触摸模拟的核心视觉,独立于事件管线 */
53
+ private touchCursor;
54
+ /** guest→host 回包订阅取消句柄(focus-editable 等) */
55
+ private readonly unsubscribeChannel;
56
+ constructor(options: GestureHostBusOptions);
57
+ /**
58
+ * Sheet / 模态层 / DevTools 元素审查打开时设为 false,避免 overlay 挡住 webview 或拦截 CDP 选点。
59
+ * 关闭后恢复,不影响手势模拟。
60
+ */
61
+ setOverlayInteractionEnabled(enabled: boolean): void;
62
+ /** 注册一个 plugin;同名 plugin 会被替换 */
63
+ use(plugin: GestureHostPlugin): void;
64
+ remove(name: string): boolean;
65
+ has(name: string): boolean;
66
+ list(): string[];
67
+ /**
68
+ * 回放一段宿主手势。
69
+ *
70
+ * 这条路径复用真实鼠标事件使用的 snapshot → plugin → receiver 管线,
71
+ * 只是把事件源从 DOM overlay 换成受控输入;调用方不需要知道 iframe、overlay
72
+ * 或坐标缩放细节。
73
+ */
74
+ dispatch(input: GestureDispatchInput): Promise<GestureDispatchResult>;
75
+ /**
76
+ * 由宿主在 iframe.onload + receiver runtime 注入完成后调用。
77
+ * 触发 "iframe:ready" 逻辑事件,需要 receiver 就绪后才能 send 的 plugin
78
+ * (如 `selection-disabler`)可通过 `ctx.hook("iframe:ready", ...)` 监听。
79
+ */
80
+ notifyIframeReady(): void;
81
+ destroy(): void;
82
+ private makeContext;
83
+ private subscribeRaw;
84
+ private subscribeLogic;
85
+ private emitLogic;
86
+ private dispatchRaw;
87
+ private sendToGuest;
88
+ /**
89
+ * 把 host 视口坐标转换为 guest CSS 像素空间。
90
+ * 考虑载体父容器 transform scale,使 guest 内 elementFromPoint / touch.clientX 正确。
91
+ */
92
+ private toIframeCoords;
93
+ private toHostCoords;
94
+ private syntheticMouseEvent;
95
+ private syntheticWheelEvent;
96
+ private modifiersOf;
97
+ private snapshotOf;
98
+ /**
99
+ * 内置手指圆点(TouchCursor)的「模拟器可视区域」判定基准。
100
+ * 用 light DOM 的 shadow host(铺满 deviceStage、无 transform,rect 最稳),
101
+ * 回退 hoverTrackTarget。contentRoot 在 stageFit 缩放 + flex 布局下 rect 可能偏移/塌缩。
102
+ */
103
+ private get hoverRegion();
104
+ private onMouseDown;
105
+ private onMouseMoveDragging;
106
+ private onMouseUp;
107
+ private onWheel;
108
+ private onWindowBlur;
109
+ /** guest 内表单控件 focus 后,把宿主焦点切到载体,键盘输入才能进小应用 */
110
+ private onGuestInbound;
111
+ private bindCapturingWindowMove;
112
+ private unbindCapturingWindowMove;
113
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Gesture 模块 — PC 模拟器手势插件系统。
3
+ *
4
+ * 设计目标:把"宿主鼠标 → iframe 内 touch/click/wheel/contextmenu/dblclick"
5
+ * 全部抽象为可插拔的 GesturePlugin,host 端 + receiver 端协同。
6
+ *
7
+ * 使用:
8
+ * ```ts
9
+ * const bus = new GestureHostBus({ iframe, mountTarget });
10
+ * for (const plugin of createDefaultHostPlugins()) bus.use(plugin);
11
+ * // iframe.onload 后注入 receiver runtime
12
+ * injectGestureReceiver(iframe);
13
+ *
14
+ * // 业务可注册自定义 plugin
15
+ * bus.use({
16
+ * name: "shake-emulator",
17
+ * install(ctx) {
18
+ * ctx.on("down", () => ctx.send({ type: "mini-app:shake" }));
19
+ * },
20
+ * });
21
+ * ```
22
+ */
23
+ export type { GestureBusMessage, GestureDispatchAction, GestureDispatchInput, GestureDispatchResult, GestureGuestChannel, GestureHostContext, GestureHostPlugin, GestureInboundMessage, GesturePoint, GestureSharedState, ModifierKeys, MultiTouchMode, PointerSnapshot, RawEventName, TapMessage, TouchMessage, WheelMessage, } from "./types";
24
+ export { GestureHostBus } from "./host-bus";
25
+ export { TouchDotManager } from "./touch-dot";
26
+ export { RECEIVER_RUNTIME_SOURCE, injectGestureReceiver, } from "./receiver-runtime";
27
+ export * from "./plugins";
@@ -0,0 +1,10 @@
1
+ /**
2
+ * DoubleTapPlugin — 双击手势(300ms 内两次 tap 且位置接近)。
3
+ *
4
+ * 依赖 TapPlugin 的 "tap" 逻辑事件,自己不监听原始指针事件。
5
+ * 触发条件满足时:
6
+ * - send `mini-app:dblclick` 给 receiver(派发原生 dblclick)
7
+ * - emit "dblclick" 逻辑事件供其他 plugin 使用
8
+ */
9
+ import type { GestureHostPlugin } from "../types";
10
+ export declare function createDoubleTapPlugin(): GestureHostPlugin;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * 内置的 host-side gesture plugin 工厂集合。
3
+ *
4
+ * GestureHostBus 默认会安装所有这些 plugin(按以下顺序):
5
+ * 1. multi-touch-switch / pinch / rotate ── 控制 state.multiTouchMode(必须在 touch-emitter 前)
6
+ * 2. touch-emitter ── 派发 touch 事件(读 state 决定单/双指几何)
7
+ * 3. tap ── 短按 → mini-app:tap(receiver 合成 click)
8
+ * 4. long-press ── 长按 → mini-app:longpress(contextmenu)
9
+ * 5. double-tap ── hook tap → mini-app:dblclick
10
+ * 6. wheel-scroll ── 滚轮 → mini-app:wheel
11
+ * 7. selection-disabler ── iframe body user-select: none
12
+ * 8. multi-touch-hint ── 状态条 + 副触点圆点
13
+ *
14
+ * 注:手指圆点(hover/press 指针)已从 plugin 上移为 gesture 核心内置 `TouchCursor`
15
+ * (见 `../touch-cursor.ts`),由 GestureHostBus 直接持有,圆点显示不再走事件管线。
16
+ */
17
+ export { createTouchEmitterPlugin } from "./touch-emitter";
18
+ export { createMultiTouchSwitchPlugin, createPinchPlugin, createRotatePlugin, } from "./multi-touch-switch";
19
+ export { createTapPlugin } from "./tap";
20
+ export { createLongPressPlugin } from "./long-press";
21
+ export { createDoubleTapPlugin } from "./double-tap";
22
+ export { createWheelScrollPlugin } from "./wheel-scroll";
23
+ export { createSelectionDisablerPlugin } from "./selection-disabler";
24
+ export { createMultiTouchHintPlugin } from "./multi-touch-hint";
25
+ import type { GestureHostPlugin } from "../types";
26
+ /** 一次性生成全套内置 plugin(mode-switch 必须在 touch-emitter 之前注册) */
27
+ export declare function createDefaultHostPlugins(): GestureHostPlugin[];
@@ -0,0 +1,13 @@
1
+ /**
2
+ * LongPressPlugin — 长按手势(500ms 未释放 + 移动 ≤10px)。
3
+ *
4
+ * down 时启动定时器,timer 到点时若仍按下且未移动则触发:
5
+ * - send `mini-app:longpress` 给 receiver(派发 contextmenu 事件)
6
+ * - emit "longpress" 逻辑事件
7
+ * - 清空 state.pressStartPoint,使 TapPlugin 在随后的 up 阶段跳过 tap 判定
8
+ * (避免"长按后松手"既触发 contextmenu 又触发 click 的双重反应)
9
+ *
10
+ * up / leave / move 超过阈值都会取消 timer。
11
+ */
12
+ import type { GestureHostPlugin } from "../types";
13
+ export declare function createLongPressPlugin(): GestureHostPlugin;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * MultiTouchHintPlugin — 双指模式可视化提示。
3
+ *
4
+ * 当任意 MultiTouchSwitch/Pinch/Rotate emit "multitouch:enter" 时:
5
+ * - 顶部加状态条,提示当前模式(mirror / pinch / rotate)
6
+ * - 在副触点位置画一个圆点,随鼠标移动
7
+ *
8
+ * leave 时清掉两者。
9
+ */
10
+ import type { GestureHostPlugin } from "../types";
11
+ export declare function createMultiTouchHintPlugin(): GestureHostPlugin;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * MultiTouchSwitchPlugin / PinchPlugin / RotatePlugin —— 双指模式切换工厂。
3
+ *
4
+ * 三者结构一致,区别仅在:检测的修饰键 + 进入时设置的 multiTouchMode。
5
+ * - MultiTouchSwitch: shiftKey → "mirror"
6
+ * - Pinch: altKey → "pinch"
7
+ * - Rotate: ctrlKey → "rotate"
8
+ *
9
+ * 都不直接派发 touch(由 TouchEmitterPlugin 读 state 决定),只控制 state + emit
10
+ * "multitouch:enter" / "multitouch:leave" 逻辑事件供视觉提示 plugin 使用。
11
+ */
12
+ import type { GestureHostPlugin } from "../types";
13
+ /** Shift+拖动 = 镜像双指(经典 hammerjs 风格) */
14
+ export declare function createMultiTouchSwitchPlugin(): GestureHostPlugin;
15
+ /** Alt+拖动 = 捏合双指(真实 pinch,副触点直接对称) */
16
+ export declare function createPinchPlugin(): GestureHostPlugin;
17
+ /** Ctrl+拖动 = 旋转双指(副触点关于 base 旋转 180°) */
18
+ export declare function createRotatePlugin(): GestureHostPlugin;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * SelectionDisablerPlugin — 在 iframe 内禁用文本选中,模拟移动端体感。
3
+ *
4
+ * 移动端 long-press 默认是选中文本,但小程序场景一般不希望出现选中蓝条。
5
+ * 本 plugin 在 iframe ready 时 send `mini-app:selection` { enabled: false },
6
+ * receiver 注入 body { user-select: none }。
7
+ *
8
+ * 可通过 `simulator.gesture.remove("selection-disabler")` 关闭,恢复文本选中。
9
+ */
10
+ import type { GestureHostPlugin } from "../types";
11
+ export declare function createSelectionDisablerPlugin(): GestureHostPlugin;