@skillbuilder/miniapp-simulator 0.2.4 → 0.2.8

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 (54) hide show
  1. package/README.md +18 -1
  2. package/docs/assets/road-king-controls.png +0 -0
  3. package/docs/audit-data-collection.codex.md +76 -393
  4. package/docs/audit-local-validation.codex.md +1 -1
  5. package/docs/audit-score-design.codex.md +23 -22
  6. package/docs/audit-score-design.md +39 -92
  7. package/docs/audit-score-tech-plan.md +6 -4
  8. package/docs/audit-tech-design.codex.md +36 -19
  9. package/docs/desktop-gesture-design.redoc.xml +96 -0
  10. package/docs/electron-review.md +1 -1
  11. package/docs/quality-evaluation-redoc.xml +4 -4
  12. package/docs/tracker.md +3 -2
  13. package/lib/client-C59iNO5u.mjs +1371 -0
  14. package/lib/{index-7MeYFlk_.mjs → index-BSj1bmle.mjs} +158 -140
  15. package/lib/index.js +4484 -3027
  16. package/lib/remote-client.js +2 -2
  17. package/lib/types/core/simulator.d.ts +2 -0
  18. package/lib/types/gesture/host-bus.d.ts +27 -2
  19. package/lib/types/gesture/input-scheduler.d.ts +29 -0
  20. package/lib/types/gesture/keyboard-panel-view.d.ts +16 -0
  21. package/lib/types/gesture/keyboard-panel.d.ts +54 -0
  22. package/lib/types/gesture/plugins/index.d.ts +11 -14
  23. package/lib/types/gesture/plugins/keyboard-touch.d.ts +4 -0
  24. package/lib/types/gesture/plugins/multi-touch-hint.d.ts +1 -9
  25. package/lib/types/gesture/plugins/multi-touch-switch.d.ts +1 -1
  26. package/lib/types/gesture/plugins/touch-emitter.d.ts +1 -9
  27. package/lib/types/gesture/plugins/wheel-pinch.d.ts +3 -0
  28. package/lib/types/gesture/plugins/wheel-scroll.d.ts +1 -1
  29. package/lib/types/gesture/touch-cursor.d.ts +4 -0
  30. package/lib/types/gesture/touch-sequence.d.ts +12 -0
  31. package/lib/types/gesture/types.d.ts +33 -9
  32. package/lib/types/host/shadow-host.d.ts +15 -5
  33. package/lib/types/inspector/host-inspector.d.ts +1 -1
  34. package/lib/types/remote/audit-controller.d.ts +7 -0
  35. package/lib/types/remote/audit-leave-monitor.d.ts +2 -0
  36. package/lib/types/remote/audit-package-sources.d.ts +9 -0
  37. package/lib/types/remote/audit-telemetry.d.ts +25 -12
  38. package/lib/types/remote/client.d.ts +2 -0
  39. package/lib/types/remote/keyboard-panel-host.d.ts +19 -0
  40. package/lib/types/remote/protocol.d.ts +38 -4
  41. package/lib/types/remote/runtime-entry.d.ts +2 -1
  42. package/lib/types/remote/runtime.d.ts +1 -1
  43. package/lib/types/runtime/jsapi-modules/interaction.d.ts +1 -1
  44. package/lib/types/runtime/jsapi-modules/local-media.d.ts +4 -0
  45. package/lib/types/runtime/jsapi-modules/media.d.ts +1 -1
  46. package/lib/types/runtime/jsapi-modules/note-publish-media.d.ts +9 -0
  47. package/lib/types/tracker/constants.d.ts +1 -1
  48. package/lib/types/tracker/default-tracker.d.ts +1 -1
  49. package/lib/types/types/options.d.ts +6 -2
  50. package/lib/types/types/renderer.d.ts +8 -0
  51. package/lib/types/utils/screen-coordinates.d.ts +31 -0
  52. package/lib/workbench.js +1 -1
  53. package/package.json +1 -1
  54. package/lib/client-BDt3WDu_.mjs +0 -1118
@@ -1,4 +1,5 @@
1
1
  import type { BusinessLine } from "../business-line";
2
+ import type { KeyboardPanelCommand, KeyboardPanelState } from "../gesture/keyboard-panel";
2
3
  import type { ManagedRequestChunk, ManagedRequestHeaders, ManagedRequestOptions, ManagedRequestResult } from "../runtime/request/request-types";
