weapp-tailwindcss 5.0.0-next.2 → 5.0.0-next.21

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 (221) hide show
  1. package/README.md +6 -7
  2. package/bin/weapp-tailwindcss.js +1 -21
  3. package/dist/bundle-state-BnV8o2Yn.js +530 -0
  4. package/dist/bundle-state-CLnuf2CW.mjs +414 -0
  5. package/dist/bundlers/shared/cache.d.ts +6 -6
  6. package/dist/bundlers/shared/css-cleanup/at-rules.d.ts +1 -0
  7. package/dist/bundlers/shared/css-cleanup.d.ts +1 -4
  8. package/dist/bundlers/shared/css-imports.d.ts +3 -3
  9. package/dist/bundlers/shared/generated-css-marker.d.ts +3 -0
  10. package/dist/bundlers/shared/generator-css/config-directive.d.ts +2 -0
  11. package/dist/bundlers/shared/generator-css/directives.d.ts +20 -0
  12. package/dist/bundlers/shared/generator-css/legacy-compat.d.ts +7 -0
  13. package/dist/bundlers/shared/generator-css/legacy-selectors.d.ts +5 -0
  14. package/dist/bundlers/shared/generator-css/legacy-units.d.ts +1 -0
  15. package/dist/bundlers/shared/generator-css/markers.d.ts +28 -0
  16. package/dist/bundlers/shared/generator-css/source-files.d.ts +14 -0
  17. package/dist/bundlers/shared/generator-css/source-resolver.d.ts +24 -0
  18. package/dist/bundlers/shared/generator-css.d.ts +16 -22
  19. package/dist/bundlers/shared/hmr-timing.d.ts +22 -0
  20. package/dist/bundlers/shared/style-requests.d.ts +2 -0
  21. package/dist/bundlers/vite/bundle-state.d.ts +1 -0
  22. package/dist/bundlers/vite/css-finalizer.d.ts +7 -1
  23. package/dist/bundlers/vite/generate-bundle/candidates.d.ts +2 -0
  24. package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +24 -0
  25. package/dist/bundlers/vite/generate-bundle/css-share-scope.d.ts +4 -0
  26. package/dist/bundlers/vite/generate-bundle/dirty-state.d.ts +1 -0
  27. package/dist/bundlers/vite/generate-bundle/js-entries.d.ts +2 -0
  28. package/dist/bundlers/vite/generate-bundle/js-handler-options.d.ts +8 -0
  29. package/dist/bundlers/vite/generate-bundle/js-linking.d.ts +13 -0
  30. package/dist/bundlers/vite/generate-bundle/metrics.d.ts +17 -0
  31. package/dist/bundlers/vite/generate-bundle/process-plan.d.ts +9 -0
  32. package/dist/bundlers/vite/generate-bundle/rollup-assets.d.ts +7 -0
  33. package/dist/bundlers/vite/generate-bundle/signatures.d.ts +8 -0
  34. package/dist/bundlers/vite/generate-bundle.d.ts +14 -2
  35. package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +5 -1
  36. package/dist/bundlers/vite/index.d.ts +1 -1
  37. package/dist/bundlers/vite/official-tailwind-plugins.d.ts +5 -0
  38. package/dist/bundlers/vite/postcss-config.d.ts +6 -0
  39. package/dist/bundlers/vite/processed-css-assets.d.ts +32 -0
  40. package/dist/bundlers/vite/rewrite-css-imports.d.ts +8 -3
  41. package/dist/bundlers/vite/runtime-class-set.d.ts +25 -0
  42. package/dist/bundlers/vite/source-candidates.d.ts +16 -1
  43. package/dist/bundlers/vite/source-scan.d.ts +26 -0
  44. package/dist/bundlers/vite/static-config-content.d.ts +5 -0
  45. package/dist/bundlers/vite/tailwind-basedir.d.ts +1 -0
  46. package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +6 -0
  47. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +6 -2
  48. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +9 -3
  49. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +1 -0
  50. package/dist/bundlers/webpack/loaders/runtime-registry.d.ts +31 -0
  51. package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +2 -6
  52. package/dist/bundlers/webpack/loaders/weapp-tw-runtime-classset-loader.d.ts +3 -7
  53. package/dist/cache/index.d.ts +6 -6
  54. package/dist/cli/context.d.ts +1 -14
  55. package/dist/cli/doctor/types.d.ts +11 -11
  56. package/dist/cli/helpers.d.ts +1 -2
  57. package/dist/cli/mount-options.d.ts +2 -0
  58. package/dist/cli/types.d.ts +0 -2
  59. package/dist/cli/vscode-entry.d.ts +3 -3
  60. package/dist/cli.js +605 -611
  61. package/dist/cli.mjs +614 -620
  62. package/dist/constants.d.ts +1 -2
  63. package/dist/core.js +13 -20
  64. package/dist/core.mjs +8 -14
  65. package/dist/css-macro/postcss.js +3 -2
  66. package/dist/css-macro/postcss.mjs +3 -2
  67. package/dist/css-macro.d.ts +1 -0
  68. package/dist/css-macro.js +2 -2
  69. package/dist/css-macro.mjs +2 -2
  70. package/dist/defaults-B1igPF_e.mjs +150 -0
  71. package/dist/defaults-IHhYxNeU.js +193 -0
  72. package/dist/defaults.d.ts +15 -1
  73. package/dist/defaults.js +6 -131
  74. package/dist/defaults.mjs +2 -129
  75. package/dist/escape.js +10 -2
  76. package/dist/escape.mjs +10 -2
  77. package/dist/generator/index.d.ts +1 -1
  78. package/dist/generator/options.d.ts +9 -8
  79. package/dist/generator/types.d.ts +3 -3
  80. package/dist/generator-B4RNgMLx.js +55 -0
  81. package/dist/generator-DvyhmC76.mjs +32 -0
  82. package/dist/generator.js +12 -11
  83. package/dist/generator.mjs +2 -1
  84. package/dist/gulp.js +185 -47
  85. package/dist/gulp.mjs +179 -41
  86. package/dist/incremental-runtime-class-set-C7Q7fC5u.mjs +1863 -0
  87. package/dist/incremental-runtime-class-set-DZsbM0-a.js +1926 -0
  88. package/dist/index.d.ts +1 -1
  89. package/dist/index.js +6 -6
  90. package/dist/index.mjs +5 -5
  91. package/dist/js/babel/cache-options.d.ts +3 -0
  92. package/dist/js/babel/parse.d.ts +7 -4
  93. package/dist/js/index.d.ts +1 -0
  94. package/dist/js/literal-transform.d.ts +2 -0
  95. package/dist/js/precheck.d.ts +2 -2
  96. package/dist/logger-CZUxvJJD.mjs +2 -0
  97. package/dist/logger-EVNB9z7i.js +1 -0
  98. package/dist/postcss/config-directive.d.ts +1 -0
  99. package/dist/postcss/context.d.ts +9 -0
  100. package/dist/postcss/source-files.d.ts +8 -0
  101. package/dist/postcss/tailwind-version.d.ts +3 -0
  102. package/dist/postcss-CFa6-qO9.js +237 -0
  103. package/dist/postcss-Drpy7j-g.mjs +228 -0
  104. package/dist/postcss.d.ts +2 -2
  105. package/dist/postcss.js +3 -276
  106. package/dist/postcss.mjs +1 -269
  107. package/dist/{recorder-gYSNLfOP.js → precheck-8pQbjqpq.js} +218 -314
  108. package/dist/{recorder-zsgatmkB.mjs → precheck-D1O5AWzy.mjs} +186 -281
  109. package/dist/presets.js +13 -11
  110. package/dist/presets.mjs +11 -9
  111. package/dist/reset.d.ts +1 -0
  112. package/dist/runtime-registry-CdCV3Opt.js +5496 -0
  113. package/dist/shared/mpx.d.ts +1 -0
  114. package/dist/source-candidates-CUTNdsiz.js +222 -0
  115. package/dist/source-candidates-CnD4vyic.mjs +209 -0
  116. package/dist/tailwindcss/miniprogram.d.ts +1 -1
  117. package/dist/tailwindcss/patcher-options.d.ts +3 -51
  118. package/dist/tailwindcss/patcher.d.ts +1 -2
  119. package/dist/tailwindcss/remove-unsupported-css.d.ts +1 -2
  120. package/dist/tailwindcss/runtime/cache.d.ts +4 -3
  121. package/dist/tailwindcss/runtime-patch.d.ts +5 -0
  122. package/dist/tailwindcss/runtime.d.ts +11 -12
  123. package/dist/tailwindcss/source-scan.d.ts +35 -0
  124. package/dist/tailwindcss/targets.d.ts +1 -5
  125. package/dist/tailwindcss/v3-engine/types.d.ts +17 -14
  126. package/dist/tailwindcss/v4/css-entries.d.ts +2 -2
  127. package/dist/tailwindcss/v4/css-sources.d.ts +5 -0
  128. package/dist/tailwindcss/v4/patcher-options.d.ts +1 -23
  129. package/dist/tailwindcss/v4/patcher.d.ts +1 -0
  130. package/dist/tailwindcss/v4-engine/source.d.ts +2 -2
  131. package/dist/tailwindcss/v4-engine/types.d.ts +17 -5
  132. package/dist/tailwindcss/version.d.ts +4 -0
  133. package/dist/tailwindcss-B_JAdOQf.mjs +600 -0
  134. package/dist/tailwindcss-whZE3HpL.js +651 -0
  135. package/dist/typedoc.export.d.ts +0 -2
  136. package/dist/types/index.d.ts +51 -48
  137. package/dist/types/shared.d.ts +3 -0
  138. package/dist/types/user-defined-options/general.d.ts +23 -23
  139. package/dist/types/user-defined-options/important.d.ts +31 -28
  140. package/dist/types/user-defined-options/lifecycle.d.ts +4 -4
  141. package/dist/types/user-defined-options/matcher.d.ts +6 -6
  142. package/dist/uni-app-x/vite.d.ts +1 -1
  143. package/dist/utils/disabled.d.ts +2 -3
  144. package/dist/utils/object.d.ts +9 -0
  145. package/dist/{utils-DmC9_In3.js → utils-4ODFyoqD.js} +1 -1
  146. package/dist/{utils-7DUGTFED.mjs → utils-CGBVVNm6.mjs} +1 -1
  147. package/dist/v3-engine-CCwvhRrQ.js +3473 -0
  148. package/dist/v3-engine-DyIcbpZm.mjs +3190 -0
  149. package/dist/{vite-CrlzCNqz.mjs → vite-B8IiXgVD.mjs} +1256 -1088
  150. package/dist/vite-BcnwgJMt.js +2368 -0
  151. package/dist/vite.d.ts +1 -2
  152. package/dist/vite.js +3 -4
  153. package/dist/vite.mjs +2 -2
  154. package/dist/weapp-tw-css-import-rewrite-loader.js +4533 -16
  155. package/dist/weapp-tw-runtime-classset-loader.js +33 -7
  156. package/dist/webpack-C4zI624R.js +846 -0
  157. package/dist/webpack-DTkshAtp.mjs +836 -0
  158. package/dist/webpack.js +1 -1
  159. package/dist/webpack.mjs +1 -1
  160. package/package.json +27 -37
  161. package/dist/bundlers/shared/generator-candidates.d.ts +0 -5
  162. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-assets.d.ts +0 -14
  163. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-loaders.d.ts +0 -15
  164. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4.d.ts +0 -9
  165. package/dist/bundlers/webpack/shared/css-imports.d.ts +0 -6
  166. package/dist/cli/config.d.ts +0 -5
  167. package/dist/cli/helpers/patch-cwd.d.ts +0 -1
  168. package/dist/cli/mount-options/patch-status.d.ts +0 -2
  169. package/dist/cli/patch-options.d.ts +0 -6
  170. package/dist/cli/tokens.d.ts +0 -4
  171. package/dist/cli/workspace/package-dirs.d.ts +0 -3
  172. package/dist/cli/workspace/patch-package.d.ts +0 -3
  173. package/dist/cli/workspace/patch-utils.d.ts +0 -3
  174. package/dist/cli/workspace/types.d.ts +0 -11
  175. package/dist/cli/workspace/workspace-globs.d.ts +0 -2
  176. package/dist/cli/workspace/workspace-io.d.ts +0 -1
  177. package/dist/cli/workspace/workspace-lock.d.ts +0 -1
  178. package/dist/cli/workspace.d.ts +0 -2
  179. package/dist/css-imports-BbrbluP9.js +0 -177
  180. package/dist/css-imports-CSdPq_Sc.mjs +0 -128
  181. package/dist/experimental/index.d.ts +0 -2
  182. package/dist/experimental/oxc/ast-utils.d.ts +0 -30
  183. package/dist/experimental/oxc/index.d.ts +0 -2
  184. package/dist/experimental/oxc/module-specifiers.d.ts +0 -2
  185. package/dist/experimental/shared/cache.d.ts +0 -3
  186. package/dist/experimental/shared/transform.d.ts +0 -3
  187. package/dist/experimental/shared.d.ts +0 -8
  188. package/dist/experimental/swc/ast-utils.d.ts +0 -30
  189. package/dist/experimental/swc/index.d.ts +0 -2
  190. package/dist/experimental/swc/module-specifiers.d.ts +0 -2
  191. package/dist/generator-Y-Ikv4Fu.mjs +0 -1177
  192. package/dist/generator-css-B5ejWUMv.mjs +0 -1098
  193. package/dist/generator-css-D3OdPRiS.js +0 -1125
  194. package/dist/generator-mmhXzZnv.js +0 -1276
  195. package/dist/js/syntax.d.ts +0 -10
  196. package/dist/lightningcss/index.d.ts +0 -8
  197. package/dist/lightningcss/style-handler/options.d.ts +0 -3
  198. package/dist/lightningcss/style-handler/selector-transform.d.ts +0 -10
  199. package/dist/lightningcss/style-handler/selector-utils.d.ts +0 -10
  200. package/dist/lightningcss/style-handler.d.ts +0 -17
  201. package/dist/loader-anchors-CNkWT8hx.js +0 -273
  202. package/dist/loader-anchors-TrU7EUr7.mjs +0 -205
  203. package/dist/logger-BZ45DZJT.js +0 -1003
  204. package/dist/logger-BoVx1Dbt.mjs +0 -935
  205. package/dist/patcher-options-6gJN2EXy.js +0 -115
  206. package/dist/patcher-options-DQfR5xxT.mjs +0 -92
  207. package/dist/tailwindcss/recorder.d.ts +0 -13
  208. package/dist/tailwindcss/targets/paths.d.ts +0 -13
  209. package/dist/tailwindcss/targets/record-io.d.ts +0 -5
  210. package/dist/tailwindcss/targets/recorder.d.ts +0 -3
  211. package/dist/tailwindcss/targets/types.d.ts +0 -35
  212. package/dist/types/disabled-options.d.ts +0 -4
  213. package/dist/vite-BC9U7ahn.js +0 -2199
  214. package/dist/webpack-Bu6M-Hbw.mjs +0 -441
  215. package/dist/webpack-DD7A6V0u.js +0 -456
  216. package/dist/webpack4.d.ts +0 -4
  217. package/dist/webpack4.js +0 -387
  218. package/dist/webpack4.mjs +0 -379
  219. package/scripts/postinstall.mjs +0 -59
  220. /package/dist/{constants-B-_T5UnW.mjs → constants-BG12WAKw.mjs} +0 -0
  221. /package/dist/{constants-p1dyh1x1.js → constants-BeeyfJ9k.js} +0 -0
