@open-wxa/wxa-runner-core 0.8.0 → 0.8.2
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/dist/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +22 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -5
- package/dist/index.mjs.map +1 -1
- package/dist/runtime/host.js +86 -14
- package/dist/runtime/host.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -64,7 +64,11 @@ declare class MiniProgram {
|
|
|
64
64
|
workersDir(app: AppJson): string | null;
|
|
65
65
|
/** 主包页面 + 分包页面(带 root 前缀) */
|
|
66
66
|
allPages(app: AppJson): string[];
|
|
67
|
-
/**
|
|
67
|
+
/**
|
|
68
|
+
* 读取并预处理页面/组件 json,id 不带扩展名。
|
|
69
|
+
* 基础库运行时只把组件引用和当前路径拼在一起,不查找 miniprogram_npm、不补 /index(开发者工具编译时已解析好),
|
|
70
|
+
* 所以能解析到的引用都换成组件的绝对路径
|
|
71
|
+
*/
|
|
68
72
|
readUnitJson(id: string, app: AppJson): UnitJson;
|
|
69
73
|
/**
|
|
70
74
|
* 解析组件引用到组件路径(不带扩展名);插件组件或找不到时返回 null。
|
package/dist/index.d.ts
CHANGED
|
@@ -64,7 +64,11 @@ declare class MiniProgram {
|
|
|
64
64
|
workersDir(app: AppJson): string | null;
|
|
65
65
|
/** 主包页面 + 分包页面(带 root 前缀) */
|
|
66
66
|
allPages(app: AppJson): string[];
|
|
67
|
-
/**
|
|
67
|
+
/**
|
|
68
|
+
* 读取并预处理页面/组件 json,id 不带扩展名。
|
|
69
|
+
* 基础库运行时只把组件引用和当前路径拼在一起,不查找 miniprogram_npm、不补 /index(开发者工具编译时已解析好),
|
|
70
|
+
* 所以能解析到的引用都换成组件的绝对路径
|
|
71
|
+
*/
|
|
68
72
|
readUnitJson(id: string, app: AppJson): UnitJson;
|
|
69
73
|
/**
|
|
70
74
|
* 解析组件引用到组件路径(不带扩展名);插件组件或找不到时返回 null。
|
package/dist/index.js
CHANGED
|
@@ -500,15 +500,32 @@ var MiniProgram = class {
|
|
|
500
500
|
}
|
|
501
501
|
return pages;
|
|
502
502
|
}
|
|
503
|
-
/**
|
|
503
|
+
/**
|
|
504
|
+
* 读取并预处理页面/组件 json,id 不带扩展名。
|
|
505
|
+
* 基础库运行时只把组件引用和当前路径拼在一起,不查找 miniprogram_npm、不补 /index(开发者工具编译时已解析好),
|
|
506
|
+
* 所以能解析到的引用都换成组件的绝对路径
|
|
507
|
+
*/
|
|
504
508
|
readUnitJson(id, app) {
|
|
505
509
|
const json = { ...readJsonFile(import_path.default.join(this.root, id + ".json")) };
|
|
506
|
-
|
|
507
|
-
|
|
510
|
+
const resolve = (fromId, ref) => {
|
|
511
|
+
const resolved = this.resolveComponent(fromId, ref);
|
|
512
|
+
return resolved ? "/" + resolved : null;
|
|
513
|
+
};
|
|
514
|
+
json.usingComponents = Object.fromEntries(
|
|
515
|
+
Object.entries(json.usingComponents || {}).map(([tag, ref]) => [tag, resolve(id, ref) ?? ref])
|
|
516
|
+
);
|
|
517
|
+
if (json.componentGenerics) {
|
|
518
|
+
json.componentGenerics = Object.fromEntries(Object.entries(json.componentGenerics).map(([name, generic]) => [
|
|
519
|
+
name,
|
|
520
|
+
typeof generic === "object" && generic.default ? { ...generic, default: resolve(id, generic.default) ?? generic.default } : generic
|
|
521
|
+
]));
|
|
522
|
+
}
|
|
523
|
+
if (!/(^|\/)miniprogram_npm\//.test(id) && !this.isInIndependentSubPackage(id, app)) {
|
|
508
524
|
for (const [tag, ref] of Object.entries(app.usingComponents || {})) {
|
|
509
525
|
if (json.usingComponents[tag]) continue;
|
|
510
|
-
|
|
511
|
-
|
|
526
|
+
const resolved = resolve("app", ref);
|
|
527
|
+
if (resolved || ref.startsWith("/") || /^plugin(-private)?:\/\//.test(ref)) {
|
|
528
|
+
json.usingComponents[tag] = resolved ?? ref;
|
|
512
529
|
} else {
|
|
513
530
|
const relative = import_path.default.posix.relative(import_path.default.posix.dirname(id), ref);
|
|
514
531
|
json.usingComponents[tag] = relative.startsWith(".") ? relative : "./" + relative;
|