weapp-tailwindcss 5.0.0-next.9 → 5.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.
Files changed (167) hide show
  1. package/README.md +2 -2
  2. package/dist/auto-DEHRmEAx.mjs +200 -0
  3. package/dist/auto-dPpsm6FB.js +238 -0
  4. package/dist/bundle-state-CBF5YX1m.js +529 -0
  5. package/dist/bundle-state-CQmxxx0R.mjs +413 -0
  6. package/dist/bundlers/shared/cache.d.ts +9 -7
  7. package/dist/bundlers/shared/css-cleanup/at-rules.d.ts +1 -2
  8. package/dist/bundlers/shared/css-cleanup.d.ts +1 -3
  9. package/dist/bundlers/shared/css-imports.d.ts +3 -3
  10. package/dist/bundlers/shared/generated-css-marker.d.ts +3 -0
  11. package/dist/bundlers/shared/generator-css/directives.d.ts +11 -3
  12. package/dist/bundlers/shared/generator-css/markers.d.ts +12 -0
  13. package/dist/bundlers/shared/generator-css/source-files.d.ts +9 -6
  14. package/dist/bundlers/shared/generator-css/source-resolver.d.ts +16 -2
  15. package/dist/bundlers/shared/generator-css/user-layer-order.d.ts +10 -0
  16. package/dist/bundlers/shared/generator-css.d.ts +6 -2
  17. package/dist/bundlers/shared/hmr-timing.d.ts +22 -0
  18. package/dist/bundlers/shared/style-requests.d.ts +2 -0
  19. package/dist/bundlers/vite/bundle-state.d.ts +1 -0
  20. package/dist/bundlers/vite/css-finalizer.d.ts +6 -0
  21. package/dist/bundlers/vite/generate-bundle/candidates.d.ts +1 -1
  22. package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +5 -1
  23. package/dist/bundlers/vite/generate-bundle/css-share-scope.d.ts +1 -0
  24. package/dist/bundlers/vite/generate-bundle.d.ts +13 -1
  25. package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +10 -2
  26. package/dist/bundlers/vite/index.d.ts +5 -2
  27. package/dist/bundlers/vite/processed-css-assets.d.ts +32 -0
  28. package/dist/bundlers/vite/rewrite-css-imports.d.ts +8 -5
  29. package/dist/bundlers/vite/runtime-class-set.d.ts +5 -1
  30. package/dist/bundlers/vite/serve-css-generation.d.ts +11 -0
  31. package/dist/bundlers/vite/source-candidates.d.ts +24 -2
  32. package/dist/bundlers/vite/source-scan.d.ts +26 -0
  33. package/dist/bundlers/vite/static-config-content.d.ts +5 -0
  34. package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +5 -0
  35. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +5 -1
  36. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +8 -3
  37. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +1 -1
  38. package/dist/bundlers/webpack/loaders/runtime-registry.d.ts +31 -0
  39. package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +2 -8
  40. package/dist/bundlers/webpack/loaders/weapp-tw-runtime-classset-loader.d.ts +3 -7
  41. package/dist/cache/index.d.ts +6 -6
  42. package/dist/{chunk-8l464Juk.js → chunk-C5U5_Hdc.js} +14 -0
  43. package/dist/cli/context.d.ts +1 -11
  44. package/dist/cli/doctor/types.d.ts +11 -11
  45. package/dist/cli/vscode-entry.d.ts +3 -3
  46. package/dist/cli.js +684 -41
  47. package/dist/cli.mjs +682 -40
  48. package/dist/context/runtime-package-replacements.d.ts +2 -0
  49. package/dist/context/style-options.d.ts +3 -0
  50. package/dist/context/tailwindcss.d.ts +1 -1
  51. package/dist/core.js +1 -2
  52. package/dist/core.mjs +1 -1
  53. package/dist/css-macro/auto.d.ts +11 -0
  54. package/dist/css-macro/constants.d.ts +5 -2
  55. package/dist/css-macro/postcss.d.ts +1 -0
  56. package/dist/css-macro/postcss.js +7 -46
  57. package/dist/css-macro/postcss.mjs +2 -46
  58. package/dist/css-macro.js +16 -7
  59. package/dist/css-macro.mjs +15 -6
  60. package/dist/defaults-8xrgzxFY.mjs +151 -0
  61. package/dist/defaults-zKUH2mDe.js +193 -0
  62. package/dist/defaults.js +6 -150
  63. package/dist/defaults.mjs +1 -143
  64. package/dist/escape.js +10 -2
  65. package/dist/escape.mjs +10 -2
  66. package/dist/generator/options.d.ts +11 -6
  67. package/dist/generator/types.d.ts +3 -3
  68. package/dist/generator-CvmsIQFI.js +92 -0
  69. package/dist/generator-DDtsUvkH.mjs +67 -0
  70. package/dist/generator.js +12 -12
  71. package/dist/generator.mjs +2 -1
  72. package/dist/gulp.js +163 -40
  73. package/dist/gulp.mjs +155 -32
  74. package/dist/incremental-runtime-class-set-BffodqHh.js +2366 -0
  75. package/dist/incremental-runtime-class-set-DArodvWs.mjs +2291 -0
  76. package/dist/index.d.ts +2 -1
  77. package/dist/index.js +17 -5
  78. package/dist/index.mjs +6 -5
  79. package/dist/js/babel/cache-options.d.ts +3 -0
  80. package/dist/js/babel/parse.d.ts +7 -4
  81. package/dist/js/precheck.d.ts +2 -2
  82. package/dist/js/replacement-cache.d.ts +5 -0
  83. package/dist/{postcss-w48mGIhe.mjs → postcss-BzNYQUOH.mjs} +54 -114
  84. package/dist/postcss-C7BMYpEF.mjs +169 -0
  85. package/dist/postcss-CiYLsqZn.js +192 -0
  86. package/dist/{postcss-QIXwT40c.js → postcss-DE0TOtV9.js} +60 -121
  87. package/dist/postcss-html-transform.js +1 -1
  88. package/dist/postcss.js +1 -1
  89. package/dist/postcss.mjs +1 -1
  90. package/dist/precheck-BzYPm-EG.js +4842 -0
  91. package/dist/precheck-jZvTVXXG.mjs +4716 -0
  92. package/dist/presets/index.d.ts +1 -0
  93. package/dist/presets/uni-app-x.d.ts +1 -0
  94. package/dist/presets.js +27 -13
  95. package/dist/presets.mjs +25 -13
  96. package/dist/reset.js +1 -1
  97. package/dist/runtime-registry-DpcR3IHI.js +5496 -0
  98. package/dist/shared/mpx.d.ts +1 -0
  99. package/dist/source-candidates-BuTlMabx.mjs +322 -0
  100. package/dist/source-candidates-CxoIaS88.js +335 -0
  101. package/dist/tailwindcss/miniprogram.d.ts +1 -5
  102. package/dist/tailwindcss/remove-unsupported-css.d.ts +1 -2
  103. package/dist/tailwindcss/runtime/cache.d.ts +4 -3
  104. package/dist/tailwindcss/runtime.d.ts +9 -9
  105. package/dist/tailwindcss/source-scan.d.ts +35 -0
  106. package/dist/tailwindcss/v3-engine/types.d.ts +19 -14
  107. package/dist/tailwindcss/v4/css-entries.d.ts +2 -2
  108. package/dist/tailwindcss/v4/patcher.d.ts +1 -1
  109. package/dist/tailwindcss/v4-engine/source.d.ts +2 -2
  110. package/dist/tailwindcss/v4-engine/types.d.ts +18 -5
  111. package/dist/{tailwindcss-C5IgPlQ0.mjs → tailwindcss-CCZcu0lr.mjs} +75 -98
  112. package/dist/{tailwindcss-Bu-RWIHx.js → tailwindcss-DZckITp1.js} +83 -106
  113. package/dist/typedoc.export.d.ts +1 -1
  114. package/dist/types/index.d.ts +51 -41
  115. package/dist/types/shared.d.ts +3 -0
  116. package/dist/types/typedoc-tailwindcss-patch.d.ts +67 -0
  117. package/dist/types/user-defined-options/general.d.ts +25 -22
  118. package/dist/types/user-defined-options/important.d.ts +32 -27
  119. package/dist/types/user-defined-options/lifecycle.d.ts +4 -4
  120. package/dist/types/user-defined-options/matcher.d.ts +6 -6
  121. package/dist/unocss/index.d.ts +2 -0
  122. package/dist/utils/object.d.ts +9 -0
  123. package/dist/utils/options.d.ts +2 -0
  124. package/dist/utils/regex.d.ts +1 -0
  125. package/dist/{utils-BiShvil9.js → utils-D7Ygohep.js} +2 -2
  126. package/dist/{utils-Btw1iOVV.mjs → utils-DsaS975I.mjs} +1 -1
  127. package/dist/v3-engine-DGBhUnjn.mjs +3419 -0
  128. package/dist/v3-engine-M6Aqru5T.js +3714 -0
  129. package/dist/vite-BBcQIJpD.mjs +24493 -0
  130. package/dist/vite-DgRkWVPG.js +24507 -0
  131. package/dist/vite.js +1 -1
  132. package/dist/vite.mjs +1 -1
  133. package/dist/weapp-tw-css-import-rewrite-loader.js +5456 -22
  134. package/dist/weapp-tw-runtime-classset-loader.js +32 -9
  135. package/dist/{webpack-BzN2ly34.js → webpack-D-gb4ZvO.js} +341 -96
  136. package/dist/{webpack-DJazm5sT.mjs → webpack-D43aMQzO.mjs} +323 -79
  137. package/dist/webpack.d.ts +1 -3
  138. package/dist/webpack.js +3 -4
  139. package/dist/webpack.mjs +2 -2
  140. package/dist/wxml/utils/codegen/legacy-visitor.d.ts +2 -4
  141. package/package.json +22 -20
  142. package/dist/bundlers/shared/css-cleanup/color-gamut.d.ts +0 -3
  143. package/dist/bundlers/shared/css-cleanup/root-cleanups.d.ts +0 -4
  144. package/dist/bundlers/shared/css-cleanup/selectors.d.ts +0 -8
  145. package/dist/cache-BVAiJV3J.js +0 -502
  146. package/dist/cache-CHs4DXui.mjs +0 -434
  147. package/dist/constants-BoB_6lFw.js +0 -73
  148. package/dist/constants-E_loJC49.mjs +0 -44
  149. package/dist/generator-DKkhJbOg.js +0 -1531
  150. package/dist/generator-UBmfduYg.mjs +0 -1432
  151. package/dist/generator-css-Bwp3nbrl.js +0 -1381
  152. package/dist/generator-css-DeLLmp2N.mjs +0 -1342
  153. package/dist/lightningcss/index.d.ts +0 -8
  154. package/dist/lightningcss/style-handler/options.d.ts +0 -3
  155. package/dist/lightningcss/style-handler/selector-transform.d.ts +0 -10
  156. package/dist/lightningcss/style-handler/selector-utils.d.ts +0 -10
  157. package/dist/lightningcss/style-handler.d.ts +0 -17
  158. package/dist/precheck-B32p-gLI.js +0 -2736
  159. package/dist/precheck-B4RH6ZNN.mjs +0 -2622
  160. package/dist/run-tasks-B50A3pxt.js +0 -128
  161. package/dist/run-tasks-DdNi-hkk.mjs +0 -91
  162. package/dist/runtime-patch-CwN5ya72.mjs +0 -71
  163. package/dist/runtime-patch-D6mBo_KB.js +0 -85
  164. package/dist/vite-By5KQi9s.js +0 -2419
  165. package/dist/vite-Cyp42bBf.mjs +0 -2406
  166. /package/dist/{logger-Bub1jggA.mjs → logger-BNzxZbZj.mjs} +0 -0
  167. /package/dist/{logger-BRy6XPQ2.js → logger-TlKT3xmR.js} +0 -0
