@dimina-kit/compiler 0.0.1-dev.20260706125036 → 0.0.1-dev.20260706154125

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.
@@ -989,23 +989,81 @@ var init_npm_resolver = __esm({
989
989
  });
990
990
 
991
991
  // ../../dimina/fe/packages/compiler/src/env.js
992
- function storeInfo(workPath) {
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
- }, compilerOptions), {
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
- }, compilerOptions), {
31223
+ }, compilerOptions2), {
31152
31224
  hmr: !isProd,
31153
- nodeTransforms: nodeTransforms.concat(compilerOptions.nodeTransforms || []),
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(".wxs")) {
63099
- const relativePath = fullPath.replace(workPath, "").replace(/\.wxs$/, "");
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, "").replace(/\.wxs$/, "");
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, "").replace(/\.wxs$/, "");
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(/\.(wxml|ddml)$/, "");
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("wxs").remove();
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(/\.(wxml|ddml)$/, "");
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("wxs").remove();
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 fileType) {
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
- let wxsNodes = $2("wxs");
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, "").replace(/\.wxs$/, "");
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, fileType, compileResCache, wxsModuleRegistry, wxsFilePathMap, braceRegex, noBraceRegex, ternaryRegex;
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();
@@ -93871,9 +93942,9 @@ var require_release_schedule2 = __commonJS({
93871
93942
  }
93872
93943
  });
93873
93944
 
