weapp-tailwindcss 5.0.0-next.5 → 5.0.0-next.8

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 (131) hide show
  1. package/dist/bundlers/shared/css-cleanup/at-rules.d.ts +2 -0
  2. package/dist/bundlers/shared/css-cleanup/color-gamut.d.ts +3 -0
  3. package/dist/bundlers/shared/css-cleanup/root-cleanups.d.ts +4 -0
  4. package/dist/bundlers/shared/css-cleanup/selectors.d.ts +8 -0
  5. package/dist/bundlers/shared/css-cleanup.d.ts +1 -2
  6. package/dist/bundlers/shared/generator-css/config-directive.d.ts +2 -0
  7. package/dist/bundlers/shared/generator-css/directives.d.ts +12 -0
  8. package/dist/bundlers/shared/generator-css/legacy-compat.d.ts +7 -0
  9. package/dist/bundlers/shared/generator-css/legacy-selectors.d.ts +5 -0
  10. package/dist/bundlers/shared/generator-css/legacy-units.d.ts +1 -0
  11. package/dist/bundlers/shared/generator-css/markers.d.ts +16 -0
  12. package/dist/bundlers/shared/generator-css/source-files.d.ts +11 -0
  13. package/dist/bundlers/shared/generator-css/source-resolver.d.ts +10 -0
  14. package/dist/bundlers/shared/generator-css.d.ts +10 -23
  15. package/dist/bundlers/vite/css-finalizer.d.ts +1 -1
  16. package/dist/bundlers/vite/generate-bundle/candidates.d.ts +2 -0
  17. package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +20 -0
  18. package/dist/bundlers/vite/generate-bundle/css-share-scope.d.ts +3 -0
  19. package/dist/bundlers/vite/generate-bundle/dirty-state.d.ts +1 -0
  20. package/dist/bundlers/vite/generate-bundle/js-entries.d.ts +2 -0
  21. package/dist/bundlers/vite/generate-bundle/js-handler-options.d.ts +8 -0
  22. package/dist/bundlers/vite/generate-bundle/js-linking.d.ts +13 -0
  23. package/dist/bundlers/vite/generate-bundle/metrics.d.ts +17 -0
  24. package/dist/bundlers/vite/generate-bundle/process-plan.d.ts +9 -0
  25. package/dist/bundlers/vite/generate-bundle/rollup-assets.d.ts +7 -0
  26. package/dist/bundlers/vite/generate-bundle/signatures.d.ts +8 -0
  27. package/dist/bundlers/vite/generate-bundle.d.ts +1 -1
  28. package/dist/bundlers/vite/official-tailwind-plugins.d.ts +5 -0
  29. package/dist/bundlers/vite/postcss-config.d.ts +6 -0
  30. package/dist/bundlers/vite/rewrite-css-imports.d.ts +1 -0
  31. package/dist/bundlers/vite/runtime-class-set.d.ts +22 -0
  32. package/dist/bundlers/vite/tailwind-basedir.d.ts +1 -0
  33. package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +1 -0
  34. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +1 -1
  35. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +2 -0
  36. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +1 -0
  37. package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +2 -0
  38. package/dist/cache-BVAiJV3J.js +502 -0
  39. package/dist/cache-CHs4DXui.mjs +434 -0
  40. package/dist/cli/helpers.d.ts +1 -2
  41. package/dist/cli/mount-options.d.ts +2 -2
  42. package/dist/cli/types.d.ts +0 -2
  43. package/dist/cli.js +107 -603
  44. package/dist/cli.mjs +118 -613
  45. package/dist/constants.d.ts +0 -1
  46. package/dist/context/tailwindcss.d.ts +1 -1
  47. package/dist/core.js +13 -20
  48. package/dist/core.mjs +8 -14
  49. package/dist/css-macro/postcss.js +1 -1
  50. package/dist/css-macro/postcss.mjs +1 -1
  51. package/dist/css-macro.js +2 -2
  52. package/dist/css-macro.mjs +2 -2
  53. package/dist/defaults.d.ts +15 -1
  54. package/dist/defaults.js +28 -7
  55. package/dist/defaults.mjs +25 -8
  56. package/dist/{generator-9UEp8OoQ.js → generator-DKkhJbOg.js} +24 -7
  57. package/dist/{generator-Dpp-5s8z.mjs → generator-UBmfduYg.mjs} +20 -3
  58. package/dist/{generator-css-MyjZhF0z.mjs → generator-css-BIapP56i.mjs} +691 -606
  59. package/dist/{generator-css-CGueCYbX.js → generator-css-Mksw8PgB.js} +703 -606
  60. package/dist/generator.js +1 -1
  61. package/dist/generator.mjs +1 -1
  62. package/dist/gulp.js +33 -21
  63. package/dist/gulp.mjs +29 -17
  64. package/dist/index.js +5 -5
  65. package/dist/index.mjs +4 -4
  66. package/dist/logger-BRy6XPQ2.js +1 -0
  67. package/dist/logger-Bub1jggA.mjs +2 -0
  68. package/dist/postcss/config-directive.d.ts +1 -0
  69. package/dist/postcss/context.d.ts +9 -0
  70. package/dist/postcss/source-files.d.ts +8 -0
  71. package/dist/postcss/tailwind-version.d.ts +3 -0
  72. package/dist/postcss-QIXwT40c.js +298 -0
  73. package/dist/postcss-w48mGIhe.mjs +288 -0
  74. package/dist/postcss.js +3 -285
  75. package/dist/postcss.mjs +1 -278
  76. package/dist/{recorder-D4BKt75Q.js → precheck-B32p-gLI.js} +139 -274
  77. package/dist/{recorder-BIW3Kuke.mjs → precheck-B4RH6ZNN.mjs} +105 -239
  78. package/dist/presets.js +6 -4
  79. package/dist/presets.mjs +4 -2
  80. package/dist/runtime-patch-CwN5ya72.mjs +71 -0
  81. package/dist/runtime-patch-D6mBo_KB.js +85 -0
  82. package/dist/tailwindcss/runtime-patch.d.ts +5 -0
  83. package/dist/tailwindcss/runtime.d.ts +2 -3
  84. package/dist/tailwindcss/targets.d.ts +1 -5
  85. package/dist/tailwindcss/v4/css-sources.d.ts +5 -0
  86. package/dist/tailwindcss/v4/patcher.d.ts +1 -1
  87. package/dist/{logger-D9clu_3f.js → tailwindcss-Bu-RWIHx.js} +70 -413
  88. package/dist/{logger-1gx9UllH.mjs → tailwindcss-C5IgPlQ0.mjs} +56 -382
  89. package/dist/types/index.d.ts +1 -6
  90. package/dist/uni-app-x/vite.d.ts +1 -1
  91. package/dist/{vite-fDM-UQpR.mjs → vite-BwgRVgxH.mjs} +677 -525
  92. package/dist/{vite-BkMGwDeH.js → vite-DyZuiyap.js} +704 -552
  93. package/dist/vite.js +1 -1
  94. package/dist/vite.mjs +1 -1
  95. package/dist/weapp-tw-css-import-rewrite-loader.js +10 -1
  96. package/dist/{webpack-CICGEKT9.js → webpack-CNV2dx3Q.js} +72 -37
  97. package/dist/{webpack-D2Wdk28V.mjs → webpack-CT6EEENx.mjs} +58 -23
  98. package/dist/webpack.js +1 -1
  99. package/dist/webpack.mjs +1 -1
  100. package/package.json +6 -9
  101. package/dist/bundlers/shared/generator-candidates.d.ts +0 -5
  102. package/dist/bundlers/webpack/shared/css-imports.d.ts +0 -6
  103. package/dist/cli/config.d.ts +0 -5
  104. package/dist/cli/helpers/patch-cwd.d.ts +0 -1
  105. package/dist/cli/mount-options/patch-status.d.ts +0 -2
  106. package/dist/cli/patch-options.d.ts +0 -6
  107. package/dist/cli/tokens.d.ts +0 -4
  108. package/dist/cli/workspace/package-dirs.d.ts +0 -3
  109. package/dist/cli/workspace/patch-package.d.ts +0 -3
  110. package/dist/cli/workspace/patch-utils.d.ts +0 -3
  111. package/dist/cli/workspace/types.d.ts +0 -11
  112. package/dist/cli/workspace/workspace-globs.d.ts +0 -2
  113. package/dist/cli/workspace/workspace-io.d.ts +0 -1
  114. package/dist/cli/workspace/workspace-lock.d.ts +0 -1
  115. package/dist/cli/workspace.d.ts +0 -2
  116. package/dist/js/syntax.d.ts +0 -10
  117. package/dist/patcher-options-DnqazL9E.js +0 -34
  118. package/dist/patcher-options-GuOwX0-k.mjs +0 -17
  119. package/dist/tailwindcss/recorder.d.ts +0 -13
  120. package/dist/tailwindcss/targets/paths.d.ts +0 -13
  121. package/dist/tailwindcss/targets/record-io.d.ts +0 -5
  122. package/dist/tailwindcss/targets/recorder.d.ts +0 -3
  123. package/dist/tailwindcss/targets/types.d.ts +0 -35
  124. package/dist/version-CWBxRFPB.js +0 -56
  125. package/dist/version-WNz3MwRv.mjs +0 -49
  126. /package/dist/{constants-p1dyh1x1.js → constants-BoB_6lFw.js} +0 -0
  127. /package/dist/{constants-B-_T5UnW.mjs → constants-E_loJC49.mjs} +0 -0
  128. /package/dist/{run-tasks-Cq5A5nVD.js → run-tasks-B50A3pxt.js} +0 -0
  129. /package/dist/{run-tasks-DUVrDJGl.mjs → run-tasks-DdNi-hkk.mjs} +0 -0
  130. /package/dist/{utils-DmC9_In3.js → utils-BiShvil9.js} +0 -0
  131. /package/dist/{utils-7DUGTFED.mjs → utils-Btw1iOVV.mjs} +0 -0
