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

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 (244) 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 +21 -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/user-layer-order.d.ts +10 -0
  21. package/dist/bundlers/shared/generator-css.d.ts +16 -22
  22. package/dist/bundlers/shared/hmr-timing.d.ts +22 -0
  23. package/dist/bundlers/shared/style-requests.d.ts +2 -0
  24. package/dist/bundlers/vite/bundle-state.d.ts +1 -0
  25. package/dist/bundlers/vite/css-finalizer.d.ts +7 -1
  26. package/dist/bundlers/vite/generate-bundle/candidates.d.ts +2 -0
  27. package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +24 -0
  28. package/dist/bundlers/vite/generate-bundle/css-share-scope.d.ts +4 -0
  29. package/dist/bundlers/vite/generate-bundle/dirty-state.d.ts +1 -0
  30. package/dist/bundlers/vite/generate-bundle/js-entries.d.ts +2 -0
  31. package/dist/bundlers/vite/generate-bundle/js-handler-options.d.ts +8 -0
  32. package/dist/bundlers/vite/generate-bundle/js-linking.d.ts +13 -0
  33. package/dist/bundlers/vite/generate-bundle/metrics.d.ts +17 -0
  34. package/dist/bundlers/vite/generate-bundle/process-plan.d.ts +9 -0
  35. package/dist/bundlers/vite/generate-bundle/rollup-assets.d.ts +7 -0
  36. package/dist/bundlers/vite/generate-bundle/signatures.d.ts +8 -0
  37. package/dist/bundlers/vite/generate-bundle.d.ts +14 -2
  38. package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +5 -1
  39. package/dist/bundlers/vite/index.d.ts +5 -2
  40. package/dist/bundlers/vite/official-tailwind-plugins.d.ts +5 -0
  41. package/dist/bundlers/vite/postcss-config.d.ts +6 -0
  42. package/dist/bundlers/vite/processed-css-assets.d.ts +32 -0
  43. package/dist/bundlers/vite/rewrite-css-imports.d.ts +8 -3
  44. package/dist/bundlers/vite/runtime-class-set.d.ts +25 -0
  45. package/dist/bundlers/vite/serve-css-generation.d.ts +11 -0
  46. package/dist/bundlers/vite/source-candidates.d.ts +19 -1
  47. package/dist/bundlers/vite/source-scan.d.ts +26 -0
  48. package/dist/bundlers/vite/static-config-content.d.ts +5 -0
  49. package/dist/bundlers/vite/tailwind-basedir.d.ts +1 -0
  50. package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +6 -0
  51. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +6 -2
  52. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +9 -3
  53. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +2 -1
  54. package/dist/bundlers/webpack/loaders/runtime-registry.d.ts +31 -0
  55. package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +2 -6
  56. package/dist/bundlers/webpack/loaders/weapp-tw-runtime-classset-loader.d.ts +3 -7
  57. package/dist/cache/index.d.ts +6 -6
  58. package/dist/{chunk-8l464Juk.js → chunk-C5U5_Hdc.js} +14 -0
  59. package/dist/cli/context.d.ts +1 -14
  60. package/dist/cli/doctor/types.d.ts +11 -11
  61. package/dist/cli/helpers.d.ts +1 -2
  62. package/dist/cli/mount-options.d.ts +2 -0
  63. package/dist/cli/types.d.ts +0 -2
  64. package/dist/cli/vscode-entry.d.ts +3 -3
  65. package/dist/cli.js +758 -604
  66. package/dist/cli.mjs +766 -612
  67. package/dist/constants.d.ts +1 -2
  68. package/dist/context/runtime-package-replacements.d.ts +2 -0
  69. package/dist/context/style-options.d.ts +3 -0
  70. package/dist/core.js +12 -20
  71. package/dist/core.mjs +8 -14
  72. package/dist/css-macro/auto.d.ts +10 -0
  73. package/dist/css-macro/constants.d.ts +5 -2
  74. package/dist/css-macro/postcss.d.ts +1 -0
  75. package/dist/css-macro/postcss.js +7 -46
  76. package/dist/css-macro/postcss.mjs +2 -46
  77. package/dist/css-macro.d.ts +1 -0
  78. package/dist/css-macro.js +16 -7
  79. package/dist/css-macro.mjs +15 -6
  80. package/dist/defaults-8xrgzxFY.mjs +151 -0
  81. package/dist/defaults-zKUH2mDe.js +193 -0
  82. package/dist/defaults.d.ts +15 -1
  83. package/dist/defaults.js +6 -131
  84. package/dist/defaults.mjs +2 -129
  85. package/dist/escape.js +10 -2
  86. package/dist/escape.mjs +10 -2
  87. package/dist/generator/index.d.ts +1 -1
  88. package/dist/generator/options.d.ts +9 -8
  89. package/dist/generator/types.d.ts +3 -3
  90. package/dist/generator-CrU-Ghc1.js +90 -0
  91. package/dist/generator-Qw-tZ0Z2.mjs +65 -0
  92. package/dist/generator.js +12 -12
  93. package/dist/generator.mjs +2 -1
  94. package/dist/gulp.js +187 -48
  95. package/dist/gulp.mjs +180 -41
  96. package/dist/incremental-runtime-class-set-Boqi1QlB.mjs +2224 -0
  97. package/dist/incremental-runtime-class-set-FAOHZmzh.js +2293 -0
  98. package/dist/index.d.ts +3 -2
  99. package/dist/index.js +19 -7
  100. package/dist/index.mjs +6 -5
  101. package/dist/js/babel/cache-options.d.ts +3 -0
  102. package/dist/js/babel/parse.d.ts +7 -4
  103. package/dist/js/index.d.ts +1 -0
  104. package/dist/js/literal-transform.d.ts +2 -0
  105. package/dist/js/precheck.d.ts +2 -2
  106. package/dist/logger-BNzxZbZj.mjs +2 -0
  107. package/dist/logger-TlKT3xmR.js +1 -0
  108. package/dist/postcss/config-directive.d.ts +1 -0
  109. package/dist/postcss/context.d.ts +9 -0
  110. package/dist/postcss/source-files.d.ts +8 -0
  111. package/dist/postcss/tailwind-version.d.ts +3 -0
  112. package/dist/postcss-C6zOQqlL.mjs +228 -0
  113. package/dist/postcss-C7BMYpEF.mjs +169 -0
  114. package/dist/postcss-CiYLsqZn.js +192 -0
  115. package/dist/postcss-DAWf9D3C.js +237 -0
  116. package/dist/postcss-html-transform.js +1 -1
  117. package/dist/postcss.d.ts +2 -2
  118. package/dist/postcss.js +3 -276
  119. package/dist/postcss.mjs +1 -269
  120. package/dist/precheck-D7K12zeX.mjs +4716 -0
  121. package/dist/precheck-D7gJSmJz.js +4842 -0
  122. package/dist/presets/index.d.ts +1 -0
  123. package/dist/presets/uni-app-x.d.ts +1 -0
  124. package/dist/presets.js +29 -13
  125. package/dist/presets.mjs +25 -11
  126. package/dist/reset.d.ts +1 -0
  127. package/dist/reset.js +1 -1
  128. package/dist/runtime-registry-DpcR3IHI.js +5496 -0
  129. package/dist/shared/mpx.d.ts +1 -0
  130. package/dist/source-candidates-CX2ozpKM.mjs +322 -0
  131. package/dist/source-candidates-DNM8iwXW.js +335 -0
  132. package/dist/tailwindcss/miniprogram.d.ts +1 -1
  133. package/dist/tailwindcss/patcher-options.d.ts +3 -51
  134. package/dist/tailwindcss/patcher.d.ts +1 -2
  135. package/dist/tailwindcss/remove-unsupported-css.d.ts +1 -2
  136. package/dist/tailwindcss/runtime/cache.d.ts +4 -3
  137. package/dist/tailwindcss/runtime-patch.d.ts +5 -0
  138. package/dist/tailwindcss/runtime.d.ts +11 -12
  139. package/dist/tailwindcss/source-scan.d.ts +35 -0
  140. package/dist/tailwindcss/targets.d.ts +1 -5
  141. package/dist/tailwindcss/v3-engine/types.d.ts +17 -14
  142. package/dist/tailwindcss/v4/css-entries.d.ts +2 -2
  143. package/dist/tailwindcss/v4/css-sources.d.ts +5 -0
  144. package/dist/tailwindcss/v4/patcher-options.d.ts +1 -23
  145. package/dist/tailwindcss/v4/patcher.d.ts +1 -0
  146. package/dist/tailwindcss/v4-engine/source.d.ts +2 -2
  147. package/dist/tailwindcss/v4-engine/types.d.ts +17 -5
  148. package/dist/tailwindcss/version.d.ts +4 -0
  149. package/dist/tailwindcss-B-e2RiXr.js +642 -0
  150. package/dist/tailwindcss-C7dJHZ0G.mjs +591 -0
  151. package/dist/typedoc.export.d.ts +0 -2
  152. package/dist/types/index.d.ts +52 -49
  153. package/dist/types/shared.d.ts +6 -0
  154. package/dist/types/user-defined-options/general.d.ts +25 -24
  155. package/dist/types/user-defined-options/important.d.ts +33 -28
  156. package/dist/types/user-defined-options/lifecycle.d.ts +4 -4
  157. package/dist/types/user-defined-options/matcher.d.ts +6 -6
  158. package/dist/uni-app-x/vite.d.ts +1 -1
  159. package/dist/unocss/index.d.ts +2 -0
  160. package/dist/utils/disabled.d.ts +2 -3
  161. package/dist/utils/object.d.ts +9 -0
  162. package/dist/utils/options.d.ts +2 -0
  163. package/dist/utils/regex.d.ts +1 -0
  164. package/dist/{utils-DmC9_In3.js → utils-D7Ygohep.js} +2 -2
  165. package/dist/{utils-7DUGTFED.mjs → utils-DsaS975I.mjs} +1 -1
  166. package/dist/v3-engine-CHItlVq5.js +3616 -0
  167. package/dist/v3-engine-DcvCCHfs.mjs +3321 -0
  168. package/dist/vite-BgTPSkQS.js +24446 -0
  169. package/dist/vite-fFRpSvyz.mjs +24432 -0
  170. package/dist/vite.d.ts +1 -2
  171. package/dist/vite.js +3 -4
  172. package/dist/vite.mjs +2 -2
  173. package/dist/weapp-tw-css-import-rewrite-loader.js +5227 -18
  174. package/dist/weapp-tw-runtime-classset-loader.js +32 -9
  175. package/dist/webpack-BXSWVdXh.js +851 -0
  176. package/dist/webpack-Dx2AZpGU.mjs +841 -0
  177. package/dist/webpack.d.ts +1 -3
  178. package/dist/webpack.js +3 -4
  179. package/dist/webpack.mjs +2 -2
  180. package/package.json +38 -48
  181. package/dist/bundlers/shared/generator-candidates.d.ts +0 -5
  182. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-assets.d.ts +0 -14
  183. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-loaders.d.ts +0 -15
  184. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4.d.ts +0 -9
  185. package/dist/bundlers/webpack/shared/css-imports.d.ts +0 -6
  186. package/dist/cli/config.d.ts +0 -5
  187. package/dist/cli/helpers/patch-cwd.d.ts +0 -1
  188. package/dist/cli/mount-options/patch-status.d.ts +0 -2
  189. package/dist/cli/patch-options.d.ts +0 -6
  190. package/dist/cli/tokens.d.ts +0 -4
  191. package/dist/cli/workspace/package-dirs.d.ts +0 -3
  192. package/dist/cli/workspace/patch-package.d.ts +0 -3
  193. package/dist/cli/workspace/patch-utils.d.ts +0 -3
  194. package/dist/cli/workspace/types.d.ts +0 -11
  195. package/dist/cli/workspace/workspace-globs.d.ts +0 -2
  196. package/dist/cli/workspace/workspace-io.d.ts +0 -1
  197. package/dist/cli/workspace/workspace-lock.d.ts +0 -1
  198. package/dist/cli/workspace.d.ts +0 -2
  199. package/dist/constants-B-_T5UnW.mjs +0 -44
  200. package/dist/constants-p1dyh1x1.js +0 -73
  201. package/dist/css-imports-BbrbluP9.js +0 -177
  202. package/dist/css-imports-CSdPq_Sc.mjs +0 -128
  203. package/dist/experimental/index.d.ts +0 -2
  204. package/dist/experimental/oxc/ast-utils.d.ts +0 -30
  205. package/dist/experimental/oxc/index.d.ts +0 -2
  206. package/dist/experimental/oxc/module-specifiers.d.ts +0 -2
  207. package/dist/experimental/shared/cache.d.ts +0 -3
  208. package/dist/experimental/shared/transform.d.ts +0 -3
  209. package/dist/experimental/shared.d.ts +0 -8
  210. package/dist/experimental/swc/ast-utils.d.ts +0 -30
  211. package/dist/experimental/swc/index.d.ts +0 -2
  212. package/dist/experimental/swc/module-specifiers.d.ts +0 -2
  213. package/dist/generator-Y-Ikv4Fu.mjs +0 -1177
  214. package/dist/generator-css-Bwy_Uz89.mjs +0 -1097
  215. package/dist/generator-css-CRLrHW4F.js +0 -1124
  216. package/dist/generator-mmhXzZnv.js +0 -1276
  217. package/dist/js/syntax.d.ts +0 -10
  218. package/dist/lightningcss/index.d.ts +0 -8
  219. package/dist/lightningcss/style-handler/options.d.ts +0 -3
  220. package/dist/lightningcss/style-handler/selector-transform.d.ts +0 -10
  221. package/dist/lightningcss/style-handler/selector-utils.d.ts +0 -10
  222. package/dist/lightningcss/style-handler.d.ts +0 -17
  223. package/dist/loader-anchors-1MumTAtA.mjs +0 -205
  224. package/dist/loader-anchors-TrFvT6g1.js +0 -273
  225. package/dist/logger-BZ45DZJT.js +0 -1003
  226. package/dist/logger-BoVx1Dbt.mjs +0 -935
  227. package/dist/patcher-options-6gJN2EXy.js +0 -115
  228. package/dist/patcher-options-DQfR5xxT.mjs +0 -92
  229. package/dist/recorder-GdTJ3QqX.js +0 -2878
  230. package/dist/recorder-XdFvVASS.mjs +0 -2763
  231. package/dist/tailwindcss/recorder.d.ts +0 -13
  232. package/dist/tailwindcss/targets/paths.d.ts +0 -13
  233. package/dist/tailwindcss/targets/record-io.d.ts +0 -5
  234. package/dist/tailwindcss/targets/recorder.d.ts +0 -3
  235. package/dist/tailwindcss/targets/types.d.ts +0 -35
  236. package/dist/types/disabled-options.d.ts +0 -4
  237. package/dist/vite-BDywuCjn.mjs +0 -2186
  238. package/dist/vite-DgRh_GXn.js +0 -2199
  239. package/dist/webpack-CAJR4hhP.js +0 -456
  240. package/dist/webpack-CiHqVZTg.mjs +0 -441
  241. package/dist/webpack4.d.ts +0 -4
  242. package/dist/webpack4.js +0 -387
  243. package/dist/webpack4.mjs +0 -379
  244. package/scripts/postinstall.mjs +0 -59