3
4
  import type { MiniAppContentMode, MiniAppFileMap, MiniAppHostApiRequest, MiniAppInspectorSelectionMode, MiniAppLoadFilesOptions, MiniAppLoadZipOptions, MiniAppRedirectOptions, MiniAppSecurityOptions, MiniAppSimulatorOptions, MiniAppSimulatorRoute, MiniAppViewport } from "../types";
4
5
  /**
@@ -14,6 +15,8 @@ export declare const REMOTE_INSPECTOR_PAUSE_RUNTIME_CAPABILITY = "inspectorPause
14
15
  * 版本不一致会让老 runtime 直接握手失败,而评测是可选能力,缺失只应降级。
15
16
  */
16
17
  export declare const REMOTE_AUDIT_CAPABILITY = "audit";
18
+ /** Client 可在外层页面承载 Runtime 的键位编辑浮窗。 */
19
+ export declare const REMOTE_KEYBOARD_PANEL_CAPABILITY = "keyboardPanelPortal";
17
20
  export declare const REMOTE_SIMULATOR_CAPABILITIES: string[];
18
21
  export type RemoteSimulatorSerializableOptions = Omit<MiniAppSimulatorOptions, "mount" | "appId" | "renderer" | "serviceWorker" | "security" | "jsapi" | "hostApi" | "tracker" | "runtimeLimits" | "onEvent" | "onReady" | "onBeforeLoad" | "onLoad" | "onRenderDone" | "onError" | "onNavigation" | "onConsole" | "onNetwork" | "onDestroy" | "onRouterChange" | "onScreenShot"> & {
19
22
  appUrl?: string;
@@ -39,6 +42,7 @@ export interface RemoteSimulatorConnectMessage {
39
42
  hostApiStubs: Record<string, {
40
43
  toast: string;
41
44
  }>;
45
+ clientCapabilities?: string[];
42
46
  options: RemoteSimulatorSerializableOptions;
43
47
  }
44
48
  /** Mars 队列项提供的稳定业务标识;随评测点位进入 APM,不进入被测 guest。 */
@@ -50,7 +54,7 @@ export interface RemoteAuditContext {
50
54
  }
51
55
  /** Runtime 发给宿主的内部评测点位;只允许扁平标量字段。 */
52
56
  export interface RemoteAuditTelemetryPayload {
53
- name: "miniapp_audit_session" | "miniapp_audit_sample" | "miniapp_audit_paint" | "miniapp_audit_incident" | "miniapp_audit_package" | "miniapp_audit_result";
57
+ name: "miniapp_audit_session" | "miniapp_audit_paint" | "miniapp_audit_incident" | "miniapp_audit_package" | "miniapp_audit_result";
54
58
  sessionId: string;
55
59
  fields: Record<string, string | number | null | undefined>;
56
60
  flush?: boolean;
@@ -60,6 +64,8 @@ export interface RemoteSimulatorReadyMessage {
60
64
  protocolVersion: number;
61
65
  runtimeVersion: string;
62
66
  capabilities: string[];
67
+ /** 当前 Runtime entry 自身的模块地址,供外层页面复用同一资源。 */
68
+ runtimeModuleUrl?: string;
63
69
  }
64
70
  export interface RemoteSimulatorRequestMessage {
65
71
  type: "request";
@@ -82,6 +88,23 @@ export interface RemoteSimulatorEventMessage {
82
88
  event: string;
83
89
  payload: unknown;
84
90
  }
91
+ export interface RemoteKeyboardPanelStateMessage {
92
+ type: "keyboard-panel-state";
93
+ controllerId: string;
94
+ revision: number;
95
+ /** null 显式销毁该控制器的浮窗;后续状态不能复活它。 */
96
+ state: KeyboardPanelState | null;
97
+ }
98
+ export interface RemoteKeyboardPanelCommandMessage {
99
+ type: "keyboard-panel-command";
100
+ controllerId: string;
101
+ command: KeyboardPanelCommand;
102
+ }
103
+ export interface RemoteKeyboardPanelPresenceMessage {
104
+ type: "keyboard-panel-presence";
105
+ controllerId: string;
106
+ active: boolean;
107
+ }
85
108
  /** Runtime 请求宿主执行不可序列化的 hostApi handler。 */
86
109
  export interface RemoteHostApiRequestMessage {
87
110
  type: "host-api-request";
@@ -132,7 +155,7 @@ export interface RemoteHostRequestEventMessage {
132
155
  export type RemoteSimulatorPortMessage = {
133
156
  type: "worker-visibility";
134
157
  visible: boolean;
135
- } | RemoteSimulatorReadyMessage | RemoteSimulatorRequestMessage | RemoteSimulatorResponseMessage | RemoteSimulatorEventMessage | RemoteHostApiRequestMessage | RemoteHostApiResponseMessage | RemoteHostRequestMessage | RemoteHostRequestResponseMessage | RemoteHostRequestAbortMessage | RemoteHostRequestEventMessage;
158
+ } | RemoteKeyboardPanelStateMessage | RemoteKeyboardPanelCommandMessage | RemoteKeyboardPanelPresenceMessage | RemoteSimulatorReadyMessage | RemoteSimulatorRequestMessage | RemoteSimulatorResponseMessage | RemoteSimulatorEventMessage | RemoteHostApiRequestMessage | RemoteHostApiResponseMessage | RemoteHostRequestMessage | RemoteHostRequestResponseMessage | RemoteHostRequestAbortMessage | RemoteHostRequestEventMessage;
136
159
  export type RemoteSimulatorMethod = "load" | "loadZip" | "loadFiles" | "loadApp" | "unload" | "reload" | "setViewport" | "switchContentMode" | "switchPhoneFrame" | "switchDevice" | "setTouchEmulation" | "permissionSheet.show" | "permissionSheet.hide" | "notePreview.update" | "notePreview.updateUser" | "notePreview.updateAppCard" | "widgetCover.update" | "router.redirectTo" | "router.getRoute" | "inspector.enable" | "inspector.disable" | "inspector.toggle" | "inspector.clear" | "inspector.setSelectionMode" | "inspector.getSelectionMode" | "inspector.getSceneTree" | "inspector.selectByRef" | "capture" | "screenShot" | "setAutoScreenShot" | "hostApi.sync" | "hostApi.emit" | "audit.start" | "audit.stop" | "audit.status" | "audit.report" | "audit.setPolicy" | "destroy";
137
160
  export interface RemoteLoadZipArgs {
138
161
  buffer: ArrayBuffer;
@@ -196,7 +219,7 @@ export interface RemoteAuditStartArgs {
196
219
  */
197
220
  durationMs?: number;
198
221
  armingMs?: number;
199
- declaredAppType?: "tool" | "game2d" | "game3d" | "video";
222
+ declaredAppType?: "tool" | "game2d" | "game3d";
200
223
  }
201
224
  /**
202
225
  * 评测报告的跨 iframe 序列化契约。
@@ -274,8 +297,19 @@ export interface RemoteAuditReport {
274
297
  interactionCount: number;
275
298
  firstInteractionAt?: number;
276
299
  };
277
- appType: "tool" | "game2d" | "game3d" | "video";
300
+ appType: "tool" | "game2d" | "game3d";
278
301
  tagMismatch: boolean;
302
+ classification?: {
303
+ engine?: string;
304
+ evidence: string[];
305
+ inferred: boolean;
306
+ frameworks?: Array<{
307
+ id: string;
308
+ confidence: "strong" | "candidate";
309
+ evidence: string[];
310
+ }>;
311
+ sourceScanComplete?: boolean;
312
+ };
279
313
  versions: {
280
314
  policyVersion: string;
281
315
  rulesVersion: string;
@@ -1 +1,2 @@
1
- export {};
1
+ export { keyboardPanelCommandNeedsGameFocus } from "../gesture/keyboard-panel";
2
+ export { createKeyboardPanelView } from "../gesture/keyboard-panel-view";
@@ -13,4 +13,4 @@ export interface RemoteRuntimeConfig {
13
13
  /** 与本 Runtime release 绑定的独立评测插件;仅 Mars 审核会话动态加载。 */
14
14
  auditPluginUrl?: string;
15
15
  }
16
- export declare function startRemoteMiniAppSimulatorRuntime(): void;
16
+ export declare function startRemoteMiniAppSimulatorRuntime(runtimeModuleUrl: string): void;
@@ -1,4 +1,4 @@
1
1
  import type { SimulatorJsapiContext } from "./context";
2
2
  import type { SimulatorJsapiModule } from "./types";
3
- export type InteractionJsapiModuleContext = Pick<SimulatorJsapiContext, "overlayRoot" | "showNotePublish" | "vibrate">;
3
+ export type InteractionJsapiModuleContext = Pick<SimulatorJsapiContext, "overlayRoot" | "showNotePublish" | "vibrate" | "loadedUrl" | "fileSystemHost" | "fileSystemMountId" | "appId">;
4
4
  export declare function createInteractionJsapiModule(context: InteractionJsapiModuleContext): SimulatorJsapiModule;
@@ -0,0 +1,4 @@
1
+ import { type SimulatorFileSystemContext } from "./filesystem";
2
+ export declare const SIMULATOR_FILE_MARKER = "/_xhsfile_/";
3
+ /** Read virtual media through its app-scoped bridge, including outside the SW scope. */
4
+ export declare function readSimulatorMediaBlob(context: SimulatorFileSystemContext, source: string): Promise<Blob>;
@@ -1,5 +1,5 @@
1
1
  import { type MiniAppHostApiHandler } from "../../types";
2
- import { type SimulatorFileSystemContext } from "./filesystem";
2
+ import type { SimulatorFileSystemContext } from "./filesystem";
3
3
  import type { SimulatorJsapiModule } from "./types";
4
4
  /** The simulator state used by browser media APIs. */
5
5
  export interface MediaJsapiModuleContext extends SimulatorFileSystemContext {
@@ -0,0 +1,9 @@
1
+ import type { NotePublishViewData } from "../../native-ui/note-publish";
2
+ import type { SimulatorFileSystemContext } from "./filesystem";
3
+ /** Object URLs belong to one preview and are released when it settles or fails to prepare. */
4
+ export declare function createNotePublishMediaResolver(context: SimulatorFileSystemContext & {
5
+ readonly loadedUrl: string;
6
+ }): {
7
+ prepare(data: NotePublishViewData): Promise<NotePublishViewData>;
8
+ dispose(): void;
9
+ };
@@ -8,7 +8,7 @@ export declare const APM_ENDPOINT: Record<MiniAppApmRegion, {
8
8
  production: string;
9
9
  development: string;
10
10
  }>;
11
- /** 批量上报:缓冲达到此条数立即发送 */
11
+ /** 批量上报:单次请求最多此条数;缓冲达到此条数触发发送。 */
12
12
  export declare const APM_BATCH_MAX = 10;
13
13
  /** 批量上报:缓冲未满时最多等待此毫秒后发送 */
14
14
  export declare const APM_BATCH_FLUSH_MS = 10000;
@@ -2,7 +2,7 @@ import type { MiniAppApmRegion, MiniAppTrackerEvent } from "../types";
2
2
  /** 默认 Tracker 的上报方法集合 */
3
3
  export interface DefaultTracker {
4
4
  sendCustomPoint(event: MiniAppTrackerEvent): void;
5
- /** 立即发送缓冲中的所有打点 */
5
+ /** 将缓冲中的所有打点加入发送队列 */
6
6
  flush(): void;
7
7
  }
8
8
  export interface DefaultTrackerDeliveryResult {
@@ -487,6 +487,9 @@ export interface MiniAppSimulatorOptions extends MiniAppLifecycleCallbacks {
487
487
  debug?: boolean;
488
488
  /** 开启鼠标→触摸事件模拟,使桌面端鼠标操作还原真机 touch 行为(显示小手光标与触点圆点) */
489
489
  touchEmulation?: boolean;
490
+ /** 桌面审核操作面板(区域键位映射与屏幕旋转),默认关闭;Mars Runtime 自动启用。
491
+ * 启用时默认开启 touchEmulation;显式关闭 touchEmulation 时面板一并关闭。 */
492
+ desktopControls?: boolean;
490
493
  /** Visual Inspector 运行时能力;游戏暂停代理默认关闭。 */
491
494
  visualInspector?: MiniAppVisualInspectorOptions;
492
495
  /** 在父级 bounds 内自适应缩放;默认开启,可传 `false` 关闭或 `{ resizeHandle: true }` 启用手动拖拽缩放 */
@@ -548,6 +551,7 @@ export interface NormalizedMiniAppSimulatorOptions extends Omit<MiniAppSimulator
548
551
  timeout: number;
549
552
  debug: boolean;
550
553
  touchEmulation: boolean;
554
+ desktopControls: boolean;
551
555
  visualInspector: NormalizedMiniAppVisualInspectorOptions;
552
556
  stageFit: false | NormalizedMiniAppStageFitOptions;
553
557
  jsapi: NormalizedMiniAppJsApiOptions;
@@ -803,8 +807,8 @@ export interface MiniAppSimulator {
803
807
  * 返回 false 表示当前不是 SW 直供状态。
804
808
  */
805
809
  refreshInjection(): Promise<boolean>;
806
- /** 打开与设备画布并排的侧栏,返回可挂载内容的容器。 */
807
- openSidePanel(width: number): HTMLElement;
810
+ /** 打开与设备画布并排的侧栏;宽度在 width 与 maxWidth 之间自适应。 */
811
+ openSidePanel(width: number, maxWidth?: number): HTMLElement;
808
812
  /** 收起侧栏并清空其内容。 */
809
813
  closeSidePanel(): void;
810
814
  /** 整块模拟器的交互区域(设备、侧栏及内部留白),用于边界监听。 */
@@ -1,3 +1,5 @@
1
+ import type { ScreenRotationDirection } from "../utils/screen-coordinates";
2
+ import type { KeyboardPanelHost } from "../gesture/keyboard-panel";
1
3
  import type { InjectionRegistry } from "../injection/registry";
2
4
  import type { NotePublishResult, NotePublishViewData } from "../native-ui/note-publish/view-data";
3
5
  import type { MiniAppPermissionKind, MiniAppPermissionSheetResult } from "../native-ui/permission-sheet/types";
@@ -99,6 +101,12 @@ export interface RendererAdapterContext {
99
101
  debug: boolean;
100
102
  /** 是否启用鼠标→触摸事件模拟 */
101
103
  touchEmulation?: boolean;
104
+ /** 显示桌面审核操作面板。 */
105
+ desktopControls?: boolean;
106
+ /** Remote Client 承载键位浮窗的内部通道。 */
107
+ keyboardPanelHost?: KeyboardPanelHost;
108
+ /** 整台设备 CSS 按指定方向旋转 90 度,保持 guest 逻辑视口尺寸。 */
109
+ rotateScreen?: (direction: ScreenRotationDirection) => void;
102
110
  /** jsapi 注入与 mock 配置 */
103
111
  jsapi: NormalizedMiniAppJsApiOptions;
104
112
  contentMode: MiniAppContentMode;
@@ -0,0 +1,31 @@
1
+ export type ScreenRotationDirection = "clockwise" | "counterclockwise";
2
+ export type ScreenRotation = 0 | -90 | -180 | -270;
3
+ /** 设备 CSS 旋转只改变显示方向,载体的 offset 尺寸始终属于 guest 逻辑视口。 */
4
+ export declare function getScreenRotation(element: Element): ScreenRotation;
5
+ /** host client 坐标 → guest / 元素局部 CSS 像素;保留屏幕外拖拽坐标。 */
6
+ export declare function hostToLocal(element: HTMLElement, hostX: number, hostY: number): {
7
+ x: number;
8
+ y: number;
9
+ };
10
+ /** guest / 元素局部 CSS 像素 → host client 坐标。 */
11
+ export declare function localToHost(element: HTMLElement, x: number, y: number): {
12
+ x: number;
13
+ y: number;
14
+ };
15
+ /** host 向量 → guest 向量;行/页单位传 false,只转换方向、不缩放。 */
16
+ export declare function hostVectorToLocal(element: HTMLElement, dx: number, dy: number, scaleToPixels?: boolean): {
17
+ x: number;
18
+ y: number;
19
+ };
20
+ /** 局部矩形在 host client 空间的轴对齐包围盒。 */
21
+ export declare function localRectToHost(element: HTMLElement, rect: {
22
+ x: number;
23
+ y: number;
24
+ width: number;
25
+ height: number;
26
+ }): {
27
+ x: number;
28
+ y: number;
29
+ width: number;
30
+ height: number;
31
+ };
package/lib/workbench.js CHANGED
@@ -1,4 +1,4 @@
1
- import { c as Mn } from "./client-BDt3WDu_.mjs";
1
+ import { c as Mn } from "./client-C59iNO5u.mjs";
2
2
  function Sn(a, i) {
3
3
  const e = /* @__PURE__ */ new Map();
4
4
  let v = 0, l = !1, w, b, L, m, u;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skillbuilder/miniapp-simulator",
3
- "version": "0.2.4",
3
+ "version": "0.2.8",
4
4
  "description": "Designable Miniapp Simulator - 技术栈无关的小应用 PC 预览与审核模拟器 SDK",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.js",