package/dist/postcss.js CHANGED
@@ -2,279 +2,6 @@ Object.defineProperties(exports, {
2
2
  __esModule: { value: true },
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
- const require_chunk = require("./chunk-8l464Juk.js");
6
- const require_generator = require("./generator-mmhXzZnv.js");
7
- let node_module = require("node:module");
8
- let postcss = require("postcss");
9
- postcss = require_chunk.__toESM(postcss);
10
- let node_path = require("node:path");
11
- node_path = require_chunk.__toESM(node_path);
12
- let node_process = require("node:process");
13
- node_process = require_chunk.__toESM(node_process);
14
- let tailwindcss_config = require("tailwindcss-config");
15
- let tailwindcss_patch = require("tailwindcss-patch");
16
- let node_fs_promises = require("node:fs/promises");
17
- let fast_glob = require("fast-glob");
18
- fast_glob = require_chunk.__toESM(fast_glob);
19
- //#region src/postcss.ts
20
- const PLUGIN_NAME = "weapp-tailwindcss";
21
- const POSTCSS_SOURCE_EXTENSIONS = [
22
- "html",
23
- "wxml",
24
- "axml",
25
- "jxml",
26
- "ksml",
27
- "ttml",
28
- "qml",
29
- "tyml",
30
- "xhsml",
31
- "swan",
32
- "vue",
33
- "mpx",
34
- "js",
35
- "jsx",
36
- "ts",
37
- "tsx"
38
- ];
39
- function resolveInputFile(result) {
40
- const from = result.opts.from;
41
- return typeof from === "string" && from.length > 0 ? from : void 0;
42
- }
43
- function resolvePostcssBase(result, options) {
44
- if (options.base) return options.base;
45
- const inputFile = resolveInputFile(result);
46
- return inputFile ? node_path.default.dirname(inputFile) : node_process.default.cwd();
47
- }
48
- function resolvePostcssProjectRoot(result, options) {
49
- if (options.projectRoot) return options.projectRoot;
50
- const inputFile = resolveInputFile(result);
51
- return inputFile ? node_path.default.dirname(inputFile) : node_process.default.cwd();
52
- }
53
- function replaceRootCss(root, css, result) {
54
- const nextRoot = postcss.default.parse(css, { from: resolveInputFile(result) });
55
- root.removeAll();
56
- root.append(nextRoot.nodes);
57
- }
58
- function addDependencyMessages(result, generated) {
59
- for (const file of generated.dependencies) result.messages.push({
60
- type: "dependency",
61
- plugin: PLUGIN_NAME,
62
- file
63
- });
64
- }
65
- function parseLocalSourceParam(params) {
66
- const value = params.trim();
67
- if (!value || value === "none" || value.startsWith("not ") || value.startsWith("inline(")) return;
68
- return /^(['"])(.+)\1$/.exec(value)?.[2];
69
- }
70
- function parseConfigParam(params) {
71
- const value = params.trim();
72
- return /^(['"])(.+)\1$/.exec(value)?.[2];
73
- }
74
- function parseSourceFileParam(params) {
75
- const value = params.trim();
76
- if (!value || value === "none" || value.startsWith("inline(")) return;
77
- const negated = value.startsWith("not ");
78
- const sourceValue = negated ? value.slice(4).trim() : value;
79
- const match = /^(['"])(.+)\1$/.exec(sourceValue);
80
- return match?.[2] ? {
81
- negated,
82
- sourcePath: match[2]
83
- } : void 0;
84
- }
85
- function hasTailwindV4CssSyntax(root) {
86
- let hasV4Syntax = false;
87
- root.walkAtRules((rule) => {
88
- if (rule.name === "theme" || rule.name === "source" || rule.name === "custom-variant") hasV4Syntax = true;
89
- if (rule.name === "import" && /(['"])tailwindcss\1/.test(rule.params)) hasV4Syntax = true;
90
- });
91
- return hasV4Syntax;
92
- }
93
- function readPackageMajorVersion(packageName, base) {
94
- try {
95
- const pkg = (0, node_module.createRequire)(`${base}/package.json`)(`${packageName}/package.json`);
96
- const major = Number(pkg.version?.split(".")[0]);
97
- return major === 3 || major === 4 ? major : void 0;
98
- } catch {
99
- return;
100
- }
101
- }
102
- function resolvePostcssTailwindVersion(root, result, options) {
103
- if (options.version) return options.version;
104
- if (hasTailwindV4CssSyntax(root)) return 4;
105
- const packageName = options.packageName ?? "tailwindcss";
106
- if (packageName === "@tailwindcss/postcss" || packageName.includes("tailwindcss4")) return 4;
107
- if (packageName.includes("tailwindcss3")) return 3;
108
- return readPackageMajorVersion(packageName, resolvePostcssProjectRoot(result, options)) ?? 4;
109
- }
110
- function getSourceExtension(file) {
111
- return node_path.default.extname(file).slice(1) || void 0;
112
- }
113
- async function pathExistsAsDirectory(file) {
114
- try {
115
- return (await (0, node_fs_promises.stat)(file)).isDirectory();
116
- } catch {
117
- return false;
118
- }
119
- }
120
- async function expandLocalSourceFiles(sourcePath, base) {
121
- const absoluteSource = node_path.default.isAbsolute(sourcePath) ? sourcePath : node_path.default.resolve(base, sourcePath);
122
- if (await pathExistsAsDirectory(absoluteSource)) return (0, fast_glob.default)(`**/*.{${POSTCSS_SOURCE_EXTENSIONS.join(",")}}`, {
123
- absolute: true,
124
- cwd: absoluteSource,
125
- onlyFiles: true
126
- });
127
- return (0, fast_glob.default)(sourcePath, {
128
- absolute: true,
129
- cwd: base,
130
- onlyFiles: true
131
- });
132
- }
133
- async function resolveTailwindSourceEntry(sourcePath, base, negated) {
134
- const absoluteSource = node_path.default.isAbsolute(sourcePath) ? node_path.default.resolve(sourcePath) : node_path.default.resolve(base, sourcePath);
135
- if (await pathExistsAsDirectory(absoluteSource)) return {
136
- base: absoluteSource,
137
- negated,
138
- pattern: "**/*"
139
- };
140
- if (node_path.default.isAbsolute(sourcePath)) return {
141
- base: node_path.default.dirname(absoluteSource),
142
- negated,
143
- pattern: node_path.default.basename(absoluteSource)
144
- };
145
- return {
146
- base,
147
- negated,
148
- pattern: sourcePath
149
- };
150
- }
151
- function collectConfigPaths(root, base) {
152
- const configPaths = [];
153
- root.walkAtRules("config", (rule) => {
154
- const configPath = parseConfigParam(rule.params);
155
- if (configPath) configPaths.push(node_path.default.isAbsolute(configPath) ? configPath : node_path.default.resolve(base, configPath));
156
- });
157
- return [...new Set(configPaths)];
158
- }
159
- function normalizeContentFiles(content) {
160
- if (typeof content === "string") return [content];
161
- if (Array.isArray(content)) return content.flatMap((item) => normalizeContentFiles(item));
162
- if (typeof content === "object" && content !== null && "files" in content) return normalizeContentFiles(content.files);
163
- return [];
164
- }
165
- async function collectConfigContentFiles(root, base) {
166
- const configPaths = collectConfigPaths(root, base);
167
- const files = [];
168
- for (const configPath of configPaths) {
169
- const contentFiles = normalizeContentFiles((await (0, tailwindcss_config.loadConfig)({
170
- config: configPath,
171
- cwd: node_path.default.dirname(configPath)
172
- }))?.config.content);
173
- for (const contentFile of contentFiles) files.push(...await expandLocalSourceFiles(contentFile, node_path.default.dirname(configPath)));
174
- }
175
- return {
176
- configPaths,
177
- files: [...new Set(files)]
178
- };
179
- }
180
- async function collectAutoTailwindCandidates(root, result, options) {
181
- const base = resolvePostcssBase(result, options);
182
- const projectRoot = resolvePostcssProjectRoot(result, options);
183
- const sourceEntryTasks = [];
184
- if (!root.toString().includes("source(none)")) sourceEntryTasks.push(Promise.resolve({
185
- base,
186
- negated: false,
187
- pattern: "**/*"
188
- }));
189
- root.walkAtRules("source", (rule) => {
190
- const parsed = parseSourceFileParam(rule.params);
191
- if (!parsed) return;
192
- sourceEntryTasks.push(resolveTailwindSourceEntry(parsed.sourcePath, base, parsed.negated));
193
- });
194
- const sourceEntries = await Promise.all(sourceEntryTasks);
195
- if (sourceEntries.length === 0) return /* @__PURE__ */ new Set();
196
- const candidates = await (0, tailwindcss_patch.extractValidCandidates)({
197
- base,
198
- css: root.toString(),
199
- cwd: projectRoot,
200
- sources: sourceEntries
201
- });
202
- return new Set(candidates);
203
- }
204
- async function collectPostcssLocalSources(root, result, options) {
205
- const base = resolvePostcssBase(result, options);
206
- const sourcePaths = [];
207
- root.walkAtRules("source", (rule) => {
208
- const sourcePath = parseLocalSourceParam(rule.params);
209
- if (sourcePath) sourcePaths.push(sourcePath);
210
- });
211
- const configContentFiles = await collectConfigContentFiles(root, base);
212
- const files = [...new Set((await Promise.all(sourcePaths.map((sourcePath) => expandLocalSourceFiles(sourcePath, base)))).flat().concat(configContentFiles.files))];
213
- const sources = await Promise.all(files.map(async (file) => ({
214
- content: await (0, node_fs_promises.readFile)(file, "utf8"),
215
- extension: getSourceExtension(file)
216
- })));
217
- return {
218
- files: [...files, ...configContentFiles.configPaths],
219
- sources
220
- };
221
- }
222
- function addSourceDependencyMessages(result, files) {
223
- for (const file of files) result.messages.push({
224
- type: "dependency",
225
- plugin: PLUGIN_NAME,
226
- file
227
- });
228
- }
229
- const weappTailwindcssPostcssPlugin = (options = {}) => {
230
- return {
231
- postcssPlugin: PLUGIN_NAME,
232
- async Once(root, { result }) {
233
- const { candidates, generator: userGeneratorOptions, sources, styleOptions, target: legacyTarget, ...sourceOptions } = options;
234
- const generatorOptions = require_generator.normalizeWeappTailwindcssGeneratorOptions(userGeneratorOptions);
235
- if (generatorOptions.mode === "off") return;
236
- const tailwindVersion = resolvePostcssTailwindVersion(root, result, options);
237
- const [collectedSources, autoCandidates] = await Promise.all([collectPostcssLocalSources(root, result, options), collectAutoTailwindCandidates(root, result, options)]);
238
- const generator = require_generator.createWeappTailwindcssGenerator(tailwindVersion === 3 ? await require_generator.resolveTailwindV3Source({
239
- config: options.config,
240
- css: sourceOptions.css ?? root.toString(),
241
- base: resolvePostcssBase(result, options),
242
- cwd: resolvePostcssProjectRoot(result, options),
243
- projectRoot: resolvePostcssProjectRoot(result, options),
244
- packageName: options.packageName,
245
- postcssPlugin: options.postcssPlugin
246
- }) : await require_generator.resolveTailwindV4Source({
247
- ...sourceOptions,
248
- css: sourceOptions.css ?? root.toString(),
249
- base: resolvePostcssBase(result, options),
250
- projectRoot: resolvePostcssProjectRoot(result, options)
251
- }));
252
- const generateOptions = {
253
- candidates: new Set([...autoCandidates, ...candidates ?? []]),
254
- scanSources: false,
255
- sources: [...collectedSources.sources, ...sources ?? []],
256
- styleOptions: {
257
- ...generatorOptions.styleOptions,
258
- ...styleOptions
259
- },
260
- tailwindcssV3Compatibility: generatorOptions.tailwindcssV3Compatibility,
261
- target: legacyTarget ?? generatorOptions.target
262
- };
263
- const generated = await generator.generate(generateOptions);
264
- replaceRootCss(root, generated.css, result);
265
- addDependencyMessages(result, generated);
266
- addSourceDependencyMessages(result, collectedSources.files);
267
- result.messages.push({
268
- type: "weapp-tailwindcss:generated",
269
- plugin: PLUGIN_NAME,
270
- target: generated.target,
271
- classSet: generated.classSet,
272
- rawCss: generated.rawCss
273
- });
274
- }
275
- };
276
- };
277
- weappTailwindcssPostcssPlugin.postcss = true;
278
- //#endregion
279
- exports.default = weappTailwindcssPostcssPlugin;
280
- exports.weappTailwindcssPostcssPlugin = weappTailwindcssPostcssPlugin;
5
+ const require_postcss = require("./postcss-CFa6-qO9.js");
6
+ exports.default = require_postcss.weappTailwindcssPostcssPlugin;
7
+ exports.weappTailwindcssPostcssPlugin = require_postcss.weappTailwindcssPostcssPlugin;
package/dist/postcss.mjs CHANGED
@@ -1,270 +1,2 @@
1
- import { a as resolveTailwindV4Source$1, i as normalizeWeappTailwindcssGeneratorOptions, p as resolveTailwindV3Source, t as createWeappTailwindcssGenerator } from "./generator-Y-Ikv4Fu.mjs";
2
- import { createRequire } from "node:module";
3
- import postcss from "postcss";
4
- import path from "node:path";
5
- import process from "node:process";
6
- import { loadConfig } from "tailwindcss-config";
7
- import { extractValidCandidates } from "tailwindcss-patch";
8
- import { readFile, stat } from "node:fs/promises";
9
- import fg from "fast-glob";
10
- //#region src/postcss.ts
11
- const PLUGIN_NAME = "weapp-tailwindcss";
12
- const POSTCSS_SOURCE_EXTENSIONS = [
13
- "html",
14
- "wxml",
15
- "axml",
16
- "jxml",
17
- "ksml",
18
- "ttml",
19
- "qml",
20
- "tyml",
21
- "xhsml",
22
- "swan",
23
- "vue",
24
- "mpx",
25
- "js",
26
- "jsx",
27
- "ts",
28
- "tsx"
29
- ];
30
- function resolveInputFile(result) {
31
- const from = result.opts.from;
32
- return typeof from === "string" && from.length > 0 ? from : void 0;
33
- }
34
- function resolvePostcssBase(result, options) {
35
- if (options.base) return options.base;
36
- const inputFile = resolveInputFile(result);
37
- return inputFile ? path.dirname(inputFile) : process.cwd();
38
- }
39
- function resolvePostcssProjectRoot(result, options) {
40
- if (options.projectRoot) return options.projectRoot;
41
- const inputFile = resolveInputFile(result);
42
- return inputFile ? path.dirname(inputFile) : process.cwd();
43
- }
44
- function replaceRootCss(root, css, result) {
45
- const nextRoot = postcss.parse(css, { from: resolveInputFile(result) });
46
- root.removeAll();
47
- root.append(nextRoot.nodes);
48
- }
49
- function addDependencyMessages(result, generated) {
50
- for (const file of generated.dependencies) result.messages.push({
51
- type: "dependency",
52
- plugin: PLUGIN_NAME,
53
- file
54
- });
55
- }
56
- function parseLocalSourceParam(params) {
57
- const value = params.trim();
58
- if (!value || value === "none" || value.startsWith("not ") || value.startsWith("inline(")) return;
59
- return /^(['"])(.+)\1$/.exec(value)?.[2];
60
- }
61
- function parseConfigParam(params) {
62
- const value = params.trim();
63
- return /^(['"])(.+)\1$/.exec(value)?.[2];
64
- }
65
- function parseSourceFileParam(params) {
66
- const value = params.trim();
67
- if (!value || value === "none" || value.startsWith("inline(")) return;
68
- const negated = value.startsWith("not ");
69
- const sourceValue = negated ? value.slice(4).trim() : value;
70
- const match = /^(['"])(.+)\1$/.exec(sourceValue);
71
- return match?.[2] ? {
72
- negated,
73
- sourcePath: match[2]
74
- } : void 0;
75
- }
76
- function hasTailwindV4CssSyntax(root) {
77
- let hasV4Syntax = false;
78
- root.walkAtRules((rule) => {
79
- if (rule.name === "theme" || rule.name === "source" || rule.name === "custom-variant") hasV4Syntax = true;
80
- if (rule.name === "import" && /(['"])tailwindcss\1/.test(rule.params)) hasV4Syntax = true;
81
- });
82
- return hasV4Syntax;
83
- }
84
- function readPackageMajorVersion(packageName, base) {
85
- try {
86
- const pkg = createRequire(`${base}/package.json`)(`${packageName}/package.json`);
87
- const major = Number(pkg.version?.split(".")[0]);
88
- return major === 3 || major === 4 ? major : void 0;
89
- } catch {
90
- return;
91
- }
92
- }
93
- function resolvePostcssTailwindVersion(root, result, options) {
94
- if (options.version) return options.version;
95
- if (hasTailwindV4CssSyntax(root)) return 4;
96
- const packageName = options.packageName ?? "tailwindcss";
97
- if (packageName === "@tailwindcss/postcss" || packageName.includes("tailwindcss4")) return 4;
98
- if (packageName.includes("tailwindcss3")) return 3;
99
- return readPackageMajorVersion(packageName, resolvePostcssProjectRoot(result, options)) ?? 4;
100
- }
101
- function getSourceExtension(file) {
102
- return path.extname(file).slice(1) || void 0;
103
- }
104
- async function pathExistsAsDirectory(file) {
105
- try {
106
- return (await stat(file)).isDirectory();
107
- } catch {
108
- return false;
109
- }
110
- }
111
- async function expandLocalSourceFiles(sourcePath, base) {
112
- const absoluteSource = path.isAbsolute(sourcePath) ? sourcePath : path.resolve(base, sourcePath);
113
- if (await pathExistsAsDirectory(absoluteSource)) return fg(`**/*.{${POSTCSS_SOURCE_EXTENSIONS.join(",")}}`, {
114
- absolute: true,
115
- cwd: absoluteSource,
116
- onlyFiles: true
117
- });
118
- return fg(sourcePath, {
119
- absolute: true,
120
- cwd: base,
121
- onlyFiles: true
122
- });
123
- }
124
- async function resolveTailwindSourceEntry(sourcePath, base, negated) {
125
- const absoluteSource = path.isAbsolute(sourcePath) ? path.resolve(sourcePath) : path.resolve(base, sourcePath);
126
- if (await pathExistsAsDirectory(absoluteSource)) return {
127
- base: absoluteSource,
128
- negated,
129
- pattern: "**/*"
130
- };
131
- if (path.isAbsolute(sourcePath)) return {
132
- base: path.dirname(absoluteSource),
133
- negated,
134
- pattern: path.basename(absoluteSource)
135
- };
136
- return {
137
- base,
138
- negated,
139
- pattern: sourcePath
140
- };
141
- }
142
- function collectConfigPaths(root, base) {
143
- const configPaths = [];
144
- root.walkAtRules("config", (rule) => {
145
- const configPath = parseConfigParam(rule.params);
146
- if (configPath) configPaths.push(path.isAbsolute(configPath) ? configPath : path.resolve(base, configPath));
147
- });
148
- return [...new Set(configPaths)];
149
- }
150
- function normalizeContentFiles(content) {
151
- if (typeof content === "string") return [content];
152
- if (Array.isArray(content)) return content.flatMap((item) => normalizeContentFiles(item));
153
- if (typeof content === "object" && content !== null && "files" in content) return normalizeContentFiles(content.files);
154
- return [];
155
- }
156
- async function collectConfigContentFiles(root, base) {
157
- const configPaths = collectConfigPaths(root, base);
158
- const files = [];
159
- for (const configPath of configPaths) {
160
- const contentFiles = normalizeContentFiles((await loadConfig({
161
- config: configPath,
162
- cwd: path.dirname(configPath)
163
- }))?.config.content);
164
- for (const contentFile of contentFiles) files.push(...await expandLocalSourceFiles(contentFile, path.dirname(configPath)));
165
- }
166
- return {
167
- configPaths,
168
- files: [...new Set(files)]
169
- };
170
- }
171
- async function collectAutoTailwindCandidates(root, result, options) {
172
- const base = resolvePostcssBase(result, options);
173
- const projectRoot = resolvePostcssProjectRoot(result, options);
174
- const sourceEntryTasks = [];
175
- if (!root.toString().includes("source(none)")) sourceEntryTasks.push(Promise.resolve({
176
- base,
177
- negated: false,
178
- pattern: "**/*"
179
- }));
180
- root.walkAtRules("source", (rule) => {
181
- const parsed = parseSourceFileParam(rule.params);
182
- if (!parsed) return;
183
- sourceEntryTasks.push(resolveTailwindSourceEntry(parsed.sourcePath, base, parsed.negated));
184
- });
185
- const sourceEntries = await Promise.all(sourceEntryTasks);
186
- if (sourceEntries.length === 0) return /* @__PURE__ */ new Set();
187
- const candidates = await extractValidCandidates({
188
- base,
189
- css: root.toString(),
190
- cwd: projectRoot,
191
- sources: sourceEntries
192
- });
193
- return new Set(candidates);
194
- }
195
- async function collectPostcssLocalSources(root, result, options) {
196
- const base = resolvePostcssBase(result, options);
197
- const sourcePaths = [];
198
- root.walkAtRules("source", (rule) => {
199
- const sourcePath = parseLocalSourceParam(rule.params);
200
- if (sourcePath) sourcePaths.push(sourcePath);
201
- });
202
- const configContentFiles = await collectConfigContentFiles(root, base);
203
- const files = [...new Set((await Promise.all(sourcePaths.map((sourcePath) => expandLocalSourceFiles(sourcePath, base)))).flat().concat(configContentFiles.files))];
204
- const sources = await Promise.all(files.map(async (file) => ({
205
- content: await readFile(file, "utf8"),
206
- extension: getSourceExtension(file)
207
- })));
208
- return {
209
- files: [...files, ...configContentFiles.configPaths],
210
- sources
211
- };
212
- }
213
- function addSourceDependencyMessages(result, files) {
214
- for (const file of files) result.messages.push({
215
- type: "dependency",
216
- plugin: PLUGIN_NAME,
217
- file
218
- });
219
- }
220
- const weappTailwindcssPostcssPlugin = (options = {}) => {
221
- return {
222
- postcssPlugin: PLUGIN_NAME,
223
- async Once(root, { result }) {
224
- const { candidates, generator: userGeneratorOptions, sources, styleOptions, target: legacyTarget, ...sourceOptions } = options;
225
- const generatorOptions = normalizeWeappTailwindcssGeneratorOptions(userGeneratorOptions);
226
- if (generatorOptions.mode === "off") return;
227
- const tailwindVersion = resolvePostcssTailwindVersion(root, result, options);
228
- const [collectedSources, autoCandidates] = await Promise.all([collectPostcssLocalSources(root, result, options), collectAutoTailwindCandidates(root, result, options)]);
229
- const generator = createWeappTailwindcssGenerator(tailwindVersion === 3 ? await resolveTailwindV3Source({
230
- config: options.config,
231
- css: sourceOptions.css ?? root.toString(),
232
- base: resolvePostcssBase(result, options),
233
- cwd: resolvePostcssProjectRoot(result, options),
234
- projectRoot: resolvePostcssProjectRoot(result, options),
235
- packageName: options.packageName,
236
- postcssPlugin: options.postcssPlugin
237
- }) : await resolveTailwindV4Source$1({
238
- ...sourceOptions,
239
- css: sourceOptions.css ?? root.toString(),
240
- base: resolvePostcssBase(result, options),
241
- projectRoot: resolvePostcssProjectRoot(result, options)
242
- }));
243
- const generateOptions = {
244
- candidates: new Set([...autoCandidates, ...candidates ?? []]),
245
- scanSources: false,
246
- sources: [...collectedSources.sources, ...sources ?? []],
247
- styleOptions: {
248
- ...generatorOptions.styleOptions,
249
- ...styleOptions
250
- },
251
- tailwindcssV3Compatibility: generatorOptions.tailwindcssV3Compatibility,
252
- target: legacyTarget ?? generatorOptions.target
253
- };
254
- const generated = await generator.generate(generateOptions);
255
- replaceRootCss(root, generated.css, result);
256
- addDependencyMessages(result, generated);
257
- addSourceDependencyMessages(result, collectedSources.files);
258
- result.messages.push({
259
- type: "weapp-tailwindcss:generated",
260
- plugin: PLUGIN_NAME,
261
- target: generated.target,
262
- classSet: generated.classSet,
263
- rawCss: generated.rawCss
264
- });
265
- }
266
- };
267
- };
268
- weappTailwindcssPostcssPlugin.postcss = true;
269
- //#endregion
1
+ import { t as weappTailwindcssPostcssPlugin } from "./postcss-Drpy7j-g.mjs";
270
2
  export { weappTailwindcssPostcssPlugin as default, weappTailwindcssPostcssPlugin };