weapp-tailwindcss 5.0.0-next.10 → 5.0.0-next.13

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 (110) hide show
  1. package/dist/{bundle-state-EUbcdKqo.js → bundle-state-Bz8vLnCf.js} +42 -3
  2. package/dist/{bundle-state-BWqi5ZyX.mjs → bundle-state-CP2XS3Uj.mjs} +31 -4
  3. package/dist/bundlers/shared/cache.d.ts +6 -6
  4. package/dist/bundlers/shared/css-cleanup.d.ts +6 -1
  5. package/dist/bundlers/shared/css-imports.d.ts +3 -3
  6. package/dist/bundlers/shared/generator-css/directives.d.ts +10 -3
  7. package/dist/bundlers/shared/generator-css/source-files.d.ts +9 -6
  8. package/dist/bundlers/shared/generator-css/source-resolver.d.ts +16 -2
  9. package/dist/bundlers/shared/generator-css.d.ts +5 -1
  10. package/dist/bundlers/shared/hmr-timing.d.ts +22 -0
  11. package/dist/bundlers/shared/style-requests.d.ts +2 -0
  12. package/dist/bundlers/vite/bundle-state.d.ts +1 -0
  13. package/dist/bundlers/vite/css-finalizer.d.ts +2 -0
  14. package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +5 -1
  15. package/dist/bundlers/vite/generate-bundle/css-share-scope.d.ts +1 -0
  16. package/dist/bundlers/vite/generate-bundle.d.ts +8 -1
  17. package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +5 -1
  18. package/dist/bundlers/vite/rewrite-css-imports.d.ts +5 -5
  19. package/dist/bundlers/vite/runtime-class-set.d.ts +4 -1
  20. package/dist/bundlers/vite/source-candidates.d.ts +13 -2
  21. package/dist/bundlers/vite/source-scan.d.ts +21 -3
  22. package/dist/bundlers/vite/static-config-content.d.ts +5 -0
  23. package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +5 -0
  24. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +3 -3
  25. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +3 -3
  26. package/dist/cache/index.d.ts +6 -6
  27. package/dist/cli/context.d.ts +1 -11
  28. package/dist/cli/doctor/types.d.ts +11 -11
  29. package/dist/cli/vscode-entry.d.ts +3 -3
  30. package/dist/cli.js +468 -10
  31. package/dist/cli.mjs +466 -9
  32. package/dist/context/tailwindcss.d.ts +1 -1
  33. package/dist/core.js +1 -1
  34. package/dist/core.mjs +1 -1
  35. package/dist/css-macro/postcss.js +3 -2
  36. package/dist/css-macro/postcss.mjs +3 -2
  37. package/dist/css-macro.js +2 -2
  38. package/dist/css-macro.mjs +2 -2
  39. package/dist/defaults.js +1 -1
  40. package/dist/defaults.mjs +1 -1
  41. package/dist/escape.js +10 -2
  42. package/dist/escape.mjs +10 -2
  43. package/dist/generator/options.d.ts +8 -6
  44. package/dist/generator/types.d.ts +3 -3
  45. package/dist/generator-C9H44wEF.mjs +32 -0
  46. package/dist/generator-CRORPkpW.js +55 -0
  47. package/dist/generator.js +12 -11
  48. package/dist/generator.mjs +2 -1
  49. package/dist/gulp.js +57 -18
  50. package/dist/gulp.mjs +54 -15
  51. package/dist/{incremental-runtime-class-set-BYmzQ-_f.js → incremental-runtime-class-set-DN9KKjSi.js} +753 -155
  52. package/dist/{incremental-runtime-class-set-BgMW6wf2.mjs → incremental-runtime-class-set-Dbn4yPfZ.mjs} +724 -144
  53. package/dist/index.js +4 -4
  54. package/dist/index.mjs +4 -4
  55. package/dist/js/precheck.d.ts +2 -2
  56. package/dist/lightningcss/style-handler/selector-transform.d.ts +1 -1
  57. package/dist/lightningcss/style-handler.d.ts +3 -3
  58. package/dist/{postcss-Dg-_lyHS.js → postcss-Ab7YzAbs.js} +37 -23
  59. package/dist/postcss-CZE8k8oP.js +5483 -0
  60. package/dist/{postcss-C7efq3hr.mjs → postcss-CtlrNknb.mjs} +26 -12
  61. package/dist/postcss.js +1 -1
  62. package/dist/postcss.mjs +1 -1
  63. package/dist/{precheck-B32p-gLI.js → precheck-CRX-pMKJ.js} +63 -37
  64. package/dist/{precheck-B4RH6ZNN.mjs → precheck-SG48aLG2.mjs} +56 -30
  65. package/dist/presets.js +11 -11
  66. package/dist/presets.mjs +11 -11
  67. package/dist/shared/mpx.d.ts +1 -0
  68. package/dist/source-candidates-C4YgmZ8A.js +274 -0
  69. package/dist/source-candidates-CyupdLKi.mjs +259 -0
  70. package/dist/tailwindcss/runtime/cache.d.ts +4 -3
  71. package/dist/tailwindcss/runtime.d.ts +9 -9
  72. package/dist/tailwindcss/v3-engine/types.d.ts +17 -14
  73. package/dist/tailwindcss/v4/css-entries.d.ts +2 -2
  74. package/dist/tailwindcss/v4/patcher.d.ts +1 -1
  75. package/dist/tailwindcss/v4-engine/types.d.ts +14 -5
  76. package/dist/{tailwindcss-C5IgPlQ0.mjs → tailwindcss-BbTVeQkG.mjs} +52 -33
  77. package/dist/{tailwindcss-Bu-RWIHx.js → tailwindcss-DZ6jVYb4.js} +59 -40
  78. package/dist/types/index.d.ts +44 -40
  79. package/dist/types/user-defined-options/general.d.ts +21 -21
  80. package/dist/types/user-defined-options/important.d.ts +30 -27
  81. package/dist/types/user-defined-options/lifecycle.d.ts +4 -4
  82. package/dist/types/user-defined-options/matcher.d.ts +6 -6
  83. package/dist/utils/object.d.ts +9 -0
  84. package/dist/{utils-Btw1iOVV.mjs → utils-CycMvPn_.mjs} +1 -1
  85. package/dist/{utils-BiShvil9.js → utils-D0MZP_tr.js} +1 -1
  86. package/dist/v3-engine-D61eilBl.mjs +3208 -0
  87. package/dist/v3-engine-DwV1E6rX.js +3461 -0
  88. package/dist/{vite-BU74SkOi.mjs → vite-Ti_qSctn.mjs} +434 -536
  89. package/dist/{vite-CKjx_5c3.js → vite-xKS6RvLR.js} +437 -542
  90. package/dist/vite.js +1 -1
  91. package/dist/vite.mjs +1 -1
  92. package/dist/weapp-tw-css-import-rewrite-loader.js +143 -18
  93. package/dist/weapp-tw-runtime-classset-loader.js +44 -6
  94. package/dist/{webpack-CAk_ITq7.mjs → webpack-DvptFz7B.mjs} +111 -39
  95. package/dist/{webpack-damWiYqY.js → webpack-wfNutjMm.js} +115 -43
  96. package/dist/webpack.js +1 -1
  97. package/dist/webpack.mjs +1 -1
  98. package/package.json +5 -5
  99. package/dist/cache-BVAiJV3J.js +0 -502
  100. package/dist/cache-CHs4DXui.mjs +0 -434
  101. package/dist/generator-DKkhJbOg.js +0 -1531
  102. package/dist/generator-UBmfduYg.mjs +0 -1432
  103. package/dist/runtime-patch-CwN5ya72.mjs +0 -71
  104. package/dist/runtime-patch-D6mBo_KB.js +0 -85
  105. package/dist/source-scan-BaYvNx-k.js +0 -293
  106. package/dist/source-scan-cGZxoJqP.mjs +0 -254
  107. /package/dist/{constants-BeeyfJ9k.js → constants-BoB_6lFw.js} +0 -0
  108. /package/dist/{constants-BG12WAKw.mjs → constants-E_loJC49.mjs} +0 -0
  109. /package/dist/{logger-EVNB9z7i.js → logger-BRy6XPQ2.js} +0 -0
  110. /package/dist/{logger-CZUxvJJD.mjs → logger-Bub1jggA.mjs} +0 -0
