@weapp-tailwindcss/engine 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,13 +1,13 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_v4 = require("./v4-DVqsqn8b.cjs");
2
+ const require_v4 = require("./v4-_oyKsjgy.cjs");
3
3
  let node_process = require("node:process");
4
4
  node_process = require_v4.__toESM(node_process, 1);
5
5
  let _weapp_tailwindcss_source_scan = require("@weapp-tailwindcss/source-scan");
6
6
  //#region src/extraction/candidate-extractor/valid.ts
7
- const designSystemCandidateCache = /* @__PURE__ */ new Map();
8
- function createCandidateCacheKey(designSystemKey, options) {
9
- if (options.bareArbitraryValues == null || options.bareArbitraryValues === false) return designSystemKey;
10
- return `${designSystemKey}:bare-arbitrary:${JSON.stringify(options.bareArbitraryValues)}`;
7
+ const designSystemCandidateCache = /* @__PURE__ */ new WeakMap();
8
+ function createCandidateCacheKey(options) {
9
+ if (options.bareArbitraryValues == null || options.bareArbitraryValues === false) return "default";
10
+ return `bare-arbitrary:${JSON.stringify(options.bareArbitraryValues)}`;
11
11
  }
12
12
  async function extractValidCandidates(options) {
13
13
  const providedOptions = options ?? {};
@@ -24,18 +24,18 @@ async function extractValidCandidates(options) {
24
24
  pattern: source.pattern,
25
25
  negated: source.negated
26
26
  }));
27
- const source = {
27
+ const designSystem = await require_v4.loadTailwindV4DesignSystem({
28
28
  projectRoot: defaultCwd,
29
29
  base,
30
30
  baseFallbacks,
31
31
  css,
32
32
  dependencies: []
33
- };
34
- const designSystemKey = require_v4.getTailwindV4DesignSystemCacheKey(source);
35
- const designSystem = await require_v4.loadTailwindV4DesignSystem(source);
36
- const candidateCacheKey = createCandidateCacheKey(designSystemKey, providedOptions);
37
- const candidateCache = designSystemCandidateCache.get(candidateCacheKey) ?? /* @__PURE__ */ new Map();
38
- designSystemCandidateCache.set(candidateCacheKey, candidateCache);
33
+ });
34
+ const candidateCacheKey = createCandidateCacheKey(providedOptions);
35
+ const caches = designSystemCandidateCache.get(designSystem) ?? /* @__PURE__ */ new Map();
36
+ designSystemCandidateCache.set(designSystem, caches);
37
+ const candidateCache = caches.get(candidateCacheKey) ?? /* @__PURE__ */ new Map();
38
+ caches.set(candidateCacheKey, candidateCache);
39
39
  const candidates = await require_v4.extractRawCandidates(sources, providedOptions.bareArbitraryValues === void 0 ? void 0 : { bareArbitraryValues: providedOptions.bareArbitraryValues });
40
40
  const inlineSources = require_v4.extractTailwindV4InlineSourceCandidates(css);
