@open-wxa/wxa-runner-core 0.8.0 → 0.8.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/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.mjs
CHANGED
|
@@ -464,15 +464,32 @@ var MiniProgram = class {
|
|
|
464
464
|
}
|
|
465
465
|
return pages;
|
|
466
466
|
}
|
|
467
|
-
/**
|
|
467
|
+
/**
|
|
468
|
+
* 读取并预处理页面/组件 json,id 不带扩展名。
|
|
469
|
+
* 基础库运行时只把组件引用和当前路径拼在一起,不查找 miniprogram_npm、不补 /index(开发者工具编译时已解析好),
|
|
470
|
+
* 所以能解析到的引用都换成组件的绝对路径
|
|
471
|
+
*/
|
|
468
472
|
readUnitJson(id, app) {
|
|
469
473
|
const json = { ...readJsonFile(path.join(this.root, id + ".json")) };
|
|
470
|
-
|
|
471
|
-
|
|
474
|
+
const resolve = (fromId, ref) => {
|
|
475
|
+
const resolved = this.resolveComponent(fromId, ref);
|
|
476
|
+
return resolved ? "/" + resolved : null;
|
|
477
|
+
};
|
|
478
|
+
json.usingComponents = Object.fromEntries(
|
|
479
|
+
Object.entries(json.usingComponents || {}).map(([tag, ref]) => [tag, resolve(id, ref) ?? ref])
|
|
480
|
+
);
|
|
481
|
+
if (json.componentGenerics) {
|
|
482
|
+
json.componentGenerics = Object.fromEntries(Object.entries(json.componentGenerics).map(([name, generic]) => [
|
|
483
|
+
name,
|
|
484
|
+
typeof generic === "object" && generic.default ? { ...generic, default: resolve(id, generic.default) ?? generic.default } : generic
|
|
485
|
+
]));
|
|
486
|
+
}
|
|
487
|
+
if (!/(^|\/)miniprogram_npm\//.test(id) && !this.isInIndependentSubPackage(id, app)) {
|
|
472
488
|
for (const [tag, ref] of Object.entries(app.usingComponents || {})) {
|
|
473
489
|
if (json.usingComponents[tag]) continue;
|
|
474
|
-
|
|
475
|
-
|
|
490
|
+
const resolved = resolve("app", ref);
|
|
491
|
+
if (resolved || ref.startsWith("/") || /^plugin(-private)?:\/\//.test(ref)) {
|
|
492
|
+
json.usingComponents[tag] = resolved ?? ref;
|
|
476
493
|
} else {
|
|
477
494
|
const relative = path.posix.relative(path.posix.dirname(id), ref);
|
|
478
495
|
json.usingComponents[tag] = relative.startsWith(".") ? relative : "./" + relative;
|