weapp-tailwindcss 5.3.1 → 5.3.3

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.
Files changed (52) hide show
  1. package/dist/bundlers/shared/source-candidates/types-and-cache.d.ts +3 -0
  2. package/dist/bundlers/vite/shared/create-framework-plugins.d.ts +1 -0
  3. package/dist/bundlers/vite/shared/framework-module-candidates.d.ts +15 -0
  4. package/dist/{context-Kvr3lLEC.js → context-4ittVpgt.js} +1 -1
  5. package/dist/{context-CB4Ef9U0.cjs → context-Ulhcd5lF.cjs} +3 -3
  6. package/dist/core.cjs +1 -1
  7. package/dist/core.js +1 -1
  8. package/dist/{gulp-vz36-uQP.js → gulp-8V2aiU52.js} +3 -3
  9. package/dist/{gulp-QJ_oz-06.cjs → gulp-CsssU4xB.cjs} +6 -6
  10. package/dist/gulp.cjs +1 -1
  11. package/dist/gulp.js +1 -1
  12. package/dist/{hmr-timing-HGlM4hX3.js → hmr-timing-CTpjCpQh.js} +42 -13
  13. package/dist/{hmr-timing-W3kro20F.cjs → hmr-timing-DyiiYupC.cjs} +2 -2
  14. package/dist/index.cjs +3 -3
  15. package/dist/index.js +3 -3
  16. package/dist/local-style-matcher-DRpFEu1s.cjs +34 -0
  17. package/dist/local-style-matcher-DsiI2wIc.js +17 -0
  18. package/dist/{options-CKZW99r4.cjs → options-BJrtIQbH.cjs} +3 -1
  19. package/dist/{pipeline-helpers-t95KPu4O.cjs → pipeline-helpers-Cda0Ox3K.cjs} +2 -2
  20. package/dist/presets.cjs +2 -2
  21. package/dist/presets.js +1 -1
  22. package/dist/rspack.cjs +2 -2
  23. package/dist/rspack.js +2 -2
  24. package/dist/{source-candidate-scan-signature-BHCPQVoD.js → source-candidate-scan-signature--r31NK5J.js} +2 -2
  25. package/dist/{source-candidate-scan-signature-BSad7bMQ.cjs → source-candidate-scan-signature-bJFr7L8T.cjs} +2 -2
  26. package/dist/{style-options-PCgz2ywM.cjs → style-options-DW30H5PV.cjs} +1 -1
  27. package/dist/{tailwindcss-jKzY37Sk.cjs → tailwindcss-CexDJBhx.cjs} +1 -1
  28. package/dist/{tailwindcss-BSEdWieh.js → tailwindcss-ChnpCv25.js} +3 -1
  29. package/dist/{component-local-style-CNhEhd2B.cjs → transform-BQjg2T2T.cjs} +201 -27
  30. package/dist/{component-local-style-C2wC8o9F.js → transform-Cp4KybBy.js} +207 -16
  31. package/dist/types/user-defined-options/important.d.ts +2 -0
  32. package/dist/uni-app-x/component-local-style.d.ts +6 -4
  33. package/dist/uni-app-x/local-style-matcher.d.ts +4 -0
  34. package/dist/uni-app-x/options.d.ts +2 -0
  35. package/dist/uni-app-x/style-asset/harmony-global.d.ts +11 -0
  36. package/dist/uni-app-x/style-asset/style-value.d.ts +1 -3
  37. package/dist/uni-app-x/style-asset.d.ts +3 -8
  38. package/dist/uni-app-x/transform.d.ts +2 -0
  39. package/dist/uni-app-x/vite/plugin-options.d.ts +1 -0
  40. package/dist/{v4-generation-core-BfeXEc6R.cjs → v4-generation-core-8YMXikPd.cjs} +42 -13
  41. package/dist/{vite-CtmGLZXy.cjs → vite-CeyMHgzQ.cjs} +180 -97
  42. package/dist/{vite-Crz1mQR4.js → vite-kY-WXrd6.js} +233 -150
  43. package/dist/vite.cjs +1 -1
  44. package/dist/vite.js +1 -1
  45. package/dist/weapp-tw-css-import-rewrite-loader.cjs +4 -4
  46. package/dist/{webpack-DwtdWqwr.js → webpack-BN2kLWW_.js} +4 -4
  47. package/dist/{webpack-Cf5RnhXt.cjs → webpack-Bfj63Wt1.cjs} +8 -8
  48. package/dist/webpack.cjs +1 -1
  49. package/dist/webpack.js +1 -1
  50. package/package.json +3 -3
  51. package/dist/transform-CgohToUV.cjs +0 -200
  52. package/dist/transform-DSRPiBWz.js +0 -201
@@ -2,9 +2,9 @@ const require_rolldown_runtime = require("./rolldown-runtime-Ctb5zv51.cjs");
2
2
  const require_generator = require("./generator-DKiYbTFR.cjs");
3
3
  require("./auto-DtU6f3X6.cjs");
4
4
  const require_object = require("./object-DbHtAXRk.cjs");
5
- const require_options = require("./options-CKZW99r4.cjs");
5
+ const require_options = require("./options-BJrtIQbH.cjs");
6
6
  const require_wxml = require("./wxml-CQmBCjOR.cjs");
7
- const require_style_options = require("./style-options-PCgz2ywM.cjs");
7
+ const require_style_options = require("./style-options-DW30H5PV.cjs");
8
8
  let node_fs = require("node:fs");
9
9
  let node_path = require("node:path");
10
10
  node_path = require_rolldown_runtime.__toESM(node_path, 1);