package/dist/index.d.ts CHANGED
@@ -4,5 +4,6 @@ export { createPlugins } from './gulp';
4
4
  export { weappTailwindcssPostcssPlugin } from './postcss';
5
5
  export type { WeappTailwindcssPostcssPluginOptions } from './postcss';
6
6
  export type * from './types';
7
- export { UnifiedViteWeappTailwindcssPlugin } from './vite';
8
- export { UnifiedWebpackPluginV5, weappTailwindcssPackageDir } from './webpack';
7
+ export { WeappTailwindcss } from './vite';
8
+ export { weappTailwindcssPackageDir } from './webpack';
9
+ export { unitConversionComposeRules, unitConversionPresets, } from '@weapp-tailwindcss/postcss';
package/dist/index.js CHANGED
@@ -1,12 +1,24 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_generator = require("./generator-mmhXzZnv.js");
2
+ const require_generator = require("./generator-CrU-Ghc1.js");
3
3
  const require_gulp = require("./gulp.js");
4
- const require_postcss = require("./postcss.js");
5
- const require_vite = require("./vite-DgRh_GXn.js");
6
- const require_webpack = require("./webpack-CAJR4hhP.js");
7
- exports.UnifiedViteWeappTailwindcssPlugin = require_vite.UnifiedViteWeappTailwindcssPlugin;
8
- exports.UnifiedWebpackPluginV5 = require_webpack.UnifiedWebpackPluginV5;
4
+ const require_postcss = require("./postcss-DAWf9D3C.js");
5
+ const require_vite = require("./vite-BgTPSkQS.js");
6
+ const require_webpack = require("./webpack-BXSWVdXh.js");
7
+ let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
8
+ exports.WeappTailwindcss = require_vite.WeappTailwindcss;
9
9
  exports.createPlugins = require_gulp.createPlugins;