41
41
  for (const candidate of inlineSources.included) candidates.push(candidate);
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
- import { A as expandTailwindV4SourceEntryBraces, B as expandTailwindV4SourceEntries, C as TAILWIND_V4_AUTO_SOURCE_SCAN_PATTERN, D as createTailwindV4CompiledSourceEntries, E as TAILWIND_V4_IGNORED_FILES, F as resolveTailwindV4SourceBaseCandidates, G as compileTailwindV4Source, H as isFileExcludedByTailwindV4SourceEntries, I as resolveTailwindV4SourceEntry, J as loadTailwindV4NodeModule, K as getTailwindV4DesignSystemCacheKey, L as toPosixPath, M as normalizeTailwindV4ScannerSources, N as normalizeTailwindV4SourceEntries, O as createTailwindV4DefaultIgnoreSources, P as resolveSourceScanPath, R as createTailwindV4SourceEntryMatcher, S as resolveProjectSourceFiles, T as TAILWIND_V4_IGNORED_EXTENSIONS, U as isFileMatchedByTailwindV4SourceEntries, V as groupTailwindV4SourceEntriesByBase, W as mergeTailwindV4SourceEntries, _ as isBareArbitraryValuesEnabled, a as createTailwindGenerationSession, b as extractProjectCandidatesWithPositions, c as replaceBareArbitraryValueSelectors, d as extractRawCandidates, f as extractRawCandidatesWithPositions, g as extractBareArbitraryValueSourceCandidatesWithPositions, h as extractBareArbitraryValueSourceCandidates, i as createTailwindV4Engine, j as normalizeGlobPattern, k as createTailwindV4RootSources, l as resolveValidTailwindV4Candidates, m as extractSourceCandidatesWithPositions, n as generateTailwindV4Style, o as collectTailwindStyleCandidates, p as extractSourceCandidates, q as loadTailwindV4DesignSystem, r as resolveTailwindV4Source, s as canonicalizeBareArbitraryValueCandidates, t as collectTailwindV4StyleCandidates, u as extractTailwindV4InlineSourceCandidates, v as resolveBareArbitraryValueCandidate, w as TAILWIND_V4_IGNORED_CONTENT_DIRS, x as groupTokensByFile, y as escapeCssClassName, z as createTailwindV4SourceExclusionMatcher } from "./v4-D46xWjyQ.js";
1
+ import { A as expandTailwindV4SourceEntryBraces, B as expandTailwindV4SourceEntries, C as TAILWIND_V4_AUTO_SOURCE_SCAN_PATTERN, D as createTailwindV4CompiledSourceEntries, E as TAILWIND_V4_IGNORED_FILES, F as resolveTailwindV4SourceBaseCandidates, G as compileTailwindV4Source, H as isFileExcludedByTailwindV4SourceEntries, I as resolveTailwindV4SourceEntry, J as loadTailwindV4NodeModule, K as getTailwindV4DesignSystemCacheKey, L as toPosixPath, M as normalizeTailwindV4ScannerSources, N as normalizeTailwindV4SourceEntries, O as createTailwindV4DefaultIgnoreSources, P as resolveSourceScanPath, R as createTailwindV4SourceEntryMatcher, S as resolveProjectSourceFiles, T as TAILWIND_V4_IGNORED_EXTENSIONS, U as isFileMatchedByTailwindV4SourceEntries, V as groupTailwindV4SourceEntriesByBase, W as mergeTailwindV4SourceEntries, _ as isBareArbitraryValuesEnabled, a as createTailwindGenerationSession, b as extractProjectCandidatesWithPositions, c as replaceBareArbitraryValueSelectors, d as extractRawCandidates, f as extractRawCandidatesWithPositions, g as extractBareArbitraryValueSourceCandidatesWithPositions, h as extractBareArbitraryValueSourceCandidates, i as createTailwindV4Engine, j as normalizeGlobPattern, k as createTailwindV4RootSources, l as resolveValidTailwindV4Candidates, m as extractSourceCandidatesWithPositions, n as generateTailwindV4Style, o as collectTailwindStyleCandidates, p as extractSourceCandidates, q as loadTailwindV4DesignSystem, r as resolveTailwindV4Source, s as canonicalizeBareArbitraryValueCandidates, t as collectTailwindV4StyleCandidates, u as extractTailwindV4InlineSourceCandidates, v as resolveBareArbitraryValueCandidate, w as TAILWIND_V4_IGNORED_CONTENT_DIRS, x as groupTokensByFile, y as escapeCssClassName, z as createTailwindV4SourceExclusionMatcher } from "./v4-Ct27rkAi.js";
2
2
  import process from "node:process";
3
3
  //#region src/extraction/candidate-extractor/valid.ts
4
- const designSystemCandidateCache = /* @__PURE__ */ new Map();
5
- function createCandidateCacheKey(designSystemKey, options) {
6
- if (options.bareArbitraryValues == null || options.bareArbitraryValues === false) return designSystemKey;
7
- return `${designSystemKey}:bare-arbitrary:${JSON.stringify(options.bareArbitraryValues)}`;
4
+ const designSystemCandidateCache = /* @__PURE__ */ new WeakMap();
5
+ function createCandidateCacheKey(options) {
6
+ if (options.bareArbitraryValues == null || options.bareArbitraryValues === false) return "default";
7
+ return `bare-arbitrary:${JSON.stringify(options.bareArbitraryValues)}`;
8
8
  }
9
9
  async function extractValidCandidates(options) {
10
10
  const providedOptions = options ?? {};
@@ -21,18 +21,18 @@ async function extractValidCandidates(options) {
21
21
  pattern: source.pattern,
22
22
  negated: source.negated
23
23
  }));