@@ -312,9 +312,11 @@ function createSourceCandidateStore(options = {}) {
312
312
  const scanCandidatesById = /* @__PURE__ */ new Map();
313
313
  const transformCandidatesById = /* @__PURE__ */ new Map();
314
314
  const cssCandidatesById = /* @__PURE__ */ new Map();
315
+ const moduleCandidatesById = /* @__PURE__ */ new Map();
315
316
  const scanSourceById = /* @__PURE__ */ new Map();
316
317
  const transformSourceById = /* @__PURE__ */ new Map();
317
318
  const cssSourceById = /* @__PURE__ */ new Map();
319
+ const moduleSourceById = /* @__PURE__ */ new Map();
318
320
  const candidateCount = /* @__PURE__ */ new Map();
319
321
  let inlineIncludedCandidates = /* @__PURE__ */ new Set();
320
322
  let inlineExcludedCandidates = /* @__PURE__ */ new Set();
@@ -345,6 +347,13 @@ function createSourceCandidateStore(options = {}) {
345
347
  cssSourceById.set(normalizedId, source);
346
348
  replaceCssLayer(normalizedId, await resolveCandidates(source, "css"));
347
349
  }
350
+ async function syncModuleSource(id, source) {
351
+ const normalizedId = cleanUrl(id);
352
+ moduleSourceById.set(normalizedId, source);
353
+ const candidates = await resolveCandidates(source, resolveSourceCandidateExtension(normalizedId));
354
+ replaceModuleLayer(normalizedId, candidates);
355
+ return new Set(candidates);
356
+ }
348
357
  async function merge(id, source) {
349
358
  const normalizedId = cleanUrl(id);
350
359
  transformSourceById.set(normalizedId, source);
@@ -372,8 +381,10 @@ function createSourceCandidateStore(options = {}) {
372
381
  if (extension !== "css") {
373
382
  transformCandidatesById.delete(normalizedId);
374
383
  cssCandidatesById.delete(normalizedId);
384
+ moduleCandidatesById.delete(normalizedId);
375
385
  transformSourceById.delete(normalizedId);
376
386
  cssSourceById.delete(normalizedId);
387
+ moduleSourceById.delete(normalizedId);
377
388
  }
378
389
  scanSourceById.set(normalizedId, source);
379
390
  replaceScanLayer(normalizedId, nextCandidates);
@@ -431,12 +442,19 @@ function createSourceCandidateStore(options = {}) {
431
442
  else cssCandidatesById.set(normalizedId, nextCandidates);
432
443
  recompute(normalizedId);
433
444
  }
445
+ function replaceModuleLayer(id, nextCandidates) {
446
+ const normalizedId = cleanUrl(id);
447
+ if (nextCandidates.size === 0) moduleCandidatesById.delete(normalizedId);
448
+ else moduleCandidatesById.set(normalizedId, nextCandidates);
449
+ recompute(normalizedId);
450
+ }
434
451
  function recompute(id) {
435
452
  const normalizedId = cleanUrl(id);
436
453
  replaceFinal(normalizedId, /* @__PURE__ */ new Set([
437
454
  ...scanCandidatesById.get(normalizedId) ?? [],
438
455
  ...transformCandidatesById.get(normalizedId) ?? [],
439
- ...cssCandidatesById.get(normalizedId) ?? []
456
+ ...cssCandidatesById.get(normalizedId) ?? [],
457
+ ...moduleCandidatesById.get(normalizedId) ?? []
440
458
  ]));
441
459
  }
442
460
  function syncInline(inlineCandidates) {
@@ -450,9 +468,11 @@ function createSourceCandidateStore(options = {}) {
450
468
  scanCandidatesById.delete(normalizedId);
451
469
  transformCandidatesById.delete(normalizedId);
452
470
  cssCandidatesById.delete(normalizedId);
471
+ moduleCandidatesById.delete(normalizedId);
453
472
  scanSourceById.delete(normalizedId);
454
473
  transformSourceById.delete(normalizedId);
455
474
  cssSourceById.delete(normalizedId);
475
+ moduleSourceById.delete(normalizedId);
456
476
  const previousCandidates = candidatesById.get(normalizedId);
457
477
  if (!previousCandidates) return diffCandidateSets(previousVisibleCandidates, /* @__PURE__ */ new Set());
458
478
  removeCandidateSet(candidateCount, previousCandidates);
@@ -461,7 +481,7 @@ function createSourceCandidateStore(options = {}) {
461
481
  }
462
482
  function source(id) {
463
483
  const normalizedId = cleanUrl(id);
464
- return scanSourceById.get(normalizedId) ?? cssSourceById.get(normalizedId) ?? transformSourceById.get(normalizedId);
484
+ return scanSourceById.get(normalizedId) ?? cssSourceById.get(normalizedId) ?? transformSourceById.get(normalizedId) ?? moduleSourceById.get(normalizedId);
465
485
  }
466
486
  function sources() {
467
487
  return mergeSourcesByPriority().entries();
@@ -475,10 +495,10 @@ function createSourceCandidateStore(options = {}) {
475
495
  if (entries === void 0) {
476
496
  if (!options.excludeEntries?.length) return values();
477
497
  }
478
- if (entries?.length === 0) return new Set(inlineIncludedCandidates);
479
498
  const filtered = /* @__PURE__ */ new Set();
480
499
  for (const [id, candidates] of candidatesById) {
481
- if (entries !== void 0 && !require_generator.isFileMatchedByTailwindSourceEntries(id, entries)) continue;
500
+ const isActiveModule = moduleCandidatesById.has(id);
501
+ if (entries !== void 0 && (isActiveModule ? require_generator.isFileExcludedByTailwindSourceEntries(id, entries) : entries.length === 0 || !require_generator.isFileMatchedByTailwindSourceEntries(id, entries))) continue;
482
502
  if (options.excludeEntries?.length && require_generator.isFileMatchedByTailwindSourceEntries(id, options.excludeEntries)) continue;
483
503
  for (const candidate of candidates) filtered.add(candidate);
484
504
  }
@@ -496,13 +516,9 @@ function createSourceCandidateStore(options = {}) {
496
516
  }
497
517
  if (id) candidateSources.add(id);
498
518
  };
499
- if (entries?.length === 0) {
500
- for (const candidate of inlineIncludedCandidates) addCandidateSource(candidate, void 0);
501
- for (const candidate of inlineExcludedCandidates) sources.delete(candidate);
502
- return sources;
503
- }
504
519
  for (const [id, candidates] of candidatesById) {
505
- if (entries !== void 0 && !require_generator.isFileMatchedByTailwindSourceEntries(id, entries)) continue;
520
+ const isActiveModule = moduleCandidatesById.has(id);
521
+ if (entries !== void 0 && (isActiveModule ? require_generator.isFileExcludedByTailwindSourceEntries(id, entries) : entries.length === 0 || !require_generator.isFileMatchedByTailwindSourceEntries(id, entries))) continue;
506
522
  if (options.excludeEntries?.length && require_generator.isFileMatchedByTailwindSourceEntries(id, options.excludeEntries)) continue;
507
523
  for (const candidate of candidates) addCandidateSource(candidate, id);
508
524
  }
@@ -515,9 +531,11 @@ function createSourceCandidateStore(options = {}) {
515
531
  scanCandidatesById.clear();
516
532
  transformCandidatesById.clear();
517
533
  cssCandidatesById.clear();
534
+ moduleCandidatesById.clear();
518
535
  scanSourceById.clear();
519
536
  transformSourceById.clear();
520
537
  cssSourceById.clear();
538
+ moduleSourceById.clear();
521
539
  candidateCount.clear();
522
540
  inlineIncludedCandidates.clear();
523
541
  inlineExcludedCandidates.clear();
@@ -539,6 +557,8 @@ function createSourceCandidateStore(options = {}) {
539
557
  candidatesById: [...candidatesById.entries()].map(([id, candidates]) => [id, [...candidates]]),
540
558
  cssCandidatesById: [...cssCandidatesById.entries()].map(([id, candidates]) => [id, [...candidates]]),
541
559
  cssSourceById: [...cssSourceById.entries()],
560
+ moduleCandidatesById: [...moduleCandidatesById.entries()].map(([id, candidates]) => [id, [...candidates]]),
561
+ moduleSourceById: [...moduleSourceById.entries()],
542
562
  scanCandidatesById: [...scanCandidatesById.entries()].map(([id, candidates]) => [id, [...candidates]]),
543
563
  scanSourceById: [...scanSourceById.entries()],
544
564
  sourceById: [...mergeSourcesByPriority().entries()],
@@ -568,13 +588,20 @@ function createSourceCandidateStore(options = {}) {
568
588
  if (candidateSet.size === 0) continue;
569
589
  cssCandidatesById.set(id, candidateSet);
570
590
  }
591
+ for (const [id, candidates] of snapshot.moduleCandidatesById ?? []) {
592
+ const candidateSet = new Set(candidates);
593
+ if (candidateSet.size === 0) continue;
594
+ moduleCandidatesById.set(id, candidateSet);
595
+ }
571
596
  for (const [id, source] of snapshot.scanSourceById ?? snapshot.sourceById ?? []) scanSourceById.set(id, source);
572
597
  for (const [id, source] of snapshot.transformSourceById ?? []) transformSourceById.set(id, source);
573
598
  for (const [id, source] of snapshot.cssSourceById ?? []) cssSourceById.set(id, source);
599
+ for (const [id, source] of snapshot.moduleSourceById ?? []) moduleSourceById.set(id, source);
574
600
  const ids = /* @__PURE__ */ new Set([
575
601
  ...scanCandidatesById.keys(),
576
602
  ...transformCandidatesById.keys(),
577
- ...cssCandidatesById.keys()
603
+ ...cssCandidatesById.keys(),
604
+ ...moduleCandidatesById.keys()
578
605
  ]);
579
606
  for (const id of ids) recompute(id);
580
607
  }
@@ -582,6 +609,7 @@ function createSourceCandidateStore(options = {}) {
582
609
  syncSource: sync,
583
610
  sync,
584
611
  syncCss,
612
+ syncModuleSource,
585
613
  merge,
586
614
  syncFile,
587
615
  syncCurrentSource,
@@ -603,6 +631,7 @@ function createSourceCandidateStore(options = {}) {
603
631
  };
604
632
  function mergeSourcesByPriority() {
605
633
  const sources = /* @__PURE__ */ new Map();
634
+ for (const [id, source] of moduleSourceById) sources.set(id, source);
606
635
  for (const [id, source] of transformSourceById) sources.set(id, source);
607
636
  for (const [id, source] of cssSourceById) sources.set(id, source);
608
637
  for (const [id, source] of scanSourceById) sources.set(id, source);
@@ -2,17 +2,17 @@ const require_rolldown_runtime = require("./rolldown-runtime-Ctb5zv51.cjs");
2
2
  const require_framework = require("./framework.cjs");
3
3
  const require_generator = require("./generator-DKiYbTFR.cjs");
4
4
  const require_object = require("./object-DbHtAXRk.cjs");
5
- const require_options = require("./options-CKZW99r4.cjs");
5
+ const require_options = require("./options-BJrtIQbH.cjs");
6
6
  require("./utils-CuKLf1Zv.cjs");
7
- const require_v4_generation_core = require("./v4-generation-core-BfeXEc6R.cjs");
7
+ const require_v4_generation_core = require("./v4-generation-core-8YMXikPd.cjs");
8
8
  const require_wxml = require("./wxml-CQmBCjOR.cjs");
9
- const require_hmr_timing = require("./hmr-timing-W3kro20F.cjs");
10
- const require_context = require("./context-CB4Ef9U0.cjs");
11
- const require_tailwindcss = require("./tailwindcss-jKzY37Sk.cjs");
12
- const require_style_options = require("./style-options-PCgz2ywM.cjs");
13
- const require_source_candidate_scan_signature = require("./source-candidate-scan-signature-BSad7bMQ.cjs");
9
+ const require_hmr_timing = require("./hmr-timing-DyiiYupC.cjs");
10
+ const require_context = require("./context-Ulhcd5lF.cjs");
11
+ const require_tailwindcss = require("./tailwindcss-CexDJBhx.cjs");
12
+ const require_style_options = require("./style-options-DW30H5PV.cjs");
13
+ const require_source_candidate_scan_signature = require("./source-candidate-scan-signature-bJFr7L8T.cjs");
14
+ const require_local_style_matcher = require("./local-style-matcher-DRpFEu1s.cjs");
14
15
  require("./logger-TlKT3xmR.cjs");
15
- const require_component_local_style = require("./component-local-style-CNhEhd2B.cjs");
16
16
  const require_css_imports = require("./css-imports-BFMU7Hpd.cjs");
17
17
  let node_fs = require("node:fs");
18
18
  node_fs = require_rolldown_runtime.__toESM(node_fs, 1);
@@ -243,6 +243,20 @@ const STRING_LITERAL_RE = /(['"`])((?:\\.|(?!\1)[\s\S])*?)\1/g;
243
243
  const SFC_STYLE_BLOCK_RE$2 = /<style\b[^>]*>([\s\S]*?)<\/style>/gi;
244
244
  const STYLE_EXPORT_PREFIX_RE = /^\s*export\s+default\s+/;
245
245
  const CLASS_SELECTOR_PREFIX_RE = /^\.((?:\\[^\n\r\f]|[\w-])+)(?=$|[.:#[])/;
246
+ function cloneStyleEntry(entry) {
247
+ return Object.fromEntries(Object.entries(entry).map(([state, declarations]) => [state, { ...declarations }]));
248
+ }
249
+ function mergeStyleEntry(local, generated) {
250
+ const merged = local ? cloneStyleEntry(local) : {};
251
+ for (const [state, declarations] of Object.entries(generated)) merged[state] = {
252
+ ...merged[state] ?? {},
253
+ ...declarations
254
+ };
255
+ return merged;
256
+ }
257
+ function cloneStyleValue(style) {
258
+ return Object.fromEntries(Object.entries(style).map(([className, entry]) => [className, cloneStyleEntry(entry)]));
259
+ }
246
260
  function toCamelCase(prop) {
247
261
  return prop.replace(/-([a-z])/g, (_, char) => char.toUpperCase());
248
262
  }
@@ -449,11 +463,14 @@ function collectUniAppXHarmonyApplyUtilitiesFromSources(sources) {
449
463
  function createMergedStyleValue(code, localStyle, appStyle) {
450
464
  const used = collectUsedStyleKeys(code, appStyle);
451
465
  if (used.size === 0) return;
452
- const merged = { ...localStyle ?? {} };
466
+ const merged = localStyle ? cloneStyleValue(localStyle) : {};
453
467
  let changed = false;
454
468
  for (const className of used) {
455
- if (merged[className] || !appStyle[className]) continue;
456
- merged[className] = appStyle[className];
469
+ const generatedStyle = appStyle[className];
470
+ if (!generatedStyle) continue;
471
+ const next = mergeStyleEntry(merged[className], generatedStyle);
472
+ if (JSON.stringify(next) === JSON.stringify(merged[className])) continue;
473
+ merged[className] = next;
457
474
  changed = true;
458
475
  }
459
476
  return changed ? merged : void 0;
@@ -462,87 +479,45 @@ function createMergedStyleValues(code, localStyles, appStyle) {
462
479
  if (localStyles.length === 0) return;
463
480
  const used = collectUsedStyleKeys(code, appStyle);
464
481
  if (used.size === 0) return;
465
- const merged = localStyles.map((style) => ({ ...style }));
482
+ const merged = localStyles.map(cloneStyleValue);
466
483
  let changed = false;
467
484
  for (const className of used) {
468
485
  const generatedStyle = appStyle[className];
469
486
  if (!generatedStyle) continue;
470
487
  const indexes = merged.flatMap((style, index) => style[className] ? [index] : []);
471
488
  if (indexes.length === 0) {
472
- merged[0][className] = generatedStyle;
489
+ merged[0][className] = mergeStyleEntry(void 0, generatedStyle);
473
490
  changed = true;
474
491
  continue;
475
492
  }
476
493
  for (const index of indexes) {
477
- if (JSON.stringify(merged[index][className]) === JSON.stringify(generatedStyle)) continue;
478
- merged[index][className] = generatedStyle;
494
+ const next = mergeStyleEntry(merged[index][className], generatedStyle);
495
+ if (JSON.stringify(merged[index][className]) === JSON.stringify(next)) continue;
496
+ merged[index][className] = next;
479
497
  changed = true;
480
498
  }
481
499
  }
482
500
  return changed ? merged : void 0;
483
501
  }
484
502
  //#endregion
485
- //#region src/uni-app-x/style-asset.ts
486
- const GEN_STYLES_PLACEHOLDER_RE = /\/\*(Gen[A-Za-z0-9]+Styles)\*\/|const\s+(Gen[A-Za-z0-9]+Styles)\s*=\s*\[\]/;
503
+ //#region src/uni-app-x/style-asset/harmony-global.ts
487
504
  const UVUE_TS_RE = /\.uvue\.ts$/;
488
505
  const JS_RE = /\.js$/;
489
- const APP_JS_RE = /(?:^|\/)App\.js$/;
506
+ const APP_JS_RE$1 = /(?:^|\/)App\.js$/;
490
507
  const COMPONENT_JS_RE = /(?:^|\/)components\/.+\.js$/;
491
- const HARMONY_BUNDLE_MARKER_FILES = /* @__PURE__ */ new Set([
492
- "import/app-service.ets",
493
- "import/dynamic.ets",
494
- "uni_modules/oh-package.json5"
495
- ]);
496
508
  const STYLE_DECL_RE = /const\s+(_style_\d+)\s*=\s*\{/g;
497
509
  const EXPORT_SFC_RE = /_export_sfc\(_sfc_main\s*,\s*\[/;
498
- const UNI_APP_X_STYLE_PLACEHOLDER_VERSION = "uni-app-x-style-placeholder-v3";
499
- function createUniAppXHarmonyApplyGeneratorSource(applyStyleSources, _applyUtilities) {
500
- return applyStyleSources.map((source) => {
501
- let root;
502
- try {
503
- root = _weapp_tailwindcss_postcss.postcss.parse(source);
504
- } catch {
505
- return source;
506
- }
507
- root.walkAtRules("reference", (rule) => {
508
- if (rule.params.match(/^(['"])(.+?)\1/)?.[2]?.startsWith(".")) rule.remove();
509
- });
510
- return root.toString();
511
- }).join("\n");
512
- }
513
- function collectUniAppXHarmonyApplyUtilities(bundle) {
514
- const utilities = /* @__PURE__ */ new Set();
515
- const getBundleSource = createUniAppXBundleAssetSourceGetter(bundle);
516
- for (const [file, item] of Object.entries(bundle)) {
517
- if (item.type !== "chunk" || !file.endsWith(".js") || APP_JS_RE.test(file)) continue;
518
- const mapSources = collectChunkMapSourcesContent(item).concat(resolveSourceMapFiles(file).flatMap((mapFile) => {
519
- const source = getBundleSource(mapFile);
520
- return source ? parseSourceMapSourcesContent(source) : [];
521
- }));
522
- for (const source of mapSources) for (const utility of collectUniAppXHarmonyApplyUtilitiesFromSources([source])) utilities.add(utility);
523
- }
524
- return utilities;
525
- }
526
- function collectUniAppXHarmonyApplyStyleSources(bundle) {
527
- const sources = /* @__PURE__ */ new Set();
528
- const getBundleSource = createUniAppXBundleAssetSourceGetter(bundle);
529
- const addSource = (source) => {
530
- for (const styleSource of collectUniAppXHarmonyApplyStyleSourcesFromSource(source)) sources.add(styleSource);
531
- };
532
- for (const [file, item] of Object.entries(bundle)) {
533
- if (item.type === "asset" && file.endsWith(".uvue")) {
534
- addSource(String(item.source));
535
- continue;
536
- }
537
- if (item.type !== "chunk" || !file.endsWith(".js") || APP_JS_RE.test(file)) continue;
538
- for (const sourceContent of collectChunkMapSourcesContent(item)) addSource(sourceContent);
539
- for (const mapFile of resolveSourceMapFiles(file)) {
540
- const source = getBundleSource(mapFile);
541
- if (!source) continue;
542
- for (const sourceContent of parseSourceMapSourcesContent(source)) addSource(sourceContent);
543
- }
544
- }
545
- return [...sources];
510
+ function resolveSfcSourceId(code) {
511
+ const match = code.match(/\[\s*["']__file["']\s*,\s*(["'])(.*?)\1\s*\]/);
512
+ return match?.[2] ? require_local_style_matcher.normalizeUniAppXLocalStyleId(match[2]) : void 0;
513
+ }
514
+ function shouldExcludeComponent(file, code, options) {
515
+ if (!options.excludeComponents) return false;
516
+ const sourceId = resolveSfcSourceId(code);
517
+ if (sourceId) return require_local_style_matcher.shouldEnableComponentLocalStyle(sourceId, options.componentMatcher);
518
+ const normalizedFile = require_local_style_matcher.normalizeUniAppXLocalStyleId(file);
519
+ if (options.componentMatcher?.(normalizedFile)) return true;
520
+ return COMPONENT_JS_RE.test(normalizedFile);
546
521
  }
547
522
  function resolveStyleAssetFile(file) {
548
523
  if (!UVUE_TS_RE.test(file)) return;
@@ -614,19 +589,19 @@ function resolveCssFallbackFiles(styleAssetFiles = []) {
614
589
  function resolveStyleAssetFilesForChunk(file, styleAssetFiles) {
615
590
  return typeof styleAssetFiles === "function" ? styleAssetFiles(file) : styleAssetFiles;
616
591
  }
617
- function resolveSourceMapFiles(file) {
592
+ function resolveSourceMapFiles$1(file) {
618
593
  return [
619
594
  `${file}.map`,
620
595
  file.startsWith("assets/") ? `${file.slice(7)}.map` : void 0,
621
596
  file.startsWith("assets/") ? void 0 : `assets/${file}.map`
622
597
  ].filter((item) => typeof item === "string");
623
598
  }
624
- function createStyleValueFromBundleSources(file, _code, getBundleSource, options = {}) {
599
+ function createStyleValueFromBundleSources(file, getBundleSource, options = {}) {
625
600
  const cssStyles = mergeStyleValues(...[...options.cssSources ?? []].map((source) => source ? cssSourceToStyleValue(source) : void 0), ...resolveCssFallbackFiles(resolveStyleAssetFilesForChunk(file, options.styleAssetFiles)).map((cssFile) => {
626
601
  const source = getBundleSource?.(cssFile);
627
602
  return source ? cssSourceToStyleValue(source) : void 0;
628
603
  }));
629
- return mergeStyleValues(cssStyles, createStyleValueFromApplySources([...options.mapSources ?? [], ...resolveSourceMapFiles(file).flatMap((mapFile) => {
604
+ return mergeStyleValues(cssStyles, createStyleValueFromApplySources([...options.mapSources ?? [], ...resolveSourceMapFiles$1(file).flatMap((mapFile) => {
630
605
  const source = getBundleSource?.(mapFile);
631
606
  return source ? parseSourceMapSourcesContent(source) : [];
632
607
  })].filter((source) => typeof source === "string"), cssStyles));
@@ -645,22 +620,9 @@ function injectStyleOption(code, styleVarName) {
645
620
  if (fileOptionIndex < 0) return code;
646
621
  return `${code.slice(0, fileOptionIndex)}["styles", [${styleVarName}]], ${code.slice(fileOptionIndex)}`;
647
622
  }
648
- function injectUniAppXStylePlaceholder(file, code, getAssetSource, cssSources = []) {
649
- const match = code.match(GEN_STYLES_PLACEHOLDER_RE);
650
- const stylesName = match?.[1] ?? match?.[2];
651
- if (!stylesName) return code;
652
- if (!resolveStyleAssetFile(file)) return code;
653
- const appStyleArray = createUtsStyleArrayFromAppStyles(code, getAssetSource?.("App.uvue.ts"));
654
- const fallbackStyleSources = resolveStylePlaceholderFallbackFiles(file).map((candidate) => getAssetSource?.(candidate));
655
- const styleExport = mergeStyleValues(...[...cssSources, ...fallbackStyleSources].map((source) => source ? cssSourceToStyleValue(source) : void 0));
656
- const styleArrays = [appStyleArray, styleExport ? styleExportToUtsMap(styleExport) : void 0].filter((item) => Boolean(item));
657
- if (styleArrays.length === 0) return code;
658
- const mergedStyleArray = styleArrays.length === 1 ? styleArrays[0] : `[${styleArrays.map((item) => item.slice(1, -1)).filter(Boolean).join(", ")}]`;
659
- return code.replace(GEN_STYLES_PLACEHOLDER_RE, `const ${stylesName} = ${mergedStyleArray}`);
660
- }
661
623
  function injectUniAppXHarmonyGlobalStyles(file, code, getBundleSource, options = {}) {
662
- if (!JS_RE.test(file) || APP_JS_RE.test(file)) return code;
663
- if (options.excludeComponents && COMPONENT_JS_RE.test(file)) return code;
624
+ if (!JS_RE.test(file) || APP_JS_RE$1.test(file)) return code;
625
+ if (shouldExcludeComponent(file, code, options)) return code;
664
626
  const appSource = getBundleSource?.("assets/App.js") ?? getBundleSource?.("App.js");
665
627
  const appStyle = appSource ? mergeStyleValues(...findStyleObjectDecls(appSource).map((decl) => parseStyleObject(decl.objectText))) : void 0;
666
628
  const parseableLocalStyles = findStyleObjectDecls(code).flatMap((decl) => {
@@ -670,7 +632,7 @@ function injectUniAppXHarmonyGlobalStyles(file, code, getBundleSource, options =
670
632
  style
671
633
  }] : [];
672
634
  });
673
- const styleSource = mergeStyleValues(createStyleValueFromBundleSources(file, code, getBundleSource, options), appStyle);
635
+ const styleSource = mergeStyleValues(createStyleValueFromBundleSources(file, getBundleSource, options), appStyle);
674
636
  if (!styleSource) return code;
675
637
  const mergedStyles = createMergedStyleValues(code, parseableLocalStyles.map((item) => item.style), styleSource);
676
638
  if (mergedStyles) {
@@ -687,7 +649,87 @@ function injectUniAppXHarmonyGlobalStyles(file, code, getBundleSource, options =
687
649
  const exportMatch = code.match(EXPORT_SFC_RE);
688
650
  if (!exportMatch || exportMatch.index === void 0) return code;
689
651
  const styleVarName = "_style_wt";
690
- return injectStyleOption(`${code.slice(0, exportMatch.index)}const ${styleVarName} = ${JSON.stringify(newStyle)};\n${code.slice(exportMatch.index)}`, styleVarName);
652
+ const statementStart = code.lastIndexOf("\n", exportMatch.index);
653
+ const insertPos = statementStart === -1 ? 0 : statementStart + 1;
654
+ return injectStyleOption(new RegExp(`\\b(?:const|let|var)\\s+${styleVarName}\\s*=`).test(code) ? code : `${code.slice(0, insertPos)}const ${styleVarName} = ${JSON.stringify(newStyle)};\n${code.slice(insertPos)}`, styleVarName);
655
+ }
656
+ //#endregion
657
+ //#region src/uni-app-x/style-asset.ts
658
+ const GEN_STYLES_PLACEHOLDER_RE = /\/\*(Gen[A-Za-z0-9]+Styles)\*\/|const\s+(Gen[A-Za-z0-9]+Styles)\s*=\s*\[\]/;
659
+ const APP_JS_RE = /(?:^|\/)App\.js$/;
660
+ const HARMONY_BUNDLE_MARKER_FILES = /* @__PURE__ */ new Set([
661
+ "import/app-service.ets",
662
+ "import/dynamic.ets",
663
+ "uni_modules/oh-package.json5"
664
+ ]);
665
+ function resolveSourceMapFiles(file) {
666
+ return [
667
+ `${file}.map`,
668
+ file.startsWith("assets/") ? `${file.slice(7)}.map` : void 0,
669
+ file.startsWith("assets/") ? void 0 : `assets/${file}.map`
670
+ ].filter((item) => typeof item === "string");
671
+ }
672
+ const UNI_APP_X_STYLE_PLACEHOLDER_VERSION = "uni-app-x-style-placeholder-v3";
673
+ function createUniAppXHarmonyApplyGeneratorSource(applyStyleSources, _applyUtilities) {
674
+ return applyStyleSources.map((source) => {
675
+ let root;
676
+ try {
677
+ root = _weapp_tailwindcss_postcss.postcss.parse(source);
678
+ } catch {
679
+ return source;
680
+ }
681
+ root.walkAtRules("reference", (rule) => {
682
+ if (rule.params.match(/^(['"])(.+?)\1/)?.[2]?.startsWith(".")) rule.remove();
683
+ });
684
+ return root.toString();
685
+ }).join("\n");
686
+ }
687
+ function collectUniAppXHarmonyApplyUtilities(bundle) {
688
+ const utilities = /* @__PURE__ */ new Set();
689
+ const getBundleSource = createUniAppXBundleAssetSourceGetter(bundle);
690
+ for (const [file, item] of Object.entries(bundle)) {
691
+ if (item.type !== "chunk" || !file.endsWith(".js") || APP_JS_RE.test(file)) continue;
692
+ const mapSources = collectChunkMapSourcesContent(item).concat(resolveSourceMapFiles(file).flatMap((mapFile) => {
693
+ const source = getBundleSource(mapFile);
694
+ return source ? parseSourceMapSourcesContent(source) : [];
695
+ }));
696
+ for (const source of mapSources) for (const utility of collectUniAppXHarmonyApplyUtilitiesFromSources([source])) utilities.add(utility);
697
+ }
698
+ return utilities;
699
+ }
700
+ function collectUniAppXHarmonyApplyStyleSources(bundle) {
701
+ const sources = /* @__PURE__ */ new Set();
702
+ const getBundleSource = createUniAppXBundleAssetSourceGetter(bundle);
703
+ const addSource = (source) => {
704
+ for (const styleSource of collectUniAppXHarmonyApplyStyleSourcesFromSource(source)) sources.add(styleSource);
705
+ };
706
+ for (const [file, item] of Object.entries(bundle)) {
707
+ if (item.type === "asset" && file.endsWith(".uvue")) {
708
+ addSource(String(item.source));
709
+ continue;
710
+ }
711
+ if (item.type !== "chunk" || !file.endsWith(".js") || APP_JS_RE.test(file)) continue;
712
+ for (const sourceContent of collectChunkMapSourcesContent(item)) addSource(sourceContent);
713
+ for (const mapFile of resolveSourceMapFiles(file)) {
714
+ const source = getBundleSource(mapFile);
715
+ if (!source) continue;
716
+ for (const sourceContent of parseSourceMapSourcesContent(source)) addSource(sourceContent);
717
+ }
718
+ }
719
+ return [...sources];
720
+ }
721
+ function injectUniAppXStylePlaceholder(file, code, getAssetSource, cssSources = []) {
722
+ const match = code.match(GEN_STYLES_PLACEHOLDER_RE);
723
+ const stylesName = match?.[1] ?? match?.[2];
724
+ if (!stylesName) return code;
725
+ if (!resolveStyleAssetFile(file)) return code;
726
+ const appStyleArray = createUtsStyleArrayFromAppStyles(code, getAssetSource?.("App.uvue.ts"));
727
+ const fallbackStyleSources = resolveStylePlaceholderFallbackFiles(file).map((candidate) => getAssetSource?.(candidate));
728
+ const styleExport = mergeStyleValues(...[...cssSources, ...fallbackStyleSources].map((source) => source ? cssSourceToStyleValue(source) : void 0));
729
+ const styleArrays = [appStyleArray, styleExport ? styleExportToUtsMap(styleExport) : void 0].filter((item) => Boolean(item));
730
+ if (styleArrays.length === 0) return code;
731
+ const mergedStyleArray = styleArrays.length === 1 ? styleArrays[0] : `[${styleArrays.map((item) => item.slice(1, -1)).filter(Boolean).join(", ")}]`;
732
+ return code.replace(GEN_STYLES_PLACEHOLDER_RE, `const ${stylesName} = ${mergedStyleArray}`);
691
733
  }
692
734
  function injectUniAppXHarmonyBundleStyles(bundle, options = {}) {
693
735
  const getBundleSource = createUniAppXBundleAssetSourceGetter(bundle);
@@ -6285,7 +6327,7 @@ function createUniAppXWebLocalStyleBridge(isEnabled) {
6285
6327
  //#region src/uni-app-x/vite.ts
6286
6328
  let transformUVuePromise;
6287
6329
  function loadTransformUVue() {
6288
- transformUVuePromise ?? (transformUVuePromise = Promise.resolve().then(() => require("./transform-CgohToUV.cjs")).then((mod) => mod.transformUVue));
6330
+ transformUVuePromise ?? (transformUVuePromise = Promise.resolve().then(() => require("./transform-BQjg2T2T.cjs")).then((mod) => mod.transformUVue));
6289
6331
  return transformUVuePromise;
6290
6332
  }
6291
6333
  const UVUE_NVUE_QUERY_RE = /\.(?:uvue|nvue)(?:\?.*)?$/;
@@ -6294,7 +6336,7 @@ function resolveUniAppXJsTransformEnabled(uniAppX) {
6294
6336
  return uniAppX === void 0 ? true : require_options.isUniAppXEnabled(uniAppX);
6295
6337
  }
6296
6338
  function createUniAppXPlugins(options) {
6297
- const { appType, customAttributesEntities, disabledDefaultTemplateHandler, isIosPlatform: providedIosPlatform, mainCssChunkMatcher, runtimeState, styleHandler, syncSourceCandidatesForHotUpdate, tailwindRootCssModuleIds = [], generateCss, jsHandler, ensureRuntimeClassSet, getResolvedConfig, isEnabled = () => true, isNativeAppStyleTarget = () => false, isWebGeneratorTarget = () => require_generator.resolveUniUtsPlatform().isWeb, uniAppX, viteProcessedCssSourceFiles = [] } = options;
6339
+ const { appType, customAttributesEntities, disabledDefaultTemplateHandler, isIosPlatform: providedIosPlatform, mainCssChunkMatcher, registerModuleGraphCandidates, runtimeState, styleHandler, syncSourceCandidatesForHotUpdate, tailwindRootCssModuleIds = [], generateCss, jsHandler, ensureRuntimeClassSet, getResolvedConfig, isEnabled = () => true, isNativeAppStyleTarget = () => false, isWebGeneratorTarget = () => require_generator.resolveUniUtsPlatform().isWeb, uniAppX, viteProcessedCssSourceFiles = [] } = options;
6298
6340
  const resolvedUniAppXOptions = require_options.resolveUniAppXOptions(uniAppX);
6299
6341
  const utsPlatform = require_generator.resolveUniUtsPlatform();
6300
6342
  const isIosPlatform = providedIosPlatform ?? utsPlatform.isAppIos;
@@ -6326,7 +6368,7 @@ function createUniAppXPlugins(options) {
6326
6368
  return componentLocalStyleEnabled;
6327
6369
  }
6328
6370
  function shouldEnablePageLocalStyleForFile(id) {
6329
- return resolvedUniAppXOptions.componentLocalStyles.enabled && (isNativeAppBuildTarget(id) || require_component_local_style.shouldEnablePageLocalStyle(id));
6371
+ return resolvedUniAppXOptions.componentLocalStyles.enabled && (isNativeAppBuildTarget(id) || require_local_style_matcher.shouldEnablePageLocalStyle(id, resolvedUniAppXOptions.componentLocalStyles.pageMatcher));
6330
6372
  }
6331
6373
  function isHarmonyBuildTarget() {
6332
6374
  if (require_generator.resolveUniUtsPlatform().isAppHarmony) return true;
@@ -6431,18 +6473,22 @@ function createUniAppXPlugins(options) {
6431
6473
  nativeLocalStyleModuleIds.add((0, _weapp_tailwindcss_shared.cleanUrl)(id));
6432
6474
  }
6433
6475
  harmonyApply.rememberSource(code, id, true);
6476
+ const enableComponentLocalStyle = shouldEnableComponentLocalStyle();
6477
+ const enablePageLocalStyle = shouldEnablePageLocalStyleForFile(id);
6434
6478
  const resolvedConfig = getResolvedConfig();
6435
6479
  const shouldForceRefresh = resolvedConfig?.command === "serve" || resolvedConfig?.command === "build";
6436
- const currentRuntimeSet = await ensureRuntimeClassSet(shouldForceRefresh);
6480
+ const moduleGraphCandidates = enableComponentLocalStyle || enablePageLocalStyle ? await registerModuleGraphCandidates?.(id, code) : void 0;
6481
+ const runtimeSet = await ensureRuntimeClassSet(shouldForceRefresh);
6482
+ const currentRuntimeSet = moduleGraphCandidates?.size ? /* @__PURE__ */ new Set([...runtimeSet, ...moduleGraphCandidates]) : runtimeSet;
6437
6483
  nativeHmrReloader.remember(currentRuntimeSet);
6438
6484
  const transformUVue = await loadTransformUVue();
6439
- const enableComponentLocalStyle = shouldEnableComponentLocalStyle();
6440
- const enablePageLocalStyle = shouldEnablePageLocalStyleForFile(id);
6441
6485
  const transformOptions = require_object.omitUndefined({
6486
+ componentMatcher: resolvedUniAppXOptions.componentLocalStyles.componentMatcher,
6442
6487
  ...customAttributesEntities.length > 0 ? { customAttributesEntities } : {},
6443
6488
  ...disabledDefaultTemplateHandler ? { disabledDefaultTemplateHandler } : {},
6444
6489
  ...enableComponentLocalStyle ? { enableComponentLocalStyle } : {},
6445
6490
  ...enablePageLocalStyle ? { enablePageLocalStyle } : {},
6491
+ pageMatcher: resolvedUniAppXOptions.componentLocalStyles.pageMatcher,
6446
6492
  ...isWebGeneratorTarget() && customAttributesEntities.length > 0 ? { webCustomAttributeDeep: true } : {},
6447
6493
  ...isWebGeneratorTarget() ? { onWebLocalStyleRules: (rules) => webLocalStyle.remember(id, rules) } : {}
6448
6494
  });
@@ -6515,6 +6561,7 @@ function createUniAppXPlugins(options) {
6515
6561
  }
6516
6562
  injectUniAppXHarmonyBundleStyles(bundle, {
6517
6563
  cssSources,
6564
+ componentMatcher: resolvedUniAppXOptions.componentLocalStyles.componentMatcher,
6518
6565
  excludeComponents: shouldEnableComponentLocalStyle()
6519
6566
  });
6520
6567
  }
@@ -9446,6 +9493,29 @@ function createViteHmrCandidateState(options) {
9446
9493
  };
9447
9494
  }
9448
9495
  //#endregion
9496
+ //#region src/bundlers/vite/shared/framework-module-candidates.ts
9497
+ function createFrameworkModuleCandidateRegistrar(options) {
9498
+ return async (id, source) => {
9499
+ await options.runtimeState.readyPromise;
9500
+ const candidates = await options.sourceCandidateCollector.syncModuleSource(id, source);
9501
+ options.invalidateRecordedGeneratorCandidates();
9502
+ options.cacheCurrent();
9503
+ const cssHandlerOptions = options.getCssHandlerOptions(id);
9504
+ return require_v4_generation_core.validateCandidatesByGenerator({
9505
+ candidates,
9506
+ cssHandlerOptions,
9507
+ cssUserHandlerOptions: cssHandlerOptions,
9508
+ debug: options.debug,
9509
+ file: (0, _weapp_tailwindcss_shared.cleanUrl)(id),
9510
+ generatorPlatform: options.getGeneratorPlatform(),
9511
+ opts: options.opts,
9512
+ rawSource: "",
9513
+ runtimeState: options.runtimeState,
9514
+ styleHandler: options.styleHandler
9515
+ });
9516
+ };
9517
+ }
9518
+ //#endregion
9449
9519
  //#region src/bundlers/vite/shared/framework-plugin-order.ts
9450
9520
  function orderFrameworkSourceCandidatePlugins(extraPlugins, rewritePlugins, sourceCandidatesPlugin, beforeExtraPlugin) {
9451
9521
  const anchor = beforeExtraPlugin ? extraPlugins.findIndex(beforeExtraPlugin) : -1;
@@ -10753,6 +10823,17 @@ ${tracedCss}`;
10753
10823
  });
10754
10824
  const extraPluginPlatform = frameworkBranch.getExtraPluginPlatform?.() ?? {};
10755
10825
  const syncSourceCandidatesForHotUpdate = (ctx) => syncFrameworkSourceCandidatesForHotUpdate(sourceScanSession, ctx);
10826
+ const registerModuleGraphCandidates = createFrameworkModuleCandidateRegistrar({
10827
+ cacheCurrent: sourceScanSession.cacheCurrent,
10828
+ debug,
10829
+ getCssHandlerOptions: transformCssHandlerOptions.getCssHandlerOptions,
10830
+ getGeneratorPlatform: resolveGeneratorPlatform,
10831
+ invalidateRecordedGeneratorCandidates,
10832
+ opts,
10833
+ runtimeState,
10834
+ sourceCandidateCollector,
10835
+ styleHandler
10836
+ });
10756
10837
  const prepareTailwindGeneration = async () => {
10757
10838
  if (sourceScanSession.shouldDiscoverAutoCssSources(autoCssSourcesDiscovered)) await discoverAndRegisterAutoCssSources();
10758
10839
  await sourceScanSession.sync();
@@ -10769,6 +10850,7 @@ ${tracedCss}`;
10769
10850
  isWebGeneratorTarget: () => resolveCurrentGeneratorBranch().isWeb,
10770
10851
  jsHandler,
10771
10852
  mainCssChunkMatcher,
10853
+ registerModuleGraphCandidates,
10772
10854
  runtimeState,
10773
10855
  styleHandler,
10774
10856
  syncSourceCandidatesForHotUpdate,
@@ -11190,6 +11272,7 @@ function createUniAppXVitePlugins(options = {}) {
11190
11272
  isWebGeneratorTarget: context.isWebGeneratorTarget,
11191
11273
  jsHandler: context.jsHandler,
11192
11274
  mainCssChunkMatcher: context.mainCssChunkMatcher,
11275
+ registerModuleGraphCandidates: context.registerModuleGraphCandidates,
11193
11276
  runtimeState: context.runtimeState,
11194
11277
  styleHandler: context.styleHandler,
11195
11278
  syncSourceCandidatesForHotUpdate: context.syncSourceCandidatesForHotUpdate,