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.
Files changed (92) hide show
  1. package/README.md +3 -3
  2. package/README.zh-CN.md +4 -4
  3. package/dist/bundlers/shared/framework-postcss.d.ts +3 -0
  4. package/dist/bundlers/shared/generator-css/result-helpers.d.ts +1 -1
  5. package/dist/bundlers/shared/generator-css/source-resolver/single-source.d.ts +1 -1
  6. package/dist/bundlers/shared/generator-css/types.d.ts +3 -1
  7. package/dist/bundlers/shared/source-candidates/snapshot.d.ts +19 -0
  8. package/dist/bundlers/shared/source-candidates/source-priority.d.ts +1 -0
  9. package/dist/bundlers/shared/source-candidates/types-and-cache.d.ts +1 -0
  10. package/dist/bundlers/shared/source-candidates/views.d.ts +12 -0
  11. package/dist/bundlers/shared/style-requests.d.ts +1 -0
  12. package/dist/bundlers/vite/bundle-state.d.ts +9 -1
  13. package/dist/bundlers/vite/capability-profile.d.ts +18 -0
  14. package/dist/bundlers/vite/generate-bundle/js-processing.d.ts +12 -0
  15. package/dist/bundlers/vite/hot-css-modules.d.ts +2 -2
  16. package/dist/bundlers/vite/shared/configured-css-entry-observer.d.ts +29 -0
  17. package/dist/bundlers/vite/shared/create-framework-plugins.d.ts +8 -0
  18. package/dist/bundlers/vite/shared/framework-css-generation-queue.d.ts +1 -0
  19. package/dist/bundlers/vite/shared/framework-hmr-module-version.d.ts +9 -0
  20. package/dist/bundlers/vite/shared/framework-runtime-utils.d.ts +5 -0
  21. package/dist/bundlers/vite/shared/framework-source-scan-session.d.ts +12 -2
  22. package/dist/compiler/compilation-session-pool.d.ts +1 -0
  23. package/dist/compiler/framework-compiler-session.d.ts +21 -0
  24. package/dist/compiler/index.d.ts +1 -0
  25. package/dist/{context-DTLRADfE.cjs → compiler-C93NfxSe.cjs} +859 -11
  26. package/dist/{context-4ittVpgt.js → compiler-qDa3phIv.js} +764 -5
  27. package/dist/context/handlers.d.ts +1 -1
  28. package/dist/core/compiler/compiler.d.ts +2 -0
  29. package/dist/core/compiler/generation-cache.d.ts +30 -0
  30. package/dist/core/compiler/generation-state.d.ts +17 -0
  31. package/dist/core/compiler/index.d.ts +2 -0
  32. package/dist/core/compiler/root-store.d.ts +38 -0
  33. package/dist/core/compiler/snapshot.d.ts +35 -0
  34. package/dist/core/compiler/source-fingerprint.d.ts +3 -0
  35. package/dist/core/compiler/transforms.d.ts +15 -0
  36. package/dist/core/compiler/types.d.ts +69 -0
  37. package/dist/core.cjs +9 -8
  38. package/dist/core.d.ts +2 -1
  39. package/dist/core.js +2 -2
  40. package/dist/framework/index.d.ts +3 -1
  41. package/dist/framework.cjs +6 -1
  42. package/dist/framework.js +6 -1
  43. package/dist/{generator-EnTXLBlK.js → generator-C0m2S4WI.js} +3 -2
  44. package/dist/{generator-DKiYbTFR.cjs → generator-CKJ6sj1f.cjs} +3 -2
  45. package/dist/generator.cjs +1 -1
  46. package/dist/generator.js +1 -1
  47. package/dist/{gulp-CUysZjW3.cjs → gulp-CW6JGqVn.cjs} +14 -16
  48. package/dist/{gulp-DwtrU4V1.js → gulp-e2iWsmEK.js} +7 -7
  49. package/dist/gulp.cjs +1 -1
  50. package/dist/gulp.js +1 -1
  51. package/dist/{hmr-timing-utmOgn6p.js → hmr-timing-DgMgwSce.js} +367 -289
  52. package/dist/{hmr-timing-Cvh5UgnM.cjs → hmr-timing-n7QQKFp7.cjs} +4 -4
  53. package/dist/index.cjs +4 -4
  54. package/dist/index.js +4 -4
  55. package/dist/{pipeline-helpers-CyVXL3h6.cjs → pipeline-helpers-DoLQy44Q.cjs} +6 -6
  56. package/dist/postcss.cjs +1 -1
  57. package/dist/postcss.js +1 -1
  58. package/dist/presets.cjs +2 -3
  59. package/dist/presets.js +1 -1
  60. package/dist/rspack.cjs +2 -2
  61. package/dist/rspack.js +2 -2
  62. package/dist/{source-candidate-scan-signature-CDrLxVKu.js → source-candidate-scan-signature-B0lOMiwB.js} +3 -3
  63. package/dist/{source-candidate-scan-signature-BNt7NrrI.cjs → source-candidate-scan-signature-Chb-Zrwt.cjs} +5 -5
  64. package/dist/{tailwindcss-CexDJBhx.cjs → tailwindcss-BGlJ1m1l.cjs} +763 -5
  65. package/dist/{tailwindcss-ChnpCv25.js → tailwindcss-BSKl0FTD.js} +1 -1
  66. package/dist/{transform-AfnwH_yx.cjs → transform-C6k9zTQR.cjs} +16 -7
  67. package/dist/{transform-BMPNt_vj.js → transform-DQhgAarN.js} +16 -7
  68. package/dist/typedoc.export.d.ts +1 -0
  69. package/dist/types/index.d.ts +1 -0
  70. package/dist/uni-app-x/component-local-style.d.ts +2 -0
  71. package/dist/uni-app-x/transform.d.ts +1 -0
  72. package/dist/uni-app-x/vite/asset-task.d.ts +21 -0
  73. package/dist/uni-app-x/vite/plugin-options.d.ts +8 -0
  74. package/dist/uni-app-x/vite/web-local-style.d.ts +2 -1
  75. package/dist/uni-app-x/vite.d.ts +1 -21
  76. package/dist/{v4-generation-core-Dhsu9Deu.cjs → v4-generation-core-B2sUkkgq.cjs} +378 -300
  77. package/dist/{vite-qxEVovZD.cjs → vite-B0IPgrvM.cjs} +807 -200
  78. package/dist/{vite-mWyHvLB0.js → vite-CcEb2SOl.js} +774 -165
  79. package/dist/vite.cjs +1 -1
  80. package/dist/vite.js +1 -1
  81. package/dist/weapp-tw-css-generation-loader.cjs +1 -1
  82. package/dist/weapp-tw-css-import-rewrite-loader.cjs +7 -7
  83. package/dist/{webpack-Cpy_yggg.cjs → webpack-B5vc13U_.cjs} +33 -35
  84. package/dist/{webpack-CzhrD9p3.js → webpack-BPA5I79o.js} +7 -7
  85. package/dist/webpack.cjs +1 -1
  86. package/dist/webpack.js +1 -1
  87. package/dist/wxml/utils.d.ts +1 -1
  88. package/dist/{wxml-B7OAVpXJ.js → wxml-CvKyV69S.js} +10 -2
  89. package/dist/{wxml-PrK-8ARX.cjs → wxml-o-CUulAM.cjs} +40 -32
  90. package/package.json +12 -11
  91. package/dist/options-BJrtIQbH.cjs +0 -768
  92. package/dist/style-options-DW30H5PV.cjs +0 -82