24
- const source = {
24
+ const designSystem = await loadTailwindV4DesignSystem({
25
25
  projectRoot: defaultCwd,
26
26
  base,
27
27
  baseFallbacks,
28
28
  css,
29
29
  dependencies: []
30
- };
31
- const designSystemKey = getTailwindV4DesignSystemCacheKey(source);
32
- const designSystem = await loadTailwindV4DesignSystem(source);
33
- const candidateCacheKey = createCandidateCacheKey(designSystemKey, providedOptions);
34
- const candidateCache = designSystemCandidateCache.get(candidateCacheKey) ?? /* @__PURE__ */ new Map();
35
- designSystemCandidateCache.set(candidateCacheKey, candidateCache);
30
+ });
31
+ const candidateCacheKey = createCandidateCacheKey(providedOptions);
32
+ const caches = designSystemCandidateCache.get(designSystem) ?? /* @__PURE__ */ new Map();
33
+ designSystemCandidateCache.set(designSystem, caches);
34
+ const candidateCache = caches.get(candidateCacheKey) ?? /* @__PURE__ */ new Map();
35
+ caches.set(candidateCacheKey, candidateCache);
36
36
  const candidates = await extractRawCandidates(sources, providedOptions.bareArbitraryValues === void 0 ? void 0 : { bareArbitraryValues: providedOptions.bareArbitraryValues });
37
37
  const inlineSources = extractTailwindV4InlineSourceCandidates(css);
38
38
  for (const candidate of inlineSources.included) candidates.push(candidate);
package/dist/v4/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_v4 = require("../v4-DVqsqn8b.cjs");
2
+ const require_v4 = require("../v4-_oyKsjgy.cjs");
3
3
  let _weapp_tailwindcss_source_scan = require("@weapp-tailwindcss/source-scan");
4
4
  exports.TAILWIND_V4_AUTO_SOURCE_SCAN_PATTERN = require_v4.TAILWIND_V4_AUTO_SOURCE_SCAN_PATTERN;
5
5
  exports.TAILWIND_V4_IGNORED_CONTENT_DIRS = require_v4.TAILWIND_V4_IGNORED_CONTENT_DIRS;
