@skillbuilder/miniapp-simulator 0.2.4 → 0.2.7
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/docs/audit-data-collection.codex.md +76 -393
- package/docs/audit-local-validation.codex.md +1 -1
- package/docs/audit-score-design.codex.md +23 -22
- package/docs/audit-score-design.md +39 -92
- package/docs/audit-score-tech-plan.md +6 -4
- package/docs/audit-tech-design.codex.md +36 -19
- package/docs/electron-review.md +1 -1
- package/docs/quality-evaluation-redoc.xml +4 -4
- package/docs/tracker.md +3 -2
- package/lib/client-BjYHK9LR.mjs +1220 -0
- package/lib/{index-7MeYFlk_.mjs → index-CqClPZVv.mjs} +158 -140
- package/lib/index.js +1885 -1819
- package/lib/remote-client.js +2 -2
- package/lib/types/host/shadow-host.d.ts +2 -2
- package/lib/types/remote/audit-controller.d.ts +5 -0
- package/lib/types/remote/audit-package-sources.d.ts +9 -0
- package/lib/types/remote/audit-telemetry.d.ts +25 -12
- package/lib/types/remote/protocol.d.ts +14 -3
- package/lib/types/runtime/jsapi-modules/interaction.d.ts +1 -1
- package/lib/types/runtime/jsapi-modules/local-media.d.ts +4 -0
- package/lib/types/runtime/jsapi-modules/media.d.ts +1 -1
- package/lib/types/runtime/jsapi-modules/note-publish-media.d.ts +9 -0
- package/lib/types/tracker/constants.d.ts +1 -1
- package/lib/types/tracker/default-tracker.d.ts +1 -1
- package/lib/types/types/options.d.ts +2 -2
- package/lib/workbench.js +1 -1
- package/package.json +1 -1
- package/lib/client-BDt3WDu_.mjs +0 -1118
package/lib/remote-client.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { R as r, a as O, c as e } from "./client-
|
|
1
|
+
import { R as r, a as O, c as e } from "./client-BjYHK9LR.mjs";
|
|
2
2
|
import { B as s, M as _ } from "./options-B34ipLmF.mjs";
|
|
3
|
-
import { M } from "./index-
|
|
3
|
+
import { M } from "./index-CqClPZVv.mjs";
|
|
4
4
|
export {
|
|
5
5
|
s as BusinessLine,
|
|
6
6
|
_ as MINIAPP_SCREENSHOT_ERROR_CODE,
|
|
@@ -39,8 +39,8 @@ export interface MiniAppShadowHost {
|
|
|
39
39
|
* 盖住后审核员既看不到小工具也点不到它。
|
|
40
40
|
*/
|
|
41
41
|
sidePanel: HTMLElement;
|
|
42
|
-
/**
|
|
43
|
-
setSidePanelWidth(width: number): void;
|
|
42
|
+
/** 设置侧栏最小/最大宽度;传 0 收起。bounds 自动让出对应宽度。 */
|
|
43
|
+
setSidePanelWidth(width: number, maxWidth?: number): void;
|
|
44
44
|
/** 销毁:移除创建的宿主元素 */
|
|
45
45
|
destroy(): void;
|
|
46
46
|
}
|
|
@@ -5,6 +5,11 @@ export interface AuditPackageSnapshot {
|
|
|
5
5
|
path: string;
|
|
6
6
|
size: number;
|
|
7
7
|
}>;
|
|
8
|
+
sources?: Array<{
|
|
9
|
+
path: string;
|
|
10
|
+
text: string;
|
|
11
|
+
}>;
|
|
12
|
+
sourceScanComplete?: boolean;
|
|
8
13
|
}
|
|
9
14
|
export interface AuditControllerDeps {
|
|
10
15
|
/** 当前 simulator 实例(需支持 registerInjection / reload) */
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { MiniAppFileMap } from "../types";
|
|
2
|
+
/** 源码仅供远程评测插件静态扫描,使用字符串避免 loadFiles 转移 ArrayBuffer 后失效。 */
|
|
3
|
+
export declare function collectAuditSources(files: MiniAppFileMap): {
|
|
4
|
+
sources: Array<{
|
|
5
|
+
path: string;
|
|
6
|
+
text: string;
|
|
7
|
+
}>;
|
|
8
|
+
sourceScanComplete: boolean;
|
|
9
|
+
};
|
|
@@ -1,23 +1,36 @@
|
|
|
1
1
|
export type AuditApmFields = Record<string, string | number | null | undefined>;
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
export interface AuditMetricRecord extends AuditApmFields {
|
|
3
|
+
name: string;
|
|
4
|
+
time?: number;
|
|
5
|
+
memory?: number;
|
|
6
|
+
size?: number;
|
|
7
|
+
score?: number;
|
|
8
|
+
weight?: number;
|
|
9
|
+
ratio?: number;
|
|
10
|
+
value?: number;
|
|
11
|
+
unit?: string;
|
|
12
|
+
count?: number;
|
|
13
|
+
result?: string;
|
|
14
|
+
}
|
|
15
|
+
/** 仅清理缺失和非法数值,不推断字段名、类型或单位。 */
|
|
16
|
+
export declare function compactFields(fields: AuditApmFields): AuditApmFields;
|
|
17
|
+
/** 首屏直接指定 time,不依赖输入字段名称推断。 */
|
|
18
|
+
export declare function toAuditPaintRecords(input: unknown, emit?: {
|
|
19
|
+
fcp: boolean;
|
|
20
|
+
lcp: boolean;
|
|
21
|
+
}): AuditApmFields[];
|
|
22
|
+
interface PackageMetadata {
|
|
5
23
|
appType?: string;
|
|
6
24
|
declaredAppType?: string;
|
|
7
25
|
features?: string[];
|
|
8
|
-
policyVersion?: string;
|
|
9
|
-
rulesVersion?: string;
|
|
10
|
-
probeVersion?: string;
|
|
11
26
|
}
|
|
12
|
-
|
|
13
|
-
export declare function toAuditPackageFields(pkg: {
|
|
27
|
+
export declare function toAuditPackageRecords(pkg: {
|
|
14
28
|
zipBytes: number;
|
|
15
29
|
files: Array<{
|
|
16
30
|
path: string;
|
|
17
31
|
size: number;
|
|
18
32
|
}>;
|
|
19
|
-
}, metadata:
|
|
20
|
-
/**
|
|
21
|
-
export declare function
|
|
22
|
-
export declare function compactFields(fields: AuditApmFields): AuditApmFields;
|
|
33
|
+
}, metadata: PackageMetadata, uncompressedJsThresholdBytes: number): AuditApmFields[];
|
|
34
|
+
/** 终态:每个指标同时携带实测值、得分和权重,诊断状态集中在摘要中。 */
|
|
35
|
+
export declare function toAuditResultRecords(report: unknown, metrics?: unknown): AuditApmFields[];
|
|
23
36
|
export {};
|
|
@@ -50,7 +50,7 @@ export interface RemoteAuditContext {
|
|
|
50
50
|
}
|
|
51
51
|
/** Runtime 发给宿主的内部评测点位;只允许扁平标量字段。 */
|
|
52
52
|
export interface RemoteAuditTelemetryPayload {
|
|
53
|
-
name: "miniapp_audit_session" | "
|
|
53
|
+
name: "miniapp_audit_session" | "miniapp_audit_paint" | "miniapp_audit_incident" | "miniapp_audit_package" | "miniapp_audit_result";
|
|
54
54
|
sessionId: string;
|
|
55
55
|
fields: Record<string, string | number | null | undefined>;
|
|
56
56
|
flush?: boolean;
|
|
@@ -196,7 +196,7 @@ export interface RemoteAuditStartArgs {
|
|
|
196
196
|
*/
|
|
197
197
|
durationMs?: number;
|
|
198
198
|
armingMs?: number;
|
|
199
|
-
declaredAppType?: "tool" | "game2d" | "game3d"
|
|
199
|
+
declaredAppType?: "tool" | "game2d" | "game3d";
|
|
200
200
|
}
|
|
201
201
|
/**
|
|
202
202
|
* 评测报告的跨 iframe 序列化契约。
|
|
@@ -274,8 +274,19 @@ export interface RemoteAuditReport {
|
|
|
274
274
|
interactionCount: number;
|
|
275
275
|
firstInteractionAt?: number;
|
|
276
276
|
};
|
|
277
|
-
appType: "tool" | "game2d" | "game3d"
|
|
277
|
+
appType: "tool" | "game2d" | "game3d";
|
|
278
278
|
tagMismatch: boolean;
|
|
279
|
+
classification?: {
|
|
280
|
+
engine?: string;
|
|
281
|
+
evidence: string[];
|
|
282
|
+
inferred: boolean;
|
|
283
|
+
frameworks?: Array<{
|
|
284
|
+
id: string;
|
|
285
|
+
confidence: "strong" | "candidate";
|
|
286
|
+
evidence: string[];
|
|
287
|
+
}>;
|
|
288
|
+
sourceScanComplete?: boolean;
|
|
289
|
+
};
|
|
279
290
|
versions: {
|
|
280
291
|
policyVersion: string;
|
|
281
292
|
rulesVersion: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { SimulatorJsapiContext } from "./context";
|
|
2
2
|
import type { SimulatorJsapiModule } from "./types";
|
|
3
|
-
export type InteractionJsapiModuleContext = Pick<SimulatorJsapiContext, "overlayRoot" | "showNotePublish" | "vibrate">;
|
|
3
|
+
export type InteractionJsapiModuleContext = Pick<SimulatorJsapiContext, "overlayRoot" | "showNotePublish" | "vibrate" | "loadedUrl" | "fileSystemHost" | "fileSystemMountId" | "appId">;
|
|
4
4
|
export declare function createInteractionJsapiModule(context: InteractionJsapiModuleContext): SimulatorJsapiModule;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type SimulatorFileSystemContext } from "./filesystem";
|
|
2
|
+
export declare const SIMULATOR_FILE_MARKER = "/_xhsfile_/";
|
|
3
|
+
/** Read virtual media through its app-scoped bridge, including outside the SW scope. */
|
|
4
|
+
export declare function readSimulatorMediaBlob(context: SimulatorFileSystemContext, source: string): Promise<Blob>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type MiniAppHostApiHandler } from "../../types";
|
|
2
|
-
import {
|
|
2
|
+
import type { SimulatorFileSystemContext } from "./filesystem";
|
|
3
3
|
import type { SimulatorJsapiModule } from "./types";
|
|
4
4
|
/** The simulator state used by browser media APIs. */
|
|
5
5
|
export interface MediaJsapiModuleContext extends SimulatorFileSystemContext {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { NotePublishViewData } from "../../native-ui/note-publish";
|
|
2
|
+
import type { SimulatorFileSystemContext } from "./filesystem";
|
|
3
|
+
/** Object URLs belong to one preview and are released when it settles or fails to prepare. */
|
|
4
|
+
export declare function createNotePublishMediaResolver(context: SimulatorFileSystemContext & {
|
|
5
|
+
readonly loadedUrl: string;
|
|
6
|
+
}): {
|
|
7
|
+
prepare(data: NotePublishViewData): Promise<NotePublishViewData>;
|
|
8
|
+
dispose(): void;
|
|
9
|
+
};
|
|
@@ -8,7 +8,7 @@ export declare const APM_ENDPOINT: Record<MiniAppApmRegion, {
|
|
|
8
8
|
production: string;
|
|
9
9
|
development: string;
|
|
10
10
|
}>;
|
|
11
|
-
/**
|
|
11
|
+
/** 批量上报:单次请求最多此条数;缓冲达到此条数触发发送。 */
|
|
12
12
|
export declare const APM_BATCH_MAX = 10;
|
|
13
13
|
/** 批量上报:缓冲未满时最多等待此毫秒后发送 */
|
|
14
14
|
export declare const APM_BATCH_FLUSH_MS = 10000;
|
|
@@ -2,7 +2,7 @@ import type { MiniAppApmRegion, MiniAppTrackerEvent } from "../types";
|
|
|
2
2
|
/** 默认 Tracker 的上报方法集合 */
|
|
3
3
|
export interface DefaultTracker {
|
|
4
4
|
sendCustomPoint(event: MiniAppTrackerEvent): void;
|
|
5
|
-
/**
|
|
5
|
+
/** 将缓冲中的所有打点加入发送队列 */
|
|
6
6
|
flush(): void;
|
|
7
7
|
}
|
|
8
8
|
export interface DefaultTrackerDeliveryResult {
|
|
@@ -803,8 +803,8 @@ export interface MiniAppSimulator {
|
|
|
803
803
|
* 返回 false 表示当前不是 SW 直供状态。
|
|
804
804
|
*/
|
|
805
805
|
refreshInjection(): Promise<boolean>;
|
|
806
|
-
/**
|
|
807
|
-
openSidePanel(width: number): HTMLElement;
|
|
806
|
+
/** 打开与设备画布并排的侧栏;宽度在 width 与 maxWidth 之间自适应。 */
|
|
807
|
+
openSidePanel(width: number, maxWidth?: number): HTMLElement;
|
|
808
808
|
/** 收起侧栏并清空其内容。 */
|
|
809
809
|
closeSidePanel(): void;
|
|
810
810
|
/** 整块模拟器的交互区域(设备、侧栏及内部留白),用于边界监听。 */
|
package/lib/workbench.js
CHANGED