weapp-tailwindcss 5.0.0-next.11 → 5.0.0-next.13
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/{bundle-state-BRkhpjio.js → bundle-state-Bz8vLnCf.js} +3 -2
- package/dist/{bundle-state-BrtFgX-A.mjs → bundle-state-CP2XS3Uj.mjs} +3 -2
- package/dist/bundlers/shared/css-cleanup.d.ts +6 -1
- package/dist/bundlers/shared/generator-css/source-files.d.ts +9 -6
- package/dist/bundlers/shared/generator-css/source-resolver.d.ts +16 -2
- package/dist/bundlers/shared/generator-css.d.ts +4 -0
- package/dist/bundlers/shared/hmr-timing.d.ts +18 -1
- package/dist/bundlers/vite/bundle-state.d.ts +1 -0
- package/dist/bundlers/vite/css-finalizer.d.ts +2 -0
- package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +5 -1
- package/dist/bundlers/vite/generate-bundle/css-share-scope.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle.d.ts +8 -1
- package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +1 -0
- package/dist/bundlers/vite/runtime-class-set.d.ts +4 -1
- package/dist/bundlers/vite/source-candidates.d.ts +11 -0
- package/dist/bundlers/vite/source-scan.d.ts +18 -1
- package/dist/bundlers/vite/static-config-content.d.ts +5 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +5 -0
- package/dist/cli.js +453 -9
- package/dist/cli.mjs +451 -8
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/css-macro/postcss.js +1 -1
- package/dist/css-macro/postcss.mjs +1 -1
- package/dist/css-macro.js +2 -2
- package/dist/css-macro.mjs +2 -2
- package/dist/defaults.js +1 -1
- package/dist/defaults.mjs +1 -1
- package/dist/generator-C9H44wEF.mjs +32 -0
- package/dist/generator-CRORPkpW.js +55 -0
- package/dist/generator.js +12 -11
- package/dist/generator.mjs +2 -1
- package/dist/gulp.js +49 -13
- package/dist/gulp.mjs +46 -10
- package/dist/{incremental-runtime-class-set-CBMefNHQ.js → incremental-runtime-class-set-DN9KKjSi.js} +512 -103
- package/dist/{incremental-runtime-class-set-DaS2yw5c.mjs → incremental-runtime-class-set-Dbn4yPfZ.mjs} +491 -88
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- package/dist/{postcss-BdcRlSpp.js → postcss-Ab7YzAbs.js} +30 -19
- package/dist/{postcss-Bs-RbNzK.js → postcss-CZE8k8oP.js} +59 -53
- package/dist/{postcss-xZDiTRII.mjs → postcss-CtlrNknb.mjs} +19 -8
- package/dist/postcss.js +1 -1
- package/dist/postcss.mjs +1 -1
- package/dist/{precheck-D5eEdqeH.js → precheck-CRX-pMKJ.js} +37 -17
- package/dist/{precheck-DtBGFS-n.mjs → precheck-SG48aLG2.mjs} +29 -9
- package/dist/presets.js +6 -6
- package/dist/presets.mjs +4 -4
- package/dist/source-candidates-C4YgmZ8A.js +274 -0
- package/dist/source-candidates-CyupdLKi.mjs +259 -0
- package/dist/tailwindcss/runtime/cache.d.ts +1 -0
- package/dist/tailwindcss/v3-engine/types.d.ts +3 -0
- package/dist/tailwindcss/v4-engine/types.d.ts +8 -0
- package/dist/{tailwindcss-DGM8lHUj.mjs → tailwindcss-BbTVeQkG.mjs} +9 -4
- package/dist/{tailwindcss-B78nj6n7.js → tailwindcss-DZ6jVYb4.js} +21 -16
- package/dist/v3-engine-D61eilBl.mjs +3208 -0
- package/dist/v3-engine-DwV1E6rX.js +3461 -0
- package/dist/{vite-C8S1wfyQ.mjs → vite-Ti_qSctn.mjs} +380 -542
- package/dist/{vite-BEj9JOOA.js → vite-xKS6RvLR.js} +385 -550
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.js +29 -9
- package/dist/weapp-tw-runtime-classset-loader.js +1 -1
- package/dist/{webpack-ZGIKKpFf.mjs → webpack-DvptFz7B.mjs} +36 -19
- package/dist/{webpack-Dm1IXTIh.js → webpack-wfNutjMm.js} +40 -23
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +3 -3
- package/dist/cache-B_9E7FxF.js +0 -517
- package/dist/cache-DEDxBMIw.mjs +0 -443
- package/dist/generator-CahkD2vq.mjs +0 -1469
- package/dist/generator-Ck1Dd1V0.js +0 -1568
- package/dist/runtime-patch-CqB-A4zA.js +0 -85
- package/dist/runtime-patch-DGKsVkiG.mjs +0 -71
- package/dist/source-scan-CIVTa3Cj.js +0 -297
- package/dist/source-scan-CJ0y0XBj.mjs +0 -258
- /package/dist/{constants-BeeyfJ9k.js → constants-BoB_6lFw.js} +0 -0
- /package/dist/{constants-BG12WAKw.mjs → constants-E_loJC49.mjs} +0 -0
- /package/dist/{logger-EVNB9z7i.js → logger-BRy6XPQ2.js} +0 -0
- /package/dist/{logger-CZUxvJJD.mjs → logger-Bub1jggA.mjs} +0 -0
- /package/dist/{utils-CGBVVNm6.mjs → utils-CycMvPn_.mjs} +0 -0
- /package/dist/{utils-4ODFyoqD.js → utils-D0MZP_tr.js} +0 -0
|
@@ -1,1568 +0,0 @@
|
|
|
1
|
-
const require_chunk = require("./chunk-8l464Juk.js");
|
|
2
|
-
const require_cache = require("./cache-B_9E7FxF.js");
|
|
3
|
-
const require_runtime_patch = require("./runtime-patch-CqB-A4zA.js");
|
|
4
|
-
let node_module = require("node:module");
|
|
5
|
-
let postcss = require("postcss");
|
|
6
|
-
postcss = require_chunk.__toESM(postcss);
|
|
7
|
-
let node_path = require("node:path");
|
|
8
|
-
node_path = require_chunk.__toESM(node_path);
|
|
9
|
-
let node_process = require("node:process");
|
|
10
|
-
node_process = require_chunk.__toESM(node_process);
|
|
11
|
-
let tailwindcss_patch = require("tailwindcss-patch");
|
|
12
|
-
let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
|
|
13
|
-
let tailwindcss_config = require("tailwindcss-config");
|
|
14
|
-
//#region src/tailwindcss/remove-unsupported-css.ts
|
|
15
|
-
/**
|
|
16
|
-
* 移除小程序不支持的 cascade layer 语法,同时保留 layer 内的实际规则。
|
|
17
|
-
*/
|
|
18
|
-
function removeUnsupportedCascadeLayers(root) {
|
|
19
|
-
root.walkAtRules("layer", (atRule) => {
|
|
20
|
-
if (!atRule.nodes || atRule.nodes.length === 0) {
|
|
21
|
-
atRule.remove();
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
atRule.replaceWith(...atRule.nodes);
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
//#endregion
|
|
28
|
-
//#region src/tailwindcss/miniprogram.ts
|
|
29
|
-
const DEFAULT_WEAPP_VARIABLE_SCOPE = "page,.tw-root,wx-root-portal-content,:host";
|
|
30
|
-
const CLASS_SELECTOR_RE = /(?:^|[^\w-])\.[_a-z\u00A0-\uFFFF\\-]/i;
|
|
31
|
-
const PSEUDO_CONTENT_SELECTOR_RE = /^(?:::before|::after|:before|:after)(?:,(?:::before|::after|:before|:after))*$/;
|
|
32
|
-
const MINI_PROGRAM_PREFLIGHT_SELECTORS = new Set([
|
|
33
|
-
"*",
|
|
34
|
-
"view",
|
|
35
|
-
"text",
|
|
36
|
-
":before",
|
|
37
|
-
":after",
|
|
38
|
-
"::before",
|
|
39
|
-
"::after"
|
|
40
|
-
]);
|
|
41
|
-
const PREFLIGHT_RESET_PROPS = new Set([
|
|
42
|
-
"box-sizing",
|
|
43
|
-
"border",
|
|
44
|
-
"border-width",
|
|
45
|
-
"border-style",
|
|
46
|
-
"border-color",
|
|
47
|
-
"margin",
|
|
48
|
-
"padding"
|
|
49
|
-
]);
|
|
50
|
-
function hasClassSelector(selector) {
|
|
51
|
-
return CLASS_SELECTOR_RE.test(selector);
|
|
52
|
-
}
|
|
53
|
-
function normalizeSelector$1(selector) {
|
|
54
|
-
return selector.trim().replace(/\s+/g, "");
|
|
55
|
-
}
|
|
56
|
-
function getRuleSelectors(rule) {
|
|
57
|
-
return rule.selector.split(",").map(normalizeSelector$1).filter(Boolean);
|
|
58
|
-
}
|
|
59
|
-
function isCustomPropertyRule(rule) {
|
|
60
|
-
let hasDeclaration = false;
|
|
61
|
-
let allCustomProperties = true;
|
|
62
|
-
rule.walkDecls((decl) => {
|
|
63
|
-
hasDeclaration = true;
|
|
64
|
-
if (!decl.prop.startsWith("--")) allCustomProperties = false;
|
|
65
|
-
});
|
|
66
|
-
return hasDeclaration && allCustomProperties;
|
|
67
|
-
}
|
|
68
|
-
function isPseudoContentInitRule(rule) {
|
|
69
|
-
const selector = rule.selector.replace(/\s+/g, "");
|
|
70
|
-
if (!PSEUDO_CONTENT_SELECTOR_RE.test(selector)) return false;
|
|
71
|
-
let hasDeclaration = false;
|
|
72
|
-
let onlyContentVariable = true;
|
|
73
|
-
rule.walkDecls((decl) => {
|
|
74
|
-
hasDeclaration = true;
|
|
75
|
-
if (decl.prop !== "--tw-content") onlyContentVariable = false;
|
|
76
|
-
});
|
|
77
|
-
return hasDeclaration && onlyContentVariable;
|
|
78
|
-
}
|
|
79
|
-
function isMiniProgramPreflightRule(rule) {
|
|
80
|
-
const selectors = getRuleSelectors(rule);
|
|
81
|
-
if (selectors.length === 0 || !selectors.every((selector) => MINI_PROGRAM_PREFLIGHT_SELECTORS.has(selector)) || !selectors.some((selector) => selector === "*" || selector === ":before" || selector === ":after" || selector === "::before" || selector === "::after")) return false;
|
|
82
|
-
let hasTailwindVariable = false;
|
|
83
|
-
let hasResetProp = false;
|
|
84
|
-
rule.walkDecls((decl) => {
|
|
85
|
-
if (decl.prop.startsWith("--tw-")) hasTailwindVariable = true;
|
|
86
|
-
if (PREFLIGHT_RESET_PROPS.has(decl.prop)) hasResetProp = true;
|
|
87
|
-
});
|
|
88
|
-
return hasTailwindVariable || hasResetProp;
|
|
89
|
-
}
|
|
90
|
-
function isKeyframesRule(rule) {
|
|
91
|
-
let parent = rule.parent;
|
|
92
|
-
while (parent) {
|
|
93
|
-
if (parent.type === "atrule" && parent.name.endsWith("keyframes")) return true;
|
|
94
|
-
parent = parent.parent;
|
|
95
|
-
}
|
|
96
|
-
return false;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* 裁剪 Tailwind 生成 CSS 中面向浏览器的 classless 规则。
|
|
100
|
-
*
|
|
101
|
-
* 生成模式面向小程序时只需要保留业务 utility 与 Tailwind 变量初始化;
|
|
102
|
-
* 浏览器元素 reset、表单伪元素等 classless 规则不适合直接输出到小程序。
|
|
103
|
-
*/
|
|
104
|
-
function pruneMiniProgramGeneratedCss(css, options = {}) {
|
|
105
|
-
const root = postcss.default.parse(css);
|
|
106
|
-
root.walkComments((comment) => {
|
|
107
|
-
comment.remove();
|
|
108
|
-
});
|
|
109
|
-
removeUnsupportedCascadeLayers(root);
|
|
110
|
-
root.walkAtRules("supports", (atRule) => {
|
|
111
|
-
atRule.remove();
|
|
112
|
-
});
|
|
113
|
-
root.walkRules((rule) => {
|
|
114
|
-
if (isKeyframesRule(rule)) return;
|
|
115
|
-
if (hasClassSelector(rule.selector)) return;
|
|
116
|
-
if (isPseudoContentInitRule(rule)) return;
|
|
117
|
-
if (options.preservePreflight && isMiniProgramPreflightRule(rule)) return;
|
|
118
|
-
if (isCustomPropertyRule(rule)) {
|
|
119
|
-
rule.selector = DEFAULT_WEAPP_VARIABLE_SCOPE;
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
rule.remove();
|
|
123
|
-
});
|
|
124
|
-
root.walkAtRules((atRule) => {
|
|
125
|
-
if (!atRule.nodes || atRule.nodes.length === 0) atRule.remove();
|
|
126
|
-
});
|
|
127
|
-
return root.toString();
|
|
128
|
-
}
|
|
129
|
-
//#endregion
|
|
130
|
-
//#region src/tailwindcss/v3-engine/miniprogram.ts
|
|
131
|
-
const defaultStyleHandler$1 = (0, _weapp_tailwindcss_postcss.createStyleHandler)({
|
|
132
|
-
cssChildCombinatorReplaceValue: ["view", "text"],
|
|
133
|
-
cssRemoveHoverPseudoClass: true,
|
|
134
|
-
isMainChunk: true,
|
|
135
|
-
majorVersion: 3
|
|
136
|
-
});
|
|
137
|
-
const MINI_PROGRAM_V3_PREFLIGHT_SELECTOR = "view,text,::before,::after";
|
|
138
|
-
const V3_PREFLIGHT_RESET_PROPS = new Set([
|
|
139
|
-
"box-sizing",
|
|
140
|
-
"border",
|
|
141
|
-
"border-width",
|
|
142
|
-
"border-style",
|
|
143
|
-
"border-color",
|
|
144
|
-
"margin",
|
|
145
|
-
"padding"
|
|
146
|
-
]);
|
|
147
|
-
function normalizeSelector(selector) {
|
|
148
|
-
return selector.trim().replace(/\s+/g, "");
|
|
149
|
-
}
|
|
150
|
-
function isMiniProgramV3PreflightRule(rule) {
|
|
151
|
-
return normalizeSelector(rule.selector) === MINI_PROGRAM_V3_PREFLIGHT_SELECTOR;
|
|
152
|
-
}
|
|
153
|
-
function hasResetDeclaration(rule) {
|
|
154
|
-
let found = false;
|
|
155
|
-
rule.walkDecls((decl) => {
|
|
156
|
-
if (V3_PREFLIGHT_RESET_PROPS.has(decl.prop)) found = true;
|
|
157
|
-
});
|
|
158
|
-
return found;
|
|
159
|
-
}
|
|
160
|
-
function createPreflightDeclarations(cssPreflight) {
|
|
161
|
-
if (!cssPreflight || typeof cssPreflight !== "object") return [];
|
|
162
|
-
return Object.entries(cssPreflight).filter((entry) => entry[1] !== false).map(([prop, value]) => postcss.default.decl({
|
|
163
|
-
prop,
|
|
164
|
-
value: value.toString()
|
|
165
|
-
}));
|
|
166
|
-
}
|
|
167
|
-
function ensureMiniProgramV3PreflightReset(css, cssPreflight) {
|
|
168
|
-
const declarations = createPreflightDeclarations(cssPreflight);
|
|
169
|
-
if (declarations.length === 0) return css;
|
|
170
|
-
try {
|
|
171
|
-
const root = postcss.default.parse(css);
|
|
172
|
-
let targetRule;
|
|
173
|
-
let hasReset = false;
|
|
174
|
-
root.walkRules((rule) => {
|
|
175
|
-
if (!isMiniProgramV3PreflightRule(rule)) return;
|
|
176
|
-
targetRule ?? (targetRule = rule);
|
|
177
|
-
if (hasResetDeclaration(rule)) hasReset = true;
|
|
178
|
-
});
|
|
179
|
-
if (!targetRule || hasReset) return css;
|
|
180
|
-
targetRule.append(...declarations.map((decl) => decl.clone()));
|
|
181
|
-
return root.toString();
|
|
182
|
-
} catch {
|
|
183
|
-
return css;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
async function transformTailwindV3CssToWeapp(css, options) {
|
|
187
|
-
return ensureMiniProgramV3PreflightReset(pruneMiniProgramGeneratedCss((await defaultStyleHandler$1(css, {
|
|
188
|
-
cssChildCombinatorReplaceValue: ["view", "text"],
|
|
189
|
-
cssRemoveHoverPseudoClass: true,
|
|
190
|
-
isMainChunk: true,
|
|
191
|
-
majorVersion: 3,
|
|
192
|
-
...options
|
|
193
|
-
})).css, { preservePreflight: true }), options?.cssPreflight);
|
|
194
|
-
}
|
|
195
|
-
async function transformTailwindV3CssByTarget(css, target, options) {
|
|
196
|
-
return target === "weapp" ? transformTailwindV3CssToWeapp(css, options) : css;
|
|
197
|
-
}
|
|
198
|
-
//#endregion
|
|
199
|
-
//#region src/tailwindcss/v3-engine/generator.ts
|
|
200
|
-
function isLegacyContentObject(value) {
|
|
201
|
-
return typeof value === "object" && value !== null && "files" in value;
|
|
202
|
-
}
|
|
203
|
-
function createRawContentEntries(candidates, sources) {
|
|
204
|
-
const entries = [];
|
|
205
|
-
const candidateContent = [...candidates].join(" ");
|
|
206
|
-
if (candidateContent.length > 0) entries.push({
|
|
207
|
-
raw: candidateContent,
|
|
208
|
-
extension: "html"
|
|
209
|
-
});
|
|
210
|
-
for (const source of sources) entries.push({
|
|
211
|
-
raw: source.content,
|
|
212
|
-
extension: source.extension ?? "html"
|
|
213
|
-
});
|
|
214
|
-
return entries;
|
|
215
|
-
}
|
|
216
|
-
function mergeContent(content, rawEntries) {
|
|
217
|
-
if (isLegacyContentObject(content)) return {
|
|
218
|
-
...content,
|
|
219
|
-
relative: content.relative ?? true,
|
|
220
|
-
files: [...[].concat(content.files ?? []), ...rawEntries]
|
|
221
|
-
};
|
|
222
|
-
return {
|
|
223
|
-
relative: true,
|
|
224
|
-
files: [...[].concat(content ?? []), ...rawEntries]
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
function normalizeConfigObject(config) {
|
|
228
|
-
if (!config || typeof config !== "object") return config;
|
|
229
|
-
const maybeDefault = config.default;
|
|
230
|
-
if (maybeDefault && typeof maybeDefault === "object") return maybeDefault;
|
|
231
|
-
return config;
|
|
232
|
-
}
|
|
233
|
-
function createTailwindConfig(source, options) {
|
|
234
|
-
const config = { ...normalizeConfigObject(source.configObject) ?? {} };
|
|
235
|
-
const rawEntries = createRawContentEntries(options.candidates ?? [], options.sources ?? []);
|
|
236
|
-
config.content = mergeContent(config.content, rawEntries);
|
|
237
|
-
return config;
|
|
238
|
-
}
|
|
239
|
-
function loadTailwindcssPlugin(source) {
|
|
240
|
-
const requireFromProject = (0, node_module.createRequire)(`${source.cwd}/package.json`);
|
|
241
|
-
const requireFromRuntime = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
|
|
242
|
-
let plugin;
|
|
243
|
-
try {
|
|
244
|
-
plugin = requireFromProject(source.postcssPlugin);
|
|
245
|
-
} catch {
|
|
246
|
-
plugin = requireFromRuntime(source.postcssPlugin);
|
|
247
|
-
}
|
|
248
|
-
return typeof plugin === "function" ? plugin : plugin.default;
|
|
249
|
-
}
|
|
250
|
-
function collectClassSet(plugin) {
|
|
251
|
-
const classSet = /* @__PURE__ */ new Set();
|
|
252
|
-
for (const context of plugin.contextRef?.value ?? []) for (const candidate of context.classCache?.keys() ?? []) if (String(candidate) !== "*") classSet.add(candidate);
|
|
253
|
-
return classSet;
|
|
254
|
-
}
|
|
255
|
-
function collectDependencyMessages(result) {
|
|
256
|
-
const dependencies = /* @__PURE__ */ new Set();
|
|
257
|
-
for (const message of result.messages) {
|
|
258
|
-
const file = message["file"];
|
|
259
|
-
if (message.type === "dependency" && typeof file === "string") dependencies.add(file);
|
|
260
|
-
}
|
|
261
|
-
return dependencies;
|
|
262
|
-
}
|
|
263
|
-
function createRuntimeReadyPromise(source) {
|
|
264
|
-
return require_runtime_patch.ensureTailwindcssRuntimePatch(require_cache.createTailwindcssPatcher({
|
|
265
|
-
basedir: source.cwd,
|
|
266
|
-
supportCustomLengthUnitsPatch: true,
|
|
267
|
-
tailwindcss: {
|
|
268
|
-
...source.config === void 0 ? {} : { config: source.config },
|
|
269
|
-
cwd: source.cwd,
|
|
270
|
-
packageName: source.packageName,
|
|
271
|
-
postcssPlugin: source.postcssPlugin,
|
|
272
|
-
version: 3
|
|
273
|
-
}
|
|
274
|
-
}), { clearRequireCache: true });
|
|
275
|
-
}
|
|
276
|
-
function createTailwindV3Engine(source) {
|
|
277
|
-
const runtimeReadyPromise = createRuntimeReadyPromise(source);
|
|
278
|
-
async function generate(options = {}) {
|
|
279
|
-
await runtimeReadyPromise;
|
|
280
|
-
const { styleOptions, target = "weapp" } = options;
|
|
281
|
-
const tailwindcss = loadTailwindcssPlugin(source);
|
|
282
|
-
const result = await (0, postcss.default)([tailwindcss(createTailwindConfig(source, options))]).process(source.css, { from: void 0 });
|
|
283
|
-
const rawCss = result.css;
|
|
284
|
-
const css = await transformTailwindV3CssByTarget(rawCss, target, styleOptions);
|
|
285
|
-
const dependencies = collectDependencyMessages(result);
|
|
286
|
-
for (const dependency of source.dependencies) dependencies.add(dependency);
|
|
287
|
-
return {
|
|
288
|
-
css,
|
|
289
|
-
rawCss,
|
|
290
|
-
classSet: collectClassSet(tailwindcss),
|
|
291
|
-
rawCandidates: new Set(options.candidates ?? []),
|
|
292
|
-
dependencies: [...dependencies],
|
|
293
|
-
sources: [],
|
|
294
|
-
root: null,
|
|
295
|
-
target,
|
|
296
|
-
version: 3
|
|
297
|
-
};
|
|
298
|
-
}
|
|
299
|
-
return {
|
|
300
|
-
source,
|
|
301
|
-
async validateCandidates(candidates) {
|
|
302
|
-
return (await generate({
|
|
303
|
-
candidates,
|
|
304
|
-
target: "tailwind"
|
|
305
|
-
})).classSet;
|
|
306
|
-
},
|
|
307
|
-
generate
|
|
308
|
-
};
|
|
309
|
-
}
|
|
310
|
-
//#endregion
|
|
311
|
-
//#region src/tailwindcss/v3-engine/source.ts
|
|
312
|
-
const DEFAULT_TAILWIND_V3_CSS = [
|
|
313
|
-
"@tailwind base;",
|
|
314
|
-
"@tailwind components;",
|
|
315
|
-
"@tailwind utilities;"
|
|
316
|
-
].join("\n");
|
|
317
|
-
function parseConfigParam(params) {
|
|
318
|
-
const value = params.trim();
|
|
319
|
-
return /^(['"])(.+)\1$/.exec(value)?.[2];
|
|
320
|
-
}
|
|
321
|
-
function resolveOptionalPath(value, base) {
|
|
322
|
-
if (!value) return;
|
|
323
|
-
return node_path.default.isAbsolute(value) ? value : node_path.default.resolve(base, value);
|
|
324
|
-
}
|
|
325
|
-
function resolveCssConfig(css, base) {
|
|
326
|
-
if (!css) return {
|
|
327
|
-
css,
|
|
328
|
-
config: void 0
|
|
329
|
-
};
|
|
330
|
-
const root = postcss.default.parse(css);
|
|
331
|
-
let config;
|
|
332
|
-
root.walkAtRules("config", (rule) => {
|
|
333
|
-
const configPath = parseConfigParam(rule.params);
|
|
334
|
-
if (!configPath) return;
|
|
335
|
-
if (!config) config = resolveOptionalPath(configPath, base);
|
|
336
|
-
rule.remove();
|
|
337
|
-
});
|
|
338
|
-
return {
|
|
339
|
-
config,
|
|
340
|
-
css: root.toString()
|
|
341
|
-
};
|
|
342
|
-
}
|
|
343
|
-
function getProjectRoot$1(patcher) {
|
|
344
|
-
return patcher.options?.projectRoot ?? node_process.default.cwd();
|
|
345
|
-
}
|
|
346
|
-
function normalizeLoadedConfig(config) {
|
|
347
|
-
if (!config || typeof config !== "object") return config;
|
|
348
|
-
const maybeDefault = config.default;
|
|
349
|
-
if (maybeDefault && typeof maybeDefault === "object") return maybeDefault;
|
|
350
|
-
return config;
|
|
351
|
-
}
|
|
352
|
-
function resolveTailwindCssPackageName(patcher) {
|
|
353
|
-
return require_cache.resolveTailwindcssOptions(patcher.options)?.packageName ?? patcher.packageInfo?.name ?? "tailwindcss";
|
|
354
|
-
}
|
|
355
|
-
async function resolveTailwindV3Source(options = {}) {
|
|
356
|
-
const projectRoot = options.projectRoot ?? node_process.default.cwd();
|
|
357
|
-
const base = options.base ?? options.cwd ?? projectRoot;
|
|
358
|
-
const cssConfig = resolveCssConfig(options.css, base);
|
|
359
|
-
const config = resolveOptionalPath(options.config, base) ?? cssConfig.config;
|
|
360
|
-
const cwd = options.cwd ?? (config ? node_path.default.dirname(config) : projectRoot);
|
|
361
|
-
const loaded = await (0, tailwindcss_config.loadConfig)(require_cache.omitUndefined({
|
|
362
|
-
config,
|
|
363
|
-
cwd
|
|
364
|
-
}));
|
|
365
|
-
return {
|
|
366
|
-
version: 3,
|
|
367
|
-
projectRoot,
|
|
368
|
-
cwd,
|
|
369
|
-
base,
|
|
370
|
-
css: cssConfig.css ?? options.css ?? DEFAULT_TAILWIND_V3_CSS,
|
|
371
|
-
config: loaded?.filepath ?? config,
|
|
372
|
-
configObject: normalizeLoadedConfig(loaded?.config),
|
|
373
|
-
dependencies: loaded?.filepath ? [loaded.filepath] : [],
|
|
374
|
-
packageName: options.packageName ?? "tailwindcss",
|
|
375
|
-
postcssPlugin: options.postcssPlugin ?? options.packageName ?? "tailwindcss"
|
|
376
|
-
};
|
|
377
|
-
}
|
|
378
|
-
function resolveTailwindV3SourceOptionsFromPatcher(patcher) {
|
|
379
|
-
const projectRoot = getProjectRoot$1(patcher);
|
|
380
|
-
const tailwindOptions = require_cache.resolveTailwindcssOptions(patcher.options);
|
|
381
|
-
return {
|
|
382
|
-
projectRoot,
|
|
383
|
-
cwd: tailwindOptions?.v3?.cwd ?? tailwindOptions?.cwd ?? projectRoot,
|
|
384
|
-
config: tailwindOptions?.v3?.config ?? tailwindOptions?.config,
|
|
385
|
-
packageName: resolveTailwindCssPackageName(patcher),
|
|
386
|
-
postcssPlugin: tailwindOptions?.v3?.postcssPlugin ?? tailwindOptions?.postcssPlugin
|
|
387
|
-
};
|
|
388
|
-
}
|
|
389
|
-
function resolveTailwindV3SourceFromPatcher(patcher) {
|
|
390
|
-
return resolveTailwindV3Source(resolveTailwindV3SourceOptionsFromPatcher(patcher));
|
|
391
|
-
}
|
|
392
|
-
//#endregion
|
|
393
|
-
//#region src/tailwindcss/v4-engine/candidates.ts
|
|
394
|
-
const UNSUPPORTED_MINI_PROGRAM_TAILWIND_V4_CANDIDATE_RE = /(?:^|:)(?:group|peer|in|not-in)-[^\s:]*\/|(?:^|:)(?:in|not-in)-\[/;
|
|
395
|
-
function isUnsupportedMiniProgramTailwindV4Candidate(candidate) {
|
|
396
|
-
return UNSUPPORTED_MINI_PROGRAM_TAILWIND_V4_CANDIDATE_RE.test(candidate);
|
|
397
|
-
}
|
|
398
|
-
function filterUnsupportedMiniProgramTailwindV4Candidates(candidates) {
|
|
399
|
-
if (!candidates) return;
|
|
400
|
-
return new Set([...candidates].filter((candidate) => !isUnsupportedMiniProgramTailwindV4Candidate(candidate)));
|
|
401
|
-
}
|
|
402
|
-
//#endregion
|
|
403
|
-
//#region src/tailwindcss/v4-engine/miniprogram.ts
|
|
404
|
-
const defaultStyleHandler = (0, _weapp_tailwindcss_postcss.createStyleHandler)({
|
|
405
|
-
cssChildCombinatorReplaceValue: ["view", "text"],
|
|
406
|
-
cssRemoveHoverPseudoClass: true,
|
|
407
|
-
isMainChunk: true,
|
|
408
|
-
majorVersion: 4
|
|
409
|
-
});
|
|
410
|
-
const CSS_DECLARATION_URL_RE = /(:\s*)url\(([^\n\r"';[\]{}]*[[\]{}][^\n\r;]*)\)(?=\s*;)/g;
|
|
411
|
-
function normalizeTailwindV4GeneratedUrlValues(css) {
|
|
412
|
-
return css.replace(CSS_DECLARATION_URL_RE, (match, prefix, urlValue) => {
|
|
413
|
-
try {
|
|
414
|
-
return `${prefix}url("${urlValue.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"")}")`;
|
|
415
|
-
} catch {
|
|
416
|
-
return match;
|
|
417
|
-
}
|
|
418
|
-
});
|
|
419
|
-
}
|
|
420
|
-
async function transformTailwindV4CssToWeapp(css, options) {
|
|
421
|
-
const protectedCss = (0, _weapp_tailwindcss_postcss.protectDynamicColorMixAlpha)(normalizeTailwindV4GeneratedUrlValues(css));
|
|
422
|
-
const result = await defaultStyleHandler(protectedCss.css, {
|
|
423
|
-
cssChildCombinatorReplaceValue: ["view", "text"],
|
|
424
|
-
cssRemoveHoverPseudoClass: true,
|
|
425
|
-
isMainChunk: true,
|
|
426
|
-
majorVersion: 4,
|
|
427
|
-
...options
|
|
428
|
-
});
|
|
429
|
-
return pruneMiniProgramGeneratedCss(protectedCss.restore(result.css));
|
|
430
|
-
}
|
|
431
|
-
async function transformTailwindV4CssByTarget(css, target, options) {
|
|
432
|
-
return target === "weapp" ? transformTailwindV4CssToWeapp(css, options) : css;
|
|
433
|
-
}
|
|
434
|
-
//#endregion
|
|
435
|
-
//#region src/tailwindcss/v4-engine/tailwind-v3-default-colors.ts
|
|
436
|
-
const TAILWIND_V3_COLOR_STEPS = [
|
|
437
|
-
"50",
|
|
438
|
-
"100",
|
|
439
|
-
"200",
|
|
440
|
-
"300",
|
|
441
|
-
"400",
|
|
442
|
-
"500",
|
|
443
|
-
"600",
|
|
444
|
-
"700",
|
|
445
|
-
"800",
|
|
446
|
-
"900",
|
|
447
|
-
"950"
|
|
448
|
-
];
|
|
449
|
-
const TAILWIND_V3_COLOR_PALETTE = {
|
|
450
|
-
slate: [
|
|
451
|
-
"#f8fafc",
|
|
452
|
-
"#f1f5f9",
|
|
453
|
-
"#e2e8f0",
|
|
454
|
-
"#cbd5e1",
|
|
455
|
-
"#94a3b8",
|
|
456
|
-
"#64748b",
|
|
457
|
-
"#475569",
|
|
458
|
-
"#334155",
|
|
459
|
-
"#1e293b",
|
|
460
|
-
"#0f172a",
|
|
461
|
-
"#020617"
|
|
462
|
-
],
|
|
463
|
-
gray: [
|
|
464
|
-
"#f9fafb",
|
|
465
|
-
"#f3f4f6",
|
|
466
|
-
"#e5e7eb",
|
|
467
|
-
"#d1d5db",
|
|
468
|
-
"#9ca3af",
|
|
469
|
-
"#6b7280",
|
|
470
|
-
"#4b5563",
|
|
471
|
-
"#374151",
|
|
472
|
-
"#1f2937",
|
|
473
|
-
"#111827",
|
|
474
|
-
"#030712"
|
|
475
|
-
],
|
|
476
|
-
zinc: [
|
|
477
|
-
"#fafafa",
|
|
478
|
-
"#f4f4f5",
|
|
479
|
-
"#e4e4e7",
|
|
480
|
-
"#d4d4d8",
|
|
481
|
-
"#a1a1aa",
|
|
482
|
-
"#71717a",
|
|
483
|
-
"#52525b",
|
|
484
|
-
"#3f3f46",
|
|
485
|
-
"#27272a",
|
|
486
|
-
"#18181b",
|
|
487
|
-
"#09090b"
|
|
488
|
-
],
|
|
489
|
-
neutral: [
|
|
490
|
-
"#fafafa",
|
|
491
|
-
"#f5f5f5",
|
|
492
|
-
"#e5e5e5",
|
|
493
|
-
"#d4d4d4",
|
|
494
|
-
"#a3a3a3",
|
|
495
|
-
"#737373",
|
|
496
|
-
"#525252",
|
|
497
|
-
"#404040",
|
|
498
|
-
"#262626",
|
|
499
|
-
"#171717",
|
|
500
|
-
"#0a0a0a"
|
|
501
|
-
],
|
|
502
|
-
stone: [
|
|
503
|
-
"#fafaf9",
|
|
504
|
-
"#f5f5f4",
|
|
505
|
-
"#e7e5e4",
|
|
506
|
-
"#d6d3d1",
|
|
507
|
-
"#a8a29e",
|
|
508
|
-
"#78716c",
|
|
509
|
-
"#57534e",
|
|
510
|
-
"#44403c",
|
|
511
|
-
"#292524",
|
|
512
|
-
"#1c1917",
|
|
513
|
-
"#0c0a09"
|
|
514
|
-
],
|
|
515
|
-
red: [
|
|
516
|
-
"#fef2f2",
|
|
517
|
-
"#fee2e2",
|
|
518
|
-
"#fecaca",
|
|
519
|
-
"#fca5a5",
|
|
520
|
-
"#f87171",
|
|
521
|
-
"#ef4444",
|
|
522
|
-
"#dc2626",
|
|
523
|
-
"#b91c1c",
|
|
524
|
-
"#991b1b",
|
|
525
|
-
"#7f1d1d",
|
|
526
|
-
"#450a0a"
|
|
527
|
-
],
|
|
528
|
-
orange: [
|
|
529
|
-
"#fff7ed",
|
|
530
|
-
"#ffedd5",
|
|
531
|
-
"#fed7aa",
|
|
532
|
-
"#fdba74",
|
|
533
|
-
"#fb923c",
|
|
534
|
-
"#f97316",
|
|
535
|
-
"#ea580c",
|
|
536
|
-
"#c2410c",
|
|
537
|
-
"#9a3412",
|
|
538
|
-
"#7c2d12",
|
|
539
|
-
"#431407"
|
|
540
|
-
],
|
|
541
|
-
amber: [
|
|
542
|
-
"#fffbeb",
|
|
543
|
-
"#fef3c7",
|
|
544
|
-
"#fde68a",
|
|
545
|
-
"#fcd34d",
|
|
546
|
-
"#fbbf24",
|
|
547
|
-
"#f59e0b",
|
|
548
|
-
"#d97706",
|
|
549
|
-
"#b45309",
|
|
550
|
-
"#92400e",
|
|
551
|
-
"#78350f",
|
|
552
|
-
"#451a03"
|
|
553
|
-
],
|
|
554
|
-
yellow: [
|
|
555
|
-
"#fefce8",
|
|
556
|
-
"#fef9c3",
|
|
557
|
-
"#fef08a",
|
|
558
|
-
"#fde047",
|
|
559
|
-
"#facc15",
|
|
560
|
-
"#eab308",
|
|
561
|
-
"#ca8a04",
|
|
562
|
-
"#a16207",
|
|
563
|
-
"#854d0e",
|
|
564
|
-
"#713f12",
|
|
565
|
-
"#422006"
|
|
566
|
-
],
|
|
567
|
-
lime: [
|
|
568
|
-
"#f7fee7",
|
|
569
|
-
"#ecfccb",
|
|
570
|
-
"#d9f99d",
|
|
571
|
-
"#bef264",
|
|
572
|
-
"#a3e635",
|
|
573
|
-
"#84cc16",
|
|
574
|
-
"#65a30d",
|
|
575
|
-
"#4d7c0f",
|
|
576
|
-
"#3f6212",
|
|
577
|
-
"#365314",
|
|
578
|
-
"#1a2e05"
|
|
579
|
-
],
|
|
580
|
-
green: [
|
|
581
|
-
"#f0fdf4",
|
|
582
|
-
"#dcfce7",
|
|
583
|
-
"#bbf7d0",
|
|
584
|
-
"#86efac",
|
|
585
|
-
"#4ade80",
|
|
586
|
-
"#22c55e",
|
|
587
|
-
"#16a34a",
|
|
588
|
-
"#15803d",
|
|
589
|
-
"#166534",
|
|
590
|
-
"#14532d",
|
|
591
|
-
"#052e16"
|
|
592
|
-
],
|
|
593
|
-
emerald: [
|
|
594
|
-
"#ecfdf5",
|
|
595
|
-
"#d1fae5",
|
|
596
|
-
"#a7f3d0",
|
|
597
|
-
"#6ee7b7",
|
|
598
|
-
"#34d399",
|
|
599
|
-
"#10b981",
|
|
600
|
-
"#059669",
|
|
601
|
-
"#047857",
|
|
602
|
-
"#065f46",
|
|
603
|
-
"#064e3b",
|
|
604
|
-
"#022c22"
|
|
605
|
-
],
|
|
606
|
-
teal: [
|
|
607
|
-
"#f0fdfa",
|
|
608
|
-
"#ccfbf1",
|
|
609
|
-
"#99f6e4",
|
|
610
|
-
"#5eead4",
|
|
611
|
-
"#2dd4bf",
|
|
612
|
-
"#14b8a6",
|
|
613
|
-
"#0d9488",
|
|
614
|
-
"#0f766e",
|
|
615
|
-
"#115e59",
|
|
616
|
-
"#134e4a",
|
|
617
|
-
"#042f2e"
|
|
618
|
-
],
|
|
619
|
-
cyan: [
|
|
620
|
-
"#ecfeff",
|
|
621
|
-
"#cffafe",
|
|
622
|
-
"#a5f3fc",
|
|
623
|
-
"#67e8f9",
|
|
624
|
-
"#22d3ee",
|
|
625
|
-
"#06b6d4",
|
|
626
|
-
"#0891b2",
|
|
627
|
-
"#0e7490",
|
|
628
|
-
"#155e75",
|
|
629
|
-
"#164e63",
|
|
630
|
-
"#083344"
|
|
631
|
-
],
|
|
632
|
-
sky: [
|
|
633
|
-
"#f0f9ff",
|
|
634
|
-
"#e0f2fe",
|
|
635
|
-
"#bae6fd",
|
|
636
|
-
"#7dd3fc",
|
|
637
|
-
"#38bdf8",
|
|
638
|
-
"#0ea5e9",
|
|
639
|
-
"#0284c7",
|
|
640
|
-
"#0369a1",
|
|
641
|
-
"#075985",
|
|
642
|
-
"#0c4a6e",
|
|
643
|
-
"#082f49"
|
|
644
|
-
],
|
|
645
|
-
blue: [
|
|
646
|
-
"#eff6ff",
|
|
647
|
-
"#dbeafe",
|
|
648
|
-
"#bfdbfe",
|
|
649
|
-
"#93c5fd",
|
|
650
|
-
"#60a5fa",
|
|
651
|
-
"#3b82f6",
|
|
652
|
-
"#2563eb",
|
|
653
|
-
"#1d4ed8",
|
|
654
|
-
"#1e40af",
|
|
655
|
-
"#1e3a8a",
|
|
656
|
-
"#172554"
|
|
657
|
-
],
|
|
658
|
-
indigo: [
|
|
659
|
-
"#eef2ff",
|
|
660
|
-
"#e0e7ff",
|
|
661
|
-
"#c7d2fe",
|
|
662
|
-
"#a5b4fc",
|
|
663
|
-
"#818cf8",
|
|
664
|
-
"#6366f1",
|
|
665
|
-
"#4f46e5",
|
|
666
|
-
"#4338ca",
|
|
667
|
-
"#3730a3",
|
|
668
|
-
"#312e81",
|
|
669
|
-
"#1e1b4b"
|
|
670
|
-
],
|
|
671
|
-
violet: [
|
|
672
|
-
"#f5f3ff",
|
|
673
|
-
"#ede9fe",
|
|
674
|
-
"#ddd6fe",
|
|
675
|
-
"#c4b5fd",
|
|
676
|
-
"#a78bfa",
|
|
677
|
-
"#8b5cf6",
|
|
678
|
-
"#7c3aed",
|
|
679
|
-
"#6d28d9",
|
|
680
|
-
"#5b21b6",
|
|
681
|
-
"#4c1d95",
|
|
682
|
-
"#2e1065"
|
|
683
|
-
],
|
|
684
|
-
purple: [
|
|
685
|
-
"#faf5ff",
|
|
686
|
-
"#f3e8ff",
|
|
687
|
-
"#e9d5ff",
|
|
688
|
-
"#d8b4fe",
|
|
689
|
-
"#c084fc",
|
|
690
|
-
"#a855f7",
|
|
691
|
-
"#9333ea",
|
|
692
|
-
"#7e22ce",
|
|
693
|
-
"#6b21a8",
|
|
694
|
-
"#581c87",
|
|
695
|
-
"#3b0764"
|
|
696
|
-
],
|
|
697
|
-
fuchsia: [
|
|
698
|
-
"#fdf4ff",
|
|
699
|
-
"#fae8ff",
|
|
700
|
-
"#f5d0fe",
|
|
701
|
-
"#f0abfc",
|
|
702
|
-
"#e879f9",
|
|
703
|
-
"#d946ef",
|
|
704
|
-
"#c026d3",
|
|
705
|
-
"#a21caf",
|
|
706
|
-
"#86198f",
|
|
707
|
-
"#701a75",
|
|
708
|
-
"#4a044e"
|
|
709
|
-
],
|
|
710
|
-
pink: [
|
|
711
|
-
"#fdf2f8",
|
|
712
|
-
"#fce7f3",
|
|
713
|
-
"#fbcfe8",
|
|
714
|
-
"#f9a8d4",
|
|
715
|
-
"#f472b6",
|
|
716
|
-
"#ec4899",
|
|
717
|
-
"#db2777",
|
|
718
|
-
"#be185d",
|
|
719
|
-
"#9d174d",
|
|
720
|
-
"#831843",
|
|
721
|
-
"#500724"
|
|
722
|
-
],
|
|
723
|
-
rose: [
|
|
724
|
-
"#fff1f2",
|
|
725
|
-
"#ffe4e6",
|
|
726
|
-
"#fecdd3",
|
|
727
|
-
"#fda4af",
|
|
728
|
-
"#fb7185",
|
|
729
|
-
"#f43f5e",
|
|
730
|
-
"#e11d48",
|
|
731
|
-
"#be123c",
|
|
732
|
-
"#9f1239",
|
|
733
|
-
"#881337",
|
|
734
|
-
"#4c0519"
|
|
735
|
-
]
|
|
736
|
-
};
|
|
737
|
-
function createTailwindV3DefaultColorThemeCss() {
|
|
738
|
-
const declarations = [" --color-black: #000;", " --color-white: #fff;"];
|
|
739
|
-
for (const [color, values] of Object.entries(TAILWIND_V3_COLOR_PALETTE)) for (let index = 0; index < TAILWIND_V3_COLOR_STEPS.length; index++) declarations.push(` --color-${color}-${TAILWIND_V3_COLOR_STEPS[index]}: ${values[index]};`);
|
|
740
|
-
return [
|
|
741
|
-
"@theme {",
|
|
742
|
-
...declarations,
|
|
743
|
-
"}"
|
|
744
|
-
].join("\n");
|
|
745
|
-
}
|
|
746
|
-
//#endregion
|
|
747
|
-
//#region src/tailwindcss/v4-engine/tailwind-v3-compatibility.ts
|
|
748
|
-
const TAILWIND_V3_COMPATIBILITY_THEME_CSS = [
|
|
749
|
-
"@theme {",
|
|
750
|
-
" --default-ring-width: 3px;",
|
|
751
|
-
" --default-ring-color: var(--color-blue-500, #3b82f6);",
|
|
752
|
-
" --default-outline-width: 3px;",
|
|
753
|
-
"",
|
|
754
|
-
" --shadow-xs: 0 1px rgb(0 0 0 / 0.05);",
|
|
755
|
-
" --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);",
|
|
756
|
-
" --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);",
|
|
757
|
-
" --drop-shadow-xs: 0 1px 1px rgb(0 0 0 / 0.05);",
|
|
758
|
-
" --drop-shadow-sm: 0 1px 2px rgb(0 0 0 / 0.15);",
|
|
759
|
-
" --drop-shadow: 0 1px 2px rgb(0 0 0 / 0.1), 0 1px 1px rgb(0 0 0 / 0.06);",
|
|
760
|
-
"",
|
|
761
|
-
" --blur-xs: 4px;",
|
|
762
|
-
" --blur-sm: 4px;",
|
|
763
|
-
" --blur: 8px;",
|
|
764
|
-
" --backdrop-blur-xs: 4px;",
|
|
765
|
-
" --backdrop-blur-sm: 4px;",
|
|
766
|
-
" --backdrop-blur: 8px;",
|
|
767
|
-
"",
|
|
768
|
-
" --radius-xs: 0.125rem;",
|
|
769
|
-
" --radius-sm: 0.125rem;",
|
|
770
|
-
" --radius: 0.25rem;",
|
|
771
|
-
"}",
|
|
772
|
-
createTailwindV3DefaultColorThemeCss()
|
|
773
|
-
].join("\n");
|
|
774
|
-
const TAILWIND_V3_COMPATIBILITY_BASE_CSS = [
|
|
775
|
-
"*,",
|
|
776
|
-
"::after,",
|
|
777
|
-
"::before,",
|
|
778
|
-
"::backdrop,",
|
|
779
|
-
"::file-selector-button {",
|
|
780
|
-
" border-color: var(--color-gray-200, currentcolor);",
|
|
781
|
-
"}",
|
|
782
|
-
"",
|
|
783
|
-
"input::placeholder,",
|
|
784
|
-
"textarea::placeholder {",
|
|
785
|
-
" opacity: 1;",
|
|
786
|
-
" color: var(--color-gray-400, currentcolor);",
|
|
787
|
-
"}",
|
|
788
|
-
"",
|
|
789
|
-
"button:not(:disabled),",
|
|
790
|
-
"[role=\"button\"]:not(:disabled) {",
|
|
791
|
-
" cursor: pointer;",
|
|
792
|
-
"}",
|
|
793
|
-
"",
|
|
794
|
-
"dialog {",
|
|
795
|
-
" margin: auto;",
|
|
796
|
-
"}"
|
|
797
|
-
].join("\n");
|
|
798
|
-
function applyTailwindV3CompatibilityCss(css) {
|
|
799
|
-
return `${TAILWIND_V3_COMPATIBILITY_THEME_CSS}\n${css}\n${TAILWIND_V3_COMPATIBILITY_BASE_CSS}`;
|
|
800
|
-
}
|
|
801
|
-
//#endregion
|
|
802
|
-
//#region src/tailwindcss/v4-engine/tailwind-v4-default-colors.ts
|
|
803
|
-
const TAILWIND_V4_COLOR_STEPS = [
|
|
804
|
-
"50",
|
|
805
|
-
"100",
|
|
806
|
-
"200",
|
|
807
|
-
"300",
|
|
808
|
-
"400",
|
|
809
|
-
"500",
|
|
810
|
-
"600",
|
|
811
|
-
"700",
|
|
812
|
-
"800",
|
|
813
|
-
"900",
|
|
814
|
-
"950"
|
|
815
|
-
];
|
|
816
|
-
const TAILWIND_V4_COLOR_PALETTE = {
|
|
817
|
-
slate: [
|
|
818
|
-
"#f8fafc",
|
|
819
|
-
"#f1f5f9",
|
|
820
|
-
"#e2e8f0",
|
|
821
|
-
"#cad5e2",
|
|
822
|
-
"#90a1b9",
|
|
823
|
-
"#62748e",
|
|
824
|
-
"#45556c",
|
|
825
|
-
"#314158",
|
|
826
|
-
"#1d293d",
|
|
827
|
-
"#0f172b",
|
|
828
|
-
"#020618"
|
|
829
|
-
],
|
|
830
|
-
gray: [
|
|
831
|
-
"#f9fafb",
|
|
832
|
-
"#f3f4f6",
|
|
833
|
-
"#e5e7eb",
|
|
834
|
-
"#d1d5dc",
|
|
835
|
-
"#99a1af",
|
|
836
|
-
"#6a7282",
|
|
837
|
-
"#4a5565",
|
|
838
|
-
"#364153",
|
|
839
|
-
"#1e2939",
|
|
840
|
-
"#101828",
|
|
841
|
-
"#030712"
|
|
842
|
-
],
|
|
843
|
-
zinc: [
|
|
844
|
-
"#fafafa",
|
|
845
|
-
"#f4f4f5",
|
|
846
|
-
"#e4e4e7",
|
|
847
|
-
"#d4d4d8",
|
|
848
|
-
"#9f9fa9",
|
|
849
|
-
"#71717b",
|
|
850
|
-
"#52525c",
|
|
851
|
-
"#3f3f46",
|
|
852
|
-
"#27272a",
|
|
853
|
-
"#18181b",
|
|
854
|
-
"#09090b"
|
|
855
|
-
],
|
|
856
|
-
neutral: [
|
|
857
|
-
"#fafafa",
|
|
858
|
-
"#f5f5f5",
|
|
859
|
-
"#e5e5e5",
|
|
860
|
-
"#d4d4d4",
|
|
861
|
-
"#a1a1a1",
|
|
862
|
-
"#737373",
|
|
863
|
-
"#525252",
|
|
864
|
-
"#404040",
|
|
865
|
-
"#262626",
|
|
866
|
-
"#171717",
|
|
867
|
-
"#0a0a0a"
|
|
868
|
-
],
|
|
869
|
-
stone: [
|
|
870
|
-
"#fafaf9",
|
|
871
|
-
"#f5f5f4",
|
|
872
|
-
"#e7e5e4",
|
|
873
|
-
"#d6d3d1",
|
|
874
|
-
"#a6a09b",
|
|
875
|
-
"#79716b",
|
|
876
|
-
"#57534d",
|
|
877
|
-
"#44403b",
|
|
878
|
-
"#292524",
|
|
879
|
-
"#1c1917",
|
|
880
|
-
"#0c0a09"
|
|
881
|
-
],
|
|
882
|
-
mauve: [
|
|
883
|
-
"#fafafa",
|
|
884
|
-
"#f3f1f3",
|
|
885
|
-
"#e7e4e7",
|
|
886
|
-
"#d7d0d7",
|
|
887
|
-
"#a89ea9",
|
|
888
|
-
"#79697b",
|
|
889
|
-
"#594c5b",
|
|
890
|
-
"#463947",
|
|
891
|
-
"#2a212c",
|
|
892
|
-
"#1d161e",
|
|
893
|
-
"#0c090c"
|
|
894
|
-
],
|
|
895
|
-
olive: [
|
|
896
|
-
"#fbfbf9",
|
|
897
|
-
"#f4f4f0",
|
|
898
|
-
"#e8e8e3",
|
|
899
|
-
"#d8d8d0",
|
|
900
|
-
"#abab9c",
|
|
901
|
-
"#7c7c67",
|
|
902
|
-
"#5b5b4b",
|
|
903
|
-
"#474739",
|
|
904
|
-
"#2b2b22",
|
|
905
|
-
"#1d1d16",
|
|
906
|
-
"#0c0c09"
|
|
907
|
-
],
|
|
908
|
-
mist: [
|
|
909
|
-
"#f9fbfb",
|
|
910
|
-
"#f1f3f3",
|
|
911
|
-
"#e3e7e8",
|
|
912
|
-
"#d0d6d8",
|
|
913
|
-
"#9ca8ab",
|
|
914
|
-
"#67787c",
|
|
915
|
-
"#4b585b",
|
|
916
|
-
"#394447",
|
|
917
|
-
"#22292b",
|
|
918
|
-
"#161b1d",
|
|
919
|
-
"#090b0c"
|
|
920
|
-
],
|
|
921
|
-
taupe: [
|
|
922
|
-
"#fbfaf9",
|
|
923
|
-
"#f3f1f1",
|
|
924
|
-
"#e8e4e3",
|
|
925
|
-
"#d8d2d0",
|
|
926
|
-
"#aba09c",
|
|
927
|
-
"#7c6d67",
|
|
928
|
-
"#5b4f4b",
|
|
929
|
-
"#473c39",
|
|
930
|
-
"#2b2422",
|
|
931
|
-
"#1d1816",
|
|
932
|
-
"#0c0a09"
|
|
933
|
-
],
|
|
934
|
-
red: [
|
|
935
|
-
"#fef2f2",
|
|
936
|
-
"#ffe2e2",
|
|
937
|
-
"#ffc9c9",
|
|
938
|
-
"#ffa2a2",
|
|
939
|
-
"#ff6467",
|
|
940
|
-
"#fb2c36",
|
|
941
|
-
"#e7000b",
|
|
942
|
-
"#c10007",
|
|
943
|
-
"#9f0712",
|
|
944
|
-
"#82181a",
|
|
945
|
-
"#460809"
|
|
946
|
-
],
|
|
947
|
-
orange: [
|
|
948
|
-
"#fff7ed",
|
|
949
|
-
"#ffedd4",
|
|
950
|
-
"#ffd6a7",
|
|
951
|
-
"#ffb86a",
|
|
952
|
-
"#ff8904",
|
|
953
|
-
"#ff6900",
|
|
954
|
-
"#f54900",
|
|
955
|
-
"#ca3500",
|
|
956
|
-
"#9f2d00",
|
|
957
|
-
"#7e2a0c",
|
|
958
|
-
"#441306"
|
|
959
|
-
],
|
|
960
|
-
amber: [
|
|
961
|
-
"#fffbeb",
|
|
962
|
-
"#fef3c6",
|
|
963
|
-
"#fee685",
|
|
964
|
-
"#ffd230",
|
|
965
|
-
"#ffb900",
|
|
966
|
-
"#fe9a00",
|
|
967
|
-
"#e17100",
|
|
968
|
-
"#bb4d00",
|
|
969
|
-
"#973c00",
|
|
970
|
-
"#7b3306",
|
|
971
|
-
"#461901"
|
|
972
|
-
],
|
|
973
|
-
yellow: [
|
|
974
|
-
"#fefce8",
|
|
975
|
-
"#fef9c2",
|
|
976
|
-
"#fff085",
|
|
977
|
-
"#ffdf20",
|
|
978
|
-
"#fdc700",
|
|
979
|
-
"#f0b100",
|
|
980
|
-
"#d08700",
|
|
981
|
-
"#a65f00",
|
|
982
|
-
"#894b00",
|
|
983
|
-
"#733e0a",
|
|
984
|
-
"#432004"
|
|
985
|
-
],
|
|
986
|
-
lime: [
|
|
987
|
-
"#f7fee7",
|
|
988
|
-
"#ecfcca",
|
|
989
|
-
"#d8f999",
|
|
990
|
-
"#bbf451",
|
|
991
|
-
"#9ae600",
|
|
992
|
-
"#7ccf00",
|
|
993
|
-
"#5ea500",
|
|
994
|
-
"#497d00",
|
|
995
|
-
"#3c6300",
|
|
996
|
-
"#35530e",
|
|
997
|
-
"#192e03"
|
|
998
|
-
],
|
|
999
|
-
green: [
|
|
1000
|
-
"#f0fdf4",
|
|
1001
|
-
"#dcfce7",
|
|
1002
|
-
"#b9f8cf",
|
|
1003
|
-
"#7bf1a8",
|
|
1004
|
-
"#05df72",
|
|
1005
|
-
"#00c950",
|
|
1006
|
-
"#00a63e",
|
|
1007
|
-
"#008236",
|
|
1008
|
-
"#016630",
|
|
1009
|
-
"#0d542b",
|
|
1010
|
-
"#032e15"
|
|
1011
|
-
],
|
|
1012
|
-
emerald: [
|
|
1013
|
-
"#ecfdf5",
|
|
1014
|
-
"#d0fae5",
|
|
1015
|
-
"#a4f4cf",
|
|
1016
|
-
"#5ee9b5",
|
|
1017
|
-
"#00d492",
|
|
1018
|
-
"#00bc7d",
|
|
1019
|
-
"#009966",
|
|
1020
|
-
"#007a55",
|
|
1021
|
-
"#006045",
|
|
1022
|
-
"#004f3b",
|
|
1023
|
-
"#002c22"
|
|
1024
|
-
],
|
|
1025
|
-
teal: [
|
|
1026
|
-
"#f0fdfa",
|
|
1027
|
-
"#cbfbf1",
|
|
1028
|
-
"#96f7e4",
|
|
1029
|
-
"#46ecd5",
|
|
1030
|
-
"#00d5be",
|
|
1031
|
-
"#00bba7",
|
|
1032
|
-
"#009689",
|
|
1033
|
-
"#00786f",
|
|
1034
|
-
"#005f5a",
|
|
1035
|
-
"#0b4f4a",
|
|
1036
|
-
"#022f2e"
|
|
1037
|
-
],
|
|
1038
|
-
cyan: [
|
|
1039
|
-
"#ecfeff",
|
|
1040
|
-
"#cefafe",
|
|
1041
|
-
"#a2f4fd",
|
|
1042
|
-
"#53eafd",
|
|
1043
|
-
"#00d3f2",
|
|
1044
|
-
"#00b8db",
|
|
1045
|
-
"#0092b8",
|
|
1046
|
-
"#007595",
|
|
1047
|
-
"#005f78",
|
|
1048
|
-
"#104e64",
|
|
1049
|
-
"#053345"
|
|
1050
|
-
],
|
|
1051
|
-
sky: [
|
|
1052
|
-
"#f0f9ff",
|
|
1053
|
-
"#dff2fe",
|
|
1054
|
-
"#b8e6fe",
|
|
1055
|
-
"#74d4ff",
|
|
1056
|
-
"#00bcff",
|
|
1057
|
-
"#00a6f4",
|
|
1058
|
-
"#0084d1",
|
|
1059
|
-
"#0069a8",
|
|
1060
|
-
"#00598a",
|
|
1061
|
-
"#024a70",
|
|
1062
|
-
"#052f4a"
|
|
1063
|
-
],
|
|
1064
|
-
blue: [
|
|
1065
|
-
"#eff6ff",
|
|
1066
|
-
"#dbeafe",
|
|
1067
|
-
"#bedbff",
|
|
1068
|
-
"#8ec5ff",
|
|
1069
|
-
"#51a2ff",
|
|
1070
|
-
"#2b7fff",
|
|
1071
|
-
"#155dfc",
|
|
1072
|
-
"#1447e6",
|
|
1073
|
-
"#193cb8",
|
|
1074
|
-
"#1c398e",
|
|
1075
|
-
"#162456"
|
|
1076
|
-
],
|
|
1077
|
-
indigo: [
|
|
1078
|
-
"#eef2ff",
|
|
1079
|
-
"#e0e7ff",
|
|
1080
|
-
"#c6d2ff",
|
|
1081
|
-
"#a3b3ff",
|
|
1082
|
-
"#7c86ff",
|
|
1083
|
-
"#615fff",
|
|
1084
|
-
"#4f39f6",
|
|
1085
|
-
"#432dd7",
|
|
1086
|
-
"#372aac",
|
|
1087
|
-
"#312c85",
|
|
1088
|
-
"#1e1a4d"
|
|
1089
|
-
],
|
|
1090
|
-
violet: [
|
|
1091
|
-
"#f5f3ff",
|
|
1092
|
-
"#ede9fe",
|
|
1093
|
-
"#ddd6ff",
|
|
1094
|
-
"#c4b4ff",
|
|
1095
|
-
"#a684ff",
|
|
1096
|
-
"#8e51ff",
|
|
1097
|
-
"#7f22fe",
|
|
1098
|
-
"#7008e7",
|
|
1099
|
-
"#5d0ec0",
|
|
1100
|
-
"#4d179a",
|
|
1101
|
-
"#2f0d68"
|
|
1102
|
-
],
|
|
1103
|
-
purple: [
|
|
1104
|
-
"#faf5ff",
|
|
1105
|
-
"#f3e8ff",
|
|
1106
|
-
"#e9d4ff",
|
|
1107
|
-
"#dab2ff",
|
|
1108
|
-
"#c27aff",
|
|
1109
|
-
"#ad46ff",
|
|
1110
|
-
"#9810fa",
|
|
1111
|
-
"#8200db",
|
|
1112
|
-
"#6e11b0",
|
|
1113
|
-
"#59168b",
|
|
1114
|
-
"#3c0366"
|
|
1115
|
-
],
|
|
1116
|
-
fuchsia: [
|
|
1117
|
-
"#fdf4ff",
|
|
1118
|
-
"#fae8ff",
|
|
1119
|
-
"#f6cfff",
|
|
1120
|
-
"#f4a8ff",
|
|
1121
|
-
"#ed6aff",
|
|
1122
|
-
"#e12afb",
|
|
1123
|
-
"#c800de",
|
|
1124
|
-
"#a800b7",
|
|
1125
|
-
"#8a0194",
|
|
1126
|
-
"#721378",
|
|
1127
|
-
"#4b004f"
|
|
1128
|
-
],
|
|
1129
|
-
pink: [
|
|
1130
|
-
"#fdf2f8",
|
|
1131
|
-
"#fce7f3",
|
|
1132
|
-
"#fccee8",
|
|
1133
|
-
"#fda5d5",
|
|
1134
|
-
"#fb64b6",
|
|
1135
|
-
"#f6339a",
|
|
1136
|
-
"#e60076",
|
|
1137
|
-
"#c6005c",
|
|
1138
|
-
"#a3004c",
|
|
1139
|
-
"#861043",
|
|
1140
|
-
"#510424"
|
|
1141
|
-
],
|
|
1142
|
-
rose: [
|
|
1143
|
-
"#fff1f2",
|
|
1144
|
-
"#ffe4e6",
|
|
1145
|
-
"#ffccd3",
|
|
1146
|
-
"#ffa1ad",
|
|
1147
|
-
"#ff637e",
|
|
1148
|
-
"#ff2056",
|
|
1149
|
-
"#ec003f",
|
|
1150
|
-
"#c70036",
|
|
1151
|
-
"#a50036",
|
|
1152
|
-
"#8b0836",
|
|
1153
|
-
"#4d0218"
|
|
1154
|
-
]
|
|
1155
|
-
};
|
|
1156
|
-
function createTailwindV4DefaultColorThemeCss() {
|
|
1157
|
-
const declarations = [" --color-black: #000;", " --color-white: #fff;"];
|
|
1158
|
-
for (const [color, values] of Object.entries(TAILWIND_V4_COLOR_PALETTE)) for (let index = 0; index < TAILWIND_V4_COLOR_STEPS.length; index++) declarations.push(` --color-${color}-${TAILWIND_V4_COLOR_STEPS[index]}: ${values[index]};`);
|
|
1159
|
-
return [
|
|
1160
|
-
"@theme {",
|
|
1161
|
-
...declarations,
|
|
1162
|
-
"}"
|
|
1163
|
-
].join("\n");
|
|
1164
|
-
}
|
|
1165
|
-
//#endregion
|
|
1166
|
-
//#region src/tailwindcss/v4-engine/generator.ts
|
|
1167
|
-
function findLeadingImportInsertionIndex(css) {
|
|
1168
|
-
const importPattern = /(?:^|\n)\s*@import\b[^;]*;/g;
|
|
1169
|
-
let insertionIndex = 0;
|
|
1170
|
-
let match = importPattern.exec(css);
|
|
1171
|
-
while (match !== null) {
|
|
1172
|
-
insertionIndex = match.index + match[0].length;
|
|
1173
|
-
match = importPattern.exec(css);
|
|
1174
|
-
}
|
|
1175
|
-
return insertionIndex;
|
|
1176
|
-
}
|
|
1177
|
-
function applyMiniProgramTailwindV4DefaultColorCss(css) {
|
|
1178
|
-
const themeCss = createTailwindV4DefaultColorThemeCss();
|
|
1179
|
-
const insertionIndex = findLeadingImportInsertionIndex(css);
|
|
1180
|
-
if (insertionIndex === 0) return `${themeCss}\n${css}`;
|
|
1181
|
-
return `${css.slice(0, insertionIndex)}\n${themeCss}\n${css.slice(insertionIndex)}`;
|
|
1182
|
-
}
|
|
1183
|
-
function parseImportSourceParam(params) {
|
|
1184
|
-
const match = /\bsource\(\s*(none|(['"])(.*?)\2)\s*\)/.exec(params);
|
|
1185
|
-
if (!match) return;
|
|
1186
|
-
return {
|
|
1187
|
-
none: match[1] === "none",
|
|
1188
|
-
sourcePath: match[3]
|
|
1189
|
-
};
|
|
1190
|
-
}
|
|
1191
|
-
function isTailwindCssImport(params) {
|
|
1192
|
-
return /^\s*(['"])tailwindcss(?:\/[^'"]*)?\1/.test(params);
|
|
1193
|
-
}
|
|
1194
|
-
function parseCssImportSpecifier$1(params) {
|
|
1195
|
-
const value = params.trim();
|
|
1196
|
-
const quoted = /^(['"])(.*?)\1/.exec(value);
|
|
1197
|
-
if (quoted) return quoted[2];
|
|
1198
|
-
const url = /^url\(\s*(?:(['"])(.*?)\1|([^'")\s]+))\s*\)/.exec(value);
|
|
1199
|
-
return url?.[2] ?? url?.[3];
|
|
1200
|
-
}
|
|
1201
|
-
function isTailwindCssPreflightImport(params) {
|
|
1202
|
-
const specifier = parseCssImportSpecifier$1(params);
|
|
1203
|
-
return specifier === "tailwindcss/preflight.css" || specifier === "tailwindcss/preflight";
|
|
1204
|
-
}
|
|
1205
|
-
function hasImportLayerOption(params) {
|
|
1206
|
-
return /\blayer(?:\s*\(|\s*$)/.test(params);
|
|
1207
|
-
}
|
|
1208
|
-
function removeUnlayeredTailwindV4PreflightImports(css) {
|
|
1209
|
-
if (!css.includes("preflight")) return css;
|
|
1210
|
-
let root;
|
|
1211
|
-
try {
|
|
1212
|
-
root = postcss.default.parse(css);
|
|
1213
|
-
} catch {
|
|
1214
|
-
return css;
|
|
1215
|
-
}
|
|
1216
|
-
let changed = false;
|
|
1217
|
-
root.walkAtRules("import", (rule) => {
|
|
1218
|
-
if (isTailwindCssPreflightImport(rule.params) && !hasImportLayerOption(rule.params)) {
|
|
1219
|
-
rule.remove();
|
|
1220
|
-
changed = true;
|
|
1221
|
-
}
|
|
1222
|
-
});
|
|
1223
|
-
return changed ? root.toString() : css;
|
|
1224
|
-
}
|
|
1225
|
-
function parseSourceFileParam(params) {
|
|
1226
|
-
const value = params.trim();
|
|
1227
|
-
if (!value || value === "none" || value.startsWith("inline(")) return;
|
|
1228
|
-
const negated = value.startsWith("not ");
|
|
1229
|
-
const sourceValue = negated ? value.slice(4).trim() : value;
|
|
1230
|
-
if (sourceValue.startsWith("inline(")) return;
|
|
1231
|
-
const match = /^(['"])(.+)\1$/.exec(sourceValue);
|
|
1232
|
-
return match?.[2] ? {
|
|
1233
|
-
negated,
|
|
1234
|
-
pattern: match[2]
|
|
1235
|
-
} : void 0;
|
|
1236
|
-
}
|
|
1237
|
-
function resolveSourceBase(base, sourcePath) {
|
|
1238
|
-
return node_path.default.isAbsolute(sourcePath) ? sourcePath : node_path.default.resolve(base, sourcePath);
|
|
1239
|
-
}
|
|
1240
|
-
function resolveCssDefinedScanSources(source) {
|
|
1241
|
-
let importSourceBase;
|
|
1242
|
-
let hasSourceNone = false;
|
|
1243
|
-
const sourcePatterns = [];
|
|
1244
|
-
const from = source.dependencies[0];
|
|
1245
|
-
let root;
|
|
1246
|
-
try {
|
|
1247
|
-
root = postcss.default.parse(source.css, { from });
|
|
1248
|
-
} catch {
|
|
1249
|
-
return;
|
|
1250
|
-
}
|
|
1251
|
-
root.walkAtRules((rule) => {
|
|
1252
|
-
if (rule.name === "import") {
|
|
1253
|
-
if (!isTailwindCssImport(rule.params)) return;
|
|
1254
|
-
const sourceParam = parseImportSourceParam(rule.params);
|
|
1255
|
-
if (sourceParam?.none) hasSourceNone = true;
|
|
1256
|
-
if (sourceParam?.sourcePath) importSourceBase = resolveSourceBase(source.base, sourceParam.sourcePath);
|
|
1257
|
-
return;
|
|
1258
|
-
}
|
|
1259
|
-
if (rule.name !== "source") return;
|
|
1260
|
-
const sourcePattern = parseSourceFileParam(rule.params);
|
|
1261
|
-
if (!sourcePattern) return;
|
|
1262
|
-
sourcePatterns.push({
|
|
1263
|
-
base: source.base,
|
|
1264
|
-
negated: sourcePattern.negated,
|
|
1265
|
-
pattern: sourcePattern.pattern
|
|
1266
|
-
});
|
|
1267
|
-
});
|
|
1268
|
-
if (!importSourceBase) {
|
|
1269
|
-
if (hasSourceNone) return sourcePatterns.length > 0 ? sourcePatterns : false;
|
|
1270
|
-
return;
|
|
1271
|
-
}
|
|
1272
|
-
return [{
|
|
1273
|
-
base: importSourceBase,
|
|
1274
|
-
negated: false,
|
|
1275
|
-
pattern: "**/*"
|
|
1276
|
-
}, ...sourcePatterns];
|
|
1277
|
-
}
|
|
1278
|
-
function resolveScanSources(source, scanSources) {
|
|
1279
|
-
if (scanSources !== true) return scanSources;
|
|
1280
|
-
return resolveCssDefinedScanSources(source) ?? scanSources;
|
|
1281
|
-
}
|
|
1282
|
-
function hasThemeParent(rule) {
|
|
1283
|
-
let parent = rule.parent;
|
|
1284
|
-
while (parent) {
|
|
1285
|
-
if (parent.type === "atrule" && parent.name === "theme") return true;
|
|
1286
|
-
parent = parent.parent;
|
|
1287
|
-
}
|
|
1288
|
-
return false;
|
|
1289
|
-
}
|
|
1290
|
-
function isVendorPrefixedKeyframes(rule) {
|
|
1291
|
-
return rule.name.startsWith("-") && rule.name.endsWith("keyframes");
|
|
1292
|
-
}
|
|
1293
|
-
function removeUnsupportedThemeVendorKeyframes(css) {
|
|
1294
|
-
if (!css.includes("@theme") || !css.includes("@-")) return css;
|
|
1295
|
-
let root;
|
|
1296
|
-
try {
|
|
1297
|
-
root = postcss.default.parse(css);
|
|
1298
|
-
} catch {
|
|
1299
|
-
return css;
|
|
1300
|
-
}
|
|
1301
|
-
let changed = false;
|
|
1302
|
-
root.walkAtRules((rule) => {
|
|
1303
|
-
if (isVendorPrefixedKeyframes(rule) && hasThemeParent(rule)) {
|
|
1304
|
-
rule.remove();
|
|
1305
|
-
changed = true;
|
|
1306
|
-
}
|
|
1307
|
-
});
|
|
1308
|
-
return changed ? root.toString() : css;
|
|
1309
|
-
}
|
|
1310
|
-
function createTailwindV4Engine(source) {
|
|
1311
|
-
async function generate(options = {}) {
|
|
1312
|
-
const { scanSources = true, styleOptions, tailwindcssV3Compatibility, target = "weapp", ...patchOptions } = options;
|
|
1313
|
-
const shouldApplyTailwindV3Compatibility = tailwindcssV3Compatibility ?? target === "weapp";
|
|
1314
|
-
const filteredSourceCss = target === "weapp" ? removeUnlayeredTailwindV4PreflightImports(source.css) : source.css;
|
|
1315
|
-
const compatibleSourceCss = removeUnsupportedThemeVendorKeyframes(shouldApplyTailwindV3Compatibility ? applyTailwindV3CompatibilityCss(filteredSourceCss) : target === "weapp" ? applyMiniProgramTailwindV4DefaultColorCss(filteredSourceCss) : filteredSourceCss);
|
|
1316
|
-
const candidates = target === "weapp" ? filterUnsupportedMiniProgramTailwindV4Candidates(patchOptions.candidates) : patchOptions.candidates;
|
|
1317
|
-
const result = await (0, tailwindcss_patch.createTailwindV4Engine)(compatibleSourceCss === source.css ? source : {
|
|
1318
|
-
...source,
|
|
1319
|
-
css: compatibleSourceCss
|
|
1320
|
-
}).generate(require_cache.omitUndefined({
|
|
1321
|
-
scanSources: resolveScanSources(source, scanSources),
|
|
1322
|
-
...patchOptions,
|
|
1323
|
-
candidates
|
|
1324
|
-
}));
|
|
1325
|
-
const rawCss = result.css;
|
|
1326
|
-
const css = await transformTailwindV4CssByTarget(rawCss, target, styleOptions);
|
|
1327
|
-
return {
|
|
1328
|
-
...result,
|
|
1329
|
-
css,
|
|
1330
|
-
rawCss,
|
|
1331
|
-
target
|
|
1332
|
-
};
|
|
1333
|
-
}
|
|
1334
|
-
return {
|
|
1335
|
-
source,
|
|
1336
|
-
loadDesignSystem: (0, tailwindcss_patch.createTailwindV4Engine)(source).loadDesignSystem,
|
|
1337
|
-
validateCandidates: (0, tailwindcss_patch.createTailwindV4Engine)(source).validateCandidates,
|
|
1338
|
-
generate
|
|
1339
|
-
};
|
|
1340
|
-
}
|
|
1341
|
-
//#endregion
|
|
1342
|
-
//#region src/tailwindcss/v4-engine/source.ts
|
|
1343
|
-
function isPostcssPluginImportTarget(value) {
|
|
1344
|
-
if (!value) return false;
|
|
1345
|
-
return value === "@tailwindcss/postcss" || value.includes("/postcss");
|
|
1346
|
-
}
|
|
1347
|
-
function uniqueDefined(values) {
|
|
1348
|
-
return [...new Set(values.filter((value) => typeof value === "string" && value.length > 0))];
|
|
1349
|
-
}
|
|
1350
|
-
function getProjectRoot(patcher) {
|
|
1351
|
-
return patcher.options?.projectRoot ?? node_process.default.cwd();
|
|
1352
|
-
}
|
|
1353
|
-
function readConfiguredV4Base(tailwindOptions) {
|
|
1354
|
-
const v4 = tailwindOptions?.v4;
|
|
1355
|
-
if (typeof v4 !== "object" || v4 === null) return;
|
|
1356
|
-
return v4.configuredBase;
|
|
1357
|
-
}
|
|
1358
|
-
function isBarePackageSpecifier(specifier) {
|
|
1359
|
-
return !specifier.startsWith(".") && !specifier.startsWith("/") && !specifier.includes("\\") && !/^[a-z][a-z\d+.-]*:/i.test(specifier);
|
|
1360
|
-
}
|
|
1361
|
-
function parseCssImportSpecifier(params) {
|
|
1362
|
-
const value = params.trim();
|
|
1363
|
-
const quoted = /^(['"])(.*?)\1/.exec(value);
|
|
1364
|
-
if (quoted) {
|
|
1365
|
-
const specifier = quoted[2];
|
|
1366
|
-
if (specifier === void 0) return;
|
|
1367
|
-
return {
|
|
1368
|
-
quote: quoted[1],
|
|
1369
|
-
raw: quoted[0],
|
|
1370
|
-
specifier
|
|
1371
|
-
};
|
|
1372
|
-
}
|
|
1373
|
-
const url = /^url\(\s*(?:(['"])(.*?)\1|([^'")\s]+))\s*\)/.exec(value);
|
|
1374
|
-
if (!url) return;
|
|
1375
|
-
const specifier = url[2] ?? url[3];
|
|
1376
|
-
if (specifier === void 0) return;
|
|
1377
|
-
return {
|
|
1378
|
-
quote: url[1],
|
|
1379
|
-
raw: url[0],
|
|
1380
|
-
specifier
|
|
1381
|
-
};
|
|
1382
|
-
}
|
|
1383
|
-
function quoteCssImportSpecifier(specifier, quote = "\"") {
|
|
1384
|
-
return `${quote}${specifier.replaceAll("\\", "\\\\").replaceAll(quote, `\\${quote}`)}${quote}`;
|
|
1385
|
-
}
|
|
1386
|
-
function createTailwindV4CssImportSpecifierSet(packageName) {
|
|
1387
|
-
const specifiers = new Set(["tailwindcss"]);
|
|
1388
|
-
if (packageName && isBarePackageSpecifier(packageName)) specifiers.add(packageName);
|
|
1389
|
-
return specifiers;
|
|
1390
|
-
}
|
|
1391
|
-
function normalizeTailwindV4CssPackageImports(css, packageName) {
|
|
1392
|
-
if (!css.includes("tailwindcss")) return css;
|
|
1393
|
-
let root;
|
|
1394
|
-
try {
|
|
1395
|
-
root = postcss.default.parse(css);
|
|
1396
|
-
} catch {
|
|
1397
|
-
return css;
|
|
1398
|
-
}
|
|
1399
|
-
const importSpecifiers = createTailwindV4CssImportSpecifierSet(packageName);
|
|
1400
|
-
let changed = false;
|
|
1401
|
-
root.walkAtRules("import", (rule) => {
|
|
1402
|
-
const parsed = parseCssImportSpecifier(rule.params);
|
|
1403
|
-
if (!parsed || !importSpecifiers.has(parsed.specifier)) return;
|
|
1404
|
-
rule.params = rule.params.replace(parsed.raw, quoteCssImportSpecifier(`${parsed.specifier}/index.css`, parsed.quote));
|
|
1405
|
-
changed = true;
|
|
1406
|
-
});
|
|
1407
|
-
return changed ? root.toString() : css;
|
|
1408
|
-
}
|
|
1409
|
-
function resolveTailwindCssImportTarget(patcher) {
|
|
1410
|
-
const configuredPackageName = require_cache.resolveTailwindcssOptions(patcher.options)?.packageName;
|
|
1411
|
-
if (typeof configuredPackageName === "string" && configuredPackageName.length > 0 && !isPostcssPluginImportTarget(configuredPackageName)) return configuredPackageName;
|
|
1412
|
-
const packageName = patcher.packageInfo?.name;
|
|
1413
|
-
if (typeof packageName === "string" && packageName.length > 0 && !isPostcssPluginImportTarget(packageName)) return packageName;
|
|
1414
|
-
return "tailwindcss";
|
|
1415
|
-
}
|
|
1416
|
-
function resolveTailwindV4SourceOptionsFromPatcher(patcher) {
|
|
1417
|
-
const projectRoot = getProjectRoot(patcher);
|
|
1418
|
-
const tailwindOptions = require_cache.resolveTailwindcssOptions(patcher.options);
|
|
1419
|
-
const configDir = tailwindOptions?.config ? node_path.default.dirname(tailwindOptions.config) : void 0;
|
|
1420
|
-
const configuredBase = readConfiguredV4Base(tailwindOptions);
|
|
1421
|
-
const hasCssEntries = Boolean(tailwindOptions?.v4?.cssEntries?.length);
|
|
1422
|
-
return require_cache.omitUndefined({
|
|
1423
|
-
projectRoot,
|
|
1424
|
-
base: configuredBase ?? (hasCssEntries ? void 0 : tailwindOptions?.v4?.base),
|
|
1425
|
-
baseFallbacks: uniqueDefined([tailwindOptions?.cwd, configDir]),
|
|
1426
|
-
css: tailwindOptions?.v4?.css,
|
|
1427
|
-
cssSources: tailwindOptions?.v4?.cssSources,
|
|
1428
|
-
cssEntries: tailwindOptions?.v4?.cssEntries,
|
|
1429
|
-
sources: tailwindOptions?.v4?.sources,
|
|
1430
|
-
packageName: resolveTailwindCssImportTarget(patcher)
|
|
1431
|
-
});
|
|
1432
|
-
}
|
|
1433
|
-
function resolveTailwindV4Source(options) {
|
|
1434
|
-
return (0, tailwindcss_patch.resolveTailwindV4Source)(options?.css === void 0 ? options : {
|
|
1435
|
-
...options,
|
|
1436
|
-
css: normalizeTailwindV4CssPackageImports(options.css, options.packageName)
|
|
1437
|
-
});
|
|
1438
|
-
}
|
|
1439
|
-
async function resolveTailwindV4SourceFromPatcher(patcher) {
|
|
1440
|
-
return resolveTailwindV4Source(resolveTailwindV4SourceOptionsFromPatcher(patcher));
|
|
1441
|
-
}
|
|
1442
|
-
//#endregion
|
|
1443
|
-
//#region src/generator/options.ts
|
|
1444
|
-
function normalizeWeappTailwindcssGeneratorOptions(options) {
|
|
1445
|
-
if (options == null) return {
|
|
1446
|
-
target: "weapp",
|
|
1447
|
-
importFallback: true,
|
|
1448
|
-
tailwindcssV3Compatibility: true
|
|
1449
|
-
};
|
|
1450
|
-
return {
|
|
1451
|
-
target: options.target ?? "weapp",
|
|
1452
|
-
config: options.config,
|
|
1453
|
-
styleOptions: options.styleOptions,
|
|
1454
|
-
importFallback: options.importFallback ?? true,
|
|
1455
|
-
tailwindcssV3Compatibility: options.tailwindcssV3Compatibility ?? (options.target ?? "weapp") === "weapp"
|
|
1456
|
-
};
|
|
1457
|
-
}
|
|
1458
|
-
//#endregion
|
|
1459
|
-
//#region src/generator/index.ts
|
|
1460
|
-
function isTailwindV3Source(source) {
|
|
1461
|
-
return "version" in source && source.version === 3;
|
|
1462
|
-
}
|
|
1463
|
-
function createWeappTailwindcssGenerator(source) {
|
|
1464
|
-
return isTailwindV3Source(source) ? createTailwindV3Engine(source) : createTailwindV4Engine(source);
|
|
1465
|
-
}
|
|
1466
|
-
async function resolveTailwindSourceFromPatcher(patcher) {
|
|
1467
|
-
return patcher.majorVersion === 3 ? resolveTailwindV3SourceFromPatcher(patcher) : resolveTailwindV4SourceFromPatcher(patcher);
|
|
1468
|
-
}
|
|
1469
|
-
async function createWeappTailwindcssGeneratorFromPatcher(patcher) {
|
|
1470
|
-
return createWeappTailwindcssGenerator(await resolveTailwindSourceFromPatcher(patcher));
|
|
1471
|
-
}
|
|
1472
|
-
//#endregion
|
|
1473
|
-
Object.defineProperty(exports, "createWeappTailwindcssGenerator", {
|
|
1474
|
-
enumerable: true,
|
|
1475
|
-
get: function() {
|
|
1476
|
-
return createWeappTailwindcssGenerator;
|
|
1477
|
-
}
|
|
1478
|
-
});
|
|
1479
|
-
Object.defineProperty(exports, "createWeappTailwindcssGeneratorFromPatcher", {
|
|
1480
|
-
enumerable: true,
|
|
1481
|
-
get: function() {
|
|
1482
|
-
return createWeappTailwindcssGeneratorFromPatcher;
|
|
1483
|
-
}
|
|
1484
|
-
});
|
|
1485
|
-
Object.defineProperty(exports, "filterUnsupportedMiniProgramTailwindV4Candidates", {
|
|
1486
|
-
enumerable: true,
|
|
1487
|
-
get: function() {
|
|
1488
|
-
return filterUnsupportedMiniProgramTailwindV4Candidates;
|
|
1489
|
-
}
|
|
1490
|
-
});
|
|
1491
|
-
Object.defineProperty(exports, "normalizeWeappTailwindcssGeneratorOptions", {
|
|
1492
|
-
enumerable: true,
|
|
1493
|
-
get: function() {
|
|
1494
|
-
return normalizeWeappTailwindcssGeneratorOptions;
|
|
1495
|
-
}
|
|
1496
|
-
});
|
|
1497
|
-
Object.defineProperty(exports, "removeUnsupportedCascadeLayers", {
|
|
1498
|
-
enumerable: true,
|
|
1499
|
-
get: function() {
|
|
1500
|
-
return removeUnsupportedCascadeLayers;
|
|
1501
|
-
}
|
|
1502
|
-
});
|
|
1503
|
-
Object.defineProperty(exports, "resolveTailwindSourceFromPatcher", {
|
|
1504
|
-
enumerable: true,
|
|
1505
|
-
get: function() {
|
|
1506
|
-
return resolveTailwindSourceFromPatcher;
|
|
1507
|
-
}
|
|
1508
|
-
});
|
|
1509
|
-
Object.defineProperty(exports, "resolveTailwindV3Source", {
|
|
1510
|
-
enumerable: true,
|
|
1511
|
-
get: function() {
|
|
1512
|
-
return resolveTailwindV3Source;
|
|
1513
|
-
}
|
|
1514
|
-
});
|
|
1515
|
-
Object.defineProperty(exports, "resolveTailwindV3SourceFromPatcher", {
|
|
1516
|
-
enumerable: true,
|
|
1517
|
-
get: function() {
|
|
1518
|
-
return resolveTailwindV3SourceFromPatcher;
|
|
1519
|
-
}
|
|
1520
|
-
});
|
|
1521
|
-
Object.defineProperty(exports, "resolveTailwindV3SourceOptionsFromPatcher", {
|
|
1522
|
-
enumerable: true,
|
|
1523
|
-
get: function() {
|
|
1524
|
-
return resolveTailwindV3SourceOptionsFromPatcher;
|
|
1525
|
-
}
|
|
1526
|
-
});
|
|
1527
|
-
Object.defineProperty(exports, "resolveTailwindV4Source", {
|
|
1528
|
-
enumerable: true,
|
|
1529
|
-
get: function() {
|
|
1530
|
-
return resolveTailwindV4Source;
|
|
1531
|
-
}
|
|
1532
|
-
});
|
|
1533
|
-
Object.defineProperty(exports, "resolveTailwindV4SourceFromPatcher", {
|
|
1534
|
-
enumerable: true,
|
|
1535
|
-
get: function() {
|
|
1536
|
-
return resolveTailwindV4SourceFromPatcher;
|
|
1537
|
-
}
|
|
1538
|
-
});
|
|
1539
|
-
Object.defineProperty(exports, "resolveTailwindV4SourceOptionsFromPatcher", {
|
|
1540
|
-
enumerable: true,
|
|
1541
|
-
get: function() {
|
|
1542
|
-
return resolveTailwindV4SourceOptionsFromPatcher;
|
|
1543
|
-
}
|
|
1544
|
-
});
|
|
1545
|
-
Object.defineProperty(exports, "transformTailwindV3CssByTarget", {
|
|
1546
|
-
enumerable: true,
|
|
1547
|
-
get: function() {
|
|
1548
|
-
return transformTailwindV3CssByTarget;
|
|
1549
|
-
}
|
|
1550
|
-
});
|
|
1551
|
-
Object.defineProperty(exports, "transformTailwindV3CssToWeapp", {
|
|
1552
|
-
enumerable: true,
|
|
1553
|
-
get: function() {
|
|
1554
|
-
return transformTailwindV3CssToWeapp;
|
|
1555
|
-
}
|
|
1556
|
-
});
|
|
1557
|
-
Object.defineProperty(exports, "transformTailwindV4CssByTarget", {
|
|
1558
|
-
enumerable: true,
|
|
1559
|
-
get: function() {
|
|
1560
|
-
return transformTailwindV4CssByTarget;
|
|
1561
|
-
}
|
|
1562
|
-
});
|
|
1563
|
-
Object.defineProperty(exports, "transformTailwindV4CssToWeapp", {
|
|
1564
|
-
enumerable: true,
|
|
1565
|
-
get: function() {
|
|
1566
|
-
return transformTailwindV4CssToWeapp;
|
|
1567
|
-
}
|
|
1568
|
-
});
|