@@ -1,13 +1,11 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-Ctb5zv51.cjs");
2
2
  const require_framework = require("./framework.cjs");
3
- const require_generator = require("./generator-DKiYbTFR.cjs");
3
+ const require_generator = require("./generator-CKJ6sj1f.cjs");
4
4
  const require_object = require("./object-DbHtAXRk.cjs");
5
- const require_options = require("./options-BJrtIQbH.cjs");
5
+ const require_tailwindcss = require("./tailwindcss-BGlJ1m1l.cjs");
6
6
  require("./utils-CuKLf1Zv.cjs");
7
- const require_wxml = require("./wxml-PrK-8ARX.cjs");
7
+ const require_wxml = require("./wxml-o-CUulAM.cjs");
8
8
  const require_defaults = require("./defaults.cjs");
9
- const require_tailwindcss = require("./tailwindcss-CexDJBhx.cjs");
10
- const require_style_options = require("./style-options-DW30H5PV.cjs");
11
9
  let node_path = require("node:path");
12
10
  node_path = require_rolldown_runtime.__toESM(node_path, 1);
13
11
  let node_process = require("node:process");
@@ -17,10 +15,532 @@ let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
17
15
  let lru_cache = require("lru-cache");
18
16
  let node_module = require("node:module");
19
17
  let node_fs_promises = require("node:fs/promises");
20
- let _weapp_tailwindcss_logger = require("@weapp-tailwindcss/logger");
21
18
  let node_buffer = require("node:buffer");
19
+ let _weapp_tailwindcss_logger = require("@weapp-tailwindcss/logger");
22
20
  let _weapp_tailwindcss_shared_node = require("@weapp-tailwindcss/shared/node");
23
21
  let _weapp_tailwindcss_shared = require("@weapp-tailwindcss/shared");
