weapp-tailwindcss 5.0.0-next.3 → 5.0.0-next.7

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 (171) hide show
  1. package/README.md +4 -5
  2. package/bin/weapp-tailwindcss.js +1 -21
  3. package/dist/bundlers/shared/css-cleanup/at-rules.d.ts +2 -0
  4. package/dist/bundlers/shared/css-cleanup/color-gamut.d.ts +3 -0
  5. package/dist/bundlers/shared/css-cleanup/root-cleanups.d.ts +4 -0
  6. package/dist/bundlers/shared/css-cleanup/selectors.d.ts +8 -0
  7. package/dist/bundlers/shared/css-cleanup.d.ts +1 -2
  8. package/dist/bundlers/shared/generator-css/config-directive.d.ts +2 -0
  9. package/dist/bundlers/shared/generator-css/directives.d.ts +11 -0
  10. package/dist/bundlers/shared/generator-css/legacy-compat.d.ts +7 -0
  11. package/dist/bundlers/shared/generator-css/legacy-selectors.d.ts +5 -0
  12. package/dist/bundlers/shared/generator-css/legacy-units.d.ts +1 -0
  13. package/dist/bundlers/shared/generator-css/markers.d.ts +16 -0
  14. package/dist/bundlers/shared/generator-css/source-files.d.ts +11 -0
  15. package/dist/bundlers/shared/generator-css/source-resolver.d.ts +10 -0
  16. package/dist/bundlers/shared/generator-css.d.ts +12 -22
  17. package/dist/bundlers/vite/css-finalizer.d.ts +1 -1
  18. package/dist/bundlers/vite/generate-bundle/candidates.d.ts +2 -0
  19. package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +20 -0
  20. package/dist/bundlers/vite/generate-bundle/css-share-scope.d.ts +3 -0
  21. package/dist/bundlers/vite/generate-bundle/dirty-state.d.ts +1 -0
  22. package/dist/bundlers/vite/generate-bundle/js-entries.d.ts +2 -0
  23. package/dist/bundlers/vite/generate-bundle/js-handler-options.d.ts +8 -0
  24. package/dist/bundlers/vite/generate-bundle/js-linking.d.ts +13 -0
  25. package/dist/bundlers/vite/generate-bundle/metrics.d.ts +17 -0
  26. package/dist/bundlers/vite/generate-bundle/process-plan.d.ts +9 -0
  27. package/dist/bundlers/vite/generate-bundle/rollup-assets.d.ts +7 -0
  28. package/dist/bundlers/vite/generate-bundle/signatures.d.ts +8 -0
  29. package/dist/bundlers/vite/generate-bundle.d.ts +2 -1
  30. package/dist/bundlers/vite/index.d.ts +1 -1
  31. package/dist/bundlers/vite/official-tailwind-plugins.d.ts +5 -0
  32. package/dist/bundlers/vite/postcss-config.d.ts +6 -0
  33. package/dist/bundlers/vite/rewrite-css-imports.d.ts +1 -0
  34. package/dist/bundlers/vite/runtime-class-set.d.ts +22 -0
  35. package/dist/bundlers/vite/tailwind-basedir.d.ts +1 -0
  36. package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +1 -0
  37. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +1 -1
  38. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +0 -1
  39. package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +1 -1
  40. package/dist/cache-DPN5yKSX.js +497 -0
  41. package/dist/cache-nq0_XJoS.mjs +429 -0
  42. package/dist/cli/context.d.ts +0 -3
  43. package/dist/cli/helpers.d.ts +1 -2
  44. package/dist/cli/mount-options.d.ts +2 -0
  45. package/dist/cli/types.d.ts +0 -2
  46. package/dist/cli.js +108 -598
  47. package/dist/cli.mjs +119 -608
  48. package/dist/constants.d.ts +1 -2
  49. package/dist/context/tailwindcss.d.ts +1 -1
  50. package/dist/core.js +13 -20
  51. package/dist/core.mjs +8 -14
  52. package/dist/css-macro/postcss.js +1 -1
  53. package/dist/css-macro/postcss.mjs +1 -1
  54. package/dist/css-macro.d.ts +1 -0
  55. package/dist/css-macro.js +2 -2
  56. package/dist/css-macro.mjs +2 -2
  57. package/dist/defaults.d.ts +15 -1
  58. package/dist/defaults.js +33 -14
  59. package/dist/defaults.mjs +30 -15
  60. package/dist/generator/index.d.ts +1 -1
  61. package/dist/generator/options.d.ts +3 -4
  62. package/dist/{generator-Y-Ikv4Fu.mjs → generator-CzfdCZyd.mjs} +277 -23
  63. package/dist/{generator-mmhXzZnv.js → generator-TOp4uz7c.js} +281 -27
  64. package/dist/{generator-css-Bwy_Uz89.mjs → generator-css-B938WI9a.mjs} +694 -506
  65. package/dist/{generator-css-CRLrHW4F.js → generator-css-Dnpl-IY2.js} +699 -505
  66. package/dist/generator.js +1 -1
  67. package/dist/generator.mjs +1 -1
  68. package/dist/gulp.js +29 -28
  69. package/dist/gulp.mjs +25 -24
  70. package/dist/index.d.ts +1 -1
  71. package/dist/index.js +6 -6
  72. package/dist/index.mjs +5 -5
  73. package/dist/js/index.d.ts +1 -0
  74. package/dist/js/literal-transform.d.ts +2 -0
  75. package/dist/logger-BRy6XPQ2.js +1 -0
  76. package/dist/logger-Bub1jggA.mjs +2 -0
  77. package/dist/postcss/config-directive.d.ts +1 -0
  78. package/dist/postcss/context.d.ts +9 -0
  79. package/dist/postcss/source-files.d.ts +8 -0
  80. package/dist/postcss/tailwind-version.d.ts +3 -0
  81. package/dist/postcss-BtAP6sQO.mjs +288 -0
  82. package/dist/postcss-WsXlC7A-.js +298 -0
  83. package/dist/postcss.d.ts +2 -2
  84. package/dist/postcss.js +3 -276
  85. package/dist/postcss.mjs +1 -269
  86. package/dist/{recorder-GdTJ3QqX.js → precheck-Dka94ArV.js} +141 -283
  87. package/dist/{recorder-XdFvVASS.mjs → precheck-DlrmwCc-.mjs} +106 -247
  88. package/dist/presets.js +6 -4
  89. package/dist/presets.mjs +4 -2
  90. package/dist/reset.d.ts +1 -0
  91. package/dist/{css-imports-BbrbluP9.js → run-tasks-B50A3pxt.js} +6 -55
  92. package/dist/{css-imports-CSdPq_Sc.mjs → run-tasks-DdNi-hkk.mjs} +5 -42
  93. package/dist/runtime-patch-pGdCqAEu.mjs +71 -0
  94. package/dist/runtime-patch-qwuisukL.js +85 -0
  95. package/dist/tailwindcss/miniprogram.d.ts +5 -1
  96. package/dist/tailwindcss/patcher-options.d.ts +3 -51
  97. package/dist/tailwindcss/patcher.d.ts +1 -2
  98. package/dist/tailwindcss/runtime-patch.d.ts +5 -0
  99. package/dist/tailwindcss/runtime.d.ts +2 -3
  100. package/dist/tailwindcss/targets.d.ts +1 -5
  101. package/dist/tailwindcss/v4/patcher-options.d.ts +1 -23
  102. package/dist/tailwindcss/v4/patcher.d.ts +2 -1
  103. package/dist/tailwindcss/v4-engine/types.d.ts +1 -1
  104. package/dist/tailwindcss/version.d.ts +4 -0
  105. package/dist/{logger-BoVx1Dbt.mjs → tailwindcss-BIJ185GB.mjs} +25 -434
  106. package/dist/{logger-BZ45DZJT.js → tailwindcss-T1U5T-iF.js} +30 -468
  107. package/dist/typedoc.export.d.ts +0 -2
  108. package/dist/types/index.d.ts +2 -9
  109. package/dist/types/shared.d.ts +3 -0
  110. package/dist/types/user-defined-options/general.d.ts +0 -2
  111. package/dist/types/user-defined-options/important.d.ts +3 -3
  112. package/dist/uni-app-x/vite.d.ts +1 -1
  113. package/dist/utils/disabled.d.ts +2 -3
  114. package/dist/{vite-BDywuCjn.mjs → vite-BXChkciE.mjs} +669 -481
  115. package/dist/{vite-DgRh_GXn.js → vite-D0CoRblu.js} +707 -519
  116. package/dist/vite.d.ts +1 -2
  117. package/dist/vite.js +3 -4
  118. package/dist/vite.mjs +2 -2
  119. package/dist/weapp-tw-css-import-rewrite-loader.js +1 -1
  120. package/dist/{webpack-CiHqVZTg.mjs → webpack-BNdGm9KL.mjs} +224 -38
  121. package/dist/{webpack-CAJR4hhP.js → webpack-D-sUCY0u.js} +250 -69
  122. package/dist/webpack.js +1 -1
  123. package/dist/webpack.mjs +1 -1
  124. package/package.json +23 -35
  125. package/dist/bundlers/shared/generator-candidates.d.ts +0 -5
  126. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-assets.d.ts +0 -14
  127. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-loaders.d.ts +0 -15
  128. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4.d.ts +0 -9
  129. package/dist/bundlers/webpack/shared/css-imports.d.ts +0 -6
  130. package/dist/cli/config.d.ts +0 -5
  131. package/dist/cli/helpers/patch-cwd.d.ts +0 -1
  132. package/dist/cli/mount-options/patch-status.d.ts +0 -2
  133. package/dist/cli/patch-options.d.ts +0 -6
  134. package/dist/cli/tokens.d.ts +0 -4
  135. package/dist/cli/workspace/package-dirs.d.ts +0 -3
  136. package/dist/cli/workspace/patch-package.d.ts +0 -3
  137. package/dist/cli/workspace/patch-utils.d.ts +0 -3
  138. package/dist/cli/workspace/types.d.ts +0 -11
  139. package/dist/cli/workspace/workspace-globs.d.ts +0 -2
  140. package/dist/cli/workspace/workspace-io.d.ts +0 -1
  141. package/dist/cli/workspace/workspace-lock.d.ts +0 -1
  142. package/dist/cli/workspace.d.ts +0 -2
  143. package/dist/experimental/index.d.ts +0 -2
  144. package/dist/experimental/oxc/ast-utils.d.ts +0 -30
  145. package/dist/experimental/oxc/index.d.ts +0 -2
  146. package/dist/experimental/oxc/module-specifiers.d.ts +0 -2
  147. package/dist/experimental/shared/cache.d.ts +0 -3
  148. package/dist/experimental/shared/transform.d.ts +0 -3
  149. package/dist/experimental/shared.d.ts +0 -8
  150. package/dist/experimental/swc/ast-utils.d.ts +0 -30
  151. package/dist/experimental/swc/index.d.ts +0 -2
  152. package/dist/experimental/swc/module-specifiers.d.ts +0 -2
  153. package/dist/js/syntax.d.ts +0 -10
  154. package/dist/loader-anchors-1MumTAtA.mjs +0 -205
  155. package/dist/loader-anchors-TrFvT6g1.js +0 -273
  156. package/dist/patcher-options-6gJN2EXy.js +0 -115
  157. package/dist/patcher-options-DQfR5xxT.mjs +0 -92
  158. package/dist/tailwindcss/recorder.d.ts +0 -13
  159. package/dist/tailwindcss/targets/paths.d.ts +0 -13
  160. package/dist/tailwindcss/targets/record-io.d.ts +0 -5
  161. package/dist/tailwindcss/targets/recorder.d.ts +0 -3
  162. package/dist/tailwindcss/targets/types.d.ts +0 -35
  163. package/dist/types/disabled-options.d.ts +0 -4
  164. package/dist/webpack4.d.ts +0 -4
  165. package/dist/webpack4.js +0 -387
  166. package/dist/webpack4.mjs +0 -379
  167. package/scripts/postinstall.mjs +0 -59
  168. /package/dist/{constants-p1dyh1x1.js → constants-BoB_6lFw.js} +0 -0
  169. /package/dist/{constants-B-_T5UnW.mjs → constants-E_loJC49.mjs} +0 -0
  170. /package/dist/{utils-7DUGTFED.mjs → utils-BJjKRQgf.mjs} +0 -0
  171. /package/dist/{utils-DmC9_In3.js → utils-VZvGusYs.js} +0 -0