10
10
  exports.createWeappTailwindcssGenerator = require_generator.createWeappTailwindcssGenerator;
11
+ Object.defineProperty(exports, "unitConversionComposeRules", {
12
+ enumerable: true,
13
+ get: function() {
14
+ return _weapp_tailwindcss_postcss.unitConversionComposeRules;
15
+ }
16
+ });
17
+ Object.defineProperty(exports, "unitConversionPresets", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return _weapp_tailwindcss_postcss.unitConversionPresets;
21
+ }
22
+ });
11
23
  exports.weappTailwindcssPackageDir = require_webpack.weappTailwindcssPackageDir;
12
- exports.weappTailwindcssPostcssPlugin = require_postcss;
24
+ exports.weappTailwindcssPostcssPlugin = require_postcss.weappTailwindcssPostcssPlugin;
package/dist/index.mjs CHANGED
@@ -1,6 +1,7 @@
1
- import { t as createWeappTailwindcssGenerator } from "./generator-Y-Ikv4Fu.mjs";
1
+ import { t as createWeappTailwindcssGenerator } from "./generator-Qw-tZ0Z2.mjs";
2
2
  import { WeappTailwindcss as createPlugins } from "./gulp.mjs";
3
- import weappTailwindcssPostcssPlugin from "./postcss.mjs";
4
- import { t as UnifiedViteWeappTailwindcssPlugin } from "./vite-BDywuCjn.mjs";
5
- import { n as weappTailwindcssPackageDir, t as UnifiedWebpackPluginV5 } from "./webpack-CiHqVZTg.mjs";
6
- export { UnifiedViteWeappTailwindcssPlugin, UnifiedWebpackPluginV5, createPlugins, createWeappTailwindcssGenerator, weappTailwindcssPackageDir, weappTailwindcssPostcssPlugin };
3
+ import { t as weappTailwindcssPostcssPlugin } from "./postcss-C6zOQqlL.mjs";
4
+ import { t as WeappTailwindcss } from "./vite-fFRpSvyz.mjs";
5
+ import { n as weappTailwindcssPackageDir } from "./webpack-Dx2AZpGU.mjs";
6
+ import { unitConversionComposeRules, unitConversionPresets } from "@weapp-tailwindcss/postcss";
7
+ export { WeappTailwindcss, createPlugins, createWeappTailwindcssGenerator, unitConversionComposeRules, unitConversionPresets, weappTailwindcssPackageDir, weappTailwindcssPostcssPlugin };
@@ -0,0 +1,3 @@
1
+ export declare const DEFAULT_PARSE_CACHE_MAX_ENTRIES = 128;
2
+ export declare const DEFAULT_PARSE_CACHE_MAX_SOURCE_LENGTH = 50000;
3
+ export declare const HARD_PARSE_CACHE_MAX_ENTRIES = 1024;
@@ -1,9 +1,12 @@
1
1
  import type { ParseResult, ParserOptions } from '@babel/parser';
