@dimina-kit/compiler 0.0.2-dev.20260718085557 → 0.0.2-dev.20260718095333
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/compile-core.browser.js +1655 -900
- package/dist/compile-core.node-chunks/chunk-6734LXNU.js +1530 -0
- package/dist/compile-core.node-chunks/{chunk-O5CWW2ZX.js → chunk-QVEZ34FP.js} +258 -43
- package/dist/compile-core.node-chunks/{logic-compiler-4BUMLGSW.js → logic-compiler-VJWEQMXZ.js} +14 -14
- package/dist/compile-core.node-chunks/{style-compiler-4F5PSTLH.js → style-compiler-YWVITCJW.js} +60 -49
- package/dist/compile-core.node-chunks/{view-compiler-HHZZFMFQ.js → view-compiler-3OUFRVZF.js} +219 -78
- package/dist/compile-core.node.js +4 -4
- package/dist/pool.node-chunks/{chunk-QLBB5HQB.js → chunk-7F3E2G42.js} +258 -43
- package/dist/pool.node-chunks/chunk-DQNLDQGT.js +1530 -0
- package/dist/pool.node-chunks/{chunk-LVUKEB4F.js → chunk-LKL7FBHG.js} +4 -4
- package/dist/pool.node-chunks/{logic-compiler-PK5DY6DB.js → logic-compiler-HMMTJJWY.js} +14 -14
- package/dist/pool.node-chunks/{style-compiler-X4EGM6MY.js → style-compiler-VGVCLQ7X.js} +60 -49
- package/dist/pool.node-chunks/{view-compiler-4GBP7IAT.js → view-compiler-2VZMJ65O.js} +219 -78
- package/dist/pool.node.js +2 -2
- package/dist/stage-worker.browser.js +1655 -900
- package/dist/stage-worker.node.js +2 -2
- package/package.json +7 -7
- package/dist/compile-core.node-chunks/chunk-3MOLMQLJ.js +0 -211
- package/dist/pool.node-chunks/chunk-S7VHZTMY.js +0 -211
|
@@ -1,7 +1,67 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
8
|
+
try {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
} catch (e) {
|
|
11
|
+
throw mod = 0, e;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from))
|
|
17
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
18
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
28
|
+
mod
|
|
29
|
+
));
|
|
30
|
+
|
|
31
|
+
// ../../dimina/fe/packages/compiler/src/common/path-utils.js
|
|
32
|
+
import path from "node:path";
|
|
33
|
+
var WINDOWS_FS_PATH_RE = /^(?:[a-zA-Z]:[\\/]|\\\\)/;
|
|
34
|
+
function isWindowsFsPath(targetPath) {
|
|
35
|
+
return typeof targetPath === "string" && (WINDOWS_FS_PATH_RE.test(targetPath) || targetPath.includes("\\"));
|
|
36
|
+
}
|
|
37
|
+
function getFsPathApi(targetPath) {
|
|
38
|
+
return isWindowsFsPath(targetPath) ? path.win32 : path.posix;
|
|
39
|
+
}
|
|
40
|
+
function normalizeToPosixPath(targetPath) {
|
|
41
|
+
return targetPath.replace(/\\/g, "/");
|
|
42
|
+
}
|
|
43
|
+
function resolveMiniProgramPath(workPath, importerPath, sourcePath) {
|
|
44
|
+
const pathApi = getFsPathApi(importerPath || workPath);
|
|
45
|
+
return sourcePath.startsWith("/") ? pathApi.join(workPath, sourcePath) : pathApi.resolve(pathApi.dirname(importerPath), sourcePath);
|
|
46
|
+
}
|
|
47
|
+
function toMiniProgramModuleId(resolvedPath, workPath) {
|
|
48
|
+
const normalizedResolvedPath = normalizeToPosixPath(resolvedPath);
|
|
49
|
+
const normalizedWorkPath = normalizeToPosixPath(workPath);
|
|
50
|
+
let moduleId = normalizedResolvedPath.startsWith(normalizedWorkPath) ? normalizedResolvedPath.slice(normalizedWorkPath.length) : normalizedResolvedPath;
|
|
51
|
+
moduleId = moduleId.replace(/\/+/g, "/");
|
|
52
|
+
if (!moduleId.startsWith("/")) {
|
|
53
|
+
moduleId = `/${moduleId}`;
|
|
54
|
+
}
|
|
55
|
+
return moduleId;
|
|
56
|
+
}
|
|
57
|
+
function getRelativePosixPath(targetPath, rootPath) {
|
|
58
|
+
return normalizeToPosixPath(targetPath).replace(normalizeToPosixPath(rootPath), "").replace(/^\//, "");
|
|
59
|
+
}
|
|
60
|
+
|
|
1
61
|
// ../../dimina/fe/packages/compiler/src/common/utils.js
|
|
2
62
|
import crypto from "node:crypto";
|
|
3
63
|
import fs from "node:fs";
|
|
4
|
-
import
|
|
64
|
+
import path2 from "node:path";
|
|
5
65
|
import process from "node:process";
|
|
6
66
|
function hasCompileInfo(modulePath, list, preList) {
|
|
7
67
|
const mergeList = Array.isArray(preList) ? [...preList, ...list] : list;
|
|
@@ -14,17 +74,34 @@ function hasCompileInfo(modulePath, list, preList) {
|
|
|
14
74
|
}
|
|
15
75
|
function getAbsolutePath(workPath, pagePath, src) {
|
|
16
76
|
if (src.startsWith("/")) {
|
|
17
|
-
return
|
|
77
|
+
return path2.join(workPath, src);
|
|
18
78
|
}
|
|
19
79
|
if (pagePath.includes("/miniprogram_npm/")) {
|
|
20
80
|
const componentDir = pagePath.split("/").slice(0, -1).join("/");
|
|
21
81
|
const componentFullPath = workPath + componentDir;
|
|
22
|
-
return
|
|
82
|
+
return path2.resolve(componentFullPath, src);
|
|
23
83
|
}
|
|
24
84
|
const relativePath = pagePath.split("/").filter((part) => part !== "").slice(0, -1).join("/");
|
|
25
|
-
return
|
|
85
|
+
return path2.resolve(workPath, relativePath, src);
|
|
26
86
|
}
|
|
27
87
|
var assetsMap = {};
|
|
88
|
+
function isPathInside(rootPath, targetPath) {
|
|
89
|
+
const relativePath = path2.relative(rootPath, targetPath);
|
|
90
|
+
return relativePath === "" || !relativePath.startsWith(`..${path2.sep}`) && relativePath !== ".." && !path2.isAbsolute(relativePath);
|
|
91
|
+
}
|
|
92
|
+
function resolveAssetSourcePath(workPath, pagePath, src) {
|
|
93
|
+
const projectRoot = path2.resolve(workPath);
|
|
94
|
+
if (src.startsWith("/")) {
|
|
95
|
+
return path2.resolve(projectRoot, `.${src}`);
|
|
96
|
+
}
|
|
97
|
+
const normalizedPagePath = path2.resolve(pagePath);
|
|
98
|
+
const pageDirectory = path2.isAbsolute(pagePath) && isPathInside(projectRoot, normalizedPagePath) ? path2.dirname(normalizedPagePath) : path2.resolve(projectRoot, path2.dirname(pagePath.replace(/^[/\\]+/, "")));
|
|
99
|
+
const resolvedPath = path2.resolve(pageDirectory, src);
|
|
100
|
+
if (isPathInside(projectRoot, resolvedPath)) {
|
|
101
|
+
return resolvedPath;
|
|
102
|
+
}
|
|
103
|
+
return path2.resolve(projectRoot, src.replace(/^(?:\.\.[/\\])+/, ""));
|
|
104
|
+
}
|
|
28
105
|
function collectAssets(workPath, pagePath, src, targetPath, appId) {
|
|
29
106
|
if (src.startsWith("http") || src.startsWith("//")) {
|
|
30
107
|
return src;
|
|
@@ -32,21 +109,20 @@ function collectAssets(workPath, pagePath, src, targetPath, appId) {
|
|
|
32
109
|
if (!/\.(?:png|jpe?g|gif|svg)(?:\?.*)?$/.test(src)) {
|
|
33
110
|
return src;
|
|
34
111
|
}
|
|
35
|
-
const
|
|
36
|
-
const absolutePath = src.startsWith("/") ? workPath + src : path.resolve(workPath, relativePath, src);
|
|
112
|
+
const absolutePath = resolveAssetSourcePath(workPath, pagePath, src);
|
|
37
113
|
if (assetsMap[absolutePath]) {
|
|
38
114
|
return assetsMap[absolutePath];
|
|
39
115
|
}
|
|
40
116
|
try {
|
|
41
117
|
const ext = `.${src.split(".").pop()}`;
|
|
42
|
-
const dirPath = absolutePath.split(
|
|
118
|
+
const dirPath = absolutePath.split(path2.sep).slice(0, -1).join("/");
|
|
43
119
|
const prefix = uuid(dirPath);
|
|
44
120
|
const targetStatic = `${targetPath}/main/static`;
|
|
45
121
|
if (!fs.existsSync(targetStatic)) {
|
|
46
122
|
fs.mkdirSync(targetStatic, { recursive: true });
|
|
47
123
|
}
|
|
48
124
|
getFilesWithExtension(dirPath, ext).forEach((file) => {
|
|
49
|
-
fs.copyFileSync(
|
|
125
|
+
fs.copyFileSync(path2.resolve(dirPath, file), `${targetStatic}/${prefix}_${file}`);
|
|
50
126
|
});
|
|
51
127
|
const filename = src.split("/").pop();
|
|
52
128
|
const pathPrefix = process.env.ASSETS_PATH_PREFIX ? "" : "/";
|
|
@@ -58,7 +134,7 @@ function collectAssets(workPath, pagePath, src, targetPath, appId) {
|
|
|
58
134
|
}
|
|
59
135
|
function getFilesWithExtension(directory, extension) {
|
|
60
136
|
const files = fs.readdirSync(directory);
|
|
61
|
-
const filteredFiles = files.filter((file) =>
|
|
137
|
+
const filteredFiles = files.filter((file) => path2.extname(file) === extension);
|
|
62
138
|
return filteredFiles;
|
|
63
139
|
}
|
|
64
140
|
function isObjectEmpty(objectName) {
|
|
@@ -75,7 +151,8 @@ function transformRpx(styleText) {
|
|
|
75
151
|
return styleText;
|
|
76
152
|
}
|
|
77
153
|
return styleText.replace(/([+-]?\d+(?:\.\d+)?)rpx/g, (_, pixel) => {
|
|
78
|
-
|
|
154
|
+
const viewportWidth = Number((Number(pixel) / 7.5).toFixed(6));
|
|
155
|
+
return `${Object.is(viewportWidth, -0) ? 0 : viewportWidth}vw`;
|
|
79
156
|
});
|
|
80
157
|
}
|
|
81
158
|
function uuid(str) {
|
|
@@ -83,7 +160,7 @@ function uuid(str) {
|
|
|
83
160
|
}
|
|
84
161
|
var tagWhiteList = [
|
|
85
162
|
"page",
|
|
86
|
-
"
|
|
163
|
+
"component-host",
|
|
87
164
|
"block",
|
|
88
165
|
"button",
|
|
89
166
|
"camera",
|
|
@@ -124,6 +201,24 @@ var tagWhiteList = [
|
|
|
124
201
|
"view",
|
|
125
202
|
"web-view"
|
|
126
203
|
];
|
|
204
|
+
var miniProgramBuiltinTags = /* @__PURE__ */ new Set([
|
|
205
|
+
...tagWhiteList,
|
|
206
|
+
"canvas",
|
|
207
|
+
"match-media",
|
|
208
|
+
"page-container",
|
|
209
|
+
"share-element",
|
|
210
|
+
"editor",
|
|
211
|
+
"audio",
|
|
212
|
+
"channel-live",
|
|
213
|
+
"channel-video",
|
|
214
|
+
"live-player",
|
|
215
|
+
"live-pusher",
|
|
216
|
+
"voip-room",
|
|
217
|
+
"ad",
|
|
218
|
+
"ad-custom",
|
|
219
|
+
"official-account",
|
|
220
|
+
"xr-frame"
|
|
221
|
+
]);
|
|
127
222
|
function __resetAssets() {
|
|
128
223
|
for (const k of Object.keys(assetsMap)) delete assetsMap[k];
|
|
129
224
|
}
|
|
@@ -133,36 +228,8 @@ import fs3 from "node:fs";
|
|
|
133
228
|
import os from "node:os";
|
|
134
229
|
import path4 from "node:path";
|
|
135
230
|
import process2 from "node:process";
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
import path2 from "node:path";
|
|
139
|
-
var WINDOWS_FS_PATH_RE = /^(?:[a-zA-Z]:[\\/]|\\\\)/;
|
|
140
|
-
function isWindowsFsPath(targetPath) {
|
|
141
|
-
return typeof targetPath === "string" && (WINDOWS_FS_PATH_RE.test(targetPath) || targetPath.includes("\\"));
|
|
142
|
-
}
|
|
143
|
-
function getFsPathApi(targetPath) {
|
|
144
|
-
return isWindowsFsPath(targetPath) ? path2.win32 : path2.posix;
|
|
145
|
-
}
|
|
146
|
-
function normalizeToPosixPath(targetPath) {
|
|
147
|
-
return targetPath.replace(/\\/g, "/");
|
|
148
|
-
}
|
|
149
|
-
function resolveMiniProgramPath(workPath, importerPath, sourcePath) {
|
|
150
|
-
const pathApi = getFsPathApi(importerPath || workPath);
|
|
151
|
-
return sourcePath.startsWith("/") ? pathApi.join(workPath, sourcePath) : pathApi.resolve(pathApi.dirname(importerPath), sourcePath);
|
|
152
|
-
}
|
|
153
|
-
function toMiniProgramModuleId(resolvedPath, workPath) {
|
|
154
|
-
const normalizedResolvedPath = normalizeToPosixPath(resolvedPath);
|
|
155
|
-
const normalizedWorkPath = normalizeToPosixPath(workPath);
|
|
156
|
-
let moduleId = normalizedResolvedPath.startsWith(normalizedWorkPath) ? normalizedResolvedPath.slice(normalizedWorkPath.length) : normalizedResolvedPath;
|
|
157
|
-
moduleId = moduleId.replace(/\/+/g, "/");
|
|
158
|
-
if (!moduleId.startsWith("/")) {
|
|
159
|
-
moduleId = `/${moduleId}`;
|
|
160
|
-
}
|
|
161
|
-
return moduleId;
|
|
162
|
-
}
|
|
163
|
-
function getRelativePosixPath(targetPath, rootPath) {
|
|
164
|
-
return normalizeToPosixPath(targetPath).replace(normalizeToPosixPath(rootPath), "").replace(/^\//, "");
|
|
165
|
-
}
|
|
231
|
+
import { parseSync } from "oxc-parser";
|
|
232
|
+
import { walk } from "oxc-walker";
|
|
166
233
|
|
|
167
234
|
// ../../dimina/fe/packages/compiler/src/common/npm-resolver.js
|
|
168
235
|
import fs2 from "node:fs";
|
|
@@ -372,6 +439,12 @@ var DEFAULT_TEMPLATE_EXTS = [".wxml", ".ddml"];
|
|
|
372
439
|
var DEFAULT_STYLE_EXTS = [".wxss", ".ddss", ".less", ".scss", ".sass"];
|
|
373
440
|
var DEFAULT_VIEW_SCRIPT_EXTS = [".wxs"];
|
|
374
441
|
var DEFAULT_VIEW_SCRIPT_TAGS = ["wxs", "dds"];
|
|
442
|
+
var CUSTOM_TAB_BAR_COMPONENT_PATH = "/custom-tab-bar/index";
|
|
443
|
+
var STYLE_ISOLATION_VALUES = /* @__PURE__ */ new Set([
|
|
444
|
+
"isolated",
|
|
445
|
+
"apply-shared",
|
|
446
|
+
"shared"
|
|
447
|
+
]);
|
|
375
448
|
var RESERVED_EXTS = /* @__PURE__ */ new Set([
|
|
376
449
|
...DEFAULT_TEMPLATE_EXTS,
|
|
377
450
|
...DEFAULT_STYLE_EXTS,
|
|
@@ -526,6 +599,50 @@ function storePageConfig() {
|
|
|
526
599
|
collectionPageJson(subPkg.pages, subPkg.root);
|
|
527
600
|
});
|
|
528
601
|
}
|
|
602
|
+
storeCustomTabBarConfig();
|
|
603
|
+
}
|
|
604
|
+
function storeCustomTabBarConfig() {
|
|
605
|
+
const tabBar = configInfo.appInfo?.tabBar;
|
|
606
|
+
if (tabBar?.custom !== true || !Array.isArray(tabBar.list)) {
|
|
607
|
+
return;
|
|
608
|
+
}
|
|
609
|
+
const componentJsonPath = path4.join(pathInfo.workPath, "custom-tab-bar/index.json");
|
|
610
|
+
if (!fs3.existsSync(componentJsonPath)) {
|
|
611
|
+
console.warn("[env] tabBar.custom \u5DF2\u542F\u7528\uFF0C\u4F46\u627E\u4E0D\u5230 custom-tab-bar/index.json");
|
|
612
|
+
return;
|
|
613
|
+
}
|
|
614
|
+
const dependencyName = `dimina-${uuid(CUSTOM_TAB_BAR_COMPONENT_PATH)}`;
|
|
615
|
+
const internalConfig = {
|
|
616
|
+
usingComponents: {
|
|
617
|
+
[dependencyName]: CUSTOM_TAB_BAR_COMPONENT_PATH
|
|
618
|
+
}
|
|
619
|
+
};
|
|
620
|
+
storeComponentConfig(internalConfig, path4.join(pathInfo.workPath, "app.json"));
|
|
621
|
+
const componentConfig = configInfo.componentInfo[CUSTOM_TAB_BAR_COMPONENT_PATH];
|
|
622
|
+
if (componentConfig) {
|
|
623
|
+
componentConfig.customTabBar = true;
|
|
624
|
+
}
|
|
625
|
+
for (const item of tabBar.list) {
|
|
626
|
+
const pagePath = typeof item?.pagePath === "string" ? item.pagePath.replace(/^\/+/, "") : "";
|
|
627
|
+
if (!pagePath || !configInfo.appInfo.pages?.includes(pagePath)) {
|
|
628
|
+
continue;
|
|
629
|
+
}
|
|
630
|
+
const pageConfig = configInfo.pageInfo[pagePath] ||= {};
|
|
631
|
+
pageConfig.usingComponents ||= {};
|
|
632
|
+
const declaredComponents = {
|
|
633
|
+
...configInfo.appInfo.usingComponents || {},
|
|
634
|
+
...pageConfig.usingComponents
|
|
635
|
+
};
|
|
636
|
+
const declaredEntry = Object.entries(declaredComponents).find(([, componentPath]) => componentPath === CUSTOM_TAB_BAR_COMPONENT_PATH);
|
|
637
|
+
let componentName = declaredEntry?.[0] || dependencyName;
|
|
638
|
+
let suffix = 0;
|
|
639
|
+
while (declaredComponents[componentName] && declaredComponents[componentName] !== CUSTOM_TAB_BAR_COMPONENT_PATH) {
|
|
640
|
+
suffix++;
|
|
641
|
+
componentName = `${dependencyName}-${suffix}`;
|
|
642
|
+
}
|
|
643
|
+
pageConfig.usingComponents[componentName] = CUSTOM_TAB_BAR_COMPONENT_PATH;
|
|
644
|
+
pageConfig.customTabBar = { componentName };
|
|
645
|
+
}
|
|
529
646
|
}
|
|
530
647
|
function collectionPageJson(pages, root) {
|
|
531
648
|
pages.forEach((pagePath) => {
|
|
@@ -581,6 +698,7 @@ function storeComponentConfig(pageJsonContent, pageFilePath) {
|
|
|
581
698
|
}
|
|
582
699
|
const cUsing = cContent.usingComponents || {};
|
|
583
700
|
const isComponent = cContent.component || false;
|
|
701
|
+
const styleIsolation = resolveComponentStyleIsolation(cContent, componentFilePath);
|
|
584
702
|
const cComponents = Object.keys(cUsing).reduce((acc, key) => {
|
|
585
703
|
acc[key] = getModuleId(cUsing[key], componentFilePath);
|
|
586
704
|
return acc;
|
|
@@ -589,6 +707,7 @@ function storeComponentConfig(pageJsonContent, pageFilePath) {
|
|
|
589
707
|
id: uuid(moduleId),
|
|
590
708
|
path: moduleId,
|
|
591
709
|
component: isComponent,
|
|
710
|
+
styleIsolation,
|
|
592
711
|
usingComponents: cComponents
|
|
593
712
|
};
|
|
594
713
|
if (cContent.usingComponents && Object.keys(cContent.usingComponents).length > 0) {
|
|
@@ -596,6 +715,65 @@ function storeComponentConfig(pageJsonContent, pageFilePath) {
|
|
|
596
715
|
}
|
|
597
716
|
}
|
|
598
717
|
}
|
|
718
|
+
function getStaticProperty(objectExpression, propertyName) {
|
|
719
|
+
if (objectExpression?.type !== "ObjectExpression") {
|
|
720
|
+
return void 0;
|
|
721
|
+
}
|
|
722
|
+
return objectExpression.properties?.find((property) => {
|
|
723
|
+
if (property.type !== "Property" || property.computed) {
|
|
724
|
+
return false;
|
|
725
|
+
}
|
|
726
|
+
return property.key?.name === propertyName || property.key?.value === propertyName;
|
|
727
|
+
})?.value;
|
|
728
|
+
}
|
|
729
|
+
function normalizeStyleIsolation(value) {
|
|
730
|
+
return STYLE_ISOLATION_VALUES.has(value) ? value : void 0;
|
|
731
|
+
}
|
|
732
|
+
function resolveComponentStyleIsolation(componentConfig, componentJsonPath) {
|
|
733
|
+
const jsonValue = normalizeStyleIsolation(componentConfig?.styleIsolation);
|
|
734
|
+
if (jsonValue) {
|
|
735
|
+
return jsonValue;
|
|
736
|
+
}
|
|
737
|
+
const basePath = componentJsonPath.replace(/\.json$/i, "");
|
|
738
|
+
const scriptPath = [".js", ".ts"].map((ext) => `${basePath}${ext}`).find((candidate) => fs3.existsSync(candidate));
|
|
739
|
+
if (!scriptPath) {
|
|
740
|
+
return "isolated";
|
|
741
|
+
}
|
|
742
|
+
try {
|
|
743
|
+
const source = getContentByPath(scriptPath);
|
|
744
|
+
const { program } = parseSync(scriptPath, source, {
|
|
745
|
+
sourceType: "unambiguous"
|
|
746
|
+
});
|
|
747
|
+
let extractedValue;
|
|
748
|
+
walk(program, {
|
|
749
|
+
enter(expression) {
|
|
750
|
+
if (extractedValue) {
|
|
751
|
+
return;
|
|
752
|
+
}
|
|
753
|
+
if (expression?.type !== "CallExpression" || expression.callee?.type !== "Identifier" || expression.callee.name !== "Component") {
|
|
754
|
+
return;
|
|
755
|
+
}
|
|
756
|
+
const definition = expression.arguments?.[0];
|
|
757
|
+
const options = getStaticProperty(definition, "options");
|
|
758
|
+
const styleIsolation = getStaticProperty(options, "styleIsolation")?.value;
|
|
759
|
+
const normalized = normalizeStyleIsolation(styleIsolation);
|
|
760
|
+
if (normalized) {
|
|
761
|
+
extractedValue = normalized;
|
|
762
|
+
return;
|
|
763
|
+
}
|
|
764
|
+
if (getStaticProperty(options, "addGlobalClass")?.value === true) {
|
|
765
|
+
extractedValue = "apply-shared";
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
});
|
|
769
|
+
if (extractedValue) {
|
|
770
|
+
return extractedValue;
|
|
771
|
+
}
|
|
772
|
+
} catch (error) {
|
|
773
|
+
console.warn(`[env] \u65E0\u6CD5\u89E3\u6790\u7EC4\u4EF6\u6837\u5F0F\u9694\u79BB\u914D\u7F6E ${scriptPath}: ${error.message}`);
|
|
774
|
+
}
|
|
775
|
+
return "isolated";
|
|
776
|
+
}
|
|
599
777
|
function getModuleId(src, pageFilePath) {
|
|
600
778
|
const resolvedAlias = resolveAppAlias(src);
|
|
601
779
|
if (resolvedAlias) {
|
|
@@ -667,7 +845,10 @@ function getPages() {
|
|
|
667
845
|
return {
|
|
668
846
|
id: uuid(path5),
|
|
669
847
|
path: path5,
|
|
670
|
-
|
|
848
|
+
appStyleScopeId: getAppStyleScopeId(),
|
|
849
|
+
sharedStyleScopeIds: collectSharedStyleScopeIds(mergedComponents),
|
|
850
|
+
usingComponents: mergedComponents,
|
|
851
|
+
customTabBar: pageInfo[path5]?.customTabBar
|
|
671
852
|
};
|
|
672
853
|
});
|
|
673
854
|
const subPages = {};
|
|
@@ -683,7 +864,10 @@ function getPages() {
|
|
|
683
864
|
return {
|
|
684
865
|
id: uuid(fullPath),
|
|
685
866
|
path: fullPath,
|
|
686
|
-
|
|
867
|
+
appStyleScopeId: getAppStyleScopeId(),
|
|
868
|
+
sharedStyleScopeIds: collectSharedStyleScopeIds(mergedComponents),
|
|
869
|
+
usingComponents: mergedComponents,
|
|
870
|
+
customTabBar: pageInfo[fullPath]?.customTabBar
|
|
687
871
|
};
|
|
688
872
|
})
|
|
689
873
|
};
|
|
@@ -693,13 +877,44 @@ function getPages() {
|
|
|
693
877
|
subPages
|
|
694
878
|
};
|
|
695
879
|
}
|
|
880
|
+
function collectSharedStyleScopeIds(usingComponents) {
|
|
881
|
+
const result = [];
|
|
882
|
+
const visited = /* @__PURE__ */ new Set();
|
|
883
|
+
const visit = (componentPath) => {
|
|
884
|
+
if (visited.has(componentPath)) {
|
|
885
|
+
return;
|
|
886
|
+
}
|
|
887
|
+
visited.add(componentPath);
|
|
888
|
+
const component = configInfo.componentInfo[componentPath];
|
|
889
|
+
if (!component) {
|
|
890
|
+
return;
|
|
891
|
+
}
|
|
892
|
+
if (component.styleIsolation === "shared") {
|
|
893
|
+
result.push(component.id);
|
|
894
|
+
}
|
|
895
|
+
for (const childPath of Object.values(component.usingComponents || {})) {
|
|
896
|
+
visit(childPath);
|
|
897
|
+
}
|
|
898
|
+
};
|
|
899
|
+
for (const componentPath of Object.values(usingComponents || {})) {
|
|
900
|
+
visit(componentPath);
|
|
901
|
+
}
|
|
902
|
+
return result;
|
|
903
|
+
}
|
|
904
|
+
function getAppStyleScopeId() {
|
|
905
|
+
return uuid("app");
|
|
906
|
+
}
|
|
696
907
|
|
|
697
908
|
export {
|
|
909
|
+
__commonJS,
|
|
910
|
+
__toESM,
|
|
911
|
+
toMiniProgramModuleId,
|
|
698
912
|
hasCompileInfo,
|
|
699
913
|
getAbsolutePath,
|
|
700
914
|
collectAssets,
|
|
701
915
|
transformRpx,
|
|
702
916
|
tagWhiteList,
|
|
917
|
+
miniProgramBuiltinTags,
|
|
703
918
|
__resetAssets,
|
|
704
919
|
storeInfo,
|
|
705
920
|
resetStoreInfo,
|