@dimina-kit/compiler 0.0.2-dev.20260718085557 → 0.0.2-dev.20260718143821
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,3 +1,33 @@
|
|
|
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
|
+
|
|
1
31
|
// src/shims/fs.js
|
|
2
32
|
var current = null;
|
|
3
33
|
function setFs(impl) {
|
|
@@ -59,9 +89,39 @@ var fs = {
|
|
|
59
89
|
};
|
|
60
90
|
var fs_default = fs;
|
|
61
91
|
|
|
92
|
+
// ../../dimina/fe/packages/compiler/src/common/path-utils.js
|
|
93
|
+
import path from "node:path";
|
|
94
|
+
var WINDOWS_FS_PATH_RE = /^(?:[a-zA-Z]:[\\/]|\\\\)/;
|
|
95
|
+
function isWindowsFsPath(targetPath) {
|
|
96
|
+
return typeof targetPath === "string" && (WINDOWS_FS_PATH_RE.test(targetPath) || targetPath.includes("\\"));
|
|
97
|
+
}
|
|
98
|
+
function getFsPathApi(targetPath) {
|
|
99
|
+
return isWindowsFsPath(targetPath) ? path.win32 : path.posix;
|
|
100
|
+
}
|
|
101
|
+
function normalizeToPosixPath(targetPath) {
|
|
102
|
+
return targetPath.replace(/\\/g, "/");
|
|
103
|
+
}
|
|
104
|
+
function resolveMiniProgramPath(workPath, importerPath, sourcePath) {
|
|
105
|
+
const pathApi = getFsPathApi(importerPath || workPath);
|
|
106
|
+
return sourcePath.startsWith("/") ? pathApi.join(workPath, sourcePath) : pathApi.resolve(pathApi.dirname(importerPath), sourcePath);
|
|
107
|
+
}
|
|
108
|
+
function toMiniProgramModuleId(resolvedPath, workPath) {
|
|
109
|
+
const normalizedResolvedPath = normalizeToPosixPath(resolvedPath);
|
|
110
|
+
const normalizedWorkPath = normalizeToPosixPath(workPath);
|
|
111
|
+
let moduleId = normalizedResolvedPath.startsWith(normalizedWorkPath) ? normalizedResolvedPath.slice(normalizedWorkPath.length) : normalizedResolvedPath;
|
|
112
|
+
moduleId = moduleId.replace(/\/+/g, "/");
|
|
113
|
+
if (!moduleId.startsWith("/")) {
|
|
114
|
+
moduleId = `/${moduleId}`;
|
|
115
|
+
}
|
|
116
|
+
return moduleId;
|
|
117
|
+
}
|
|
118
|
+
function getRelativePosixPath(targetPath, rootPath) {
|
|
119
|
+
return normalizeToPosixPath(targetPath).replace(normalizeToPosixPath(rootPath), "").replace(/^\//, "");
|
|
120
|
+
}
|
|
121
|
+
|
|
62
122
|
// ../../dimina/fe/packages/compiler/src/common/utils.js
|
|
63
123
|
import crypto from "node:crypto";
|
|
64
|
-
import
|
|
124
|
+
import path2 from "node:path";
|
|
65
125
|
import process from "node:process";
|
|
66
126
|
function hasCompileInfo(modulePath, list, preList) {
|
|
67
127
|
const mergeList = Array.isArray(preList) ? [...preList, ...list] : list;
|
|
@@ -74,17 +134,34 @@ function hasCompileInfo(modulePath, list, preList) {
|
|
|
74
134
|
}
|
|
75
135
|
function getAbsolutePath(workPath, pagePath, src) {
|
|
76
136
|
if (src.startsWith("/")) {
|
|
77
|
-
return
|
|
137
|
+
return path2.join(workPath, src);
|
|
78
138
|
}
|
|
79
139
|
if (pagePath.includes("/miniprogram_npm/")) {
|
|
80
140
|
const componentDir = pagePath.split("/").slice(0, -1).join("/");
|
|
81
141
|
const componentFullPath = workPath + componentDir;
|
|
82
|
-
return
|
|
142
|
+
return path2.resolve(componentFullPath, src);
|
|
83
143
|
}
|
|
84
144
|
const relativePath = pagePath.split("/").filter((part) => part !== "").slice(0, -1).join("/");
|
|
85
|
-
return
|
|
145
|
+
return path2.resolve(workPath, relativePath, src);
|
|
86
146
|
}
|
|
87
147
|
var assetsMap = {};
|
|
148
|
+
function isPathInside(rootPath, targetPath) {
|
|
149
|
+
const relativePath = path2.relative(rootPath, targetPath);
|
|
150
|
+
return relativePath === "" || !relativePath.startsWith(`..${path2.sep}`) && relativePath !== ".." && !path2.isAbsolute(relativePath);
|
|
151
|
+
}
|
|
152
|
+
function resolveAssetSourcePath(workPath, pagePath, src) {
|
|
153
|
+
const projectRoot = path2.resolve(workPath);
|
|
154
|
+
if (src.startsWith("/")) {
|
|
155
|
+
return path2.resolve(projectRoot, `.${src}`);
|
|
156
|
+
}
|
|
157
|
+
const normalizedPagePath = path2.resolve(pagePath);
|
|
158
|
+
const pageDirectory = path2.isAbsolute(pagePath) && isPathInside(projectRoot, normalizedPagePath) ? path2.dirname(normalizedPagePath) : path2.resolve(projectRoot, path2.dirname(pagePath.replace(/^[/\\]+/, "")));
|
|
159
|
+
const resolvedPath = path2.resolve(pageDirectory, src);
|
|
160
|
+
if (isPathInside(projectRoot, resolvedPath)) {
|
|
161
|
+
return resolvedPath;
|
|
162
|
+
}
|
|
163
|
+
return path2.resolve(projectRoot, src.replace(/^(?:\.\.[/\\])+/, ""));
|
|
164
|
+
}
|
|
88
165
|
function collectAssets(workPath, pagePath, src, targetPath, appId) {
|
|
89
166
|
if (src.startsWith("http") || src.startsWith("//")) {
|
|
90
167
|
return src;
|
|
@@ -92,21 +169,20 @@ function collectAssets(workPath, pagePath, src, targetPath, appId) {
|
|
|
92
169
|
if (!/\.(?:png|jpe?g|gif|svg)(?:\?.*)?$/.test(src)) {
|
|
93
170
|
return src;
|
|
94
171
|
}
|
|
95
|
-
const
|
|
96
|
-
const absolutePath = src.startsWith("/") ? workPath + src : path.resolve(workPath, relativePath, src);
|
|
172
|
+
const absolutePath = resolveAssetSourcePath(workPath, pagePath, src);
|
|
97
173
|
if (assetsMap[absolutePath]) {
|
|
98
174
|
return assetsMap[absolutePath];
|
|
99
175
|
}
|
|
100
176
|
try {
|
|
101
177
|
const ext = `.${src.split(".").pop()}`;
|
|
102
|
-
const dirPath = absolutePath.split(
|
|
178
|
+
const dirPath = absolutePath.split(path2.sep).slice(0, -1).join("/");
|
|
103
179
|
const prefix = uuid(dirPath);
|
|
104
180
|
const targetStatic = `${targetPath}/main/static`;
|
|
105
181
|
if (!fs_default.existsSync(targetStatic)) {
|
|
106
182
|
fs_default.mkdirSync(targetStatic, { recursive: true });
|
|
107
183
|
}
|
|
108
184
|
getFilesWithExtension(dirPath, ext).forEach((file) => {
|
|
109
|
-
fs_default.copyFileSync(
|
|
185
|
+
fs_default.copyFileSync(path2.resolve(dirPath, file), `${targetStatic}/${prefix}_${file}`);
|
|
110
186
|
});
|
|
111
187
|
const filename = src.split("/").pop();
|
|
112
188
|
const pathPrefix = process.env.ASSETS_PATH_PREFIX ? "" : "/";
|
|
@@ -118,7 +194,7 @@ function collectAssets(workPath, pagePath, src, targetPath, appId) {
|
|
|
118
194
|
}
|
|
119
195
|
function getFilesWithExtension(directory, extension) {
|
|
120
196
|
const files = fs_default.readdirSync(directory);
|
|
121
|
-
const filteredFiles = files.filter((file) =>
|
|
197
|
+
const filteredFiles = files.filter((file) => path2.extname(file) === extension);
|
|
122
198
|
return filteredFiles;
|
|
123
199
|
}
|
|
124
200
|
function isObjectEmpty(objectName) {
|
|
@@ -135,7 +211,8 @@ function transformRpx(styleText) {
|
|
|
135
211
|
return styleText;
|
|
136
212
|
}
|
|
137
213
|
return styleText.replace(/([+-]?\d+(?:\.\d+)?)rpx/g, (_, pixel) => {
|
|
138
|
-
|
|
214
|
+
const viewportWidth = Number((Number(pixel) / 7.5).toFixed(6));
|
|
215
|
+
return `${Object.is(viewportWidth, -0) ? 0 : viewportWidth}vw`;
|
|
139
216
|
});
|
|
140
217
|
}
|
|
141
218
|
function uuid(str) {
|
|
@@ -143,7 +220,7 @@ function uuid(str) {
|
|
|
143
220
|
}
|
|
144
221
|
var tagWhiteList = [
|
|
145
222
|
"page",
|
|
146
|
-
"
|
|
223
|
+
"component-host",
|
|
147
224
|
"block",
|
|
148
225
|
"button",
|
|
149
226
|
"camera",
|
|
@@ -184,6 +261,24 @@ var tagWhiteList = [
|
|
|
184
261
|
"view",
|
|
185
262
|
"web-view"
|
|
186
263
|
];
|
|
264
|
+
var miniProgramBuiltinTags = /* @__PURE__ */ new Set([
|
|
265
|
+
...tagWhiteList,
|
|
266
|
+
"canvas",
|
|
267
|
+
"match-media",
|
|
268
|
+
"page-container",
|
|
269
|
+
"share-element",
|
|
270
|
+
"editor",
|
|
271
|
+
"audio",
|
|
272
|
+
"channel-live",
|
|
273
|
+
"channel-video",
|
|
274
|
+
"live-player",
|
|
275
|
+
"live-pusher",
|
|
276
|
+
"voip-room",
|
|
277
|
+
"ad",
|
|
278
|
+
"ad-custom",
|
|
279
|
+
"official-account",
|
|
280
|
+
"xr-frame"
|
|
281
|
+
]);
|
|
187
282
|
function __resetAssets() {
|
|
188
283
|
for (const k of Object.keys(assetsMap)) delete assetsMap[k];
|
|
189
284
|
}
|
|
@@ -192,36 +287,8 @@ function __resetAssets() {
|
|
|
192
287
|
import os from "node:os";
|
|
193
288
|
import path4 from "node:path";
|
|
194
289
|
import process2 from "node:process";
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
import path2 from "node:path";
|
|
198
|
-
var WINDOWS_FS_PATH_RE = /^(?:[a-zA-Z]:[\\/]|\\\\)/;
|
|
199
|
-
function isWindowsFsPath(targetPath) {
|
|
200
|
-
return typeof targetPath === "string" && (WINDOWS_FS_PATH_RE.test(targetPath) || targetPath.includes("\\"));
|
|
201
|
-
}
|
|
202
|
-
function getFsPathApi(targetPath) {
|
|
203
|
-
return isWindowsFsPath(targetPath) ? path2.win32 : path2.posix;
|
|
204
|
-
}
|
|
205
|
-
function normalizeToPosixPath(targetPath) {
|
|
206
|
-
return targetPath.replace(/\\/g, "/");
|
|
207
|
-
}
|
|
208
|
-
function resolveMiniProgramPath(workPath, importerPath, sourcePath) {
|
|
209
|
-
const pathApi = getFsPathApi(importerPath || workPath);
|
|
210
|
-
return sourcePath.startsWith("/") ? pathApi.join(workPath, sourcePath) : pathApi.resolve(pathApi.dirname(importerPath), sourcePath);
|
|
211
|
-
}
|
|
212
|
-
function toMiniProgramModuleId(resolvedPath, workPath) {
|
|
213
|
-
const normalizedResolvedPath = normalizeToPosixPath(resolvedPath);
|
|
214
|
-
const normalizedWorkPath = normalizeToPosixPath(workPath);
|
|
215
|
-
let moduleId = normalizedResolvedPath.startsWith(normalizedWorkPath) ? normalizedResolvedPath.slice(normalizedWorkPath.length) : normalizedResolvedPath;
|
|
216
|
-
moduleId = moduleId.replace(/\/+/g, "/");
|
|
217
|
-
if (!moduleId.startsWith("/")) {
|
|
218
|
-
moduleId = `/${moduleId}`;
|
|
219
|
-
}
|
|
220
|
-
return moduleId;
|
|
221
|
-
}
|
|
222
|
-
function getRelativePosixPath(targetPath, rootPath) {
|
|
223
|
-
return normalizeToPosixPath(targetPath).replace(normalizeToPosixPath(rootPath), "").replace(/^\//, "");
|
|
224
|
-
}
|
|
290
|
+
import { parseSync } from "oxc-parser";
|
|
291
|
+
import { walk } from "oxc-walker";
|
|
225
292
|
|
|
226
293
|
// ../../dimina/fe/packages/compiler/src/common/npm-resolver.js
|
|
227
294
|
import path3 from "node:path";
|
|
@@ -430,6 +497,12 @@ var DEFAULT_TEMPLATE_EXTS = [".wxml", ".ddml"];
|
|
|
430
497
|
var DEFAULT_STYLE_EXTS = [".wxss", ".ddss", ".less", ".scss", ".sass"];
|
|
431
498
|
var DEFAULT_VIEW_SCRIPT_EXTS = [".wxs"];
|
|
432
499
|
var DEFAULT_VIEW_SCRIPT_TAGS = ["wxs", "dds"];
|
|
500
|
+
var CUSTOM_TAB_BAR_COMPONENT_PATH = "/custom-tab-bar/index";
|
|
501
|
+
var STYLE_ISOLATION_VALUES = /* @__PURE__ */ new Set([
|
|
502
|
+
"isolated",
|
|
503
|
+
"apply-shared",
|
|
504
|
+
"shared"
|
|
505
|
+
]);
|
|
433
506
|
var RESERVED_EXTS = /* @__PURE__ */ new Set([
|
|
434
507
|
...DEFAULT_TEMPLATE_EXTS,
|
|
435
508
|
...DEFAULT_STYLE_EXTS,
|
|
@@ -584,6 +657,50 @@ function storePageConfig() {
|
|
|
584
657
|
collectionPageJson(subPkg.pages, subPkg.root);
|
|
585
658
|
});
|
|
586
659
|
}
|
|
660
|
+
storeCustomTabBarConfig();
|
|
661
|
+
}
|
|
662
|
+
function storeCustomTabBarConfig() {
|
|
663
|
+
const tabBar = configInfo.appInfo?.tabBar;
|
|
664
|
+
if (tabBar?.custom !== true || !Array.isArray(tabBar.list)) {
|
|
665
|
+
return;
|
|
666
|
+
}
|
|
667
|
+
const componentJsonPath = path4.join(pathInfo.workPath, "custom-tab-bar/index.json");
|
|
668
|
+
if (!fs_default.existsSync(componentJsonPath)) {
|
|
669
|
+
console.warn("[env] tabBar.custom \u5DF2\u542F\u7528\uFF0C\u4F46\u627E\u4E0D\u5230 custom-tab-bar/index.json");
|
|
670
|
+
return;
|
|
671
|
+
}
|
|
672
|
+
const dependencyName = `dimina-${uuid(CUSTOM_TAB_BAR_COMPONENT_PATH)}`;
|
|
673
|
+
const internalConfig = {
|
|
674
|
+
usingComponents: {
|
|
675
|
+
[dependencyName]: CUSTOM_TAB_BAR_COMPONENT_PATH
|
|
676
|
+
}
|
|
677
|
+
};
|
|
678
|
+
storeComponentConfig(internalConfig, path4.join(pathInfo.workPath, "app.json"));
|
|
679
|
+
const componentConfig = configInfo.componentInfo[CUSTOM_TAB_BAR_COMPONENT_PATH];
|
|
680
|
+
if (componentConfig) {
|
|
681
|
+
componentConfig.customTabBar = true;
|
|
682
|
+
}
|
|
683
|
+
for (const item of tabBar.list) {
|
|
684
|
+
const pagePath = typeof item?.pagePath === "string" ? item.pagePath.replace(/^\/+/, "") : "";
|
|
685
|
+
if (!pagePath || !configInfo.appInfo.pages?.includes(pagePath)) {
|
|
686
|
+
continue;
|
|
687
|
+
}
|
|
688
|
+
const pageConfig = configInfo.pageInfo[pagePath] ||= {};
|
|
689
|
+
pageConfig.usingComponents ||= {};
|
|
690
|
+
const declaredComponents = {
|
|
691
|
+
...configInfo.appInfo.usingComponents || {},
|
|
692
|
+
...pageConfig.usingComponents
|
|
693
|
+
};
|
|
694
|
+
const declaredEntry = Object.entries(declaredComponents).find(([, componentPath]) => componentPath === CUSTOM_TAB_BAR_COMPONENT_PATH);
|
|
695
|
+
let componentName = declaredEntry?.[0] || dependencyName;
|
|
696
|
+
let suffix = 0;
|
|
697
|
+
while (declaredComponents[componentName] && declaredComponents[componentName] !== CUSTOM_TAB_BAR_COMPONENT_PATH) {
|
|
698
|
+
suffix++;
|
|
699
|
+
componentName = `${dependencyName}-${suffix}`;
|
|
700
|
+
}
|
|
701
|
+
pageConfig.usingComponents[componentName] = CUSTOM_TAB_BAR_COMPONENT_PATH;
|
|
702
|
+
pageConfig.customTabBar = { componentName };
|
|
703
|
+
}
|
|
587
704
|
}
|
|
588
705
|
function collectionPageJson(pages, root) {
|
|
589
706
|
pages.forEach((pagePath) => {
|
|
@@ -639,6 +756,7 @@ function storeComponentConfig(pageJsonContent, pageFilePath) {
|
|
|
639
756
|
}
|
|
640
757
|
const cUsing = cContent.usingComponents || {};
|
|
641
758
|
const isComponent = cContent.component || false;
|
|
759
|
+
const styleIsolation = resolveComponentStyleIsolation(cContent, componentFilePath);
|
|
642
760
|
const cComponents = Object.keys(cUsing).reduce((acc, key) => {
|
|
643
761
|
acc[key] = getModuleId(cUsing[key], componentFilePath);
|
|
644
762
|
return acc;
|
|
@@ -647,6 +765,7 @@ function storeComponentConfig(pageJsonContent, pageFilePath) {
|
|
|
647
765
|
id: uuid(moduleId),
|
|
648
766
|
path: moduleId,
|
|
649
767
|
component: isComponent,
|
|
768
|
+
styleIsolation,
|
|
650
769
|
usingComponents: cComponents
|
|
651
770
|
};
|
|
652
771
|
if (cContent.usingComponents && Object.keys(cContent.usingComponents).length > 0) {
|
|
@@ -654,6 +773,65 @@ function storeComponentConfig(pageJsonContent, pageFilePath) {
|
|
|
654
773
|
}
|
|
655
774
|
}
|
|
656
775
|
}
|
|
776
|
+
function getStaticProperty(objectExpression, propertyName) {
|
|
777
|
+
if (objectExpression?.type !== "ObjectExpression") {
|
|
778
|
+
return void 0;
|
|
779
|
+
}
|
|
780
|
+
return objectExpression.properties?.find((property) => {
|
|
781
|
+
if (property.type !== "Property" || property.computed) {
|
|
782
|
+
return false;
|
|
783
|
+
}
|
|
784
|
+
return property.key?.name === propertyName || property.key?.value === propertyName;
|
|
785
|
+
})?.value;
|
|
786
|
+
}
|
|
787
|
+
function normalizeStyleIsolation(value) {
|
|
788
|
+
return STYLE_ISOLATION_VALUES.has(value) ? value : void 0;
|
|
789
|
+
}
|
|
790
|
+
function resolveComponentStyleIsolation(componentConfig, componentJsonPath) {
|
|
791
|
+
const jsonValue = normalizeStyleIsolation(componentConfig?.styleIsolation);
|
|
792
|
+
if (jsonValue) {
|
|
793
|
+
return jsonValue;
|
|
794
|
+
}
|
|
795
|
+
const basePath = componentJsonPath.replace(/\.json$/i, "");
|
|
796
|
+
const scriptPath = [".js", ".ts"].map((ext) => `${basePath}${ext}`).find((candidate) => fs_default.existsSync(candidate));
|
|
797
|
+
if (!scriptPath) {
|
|
798
|
+
return "isolated";
|
|
799
|
+
}
|
|
800
|
+
try {
|
|
801
|
+
const source = getContentByPath(scriptPath);
|
|
802
|
+
const { program } = parseSync(scriptPath, source, {
|
|
803
|
+
sourceType: "unambiguous"
|
|
804
|
+
});
|
|
805
|
+
let extractedValue;
|
|
806
|
+
walk(program, {
|
|
807
|
+
enter(expression) {
|
|
808
|
+
if (extractedValue) {
|
|
809
|
+
return;
|
|
810
|
+
}
|
|
811
|
+
if (expression?.type !== "CallExpression" || expression.callee?.type !== "Identifier" || expression.callee.name !== "Component") {
|
|
812
|
+
return;
|
|
813
|
+
}
|
|
814
|
+
const definition = expression.arguments?.[0];
|
|
815
|
+
const options = getStaticProperty(definition, "options");
|
|
816
|
+
const styleIsolation = getStaticProperty(options, "styleIsolation")?.value;
|
|
817
|
+
const normalized = normalizeStyleIsolation(styleIsolation);
|
|
818
|
+
if (normalized) {
|
|
819
|
+
extractedValue = normalized;
|
|
820
|
+
return;
|
|
821
|
+
}
|
|
822
|
+
if (getStaticProperty(options, "addGlobalClass")?.value === true) {
|
|
823
|
+
extractedValue = "apply-shared";
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
});
|
|
827
|
+
if (extractedValue) {
|
|
828
|
+
return extractedValue;
|
|
829
|
+
}
|
|
830
|
+
} catch (error) {
|
|
831
|
+
console.warn(`[env] \u65E0\u6CD5\u89E3\u6790\u7EC4\u4EF6\u6837\u5F0F\u9694\u79BB\u914D\u7F6E ${scriptPath}: ${error.message}`);
|
|
832
|
+
}
|
|
833
|
+
return "isolated";
|
|
834
|
+
}
|
|
657
835
|
function getModuleId(src, pageFilePath) {
|
|
658
836
|
const resolvedAlias = resolveAppAlias(src);
|
|
659
837
|
if (resolvedAlias) {
|
|
@@ -725,7 +903,10 @@ function getPages() {
|
|
|
725
903
|
return {
|
|
726
904
|
id: uuid(path5),
|
|
727
905
|
path: path5,
|
|
728
|
-
|
|
906
|
+
appStyleScopeId: getAppStyleScopeId(),
|
|
907
|
+
sharedStyleScopeIds: collectSharedStyleScopeIds(mergedComponents),
|
|
908
|
+
usingComponents: mergedComponents,
|
|
909
|
+
customTabBar: pageInfo[path5]?.customTabBar
|
|
729
910
|
};
|
|
730
911
|
});
|
|
731
912
|
const subPages = {};
|
|
@@ -741,7 +922,10 @@ function getPages() {
|
|
|
741
922
|
return {
|
|
742
923
|
id: uuid(fullPath),
|
|
743
924
|
path: fullPath,
|
|
744
|
-
|
|
925
|
+
appStyleScopeId: getAppStyleScopeId(),
|
|
926
|
+
sharedStyleScopeIds: collectSharedStyleScopeIds(mergedComponents),
|
|
927
|
+
usingComponents: mergedComponents,
|
|
928
|
+
customTabBar: pageInfo[fullPath]?.customTabBar
|
|
745
929
|
};
|
|
746
930
|
})
|
|
747
931
|
};
|
|
@@ -751,16 +935,47 @@ function getPages() {
|
|
|
751
935
|
subPages
|
|
752
936
|
};
|
|
753
937
|
}
|
|
938
|
+
function collectSharedStyleScopeIds(usingComponents) {
|
|
939
|
+
const result = [];
|
|
940
|
+
const visited = /* @__PURE__ */ new Set();
|
|
941
|
+
const visit = (componentPath) => {
|
|
942
|
+
if (visited.has(componentPath)) {
|
|
943
|
+
return;
|
|
944
|
+
}
|
|
945
|
+
visited.add(componentPath);
|
|
946
|
+
const component = configInfo.componentInfo[componentPath];
|
|
947
|
+
if (!component) {
|
|
948
|
+
return;
|
|
949
|
+
}
|
|
950
|
+
if (component.styleIsolation === "shared") {
|
|
951
|
+
result.push(component.id);
|
|
952
|
+
}
|
|
953
|
+
for (const childPath of Object.values(component.usingComponents || {})) {
|
|
954
|
+
visit(childPath);
|
|
955
|
+
}
|
|
956
|
+
};
|
|
957
|
+
for (const componentPath of Object.values(usingComponents || {})) {
|
|
958
|
+
visit(componentPath);
|
|
959
|
+
}
|
|
960
|
+
return result;
|
|
961
|
+
}
|
|
962
|
+
function getAppStyleScopeId() {
|
|
963
|
+
return uuid("app");
|
|
964
|
+
}
|
|
754
965
|
|
|
755
966
|
export {
|
|
967
|
+
__commonJS,
|
|
968
|
+
__toESM,
|
|
756
969
|
setFs,
|
|
757
970
|
resetFs,
|
|
758
971
|
fs_default,
|
|
972
|
+
toMiniProgramModuleId,
|
|
759
973
|
hasCompileInfo,
|
|
760
974
|
getAbsolutePath,
|
|
761
975
|
collectAssets,
|
|
762
976
|
transformRpx,
|
|
763
977
|
tagWhiteList,
|
|
978
|
+
miniProgramBuiltinTags,
|
|
764
979
|
__resetAssets,
|
|
765
980
|
storeInfo,
|
|
766
981
|
resetStoreInfo,
|
package/dist/compile-core.node-chunks/{logic-compiler-4BUMLGSW.js → logic-compiler-VJWEQMXZ.js}
RENAMED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getWxMemberName,
|
|
3
|
+
takeCompatibilityWarnings,
|
|
3
4
|
warnUnsupportedWxApi
|
|
4
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-6734LXNU.js";
|
|
5
6
|
import {
|
|
6
7
|
isMainThread,
|
|
7
8
|
parentPort
|
|
@@ -19,7 +20,7 @@ import {
|
|
|
19
20
|
hasCompileInfo,
|
|
20
21
|
resetStoreInfo,
|
|
21
22
|
resolveAppAlias
|
|
22
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-QVEZ34FP.js";
|
|
23
24
|
|
|
24
25
|
// ../../dimina/fe/packages/compiler/src/core/logic-compiler.js
|
|
25
26
|
import { resolve, sep } from "node:path";
|
|
@@ -157,7 +158,10 @@ ${error.stack}`);
|
|
|
157
158
|
}
|
|
158
159
|
await writeCompileRes(mainCompileRes, null);
|
|
159
160
|
processedModules.clear();
|
|
160
|
-
parentPort.postMessage({
|
|
161
|
+
parentPort.postMessage({
|
|
162
|
+
success: true,
|
|
163
|
+
compatibilityWarnings: takeCompatibilityWarnings()
|
|
164
|
+
});
|
|
161
165
|
} catch (error) {
|
|
162
166
|
processedModules.clear();
|
|
163
167
|
parentPort.postMessage({
|
|
@@ -210,18 +214,12 @@ async function compileJS(pages, root, mainCompileRes, progress) {
|
|
|
210
214
|
}
|
|
211
215
|
return compileRes;
|
|
212
216
|
}
|
|
213
|
-
async function buildJSByPath(packageName, module, compileRes, mainCompileRes, addExtra,
|
|
217
|
+
async function buildJSByPath(packageName, module, compileRes, mainCompileRes, addExtra, activePaths = /* @__PURE__ */ new Set(), putMain = false) {
|
|
214
218
|
const currentPath = module.path;
|
|
215
|
-
if (
|
|
216
|
-
console.warn("[logic]", `\u68C0\u6D4B\u5230\u5FAA\u73AF\u4F9D\u8D56: ${[...depthChain, currentPath].join(" -> ")}`);
|
|
217
|
-
return;
|
|
218
|
-
}
|
|
219
|
-
if (depthChain.length > 20) {
|
|
220
|
-
console.warn("[logic]", `\u68C0\u6D4B\u5230\u6DF1\u5EA6\u4F9D\u8D56: ${[...depthChain, currentPath].join(" -> ")}`);
|
|
219
|
+
if (!currentPath) {
|
|
221
220
|
return;
|
|
222
221
|
}
|
|
223
|
-
|
|
224
|
-
if (!module.path) {
|
|
222
|
+
if (activePaths.has(currentPath)) {
|
|
225
223
|
return;
|
|
226
224
|
}
|
|
227
225
|
if (hasCompileInfo(module.path, compileRes, mainCompileRes)) {
|
|
@@ -258,6 +256,7 @@ async function buildJSByPath(packageName, module, compileRes, mainCompileRes, ad
|
|
|
258
256
|
const extraInfo = {
|
|
259
257
|
path: module.path
|
|
260
258
|
};
|
|
259
|
+
activePaths.add(currentPath);
|
|
261
260
|
if (module.component) {
|
|
262
261
|
extraInfo.component = true;
|
|
263
262
|
}
|
|
@@ -281,7 +280,7 @@ async function buildJSByPath(packageName, module, compileRes, mainCompileRes, ad
|
|
|
281
280
|
if (!componentModule) {
|
|
282
281
|
continue;
|
|
283
282
|
}
|
|
284
|
-
await buildJSByPath(packageName, componentModule, compileRes, mainCompileRes, true,
|
|
283
|
+
await buildJSByPath(packageName, componentModule, compileRes, mainCompileRes, true, activePaths, putMain || toMainSubPackage);
|
|
285
284
|
componentsObj[name] = path;
|
|
286
285
|
}
|
|
287
286
|
extraInfo.usingComponents = componentsObj;
|
|
@@ -392,7 +391,7 @@ async function buildJSByPath(packageName, module, compileRes, mainCompileRes, ad
|
|
|
392
391
|
}
|
|
393
392
|
});
|
|
394
393
|
for (const depId of dependenciesToProcess) {
|
|
395
|
-
await buildJSByPath(packageName, { path: depId }, compileRes, mainCompileRes, false,
|
|
394
|
+
await buildJSByPath(packageName, { path: depId }, compileRes, mainCompileRes, false, activePaths, putMain);
|
|
396
395
|
}
|
|
397
396
|
for (const replacement of pathReplacements.reverse()) {
|
|
398
397
|
s.overwrite(replacement.start, replacement.end, `'${replacement.newValue}'`);
|
|
@@ -433,6 +432,7 @@ async function buildJSByPath(packageName, module, compileRes, mainCompileRes, ad
|
|
|
433
432
|
compileInfo.code = modifiedCode;
|
|
434
433
|
}
|
|
435
434
|
processedModules.add(packageName + currentPath);
|
|
435
|
+
activePaths.delete(currentPath);
|
|
436
436
|
}
|
|
437
437
|
function isLocalAssetString(value) {
|
|
438
438
|
return typeof value === "string" && !value.startsWith("http") && !value.startsWith("//") && (value.startsWith("/") || value.startsWith("./") || value.startsWith("../")) && /\.(?:png|jpe?g|gif|svg)(?:\?.*)?$/.test(value);
|