@dimina-kit/compiler 0.0.1-dev.20260706064107 → 0.0.1

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,81 +989,23 @@ var init_npm_resolver = __esm({
989
989
  });
990
990
 
991
991
  // ../../dimina/fe/packages/compiler/src/env.js
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 = {}) {
992
+ function storeInfo(workPath) {
1036
993
  storePathInfo(workPath);
1037
994
  storeProjectConfig();
1038
995
  storeAppConfig();
1039
996
  storePageConfig();
1040
- compilerOptions = normalizeFileTypes(options.fileTypes);
1041
997
  return {
1042
998
  pathInfo,
1043
- configInfo,
1044
- compilerOptions
999
+ configInfo
1045
1000
  };
1046
1001
  }
1047
1002
  function resetStoreInfo(opts) {
1048
1003
  pathInfo = opts.pathInfo;
1049
1004
  configInfo = opts.configInfo;
1050
- compilerOptions = opts.compilerOptions || normalizeFileTypes();
1051
1005
  if (pathInfo.workPath) {
1052
1006
  npmResolver = new NpmResolver(pathInfo.workPath);
1053
1007
  }
1054
1008
  }
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
- }
1067
1009
  function storePathInfo(workPath) {
1068
1010
  pathInfo.workPath = workPath;
1069
1011
  if (process_default.env.TARGET_PATH) {
@@ -1301,7 +1243,7 @@ function getPages() {
1301
1243
  subPages
1302
1244
  };
1303
1245
  }
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;
1246
+ var import_node_path4, pathInfo, configInfo, npmResolver;
1305
1247
  var init_env = __esm({
1306
1248
  "../../dimina/fe/packages/compiler/src/env.js"() {
1307
1249
  init_fs();
@@ -1314,19 +1256,6 @@ var init_env = __esm({
1314
1256
  pathInfo = {};
1315
1257
  configInfo = {};
1316
1258
  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();
1330
1259
  }
1331
1260
  });
1332
1261
 
@@ -4740,7 +4669,7 @@ function warnUnsupportedWxApi(apiName, filePath, line) {
4740
4669
  }
4741
4670
  function warnUnsupportedComponent(tagName, filePath, line) {
4742
4671
  const { supportedBuiltinComponents: supportedBuiltinComponents2 } = loadReference();
4743
- if (!tagName || supportedBuiltinComponents2.has(tagName) || getViewScriptTags().includes(tagName)) {
4672
+ if (!tagName || supportedBuiltinComponents2.has(tagName)) {
4744
4673
  return;
4745
4674
  }
4746
4675
  const location = formatLocation(filePath, line);
@@ -4801,7 +4730,6 @@ var cachedReference, warnedItems;
4801
4730
  var init_compatibility = __esm({
4802
4731
  "../../dimina/fe/packages/compiler/src/common/compatibility.js"() {
4803
4732
  init_dist3();
4804
- init_env();
4805
4733
  init_compatibility_reference();
4806
4734
  cachedReference = null;
4807
4735
  warnedItems = /* @__PURE__ */ new Set();
@@ -31168,7 +31096,7 @@ function doCompileTemplate({
31168
31096
  ssrCssVars,
31169
31097
  isProd = false,
31170
31098
  compiler,
31171
- compilerOptions: compilerOptions2 = {},
31099
+ compilerOptions = {},
31172
31100
  transformAssetUrls
31173
31101
  }) {
31174
31102
  const errors2 = [];
@@ -31202,7 +31130,7 @@ function doCompileTemplate({
31202
31130
  if (inAST == null ? void 0 : inAST.transformed) {
31203
31131
  const newAST = (ssr ? CompilerDOM : compiler).parse(inAST.source, __spreadProps$5(__spreadValues$6({
31204
31132
  prefixIdentifiers: true
31205
- }, compilerOptions2), {
31133
+ }, compilerOptions), {
31206
31134
  parseMode: "sfc",
31207
31135
  onError: (e) => errors2.push(e)
31208
31136
  }));
@@ -31220,9 +31148,9 @@ function doCompileTemplate({
31220
31148
  scopeId: scoped ? longId : void 0,
31221
31149
  slotted,
31222
31150
  sourceMap: true
31223
- }, compilerOptions2), {
31151
+ }, compilerOptions), {
31224
31152
  hmr: !isProd,
31225
- nodeTransforms: nodeTransforms.concat(compilerOptions2.nodeTransforms || []),
31153
+ nodeTransforms: nodeTransforms.concat(compilerOptions.nodeTransforms || []),
31226
31154
  filename,
31227
31155
  onError: (e) => errors2.push(e),
31228
31156
  onWarn: (w) => warnings.push(w)
@@ -62994,8 +62922,6 @@ __export(view_compiler_exports, {
62994
62922
  compileML: () => compileML,
62995
62923
  generateSlotDirective: () => generateSlotDirective,
62996
62924
  generateVModelTemplate: () => generateVModelTemplate,
62997
- initWxsFilePathMap: () => initWxsFilePathMap,
62998
- loadWxsModule: () => loadWxsModule,
62999
62925
  parseBraceExp: () => parseBraceExp,
63000
62926
  parseClassRules: () => parseClassRules,
63001
62927
  parseKeyExpression: () => parseKeyExpression,
@@ -63004,13 +62930,6 @@ __export(view_compiler_exports, {
63004
62930
  processWxsContent: () => processWxsContent,
63005
62931
  splitWithBraces: () => splitWithBraces
63006
62932
  });
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
- }
63014
62933
  function parseJs(code, filename = "view-compiler.js", sourceType = "module") {
63015
62934
  return parseSync(filename, code, {
63016
62935
  sourceType,
@@ -63176,8 +63095,8 @@ function scanWxsFiles(dir, workPath) {
63176
63095
  const stat2 = fs_default.statSync(fullPath);
63177
63096
  if (stat2.isDirectory()) {
63178
63097
  scanWxsFiles(fullPath, workPath);
63179
- } else if (stat2.isFile() && getViewScriptExts().some((ext) => item.endsWith(ext))) {
63180
- const relativePath = stripViewScriptExt(fullPath.replace(workPath, ""));
63098
+ } else if (stat2.isFile() && item.endsWith(".wxs")) {
63099
+ const relativePath = fullPath.replace(workPath, "").replace(/\.wxs$/, "");
63181
63100
  const moduleName = relativePath.replace(/[\/\\@\-]/g, "_").replace(/^_/, "");
63182
63101
  wxsFilePathMap.set(moduleName, fullPath);
63183
63102
  }
@@ -63407,7 +63326,7 @@ function processWxsContent(wxsContent, wxsFilePath, scriptModule, workPath, file
63407
63326
  if (filePath && filePath.includes("/miniprogram_npm/")) {
63408
63327
  const currentWxsDir = import_node_path8.default.dirname(wxsFilePath);
63409
63328
  resolvedWxsPath = import_node_path8.default.resolve(currentWxsDir, requirePath);
63410
- const relativePath = stripViewScriptExt(resolvedWxsPath.replace(workPath, ""));
63329
+ const relativePath = resolvedWxsPath.replace(workPath, "").replace(/\.wxs$/, "");
63411
63330
  const moduleName = relativePath.replace(/[\/\\@\-]/g, "_").replace(/^_/, "");
63412
63331
  processWxsDependency(resolvedWxsPath, moduleName, scriptModule, workPath, filePath);
63413
63332
  replacements.push({
@@ -63418,7 +63337,7 @@ function processWxsContent(wxsContent, wxsFilePath, scriptModule, workPath, file
63418
63337
  } else {
63419
63338
  const currentWxsDir = import_node_path8.default.dirname(wxsFilePath);
63420
63339
  resolvedWxsPath = import_node_path8.default.resolve(currentWxsDir, requirePath);
63421
- const relativePath = stripViewScriptExt(resolvedWxsPath.replace(workPath, ""));
63340
+ const relativePath = resolvedWxsPath.replace(workPath, "").replace(/\.wxs$/, "");
63422
63341
  const depModuleName = relativePath.replace(/[\/\\@\-]/g, "_").replace(/^_/, "");
63423
63342
  processWxsDependency(resolvedWxsPath, depModuleName, scriptModule, workPath, filePath);
63424
63343
  replacements.push({
@@ -63634,7 +63553,7 @@ function toCompileTemplate(isComponent2, path10, components, componentPlaceholde
63634
63553
  const src = $2(elem).attr("src");
63635
63554
  if (src) {
63636
63555
  const includeFullPath = getAbsolutePath(workPath, path10, src);
63637
- let includePath = includeFullPath.replace(workPath, "").replace(buildExtStripRegex(getTemplateExts()), "");
63556
+ let includePath = includeFullPath.replace(workPath, "").replace(/\.(wxml|ddml)$/, "");
63638
63557
  const includeDiagnosticSource = includeFullPath.startsWith(workPath) ? includeFullPath.slice(workPath.length) : includePath;
63639
63558
  if (!includePath.startsWith("/")) {
63640
63559
  includePath = "/" + includePath;
@@ -63660,7 +63579,8 @@ function toCompileTemplate(isComponent2, path10, components, componentPlaceholde
63660
63579
  );
63661
63580
  processIncludedFileWxsDependencies(includeContent, includePath, scriptModule, components, processedPaths);
63662
63581
  $includeContent("template").remove();
63663
- $includeContent(getViewScriptTags().join(",")).remove();
63582
+ $includeContent("wxs").remove();
63583
+ $includeContent("dds").remove();
63664
63584
  const processedContent = processIncludeConditionalAttrs($2, elem, $includeContent.html());
63665
63585
  $2(elem).replaceWith(processedContent);
63666
63586
  } else {
@@ -63677,7 +63597,7 @@ function toCompileTemplate(isComponent2, path10, components, componentPlaceholde
63677
63597
  const src = $2(elem).attr("src");
63678
63598
  if (src) {
63679
63599
  const importFullPath = getAbsolutePath(workPath, path10, src);
63680
- let importPath = importFullPath.replace(workPath, "").replace(buildExtStripRegex(getTemplateExts()), "");
63600
+ let importPath = importFullPath.replace(workPath, "").replace(/\.(wxml|ddml)$/, "");
63681
63601
  const importDiagnosticSource = importFullPath.startsWith(workPath) ? importFullPath.slice(workPath.length) : importPath;
63682
63602
  if (!importPath.startsWith("/")) {
63683
63603
  importPath = "/" + importPath;
@@ -63724,7 +63644,8 @@ function transTagTemplate($2, templateModule, path10, components, componentPlace
63724
63644
  const templateContent = $2(elem);
63725
63645
  templateContent.find("import").remove();
63726
63646
  templateContent.find("include").remove();
63727
- templateContent.find(getViewScriptTags().join(",")).remove();
63647
+ templateContent.find("wxs").remove();
63648
+ templateContent.find("dds").remove();
63728
63649
  transAsses($2, templateContent.find("image"), path10);
63729
63650
  const res = [];
63730
63651
  transHtmlTag(templateContent.html(), res, components, componentPlaceholder);
@@ -64031,7 +63952,7 @@ function parseKeyExpression(exp, itemName = "item", indexName = "index") {
64031
63952
  }
64032
63953
  function getViewPath(workPath, src) {
64033
63954
  const aSrc = src.startsWith("/") ? src : `/${src}`;
64034
- for (const mlType of getTemplateExts()) {
63955
+ for (const mlType of fileType) {
64035
63956
  const mlFullPath = `${workPath}${aSrc}${mlType}`;
64036
63957
  if (fs_default.existsSync(mlFullPath)) {
64037
63958
  return mlFullPath;
@@ -64137,7 +64058,10 @@ function parseTemplateDataExp(exp) {
64137
64058
  return `{${parseBraceExp(exp)}}`;
64138
64059
  }
64139
64060
  function transTagWxs($2, scriptModule, filePath) {
64140
- const wxsNodes = $2(getViewScriptTags().join(","));
64061
+ let wxsNodes = $2("wxs");
64062
+ if (wxsNodes.length === 0) {
64063
+ wxsNodes = $2("dds");
64064
+ }
64141
64065
  wxsNodes.each((_, elem) => {
64142
64066
  const smName = $2(elem).attr("module");
64143
64067
  if (smName) {
@@ -64156,7 +64080,7 @@ function transTagWxs($2, scriptModule, filePath) {
64156
64080
  wxsFilePath = getAbsolutePath(workPath, filePath, src);
64157
64081
  }
64158
64082
  if (wxsFilePath) {
64159
- const relativePath = stripViewScriptExt(wxsFilePath.replace(workPath, ""));
64083
+ const relativePath = wxsFilePath.replace(workPath, "").replace(/\.wxs$/, "");
64160
64084
  uniqueModuleName = relativePath.replace(/[\/\\@\-]/g, "_").replace(/^_/, "");
64161
64085
  cacheKey = wxsFilePath;
64162
64086
  }
@@ -64229,8 +64153,12 @@ function collectAllWxsModules(scriptRes, collectedPaths = /* @__PURE__ */ new Se
64229
64153
  return allWxsModules;
64230
64154
  }
64231
64155
  function loadWxsModule(modulePath, workPath, scriptModule) {
64156
+ if (!modulePath.startsWith("miniprogram_npm__") || !modulePath.includes("_wxs_")) {
64157
+ return null;
64158
+ }
64232
64159
  const wxsFilePath = wxsFilePathMap.get(modulePath);
64233
64160
  if (!wxsFilePath) {
64161
+ console.warn(`[view] \u65E0\u6CD5\u627E\u5230 wxs \u6A21\u5757\u6587\u4EF6: ${modulePath}`);
64234
64162
  return null;
64235
64163
  }
64236
64164
  try {
@@ -64317,7 +64245,7 @@ function __resetViewState() {
64317
64245
  wxsModuleRegistry.clear();
64318
64246
  wxsFilePathMap.clear();
64319
64247
  }
64320
- var import_node_path8, compileResCache, wxsModuleRegistry, wxsFilePathMap, braceRegex, noBraceRegex, ternaryRegex;
64248
+ var import_node_path8, fileType, compileResCache, wxsModuleRegistry, wxsFilePathMap, braceRegex, noBraceRegex, ternaryRegex;
64321
64249
  var init_view_compiler = __esm({
64322
64250
  "../../dimina/fe/packages/compiler/src/core/view-compiler.js"() {
64323
64251
  init_fs();
@@ -64334,6 +64262,7 @@ var init_view_compiler = __esm({
64334
64262
  init_utils();
64335
64263
  init_env();
64336
64264
  init_expression_parser();
64265
+ fileType = [".wxml", ".ddml"];
64337
64266
  compileResCache = /* @__PURE__ */ new Map();
64338
64267
  wxsModuleRegistry = /* @__PURE__ */ new Set();
64339
64268
  wxsFilePathMap = /* @__PURE__ */ new Map();
@@ -281985,7 +281914,7 @@ function normalizeCssUrlValue(value, absolutePath) {
281985
281914
  function getAbsolutePath2(modulePath) {
281986
281915
  const workPath = getWorkPath();
281987
281916
  const src = modulePath.startsWith("/") ? modulePath : `/${modulePath}`;
281988
- for (const ssType of getStyleExts()) {
281917
+ for (const ssType of fileType2) {
281989
281918
  const ssFullPath = `${workPath}${src}${ssType}`;
281990
281919
  if (fs_default.existsSync(ssFullPath)) {
281991
281920
  return ssFullPath;
@@ -282038,7 +281967,7 @@ function processHostSelector(selector2, moduleId) {
282038
281967
  function __resetStyleState() {
282039
281968
  compileRes.clear();
282040
281969
  }
282041
- var import_node_path9, import_autoprefixer, import_cssnano, import_postcss_selector_parser, compileRes;
281970
+ var import_node_path9, import_autoprefixer, import_cssnano, import_postcss_selector_parser, fileType2, compileRes;
282042
281971
  var init_style_compiler = __esm({
282043
281972
  "../../dimina/fe/packages/compiler/src/core/style-compiler.js"() {
282044
281973
  init_fs();
@@ -282053,6 +281982,7 @@ var init_style_compiler = __esm({
282053
281982
  init_sass_default();
282054
281983
  init_utils();
282055
281984
  init_env();
281985
+ fileType2 = [".wxss", ".ddss", ".less", ".scss", ".sass"];
282056
281986
  compileRes = /* @__PURE__ */ new Map();
282057
281987
  if (!isMainThread) {
282058
281988
  parentPort.on("message", async ({ pages, storeInfo: storeInfo2 }) => {
@@ -282148,7 +282078,6 @@ var config_compiler_default = compileConfig;
282148
282078
  // ../../dimina/fe/packages/compiler/src/common/npm-builder.js
282149
282079
  init_fs();
282150
282080
  var import_node_path6 = __toESM(require_path_browserify(), 1);
282151
- init_env();
282152
282081
  var NpmBuilder = class {
282153
282082
  constructor(workPath, targetPath) {
282154
282083
  this.workPath = workPath;
@@ -282256,7 +282185,7 @@ var NpmBuilder = class {
282256
282185
  * @returns {boolean} 是否为小程序文件
282257
282186
  */
282258
282187
  isMiniprogramFile(filename) {
282259
- const miniprogramExts = [".js", ".json", ".ts", ...getTemplateExts(), ...getStyleExts(), ...getViewScriptExts()];
282188
+ const miniprogramExts = [".js", ".json", ".wxml", ".wxss", ".wxs", ".ts", ".less", ".scss", ".styl"];
282260
282189
  const ext = import_node_path6.default.extname(filename).toLowerCase();
282261
282190
  return miniprogramExts.includes(ext) || filename === "package.json" || filename === "README.md" || filename.startsWith(".");
282262
282191
  }
@@ -425,94 +425,23 @@ var NpmResolver = class {
425
425
  var pathInfo = {};
426
426
  var configInfo = {};
427
427
  var npmResolver = null;
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 = {}) {
428
+ function storeInfo(workPath) {
485
429
  storePathInfo(workPath);
486
430
  storeProjectConfig();
487
431
  storeAppConfig();
488
432
  storePageConfig();
489
- compilerOptions = normalizeFileTypes(options.fileTypes);
490
433
  return {
491
434
  pathInfo,
492
- configInfo,
493
- compilerOptions
435
+ configInfo
494
436
  };
495
437
  }
496
438
  function resetStoreInfo(opts) {
497
439
  pathInfo = opts.pathInfo;
498
440
  configInfo = opts.configInfo;
499
- compilerOptions = opts.compilerOptions || normalizeFileTypes();
500
441
  if (pathInfo.workPath) {
501
442
  npmResolver = new NpmResolver(pathInfo.workPath);
502
443
  }
503
444
  }
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
- }
516
445
  function storePathInfo(workPath) {
517
446
  pathInfo.workPath = workPath;
518
447
  if (process2.env.TARGET_PATH) {
@@ -763,10 +692,6 @@ export {
763
692
  __resetAssets,
764
693
  storeInfo,
765
694
  resetStoreInfo,
766
- getTemplateExts,
767
- getStyleExts,
768
- getViewScriptExts,
769
- getViewScriptTags,
770
695
  getContentByPath,
771
696
  resolveAppAlias,
772
697
  getTargetPath,
@@ -1,7 +1,3 @@
1
- import {
2
- getViewScriptTags
3
- } from "./chunk-QJ34C5KK.js";
4
-
5
1
  // ../../dimina/fe/packages/compiler/src/common/compatibility.js
6
2
  import { Parser } from "htmlparser2";
7
3
 
@@ -146,7 +142,7 @@ function warnUnsupportedWxApi(apiName, filePath, line) {
146
142
  }
147
143
  function warnUnsupportedComponent(tagName, filePath, line) {
148
144
  const { supportedBuiltinComponents: supportedBuiltinComponents2 } = loadReference();
149
- if (!tagName || supportedBuiltinComponents2.has(tagName) || getViewScriptTags().includes(tagName)) {
145
+ if (!tagName || supportedBuiltinComponents2.has(tagName)) {
150
146
  return;
151
147
  }
152
148
  const location = formatLocation(filePath, line);
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  getWxMemberName,
3
3
  warnUnsupportedWxApi
4
- } from "./chunk-LUD2P6RM.js";
4
+ } from "./chunk-CCZB2BJG.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-QJ34C5KK.js";
22
+ } from "./chunk-5ND5V2SC.js";
23
23
 
24
24
  // ../../dimina/fe/packages/compiler/src/core/logic-compiler.js
25
25
  import { resolve, sep } from "node:path";
@@ -8,13 +8,12 @@ import {
8
8
  getAppId,
9
9
  getComponent,
10
10
  getContentByPath,
11
- getStyleExts,
12
11
  getTargetPath,
13
12
  getWorkPath,
14
13
  resetStoreInfo,
15
14
  tagWhiteList,
16
15
  transformRpx
17
- } from "./chunk-QJ34C5KK.js";
16
+ } from "./chunk-5ND5V2SC.js";
18
17
 
19
18
  // ../../dimina/fe/packages/compiler/src/core/style-compiler.js
20
19
  import path from "node:path";
@@ -25,6 +24,7 @@ import less from "less";
25
24
  import postcss from "postcss";
26
25
  import selectorParser from "postcss-selector-parser";
27
26
  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 getStyleExts()) {
215
+ for (const ssType of fileType) {
216
216
  const ssFullPath = `${workPath}${src}${ssType}`;
217
217
  if (fs_default.existsSync(ssFullPath)) {
218
218
  return ssFullPath;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  checkTemplateCompatibility
3
- } from "./chunk-LUD2P6RM.js";
3
+ } from "./chunk-CCZB2BJG.js";
4
4
  import {
5
5
  isMainThread,
6
6
  parentPort
@@ -13,14 +13,11 @@ import {
13
13
  getComponent,
14
14
  getContentByPath,
15
15
  getTargetPath,
16
- getTemplateExts,
17
- getViewScriptExts,
18
- getViewScriptTags,
19
16
  getWorkPath,
20
17
  resetStoreInfo,
21
18
  tagWhiteList,
22
19
  transformRpx
23
- } from "./chunk-QJ34C5KK.js";
20
+ } from "./chunk-5ND5V2SC.js";
24
21
 
25
22
  // ../../dimina/fe/packages/compiler/src/core/view-compiler.js
26
23
  import path from "node:path";
@@ -155,13 +152,7 @@ function parseBindings(bindings) {
155
152
  }
156
153
 
157
154
  // ../../dimina/fe/packages/compiler/src/core/view-compiler.js
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
- }
155
+ var fileType = [".wxml", ".ddml"];
165
156
  function parseJs(code, filename = "view-compiler.js", sourceType = "module") {
166
157
  return parseSync2(filename, code, {
167
158
  sourceType,
@@ -367,8 +358,8 @@ function scanWxsFiles(dir, workPath) {
367
358
  const stat = fs_default.statSync(fullPath);
368
359
  if (stat.isDirectory()) {
369
360
  scanWxsFiles(fullPath, workPath);
370
- } else if (stat.isFile() && getViewScriptExts().some((ext) => item.endsWith(ext))) {
371
- const relativePath = stripViewScriptExt(fullPath.replace(workPath, ""));
361
+ } else if (stat.isFile() && item.endsWith(".wxs")) {
362
+ const relativePath = fullPath.replace(workPath, "").replace(/\.wxs$/, "");
372
363
  const moduleName = relativePath.replace(/[\/\\@\-]/g, "_").replace(/^_/, "");
373
364
  wxsFilePathMap.set(moduleName, fullPath);
374
365
  }
@@ -598,7 +589,7 @@ function processWxsContent(wxsContent, wxsFilePath, scriptModule, workPath, file
598
589
  if (filePath && filePath.includes("/miniprogram_npm/")) {
599
590
  const currentWxsDir = path.dirname(wxsFilePath);
600
591
  resolvedWxsPath = path.resolve(currentWxsDir, requirePath);
601
- const relativePath = stripViewScriptExt(resolvedWxsPath.replace(workPath, ""));
592
+ const relativePath = resolvedWxsPath.replace(workPath, "").replace(/\.wxs$/, "");
602
593
  const moduleName = relativePath.replace(/[\/\\@\-]/g, "_").replace(/^_/, "");
603
594
  processWxsDependency(resolvedWxsPath, moduleName, scriptModule, workPath, filePath);
604
595
  replacements.push({
@@ -609,7 +600,7 @@ function processWxsContent(wxsContent, wxsFilePath, scriptModule, workPath, file
609
600
  } else {
610
601
  const currentWxsDir = path.dirname(wxsFilePath);
611
602
  resolvedWxsPath = path.resolve(currentWxsDir, requirePath);
612
- const relativePath = stripViewScriptExt(resolvedWxsPath.replace(workPath, ""));
603
+ const relativePath = resolvedWxsPath.replace(workPath, "").replace(/\.wxs$/, "");
613
604
  const depModuleName = relativePath.replace(/[\/\\@\-]/g, "_").replace(/^_/, "");
614
605
  processWxsDependency(resolvedWxsPath, depModuleName, scriptModule, workPath, filePath);
615
606
  replacements.push({
@@ -825,7 +816,7 @@ function toCompileTemplate(isComponent, path2, components, componentPlaceholder,
825
816
  const src = $(elem).attr("src");
826
817
  if (src) {
827
818
  const includeFullPath = getAbsolutePath(workPath, path2, src);
828
- let includePath = includeFullPath.replace(workPath, "").replace(buildExtStripRegex(getTemplateExts()), "");
819
+ let includePath = includeFullPath.replace(workPath, "").replace(/\.(wxml|ddml)$/, "");
829
820
  const includeDiagnosticSource = includeFullPath.startsWith(workPath) ? includeFullPath.slice(workPath.length) : includePath;
830
821
  if (!includePath.startsWith("/")) {
831
822
  includePath = "/" + includePath;
@@ -851,7 +842,8 @@ function toCompileTemplate(isComponent, path2, components, componentPlaceholder,
851
842
  );
852
843
  processIncludedFileWxsDependencies(includeContent, includePath, scriptModule, components, processedPaths);
853
844
  $includeContent("template").remove();
854
- $includeContent(getViewScriptTags().join(",")).remove();
845
+ $includeContent("wxs").remove();
846
+ $includeContent("dds").remove();
855
847
  const processedContent = processIncludeConditionalAttrs($, elem, $includeContent.html());
856
848
  $(elem).replaceWith(processedContent);
857
849
  } else {
@@ -868,7 +860,7 @@ function toCompileTemplate(isComponent, path2, components, componentPlaceholder,
868
860
  const src = $(elem).attr("src");
869
861
  if (src) {
870
862
  const importFullPath = getAbsolutePath(workPath, path2, src);
871
- let importPath = importFullPath.replace(workPath, "").replace(buildExtStripRegex(getTemplateExts()), "");
863
+ let importPath = importFullPath.replace(workPath, "").replace(/\.(wxml|ddml)$/, "");
872
864
  const importDiagnosticSource = importFullPath.startsWith(workPath) ? importFullPath.slice(workPath.length) : importPath;
873
865
  if (!importPath.startsWith("/")) {
874
866
  importPath = "/" + importPath;
@@ -915,7 +907,8 @@ function transTagTemplate($, templateModule, path2, components, componentPlaceho
915
907
  const templateContent = $(elem);
916
908
  templateContent.find("import").remove();
917
909
  templateContent.find("include").remove();
918
- templateContent.find(getViewScriptTags().join(",")).remove();
910
+ templateContent.find("wxs").remove();
911
+ templateContent.find("dds").remove();
919
912
  transAsses($, templateContent.find("image"), path2);
920
913
  const res = [];
921
914
  transHtmlTag(templateContent.html(), res, components, componentPlaceholder);
@@ -1222,7 +1215,7 @@ function parseKeyExpression(exp, itemName = "item", indexName = "index") {
1222
1215
  }
1223
1216
  function getViewPath(workPath, src) {
1224
1217
  const aSrc = src.startsWith("/") ? src : `/${src}`;
1225
- for (const mlType of getTemplateExts()) {
1218
+ for (const mlType of fileType) {
1226
1219
  const mlFullPath = `${workPath}${aSrc}${mlType}`;
1227
1220
  if (fs_default.existsSync(mlFullPath)) {
1228
1221
  return mlFullPath;
@@ -1331,7 +1324,10 @@ function parseTemplateDataExp(exp) {
1331
1324
  return `{${parseBraceExp(exp)}}`;
1332
1325
  }
1333
1326
  function transTagWxs($, scriptModule, filePath) {
1334
- const wxsNodes = $(getViewScriptTags().join(","));
1327
+ let wxsNodes = $("wxs");
1328
+ if (wxsNodes.length === 0) {
1329
+ wxsNodes = $("dds");
1330
+ }
1335
1331
  wxsNodes.each((_, elem) => {
1336
1332
  const smName = $(elem).attr("module");
1337
1333
  if (smName) {
@@ -1350,7 +1346,7 @@ function transTagWxs($, scriptModule, filePath) {
1350
1346
  wxsFilePath = getAbsolutePath(workPath, filePath, src);
1351
1347
  }
1352
1348
  if (wxsFilePath) {
1353
- const relativePath = stripViewScriptExt(wxsFilePath.replace(workPath, ""));
1349
+ const relativePath = wxsFilePath.replace(workPath, "").replace(/\.wxs$/, "");
1354
1350
  uniqueModuleName = relativePath.replace(/[\/\\@\-]/g, "_").replace(/^_/, "");
1355
1351
  cacheKey = wxsFilePath;
1356
1352
  }
@@ -1423,8 +1419,12 @@ function collectAllWxsModules(scriptRes, collectedPaths = /* @__PURE__ */ new Se
1423
1419
  return allWxsModules;
1424
1420
  }
1425
1421
  function loadWxsModule(modulePath, workPath, scriptModule) {
1422
+ if (!modulePath.startsWith("miniprogram_npm__") || !modulePath.includes("_wxs_")) {
1423
+ return null;
1424
+ }
1426
1425
  const wxsFilePath = wxsFilePathMap.get(modulePath);
1427
1426
  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,8 +1516,6 @@ export {
1516
1516
  compileML,
1517
1517
  generateSlotDirective,
1518
1518
  generateVModelTemplate,
1519
- initWxsFilePathMap,
1520
- loadWxsModule,
1521
1519
  parseBraceExp,
1522
1520
  parseClassRules,
1523
1521
  parseKeyExpression,