@@ -2,26 +2,26 @@ import type { RefreshTailwindcssPatcherOptions, TailwindcssPatcherLike } from '.
2
2
  import { invalidateRuntimeClassSet } from './runtime/cache';
3
3
  export declare const refreshTailwindcssPatcherSymbol: unique symbol;
4
4
  export interface CollectRuntimeClassSetOptions {
5
- force?: boolean;
6
- skipRefresh?: boolean;
7
- clearCache?: boolean;
5
+ force?: boolean | undefined;
6
+ skipRefresh?: boolean | undefined;
7
+ clearCache?: boolean | undefined;
8
8
  }
9
9
  export interface RefreshTailwindRuntimeStateOptions {
10
10
  force: boolean;
11
- clearCache?: boolean;
11
+ clearCache?: boolean | undefined;
12
12
  }
13
13
  export declare function createTailwindRuntimeReadyPromise(twPatcher: TailwindcssPatcherLike): Promise<void>;
14
14
  export interface TailwindRuntimeState {
15
15
  twPatcher: TailwindcssPatcherLike;
16
16
  readyPromise: Promise<void>;
17
- refreshTailwindcssPatcher?: (options?: RefreshTailwindcssPatcherOptions) => Promise<TailwindcssPatcherLike>;
17
+ refreshTailwindcssPatcher?: ((options?: RefreshTailwindcssPatcherOptions) => Promise<TailwindcssPatcherLike>) | undefined;
18
18
  }
