weapp-tailwindcss 5.5.0 → 5.5.2

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 (83) hide show
  1. package/README.md +1 -1
  2. package/README.zh-CN.md +1 -1
  3. package/dist/bundlers/shared/css-imports.d.ts +1 -0
  4. package/dist/bundlers/shared/final-css-cleanup.d.ts +1 -1
  5. package/dist/bundlers/shared/framework-user-css.d.ts +3 -0
  6. package/dist/bundlers/shared/generator-css/output-import-shell.d.ts +6 -2
  7. package/dist/bundlers/shared/source-candidates/types-and-cache.d.ts +1 -1
  8. package/dist/bundlers/shared/v4-generation-core.d.ts +1 -0
  9. package/dist/bundlers/vite/frameworks/taro/index.d.ts +2 -1
  10. package/dist/bundlers/vite/generate-bundle/bundle-markup-candidates.d.ts +3 -2
  11. package/dist/bundlers/vite/generate-bundle/css-output-helpers.d.ts +1 -0
  12. package/dist/bundlers/vite/generate-bundle/entry-style-graph.d.ts +6 -0
  13. package/dist/bundlers/vite/generate-bundle/runtime-configured-css.d.ts +1 -0
  14. package/dist/bundlers/vite/serve-js-transform.d.ts +1 -1
  15. package/dist/bundlers/vite/shared/create-framework-plugins.d.ts +2 -0
  16. package/dist/bundlers/vite/shared/framework-module-candidates.d.ts +1 -1
  17. package/dist/bundlers/webpack/loaders/watch-dependencies.d.ts +3 -1
  18. package/dist/bundlers/webpack/shared/loader-anchors.d.ts +1 -0
  19. package/dist/compiler/runtime-snapshot.d.ts +4 -1
  20. package/dist/{compiler-SwMb3lOX.cjs → compiler-BSMSbVVt.cjs} +6 -6
  21. package/dist/{compiler-B0YSc0DY.js → compiler-tHMcW3BT.js} +3 -3
  22. package/dist/core.cjs +1 -1
  23. package/dist/core.js +1 -1
  24. package/dist/{css-imports-BFMU7Hpd.cjs → css-imports-DsCSPIj2.cjs} +29 -0
  25. package/dist/{css-loader-runtime-CSv0lKqV.cjs → css-loader-runtime-DGqsWVua.cjs} +2 -1
  26. package/dist/{defaults-B5ep0ojb.js → defaults-CKx-4LcW.js} +1 -1
  27. package/dist/{defaults-BI9j1znS.cjs → defaults-CiGsr8Xq.cjs} +1 -1
  28. package/dist/defaults.cjs +1 -1
  29. package/dist/defaults.js +1 -1
  30. package/dist/{final-css-cleanup-CmVYbXPr.js → final-css-cleanup-B0HUBtiE.js} +63 -37
  31. package/dist/final-css-cleanup-DSjczga3.cjs +138 -0
  32. package/dist/{generator-DsrQ9txU.cjs → generator-CCw17l0G.cjs} +72 -67
  33. package/dist/{generator-DyXTBPmE.js → generator-DxEsInLz.js} +61 -68
  34. package/dist/generator.cjs +1 -1
  35. package/dist/generator.js +1 -1
  36. package/dist/{gulp-Dtc01FdI.cjs → gulp-C1r36Y_f.cjs} +6 -6
  37. package/dist/{gulp-CVUiPXPy.js → gulp-qGXKwQMZ.js} +5 -5
  38. package/dist/gulp.cjs +1 -1
  39. package/dist/gulp.js +1 -1
  40. package/dist/{hmr-timing-DNxQm-bN.js → hmr-timing-DixZjtTS.js} +245 -183
  41. package/dist/{hmr-timing-3SdRVfZx.cjs → hmr-timing-DuIbach8.cjs} +5 -5
  42. package/dist/index.cjs +4 -4
  43. package/dist/index.js +4 -4
  44. package/dist/{pipeline-helpers-DVrgv1HS.cjs → pipeline-helpers-CUwwOFt3.cjs} +5 -5
  45. package/dist/postcss.cjs +1 -1
  46. package/dist/postcss.js +1 -1
  47. package/dist/presets.cjs +2 -2
  48. package/dist/presets.js +2 -2
  49. package/dist/rspack.cjs +6 -3
  50. package/dist/rspack.js +6 -3
  51. package/dist/{scoped-generator-kRj_5Axx.js → scoped-generator-BJvL2CKZ.js} +3 -3
  52. package/dist/{scoped-generator-B7thnzzm.cjs → scoped-generator-CO9xZ06m.cjs} +3 -3
  53. package/dist/{source-candidate-scan-signature-CsP4BQNa.js → source-candidate-scan-signature-CgJi--lh.js} +2 -2
  54. package/dist/{source-candidate-scan-signature-B7cUxqqX.cjs → source-candidate-scan-signature-_UPwg8oJ.cjs} +2 -2
  55. package/dist/tailwindcss/v4-engine/css-import.d.ts +14 -0
  56. package/dist/{tailwindcss-BK9S7zuq.js → tailwindcss-D2joPNdN.js} +1 -1
  57. package/dist/{tailwindcss-C-jBBQfw.cjs → tailwindcss-DhaLV5a2.cjs} +1 -1
  58. package/dist/{transform-C0rWZblB.js → transform-BNtyKkZi.js} +14 -14
  59. package/dist/{transform-C7QxW-fV.cjs → transform-DAg85t9Z.cjs} +14 -14
  60. package/dist/uni-app-x/border-preflight.d.ts +18 -0
  61. package/dist/uni-app-x/style-asset/source-parser.d.ts +2 -0
  62. package/dist/uni-app-x/transform.d.ts +2 -0
  63. package/dist/uni-app-x/vite/plugin-options.d.ts +2 -0
  64. package/dist/uni-app-x/vite/style-source.d.ts +21 -0
  65. package/dist/{v4-generation-core-DuIVZvRz.cjs → v4-generation-core-bOm8k4AY.cjs} +243 -181
  66. package/dist/vite/web.cjs +1 -1
  67. package/dist/vite/web.js +1 -1
  68. package/dist/{vite-0PsttwuR.js → vite-C_JJxZWl.js} +290 -69
  69. package/dist/{vite-CJbO-7AQ.cjs → vite-bJZi1V-l.cjs} +306 -66
  70. package/dist/vite.cjs +1 -1
  71. package/dist/vite.js +1 -1
  72. package/dist/{watch-dependencies-DLZDrWdH.cjs → watch-dependencies-GbC14Rlt.cjs} +14 -11
  73. package/dist/weapp-tw-css-generation-loader.cjs +3 -2
  74. package/dist/weapp-tw-css-import-rewrite-loader.cjs +11 -10
  75. package/dist/weapp-tw-runtime-classset-loader.cjs +16 -11
  76. package/dist/{web-BFOkkJ-8.cjs → web-B4wa3xrE.cjs} +13 -8
  77. package/dist/{web-D8HSs56R.js → web-BiubXhxs.js} +11 -6
  78. package/dist/{webpack-DVtKeBq1.js → webpack-BDOQUv3J.js} +39 -24
  79. package/dist/{webpack-BWknqSDV.cjs → webpack-CsBe1G_1.cjs} +37 -23
  80. package/dist/webpack.cjs +1 -1
  81. package/dist/webpack.js +1 -1
  82. package/package.json +7 -5
  83. package/dist/final-css-cleanup-BMlUDzik.cjs +0 -112