93874
- // ../../dimina/fe/node_modules/.pnpm/browserslist@4.28.4/node_modules/browserslist/error.js
93945
+ // ../../dimina/fe/node_modules/.pnpm/browserslist@4.28.5/node_modules/browserslist/error.js
93875
93946
  var require_error2 = __commonJS({
93876
- "../../dimina/fe/node_modules/.pnpm/browserslist@4.28.4/node_modules/browserslist/error.js"(exports, module) {
93947
+ "../../dimina/fe/node_modules/.pnpm/browserslist@4.28.5/node_modules/browserslist/error.js"(exports, module) {
93877
93948
  function BrowserslistError(message) {
93878
93949
  this.name = "BrowserslistError";
93879
93950
  this.message = message;
@@ -93887,9 +93958,9 @@ var require_error2 = __commonJS({
93887
93958
  }
93888
93959
  });
93889
93960
 
93890
- // ../../dimina/fe/node_modules/.pnpm/browserslist@4.28.4/node_modules/browserslist/browser.js
93961
+ // ../../dimina/fe/node_modules/.pnpm/browserslist@4.28.5/node_modules/browserslist/browser.js
93891
93962
  var require_browser3 = __commonJS({
93892
- "../../dimina/fe/node_modules/.pnpm/browserslist@4.28.4/node_modules/browserslist/browser.js"(exports, module) {
93963
+ "../../dimina/fe/node_modules/.pnpm/browserslist@4.28.5/node_modules/browserslist/browser.js"(exports, module) {
93893
93964
  var BrowserslistError = require_error2();
93894
93965
  function noop2() {
93895
93966
  }
@@ -93933,9 +94004,9 @@ var require_browser3 = __commonJS({
93933
94004
  }
93934
94005
  });
93935
94006
 
93936
- // ../../dimina/fe/node_modules/.pnpm/browserslist@4.28.4/node_modules/browserslist/parse.js
94007
+ // ../../dimina/fe/node_modules/.pnpm/browserslist@4.28.5/node_modules/browserslist/parse.js
93937
94008
  var require_parse6 = __commonJS({
93938
- "../../dimina/fe/node_modules/.pnpm/browserslist@4.28.4/node_modules/browserslist/parse.js"(exports, module) {
94009
+ "../../dimina/fe/node_modules/.pnpm/browserslist@4.28.5/node_modules/browserslist/parse.js"(exports, module) {
93939
94010
  var AND_REGEXP = /^\s+and\s+(.*)/i;
93940
94011
  var OR_REGEXP = /^(?:,\s*|\s+or\s+)(.*)/i;
93941
94012
  function flatten3(array) {
@@ -94010,9 +94081,9 @@ var require_parse6 = __commonJS({
94010
94081
  }
94011
94082
  });
94012
94083
 
94013
- // ../../dimina/fe/node_modules/.pnpm/browserslist@4.28.4/node_modules/browserslist/index.js
94084
+ // ../../dimina/fe/node_modules/.pnpm/browserslist@4.28.5/node_modules/browserslist/index.js
94014
94085
  var require_browserslist2 = __commonJS({
94015
- "../../dimina/fe/node_modules/.pnpm/browserslist@4.28.4/node_modules/browserslist/index.js"(exports, module) {
94086
+ "../../dimina/fe/node_modules/.pnpm/browserslist@4.28.5/node_modules/browserslist/index.js"(exports, module) {
94016
94087
  var bbm = require_dist3();
94017
94088
  var jsReleases = require_envs2();
94018
94089
  var agents = require_agents4().agents;
@@ -94082,22 +94153,21 @@ var require_browserslist2 = __commonJS({
94082
94153
  }
94083
94154
  }
94084
94155
  function generateFilter(sign, version3) {
94085
- version3 = parseFloat(version3);
94086
94156
  if (sign === ">") {
94087
94157
  return function(v) {
94088
- return parseLatestFloat(v) > version3;
94158
+ return parseLatestFloat(v) > parseLatestFloat(version3);
94089
94159
  };
94090
94160
  } else if (sign === ">=") {
94091
94161
  return function(v) {
94092
- return parseLatestFloat(v) >= version3;
94162
+ return parseLatestFloat(v) >= parseLatestFloat(version3);
94093
94163
  };
94094
94164
  } else if (sign === "<") {
94095
94165
  return function(v) {
94096
- return parseFloat(v) < version3;
94166
+ return parseFloat(v) < parseFloat(version3);
94097
94167
  };
94098
94168
  } else {
94099
94169
  return function(v) {
94100
- return parseFloat(v) <= version3;
94170
+ return parseFloat(v) <= parseFloat(version3);
94101
94171
  };
94102
94172
  }
94103
94173
  function parseLatestFloat(v) {
@@ -281914,7 +281984,7 @@ function normalizeCssUrlValue(value, absolutePath) {
281914
281984
  function getAbsolutePath2(modulePath) {
281915
281985
  const workPath = getWorkPath();
281916
281986
  const src = modulePath.startsWith("/") ? modulePath : `/${modulePath}`;
281917
- for (const ssType of fileType2) {
281987
+ for (const ssType of getStyleExts()) {
281918
281988
  const ssFullPath = `${workPath}${src}${ssType}`;
281919
281989
  if (fs_default.existsSync(ssFullPath)) {
281920
281990
  return ssFullPath;
@@ -281967,7 +282037,7 @@ function processHostSelector(selector2, moduleId) {
281967
282037
  function __resetStyleState() {
281968
282038
  compileRes.clear();
281969
282039
  }
281970
- var import_node_path9, import_autoprefixer, import_cssnano, import_postcss_selector_parser, fileType2, compileRes;
282040
+ var import_node_path9, import_autoprefixer, import_cssnano, import_postcss_selector_parser, compileRes;
281971
282041
  var init_style_compiler = __esm({
281972
282042
  "../../dimina/fe/packages/compiler/src/core/style-compiler.js"() {
281973
282043
  init_fs();
@@ -281982,7 +282052,6 @@ var init_style_compiler = __esm({
281982
282052
  init_sass_default();
281983
282053
  init_utils();
281984
282054
  init_env();
281985
- fileType2 = [".wxss", ".ddss", ".less", ".scss", ".sass"];
281986
282055
  compileRes = /* @__PURE__ */ new Map();
281987
282056
  if (!isMainThread) {
281988
282057
  parentPort.on("message", async ({ pages, storeInfo: storeInfo2 }) => {
@@ -282078,6 +282147,7 @@ var config_compiler_default = compileConfig;
282078
282147
  // ../../dimina/fe/packages/compiler/src/common/npm-builder.js
282079
282148
  init_fs();
282080
282149
  var import_node_path6 = __toESM(require_path_browserify(), 1);
282150
+ init_env();
282081
282151
  var NpmBuilder = class {
282082
282152
  constructor(workPath, targetPath) {
282083
282153
  this.workPath = workPath;
@@ -282185,7 +282255,7 @@ var NpmBuilder = class {
282185
282255
  * @returns {boolean} 是否为小程序文件
282186
282256
  */
282187
282257
  isMiniprogramFile(filename) {
282188
- const miniprogramExts = [".js", ".json", ".wxml", ".wxss", ".wxs", ".ts", ".less", ".scss", ".styl"];
282258
+ const miniprogramExts = [".js", ".json", ".ts", ...getTemplateExts(), ...getStyleExts(), ...getViewScriptExts()];
282189
282259
  const ext = import_node_path6.default.extname(filename).toLowerCase();
282190
282260
  return miniprogramExts.includes(ext) || filename === "package.json" || filename === "README.md" || filename.startsWith(".");
282191
282261
  }
@@ -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
- function storeInfo(workPath) {
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,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  getWxMemberName,
3
3
  warnUnsupportedWxApi
4
- } from "./chunk-CCZB2BJG.js";
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-5ND5V2SC.js";
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";
@@ -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-5ND5V2SC.js";
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 fileType) {
215
+ for (const ssType of getStyleExts()) {
216
216
  const ssFullPath = `${workPath}${src}${ssType}`;
217
217
  if (fs_default.existsSync(ssFullPath)) {
218
218
  return ssFullPath;