package/dist/postcss.mjs CHANGED
@@ -1,279 +1,2 @@
1
- import { a as resolveTailwindV4Source$1, i as normalizeWeappTailwindcssGeneratorOptions, p as resolveTailwindV3Source, t as createWeappTailwindcssGenerator } from "./generator-Dpp-5s8z.mjs";
2
- import { t as readInstalledPackageMajorVersion } from "./version-WNz3MwRv.mjs";
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_PATTERN = `**/*.{${[
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
- ].join(",")}}`;
30
- function resolveInputFile(result) {
31
- const from = result.opts.from;
32
- if (typeof from !== "string" || from.length === 0) return;
33
- return path.isAbsolute(from) ? from : path.resolve(process.cwd(), from);
34
- }
35
- function resolvePostcssBase(result, options) {
36
- if (options.base) return options.base;
37
- const inputFile = resolveInputFile(result);
38
- return inputFile ? path.dirname(inputFile) : process.cwd();
39
- }
40
- function resolvePostcssProjectRoot(result, options) {
41
- if (options.projectRoot) return options.projectRoot;
42
- const inputFile = resolveInputFile(result);
43
- return inputFile ? path.dirname(inputFile) : process.cwd();
44
- }
45
- function replaceRootCss(root, css, result) {
46
- root.removeAll();
47
- try {
48
- const nextRoot = postcss.parse(css, { from: resolveInputFile(result) });
49
- root.append(nextRoot.nodes);
50
- } catch {
51
- root.raws = { after: css };
52
- }
53
- }
54
- function addDependencyMessages(result, generated) {
55
- for (const file of generated.dependencies) result.messages.push({
56
- type: "dependency",
57
- plugin: PLUGIN_NAME,
58
- file
59
- });
60
- }
61
- function parseLocalSourceParam(params) {
62
- const value = params.trim();
63
- if (!value || value === "none" || value.startsWith("not ") || value.startsWith("inline(")) return;
64
- return /^(['"])(.+)\1$/.exec(value)?.[2];
65
- }
66
- function parseConfigParam(params) {
67
- const value = params.trim();
68
- return /^(['"])(.+)\1$/.exec(value)?.[2];
69
- }
70
- function parseSourceFileParam(params) {
71
- const value = params.trim();
72
- if (!value || value === "none" || value.startsWith("inline(")) return;
73
- const negated = value.startsWith("not ");
74
- const sourceValue = negated ? value.slice(4).trim() : value;
75
- const match = /^(['"])(.+)\1$/.exec(sourceValue);
76
- return match?.[2] ? {
77
- negated,
78
- sourcePath: match[2]
79
- } : void 0;
80
- }
81
- function hasTailwindV4CssSyntax(root) {
82
- let hasV4Syntax = false;
83
- root.walkAtRules((rule) => {
84
- if (rule.name === "theme" || rule.name === "source" || rule.name === "custom-variant") hasV4Syntax = true;
85
- if (rule.name === "import" && /(['"])tailwindcss\1/.test(rule.params)) hasV4Syntax = true;
86
- });
87
- return hasV4Syntax;
88
- }
89
- function resolvePostcssTailwindVersion(root, result, options) {
90
- const packageName = options.packageName ?? "tailwindcss";
91
- const installedVersion = readInstalledPackageMajorVersion(packageName, resolvePostcssProjectRoot(result, options));
92
- if (installedVersion) return installedVersion;
93
- if (options.version) return options.version;
94
- if (packageName === "@tailwindcss/postcss" || packageName.includes("tailwindcss4")) return 4;
95
- if (packageName.includes("tailwindcss3")) return 3;
96
- if (hasTailwindV4CssSyntax(root)) return 4;
97
- return 4;
98
- }
99
- function getSourceExtension(file) {
100
- return path.extname(file).slice(1) || void 0;
101
- }
102
- async function pathExistsAsDirectory(file) {
103
- try {
104
- return (await stat(file)).isDirectory();
105
- } catch {
106
- return false;
107
- }
108
- }
109
- async function expandLocalSourceFiles(sourcePath, base) {
110
- const absoluteSource = path.isAbsolute(sourcePath) ? sourcePath : path.resolve(base, sourcePath);
111
- if (await pathExistsAsDirectory(absoluteSource)) return fg(POSTCSS_SOURCE_PATTERN, {
112
- absolute: true,
113
- cwd: absoluteSource,
114
- onlyFiles: true
115
- });
116
- return fg(sourcePath, {
117
- absolute: true,
118
- cwd: base,
119
- onlyFiles: true
120
- });
121
- }
122
- async function resolveTailwindSourceEntry(sourcePath, base, negated) {
123
- const absoluteSource = path.isAbsolute(sourcePath) ? path.resolve(sourcePath) : path.resolve(base, sourcePath);
124
- if (await pathExistsAsDirectory(absoluteSource)) return {
125
- base: absoluteSource,
126
- negated,
127
- pattern: POSTCSS_SOURCE_PATTERN
128
- };
129
- if (path.isAbsolute(sourcePath)) return {
130
- base: path.dirname(absoluteSource),
131
- negated,
132
- pattern: path.basename(absoluteSource)
133
- };
134
- return {
135
- base,
136
- negated,
137
- pattern: sourcePath
138
- };
139
- }
140
- function collectConfigPaths(root, base) {
141
- const configPaths = [];
142
- root.walkAtRules("config", (rule) => {
143
- const configPath = parseConfigParam(rule.params);
144
- if (configPath) configPaths.push(path.isAbsolute(configPath) ? configPath : path.resolve(base, configPath));
145
- });
146
- return [...new Set(configPaths)];
147
- }
148
- function normalizeContentFiles(content) {
149
- if (typeof content === "string") return [content];
150
- if (Array.isArray(content)) return content.flatMap((item) => normalizeContentFiles(item));
151
- if (typeof content === "object" && content !== null && "files" in content) return normalizeContentFiles(content.files);
152
- return [];
153
- }
154
- async function collectConfigContentFiles(root, base) {
155
- const configPaths = collectConfigPaths(root, base);
156
- const files = [];
157
- for (const configPath of configPaths) {
158
- const contentFiles = normalizeContentFiles((await loadConfig({
159
- config: configPath,
160
- cwd: path.dirname(configPath)
161
- }))?.config.content);
162
- for (const contentFile of contentFiles) files.push(...await expandLocalSourceFiles(contentFile, path.dirname(configPath)));
163
- }
164
- return {
165
- configPaths,
166
- files: [...new Set(files)]
167
- };
168
- }
169
- async function collectAutoTailwindCandidates(root, result, options) {
170
- if (options.scanSources === false) return /* @__PURE__ */ new Set();
171
- const base = resolvePostcssBase(result, options);
172
- const projectRoot = resolvePostcssProjectRoot(result, options);
173
- const sourceEntryTasks = [];
174
- if (!root.toString().includes("source(none)")) sourceEntryTasks.push(Promise.resolve({
175
- base,
176
- negated: false,
177
- pattern: POSTCSS_SOURCE_PATTERN
178
- }));
179
- root.walkAtRules("source", (rule) => {
180
- const parsed = parseSourceFileParam(rule.params);
181
- if (!parsed) return;
182
- sourceEntryTasks.push(resolveTailwindSourceEntry(parsed.sourcePath, base, parsed.negated));
183
- });
184
- const sourceEntries = await Promise.all(sourceEntryTasks);
185
- if (sourceEntries.length === 0) return /* @__PURE__ */ new Set();
186
- const candidates = await extractValidCandidates({
187
- base,
188
- css: root.toString(),
189
- cwd: projectRoot,
190
- sources: sourceEntries
191
- });
192
- return new Set(candidates);
193
- }
194
- async function collectPostcssLocalSources(root, result, options) {
195
- const base = resolvePostcssBase(result, options);
196
- const sourcePaths = [];
197
- root.walkAtRules("source", (rule) => {
198
- const sourcePath = parseLocalSourceParam(rule.params);
199
- if (sourcePath) sourcePaths.push(sourcePath);
200
- });
201
- const configContentFiles = await collectConfigContentFiles(root, base);
202
- const files = [...new Set((await Promise.all(sourcePaths.map((sourcePath) => expandLocalSourceFiles(sourcePath, base)))).flat().concat(configContentFiles.files))];
203
- const sources = await Promise.all(files.map(async (file) => ({
204
- content: await readFile(file, "utf8"),
205
- extension: getSourceExtension(file)
206
- })));
207
- return {
208
- files: [...files, ...configContentFiles.configPaths],
209
- sources
210
- };
211
- }
212
- function addSourceDependencyMessages(result, files) {
213
- for (const file of files) result.messages.push({
214
- type: "dependency",
215
- plugin: PLUGIN_NAME,
216
- file
217
- });
218
- }
219
- function quoteCssString(value) {
220
- return value.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"");
221
- }
222
- function toCssPath(value) {
223
- return value.replaceAll("\\", "/");
224
- }
225
- function prependConfigDirective(css, config) {
226
- if (!config || /@config\s+/.test(css)) return css;
227
- return `@config "${quoteCssString(toCssPath(config))}";\n${css}`;
228
- }
229
- const weappTailwindcssPostcssPlugin = (options = {}) => {
230
- return {
231
- postcssPlugin: PLUGIN_NAME,
232
- async Once(root, { result }) {
233
- const { candidates, generator: userGeneratorOptions, scanSources, sources, styleOptions, ...sourceOptions } = options;
234
- const generatorOptions = normalizeWeappTailwindcssGeneratorOptions(userGeneratorOptions);
235
- const tailwindVersion = resolvePostcssTailwindVersion(root, result, options);
236
- const [collectedSources, autoCandidates] = await Promise.all([collectPostcssLocalSources(root, result, options), collectAutoTailwindCandidates(root, result, options)]);
237
- const generatorConfig = generatorOptions.config ?? options.config;
238
- const generator = createWeappTailwindcssGenerator(tailwindVersion === 3 ? await resolveTailwindV3Source({
239
- config: generatorConfig,
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 resolveTailwindV4Source$1({
247
- ...sourceOptions,
248
- css: prependConfigDirective(sourceOptions.css ?? root.toString(), generatorConfig),
249
- base: resolvePostcssBase(result, options),
250
- projectRoot: resolvePostcssProjectRoot(result, options)
251
- }));
252
- const generateOptions = {
253
- candidates: new Set([...autoCandidates, ...candidates ?? []]),
254
- scanSources: scanSources ?? false,
255
- sources: [...collectedSources.sources, ...sources ?? []],
256
- styleOptions: {
257
- ...generatorOptions.styleOptions,
258
- ...styleOptions
259
- },
260
- tailwindcssV3Compatibility: generatorOptions.tailwindcssV3Compatibility,
261
- target: 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
1
+ import { t as weappTailwindcssPostcssPlugin } from "./postcss-w48mGIhe.mjs";
279
2
  export { weappTailwindcssPostcssPlugin as default, weappTailwindcssPostcssPlugin };