package/README.md CHANGED
@@ -34,7 +34,7 @@ export default {
34
34
  }
35
35
  ```
36
36
 
37
- The repository provides four canonical templates: [Generic Vite](../../templates/generic-vite-tailwindcss-v4), [uni-app](../../templates/uni-app-tailwindcss-v4), [Taro Vite](../../templates/taro-vite-tailwindcss-v4), and [weapp-vite](../../templates/weapp-vite-tailwindcss-v4). Each can be installed independently and verified with the template smoke build.
37
+ The repository provides three canonical templates: [uni-app](../../templates/uni-app-tailwindcss-v4), [Taro Vite](../../templates/taro-vite-tailwindcss-v4), and [weapp-vite](../../templates/weapp-vite-tailwindcss-v4). Each can be installed independently and verified with the template smoke build.
38
38
 
39
39
  ## Tailwind CSS 4 entry
40
40
 
package/README.zh-CN.md CHANGED
@@ -34,7 +34,7 @@ export default {
34
34
  }
35
35
  ```
36
36
 
37
- 仓库提供 [Generic Vite](../../templates/generic-vite-tailwindcss-v4)、[uni-app](../../templates/uni-app-tailwindcss-v4)、[Taro Vite](../../templates/taro-vite-tailwindcss-v4) 和 [weapp-vite](../../templates/weapp-vite-tailwindcss-v4) 四个 canonical 模板,可直接安装并运行 smoke 构建。
37
+ 仓库提供 [uni-app](../../templates/uni-app-tailwindcss-v4)、[Taro Vite](../../templates/taro-vite-tailwindcss-v4) 和 [weapp-vite](../../templates/weapp-vite-tailwindcss-v4) 三个 canonical 模板,可直接安装并运行 smoke 构建。
38
38
 
39
39
  ## Tailwind CSS 4 入口
40
40
 
@@ -1,4 +1,5 @@
1
1
  import type { AppType } from '../../types/index.js';
