@dimina-kit/compiler 0.0.1-dev.20260706125036 → 0.0.1-dev.20260706131625
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 +105 -34
- 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 +8 -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 +2 -2
- package/dist/stage-worker.browser.js +105 -34
- package/dist/stage-worker.node.js +2 -2
- package/package.json +1 -1
|
@@ -989,23 +989,81 @@ var init_npm_resolver = __esm({
|
|
|
989
989
|
});
|
|
990
990
|
|
|
991
991
|
// ../../dimina/fe/packages/compiler/src/env.js
|
|
992
|
-
function
|
|
992
|
+
function normalizeExt(raw) {
|
|
993
|
+
if (typeof raw !== "string") {
|
|
994
|
+
return null;
|
|
995
|
+
}
|
|
996
|
+
const v = raw.trim().toLowerCase().replace(/^\.+/, "");
|
|
997
|
+
if (!/^[a-z0-9_-]+$/.test(v)) {
|
|
998
|
+
return null;
|
|
999
|
+
}
|
|
1000
|
+
return `.${v}`;
|
|
1001
|
+
}
|
|
1002
|
+
function normalizeTag(raw) {
|
|
1003
|
+
if (typeof raw !== "string") {
|
|
1004
|
+
return null;
|
|
1005
|
+
}
|
|
1006
|
+
const v = raw.trim().toLowerCase().replace(/^\.+/, "");
|
|
1007
|
+
if (!/^[a-z][a-z0-9_-]*$/.test(v)) {
|
|
1008
|
+
return null;
|
|
1009
|
+
}
|
|
1010
|
+
return v;
|
|
1011
|
+
}
|
|
1012
|
+
function mergeUnique(builtins, custom, normalizer, reserved) {
|
|
1013
|
+
const out = [...builtins];
|
|
1014
|
+
const seen2 = new Set(builtins);
|
|
1015
|
+
if (Array.isArray(custom)) {
|
|
1016
|
+
for (const raw of custom) {
|
|
1017
|
+
const n2 = normalizer(raw);
|
|
1018
|
+
if (n2 && !seen2.has(n2) && !reserved?.has(n2)) {
|
|
1019
|
+
seen2.add(n2);
|
|
1020
|
+
out.push(n2);
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
return out;
|
|
1025
|
+
}
|
|
1026
|
+
function normalizeFileTypes(fileTypes = {}) {
|
|
1027
|
+
const ft = fileTypes || {};
|
|
1028
|
+
return {
|
|
1029
|
+
templateExts: mergeUnique(DEFAULT_TEMPLATE_EXTS, ft.template, normalizeExt, RESERVED_EXTS),
|
|
1030
|
+
styleExts: mergeUnique(DEFAULT_STYLE_EXTS, ft.style, normalizeExt, RESERVED_EXTS),
|
|
1031
|
+
viewScriptExts: mergeUnique(DEFAULT_VIEW_SCRIPT_EXTS, ft.viewScript, normalizeExt, RESERVED_EXTS),
|
|
1032
|
+
viewScriptTags: mergeUnique(DEFAULT_VIEW_SCRIPT_TAGS, ft.viewScript, normalizeTag)
|
|
1033
|
+
};
|
|
1034
|
+
}
|
|
1035
|
+
function storeInfo(workPath, options = {}) {
|
|
993
1036
|
storePathInfo(workPath);
|
|
994
1037
|
storeProjectConfig();
|
|
995
1038
|
storeAppConfig();
|
|
996
1039
|
storePageConfig();
|
|
1040
|
+
compilerOptions = normalizeFileTypes(options.fileTypes);
|
|
997
1041
|
return {
|
|
998
1042
|
pathInfo,
|
|
999
|
-
configInfo
|
|
1043
|
+
configInfo,
|
|
1044
|
+
compilerOptions
|
|
1000
1045
|
};
|
|
1001
1046
|
}
|
|
1002
1047
|
function resetStoreInfo(opts) {
|
|
1003
1048
|
pathInfo = opts.pathInfo;
|
|
1004
1049
|
configInfo = opts.configInfo;
|
|
1050
|
+
compilerOptions = opts.compilerOptions || normalizeFileTypes();
|
|
1005
1051
|
if (pathInfo.workPath) {
|
|
1006
1052
|
npmResolver = new NpmResolver(pathInfo.workPath);
|
|
1007
1053
|
}
|
|
1008
1054
|
}
|
|
1055
|
+
function getTemplateExts() {
|
|
1056
|
+
return compilerOptions.templateExts;
|
|
1057
|
+
}
|
|
1058
|
+
function getStyleExts() {
|
|
1059
|
+
return compilerOptions.styleExts;
|
|
1060
|
+
}
|
|
1061
|
+
function getViewScriptExts() {
|
|
1062
|
+
return compilerOptions.viewScriptExts;
|
|
1063
|
+
}
|
|
1064
|
+
function getViewScriptTags() {
|
|
1065
|
+
return compilerOptions.viewScriptTags;
|
|
1066
|
+
}
|
|
1009
1067
|
function storePathInfo(workPath) {
|
|
1010
1068
|
pathInfo.workPath = workPath;
|
|
1011
1069
|
if (process_default.env.TARGET_PATH) {
|
|
@@ -1243,7 +1301,7 @@ function getPages() {
|
|
|
1243
1301
|
subPages
|
|
1244
1302
|
};
|
|
1245
1303
|
}
|
|
1246
|
-
var import_node_path4, pathInfo, configInfo, npmResolver;
|
|
1304
|
+
var import_node_path4, pathInfo, configInfo, npmResolver, DEFAULT_TEMPLATE_EXTS, DEFAULT_STYLE_EXTS, DEFAULT_VIEW_SCRIPT_EXTS, DEFAULT_VIEW_SCRIPT_TAGS, RESERVED_EXTS, compilerOptions;
|
|
1247
1305
|
var init_env = __esm({
|
|
1248
1306
|
"../../dimina/fe/packages/compiler/src/env.js"() {
|
|
1249
1307
|
init_fs();
|
|
@@ -1256,6 +1314,19 @@ var init_env = __esm({
|
|
|
1256
1314
|
pathInfo = {};
|
|
1257
1315
|
configInfo = {};
|
|
1258
1316
|
npmResolver = null;
|
|
1317
|
+
DEFAULT_TEMPLATE_EXTS = [".wxml", ".ddml"];
|
|
1318
|
+
DEFAULT_STYLE_EXTS = [".wxss", ".ddss", ".less", ".scss", ".sass"];
|
|
1319
|
+
DEFAULT_VIEW_SCRIPT_EXTS = [".wxs"];
|
|
1320
|
+
DEFAULT_VIEW_SCRIPT_TAGS = ["wxs", "dds"];
|
|
1321
|
+
RESERVED_EXTS = /* @__PURE__ */ new Set([
|
|
1322
|
+
...DEFAULT_TEMPLATE_EXTS,
|
|
1323
|
+
...DEFAULT_STYLE_EXTS,
|
|
1324
|
+
...DEFAULT_VIEW_SCRIPT_EXTS,
|
|
1325
|
+
".js",
|
|
1326
|
+
".ts",
|
|
1327
|
+
".json"
|
|
1328
|
+
]);
|
|
1329
|
+
compilerOptions = normalizeFileTypes();
|
|
1259
1330
|
}
|
|
1260
1331
|
});
|
|
1261
1332
|
|
|
@@ -4669,7 +4740,7 @@ function warnUnsupportedWxApi(apiName, filePath, line) {
|
|
|
4669
4740
|
}
|
|
4670
4741
|
function warnUnsupportedComponent(tagName, filePath, line) {
|
|
4671
4742
|
const { supportedBuiltinComponents: supportedBuiltinComponents2 } = loadReference();
|
|
4672
|
-
if (!tagName || supportedBuiltinComponents2.has(tagName)) {
|
|
4743
|
+
if (!tagName || supportedBuiltinComponents2.has(tagName) || getViewScriptTags().includes(tagName)) {
|
|
4673
4744
|
return;
|
|
4674
4745
|
}
|
|
4675
4746
|
const location = formatLocation(filePath, line);
|
|
@@ -4730,6 +4801,7 @@ var cachedReference, warnedItems;
|
|
|
4730
4801
|
var init_compatibility = __esm({
|
|
4731
4802
|
"../../dimina/fe/packages/compiler/src/common/compatibility.js"() {
|
|
4732
4803
|
init_dist3();
|
|
4804
|
+
init_env();
|
|
4733
4805
|
init_compatibility_reference();
|
|
4734
4806
|
cachedReference = null;
|
|
4735
4807
|
warnedItems = /* @__PURE__ */ new Set();
|
|
@@ -31096,7 +31168,7 @@ function doCompileTemplate({
|
|
|
31096
31168
|
ssrCssVars,
|
|
31097
31169
|
isProd = false,
|
|
31098
31170
|
compiler,
|
|
31099
|
-
compilerOptions = {},
|
|
31171
|
+
compilerOptions: compilerOptions2 = {},
|
|
31100
31172
|
transformAssetUrls
|
|
31101
31173
|
}) {
|
|
31102
31174
|
const errors2 = [];
|
|
@@ -31130,7 +31202,7 @@ function doCompileTemplate({
|
|
|
31130
31202
|
if (inAST == null ? void 0 : inAST.transformed) {
|
|
31131
31203
|
const newAST = (ssr ? CompilerDOM : compiler).parse(inAST.source, __spreadProps$5(__spreadValues$6({
|
|
31132
31204
|
prefixIdentifiers: true
|
|
31133
|
-
},
|
|
31205
|
+
}, compilerOptions2), {
|
|
31134
31206
|
parseMode: "sfc",
|
|
31135
31207
|
onError: (e) => errors2.push(e)
|
|
31136
31208
|
}));
|
|
@@ -31148,9 +31220,9 @@ function doCompileTemplate({
|
|
|
31148
31220
|
scopeId: scoped ? longId : void 0,
|
|
31149
31221
|
slotted,
|
|
31150
31222
|
sourceMap: true
|
|
31151
|
-
},
|
|
31223
|
+
}, compilerOptions2), {
|
|
31152
31224
|
hmr: !isProd,
|
|
31153
|
-
nodeTransforms: nodeTransforms.concat(
|
|
31225
|
+
nodeTransforms: nodeTransforms.concat(compilerOptions2.nodeTransforms || []),
|
|
31154
31226
|
filename,
|
|
31155
31227
|
onError: (e) => errors2.push(e),
|
|
31156
31228
|
onWarn: (w) => warnings.push(w)
|
|
@@ -62922,6 +62994,8 @@ __export(view_compiler_exports, {
|
|
|
62922
62994
|
compileML: () => compileML,
|
|
62923
62995
|
generateSlotDirective: () => generateSlotDirective,
|
|
62924
62996
|
generateVModelTemplate: () => generateVModelTemplate,
|
|
62997
|
+
initWxsFilePathMap: () => initWxsFilePathMap,
|
|
62998
|
+
loadWxsModule: () => loadWxsModule,
|
|
62925
62999
|
parseBraceExp: () => parseBraceExp,
|
|
62926
63000
|
parseClassRules: () => parseClassRules,
|
|
62927
63001
|
parseKeyExpression: () => parseKeyExpression,
|
|
@@ -62930,6 +63004,13 @@ __export(view_compiler_exports, {
|
|
|
62930
63004
|
processWxsContent: () => processWxsContent,
|
|
62931
63005
|
splitWithBraces: () => splitWithBraces
|
|
62932
63006
|
});
|
|
63007
|
+
function buildExtStripRegex(exts) {
|
|
63008
|
+
const alt = exts.map((e) => e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
|
|
63009
|
+
return new RegExp(`(${alt})$`);
|
|
63010
|
+
}
|
|
63011
|
+
function stripViewScriptExt(p) {
|
|
63012
|
+
return p.replace(buildExtStripRegex(getViewScriptExts()), "");
|
|
63013
|
+
}
|
|
62933
63014
|
function parseJs(code, filename = "view-compiler.js", sourceType = "module") {
|
|
62934
63015
|
return parseSync(filename, code, {
|
|
62935
63016
|
sourceType,
|
|
@@ -63095,8 +63176,8 @@ function scanWxsFiles(dir, workPath) {
|
|
|
63095
63176
|
const stat2 = fs_default.statSync(fullPath);
|
|
63096
63177
|
if (stat2.isDirectory()) {
|
|
63097
63178
|
scanWxsFiles(fullPath, workPath);
|
|
63098
|
-
} else if (stat2.isFile() && item.endsWith(
|
|
63099
|
-
const relativePath = fullPath.replace(workPath, "")
|
|
63179
|
+
} else if (stat2.isFile() && getViewScriptExts().some((ext) => item.endsWith(ext))) {
|
|
63180
|
+
const relativePath = stripViewScriptExt(fullPath.replace(workPath, ""));
|
|
63100
63181
|
const moduleName = relativePath.replace(/[\/\\@\-]/g, "_").replace(/^_/, "");
|
|
63101
63182
|
wxsFilePathMap.set(moduleName, fullPath);
|
|
63102
63183
|
}
|
|
@@ -63326,7 +63407,7 @@ function processWxsContent(wxsContent, wxsFilePath, scriptModule, workPath, file
|
|
|
63326
63407
|
if (filePath && filePath.includes("/miniprogram_npm/")) {
|
|
63327
63408
|
const currentWxsDir = import_node_path8.default.dirname(wxsFilePath);
|
|
63328
63409
|
resolvedWxsPath = import_node_path8.default.resolve(currentWxsDir, requirePath);
|
|
63329
|
-
const relativePath = resolvedWxsPath.replace(workPath, "")
|
|
63410
|
+
const relativePath = stripViewScriptExt(resolvedWxsPath.replace(workPath, ""));
|
|
63330
63411
|
const moduleName = relativePath.replace(/[\/\\@\-]/g, "_").replace(/^_/, "");
|
|
63331
63412
|
processWxsDependency(resolvedWxsPath, moduleName, scriptModule, workPath, filePath);
|
|
63332
63413
|
replacements.push({
|
|
@@ -63337,7 +63418,7 @@ function processWxsContent(wxsContent, wxsFilePath, scriptModule, workPath, file
|
|
|
63337
63418
|
} else {
|
|
63338
63419
|
const currentWxsDir = import_node_path8.default.dirname(wxsFilePath);
|
|
63339
63420
|
resolvedWxsPath = import_node_path8.default.resolve(currentWxsDir, requirePath);
|
|
63340
|
-
const relativePath = resolvedWxsPath.replace(workPath, "")
|
|
63421
|
+
const relativePath = stripViewScriptExt(resolvedWxsPath.replace(workPath, ""));
|
|
63341
63422
|
const depModuleName = relativePath.replace(/[\/\\@\-]/g, "_").replace(/^_/, "");
|
|
63342
63423
|
processWxsDependency(resolvedWxsPath, depModuleName, scriptModule, workPath, filePath);
|
|
63343
63424
|
replacements.push({
|
|
@@ -63553,7 +63634,7 @@ function toCompileTemplate(isComponent2, path10, components, componentPlaceholde
|
|
|
63553
63634
|
const src = $2(elem).attr("src");
|
|
63554
63635
|
if (src) {
|
|
63555
63636
|
const includeFullPath = getAbsolutePath(workPath, path10, src);
|
|
63556
|
-
let includePath = includeFullPath.replace(workPath, "").replace(
|
|
63637
|
+
let includePath = includeFullPath.replace(workPath, "").replace(buildExtStripRegex(getTemplateExts()), "");
|
|
63557
63638
|
const includeDiagnosticSource = includeFullPath.startsWith(workPath) ? includeFullPath.slice(workPath.length) : includePath;
|
|
63558
63639
|
if (!includePath.startsWith("/")) {
|
|
63559
63640
|
includePath = "/" + includePath;
|
|
@@ -63579,8 +63660,7 @@ function toCompileTemplate(isComponent2, path10, components, componentPlaceholde
|
|
|
63579
63660
|
);
|
|
63580
63661
|
processIncludedFileWxsDependencies(includeContent, includePath, scriptModule, components, processedPaths);
|
|
63581
63662
|
$includeContent("template").remove();
|
|
63582
|
-
$includeContent("
|
|
63583
|
-
$includeContent("dds").remove();
|
|
63663
|
+
$includeContent(getViewScriptTags().join(",")).remove();
|
|
63584
63664
|
const processedContent = processIncludeConditionalAttrs($2, elem, $includeContent.html());
|
|
63585
63665
|
$2(elem).replaceWith(processedContent);
|
|
63586
63666
|
} else {
|
|
@@ -63597,7 +63677,7 @@ function toCompileTemplate(isComponent2, path10, components, componentPlaceholde
|
|
|
63597
63677
|
const src = $2(elem).attr("src");
|
|
63598
63678
|
if (src) {
|
|
63599
63679
|
const importFullPath = getAbsolutePath(workPath, path10, src);
|
|
63600
|
-
let importPath = importFullPath.replace(workPath, "").replace(
|
|
63680
|
+
let importPath = importFullPath.replace(workPath, "").replace(buildExtStripRegex(getTemplateExts()), "");
|
|
63601
63681
|
const importDiagnosticSource = importFullPath.startsWith(workPath) ? importFullPath.slice(workPath.length) : importPath;
|
|
63602
63682
|
if (!importPath.startsWith("/")) {
|
|
63603
63683
|
importPath = "/" + importPath;
|
|
@@ -63644,8 +63724,7 @@ function transTagTemplate($2, templateModule, path10, components, componentPlace
|
|
|
63644
63724
|
const templateContent = $2(elem);
|
|
63645
63725
|
templateContent.find("import").remove();
|
|
63646
63726
|
templateContent.find("include").remove();
|
|
63647
|
-
templateContent.find("
|
|
63648
|
-
templateContent.find("dds").remove();
|
|
63727
|
+
templateContent.find(getViewScriptTags().join(",")).remove();
|
|
63649
63728
|
transAsses($2, templateContent.find("image"), path10);
|
|
63650
63729
|
const res = [];
|
|
63651
63730
|
transHtmlTag(templateContent.html(), res, components, componentPlaceholder);
|
|
@@ -63952,7 +64031,7 @@ function parseKeyExpression(exp, itemName = "item", indexName = "index") {
|
|
|
63952
64031
|
}
|
|
63953
64032
|
function getViewPath(workPath, src) {
|
|
63954
64033
|
const aSrc = src.startsWith("/") ? src : `/${src}`;
|
|
63955
|
-
for (const mlType of
|
|
64034
|
+
for (const mlType of getTemplateExts()) {
|
|
63956
64035
|
const mlFullPath = `${workPath}${aSrc}${mlType}`;
|
|
63957
64036
|
if (fs_default.existsSync(mlFullPath)) {
|
|
63958
64037
|
return mlFullPath;
|
|
@@ -64058,10 +64137,7 @@ function parseTemplateDataExp(exp) {
|
|
|
64058
64137
|
return `{${parseBraceExp(exp)}}`;
|
|
64059
64138
|
}
|
|
64060
64139
|
function transTagWxs($2, scriptModule, filePath) {
|
|
64061
|
-
|
|
64062
|
-
if (wxsNodes.length === 0) {
|
|
64063
|
-
wxsNodes = $2("dds");
|
|
64064
|
-
}
|
|
64140
|
+
const wxsNodes = $2(getViewScriptTags().join(","));
|
|
64065
64141
|
wxsNodes.each((_, elem) => {
|
|
64066
64142
|
const smName = $2(elem).attr("module");
|
|
64067
64143
|
if (smName) {
|
|
@@ -64080,7 +64156,7 @@ function transTagWxs($2, scriptModule, filePath) {
|
|
|
64080
64156
|
wxsFilePath = getAbsolutePath(workPath, filePath, src);
|
|
64081
64157
|
}
|
|
64082
64158
|
if (wxsFilePath) {
|
|
64083
|
-
const relativePath = wxsFilePath.replace(workPath, "")
|
|
64159
|
+
const relativePath = stripViewScriptExt(wxsFilePath.replace(workPath, ""));
|
|
64084
64160
|
uniqueModuleName = relativePath.replace(/[\/\\@\-]/g, "_").replace(/^_/, "");
|
|
64085
64161
|
cacheKey = wxsFilePath;
|
|
64086
64162
|
}
|
|
@@ -64153,12 +64229,8 @@ function collectAllWxsModules(scriptRes, collectedPaths = /* @__PURE__ */ new Se
|
|
|
64153
64229
|
return allWxsModules;
|
|
64154
64230
|
}
|
|
64155
64231
|
function loadWxsModule(modulePath, workPath, scriptModule) {
|
|
64156
|
-
if (!modulePath.startsWith("miniprogram_npm__") || !modulePath.includes("_wxs_")) {
|
|
64157
|
-
return null;
|
|
64158
|
-
}
|
|
64159
64232
|
const wxsFilePath = wxsFilePathMap.get(modulePath);
|
|
64160
64233
|
if (!wxsFilePath) {
|
|
64161
|
-
console.warn(`[view] \u65E0\u6CD5\u627E\u5230 wxs \u6A21\u5757\u6587\u4EF6: ${modulePath}`);
|
|
64162
64234
|
return null;
|
|
64163
64235
|
}
|
|
64164
64236
|
try {
|
|
@@ -64245,7 +64317,7 @@ function __resetViewState() {
|
|
|
64245
64317
|
wxsModuleRegistry.clear();
|
|
64246
64318
|
wxsFilePathMap.clear();
|
|
64247
64319
|
}
|
|
64248
|
-
var import_node_path8,
|
|
64320
|
+
var import_node_path8, compileResCache, wxsModuleRegistry, wxsFilePathMap, braceRegex, noBraceRegex, ternaryRegex;
|
|
64249
64321
|
var init_view_compiler = __esm({
|
|
64250
64322
|
"../../dimina/fe/packages/compiler/src/core/view-compiler.js"() {
|
|
64251
64323
|
init_fs();
|
|
@@ -64262,7 +64334,6 @@ var init_view_compiler = __esm({
|
|
|
64262
64334
|
init_utils();
|
|
64263
64335
|
init_env();
|
|
64264
64336
|
init_expression_parser();
|
|
64265
|
-
fileType = [".wxml", ".ddml"];
|
|
64266
64337
|
compileResCache = /* @__PURE__ */ new Map();
|
|
64267
64338
|
wxsModuleRegistry = /* @__PURE__ */ new Set();
|
|
64268
64339
|
wxsFilePathMap = /* @__PURE__ */ new Map();
|
|
@@ -281914,7 +281985,7 @@ function normalizeCssUrlValue(value, absolutePath) {
|
|
|
281914
281985
|
function getAbsolutePath2(modulePath) {
|
|
281915
281986
|
const workPath = getWorkPath();
|
|
281916
281987
|
const src = modulePath.startsWith("/") ? modulePath : `/${modulePath}`;
|
|
281917
|
-
for (const ssType of
|
|
281988
|
+
for (const ssType of getStyleExts()) {
|
|
281918
281989
|
const ssFullPath = `${workPath}${src}${ssType}`;
|
|
281919
281990
|
if (fs_default.existsSync(ssFullPath)) {
|
|
281920
281991
|
return ssFullPath;
|
|
@@ -281967,7 +282038,7 @@ function processHostSelector(selector2, moduleId) {
|
|
|
281967
282038
|
function __resetStyleState() {
|
|
281968
282039
|
compileRes.clear();
|
|
281969
282040
|
}
|
|
281970
|
-
var import_node_path9, import_autoprefixer, import_cssnano, import_postcss_selector_parser,
|
|
282041
|
+
var import_node_path9, import_autoprefixer, import_cssnano, import_postcss_selector_parser, compileRes;
|
|
281971
282042
|
var init_style_compiler = __esm({
|
|
281972
282043
|
"../../dimina/fe/packages/compiler/src/core/style-compiler.js"() {
|
|
281973
282044
|
init_fs();
|
|
@@ -281982,7 +282053,6 @@ var init_style_compiler = __esm({
|
|
|
281982
282053
|
init_sass_default();
|
|
281983
282054
|
init_utils();
|
|
281984
282055
|
init_env();
|
|
281985
|
-
fileType2 = [".wxss", ".ddss", ".less", ".scss", ".sass"];
|
|
281986
282056
|
compileRes = /* @__PURE__ */ new Map();
|
|
281987
282057
|
if (!isMainThread) {
|
|
281988
282058
|
parentPort.on("message", async ({ pages, storeInfo: storeInfo2 }) => {
|
|
@@ -282078,6 +282148,7 @@ var config_compiler_default = compileConfig;
|
|
|
282078
282148
|
// ../../dimina/fe/packages/compiler/src/common/npm-builder.js
|
|
282079
282149
|
init_fs();
|
|
282080
282150
|
var import_node_path6 = __toESM(require_path_browserify(), 1);
|
|
282151
|
+
init_env();
|
|
282081
282152
|
var NpmBuilder = class {
|
|
282082
282153
|
constructor(workPath, targetPath) {
|
|
282083
282154
|
this.workPath = workPath;
|
|
@@ -282185,7 +282256,7 @@ var NpmBuilder = class {
|
|
|
282185
282256
|
* @returns {boolean} 是否为小程序文件
|
|
282186
282257
|
*/
|
|
282187
282258
|
isMiniprogramFile(filename) {
|
|
282188
|
-
const miniprogramExts = [".js", ".json", ".
|
|
282259
|
+
const miniprogramExts = [".js", ".json", ".ts", ...getTemplateExts(), ...getStyleExts(), ...getViewScriptExts()];
|
|
282189
282260
|
const ext = import_node_path6.default.extname(filename).toLowerCase();
|
|
282190
282261
|
return miniprogramExts.includes(ext) || filename === "package.json" || filename === "README.md" || filename.startsWith(".");
|
|
282191
282262
|
}
|
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,
|