@mpcore/simulator 0.5.1 → 0.6.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 +20 -0
- package/dist/index.d.mts +54 -15
- package/dist/index.mjs +422 -135
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -24,3 +24,23 @@
|
|
|
24
24
|
浏览器会话的 `renderCurrentPage().styles` 提供当前页面的 `cssText`、项目相对 `dependencies` 和 `appWxssEnabled`,Web demo 将该结果挂载到页面预览的 Shadow DOM。解析器读取 `app.wxss`、页面 `.wxss` 及递归本地 `@import`,保留导入位置和全局在前、页面在后的层叠顺序;页面 `.wxss` 内联的全局样式快照也会动态加载,并保留其后页面自有样式的覆盖优先级。文件修改后重新渲染会读取最新内容,包括只更新样式的场景,不重建页面或 App 实例。
|
|
25
25
|
|
|
26
26
|
此入口只负责页面样式依赖和 CSS 兼容声明,不实现嵌套组件的完整样式隔离、类名前缀转换或 `rpx` 布局换算。Component 页面的 `page-isolated`、`page-strong-isolated`、`page-apply-shared`、`page-shared` 禁用隐式 `app.wxss`,页面仍可显式导入样式;最终页面 JSON 的 `styleIsolation` 优先于 JS 定义,JSON 未提供该值时才保留 JS 选项。普通 `Page` 注册不应用组件隔离选项,普通 `isolated` 也不等同于 `page-isolated`。缺失依赖、循环导入、非法 CSS 和不支持的导入会抛出明确错误。支持带媒体条件的本地导入;远程导入及 `layer` / `supports` 导入条件不受支持,也不会触发外部请求。
|
|
27
|
+
|
|
28
|
+
## 分块请求 mock
|
|
29
|
+
|
|
30
|
+
`session.mockRequest()` 支持为 `enableChunked: true` 的请求声明分块,默认仍不访问网络:
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
session.mockRequest({
|
|
34
|
+
url: 'https://example.test/data',
|
|
35
|
+
response: '',
|
|
36
|
+
delay: 10,
|
|
37
|
+
chunks: [
|
|
38
|
+
{ data: new Uint8Array([65]).buffer, delay: 10 },
|
|
39
|
+
{ data: new Uint8Array([66]).buffer, delay: 10 },
|
|
40
|
+
],
|
|
41
|
+
})
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
顶层 `delay` 控制响应头阶段,每个分块的 `delay` 相对于前一个阶段。请求提供 `onHeadersReceived` / `offHeadersReceived`、`onChunkReceived` / `offChunkReceived`;不传回调的 off 方法移除全部对应监听。取消会停止后续分块并仅触发一次 `fail → complete`。可设置 `error` 模拟已发送分块后的连接失败。
|
|
45
|
+
|
|
46
|
+
分块请求的 `success.data` 按已验证的微信 DevTools 行为返回空字符串;数据只通过 chunk 交付。未设置 `chunks` 时不会将普通 `response` 自动拆分。自定义 driver 仍可只实现 abort,公开监听方法类型为可选,使用前需检测能力。此模型不提供 Streams 或传输反压保证。
|
package/dist/index.d.mts
CHANGED
|
@@ -641,7 +641,10 @@ export interface HeadlessWxRequestSuccessResult {
|
|
|
641
641
|
header: Record<string, string>;
|
|
642
642
|
statusCode: number;
|
|
643
643
|
}
|
|
644
|
-
export interface HeadlessWxRequestOption extends HeadlessWxCallbackOption<HeadlessWxRequestSuccessResult> {
|
|
644
|
+
export interface HeadlessWxRequestOption extends Omit<HeadlessWxCallbackOption<HeadlessWxRequestSuccessResult>, 'complete'> {
|
|
645
|
+
complete?: (result?: HeadlessWxRequestSuccessResult | Error) => void;
|
|
646
|
+
enableChunked?: boolean;
|
|
647
|
+
responseType?: 'text' | 'arraybuffer';
|
|
645
648
|
data?: unknown;
|
|
646
649
|
header?: Record<string, string>;
|
|
647
650
|
method?: string;
|
|
@@ -650,6 +653,21 @@ export interface HeadlessWxRequestOption extends HeadlessWxCallbackOption<Headle
|
|
|
650
653
|
export interface HeadlessWxRequestTask {
|
|
651
654
|
abort: () => void;
|
|
652
655
|
}
|
|
656
|
+
export interface HeadlessWxRequestHeadersResult {
|
|
657
|
+
cookies: string[];
|
|
658
|
+
header: Record<string, string>;
|
|
659
|
+
statusCode: number;
|
|
660
|
+
}
|
|
661
|
+
export interface HeadlessWxRequestChunkResult {
|
|
662
|
+
data: ArrayBuffer;
|
|
663
|
+
}
|
|
664
|
+
export interface HeadlessWxNetworkRequestTask extends HeadlessWxRequestTask {
|
|
665
|
+
/** 自定义传输可仅实现 abort,使用监听前应检测能力。 */
|
|
666
|
+
onHeadersReceived?: (callback: (result: HeadlessWxRequestHeadersResult) => void) => void;
|
|
667
|
+
offHeadersReceived?: (callback?: (result: HeadlessWxRequestHeadersResult) => void) => void;
|
|
668
|
+
onChunkReceived?: (callback: (result: HeadlessWxRequestChunkResult) => void) => void;
|
|
669
|
+
offChunkReceived?: (callback?: (result: HeadlessWxRequestChunkResult) => void) => void;
|
|
670
|
+
}
|
|
653
671
|
export interface HeadlessWxDownloadFileSuccessResult {
|
|
654
672
|
errMsg: string;
|
|
655
673
|
statusCode: number;
|
|
@@ -934,7 +952,7 @@ export interface HeadlessWxDriver extends HeadlessWxDriverCapabilities {
|
|
|
934
952
|
removeSavedFile: (option: HeadlessWxRemoveSavedFileOption) => {
|
|
935
953
|
errMsg: string;
|
|
936
954
|
};
|
|
937
|
-
request: (option: HeadlessWxRequestOption) =>
|
|
955
|
+
request: (option: HeadlessWxRequestOption) => HeadlessWxNetworkRequestTask;
|
|
938
956
|
saveFile: (option: HeadlessWxSaveFileOption) => HeadlessWxSaveFileSuccessResult;
|
|
939
957
|
saveImageToPhotosAlbum: (option: HeadlessWxSaveImageToPhotosAlbumOption) => HeadlessWxSaveImageToPhotosAlbumResult;
|
|
940
958
|
saveVideoToPhotosAlbum: (option: HeadlessWxSaveVideoToPhotosAlbumOption) => HeadlessWxSaveVideoToPhotosAlbumResult;
|
|
@@ -1011,7 +1029,7 @@ export interface HeadlessWx extends HeadlessUniEventBus {
|
|
|
1011
1029
|
removeStorage: (option: HeadlessWxRemoveStorageOption) => HeadlessWxStorageResult | undefined;
|
|
1012
1030
|
removeStorageSync: (key: string) => void;
|
|
1013
1031
|
rpx2px: (value: number) => number;
|
|
1014
|
-
request: (option: HeadlessWxRequestOption) =>
|
|
1032
|
+
request: (option: HeadlessWxRequestOption) => HeadlessWxNetworkRequestTask;
|
|
1015
1033
|
saveFile: (option: HeadlessWxSaveFileOption) => HeadlessWxSaveFileSuccessResult | undefined;
|
|
1016
1034
|
setBackgroundColor: (option: HeadlessWxSetBackgroundColorOption) => {
|
|
1017
1035
|
errMsg: string;
|
|
@@ -1212,6 +1230,13 @@ export interface CreateArtifactProjectOptions {
|
|
|
1212
1230
|
}
|
|
1213
1231
|
export declare function createArtifactProject(options: CreateArtifactProjectOptions): HeadlessProjectDescriptor;
|
|
1214
1232
|
//#endregion
|
|
1233
|
+
//#region src/project/hostConfig.d.ts
|
|
1234
|
+
/**
|
|
1235
|
+
* @description 根据构建后的 app.json 创建模拟器提供给小程序脚本读取的宿主配置。
|
|
1236
|
+
* 微信开发者工具的 tabBar 页面路径通常带有 `.html` 后缀,保留该形态以覆盖路由归一化边界。
|
|
1237
|
+
*/
|
|
1238
|
+
export declare function createMiniProgramHostConfig(appConfig: Record<string, any>, override?: unknown): Record<string, any>;
|
|
1239
|
+
//#endregion
|
|
1215
1240
|
//#region src/project/loadProject.d.ts
|
|
1216
1241
|
export declare function loadProject(projectPath: string): HeadlessProjectDescriptor;
|
|
1217
1242
|
//#endregion
|
|
@@ -1380,6 +1405,7 @@ interface DomNodeLike$5 {
|
|
|
1380
1405
|
attribs?: Record<string, string>;
|
|
1381
1406
|
children?: DomNodeLike$5[];
|
|
1382
1407
|
data?: string;
|
|
1408
|
+
dataset?: Record<string, unknown>;
|
|
1383
1409
|
name?: string;
|
|
1384
1410
|
parent?: DomNodeLike$5 | null;
|
|
1385
1411
|
type?: string;
|
|
@@ -1389,7 +1415,7 @@ interface BrowserRenderScope {
|
|
|
1389
1415
|
alias?: string;
|
|
1390
1416
|
classList?: string[];
|
|
1391
1417
|
data: Record<string, any>;
|
|
1392
|
-
dataset?: Record<string,
|
|
1418
|
+
dataset?: Record<string, unknown>;
|
|
1393
1419
|
eventBindings?: Map<string, {
|
|
1394
1420
|
method: string;
|
|
1395
1421
|
stopAfter: boolean;
|
|
@@ -1457,6 +1483,7 @@ interface DomNodeLike$4 {
|
|
|
1457
1483
|
attribs?: Record<string, string>;
|
|
1458
1484
|
children?: DomNodeLike$4[];
|
|
1459
1485
|
data?: string;
|
|
1486
|
+
dataset?: Record<string, unknown>;
|
|
1460
1487
|
name?: string;
|
|
1461
1488
|
parent?: DomNodeLike$4 | null;
|
|
1462
1489
|
type?: string;
|
|
@@ -1466,7 +1493,7 @@ interface RuntimeRenderScope {
|
|
|
1466
1493
|
alias?: string;
|
|
1467
1494
|
classList?: string[];
|
|
1468
1495
|
data: Record<string, any>;
|
|
1469
|
-
dataset?: Record<string,
|
|
1496
|
+
dataset?: Record<string, unknown>;
|
|
1470
1497
|
eventBindings?: Map<string, {
|
|
1471
1498
|
method: string;
|
|
1472
1499
|
stopAfter: boolean;
|
|
@@ -1567,6 +1594,13 @@ export interface HeadlessWxModalLogEntry {
|
|
|
1567
1594
|
title: string;
|
|
1568
1595
|
}
|
|
1569
1596
|
export interface HeadlessWxRequestMockDefinition {
|
|
1597
|
+
/** enableChunked 请求的显式分块,每个 delay 相对于前一个阶段。 */
|
|
1598
|
+
chunks?: Array<{
|
|
1599
|
+
data: ArrayBuffer;
|
|
1600
|
+
delay?: number;
|
|
1601
|
+
}>;
|
|
1602
|
+
/** 分块发送完成后触发的模拟错误。 */
|
|
1603
|
+
error?: string;
|
|
1570
1604
|
delay?: number;
|
|
1571
1605
|
header?: Record<string, string>;
|
|
1572
1606
|
method?: string;
|
|
@@ -1849,7 +1883,7 @@ export declare function createHeadlessWxState(scheduler?: Pick<RuntimeScheduler,
|
|
|
1849
1883
|
errMsg: string;
|
|
1850
1884
|
};
|
|
1851
1885
|
removeStorageSync(key: string): void;
|
|
1852
|
-
request(option: HeadlessWxRequestOption):
|
|
1886
|
+
request(option: HeadlessWxRequestOption): HeadlessWxNetworkRequestTask;
|
|
1853
1887
|
removeSavedFile(option: HeadlessWxRemoveSavedFileOption): {
|
|
1854
1888
|
errMsg: string;
|
|
1855
1889
|
};
|
|
@@ -1902,6 +1936,7 @@ export interface HeadlessSessionOptions {
|
|
|
1902
1936
|
export declare class HeadlessSession {
|
|
1903
1937
|
readonly project: HeadlessProjectDescriptor;
|
|
1904
1938
|
private readonly kernel;
|
|
1939
|
+
private readonly startupNavigation;
|
|
1905
1940
|
private appDefinition;
|
|
1906
1941
|
private appInstance;
|
|
1907
1942
|
private readonly appLifecycle;
|
|
@@ -2281,6 +2316,7 @@ export declare class BrowserHeadlessSession {
|
|
|
2281
2316
|
private enterOptions;
|
|
2282
2317
|
private launchOptions;
|
|
2283
2318
|
private readonly kernel;
|
|
2319
|
+
private readonly startupNavigation;
|
|
2284
2320
|
private readonly wxState;
|
|
2285
2321
|
private pullDownRefreshState;
|
|
2286
2322
|
constructor(options: BrowserHeadlessSessionOptions);
|
|
@@ -2545,14 +2581,14 @@ export declare class BrowserHeadlessSession {
|
|
|
2545
2581
|
callTapBinding(scopeId: string, methodName: string): any;
|
|
2546
2582
|
callTapBindingWithEvent(scopeId: string, methodName: string, event?: {
|
|
2547
2583
|
currentTarget?: {
|
|
2548
|
-
dataset?: Record<string,
|
|
2584
|
+
dataset?: Record<string, unknown>;
|
|
2549
2585
|
id?: string;
|
|
2550
2586
|
};
|
|
2551
|
-
dataset?: Record<string,
|
|
2587
|
+
dataset?: Record<string, unknown>;
|
|
2552
2588
|
id?: string;
|
|
2553
2589
|
mark?: Record<string, unknown>;
|
|
2554
2590
|
target?: {
|
|
2555
|
-
dataset?: Record<string,
|
|
2591
|
+
dataset?: Record<string, unknown>;
|
|
2556
2592
|
id?: string;
|
|
2557
2593
|
};
|
|
2558
2594
|
}): any;
|
|
@@ -2642,25 +2678,26 @@ interface DomNodeLike$3 {
|
|
|
2642
2678
|
attribs?: Record<string, string>;
|
|
2643
2679
|
children?: DomNodeLike$3[];
|
|
2644
2680
|
data?: string;
|
|
2681
|
+
dataset?: Record<string, unknown>;
|
|
2645
2682
|
name?: string;
|
|
2646
2683
|
parent?: DomNodeLike$3 | null;
|
|
2647
2684
|
type?: string;
|
|
2648
2685
|
}
|
|
2649
|
-
interface HeadlessTestingNodeEventInit {
|
|
2686
|
+
export interface HeadlessTestingNodeEventInit {
|
|
2650
2687
|
currentTarget?: {
|
|
2651
|
-
dataset?: Record<string,
|
|
2688
|
+
dataset?: Record<string, unknown>;
|
|
2652
2689
|
id?: string;
|
|
2653
2690
|
};
|
|
2654
|
-
dataset?: Record<string,
|
|
2691
|
+
dataset?: Record<string, unknown>;
|
|
2655
2692
|
detail?: unknown;
|
|
2656
2693
|
id?: string;
|
|
2657
2694
|
mark?: Record<string, unknown>;
|
|
2658
2695
|
target?: {
|
|
2659
|
-
dataset?: Record<string,
|
|
2696
|
+
dataset?: Record<string, unknown>;
|
|
2660
2697
|
id?: string;
|
|
2661
2698
|
};
|
|
2662
2699
|
}
|
|
2663
|
-
interface HeadlessTestingNodeValueEventInit extends HeadlessTestingNodeEventInit {
|
|
2700
|
+
export interface HeadlessTestingNodeValueEventInit extends HeadlessTestingNodeEventInit {
|
|
2664
2701
|
detail?: {
|
|
2665
2702
|
value?: string;
|
|
2666
2703
|
[key: string]: unknown;
|
|
@@ -2688,7 +2725,7 @@ export declare class HeadlessTestingNodeHandle {
|
|
|
2688
2725
|
$$(selector: string): Promise<HeadlessTestingNodeHandle[]>;
|
|
2689
2726
|
getElementsByXpath(expression: string): Promise<HeadlessTestingNodeHandle[]>;
|
|
2690
2727
|
attr(name: string): Promise<string | undefined>;
|
|
2691
|
-
dataset(): Promise<Record<string,
|
|
2728
|
+
dataset(): Promise<Record<string, unknown>>;
|
|
2692
2729
|
scope(): Promise<{
|
|
2693
2730
|
scopeId: string;
|
|
2694
2731
|
snapshot: () => Promise<unknown>;
|
|
@@ -2723,6 +2760,7 @@ interface DomNodeLike$2 {
|
|
|
2723
2760
|
attribs?: Record<string, string>;
|
|
2724
2761
|
children?: DomNodeLike$2[];
|
|
2725
2762
|
data?: string;
|
|
2763
|
+
dataset?: Record<string, unknown>;
|
|
2726
2764
|
name?: string;
|
|
2727
2765
|
parent?: DomNodeLike$2 | null;
|
|
2728
2766
|
type?: string;
|
|
@@ -2738,6 +2776,7 @@ interface DomNodeLike$1 {
|
|
|
2738
2776
|
attribs?: Record<string, string>;
|
|
2739
2777
|
children?: DomNodeLike$1[];
|
|
2740
2778
|
data?: string;
|
|
2779
|
+
dataset?: Record<string, unknown>;
|
|
2741
2780
|
name?: string;
|
|
2742
2781
|
parent?: DomNodeLike$1 | null;
|
|
2743
2782
|
type?: string;
|
package/dist/index.mjs
CHANGED
|
@@ -219,6 +219,57 @@ function createHeadlessLogManager(runtimeConsole) {
|
|
|
219
219
|
};
|
|
220
220
|
}
|
|
221
221
|
//#endregion
|
|
222
|
+
//#region src/host/wx/startupNavigation.ts
|
|
223
|
+
const queues = /* @__PURE__ */ new WeakMap();
|
|
224
|
+
/** 冷启动先完成 App 与首屏装载,再顺序提交启动钩子请求的导航。 */
|
|
225
|
+
var StartupNavigationQueue = class {
|
|
226
|
+
scheduler;
|
|
227
|
+
collecting = false;
|
|
228
|
+
pending = [];
|
|
229
|
+
constructor(scheduler) {
|
|
230
|
+
this.scheduler = scheduler;
|
|
231
|
+
}
|
|
232
|
+
capture(operation) {
|
|
233
|
+
this.collecting = true;
|
|
234
|
+
try {
|
|
235
|
+
operation();
|
|
236
|
+
} catch (error) {
|
|
237
|
+
this.pending.length = 0;
|
|
238
|
+
throw error;
|
|
239
|
+
} finally {
|
|
240
|
+
this.collecting = false;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
run(option, operation) {
|
|
244
|
+
if (!this.collecting) return operation(option);
|
|
245
|
+
const defer = (callback) => callback ? (...args) => {
|
|
246
|
+
this.scheduler.setTimeout(() => callback(...args), 0);
|
|
247
|
+
} : void 0;
|
|
248
|
+
const deferred = option && {
|
|
249
|
+
...option,
|
|
250
|
+
success: defer(option.success),
|
|
251
|
+
fail: defer(option.fail),
|
|
252
|
+
complete: defer(option.complete)
|
|
253
|
+
};
|
|
254
|
+
this.pending.push(() => {
|
|
255
|
+
operation(deferred);
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
flush() {
|
|
259
|
+
const pending = this.pending.splice(0);
|
|
260
|
+
for (const operation of pending) operation();
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
/** 内部绑定保持 driver 的公开形状不变,两种 runtime 共享启动调度。 */
|
|
264
|
+
function bindStartupNavigation(driver, queue) {
|
|
265
|
+
queues.set(driver, queue);
|
|
266
|
+
return driver;
|
|
267
|
+
}
|
|
268
|
+
function runNavigationApi(driver, option, operation) {
|
|
269
|
+
const queue = queues.get(driver);
|
|
270
|
+
return queue ? queue.run(option, operation) : operation(option);
|
|
271
|
+
}
|
|
272
|
+
//#endregion
|
|
222
273
|
//#region src/host/wx/index.ts
|
|
223
274
|
function invokeWxApi(operation, option) {
|
|
224
275
|
try {
|
|
@@ -616,12 +667,12 @@ function createHeadlessWx(driver, runtimeConsole = console) {
|
|
|
616
667
|
hideLoading: (option) => invokeWxApi(() => driver.hideLoading(), option),
|
|
617
668
|
hideToast: () => driver.hideToast(),
|
|
618
669
|
downloadFile: (option) => driver.downloadFile(option),
|
|
619
|
-
navigateBack: (option) => invokeWxApi(() => {
|
|
620
|
-
driver.navigateBack(
|
|
621
|
-
},
|
|
622
|
-
navigateTo: (option) => invokeWxApi(() => {
|
|
623
|
-
driver.navigateTo(
|
|
624
|
-
},
|
|
670
|
+
navigateBack: (option) => runNavigationApi(driver, option, (deferred) => invokeWxApi(() => {
|
|
671
|
+
driver.navigateBack(deferred);
|
|
672
|
+
}, deferred)),
|
|
673
|
+
navigateTo: (option) => runNavigationApi(driver, option, (deferred) => invokeWxApi(() => {
|
|
674
|
+
driver.navigateTo(deferred);
|
|
675
|
+
}, deferred)),
|
|
625
676
|
nextTick: (callback) => driver.nextTick(callback),
|
|
626
677
|
offAppHide: (callback) => driver.offAppHide(callback),
|
|
627
678
|
offAppShow: (callback) => driver.offAppShow(callback),
|
|
@@ -634,12 +685,12 @@ function createHeadlessWx(driver, runtimeConsole = console) {
|
|
|
634
685
|
driver.pageScrollTo(option);
|
|
635
686
|
}, option),
|
|
636
687
|
previewImage: (option) => invokeWxApi(() => driver.previewImage(option), option),
|
|
637
|
-
reLaunch: (option) => invokeWxApi(() => {
|
|
638
|
-
driver.reLaunch(
|
|
639
|
-
},
|
|
640
|
-
redirectTo: (option) => invokeWxApi(() => {
|
|
641
|
-
driver.redirectTo(
|
|
642
|
-
},
|
|
688
|
+
reLaunch: (option) => runNavigationApi(driver, option, (deferred) => invokeWxApi(() => {
|
|
689
|
+
driver.reLaunch(deferred);
|
|
690
|
+
}, deferred)),
|
|
691
|
+
redirectTo: (option) => runNavigationApi(driver, option, (deferred) => invokeWxApi(() => {
|
|
692
|
+
driver.redirectTo(deferred);
|
|
693
|
+
}, deferred)),
|
|
643
694
|
removeSavedFile: (option) => invokeWxApi(() => driver.removeSavedFile(option), option),
|
|
644
695
|
saveImageToPhotosAlbum: (option) => invokeWxApi(() => driver.saveImageToPhotosAlbum(option), option),
|
|
645
696
|
saveVideoToPhotosAlbum: (option) => invokeWxApi(() => driver.saveVideoToPhotosAlbum(option), option),
|
|
@@ -675,7 +726,7 @@ function createHeadlessWx(driver, runtimeConsole = console) {
|
|
|
675
726
|
showToast: (option) => invokeWxApi(() => driver.showToast(option), option),
|
|
676
727
|
startPullDownRefresh: (option) => invokeWxApi(() => driver.startPullDownRefresh(), option),
|
|
677
728
|
stopPullDownRefresh: () => driver.stopPullDownRefresh(),
|
|
678
|
-
switchTab: (option) => driver.switchTab(
|
|
729
|
+
switchTab: (option) => runNavigationApi(driver, option, (deferred) => driver.switchTab(deferred)),
|
|
679
730
|
uploadFile: (option) => driver.uploadFile(option),
|
|
680
731
|
removeTabBarBadge: (option) => invokeWxApi(() => driver.removeTabBarBadge(option), option),
|
|
681
732
|
setTabBarBadge: (option) => invokeWxApi(() => driver.setTabBarBadge(option), option),
|
|
@@ -1776,6 +1827,26 @@ function flushComponentAttachments(instances, attach) {
|
|
|
1776
1827
|
return pending.length > 0;
|
|
1777
1828
|
}
|
|
1778
1829
|
//#endregion
|
|
1830
|
+
//#region src/runtime/componentInstance/discardedReady.ts
|
|
1831
|
+
const discardedReady = /* @__PURE__ */ new WeakMap();
|
|
1832
|
+
/** 初始模板分支被 props 替换时,微信仍发送 ready,但不发送 attached 或 detached。 */
|
|
1833
|
+
function scheduleDiscardedComponentReady(cache, scopeId, instance) {
|
|
1834
|
+
const pending = discardedReady.get(cache) ?? /* @__PURE__ */ new Map();
|
|
1835
|
+
pending.set(scopeId, instance);
|
|
1836
|
+
discardedReady.set(cache, pending);
|
|
1837
|
+
}
|
|
1838
|
+
function flushDiscardedComponentReady(cache, pageScopeId, ready) {
|
|
1839
|
+
const pending = discardedReady.get(cache);
|
|
1840
|
+
if (!pending) return;
|
|
1841
|
+
const current = [...pending].filter(([scopeId]) => scopeId.startsWith(`${pageScopeId}/`));
|
|
1842
|
+
for (const [scopeId, instance] of current) {
|
|
1843
|
+
pending.delete(scopeId);
|
|
1844
|
+
instance.__ready__ = true;
|
|
1845
|
+
}
|
|
1846
|
+
for (const [, instance] of current) ready(instance);
|
|
1847
|
+
if (!pending.size) discardedReady.delete(cache);
|
|
1848
|
+
}
|
|
1849
|
+
//#endregion
|
|
1779
1850
|
//#region src/runtime/pageLifecycle.ts
|
|
1780
1851
|
const loadingPages = /* @__PURE__ */ new WeakSet();
|
|
1781
1852
|
function isPageBeforeReady(page) {
|
|
@@ -1876,13 +1947,13 @@ const BLOCKED_MEMBER_KEYS = /* @__PURE__ */ new Set([
|
|
|
1876
1947
|
"prototype"
|
|
1877
1948
|
]);
|
|
1878
1949
|
const NUMERIC_DOT_PATH_RE = /\.(\d+)(?=[.[\s,}\]]|$)/g;
|
|
1879
|
-
function isMustacheOnly$
|
|
1950
|
+
function isMustacheOnly$3(value) {
|
|
1880
1951
|
const trimmed = value.trim();
|
|
1881
1952
|
return trimmed.startsWith("{{") && trimmed.endsWith("}}") && !trimmed.includes("{{", 2);
|
|
1882
1953
|
}
|
|
1883
1954
|
function unwrapMustacheExpression(expression) {
|
|
1884
1955
|
const normalized = expression.trim();
|
|
1885
|
-
if (isMustacheOnly$
|
|
1956
|
+
if (isMustacheOnly$3(normalized)) return normalized.slice(2, -2).trim();
|
|
1886
1957
|
return normalized;
|
|
1887
1958
|
}
|
|
1888
1959
|
function parseTemplateExpression(expression) {
|
|
@@ -2128,6 +2199,20 @@ function resolveBrowserComponentPageStyleIsolation(files, page, route, miniprogr
|
|
|
2128
2199
|
return isolation === void 0 ? definitionIsolation : typeof isolation === "string" ? isolation : void 0;
|
|
2129
2200
|
}
|
|
2130
2201
|
//#endregion
|
|
2202
|
+
//#region src/runtime/componentInstance/selection.ts
|
|
2203
|
+
function hasExportBehavior(definition, visited = /* @__PURE__ */ new Set()) {
|
|
2204
|
+
if (visited.has(definition)) return false;
|
|
2205
|
+
visited.add(definition);
|
|
2206
|
+
return (Array.isArray(definition.behaviors) ? definition.behaviors : []).some((behavior) => behavior === "wx://component-export" || behavior !== null && typeof behavior === "object" && hasExportBehavior(behavior, visited));
|
|
2207
|
+
}
|
|
2208
|
+
/** 原生选择器尊重组件导出行为;测试桥接继续保留完整组件实例。 */
|
|
2209
|
+
function resolveNativeComponentSelection(instance) {
|
|
2210
|
+
if (!instance) return null;
|
|
2211
|
+
const definition = instance.__definition__;
|
|
2212
|
+
if (!definition || !hasExportBehavior(definition) || typeof instance.export !== "function") return instance;
|
|
2213
|
+
return instance.export();
|
|
2214
|
+
}
|
|
2215
|
+
//#endregion
|
|
2131
2216
|
//#region src/runtime/componentResolution.ts
|
|
2132
2217
|
function resolveMiniProgramComponent(ownerFilePath, request, miniprogramRootPath, hasFile) {
|
|
2133
2218
|
const localPath = request.startsWith("/") ? request.replace(/^\/+/, "") : join(dirname(ownerFilePath), request);
|
|
@@ -2249,6 +2334,21 @@ function resolveSelectorQueryScopeSnapshot(scope, snapshots) {
|
|
|
2249
2334
|
return null;
|
|
2250
2335
|
}
|
|
2251
2336
|
//#endregion
|
|
2337
|
+
//#region src/view/nodeDataset.ts
|
|
2338
|
+
const DATASET_NAME_RE = /-([a-z])/g;
|
|
2339
|
+
function isDatasetAttribute(attributeName) {
|
|
2340
|
+
return attributeName.startsWith("data-") && !attributeName.startsWith("data-sim-");
|
|
2341
|
+
}
|
|
2342
|
+
function toDatasetKey(attributeName) {
|
|
2343
|
+
return attributeName.slice(5).replace(DATASET_NAME_RE, (_match, char) => char.toUpperCase());
|
|
2344
|
+
}
|
|
2345
|
+
function collectNodeDataset(node) {
|
|
2346
|
+
if (node.dataset) return { ...node.dataset };
|
|
2347
|
+
const dataset = {};
|
|
2348
|
+
for (const [key, value] of Object.entries(node.attribs ?? {})) if (isDatasetAttribute(key)) dataset[toDatasetKey(key)] = value;
|
|
2349
|
+
return dataset;
|
|
2350
|
+
}
|
|
2351
|
+
//#endregion
|
|
2252
2352
|
//#region src/view/templateImports.ts
|
|
2253
2353
|
function createImportedTemplateState(root, filePath, loadImport, loadWxs) {
|
|
2254
2354
|
const documents = /* @__PURE__ */ new Map();
|
|
@@ -2278,7 +2378,8 @@ function createImportedTemplateState(root, filePath, loadImport, loadWxs) {
|
|
|
2278
2378
|
return;
|
|
2279
2379
|
}
|
|
2280
2380
|
if (child.name === "import" && child.attribs?.src) {
|
|
2281
|
-
const
|
|
2381
|
+
const source = child.attribs.src;
|
|
2382
|
+
const imported = loadImport(owner, source.endsWith(".wxml") ? source : `${source}.wxml`);
|
|
2282
2383
|
const importedDocument = collect(imported.root, imported.filePath);
|
|
2283
2384
|
for (const [name, definition] of importedDocument.exports) state.definitions.set(name, definition);
|
|
2284
2385
|
}
|
|
@@ -2334,7 +2435,6 @@ function parseWxsTemplateDocument(templateSource) {
|
|
|
2334
2435
|
//#endregion
|
|
2335
2436
|
//#region src/browser/render/shared.ts
|
|
2336
2437
|
const TEMPLATE_INTERPOLATION_RE$2 = /\{\{([^{}]+)\}\}/g;
|
|
2337
|
-
const DATASET_NAME_RE$4 = /-([a-z])/g;
|
|
2338
2438
|
const LEADING_SLASH_RE$5 = /^\/+/;
|
|
2339
2439
|
const EVENT_BINDING_ATTRS$1 = [
|
|
2340
2440
|
"bindtap",
|
|
@@ -2353,19 +2453,16 @@ const STRUCTURAL_ATTRS$1 = [
|
|
|
2353
2453
|
];
|
|
2354
2454
|
const CLASS_SPLIT_RE$1 = /\s+/;
|
|
2355
2455
|
const JS_FILE_RE$1 = /\.js$/;
|
|
2356
|
-
function isMustacheOnly$
|
|
2456
|
+
function isMustacheOnly$2(value) {
|
|
2357
2457
|
const trimmed = value.trim();
|
|
2358
2458
|
return trimmed.startsWith("{{") && trimmed.endsWith("}}") && !trimmed.includes("{{", 2);
|
|
2359
2459
|
}
|
|
2360
|
-
function
|
|
2361
|
-
|
|
2362
|
-
}
|
|
2363
|
-
function collectDataset$4(node, source) {
|
|
2460
|
+
function collectDataset$1(node, source) {
|
|
2461
|
+
if (node.dataset) return collectNodeDataset(node);
|
|
2364
2462
|
const dataset = {};
|
|
2365
2463
|
for (const [key, value] of Object.entries(node.attribs ?? {})) {
|
|
2366
|
-
if (!
|
|
2367
|
-
|
|
2368
|
-
dataset[toDatasetKey$4(key)] = String(resolvedValue ?? "");
|
|
2464
|
+
if (!isDatasetAttribute(key)) continue;
|
|
2465
|
+
dataset[toDatasetKey(key)] = source && isMustacheOnly$2(value) ? resolveTemplateExpression(source, value) : value;
|
|
2369
2466
|
}
|
|
2370
2467
|
return dataset;
|
|
2371
2468
|
}
|
|
@@ -2379,13 +2476,14 @@ function cloneNode$1(node) {
|
|
|
2379
2476
|
return {
|
|
2380
2477
|
...node,
|
|
2381
2478
|
attribs: node.attribs ? { ...node.attribs } : void 0,
|
|
2479
|
+
dataset: node.dataset ? { ...node.dataset } : void 0,
|
|
2382
2480
|
children: node.children?.map((child) => cloneNode$1(child))
|
|
2383
2481
|
};
|
|
2384
2482
|
}
|
|
2385
2483
|
function resolveValueByPath$2(source, expression) {
|
|
2386
2484
|
return resolveTemplateExpression(source, expression) ?? "";
|
|
2387
2485
|
}
|
|
2388
|
-
function resolveRawValueByPath$
|
|
2486
|
+
function resolveRawValueByPath$2(source, expression) {
|
|
2389
2487
|
return resolveTemplateExpression(source, expression);
|
|
2390
2488
|
}
|
|
2391
2489
|
function interpolateTemplate$2(input, data) {
|
|
@@ -2428,16 +2526,16 @@ function isTagNode$1(node) {
|
|
|
2428
2526
|
return node.type === "tag" && typeof node.name === "string";
|
|
2429
2527
|
}
|
|
2430
2528
|
function resolveAttributeValue$1(value, scope) {
|
|
2431
|
-
if (isMustacheOnly$
|
|
2529
|
+
if (isMustacheOnly$2(value)) {
|
|
2432
2530
|
const expression = value.trim().slice(2, -2);
|
|
2433
|
-
return
|
|
2531
|
+
return resolveRawValueByPath$2(wxsScopeData(scope), expression);
|
|
2434
2532
|
}
|
|
2435
2533
|
return interpolateTemplate$2(value, wxsScopeData(scope));
|
|
2436
2534
|
}
|
|
2437
2535
|
function resolveComponentAttributeValue$1(value, scope) {
|
|
2438
|
-
if (isMustacheOnly$
|
|
2536
|
+
if (isMustacheOnly$2(value)) {
|
|
2439
2537
|
const expression = value.trim().slice(2, -2);
|
|
2440
|
-
return resolveRawValueByPath$
|
|
2538
|
+
return resolveRawValueByPath$2(wxsScopeData(scope), expression) ?? null;
|
|
2441
2539
|
}
|
|
2442
2540
|
return interpolateTemplate$2(value, wxsScopeData(scope));
|
|
2443
2541
|
}
|
|
@@ -2449,18 +2547,25 @@ function applyNodeBindings$1(node, scope) {
|
|
|
2449
2547
|
node.attribs ??= {};
|
|
2450
2548
|
node.attribs["data-sim-scope"] = scope.getScopeId();
|
|
2451
2549
|
for (const key of STRUCTURAL_ATTRS$1) delete node.attribs[key];
|
|
2550
|
+
let dataset;
|
|
2452
2551
|
for (const [key, value] of Object.entries({ ...node.attribs })) {
|
|
2453
2552
|
if (EVENT_BINDING_ATTRS$1.includes(key)) {
|
|
2454
2553
|
node.attribs["data-sim-tap"] = value;
|
|
2455
2554
|
continue;
|
|
2456
2555
|
}
|
|
2457
|
-
|
|
2556
|
+
const resolvedValue = typeof value === "string" ? resolveAttributeValue$1(value, scope) : value;
|
|
2557
|
+
node.attribs[key] = String(resolvedValue ?? "");
|
|
2558
|
+
if (isDatasetAttribute(key)) {
|
|
2559
|
+
dataset ??= {};
|
|
2560
|
+
dataset[toDatasetKey(key)] = resolvedValue;
|
|
2561
|
+
}
|
|
2458
2562
|
}
|
|
2563
|
+
node.dataset = dataset;
|
|
2459
2564
|
}
|
|
2460
2565
|
function evaluateConditionalBranch$1(node, scope) {
|
|
2461
2566
|
const condition = node.attribs?.["wx:if"] ?? node.attribs?.["wx:elif"];
|
|
2462
2567
|
if (condition == null) return true;
|
|
2463
|
-
return Boolean(resolveRawValueByPath$
|
|
2568
|
+
return Boolean(resolveRawValueByPath$2(wxsScopeData(scope), condition));
|
|
2464
2569
|
}
|
|
2465
2570
|
function createLoopScope$1(scope, itemName, indexName, item, index) {
|
|
2466
2571
|
return {
|
|
@@ -2534,7 +2639,7 @@ function collectComponentEventBindings$1(hostNode) {
|
|
|
2534
2639
|
return collectMiniProgramEventBindings(hostNode.attribs);
|
|
2535
2640
|
}
|
|
2536
2641
|
function buildComponentTrigger$1(componentScopeId, context, hostNode) {
|
|
2537
|
-
const hostDataset = collectDataset$
|
|
2642
|
+
const hostDataset = collectDataset$1(hostNode);
|
|
2538
2643
|
const hostId = hostNode.attribs?.id ?? "";
|
|
2539
2644
|
return (instance, eventName, detail, triggerOptions) => {
|
|
2540
2645
|
const originScope = context.componentScopes.get(componentScopeId);
|
|
@@ -2596,7 +2701,7 @@ function createComponentScope$1(clonedNode, scope, componentScopeId, componentIn
|
|
|
2596
2701
|
alias: clonedNode.name,
|
|
2597
2702
|
classList: String(clonedNode.attribs?.class ?? "").split(CLASS_SPLIT_RE$1).map((item) => item.trim()).filter(Boolean),
|
|
2598
2703
|
data: { ...componentInstance.data },
|
|
2599
|
-
dataset: collectDataset$
|
|
2704
|
+
dataset: collectDataset$1(clonedNode, wxsScopeData(scope)),
|
|
2600
2705
|
eventBindings: collectComponentEventBindings$1(clonedNode),
|
|
2601
2706
|
getMethod: (methodName) => {
|
|
2602
2707
|
const method = componentInstance?.[methodName];
|
|
@@ -2619,7 +2724,7 @@ function resolveComponentProperties$1(clonedNode, scope, definition) {
|
|
|
2619
2724
|
if (key.startsWith("bind") || key.startsWith("generic:")) continue;
|
|
2620
2725
|
const camelizedKey = key.replace(/-([a-z])/g, (_match, char) => char.toUpperCase());
|
|
2621
2726
|
const propertyKey = key in declaredProperties || !(camelizedKey in declaredProperties) ? key : camelizedKey;
|
|
2622
|
-
if (isMustacheOnly$
|
|
2727
|
+
if (isMustacheOnly$2(String(value))) bindingExpressions[propertyKey] = String(value).trim().slice(2, -2).trim();
|
|
2623
2728
|
nextProperties[propertyKey] = resolveComponentAttributeValue$1(String(value), scope);
|
|
2624
2729
|
}
|
|
2625
2730
|
return {
|
|
@@ -2627,7 +2732,7 @@ function resolveComponentProperties$1(clonedNode, scope, definition) {
|
|
|
2627
2732
|
bindingExpressions
|
|
2628
2733
|
};
|
|
2629
2734
|
}
|
|
2630
|
-
function createBrowserComponentInstance(componentScopeId, context, clonedNode, componentEntry, nextProperties, ownerScopeId) {
|
|
2735
|
+
function createBrowserComponentInstance(componentScopeId, context, clonedNode, componentEntry, nextProperties, ownerScopeId, beforeCreated) {
|
|
2631
2736
|
const componentProperties = Object.keys(componentEntry.definition.methods ?? {}).some((key) => key.startsWith("__weapp_vite_")) || Object.hasOwn(componentEntry.definition.properties ?? {}, "__wvSlotOwnerId") ? Object.fromEntries(Object.keys(componentEntry.definition.properties ?? {}).filter((key) => Object.hasOwn(nextProperties, key)).map((key) => [key, nextProperties[key]])) : nextProperties;
|
|
2632
2737
|
const componentInstance = createComponentInstance({
|
|
2633
2738
|
definition: componentEntry.definition,
|
|
@@ -2639,10 +2744,11 @@ function createBrowserComponentInstance(componentScopeId, context, clonedNode, c
|
|
|
2639
2744
|
componentInstance.createIntersectionObserver = (options) => context.session.createIntersectionObserver(componentInstance, options);
|
|
2640
2745
|
componentInstance.createMediaQueryObserver = () => context.session.createMediaQueryObserver(componentInstance);
|
|
2641
2746
|
componentInstance.createSelectorQuery = () => context.moduleLoader.wx.createSelectorQuery().in(componentInstance);
|
|
2642
|
-
componentInstance.selectComponent = (selector) => context.session.selectComponentWithin(componentScopeId, selector);
|
|
2643
|
-
componentInstance.selectAllComponents = (selector) => context.session.selectAllComponentsWithin(componentScopeId, selector);
|
|
2747
|
+
componentInstance.selectComponent = (selector) => resolveNativeComponentSelection(context.session.selectComponentWithin(componentScopeId, selector));
|
|
2748
|
+
componentInstance.selectAllComponents = (selector) => context.session.selectAllComponentsWithin(componentScopeId, selector).map(resolveNativeComponentSelection);
|
|
2644
2749
|
componentInstance.selectOwnerComponent = () => ownerScopeId ? context.componentCache.get(ownerScopeId) ?? null : null;
|
|
2645
2750
|
context.componentCache.set(componentScopeId, componentInstance);
|
|
2751
|
+
beforeCreated?.(componentInstance);
|
|
2646
2752
|
runComponentLifecycle(componentInstance, "created");
|
|
2647
2753
|
componentInstance.__propertySnapshots = Object.fromEntries(Object.entries(componentInstance.properties).map(([key, propertyValue]) => [key, cloneValue(propertyValue)]));
|
|
2648
2754
|
syncComponentProperties$1(componentInstance, componentInstance.__definition__ ?? componentEntry.definition, componentProperties, {}, []);
|
|
@@ -2664,7 +2770,7 @@ function expandNodeByFor$1(node, scope) {
|
|
|
2664
2770
|
scope,
|
|
2665
2771
|
instanceSuffix: ""
|
|
2666
2772
|
}];
|
|
2667
|
-
const items = resolveLoopEntries(resolveRawValueByPath$
|
|
2773
|
+
const items = resolveLoopEntries(resolveRawValueByPath$2(wxsScopeData(scope), forExpression));
|
|
2668
2774
|
const itemName = node.attribs?.["wx:for-item"]?.trim() || "item";
|
|
2669
2775
|
const indexName = node.attribs?.["wx:for-index"]?.trim() || "index";
|
|
2670
2776
|
return items.map(([index, item]) => ({
|
|
@@ -2776,12 +2882,16 @@ function renderNodeTree$1(node, scope, context, ownerJsonPath, ownerFilePath, in
|
|
|
2776
2882
|
const componentScopeId = `${instancePath}/${clonedNode.name}`;
|
|
2777
2883
|
const ownerScopeId = scope.getScopeId().includes("/") ? scope.getScopeId() : void 0;
|
|
2778
2884
|
const { nextProperties, bindingExpressions } = resolveComponentProperties$1(clonedNode, scope, componentEntry.definition);
|
|
2885
|
+
const genericComponents = resolveComponentGenerics$1(context, clonedNode, ownerJsonPath, ownerFilePath, componentEntry.filePath);
|
|
2886
|
+
const slots = collectComponentSlots$1(clonedNode, scope, ownerJsonPath, ownerFilePath, componentScopeId, templateRenderState);
|
|
2779
2887
|
let componentInstance = context.componentCache.get(componentScopeId);
|
|
2780
|
-
if (!componentInstance) componentInstance = createBrowserComponentInstance(componentScopeId, context, clonedNode, componentEntry, nextProperties, ownerScopeId)
|
|
2888
|
+
if (!componentInstance) componentInstance = createBrowserComponentInstance(componentScopeId, context, clonedNode, componentEntry, nextProperties, ownerScopeId, (instance) => {
|
|
2889
|
+
const initialScope = createComponentScope$1(clonedNode, scope, componentScopeId, instance, genericComponents, slots);
|
|
2890
|
+
context.componentScopes.set(componentScopeId, initialScope);
|
|
2891
|
+
renderBrowserComponentTemplate(context, componentEntry, renderNodeTree$1, initialScope, componentScopeId, /* @__PURE__ */ new Set());
|
|
2892
|
+
});
|
|
2781
2893
|
else syncComponentProperties$1(componentInstance, componentInstance.__definition__ ?? componentEntry.definition, nextProperties, bindingExpressions, context.changedPageKeys);
|
|
2782
2894
|
seenComponentScopes.add(componentScopeId);
|
|
2783
|
-
const genericComponents = resolveComponentGenerics$1(context, clonedNode, ownerJsonPath, ownerFilePath, componentEntry.filePath);
|
|
2784
|
-
const slots = collectComponentSlots$1(clonedNode, scope, ownerJsonPath, ownerFilePath, componentScopeId, templateRenderState);
|
|
2785
2895
|
const componentScope = createComponentScope$1(clonedNode, scope, componentScopeId, componentInstance, genericComponents, slots);
|
|
2786
2896
|
context.componentScopes.set(componentScopeId, componentScope);
|
|
2787
2897
|
const renderedComponentRoot = renderBrowserComponentTemplate(context, componentEntry, renderNodeTree$1, componentScope, componentScopeId, seenComponentScopes);
|
|
@@ -2791,6 +2901,10 @@ function renderNodeTree$1(node, scope, context, ownerJsonPath, ownerFilePath, in
|
|
|
2791
2901
|
...clonedNode.attribs,
|
|
2792
2902
|
...renderedComponentRoot.attribs
|
|
2793
2903
|
};
|
|
2904
|
+
if (clonedNode.dataset || renderedComponentRoot.dataset) renderedComponentRoot.dataset = {
|
|
2905
|
+
...clonedNode.dataset,
|
|
2906
|
+
...renderedComponentRoot.dataset
|
|
2907
|
+
};
|
|
2794
2908
|
renderedComponentRoot.attribs["data-sim-component"] = clonedNode.name;
|
|
2795
2909
|
renderedComponentRoot.attribs["data-sim-scope"] = componentScopeId;
|
|
2796
2910
|
}
|
|
@@ -2835,7 +2949,8 @@ function renderBrowserPageTree(context, page) {
|
|
|
2835
2949
|
if (instance !== context.componentCache.get(customTabBarScopeId(route))) runComponentPageLifetime(instance, "show");
|
|
2836
2950
|
});
|
|
2837
2951
|
const removed = [...context.componentCache].filter(([scopeId]) => scopeId.startsWith(`${pageScopeId}/`) && !seenComponentScopes.has(scopeId));
|
|
2838
|
-
for (const [, instance] of removed) runComponentLifecycle(instance, "detached");
|
|
2952
|
+
for (const [scopeId, instance] of removed) if (isComponentAttached(instance)) runComponentLifecycle(instance, "detached");
|
|
2953
|
+
else scheduleDiscardedComponentReady(context.componentCache, scopeId, instance);
|
|
2839
2954
|
const instances = [...seenComponentScopes].map((scopeId) => context.componentCache.get(scopeId));
|
|
2840
2955
|
const relationsChanged = !pageAttaching && !hasPendingComponentAttachments(instances) && syncComponentRelations(context.componentCache, seenComponentScopes, pageScopeId);
|
|
2841
2956
|
for (const [scopeId] of removed) {
|
|
@@ -2843,6 +2958,7 @@ function renderBrowserPageTree(context, page) {
|
|
|
2843
2958
|
context.componentScopes.delete(scopeId);
|
|
2844
2959
|
}
|
|
2845
2960
|
if (pageAttached || attached || relationsChanged) return renderBrowserPageTree(context, page);
|
|
2961
|
+
if (!isPageBeforeReady(page)) flushDiscardedComponentReady(context.componentCache, pageScopeId, (instance) => runComponentLifecycle(instance, "ready"));
|
|
2846
2962
|
if (!isPageBeforeReady(page) && flushComponentReady(instances, (instance) => runComponentLifecycle(instance, "ready"))) return renderBrowserPageTree(context, page);
|
|
2847
2963
|
const treeRoot = roots.length > 1 ? {
|
|
2848
2964
|
type: "root",
|
|
@@ -2896,6 +3012,40 @@ function invokePreparedNavigationApi(prepare, option) {
|
|
|
2896
3012
|
}
|
|
2897
3013
|
}
|
|
2898
3014
|
//#endregion
|
|
3015
|
+
//#region src/project/hostConfig.ts
|
|
3016
|
+
/**
|
|
3017
|
+
* @description 根据构建后的 app.json 创建模拟器提供给小程序脚本读取的宿主配置。
|
|
3018
|
+
* 微信开发者工具的 tabBar 页面路径通常带有 `.html` 后缀,保留该形态以覆盖路由归一化边界。
|
|
3019
|
+
*/
|
|
3020
|
+
function createMiniProgramHostConfig(appConfig, override) {
|
|
3021
|
+
const appTabBar = appConfig.tabBar && typeof appConfig.tabBar === "object" ? appConfig.tabBar : void 0;
|
|
3022
|
+
const tabBar = appTabBar ? {
|
|
3023
|
+
...appTabBar,
|
|
3024
|
+
...Array.isArray(appTabBar.list) ? { list: appTabBar.list.map((item) => {
|
|
3025
|
+
if (!item || typeof item !== "object") return item;
|
|
3026
|
+
const pagePath = typeof item.pagePath === "string" ? item.pagePath.replace(/^\/+/, "").replace(/\.html$/, "") : void 0;
|
|
3027
|
+
return pagePath ? {
|
|
3028
|
+
...item,
|
|
3029
|
+
pagePath: `${pagePath}.html`
|
|
3030
|
+
} : { ...item };
|
|
3031
|
+
}) } : {}
|
|
3032
|
+
} : void 0;
|
|
3033
|
+
const generated = {
|
|
3034
|
+
...appConfig,
|
|
3035
|
+
...tabBar ? { tabBar } : {}
|
|
3036
|
+
};
|
|
3037
|
+
if (!override || typeof override !== "object" || Array.isArray(override)) return generated;
|
|
3038
|
+
const overrideRecord = override;
|
|
3039
|
+
return {
|
|
3040
|
+
...generated,
|
|
3041
|
+
...overrideRecord,
|
|
3042
|
+
...generated.tabBar || overrideRecord.tabBar ? { tabBar: {
|
|
3043
|
+
...generated.tabBar ?? {},
|
|
3044
|
+
...overrideRecord.tabBar ?? {}
|
|
3045
|
+
} } : {}
|
|
3046
|
+
};
|
|
3047
|
+
}
|
|
3048
|
+
//#endregion
|
|
2899
3049
|
//#region src/project/pageConfig.ts
|
|
2900
3050
|
const DEFAULT_NAVIGATION_BAR_BACKGROUND_COLOR = "#ffffff";
|
|
2901
3051
|
const DEFAULT_NAVIGATION_BAR_FRONT_COLOR = "#000000";
|
|
@@ -3251,6 +3401,110 @@ function deriveMenuButtonBoundingClientRect(systemInfo) {
|
|
|
3251
3401
|
};
|
|
3252
3402
|
}
|
|
3253
3403
|
//#endregion
|
|
3404
|
+
//#region src/runtime/request/task.ts
|
|
3405
|
+
/** mock 与显式网络桥接共用终止状态;终止后不再分发 headers/chunk。 */
|
|
3406
|
+
function createRequestTask(option, onAbort = () => {}) {
|
|
3407
|
+
const headers = /* @__PURE__ */ new Set();
|
|
3408
|
+
const chunks = /* @__PURE__ */ new Set();
|
|
3409
|
+
let settled = false;
|
|
3410
|
+
function finish(result, success) {
|
|
3411
|
+
if (settled) return;
|
|
3412
|
+
settled = true;
|
|
3413
|
+
headers.clear();
|
|
3414
|
+
chunks.clear();
|
|
3415
|
+
try {
|
|
3416
|
+
if (success) option.success?.(result);
|
|
3417
|
+
else option.fail?.(result);
|
|
3418
|
+
} finally {
|
|
3419
|
+
option.complete?.(result);
|
|
3420
|
+
}
|
|
3421
|
+
}
|
|
3422
|
+
return {
|
|
3423
|
+
task: {
|
|
3424
|
+
abort() {
|
|
3425
|
+
if (settled) return;
|
|
3426
|
+
const error = Object.assign(/* @__PURE__ */ new Error("request:fail abort"), { errMsg: "request:fail abort" });
|
|
3427
|
+
try {
|
|
3428
|
+
finish(error, false);
|
|
3429
|
+
} finally {
|
|
3430
|
+
onAbort();
|
|
3431
|
+
}
|
|
3432
|
+
},
|
|
3433
|
+
onHeadersReceived(callback) {
|
|
3434
|
+
headers.add(callback);
|
|
3435
|
+
},
|
|
3436
|
+
offHeadersReceived(callback) {
|
|
3437
|
+
if (callback) headers.delete(callback);
|
|
3438
|
+
else headers.clear();
|
|
3439
|
+
},
|
|
3440
|
+
onChunkReceived(callback) {
|
|
3441
|
+
chunks.add(callback);
|
|
3442
|
+
},
|
|
3443
|
+
offChunkReceived(callback) {
|
|
3444
|
+
if (callback) chunks.delete(callback);
|
|
3445
|
+
else chunks.clear();
|
|
3446
|
+
}
|
|
3447
|
+
},
|
|
3448
|
+
get settled() {
|
|
3449
|
+
return settled;
|
|
3450
|
+
},
|
|
3451
|
+
headers(result) {
|
|
3452
|
+
if (settled) return;
|
|
3453
|
+
for (const callback of Array.from(headers)) if (!settled && headers.has(callback)) callback(result);
|
|
3454
|
+
},
|
|
3455
|
+
chunk(data) {
|
|
3456
|
+
if (settled || !option.enableChunked) return;
|
|
3457
|
+
for (const callback of Array.from(chunks)) if (!settled && chunks.has(callback)) callback({ data: data.slice(0) });
|
|
3458
|
+
},
|
|
3459
|
+
succeed(result) {
|
|
3460
|
+
finish(result, true);
|
|
3461
|
+
},
|
|
3462
|
+
fail(error) {
|
|
3463
|
+
finish(Object.assign(error, { errMsg: "errMsg" in error ? error.errMsg : error.message }), false);
|
|
3464
|
+
}
|
|
3465
|
+
};
|
|
3466
|
+
}
|
|
3467
|
+
//#endregion
|
|
3468
|
+
//#region src/runtime/request/mock.ts
|
|
3469
|
+
/** 仅模拟已声明的分块;不进行网络访问,也不把完整 response 拆成假分块。 */
|
|
3470
|
+
function createChunkedMockRequest(option, mock, response, scheduler, onSuccess) {
|
|
3471
|
+
let timer;
|
|
3472
|
+
const request = createRequestTask(option, () => scheduler.clearTimeout(timer));
|
|
3473
|
+
const chunks = (mock.chunks ?? []).map((chunk) => ({
|
|
3474
|
+
...chunk,
|
|
3475
|
+
data: chunk.data.slice(0)
|
|
3476
|
+
}));
|
|
3477
|
+
let index = 0;
|
|
3478
|
+
function next() {
|
|
3479
|
+
if (request.settled) return;
|
|
3480
|
+
const chunk = chunks[index++];
|
|
3481
|
+
if (chunk) timer = scheduler.setTimeout(() => {
|
|
3482
|
+
request.chunk(chunk.data);
|
|
3483
|
+
next();
|
|
3484
|
+
}, Math.max(0, chunk.delay ?? 0));
|
|
3485
|
+
else timer = scheduler.setTimeout(() => {
|
|
3486
|
+
if (request.settled) return;
|
|
3487
|
+
if (mock.error) request.fail(new Error(mock.error));
|
|
3488
|
+
else {
|
|
3489
|
+
onSuccess();
|
|
3490
|
+
request.succeed({
|
|
3491
|
+
...response,
|
|
3492
|
+
data: ""
|
|
3493
|
+
});
|
|
3494
|
+
}
|
|
3495
|
+
}, 0);
|
|
3496
|
+
}
|
|
3497
|
+
timer = scheduler.setTimeout(() => {
|
|
3498
|
+
request.headers({
|
|
3499
|
+
cookies: response.cookies,
|
|
3500
|
+
header: response.header,
|
|
3501
|
+
statusCode: response.statusCode
|
|
3502
|
+
});
|
|
3503
|
+
next();
|
|
3504
|
+
}, Math.max(0, mock.delay ?? 0));
|
|
3505
|
+
return request.task;
|
|
3506
|
+
}
|
|
3507
|
+
//#endregion
|
|
3254
3508
|
//#region src/runtime/wxState.ts
|
|
3255
3509
|
const STORAGE_LIMIT_SIZE = 10240;
|
|
3256
3510
|
const DEFAULT_MODAL_CANCEL_COLOR = "#000000";
|
|
@@ -4572,6 +4826,7 @@ function createHeadlessWxState(scheduler = nativeScheduler, options = {}) {
|
|
|
4572
4826
|
request(option) {
|
|
4573
4827
|
const matchedMock = requestMocks.find((mock) => matchesRequestMock(mock, option));
|
|
4574
4828
|
if (!matchedMock) {
|
|
4829
|
+
const request = createRequestTask(option);
|
|
4575
4830
|
const logEntry = {
|
|
4576
4831
|
data: cloneValue$1(option.data),
|
|
4577
4832
|
header: { ...option.header ?? {} },
|
|
@@ -4582,9 +4837,8 @@ function createHeadlessWxState(scheduler = nativeScheduler, options = {}) {
|
|
|
4582
4837
|
requestLogs.push(logEntry);
|
|
4583
4838
|
const error = /* @__PURE__ */ new Error(`No request mock matched in headless runtime: ${normalizeMethod(option.method)} ${option.url}`);
|
|
4584
4839
|
if (options.strictMocks) throw error;
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
return createNoopTask();
|
|
4840
|
+
request.fail(error);
|
|
4841
|
+
return request.task;
|
|
4588
4842
|
}
|
|
4589
4843
|
const response = resolveRequestResponse(matchedMock, option);
|
|
4590
4844
|
const requestLogEntry = {
|
|
@@ -4596,20 +4850,31 @@ function createHeadlessWxState(scheduler = nativeScheduler, options = {}) {
|
|
|
4596
4850
|
url: option.url
|
|
4597
4851
|
};
|
|
4598
4852
|
const delay = Number.isFinite(matchedMock.delay) ? Math.max(0, Math.trunc(matchedMock.delay ?? 0)) : 0;
|
|
4853
|
+
if (option.enableChunked) return createChunkedMockRequest(option, matchedMock, response, scheduler, () => {
|
|
4854
|
+
requestLogs.push({
|
|
4855
|
+
...requestLogEntry,
|
|
4856
|
+
response: {
|
|
4857
|
+
...response,
|
|
4858
|
+
data: ""
|
|
4859
|
+
}
|
|
4860
|
+
});
|
|
4861
|
+
});
|
|
4862
|
+
const request = createRequestTask(option);
|
|
4599
4863
|
if (delay <= 0) {
|
|
4600
4864
|
requestLogs.push(requestLogEntry);
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
return createNoopTask();
|
|
4865
|
+
request.succeed(response);
|
|
4866
|
+
return request.task;
|
|
4604
4867
|
}
|
|
4605
|
-
|
|
4868
|
+
const delayed = runDelayedTask(delay, () => {
|
|
4606
4869
|
requestLogs.push(requestLogEntry);
|
|
4607
|
-
|
|
4608
|
-
option.complete?.(response);
|
|
4870
|
+
request.succeed(response);
|
|
4609
4871
|
}, (error) => {
|
|
4610
|
-
|
|
4611
|
-
option.complete?.();
|
|
4872
|
+
request.fail(error);
|
|
4612
4873
|
}, "request:fail abort");
|
|
4874
|
+
return {
|
|
4875
|
+
...request.task,
|
|
4876
|
+
abort: delayed.abort
|
|
4877
|
+
};
|
|
4613
4878
|
},
|
|
4614
4879
|
removeSavedFile(option) {
|
|
4615
4880
|
return removeSavedFile(option.filePath);
|
|
@@ -4891,23 +5156,11 @@ function queryXPathElements(root, expression) {
|
|
|
4891
5156
|
}
|
|
4892
5157
|
//#endregion
|
|
4893
5158
|
//#region src/view/nodeHandle.ts
|
|
4894
|
-
const DATASET_NAME_RE$3 = /-([a-z])/g;
|
|
4895
5159
|
function escapeText$2(text) {
|
|
4896
5160
|
return text.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">");
|
|
4897
5161
|
}
|
|
4898
|
-
function toDatasetKey$3(attributeName) {
|
|
4899
|
-
return attributeName.slice(5).replace(DATASET_NAME_RE$3, (_match, char) => char.toUpperCase());
|
|
4900
|
-
}
|
|
4901
|
-
function collectDataset$3(node) {
|
|
4902
|
-
const dataset = {};
|
|
4903
|
-
for (const [key, value] of Object.entries(node.attribs ?? {})) {
|
|
4904
|
-
if (!key.startsWith("data-") || key.startsWith("data-sim-")) continue;
|
|
4905
|
-
dataset[toDatasetKey$3(key)] = value;
|
|
4906
|
-
}
|
|
4907
|
-
return dataset;
|
|
4908
|
-
}
|
|
4909
5162
|
function createEventPayload$1(node, eventName, event) {
|
|
4910
|
-
const dataset =
|
|
5163
|
+
const dataset = collectNodeDataset(node);
|
|
4911
5164
|
const nodeId = node.attribs?.id ?? "";
|
|
4912
5165
|
return {
|
|
4913
5166
|
bubbles: false,
|
|
@@ -4995,7 +5248,7 @@ var HeadlessTestingNodeHandle = class HeadlessTestingNodeHandle {
|
|
|
4995
5248
|
}
|
|
4996
5249
|
async dataset() {
|
|
4997
5250
|
this.assertActive();
|
|
4998
|
-
return
|
|
5251
|
+
return collectNodeDataset(this.node);
|
|
4999
5252
|
}
|
|
5000
5253
|
async scope() {
|
|
5001
5254
|
this.assertActive();
|
|
@@ -5070,13 +5323,19 @@ var HeadlessTestingNodeHandle = class HeadlessTestingNodeHandle {
|
|
|
5070
5323
|
//#region src/view/render.ts
|
|
5071
5324
|
const LEADING_SLASH_RE$4 = /^\/+/;
|
|
5072
5325
|
const TEMPLATE_INTERPOLATION_RE$1 = /\{\{([^{}]+)\}\}/g;
|
|
5073
|
-
function
|
|
5326
|
+
function resolveRawValueByPath$1(source, expression) {
|
|
5074
5327
|
const normalized = expression.trim();
|
|
5075
|
-
if (!normalized) return
|
|
5328
|
+
if (!normalized) return;
|
|
5076
5329
|
const segments = normalized.split(".").filter(Boolean);
|
|
5077
5330
|
let current = source;
|
|
5078
|
-
for (const segment of segments)
|
|
5079
|
-
|
|
5331
|
+
for (const segment of segments) {
|
|
5332
|
+
if (current == null || typeof current !== "object" && typeof current !== "function") return;
|
|
5333
|
+
current = Reflect.get(current, segment);
|
|
5334
|
+
}
|
|
5335
|
+
return current;
|
|
5336
|
+
}
|
|
5337
|
+
function resolveValueByPath$1(source, expression) {
|
|
5338
|
+
return resolveRawValueByPath$1(source, expression) ?? "";
|
|
5080
5339
|
}
|
|
5081
5340
|
function interpolateTemplate$1(input, data) {
|
|
5082
5341
|
return input.replace(TEMPLATE_INTERPOLATION_RE$1, (_match, expression) => {
|
|
@@ -5084,6 +5343,10 @@ function interpolateTemplate$1(input, data) {
|
|
|
5084
5343
|
return typeof value === "string" ? value : String(value);
|
|
5085
5344
|
});
|
|
5086
5345
|
}
|
|
5346
|
+
function isMustacheOnly$1(value) {
|
|
5347
|
+
const trimmed = value.trim();
|
|
5348
|
+
return trimmed.startsWith("{{") && trimmed.endsWith("}}") && !trimmed.includes("{{", 2);
|
|
5349
|
+
}
|
|
5087
5350
|
function visitDom(node, visitor) {
|
|
5088
5351
|
visitor(node);
|
|
5089
5352
|
for (const child of node.children ?? []) visitDom(child, visitor);
|
|
@@ -5091,7 +5354,18 @@ function visitDom(node, visitor) {
|
|
|
5091
5354
|
function interpolateDomTree(root, data) {
|
|
5092
5355
|
visitDom(root, (node) => {
|
|
5093
5356
|
if (typeof node.data === "string") node.data = interpolateTemplateText(node.data, data);
|
|
5094
|
-
if (node.attribs)
|
|
5357
|
+
if (node.attribs) {
|
|
5358
|
+
let dataset;
|
|
5359
|
+
for (const [key, value] of Object.entries(node.attribs)) {
|
|
5360
|
+
const resolvedValue = isMustacheOnly$1(value) ? resolveRawValueByPath$1(data, value.trim().slice(2, -2)) : interpolateTemplate$1(value, data);
|
|
5361
|
+
node.attribs[key] = String(resolvedValue ?? "");
|
|
5362
|
+
if (isDatasetAttribute(key)) {
|
|
5363
|
+
dataset ??= {};
|
|
5364
|
+
dataset[toDatasetKey(key)] = resolvedValue;
|
|
5365
|
+
}
|
|
5366
|
+
}
|
|
5367
|
+
node.dataset = dataset;
|
|
5368
|
+
}
|
|
5095
5369
|
});
|
|
5096
5370
|
}
|
|
5097
5371
|
function escapeText$1(text) {
|
|
@@ -5125,21 +5399,9 @@ function renderPageTree(project, page) {
|
|
|
5125
5399
|
}
|
|
5126
5400
|
//#endregion
|
|
5127
5401
|
//#region src/view/selectorQuery.ts
|
|
5128
|
-
const DATASET_NAME_RE$2 = /-([a-z])/g;
|
|
5129
5402
|
const LEADING_MARK_PREFIX_RE = /^mark[:\-]?/;
|
|
5130
5403
|
const MARK_NAME_RE = /[:\-]([a-z])/g;
|
|
5131
5404
|
const NUMERIC_LIKE_VALUE_RE$1 = /-?\d+(?:\.\d+)?/;
|
|
5132
|
-
function toDatasetKey$2(attributeName) {
|
|
5133
|
-
return attributeName.slice(5).replace(DATASET_NAME_RE$2, (_match, char) => char.toUpperCase());
|
|
5134
|
-
}
|
|
5135
|
-
function collectDataset$2(node) {
|
|
5136
|
-
const dataset = {};
|
|
5137
|
-
for (const [key, value] of Object.entries(node.attribs ?? {})) {
|
|
5138
|
-
if (!key.startsWith("data-") || key.startsWith("data-sim-")) continue;
|
|
5139
|
-
dataset[toDatasetKey$2(key)] = value;
|
|
5140
|
-
}
|
|
5141
|
-
return dataset;
|
|
5142
|
-
}
|
|
5143
5405
|
function toMarkKey(attributeName) {
|
|
5144
5406
|
return attributeName.replace(LEADING_MARK_PREFIX_RE, "").replace(MARK_NAME_RE, (_match, char) => char.toUpperCase());
|
|
5145
5407
|
}
|
|
@@ -5216,7 +5478,7 @@ function resolvePropertyValue(node, propertyName) {
|
|
|
5216
5478
|
if (!normalizedPropertyName) return;
|
|
5217
5479
|
if (normalizedPropertyName === "id") return node.attribs?.id ?? "";
|
|
5218
5480
|
if (normalizedPropertyName === "class") return node.attribs?.class ?? "";
|
|
5219
|
-
if (normalizedPropertyName === "dataset") return
|
|
5481
|
+
if (normalizedPropertyName === "dataset") return collectNodeDataset(node);
|
|
5220
5482
|
return node.attribs?.[normalizedPropertyName];
|
|
5221
5483
|
}
|
|
5222
5484
|
function pickProperties(node, propertyNames) {
|
|
@@ -5233,7 +5495,7 @@ function pickComputedStyle(node, propertyNames) {
|
|
|
5233
5495
|
function resolveFieldsResult(node, fields, options) {
|
|
5234
5496
|
const result = {};
|
|
5235
5497
|
if (fields.id) result.id = node.attribs?.id ?? "";
|
|
5236
|
-
if (fields.dataset) result.dataset =
|
|
5498
|
+
if (fields.dataset) result.dataset = collectNodeDataset(node);
|
|
5237
5499
|
if (fields.mark) result.mark = collectMark(node);
|
|
5238
5500
|
if (fields.rect || fields.size) {
|
|
5239
5501
|
const rect = resolveRect$1(node, options.root.name === "page" ? options.windowInfo : void 0);
|
|
@@ -5938,20 +6200,8 @@ function createHeadlessMediaQueryObserver(driver, onDisconnect) {
|
|
|
5938
6200
|
}
|
|
5939
6201
|
//#endregion
|
|
5940
6202
|
//#region src/view/videoContext.ts
|
|
5941
|
-
const DATASET_NAME_RE$1 = /-([a-z])/g;
|
|
5942
|
-
function toDatasetKey$1(attributeName) {
|
|
5943
|
-
return attributeName.slice(5).replace(DATASET_NAME_RE$1, (_match, char) => char.toUpperCase());
|
|
5944
|
-
}
|
|
5945
|
-
function collectDataset$1(node) {
|
|
5946
|
-
const dataset = {};
|
|
5947
|
-
for (const [key, value] of Object.entries(node.attribs ?? {})) {
|
|
5948
|
-
if (!key.startsWith("data-") || key.startsWith("data-sim-")) continue;
|
|
5949
|
-
dataset[toDatasetKey$1(key)] = value;
|
|
5950
|
-
}
|
|
5951
|
-
return dataset;
|
|
5952
|
-
}
|
|
5953
6203
|
function createEventPayload(node, eventName, detail) {
|
|
5954
|
-
const dataset =
|
|
6204
|
+
const dataset = collectNodeDataset(node);
|
|
5955
6205
|
const nodeId = node.attribs?.id ?? "";
|
|
5956
6206
|
return {
|
|
5957
6207
|
bubbles: false,
|
|
@@ -6063,7 +6313,7 @@ function matchesComponentSelector$1(scope, selector) {
|
|
|
6063
6313
|
if (dataAttrMatch) {
|
|
6064
6314
|
const [, key, value] = dataAttrMatch;
|
|
6065
6315
|
const datasetKey = key.replace(DATASET_KEY_RE$1, (_match, char) => char.toUpperCase());
|
|
6066
|
-
return scope.dataset
|
|
6316
|
+
return scope.dataset != null && Object.hasOwn(scope.dataset, datasetKey) && String(scope.dataset[datasetKey] ?? "") === value;
|
|
6067
6317
|
}
|
|
6068
6318
|
return scope.alias === part;
|
|
6069
6319
|
});
|
|
@@ -6114,6 +6364,7 @@ var BrowserHeadlessSession = class {
|
|
|
6114
6364
|
enterOptions = createAppLaunchOptions("", {});
|
|
6115
6365
|
launchOptions = createAppLaunchOptions("", {});
|
|
6116
6366
|
kernel = new RuntimeKernel();
|
|
6367
|
+
startupNavigation = new StartupNavigationQueue(this.kernel.scheduler);
|
|
6117
6368
|
wxState;
|
|
6118
6369
|
pullDownRefreshState = {
|
|
6119
6370
|
active: false,
|
|
@@ -6146,7 +6397,7 @@ var BrowserHeadlessSession = class {
|
|
|
6146
6397
|
});
|
|
6147
6398
|
});
|
|
6148
6399
|
this.tabBarVisible = this.tabBarRoutes.size > 0;
|
|
6149
|
-
this.moduleLoader = createBrowserModuleLoader(this.files, this.registries, () => this.pages.slice(), () => this.getApp(), {
|
|
6400
|
+
this.moduleLoader = createBrowserModuleLoader(this.files, this.registries, () => this.pages.slice(), () => this.getApp(), bindStartupNavigation({
|
|
6150
6401
|
chooseImage: (option) => this.wxState.chooseImage(option ?? {}),
|
|
6151
6402
|
chooseMessageFile: (option) => this.wxState.chooseMessageFile(option ?? {}),
|
|
6152
6403
|
chooseMedia: (option) => this.wxState.chooseMedia(option ?? {}),
|
|
@@ -6225,8 +6476,11 @@ var BrowserHeadlessSession = class {
|
|
|
6225
6476
|
removeTabBarBadge: (option) => this.removeTabBarBadge(option.index),
|
|
6226
6477
|
setTabBarBadge: (option) => this.setTabBarBadge(option.index, option.text),
|
|
6227
6478
|
updateShareMenu: (option) => this.wxState.updateShareMenu(option)
|
|
6228
|
-
}, {
|
|
6229
|
-
globals:
|
|
6479
|
+
}, this.startupNavigation), {
|
|
6480
|
+
globals: {
|
|
6481
|
+
...options.globals,
|
|
6482
|
+
__wxConfig: createMiniProgramHostConfig(this.project.appConfig, options.globals?.__wxConfig)
|
|
6483
|
+
},
|
|
6230
6484
|
kernel: this.kernel,
|
|
6231
6485
|
miniprogramRootPath: this.project.miniprogramRootPath,
|
|
6232
6486
|
plugins: this.project.plugins
|
|
@@ -6702,9 +6956,16 @@ var BrowserHeadlessSession = class {
|
|
|
6702
6956
|
return this.appInstance;
|
|
6703
6957
|
}
|
|
6704
6958
|
bootstrapNavigation(launchOptions = createAppLaunchOptions("", {})) {
|
|
6705
|
-
|
|
6706
|
-
this.
|
|
6707
|
-
|
|
6959
|
+
if (this.appInstance) return null;
|
|
6960
|
+
this.startupNavigation.capture(() => {
|
|
6961
|
+
this.bootstrap(launchOptions);
|
|
6962
|
+
});
|
|
6963
|
+
if (launchOptions.path) {
|
|
6964
|
+
const query = new URLSearchParams(launchOptions.query).toString();
|
|
6965
|
+
this.reLaunch(`/${launchOptions.path}${query ? `?${query}` : ""}`);
|
|
6966
|
+
}
|
|
6967
|
+
this.startupNavigation.flush();
|
|
6968
|
+
return this.currentPageInstance;
|
|
6708
6969
|
}
|
|
6709
6970
|
reLaunch(url) {
|
|
6710
6971
|
const target = this.resolveNavigationTarget(url);
|
|
@@ -6934,8 +7195,8 @@ var BrowserHeadlessSession = class {
|
|
|
6934
7195
|
});
|
|
6935
7196
|
pageInstance.createIntersectionObserver = (options) => this.createIntersectionObserver(pageInstance, options);
|
|
6936
7197
|
pageInstance.createMediaQueryObserver = () => this.createMediaQueryObserver(pageInstance);
|
|
6937
|
-
pageInstance.selectComponent = (selector) => this.selectComponent(selector);
|
|
6938
|
-
pageInstance.selectAllComponents = (selector) => this.selectAllComponents(selector);
|
|
7198
|
+
pageInstance.selectComponent = (selector) => resolveNativeComponentSelection(this.selectComponent(selector));
|
|
7199
|
+
pageInstance.selectAllComponents = (selector) => this.selectAllComponents(selector).map(resolveNativeComponentSelection);
|
|
6939
7200
|
pageInstance.getTabBar = () => {
|
|
6940
7201
|
if (this.currentPageInstance === pageInstance) this.renderCurrentPage();
|
|
6941
7202
|
return this.componentCache.get(customTabBarScopeId(pageInstance.route)) ?? null;
|
|
@@ -7277,7 +7538,6 @@ function getRuntimeWxsLoader(owner, artifactSource) {
|
|
|
7277
7538
|
//#endregion
|
|
7278
7539
|
//#region src/runtime/render/shared.ts
|
|
7279
7540
|
const TEMPLATE_INTERPOLATION_RE = /\{\{([^{}]+)\}\}/g;
|
|
7280
|
-
const DATASET_NAME_RE = /-([a-z])/g;
|
|
7281
7541
|
const LEADING_SLASH_RE$2 = /^\/+/;
|
|
7282
7542
|
const EVENT_BINDING_ATTRS = [
|
|
7283
7543
|
"bindtap",
|
|
@@ -7300,15 +7560,12 @@ function isMustacheOnly(value) {
|
|
|
7300
7560
|
const trimmed = value.trim();
|
|
7301
7561
|
return trimmed.startsWith("{{") && trimmed.endsWith("}}") && !trimmed.includes("{{", 2);
|
|
7302
7562
|
}
|
|
7303
|
-
function toDatasetKey(attributeName) {
|
|
7304
|
-
return attributeName.slice(5).replace(DATASET_NAME_RE, (_match, char) => char.toUpperCase());
|
|
7305
|
-
}
|
|
7306
7563
|
function collectDataset(node, source) {
|
|
7564
|
+
if (node.dataset) return collectNodeDataset(node);
|
|
7307
7565
|
const dataset = {};
|
|
7308
7566
|
for (const [key, value] of Object.entries(node.attribs ?? {})) {
|
|
7309
|
-
if (!
|
|
7310
|
-
|
|
7311
|
-
dataset[toDatasetKey(key)] = String(resolvedValue ?? "");
|
|
7567
|
+
if (!isDatasetAttribute(key)) continue;
|
|
7568
|
+
dataset[toDatasetKey(key)] = source && isMustacheOnly(value) ? resolveTemplateExpression(source, value) : value;
|
|
7312
7569
|
}
|
|
7313
7570
|
return dataset;
|
|
7314
7571
|
}
|
|
@@ -7322,6 +7579,7 @@ function cloneNode(node) {
|
|
|
7322
7579
|
return {
|
|
7323
7580
|
...node,
|
|
7324
7581
|
attribs: node.attribs ? { ...node.attribs } : void 0,
|
|
7582
|
+
dataset: node.dataset ? { ...node.dataset } : void 0,
|
|
7325
7583
|
children: node.children?.map((child) => cloneNode(child))
|
|
7326
7584
|
};
|
|
7327
7585
|
}
|
|
@@ -7373,7 +7631,7 @@ function isTagNode(node) {
|
|
|
7373
7631
|
function resolveAttributeValue(value, scope) {
|
|
7374
7632
|
if (isMustacheOnly(value)) {
|
|
7375
7633
|
const expression = value.trim().slice(2, -2);
|
|
7376
|
-
return
|
|
7634
|
+
return resolveRawValueByPath(wxsScopeData(scope), expression);
|
|
7377
7635
|
}
|
|
7378
7636
|
return interpolateTemplate(value, wxsScopeData(scope));
|
|
7379
7637
|
}
|
|
@@ -7392,13 +7650,20 @@ function applyNodeBindings(node, scope) {
|
|
|
7392
7650
|
node.attribs ??= {};
|
|
7393
7651
|
node.attribs["data-sim-scope"] = scope.getScopeId();
|
|
7394
7652
|
for (const key of STRUCTURAL_ATTRS) delete node.attribs[key];
|
|
7653
|
+
let dataset;
|
|
7395
7654
|
for (const [key, value] of Object.entries({ ...node.attribs })) {
|
|
7396
7655
|
if (EVENT_BINDING_ATTRS.includes(key)) {
|
|
7397
7656
|
node.attribs["data-sim-tap"] = value;
|
|
7398
7657
|
continue;
|
|
7399
7658
|
}
|
|
7400
|
-
|
|
7659
|
+
const resolvedValue = typeof value === "string" ? resolveAttributeValue(value, scope) : value;
|
|
7660
|
+
node.attribs[key] = String(resolvedValue ?? "");
|
|
7661
|
+
if (isDatasetAttribute(key)) {
|
|
7662
|
+
dataset ??= {};
|
|
7663
|
+
dataset[toDatasetKey(key)] = resolvedValue;
|
|
7664
|
+
}
|
|
7401
7665
|
}
|
|
7666
|
+
node.dataset = dataset;
|
|
7402
7667
|
}
|
|
7403
7668
|
function evaluateConditionalBranch(node, scope) {
|
|
7404
7669
|
const condition = node.attribs?.["wx:if"] ?? node.attribs?.["wx:elif"];
|
|
@@ -7572,7 +7837,7 @@ function resolveComponentProperties(clonedNode, scope, definition) {
|
|
|
7572
7837
|
bindingExpressions
|
|
7573
7838
|
};
|
|
7574
7839
|
}
|
|
7575
|
-
function createRuntimeComponentInstance(componentScopeId, context, clonedNode, componentEntry, nextProperties, ownerScopeId) {
|
|
7840
|
+
function createRuntimeComponentInstance(componentScopeId, context, clonedNode, componentEntry, nextProperties, ownerScopeId, beforeCreated) {
|
|
7576
7841
|
const componentProperties = Object.keys(componentEntry.definition.methods ?? {}).some((key) => key.startsWith("__weapp_vite_")) || Object.hasOwn(componentEntry.definition.properties ?? {}, "__wvSlotOwnerId") ? Object.fromEntries(Object.keys(componentEntry.definition.properties ?? {}).filter((key) => Object.hasOwn(nextProperties, key)).map((key) => [key, nextProperties[key]])) : nextProperties;
|
|
7577
7842
|
const componentInstance = createComponentInstance({
|
|
7578
7843
|
definition: componentEntry.definition,
|
|
@@ -7584,10 +7849,11 @@ function createRuntimeComponentInstance(componentScopeId, context, clonedNode, c
|
|
|
7584
7849
|
componentInstance.createIntersectionObserver = (options) => context.session.createIntersectionObserver(componentInstance, options);
|
|
7585
7850
|
componentInstance.createMediaQueryObserver = () => context.session.createMediaQueryObserver(componentInstance);
|
|
7586
7851
|
componentInstance.createSelectorQuery = () => context.moduleLoader.wx.createSelectorQuery().in(componentInstance);
|
|
7587
|
-
componentInstance.selectComponent = (selector) => context.session.selectComponentWithin(componentScopeId, selector);
|
|
7588
|
-
componentInstance.selectAllComponents = (selector) => context.session.selectAllComponentsWithin(componentScopeId, selector);
|
|
7852
|
+
componentInstance.selectComponent = (selector) => resolveNativeComponentSelection(context.session.selectComponentWithin(componentScopeId, selector));
|
|
7853
|
+
componentInstance.selectAllComponents = (selector) => context.session.selectAllComponentsWithin(componentScopeId, selector).map(resolveNativeComponentSelection);
|
|
7589
7854
|
componentInstance.selectOwnerComponent = () => ownerScopeId ? context.componentCache.get(ownerScopeId) ?? null : null;
|
|
7590
7855
|
context.componentCache.set(componentScopeId, componentInstance);
|
|
7856
|
+
beforeCreated?.(componentInstance);
|
|
7591
7857
|
runComponentLifecycle(componentInstance, "created");
|
|
7592
7858
|
componentInstance.__propertySnapshots = Object.fromEntries(Object.entries(componentInstance.properties).map(([key, propertyValue]) => [key, cloneValue(propertyValue)]));
|
|
7593
7859
|
syncComponentProperties(componentInstance, componentInstance.__definition__ ?? componentEntry.definition, componentProperties, {}, []);
|
|
@@ -7723,12 +7989,16 @@ function renderNodeTree(node, scope, context, ownerJsonPath, ownerFilePath, inst
|
|
|
7723
7989
|
const componentScopeId = `${instancePath}/${clonedNode.name}`;
|
|
7724
7990
|
const ownerScopeId = scope.getScopeId().includes("/") ? scope.getScopeId() : void 0;
|
|
7725
7991
|
const { nextProperties, bindingExpressions } = resolveComponentProperties(clonedNode, scope, componentEntry.definition);
|
|
7992
|
+
const genericComponents = resolveComponentGenerics(context, clonedNode, ownerJsonPath, ownerFilePath, componentEntry.filePath);
|
|
7993
|
+
const slots = collectComponentSlots(clonedNode, scope, ownerJsonPath, ownerFilePath, componentScopeId, templateRenderState);
|
|
7726
7994
|
let componentInstance = context.componentCache.get(componentScopeId);
|
|
7727
|
-
if (!componentInstance) componentInstance = createRuntimeComponentInstance(componentScopeId, context, clonedNode, componentEntry, nextProperties, ownerScopeId)
|
|
7995
|
+
if (!componentInstance) componentInstance = createRuntimeComponentInstance(componentScopeId, context, clonedNode, componentEntry, nextProperties, ownerScopeId, (instance) => {
|
|
7996
|
+
const initialScope = createComponentScope(clonedNode, scope, componentScopeId, instance, genericComponents, slots);
|
|
7997
|
+
context.componentScopes.set(componentScopeId, initialScope);
|
|
7998
|
+
renderRuntimeComponentTemplate(context, componentEntry, renderNodeTree, initialScope, componentScopeId, /* @__PURE__ */ new Set());
|
|
7999
|
+
});
|
|
7728
8000
|
else syncComponentProperties(componentInstance, componentInstance.__definition__ ?? componentEntry.definition, nextProperties, bindingExpressions, context.changedPageKeys);
|
|
7729
8001
|
seenComponentScopes.add(componentScopeId);
|
|
7730
|
-
const genericComponents = resolveComponentGenerics(context, clonedNode, ownerJsonPath, ownerFilePath, componentEntry.filePath);
|
|
7731
|
-
const slots = collectComponentSlots(clonedNode, scope, ownerJsonPath, ownerFilePath, componentScopeId, templateRenderState);
|
|
7732
8002
|
const componentScope = createComponentScope(clonedNode, scope, componentScopeId, componentInstance, genericComponents, slots);
|
|
7733
8003
|
context.componentScopes.set(componentScopeId, componentScope);
|
|
7734
8004
|
const renderedComponentRoot = renderRuntimeComponentTemplate(context, componentEntry, renderNodeTree, componentScope, componentScopeId, seenComponentScopes);
|
|
@@ -7738,6 +8008,10 @@ function renderNodeTree(node, scope, context, ownerJsonPath, ownerFilePath, inst
|
|
|
7738
8008
|
...clonedNode.attribs,
|
|
7739
8009
|
...renderedComponentRoot.attribs
|
|
7740
8010
|
};
|
|
8011
|
+
if (clonedNode.dataset || renderedComponentRoot.dataset) renderedComponentRoot.dataset = {
|
|
8012
|
+
...clonedNode.dataset,
|
|
8013
|
+
...renderedComponentRoot.dataset
|
|
8014
|
+
};
|
|
7741
8015
|
renderedComponentRoot.attribs["data-sim-component"] = clonedNode.name;
|
|
7742
8016
|
renderedComponentRoot.attribs["data-sim-node"] = instancePath;
|
|
7743
8017
|
renderedComponentRoot.attribs["data-sim-scope"] = componentScopeId;
|
|
@@ -7781,7 +8055,8 @@ function renderRuntimePageTree(context, page) {
|
|
|
7781
8055
|
const pageAttaching = isComponentPageAttaching(page);
|
|
7782
8056
|
const attached = !pageAttaching && flushComponentAttachments([...seenComponentScopes].map((scopeId) => context.componentCache.get(scopeId)), (instance) => runComponentLifecycle(instance, "attached"));
|
|
7783
8057
|
const removed = [...context.componentCache].filter(([scopeId]) => scopeId.startsWith(`${pageScopeId}/`) && !seenComponentScopes.has(scopeId));
|
|
7784
|
-
for (const [, instance] of removed) runComponentLifecycle(instance, "detached");
|
|
8058
|
+
for (const [scopeId, instance] of removed) if (isComponentAttached(instance)) runComponentLifecycle(instance, "detached");
|
|
8059
|
+
else scheduleDiscardedComponentReady(context.componentCache, scopeId, instance);
|
|
7785
8060
|
const instances = [...seenComponentScopes].map((scopeId) => context.componentCache.get(scopeId));
|
|
7786
8061
|
const relationsChanged = !pageAttaching && !hasPendingComponentAttachments(instances) && syncComponentRelations(context.componentCache, seenComponentScopes, pageScopeId);
|
|
7787
8062
|
for (const [scopeId] of removed) {
|
|
@@ -7789,6 +8064,7 @@ function renderRuntimePageTree(context, page) {
|
|
|
7789
8064
|
context.componentScopes.delete(scopeId);
|
|
7790
8065
|
}
|
|
7791
8066
|
if (pageAttached || attached || relationsChanged) return renderRuntimePageTree(context, page);
|
|
8067
|
+
if (!isPageBeforeReady(page)) flushDiscardedComponentReady(context.componentCache, pageScopeId, (instance) => runComponentLifecycle(instance, "ready"));
|
|
7792
8068
|
if (!isPageBeforeReady(page) && flushComponentReady(instances, (instance) => {
|
|
7793
8069
|
runComponentLifecycle(instance, "ready");
|
|
7794
8070
|
if (instance !== context.componentCache.get(customTabBarScopeId(route))) instance.__definition__?.pageLifetimes?.show?.call(instance);
|
|
@@ -8071,7 +8347,7 @@ function matchesComponentSelector(scope, selector) {
|
|
|
8071
8347
|
if (dataAttrMatch) {
|
|
8072
8348
|
const [, key, value] = dataAttrMatch;
|
|
8073
8349
|
const datasetKey = key.replace(DATASET_KEY_RE, (_match, char) => char.toUpperCase());
|
|
8074
|
-
return scope.dataset
|
|
8350
|
+
return scope.dataset != null && Object.hasOwn(scope.dataset, datasetKey) && String(scope.dataset[datasetKey] ?? "") === value;
|
|
8075
8351
|
}
|
|
8076
8352
|
return scope.alias === part;
|
|
8077
8353
|
});
|
|
@@ -8097,6 +8373,7 @@ function resolveNavigationPath(targetPath, baseRoute) {
|
|
|
8097
8373
|
var HeadlessSession = class {
|
|
8098
8374
|
project;
|
|
8099
8375
|
kernel = new RuntimeKernel();
|
|
8376
|
+
startupNavigation = new StartupNavigationQueue(this.kernel.scheduler);
|
|
8100
8377
|
appDefinition = null;
|
|
8101
8378
|
appInstance = null;
|
|
8102
8379
|
appLifecycle = new HeadlessAppLifecycle();
|
|
@@ -8151,7 +8428,7 @@ var HeadlessSession = class {
|
|
|
8151
8428
|
});
|
|
8152
8429
|
});
|
|
8153
8430
|
this.tabBarVisible = this.tabBarRoutes.size > 0;
|
|
8154
|
-
this.moduleLoader = createModuleLoader(this.registries, () => this.pages.slice(), () => this.getApp(), {
|
|
8431
|
+
this.moduleLoader = createModuleLoader(this.registries, () => this.pages.slice(), () => this.getApp(), bindStartupNavigation({
|
|
8155
8432
|
chooseImage: (option) => this.wxState.chooseImage(option ?? {}),
|
|
8156
8433
|
chooseMessageFile: (option) => this.wxState.chooseMessageFile(option ?? {}),
|
|
8157
8434
|
chooseMedia: (option) => this.wxState.chooseMedia(option ?? {}),
|
|
@@ -8230,9 +8507,12 @@ var HeadlessSession = class {
|
|
|
8230
8507
|
removeTabBarBadge: (option) => this.removeTabBarBadge(option.index),
|
|
8231
8508
|
setTabBarBadge: (option) => this.setTabBarBadge(option.index, option.text),
|
|
8232
8509
|
updateShareMenu: (option) => this.wxState.updateShareMenu(option)
|
|
8233
|
-
}, {
|
|
8510
|
+
}, this.startupNavigation), {
|
|
8234
8511
|
artifactSource: this.project.artifactSource,
|
|
8235
|
-
globals:
|
|
8512
|
+
globals: {
|
|
8513
|
+
...options.globals,
|
|
8514
|
+
__wxConfig: createMiniProgramHostConfig(this.project.appConfig, options.globals?.__wxConfig)
|
|
8515
|
+
},
|
|
8236
8516
|
kernel: this.kernel,
|
|
8237
8517
|
miniprogramRootPath: this.project.miniprogramRootPath,
|
|
8238
8518
|
onConsole: (entry) => this.emit("console", entry),
|
|
@@ -8686,9 +8966,16 @@ var HeadlessSession = class {
|
|
|
8686
8966
|
if (Object.hasOwn(runtimeApp, "routes")) this.appInstance.routes = runtimeApp.routes;
|
|
8687
8967
|
}
|
|
8688
8968
|
bootstrapNavigation(launchOptions = createAppLaunchOptions("", {})) {
|
|
8689
|
-
|
|
8690
|
-
this.
|
|
8691
|
-
|
|
8969
|
+
if (this.appInstance) return null;
|
|
8970
|
+
this.startupNavigation.capture(() => {
|
|
8971
|
+
this.bootstrap(launchOptions);
|
|
8972
|
+
});
|
|
8973
|
+
if (launchOptions.path) {
|
|
8974
|
+
const query = new URLSearchParams(launchOptions.query).toString();
|
|
8975
|
+
this.reLaunch(`/${launchOptions.path}${query ? `?${query}` : ""}`);
|
|
8976
|
+
}
|
|
8977
|
+
this.startupNavigation.flush();
|
|
8978
|
+
return this.currentPageInstance;
|
|
8692
8979
|
}
|
|
8693
8980
|
reLaunch(url) {
|
|
8694
8981
|
const target = this.resolveNavigationTarget(url);
|
|
@@ -8889,8 +9176,8 @@ var HeadlessSession = class {
|
|
|
8889
9176
|
});
|
|
8890
9177
|
pageInstance.createIntersectionObserver = (options) => this.createIntersectionObserver(pageInstance, options);
|
|
8891
9178
|
pageInstance.createMediaQueryObserver = () => this.createMediaQueryObserver(pageInstance);
|
|
8892
|
-
pageInstance.selectComponent = (selector) => this.selectComponent(selector);
|
|
8893
|
-
pageInstance.selectAllComponents = (selector) => this.selectAllComponents(selector);
|
|
9179
|
+
pageInstance.selectComponent = (selector) => resolveNativeComponentSelection(this.selectComponent(selector));
|
|
9180
|
+
pageInstance.selectAllComponents = (selector) => this.selectAllComponents(selector).map(resolveNativeComponentSelection);
|
|
8894
9181
|
pageInstance.getTabBar = () => {
|
|
8895
9182
|
if (this.currentPageInstance === pageInstance) this.renderCurrentPage();
|
|
8896
9183
|
return this.componentCache.get(customTabBarScopeId(pageInstance.route)) ?? null;
|
|
@@ -9753,4 +10040,4 @@ async function launch(options) {
|
|
|
9753
10040
|
}
|
|
9754
10041
|
}
|
|
9755
10042
|
//#endregion
|
|
9756
|
-
export { BrowserHeadlessSession, HEADLESS_PLUGIN_VIRTUAL_ROOT, HeadlessSession, HeadlessTestingNodeHandle, HeadlessTestingPageHandle, HeadlessTestingScopeHandle, HeadlessTestingSessionHandle, RuntimeDiagnostics, RuntimeKernel, RuntimeScheduler, cloneValue, coerceComponentPropertyValue, collectMiniProgramEventBindings, createAppInstance, createArtifactProject, createBrowserHeadlessSession, createBrowserModuleLoader, createBrowserProject, createBrowserVirtualFiles, createBrowserVirtualFilesFromDirectory, createComponentInstance, createFileSystemArtifactSource, createHeadlessSession, createHeadlessUniEventBus, createHeadlessWx, createHeadlessWxState, createHostRegistries, createLogicalNode, createMemoryArtifactSource, createOverlayArtifactSource, createPageInstance, createPluginArtifactSource, createPluginVirtualRoot, createProjectDescriptor, executeSelectorQueryRequests, getPageInstanceId, hasBrowserVirtualFile, hasComponentPropertyValueChanged, launch, loadProject, normalizeBrowserFilePath, normalizeComponentPageDefinition, normalizeComponentPropertyValue, querySelectorAll, readBrowserVirtualFile, readRenderedNodes, readRenderedSelectorNodes, registerAppDefinition, registerComponentDefinition, registerExportedComponentDefinition, registerPageDefinition, renderBrowserPageTree, renderPageTree, renderRuntimePageTree, resolveBrowserPageStyles, resolveMiniProgramEventBinding, resolvePluginRequest, resolveRoutesFromAppConfig, resolveSelectorQueryScopeRoot, resolveSelectorScrollTop, runComponentLifecycle, runComponentObservers, runComponentPageLifetime, waitForPageComponent, waitForPageComponents, waitForPageData, waitForPageSelector, waitForPageText, waitForPageTextGone, waitForRenderedPage, wechat };
|
|
10043
|
+
export { BrowserHeadlessSession, HEADLESS_PLUGIN_VIRTUAL_ROOT, HeadlessSession, HeadlessTestingNodeHandle, HeadlessTestingPageHandle, HeadlessTestingScopeHandle, HeadlessTestingSessionHandle, RuntimeDiagnostics, RuntimeKernel, RuntimeScheduler, cloneValue, coerceComponentPropertyValue, collectMiniProgramEventBindings, createAppInstance, createArtifactProject, createBrowserHeadlessSession, createBrowserModuleLoader, createBrowserProject, createBrowserVirtualFiles, createBrowserVirtualFilesFromDirectory, createComponentInstance, createFileSystemArtifactSource, createHeadlessSession, createHeadlessUniEventBus, createHeadlessWx, createHeadlessWxState, createHostRegistries, createLogicalNode, createMemoryArtifactSource, createMiniProgramHostConfig, createOverlayArtifactSource, createPageInstance, createPluginArtifactSource, createPluginVirtualRoot, createProjectDescriptor, executeSelectorQueryRequests, getPageInstanceId, hasBrowserVirtualFile, hasComponentPropertyValueChanged, launch, loadProject, normalizeBrowserFilePath, normalizeComponentPageDefinition, normalizeComponentPropertyValue, querySelectorAll, readBrowserVirtualFile, readRenderedNodes, readRenderedSelectorNodes, registerAppDefinition, registerComponentDefinition, registerExportedComponentDefinition, registerPageDefinition, renderBrowserPageTree, renderPageTree, renderRuntimePageTree, resolveBrowserPageStyles, resolveMiniProgramEventBinding, resolvePluginRequest, resolveRoutesFromAppConfig, resolveSelectorQueryScopeRoot, resolveSelectorScrollTop, runComponentLifecycle, runComponentObservers, runComponentPageLifetime, waitForPageComponent, waitForPageComponents, waitForPageData, waitForPageSelector, waitForPageText, waitForPageTextGone, waitForRenderedPage, wechat };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpcore/simulator",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.6.1",
|
|
5
5
|
"description": "Headless mini-program runtime and testing kernel for the weapp-vite ecosystem",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
"node": "^20.19.0 || >=22.12.0"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@babel/parser": "^8.0.
|
|
47
|
-
"@weapp-core/constants": "0.2.
|
|
46
|
+
"@babel/parser": "^8.0.6",
|
|
47
|
+
"@weapp-core/constants": "0.2.5",
|
|
48
48
|
"css-select": "^7.0.0",
|
|
49
49
|
"css-what": "^8.0.0",
|
|
50
50
|
"fontoxpath": "^3.34.0",
|