@@ -0,0 +1,429 @@
1
+ import { createRequire } from "node:module";
2
+ import path from "node:path";
3
+ import process from "node:process";
4
+ import { logger } from "@weapp-tailwindcss/logger";
5
+ import { defuOverrideArray } from "@weapp-tailwindcss/shared";
6
+ import { TailwindcssPatcher } from "tailwindcss-patch";
7
+ import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
8
+ import { fileURLToPath } from "node:url";
9
+ //#region src/context/workspace.ts
10
+ const IGNORED_WORKSPACE_DIRS = new Set([
11
+ "node_modules",
12
+ ".git",
13
+ ".hg",
14
+ ".svn",
15
+ ".turbo",
16
+ ".output",
17
+ ".next",
18
+ "dist",
19
+ "build"
20
+ ]);
21
+ function findWorkspaceRoot(startDir) {
22
+ if (!startDir) return;
23
+ let current = path.resolve(startDir);
24
+ while (true) {
25
+ if (existsSync(path.join(current, "pnpm-workspace.yaml"))) return current;
26
+ const parent = path.dirname(current);
27
+ if (parent === current) return;
28
+ current = parent;
29
+ }
30
+ }
31
+ function findNearestPackageRoot(startDir) {
32
+ if (!startDir) return;
33
+ let current = path.resolve(startDir);
34
+ while (true) {
35
+ if (existsSync(path.join(current, "package.json"))) return current;
36
+ const parent = path.dirname(current);
37
+ if (parent === current) return;
38
+ current = parent;
39
+ }
40
+ }
41
+ function findWorkspacePackageDir(rootDir, packageName) {
42
+ const visited = /* @__PURE__ */ new Set();
43
+ const queue = [path.resolve(rootDir)];
44
+ while (queue.length > 0) {
45
+ const current = queue.shift();
46
+ const normalized = path.normalize(current);
47
+ if (visited.has(normalized)) continue;
48
+ visited.add(normalized);
49
+ try {
50
+ const pkgPath = path.join(normalized, "package.json");
51
+ if (existsSync(pkgPath)) {
52
+ if (JSON.parse(readFileSync(pkgPath, "utf8"))?.name === packageName) return normalized;
53
+ }
54
+ } catch {}
55
+ let entries;
56
+ try {
57
+ entries = readdirSync(normalized, { withFileTypes: true });
58
+ } catch {
59
+ continue;
60
+ }
61
+ for (const entry of entries) {
62
+ if (!entry.isDirectory() || IGNORED_WORKSPACE_DIRS.has(entry.name) || entry.isSymbolicLink?.()) continue;
63
+ queue.push(path.join(normalized, entry.name));
64
+ }
65
+ }
66
+ }
67
+ //#endregion
68
+ //#region src/tailwindcss/patcher-options.ts
69
+ function resolveTailwindcssOptions(options) {
70
+ return options?.tailwindcss ?? options?.tailwind;
71
+ }
72
+ function normalizeExtendLengthUnits(value) {
73
+ if (value === false) return false;
74
+ if (value === true) return { enabled: true };
75
+ if (value && typeof value === "object") return {
76
+ enabled: true,
77
+ ...value
78
+ };
79
+ }
80
+ function normalizeTailwindcssPatcherOptions(options) {
81
+ return options;
82
+ }
83
+ //#endregion
84
+ //#region src/tailwindcss/patcher-resolve.ts
85
+ const GENERIC_RELATIVE_SPECIFIERS = [".", ".."];
86
+ const DEFAULT_TAILWIND_CONFIG_SPECIFIERS = ["stubs/config.full.js", "defaultConfig.js"];
87
+ const TAILWIND_CONFIG_FILES = [
88
+ "tailwind.config.js",
89
+ "tailwind.config.cjs",
90
+ "tailwind.config.mjs",
91
+ "tailwind.config.ts",
92
+ "tailwind.config.cts",
93
+ "tailwind.config.mts"
94
+ ];
95
+ function isPathSpecifier(specifier) {
96
+ if (!specifier) return false;
97
+ if (specifier.startsWith("file://")) return true;
98
+ if (path.isAbsolute(specifier)) return true;
99
+ return GENERIC_RELATIVE_SPECIFIERS.some((prefix) => specifier.startsWith(`${prefix}/`) || specifier.startsWith(`${prefix}\\`));
100
+ }
101
+ function resolveModuleFromPaths(specifier, paths) {
102
+ if (!specifier || isPathSpecifier(specifier) || paths.length === 0) return;
103
+ try {
104
+ return createRequire(import.meta.url).resolve(specifier, { paths });
105
+ } catch {
106
+ return;
107
+ }
108
+ }
109
+ function resolveTailwindConfigFallback(packageName, paths) {
110
+ if (!packageName) return;
111
+ for (const suffix of DEFAULT_TAILWIND_CONFIG_SPECIFIERS) {
112
+ const resolved = resolveModuleFromPaths(`${packageName}/${suffix}`, paths);
113
+ if (resolved) return resolved;
114
+ }
115
+ }
116
+ function appendNodeModules(paths, dir) {
117
+ if (!dir) return;
118
+ const nodeModulesDir = path.join(dir, "node_modules");
119
+ if (existsSync(nodeModulesDir)) paths.add(nodeModulesDir);
120
+ }
121
+ function findTailwindConfig(searchRoots) {
122
+ for (const root of searchRoots) for (const file of TAILWIND_CONFIG_FILES) {
123
+ const candidate = path.resolve(root, file);
124
+ if (existsSync(candidate)) return candidate;
125
+ }
126
+ }
127
+ function createDefaultResolvePaths(basedir) {
128
+ const paths = /* @__PURE__ */ new Set();
129
+ let fallbackCandidates = [];
130
+ if (basedir) {
131
+ const resolvedBase = path.resolve(basedir);
132
+ appendNodeModules(paths, resolvedBase);
133
+ fallbackCandidates.push(resolvedBase);
134
+ const packageRoot = findNearestPackageRoot(resolvedBase);
135
+ if (packageRoot) {
136
+ appendNodeModules(paths, packageRoot);
137
+ fallbackCandidates.push(packageRoot);
138
+ }
139
+ }
140
+ const cwd = process.cwd();
141
+ appendNodeModules(paths, cwd);
142
+ try {
143
+ const modulePath = fileURLToPath(import.meta.url);
144
+ const candidate = existsSync(modulePath) && !path.extname(modulePath) ? modulePath : path.dirname(modulePath);
145
+ paths.add(candidate);
146
+ } catch {
147
+ paths.add(import.meta.url);
148
+ }
149
+ if (paths.size === 0) {
150
+ fallbackCandidates = fallbackCandidates.filter(Boolean);
151
+ if (fallbackCandidates.length === 0) fallbackCandidates.push(cwd);
152
+ for (const candidate of fallbackCandidates) paths.add(candidate);
153
+ }
154
+ return [...paths];
155
+ }
156
+ //#endregion
157
+ //#region src/tailwindcss/version.ts
158
+ function normalizeSupportedTailwindcssMajorVersion(version) {
159
+ return version === 3 || version === 4 ? version : void 0;
160
+ }
161
+ function readPackageJson(packageJsonPath) {
162
+ try {
163
+ return JSON.parse(readFileSync(packageJsonPath, "utf8"));
164
+ } catch {
165
+ return;
166
+ }
167
+ }
168
+ function findPackageJsonDeclaringPackage(packageName, base) {
169
+ let current = path.resolve(base);
170
+ while (true) {
171
+ const pkgPath = path.join(current, "package.json");
172
+ if (existsSync(pkgPath)) {
173
+ const pkg = readPackageJson(pkgPath);
174
+ if (readDeclaredPackageVersion(packageName, pkg)) return pkgPath;
175
+ if (pkg?.name !== "weapp-tailwindcss") return;
176
+ }
177
+ const parent = path.dirname(current);
178
+ if (parent === current) return;
179
+ current = parent;
180
+ }
181
+ }
182
+ function readDeclaredPackageVersion(packageName, pkg) {
183
+ return pkg?.dependencies?.[packageName] ?? pkg?.devDependencies?.[packageName] ?? pkg?.peerDependencies?.[packageName] ?? pkg?.optionalDependencies?.[packageName];
184
+ }
185
+ function readDeclaredPackageMajorVersion(version) {
186
+ const match = version?.match(/(?:^|\D)([34])(?:\.|\b)/);
187
+ return normalizeSupportedTailwindcssMajorVersion(match ? Number(match[1]) : void 0);
188
+ }
189
+ function readInstalledPackageMajorVersion(packageName, base) {
190
+ const packageJsonPath = findPackageJsonDeclaringPackage(packageName, base);
191
+ if (!packageJsonPath) return;
192
+ const declaredVersion = readDeclaredPackageVersion(packageName, readPackageJson(packageJsonPath));
193
+ if (!declaredVersion) return;
194
+ try {
195
+ const pkg = createRequire(packageJsonPath)(`${packageName}/package.json`);
196
+ return normalizeSupportedTailwindcssMajorVersion(Number(pkg.version?.split(".")[0]));
197
+ } catch {
198
+ return readDeclaredPackageMajorVersion(declaredVersion);
199
+ }
200
+ }
201
+ //#endregion
202
+ //#region src/tailwindcss/patcher.ts
203
+ function createFallbackTailwindcssPatcher() {
204
+ return {
205
+ packageInfo: {
206
+ name: "tailwindcss",
207
+ version: void 0,
208
+ rootPath: "",
209
+ packageJsonPath: "",
210
+ packageJson: {}
211
+ },
212
+ majorVersion: 4,
213
+ async getClassSet() {
214
+ return /* @__PURE__ */ new Set();
215
+ },
216
+ async extract(_options) {
217
+ return {
218
+ classList: [],
219
+ classSet: /* @__PURE__ */ new Set()
220
+ };
221
+ },
222
+ async collectContentTokens() {
223
+ return {
224
+ entries: [],
225
+ filesScanned: 0,
226
+ sources: [],
227
+ skippedFiles: []
228
+ };
229
+ }
230
+ };
231
+ }
232
+ let hasLoggedMissingTailwind = false;
233
+ const TAILWINDCSS_NOT_FOUND_RE = /tailwindcss not found/i;
234
+ const UNABLE_TO_LOCATE_TAILWINDCSS_RE = /unable to locate tailwind css package/i;
235
+ function isTailwindcssV4PackageName(packageName) {
236
+ return packageName === "@tailwindcss/postcss" || packageName === "tailwindcss4" || Boolean(packageName && packageName.includes("tailwindcss4"));
237
+ }
238
+ function createTailwindcssPatcher(options) {
239
+ const { basedir, cacheDir, supportCustomLengthUnitsPatch, tailwindcss, tailwindcssPatcherOptions } = options || {};
240
+ const cache = { driver: "memory" };
241
+ const normalizedBasedir = basedir ? path.resolve(basedir) : void 0;
242
+ const cacheRoot = findNearestPackageRoot(normalizedBasedir) ?? normalizedBasedir ?? process.cwd();
243
+ if (cacheDir) if (path.isAbsolute(cacheDir)) cache.dir = cacheDir;
244
+ else if (normalizedBasedir) cache.dir = path.resolve(normalizedBasedir, cacheDir);
245
+ else cache.dir = path.resolve(process.cwd(), cacheDir);
246
+ else cache.dir = path.join(cacheRoot, "node_modules", ".cache", "tailwindcss-patch");
247
+ if (normalizedBasedir) cache.cwd = normalizedBasedir;
248
+ const resolvePaths = createDefaultResolvePaths(cache.cwd ?? normalizedBasedir ?? process.cwd());
249
+ const normalizedUserOptions = normalizeTailwindcssPatcherOptions(tailwindcssPatcherOptions);
250
+ const extendLengthUnits = normalizeExtendLengthUnits(supportCustomLengthUnitsPatch ?? true);
251
+ const baseTailwindOptions = defuOverrideArray(tailwindcss ?? {}, {
252
+ cwd: normalizedBasedir,
253
+ resolve: { paths: resolvePaths }
254
+ });
255
+ if (!baseTailwindOptions.packageName) baseTailwindOptions.packageName = "tailwindcss";
256
+ if (!baseTailwindOptions.postcssPlugin) baseTailwindOptions.postcssPlugin = baseTailwindOptions.version === 4 || isTailwindcssV4PackageName(baseTailwindOptions.packageName) ? "@tailwindcss/postcss" : "tailwindcss";
257
+ if (typeof baseTailwindOptions.postcssPlugin === "string") {
258
+ const resolvedPlugin = resolveModuleFromPaths(baseTailwindOptions.postcssPlugin, resolvePaths);
259
+ if (resolvedPlugin) baseTailwindOptions.postcssPlugin = resolvedPlugin;
260
+ }
261
+ const resolvedOptions = defuOverrideArray(normalizedUserOptions ?? {}, {
262
+ projectRoot: normalizedBasedir,
263
+ cache,
264
+ tailwindcss: baseTailwindOptions,
265
+ apply: {
266
+ exposeContext: true,
267
+ extendLengthUnits
268
+ }
269
+ });
270
+ const resolvedTailwindOptions = resolvedOptions.tailwindcss;
271
+ if (resolvedTailwindOptions) {
272
+ const existingResolve = resolvedTailwindOptions.resolve ?? {};
273
+ const sourcePaths = Array.isArray(existingResolve.paths) && existingResolve.paths.length > 0 ? existingResolve.paths : resolvePaths;
274
+ resolvedTailwindOptions.resolve = {
275
+ ...existingResolve,
276
+ paths: [...new Set(sourcePaths)]
277
+ };
278
+ logger.debug("Tailwind resolve config %O", {
279
+ packageName: resolvedTailwindOptions.packageName,
280
+ version: resolvedTailwindOptions.version,
281
+ resolve: resolvedTailwindOptions.resolve,
282
+ cwd: resolvedTailwindOptions.cwd
283
+ });
284
+ if (typeof resolvedTailwindOptions.postcssPlugin === "string") {
285
+ const resolvedPlugin = resolveModuleFromPaths(resolvedTailwindOptions.postcssPlugin, resolvedTailwindOptions.resolve?.paths ?? resolvePaths);
286
+ if (resolvedPlugin) resolvedTailwindOptions.postcssPlugin = resolvedPlugin;
287
+ }
288
+ const searchRoots = /* @__PURE__ */ new Set();
289
+ if (resolvedTailwindOptions.cwd) searchRoots.add(resolvedTailwindOptions.cwd);
290
+ for (const resolvePath of resolvedTailwindOptions.resolve?.paths ?? []) {
291
+ const parentDir = path.dirname(resolvePath);
292
+ searchRoots.add(parentDir);
293
+ }
294
+ const configPath = findTailwindConfig(searchRoots);
295
+ if (!resolvedTailwindOptions.config) if (configPath) resolvedTailwindOptions.config = configPath;
296
+ else {
297
+ const fallbackConfig = resolveTailwindConfigFallback(resolvedTailwindOptions.packageName, resolvedTailwindOptions.resolve.paths ?? resolvePaths);
298
+ if (fallbackConfig) resolvedTailwindOptions.config = fallbackConfig;
299
+ }
300
+ if (!resolvedTailwindOptions.cwd && configPath) resolvedTailwindOptions.cwd = path.dirname(configPath);
301
+ resolvedOptions.tailwindcss = resolvedTailwindOptions;
302
+ }
303
+ try {
304
+ return new TailwindcssPatcher(resolvedOptions);
305
+ } catch (error) {
306
+ const searchPaths = resolvedOptions.tailwindcss?.resolve?.paths;
307
+ if (error instanceof Error && TAILWINDCSS_NOT_FOUND_RE.test(error.message)) {
308
+ if (!hasLoggedMissingTailwind) {
309
+ logger.warn("Tailwind CSS 未安装,已跳过 Tailwind 运行时能力。若需使用 Tailwind 能力,请安装 tailwindcss。");
310
+ hasLoggedMissingTailwind = true;
311
+ }
312
+ return createFallbackTailwindcssPatcher();
313
+ }
314
+ if (error instanceof Error && UNABLE_TO_LOCATE_TAILWINDCSS_RE.test(error.message)) logger.error("无法定位 Tailwind CSS 包 \"%s\",已尝试路径: %O", resolvedOptions.tailwindcss?.packageName, searchPaths);
315
+ throw error;
316
+ }
317
+ }
318
+ //#endregion
319
+ //#region src/tailwindcss/runtime/cache.ts
320
+ const runtimeClassSetCache = /* @__PURE__ */ new WeakMap();
321
+ const runtimeFileSignatureCache = /* @__PURE__ */ new Map();
322
+ let runtimeFileSignatureCacheClearTimer;
323
+ const runtimeSignaturePatchersSymbol = Symbol.for("weapp-tailwindcss.runtimeSignaturePatchers");
324
+ function getCacheEntry(twPatcher) {
325
+ let entry = runtimeClassSetCache.get(twPatcher);
326
+ if (!entry) {
327
+ entry = {};
328
+ runtimeClassSetCache.set(twPatcher, entry);
329
+ }
330
+ return entry;
331
+ }
332
+ function scheduleRuntimeConfigSignatureCacheClear() {
333
+ if (runtimeFileSignatureCacheClearTimer) return;
334
+ runtimeFileSignatureCacheClearTimer = setTimeout(() => {
335
+ runtimeFileSignatureCache.clear();
336
+ runtimeFileSignatureCacheClearTimer = void 0;
337
+ }, 0);
338
+ runtimeFileSignatureCacheClearTimer.unref?.();
339
+ }
340
+ function getFileSignature(filePath) {
341
+ const cached = runtimeFileSignatureCache.get(filePath);
342
+ if (cached !== void 0) return cached;
343
+ let signature;
344
+ try {
345
+ const stats = statSync(filePath);
346
+ signature = `${filePath}:${stats.size}:${stats.mtimeMs}`;
347
+ } catch {
348
+ signature = `${filePath}:missing`;
349
+ }
350
+ runtimeFileSignatureCache.set(filePath, signature);
351
+ scheduleRuntimeConfigSignatureCacheClear();
352
+ return signature;
353
+ }
354
+ function getTailwindTrackedFiles(twPatcher) {
355
+ const tailwindOptions = resolveTailwindcssOptions(twPatcher.options);
356
+ const tracked = /* @__PURE__ */ new Set();
357
+ const configPath = tailwindOptions?.config;
358
+ if (typeof configPath === "string" && configPath.length > 0) tracked.add(configPath);
359
+ for (const entry of tailwindOptions?.v4?.cssEntries ?? []) if (typeof entry === "string" && entry.length > 0) tracked.add(entry);
360
+ return tracked;
361
+ }
362
+ function normalizeSignatureValue(value) {
363
+ if (value == null) return "null";
364
+ if (typeof value === "string") return value;
365
+ if (typeof value === "number" || typeof value === "boolean") return String(value);
366
+ if (Array.isArray(value)) return `[${value.map((item) => normalizeSignatureValue(item)).join(",")}]`;
367
+ if (typeof value === "object") return `{${Object.entries(value).filter(([, item]) => item !== void 0).sort(([a], [b]) => a.localeCompare(b)).map(([key, item]) => `${key}:${normalizeSignatureValue(item)}`).join(",")}}`;
368
+ return String(value);
369
+ }
370
+ function readOptionalProperty(value, key) {
371
+ if (typeof value !== "object" || value === null || !(key in value)) return;
372
+ return value[key];
373
+ }
374
+ function getTailwindOptionsSignature(twPatcher) {
375
+ const options = twPatcher.options;
376
+ const tailwindOptions = resolveTailwindcssOptions(options);
377
+ return normalizeSignatureValue({
378
+ projectRoot: options?.projectRoot,
379
+ packageName: tailwindOptions?.packageName,
380
+ versionHint: readOptionalProperty(tailwindOptions, "versionHint"),
381
+ cwd: tailwindOptions?.cwd,
382
+ config: tailwindOptions?.config,
383
+ v2: tailwindOptions?.v2,
384
+ v3: tailwindOptions?.v3,
385
+ v4: {
386
+ base: tailwindOptions?.v4?.base,
387
+ configuredBase: readOptionalProperty(tailwindOptions?.v4, "configuredBase"),
388
+ css: tailwindOptions?.v4?.css,
389
+ cssEntries: tailwindOptions?.v4?.cssEntries,
390
+ hasUserDefinedSources: readOptionalProperty(tailwindOptions?.v4, "hasUserDefinedSources"),
391
+ sources: tailwindOptions?.v4?.sources
392
+ }
393
+ });
394
+ }
395
+ function getRuntimeTargetSignature(twPatcher) {
396
+ const packageInfo = twPatcher.packageInfo;
397
+ return [
398
+ packageInfo?.name ?? "missing",
399
+ packageInfo?.rootPath ?? "missing",
400
+ packageInfo?.version ?? "unknown",
401
+ twPatcher.majorVersion ?? "unknown",
402
+ getTailwindOptionsSignature(twPatcher)
403
+ ].join(":");
404
+ }
405
+ function getNestedPatchers(twPatcher) {
406
+ const nested = twPatcher[runtimeSignaturePatchersSymbol];
407
+ return Array.isArray(nested) && nested.length > 0 ? nested : void 0;
408
+ }
409
+ function getOwnRuntimeClassSetSignature(twPatcher) {
410
+ const trackedFiles = [...getTailwindTrackedFiles(twPatcher)].sort((a, b) => a.localeCompare(b)).map(getFileSignature);
411
+ return `${trackedFiles.length > 0 ? trackedFiles.join("|") : "files:missing"}|runtime:${getRuntimeTargetSignature(twPatcher)}`;
412
+ }
413
+ function invalidateRuntimeClassSet(twPatcher) {
414
+ if (!twPatcher) return;
415
+ const nestedPatchers = getNestedPatchers(twPatcher);
416
+ if (nestedPatchers) for (const patcher of nestedPatchers) invalidateRuntimeClassSet(patcher);
417
+ for (const trackedFile of getTailwindTrackedFiles(twPatcher)) runtimeFileSignatureCache.delete(trackedFile);
418
+ runtimeClassSetCache.delete(twPatcher);
419
+ }
420
+ function getRuntimeClassSetCacheEntry(twPatcher) {
421
+ return getCacheEntry(twPatcher);
422
+ }
423
+ function getRuntimeClassSetSignature(twPatcher) {
424
+ const nestedPatchers = getNestedPatchers(twPatcher);
425
+ if (nestedPatchers) return nestedPatchers.map(getOwnRuntimeClassSetSignature).sort((a, b) => a.localeCompare(b)).join("||");
426
+ return getOwnRuntimeClassSetSignature(twPatcher);
427
+ }
428
+ //#endregion
429
+ export { createTailwindcssPatcher as a, resolveTailwindcssOptions as c, findWorkspaceRoot as d, runtimeSignaturePatchersSymbol as i, findNearestPackageRoot as l, getRuntimeClassSetSignature as n, readInstalledPackageMajorVersion as o, invalidateRuntimeClassSet as r, findTailwindConfig as s, getRuntimeClassSetCacheEntry as t, findWorkspacePackageDir as u };
@@ -1,7 +1,4 @@
1
- import type { CompatTailwindCssPatchOptions } from '../tailwindcss/patcher-options';
2
1
  import type { UserDefinedOptions } from '../types';
