weapp-tailwindcss 5.3.5 → 5.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/README.zh-CN.md +4 -4
- package/dist/bundlers/shared/framework-postcss.d.ts +3 -0
- package/dist/bundlers/shared/generator-css/result-helpers.d.ts +1 -1
- package/dist/bundlers/shared/generator-css/source-resolver/single-source.d.ts +1 -1
- package/dist/bundlers/shared/generator-css/types.d.ts +3 -1
- package/dist/bundlers/shared/source-candidates/snapshot.d.ts +19 -0
- package/dist/bundlers/shared/source-candidates/source-priority.d.ts +1 -0
- package/dist/bundlers/shared/source-candidates/types-and-cache.d.ts +1 -0
- package/dist/bundlers/shared/source-candidates/views.d.ts +12 -0
- package/dist/bundlers/shared/style-requests.d.ts +1 -0
- package/dist/bundlers/vite/bundle-state.d.ts +9 -1
- package/dist/bundlers/vite/capability-profile.d.ts +18 -0
- package/dist/bundlers/vite/generate-bundle/js-processing.d.ts +12 -0
- package/dist/bundlers/vite/hot-css-modules.d.ts +2 -2
- package/dist/bundlers/vite/shared/configured-css-entry-observer.d.ts +29 -0
- package/dist/bundlers/vite/shared/create-framework-plugins.d.ts +8 -0
- package/dist/bundlers/vite/shared/framework-css-generation-queue.d.ts +1 -0
- package/dist/bundlers/vite/shared/framework-hmr-module-version.d.ts +9 -0
- package/dist/bundlers/vite/shared/framework-runtime-utils.d.ts +5 -0
- package/dist/bundlers/vite/shared/framework-source-scan-session.d.ts +12 -2
- package/dist/compiler/compilation-session-pool.d.ts +1 -0
- package/dist/compiler/framework-compiler-session.d.ts +21 -0
- package/dist/compiler/index.d.ts +1 -0
- package/dist/{context-DTLRADfE.cjs → compiler-C93NfxSe.cjs} +859 -11
- package/dist/{context-4ittVpgt.js → compiler-qDa3phIv.js} +764 -5
- package/dist/context/handlers.d.ts +1 -1
- package/dist/core/compiler/compiler.d.ts +2 -0
- package/dist/core/compiler/generation-cache.d.ts +30 -0
- package/dist/core/compiler/generation-state.d.ts +17 -0
- package/dist/core/compiler/index.d.ts +2 -0
- package/dist/core/compiler/root-store.d.ts +38 -0
- package/dist/core/compiler/snapshot.d.ts +35 -0
- package/dist/core/compiler/source-fingerprint.d.ts +3 -0
- package/dist/core/compiler/transforms.d.ts +15 -0
- package/dist/core/compiler/types.d.ts +69 -0
- package/dist/core.cjs +9 -8
- package/dist/core.d.ts +2 -1
- package/dist/core.js +2 -2
- package/dist/framework/index.d.ts +3 -1
- package/dist/framework.cjs +6 -1
- package/dist/framework.js +6 -1
- package/dist/{generator-EnTXLBlK.js → generator-C0m2S4WI.js} +3 -2
- package/dist/{generator-DKiYbTFR.cjs → generator-CKJ6sj1f.cjs} +3 -2
- package/dist/generator.cjs +1 -1
- package/dist/generator.js +1 -1
- package/dist/{gulp-CUysZjW3.cjs → gulp-CW6JGqVn.cjs} +14 -16
- package/dist/{gulp-DwtrU4V1.js → gulp-e2iWsmEK.js} +7 -7
- package/dist/gulp.cjs +1 -1
- package/dist/gulp.js +1 -1
- package/dist/{hmr-timing-utmOgn6p.js → hmr-timing-DgMgwSce.js} +367 -289
- package/dist/{hmr-timing-Cvh5UgnM.cjs → hmr-timing-n7QQKFp7.cjs} +4 -4
- package/dist/index.cjs +4 -4
- package/dist/index.js +4 -4
- package/dist/{pipeline-helpers-CyVXL3h6.cjs → pipeline-helpers-DoLQy44Q.cjs} +6 -6
- package/dist/postcss.cjs +1 -1
- package/dist/postcss.js +1 -1
- package/dist/presets.cjs +2 -3
- package/dist/presets.js +1 -1
- package/dist/rspack.cjs +2 -2
- package/dist/rspack.js +2 -2
- package/dist/{source-candidate-scan-signature-CDrLxVKu.js → source-candidate-scan-signature-B0lOMiwB.js} +3 -3
- package/dist/{source-candidate-scan-signature-BNt7NrrI.cjs → source-candidate-scan-signature-Chb-Zrwt.cjs} +5 -5
- package/dist/{tailwindcss-CexDJBhx.cjs → tailwindcss-BGlJ1m1l.cjs} +763 -5
- package/dist/{tailwindcss-ChnpCv25.js → tailwindcss-BSKl0FTD.js} +1 -1
- package/dist/{transform-AfnwH_yx.cjs → transform-C6k9zTQR.cjs} +16 -7
- package/dist/{transform-BMPNt_vj.js → transform-DQhgAarN.js} +16 -7
- package/dist/typedoc.export.d.ts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/uni-app-x/component-local-style.d.ts +2 -0
- package/dist/uni-app-x/transform.d.ts +1 -0
- package/dist/uni-app-x/vite/asset-task.d.ts +21 -0
- package/dist/uni-app-x/vite/plugin-options.d.ts +8 -0
- package/dist/uni-app-x/vite/web-local-style.d.ts +2 -1
- package/dist/uni-app-x/vite.d.ts +1 -21
- package/dist/{v4-generation-core-Dhsu9Deu.cjs → v4-generation-core-B2sUkkgq.cjs} +378 -300
- package/dist/{vite-qxEVovZD.cjs → vite-B0IPgrvM.cjs} +807 -200
- package/dist/{vite-mWyHvLB0.js → vite-CcEb2SOl.js} +774 -165
- package/dist/vite.cjs +1 -1
- package/dist/vite.js +1 -1
- package/dist/weapp-tw-css-generation-loader.cjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.cjs +7 -7
- package/dist/{webpack-Cpy_yggg.cjs → webpack-B5vc13U_.cjs} +33 -35
- package/dist/{webpack-CzhrD9p3.js → webpack-BPA5I79o.js} +7 -7
- package/dist/webpack.cjs +1 -1
- package/dist/webpack.js +1 -1
- package/dist/wxml/utils.d.ts +1 -1
- package/dist/{wxml-B7OAVpXJ.js → wxml-CvKyV69S.js} +10 -2
- package/dist/{wxml-PrK-8ARX.cjs → wxml-o-CUulAM.cjs} +40 -32
- package/package.json +12 -11
- package/dist/options-BJrtIQbH.cjs +0 -768
- package/dist/style-options-DW30H5PV.cjs +0 -82
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-Ctb5zv51.cjs");
|
|
2
|
-
const require_generator = require("./generator-
|
|
2
|
+
const require_generator = require("./generator-CKJ6sj1f.cjs");
|
|
3
3
|
require("./auto-DtU6f3X6.cjs");
|
|
4
4
|
const require_object = require("./object-DbHtAXRk.cjs");
|
|
5
|
-
const
|
|
6
|
-
const require_wxml = require("./wxml-
|
|
7
|
-
const
|
|
5
|
+
const require_tailwindcss = require("./tailwindcss-BGlJ1m1l.cjs");
|
|
6
|
+
const require_wxml = require("./wxml-o-CUulAM.cjs");
|
|
7
|
+
const require_compiler = require("./compiler-C93NfxSe.cjs");
|
|
8
8
|
let node_fs = require("node:fs");
|
|
9
9
|
let node_path = require("node:path");
|
|
10
10
|
node_path = require_rolldown_runtime.__toESM(node_path, 1);
|
|
@@ -15,6 +15,7 @@ let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
|
|
|
15
15
|
let lru_cache = require("lru-cache");
|
|
16
16
|
let node_fs_promises = require("node:fs/promises");
|
|
17
17
|
let _weapp_core_escape = require("@weapp-core/escape");
|
|
18
|
+
let node_buffer = require("node:buffer");
|
|
18
19
|
let _weapp_tailwindcss_shared_node = require("@weapp-tailwindcss/shared/node");
|
|
19
20
|
//#region src/bundlers/shared/source-candidates/scan-root.ts
|
|
20
21
|
const TAILWIND_V4_IGNORED_CONTENT_DIRS = [
|
|
@@ -146,6 +147,62 @@ function resolveSourceCandidateScanFiles(options) {
|
|
|
146
147
|
});
|
|
147
148
|
}
|
|
148
149
|
//#endregion
|
|
150
|
+
//#region src/bundlers/shared/source-candidates/source-priority.ts
|
|
151
|
+
function mergeSourcesByPriority(moduleSourceById, transformSourceById, cssSourceById, scanSourceById) {
|
|
152
|
+
const sources = /* @__PURE__ */ new Map();
|
|
153
|
+
for (const [id, source] of moduleSourceById) sources.set(id, source);
|
|
154
|
+
for (const [id, source] of transformSourceById) sources.set(id, source);
|
|
155
|
+
for (const [id, source] of cssSourceById) sources.set(id, source);
|
|
156
|
+
for (const [id, source] of scanSourceById) sources.set(id, source);
|
|
157
|
+
return sources;
|
|
158
|
+
}
|
|
159
|
+
//#endregion
|
|
160
|
+
//#region src/bundlers/shared/source-candidates/snapshot.ts
|
|
161
|
+
function createCandidateSnapshot(maps) {
|
|
162
|
+
return {
|
|
163
|
+
candidatesById: [...maps.candidatesById.entries()].map(([id, candidates]) => [id, [...candidates]]),
|
|
164
|
+
cssCandidatesById: [...maps.cssCandidatesById.entries()].map(([id, candidates]) => [id, [...candidates]]),
|
|
165
|
+
cssSourceById: [...maps.cssSourceById.entries()],
|
|
166
|
+
moduleCandidatesById: [...maps.moduleCandidatesById.entries()].map(([id, candidates]) => [id, [...candidates]]),
|
|
167
|
+
moduleSourceById: [...maps.moduleSourceById.entries()],
|
|
168
|
+
scanCandidatesById: [...maps.scanCandidatesById.entries()].map(([id, candidates]) => [id, [...candidates]]),
|
|
169
|
+
scanSourceById: [...maps.scanSourceById.entries()],
|
|
170
|
+
sourceById: [...mergeSourcesByPriority(maps.moduleSourceById, maps.transformSourceById, maps.cssSourceById, maps.scanSourceById).entries()],
|
|
171
|
+
transformCandidatesById: [...maps.transformCandidatesById.entries()].map(([id, candidates]) => [id, [...candidates]]),
|
|
172
|
+
transformSourceById: [...maps.transformSourceById.entries()],
|
|
173
|
+
inlineExcludedCandidates: [...maps.inlineExcludedCandidates],
|
|
174
|
+
inlineIncludedCandidates: [...maps.inlineIncludedCandidates]
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
function restoreCandidateSnapshot(maps, snapshot, clear, recompute, setInlineCandidates) {
|
|
178
|
+
clear();
|
|
179
|
+
setInlineCandidates(new Set(snapshot.inlineIncludedCandidates), new Set(snapshot.inlineExcludedCandidates));
|
|
180
|
+
const restoreCandidates = (target, entries) => {
|
|
181
|
+
for (const [id, candidates] of entries ?? []) {
|
|
182
|
+
const candidateSet = new Set(candidates);
|
|
183
|
+
if (candidateSet.size > 0) target.set(id, candidateSet);
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
restoreCandidates(maps.scanCandidatesById, snapshot.scanCandidatesById ?? snapshot.candidatesById);
|
|
187
|
+
restoreCandidates(maps.transformCandidatesById, snapshot.transformCandidatesById);
|
|
188
|
+
restoreCandidates(maps.cssCandidatesById, snapshot.cssCandidatesById);
|
|
189
|
+
restoreCandidates(maps.moduleCandidatesById, snapshot.moduleCandidatesById);
|
|
190
|
+
const restoreSources = (target, entries) => {
|
|
191
|
+
for (const [id, source] of entries ?? []) target.set(id, source);
|
|
192
|
+
};
|
|
193
|
+
restoreSources(maps.scanSourceById, snapshot.scanSourceById ?? snapshot.sourceById);
|
|
194
|
+
restoreSources(maps.transformSourceById, snapshot.transformSourceById);
|
|
195
|
+
restoreSources(maps.cssSourceById, snapshot.cssSourceById);
|
|
196
|
+
restoreSources(maps.moduleSourceById, snapshot.moduleSourceById);
|
|
197
|
+
const ids = /* @__PURE__ */ new Set([
|
|
198
|
+
...maps.scanCandidatesById.keys(),
|
|
199
|
+
...maps.transformCandidatesById.keys(),
|
|
200
|
+
...maps.cssCandidatesById.keys(),
|
|
201
|
+
...maps.moduleCandidatesById.keys()
|
|
202
|
+
]);
|
|
203
|
+
for (const id of ids) recompute(id);
|
|
204
|
+
}
|
|
205
|
+
//#endregion
|
|
149
206
|
//#region src/tailwindcss/candidates.ts
|
|
150
207
|
const SCRIPT_SOURCE_CANDIDATE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
151
208
|
"js",
|
|
@@ -306,7 +363,53 @@ function diffCandidateSets(previous, next) {
|
|
|
306
363
|
};
|
|
307
364
|
}
|
|
308
365
|
//#endregion
|
|
366
|
+
//#region src/bundlers/shared/source-candidates/views.ts
|
|
367
|
+
function isIncludedFile(id, isActiveModule, entries, excludeEntries) {
|
|
368
|
+
if (entries !== void 0 && (isActiveModule ? require_generator.isFileExcludedByTailwindSourceEntries(id, entries) : entries.length === 0 || !require_generator.isFileMatchedByTailwindSourceEntries(id, entries))) return false;
|
|
369
|
+
return !(excludeEntries?.length && require_generator.isFileMatchedByTailwindSourceEntries(id, excludeEntries));
|
|
370
|
+
}
|
|
371
|
+
function collectCandidateValues(view, entries, excludeEntries) {
|
|
372
|
+
if (entries === void 0 && !excludeEntries?.length) {
|
|
373
|
+
const values = new Set(view.candidateCount.keys());
|
|
374
|
+
for (const candidate of view.inlineIncludedCandidates) values.add(candidate);
|
|
375
|
+
for (const candidate of view.inlineExcludedCandidates) values.delete(candidate);
|
|
376
|
+
return values;
|
|
377
|
+
}
|
|
378
|
+
const filtered = /* @__PURE__ */ new Set();
|
|
379
|
+
for (const [id, candidates] of view.candidatesById) {
|
|
380
|
+
if (!isIncludedFile(id, view.moduleCandidatesById.has(id), entries, excludeEntries)) continue;
|
|
381
|
+
for (const candidate of candidates) filtered.add(candidate);
|
|
382
|
+
}
|
|
383
|
+
for (const candidate of view.inlineIncludedCandidates) filtered.add(candidate);
|
|
384
|
+
for (const candidate of view.inlineExcludedCandidates) filtered.delete(candidate);
|
|
385
|
+
return filtered;
|
|
386
|
+
}
|
|
387
|
+
function collectCandidateSources(view, entries, excludeEntries) {
|
|
388
|
+
const sources = /* @__PURE__ */ new Map();
|
|
389
|
+
const addCandidateSource = (candidate, id) => {
|
|
390
|
+
let candidateSources = sources.get(candidate);
|
|
391
|
+
if (!candidateSources) {
|
|
392
|
+
candidateSources = /* @__PURE__ */ new Set();
|
|
393
|
+
sources.set(candidate, candidateSources);
|
|
394
|
+
}
|
|
395
|
+
if (id) candidateSources.add(id);
|
|
396
|
+
};
|
|
397
|
+
for (const [id, candidates] of view.candidatesById) {
|
|
398
|
+
if (!isIncludedFile(id, view.moduleCandidatesById.has(id), entries, excludeEntries)) continue;
|
|
399
|
+
for (const candidate of candidates) addCandidateSource(candidate, id);
|
|
400
|
+
}
|
|
401
|
+
for (const candidate of view.inlineIncludedCandidates) addCandidateSource(candidate);
|
|
402
|
+
for (const candidate of view.inlineExcludedCandidates) sources.delete(candidate);
|
|
403
|
+
return sources;
|
|
404
|
+
}
|
|
405
|
+
//#endregion
|
|
309
406
|
//#region src/bundlers/shared/source-candidates/store.ts
|
|
407
|
+
const SOURCE_CANDIDATE_FILE_MEMO_MAX = 4096;
|
|
408
|
+
function areSetsEqual(left, right) {
|
|
409
|
+
if (!left || left.size !== right.size) return false;
|
|
410
|
+
for (const value of right) if (!left.has(value)) return false;
|
|
411
|
+
return true;
|
|
412
|
+
}
|
|
310
413
|
function createSourceCandidateStore(options = {}) {
|
|
311
414
|
const candidatesById = /* @__PURE__ */ new Map();
|
|
312
415
|
const scanCandidatesById = /* @__PURE__ */ new Map();
|
|
@@ -318,15 +421,30 @@ function createSourceCandidateStore(options = {}) {
|
|
|
318
421
|
const cssSourceById = /* @__PURE__ */ new Map();
|
|
319
422
|
const moduleSourceById = /* @__PURE__ */ new Map();
|
|
320
423
|
const candidateCount = /* @__PURE__ */ new Map();
|
|
424
|
+
const fileCandidateMemo = /* @__PURE__ */ new Map();
|
|
321
425
|
let inlineIncludedCandidates = /* @__PURE__ */ new Set();
|
|
322
426
|
let inlineExcludedCandidates = /* @__PURE__ */ new Set();
|
|
323
|
-
|
|
427
|
+
let revision = 0;
|
|
428
|
+
async function resolveCandidates(id, source, extension) {
|
|
429
|
+
const memoKey = `${cleanUrl(id)}\0${extension}`;
|
|
430
|
+
const memo = fileCandidateMemo.get(memoKey);
|
|
431
|
+
if (memo?.source === source) return new Set(memo.candidates);
|
|
324
432
|
const contentCacheKey = createSourceCandidateContentCacheKey(extension, source, options.bareArbitraryValues, options.customAttributesEntities, options.disabledDefaultTemplateHandler, options.extractor);
|
|
325
433
|
const cachedCandidates = sourceCandidateContentCache.get(contentCacheKey);
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
434
|
+
const nextCandidates = cachedCandidates ? new Set(cachedCandidates) : await extractCandidates(source, extension, options);
|
|
435
|
+
if (!cachedCandidates) sourceCandidateContentCache.set(contentCacheKey, [...nextCandidates]);
|
|
436
|
+
fileCandidateMemo.delete(memoKey);
|
|
437
|
+
fileCandidateMemo.set(memoKey, {
|
|
438
|
+
candidates: new Set(nextCandidates),
|
|
439
|
+
extension,
|
|
440
|
+
source
|
|
441
|
+
});
|
|
442
|
+
while (fileCandidateMemo.size > SOURCE_CANDIDATE_FILE_MEMO_MAX) {
|
|
443
|
+
const oldest = fileCandidateMemo.keys().next().value;
|
|
444
|
+
if (oldest === void 0) break;
|
|
445
|
+
fileCandidateMemo.delete(oldest);
|
|
446
|
+
}
|
|
447
|
+
return new Set(nextCandidates);
|
|
330
448
|
}
|
|
331
449
|
function isCandidateVisible(candidate) {
|
|
332
450
|
if (inlineExcludedCandidates.has(candidate)) return false;
|
|
@@ -339,25 +457,29 @@ function createSourceCandidateStore(options = {}) {
|
|
|
339
457
|
}
|
|
340
458
|
async function sync(id, source) {
|
|
341
459
|
const normalizedId = cleanUrl(id);
|
|
460
|
+
if (scanSourceById.get(normalizedId) !== source) revision++;
|
|
342
461
|
scanSourceById.set(normalizedId, source);
|
|
343
|
-
replaceScanLayer(normalizedId, await resolveCandidates(source, resolveSourceCandidateExtension(normalizedId)));
|
|
462
|
+
replaceScanLayer(normalizedId, await resolveCandidates(normalizedId, source, resolveSourceCandidateExtension(normalizedId)));
|
|
344
463
|
}
|
|
345
464
|
async function syncCss(id, source) {
|
|
346
465
|
const normalizedId = cleanUrl(id);
|
|
466
|
+
if (cssSourceById.get(normalizedId) !== source) revision++;
|
|
347
467
|
cssSourceById.set(normalizedId, source);
|
|
348
|
-
replaceCssLayer(normalizedId, await resolveCandidates(source, "css"));
|
|
468
|
+
replaceCssLayer(normalizedId, await resolveCandidates(normalizedId, source, "css"));
|
|
349
469
|
}
|
|
350
470
|
async function syncModuleSource(id, source) {
|
|
351
471
|
const normalizedId = cleanUrl(id);
|
|
472
|
+
if (moduleSourceById.get(normalizedId) !== source) revision++;
|
|
352
473
|
moduleSourceById.set(normalizedId, source);
|
|
353
|
-
const candidates = await resolveCandidates(source, resolveSourceCandidateExtension(normalizedId));
|
|
474
|
+
const candidates = await resolveCandidates(normalizedId, source, resolveSourceCandidateExtension(normalizedId));
|
|
354
475
|
replaceModuleLayer(normalizedId, candidates);
|
|
355
476
|
return new Set(candidates);
|
|
356
477
|
}
|
|
357
478
|
async function merge(id, source) {
|
|
358
479
|
const normalizedId = cleanUrl(id);
|
|
480
|
+
if (transformSourceById.get(normalizedId) !== source) revision++;
|
|
359
481
|
transformSourceById.set(normalizedId, source);
|
|
360
|
-
replaceTransformLayer(normalizedId, await resolveCandidates(source, resolveSourceCandidateExtension(normalizedId)));
|
|
482
|
+
replaceTransformLayer(normalizedId, await resolveCandidates(normalizedId, source, resolveSourceCandidateExtension(normalizedId)));
|
|
361
483
|
}
|
|
362
484
|
async function syncFile(id) {
|
|
363
485
|
const normalizedId = cleanUrl(id);
|
|
@@ -375,7 +497,8 @@ function createSourceCandidateStore(options = {}) {
|
|
|
375
497
|
const normalizedId = cleanUrl(id);
|
|
376
498
|
const previousFileCandidates = new Set(candidatesById.get(normalizedId) ?? []);
|
|
377
499
|
const extension = resolveSourceCandidateExtension(normalizedId);
|
|
378
|
-
|
|
500
|
+
if (scanSourceById.get(normalizedId) !== source || extension !== "css" && (transformSourceById.has(normalizedId) || cssSourceById.has(normalizedId) || moduleSourceById.has(normalizedId))) revision++;
|
|
501
|
+
const nextCandidates = await resolveCandidates(normalizedId, source, extension);
|
|
379
502
|
const affectedCandidates = /* @__PURE__ */ new Set([...previousFileCandidates, ...nextCandidates]);
|
|
380
503
|
const previousVisibleCandidates = collectVisibleCandidates(affectedCandidates);
|
|
381
504
|
if (extension !== "css") {
|
|
@@ -416,6 +539,8 @@ function createSourceCandidateStore(options = {}) {
|
|
|
416
539
|
function replaceFinal(id, nextCandidates) {
|
|
417
540
|
const normalizedId = cleanUrl(id);
|
|
418
541
|
const previousCandidates = candidatesById.get(normalizedId);
|
|
542
|
+
if (areSetsEqual(previousCandidates, nextCandidates)) return;
|
|
543
|
+
revision++;
|
|
419
544
|
if (previousCandidates) {
|
|
420
545
|
removeCandidateSet(candidateCount, previousCandidates);
|
|
421
546
|
candidatesById.delete(normalizedId);
|
|
@@ -458,11 +583,15 @@ function createSourceCandidateStore(options = {}) {
|
|
|
458
583
|
]));
|
|
459
584
|
}
|
|
460
585
|
function syncInline(inlineCandidates) {
|
|
461
|
-
|
|
462
|
-
|
|
586
|
+
const nextIncluded = new Set(inlineCandidates?.included ?? []);
|
|
587
|
+
const nextExcluded = new Set(inlineCandidates?.excluded ?? []);
|
|
588
|
+
if (!areSetsEqual(inlineIncludedCandidates, nextIncluded) || !areSetsEqual(inlineExcludedCandidates, nextExcluded)) revision++;
|
|
589
|
+
inlineIncludedCandidates = nextIncluded;
|
|
590
|
+
inlineExcludedCandidates = nextExcluded;
|
|
463
591
|
}
|
|
464
592
|
function remove(id) {
|
|
465
593
|
const normalizedId = cleanUrl(id);
|
|
594
|
+
const hadState = candidatesById.has(normalizedId) || scanCandidatesById.has(normalizedId) || transformCandidatesById.has(normalizedId) || cssCandidatesById.has(normalizedId) || moduleCandidatesById.has(normalizedId) || scanSourceById.has(normalizedId) || transformSourceById.has(normalizedId) || cssSourceById.has(normalizedId) || moduleSourceById.has(normalizedId);
|
|
466
595
|
const affectedCandidates = new Set(candidatesById.get(normalizedId) ?? []);
|
|
467
596
|
const previousVisibleCandidates = collectVisibleCandidates(affectedCandidates);
|
|
468
597
|
scanCandidatesById.delete(normalizedId);
|
|
@@ -473,10 +602,15 @@ function createSourceCandidateStore(options = {}) {
|
|
|
473
602
|
transformSourceById.delete(normalizedId);
|
|
474
603
|
cssSourceById.delete(normalizedId);
|
|
475
604
|
moduleSourceById.delete(normalizedId);
|
|
605
|
+
for (const key of fileCandidateMemo.keys()) if (key.startsWith(`${normalizedId}\0`)) fileCandidateMemo.delete(key);
|
|
476
606
|
const previousCandidates = candidatesById.get(normalizedId);
|
|
477
|
-
if (!previousCandidates)
|
|
607
|
+
if (!previousCandidates) {
|
|
608
|
+
if (hadState) revision++;
|
|
609
|
+
return diffCandidateSets(previousVisibleCandidates, /* @__PURE__ */ new Set());
|
|
610
|
+
}
|
|
478
611
|
removeCandidateSet(candidateCount, previousCandidates);
|
|
479
612
|
candidatesById.delete(normalizedId);
|
|
613
|
+
revision++;
|
|
480
614
|
return diffCandidateSets(previousVisibleCandidates, collectVisibleCandidates(affectedCandidates));
|
|
481
615
|
}
|
|
482
616
|
function source(id) {
|
|
@@ -484,49 +618,37 @@ function createSourceCandidateStore(options = {}) {
|
|
|
484
618
|
return scanSourceById.get(normalizedId) ?? cssSourceById.get(normalizedId) ?? transformSourceById.get(normalizedId) ?? moduleSourceById.get(normalizedId);
|
|
485
619
|
}
|
|
486
620
|
function sources() {
|
|
487
|
-
return mergeSourcesByPriority().entries();
|
|
621
|
+
return mergeSourcesByPriority(moduleSourceById, transformSourceById, cssSourceById, scanSourceById).entries();
|
|
488
622
|
}
|
|
489
623
|
function values() {
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
624
|
+
return collectCandidateValues({
|
|
625
|
+
candidatesById,
|
|
626
|
+
moduleCandidatesById,
|
|
627
|
+
candidateCount,
|
|
628
|
+
inlineIncludedCandidates,
|
|
629
|
+
inlineExcludedCandidates
|
|
630
|
+
});
|
|
493
631
|
}
|
|
494
632
|
function valuesForEntries(entries, options = {}) {
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
if (options.excludeEntries?.length && require_generator.isFileMatchedByTailwindSourceEntries(id, options.excludeEntries)) continue;
|
|
503
|
-
for (const candidate of candidates) filtered.add(candidate);
|
|
504
|
-
}
|
|
505
|
-
for (const candidate of inlineIncludedCandidates) filtered.add(candidate);
|
|
506
|
-
for (const candidate of inlineExcludedCandidates) filtered.delete(candidate);
|
|
507
|
-
return filtered;
|
|
633
|
+
return collectCandidateValues({
|
|
634
|
+
candidatesById,
|
|
635
|
+
moduleCandidatesById,
|
|
636
|
+
candidateCount,
|
|
637
|
+
inlineIncludedCandidates,
|
|
638
|
+
inlineExcludedCandidates
|
|
639
|
+
}, entries, options.excludeEntries);
|
|
508
640
|
}
|
|
509
641
|
function sourcesForEntries(entries, options = {}) {
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
if (id) candidateSources.add(id);
|
|
518
|
-
};
|
|
519
|
-
for (const [id, candidates] of candidatesById) {
|
|
520
|
-
const isActiveModule = moduleCandidatesById.has(id);
|
|
521
|
-
if (entries !== void 0 && (isActiveModule ? require_generator.isFileExcludedByTailwindSourceEntries(id, entries) : entries.length === 0 || !require_generator.isFileMatchedByTailwindSourceEntries(id, entries))) continue;
|
|
522
|
-
if (options.excludeEntries?.length && require_generator.isFileMatchedByTailwindSourceEntries(id, options.excludeEntries)) continue;
|
|
523
|
-
for (const candidate of candidates) addCandidateSource(candidate, id);
|
|
524
|
-
}
|
|
525
|
-
for (const candidate of inlineIncludedCandidates) addCandidateSource(candidate, void 0);
|
|
526
|
-
for (const candidate of inlineExcludedCandidates) sources.delete(candidate);
|
|
527
|
-
return sources;
|
|
642
|
+
return collectCandidateSources({
|
|
643
|
+
candidatesById,
|
|
644
|
+
moduleCandidatesById,
|
|
645
|
+
candidateCount,
|
|
646
|
+
inlineIncludedCandidates,
|
|
647
|
+
inlineExcludedCandidates
|
|
648
|
+
}, entries, options.excludeEntries);
|
|
528
649
|
}
|
|
529
650
|
function clear() {
|
|
651
|
+
if (candidateCount.size > 0 || fileCandidateMemo.size > 0 || inlineIncludedCandidates.size > 0 || inlineExcludedCandidates.size > 0) revision++;
|
|
530
652
|
candidatesById.clear();
|
|
531
653
|
scanCandidatesById.clear();
|
|
532
654
|
transformCandidatesById.clear();
|
|
@@ -539,71 +661,56 @@ function createSourceCandidateStore(options = {}) {
|
|
|
539
661
|
candidateCount.clear();
|
|
540
662
|
inlineIncludedCandidates.clear();
|
|
541
663
|
inlineExcludedCandidates.clear();
|
|
664
|
+
fileCandidateMemo.clear();
|
|
542
665
|
}
|
|
543
666
|
function clearScan() {
|
|
667
|
+
const hadState = scanCandidatesById.size > 0 || inlineIncludedCandidates.size > 0 || inlineExcludedCandidates.size > 0;
|
|
544
668
|
for (const id of scanCandidatesById.keys()) {
|
|
545
669
|
scanCandidatesById.delete(id);
|
|
546
670
|
recompute(id);
|
|
547
671
|
}
|
|
548
672
|
inlineIncludedCandidates.clear();
|
|
549
673
|
inlineExcludedCandidates.clear();
|
|
674
|
+
if (hadState) revision++;
|
|
550
675
|
}
|
|
551
676
|
function resetScan() {
|
|
677
|
+
const hadState = inlineIncludedCandidates.size > 0 || inlineExcludedCandidates.size > 0;
|
|
552
678
|
inlineIncludedCandidates.clear();
|
|
553
679
|
inlineExcludedCandidates.clear();
|
|
680
|
+
if (hadState) revision++;
|
|
554
681
|
}
|
|
555
682
|
function snapshot() {
|
|
556
|
-
return {
|
|
557
|
-
candidatesById
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
inlineExcludedCandidates
|
|
568
|
-
|
|
569
|
-
};
|
|
683
|
+
return createCandidateSnapshot({
|
|
684
|
+
candidatesById,
|
|
685
|
+
scanCandidatesById,
|
|
686
|
+
transformCandidatesById,
|
|
687
|
+
cssCandidatesById,
|
|
688
|
+
moduleCandidatesById,
|
|
689
|
+
scanSourceById,
|
|
690
|
+
transformSourceById,
|
|
691
|
+
cssSourceById,
|
|
692
|
+
moduleSourceById,
|
|
693
|
+
inlineIncludedCandidates,
|
|
694
|
+
inlineExcludedCandidates
|
|
695
|
+
});
|
|
570
696
|
}
|
|
571
697
|
function restore(snapshot) {
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
if (candidateSet.size === 0) continue;
|
|
589
|
-
cssCandidatesById.set(id, candidateSet);
|
|
590
|
-
}
|
|
591
|
-
for (const [id, candidates] of snapshot.moduleCandidatesById ?? []) {
|
|
592
|
-
const candidateSet = new Set(candidates);
|
|
593
|
-
if (candidateSet.size === 0) continue;
|
|
594
|
-
moduleCandidatesById.set(id, candidateSet);
|
|
595
|
-
}
|
|
596
|
-
for (const [id, source] of snapshot.scanSourceById ?? snapshot.sourceById ?? []) scanSourceById.set(id, source);
|
|
597
|
-
for (const [id, source] of snapshot.transformSourceById ?? []) transformSourceById.set(id, source);
|
|
598
|
-
for (const [id, source] of snapshot.cssSourceById ?? []) cssSourceById.set(id, source);
|
|
599
|
-
for (const [id, source] of snapshot.moduleSourceById ?? []) moduleSourceById.set(id, source);
|
|
600
|
-
const ids = /* @__PURE__ */ new Set([
|
|
601
|
-
...scanCandidatesById.keys(),
|
|
602
|
-
...transformCandidatesById.keys(),
|
|
603
|
-
...cssCandidatesById.keys(),
|
|
604
|
-
...moduleCandidatesById.keys()
|
|
605
|
-
]);
|
|
606
|
-
for (const id of ids) recompute(id);
|
|
698
|
+
restoreCandidateSnapshot({
|
|
699
|
+
candidatesById,
|
|
700
|
+
scanCandidatesById,
|
|
701
|
+
transformCandidatesById,
|
|
702
|
+
cssCandidatesById,
|
|
703
|
+
moduleCandidatesById,
|
|
704
|
+
scanSourceById,
|
|
705
|
+
transformSourceById,
|
|
706
|
+
cssSourceById,
|
|
707
|
+
moduleSourceById,
|
|
708
|
+
inlineIncludedCandidates,
|
|
709
|
+
inlineExcludedCandidates
|
|
710
|
+
}, snapshot, clear, recompute, (included, excluded) => {
|
|
711
|
+
inlineIncludedCandidates = included;
|
|
712
|
+
inlineExcludedCandidates = excluded;
|
|
713
|
+
});
|
|
607
714
|
}
|
|
608
715
|
return {
|
|
609
716
|
syncSource: sync,
|
|
@@ -627,16 +734,9 @@ function createSourceCandidateStore(options = {}) {
|
|
|
627
734
|
restore,
|
|
628
735
|
clearScan,
|
|
629
736
|
resetScan,
|
|
630
|
-
clear
|
|
737
|
+
clear,
|
|
738
|
+
getRevision: () => revision
|
|
631
739
|
};
|
|
632
|
-
function mergeSourcesByPriority() {
|
|
633
|
-
const sources = /* @__PURE__ */ new Map();
|
|
634
|
-
for (const [id, source] of moduleSourceById) sources.set(id, source);
|
|
635
|
-
for (const [id, source] of transformSourceById) sources.set(id, source);
|
|
636
|
-
for (const [id, source] of cssSourceById) sources.set(id, source);
|
|
637
|
-
for (const [id, source] of scanSourceById) sources.set(id, source);
|
|
638
|
-
return sources;
|
|
639
|
-
}
|
|
640
740
|
}
|
|
641
741
|
//#endregion
|
|
642
742
|
//#region src/bundlers/shared/source-candidates/collector.ts
|
|
@@ -680,48 +780,6 @@ function createGenerationArtifact(fragments, options) {
|
|
|
680
780
|
});
|
|
681
781
|
}
|
|
682
782
|
//#endregion
|
|
683
|
-
//#region src/compiler/candidate-index.ts
|
|
684
|
-
var CandidateIndex = class {
|
|
685
|
-
constructor() {
|
|
686
|
-
require_object._defineProperty(this, "candidatesBySource", /* @__PURE__ */ new Map());
|
|
687
|
-
}
|
|
688
|
-
sync(sourceId, candidates) {
|
|
689
|
-
const previous = this.candidatesBySource.get(sourceId) ?? /* @__PURE__ */ new Set();
|
|
690
|
-
const next = new Set(candidates);
|
|
691
|
-
const addedCandidates = new Set([...next].filter((candidate) => !previous.has(candidate)));
|
|
692
|
-
const removedCandidates = new Set([...previous].filter((candidate) => !next.has(candidate)));
|
|
693
|
-
this.candidatesBySource.set(sourceId, next);
|
|
694
|
-
return {
|
|
695
|
-
sourceId,
|
|
696
|
-
addedCandidates,
|
|
697
|
-
removedCandidates
|
|
698
|
-
};
|
|
699
|
-
}
|
|
700
|
-
remove(sourceId) {
|
|
701
|
-
const previous = this.candidatesBySource.get(sourceId) ?? /* @__PURE__ */ new Set();
|
|
702
|
-
this.candidatesBySource.delete(sourceId);
|
|
703
|
-
return {
|
|
704
|
-
sourceId,
|
|
705
|
-
addedCandidates: /* @__PURE__ */ new Set(),
|
|
706
|
-
removedCandidates: new Set(previous)
|
|
707
|
-
};
|
|
708
|
-
}
|
|
709
|
-
values() {
|
|
710
|
-
const values = /* @__PURE__ */ new Set();
|
|
711
|
-
for (const candidates of this.candidatesBySource.values()) for (const candidate of candidates) values.add(candidate);
|
|
712
|
-
return values;
|
|
713
|
-
}
|
|
714
|
-
get(sourceId) {
|
|
715
|
-
return new Set(this.candidatesBySource.get(sourceId) ?? []);
|
|
716
|
-
}
|
|
717
|
-
entries() {
|
|
718
|
-
return new Map([...this.candidatesBySource].map(([sourceId, candidates]) => [sourceId, new Set(candidates)]));
|
|
719
|
-
}
|
|
720
|
-
clear() {
|
|
721
|
-
this.candidatesBySource.clear();
|
|
722
|
-
}
|
|
723
|
-
};
|
|
724
|
-
//#endregion
|
|
725
783
|
//#region src/compiler/compilation-scope-graph.ts
|
|
726
784
|
function sourceNodeId(sourceId) {
|
|
727
785
|
return `source:${sourceId}`;
|
|
@@ -904,124 +962,6 @@ function runCompilerOwnerDisposal(owner, dispose) {
|
|
|
904
962
|
return disposal;
|
|
905
963
|
}
|
|
906
964
|
//#endregion
|
|
907
|
-
//#region src/compiler/invalidation.ts
|
|
908
|
-
function resolveInvalidatedScopes(graph, changes) {
|
|
909
|
-
const invalidatedScopes = /* @__PURE__ */ new Set();
|
|
910
|
-
const visit = (sourceId, visited) => {
|
|
911
|
-
if (visited.has(sourceId)) return;
|
|
912
|
-
visited.add(sourceId);
|
|
913
|
-
const node = graph.getNode(sourceId);
|
|
914
|
-
if (node) invalidatedScopes.add(node.scope.id);
|
|
915
|
-
for (const dependent of graph.getDependents(sourceId)) visit(dependent, visited);
|
|
916
|
-
};
|
|
917
|
-
for (const change of changes) visit(change.sourceId, /* @__PURE__ */ new Set());
|
|
918
|
-
return invalidatedScopes;
|
|
919
|
-
}
|
|
920
|
-
//#endregion
|
|
921
|
-
//#region src/compiler/source-graph.ts
|
|
922
|
-
var SourceGraph = class {
|
|
923
|
-
constructor() {
|
|
924
|
-
require_object._defineProperty(this, "edges", /* @__PURE__ */ new Map());
|
|
925
|
-
require_object._defineProperty(this, "nodes", /* @__PURE__ */ new Map());
|
|
926
|
-
}
|
|
927
|
-
replace(nodes, edges) {
|
|
928
|
-
this.clear();
|
|
929
|
-
for (const node of nodes) this.nodes.set(node.id, {
|
|
930
|
-
...node,
|
|
931
|
-
scope: { ...node.scope }
|
|
932
|
-
});
|
|
933
|
-
for (const edge of edges) {
|
|
934
|
-
if (!this.nodes.has(edge.from) || !this.nodes.has(edge.to)) throw new Error(`编译图边引用了不存在的节点:${edge.from} -> ${edge.to}`);
|
|
935
|
-
this.edges.set(this.edgeKey(edge), { ...edge });
|
|
936
|
-
}
|
|
937
|
-
}
|
|
938
|
-
getNode(id) {
|
|
939
|
-
const node = this.nodes.get(id);
|
|
940
|
-
return node ? {
|
|
941
|
-
...node,
|
|
942
|
-
scope: { ...node.scope }
|
|
943
|
-
} : void 0;
|
|
944
|
-
}
|
|
945
|
-
getNodes() {
|
|
946
|
-
return [...this.nodes.values()].map((node) => ({
|
|
947
|
-
...node,
|
|
948
|
-
scope: { ...node.scope }
|
|
949
|
-
}));
|
|
950
|
-
}
|
|
951
|
-
getEdges() {
|
|
952
|
-
return [...this.edges.values()].map((edge) => ({ ...edge }));
|
|
953
|
-
}
|
|
954
|
-
getDependents(id) {
|
|
955
|
-
return this.getEdges().filter((edge) => edge.to === id).map((edge) => edge.from);
|
|
956
|
-
}
|
|
957
|
-
clear() {
|
|
958
|
-
this.edges.clear();
|
|
959
|
-
this.nodes.clear();
|
|
960
|
-
}
|
|
961
|
-
edgeKey(edge) {
|
|
962
|
-
return `${edge.kind}\0${edge.from}\0${edge.to}`;
|
|
963
|
-
}
|
|
964
|
-
};
|
|
965
|
-
//#endregion
|
|
966
|
-
//#region src/compiler/session.ts
|
|
967
|
-
var DefaultCompilationSession = class {
|
|
968
|
-
constructor() {
|
|
969
|
-
require_object._defineProperty(this, "candidateIndex", new CandidateIndex());
|
|
970
|
-
require_object._defineProperty(this, "graph", new SourceGraph());
|
|
971
|
-
require_object._defineProperty(this, "retainedCandidates", /* @__PURE__ */ new Set());
|
|
972
|
-
require_object._defineProperty(this, "validatedClassSet", /* @__PURE__ */ new Set());
|
|
973
|
-
require_object._defineProperty(this, "invalidatedScopes", /* @__PURE__ */ new Set());
|
|
974
|
-
require_object._defineProperty(this, "revision", 0);
|
|
975
|
-
}
|
|
976
|
-
update(snapshot) {
|
|
977
|
-
const changes = [...snapshot.changes ?? []];
|
|
978
|
-
const invalidatedScopes = resolveInvalidatedScopes(this.graph, changes);
|
|
979
|
-
this.graph.replace(snapshot.nodes, snapshot.edges);
|
|
980
|
-
for (const [sourceId, candidates] of snapshot.candidatesBySource ?? []) {
|
|
981
|
-
const change = this.candidateIndex.sync(sourceId, candidates);
|
|
982
|
-
if (change.addedCandidates.size > 0 || change.removedCandidates.size > 0) changes.push(change);
|
|
983
|
-
}
|
|
984
|
-
for (const change of changes) if ("type" in change && change.type === "source-removed") this.candidateIndex.remove(change.sourceId);
|
|
985
|
-
const currentCandidates = this.candidateIndex.values();
|
|
986
|
-
if (snapshot.preserveDeletedCss) for (const candidate of currentCandidates) this.retainedCandidates.add(candidate);
|
|
987
|
-
else {
|
|
988
|
-
this.retainedCandidates.clear();
|
|
989
|
-
for (const candidate of currentCandidates) this.retainedCandidates.add(candidate);
|
|
990
|
-
}
|
|
991
|
-
if (snapshot.validatedClassSet !== void 0) this.validatedClassSet = new Set(snapshot.validatedClassSet);
|
|
992
|
-
else if (!snapshot.preserveDeletedCss) this.validatedClassSet = new Set([...this.validatedClassSet].filter((candidate) => this.retainedCandidates.has(candidate)));
|
|
993
|
-
this.revision += 1;
|
|
994
|
-
for (const scopeId of resolveInvalidatedScopes(this.graph, changes)) invalidatedScopes.add(scopeId);
|
|
995
|
-
this.invalidatedScopes = invalidatedScopes;
|
|
996
|
-
return this.createResult();
|
|
997
|
-
}
|
|
998
|
-
commitValidation(revision, validatedClassSet, graph) {
|
|
999
|
-
if (revision !== this.revision) throw new Error(`不能向编译 revision ${this.revision} 提交 revision ${revision} 的 classSet。`);
|
|
1000
|
-
if (graph) this.graph.replace(graph.nodes, graph.edges);
|
|
1001
|
-
this.validatedClassSet = new Set(validatedClassSet);
|
|
1002
|
-
return this.createResult();
|
|
1003
|
-
}
|
|
1004
|
-
createResult() {
|
|
1005
|
-
return {
|
|
1006
|
-
revision: this.revision,
|
|
1007
|
-
candidates: new Set(this.retainedCandidates),
|
|
1008
|
-
candidatesBySource: this.candidateIndex.entries(),
|
|
1009
|
-
validatedClassSet: new Set(this.validatedClassSet),
|
|
1010
|
-
invalidatedScopes: new Set(this.invalidatedScopes),
|
|
1011
|
-
graphEdges: this.graph.getEdges(),
|
|
1012
|
-
graphNodes: this.graph.getNodes()
|
|
1013
|
-
};
|
|
1014
|
-
}
|
|
1015
|
-
dispose() {
|
|
1016
|
-
this.candidateIndex.clear();
|
|
1017
|
-
this.graph.clear();
|
|
1018
|
-
this.retainedCandidates.clear();
|
|
1019
|
-
this.validatedClassSet.clear();
|
|
1020
|
-
this.invalidatedScopes.clear();
|
|
1021
|
-
this.revision = 0;
|
|
1022
|
-
}
|
|
1023
|
-
};
|
|
1024
|
-
//#endregion
|
|
1025
965
|
//#region src/compiler/compilation-session-pool.ts
|
|
1026
966
|
const COMPILATION_SCOPE_CACHE_MAX = 128;
|
|
1027
967
|
function cloneScopeSource(source) {
|
|
@@ -1093,7 +1033,7 @@ var CompilationSessionPool = class {
|
|
|
1093
1033
|
executions: /* @__PURE__ */ new Set(),
|
|
1094
1034
|
pending: Promise.resolve(),
|
|
1095
1035
|
scope: { ...scope },
|
|
1096
|
-
session: new DefaultCompilationSession(),
|
|
1036
|
+
session: new require_compiler.DefaultCompilationSession(),
|
|
1097
1037
|
generatedDependencies: /* @__PURE__ */ new Map(),
|
|
1098
1038
|
sources: /* @__PURE__ */ new Map()
|
|
1099
1039
|
};
|
|
@@ -1436,6 +1376,98 @@ var AssetEmissionPlan = class {
|
|
|
1436
1376
|
}
|
|
1437
1377
|
};
|
|
1438
1378
|
//#endregion
|
|
1379
|
+
//#region src/compiler/framework-compiler-session.ts
|
|
1380
|
+
/**
|
|
1381
|
+
* 官方 bundler 共享的 compiler 生命周期边界。
|
|
1382
|
+
*
|
|
1383
|
+
* bundler 继续拥有模块图和 scope 投影;本层只负责把逻辑 source root
|
|
1384
|
+
* 映射到一个长期复用的 compiler,并保证 root 删除与 owner 释放可等待。
|
|
1385
|
+
*/
|
|
1386
|
+
var FrameworkCompilerSession = class {
|
|
1387
|
+
constructor(options) {
|
|
1388
|
+
require_object._defineProperty(this, "compiler", void 0);
|
|
1389
|
+
require_object._defineProperty(this, "scopeRoots", /* @__PURE__ */ new Map());
|
|
1390
|
+
require_object._defineProperty(this, "activeRoots", /* @__PURE__ */ new Set());
|
|
1391
|
+
require_object._defineProperty(this, "transactionId", 0);
|
|
1392
|
+
require_object._defineProperty(this, "disposed", false);
|
|
1393
|
+
this.compiler = require_compiler.createCompiler(options);
|
|
1394
|
+
}
|
|
1395
|
+
rootId(scopeId, sourceId) {
|
|
1396
|
+
return `framework:${this.encode(scopeId)}:${this.encode(sourceId)}`;
|
|
1397
|
+
}
|
|
1398
|
+
async generate(scopeId, sourceId, source, request) {
|
|
1399
|
+
if (this.disposed) throw new Error("FrameworkCompilerSession 已释放。");
|
|
1400
|
+
const stableId = this.rootId(scopeId, sourceId);
|
|
1401
|
+
const id = this.activeRoots.has(stableId) ? `${stableId}:transaction-${++this.transactionId}` : stableId;
|
|
1402
|
+
let roots = this.scopeRoots.get(scopeId);
|
|
1403
|
+
if (!roots) {
|
|
1404
|
+
roots = /* @__PURE__ */ new Set();
|
|
1405
|
+
this.scopeRoots.set(scopeId, roots);
|
|
1406
|
+
}
|
|
1407
|
+
roots.add(stableId);
|
|
1408
|
+
this.activeRoots.add(stableId);
|
|
1409
|
+
try {
|
|
1410
|
+
return await this.compiler.generate({
|
|
1411
|
+
...request,
|
|
1412
|
+
id,
|
|
1413
|
+
source: {
|
|
1414
|
+
...source,
|
|
1415
|
+
dependencies: source.dependencies ?? []
|
|
1416
|
+
}
|
|
1417
|
+
});
|
|
1418
|
+
} finally {
|
|
1419
|
+
this.activeRoots.delete(stableId);
|
|
1420
|
+
if (id !== stableId) await this.compiler.remove(id);
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
async syncScope(scopeId, sourceIds) {
|
|
1424
|
+
if (this.disposed) return;
|
|
1425
|
+
const roots = this.scopeRoots.get(scopeId);
|
|
1426
|
+
if (!roots) return;
|
|
1427
|
+
const active = new Set([...sourceIds].map((sourceId) => this.rootId(scopeId, sourceId)));
|
|
1428
|
+
const removed = [...roots].filter((rootId) => !active.has(rootId));
|
|
1429
|
+
await Promise.all(removed.map((rootId) => this.compiler.remove(rootId)));
|
|
1430
|
+
for (const rootId of removed) roots.delete(rootId);
|
|
1431
|
+
if (roots.size === 0) this.scopeRoots.delete(scopeId);
|
|
1432
|
+
}
|
|
1433
|
+
async removeScope(scopeId) {
|
|
1434
|
+
const roots = this.scopeRoots.get(scopeId);
|
|
1435
|
+
if (!roots) return;
|
|
1436
|
+
this.scopeRoots.delete(scopeId);
|
|
1437
|
+
await Promise.all([...roots].map((rootId) => this.compiler.remove(rootId)));
|
|
1438
|
+
}
|
|
1439
|
+
invalidate(ids) {
|
|
1440
|
+
return this.compiler.invalidate(ids);
|
|
1441
|
+
}
|
|
1442
|
+
mergeSnapshots(snapshots) {
|
|
1443
|
+
return this.compiler.mergeSnapshots(snapshots);
|
|
1444
|
+
}
|
|
1445
|
+
dispose() {
|
|
1446
|
+
if (this.disposed) return Promise.resolve();
|
|
1447
|
+
this.disposed = true;
|
|
1448
|
+
this.scopeRoots.clear();
|
|
1449
|
+
return this.compiler.dispose();
|
|
1450
|
+
}
|
|
1451
|
+
encode(value) {
|
|
1452
|
+
return node_buffer.Buffer.from(value, "utf8").toString("base64url");
|
|
1453
|
+
}
|
|
1454
|
+
};
|
|
1455
|
+
const frameworkCompilerSessions = /* @__PURE__ */ new WeakMap();
|
|
1456
|
+
function getFrameworkCompilerSession(owner, options) {
|
|
1457
|
+
let session = frameworkCompilerSessions.get(owner);
|
|
1458
|
+
if (!session) {
|
|
1459
|
+
session = new FrameworkCompilerSession(options);
|
|
1460
|
+
frameworkCompilerSessions.set(owner, session);
|
|
1461
|
+
}
|
|
1462
|
+
return session;
|
|
1463
|
+
}
|
|
1464
|
+
function disposeFrameworkCompilerSession(owner) {
|
|
1465
|
+
const session = frameworkCompilerSessions.get(owner);
|
|
1466
|
+
if (!session) return Promise.resolve();
|
|
1467
|
+
frameworkCompilerSessions.delete(owner);
|
|
1468
|
+
return session.dispose();
|
|
1469
|
+
}
|
|
1470
|
+
//#endregion
|
|
1439
1471
|
//#region src/compiler/mode.ts
|
|
1440
1472
|
const COMPILER_MODE_ENV = "WEAPP_TAILWINDCSS_COMPILER";
|
|
1441
1473
|
function resolveCompilerMode(env = node_process.default.env) {
|
|
@@ -1570,6 +1602,7 @@ function disposeCompilerShadowReportSession(owner) {
|
|
|
1570
1602
|
async function disposeCompilerOwnerResources(owner) {
|
|
1571
1603
|
disposeCompilationChangeCoordinator(owner);
|
|
1572
1604
|
await disposeCompilationSessionPool(owner);
|
|
1605
|
+
await disposeFrameworkCompilerSession(owner);
|
|
1573
1606
|
disposeTailwindGenerationSessionPool(owner);
|
|
1574
1607
|
disposeCompilerShadowReportSession(owner);
|
|
1575
1608
|
}
|
|
@@ -2234,6 +2267,7 @@ function parseBundlerGeneratedCssMarkerBlocks(source) {
|
|
|
2234
2267
|
//#region src/bundlers/shared/style-requests.ts
|
|
2235
2268
|
const SOURCE_STYLE_EXT_RE = /\.(?:css|scss|sass|less|styl|stylus|pcss|postcss)$/i;
|
|
2236
2269
|
const SOURCE_PREPROCESSOR_EXT_RE = /\.(?:scss|sass|less|styl|stylus)$/i;
|
|
2270
|
+
const SFC_SOURCE_EXT_RE = /\.(?:vue|uvue|nvue|svelte|mpx)$/i;
|
|
2237
2271
|
const INLINE_PREPROCESSOR_LANG_RE = /(?:^|[.?&])lang\.(?:scss|sass|less|styl|stylus)(?:[.&]|$)/i;
|
|
2238
2272
|
const STYLE_QUERY_RE = /(?:^|&)type=styles?(?:&|$)/;
|
|
2239
2273
|
const VUE_STYLE_QUERY_RE = /(?:^|&)type=style(?:&|$)/;
|
|
@@ -2259,6 +2293,10 @@ function isSourceStyleRequest(request) {
|
|
|
2259
2293
|
const query = normalized.slice(queryIndex + 1);
|
|
2260
2294
|
return STYLE_QUERY_RE.test(query) || STYLE_LANG_QUERY_RE.test(query);
|
|
2261
2295
|
}
|
|
2296
|
+
function isSfcStyleSourceRequest(request) {
|
|
2297
|
+
if (typeof request !== "string" || request.length === 0) return false;
|
|
2298
|
+
return SFC_SOURCE_EXT_RE.test(stripRequestQuery(request));
|
|
2299
|
+
}
|
|
2262
2300
|
function isSourcePreprocessorRequest(request, lang) {
|
|
2263
2301
|
if (typeof lang === "string" && SOURCE_PREPROCESSOR_EXT_RE.test(`.${lang}`)) return true;
|
|
2264
2302
|
if (typeof request !== "string" || request.length === 0) return false;
|
|
@@ -2335,7 +2373,7 @@ function resolveMiniProgramPreflightModeForGeneratorCss(opts, options) {
|
|
|
2335
2373
|
inject: false,
|
|
2336
2374
|
preserve: false
|
|
2337
2375
|
};
|
|
2338
|
-
const shouldInjectUniAppXLocalImportPreflight =
|
|
2376
|
+
const shouldInjectUniAppXLocalImportPreflight = require_tailwindcss.isUniAppXEnabled(opts.uniAppX) && Boolean(options.localImports?.trim());
|
|
2339
2377
|
if (opts.cssPreflight === false) return {
|
|
2340
2378
|
inject: false,
|
|
2341
2379
|
preserve: false
|
|
@@ -2558,7 +2596,7 @@ function isEmptyCssSourceOrderParts(parts) {
|
|
|
2558
2596
|
return parts.before.trim().length === 0 && parts.after.trim().length === 0;
|
|
2559
2597
|
}
|
|
2560
2598
|
function resolveGeneratorStyleOptions(opts, cssHandlerOptions, generatorStyleOptions) {
|
|
2561
|
-
const resolvedStyleOptions =
|
|
2599
|
+
const resolvedStyleOptions = require_compiler.resolveStyleOptionsFromContext(opts);
|
|
2562
2600
|
const scopedVueStyleSource = isVueScopedStyleRequest(resolvePostcssRequestOption(cssHandlerOptions));
|
|
2563
2601
|
const preflightStyleOptions = {
|
|
2564
2602
|
cssPreflight: scopedVueStyleSource ? false : resolvedStyleOptions.cssPreflight,
|
|
@@ -2699,11 +2737,18 @@ async function adaptGeneratedCssWithFrameworkPipeline(owner, generated, options)
|
|
|
2699
2737
|
}
|
|
2700
2738
|
async function adaptGeneratedCssWithFrameworkRootPipeline(owner, generated, options) {
|
|
2701
2739
|
const handlerOptions = createGeneratedCssHandlerOptions(owner, options.cssHandlerOptions, options.file);
|
|
2702
|
-
const
|
|
2740
|
+
const replayArtifact = createFrameworkReplayArtifact(generated, options);
|
|
2741
|
+
const handled = options.compiler && options.snapshot ? composeGenerationArtifact(await (async () => {
|
|
2742
|
+
for (const fragment of replayArtifact.fragments) {
|
|
2743
|
+
fragment.root = (await options.compiler.transformCssRoot(fragment.root, options.snapshot, handlerOptions)).root.clone();
|
|
2744
|
+
fragment.stage = "framework-processed";
|
|
2745
|
+
}
|
|
2746
|
+
return replayArtifact;
|
|
2747
|
+
})()) : typeof options.styleHandler.transformRoot === "function" ? composeGenerationArtifact(await createStylePlatformAdapter({
|
|
2703
2748
|
id: generated.target === "web" ? "web" : "mini-program",
|
|
2704
2749
|
styleHandler: options.styleHandler,
|
|
2705
2750
|
styleOptions: handlerOptions
|
|
2706
|
-
}).transform(
|
|
2751
|
+
}).transform(replayArtifact, { stage: "framework-processed" })) : await options.styleHandler(generated.css, handlerOptions);
|
|
2707
2752
|
const preflightMode = generated.metadata?.preflightMode;
|
|
2708
2753
|
const injectPreflight = preflightMode?.inject ?? options.cssHandlerOptions.isMainChunk;
|
|
2709
2754
|
const preservePreflight = preflightMode?.preserve ?? options.cssHandlerOptions.isMainChunk;
|
|
@@ -3204,7 +3249,7 @@ function collectLocalStyleImportFiles(source, base) {
|
|
|
3204
3249
|
}
|
|
3205
3250
|
function extractStyleDirectiveSourcesDeep(source, sourceFile, seen) {
|
|
3206
3251
|
const ownSources = extractStyleDirectiveSources(source);
|
|
3207
|
-
if (ownSources.
|
|
3252
|
+
if (ownSources.some((styleSource) => require_generator.hasTailwindRootDirectives(styleSource, { importFallback: true }))) return ownSources.map((styleSource) => ({
|
|
3208
3253
|
source: styleSource,
|
|
3209
3254
|
file: sourceFile
|
|
3210
3255
|
}));
|
|
@@ -3219,7 +3264,10 @@ function extractStyleDirectiveSourcesDeep(source, sourceFile, seen) {
|
|
|
3219
3264
|
sources.push(...extractStyleDirectiveSourcesDeep(importedSource, normalizedImportedFile, seen));
|
|
3220
3265
|
} catch {}
|
|
3221
3266
|
}
|
|
3222
|
-
return sources
|
|
3267
|
+
return sources.length > 0 ? sources : ownSources.map((styleSource) => ({
|
|
3268
|
+
source: styleSource,
|
|
3269
|
+
file: sourceFile
|
|
3270
|
+
}));
|
|
3223
3271
|
}
|
|
3224
3272
|
function resolveSourceSideCssEntrySource(file, sourceOptions, resolveOptions = {}) {
|
|
3225
3273
|
for (const sourceFile of createSourceStylePathCandidates(file, sourceOptions)) try {
|
|
@@ -3263,7 +3311,7 @@ function collectGeneratorCssCandidates(css) {
|
|
|
3263
3311
|
const root = parseGeneratorCss(css);
|
|
3264
3312
|
if (!root) return [];
|
|
3265
3313
|
const candidates = collectApplyCandidates(root);
|
|
3266
|
-
const inlineCandidates =
|
|
3314
|
+
const inlineCandidates = require_tailwindcss.collectCssInlineSourceCandidates(root);
|
|
3267
3315
|
for (const candidate of inlineCandidates.included) candidates.add(candidate);
|
|
3268
3316
|
for (const candidate of inlineCandidates.excluded) candidates.delete(candidate);
|
|
3269
3317
|
return [...candidates].sort();
|
|
@@ -3603,7 +3651,7 @@ async function resolveTailwindV4CssSourceEntries(cssSource, sourceOptions) {
|
|
|
3603
3651
|
if (typeof cssSource.css !== "string" || cssSource.css.length === 0) return;
|
|
3604
3652
|
const sourceBaseFallback = sourceOptions.base ?? sourceOptions.projectRoot ?? node_process.default.cwd();
|
|
3605
3653
|
const sourceBase = require_generator.resolveTailwindV4CssSourceBase(cssSource, sourceBaseFallback);
|
|
3606
|
-
return
|
|
3654
|
+
return require_tailwindcss.resolveTailwindV4EntriesFromCss(cssSource.css, sourceBase);
|
|
3607
3655
|
}
|
|
3608
3656
|
function countRuntimeCandidateHits(candidates, runtime) {
|
|
3609
3657
|
if (!runtime?.size) return 0;
|
|
@@ -3646,7 +3694,7 @@ async function resolveCandidateMatchedTailwindV4CssSource(_rawSource, _cssHandle
|
|
|
3646
3694
|
async function resolveTailwindV4CssEntryEntries(cssEntry) {
|
|
3647
3695
|
if (!(0, node_fs.existsSync)(cssEntry)) return;
|
|
3648
3696
|
const file = node_path.default.resolve(cssEntry);
|
|
3649
|
-
return
|
|
3697
|
+
return require_tailwindcss.resolveTailwindV4EntriesFromCss((0, node_fs.readFileSync)(file, "utf8"), node_path.default.dirname(file));
|
|
3650
3698
|
}
|
|
3651
3699
|
async function resolveTailwindV4CssEntryIncludesPreflight(cssEntry) {
|
|
3652
3700
|
return resolveTailwindV4CssEntryEntries(cssEntry).then((resolved) => resolved?.includesPreflight);
|
|
@@ -3688,22 +3736,22 @@ function createTailwindV4CssSourceResolver(sourceOptions, generatorOptions) {
|
|
|
3688
3736
|
css: require_generator.prependConfigDirective(source.css, generatorOptions.config)
|
|
3689
3737
|
} : source);
|
|
3690
3738
|
}
|
|
3691
|
-
async function resolveTailwindV4SourceSideEntrySource(resolvedEntrySource, sourceOptions, generatorOptions, file) {
|
|
3739
|
+
async function resolveTailwindV4SourceSideEntrySource(resolvedEntrySource, sourceOptions, generatorOptions, file, currentCss) {
|
|
3692
3740
|
if (!resolvedEntrySource) return;
|
|
3693
3741
|
const resolvedSourceOptions = require_object.omitUndefined(sourceOptions);
|
|
3694
3742
|
const config = resolveExistingConfigPath(resolvedEntrySource.config, resolvedEntrySource.configRequest, file, {
|
|
3695
3743
|
...resolvedSourceOptions,
|
|
3696
3744
|
sourceFile: resolvedEntrySource.file
|
|
3697
3745
|
});
|
|
3698
|
-
const css = createTailwindV4SourceReferenceSource(require_generator.normalizeConfigDirective(require_generator.prependConfigDirective(resolvedEntrySource.css, generatorOptions?.config), config), resolvedSourceOptions);
|
|
3746
|
+
const css = createTailwindV4SourceReferenceSource(require_generator.normalizeConfigDirective(require_generator.prependConfigDirective(currentCss ?? resolvedEntrySource.css, generatorOptions?.config), config), resolvedSourceOptions);
|
|
3699
3747
|
const source = await require_generator.resolveTailwindV4Source(createSingleTailwindV4SourceOptions(resolvedSourceOptions, {
|
|
3700
|
-
base: resolvedEntrySource.base,
|
|
3748
|
+
base: currentCss && config ? node_path.default.dirname(config) : resolvedEntrySource.base,
|
|
3701
3749
|
css,
|
|
3702
3750
|
cssEntries: [resolvedEntrySource.file]
|
|
3703
3751
|
}));
|
|
3704
3752
|
const matchedCssEntryIndex = sourceOptions.cssEntries?.findIndex((cssEntry) => typeof resolvedEntrySource.file === "string" && node_path.default.resolve(cssEntry.replace(/[?#].*$/, "")) === node_path.default.resolve(resolvedEntrySource.file));
|
|
3705
3753
|
const matchedCssSourceIndex = sourceOptions.cssSources?.findIndex((cssSource) => typeof cssSource.file === "string" && typeof resolvedEntrySource.file === "string" && node_path.default.resolve(cssSource.file.replace(/[?#].*$/, "")) === node_path.default.resolve(resolvedEntrySource.file));
|
|
3706
|
-
const resolvedEntries = await
|
|
3754
|
+
const resolvedEntries = await require_tailwindcss.resolveTailwindV4EntriesFromCss(resolvedEntrySource.css, resolvedEntrySource.base);
|
|
3707
3755
|
return withMatchedSourceSideMetadata(source, resolvedEntrySource, {
|
|
3708
3756
|
cssEntryIndex: matchedCssEntryIndex !== void 0 && matchedCssEntryIndex >= 0 ? matchedCssEntryIndex : void 0,
|
|
3709
3757
|
cssSourceIndex: matchedCssSourceIndex !== void 0 && matchedCssSourceIndex >= 0 ? matchedCssSourceIndex : void 0,
|
|
@@ -3804,7 +3852,7 @@ async function resolveGeneratorSource(_majorVersion, runtimeState, rawSource, fi
|
|
|
3804
3852
|
}
|
|
3805
3853
|
const shouldPreferSourceSideEntry = shouldResolveSourceSideCssEntry(rawSource) || Boolean(cssEntrySource?.css.includes("weapp-tailwindcss generator-placeholder")) && (sourceOptions?.cssEntries?.length ?? 0) <= 1;
|
|
3806
3854
|
const sourceSideEntrySource = normalizedSourceOptions && (shouldPreferSourceSideEntry || normalizedSourceOptions.sourceFile !== void 0) && canResolveSourceSideCssEntry(file, cssHandlerOptions, normalizedSourceOptions) ? resolveSourceSideCssEntrySource(file, normalizedSourceOptions, { removeConfig: false }) : void 0;
|
|
3807
|
-
const sourceSideCssSource = sourceSideEntrySource?.file &&
|
|
3855
|
+
const sourceSideCssSource = sourceSideEntrySource?.file && (sourceOptions?.cssEntries?.some((cssEntry) => node_path.default.resolve(cssEntry.replace(/[?#].*$/, "")) === node_path.default.resolve(sourceSideEntrySource.file)) || isSfcStyleSourceRequest(file) && sourceOptions?.cssSources?.some((cssSource) => typeof cssSource.file === "string" && node_path.default.resolve(cssSource.file.replace(/[?#].*$/, "")) === node_path.default.resolve(sourceSideEntrySource.file))) ? await resolveTailwindV4SourceSideEntrySource(sourceSideEntrySource, normalizedSourceOptions, generatorOptions, file, rawSource) : void 0;
|
|
3808
3856
|
if (sourceSideCssSource) return sourceSideCssSource;
|
|
3809
3857
|
const matchedCssEntrySource = normalizedSourceOptions ? await resolveMatchingTailwindV4CssEntry(rawSource, file, normalizedSourceOptions) : void 0;
|
|
3810
3858
|
const matchedCssSource = normalizedSourceOptions && !matchedCssEntrySource ? await resolveMatchingTailwindV4CssSource(rawSource, file, cssHandlerOptions, normalizedSourceOptions, selectionOptions) : void 0;
|
|
@@ -3918,7 +3966,7 @@ async function resolveGeneratorSourceEntries(record, runtimeState) {
|
|
|
3918
3966
|
const { metadata: sourceMetadata, source } = record;
|
|
3919
3967
|
if (sourceMetadata?.sourceEntries) return sourceMetadata.sourceEntries;
|
|
3920
3968
|
if (!("css" in source) || !("base" in source) || !("baseFallbacks" in source)) return;
|
|
3921
|
-
const resolved = await
|
|
3969
|
+
const resolved = await require_tailwindcss.resolveTailwindV4EntriesFromCss(sourceMetadata?.sourceCss ?? source.css, sourceMetadata?.sourceBase ?? source.base);
|
|
3922
3970
|
if (resolved?.entries.length === 0 && !resolved.inlineCandidates.included.size && !resolved.inlineCandidates.excluded.size && !resolved.dependencies.length) {
|
|
3923
3971
|
if (sourceMetadata?.matchedCssSourceFile) return [];
|
|
3924
3972
|
return;
|
|
@@ -3929,12 +3977,12 @@ async function resolveGeneratorSourceEntries(record, runtimeState) {
|
|
|
3929
3977
|
return cssSource.css === source.css;
|
|
3930
3978
|
});
|
|
3931
3979
|
if (!matchingCssSource) return resolved?.entries;
|
|
3932
|
-
const sourceResolved = await
|
|
3980
|
+
const sourceResolved = await require_tailwindcss.resolveTailwindV4EntriesFromCss(matchingCssSource.css, typeof matchingCssSource.base === "string" && matchingCssSource.base.length > 0 ? matchingCssSource.base : typeof matchingCssSource.file === "string" && matchingCssSource.file.length > 0 ? node_path.default.dirname(matchingCssSource.file) : source.base);
|
|
3933
3981
|
if (sourceResolved?.entries.length) return sourceResolved.entries;
|
|
3934
3982
|
for (const dependency of matchingCssSource.dependencies ?? []) {
|
|
3935
3983
|
if (!(0, node_fs.existsSync)(dependency)) continue;
|
|
3936
3984
|
try {
|
|
3937
|
-
const dependencyResolved = await
|
|
3985
|
+
const dependencyResolved = await require_tailwindcss.resolveTailwindV4EntriesFromCss((0, node_fs.readFileSync)(dependency, "utf8"), node_path.default.dirname(dependency));
|
|
3938
3986
|
if (dependencyResolved?.entries.length) return dependencyResolved.entries;
|
|
3939
3987
|
} catch {}
|
|
3940
3988
|
}
|
|
@@ -4896,6 +4944,7 @@ async function executeGeneratorPipeline(context) {
|
|
|
4896
4944
|
async function executeGeneratorPipelineWithOwner(context, compilationPool, generationSession) {
|
|
4897
4945
|
const { cssHandlerOptions, debug, file, generatorBranch, generatorOptions, generatorRawSource, getSourceCandidatesForEntries, hasGeneratedCss, hasGeneratedMarkers, localImports, majorVersion, normalizeGeneratorSource, normalizedCssSources, options, opts, runtime, runtimeState, useMiniProgramCssBranch } = context;
|
|
4898
4946
|
await runtimeState.readyPromise;
|
|
4947
|
+
const compilerSession = options.compilation?.enabled ? getFrameworkCompilerSession(runtimeState, opts) : void 0;
|
|
4899
4948
|
const currentCssCandidates = collectGeneratorCssCandidates(generatorRawSource);
|
|
4900
4949
|
const isolateCurrentCssCandidates = shouldIsolateCurrentTailwindV4CssCandidates(majorVersion, cssHandlerOptions, {
|
|
4901
4950
|
hasGeneratedCss,
|
|
@@ -4958,16 +5007,26 @@ async function executeGeneratorPipelineWithOwner(context, compilationPool, gener
|
|
|
4958
5007
|
}), sourceConcurrency)).filter((item) => Boolean(item));
|
|
4959
5008
|
const generatePreparedInputs = async (candidateSets) => {
|
|
4960
5009
|
return runWithConcurrency(preparedGenerationInputs.map((input) => async () => {
|
|
4961
|
-
const
|
|
5010
|
+
const projectedCandidates = candidateSets?.get(input.sourceId);
|
|
5011
|
+
const currentCandidates = projectedCandidates ? /* @__PURE__ */ new Set([...input.generatorRuntime, ...projectedCandidates]) : input.generatorRuntime;
|
|
5012
|
+
const generateOptions = {
|
|
5013
|
+
bareArbitraryValues: generatorOptions.bareArbitraryValues,
|
|
5014
|
+
candidates: currentCandidates,
|
|
5015
|
+
incrementalCache: options.incrementalCache ?? true,
|
|
5016
|
+
scanSources: options.disableSourceScan === true ? false : shouldScanTailwindV4Sources(majorVersion, generatorOptions.target, currentCandidates, input.isolateCssSource),
|
|
5017
|
+
styleOptions: generatorStyleOptions,
|
|
5018
|
+
target: generatorOptions.target
|
|
5019
|
+
};
|
|
5020
|
+
let generated;
|
|
5021
|
+
if (compilerSession && input.generatorSource) try {
|
|
5022
|
+
generated = await compilerSession.generate(options.compilation?.scope.id ?? options.outputFile ?? file, input.sourceId, input.generatorSource, generateOptions);
|
|
5023
|
+
} catch (error) {
|
|
5024
|
+
if (!(error instanceof TypeError) || !String(error.message).includes("dependencies")) throw error;
|
|
5025
|
+
generated = await generationSession.generate(input.generatorSource, generateOptions);
|
|
5026
|
+
}
|
|
5027
|
+
else generated = await generationSession.generate(input.generatorSource, generateOptions);
|
|
4962
5028
|
return {
|
|
4963
|
-
generated
|
|
4964
|
-
bareArbitraryValues: generatorOptions.bareArbitraryValues,
|
|
4965
|
-
candidates: currentCandidates,
|
|
4966
|
-
incrementalCache: options.incrementalCache ?? true,
|
|
4967
|
-
scanSources: options.disableSourceScan === true ? false : shouldScanTailwindV4Sources(majorVersion, generatorOptions.target, currentCandidates, input.isolateCssSource),
|
|
4968
|
-
styleOptions: generatorStyleOptions,
|
|
4969
|
-
target: generatorOptions.target
|
|
4970
|
-
}),
|
|
5029
|
+
generated,
|
|
4971
5030
|
sourceId: input.sourceId
|
|
4972
5031
|
};
|
|
4973
5032
|
}), sourceConcurrency);
|
|
@@ -4988,12 +5047,18 @@ async function executeGeneratorPipelineWithOwner(context, compilationPool, gener
|
|
|
4988
5047
|
})),
|
|
4989
5048
|
preserveDeletedCss: options.compilation.preserveDeletedCss
|
|
4990
5049
|
}, async (compilation) => {
|
|
5050
|
+
if (compilerSession && options.compilation?.changes) compilerSession.invalidate(options.compilation.changes.map((change) => change.id));
|
|
5051
|
+
await compilerSession?.syncScope(options.compilation?.scope.id ?? options.outputFile ?? file, preparedGenerationInputs.map((input) => input.sourceId));
|
|
4991
5052
|
const results = await generatePreparedInputs(compilation.candidatesBySource);
|
|
4992
5053
|
const merged = mergeGeneratorResults(results.map((result) => result.generated));
|
|
4993
5054
|
return merged ? {
|
|
4994
5055
|
classSet: merged.classSet,
|
|
4995
5056
|
dependenciesBySource: results.map((result) => [result.sourceId, resolveCompilationDependencies(result.generated.dependencies)]),
|
|
4996
|
-
generated: merged
|
|
5057
|
+
generated: merged,
|
|
5058
|
+
...compilerSession ? (() => {
|
|
5059
|
+
const snapshots = results.map((result) => result.generated.snapshot).filter((snapshot) => snapshot !== void 0);
|
|
5060
|
+
return snapshots.length > 0 ? { snapshot: compilerSession.mergeSnapshots(snapshots) } : {};
|
|
5061
|
+
})() : {}
|
|
4997
5062
|
} : void 0;
|
|
4998
5063
|
});
|
|
4999
5064
|
if (!execution.committed) {
|
|
@@ -5001,6 +5066,10 @@ async function executeGeneratorPipelineWithOwner(context, compilationPool, gener
|
|
|
5001
5066
|
return;
|
|
5002
5067
|
}
|
|
5003
5068
|
generated = execution.value?.generated;
|
|
5069
|
+
if (generated && execution.value?.snapshot) generated = {
|
|
5070
|
+
...generated,
|
|
5071
|
+
snapshot: execution.value.snapshot
|
|
5072
|
+
};
|
|
5004
5073
|
compilationRevision = execution.compilation.revision;
|
|
5005
5074
|
} else generated = mergeGeneratorResults((await generatePreparedInputs()).map((result) => result.generated));
|
|
5006
5075
|
if (!generated) return;
|
|
@@ -5013,7 +5082,7 @@ async function executeGeneratorPipelineWithOwner(context, compilationPool, gener
|
|
|
5013
5082
|
const appEntryMatchedByCandidates = metadata?.candidateMatchedCssSource === true && metadata.cssEntryIndex === 0 && metadata.cssSourceIndex === void 0;
|
|
5014
5083
|
return metadata?.includesPreflight === true && !appEntryMatchedByCandidates;
|
|
5015
5084
|
});
|
|
5016
|
-
const hasPreflightRawSource =
|
|
5085
|
+
const hasPreflightRawSource = require_tailwindcss.includesTailwindV4PreflightDirective(generatorRawSource);
|
|
5017
5086
|
const hasOnlyPrimaryCssSource = generatorSourceRecords.length > 0 && generatorSourceRecords.every(({ metadata }) => {
|
|
5018
5087
|
return metadata?.candidateMatchedCssSource !== true && metadata?.primaryCssSource === true;
|
|
5019
5088
|
});
|
|
@@ -5034,6 +5103,11 @@ async function executeGeneratorPipelineWithOwner(context, compilationPool, gener
|
|
|
5034
5103
|
});
|
|
5035
5104
|
const outputContext = {
|
|
5036
5105
|
...context,
|
|
5106
|
+
...compilerSession && options.compilation?.preserveDeletedCss !== true ? { options: {
|
|
5107
|
+
...context.options,
|
|
5108
|
+
previousClassSet: void 0,
|
|
5109
|
+
previousCss: void 0
|
|
5110
|
+
} } : {},
|
|
5037
5111
|
configuredContainerCompat,
|
|
5038
5112
|
filterGeneratedApplyOnlyCss,
|
|
5039
5113
|
generated,
|
|
@@ -5340,7 +5414,11 @@ async function generateTailwindV4CssWithImplementation(options, implementation)
|
|
|
5340
5414
|
file: options.file,
|
|
5341
5415
|
majorVersion,
|
|
5342
5416
|
rawCandidates: options.runtime,
|
|
5343
|
-
styleHandler: options.styleHandler
|
|
5417
|
+
styleHandler: options.styleHandler,
|
|
5418
|
+
...implementation.frameworkAdapter === "graph" && generated.snapshot ? {
|
|
5419
|
+
compiler: getFrameworkCompilerSession(options.runtimeState, options.opts).compiler,
|
|
5420
|
+
snapshot: generated.snapshot
|
|
5421
|
+
} : {}
|
|
5344
5422
|
}) : generated.css;
|
|
5345
5423
|
const css = isVueScopedStyleRequest(resolvePostcssRequestOption(options.cssHandlerOptions)) ? require_generator.preferScopedGeneratedCssRules(adaptedCss) : adaptedCss;
|
|
5346
5424
|
const artifact = implementation.emitArtifact ? createCoreArtifact(generated, css, options) : void 0;
|