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

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 (243) hide show
  1. package/README.md +6 -7
  2. package/bin/weapp-tailwindcss.js +1 -21
  3. package/dist/auto-TH1jG2UW.js +115 -0
  4. package/dist/auto-XyKTOP7B.mjs +78 -0
  5. package/dist/bundle-state-Bi-cQua6.mjs +413 -0
  6. package/dist/bundle-state-Ct_8GcSR.js +529 -0
  7. package/dist/bundlers/shared/cache.d.ts +6 -6
  8. package/dist/bundlers/shared/css-cleanup/at-rules.d.ts +1 -0
  9. package/dist/bundlers/shared/css-cleanup.d.ts +1 -4
  10. package/dist/bundlers/shared/css-imports.d.ts +3 -3
  11. package/dist/bundlers/shared/generated-css-marker.d.ts +3 -0
  12. package/dist/bundlers/shared/generator-css/config-directive.d.ts +2 -0
  13. package/dist/bundlers/shared/generator-css/directives.d.ts +20 -0
  14. package/dist/bundlers/shared/generator-css/legacy-compat.d.ts +7 -0
  15. package/dist/bundlers/shared/generator-css/legacy-selectors.d.ts +5 -0
  16. package/dist/bundlers/shared/generator-css/legacy-units.d.ts +1 -0
  17. package/dist/bundlers/shared/generator-css/markers.d.ts +28 -0
  18. package/dist/bundlers/shared/generator-css/source-files.d.ts +14 -0
  19. package/dist/bundlers/shared/generator-css/source-resolver.d.ts +24 -0
  20. package/dist/bundlers/shared/generator-css.d.ts +16 -22
  21. package/dist/bundlers/shared/hmr-timing.d.ts +22 -0
  22. package/dist/bundlers/shared/style-requests.d.ts +2 -0
  23. package/dist/bundlers/vite/bundle-state.d.ts +1 -0
  24. package/dist/bundlers/vite/css-finalizer.d.ts +7 -1
  25. package/dist/bundlers/vite/generate-bundle/candidates.d.ts +2 -0
  26. package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +24 -0
  27. package/dist/bundlers/vite/generate-bundle/css-share-scope.d.ts +4 -0
  28. package/dist/bundlers/vite/generate-bundle/dirty-state.d.ts +1 -0
  29. package/dist/bundlers/vite/generate-bundle/js-entries.d.ts +2 -0
  30. package/dist/bundlers/vite/generate-bundle/js-handler-options.d.ts +8 -0
  31. package/dist/bundlers/vite/generate-bundle/js-linking.d.ts +13 -0
  32. package/dist/bundlers/vite/generate-bundle/metrics.d.ts +17 -0
  33. package/dist/bundlers/vite/generate-bundle/process-plan.d.ts +9 -0
  34. package/dist/bundlers/vite/generate-bundle/rollup-assets.d.ts +7 -0
  35. package/dist/bundlers/vite/generate-bundle/signatures.d.ts +8 -0
  36. package/dist/bundlers/vite/generate-bundle.d.ts +14 -2
  37. package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +5 -1
  38. package/dist/bundlers/vite/index.d.ts +5 -2
  39. package/dist/bundlers/vite/official-tailwind-plugins.d.ts +5 -0
  40. package/dist/bundlers/vite/postcss-config.d.ts +6 -0
  41. package/dist/bundlers/vite/processed-css-assets.d.ts +32 -0
  42. package/dist/bundlers/vite/rewrite-css-imports.d.ts +8 -3
  43. package/dist/bundlers/vite/runtime-class-set.d.ts +25 -0
  44. package/dist/bundlers/vite/serve-css-generation.d.ts +11 -0
  45. package/dist/bundlers/vite/source-candidates.d.ts +19 -1
  46. package/dist/bundlers/vite/source-scan.d.ts +26 -0
  47. package/dist/bundlers/vite/static-config-content.d.ts +5 -0
  48. package/dist/bundlers/vite/tailwind-basedir.d.ts +1 -0
  49. package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +6 -0
  50. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +6 -2
  51. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +9 -3
  52. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +2 -1
  53. package/dist/bundlers/webpack/loaders/runtime-registry.d.ts +31 -0
  54. package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +2 -6
  55. package/dist/bundlers/webpack/loaders/weapp-tw-runtime-classset-loader.d.ts +3 -7
  56. package/dist/cache/index.d.ts +6 -6
  57. package/dist/{chunk-8l464Juk.js → chunk-C5U5_Hdc.js} +14 -0
  58. package/dist/cli/context.d.ts +1 -14
  59. package/dist/cli/doctor/types.d.ts +11 -11
  60. package/dist/cli/helpers.d.ts +1 -2
  61. package/dist/cli/mount-options.d.ts +2 -0
  62. package/dist/cli/types.d.ts +0 -2
  63. package/dist/cli/vscode-entry.d.ts +3 -3
  64. package/dist/cli.js +758 -604
  65. package/dist/cli.mjs +766 -612
  66. package/dist/constants.d.ts +1 -2
  67. package/dist/context/runtime-package-replacements.d.ts +2 -0
  68. package/dist/context/style-options.d.ts +3 -0
  69. package/dist/core.js +12 -20
  70. package/dist/core.mjs +8 -14
  71. package/dist/css-macro/auto.d.ts +10 -0
  72. package/dist/css-macro/constants.d.ts +5 -2
  73. package/dist/css-macro/postcss.d.ts +1 -0
  74. package/dist/css-macro/postcss.js +7 -46
  75. package/dist/css-macro/postcss.mjs +2 -46
  76. package/dist/css-macro.d.ts +1 -0
  77. package/dist/css-macro.js +16 -7
  78. package/dist/css-macro.mjs +15 -6
  79. package/dist/defaults-8xrgzxFY.mjs +151 -0
  80. package/dist/defaults-zKUH2mDe.js +193 -0
  81. package/dist/defaults.d.ts +15 -1
  82. package/dist/defaults.js +6 -131
  83. package/dist/defaults.mjs +2 -129
  84. package/dist/escape.js +10 -2
  85. package/dist/escape.mjs +10 -2
  86. package/dist/generator/index.d.ts +1 -1
  87. package/dist/generator/options.d.ts +9 -8
  88. package/dist/generator/types.d.ts +3 -3
  89. package/dist/generator-CrU-Ghc1.js +90 -0
  90. package/dist/generator-Qw-tZ0Z2.mjs +65 -0
  91. package/dist/generator.js +12 -12
  92. package/dist/generator.mjs +2 -1
  93. package/dist/gulp.js +187 -48
  94. package/dist/gulp.mjs +180 -41
  95. package/dist/incremental-runtime-class-set-BdZHkoTs.mjs +1975 -0
  96. package/dist/incremental-runtime-class-set-BxvZONkv.js +2038 -0
  97. package/dist/index.d.ts +3 -2
  98. package/dist/index.js +19 -7
  99. package/dist/index.mjs +6 -5
  100. package/dist/js/babel/cache-options.d.ts +3 -0
  101. package/dist/js/babel/parse.d.ts +7 -4
  102. package/dist/js/index.d.ts +1 -0
  103. package/dist/js/literal-transform.d.ts +2 -0
  104. package/dist/js/precheck.d.ts +2 -2
  105. package/dist/logger-BNzxZbZj.mjs +2 -0
  106. package/dist/logger-TlKT3xmR.js +1 -0
  107. package/dist/postcss/config-directive.d.ts +1 -0
  108. package/dist/postcss/context.d.ts +9 -0
  109. package/dist/postcss/source-files.d.ts +8 -0
  110. package/dist/postcss/tailwind-version.d.ts +3 -0
  111. package/dist/postcss-C6zOQqlL.mjs +228 -0
  112. package/dist/postcss-C7BMYpEF.mjs +169 -0
  113. package/dist/postcss-CiYLsqZn.js +192 -0
  114. package/dist/postcss-DAWf9D3C.js +237 -0
  115. package/dist/postcss-html-transform.js +1 -1
  116. package/dist/postcss.d.ts +2 -2
  117. package/dist/postcss.js +3 -276
  118. package/dist/postcss.mjs +1 -269
  119. package/dist/precheck-D7K12zeX.mjs +4716 -0
  120. package/dist/precheck-D7gJSmJz.js +4842 -0
  121. package/dist/presets/index.d.ts +1 -0
  122. package/dist/presets/uni-app-x.d.ts +1 -0
  123. package/dist/presets.js +29 -13
  124. package/dist/presets.mjs +25 -11
  125. package/dist/reset.d.ts +1 -0
  126. package/dist/reset.js +1 -1
  127. package/dist/runtime-registry-DpcR3IHI.js +5496 -0
  128. package/dist/shared/mpx.d.ts +1 -0
  129. package/dist/source-candidates-CX2ozpKM.mjs +322 -0
  130. package/dist/source-candidates-DNM8iwXW.js +335 -0
  131. package/dist/tailwindcss/miniprogram.d.ts +1 -1
  132. package/dist/tailwindcss/patcher-options.d.ts +3 -51
  133. package/dist/tailwindcss/patcher.d.ts +1 -2
  134. package/dist/tailwindcss/remove-unsupported-css.d.ts +1 -2
  135. package/dist/tailwindcss/runtime/cache.d.ts +4 -3
  136. package/dist/tailwindcss/runtime-patch.d.ts +5 -0
  137. package/dist/tailwindcss/runtime.d.ts +11 -12
  138. package/dist/tailwindcss/source-scan.d.ts +35 -0
  139. package/dist/tailwindcss/targets.d.ts +1 -5
  140. package/dist/tailwindcss/v3-engine/types.d.ts +17 -14
  141. package/dist/tailwindcss/v4/css-entries.d.ts +2 -2
  142. package/dist/tailwindcss/v4/css-sources.d.ts +5 -0
  143. package/dist/tailwindcss/v4/patcher-options.d.ts +1 -23
  144. package/dist/tailwindcss/v4/patcher.d.ts +1 -0
  145. package/dist/tailwindcss/v4-engine/source.d.ts +2 -2
  146. package/dist/tailwindcss/v4-engine/types.d.ts +17 -5
  147. package/dist/tailwindcss/version.d.ts +4 -0
  148. package/dist/tailwindcss-B-e2RiXr.js +642 -0
  149. package/dist/tailwindcss-C7dJHZ0G.mjs +591 -0
  150. package/dist/typedoc.export.d.ts +0 -2
  151. package/dist/types/index.d.ts +52 -49
  152. package/dist/types/shared.d.ts +6 -0
  153. package/dist/types/user-defined-options/general.d.ts +25 -24
  154. package/dist/types/user-defined-options/important.d.ts +33 -28
  155. package/dist/types/user-defined-options/lifecycle.d.ts +4 -4
  156. package/dist/types/user-defined-options/matcher.d.ts +6 -6
  157. package/dist/uni-app-x/vite.d.ts +1 -1
  158. package/dist/unocss/index.d.ts +2 -0
  159. package/dist/utils/disabled.d.ts +2 -3
  160. package/dist/utils/object.d.ts +9 -0
  161. package/dist/utils/options.d.ts +2 -0
  162. package/dist/utils/regex.d.ts +1 -0
  163. package/dist/{utils-DmC9_In3.js → utils-D7Ygohep.js} +2 -2
  164. package/dist/{utils-7DUGTFED.mjs → utils-DsaS975I.mjs} +1 -1
  165. package/dist/v3-engine-CHItlVq5.js +3616 -0
  166. package/dist/v3-engine-DcvCCHfs.mjs +3321 -0
  167. package/dist/vite-C65DdWEj.js +24439 -0
  168. package/dist/vite-rmL1rsA_.mjs +24425 -0
  169. package/dist/vite.d.ts +1 -2
  170. package/dist/vite.js +3 -4
  171. package/dist/vite.mjs +2 -2
  172. package/dist/weapp-tw-css-import-rewrite-loader.js +5032 -18
  173. package/dist/weapp-tw-runtime-classset-loader.js +32 -9
  174. package/dist/webpack-BU2Er4qg.mjs +841 -0
  175. package/dist/webpack-CqGvjvSQ.js +851 -0
  176. package/dist/webpack.d.ts +1 -3
  177. package/dist/webpack.js +3 -4
  178. package/dist/webpack.mjs +2 -2
  179. package/package.json +38 -48
  180. package/dist/bundlers/shared/generator-candidates.d.ts +0 -5
  181. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-assets.d.ts +0 -14
  182. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-loaders.d.ts +0 -15
  183. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4.d.ts +0 -9
  184. package/dist/bundlers/webpack/shared/css-imports.d.ts +0 -6
  185. package/dist/cli/config.d.ts +0 -5
  186. package/dist/cli/helpers/patch-cwd.d.ts +0 -1
  187. package/dist/cli/mount-options/patch-status.d.ts +0 -2
  188. package/dist/cli/patch-options.d.ts +0 -6
  189. package/dist/cli/tokens.d.ts +0 -4
  190. package/dist/cli/workspace/package-dirs.d.ts +0 -3
  191. package/dist/cli/workspace/patch-package.d.ts +0 -3
  192. package/dist/cli/workspace/patch-utils.d.ts +0 -3
  193. package/dist/cli/workspace/types.d.ts +0 -11
  194. package/dist/cli/workspace/workspace-globs.d.ts +0 -2
  195. package/dist/cli/workspace/workspace-io.d.ts +0 -1
  196. package/dist/cli/workspace/workspace-lock.d.ts +0 -1
  197. package/dist/cli/workspace.d.ts +0 -2
  198. package/dist/constants-B-_T5UnW.mjs +0 -44
  199. package/dist/constants-p1dyh1x1.js +0 -73
  200. package/dist/css-imports-BbrbluP9.js +0 -177
  201. package/dist/css-imports-CSdPq_Sc.mjs +0 -128
  202. package/dist/experimental/index.d.ts +0 -2
  203. package/dist/experimental/oxc/ast-utils.d.ts +0 -30
  204. package/dist/experimental/oxc/index.d.ts +0 -2
  205. package/dist/experimental/oxc/module-specifiers.d.ts +0 -2
  206. package/dist/experimental/shared/cache.d.ts +0 -3
  207. package/dist/experimental/shared/transform.d.ts +0 -3
  208. package/dist/experimental/shared.d.ts +0 -8
  209. package/dist/experimental/swc/ast-utils.d.ts +0 -30
  210. package/dist/experimental/swc/index.d.ts +0 -2
  211. package/dist/experimental/swc/module-specifiers.d.ts +0 -2
  212. package/dist/generator-Y-Ikv4Fu.mjs +0 -1177
  213. package/dist/generator-css-Bwy_Uz89.mjs +0 -1097
  214. package/dist/generator-css-CRLrHW4F.js +0 -1124
  215. package/dist/generator-mmhXzZnv.js +0 -1276
  216. package/dist/js/syntax.d.ts +0 -10
  217. package/dist/lightningcss/index.d.ts +0 -8
  218. package/dist/lightningcss/style-handler/options.d.ts +0 -3
  219. package/dist/lightningcss/style-handler/selector-transform.d.ts +0 -10
  220. package/dist/lightningcss/style-handler/selector-utils.d.ts +0 -10
  221. package/dist/lightningcss/style-handler.d.ts +0 -17
  222. package/dist/loader-anchors-1MumTAtA.mjs +0 -205
  223. package/dist/loader-anchors-TrFvT6g1.js +0 -273
  224. package/dist/logger-BZ45DZJT.js +0 -1003
  225. package/dist/logger-BoVx1Dbt.mjs +0 -935
  226. package/dist/patcher-options-6gJN2EXy.js +0 -115
  227. package/dist/patcher-options-DQfR5xxT.mjs +0 -92
  228. package/dist/recorder-GdTJ3QqX.js +0 -2878
  229. package/dist/recorder-XdFvVASS.mjs +0 -2763
  230. package/dist/tailwindcss/recorder.d.ts +0 -13
  231. package/dist/tailwindcss/targets/paths.d.ts +0 -13
  232. package/dist/tailwindcss/targets/record-io.d.ts +0 -5
  233. package/dist/tailwindcss/targets/recorder.d.ts +0 -3
  234. package/dist/tailwindcss/targets/types.d.ts +0 -35
  235. package/dist/types/disabled-options.d.ts +0 -4
  236. package/dist/vite-BDywuCjn.mjs +0 -2186
  237. package/dist/vite-DgRh_GXn.js +0 -2199
  238. package/dist/webpack-CAJR4hhP.js +0 -456
  239. package/dist/webpack-CiHqVZTg.mjs +0 -441
  240. package/dist/webpack4.d.ts +0 -4
  241. package/dist/webpack4.js +0 -387
  242. package/dist/webpack4.mjs +0 -379
  243. package/scripts/postinstall.mjs +0 -59
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-DAWf9D3C.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-C6zOQqlL.mjs";
270
2
  export { weappTailwindcssPostcssPlugin as default, weappTailwindcssPostcssPlugin };