2
2
  import type { File } from '@babel/types';
3
3
  import { LRUCache } from 'lru-cache';
4
+ export type BabelParseOptions = ParserOptions & {
5
+ cache?: boolean | undefined;
6
+ cacheKey?: string | undefined;
7
+ cacheMaxEntries?: number | undefined;
8
+ cacheMaxSourceLength?: number | undefined;
9
+ };
4
10
  export declare const parseCache: LRUCache<string, ParseResult<File>>;
5
11
  export declare function genCacheKey(source: string, options: any): string;
6
- export declare function babelParse(code: string, opts?: (ParserOptions & {
7
- cache?: boolean;
8
- cacheKey?: string;
9
- })): ParseResult<File>;
12
+ export declare function babelParse(code: string, opts?: BabelParseOptions): ParseResult<File>;
@@ -1,4 +1,5 @@
1
1
  import type { CreateJsHandlerOptions, JsHandler } from '../types';
2
2
  import { jsHandler } from './babel';
3
3
  export { jsHandler, };
4
+ export { transformLiteralText } from './literal-transform';
4
5
  export declare function createJsHandler(options: CreateJsHandlerOptions): JsHandler;
@@ -0,0 +1,2 @@
1
+ import type { IJsHandlerOptions } from '../types';
2
+ export declare function transformLiteralText(literal: string, options: IJsHandlerOptions): string | undefined;
@@ -1,2 +1,2 @@
1
- import type { CreateJsHandlerOptions } from '../types';
2
- export declare function shouldSkipJsTransform(rawSource: string, options?: CreateJsHandlerOptions): boolean;
1
+ import type { IJsHandlerOptions } from '../types';
2
+ export declare function shouldSkipJsTransform(rawSource: string, options?: IJsHandlerOptions): boolean;
@@ -0,0 +1,2 @@
1
+ import { logger as logger$1 } from "@weapp-tailwindcss/logger";
2
+ export { logger$1 as t };
@@ -0,0 +1 @@
1
+ require("@weapp-tailwindcss/logger");
@@ -0,0 +1 @@
1
+ export declare function prependConfigDirective(css: string, config: string | undefined): string;
@@ -0,0 +1,9 @@
1
+ import type { Result, Root } from 'postcss';
2
+ import type { WeappTailwindcssGenerateResult } from '../generator';
3
+ import type { WeappTailwindcssPostcssPluginOptions } from '../postcss';
4
+ export declare function resolveInputFile(result: Result): string | undefined;
5
+ export declare function resolvePostcssBase(result: Result, options: WeappTailwindcssPostcssPluginOptions): string;
6
+ export declare function resolvePostcssProjectRoot(result: Result, options: WeappTailwindcssPostcssPluginOptions): string;
7
+ export declare function replaceRootCss(root: Root, css: string, result: Result): void;
8
+ export declare function addDependencyMessages(result: Result, generated: WeappTailwindcssGenerateResult): void;
9
+ export declare function addSourceDependencyMessages(result: Result, files: string[]): void;
@@ -0,0 +1,8 @@
1
+ import type { Result, Root } from 'postcss';
2
+ import type { TailwindV4CandidateSource } from '../generator';
3
+ import type { WeappTailwindcssPostcssPluginOptions } from '../postcss';
4
+ export declare function collectAutoTailwindCandidates(root: Root, result: Result, options: WeappTailwindcssPostcssPluginOptions): Promise<Set<string>>;
5
+ export declare function collectPostcssLocalSources(root: Root, result: Result, options: WeappTailwindcssPostcssPluginOptions): Promise<{
6
+ files: string[];
7
+ sources: TailwindV4CandidateSource[];
8
+ }>;
@@ -0,0 +1,3 @@
1
+ import type { Result, Root } from 'postcss';
2
+ import type { WeappTailwindcssPostcssPluginOptions } from '../postcss';
3
+ export declare function resolvePostcssTailwindVersion(root: Root, result: Result, options: WeappTailwindcssPostcssPluginOptions): import("../tailwindcss/version").SupportedTailwindcssMajorVersion;
@@ -0,0 +1,228 @@
1
+ import { A as collectCssInlineSourceCandidates, F as parseConfigParam, H as readInstalledPackageMajorVersion, I as resolveCssSourceEntries, M as expandTailwindSourceEntries, O as DEFAULT_SOURCE_SCAN_EXTENSIONS, P as normalizeLegacyContentEntries, j as createSourceScanPattern, t as resolveTailwindV3Source, y as resolveTailwindV4Source$1 } from "./v3-engine-DcvCCHfs.mjs";
2
+ import { i as normalizeWeappTailwindcssGeneratorOptions, t as createWeappTailwindcssGenerator } from "./generator-Qw-tZ0Z2.mjs";
3
+ import postcss from "postcss";
4
+ import path from "node:path";
5
+ import process from "node:process";
6
+ import { extractRawCandidatesWithPositions, extractValidCandidates } from "tailwindcss-patch";
7
+ import { readFile } from "node:fs/promises";
8
+ import { loadConfig } from "tailwindcss-config";
9
+ //#region src/postcss/config-directive.ts
10
+ function quoteCssString(value) {
11
+ return value.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"");
12
+ }
13
+ function toCssPath(value) {
14
+ return value.replaceAll("\\", "/");
15
+ }
16
+ function prependConfigDirective(css, config) {
17
+ if (!config || /@config\s+/.test(css)) return css;
18
+ return `@config "${quoteCssString(toCssPath(config))}";\n${css}`;
19
+ }
20
+ //#endregion
21
+ //#region src/postcss/context.ts
22
+ const PLUGIN_NAME$1 = "weapp-tailwindcss";
23
+ function resolveInputFile(result) {
24
+ const from = result.opts.from;
25
+ if (typeof from !== "string" || from.length === 0) return;
26
+ return path.isAbsolute(from) ? from : path.resolve(process.cwd(), from);
27
+ }
28
+ function resolvePostcssBase(result, options) {
29
+ if (options.base) return options.base;
30
+ const inputFile = resolveInputFile(result);
31
+ return inputFile ? path.dirname(inputFile) : process.cwd();
32
+ }
33
+ function resolvePostcssProjectRoot(result, options) {
34
+ if (options.projectRoot) return options.projectRoot;
35
+ const inputFile = resolveInputFile(result);
36
+ return inputFile ? path.dirname(inputFile) : process.cwd();
37
+ }
38
+ function replaceRootCss(root, css, result) {
39
+ root.removeAll();
40
+ try {
41
+ const nextRoot = postcss.parse(css, { from: resolveInputFile(result) });
42
+ root.append(nextRoot.nodes);
43
+ } catch {
44
+ root.raws = { after: css };
45
+ }
46
+ }
47
+ function addDependencyMessages(result, generated) {
48
+ for (const file of generated.dependencies) result.messages.push({
49
+ type: "dependency",
50
+ plugin: PLUGIN_NAME$1,
51
+ file
52
+ });
53
+ }
54
+ function addSourceDependencyMessages(result, files) {
55
+ for (const file of files) result.messages.push({
56
+ type: "dependency",
57
+ plugin: PLUGIN_NAME$1,
58
+ file
59
+ });
60
+ }
61
+ //#endregion
62
+ //#region src/postcss/source-files.ts
63
+ const POSTCSS_SOURCE_PATTERN = createSourceScanPattern(DEFAULT_SOURCE_SCAN_EXTENSIONS);
64
+ function getSourceExtension(file) {
65
+ return path.extname(file).slice(1) || void 0;
66
+ }
67
+ function collectConfigPaths(root, base) {
68
+ const configPaths = [];
69
+ root.walkAtRules("config", (rule) => {
70
+ const configPath = parseConfigParam(rule.params);
71
+ if (configPath) configPaths.push(path.isAbsolute(configPath) ? configPath : path.resolve(base, configPath));
72
+ });
73
+ return [...new Set(configPaths)];
74
+ }
75
+ function resolveOptionConfigPath(config, base) {
76
+ if (!config) return;
77
+ return path.isAbsolute(config) ? config : path.resolve(base, config);
78
+ }
79
+ async function collectConfigContentFiles(root, base, options) {
80
+ const configPaths = [...new Set([...resolveOptionConfigPath(options.config, base) ? [resolveOptionConfigPath(options.config, base)] : [], ...collectConfigPaths(root, base)])];
81
+ const files = [];
82
+ for (const configPath of configPaths) {
83
+ const contentEntries = normalizeLegacyContentEntries((await loadConfig({
84
+ config: configPath,
85
+ cwd: path.dirname(configPath)
86
+ }))?.config.content, path.dirname(configPath));
87
+ files.push(...await expandTailwindSourceEntries(contentEntries));
88
+ }
89
+ return {
90
+ configPaths,
91
+ files: [...new Set(files)]
92
+ };
93
+ }
94
+ async function collectConfiguredContentEntries(root, base, options) {
95
+ const configPath = resolveOptionConfigPath(options.generator?.config ?? options.config, base) ?? collectConfigPaths(root, base)[0];
96
+ if (!configPath) return [];
97
+ const resolvedConfigPath = path.isAbsolute(configPath) ? configPath : path.resolve(base, configPath);
98
+ return normalizeLegacyContentEntries((await loadConfig({
99
+ config: resolvedConfigPath,
100
+ cwd: path.dirname(resolvedConfigPath)
101
+ }))?.config.content, path.dirname(resolvedConfigPath));
102
+ }
103
+ async function collectRawCandidatesFromSourceEntries(sourceEntries) {
104
+ const candidates = /* @__PURE__ */ new Set();
105
+ const files = await expandTailwindSourceEntries(sourceEntries);
106
+ await Promise.all(files.map(async (file) => {
107
+ const matches = await extractRawCandidatesWithPositions(await readFile(file, "utf8"), getSourceExtension(file));
108
+ for (const match of matches) {
109
+ const candidate = match?.rawCandidate;
110
+ if (typeof candidate === "string" && candidate.length > 0) candidates.add(candidate);
111
+ }
112
+ }));
113
+ return candidates;
114
+ }
115
+ async function collectAutoTailwindCandidates(root, result, options) {
116
+ if (options.scanSources === false) return /* @__PURE__ */ new Set();
117
+ const base = resolvePostcssBase(result, options);
118
+ const projectRoot = resolvePostcssProjectRoot(result, options);
119
+ const sourceEntries = [];
120
+ const hasSourceNone = root.toString().includes("source(none)");
121
+ const inlineCandidates = collectCssInlineSourceCandidates(root);
122
+ const configuredContentEntries = options.version === 3 ? await collectConfiguredContentEntries(root, base, options) : [];
123
+ if (configuredContentEntries.length > 0) sourceEntries.push(...configuredContentEntries);
124
+ else if (!hasSourceNone) sourceEntries.push({
125
+ base,
126
+ negated: false,
127
+ pattern: POSTCSS_SOURCE_PATTERN
128
+ });
129
+ sourceEntries.push(...await resolveCssSourceEntries(root, base, POSTCSS_SOURCE_PATTERN));
130
+ const candidates = sourceEntries.length === 0 ? [] : options.version === 3 ? await collectRawCandidatesFromSourceEntries(sourceEntries) : await extractValidCandidates({
131
+ base,
132
+ css: root.toString(),
133
+ cwd: projectRoot,
134
+ sources: sourceEntries
135
+ });
136
+ return new Set([...[...candidates].filter((candidate) => !inlineCandidates.excluded.has(candidate)), ...inlineCandidates.included]);
137
+ }
138
+ async function collectPostcssLocalSources(root, result, options) {
139
+ const base = resolvePostcssBase(result, options);
140
+ const sourceEntries = await resolveCssSourceEntries(root, base, POSTCSS_SOURCE_PATTERN);
141
+ const configContentFiles = await collectConfigContentFiles(root, base, options);
142
+ const files = [...new Set([...await expandTailwindSourceEntries(sourceEntries), ...configContentFiles.files])];
143
+ const sources = await Promise.all(files.map(async (file) => {
144
+ const extension = getSourceExtension(file);
145
+ return {
146
+ content: await readFile(file, "utf8"),
147
+ ...extension === void 0 ? {} : { extension }
148
+ };
149
+ }));
150
+ return {
151
+ files: [...files, ...configContentFiles.configPaths],
152
+ sources
153
+ };
154
+ }
155
+ //#endregion
156
+ //#region src/postcss/tailwind-version.ts
157
+ function hasTailwindV4CssSyntax(root) {
158
+ let hasV4Syntax = false;
159
+ root.walkAtRules((rule) => {
160
+ if (rule.name === "theme" || rule.name === "source" || rule.name === "custom-variant") hasV4Syntax = true;
161
+ if (rule.name === "import" && /(['"])tailwindcss\1/.test(rule.params)) hasV4Syntax = true;
162
+ });
163
+ return hasV4Syntax;
164
+ }
165
+ function resolvePostcssTailwindVersion(root, result, options) {
166
+ const packageName = options.packageName ?? "tailwindcss";
167
+ const installedVersion = readInstalledPackageMajorVersion(packageName, resolvePostcssProjectRoot(result, options));
168
+ if (installedVersion) return installedVersion;
169
+ if (options.version) return options.version;
170
+ if (packageName === "@tailwindcss/postcss" || packageName.includes("tailwindcss4")) return 4;
171
+ if (packageName.includes("tailwindcss3")) return 3;
172
+ if (hasTailwindV4CssSyntax(root)) return 4;
173
+ return 4;
174
+ }
175
+ //#endregion
176
+ //#region src/postcss.ts
177
+ const PLUGIN_NAME = "weapp-tailwindcss";
178
+ const weappTailwindcssPostcssPlugin = (options = {}) => {
179
+ return {
180
+ postcssPlugin: PLUGIN_NAME,
181
+ async Once(root, { result }) {
182
+ const { candidates, generator: userGeneratorOptions, scanSources, sources, styleOptions, ...sourceOptions } = options;
183
+ const generatorOptions = normalizeWeappTailwindcssGeneratorOptions(userGeneratorOptions);
184
+ const tailwindVersion = resolvePostcssTailwindVersion(root, result, options);
185
+ const [collectedSources, autoCandidates] = await Promise.all([collectPostcssLocalSources(root, result, options), collectAutoTailwindCandidates(root, result, options)]);
186
+ const generatorConfig = generatorOptions.config ?? options.config;
187
+ const generator = createWeappTailwindcssGenerator(tailwindVersion === 3 ? await resolveTailwindV3Source({
188
+ config: generatorConfig,
189
+ css: sourceOptions.css ?? root.toString(),
190
+ base: resolvePostcssBase(result, options),
191
+ cwd: resolvePostcssProjectRoot(result, options),
192
+ projectRoot: resolvePostcssProjectRoot(result, options),
193
+ packageName: options.packageName,
194
+ postcssPlugin: options.postcssPlugin
195
+ }) : await resolveTailwindV4Source$1({
196
+ ...sourceOptions,
197
+ css: prependConfigDirective(sourceOptions.css ?? root.toString(), generatorConfig),
198
+ base: resolvePostcssBase(result, options),
199
+ projectRoot: resolvePostcssProjectRoot(result, options)
200
+ }));
201
+ const generateOptions = {
202
+ candidates: new Set([...autoCandidates, ...candidates ?? []]),
203
+ scanSources: scanSources ?? false,
204
+ sources: [...collectedSources.sources, ...sources ?? []],
205
+ styleOptions: {
206
+ ...generatorOptions.styleOptions,
207
+ ...styleOptions
208
+ },
209
+ tailwindcssV3Compatibility: generatorOptions.tailwindcssV3Compatibility,
210
+ target: generatorOptions.target
211
+ };
212
+ const generated = await generator.generate(generateOptions);
213
+ replaceRootCss(root, generated.css, result);
214
+ addDependencyMessages(result, generated);
215
+ addSourceDependencyMessages(result, collectedSources.files);
216
+ result.messages.push({
217
+ type: "weapp-tailwindcss:generated",
218
+ plugin: PLUGIN_NAME,
219
+ target: generated.target,
220
+ classSet: generated.classSet,
221
+ rawCss: generated.rawCss
222
+ });
223
+ }
224
+ };
225
+ };
226
+ weappTailwindcssPostcssPlugin.postcss = true;
227
+ //#endregion
228
+ export { weappTailwindcssPostcssPlugin as t };
@@ -0,0 +1,169 @@
1
+ //#region src/css-macro/constants.ts
2
+ const queryKey = "weapp-tw-platform";
3
+ const ifdefAtRule = "weapp-tw-ifdef";
4
+ const ifndefAtRule = "weapp-tw-ifndef";
5
+ function quoteAtRuleParam(value) {
6
+ return `"${value.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"")}"`;
7
+ }
8
+ function createConditionalAtRule(value) {
9
+ return `@${ifdefAtRule} ${quoteAtRuleParam(value)}{&}`;
10
+ }
11
+ function createNegativeConditionalAtRule(value) {
12
+ return `@${ifndefAtRule} ${quoteAtRuleParam(value)}{&}`;
13
+ }
14
+ const UNESCAPED_UNDERSCORE_RE = /(?<!\\)_/g;
15
+ const WHITESPACE_RE = /\s+/g;
16
+ const LOGICAL_OPERATOR_RE = /\s*(\|\||&&)\s*/g;
17
+ function normalComment(text) {
18
+ if (typeof text === "string") {
19
+ const normalized = text.replaceAll(UNESCAPED_UNDERSCORE_RE, " ").replaceAll(WHITESPACE_RE, " ").trim();
20
+ if (normalized.includes("\\")) return normalized;
21
+ return normalized.replaceAll(LOGICAL_OPERATOR_RE, " $1 ").replaceAll(WHITESPACE_RE, " ").trim();
22
+ }
23
+ return text;
24
+ }
25
+ function ifdef(text) {
26
+ return {
27
+ start: `#ifdef ${normalComment(text)}`,
28
+ end: `#endif`
29
+ };
30
+ }
31
+ function ifndef(text) {
32
+ return {
33
+ start: `#ifndef ${normalComment(text)}`,
34
+ end: `#endif`
35
+ };
36
+ }
37
+ const QUERY_KEY_REGEX = new RegExp(`\\(\\s*${queryKey}\\s*:\\s*"([^)]*)"\\)`, "g");
38
+ function matchCustomPropertyFromValue(str, cb) {
39
+ let index = 0;
40
+ QUERY_KEY_REGEX.lastIndex = 0;
41
+ let arr = QUERY_KEY_REGEX.exec(str);
42
+ while (arr !== null) {
43
+ cb(arr, index);
44
+ index++;
45
+ arr = QUERY_KEY_REGEX.exec(str);
46
+ }
47
+ }
48
+ function parseConditionalAtRuleParam(params) {
49
+ const value = params.trim();
50
+ const quoted = /^(['"])((?:\\.|(?!\1).)*)\1/.exec(value);
51
+ if (!quoted) return value;
52
+ return quoted[2]?.replaceAll(/\\(["'\\])/g, "$1") ?? "";
53
+ }
54
+ //#endregion
55
+ //#region src/css-macro/postcss.ts
56
+ const IFDEF_ENDIF_RE = /#(?:ifn?def|endif)/;
57
+ const CONDITIONAL_COMMENT_SPACING = " ";
58
+ const CSS_MACRO_POSTCSS_PLUGIN_NAME = "postcss-weapp-tw-css-macro-plugin";
59
+ const creator = () => {
60
+ return {
61
+ postcssPlugin: CSS_MACRO_POSTCSS_PLUGIN_NAME,
62
+ prepare() {
63
+ function replaceAtRuleWithConditionalComments(atRule, helper, comment) {
64
+ const hasPreviousNode = Boolean(atRule.prev());
65
+ const clonedNodes = (atRule.nodes ?? []).map((node) => node.clone());
66
+ const startComment = helper.comment({
67
+ raws: {
68
+ left: CONDITIONAL_COMMENT_SPACING,
69
+ right: CONDITIONAL_COMMENT_SPACING
70
+ },
71
+ text: comment.start
72
+ });
73
+ const endComment = helper.comment({
74
+ raws: {
75
+ left: CONDITIONAL_COMMENT_SPACING,
76
+ right: CONDITIONAL_COMMENT_SPACING
77
+ },
78
+ text: comment.end
79
+ });
80
+ const nextNodes = [
81
+ startComment,
82
+ ...clonedNodes,
83
+ endComment
84
+ ];
85
+ atRule.replaceWith(nextNodes);
86
+ startComment.raws.before = hasPreviousNode ? "\n" : "";
87
+ startComment.raws["after"] = "\n";
88
+ if (clonedNodes[0]) clonedNodes[0].raws.before = "\n";
89
+ endComment.raws.before = "\n";
90
+ endComment.raws["after"] = "\n";
91
+ const nextNode = endComment?.next();
92
+ if (nextNode) nextNode.raws.before = "\n";
93
+ }
94
+ function replaceNestedAtRuleWithConditionalRule(atRule, helper, comment) {
95
+ if (atRule.parent?.type !== "rule") return false;
96
+ const parentRule = atRule.parent;
97
+ const clonedNodes = (atRule.nodes ?? []).map((node) => node.clone());
98
+ const conditionalRule = parentRule.clone();
99
+ conditionalRule.removeAll();
100
+ conditionalRule.append(...clonedNodes);
101
+ const startComment = helper.comment({
102
+ raws: {
103
+ left: CONDITIONAL_COMMENT_SPACING,
104
+ right: CONDITIONAL_COMMENT_SPACING
105
+ },
106
+ text: comment.start
107
+ });
108
+ const endComment = helper.comment({
109
+ raws: {
110
+ left: CONDITIONAL_COMMENT_SPACING,
111
+ right: CONDITIONAL_COMMENT_SPACING
112
+ },
113
+ text: comment.end
114
+ });
115
+ const nextNodes = [
116
+ startComment,
117
+ conditionalRule,
118
+ endComment
119
+ ];
120
+ const hasPreviousNode = Boolean(parentRule.prev());
121
+ atRule.remove();
122
+ if ((parentRule.nodes?.length ?? 0) === 0) parentRule.replaceWith(nextNodes);
123
+ else parentRule.after(nextNodes);
124
+ startComment.raws.before = hasPreviousNode ? "\n" : "";
125
+ startComment.raws["after"] = "\n";
126
+ conditionalRule.raws.before = "\n";
127
+ endComment.raws.before = "\n";
128
+ endComment.raws["after"] = "\n";
129
+ const nextNode = endComment.next();
130
+ if (nextNode) nextNode.raws.before = "\n";
131
+ return true;
132
+ }
133
+ return {
134
+ AtRule(atRule, helper) {
135
+ if (atRule.name === "weapp-tw-ifdef" || atRule.name === "weapp-tw-ifndef") {
136
+ const text = parseConditionalAtRuleParam(atRule.params);
137
+ const comment = atRule.name === "weapp-tw-ifndef" ? ifndef(text) : ifdef(text);
138
+ if (replaceNestedAtRuleWithConditionalRule(atRule, helper, comment)) return;
139
+ replaceAtRuleWithConditionalComments(atRule, helper, comment);
140
+ return;
141
+ }
142
+ if (atRule.name === "media") {
143
+ const values = [];
144
+ matchCustomPropertyFromValue(atRule.params, (arr) => {
145
+ const value = arr[1];
146
+ if (value) values.push(value);
147
+ });
148
+ if (values.length > 0) {
149
+ const isNegative = atRule.params.includes("not");
150
+ const text = values.join(" ");
151
+ const comment = isNegative ? ifndef(text) : ifdef(text);
152
+ if (replaceNestedAtRuleWithConditionalRule(atRule, helper, comment)) return;
153
+ replaceAtRuleWithConditionalComments(atRule, helper, comment);
154
+ }
155
+ }
156
+ },
157
+ CommentExit(comment) {
158
+ if (IFDEF_ENDIF_RE.test(comment.text)) {
159
+ comment.raws.left = CONDITIONAL_COMMENT_SPACING;
160
+ comment.raws.right = CONDITIONAL_COMMENT_SPACING;
161
+ }
162
+ }
163
+ };
164
+ }
165
+ };
166
+ };
167
+ creator.postcss = true;
168
+ //#endregion
169
+ export { createNegativeConditionalAtRule as i, creator as n, createConditionalAtRule as r, CSS_MACRO_POSTCSS_PLUGIN_NAME as t };