weapp-tailwindcss 4.12.0 → 5.0.0-next.1
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.
- package/dist/babel/index.d.ts +3 -0
- package/dist/bundlers/gulp/index.d.ts +7 -0
- package/dist/bundlers/shared/cache.d.ts +16 -0
- package/dist/bundlers/shared/css-cleanup.d.ts +4 -0
- package/dist/bundlers/shared/css-imports.d.ts +8 -0
- package/dist/bundlers/shared/generator-candidates.d.ts +5 -0
- package/dist/bundlers/shared/generator-css.d.ts +41 -0
- package/dist/bundlers/shared/module-graph.d.ts +5 -0
- package/dist/bundlers/shared/run-tasks.d.ts +2 -0
- package/dist/bundlers/vite/bundle-entries.d.ts +14 -0
- package/dist/bundlers/vite/bundle-state.d.ts +43 -0
- package/dist/bundlers/vite/css-finalizer.d.ts +19 -0
- package/dist/bundlers/vite/generate-bundle.d.ts +20 -0
- package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +21 -0
- package/dist/bundlers/vite/index.d.ts +3 -0
- package/dist/bundlers/vite/js-precheck.d.ts +1 -0
- package/dist/bundlers/vite/query.d.ts +15 -0
- package/dist/bundlers/vite/resolve-app-type.d.ts +2 -0
- package/dist/bundlers/vite/rewrite-css-imports.d.ts +11 -0
- package/dist/bundlers/vite/runtime-affecting-signature.d.ts +2 -0
- package/dist/bundlers/vite/utils.d.ts +9 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +20 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-assets.d.ts +14 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-loaders.d.ts +15 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v4.d.ts +9 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +17 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +19 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +9 -0
- package/dist/bundlers/webpack/index.d.ts +1 -0
- package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +12 -0
- package/dist/bundlers/webpack/loaders/weapp-tw-runtime-classset-loader.d.ts +11 -0
- package/dist/bundlers/webpack/shared/css-imports.d.ts +6 -0
- package/dist/bundlers/webpack/shared/loader-anchors.d.ts +8 -0
- package/dist/cache/index.d.ts +38 -0
- package/dist/cache/md5.d.ts +1 -0
- package/dist/chunk-8l464Juk.js +28 -0
- package/dist/cli/config.d.ts +5 -0
- package/dist/cli/context.d.ts +16 -0
- package/dist/cli/doctor/constants.d.ts +7 -0
- package/dist/cli/doctor/types.d.ts +31 -0
- package/dist/cli/doctor.d.ts +4 -0
- package/dist/cli/helpers/options/format.d.ts +2 -0
- package/dist/cli/helpers/options/parse.d.ts +3 -0
- package/dist/cli/helpers/options/resolve.d.ts +1 -0
- package/dist/cli/helpers/options.d.ts +3 -0
- package/dist/cli/helpers/patch-cwd.d.ts +1 -0
- package/dist/cli/helpers.d.ts +5 -0
- package/dist/cli/mount-options/patch-status.d.ts +2 -0
- package/dist/cli/mount-options.d.ts +2 -0
- package/dist/cli/patch-options.d.ts +6 -0
- package/dist/cli/tokens.d.ts +4 -0
- package/dist/cli/types.d.ts +17 -0
- package/dist/cli/vscode-entry.d.ts +14 -0
- package/dist/cli/workspace/package-dirs.d.ts +3 -0
- package/dist/cli/workspace/patch-package.d.ts +3 -0
- package/dist/cli/workspace/patch-utils.d.ts +3 -0
- package/dist/cli/workspace/types.d.ts +11 -0
- package/dist/cli/workspace/workspace-globs.d.ts +2 -0
- package/dist/cli/workspace/workspace-io.d.ts +1 -0
- package/dist/cli/workspace/workspace-lock.d.ts +1 -0
- package/dist/cli/workspace.d.ts +2 -0
- package/dist/cli.d.ts +1 -2
- package/dist/cli.js +2425 -3524
- package/dist/cli.mjs +2402 -3505
- package/dist/constants-B-_T5UnW.mjs +44 -0
- package/dist/constants-p1dyh1x1.js +73 -0
- package/dist/constants.d.ts +13 -0
- package/dist/context/compiler-context-cache.d.ts +3 -0
- package/dist/context/custom-attributes.d.ts +2 -0
- package/dist/context/handlers.d.ts +6 -0
- package/dist/context/index.d.ts +7 -0
- package/dist/context/logger.d.ts +4 -0
- package/dist/context/tailwindcss/basedir.d.ts +1 -0
- package/dist/context/tailwindcss/rax.d.ts +2 -0
- package/dist/context/tailwindcss.d.ts +4 -0
- package/dist/context/workspace.d.ts +3 -0
- package/dist/core.d.ts +5 -21
- package/dist/core.js +138 -180
- package/dist/core.mjs +135 -180
- package/dist/css-imports-BbrbluP9.js +177 -0
- package/dist/css-imports-CSdPq_Sc.mjs +128 -0
- package/dist/css-macro/constants.d.ts +14 -0
- package/dist/css-macro/index.d.ts +15 -0
- package/dist/css-macro/postcss.d.ts +3 -7
- package/dist/css-macro/postcss.js +44 -58
- package/dist/css-macro/postcss.mjs +44 -56
- package/dist/css-macro.d.ts +1 -20
- package/dist/css-macro.js +37 -50
- package/dist/css-macro.mjs +33 -47
- package/dist/debug/index.d.ts +5 -0
- package/dist/defaults.d.ts +2 -11
- package/dist/defaults.js +132 -8
- package/dist/defaults.mjs +128 -7
- package/dist/escape.js +31 -54
- package/dist/escape.mjs +18 -25
- package/dist/experimental/index.d.ts +2 -0
- package/dist/experimental/oxc/ast-utils.d.ts +30 -0
- package/dist/experimental/oxc/index.d.ts +2 -0
- package/dist/experimental/oxc/module-specifiers.d.ts +2 -0
- package/dist/experimental/shared/cache.d.ts +3 -0
- package/dist/experimental/shared/transform.d.ts +3 -0
- package/dist/experimental/shared.d.ts +8 -0
- package/dist/experimental/swc/ast-utils.d.ts +30 -0
- package/dist/experimental/swc/index.d.ts +2 -0
- package/dist/experimental/swc/module-specifiers.d.ts +2 -0
- package/dist/generator/index.d.ts +11 -0
- package/dist/generator/options.d.ts +15 -0
- package/dist/generator/types.d.ts +19 -0
- package/dist/generator-CZ-JXw6T.js +492 -0
- package/dist/generator-Dwxgra97.mjs +399 -0
- package/dist/generator-css-CnYjiMrD.js +1084 -0
- package/dist/generator-css-DhPFjSzK.mjs +1057 -0
- package/dist/generator.d.ts +1 -0
- package/dist/generator.js +19 -0
- package/dist/generator.mjs +2 -0
- package/dist/gulp.d.ts +4 -24
- package/dist/gulp.js +271 -13
- package/dist/gulp.mjs +263 -13
- package/dist/index.d.ts +8 -15
- package/dist/index.js +12 -24
- package/dist/index.mjs +6 -24
- package/dist/js/JsTokenUpdater.d.ts +14 -0
- package/dist/js/ModuleGraph.d.ts +18 -0
- package/dist/js/NodePathWalker.d.ts +33 -0
- package/dist/js/babel/parse.d.ts +9 -0
- package/dist/js/babel/process.d.ts +4 -0
- package/dist/js/babel.d.ts +13 -0
- package/dist/js/class-context.d.ts +3 -0
- package/dist/js/evalTransforms.d.ts +7 -0
- package/dist/js/handlers.d.ts +5 -0
- package/dist/js/index.d.ts +4 -0
- package/dist/js/module-graph/ignored-exports.d.ts +18 -0
- package/dist/js/module-graph/types.d.ts +17 -0
- package/dist/js/node-path-walker/export-handlers.d.ts +12 -0
- package/dist/js/node-path-walker/import-tokens.d.ts +24 -0
- package/dist/js/precheck.d.ts +2 -0
- package/dist/js/sourceAnalysis.d.ts +17 -0
- package/dist/js/syntax.d.ts +10 -0
- package/dist/js/taggedTemplateIgnore.d.ts +13 -0
- package/dist/js/types.d.ts +11 -0
- package/dist/lightningcss/index.d.ts +8 -0
- package/dist/lightningcss/style-handler/options.d.ts +3 -0
- package/dist/lightningcss/style-handler/selector-transform.d.ts +10 -0
- package/dist/lightningcss/style-handler/selector-utils.d.ts +10 -0
- package/dist/lightningcss/style-handler.d.ts +17 -0
- package/dist/loader-anchors-DvwgIYdA.mjs +205 -0
- package/dist/loader-anchors-cprm4Klq.js +273 -0
- package/dist/logger/index.d.ts +2 -0
- package/dist/logger-BZ45DZJT.js +1003 -0
- package/dist/logger-BoVx1Dbt.mjs +935 -0
- package/dist/patcher-options-6gJN2EXy.js +115 -0
- package/dist/patcher-options-DQfR5xxT.mjs +92 -0
- package/dist/postcss-html-transform.d.ts +3 -3
- package/dist/postcss-html-transform.js +7 -10
- package/dist/postcss-html-transform.mjs +3 -6
- package/dist/postcss.d.ts +15 -0
- package/dist/postcss.js +278 -0
- package/dist/postcss.mjs +268 -0
- package/dist/presets/hbuilderx.d.ts +4 -0
- package/dist/presets/index.d.ts +3 -0
- package/dist/presets/shared.d.ts +10 -0
- package/dist/presets/taro.d.ts +4 -0
- package/dist/presets/uni-app-x.d.ts +16 -0
- package/dist/presets/uni-app.d.ts +4 -0
- package/dist/presets.d.ts +1 -76
- package/dist/presets.js +115 -163
- package/dist/presets.mjs +107 -163
- package/dist/recorder-B_XyZ576.mjs +2763 -0
- package/dist/recorder-rn_2v_nd.js +2878 -0
- package/dist/reset/index.d.ts +2 -0
- package/dist/reset.d.ts +1 -4
- package/dist/reset.js +19 -8
- package/dist/reset.mjs +2 -8
- package/dist/shared/classname-transform.d.ts +14 -0
- package/dist/shared/mpx.d.ts +7 -0
- package/dist/shared/tailwindcss-css-redirect.d.ts +1 -0
- package/dist/tailwindcss/index.d.ts +11 -0
- package/dist/tailwindcss/miniprogram.d.ts +1 -0
- package/dist/tailwindcss/patcher-options.d.ts +56 -0
- package/dist/tailwindcss/patcher-resolve.d.ts +4 -0
- package/dist/tailwindcss/patcher.d.ts +13 -0
- package/dist/tailwindcss/recorder.d.ts +13 -0
- package/dist/tailwindcss/remove-unsupported-css.d.ts +2 -0
- package/dist/tailwindcss/runtime/cache.d.ts +11 -0
- package/dist/tailwindcss/runtime-logs.d.ts +3 -0
- package/dist/tailwindcss/runtime.d.ts +29 -0
- package/dist/tailwindcss/targets/paths.d.ts +13 -0
- package/dist/tailwindcss/targets/record-io.d.ts +5 -0
- package/dist/tailwindcss/targets/recorder.d.ts +3 -0
- package/dist/tailwindcss/targets/types.d.ts +35 -0
- package/dist/tailwindcss/targets.d.ts +6 -0
- package/dist/tailwindcss/v3-engine/generator.d.ts +2 -0
- package/dist/tailwindcss/v3-engine/index.d.ts +4 -0
- package/dist/tailwindcss/v3-engine/miniprogram.d.ts +4 -0
- package/dist/tailwindcss/v3-engine/source.d.ts +5 -0
- package/dist/tailwindcss/v3-engine/types.d.ts +55 -0
- package/dist/tailwindcss/v4/config.d.ts +5 -0
- package/dist/tailwindcss/v4/css-entries.d.ts +7 -0
- package/dist/tailwindcss/v4/index.d.ts +2 -0
- package/dist/tailwindcss/v4/multi-patcher.d.ts +2 -0
- package/dist/tailwindcss/v4/patcher-options.d.ts +24 -0
- package/dist/tailwindcss/v4/patcher.d.ts +14 -0
- package/dist/tailwindcss/v4-engine/design-system.d.ts +1 -0
- package/dist/tailwindcss/v4-engine/generator.d.ts +2 -0
- package/dist/tailwindcss/v4-engine/index.d.ts +5 -0
- package/dist/tailwindcss/v4-engine/miniprogram.d.ts +4 -0
- package/dist/tailwindcss/v4-engine/source.d.ts +7 -0
- package/dist/tailwindcss/v4-engine/types.d.ts +17 -0
- package/dist/typedoc.export.d.ts +5 -0
- package/dist/types/base.d.ts +1 -0
- package/dist/types/disabled-options.d.ts +4 -0
- package/dist/types/index.d.ts +104 -0
- package/dist/types/shared.d.ts +7 -0
- package/dist/types/user-defined-options/general.d.ts +31 -0
- package/dist/types/user-defined-options/important.d.ts +37 -0
- package/dist/types/user-defined-options/index.d.ts +11 -0
- package/dist/types/user-defined-options/lifecycle.d.ts +6 -0
- package/dist/types/user-defined-options/matcher.d.ts +9 -0
- package/dist/types.d.ts +1 -150
- package/dist/types.js +0 -1
- package/dist/types.mjs +1 -1
- package/dist/uni-app-x/component-local-style.d.ts +19 -0
- package/dist/uni-app-x/index.d.ts +2 -0
- package/dist/uni-app-x/options.d.ts +12 -0
- package/dist/uni-app-x/style-isolation.d.ts +2 -0
- package/dist/uni-app-x/transform.d.ts +9 -0
- package/dist/uni-app-x/vite.d.ts +36 -0
- package/dist/utils/decode.d.ts +2 -0
- package/dist/utils/disabled.d.ts +6 -0
- package/dist/utils/hbuilderx.d.ts +5 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/nameMatcher.d.ts +4 -0
- package/dist/utils/resolve-package.d.ts +1 -0
- package/dist/utils/uni-platform.d.ts +11 -0
- package/dist/utils-7DUGTFED.mjs +48 -0
- package/dist/utils-DmC9_In3.js +61 -0
- package/dist/vite-BHpAqldo.js +1952 -0
- package/dist/vite-C8JlHiyR.mjs +1940 -0
- package/dist/vite.d.ts +4 -17
- package/dist/vite.js +5 -14
- package/dist/vite.mjs +2 -14
- package/dist/weapp-tw-css-import-rewrite-loader.js +59 -92
- package/dist/weapp-tw-runtime-classset-loader.js +31 -50
- package/dist/webpack-CABjKGGQ.mjs +441 -0
- package/dist/webpack-DNIJ0ysE.js +456 -0
- package/dist/webpack.d.ts +4 -25
- package/dist/webpack.js +6 -17
- package/dist/webpack.mjs +2 -17
- package/dist/webpack4.d.ts +4 -26
- package/dist/webpack4.js +375 -481
- package/dist/webpack4.mjs +366 -482
- package/dist/wxml/Tokenizer.d.ts +15 -0
- package/dist/wxml/custom-attributes.d.ts +4 -0
- package/dist/wxml/index.d.ts +2 -0
- package/dist/wxml/shared.d.ts +2 -0
- package/dist/wxml/tokenizer/types.d.ts +18 -0
- package/dist/wxml/utils/codegen/legacy-rewriter.d.ts +2 -0
- package/dist/wxml/utils/codegen/legacy-visitor.d.ts +8 -0
- package/dist/wxml/utils/codegen.d.ts +2 -0
- package/dist/wxml/utils/custom-template.d.ts +3 -0
- package/dist/wxml/utils/fragment-helpers.d.ts +6 -0
- package/dist/wxml/utils/fragment-updater.d.ts +4 -0
- package/dist/wxml/utils/template-fragments.d.ts +3 -0
- package/dist/wxml/utils.d.ts +8 -0
- package/dist/wxml/whitespace.d.ts +2 -0
- package/generator-placeholder.css +1 -0
- package/package.json +19 -5
- package/dist/chunk-24AGZQVR.js +0 -183
- package/dist/chunk-3VQKDHGP.mjs +0 -179
- package/dist/chunk-4AFQP74Z.js +0 -24
- package/dist/chunk-57SOQCAU.mjs +0 -582
- package/dist/chunk-5ZYHNDEK.mjs +0 -2439
- package/dist/chunk-76S2EME4.mjs +0 -34
- package/dist/chunk-A5PB4KZT.js +0 -138
- package/dist/chunk-DUHYLR2R.js +0 -276
- package/dist/chunk-DYLQ6UOI.js +0 -71
- package/dist/chunk-E7I5TW5K.js +0 -52
- package/dist/chunk-FS2NOOEB.js +0 -292
- package/dist/chunk-HVNGIKLS.js +0 -3930
- package/dist/chunk-JZQBZHN5.js +0 -579
- package/dist/chunk-KGTVD4EP.mjs +0 -3930
- package/dist/chunk-NNOQDMUP.mjs +0 -10
- package/dist/chunk-OF6MFURR.js +0 -34
- package/dist/chunk-OFB2KBRP.js +0 -2442
- package/dist/chunk-OOHJLO5M.mjs +0 -71
- package/dist/chunk-PCDYXXSK.mjs +0 -1515
- package/dist/chunk-RKISS72P.js +0 -7
- package/dist/chunk-RRQZL7FQ.mjs +0 -292
- package/dist/chunk-XAKAD2CR.mjs +0 -138
- package/dist/chunk-XZP3MREK.mjs +0 -276
- package/dist/chunk-ZAA5ZG3D.js +0 -1518
- package/dist/chunk-ZCH4YINE.mjs +0 -52
- package/dist/cli.d.mts +0 -2
- package/dist/core.d.mts +0 -26
- package/dist/css-macro/postcss.d.mts +0 -7
- package/dist/css-macro.d.mts +0 -18
- package/dist/defaults.d.mts +0 -11
- package/dist/gulp.d.mts +0 -24
- package/dist/index-BXrmQelt.d.mts +0 -672
- package/dist/index-BXrmQelt.d.ts +0 -672
- package/dist/index.d.mts +0 -15
- package/dist/postcss-html-transform.d.mts +0 -2
- package/dist/presets.d.mts +0 -76
- package/dist/reset.d.mts +0 -1
- package/dist/types.d.mts +0 -150
- package/dist/vite.d.mts +0 -17
- package/dist/webpack.d.mts +0 -25
- package/dist/webpack4.d.mts +0 -26
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
import { r as resolveTailwindcssOptions } from "./patcher-options-DQfR5xxT.mjs";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import postcss from "postcss";
|
|
4
|
+
import { createStyleHandler } from "@weapp-tailwindcss/postcss";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import process from "node:process";
|
|
7
|
+
import { loadConfig } from "tailwindcss-config";
|
|
8
|
+
import { createTailwindV4Engine, loadTailwindV4DesignSystem, resolveTailwindV4Source, resolveTailwindV4SourceFromPatchOptions } from "tailwindcss-patch";
|
|
9
|
+
//#region src/tailwindcss/remove-unsupported-css.ts
|
|
10
|
+
/**
|
|
11
|
+
* 移除小程序不支持的 cascade layer 语法,同时保留 layer 内的实际规则。
|
|
12
|
+
*/
|
|
13
|
+
function removeUnsupportedCascadeLayers(root) {
|
|
14
|
+
root.walkAtRules("layer", (atRule) => {
|
|
15
|
+
if (!atRule.nodes || atRule.nodes.length === 0) {
|
|
16
|
+
atRule.remove();
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
atRule.replaceWith(...atRule.nodes);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/tailwindcss/miniprogram.ts
|
|
24
|
+
const DEFAULT_WEAPP_VARIABLE_SCOPE = "page,.tw-root,wx-root-portal-content,:host";
|
|
25
|
+
const CLASS_SELECTOR_RE = /(?:^|[^\w-])\.[_a-z\u00A0-\uFFFF\\-]/i;
|
|
26
|
+
const PSEUDO_CONTENT_SELECTOR_RE = /^(?:::before|::after|:before|:after)(?:,(?:::before|::after|:before|:after))*$/;
|
|
27
|
+
function hasClassSelector(selector) {
|
|
28
|
+
return CLASS_SELECTOR_RE.test(selector);
|
|
29
|
+
}
|
|
30
|
+
function isCustomPropertyRule(rule) {
|
|
31
|
+
let hasDeclaration = false;
|
|
32
|
+
let allCustomProperties = true;
|
|
33
|
+
rule.walkDecls((decl) => {
|
|
34
|
+
hasDeclaration = true;
|
|
35
|
+
if (!decl.prop.startsWith("--")) allCustomProperties = false;
|
|
36
|
+
});
|
|
37
|
+
return hasDeclaration && allCustomProperties;
|
|
38
|
+
}
|
|
39
|
+
function isPseudoContentInitRule(rule) {
|
|
40
|
+
const selector = rule.selector.replace(/\s+/g, "");
|
|
41
|
+
if (!PSEUDO_CONTENT_SELECTOR_RE.test(selector)) return false;
|
|
42
|
+
let hasDeclaration = false;
|
|
43
|
+
let onlyContentVariable = true;
|
|
44
|
+
rule.walkDecls((decl) => {
|
|
45
|
+
hasDeclaration = true;
|
|
46
|
+
if (decl.prop !== "--tw-content") onlyContentVariable = false;
|
|
47
|
+
});
|
|
48
|
+
return hasDeclaration && onlyContentVariable;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* 裁剪 Tailwind 生成 CSS 中面向浏览器的 classless 规则。
|
|
52
|
+
*
|
|
53
|
+
* 生成模式面向小程序时只需要保留业务 utility 与 Tailwind 变量初始化;
|
|
54
|
+
* 浏览器元素 reset、表单伪元素等 classless 规则不适合直接输出到小程序。
|
|
55
|
+
*/
|
|
56
|
+
function pruneMiniProgramGeneratedCss(css) {
|
|
57
|
+
const root = postcss.parse(css);
|
|
58
|
+
root.walkComments((comment) => {
|
|
59
|
+
comment.remove();
|
|
60
|
+
});
|
|
61
|
+
removeUnsupportedCascadeLayers(root);
|
|
62
|
+
root.walkAtRules("supports", (atRule) => {
|
|
63
|
+
atRule.remove();
|
|
64
|
+
});
|
|
65
|
+
root.walkRules((rule) => {
|
|
66
|
+
if (hasClassSelector(rule.selector)) return;
|
|
67
|
+
if (isPseudoContentInitRule(rule)) return;
|
|
68
|
+
if (isCustomPropertyRule(rule)) {
|
|
69
|
+
rule.selector = DEFAULT_WEAPP_VARIABLE_SCOPE;
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
rule.remove();
|
|
73
|
+
});
|
|
74
|
+
root.walkAtRules((atRule) => {
|
|
75
|
+
if (!atRule.nodes || atRule.nodes.length === 0) atRule.remove();
|
|
76
|
+
});
|
|
77
|
+
return root.toString();
|
|
78
|
+
}
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region src/tailwindcss/v3-engine/miniprogram.ts
|
|
81
|
+
const defaultStyleHandler$1 = createStyleHandler({
|
|
82
|
+
cssChildCombinatorReplaceValue: ["view", "text"],
|
|
83
|
+
cssRemoveHoverPseudoClass: true,
|
|
84
|
+
isMainChunk: true,
|
|
85
|
+
majorVersion: 3
|
|
86
|
+
});
|
|
87
|
+
async function transformTailwindV3CssToWeapp(css, options) {
|
|
88
|
+
return pruneMiniProgramGeneratedCss((await defaultStyleHandler$1(css, {
|
|
89
|
+
cssChildCombinatorReplaceValue: ["view", "text"],
|
|
90
|
+
cssRemoveHoverPseudoClass: true,
|
|
91
|
+
isMainChunk: true,
|
|
92
|
+
majorVersion: 3,
|
|
93
|
+
...options
|
|
94
|
+
})).css);
|
|
95
|
+
}
|
|
96
|
+
async function transformTailwindV3CssByTarget(css, target, options) {
|
|
97
|
+
return target === "weapp" ? transformTailwindV3CssToWeapp(css, options) : css;
|
|
98
|
+
}
|
|
99
|
+
//#endregion
|
|
100
|
+
//#region src/tailwindcss/v3-engine/generator.ts
|
|
101
|
+
function isLegacyContentObject(value) {
|
|
102
|
+
return typeof value === "object" && value !== null && "files" in value;
|
|
103
|
+
}
|
|
104
|
+
function createRawContentEntries(candidates, sources) {
|
|
105
|
+
const entries = [];
|
|
106
|
+
const candidateContent = [...candidates].join(" ");
|
|
107
|
+
if (candidateContent.length > 0) entries.push({
|
|
108
|
+
raw: candidateContent,
|
|
109
|
+
extension: "html"
|
|
110
|
+
});
|
|
111
|
+
for (const source of sources) entries.push({
|
|
112
|
+
raw: source.content,
|
|
113
|
+
extension: source.extension ?? "html"
|
|
114
|
+
});
|
|
115
|
+
return entries;
|
|
116
|
+
}
|
|
117
|
+
function mergeContent(content, rawEntries) {
|
|
118
|
+
if (isLegacyContentObject(content)) return {
|
|
119
|
+
...content,
|
|
120
|
+
relative: content.relative ?? true,
|
|
121
|
+
files: [...[].concat(content.files ?? []), ...rawEntries]
|
|
122
|
+
};
|
|
123
|
+
return {
|
|
124
|
+
relative: true,
|
|
125
|
+
files: [...[].concat(content ?? []), ...rawEntries]
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
function normalizeConfigObject(config) {
|
|
129
|
+
if (!config || typeof config !== "object") return config;
|
|
130
|
+
const maybeDefault = config.default;
|
|
131
|
+
if (maybeDefault && typeof maybeDefault === "object") return maybeDefault;
|
|
132
|
+
return config;
|
|
133
|
+
}
|
|
134
|
+
function createTailwindConfig(source, options) {
|
|
135
|
+
const config = { ...normalizeConfigObject(source.configObject) ?? {} };
|
|
136
|
+
const rawEntries = createRawContentEntries(options.candidates ?? [], options.sources ?? []);
|
|
137
|
+
config.content = mergeContent(config.content, rawEntries);
|
|
138
|
+
return config;
|
|
139
|
+
}
|
|
140
|
+
function loadTailwindcssPlugin(source) {
|
|
141
|
+
const requireFromProject = createRequire(`${source.cwd}/package.json`);
|
|
142
|
+
const requireFromRuntime = createRequire(import.meta.url);
|
|
143
|
+
let plugin;
|
|
144
|
+
try {
|
|
145
|
+
plugin = requireFromProject(source.postcssPlugin);
|
|
146
|
+
} catch {
|
|
147
|
+
plugin = requireFromRuntime(source.postcssPlugin);
|
|
148
|
+
}
|
|
149
|
+
return typeof plugin === "function" ? plugin : plugin.default;
|
|
150
|
+
}
|
|
151
|
+
function collectClassSet(plugin) {
|
|
152
|
+
const classSet = /* @__PURE__ */ new Set();
|
|
153
|
+
for (const context of plugin.contextRef?.value ?? []) for (const candidate of context.classCache?.keys() ?? []) if (candidate !== "*") classSet.add(candidate);
|
|
154
|
+
return classSet;
|
|
155
|
+
}
|
|
156
|
+
function collectDependencyMessages(result) {
|
|
157
|
+
const dependencies = /* @__PURE__ */ new Set();
|
|
158
|
+
for (const message of result.messages) if (message.type === "dependency" && typeof message.file === "string") dependencies.add(message.file);
|
|
159
|
+
return dependencies;
|
|
160
|
+
}
|
|
161
|
+
function createTailwindV3Engine(source) {
|
|
162
|
+
async function generate(options = {}) {
|
|
163
|
+
const { styleOptions, target = "weapp" } = options;
|
|
164
|
+
const tailwindcss = loadTailwindcssPlugin(source);
|
|
165
|
+
const result = await postcss([tailwindcss(createTailwindConfig(source, options))]).process(source.css, { from: void 0 });
|
|
166
|
+
const rawCss = result.css;
|
|
167
|
+
const css = await transformTailwindV3CssByTarget(rawCss, target, styleOptions);
|
|
168
|
+
const dependencies = collectDependencyMessages(result);
|
|
169
|
+
for (const dependency of source.dependencies) dependencies.add(dependency);
|
|
170
|
+
return {
|
|
171
|
+
css,
|
|
172
|
+
rawCss,
|
|
173
|
+
classSet: collectClassSet(tailwindcss),
|
|
174
|
+
rawCandidates: new Set(options.candidates ?? []),
|
|
175
|
+
dependencies: [...dependencies],
|
|
176
|
+
sources: [],
|
|
177
|
+
root: null,
|
|
178
|
+
target,
|
|
179
|
+
version: 3
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
return {
|
|
183
|
+
source,
|
|
184
|
+
async validateCandidates(candidates) {
|
|
185
|
+
return (await generate({
|
|
186
|
+
candidates,
|
|
187
|
+
target: "tailwind"
|
|
188
|
+
})).classSet;
|
|
189
|
+
},
|
|
190
|
+
generate
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
//#endregion
|
|
194
|
+
//#region src/tailwindcss/v3-engine/source.ts
|
|
195
|
+
const DEFAULT_TAILWIND_V3_CSS = [
|
|
196
|
+
"@tailwind base;",
|
|
197
|
+
"@tailwind components;",
|
|
198
|
+
"@tailwind utilities;"
|
|
199
|
+
].join("\n");
|
|
200
|
+
function parseConfigParam(params) {
|
|
201
|
+
const value = params.trim();
|
|
202
|
+
return /^(['"])(.+)\1$/.exec(value)?.[2];
|
|
203
|
+
}
|
|
204
|
+
function resolveOptionalPath(value, base) {
|
|
205
|
+
if (!value) return;
|
|
206
|
+
return path.isAbsolute(value) ? value : path.resolve(base, value);
|
|
207
|
+
}
|
|
208
|
+
function resolveCssConfig(css, base) {
|
|
209
|
+
if (!css) return {
|
|
210
|
+
css,
|
|
211
|
+
config: void 0
|
|
212
|
+
};
|
|
213
|
+
const root = postcss.parse(css);
|
|
214
|
+
let config;
|
|
215
|
+
root.walkAtRules("config", (rule) => {
|
|
216
|
+
const configPath = parseConfigParam(rule.params);
|
|
217
|
+
if (!configPath) return;
|
|
218
|
+
if (!config) config = resolveOptionalPath(configPath, base);
|
|
219
|
+
rule.remove();
|
|
220
|
+
});
|
|
221
|
+
return {
|
|
222
|
+
config,
|
|
223
|
+
css: root.toString()
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
function getProjectRoot$1(patcher) {
|
|
227
|
+
return patcher.options?.projectRoot ?? process.cwd();
|
|
228
|
+
}
|
|
229
|
+
function normalizeLoadedConfig(config) {
|
|
230
|
+
if (!config || typeof config !== "object") return config;
|
|
231
|
+
const maybeDefault = config.default;
|
|
232
|
+
if (maybeDefault && typeof maybeDefault === "object") return maybeDefault;
|
|
233
|
+
return config;
|
|
234
|
+
}
|
|
235
|
+
function resolveTailwindCssPackageName(patcher) {
|
|
236
|
+
return resolveTailwindcssOptions(patcher.options)?.packageName ?? patcher.packageInfo?.name ?? "tailwindcss";
|
|
237
|
+
}
|
|
238
|
+
async function resolveTailwindV3Source(options = {}) {
|
|
239
|
+
const projectRoot = options.projectRoot ?? process.cwd();
|
|
240
|
+
const base = options.base ?? options.cwd ?? projectRoot;
|
|
241
|
+
const cssConfig = resolveCssConfig(options.css, base);
|
|
242
|
+
const config = resolveOptionalPath(options.config, base) ?? cssConfig.config;
|
|
243
|
+
const cwd = options.cwd ?? (config ? path.dirname(config) : projectRoot);
|
|
244
|
+
const loaded = await loadConfig({
|
|
245
|
+
config,
|
|
246
|
+
cwd
|
|
247
|
+
});
|
|
248
|
+
return {
|
|
249
|
+
version: 3,
|
|
250
|
+
projectRoot,
|
|
251
|
+
cwd,
|
|
252
|
+
base,
|
|
253
|
+
css: cssConfig.css ?? options.css ?? DEFAULT_TAILWIND_V3_CSS,
|
|
254
|
+
config: loaded?.filepath ?? config,
|
|
255
|
+
configObject: normalizeLoadedConfig(loaded?.config),
|
|
256
|
+
dependencies: loaded?.filepath ? [loaded.filepath] : [],
|
|
257
|
+
packageName: options.packageName ?? "tailwindcss",
|
|
258
|
+
postcssPlugin: options.postcssPlugin ?? options.packageName ?? "tailwindcss"
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
function resolveTailwindV3SourceOptionsFromPatcher(patcher) {
|
|
262
|
+
const projectRoot = getProjectRoot$1(patcher);
|
|
263
|
+
const tailwindOptions = resolveTailwindcssOptions(patcher.options);
|
|
264
|
+
return {
|
|
265
|
+
projectRoot,
|
|
266
|
+
cwd: tailwindOptions?.v3?.cwd ?? tailwindOptions?.cwd ?? projectRoot,
|
|
267
|
+
config: tailwindOptions?.v3?.config ?? tailwindOptions?.config,
|
|
268
|
+
packageName: resolveTailwindCssPackageName(patcher),
|
|
269
|
+
postcssPlugin: tailwindOptions?.v3?.postcssPlugin ?? tailwindOptions?.postcssPlugin
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
function resolveTailwindV3SourceFromPatcher(patcher) {
|
|
273
|
+
return resolveTailwindV3Source(resolveTailwindV3SourceOptionsFromPatcher(patcher));
|
|
274
|
+
}
|
|
275
|
+
//#endregion
|
|
276
|
+
//#region src/tailwindcss/v4-engine/miniprogram.ts
|
|
277
|
+
const defaultStyleHandler = createStyleHandler({
|
|
278
|
+
cssChildCombinatorReplaceValue: ["view", "text"],
|
|
279
|
+
cssRemoveHoverPseudoClass: true,
|
|
280
|
+
isMainChunk: true,
|
|
281
|
+
majorVersion: 4
|
|
282
|
+
});
|
|
283
|
+
async function transformTailwindV4CssToWeapp(css, options) {
|
|
284
|
+
return pruneMiniProgramGeneratedCss((await defaultStyleHandler(css, {
|
|
285
|
+
cssChildCombinatorReplaceValue: ["view", "text"],
|
|
286
|
+
cssRemoveHoverPseudoClass: true,
|
|
287
|
+
isMainChunk: true,
|
|
288
|
+
majorVersion: 4,
|
|
289
|
+
...options
|
|
290
|
+
})).css);
|
|
291
|
+
}
|
|
292
|
+
async function transformTailwindV4CssByTarget(css, target, options) {
|
|
293
|
+
return target === "weapp" ? transformTailwindV4CssToWeapp(css, options) : css;
|
|
294
|
+
}
|
|
295
|
+
//#endregion
|
|
296
|
+
//#region src/tailwindcss/v4-engine/generator.ts
|
|
297
|
+
function createTailwindV4Engine$1(source) {
|
|
298
|
+
const engine = createTailwindV4Engine(source);
|
|
299
|
+
async function generate(options = {}) {
|
|
300
|
+
const { styleOptions, target = "weapp", ...patchOptions } = options;
|
|
301
|
+
const result = await engine.generate({
|
|
302
|
+
scanSources: true,
|
|
303
|
+
...patchOptions
|
|
304
|
+
});
|
|
305
|
+
const rawCss = result.css;
|
|
306
|
+
const css = await transformTailwindV4CssByTarget(rawCss, target, styleOptions);
|
|
307
|
+
return {
|
|
308
|
+
...result,
|
|
309
|
+
css,
|
|
310
|
+
rawCss,
|
|
311
|
+
target
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
return {
|
|
315
|
+
source,
|
|
316
|
+
loadDesignSystem: engine.loadDesignSystem,
|
|
317
|
+
validateCandidates: engine.validateCandidates,
|
|
318
|
+
generate
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
//#endregion
|
|
322
|
+
//#region src/tailwindcss/v4-engine/source.ts
|
|
323
|
+
function isPostcssPluginImportTarget(value) {
|
|
324
|
+
if (!value) return false;
|
|
325
|
+
return value === "@tailwindcss/postcss" || value === "@tailwindcss/postcss7-compat" || value.includes("/postcss");
|
|
326
|
+
}
|
|
327
|
+
function uniqueDefined(values) {
|
|
328
|
+
return [...new Set(values.filter((value) => typeof value === "string" && value.length > 0))];
|
|
329
|
+
}
|
|
330
|
+
function getProjectRoot(patcher) {
|
|
331
|
+
return patcher.options?.projectRoot ?? process.cwd();
|
|
332
|
+
}
|
|
333
|
+
function readConfiguredV4Base(tailwindOptions) {
|
|
334
|
+
const v4 = tailwindOptions?.v4;
|
|
335
|
+
if (typeof v4 !== "object" || v4 === null) return;
|
|
336
|
+
return v4.configuredBase;
|
|
337
|
+
}
|
|
338
|
+
function resolveTailwindCssImportTarget(patcher) {
|
|
339
|
+
const configuredPackageName = resolveTailwindcssOptions(patcher.options)?.packageName;
|
|
340
|
+
if (typeof configuredPackageName === "string" && configuredPackageName.length > 0 && !isPostcssPluginImportTarget(configuredPackageName)) return configuredPackageName;
|
|
341
|
+
const packageName = patcher.packageInfo?.name;
|
|
342
|
+
if (typeof packageName === "string" && packageName.length > 0 && !isPostcssPluginImportTarget(packageName)) return packageName;
|
|
343
|
+
return "tailwindcss";
|
|
344
|
+
}
|
|
345
|
+
function resolveTailwindV4SourceOptionsFromPatcher(patcher) {
|
|
346
|
+
const projectRoot = getProjectRoot(patcher);
|
|
347
|
+
const tailwindOptions = resolveTailwindcssOptions(patcher.options);
|
|
348
|
+
const configDir = tailwindOptions?.config ? path.dirname(tailwindOptions.config) : void 0;
|
|
349
|
+
const configuredBase = readConfiguredV4Base(tailwindOptions);
|
|
350
|
+
const hasCssEntries = Boolean(tailwindOptions?.v4?.cssEntries?.length);
|
|
351
|
+
return {
|
|
352
|
+
projectRoot,
|
|
353
|
+
base: configuredBase ?? (hasCssEntries ? void 0 : tailwindOptions?.v4?.base),
|
|
354
|
+
baseFallbacks: uniqueDefined([tailwindOptions?.cwd, configDir]),
|
|
355
|
+
css: tailwindOptions?.v4?.css,
|
|
356
|
+
cssEntries: tailwindOptions?.v4?.cssEntries,
|
|
357
|
+
sources: tailwindOptions?.v4?.sources,
|
|
358
|
+
packageName: resolveTailwindCssImportTarget(patcher)
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
function resolveTailwindV4Source$1(options) {
|
|
362
|
+
return resolveTailwindV4Source(options);
|
|
363
|
+
}
|
|
364
|
+
async function resolveTailwindV4SourceFromPatcher(patcher) {
|
|
365
|
+
return resolveTailwindV4Source(resolveTailwindV4SourceOptionsFromPatcher(patcher));
|
|
366
|
+
}
|
|
367
|
+
//#endregion
|
|
368
|
+
//#region src/generator/options.ts
|
|
369
|
+
function normalizeWeappTailwindcssGeneratorOptions(options) {
|
|
370
|
+
if (options === false) return {
|
|
371
|
+
mode: "off",
|
|
372
|
+
target: "weapp"
|
|
373
|
+
};
|
|
374
|
+
if (options === true || options == null) return {
|
|
375
|
+
mode: "auto",
|
|
376
|
+
target: "weapp"
|
|
377
|
+
};
|
|
378
|
+
return {
|
|
379
|
+
mode: options.mode ?? "auto",
|
|
380
|
+
target: options.target ?? "weapp",
|
|
381
|
+
styleOptions: options.styleOptions
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
//#endregion
|
|
385
|
+
//#region src/generator/index.ts
|
|
386
|
+
function isTailwindV3Source(source) {
|
|
387
|
+
return "version" in source && source.version === 3;
|
|
388
|
+
}
|
|
389
|
+
function createWeappTailwindcssGenerator(source) {
|
|
390
|
+
return isTailwindV3Source(source) ? createTailwindV3Engine(source) : createTailwindV4Engine$1(source);
|
|
391
|
+
}
|
|
392
|
+
async function resolveTailwindSourceFromPatcher(patcher) {
|
|
393
|
+
return patcher.majorVersion === 3 ? resolveTailwindV3SourceFromPatcher(patcher) : resolveTailwindV4SourceFromPatcher(patcher);
|
|
394
|
+
}
|
|
395
|
+
async function createWeappTailwindcssGeneratorFromPatcher(patcher) {
|
|
396
|
+
return createWeappTailwindcssGenerator(await resolveTailwindSourceFromPatcher(patcher));
|
|
397
|
+
}
|
|
398
|
+
//#endregion
|
|
399
|
+
export { removeUnsupportedCascadeLayers as _, resolveTailwindV4Source$1 as a, resolveTailwindV4SourceOptionsFromPatcher as c, loadTailwindV4DesignSystem as d, resolveTailwindV3Source as f, transformTailwindV3CssToWeapp as g, transformTailwindV3CssByTarget as h, normalizeWeappTailwindcssGeneratorOptions as i, transformTailwindV4CssByTarget as l, resolveTailwindV3SourceOptionsFromPatcher as m, createWeappTailwindcssGeneratorFromPatcher as n, resolveTailwindV4SourceFromPatchOptions as o, resolveTailwindV3SourceFromPatcher as p, resolveTailwindSourceFromPatcher as r, resolveTailwindV4SourceFromPatcher as s, createWeappTailwindcssGenerator as t, transformTailwindV4CssToWeapp as u };
|