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
@@ -1,6 +1,7 @@
1
1
  import type { AppType } from '../types';
2
2
  export declare function isMpx(appType?: AppType): appType is "mpx";
3
3
  export declare function getTailwindcssCssEntry(pkgDir: string): string;
4
+ export declare function patchMpxWebpackPluginNormalizeLib(compiler: any, mpxWebpackPluginDir: string | undefined): boolean;
4
5
  export declare function ensureMpxTailwindcssAliases(compiler: any, pkgDir: string): string;
5
6
  export declare function patchMpxLoaderResolve(loaderContext: any, pkgDir: string, enabled: boolean): void;
6
7
  export declare function setupMpxTailwindcssRedirect(pkgDir: string, enabled: boolean): void;
@@ -0,0 +1,322 @@
1
+ import { L as resolveSourceScanPath, N as isFileMatchedByTailwindSourceEntries, k as FULL_SOURCE_SCAN_EXTENSION_RE, z as toPosixPath } from "./v3-engine-DGBhUnjn.mjs";
2
+ import { extractSourceCandidates, resolveProjectSourceFiles } from "tailwindcss-patch";
3
+ import path from "node:path";
4
+ import { readFile } from "node:fs/promises";
5
+ //#region src/bundlers/vite/source-candidates.ts
6
+ const CLEAN_URL_RE = /[?#].*$/;
7
+ const TAILWIND_V4_IGNORED_CONTENT_DIRS = [
8
+ ".git",
9
+ ".hg",
10
+ ".jj",
11
+ ".next",
12
+ ".parcel-cache",
13
+ ".pnpm-store",
14
+ ".svelte-kit",
15
+ ".svn",
16
+ ".turbo",
17
+ ".venv",
18
+ ".vercel",
19
+ ".yarn",
20
+ "__pycache__",
21
+ "node_modules",
22
+ "venv"
23
+ ];
24
+ const TAILWIND_V4_IGNORED_EXTENSIONS = [
25
+ "css",
26
+ "less",
27
+ "postcss",
28
+ "pcss",
29
+ "lock",
30
+ "sass",
31
+ "scss",
32
+ "styl",
33
+ "stylus",
34
+ "log",
35
+ "wxss",
36
+ "acss",
37
+ "jxss",
38
+ "ttss",
39
+ "qss",
40
+ "tyss"
41
+ ];
42
+ const TAILWIND_V4_IGNORED_FILES = [
43
+ "package-lock.json",
44
+ "pnpm-lock.yaml",
45
+ "bun.lockb",
46
+ ".gitignore",
47
+ ".env",
48
+ ".env.*"
49
+ ];
50
+ const sourceCandidateContentCache = /* @__PURE__ */ new Map();
51
+ function cleanUrl(id) {
52
+ return resolveSourceScanPath(id.replace(CLEAN_URL_RE, ""));
53
+ }
54
+ function resolveOutDirIgnorePattern(root, outDir) {
55
+ if (!outDir) return;
56
+ const relative = path.relative(root, path.resolve(root, outDir));
57
+ if (!relative || relative.startsWith("..") || path.isAbsolute(relative)) return;
58
+ return `${toPosixPath(relative)}/**`;
59
+ }
60
+ function normalizeScanEntries(root, entries, outDirIgnore) {
61
+ const hasPositiveEntry = entries?.some((entry) => !entry.negated) === true;
62
+ const scanEntries = entries?.length ? hasPositiveEntry ? entries : [{
63
+ base: root,
64
+ pattern: "**/*",
65
+ negated: false
66
+ }, ...entries] : void 0;
67
+ if (!outDirIgnore) return scanEntries;
68
+ return [...scanEntries ?? [{
69
+ base: root,
70
+ pattern: "**/*",
71
+ negated: false
72
+ }], {
73
+ base: root,
74
+ pattern: outDirIgnore,
75
+ negated: true
76
+ }];
77
+ }
78
+ function shouldApplyDefaultIgnoredSources(entries) {
79
+ return entries?.length === void 0 ? false : entries.length > 0 && entries.every((entry) => entry.negated);
80
+ }
81
+ function createDefaultIgnoredSources(root, outDirIgnore, entries, explicit) {
82
+ return [...!explicit || shouldApplyDefaultIgnoredSources(entries) ? [
83
+ ...TAILWIND_V4_IGNORED_CONTENT_DIRS.map((pattern) => ({
84
+ base: root,
85
+ pattern: `**/${pattern}/**`,
86
+ negated: true
87
+ })),
88
+ ...TAILWIND_V4_IGNORED_EXTENSIONS.map((extension) => ({
89
+ base: root,
90
+ pattern: `**/*.${extension}`,
91
+ negated: true
92
+ })),
93
+ ...TAILWIND_V4_IGNORED_FILES.map((pattern) => ({
94
+ base: root,
95
+ pattern: `**/${pattern}`,
96
+ negated: true
97
+ }))
98
+ ] : [], ...outDirIgnore ? [{
99
+ base: root,
100
+ pattern: outDirIgnore,
101
+ negated: true
102
+ }] : []];
103
+ }
104
+ function resolveSourceCandidateExtension(id) {
105
+ const normalized = cleanUrl(id);
106
+ return /\.([^.\\/]+)$/.exec(normalized)?.[1] ?? "html";
107
+ }
108
+ function createSourceCandidateContentCacheKey(extension, source, bareArbitraryValues) {
109
+ return `${extension}\0${JSON.stringify(bareArbitraryValues ?? false)}\0${source}`;
110
+ }
111
+ function isSourceCandidateRequest(id) {
112
+ return FULL_SOURCE_SCAN_EXTENSION_RE.test(cleanUrl(id));
113
+ }
114
+ function removeCandidateSet(candidateCount, candidates) {
115
+ for (const candidate of candidates) {
116
+ const count = candidateCount.get(candidate);
117
+ if (count == null) continue;
118
+ if (count <= 1) {
119
+ candidateCount.delete(candidate);
120
+ continue;
121
+ }
122
+ candidateCount.set(candidate, count - 1);
123
+ }
124
+ }
125
+ function addCandidateSet(candidateCount, candidates) {
126
+ for (const candidate of candidates) candidateCount.set(candidate, (candidateCount.get(candidate) ?? 0) + 1);
127
+ }
128
+ function createSourceCandidateCollector(options = {}) {
129
+ const candidatesById = /* @__PURE__ */ new Map();
130
+ const scanCandidatesById = /* @__PURE__ */ new Map();
131
+ const transformCandidatesById = /* @__PURE__ */ new Map();
132
+ const cssCandidatesById = /* @__PURE__ */ new Map();
133
+ const candidateCount = /* @__PURE__ */ new Map();
134
+ let inlineIncludedCandidates = /* @__PURE__ */ new Set();
135
+ let inlineExcludedCandidates = /* @__PURE__ */ new Set();
136
+ async function sync(id, source) {
137
+ const normalizedId = cleanUrl(id);
138
+ const extension = resolveSourceCandidateExtension(normalizedId);
139
+ const contentCacheKey = createSourceCandidateContentCacheKey(extension, source, options.bareArbitraryValues);
140
+ const cachedCandidates = sourceCandidateContentCache.get(contentCacheKey);
141
+ if (cachedCandidates) {
142
+ replaceScanLayer(normalizedId, new Set(cachedCandidates));
143
+ return;
144
+ }
145
+ const nextCandidates = new Set(await extractSourceCandidates(source, extension, { bareArbitraryValues: options.bareArbitraryValues }));
146
+ sourceCandidateContentCache.set(contentCacheKey, [...nextCandidates]);
147
+ replaceScanLayer(normalizedId, nextCandidates);
148
+ }
149
+ async function syncCss(id, source) {
150
+ const normalizedId = cleanUrl(id);
151
+ const contentCacheKey = createSourceCandidateContentCacheKey("css", source, options.bareArbitraryValues);
152
+ const cachedCandidates = sourceCandidateContentCache.get(contentCacheKey);
153
+ if (cachedCandidates) {
154
+ replaceCssLayer(normalizedId, new Set(cachedCandidates));
155
+ return;
156
+ }
157
+ const nextCandidates = new Set(await extractSourceCandidates(source, "css", { bareArbitraryValues: options.bareArbitraryValues }));
158
+ sourceCandidateContentCache.set(contentCacheKey, [...nextCandidates]);
159
+ replaceCssLayer(normalizedId, nextCandidates);
160
+ }
161
+ async function merge(id, source) {
162
+ const normalizedId = cleanUrl(id);
163
+ const extension = resolveSourceCandidateExtension(normalizedId);
164
+ const contentCacheKey = createSourceCandidateContentCacheKey(extension, source, options.bareArbitraryValues);
165
+ const cachedCandidates = sourceCandidateContentCache.get(contentCacheKey);
166
+ const extractedCandidates = cachedCandidates ? new Set(cachedCandidates) : new Set(await extractSourceCandidates(source, extension, { bareArbitraryValues: options.bareArbitraryValues }));
167
+ if (!cachedCandidates) sourceCandidateContentCache.set(contentCacheKey, [...extractedCandidates]);
168
+ replaceTransformLayer(normalizedId, extractedCandidates);
169
+ }
170
+ async function syncFile(id) {
171
+ const normalizedId = cleanUrl(id);
172
+ await sync(normalizedId, await readFile(normalizedId, "utf8"));
173
+ }
174
+ async function syncCurrentFile(id) {
175
+ const normalizedId = cleanUrl(id);
176
+ transformCandidatesById.delete(normalizedId);
177
+ await syncFile(normalizedId);
178
+ }
179
+ async function scanRoot({ entries, explicit, root, outDir }) {
180
+ const resolvedRoot = path.resolve(root);
181
+ const outDirIgnore = resolveOutDirIgnorePattern(resolvedRoot, outDir);
182
+ const scanEntries = normalizeScanEntries(resolvedRoot, entries, outDirIgnore);
183
+ const ignoredSources = createDefaultIgnoredSources(resolvedRoot, outDirIgnore, entries, explicit);
184
+ const files = await resolveProjectSourceFiles({
185
+ cwd: resolvedRoot,
186
+ ...scanEntries === void 0 ? {} : { sources: scanEntries },
187
+ ...ignoredSources.length > 0 ? { ignoredSources } : {},
188
+ filter: isSourceCandidateRequest
189
+ });
190
+ await Promise.all(files.map((file) => syncFile(file)));
191
+ }
192
+ function replaceFinal(id, nextCandidates) {
193
+ const normalizedId = cleanUrl(id);
194
+ const previousCandidates = candidatesById.get(normalizedId);
195
+ if (previousCandidates) {
196
+ removeCandidateSet(candidateCount, previousCandidates);
197
+ candidatesById.delete(normalizedId);
198
+ }
199
+ if (nextCandidates.size === 0) return;
200
+ candidatesById.set(normalizedId, nextCandidates);
201
+ addCandidateSet(candidateCount, nextCandidates);
202
+ }
203
+ function replaceScanLayer(id, nextCandidates) {
204
+ const normalizedId = cleanUrl(id);
205
+ if (nextCandidates.size === 0) scanCandidatesById.delete(normalizedId);
206
+ else scanCandidatesById.set(normalizedId, nextCandidates);
207
+ recompute(normalizedId);
208
+ }
209
+ function replaceTransformLayer(id, nextCandidates) {
210
+ const normalizedId = cleanUrl(id);
211
+ if (nextCandidates.size === 0) transformCandidatesById.delete(normalizedId);
212
+ else transformCandidatesById.set(normalizedId, nextCandidates);
213
+ recompute(normalizedId);
214
+ }
215
+ function replaceCssLayer(id, nextCandidates) {
216
+ const normalizedId = cleanUrl(id);
217
+ if (nextCandidates.size === 0) cssCandidatesById.delete(normalizedId);
218
+ else cssCandidatesById.set(normalizedId, nextCandidates);
219
+ recompute(normalizedId);
220
+ }
221
+ function recompute(id) {
222
+ const normalizedId = cleanUrl(id);
223
+ replaceFinal(normalizedId, new Set([
224
+ ...scanCandidatesById.get(normalizedId) ?? [],
225
+ ...transformCandidatesById.get(normalizedId) ?? [],
226
+ ...cssCandidatesById.get(normalizedId) ?? []
227
+ ]));
228
+ }
229
+ function syncInline(inlineCandidates) {
230
+ inlineIncludedCandidates = new Set(inlineCandidates?.included ?? []);
231
+ inlineExcludedCandidates = new Set(inlineCandidates?.excluded ?? []);
232
+ }
233
+ function remove(id) {
234
+ const normalizedId = cleanUrl(id);
235
+ scanCandidatesById.delete(normalizedId);
236
+ transformCandidatesById.delete(normalizedId);
237
+ cssCandidatesById.delete(normalizedId);
238
+ const previousCandidates = candidatesById.get(normalizedId);
239
+ if (!previousCandidates) return;
240
+ removeCandidateSet(candidateCount, previousCandidates);
241
+ candidatesById.delete(normalizedId);
242
+ }
243
+ function values() {
244
+ const values = new Set([...candidateCount.keys(), ...inlineIncludedCandidates]);
245
+ for (const candidate of inlineExcludedCandidates) values.delete(candidate);
246
+ return values;
247
+ }
248
+ function valuesForEntries(entries) {
249
+ if (entries === void 0) return values();
250
+ const filtered = /* @__PURE__ */ new Set();
251
+ for (const [id, candidates] of candidatesById) {
252
+ if (!isFileMatchedByTailwindSourceEntries(id, entries)) continue;
253
+ for (const candidate of candidates) filtered.add(candidate);
254
+ }
255
+ for (const candidate of inlineIncludedCandidates) filtered.add(candidate);
256
+ for (const candidate of inlineExcludedCandidates) filtered.delete(candidate);
257
+ return filtered;
258
+ }
259
+ function clear() {
260
+ candidatesById.clear();
261
+ scanCandidatesById.clear();
262
+ transformCandidatesById.clear();
263
+ cssCandidatesById.clear();
264
+ candidateCount.clear();
265
+ inlineIncludedCandidates.clear();
266
+ inlineExcludedCandidates.clear();
267
+ }
268
+ function snapshot() {
269
+ return {
270
+ candidatesById: [...candidatesById.entries()].map(([id, candidates]) => [id, [...candidates]]),
271
+ cssCandidatesById: [...cssCandidatesById.entries()].map(([id, candidates]) => [id, [...candidates]]),
272
+ scanCandidatesById: [...scanCandidatesById.entries()].map(([id, candidates]) => [id, [...candidates]]),
273
+ transformCandidatesById: [...transformCandidatesById.entries()].map(([id, candidates]) => [id, [...candidates]]),
274
+ inlineExcludedCandidates: [...inlineExcludedCandidates],
275
+ inlineIncludedCandidates: [...inlineIncludedCandidates]
276
+ };
277
+ }
278
+ function restore(snapshot) {
279
+ clear();
280
+ inlineExcludedCandidates = new Set(snapshot.inlineExcludedCandidates);
281
+ inlineIncludedCandidates = new Set(snapshot.inlineIncludedCandidates);
282
+ const scanEntries = snapshot.scanCandidatesById ?? snapshot.candidatesById;
283
+ for (const [id, candidates] of scanEntries) {
284
+ const candidateSet = new Set(candidates);
285
+ if (candidateSet.size === 0) continue;
286
+ scanCandidatesById.set(id, candidateSet);
287
+ }
288
+ for (const [id, candidates] of snapshot.transformCandidatesById ?? []) {
289
+ const candidateSet = new Set(candidates);
290
+ if (candidateSet.size === 0) continue;
291
+ transformCandidatesById.set(id, candidateSet);
292
+ }
293
+ for (const [id, candidates] of snapshot.cssCandidatesById ?? []) {
294
+ const candidateSet = new Set(candidates);
295
+ if (candidateSet.size === 0) continue;
296
+ cssCandidatesById.set(id, candidateSet);
297
+ }
298
+ for (const [id, candidates] of snapshot.candidatesById) {
299
+ const candidateSet = new Set(candidates);
300
+ if (candidateSet.size === 0) continue;
301
+ candidatesById.set(id, candidateSet);
302
+ addCandidateSet(candidateCount, candidateSet);
303
+ }
304
+ }
305
+ return {
306
+ sync,
307
+ syncCss,
308
+ merge,
309
+ syncFile,
310
+ syncCurrentFile,
311
+ scanRoot,
312
+ syncInline,
313
+ remove,
314
+ values,
315
+ valuesForEntries,
316
+ snapshot,
317
+ restore,
318
+ clear
319
+ };
320
+ }
321
+ //#endregion
322
+ export { isSourceCandidateRequest as n, createSourceCandidateCollector as t };
@@ -0,0 +1,335 @@
1
+ const require_chunk = require("./chunk-C5U5_Hdc.js");
2
+ const require_v3_engine = require("./v3-engine-M6Aqru5T.js");
3
+ let tailwindcss_patch = require("tailwindcss-patch");
4
+ let node_path = require("node:path");
5
+ node_path = require_chunk.__toESM(node_path);
6
+ let node_fs_promises = require("node:fs/promises");
7
+ //#region src/bundlers/vite/source-candidates.ts
8
+ const CLEAN_URL_RE = /[?#].*$/;
9
+ const TAILWIND_V4_IGNORED_CONTENT_DIRS = [
10
+ ".git",
11
+ ".hg",
12
+ ".jj",
13
+ ".next",
14
+ ".parcel-cache",
15
+ ".pnpm-store",
16
+ ".svelte-kit",
17
+ ".svn",
18
+ ".turbo",
19
+ ".venv",
20
+ ".vercel",
21
+ ".yarn",
22
+ "__pycache__",
23
+ "node_modules",
24
+ "venv"
25
+ ];
26
+ const TAILWIND_V4_IGNORED_EXTENSIONS = [
27
+ "css",
28
+ "less",
29
+ "postcss",
30
+ "pcss",
31
+ "lock",
32
+ "sass",
33
+ "scss",
34
+ "styl",
35
+ "stylus",
36
+ "log",
37
+ "wxss",
38
+ "acss",
39
+ "jxss",
40
+ "ttss",
41
+ "qss",
42
+ "tyss"
43
+ ];
44
+ const TAILWIND_V4_IGNORED_FILES = [
45
+ "package-lock.json",
46
+ "pnpm-lock.yaml",
47
+ "bun.lockb",
48
+ ".gitignore",
49
+ ".env",
50
+ ".env.*"
51
+ ];
52
+ const sourceCandidateContentCache = /* @__PURE__ */ new Map();
53
+ function cleanUrl(id) {
54
+ return require_v3_engine.resolveSourceScanPath(id.replace(CLEAN_URL_RE, ""));
55
+ }
56
+ function resolveOutDirIgnorePattern(root, outDir) {
57
+ if (!outDir) return;
58
+ const relative = node_path.default.relative(root, node_path.default.resolve(root, outDir));
59
+ if (!relative || relative.startsWith("..") || node_path.default.isAbsolute(relative)) return;
60
+ return `${require_v3_engine.toPosixPath(relative)}/**`;
61
+ }
62
+ function normalizeScanEntries(root, entries, outDirIgnore) {
63
+ const hasPositiveEntry = entries?.some((entry) => !entry.negated) === true;
64
+ const scanEntries = entries?.length ? hasPositiveEntry ? entries : [{
65
+ base: root,
66
+ pattern: "**/*",
67
+ negated: false
68
+ }, ...entries] : void 0;
69
+ if (!outDirIgnore) return scanEntries;
70
+ return [...scanEntries ?? [{
71
+ base: root,
72
+ pattern: "**/*",
73
+ negated: false
74
+ }], {
75
+ base: root,
76
+ pattern: outDirIgnore,
77
+ negated: true
78
+ }];
79
+ }
80
+ function shouldApplyDefaultIgnoredSources(entries) {
81
+ return entries?.length === void 0 ? false : entries.length > 0 && entries.every((entry) => entry.negated);
82
+ }
83
+ function createDefaultIgnoredSources(root, outDirIgnore, entries, explicit) {
84
+ return [...!explicit || shouldApplyDefaultIgnoredSources(entries) ? [
85
+ ...TAILWIND_V4_IGNORED_CONTENT_DIRS.map((pattern) => ({
86
+ base: root,
87
+ pattern: `**/${pattern}/**`,
88
+ negated: true
89
+ })),
90
+ ...TAILWIND_V4_IGNORED_EXTENSIONS.map((extension) => ({
91
+ base: root,
92
+ pattern: `**/*.${extension}`,
93
+ negated: true
94
+ })),
95
+ ...TAILWIND_V4_IGNORED_FILES.map((pattern) => ({
96
+ base: root,
97
+ pattern: `**/${pattern}`,
98
+ negated: true
99
+ }))
100
+ ] : [], ...outDirIgnore ? [{
101
+ base: root,
102
+ pattern: outDirIgnore,
103
+ negated: true
104
+ }] : []];
105
+ }
106
+ function resolveSourceCandidateExtension(id) {
107
+ const normalized = cleanUrl(id);
108
+ return /\.([^.\\/]+)$/.exec(normalized)?.[1] ?? "html";
109
+ }
110
+ function createSourceCandidateContentCacheKey(extension, source, bareArbitraryValues) {
111
+ return `${extension}\0${JSON.stringify(bareArbitraryValues ?? false)}\0${source}`;
112
+ }
113
+ function isSourceCandidateRequest(id) {
114
+ return require_v3_engine.FULL_SOURCE_SCAN_EXTENSION_RE.test(cleanUrl(id));
115
+ }
116
+ function removeCandidateSet(candidateCount, candidates) {
117
+ for (const candidate of candidates) {
118
+ const count = candidateCount.get(candidate);
119
+ if (count == null) continue;
120
+ if (count <= 1) {
121
+ candidateCount.delete(candidate);
122
+ continue;
123
+ }
124
+ candidateCount.set(candidate, count - 1);
125
+ }
126
+ }
127
+ function addCandidateSet(candidateCount, candidates) {
128
+ for (const candidate of candidates) candidateCount.set(candidate, (candidateCount.get(candidate) ?? 0) + 1);
129
+ }
130
+ function createSourceCandidateCollector(options = {}) {
131
+ const candidatesById = /* @__PURE__ */ new Map();
132
+ const scanCandidatesById = /* @__PURE__ */ new Map();
133
+ const transformCandidatesById = /* @__PURE__ */ new Map();
134
+ const cssCandidatesById = /* @__PURE__ */ new Map();
135
+ const candidateCount = /* @__PURE__ */ new Map();
136
+ let inlineIncludedCandidates = /* @__PURE__ */ new Set();
137
+ let inlineExcludedCandidates = /* @__PURE__ */ new Set();
138
+ async function sync(id, source) {
139
+ const normalizedId = cleanUrl(id);
140
+ const extension = resolveSourceCandidateExtension(normalizedId);
141
+ const contentCacheKey = createSourceCandidateContentCacheKey(extension, source, options.bareArbitraryValues);
142
+ const cachedCandidates = sourceCandidateContentCache.get(contentCacheKey);
143
+ if (cachedCandidates) {
144
+ replaceScanLayer(normalizedId, new Set(cachedCandidates));
145
+ return;
146
+ }
147
+ const nextCandidates = new Set(await (0, tailwindcss_patch.extractSourceCandidates)(source, extension, { bareArbitraryValues: options.bareArbitraryValues }));
148
+ sourceCandidateContentCache.set(contentCacheKey, [...nextCandidates]);
149
+ replaceScanLayer(normalizedId, nextCandidates);
150
+ }
151
+ async function syncCss(id, source) {
152
+ const normalizedId = cleanUrl(id);
153
+ const contentCacheKey = createSourceCandidateContentCacheKey("css", source, options.bareArbitraryValues);
154
+ const cachedCandidates = sourceCandidateContentCache.get(contentCacheKey);
155
+ if (cachedCandidates) {
156
+ replaceCssLayer(normalizedId, new Set(cachedCandidates));
157
+ return;
158
+ }
159
+ const nextCandidates = new Set(await (0, tailwindcss_patch.extractSourceCandidates)(source, "css", { bareArbitraryValues: options.bareArbitraryValues }));
160
+ sourceCandidateContentCache.set(contentCacheKey, [...nextCandidates]);
161
+ replaceCssLayer(normalizedId, nextCandidates);
162
+ }
163
+ async function merge(id, source) {
164
+ const normalizedId = cleanUrl(id);
165
+ const extension = resolveSourceCandidateExtension(normalizedId);
166
+ const contentCacheKey = createSourceCandidateContentCacheKey(extension, source, options.bareArbitraryValues);
167
+ const cachedCandidates = sourceCandidateContentCache.get(contentCacheKey);
168
+ const extractedCandidates = cachedCandidates ? new Set(cachedCandidates) : new Set(await (0, tailwindcss_patch.extractSourceCandidates)(source, extension, { bareArbitraryValues: options.bareArbitraryValues }));
169
+ if (!cachedCandidates) sourceCandidateContentCache.set(contentCacheKey, [...extractedCandidates]);
170
+ replaceTransformLayer(normalizedId, extractedCandidates);
171
+ }
172
+ async function syncFile(id) {
173
+ const normalizedId = cleanUrl(id);
174
+ await sync(normalizedId, await (0, node_fs_promises.readFile)(normalizedId, "utf8"));
175
+ }
176
+ async function syncCurrentFile(id) {
177
+ const normalizedId = cleanUrl(id);
178
+ transformCandidatesById.delete(normalizedId);
179
+ await syncFile(normalizedId);
180
+ }
181
+ async function scanRoot({ entries, explicit, root, outDir }) {
182
+ const resolvedRoot = node_path.default.resolve(root);
183
+ const outDirIgnore = resolveOutDirIgnorePattern(resolvedRoot, outDir);
184
+ const scanEntries = normalizeScanEntries(resolvedRoot, entries, outDirIgnore);
185
+ const ignoredSources = createDefaultIgnoredSources(resolvedRoot, outDirIgnore, entries, explicit);
186
+ const files = await (0, tailwindcss_patch.resolveProjectSourceFiles)({
187
+ cwd: resolvedRoot,
188
+ ...scanEntries === void 0 ? {} : { sources: scanEntries },
189
+ ...ignoredSources.length > 0 ? { ignoredSources } : {},
190
+ filter: isSourceCandidateRequest
191
+ });
192
+ await Promise.all(files.map((file) => syncFile(file)));
193
+ }
194
+ function replaceFinal(id, nextCandidates) {
195
+ const normalizedId = cleanUrl(id);
196
+ const previousCandidates = candidatesById.get(normalizedId);
197
+ if (previousCandidates) {
198
+ removeCandidateSet(candidateCount, previousCandidates);
199
+ candidatesById.delete(normalizedId);
200
+ }
201
+ if (nextCandidates.size === 0) return;
202
+ candidatesById.set(normalizedId, nextCandidates);
203
+ addCandidateSet(candidateCount, nextCandidates);
204
+ }
205
+ function replaceScanLayer(id, nextCandidates) {
206
+ const normalizedId = cleanUrl(id);
207
+ if (nextCandidates.size === 0) scanCandidatesById.delete(normalizedId);
208
+ else scanCandidatesById.set(normalizedId, nextCandidates);
209
+ recompute(normalizedId);
210
+ }
211
+ function replaceTransformLayer(id, nextCandidates) {
212
+ const normalizedId = cleanUrl(id);
213
+ if (nextCandidates.size === 0) transformCandidatesById.delete(normalizedId);
214
+ else transformCandidatesById.set(normalizedId, nextCandidates);
215
+ recompute(normalizedId);
216
+ }
217
+ function replaceCssLayer(id, nextCandidates) {
218
+ const normalizedId = cleanUrl(id);
219
+ if (nextCandidates.size === 0) cssCandidatesById.delete(normalizedId);
220
+ else cssCandidatesById.set(normalizedId, nextCandidates);
221
+ recompute(normalizedId);
222
+ }
223
+ function recompute(id) {
224
+ const normalizedId = cleanUrl(id);
225
+ replaceFinal(normalizedId, new Set([
226
+ ...scanCandidatesById.get(normalizedId) ?? [],
227
+ ...transformCandidatesById.get(normalizedId) ?? [],
228
+ ...cssCandidatesById.get(normalizedId) ?? []
229
+ ]));
230
+ }
231
+ function syncInline(inlineCandidates) {
232
+ inlineIncludedCandidates = new Set(inlineCandidates?.included ?? []);
233
+ inlineExcludedCandidates = new Set(inlineCandidates?.excluded ?? []);
234
+ }
235
+ function remove(id) {
236
+ const normalizedId = cleanUrl(id);
237
+ scanCandidatesById.delete(normalizedId);
238
+ transformCandidatesById.delete(normalizedId);
239
+ cssCandidatesById.delete(normalizedId);
240
+ const previousCandidates = candidatesById.get(normalizedId);
241
+ if (!previousCandidates) return;
242
+ removeCandidateSet(candidateCount, previousCandidates);
243
+ candidatesById.delete(normalizedId);
244
+ }
245
+ function values() {
246
+ const values = new Set([...candidateCount.keys(), ...inlineIncludedCandidates]);
247
+ for (const candidate of inlineExcludedCandidates) values.delete(candidate);
248
+ return values;
249
+ }
250
+ function valuesForEntries(entries) {
251
+ if (entries === void 0) return values();
252
+ const filtered = /* @__PURE__ */ new Set();
253
+ for (const [id, candidates] of candidatesById) {
254
+ if (!require_v3_engine.isFileMatchedByTailwindSourceEntries(id, entries)) continue;
255
+ for (const candidate of candidates) filtered.add(candidate);
256
+ }
257
+ for (const candidate of inlineIncludedCandidates) filtered.add(candidate);
258
+ for (const candidate of inlineExcludedCandidates) filtered.delete(candidate);
259
+ return filtered;
260
+ }
261
+ function clear() {
262
+ candidatesById.clear();
263
+ scanCandidatesById.clear();
264
+ transformCandidatesById.clear();
265
+ cssCandidatesById.clear();
266
+ candidateCount.clear();
267
+ inlineIncludedCandidates.clear();
268
+ inlineExcludedCandidates.clear();
269
+ }
270
+ function snapshot() {
271
+ return {
272
+ candidatesById: [...candidatesById.entries()].map(([id, candidates]) => [id, [...candidates]]),
273
+ cssCandidatesById: [...cssCandidatesById.entries()].map(([id, candidates]) => [id, [...candidates]]),
274
+ scanCandidatesById: [...scanCandidatesById.entries()].map(([id, candidates]) => [id, [...candidates]]),
275
+ transformCandidatesById: [...transformCandidatesById.entries()].map(([id, candidates]) => [id, [...candidates]]),
276
+ inlineExcludedCandidates: [...inlineExcludedCandidates],
277
+ inlineIncludedCandidates: [...inlineIncludedCandidates]
278
+ };
279
+ }
280
+ function restore(snapshot) {
281
+ clear();
282
+ inlineExcludedCandidates = new Set(snapshot.inlineExcludedCandidates);
283
+ inlineIncludedCandidates = new Set(snapshot.inlineIncludedCandidates);
284
+ const scanEntries = snapshot.scanCandidatesById ?? snapshot.candidatesById;
285
+ for (const [id, candidates] of scanEntries) {
286
+ const candidateSet = new Set(candidates);
287
+ if (candidateSet.size === 0) continue;
288
+ scanCandidatesById.set(id, candidateSet);
289
+ }
290
+ for (const [id, candidates] of snapshot.transformCandidatesById ?? []) {
291
+ const candidateSet = new Set(candidates);
292
+ if (candidateSet.size === 0) continue;
293
+ transformCandidatesById.set(id, candidateSet);
294
+ }
295
+ for (const [id, candidates] of snapshot.cssCandidatesById ?? []) {
296
+ const candidateSet = new Set(candidates);
297
+ if (candidateSet.size === 0) continue;
298
+ cssCandidatesById.set(id, candidateSet);
299
+ }
300
+ for (const [id, candidates] of snapshot.candidatesById) {
301
+ const candidateSet = new Set(candidates);
302
+ if (candidateSet.size === 0) continue;
303
+ candidatesById.set(id, candidateSet);
304
+ addCandidateSet(candidateCount, candidateSet);
305
+ }
306
+ }
307
+ return {
308
+ sync,
309
+ syncCss,
310
+ merge,
311
+ syncFile,
312
+ syncCurrentFile,
313
+ scanRoot,
314
+ syncInline,
315
+ remove,
316
+ values,
317
+ valuesForEntries,
318
+ snapshot,
319
+ restore,
320
+ clear
321
+ };
322
+ }
323
+ //#endregion
324
+ Object.defineProperty(exports, "createSourceCandidateCollector", {
325
+ enumerable: true,
326
+ get: function() {
327
+ return createSourceCandidateCollector;
328
+ }
329
+ });
330
+ Object.defineProperty(exports, "isSourceCandidateRequest", {
331
+ enumerable: true,
332
+ get: function() {
333
+ return isSourceCandidateRequest;
334
+ }
335
+ });
@@ -1,5 +1 @@
1
- interface PruneMiniProgramGeneratedCssOptions {
2
- preservePreflight?: boolean;
3
- }
4
- export declare function pruneMiniProgramGeneratedCss(css: string, options?: PruneMiniProgramGeneratedCssOptions): string;
5
- export {};
1
+ export { pruneMiniProgramGeneratedCss } from '@weapp-tailwindcss/postcss';
@@ -1,2 +1 @@
1
- import type postcss from 'postcss';
2
- export declare function removeUnsupportedCascadeLayers(root: postcss.Root): void;
1
+ export { removeUnsupportedCascadeLayers, } from '@weapp-tailwindcss/postcss';
@@ -1,11 +1,12 @@
1
1
  import type { TailwindcssPatcherLike } from '../../types';
2
2
  interface RuntimeClassSetCacheEntry {
3
- value?: Set<string>;
4
- promise?: Promise<Set<string>>;
5
- signature?: string;
3
+ value?: Set<string> | undefined;
4
+ promise?: Promise<Set<string>> | undefined;
5
+ signature?: string | undefined;
6
6
  }
7
7
  export declare const runtimeSignaturePatchersSymbol: unique symbol;
8
8
  export declare function invalidateRuntimeClassSet(twPatcher?: TailwindcssPatcherLike): void;
9
9
  export declare function getRuntimeClassSetCacheEntry(twPatcher: TailwindcssPatcherLike): RuntimeClassSetCacheEntry;
10
10
  export declare function getRuntimeClassSetSignature(twPatcher: TailwindcssPatcherLike): string;
11
+ export declare function getRuntimeClassSetSignatureWithSources(twPatcher: TailwindcssPatcherLike): Promise<string>;
11
12
  export {};