@skillbuilder/miniapp-simulator 0.0.0-stage → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +263 -2
- package/assets/phones/Nexus-5X.png +0 -0
- package/assets/phones/iPhone-14ProMax.png +0 -0
- package/assets/rednote-preview/cover/homebar-1439.jpg +0 -0
- package/assets/rednote-preview/cover/homebar-1679.jpg +0 -0
- package/assets/rednote-preview/cover/homebar-1919.jpg +0 -0
- package/assets/rednote-preview/cover/homebar-2284.jpg +0 -0
- package/assets/rednote-preview/cover/homebar-2285.jpg +0 -0
- package/assets/rednote-preview/cover/like.png +0 -0
- package/assets/rednote-preview/cover/play.png +0 -0
- package/assets/rednote-preview/cover/topbar-1439.jpg +0 -0
- package/assets/rednote-preview/cover/topbar-1679.jpg +0 -0
- package/assets/rednote-preview/cover/topbar-1919.jpg +0 -0
- package/assets/rednote-preview/cover/topbar-2284.jpg +0 -0
- package/assets/rednote-preview/cover/topbar-2285.jpg +0 -0
- package/assets/workbench/index.html +77 -0
- package/dist/sw/miniapp-simulator-service-worker.js +971 -0
- package/dist/sw/miniapp-simulator-service-worker.min.js +1 -0
- package/docs/consumer-guide.md +143 -0
- package/docs/electron-review.md +21 -0
- package/docs/external-cli-workbench.md +195 -0
- package/docs/file-system-design.md +334 -0
- package/docs/host-external-api.md +235 -0
- package/docs/iframe-service-worker.md +190 -0
- package/docs/local-dev.md +106 -0
- package/docs/npm-integration-verification.md +35 -0
- package/docs/remote-architecture.md +408 -0
- package/docs/remote-load-observability.md +268 -0
- package/docs/remote-usage.md +376 -0
- package/docs/request-design.md +247 -0
- package/docs/sdk-usage.md +260 -0
- package/docs/server-playground-https-debugging.md +150 -0
- package/docs/storage-api-design.md +275 -0
- package/docs/tracker.md +339 -0
- package/docs/worker-runtime.md +62 -0
- package/lib/client-BlQ9j4FW.mjs +775 -0
- package/lib/index-DI2oETZ_.mjs +574 -0
- package/lib/index.js +10831 -0
- package/lib/options-B34ipLmF.mjs +15 -0
- package/lib/preload/webview-preload.js +37 -0
- package/lib/remote-client.js +11 -0
- package/lib/types/business-line.d.ts +7 -0
- package/lib/types/capabilities/constants.d.ts +29 -0
- package/lib/types/capabilities/csp-snippet.d.ts +34 -0
- package/lib/types/capabilities/launch-options.d.ts +7 -0
- package/lib/types/capabilities/performance-policy.d.ts +5 -0
- package/lib/types/capabilities/security-head-snippet.d.ts +21 -0
- package/lib/types/capabilities/security.d.ts +25 -0
- package/lib/types/capabilities/style-snippet.d.ts +2 -0
- package/lib/types/core/controllers/game-playtest.d.ts +9 -0
- package/lib/types/core/controllers/gesture.d.ts +8 -0
- package/lib/types/core/controllers/host-api.d.ts +19 -0
- package/lib/types/core/controllers/index.d.ts +11 -0
- package/lib/types/core/controllers/inspector.d.ts +20 -0
- package/lib/types/core/controllers/note-preview.d.ts +9 -0
- package/lib/types/core/controllers/permission-sheet.d.ts +7 -0
- package/lib/types/core/controllers/widget-cover.d.ts +12 -0
- package/lib/types/core/lifecycle.d.ts +7 -0
- package/lib/types/core/options.d.ts +33 -0
- package/lib/types/core/simulator.d.ts +9 -0
- package/lib/types/errors.d.ts +11 -0
- package/lib/types/event-bus.d.ts +15 -0
- package/lib/types/gesture/host-bus.d.ts +113 -0
- package/lib/types/gesture/index.d.ts +27 -0
- package/lib/types/gesture/plugins/double-tap.d.ts +10 -0
- package/lib/types/gesture/plugins/index.d.ts +27 -0
- package/lib/types/gesture/plugins/long-press.d.ts +13 -0
- package/lib/types/gesture/plugins/multi-touch-hint.d.ts +11 -0
- package/lib/types/gesture/plugins/multi-touch-switch.d.ts +18 -0
- package/lib/types/gesture/plugins/selection-disabler.d.ts +11 -0
- package/lib/types/gesture/plugins/tap.d.ts +11 -0
- package/lib/types/gesture/plugins/touch-emitter.d.ts +11 -0
- package/lib/types/gesture/plugins/wheel-scroll.d.ts +11 -0
- package/lib/types/gesture/receiver-runtime.d.ts +10 -0
- package/lib/types/gesture/receiver-runtime.impl.d.ts +6 -0
- package/lib/types/gesture/touch-cursor.d.ts +78 -0
- package/lib/types/gesture/touch-dot.d.ts +12 -0
- package/lib/types/gesture/types.d.ts +206 -0
- package/lib/types/host/shadow-host.d.ts +40 -0
- package/lib/types/index.d.ts +56 -0
- package/lib/types/injection/guest-log-mark.d.ts +7 -0
- package/lib/types/injection/head-builder.d.ts +4 -0
- package/lib/types/injection/index.d.ts +19 -0
- package/lib/types/injection/modules/console-forward.d.ts +2 -0
- package/lib/types/injection/modules/gesture.d.ts +6 -0
- package/lib/types/injection/modules/inspector-guest-runtime.d.ts +5 -0
- package/lib/types/injection/modules/inspector-pause-runtime.d.ts +6 -0
- package/lib/types/injection/modules/inspector.d.ts +8 -0
- package/lib/types/injection/modules/jsapi-channel.d.ts +9 -0
- package/lib/types/injection/modules/jsapi.d.ts +22 -0
- package/lib/types/injection/modules/render-done.d.ts +2 -0
- package/lib/types/injection/modules/resource-guard.d.ts +7 -0
- package/lib/types/injection/modules/scroll-containment.d.ts +3 -0
- package/lib/types/injection/modules/security.d.ts +3 -0
- package/lib/types/injection/modules/widget-snapshot.d.ts +13 -0
- package/lib/types/injection/preload-builder.d.ts +41 -0
- package/lib/types/injection/registry.d.ts +20 -0
- package/lib/types/injection/types.d.ts +45 -0
- package/lib/types/inspector/host-inspector.d.ts +108 -0
- package/lib/types/inspector/index.d.ts +8 -0
- package/lib/types/inspector/selector.d.ts +18 -0
- package/lib/types/native-ui/devtools/CapabilitiesView.d.ts +18 -0
- package/lib/types/native-ui/devtools/DevtoolsPanel.d.ts +24 -0
- package/lib/types/native-ui/devtools/LogsView.d.ts +17 -0
- package/lib/types/native-ui/devtools/dom.d.ts +40 -0
- package/lib/types/native-ui/devtools/index.d.ts +19 -0
- package/lib/types/native-ui/devtools/log-entry.d.ts +8 -0
- package/lib/types/native-ui/devtools/shortcut.d.ts +12 -0
- package/lib/types/native-ui/devtools/tokens.d.ts +14 -0
- package/lib/types/native-ui/devtools/types.d.ts +51 -0
- package/lib/types/native-ui/index.d.ts +17 -0
- package/lib/types/native-ui/note-publish/defaults.d.ts +40 -0
- package/lib/types/native-ui/note-publish/index.d.ts +2 -0
- package/lib/types/native-ui/note-publish/miniapp-note-publish.d.ts +15 -0
- package/lib/types/native-ui/note-publish/note-publish-host.d.ts +15 -0
- package/lib/types/native-ui/note-publish/view-data.d.ts +21 -0
- package/lib/types/native-ui/permission-sheet/defaults.d.ts +12 -0
- package/lib/types/native-ui/permission-sheet/index.d.ts +4 -0
- package/lib/types/native-ui/permission-sheet/miniapp-permission-sheet.d.ts +19 -0
- package/lib/types/native-ui/permission-sheet/permission-sheet-host.d.ts +23 -0
- package/lib/types/native-ui/permission-sheet/types.d.ts +8 -0
- package/lib/types/native-ui/phone-vibration.d.ts +10 -0
- package/lib/types/native-ui/rednote-preview/chrome-tone.d.ts +44 -0
- package/lib/types/native-ui/rednote-preview/defaults.d.ts +30 -0
- package/lib/types/native-ui/rednote-preview/half-sheet-drag.d.ts +61 -0
- package/lib/types/native-ui/rednote-preview/index.d.ts +2 -0
- package/lib/types/native-ui/rednote-preview/register.d.ts +7 -0
- package/lib/types/native-ui/rednote-preview/styles.d.ts +4 -0
- package/lib/types/native-ui/rednote-preview/xhs-note-detail-shell.d.ts +70 -0
- package/lib/types/native-ui/rednote-preview/xhs-note-half-sheet.d.ts +100 -0
- package/lib/types/native-ui/rednote-preview/xhs-profile-shell.d.ts +31 -0
- package/lib/types/native-ui/toast/frame-toast-host.d.ts +18 -0
- package/lib/types/native-ui/toast/index.d.ts +19 -0
- package/lib/types/presets.d.ts +11 -0
- package/lib/types/remote/client.d.ts +89 -0
- package/lib/types/remote/jsapi-config.d.ts +9 -0
- package/lib/types/remote/load-timing.d.ts +46 -0
- package/lib/types/remote/protocol.d.ts +165 -0
- package/lib/types/remote/review-launch.d.ts +6 -0
- package/lib/types/remote/runtime-entry.d.ts +1 -0
- package/lib/types/remote/runtime.d.ts +14 -0
- package/lib/types/remote/simulator-prompt.d.ts +9 -0
- package/lib/types/remote/widget-snapshot-guest-runtime.d.ts +1 -0
- package/lib/types/remote-client.d.ts +5 -0
- package/lib/types/renderer/base.d.ts +8 -0
- package/lib/types/renderer/content-host/iframe-content-host.d.ts +84 -0
- package/lib/types/renderer/content-host/index.d.ts +3 -0
- package/lib/types/renderer/content-host/types.d.ts +89 -0
- package/lib/types/renderer/content-host/webview-content-host.d.ts +53 -0
- package/lib/types/renderer/iframe.d.ts +93 -0
- package/lib/types/renderer/index.d.ts +2 -0
- package/lib/types/renderer/rednote-shell.d.ts +73 -0
- package/lib/types/renderer/webview.d.ts +59 -0
- package/lib/types/runtime/context.d.ts +31 -0
- package/lib/types/runtime/jsapi-alert.d.ts +3 -0
- package/lib/types/runtime/jsapi-modules/context.d.ts +21 -0
- package/lib/types/runtime/jsapi-modules/filesystem.d.ts +19 -0
- package/lib/types/runtime/jsapi-modules/index.d.ts +9 -0
- package/lib/types/runtime/jsapi-modules/interaction.d.ts +4 -0
- package/lib/types/runtime/jsapi-modules/location.d.ts +3 -0
- package/lib/types/runtime/jsapi-modules/media.d.ts +13 -0
- package/lib/types/runtime/jsapi-modules/network.d.ts +3 -0
- package/lib/types/runtime/jsapi-modules/storage.d.ts +26 -0
- package/lib/types/runtime/jsapi-modules/system.d.ts +4 -0
- package/lib/types/runtime/jsapi-modules/types.d.ts +21 -0
- package/lib/types/runtime/jsapi-modules/window-info.d.ts +43 -0
- package/lib/types/runtime/request/host-request.d.ts +13 -0
- package/lib/types/runtime/request/request-manager-frame.d.ts +29 -0
- package/lib/types/runtime/request/request-runtime.d.ts +26 -0
- package/lib/types/runtime/request/request-types.d.ts +26 -0
- package/lib/types/runtime/request/sse-text-framer.d.ts +16 -0
- package/lib/types/seal-config.d.ts +134 -0
- package/lib/types/sw/index.d.ts +9 -0
- package/lib/types/sw/parse-raw.d.ts +34 -0
- package/lib/types/sw/protocol.d.ts +19 -0
- package/lib/types/sw/served-entry.d.ts +9 -0
- package/lib/types/sw/service-worker-content-host.d.ts +11 -0
- package/lib/types/sw/service-worker-host.d.ts +74 -0
- package/lib/types/sw/service-worker-renderer.d.ts +10 -0
- package/lib/types/sw/worker/fs-codec.d.ts +23 -0
- package/lib/types/sw/worker/fs-ops.d.ts +22 -0
- package/lib/types/sw/worker/fs-store.d.ts +29 -0
- package/lib/types/sw/worker/globals.d.ts +50 -0
- package/lib/types/sw/worker/main.d.ts +6 -0
- package/lib/types/sw/worker/mime.d.ts +2 -0
- package/lib/types/sw/worker/mount-store.d.ts +48 -0
- package/lib/types/sw/worker/paths.d.ts +4 -0
- package/lib/types/sw/worker/serve.d.ts +13 -0
- package/lib/types/tracker/constants.d.ts +14 -0
- package/lib/types/tracker/default-tracker.d.ts +19 -0
- package/lib/types/tracker/index.d.ts +70 -0
- package/lib/types/transport/bridge-protocol.d.ts +78 -0
- package/lib/types/transport/iframe-transport.d.ts +39 -0
- package/lib/types/transport/index.d.ts +14 -0
- package/lib/types/transport/jsapi-bridge-messages.d.ts +36 -0
- package/lib/types/transport/types.d.ts +48 -0
- package/lib/types/transport/webview-transport.d.ts +52 -0
- package/lib/types/types/events.d.ts +130 -0
- package/lib/types/types/index.d.ts +11 -0
- package/lib/types/types/inspector.d.ts +172 -0
- package/lib/types/types/jsapi.d.ts +18 -0
- package/lib/types/types/options.d.ts +851 -0
- package/lib/types/types/renderer.d.ts +145 -0
- package/lib/types/utils/ancestor-scroll.d.ts +11 -0
- package/lib/types/utils/error-svg.d.ts +12 -0
- package/lib/types/utils/frameless-shell.d.ts +114 -0
- package/lib/types/utils/miniapp-chrome-svg.d.ts +47 -0
- package/lib/types/utils/package-constants.d.ts +8 -0
- package/lib/types/utils/screenshot.d.ts +14 -0
- package/lib/types/utils/simulator-pc-guard.d.ts +10 -0
- package/lib/types/utils/stage-fit.d.ts +6 -0
- package/lib/types/utils/touch-emulate.d.ts +26 -0
- package/lib/types/utils/zip-entry.d.ts +13 -0
- package/lib/types/workbench/index.d.ts +63 -0
- package/lib/types/workbench/preview-transition.d.ts +8 -0
- package/lib/types/workbench/server/artifact.d.ts +8 -0
- package/lib/types/workbench/server/index.d.ts +19 -0
- package/lib/types/workbench/server/watch.d.ts +6 -0
- package/lib/types/workbench/view.d.ts +36 -0
- package/lib/types/worker/adapters/csp-policy.d.ts +7 -0
- package/lib/types/worker/adapters/host-lifecycle.d.ts +5 -0
- package/lib/types/worker/adapters/mount-recovery.d.ts +2 -0
- package/lib/types/worker/adapters/package-policy.d.ts +12 -0
- package/lib/types/worker/adapters/page-lifecycle.d.ts +1 -0
- package/lib/types/worker/adapters/protocol.d.ts +49 -0
- package/lib/types/worker/adapters/scripts.d.ts +2 -0
- package/lib/types/worker/adapters/service-worker.d.ts +2 -0
- package/lib/workbench-server.mjs +183 -0
- package/lib/workbench.js +1404 -0
- package/package.json +61 -4
- package/scripts/mock-cli-dev.mjs +52 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import type { BusinessLine } from "../business-line";
|
|
2
|
+
import type { ManagedRequestChunk, ManagedRequestHeaders, ManagedRequestOptions, ManagedRequestResult } from "../runtime/request/request-types";
|
|
3
|
+
import type { MiniAppContentMode, MiniAppFileMap, MiniAppHostApiRequest, MiniAppInspectorSelectionMode, MiniAppLoadFilesOptions, MiniAppLoadZipOptions, MiniAppRedirectOptions, MiniAppSecurityOptions, MiniAppSimulatorOptions, MiniAppSimulatorRoute, MiniAppViewport } from "../types";
|
|
4
|
+
/**
|
|
5
|
+
* 远程模拟器通信协议版本。单一来源是同目录的 protocol-version.json,
|
|
6
|
+
* 发布脚本(scripts/publish-assets.mjs)、server dev 接口与压测脚本都从该文件读取。
|
|
7
|
+
*/
|
|
8
|
+
export declare const REMOTE_SIMULATOR_PROTOCOL_VERSION: number;
|
|
9
|
+
export declare const REMOTE_SIMULATOR_CONNECT = "miniapp-simulator:connect";
|
|
10
|
+
/** Runtime 已包含可在圈选期间冻结 RAF/timer/CSS/media 的 guest 注入能力。 */
|
|
11
|
+
export declare const REMOTE_INSPECTOR_PAUSE_RUNTIME_CAPABILITY = "inspectorPauseRuntime";
|
|
12
|
+
export declare const REMOTE_SIMULATOR_CAPABILITIES: string[];
|
|
13
|
+
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"> & {
|
|
14
|
+
appUrl?: string;
|
|
15
|
+
/** 包会话 Worker 开关;Worker CSP 由 Runtime 服务配置。 */
|
|
16
|
+
security?: Pick<MiniAppSecurityOptions, "worker">;
|
|
17
|
+
};
|
|
18
|
+
export interface RemoteSimulatorGatewayOptions {
|
|
19
|
+
edith: string;
|
|
20
|
+
www: string;
|
|
21
|
+
[name: string]: string;
|
|
22
|
+
}
|
|
23
|
+
export interface RemoteSimulatorConnectMessage {
|
|
24
|
+
type: typeof REMOTE_SIMULATOR_CONNECT;
|
|
25
|
+
protocolVersion: number;
|
|
26
|
+
sessionId: string;
|
|
27
|
+
appId: string;
|
|
28
|
+
businessLine: BusinessLine;
|
|
29
|
+
tracker: boolean;
|
|
30
|
+
gateway?: RemoteSimulatorGatewayOptions;
|
|
31
|
+
userInfo?: Record<string, unknown>;
|
|
32
|
+
hostApiMethods: string[];
|
|
33
|
+
hostApiStubs: Record<string, {
|
|
34
|
+
toast: string;
|
|
35
|
+
}>;
|
|
36
|
+
options: RemoteSimulatorSerializableOptions;
|
|
37
|
+
}
|
|
38
|
+
export interface RemoteSimulatorReadyMessage {
|
|
39
|
+
type: "ready";
|
|
40
|
+
protocolVersion: number;
|
|
41
|
+
runtimeVersion: string;
|
|
42
|
+
capabilities: string[];
|
|
43
|
+
}
|
|
44
|
+
export interface RemoteSimulatorRequestMessage {
|
|
45
|
+
type: "request";
|
|
46
|
+
requestId: string;
|
|
47
|
+
method: RemoteSimulatorMethod;
|
|
48
|
+
args: unknown[];
|
|
49
|
+
}
|
|
50
|
+
export interface RemoteSimulatorResponseMessage {
|
|
51
|
+
type: "response";
|
|
52
|
+
requestId: string;
|
|
53
|
+
ok: boolean;
|
|
54
|
+
result?: unknown;
|
|
55
|
+
error?: {
|
|
56
|
+
message: string;
|
|
57
|
+
code?: string;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
export interface RemoteSimulatorEventMessage {
|
|
61
|
+
type: "event";
|
|
62
|
+
event: string;
|
|
63
|
+
payload: unknown;
|
|
64
|
+
}
|
|
65
|
+
/** Runtime 请求宿主执行不可序列化的 hostApi handler。 */
|
|
66
|
+
export interface RemoteHostApiRequestMessage {
|
|
67
|
+
type: "host-api-request";
|
|
68
|
+
requestId: string;
|
|
69
|
+
event: string;
|
|
70
|
+
request: MiniAppHostApiRequest;
|
|
71
|
+
}
|
|
72
|
+
/** 宿主执行 hostApi handler 后回传给 Runtime。 */
|
|
73
|
+
export interface RemoteHostApiResponseMessage {
|
|
74
|
+
type: "host-api-response";
|
|
75
|
+
requestId: string;
|
|
76
|
+
ok: boolean;
|
|
77
|
+
result?: unknown;
|
|
78
|
+
error?: {
|
|
79
|
+
message: string;
|
|
80
|
+
code?: string;
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/** Runtime 请求宿主通用 HTTP 执行器发起请求。 */
|
|
84
|
+
export interface RemoteHostRequestMessage {
|
|
85
|
+
type: "host-request";
|
|
86
|
+
requestId: string;
|
|
87
|
+
options: ManagedRequestOptions;
|
|
88
|
+
}
|
|
89
|
+
/** 宿主侧 SDK 适配完成后向 Runtime 回传结果。 */
|
|
90
|
+
export interface RemoteHostRequestResponseMessage {
|
|
91
|
+
type: "host-request-response";
|
|
92
|
+
requestId: string;
|
|
93
|
+
ok: boolean;
|
|
94
|
+
result?: ManagedRequestResult;
|
|
95
|
+
error?: {
|
|
96
|
+
message: string;
|
|
97
|
+
code?: number;
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
/** Runtime 取消宿主中正在执行的通用请求。 */
|
|
101
|
+
export interface RemoteHostRequestAbortMessage {
|
|
102
|
+
type: "host-request-abort";
|
|
103
|
+
requestId: string;
|
|
104
|
+
}
|
|
105
|
+
/** 宿主侧 SDK 适配器把响应头或流式分片转发给 Runtime。 */
|
|
106
|
+
export interface RemoteHostRequestEventMessage {
|
|
107
|
+
type: "host-request-event";
|
|
108
|
+
requestId: string;
|
|
109
|
+
event: "headers" | "chunk";
|
|
110
|
+
payload: ManagedRequestHeaders | ManagedRequestChunk;
|
|
111
|
+
}
|
|
112
|
+
export type RemoteSimulatorPortMessage = {
|
|
113
|
+
type: "worker-visibility";
|
|
114
|
+
visible: boolean;
|
|
115
|
+
} | RemoteSimulatorReadyMessage | RemoteSimulatorRequestMessage | RemoteSimulatorResponseMessage | RemoteSimulatorEventMessage | RemoteHostApiRequestMessage | RemoteHostApiResponseMessage | RemoteHostRequestMessage | RemoteHostRequestResponseMessage | RemoteHostRequestAbortMessage | RemoteHostRequestEventMessage;
|
|
116
|
+
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" | "destroy";
|
|
117
|
+
export interface RemoteLoadZipArgs {
|
|
118
|
+
buffer: ArrayBuffer;
|
|
119
|
+
options?: Omit<MiniAppLoadZipOptions, "jszip">;
|
|
120
|
+
}
|
|
121
|
+
export interface RemoteLoadFilesArgs {
|
|
122
|
+
files: MiniAppFileMap;
|
|
123
|
+
options?: MiniAppLoadFilesOptions;
|
|
124
|
+
}
|
|
125
|
+
export type RemoteMethodArgumentMap = {
|
|
126
|
+
load: [];
|
|
127
|
+
loadZip: [RemoteLoadZipArgs];
|
|
128
|
+
loadFiles: [RemoteLoadFilesArgs];
|
|
129
|
+
loadApp: [string, {
|
|
130
|
+
query?: MiniAppSimulatorOptions["query"];
|
|
131
|
+
}?];
|
|
132
|
+
unload: [];
|
|
133
|
+
reload: [];
|
|
134
|
+
setViewport: [MiniAppViewport];
|
|
135
|
+
switchContentMode: [MiniAppContentMode];
|
|
136
|
+
switchPhoneFrame: [NonNullable<MiniAppSimulatorOptions["phoneFrame"]> | false];
|
|
137
|
+
switchDevice: [string];
|
|
138
|
+
setTouchEmulation: [boolean];
|
|
139
|
+
"permissionSheet.show": [string[]?];
|
|
140
|
+
"permissionSheet.hide": [];
|
|
141
|
+
"notePreview.update": [unknown];
|
|
142
|
+
"notePreview.updateUser": [unknown];
|
|
143
|
+
"notePreview.updateAppCard": [unknown];
|
|
144
|
+
"widgetCover.update": [unknown];
|
|
145
|
+
"router.redirectTo": [MiniAppSimulatorRoute, MiniAppRedirectOptions?];
|
|
146
|
+
"router.getRoute": [];
|
|
147
|
+
"inspector.enable": [];
|
|
148
|
+
"inspector.disable": [];
|
|
149
|
+
"inspector.toggle": [];
|
|
150
|
+
"inspector.clear": [];
|
|
151
|
+
"inspector.setSelectionMode": [MiniAppInspectorSelectionMode];
|
|
152
|
+
"inspector.getSelectionMode": [];
|
|
153
|
+
"inspector.getSceneTree": [];
|
|
154
|
+
"inspector.selectByRef": [string];
|
|
155
|
+
capture: [{
|
|
156
|
+
fullPage?: boolean;
|
|
157
|
+
}?];
|
|
158
|
+
screenShot: [];
|
|
159
|
+
setAutoScreenShot: [boolean];
|
|
160
|
+
"hostApi.sync": [string[], Record<string, {
|
|
161
|
+
toast: string;
|
|
162
|
+
}>];
|
|
163
|
+
"hostApi.emit": [string, unknown];
|
|
164
|
+
destroy: [string?];
|
|
165
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export interface MarsReviewLaunchButton {
|
|
2
|
+
setStartHandler(handler: (() => Promise<void>) | null): void;
|
|
3
|
+
destroy(): void;
|
|
4
|
+
}
|
|
5
|
+
/** Mars Runtime 专用审核入口,挂在小工具内容页的未部署空态中。 */
|
|
6
|
+
export declare function createMarsReviewLaunchButton(doc: Document, nickname?: string): MarsReviewLaunchButton;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
interface Window {
|
|
3
|
+
__MINIAPP_SIMULATOR_RUNTIME_CONFIG__?: RemoteRuntimeConfig;
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
export interface RemoteRuntimeConfig {
|
|
7
|
+
runtimeVersion: string;
|
|
8
|
+
requestManagerFrameUrl: string;
|
|
9
|
+
serviceWorkerScriptUrl: string;
|
|
10
|
+
serviceWorkerScope: string;
|
|
11
|
+
allowedParentOrigins: string[];
|
|
12
|
+
runtimeConfigUrl: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function startRemoteMiniAppSimulatorRuntime(): void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface SimulatorPromptOptions {
|
|
2
|
+
title: string;
|
|
3
|
+
content: string;
|
|
4
|
+
buttonLabel: string;
|
|
5
|
+
pendingButtonLabel?: string;
|
|
6
|
+
onButtonClick: () => void | Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export declare function showSimulatorPrompt(doc: Document, options: SimulatorPromptOptions): void;
|
|
9
|
+
export declare function hideSimulatorPrompt(doc: Document): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { createRemoteMiniAppSimulator, type RemoteMiniAppSimulator, type RemoteMiniAppSimulatorOptions, type RemoteSimulatorEventHandler, } from "./remote/client";
|
|
2
|
+
export { BusinessLine } from "./business-line";
|
|
3
|
+
export { REMOTE_INSPECTOR_PAUSE_RUNTIME_CAPABILITY, REMOTE_SIMULATOR_PROTOCOL_VERSION, type RemoteSimulatorGatewayOptions, type RemoteSimulatorSerializableOptions, } from "./remote/protocol";
|
|
4
|
+
export { MiniAppJsApiErrorCode, MINIAPP_SCREENSHOT_ERROR_CODE } from "./types";
|
|
5
|
+
export type { MiniAppContentMode, MiniAppLoadZipResult, MiniAppHostApiController, MiniAppHostApiEntry, MiniAppHostApiHandler, MiniAppHostApiRequest, MiniAppHostRequest, MiniAppHostRequestOptions, MiniAppHostRequestResponse, MiniAppViewport, VisualSelection, XhsNoteAppCardData, XhsNotePreviewUser, XhsWidgetCoverData, MiniAppSimulatorRoute, MiniAppRedirectOptions, MiniAppScreenShotResult, MiniAppScreenShotErrorCode, MiniAppRouterChangeEvent, MiniAppSimulatorOptions, } from "./types";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { EventBus } from "../event-bus";
|
|
2
|
+
import type { MiniAppEventHandler, MiniAppEventMap, MiniAppEventName } from "../types";
|
|
3
|
+
export declare abstract class BaseRendererAdapter {
|
|
4
|
+
protected readonly events: EventBus;
|
|
5
|
+
on<E extends MiniAppEventName>(event: E, handler: MiniAppEventHandler<E>): () => void;
|
|
6
|
+
protected emit<E extends MiniAppEventName>(event: E, payload: MiniAppEventMap[E]): void;
|
|
7
|
+
protected clearEvents(): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { GestureDispatchInput, GestureDispatchResult } from "../../gesture/types";
|
|
2
|
+
import type { GestureHostPluginLike, MiniAppViewport, VisualSelection } from "../../types";
|
|
3
|
+
import type { ContentHost, ContentHostContext, GestureSetupOptions } from "./types";
|
|
4
|
+
/**
|
|
5
|
+
* iframe 载体:以 `iframe.src` 直连同源 URL(SW 虚拟服务器直供,head 注入由 SW 完成),
|
|
6
|
+
* 走 IframeTransport(contentWindow.postMessage),并承载 PC 手势模拟
|
|
7
|
+
* (GestureHostBus + receiver runtime)。
|
|
8
|
+
*
|
|
9
|
+
* 尺寸策略:iframe 始终 100% 撑满父容器,逻辑视口缩放由渲染器在 contentRoot 上做。
|
|
10
|
+
*/
|
|
11
|
+
export declare class IframeContentHost implements ContentHost {
|
|
12
|
+
private iframe;
|
|
13
|
+
protected readonly ctx: ContentHostContext;
|
|
14
|
+
private currentUrl;
|
|
15
|
+
private detachWorkerLifecycle?;
|
|
16
|
+
private loadStartedAt;
|
|
17
|
+
private renderDoneEmitted;
|
|
18
|
+
private gestureBus;
|
|
19
|
+
private gestureSetup;
|
|
20
|
+
private resourceLimitRecovering;
|
|
21
|
+
private heapCooling;
|
|
22
|
+
private readonly pendingGesturePlugins;
|
|
23
|
+
/** 可视化元素选取器:惰性创建(首次 enableInspector),跨 reload 复用同一 iframe */
|
|
24
|
+
private inspector;
|
|
25
|
+
constructor(ctx: ContentHostContext);
|
|
26
|
+
get element(): HTMLIFrameElement;
|
|
27
|
+
private createIframe;
|
|
28
|
+
prepare(): Promise<void>;
|
|
29
|
+
afterAttached(): void;
|
|
30
|
+
private readonly handleMessage;
|
|
31
|
+
/**
|
|
32
|
+
* 先物理移除超限 Guest,再收起内容页;Runtime 只会在笔记页已恢复后收到错误事件。
|
|
33
|
+
* 这样既释放旧 iframe Realm/WebGL,又不会让审核员看到空白小工具页。
|
|
34
|
+
*/
|
|
35
|
+
private handleResourceLimit;
|
|
36
|
+
/** 未启动新 Guest 时命中总堆上限:直接退回笔记页,不允许第二份应用堆叠。 */
|
|
37
|
+
private rejectLoadForResourceLimit;
|
|
38
|
+
/**
|
|
39
|
+
* 内存限制时必须移除旧 iframe,单纯导航至 about:blank 无法可靠释放旧 Realm。
|
|
40
|
+
* Renderer、Runtime 通道和设备外壳保留;手势总线仅针对替换的 iframe 重建。
|
|
41
|
+
*/
|
|
42
|
+
private replaceGuestAfterResourceLimit;
|
|
43
|
+
/**
|
|
44
|
+
* 让 Guest 先执行资源释放(尤其是 `WEBGL_lose_context`)再拆 iframe。
|
|
45
|
+
* `resource-disposed` 来自内置 resource-guard;失控 Guest 不回包时以短超时继续,绝不阻塞返回笔记页。
|
|
46
|
+
*/
|
|
47
|
+
private waitForGuestResourceDisposal;
|
|
48
|
+
private terminateGuest;
|
|
49
|
+
private emitRenderDone;
|
|
50
|
+
load(url: string): Promise<void>;
|
|
51
|
+
private readHostHeapUsage;
|
|
52
|
+
getLoadBlockReason(): {
|
|
53
|
+
used: number;
|
|
54
|
+
limit: number;
|
|
55
|
+
} | null;
|
|
56
|
+
private rememberHeapCooling;
|
|
57
|
+
reload(currentUrl: string): Promise<void>;
|
|
58
|
+
/** 卸载当前文档:清空 iframe 内容重置小工具运行态 */
|
|
59
|
+
unload(): void;
|
|
60
|
+
resize(_viewport: MiniAppViewport): void;
|
|
61
|
+
capture(): Promise<Blob>;
|
|
62
|
+
invokeGamePlaytest(method: "manifest" | "snapshot" | "act" | "step" | "reset" | "isAvailable", args?: unknown[]): Promise<unknown>;
|
|
63
|
+
/**
|
|
64
|
+
* iframe 介质通道:同源 iframe 可直接 postMessage / 读 contentDocument cursor。
|
|
65
|
+
*/
|
|
66
|
+
private createGestureChannel;
|
|
67
|
+
setupGesture(opts: GestureSetupOptions): void;
|
|
68
|
+
private createGestureBus;
|
|
69
|
+
dispatchGesture(input: GestureDispatchInput): Promise<GestureDispatchResult>;
|
|
70
|
+
useGesturePlugin(plugin: GestureHostPluginLike): void;
|
|
71
|
+
removeGesturePlugin(name: string): boolean;
|
|
72
|
+
hasGesturePlugin(name: string): boolean;
|
|
73
|
+
listGesturePlugins(): string[];
|
|
74
|
+
setGestureOverlayInteractionEnabled(enabled: boolean): void;
|
|
75
|
+
/** 惰性创建选取器:overlay 挂到 iframe 父容器(与 iframe 盒对齐,适配各内容模式) */
|
|
76
|
+
private ensureInspector;
|
|
77
|
+
enableInspector(): void;
|
|
78
|
+
disableInspector(): void;
|
|
79
|
+
clearInspectorSelection(): void;
|
|
80
|
+
setInspectorSelectionMode(mode: import("../../types").MiniAppInspectorSelectionMode): void;
|
|
81
|
+
getInspectorSceneTree(): Promise<import("../../types").MiniAppSceneTreeSnapshot>;
|
|
82
|
+
selectInspectorByRef(ref: string): Promise<VisualSelection | null>;
|
|
83
|
+
destroy(): void;
|
|
84
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { GestureDispatchInput, GestureDispatchResult, GestureHostPluginLike, MiniAppEventMap, MiniAppEventName, MiniAppViewport, RendererAdapterContext } from "../../types";
|
|
2
|
+
/** 转发渲染器事件(load / error / renderDone / console / navigation / capture) */
|
|
3
|
+
export type ContentHostEmit = <E extends MiniAppEventName>(event: E, payload: MiniAppEventMap[E]) => void;
|
|
4
|
+
/** 载体在设备内的放置方式,决定尺寸策略 */
|
|
5
|
+
export type ContentHostPlacement = "fullscreen" | "sheet";
|
|
6
|
+
export interface ContentHostContext {
|
|
7
|
+
/** 渲染器上下文(jsapi / injection / normalizedOptions / transport / 等) */
|
|
8
|
+
rendererContext: RendererAdapterContext;
|
|
9
|
+
/** 把载体内部事件转发到渲染器 EventBus */
|
|
10
|
+
emit: ContentHostEmit;
|
|
11
|
+
/**
|
|
12
|
+
* 资源超限时,旧 Guest iframe 已物理移除后的宿主收尾。
|
|
13
|
+
* iframe 载体会等待该回调完成后才向 Runtime 发出错误事件,避免提示覆盖在空内容页上。
|
|
14
|
+
*/
|
|
15
|
+
onResourceLimitReleased?: () => void | Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* 放置方式:
|
|
18
|
+
* - fullscreen:直接铺满设备逻辑视口
|
|
19
|
+
* - sheet:挂在半屏 sheet body 内,撑满父容器
|
|
20
|
+
*/
|
|
21
|
+
placement: ContentHostPlacement;
|
|
22
|
+
}
|
|
23
|
+
/** 手势接线参数(仅 iframe 载体使用) */
|
|
24
|
+
export interface GestureSetupOptions {
|
|
25
|
+
/** 详情半屏外的兜底 overlay 挂载点(一般是手机壳屏幕层或 contentRoot) */
|
|
26
|
+
fallbackMountTarget: HTMLElement;
|
|
27
|
+
/** 悬停圆点跟踪区域(一般是 contentRoot,覆盖整台逻辑视口) */
|
|
28
|
+
hoverTrackTarget?: HTMLElement;
|
|
29
|
+
/** 跨 Shadow 边界的移入监听(shadow host,light DOM) */
|
|
30
|
+
hoverEnterTarget?: HTMLElement;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* 内容载体策略:封装「iframe / webview」介质差异。
|
|
34
|
+
*
|
|
35
|
+
* 渲染器只负责设备外壳布局 + rednote 外壳挂载,载体的创建、按介质加载 URL、
|
|
36
|
+
* 通道绑定、(iframe)手势、(webview)缩放/DevTools 全部收敛到本接口的实现里。
|
|
37
|
+
*/
|
|
38
|
+
export interface ContentHost {
|
|
39
|
+
/** 载体根元素(iframe / webview),由渲染器挂载到 contentRoot 或 sheet body */
|
|
40
|
+
readonly element: HTMLElement;
|
|
41
|
+
/** 异步准备(webview 物化 preload);在挂载进 DOM 之前调用 */
|
|
42
|
+
prepare(): Promise<void>;
|
|
43
|
+
/** 挂载进 DOM 之后的初始化(事件监听、transport.attach 等) */
|
|
44
|
+
afterAttached(): void;
|
|
45
|
+
/** 加载 URL(介质相关:srcdoc / src+guestUrl);内部 emit load/error/renderDone */
|
|
46
|
+
load(url: string): Promise<void>;
|
|
47
|
+
/** 返回阻止启动新 Guest 的 renderer heap 状态;`null` 表示可启动。 */
|
|
48
|
+
getLoadBlockReason?(): {
|
|
49
|
+
used: number;
|
|
50
|
+
limit: number;
|
|
51
|
+
} | null;
|
|
52
|
+
reload(currentUrl: string): Promise<void>;
|
|
53
|
+
/** 卸载当前文档(壳层收起时调用):清空内容重置运行态 */
|
|
54
|
+
unload?(): void;
|
|
55
|
+
/** 设置载体自身尺寸(设备壳层缩放由渲染器负责,此处仅管载体元素本身) */
|
|
56
|
+
resize(viewport: MiniAppViewport): void;
|
|
57
|
+
destroy(): void;
|
|
58
|
+
/** webview:guest webContents.setZoomFactor */
|
|
59
|
+
setZoomFactor?(factor: number): void;
|
|
60
|
+
/** webview:guest webContents id(dom-ready 后可用) */
|
|
61
|
+
getWebContentsId?(): number | null;
|
|
62
|
+
/** webview:开关 guest DevTools */
|
|
63
|
+
setDevtools?(open: boolean): void;
|
|
64
|
+
isDevtoolsOpen?(): boolean;
|
|
65
|
+
/** webview:截屏 */
|
|
66
|
+
capture?(): Promise<Blob>;
|
|
67
|
+
/** iframe/webview 统一的受控游戏测试桥调用。 */
|
|
68
|
+
invokeGamePlaytest?(method: "manifest" | "snapshot" | "act" | "step" | "reset" | "isAvailable", args?: unknown[]): Promise<unknown>;
|
|
69
|
+
dispatchGesture?(input: GestureDispatchInput): Promise<GestureDispatchResult>;
|
|
70
|
+
setupGesture?(opts: GestureSetupOptions): void;
|
|
71
|
+
useGesturePlugin?(plugin: GestureHostPluginLike): void;
|
|
72
|
+
removeGesturePlugin?(name: string): boolean;
|
|
73
|
+
hasGesturePlugin?(name: string): boolean;
|
|
74
|
+
listGesturePlugins?(): string[];
|
|
75
|
+
/** 权限弹窗打开时禁用手势 overlay 交互(仅 iframe gesture 实现) */
|
|
76
|
+
setGestureOverlayInteractionEnabled?(enabled: boolean): void;
|
|
77
|
+
/** 开启选取模式(惰性创建 overlay;同时禁用手势 overlay 交互让选取接管指针) */
|
|
78
|
+
enableInspector?(): void;
|
|
79
|
+
/** 关闭选取模式(移除 overlay;恢复手势 overlay 交互) */
|
|
80
|
+
disableInspector?(): void;
|
|
81
|
+
/** 清除当前选中高亮 */
|
|
82
|
+
clearInspectorSelection?(): void;
|
|
83
|
+
/** 设置可视化选取为单选 / 多选 */
|
|
84
|
+
setInspectorSelectionMode?(mode: import("../../types").MiniAppInspectorSelectionMode): void;
|
|
85
|
+
/** 获取 Guest Scene Provider 的只读层级树。 */
|
|
86
|
+
getInspectorSceneTree?(): Promise<import("../../types").MiniAppSceneTreeSnapshot>;
|
|
87
|
+
/** 从 Hierarchy 反向选中场景节点。 */
|
|
88
|
+
selectInspectorByRef?(ref: string): Promise<import("../../types").VisualSelection | null>;
|
|
89
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { GestureHostPluginLike, MiniAppViewport } from "../../types";
|
|
2
|
+
import type { ContentHost, ContentHostContext, GestureSetupOptions } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* webview 载体:Electron `<webview>`,独立 webContents。
|
|
5
|
+
* 通过 `src`(远程/同源 URL 直连)加载,走 WebviewTransport(IPC)。
|
|
6
|
+
*
|
|
7
|
+
* 尺寸策略:
|
|
8
|
+
* - sheet 放置:100% 撑满 sheet body(body 有确定高度,配合 webview 默认 :host flex 让内部 iframe 填满)。
|
|
9
|
+
* - fullscreen 放置:明确像素尺寸(规避内部 iframe 在百分比高度下塌成 150px);phoneFrame 时叠加 scale。
|
|
10
|
+
*/
|
|
11
|
+
export declare class WebviewContentHost implements ContentHost {
|
|
12
|
+
readonly element: HTMLElement;
|
|
13
|
+
private readonly webview;
|
|
14
|
+
private readonly ctx;
|
|
15
|
+
private currentUrl;
|
|
16
|
+
private preloadUrl;
|
|
17
|
+
private domReady;
|
|
18
|
+
private devtoolsDesired;
|
|
19
|
+
private zoomFactorDesired;
|
|
20
|
+
private gestureBus;
|
|
21
|
+
private readonly pendingGesturePlugins;
|
|
22
|
+
constructor(ctx: ContentHostContext);
|
|
23
|
+
prepare(): Promise<void>;
|
|
24
|
+
afterAttached(): void;
|
|
25
|
+
load(url: string): Promise<void>;
|
|
26
|
+
reload(currentUrl: string): Promise<void>;
|
|
27
|
+
resize(_viewport: MiniAppViewport): void;
|
|
28
|
+
setZoomFactor(factor: number): void;
|
|
29
|
+
getWebContentsId(): number | null;
|
|
30
|
+
setDevtools(open: boolean): void;
|
|
31
|
+
isDevtoolsOpen(): boolean;
|
|
32
|
+
capture(): Promise<Blob>;
|
|
33
|
+
invokeGamePlaytest(method: "manifest" | "snapshot" | "act" | "step" | "reset" | "isAvailable", args?: unknown[]): Promise<unknown>;
|
|
34
|
+
/**
|
|
35
|
+
* webview 介质通道:跨进程,发送/回包都走 WebviewTransport(IPC `mas:msg`)。
|
|
36
|
+
* - send:`transport.post` → preload `ipcRenderer.on` → guest `window.message` → receiver
|
|
37
|
+
* - subscribe:`transport.onMessage`(guest 经 preload `sendToHost` 上报,如 focus-editable)
|
|
38
|
+
* - focusGuest:把宿主键盘焦点切到 webview(guest 内 editable.focus 已由 receiver 做)
|
|
39
|
+
* - readCursorAt:跨进程无法同步读 computed cursor → undefined(hot 高亮降级)
|
|
40
|
+
*/
|
|
41
|
+
private createGestureChannel;
|
|
42
|
+
setupGesture(opts: GestureSetupOptions): void;
|
|
43
|
+
useGesturePlugin(plugin: GestureHostPluginLike): void;
|
|
44
|
+
removeGesturePlugin(name: string): boolean;
|
|
45
|
+
hasGesturePlugin(name: string): boolean;
|
|
46
|
+
listGesturePlugins(): string[];
|
|
47
|
+
setGestureOverlayInteractionEnabled(enabled: boolean): void;
|
|
48
|
+
destroy(): void;
|
|
49
|
+
private applyDevtools;
|
|
50
|
+
private readonly handleDomReady;
|
|
51
|
+
private readonly handleConsole;
|
|
52
|
+
private readonly handleNavigation;
|
|
53
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { NotePublishResult, NotePublishViewData } from "../native-ui/note-publish";
|
|
2
|
+
import type { MiniAppPermissionKind, MiniAppPermissionSheetResult } from "../native-ui/permission-sheet";
|
|
3
|
+
import { BridgeProtocol } from "../transport";
|
|
4
|
+
import type { GestureDispatchInput, GestureDispatchResult, GestureHostPluginLike, MiniAppSimulatorRoute, MiniAppViewport, NormalizedRednoteDetailSheetOptions, RendererAdapter, RendererAdapterContext, XhsNotePreviewData, XhsProfilePreviewData, XhsWidgetCoverData } from "../types";
|
|
5
|
+
import { BaseRendererAdapter } from "./base";
|
|
6
|
+
import type { ContentHostContext, IframeContentHost } from "./content-host";
|
|
7
|
+
/**
|
|
8
|
+
* iframe 渲染器基类:负责设备外壳布局(手机壳 / 无壳标准边框 / 缩放层 contentRoot),
|
|
9
|
+
* 通过 RednoteShellMount 挂载 rednote 外壳、通过 IframeContentHost 承载 <iframe> 载体。
|
|
10
|
+
*
|
|
11
|
+
* 抽象类:内容载体由子类经 {@link createContentHost} 提供
|
|
12
|
+
* (当前唯一实现 {@link ServiceWorkerRendererAdapter} —— Web/SW 运行时)。
|
|
13
|
+
*/
|
|
14
|
+
export declare abstract class IframeRendererAdapter extends BaseRendererAdapter implements RendererAdapter {
|
|
15
|
+
private frame;
|
|
16
|
+
private overlay;
|
|
17
|
+
private container;
|
|
18
|
+
/** 逻辑视口尺寸的缩放层(REDNote 模式与全屏 iframe 共用) */
|
|
19
|
+
private contentRoot;
|
|
20
|
+
private rednoteShell;
|
|
21
|
+
private contentHost;
|
|
22
|
+
private currentUrl;
|
|
23
|
+
/** 与 iframe 绑定的通道;由 Kernel 创建,mount 阶段 attach,destroy 时关闭 */
|
|
24
|
+
private get transport();
|
|
25
|
+
/** 无壳纯面板模式:跳过 rednote 壳层与设备边框,内容铺满挂载区(等价裸 iframe 内嵌)。 */
|
|
26
|
+
private get chromeless();
|
|
27
|
+
/**
|
|
28
|
+
* 协议解析器;mount 阶段创建(仅当 jsapi 启用)。
|
|
29
|
+
* 暴露 public 让 simulator / native-ui 路由模块直接注册内置 jsapi handler。
|
|
30
|
+
*/
|
|
31
|
+
bridge: BridgeProtocol | null;
|
|
32
|
+
private permissionSheetHost;
|
|
33
|
+
private notePublishHost;
|
|
34
|
+
private frameToastHost;
|
|
35
|
+
/** 无壳模式:同步 window `@media` 分档 */
|
|
36
|
+
private detachFramelessShellWindowSync;
|
|
37
|
+
/** 当前逻辑视口(resize 时更新,供无壳 window 同步使用) */
|
|
38
|
+
private viewport;
|
|
39
|
+
/** 卸载 contentRoot 上的 PC 行为拦截 */
|
|
40
|
+
private detachContentPcGuard;
|
|
41
|
+
private readonly context;
|
|
42
|
+
/** 把 ContentHost 内部事件转发到本渲染器 EventBus */
|
|
43
|
+
private readonly forwardEmit;
|
|
44
|
+
constructor(context: RendererAdapterContext);
|
|
45
|
+
mount(container: HTMLElement): void;
|
|
46
|
+
/** 无壳模式:挂载 window resize 同步(对齐 Vue `@media` 分档) */
|
|
47
|
+
private attachFramelessShellIfNeeded;
|
|
48
|
+
/** 创建内容载体;由子类(如 SW 渲染器)提供具体载体实现。 */
|
|
49
|
+
protected abstract createContentHost(ctx: ContentHostContext): IframeContentHost;
|
|
50
|
+
private setupBridge;
|
|
51
|
+
private setupGesture;
|
|
52
|
+
showPermissionSheet(kinds?: MiniAppPermissionKind[]): Promise<MiniAppPermissionSheetResult>;
|
|
53
|
+
hidePermissionSheet(): void;
|
|
54
|
+
showNotePublish(data: NotePublishViewData): Promise<NotePublishResult>;
|
|
55
|
+
hideNotePublish(): void;
|
|
56
|
+
showToast(text: string, options?: {
|
|
57
|
+
duration?: number;
|
|
58
|
+
}): void;
|
|
59
|
+
load(url: string): Promise<void>;
|
|
60
|
+
reload(): Promise<void>;
|
|
61
|
+
unload(): void;
|
|
62
|
+
capture(): Promise<Blob>;
|
|
63
|
+
invokeGamePlaytest(method: "manifest" | "snapshot" | "act" | "step" | "reset" | "isAvailable", args?: unknown[]): Promise<unknown>;
|
|
64
|
+
dispatchGesture(input: GestureDispatchInput): Promise<GestureDispatchResult>;
|
|
65
|
+
/** 壳层收起(下滑 / 全屏返回):卸载内容载体文档,重置小工具运行态 */
|
|
66
|
+
private suspendContent;
|
|
67
|
+
/** 壳层重新唤起:按当前 url 重新加载 */
|
|
68
|
+
private resumeContent;
|
|
69
|
+
/** 点击“用一用”前的 heap 准入:拒绝时保持笔记页,由 Runtime 展示现有底部提示。 */
|
|
70
|
+
private allowContentOpen;
|
|
71
|
+
/** 资源超限后的 Guest 已释放,此时收起 sheet,避免暴露空 iframe。 */
|
|
72
|
+
private returnToNoteAfterResourceLimit;
|
|
73
|
+
syncRednotePreviewContext(notePreview: XhsNotePreviewData, rednoteDetail: NormalizedRednoteDetailSheetOptions): void;
|
|
74
|
+
syncProfilePreviewContext(profilePreview: XhsProfilePreviewData): void;
|
|
75
|
+
syncWidgetCoverContext(widgetCover: XhsWidgetCoverData): void;
|
|
76
|
+
setActivePage(page: Extract<MiniAppSimulatorRoute, "note" | "profile">): void;
|
|
77
|
+
openContent(sheetMode: "half" | "full"): void;
|
|
78
|
+
closeContent(): Promise<void>;
|
|
79
|
+
resize(viewport: MiniAppViewport): void;
|
|
80
|
+
useGesturePlugin(plugin: GestureHostPluginLike): void;
|
|
81
|
+
removeGesturePlugin(name: string): boolean;
|
|
82
|
+
hasGesturePlugin(name: string): boolean;
|
|
83
|
+
listGesturePlugins(): string[];
|
|
84
|
+
setGestureOverlayInteractionEnabled(enabled: boolean): void;
|
|
85
|
+
enableInspector(): void;
|
|
86
|
+
disableInspector(): void;
|
|
87
|
+
clearInspectorSelection(): void;
|
|
88
|
+
setInspectorSelectionMode(mode: import("../types").MiniAppInspectorSelectionMode): void;
|
|
89
|
+
getInspectorSceneTree(): Promise<import("../types").MiniAppSceneTreeSnapshot>;
|
|
90
|
+
selectInspectorByRef(ref: string): Promise<import("../types").VisualSelection | null>;
|
|
91
|
+
destroy(): void;
|
|
92
|
+
private createMountTarget;
|
|
93
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { MiniAppContentMode, MiniAppSimulatorRoute, MiniAppViewport, NormalizedRednoteDetailSheetOptions, XhsNotePreviewData, XhsProfilePreviewData, XhsWidgetCoverData } from "../types";
|
|
2
|
+
/** RednoteShellMount 所需的最小上下文(由渲染器从 RendererAdapterContext 透传) */
|
|
3
|
+
export interface RednoteShellContext {
|
|
4
|
+
contentMode: MiniAppContentMode;
|
|
5
|
+
notePreview: XhsNotePreviewData;
|
|
6
|
+
profilePreview?: XhsProfilePreviewData;
|
|
7
|
+
/** 小工具封面:笔记尾卡 + 个人页卡片两处生效 */
|
|
8
|
+
widgetCover?: XhsWidgetCoverData;
|
|
9
|
+
rednoteDetail: NormalizedRednoteDetailSheetOptions;
|
|
10
|
+
viewport: MiniAppViewport;
|
|
11
|
+
/** 壳层内容收起回调 */
|
|
12
|
+
onContentClose?: () => void;
|
|
13
|
+
/** 壳层内容重新唤起回调 */
|
|
14
|
+
onContentOpen?: () => void;
|
|
15
|
+
/** 请求唤起内容前的准入检查;返回 false 时保持在笔记页。 */
|
|
16
|
+
onContentOpenRequest?: () => boolean;
|
|
17
|
+
/**
|
|
18
|
+
* 壳层路由变化:note/profile(头像 / 返回点击)、minitool(卡片点击 / sheet 唤起)、
|
|
19
|
+
* "back"(sheet 收起,由上层回落到当前活动页)。
|
|
20
|
+
*/
|
|
21
|
+
onRouteChange?: (to: MiniAppSimulatorRoute | "back") => void;
|
|
22
|
+
}
|
|
23
|
+
/** 一次加载的模式行为描述 */
|
|
24
|
+
export interface RednoteLoadBehavior {
|
|
25
|
+
/** 是否跳过内容载体加载(无 url 占位) */
|
|
26
|
+
skipContent: boolean;
|
|
27
|
+
/** 半屏占位/真实内容切换;undefined 表示无需设置 */
|
|
28
|
+
hasAppUrl?: boolean;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* RednoteShellMount —— renderer 无关的 rednote 外壳挂载/数据同步控制器。
|
|
32
|
+
*
|
|
33
|
+
* 负责:注册 Web Component、挂 detail 外壳(half / fullscreen 共用)、提供内容载体挂载点、
|
|
34
|
+
* 同步 notePreview/sheetOptions、setHasAppUrl/光标隐藏、解析 load 模式行为。
|
|
35
|
+
*
|
|
36
|
+
* 不负责:contentRoot/手机壳/缩放(设备外壳由各渲染器自持)、内容载体本身(ContentHost)。
|
|
37
|
+
*/
|
|
38
|
+
export declare class RednoteShellMount {
|
|
39
|
+
private context;
|
|
40
|
+
private detailShell;
|
|
41
|
+
private profileShell;
|
|
42
|
+
/** 当前活动页(note 笔记页 / profile 个人页);小工具 sheet 覆盖其上 */
|
|
43
|
+
private activePage;
|
|
44
|
+
constructor(context: RednoteShellContext);
|
|
45
|
+
/**
|
|
46
|
+
* 在 contentRoot 内挂 detail 外壳(half / fullscreen 共用),返回内容载体挂载点:
|
|
47
|
+
* 半屏 sheet body(并初始化为占位态)。
|
|
48
|
+
*/
|
|
49
|
+
mount(contentRoot: HTMLElement): HTMLElement | null;
|
|
50
|
+
/** 个人页数据:user 仅取 profilePreview 显式注入值(默认保持灰圆占位,不跟随笔记页头像) */
|
|
51
|
+
private resolveProfilePreview;
|
|
52
|
+
/** 解析当前 url 的加载行为(无/`about:blank` URL → 占位) */
|
|
53
|
+
resolveLoad(url: string): RednoteLoadBehavior;
|
|
54
|
+
/** 增量同步笔记预览数据(不重建外壳) */
|
|
55
|
+
syncPreviewContext(notePreview: XhsNotePreviewData, rednoteDetail: NormalizedRednoteDetailSheetOptions): void;
|
|
56
|
+
/** 增量同步个人页数据(不重建外壳) */
|
|
57
|
+
syncProfilePreview(profilePreview?: XhsProfilePreviewData): void;
|
|
58
|
+
/** 增量同步小工具封面(笔记尾卡走 notePreview.widgetCover;个人页卡片走 profileShell) */
|
|
59
|
+
syncWidgetCover(widgetCover?: XhsWidgetCoverData): void;
|
|
60
|
+
/** 切换活动页:note 笔记页 / profile 个人页 */
|
|
61
|
+
setActivePage(page: Extract<MiniAppSimulatorRoute, "note" | "profile">): void;
|
|
62
|
+
/** 当前活动页 */
|
|
63
|
+
getActivePage(): Extract<MiniAppSimulatorRoute, "note" | "profile">;
|
|
64
|
+
/** 唤起小工具内容(先过壳层准入检查) */
|
|
65
|
+
openContent(sheetMode: "half" | "full"): void;
|
|
66
|
+
/** resize 时同步外壳尺寸相关数据(对齐原 iframe renderer resize 行为) */
|
|
67
|
+
onResize(viewport: MiniAppViewport): void;
|
|
68
|
+
setHasAppUrl(hasApp: boolean): void;
|
|
69
|
+
setSimulatedCursorHidden(hidden: boolean): void;
|
|
70
|
+
/** 收起小工具内容并等待视觉退场完成,随后才允许宿主展示覆盖提示。 */
|
|
71
|
+
closeContent(): Promise<void>;
|
|
72
|
+
destroy(): void;
|
|
73
|
+
}
|