@dimina-kit/compiler 0.0.2-dev.20260728080958 → 0.0.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/compile-core.browser.js +14463 -15788
- package/dist/compile-core.node-chunks/chunk-2VRS523Z.js +8 -0
- package/dist/compile-core.node-chunks/chunk-LUD2P6RM.js +211 -0
- package/dist/compile-core.node-chunks/{chunk-M62ZDT7T.js → chunk-QJ34C5KK.js} +66 -542
- package/dist/compile-core.node-chunks/{logic-compiler-AEZPY2MO.js → logic-compiler-2SQFOFEO.js} +113 -37
- package/dist/compile-core.node-chunks/style-compiler-ZEJ3XLTS.js +277 -0
- package/dist/compile-core.node-chunks/{view-compiler-2SMUHAPD.js → view-compiler-WQNV7H5G.js} +161 -425
- package/dist/compile-core.node.js +6 -11
- package/dist/pool.node-chunks/{chunk-CKQISGZS.js → chunk-7FGOYOXU.js} +66 -542
- package/dist/pool.node-chunks/chunk-C7GEIDCP.js +211 -0
- package/dist/pool.node-chunks/chunk-KLXXOLDF.js +8 -0
- package/dist/pool.node-chunks/{chunk-WX4462A5.js → chunk-PDHO4Y56.js} +6 -11
- package/dist/pool.node-chunks/{logic-compiler-P4T4OMTG.js → logic-compiler-BODAINZQ.js} +113 -37
- package/dist/pool.node-chunks/style-compiler-TUNDVSR5.js +277 -0
- package/dist/pool.node-chunks/{view-compiler-2D7HPYIN.js → view-compiler-HOFFL63K.js} +161 -425
- package/dist/pool.node.js +2 -2
- package/dist/stage-worker.browser.js +1644 -2969
- package/dist/stage-worker.node.js +2 -2
- package/package.json +3 -3
- package/dist/compile-core.node-chunks/chunk-23PCGQQU.js +0 -141
- package/dist/compile-core.node-chunks/chunk-QYHGF3MS.js +0 -1601
- package/dist/compile-core.node-chunks/style-compiler-4PHMBQIC.js +0 -470
- package/dist/pool.node-chunks/chunk-LGB3AH5C.js +0 -1601
- package/dist/pool.node-chunks/chunk-VHWKAXDL.js +0 -141
- package/dist/pool.node-chunks/style-compiler-W7EA2Y7R.js +0 -470
|
@@ -1,33 +1,3 @@
|
|
|
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
1
|
// src/shims/fs.js
|
|
32
2
|
var current = null;
|
|
33
3
|
function setFs(impl) {
|
|
@@ -89,39 +59,8 @@ var fs = {
|
|
|
89
59
|
};
|
|
90
60
|
var fs_default = fs;
|
|
91
61
|
|
|
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
|
-
|
|
122
62
|
// ../../dimina/fe/packages/compiler/src/common/utils.js
|
|
123
|
-
import
|
|
124
|
-
import path2 from "node:path";
|
|
63
|
+
import path from "node:path";
|
|
125
64
|
import process from "node:process";
|
|
126
65
|
function hasCompileInfo(modulePath, list, preList) {
|
|
127
66
|
const mergeList = Array.isArray(preList) ? [...preList, ...list] : list;
|
|
@@ -134,34 +73,17 @@ function hasCompileInfo(modulePath, list, preList) {
|
|
|
134
73
|
}
|
|
135
74
|
function getAbsolutePath(workPath, pagePath, src) {
|
|
136
75
|
if (src.startsWith("/")) {
|
|
137
|
-
return
|
|
76
|
+
return path.join(workPath, src);
|
|
138
77
|
}
|
|
139
78
|
if (pagePath.includes("/miniprogram_npm/")) {
|
|
140
79
|
const componentDir = pagePath.split("/").slice(0, -1).join("/");
|
|
141
80
|
const componentFullPath = workPath + componentDir;
|
|
142
|
-
return
|
|
81
|
+
return path.resolve(componentFullPath, src);
|
|
143
82
|
}
|
|
144
83
|
const relativePath = pagePath.split("/").filter((part) => part !== "").slice(0, -1).join("/");
|
|
145
|
-
return
|
|
84
|
+
return path.resolve(workPath, relativePath, src);
|
|
146
85
|
}
|
|
147
86
|
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
|
-
}
|
|
165
87
|
function collectAssets(workPath, pagePath, src, targetPath, appId) {
|
|
166
88
|
if (src.startsWith("http") || src.startsWith("//")) {
|
|
167
89
|
return src;
|
|
@@ -169,20 +91,21 @@ function collectAssets(workPath, pagePath, src, targetPath, appId) {
|
|
|
169
91
|
if (!/\.(?:png|jpe?g|gif|svg)(?:\?.*)?$/.test(src)) {
|
|
170
92
|
return src;
|
|
171
93
|
}
|
|
172
|
-
const
|
|
94
|
+
const relativePath = pagePath.split("/").slice(0, -1).join("/");
|
|
95
|
+
const absolutePath = src.startsWith("/") ? workPath + src : path.resolve(workPath, relativePath, src);
|
|
173
96
|
if (assetsMap[absolutePath]) {
|
|
174
97
|
return assetsMap[absolutePath];
|
|
175
98
|
}
|
|
176
99
|
try {
|
|
177
100
|
const ext = `.${src.split(".").pop()}`;
|
|
178
|
-
const dirPath = absolutePath.split(
|
|
179
|
-
const prefix = uuid(
|
|
101
|
+
const dirPath = absolutePath.split(path.sep).slice(0, -1).join("/");
|
|
102
|
+
const prefix = uuid();
|
|
180
103
|
const targetStatic = `${targetPath}/main/static`;
|
|
181
104
|
if (!fs_default.existsSync(targetStatic)) {
|
|
182
105
|
fs_default.mkdirSync(targetStatic, { recursive: true });
|
|
183
106
|
}
|
|
184
107
|
getFilesWithExtension(dirPath, ext).forEach((file) => {
|
|
185
|
-
fs_default.copyFileSync(
|
|
108
|
+
fs_default.copyFileSync(path.resolve(dirPath, file), `${targetStatic}/${prefix}_${file}`);
|
|
186
109
|
});
|
|
187
110
|
const filename = src.split("/").pop();
|
|
188
111
|
const pathPrefix = process.env.ASSETS_PATH_PREFIX ? "" : "/";
|
|
@@ -194,7 +117,7 @@ function collectAssets(workPath, pagePath, src, targetPath, appId) {
|
|
|
194
117
|
}
|
|
195
118
|
function getFilesWithExtension(directory, extension) {
|
|
196
119
|
const files = fs_default.readdirSync(directory);
|
|
197
|
-
const filteredFiles = files.filter((file) =>
|
|
120
|
+
const filteredFiles = files.filter((file) => path.extname(file) === extension);
|
|
198
121
|
return filteredFiles;
|
|
199
122
|
}
|
|
200
123
|
function isObjectEmpty(objectName) {
|
|
@@ -211,16 +134,15 @@ function transformRpx(styleText) {
|
|
|
211
134
|
return styleText;
|
|
212
135
|
}
|
|
213
136
|
return styleText.replace(/([+-]?\d+(?:\.\d+)?)rpx/g, (_, pixel) => {
|
|
214
|
-
|
|
215
|
-
return `${Object.is(viewportWidth, -0) ? 0 : viewportWidth}vw`;
|
|
137
|
+
return `${Number(pixel)}rem`;
|
|
216
138
|
});
|
|
217
139
|
}
|
|
218
|
-
function uuid(
|
|
219
|
-
return
|
|
140
|
+
function uuid() {
|
|
141
|
+
return Math.random().toString(36).slice(2, 7);
|
|
220
142
|
}
|
|
221
143
|
var tagWhiteList = [
|
|
222
144
|
"page",
|
|
223
|
-
"
|
|
145
|
+
"wrapper",
|
|
224
146
|
"block",
|
|
225
147
|
"button",
|
|
226
148
|
"camera",
|
|
@@ -261,34 +183,44 @@ var tagWhiteList = [
|
|
|
261
183
|
"view",
|
|
262
184
|
"web-view"
|
|
263
185
|
];
|
|
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
|
-
]);
|
|
282
186
|
function __resetAssets() {
|
|
283
187
|
for (const k of Object.keys(assetsMap)) delete assetsMap[k];
|
|
284
188
|
}
|
|
285
189
|
|
|
286
190
|
// ../../dimina/fe/packages/compiler/src/env.js
|
|
287
191
|
import os from "node:os";
|
|
288
|
-
import
|
|
192
|
+
import path4 from "node:path";
|
|
289
193
|
import process2 from "node:process";
|
|
290
|
-
|
|
291
|
-
|
|
194
|
+
|
|
195
|
+
// ../../dimina/fe/packages/compiler/src/common/path-utils.js
|
|
196
|
+
import path2 from "node:path";
|
|
197
|
+
var WINDOWS_FS_PATH_RE = /^(?:[a-zA-Z]:[\\/]|\\\\)/;
|
|
198
|
+
function isWindowsFsPath(targetPath) {
|
|
199
|
+
return typeof targetPath === "string" && (WINDOWS_FS_PATH_RE.test(targetPath) || targetPath.includes("\\"));
|
|
200
|
+
}
|
|
201
|
+
function getFsPathApi(targetPath) {
|
|
202
|
+
return isWindowsFsPath(targetPath) ? path2.win32 : path2.posix;
|
|
203
|
+
}
|
|
204
|
+
function normalizeToPosixPath(targetPath) {
|
|
205
|
+
return targetPath.replace(/\\/g, "/");
|
|
206
|
+
}
|
|
207
|
+
function resolveMiniProgramPath(workPath, importerPath, sourcePath) {
|
|
208
|
+
const pathApi = getFsPathApi(importerPath || workPath);
|
|
209
|
+
return sourcePath.startsWith("/") ? pathApi.join(workPath, sourcePath) : pathApi.resolve(pathApi.dirname(importerPath), sourcePath);
|
|
210
|
+
}
|
|
211
|
+
function toMiniProgramModuleId(resolvedPath, workPath) {
|
|
212
|
+
const normalizedResolvedPath = normalizeToPosixPath(resolvedPath);
|
|
213
|
+
const normalizedWorkPath = normalizeToPosixPath(workPath);
|
|
214
|
+
let moduleId = normalizedResolvedPath.startsWith(normalizedWorkPath) ? normalizedResolvedPath.slice(normalizedWorkPath.length) : normalizedResolvedPath;
|
|
215
|
+
moduleId = moduleId.replace(/\/+/g, "/");
|
|
216
|
+
if (!moduleId.startsWith("/")) {
|
|
217
|
+
moduleId = `/${moduleId}`;
|
|
218
|
+
}
|
|
219
|
+
return moduleId;
|
|
220
|
+
}
|
|
221
|
+
function getRelativePosixPath(targetPath, rootPath) {
|
|
222
|
+
return normalizeToPosixPath(targetPath).replace(normalizeToPosixPath(rootPath), "").replace(/^\//, "");
|
|
223
|
+
}
|
|
292
224
|
|
|
293
225
|
// ../../dimina/fe/packages/compiler/src/common/npm-resolver.js
|
|
294
226
|
import path3 from "node:path";
|
|
@@ -489,173 +421,14 @@ var NpmResolver = class {
|
|
|
489
421
|
}
|
|
490
422
|
};
|
|
491
423
|
|
|
492
|
-
// ../../dimina/fe/packages/compiler/src/common/dependency-graph.js
|
|
493
|
-
import path4 from "node:path";
|
|
494
|
-
function normalizeFilePath(filePath) {
|
|
495
|
-
return path4.resolve(filePath);
|
|
496
|
-
}
|
|
497
|
-
function normalizeKinds(kinds) {
|
|
498
|
-
if (!kinds) return null;
|
|
499
|
-
return new Set(Array.isArray(kinds) ? kinds : [kinds]);
|
|
500
|
-
}
|
|
501
|
-
var DependencyGraph = class _DependencyGraph {
|
|
502
|
-
constructor(snapshot) {
|
|
503
|
-
this.nodes = /* @__PURE__ */ new Map();
|
|
504
|
-
this.dependencies = /* @__PURE__ */ new Map();
|
|
505
|
-
this.dependents = /* @__PURE__ */ new Map();
|
|
506
|
-
this.fileOwners = /* @__PURE__ */ new Map();
|
|
507
|
-
this.fileKinds = /* @__PURE__ */ new Map();
|
|
508
|
-
if (snapshot) {
|
|
509
|
-
this.merge(snapshot);
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
addNode(id, metadata = {}) {
|
|
513
|
-
if (!id) return null;
|
|
514
|
-
const current2 = this.nodes.get(id) || {
|
|
515
|
-
id,
|
|
516
|
-
type: "module",
|
|
517
|
-
entry: false,
|
|
518
|
-
packageRoot: null,
|
|
519
|
-
files: /* @__PURE__ */ new Set()
|
|
520
|
-
};
|
|
521
|
-
if (metadata.type) current2.type = metadata.type;
|
|
522
|
-
if (metadata.entry === true) current2.entry = true;
|
|
523
|
-
if (metadata.packageRoot !== void 0) current2.packageRoot = metadata.packageRoot;
|
|
524
|
-
this.nodes.set(id, current2);
|
|
525
|
-
for (const filePath of metadata.files || []) {
|
|
526
|
-
this.addFile(id, filePath);
|
|
527
|
-
}
|
|
528
|
-
return current2;
|
|
529
|
-
}
|
|
530
|
-
addFile(id, filePath, kind = "module") {
|
|
531
|
-
if (!id || !filePath) return;
|
|
532
|
-
const node = this.addNode(id);
|
|
533
|
-
const normalizedPath = normalizeFilePath(filePath);
|
|
534
|
-
node.files.add(normalizedPath);
|
|
535
|
-
const owners = this.fileOwners.get(normalizedPath) || /* @__PURE__ */ new Set();
|
|
536
|
-
owners.add(id);
|
|
537
|
-
this.fileOwners.set(normalizedPath, owners);
|
|
538
|
-
const ownerKinds = this.fileKinds.get(normalizedPath) || /* @__PURE__ */ new Map();
|
|
539
|
-
const kinds = ownerKinds.get(id) || /* @__PURE__ */ new Set();
|
|
540
|
-
kinds.add(kind);
|
|
541
|
-
ownerKinds.set(id, kinds);
|
|
542
|
-
this.fileKinds.set(normalizedPath, ownerKinds);
|
|
543
|
-
}
|
|
544
|
-
addDependency(from, to, kind = "module") {
|
|
545
|
-
if (!from || !to) return;
|
|
546
|
-
this.addNode(from);
|
|
547
|
-
this.addNode(to);
|
|
548
|
-
const outgoing = this.dependencies.get(from) || /* @__PURE__ */ new Map();
|
|
549
|
-
const kinds = outgoing.get(to) || /* @__PURE__ */ new Set();
|
|
550
|
-
kinds.add(kind);
|
|
551
|
-
outgoing.set(to, kinds);
|
|
552
|
-
this.dependencies.set(from, outgoing);
|
|
553
|
-
const incoming = this.dependents.get(to) || /* @__PURE__ */ new Map();
|
|
554
|
-
const reverseKinds = incoming.get(from) || /* @__PURE__ */ new Set();
|
|
555
|
-
reverseKinds.add(kind);
|
|
556
|
-
incoming.set(from, reverseKinds);
|
|
557
|
-
this.dependents.set(to, incoming);
|
|
558
|
-
}
|
|
559
|
-
getDirectDependencies(id, kinds) {
|
|
560
|
-
return this.#filterEdges(this.dependencies.get(id), kinds);
|
|
561
|
-
}
|
|
562
|
-
getDirectDependents(id, kinds) {
|
|
563
|
-
return this.#filterEdges(this.dependents.get(id), kinds);
|
|
564
|
-
}
|
|
565
|
-
getAffectedEntries(filePath) {
|
|
566
|
-
const owners = this.fileOwners.get(normalizeFilePath(filePath)) || /* @__PURE__ */ new Set();
|
|
567
|
-
const pending = [...owners];
|
|
568
|
-
const visited = /* @__PURE__ */ new Set();
|
|
569
|
-
const entries = /* @__PURE__ */ new Set();
|
|
570
|
-
while (pending.length > 0) {
|
|
571
|
-
const id = pending.pop();
|
|
572
|
-
if (visited.has(id)) continue;
|
|
573
|
-
visited.add(id);
|
|
574
|
-
const node = this.nodes.get(id);
|
|
575
|
-
if (node?.entry) entries.add(id);
|
|
576
|
-
for (const dependent of this.getDirectDependents(id)) {
|
|
577
|
-
pending.push(dependent);
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
return [...entries].sort();
|
|
581
|
-
}
|
|
582
|
-
hasFile(filePath) {
|
|
583
|
-
return this.fileOwners.has(normalizeFilePath(filePath));
|
|
584
|
-
}
|
|
585
|
-
getFileKinds(filePath) {
|
|
586
|
-
const ownerKinds = this.fileKinds.get(normalizeFilePath(filePath));
|
|
587
|
-
if (!ownerKinds) return [];
|
|
588
|
-
return [...new Set(
|
|
589
|
-
[...ownerKinds.values()].flatMap((kinds) => [...kinds])
|
|
590
|
-
)].sort();
|
|
591
|
-
}
|
|
592
|
-
merge(snapshotOrGraph) {
|
|
593
|
-
const snapshot = snapshotOrGraph instanceof _DependencyGraph ? snapshotOrGraph.toJSON() : snapshotOrGraph;
|
|
594
|
-
const fileEdges = snapshot?.fileEdges || [];
|
|
595
|
-
for (const node of snapshot?.nodes || []) {
|
|
596
|
-
this.addNode(node.id, { ...node, files: [] });
|
|
597
|
-
if (fileEdges.length === 0) {
|
|
598
|
-
for (const filePath of node.files || []) {
|
|
599
|
-
this.addFile(node.id, filePath);
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
}
|
|
603
|
-
for (const fileEdge of fileEdges) {
|
|
604
|
-
for (const kind of fileEdge.kinds || ["module"]) {
|
|
605
|
-
this.addFile(fileEdge.owner, fileEdge.file, kind);
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
|
-
for (const edge of snapshot?.edges || []) {
|
|
609
|
-
for (const kind of edge.kinds || ["module"]) {
|
|
610
|
-
this.addDependency(edge.from, edge.to, kind);
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
return this;
|
|
614
|
-
}
|
|
615
|
-
toJSON() {
|
|
616
|
-
return {
|
|
617
|
-
nodes: [...this.nodes.values()].map((node) => ({
|
|
618
|
-
id: node.id,
|
|
619
|
-
type: node.type,
|
|
620
|
-
entry: node.entry,
|
|
621
|
-
packageRoot: node.packageRoot,
|
|
622
|
-
files: [...node.files].sort()
|
|
623
|
-
})).sort((a, b) => a.id.localeCompare(b.id)),
|
|
624
|
-
edges: [...this.dependencies.entries()].flatMap(([from, targets]) => [...targets.entries()].map(([to, kinds]) => ({
|
|
625
|
-
from,
|
|
626
|
-
to,
|
|
627
|
-
kinds: [...kinds].sort()
|
|
628
|
-
}))).sort((a, b) => a.from.localeCompare(b.from) || a.to.localeCompare(b.to)),
|
|
629
|
-
fileEdges: [...this.fileKinds.entries()].flatMap(([file, owners]) => [...owners.entries()].map(([owner, kinds]) => ({
|
|
630
|
-
file,
|
|
631
|
-
owner,
|
|
632
|
-
kinds: [...kinds].sort()
|
|
633
|
-
}))).sort((a, b) => a.file.localeCompare(b.file) || a.owner.localeCompare(b.owner))
|
|
634
|
-
};
|
|
635
|
-
}
|
|
636
|
-
#filterEdges(edges, kinds) {
|
|
637
|
-
if (!edges) return [];
|
|
638
|
-
const acceptedKinds = normalizeKinds(kinds);
|
|
639
|
-
return [...edges.entries()].filter(([, edgeKinds]) => !acceptedKinds || [...edgeKinds].some((kind) => acceptedKinds.has(kind))).map(([id]) => id);
|
|
640
|
-
}
|
|
641
|
-
};
|
|
642
|
-
|
|
643
424
|
// ../../dimina/fe/packages/compiler/src/env.js
|
|
644
425
|
var pathInfo = {};
|
|
645
426
|
var configInfo = {};
|
|
646
427
|
var npmResolver = null;
|
|
647
|
-
var dependencyGraph = new DependencyGraph();
|
|
648
428
|
var DEFAULT_TEMPLATE_EXTS = [".wxml", ".ddml"];
|
|
649
|
-
var DEFAULT_TEMPLATE_DIRECTIVE_PREFIXES = ["wx", "dd", "a"];
|
|
650
429
|
var DEFAULT_STYLE_EXTS = [".wxss", ".ddss", ".less", ".scss", ".sass"];
|
|
651
430
|
var DEFAULT_VIEW_SCRIPT_EXTS = [".wxs"];
|
|
652
431
|
var DEFAULT_VIEW_SCRIPT_TAGS = ["wxs", "dds"];
|
|
653
|
-
var CUSTOM_TAB_BAR_COMPONENT_PATH = "/custom-tab-bar/index";
|
|
654
|
-
var STYLE_ISOLATION_VALUES = /* @__PURE__ */ new Set([
|
|
655
|
-
"isolated",
|
|
656
|
-
"apply-shared",
|
|
657
|
-
"shared"
|
|
658
|
-
]);
|
|
659
432
|
var RESERVED_EXTS = /* @__PURE__ */ new Set([
|
|
660
433
|
...DEFAULT_TEMPLATE_EXTS,
|
|
661
434
|
...DEFAULT_STYLE_EXTS,
|
|
@@ -701,38 +474,29 @@ function mergeUnique(builtins, custom, normalizer, reserved) {
|
|
|
701
474
|
}
|
|
702
475
|
function normalizeFileTypes(fileTypes = {}) {
|
|
703
476
|
const ft = fileTypes || {};
|
|
704
|
-
const templateExts = mergeUnique(DEFAULT_TEMPLATE_EXTS, ft.template, normalizeExt, RESERVED_EXTS);
|
|
705
477
|
return {
|
|
706
|
-
templateExts,
|
|
707
|
-
templateDirectivePrefixes: [.../* @__PURE__ */ new Set([...DEFAULT_TEMPLATE_DIRECTIVE_PREFIXES, ...templateExts.map((extension) => {
|
|
708
|
-
const name = extension.slice(1);
|
|
709
|
-
return name.endsWith("ml") ? name.slice(0, -2) : name;
|
|
710
|
-
}).filter(Boolean)])],
|
|
478
|
+
templateExts: mergeUnique(DEFAULT_TEMPLATE_EXTS, ft.template, normalizeExt, RESERVED_EXTS),
|
|
711
479
|
styleExts: mergeUnique(DEFAULT_STYLE_EXTS, ft.style, normalizeExt, RESERVED_EXTS),
|
|
712
480
|
viewScriptExts: mergeUnique(DEFAULT_VIEW_SCRIPT_EXTS, ft.viewScript, normalizeExt, RESERVED_EXTS),
|
|
713
481
|
viewScriptTags: mergeUnique(DEFAULT_VIEW_SCRIPT_TAGS, ft.viewScript, normalizeTag)
|
|
714
482
|
};
|
|
715
483
|
}
|
|
716
484
|
function storeInfo(workPath, options = {}) {
|
|
717
|
-
compilerOptions = normalizeFileTypes(options.fileTypes);
|
|
718
485
|
storePathInfo(workPath);
|
|
719
486
|
storeProjectConfig();
|
|
720
487
|
storeAppConfig();
|
|
721
488
|
storePageConfig();
|
|
722
|
-
|
|
723
|
-
dependencyGraph.merge(options.dependencyGraph);
|
|
489
|
+
compilerOptions = normalizeFileTypes(options.fileTypes);
|
|
724
490
|
return {
|
|
725
491
|
pathInfo,
|
|
726
492
|
configInfo,
|
|
727
|
-
compilerOptions
|
|
728
|
-
dependencyGraph: dependencyGraph.toJSON()
|
|
493
|
+
compilerOptions
|
|
729
494
|
};
|
|
730
495
|
}
|
|
731
496
|
function resetStoreInfo(opts) {
|
|
732
497
|
pathInfo = opts.pathInfo;
|
|
733
498
|
configInfo = opts.configInfo;
|
|
734
499
|
compilerOptions = opts.compilerOptions || normalizeFileTypes();
|
|
735
|
-
dependencyGraph = new DependencyGraph(opts.dependencyGraph);
|
|
736
500
|
if (pathInfo.workPath) {
|
|
737
501
|
npmResolver = new NpmResolver(pathInfo.workPath);
|
|
738
502
|
}
|
|
@@ -740,9 +504,6 @@ function resetStoreInfo(opts) {
|
|
|
740
504
|
function getTemplateExts() {
|
|
741
505
|
return compilerOptions.templateExts;
|
|
742
506
|
}
|
|
743
|
-
function getTemplateDirectivePrefixes() {
|
|
744
|
-
return compilerOptions.templateDirectivePrefixes || normalizeFileTypes({ template: compilerOptions.templateExts }).templateDirectivePrefixes;
|
|
745
|
-
}
|
|
746
507
|
function getStyleExts() {
|
|
747
508
|
return compilerOptions.styleExts;
|
|
748
509
|
}
|
|
@@ -752,16 +513,13 @@ function getViewScriptExts() {
|
|
|
752
513
|
function getViewScriptTags() {
|
|
753
514
|
return compilerOptions.viewScriptTags;
|
|
754
515
|
}
|
|
755
|
-
function getDependencyGraph() {
|
|
756
|
-
return dependencyGraph;
|
|
757
|
-
}
|
|
758
516
|
function storePathInfo(workPath) {
|
|
759
517
|
pathInfo.workPath = workPath;
|
|
760
518
|
if (process2.env.TARGET_PATH) {
|
|
761
519
|
pathInfo.targetPath = process2.env.TARGET_PATH;
|
|
762
520
|
} else {
|
|
763
521
|
const tempDir = process2.env.GITHUB_WORKSPACE || os.tmpdir();
|
|
764
|
-
const targetDir =
|
|
522
|
+
const targetDir = path4.join(tempDir, `dimina-fe-dist-${Date.now()}`);
|
|
765
523
|
if (!fs_default.existsSync(targetDir)) {
|
|
766
524
|
fs_default.mkdirSync(targetDir, { recursive: true });
|
|
767
525
|
}
|
|
@@ -805,11 +563,11 @@ function storeAppConfig() {
|
|
|
805
563
|
}
|
|
806
564
|
configInfo.appInfo = newObj;
|
|
807
565
|
}
|
|
808
|
-
function getContentByPath(
|
|
809
|
-
return fs_default.readFileSync(
|
|
566
|
+
function getContentByPath(path5) {
|
|
567
|
+
return fs_default.readFileSync(path5, { encoding: "utf-8" });
|
|
810
568
|
}
|
|
811
|
-
function parseContentByPath(
|
|
812
|
-
return JSON.parse(getContentByPath(
|
|
569
|
+
function parseContentByPath(path5) {
|
|
570
|
+
return JSON.parse(getContentByPath(path5));
|
|
813
571
|
}
|
|
814
572
|
function storePageConfig() {
|
|
815
573
|
const { pages, subPackages } = configInfo.appInfo;
|
|
@@ -825,50 +583,6 @@ function storePageConfig() {
|
|
|
825
583
|
collectionPageJson(subPkg.pages, subPkg.root);
|
|
826
584
|
});
|
|
827
585
|
}
|
|
828
|
-
storeCustomTabBarConfig();
|
|
829
|
-
}
|
|
830
|
-
function storeCustomTabBarConfig() {
|
|
831
|
-
const tabBar = configInfo.appInfo?.tabBar;
|
|
832
|
-
if (tabBar?.custom !== true || !Array.isArray(tabBar.list)) {
|
|
833
|
-
return;
|
|
834
|
-
}
|
|
835
|
-
const componentJsonPath = path5.join(pathInfo.workPath, "custom-tab-bar/index.json");
|
|
836
|
-
if (!fs_default.existsSync(componentJsonPath)) {
|
|
837
|
-
console.warn("[env] tabBar.custom \u5DF2\u542F\u7528\uFF0C\u4F46\u627E\u4E0D\u5230 custom-tab-bar/index.json");
|
|
838
|
-
return;
|
|
839
|
-
}
|
|
840
|
-
const dependencyName = `dimina-${uuid(CUSTOM_TAB_BAR_COMPONENT_PATH)}`;
|
|
841
|
-
const internalConfig = {
|
|
842
|
-
usingComponents: {
|
|
843
|
-
[dependencyName]: CUSTOM_TAB_BAR_COMPONENT_PATH
|
|
844
|
-
}
|
|
845
|
-
};
|
|
846
|
-
storeComponentConfig(internalConfig, path5.join(pathInfo.workPath, "app.json"));
|
|
847
|
-
const componentConfig = configInfo.componentInfo[CUSTOM_TAB_BAR_COMPONENT_PATH];
|
|
848
|
-
if (componentConfig) {
|
|
849
|
-
componentConfig.customTabBar = true;
|
|
850
|
-
}
|
|
851
|
-
for (const item of tabBar.list) {
|
|
852
|
-
const pagePath = typeof item?.pagePath === "string" ? item.pagePath.replace(/^\/+/, "") : "";
|
|
853
|
-
if (!pagePath || !configInfo.appInfo.pages?.includes(pagePath)) {
|
|
854
|
-
continue;
|
|
855
|
-
}
|
|
856
|
-
const pageConfig = configInfo.pageInfo[pagePath] ||= {};
|
|
857
|
-
pageConfig.usingComponents ||= {};
|
|
858
|
-
const declaredComponents = {
|
|
859
|
-
...configInfo.appInfo.usingComponents || {},
|
|
860
|
-
...pageConfig.usingComponents
|
|
861
|
-
};
|
|
862
|
-
const declaredEntry = Object.entries(declaredComponents).find(([, componentPath]) => componentPath === CUSTOM_TAB_BAR_COMPONENT_PATH);
|
|
863
|
-
let componentName = declaredEntry?.[0] || dependencyName;
|
|
864
|
-
let suffix = 0;
|
|
865
|
-
while (declaredComponents[componentName] && declaredComponents[componentName] !== CUSTOM_TAB_BAR_COMPONENT_PATH) {
|
|
866
|
-
suffix++;
|
|
867
|
-
componentName = `${dependencyName}-${suffix}`;
|
|
868
|
-
}
|
|
869
|
-
pageConfig.usingComponents[componentName] = CUSTOM_TAB_BAR_COMPONENT_PATH;
|
|
870
|
-
pageConfig.customTabBar = { componentName };
|
|
871
|
-
}
|
|
872
586
|
}
|
|
873
587
|
function collectionPageJson(pages, root) {
|
|
874
588
|
pages.forEach((pagePath) => {
|
|
@@ -900,12 +614,12 @@ function storeComponentConfig(pageJsonContent, pageFilePath) {
|
|
|
900
614
|
if (configInfo.componentInfo[moduleId]) {
|
|
901
615
|
continue;
|
|
902
616
|
}
|
|
903
|
-
let componentFilePath =
|
|
617
|
+
let componentFilePath = path4.resolve(getWorkPath(), `./${moduleId}.json`);
|
|
904
618
|
let cContent = null;
|
|
905
619
|
if (fs_default.existsSync(componentFilePath)) {
|
|
906
620
|
cContent = parseContentByPath(componentFilePath);
|
|
907
621
|
} else {
|
|
908
|
-
const indexJsonPath =
|
|
622
|
+
const indexJsonPath = path4.resolve(getWorkPath(), `./${moduleId}/index.json`);
|
|
909
623
|
if (fs_default.existsSync(indexJsonPath)) {
|
|
910
624
|
componentFilePath = indexJsonPath;
|
|
911
625
|
cContent = parseContentByPath(componentFilePath);
|
|
@@ -924,83 +638,21 @@ function storeComponentConfig(pageJsonContent, pageFilePath) {
|
|
|
924
638
|
}
|
|
925
639
|
const cUsing = cContent.usingComponents || {};
|
|
926
640
|
const isComponent = cContent.component || false;
|
|
927
|
-
const styleIsolation = resolveComponentStyleIsolation(cContent, componentFilePath);
|
|
928
641
|
const cComponents = Object.keys(cUsing).reduce((acc, key) => {
|
|
929
642
|
acc[key] = getModuleId(cUsing[key], componentFilePath);
|
|
930
643
|
return acc;
|
|
931
644
|
}, {});
|
|
932
645
|
configInfo.componentInfo[moduleId] = {
|
|
933
|
-
id: uuid(
|
|
646
|
+
id: uuid(),
|
|
934
647
|
path: moduleId,
|
|
935
648
|
component: isComponent,
|
|
936
|
-
|
|
937
|
-
usingComponents: cComponents,
|
|
938
|
-
componentPlaceholder: { ...cContent.componentPlaceholder || {} }
|
|
649
|
+
usingComponents: cComponents
|
|
939
650
|
};
|
|
940
651
|
if (cContent.usingComponents && Object.keys(cContent.usingComponents).length > 0) {
|
|
941
652
|
storeComponentConfig(configInfo.componentInfo[moduleId], componentFilePath);
|
|
942
653
|
}
|
|
943
654
|
}
|
|
944
655
|
}
|
|
945
|
-
function getStaticProperty(objectExpression, propertyName) {
|
|
946
|
-
if (objectExpression?.type !== "ObjectExpression") {
|
|
947
|
-
return void 0;
|
|
948
|
-
}
|
|
949
|
-
return objectExpression.properties?.find((property) => {
|
|
950
|
-
if (property.type !== "Property" || property.computed) {
|
|
951
|
-
return false;
|
|
952
|
-
}
|
|
953
|
-
return property.key?.name === propertyName || property.key?.value === propertyName;
|
|
954
|
-
})?.value;
|
|
955
|
-
}
|
|
956
|
-
function normalizeStyleIsolation(value) {
|
|
957
|
-
return STYLE_ISOLATION_VALUES.has(value) ? value : void 0;
|
|
958
|
-
}
|
|
959
|
-
function resolveComponentStyleIsolation(componentConfig, componentJsonPath) {
|
|
960
|
-
const jsonValue = normalizeStyleIsolation(componentConfig?.styleIsolation);
|
|
961
|
-
if (jsonValue) {
|
|
962
|
-
return jsonValue;
|
|
963
|
-
}
|
|
964
|
-
const basePath = componentJsonPath.replace(/\.json$/i, "");
|
|
965
|
-
const scriptPath = [".js", ".ts"].map((ext) => `${basePath}${ext}`).find((candidate) => fs_default.existsSync(candidate));
|
|
966
|
-
if (!scriptPath) {
|
|
967
|
-
return "isolated";
|
|
968
|
-
}
|
|
969
|
-
try {
|
|
970
|
-
const source = getContentByPath(scriptPath);
|
|
971
|
-
const { program } = parseSync(scriptPath, source, {
|
|
972
|
-
sourceType: "unambiguous"
|
|
973
|
-
});
|
|
974
|
-
let extractedValue;
|
|
975
|
-
walk(program, {
|
|
976
|
-
enter(expression) {
|
|
977
|
-
if (extractedValue) {
|
|
978
|
-
return;
|
|
979
|
-
}
|
|
980
|
-
if (expression?.type !== "CallExpression" || expression.callee?.type !== "Identifier" || expression.callee.name !== "Component") {
|
|
981
|
-
return;
|
|
982
|
-
}
|
|
983
|
-
const definition = expression.arguments?.[0];
|
|
984
|
-
const options = getStaticProperty(definition, "options");
|
|
985
|
-
const styleIsolation = getStaticProperty(options, "styleIsolation")?.value;
|
|
986
|
-
const normalized = normalizeStyleIsolation(styleIsolation);
|
|
987
|
-
if (normalized) {
|
|
988
|
-
extractedValue = normalized;
|
|
989
|
-
return;
|
|
990
|
-
}
|
|
991
|
-
if (getStaticProperty(options, "addGlobalClass")?.value === true) {
|
|
992
|
-
extractedValue = "apply-shared";
|
|
993
|
-
}
|
|
994
|
-
}
|
|
995
|
-
});
|
|
996
|
-
if (extractedValue) {
|
|
997
|
-
return extractedValue;
|
|
998
|
-
}
|
|
999
|
-
} catch (error) {
|
|
1000
|
-
console.warn(`[env] \u65E0\u6CD5\u89E3\u6790\u7EC4\u4EF6\u6837\u5F0F\u9694\u79BB\u914D\u7F6E ${scriptPath}: ${error.message}`);
|
|
1001
|
-
}
|
|
1002
|
-
return "isolated";
|
|
1003
|
-
}
|
|
1004
656
|
function getModuleId(src, pageFilePath) {
|
|
1005
657
|
const resolvedAlias = resolveAppAlias(src);
|
|
1006
658
|
if (resolvedAlias) {
|
|
@@ -1066,17 +718,13 @@ function transSubDir(name) {
|
|
|
1066
718
|
function getPages() {
|
|
1067
719
|
const { pages, subPackages = [], usingComponents: globalComponents = {} } = getAppConfigInfo();
|
|
1068
720
|
const pageInfo = getPageConfigInfo();
|
|
1069
|
-
const mainPages = pages.map((
|
|
1070
|
-
const pageComponents = pageInfo[
|
|
721
|
+
const mainPages = pages.map((path5) => {
|
|
722
|
+
const pageComponents = pageInfo[path5]?.usingComponents || {};
|
|
1071
723
|
const mergedComponents = { ...globalComponents, ...pageComponents };
|
|
1072
724
|
return {
|
|
1073
|
-
id: uuid(
|
|
1074
|
-
path:
|
|
1075
|
-
|
|
1076
|
-
sharedStyleScopeIds: collectSharedStyleScopeIds(mergedComponents),
|
|
1077
|
-
usingComponents: mergedComponents,
|
|
1078
|
-
componentPlaceholder: { ...pageInfo[path6]?.componentPlaceholder || {} },
|
|
1079
|
-
customTabBar: pageInfo[path6]?.customTabBar
|
|
725
|
+
id: uuid(),
|
|
726
|
+
path: path5,
|
|
727
|
+
usingComponents: mergedComponents
|
|
1080
728
|
};
|
|
1081
729
|
});
|
|
1082
730
|
const subPages = {};
|
|
@@ -1085,18 +733,14 @@ function getPages() {
|
|
|
1085
733
|
const independent = subPkg.independent ? subPkg.independent : false;
|
|
1086
734
|
subPages[transSubDir(rootPath)] = {
|
|
1087
735
|
independent,
|
|
1088
|
-
info: subPkg.pages.map((
|
|
1089
|
-
const fullPath = rootPath +
|
|
736
|
+
info: subPkg.pages.map((path5) => {
|
|
737
|
+
const fullPath = rootPath + path5;
|
|
1090
738
|
const pageComponents = pageInfo[fullPath]?.usingComponents || {};
|
|
1091
739
|
const mergedComponents = { ...globalComponents, ...pageComponents };
|
|
1092
740
|
return {
|
|
1093
|
-
id: uuid(
|
|
741
|
+
id: uuid(),
|
|
1094
742
|
path: fullPath,
|
|
1095
|
-
|
|
1096
|
-
sharedStyleScopeIds: collectSharedStyleScopeIds(mergedComponents),
|
|
1097
|
-
usingComponents: mergedComponents,
|
|
1098
|
-
componentPlaceholder: { ...pageInfo[fullPath]?.componentPlaceholder || {} },
|
|
1099
|
-
customTabBar: pageInfo[fullPath]?.customTabBar
|
|
743
|
+
usingComponents: mergedComponents
|
|
1100
744
|
};
|
|
1101
745
|
})
|
|
1102
746
|
};
|
|
@@ -1106,143 +750,23 @@ function getPages() {
|
|
|
1106
750
|
subPages
|
|
1107
751
|
};
|
|
1108
752
|
}
|
|
1109
|
-
function addExistingModuleFiles(graph, moduleId) {
|
|
1110
|
-
const relativeId = moduleId.replace(/^\/+/, "");
|
|
1111
|
-
const basePath = path5.resolve(getWorkPath(), relativeId);
|
|
1112
|
-
const baseCandidates = [basePath, path5.join(basePath, "index")];
|
|
1113
|
-
const extensions = [
|
|
1114
|
-
".json",
|
|
1115
|
-
".js",
|
|
1116
|
-
".ts",
|
|
1117
|
-
...getTemplateExts(),
|
|
1118
|
-
...getStyleExts(),
|
|
1119
|
-
...getViewScriptExts()
|
|
1120
|
-
];
|
|
1121
|
-
for (const candidateBase of baseCandidates) {
|
|
1122
|
-
for (const extension of extensions) {
|
|
1123
|
-
const filePath = `${candidateBase}${extension}`;
|
|
1124
|
-
if (fs_default.existsSync(filePath)) {
|
|
1125
|
-
graph.addFile(moduleId, filePath, getFileDependencyKind(filePath));
|
|
1126
|
-
}
|
|
1127
|
-
}
|
|
1128
|
-
}
|
|
1129
|
-
}
|
|
1130
|
-
function getFileDependencyKind(filePath) {
|
|
1131
|
-
const extension = path5.extname(filePath).toLowerCase();
|
|
1132
|
-
if (extension === ".json") return "config";
|
|
1133
|
-
if (extension === ".js" || extension === ".ts") return "logic";
|
|
1134
|
-
if (getTemplateExts().includes(extension) || getViewScriptExts().includes(extension)) return "view";
|
|
1135
|
-
if (getStyleExts().includes(extension)) return "style";
|
|
1136
|
-
return "module";
|
|
1137
|
-
}
|
|
1138
|
-
function createInitialDependencyGraph() {
|
|
1139
|
-
const graph = new DependencyGraph();
|
|
1140
|
-
graph.addNode("app", { type: "app" });
|
|
1141
|
-
for (const fileName of [
|
|
1142
|
-
"app.json",
|
|
1143
|
-
"app.js",
|
|
1144
|
-
"app.ts",
|
|
1145
|
-
"project.config.json",
|
|
1146
|
-
"project.private.config.json"
|
|
1147
|
-
]) {
|
|
1148
|
-
const filePath = path5.resolve(getWorkPath(), fileName);
|
|
1149
|
-
if (fs_default.existsSync(filePath)) {
|
|
1150
|
-
graph.addFile("app", filePath, getFileDependencyKind(filePath));
|
|
1151
|
-
}
|
|
1152
|
-
}
|
|
1153
|
-
addExistingModuleFiles(graph, "app");
|
|
1154
|
-
for (const item of getAppConfigInfo().tabBar?.list || []) {
|
|
1155
|
-
for (const field of ["iconPath", "selectedIconPath"]) {
|
|
1156
|
-
if (!item[field]) continue;
|
|
1157
|
-
const assetPath = resolveAssetSourcePath(getWorkPath(), "", item[field]);
|
|
1158
|
-
if (fs_default.existsSync(assetPath)) {
|
|
1159
|
-
graph.addFile("app", assetPath, "config");
|
|
1160
|
-
}
|
|
1161
|
-
}
|
|
1162
|
-
}
|
|
1163
|
-
for (const component of Object.values(configInfo.componentInfo || {})) {
|
|
1164
|
-
graph.addNode(component.path, { type: "component" });
|
|
1165
|
-
addExistingModuleFiles(graph, component.path);
|
|
1166
|
-
}
|
|
1167
|
-
for (const component of Object.values(configInfo.componentInfo || {})) {
|
|
1168
|
-
for (const dependencyPath of Object.values(component.usingComponents || {})) {
|
|
1169
|
-
graph.addDependency(component.path, dependencyPath, "component");
|
|
1170
|
-
}
|
|
1171
|
-
}
|
|
1172
|
-
const pages = getPages();
|
|
1173
|
-
const addEntry = (page, packageRoot) => {
|
|
1174
|
-
graph.addNode(page.path, {
|
|
1175
|
-
type: "page",
|
|
1176
|
-
entry: true,
|
|
1177
|
-
packageRoot
|
|
1178
|
-
});
|
|
1179
|
-
addExistingModuleFiles(graph, page.path);
|
|
1180
|
-
graph.addDependency(page.path, "app", "app");
|
|
1181
|
-
for (const dependencyPath of Object.values(page.usingComponents || {})) {
|
|
1182
|
-
graph.addDependency(page.path, dependencyPath, "component");
|
|
1183
|
-
}
|
|
1184
|
-
};
|
|
1185
|
-
for (const page of pages.mainPages) {
|
|
1186
|
-
addEntry(page, null);
|
|
1187
|
-
}
|
|
1188
|
-
for (const [packageRoot, subPackage] of Object.entries(pages.subPages)) {
|
|
1189
|
-
for (const page of subPackage.info) {
|
|
1190
|
-
addEntry(page, packageRoot);
|
|
1191
|
-
}
|
|
1192
|
-
}
|
|
1193
|
-
return graph;
|
|
1194
|
-
}
|
|
1195
|
-
function collectSharedStyleScopeIds(usingComponents) {
|
|
1196
|
-
const result = [];
|
|
1197
|
-
const visited = /* @__PURE__ */ new Set();
|
|
1198
|
-
const visit = (componentPath) => {
|
|
1199
|
-
if (visited.has(componentPath)) {
|
|
1200
|
-
return;
|
|
1201
|
-
}
|
|
1202
|
-
visited.add(componentPath);
|
|
1203
|
-
const component = configInfo.componentInfo[componentPath];
|
|
1204
|
-
if (!component) {
|
|
1205
|
-
return;
|
|
1206
|
-
}
|
|
1207
|
-
if (component.styleIsolation === "shared") {
|
|
1208
|
-
result.push(component.id);
|
|
1209
|
-
}
|
|
1210
|
-
for (const childPath of Object.values(component.usingComponents || {})) {
|
|
1211
|
-
visit(childPath);
|
|
1212
|
-
}
|
|
1213
|
-
};
|
|
1214
|
-
for (const componentPath of Object.values(usingComponents || {})) {
|
|
1215
|
-
visit(componentPath);
|
|
1216
|
-
}
|
|
1217
|
-
return result;
|
|
1218
|
-
}
|
|
1219
|
-
function getAppStyleScopeId() {
|
|
1220
|
-
return uuid("app");
|
|
1221
|
-
}
|
|
1222
753
|
|
|
1223
754
|
export {
|
|
1224
|
-
__commonJS,
|
|
1225
|
-
__toESM,
|
|
1226
755
|
setFs,
|
|
1227
756
|
resetFs,
|
|
1228
757
|
fs_default,
|
|
1229
|
-
toMiniProgramModuleId,
|
|
1230
758
|
hasCompileInfo,
|
|
1231
759
|
getAbsolutePath,
|
|
1232
|
-
resolveAssetSourcePath,
|
|
1233
760
|
collectAssets,
|
|
1234
761
|
transformRpx,
|
|
1235
762
|
tagWhiteList,
|
|
1236
|
-
miniProgramBuiltinTags,
|
|
1237
763
|
__resetAssets,
|
|
1238
764
|
storeInfo,
|
|
1239
765
|
resetStoreInfo,
|
|
1240
766
|
getTemplateExts,
|
|
1241
|
-
getTemplateDirectivePrefixes,
|
|
1242
767
|
getStyleExts,
|
|
1243
768
|
getViewScriptExts,
|
|
1244
769
|
getViewScriptTags,
|
|
1245
|
-
getDependencyGraph,
|
|
1246
770
|
getContentByPath,
|
|
1247
771
|
resolveAppAlias,
|
|
1248
772
|
getTargetPath,
|