22
+ //#region src/compiler/candidate-index.ts
23
+ var CandidateIndex = class {
24
+ constructor() {
25
+ require_object._defineProperty(this, "candidatesBySource", /* @__PURE__ */ new Map());
26
+ }
27
+ sync(sourceId, candidates) {
28
+ const previous = this.candidatesBySource.get(sourceId) ?? /* @__PURE__ */ new Set();
29
+ const next = new Set(candidates);
30
+ const addedCandidates = new Set([...next].filter((candidate) => !previous.has(candidate)));
31
+ const removedCandidates = new Set([...previous].filter((candidate) => !next.has(candidate)));
32
+ this.candidatesBySource.set(sourceId, next);
33
+ return {
34
+ sourceId,
35
+ addedCandidates,
36
+ removedCandidates
37
+ };
38
+ }
39
+ remove(sourceId) {
40
+ const previous = this.candidatesBySource.get(sourceId) ?? /* @__PURE__ */ new Set();
41
+ this.candidatesBySource.delete(sourceId);
42
+ return {
43
+ sourceId,
44
+ addedCandidates: /* @__PURE__ */ new Set(),
45
+ removedCandidates: new Set(previous)
46
+ };
47
+ }
48
+ values() {
49
+ const values = /* @__PURE__ */ new Set();
50
+ for (const candidates of this.candidatesBySource.values()) for (const candidate of candidates) values.add(candidate);
51
+ return values;
52
+ }
53
+ get(sourceId) {
54
+ return new Set(this.candidatesBySource.get(sourceId) ?? []);
55
+ }
56
+ entries() {
57
+ return new Map([...this.candidatesBySource].map(([sourceId, candidates]) => [sourceId, new Set(candidates)]));
58
+ }
59
+ clear() {
60
+ this.candidatesBySource.clear();
61
+ }
62
+ };
63
+ //#endregion
64
+ //#region src/compiler/invalidation.ts
65
+ function resolveInvalidatedScopes(graph, changes) {
66
+ const invalidatedScopes = /* @__PURE__ */ new Set();
67
+ const visit = (sourceId, visited) => {
68
+ if (visited.has(sourceId)) return;
69
+ visited.add(sourceId);
70
+ const node = graph.getNode(sourceId);
71
+ if (node) invalidatedScopes.add(node.scope.id);
72
+ for (const dependent of graph.getDependents(sourceId)) visit(dependent, visited);
73
+ };
74
+ for (const change of changes) visit(change.sourceId, /* @__PURE__ */ new Set());
75
+ return invalidatedScopes;
76
+ }
77
+ //#endregion
78
+ //#region src/compiler/source-graph.ts
79
+ var SourceGraph = class {
80
+ constructor() {
81
+ require_object._defineProperty(this, "edges", /* @__PURE__ */ new Map());
82
+ require_object._defineProperty(this, "nodes", /* @__PURE__ */ new Map());
83
+ }
84
+ replace(nodes, edges) {
85
+ this.clear();
86
+ for (const node of nodes) this.nodes.set(node.id, {
87
+ ...node,
88
+ scope: { ...node.scope }
89
+ });
90
+ for (const edge of edges) {
91
+ if (!this.nodes.has(edge.from) || !this.nodes.has(edge.to)) throw new Error(`编译图边引用了不存在的节点:${edge.from} -> ${edge.to}`);
92
+ this.edges.set(this.edgeKey(edge), { ...edge });
93
+ }
94
+ }
95
+ getNode(id) {
96
+ const node = this.nodes.get(id);
97
+ return node ? {
98
+ ...node,
99
+ scope: { ...node.scope }
100
+ } : void 0;
101
+ }
102
+ getNodes() {
103
+ return [...this.nodes.values()].map((node) => ({
104
+ ...node,
105
+ scope: { ...node.scope }
106
+ }));
107
+ }
108
+ getEdges() {
109
+ return [...this.edges.values()].map((edge) => ({ ...edge }));
110
+ }
111
+ getDependents(id) {
112
+ return this.getEdges().filter((edge) => edge.to === id).map((edge) => edge.from);
113
+ }
114
+ clear() {
115
+ this.edges.clear();
116
+ this.nodes.clear();
117
+ }
118
+ edgeKey(edge) {
119
+ return `${edge.kind}\0${edge.from}\0${edge.to}`;
120
+ }
121
+ };
122
+ //#endregion
123
+ //#region src/compiler/session.ts
124
+ var DefaultCompilationSession = class {
125
+ constructor() {
126
+ require_object._defineProperty(this, "candidateIndex", new CandidateIndex());
127
+ require_object._defineProperty(this, "graph", new SourceGraph());
128
+ require_object._defineProperty(this, "retainedCandidates", /* @__PURE__ */ new Set());
129
+ require_object._defineProperty(this, "validatedClassSet", /* @__PURE__ */ new Set());
130
+ require_object._defineProperty(this, "invalidatedScopes", /* @__PURE__ */ new Set());
131
+ require_object._defineProperty(this, "revision", 0);
132
+ }
133
+ update(snapshot) {
134
+ const changes = [...snapshot.changes ?? []];
135
+ const invalidatedScopes = resolveInvalidatedScopes(this.graph, changes);
136
+ this.graph.replace(snapshot.nodes, snapshot.edges);
137
+ for (const [sourceId, candidates] of snapshot.candidatesBySource ?? []) {
138
+ const change = this.candidateIndex.sync(sourceId, candidates);
139
+ if (change.addedCandidates.size > 0 || change.removedCandidates.size > 0) changes.push(change);
140
+ }
141
+ for (const change of changes) if ("type" in change && change.type === "source-removed") this.candidateIndex.remove(change.sourceId);
142
+ const currentCandidates = this.candidateIndex.values();
143
+ if (snapshot.preserveDeletedCss) for (const candidate of currentCandidates) this.retainedCandidates.add(candidate);
144
+ else {
145
+ this.retainedCandidates.clear();
146
+ for (const candidate of currentCandidates) this.retainedCandidates.add(candidate);
147
+ }
148
+ if (snapshot.validatedClassSet !== void 0) this.validatedClassSet = new Set(snapshot.validatedClassSet);
149
+ else if (!snapshot.preserveDeletedCss) this.validatedClassSet = new Set([...this.validatedClassSet].filter((candidate) => this.retainedCandidates.has(candidate)));
150
+ this.revision += 1;
151
+ for (const scopeId of resolveInvalidatedScopes(this.graph, changes)) invalidatedScopes.add(scopeId);
152
+ this.invalidatedScopes = invalidatedScopes;
153
+ return this.createResult();
154
+ }
155
+ commitValidation(revision, validatedClassSet, graph) {
156
+ if (revision !== this.revision) throw new Error(`不能向编译 revision ${this.revision} 提交 revision ${revision} 的 classSet。`);
157
+ if (graph) this.graph.replace(graph.nodes, graph.edges);
158
+ this.validatedClassSet = new Set(validatedClassSet);
159
+ return this.createResult();
160
+ }
161
+ createResult() {
162
+ return {
163
+ revision: this.revision,
164
+ candidates: new Set(this.retainedCandidates),
165
+ candidatesBySource: this.candidateIndex.entries(),
166
+ validatedClassSet: new Set(this.validatedClassSet),
167
+ invalidatedScopes: new Set(this.invalidatedScopes),
168
+ graphEdges: this.graph.getEdges(),
169
+ graphNodes: this.graph.getNodes()
170
+ };
171
+ }
172
+ dispose() {
173
+ this.candidateIndex.clear();
174
+ this.graph.clear();
175
+ this.retainedCandidates.clear();
176
+ this.validatedClassSet.clear();
177
+ this.invalidatedScopes.clear();
178
+ this.revision = 0;
179
+ }
180
+ };
181
+ //#endregion
182
+ //#region src/core/compiler/source-fingerprint.ts
183
+ function stableSerialize(value, stack = /* @__PURE__ */ new WeakSet()) {
184
+ if (value == null || typeof value === "number" || typeof value === "boolean" || typeof value === "string") return JSON.stringify(value);
185
+ if (typeof value === "function") return `[Function:${value.name}]`;
186
+ if (typeof value !== "object") return String(value);
187
+ if (stack.has(value)) return "[Circular]";
188
+ stack.add(value);
189
+ const serialized = Array.isArray(value) ? `[${value.map((item) => stableSerialize(item, stack)).join(",")}]` : `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${stableSerialize(value[key], stack)}`).join(",")}}`;
190
+ stack.delete(value);
191
+ return serialized;
192
+ }
193
+ function createSourceFingerprint(source) {
194
+ return createCompilerValueFingerprint(source);
195
+ }
196
+ function createCompilerValueFingerprint(value) {
197
+ return (0, _weapp_tailwindcss_shared_node.md5)(stableSerialize(value));
198
+ }
199
+ //#endregion
200
+ //#region src/core/compiler/generation-cache.ts
201
+ function createCompilerGenerationCacheKey(request, candidates, target) {
202
+ return {
203
+ bareArbitraryValues: request.bareArbitraryValues,
204
+ candidateSignature: [...candidates].sort().join("\0"),
205
+ incrementalCache: request.incrementalCache,
206
+ scanSources: request.scanSources,
207
+ sourcesFingerprint: request.sources === void 0 ? void 0 : createCompilerValueFingerprint(request.sources),
208
+ styleOptionsFingerprint: request.styleOptions === void 0 ? void 0 : createCompilerValueFingerprint(request.styleOptions),
209
+ target
210
+ };
211
+ }
212
+ function isSameCompilerGenerationCacheKey(left, right) {
213
+ return left.bareArbitraryValues === right.bareArbitraryValues && left.candidateSignature === right.candidateSignature && left.incrementalCache === right.incrementalCache && left.scanSources === right.scanSources && left.sourcesFingerprint === right.sourcesFingerprint && left.styleOptionsFingerprint === right.styleOptionsFingerprint && left.target === right.target;
214
+ }
215
+ function reuseCompilerGenerationResult(result) {
216
+ return {
217
+ ...result,
218
+ incrementalCss: "",
219
+ incrementalRawCss: ""
220
+ };
221
+ }
222
+ //#endregion
223
+ //#region src/core/compiler/generation-state.ts
224
+ function createGenerationGraph(rootId, source, dependencies) {
225
+ const scope = {
226
+ id: rootId,
227
+ kind: "global"
228
+ };
229
+ const dependencyIds = [...new Set(dependencies)].filter((id) => id !== rootId).sort();
230
+ const nodes = [{
231
+ content: source.css,
232
+ id: rootId,
233
+ kind: "css",
234
+ scope
235
+ }, ...dependencyIds.map((id) => ({
236
+ id,
237
+ kind: "config",
238
+ scope
239
+ }))];
240
+ return {
241
+ edges: dependencyIds.map((id) => ({
242
+ from: rootId,
243
+ kind: "depends-on",
244
+ to: id
245
+ })),
246
+ nodes
247
+ };
248
+ }
249
+ function prepareCompilerGeneration(entry, request, source, sourceChanged) {
250
+ const explicitCandidates = request.candidates !== void 0;
251
+ const candidates = explicitCandidates ? [...request.candidates] : [];
252
+ const candidateSignature = [...candidates].sort().join("\0");
253
+ if (!sourceChanged && entry.compilationCache?.candidateSignature === candidateSignature && entry.compilationCache.compilation.revision === entry.compilationRevision) return {
254
+ ...entry.compilationCache,
255
+ explicitCandidates
256
+ };
257
+ const graph = createGenerationGraph(entry.id, source, source.dependencies);
258
+ const compilation = entry.compilation.update({
259
+ ...graph,
260
+ candidatesBySource: [[entry.id, candidates]],
261
+ changes: sourceChanged ? [{
262
+ sourceId: entry.id,
263
+ type: "dependency-changed"
264
+ }] : void 0
265
+ });
266
+ entry.compilationRevision = compilation.revision;
267
+ return {
268
+ candidateSignature,
269
+ compilation,
270
+ explicitCandidates,
271
+ graph
272
+ };
273
+ }
274
+ function commitCompilerGeneration(entry, prepared, source, dependencies, classSet) {
275
+ const graph = createGenerationGraph(entry.id, source, dependencies);
276
+ const compilation = entry.compilation.commitValidation(prepared.compilation.revision, classSet, graph);
277
+ entry.compilationCache = {
278
+ candidateSignature: prepared.candidateSignature,
279
+ compilation,
280
+ graph
281
+ };
282
+ }
283
+ //#endregion
284
+ //#region src/core/compiler/root-store.ts
285
+ function disposeGenerator(generator) {
286
+ generator?.dispose?.();
287
+ }
288
+ var CompilerRootStore = class {
289
+ constructor(maxRoots) {
290
+ this.maxRoots = maxRoots;
291
+ require_object._defineProperty(this, "dependencyRoots", /* @__PURE__ */ new Map());
292
+ require_object._defineProperty(this, "releasing", /* @__PURE__ */ new Map());
293
+ require_object._defineProperty(this, "roots", /* @__PURE__ */ new Map());
294
+ }
295
+ get(id) {
296
+ if (!id) throw new Error("Compiler root id 不能为空。");
297
+ if (this.releasing.has(id)) throw new Error(`Compiler root 正在移除:${id}`);
298
+ const cached = this.roots.get(id);
299
+ if (cached) {
300
+ if (!cached.accepting) throw new Error(`Compiler root 正在移除:${id}`);
301
+ this.roots.delete(id);
302
+ this.roots.set(id, cached);
303
+ return cached;
304
+ }
305
+ if (this.roots.size >= this.maxRoots) {
306
+ const oldest = [...this.roots.values()].find((entry) => entry.pendingCount === 0);
307
+ if (oldest) this.remove(oldest.id);
308
+ }
309
+ const entry = {
310
+ accepting: true,
311
+ active: true,
312
+ appliedInvalidation: 0,
313
+ compilation: new DefaultCompilationSession(),
314
+ compilationRevision: 0,
315
+ dependencies: /* @__PURE__ */ new Set(),
316
+ id,
317
+ invalidation: 0,
318
+ pending: Promise.resolve(),
319
+ pendingCount: 0
320
+ };
321
+ this.roots.set(id, entry);
322
+ return entry;
323
+ }
324
+ attachDependencies(entry, dependencies) {
325
+ this.detachDependencies(entry);
326
+ if (!entry.accepting) return;
327
+ for (const dependency of dependencies) {
328
+ entry.dependencies.add(dependency);
329
+ let owners = this.dependencyRoots.get(dependency);
330
+ if (!owners) {
331
+ owners = /* @__PURE__ */ new Set();
332
+ this.dependencyRoots.set(dependency, owners);
333
+ }
334
+ owners.add(entry.id);
335
+ }
336
+ }
337
+ invalidate(ids) {
338
+ const affected = /* @__PURE__ */ new Set();
339
+ for (const id of ids) {
340
+ const root = this.roots.get(id);
341
+ if (root?.accepting) affected.add(root.id);
342
+ for (const rootId of this.dependencyRoots.get(id) ?? []) affected.add(rootId);
343
+ }
344
+ for (const rootId of affected) {
345
+ const entry = this.roots.get(rootId);
346
+ if (entry?.accepting) entry.invalidation += 1;
347
+ }
348
+ return Object.freeze([...affected].sort());
349
+ }
350
+ trim() {
351
+ while (this.roots.size > this.maxRoots) {
352
+ const oldest = [...this.roots.values()].find((entry) => entry.pendingCount === 0);
353
+ if (!oldest) return;
354
+ this.remove(oldest.id);
355
+ }
356
+ }
357
+ remove(id) {
358
+ const pendingRelease = this.releasing.get(id);
359
+ if (pendingRelease) return pendingRelease;
360
+ const entry = this.roots.get(id);
361
+ if (!entry) return Promise.resolve();
362
+ entry.accepting = false;
363
+ this.roots.delete(id);
364
+ this.detachDependencies(entry);
365
+ const release = entry.pending.then(() => {
366
+ entry.active = false;
367
+ entry.compilation.dispose();
368
+ entry.compilationCache = void 0;
369
+ disposeGenerator(entry.generator);
370
+ entry.generator = void 0;
371
+ entry.generationCache = void 0;
372
+ entry.latestSnapshot = void 0;
373
+ entry.source = void 0;
374
+ entry.sourceInput = void 0;
375
+ entry.sourceFingerprint = void 0;
376
+ }).finally(() => {
377
+ this.releasing.delete(id);
378
+ });
379
+ this.releasing.set(id, release);
380
+ return release;
381
+ }
382
+ async dispose() {
383
+ await Promise.all([...[...this.roots.keys()].map((id) => this.remove(id)), ...this.releasing.values()]);
384
+ this.dependencyRoots.clear();
385
+ }
386
+ detachDependencies(entry) {
387
+ for (const dependency of entry.dependencies) {
388
+ const owners = this.dependencyRoots.get(dependency);
389
+ owners?.delete(entry.id);
390
+ if (owners?.size === 0) this.dependencyRoots.delete(dependency);
391
+ }
392
+ entry.dependencies.clear();
393
+ }
394
+ };
395
+ //#endregion
396
+ //#region src/core/compiler/snapshot.ts
397
+ const readonlySetValues = /* @__PURE__ */ new WeakMap();
398
+ const snapshotRegistry = /* @__PURE__ */ new WeakMap();
399
+ var ImmutableSetView = class {
400
+ constructor(values) {
401
+ readonlySetValues.set(this, new Set(values));
402
+ Object.freeze(this);
403
+ }
404
+ get size() {
405
+ return this.valuesSet.size;
406
+ }
407
+ get [Symbol.toStringTag]() {
408
+ return "Set";
409
+ }
410
+ has(value) {
411
+ return this.valuesSet.has(value);
412
+ }
413
+ entries() {
414
+ return this.valuesSet.entries();
415
+ }
416
+ keys() {
417
+ return this.valuesSet.keys();
418
+ }
419
+ values() {
420
+ return this.valuesSet.values();
421
+ }
422
+ forEach(callbackfn, thisArg) {
423
+ for (const value of this.valuesSet) callbackfn.call(thisArg, value, value, this);
424
+ }
425
+ [Symbol.iterator]() {
426
+ return this.values();
427
+ }
428
+ get valuesSet() {
429
+ return readonlySetValues.get(this);
430
+ }
431
+ };
432
+ function uniqueSorted(values) {
433
+ return Object.freeze([...new Set(values)].sort());
434
+ }
435
+ function sourceKey(source) {
436
+ return `${source.base}\0${source.pattern}\0${source.negated ? "1" : "0"}`;
437
+ }
438
+ function uniqueSortedSources(sources) {
439
+ const values = /* @__PURE__ */ new Map();
440
+ for (const source of sources) {
441
+ const cloned = Object.freeze({ ...source });
442
+ values.set(sourceKey(cloned), cloned);
443
+ }
444
+ return Object.freeze([...values.entries()].sort(([left], [right]) => left.localeCompare(right)).map(([, value]) => value));
445
+ }
446
+ function createRootFingerprint(root, target, classSet, dependencies, sources) {
447
+ return [
448
+ root.id,
449
+ String(root.revision),
450
+ target,
451
+ ...[...classSet].sort(),
452
+ ...dependencies,
453
+ ...[...sources].map(sourceKey)
454
+ ].join("\0");
455
+ }
456
+ function createSnapshotFromState(state, reusableClassSet, reusableClassSetView) {
457
+ const roots = Object.freeze([...state.roots.values()].sort((left, right) => left.id.localeCompare(right.id)).map(({ id, revision }) => Object.freeze({
458
+ id,
459
+ revision
460
+ })));
461
+ const classSet = reusableClassSet ?? new Set(state.classSet);
462
+ const fingerprint = [
463
+ state.target,
464
+ ...[...state.roots.values()].map((root) => `${root.id}\0${root.revision}\0${root.fingerprint}`).sort(),
465
+ ...[...classSet].sort(),
466
+ ...state.dependencies,
467
+ ...state.sources.map(sourceKey)
468
+ ].join("\0");
469
+ const snapshot = Object.freeze({
470
+ classSet: reusableClassSetView ?? new ImmutableSetView(classSet),
471
+ dependencies: state.dependencies,
472
+ roots,
473
+ sources: state.sources,
474
+ target: state.target
475
+ });
476
+ snapshotRegistry.set(snapshot, {
477
+ ...state,
478
+ classSet,
479
+ fingerprint
480
+ });
481
+ return snapshot;
482
+ }
483
+ function createRegisteredCompilerSnapshot(request, reusableClassSet, reusableClassSetView) {
484
+ if (!request.id) throw new Error("Compiler snapshot 的 root id 不能为空。");
485
+ const revision = request.revision ?? 0;
486
+ if (!Number.isSafeInteger(revision) || revision < 0) throw new Error(`Compiler snapshot revision 必须是非负安全整数:${revision}`);
487
+ const target = request.target ?? "weapp";
488
+ const classSet = new Set(request.classSet);
489
+ const dependencies = uniqueSorted(request.dependencies ?? []);
490
+ const sources = uniqueSortedSources(request.sources ?? []);
491
+ const root = {
492
+ id: request.id,
493
+ revision
494
+ };
495
+ const internalRoot = {
496
+ ...root,
497
+ fingerprint: createRootFingerprint(root, target, classSet, dependencies, sources)
498
+ };
499
+ return createSnapshotFromState({
500
+ classSet,
501
+ dependencies,
502
+ roots: /* @__PURE__ */ new Map([[root.id, internalRoot]]),
503
+ sources,
504
+ target
505
+ }, reusableClassSet, reusableClassSetView);
506
+ }
507
+ function getInternalCompilerSnapshot(snapshot) {
508
+ const state = snapshotRegistry.get(snapshot);
509
+ if (!state) throw new Error("Compiler snapshot 必须由 createSnapshot()、generate() 或 mergeSnapshots() 创建。");
510
+ return state;
511
+ }
512
+ function mergeRegisteredCompilerSnapshots(snapshots) {
513
+ const states = [...snapshots].map(getInternalCompilerSnapshot);
514
+ if (states.length === 0) throw new Error("mergeSnapshots() 至少需要一个 snapshot。");
515
+ const target = states[0].target;
516
+ const roots = /* @__PURE__ */ new Map();
517
+ const classSet = /* @__PURE__ */ new Set();
518
+ const dependencies = [];
519
+ const sources = [];
520
+ for (const state of states) {
521
+ if (state.target !== target) throw new Error(`不能合并不同 target 的 snapshot:${target} 与 ${state.target}`);
522
+ for (const root of state.roots.values()) {
523
+ const current = roots.get(root.id);
524
+ if (current && current.revision !== root.revision) throw new Error(`同一 root 不能合并不同 revision:${root.id} (${current.revision} / ${root.revision})`);
525
+ if (current && current.fingerprint !== root.fingerprint) throw new Error(`同一 root revision 的 snapshot 内容冲突:${root.id}@${root.revision}`);
526
+ roots.set(root.id, root);
527
+ }
528
+ for (const candidate of state.classSet) classSet.add(candidate);
529
+ dependencies.push(...state.dependencies);
530
+ sources.push(...state.sources);
531
+ }
532
+ return createSnapshotFromState({
533
+ classSet: new Set([...classSet].sort()),
534
+ dependencies: uniqueSorted(dependencies),
535
+ roots,
536
+ sources: uniqueSortedSources(sources),
537
+ target
538
+ });
539
+ }
540
+ function createImmutableSet(values) {
541
+ return new ImmutableSetView(values);
542
+ }
543
+ //#endregion
24
544
  //#region src/cache/index.ts
25
545
  function isProcessResult(value) {
26
546
  return typeof value === "object" && value !== null && "result" in value;
@@ -619,7 +1139,7 @@ function toCustomAttributesEntities(customAttributes) {
619
1139
  return Object.entries(customAttributes);
620
1140
  }
621
1141
  //#endregion
622
- //#region ../../node_modules/.pnpm/oxc-walker@1.1.1_@oxc-project+types@0.146.0_oxc-parser@0.146.0_rolldown@1.2.3/node_modules/oxc-walker/dist/index.mjs
1142
+ //#region ../../node_modules/.pnpm/oxc-walker@1.1.1_@oxc-project+types@0.147.0_oxc-parser@0.147.0_rolldown@1.2.3/node_modules/oxc-walker/dist/index.mjs
623
1143
  function isNode(v) {
624
1144
  return v !== null && typeof v === "object" && typeof v.type === "string";
625
1145
  }
@@ -1146,11 +1666,79 @@ function resolveRuntimePackageReplacements(option) {
1146
1666
  return Object.keys(normalized).length > 0 ? normalized : void 0;
1147
1667
  }
1148
1668
  //#endregion
1669
+ //#region src/context/style-options.ts
1670
+ function normalizeStyleHandlerMajorVersion(majorVersion) {
1671
+ return majorVersion === 4 ? 4 : void 0;
1672
+ }
1673
+ function resolveStyleOptionsFromContext(ctx, tailwindcssMajorVersion) {
1674
+ const resolvedUniAppXOptions = require_tailwindcss.resolveUniAppXOptions(ctx.uniAppX);
1675
+ const generatorOptions = require_generator.normalizeWeappTailwindcssGeneratorOptions(ctx.generator, {
1676
+ appType: ctx.appType,
1677
+ platform: ctx.cssOptions?.platform ?? ctx.platform,
1678
+ tailwindcssMajorVersion,
1679
+ uniAppX: resolvedUniAppXOptions
1680
+ });
1681
+ const branch = require_generator.resolveGeneratorRuntimeBranch(generatorOptions, {
1682
+ appType: ctx.appType,
1683
+ platform: ctx.cssOptions?.platform ?? ctx.platform,
1684
+ tailwindcssMajorVersion,
1685
+ uniAppX: resolvedUniAppXOptions
1686
+ });
1687
+ const hasCssOptions = ctx.cssOptions !== void 0;
1688
+ const configuredRem2rpx = ctx.cssOptions?.rem2rpx ?? ctx.rem2rpx;
1689
+ const rem2rpx = branch.isWeb && require_generator.shouldUseUniAppWebRpxCompatibility(ctx.appType) ? false : configuredRem2rpx;
1690
+ const cssOptions = {
1691
+ cssPreflight: ctx.cssOptions?.cssPreflight ?? ctx.cssPreflight,
1692
+ cssPreflightRange: ctx.cssOptions?.cssPreflightRange ?? ctx.cssPreflightRange,
1693
+ cssChildCombinatorReplaceValue: ctx.cssOptions?.cssChildCombinatorReplaceValue ?? ctx.cssChildCombinatorReplaceValue,
1694
+ cssSelectorReplacement: ctx.cssOptions?.cssSelectorReplacement ?? ctx.cssSelectorReplacement,
1695
+ rem2rpx,
1696
+ cssRemoveProperty: ctx.cssOptions?.cssRemoveProperty ?? ctx.cssRemoveProperty,
1697
+ cssRemoveActivePseudoClass: ctx.cssOptions?.cssRemoveActivePseudoClass ?? ctx.cssRemoveActivePseudoClass,
1698
+ cssRemoveHoverPseudoClass: ctx.cssOptions?.cssRemoveHoverPseudoClass ?? ctx.cssRemoveHoverPseudoClass,
1699
+ cssRemoveFocusPseudoClass: ctx.cssOptions?.cssRemoveFocusPseudoClass ?? ctx.cssRemoveFocusPseudoClass,
1700
+ tailwindcssV4GradientFallback: ctx.cssOptions?.tailwindcssV4GradientFallback ?? ctx.tailwindcssV4GradientFallback,
1701
+ cssPresetEnv: ctx.cssOptions?.cssPresetEnv ?? ctx.cssPresetEnv,
1702
+ atRules: ctx.cssOptions?.atRules ?? ctx.atRules,
1703
+ autoprefixer: ctx.cssOptions?.autoprefixer ?? ctx.autoprefixer,
1704
+ cssCalc: ctx.cssOptions?.cssCalc ?? ctx.cssCalc,
1705
+ platform: branch.platform ?? ctx.cssOptions?.platform ?? ctx.platform,
1706
+ px2rpx: ctx.cssOptions?.px2rpx ?? ctx.px2rpx,
1707
+ unitsToPx: ctx.cssOptions?.unitsToPx ?? ctx.unitsToPx,
1708
+ unitConversion: ctx.cssOptions?.unitConversion ?? ctx.unitConversion,
1709
+ injectAdditionalCssVarScope: ctx.cssOptions?.injectAdditionalCssVarScope ?? ctx.injectAdditionalCssVarScope
1710
+ };
1711
+ return {
1712
+ appType: ctx.appType,
1713
+ postcssOptions: ctx.postcssOptions,
1714
+ cssPreflight: cssOptions.cssPreflight,
1715
+ cssPreflightRange: cssOptions.cssPreflightRange,
1716
+ cssChildCombinatorReplaceValue: cssOptions.cssChildCombinatorReplaceValue,
1717
+ cssSelectorReplacement: cssOptions.cssSelectorReplacement,
1718
+ rem2rpx: cssOptions.rem2rpx,
1719
+ ...hasCssOptions ? { cssOptions } : {},
1720
+ cssRemoveProperty: cssOptions.cssRemoveProperty,
1721
+ cssRemoveActivePseudoClass: cssOptions.cssRemoveActivePseudoClass,
1722
+ cssRemoveHoverPseudoClass: cssOptions.cssRemoveHoverPseudoClass,
1723
+ cssRemoveFocusPseudoClass: cssOptions.cssRemoveFocusPseudoClass,
1724
+ tailwindcssV4GradientFallback: cssOptions.tailwindcssV4GradientFallback,
1725
+ cssPresetEnv: cssOptions.cssPresetEnv,
1726
+ atRules: cssOptions.atRules,
1727
+ autoprefixer: cssOptions.autoprefixer,
1728
+ cssCalc: cssOptions.cssCalc,
1729
+ uniAppX: branch.isNativeApp,
1730
+ platform: cssOptions.platform,
1731
+ px2rpx: cssOptions.px2rpx,
1732
+ unitsToPx: cssOptions.unitsToPx,
1733
+ unitConversion: cssOptions.unitConversion
1734
+ };
1735
+ }
1736
+ //#endregion
1149
1737
  //#region src/context/handlers.ts
1150
1738
  function createHandlersFromContext(ctx, customAttributesEntities, cssCalcOptions, tailwindcssMajorVersion) {
1151
1739
  const { escapeMap, injectAdditionalCssVarScope, postcssOptions, uniAppX, arbitraryValues, jsPreserveClass, babelParserOptions, experimentalJsFastPath, ignoreCallExpressionIdentifiers, ignoreTaggedTemplateExpressionIdentifiers, inlineWxs, disabledDefaultTemplateHandler, replaceRuntimePackages } = ctx;
1152
- const resolvedUniAppXOptions = require_options.resolveUniAppXOptions(uniAppX);
1153
- const styleOptions = require_style_options.resolveStyleOptionsFromContext(ctx, tailwindcssMajorVersion);
1740
+ const resolvedUniAppXOptions = require_tailwindcss.resolveUniAppXOptions(uniAppX);
1741
+ const styleOptions = resolveStyleOptionsFromContext(ctx, tailwindcssMajorVersion);
1154
1742
  const resolvedInjectAdditionalCssVarScope = styleOptions.cssOptions?.injectAdditionalCssVarScope ?? injectAdditionalCssVarScope;
1155
1743
  const uniAppXEnabled = styleOptions.uniAppX === true;
1156
1744
  const moduleSpecifierReplacements = resolveRuntimePackageReplacements(replaceRuntimePackages);
@@ -1161,7 +1749,7 @@ function createHandlersFromContext(ctx, customAttributesEntities, cssCalcOptions
1161
1749
  postcssOptions,
1162
1750
  uniAppXUnsupported: resolvedUniAppXOptions.uvueUnsupported,
1163
1751
  cssCalc: cssCalcOptions,
1164
- majorVersion: require_style_options.normalizeStyleHandlerMajorVersion(tailwindcssMajorVersion)
1752
+ majorVersion: normalizeStyleHandlerMajorVersion(tailwindcssMajorVersion)
1165
1753
  });
1166
1754
  const jsHandler = createJsHandler({
1167
1755
  escapeMap,
@@ -1203,7 +1791,7 @@ function applyLoggerLevel(logLevel) {
1203
1791
  function resolveContextCssPreflight(opts, ctx, majorVersion) {
1204
1792
  const userCssPreflight = opts?.cssOptions?.cssPreflight ?? opts?.cssPreflight;
1205
1793
  const cssPreflight = require_defaults.resolveDefaultCssPreflight(userCssPreflight, majorVersion);
1206
- const shouldUseUniAppXPreflight = ctx.appType === "uni-app-x" || require_options.resolveUniAppXOptions(ctx.uniAppX).enabled;
1794
+ const shouldUseUniAppXPreflight = ctx.appType === "uni-app-x" || require_tailwindcss.resolveUniAppXOptions(ctx.uniAppX).enabled;
1207
1795
  if (cssPreflight === false || !shouldUseUniAppXPreflight) return cssPreflight;
1208
1796
  const userCssPreflightObject = userCssPreflight && typeof userCssPreflight === "object" ? userCssPreflight : void 0;
1209
1797
  return {
@@ -1344,12 +1932,260 @@ function getCompilerContext(opts) {
1344
1932
  return withCompilerContextCache(opts, () => createInternalCompilerContext(opts));
1345
1933
  }
1346
1934
  //#endregion
1935
+ //#region src/core/compiler/transforms.ts
1936
+ const DEFAULT_JS_OPTIONS = Object.freeze({ tailwindcssMajorVersion: 4 });
1937
+ const DEFAULT_STYLE_OPTIONS = Object.freeze({ isMainChunk: true });
1938
+ function clonePostcssResult(result) {
1939
+ return Object.assign(Object.create(Object.getPrototypeOf(result)), result, {
1940
+ messages: [...result.messages],
1941
+ root: result.root.clone()
1942
+ });
1943
+ }
1944
+ function resolveStyleOptions(options) {
1945
+ if (!options) return DEFAULT_STYLE_OPTIONS;
1946
+ return options?.isMainChunk === void 0 ? {
1947
+ ...options,
1948
+ isMainChunk: true
1949
+ } : options;
1950
+ }
1951
+ function createCompilerTransforms({ ensureActive, track, userOptions }) {
1952
+ const context = getCompilerContext({
1953
+ ...userOptions,
1954
+ __internalDeferMissingCssEntriesWarning: true
1955
+ });
1956
+ const styleHandler = context.styleHandler;
1957
+ let cachedTemplateClassSet;
1958
+ let cachedTemplateOptions;
1959
+ function clearCache() {
1960
+ cachedTemplateClassSet = void 0;
1961
+ cachedTemplateOptions = void 0;
1962
+ }
1963
+ function createTemplateOptions(classSet, options) {
1964
+ const isDefault = !options || Object.keys(options).length === 0;
1965
+ if (isDefault && cachedTemplateClassSet === classSet && cachedTemplateOptions) return cachedTemplateOptions;
1966
+ const resolved = {
1967
+ ...options,
1968
+ classSetMode: "exact",
1969
+ jsHandler: (jsSource, _runtimeSet, jsOptions) => context.jsHandler(jsSource, classSet, {
1970
+ ...jsOptions,
1971
+ tailwindcssMajorVersion: jsOptions?.tailwindcssMajorVersion ?? 4
1972
+ }),
1973
+ runtimeSet: classSet
1974
+ };
1975
+ if (isDefault) {
1976
+ cachedTemplateClassSet = classSet;
1977
+ cachedTemplateOptions = resolved;
1978
+ }
1979
+ return resolved;
1980
+ }
1981
+ function transformCss(css, snapshot, options) {
1982
+ ensureActive();
1983
+ getInternalCompilerSnapshot(snapshot);
1984
+ return track(styleHandler(css, resolveStyleOptions(options)).then(clonePostcssResult));
1985
+ }
1986
+ function transformCssRoot(root, snapshot, options) {
1987
+ ensureActive();
1988
+ getInternalCompilerSnapshot(snapshot);
1989
+ return track(styleHandler.transformRoot(root, resolveStyleOptions(options)));
1990
+ }
1991
+ function transformJavaScript(source, snapshot, options) {
1992
+ ensureActive();
1993
+ const classSet = getInternalCompilerSnapshot(snapshot).classSet;
1994
+ const resolvedOptions = options?.tailwindcssMajorVersion === void 0 ? options ? {
1995
+ ...options,
1996
+ tailwindcssMajorVersion: 4
1997
+ } : DEFAULT_JS_OPTIONS : options;
1998
+ return track(Promise.resolve(shouldSkipJsTransform(source, resolvedOptions) ? { code: source } : context.jsHandler(source, classSet, resolvedOptions)));
1999
+ }
2000
+ function transformTemplate(source, snapshot, options) {
2001
+ ensureActive();
2002
+ const classSet = getInternalCompilerSnapshot(snapshot).classSet;
2003
+ return track(context.templateHandler(source, createTemplateOptions(classSet, options)));
2004
+ }
2005
+ return {
2006
+ clearCache,
2007
+ transformCss,
2008
+ transformCssRoot,
2009
+ transformJavaScript,
2010
+ transformTemplate
2011
+ };
2012
+ }
2013
+ //#endregion
2014
+ //#region src/core/compiler/compiler.ts
2015
+ const DEFAULT_MAX_ROOTS = 128;
2016
+ function createCompiler(options = {}) {
2017
+ const { compiler: compilerOptions, ...userOptions } = options;
2018
+ const rootStore = new CompilerRootStore(Math.max(1, Math.floor(compilerOptions?.maxRoots ?? DEFAULT_MAX_ROOTS)));
2019
+ const activeTasks = /* @__PURE__ */ new Set();
2020
+ let lifecycle = "active";
2021
+ let disposePromise;
2022
+ function ensureActive() {
2023
+ if (lifecycle !== "active") throw new Error(lifecycle === "disposing" ? "Compiler 正在释放,不能接受新任务。" : "Compiler 已释放。");
2024
+ }
2025
+ function track(task) {
2026
+ activeTasks.add(task);
2027
+ task.then(() => activeTasks.delete(task), () => activeTasks.delete(task));
2028
+ return task;
2029
+ }
2030
+ const { clearCache: clearTransformCache, ...transforms } = createCompilerTransforms({
2031
+ ensureActive,
2032
+ track,
2033
+ userOptions
2034
+ });
2035
+ async function resolveRequestSource(entry, request) {
2036
+ if (request.source && request.sourceOptions) throw new Error("generate() 的 source 与 sourceOptions 互斥。");
2037
+ if (!request.source && !request.sourceOptions) throw new Error("generate() 必须提供 source 或 sourceOptions。");
2038
+ const sourceInput = request.source ?? request.sourceOptions;
2039
+ return {
2040
+ source: entry.source !== void 0 && entry.sourceInput === sourceInput && entry.appliedInvalidation === entry.invalidation ? entry.source : request.source ?? await require_generator.resolveTailwindV4Source(request.sourceOptions),
2041
+ sourceInput
2042
+ };
2043
+ }
2044
+ async function runGenerate(entry, request) {
2045
+ if (!entry.active) throw new Error(`Compiler root 已被移除:${entry.id}`);
2046
+ const invalidation = entry.invalidation;
2047
+ const { source, sourceInput } = await resolveRequestSource(entry, request);
2048
+ const sourceFingerprint = entry.sourceInput === sourceInput && entry.sourceFingerprint !== void 0 && entry.appliedInvalidation === invalidation ? entry.sourceFingerprint : createSourceFingerprint(source);
2049
+ const sourceReused = entry.sourceFingerprint === sourceFingerprint;
2050
+ const engineReused = sourceReused && entry.generator !== void 0 && entry.appliedInvalidation === invalidation;
2051
+ const generator = engineReused ? entry.generator : require_generator.createWeappTailwindcssGenerator(source);
2052
+ const target = request.target ?? "weapp";
2053
+ const { id: _id, source: _source, sourceOptions: _sourceOptions, target: _target, ...generateOptions } = request;
2054
+ const prepared = prepareCompilerGeneration(entry, request, source, !sourceReused || entry.appliedInvalidation !== invalidation);
2055
+ const generationCacheKey = createCompilerGenerationCacheKey(request, prepared.compilation.candidates, target);
2056
+ const reusableGeneration = engineReused && entry.generationCache && isSameCompilerGenerationCacheKey(entry.generationCache.key, generationCacheKey) ? entry.generationCache.result : void 0;
2057
+ try {
2058
+ const generated = reusableGeneration ? reuseCompilerGenerationResult(reusableGeneration) : await generator.generate({
2059
+ ...generateOptions,
2060
+ candidates: prepared.explicitCandidates ? prepared.compilation.candidates : void 0,
2061
+ incrementalCache: generateOptions.incrementalCache ?? true,
2062
+ target: target === "tailwind" ? "web" : target
2063
+ });
2064
+ if (!entry.active) throw new Error(`Compiler root 已被移除:${entry.id}`);
2065
+ const revision = (getLatestRevision(entry) ?? 0) + 1;
2066
+ const dependencies = [.../* @__PURE__ */ new Set([...source.dependencies, ...generated.dependencies])].sort();
2067
+ const sources = generated.sources ?? source.sources ?? [];
2068
+ const previousSnapshotState = entry.latestSnapshot ? getInternalCompilerSnapshot(entry.latestSnapshot) : void 0;
2069
+ const reusableClassSet = engineReused && generated.incrementalCss === "" && previousSnapshotState && previousSnapshotState.classSet.size === generated.classSet.size && [...generated.classSet].every((candidate) => previousSnapshotState.classSet.has(candidate)) ? previousSnapshotState.classSet : void 0;
2070
+ const reusableClassSetView = reusableClassSet ? entry.latestSnapshot?.classSet : void 0;
2071
+ const snapshot = createRegisteredCompilerSnapshot({
2072
+ classSet: generated.classSet,
2073
+ dependencies,
2074
+ id: entry.id,
2075
+ revision,
2076
+ sources,
2077
+ target
2078
+ }, reusableClassSet, reusableClassSetView);
2079
+ const internalSnapshot = getInternalCompilerSnapshot(snapshot);
2080
+ const previousGenerator = entry.generator;
2081
+ commitCompilerGeneration(entry, prepared, source, dependencies, generated.classSet);
2082
+ entry.generator = generator;
2083
+ entry.generationCache = {
2084
+ key: generationCacheKey,
2085
+ result: generated
2086
+ };
2087
+ entry.source = source;
2088
+ entry.sourceFingerprint = sourceFingerprint;
2089
+ entry.sourceInput = sourceInput;
2090
+ entry.appliedInvalidation = invalidation;
2091
+ entry.latestSnapshot = snapshot;
2092
+ rootStore.attachDependencies(entry, dependencies);
2093
+ if (!engineReused && previousGenerator !== generator) previousGenerator?.dispose?.();
2094
+ const css = target === "tailwind" ? generated.rawCss : generated.css;
2095
+ const incrementalCss = target === "tailwind" ? generated.incrementalRawCss : generated.incrementalCss;
2096
+ return {
2097
+ ...generated,
2098
+ cache: Object.freeze({
2099
+ engine: engineReused,
2100
+ output: reusableGeneration !== void 0 || engineReused && incrementalCss === "",
2101
+ source: sourceReused
2102
+ }),
2103
+ classSet: snapshot.classSet,
2104
+ css,
2105
+ dependencies: snapshot.dependencies,
2106
+ incrementalCss,
2107
+ rawCandidates: createImmutableSet(generated.rawCandidates),
2108
+ revision,
2109
+ snapshot,
2110
+ sources: internalSnapshot.sources,
2111
+ target
2112
+ };
2113
+ } catch (error) {
2114
+ if (!engineReused) generator.dispose?.();
2115
+ throw error;
2116
+ }
2117
+ }
2118
+ function getLatestRevision(entry) {
2119
+ return entry.latestSnapshot?.roots[0]?.revision;
2120
+ }
2121
+ function generate(request) {
2122
+ ensureActive();
2123
+ const entry = rootStore.get(request.id);
2124
+ entry.pendingCount += 1;
2125
+ const execution = entry.pending.then(() => runGenerate(entry, request));
2126
+ entry.pending = execution.finally(() => {
2127
+ entry.pendingCount -= 1;
2128
+ rootStore.trim();
2129
+ }).then(() => void 0, () => void 0);
2130
+ return track(execution);
2131
+ }
2132
+ function createSnapshot(request) {
2133
+ ensureActive();
2134
+ return createRegisteredCompilerSnapshot(request);
2135
+ }
2136
+ function mergeSnapshots(snapshots) {
2137
+ ensureActive();
2138
+ return mergeRegisteredCompilerSnapshots(snapshots);
2139
+ }
2140
+ function invalidate(ids) {
2141
+ ensureActive();
2142
+ return rootStore.invalidate(ids);
2143
+ }
2144
+ async function remove(id) {
2145
+ if (lifecycle === "disposed") return;
2146
+ clearTransformCache();
2147
+ await rootStore.remove(id);
2148
+ }
2149
+ function dispose() {
2150
+ if (disposePromise) return disposePromise;
2151
+ lifecycle = "disposing";
2152
+ disposePromise = (async () => {
2153
+ await Promise.allSettled([...activeTasks]);
2154
+ clearTransformCache();
2155
+ await rootStore.dispose();
2156
+ lifecycle = "disposed";
2157
+ })();
2158
+ return disposePromise;
2159
+ }
2160
+ return {
2161
+ createSnapshot,
2162
+ dispose,
2163
+ generate,
2164
+ invalidate,
2165
+ mergeSnapshots,
2166
+ remove,
2167
+ ...transforms
2168
+ };
2169
+ }
2170
+ //#endregion
2171
+ Object.defineProperty(exports, "DefaultCompilationSession", {
2172
+ enumerable: true,
2173
+ get: function() {
2174
+ return DefaultCompilationSession;
2175
+ }
2176
+ });
1347
2177
  Object.defineProperty(exports, "collectRuntimeClassSet", {
1348
2178
  enumerable: true,
1349
2179
  get: function() {
1350
2180
  return collectRuntimeClassSet;
1351
2181
  }
1352
2182
  });
2183
+ Object.defineProperty(exports, "createCompiler", {
2184
+ enumerable: true,
2185
+ get: function() {
2186
+ return createCompiler;
2187
+ }
2188
+ });
1353
2189
  Object.defineProperty(exports, "createTailwindRuntimeReadyPromise", {
1354
2190
  enumerable: true,
1355
2191
  get: function() {
@@ -1374,6 +2210,12 @@ Object.defineProperty(exports, "normalizeFrameworkStylePlatform", {
1374
2210
  return normalizeFrameworkStylePlatform;
1375
2211
  }
1376
2212
  });
2213
+ Object.defineProperty(exports, "normalizeStyleHandlerMajorVersion", {
2214
+ enumerable: true,
2215
+ get: function() {
2216
+ return normalizeStyleHandlerMajorVersion;
2217
+ }
2218
+ });
1377
2219
  Object.defineProperty(exports, "pluginName", {
1378
2220
  enumerable: true,
1379
2221
  get: function() {
@@ -1386,6 +2228,12 @@ Object.defineProperty(exports, "refreshTailwindRuntimeState", {
1386
2228
  return refreshTailwindRuntimeState;
1387
2229
  }
1388
2230
  });
2231
+ Object.defineProperty(exports, "resolveStyleOptionsFromContext", {
2232
+ enumerable: true,
2233
+ get: function() {
2234
+ return resolveStyleOptionsFromContext;
2235
+ }
2236
+ });
1389
2237
  Object.defineProperty(exports, "shouldSkipJsTransform", {
1390
2238
  enumerable: true,
1391
2239
  get: function() {