@skillbuilder/miniapp-simulator 0.0.0-beta-20261023084421
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 +214 -0
- 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 +855 -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 +197 -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 +45 -0
- package/docs/remote-architecture.md +403 -0
- package/docs/remote-load-observability.md +268 -0
- package/docs/remote-usage.md +371 -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/lib/business-line-CMb3ehRn.mjs +15 -0
- package/lib/client-BZtD2VtP.mjs +772 -0
- package/lib/index-BW85h7kT.mjs +505 -0
- package/lib/index.js +10686 -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 +28 -0
- package/lib/types/capabilities/csp-snippet.d.ts +32 -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 +20 -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 +49 -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 +43 -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/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 +160 -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 +83 -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-modules/context.d.ts +19 -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 +17 -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 +73 -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 +49 -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 +43 -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 +844 -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/workbench-server.mjs +183 -0
- package/lib/workbench.js +1404 -0
- package/package.json +63 -0
- package/scripts/mock-cli-dev.mjs +52 -0
package/docs/tracker.md
ADDED
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
# Tracker 上报文档
|
|
2
|
+
|
|
3
|
+
## 概述
|
|
4
|
+
|
|
5
|
+
miniapp-simulator SDK 内置生命周期 Tracker,监控模拟器从初始化到销毁的全链路关键节点,并上报 bridge 调用情况。
|
|
6
|
+
|
|
7
|
+
## APM 应用信息
|
|
8
|
+
|
|
9
|
+
| 字段 | 值 |
|
|
10
|
+
| ------------------------------ | ------------------------- |
|
|
11
|
+
| 应用名(context_artifactName) | `skillbuilder-miniapp` |
|
|
12
|
+
| 点位名(measurement_name) | `miniapp_simulator_event` |
|
|
13
|
+
|
|
14
|
+
## 接入方式
|
|
15
|
+
|
|
16
|
+
内置默认上报直接把自定义打点 POST 到 APM 端点,接入方无需额外安装。
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
// 内置默认上报 —— business_line 必填
|
|
20
|
+
createMiniAppSimulator({ tracker: { business_line: 'creator' } });
|
|
21
|
+
|
|
22
|
+
// 上报到海外(rednote)
|
|
23
|
+
createMiniAppSimulator({ tracker: { business_line: 'creator', region: 'sg' } });
|
|
24
|
+
|
|
25
|
+
// 覆盖上报端点(可选,优先级高于 region)
|
|
26
|
+
createMiniAppSimulator({
|
|
27
|
+
tracker: { business_line: 'creator', endpoint: 'https://your-apm/api/data' },
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// 不启用(默认)
|
|
31
|
+
// tracker 不传或传 false
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
> - `business_line` 取值 `creator`(创作平台)/ `audit`(审核平台),作为公共字段注入每条打点(缺省兜底 `unknown`)。
|
|
35
|
+
> - 如需上报用户 ID,可在 tracker 选项里提供 `getUserInfo`(见下文「默认上报说明」)。
|
|
36
|
+
> - `region`:`cn`(默认)/ `sg`(海外)。端点只按当前 hostname 选择:`localhost` / `127.0.0.1` / `0.0.0.0` / 包含 `.sit.` / 以 `local.` 开头走测试 APM;`.beta.` 和其他域名继续上报正式 APM。
|
|
37
|
+
> - `endpoint`:直接指定上报 URL,传了则忽略 `region`。
|
|
38
|
+
> - `debug`:打印到 console 而非真正上报;仅显式传 `true` 时开启。
|
|
39
|
+
|
|
40
|
+
### 默认上报说明
|
|
41
|
+
|
|
42
|
+
- **`getUserInfo` 取用户 ID**:在 tracker 选项里提供 `getUserInfo()`,SDK 上报时会调用它取
|
|
43
|
+
`userId` 作为 APM 用户标识;可同步或异步返回,未提供 / 返回空则 `userId` 留空,不影响其它字段。
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
createMiniAppSimulator({
|
|
47
|
+
tracker: {
|
|
48
|
+
business_line: 'creator',
|
|
49
|
+
async getUserInfo() {
|
|
50
|
+
return { userId: 'current-user-id' };
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
- **批量上报**:打点先进缓冲,满 10 条或最多 10s 后合并成一次请求发送;页面隐藏(`visibilitychange`)
|
|
57
|
+
与 `destroy()` 时立即冲刷,避免关闭前丢数据。
|
|
58
|
+
- **本地开发**:`localhost` / `127.0.0.1` 默认上报到测试 APM;需要只看 console 时显式传 `debug: true`。
|
|
59
|
+
|
|
60
|
+
## 字段说明
|
|
61
|
+
|
|
62
|
+
### 公共字段
|
|
63
|
+
|
|
64
|
+
每条打点自动注入,无需各事件单独声明。
|
|
65
|
+
|
|
66
|
+
| 字段 | 类型 | 说明 |
|
|
67
|
+
| --------------- | -------- | --------------------------------------------------------------------- |
|
|
68
|
+
| `event_name` | `string` | 事件名称 |
|
|
69
|
+
| `timestamp` | `number` | 打点时间戳(ms) |
|
|
70
|
+
| `business_line` | `string` | 业务线:区分使用模拟器的平台(`creator` / `audit`,默认上报模式必填) |
|
|
71
|
+
| `sdk_version` | `string` | SDK 版本号 |
|
|
72
|
+
| `content_mode` | `string` | 内容模式:`half` / `fullscreen` |
|
|
73
|
+
| `renderer` | `string` | 渲染器类型:`iframe-service-worker` / `webview` |
|
|
74
|
+
|
|
75
|
+
### 事件字段
|
|
76
|
+
|
|
77
|
+
同一字段在不同 `event_name` 下含义不同。
|
|
78
|
+
|
|
79
|
+
| 字段 | 类型 | 说明 |
|
|
80
|
+
| ------------ | -------- | -------------------------------------------------------------------------------------- |
|
|
81
|
+
| `url` | `string` | 相关 URL |
|
|
82
|
+
| `source` | `string` | 来源(触发来源 / 导航来源 URL) |
|
|
83
|
+
| `duration` | `number` | 耗时(ms) |
|
|
84
|
+
| `message` | `string` | 文本信息(错误信息 / 销毁原因等) |
|
|
85
|
+
| `error_name` | `string` | 标识名(错误码 / bridge 事件名) |
|
|
86
|
+
| `result` | `string` | 操作结果(`success` / `fail` / `allow` / `deny` / `cancel` / `injected` / `fallback`) |
|
|
87
|
+
| `type` | `string` | 类型标识(`zip` / `files` / 权限种类) |
|
|
88
|
+
| `count` | `number` | 数量 |
|
|
89
|
+
| `entry` | `string` | 入口文件名 |
|
|
90
|
+
|
|
91
|
+
## 上报事件清单
|
|
92
|
+
|
|
93
|
+
### 维护范围
|
|
94
|
+
|
|
95
|
+
| 分类 | 事件 | 策略 |
|
|
96
|
+
| --- | --- | --- |
|
|
97
|
+
| 核心加载 | `simulator_load_stage`、`simulator_before_load`、`simulator_ready`、`simulator_load`、`simulator_load_error`、`simulator_render_done`、`simulator_parse_done`、`simulator_sw_register`、`simulator_sw_mount` | 持续维护,用于加载耗时与成功率看板 |
|
|
98
|
+
| 故障上下文 | `simulator_guest_error`、`simulator_inject_done` | 持续维护,用于解释加载失败、白屏和运行异常 |
|
|
99
|
+
| 非加载生命周期 | `simulator_init`、`simulator_reload`、`simulator_navigation_blocked`、`simulator_permission_result`、`simulator_destroy`、`bridge_invoke` | 保留已有上报兼容性,不纳入核心加载口径,不继续扩展字段 |
|
|
100
|
+
|
|
101
|
+
历史事件在确认无下游查询和告警依赖前不直接删除。核心加载看板只依赖前两类,避免把人工操作和普通
|
|
102
|
+
JSAPI 调用耗时误判为模拟器加载耗时。
|
|
103
|
+
|
|
104
|
+
### simulator_init
|
|
105
|
+
|
|
106
|
+
模拟器实例构造完成时触发。
|
|
107
|
+
|
|
108
|
+
| 字段 | 值 |
|
|
109
|
+
| ----- | -------------- |
|
|
110
|
+
| `url` | 小应用入口 URL |
|
|
111
|
+
|
|
112
|
+
### simulator_before_load
|
|
113
|
+
|
|
114
|
+
`load()` 触发前发出。
|
|
115
|
+
|
|
116
|
+
| 字段 | 值 |
|
|
117
|
+
| -------- | ----------------------------------------------------------------------------------------------------- |
|
|
118
|
+
| `url` | 即将加载的 URL |
|
|
119
|
+
| `source` | 触发来源:`load` / `reload` / `switch-mode` / `switch-frame` / `load-app` / `load-zip` / `load-files` |
|
|
120
|
+
|
|
121
|
+
### simulator_ready
|
|
122
|
+
|
|
123
|
+
渲染容器 mount 完成时触发。仅公共字段。
|
|
124
|
+
|
|
125
|
+
### simulator_load
|
|
126
|
+
|
|
127
|
+
内容加载完成时触发。
|
|
128
|
+
|
|
129
|
+
| 字段 | 值 |
|
|
130
|
+
| ---------- | -------------- |
|
|
131
|
+
| `url` | 加载的 URL |
|
|
132
|
+
| `duration` | 加载耗时(ms) |
|
|
133
|
+
|
|
134
|
+
### simulator_load_error
|
|
135
|
+
|
|
136
|
+
加载失败时触发。
|
|
137
|
+
|
|
138
|
+
| 字段 | 值 |
|
|
139
|
+
| ------------ | ------------------------------------------------------------ |
|
|
140
|
+
| `url` | 失败的 URL |
|
|
141
|
+
| `error_name` | 错误码:`LOAD_TIMEOUT` / `LOAD_FAILED` / `RENDERER_ERROR` 等 |
|
|
142
|
+
| `message` | 错误信息 |
|
|
143
|
+
|
|
144
|
+
### simulator_render_done
|
|
145
|
+
|
|
146
|
+
子文档首帧渲染完毕时触发。
|
|
147
|
+
|
|
148
|
+
| 字段 | 值 |
|
|
149
|
+
| ---------- | ------------------ |
|
|
150
|
+
| `url` | 完成渲染的 URL |
|
|
151
|
+
| `duration` | 首帧渲染耗时(ms) |
|
|
152
|
+
|
|
153
|
+
### simulator_reload
|
|
154
|
+
|
|
155
|
+
调用 `simulator.reload()` 时触发。
|
|
156
|
+
|
|
157
|
+
| 字段 | 值 |
|
|
158
|
+
| ----- | -------------- |
|
|
159
|
+
| `url` | 重新加载的 URL |
|
|
160
|
+
|
|
161
|
+
### simulator_inject_done
|
|
162
|
+
|
|
163
|
+
head 注入完成时触发。
|
|
164
|
+
|
|
165
|
+
| 字段 | 值 |
|
|
166
|
+
| ---------- | ------------------------------------------------------- |
|
|
167
|
+
| `url` | 注入的 URL |
|
|
168
|
+
| `result` | `injected`(走注入路径)/ `fallback`(降级为 src 直连) |
|
|
169
|
+
| `duration` | 注入耗时(ms) |
|
|
170
|
+
|
|
171
|
+
### simulator_navigation_blocked
|
|
172
|
+
|
|
173
|
+
iframe/webview 内部导航被拦截时触发。
|
|
174
|
+
|
|
175
|
+
| 字段 | 值 |
|
|
176
|
+
| -------- | -------- |
|
|
177
|
+
| `source` | 来源 URL |
|
|
178
|
+
| `url` | 目标 URL |
|
|
179
|
+
|
|
180
|
+
### simulator_guest_error
|
|
181
|
+
|
|
182
|
+
小工具内部发生未捕获错误时触发。
|
|
183
|
+
|
|
184
|
+
| 字段 | 值 |
|
|
185
|
+
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
186
|
+
| `type` | 监听的事件名:`error`(JS 异常 + 资源加载失败)/ `unhandledrejection`(Promise 未处理拒绝)/ `securitypolicyviolation`(CSP 拦截)/ `fetch`(网络失败) |
|
|
187
|
+
| `error_name` | 错误名(JS:error.name;资源:`ResourceError`;CSP:`CSPViolation`;fetch:error.name) |
|
|
188
|
+
| `message` | JS / Promise 为错误堆栈,其余为错误消息(截断至 1000 字符);CSP 为被拦截的指令 |
|
|
189
|
+
| `source` | JS:`filename:line:col`;资源:标签名;CSP:`sourceFile:line:col` |
|
|
190
|
+
| `url` | 出错脚本 / 失败资源 / 被拦截资源的 URL |
|
|
191
|
+
| `disposition` | CSP 处置方式:`enforce`(拦截)/ `report`(仅上报)。仅 CSP 有 |
|
|
192
|
+
|
|
193
|
+
### simulator_parse_done
|
|
194
|
+
|
|
195
|
+
`loadZip()` / `loadFiles()` 解析完成时触发。
|
|
196
|
+
|
|
197
|
+
| 字段 | 值 |
|
|
198
|
+
| ---------- | --------------- |
|
|
199
|
+
| `type` | `zip` / `files` |
|
|
200
|
+
| `duration` | 解析耗时(ms) |
|
|
201
|
+
| `count` | 文件数量 |
|
|
202
|
+
| `entry` | 入口文件名 |
|
|
203
|
+
|
|
204
|
+
### simulator_permission_result
|
|
205
|
+
|
|
206
|
+
权限弹窗操作完成时触发。
|
|
207
|
+
|
|
208
|
+
| 字段 | 值 |
|
|
209
|
+
| -------- | --------------------------- |
|
|
210
|
+
| `type` | 权限种类(逗号分隔) |
|
|
211
|
+
| `result` | `allow` / `deny` / `cancel` |
|
|
212
|
+
|
|
213
|
+
### simulator_destroy
|
|
214
|
+
|
|
215
|
+
模拟器销毁时触发。
|
|
216
|
+
|
|
217
|
+
| 字段 | 值 |
|
|
218
|
+
| --------- | -------- |
|
|
219
|
+
| `message` | 销毁原因 |
|
|
220
|
+
|
|
221
|
+
### bridge_invoke
|
|
222
|
+
|
|
223
|
+
bridge(jsapi)调用完成时触发。
|
|
224
|
+
|
|
225
|
+
| 字段 | 值 |
|
|
226
|
+
| ------------ | ------------------------------- |
|
|
227
|
+
| `error_name` | bridge 事件名(如 `showToast`) |
|
|
228
|
+
| `result` | `success` / `fail` |
|
|
229
|
+
| `duration` | 成功时的执行耗时(ms) |
|
|
230
|
+
| `message` | 失败时的错误原因 |
|
|
231
|
+
|
|
232
|
+
## 核心加载链路
|
|
233
|
+
|
|
234
|
+
核心诊断统一使用 `simulator_load_stage`,阶段差异放在 `stage`,不为每个阶段新增点位或字段。
|
|
235
|
+
Client、Runtime 和 Core 复用远程协议中已有的 `sessionId`,上报字段统一命名为 `session_id`;
|
|
236
|
+
上报不经过 MessageChannel,不增加协议字段。
|
|
237
|
+
|
|
238
|
+
### 字段登记
|
|
239
|
+
|
|
240
|
+
| 字段 | 类型 | 说明 |
|
|
241
|
+
| ----------------- | -------- | --------------------------------------------------------- |
|
|
242
|
+
| `session_id` | `string` | 一次远程模拟器连接,全链路关联键 |
|
|
243
|
+
| `app_id` | `string` | 小工具 ID |
|
|
244
|
+
| `runtime_version` | `string` | Runtime 发布版本 |
|
|
245
|
+
| `stage` | `string` | 低基数加载阶段 |
|
|
246
|
+
| `result` | `string` | `success` / `fail` / `timeout` / `fallback` / `protocol_mismatch` |
|
|
247
|
+
| `duration` | `number` | 当前阶段耗时,单位 ms |
|
|
248
|
+
| `type` | `string` | 通用分类,如 `zip` / `files` / `primary` / `fallback` |
|
|
249
|
+
| `count` | `number` | 文件或资源数量 |
|
|
250
|
+
| `bytes` | `number` | 包或传输体积,单位 byte |
|
|
251
|
+
| `network_duration` | `number` | 网络资源总耗时,单位 ms |
|
|
252
|
+
| `dns_duration` | `number` | DNS 耗时,单位 ms |
|
|
253
|
+
| `connect_duration` | `number` | TCP/TLS 建连耗时,单位 ms |
|
|
254
|
+
| `ttfb_duration` | `number` | 请求发出到首字节耗时,单位 ms |
|
|
255
|
+
| `code` | `number` | HTTP 状态码 |
|
|
256
|
+
| `error_name` | `string` | 字符串业务错误码或网络错误分类 |
|
|
257
|
+
| `message` | `string` | 截断后的错误信息,仅失败时上报 |
|
|
258
|
+
|
|
259
|
+
`business_line`、`sdk_version` 和 `renderer` 继续复用公共字段。网络字段为跨请求类型通用字段,
|
|
260
|
+
同样用于 manifest、Runtime 文档、Runtime 脚本和动态策略请求。
|
|
261
|
+
`request_id` 复用已有字段,不需要新增登记:`session_id` 关联一次 Runtime 连接,`request_id`
|
|
262
|
+
关联该连接中的一次 `loadZip` / `loadFiles`,从 Client 资源物化一直串到 Core 和 Guest。
|
|
263
|
+
`loadZip` / `loadFiles` 是核心加载入口;其他远程方法仍上报通用调用耗时,但不计入核心加载
|
|
264
|
+
成功率、耗时分位和阶段漏斗。
|
|
265
|
+
下载耗时不单独登记字段,统一使用 `<stage>_download` 阶段的 `duration`,例如
|
|
266
|
+
`runtime_manifest_download`、`runtime_document_download` 和 `runtime_config_download`。
|
|
267
|
+
|
|
268
|
+
当前 Runtime 与 Service Worker 都是单文件 bundle。模拟器自身资源由 `runtime_manifest`、
|
|
269
|
+
`runtime_document`、`runtime_script`、`runtime_config` 和 `simulator_sw_register` 覆盖;其中
|
|
270
|
+
`simulator_sw_register` 是 SW bootstrap、CDN SW 模块加载、安装和激活的端到端耗时。
|
|
271
|
+
`request-manager` 按业务网络请求懒加载,不属于模拟器首次 ready 的关键路径。
|
|
272
|
+
|
|
273
|
+
### 阶段清单
|
|
274
|
+
|
|
275
|
+
| 阶段 | 诊断目标 |
|
|
276
|
+
| ------------------------------------- | -------------------------------------------- |
|
|
277
|
+
| `runtime_manifest` | Runtime 清单请求总耗时和主/备用服务结果 |
|
|
278
|
+
| `runtime_document` | Client 观察到的 Runtime iframe 总加载耗时:导航到 `load`,包含文档、模块依赖和执行 |
|
|
279
|
+
| `runtime_bootstrap` | Runtime 页面启动时采集的导航、模块执行和 DOM 初始化耗时,只采一次 |
|
|
280
|
+
| `runtime_script` | Runtime 模块脚本网络分段 |
|
|
281
|
+
| `<stage>_download` | 对应网络阶段的响应体下载耗时 |
|
|
282
|
+
| `runtime_handshake` | connect 到 ready |
|
|
283
|
+
| `runtime_config` | 动态策略请求总耗时和网络分段 |
|
|
284
|
+
| `simulator_create` | Runtime 内创建 Core 模拟器 |
|
|
285
|
+
| `runtime_ready` | Runtime 收到 connect 到返回 ready |
|
|
286
|
+
| `client_ready` | Client 创建到可调用的端到端总耗时 |
|
|
287
|
+
| `package_materialize` | Client 侧 Blob/File 转 ArrayBuffer,带本次加载的 `request_id` |
|
|
288
|
+
| `remote_request` | 所有远程方法调用的端到端耗时,`type` 为方法名;核心加载只筛选 `loadZip` / `loadFiles` |
|
|
289
|
+
| `runtime_request` | Runtime 处理 `loadZip` / `loadFiles` 的耗时,旧 Client 连接时也可采集 |
|
|
290
|
+
| `zip_parse` | 审核 Runtime 的 zip 解压 |
|
|
291
|
+
| `review_wait` | ZIP 解析完成到开始审核,仅隔离人工等待 |
|
|
292
|
+
| `review_app_load` | 开始审核到 Core `loadFiles` 完成 |
|
|
293
|
+
| `renderer_setup` | 渲染器、SW 前置准备和容器初始化 |
|
|
294
|
+
| `injection_build` | 注入脚本与 CSP 构建 |
|
|
295
|
+
| `guest_document` | 小工具 iframe 文档 load |
|
|
296
|
+
| `guest_dom_ready` | 小工具 DOMContentLoaded |
|
|
297
|
+
| `guest_script_execution` | 小工具 DOM 解析及同步脚本执行 |
|
|
298
|
+
| `guest_first_paint` | 小工具首绘 |
|
|
299
|
+
| `guest_resources` | 小工具资源数量和传输体积 |
|
|
300
|
+
| `guest_render` | 小工具 render-done |
|
|
301
|
+
| `guest_error` | 小工具加载阶段错误码与错误信息 |
|
|
302
|
+
|
|
303
|
+
Core 中的 `simulator_parse_done`、`simulator_sw_register`、`simulator_sw_mount`、
|
|
304
|
+
`simulator_load` 和 `simulator_render_done` 使用同一个 `session_id`,核心包加载期间同时带
|
|
305
|
+
`request_id` 和 `type`。核心加载看板依赖这些事件与 `simulator_load_stage`;权限、bridge、
|
|
306
|
+
销毁等生命周期点位不纳入加载耗时口径。
|
|
307
|
+
|
|
308
|
+
### 时序
|
|
309
|
+
|
|
310
|
+
```mermaid
|
|
311
|
+
sequenceDiagram
|
|
312
|
+
participant C as Client
|
|
313
|
+
participant S as Simulator Server
|
|
314
|
+
participant R as Runtime
|
|
315
|
+
participant W as Service Worker
|
|
316
|
+
participant G as Guest iframe
|
|
317
|
+
participant A as APM
|
|
318
|
+
|
|
319
|
+
C->>S: GET runtime-manifest
|
|
320
|
+
C-->>A: runtime_manifest + network phases
|
|
321
|
+
C->>R: navigate Runtime document
|
|
322
|
+
R-->>A: runtime_bootstrap / runtime_script
|
|
323
|
+
C->>R: connect(sessionId, protocol v6)
|
|
324
|
+
R->>S: fetch runtime config
|
|
325
|
+
R-->>A: runtime_config / simulator_create
|
|
326
|
+
R-->>C: ready(protocol v6)
|
|
327
|
+
C-->>A: runtime_handshake / client_ready
|
|
328
|
+
C->>R: loadZip / loadFiles
|
|
329
|
+
C-->>A: package_materialize / remote_request
|
|
330
|
+
R-->>A: runtime_request / zip_parse
|
|
331
|
+
Note over R: review_wait 隔离人工等待
|
|
332
|
+
R->>R: reviewer starts loading
|
|
333
|
+
R->>W: parse files / register / build injection / mount
|
|
334
|
+
W-->>R: MOUNT ACK
|
|
335
|
+
R->>G: navigate virtual entry
|
|
336
|
+
G-->>R: load / DOM ready / first paint / render done
|
|
337
|
+
R-->>A: review_app_load / guest_* stages
|
|
338
|
+
Note over C,A: session_id 串连接,request_id 串单次 loadZip/loadFiles
|
|
339
|
+
```
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const a = {
|
|
2
|
+
/** 小工具尚未加载(含占位态 / 不在小工具页) */
|
|
3
|
+
notLoaded: "not-loaded",
|
|
4
|
+
/** 页面渲染异常,截图内容不可用 */
|
|
5
|
+
renderFailed: "render-failed",
|
|
6
|
+
/** 截图超时 */
|
|
7
|
+
timeout: "timeout",
|
|
8
|
+
/** 当前环境不支持截图 */
|
|
9
|
+
unsupported: "unsupported"
|
|
10
|
+
};
|
|
11
|
+
var r = /* @__PURE__ */ ((e) => (e.skillDesignable = "skill-designable", e.creator = "creator", e.mars = "mars", e.dev = "dev", e))(r || {});
|
|
12
|
+
export {
|
|
13
|
+
r as B,
|
|
14
|
+
a as M
|
|
15
|
+
};
|