19
19
  export declare function refreshTailwindRuntimeState(state: TailwindRuntimeState, forceOrOptions: boolean | RefreshTailwindRuntimeStateOptions): Promise<boolean>;
20
20
  export interface EnsureRuntimeClassSetOptions {
21
- forceRefresh?: boolean;
22
- forceCollect?: boolean;
23
- clearCache?: boolean;
24
- allowEmpty?: boolean;
21
+ forceRefresh?: boolean | undefined;
22
+ forceCollect?: boolean | undefined;
23
+ clearCache?: boolean | undefined;
24
+ allowEmpty?: boolean | undefined;
25
25
  }
26
26
  export declare function ensureRuntimeClassSet(state: TailwindRuntimeState, options?: EnsureRuntimeClassSetOptions): Promise<Set<string>>;
27
27
  declare function collectRuntimeClassSet(twPatcher: TailwindcssPatcherLike, options?: CollectRuntimeClassSetOptions): Promise<Set<string>>;
@@ -0,0 +1,35 @@
1
+ import type { Root } from 'postcss';
2
+ import type { TailwindV4CssSource } from 'tailwindcss-patch';
3
+ export interface TailwindSourceEntry {
4
+ base: string;
5
+ pattern: string;
6
+ negated: boolean;
7
+ }
8
+ export interface TailwindInlineSourceCandidates {
9
+ included: Set<string>;
10
+ excluded: Set<string>;
11
+ }
12
+ export declare const DEFAULT_SOURCE_SCAN_EXTENSIONS: string[];
13
+ export declare const FULL_SOURCE_SCAN_EXTENSIONS: string[];
14
+ export declare function createSourceScanPattern(extensions?: string[]): string;
15
+ export declare const FULL_SOURCE_SCAN_PATTERN: string;
16
+ export declare const FULL_SOURCE_SCAN_EXTENSION_RE: RegExp;
17
+ export declare function toPosixPath(value: string): string;
18
+ export declare function resolveSourceScanPath(value: string): string;
19
+ export declare function isFileExcludedByTailwindSourceEntries(file: string, entries: TailwindSourceEntry[] | undefined): boolean;
20
+ export declare function isFileMatchedByTailwindSourceEntries(file: string, entries: TailwindSourceEntry[] | undefined): boolean;
21
+ export declare function createTailwindSourceEntryMatcher(entries: TailwindSourceEntry[] | undefined): ((file: string) => boolean) | undefined;
22
+ export declare function resolveTailwindV4CssSourceBase(source: Pick<TailwindV4CssSource, 'base' | 'file'>, fallbackBase: string): string;
23
+ export declare function parseConfigParam(params: string): string | undefined;
24
+ export declare function expandInlineSourceCandidatePattern(pattern: string): string[];
25
+ export declare function collectCssInlineSourceCandidates(root: Root): TailwindInlineSourceCandidates;
26
+ export declare function normalizeLegacyContentEntries(content: unknown, base: string): TailwindSourceEntry[];
27
+ export declare function resolveTailwindSourceEntry(sourcePath: string, base: string, negated: boolean, defaultPattern?: string): Promise<TailwindSourceEntry>;
28
+ export declare function parseSourceFileParam(params: string): {
29
+ negated: boolean;
30
+ sourcePath: string;
31
+ } | undefined;
32
+ export declare function resolveCssSourceEntries(root: Root, base: string, defaultPattern?: string): Promise<TailwindSourceEntry[]>;
33
+ export declare function expandTailwindSourceEntries(entries: TailwindSourceEntry[], options?: {
34
+ ignore?: string[];
35
+ }): Promise<string[]>;
@@ -1,9 +1,10 @@
1
1
  import type { IStyleHandlerOptions } from '@weapp-tailwindcss/postcss/types';
2
2
  import type { Config } from 'tailwindcss';
3
+ import type { IArbitraryValues } from '../../types/shared';
3
4
  export type TailwindV3GenerateTarget = 'weapp' | 'web' | 'tailwind';
4
5
  export interface TailwindV3CandidateSource {
5
6
  content: string;
6
- extension?: string;
7
+ extension?: string | undefined;
7
8
  }
