weapp-tailwindcss 5.0.11 → 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-BwtEqxvU.js → bundle-state-CKWeTEhv.js} +2 -40
- package/dist/{bundle-state-CXzPknlT.mjs → bundle-state-zQ2MrDdi.mjs} +2 -34
- package/dist/bundlers/gulp/vinyl-transform.d.ts +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/shared/hmr-timing.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 +9 -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 +7 -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 +9 -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 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/helpers.d.ts +11 -8
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +2 -0
- package/dist/bundlers/webpack/loaders/runtime-registry.d.ts +5 -0
- package/dist/cache/index.d.ts +4 -0
- package/dist/cli.js +9 -2
- package/dist/cli.mjs +8 -1
- package/dist/core.d.ts +7 -0
- package/dist/core.js +8 -5
- package/dist/core.mjs +8 -5
- 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-ChgOWNOj.js → generator-CzpArpCL.js} +1 -1
- package/dist/{generator-h2XRiJ9-.mjs → generator-ITLd7PTl.mjs} +1 -1
- package/dist/generator.js +2 -2
- package/dist/generator.mjs +2 -2
- package/dist/{gulp-Be88jhoY.mjs → gulp-DfOQERcV.mjs} +137 -23
- package/dist/{gulp-CHtZF-oT.js → gulp-XT8Jc7lH.js} +137 -23
- package/dist/gulp.js +1 -1
- package/dist/gulp.mjs +1 -1
- package/dist/{hmr-timing-BkivBZvN.js → hmr-timing-BMftW7Us.js} +354 -225
- package/dist/{hmr-timing-Ct5w4hdM.mjs → hmr-timing-DQIP_8qP.mjs} +341 -225
- package/dist/index.d.ts +1 -0
- package/dist/index.js +20 -4
- package/dist/index.mjs +6 -5
- package/dist/postcss.js +9 -10
- package/dist/postcss.mjs +7 -5
- package/dist/{precheck-CY9oaH49.js → precheck-B0Z8yW7E.js} +108 -27
- package/dist/{precheck-BpHxsWRd.mjs → precheck-CRI90iL1.mjs} +109 -28
- package/dist/presets.js +3 -3
- package/dist/presets.mjs +3 -3
- package/dist/tailwindcss/source-scan.d.ts +1 -0
- package/dist/tailwindcss/v3-engine/generator.d.ts +17 -0
- package/dist/tailwindcss/v3-engine/index.d.ts +1 -1
- package/dist/tailwindcss/v3-engine/types.d.ts +1 -0
- package/dist/tailwindcss/v4-engine/generator.d.ts +19 -0
- package/dist/tailwindcss/v4-engine/index.d.ts +1 -1
- package/dist/{tailwindcss-Bfy2egdX.mjs → tailwindcss-DTq3uYBK.mjs} +2 -2
- package/dist/{tailwindcss-DbbAKAZP.js → tailwindcss-DZEwT3C_.js} +3 -3
- package/dist/{transform-r5evL6Hn.mjs → transform-DfcEjsZF.mjs} +29 -21
- package/dist/{transform-Cd634UZV.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-D0yA9ZkF.js → v3-engine-2rrgylhn.js} +194 -34
- package/dist/{v3-engine-CFkP6dWF.mjs → v3-engine-C6eJ0YzK.mjs} +176 -34
- package/dist/{vite-j9cB2Ff1.js → vite-CXHVsHmX.js} +2071 -1160
- package/dist/{vite-Bd8qf9dK.mjs → vite-DjI09vVN.mjs} +2071 -1160
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.js +476 -217
- package/dist/weapp-tw-runtime-classset-loader.js +25 -0
- package/dist/{webpack-DPdrcC2X.mjs → webpack-BcPpnT90.mjs} +251 -40
- package/dist/{webpack-CJAOcYEO.js → webpack-CfkUkMXG.js} +254 -43
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +10 -5
|
@@ -1,18 +1,20 @@
|
|
|
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 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");
|
|
9
6
|
let node_fs = require("node:fs");
|
|
10
7
|
let node_path = require("node:path");
|
|
11
8
|
node_path = require_chunk.__toESM(node_path);
|
|
12
9
|
let node_process = require("node:process");
|
|
13
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");
|
|
14
15
|
let node_fs_promises = require("node:fs/promises");
|
|
15
16
|
let _weapp_core_escape = require("@weapp-core/escape");
|
|
17
|
+
let _weapp_tailwindcss_shared_node = require("@weapp-tailwindcss/shared/node");
|
|
16
18
|
//#region src/bundlers/shared/cache.ts
|
|
17
19
|
async function processCachedTask({ cache, cacheKey, hashKey = cacheKey, rawSource, hash, readCache, applyResult, transform, onCacheHit }) {
|
|
18
20
|
let cacheHit = false;
|
|
@@ -103,6 +105,9 @@ function removeTracedTailwindGeneratedContainerRules(root) {
|
|
|
103
105
|
rule.remove();
|
|
104
106
|
});
|
|
105
107
|
}
|
|
108
|
+
function normalizeTraceCommentBefore(value) {
|
|
109
|
+
return value?.includes("\n") ? value : "\n";
|
|
110
|
+
}
|
|
106
111
|
function annotateCssSourceTrace(css, options) {
|
|
107
112
|
if (!isCssSourceTraceEnabled(options.opts) || !options.tokenSources?.size) return css;
|
|
108
113
|
try {
|
|
@@ -117,7 +122,7 @@ function annotateCssSourceTrace(css, options) {
|
|
|
117
122
|
return `${token} <= ${sources.length > 0 ? sources.join(", ") : "<tailwind generated>"}`;
|
|
118
123
|
});
|
|
119
124
|
const comment = _weapp_tailwindcss_postcss.postcss.comment({ text: `tokens: ${lines.join(" | ")}` });
|
|
120
|
-
|
|
125
|
+
comment.raws.before = normalizeTraceCommentBefore(rule.raws.before);
|
|
121
126
|
rule.raws.before = "\n";
|
|
122
127
|
rule.parent.insertBefore(rule, comment);
|
|
123
128
|
});
|
|
@@ -134,7 +139,8 @@ function finalizeMiniProgramGeneratorCss(css, target, majorVersion, cssPreflight
|
|
|
134
139
|
return (0, _weapp_tailwindcss_postcss.finalizeMiniProgramCss)(css, {
|
|
135
140
|
cssPreflight: majorVersion === 4 && options.injectPreflight !== false ? cssPreflight : void 0,
|
|
136
141
|
isTailwindcssV4: majorVersion === 4,
|
|
137
|
-
preservePseudoContentInit: majorVersion === 3
|
|
142
|
+
preservePseudoContentInit: majorVersion === 3,
|
|
143
|
+
tailwindcssV4GradientFallback: options.styleOptions?.cssOptions?.tailwindcssV4GradientFallback ?? options.styleOptions?.tailwindcssV4GradientFallback
|
|
138
144
|
});
|
|
139
145
|
}
|
|
140
146
|
function shouldInjectMiniProgramPreflightForGeneratorCss(opts, options) {
|
|
@@ -143,12 +149,24 @@ function shouldInjectMiniProgramPreflightForGeneratorCss(opts, options) {
|
|
|
143
149
|
return require_tailwindcss.isUniAppXEnabled(opts.uniAppX) && Boolean(options.localImports?.trim());
|
|
144
150
|
}
|
|
145
151
|
function mergeScopedRuntimeWithCurrentRuntime(scopedRuntime, runtime, options) {
|
|
146
|
-
if (options.
|
|
147
|
-
|
|
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;
|
|
148
162
|
return new Set([...scopedRuntime, ...runtime]);
|
|
149
163
|
}
|
|
150
|
-
function shouldIsolateScopedCssSource(source, sourceEntries) {
|
|
151
|
-
|
|
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;
|
|
152
170
|
}
|
|
153
171
|
function shouldIsolateCurrentTailwindV4CssCandidates(majorVersion, cssHandlerOptions, options) {
|
|
154
172
|
return majorVersion === 4 && !cssHandlerOptions.isMainChunk && require_v3_engine.hasTailwindApplyDirective(options.rawSource) && !require_v3_engine.hasTailwindRootDirectives(options.rawSource) && !options.hasGeneratedCss && !options.hasGeneratedMarkers;
|
|
@@ -166,13 +184,13 @@ function isEmptyCssSourceOrderParts(parts) {
|
|
|
166
184
|
return parts.before.trim().length === 0 && parts.after.trim().length === 0;
|
|
167
185
|
}
|
|
168
186
|
function resolveGeneratorStyleOptions(opts, cssHandlerOptions, generatorStyleOptions) {
|
|
187
|
+
const resolvedStyleOptions = require_precheck.resolveStyleOptionsFromContext(opts);
|
|
169
188
|
const preflightStyleOptions = {
|
|
170
|
-
cssPreflight:
|
|
171
|
-
cssPreflightRange:
|
|
189
|
+
cssPreflight: resolvedStyleOptions.cssPreflight,
|
|
190
|
+
cssPreflightRange: resolvedStyleOptions.cssPreflightRange
|
|
172
191
|
};
|
|
173
192
|
return {
|
|
174
|
-
...
|
|
175
|
-
atRules: opts.atRules,
|
|
193
|
+
...resolvedStyleOptions,
|
|
176
194
|
uniAppXCssTarget: opts.uniAppXCssTarget,
|
|
177
195
|
uniAppXUnsupported: opts.uniAppXUnsupported,
|
|
178
196
|
...cssHandlerOptions,
|
|
@@ -196,9 +214,9 @@ function splitRawSourceByGeneratedCssOrder(rawSource, rawTailwindCss) {
|
|
|
196
214
|
if (exactParts) return exactParts;
|
|
197
215
|
return require_v3_engine.splitTailwindGeneratedCssByBanner(rawSource);
|
|
198
216
|
}
|
|
199
|
-
function shouldUseGeneratorForCurrentCss(
|
|
217
|
+
function shouldUseGeneratorForCurrentCss(_majorVersion, cssHandlerOptions, options) {
|
|
200
218
|
const hasApplyDirectives = require_v3_engine.hasTailwindApplyDirective(options.rawSource);
|
|
201
|
-
return options.hasGeneratedCss || options.hasGeneratedMarkers || options.hasSourceDirectives ||
|
|
219
|
+
return options.hasGeneratedCss || options.hasGeneratedMarkers || options.hasSourceDirectives || hasApplyDirectives || cssHandlerOptions.isMainChunk;
|
|
202
220
|
}
|
|
203
221
|
function createRuntimeWithCurrentCssCandidates(runtime, currentCssCandidates, isolateCurrentCssCandidates) {
|
|
204
222
|
return isolateCurrentCssCandidates ? new Set(currentCssCandidates) : currentCssCandidates.length > 0 ? new Set([...runtime, ...currentCssCandidates]) : runtime;
|
|
@@ -550,98 +568,53 @@ function extractStyleDirectiveSources(source) {
|
|
|
550
568
|
let match = SFC_STYLE_BLOCK_RE.exec(source);
|
|
551
569
|
while (match !== null) {
|
|
552
570
|
const styleSource = match[1] ?? "";
|
|
553
|
-
if (require_v3_engine.hasTailwindSourceDirectives(styleSource)) styleSources.push(styleSource);
|
|
571
|
+
if (require_v3_engine.hasTailwindSourceDirectives(styleSource, { importFallback: true })) styleSources.push(styleSource);
|
|
554
572
|
match = SFC_STYLE_BLOCK_RE.exec(source);
|
|
555
573
|
}
|
|
556
574
|
if (styleSources.length > 0) return styleSources;
|
|
557
|
-
return require_v3_engine.hasTailwindSourceDirectives(source) ? [source] : [];
|
|
575
|
+
return require_v3_engine.hasTailwindSourceDirectives(source, { importFallback: true }) ? [source] : [];
|
|
558
576
|
}
|
|
559
577
|
function resolveSourceSideCssEntrySource(file, sourceOptions, resolveOptions = {}) {
|
|
560
|
-
for (const sourceFile of createSourceStylePathCandidates(file, sourceOptions)) {
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
};
|
|
570
|
-
}
|
|
571
|
-
} catch {
|
|
572
|
-
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
|
+
};
|
|
573
587
|
}
|
|
588
|
+
} catch {
|
|
589
|
+
continue;
|
|
574
590
|
}
|
|
575
591
|
}
|
|
576
592
|
//#endregion
|
|
577
|
-
//#region src/bundlers/shared/generator-css/source-resolver.ts
|
|
578
|
-
function
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
}
|
|
587
|
-
function resolveCssHandlerSourceOptions(cssHandlerOptions) {
|
|
588
|
-
return cssHandlerOptions.sourceOptions;
|
|
589
|
-
}
|
|
590
|
-
function createCssEntrySources(cssEntries) {
|
|
591
|
-
return cssEntries?.filter((entry) => typeof entry === "string" && entry.length > 0 && node_path.default.isAbsolute(entry)).map((entry) => ({ file: node_path.default.resolve(entry) }));
|
|
592
|
-
}
|
|
593
|
-
function mergeCssSources(cssSources, cssEntrySources) {
|
|
594
|
-
const merged = [];
|
|
595
|
-
const seenFiles = /* @__PURE__ */ new Set();
|
|
596
|
-
const addSource = (cssSource) => {
|
|
597
|
-
const file = typeof cssSource.file === "string" && cssSource.file.length > 0 ? node_path.default.resolve(cssSource.file) : void 0;
|
|
598
|
-
if (file) {
|
|
599
|
-
if (seenFiles.has(file)) return;
|
|
600
|
-
seenFiles.add(file);
|
|
601
|
-
}
|
|
602
|
-
merged.push(cssSource);
|
|
603
|
-
};
|
|
604
|
-
for (const cssSource of cssSources ?? []) addSource(cssSource);
|
|
605
|
-
for (const cssSource of cssEntrySources ?? []) addSource(cssSource);
|
|
606
|
-
return merged.length > 0 ? merged : void 0;
|
|
607
|
-
}
|
|
608
|
-
function createSingleTailwindV4SourceOptions(sourceOptions, options) {
|
|
609
|
-
return require_v3_engine.omitUndefined({
|
|
610
|
-
projectRoot: sourceOptions.projectRoot,
|
|
611
|
-
baseFallbacks: sourceOptions.baseFallbacks,
|
|
612
|
-
packageName: sourceOptions.packageName,
|
|
613
|
-
base: options.base,
|
|
614
|
-
css: options.css
|
|
615
|
-
});
|
|
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");
|
|
616
602
|
}
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
const
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
...sourceOptions,
|
|
628
|
-
sourceFile: sourceOptions.sourceFile ?? cssEntry
|
|
629
|
-
});
|
|
630
|
-
return withGeneratorSourceMetadata(await require_v3_engine.resolveTailwindV4Source({
|
|
631
|
-
...require_v3_engine.omitUndefined(singleEntrySourceOptions),
|
|
632
|
-
base,
|
|
633
|
-
css: require_v3_engine.normalizeConfigDirective(css, config),
|
|
634
|
-
cssEntries: [cssEntry]
|
|
635
|
-
}), {
|
|
636
|
-
matchedCssSourceFile: cssEntry,
|
|
637
|
-
sourceBase: base,
|
|
638
|
-
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);
|
|
639
613
|
});
|
|
614
|
+
return [...utilities].sort();
|
|
640
615
|
}
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
return node_path.default.dirname(node_path.default.resolve(normalized));
|
|
644
|
-
}
|
|
616
|
+
//#endregion
|
|
617
|
+
//#region src/bundlers/shared/generator-css/source-resolver/config.ts
|
|
645
618
|
function resolveExistingConfigPath(config, configRequest, file, sourceOptions) {
|
|
646
619
|
if (config && (0, node_fs.existsSync)(config)) return config;
|
|
647
620
|
if (!configRequest || node_path.default.isAbsolute(configRequest)) return sourceOptions.config;
|
|
@@ -668,20 +641,8 @@ function resolveExistingConfigPath(config, configRequest, file, sourceOptions) {
|
|
|
668
641
|
for (const candidate of configCandidates) if ((0, node_fs.existsSync)(candidate)) return candidate;
|
|
669
642
|
return sourceOptions.config;
|
|
670
643
|
}
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
if (!from || !node_path.default.isAbsolute(from)) return node_path.default.isAbsolute(file) || Boolean(sourceOptions?.sourceFile) || Boolean(sourceOptions?.cssSources?.length);
|
|
674
|
-
return true;
|
|
675
|
-
}
|
|
676
|
-
function shouldResolveSourceSideCssEntry(rawSource) {
|
|
677
|
-
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);
|
|
678
|
-
}
|
|
679
|
-
function shouldPreferTailwindV3SourceSideEntry(rawSource, sourceSideEntrySource) {
|
|
680
|
-
return Boolean(sourceSideEntrySource) && !require_v3_engine.hasTailwindSourceDirectives(rawSource, { importFallback: true });
|
|
681
|
-
}
|
|
682
|
-
function shouldPreferResolvedSourceSideEntry(cssEntrySource, sourceSideEntrySource) {
|
|
683
|
-
return Boolean(sourceSideEntrySource?.config) && Boolean(cssEntrySource?.configRequest) && (!cssEntrySource?.config || !(0, node_fs.existsSync)(cssEntrySource.config));
|
|
684
|
-
}
|
|
644
|
+
//#endregion
|
|
645
|
+
//#region src/bundlers/shared/generator-css/source-resolver/matching.ts
|
|
685
646
|
function normalizeCssSourceForCompare(css) {
|
|
686
647
|
return require_v3_engine.stripGeneratorPlaceholderMarkers(require_v3_engine.stripTailwindBanners(css)).trim();
|
|
687
648
|
}
|
|
@@ -732,6 +693,107 @@ function scoreTailwindV4CssSourceFileMatch(file, cssSourceFile, sourceOptions) {
|
|
|
732
693
|
else if (sourceBase.endsWith(`/${outputBase}`)) bestScore = Math.max(bestScore, 1e3 + outputBase.length);
|
|
733
694
|
return bestScore;
|
|
734
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
|
+
}
|
|
735
797
|
function resolveMatchingTailwindV4CssEntry(rawSource, file, sourceOptions) {
|
|
736
798
|
const cssEntries = sourceOptions.cssEntries;
|
|
737
799
|
if (!cssEntries?.length) return;
|
|
@@ -909,12 +971,6 @@ async function resolveTailwindV4SourceSideEntrySource(resolvedEntrySource, sourc
|
|
|
909
971
|
css
|
|
910
972
|
})), resolvedEntrySource);
|
|
911
973
|
}
|
|
912
|
-
function withGeneratorSourceMetadata(source, metadata) {
|
|
913
|
-
return {
|
|
914
|
-
...source,
|
|
915
|
-
__weappTailwindcssMeta: metadata
|
|
916
|
-
};
|
|
917
|
-
}
|
|
918
974
|
function resolveTailwindV3SourceEntries(source) {
|
|
919
975
|
if (!("version" in source) || source.version !== 3) return;
|
|
920
976
|
const entries = require_v3_engine.normalizeLegacyContentEntries(source.configObject?.content, source.cwd, { relativeBase: source.config ? node_path.default.dirname(source.config) : source.cwd });
|
|
@@ -924,35 +980,6 @@ function withTailwindV3SourceMetadata(source) {
|
|
|
924
980
|
const sourceEntries = resolveTailwindV3SourceEntries(source);
|
|
925
981
|
return sourceEntries ? withGeneratorSourceMetadata(source, { sourceEntries }) : source;
|
|
926
982
|
}
|
|
927
|
-
function withMatchedSourceSideMetadata(source, resolvedEntrySource) {
|
|
928
|
-
return resolvedEntrySource.file ? withGeneratorSourceMetadata(source, {
|
|
929
|
-
matchedCssSourceFile: resolvedEntrySource.file,
|
|
930
|
-
sourceBase: resolvedEntrySource.base,
|
|
931
|
-
sourceCss: resolvedEntrySource.css
|
|
932
|
-
}) : source;
|
|
933
|
-
}
|
|
934
|
-
function createTailwindV4ApplyReferenceSource(css, sourceOptions) {
|
|
935
|
-
if (!require_v3_engine.hasTailwindApplyDirective(css) || require_v3_engine.hasTailwindRootDirectives(css)) return css;
|
|
936
|
-
const utilities = collectTailwindApplyUtilities(css);
|
|
937
|
-
return [
|
|
938
|
-
`@import "${sourceOptions.packageName ?? "tailwindcss"}" source(none);`,
|
|
939
|
-
utilities.length > 0 ? `@source inline(${JSON.stringify(utilities.join(" "))});` : void 0,
|
|
940
|
-
css
|
|
941
|
-
].filter(Boolean).join("\n");
|
|
942
|
-
}
|
|
943
|
-
function collectTailwindApplyUtilities(css) {
|
|
944
|
-
let root;
|
|
945
|
-
try {
|
|
946
|
-
root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
947
|
-
} catch {
|
|
948
|
-
return [];
|
|
949
|
-
}
|
|
950
|
-
const utilities = /* @__PURE__ */ new Set();
|
|
951
|
-
root.walkAtRules("apply", (rule) => {
|
|
952
|
-
for (const utility of (0, tailwindcss_patch.splitCandidateTokens)(rule.params)) utilities.add(utility);
|
|
953
|
-
});
|
|
954
|
-
return [...utilities].sort();
|
|
955
|
-
}
|
|
956
983
|
async function resolveGeneratorSource(majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions, selectionOptions) {
|
|
957
984
|
const base = resolveCssSourceBase(file, cssHandlerOptions);
|
|
958
985
|
const cssEntrySource = require_v3_engine.resolveCssEntrySource(rawSource, base, {
|
|
@@ -985,15 +1012,19 @@ async function resolveGeneratorSource(majorVersion, runtimeState, rawSource, fil
|
|
|
985
1012
|
css: require_v3_engine.normalizeTailwindV3CssEntrySource(resolvedEntrySource.css),
|
|
986
1013
|
...config ? { config } : {}
|
|
987
1014
|
}));
|
|
1015
|
+
const cssEntrySourceEntries = await require_v3_engine.resolveTailwindConfigEntriesFromCssCached(rawSource, resolvedEntrySource.base);
|
|
1016
|
+
const sourceMetadata = sourceWithMetadata.__weappTailwindcssMeta;
|
|
1017
|
+
const matchedSourceFile = resolvedEntrySource.file ?? sourceSideEntrySource?.file;
|
|
988
1018
|
return withGeneratorSourceMetadata(sourceWithMetadata, {
|
|
989
|
-
...
|
|
990
|
-
matchedCssSourceFile:
|
|
1019
|
+
...sourceMetadata,
|
|
1020
|
+
matchedCssSourceFile: matchedSourceFile,
|
|
1021
|
+
sourceEntries: cssEntrySourceEntries?.entries ?? sourceMetadata?.sourceEntries
|
|
991
1022
|
});
|
|
992
1023
|
}
|
|
993
1024
|
const sourceOptions = tryResolveTailwindV4SourceOptions(runtimeState);
|
|
994
1025
|
const resolvedSourceOptions = sourceOptions ? require_v3_engine.omitUndefined({
|
|
995
1026
|
...sourceOptions,
|
|
996
|
-
sourceFile: resolvePostcssSourceFile(cssHandlerOptions),
|
|
1027
|
+
sourceFile: sourceOptions.sourceFile ?? resolvePostcssSourceFile(cssHandlerOptions),
|
|
997
1028
|
...resolveCssHandlerSourceOptions(cssHandlerOptions),
|
|
998
1029
|
cssEntries: selectionOptions?.cssEntries ?? sourceOptions.cssEntries,
|
|
999
1030
|
cssSources: mergeCssSources(sourceOptions.cssSources, sourceOptions.cssSources?.length ? void 0 : createCssEntrySources(selectionOptions?.cssEntries ?? sourceOptions.cssEntries))
|
|
@@ -1007,17 +1038,18 @@ async function resolveGeneratorSource(majorVersion, runtimeState, rawSource, fil
|
|
|
1007
1038
|
}));
|
|
1008
1039
|
}
|
|
1009
1040
|
const shouldPreferSourceSideEntry = shouldResolveSourceSideCssEntry(rawSource) || Boolean(cssEntrySource?.css.includes("weapp-tailwindcss generator-placeholder")) && (sourceOptions?.cssEntries?.length ?? 0) <= 1;
|
|
1010
|
-
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;
|
|
1011
1042
|
const matchedCssEntrySource = normalizedSourceOptions ? await resolveMatchingTailwindV4CssEntry(rawSource, file, normalizedSourceOptions) : void 0;
|
|
1012
1043
|
const matchedCssSource = normalizedSourceOptions && !matchedCssEntrySource ? await resolveMatchingTailwindV4CssSource(rawSource, file, cssHandlerOptions, normalizedSourceOptions) : void 0;
|
|
1013
1044
|
const candidateMatchedCssSource = normalizedSourceOptions && !matchedCssEntrySource ? await resolveCandidateMatchedTailwindV4CssSource(rawSource, cssHandlerOptions, normalizedSourceOptions, selectionOptions) : void 0;
|
|
1014
|
-
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;
|
|
1015
1047
|
if (configuredCssSource) return generatorOptions?.config ? {
|
|
1016
1048
|
...configuredCssSource,
|
|
1017
1049
|
css: require_v3_engine.prependConfigDirective(configuredCssSource.css, generatorOptions.config)
|
|
1018
1050
|
} : configuredCssSource;
|
|
1019
1051
|
const mainCssEntrySource = normalizedSourceOptions && cssHandlerOptions.isMainChunk && normalizedSourceOptions.cssEntries?.length === 1 ? await resolveTailwindV4CssEntrySource(normalizedSourceOptions.cssEntries[0], normalizedSourceOptions) : void 0;
|
|
1020
|
-
const preferredCssEntrySource = matchedCssEntrySource ?? matchedCssSource ?? candidateMatchedCssSource ?? mainCssEntrySource;
|
|
1052
|
+
const preferredCssEntrySource = matchedCssEntrySource ?? matchedCssSource ?? candidateMatchedCssSource ?? mainCssEntrySource ?? singleConfiguredCssSource;
|
|
1021
1053
|
if (preferredCssEntrySource) return generatorOptions?.config ? {
|
|
1022
1054
|
...preferredCssEntrySource,
|
|
1023
1055
|
css: require_v3_engine.prependConfigDirective(preferredCssEntrySource.css, generatorOptions.config)
|
|
@@ -1057,7 +1089,7 @@ async function resolveGeneratorSources(majorVersion, runtimeState, rawSource, fi
|
|
|
1057
1089
|
sourceFile: resolvePostcssSourceFile(cssHandlerOptions),
|
|
1058
1090
|
...resolveCssHandlerSourceOptions(cssHandlerOptions),
|
|
1059
1091
|
cssEntries,
|
|
1060
|
-
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))
|
|
1061
1093
|
});
|
|
1062
1094
|
} catch {
|
|
1063
1095
|
const resolved = await resolveGeneratorSource(majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions, selectionOptions);
|
|
@@ -1068,7 +1100,7 @@ async function resolveGeneratorSources(majorVersion, runtimeState, rawSource, fi
|
|
|
1068
1100
|
...matchedCssEntrySource,
|
|
1069
1101
|
css: require_v3_engine.prependConfigDirective(matchedCssEntrySource.css, generatorOptions.config)
|
|
1070
1102
|
} : matchedCssEntrySource];
|
|
1071
|
-
const sourceSideCssSource = await resolveTailwindV4SourceSideEntrySource(
|
|
1103
|
+
const sourceSideCssSource = await resolveTailwindV4SourceSideEntrySource(canResolveSourceSideCssEntry(file, cssHandlerOptions, sourceOptions) ? resolveSourceSideCssEntrySource(file, sourceOptions, { removeConfig: false }) : void 0, sourceOptions, generatorOptions, file);
|
|
1072
1104
|
if (sourceSideCssSource) return [sourceSideCssSource];
|
|
1073
1105
|
const matchedCssSource = await resolveMatchingTailwindV4CssSource(rawSource, file, cssHandlerOptions, sourceOptions);
|
|
1074
1106
|
const candidateMatchedCssSource = await resolveCandidateMatchedTailwindV4CssSource(rawSource, cssHandlerOptions, sourceOptions, selectionOptions);
|
|
@@ -1103,6 +1135,10 @@ async function resolveGeneratorSourceEntries(source, runtimeState) {
|
|
|
1103
1135
|
if (sourceMetadata?.sourceEntries) return sourceMetadata.sourceEntries;
|
|
1104
1136
|
if (!("css" in source) || !("base" in source) || !("baseFallbacks" in source)) return;
|
|
1105
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
|
+
}
|
|
1106
1142
|
if (resolved?.entries.length || !resolved?.explicit && !sourceMetadata?.matchedCssSourceFile || !runtimeState) return resolved?.entries;
|
|
1107
1143
|
const matchingCssSource = tryResolveTailwindV4SourceOptions(runtimeState)?.cssSources?.find((cssSource) => {
|
|
1108
1144
|
if (sourceMetadata?.matchedCssSourceFile && typeof cssSource.file === "string" && node_path.default.resolve(cssSource.file) === node_path.default.resolve(sourceMetadata.matchedCssSourceFile)) return true;
|
|
@@ -1526,6 +1562,16 @@ function isCommentOnlyCss(source) {
|
|
|
1526
1562
|
return false;
|
|
1527
1563
|
}
|
|
1528
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
|
+
}
|
|
1529
1575
|
function stripTailwindSourceMediaFragments(source) {
|
|
1530
1576
|
let removedSourceMediaStart = false;
|
|
1531
1577
|
return source.split(/\r?\n/).filter((line) => {
|
|
@@ -1693,7 +1739,7 @@ async function transformGeneratorUserCss(source, options) {
|
|
|
1693
1739
|
if (source.trim().length === 0) return "";
|
|
1694
1740
|
const cleanedSource = require_v3_engine.removeTailwindSourceDirectives(removeTailwindV4GeneratorAtRules(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(source))), { importFallback: options.importFallback });
|
|
1695
1741
|
if (cleanedSource.trim().length === 0) return "";
|
|
1696
|
-
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 })));
|
|
1697
1743
|
if (userSource.trim().length === 0) return "";
|
|
1698
1744
|
if (isCommentOnlyCss(userSource)) return userSource;
|
|
1699
1745
|
if (options.generatorTarget !== "weapp") return userSource;
|
|
@@ -1823,10 +1869,42 @@ function mergeMarkedUserLayerComponentsCss(baseCss, markedCss) {
|
|
|
1823
1869
|
};
|
|
1824
1870
|
}
|
|
1825
1871
|
//#endregion
|
|
1872
|
+
//#region src/bundlers/shared/run-tasks.ts
|
|
1873
|
+
async function runWithConcurrency(factories, limit = Math.min(4, Math.max(1, factories.length))) {
|
|
1874
|
+
if (factories.length === 0) return [];
|
|
1875
|
+
const results = Array.from({ length: factories.length });
|
|
1876
|
+
const executing = /* @__PURE__ */ new Set();
|
|
1877
|
+
let cursor = 0;
|
|
1878
|
+
const effectiveLimit = Math.max(1, limit);
|
|
1879
|
+
const scheduleNext = () => {
|
|
1880
|
+
if (cursor >= factories.length) return;
|
|
1881
|
+
const currentIndex = cursor++;
|
|
1882
|
+
const factory = factories[currentIndex];
|
|
1883
|
+
if (!factory) return;
|
|
1884
|
+
const wrapped = Promise.resolve(factory()).then((value) => {
|
|
1885
|
+
results[currentIndex] = value;
|
|
1886
|
+
}).finally(() => {
|
|
1887
|
+
executing.delete(wrapped);
|
|
1888
|
+
});
|
|
1889
|
+
executing.add(wrapped);
|
|
1890
|
+
};
|
|
1891
|
+
while (cursor < factories.length && executing.size < effectiveLimit) scheduleNext();
|
|
1892
|
+
while (cursor < factories.length) {
|
|
1893
|
+
await Promise.race(executing);
|
|
1894
|
+
scheduleNext();
|
|
1895
|
+
}
|
|
1896
|
+
await Promise.all(executing);
|
|
1897
|
+
return results;
|
|
1898
|
+
}
|
|
1899
|
+
function pushConcurrentTaskFactories(queue, factories, limit) {
|
|
1900
|
+
if (factories.length === 0) return;
|
|
1901
|
+
queue.push(runWithConcurrency(factories, limit).then(() => void 0));
|
|
1902
|
+
}
|
|
1903
|
+
//#endregion
|
|
1826
1904
|
//#region src/bundlers/shared/generator-css/validate.ts
|
|
1827
1905
|
const SUPPORTED_GENERATOR_MAJOR_VERSIONS = new Set([3, 4]);
|
|
1828
1906
|
async function validateCandidatesByGenerator(options) {
|
|
1829
|
-
const { candidates, cssHandlerOptions, debug, file, opts, rawSource, runtimeState } = options;
|
|
1907
|
+
const { candidates, cssHandlerOptions, debug, file, opts, rawSource, runtimeState, skipGenerateFallback } = options;
|
|
1830
1908
|
const majorVersion = runtimeState.twPatcher.majorVersion;
|
|
1831
1909
|
if (!SUPPORTED_GENERATOR_MAJOR_VERSIONS.has(majorVersion ?? 0) || candidates.size === 0) return /* @__PURE__ */ new Set();
|
|
1832
1910
|
const generatorOptions = {
|
|
@@ -1842,6 +1920,7 @@ async function validateCandidatesByGenerator(options) {
|
|
|
1842
1920
|
if (generatorOptions.bareArbitraryValues === void 0 || generatorOptions.bareArbitraryValues === false) {
|
|
1843
1921
|
if (typeof generator.validateCandidates === "function") return generator.validateCandidates(candidates);
|
|
1844
1922
|
}
|
|
1923
|
+
if (skipGenerateFallback) return /* @__PURE__ */ new Set();
|
|
1845
1924
|
return (await generator.generate({
|
|
1846
1925
|
bareArbitraryValues: generatorOptions.bareArbitraryValues,
|
|
1847
1926
|
candidates,
|
|
@@ -1854,6 +1933,11 @@ async function validateCandidatesByGenerator(options) {
|
|
|
1854
1933
|
}
|
|
1855
1934
|
//#endregion
|
|
1856
1935
|
//#region src/bundlers/shared/generator-css.ts
|
|
1936
|
+
function resolveGeneratorSourceConcurrency() {
|
|
1937
|
+
const configured = Number.parseInt(node_process.default.env["WEAPP_TW_GENERATOR_SOURCE_CONCURRENCY"] ?? "", 10);
|
|
1938
|
+
if (Number.isFinite(configured) && configured > 0) return configured;
|
|
1939
|
+
return 1;
|
|
1940
|
+
}
|
|
1857
1941
|
async function generateCssByGenerator(options) {
|
|
1858
1942
|
const { opts, runtimeState, runtime, rawSource, file, cssHandlerOptions, cssUserHandlerOptions, getSourceCandidatesForEntries, styleHandler, debug } = options;
|
|
1859
1943
|
const generatorOptions = {
|
|
@@ -1894,26 +1978,32 @@ async function generateCssByGenerator(options) {
|
|
|
1894
1978
|
const runtimeWithCurrentCss = createRuntimeWithCurrentCssCandidates(runtime, currentCssCandidates, isolateCurrentCssCandidates);
|
|
1895
1979
|
const sources = await resolveGeneratorSources(majorVersion, runtimeState, generatorRawSource, file, cssHandlerOptions, generatorOptions, {
|
|
1896
1980
|
cssEntries: opts.cssEntries,
|
|
1981
|
+
cssSources: options.cssSources,
|
|
1897
1982
|
getSourceCandidatesForEntries,
|
|
1898
1983
|
runtime: runtimeWithCurrentCss
|
|
1899
1984
|
});
|
|
1900
1985
|
const generatorStyleOptions = resolveGeneratorStyleOptions(opts, cssHandlerOptions, generatorOptions.styleOptions);
|
|
1901
1986
|
const configuredContainerCompat = hasConfiguredContainerCompatSources(sources);
|
|
1902
|
-
const
|
|
1987
|
+
const sourceConcurrency = resolveGeneratorSourceConcurrency();
|
|
1988
|
+
const generated = mergeGeneratorResults((await runWithConcurrency(sources.map((source) => async () => {
|
|
1903
1989
|
const generator = require_generator.createWeappTailwindcssGenerator(source);
|
|
1904
1990
|
const sourceEntries = getSourceCandidatesForEntries && (majorVersion === 3 || majorVersion === 4) ? await resolveGeneratorSourceEntries(source, runtimeState) : void 0;
|
|
1905
|
-
const scopedRuntime = sourceEntries ? getSourceCandidatesForEntries?.(sourceEntries) : void 0;
|
|
1906
|
-
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
|
+
});
|
|
1907
1996
|
const sourceMetadata = source.__weappTailwindcssMeta;
|
|
1908
1997
|
const matchedCssSourceFile = Boolean(sourceMetadata?.matchedCssSourceFile);
|
|
1909
1998
|
if (options.deferEmptyScopedCssSource && isolateCssSource && scopedRuntime?.size === 0 && currentCssCandidates.length === 0 && !cssHandlerOptions.isMainChunk) {
|
|
1910
1999
|
debug("defer empty scoped css source generation: %s", file);
|
|
1911
2000
|
return;
|
|
1912
2001
|
}
|
|
1913
|
-
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, {
|
|
1914
2003
|
currentCssCandidates,
|
|
1915
2004
|
cssHandlerOptions,
|
|
1916
2005
|
isolateCssSource,
|
|
2006
|
+
majorVersion,
|
|
1917
2007
|
matchedCssSourceFile
|
|
1918
2008
|
}) : runtimeWithCurrentCss;
|
|
1919
2009
|
const generatorRuntime = majorVersion === 4 && generatorOptions.target === "weapp" ? require_v3_engine.filterUnsupportedMiniProgramTailwindV4Candidates(sourceRuntime) : sourceRuntime;
|
|
@@ -1927,13 +2017,16 @@ async function generateCssByGenerator(options) {
|
|
|
1927
2017
|
tailwindcssV3Compatibility: generatorOptions.tailwindcssV3Compatibility,
|
|
1928
2018
|
target: generatorOptions.target
|
|
1929
2019
|
});
|
|
1930
|
-
}))).filter((item) => Boolean(item)));
|
|
2020
|
+
}), sourceConcurrency)).filter((item) => Boolean(item)));
|
|
1931
2021
|
if (!generated) return;
|
|
1932
2022
|
debug("tailwind generator result: %s rawBytes=%d cssBytes=%d candidates=%d", file, generated.rawCss.length, generated.css.length, generated.classSet.size);
|
|
1933
2023
|
if ((generated.target !== "weapp" || !hasUserCssLayerBlocks(generatorRawSource)) && typeof options.previousCss === "string" && typeof generated.incrementalCss === "string") {
|
|
1934
2024
|
const incrementalCss = require_v3_engine.stripTailwindBanner(generated.incrementalCss);
|
|
1935
2025
|
return {
|
|
1936
|
-
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),
|
|
1937
2030
|
target: generated.target,
|
|
1938
2031
|
source: "generator",
|
|
1939
2032
|
dependencies: generated.dependencies,
|
|
@@ -1965,7 +2058,8 @@ async function generateCssByGenerator(options) {
|
|
|
1965
2058
|
const beforeUserCss = await transformGeneratorUserCss(orderedExtraCss.before, userCssOptions);
|
|
1966
2059
|
const afterLayerUserCss = await transformGeneratorUserCss(afterLayerParts.layer, userCssOptions);
|
|
1967
2060
|
const afterUserCss = await transformGeneratorUserCss(afterLayerParts.rest, userCssOptions);
|
|
1968
|
-
|
|
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);
|
|
1969
2063
|
if (isEmptyCssSourceOrderParts(orderedExtraCss) && shouldAppendWebBundleCssFallback(generated.target, {
|
|
1970
2064
|
hasSourceDirectives,
|
|
1971
2065
|
hasMatchedCssSourceFile
|
|
@@ -1981,11 +2075,14 @@ async function generateCssByGenerator(options) {
|
|
|
1981
2075
|
}
|
|
1982
2076
|
} else if (generated.target === "weapp" && shouldFinalizeMarkedUserLayerComponentsCss(file)) css = reorderMarkedUserLayerComponentsCss(css);
|
|
1983
2077
|
return {
|
|
1984
|
-
css: restoreLocalCssImports(finalizeMiniProgramGeneratorCss(css, generated.target, majorVersion, opts.cssPreflight, {
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
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),
|
|
1989
2086
|
target: generated.target,
|
|
1990
2087
|
source: "generator",
|
|
1991
2088
|
dependencies: generated.dependencies
|
|
@@ -2024,6 +2121,18 @@ async function generateCssByGenerator(options) {
|
|
|
2024
2121
|
importFallback: generatorOptions.importFallback
|
|
2025
2122
|
});
|
|
2026
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
|
+
}
|
|
2027
2136
|
}
|
|
2028
2137
|
if (hasMatchedCssSourceFile && generated.target === "weapp") {
|
|
2029
2138
|
if (!isolateCurrentCssCandidates && !shouldFilterApplyOnlyCss) css = await appendLegacyContainerCompatCss(css, userCssRawSource, file, runtime, configuredContainerCompat, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions);
|
|
@@ -2042,11 +2151,14 @@ async function generateCssByGenerator(options) {
|
|
|
2042
2151
|
css = createCssSourceOrderAppend$1(css, userCss);
|
|
2043
2152
|
}
|
|
2044
2153
|
return {
|
|
2045
|
-
css: restoreLocalCssImports(finalizeMiniProgramGeneratorCss(css, generated.target, majorVersion, opts.cssPreflight, {
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
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),
|
|
2050
2162
|
target: generated.target,
|
|
2051
2163
|
source: "generator",
|
|
2052
2164
|
dependencies: generated.dependencies
|
|
@@ -2057,11 +2169,14 @@ async function generateCssByGenerator(options) {
|
|
|
2057
2169
|
css = await appendLegacyContainerCompatCss(css, userCssRawSource, file, runtime, configuredContainerCompat, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions);
|
|
2058
2170
|
}
|
|
2059
2171
|
return {
|
|
2060
|
-
css: restoreLocalCssImports(finalizeMiniProgramGeneratorCss(css, generated.target, majorVersion, opts.cssPreflight, {
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
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),
|
|
2065
2180
|
target: generated.target,
|
|
2066
2181
|
source: "generator",
|
|
2067
2182
|
dependencies: generated.dependencies
|
|
@@ -2331,7 +2446,7 @@ function createHighConfidenceLiteralRanges(source, matches) {
|
|
|
2331
2446
|
for (const match of matches) {
|
|
2332
2447
|
const candidate = match?.rawCandidate;
|
|
2333
2448
|
if (typeof candidate !== "string" || !isHighConfidenceV3Candidate(candidate)) continue;
|
|
2334
|
-
const range = resolveQuotedLiteralRange(source, match
|
|
2449
|
+
const range = resolveQuotedLiteralRange(source, match?.start ?? source.indexOf(candidate));
|
|
2335
2450
|
if (range) ranges.push(range);
|
|
2336
2451
|
}
|
|
2337
2452
|
return ranges;
|
|
@@ -2633,39 +2748,6 @@ const SCRIPT_SOURCE_CANDIDATE_EXTENSIONS = new Set([
|
|
|
2633
2748
|
"mts",
|
|
2634
2749
|
"cts"
|
|
2635
2750
|
]);
|
|
2636
|
-
const CLASS_LIKE_NAME_RE = /class/i;
|
|
2637
|
-
function getPropertyName(node) {
|
|
2638
|
-
if (!node) return;
|
|
2639
|
-
if (node.type === "Identifier") return node.name;
|
|
2640
|
-
if (node.type === "StringLiteral") return node.value;
|
|
2641
|
-
}
|
|
2642
|
-
function isClassLikeStringPath(path) {
|
|
2643
|
-
const parent = path.parentPath;
|
|
2644
|
-
if (!parent) return false;
|
|
2645
|
-
if (parent.isVariableDeclarator?.()) return CLASS_LIKE_NAME_RE.test(getPropertyName(parent.node.id) ?? "");
|
|
2646
|
-
if (parent.isObjectProperty?.() || parent.isObjectMethod?.()) return CLASS_LIKE_NAME_RE.test(getPropertyName(parent.node.key) ?? "");
|
|
2647
|
-
if (parent.isAssignmentExpression?.()) {
|
|
2648
|
-
const left = parent.node.left;
|
|
2649
|
-
if (left?.type === "Identifier") return CLASS_LIKE_NAME_RE.test(left.name);
|
|
2650
|
-
if (left?.type === "MemberExpression") return CLASS_LIKE_NAME_RE.test(getPropertyName(left.property) ?? "");
|
|
2651
|
-
}
|
|
2652
|
-
if (parent.isJSXAttribute?.()) return CLASS_LIKE_NAME_RE.test(getPropertyName(parent.node.name) ?? "");
|
|
2653
|
-
return false;
|
|
2654
|
-
}
|
|
2655
|
-
function isTemplateElementInClassLikePath(path) {
|
|
2656
|
-
const templateLiteralPath = path.parentPath;
|
|
2657
|
-
if (!templateLiteralPath?.isTemplateLiteral?.()) return false;
|
|
2658
|
-
const parent = templateLiteralPath.parentPath;
|
|
2659
|
-
if (!parent) return false;
|
|
2660
|
-
if (parent.isVariableDeclarator?.()) return CLASS_LIKE_NAME_RE.test(getPropertyName(parent.node.id) ?? "");
|
|
2661
|
-
if (parent.isObjectProperty?.() || parent.isObjectMethod?.()) return CLASS_LIKE_NAME_RE.test(getPropertyName(parent.node.key) ?? "");
|
|
2662
|
-
if (parent.isAssignmentExpression?.()) {
|
|
2663
|
-
const left = parent.node.left;
|
|
2664
|
-
if (left?.type === "Identifier") return CLASS_LIKE_NAME_RE.test(left.name);
|
|
2665
|
-
if (left?.type === "MemberExpression") return CLASS_LIKE_NAME_RE.test(getPropertyName(left.property) ?? "");
|
|
2666
|
-
}
|
|
2667
|
-
return false;
|
|
2668
|
-
}
|
|
2669
2751
|
async function extractScriptStringCandidates(source, extension, options) {
|
|
2670
2752
|
if (!SCRIPT_SOURCE_CANDIDATE_EXTENSIONS.has(extension)) return [];
|
|
2671
2753
|
const values = /* @__PURE__ */ new Set();
|
|
@@ -2678,10 +2760,10 @@ async function extractScriptStringCandidates(source, extension, options) {
|
|
|
2678
2760
|
}), {
|
|
2679
2761
|
noScope: true,
|
|
2680
2762
|
StringLiteral(path) {
|
|
2681
|
-
|
|
2763
|
+
values.add(path.node.value);
|
|
2682
2764
|
},
|
|
2683
2765
|
TemplateElement(path) {
|
|
2684
|
-
|
|
2766
|
+
values.add(path.node.value.raw);
|
|
2685
2767
|
}
|
|
2686
2768
|
});
|
|
2687
2769
|
} catch {
|
|
@@ -2727,7 +2809,7 @@ function createTailwindV3DefaultExtractor() {
|
|
|
2727
2809
|
//#endregion
|
|
2728
2810
|
//#region src/bundlers/vite/source-candidates.ts
|
|
2729
2811
|
const CLEAN_URL_RE = /[?#].*$/;
|
|
2730
|
-
const sourceCandidateContentCache =
|
|
2812
|
+
const sourceCandidateContentCache = new lru_cache.LRUCache({ max: 128 });
|
|
2731
2813
|
function cleanUrl(id) {
|
|
2732
2814
|
return require_v3_engine.resolveSourceScanPath(id.replace(CLEAN_URL_RE, ""));
|
|
2733
2815
|
}
|
|
@@ -2736,7 +2818,7 @@ function resolveSourceCandidateExtension(id) {
|
|
|
2736
2818
|
return /\.([^.\\/]+)$/.exec(normalized)?.[1] ?? "html";
|
|
2737
2819
|
}
|
|
2738
2820
|
function createSourceCandidateContentCacheKey(extension, source, bareArbitraryValues, extractor) {
|
|
2739
|
-
return `${extension}\0${JSON.stringify(bareArbitraryValues ?? false)}\0${extractor ? "custom" : "default"}\0${source}`;
|
|
2821
|
+
return `${extension}\0${JSON.stringify(bareArbitraryValues ?? false)}\0${extractor ? "custom" : "default"}\0${(0, _weapp_tailwindcss_shared_node.md5)(source)}`;
|
|
2740
2822
|
}
|
|
2741
2823
|
async function extractCandidates(source, extension, options) {
|
|
2742
2824
|
const candidates = options.extractor ? new Set(await options.extractor(source, extension)) : new Set(await (0, tailwindcss_patch.extractSourceCandidates)(source, extension, { ...options.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: options.bareArbitraryValues } }));
|
|
@@ -2786,6 +2868,7 @@ function createSourceCandidateCollector(options = {}) {
|
|
|
2786
2868
|
}
|
|
2787
2869
|
async function syncCss(id, source) {
|
|
2788
2870
|
const normalizedId = cleanUrl(id);
|
|
2871
|
+
sourceById.set(normalizedId, source);
|
|
2789
2872
|
const contentCacheKey = createSourceCandidateContentCacheKey("css", source, options.bareArbitraryValues, options.extractor);
|
|
2790
2873
|
const cachedCandidates = sourceCandidateContentCache.get(contentCacheKey);
|
|
2791
2874
|
if (cachedCandidates) {
|
|
@@ -2798,6 +2881,7 @@ function createSourceCandidateCollector(options = {}) {
|
|
|
2798
2881
|
}
|
|
2799
2882
|
async function merge(id, source) {
|
|
2800
2883
|
const normalizedId = cleanUrl(id);
|
|
2884
|
+
sourceById.set(normalizedId, source);
|
|
2801
2885
|
const extension = resolveSourceCandidateExtension(normalizedId);
|
|
2802
2886
|
const contentCacheKey = createSourceCandidateContentCacheKey(extension, source, options.bareArbitraryValues, options.extractor);
|
|
2803
2887
|
const cachedCandidates = sourceCandidateContentCache.get(contentCacheKey);
|
|
@@ -2807,11 +2891,20 @@ function createSourceCandidateCollector(options = {}) {
|
|
|
2807
2891
|
}
|
|
2808
2892
|
async function syncFile(id) {
|
|
2809
2893
|
const normalizedId = cleanUrl(id);
|
|
2810
|
-
|
|
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
|
+
}
|
|
2811
2903
|
}
|
|
2812
2904
|
async function syncCurrentFile(id) {
|
|
2813
2905
|
const normalizedId = cleanUrl(id);
|
|
2814
2906
|
transformCandidatesById.delete(normalizedId);
|
|
2907
|
+
cssCandidatesById.delete(normalizedId);
|
|
2815
2908
|
await syncFile(normalizedId);
|
|
2816
2909
|
}
|
|
2817
2910
|
async function scanRoot({ entries, explicit, root, outDir }) {
|
|
@@ -2879,6 +2972,9 @@ function createSourceCandidateCollector(options = {}) {
|
|
|
2879
2972
|
function source(id) {
|
|
2880
2973
|
return sourceById.get(cleanUrl(id));
|
|
2881
2974
|
}
|
|
2975
|
+
function sources() {
|
|
2976
|
+
return sourceById.entries();
|
|
2977
|
+
}
|
|
2882
2978
|
function values() {
|
|
2883
2979
|
const values = new Set([...candidateCount.keys(), ...inlineIncludedCandidates]);
|
|
2884
2980
|
for (const candidate of inlineExcludedCandidates) values.delete(candidate);
|
|
@@ -2888,6 +2984,7 @@ function createSourceCandidateCollector(options = {}) {
|
|
|
2888
2984
|
if (entries === void 0) {
|
|
2889
2985
|
if (!options.excludeEntries?.length) return values();
|
|
2890
2986
|
}
|
|
2987
|
+
if (entries?.length === 0) return new Set(inlineIncludedCandidates);
|
|
2891
2988
|
const filtered = /* @__PURE__ */ new Set();
|
|
2892
2989
|
for (const [id, candidates] of candidatesById) {
|
|
2893
2990
|
if (entries !== void 0 && !require_v3_engine.isFileMatchedByTailwindSourceEntries(id, entries)) continue;
|
|
@@ -2908,6 +3005,11 @@ function createSourceCandidateCollector(options = {}) {
|
|
|
2908
3005
|
}
|
|
2909
3006
|
if (id) candidateSources.add(id);
|
|
2910
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
|
+
}
|
|
2911
3013
|
for (const [id, candidates] of candidatesById) {
|
|
2912
3014
|
if (entries !== void 0 && !require_v3_engine.isFileMatchedByTailwindSourceEntries(id, entries)) continue;
|
|
2913
3015
|
if (options.excludeEntries?.length && require_v3_engine.isFileMatchedByTailwindSourceEntries(id, options.excludeEntries)) continue;
|
|
@@ -2927,6 +3029,18 @@ function createSourceCandidateCollector(options = {}) {
|
|
|
2927
3029
|
inlineIncludedCandidates.clear();
|
|
2928
3030
|
inlineExcludedCandidates.clear();
|
|
2929
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
|
+
}
|
|
2930
3044
|
function snapshot() {
|
|
2931
3045
|
return {
|
|
2932
3046
|
candidatesById: [...candidatesById.entries()].map(([id, candidates]) => [id, [...candidates]]),
|
|
@@ -2958,13 +3072,13 @@ function createSourceCandidateCollector(options = {}) {
|
|
|
2958
3072
|
if (candidateSet.size === 0) continue;
|
|
2959
3073
|
cssCandidatesById.set(id, candidateSet);
|
|
2960
3074
|
}
|
|
2961
|
-
for (const [id, candidates] of snapshot.candidatesById) {
|
|
2962
|
-
const candidateSet = new Set(candidates);
|
|
2963
|
-
if (candidateSet.size === 0) continue;
|
|
2964
|
-
candidatesById.set(id, candidateSet);
|
|
2965
|
-
addCandidateSet(candidateCount, candidateSet);
|
|
2966
|
-
}
|
|
2967
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);
|
|
2968
3082
|
}
|
|
2969
3083
|
return {
|
|
2970
3084
|
sync,
|
|
@@ -2976,11 +3090,14 @@ function createSourceCandidateCollector(options = {}) {
|
|
|
2976
3090
|
syncInline,
|
|
2977
3091
|
remove,
|
|
2978
3092
|
source,
|
|
3093
|
+
sources,
|
|
2979
3094
|
values,
|
|
2980
3095
|
valuesForEntries,
|
|
2981
3096
|
sourcesForEntries,
|
|
2982
3097
|
snapshot,
|
|
2983
3098
|
restore,
|
|
3099
|
+
clearScan,
|
|
3100
|
+
resetScan,
|
|
2984
3101
|
clear
|
|
2985
3102
|
};
|
|
2986
3103
|
}
|
|
@@ -3153,6 +3270,18 @@ Object.defineProperty(exports, "processCachedTask", {
|
|
|
3153
3270
|
return processCachedTask;
|
|
3154
3271
|
}
|
|
3155
3272
|
});
|
|
3273
|
+
Object.defineProperty(exports, "pushConcurrentTaskFactories", {
|
|
3274
|
+
enumerable: true,
|
|
3275
|
+
get: function() {
|
|
3276
|
+
return pushConcurrentTaskFactories;
|
|
3277
|
+
}
|
|
3278
|
+
});
|
|
3279
|
+
Object.defineProperty(exports, "runWithConcurrency", {
|
|
3280
|
+
enumerable: true,
|
|
3281
|
+
get: function() {
|
|
3282
|
+
return runWithConcurrency;
|
|
3283
|
+
}
|
|
3284
|
+
});
|
|
3156
3285
|
Object.defineProperty(exports, "validateCandidatesByGenerator", {
|
|
3157
3286
|
enumerable: true,
|
|
3158
3287
|
get: function() {
|