@csszyx/unplugin 0.14.0 → 0.14.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.
@@ -1,8 +1,8 @@
1
1
  import { readFileSync } from 'node:fs';
2
2
  import * as path from 'node:path';
3
- import { extractCrossModuleRegistryEntries, ensureRustTransformAvailable, transformRust, transformWasm, transform } from '@csszyx/compiler';
3
+ import { extractCrossModuleForwards, extractCrossModuleRegistryEntries, ensureRustTransformAvailable, transformRust, transformWasm, transform } from '@csszyx/compiler';
4
4
  import { DEFAULT_IMPORTED_STATIC_SZ } from '@csszyx/types';
5
- import { c as collectSpecifierAliases, i as importedSpecifiersIn, s as specifierBases, a as resolveProviderPathWith, n as normalizePathSeparators, b as recordResolvedEntry, d as isReadableProviderFile, e as createTransformCacheKey, f as readTransformCache, w as writeTransformCache } from './unplugin.DKcwO8O4.mjs';
5
+ import { c as collectSpecifierAliases, i as importedSpecifiersIn, s as specifierBases, a as resolveProviderPathWith, n as normalizePathSeparators, b as recordResolvedEntry, f as forwardVisitKey, M as MAX_FORWARD_HOPS, d as isReadableProviderFile, e as createTransformCacheKey, g as readTransformCache, w as writeTransformCache } from './unplugin.NlPvn5P4.mjs';
6
6
  import { createHash } from 'node:crypto';
7
7
  import { s as sortStrings } from './unplugin.B3XoSRB8.mjs';
8
8
 
@@ -22,6 +22,7 @@ function resolveNextCrossModule(input) {
22
22
  const statics = {};
23
23
  const providers = [];
24
24
  const seen = /* @__PURE__ */ new Set();
25
+ const modules = /* @__PURE__ */ new Map();
25
26
  for (const specifier of importedSpecifiersIn(input.source)) {
26
27
  if (seen.has(specifier)) continue;
27
28
  seen.add(specifier);
@@ -29,18 +30,60 @@ function resolveNextCrossModule(input) {
29
30
  const provider = resolveProviderPathWith(base, isReadableProviderFile);
30
31
  if (provider === void 0) continue;
31
32
  providers.push(provider);
32
- recordEntries(statics, specifier, readProviderEntries(provider), input);
33
+ const walk = { aliases, modules, providers };
34
+ recordEntries(statics, specifier, providerExports(provider, walk), input);
33
35
  break;
34
36
  }
35
37
  }
36
38
  return { statics, providers };
37
39
  }