3
- export declare function resolveEntry(entry: string, cwd: string | undefined): string;
4
- export declare function buildTailwindcssPatcherOptions(overrides: Partial<CompatTailwindCssPatchOptions> | undefined): CompatTailwindCssPatchOptions | undefined;
5
2
  export declare function createCliContext(overrides: Partial<UserDefinedOptions> | undefined, resolvedCwd: string | undefined): Required<Omit<UserDefinedOptions, "supportCustomLengthUnitsPatch" | "customReplaceDictionary" | "cache"> & {
6
3
  supportCustomLengthUnitsPatch: import("tailwindcss-patch").ILengthUnitsPatchOptions | boolean;
7
4
  templateHandler: (rawSource: string, options?: import("@/types").ITemplateHandlerOptions) => Promise<string>;
@@ -1,5 +1,4 @@
1
1
  import { normalizeExtractFormat, normalizeTokenFormat, readStringArrayOption, readStringOption, resolveCliCwd, toBoolean } from './helpers/options';
2
- import { resolvePatchDefaultCwd } from './helpers/patch-cwd';
3
2
  export declare function ensureDir(dir: string): Promise<void>;
4
3
  export declare function commandAction<T extends unknown[]>(handler: (...args: T) => Promise<void>): (...args: T) => Promise<void>;
5
- export { normalizeExtractFormat, normalizeTokenFormat, readStringArrayOption, readStringOption, resolveCliCwd, resolvePatchDefaultCwd, toBoolean, };
4
+ export { normalizeExtractFormat, normalizeTokenFormat, readStringArrayOption, readStringOption, resolveCliCwd, toBoolean, };
@@ -1,2 +1,4 @@
1
1
  import type { TailwindcssPatchCliMountOptions } from 'tailwindcss-patch';
2
+ export declare const PATCH_COMMAND_OBSOLETE_NOTICE = "\u63D0\u793A\uFF1Aweapp-tailwindcss@5 \u5DF2\u7531\u6784\u5EFA\u8FD0\u884C\u65F6\u63A5\u7BA1 Tailwind CSS \u5904\u7406\uFF0Cweapp-tw patch \u5DF2\u65E0\u9700\u6267\u884C\uFF1B\u8BF7\u79FB\u9664 package.json \u4E2D\u7684 postinstall \u94A9\u5B50\u3002";
3
+ export declare function logPatchCommandObsoleteNotice(): void;
2
4
  export declare const mountOptions: TailwindcssPatchCliMountOptions;
@@ -1,7 +1,5 @@
1
1
  export interface CommonCommandOptions {
2
2
  cwd?: string | boolean;
3
- recordTarget?: boolean | string;
4
- clearCache?: boolean | string;
5
3
  }
6
4
  export interface ExtractCommandOptions extends CommonCommandOptions {
7
5
  output?: string | boolean;