8
9
  export interface TailwindV3SourcePattern {
9
10
  base: string;
@@ -11,13 +12,13 @@ export interface TailwindV3SourcePattern {
11
12
  negated: boolean;
12
13
  }
13
14
  export interface TailwindV3SourceOptions {
14
- projectRoot?: string;
15
- cwd?: string;
16
- base?: string;
17
- css?: string;
18
- config?: string;
19
- packageName?: string;
20
- postcssPlugin?: string;
15
+ projectRoot?: string | undefined;
16
+ cwd?: string | undefined;
17
+ base?: string | undefined;
18
+ css?: string | undefined;
19
+ config?: string | undefined;
20
+ packageName?: string | undefined;
21
+ postcssPlugin?: string | undefined;
21
22
  }
22
23
  export interface TailwindV3ResolvedSource {
23
24
  version: 3;
@@ -25,21 +26,25 @@ export interface TailwindV3ResolvedSource {
25
26
  cwd: string;
26
27
  base: string;
27
28
  css: string;
28
- config?: string;
29
- configObject?: Config;
29
+ config?: string | undefined;
30
+ configObject?: Config | undefined;
30
31
  dependencies: string[];
31
32
  packageName: string;
32
33
  postcssPlugin: string;
33
34
  }
34
35
  export interface TailwindV3GenerateOptions {
35
- candidates?: Iterable<string>;
36
- sources?: TailwindV3CandidateSource[];
37
- target?: TailwindV3GenerateTarget;
38
- styleOptions?: Partial<IStyleHandlerOptions>;
36
+ candidates?: Iterable<string> | undefined;
37
+ sources?: TailwindV3CandidateSource[] | undefined;
38
+ bareArbitraryValues?: IArbitraryValues['bareArbitraryValues'] | undefined;
39
+ incrementalCache?: boolean | undefined;
40
+ target?: TailwindV3GenerateTarget | undefined;
41
+ styleOptions?: Partial<IStyleHandlerOptions> | undefined;
39
42
  }
40
43
  export interface TailwindV3GenerateResult {
41
44
  css: string;
42
45
  rawCss: string;
46
+ incrementalCss?: string | undefined;
47
+ incrementalRawCss?: string | undefined;
43
48
  classSet: Set<string>;
44
49
  rawCandidates: Set<string>;
45
50
  dependencies: string[];
@@ -1,7 +1,7 @@
1
1
  export declare function guessBasedirFromEntries(entries?: string[]): string | undefined;
2
2
  export declare function normalizeCssEntries(entries: string[] | undefined, anchor: string): string[] | undefined;
3
3
  export interface GroupCssEntriesOptions {
4
- preferredBaseDir?: string;
5
- workspaceRoot?: string;
4
+ preferredBaseDir?: string | undefined;
5
+ workspaceRoot?: string | undefined;
6
6
  }
7
7
  export declare function groupCssEntriesByBase(entries: string[], options?: GroupCssEntriesOptions): Map<string, string[]>;
@@ -11,5 +11,5 @@ export interface TailwindcssPatcherFactoryOptions {
11
11
  appType: InternalUserDefinedOptions['appType'];
12
12
  bareArbitraryValues?: InternalUserDefinedOptions['arbitraryValues']['bareArbitraryValues'];
13
13
  }
14
- export declare function createPatcherForBase(baseDir: string, cssEntries: string[] | undefined, options: TailwindcssPatcherFactoryOptions): TailwindcssPatcherLike | undefined;
14
+ export declare function createPatcherForBase(baseDir: string, cssEntries: string[] | undefined, options: TailwindcssPatcherFactoryOptions): TailwindcssPatcherLike;
15
15
  export declare function tryCreateMultiTailwindcssPatcher(groups: Map<string, string[]>, options: TailwindcssPatcherFactoryOptions): TailwindcssPatcherLike | undefined;
@@ -1,7 +1,7 @@
1
- import type { TailwindV4SourceOptions } from './types';
1
+ import type { TailwindV4SourceOptions, TailwindV4SourceOptionsWithSources } from './types';
2
2
  import type { TailwindcssPatcherLike } from '../../types';
3
3
  import { resolveTailwindV4SourceFromPatchOptions } from 'tailwindcss-patch';
4
- export declare function resolveTailwindV4SourceOptionsFromPatcher(patcher: TailwindcssPatcherLike): TailwindV4SourceOptions;
4
+ export declare function resolveTailwindV4SourceOptionsFromPatcher(patcher: TailwindcssPatcherLike): TailwindV4SourceOptionsWithSources;
5
5
  export declare function resolveTailwindV4Source(options?: TailwindV4SourceOptions): Promise<import("tailwindcss-patch").TailwindV4ResolvedSource>;
6
6
  export declare function resolveTailwindV4SourceFromPatcher(patcher: TailwindcssPatcherLike): Promise<import("tailwindcss-patch").TailwindV4ResolvedSource>;
7
7
  export { resolveTailwindV4SourceFromPatchOptions };
@@ -1,15 +1,28 @@
1
1
  import type { IStyleHandlerOptions } from '@weapp-tailwindcss/postcss/types';
2
2
  import type { TailwindV4Engine as PatchTailwindV4Engine, TailwindV4GenerateOptions as PatchTailwindV4GenerateOptions, TailwindV4GenerateResult as PatchTailwindV4GenerateResult, TailwindV4CandidateSource, TailwindV4DesignSystem, TailwindV4ResolvedSource, TailwindV4SourceOptions } from 'tailwindcss-patch';
3
3
  export type TailwindV4GenerateTarget = 'weapp' | 'web' | 'tailwind';
4
- export interface TailwindV4GenerateOptions extends PatchTailwindV4GenerateOptions {
5
- target?: TailwindV4GenerateTarget;
6
- styleOptions?: Partial<IStyleHandlerOptions>;
7
- tailwindcssV3Compatibility?: boolean;
8
- scanSources?: PatchTailwindV4GenerateOptions['scanSources'];
4
+ export interface TailwindV4SourcePattern {
5
+ base: string;
6
+ pattern: string;
7
+ negated: boolean;
8
+ }
9
+ type TailwindV4PatchGenerateOptions = Omit<PatchTailwindV4GenerateOptions, 'target' | 'styleOptions' | 'tailwindcssV3Compatibility' | 'scanSources'>;
10
+ export interface TailwindV4GenerateOptions extends TailwindV4PatchGenerateOptions {
11
+ incrementalCache?: boolean | undefined;
12
+ bareArbitraryValues?: PatchTailwindV4GenerateOptions['bareArbitraryValues'] | undefined;
13
+ target?: TailwindV4GenerateTarget | undefined;
14
+ styleOptions?: Partial<IStyleHandlerOptions> | undefined;
15
+ tailwindcssV3Compatibility?: boolean | undefined;
16
+ scanSources?: PatchTailwindV4GenerateOptions['scanSources'] | undefined;
17
+ }
18
+ export interface TailwindV4SourceOptionsWithSources extends TailwindV4SourceOptions {
19
+ sources?: TailwindV4SourcePattern[] | undefined;
9
20
  }
10
21
  export interface TailwindV4GenerateResult extends Omit<PatchTailwindV4GenerateResult, 'css'> {
11
22
  css: string;
12
23
  rawCss: string;
24
+ incrementalCss?: string | undefined;
25
+ incrementalRawCss?: string | undefined;
13
26
  target: TailwindV4GenerateTarget;
14
27
  }
15
28
  export interface TailwindV4Engine extends Omit<PatchTailwindV4Engine, 'generate'> {
@@ -1,10 +1,10 @@
1
- import { a as createTailwindcssPatcher, d as findWorkspaceRoot, i as runtimeSignaturePatchersSymbol, l as findNearestPackageRoot, o as readInstalledPackageMajorVersion, u as findWorkspacePackageDir } from "./cache-CHs4DXui.mjs";
2
- import { n as defuOverrideArray } from "./utils-Btw1iOVV.mjs";
1
+ import { G as normalizeStringListOption, H as readInstalledPackageMajorVersion, J as findNearestPackageRoot, V as createTailwindcssPatcher, X as findWorkspaceRoot, Y as findWorkspacePackageDir, f as runtimeSignaturePatchersSymbol, q as omitUndefined } from "./v3-engine-DGBhUnjn.mjs";
2
+ import { n as defuOverrideArray } from "./utils-DsaS975I.mjs";
3
3
  import { createRequire } from "node:module";
4
- import path from "node:path";
4
+ import { existsSync, readFileSync } from "node:fs";
5
5
  import process from "node:process";
6
+ import path from "node:path";
6
7
  import { logger } from "@weapp-tailwindcss/logger";
7
- import { existsSync, readFileSync } from "node:fs";
8
8
  import { fileURLToPath } from "node:url";
9
9
  //#region src/tailwindcss/v4/css-sources.ts
10
10
  function hasCssEntriesValue(value) {
@@ -23,18 +23,23 @@ function normalizeCssSourceFile(file) {
23
23
  if (!file) return;
24
24
  return path.isAbsolute(file) ? path.normalize(file) : file;
25
25
  }
26
+ function normalizeCssSourceBase(base) {
27
+ if (!base) return;
28
+ return path.resolve(base);
29
+ }
26
30
  function normalizeDependencies(dependencies) {
27
31
  return dependencies?.map(normalizeCssSourceFile).filter((dependency) => typeof dependency === "string" && dependency.length > 0);
28
32
  }
29
33
  function isSameCssSource(a, b) {
30
- return a.css === b.css && a.base === b.base && normalizeCssSourceFile(a.file) === normalizeCssSourceFile(b.file) && JSON.stringify(normalizeDependencies(a.dependencies)) === JSON.stringify(normalizeDependencies(b.dependencies));
34
+ return a.css === b.css && normalizeCssSourceBase(a.base) === normalizeCssSourceBase(b.base) && normalizeCssSourceFile(a.file) === normalizeCssSourceFile(b.file) && JSON.stringify(normalizeDependencies(a.dependencies)) === JSON.stringify(normalizeDependencies(b.dependencies));
31
35
  }
32
36
  function upsertTailwindV4CssSource(opts, source) {
33
- const normalizedSource = {
37
+ const normalizedSource = omitUndefined({
34
38
  ...source,
39
+ ...source.base === void 0 ? {} : { base: normalizeCssSourceBase(source.base) },
35
40
  ...source.file === void 0 ? {} : { file: normalizeCssSourceFile(source.file) },
36
41
  ...source.dependencies === void 0 ? {} : { dependencies: normalizeDependencies(source.dependencies) }
37
- };
42
+ });
38
43
  const tailwindcss = opts.tailwindcss ?? {};
39
44
  const v4 = tailwindcss.v4 ?? {};
40
45
  const cssSources = [...v4.cssSources ?? []];
@@ -42,6 +47,10 @@ function upsertTailwindV4CssSource(opts, source) {
42
47
  const existingIndex = cssSources.findIndex((candidate) => normalizeCssSourceFile(candidate.file) === sourceFile);
43
48
  if (existingIndex >= 0) {
44
49
  const existing = cssSources[existingIndex];
50
+ if (!existing) {
51
+ cssSources[existingIndex] = normalizedSource;
52
+ return true;
53
+ }
45
54
  const nextSource = {
46
55
  ...existing,
47
56
  ...normalizedSource
@@ -98,14 +107,7 @@ function ensureDefaultsIncluded(value) {
98
107
  return value;
99
108
  }
100
109
  function normalizeCssEntriesConfig(entries) {
101
- if (!entries) return;
102
- if (typeof entries === "string") {
103
- const trimmed = entries.trim();
104
- return trimmed ? [trimmed] : void 0;
105
- }
106
- if (!Array.isArray(entries)) return;
107
- const normalized = entries.map((entry) => typeof entry === "string" ? entry.trim() : "").filter((entry) => entry.length > 0);
108
- return normalized.length > 0 ? normalized : void 0;
110
+ return normalizeStringListOption(entries);
109
111
  }
110
112
  function hasConfiguredCssEntries(ctx) {
111
113
  if (normalizeCssEntriesConfig(ctx.cssEntries)) return true;
@@ -132,7 +134,11 @@ function applyV4CssCalcDefaults(cssCalc, patcher) {
132
134
  //#endregion
133
135
  //#region src/tailwindcss/v4/multi-patcher.ts
134
136
  function createMultiTailwindcssPatcher(patchers) {
135
- if (patchers.length <= 1) return patchers[0];
137
+ if (patchers.length <= 1) {
138
+ const [patcher] = patchers;
139
+ if (!patcher) throw new Error("createMultiTailwindcssPatcher requires at least one patcher.");
140
+ return patcher;
141
+ }
136
142
  const first = patchers[0];
137
143
  const firstWithoutPatch = { ...first };
138
144
  delete firstWithoutPatch.patch;
@@ -163,11 +169,11 @@ function createMultiTailwindcssPatcher(patchers) {
163
169
  }
164
170
  if (result.classSet) for (const className of result.classSet) aggregatedSet.add(className);
165
171
  }
166
- return {
172
+ return omitUndefined({
167
173
  classList: aggregatedList,
168
174
  classSet: aggregatedSet,
169
175
  filename
170
- };
176
+ });
171
177
  }
172
178
  };
173
179
  if (patchers.every((patcher) => typeof patcher.getClassSetSync === "function")) multiPatcher.getClassSetSync = () => {
@@ -259,34 +265,26 @@ function groupCssEntriesByBase(entries, options = {}) {
259
265
  }
260
266
  //#endregion
261
267
  //#region src/tailwindcss/v4/patcher.ts
262
- const CONFIGURED_TAILWIND_VERSION_RE = /Configured tailwindcss\.version=\d+/u;
263
- const RESOLVED_TAILWIND_VERSION_RE = /resolved package ".+" is version /u;
264
268
  function isTailwindcss4Package(packageName) {
265
269
  return Boolean(packageName && (packageName === "tailwindcss4" || packageName === "@tailwindcss/postcss" || packageName.includes("tailwindcss4")));
266
270
  }
267
271
  function resolveExplicitTailwindVersion(configuredVersion, configuredPackageName) {
268
272
  if (typeof configuredVersion === "number") return configuredVersion;
269
- if (configuredPackageName === "tailwindcss") return 3;
270
273
  if (isTailwindcss4Package(configuredPackageName)) return 4;
271
274
  }
272
- function hasOwnV4Signal(value) {
273
- return typeof value === "object" && value !== null && "v4" in value;
274
- }
275
- function isTailwindVersionMismatchError(error) {
276
- return error instanceof Error && CONFIGURED_TAILWIND_VERSION_RE.test(error.message) && RESOLVED_TAILWIND_VERSION_RE.test(error.message);
277
- }
278
275
  function createPatcherForBase(baseDir, cssEntries, options) {
279
276
  const { tailwindcss, tailwindcssPatcherOptions, supportCustomLengthUnitsPatch, bareArbitraryValues } = options;
280
277
  const hasCssEntries = Boolean(cssEntries?.length);
281
- const mergedTailwindOptions = defuOverrideArray(tailwindcss ?? {}, {
278
+ const defaultTailwindcssConfig = {
282
279
  cwd: baseDir,
283
280
  v2: { cwd: baseDir },
284
281
  v3: { cwd: baseDir },
285
- v4: hasCssEntries ? { cssEntries } : {
282
+ v4: hasCssEntries ? omitUndefined({ cssEntries }) : omitUndefined({
286
283
  base: baseDir,
287
284
  cssEntries
288
- }
289
- });
285
+ })
286
+ };
287
+ const mergedTailwindOptions = defuOverrideArray(tailwindcss ?? {}, defaultTailwindcssConfig);
290
288
  if (!mergedTailwindOptions.v4) mergedTailwindOptions.v4 = hasCssEntries ? { cssEntries: cssEntries ?? [] } : {
291
289
  base: baseDir,
292
290
  cssEntries: cssEntries ?? []
@@ -302,69 +300,48 @@ function createPatcherForBase(baseDir, cssEntries, options) {
302
300
  const patchedOptions = overrideTailwindcssPatcherOptionsForBase(tailwindcssPatcherOptions, baseDir, cssEntries ?? []);
303
301
  const configuredPackageName = tailwindcss?.packageName || tailwindcssPatcherOptions?.tailwindcss?.packageName;
304
302
  const explicitTailwindVersion = resolveExplicitTailwindVersion(tailwindcss?.version || tailwindcssPatcherOptions?.tailwindcss?.version || mergedTailwindOptions.version, configuredPackageName);
305
- const hasExplicitV4Signals = hasCssEntries || hasOwnV4Signal(tailwindcss) || hasOwnV4Signal(tailwindcssPatcherOptions?.tailwindcss);
306
- const packageNameForVersionDetection = configuredPackageName ?? mergedTailwindOptions.packageName ?? "tailwindcss";
307
- const installedTailwindVersion = readInstalledPackageMajorVersion(packageNameForVersionDetection, baseDir);
308
- const resolvedTailwindVersion = installedTailwindVersion ?? explicitTailwindVersion;
309
- const shouldPatchV4PostcssPackage = (resolvedTailwindVersion === 4 && (installedTailwindVersion === 4 || explicitTailwindVersion === 4 || hasExplicitV4Signals && isTailwindcss4Package(packageNameForVersionDetection)) || resolvedTailwindVersion === void 0 && (hasCssEntries || hasOwnV4Signal(tailwindcss) || hasOwnV4Signal(tailwindcssPatcherOptions?.tailwindcss))) && !Boolean(configuredPackageName);
310
- const packageCandidates = /* @__PURE__ */ new Set();
311
- if (shouldPatchV4PostcssPackage) packageCandidates.add("@tailwindcss/postcss");
312
- packageCandidates.add(mergedTailwindOptions.packageName ?? configuredPackageName ?? "tailwindcss");
313
- const patchers = [];
314
- const packageCandidateList = [...packageCandidates];
315
- let firstVersionMismatchError;
316
- for (const packageName of packageCandidateList) {
317
- const tailwindOptionsForPackage = {
318
- ...mergedTailwindOptions,
319
- packageName
320
- };
321
- if (resolvedTailwindVersion) tailwindOptionsForPackage.version = resolvedTailwindVersion;
322
- try {
323
- patchers.push(createTailwindcssPatcher({
324
- basedir: baseDir,
325
- supportCustomLengthUnitsPatch: supportCustomLengthUnitsPatch ?? true,
326
- tailwindcss: tailwindOptionsForPackage,
327
- tailwindcssPatcherOptions: patchedOptions
328
- }));
329
- } catch (error) {
330
- if (packageCandidateList.length > 1 && isTailwindVersionMismatchError(error)) {
331
- firstVersionMismatchError ?? (firstVersionMismatchError = error);
332
- logger.warn("skip incompatible Tailwind package candidate \"%s\" for v4 patcher: %s", packageName, error.message);
333
- continue;
334
- }
335
- throw error;
336
- }
337
- }
338
- if (patchers.length === 0 && firstVersionMismatchError) throw firstVersionMismatchError;
339
- return patchers.length === 1 ? patchers[0] : createMultiTailwindcssPatcher(patchers);
303
+ const resolvedTailwindVersion = readInstalledPackageMajorVersion(configuredPackageName ?? mergedTailwindOptions.packageName ?? "tailwindcss", baseDir) ?? explicitTailwindVersion;
304
+ const supportedResolvedTailwindVersion = resolvedTailwindVersion === 2 || resolvedTailwindVersion === 3 || resolvedTailwindVersion === 4 ? resolvedTailwindVersion : void 0;
305
+ const tailwindOptionsForPackage = {
306
+ ...mergedTailwindOptions,
307
+ packageName: mergedTailwindOptions.packageName ?? configuredPackageName ?? "tailwindcss"
308
+ };
309
+ if (supportedResolvedTailwindVersion) tailwindOptionsForPackage.version = supportedResolvedTailwindVersion;
310
+ return createTailwindcssPatcher(omitUndefined({
311
+ basedir: baseDir,
312
+ supportCustomLengthUnitsPatch: supportCustomLengthUnitsPatch ?? true,
313
+ tailwindcss: tailwindOptionsForPackage,
314
+ tailwindcssPatcherOptions: patchedOptions
315
+ }));
340
316
  }
341
317
  function tryCreateMultiTailwindcssPatcher(groups, options) {
342
318
  if (groups.size <= 1) return;
343
319
  logger.debug("detected multiple Tailwind CSS entry bases: %O", [...groups.keys()]);
344
320
  const patchers = [];
345
- for (const [baseDir, entries] of groups) patchers.push(createPatcherForBase(baseDir, entries, options));
321
+ for (const [baseDir, entries] of groups) {
322
+ const patcher = createPatcherForBase(baseDir, entries, options);
323
+ if (patcher) patchers.push(patcher);
324
+ }
346
325
  return createMultiTailwindcssPatcher(patchers);
347
326
  }
348
327
  //#endregion
349
328
  //#region src/uni-app-x/options.ts
329
+ const DEFAULT_COMPONENT_LOCAL_STYLES_OPTIONS = {
330
+ enabled: true,
331
+ onlyWhenStyleIsolationVersion2: true
332
+ };
333
+ const DISABLED_COMPONENT_LOCAL_STYLES_OPTIONS = {
334
+ enabled: false,
335
+ onlyWhenStyleIsolationVersion2: true
336
+ };
337
+ function isBooleanUniAppXShortcut(option) {
338
+ return option === true || option === false || option === void 0;
339
+ }
350
340
  function resolveComponentLocalStyles(option) {
351
- if (option === false) return {
352
- enabled: false,
353
- onlyWhenStyleIsolationVersion2: true
354
- };
355
- if (option === true || option === void 0) return {
356
- enabled: false,
357
- onlyWhenStyleIsolationVersion2: true
358
- };
341
+ if (isBooleanUniAppXShortcut(option)) return DISABLED_COMPONENT_LOCAL_STYLES_OPTIONS;
359
342
  const componentLocalStyles = option.componentLocalStyles;
360
- if (componentLocalStyles === false) return {
361
- enabled: false,
362
- onlyWhenStyleIsolationVersion2: true
363
- };
364
- if (componentLocalStyles === true || componentLocalStyles === void 0) return {
365
- enabled: true,
366
- onlyWhenStyleIsolationVersion2: true
367
- };
343
+ if (componentLocalStyles === false) return DISABLED_COMPONENT_LOCAL_STYLES_OPTIONS;
344
+ if (componentLocalStyles === true || componentLocalStyles === void 0) return DEFAULT_COMPONENT_LOCAL_STYLES_OPTIONS;
368
345
  return {
369
346
  enabled: componentLocalStyles.enabled !== false,
370
347
  onlyWhenStyleIsolationVersion2: componentLocalStyles.onlyWhenStyleIsolationVersion2 !== false
@@ -410,12 +387,12 @@ function pickEnvBasedir() {
410
387
  }
411
388
  }
412
389
  function pickPackageEnvBasedir() {
413
- const packageJsonPath = process.env.npm_package_json;
390
+ const packageJsonPath = process.env["npm_package_json"];
414
391
  if (packageJsonPath) {
415
392
  const packageDir = path.dirname(packageJsonPath);
416
393
  if (packageDir && path.isAbsolute(packageDir)) return packageDir;
417
394
  }
418
- const localPrefix = process.env.npm_config_local_prefix;
395
+ const localPrefix = process.env["npm_config_local_prefix"];
419
396
  if (localPrefix && path.isAbsolute(localPrefix)) return localPrefix;
420
397
  }
421
398
  const STACK_PAREN_RE = /\(([^)]+)\)/u;
@@ -423,7 +400,7 @@ const STACK_AT_RE = /at\s+(\S.*)$/u;
423
400
  function detectCallerBasedir() {
424
401
  const stack = (/* @__PURE__ */ new Error("resolveTailwindcssBasedir stack probe")).stack;
425
402
  if (!stack) return;
426
- if (process.env.WEAPP_TW_DEBUG_STACK === "1") logger.debug("caller stack: %s", stack);
403
+ if (process.env["WEAPP_TW_DEBUG_STACK"] === "1") logger.debug("caller stack: %s", stack);
427
404
  const lines = stack.split("\n");
428
405
  for (const line of lines) {
429
406
  const location = (line.match(STACK_PAREN_RE) ?? line.match(STACK_AT_RE))?.[1];
@@ -434,7 +411,7 @@ function detectCallerBasedir() {
434
411
  } catch {
435
412
  continue;
436
413
  }
437
- const [candidate] = filePath.split(":");
414
+ const [candidate = ""] = filePath.split(":");
438
415
  const resolvedPath = path.isAbsolute(filePath) ? filePath : candidate;
439
416
  if (!path.isAbsolute(resolvedPath)) continue;
440
417
  if (resolvedPath.includes("node_modules") && resolvedPath.includes("weapp-tailwindcss")) continue;
@@ -455,7 +432,7 @@ function resolveTailwindcssBasedir(basedir, fallback) {
455
432
  const cwd = process.cwd();
456
433
  const anchor = envBasedir ?? packageEnvBasedir ?? fallback ?? callerBasedir ?? cwd;
457
434
  const resolveRelative = (value) => path.isAbsolute(value) ? path.normalize(value) : path.normalize(path.resolve(anchor, value));
458
- if (process.env.WEAPP_TW_DEBUG_STACK === "1") logger.debug("resolveTailwindcssBasedir anchor %O", {
435
+ if (process.env["WEAPP_TW_DEBUG_STACK"] === "1") logger.debug("resolveTailwindcssBasedir anchor %O", {
459
436
  basedir,
460
437
  envBasedir,
461
438
  envBasedirKey,
@@ -463,7 +440,7 @@ function resolveTailwindcssBasedir(basedir, fallback) {
463
440
  packageEnvBasedir,
464
441
  fallback,
465
442
  callerBasedir,
466
- npm_package_json: process.env.npm_package_json,
443
+ npm_package_json: process.env["npm_package_json"],
467
444
  cwd,
468
445
  anchor
469
446
  });
@@ -476,13 +453,13 @@ function resolveTailwindcssBasedir(basedir, fallback) {
476
453
  const librarySegment = `${path.sep}weapp-tailwindcss${path.sep}`;
477
454
  if (!normalizedCaller.includes(librarySegment)) return normalizedCaller;
478
455
  }
479
- const packageName = process.env.PNPM_PACKAGE_NAME;
456
+ const packageName = process.env["PNPM_PACKAGE_NAME"];
480
457
  if (packageName) try {
481
458
  const packageJsonPath = createRequire(path.join(anchor, "__resolve_tailwindcss_basedir__.cjs")).resolve(`${packageName}/package.json`);
482
- if (process.env.WEAPP_TW_DEBUG_STACK === "1") logger.debug("package basedir resolved from PNPM_PACKAGE_NAME: %s", packageJsonPath);
459
+ if (process.env["WEAPP_TW_DEBUG_STACK"] === "1") logger.debug("package basedir resolved from PNPM_PACKAGE_NAME: %s", packageJsonPath);
483
460
  return path.normalize(path.dirname(packageJsonPath));
484
461
  } catch {
485
- if (process.env.WEAPP_TW_DEBUG_STACK === "1") logger.debug("failed to resolve package json for %s", packageName);
462
+ if (process.env["WEAPP_TW_DEBUG_STACK"] === "1") logger.debug("failed to resolve package json for %s", packageName);
486
463
  const workspaceRoot = findWorkspaceRoot(anchor);
487
464
  if (workspaceRoot) {
488
465
  const packageDir = findWorkspacePackageDir(workspaceRoot, packageName);
@@ -501,8 +478,8 @@ function isRaxWorkspace(appType, baseDir) {
501
478
  if (!existsSync(pkgPath)) return false;
502
479
  const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
503
480
  const deps = {
504
- ...pkg.dependencies ?? {},
505
- ...pkg.devDependencies ?? {}
481
+ ...pkg["dependencies"] ?? {},
482
+ ...pkg["devDependencies"] ?? {}
506
483
  };
507
484
  if (deps["rax-app"] || deps.rax) return true;
508
485
  } catch {
@@ -531,8 +508,8 @@ function detectImplicitCssEntries(appType, baseDir) {
531
508
  baseCandidates.add(path.normalize(baseDir));
532
509
  const envCandidates = [
533
510
  process.cwd(),
534
- process.env.INIT_CWD,
535
- process.env.PWD
511
+ process.env["INIT_CWD"],
512
+ process.env["PWD"]
536
513
  ];
537
514
  for (const candidate of envCandidates) if (candidate) baseCandidates.add(path.normalize(candidate));
538
515
  for (const candidateBase of baseCandidates) {
@@ -560,10 +537,10 @@ function createTailwindcssPatcherFromContext(ctx) {
560
537
  bareArbitraryValues: arbitraryValues?.bareArbitraryValues
561
538
  };
562
539
  const workspaceRoot = findWorkspaceRoot(resolvedTailwindcssBasedir) ?? (absoluteCssEntryBasedir ? findWorkspaceRoot(absoluteCssEntryBasedir) : void 0);
563
- const groupedCssEntries = normalizedCssEntries ? groupCssEntriesByBase(normalizedCssEntries, {
540
+ const groupedCssEntries = normalizedCssEntries ? groupCssEntriesByBase(normalizedCssEntries, omitUndefined({
564
541
  preferredBaseDir: resolvedTailwindcssBasedir,
565
542
  workspaceRoot
566
- }) : void 0;
543
+ })) : void 0;
567
544
  const multiPatcher = groupedCssEntries ? tryCreateMultiTailwindcssPatcher(groupedCssEntries, patcherOptions) : void 0;
568
545
  if (multiPatcher) return multiPatcher;
569
546
  if (groupedCssEntries?.size === 1) {