weapp-tailwindcss 5.0.12 → 5.0.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-DU2ATDhw.js → bundle-state-CKWeTEhv.js} +2 -2
- package/dist/{bundle-state-BxMNKjBV.mjs → bundle-state-zQ2MrDdi.mjs} +1 -1
- package/dist/bundlers/shared/generator-css/generation-helpers.d.ts +7 -2
- package/dist/bundlers/shared/generator-css/source-files.d.ts +1 -0
- package/dist/bundlers/shared/generator-css/source-resolver/apply-reference.d.ts +3 -0
- package/dist/bundlers/shared/generator-css/source-resolver/config.d.ts +7 -0
- package/dist/bundlers/shared/generator-css/source-resolver/matching.d.ts +4 -0
- package/dist/bundlers/shared/generator-css/source-resolver/metadata.d.ts +15 -0
- package/dist/bundlers/shared/generator-css/source-resolver/postcss-source.d.ts +12 -0
- package/dist/bundlers/shared/generator-css/source-resolver/types.d.ts +22 -0
- package/dist/bundlers/shared/generator-css/source-resolver.d.ts +5 -22
- package/dist/bundlers/shared/generator-css/types.d.ts +2 -0
- package/dist/bundlers/shared/generator-css/validate.d.ts +1 -0
- package/dist/bundlers/vite/css-memory.d.ts +27 -0
- package/dist/bundlers/vite/generate-bundle/bundle-file-names.d.ts +2 -0
- package/dist/bundlers/vite/generate-bundle/configured-css-sources.d.ts +8 -0
- package/dist/bundlers/vite/generate-bundle/css-assets.d.ts +4 -0
- package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +5 -0
- package/dist/bundlers/vite/generate-bundle/css-output.d.ts +8 -7
- package/dist/bundlers/vite/generate-bundle/env-flags.d.ts +7 -0
- package/dist/bundlers/vite/generate-bundle/finalize.d.ts +58 -0
- package/dist/bundlers/vite/generate-bundle/js-processing.d.ts +31 -0
- package/dist/bundlers/vite/generate-bundle/memory-debug.d.ts +77 -0
- package/dist/bundlers/vite/generate-bundle/remembered-css-replay.d.ts +53 -0
- package/dist/bundlers/vite/generate-bundle/remembered-css.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/runtime-linked-css.d.ts +4 -0
- package/dist/bundlers/vite/generate-bundle/scoped-generator.d.ts +21 -0
- package/dist/bundlers/vite/generate-bundle/sfc-style-source.d.ts +2 -1
- package/dist/bundlers/vite/generate-bundle/source-candidate-scope.d.ts +29 -0
- package/dist/bundlers/vite/generate-bundle/timing.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/types.d.ts +2 -0
- package/dist/bundlers/vite/generate-bundle/uni-app-x-postprocess.d.ts +20 -0
- package/dist/bundlers/vite/generate-bundle/vite-css-cache.d.ts +6 -0
- package/dist/bundlers/vite/generate-bundle.d.ts +2 -1
- package/dist/bundlers/vite/hot-css-modules.d.ts +5 -0
- package/dist/bundlers/vite/map-cache.d.ts +2 -0
- package/dist/bundlers/vite/processed-css-assets.d.ts +16 -0
- package/dist/bundlers/vite/resolve-app-type.d.ts +1 -2
- package/dist/bundlers/vite/source-candidate-scan-signature.d.ts +13 -0
- package/dist/bundlers/vite/source-candidates.d.ts +3 -0
- package/dist/bundlers/vite/source-scan/css-entries.d.ts +1 -0
- package/dist/bundlers/vite/source-scan.d.ts +1 -1
- package/dist/bundlers/vite/weapp-vite-config.d.ts +3 -1
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/helpers.d.ts +1 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +2 -0
- package/dist/bundlers/webpack/loaders/runtime-registry.d.ts +5 -0
- package/dist/cli.js +2 -2
- package/dist/cli.mjs +1 -1
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/css-macro.js +1 -1
- package/dist/css-macro.mjs +1 -1
- package/dist/{defaults-DH0ZQRhy.mjs → defaults-Bqx18S1f.mjs} +2 -35
- package/dist/{defaults-Boc26eel.js → defaults-C_J_kBpw.js} +2 -35
- package/dist/defaults.js +1 -1
- package/dist/defaults.mjs +1 -1
- package/dist/framework/index.d.ts +59 -0
- package/dist/framework.d.ts +1 -0
- package/dist/framework.js +198 -0
- package/dist/framework.mjs +180 -0
- package/dist/{generator-Cb1Zp3Al.js → generator-CzpArpCL.js} +1 -1
- package/dist/{generator-mvNFUvns.mjs → generator-ITLd7PTl.mjs} +1 -1
- package/dist/generator.js +2 -2
- package/dist/generator.mjs +2 -2
- package/dist/{gulp-BfZpaYSQ.mjs → gulp-DfOQERcV.mjs} +44 -16
- package/dist/{gulp-CxGZU0-v.js → gulp-XT8Jc7lH.js} +44 -16
- package/dist/gulp.js +1 -1
- package/dist/gulp.mjs +1 -1
- package/dist/{hmr-timing-DFR51wgo.js → hmr-timing-BMftW7Us.js} +298 -221
- package/dist/{hmr-timing-DNjF8bWA.mjs → hmr-timing-DQIP_8qP.mjs} +297 -220
- package/dist/index.d.ts +1 -0
- package/dist/index.js +20 -4
- package/dist/index.mjs +6 -5
- package/dist/postcss.js +2 -2
- package/dist/postcss.mjs +2 -2
- package/dist/{precheck-30zNPRlI.js → precheck-B0Z8yW7E.js} +98 -27
- package/dist/{precheck-CsFr1q2l.mjs → precheck-CRI90iL1.mjs} +97 -26
- package/dist/presets.js +3 -3
- package/dist/presets.mjs +3 -3
- package/dist/{tailwindcss-CK84uGBp.mjs → tailwindcss-DTq3uYBK.mjs} +2 -2
- package/dist/{tailwindcss-Clpkz1oR.js → tailwindcss-DZEwT3C_.js} +3 -3
- package/dist/{transform-Cju08-aJ.mjs → transform-DfcEjsZF.mjs} +29 -21
- package/dist/{transform-CaVEBOuR.js → transform-YmrmxuF3.js} +29 -21
- package/dist/types/user-defined-options/general.d.ts +3 -1
- package/dist/{utils-Dolmt8EO.js → utils-BCa37Wqj.js} +2 -17
- package/dist/{utils-DsaS975I.mjs → utils-DodxWHGz.mjs} +2 -17
- package/dist/{v3-engine-CQE5JJNZ.js → v3-engine-2rrgylhn.js} +53 -6
- package/dist/{v3-engine-DKBaKWGL.mjs → v3-engine-C6eJ0YzK.mjs} +46 -5
- package/dist/{vite-BBGOjh9e.js → vite-CXHVsHmX.js} +1945 -1280
- package/dist/{vite-CS5DE-HD.mjs → vite-DjI09vVN.mjs} +1944 -1279
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.js +346 -186
- package/dist/weapp-tw-runtime-classset-loader.js +25 -0
- package/dist/{webpack-SPcri_D8.mjs → webpack-BcPpnT90.mjs} +165 -35
- package/dist/{webpack-DIWrcpRo.js → webpack-CfkUkMXG.js} +167 -37
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +9 -4
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
import { i as normalizeWeappTailwindcssGeneratorOptions, t as createWeappTailwindcssGenerator } from "./generator-
|
|
3
|
-
import { h as traverse, m as babelParse, p as replaceWxml, r as resolveStyleOptionsFromContext, x as md5Hash } from "./precheck-
|
|
4
|
-
import { r as isUniAppXEnabled } from "./tailwindcss-
|
|
1
|
+
import { $ as loadTailwindV4DesignSystem, A as normalizeTailwindSourceDirectives, B as splitGeneratorPlaceholderCssBySourceOrder, C as resolveTailwindV4SourceFromPatcher, D as hasTailwindRootDirectives, E as hasTailwindApplyDirective, F as resolveCssEntrySource, G as stripTailwindBanners, H as splitTailwindV4GeneratedCssBySourceOrder, I as VITE_MARKER_RE, K as normalizeConfigDirective, L as createCssAppend, M as normalizeTailwindV3CssEntrySource, N as parseImportRequest, O as hasTailwindSourceDirectives, P as removeTailwindSourceDirectives, Q as filterUnsupportedMiniProgramTailwindV4Candidates, R as hasTailwindGeneratedCss, U as stripGeneratorPlaceholderMarkers, V as splitTailwindGeneratedCssByBanner, W as stripTailwindBanner, _ as resolveTailwindConfigEntriesFromCssCached, at as toPosixPath$1, et as FULL_SOURCE_SCAN_EXTENSION_RE, gt as omitUndefined, it as resolveTailwindV4CssSourceBase, n as resolveTailwindV3SourceFromPatcher, nt as normalizeLegacyContentEntries, ot as createDebug, q as prependConfigDirective, r as resolveTailwindV3SourceOptionsFromPatcher, rt as resolveSourceScanPath, t as resolveTailwindV3Source, tt as isFileMatchedByTailwindSourceEntries, u as getRuntimeClassSetSignature, v as resolveTailwindV4EntriesFromCss, w as resolveTailwindV4SourceOptionsFromPatcher, x as resolveTailwindV4Source$1, z as hasTailwindGeneratedCssMarkers } from "./v3-engine-C6eJ0YzK.mjs";
|
|
2
|
+
import { i as normalizeWeappTailwindcssGeneratorOptions, t as createWeappTailwindcssGenerator } from "./generator-ITLd7PTl.mjs";
|
|
3
|
+
import { h as traverse, m as babelParse, p as replaceWxml, r as resolveStyleOptionsFromContext, x as md5Hash } from "./precheck-CRI90iL1.mjs";
|
|
4
|
+
import { r as isUniAppXEnabled } from "./tailwindcss-DTq3uYBK.mjs";
|
|
5
5
|
import { createRequire } from "node:module";
|
|
6
|
-
import { finalizeMiniProgramCss, postcss, pruneMiniProgramGeneratedCss, removeUnsupportedMiniProgramAtRules } from "@weapp-tailwindcss/postcss";
|
|
7
|
-
import { LRUCache } from "lru-cache";
|
|
8
|
-
import { extractRawCandidatesWithPositions, extractSourceCandidates, extractValidCandidates, resolveProjectSourceFiles, resolveValidTailwindV4Candidates, splitCandidateTokens } from "tailwindcss-patch";
|
|
9
6
|
import { existsSync, readFileSync } from "node:fs";
|
|
10
7
|
import path from "node:path";
|
|
11
8
|
import process from "node:process";
|
|
9
|
+
import { finalizeMiniProgramCss, postcss, pruneMiniProgramGeneratedCss, removeUnsupportedCascadeLayers, removeUnsupportedMiniProgramAtRules } from "@weapp-tailwindcss/postcss";
|
|
10
|
+
import { LRUCache } from "lru-cache";
|
|
11
|
+
import { extractRawCandidatesWithPositions, extractSourceCandidates, extractValidCandidates, resolveProjectSourceFiles, resolveValidTailwindV4Candidates, splitCandidateTokens } from "tailwindcss-patch";
|
|
12
12
|
import { readFile } from "node:fs/promises";
|
|
13
13
|
import { MappingChars2String, unescape } from "@weapp-core/escape";
|
|
14
14
|
//#region src/bundlers/shared/cache.ts
|
|
@@ -101,6 +101,9 @@ function removeTracedTailwindGeneratedContainerRules(root) {
|
|
|
101
101
|
rule.remove();
|
|
102
102
|
});
|
|
103
103
|
}
|
|
104
|
+
function normalizeTraceCommentBefore(value) {
|
|
105
|
+
return value?.includes("\n") ? value : "\n";
|
|
106
|
+
}
|
|
104
107
|
function annotateCssSourceTrace(css, options) {
|
|
105
108
|
if (!isCssSourceTraceEnabled(options.opts) || !options.tokenSources?.size) return css;
|
|
106
109
|
try {
|
|
@@ -115,7 +118,7 @@ function annotateCssSourceTrace(css, options) {
|
|
|
115
118
|
return `${token} <= ${sources.length > 0 ? sources.join(", ") : "<tailwind generated>"}`;
|
|
116
119
|
});
|
|
117
120
|
const comment = postcss.comment({ text: `tokens: ${lines.join(" | ")}` });
|
|
118
|
-
|
|
121
|
+
comment.raws.before = normalizeTraceCommentBefore(rule.raws.before);
|
|
119
122
|
rule.raws.before = "\n";
|
|
120
123
|
rule.parent.insertBefore(rule, comment);
|
|
121
124
|
});
|
|
@@ -132,7 +135,8 @@ function finalizeMiniProgramGeneratorCss(css, target, majorVersion, cssPreflight
|
|
|
132
135
|
return finalizeMiniProgramCss(css, {
|
|
133
136
|
cssPreflight: majorVersion === 4 && options.injectPreflight !== false ? cssPreflight : void 0,
|
|
134
137
|
isTailwindcssV4: majorVersion === 4,
|
|
135
|
-
preservePseudoContentInit: majorVersion === 3
|
|
138
|
+
preservePseudoContentInit: majorVersion === 3,
|
|
139
|
+
tailwindcssV4GradientFallback: options.styleOptions?.cssOptions?.tailwindcssV4GradientFallback ?? options.styleOptions?.tailwindcssV4GradientFallback
|
|
136
140
|
});
|
|
137
141
|
}
|
|
138
142
|
function shouldInjectMiniProgramPreflightForGeneratorCss(opts, options) {
|
|
@@ -141,12 +145,24 @@ function shouldInjectMiniProgramPreflightForGeneratorCss(opts, options) {
|
|
|
141
145
|
return isUniAppXEnabled(opts.uniAppX) && Boolean(options.localImports?.trim());
|
|
142
146
|
}
|
|
143
147
|
function mergeScopedRuntimeWithCurrentRuntime(scopedRuntime, runtime, options) {
|
|
144
|
-
if (options.
|
|
145
|
-
|
|
148
|
+
if (options.majorVersion === 3 && !options.isolateCssSource) return new Set([
|
|
149
|
+
...scopedRuntime,
|
|
150
|
+
...runtime,
|
|
151
|
+
...options.currentCssCandidates ?? []
|
|
152
|
+
]);
|
|
153
|
+
if (options.isolateCssSource) {
|
|
154
|
+
if (options.matchedCssSourceFile) return new Set([...scopedRuntime, ...options.currentCssCandidates ?? []]);
|
|
155
|
+
return new Set([...scopedRuntime, ...options.currentCssCandidates ?? []]);
|
|
156
|
+
}
|
|
157
|
+
if (runtime.size === 0 || !options.cssHandlerOptions.isMainChunk) return scopedRuntime;
|
|
146
158
|
return new Set([...scopedRuntime, ...runtime]);
|
|
147
159
|
}
|
|
148
|
-
function shouldIsolateScopedCssSource(source, sourceEntries) {
|
|
149
|
-
|
|
160
|
+
function shouldIsolateScopedCssSource(majorVersion, source, sourceEntries, options) {
|
|
161
|
+
if (options.target !== "weapp") return false;
|
|
162
|
+
if (source.__weappTailwindcssMeta?.isolateCssSource) return true;
|
|
163
|
+
if (source.__weappTailwindcssMeta?.matchedCssSourceFile && (sourceEntries?.length ?? 0) > 0) return true;
|
|
164
|
+
if (sourceEntries?.length === 0) return false;
|
|
165
|
+
return (majorVersion === 3 || majorVersion === 4) && sourceEntries !== void 0 && options.cssHandlerOptions?.isMainChunk !== true;
|
|
150
166
|
}
|
|
151
167
|
function shouldIsolateCurrentTailwindV4CssCandidates(majorVersion, cssHandlerOptions, options) {
|
|
152
168
|
return majorVersion === 4 && !cssHandlerOptions.isMainChunk && hasTailwindApplyDirective(options.rawSource) && !hasTailwindRootDirectives(options.rawSource) && !options.hasGeneratedCss && !options.hasGeneratedMarkers;
|
|
@@ -164,13 +180,13 @@ function isEmptyCssSourceOrderParts(parts) {
|
|
|
164
180
|
return parts.before.trim().length === 0 && parts.after.trim().length === 0;
|
|
165
181
|
}
|
|
166
182
|
function resolveGeneratorStyleOptions(opts, cssHandlerOptions, generatorStyleOptions) {
|
|
183
|
+
const resolvedStyleOptions = resolveStyleOptionsFromContext(opts);
|
|
167
184
|
const preflightStyleOptions = {
|
|
168
|
-
cssPreflight:
|
|
169
|
-
cssPreflightRange:
|
|
185
|
+
cssPreflight: resolvedStyleOptions.cssPreflight,
|
|
186
|
+
cssPreflightRange: resolvedStyleOptions.cssPreflightRange
|
|
170
187
|
};
|
|
171
188
|
return {
|
|
172
|
-
...
|
|
173
|
-
atRules: opts.atRules,
|
|
189
|
+
...resolvedStyleOptions,
|
|
174
190
|
uniAppXCssTarget: opts.uniAppXCssTarget,
|
|
175
191
|
uniAppXUnsupported: opts.uniAppXUnsupported,
|
|
176
192
|
...cssHandlerOptions,
|
|
@@ -194,9 +210,9 @@ function splitRawSourceByGeneratedCssOrder(rawSource, rawTailwindCss) {
|
|
|
194
210
|
if (exactParts) return exactParts;
|
|
195
211
|
return splitTailwindGeneratedCssByBanner(rawSource);
|
|
196
212
|
}
|
|
197
|
-
function shouldUseGeneratorForCurrentCss(
|
|
213
|
+
function shouldUseGeneratorForCurrentCss(_majorVersion, cssHandlerOptions, options) {
|
|
198
214
|
const hasApplyDirectives = hasTailwindApplyDirective(options.rawSource);
|
|
199
|
-
return options.hasGeneratedCss || options.hasGeneratedMarkers || options.hasSourceDirectives ||
|
|
215
|
+
return options.hasGeneratedCss || options.hasGeneratedMarkers || options.hasSourceDirectives || hasApplyDirectives || cssHandlerOptions.isMainChunk;
|
|
200
216
|
}
|
|
201
217
|
function createRuntimeWithCurrentCssCandidates(runtime, currentCssCandidates, isolateCurrentCssCandidates) {
|
|
202
218
|
return isolateCurrentCssCandidates ? new Set(currentCssCandidates) : currentCssCandidates.length > 0 ? new Set([...runtime, ...currentCssCandidates]) : runtime;
|
|
@@ -548,98 +564,53 @@ function extractStyleDirectiveSources(source) {
|
|
|
548
564
|
let match = SFC_STYLE_BLOCK_RE.exec(source);
|
|
549
565
|
while (match !== null) {
|
|
550
566
|
const styleSource = match[1] ?? "";
|
|
551
|
-
if (hasTailwindSourceDirectives(styleSource)) styleSources.push(styleSource);
|
|
567
|
+
if (hasTailwindSourceDirectives(styleSource, { importFallback: true })) styleSources.push(styleSource);
|
|
552
568
|
match = SFC_STYLE_BLOCK_RE.exec(source);
|
|
553
569
|
}
|
|
554
570
|
if (styleSources.length > 0) return styleSources;
|
|
555
|
-
return hasTailwindSourceDirectives(source) ? [source] : [];
|
|
571
|
+
return hasTailwindSourceDirectives(source, { importFallback: true }) ? [source] : [];
|
|
556
572
|
}
|
|
557
573
|
function resolveSourceSideCssEntrySource(file, sourceOptions, resolveOptions = {}) {
|
|
558
|
-
for (const sourceFile of createSourceStylePathCandidates(file, sourceOptions)) {
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
};
|
|
568
|
-
}
|
|
569
|
-
} catch {
|
|
570
|
-
continue;
|
|
574
|
+
for (const sourceFile of createSourceStylePathCandidates(file, sourceOptions)) try {
|
|
575
|
+
const source = sourceOptions.sourceFile && path.resolve(sourceOptions.sourceFile) === path.resolve(sourceFile) && typeof sourceOptions.sourceCss === "string" ? sourceOptions.sourceCss : existsSync(sourceFile) ? readFileSync(sourceFile, "utf8") : void 0;
|
|
576
|
+
if (source === void 0) continue;
|
|
577
|
+
for (const styleSource of extractStyleDirectiveSources(source)) {
|
|
578
|
+
const cssEntrySource = resolveCssEntrySource(styleSource, path.dirname(sourceFile), resolveOptions);
|
|
579
|
+
if (cssEntrySource) return {
|
|
580
|
+
...cssEntrySource,
|
|
581
|
+
file: sourceFile
|
|
582
|
+
};
|
|
571
583
|
}
|
|
584
|
+
} catch {
|
|
585
|
+
continue;
|
|
572
586
|
}
|
|
573
587
|
}
|
|
574
588
|
//#endregion
|
|
575
|
-
//#region src/bundlers/shared/generator-css/source-resolver.ts
|
|
576
|
-
function
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
}
|
|
585
|
-
function resolveCssHandlerSourceOptions(cssHandlerOptions) {
|
|
586
|
-
return cssHandlerOptions.sourceOptions;
|
|
587
|
-
}
|
|
588
|
-
function createCssEntrySources(cssEntries) {
|
|
589
|
-
return cssEntries?.filter((entry) => typeof entry === "string" && entry.length > 0 && path.isAbsolute(entry)).map((entry) => ({ file: path.resolve(entry) }));
|
|
590
|
-
}
|
|
591
|
-
function mergeCssSources(cssSources, cssEntrySources) {
|
|
592
|
-
const merged = [];
|
|
593
|
-
const seenFiles = /* @__PURE__ */ new Set();
|
|
594
|
-
const addSource = (cssSource) => {
|
|
595
|
-
const file = typeof cssSource.file === "string" && cssSource.file.length > 0 ? path.resolve(cssSource.file) : void 0;
|
|
596
|
-
if (file) {
|
|
597
|
-
if (seenFiles.has(file)) return;
|
|
598
|
-
seenFiles.add(file);
|
|
599
|
-
}
|
|
600
|
-
merged.push(cssSource);
|
|
601
|
-
};
|
|
602
|
-
for (const cssSource of cssSources ?? []) addSource(cssSource);
|
|
603
|
-
for (const cssSource of cssEntrySources ?? []) addSource(cssSource);
|
|
604
|
-
return merged.length > 0 ? merged : void 0;
|
|
605
|
-
}
|
|
606
|
-
function createSingleTailwindV4SourceOptions(sourceOptions, options) {
|
|
607
|
-
return omitUndefined({
|
|
608
|
-
projectRoot: sourceOptions.projectRoot,
|
|
609
|
-
baseFallbacks: sourceOptions.baseFallbacks,
|
|
610
|
-
packageName: sourceOptions.packageName,
|
|
611
|
-
base: options.base,
|
|
612
|
-
css: options.css
|
|
613
|
-
});
|
|
589
|
+
//#region src/bundlers/shared/generator-css/source-resolver/apply-reference.ts
|
|
590
|
+
function createTailwindV4ApplyReferenceSource(css, sourceOptions) {
|
|
591
|
+
if (!hasTailwindApplyDirective(css) || hasTailwindRootDirectives(css)) return css;
|
|
592
|
+
const utilities = collectTailwindApplyUtilities(css);
|
|
593
|
+
return [
|
|
594
|
+
`@import "${sourceOptions.packageName ?? "tailwindcss"}" source(none);`,
|
|
595
|
+
utilities.length > 0 ? `@source inline(${JSON.stringify(utilities.join(" "))});` : void 0,
|
|
596
|
+
css
|
|
597
|
+
].filter(Boolean).join("\n");
|
|
614
598
|
}
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
const
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
...sourceOptions,
|
|
626
|
-
sourceFile: sourceOptions.sourceFile ?? cssEntry
|
|
627
|
-
});
|
|
628
|
-
return withGeneratorSourceMetadata(await resolveTailwindV4Source$1({
|
|
629
|
-
...omitUndefined(singleEntrySourceOptions),
|
|
630
|
-
base,
|
|
631
|
-
css: normalizeConfigDirective(css, config),
|
|
632
|
-
cssEntries: [cssEntry]
|
|
633
|
-
}), {
|
|
634
|
-
matchedCssSourceFile: cssEntry,
|
|
635
|
-
sourceBase: base,
|
|
636
|
-
sourceCss: css
|
|
599
|
+
function collectTailwindApplyUtilities(css) {
|
|
600
|
+
let root;
|
|
601
|
+
try {
|
|
602
|
+
root = postcss.parse(css);
|
|
603
|
+
} catch {
|
|
604
|
+
return [];
|
|
605
|
+
}
|
|
606
|
+
const utilities = /* @__PURE__ */ new Set();
|
|
607
|
+
root.walkAtRules("apply", (rule) => {
|
|
608
|
+
for (const utility of splitCandidateTokens(rule.params)) utilities.add(utility);
|
|
637
609
|
});
|
|
610
|
+
return [...utilities].sort();
|
|
638
611
|
}
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
return path.dirname(path.resolve(normalized));
|
|
642
|
-
}
|
|
612
|
+
//#endregion
|
|
613
|
+
//#region src/bundlers/shared/generator-css/source-resolver/config.ts
|
|
643
614
|
function resolveExistingConfigPath(config, configRequest, file, sourceOptions) {
|
|
644
615
|
if (config && existsSync(config)) return config;
|
|
645
616
|
if (!configRequest || path.isAbsolute(configRequest)) return sourceOptions.config;
|
|
@@ -666,20 +637,8 @@ function resolveExistingConfigPath(config, configRequest, file, sourceOptions) {
|
|
|
666
637
|
for (const candidate of configCandidates) if (existsSync(candidate)) return candidate;
|
|
667
638
|
return sourceOptions.config;
|
|
668
639
|
}
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
if (!from || !path.isAbsolute(from)) return path.isAbsolute(file) || Boolean(sourceOptions?.sourceFile) || Boolean(sourceOptions?.cssSources?.length);
|
|
672
|
-
return true;
|
|
673
|
-
}
|
|
674
|
-
function shouldResolveSourceSideCssEntry(rawSource) {
|
|
675
|
-
return rawSource.includes("@apply") || hasTailwindRootDirectives(rawSource, { importFallback: true }) || hasTailwindSourceDirectives(rawSource, { importFallback: true }) || hasTailwindGeneratedCss(rawSource) || hasTailwindGeneratedCssMarkers(rawSource);
|
|
676
|
-
}
|
|
677
|
-
function shouldPreferTailwindV3SourceSideEntry(rawSource, sourceSideEntrySource) {
|
|
678
|
-
return Boolean(sourceSideEntrySource) && !hasTailwindSourceDirectives(rawSource, { importFallback: true });
|
|
679
|
-
}
|
|
680
|
-
function shouldPreferResolvedSourceSideEntry(cssEntrySource, sourceSideEntrySource) {
|
|
681
|
-
return Boolean(sourceSideEntrySource?.config) && Boolean(cssEntrySource?.configRequest) && (!cssEntrySource?.config || !existsSync(cssEntrySource.config));
|
|
682
|
-
}
|
|
640
|
+
//#endregion
|
|
641
|
+
//#region src/bundlers/shared/generator-css/source-resolver/matching.ts
|
|
683
642
|
function normalizeCssSourceForCompare(css) {
|
|
684
643
|
return stripGeneratorPlaceholderMarkers(stripTailwindBanners(css)).trim();
|
|
685
644
|
}
|
|
@@ -730,6 +689,107 @@ function scoreTailwindV4CssSourceFileMatch(file, cssSourceFile, sourceOptions) {
|
|
|
730
689
|
else if (sourceBase.endsWith(`/${outputBase}`)) bestScore = Math.max(bestScore, 1e3 + outputBase.length);
|
|
731
690
|
return bestScore;
|
|
732
691
|
}
|
|
692
|
+
//#endregion
|
|
693
|
+
//#region src/bundlers/shared/generator-css/source-resolver/metadata.ts
|
|
694
|
+
function withGeneratorSourceMetadata(source, metadata) {
|
|
695
|
+
return {
|
|
696
|
+
...source,
|
|
697
|
+
__weappTailwindcssMeta: metadata
|
|
698
|
+
};
|
|
699
|
+
}
|
|
700
|
+
function withMatchedSourceSideMetadata(source, resolvedEntrySource) {
|
|
701
|
+
return resolvedEntrySource.file ? withGeneratorSourceMetadata(source, {
|
|
702
|
+
isolateCssSource: true,
|
|
703
|
+
matchedCssSourceFile: resolvedEntrySource.file,
|
|
704
|
+
sourceBase: resolvedEntrySource.base,
|
|
705
|
+
sourceCss: resolvedEntrySource.css
|
|
706
|
+
}) : source;
|
|
707
|
+
}
|
|
708
|
+
//#endregion
|
|
709
|
+
//#region src/bundlers/shared/generator-css/source-resolver/postcss-source.ts
|
|
710
|
+
function resolvePostcssFromOption(cssHandlerOptions) {
|
|
711
|
+
const from = cssHandlerOptions.postcssOptions?.options?.from;
|
|
712
|
+
return typeof from === "string" && from.length > 0 ? from : void 0;
|
|
713
|
+
}
|
|
714
|
+
function resolvePostcssSourceFile(cssHandlerOptions) {
|
|
715
|
+
const from = resolvePostcssFromOption(cssHandlerOptions);
|
|
716
|
+
if (!from || !path.isAbsolute(from)) return;
|
|
717
|
+
return from.replace(/[?#].*$/, "");
|
|
718
|
+
}
|
|
719
|
+
function resolveCssHandlerSourceOptions(cssHandlerOptions) {
|
|
720
|
+
return cssHandlerOptions.sourceOptions;
|
|
721
|
+
}
|
|
722
|
+
function resolveCssSourceBase(file, cssHandlerOptions) {
|
|
723
|
+
const normalized = (resolvePostcssFromOption(cssHandlerOptions) ?? file).replace(/[?#].*$/, "");
|
|
724
|
+
return path.dirname(path.resolve(normalized));
|
|
725
|
+
}
|
|
726
|
+
//#endregion
|
|
727
|
+
//#region src/bundlers/shared/generator-css/source-resolver.ts
|
|
728
|
+
function createCssEntrySources(cssEntries) {
|
|
729
|
+
return cssEntries?.filter((entry) => typeof entry === "string" && entry.length > 0 && path.isAbsolute(entry)).map((entry) => ({ file: path.resolve(entry) }));
|
|
730
|
+
}
|
|
731
|
+
function mergeCssSources(cssSources, cssEntrySources) {
|
|
732
|
+
const merged = [];
|
|
733
|
+
const seenFiles = /* @__PURE__ */ new Set();
|
|
734
|
+
const addSource = (cssSource) => {
|
|
735
|
+
const file = typeof cssSource.file === "string" && cssSource.file.length > 0 ? path.resolve(cssSource.file) : void 0;
|
|
736
|
+
if (file) {
|
|
737
|
+
if (seenFiles.has(file)) return;
|
|
738
|
+
seenFiles.add(file);
|
|
739
|
+
}
|
|
740
|
+
merged.push(cssSource);
|
|
741
|
+
};
|
|
742
|
+
for (const cssSource of cssSources ?? []) addSource(cssSource);
|
|
743
|
+
for (const cssSource of cssEntrySources ?? []) addSource(cssSource);
|
|
744
|
+
return merged.length > 0 ? merged : void 0;
|
|
745
|
+
}
|
|
746
|
+
function createSingleTailwindV4SourceOptions(sourceOptions, options) {
|
|
747
|
+
return omitUndefined({
|
|
748
|
+
projectRoot: sourceOptions.projectRoot,
|
|
749
|
+
baseFallbacks: sourceOptions.baseFallbacks,
|
|
750
|
+
packageName: sourceOptions.packageName,
|
|
751
|
+
base: options.base,
|
|
752
|
+
css: options.css
|
|
753
|
+
});
|
|
754
|
+
}
|
|
755
|
+
async function resolveTailwindV4CssEntrySource(cssEntry, sourceOptions) {
|
|
756
|
+
const { cssEntries: _cssEntries, cssSources: _cssSources, ...singleEntrySourceOptions } = sourceOptions;
|
|
757
|
+
if (!existsSync(cssEntry)) return resolveTailwindV4Source$1({
|
|
758
|
+
...omitUndefined(singleEntrySourceOptions),
|
|
759
|
+
cssEntries: [cssEntry]
|
|
760
|
+
});
|
|
761
|
+
const css = readFileSync(cssEntry, "utf8");
|
|
762
|
+
const base = path.dirname(path.resolve(cssEntry));
|
|
763
|
+
const entrySource = resolveCssEntrySource(css, base, { removeConfig: false });
|
|
764
|
+
const config = resolveExistingConfigPath(entrySource?.config, entrySource?.configRequest, cssEntry, {
|
|
765
|
+
...sourceOptions,
|
|
766
|
+
sourceFile: sourceOptions.sourceFile ?? cssEntry
|
|
767
|
+
});
|
|
768
|
+
return withGeneratorSourceMetadata(await resolveTailwindV4Source$1({
|
|
769
|
+
...omitUndefined(singleEntrySourceOptions),
|
|
770
|
+
base,
|
|
771
|
+
css: normalizeConfigDirective(css, config),
|
|
772
|
+
cssEntries: [cssEntry]
|
|
773
|
+
}), {
|
|
774
|
+
matchedCssSourceFile: cssEntry,
|
|
775
|
+
sourceBase: base,
|
|
776
|
+
sourceCss: css
|
|
777
|
+
});
|
|
778
|
+
}
|
|
779
|
+
function canResolveSourceSideCssEntry(file, cssHandlerOptions, sourceOptions) {
|
|
780
|
+
const from = resolvePostcssFromOption(cssHandlerOptions);
|
|
781
|
+
if (!from || !path.isAbsolute(from)) return path.isAbsolute(file) || Boolean(sourceOptions?.sourceFile) || Boolean(sourceOptions?.cssSources?.length);
|
|
782
|
+
return true;
|
|
783
|
+
}
|
|
784
|
+
function shouldResolveSourceSideCssEntry(rawSource) {
|
|
785
|
+
return rawSource.includes("@apply") || hasTailwindRootDirectives(rawSource, { importFallback: true }) || hasTailwindSourceDirectives(rawSource, { importFallback: true }) || hasTailwindGeneratedCss(rawSource) || hasTailwindGeneratedCssMarkers(rawSource);
|
|
786
|
+
}
|
|
787
|
+
function shouldPreferTailwindV3SourceSideEntry(rawSource, sourceSideEntrySource) {
|
|
788
|
+
return Boolean(sourceSideEntrySource) && !hasTailwindSourceDirectives(rawSource, { importFallback: true });
|
|
789
|
+
}
|
|
790
|
+
function shouldPreferResolvedSourceSideEntry(cssEntrySource, sourceSideEntrySource) {
|
|
791
|
+
return Boolean(sourceSideEntrySource?.config) && (Boolean(cssEntrySource?.configRequest) || !cssEntrySource?.config) && (!cssEntrySource?.config || !existsSync(cssEntrySource.config));
|
|
792
|
+
}
|
|
733
793
|
function resolveMatchingTailwindV4CssEntry(rawSource, file, sourceOptions) {
|
|
734
794
|
const cssEntries = sourceOptions.cssEntries;
|
|
735
795
|
if (!cssEntries?.length) return;
|
|
@@ -907,12 +967,6 @@ async function resolveTailwindV4SourceSideEntrySource(resolvedEntrySource, sourc
|
|
|
907
967
|
css
|
|
908
968
|
})), resolvedEntrySource);
|
|
909
969
|
}
|
|
910
|
-
function withGeneratorSourceMetadata(source, metadata) {
|
|
911
|
-
return {
|
|
912
|
-
...source,
|
|
913
|
-
__weappTailwindcssMeta: metadata
|
|
914
|
-
};
|
|
915
|
-
}
|
|
916
970
|
function resolveTailwindV3SourceEntries(source) {
|
|
917
971
|
if (!("version" in source) || source.version !== 3) return;
|
|
918
972
|
const entries = normalizeLegacyContentEntries(source.configObject?.content, source.cwd, { relativeBase: source.config ? path.dirname(source.config) : source.cwd });
|
|
@@ -922,35 +976,6 @@ function withTailwindV3SourceMetadata(source) {
|
|
|
922
976
|
const sourceEntries = resolveTailwindV3SourceEntries(source);
|
|
923
977
|
return sourceEntries ? withGeneratorSourceMetadata(source, { sourceEntries }) : source;
|
|
924
978
|
}
|
|
925
|
-
function withMatchedSourceSideMetadata(source, resolvedEntrySource) {
|
|
926
|
-
return resolvedEntrySource.file ? withGeneratorSourceMetadata(source, {
|
|
927
|
-
matchedCssSourceFile: resolvedEntrySource.file,
|
|
928
|
-
sourceBase: resolvedEntrySource.base,
|
|
929
|
-
sourceCss: resolvedEntrySource.css
|
|
930
|
-
}) : source;
|
|
931
|
-
}
|
|
932
|
-
function createTailwindV4ApplyReferenceSource(css, sourceOptions) {
|
|
933
|
-
if (!hasTailwindApplyDirective(css) || hasTailwindRootDirectives(css)) return css;
|
|
934
|
-
const utilities = collectTailwindApplyUtilities(css);
|
|
935
|
-
return [
|
|
936
|
-
`@import "${sourceOptions.packageName ?? "tailwindcss"}" source(none);`,
|
|
937
|
-
utilities.length > 0 ? `@source inline(${JSON.stringify(utilities.join(" "))});` : void 0,
|
|
938
|
-
css
|
|
939
|
-
].filter(Boolean).join("\n");
|
|
940
|
-
}
|
|
941
|
-
function collectTailwindApplyUtilities(css) {
|
|
942
|
-
let root;
|
|
943
|
-
try {
|
|
944
|
-
root = postcss.parse(css);
|
|
945
|
-
} catch {
|
|
946
|
-
return [];
|
|
947
|
-
}
|
|
948
|
-
const utilities = /* @__PURE__ */ new Set();
|
|
949
|
-
root.walkAtRules("apply", (rule) => {
|
|
950
|
-
for (const utility of splitCandidateTokens(rule.params)) utilities.add(utility);
|
|
951
|
-
});
|
|
952
|
-
return [...utilities].sort();
|
|
953
|
-
}
|
|
954
979
|
async function resolveGeneratorSource(majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions, selectionOptions) {
|
|
955
980
|
const base = resolveCssSourceBase(file, cssHandlerOptions);
|
|
956
981
|
const cssEntrySource = resolveCssEntrySource(rawSource, base, {
|
|
@@ -983,15 +1008,19 @@ async function resolveGeneratorSource(majorVersion, runtimeState, rawSource, fil
|
|
|
983
1008
|
css: normalizeTailwindV3CssEntrySource(resolvedEntrySource.css),
|
|
984
1009
|
...config ? { config } : {}
|
|
985
1010
|
}));
|
|
1011
|
+
const cssEntrySourceEntries = await resolveTailwindConfigEntriesFromCssCached(rawSource, resolvedEntrySource.base);
|
|
1012
|
+
const sourceMetadata = sourceWithMetadata.__weappTailwindcssMeta;
|
|
1013
|
+
const matchedSourceFile = resolvedEntrySource.file ?? sourceSideEntrySource?.file;
|
|
986
1014
|
return withGeneratorSourceMetadata(sourceWithMetadata, {
|
|
987
|
-
...
|
|
988
|
-
matchedCssSourceFile:
|
|
1015
|
+
...sourceMetadata,
|
|
1016
|
+
matchedCssSourceFile: matchedSourceFile,
|
|
1017
|
+
sourceEntries: cssEntrySourceEntries?.entries ?? sourceMetadata?.sourceEntries
|
|
989
1018
|
});
|
|
990
1019
|
}
|
|
991
1020
|
const sourceOptions = tryResolveTailwindV4SourceOptions(runtimeState);
|
|
992
1021
|
const resolvedSourceOptions = sourceOptions ? omitUndefined({
|
|
993
1022
|
...sourceOptions,
|
|
994
|
-
sourceFile: resolvePostcssSourceFile(cssHandlerOptions),
|
|
1023
|
+
sourceFile: sourceOptions.sourceFile ?? resolvePostcssSourceFile(cssHandlerOptions),
|
|
995
1024
|
...resolveCssHandlerSourceOptions(cssHandlerOptions),
|
|
996
1025
|
cssEntries: selectionOptions?.cssEntries ?? sourceOptions.cssEntries,
|
|
997
1026
|
cssSources: mergeCssSources(sourceOptions.cssSources, sourceOptions.cssSources?.length ? void 0 : createCssEntrySources(selectionOptions?.cssEntries ?? sourceOptions.cssEntries))
|
|
@@ -1005,17 +1034,18 @@ async function resolveGeneratorSource(majorVersion, runtimeState, rawSource, fil
|
|
|
1005
1034
|
}));
|
|
1006
1035
|
}
|
|
1007
1036
|
const shouldPreferSourceSideEntry = shouldResolveSourceSideCssEntry(rawSource) || Boolean(cssEntrySource?.css.includes("weapp-tailwindcss generator-placeholder")) && (sourceOptions?.cssEntries?.length ?? 0) <= 1;
|
|
1008
|
-
const sourceSideEntrySource = normalizedSourceOptions && shouldPreferSourceSideEntry && canResolveSourceSideCssEntry(file, cssHandlerOptions, normalizedSourceOptions) ? resolveSourceSideCssEntrySource(file, normalizedSourceOptions, { removeConfig: false }) : void 0;
|
|
1037
|
+
const sourceSideEntrySource = normalizedSourceOptions && (shouldPreferSourceSideEntry || normalizedSourceOptions.sourceFile !== void 0) && canResolveSourceSideCssEntry(file, cssHandlerOptions, normalizedSourceOptions) ? resolveSourceSideCssEntrySource(file, normalizedSourceOptions, { removeConfig: false }) : void 0;
|
|
1009
1038
|
const matchedCssEntrySource = normalizedSourceOptions ? await resolveMatchingTailwindV4CssEntry(rawSource, file, normalizedSourceOptions) : void 0;
|
|
1010
1039
|
const matchedCssSource = normalizedSourceOptions && !matchedCssEntrySource ? await resolveMatchingTailwindV4CssSource(rawSource, file, cssHandlerOptions, normalizedSourceOptions) : void 0;
|
|
1011
1040
|
const candidateMatchedCssSource = normalizedSourceOptions && !matchedCssEntrySource ? await resolveCandidateMatchedTailwindV4CssSource(rawSource, cssHandlerOptions, normalizedSourceOptions, selectionOptions) : void 0;
|
|
1012
|
-
const
|
|
1041
|
+
const singleConfiguredCssSource = normalizedSourceOptions?.cssSources?.length === 1 ? await resolveSingleTailwindV4CssSource(normalizedSourceOptions.cssSources[0], normalizedSourceOptions, { matched: true }) : void 0;
|
|
1042
|
+
const configuredCssSource = normalizedSourceOptions && hasConfiguredTailwindV4CssSource(normalizedSourceOptions) && hasTailwindGeneratedCssMarkers(rawSource) ? matchedCssSource ?? candidateMatchedCssSource ?? singleConfiguredCssSource ?? await resolveTailwindV4Source$1(normalizedSourceOptions) : void 0;
|
|
1013
1043
|
if (configuredCssSource) return generatorOptions?.config ? {
|
|
1014
1044
|
...configuredCssSource,
|
|
1015
1045
|
css: prependConfigDirective(configuredCssSource.css, generatorOptions.config)
|
|
1016
1046
|
} : configuredCssSource;
|
|
1017
1047
|
const mainCssEntrySource = normalizedSourceOptions && cssHandlerOptions.isMainChunk && normalizedSourceOptions.cssEntries?.length === 1 ? await resolveTailwindV4CssEntrySource(normalizedSourceOptions.cssEntries[0], normalizedSourceOptions) : void 0;
|
|
1018
|
-
const preferredCssEntrySource = matchedCssEntrySource ?? matchedCssSource ?? candidateMatchedCssSource ?? mainCssEntrySource;
|
|
1048
|
+
const preferredCssEntrySource = matchedCssEntrySource ?? matchedCssSource ?? candidateMatchedCssSource ?? mainCssEntrySource ?? singleConfiguredCssSource;
|
|
1019
1049
|
if (preferredCssEntrySource) return generatorOptions?.config ? {
|
|
1020
1050
|
...preferredCssEntrySource,
|
|
1021
1051
|
css: prependConfigDirective(preferredCssEntrySource.css, generatorOptions.config)
|
|
@@ -1055,7 +1085,7 @@ async function resolveGeneratorSources(majorVersion, runtimeState, rawSource, fi
|
|
|
1055
1085
|
sourceFile: resolvePostcssSourceFile(cssHandlerOptions),
|
|
1056
1086
|
...resolveCssHandlerSourceOptions(cssHandlerOptions),
|
|
1057
1087
|
cssEntries,
|
|
1058
|
-
cssSources: mergeCssSources(sourceOptionsFromPatcher.cssSources, sourceOptionsFromPatcher.cssSources?.length ? void 0 : createCssEntrySources(cssEntries))
|
|
1088
|
+
cssSources: mergeCssSources(mergeCssSources(sourceOptionsFromPatcher.cssSources, selectionOptions?.cssSources), sourceOptionsFromPatcher.cssSources?.length || selectionOptions?.cssSources?.length ? void 0 : createCssEntrySources(cssEntries))
|
|
1059
1089
|
});
|
|
1060
1090
|
} catch {
|
|
1061
1091
|
const resolved = await resolveGeneratorSource(majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions, selectionOptions);
|
|
@@ -1066,7 +1096,7 @@ async function resolveGeneratorSources(majorVersion, runtimeState, rawSource, fi
|
|
|
1066
1096
|
...matchedCssEntrySource,
|
|
1067
1097
|
css: prependConfigDirective(matchedCssEntrySource.css, generatorOptions.config)
|
|
1068
1098
|
} : matchedCssEntrySource];
|
|
1069
|
-
const sourceSideCssSource = await resolveTailwindV4SourceSideEntrySource(
|
|
1099
|
+
const sourceSideCssSource = await resolveTailwindV4SourceSideEntrySource(canResolveSourceSideCssEntry(file, cssHandlerOptions, sourceOptions) ? resolveSourceSideCssEntrySource(file, sourceOptions, { removeConfig: false }) : void 0, sourceOptions, generatorOptions, file);
|
|
1070
1100
|
if (sourceSideCssSource) return [sourceSideCssSource];
|
|
1071
1101
|
const matchedCssSource = await resolveMatchingTailwindV4CssSource(rawSource, file, cssHandlerOptions, sourceOptions);
|
|
1072
1102
|
const candidateMatchedCssSource = await resolveCandidateMatchedTailwindV4CssSource(rawSource, cssHandlerOptions, sourceOptions, selectionOptions);
|
|
@@ -1101,6 +1131,10 @@ async function resolveGeneratorSourceEntries(source, runtimeState) {
|
|
|
1101
1131
|
if (sourceMetadata?.sourceEntries) return sourceMetadata.sourceEntries;
|
|
1102
1132
|
if (!("css" in source) || !("base" in source) || !("baseFallbacks" in source)) return;
|
|
1103
1133
|
const resolved = await resolveTailwindV4EntriesFromCss(sourceMetadata?.sourceCss ?? source.css, sourceMetadata?.sourceBase ?? source.base);
|
|
1134
|
+
if (resolved?.entries.length === 0 && !resolved.inlineCandidates.included.size && !resolved.inlineCandidates.excluded.size && !resolved.dependencies.length) {
|
|
1135
|
+
if (sourceMetadata?.matchedCssSourceFile) return [];
|
|
1136
|
+
return;
|
|
1137
|
+
}
|
|
1104
1138
|
if (resolved?.entries.length || !resolved?.explicit && !sourceMetadata?.matchedCssSourceFile || !runtimeState) return resolved?.entries;
|
|
1105
1139
|
const matchingCssSource = tryResolveTailwindV4SourceOptions(runtimeState)?.cssSources?.find((cssSource) => {
|
|
1106
1140
|
if (sourceMetadata?.matchedCssSourceFile && typeof cssSource.file === "string" && path.resolve(cssSource.file) === path.resolve(sourceMetadata.matchedCssSourceFile)) return true;
|
|
@@ -1524,6 +1558,16 @@ function isCommentOnlyCss(source) {
|
|
|
1524
1558
|
return false;
|
|
1525
1559
|
}
|
|
1526
1560
|
}
|
|
1561
|
+
function unwrapMiniProgramCascadeLayers(source) {
|
|
1562
|
+
if (!source.includes("@layer")) return source;
|
|
1563
|
+
try {
|
|
1564
|
+
const root = postcss.parse(source);
|
|
1565
|
+
removeUnsupportedCascadeLayers(root);
|
|
1566
|
+
return root.toString();
|
|
1567
|
+
} catch {
|
|
1568
|
+
return source;
|
|
1569
|
+
}
|
|
1570
|
+
}
|
|
1527
1571
|
function stripTailwindSourceMediaFragments(source) {
|
|
1528
1572
|
let removedSourceMediaStart = false;
|
|
1529
1573
|
return source.split(/\r?\n/).filter((line) => {
|
|
@@ -1691,7 +1735,7 @@ async function transformGeneratorUserCss(source, options) {
|
|
|
1691
1735
|
if (source.trim().length === 0) return "";
|
|
1692
1736
|
const cleanedSource = removeTailwindSourceDirectives(removeTailwindV4GeneratorAtRules(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(source))), { importFallback: options.importFallback });
|
|
1693
1737
|
if (cleanedSource.trim().length === 0) return "";
|
|
1694
|
-
const userSource = stripUnmatchedTailwindSourceMediaCloseFragments(removeTailwindApplyAtRules(removeTailwindSourceDirectives(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(options.generatorTarget === "weapp" ? removeUnsupportedMiniProgramAtRules(cleanedSource) : cleanedSource)), { importFallback: options.importFallback })));
|
|
1738
|
+
const userSource = stripUnmatchedTailwindSourceMediaCloseFragments(removeTailwindApplyAtRules(removeTailwindSourceDirectives(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(options.generatorTarget === "weapp" ? removeUnsupportedMiniProgramAtRules(unwrapMiniProgramCascadeLayers(cleanedSource)) : cleanedSource)), { importFallback: options.importFallback })));
|
|
1695
1739
|
if (userSource.trim().length === 0) return "";
|
|
1696
1740
|
if (isCommentOnlyCss(userSource)) return userSource;
|
|
1697
1741
|
if (options.generatorTarget !== "weapp") return userSource;
|
|
@@ -1856,7 +1900,7 @@ function pushConcurrentTaskFactories(queue, factories, limit) {
|
|
|
1856
1900
|
//#region src/bundlers/shared/generator-css/validate.ts
|
|
1857
1901
|
const SUPPORTED_GENERATOR_MAJOR_VERSIONS = new Set([3, 4]);
|
|
1858
1902
|
async function validateCandidatesByGenerator(options) {
|
|
1859
|
-
const { candidates, cssHandlerOptions, debug, file, opts, rawSource, runtimeState } = options;
|
|
1903
|
+
const { candidates, cssHandlerOptions, debug, file, opts, rawSource, runtimeState, skipGenerateFallback } = options;
|
|
1860
1904
|
const majorVersion = runtimeState.twPatcher.majorVersion;
|
|
1861
1905
|
if (!SUPPORTED_GENERATOR_MAJOR_VERSIONS.has(majorVersion ?? 0) || candidates.size === 0) return /* @__PURE__ */ new Set();
|
|
1862
1906
|
const generatorOptions = {
|
|
@@ -1872,6 +1916,7 @@ async function validateCandidatesByGenerator(options) {
|
|
|
1872
1916
|
if (generatorOptions.bareArbitraryValues === void 0 || generatorOptions.bareArbitraryValues === false) {
|
|
1873
1917
|
if (typeof generator.validateCandidates === "function") return generator.validateCandidates(candidates);
|
|
1874
1918
|
}
|
|
1919
|
+
if (skipGenerateFallback) return /* @__PURE__ */ new Set();
|
|
1875
1920
|
return (await generator.generate({
|
|
1876
1921
|
bareArbitraryValues: generatorOptions.bareArbitraryValues,
|
|
1877
1922
|
candidates,
|
|
@@ -1929,6 +1974,7 @@ async function generateCssByGenerator(options) {
|
|
|
1929
1974
|
const runtimeWithCurrentCss = createRuntimeWithCurrentCssCandidates(runtime, currentCssCandidates, isolateCurrentCssCandidates);
|
|
1930
1975
|
const sources = await resolveGeneratorSources(majorVersion, runtimeState, generatorRawSource, file, cssHandlerOptions, generatorOptions, {
|
|
1931
1976
|
cssEntries: opts.cssEntries,
|
|
1977
|
+
cssSources: options.cssSources,
|
|
1932
1978
|
getSourceCandidatesForEntries,
|
|
1933
1979
|
runtime: runtimeWithCurrentCss
|
|
1934
1980
|
});
|
|
@@ -1938,18 +1984,22 @@ async function generateCssByGenerator(options) {
|
|
|
1938
1984
|
const generated = mergeGeneratorResults((await runWithConcurrency(sources.map((source) => async () => {
|
|
1939
1985
|
const generator = createWeappTailwindcssGenerator(source);
|
|
1940
1986
|
const sourceEntries = getSourceCandidatesForEntries && (majorVersion === 3 || majorVersion === 4) ? await resolveGeneratorSourceEntries(source, runtimeState) : void 0;
|
|
1941
|
-
const scopedRuntime = sourceEntries ? getSourceCandidatesForEntries?.(sourceEntries) : void 0;
|
|
1942
|
-
const isolateCssSource = shouldIsolateScopedCssSource(source, sourceEntries
|
|
1987
|
+
const scopedRuntime = sourceEntries && sourceEntries.length > 0 ? getSourceCandidatesForEntries?.(sourceEntries) : void 0;
|
|
1988
|
+
const isolateCssSource = shouldIsolateScopedCssSource(majorVersion, source, sourceEntries, {
|
|
1989
|
+
cssHandlerOptions,
|
|
1990
|
+
target: generatorOptions.target
|
|
1991
|
+
});
|
|
1943
1992
|
const sourceMetadata = source.__weappTailwindcssMeta;
|
|
1944
1993
|
const matchedCssSourceFile = Boolean(sourceMetadata?.matchedCssSourceFile);
|
|
1945
1994
|
if (options.deferEmptyScopedCssSource && isolateCssSource && scopedRuntime?.size === 0 && currentCssCandidates.length === 0 && !cssHandlerOptions.isMainChunk) {
|
|
1946
1995
|
debug("defer empty scoped css source generation: %s", file);
|
|
1947
1996
|
return;
|
|
1948
1997
|
}
|
|
1949
|
-
const sourceRuntime = scopedRuntime && (scopedRuntime.size > 0 || isolateCssSource) ? isolateCurrentCssCandidates ? runtimeWithCurrentCss : mergeScopedRuntimeWithCurrentRuntime(scopedRuntime, runtimeWithCurrentCss, {
|
|
1998
|
+
const sourceRuntime = scopedRuntime && (scopedRuntime.size > 0 || isolateCssSource) || isolateCssSource ? isolateCurrentCssCandidates ? runtimeWithCurrentCss : mergeScopedRuntimeWithCurrentRuntime(scopedRuntime ?? /* @__PURE__ */ new Set(), runtimeWithCurrentCss, {
|
|
1950
1999
|
currentCssCandidates,
|
|
1951
2000
|
cssHandlerOptions,
|
|
1952
2001
|
isolateCssSource,
|
|
2002
|
+
majorVersion,
|
|
1953
2003
|
matchedCssSourceFile
|
|
1954
2004
|
}) : runtimeWithCurrentCss;
|
|
1955
2005
|
const generatorRuntime = majorVersion === 4 && generatorOptions.target === "weapp" ? filterUnsupportedMiniProgramTailwindV4Candidates(sourceRuntime) : sourceRuntime;
|
|
@@ -1969,7 +2019,10 @@ async function generateCssByGenerator(options) {
|
|
|
1969
2019
|
if ((generated.target !== "weapp" || !hasUserCssLayerBlocks(generatorRawSource)) && typeof options.previousCss === "string" && typeof generated.incrementalCss === "string") {
|
|
1970
2020
|
const incrementalCss = stripTailwindBanner(generated.incrementalCss);
|
|
1971
2021
|
return {
|
|
1972
|
-
css: restoreLocalCssImports(incrementalCss.trim().length > 0 ? createCssAppend(options.previousCss, finalizeMiniProgramGeneratorCss(incrementalCss, generated.target, majorVersion, opts.cssPreflight, {
|
|
2022
|
+
css: restoreLocalCssImports(incrementalCss.trim().length > 0 ? createCssAppend(options.previousCss, finalizeMiniProgramGeneratorCss(incrementalCss, generated.target, majorVersion, opts.cssPreflight, {
|
|
2023
|
+
injectPreflight: false,
|
|
2024
|
+
styleOptions: generatorStyleOptions
|
|
2025
|
+
})) : options.previousCss, localImportParts?.imports),
|
|
1973
2026
|
target: generated.target,
|
|
1974
2027
|
source: "generator",
|
|
1975
2028
|
dependencies: generated.dependencies,
|
|
@@ -2001,7 +2054,8 @@ async function generateCssByGenerator(options) {
|
|
|
2001
2054
|
const beforeUserCss = await transformGeneratorUserCss(orderedExtraCss.before, userCssOptions);
|
|
2002
2055
|
const afterLayerUserCss = await transformGeneratorUserCss(afterLayerParts.layer, userCssOptions);
|
|
2003
2056
|
const afterUserCss = await transformGeneratorUserCss(afterLayerParts.rest, userCssOptions);
|
|
2004
|
-
|
|
2057
|
+
const fallbackLayerUserCss = generated.target === "weapp" && afterLayerParts.layer.trim().length === 0 && hasUserCssLayerBlocks(userCssRawSource) ? await transformGeneratorUserCss(splitUserCssLayerBlocks(userCssRawSource).layer, userCssOptions) : "";
|
|
2058
|
+
css = createCssSourceOrderAppend$1(createCssSourceOrderAppend$1(createCssSourceOrderAppend$1(beforeUserCss, generated.target === "weapp" ? wrapUserLayerComponentsCss(createCssSourceOrderAppend$1(afterLayerUserCss, fallbackLayerUserCss)) : afterLayerUserCss), css), afterUserCss);
|
|
2005
2059
|
if (isEmptyCssSourceOrderParts(orderedExtraCss) && shouldAppendWebBundleCssFallback(generated.target, {
|
|
2006
2060
|
hasSourceDirectives,
|
|
2007
2061
|
hasMatchedCssSourceFile
|
|
@@ -2017,11 +2071,14 @@ async function generateCssByGenerator(options) {
|
|
|
2017
2071
|
}
|
|
2018
2072
|
} else if (generated.target === "weapp" && shouldFinalizeMarkedUserLayerComponentsCss(file)) css = reorderMarkedUserLayerComponentsCss(css);
|
|
2019
2073
|
return {
|
|
2020
|
-
css: restoreLocalCssImports(finalizeMiniProgramGeneratorCss(css, generated.target, majorVersion, opts.cssPreflight, {
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2074
|
+
css: restoreLocalCssImports(finalizeMiniProgramGeneratorCss(css, generated.target, majorVersion, opts.cssPreflight, {
|
|
2075
|
+
injectPreflight: shouldInjectMiniProgramPreflightForGeneratorCss(opts, {
|
|
2076
|
+
cssHandlerOptions,
|
|
2077
|
+
isolateCurrentCssCandidates,
|
|
2078
|
+
localImports: localImportParts?.imports
|
|
2079
|
+
}),
|
|
2080
|
+
styleOptions: generatorStyleOptions
|
|
2081
|
+
}), localImportParts?.imports),
|
|
2025
2082
|
target: generated.target,
|
|
2026
2083
|
source: "generator",
|
|
2027
2084
|
dependencies: generated.dependencies
|
|
@@ -2060,6 +2117,18 @@ async function generateCssByGenerator(options) {
|
|
|
2060
2117
|
importFallback: generatorOptions.importFallback
|
|
2061
2118
|
});
|
|
2062
2119
|
css = createCssSourceOrderAppend$1(css, userCss);
|
|
2120
|
+
} else if (hasMatchedCssSourceFile && generated.target === "weapp" && hasUserCssLayerBlocks(userCssRawSource)) {
|
|
2121
|
+
const layerUserCss = await transformGeneratorUserCss(splitUserCssLayerBlocks(userCssRawSource).layer, {
|
|
2122
|
+
generatorTarget: generated.target,
|
|
2123
|
+
generatorStyleOptions,
|
|
2124
|
+
cssUserHandlerOptions,
|
|
2125
|
+
styleHandler,
|
|
2126
|
+
importFallback: generatorOptions.importFallback
|
|
2127
|
+
});
|
|
2128
|
+
if (layerUserCss.trim().length > 0) {
|
|
2129
|
+
css = createCssSourceOrderAppend$1(css, wrapUserLayerComponentsCss(layerUserCss));
|
|
2130
|
+
if (shouldFinalizeMarkedUserLayerComponentsCss(file)) css = reorderMarkedUserLayerComponentsCss(css);
|
|
2131
|
+
}
|
|
2063
2132
|
}
|
|
2064
2133
|
if (hasMatchedCssSourceFile && generated.target === "weapp") {
|
|
2065
2134
|
if (!isolateCurrentCssCandidates && !shouldFilterApplyOnlyCss) css = await appendLegacyContainerCompatCss(css, userCssRawSource, file, runtime, configuredContainerCompat, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions);
|
|
@@ -2078,11 +2147,14 @@ async function generateCssByGenerator(options) {
|
|
|
2078
2147
|
css = createCssSourceOrderAppend$1(css, userCss);
|
|
2079
2148
|
}
|
|
2080
2149
|
return {
|
|
2081
|
-
css: restoreLocalCssImports(finalizeMiniProgramGeneratorCss(css, generated.target, majorVersion, opts.cssPreflight, {
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2150
|
+
css: restoreLocalCssImports(finalizeMiniProgramGeneratorCss(css, generated.target, majorVersion, opts.cssPreflight, {
|
|
2151
|
+
injectPreflight: shouldInjectMiniProgramPreflightForGeneratorCss(opts, {
|
|
2152
|
+
cssHandlerOptions,
|
|
2153
|
+
isolateCurrentCssCandidates,
|
|
2154
|
+
localImports: localImportParts?.imports
|
|
2155
|
+
}),
|
|
2156
|
+
styleOptions: generatorStyleOptions
|
|
2157
|
+
}), localImportParts?.imports),
|
|
2086
2158
|
target: generated.target,
|
|
2087
2159
|
source: "generator",
|
|
2088
2160
|
dependencies: generated.dependencies
|
|
@@ -2093,11 +2165,14 @@ async function generateCssByGenerator(options) {
|
|
|
2093
2165
|
css = await appendLegacyContainerCompatCss(css, userCssRawSource, file, runtime, configuredContainerCompat, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions);
|
|
2094
2166
|
}
|
|
2095
2167
|
return {
|
|
2096
|
-
css: restoreLocalCssImports(finalizeMiniProgramGeneratorCss(css, generated.target, majorVersion, opts.cssPreflight, {
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2168
|
+
css: restoreLocalCssImports(finalizeMiniProgramGeneratorCss(css, generated.target, majorVersion, opts.cssPreflight, {
|
|
2169
|
+
injectPreflight: shouldInjectMiniProgramPreflightForGeneratorCss(opts, {
|
|
2170
|
+
cssHandlerOptions,
|
|
2171
|
+
isolateCurrentCssCandidates,
|
|
2172
|
+
localImports: localImportParts?.imports
|
|
2173
|
+
}),
|
|
2174
|
+
styleOptions: generatorStyleOptions
|
|
2175
|
+
}), localImportParts?.imports),
|
|
2101
2176
|
target: generated.target,
|
|
2102
2177
|
source: "generator",
|
|
2103
2178
|
dependencies: generated.dependencies
|
|
@@ -2669,39 +2744,6 @@ const SCRIPT_SOURCE_CANDIDATE_EXTENSIONS = new Set([
|
|
|
2669
2744
|
"mts",
|
|
2670
2745
|
"cts"
|
|
2671
2746
|
]);
|
|
2672
|
-
const CLASS_LIKE_NAME_RE = /class/i;
|
|
2673
|
-
function getPropertyName(node) {
|
|
2674
|
-
if (!node) return;
|
|
2675
|
-
if (node.type === "Identifier") return node.name;
|
|
2676
|
-
if (node.type === "StringLiteral") return node.value;
|
|
2677
|
-
}
|
|
2678
|
-
function isClassLikeStringPath(path) {
|
|
2679
|
-
const parent = path.parentPath;
|
|
2680
|
-
if (!parent) return false;
|
|
2681
|
-
if (parent.isVariableDeclarator?.()) return CLASS_LIKE_NAME_RE.test(getPropertyName(parent.node.id) ?? "");
|
|
2682
|
-
if (parent.isObjectProperty?.() || parent.isObjectMethod?.()) return CLASS_LIKE_NAME_RE.test(getPropertyName(parent.node.key) ?? "");
|
|
2683
|
-
if (parent.isAssignmentExpression?.()) {
|
|
2684
|
-
const left = parent.node.left;
|
|
2685
|
-
if (left?.type === "Identifier") return CLASS_LIKE_NAME_RE.test(left.name);
|
|
2686
|
-
if (left?.type === "MemberExpression") return CLASS_LIKE_NAME_RE.test(getPropertyName(left.property) ?? "");
|
|
2687
|
-
}
|
|
2688
|
-
if (parent.isJSXAttribute?.()) return CLASS_LIKE_NAME_RE.test(getPropertyName(parent.node.name) ?? "");
|
|
2689
|
-
return false;
|
|
2690
|
-
}
|
|
2691
|
-
function isTemplateElementInClassLikePath(path) {
|
|
2692
|
-
const templateLiteralPath = path.parentPath;
|
|
2693
|
-
if (!templateLiteralPath?.isTemplateLiteral?.()) return false;
|
|
2694
|
-
const parent = templateLiteralPath.parentPath;
|
|
2695
|
-
if (!parent) return false;
|
|
2696
|
-
if (parent.isVariableDeclarator?.()) return CLASS_LIKE_NAME_RE.test(getPropertyName(parent.node.id) ?? "");
|
|
2697
|
-
if (parent.isObjectProperty?.() || parent.isObjectMethod?.()) return CLASS_LIKE_NAME_RE.test(getPropertyName(parent.node.key) ?? "");
|
|
2698
|
-
if (parent.isAssignmentExpression?.()) {
|
|
2699
|
-
const left = parent.node.left;
|
|
2700
|
-
if (left?.type === "Identifier") return CLASS_LIKE_NAME_RE.test(left.name);
|
|
2701
|
-
if (left?.type === "MemberExpression") return CLASS_LIKE_NAME_RE.test(getPropertyName(left.property) ?? "");
|
|
2702
|
-
}
|
|
2703
|
-
return false;
|
|
2704
|
-
}
|
|
2705
2747
|
async function extractScriptStringCandidates(source, extension, options) {
|
|
2706
2748
|
if (!SCRIPT_SOURCE_CANDIDATE_EXTENSIONS.has(extension)) return [];
|
|
2707
2749
|
const values = /* @__PURE__ */ new Set();
|
|
@@ -2714,10 +2756,10 @@ async function extractScriptStringCandidates(source, extension, options) {
|
|
|
2714
2756
|
}), {
|
|
2715
2757
|
noScope: true,
|
|
2716
2758
|
StringLiteral(path) {
|
|
2717
|
-
|
|
2759
|
+
values.add(path.node.value);
|
|
2718
2760
|
},
|
|
2719
2761
|
TemplateElement(path) {
|
|
2720
|
-
|
|
2762
|
+
values.add(path.node.value.raw);
|
|
2721
2763
|
}
|
|
2722
2764
|
});
|
|
2723
2765
|
} catch {
|
|
@@ -2822,6 +2864,7 @@ function createSourceCandidateCollector(options = {}) {
|
|
|
2822
2864
|
}
|
|
2823
2865
|
async function syncCss(id, source) {
|
|
2824
2866
|
const normalizedId = cleanUrl(id);
|
|
2867
|
+
sourceById.set(normalizedId, source);
|
|
2825
2868
|
const contentCacheKey = createSourceCandidateContentCacheKey("css", source, options.bareArbitraryValues, options.extractor);
|
|
2826
2869
|
const cachedCandidates = sourceCandidateContentCache.get(contentCacheKey);
|
|
2827
2870
|
if (cachedCandidates) {
|
|
@@ -2834,6 +2877,7 @@ function createSourceCandidateCollector(options = {}) {
|
|
|
2834
2877
|
}
|
|
2835
2878
|
async function merge(id, source) {
|
|
2836
2879
|
const normalizedId = cleanUrl(id);
|
|
2880
|
+
sourceById.set(normalizedId, source);
|
|
2837
2881
|
const extension = resolveSourceCandidateExtension(normalizedId);
|
|
2838
2882
|
const contentCacheKey = createSourceCandidateContentCacheKey(extension, source, options.bareArbitraryValues, options.extractor);
|
|
2839
2883
|
const cachedCandidates = sourceCandidateContentCache.get(contentCacheKey);
|
|
@@ -2843,11 +2887,20 @@ function createSourceCandidateCollector(options = {}) {
|
|
|
2843
2887
|
}
|
|
2844
2888
|
async function syncFile(id) {
|
|
2845
2889
|
const normalizedId = cleanUrl(id);
|
|
2846
|
-
|
|
2890
|
+
try {
|
|
2891
|
+
await sync(normalizedId, await readFile(normalizedId, "utf8"));
|
|
2892
|
+
} catch (error) {
|
|
2893
|
+
if ((typeof error === "object" && error !== null && "code" in error ? error.code : void 0) === "ENOENT") {
|
|
2894
|
+
remove(normalizedId);
|
|
2895
|
+
return;
|
|
2896
|
+
}
|
|
2897
|
+
throw error;
|
|
2898
|
+
}
|
|
2847
2899
|
}
|
|
2848
2900
|
async function syncCurrentFile(id) {
|
|
2849
2901
|
const normalizedId = cleanUrl(id);
|
|
2850
2902
|
transformCandidatesById.delete(normalizedId);
|
|
2903
|
+
cssCandidatesById.delete(normalizedId);
|
|
2851
2904
|
await syncFile(normalizedId);
|
|
2852
2905
|
}
|
|
2853
2906
|
async function scanRoot({ entries, explicit, root, outDir }) {
|
|
@@ -2915,6 +2968,9 @@ function createSourceCandidateCollector(options = {}) {
|
|
|
2915
2968
|
function source(id) {
|
|
2916
2969
|
return sourceById.get(cleanUrl(id));
|
|
2917
2970
|
}
|
|
2971
|
+
function sources() {
|
|
2972
|
+
return sourceById.entries();
|
|
2973
|
+
}
|
|
2918
2974
|
function values() {
|
|
2919
2975
|
const values = new Set([...candidateCount.keys(), ...inlineIncludedCandidates]);
|
|
2920
2976
|
for (const candidate of inlineExcludedCandidates) values.delete(candidate);
|
|
@@ -2924,6 +2980,7 @@ function createSourceCandidateCollector(options = {}) {
|
|
|
2924
2980
|
if (entries === void 0) {
|
|
2925
2981
|
if (!options.excludeEntries?.length) return values();
|
|
2926
2982
|
}
|
|
2983
|
+
if (entries?.length === 0) return new Set(inlineIncludedCandidates);
|
|
2927
2984
|
const filtered = /* @__PURE__ */ new Set();
|
|
2928
2985
|
for (const [id, candidates] of candidatesById) {
|
|
2929
2986
|
if (entries !== void 0 && !isFileMatchedByTailwindSourceEntries(id, entries)) continue;
|
|
@@ -2944,6 +3001,11 @@ function createSourceCandidateCollector(options = {}) {
|
|
|
2944
3001
|
}
|
|
2945
3002
|
if (id) candidateSources.add(id);
|
|
2946
3003
|
};
|
|
3004
|
+
if (entries?.length === 0) {
|
|
3005
|
+
for (const candidate of inlineIncludedCandidates) addCandidateSource(candidate, void 0);
|
|
3006
|
+
for (const candidate of inlineExcludedCandidates) sources.delete(candidate);
|
|
3007
|
+
return sources;
|
|
3008
|
+
}
|
|
2947
3009
|
for (const [id, candidates] of candidatesById) {
|
|
2948
3010
|
if (entries !== void 0 && !isFileMatchedByTailwindSourceEntries(id, entries)) continue;
|
|
2949
3011
|
if (options.excludeEntries?.length && isFileMatchedByTailwindSourceEntries(id, options.excludeEntries)) continue;
|
|
@@ -2963,6 +3025,18 @@ function createSourceCandidateCollector(options = {}) {
|
|
|
2963
3025
|
inlineIncludedCandidates.clear();
|
|
2964
3026
|
inlineExcludedCandidates.clear();
|
|
2965
3027
|
}
|
|
3028
|
+
function clearScan() {
|
|
3029
|
+
for (const id of scanCandidatesById.keys()) {
|
|
3030
|
+
scanCandidatesById.delete(id);
|
|
3031
|
+
recompute(id);
|
|
3032
|
+
}
|
|
3033
|
+
inlineIncludedCandidates.clear();
|
|
3034
|
+
inlineExcludedCandidates.clear();
|
|
3035
|
+
}
|
|
3036
|
+
function resetScan() {
|
|
3037
|
+
inlineIncludedCandidates.clear();
|
|
3038
|
+
inlineExcludedCandidates.clear();
|
|
3039
|
+
}
|
|
2966
3040
|
function snapshot() {
|
|
2967
3041
|
return {
|
|
2968
3042
|
candidatesById: [...candidatesById.entries()].map(([id, candidates]) => [id, [...candidates]]),
|
|
@@ -2994,13 +3068,13 @@ function createSourceCandidateCollector(options = {}) {
|
|
|
2994
3068
|
if (candidateSet.size === 0) continue;
|
|
2995
3069
|
cssCandidatesById.set(id, candidateSet);
|
|
2996
3070
|
}
|
|
2997
|
-
for (const [id, candidates] of snapshot.candidatesById) {
|
|
2998
|
-
const candidateSet = new Set(candidates);
|
|
2999
|
-
if (candidateSet.size === 0) continue;
|
|
3000
|
-
candidatesById.set(id, candidateSet);
|
|
3001
|
-
addCandidateSet(candidateCount, candidateSet);
|
|
3002
|
-
}
|
|
3003
3071
|
for (const [id, source] of snapshot.sourceById ?? []) sourceById.set(id, source);
|
|
3072
|
+
const ids = new Set([
|
|
3073
|
+
...scanCandidatesById.keys(),
|
|
3074
|
+
...transformCandidatesById.keys(),
|
|
3075
|
+
...cssCandidatesById.keys()
|
|
3076
|
+
]);
|
|
3077
|
+
for (const id of ids) recompute(id);
|
|
3004
3078
|
}
|
|
3005
3079
|
return {
|
|
3006
3080
|
sync,
|
|
@@ -3012,11 +3086,14 @@ function createSourceCandidateCollector(options = {}) {
|
|
|
3012
3086
|
syncInline,
|
|
3013
3087
|
remove,
|
|
3014
3088
|
source,
|
|
3089
|
+
sources,
|
|
3015
3090
|
values,
|
|
3016
3091
|
valuesForEntries,
|
|
3017
3092
|
sourcesForEntries,
|
|
3018
3093
|
snapshot,
|
|
3019
3094
|
restore,
|
|
3095
|
+
clearScan,
|
|
3096
|
+
resetScan,
|
|
3020
3097
|
clear
|
|
3021
3098
|
};
|
|
3022
3099
|
}
|