2
+ export declare function normalizeResolvedTailwindcssImports(code: string, pkgDir: string | undefined): string;
2
3
  export interface ResolveTailwindcssImportOptions {
3
4
  join?: ((base: string, subpath: string) => string) | undefined;
4
5
  appType?: AppType | undefined;
@@ -1,2 +1,2 @@
1
- export declare function hasEmptyAtRuleBlockCandidate(css: string): boolean;
1
+ export declare function hasEmptyCssBlockCandidate(css: string): boolean;
2
2
  export declare function finalizeMiniProgramCssStructure(css: string): string;
@@ -0,0 +1,3 @@
1
+ import type { GenerateCssByGeneratorOptions, GenerateCssByGeneratorResult } from './generator-css.js';
2
+ import type { NormalizedWeappTailwindcssGeneratorOptions } from '../../generator/index.js';
3
+ export declare function restoreFrameworkProcessedUserCss(css: string, generated: GenerateCssByGeneratorResult, source: string, options: GenerateCssByGeneratorOptions, generatorOptions: NormalizedWeappTailwindcssGeneratorOptions): Promise<string>;
@@ -1,4 +1,8 @@
1
- export declare function normalizeMiniProgramImportShell(css: string): string;
1
+ export declare function normalizeMiniProgramImportShell(css: string, output?: {
2
+ outputFile: string;
3
+ outputFiles: Iterable<string>;
4
+ cssOnly?: boolean;
5
+ }): string;
2
6
  export declare function removeSelfMiniProgramOutputImports(css: string, outputFile: string): string;
3
7
  export declare function removeMiniProgramOutputImports(css: string): string;
4
- export declare function normalizeMiniProgramGeneratorCssSource(css: string, outputFile?: string | undefined): string;
8
+ export declare function normalizeMiniProgramGeneratorCssSource(css: string, outputFile?: string | undefined, outputFiles?: Iterable<string>): string;
@@ -6,7 +6,7 @@ export interface SourceCandidateStore {
6
6
  syncSource: (id: string, source: string) => Promise<void>;
7
7
  sync: (id: string, source: string) => Promise<void>;
8
8
  syncCss: (id: string, source: string) => Promise<void>;
9
- syncModuleSource: (id: string, source: string) => Promise<Set<string>>;
9
+ syncModuleSource: (id: string, source: string, extension?: string) => Promise<Set<string>>;
10
10
  merge: (id: string, source: string) => Promise<void>;
11
11
  syncFile: (id: string) => Promise<void>;
12
12
  syncCurrentSource: (id: string, source: string) => Promise<SourceCandidateChange>;
@@ -6,6 +6,7 @@ export interface TailwindV4GenerationCoreInput extends GenerateCssByGeneratorOpt
6
6
  compilationChanges?: CompilationDependencyChange[] | undefined;
7
7
  frameworkPostcssOwner?: InternalUserDefinedOptions | undefined;
8
8
  cssStage?: CssStage | undefined;
9
+ frameworkProcessedUserCss?: string | undefined;
9
10
  outputFile?: string | undefined;
10
11
  onCompilerShadowReport?: ((report: CompilerShadowReport) => void) | undefined;
11
12
  scope?: SourceScope | undefined;
@@ -1,4 +1,5 @@
1
+ import type { Plugin } from 'vite';
1
2
  import type { ViteFrameworkCssPipelineStrategy } from '../../shared/framework-strategy.js';
2
3
  import type { InternalUserDefinedOptions, UserDefinedOptions } from '../../../../types/index.js';
3
4
  export declare const taroCssPipelineStrategy: ViteFrameworkCssPipelineStrategy;
4
- export declare function createTaroVitePlugins(options?: UserDefinedOptions | InternalUserDefinedOptions): any[];
5
+ export declare function createTaroVitePlugins(options?: UserDefinedOptions | InternalUserDefinedOptions): (Plugin<any> | import("../../index.js").WeappTailwindcssVitePlugin)[] | undefined;
@@ -1,10 +1,11 @@
1
1
  import type { BundleSnapshot } from '../bundle-state.js';
2
2
  import type { SourceCandidateFilterOptions } from '../source-candidates.js';
3
3
  import type { createTransformFilter } from './transform-filter.js';
4
+ import type { RuntimeCompilationBuildState } from '../../../compiler/index.js';
4
5
  import type { TailwindSourceEntry } from '../../../tailwindcss/source-scan.js';
5
6
  interface CollectBundleMarkupCandidatesOptions {
6
7
  extractSourceCandidates?: ((file: string, source: string) => Promise<Set<string>>) | undefined;
7
- previousCandidatesByFile?: ReadonlyMap<string, Set<string>> | undefined;
8
+ previousCandidatesByFile?: RuntimeCompilationBuildState['bundleMarkupCandidatesByFile'] | undefined;
8
9
  preserveMissingFiles?: boolean | undefined;
9
10
  resolveSourceCandidateFile: (file: string) => string | undefined;
10
11
  rootDir: string;
@@ -12,7 +13,7 @@ interface CollectBundleMarkupCandidatesOptions {
12
13
  transformFilter: ReturnType<typeof createTransformFilter>;
13
14
  }
14
15
  export interface BundleMarkupCandidateCollection {
15
- candidatesByFile: Map<string, Set<string>>;
16
+ candidatesByFile: RuntimeCompilationBuildState['bundleMarkupCandidatesByFile'];
16
17
  values: Set<string>;
17
18
  valuesForEntries: (entries: TailwindSourceEntry[] | undefined, options?: SourceCandidateFilterOptions) => Set<string>;
18
19
  }
@@ -2,6 +2,7 @@ import type { OutputAsset, OutputChunk } from 'rollup';
2
2
  import type { ViteFrameworkCssPipelineContext, ViteFrameworkCssPipelineStrategy } from '../shared/framework-strategy.js';
3
3
  import type { InternalUserDefinedOptions } from '../../../types/index.js';
4
4
  export declare function resolveCssBundleOutputFile(options: {
5
+ assetOutputFile?: string | undefined;
5
6
  bundleFiles: string[];
6
7
  defaultStyleOutputExtension: string;
7
8
  file: string;
@@ -0,0 +1,6 @@
1
+ import type { OutputBundle } from 'rollup';
2
+ export declare function linkEntryChunkStyles(bundle: OutputBundle, options: {
3
+ matchesCss: (file: string) => boolean;
4
+ resolveOutputFile: (sourceFile: string) => string | undefined;
5
+ onUpdate?: ((file: string, oldVal: string, newVal: string) => void) | undefined;
6
+ }): void;
@@ -21,6 +21,7 @@ export declare function createConfiguredCssSourceRegistry(options: CreateConfigu
21
21
  resolveMatchedSourceOutputFile: (sourceFile: string) => string | undefined;
22
22
  };
23
23
  export interface CreateConfiguredCssRootResolversOptions {
24
+ rootImportShellTargets?: ReadonlyMap<string, string> | undefined;
24
25
  bundle: OutputBundle;
25
26
  bundleFiles: string[];
26
27
  cssPipelineContext: ViteFrameworkCssPipelineContext;
@@ -5,7 +5,7 @@ interface ViteServeJsTransformOptions {
5
5
  getCommand: () => string | undefined;
6
6
  jsHandler: InternalUserDefinedOptions['jsHandler'];
7
7
  shouldTransform: () => boolean;
8
- transformRuntime: () => Promise<Set<string>> | Set<string>;
8
+ transformRuntime: (id: string, source: string) => Promise<Set<string>> | Set<string>;
9
9
  }
10
10
  export declare function createViteServeJsTransformPlugin(options: ViteServeJsTransformOptions): Plugin;
11
11
  export {};
@@ -22,6 +22,8 @@ export interface ViteFrameworkBranchContext {
22
22
  sourceCandidatesBeforeExtraPlugin?: (plugin: Plugin) => boolean;
23
23
  }
24
24
  export interface ViteFrameworkExtraPluginContext {
25
+ cssPreflight: InternalUserDefinedOptions['cssPreflight'];
26
+ cssPreflightRange: InternalUserDefinedOptions['cssPreflightRange'];
25
27
  customAttributesEntities: ReturnType<typeof toCustomAttributesEntities>;
26
28
  disabledDefaultTemplateHandler: boolean | undefined;
27
29
  ensureRuntimeClassSet: (...args: any[]) => Promise<Set<string>>;
@@ -11,5 +11,5 @@ interface FrameworkModuleCandidateRegistrarOptions {
11
11
  sourceCandidateCollector: Pick<SourceCandidateStore, 'syncModuleSource'>;
12
12
  styleHandler: ValidateCandidatesByGeneratorOptions['styleHandler'];
13
13
  }
14
- export declare function createFrameworkModuleCandidateRegistrar(options: FrameworkModuleCandidateRegistrarOptions): (id: string, source: string) => Promise<Set<string>>;
14
+ export declare function createFrameworkModuleCandidateRegistrar(options: FrameworkModuleCandidateRegistrarOptions): (id: string, source: string, extension?: string) => Promise<Set<string>>;
15
15
  export {};
@@ -1,8 +1,10 @@
1
+ import type { Compiler } from 'webpack';
1
2
  interface WebpackWatchDependencyLoaderContext {
3
+ fs?: Pick<NonNullable<Compiler['inputFileSystem']>, 'stat'>;
2
4
  addDependency?: (file: string) => void;
3
5
  addMissingDependency?: (file: string) => void;
4
6
  addContextDependency?: (context: string) => void;
5
7
  }
6
- export declare function registerWebpackWatchFile(loaderContext: WebpackWatchDependencyLoaderContext, file: string): void;
8
+ export declare function registerWebpackWatchFile(loaderContext: WebpackWatchDependencyLoaderContext, file: string): Promise<void> | undefined;
7
9
  export declare function registerWebpackWatchContext(loaderContext: WebpackWatchDependencyLoaderContext, context: string): void;
8
10
  export {};
@@ -1,6 +1,7 @@
1
1
  export interface LoaderEntry {
2
2
  loader?: string;
3
3
  }
4
+ export declare function findCssPreprocessorIndex(entries: LoaderEntry[]): number;
4
5
  export interface LoaderAnchorFinders {
5
6
  findRewriteAnchor: (entries: LoaderEntry[]) => number;
6
7
  findClassSetAnchor: (entries: LoaderEntry[]) => number;
@@ -29,7 +29,10 @@ export interface RuntimeCompilationBuildState {
29
29
  runtimeAffectingHashByFile: Map<string, string>;
30
30
  linkedByEntry: Map<string, Set<string>>;
31
31
  dependentsByLinkedFile: Map<string, Set<string>>;
32
- bundleMarkupCandidatesByFile: Map<string, Set<string>>;
32
+ bundleMarkupCandidatesByFile: Map<string, {
33
+ sourceFile: string;
34
+ candidates: Set<string>;
35
+ }>;
33
36
  generatorCandidateSignature?: string | undefined;
34
37
  }
35
38
  export interface CreateRuntimeCompilationSnapshotOptions {
@@ -1,9 +1,9 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-Ctb5zv51.cjs");
2
2
  const require_framework = require("./framework.cjs");
3
- const require_generator = require("./generator-DsrQ9txU.cjs");
4
- const require_tailwindcss = require("./tailwindcss-C-jBBQfw.cjs");
3
+ const require_generator = require("./generator-CCw17l0G.cjs");
4
+ const require_tailwindcss = require("./tailwindcss-DhaLV5a2.cjs");
5
5
  require("./utils-CuKLf1Zv.cjs");
6
- const require_defaults = require("./defaults-BI9j1znS.cjs");
6
+ const require_defaults = require("./defaults-CiGsr8Xq.cjs");
7
7
  let node_path = require("node:path");
8
8
  node_path = require_rolldown_runtime.__toESM(node_path, 1);
9
9
  let node_process = require("node:process");
@@ -22974,8 +22974,8 @@ var StatementParser = class extends ExpressionParser {
22974
22974
  return this.finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement");
22975
22975
  }
22976
22976
  verifyBreakContinue(node, isBreak) {
22977
- let i;
22978
- for (i = 0; i < this.state.labels.length; ++i) {
22977
+ let i = 0;
22978
+ for (; i < this.state.labels.length; ++i) {
22979
22979
  const lab = this.state.labels[i];
22980
22980
  if (node.label == null || lab.name === node.label.name) {
22981
22981
  if (lab.kind != null && (isBreak || lab.kind === 1)) break;
@@ -40031,7 +40031,7 @@ function toCustomAttributesEntities(customAttributes) {
40031
40031
  return Object.entries(customAttributes);
40032
40032
  }
40033
40033
  //#endregion
40034
- //#region ../../node_modules/.pnpm/oxc-walker@1.1.1_@oxc-project+types@0.147.0_oxc-parser@0.147.0_rolldown@1.2.6/node_modules/oxc-walker/dist/index.mjs
40034
+ //#region ../../node_modules/.pnpm/oxc-walker@1.1.1_@oxc-project+types@0.148.0_oxc-parser@0.148.0_rolldown@1.2.7/node_modules/oxc-walker/dist/index.mjs
40035
40035
  function isNode(v) {
40036
40036
  return v !== null && typeof v === "object" && typeof v.type === "string";
40037
40037
  }
@@ -1,8 +1,8 @@
1
1
  import { resolveMpxPlatform } from "./framework.js";
2
- import { A as resolveBooleanObjectOption, Bt as resolveValidTailwindV4Candidates$1, Ft as resolveCssMacroTailwindV4Source, Mt as _defineProperty, Rt as shouldUseUniAppWebRpxCompatibility, T as omitUndefined, Tt as isFileMatchedByTailwindSourceEntries, a as resolveGeneratorRuntimeBranch, bt as createTailwindV4Engine$1, d as resolveTailwindV4SourceFromRuntime, i as normalizeWeappTailwindcssGeneratorOptions, t as createWeappTailwindcssGenerator, u as resolveTailwindV4Source$1, zt as loadTailwindV4DesignSystem } from "./generator-DyXTBPmE.js";
3
- import { c as getRuntimeClassSetCacheEntry, d as invalidateRuntimeClassSet, i as resolveUniAppXOptions, o as applyV4CssCalcDefaults, s as warnMissingCssEntries, t as createTailwindcssRuntimeFromContext, u as getRuntimeClassSetSignatureWithSources } from "./tailwindcss-BK9S7zuq.js";
2
+ import { A as resolveBooleanObjectOption, Bt as shouldUseUniAppWebRpxCompatibility, Ht as resolveValidTailwindV4Candidates$1, Lt as resolveCssMacroTailwindV4Source, Mt as _defineProperty, T as omitUndefined, Tt as isFileMatchedByTailwindSourceEntries, Vt as loadTailwindV4DesignSystem, a as resolveGeneratorRuntimeBranch, bt as createTailwindV4Engine$1, d as resolveTailwindV4SourceFromRuntime, i as normalizeWeappTailwindcssGeneratorOptions, t as createWeappTailwindcssGenerator, u as resolveTailwindV4Source$1 } from "./generator-DxEsInLz.js";
3
+ import { c as getRuntimeClassSetCacheEntry, d as invalidateRuntimeClassSet, i as resolveUniAppXOptions, o as applyV4CssCalcDefaults, s as warnMissingCssEntries, t as createTailwindcssRuntimeFromContext, u as getRuntimeClassSetSignatureWithSources } from "./tailwindcss-D2joPNdN.js";
4
4
  import { i as isMap, n as defuOverrideArray$1 } from "./utils-MVwpU07P.js";
5
- import { a as DEFAULT_PARSE_CACHE_MAX_SOURCE_LENGTH, i as resolveDefaultCssPreflight, o as HARD_PARSE_CACHE_MAX_ENTRIES, r as getDefaultOptions } from "./defaults-B5ep0ojb.js";
5
+ import { a as DEFAULT_PARSE_CACHE_MAX_SOURCE_LENGTH, i as resolveDefaultCssPreflight, o as HARD_PARSE_CACHE_MAX_ENTRIES, r as getDefaultOptions } from "./defaults-CKx-4LcW.js";
6
6
  import { createRequire } from "node:module";
7
7
  import path from "node:path";
8
8
  import process from "node:process";
package/dist/core.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_compiler = require("./compiler-SwMb3lOX.cjs");
2
+ const require_compiler = require("./compiler-BSMSbVVt.cjs");
3
3
  const require_runtime_state = require("./runtime-state-BBQcA0n5.cjs");
4
4
  let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
5
5
  let _weapp_tailwindcss_shared = require("@weapp-tailwindcss/shared");
package/dist/core.js CHANGED
@@ -1,4 +1,4 @@
1
- import { C as createTailwindRuntimeReadyPromise, D as createCompilationEventBus, d as createCompiler, f as getCompilerContext, t as createCompilerRuntimeState, v as shouldSkipJsTransform, w as ensureRuntimeClassSet } from "./compiler-B0YSc0DY.js";
1
+ import { C as createTailwindRuntimeReadyPromise, D as createCompilationEventBus, d as createCompiler, f as getCompilerContext, t as createCompilerRuntimeState, v as shouldSkipJsTransform, w as ensureRuntimeClassSet } from "./compiler-tHMcW3BT.js";
2
2
  import { finalizeMiniProgramCss, finalizeMiniProgramCssRoot, postcss, removeTailwindSourceDirectivesRoot } from "@weapp-tailwindcss/postcss";
3
3
  import { defuOverrideArray } from "@weapp-tailwindcss/shared";
4
4
  //#region src/core.ts
@@ -1,9 +1,32 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-Ctb5zv51.cjs");
2
+ const require_generator = require("./generator-CCw17l0G.cjs");
2
3
  let node_path = require("node:path");
3
4
  node_path = require_rolldown_runtime.__toESM(node_path, 1);
5
+ let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
4
6
  //#region src/bundlers/shared/css-imports.ts
5
7
  const tailwindcssImportRE = /^(?:tailwindcss|weapp-tailwindcss)(?:\/.*)?$/;
6
8
  const tailwindcssCssImportStatementRE = /(@import\s+(?:url\(\s*)?)(["'])((?:tailwindcss|weapp-tailwindcss)(?:\/[^"']*)?\$?)(\2\s*\)?)/gi;
9
+ function normalizeResolvedTailwindcssImports(code, pkgDir) {
10
+ if (!pkgDir) return code;
11
+ const paths = /^[a-z]:[\\/]|^\\\\/i.test(pkgDir) ? node_path.default.win32 : node_path.default.posix;
12
+ const root = _weapp_tailwindcss_postcss.postcss.parse(code);
13
+ let changed = false;
14
+ root.walkAtRules("import", (rule) => {
15
+ const parsed = require_generator.parseCssImportSpecifier(rule.params);
16
+ if (!parsed || !paths.isAbsolute(parsed.specifier)) return;
17
+ const subpath = paths.relative(pkgDir, parsed.specifier);
18
+ if (![
19
+ "index.css",
20
+ "theme.css",
21
+ "utilities.css",
22
+ "preflight.css"
23
+ ].includes(subpath)) return;
24
+ const request = subpath === "index.css" ? "tailwindcss" : `tailwindcss/${subpath}`;
25
+ rule.params = rule.params.replace(parsed.raw, () => require_generator.quoteCssImportSpecifier(request, parsed.quote));
26
+ changed = true;
27
+ });
28
+ return changed ? root.toString() : code;
29
+ }
7
30
  function normalizeTailwindcssSpecifier(specifier) {
8
31
  if (specifier === "tailwindcss$" || specifier === "weapp-tailwindcss$") return specifier.slice(0, -1);
9
32
  return specifier;
@@ -29,6 +52,12 @@ function rewriteTailwindcssImportsInCode(code, pkgDir, options) {
29
52
  return hasReplacements ? rewritten : void 0;
30
53
  }
31
54
  //#endregion
55
+ Object.defineProperty(exports, "normalizeResolvedTailwindcssImports", {
56
+ enumerable: true,
57
+ get: function() {
58
+ return normalizeResolvedTailwindcssImports;
59
+ }
60
+ });
32
61
  Object.defineProperty(exports, "resolveTailwindcssImport", {
33
62
  enumerable: true,
34
63
  get: function() {
@@ -1,6 +1,7 @@
1
1
  //#region src/bundlers/webpack/shared/css-loader-runtime.ts
2
2
  function isWebpackCssLoaderRuntimeSource(source) {
3
- return source.includes("___CSS_LOADER_EXPORT___") && source.includes("___CSS_LOADER_API_IMPORT___") && source.includes("module.exports = ___CSS_LOADER_EXPORT___");
3
+ if (source.trimStart().startsWith("// extracted by mini-css-extract-plugin")) return true;
4
+ return source.includes("___CSS_LOADER_EXPORT___") && source.includes("___CSS_LOADER_API_IMPORT___") && (source.includes("module.exports = ___CSS_LOADER_EXPORT___") || source.includes("export default ___CSS_LOADER_EXPORT___"));
4
5
  }
5
6
  //#endregion
6
7
  Object.defineProperty(exports, "isWebpackCssLoaderRuntimeSource", {
@@ -6,7 +6,7 @@ const HARD_PARSE_CACHE_MAX_ENTRIES = 1024;
6
6
  //#endregion
7
7
  //#region src/defaults.ts
8
8
  const CSS_FILE_PATTERN = /.+\.(?:wx|ac|jx|tt|q|c|ty)ss$/;
9
- const HTML_FILE_PATTERN = /.+\.(?:(?:wx|ax|jx|ks|tt|q|ty|xhs)ml|swan)$/;
9
+ const HTML_FILE_PATTERN = /.+\.(?:(?:wx|ax|jx|ks|tt|q|qx|ty|xhs)ml|swan)$/;
10
10
  const JS_FILE_PATTERN = /.+\.[cm]?js?$/;
11
11
  const alwaysFalse = () => false;
12
12
  const TAILWIND_V4_CSS_PREFLIGHT = {
@@ -7,7 +7,7 @@ const HARD_PARSE_CACHE_MAX_ENTRIES = 1024;
7
7
  //#endregion
8
8
  //#region src/defaults.ts
9
9
  const CSS_FILE_PATTERN = /.+\.(?:wx|ac|jx|tt|q|c|ty)ss$/;
10
- const HTML_FILE_PATTERN = /.+\.(?:(?:wx|ax|jx|ks|tt|q|ty|xhs)ml|swan)$/;
10
+ const HTML_FILE_PATTERN = /.+\.(?:(?:wx|ax|jx|ks|tt|q|qx|ty|xhs)ml|swan)$/;
11
11
  const JS_FILE_PATTERN = /.+\.[cm]?js?$/;
12
12
  const alwaysFalse = () => false;
13
13
  const TAILWIND_V4_CSS_PREFLIGHT = {
package/dist/defaults.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_defaults = require("./defaults-BI9j1znS.cjs");
2
+ const require_defaults = require("./defaults-CiGsr8Xq.cjs");
3
3
  exports.TAILWIND_V4_CSS_PREFLIGHT = require_defaults.TAILWIND_V4_CSS_PREFLIGHT;
4
4
  exports.getDefaultCssPreflight = require_defaults.getDefaultCssPreflight;
5
5
  exports.getDefaultOptions = require_defaults.getDefaultOptions;
package/dist/defaults.js CHANGED
@@ -1,2 +1,2 @@
1
- import { i as resolveDefaultCssPreflight, n as getDefaultCssPreflight, r as getDefaultOptions, t as TAILWIND_V4_CSS_PREFLIGHT } from "./defaults-B5ep0ojb.js";
1
+ import { i as resolveDefaultCssPreflight, n as getDefaultCssPreflight, r as getDefaultOptions, t as TAILWIND_V4_CSS_PREFLIGHT } from "./defaults-CKx-4LcW.js";
2
2
  export { TAILWIND_V4_CSS_PREFLIGHT, getDefaultCssPreflight, getDefaultOptions, resolveDefaultCssPreflight };
@@ -1,4 +1,4 @@
1
- import { postcss, removeEmptyAtRules, repairTrailingUnclosedTailwindSourceMedia } from "@weapp-tailwindcss/postcss";
1
+ import { postcss, removeEmptyAtRules, removeEmptyRules, repairTrailingUnclosedTailwindSourceMedia } from "@weapp-tailwindcss/postcss";
2
2
  //#region src/compiler/runtime-build-state.ts
3
3
  function invertLinkedByEntry(linkedByEntry) {
4
4
  const dependentsByLinkedFile = /* @__PURE__ */ new Map();
@@ -181,17 +181,44 @@ async function processCachedTask({ cache, cacheKey, hashKey = cacheKey, rawSourc
181
181
  }
182
182
  //#endregion
183
183
  //#region src/bundlers/shared/final-css-cleanup.ts
184
- function isAtRuleNameCharacter(code) {
185
- return code === 45 || code >= 65 && code <= 90 || code >= 97 && code <= 122;
186
- }
187
184
  function isCssWhitespace(code) {
188
185
  return code === 9 || code === 10 || code === 12 || code === 13 || code === 32;
189
186
  }
190
- function findAtRuleBlockStart(css, start) {
187
+ function isCssWordChar(code) {
188
+ return code >= 48 && code <= 57 || code >= 65 && code <= 90 || code >= 97 && code <= 122 || code === 95;
189
+ }
190
+ const EMPTY_CSS_BLOCK_RE = /\{(?:[\t\n\f\r ]|\/\*(?:[^*]|\*(?!\/))*\*\/)*\}/;
191
+ function findCssPreludeStart(css, start, end) {
192
+ let cursor = start;
193
+ while (cursor < end) {
194
+ while (cursor < end && isCssWhitespace(css.charCodeAt(cursor))) cursor++;
195
+ if (css.charCodeAt(cursor) !== 47 || css.charCodeAt(cursor + 1) !== 42) return cursor;
196
+ const commentEnd = css.indexOf("*/", cursor + 2);
197
+ if (commentEnd < 0 || commentEnd + 2 > end) return end;
198
+ cursor = commentEnd + 2;
199
+ }
200
+ return end;
201
+ }
202
+ function isKeyframesAtRule(css, start, end) {
203
+ let cursor = start + 1;
204
+ if (css.charCodeAt(cursor) === 45) {
205
+ cursor++;
206
+ const prefixStart = cursor;
207
+ while (cursor < end && isCssWordChar(css.charCodeAt(cursor))) cursor++;
208
+ if (cursor === prefixStart || css.charCodeAt(cursor) !== 45) return false;
209
+ cursor++;
210
+ }
211
+ if (cursor + 9 > end || css.slice(cursor, cursor + 9).toLowerCase() !== "keyframes") return false;
212
+ return !isCssWordChar(css.charCodeAt(cursor + 9));
213
+ }
214
+ function hasEmptyCssBlockCandidate(css) {
215
+ if (!EMPTY_CSS_BLOCK_RE.test(css)) return false;
216
+ const blocks = [];
191
217
  let parenthesisDepth = 0;
192
218
  let quote = 0;
193
219
  let squareBracketDepth = 0;
194
- for (let index = start; index < css.length; index++) {
220
+ let statementStart = 0;
221
+ for (let index = 0; index < css.length; index++) {
195
222
  const code = css.charCodeAt(index);
196
223
  if (quote !== 0) {
197
224
  if (code === 92) index++;
@@ -200,15 +227,17 @@ function findAtRuleBlockStart(css, start) {
200
227
  }
201
228
  if (code === 34 || code === 39) {
202
229
  quote = code;
230
+ if (blocks.length > 0) blocks[blocks.length - 1].hasContent = true;
203
231
  continue;
204
232
  }
205
233
  if (code === 92) {
234
+ if (blocks.length > 0) blocks[blocks.length - 1].hasContent = true;
206
235
  index++;
207
236
  continue;
208
237
  }
209
238
  if (code === 47 && css.charCodeAt(index + 1) === 42) {
210
239
  const commentEnd = css.indexOf("*/", index + 2);
211
- if (commentEnd < 0) return -1;
240
+ if (commentEnd < 0) return false;
212
241
  index = commentEnd + 1;
213
242
  continue;
214
243
  }
@@ -228,49 +257,46 @@ function findAtRuleBlockStart(css, start) {
228
257
  squareBracketDepth--;
229
258
  continue;
230
259
  }
231
- if (code === 123 && parenthesisDepth === 0 && squareBracketDepth === 0) return index;
232
- if ((code === 59 || code === 125) && parenthesisDepth === 0 && squareBracketDepth === 0) return -1;
233
- }
234
- return -1;
235
- }
236
- function isEmptyAtRuleBody(css, blockStart) {
237
- for (let index = blockStart + 1; index < css.length; index++) {
238
- const code = css.charCodeAt(index);
239
- if (isCssWhitespace(code)) continue;
240
- if (code === 47 && css.charCodeAt(index + 1) === 42) {
241
- const commentEnd = css.indexOf("*/", index + 2);
242
- if (commentEnd < 0) return false;
243
- index = commentEnd + 1;
260
+ if (code === 123 && parenthesisDepth === 0 && squareBracketDepth === 0) {
261
+ const preludeStart = findCssPreludeStart(css, statementStart, index);
262
+ const isAtRule = css.charCodeAt(preludeStart) === 64;
263
+ const isKeyframesContainer = isAtRule && isKeyframesAtRule(css, preludeStart, index);
264
+ blocks.push({
265
+ hasContent: false,
266
+ isKeyframesContainer,
267
+ isKeyframeStep: !isAtRule && blocks[blocks.length - 1]?.isKeyframesContainer === true
268
+ });
269
+ statementStart = index + 1;
244
270
  continue;
245
271
  }
246
- return code === 125;
247
- }
248
- return false;
249
- }
250
- function hasEmptyAtRuleBlockCandidate(css) {
251
- let searchFrom = 0;
252
- while (searchFrom < css.length) {
253
- const atRuleStart = css.indexOf("@", searchFrom);
254
- if (atRuleStart < 0) return false;
255
- searchFrom = atRuleStart + 1;
256
- if (!isAtRuleNameCharacter(css.charCodeAt(searchFrom))) continue;
257
- const blockStart = findAtRuleBlockStart(css, searchFrom + 1);
258
- if (blockStart >= 0 && isEmptyAtRuleBody(css, blockStart)) return true;
272
+ if (code === 125 && parenthesisDepth === 0 && squareBracketDepth === 0) {
273
+ const block = blocks.pop();
274
+ if (!block) continue;
275
+ if (!block.hasContent && !block.isKeyframeStep) return true;
276
+ if (blocks.length > 0) blocks[blocks.length - 1].hasContent = true;
277
+ statementStart = index + 1;
278
+ continue;
279
+ }
280
+ if (code === 59 && parenthesisDepth === 0 && squareBracketDepth === 0) {
281
+ statementStart = index + 1;
282
+ continue;
283
+ }
284
+ if (!isCssWhitespace(code) && blocks.length > 0) blocks[blocks.length - 1].hasContent = true;
259
285
  }
260
286
  return false;
261
287
  }
262
288
  /**
263
- * 在小程序样式进入最终产物图时递归清理空的块级 at-rule。
289
+ * 在小程序样式进入最终产物图时递归清理无语义的空 CSS 块。
264
290
  */
265
291
  function finalizeMiniProgramCssStructure(css) {
266
292
  const repaired = repairTrailingUnclosedTailwindSourceMedia(css);
267
- if (!hasEmptyAtRuleBlockCandidate(repaired)) return repaired;
293
+ if (!hasEmptyCssBlockCandidate(repaired)) return repaired;
268
294
  try {
269
295
  const root = postcss.parse(repaired);
270
296
  let removed = 0;
271
297
  let passRemoved = 0;
272
298
  do {
273
- passRemoved = removeEmptyAtRules(root);
299
+ passRemoved = removeEmptyRules(root) + removeEmptyAtRules(root);
274
300
  removed += passRemoved;
275
301
  } while (passRemoved > 0);
276
302
  return removed > 0 ? root.toString() : repaired;
@@ -279,4 +305,4 @@ function finalizeMiniProgramCssStructure(css) {
279
305
  }
280
306
  }
281
307
  //#endregion
282
- export { createRuntimeCompilationAffectingSignature as a, resetRuntimeCompilationBuildState as c, buildRuntimeCompilationSnapshot as i, updateRuntimeCompilationBuildState as l, hasEmptyAtRuleBlockCandidate as n, createRuntimeCompilationBuildState as o, processCachedTask as r, removeRuntimeCompilationBuildStateFiles as s, finalizeMiniProgramCssStructure as t };
308
+ export { createRuntimeCompilationAffectingSignature as a, resetRuntimeCompilationBuildState as c, buildRuntimeCompilationSnapshot as i, updateRuntimeCompilationBuildState as l, hasEmptyCssBlockCandidate as n, createRuntimeCompilationBuildState as o, processCachedTask as r, removeRuntimeCompilationBuildStateFiles as s, finalizeMiniProgramCssStructure as t };