weapp-tailwindcss 5.0.0-next.8 → 5.0.0

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-CnaJxkFY.mjs +413 -0
  5. package/dist/bundle-state-DgGEhk_z.js +529 -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 +12 -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--0-ekuVO.js +92 -0
  69. package/dist/generator-B76ovqsv.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-CN6K_97P.js +2366 -0
  75. package/dist/incremental-runtime-class-set-x10M9bn_.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-C7BMYpEF.mjs +169 -0
  84. package/dist/{postcss-w48mGIhe.mjs → postcss-CR9UCaIK.mjs} +54 -114
  85. package/dist/postcss-CiYLsqZn.js +192 -0
  86. package/dist/{postcss-QIXwT40c.js → postcss-hYimKoN_.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-BrNwLG2e.mjs +4716 -0
  91. package/dist/precheck-DPtJjZmV.js +4842 -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-DN1mihlU.mjs +322 -0
  100. package/dist/source-candidates-DSxme_O2.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-DWtPieNE.mjs} +72 -60
  112. package/dist/{tailwindcss-Bu-RWIHx.js → tailwindcss-glCm_d3H.js} +81 -69
  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-D3BMLVAN.js +3712 -0
  128. package/dist/v3-engine-DCxNPBVs.mjs +3417 -0
  129. package/dist/vite-DOprpdH-.mjs +24493 -0
  130. package/dist/vite-Ec0uX6kF.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 +5444 -22
  134. package/dist/weapp-tw-runtime-classset-loader.js +32 -9
  135. package/dist/{webpack-CNV2dx3Q.js → webpack-Ccohlg3A.js} +341 -96
  136. package/dist/{webpack-CT6EEENx.mjs → webpack-DFlZcqAU.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-BIapP56i.mjs +0 -1323
  152. package/dist/generator-css-Mksw8PgB.js +0 -1362
  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-BwgRVgxH.mjs +0 -2405
  165. package/dist/vite-DyZuiyap.js +0 -2418
  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-DCxNPBVs.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 = () => {
@@ -278,15 +284,18 @@ function isTailwindVersionMismatchError(error) {
278
284
  function createPatcherForBase(baseDir, cssEntries, options) {
279
285
  const { tailwindcss, tailwindcssPatcherOptions, supportCustomLengthUnitsPatch, bareArbitraryValues } = options;
280
286
  const hasCssEntries = Boolean(cssEntries?.length);
281
- const mergedTailwindOptions = defuOverrideArray(tailwindcss ?? {}, {
287
+ const configuredV4Options = tailwindcss?.v4 ?? tailwindcssPatcherOptions?.tailwindcss?.v4;
288
+ const hasCssSources = Boolean(configuredV4Options?.cssSources?.length);
289
+ const defaultTailwindcssConfig = {
282
290
  cwd: baseDir,
283
291
  v2: { cwd: baseDir },
284
292
  v3: { cwd: baseDir },
285
- v4: hasCssEntries ? { cssEntries } : {
293
+ v4: hasCssEntries ? omitUndefined({ cssEntries }) : omitUndefined({
286
294
  base: baseDir,
287
295
  cssEntries
288
- }
289
- });
296
+ })
297
+ };
298
+ const mergedTailwindOptions = defuOverrideArray(tailwindcss ?? {}, defaultTailwindcssConfig);
290
299
  if (!mergedTailwindOptions.v4) mergedTailwindOptions.v4 = hasCssEntries ? { cssEntries: cssEntries ?? [] } : {
291
300
  base: baseDir,
292
301
  cssEntries: cssEntries ?? []
@@ -302,11 +311,12 @@ function createPatcherForBase(baseDir, cssEntries, options) {
302
311
  const patchedOptions = overrideTailwindcssPatcherOptionsForBase(tailwindcssPatcherOptions, baseDir, cssEntries ?? []);
303
312
  const configuredPackageName = tailwindcss?.packageName || tailwindcssPatcherOptions?.tailwindcss?.packageName;
304
313
  const explicitTailwindVersion = resolveExplicitTailwindVersion(tailwindcss?.version || tailwindcssPatcherOptions?.tailwindcss?.version || mergedTailwindOptions.version, configuredPackageName);
305
- const hasExplicitV4Signals = hasCssEntries || hasOwnV4Signal(tailwindcss) || hasOwnV4Signal(tailwindcssPatcherOptions?.tailwindcss);
314
+ const hasExplicitV4Signals = hasCssEntries || hasCssSources || hasOwnV4Signal(tailwindcss) || hasOwnV4Signal(tailwindcssPatcherOptions?.tailwindcss);
306
315
  const packageNameForVersionDetection = configuredPackageName ?? mergedTailwindOptions.packageName ?? "tailwindcss";
307
316
  const installedTailwindVersion = readInstalledPackageMajorVersion(packageNameForVersionDetection, baseDir);
308
317
  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);
318
+ const supportedResolvedTailwindVersion = resolvedTailwindVersion === 2 || resolvedTailwindVersion === 3 || resolvedTailwindVersion === 4 ? resolvedTailwindVersion : void 0;
319
+ const shouldPatchV4PostcssPackage = (resolvedTailwindVersion === 4 && (installedTailwindVersion === 4 || explicitTailwindVersion === 4 || hasExplicitV4Signals && isTailwindcss4Package(packageNameForVersionDetection)) || resolvedTailwindVersion === void 0 && (hasCssEntries || hasCssSources || hasOwnV4Signal(tailwindcss) || hasOwnV4Signal(tailwindcssPatcherOptions?.tailwindcss))) && !Boolean(configuredPackageName);
310
320
  const packageCandidates = /* @__PURE__ */ new Set();
311
321
  if (shouldPatchV4PostcssPackage) packageCandidates.add("@tailwindcss/postcss");
312
322
  packageCandidates.add(mergedTailwindOptions.packageName ?? configuredPackageName ?? "tailwindcss");
@@ -318,14 +328,14 @@ function createPatcherForBase(baseDir, cssEntries, options) {
318
328
  ...mergedTailwindOptions,
319
329
  packageName
320
330
  };
321
- if (resolvedTailwindVersion) tailwindOptionsForPackage.version = resolvedTailwindVersion;
331
+ if (supportedResolvedTailwindVersion) tailwindOptionsForPackage.version = supportedResolvedTailwindVersion;
322
332
  try {
323
- patchers.push(createTailwindcssPatcher({
333
+ patchers.push(createTailwindcssPatcher(omitUndefined({
324
334
  basedir: baseDir,
325
335
  supportCustomLengthUnitsPatch: supportCustomLengthUnitsPatch ?? true,
326
336
  tailwindcss: tailwindOptionsForPackage,
327
337
  tailwindcssPatcherOptions: patchedOptions
328
- }));
338
+ })));
329
339
  } catch (error) {
330
340
  if (packageCandidateList.length > 1 && isTailwindVersionMismatchError(error)) {
331
341
  firstVersionMismatchError ?? (firstVersionMismatchError = error);
@@ -336,35 +346,37 @@ function createPatcherForBase(baseDir, cssEntries, options) {
336
346
  }
337
347
  }
338
348
  if (patchers.length === 0 && firstVersionMismatchError) throw firstVersionMismatchError;
339
- return patchers.length === 1 ? patchers[0] : createMultiTailwindcssPatcher(patchers);
349
+ const [singlePatcher] = patchers;
350
+ return patchers.length === 1 && singlePatcher ? singlePatcher : createMultiTailwindcssPatcher(patchers);
340
351
  }
341
352
  function tryCreateMultiTailwindcssPatcher(groups, options) {
342
353
  if (groups.size <= 1) return;
343
354
  logger.debug("detected multiple Tailwind CSS entry bases: %O", [...groups.keys()]);
344
355
  const patchers = [];
345
- for (const [baseDir, entries] of groups) patchers.push(createPatcherForBase(baseDir, entries, options));
356
+ for (const [baseDir, entries] of groups) {
357
+ const patcher = createPatcherForBase(baseDir, entries, options);
358
+ if (patcher) patchers.push(patcher);
359
+ }
346
360
  return createMultiTailwindcssPatcher(patchers);
347
361
  }
348
362
  //#endregion
349
363
  //#region src/uni-app-x/options.ts
364
+ const DEFAULT_COMPONENT_LOCAL_STYLES_OPTIONS = {
365
+ enabled: true,
366
+ onlyWhenStyleIsolationVersion2: true
367
+ };
368
+ const DISABLED_COMPONENT_LOCAL_STYLES_OPTIONS = {
369
+ enabled: false,
370
+ onlyWhenStyleIsolationVersion2: true
371
+ };
372
+ function isBooleanUniAppXShortcut(option) {
373
+ return option === true || option === false || option === void 0;
374
+ }
350
375
  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
- };
376
+ if (isBooleanUniAppXShortcut(option)) return DISABLED_COMPONENT_LOCAL_STYLES_OPTIONS;
359
377
  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
- };
378
+ if (componentLocalStyles === false) return DISABLED_COMPONENT_LOCAL_STYLES_OPTIONS;
379
+ if (componentLocalStyles === true || componentLocalStyles === void 0) return DEFAULT_COMPONENT_LOCAL_STYLES_OPTIONS;
368
380
  return {
369
381
  enabled: componentLocalStyles.enabled !== false,
370
382
  onlyWhenStyleIsolationVersion2: componentLocalStyles.onlyWhenStyleIsolationVersion2 !== false
@@ -410,12 +422,12 @@ function pickEnvBasedir() {
410
422
  }
411
423
  }
412
424
  function pickPackageEnvBasedir() {
413
- const packageJsonPath = process.env.npm_package_json;
425
+ const packageJsonPath = process.env["npm_package_json"];
414
426
  if (packageJsonPath) {
415
427
  const packageDir = path.dirname(packageJsonPath);
416
428
  if (packageDir && path.isAbsolute(packageDir)) return packageDir;
417
429
  }
418
- const localPrefix = process.env.npm_config_local_prefix;
430
+ const localPrefix = process.env["npm_config_local_prefix"];
419
431
  if (localPrefix && path.isAbsolute(localPrefix)) return localPrefix;
420
432
  }
421
433
  const STACK_PAREN_RE = /\(([^)]+)\)/u;
@@ -423,7 +435,7 @@ const STACK_AT_RE = /at\s+(\S.*)$/u;
423
435
  function detectCallerBasedir() {
424
436
  const stack = (/* @__PURE__ */ new Error("resolveTailwindcssBasedir stack probe")).stack;
425
437
  if (!stack) return;
426
- if (process.env.WEAPP_TW_DEBUG_STACK === "1") logger.debug("caller stack: %s", stack);
438
+ if (process.env["WEAPP_TW_DEBUG_STACK"] === "1") logger.debug("caller stack: %s", stack);
427
439
  const lines = stack.split("\n");
428
440
  for (const line of lines) {
429
441
  const location = (line.match(STACK_PAREN_RE) ?? line.match(STACK_AT_RE))?.[1];
@@ -434,7 +446,7 @@ function detectCallerBasedir() {
434
446
  } catch {
435
447
  continue;
436
448
  }
437
- const [candidate] = filePath.split(":");
449
+ const [candidate = ""] = filePath.split(":");
438
450
  const resolvedPath = path.isAbsolute(filePath) ? filePath : candidate;
439
451
  if (!path.isAbsolute(resolvedPath)) continue;
440
452
  if (resolvedPath.includes("node_modules") && resolvedPath.includes("weapp-tailwindcss")) continue;
@@ -455,7 +467,7 @@ function resolveTailwindcssBasedir(basedir, fallback) {
455
467
  const cwd = process.cwd();
456
468
  const anchor = envBasedir ?? packageEnvBasedir ?? fallback ?? callerBasedir ?? cwd;
457
469
  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", {
470
+ if (process.env["WEAPP_TW_DEBUG_STACK"] === "1") logger.debug("resolveTailwindcssBasedir anchor %O", {
459
471
  basedir,
460
472
  envBasedir,
461
473
  envBasedirKey,
@@ -463,7 +475,7 @@ function resolveTailwindcssBasedir(basedir, fallback) {
463
475
  packageEnvBasedir,
464
476
  fallback,
465
477
  callerBasedir,
466
- npm_package_json: process.env.npm_package_json,
478
+ npm_package_json: process.env["npm_package_json"],
467
479
  cwd,
468
480
  anchor
469
481
  });
@@ -476,13 +488,13 @@ function resolveTailwindcssBasedir(basedir, fallback) {
476
488
  const librarySegment = `${path.sep}weapp-tailwindcss${path.sep}`;
477
489
  if (!normalizedCaller.includes(librarySegment)) return normalizedCaller;
478
490
  }
479
- const packageName = process.env.PNPM_PACKAGE_NAME;
491
+ const packageName = process.env["PNPM_PACKAGE_NAME"];
480
492
  if (packageName) try {
481
493
  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);
494
+ if (process.env["WEAPP_TW_DEBUG_STACK"] === "1") logger.debug("package basedir resolved from PNPM_PACKAGE_NAME: %s", packageJsonPath);
483
495
  return path.normalize(path.dirname(packageJsonPath));
484
496
  } catch {
485
- if (process.env.WEAPP_TW_DEBUG_STACK === "1") logger.debug("failed to resolve package json for %s", packageName);
497
+ if (process.env["WEAPP_TW_DEBUG_STACK"] === "1") logger.debug("failed to resolve package json for %s", packageName);
486
498
  const workspaceRoot = findWorkspaceRoot(anchor);
487
499
  if (workspaceRoot) {
488
500
  const packageDir = findWorkspacePackageDir(workspaceRoot, packageName);
@@ -501,8 +513,8 @@ function isRaxWorkspace(appType, baseDir) {
501
513
  if (!existsSync(pkgPath)) return false;
502
514
  const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
503
515
  const deps = {
504
- ...pkg.dependencies ?? {},
505
- ...pkg.devDependencies ?? {}
516
+ ...pkg["dependencies"] ?? {},
517
+ ...pkg["devDependencies"] ?? {}
506
518
  };
507
519
  if (deps["rax-app"] || deps.rax) return true;
508
520
  } catch {
@@ -531,8 +543,8 @@ function detectImplicitCssEntries(appType, baseDir) {
531
543
  baseCandidates.add(path.normalize(baseDir));
532
544
  const envCandidates = [
533
545
  process.cwd(),
534
- process.env.INIT_CWD,
535
- process.env.PWD
546
+ process.env["INIT_CWD"],
547
+ process.env["PWD"]
536
548
  ];
537
549
  for (const candidate of envCandidates) if (candidate) baseCandidates.add(path.normalize(candidate));
538
550
  for (const candidateBase of baseCandidates) {
@@ -560,10 +572,10 @@ function createTailwindcssPatcherFromContext(ctx) {
560
572
  bareArbitraryValues: arbitraryValues?.bareArbitraryValues
561
573
  };
562
574
  const workspaceRoot = findWorkspaceRoot(resolvedTailwindcssBasedir) ?? (absoluteCssEntryBasedir ? findWorkspaceRoot(absoluteCssEntryBasedir) : void 0);
563
- const groupedCssEntries = normalizedCssEntries ? groupCssEntriesByBase(normalizedCssEntries, {
575
+ const groupedCssEntries = normalizedCssEntries ? groupCssEntriesByBase(normalizedCssEntries, omitUndefined({
564
576
  preferredBaseDir: resolvedTailwindcssBasedir,
565
577
  workspaceRoot
566
- }) : void 0;
578
+ })) : void 0;
567
579
  const multiPatcher = groupedCssEntries ? tryCreateMultiTailwindcssPatcher(groupedCssEntries, patcherOptions) : void 0;
568
580
  if (multiPatcher) return multiPatcher;
569
581
  if (groupedCssEntries?.size === 1) {