@dimina-kit/compiler 0.0.1 → 0.0.2-dev.20260711062001
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/README.md +8 -3
- package/dist/compile-core.browser.js +1331 -1252
- package/dist/{pool.node-chunks/chunk-FVCSERCO.js → compile-core.node-chunks/chunk-LUD2P6RM.js} +5 -1
- package/dist/compile-core.node-chunks/{chunk-5ND5V2SC.js → chunk-QJ34C5KK.js} +77 -2
- package/dist/compile-core.node-chunks/{logic-compiler-RX63Y2FZ.js → logic-compiler-2SQFOFEO.js} +2 -2
- package/dist/compile-core.node-chunks/{style-compiler-JUY5MZSO.js → style-compiler-ZEJ3XLTS.js} +3 -3
- package/dist/compile-core.node-chunks/{view-compiler-KA2OZG44.js → view-compiler-WQNV7H5G.js} +25 -23
- package/dist/compile-core.node.js +10 -7
- package/dist/pool.browser.js +6 -5
- package/dist/pool.node-chunks/{chunk-UYQ7D5I5.js → chunk-7FGOYOXU.js} +77 -2
- package/dist/{compile-core.node-chunks/chunk-CCZB2BJG.js → pool.node-chunks/chunk-C7GEIDCP.js} +5 -1
- package/dist/pool.node-chunks/{chunk-MHOA4NGC.js → chunk-PDHO4Y56.js} +8 -5
- package/dist/pool.node-chunks/{logic-compiler-3VVLN3YN.js → logic-compiler-BODAINZQ.js} +2 -2
- package/dist/pool.node-chunks/{style-compiler-QOUWS72U.js → style-compiler-TUNDVSR5.js} +3 -3
- package/dist/pool.node-chunks/{view-compiler-KAYOMOXO.js → view-compiler-HOFFL63K.js} +25 -23
- package/dist/pool.node.js +34 -11
- package/dist/stage-worker.browser.js +1337 -1258
- package/dist/stage-worker.node.js +2 -2
- package/package.json +4 -2
- package/scripts/test-pool-filetypes.js +159 -0
- package/scripts/test-pool-node.js +93 -3
- package/scripts/test-pool-toolchain-death.js +135 -0
- package/scripts/toolchain-setup-node-native.js +13 -0
- package/src/compile-core.js +8 -5
- package/src/pool-node.js +84 -17
- package/src/pool.js +23 -10
- package/src/stage-worker.js +12 -8
package/dist/{pool.node-chunks/chunk-FVCSERCO.js → compile-core.node-chunks/chunk-LUD2P6RM.js}
RENAMED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getViewScriptTags
|
|
3
|
+
} from "./chunk-QJ34C5KK.js";
|
|
4
|
+
|
|
1
5
|
// ../../dimina/fe/packages/compiler/src/common/compatibility.js
|
|
2
6
|
import { Parser } from "htmlparser2";
|
|
3
7
|
|
|
@@ -142,7 +146,7 @@ function warnUnsupportedWxApi(apiName, filePath, line) {
|
|
|
142
146
|
}
|
|
143
147
|
function warnUnsupportedComponent(tagName, filePath, line) {
|
|
144
148
|
const { supportedBuiltinComponents: supportedBuiltinComponents2 } = loadReference();
|
|
145
|
-
if (!tagName || supportedBuiltinComponents2.has(tagName)) {
|
|
149
|
+
if (!tagName || supportedBuiltinComponents2.has(tagName) || getViewScriptTags().includes(tagName)) {
|
|
146
150
|
return;
|
|
147
151
|
}
|
|
148
152
|
const location = formatLocation(filePath, line);
|
|
@@ -425,23 +425,94 @@ var NpmResolver = class {
|
|
|
425
425
|
var pathInfo = {};
|
|
426
426
|
var configInfo = {};
|
|
427
427
|
var npmResolver = null;
|
|
428
|
-
|
|
428
|
+
var DEFAULT_TEMPLATE_EXTS = [".wxml", ".ddml"];
|
|
429
|
+
var DEFAULT_STYLE_EXTS = [".wxss", ".ddss", ".less", ".scss", ".sass"];
|
|
430
|
+
var DEFAULT_VIEW_SCRIPT_EXTS = [".wxs"];
|
|
431
|
+
var DEFAULT_VIEW_SCRIPT_TAGS = ["wxs", "dds"];
|
|
432
|
+
var RESERVED_EXTS = /* @__PURE__ */ new Set([
|
|
433
|
+
...DEFAULT_TEMPLATE_EXTS,
|
|
434
|
+
...DEFAULT_STYLE_EXTS,
|
|
435
|
+
...DEFAULT_VIEW_SCRIPT_EXTS,
|
|
436
|
+
".js",
|
|
437
|
+
".ts",
|
|
438
|
+
".json"
|
|
439
|
+
]);
|
|
440
|
+
var compilerOptions = normalizeFileTypes();
|
|
441
|
+
function normalizeExt(raw) {
|
|
442
|
+
if (typeof raw !== "string") {
|
|
443
|
+
return null;
|
|
444
|
+
}
|
|
445
|
+
const v = raw.trim().toLowerCase().replace(/^\.+/, "");
|
|
446
|
+
if (!/^[a-z0-9_-]+$/.test(v)) {
|
|
447
|
+
return null;
|
|
448
|
+
}
|
|
449
|
+
return `.${v}`;
|
|
450
|
+
}
|
|
451
|
+
function normalizeTag(raw) {
|
|
452
|
+
if (typeof raw !== "string") {
|
|
453
|
+
return null;
|
|
454
|
+
}
|
|
455
|
+
const v = raw.trim().toLowerCase().replace(/^\.+/, "");
|
|
456
|
+
if (!/^[a-z][a-z0-9_-]*$/.test(v)) {
|
|
457
|
+
return null;
|
|
458
|
+
}
|
|
459
|
+
return v;
|
|
460
|
+
}
|
|
461
|
+
function mergeUnique(builtins, custom, normalizer, reserved) {
|
|
462
|
+
const out = [...builtins];
|
|
463
|
+
const seen = new Set(builtins);
|
|
464
|
+
if (Array.isArray(custom)) {
|
|
465
|
+
for (const raw of custom) {
|
|
466
|
+
const n = normalizer(raw);
|
|
467
|
+
if (n && !seen.has(n) && !reserved?.has(n)) {
|
|
468
|
+
seen.add(n);
|
|
469
|
+
out.push(n);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
return out;
|
|
474
|
+
}
|
|
475
|
+
function normalizeFileTypes(fileTypes = {}) {
|
|
476
|
+
const ft = fileTypes || {};
|
|
477
|
+
return {
|
|
478
|
+
templateExts: mergeUnique(DEFAULT_TEMPLATE_EXTS, ft.template, normalizeExt, RESERVED_EXTS),
|
|
479
|
+
styleExts: mergeUnique(DEFAULT_STYLE_EXTS, ft.style, normalizeExt, RESERVED_EXTS),
|
|
480
|
+
viewScriptExts: mergeUnique(DEFAULT_VIEW_SCRIPT_EXTS, ft.viewScript, normalizeExt, RESERVED_EXTS),
|
|
481
|
+
viewScriptTags: mergeUnique(DEFAULT_VIEW_SCRIPT_TAGS, ft.viewScript, normalizeTag)
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
function storeInfo(workPath, options = {}) {
|
|
429
485
|
storePathInfo(workPath);
|
|
430
486
|
storeProjectConfig();
|
|
431
487
|
storeAppConfig();
|
|
432
488
|
storePageConfig();
|
|
489
|
+
compilerOptions = normalizeFileTypes(options.fileTypes);
|
|
433
490
|
return {
|
|
434
491
|
pathInfo,
|
|
435
|
-
configInfo
|
|
492
|
+
configInfo,
|
|
493
|
+
compilerOptions
|
|
436
494
|
};
|
|
437
495
|
}
|
|
438
496
|
function resetStoreInfo(opts) {
|
|
439
497
|
pathInfo = opts.pathInfo;
|
|
440
498
|
configInfo = opts.configInfo;
|
|
499
|
+
compilerOptions = opts.compilerOptions || normalizeFileTypes();
|
|
441
500
|
if (pathInfo.workPath) {
|
|
442
501
|
npmResolver = new NpmResolver(pathInfo.workPath);
|
|
443
502
|
}
|
|
444
503
|
}
|
|
504
|
+
function getTemplateExts() {
|
|
505
|
+
return compilerOptions.templateExts;
|
|
506
|
+
}
|
|
507
|
+
function getStyleExts() {
|
|
508
|
+
return compilerOptions.styleExts;
|
|
509
|
+
}
|
|
510
|
+
function getViewScriptExts() {
|
|
511
|
+
return compilerOptions.viewScriptExts;
|
|
512
|
+
}
|
|
513
|
+
function getViewScriptTags() {
|
|
514
|
+
return compilerOptions.viewScriptTags;
|
|
515
|
+
}
|
|
445
516
|
function storePathInfo(workPath) {
|
|
446
517
|
pathInfo.workPath = workPath;
|
|
447
518
|
if (process2.env.TARGET_PATH) {
|
|
@@ -692,6 +763,10 @@ export {
|
|
|
692
763
|
__resetAssets,
|
|
693
764
|
storeInfo,
|
|
694
765
|
resetStoreInfo,
|
|
766
|
+
getTemplateExts,
|
|
767
|
+
getStyleExts,
|
|
768
|
+
getViewScriptExts,
|
|
769
|
+
getViewScriptTags,
|
|
695
770
|
getContentByPath,
|
|
696
771
|
resolveAppAlias,
|
|
697
772
|
getTargetPath,
|
package/dist/compile-core.node-chunks/{logic-compiler-RX63Y2FZ.js → logic-compiler-2SQFOFEO.js}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getWxMemberName,
|
|
3
3
|
warnUnsupportedWxApi
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-LUD2P6RM.js";
|
|
5
5
|
import {
|
|
6
6
|
isMainThread,
|
|
7
7
|
parentPort
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
hasCompileInfo,
|
|
20
20
|
resetStoreInfo,
|
|
21
21
|
resolveAppAlias
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-QJ34C5KK.js";
|
|
23
23
|
|
|
24
24
|
// ../../dimina/fe/packages/compiler/src/core/logic-compiler.js
|
|
25
25
|
import { resolve, sep } from "node:path";
|
package/dist/compile-core.node-chunks/{style-compiler-JUY5MZSO.js → style-compiler-ZEJ3XLTS.js}
RENAMED
|
@@ -8,12 +8,13 @@ import {
|
|
|
8
8
|
getAppId,
|
|
9
9
|
getComponent,
|
|
10
10
|
getContentByPath,
|
|
11
|
+
getStyleExts,
|
|
11
12
|
getTargetPath,
|
|
12
13
|
getWorkPath,
|
|
13
14
|
resetStoreInfo,
|
|
14
15
|
tagWhiteList,
|
|
15
16
|
transformRpx
|
|
16
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-QJ34C5KK.js";
|
|
17
18
|
|
|
18
19
|
// ../../dimina/fe/packages/compiler/src/core/style-compiler.js
|
|
19
20
|
import path from "node:path";
|
|
@@ -24,7 +25,6 @@ import less from "less";
|
|
|
24
25
|
import postcss from "postcss";
|
|
25
26
|
import selectorParser from "postcss-selector-parser";
|
|
26
27
|
import * as sass from "sass";
|
|
27
|
-
var fileType = [".wxss", ".ddss", ".less", ".scss", ".sass"];
|
|
28
28
|
var compileRes = /* @__PURE__ */ new Map();
|
|
29
29
|
if (!isMainThread) {
|
|
30
30
|
parentPort.on("message", async ({ pages, storeInfo }) => {
|
|
@@ -212,7 +212,7 @@ function normalizeCssUrlValue(value, absolutePath) {
|
|
|
212
212
|
function getAbsolutePath(modulePath) {
|
|
213
213
|
const workPath = getWorkPath();
|
|
214
214
|
const src = modulePath.startsWith("/") ? modulePath : `/${modulePath}`;
|
|
215
|
-
for (const ssType of
|
|
215
|
+
for (const ssType of getStyleExts()) {
|
|
216
216
|
const ssFullPath = `${workPath}${src}${ssType}`;
|
|
217
217
|
if (fs_default.existsSync(ssFullPath)) {
|
|
218
218
|
return ssFullPath;
|
package/dist/compile-core.node-chunks/{view-compiler-KA2OZG44.js → view-compiler-WQNV7H5G.js}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
checkTemplateCompatibility
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-LUD2P6RM.js";
|
|
4
4
|
import {
|
|
5
5
|
isMainThread,
|
|
6
6
|
parentPort
|
|
@@ -13,11 +13,14 @@ import {
|
|
|
13
13
|
getComponent,
|
|
14
14
|
getContentByPath,
|
|
15
15
|
getTargetPath,
|
|
16
|
+
getTemplateExts,
|
|
17
|
+
getViewScriptExts,
|
|
18
|
+
getViewScriptTags,
|
|
16
19
|
getWorkPath,
|
|
17
20
|
resetStoreInfo,
|
|
18
21
|
tagWhiteList,
|
|
19
22
|
transformRpx
|
|
20
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-QJ34C5KK.js";
|
|
21
24
|
|
|
22
25
|
// ../../dimina/fe/packages/compiler/src/core/view-compiler.js
|
|
23
26
|
import path from "node:path";
|
|
@@ -152,7 +155,13 @@ function parseBindings(bindings) {
|
|
|
152
155
|
}
|
|
153
156
|
|
|
154
157
|
// ../../dimina/fe/packages/compiler/src/core/view-compiler.js
|
|
155
|
-
|
|
158
|
+
function buildExtStripRegex(exts) {
|
|
159
|
+
const alt = exts.map((e) => e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
|
|
160
|
+
return new RegExp(`(${alt})$`);
|
|
161
|
+
}
|
|
162
|
+
function stripViewScriptExt(p) {
|
|
163
|
+
return p.replace(buildExtStripRegex(getViewScriptExts()), "");
|
|
164
|
+
}
|
|
156
165
|
function parseJs(code, filename = "view-compiler.js", sourceType = "module") {
|
|
157
166
|
return parseSync2(filename, code, {
|
|
158
167
|
sourceType,
|
|
@@ -358,8 +367,8 @@ function scanWxsFiles(dir, workPath) {
|
|
|
358
367
|
const stat = fs_default.statSync(fullPath);
|
|
359
368
|
if (stat.isDirectory()) {
|
|
360
369
|
scanWxsFiles(fullPath, workPath);
|
|
361
|
-
} else if (stat.isFile() && item.endsWith(
|
|
362
|
-
const relativePath = fullPath.replace(workPath, "")
|
|
370
|
+
} else if (stat.isFile() && getViewScriptExts().some((ext) => item.endsWith(ext))) {
|
|
371
|
+
const relativePath = stripViewScriptExt(fullPath.replace(workPath, ""));
|
|
363
372
|
const moduleName = relativePath.replace(/[\/\\@\-]/g, "_").replace(/^_/, "");
|
|
364
373
|
wxsFilePathMap.set(moduleName, fullPath);
|
|
365
374
|
}
|
|
@@ -589,7 +598,7 @@ function processWxsContent(wxsContent, wxsFilePath, scriptModule, workPath, file
|
|
|
589
598
|
if (filePath && filePath.includes("/miniprogram_npm/")) {
|
|
590
599
|
const currentWxsDir = path.dirname(wxsFilePath);
|
|
591
600
|
resolvedWxsPath = path.resolve(currentWxsDir, requirePath);
|
|
592
|
-
const relativePath = resolvedWxsPath.replace(workPath, "")
|
|
601
|
+
const relativePath = stripViewScriptExt(resolvedWxsPath.replace(workPath, ""));
|
|
593
602
|
const moduleName = relativePath.replace(/[\/\\@\-]/g, "_").replace(/^_/, "");
|
|
594
603
|
processWxsDependency(resolvedWxsPath, moduleName, scriptModule, workPath, filePath);
|
|
595
604
|
replacements.push({
|
|
@@ -600,7 +609,7 @@ function processWxsContent(wxsContent, wxsFilePath, scriptModule, workPath, file
|
|
|
600
609
|
} else {
|
|
601
610
|
const currentWxsDir = path.dirname(wxsFilePath);
|
|
602
611
|
resolvedWxsPath = path.resolve(currentWxsDir, requirePath);
|
|
603
|
-
const relativePath = resolvedWxsPath.replace(workPath, "")
|
|
612
|
+
const relativePath = stripViewScriptExt(resolvedWxsPath.replace(workPath, ""));
|
|
604
613
|
const depModuleName = relativePath.replace(/[\/\\@\-]/g, "_").replace(/^_/, "");
|
|
605
614
|
processWxsDependency(resolvedWxsPath, depModuleName, scriptModule, workPath, filePath);
|
|
606
615
|
replacements.push({
|
|
@@ -816,7 +825,7 @@ function toCompileTemplate(isComponent, path2, components, componentPlaceholder,
|
|
|
816
825
|
const src = $(elem).attr("src");
|
|
817
826
|
if (src) {
|
|
818
827
|
const includeFullPath = getAbsolutePath(workPath, path2, src);
|
|
819
|
-
let includePath = includeFullPath.replace(workPath, "").replace(
|
|
828
|
+
let includePath = includeFullPath.replace(workPath, "").replace(buildExtStripRegex(getTemplateExts()), "");
|
|
820
829
|
const includeDiagnosticSource = includeFullPath.startsWith(workPath) ? includeFullPath.slice(workPath.length) : includePath;
|
|
821
830
|
if (!includePath.startsWith("/")) {
|
|
822
831
|
includePath = "/" + includePath;
|
|
@@ -842,8 +851,7 @@ function toCompileTemplate(isComponent, path2, components, componentPlaceholder,
|
|
|
842
851
|
);
|
|
843
852
|
processIncludedFileWxsDependencies(includeContent, includePath, scriptModule, components, processedPaths);
|
|
844
853
|
$includeContent("template").remove();
|
|
845
|
-
$includeContent("
|
|
846
|
-
$includeContent("dds").remove();
|
|
854
|
+
$includeContent(getViewScriptTags().join(",")).remove();
|
|
847
855
|
const processedContent = processIncludeConditionalAttrs($, elem, $includeContent.html());
|
|
848
856
|
$(elem).replaceWith(processedContent);
|
|
849
857
|
} else {
|
|
@@ -860,7 +868,7 @@ function toCompileTemplate(isComponent, path2, components, componentPlaceholder,
|
|
|
860
868
|
const src = $(elem).attr("src");
|
|
861
869
|
if (src) {
|
|
862
870
|
const importFullPath = getAbsolutePath(workPath, path2, src);
|
|
863
|
-
let importPath = importFullPath.replace(workPath, "").replace(
|
|
871
|
+
let importPath = importFullPath.replace(workPath, "").replace(buildExtStripRegex(getTemplateExts()), "");
|
|
864
872
|
const importDiagnosticSource = importFullPath.startsWith(workPath) ? importFullPath.slice(workPath.length) : importPath;
|
|
865
873
|
if (!importPath.startsWith("/")) {
|
|
866
874
|
importPath = "/" + importPath;
|
|
@@ -907,8 +915,7 @@ function transTagTemplate($, templateModule, path2, components, componentPlaceho
|
|
|
907
915
|
const templateContent = $(elem);
|
|
908
916
|
templateContent.find("import").remove();
|
|
909
917
|
templateContent.find("include").remove();
|
|
910
|
-
templateContent.find("
|
|
911
|
-
templateContent.find("dds").remove();
|
|
918
|
+
templateContent.find(getViewScriptTags().join(",")).remove();
|
|
912
919
|
transAsses($, templateContent.find("image"), path2);
|
|
913
920
|
const res = [];
|
|
914
921
|
transHtmlTag(templateContent.html(), res, components, componentPlaceholder);
|
|
@@ -1215,7 +1222,7 @@ function parseKeyExpression(exp, itemName = "item", indexName = "index") {
|
|
|
1215
1222
|
}
|
|
1216
1223
|
function getViewPath(workPath, src) {
|
|
1217
1224
|
const aSrc = src.startsWith("/") ? src : `/${src}`;
|
|
1218
|
-
for (const mlType of
|
|
1225
|
+
for (const mlType of getTemplateExts()) {
|
|
1219
1226
|
const mlFullPath = `${workPath}${aSrc}${mlType}`;
|
|
1220
1227
|
if (fs_default.existsSync(mlFullPath)) {
|
|
1221
1228
|
return mlFullPath;
|
|
@@ -1324,10 +1331,7 @@ function parseTemplateDataExp(exp) {
|
|
|
1324
1331
|
return `{${parseBraceExp(exp)}}`;
|
|
1325
1332
|
}
|
|
1326
1333
|
function transTagWxs($, scriptModule, filePath) {
|
|
1327
|
-
|
|
1328
|
-
if (wxsNodes.length === 0) {
|
|
1329
|
-
wxsNodes = $("dds");
|
|
1330
|
-
}
|
|
1334
|
+
const wxsNodes = $(getViewScriptTags().join(","));
|
|
1331
1335
|
wxsNodes.each((_, elem) => {
|
|
1332
1336
|
const smName = $(elem).attr("module");
|
|
1333
1337
|
if (smName) {
|
|
@@ -1346,7 +1350,7 @@ function transTagWxs($, scriptModule, filePath) {
|
|
|
1346
1350
|
wxsFilePath = getAbsolutePath(workPath, filePath, src);
|
|
1347
1351
|
}
|
|
1348
1352
|
if (wxsFilePath) {
|
|
1349
|
-
const relativePath = wxsFilePath.replace(workPath, "")
|
|
1353
|
+
const relativePath = stripViewScriptExt(wxsFilePath.replace(workPath, ""));
|
|
1350
1354
|
uniqueModuleName = relativePath.replace(/[\/\\@\-]/g, "_").replace(/^_/, "");
|
|
1351
1355
|
cacheKey = wxsFilePath;
|
|
1352
1356
|
}
|
|
@@ -1419,12 +1423,8 @@ function collectAllWxsModules(scriptRes, collectedPaths = /* @__PURE__ */ new Se
|
|
|
1419
1423
|
return allWxsModules;
|
|
1420
1424
|
}
|
|
1421
1425
|
function loadWxsModule(modulePath, workPath, scriptModule) {
|
|
1422
|
-
if (!modulePath.startsWith("miniprogram_npm__") || !modulePath.includes("_wxs_")) {
|
|
1423
|
-
return null;
|
|
1424
|
-
}
|
|
1425
1426
|
const wxsFilePath = wxsFilePathMap.get(modulePath);
|
|
1426
1427
|
if (!wxsFilePath) {
|
|
1427
|
-
console.warn(`[view] \u65E0\u6CD5\u627E\u5230 wxs \u6A21\u5757\u6587\u4EF6: ${modulePath}`);
|
|
1428
1428
|
return null;
|
|
1429
1429
|
}
|
|
1430
1430
|
try {
|
|
@@ -1516,6 +1516,8 @@ export {
|
|
|
1516
1516
|
compileML,
|
|
1517
1517
|
generateSlotDirective,
|
|
1518
1518
|
generateVModelTemplate,
|
|
1519
|
+
initWxsFilePathMap,
|
|
1520
|
+
loadWxsModule,
|
|
1519
1521
|
parseBraceExp,
|
|
1520
1522
|
parseClassRules,
|
|
1521
1523
|
parseKeyExpression,
|
|
@@ -7,13 +7,16 @@ import {
|
|
|
7
7
|
getAppName,
|
|
8
8
|
getPageConfigInfo,
|
|
9
9
|
getPages,
|
|
10
|
+
getStyleExts,
|
|
10
11
|
getTargetPath,
|
|
12
|
+
getTemplateExts,
|
|
13
|
+
getViewScriptExts,
|
|
11
14
|
getWorkPath,
|
|
12
15
|
resetFs,
|
|
13
16
|
resetStoreInfo,
|
|
14
17
|
setFs,
|
|
15
18
|
storeInfo
|
|
16
|
-
} from "./compile-core.node-chunks/chunk-
|
|
19
|
+
} from "./compile-core.node-chunks/chunk-QJ34C5KK.js";
|
|
17
20
|
|
|
18
21
|
// ../../dimina/fe/packages/compiler/src/common/publish.js
|
|
19
22
|
function createDist() {
|
|
@@ -168,7 +171,7 @@ var NpmBuilder = class {
|
|
|
168
171
|
* @returns {boolean} 是否为小程序文件
|
|
169
172
|
*/
|
|
170
173
|
isMiniprogramFile(filename) {
|
|
171
|
-
const miniprogramExts = [".js", ".json", ".
|
|
174
|
+
const miniprogramExts = [".js", ".json", ".ts", ...getTemplateExts(), ...getStyleExts(), ...getViewScriptExts()];
|
|
172
175
|
const ext = path.extname(filename).toLowerCase();
|
|
173
176
|
return miniprogramExts.includes(ext) || filename === "package.json" || filename === "README.md" || filename.startsWith(".");
|
|
174
177
|
}
|
|
@@ -251,9 +254,9 @@ var NpmBuilder = class {
|
|
|
251
254
|
|
|
252
255
|
// src/compile-core.js
|
|
253
256
|
var STAGE_IMPORTERS = {
|
|
254
|
-
logic: () => import("./compile-core.node-chunks/logic-compiler-
|
|
255
|
-
view: () => import("./compile-core.node-chunks/view-compiler-
|
|
256
|
-
style: () => import("./compile-core.node-chunks/style-compiler-
|
|
257
|
+
logic: () => import("./compile-core.node-chunks/logic-compiler-2SQFOFEO.js"),
|
|
258
|
+
view: () => import("./compile-core.node-chunks/view-compiler-WQNV7H5G.js"),
|
|
259
|
+
style: () => import("./compile-core.node-chunks/style-compiler-ZEJ3XLTS.js")
|
|
257
260
|
};
|
|
258
261
|
var stageLoads = /* @__PURE__ */ new Map();
|
|
259
262
|
var stageModules = /* @__PURE__ */ new Map();
|
|
@@ -474,8 +477,8 @@ function compileMiniApp(opts = {}) {
|
|
|
474
477
|
});
|
|
475
478
|
return result;
|
|
476
479
|
}
|
|
477
|
-
async function runCompile({ fs, workPath = "/work" } = {}) {
|
|
478
|
-
const ctx = await setupCompile({ fs, workPath });
|
|
480
|
+
async function runCompile({ fs, workPath = "/work", options = {} } = {}) {
|
|
481
|
+
const ctx = await setupCompile({ fs, workPath, options });
|
|
479
482
|
const { storeInfo: bundle, pages, appId, name, targetPath } = ctx;
|
|
480
483
|
await compileStage({ stage: "logic", pages, storeInfo: bundle, fs });
|
|
481
484
|
await compileStage({ stage: "view", pages, storeInfo: bundle, fs });
|
package/dist/pool.browser.js
CHANGED
|
@@ -252,9 +252,9 @@ function createCompilerPool(options = {}) {
|
|
|
252
252
|
function warmup() {
|
|
253
253
|
return settleAll(workers.map(ensureWarm));
|
|
254
254
|
}
|
|
255
|
-
async function runAttempt(files, workPath) {
|
|
255
|
+
async function runAttempt(files, workPath, options2) {
|
|
256
256
|
await settleAll(workers.map(ensureWarm));
|
|
257
|
-
const s = await requestChecked(workers[0], { type: "setup", files, workPath, wantHeartbeat: true }, "setup", sendTimeoutMs);
|
|
257
|
+
const s = await requestChecked(workers[0], { type: "setup", files, workPath, options: options2, wantHeartbeat: true }, "setup", sendTimeoutMs);
|
|
258
258
|
const { bundle, scaffold } = s;
|
|
259
259
|
const parts = await settleAll(workers.map((x) => requestChecked(x, { type: "compile-subset", files, workPath, stages: [x.stage], bundle, wantHeartbeat: true }, "compile-subset", sendTimeoutMs)));
|
|
260
260
|
const merged = { ...scaffold || {} };
|
|
@@ -271,14 +271,15 @@ function createCompilerPool(options = {}) {
|
|
|
271
271
|
}
|
|
272
272
|
const files = input.files || input;
|
|
273
273
|
if (!files || typeof files !== "object" || !Object.keys(files).length) {
|
|
274
|
-
throw new Error("[compiler] pool.compile expects { files: { relPath: content }, workPath? } (or a non-empty files map)");
|
|
274
|
+
throw new Error("[compiler] pool.compile expects { files: { relPath: content }, workPath?, options? } (or a non-empty files map)");
|
|
275
275
|
}
|
|
276
276
|
const workPath = input.workPath || defaultWorkPath;
|
|
277
|
+
const options2 = input.options || {};
|
|
277
278
|
try {
|
|
278
|
-
return await runAttempt(files, workPath);
|
|
279
|
+
return await runAttempt(files, workPath, options2);
|
|
279
280
|
} catch (err) {
|
|
280
281
|
if (!retryOnWorkerDeath || !err || !WORKER_DEATH_CODES.has(err.code)) throw err;
|
|
281
|
-
return await runAttempt(files, workPath);
|
|
282
|
+
return await runAttempt(files, workPath, options2);
|
|
282
283
|
}
|
|
283
284
|
});
|
|
284
285
|
chain = run.then(() => {
|
|
@@ -367,23 +367,94 @@ var NpmResolver = class {
|
|
|
367
367
|
var pathInfo = {};
|
|
368
368
|
var configInfo = {};
|
|
369
369
|
var npmResolver = null;
|
|
370
|
-
|
|
370
|
+
var DEFAULT_TEMPLATE_EXTS = [".wxml", ".ddml"];
|
|
371
|
+
var DEFAULT_STYLE_EXTS = [".wxss", ".ddss", ".less", ".scss", ".sass"];
|
|
372
|
+
var DEFAULT_VIEW_SCRIPT_EXTS = [".wxs"];
|
|
373
|
+
var DEFAULT_VIEW_SCRIPT_TAGS = ["wxs", "dds"];
|
|
374
|
+
var RESERVED_EXTS = /* @__PURE__ */ new Set([
|
|
375
|
+
...DEFAULT_TEMPLATE_EXTS,
|
|
376
|
+
...DEFAULT_STYLE_EXTS,
|
|
377
|
+
...DEFAULT_VIEW_SCRIPT_EXTS,
|
|
378
|
+
".js",
|
|
379
|
+
".ts",
|
|
380
|
+
".json"
|
|
381
|
+
]);
|
|
382
|
+
var compilerOptions = normalizeFileTypes();
|
|
383
|
+
function normalizeExt(raw) {
|
|
384
|
+
if (typeof raw !== "string") {
|
|
385
|
+
return null;
|
|
386
|
+
}
|
|
387
|
+
const v = raw.trim().toLowerCase().replace(/^\.+/, "");
|
|
388
|
+
if (!/^[a-z0-9_-]+$/.test(v)) {
|
|
389
|
+
return null;
|
|
390
|
+
}
|
|
391
|
+
return `.${v}`;
|
|
392
|
+
}
|
|
393
|
+
function normalizeTag(raw) {
|
|
394
|
+
if (typeof raw !== "string") {
|
|
395
|
+
return null;
|
|
396
|
+
}
|
|
397
|
+
const v = raw.trim().toLowerCase().replace(/^\.+/, "");
|
|
398
|
+
if (!/^[a-z][a-z0-9_-]*$/.test(v)) {
|
|
399
|
+
return null;
|
|
400
|
+
}
|
|
401
|
+
return v;
|
|
402
|
+
}
|
|
403
|
+
function mergeUnique(builtins, custom, normalizer, reserved) {
|
|
404
|
+
const out = [...builtins];
|
|
405
|
+
const seen = new Set(builtins);
|
|
406
|
+
if (Array.isArray(custom)) {
|
|
407
|
+
for (const raw of custom) {
|
|
408
|
+
const n = normalizer(raw);
|
|
409
|
+
if (n && !seen.has(n) && !reserved?.has(n)) {
|
|
410
|
+
seen.add(n);
|
|
411
|
+
out.push(n);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
return out;
|
|
416
|
+
}
|
|
417
|
+
function normalizeFileTypes(fileTypes = {}) {
|
|
418
|
+
const ft = fileTypes || {};
|
|
419
|
+
return {
|
|
420
|
+
templateExts: mergeUnique(DEFAULT_TEMPLATE_EXTS, ft.template, normalizeExt, RESERVED_EXTS),
|
|
421
|
+
styleExts: mergeUnique(DEFAULT_STYLE_EXTS, ft.style, normalizeExt, RESERVED_EXTS),
|
|
422
|
+
viewScriptExts: mergeUnique(DEFAULT_VIEW_SCRIPT_EXTS, ft.viewScript, normalizeExt, RESERVED_EXTS),
|
|
423
|
+
viewScriptTags: mergeUnique(DEFAULT_VIEW_SCRIPT_TAGS, ft.viewScript, normalizeTag)
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
function storeInfo(workPath, options = {}) {
|
|
371
427
|
storePathInfo(workPath);
|
|
372
428
|
storeProjectConfig();
|
|
373
429
|
storeAppConfig();
|
|
374
430
|
storePageConfig();
|
|
431
|
+
compilerOptions = normalizeFileTypes(options.fileTypes);
|
|
375
432
|
return {
|
|
376
433
|
pathInfo,
|
|
377
|
-
configInfo
|
|
434
|
+
configInfo,
|
|
435
|
+
compilerOptions
|
|
378
436
|
};
|
|
379
437
|
}
|
|
380
438
|
function resetStoreInfo(opts) {
|
|
381
439
|
pathInfo = opts.pathInfo;
|
|
382
440
|
configInfo = opts.configInfo;
|
|
441
|
+
compilerOptions = opts.compilerOptions || normalizeFileTypes();
|
|
383
442
|
if (pathInfo.workPath) {
|
|
384
443
|
npmResolver = new NpmResolver(pathInfo.workPath);
|
|
385
444
|
}
|
|
386
445
|
}
|
|
446
|
+
function getTemplateExts() {
|
|
447
|
+
return compilerOptions.templateExts;
|
|
448
|
+
}
|
|
449
|
+
function getStyleExts() {
|
|
450
|
+
return compilerOptions.styleExts;
|
|
451
|
+
}
|
|
452
|
+
function getViewScriptExts() {
|
|
453
|
+
return compilerOptions.viewScriptExts;
|
|
454
|
+
}
|
|
455
|
+
function getViewScriptTags() {
|
|
456
|
+
return compilerOptions.viewScriptTags;
|
|
457
|
+
}
|
|
387
458
|
function storePathInfo(workPath) {
|
|
388
459
|
pathInfo.workPath = workPath;
|
|
389
460
|
if (process2.env.TARGET_PATH) {
|
|
@@ -631,6 +702,10 @@ export {
|
|
|
631
702
|
__resetAssets,
|
|
632
703
|
storeInfo,
|
|
633
704
|
resetStoreInfo,
|
|
705
|
+
getTemplateExts,
|
|
706
|
+
getStyleExts,
|
|
707
|
+
getViewScriptExts,
|
|
708
|
+
getViewScriptTags,
|
|
634
709
|
getContentByPath,
|
|
635
710
|
resolveAppAlias,
|
|
636
711
|
getTargetPath,
|
package/dist/{compile-core.node-chunks/chunk-CCZB2BJG.js → pool.node-chunks/chunk-C7GEIDCP.js}
RENAMED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getViewScriptTags
|
|
3
|
+
} from "./chunk-7FGOYOXU.js";
|
|
4
|
+
|
|
1
5
|
// ../../dimina/fe/packages/compiler/src/common/compatibility.js
|
|
2
6
|
import { Parser } from "htmlparser2";
|
|
3
7
|
|
|
@@ -142,7 +146,7 @@ function warnUnsupportedWxApi(apiName, filePath, line) {
|
|
|
142
146
|
}
|
|
143
147
|
function warnUnsupportedComponent(tagName, filePath, line) {
|
|
144
148
|
const { supportedBuiltinComponents: supportedBuiltinComponents2 } = loadReference();
|
|
145
|
-
if (!tagName || supportedBuiltinComponents2.has(tagName)) {
|
|
149
|
+
if (!tagName || supportedBuiltinComponents2.has(tagName) || getViewScriptTags().includes(tagName)) {
|
|
146
150
|
return;
|
|
147
151
|
}
|
|
148
152
|
const location = formatLocation(filePath, line);
|
|
@@ -6,10 +6,13 @@ import {
|
|
|
6
6
|
getAppName,
|
|
7
7
|
getPageConfigInfo,
|
|
8
8
|
getPages,
|
|
9
|
+
getStyleExts,
|
|
9
10
|
getTargetPath,
|
|
11
|
+
getTemplateExts,
|
|
12
|
+
getViewScriptExts,
|
|
10
13
|
getWorkPath,
|
|
11
14
|
storeInfo
|
|
12
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-7FGOYOXU.js";
|
|
13
16
|
|
|
14
17
|
// ../../dimina/fe/packages/compiler/src/common/publish.js
|
|
15
18
|
import path from "node:path";
|
|
@@ -232,7 +235,7 @@ var NpmBuilder = class {
|
|
|
232
235
|
* @returns {boolean} 是否为小程序文件
|
|
233
236
|
*/
|
|
234
237
|
isMiniprogramFile(filename) {
|
|
235
|
-
const miniprogramExts = [".js", ".json", ".
|
|
238
|
+
const miniprogramExts = [".js", ".json", ".ts", ...getTemplateExts(), ...getStyleExts(), ...getViewScriptExts()];
|
|
236
239
|
const ext = path2.extname(filename).toLowerCase();
|
|
237
240
|
return miniprogramExts.includes(ext) || filename === "package.json" || filename === "README.md" || filename.startsWith(".");
|
|
238
241
|
}
|
|
@@ -315,9 +318,9 @@ var NpmBuilder = class {
|
|
|
315
318
|
|
|
316
319
|
// src/compile-core.js
|
|
317
320
|
var STAGE_IMPORTERS = {
|
|
318
|
-
logic: () => import("./logic-compiler-
|
|
319
|
-
view: () => import("./view-compiler-
|
|
320
|
-
style: () => import("./style-compiler-
|
|
321
|
+
logic: () => import("./logic-compiler-BODAINZQ.js"),
|
|
322
|
+
view: () => import("./view-compiler-HOFFL63K.js"),
|
|
323
|
+
style: () => import("./style-compiler-TUNDVSR5.js")
|
|
321
324
|
};
|
|
322
325
|
var stageLoads = /* @__PURE__ */ new Map();
|
|
323
326
|
var stageModules = /* @__PURE__ */ new Map();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getWxMemberName,
|
|
3
3
|
warnUnsupportedWxApi
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-C7GEIDCP.js";
|
|
5
5
|
import {
|
|
6
6
|
isMainThread,
|
|
7
7
|
parentPort
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
hasCompileInfo,
|
|
19
19
|
resetStoreInfo,
|
|
20
20
|
resolveAppAlias
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-7FGOYOXU.js";
|
|
22
22
|
|
|
23
23
|
// ../../dimina/fe/packages/compiler/src/core/logic-compiler.js
|
|
24
24
|
import fs from "node:fs";
|
|
@@ -7,12 +7,13 @@ import {
|
|
|
7
7
|
getAppId,
|
|
8
8
|
getComponent,
|
|
9
9
|
getContentByPath,
|
|
10
|
+
getStyleExts,
|
|
10
11
|
getTargetPath,
|
|
11
12
|
getWorkPath,
|
|
12
13
|
resetStoreInfo,
|
|
13
14
|
tagWhiteList,
|
|
14
15
|
transformRpx
|
|
15
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-7FGOYOXU.js";
|
|
16
17
|
|
|
17
18
|
// ../../dimina/fe/packages/compiler/src/core/style-compiler.js
|
|
18
19
|
import fs from "node:fs";
|
|
@@ -24,7 +25,6 @@ import less from "less";
|
|
|
24
25
|
import postcss from "postcss";
|
|
25
26
|
import selectorParser from "postcss-selector-parser";
|
|
26
27
|
import * as sass from "sass";
|
|
27
|
-
var fileType = [".wxss", ".ddss", ".less", ".scss", ".sass"];
|
|
28
28
|
var compileRes = /* @__PURE__ */ new Map();
|
|
29
29
|
if (!isMainThread) {
|
|
30
30
|
parentPort.on("message", async ({ pages, storeInfo }) => {
|
|
@@ -212,7 +212,7 @@ function normalizeCssUrlValue(value, absolutePath) {
|
|
|
212
212
|
function getAbsolutePath(modulePath) {
|
|
213
213
|
const workPath = getWorkPath();
|
|
214
214
|
const src = modulePath.startsWith("/") ? modulePath : `/${modulePath}`;
|
|
215
|
-
for (const ssType of
|
|
215
|
+
for (const ssType of getStyleExts()) {
|
|
216
216
|
const ssFullPath = `${workPath}${src}${ssType}`;
|
|
217
217
|
if (fs.existsSync(ssFullPath)) {
|
|
218
218
|
return ssFullPath;
|