@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
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Injection —— 注入模块清单(介质无关)
|
|
3
|
+
*
|
|
4
|
+
* 每个 InjectionModule 只关心"我要注入什么",由 Renderer 决定"注入到哪里":
|
|
5
|
+
* - IframeRenderer:调 `buildHeadSnippet`,拼到 srcdoc `<head>`
|
|
6
|
+
* - WebviewRenderer:调 `buildPreloadSource`,物化成 preload script
|
|
7
|
+
*
|
|
8
|
+
* 一个模块可以同时实现两个函数(如 jsapi UMD),也可以只实现一个
|
|
9
|
+
* (如 RenderDoneBootstrap 仅在 iframe 才需要)。
|
|
10
|
+
*
|
|
11
|
+
* 设计意图见:design/mini-app/mini-app-simulator-refactor-design.md §8
|
|
12
|
+
*/
|
|
13
|
+
import type { NormalizedMiniAppSimulatorOptions } from "../types";
|
|
14
|
+
export interface InjectionContext {
|
|
15
|
+
/** 当前渲染介质 */
|
|
16
|
+
rendererType: "iframe" | "webview";
|
|
17
|
+
/** 归一化后的 simulator options(供模块按需读取 jsapi/security 等配置) */
|
|
18
|
+
options: NormalizedMiniAppSimulatorOptions;
|
|
19
|
+
/** 当前 load 的 appUrl(用于 base href 等场景) */
|
|
20
|
+
appUrl: string;
|
|
21
|
+
/** 当前渲染实例可写 usr 根路径;SW 模式为同源 `_xhsfile_` URL。 */
|
|
22
|
+
userDataPath?: string;
|
|
23
|
+
/** 宿主为当前 Runtime 指定的网关;缺省时由各 SDK 使用内置默认值。 */
|
|
24
|
+
gateways?: Record<string, string>;
|
|
25
|
+
/** 业务线;用于启动参数和 AI 网关路由。 */
|
|
26
|
+
businessLine?: string;
|
|
27
|
+
/** iframe srcdoc 路径:fetch 到的原始 HTML(供 jsapi 等模块做 auto-detect) */
|
|
28
|
+
rawHtml?: string;
|
|
29
|
+
/** CSP nonce:装配器打在合并 `<script>` 上,模块用于 CSP meta 的 script-src。 */
|
|
30
|
+
scriptNonce?: string;
|
|
31
|
+
/** true(SW 模式)时 CSP 走响应头,head 内不注入 CSP meta。 */
|
|
32
|
+
cspAsHeader?: boolean;
|
|
33
|
+
}
|
|
34
|
+
export interface InjectionModule {
|
|
35
|
+
/** 唯一名,用于去重与调试 */
|
|
36
|
+
id: string;
|
|
37
|
+
/** head 非脚本 HTML(meta / style / link)。 */
|
|
38
|
+
buildHeadSnippet?(ctx: InjectionContext): string | Promise<string>;
|
|
39
|
+
/** head 合并 `<script>` 内的裸 JS(装配器逐段包 try/catch)。 */
|
|
40
|
+
buildHeadScriptSource?(ctx: InjectionContext): string | Promise<string>;
|
|
41
|
+
/** webview preload script 的一段 IIFE 函数体。 */
|
|
42
|
+
buildPreloadSource?(ctx: InjectionContext): string | Promise<string>;
|
|
43
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HostInspector —— 父窗口侧的可视化元素选取器。
|
|
3
|
+
*
|
|
4
|
+
* 职责:
|
|
5
|
+
* 1. enable 时在 iframe 之上盖一层独立 overlay(高于手势 overlay),接管悬停 / 点击
|
|
6
|
+
* 2. DOM 同源直读;Canvas 则通过 guest bridge 委托模板注册的场景 Provider 命中
|
|
7
|
+
* 3. 画悬停 / 选中高亮框,并把统一的 VisualSelection 回调给宿主
|
|
8
|
+
* 4. disable 时彻底移除 overlay,恢复正常预览 / 手势交互
|
|
9
|
+
*
|
|
10
|
+
* 设计要点(关键:**不影响现有功能**):
|
|
11
|
+
* - overlay 只在选取模式开启时存在;关闭即移除,手势 / jsapi / 渲染链路零感知。
|
|
12
|
+
* - DOM 仍与手势模块的 `readCursorAt` 共用同一套坐标换算;场景能力按 Provider 渐进增强。
|
|
13
|
+
*/
|
|
14
|
+
import type { MiniAppInspectorSelectionMode, MiniAppSceneTreeSnapshot, MiniAppVisualSelectionChangeEvent, VisualSelection } from "../types";
|
|
15
|
+
export interface HostInspectorOptions {
|
|
16
|
+
/** 内容载体 iframe:读取 contentDocument + 坐标换算的基准 */
|
|
17
|
+
element: HTMLIFrameElement;
|
|
18
|
+
/** overlay 挂载点(iframe 父容器,与 iframe 盒对齐);惰性求值以适配 reload 重建 */
|
|
19
|
+
getMountTarget: () => HTMLElement | null;
|
|
20
|
+
/** 点击选中回调 */
|
|
21
|
+
onSelect: (selection: VisualSelection) => void;
|
|
22
|
+
/** 选中集合变化回调 */
|
|
23
|
+
onSelectionChange?: (event: MiniAppVisualSelectionChangeEvent) => void;
|
|
24
|
+
/** 悬停变化回调(移出小应用区域时传 null) */
|
|
25
|
+
onHover: (selection: VisualSelection | null) => void;
|
|
26
|
+
debug?: boolean;
|
|
27
|
+
}
|
|
28
|
+
export declare class HostInspector {
|
|
29
|
+
private readonly opts;
|
|
30
|
+
private enabled;
|
|
31
|
+
private destroyed;
|
|
32
|
+
private overlay;
|
|
33
|
+
private hoverBox;
|
|
34
|
+
private readonly selectedBoxes;
|
|
35
|
+
private readonly selections;
|
|
36
|
+
private selectionMode;
|
|
37
|
+
/** 当前悬停元素,避免重复 emit / 重画 */
|
|
38
|
+
private hoveredEl;
|
|
39
|
+
/** 悬停 / 选中框是否已可见(决定移动时是「滑动」还是「首次出现」) */
|
|
40
|
+
private hoverShown;
|
|
41
|
+
private requestSeq;
|
|
42
|
+
private latestHoverRequest;
|
|
43
|
+
private guestHoverFrame;
|
|
44
|
+
private pendingGuestHover;
|
|
45
|
+
private readonly pendingRequests;
|
|
46
|
+
private sceneRefreshTimer;
|
|
47
|
+
private sceneRefreshPending;
|
|
48
|
+
/** 同源不可访问时只告警一次 */
|
|
49
|
+
private warnedNoAccess;
|
|
50
|
+
constructor(opts: HostInspectorOptions);
|
|
51
|
+
get isEnabled(): boolean;
|
|
52
|
+
enable(): void;
|
|
53
|
+
disable(): void;
|
|
54
|
+
/** 清除选中高亮(保持选取模式开启) */
|
|
55
|
+
clear(): void;
|
|
56
|
+
setSelectionMode(mode: MiniAppInspectorSelectionMode): void;
|
|
57
|
+
destroy(): void;
|
|
58
|
+
private readonly onFrameLoad;
|
|
59
|
+
private notifyGuestPause;
|
|
60
|
+
private buildOverlay;
|
|
61
|
+
private teardownOverlay;
|
|
62
|
+
private createBox;
|
|
63
|
+
private readonly onMove;
|
|
64
|
+
private readonly onLeave;
|
|
65
|
+
private readonly onMouseDown;
|
|
66
|
+
private select;
|
|
67
|
+
/** contentDocument 不可读时,经常驻 guest bridge 请求同一份结构化定位结果。 */
|
|
68
|
+
private queueGuestHover;
|
|
69
|
+
private cancelGuestHover;
|
|
70
|
+
private requestGuestSelection;
|
|
71
|
+
/** 获取 Guest 中所有已注册 Provider 的只读场景树。 */
|
|
72
|
+
getSceneTree(): Promise<MiniAppSceneTreeSnapshot>;
|
|
73
|
+
/** 从 Hierarchy / Outliner 反向选择,并复用同一个 Selection Store 与高亮层。 */
|
|
74
|
+
selectByRef(ref: string): Promise<VisualSelection | null>;
|
|
75
|
+
private startSceneSelectionRefresh;
|
|
76
|
+
private stopSceneSelectionRefresh;
|
|
77
|
+
/**
|
|
78
|
+
* Scene 对象通常每帧运动;通过稳定 ref 重新 describe,只更新宿主选框与缓存,
|
|
79
|
+
* 不重复触发用户级 select 事件。对象销毁后自动移除对应选择。
|
|
80
|
+
*/
|
|
81
|
+
private refreshSceneSelections;
|
|
82
|
+
private requestGuestRpc;
|
|
83
|
+
private readonly onGuestMessage;
|
|
84
|
+
private completeGuestSelection;
|
|
85
|
+
private selectionKey;
|
|
86
|
+
private selectionRect;
|
|
87
|
+
/**
|
|
88
|
+
* 宿主视口坐标 → iframe 内容元素。
|
|
89
|
+
* 与手势模块 `readCursorAt` 同一套换算:用 offsetWidth/rect.width 修正设备缩放。
|
|
90
|
+
* 同源不可访问(跨源 / webview)时返回 null 并降级告警一次。
|
|
91
|
+
*/
|
|
92
|
+
private resolveElement;
|
|
93
|
+
/** html/body 表示点到了应用内容之外的根背景,用作清空当前选择。 */
|
|
94
|
+
private isDocumentSurface;
|
|
95
|
+
/**
|
|
96
|
+
* 摆放高亮框。overlay 与 iframe 内容共享同一未缩放坐标空间(设备缩放在共同祖先上),
|
|
97
|
+
* 故元素的 getBoundingClientRect(iframe 内容 CSS px)可直接作为 overlay 内定位。
|
|
98
|
+
*
|
|
99
|
+
* @param wasShown 框是否已可见:已可见则保留过渡,框「滑」到新元素(粘黏感);
|
|
100
|
+
* 首次出现则临时关掉几何过渡,避免从 (0,0) 滑入。
|
|
101
|
+
*/
|
|
102
|
+
private placeBox;
|
|
103
|
+
private placeRect;
|
|
104
|
+
/** 选中时弹一下,给"咔哒选中"的手感(transform 动画独立于 left/top 过渡) */
|
|
105
|
+
private popBox;
|
|
106
|
+
private hideBox;
|
|
107
|
+
private createSelectedBox;
|
|
108
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inspector 模块 —— 可视化元素选取(悬停高亮 + 点击选中)。
|
|
3
|
+
*
|
|
4
|
+
* host-inspector 在父窗口侧盖独立 overlay 接管指针,同源直读 iframe DOM;
|
|
5
|
+
* selector 负责把命中元素转成可抛给宿主 / AI 的结构化描述。
|
|
6
|
+
*/
|
|
7
|
+
export { HostInspector, type HostInspectorOptions } from "./host-inspector";
|
|
8
|
+
export { buildElementSelection, computeSelector } from "./selector";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 元素 → 结构化描述(ElementSelection)。
|
|
3
|
+
*
|
|
4
|
+
* 纯 DOM 计算,运行在宿主侧(同源 iframe 的 contentDocument 可直接访问)。
|
|
5
|
+
* 不依赖任何宿主全局,可对任意业务 DOM 安全求值。
|
|
6
|
+
*/
|
|
7
|
+
import type { ElementSelection } from "../types";
|
|
8
|
+
/**
|
|
9
|
+
* 计算从文档根到该元素的稳定 CSS selector。
|
|
10
|
+
* - 命中唯一 id 即作为锚点截断(短且稳定)
|
|
11
|
+
* - 否则用 tag + :nth-of-type(同标签兄弟索引) 逐级回溯
|
|
12
|
+
*/
|
|
13
|
+
export declare function computeSelector(node: Element): string;
|
|
14
|
+
/**
|
|
15
|
+
* 把元素转成可抛给宿主 / AI 的结构化描述。
|
|
16
|
+
* @param iframe 内容载体,用于把元素包围盒换算到宿主视口坐标(viewportRect)。
|
|
17
|
+
*/
|
|
18
|
+
export declare function buildElementSelection(el: Element, iframe: HTMLIFrameElement): ElementSelection;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `<miniapp-devtools-capabilities>` —— 能力管控视图。
|
|
3
|
+
*
|
|
4
|
+
* DevTools 风格组件:数据经 setter 注入 → 调度重渲染;用户操作不直接改状态,而是
|
|
5
|
+
* 冒泡 `capabilitychange`(CustomEvent,detail.allow 为新白名单),由父面板决定如何应用
|
|
6
|
+
* (触发模拟器整页 reload)。样式经 adoptedStyleSheets 适配,模板用 `html\`\`` 声明。
|
|
7
|
+
*/
|
|
8
|
+
import type { DevtoolsSnapshot } from "./types";
|
|
9
|
+
export declare const CAPABILITIES_TAG = "miniapp-devtools-capabilities";
|
|
10
|
+
/** 派发的能力变更事件名(detail: { allow: string[] }) */
|
|
11
|
+
export declare const CAPABILITY_CHANGE_EVENT = "capabilitychange";
|
|
12
|
+
export declare class CapabilitiesView extends HTMLElement {
|
|
13
|
+
#private;
|
|
14
|
+
constructor();
|
|
15
|
+
set snapshot(value: DevtoolsSnapshot | null);
|
|
16
|
+
set applying(value: boolean);
|
|
17
|
+
}
|
|
18
|
+
export declare function defineCapabilitiesView(): void;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `<miniapp-devtools>` —— 调试面板根组件(DevTools 风格的「面板外壳 + tab 切换 + 视图装配」)。
|
|
3
|
+
*
|
|
4
|
+
* 职责:
|
|
5
|
+
* - fixed 停靠窗口右侧(不进入模拟器 mount、不遮挡舞台),`[open]` 属性驱动滑入/滑出过渡;
|
|
6
|
+
* - 装配两个子视图(CapabilitiesView / LogsView),把模拟器事件流转发给日志视图;
|
|
7
|
+
* - 监听能力视图冒泡的 `capabilitychange`,调用 onApplyCapabilities(整页 reload)并自刷新;
|
|
8
|
+
* - 对外(经工厂)暴露 open/close/toggle/refresh/dispose 控制器接口。
|
|
9
|
+
*/
|
|
10
|
+
import type { DevtoolsPanelOptions } from "./types";
|
|
11
|
+
export declare const PANEL_TAG = "miniapp-devtools";
|
|
12
|
+
export declare class DevtoolsPanelElement extends HTMLElement {
|
|
13
|
+
#private;
|
|
14
|
+
constructor();
|
|
15
|
+
/** 注入模拟器侧回调(创建后立即调用) */
|
|
16
|
+
bind(options: DevtoolsPanelOptions): void;
|
|
17
|
+
get isOpen(): boolean;
|
|
18
|
+
open(): void;
|
|
19
|
+
close(): void;
|
|
20
|
+
toggle(): void;
|
|
21
|
+
refresh(): void;
|
|
22
|
+
dispose(): void;
|
|
23
|
+
}
|
|
24
|
+
export declare function defineDevtoolsPanel(): void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `<miniapp-devtools-logs>` —— 运行日志视图。
|
|
3
|
+
*
|
|
4
|
+
* 自带事件缓冲(环形上限)、文本过滤、暂停自动滚动。父面板把模拟器事件经 `push()` 灌入;
|
|
5
|
+
* 视图负责归一、增量渲染(新行 `insertAdjacentHTML` 追加,避免全量重排)。
|
|
6
|
+
*/
|
|
7
|
+
import type { MiniAppEventName } from "../../types";
|
|
8
|
+
export declare const LOGS_TAG = "miniapp-devtools-logs";
|
|
9
|
+
export declare class LogsView extends HTMLElement {
|
|
10
|
+
#private;
|
|
11
|
+
constructor();
|
|
12
|
+
connectedCallback(): void;
|
|
13
|
+
/** 灌入一条模拟器事件 */
|
|
14
|
+
push(event: MiniAppEventName | string, payload: unknown): void;
|
|
15
|
+
clear(): void;
|
|
16
|
+
}
|
|
17
|
+
export declare function defineLogsView(): void;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DevTools 风格的极简 DOM / 模板基建(零依赖,替代 lit-html)。
|
|
3
|
+
*
|
|
4
|
+
* 对齐 Chrome DevTools frontend 的工程习惯:
|
|
5
|
+
* - 组件用 `adoptedStyleSheets` 适配「构造式样式表」(co-located CSS 文本),而非内联 <style>;
|
|
6
|
+
* - 视图用标签模板 `html\`\`` 声明式描述结构,插值默认转义(防 XSS),已可信片段用 `raw()`;
|
|
7
|
+
* - 渲染走调度(rAF 合并),由 {@link RenderScheduler} 提供。
|
|
8
|
+
*/
|
|
9
|
+
/** 标记「已可信、无需转义」的 HTML 片段(如子模板拼接结果)。 */
|
|
10
|
+
declare class RawHtml {
|
|
11
|
+
readonly value: string;
|
|
12
|
+
constructor(value: string);
|
|
13
|
+
}
|
|
14
|
+
export declare function raw(value: string): RawHtml;
|
|
15
|
+
export declare function escapeHtml(value: unknown): string;
|
|
16
|
+
/**
|
|
17
|
+
* lit 风格标签模板:返回 HTML 字符串。插值默认转义;数组自动 join;
|
|
18
|
+
* `raw(...)` / 由 `html` 产出的片段视为可信不再转义。
|
|
19
|
+
*/
|
|
20
|
+
export declare function html(strings: TemplateStringsArray, ...values: unknown[]): RawHtml;
|
|
21
|
+
/** 把 `html\`\`` 结果转为最终字符串(用于 innerHTML 落地)。 */
|
|
22
|
+
export declare function toHtmlString(node: RawHtml): string;
|
|
23
|
+
/**
|
|
24
|
+
* 把若干 CSS 文本以「构造式样式表」适配进 shadow root(DevTools 习惯)。
|
|
25
|
+
* 同一份 CSS 文本只构造一次并跨组件复用。不支持的环境降级为内联 <style>。
|
|
26
|
+
*/
|
|
27
|
+
export declare function adoptStyles(shadow: ShadowRoot, cssTexts: string[]): void;
|
|
28
|
+
/** 幂等注册自定义元素。 */
|
|
29
|
+
export declare function defineComponent(tag: string, ctor: CustomElementConstructor): void;
|
|
30
|
+
/**
|
|
31
|
+
* rAF 合并的渲染调度器:多次 schedule 只触发一次 render。
|
|
32
|
+
*/
|
|
33
|
+
export declare class RenderScheduler {
|
|
34
|
+
#private;
|
|
35
|
+
private readonly render;
|
|
36
|
+
constructor(render: () => void);
|
|
37
|
+
schedule(): void;
|
|
38
|
+
flushCancel(): void;
|
|
39
|
+
}
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Debug DevTools 面板出口(Chrome DevTools frontend 风格)。
|
|
3
|
+
*
|
|
4
|
+
* 仅在 `createMiniAppSimulator({ debug: true })` 时由模拟器内部实例化,
|
|
5
|
+
* 通过 `Shift + Cmd/Ctrl + U` 快捷键唤起。架构:
|
|
6
|
+
* - 组件化自定义元素(`<miniapp-devtools>` 装配 capabilities / logs 两个子视图)
|
|
7
|
+
* - adoptedStyleSheets 构造式样式表 + 设计 token,子视图经 setter 注入、CustomEvent 上报
|
|
8
|
+
* 能力:
|
|
9
|
+
* - 能力管控(封印能力枚举 + 动态启停并重载)
|
|
10
|
+
* - 运行日志 / 关键事件实时流
|
|
11
|
+
*/
|
|
12
|
+
import type { DevtoolsPanel, DevtoolsPanelOptions } from "./types";
|
|
13
|
+
/**
|
|
14
|
+
* 创建并挂载调试面板,返回控制器。面板默认挂到 `document.body`,以 fixed 停靠窗口右侧。
|
|
15
|
+
*/
|
|
16
|
+
export declare function createDevtoolsPanel(options: DevtoolsPanelOptions): DevtoolsPanel;
|
|
17
|
+
export { registerDevtoolsShortcut } from "./shortcut";
|
|
18
|
+
export { DEVTOOLS_PANEL_WIDTH } from "./tokens";
|
|
19
|
+
export type { DevtoolsPanel, DevtoolsPanelOptions, DevtoolsSnapshot, DevtoolsLogEntry, } from "./types";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 事件 → 日志条目归一。模拟器各类事件 payload 形态不同,这里收敛成统一的
|
|
3
|
+
* `{ timestamp, event, message, level }`,供 LogsView 渲染。
|
|
4
|
+
*/
|
|
5
|
+
import type { MiniAppEventName } from "../../types";
|
|
6
|
+
import type { DevtoolsLogEntry } from "./types";
|
|
7
|
+
export declare function toLogEntry(event: MiniAppEventName | string, payload: unknown): DevtoolsLogEntry;
|
|
8
|
+
export declare function formatLogTime(ts: number): string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DevTools 唤起快捷键:
|
|
3
|
+
* - macOS:`Shift + Command + U`
|
|
4
|
+
* - 其他平台:`Shift + Ctrl + U`
|
|
5
|
+
*
|
|
6
|
+
* 监听挂在 capture 阶段的 document 上。注意:当焦点位于小应用 iframe 内部时,
|
|
7
|
+
* 父文档收不到该 keydown,此时需先点击手机外区域再触发(已在文档说明)。
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* 注册唤起快捷键,返回卸载函数。
|
|
11
|
+
*/
|
|
12
|
+
export declare function registerDevtoolsShortcut(onTrigger: () => void, target?: Document): () => void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 设计 token(CSS 变量,暗色玻璃拟态主题)。
|
|
3
|
+
*
|
|
4
|
+
* 对齐 Chrome DevTools 的 `--sys-color-*` 思路:所有组件共享同一份 token 样式表
|
|
5
|
+
* (经 `adoptStyles` 适配进各自 shadow root),具体组件样式只引用变量,便于统一换肤。
|
|
6
|
+
*/
|
|
7
|
+
/** 面板停靠宽度(px);与 token --dt-width 同步,供 JS 侧引用。 */
|
|
8
|
+
export declare const DEVTOOLS_PANEL_WIDTH = 420;
|
|
9
|
+
export declare const TOKENS_CSS = "\n:host {\n --dt-width: 420px;\n\n --dt-fg: #e8eaf0;\n --dt-fg-2: rgba(232, 234, 240, 0.72);\n --dt-fg-3: rgba(232, 234, 240, 0.45);\n --dt-fg-4: rgba(232, 234, 240, 0.38);\n\n --dt-bg: linear-gradient(180deg, rgba(20, 22, 30, 0.92) 0%, rgba(14, 15, 22, 0.94) 100%);\n --dt-surface: rgba(255, 255, 255, 0.05);\n --dt-surface-2: rgba(255, 255, 255, 0.08);\n --dt-surface-hover: rgba(255, 255, 255, 0.12);\n --dt-border: rgba(255, 255, 255, 0.08);\n --dt-border-soft: rgba(255, 255, 255, 0.04);\n\n --dt-accent: #ff2442;\n --dt-accent-2: #ff6b81;\n --dt-ok: #4ade80;\n --dt-err: #ff7a72;\n --dt-warn: #ffd166;\n --dt-host: #7ab0ff;\n\n --dt-radius: 8px;\n --dt-radius-pill: 999px;\n --dt-font: 13px/1.5 -apple-system, BlinkMacSystemFont, \"Segoe UI\", \"PingFang SC\", sans-serif;\n --dt-mono: 11.5px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;\n}\n";
|
|
10
|
+
/**
|
|
11
|
+
* 通用控件样式(滚动区 / 工具条 / 输入框 / 按钮 / 空态),各视图共享适配,
|
|
12
|
+
* 避免每个组件重复声明。仅引用 token 变量。
|
|
13
|
+
*/
|
|
14
|
+
export declare const BASE_CSS = "\n*, *::before, *::after { box-sizing: border-box; }\n.dt-content {\n display: flex;\n flex-direction: column;\n min-height: 0;\n height: 100%;\n}\n.dt-scroll {\n flex: 1 1 auto;\n min-height: 0;\n overflow-y: auto;\n overflow-x: hidden;\n padding: 4px 0 14px;\n}\n.dt-scroll::-webkit-scrollbar { width: 8px; }\n.dt-scroll::-webkit-scrollbar-thumb {\n background: rgba(255, 255, 255, 0.14);\n border-radius: 8px;\n}\n.dt-toolbar {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 10px 14px;\n flex: none;\n}\n.dt-input {\n flex: 1 1 auto;\n min-width: 0;\n height: 30px;\n padding: 0 10px;\n border-radius: var(--dt-radius);\n border: 1px solid rgba(255, 255, 255, 0.1);\n background: var(--dt-surface);\n color: var(--dt-fg);\n font-size: 12px;\n outline: none;\n}\n.dt-input::placeholder { color: var(--dt-fg-4); }\n.dt-input:focus { border-color: rgba(255, 36, 66, 0.5); }\n.dt-btn {\n height: 30px;\n padding: 0 12px;\n border-radius: var(--dt-radius);\n border: 1px solid rgba(255, 255, 255, 0.1);\n background: var(--dt-surface);\n color: var(--dt-fg-2);\n font-size: 12px;\n cursor: pointer;\n white-space: nowrap;\n transition: background 0.15s, border-color 0.15s;\n}\n.dt-btn:hover { background: var(--dt-surface-hover); }\n.dt-btn[aria-pressed=\"true\"] {\n border-color: rgba(255, 36, 66, 0.55);\n color: var(--dt-accent-2);\n}\n.dt-empty {\n padding: 40px 24px;\n text-align: center;\n font-size: 12px;\n color: var(--dt-fg-4);\n}\n";
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { MiniAppCapability } from "../../seal-config";
|
|
2
|
+
import type { MiniAppEventName } from "../../types";
|
|
3
|
+
/** 调试面板从模拟器读取的当前快照(每次 open / refresh 调用) */
|
|
4
|
+
export interface DevtoolsSnapshot {
|
|
5
|
+
/** 当前生效的 seal allow 白名单(已展开默认值;即便使用 DEFAULT_ALLOW 也是具体数组) */
|
|
6
|
+
allow: ReadonlyArray<MiniAppCapability>;
|
|
7
|
+
/** 是否为消费方显式传入的 sealAllow(false = 当前用 seal 内置 DEFAULT_ALLOW) */
|
|
8
|
+
custom: boolean;
|
|
9
|
+
renderer: string;
|
|
10
|
+
contentMode: string;
|
|
11
|
+
viewport: {
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
};
|
|
15
|
+
appUrl: string;
|
|
16
|
+
}
|
|
17
|
+
/** 单条日志条目 */
|
|
18
|
+
export interface DevtoolsLogEntry {
|
|
19
|
+
timestamp: number;
|
|
20
|
+
event: MiniAppEventName | string;
|
|
21
|
+
message: string;
|
|
22
|
+
level: "info" | "ok" | "warn" | "error" | "blocked";
|
|
23
|
+
}
|
|
24
|
+
export interface DevtoolsPanelOptions {
|
|
25
|
+
/**
|
|
26
|
+
* 面板挂载根,默认 `document.body`。面板以 fixed 停靠窗口右侧,不进入模拟器
|
|
27
|
+
* mount 容器,因此不遮挡 / 不压缩手机舞台。
|
|
28
|
+
*/
|
|
29
|
+
mountRoot?: HTMLElement;
|
|
30
|
+
/** 读取当前模拟器快照(用于能力 Tab 与信息条渲染) */
|
|
31
|
+
getSnapshot: () => DevtoolsSnapshot;
|
|
32
|
+
/**
|
|
33
|
+
* 应用新的能力白名单(会触发模拟器整页 reload)。
|
|
34
|
+
* resolve 后面板用最新 snapshot 重渲染能力列表。
|
|
35
|
+
*/
|
|
36
|
+
onApplyCapabilities: (sealAllow: MiniAppCapability[]) => Promise<void> | void;
|
|
37
|
+
/** 订阅模拟器事件流,返回退订函数 */
|
|
38
|
+
subscribe: (handler: (event: MiniAppEventName | string, payload: unknown) => void) => () => void;
|
|
39
|
+
/** 面板显隐变化回调(如收窄/还原 bounds 之外的联动) */
|
|
40
|
+
onOpenChange?: (open: boolean) => void;
|
|
41
|
+
}
|
|
42
|
+
/** 调试面板控制器 */
|
|
43
|
+
export interface DevtoolsPanel {
|
|
44
|
+
open(): void;
|
|
45
|
+
close(): void;
|
|
46
|
+
toggle(): void;
|
|
47
|
+
readonly isOpen: boolean;
|
|
48
|
+
/** 重新从 snapshot 渲染能力列表(reload 后由模拟器调用) */
|
|
49
|
+
refresh(): void;
|
|
50
|
+
destroy(): void;
|
|
51
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Native UI 模块出口。
|
|
3
|
+
*
|
|
4
|
+
* 包含"小应用 jsapi 调用时由模拟器渲染的、模拟真机原生界面的 UI 组件":
|
|
5
|
+
* - `toast` - 顶部短提示(对应真机 `showToast`)
|
|
6
|
+
* - `permission-sheet` - 权限授权 bottom sheet(对应真机系统弹窗)
|
|
7
|
+
* - `rednote-preview` - 小红书笔记 Feed / 详情壳层
|
|
8
|
+
*
|
|
9
|
+
* 这些组件由 simulator 在内部按需挂载,通过 BridgeProtocol 接收 jsapi 路由后渲染。
|
|
10
|
+
* 与 `hostApi`(宿主能力委托)的区别:native-ui 是"模拟器内置实现",hostApi 是"宿主真实能力"。
|
|
11
|
+
*/
|
|
12
|
+
export { showHostToast, type HostToastFn, type HostToastOptions } from "./toast";
|
|
13
|
+
export { FrameToastHost, type FrameToastOptions } from "./toast/frame-toast-host";
|
|
14
|
+
export { PermissionSheetHost, type PermissionSheetHostOptions, type PermissionSheetShowOptions, } from "./permission-sheet/permission-sheet-host";
|
|
15
|
+
export type { MiniAppPermissionKind, MiniAppPermissionSheetResult, } from "./permission-sheet/types";
|
|
16
|
+
export { registerRednotePreviewElements, mergeNotePreview, XHS_NOTE_DETAIL_SHELL_TAG, type XhsNoteDetailShell, } from "./rednote-preview";
|
|
17
|
+
export { NotePublishHost, type NotePublishHostOptions, toNotePublishViewData, type NoteMedia, type NotePublishResult, type NotePublishViewData, } from "./note-publish";
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export declare const NOTE_PUBLISH_TEXT: {
|
|
2
|
+
readonly titlePlaceholder: "添加标题";
|
|
3
|
+
readonly contentPlaceholder: "添加正文或发语音";
|
|
4
|
+
readonly location: "标记地点";
|
|
5
|
+
readonly visibility: "公开可见";
|
|
6
|
+
readonly addComponent: "添加组件";
|
|
7
|
+
readonly advanced: "高级选项";
|
|
8
|
+
readonly topic: "话题";
|
|
9
|
+
readonly mention: "用户";
|
|
10
|
+
readonly vote: "投票";
|
|
11
|
+
readonly chooseCover: "选封面";
|
|
12
|
+
readonly livePhoto: "实况";
|
|
13
|
+
readonly saveDraft: "存草稿";
|
|
14
|
+
readonly publish: "发布笔记";
|
|
15
|
+
};
|
|
16
|
+
export declare const NOTE_PUBLISH_ICON: {
|
|
17
|
+
readonly navBar: "https://fe-platform.xhscdn.com/platform/104101l0323g0lkiknu0m277180ac7t8006ptl0akiev06.png";
|
|
18
|
+
readonly statusLevels: "https://fe-platform.xhscdn.com/platform/104101l0323g0lkih7a06277180ac7t8006ptl0b0qgdka.png";
|
|
19
|
+
readonly homeIndicator: "https://fe-platform.xhscdn.com/platform/104101l0323g0lkipga06277180ac7t8006ptl0dehcmn4.png";
|
|
20
|
+
readonly voice: "https://fe-platform.xhscdn.com/platform/104101l0323g0lki10206277180ac7t8006ptl0br01bmu.png";
|
|
21
|
+
readonly location: "https://fe-platform.xhscdn.com/platform/104101l0323g0lkiknk0m277180ac7t8006ptl0e7n5ldm.png";
|
|
22
|
+
readonly visibility: "https://fe-platform.xhscdn.com/platform/104101l0323g0lkiknk06277180ac7t8006ptl0e1f6908.png";
|
|
23
|
+
readonly addComponent: "https://fe-platform.xhscdn.com/platform/104101l0323g0lki07k06277180ac7t8006ptl0ck0o7v8.png";
|
|
24
|
+
readonly setting: "https://fe-platform.xhscdn.com/platform/104101l0323g0lki07u06277180ac7t8006ptl09f764ic.png";
|
|
25
|
+
readonly chevron: "https://fe-platform.xhscdn.com/platform/104101l0323g0lkij7a06277180ac7t8006ptl0aholfs6.png";
|
|
26
|
+
readonly topic: "https://fe-platform.xhscdn.com/platform/104101l0323g0lkiqna06277180ac7t8006ptl0ckpb7vo.png";
|
|
27
|
+
readonly mention: "https://fe-platform.xhscdn.com/platform/104101l0323g0lki1nu76277180ac7t8006ptl0e2eecng.png";
|
|
28
|
+
readonly vote: "https://fe-platform.xhscdn.com/platform/104101l0323g0lki07k0m277180ac7t8006ptl0bpvoc3i.png";
|
|
29
|
+
readonly videoBadge: "https://fe-platform.xhscdn.com/platform/104101l0323g0ofcn0206277180ac7t8006ptl0ctk6mds.png";
|
|
30
|
+
};
|
|
31
|
+
export declare const NOTE_PUBLISH_COLOR: {
|
|
32
|
+
readonly red: "#FF2442";
|
|
33
|
+
readonly title: "rgba(0, 0, 0, 0.8)";
|
|
34
|
+
readonly placeholder: "rgba(0, 0, 0, 0.27)";
|
|
35
|
+
readonly chipBg: "#F5F5F5";
|
|
36
|
+
readonly border: "rgba(0, 0, 0, 0.08)";
|
|
37
|
+
readonly coverBadgeBg: "rgba(48, 48, 52, 0.5)";
|
|
38
|
+
readonly chooseCoverBg: "rgba(0, 0, 0, 0.65)";
|
|
39
|
+
readonly chooseCoverBorder: "rgba(255, 255, 255, 0.3)";
|
|
40
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { NotePublishResult, NotePublishViewData } from "./view-data";
|
|
2
|
+
export declare class MiniappNotePublish extends HTMLElement {
|
|
3
|
+
private _panelEl;
|
|
4
|
+
private _resolve;
|
|
5
|
+
connectedCallback(): void;
|
|
6
|
+
present(data: NotePublishViewData): Promise<NotePublishResult>;
|
|
7
|
+
hide(): void;
|
|
8
|
+
private finish;
|
|
9
|
+
private settle;
|
|
10
|
+
private syncOpen;
|
|
11
|
+
private renderContent;
|
|
12
|
+
private render;
|
|
13
|
+
}
|
|
14
|
+
export declare function registerMiniappNotePublish(): void;
|
|
15
|
+
export declare function createMiniappNotePublishElement(): MiniappNotePublish;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { NotePublishResult, NotePublishViewData } from "./view-data";
|
|
2
|
+
export interface NotePublishHostOptions {
|
|
3
|
+
onOpenChange?: (open: boolean) => void;
|
|
4
|
+
}
|
|
5
|
+
export declare class NotePublishHost {
|
|
6
|
+
private readonly mountEl;
|
|
7
|
+
private readonly options;
|
|
8
|
+
private readonly page;
|
|
9
|
+
private mounted;
|
|
10
|
+
constructor(mountEl: HTMLElement, options?: NotePublishHostOptions);
|
|
11
|
+
mount(): void;
|
|
12
|
+
show(data: NotePublishViewData): Promise<NotePublishResult>;
|
|
13
|
+
hide(): void;
|
|
14
|
+
destroy(): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type NoteMedia = {
|
|
2
|
+
type: "image";
|
|
3
|
+
url: string;
|
|
4
|
+
} | {
|
|
5
|
+
type: "video";
|
|
6
|
+
url: string;
|
|
7
|
+
cover?: string;
|
|
8
|
+
} | {
|
|
9
|
+
type: "live_photo";
|
|
10
|
+
url: string;
|
|
11
|
+
cover: string;
|
|
12
|
+
};
|
|
13
|
+
export interface NotePublishViewData {
|
|
14
|
+
title: string;
|
|
15
|
+
content: string;
|
|
16
|
+
media: NoteMedia[];
|
|
17
|
+
tags: string[];
|
|
18
|
+
pageType?: string;
|
|
19
|
+
}
|
|
20
|
+
export type NotePublishResult = "publish" | "cancel";
|
|
21
|
+
export declare function toNotePublishViewData(message: Record<string, unknown>): NotePublishViewData;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { MiniAppPermissionItem, MiniAppPermissionKind } from "./types";
|
|
2
|
+
/** 设计稿固定文案 */
|
|
3
|
+
export declare const PERMISSION_PRESETS: Record<MiniAppPermissionKind, MiniAppPermissionItem>;
|
|
4
|
+
/**
|
|
5
|
+
* V1 permission-gate 入口写死:未来由业务勾选覆盖。
|
|
6
|
+
* gate 脚本将根据该列表决定包装 getUserMedia / 拦截 file 等。
|
|
7
|
+
*/
|
|
8
|
+
export declare const V1_PERMISSION_GATE_ENABLED: MiniAppPermissionKind[];
|
|
9
|
+
export declare const PERMISSION_SHEET_TITLE = "\u5C0F\u5DE5\u5177\u7533\u8BF7\u4F7F\u7528\u4EE5\u4E0B\u6743\u9650";
|
|
10
|
+
export declare const PERMISSION_SHEET_CANCEL_LABEL = "\u53D6\u6D88";
|
|
11
|
+
export declare const PERMISSION_SHEET_GRANT_LABEL = "\u540C\u610F\u6388\u6743";
|
|
12
|
+
export declare function buildPermissionItems(kinds: MiniAppPermissionKind[]): MiniAppPermissionItem[];
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type { MiniAppPermissionKind, MiniAppPermissionItem, MiniAppPermissionSheetResult, } from "./types";
|
|
2
|
+
export { buildPermissionItems, PERMISSION_PRESETS, PERMISSION_SHEET_TITLE, V1_PERMISSION_GATE_ENABLED, } from "./defaults";
|
|
3
|
+
export { createMiniappPermissionSheetElement, registerMiniappPermissionSheet, MiniappPermissionSheet, } from "./miniapp-permission-sheet";
|
|
4
|
+
export { PermissionSheetHost, type PermissionSheetShowOptions } from "./permission-sheet-host";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { MiniAppPermissionItem, MiniAppPermissionSheetResult } from "./types";
|
|
2
|
+
export declare class MiniappPermissionSheet extends HTMLElement {
|
|
3
|
+
private _backdropEl;
|
|
4
|
+
private _panelEl;
|
|
5
|
+
private _listEl;
|
|
6
|
+
private _resolve;
|
|
7
|
+
static get observedAttributes(): string[];
|
|
8
|
+
connectedCallback(): void;
|
|
9
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
10
|
+
/** 展示授权 Sheet,返回用户选择 */
|
|
11
|
+
present(items: MiniAppPermissionItem[]): Promise<MiniAppPermissionSheetResult>;
|
|
12
|
+
hide(): void;
|
|
13
|
+
private finish;
|
|
14
|
+
private syncOpenAttr;
|
|
15
|
+
private renderList;
|
|
16
|
+
private render;
|
|
17
|
+
}
|
|
18
|
+
export declare function registerMiniappPermissionSheet(): void;
|
|
19
|
+
export declare function createMiniappPermissionSheetElement(): MiniappPermissionSheet;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { MiniAppPermissionKind, MiniAppPermissionSheetResult } from "./types";
|
|
2
|
+
export interface PermissionSheetShowOptions {
|
|
3
|
+
/** 要展示的权限项;省略则使用 V1_PERMISSION_GATE_ENABLED 全量 */
|
|
4
|
+
kinds?: MiniAppPermissionKind[];
|
|
5
|
+
}
|
|
6
|
+
export interface PermissionSheetHostOptions {
|
|
7
|
+
/** Sheet 显隐变化(用于暂时关闭 gesture overlay 等上层拦截) */
|
|
8
|
+
onOpenChange?: (open: boolean) => void;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* 宿主侧权限 Sheet 控制器:挂载在 iframe 的 contentRoot 上,覆盖手机框视口。
|
|
12
|
+
*/
|
|
13
|
+
export declare class PermissionSheetHost {
|
|
14
|
+
private readonly mountEl;
|
|
15
|
+
private readonly options;
|
|
16
|
+
private readonly sheet;
|
|
17
|
+
private mounted;
|
|
18
|
+
constructor(mountEl: HTMLElement, options?: PermissionSheetHostOptions);
|
|
19
|
+
mount(): void;
|
|
20
|
+
show(options?: PermissionSheetShowOptions): Promise<MiniAppPermissionSheetResult>;
|
|
21
|
+
hide(): void;
|
|
22
|
+
destroy(): void;
|
|
23
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** 第一版支持的权限种类(与 MiniTool 规范 §3 允许项对齐) */
|
|
2
|
+
export type MiniAppPermissionKind = "album" | "camera" | "microphone";
|
|
3
|
+
export interface MiniAppPermissionItem {
|
|
4
|
+
kind: MiniAppPermissionKind;
|
|
5
|
+
title: string;
|
|
6
|
+
description: string;
|
|
7
|
+
}
|
|
8
|
+
export type MiniAppPermissionSheetResult = "grant" | "cancel";
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 顶部 chrome(状态栏时间/信号 + 半屏全屏态返回/分享/更多)底色自适应探测。
|
|
3
|
+
*
|
|
4
|
+
* 背景:小工具半屏拖全后做沉浸式导航,顶部 svg / 状态栏浮于小程序内容之上。
|
|
5
|
+
* 若小程序底色偏深,默认的白色图标尚可见;若底色偏亮,白色图标几乎不可见。
|
|
6
|
+
* 故对 iframe(同源 srcdoc)内容顶部区域采样底色,按通用亮度公式判定明暗,
|
|
7
|
+
* 自动切换 chrome 前景明暗,保证任意底色下都有足够对比度。
|
|
8
|
+
*
|
|
9
|
+
* tone 语义(描述「前景应使用的明暗」,与背景相反):
|
|
10
|
+
* - "light" → 浅色前景(白图标 / 白拖杆),适配深色背景
|
|
11
|
+
* - "dark" → 深色前景(黑图标 / 深拖杆),适配浅色背景
|
|
12
|
+
*/
|
|
13
|
+
export type ChromeTone = "light" | "dark";
|
|
14
|
+
/** 默认 tone:深色前景对应浅底,但模拟器默认底色未知,按设计稿默认浅色前景(深底) */
|
|
15
|
+
export declare const DEFAULT_CHROME_TONE: ChromeTone;
|
|
16
|
+
/** 通用亮度阈值:Y > 128 视为亮底(用深色前景),Y ≤ 128 视为暗底(用浅色前景) */
|
|
17
|
+
export declare const LUMINANCE_THRESHOLD = 128;
|
|
18
|
+
interface Rgb {
|
|
19
|
+
r: number;
|
|
20
|
+
g: number;
|
|
21
|
+
b: number;
|
|
22
|
+
}
|
|
23
|
+
/** 通用亮度公式 Y = 0.299R + 0.587G + 0.114B(0–255) */
|
|
24
|
+
export declare function relativeLuminance({ r, g, b }: Rgb): number;
|
|
25
|
+
/** 亮度转 tone:亮底用深前景,暗底用浅前景 */
|
|
26
|
+
export declare function luminanceToTone(luminance: number): ChromeTone;
|
|
27
|
+
/**
|
|
28
|
+
* 解析 getComputedStyle 返回的背景色(仅 rgb()/rgba(),浏览器计算值恒为此形式)。
|
|
29
|
+
* 返回含 alpha;无法解析或全透明返回 null。
|
|
30
|
+
*/
|
|
31
|
+
export declare function parseCssColor(value: string | null | undefined): (Rgb & {
|
|
32
|
+
a: number;
|
|
33
|
+
}) | null;
|
|
34
|
+
/**
|
|
35
|
+
* 自元素向上回溯祖先链,取第一个不透明(alpha ≥ 0.5)的背景色。
|
|
36
|
+
* 全链透明时回退到浏览器默认白底。
|
|
37
|
+
*/
|
|
38
|
+
export declare function resolveBackgroundColor(el: Element | null, view: Window & typeof globalThis): Rgb;
|
|
39
|
+
/**
|
|
40
|
+
* 探测同源 iframe 顶部内容底色对应的 chrome tone。
|
|
41
|
+
* 跨域或文档未就绪时返回 null(调用方据此保留当前 tone)。
|
|
42
|
+
*/
|
|
43
|
+
export declare function detectChromeToneFromIframe(iframe: HTMLIFrameElement): ChromeTone | null;
|
|
44
|
+
export {};
|