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,17 +1,17 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-emK7D4bc.js");
|
|
2
|
-
const require_v3_engine = require("./v3-engine-
|
|
3
|
-
const require_generator = require("./generator-
|
|
4
|
-
const require_precheck = require("./precheck-
|
|
5
|
-
const require_tailwindcss = require("./tailwindcss-
|
|
6
|
-
let node_module = require("node:module");
|
|
7
|
-
let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
|
|
8
|
-
let lru_cache = require("lru-cache");
|
|
9
|
-
let tailwindcss_patch = require("tailwindcss-patch");
|
|
2
|
+
const require_v3_engine = require("./v3-engine-2rrgylhn.js");
|
|
3
|
+
const require_generator = require("./generator-CzpArpCL.js");
|
|
4
|
+
const require_precheck = require("./precheck-B0Z8yW7E.js");
|
|
5
|
+
const require_tailwindcss = require("./tailwindcss-DZEwT3C_.js");
|
|
10
6
|
let node_fs = require("node:fs");
|
|
11
7
|
let node_path = require("node:path");
|
|
12
8
|
node_path = require_chunk.__toESM(node_path);
|
|
13
9
|
let node_process = require("node:process");
|
|
14
10
|
node_process = require_chunk.__toESM(node_process);
|
|
11
|
+
let node_module = require("node:module");
|
|
12
|
+
let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
|
|
13
|
+
let lru_cache = require("lru-cache");
|
|
14
|
+
let tailwindcss_patch = require("tailwindcss-patch");
|
|
15
15
|
let node_fs_promises = require("node:fs/promises");
|
|
16
16
|
let _weapp_core_escape = require("@weapp-core/escape");
|
|
17
17
|
let _weapp_tailwindcss_shared_node = require("@weapp-tailwindcss/shared/node");
|
|
@@ -105,6 +105,9 @@ function removeTracedTailwindGeneratedContainerRules(root) {
|
|
|
105
105
|
rule.remove();
|
|
106
106
|
});
|
|
107
107
|
}
|
|
108
|
+
function normalizeTraceCommentBefore(value) {
|
|
109
|
+
return value?.includes("\n") ? value : "\n";
|
|
110
|
+
}
|
|
108
111
|
function annotateCssSourceTrace(css, options) {
|
|
109
112
|
if (!isCssSourceTraceEnabled(options.opts) || !options.tokenSources?.size) return css;
|
|
110
113
|
try {
|
|
@@ -119,7 +122,7 @@ function annotateCssSourceTrace(css, options) {
|
|
|
119
122
|
return `${token} <= ${sources.length > 0 ? sources.join(", ") : "<tailwind generated>"}`;
|
|
120
123
|
});
|
|
121
124
|
const comment = _weapp_tailwindcss_postcss.postcss.comment({ text: `tokens: ${lines.join(" | ")}` });
|
|
122
|
-
|
|
125
|
+
comment.raws.before = normalizeTraceCommentBefore(rule.raws.before);
|
|
123
126
|
rule.raws.before = "\n";
|
|
124
127
|
rule.parent.insertBefore(rule, comment);
|
|
125
128
|
});
|
|
@@ -136,7 +139,8 @@ function finalizeMiniProgramGeneratorCss(css, target, majorVersion, cssPreflight
|
|
|
136
139
|
return (0, _weapp_tailwindcss_postcss.finalizeMiniProgramCss)(css, {
|
|
137
140
|
cssPreflight: majorVersion === 4 && options.injectPreflight !== false ? cssPreflight : void 0,
|
|
138
141
|
isTailwindcssV4: majorVersion === 4,
|
|
139
|
-
preservePseudoContentInit: majorVersion === 3
|
|
142
|
+
preservePseudoContentInit: majorVersion === 3,
|
|
143
|
+
tailwindcssV4GradientFallback: options.styleOptions?.cssOptions?.tailwindcssV4GradientFallback ?? options.styleOptions?.tailwindcssV4GradientFallback
|
|
140
144
|
});
|
|
141
145
|
}
|
|
142
146
|
function shouldInjectMiniProgramPreflightForGeneratorCss(opts, options) {
|
|
@@ -145,12 +149,24 @@ function shouldInjectMiniProgramPreflightForGeneratorCss(opts, options) {
|
|
|
145
149
|
return require_tailwindcss.isUniAppXEnabled(opts.uniAppX) && Boolean(options.localImports?.trim());
|
|
146
150
|
}
|
|
147
151
|
function mergeScopedRuntimeWithCurrentRuntime(scopedRuntime, runtime, options) {
|
|
148
|
-
if (options.
|
|
149
|
-
|
|
152
|
+
if (options.majorVersion === 3 && !options.isolateCssSource) return new Set([
|
|
153
|
+
...scopedRuntime,
|
|
154
|
+
...runtime,
|
|
155
|
+
...options.currentCssCandidates ?? []
|
|
156
|
+
]);
|
|
157
|
+
if (options.isolateCssSource) {
|
|
158
|
+
if (options.matchedCssSourceFile) return new Set([...scopedRuntime, ...options.currentCssCandidates ?? []]);
|
|
159
|
+
return new Set([...scopedRuntime, ...options.currentCssCandidates ?? []]);
|
|
160
|
+
}
|
|
161
|
+
if (runtime.size === 0 || !options.cssHandlerOptions.isMainChunk) return scopedRuntime;
|
|
150
162
|
return new Set([...scopedRuntime, ...runtime]);
|
|
151
163
|
}
|
|
152
|
-
function shouldIsolateScopedCssSource(source, sourceEntries) {
|
|
153
|
-
|
|
164
|
+
function shouldIsolateScopedCssSource(majorVersion, source, sourceEntries, options) {
|
|
165
|
+
if (options.target !== "weapp") return false;
|
|
166
|
+
if (source.__weappTailwindcssMeta?.isolateCssSource) return true;
|
|
167
|
+
if (source.__weappTailwindcssMeta?.matchedCssSourceFile && (sourceEntries?.length ?? 0) > 0) return true;
|
|
168
|
+
if (sourceEntries?.length === 0) return false;
|
|
169
|
+
return (majorVersion === 3 || majorVersion === 4) && sourceEntries !== void 0 && options.cssHandlerOptions?.isMainChunk !== true;
|
|
154
170
|
}
|
|
155
171
|
function shouldIsolateCurrentTailwindV4CssCandidates(majorVersion, cssHandlerOptions, options) {
|
|
156
172
|
return majorVersion === 4 && !cssHandlerOptions.isMainChunk && require_v3_engine.hasTailwindApplyDirective(options.rawSource) && !require_v3_engine.hasTailwindRootDirectives(options.rawSource) && !options.hasGeneratedCss && !options.hasGeneratedMarkers;
|
|
@@ -168,13 +184,13 @@ function isEmptyCssSourceOrderParts(parts) {
|
|
|
168
184
|
return parts.before.trim().length === 0 && parts.after.trim().length === 0;
|
|
169
185
|
}
|
|
170
186
|
function resolveGeneratorStyleOptions(opts, cssHandlerOptions, generatorStyleOptions) {
|
|
187
|
+
const resolvedStyleOptions = require_precheck.resolveStyleOptionsFromContext(opts);
|
|
171
188
|
const preflightStyleOptions = {
|
|
172
|
-
cssPreflight:
|
|
173
|
-
cssPreflightRange:
|
|
189
|
+
cssPreflight: resolvedStyleOptions.cssPreflight,
|
|
190
|
+
cssPreflightRange: resolvedStyleOptions.cssPreflightRange
|
|
174
191
|
};
|
|
175
192
|
return {
|
|
176
|
-
...
|
|
177
|
-
atRules: opts.atRules,
|
|
193
|
+
...resolvedStyleOptions,
|
|
178
194
|
uniAppXCssTarget: opts.uniAppXCssTarget,
|
|
179
195
|
uniAppXUnsupported: opts.uniAppXUnsupported,
|
|
180
196
|
...cssHandlerOptions,
|
|
@@ -198,9 +214,9 @@ function splitRawSourceByGeneratedCssOrder(rawSource, rawTailwindCss) {
|
|
|
198
214
|
if (exactParts) return exactParts;
|
|
199
215
|
return require_v3_engine.splitTailwindGeneratedCssByBanner(rawSource);
|
|
200
216
|
}
|
|
201
|
-
function shouldUseGeneratorForCurrentCss(
|
|
217
|
+
function shouldUseGeneratorForCurrentCss(_majorVersion, cssHandlerOptions, options) {
|
|
202
218
|
const hasApplyDirectives = require_v3_engine.hasTailwindApplyDirective(options.rawSource);
|
|
203
|
-
return options.hasGeneratedCss || options.hasGeneratedMarkers || options.hasSourceDirectives ||
|
|
219
|
+
return options.hasGeneratedCss || options.hasGeneratedMarkers || options.hasSourceDirectives || hasApplyDirectives || cssHandlerOptions.isMainChunk;
|
|
204
220
|
}
|
|
205
221
|
function createRuntimeWithCurrentCssCandidates(runtime, currentCssCandidates, isolateCurrentCssCandidates) {
|
|
206
222
|
return isolateCurrentCssCandidates ? new Set(currentCssCandidates) : currentCssCandidates.length > 0 ? new Set([...runtime, ...currentCssCandidates]) : runtime;
|
|
@@ -552,98 +568,53 @@ function extractStyleDirectiveSources(source) {
|
|
|
552
568
|
let match = SFC_STYLE_BLOCK_RE.exec(source);
|
|
553
569
|
while (match !== null) {
|
|
554
570
|
const styleSource = match[1] ?? "";
|
|
555
|
-
if (require_v3_engine.hasTailwindSourceDirectives(styleSource)) styleSources.push(styleSource);
|
|
571
|
+
if (require_v3_engine.hasTailwindSourceDirectives(styleSource, { importFallback: true })) styleSources.push(styleSource);
|
|
556
572
|
match = SFC_STYLE_BLOCK_RE.exec(source);
|
|
557
573
|
}
|
|
558
574
|
if (styleSources.length > 0) return styleSources;
|
|
559
|
-
return require_v3_engine.hasTailwindSourceDirectives(source) ? [source] : [];
|
|
575
|
+
return require_v3_engine.hasTailwindSourceDirectives(source, { importFallback: true }) ? [source] : [];
|
|
560
576
|
}
|
|
561
577
|
function resolveSourceSideCssEntrySource(file, sourceOptions, resolveOptions = {}) {
|
|
562
|
-
for (const sourceFile of createSourceStylePathCandidates(file, sourceOptions)) {
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
};
|
|
572
|
-
}
|
|
573
|
-
} catch {
|
|
574
|
-
continue;
|
|
578
|
+
for (const sourceFile of createSourceStylePathCandidates(file, sourceOptions)) try {
|
|
579
|
+
const source = sourceOptions.sourceFile && node_path.default.resolve(sourceOptions.sourceFile) === node_path.default.resolve(sourceFile) && typeof sourceOptions.sourceCss === "string" ? sourceOptions.sourceCss : (0, node_fs.existsSync)(sourceFile) ? (0, node_fs.readFileSync)(sourceFile, "utf8") : void 0;
|
|
580
|
+
if (source === void 0) continue;
|
|
581
|
+
for (const styleSource of extractStyleDirectiveSources(source)) {
|
|
582
|
+
const cssEntrySource = require_v3_engine.resolveCssEntrySource(styleSource, node_path.default.dirname(sourceFile), resolveOptions);
|
|
583
|
+
if (cssEntrySource) return {
|
|
584
|
+
...cssEntrySource,
|
|
585
|
+
file: sourceFile
|
|
586
|
+
};
|
|
575
587
|
}
|
|
588
|
+
} catch {
|
|
589
|
+
continue;
|
|
576
590
|
}
|
|
577
591
|
}
|
|
578
592
|
//#endregion
|
|
579
|
-
//#region src/bundlers/shared/generator-css/source-resolver.ts
|
|
580
|
-
function
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
}
|
|
589
|
-
function resolveCssHandlerSourceOptions(cssHandlerOptions) {
|
|
590
|
-
return cssHandlerOptions.sourceOptions;
|
|
591
|
-
}
|
|
592
|
-
function createCssEntrySources(cssEntries) {
|
|
593
|
-
return cssEntries?.filter((entry) => typeof entry === "string" && entry.length > 0 && node_path.default.isAbsolute(entry)).map((entry) => ({ file: node_path.default.resolve(entry) }));
|
|
594
|
-
}
|
|
595
|
-
function mergeCssSources(cssSources, cssEntrySources) {
|
|
596
|
-
const merged = [];
|
|
597
|
-
const seenFiles = /* @__PURE__ */ new Set();
|
|
598
|
-
const addSource = (cssSource) => {
|
|
599
|
-
const file = typeof cssSource.file === "string" && cssSource.file.length > 0 ? node_path.default.resolve(cssSource.file) : void 0;
|
|
600
|
-
if (file) {
|
|
601
|
-
if (seenFiles.has(file)) return;
|
|
602
|
-
seenFiles.add(file);
|
|
603
|
-
}
|
|
604
|
-
merged.push(cssSource);
|
|
605
|
-
};
|
|
606
|
-
for (const cssSource of cssSources ?? []) addSource(cssSource);
|
|
607
|
-
for (const cssSource of cssEntrySources ?? []) addSource(cssSource);
|
|
608
|
-
return merged.length > 0 ? merged : void 0;
|
|
609
|
-
}
|
|
610
|
-
function createSingleTailwindV4SourceOptions(sourceOptions, options) {
|
|
611
|
-
return require_v3_engine.omitUndefined({
|
|
612
|
-
projectRoot: sourceOptions.projectRoot,
|
|
613
|
-
baseFallbacks: sourceOptions.baseFallbacks,
|
|
614
|
-
packageName: sourceOptions.packageName,
|
|
615
|
-
base: options.base,
|
|
616
|
-
css: options.css
|
|
617
|
-
});
|
|
593
|
+
//#region src/bundlers/shared/generator-css/source-resolver/apply-reference.ts
|
|
594
|
+
function createTailwindV4ApplyReferenceSource(css, sourceOptions) {
|
|
595
|
+
if (!require_v3_engine.hasTailwindApplyDirective(css) || require_v3_engine.hasTailwindRootDirectives(css)) return css;
|
|
596
|
+
const utilities = collectTailwindApplyUtilities(css);
|
|
597
|
+
return [
|
|
598
|
+
`@import "${sourceOptions.packageName ?? "tailwindcss"}" source(none);`,
|
|
599
|
+
utilities.length > 0 ? `@source inline(${JSON.stringify(utilities.join(" "))});` : void 0,
|
|
600
|
+
css
|
|
601
|
+
].filter(Boolean).join("\n");
|
|
618
602
|
}
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
const
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
...sourceOptions,
|
|
630
|
-
sourceFile: sourceOptions.sourceFile ?? cssEntry
|
|
631
|
-
});
|
|
632
|
-
return withGeneratorSourceMetadata(await require_v3_engine.resolveTailwindV4Source({
|
|
633
|
-
...require_v3_engine.omitUndefined(singleEntrySourceOptions),
|
|
634
|
-
base,
|
|
635
|
-
css: require_v3_engine.normalizeConfigDirective(css, config),
|
|
636
|
-
cssEntries: [cssEntry]
|
|
637
|
-
}), {
|
|
638
|
-
matchedCssSourceFile: cssEntry,
|
|
639
|
-
sourceBase: base,
|
|
640
|
-
sourceCss: css
|
|
603
|
+
function collectTailwindApplyUtilities(css) {
|
|
604
|
+
let root;
|
|
605
|
+
try {
|
|
606
|
+
root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
607
|
+
} catch {
|
|
608
|
+
return [];
|
|
609
|
+
}
|
|
610
|
+
const utilities = /* @__PURE__ */ new Set();
|
|
611
|
+
root.walkAtRules("apply", (rule) => {
|
|
612
|
+
for (const utility of (0, tailwindcss_patch.splitCandidateTokens)(rule.params)) utilities.add(utility);
|
|
641
613
|
});
|
|
614
|
+
return [...utilities].sort();
|
|
642
615
|
}
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
return node_path.default.dirname(node_path.default.resolve(normalized));
|
|
646
|
-
}
|
|
616
|
+
//#endregion
|
|
617
|
+
//#region src/bundlers/shared/generator-css/source-resolver/config.ts
|
|
647
618
|
function resolveExistingConfigPath(config, configRequest, file, sourceOptions) {
|
|
648
619
|
if (config && (0, node_fs.existsSync)(config)) return config;
|
|
649
620
|
if (!configRequest || node_path.default.isAbsolute(configRequest)) return sourceOptions.config;
|
|
@@ -670,20 +641,8 @@ function resolveExistingConfigPath(config, configRequest, file, sourceOptions) {
|
|
|
670
641
|
for (const candidate of configCandidates) if ((0, node_fs.existsSync)(candidate)) return candidate;
|
|
671
642
|
return sourceOptions.config;
|
|
672
643
|
}
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
if (!from || !node_path.default.isAbsolute(from)) return node_path.default.isAbsolute(file) || Boolean(sourceOptions?.sourceFile) || Boolean(sourceOptions?.cssSources?.length);
|
|
676
|
-
return true;
|
|
677
|
-
}
|
|
678
|
-
function shouldResolveSourceSideCssEntry(rawSource) {
|
|
679
|
-
return rawSource.includes("@apply") || require_v3_engine.hasTailwindRootDirectives(rawSource, { importFallback: true }) || require_v3_engine.hasTailwindSourceDirectives(rawSource, { importFallback: true }) || require_v3_engine.hasTailwindGeneratedCss(rawSource) || require_v3_engine.hasTailwindGeneratedCssMarkers(rawSource);
|
|
680
|
-
}
|
|
681
|
-
function shouldPreferTailwindV3SourceSideEntry(rawSource, sourceSideEntrySource) {
|
|
682
|
-
return Boolean(sourceSideEntrySource) && !require_v3_engine.hasTailwindSourceDirectives(rawSource, { importFallback: true });
|
|
683
|
-
}
|
|
684
|
-
function shouldPreferResolvedSourceSideEntry(cssEntrySource, sourceSideEntrySource) {
|
|
685
|
-
return Boolean(sourceSideEntrySource?.config) && Boolean(cssEntrySource?.configRequest) && (!cssEntrySource?.config || !(0, node_fs.existsSync)(cssEntrySource.config));
|
|
686
|
-
}
|
|
644
|
+
//#endregion
|
|
645
|
+
//#region src/bundlers/shared/generator-css/source-resolver/matching.ts
|
|
687
646
|
function normalizeCssSourceForCompare(css) {
|
|
688
647
|
return require_v3_engine.stripGeneratorPlaceholderMarkers(require_v3_engine.stripTailwindBanners(css)).trim();
|
|
689
648
|
}
|
|
@@ -734,6 +693,107 @@ function scoreTailwindV4CssSourceFileMatch(file, cssSourceFile, sourceOptions) {
|
|
|
734
693
|
else if (sourceBase.endsWith(`/${outputBase}`)) bestScore = Math.max(bestScore, 1e3 + outputBase.length);
|
|
735
694
|
return bestScore;
|
|
736
695
|
}
|
|
696
|
+
//#endregion
|
|
697
|
+
//#region src/bundlers/shared/generator-css/source-resolver/metadata.ts
|
|
698
|
+
function withGeneratorSourceMetadata(source, metadata) {
|
|
699
|
+
return {
|
|
700
|
+
...source,
|
|
701
|
+
__weappTailwindcssMeta: metadata
|
|
702
|
+
};
|
|
703
|
+
}
|
|
704
|
+
function withMatchedSourceSideMetadata(source, resolvedEntrySource) {
|
|
705
|
+
return resolvedEntrySource.file ? withGeneratorSourceMetadata(source, {
|
|
706
|
+
isolateCssSource: true,
|
|
707
|
+
matchedCssSourceFile: resolvedEntrySource.file,
|
|
708
|
+
sourceBase: resolvedEntrySource.base,
|
|
709
|
+
sourceCss: resolvedEntrySource.css
|
|
710
|
+
}) : source;
|
|
711
|
+
}
|
|
712
|
+
//#endregion
|
|
713
|
+
//#region src/bundlers/shared/generator-css/source-resolver/postcss-source.ts
|
|
714
|
+
function resolvePostcssFromOption(cssHandlerOptions) {
|
|
715
|
+
const from = cssHandlerOptions.postcssOptions?.options?.from;
|
|
716
|
+
return typeof from === "string" && from.length > 0 ? from : void 0;
|
|
717
|
+
}
|
|
718
|
+
function resolvePostcssSourceFile(cssHandlerOptions) {
|
|
719
|
+
const from = resolvePostcssFromOption(cssHandlerOptions);
|
|
720
|
+
if (!from || !node_path.default.isAbsolute(from)) return;
|
|
721
|
+
return from.replace(/[?#].*$/, "");
|
|
722
|
+
}
|
|
723
|
+
function resolveCssHandlerSourceOptions(cssHandlerOptions) {
|
|
724
|
+
return cssHandlerOptions.sourceOptions;
|
|
725
|
+
}
|
|
726
|
+
function resolveCssSourceBase(file, cssHandlerOptions) {
|
|
727
|
+
const normalized = (resolvePostcssFromOption(cssHandlerOptions) ?? file).replace(/[?#].*$/, "");
|
|
728
|
+
return node_path.default.dirname(node_path.default.resolve(normalized));
|
|
729
|
+
}
|
|
730
|
+
//#endregion
|
|
731
|
+
//#region src/bundlers/shared/generator-css/source-resolver.ts
|
|
732
|
+
function createCssEntrySources(cssEntries) {
|
|
733
|
+
return cssEntries?.filter((entry) => typeof entry === "string" && entry.length > 0 && node_path.default.isAbsolute(entry)).map((entry) => ({ file: node_path.default.resolve(entry) }));
|
|
734
|
+
}
|
|
735
|
+
function mergeCssSources(cssSources, cssEntrySources) {
|
|
736
|
+
const merged = [];
|
|
737
|
+
const seenFiles = /* @__PURE__ */ new Set();
|
|
738
|
+
const addSource = (cssSource) => {
|
|
739
|
+
const file = typeof cssSource.file === "string" && cssSource.file.length > 0 ? node_path.default.resolve(cssSource.file) : void 0;
|
|
740
|
+
if (file) {
|
|
741
|
+
if (seenFiles.has(file)) return;
|
|
742
|
+
seenFiles.add(file);
|
|
743
|
+
}
|
|
744
|
+
merged.push(cssSource);
|
|
745
|
+
};
|
|
746
|
+
for (const cssSource of cssSources ?? []) addSource(cssSource);
|
|
747
|
+
for (const cssSource of cssEntrySources ?? []) addSource(cssSource);
|
|
748
|
+
return merged.length > 0 ? merged : void 0;
|
|
749
|
+
}
|
|
750
|
+
function createSingleTailwindV4SourceOptions(sourceOptions, options) {
|
|
751
|
+
return require_v3_engine.omitUndefined({
|
|
752
|
+
projectRoot: sourceOptions.projectRoot,
|
|
753
|
+
baseFallbacks: sourceOptions.baseFallbacks,
|
|
754
|
+
packageName: sourceOptions.packageName,
|
|
755
|
+
base: options.base,
|
|
756
|
+
css: options.css
|
|
757
|
+
});
|
|
758
|
+
}
|
|
759
|
+
async function resolveTailwindV4CssEntrySource(cssEntry, sourceOptions) {
|
|
760
|
+
const { cssEntries: _cssEntries, cssSources: _cssSources, ...singleEntrySourceOptions } = sourceOptions;
|
|
761
|
+
if (!(0, node_fs.existsSync)(cssEntry)) return require_v3_engine.resolveTailwindV4Source({
|
|
762
|
+
...require_v3_engine.omitUndefined(singleEntrySourceOptions),
|
|
763
|
+
cssEntries: [cssEntry]
|
|
764
|
+
});
|
|
765
|
+
const css = (0, node_fs.readFileSync)(cssEntry, "utf8");
|
|
766
|
+
const base = node_path.default.dirname(node_path.default.resolve(cssEntry));
|
|
767
|
+
const entrySource = require_v3_engine.resolveCssEntrySource(css, base, { removeConfig: false });
|
|
768
|
+
const config = resolveExistingConfigPath(entrySource?.config, entrySource?.configRequest, cssEntry, {
|
|
769
|
+
...sourceOptions,
|
|
770
|
+
sourceFile: sourceOptions.sourceFile ?? cssEntry
|
|
771
|
+
});
|
|
772
|
+
return withGeneratorSourceMetadata(await require_v3_engine.resolveTailwindV4Source({
|
|
773
|
+
...require_v3_engine.omitUndefined(singleEntrySourceOptions),
|
|
774
|
+
base,
|
|
775
|
+
css: require_v3_engine.normalizeConfigDirective(css, config),
|
|
776
|
+
cssEntries: [cssEntry]
|
|
777
|
+
}), {
|
|
778
|
+
matchedCssSourceFile: cssEntry,
|
|
779
|
+
sourceBase: base,
|
|
780
|
+
sourceCss: css
|
|
781
|
+
});
|
|
782
|
+
}
|
|
783
|
+
function canResolveSourceSideCssEntry(file, cssHandlerOptions, sourceOptions) {
|
|
784
|
+
const from = resolvePostcssFromOption(cssHandlerOptions);
|
|
785
|
+
if (!from || !node_path.default.isAbsolute(from)) return node_path.default.isAbsolute(file) || Boolean(sourceOptions?.sourceFile) || Boolean(sourceOptions?.cssSources?.length);
|
|
786
|
+
return true;
|
|
787
|
+
}
|
|
788
|
+
function shouldResolveSourceSideCssEntry(rawSource) {
|
|
789
|
+
return rawSource.includes("@apply") || require_v3_engine.hasTailwindRootDirectives(rawSource, { importFallback: true }) || require_v3_engine.hasTailwindSourceDirectives(rawSource, { importFallback: true }) || require_v3_engine.hasTailwindGeneratedCss(rawSource) || require_v3_engine.hasTailwindGeneratedCssMarkers(rawSource);
|
|
790
|
+
}
|
|
791
|
+
function shouldPreferTailwindV3SourceSideEntry(rawSource, sourceSideEntrySource) {
|
|
792
|
+
return Boolean(sourceSideEntrySource) && !require_v3_engine.hasTailwindSourceDirectives(rawSource, { importFallback: true });
|
|
793
|
+
}
|
|
794
|
+
function shouldPreferResolvedSourceSideEntry(cssEntrySource, sourceSideEntrySource) {
|
|
795
|
+
return Boolean(sourceSideEntrySource?.config) && (Boolean(cssEntrySource?.configRequest) || !cssEntrySource?.config) && (!cssEntrySource?.config || !(0, node_fs.existsSync)(cssEntrySource.config));
|
|
796
|
+
}
|
|
737
797
|
function resolveMatchingTailwindV4CssEntry(rawSource, file, sourceOptions) {
|
|
738
798
|
const cssEntries = sourceOptions.cssEntries;
|
|
739
799
|
if (!cssEntries?.length) return;
|
|
@@ -911,12 +971,6 @@ async function resolveTailwindV4SourceSideEntrySource(resolvedEntrySource, sourc
|
|
|
911
971
|
css
|
|
912
972
|
})), resolvedEntrySource);
|
|
913
973
|
}
|
|
914
|
-
function withGeneratorSourceMetadata(source, metadata) {
|
|
915
|
-
return {
|
|
916
|
-
...source,
|
|
917
|
-
__weappTailwindcssMeta: metadata
|
|
918
|
-
};
|
|
919
|
-
}
|
|
920
974
|
function resolveTailwindV3SourceEntries(source) {
|
|
921
975
|
if (!("version" in source) || source.version !== 3) return;
|
|
922
976
|
const entries = require_v3_engine.normalizeLegacyContentEntries(source.configObject?.content, source.cwd, { relativeBase: source.config ? node_path.default.dirname(source.config) : source.cwd });
|
|
@@ -926,35 +980,6 @@ function withTailwindV3SourceMetadata(source) {
|
|
|
926
980
|
const sourceEntries = resolveTailwindV3SourceEntries(source);
|
|
927
981
|
return sourceEntries ? withGeneratorSourceMetadata(source, { sourceEntries }) : source;
|
|
928
982
|
}
|
|
929
|
-
function withMatchedSourceSideMetadata(source, resolvedEntrySource) {
|
|
930
|
-
return resolvedEntrySource.file ? withGeneratorSourceMetadata(source, {
|
|
931
|
-
matchedCssSourceFile: resolvedEntrySource.file,
|
|
932
|
-
sourceBase: resolvedEntrySource.base,
|
|
933
|
-
sourceCss: resolvedEntrySource.css
|
|
934
|
-
}) : source;
|
|
935
|
-
}
|
|
936
|
-
function createTailwindV4ApplyReferenceSource(css, sourceOptions) {
|
|
937
|
-
if (!require_v3_engine.hasTailwindApplyDirective(css) || require_v3_engine.hasTailwindRootDirectives(css)) return css;
|
|
938
|
-
const utilities = collectTailwindApplyUtilities(css);
|
|
939
|
-
return [
|
|
940
|
-
`@import "${sourceOptions.packageName ?? "tailwindcss"}" source(none);`,
|
|
941
|
-
utilities.length > 0 ? `@source inline(${JSON.stringify(utilities.join(" "))});` : void 0,
|
|
942
|
-
css
|
|
943
|
-
].filter(Boolean).join("\n");
|
|
944
|
-
}
|
|
945
|
-
function collectTailwindApplyUtilities(css) {
|
|
946
|
-
let root;
|
|
947
|
-
try {
|
|
948
|
-
root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
949
|
-
} catch {
|
|
950
|
-
return [];
|
|
951
|
-
}
|
|
952
|
-
const utilities = /* @__PURE__ */ new Set();
|
|
953
|
-
root.walkAtRules("apply", (rule) => {
|
|
954
|
-
for (const utility of (0, tailwindcss_patch.splitCandidateTokens)(rule.params)) utilities.add(utility);
|
|
955
|
-
});
|
|
956
|
-
return [...utilities].sort();
|
|
957
|
-
}
|
|
958
983
|
async function resolveGeneratorSource(majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions, selectionOptions) {
|
|
959
984
|
const base = resolveCssSourceBase(file, cssHandlerOptions);
|
|
960
985
|
const cssEntrySource = require_v3_engine.resolveCssEntrySource(rawSource, base, {
|
|
@@ -987,15 +1012,19 @@ async function resolveGeneratorSource(majorVersion, runtimeState, rawSource, fil
|
|
|
987
1012
|
css: require_v3_engine.normalizeTailwindV3CssEntrySource(resolvedEntrySource.css),
|
|
988
1013
|
...config ? { config } : {}
|
|
989
1014
|
}));
|
|
1015
|
+
const cssEntrySourceEntries = await require_v3_engine.resolveTailwindConfigEntriesFromCssCached(rawSource, resolvedEntrySource.base);
|
|
1016
|
+
const sourceMetadata = sourceWithMetadata.__weappTailwindcssMeta;
|
|
1017
|
+
const matchedSourceFile = resolvedEntrySource.file ?? sourceSideEntrySource?.file;
|
|
990
1018
|
return withGeneratorSourceMetadata(sourceWithMetadata, {
|
|
991
|
-
...
|
|
992
|
-
matchedCssSourceFile:
|
|
1019
|
+
...sourceMetadata,
|
|
1020
|
+
matchedCssSourceFile: matchedSourceFile,
|
|
1021
|
+
sourceEntries: cssEntrySourceEntries?.entries ?? sourceMetadata?.sourceEntries
|
|
993
1022
|
});
|
|
994
1023
|
}
|
|
995
1024
|
const sourceOptions = tryResolveTailwindV4SourceOptions(runtimeState);
|
|
996
1025
|
const resolvedSourceOptions = sourceOptions ? require_v3_engine.omitUndefined({
|
|
997
1026
|
...sourceOptions,
|
|
998
|
-
sourceFile: resolvePostcssSourceFile(cssHandlerOptions),
|
|
1027
|
+
sourceFile: sourceOptions.sourceFile ?? resolvePostcssSourceFile(cssHandlerOptions),
|
|
999
1028
|
...resolveCssHandlerSourceOptions(cssHandlerOptions),
|
|
1000
1029
|
cssEntries: selectionOptions?.cssEntries ?? sourceOptions.cssEntries,
|
|
1001
1030
|
cssSources: mergeCssSources(sourceOptions.cssSources, sourceOptions.cssSources?.length ? void 0 : createCssEntrySources(selectionOptions?.cssEntries ?? sourceOptions.cssEntries))
|
|
@@ -1009,17 +1038,18 @@ async function resolveGeneratorSource(majorVersion, runtimeState, rawSource, fil
|
|
|
1009
1038
|
}));
|
|
1010
1039
|
}
|
|
1011
1040
|
const shouldPreferSourceSideEntry = shouldResolveSourceSideCssEntry(rawSource) || Boolean(cssEntrySource?.css.includes("weapp-tailwindcss generator-placeholder")) && (sourceOptions?.cssEntries?.length ?? 0) <= 1;
|
|
1012
|
-
const sourceSideEntrySource = normalizedSourceOptions && shouldPreferSourceSideEntry && canResolveSourceSideCssEntry(file, cssHandlerOptions, normalizedSourceOptions) ? resolveSourceSideCssEntrySource(file, normalizedSourceOptions, { removeConfig: false }) : void 0;
|
|
1041
|
+
const sourceSideEntrySource = normalizedSourceOptions && (shouldPreferSourceSideEntry || normalizedSourceOptions.sourceFile !== void 0) && canResolveSourceSideCssEntry(file, cssHandlerOptions, normalizedSourceOptions) ? resolveSourceSideCssEntrySource(file, normalizedSourceOptions, { removeConfig: false }) : void 0;
|
|
1013
1042
|
const matchedCssEntrySource = normalizedSourceOptions ? await resolveMatchingTailwindV4CssEntry(rawSource, file, normalizedSourceOptions) : void 0;
|
|
1014
1043
|
const matchedCssSource = normalizedSourceOptions && !matchedCssEntrySource ? await resolveMatchingTailwindV4CssSource(rawSource, file, cssHandlerOptions, normalizedSourceOptions) : void 0;
|
|
1015
1044
|
const candidateMatchedCssSource = normalizedSourceOptions && !matchedCssEntrySource ? await resolveCandidateMatchedTailwindV4CssSource(rawSource, cssHandlerOptions, normalizedSourceOptions, selectionOptions) : void 0;
|
|
1016
|
-
const
|
|
1045
|
+
const singleConfiguredCssSource = normalizedSourceOptions?.cssSources?.length === 1 ? await resolveSingleTailwindV4CssSource(normalizedSourceOptions.cssSources[0], normalizedSourceOptions, { matched: true }) : void 0;
|
|
1046
|
+
const configuredCssSource = normalizedSourceOptions && hasConfiguredTailwindV4CssSource(normalizedSourceOptions) && require_v3_engine.hasTailwindGeneratedCssMarkers(rawSource) ? matchedCssSource ?? candidateMatchedCssSource ?? singleConfiguredCssSource ?? await require_v3_engine.resolveTailwindV4Source(normalizedSourceOptions) : void 0;
|
|
1017
1047
|
if (configuredCssSource) return generatorOptions?.config ? {
|
|
1018
1048
|
...configuredCssSource,
|
|
1019
1049
|
css: require_v3_engine.prependConfigDirective(configuredCssSource.css, generatorOptions.config)
|
|
1020
1050
|
} : configuredCssSource;
|
|
1021
1051
|
const mainCssEntrySource = normalizedSourceOptions && cssHandlerOptions.isMainChunk && normalizedSourceOptions.cssEntries?.length === 1 ? await resolveTailwindV4CssEntrySource(normalizedSourceOptions.cssEntries[0], normalizedSourceOptions) : void 0;
|
|
1022
|
-
const preferredCssEntrySource = matchedCssEntrySource ?? matchedCssSource ?? candidateMatchedCssSource ?? mainCssEntrySource;
|
|
1052
|
+
const preferredCssEntrySource = matchedCssEntrySource ?? matchedCssSource ?? candidateMatchedCssSource ?? mainCssEntrySource ?? singleConfiguredCssSource;
|
|
1023
1053
|
if (preferredCssEntrySource) return generatorOptions?.config ? {
|
|
1024
1054
|
...preferredCssEntrySource,
|
|
1025
1055
|
css: require_v3_engine.prependConfigDirective(preferredCssEntrySource.css, generatorOptions.config)
|
|
@@ -1059,7 +1089,7 @@ async function resolveGeneratorSources(majorVersion, runtimeState, rawSource, fi
|
|
|
1059
1089
|
sourceFile: resolvePostcssSourceFile(cssHandlerOptions),
|
|
1060
1090
|
...resolveCssHandlerSourceOptions(cssHandlerOptions),
|
|
1061
1091
|
cssEntries,
|
|
1062
|
-
cssSources: mergeCssSources(sourceOptionsFromPatcher.cssSources, sourceOptionsFromPatcher.cssSources?.length ? void 0 : createCssEntrySources(cssEntries))
|
|
1092
|
+
cssSources: mergeCssSources(mergeCssSources(sourceOptionsFromPatcher.cssSources, selectionOptions?.cssSources), sourceOptionsFromPatcher.cssSources?.length || selectionOptions?.cssSources?.length ? void 0 : createCssEntrySources(cssEntries))
|
|
1063
1093
|
});
|
|
1064
1094
|
} catch {
|
|
1065
1095
|
const resolved = await resolveGeneratorSource(majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions, selectionOptions);
|
|
@@ -1070,7 +1100,7 @@ async function resolveGeneratorSources(majorVersion, runtimeState, rawSource, fi
|
|
|
1070
1100
|
...matchedCssEntrySource,
|
|
1071
1101
|
css: require_v3_engine.prependConfigDirective(matchedCssEntrySource.css, generatorOptions.config)
|
|
1072
1102
|
} : matchedCssEntrySource];
|
|
1073
|
-
const sourceSideCssSource = await resolveTailwindV4SourceSideEntrySource(
|
|
1103
|
+
const sourceSideCssSource = await resolveTailwindV4SourceSideEntrySource(canResolveSourceSideCssEntry(file, cssHandlerOptions, sourceOptions) ? resolveSourceSideCssEntrySource(file, sourceOptions, { removeConfig: false }) : void 0, sourceOptions, generatorOptions, file);
|
|
1074
1104
|
if (sourceSideCssSource) return [sourceSideCssSource];
|
|
1075
1105
|
const matchedCssSource = await resolveMatchingTailwindV4CssSource(rawSource, file, cssHandlerOptions, sourceOptions);
|
|
1076
1106
|
const candidateMatchedCssSource = await resolveCandidateMatchedTailwindV4CssSource(rawSource, cssHandlerOptions, sourceOptions, selectionOptions);
|
|
@@ -1105,6 +1135,10 @@ async function resolveGeneratorSourceEntries(source, runtimeState) {
|
|
|
1105
1135
|
if (sourceMetadata?.sourceEntries) return sourceMetadata.sourceEntries;
|
|
1106
1136
|
if (!("css" in source) || !("base" in source) || !("baseFallbacks" in source)) return;
|
|
1107
1137
|
const resolved = await require_v3_engine.resolveTailwindV4EntriesFromCss(sourceMetadata?.sourceCss ?? source.css, sourceMetadata?.sourceBase ?? source.base);
|
|
1138
|
+
if (resolved?.entries.length === 0 && !resolved.inlineCandidates.included.size && !resolved.inlineCandidates.excluded.size && !resolved.dependencies.length) {
|
|
1139
|
+
if (sourceMetadata?.matchedCssSourceFile) return [];
|
|
1140
|
+
return;
|
|
1141
|
+
}
|
|
1108
1142
|
if (resolved?.entries.length || !resolved?.explicit && !sourceMetadata?.matchedCssSourceFile || !runtimeState) return resolved?.entries;
|
|
1109
1143
|
const matchingCssSource = tryResolveTailwindV4SourceOptions(runtimeState)?.cssSources?.find((cssSource) => {
|
|
1110
1144
|
if (sourceMetadata?.matchedCssSourceFile && typeof cssSource.file === "string" && node_path.default.resolve(cssSource.file) === node_path.default.resolve(sourceMetadata.matchedCssSourceFile)) return true;
|
|
@@ -1528,6 +1562,16 @@ function isCommentOnlyCss(source) {
|
|
|
1528
1562
|
return false;
|
|
1529
1563
|
}
|
|
1530
1564
|
}
|
|
1565
|
+
function unwrapMiniProgramCascadeLayers(source) {
|
|
1566
|
+
if (!source.includes("@layer")) return source;
|
|
1567
|
+
try {
|
|
1568
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
1569
|
+
(0, _weapp_tailwindcss_postcss.removeUnsupportedCascadeLayers)(root);
|
|
1570
|
+
return root.toString();
|
|
1571
|
+
} catch {
|
|
1572
|
+
return source;
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1531
1575
|
function stripTailwindSourceMediaFragments(source) {
|
|
1532
1576
|
let removedSourceMediaStart = false;
|
|
1533
1577
|
return source.split(/\r?\n/).filter((line) => {
|
|
@@ -1695,7 +1739,7 @@ async function transformGeneratorUserCss(source, options) {
|
|
|
1695
1739
|
if (source.trim().length === 0) return "";
|
|
1696
1740
|
const cleanedSource = require_v3_engine.removeTailwindSourceDirectives(removeTailwindV4GeneratorAtRules(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(source))), { importFallback: options.importFallback });
|
|
1697
1741
|
if (cleanedSource.trim().length === 0) return "";
|
|
1698
|
-
const userSource = stripUnmatchedTailwindSourceMediaCloseFragments(removeTailwindApplyAtRules(require_v3_engine.removeTailwindSourceDirectives(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(options.generatorTarget === "weapp" ? (0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(cleanedSource) : cleanedSource)), { importFallback: options.importFallback })));
|
|
1742
|
+
const userSource = stripUnmatchedTailwindSourceMediaCloseFragments(removeTailwindApplyAtRules(require_v3_engine.removeTailwindSourceDirectives(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(options.generatorTarget === "weapp" ? (0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(unwrapMiniProgramCascadeLayers(cleanedSource)) : cleanedSource)), { importFallback: options.importFallback })));
|
|
1699
1743
|
if (userSource.trim().length === 0) return "";
|
|
1700
1744
|
if (isCommentOnlyCss(userSource)) return userSource;
|
|
1701
1745
|
if (options.generatorTarget !== "weapp") return userSource;
|
|
@@ -1860,7 +1904,7 @@ function pushConcurrentTaskFactories(queue, factories, limit) {
|
|
|
1860
1904
|
//#region src/bundlers/shared/generator-css/validate.ts
|
|
1861
1905
|
const SUPPORTED_GENERATOR_MAJOR_VERSIONS = new Set([3, 4]);
|
|
1862
1906
|
async function validateCandidatesByGenerator(options) {
|
|
1863
|
-
const { candidates, cssHandlerOptions, debug, file, opts, rawSource, runtimeState } = options;
|
|
1907
|
+
const { candidates, cssHandlerOptions, debug, file, opts, rawSource, runtimeState, skipGenerateFallback } = options;
|
|
1864
1908
|
const majorVersion = runtimeState.twPatcher.majorVersion;
|
|
1865
1909
|
if (!SUPPORTED_GENERATOR_MAJOR_VERSIONS.has(majorVersion ?? 0) || candidates.size === 0) return /* @__PURE__ */ new Set();
|
|
1866
1910
|
const generatorOptions = {
|
|
@@ -1876,6 +1920,7 @@ async function validateCandidatesByGenerator(options) {
|
|
|
1876
1920
|
if (generatorOptions.bareArbitraryValues === void 0 || generatorOptions.bareArbitraryValues === false) {
|
|
1877
1921
|
if (typeof generator.validateCandidates === "function") return generator.validateCandidates(candidates);
|
|
1878
1922
|
}
|
|
1923
|
+
if (skipGenerateFallback) return /* @__PURE__ */ new Set();
|
|
1879
1924
|
return (await generator.generate({
|
|
1880
1925
|
bareArbitraryValues: generatorOptions.bareArbitraryValues,
|
|
1881
1926
|
candidates,
|
|
@@ -1933,6 +1978,7 @@ async function generateCssByGenerator(options) {
|
|
|
1933
1978
|
const runtimeWithCurrentCss = createRuntimeWithCurrentCssCandidates(runtime, currentCssCandidates, isolateCurrentCssCandidates);
|
|
1934
1979
|
const sources = await resolveGeneratorSources(majorVersion, runtimeState, generatorRawSource, file, cssHandlerOptions, generatorOptions, {
|
|
1935
1980
|
cssEntries: opts.cssEntries,
|
|
1981
|
+
cssSources: options.cssSources,
|
|
1936
1982
|
getSourceCandidatesForEntries,
|
|
1937
1983
|
runtime: runtimeWithCurrentCss
|
|
1938
1984
|
});
|
|
@@ -1942,18 +1988,22 @@ async function generateCssByGenerator(options) {
|
|
|
1942
1988
|
const generated = mergeGeneratorResults((await runWithConcurrency(sources.map((source) => async () => {
|
|
1943
1989
|
const generator = require_generator.createWeappTailwindcssGenerator(source);
|
|
1944
1990
|
const sourceEntries = getSourceCandidatesForEntries && (majorVersion === 3 || majorVersion === 4) ? await resolveGeneratorSourceEntries(source, runtimeState) : void 0;
|
|
1945
|
-
const scopedRuntime = sourceEntries ? getSourceCandidatesForEntries?.(sourceEntries) : void 0;
|
|
1946
|
-
const isolateCssSource = shouldIsolateScopedCssSource(source, sourceEntries
|
|
1991
|
+
const scopedRuntime = sourceEntries && sourceEntries.length > 0 ? getSourceCandidatesForEntries?.(sourceEntries) : void 0;
|
|
1992
|
+
const isolateCssSource = shouldIsolateScopedCssSource(majorVersion, source, sourceEntries, {
|
|
1993
|
+
cssHandlerOptions,
|
|
1994
|
+
target: generatorOptions.target
|
|
1995
|
+
});
|
|
1947
1996
|
const sourceMetadata = source.__weappTailwindcssMeta;
|
|
1948
1997
|
const matchedCssSourceFile = Boolean(sourceMetadata?.matchedCssSourceFile);
|
|
1949
1998
|
if (options.deferEmptyScopedCssSource && isolateCssSource && scopedRuntime?.size === 0 && currentCssCandidates.length === 0 && !cssHandlerOptions.isMainChunk) {
|
|
1950
1999
|
debug("defer empty scoped css source generation: %s", file);
|
|
1951
2000
|
return;
|
|
1952
2001
|
}
|
|
1953
|
-
const sourceRuntime = scopedRuntime && (scopedRuntime.size > 0 || isolateCssSource) ? isolateCurrentCssCandidates ? runtimeWithCurrentCss : mergeScopedRuntimeWithCurrentRuntime(scopedRuntime, runtimeWithCurrentCss, {
|
|
2002
|
+
const sourceRuntime = scopedRuntime && (scopedRuntime.size > 0 || isolateCssSource) || isolateCssSource ? isolateCurrentCssCandidates ? runtimeWithCurrentCss : mergeScopedRuntimeWithCurrentRuntime(scopedRuntime ?? /* @__PURE__ */ new Set(), runtimeWithCurrentCss, {
|
|
1954
2003
|
currentCssCandidates,
|
|
1955
2004
|
cssHandlerOptions,
|
|
1956
2005
|
isolateCssSource,
|
|
2006
|
+
majorVersion,
|
|
1957
2007
|
matchedCssSourceFile
|
|
1958
2008
|
}) : runtimeWithCurrentCss;
|
|
1959
2009
|
const generatorRuntime = majorVersion === 4 && generatorOptions.target === "weapp" ? require_v3_engine.filterUnsupportedMiniProgramTailwindV4Candidates(sourceRuntime) : sourceRuntime;
|
|
@@ -1973,7 +2023,10 @@ async function generateCssByGenerator(options) {
|
|
|
1973
2023
|
if ((generated.target !== "weapp" || !hasUserCssLayerBlocks(generatorRawSource)) && typeof options.previousCss === "string" && typeof generated.incrementalCss === "string") {
|
|
1974
2024
|
const incrementalCss = require_v3_engine.stripTailwindBanner(generated.incrementalCss);
|
|
1975
2025
|
return {
|
|
1976
|
-
css: restoreLocalCssImports(incrementalCss.trim().length > 0 ? require_v3_engine.createCssAppend(options.previousCss, finalizeMiniProgramGeneratorCss(incrementalCss, generated.target, majorVersion, opts.cssPreflight, {
|
|
2026
|
+
css: restoreLocalCssImports(incrementalCss.trim().length > 0 ? require_v3_engine.createCssAppend(options.previousCss, finalizeMiniProgramGeneratorCss(incrementalCss, generated.target, majorVersion, opts.cssPreflight, {
|
|
2027
|
+
injectPreflight: false,
|
|
2028
|
+
styleOptions: generatorStyleOptions
|
|
2029
|
+
})) : options.previousCss, localImportParts?.imports),
|
|
1977
2030
|
target: generated.target,
|
|
1978
2031
|
source: "generator",
|
|
1979
2032
|
dependencies: generated.dependencies,
|
|
@@ -2005,7 +2058,8 @@ async function generateCssByGenerator(options) {
|
|
|
2005
2058
|
const beforeUserCss = await transformGeneratorUserCss(orderedExtraCss.before, userCssOptions);
|
|
2006
2059
|
const afterLayerUserCss = await transformGeneratorUserCss(afterLayerParts.layer, userCssOptions);
|
|
2007
2060
|
const afterUserCss = await transformGeneratorUserCss(afterLayerParts.rest, userCssOptions);
|
|
2008
|
-
|
|
2061
|
+
const fallbackLayerUserCss = generated.target === "weapp" && afterLayerParts.layer.trim().length === 0 && hasUserCssLayerBlocks(userCssRawSource) ? await transformGeneratorUserCss(splitUserCssLayerBlocks(userCssRawSource).layer, userCssOptions) : "";
|
|
2062
|
+
css = createCssSourceOrderAppend$1(createCssSourceOrderAppend$1(createCssSourceOrderAppend$1(beforeUserCss, generated.target === "weapp" ? wrapUserLayerComponentsCss(createCssSourceOrderAppend$1(afterLayerUserCss, fallbackLayerUserCss)) : afterLayerUserCss), css), afterUserCss);
|
|
2009
2063
|
if (isEmptyCssSourceOrderParts(orderedExtraCss) && shouldAppendWebBundleCssFallback(generated.target, {
|
|
2010
2064
|
hasSourceDirectives,
|
|
2011
2065
|
hasMatchedCssSourceFile
|
|
@@ -2021,11 +2075,14 @@ async function generateCssByGenerator(options) {
|
|
|
2021
2075
|
}
|
|
2022
2076
|
} else if (generated.target === "weapp" && shouldFinalizeMarkedUserLayerComponentsCss(file)) css = reorderMarkedUserLayerComponentsCss(css);
|
|
2023
2077
|
return {
|
|
2024
|
-
css: restoreLocalCssImports(finalizeMiniProgramGeneratorCss(css, generated.target, majorVersion, opts.cssPreflight, {
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2078
|
+
css: restoreLocalCssImports(finalizeMiniProgramGeneratorCss(css, generated.target, majorVersion, opts.cssPreflight, {
|
|
2079
|
+
injectPreflight: shouldInjectMiniProgramPreflightForGeneratorCss(opts, {
|
|
2080
|
+
cssHandlerOptions,
|
|
2081
|
+
isolateCurrentCssCandidates,
|
|
2082
|
+
localImports: localImportParts?.imports
|
|
2083
|
+
}),
|
|
2084
|
+
styleOptions: generatorStyleOptions
|
|
2085
|
+
}), localImportParts?.imports),
|
|
2029
2086
|
target: generated.target,
|
|
2030
2087
|
source: "generator",
|
|
2031
2088
|
dependencies: generated.dependencies
|
|
@@ -2064,6 +2121,18 @@ async function generateCssByGenerator(options) {
|
|
|
2064
2121
|
importFallback: generatorOptions.importFallback
|
|
2065
2122
|
});
|
|
2066
2123
|
css = createCssSourceOrderAppend$1(css, userCss);
|
|
2124
|
+
} else if (hasMatchedCssSourceFile && generated.target === "weapp" && hasUserCssLayerBlocks(userCssRawSource)) {
|
|
2125
|
+
const layerUserCss = await transformGeneratorUserCss(splitUserCssLayerBlocks(userCssRawSource).layer, {
|
|
2126
|
+
generatorTarget: generated.target,
|
|
2127
|
+
generatorStyleOptions,
|
|
2128
|
+
cssUserHandlerOptions,
|
|
2129
|
+
styleHandler,
|
|
2130
|
+
importFallback: generatorOptions.importFallback
|
|
2131
|
+
});
|
|
2132
|
+
if (layerUserCss.trim().length > 0) {
|
|
2133
|
+
css = createCssSourceOrderAppend$1(css, wrapUserLayerComponentsCss(layerUserCss));
|
|
2134
|
+
if (shouldFinalizeMarkedUserLayerComponentsCss(file)) css = reorderMarkedUserLayerComponentsCss(css);
|
|
2135
|
+
}
|
|
2067
2136
|
}
|
|
2068
2137
|
if (hasMatchedCssSourceFile && generated.target === "weapp") {
|
|
2069
2138
|
if (!isolateCurrentCssCandidates && !shouldFilterApplyOnlyCss) css = await appendLegacyContainerCompatCss(css, userCssRawSource, file, runtime, configuredContainerCompat, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions);
|
|
@@ -2082,11 +2151,14 @@ async function generateCssByGenerator(options) {
|
|
|
2082
2151
|
css = createCssSourceOrderAppend$1(css, userCss);
|
|
2083
2152
|
}
|
|
2084
2153
|
return {
|
|
2085
|
-
css: restoreLocalCssImports(finalizeMiniProgramGeneratorCss(css, generated.target, majorVersion, opts.cssPreflight, {
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2154
|
+
css: restoreLocalCssImports(finalizeMiniProgramGeneratorCss(css, generated.target, majorVersion, opts.cssPreflight, {
|
|
2155
|
+
injectPreflight: shouldInjectMiniProgramPreflightForGeneratorCss(opts, {
|
|
2156
|
+
cssHandlerOptions,
|
|
2157
|
+
isolateCurrentCssCandidates,
|
|
2158
|
+
localImports: localImportParts?.imports
|
|
2159
|
+
}),
|
|
2160
|
+
styleOptions: generatorStyleOptions
|
|
2161
|
+
}), localImportParts?.imports),
|
|
2090
2162
|
target: generated.target,
|
|
2091
2163
|
source: "generator",
|
|
2092
2164
|
dependencies: generated.dependencies
|
|
@@ -2097,11 +2169,14 @@ async function generateCssByGenerator(options) {
|
|
|
2097
2169
|
css = await appendLegacyContainerCompatCss(css, userCssRawSource, file, runtime, configuredContainerCompat, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions);
|
|
2098
2170
|
}
|
|
2099
2171
|
return {
|
|
2100
|
-
css: restoreLocalCssImports(finalizeMiniProgramGeneratorCss(css, generated.target, majorVersion, opts.cssPreflight, {
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2172
|
+
css: restoreLocalCssImports(finalizeMiniProgramGeneratorCss(css, generated.target, majorVersion, opts.cssPreflight, {
|
|
2173
|
+
injectPreflight: shouldInjectMiniProgramPreflightForGeneratorCss(opts, {
|
|
2174
|
+
cssHandlerOptions,
|
|
2175
|
+
isolateCurrentCssCandidates,
|
|
2176
|
+
localImports: localImportParts?.imports
|
|
2177
|
+
}),
|
|
2178
|
+
styleOptions: generatorStyleOptions
|
|
2179
|
+
}), localImportParts?.imports),
|
|
2105
2180
|
target: generated.target,
|
|
2106
2181
|
source: "generator",
|
|
2107
2182
|
dependencies: generated.dependencies
|
|
@@ -2673,39 +2748,6 @@ const SCRIPT_SOURCE_CANDIDATE_EXTENSIONS = new Set([
|
|
|
2673
2748
|
"mts",
|
|
2674
2749
|
"cts"
|
|
2675
2750
|
]);
|
|
2676
|
-
const CLASS_LIKE_NAME_RE = /class/i;
|
|
2677
|
-
function getPropertyName(node) {
|
|
2678
|
-
if (!node) return;
|
|
2679
|
-
if (node.type === "Identifier") return node.name;
|
|
2680
|
-
if (node.type === "StringLiteral") return node.value;
|
|
2681
|
-
}
|
|
2682
|
-
function isClassLikeStringPath(path) {
|
|
2683
|
-
const parent = path.parentPath;
|
|
2684
|
-
if (!parent) return false;
|
|
2685
|
-
if (parent.isVariableDeclarator?.()) return CLASS_LIKE_NAME_RE.test(getPropertyName(parent.node.id) ?? "");
|
|
2686
|
-
if (parent.isObjectProperty?.() || parent.isObjectMethod?.()) return CLASS_LIKE_NAME_RE.test(getPropertyName(parent.node.key) ?? "");
|
|
2687
|
-
if (parent.isAssignmentExpression?.()) {
|
|
2688
|
-
const left = parent.node.left;
|
|
2689
|
-
if (left?.type === "Identifier") return CLASS_LIKE_NAME_RE.test(left.name);
|
|
2690
|
-
if (left?.type === "MemberExpression") return CLASS_LIKE_NAME_RE.test(getPropertyName(left.property) ?? "");
|
|
2691
|
-
}
|
|
2692
|
-
if (parent.isJSXAttribute?.()) return CLASS_LIKE_NAME_RE.test(getPropertyName(parent.node.name) ?? "");
|
|
2693
|
-
return false;
|
|
2694
|
-
}
|
|
2695
|
-
function isTemplateElementInClassLikePath(path) {
|
|
2696
|
-
const templateLiteralPath = path.parentPath;
|
|
2697
|
-
if (!templateLiteralPath?.isTemplateLiteral?.()) return false;
|
|
2698
|
-
const parent = templateLiteralPath.parentPath;
|
|
2699
|
-
if (!parent) return false;
|
|
2700
|
-
if (parent.isVariableDeclarator?.()) return CLASS_LIKE_NAME_RE.test(getPropertyName(parent.node.id) ?? "");
|
|
2701
|
-
if (parent.isObjectProperty?.() || parent.isObjectMethod?.()) return CLASS_LIKE_NAME_RE.test(getPropertyName(parent.node.key) ?? "");
|
|
2702
|
-
if (parent.isAssignmentExpression?.()) {
|
|
2703
|
-
const left = parent.node.left;
|
|
2704
|
-
if (left?.type === "Identifier") return CLASS_LIKE_NAME_RE.test(left.name);
|
|
2705
|
-
if (left?.type === "MemberExpression") return CLASS_LIKE_NAME_RE.test(getPropertyName(left.property) ?? "");
|
|
2706
|
-
}
|
|
2707
|
-
return false;
|
|
2708
|
-
}
|
|
2709
2751
|
async function extractScriptStringCandidates(source, extension, options) {
|
|
2710
2752
|
if (!SCRIPT_SOURCE_CANDIDATE_EXTENSIONS.has(extension)) return [];
|
|
2711
2753
|
const values = /* @__PURE__ */ new Set();
|
|
@@ -2718,10 +2760,10 @@ async function extractScriptStringCandidates(source, extension, options) {
|
|
|
2718
2760
|
}), {
|
|
2719
2761
|
noScope: true,
|
|
2720
2762
|
StringLiteral(path) {
|
|
2721
|
-
|
|
2763
|
+
values.add(path.node.value);
|
|
2722
2764
|
},
|
|
2723
2765
|
TemplateElement(path) {
|
|
2724
|
-
|
|
2766
|
+
values.add(path.node.value.raw);
|
|
2725
2767
|
}
|
|
2726
2768
|
});
|
|
2727
2769
|
} catch {
|
|
@@ -2826,6 +2868,7 @@ function createSourceCandidateCollector(options = {}) {
|
|
|
2826
2868
|
}
|
|
2827
2869
|
async function syncCss(id, source) {
|
|
2828
2870
|
const normalizedId = cleanUrl(id);
|
|
2871
|
+
sourceById.set(normalizedId, source);
|
|
2829
2872
|
const contentCacheKey = createSourceCandidateContentCacheKey("css", source, options.bareArbitraryValues, options.extractor);
|
|
2830
2873
|
const cachedCandidates = sourceCandidateContentCache.get(contentCacheKey);
|
|
2831
2874
|
if (cachedCandidates) {
|
|
@@ -2838,6 +2881,7 @@ function createSourceCandidateCollector(options = {}) {
|
|
|
2838
2881
|
}
|
|
2839
2882
|
async function merge(id, source) {
|
|
2840
2883
|
const normalizedId = cleanUrl(id);
|
|
2884
|
+
sourceById.set(normalizedId, source);
|
|
2841
2885
|
const extension = resolveSourceCandidateExtension(normalizedId);
|
|
2842
2886
|
const contentCacheKey = createSourceCandidateContentCacheKey(extension, source, options.bareArbitraryValues, options.extractor);
|
|
2843
2887
|
const cachedCandidates = sourceCandidateContentCache.get(contentCacheKey);
|
|
@@ -2847,11 +2891,20 @@ function createSourceCandidateCollector(options = {}) {
|
|
|
2847
2891
|
}
|
|
2848
2892
|
async function syncFile(id) {
|
|
2849
2893
|
const normalizedId = cleanUrl(id);
|
|
2850
|
-
|
|
2894
|
+
try {
|
|
2895
|
+
await sync(normalizedId, await (0, node_fs_promises.readFile)(normalizedId, "utf8"));
|
|
2896
|
+
} catch (error) {
|
|
2897
|
+
if ((typeof error === "object" && error !== null && "code" in error ? error.code : void 0) === "ENOENT") {
|
|
2898
|
+
remove(normalizedId);
|
|
2899
|
+
return;
|
|
2900
|
+
}
|
|
2901
|
+
throw error;
|
|
2902
|
+
}
|
|
2851
2903
|
}
|
|
2852
2904
|
async function syncCurrentFile(id) {
|
|
2853
2905
|
const normalizedId = cleanUrl(id);
|
|
2854
2906
|
transformCandidatesById.delete(normalizedId);
|
|
2907
|
+
cssCandidatesById.delete(normalizedId);
|
|
2855
2908
|
await syncFile(normalizedId);
|
|
2856
2909
|
}
|
|
2857
2910
|
async function scanRoot({ entries, explicit, root, outDir }) {
|
|
@@ -2919,6 +2972,9 @@ function createSourceCandidateCollector(options = {}) {
|
|
|
2919
2972
|
function source(id) {
|
|
2920
2973
|
return sourceById.get(cleanUrl(id));
|
|
2921
2974
|
}
|
|
2975
|
+
function sources() {
|
|
2976
|
+
return sourceById.entries();
|
|
2977
|
+
}
|
|
2922
2978
|
function values() {
|
|
2923
2979
|
const values = new Set([...candidateCount.keys(), ...inlineIncludedCandidates]);
|
|
2924
2980
|
for (const candidate of inlineExcludedCandidates) values.delete(candidate);
|
|
@@ -2928,6 +2984,7 @@ function createSourceCandidateCollector(options = {}) {
|
|
|
2928
2984
|
if (entries === void 0) {
|
|
2929
2985
|
if (!options.excludeEntries?.length) return values();
|
|
2930
2986
|
}
|
|
2987
|
+
if (entries?.length === 0) return new Set(inlineIncludedCandidates);
|
|
2931
2988
|
const filtered = /* @__PURE__ */ new Set();
|
|
2932
2989
|
for (const [id, candidates] of candidatesById) {
|
|
2933
2990
|
if (entries !== void 0 && !require_v3_engine.isFileMatchedByTailwindSourceEntries(id, entries)) continue;
|
|
@@ -2948,6 +3005,11 @@ function createSourceCandidateCollector(options = {}) {
|
|
|
2948
3005
|
}
|
|
2949
3006
|
if (id) candidateSources.add(id);
|
|
2950
3007
|
};
|
|
3008
|
+
if (entries?.length === 0) {
|
|
3009
|
+
for (const candidate of inlineIncludedCandidates) addCandidateSource(candidate, void 0);
|
|
3010
|
+
for (const candidate of inlineExcludedCandidates) sources.delete(candidate);
|
|
3011
|
+
return sources;
|
|
3012
|
+
}
|
|
2951
3013
|
for (const [id, candidates] of candidatesById) {
|
|
2952
3014
|
if (entries !== void 0 && !require_v3_engine.isFileMatchedByTailwindSourceEntries(id, entries)) continue;
|
|
2953
3015
|
if (options.excludeEntries?.length && require_v3_engine.isFileMatchedByTailwindSourceEntries(id, options.excludeEntries)) continue;
|
|
@@ -2967,6 +3029,18 @@ function createSourceCandidateCollector(options = {}) {
|
|
|
2967
3029
|
inlineIncludedCandidates.clear();
|
|
2968
3030
|
inlineExcludedCandidates.clear();
|
|
2969
3031
|
}
|
|
3032
|
+
function clearScan() {
|
|
3033
|
+
for (const id of scanCandidatesById.keys()) {
|
|
3034
|
+
scanCandidatesById.delete(id);
|
|
3035
|
+
recompute(id);
|
|
3036
|
+
}
|
|
3037
|
+
inlineIncludedCandidates.clear();
|
|
3038
|
+
inlineExcludedCandidates.clear();
|
|
3039
|
+
}
|
|
3040
|
+
function resetScan() {
|
|
3041
|
+
inlineIncludedCandidates.clear();
|
|
3042
|
+
inlineExcludedCandidates.clear();
|
|
3043
|
+
}
|
|
2970
3044
|
function snapshot() {
|
|
2971
3045
|
return {
|
|
2972
3046
|
candidatesById: [...candidatesById.entries()].map(([id, candidates]) => [id, [...candidates]]),
|
|
@@ -2998,13 +3072,13 @@ function createSourceCandidateCollector(options = {}) {
|
|
|
2998
3072
|
if (candidateSet.size === 0) continue;
|
|
2999
3073
|
cssCandidatesById.set(id, candidateSet);
|
|
3000
3074
|
}
|
|
3001
|
-
for (const [id, candidates] of snapshot.candidatesById) {
|
|
3002
|
-
const candidateSet = new Set(candidates);
|
|
3003
|
-
if (candidateSet.size === 0) continue;
|
|
3004
|
-
candidatesById.set(id, candidateSet);
|
|
3005
|
-
addCandidateSet(candidateCount, candidateSet);
|
|
3006
|
-
}
|
|
3007
3075
|
for (const [id, source] of snapshot.sourceById ?? []) sourceById.set(id, source);
|
|
3076
|
+
const ids = new Set([
|
|
3077
|
+
...scanCandidatesById.keys(),
|
|
3078
|
+
...transformCandidatesById.keys(),
|
|
3079
|
+
...cssCandidatesById.keys()
|
|
3080
|
+
]);
|
|
3081
|
+
for (const id of ids) recompute(id);
|
|
3008
3082
|
}
|
|
3009
3083
|
return {
|
|
3010
3084
|
sync,
|
|
@@ -3016,11 +3090,14 @@ function createSourceCandidateCollector(options = {}) {
|
|
|
3016
3090
|
syncInline,
|
|
3017
3091
|
remove,
|
|
3018
3092
|
source,
|
|
3093
|
+
sources,
|
|
3019
3094
|
values,
|
|
3020
3095
|
valuesForEntries,
|
|
3021
3096
|
sourcesForEntries,
|
|
3022
3097
|
snapshot,
|
|
3023
3098
|
restore,
|
|
3099
|
+
clearScan,
|
|
3100
|
+
resetScan,
|
|
3024
3101
|
clear
|
|
3025
3102
|
};
|
|
3026
3103
|
}
|