weapp-tailwindcss 5.1.4 → 5.1.6
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.en.md +1 -1
- package/README.md +1 -1
- package/dist/bundlers/shared/generator-css/generation-helpers.d.ts +8 -2
- package/dist/bundlers/shared/generator-css/source-resolver/metadata.d.ts +5 -1
- package/dist/bundlers/shared/generator-css/types.d.ts +1 -0
- package/dist/bundlers/shared/generator-css/user-css.d.ts +4 -1
- package/dist/bundlers/vite/generate-bundle/finalize.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/remembered-css-replay.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/tailwind-v4-css-source.d.ts +6 -3
- package/dist/bundlers/vite/hot-css-modules.d.ts +1 -0
- package/dist/bundlers/vite/processed-css-assets.d.ts +7 -0
- package/dist/bundlers/vite/source-scan/css-entries.d.ts +1 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers.d.ts +2 -1
- package/dist/cli.js +18 -3
- package/dist/cli.mjs +16 -1
- package/dist/{context-Bkpmt3ja.mjs → context-3GGqW9vw.mjs} +20 -5
- package/dist/{context-DCVMkTRj.js → context-BCSk_YnL.js} +23 -8
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/css-macro/index.d.ts +2 -1
- package/dist/{defaults-BhE26nSw.mjs → defaults-9B6aMyZb.mjs} +2 -2
- package/dist/{defaults-DQhgnnn-.js → defaults-nsf4VNMX.js} +2 -2
- package/dist/defaults.d.ts +1 -1
- package/dist/defaults.js +1 -1
- package/dist/defaults.mjs +1 -1
- package/dist/{generator-24-HgU9F.mjs → generator-CoT5vu9w.mjs} +2 -2
- package/dist/{generator-CilgHtxb.js → generator-CqWzj2Z1.js} +2 -2
- package/dist/generator.js +2 -2
- package/dist/generator.mjs +2 -2
- package/dist/{gulp-0RsqkF_d.mjs → gulp-Bss4wJ8t.mjs} +4 -4
- package/dist/{gulp-Bogfnoki.js → gulp-hXE1U4Cu.js} +4 -4
- package/dist/gulp.js +1 -1
- package/dist/gulp.mjs +1 -1
- package/dist/{hmr-timing-BRNaz8Od.mjs → hmr-timing-Cfu-4Bnf.mjs} +229 -576
- package/dist/{hmr-timing-BV6nFPoT.js → hmr-timing-Df4203aI.js} +253 -630
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- package/dist/js/js-string-escape.d.ts +1 -0
- package/dist/postcss.js +2 -2
- package/dist/postcss.mjs +2 -2
- package/dist/presets.js +6 -3
- package/dist/presets.mjs +6 -3
- package/dist/rspack.js +1 -1
- package/dist/rspack.mjs +1 -1
- package/dist/runtime-branch/generator-target-env.d.ts +1 -0
- package/dist/{source-candidate-scan-signature-CaDT0gkj.js → source-candidate-scan-signature-5Uk6U72B.js} +168 -5
- package/dist/{source-candidate-scan-signature-BB1hvW68.mjs → source-candidate-scan-signature-BbCmW975.mjs} +157 -6
- package/dist/style-injector/internal.d.ts +7 -0
- package/dist/style-injector/options.d.ts +25 -0
- package/dist/tailwindcss/v4/preflight.d.ts +4 -0
- package/dist/{tailwindcss-D0JF0fuZ.mjs → tailwindcss-Bjr3aphG.mjs} +62 -15
- package/dist/{tailwindcss-D2xs4OEu.js → tailwindcss-DYJ3HZD2.js} +67 -14
- package/dist/{transform-BP86eSZp.mjs → transform--155BmeJ.mjs} +1 -1
- package/dist/{transform-CXCQ28Tc.js → transform-B6_y_yCB.js} +1 -1
- package/dist/typedoc.export.d.ts +1 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/user-defined-options/general.d.ts +2 -0
- package/dist/{v4-engine-CKtsdKxK.js → v4-engine-C9cmNlP8.js} +610 -3
- package/dist/{v4-engine-BuuYDXt1.mjs → v4-engine-DRQaCFMm.mjs} +529 -6
- package/dist/{vite-BYgT1ir9.js → vite-Baw9qNrc.js} +652 -140
- package/dist/{vite-B1SlBmqO.mjs → vite-PdxjaqhO.mjs} +653 -141
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.js +2981 -2752
- package/dist/{webpack-Bg6pefpb.mjs → webpack-BffTDmod.mjs} +69 -26
- package/dist/{webpack-khSwkXP5.js → webpack-C9u7mfGE.js} +74 -31
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +16 -5
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-emK7D4bc.js");
|
|
2
|
-
const require_v4_engine = require("./v4-engine-
|
|
3
|
-
const require_generator = require("./generator-
|
|
4
|
-
const require_context = require("./context-
|
|
5
|
-
const require_tailwindcss = require("./tailwindcss-
|
|
2
|
+
const require_v4_engine = require("./v4-engine-C9cmNlP8.js");
|
|
3
|
+
const require_generator = require("./generator-CqWzj2Z1.js");
|
|
4
|
+
const require_context = require("./context-BCSk_YnL.js");
|
|
5
|
+
const require_tailwindcss = require("./tailwindcss-DYJ3HZD2.js");
|
|
6
6
|
let node_fs = require("node:fs");
|
|
7
7
|
let node_path = require("node:path");
|
|
8
8
|
node_path = require_rolldown_runtime.__toESM(node_path);
|
|
@@ -156,24 +156,94 @@ function collectGeneratedRawSourceCandidates(candidates, rawSource, escapeMap) {
|
|
|
156
156
|
return matched;
|
|
157
157
|
}
|
|
158
158
|
//#endregion
|
|
159
|
+
//#region src/bundlers/shared/generator-css/source-resolver/postcss-source.ts
|
|
160
|
+
function resolvePostcssFromOption(cssHandlerOptions) {
|
|
161
|
+
const from = cssHandlerOptions.postcssOptions?.options?.from;
|
|
162
|
+
return typeof from === "string" && from.length > 0 ? from : void 0;
|
|
163
|
+
}
|
|
164
|
+
function resolvePostcssSourceFile(cssHandlerOptions) {
|
|
165
|
+
const from = resolvePostcssFromOption(cssHandlerOptions);
|
|
166
|
+
if (!from || !node_path.default.isAbsolute(from)) return;
|
|
167
|
+
return from.replace(/[?#].*$/, "");
|
|
168
|
+
}
|
|
169
|
+
function resolveCssHandlerSourceOptions(cssHandlerOptions) {
|
|
170
|
+
return cssHandlerOptions.sourceOptions;
|
|
171
|
+
}
|
|
172
|
+
function resolveCssSourceBase(file, cssHandlerOptions) {
|
|
173
|
+
const normalized = (resolvePostcssFromOption(cssHandlerOptions) ?? file).replace(/[?#].*$/, "");
|
|
174
|
+
return node_path.default.dirname(node_path.default.resolve(normalized));
|
|
175
|
+
}
|
|
176
|
+
//#endregion
|
|
159
177
|
//#region src/bundlers/shared/generator-css/generation-helpers.ts
|
|
178
|
+
function isVueScopedStyleSource(from) {
|
|
179
|
+
if (typeof from !== "string" || from.length === 0) return false;
|
|
180
|
+
const queryIndex = from.indexOf("?");
|
|
181
|
+
if (queryIndex === -1) return false;
|
|
182
|
+
const query = from.slice(queryIndex + 1);
|
|
183
|
+
return /(?:^|&)type=style(?:&|$)/.test(query) && /(?:^|&)scoped(?:=(?:true|1))?(?:&|$)/.test(query);
|
|
184
|
+
}
|
|
160
185
|
function hasMiniProgramTailwindV4PreflightReset(css) {
|
|
161
186
|
return /(?:^|[},])\s*view\s*,\s*text\s*,\s*::after\s*,\s*::before\s*\{[^}]*\bborder\s*:\s*0\s+solid\b/.test(css);
|
|
162
187
|
}
|
|
188
|
+
function isMiniProgramGeneratorTarget(target) {
|
|
189
|
+
return target !== "web";
|
|
190
|
+
}
|
|
163
191
|
function finalizeMiniProgramGeneratorCss(css, target, _majorVersion, cssPreflight, options = {}) {
|
|
164
|
-
if (target
|
|
165
|
-
|
|
192
|
+
if (!isMiniProgramGeneratorTarget(target)) return css;
|
|
193
|
+
if (isVueScopedStyleSource(options.styleOptions?.postcssOptions?.options?.from)) return (0, _weapp_tailwindcss_postcss.finalizeMiniProgramCss)(css, {
|
|
194
|
+
cssPreflight: false,
|
|
195
|
+
cssSelectorReplacement: options.styleOptions?.cssOptions?.cssSelectorReplacement ?? options.styleOptions?.cssSelectorReplacement,
|
|
196
|
+
isTailwindcssV4: true,
|
|
197
|
+
tailwindcssV4GradientFallback: options.styleOptions?.cssOptions?.tailwindcssV4GradientFallback ?? options.styleOptions?.tailwindcssV4GradientFallback
|
|
198
|
+
});
|
|
199
|
+
const hasPreflightReset = hasMiniProgramTailwindV4PreflightReset(css);
|
|
200
|
+
const injectPreflight = options.injectPreflight !== false && !hasPreflightReset;
|
|
201
|
+
const preservePreflight = options.preservePreflight !== false;
|
|
166
202
|
return (0, _weapp_tailwindcss_postcss.finalizeMiniProgramCss)(css, {
|
|
167
|
-
cssPreflight: cssPreflight === false ? false : injectPreflight ? cssPreflight : void 0,
|
|
203
|
+
cssPreflight: cssPreflight === false || options.injectPreflight === false && (!hasPreflightReset || !preservePreflight) ? false : injectPreflight ? cssPreflight : hasPreflightReset && preservePreflight ? cssPreflight : void 0,
|
|
168
204
|
cssSelectorReplacement: options.styleOptions?.cssOptions?.cssSelectorReplacement ?? options.styleOptions?.cssSelectorReplacement,
|
|
169
205
|
isTailwindcssV4: true,
|
|
170
206
|
tailwindcssV4GradientFallback: options.styleOptions?.cssOptions?.tailwindcssV4GradientFallback ?? options.styleOptions?.tailwindcssV4GradientFallback
|
|
171
207
|
});
|
|
172
208
|
}
|
|
173
|
-
function
|
|
174
|
-
if (options.cssHandlerOptions
|
|
175
|
-
|
|
176
|
-
|
|
209
|
+
function resolveMiniProgramPreflightModeForGeneratorCss(opts, options) {
|
|
210
|
+
if (isVueScopedStyleSource(resolvePostcssFromOption(options.cssHandlerOptions))) return {
|
|
211
|
+
inject: false,
|
|
212
|
+
preserve: false
|
|
213
|
+
};
|
|
214
|
+
if (options.cssHandlerOptions.uniAppX === true && options.cssHandlerOptions.uniAppXCssTarget === "uvue") return {
|
|
215
|
+
inject: false,
|
|
216
|
+
preserve: false
|
|
217
|
+
};
|
|
218
|
+
const shouldInjectUniAppXLocalImportPreflight = require_tailwindcss.isUniAppXEnabled(opts.uniAppX) && Boolean(options.localImports?.trim());
|
|
219
|
+
if (opts.cssPreflight === false) return {
|
|
220
|
+
inject: false,
|
|
221
|
+
preserve: false
|
|
222
|
+
};
|
|
223
|
+
if (options.primaryCssSource) return {
|
|
224
|
+
inject: true,
|
|
225
|
+
preserve: true
|
|
226
|
+
};
|
|
227
|
+
if (options.explicitCssSource) return {
|
|
228
|
+
inject: false,
|
|
229
|
+
preserve: true
|
|
230
|
+
};
|
|
231
|
+
if (options.cssHandlerOptions.isMainChunk) return {
|
|
232
|
+
inject: true,
|
|
233
|
+
preserve: true
|
|
234
|
+
};
|
|
235
|
+
if (!options.cssHandlerOptions.isMainChunk && !options.primaryCssSource && !options.explicitCssSource) return {
|
|
236
|
+
inject: shouldInjectUniAppXLocalImportPreflight,
|
|
237
|
+
preserve: shouldInjectUniAppXLocalImportPreflight
|
|
238
|
+
};
|
|
239
|
+
if (!options.isolateCurrentCssCandidates) return {
|
|
240
|
+
inject: true,
|
|
241
|
+
preserve: true
|
|
242
|
+
};
|
|
243
|
+
return {
|
|
244
|
+
inject: shouldInjectUniAppXLocalImportPreflight,
|
|
245
|
+
preserve: shouldInjectUniAppXLocalImportPreflight
|
|
246
|
+
};
|
|
177
247
|
}
|
|
178
248
|
function mergeScopedRuntimeWithCurrentRuntime(scopedRuntime, runtime, options) {
|
|
179
249
|
if (options.isolateCssSource) {
|
|
@@ -207,9 +277,10 @@ function isEmptyCssSourceOrderParts(parts) {
|
|
|
207
277
|
}
|
|
208
278
|
function resolveGeneratorStyleOptions(opts, cssHandlerOptions, generatorStyleOptions) {
|
|
209
279
|
const resolvedStyleOptions = require_context.resolveStyleOptionsFromContext(opts);
|
|
280
|
+
const scopedVueStyleSource = isVueScopedStyleSource(resolvePostcssFromOption(cssHandlerOptions));
|
|
210
281
|
const preflightStyleOptions = {
|
|
211
|
-
cssPreflight: resolvedStyleOptions.cssPreflight,
|
|
212
|
-
cssPreflightRange: resolvedStyleOptions.cssPreflightRange
|
|
282
|
+
cssPreflight: scopedVueStyleSource ? false : resolvedStyleOptions.cssPreflight,
|
|
283
|
+
cssPreflightRange: scopedVueStyleSource ? void 0 : resolvedStyleOptions.cssPreflightRange
|
|
213
284
|
};
|
|
214
285
|
return {
|
|
215
286
|
...resolvedStyleOptions,
|
|
@@ -830,8 +901,9 @@ function withGeneratorSourceMetadata(source, metadata) {
|
|
|
830
901
|
__weappTailwindcssMeta: metadata
|
|
831
902
|
};
|
|
832
903
|
}
|
|
833
|
-
function withMatchedSourceSideMetadata(source, resolvedEntrySource) {
|
|
904
|
+
function withMatchedSourceSideMetadata(source, resolvedEntrySource, metadata = {}) {
|
|
834
905
|
return resolvedEntrySource.file ? withGeneratorSourceMetadata(source, {
|
|
906
|
+
...metadata,
|
|
835
907
|
isolateCssSource: true,
|
|
836
908
|
matchedCssSourceFile: resolvedEntrySource.file,
|
|
837
909
|
sourceBase: resolvedEntrySource.base,
|
|
@@ -839,24 +911,6 @@ function withMatchedSourceSideMetadata(source, resolvedEntrySource) {
|
|
|
839
911
|
}) : source;
|
|
840
912
|
}
|
|
841
913
|
//#endregion
|
|
842
|
-
//#region src/bundlers/shared/generator-css/source-resolver/postcss-source.ts
|
|
843
|
-
function resolvePostcssFromOption(cssHandlerOptions) {
|
|
844
|
-
const from = cssHandlerOptions.postcssOptions?.options?.from;
|
|
845
|
-
return typeof from === "string" && from.length > 0 ? from : void 0;
|
|
846
|
-
}
|
|
847
|
-
function resolvePostcssSourceFile(cssHandlerOptions) {
|
|
848
|
-
const from = resolvePostcssFromOption(cssHandlerOptions);
|
|
849
|
-
if (!from || !node_path.default.isAbsolute(from)) return;
|
|
850
|
-
return from.replace(/[?#].*$/, "");
|
|
851
|
-
}
|
|
852
|
-
function resolveCssHandlerSourceOptions(cssHandlerOptions) {
|
|
853
|
-
return cssHandlerOptions.sourceOptions;
|
|
854
|
-
}
|
|
855
|
-
function resolveCssSourceBase(file, cssHandlerOptions) {
|
|
856
|
-
const normalized = (resolvePostcssFromOption(cssHandlerOptions) ?? file).replace(/[?#].*$/, "");
|
|
857
|
-
return node_path.default.dirname(node_path.default.resolve(normalized));
|
|
858
|
-
}
|
|
859
|
-
//#endregion
|
|
860
914
|
//#region src/bundlers/shared/generator-css/source-resolver.ts
|
|
861
915
|
function createCssEntrySources(cssEntries) {
|
|
862
916
|
return cssEntries?.filter((entry) => typeof entry === "string" && entry.length > 0 && node_path.default.isAbsolute(entry)).map((entry) => ({ file: node_path.default.resolve(entry) }));
|
|
@@ -890,11 +944,15 @@ function createSingleTailwindV4SourceOptions(sourceOptions, options) {
|
|
|
890
944
|
cssEntries: options.cssEntries
|
|
891
945
|
});
|
|
892
946
|
}
|
|
893
|
-
async function resolveTailwindV4CssEntrySource(cssEntry, sourceOptions) {
|
|
947
|
+
async function resolveTailwindV4CssEntrySource(cssEntry, sourceOptions, options = {}) {
|
|
894
948
|
const { cssEntries: _cssEntries, cssSources: _cssSources, ...singleEntrySourceOptions } = sourceOptions;
|
|
895
|
-
if (!(0, node_fs.existsSync)(cssEntry)) return require_v4_engine.resolveTailwindV4Source({
|
|
949
|
+
if (!(0, node_fs.existsSync)(cssEntry)) return withGeneratorSourceMetadata(await require_v4_engine.resolveTailwindV4Source({
|
|
896
950
|
...require_v4_engine.omitUndefined(singleEntrySourceOptions),
|
|
897
951
|
cssEntries: [cssEntry]
|
|
952
|
+
}), {
|
|
953
|
+
cssEntryIndex: options.index,
|
|
954
|
+
includesPreflight: options.includesPreflight,
|
|
955
|
+
primaryCssSource: options.index === 0
|
|
898
956
|
});
|
|
899
957
|
const css = (0, node_fs.readFileSync)(cssEntry, "utf8");
|
|
900
958
|
const base = node_path.default.dirname(node_path.default.resolve(cssEntry));
|
|
@@ -909,7 +967,10 @@ async function resolveTailwindV4CssEntrySource(cssEntry, sourceOptions) {
|
|
|
909
967
|
css: require_v4_engine.normalizeConfigDirective(css, config),
|
|
910
968
|
cssEntries: [cssEntry]
|
|
911
969
|
}), {
|
|
970
|
+
cssEntryIndex: options.index,
|
|
971
|
+
includesPreflight: options.includesPreflight,
|
|
912
972
|
matchedCssSourceFile: cssEntry,
|
|
973
|
+
primaryCssSource: options.index === 0,
|
|
913
974
|
sourceBase: base,
|
|
914
975
|
sourceCss: css
|
|
915
976
|
});
|
|
@@ -922,12 +983,15 @@ function canResolveSourceSideCssEntry(file, cssHandlerOptions, sourceOptions) {
|
|
|
922
983
|
function shouldResolveSourceSideCssEntry(rawSource) {
|
|
923
984
|
return rawSource.includes("@apply") || require_v4_engine.hasTailwindRootDirectives(rawSource, { importFallback: true }) || require_v4_engine.hasTailwindSourceDirectives(rawSource, { importFallback: true }) || require_v4_engine.hasTailwindGeneratedCss(rawSource) || require_v4_engine.hasTailwindGeneratedCssMarkers(rawSource);
|
|
924
985
|
}
|
|
925
|
-
function resolveMatchingTailwindV4CssEntry(rawSource, file, sourceOptions) {
|
|
986
|
+
async function resolveMatchingTailwindV4CssEntry(rawSource, file, sourceOptions) {
|
|
926
987
|
const cssEntries = sourceOptions.cssEntries;
|
|
927
988
|
if (!cssEntries?.length) return;
|
|
928
989
|
const normalizedFile = node_path.default.resolve(file.replace(/[?#].*$/, ""));
|
|
929
990
|
const pathMatchedEntries = cssEntries.filter((cssEntry) => node_path.default.resolve(cssEntry.replace(/[?#].*$/, "")) === normalizedFile);
|
|
930
|
-
if (pathMatchedEntries.length === 1) return resolveTailwindV4CssEntrySource(pathMatchedEntries[0], sourceOptions
|
|
991
|
+
if (pathMatchedEntries.length === 1) return resolveTailwindV4CssEntrySource(pathMatchedEntries[0], sourceOptions, {
|
|
992
|
+
includesPreflight: await resolveTailwindV4CssEntryIncludesPreflight(pathMatchedEntries[0]),
|
|
993
|
+
index: cssEntries.indexOf(pathMatchedEntries[0])
|
|
994
|
+
});
|
|
931
995
|
const normalizedRawSource = normalizeCssSourceForCompare(rawSource);
|
|
932
996
|
const matches = cssEntries.map((cssEntry) => {
|
|
933
997
|
if (!(0, node_fs.existsSync)(cssEntry)) return;
|
|
@@ -946,7 +1010,10 @@ function resolveMatchingTailwindV4CssEntry(rawSource, file, sourceOptions) {
|
|
|
946
1010
|
const bestScore = matches[0]?.score;
|
|
947
1011
|
const matchingEntry = bestScore && matches.filter((match) => match.score === bestScore).length === 1 ? matches[0]?.cssEntry : void 0;
|
|
948
1012
|
if (!matchingEntry) return;
|
|
949
|
-
return resolveTailwindV4CssEntrySource(matchingEntry, sourceOptions
|
|
1013
|
+
return resolveTailwindV4CssEntrySource(matchingEntry, sourceOptions, {
|
|
1014
|
+
includesPreflight: await resolveTailwindV4CssEntryIncludesPreflight(matchingEntry),
|
|
1015
|
+
index: cssEntries.indexOf(matchingEntry)
|
|
1016
|
+
});
|
|
950
1017
|
}
|
|
951
1018
|
function normalizeTailwindV4CssSourceConfig(cssSource, sourceBase) {
|
|
952
1019
|
if (typeof cssSource.css !== "string" || cssSource.css.length === 0 || !cssSource.css.includes("@config")) return cssSource;
|
|
@@ -996,7 +1063,7 @@ function normalizeTailwindV4CssSourceConfigs(sourceOptions) {
|
|
|
996
1063
|
cssSources
|
|
997
1064
|
} : sourceOptions;
|
|
998
1065
|
}
|
|
999
|
-
async function resolveMatchingTailwindV4CssSource(rawSource, file, cssHandlerOptions, sourceOptions) {
|
|
1066
|
+
async function resolveMatchingTailwindV4CssSource(rawSource, file, cssHandlerOptions, sourceOptions, selectionOptions) {
|
|
1000
1067
|
const cssSources = sourceOptions.cssSources;
|
|
1001
1068
|
if (!cssSources?.length) return;
|
|
1002
1069
|
const normalizedRawSource = normalizeCssSourceForCompare(rawSource);
|
|
@@ -1017,7 +1084,12 @@ async function resolveMatchingTailwindV4CssSource(rawSource, file, cssHandlerOpt
|
|
|
1017
1084
|
const bestScore = matches[0]?.score;
|
|
1018
1085
|
const matchingSource = bestScore && matches.filter((match) => match.score === bestScore).length === 1 ? matches[0]?.cssSource : void 0;
|
|
1019
1086
|
if (!matchingSource) return;
|
|
1020
|
-
return resolveSingleTailwindV4CssSource(matchingSource, sourceOptions, {
|
|
1087
|
+
return resolveSingleTailwindV4CssSource(matchingSource, sourceOptions, {
|
|
1088
|
+
includesPreflight: await resolveTailwindV4CssSourceEntries(matchingSource, sourceOptions).then((resolved) => resolved?.includesPreflight),
|
|
1089
|
+
index: matches[0]?.index,
|
|
1090
|
+
matched: true,
|
|
1091
|
+
primary: isSameTailwindV4CssSource(matchingSource, selectionOptions?.cssSources?.[0])
|
|
1092
|
+
});
|
|
1021
1093
|
}
|
|
1022
1094
|
function tryResolveTailwindV4SourceOptions(runtimeState) {
|
|
1023
1095
|
try {
|
|
@@ -1029,14 +1101,24 @@ function tryResolveTailwindV4SourceOptions(runtimeState) {
|
|
|
1029
1101
|
function hasConfiguredTailwindV4CssSource(sourceOptions) {
|
|
1030
1102
|
return Boolean(sourceOptions?.css) || Boolean(sourceOptions?.cssSources?.length);
|
|
1031
1103
|
}
|
|
1104
|
+
function isSameTailwindV4CssSource(a, b) {
|
|
1105
|
+
if (!a || !b) return false;
|
|
1106
|
+
if (typeof a.file === "string" && typeof b.file === "string") return node_path.default.resolve(a.file) === node_path.default.resolve(b.file);
|
|
1107
|
+
return typeof a.css === "string" && typeof b.css === "string" && normalizeCssSourceForCompare(a.css) === normalizeCssSourceForCompare(b.css);
|
|
1108
|
+
}
|
|
1032
1109
|
async function resolveSingleTailwindV4CssSource(cssSource, sourceOptions, options = {}) {
|
|
1033
1110
|
const sourceBase = require_v4_engine.resolveTailwindV4CssSourceBase(cssSource, sourceOptions.base ?? sourceOptions.projectRoot ?? node_process.default.cwd());
|
|
1034
1111
|
const normalizedCssSource = normalizeTailwindV4CssSourceConfig(cssSource, sourceBase);
|
|
1035
|
-
|
|
1112
|
+
const source = await require_v4_engine.resolveTailwindV4Source(createSingleTailwindV4SourceOptions(sourceOptions, {
|
|
1036
1113
|
base: sourceBase,
|
|
1037
1114
|
css: normalizedCssSource.css
|
|
1038
|
-
}))
|
|
1115
|
+
}));
|
|
1116
|
+
const resolvedEntries = options.includesPreflight === void 0 ? await resolveTailwindV4CssSourceEntries(normalizedCssSource, sourceOptions) : void 0;
|
|
1117
|
+
return withGeneratorSourceMetadata(source, {
|
|
1118
|
+
cssSourceIndex: options.index,
|
|
1119
|
+
includesPreflight: options.includesPreflight ?? resolvedEntries?.includesPreflight,
|
|
1039
1120
|
matchedCssSourceFile: options.matched && typeof normalizedCssSource.file === "string" ? normalizedCssSource.file : void 0,
|
|
1121
|
+
primaryCssSource: options.primary === true || !sourceOptions.cssEntries?.length && options.index === 0 || void 0,
|
|
1040
1122
|
sourceBase,
|
|
1041
1123
|
sourceCss: normalizedCssSource.css
|
|
1042
1124
|
});
|
|
@@ -1065,6 +1147,47 @@ async function resolveCandidateMatchedTailwindV4CssSource(_rawSource, _cssHandle
|
|
|
1065
1147
|
if (runtimeHits === 0) return;
|
|
1066
1148
|
matches.push({
|
|
1067
1149
|
cssSource,
|
|
1150
|
+
includesPreflight: resolved.includesPreflight,
|
|
1151
|
+
index,
|
|
1152
|
+
runtimeHits,
|
|
1153
|
+
totalCandidates: scopedCandidates.size
|
|
1154
|
+
});
|
|
1155
|
+
}));
|
|
1156
|
+
if (matches.length === 0) return;
|
|
1157
|
+
matches.sort((a, b) => b.runtimeHits - a.runtimeHits || b.totalCandidates - a.totalCandidates || a.index - b.index);
|
|
1158
|
+
const best = matches[0];
|
|
1159
|
+
const second = matches[1];
|
|
1160
|
+
if (!best) return;
|
|
1161
|
+
if (second && second.runtimeHits === best.runtimeHits && second.totalCandidates === best.totalCandidates) return;
|
|
1162
|
+
return resolveSingleTailwindV4CssSource(best.cssSource, sourceOptions, {
|
|
1163
|
+
includesPreflight: best.includesPreflight,
|
|
1164
|
+
index: best.index,
|
|
1165
|
+
matched: true,
|
|
1166
|
+
primary: isSameTailwindV4CssSource(best.cssSource, selectionOptions?.cssSources?.[0])
|
|
1167
|
+
});
|
|
1168
|
+
}
|
|
1169
|
+
async function resolveTailwindV4CssEntryEntries(cssEntry) {
|
|
1170
|
+
if (!(0, node_fs.existsSync)(cssEntry)) return;
|
|
1171
|
+
const file = node_path.default.resolve(cssEntry);
|
|
1172
|
+
return require_tailwindcss.resolveTailwindV4EntriesFromCss((0, node_fs.readFileSync)(file, "utf8"), node_path.default.dirname(file));
|
|
1173
|
+
}
|
|
1174
|
+
async function resolveTailwindV4CssEntryIncludesPreflight(cssEntry) {
|
|
1175
|
+
return resolveTailwindV4CssEntryEntries(cssEntry).then((resolved) => resolved?.includesPreflight);
|
|
1176
|
+
}
|
|
1177
|
+
async function resolveCandidateMatchedTailwindV4CssEntry(sourceOptions, selectionOptions) {
|
|
1178
|
+
const cssEntries = sourceOptions.cssEntries;
|
|
1179
|
+
const getSourceCandidatesForEntries = selectionOptions?.getSourceCandidatesForEntries;
|
|
1180
|
+
if (!cssEntries?.length || !getSourceCandidatesForEntries) return;
|
|
1181
|
+
const matches = [];
|
|
1182
|
+
await Promise.all(cssEntries.map(async (cssEntry, index) => {
|
|
1183
|
+
const resolved = await resolveTailwindV4CssEntryEntries(cssEntry);
|
|
1184
|
+
if (resolved?.entries === void 0) return;
|
|
1185
|
+
const scopedCandidates = getSourceCandidatesForEntries(resolved.entries);
|
|
1186
|
+
const runtimeHits = countRuntimeCandidateHits(scopedCandidates, selectionOptions?.runtime);
|
|
1187
|
+
if (runtimeHits === 0) return;
|
|
1188
|
+
matches.push({
|
|
1189
|
+
cssEntry,
|
|
1190
|
+
includesPreflight: resolved.includesPreflight,
|
|
1068
1191
|
index,
|
|
1069
1192
|
runtimeHits,
|
|
1070
1193
|
totalCandidates: scopedCandidates.size
|
|
@@ -1076,10 +1199,13 @@ async function resolveCandidateMatchedTailwindV4CssSource(_rawSource, _cssHandle
|
|
|
1076
1199
|
const second = matches[1];
|
|
1077
1200
|
if (!best) return;
|
|
1078
1201
|
if (second && second.runtimeHits === best.runtimeHits && second.totalCandidates === best.totalCandidates) return;
|
|
1079
|
-
return
|
|
1202
|
+
return resolveTailwindV4CssEntrySource(best.cssEntry, sourceOptions, {
|
|
1203
|
+
includesPreflight: best.includesPreflight,
|
|
1204
|
+
index: best.index
|
|
1205
|
+
});
|
|
1080
1206
|
}
|
|
1081
1207
|
function createTailwindV4CssSourceResolver(sourceOptions, generatorOptions) {
|
|
1082
|
-
return (cssSource) => resolveSingleTailwindV4CssSource(cssSource, sourceOptions).then((source) => generatorOptions?.config ? {
|
|
1208
|
+
return (cssSource, index) => resolveSingleTailwindV4CssSource(cssSource, sourceOptions, { index }).then((source) => generatorOptions?.config ? {
|
|
1083
1209
|
...source,
|
|
1084
1210
|
css: require_v4_engine.prependConfigDirective(source.css, generatorOptions.config)
|
|
1085
1211
|
} : source);
|
|
@@ -1092,11 +1218,19 @@ async function resolveTailwindV4SourceSideEntrySource(resolvedEntrySource, sourc
|
|
|
1092
1218
|
sourceFile: resolvedEntrySource.file
|
|
1093
1219
|
});
|
|
1094
1220
|
const css = createTailwindV4SourceReferenceSource(require_v4_engine.normalizeConfigDirective(require_v4_engine.prependConfigDirective(resolvedEntrySource.css, generatorOptions?.config), config), resolvedSourceOptions);
|
|
1095
|
-
|
|
1221
|
+
const source = await require_v4_engine.resolveTailwindV4Source(createSingleTailwindV4SourceOptions(resolvedSourceOptions, {
|
|
1096
1222
|
base: resolvedEntrySource.base,
|
|
1097
1223
|
css,
|
|
1098
1224
|
cssEntries: [resolvedEntrySource.file]
|
|
1099
|
-
}))
|
|
1225
|
+
}));
|
|
1226
|
+
const cssEntryIndex = sourceOptions.cssEntries?.findIndex((cssEntry) => typeof resolvedEntrySource.file === "string" && node_path.default.resolve(cssEntry.replace(/[?#].*$/, "")) === node_path.default.resolve(resolvedEntrySource.file));
|
|
1227
|
+
const cssSourceIndex = sourceOptions.cssSources?.findIndex((cssSource) => typeof cssSource.file === "string" && typeof resolvedEntrySource.file === "string" && node_path.default.resolve(cssSource.file.replace(/[?#].*$/, "")) === node_path.default.resolve(resolvedEntrySource.file));
|
|
1228
|
+
return withMatchedSourceSideMetadata(source, resolvedEntrySource, {
|
|
1229
|
+
cssEntryIndex,
|
|
1230
|
+
cssSourceIndex,
|
|
1231
|
+
includesPreflight: (await require_tailwindcss.resolveTailwindV4EntriesFromCss(resolvedEntrySource.css, resolvedEntrySource.base))?.includesPreflight,
|
|
1232
|
+
primaryCssSource: cssEntryIndex === 0 || !sourceOptions.cssEntries?.length && cssSourceIndex === 0
|
|
1233
|
+
});
|
|
1100
1234
|
}
|
|
1101
1235
|
async function resolveGeneratorSource(_majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions, selectionOptions) {
|
|
1102
1236
|
const base = resolveCssSourceBase(file, cssHandlerOptions);
|
|
@@ -1114,7 +1248,7 @@ async function resolveGeneratorSource(_majorVersion, runtimeState, rawSource, fi
|
|
|
1114
1248
|
sourceFile: sourceOptions.sourceFile ?? resolvePostcssSourceFile(cssHandlerOptions),
|
|
1115
1249
|
...resolveCssHandlerSourceOptions(cssHandlerOptions),
|
|
1116
1250
|
cssEntries: selectionOptions?.cssEntries ?? sourceOptions.cssEntries,
|
|
1117
|
-
cssSources: mergeCssSources(sourceOptions.cssSources, sourceOptions.cssSources?.length ? void 0 : createCssEntrySources(selectionOptions?.cssEntries ?? sourceOptions.cssEntries))
|
|
1251
|
+
cssSources: mergeCssSources(mergeCssSources(sourceOptions.cssSources, selectionOptions?.cssSources), sourceOptions.cssSources?.length || selectionOptions?.cssSources?.length ? void 0 : createCssEntrySources(selectionOptions?.cssEntries ?? sourceOptions.cssEntries))
|
|
1118
1252
|
}) : void 0;
|
|
1119
1253
|
const normalizedSourceOptions = resolvedSourceOptions ? normalizeTailwindV4CssSourceConfigs(resolvedSourceOptions) : void 0;
|
|
1120
1254
|
if (applyEntrySource && !cssHandlerOptions.isMainChunk && !require_v4_engine.hasTailwindRootDirectives(rawSource, { importFallback: generatorOptions?.importFallback ?? false })) {
|
|
@@ -1129,16 +1263,20 @@ async function resolveGeneratorSource(_majorVersion, runtimeState, rawSource, fi
|
|
|
1129
1263
|
const sourceSideCssSource = sourceSideEntrySource?.file && normalizedSourceOptions.cssEntries?.some((cssEntry) => node_path.default.resolve(cssEntry.replace(/[?#].*$/, "")) === node_path.default.resolve(sourceSideEntrySource.file)) ? await resolveTailwindV4SourceSideEntrySource(sourceSideEntrySource, normalizedSourceOptions, generatorOptions, file) : void 0;
|
|
1130
1264
|
if (sourceSideCssSource) return sourceSideCssSource;
|
|
1131
1265
|
const matchedCssEntrySource = normalizedSourceOptions ? await resolveMatchingTailwindV4CssEntry(rawSource, file, normalizedSourceOptions) : void 0;
|
|
1132
|
-
const matchedCssSource = normalizedSourceOptions && !matchedCssEntrySource ? await resolveMatchingTailwindV4CssSource(rawSource, file, cssHandlerOptions, normalizedSourceOptions) : void 0;
|
|
1266
|
+
const matchedCssSource = normalizedSourceOptions && !matchedCssEntrySource ? await resolveMatchingTailwindV4CssSource(rawSource, file, cssHandlerOptions, normalizedSourceOptions, selectionOptions) : void 0;
|
|
1267
|
+
const candidateMatchedCssEntrySource = normalizedSourceOptions && !matchedCssEntrySource ? await resolveCandidateMatchedTailwindV4CssEntry(normalizedSourceOptions, selectionOptions) : void 0;
|
|
1133
1268
|
const candidateMatchedCssSource = normalizedSourceOptions && !matchedCssEntrySource ? await resolveCandidateMatchedTailwindV4CssSource(rawSource, cssHandlerOptions, normalizedSourceOptions, selectionOptions) : void 0;
|
|
1134
|
-
const singleConfiguredCssSource = normalizedSourceOptions?.cssSources?.length === 1 ? await resolveSingleTailwindV4CssSource(normalizedSourceOptions.cssSources[0], normalizedSourceOptions, {
|
|
1269
|
+
const singleConfiguredCssSource = normalizedSourceOptions?.cssSources?.length === 1 ? await resolveSingleTailwindV4CssSource(normalizedSourceOptions.cssSources[0], normalizedSourceOptions, {
|
|
1270
|
+
index: 0,
|
|
1271
|
+
matched: true
|
|
1272
|
+
}) : void 0;
|
|
1135
1273
|
const configuredCssSource = normalizedSourceOptions && hasConfiguredTailwindV4CssSource(normalizedSourceOptions) && require_v4_engine.hasTailwindGeneratedCssMarkers(rawSource) ? matchedCssSource ?? candidateMatchedCssSource ?? singleConfiguredCssSource ?? await require_v4_engine.resolveTailwindV4Source(normalizedSourceOptions) : void 0;
|
|
1136
1274
|
if (configuredCssSource) return generatorOptions?.config ? {
|
|
1137
1275
|
...configuredCssSource,
|
|
1138
1276
|
css: require_v4_engine.prependConfigDirective(configuredCssSource.css, generatorOptions.config)
|
|
1139
1277
|
} : configuredCssSource;
|
|
1140
1278
|
const mainCssEntrySource = normalizedSourceOptions && cssHandlerOptions.isMainChunk && normalizedSourceOptions.cssEntries?.length === 1 ? await resolveTailwindV4CssEntrySource(normalizedSourceOptions.cssEntries[0], normalizedSourceOptions) : void 0;
|
|
1141
|
-
const preferredCssEntrySource = matchedCssEntrySource ?? matchedCssSource ?? candidateMatchedCssSource ?? mainCssEntrySource ?? singleConfiguredCssSource;
|
|
1279
|
+
const preferredCssEntrySource = matchedCssEntrySource ?? matchedCssSource ?? candidateMatchedCssEntrySource ?? candidateMatchedCssSource ?? mainCssEntrySource ?? singleConfiguredCssSource;
|
|
1142
1280
|
if (preferredCssEntrySource) return generatorOptions?.config ? {
|
|
1143
1281
|
...preferredCssEntrySource,
|
|
1144
1282
|
css: require_v4_engine.prependConfigDirective(preferredCssEntrySource.css, generatorOptions.config)
|
|
@@ -1194,19 +1332,20 @@ async function resolveGeneratorSources(majorVersion, runtimeState, rawSource, fi
|
|
|
1194
1332
|
} : matchedCssEntrySource, matchedCssEntrySource.__weappTailwindcssMeta?.matchedCssSourceFile, sourceOptions)];
|
|
1195
1333
|
const sourceSideCssSource = await resolveTailwindV4SourceSideEntrySource(canResolveSourceSideCssEntry(file, cssHandlerOptions, sourceOptions) ? resolveSourceSideCssEntrySource(file, sourceOptions, { removeConfig: false }) : void 0, sourceOptions, generatorOptions, file);
|
|
1196
1334
|
if (sourceSideCssSource) return [sourceSideCssSource];
|
|
1197
|
-
const matchedCssSource = await resolveMatchingTailwindV4CssSource(rawSource, file, cssHandlerOptions, sourceOptions);
|
|
1335
|
+
const matchedCssSource = await resolveMatchingTailwindV4CssSource(rawSource, file, cssHandlerOptions, sourceOptions, selectionOptions);
|
|
1336
|
+
const candidateMatchedCssEntrySource = await resolveCandidateMatchedTailwindV4CssEntry(sourceOptions, selectionOptions);
|
|
1198
1337
|
const candidateMatchedCssSource = await resolveCandidateMatchedTailwindV4CssSource(rawSource, cssHandlerOptions, sourceOptions, selectionOptions);
|
|
1199
|
-
const preferredCssEntrySource = matchedCssEntrySource ?? matchedCssSource ?? candidateMatchedCssSource;
|
|
1338
|
+
const preferredCssEntrySource = matchedCssEntrySource ?? matchedCssSource ?? candidateMatchedCssEntrySource ?? candidateMatchedCssSource;
|
|
1200
1339
|
if (preferredCssEntrySource) return [normalizeResolvedTailwindV4SourceConfig(generatorOptions?.config ? {
|
|
1201
1340
|
...preferredCssEntrySource,
|
|
1202
1341
|
css: require_v4_engine.prependConfigDirective(preferredCssEntrySource.css, generatorOptions.config)
|
|
1203
1342
|
} : preferredCssEntrySource, preferredCssEntrySource.__weappTailwindcssMeta?.matchedCssSourceFile, sourceOptions)];
|
|
1204
1343
|
if (!sourceOptions.cssEntries || sourceOptions.cssEntries.length <= 1) {
|
|
1205
|
-
if (cssHandlerOptions.isMainChunk && sourceOptions.cssEntries?.length === 1) return [await resolveTailwindV4CssEntrySource(sourceOptions.cssEntries[0], normalizeTailwindV4CssSourceConfigs(sourceOptions)).then((source) => generatorOptions?.config ? {
|
|
1344
|
+
if (cssHandlerOptions.isMainChunk && sourceOptions.cssEntries?.length === 1) return [await resolveTailwindV4CssEntrySource(sourceOptions.cssEntries[0], normalizeTailwindV4CssSourceConfigs(sourceOptions), { index: 0 }).then((source) => generatorOptions?.config ? {
|
|
1206
1345
|
...source,
|
|
1207
1346
|
css: require_v4_engine.prependConfigDirective(source.css, generatorOptions.config)
|
|
1208
1347
|
} : source)];
|
|
1209
|
-
if (sourceOptions.cssSources?.length === 1) return [normalizeResolvedTailwindV4SourceConfig(await createTailwindV4CssSourceResolver(sourceOptions, generatorOptions)(sourceOptions.cssSources[0]), sourceOptions.cssSources[0]?.file, sourceOptions)];
|
|
1348
|
+
if (sourceOptions.cssSources?.length === 1) return [normalizeResolvedTailwindV4SourceConfig(await createTailwindV4CssSourceResolver(sourceOptions, generatorOptions)(sourceOptions.cssSources[0], 0), sourceOptions.cssSources[0]?.file, sourceOptions)];
|
|
1210
1349
|
const resolved = await resolveGeneratorSource(majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions, selectionOptions);
|
|
1211
1350
|
return resolved ? [resolved] : [];
|
|
1212
1351
|
}
|
|
@@ -1215,7 +1354,7 @@ async function resolveGeneratorSources(majorVersion, runtimeState, rawSource, fi
|
|
|
1215
1354
|
return resolved ? [resolved] : [];
|
|
1216
1355
|
}
|
|
1217
1356
|
const normalizedCssSourceOptions = normalizeTailwindV4CssSourceConfigs(sourceOptions);
|
|
1218
|
-
const cssEntrySources = await Promise.all(sourceOptions.cssEntries.map((cssEntry) => resolveTailwindV4CssEntrySource(cssEntry, normalizedCssSourceOptions).then((source) => generatorOptions?.config ? {
|
|
1357
|
+
const cssEntrySources = await Promise.all(sourceOptions.cssEntries.map((cssEntry, index) => resolveTailwindV4CssEntrySource(cssEntry, normalizedCssSourceOptions, { index }).then((source) => generatorOptions?.config ? {
|
|
1219
1358
|
...source,
|
|
1220
1359
|
css: require_v4_engine.prependConfigDirective(source.css, generatorOptions.config)
|
|
1221
1360
|
} : source)));
|
|
@@ -1249,501 +1388,6 @@ async function resolveGeneratorSourceEntries(source, runtimeState) {
|
|
|
1249
1388
|
return resolved?.entries;
|
|
1250
1389
|
}
|
|
1251
1390
|
//#endregion
|
|
1252
|
-
//#region src/bundlers/shared/generator-css/user-css.ts
|
|
1253
|
-
const TAILWIND_V4_GENERATOR_AT_RULES = /* @__PURE__ */ new Set([
|
|
1254
|
-
"config",
|
|
1255
|
-
"custom-variant",
|
|
1256
|
-
"plugin",
|
|
1257
|
-
"source",
|
|
1258
|
-
"theme",
|
|
1259
|
-
"utility",
|
|
1260
|
-
"variant"
|
|
1261
|
-
]);
|
|
1262
|
-
function removeBalancedAtRuleBlock(source, atRuleStart) {
|
|
1263
|
-
const blockStart = source.indexOf("{", atRuleStart);
|
|
1264
|
-
if (blockStart === -1) {
|
|
1265
|
-
const semicolon = source.indexOf(";", atRuleStart);
|
|
1266
|
-
return semicolon === -1 ? source.slice(0, atRuleStart) : `${source.slice(0, atRuleStart)}${source.slice(semicolon + 1)}`;
|
|
1267
|
-
}
|
|
1268
|
-
let depth = 0;
|
|
1269
|
-
for (let index = blockStart; index < source.length; index++) {
|
|
1270
|
-
const char = source[index];
|
|
1271
|
-
if (char === "{") {
|
|
1272
|
-
depth++;
|
|
1273
|
-
continue;
|
|
1274
|
-
}
|
|
1275
|
-
if (char !== "}") continue;
|
|
1276
|
-
depth--;
|
|
1277
|
-
if (depth === 0) return `${source.slice(0, atRuleStart)}${source.slice(index + 1)}`;
|
|
1278
|
-
}
|
|
1279
|
-
return source.slice(0, atRuleStart);
|
|
1280
|
-
}
|
|
1281
|
-
function removeTailwindV4GeneratorAtRulesFallback(source) {
|
|
1282
|
-
let next = source;
|
|
1283
|
-
let changed = false;
|
|
1284
|
-
const sourceMediaRE = /@media\s+source\([^)]*\)\s*\{/g;
|
|
1285
|
-
for (;;) {
|
|
1286
|
-
sourceMediaRE.lastIndex = 0;
|
|
1287
|
-
const match = sourceMediaRE.exec(next);
|
|
1288
|
-
if (!match) break;
|
|
1289
|
-
next = removeBalancedAtRuleBlock(next, match.index);
|
|
1290
|
-
changed = true;
|
|
1291
|
-
}
|
|
1292
|
-
const atRuleRE = /@(?:config|custom-variant|plugin|source|theme|utility|variant)\b/g;
|
|
1293
|
-
for (;;) {
|
|
1294
|
-
atRuleRE.lastIndex = 0;
|
|
1295
|
-
const match = atRuleRE.exec(next);
|
|
1296
|
-
if (!match) break;
|
|
1297
|
-
next = removeBalancedAtRuleBlock(next, match.index);
|
|
1298
|
-
changed = true;
|
|
1299
|
-
}
|
|
1300
|
-
return changed ? next : source;
|
|
1301
|
-
}
|
|
1302
|
-
function isTailwindGeneratedPreflightComment(text) {
|
|
1303
|
-
return text.includes("cssremedy") || text.includes("Use the user's configured") || text.includes("tailwindlabs/tailwindcss") || text.includes("Prevent padding and border from affecting element width") || text.includes("Remove default margins and padding") || text.includes("Deprecated") || text.includes("Reset all borders") || text.includes("Add the correct text decoration") || text.includes("Make elements with the HTML hidden attribute stay hidden") || text.includes("Inherit font styles in all browsers") || text.includes("Add the correct height in Firefox") || text.includes("Remove the default font size and weight for headings") || text.includes("Reset links to optimize for opt-in styling") || text.includes("Add the correct font weight in Edge and Safari") || text.includes("Use the user's configured `mono` font-family") || text.includes("Add the correct font size in all browsers") || text.includes("Prevent `sub` and `sup` elements from affecting the line height") || text.includes("Remove text indentation from table contents") || text.includes("Use the modern Firefox focus style") || text.includes("Add the correct vertical alignment") || text.includes("Add the correct display") || text.includes("Make lists unstyled by default") || text.includes("Make replaced elements `display: block` by default") || text.includes("Constrain images and videos to the parent width") || text.includes("Restore default font weight") || text.includes("Restore indentation") || text.includes("Restore space after button") || text.includes("Prevent resizing textareas horizontally") || text.includes("Remove the inner padding in Chrome and Safari") || text.includes("Ensure date/time inputs have the same height") || text.includes("Prevent height from changing on date/time inputs") || text.includes("Remove excess padding from pseudo-elements") || text.includes("Center dropdown marker shown on inputs") || text.includes("Remove the additional `:invalid` styles") || text.includes("Correct the inability to style the border radius") || text.includes("Correct the cursor style of increment and decrement buttons");
|
|
1304
|
-
}
|
|
1305
|
-
function isTailwindGeneratedThemeRule(selector, node) {
|
|
1306
|
-
if (!/(?:^|,)\s*(?::host|page|\.tw-root|wx-root-portal-content)\b/.test(selector)) return false;
|
|
1307
|
-
return node.nodes?.some((child) => child.type === "decl" && /^--(?:color|spacing|text|font|default|radius|tw-)/.test(child.prop)) ?? false;
|
|
1308
|
-
}
|
|
1309
|
-
function isTailwindGeneratedPreflightRule(selector, node) {
|
|
1310
|
-
if (selector === "view,text,::after,::before" || selector === "view, text, ::after, ::before" || selector === "*" || selector === "::after" || selector === "::before" || selector === "::backdrop" || selector === ":host" || selector === "[hidden]:not([hidden=\"until-found\"])" || selector === "[hidden]:not([hidden='until-found'])" || selector === "button,input[type=\"button\"],input[type=\"reset\"],input[type=\"submit\"]" || selector === "button, input[type=\"button\"], input[type=\"reset\"], input[type=\"submit\"]" || selector === "button,input[type='button'],input[type='reset'],input[type='submit']" || selector === "button, input[type='button'], input[type='reset'], input[type='submit']") return true;
|
|
1311
|
-
if (selector === "abbr[title]") return node.nodes?.some((child) => child.type === "decl" && child.prop === "text-decoration") ?? false;
|
|
1312
|
-
if (selector === ":host") return node.nodes?.some((child) => child.type === "decl" && child.value?.includes("--theme(")) ?? false;
|
|
1313
|
-
return false;
|
|
1314
|
-
}
|
|
1315
|
-
function removeTailwindV4GeneratedUserCssArtifacts(source) {
|
|
1316
|
-
try {
|
|
1317
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
1318
|
-
let changed = false;
|
|
1319
|
-
root.walkComments((comment) => {
|
|
1320
|
-
if (!isTailwindGeneratedPreflightComment(comment.text)) return;
|
|
1321
|
-
comment.remove();
|
|
1322
|
-
changed = true;
|
|
1323
|
-
});
|
|
1324
|
-
root.walkRules((rule) => {
|
|
1325
|
-
const selector = rule.selector.replace(/\s+/g, " ").trim();
|
|
1326
|
-
if (isTailwindGeneratedThemeRule(selector, rule) || isTailwindGeneratedPreflightRule(selector, rule)) {
|
|
1327
|
-
rule.remove();
|
|
1328
|
-
changed = true;
|
|
1329
|
-
}
|
|
1330
|
-
});
|
|
1331
|
-
root.walkAtRules((rule) => {
|
|
1332
|
-
if (rule.nodes !== void 0 && rule.nodes.length === 0) {
|
|
1333
|
-
rule.remove();
|
|
1334
|
-
changed = true;
|
|
1335
|
-
}
|
|
1336
|
-
});
|
|
1337
|
-
return changed ? root.toString() : source;
|
|
1338
|
-
} catch {
|
|
1339
|
-
return source;
|
|
1340
|
-
}
|
|
1341
|
-
}
|
|
1342
|
-
function removeTailwindSourceMediaBlocks(source) {
|
|
1343
|
-
let next = source;
|
|
1344
|
-
let changed = false;
|
|
1345
|
-
const sourceMediaRE = /@media\s+source\([^)]*\)\s*\{/g;
|
|
1346
|
-
for (;;) {
|
|
1347
|
-
sourceMediaRE.lastIndex = 0;
|
|
1348
|
-
const match = sourceMediaRE.exec(next);
|
|
1349
|
-
if (!match) break;
|
|
1350
|
-
const blockStart = next.indexOf("{", match.index);
|
|
1351
|
-
if (blockStart === -1) break;
|
|
1352
|
-
let depth = 0;
|
|
1353
|
-
let blockEnd = -1;
|
|
1354
|
-
for (let index = blockStart; index < next.length; index++) {
|
|
1355
|
-
const char = next[index];
|
|
1356
|
-
if (char === "{") {
|
|
1357
|
-
depth++;
|
|
1358
|
-
continue;
|
|
1359
|
-
}
|
|
1360
|
-
if (char !== "}") continue;
|
|
1361
|
-
depth--;
|
|
1362
|
-
if (depth === 0) {
|
|
1363
|
-
blockEnd = index;
|
|
1364
|
-
break;
|
|
1365
|
-
}
|
|
1366
|
-
}
|
|
1367
|
-
if (blockEnd === -1) break;
|
|
1368
|
-
next = `${next.slice(0, match.index)}${next.slice(blockEnd + 1)}`;
|
|
1369
|
-
changed = true;
|
|
1370
|
-
}
|
|
1371
|
-
for (;;) {
|
|
1372
|
-
const atRuleStart = findTailwindSourceWrapperBlockStart(next);
|
|
1373
|
-
if (atRuleStart === -1) break;
|
|
1374
|
-
next = removeBalancedAtRuleBlock(next, atRuleStart);
|
|
1375
|
-
changed = true;
|
|
1376
|
-
}
|
|
1377
|
-
return changed ? next : source;
|
|
1378
|
-
}
|
|
1379
|
-
function terminateTailwindSourceAtRulesBeforeNextDirective(source) {
|
|
1380
|
-
if (!source.includes("@source")) return source;
|
|
1381
|
-
let next = "";
|
|
1382
|
-
let searchIndex = 0;
|
|
1383
|
-
for (;;) {
|
|
1384
|
-
const atRuleStart = source.indexOf("@source", searchIndex);
|
|
1385
|
-
if (atRuleStart === -1) {
|
|
1386
|
-
next += source.slice(searchIndex);
|
|
1387
|
-
break;
|
|
1388
|
-
}
|
|
1389
|
-
const nextChar = source[atRuleStart + 7];
|
|
1390
|
-
if (nextChar && /[\w-]/.test(nextChar)) {
|
|
1391
|
-
next += source.slice(searchIndex, atRuleStart + 7);
|
|
1392
|
-
searchIndex = atRuleStart + 7;
|
|
1393
|
-
continue;
|
|
1394
|
-
}
|
|
1395
|
-
next += source.slice(searchIndex, atRuleStart);
|
|
1396
|
-
let quote;
|
|
1397
|
-
let parenDepth = 0;
|
|
1398
|
-
let terminated = false;
|
|
1399
|
-
let index = atRuleStart + 7;
|
|
1400
|
-
for (; index < source.length; index++) {
|
|
1401
|
-
const char = source[index];
|
|
1402
|
-
if (quote) {
|
|
1403
|
-
if (char === "\\") {
|
|
1404
|
-
index++;
|
|
1405
|
-
continue;
|
|
1406
|
-
}
|
|
1407
|
-
if (char === quote) quote = void 0;
|
|
1408
|
-
continue;
|
|
1409
|
-
}
|
|
1410
|
-
if (char === "\"" || char === "'") {
|
|
1411
|
-
quote = char;
|
|
1412
|
-
continue;
|
|
1413
|
-
}
|
|
1414
|
-
if (char === "(") {
|
|
1415
|
-
parenDepth++;
|
|
1416
|
-
continue;
|
|
1417
|
-
}
|
|
1418
|
-
if (char === ")" && parenDepth > 0) {
|
|
1419
|
-
parenDepth--;
|
|
1420
|
-
continue;
|
|
1421
|
-
}
|
|
1422
|
-
if (parenDepth > 0) continue;
|
|
1423
|
-
if (char === ";" || char === "{") {
|
|
1424
|
-
terminated = true;
|
|
1425
|
-
index++;
|
|
1426
|
-
break;
|
|
1427
|
-
}
|
|
1428
|
-
if (char === "@" && /^(?:config|custom-variant|plugin|source|theme|utility|variant)\b/.test(source.slice(index + 1))) break;
|
|
1429
|
-
}
|
|
1430
|
-
const segment = source.slice(atRuleStart, index);
|
|
1431
|
-
const trimmedSegment = segment.trimEnd();
|
|
1432
|
-
next += terminated || trimmedSegment.endsWith(";") || trimmedSegment.endsWith("{") ? segment : `${trimmedSegment};${segment.slice(trimmedSegment.length)}`;
|
|
1433
|
-
searchIndex = index;
|
|
1434
|
-
}
|
|
1435
|
-
return next;
|
|
1436
|
-
}
|
|
1437
|
-
function findTailwindSourceWrapperBlockStart(source) {
|
|
1438
|
-
let searchIndex = 0;
|
|
1439
|
-
for (;;) {
|
|
1440
|
-
const atRuleStart = source.indexOf("@source", searchIndex);
|
|
1441
|
-
if (atRuleStart === -1) return -1;
|
|
1442
|
-
const nextChar = source[atRuleStart + 7];
|
|
1443
|
-
if (nextChar && /[\w-]/.test(nextChar)) {
|
|
1444
|
-
searchIndex = atRuleStart + 7;
|
|
1445
|
-
continue;
|
|
1446
|
-
}
|
|
1447
|
-
let quote;
|
|
1448
|
-
let parenDepth = 0;
|
|
1449
|
-
for (let index = atRuleStart + 7; index < source.length; index++) {
|
|
1450
|
-
const char = source[index];
|
|
1451
|
-
if (quote) {
|
|
1452
|
-
if (char === "\\") {
|
|
1453
|
-
index++;
|
|
1454
|
-
continue;
|
|
1455
|
-
}
|
|
1456
|
-
if (char === quote) quote = void 0;
|
|
1457
|
-
continue;
|
|
1458
|
-
}
|
|
1459
|
-
if (char === "\"" || char === "'") {
|
|
1460
|
-
quote = char;
|
|
1461
|
-
continue;
|
|
1462
|
-
}
|
|
1463
|
-
if (char === "(") {
|
|
1464
|
-
parenDepth++;
|
|
1465
|
-
continue;
|
|
1466
|
-
}
|
|
1467
|
-
if (char === ")" && parenDepth > 0) {
|
|
1468
|
-
parenDepth--;
|
|
1469
|
-
continue;
|
|
1470
|
-
}
|
|
1471
|
-
if (parenDepth > 0) continue;
|
|
1472
|
-
if (char === ";") {
|
|
1473
|
-
searchIndex = index + 1;
|
|
1474
|
-
break;
|
|
1475
|
-
}
|
|
1476
|
-
if (char === "{") return atRuleStart;
|
|
1477
|
-
}
|
|
1478
|
-
if (searchIndex <= atRuleStart) return -1;
|
|
1479
|
-
}
|
|
1480
|
-
}
|
|
1481
|
-
function removeTailwindApplyAtRules(source) {
|
|
1482
|
-
if (!source.includes("@apply")) return source;
|
|
1483
|
-
try {
|
|
1484
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
1485
|
-
let changed = false;
|
|
1486
|
-
root.walkAtRules("apply", (rule) => {
|
|
1487
|
-
rule.remove();
|
|
1488
|
-
changed = true;
|
|
1489
|
-
});
|
|
1490
|
-
root.walk((node) => {
|
|
1491
|
-
if ("nodes" in node && node.nodes?.length === 0) node.remove();
|
|
1492
|
-
});
|
|
1493
|
-
return changed ? root.toString() : source;
|
|
1494
|
-
} catch {
|
|
1495
|
-
return source;
|
|
1496
|
-
}
|
|
1497
|
-
}
|
|
1498
|
-
function removeTailwindV4GeneratorAtRules(source) {
|
|
1499
|
-
try {
|
|
1500
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
1501
|
-
let changed = false;
|
|
1502
|
-
root.walkAtRules((rule) => {
|
|
1503
|
-
if (rule.name === "media" && /^source\(/.test(rule.params.trim())) {
|
|
1504
|
-
rule.remove();
|
|
1505
|
-
changed = true;
|
|
1506
|
-
return;
|
|
1507
|
-
}
|
|
1508
|
-
if (!TAILWIND_V4_GENERATOR_AT_RULES.has(rule.name)) return;
|
|
1509
|
-
rule.remove();
|
|
1510
|
-
changed = true;
|
|
1511
|
-
});
|
|
1512
|
-
return changed ? root.toString() : source;
|
|
1513
|
-
} catch {
|
|
1514
|
-
return removeTailwindV4GeneratorAtRulesFallback(source);
|
|
1515
|
-
}
|
|
1516
|
-
}
|
|
1517
|
-
function isCommentOnlyCss(source) {
|
|
1518
|
-
try {
|
|
1519
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
1520
|
-
return root.nodes.length > 0 && root.nodes.every((node) => node.type === "comment");
|
|
1521
|
-
} catch {
|
|
1522
|
-
return false;
|
|
1523
|
-
}
|
|
1524
|
-
}
|
|
1525
|
-
function removeMiniProgramHoverSelectors(source, enabled = true) {
|
|
1526
|
-
if (!enabled || !source.includes(":hover")) return source;
|
|
1527
|
-
try {
|
|
1528
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
1529
|
-
let changed = false;
|
|
1530
|
-
root.walkRules((rule) => {
|
|
1531
|
-
const selectors = rule.selectors ?? [rule.selector];
|
|
1532
|
-
const keptSelectors = selectors.filter((selector) => !selector.includes(":hover"));
|
|
1533
|
-
if (keptSelectors.length === selectors.length) return;
|
|
1534
|
-
changed = true;
|
|
1535
|
-
if (keptSelectors.length === 0) {
|
|
1536
|
-
rule.remove();
|
|
1537
|
-
return;
|
|
1538
|
-
}
|
|
1539
|
-
rule.selectors = keptSelectors;
|
|
1540
|
-
});
|
|
1541
|
-
root.walk((node) => {
|
|
1542
|
-
if ("nodes" in node && node.nodes?.length === 0) {
|
|
1543
|
-
node.remove();
|
|
1544
|
-
changed = true;
|
|
1545
|
-
}
|
|
1546
|
-
});
|
|
1547
|
-
return changed ? root.toString() : source;
|
|
1548
|
-
} catch {
|
|
1549
|
-
return source;
|
|
1550
|
-
}
|
|
1551
|
-
}
|
|
1552
|
-
function removeProcessedMiniProgramUnsupportedCss(source, options) {
|
|
1553
|
-
return removeMiniProgramHoverSelectors((0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(source), options.cssRemoveHoverPseudoClass);
|
|
1554
|
-
}
|
|
1555
|
-
function unwrapMiniProgramCascadeLayers(source) {
|
|
1556
|
-
if (!source.includes("@layer")) return source;
|
|
1557
|
-
try {
|
|
1558
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
1559
|
-
(0, _weapp_tailwindcss_postcss.removeUnsupportedCascadeLayers)(root);
|
|
1560
|
-
return root.toString();
|
|
1561
|
-
} catch {
|
|
1562
|
-
return source;
|
|
1563
|
-
}
|
|
1564
|
-
}
|
|
1565
|
-
function stripTailwindSourceMediaFragments(source) {
|
|
1566
|
-
let removedSourceMediaStart = false;
|
|
1567
|
-
return terminateTailwindSourceAtRulesBeforeNextDirective(removeTailwindSourceMediaBlocks(source)).split(/\r?\n/).filter((line) => {
|
|
1568
|
-
if (/^\s*@media\s+source\([^)]*\)\s*\{\s*$/.test(line)) {
|
|
1569
|
-
removedSourceMediaStart = true;
|
|
1570
|
-
return false;
|
|
1571
|
-
}
|
|
1572
|
-
if (/^\s*\}\s*\/\*\s*source\([^)]*\)\s*\*\/\s*$/.test(line)) return false;
|
|
1573
|
-
if (removedSourceMediaStart && /^\s*\}\s*$/.test(line)) {
|
|
1574
|
-
removedSourceMediaStart = false;
|
|
1575
|
-
return false;
|
|
1576
|
-
}
|
|
1577
|
-
return true;
|
|
1578
|
-
}).join("\n");
|
|
1579
|
-
}
|
|
1580
|
-
function stripLeadingTailwindSourceMediaCloseFragment(source) {
|
|
1581
|
-
return source.replace(/^\s*\}\s*(?:\n|$)/, "");
|
|
1582
|
-
}
|
|
1583
|
-
function stripUnmatchedTailwindSourceMediaCloseFragments(source) {
|
|
1584
|
-
try {
|
|
1585
|
-
_weapp_tailwindcss_postcss.postcss.parse(source);
|
|
1586
|
-
return source;
|
|
1587
|
-
} catch {
|
|
1588
|
-
return stripLeadingTailwindSourceMediaCloseFragment(source).replace(/\s*\}\s*$/, "");
|
|
1589
|
-
}
|
|
1590
|
-
}
|
|
1591
|
-
function splitUserCssLayerBlocks(source) {
|
|
1592
|
-
if (!source.includes("@layer")) return {
|
|
1593
|
-
layer: "",
|
|
1594
|
-
rest: source
|
|
1595
|
-
};
|
|
1596
|
-
try {
|
|
1597
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
1598
|
-
const layerRoot = _weapp_tailwindcss_postcss.postcss.root();
|
|
1599
|
-
const restRoot = _weapp_tailwindcss_postcss.postcss.root();
|
|
1600
|
-
for (const node of root.nodes) (node.type === "atrule" && node.name === "layer" && node.nodes?.length ? layerRoot : restRoot).append(node.clone());
|
|
1601
|
-
return {
|
|
1602
|
-
layer: layerRoot.toString(),
|
|
1603
|
-
rest: restRoot.toString()
|
|
1604
|
-
};
|
|
1605
|
-
} catch {
|
|
1606
|
-
return {
|
|
1607
|
-
layer: source,
|
|
1608
|
-
rest: ""
|
|
1609
|
-
};
|
|
1610
|
-
}
|
|
1611
|
-
}
|
|
1612
|
-
function hasUserCssLayerBlocks(source) {
|
|
1613
|
-
if (!source.includes("@layer")) return false;
|
|
1614
|
-
try {
|
|
1615
|
-
let hasLayerBlock = false;
|
|
1616
|
-
_weapp_tailwindcss_postcss.postcss.parse(source).walkAtRules("layer", (node) => {
|
|
1617
|
-
if (node.nodes?.length) hasLayerBlock = true;
|
|
1618
|
-
});
|
|
1619
|
-
return hasLayerBlock;
|
|
1620
|
-
} catch {
|
|
1621
|
-
return true;
|
|
1622
|
-
}
|
|
1623
|
-
}
|
|
1624
|
-
function collectUserLayerSelectors(source) {
|
|
1625
|
-
const selectors = /* @__PURE__ */ new Set();
|
|
1626
|
-
try {
|
|
1627
|
-
_weapp_tailwindcss_postcss.postcss.parse(source).walkRules((rule) => {
|
|
1628
|
-
for (const selector of rule.selectors ?? [rule.selector]) {
|
|
1629
|
-
const normalized = selector.trim();
|
|
1630
|
-
if (normalized) selectors.add(normalized);
|
|
1631
|
-
}
|
|
1632
|
-
});
|
|
1633
|
-
} catch {}
|
|
1634
|
-
return selectors;
|
|
1635
|
-
}
|
|
1636
|
-
function matchesUserLayerSelector(selector, userLayerSelector) {
|
|
1637
|
-
if (selector === userLayerSelector) return true;
|
|
1638
|
-
if (!selector.startsWith(userLayerSelector)) return false;
|
|
1639
|
-
const next = selector[userLayerSelector.length];
|
|
1640
|
-
return next === ":" || next === "[";
|
|
1641
|
-
}
|
|
1642
|
-
function extractGeneratedCssForUserLayerSelectors(css, userLayerSource) {
|
|
1643
|
-
const selectors = collectUserLayerSelectors(userLayerSource);
|
|
1644
|
-
if (selectors.size === 0) return {
|
|
1645
|
-
layer: "",
|
|
1646
|
-
rest: css
|
|
1647
|
-
};
|
|
1648
|
-
try {
|
|
1649
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
1650
|
-
const layerRoot = _weapp_tailwindcss_postcss.postcss.root();
|
|
1651
|
-
const selectorList = [...selectors];
|
|
1652
|
-
root.walkRules((rule) => {
|
|
1653
|
-
if ((rule.selectors ?? [rule.selector]).some((selector) => selectorList.some((userSelector) => matchesUserLayerSelector(selector.trim(), userSelector)))) {
|
|
1654
|
-
layerRoot.append(rule.clone());
|
|
1655
|
-
rule.remove();
|
|
1656
|
-
}
|
|
1657
|
-
});
|
|
1658
|
-
return {
|
|
1659
|
-
layer: layerRoot.toString(),
|
|
1660
|
-
rest: root.toString()
|
|
1661
|
-
};
|
|
1662
|
-
} catch {
|
|
1663
|
-
return {
|
|
1664
|
-
layer: "",
|
|
1665
|
-
rest: css
|
|
1666
|
-
};
|
|
1667
|
-
}
|
|
1668
|
-
}
|
|
1669
|
-
function normalizeGeneratedSelector(selector) {
|
|
1670
|
-
return selector.replace(/:not\(#\\#\)/g, "").trim();
|
|
1671
|
-
}
|
|
1672
|
-
function collectApplyOnlySourceSelectors(source) {
|
|
1673
|
-
const selectors = /* @__PURE__ */ new Set();
|
|
1674
|
-
try {
|
|
1675
|
-
_weapp_tailwindcss_postcss.postcss.parse(source).walkRules((rule) => {
|
|
1676
|
-
if (!rule.nodes?.some((node) => node.type === "atrule" && node.name === "apply")) return;
|
|
1677
|
-
for (const selector of rule.selectors ?? [rule.selector]) {
|
|
1678
|
-
const normalized = normalizeGeneratedSelector(selector);
|
|
1679
|
-
if (normalized) selectors.add(normalized);
|
|
1680
|
-
}
|
|
1681
|
-
});
|
|
1682
|
-
} catch {}
|
|
1683
|
-
return selectors;
|
|
1684
|
-
}
|
|
1685
|
-
function hasOnlyApplyBackedSourceRules(source) {
|
|
1686
|
-
let hasApplyRule = false;
|
|
1687
|
-
let hasNonApplyRule = false;
|
|
1688
|
-
try {
|
|
1689
|
-
_weapp_tailwindcss_postcss.postcss.parse(source).walkRules((rule) => {
|
|
1690
|
-
if (rule.nodes?.some((node) => node.type === "atrule" && node.name === "apply")) hasApplyRule = true;
|
|
1691
|
-
else hasNonApplyRule = true;
|
|
1692
|
-
});
|
|
1693
|
-
} catch {
|
|
1694
|
-
return false;
|
|
1695
|
-
}
|
|
1696
|
-
return hasApplyRule && !hasNonApplyRule;
|
|
1697
|
-
}
|
|
1698
|
-
function filterApplyOnlyGeneratedCss(css, source) {
|
|
1699
|
-
const selectors = collectApplyOnlySourceSelectors(source);
|
|
1700
|
-
if (selectors.size === 0) return css;
|
|
1701
|
-
const selectorList = [...selectors];
|
|
1702
|
-
try {
|
|
1703
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
1704
|
-
root.walkRules((rule) => {
|
|
1705
|
-
const isApplySelector = (rule.selectors ?? [rule.selector]).some((selector) => {
|
|
1706
|
-
const normalized = normalizeGeneratedSelector(selector);
|
|
1707
|
-
return selectorList.some((sourceSelector) => {
|
|
1708
|
-
if (normalized === sourceSelector) return true;
|
|
1709
|
-
if (!normalized.startsWith(sourceSelector)) return false;
|
|
1710
|
-
const next = normalized[sourceSelector.length];
|
|
1711
|
-
return next === ":" || next === "[" || next === ".";
|
|
1712
|
-
});
|
|
1713
|
-
});
|
|
1714
|
-
const isVariableRule = rule.nodes?.some((node) => node.type === "decl" && node.prop.startsWith("--"));
|
|
1715
|
-
if (!isApplySelector && !isVariableRule) rule.remove();
|
|
1716
|
-
});
|
|
1717
|
-
root.walkAtRules((rule) => {
|
|
1718
|
-
if (rule.nodes !== void 0 && rule.nodes.length === 0) rule.remove();
|
|
1719
|
-
});
|
|
1720
|
-
return root.toString();
|
|
1721
|
-
} catch {
|
|
1722
|
-
return css;
|
|
1723
|
-
}
|
|
1724
|
-
}
|
|
1725
|
-
function shouldFilterApplyOnlyGeneratedCss(_majorVersion, target, source, options) {
|
|
1726
|
-
return target === "weapp" && require_v4_engine.hasTailwindApplyDirective(source) && !require_v4_engine.hasTailwindRootDirectives(source) && !options.hasGeneratedCss && !options.hasGeneratedMarkers && collectApplyOnlySourceSelectors(source).size > 0 && hasOnlyApplyBackedSourceRules(source);
|
|
1727
|
-
}
|
|
1728
|
-
async function transformGeneratorUserCss(source, options) {
|
|
1729
|
-
if (source.trim().length === 0) return "";
|
|
1730
|
-
if (options.processed) return stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(removeTailwindV4GeneratorAtRules(options.generatorTarget === "weapp" ? removeTailwindV4GeneratedUserCssArtifacts(removeProcessedMiniProgramUnsupportedCss(source, {
|
|
1731
|
-
...options.generatorStyleOptions,
|
|
1732
|
-
...options.cssUserHandlerOptions
|
|
1733
|
-
})) : source)));
|
|
1734
|
-
const cleanedSource = require_v4_engine.removeTailwindSourceDirectives(removeTailwindV4GeneratorAtRules(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(source))), { importFallback: options.importFallback });
|
|
1735
|
-
if (cleanedSource.trim().length === 0) return "";
|
|
1736
|
-
const userSource = stripUnmatchedTailwindSourceMediaCloseFragments(removeTailwindApplyAtRules(require_v4_engine.removeTailwindSourceDirectives(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(options.generatorTarget === "weapp" ? removeTailwindV4GeneratedUserCssArtifacts((0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(unwrapMiniProgramCascadeLayers(cleanedSource))) : cleanedSource)), { importFallback: options.importFallback })));
|
|
1737
|
-
if (userSource.trim().length === 0) return "";
|
|
1738
|
-
if (isCommentOnlyCss(userSource)) return userSource;
|
|
1739
|
-
if (options.generatorTarget !== "weapp") return userSource;
|
|
1740
|
-
const { css } = await options.styleHandler(userSource, {
|
|
1741
|
-
...options.generatorStyleOptions,
|
|
1742
|
-
...options.cssUserHandlerOptions
|
|
1743
|
-
});
|
|
1744
|
-
return removeTailwindV4GeneratedUserCssArtifacts((0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(css));
|
|
1745
|
-
}
|
|
1746
|
-
//#endregion
|
|
1747
1391
|
//#region src/bundlers/shared/generator-css/legacy-compat.ts
|
|
1748
1392
|
const LEGACY_CONTAINER_COMPAT_CSS = [
|
|
1749
1393
|
".container {",
|
|
@@ -1869,7 +1513,7 @@ function removeTailwindApplyRules(rawSource) {
|
|
|
1869
1513
|
function resolveLegacyCompatCssSource(rawSource) {
|
|
1870
1514
|
const cached = legacyCompatSourceCache.get(rawSource);
|
|
1871
1515
|
if (cached !== void 0) return cached;
|
|
1872
|
-
const resolved = closeTrailingUnclosedBlocks(removeTailwindV4GeneratedUserCssArtifacts((0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(removeTailwindApplyRules(require_v4_engine.removeTailwindSourceDirectives(closeTrailingUnclosedBlocks(require_v4_engine.stripTailwindBanners(rawSource)))))));
|
|
1516
|
+
const resolved = closeTrailingUnclosedBlocks(require_v4_engine.removeTailwindV4GeneratedUserCssArtifacts((0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(removeTailwindApplyRules(require_v4_engine.removeTailwindSourceDirectives(closeTrailingUnclosedBlocks(require_v4_engine.stripTailwindBanners(rawSource)))))));
|
|
1873
1517
|
setLimitedCacheValue(legacyCompatSourceCache, rawSource, resolved);
|
|
1874
1518
|
return resolved;
|
|
1875
1519
|
}
|
|
@@ -1937,7 +1581,7 @@ async function appendLegacyCompatCss(css, rawSource, generatorTarget, styleHandl
|
|
|
1937
1581
|
compatCss = (await styleHandler(compatSource, styleOptions)).css;
|
|
1938
1582
|
setLimitedCacheValue(legacyCompatTransformCache, compatCssCacheKey, compatCss);
|
|
1939
1583
|
}
|
|
1940
|
-
const cleanedCompatCss = collectDedupedPostTransformCompatCss(removeTailwindV4GeneratedUserCssArtifacts(removeDuplicatedViteMarkers((0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(compatCss), css)), css);
|
|
1584
|
+
const cleanedCompatCss = collectDedupedPostTransformCompatCss(require_v4_engine.removeTailwindV4GeneratedUserCssArtifacts(removeDuplicatedViteMarkers((0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(compatCss), css)), css);
|
|
1941
1585
|
if (cleanedCompatCss.trim().length === 0) return css;
|
|
1942
1586
|
return require_v4_engine.createCssAppend(css, cleanedCompatCss);
|
|
1943
1587
|
}
|
|
@@ -2248,11 +1892,12 @@ function finalizeWebGeneratorCss(css, target, webCompat) {
|
|
|
2248
1892
|
return target === "web" ? (0, _weapp_tailwindcss_postcss.transformWebCssCompat)(css, webCompat) : css;
|
|
2249
1893
|
}
|
|
2250
1894
|
async function generateCssByGenerator(options) {
|
|
2251
|
-
const { opts, runtimeState, runtime, rawSource, file, cssHandlerOptions, cssUserHandlerOptions, getSourceCandidatesForEntries, styleHandler, userRawSource, userRawSourceProcessed, debug } = options;
|
|
1895
|
+
const { opts, runtimeState, runtime, rawSource, file, cssHandlerOptions, cssUserHandlerOptions, getSourceCandidatesForEntries, styleHandler, generatorPlatform, userRawSource, userRawSourceProcessed, debug } = options;
|
|
1896
|
+
const platform = generatorPlatform ?? opts.cssOptions?.platform ?? opts.platform;
|
|
2252
1897
|
const generatorOptions = {
|
|
2253
1898
|
...require_generator.normalizeWeappTailwindcssGeneratorOptions(opts.generator, {
|
|
2254
1899
|
appType: opts.appType,
|
|
2255
|
-
platform
|
|
1900
|
+
platform,
|
|
2256
1901
|
tailwindcssMajorVersion: runtimeState.tailwindRuntime.majorVersion,
|
|
2257
1902
|
uniAppX: opts.uniAppX
|
|
2258
1903
|
}),
|
|
@@ -2260,13 +1905,13 @@ async function generateCssByGenerator(options) {
|
|
|
2260
1905
|
};
|
|
2261
1906
|
const generatorBranch = require_generator.resolveGeneratorRuntimeBranch(generatorOptions, {
|
|
2262
1907
|
appType: opts.appType,
|
|
2263
|
-
platform
|
|
1908
|
+
platform,
|
|
2264
1909
|
tailwindcssMajorVersion: runtimeState.tailwindRuntime.majorVersion,
|
|
2265
1910
|
uniAppX: opts.uniAppX
|
|
2266
1911
|
});
|
|
2267
1912
|
const majorVersion = runtimeState.tailwindRuntime.majorVersion;
|
|
2268
1913
|
if (majorVersion !== 4) throw new Error("weapp-tailwindcss 生成管线仅支持 Tailwind CSS v4。");
|
|
2269
|
-
const effectiveRawSource = stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(require_v4_engine.normalizeTailwindSourceDirectives(rawSource, { importFallback: generatorOptions.importFallback })));
|
|
1914
|
+
const effectiveRawSource = require_v4_engine.stripUnmatchedTailwindSourceMediaCloseFragments(require_v4_engine.stripTailwindSourceMediaFragments(require_v4_engine.normalizeEmptyTailwindCustomVariants(require_v4_engine.normalizeTailwindSourceDirectives(rawSource, { importFallback: generatorOptions.importFallback }))));
|
|
2270
1915
|
const effectiveRawSourceRoot = parseCssSourceRoot(effectiveRawSource);
|
|
2271
1916
|
const cleanedLocalImportWrapper = cleanLocalCssImportWrapperFromParsedRoot(effectiveRawSource, effectiveRawSourceRoot);
|
|
2272
1917
|
if (cleanedLocalImportWrapper !== void 0) return {
|
|
@@ -2284,12 +1929,12 @@ async function generateCssByGenerator(options) {
|
|
|
2284
1929
|
const localImportParts = splitLocalCssImportsFromParsedRoot(effectiveRawSource, effectiveRawSourceRoot);
|
|
2285
1930
|
const localImports = options.restoreLocalCssImports === false ? void 0 : localImportParts?.imports;
|
|
2286
1931
|
const finalizeGeneratorCss = (css, target, finalizeOptions = {}) => {
|
|
2287
|
-
return finalizeWebGeneratorCss((0, _weapp_tailwindcss_postcss.restoreLocalCssImports)(finalizeMiniProgramGeneratorCss(css, target, majorVersion, opts.cssPreflight, finalizeOptions), localImports), target, generatorOptions.webCompat);
|
|
1932
|
+
return finalizeWebGeneratorCss((0, _weapp_tailwindcss_postcss.restoreLocalCssImports)(finalizeMiniProgramGeneratorCss(css, target, majorVersion, opts.cssPreflight, finalizeOptions), localImports, { outputFile: file }), target, generatorOptions.webCompat);
|
|
2288
1933
|
};
|
|
2289
1934
|
const generatorRawSource = localImportParts?.source ?? effectiveRawSource;
|
|
2290
|
-
const rawUserSource = userRawSource === void 0 ? generatorRawSource : userRawSourceProcessed ? userRawSource : stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(require_v4_engine.normalizeTailwindSourceDirectives(userRawSource, { importFallback: generatorOptions.importFallback })));
|
|
1935
|
+
const rawUserSource = userRawSource === void 0 ? generatorRawSource : userRawSourceProcessed ? userRawSource : require_v4_engine.stripUnmatchedTailwindSourceMediaCloseFragments(require_v4_engine.stripTailwindSourceMediaFragments(require_v4_engine.normalizeEmptyTailwindCustomVariants(require_v4_engine.normalizeTailwindSourceDirectives(userRawSource, { importFallback: generatorOptions.importFallback }))));
|
|
2291
1936
|
const userSource = (rawUserSource === generatorRawSource ? void 0 : (0, _weapp_tailwindcss_postcss.splitLocalCssImports)(rawUserSource))?.source ?? rawUserSource;
|
|
2292
|
-
const userCssRawSource = removeTailwindV4GeneratorAtRules(userSource);
|
|
1937
|
+
const userCssRawSource = require_v4_engine.removeTailwindV4GeneratorAtRules(userSource);
|
|
2293
1938
|
const generatedUserCssOrderSource = require_v4_engine.hasTailwindGeneratedCss(userSource) ? require_v4_engine.splitTailwindV4GeneratedCssBySourceOrder(userSource, generatorRawSource) : void 0;
|
|
2294
1939
|
const generatedUserCssRawSource = generatedUserCssOrderSource ? require_v4_engine.createCssAppend(generatedUserCssOrderSource.before, generatedUserCssOrderSource.after) : require_v4_engine.hasTailwindGeneratedCss(userSource) ? "" : userCssRawSource;
|
|
2295
1940
|
const userCssOrderSource = require_v4_engine.GENERATOR_PLACEHOLDER_MARKER_RE.test(userSource) ? userSource : require_v4_engine.hasTailwindGeneratedCss(userSource) ? userSource : generatedUserCssRawSource;
|
|
@@ -2297,6 +1942,10 @@ async function generateCssByGenerator(options) {
|
|
|
2297
1942
|
const hasGeneratedCss = require_v4_engine.hasTailwindGeneratedCss(generatorRawSource);
|
|
2298
1943
|
const hasSourceDirectives = require_v4_engine.hasTailwindSourceDirectives(generatorRawSource, { importFallback: generatorOptions.importFallback });
|
|
2299
1944
|
const hasGeneratedMarkers = require_v4_engine.hasTailwindGeneratedCssMarkers(generatorRawSource);
|
|
1945
|
+
const normalizedCssSources = options.cssSources?.map((source) => ({
|
|
1946
|
+
...source,
|
|
1947
|
+
css: require_v4_engine.normalizeEmptyTailwindCustomVariants(source.css)
|
|
1948
|
+
}));
|
|
2300
1949
|
if (!shouldUseGeneratorForCurrentCss(majorVersion, cssHandlerOptions, {
|
|
2301
1950
|
forceGenerator: options.forceGenerator,
|
|
2302
1951
|
hasGeneratedCss,
|
|
@@ -2317,8 +1966,8 @@ async function generateCssByGenerator(options) {
|
|
|
2317
1966
|
});
|
|
2318
1967
|
const runtimeWithCurrentCss = createRuntimeWithCurrentCssCandidates(runtime, currentCssCandidates, isolateCurrentCssCandidates);
|
|
2319
1968
|
const sources = await resolveGeneratorSources(majorVersion, runtimeState, generatorRawSource, file, cssHandlerOptions, generatorOptions, {
|
|
2320
|
-
cssEntries: opts.cssEntries,
|
|
2321
|
-
cssSources:
|
|
1969
|
+
cssEntries: cssHandlerOptions.sourceOptions?.cssEntries ?? opts.cssEntries,
|
|
1970
|
+
cssSources: normalizedCssSources,
|
|
2322
1971
|
getSourceCandidatesForEntries,
|
|
2323
1972
|
runtime: runtimeWithCurrentCss
|
|
2324
1973
|
});
|
|
@@ -2359,12 +2008,12 @@ async function generateCssByGenerator(options) {
|
|
|
2359
2008
|
}), sourceConcurrency)).filter((item) => Boolean(item)));
|
|
2360
2009
|
if (!generated) return;
|
|
2361
2010
|
debug("tailwind generator result: %s rawBytes=%d cssBytes=%d candidates=%d", file, generated.rawCss.length, generated.css.length, generated.classSet.size);
|
|
2362
|
-
if ((generated.target !== "weapp" || !hasUserCssLayerBlocks(generatorRawSource)) && typeof options.previousCss === "string" && typeof generated.incrementalCss === "string") {
|
|
2011
|
+
if ((generated.target !== "weapp" || !require_v4_engine.hasUserCssLayerBlocks(generatorRawSource)) && typeof options.previousCss === "string" && typeof generated.incrementalCss === "string") {
|
|
2363
2012
|
const incrementalCss = require_v4_engine.stripTailwindBanner(generated.incrementalCss);
|
|
2364
2013
|
const finalCss = finalizeWebGeneratorCss((0, _weapp_tailwindcss_postcss.restoreLocalCssImports)(incrementalCss.trim().length > 0 ? require_v4_engine.createCssAppend(options.previousCss, finalizeMiniProgramGeneratorCss(incrementalCss, generated.target, majorVersion, opts.cssPreflight, {
|
|
2365
2014
|
injectPreflight: false,
|
|
2366
2015
|
styleOptions: generatorStyleOptions
|
|
2367
|
-
})) : options.previousCss, localImports), generated.target, generatorOptions.webCompat);
|
|
2016
|
+
})) : options.previousCss, localImports, { outputFile: file }), generated.target, generatorOptions.webCompat);
|
|
2368
2017
|
return {
|
|
2369
2018
|
css: finalCss,
|
|
2370
2019
|
classSet: mergeGeneratedCssClassSet(generated.classSet, runtimeWithCurrentCss, finalCss, opts.escapeMap),
|
|
@@ -2379,13 +2028,26 @@ async function generateCssByGenerator(options) {
|
|
|
2379
2028
|
}
|
|
2380
2029
|
};
|
|
2381
2030
|
}
|
|
2382
|
-
const shouldFilterApplyOnlyCss = shouldFilterApplyOnlyGeneratedCss(majorVersion, generated.target, generatorRawSource, {
|
|
2031
|
+
const shouldFilterApplyOnlyCss = require_v4_engine.shouldFilterApplyOnlyGeneratedCss(majorVersion, generated.target, generatorRawSource, {
|
|
2383
2032
|
hasGeneratedCss,
|
|
2384
2033
|
hasGeneratedMarkers
|
|
2385
2034
|
});
|
|
2386
2035
|
const generatedCssSource = generated.target === "web" ? generated.css : require_v4_engine.stripTailwindBanner(generated.css);
|
|
2387
|
-
const generatedCss = shouldFilterApplyOnlyCss ? filterApplyOnlyGeneratedCss(generatedCssSource, generatorRawSource) : generatedCssSource;
|
|
2036
|
+
const generatedCss = shouldFilterApplyOnlyCss ? require_v4_engine.filterApplyOnlyGeneratedCss(generatedCssSource, generatorRawSource, { preserveVariables: generated.target !== "web" }) : generatedCssSource;
|
|
2388
2037
|
const hasMatchedCssSourceFile = sources.some((source) => source.__weappTailwindcssMeta?.matchedCssSourceFile);
|
|
2038
|
+
const hasExplicitCssSource = sources.some((source) => {
|
|
2039
|
+
const metadata = source.__weappTailwindcssMeta;
|
|
2040
|
+
return metadata?.cssEntryIndex !== void 0 || metadata?.cssSourceIndex !== void 0;
|
|
2041
|
+
});
|
|
2042
|
+
const hasPreflightCssSource = sources.some((source) => source.__weappTailwindcssMeta?.includesPreflight === true);
|
|
2043
|
+
const hasPreflightRawSource = require_tailwindcss.includesTailwindV4PreflightDirective(generatorRawSource);
|
|
2044
|
+
const preflightMode = resolveMiniProgramPreflightModeForGeneratorCss(opts, {
|
|
2045
|
+
cssHandlerOptions,
|
|
2046
|
+
isolateCurrentCssCandidates,
|
|
2047
|
+
localImports,
|
|
2048
|
+
explicitCssSource: hasExplicitCssSource,
|
|
2049
|
+
primaryCssSource: sources.length > 0 && sources.every((source) => source.__weappTailwindcssMeta?.primaryCssSource === true) || hasPreflightCssSource || hasPreflightRawSource
|
|
2050
|
+
});
|
|
2389
2051
|
const orderedExtraCss = require_v4_engine.splitGeneratorPlaceholderCssBySourceOrder(userCssOrderSource, generated.rawCss) ?? (hasMatchedCssSourceFile ? require_v4_engine.splitTailwindV4GeneratedCssBySourceOrder(userCssOrderSource, generated.rawCss) : splitRawSourceByGeneratedCssOrder(userCssOrderSource, generated.rawCss));
|
|
2390
2052
|
const shouldAppendMatchedCssSourceCompat = !hasMatchedCssSourceFile || orderedExtraCss !== void 0;
|
|
2391
2053
|
if (orderedExtraCss) {
|
|
@@ -2399,29 +2061,29 @@ async function generateCssByGenerator(options) {
|
|
|
2399
2061
|
importFallback: generatorOptions.importFallback,
|
|
2400
2062
|
processed: userRawSourceProcessed
|
|
2401
2063
|
};
|
|
2402
|
-
const afterLayerParts = generated.target === "weapp" ? splitUserCssLayerBlocks(orderedExtraCss.after) : {
|
|
2064
|
+
const afterLayerParts = generated.target === "weapp" ? require_v4_engine.splitUserCssLayerBlocks(orderedExtraCss.after) : {
|
|
2403
2065
|
layer: "",
|
|
2404
2066
|
rest: orderedExtraCss.after
|
|
2405
2067
|
};
|
|
2406
|
-
const beforeUserCss = await transformGeneratorUserCss(orderedExtraCss.before, userCssOptions);
|
|
2407
|
-
const afterLayerUserCss = await transformGeneratorUserCss(afterLayerParts.layer, userCssOptions);
|
|
2408
|
-
const afterUserCss = await transformGeneratorUserCss(afterLayerParts.rest, userCssOptions);
|
|
2409
|
-
const fallbackLayerUserCss = generated.target === "weapp" && afterLayerParts.layer.trim().length === 0 && hasUserCssLayerBlocks(userCssRawSource) ? await transformGeneratorUserCss(splitUserCssLayerBlocks(userCssRawSource).layer, userCssOptions) : "";
|
|
2068
|
+
const beforeUserCss = await require_v4_engine.transformGeneratorUserCss(orderedExtraCss.before, userCssOptions);
|
|
2069
|
+
const afterLayerUserCss = await require_v4_engine.transformGeneratorUserCss(afterLayerParts.layer, userCssOptions);
|
|
2070
|
+
const afterUserCss = await require_v4_engine.transformGeneratorUserCss(afterLayerParts.rest, userCssOptions);
|
|
2071
|
+
const fallbackLayerUserCss = generated.target === "weapp" && afterLayerParts.layer.trim().length === 0 && require_v4_engine.hasUserCssLayerBlocks(userCssRawSource) ? await require_v4_engine.transformGeneratorUserCss(require_v4_engine.splitUserCssLayerBlocks(userCssRawSource).layer, userCssOptions) : "";
|
|
2410
2072
|
css = createCssSourceOrderAppend$1(createCssSourceOrderAppend$1(createCssSourceOrderAppend$1(beforeUserCss, generated.target === "weapp" ? wrapUserLayerComponentsCss(createCssSourceOrderAppend$1(afterLayerUserCss, fallbackLayerUserCss)) : afterLayerUserCss), css), afterUserCss);
|
|
2411
2073
|
if (isEmptyCssSourceOrderParts(orderedExtraCss) && shouldAppendWebBundleCssFallback(generated.target, {
|
|
2412
2074
|
hasSourceDirectives,
|
|
2413
2075
|
hasMatchedCssSourceFile
|
|
2414
2076
|
})) {
|
|
2415
|
-
const userCss = await transformGeneratorUserCss(userCssRawSource, userCssOptions);
|
|
2077
|
+
const userCss = await require_v4_engine.transformGeneratorUserCss(userCssRawSource, userCssOptions);
|
|
2416
2078
|
css = createCssSourceOrderAppend$1(css, userCss);
|
|
2417
2079
|
}
|
|
2418
2080
|
if (generated.target === "web") {
|
|
2419
|
-
const userCss = await transformGeneratorUserCss(userCssRawSource, userCssOptions);
|
|
2420
|
-
const missingUserCss = isCommentOnlyCss(userCss) ? "" : (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(css, userCss);
|
|
2081
|
+
const userCss = await require_v4_engine.transformGeneratorUserCss(userCssRawSource, userCssOptions);
|
|
2082
|
+
const missingUserCss = require_v4_engine.isCommentOnlyCss(userCss) ? "" : (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(css, userCss);
|
|
2421
2083
|
css = createCssSourceOrderAppend$1(css, missingUserCss);
|
|
2422
2084
|
}
|
|
2423
2085
|
if (generated.target === "weapp" && isEmptyCssSourceOrderParts(orderedExtraCss) && hasDistinctUserRawSource && !hasGeneratedCss && !hasGeneratedMarkers && !require_v4_engine.hasTailwindApplyDirective(generatedUserCssRawSource)) {
|
|
2424
|
-
const userCss = await transformGeneratorUserCss(generatedUserCssRawSource, userCssOptions);
|
|
2086
|
+
const userCss = await require_v4_engine.transformGeneratorUserCss(generatedUserCssRawSource, userCssOptions);
|
|
2425
2087
|
const missingUserCss = isCssAlreadyRepresentedByMarkers(css, generatedUserCssRawSource) ? (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(css, userCss) : userCss;
|
|
2426
2088
|
css = createCssSourceOrderAppend$1(css, missingUserCss);
|
|
2427
2089
|
}
|
|
@@ -2433,11 +2095,8 @@ async function generateCssByGenerator(options) {
|
|
|
2433
2095
|
}
|
|
2434
2096
|
} else if (generated.target === "weapp" && shouldFinalizeMarkedUserLayerComponentsCss(file)) css = reorderMarkedUserLayerComponentsCss(css);
|
|
2435
2097
|
const finalCss = finalizeGeneratorCss(css, generated.target, {
|
|
2436
|
-
injectPreflight:
|
|
2437
|
-
|
|
2438
|
-
isolateCurrentCssCandidates,
|
|
2439
|
-
localImports
|
|
2440
|
-
}),
|
|
2098
|
+
injectPreflight: preflightMode.inject,
|
|
2099
|
+
preservePreflight: preflightMode.preserve,
|
|
2441
2100
|
styleOptions: generatorStyleOptions
|
|
2442
2101
|
});
|
|
2443
2102
|
return {
|
|
@@ -2455,7 +2114,7 @@ async function generateCssByGenerator(options) {
|
|
|
2455
2114
|
}
|
|
2456
2115
|
debug("tailwind direct css generation prefix mismatch, append transformed bundle css %s", file);
|
|
2457
2116
|
let css = generatedCss;
|
|
2458
|
-
if (generated.target === "weapp" && generatorRawSource.includes("weapp-tailwindcss generator-placeholder") && !hasUserCssLayerBlocks(generatorRawSource)) css = createCssSourceOrderAppend$1(await transformGeneratorUserCss(generatedUserCssRawSource, {
|
|
2117
|
+
if (generated.target === "weapp" && generatorRawSource.includes("weapp-tailwindcss generator-placeholder") && !require_v4_engine.hasUserCssLayerBlocks(generatorRawSource)) css = createCssSourceOrderAppend$1(await require_v4_engine.transformGeneratorUserCss(generatedUserCssRawSource, {
|
|
2459
2118
|
generatorTarget: generated.target,
|
|
2460
2119
|
generatorStyleOptions,
|
|
2461
2120
|
cssUserHandlerOptions,
|
|
@@ -2465,9 +2124,9 @@ async function generateCssByGenerator(options) {
|
|
|
2465
2124
|
}), css);
|
|
2466
2125
|
if (generated.target === "weapp") {
|
|
2467
2126
|
css = inheritLegacyUnitConvertedDeclarations(css, generatorRawSource);
|
|
2468
|
-
if (hasUserCssLayerBlocks(generatorRawSource)) {
|
|
2469
|
-
const layerParts = splitUserCssLayerBlocks(generatorRawSource);
|
|
2470
|
-
const layerUserCss = await transformGeneratorUserCss(layerParts.layer, {
|
|
2127
|
+
if (require_v4_engine.hasUserCssLayerBlocks(generatorRawSource)) {
|
|
2128
|
+
const layerParts = require_v4_engine.splitUserCssLayerBlocks(generatorRawSource);
|
|
2129
|
+
const layerUserCss = await require_v4_engine.transformGeneratorUserCss(layerParts.layer, {
|
|
2471
2130
|
generatorTarget: generated.target,
|
|
2472
2131
|
generatorStyleOptions,
|
|
2473
2132
|
cssUserHandlerOptions,
|
|
@@ -2478,7 +2137,7 @@ async function generateCssByGenerator(options) {
|
|
|
2478
2137
|
const layerCss = layerUserCss.trim().length > 0 && !require_v4_engine.hasTailwindApplyDirective(layerUserCss) ? {
|
|
2479
2138
|
layer: layerUserCss,
|
|
2480
2139
|
rest: css
|
|
2481
|
-
} : extractGeneratedCssForUserLayerSelectors(css, layerParts.layer);
|
|
2140
|
+
} : require_v4_engine.extractGeneratedCssForUserLayerSelectors(css, layerParts.layer);
|
|
2482
2141
|
if (layerCss.layer.trim().length > 0) {
|
|
2483
2142
|
css = createCssSourceOrderAppend$1(wrapUserLayerComponentsCss(layerCss.layer), layerCss.rest);
|
|
2484
2143
|
if (shouldFinalizeMarkedUserLayerComponentsCss(file)) css = reorderMarkedUserLayerComponentsCss(css);
|
|
@@ -2487,7 +2146,7 @@ async function generateCssByGenerator(options) {
|
|
|
2487
2146
|
}
|
|
2488
2147
|
if (hasMatchedCssSourceFile || generated.target === "web") {
|
|
2489
2148
|
if (generated.target === "weapp" && !hasGeneratedCss && !hasGeneratedMarkers) {
|
|
2490
|
-
const userCss = await transformGeneratorUserCss(generatedUserCssRawSource, {
|
|
2149
|
+
const userCss = await require_v4_engine.transformGeneratorUserCss(generatedUserCssRawSource, {
|
|
2491
2150
|
generatorTarget: generated.target,
|
|
2492
2151
|
generatorStyleOptions,
|
|
2493
2152
|
cssUserHandlerOptions,
|
|
@@ -2498,7 +2157,7 @@ async function generateCssByGenerator(options) {
|
|
|
2498
2157
|
const missingUserCss = isCssAlreadyRepresentedByMarkers(css, generatedUserCssRawSource) ? (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(css, userCss) : userCss;
|
|
2499
2158
|
css = createCssSourceOrderAppend$1(css, missingUserCss);
|
|
2500
2159
|
} else if (hasMatchedCssSourceFile && generated.target === "weapp" && hasGeneratedMarkers && !hasGeneratedCss) {
|
|
2501
|
-
const userCss = await transformGeneratorUserCss(removeTailwindV4GeneratedUserCssArtifacts(userCssRawSource), {
|
|
2160
|
+
const userCss = await require_v4_engine.transformGeneratorUserCss(require_v4_engine.removeTailwindV4GeneratedUserCssArtifacts(userCssRawSource), {
|
|
2502
2161
|
generatorTarget: generated.target,
|
|
2503
2162
|
generatorStyleOptions,
|
|
2504
2163
|
cssUserHandlerOptions,
|
|
@@ -2508,8 +2167,8 @@ async function generateCssByGenerator(options) {
|
|
|
2508
2167
|
});
|
|
2509
2168
|
const missingUserCss = (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(css, userCss);
|
|
2510
2169
|
css = createCssSourceOrderAppend$1(css, missingUserCss);
|
|
2511
|
-
} else if (hasMatchedCssSourceFile && generated.target === "weapp" && hasUserCssLayerBlocks(generatedUserCssRawSource)) {
|
|
2512
|
-
const layerUserCss = await transformGeneratorUserCss(splitUserCssLayerBlocks(generatedUserCssRawSource).layer, {
|
|
2170
|
+
} else if (hasMatchedCssSourceFile && generated.target === "weapp" && require_v4_engine.hasUserCssLayerBlocks(generatedUserCssRawSource)) {
|
|
2171
|
+
const layerUserCss = await require_v4_engine.transformGeneratorUserCss(require_v4_engine.splitUserCssLayerBlocks(generatedUserCssRawSource).layer, {
|
|
2513
2172
|
generatorTarget: generated.target,
|
|
2514
2173
|
generatorStyleOptions,
|
|
2515
2174
|
cssUserHandlerOptions,
|
|
@@ -2529,7 +2188,7 @@ async function generateCssByGenerator(options) {
|
|
|
2529
2188
|
hasSourceDirectives,
|
|
2530
2189
|
hasMatchedCssSourceFile
|
|
2531
2190
|
})) {
|
|
2532
|
-
const userCss = await transformGeneratorUserCss(generatedUserCssRawSource, {
|
|
2191
|
+
const userCss = await require_v4_engine.transformGeneratorUserCss(generatedUserCssRawSource, {
|
|
2533
2192
|
generatorTarget: generated.target,
|
|
2534
2193
|
generatorStyleOptions,
|
|
2535
2194
|
cssUserHandlerOptions,
|
|
@@ -2537,15 +2196,12 @@ async function generateCssByGenerator(options) {
|
|
|
2537
2196
|
importFallback: generatorOptions.importFallback,
|
|
2538
2197
|
processed: userRawSourceProcessed
|
|
2539
2198
|
});
|
|
2540
|
-
const missingUserCss = isCommentOnlyCss(userCss) ? "" : (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(css, userCss);
|
|
2199
|
+
const missingUserCss = require_v4_engine.isCommentOnlyCss(userCss) ? "" : (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(css, userCss);
|
|
2541
2200
|
css = createCssSourceOrderAppend$1(css, missingUserCss);
|
|
2542
2201
|
}
|
|
2543
2202
|
const finalCss = finalizeGeneratorCss(css, generated.target, {
|
|
2544
|
-
injectPreflight:
|
|
2545
|
-
|
|
2546
|
-
isolateCurrentCssCandidates,
|
|
2547
|
-
localImports
|
|
2548
|
-
}),
|
|
2203
|
+
injectPreflight: preflightMode.inject,
|
|
2204
|
+
preservePreflight: preflightMode.preserve,
|
|
2549
2205
|
styleOptions: generatorStyleOptions
|
|
2550
2206
|
});
|
|
2551
2207
|
return {
|
|
@@ -2566,7 +2222,7 @@ async function generateCssByGenerator(options) {
|
|
|
2566
2222
|
css = await appendLegacyContainerCompatCss(css, generatedUserCssRawSource, file, runtime, configuredContainerCompat, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions);
|
|
2567
2223
|
}
|
|
2568
2224
|
if (generated.target === "weapp" && hasDistinctUserRawSource && !hasGeneratedCss && !hasGeneratedMarkers && !require_v4_engine.hasTailwindApplyDirective(generatedUserCssRawSource)) {
|
|
2569
|
-
const userCss = await transformGeneratorUserCss(generatedUserCssRawSource, {
|
|
2225
|
+
const userCss = await require_v4_engine.transformGeneratorUserCss(generatedUserCssRawSource, {
|
|
2570
2226
|
generatorTarget: generated.target,
|
|
2571
2227
|
generatorStyleOptions,
|
|
2572
2228
|
cssUserHandlerOptions,
|
|
@@ -2578,11 +2234,8 @@ async function generateCssByGenerator(options) {
|
|
|
2578
2234
|
css = createCssSourceOrderAppend$1(css, missingUserCss);
|
|
2579
2235
|
}
|
|
2580
2236
|
const finalCss = finalizeGeneratorCss(css, generated.target, {
|
|
2581
|
-
injectPreflight:
|
|
2582
|
-
|
|
2583
|
-
isolateCurrentCssCandidates,
|
|
2584
|
-
localImports
|
|
2585
|
-
}),
|
|
2237
|
+
injectPreflight: preflightMode.inject,
|
|
2238
|
+
preservePreflight: preflightMode.preserve,
|
|
2586
2239
|
styleOptions: generatorStyleOptions
|
|
2587
2240
|
});
|
|
2588
2241
|
return {
|
|
@@ -3541,24 +3194,6 @@ Object.defineProperty(exports, "removeGeneratedSelectorCompatCss", {
|
|
|
3541
3194
|
return removeGeneratedSelectorCompatCss;
|
|
3542
3195
|
}
|
|
3543
3196
|
});
|
|
3544
|
-
Object.defineProperty(exports, "removeMiniProgramHoverSelectors", {
|
|
3545
|
-
enumerable: true,
|
|
3546
|
-
get: function() {
|
|
3547
|
-
return removeMiniProgramHoverSelectors;
|
|
3548
|
-
}
|
|
3549
|
-
});
|
|
3550
|
-
Object.defineProperty(exports, "removeTailwindV4GeneratedUserCssArtifacts", {
|
|
3551
|
-
enumerable: true,
|
|
3552
|
-
get: function() {
|
|
3553
|
-
return removeTailwindV4GeneratedUserCssArtifacts;
|
|
3554
|
-
}
|
|
3555
|
-
});
|
|
3556
|
-
Object.defineProperty(exports, "removeTailwindV4GeneratorAtRules", {
|
|
3557
|
-
enumerable: true,
|
|
3558
|
-
get: function() {
|
|
3559
|
-
return removeTailwindV4GeneratorAtRules;
|
|
3560
|
-
}
|
|
3561
|
-
});
|
|
3562
3197
|
Object.defineProperty(exports, "resolveSourceCandidateScanFiles", {
|
|
3563
3198
|
enumerable: true,
|
|
3564
3199
|
get: function() {
|
|
@@ -3583,18 +3218,6 @@ Object.defineProperty(exports, "scoreTailwindV4CssSourceFileMatch", {
|
|
|
3583
3218
|
return scoreTailwindV4CssSourceFileMatch;
|
|
3584
3219
|
}
|
|
3585
3220
|
});
|
|
3586
|
-
Object.defineProperty(exports, "stripTailwindSourceMediaFragments", {
|
|
3587
|
-
enumerable: true,
|
|
3588
|
-
get: function() {
|
|
3589
|
-
return stripTailwindSourceMediaFragments;
|
|
3590
|
-
}
|
|
3591
|
-
});
|
|
3592
|
-
Object.defineProperty(exports, "stripUnmatchedTailwindSourceMediaCloseFragments", {
|
|
3593
|
-
enumerable: true,
|
|
3594
|
-
get: function() {
|
|
3595
|
-
return stripUnmatchedTailwindSourceMediaCloseFragments;
|
|
3596
|
-
}
|
|
3597
|
-
});
|
|
3598
3221
|
Object.defineProperty(exports, "validateCandidatesByGenerator", {
|
|
3599
3222
|
enumerable: true,
|
|
3600
3223
|
get: function() {
|