package/dist/v4/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import { A as expandTailwindV4SourceEntryBraces, B as expandTailwindV4SourceEntries, C as TAILWIND_V4_AUTO_SOURCE_SCAN_PATTERN, D as createTailwindV4CompiledSourceEntries, E as TAILWIND_V4_IGNORED_FILES, F as resolveTailwindV4SourceBaseCandidates, G as compileTailwindV4Source, H as isFileExcludedByTailwindV4SourceEntries, I as resolveTailwindV4SourceEntry, J as loadTailwindV4NodeModule, K as getTailwindV4DesignSystemCacheKey, L as toPosixPath, M as normalizeTailwindV4ScannerSources, N as normalizeTailwindV4SourceEntries, O as createTailwindV4DefaultIgnoreSources, P as resolveSourceScanPath, R as createTailwindV4SourceEntryMatcher, T as TAILWIND_V4_IGNORED_EXTENSIONS, U as isFileMatchedByTailwindV4SourceEntries, V as groupTailwindV4SourceEntriesByBase, W as mergeTailwindV4SourceEntries, _ as isBareArbitraryValuesEnabled, a as createTailwindGenerationSession, c as replaceBareArbitraryValueSelectors, g as extractBareArbitraryValueSourceCandidatesWithPositions, h as extractBareArbitraryValueSourceCandidates, i as createTailwindV4Engine, j as normalizeGlobPattern, k as createTailwindV4RootSources, l as resolveValidTailwindV4Candidates, n as generateTailwindV4Style, q as loadTailwindV4DesignSystem, r as resolveTailwindV4Source, s as canonicalizeBareArbitraryValueCandidates, t as collectTailwindV4StyleCandidates, u as extractTailwindV4InlineSourceCandidates, v as resolveBareArbitraryValueCandidate, w as TAILWIND_V4_IGNORED_CONTENT_DIRS, y as escapeCssClassName, z as createTailwindV4SourceExclusionMatcher } from "../v4-D46xWjyQ.js";
1
+ import { A as expandTailwindV4SourceEntryBraces, B as expandTailwindV4SourceEntries, C as TAILWIND_V4_AUTO_SOURCE_SCAN_PATTERN, D as createTailwindV4CompiledSourceEntries, E as TAILWIND_V4_IGNORED_FILES, F as resolveTailwindV4SourceBaseCandidates, G as compileTailwindV4Source, H as isFileExcludedByTailwindV4SourceEntries, I as resolveTailwindV4SourceEntry, J as loadTailwindV4NodeModule, K as getTailwindV4DesignSystemCacheKey, L as toPosixPath, M as normalizeTailwindV4ScannerSources, N as normalizeTailwindV4SourceEntries, O as createTailwindV4DefaultIgnoreSources, P as resolveSourceScanPath, R as createTailwindV4SourceEntryMatcher, T as TAILWIND_V4_IGNORED_EXTENSIONS, U as isFileMatchedByTailwindV4SourceEntries, V as groupTailwindV4SourceEntriesByBase, W as mergeTailwindV4SourceEntries, _ as isBareArbitraryValuesEnabled, a as createTailwindGenerationSession, c as replaceBareArbitraryValueSelectors, g as extractBareArbitraryValueSourceCandidatesWithPositions, h as extractBareArbitraryValueSourceCandidates, i as createTailwindV4Engine, j as normalizeGlobPattern, k as createTailwindV4RootSources, l as resolveValidTailwindV4Candidates, n as generateTailwindV4Style, q as loadTailwindV4DesignSystem, r as resolveTailwindV4Source, s as canonicalizeBareArbitraryValueCandidates, t as collectTailwindV4StyleCandidates, u as extractTailwindV4InlineSourceCandidates, v as resolveBareArbitraryValueCandidate, w as TAILWIND_V4_IGNORED_CONTENT_DIRS, y as escapeCssClassName, z as createTailwindV4SourceExclusionMatcher } from "../v4-Ct27rkAi.js";
2
2
  export { TAILWIND_V4_AUTO_SOURCE_SCAN_PATTERN, TAILWIND_V4_IGNORED_CONTENT_DIRS, TAILWIND_V4_IGNORED_EXTENSIONS, TAILWIND_V4_IGNORED_FILES, canonicalizeBareArbitraryValueCandidates, collectTailwindV4StyleCandidates, compileTailwindV4Source, createTailwindGenerationSession, createTailwindV4CompiledSourceEntries, createTailwindV4DefaultIgnoreSources, createTailwindV4Engine, createTailwindV4RootSources, createTailwindV4SourceEntryMatcher, createTailwindV4SourceExclusionMatcher, escapeCssClassName, expandTailwindV4SourceEntries, expandTailwindV4SourceEntryBraces, extractBareArbitraryValueSourceCandidates, extractBareArbitraryValueSourceCandidatesWithPositions, extractTailwindV4InlineSourceCandidates, generateTailwindV4Style, getTailwindV4DesignSystemCacheKey, groupTailwindV4SourceEntriesByBase, isBareArbitraryValuesEnabled, isFileExcludedByTailwindV4SourceEntries, isFileMatchedByTailwindV4SourceEntries, loadTailwindV4DesignSystem, loadTailwindV4NodeModule, mergeTailwindV4SourceEntries, normalizeGlobPattern, normalizeTailwindV4ScannerSources, normalizeTailwindV4SourceEntries, replaceBareArbitraryValueSelectors, resolveBareArbitraryValueCandidate, resolveSourceScanPath, resolveTailwindV4Source, resolveTailwindV4SourceBaseCandidates, resolveTailwindV4SourceEntry, resolveValidTailwindV4Candidates, toPosixPath };
@@ -2,9 +2,9 @@ import { createRequire, findPackageJSON } from "node:module";
2
2
  import { promises, readFileSync } from "node:fs";
3
3
  import path from "node:path";
4
4
  import process from "node:process";
5
+ import { createHash } from "node:crypto";
5
6
  import { fileURLToPath, pathToFileURL } from "node:url";
6
7
  import { AsyncLocalStorage } from "node:async_hooks";
7
- import { createHash } from "node:crypto";
8
8
  import { clearRequireCache } from "@tailwindcss/node/require-cache";
9
9
  import { createSourceScanPlan, expandSourceEntries as expandTailwindV4SourceEntries, expandSourceEntryBraces, expandSourceEntryBraces as expandTailwindV4SourceEntryBraces, groupSourceEntriesByBase as groupTailwindV4SourceEntriesByBase, isFileExcludedByTailwindSourceEntries, isFileExcludedByTailwindSourceEntries as isFileExcludedByTailwindV4SourceEntries, isFileMatchedByTailwindSourceEntries, mergeSourceEntries as mergeTailwindV4SourceEntries, normalizeGlobPattern, resolveSourceScanPath, resolveSourceScanPath as resolveSourceScanPath$1, resolveTailwindSourceEntry, toPosixPath } from "@weapp-tailwindcss/source-scan";