package/dist/presets.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import "./cache-CHs4DXui.mjs";
2
- import { n as defuOverrideArray, o as resolveUniUtsPlatform } from "./utils-Btw1iOVV.mjs";
3
- import { i as resolveUniAppXOptions, n as resolveTailwindcssBasedir } from "./tailwindcss-C5IgPlQ0.mjs";
4
- import { t as logger } from "./logger-CZUxvJJD.mjs";
1
+ import { B as omitUndefined } from "./v3-engine-D61eilBl.mjs";
2
+ import { n as defuOverrideArray, o as resolveUniUtsPlatform } from "./utils-CycMvPn_.mjs";
3
+ import { i as resolveUniAppXOptions, n as resolveTailwindcssBasedir } from "./tailwindcss-BbTVeQkG.mjs";
4
+ import { t as logger } from "./logger-Bub1jggA.mjs";
5
5
  import process from "node:process";
6
6
  import { getPackageInfoSync } from "local-pkg";
7
7
  //#region src/presets/shared.ts
@@ -17,10 +17,10 @@ function createBasePreset(options = {}) {
17
17
  const tailwindConfig = {
18
18
  v2: { cwd: baseDir },
19
19
  v3: { cwd: baseDir },
20
- v4: {
20
+ v4: omitUndefined({
21
21
  base: baseDir,
22
22
  cssEntries: normalizedCssEntries
23
- }
23
+ })
24
24
  };
25
25
  if (normalizedCssEntries && normalizedCssEntries.length > 0) tailwindConfig.version = 4;
26
26
  const preset = {
@@ -39,7 +39,7 @@ function createBasePreset(options = {}) {
39
39
  //#endregion
40
40
  //#region src/presets/uni-app.ts
41
41
  function uniApp(options = {}) {
42
- const uniPlatform = process.env.UNI_PLATFORM;
42
+ const uniPlatform = process.env["UNI_PLATFORM"];
43
43
  return createBasePreset({
44
44
  disabled: uniPlatform === "h5" || uniPlatform === "app" || uniPlatform === "app-plus" ? true : void 0,
45
45
  ...options
@@ -76,9 +76,9 @@ function resolveInstalledTailwindDefaults(resolve) {
76
76
  };
77
77
  }
78
78
  function uniAppX(options) {
79
- logger.info(`UNI_PLATFORM: ${process.env.UNI_PLATFORM}`);
79
+ logger.info(`UNI_PLATFORM: ${process.env["UNI_PLATFORM"]}`);
80
80
  const utsPlatform = resolveUniUtsPlatform();
81
- const uniPlatform = resolveUniUtsPlatform(process.env.UNI_PLATFORM);
81
+ const uniPlatform = resolveUniUtsPlatform(process.env["UNI_PLATFORM"]);
82
82
  logger.info(`UNI_UTS_PLATFORM: ${utsPlatform.raw ?? "undefined"}`);
83
83
  const isApp = utsPlatform.isApp || uniPlatform.isApp;
84
84
  const cssEntries = normalizeCssEntries(options.cssEntries);
@@ -104,10 +104,10 @@ function uniAppX(options) {
104
104
  cwd: options.base,
105
105
  resolve: resolvedResolve,
106
106
  v3: { cwd: options.base },
107
- v4: {
107
+ v4: omitUndefined({
108
108
  base: options.base,
109
109
  cssEntries
110
- }
110
+ })
111
111
  }
112
112
  },
113
113
  tailwindcss: {
@@ -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,274 @@
1
+ const require_chunk = require("./chunk-8l464Juk.js");
2
+ const require_v3_engine = require("./v3-engine-DwV1E6rX.js");
3
+ let node_path = require("node:path");
4
+ node_path = require_chunk.__toESM(node_path);
5
+ let tailwindcss_patch = require("tailwindcss-patch");
6
+ let node_fs_promises = require("node:fs/promises");
7
+ let fast_glob = require("fast-glob");
8
+ fast_glob = require_chunk.__toESM(fast_glob);
9
+ let micromatch = require("micromatch");
10
+ micromatch = require_chunk.__toESM(micromatch);
11
+ //#region src/bundlers/vite/source-candidates.ts
12
+ const CLEAN_URL_RE = /[?#].*$/;
13
+ const SOURCE_CANDIDATE_EXTENSIONS = [
14
+ "js",
15
+ "jsx",
16
+ "mjs",
17
+ "cjs",
18
+ "ts",
19
+ "tsx",
20
+ "mts",
21
+ "cts",
22
+ "vue",
23
+ "uvue",
24
+ "nvue",
25
+ "svelte",
26
+ "mpx",
27
+ "html",
28
+ "wxml",
29
+ "axml",
30
+ "jxml",
31
+ "ksml",
32
+ "ttml",
33
+ "qml",
34
+ "tyml",
35
+ "xhsml",
36
+ "swan",
37
+ "css",
38
+ "wxss",
39
+ "acss",
40
+ "jxss",
41
+ "ttss",
42
+ "qss",
43
+ "tyss",
44
+ "scss",
45
+ "sass",
46
+ "less",
47
+ "styl",
48
+ "stylus"
49
+ ];
50
+ const SOURCE_CANDIDATE_EXTENSION_RE = /\.(?:[cm]?[jt]sx?|vue|uvue|nvue|svelte|mpx|html|wxml|axml|jxml|ksml|ttml|qml|tyml|xhsml|swan|css|wxss|acss|jxss|ttss|qss|tyss|scss|sass|less|stylus?)$/;
51
+ const SOURCE_CANDIDATE_GLOB = `**/*.{${SOURCE_CANDIDATE_EXTENSIONS.join(",")}}`;
52
+ const DEFAULT_SCAN_IGNORE = ["**/node_modules/**", "**/.git/**"];
53
+ const sourceCandidateContentCache = /* @__PURE__ */ new Map();
54
+ function cleanUrl(id) {
55
+ return node_path.default.resolve(id.replace(CLEAN_URL_RE, ""));
56
+ }
57
+ function toPosixPath(value) {
58
+ return value.split(node_path.default.sep).join("/");
59
+ }
60
+ function resolveOutDirIgnorePattern(root, outDir) {
61
+ if (!outDir) return;
62
+ const relative = node_path.default.relative(root, node_path.default.resolve(root, outDir));
63
+ if (!relative || relative.startsWith("..") || node_path.default.isAbsolute(relative)) return;
64
+ return `${toPosixPath(relative)}/**`;
65
+ }
66
+ function resolveSourceCandidateExtension(id) {
67
+ const normalized = cleanUrl(id);
68
+ return /\.([^.\\/]+)$/.exec(normalized)?.[1] ?? "html";
69
+ }
70
+ function createSourceCandidateContentCacheKey(extension, source) {
71
+ return `${extension}\0${source}`;
72
+ }
73
+ function isSourceCandidateRequest(id) {
74
+ return SOURCE_CANDIDATE_EXTENSION_RE.test(cleanUrl(id));
75
+ }
76
+ function removeCandidateSet(candidateCount, candidates) {
77
+ for (const candidate of candidates) {
78
+ const count = candidateCount.get(candidate);
79
+ if (count == null) continue;
80
+ if (count <= 1) {
81
+ candidateCount.delete(candidate);
82
+ continue;
83
+ }
84
+ candidateCount.set(candidate, count - 1);
85
+ }
86
+ }
87
+ function addCandidateSet(candidateCount, candidates) {
88
+ for (const candidate of candidates) candidateCount.set(candidate, (candidateCount.get(candidate) ?? 0) + 1);
89
+ }
90
+ function isFileMatchedByEntries(file, entries) {
91
+ if (!entries?.length) return true;
92
+ const positiveEntries = entries.filter((entry) => !entry.negated);
93
+ const negativeEntries = entries.filter((entry) => entry.negated);
94
+ if (positiveEntries.length === 0) return false;
95
+ const resolvedFile = node_path.default.resolve(file);
96
+ if (!positiveEntries.some((entry) => {
97
+ const relative = toPosixPath(node_path.default.relative(node_path.default.resolve(entry.base), resolvedFile));
98
+ const pattern = node_path.default.isAbsolute(entry.pattern) ? toPosixPath(node_path.default.relative(node_path.default.resolve(entry.base), entry.pattern)) : entry.pattern;
99
+ return relative && !relative.startsWith("../") && !node_path.default.isAbsolute(relative) && micromatch.default.isMatch(relative, pattern);
100
+ })) return false;
101
+ return !negativeEntries.some((entry) => {
102
+ const relative = toPosixPath(node_path.default.relative(node_path.default.resolve(entry.base), resolvedFile));
103
+ const pattern = node_path.default.isAbsolute(entry.pattern) ? toPosixPath(node_path.default.relative(node_path.default.resolve(entry.base), entry.pattern)) : entry.pattern;
104
+ return relative && !relative.startsWith("../") && !node_path.default.isAbsolute(relative) && micromatch.default.isMatch(relative, pattern);
105
+ });
106
+ }
107
+ function createSourceCandidateCollector() {
108
+ const candidatesById = /* @__PURE__ */ new Map();
109
+ const scanCandidatesById = /* @__PURE__ */ new Map();
110
+ const transformCandidatesById = /* @__PURE__ */ new Map();
111
+ const candidateCount = /* @__PURE__ */ new Map();
112
+ let inlineIncludedCandidates = /* @__PURE__ */ new Set();
113
+ let inlineExcludedCandidates = /* @__PURE__ */ new Set();
114
+ async function sync(id, source) {
115
+ const normalizedId = cleanUrl(id);
116
+ const extension = resolveSourceCandidateExtension(normalizedId);
117
+ const contentCacheKey = createSourceCandidateContentCacheKey(extension, source);
118
+ const cachedCandidates = sourceCandidateContentCache.get(contentCacheKey);
119
+ if (cachedCandidates) {
120
+ replaceScanLayer(normalizedId, new Set(cachedCandidates));
121
+ return;
122
+ }
123
+ const nextCandidates = new Set(await (0, tailwindcss_patch.extractSourceCandidates)(source, extension));
124
+ sourceCandidateContentCache.set(contentCacheKey, [...nextCandidates]);
125
+ replaceScanLayer(normalizedId, nextCandidates);
126
+ }
127
+ async function merge(id, source) {
128
+ const normalizedId = cleanUrl(id);
129
+ const extension = resolveSourceCandidateExtension(normalizedId);
130
+ const contentCacheKey = createSourceCandidateContentCacheKey(extension, source);
131
+ const cachedCandidates = sourceCandidateContentCache.get(contentCacheKey);
132
+ const extractedCandidates = cachedCandidates ? new Set(cachedCandidates) : new Set(await (0, tailwindcss_patch.extractSourceCandidates)(source, extension));
133
+ if (!cachedCandidates) sourceCandidateContentCache.set(contentCacheKey, [...extractedCandidates]);
134
+ replaceTransformLayer(normalizedId, extractedCandidates);
135
+ }
136
+ async function syncFile(id) {
137
+ const normalizedId = cleanUrl(id);
138
+ await sync(normalizedId, await (0, node_fs_promises.readFile)(normalizedId, "utf8"));
139
+ }
140
+ async function scanRoot({ entries, root, outDir }) {
141
+ const resolvedRoot = node_path.default.resolve(root);
142
+ const outDirIgnore = resolveOutDirIgnorePattern(resolvedRoot, outDir);
143
+ const ignore = outDirIgnore ? [...DEFAULT_SCAN_IGNORE, outDirIgnore] : DEFAULT_SCAN_IGNORE;
144
+ const files = entries ? await require_v3_engine.expandTailwindSourceEntries(entries, { ignore }) : await (0, fast_glob.default)(SOURCE_CANDIDATE_GLOB, {
145
+ absolute: true,
146
+ cwd: resolvedRoot,
147
+ ignore,
148
+ onlyFiles: true,
149
+ unique: true
150
+ });
151
+ await Promise.all(files.map((file) => syncFile(file)));
152
+ }
153
+ function replaceFinal(id, nextCandidates) {
154
+ const normalizedId = cleanUrl(id);
155
+ const previousCandidates = candidatesById.get(normalizedId);
156
+ if (previousCandidates) {
157
+ removeCandidateSet(candidateCount, previousCandidates);
158
+ candidatesById.delete(normalizedId);
159
+ }
160
+ if (nextCandidates.size === 0) return;
161
+ candidatesById.set(normalizedId, nextCandidates);
162
+ addCandidateSet(candidateCount, nextCandidates);
163
+ }
164
+ function replaceScanLayer(id, nextCandidates) {
165
+ const normalizedId = cleanUrl(id);
166
+ if (nextCandidates.size === 0) scanCandidatesById.delete(normalizedId);
167
+ else scanCandidatesById.set(normalizedId, nextCandidates);
168
+ recompute(normalizedId);
169
+ }
170
+ function replaceTransformLayer(id, nextCandidates) {
171
+ const normalizedId = cleanUrl(id);
172
+ if (nextCandidates.size === 0) transformCandidatesById.delete(normalizedId);
173
+ else transformCandidatesById.set(normalizedId, nextCandidates);
174
+ recompute(normalizedId);
175
+ }
176
+ function recompute(id) {
177
+ const normalizedId = cleanUrl(id);
178
+ replaceFinal(normalizedId, new Set([...scanCandidatesById.get(normalizedId) ?? [], ...transformCandidatesById.get(normalizedId) ?? []]));
179
+ }
180
+ function syncInline(inlineCandidates) {
181
+ inlineIncludedCandidates = new Set(inlineCandidates?.included ?? []);
182
+ inlineExcludedCandidates = new Set(inlineCandidates?.excluded ?? []);
183
+ }
184
+ function remove(id) {
185
+ const normalizedId = cleanUrl(id);
186
+ scanCandidatesById.delete(normalizedId);
187
+ transformCandidatesById.delete(normalizedId);
188
+ const previousCandidates = candidatesById.get(normalizedId);
189
+ if (!previousCandidates) return;
190
+ removeCandidateSet(candidateCount, previousCandidates);
191
+ candidatesById.delete(normalizedId);
192
+ }
193
+ function values() {
194
+ const values = new Set([...candidateCount.keys(), ...inlineIncludedCandidates]);
195
+ for (const candidate of inlineExcludedCandidates) values.delete(candidate);
196
+ return values;
197
+ }
198
+ function valuesForEntries(entries) {
199
+ if (entries === void 0) return values();
200
+ const filtered = /* @__PURE__ */ new Set();
201
+ for (const [id, candidates] of candidatesById) {
202
+ if (!isFileMatchedByEntries(id, entries)) continue;
203
+ for (const candidate of candidates) filtered.add(candidate);
204
+ }
205
+ for (const candidate of inlineIncludedCandidates) filtered.add(candidate);
206
+ for (const candidate of inlineExcludedCandidates) filtered.delete(candidate);
207
+ return filtered;
208
+ }
209
+ function clear() {
210
+ candidatesById.clear();
211
+ scanCandidatesById.clear();
212
+ transformCandidatesById.clear();
213
+ candidateCount.clear();
214
+ inlineIncludedCandidates.clear();
215
+ inlineExcludedCandidates.clear();
216
+ }
217
+ function snapshot() {
218
+ return {
219
+ candidatesById: [...candidatesById.entries()].map(([id, candidates]) => [id, [...candidates]]),
220
+ scanCandidatesById: [...scanCandidatesById.entries()].map(([id, candidates]) => [id, [...candidates]]),
221
+ transformCandidatesById: [...transformCandidatesById.entries()].map(([id, candidates]) => [id, [...candidates]]),
222
+ inlineExcludedCandidates: [...inlineExcludedCandidates],
223
+ inlineIncludedCandidates: [...inlineIncludedCandidates]
224
+ };
225
+ }
226
+ function restore(snapshot) {
227
+ clear();
228
+ inlineExcludedCandidates = new Set(snapshot.inlineExcludedCandidates);
229
+ inlineIncludedCandidates = new Set(snapshot.inlineIncludedCandidates);
230
+ const scanEntries = snapshot.scanCandidatesById ?? snapshot.candidatesById;
231
+ for (const [id, candidates] of scanEntries) {
232
+ const candidateSet = new Set(candidates);
233
+ if (candidateSet.size === 0) continue;
234
+ scanCandidatesById.set(id, candidateSet);
235
+ }
236
+ for (const [id, candidates] of snapshot.transformCandidatesById ?? []) {
237
+ const candidateSet = new Set(candidates);
238
+ if (candidateSet.size === 0) continue;
239
+ transformCandidatesById.set(id, candidateSet);
240
+ }
241
+ for (const [id, candidates] of snapshot.candidatesById) {
242
+ const candidateSet = new Set(candidates);
243
+ if (candidateSet.size === 0) continue;
244
+ candidatesById.set(id, candidateSet);
245
+ addCandidateSet(candidateCount, candidateSet);
246
+ }
247
+ }
248
+ return {
249
+ sync,
250
+ merge,
251
+ syncFile,
252
+ scanRoot,
253
+ syncInline,
254
+ remove,
255
+ values,
256
+ valuesForEntries,
257
+ snapshot,
258
+ restore,
259
+ clear
260
+ };
261
+ }
262
+ //#endregion
263
+ Object.defineProperty(exports, "createSourceCandidateCollector", {
264
+ enumerable: true,
265
+ get: function() {
266
+ return createSourceCandidateCollector;
267
+ }
268
+ });
269
+ Object.defineProperty(exports, "isSourceCandidateRequest", {
270
+ enumerable: true,
271
+ get: function() {
272
+ return isSourceCandidateRequest;
273
+ }
274
+ });
@@ -0,0 +1,259 @@
1
+ import { j as expandTailwindSourceEntries } from "./v3-engine-D61eilBl.mjs";
2
+ import path from "node:path";
3
+ import { extractSourceCandidates } from "tailwindcss-patch";
4
+ import { readFile } from "node:fs/promises";
5
+ import fg from "fast-glob";
6
+ import micromatch from "micromatch";
7
+ //#region src/bundlers/vite/source-candidates.ts
8
+ const CLEAN_URL_RE = /[?#].*$/;
9
+ const SOURCE_CANDIDATE_EXTENSIONS = [
10
+ "js",
11
+ "jsx",
12
+ "mjs",
13
+ "cjs",
14
+ "ts",
15
+ "tsx",
16
+ "mts",
17
+ "cts",
18
+ "vue",
19
+ "uvue",
20
+ "nvue",
21
+ "svelte",
22
+ "mpx",
23
+ "html",
24
+ "wxml",
25
+ "axml",
26
+ "jxml",
27
+ "ksml",
28
+ "ttml",
29
+ "qml",
30
+ "tyml",
31
+ "xhsml",
32
+ "swan",
33
+ "css",
34
+ "wxss",
35
+ "acss",
36
+ "jxss",
37
+ "ttss",
38
+ "qss",
39
+ "tyss",
40
+ "scss",
41
+ "sass",
42
+ "less",
43
+ "styl",
44
+ "stylus"
45
+ ];
46
+ const SOURCE_CANDIDATE_EXTENSION_RE = /\.(?:[cm]?[jt]sx?|vue|uvue|nvue|svelte|mpx|html|wxml|axml|jxml|ksml|ttml|qml|tyml|xhsml|swan|css|wxss|acss|jxss|ttss|qss|tyss|scss|sass|less|stylus?)$/;
47
+ const SOURCE_CANDIDATE_GLOB = `**/*.{${SOURCE_CANDIDATE_EXTENSIONS.join(",")}}`;
48
+ const DEFAULT_SCAN_IGNORE = ["**/node_modules/**", "**/.git/**"];
49
+ const sourceCandidateContentCache = /* @__PURE__ */ new Map();
50
+ function cleanUrl(id) {
51
+ return path.resolve(id.replace(CLEAN_URL_RE, ""));
52
+ }
53
+ function toPosixPath(value) {
54
+ return value.split(path.sep).join("/");
55
+ }
56
+ function resolveOutDirIgnorePattern(root, outDir) {
57
+ if (!outDir) return;
58
+ const relative = path.relative(root, path.resolve(root, outDir));
59
+ if (!relative || relative.startsWith("..") || path.isAbsolute(relative)) return;
60
+ return `${toPosixPath(relative)}/**`;
61
+ }
62
+ function resolveSourceCandidateExtension(id) {
63
+ const normalized = cleanUrl(id);
64
+ return /\.([^.\\/]+)$/.exec(normalized)?.[1] ?? "html";
65
+ }
66
+ function createSourceCandidateContentCacheKey(extension, source) {
67
+ return `${extension}\0${source}`;
68
+ }
69
+ function isSourceCandidateRequest(id) {
70
+ return SOURCE_CANDIDATE_EXTENSION_RE.test(cleanUrl(id));
71
+ }
72
+ function removeCandidateSet(candidateCount, candidates) {
73
+ for (const candidate of candidates) {
74
+ const count = candidateCount.get(candidate);
75
+ if (count == null) continue;
76
+ if (count <= 1) {
77
+ candidateCount.delete(candidate);
78
+ continue;
79
+ }
80
+ candidateCount.set(candidate, count - 1);
81
+ }
82
+ }
83
+ function addCandidateSet(candidateCount, candidates) {
84
+ for (const candidate of candidates) candidateCount.set(candidate, (candidateCount.get(candidate) ?? 0) + 1);
85
+ }
86
+ function isFileMatchedByEntries(file, entries) {
87
+ if (!entries?.length) return true;
88
+ const positiveEntries = entries.filter((entry) => !entry.negated);
89
+ const negativeEntries = entries.filter((entry) => entry.negated);
90
+ if (positiveEntries.length === 0) return false;
91
+ const resolvedFile = path.resolve(file);
92
+ if (!positiveEntries.some((entry) => {
93
+ const relative = toPosixPath(path.relative(path.resolve(entry.base), resolvedFile));
94
+ const pattern = path.isAbsolute(entry.pattern) ? toPosixPath(path.relative(path.resolve(entry.base), entry.pattern)) : entry.pattern;
95
+ return relative && !relative.startsWith("../") && !path.isAbsolute(relative) && micromatch.isMatch(relative, pattern);
96
+ })) return false;
97
+ return !negativeEntries.some((entry) => {
98
+ const relative = toPosixPath(path.relative(path.resolve(entry.base), resolvedFile));
99
+ const pattern = path.isAbsolute(entry.pattern) ? toPosixPath(path.relative(path.resolve(entry.base), entry.pattern)) : entry.pattern;
100
+ return relative && !relative.startsWith("../") && !path.isAbsolute(relative) && micromatch.isMatch(relative, pattern);
101
+ });
102
+ }
103
+ function createSourceCandidateCollector() {
104
+ const candidatesById = /* @__PURE__ */ new Map();
105
+ const scanCandidatesById = /* @__PURE__ */ new Map();
106
+ const transformCandidatesById = /* @__PURE__ */ new Map();
107
+ const candidateCount = /* @__PURE__ */ new Map();
108
+ let inlineIncludedCandidates = /* @__PURE__ */ new Set();
109
+ let inlineExcludedCandidates = /* @__PURE__ */ new Set();
110
+ async function sync(id, source) {
111
+ const normalizedId = cleanUrl(id);
112
+ const extension = resolveSourceCandidateExtension(normalizedId);
113
+ const contentCacheKey = createSourceCandidateContentCacheKey(extension, source);
114
+ const cachedCandidates = sourceCandidateContentCache.get(contentCacheKey);
115
+ if (cachedCandidates) {
116
+ replaceScanLayer(normalizedId, new Set(cachedCandidates));
117
+ return;
118
+ }
119
+ const nextCandidates = new Set(await extractSourceCandidates(source, extension));
120
+ sourceCandidateContentCache.set(contentCacheKey, [...nextCandidates]);
121
+ replaceScanLayer(normalizedId, nextCandidates);
122
+ }
123
+ async function merge(id, source) {
124
+ const normalizedId = cleanUrl(id);
125
+ const extension = resolveSourceCandidateExtension(normalizedId);
126
+ const contentCacheKey = createSourceCandidateContentCacheKey(extension, source);
127
+ const cachedCandidates = sourceCandidateContentCache.get(contentCacheKey);
128
+ const extractedCandidates = cachedCandidates ? new Set(cachedCandidates) : new Set(await extractSourceCandidates(source, extension));
129
+ if (!cachedCandidates) sourceCandidateContentCache.set(contentCacheKey, [...extractedCandidates]);
130
+ replaceTransformLayer(normalizedId, extractedCandidates);
131
+ }
132
+ async function syncFile(id) {
133
+ const normalizedId = cleanUrl(id);
134
+ await sync(normalizedId, await readFile(normalizedId, "utf8"));
135
+ }
136
+ async function scanRoot({ entries, root, outDir }) {
137
+ const resolvedRoot = path.resolve(root);
138
+ const outDirIgnore = resolveOutDirIgnorePattern(resolvedRoot, outDir);
139
+ const ignore = outDirIgnore ? [...DEFAULT_SCAN_IGNORE, outDirIgnore] : DEFAULT_SCAN_IGNORE;
140
+ const files = entries ? await expandTailwindSourceEntries(entries, { ignore }) : await fg(SOURCE_CANDIDATE_GLOB, {
141
+ absolute: true,
142
+ cwd: resolvedRoot,
143
+ ignore,
144
+ onlyFiles: true,
145
+ unique: true
146
+ });
147
+ await Promise.all(files.map((file) => syncFile(file)));
148
+ }
149
+ function replaceFinal(id, nextCandidates) {
150
+ const normalizedId = cleanUrl(id);
151
+ const previousCandidates = candidatesById.get(normalizedId);
152
+ if (previousCandidates) {
153
+ removeCandidateSet(candidateCount, previousCandidates);
154
+ candidatesById.delete(normalizedId);
155
+ }
156
+ if (nextCandidates.size === 0) return;
157
+ candidatesById.set(normalizedId, nextCandidates);
158
+ addCandidateSet(candidateCount, nextCandidates);
159
+ }
160
+ function replaceScanLayer(id, nextCandidates) {
161
+ const normalizedId = cleanUrl(id);
162
+ if (nextCandidates.size === 0) scanCandidatesById.delete(normalizedId);
163
+ else scanCandidatesById.set(normalizedId, nextCandidates);
164
+ recompute(normalizedId);
165
+ }
166
+ function replaceTransformLayer(id, nextCandidates) {
167
+ const normalizedId = cleanUrl(id);
168
+ if (nextCandidates.size === 0) transformCandidatesById.delete(normalizedId);
169
+ else transformCandidatesById.set(normalizedId, nextCandidates);
170
+ recompute(normalizedId);
171
+ }
172
+ function recompute(id) {
173
+ const normalizedId = cleanUrl(id);
174
+ replaceFinal(normalizedId, new Set([...scanCandidatesById.get(normalizedId) ?? [], ...transformCandidatesById.get(normalizedId) ?? []]));
175
+ }
176
+ function syncInline(inlineCandidates) {
177
+ inlineIncludedCandidates = new Set(inlineCandidates?.included ?? []);
178
+ inlineExcludedCandidates = new Set(inlineCandidates?.excluded ?? []);
179
+ }
180
+ function remove(id) {
181
+ const normalizedId = cleanUrl(id);
182
+ scanCandidatesById.delete(normalizedId);
183
+ transformCandidatesById.delete(normalizedId);
184
+ const previousCandidates = candidatesById.get(normalizedId);
185
+ if (!previousCandidates) return;
186
+ removeCandidateSet(candidateCount, previousCandidates);
187
+ candidatesById.delete(normalizedId);
188
+ }
189
+ function values() {
190
+ const values = new Set([...candidateCount.keys(), ...inlineIncludedCandidates]);
191
+ for (const candidate of inlineExcludedCandidates) values.delete(candidate);
192
+ return values;
193
+ }
194
+ function valuesForEntries(entries) {
195
+ if (entries === void 0) return values();
196
+ const filtered = /* @__PURE__ */ new Set();
197
+ for (const [id, candidates] of candidatesById) {
198
+ if (!isFileMatchedByEntries(id, entries)) continue;
199
+ for (const candidate of candidates) filtered.add(candidate);
200
+ }
201
+ for (const candidate of inlineIncludedCandidates) filtered.add(candidate);
202
+ for (const candidate of inlineExcludedCandidates) filtered.delete(candidate);
203
+ return filtered;
204
+ }
205
+ function clear() {
206
+ candidatesById.clear();
207
+ scanCandidatesById.clear();
208
+ transformCandidatesById.clear();
209
+ candidateCount.clear();
210
+ inlineIncludedCandidates.clear();
211
+ inlineExcludedCandidates.clear();
212
+ }
213
+ function snapshot() {
214
+ return {
215
+ candidatesById: [...candidatesById.entries()].map(([id, candidates]) => [id, [...candidates]]),
216
+ scanCandidatesById: [...scanCandidatesById.entries()].map(([id, candidates]) => [id, [...candidates]]),
217
+ transformCandidatesById: [...transformCandidatesById.entries()].map(([id, candidates]) => [id, [...candidates]]),
218
+ inlineExcludedCandidates: [...inlineExcludedCandidates],
219
+ inlineIncludedCandidates: [...inlineIncludedCandidates]
220
+ };
221
+ }
222
+ function restore(snapshot) {
223
+ clear();
224
+ inlineExcludedCandidates = new Set(snapshot.inlineExcludedCandidates);
225
+ inlineIncludedCandidates = new Set(snapshot.inlineIncludedCandidates);
226
+ const scanEntries = snapshot.scanCandidatesById ?? snapshot.candidatesById;
227
+ for (const [id, candidates] of scanEntries) {
228
+ const candidateSet = new Set(candidates);
229
+ if (candidateSet.size === 0) continue;
230
+ scanCandidatesById.set(id, candidateSet);
231
+ }
232
+ for (const [id, candidates] of snapshot.transformCandidatesById ?? []) {
233
+ const candidateSet = new Set(candidates);
234
+ if (candidateSet.size === 0) continue;
235
+ transformCandidatesById.set(id, candidateSet);
236
+ }
237
+ for (const [id, candidates] of snapshot.candidatesById) {
238
+ const candidateSet = new Set(candidates);
239
+ if (candidateSet.size === 0) continue;
240
+ candidatesById.set(id, candidateSet);
241
+ addCandidateSet(candidateCount, candidateSet);
242
+ }
243
+ }
244
+ return {
245
+ sync,
246
+ merge,
247
+ syncFile,
248
+ scanRoot,
249
+ syncInline,
250
+ remove,
251
+ values,
252
+ valuesForEntries,
253
+ snapshot,
254
+ restore,
255
+ clear
256
+ };
257
+ }
258
+ //#endregion
259
+ export { isSourceCandidateRequest as n, createSourceCandidateCollector as t };
@@ -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 {};
@@ -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>>;