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.
- package/README.md +6 -7
- package/bin/weapp-tailwindcss.js +1 -21
- package/dist/auto-TH1jG2UW.js +115 -0
- package/dist/auto-XyKTOP7B.mjs +78 -0
- package/dist/bundle-state-Bi-cQua6.mjs +413 -0
- package/dist/bundle-state-Ct_8GcSR.js +529 -0
- package/dist/bundlers/shared/cache.d.ts +6 -6
- package/dist/bundlers/shared/css-cleanup/at-rules.d.ts +1 -0
- package/dist/bundlers/shared/css-cleanup.d.ts +1 -4
- package/dist/bundlers/shared/css-imports.d.ts +3 -3
- package/dist/bundlers/shared/generated-css-marker.d.ts +3 -0
- package/dist/bundlers/shared/generator-css/config-directive.d.ts +2 -0
- package/dist/bundlers/shared/generator-css/directives.d.ts +21 -0
- package/dist/bundlers/shared/generator-css/legacy-compat.d.ts +7 -0
- package/dist/bundlers/shared/generator-css/legacy-selectors.d.ts +5 -0
- package/dist/bundlers/shared/generator-css/legacy-units.d.ts +1 -0
- package/dist/bundlers/shared/generator-css/markers.d.ts +28 -0
- package/dist/bundlers/shared/generator-css/source-files.d.ts +14 -0
- package/dist/bundlers/shared/generator-css/source-resolver.d.ts +24 -0
- package/dist/bundlers/shared/generator-css/user-layer-order.d.ts +10 -0
- package/dist/bundlers/shared/generator-css.d.ts +16 -22
- package/dist/bundlers/shared/hmr-timing.d.ts +22 -0
- package/dist/bundlers/shared/style-requests.d.ts +2 -0
- package/dist/bundlers/vite/bundle-state.d.ts +1 -0
- package/dist/bundlers/vite/css-finalizer.d.ts +7 -1
- package/dist/bundlers/vite/generate-bundle/candidates.d.ts +2 -0
- package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +24 -0
- package/dist/bundlers/vite/generate-bundle/css-share-scope.d.ts +4 -0
- package/dist/bundlers/vite/generate-bundle/dirty-state.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/js-entries.d.ts +2 -0
- package/dist/bundlers/vite/generate-bundle/js-handler-options.d.ts +8 -0
- package/dist/bundlers/vite/generate-bundle/js-linking.d.ts +13 -0
- package/dist/bundlers/vite/generate-bundle/metrics.d.ts +17 -0
- package/dist/bundlers/vite/generate-bundle/process-plan.d.ts +9 -0
- package/dist/bundlers/vite/generate-bundle/rollup-assets.d.ts +7 -0
- package/dist/bundlers/vite/generate-bundle/signatures.d.ts +8 -0
- package/dist/bundlers/vite/generate-bundle.d.ts +14 -2
- package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +5 -1
- package/dist/bundlers/vite/index.d.ts +5 -2
- package/dist/bundlers/vite/official-tailwind-plugins.d.ts +5 -0
- package/dist/bundlers/vite/postcss-config.d.ts +6 -0
- package/dist/bundlers/vite/processed-css-assets.d.ts +32 -0
- package/dist/bundlers/vite/rewrite-css-imports.d.ts +8 -3
- package/dist/bundlers/vite/runtime-class-set.d.ts +25 -0
- package/dist/bundlers/vite/serve-css-generation.d.ts +11 -0
- package/dist/bundlers/vite/source-candidates.d.ts +19 -1
- package/dist/bundlers/vite/source-scan.d.ts +26 -0
- package/dist/bundlers/vite/static-config-content.d.ts +5 -0
- package/dist/bundlers/vite/tailwind-basedir.d.ts +1 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +6 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +6 -2
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +9 -3
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +2 -1
- package/dist/bundlers/webpack/loaders/runtime-registry.d.ts +31 -0
- package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +2 -6
- package/dist/bundlers/webpack/loaders/weapp-tw-runtime-classset-loader.d.ts +3 -7
- package/dist/cache/index.d.ts +6 -6
- package/dist/{chunk-8l464Juk.js → chunk-C5U5_Hdc.js} +14 -0
- package/dist/cli/context.d.ts +1 -14
- package/dist/cli/doctor/types.d.ts +11 -11
- package/dist/cli/helpers.d.ts +1 -2
- package/dist/cli/mount-options.d.ts +2 -0
- package/dist/cli/types.d.ts +0 -2
- package/dist/cli/vscode-entry.d.ts +3 -3
- package/dist/cli.js +758 -604
- package/dist/cli.mjs +766 -612
- package/dist/constants.d.ts +1 -2
- package/dist/context/runtime-package-replacements.d.ts +2 -0
- package/dist/context/style-options.d.ts +3 -0
- package/dist/core.js +12 -20
- package/dist/core.mjs +8 -14
- package/dist/css-macro/auto.d.ts +10 -0
- package/dist/css-macro/constants.d.ts +5 -2
- package/dist/css-macro/postcss.d.ts +1 -0
- package/dist/css-macro/postcss.js +7 -46
- package/dist/css-macro/postcss.mjs +2 -46
- package/dist/css-macro.d.ts +1 -0
- package/dist/css-macro.js +16 -7
- package/dist/css-macro.mjs +15 -6
- package/dist/defaults-8xrgzxFY.mjs +151 -0
- package/dist/defaults-zKUH2mDe.js +193 -0
- package/dist/defaults.d.ts +15 -1
- package/dist/defaults.js +6 -131
- package/dist/defaults.mjs +2 -129
- package/dist/escape.js +10 -2
- package/dist/escape.mjs +10 -2
- package/dist/generator/index.d.ts +1 -1
- package/dist/generator/options.d.ts +9 -8
- package/dist/generator/types.d.ts +3 -3
- package/dist/generator-CrU-Ghc1.js +90 -0
- package/dist/generator-Qw-tZ0Z2.mjs +65 -0
- package/dist/generator.js +12 -12
- package/dist/generator.mjs +2 -1
- package/dist/gulp.js +187 -48
- package/dist/gulp.mjs +180 -41
- package/dist/incremental-runtime-class-set-Boqi1QlB.mjs +2224 -0
- package/dist/incremental-runtime-class-set-FAOHZmzh.js +2293 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +19 -7
- package/dist/index.mjs +6 -5
- package/dist/js/babel/cache-options.d.ts +3 -0
- package/dist/js/babel/parse.d.ts +7 -4
- package/dist/js/index.d.ts +1 -0
- package/dist/js/literal-transform.d.ts +2 -0
- package/dist/js/precheck.d.ts +2 -2
- package/dist/logger-BNzxZbZj.mjs +2 -0
- package/dist/logger-TlKT3xmR.js +1 -0
- package/dist/postcss/config-directive.d.ts +1 -0
- package/dist/postcss/context.d.ts +9 -0
- package/dist/postcss/source-files.d.ts +8 -0
- package/dist/postcss/tailwind-version.d.ts +3 -0
- package/dist/postcss-C6zOQqlL.mjs +228 -0
- package/dist/postcss-C7BMYpEF.mjs +169 -0
- package/dist/postcss-CiYLsqZn.js +192 -0
- package/dist/postcss-DAWf9D3C.js +237 -0
- package/dist/postcss-html-transform.js +1 -1
- package/dist/postcss.d.ts +2 -2
- package/dist/postcss.js +3 -276
- package/dist/postcss.mjs +1 -269
- package/dist/precheck-D7K12zeX.mjs +4716 -0
- package/dist/precheck-D7gJSmJz.js +4842 -0
- package/dist/presets/index.d.ts +1 -0
- package/dist/presets/uni-app-x.d.ts +1 -0
- package/dist/presets.js +29 -13
- package/dist/presets.mjs +25 -11
- package/dist/reset.d.ts +1 -0
- package/dist/reset.js +1 -1
- package/dist/runtime-registry-DpcR3IHI.js +5496 -0
- package/dist/shared/mpx.d.ts +1 -0
- package/dist/source-candidates-CX2ozpKM.mjs +322 -0
- package/dist/source-candidates-DNM8iwXW.js +335 -0
- package/dist/tailwindcss/miniprogram.d.ts +1 -1
- package/dist/tailwindcss/patcher-options.d.ts +3 -51
- package/dist/tailwindcss/patcher.d.ts +1 -2
- package/dist/tailwindcss/remove-unsupported-css.d.ts +1 -2
- package/dist/tailwindcss/runtime/cache.d.ts +4 -3
- package/dist/tailwindcss/runtime-patch.d.ts +5 -0
- package/dist/tailwindcss/runtime.d.ts +11 -12
- package/dist/tailwindcss/source-scan.d.ts +35 -0
- package/dist/tailwindcss/targets.d.ts +1 -5
- package/dist/tailwindcss/v3-engine/types.d.ts +17 -14
- package/dist/tailwindcss/v4/css-entries.d.ts +2 -2
- package/dist/tailwindcss/v4/css-sources.d.ts +5 -0
- package/dist/tailwindcss/v4/patcher-options.d.ts +1 -23
- package/dist/tailwindcss/v4/patcher.d.ts +1 -0
- package/dist/tailwindcss/v4-engine/source.d.ts +2 -2
- package/dist/tailwindcss/v4-engine/types.d.ts +17 -5
- package/dist/tailwindcss/version.d.ts +4 -0
- package/dist/tailwindcss-B-e2RiXr.js +642 -0
- package/dist/tailwindcss-C7dJHZ0G.mjs +591 -0
- package/dist/typedoc.export.d.ts +0 -2
- package/dist/types/index.d.ts +52 -49
- package/dist/types/shared.d.ts +6 -0
- package/dist/types/user-defined-options/general.d.ts +25 -24
- package/dist/types/user-defined-options/important.d.ts +33 -28
- package/dist/types/user-defined-options/lifecycle.d.ts +4 -4
- package/dist/types/user-defined-options/matcher.d.ts +6 -6
- package/dist/uni-app-x/vite.d.ts +1 -1
- package/dist/unocss/index.d.ts +2 -0
- package/dist/utils/disabled.d.ts +2 -3
- package/dist/utils/object.d.ts +9 -0
- package/dist/utils/options.d.ts +2 -0
- package/dist/utils/regex.d.ts +1 -0
- package/dist/{utils-DmC9_In3.js → utils-D7Ygohep.js} +2 -2
- package/dist/{utils-7DUGTFED.mjs → utils-DsaS975I.mjs} +1 -1
- package/dist/v3-engine-CHItlVq5.js +3616 -0
- package/dist/v3-engine-DcvCCHfs.mjs +3321 -0
- package/dist/vite-BgTPSkQS.js +24446 -0
- package/dist/vite-fFRpSvyz.mjs +24432 -0
- package/dist/vite.d.ts +1 -2
- package/dist/vite.js +3 -4
- package/dist/vite.mjs +2 -2
- package/dist/weapp-tw-css-import-rewrite-loader.js +5227 -18
- package/dist/weapp-tw-runtime-classset-loader.js +32 -9
- package/dist/webpack-BXSWVdXh.js +851 -0
- package/dist/webpack-Dx2AZpGU.mjs +841 -0
- package/dist/webpack.d.ts +1 -3
- package/dist/webpack.js +3 -4
- package/dist/webpack.mjs +2 -2
- package/package.json +38 -48
- package/dist/bundlers/shared/generator-candidates.d.ts +0 -5
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-assets.d.ts +0 -14
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-loaders.d.ts +0 -15
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v4.d.ts +0 -9
- package/dist/bundlers/webpack/shared/css-imports.d.ts +0 -6
- package/dist/cli/config.d.ts +0 -5
- package/dist/cli/helpers/patch-cwd.d.ts +0 -1
- package/dist/cli/mount-options/patch-status.d.ts +0 -2
- package/dist/cli/patch-options.d.ts +0 -6
- package/dist/cli/tokens.d.ts +0 -4
- package/dist/cli/workspace/package-dirs.d.ts +0 -3
- package/dist/cli/workspace/patch-package.d.ts +0 -3
- package/dist/cli/workspace/patch-utils.d.ts +0 -3
- package/dist/cli/workspace/types.d.ts +0 -11
- package/dist/cli/workspace/workspace-globs.d.ts +0 -2
- package/dist/cli/workspace/workspace-io.d.ts +0 -1
- package/dist/cli/workspace/workspace-lock.d.ts +0 -1
- package/dist/cli/workspace.d.ts +0 -2
- package/dist/constants-B-_T5UnW.mjs +0 -44
- package/dist/constants-p1dyh1x1.js +0 -73
- package/dist/css-imports-BbrbluP9.js +0 -177
- package/dist/css-imports-CSdPq_Sc.mjs +0 -128
- package/dist/experimental/index.d.ts +0 -2
- package/dist/experimental/oxc/ast-utils.d.ts +0 -30
- package/dist/experimental/oxc/index.d.ts +0 -2
- package/dist/experimental/oxc/module-specifiers.d.ts +0 -2
- package/dist/experimental/shared/cache.d.ts +0 -3
- package/dist/experimental/shared/transform.d.ts +0 -3
- package/dist/experimental/shared.d.ts +0 -8
- package/dist/experimental/swc/ast-utils.d.ts +0 -30
- package/dist/experimental/swc/index.d.ts +0 -2
- package/dist/experimental/swc/module-specifiers.d.ts +0 -2
- package/dist/generator-Y-Ikv4Fu.mjs +0 -1177
- package/dist/generator-css-Bwy_Uz89.mjs +0 -1097
- package/dist/generator-css-CRLrHW4F.js +0 -1124
- package/dist/generator-mmhXzZnv.js +0 -1276
- package/dist/js/syntax.d.ts +0 -10
- package/dist/lightningcss/index.d.ts +0 -8
- package/dist/lightningcss/style-handler/options.d.ts +0 -3
- package/dist/lightningcss/style-handler/selector-transform.d.ts +0 -10
- package/dist/lightningcss/style-handler/selector-utils.d.ts +0 -10
- package/dist/lightningcss/style-handler.d.ts +0 -17
- package/dist/loader-anchors-1MumTAtA.mjs +0 -205
- package/dist/loader-anchors-TrFvT6g1.js +0 -273
- package/dist/logger-BZ45DZJT.js +0 -1003
- package/dist/logger-BoVx1Dbt.mjs +0 -935
- package/dist/patcher-options-6gJN2EXy.js +0 -115
- package/dist/patcher-options-DQfR5xxT.mjs +0 -92
- package/dist/recorder-GdTJ3QqX.js +0 -2878
- package/dist/recorder-XdFvVASS.mjs +0 -2763
- package/dist/tailwindcss/recorder.d.ts +0 -13
- package/dist/tailwindcss/targets/paths.d.ts +0 -13
- package/dist/tailwindcss/targets/record-io.d.ts +0 -5
- package/dist/tailwindcss/targets/recorder.d.ts +0 -3
- package/dist/tailwindcss/targets/types.d.ts +0 -35
- package/dist/types/disabled-options.d.ts +0 -4
- package/dist/vite-BDywuCjn.mjs +0 -2186
- package/dist/vite-DgRh_GXn.js +0 -2199
- package/dist/webpack-CAJR4hhP.js +0 -456
- package/dist/webpack-CiHqVZTg.mjs +0 -441
- package/dist/webpack4.d.ts +0 -4
- package/dist/webpack4.js +0 -387
- package/dist/webpack4.mjs +0 -379
- package/scripts/postinstall.mjs +0 -59
|
@@ -0,0 +1,192 @@
|
|
|
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
|
+
Object.defineProperty(exports, "CSS_MACRO_POSTCSS_PLUGIN_NAME", {
|
|
170
|
+
enumerable: true,
|
|
171
|
+
get: function() {
|
|
172
|
+
return CSS_MACRO_POSTCSS_PLUGIN_NAME;
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
Object.defineProperty(exports, "createConditionalAtRule", {
|
|
176
|
+
enumerable: true,
|
|
177
|
+
get: function() {
|
|
178
|
+
return createConditionalAtRule;
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
Object.defineProperty(exports, "createNegativeConditionalAtRule", {
|
|
182
|
+
enumerable: true,
|
|
183
|
+
get: function() {
|
|
184
|
+
return createNegativeConditionalAtRule;
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
Object.defineProperty(exports, "creator", {
|
|
188
|
+
enumerable: true,
|
|
189
|
+
get: function() {
|
|
190
|
+
return creator;
|
|
191
|
+
}
|
|
192
|
+
});
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
const require_chunk = require("./chunk-C5U5_Hdc.js");
|
|
2
|
+
const require_v3_engine = require("./v3-engine-CHItlVq5.js");
|
|
3
|
+
const require_generator = require("./generator-CrU-Ghc1.js");
|
|
4
|
+
let postcss = require("postcss");
|
|
5
|
+
postcss = require_chunk.__toESM(postcss);
|
|
6
|
+
let node_path = require("node:path");
|
|
7
|
+
node_path = require_chunk.__toESM(node_path);
|
|
8
|
+
let node_process = require("node:process");
|
|
9
|
+
node_process = require_chunk.__toESM(node_process);
|
|
10
|
+
let tailwindcss_patch = require("tailwindcss-patch");
|
|
11
|
+
let node_fs_promises = require("node:fs/promises");
|
|
12
|
+
let tailwindcss_config = require("tailwindcss-config");
|
|
13
|
+
//#region src/postcss/config-directive.ts
|
|
14
|
+
function quoteCssString(value) {
|
|
15
|
+
return value.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"");
|
|
16
|
+
}
|
|
17
|
+
function toCssPath(value) {
|
|
18
|
+
return value.replaceAll("\\", "/");
|
|
19
|
+
}
|
|
20
|
+
function prependConfigDirective(css, config) {
|
|
21
|
+
if (!config || /@config\s+/.test(css)) return css;
|
|
22
|
+
return `@config "${quoteCssString(toCssPath(config))}";\n${css}`;
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/postcss/context.ts
|
|
26
|
+
const PLUGIN_NAME$1 = "weapp-tailwindcss";
|
|
27
|
+
function resolveInputFile(result) {
|
|
28
|
+
const from = result.opts.from;
|
|
29
|
+
if (typeof from !== "string" || from.length === 0) return;
|
|
30
|
+
return node_path.default.isAbsolute(from) ? from : node_path.default.resolve(node_process.default.cwd(), from);
|
|
31
|
+
}
|
|
32
|
+
function resolvePostcssBase(result, options) {
|
|
33
|
+
if (options.base) return options.base;
|
|
34
|
+
const inputFile = resolveInputFile(result);
|
|
35
|
+
return inputFile ? node_path.default.dirname(inputFile) : node_process.default.cwd();
|
|
36
|
+
}
|
|
37
|
+
function resolvePostcssProjectRoot(result, options) {
|
|
38
|
+
if (options.projectRoot) return options.projectRoot;
|
|
39
|
+
const inputFile = resolveInputFile(result);
|
|
40
|
+
return inputFile ? node_path.default.dirname(inputFile) : node_process.default.cwd();
|
|
41
|
+
}
|
|
42
|
+
function replaceRootCss(root, css, result) {
|
|
43
|
+
root.removeAll();
|
|
44
|
+
try {
|
|
45
|
+
const nextRoot = postcss.default.parse(css, { from: resolveInputFile(result) });
|
|
46
|
+
root.append(nextRoot.nodes);
|
|
47
|
+
} catch {
|
|
48
|
+
root.raws = { after: css };
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function addDependencyMessages(result, generated) {
|
|
52
|
+
for (const file of generated.dependencies) result.messages.push({
|
|
53
|
+
type: "dependency",
|
|
54
|
+
plugin: PLUGIN_NAME$1,
|
|
55
|
+
file
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
function addSourceDependencyMessages(result, files) {
|
|
59
|
+
for (const file of files) result.messages.push({
|
|
60
|
+
type: "dependency",
|
|
61
|
+
plugin: PLUGIN_NAME$1,
|
|
62
|
+
file
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/postcss/source-files.ts
|
|
67
|
+
const POSTCSS_SOURCE_PATTERN = require_v3_engine.createSourceScanPattern(require_v3_engine.DEFAULT_SOURCE_SCAN_EXTENSIONS);
|
|
68
|
+
function getSourceExtension(file) {
|
|
69
|
+
return node_path.default.extname(file).slice(1) || void 0;
|
|
70
|
+
}
|
|
71
|
+
function collectConfigPaths(root, base) {
|
|
72
|
+
const configPaths = [];
|
|
73
|
+
root.walkAtRules("config", (rule) => {
|
|
74
|
+
const configPath = require_v3_engine.parseConfigParam(rule.params);
|
|
75
|
+
if (configPath) configPaths.push(node_path.default.isAbsolute(configPath) ? configPath : node_path.default.resolve(base, configPath));
|
|
76
|
+
});
|
|
77
|
+
return [...new Set(configPaths)];
|
|
78
|
+
}
|
|
79
|
+
function resolveOptionConfigPath(config, base) {
|
|
80
|
+
if (!config) return;
|
|
81
|
+
return node_path.default.isAbsolute(config) ? config : node_path.default.resolve(base, config);
|
|
82
|
+
}
|
|
83
|
+
async function collectConfigContentFiles(root, base, options) {
|
|
84
|
+
const configPaths = [...new Set([...resolveOptionConfigPath(options.config, base) ? [resolveOptionConfigPath(options.config, base)] : [], ...collectConfigPaths(root, base)])];
|
|
85
|
+
const files = [];
|
|
86
|
+
for (const configPath of configPaths) {
|
|
87
|
+
const contentEntries = require_v3_engine.normalizeLegacyContentEntries((await (0, tailwindcss_config.loadConfig)({
|
|
88
|
+
config: configPath,
|
|
89
|
+
cwd: node_path.default.dirname(configPath)
|
|
90
|
+
}))?.config.content, node_path.default.dirname(configPath));
|
|
91
|
+
files.push(...await require_v3_engine.expandTailwindSourceEntries(contentEntries));
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
configPaths,
|
|
95
|
+
files: [...new Set(files)]
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
async function collectConfiguredContentEntries(root, base, options) {
|
|
99
|
+
const configPath = resolveOptionConfigPath(options.generator?.config ?? options.config, base) ?? collectConfigPaths(root, base)[0];
|
|
100
|
+
if (!configPath) return [];
|
|
101
|
+
const resolvedConfigPath = node_path.default.isAbsolute(configPath) ? configPath : node_path.default.resolve(base, configPath);
|
|
102
|
+
return require_v3_engine.normalizeLegacyContentEntries((await (0, tailwindcss_config.loadConfig)({
|
|
103
|
+
config: resolvedConfigPath,
|
|
104
|
+
cwd: node_path.default.dirname(resolvedConfigPath)
|
|
105
|
+
}))?.config.content, node_path.default.dirname(resolvedConfigPath));
|
|
106
|
+
}
|
|
107
|
+
async function collectRawCandidatesFromSourceEntries(sourceEntries) {
|
|
108
|
+
const candidates = /* @__PURE__ */ new Set();
|
|
109
|
+
const files = await require_v3_engine.expandTailwindSourceEntries(sourceEntries);
|
|
110
|
+
await Promise.all(files.map(async (file) => {
|
|
111
|
+
const matches = await (0, tailwindcss_patch.extractRawCandidatesWithPositions)(await (0, node_fs_promises.readFile)(file, "utf8"), getSourceExtension(file));
|
|
112
|
+
for (const match of matches) {
|
|
113
|
+
const candidate = match?.rawCandidate;
|
|
114
|
+
if (typeof candidate === "string" && candidate.length > 0) candidates.add(candidate);
|
|
115
|
+
}
|
|
116
|
+
}));
|
|
117
|
+
return candidates;
|
|
118
|
+
}
|
|
119
|
+
async function collectAutoTailwindCandidates(root, result, options) {
|
|
120
|
+
if (options.scanSources === false) return /* @__PURE__ */ new Set();
|
|
121
|
+
const base = resolvePostcssBase(result, options);
|
|
122
|
+
const projectRoot = resolvePostcssProjectRoot(result, options);
|
|
123
|
+
const sourceEntries = [];
|
|
124
|
+
const hasSourceNone = root.toString().includes("source(none)");
|
|
125
|
+
const inlineCandidates = require_v3_engine.collectCssInlineSourceCandidates(root);
|
|
126
|
+
const configuredContentEntries = options.version === 3 ? await collectConfiguredContentEntries(root, base, options) : [];
|
|
127
|
+
if (configuredContentEntries.length > 0) sourceEntries.push(...configuredContentEntries);
|
|
128
|
+
else if (!hasSourceNone) sourceEntries.push({
|
|
129
|
+
base,
|
|
130
|
+
negated: false,
|
|
131
|
+
pattern: POSTCSS_SOURCE_PATTERN
|
|
132
|
+
});
|
|
133
|
+
sourceEntries.push(...await require_v3_engine.resolveCssSourceEntries(root, base, POSTCSS_SOURCE_PATTERN));
|
|
134
|
+
const candidates = sourceEntries.length === 0 ? [] : options.version === 3 ? await collectRawCandidatesFromSourceEntries(sourceEntries) : await (0, tailwindcss_patch.extractValidCandidates)({
|
|
135
|
+
base,
|
|
136
|
+
css: root.toString(),
|
|
137
|
+
cwd: projectRoot,
|
|
138
|
+
sources: sourceEntries
|
|
139
|
+
});
|
|
140
|
+
return new Set([...[...candidates].filter((candidate) => !inlineCandidates.excluded.has(candidate)), ...inlineCandidates.included]);
|
|
141
|
+
}
|
|
142
|
+
async function collectPostcssLocalSources(root, result, options) {
|
|
143
|
+
const base = resolvePostcssBase(result, options);
|
|
144
|
+
const sourceEntries = await require_v3_engine.resolveCssSourceEntries(root, base, POSTCSS_SOURCE_PATTERN);
|
|
145
|
+
const configContentFiles = await collectConfigContentFiles(root, base, options);
|
|
146
|
+
const files = [...new Set([...await require_v3_engine.expandTailwindSourceEntries(sourceEntries), ...configContentFiles.files])];
|
|
147
|
+
const sources = await Promise.all(files.map(async (file) => {
|
|
148
|
+
const extension = getSourceExtension(file);
|
|
149
|
+
return {
|
|
150
|
+
content: await (0, node_fs_promises.readFile)(file, "utf8"),
|
|
151
|
+
...extension === void 0 ? {} : { extension }
|
|
152
|
+
};
|
|
153
|
+
}));
|
|
154
|
+
return {
|
|
155
|
+
files: [...files, ...configContentFiles.configPaths],
|
|
156
|
+
sources
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
//#endregion
|
|
160
|
+
//#region src/postcss/tailwind-version.ts
|
|
161
|
+
function hasTailwindV4CssSyntax(root) {
|
|
162
|
+
let hasV4Syntax = false;
|
|
163
|
+
root.walkAtRules((rule) => {
|
|
164
|
+
if (rule.name === "theme" || rule.name === "source" || rule.name === "custom-variant") hasV4Syntax = true;
|
|
165
|
+
if (rule.name === "import" && /(['"])tailwindcss\1/.test(rule.params)) hasV4Syntax = true;
|
|
166
|
+
});
|
|
167
|
+
return hasV4Syntax;
|
|
168
|
+
}
|
|
169
|
+
function resolvePostcssTailwindVersion(root, result, options) {
|
|
170
|
+
const packageName = options.packageName ?? "tailwindcss";
|
|
171
|
+
const installedVersion = require_v3_engine.readInstalledPackageMajorVersion(packageName, resolvePostcssProjectRoot(result, options));
|
|
172
|
+
if (installedVersion) return installedVersion;
|
|
173
|
+
if (options.version) return options.version;
|
|
174
|
+
if (packageName === "@tailwindcss/postcss" || packageName.includes("tailwindcss4")) return 4;
|
|
175
|
+
if (packageName.includes("tailwindcss3")) return 3;
|
|
176
|
+
if (hasTailwindV4CssSyntax(root)) return 4;
|
|
177
|
+
return 4;
|
|
178
|
+
}
|
|
179
|
+
//#endregion
|
|
180
|
+
//#region src/postcss.ts
|
|
181
|
+
const PLUGIN_NAME = "weapp-tailwindcss";
|
|
182
|
+
const weappTailwindcssPostcssPlugin = (options = {}) => {
|
|
183
|
+
return {
|
|
184
|
+
postcssPlugin: PLUGIN_NAME,
|
|
185
|
+
async Once(root, { result }) {
|
|
186
|
+
const { candidates, generator: userGeneratorOptions, scanSources, sources, styleOptions, ...sourceOptions } = options;
|
|
187
|
+
const generatorOptions = require_generator.normalizeWeappTailwindcssGeneratorOptions(userGeneratorOptions);
|
|
188
|
+
const tailwindVersion = resolvePostcssTailwindVersion(root, result, options);
|
|
189
|
+
const [collectedSources, autoCandidates] = await Promise.all([collectPostcssLocalSources(root, result, options), collectAutoTailwindCandidates(root, result, options)]);
|
|
190
|
+
const generatorConfig = generatorOptions.config ?? options.config;
|
|
191
|
+
const generator = require_generator.createWeappTailwindcssGenerator(tailwindVersion === 3 ? await require_v3_engine.resolveTailwindV3Source({
|
|
192
|
+
config: generatorConfig,
|
|
193
|
+
css: sourceOptions.css ?? root.toString(),
|
|
194
|
+
base: resolvePostcssBase(result, options),
|
|
195
|
+
cwd: resolvePostcssProjectRoot(result, options),
|
|
196
|
+
projectRoot: resolvePostcssProjectRoot(result, options),
|
|
197
|
+
packageName: options.packageName,
|
|
198
|
+
postcssPlugin: options.postcssPlugin
|
|
199
|
+
}) : await require_v3_engine.resolveTailwindV4Source({
|
|
200
|
+
...sourceOptions,
|
|
201
|
+
css: prependConfigDirective(sourceOptions.css ?? root.toString(), generatorConfig),
|
|
202
|
+
base: resolvePostcssBase(result, options),
|
|
203
|
+
projectRoot: resolvePostcssProjectRoot(result, options)
|
|
204
|
+
}));
|
|
205
|
+
const generateOptions = {
|
|
206
|
+
candidates: new Set([...autoCandidates, ...candidates ?? []]),
|
|
207
|
+
scanSources: scanSources ?? false,
|
|
208
|
+
sources: [...collectedSources.sources, ...sources ?? []],
|
|
209
|
+
styleOptions: {
|
|
210
|
+
...generatorOptions.styleOptions,
|
|
211
|
+
...styleOptions
|
|
212
|
+
},
|
|
213
|
+
tailwindcssV3Compatibility: generatorOptions.tailwindcssV3Compatibility,
|
|
214
|
+
target: generatorOptions.target
|
|
215
|
+
};
|
|
216
|
+
const generated = await generator.generate(generateOptions);
|
|
217
|
+
replaceRootCss(root, generated.css, result);
|
|
218
|
+
addDependencyMessages(result, generated);
|
|
219
|
+
addSourceDependencyMessages(result, collectedSources.files);
|
|
220
|
+
result.messages.push({
|
|
221
|
+
type: "weapp-tailwindcss:generated",
|
|
222
|
+
plugin: PLUGIN_NAME,
|
|
223
|
+
target: generated.target,
|
|
224
|
+
classSet: generated.classSet,
|
|
225
|
+
rawCss: generated.rawCss
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
};
|
|
230
|
+
weappTailwindcssPostcssPlugin.postcss = true;
|
|
231
|
+
//#endregion
|
|
232
|
+
Object.defineProperty(exports, "weappTailwindcssPostcssPlugin", {
|
|
233
|
+
enumerable: true,
|
|
234
|
+
get: function() {
|
|
235
|
+
return weappTailwindcssPostcssPlugin;
|
|
236
|
+
}
|
|
237
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_chunk = require("./chunk-
|
|
1
|
+
const require_chunk = require("./chunk-C5U5_Hdc.js");
|
|
2
2
|
let _weapp_tailwindcss_postcss_html_transform = require("@weapp-tailwindcss/postcss/html-transform");
|
|
3
3
|
_weapp_tailwindcss_postcss_html_transform = require_chunk.__toESM(_weapp_tailwindcss_postcss_html_transform);
|
|
4
4
|
//#region src/postcss-html-transform.ts
|
package/dist/postcss.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { IStyleHandlerOptions } from '@weapp-tailwindcss/postcss/types';
|
|
2
2
|
import type { PluginCreator } from 'postcss';
|
|
3
|
-
import type { TailwindV4CandidateSource, TailwindV4SourceOptions,
|
|
3
|
+
import type { TailwindV4CandidateSource, TailwindV4SourceOptions, WeappTailwindcssGenerateOptions, WeappTailwindcssGeneratorUserOptions } from './generator';
|
|
4
4
|
export interface WeappTailwindcssPostcssPluginOptions extends TailwindV4SourceOptions {
|
|
5
5
|
generator?: WeappTailwindcssGeneratorUserOptions;
|
|
6
|
-
target?: WeappTailwindcssGeneratorTarget;
|
|
7
6
|
version?: 3 | 4;
|
|
8
7
|
config?: string;
|
|
9
8
|
postcssPlugin?: string;
|
|
10
9
|
candidates?: Iterable<string>;
|
|
10
|
+
scanSources?: WeappTailwindcssGenerateOptions['scanSources'];
|
|
11
11
|
sources?: TailwindV4CandidateSource[];
|
|
12
12
|
styleOptions?: Partial<IStyleHandlerOptions>;
|
|
13
13
|
}
|