10
10
  import postcss from "postcss";
@@ -171,6 +171,18 @@ function prepareGenerationModuleRequests(css, base) {
171
171
  //#region src/v4/node-adapter.ts
172
172
  const nodeModulePromiseCache = /* @__PURE__ */ new Map();
173
173
  const designSystemPromiseCache = /* @__PURE__ */ new Map();
174
+ function fingerprintDesignDependencies(files) {
175
+ const hash = createHash("sha256");
176
+ for (const file of [...files].sort()) {
177
+ hash.update(file);
178
+ try {
179
+ hash.update(readFileSync(file));
180
+ } catch {
181
+ hash.update("missing");
182
+ }
183
+ }
184
+ return hash.digest("hex");
185
+ }
174
186
  function unique(values) {
175
187
  return Array.from(new Set(Array.from(values).filter(Boolean).map((value) => path.resolve(value))));
176
188
  }
@@ -242,14 +254,14 @@ function createDesignSystemCacheKey(css, bases) {
242
254
  function getTailwindV4DesignSystemCacheKey(source) {
243
255
  return createDesignSystemCacheKey(source.css, [source.base, ...source.baseFallbacks]);
244
256
  }
245
- async function createTailwindV4DesignSystem(source) {
257
+ async function createTailwindV4DesignSystem(source, onDependency) {
246
258
  const bases = unique([source.base, ...source.baseFallbacks]);
247
259
  if (bases.length === 0) throw new Error("No base directories provided for Tailwind CSS v4 design system.");
248
260
  const node = await loadTailwindV4NodeModule([source.projectRoot, ...bases]);
249
261
  let lastError;
250
262
  for (const base of bases) try {
251
263
  const prepared = prepareGenerationModuleRequests(source.css, base);
252
- return await withGenerationModuleCache(node, () => node.__unstable__loadDesignSystem(prepared.css, { base }), prepared.files);
264
+ return await withGenerationModuleCache(node, () => node.__unstable__loadDesignSystem(prepared.css, { base }), prepared.files, onDependency);
253
265
  } catch (error) {
254
266
  lastError = error;
255
267
  }
@@ -258,13 +270,20 @@ async function createTailwindV4DesignSystem(source) {
258
270
  }
259
271
  async function loadTailwindV4DesignSystem(source, options) {
260
272
  if (options?.cache === false) return createTailwindV4DesignSystem(source);
261
- const cacheKey = getTailwindV4DesignSystemCacheKey(source);
273
+ const cacheKey = JSON.stringify([source.projectRoot, getTailwindV4DesignSystemCacheKey(source)]);
262
274
  const cached = designSystemPromiseCache.get(cacheKey);
263
- if (cached) return cached;
264
- const promise = createTailwindV4DesignSystem(source);
265
- designSystemPromiseCache.set(cacheKey, promise);
266
- promise.catch(() => {
267
- if (designSystemPromiseCache.get(cacheKey) === promise) designSystemPromiseCache.delete(cacheKey);
275
+ if (cached && (cached.fingerprint === void 0 || cached.fingerprint === fingerprintDesignDependencies(cached.dependencies))) return cached.promise;
276
+ const dependencies = new Set(source.dependencies);
277
+ const promise = createTailwindV4DesignSystem(source, (file) => dependencies.add(file));
278
+ const entry = {
279
+ promise,
280
+ dependencies
281
+ };
282
+ designSystemPromiseCache.set(cacheKey, entry);
283
+ promise.then(() => {
284
+ entry.fingerprint = fingerprintDesignDependencies(dependencies);
285
+ }, () => {
286
+ if (designSystemPromiseCache.get(cacheKey) === entry) designSystemPromiseCache.delete(cacheKey);
268
287
  });
269
288
  return promise;
270
289
  }
@@ -25,10 +25,10 @@ let node_path = require("node:path");
25
25
  node_path = __toESM(node_path, 1);
26
26
  let node_process = require("node:process");
27
27
  node_process = __toESM(node_process, 1);
28
+ let node_crypto = require("node:crypto");
28
29
  let node_module = require("node:module");
29
30
  let node_url = require("node:url");
30
31
  let node_async_hooks = require("node:async_hooks");
31
- let node_crypto = require("node:crypto");
32
32
  let _tailwindcss_node_require_cache = require("@tailwindcss/node/require-cache");
33
33
  let _weapp_tailwindcss_source_scan = require("@weapp-tailwindcss/source-scan");
34
34
  let postcss = require("postcss");
@@ -196,6 +196,18 @@ function prepareGenerationModuleRequests(css, base) {
196
196
  //#region src/v4/node-adapter.ts
197
197
  const nodeModulePromiseCache = /* @__PURE__ */ new Map();
198
198
  const designSystemPromiseCache = /* @__PURE__ */ new Map();
199
+ function fingerprintDesignDependencies(files) {
200
+ const hash = (0, node_crypto.createHash)("sha256");
201
+ for (const file of [...files].sort()) {
202
+ hash.update(file);
203
+ try {
204
+ hash.update((0, node_fs.readFileSync)(file));
205
+ } catch {
206
+ hash.update("missing");
207
+ }
208
+ }
209
+ return hash.digest("hex");
210
+ }
199
211
  function unique(values) {
200
212
  return Array.from(new Set(Array.from(values).filter(Boolean).map((value) => node_path.default.resolve(value))));
201
213
  }
@@ -267,14 +279,14 @@ function createDesignSystemCacheKey(css, bases) {
267
279
  function getTailwindV4DesignSystemCacheKey(source) {
268
280
  return createDesignSystemCacheKey(source.css, [source.base, ...source.baseFallbacks]);
269
281
  }
270
- async function createTailwindV4DesignSystem(source) {
282
+ async function createTailwindV4DesignSystem(source, onDependency) {
271
283
  const bases = unique([source.base, ...source.baseFallbacks]);
272
284
  if (bases.length === 0) throw new Error("No base directories provided for Tailwind CSS v4 design system.");
273
285
  const node = await loadTailwindV4NodeModule([source.projectRoot, ...bases]);
274
286
  let lastError;
275
287
  for (const base of bases) try {
276
288
  const prepared = prepareGenerationModuleRequests(source.css, base);
277
- return await withGenerationModuleCache(node, () => node.__unstable__loadDesignSystem(prepared.css, { base }), prepared.files);
289
+ return await withGenerationModuleCache(node, () => node.__unstable__loadDesignSystem(prepared.css, { base }), prepared.files, onDependency);
278
290
  } catch (error) {
279
291
  lastError = error;
280
292
  }
@@ -283,13 +295,20 @@ async function createTailwindV4DesignSystem(source) {
283
295
  }
284
296
  async function loadTailwindV4DesignSystem(source, options) {
285
297
  if (options?.cache === false) return createTailwindV4DesignSystem(source);
286
- const cacheKey = getTailwindV4DesignSystemCacheKey(source);
298
+ const cacheKey = JSON.stringify([source.projectRoot, getTailwindV4DesignSystemCacheKey(source)]);
287
299
  const cached = designSystemPromiseCache.get(cacheKey);
288
- if (cached) return cached;
289
- const promise = createTailwindV4DesignSystem(source);
290
- designSystemPromiseCache.set(cacheKey, promise);
291
- promise.catch(() => {
292
- if (designSystemPromiseCache.get(cacheKey) === promise) designSystemPromiseCache.delete(cacheKey);
300
+ if (cached && (cached.fingerprint === void 0 || cached.fingerprint === fingerprintDesignDependencies(cached.dependencies))) return cached.promise;
301
+ const dependencies = new Set(source.dependencies);
302
+ const promise = createTailwindV4DesignSystem(source, (file) => dependencies.add(file));
303
+ const entry = {
304
+ promise,
305
+ dependencies
306
+ };
307
+ designSystemPromiseCache.set(cacheKey, entry);
308
+ promise.then(() => {
309
+ entry.fingerprint = fingerprintDesignDependencies(dependencies);
310
+ }, () => {
311
+ if (designSystemPromiseCache.get(cacheKey) === entry) designSystemPromiseCache.delete(cacheKey);
293
312
  });
294
313
  return promise;
295
314
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@weapp-tailwindcss/engine",
3
3
  "type": "module",
4
- "version": "0.1.1",
4
+ "version": "0.1.2",
5
5
  "description": "Tailwind CSS 4 候选提取、源码扫描与样式生成引擎。",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",