38
- function readProviderEntries(provider) {
40
+ function providerExports(provider, context) {
41
+ const module = readProviderModule(provider, context.modules);
42
+ if (module.forwards.length === 0) return module.entries;
43
+ const declared = new Set(module.entries.map((entry) => entry.exportName));
44
+ const resolved = [...module.entries];
45
+ for (const forward of module.forwards) {
46
+ if (declared.has(forward.exportName)) continue;
47
+ const found = followForward(provider, forward, context, {
48
+ hops: MAX_FORWARD_HOPS,
49
+ visited: /* @__PURE__ */ new Set([forwardVisitKey(provider, forward.exportName)])
50
+ });
51
+ if (found !== void 0) resolved.push({ ...found, exportName: forward.exportName });
52
+ }
53
+ return resolved;
54
+ }
55
+ function followForward(fromPath, forward, context, walk) {
56
+ if (walk.hops <= 0) return void 0;
57
+ for (const base of specifierBases(forward.specifier, path.dirname(fromPath), context.aliases)) {
58
+ const next = resolveProviderPathWith(base, isReadableProviderFile);
59
+ if (next === void 0) continue;
60
+ const key = forwardVisitKey(next, forward.importedName);
61
+ if (walk.visited.has(key)) return void 0;
62
+ walk.visited.add(key);
63
+ context.providers.push(next);
64
+ const module = readProviderModule(next, context.modules);
65
+ const own = module.entries.find((entry) => entry.exportName === forward.importedName);
66
+ if (own !== void 0) return own;
67
+ const link = module.forwards.find((item) => item.exportName === forward.importedName);
68
+ if (link === void 0) return void 0;
69
+ return followForward(next, link, context, { hops: walk.hops - 1, visited: walk.visited });
70
+ }
71
+ return void 0;
72
+ }
73
+ function readProviderModule(provider, cache) {
74
+ const hit = cache.get(provider);
75
+ if (hit !== void 0) return hit;
76
+ let module = { entries: [], forwards: [] };
39
77
  try {
40
- return extractCrossModuleRegistryEntries(readFileSync(provider, "utf8"), provider);
78
+ const text = readFileSync(provider, "utf8");
79
+ module = {
80
+ entries: extractCrossModuleRegistryEntries(text, provider),
81
+ forwards: extractCrossModuleForwards(text, provider)
82
+ };
41
83
  } catch {
42
- return [];
43
84
  }
85
+ cache.set(provider, module);
86
+ return module;
44
87
  }
45
88
  function recordEntries(statics, specifier, entries, input) {
46
89
  for (const entry of entries) {
@@ -4,7 +4,7 @@ const fs = require('node:fs');
4
4
  const path = require('node:path');
5
5
  const compiler = require('@csszyx/compiler');
6
6
  const types = require('@csszyx/types');
7
- const transformCache = require('./unplugin.BKGCkMgM.cjs');
7
+ const transformCache = require('./unplugin.VtXstzEh.cjs');
8
8
  const node_crypto = require('node:crypto');
9
9
  const htmlEscape = require('./unplugin.BkRah5Ot.cjs');
10
10
 
@@ -38,6 +38,7 @@ function resolveNextCrossModule(input) {
38
38
  const statics = {};
39
39
  const providers = [];
40
40
  const seen = /* @__PURE__ */ new Set();
41
+ const modules = /* @__PURE__ */ new Map();
41
42
  for (const specifier of transformCache.importedSpecifiersIn(input.source)) {
42
43
  if (seen.has(specifier)) continue;
43
44
  seen.add(specifier);
@@ -45,18 +46,60 @@ function resolveNextCrossModule(input) {
45
46
  const provider = transformCache.resolveProviderPathWith(base, transformCache.isReadableProviderFile);
46
47
  if (provider === void 0) continue;
47
48
  providers.push(provider);
48
- recordEntries(statics, specifier, readProviderEntries(provider), input);
49
+ const walk = { aliases, modules, providers };
50
+ recordEntries(statics, specifier, providerExports(provider, walk), input);
49
51
  break;
50
52
  }
51
53
  }
52
54
  return { statics, providers };
53
55
  }
54
- function readProviderEntries(provider) {
56
+ function providerExports(provider, context) {
57
+ const module = readProviderModule(provider, context.modules);
58
+ if (module.forwards.length === 0) return module.entries;
59
+ const declared = new Set(module.entries.map((entry) => entry.exportName));
60
+ const resolved = [...module.entries];
61
+ for (const forward of module.forwards) {
62
+ if (declared.has(forward.exportName)) continue;
63
+ const found = followForward(provider, forward, context, {
64
+ hops: transformCache.MAX_FORWARD_HOPS,
65
+ visited: /* @__PURE__ */ new Set([transformCache.forwardVisitKey(provider, forward.exportName)])
66
+ });
67
+ if (found !== void 0) resolved.push({ ...found, exportName: forward.exportName });
68
+ }
69
+ return resolved;
70
+ }
71
+ function followForward(fromPath, forward, context, walk) {
72
+ if (walk.hops <= 0) return void 0;
73
+ for (const base of transformCache.specifierBases(forward.specifier, path__namespace.dirname(fromPath), context.aliases)) {
74
+ const next = transformCache.resolveProviderPathWith(base, transformCache.isReadableProviderFile);
75
+ if (next === void 0) continue;
76
+ const key = transformCache.forwardVisitKey(next, forward.importedName);
77
+ if (walk.visited.has(key)) return void 0;
78
+ walk.visited.add(key);
79
+ context.providers.push(next);
80
+ const module = readProviderModule(next, context.modules);
81
+ const own = module.entries.find((entry) => entry.exportName === forward.importedName);
82
+ if (own !== void 0) return own;
83
+ const link = module.forwards.find((item) => item.exportName === forward.importedName);
84
+ if (link === void 0) return void 0;
85
+ return followForward(next, link, context, { hops: walk.hops - 1, visited: walk.visited });
86
+ }
87
+ return void 0;
88
+ }
89
+ function readProviderModule(provider, cache) {
90
+ const hit = cache.get(provider);
91
+ if (hit !== void 0) return hit;
92
+ let module = { entries: [], forwards: [] };
55
93
  try {
56
- return compiler.extractCrossModuleRegistryEntries(fs.readFileSync(provider, "utf8"), provider);
94
+ const text = fs.readFileSync(provider, "utf8");
95
+ module = {
96
+ entries: compiler.extractCrossModuleRegistryEntries(text, provider),
97
+ forwards: compiler.extractCrossModuleForwards(text, provider)
98
+ };
57
99
  } catch {
58
- return [];
59
100
  }
101
+ cache.set(provider, module);
102
+ return module;
60
103
  }
61
104
  function recordEntries(statics, specifier, entries, input) {
62
105
  for (const entry of entries) {
@@ -1,5 +1,5 @@
1
1
  import * as path from 'node:path';
2
- import { extractCrossModuleRegistryEntries } from '@csszyx/compiler';
2
+ import { extractCrossModuleRegistryEntries, extractCrossModuleForwards } from '@csszyx/compiler';
3
3
  import * as fs from 'node:fs';
4
4
  import { existsSync, statSync } from 'node:fs';
5
5
  import { createHash, randomUUID } from 'node:crypto';
@@ -194,7 +194,68 @@ const EMITTED_EXTENSION_SOURCES = [
194
194
  [".mjs", [".mts"]],
195
195
  [".cjs", [".cts"]]
196
196
  ];
197
- function resolveCrossModuleStaticsFor(registry, filename, source, aliases = []) {
197
+ function recordCrossModuleForwards(index, filePath, content) {
198
+ const key = normalizePathSeparators(filePath);
199
+ const forwards = extractCrossModuleForwards(content, filePath);
200
+ if (forwards.length === 0) index.delete(key);
201
+ else index.set(key, forwards);
202
+ }
203
+ const MAX_FORWARD_HOPS = 8;
204
+ function forwardVisitKey(modulePath, name) {
205
+ return `${modulePath}\0${name}`;
206
+ }
207
+ function moduleExports(registry, forwards, modulePath, aliases) {
208
+ const own = registry.get(modulePath);
209
+ const links = forwards.get(modulePath);
210
+ if (links === void 0) return own;
211
+ const merged = emptyNameIndex();
212
+ for (const [name, value] of Object.entries(own ?? {})) merged[name] = value;
213
+ for (const link of links) {
214
+ if (merged[link.exportName] !== void 0) continue;
215
+ const value = followForward(registry, forwards, modulePath, link, aliases, {
216
+ hops: MAX_FORWARD_HOPS,
217
+ visited: /* @__PURE__ */ new Set([forwardVisitKey(modulePath, link.exportName)])
218
+ });
219
+ if (value !== void 0) merged[link.exportName] = value;
220
+ }
221
+ return Object.keys(merged).length === 0 ? void 0 : merged;
222
+ }
223
+ function followForward(registry, forwards, fromPath, forward, aliases, walk) {
224
+ if (walk.hops <= 0) return void 0;
225
+ const directory = path.dirname(fromPath);
226
+ for (const base of specifierBases(forward.specifier, directory, aliases)) {
227
+ const providerPath = probeSpecifier(
228
+ base,
229
+ (candidate) => registry.has(candidate) || forwards.has(candidate) ? candidate : void 0
230
+ );
231
+ if (providerPath === void 0) continue;
232
+ return lookupForwardedExport(
233
+ registry,
234
+ forwards,
235
+ providerPath,
236
+ forward.importedName,
237
+ aliases,
238
+ walk
239
+ );
240
+ }
241
+ return void 0;
242
+ }
243
+ function lookupForwardedExport(registry, forwards, modulePath, name, aliases, walk) {
244
+ const key = forwardVisitKey(modulePath, name);
245
+ if (walk.visited.has(key)) return void 0;
246
+ walk.visited.add(key);
247
+ const own = registry.get(modulePath)?.[name];
248
+ if (own !== void 0) return own;
249
+ for (const link of forwards.get(modulePath) ?? []) {
250
+ if (link.exportName !== name) continue;
251
+ return followForward(registry, forwards, modulePath, link, aliases, {
252
+ hops: walk.hops - 1,
253
+ visited: walk.visited
254
+ });
255
+ }
256
+ return void 0;
257
+ }
258
+ function resolveCrossModuleStaticsFor(registry, filename, source, aliases = [], forwards = /* @__PURE__ */ new Map()) {
198
259
  if (registry.size === 0 || !source.includes("from")) return {};
199
260
  const directory = path.dirname(filename);
200
261
  const resolved = {};
@@ -202,15 +263,19 @@ function resolveCrossModuleStaticsFor(registry, filename, source, aliases = [])
202
263
  for (const specifier of importedSpecifiersIn(source)) {
203
264
  if (seen.has(specifier)) continue;
204
265
  seen.add(specifier);
205
- const entries = firstRegistryHit(registry, specifier, directory, aliases);
266
+ const entries = firstRegistryHit(registry, specifier, directory, aliases, forwards);
206
267
  if (entries !== void 0) fileUnderSpecifier(resolved, specifier, entries);
207
268
  }
208
269
  return resolved;
209
270
  }
210
- function firstRegistryHit(registry, specifier, directory, aliases) {
271
+ function firstRegistryHit(registry, specifier, directory, aliases, forwards) {
211
272
  for (const base of specifierBases(specifier, directory, aliases)) {
212
- const entries = lookupRegistryKey(registry, base);
213
- if (entries !== void 0) return entries;
273
+ const modulePath = probeSpecifier(
274
+ base,
275
+ (candidate) => registry.has(candidate) || forwards.has(candidate) ? candidate : void 0
276
+ );
277
+ if (modulePath === void 0) continue;
278
+ return moduleExports(registry, forwards, modulePath, aliases);
214
279
  }
215
280
  return void 0;
216
281
  }
@@ -266,9 +331,6 @@ function probeSpecifier(base, lookup) {
266
331
  }
267
332
  return void 0;
268
333
  }
269
- function lookupRegistryKey(registry, base) {
270
- return probeSpecifier(base, (candidate) => registry.get(candidate));
271
- }
272
334
 
273
335
  function isReadableProviderFile(candidate) {
274
336
  try {
@@ -487,4 +549,4 @@ function evictMemoryCacheToBudget(cache, totalCodeChars, maxEntries, maxCodeChar
487
549
  return total;
488
550
  }
489
551
 
490
- export { resolveProviderPathWith as a, recordResolvedEntry as b, collectSpecifierAliases as c, isReadableProviderFile as d, createTransformCacheKey as e, readTransformCache as f, recordSzvRegistryFile as g, recordSzObjectRegistryFile as h, importedSpecifiersIn as i, resolveCrossModuleStaticsFor as j, evictOldTransformCacheEntries as k, evictMemoryCacheToBudget as l, mayExportSzvFactories as m, normalizePathSeparators as n, resolveProviderPath as o, resolveTransformCacheDir as r, specifierBases as s, writeTransformCache as w };
552
+ export { MAX_FORWARD_HOPS as M, resolveProviderPathWith as a, recordResolvedEntry as b, collectSpecifierAliases as c, isReadableProviderFile as d, createTransformCacheKey as e, forwardVisitKey as f, readTransformCache as g, recordSzvRegistryFile as h, importedSpecifiersIn as i, recordCrossModuleForwards as j, recordSzObjectRegistryFile as k, resolveCrossModuleStaticsFor as l, evictOldTransformCacheEntries as m, normalizePathSeparators as n, mayExportSzvFactories as o, evictMemoryCacheToBudget as p, resolveProviderPath as q, resolveTransformCacheDir as r, specifierBases as s, writeTransformCache as w };
@@ -13,9 +13,9 @@ const svelteAdapter = require('@csszyx/svelte-adapter');
13
13
  const types = require('@csszyx/types');
14
14
  const vueAdapter = require('@csszyx/vue-adapter');
15
15
  const unplugin$1 = require('unplugin');
16
- const transformCache = require('./unplugin.BKGCkMgM.cjs');
16
+ const transformCache = require('./unplugin.VtXstzEh.cjs');
17
17
  const cssMangler = require('../css-mangler.cjs');
18
- const themeGroupsFile = require('./unplugin.CkNQjA4G.cjs');
18
+ const themeGroupsFile = require('./unplugin.D8BxOOkA.cjs');
19
19
  const htmlEscape = require('./unplugin.BkRah5Ot.cjs');
20
20
  const node_zlib = require('node:zlib');
21
21
  const postcss = require('postcss');
@@ -1501,6 +1501,49 @@ function collectAuthoredClassNames(source) {
1501
1501
  return classes;
1502
1502
  }
1503
1503
 
1504
+ const COLOR_CLASS_PREFIXES = [
1505
+ "text",
1506
+ "bg",
1507
+ "border",
1508
+ "decoration",
1509
+ "shadow",
1510
+ "outline",
1511
+ "ring",
1512
+ "fill",
1513
+ "stroke",
1514
+ "divide",
1515
+ "accent",
1516
+ "caret",
1517
+ "from",
1518
+ "via",
1519
+ "to",
1520
+ "inset-shadow",
1521
+ "inset-ring",
1522
+ "placeholder"
1523
+ ];
1524
+ function findClassNameAuthorConflicts(declared) {
1525
+ const generatedByTheme = new Set(
1526
+ declared.themeColors.flatMap(
1527
+ (name) => COLOR_CLASS_PREFIXES.map((prefix) => `${prefix}-${name}`)
1528
+ )
1529
+ );
1530
+ const conflicts = [];
1531
+ const seen = /* @__PURE__ */ new Set();
1532
+ for (const cls of declared.utilityStatics) {
1533
+ const declaredTwice = seen.has(cls);
1534
+ seen.add(cls);
1535
+ if (conflicts.some((existing) => existing.name === cls)) continue;
1536
+ if (declaredTwice) {
1537
+ conflicts.push({ name: cls, reason: "declared twice" });
1538
+ continue;
1539
+ }
1540
+ if (generatedByTheme.has(cls)) {
1541
+ conflicts.push({ name: cls, reason: "a theme token already generates it" });
1542
+ }
1543
+ }
1544
+ return conflicts;
1545
+ }
1546
+
1504
1547
  const KNOWN_TOP_LEVEL_KEYS = /* @__PURE__ */ new Set([
1505
1548
  "include",
1506
1549
  "exclude",
@@ -2055,13 +2098,14 @@ function findOpeningTag(source, tag) {
2055
2098
  from = start + marker.length;
2056
2099
  }
2057
2100
  }
2101
+ const _warnedClassNameAuthors = /* @__PURE__ */ new Set();
2058
2102
  let _hasWarnedTsConfig = false;
2059
2103
  let _hasWarnedTransformCacheVersion = false;
2060
2104
  let _hasWarnedNativeFallback = false;
2061
2105
  const _loggedActiveParsers = /* @__PURE__ */ new Set();
2062
- const requireFromHere = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared/unplugin.ZMa9YE1H.cjs', document.baseURI).href)));
2106
+ const requireFromHere = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared/unplugin.RGzhYt-D.cjs', document.baseURI).href)));
2063
2107
  const PLUGIN_VERSION = findPackageVersionFromFile(
2064
- node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared/unplugin.ZMa9YE1H.cjs', document.baseURI).href))),
2108
+ node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared/unplugin.RGzhYt-D.cjs', document.baseURI).href))),
2065
2109
  UNKNOWN_PACKAGE_VERSION
2066
2110
  );
2067
2111
  const COMPILER_VERSION = findPackageVersionFromModule("@csszyx/compiler", UNKNOWN_PACKAGE_VERSION);
@@ -2704,6 +2748,29 @@ function runThemeScan(rootDir, scanCss) {
2704
2748
  if (!scanCss) {
2705
2749
  return null;
2706
2750
  }
2751
+ function reportClassNameAuthorConflicts(rootDir2, sourceFiles2, theme) {
2752
+ const utilityStatics = [];
2753
+ for (const file of sourceFiles2) {
2754
+ try {
2755
+ utilityStatics.push(
2756
+ ...themeGroupsFile.parseUtilityBlocks(readStableTextFileSnapshotSync(file).source).statics
2757
+ );
2758
+ } catch {
2759
+ }
2760
+ }
2761
+ const conflicts = findClassNameAuthorConflicts({
2762
+ themeColors: theme.colors,
2763
+ utilityStatics
2764
+ });
2765
+ for (const conflict of conflicts) {
2766
+ const key = `${rootDir2}\0${conflict.name}`;
2767
+ if (_warnedClassNameAuthors.has(key)) continue;
2768
+ _warnedClassNameAuthors.add(key);
2769
+ console.warn(
2770
+ `[csszyx] "@utility ${conflict.name}" collides \u2014 ${conflict.reason}. Tailwind merges both declarations into one rule and reports nothing, so the class carries styles no single place in your CSS shows. Every use is affected, including sz props that spell it correctly. Rename it; if a multi-property class is the point, declare it under a name nothing else claims.`
2771
+ );
2772
+ }
2773
+ }
2707
2774
  const sourceFiles = expandFilePatterns(rootDir, scanCss).filter((file) => file.endsWith(".css"));
2708
2775
  if (sourceFiles.length === 0) {
2709
2776
  return null;
@@ -2716,6 +2783,7 @@ function runThemeScan(rootDir, scanCss) {
2716
2783
  }
2717
2784
  }).filter((t) => t !== null);
2718
2785
  const merged = themeGroupsFile.mergeThemes(themes);
2786
+ reportClassNameAuthorConflicts(rootDir, sourceFiles, merged);
2719
2787
  const outputPath = path__namespace.join(rootDir, ".csszyx", "theme.d.ts");
2720
2788
  writeThemeDts({ outputPath, theme: merged, sourceFiles });
2721
2789
  if (!_hasWarnedTsConfig) {
@@ -3042,6 +3110,7 @@ function createCsszyxPlugins(options = {}) {
3042
3110
  let manglingEnabled = options.production?.mangle === true;
3043
3111
  const importedStaticSzEnabled = options.build?.importedStaticSz ?? types.DEFAULT_IMPORTED_STATIC_SZ;
3044
3112
  const szvCrossModuleRegistry = /* @__PURE__ */ new Map();
3113
+ const szvCrossModuleForwards = /* @__PURE__ */ new Map();
3045
3114
  const szObjectProvidersExamined = /* @__PURE__ */ new Set();
3046
3115
  let specifierAliases = [];
3047
3116
  const mangleReserved = new Set(options.production?.mangleExclude ?? []);
@@ -3280,7 +3349,8 @@ function createCsszyxPlugins(options = {}) {
3280
3349
  szvCrossModuleRegistry,
3281
3350
  filename,
3282
3351
  source,
3283
- specifierAliases
3352
+ specifierAliases,
3353
+ szvCrossModuleForwards
3284
3354
  );
3285
3355
  if (crossModuleStatics.szvConfigs !== void 0) {
3286
3356
  compilerOptions.crossModuleStatics = crossModuleStatics.szvConfigs;
@@ -3411,7 +3481,8 @@ function createCsszyxPlugins(options = {}) {
3411
3481
  szvCrossModuleRegistry,
3412
3482
  file.filePath,
3413
3483
  file.content,
3414
- specifierAliases
3484
+ specifierAliases,
3485
+ szvCrossModuleForwards
3415
3486
  );
3416
3487
  return resolved.szvConfigs !== void 0 || resolved.szObjects !== void 0;
3417
3488
  }
@@ -3610,9 +3681,11 @@ function createCsszyxPlugins(options = {}) {
3610
3681
  if (!shouldProcessSource(filePath)) return;
3611
3682
  if (content === null) {
3612
3683
  szvCrossModuleRegistry.delete(transformCache.normalizePathSeparators(filePath));
3684
+ szvCrossModuleForwards.delete(transformCache.normalizePathSeparators(filePath));
3613
3685
  return;
3614
3686
  }
3615
3687
  transformCache.recordSzvRegistryFile(szvCrossModuleRegistry, filePath, content);
3688
+ transformCache.recordCrossModuleForwards(szvCrossModuleForwards, filePath, content);
3616
3689
  if (importedStaticSzEnabled) {
3617
3690
  transformCache.recordSzObjectRegistryFile(szvCrossModuleRegistry, filePath, content);
3618
3691
  szObjectProvidersExamined.add(transformCache.normalizePathSeparators(filePath));
@@ -3621,19 +3694,30 @@ function createCsszyxPlugins(options = {}) {
3621
3694
  }
3622
3695
  function recordProvidersDemandedBy(filePath, content) {
3623
3696
  if (!fileMayContainSafelistableSz(content)) return;
3624
- const directory = path__namespace.dirname(filePath);
3697
+ const queue = [];
3698
+ const queued = /* @__PURE__ */ new Set();
3625
3699
  for (const specifier of transformCache.importedSpecifiersIn(content)) {
3626
- for (const base of transformCache.specifierBases(specifier, directory, specifierAliases)) {
3627
- const providerPath = transformCache.resolveProviderPathWith(base, transformCache.isReadableProviderFile);
3628
- if (providerPath === void 0) continue;
3629
- const key = transformCache.normalizePathSeparators(providerPath);
3630
- if (!szObjectProvidersExamined.has(key)) {
3631
- szObjectProvidersExamined.add(key);
3632
- readAndRecordSzObjectProvider(providerPath);
3700
+ for (const base of transformCache.specifierBases(
3701
+ specifier,
3702
+ path__namespace.dirname(filePath),
3703
+ specifierAliases
3704
+ )) {
3705
+ if (!queued.has(base)) {
3706
+ queued.add(base);
3707
+ queue.push(base);
3633
3708
  }
3634
- break;
3635
3709
  }
3636
3710
  }
3711
+ for (const specifier of queue) {
3712
+ const providerPath = transformCache.resolveProviderPathWith(specifier, transformCache.isReadableProviderFile);
3713
+ if (providerPath === void 0) continue;
3714
+ const key = transformCache.normalizePathSeparators(providerPath);
3715
+ if (!szObjectProvidersExamined.has(key)) {
3716
+ szObjectProvidersExamined.add(key);
3717
+ readAndRecordSzObjectProvider(providerPath);
3718
+ }
3719
+ enqueueForwardedProviders(providerPath, queue, queued);
3720
+ }
3637
3721
  }
3638
3722
  function readAndRecordSzObjectProvider(providerPath) {
3639
3723
  let content;
@@ -3643,13 +3727,27 @@ function createCsszyxPlugins(options = {}) {
3643
3727
  return;
3644
3728
  }
3645
3729
  transformCache.recordSzObjectRegistryFile(szvCrossModuleRegistry, providerPath, content);
3730
+ transformCache.recordCrossModuleForwards(szvCrossModuleForwards, providerPath, content);
3646
3731
  }
3647
3732
  function recordDemandedSzObjectProviders(seenSourcePaths, demand) {
3648
- for (const base of demand) {
3649
- const providerPath = transformCache.resolveProviderPath(seenSourcePaths, base);
3733
+ const queue = [...demand];
3734
+ const queued = new Set(queue);
3735
+ for (const specifier of queue) {
3736
+ const providerPath = transformCache.resolveProviderPath(seenSourcePaths, specifier);
3650
3737
  if (providerPath === void 0) continue;
3651
3738
  szObjectProvidersExamined.add(transformCache.normalizePathSeparators(providerPath));
3652
3739
  readAndRecordSzObjectProvider(providerPath);
3740
+ enqueueForwardedProviders(providerPath, queue, queued);
3741
+ }
3742
+ }
3743
+ function enqueueForwardedProviders(providerPath, queue, queued) {
3744
+ const directory = path__namespace.dirname(providerPath);
3745
+ for (const forward of szvCrossModuleForwards.get(transformCache.normalizePathSeparators(providerPath)) ?? []) {
3746
+ for (const base of transformCache.specifierBases(forward.specifier, directory, specifierAliases)) {
3747
+ if (queued.has(base)) continue;
3748
+ queued.add(base);
3749
+ queue.push(base);
3750
+ }
3653
3751
  }
3654
3752
  }
3655
3753
  function refreshSzvRegistryEntryFromDisk(filePath) {
@@ -3666,6 +3764,7 @@ function createCsszyxPlugins(options = {}) {
3666
3764
  function prescanAndWriteClasses() {
3667
3765
  refreshCompileSourceDirs();
3668
3766
  szvCrossModuleRegistry.clear();
3767
+ szvCrossModuleForwards.clear();
3669
3768
  szObjectProvidersExamined.clear();
3670
3769
  const prescanStarted = node_perf_hooks.performance.now();
3671
3770
  const discoveredClasses = /* @__PURE__ */ new Set();
@@ -3686,6 +3785,7 @@ function createCsszyxPlugins(options = {}) {
3686
3785
  }
3687
3786
  recordAuthoredClasses(content);
3688
3787
  recordSzvRegistryEntries(filePath, content);
3788
+ transformCache.recordCrossModuleForwards(szvCrossModuleForwards, filePath, content);
3689
3789
  seenSourcePaths.add(transformCache.normalizePathSeparators(filePath));
3690
3790
  if (fileMayContainSafelistableSz(content)) {
3691
3791
  prescanSources.push({ filePath, content });
@@ -210,7 +210,68 @@ const EMITTED_EXTENSION_SOURCES = [
210
210
  [".mjs", [".mts"]],
211
211
  [".cjs", [".cts"]]
212
212
  ];
213
- function resolveCrossModuleStaticsFor(registry, filename, source, aliases = []) {
213
+ function recordCrossModuleForwards(index, filePath, content) {
214
+ const key = normalizePathSeparators(filePath);
215
+ const forwards = compiler.extractCrossModuleForwards(content, filePath);
216
+ if (forwards.length === 0) index.delete(key);
217
+ else index.set(key, forwards);
218
+ }
219
+ const MAX_FORWARD_HOPS = 8;
220
+ function forwardVisitKey(modulePath, name) {
221
+ return `${modulePath}\0${name}`;
222
+ }
223
+ function moduleExports(registry, forwards, modulePath, aliases) {
224
+ const own = registry.get(modulePath);
225
+ const links = forwards.get(modulePath);
226
+ if (links === void 0) return own;
227
+ const merged = emptyNameIndex();
228
+ for (const [name, value] of Object.entries(own ?? {})) merged[name] = value;
229
+ for (const link of links) {
230
+ if (merged[link.exportName] !== void 0) continue;
231
+ const value = followForward(registry, forwards, modulePath, link, aliases, {
232
+ hops: MAX_FORWARD_HOPS,
233
+ visited: /* @__PURE__ */ new Set([forwardVisitKey(modulePath, link.exportName)])
234
+ });
235
+ if (value !== void 0) merged[link.exportName] = value;
236
+ }
237
+ return Object.keys(merged).length === 0 ? void 0 : merged;
238
+ }
239
+ function followForward(registry, forwards, fromPath, forward, aliases, walk) {
240
+ if (walk.hops <= 0) return void 0;
241
+ const directory = path__namespace.dirname(fromPath);
242
+ for (const base of specifierBases(forward.specifier, directory, aliases)) {
243
+ const providerPath = probeSpecifier(
244
+ base,
245
+ (candidate) => registry.has(candidate) || forwards.has(candidate) ? candidate : void 0
246
+ );
247
+ if (providerPath === void 0) continue;
248
+ return lookupForwardedExport(
249
+ registry,
250
+ forwards,
251
+ providerPath,
252
+ forward.importedName,
253
+ aliases,
254
+ walk
255
+ );
256
+ }
257
+ return void 0;
258
+ }
259
+ function lookupForwardedExport(registry, forwards, modulePath, name, aliases, walk) {
260
+ const key = forwardVisitKey(modulePath, name);
261
+ if (walk.visited.has(key)) return void 0;
262
+ walk.visited.add(key);
263
+ const own = registry.get(modulePath)?.[name];
264
+ if (own !== void 0) return own;
265
+ for (const link of forwards.get(modulePath) ?? []) {
266
+ if (link.exportName !== name) continue;
267
+ return followForward(registry, forwards, modulePath, link, aliases, {
268
+ hops: walk.hops - 1,
269
+ visited: walk.visited
270
+ });
271
+ }
272
+ return void 0;
273
+ }
274
+ function resolveCrossModuleStaticsFor(registry, filename, source, aliases = [], forwards = /* @__PURE__ */ new Map()) {
214
275
  if (registry.size === 0 || !source.includes("from")) return {};
215
276
  const directory = path__namespace.dirname(filename);
216
277
  const resolved = {};
@@ -218,15 +279,19 @@ function resolveCrossModuleStaticsFor(registry, filename, source, aliases = [])
218
279
  for (const specifier of importedSpecifiersIn(source)) {
219
280
  if (seen.has(specifier)) continue;
220
281
  seen.add(specifier);
221
- const entries = firstRegistryHit(registry, specifier, directory, aliases);
282
+ const entries = firstRegistryHit(registry, specifier, directory, aliases, forwards);
222
283
  if (entries !== void 0) fileUnderSpecifier(resolved, specifier, entries);
223
284
  }
224
285
  return resolved;
225
286
  }
226
- function firstRegistryHit(registry, specifier, directory, aliases) {
287
+ function firstRegistryHit(registry, specifier, directory, aliases, forwards) {
227
288
  for (const base of specifierBases(specifier, directory, aliases)) {
228
- const entries = lookupRegistryKey(registry, base);
229
- if (entries !== void 0) return entries;
289
+ const modulePath = probeSpecifier(
290
+ base,
291
+ (candidate) => registry.has(candidate) || forwards.has(candidate) ? candidate : void 0
292
+ );
293
+ if (modulePath === void 0) continue;
294
+ return moduleExports(registry, forwards, modulePath, aliases);
230
295
  }
231
296
  return void 0;
232
297
  }
@@ -282,9 +347,6 @@ function probeSpecifier(base, lookup) {
282
347
  }
283
348
  return void 0;
284
349
  }
285
- function lookupRegistryKey(registry, base) {
286
- return probeSpecifier(base, (candidate) => registry.get(candidate));
287
- }
288
350
 
289
351
  function isReadableProviderFile(candidate) {
290
352
  try {
@@ -503,15 +565,18 @@ function evictMemoryCacheToBudget(cache, totalCodeChars, maxEntries, maxCodeChar
503
565
  return total;
504
566
  }
505
567
 
568
+ exports.MAX_FORWARD_HOPS = MAX_FORWARD_HOPS;
506
569
  exports.collectSpecifierAliases = collectSpecifierAliases;
507
570
  exports.createTransformCacheKey = createTransformCacheKey;
508
571
  exports.evictMemoryCacheToBudget = evictMemoryCacheToBudget;
509
572
  exports.evictOldTransformCacheEntries = evictOldTransformCacheEntries;
573
+ exports.forwardVisitKey = forwardVisitKey;
510
574
  exports.importedSpecifiersIn = importedSpecifiersIn;
511
575
  exports.isReadableProviderFile = isReadableProviderFile;
512
576
  exports.mayExportSzvFactories = mayExportSzvFactories;
513
577
  exports.normalizePathSeparators = normalizePathSeparators;
514
578
  exports.readTransformCache = readTransformCache;
579
+ exports.recordCrossModuleForwards = recordCrossModuleForwards;
515
580
  exports.recordResolvedEntry = recordResolvedEntry;
516
581
  exports.recordSzObjectRegistryFile = recordSzObjectRegistryFile;
517
582
  exports.recordSzvRegistryFile = recordSzvRegistryFile;
package/dist/vite.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const unplugin = require('./shared/unplugin.ZMa9YE1H.cjs');
5
+ const unplugin = require('./shared/unplugin.RGzhYt-D.cjs');
6
6
  require('node:crypto');
7
7
  require('node:fs');
8
8
  require('node:module');
@@ -16,11 +16,11 @@ require('@csszyx/svelte-adapter');
16
16
  require('@csszyx/types');
17
17
  require('@csszyx/vue-adapter');
18
18
  require('unplugin');
19
- require('./shared/unplugin.BKGCkMgM.cjs');
19
+ require('./shared/unplugin.VtXstzEh.cjs');
20
20
  require('./css-mangler.cjs');
21
21
  require('postcss');
22
22
  require('postcss-selector-parser');
23
- require('./shared/unplugin.CkNQjA4G.cjs');
23
+ require('./shared/unplugin.D8BxOOkA.cjs');
24
24
  require('./shared/unplugin.BkRah5Ot.cjs');
25
25
  require('node:zlib');
26
26
  require('postcss-value-parser');
package/dist/vite.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { ao } from './shared/unplugin.BsjD3mtb.cjs';
2
- export = ao;
1
+ import { aq } from './shared/unplugin.BXYakiXt.cjs';
2
+ export = aq;
3
3
  import '@csszyx/compiler';
4
4
  import '@csszyx/types';
5
5
  import 'esbuild';