@csszyx/unplugin 0.10.10 → 0.10.12

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,4 +1,4 @@
1
- import { GlobalVarUsageDiagnostic, CssVariableMangleValue, TransformSourceCodeOptions } from '@csszyx/compiler';
1
+ import { GlobalVarUsageDiagnostic, CssVariableMangleValue, TransformSourceCodeOptions, TokenData } from '@csszyx/compiler';
2
2
  import { PartialCsszyxConfig } from '@csszyx/types';
3
3
  import { Plugin } from 'esbuild';
4
4
  import { InputPluginOption } from 'rollup';
@@ -207,6 +207,250 @@ interface GlobalVarCssAliasRewriteResult {
207
207
  diagnostics: GlobalVarAliasDiagnostic[];
208
208
  }
209
209
 
210
+ /**
211
+ * Direct RSC boundary violation found in a transformed module.
212
+ */
213
+ interface RSCBoundaryViolation {
214
+ /** Forbidden runtime helper that crossed into an RSC server module. */
215
+ symbol: string;
216
+ /** Server module path where the import was found. */
217
+ path: string;
218
+ /** Import chain used in the fatal build error. */
219
+ importChain: string[];
220
+ }
221
+ /**
222
+ * RSC module metadata collected during the transform phase.
223
+ */
224
+ interface RSCModuleRecord {
225
+ /** Normalized absolute module ID. */
226
+ id: string;
227
+ /** True when this module is an RSC server module entry or has `'use server'`. */
228
+ isServer: boolean;
229
+ /** True when this module declares the client boundary. */
230
+ isClient: boolean;
231
+ /** Local modules imported by this file after path resolution. */
232
+ imports: string[];
233
+ /** Forbidden runtime imports found directly in this module. */
234
+ runtimeImports: Array<{
235
+ source: string;
236
+ symbols: string[];
237
+ }>;
238
+ }
239
+ /**
240
+ * Returns true when a module starts with the top-level `'use server'`
241
+ * directive. Comments and blank lines before the directive are allowed, but
242
+ * detection stops at the first real statement.
243
+ *
244
+ * @param code module source
245
+ * @returns true when the module has a top-level `'use server'` directive
246
+ */
247
+ declare function hasUseServerDirective(code: string): boolean;
248
+ /**
249
+ * Returns true when a module starts with the top-level `'use client'`
250
+ * directive.
251
+ *
252
+ * @param code module source
253
+ * @returns true when the module has a top-level `'use client'` directive
254
+ */
255
+ declare function hasUseClientDirective(code: string): boolean;
256
+ /**
257
+ * Detects modules that should be treated as RSC server modules by csszyx.
258
+ *
259
+ * @param code module source
260
+ * @param id module ID/path
261
+ * @returns true when the module is server-side for RSC boundary purposes
262
+ */
263
+ declare function isRSCServerModule(code: string, id: string): boolean;
264
+ /**
265
+ * Finds the first direct forbidden runtime helper import in an RSC server
266
+ * module.
267
+ *
268
+ * @param code module source
269
+ * @param id module ID/path
270
+ * @returns violation details, or null when the module is allowed
271
+ */
272
+ declare function findRSCBoundaryViolation(code: string, id: string): RSCBoundaryViolation | null;
273
+ /**
274
+ * Builds module metadata for the RSC graph walker.
275
+ *
276
+ * @param code module source
277
+ * @param id module ID/path
278
+ * @returns graph metadata for the module
279
+ */
280
+ declare function createRSCModuleRecord(code: string, id: string): RSCModuleRecord;
281
+ /**
282
+ * Removes a module record after the bundler watcher reports that the file was
283
+ * deleted.
284
+ *
285
+ * @param records module graph records keyed by normalized module ID
286
+ * @param id module ID/path from the watcher event
287
+ * @returns true when a stale record was removed
288
+ */
289
+ declare function deleteRSCModuleRecord(records: Map<string, RSCModuleRecord>, id: string): boolean;
290
+ /**
291
+ * Finds forbidden runtime helper imports reachable from an RSC server module.
292
+ * Traversal stops at `'use client'` modules because they define a separate
293
+ * client module graph.
294
+ *
295
+ * @param records module graph records keyed by normalized module ID
296
+ * @returns first graph violation, or null when the graph is allowed
297
+ */
298
+ declare function findRSCGraphViolation(records: Map<string, RSCModuleRecord>): RSCBoundaryViolation | null;
299
+ /**
300
+ * Throws the spec-format fatal RSC boundary error for graph-level violations.
301
+ *
302
+ * @param records module graph records keyed by normalized module ID
303
+ */
304
+ declare function assertNoRSCGraphViolation(records: Map<string, RSCModuleRecord>): void;
305
+ /**
306
+ * Throws the spec-format fatal RSC boundary error when a server module imports
307
+ * a forbidden csszyx runtime helper.
308
+ *
309
+ * @param code module source
310
+ * @param id module ID/path
311
+ */
312
+ declare function assertNoRSCBoundaryViolation(code: string, id: string): void;
313
+
314
+ /**
315
+ * Theme Scanner — parses Tailwind v4 @theme blocks from CSS files.
316
+ *
317
+ * Extracts custom design tokens and categorizes them by type so the
318
+ * type writer can generate accurate TypeScript augmentation.
319
+ *
320
+ * Supports:
321
+ * - Multiple @theme blocks per file
322
+ * - @theme inline { } syntax (inline keyword ignored)
323
+ * - @theme inside @layer (two-pass strip)
324
+ * - --color-brand-50 shade suffixes (deduped to 'brand')
325
+ * - Multi-file merge via mergeThemes()
326
+ */
327
+ /** Extracted and categorized custom tokens from @theme blocks. */
328
+ interface ParsedTheme {
329
+ /** Custom color names (from --color-*): e.g. ['brand', 'brand-dark'] */
330
+ colors: string[];
331
+ /** Custom spacing tokens (from --spacing-*): e.g. ['xl', '2xs'] */
332
+ spacings: string[];
333
+ /** Custom font families (from --font-*): e.g. ['display', 'body'] */
334
+ fonts: string[];
335
+ /** Custom font sizes (from --text-*): e.g. ['huge'] */
336
+ textSizes: string[];
337
+ /** Custom font weights (from --font-weight-*): e.g. ['chunky'] */
338
+ fontWeights: string[];
339
+ /** Custom border radii (from --radius-*): e.g. ['button'] */
340
+ radii: string[];
341
+ /** Custom shadows (from --shadow-*): e.g. ['card'] */
342
+ shadows: string[];
343
+ /** Custom responsive breakpoints (from --breakpoint-*): e.g. ['tablet', '3xl'] */
344
+ breakpoints: string[];
345
+ }
346
+ /**
347
+ * Parse all @theme blocks in a CSS file and extract design tokens.
348
+ *
349
+ * @param cssContent - Raw CSS file content
350
+ * @returns Categorized design tokens
351
+ */
352
+ declare function parseThemeBlocks(cssContent: string): ParsedTheme;
353
+ /**
354
+ * Merge multiple ParsedTheme objects into one, deduplicating tokens.
355
+ *
356
+ * @param themes - Array of parsed themes to merge
357
+ * @returns Merged theme with unique tokens per category
358
+ */
359
+ declare function mergeThemes(themes: ParsedTheme[]): ParsedTheme;
360
+ /**
361
+ * Check if a ParsedTheme has any tokens.
362
+ *
363
+ * @param theme - Parsed theme to check
364
+ * @returns True if at least one category has tokens
365
+ */
366
+ declare function hasTokens(theme: ParsedTheme): boolean;
367
+
368
+ /**
369
+ * Plugin state for mangle map management.
370
+ */
371
+ interface PluginState {
372
+ /**
373
+ * Every class csszyx wants Tailwind to generate CSS for — sz-generated
374
+ * classes plus raw author `className` values seen during the fallback scan.
375
+ * Drives the `@source` safelist; NOT the mangle map.
376
+ */
377
+ classes: Set<string>;
378
+ /** Merged @theme scan result — feeds the theme-groups virtual module. */
379
+ parsedTheme: ParsedTheme | null;
380
+ /**
381
+ * True once any processed CSS file was seen importing `tailwindcss`. Used to
382
+ * warn at build end when csszyx generated classes but nothing makes Tailwind
383
+ * emit their CSS (no entry → the classes resolve to no styles, silently).
384
+ */
385
+ sawTailwindEntry: boolean;
386
+ /**
387
+ * True once ANY CSS file passed through the transform hook. The missing-entry
388
+ * warning only fires when csszyx actually observed the CSS pipeline but found
389
+ * no `tailwindcss` entry — otherwise it false-positives in setups where CSS is
390
+ * handled outside this hook or not yet processed at build end (`astro check`,
391
+ * an early Astro build phase), where the build in fact emits valid CSS.
392
+ */
393
+ sawAnyCss: boolean;
394
+ /** Guards the missing-Tailwind-entry warning so it fires at most once. */
395
+ tailwindWarningEmitted: boolean;
396
+ /** Whether a Tailwind entry scoped content detection (source()/@source not). */
397
+ tailwindEntryScoped: boolean;
398
+ /** Guards the unscoped-monorepo warning so it fires at most once. */
399
+ contentScopeWarningEmitted: boolean;
400
+ /** Memoized `isMonorepoPackage(rootDir)` result; `undefined` until computed. */
401
+ inMonorepo?: boolean;
402
+ /**
403
+ * Classes csszyx generated by lowering `sz` props — the ONLY classes the
404
+ * mangle map may rename. Author-written `className` values are deliberately
405
+ * excluded: renaming them would break selectors an external stylesheet (or
406
+ * JS that references classes by name) owns.
407
+ */
408
+ ownedClasses: Set<string>;
409
+ /** Unresolvable-spread warnings surfaced to the build log in every mode. */
410
+ spreadWarnings: Set<string>;
411
+ /**
412
+ * Workspace-package files under `/packages/` that contain `sz` but were
413
+ * skipped by the hard-ignore (not under any `compileSources` dir). Surfaced at
414
+ * build end so the silent no-op (skipped `sz` → no CSS) becomes visible.
415
+ */
416
+ skippedSzFiles: Set<string>;
417
+ /** Guards the skipped-sz-files warning so it fires at most once. */
418
+ skipWarningEmitted: boolean;
419
+ /**
420
+ * Set once the safelist class set hits {@link MAX_SAFELIST_CLASSES} and extra
421
+ * classes are dropped — bounds memory/output growth from pathological input.
422
+ */
423
+ classesCapped: boolean;
424
+ mangleMap: Record<string, string>;
425
+ varMangleEntriesByFile: Map<string, Array<[string, string]>>;
426
+ varMangleMap: Record<string, CssVariableMangleValue>;
427
+ cssVarMetricsByFile: Map<string, CSSVariableMetrics>;
428
+ cssVarMetrics: CSSVariableMetrics;
429
+ checksum: string;
430
+ finalized: boolean;
431
+ rootDir: string;
432
+ /**
433
+ * Recovery tokens collected from szRecover JSX attributes across all
434
+ * transformed files. Aggregated by the `transform` hook (compiler emits
435
+ * the data-sz-recovery-token attribute and returns the per-file map),
436
+ * then serialised into the manifest script tag injected into SSR HTML.
437
+ */
438
+ recoveryTokens: Map<string, TokenData>;
439
+ /** RSC graph records collected from transformed TS/JS modules. */
440
+ rscModules: Map<string, RSCModuleRecord>;
441
+ /** Source files observed by the transform hook for global-var diagnostics. */
442
+ globalVarSourceFilesByFile: Map<string, string>;
443
+ /** Last validated global-var alias result for the current output hook. */
444
+ globalVarValidationResult: GlobalVarAliasValidationResult | null;
445
+ }
446
+ /** CSS variable mangling and hoisting metrics emitted for debugging. */
447
+ interface CSSVariableMetrics {
448
+ componentClassUses: number;
449
+ componentStyleDeclarations: number;
450
+ estimatedHoistedDeclarationsSaved: number;
451
+ scopedClassUses: number;
452
+ scopedStyleDeclarations: number;
453
+ }
210
454
  /**
211
455
  * Identity of the installed native engine binary for transform-cache keys.
212
456
  *
@@ -469,6 +713,28 @@ declare function skippedSzFilesMessage(files: readonly string[]): string;
469
713
  * @returns the posix relative path from the CSS file to the safelist file.
470
714
  */
471
715
  declare function computeSafelistRelPath(rootDir: string, safelistFilename: string, cssId: string): string;
716
+ /**
717
+ * Whether transformed source text must be retained for global-var alias
718
+ * validation. Retention is only consumed when `production.mangleGlobalVars`
719
+ * is explicitly enabled; recording without that consumer keeps the full text
720
+ * of every transformed JS/TS module alive for the plugin lifetime.
721
+ *
722
+ * @param config The `production.mangleGlobalVars` option value.
723
+ * @param config.enabled Whether global-var mangling is turned on.
724
+ * @returns True only when the feature is explicitly enabled.
725
+ */
726
+ declare function shouldTrackGlobalVarSources(config?: {
727
+ enabled?: boolean;
728
+ }): boolean;
729
+ /**
730
+ * Records source text available before bundling/minification for Phase H
731
+ * global-var diagnostics.
732
+ *
733
+ * @param state Plugin state to update.
734
+ * @param filename Source filename that owns the text.
735
+ * @param code Source text, or null to clear this file.
736
+ */
737
+ declare function recordGlobalVarSourceFile(state: Pick<PluginState, 'globalVarSourceFilesByFile'>, filename: string, code: string | null): void;
472
738
  /**
473
739
  * Extracts Phase H global custom-property aliases for manifest/debug tooling.
474
740
  *
@@ -540,5 +806,5 @@ declare const rollupPlugin: (options?: PartialCsszyxConfig) => InputPluginOption
540
806
  */
541
807
  declare const esbuildPlugin: (options?: PartialCsszyxConfig) => Plugin;
542
808
 
543
- export { isHardIgnoredPath as A, isMonorepoPackage as B, isPackagesSkippedSource as D, mangleCodeClassesSync as E, mangleHybridHazardMessage as F, missingTailwindEntryMessage as H, normalizeGlobalVarAliasesForCache as I, resolveCompileSourceDirs as J, resolveNativeCacheIdentity as K, rollupPlugin as L, shouldEmitWarning as N, shouldWarnMissingTailwindEntry as O, shouldWarnUnscopedMonorepo as Q, skippedSzFilesMessage as T, unscopedMonorepoMessage as U, vitePlugin as W, webpackPlugin as X, appendTailwindSourceDirective as o, collectMangleHybridHazards as p, computeSafelistRelPath as q, createGlobalVarMapAssetSource as r, cssHasContentScope as s, cssImportsTailwind as t, unplugin as u, esbuildPlugin as v, extractGlobalVarAliasesForManifest as w, fileMayContainSafelistableSz as x, hasInjectableTailwindCandidate as y, isCompileSourceOptedIn as z };
544
- export type { CssVarScanResult as C, GlobalVarScanCacheKeyInput as G, MangleHybridHazards as M, PlanGlobalVarAliasesInput as P, RewriteGlobalVarCssAliasesOptions as R, ScanGlobalVarCssOptions as S, ValidateGlobalVarAliasInputsOptions as V, GlobalVarAliasPlan as a, GlobalVarCssAliasRewriteResult as b, CreateGlobalVarAliasValidationOptionsInput as c, GlobalVarAliasValidationResult as d, CssVarDefinition as e, CssVarLocation as f, CssVarReference as g, GlobalVarAliasDiagnostic as h, GlobalVarAliasDiagnosticSeverity as i, GlobalVarAliasEntry as j, GlobalVarCodeSource as k, GlobalVarCssAssetSource as l, GlobalVarCssSource as m, GlobalVarScanCacheEntry as n };
809
+ export { normalizeGlobalVarAliasesForCache as $, unplugin as A, deleteRSCModuleRecord as B, esbuildPlugin as D, extractGlobalVarAliasesForManifest as E, fileMayContainSafelistableSz as F, findRSCBoundaryViolation as H, findRSCGraphViolation as I, hasInjectableTailwindCandidate as J, hasTokens as K, hasUseClientDirective as L, hasUseServerDirective as N, isCompileSourceOptedIn as O, isHardIgnoredPath as Q, isMonorepoPackage as T, isPackagesSkippedSource as U, isRSCServerModule as W, mangleCodeClassesSync as X, mangleHybridHazardMessage as Y, mergeThemes as Z, missingTailwindEntryMessage as _, parseThemeBlocks as a0, recordGlobalVarSourceFile as a1, resolveCompileSourceDirs as a2, resolveNativeCacheIdentity as a3, rollupPlugin as a4, shouldEmitWarning as a5, shouldTrackGlobalVarSources as a6, shouldWarnMissingTailwindEntry as a7, shouldWarnUnscopedMonorepo as a8, skippedSzFilesMessage as a9, unscopedMonorepoMessage as aa, vitePlugin as ab, webpackPlugin as ac, appendTailwindSourceDirective as r, assertNoRSCBoundaryViolation as s, assertNoRSCGraphViolation as t, collectMangleHybridHazards as u, computeSafelistRelPath as v, createGlobalVarMapAssetSource as w, createRSCModuleRecord as x, cssHasContentScope as y, cssImportsTailwind as z };
810
+ export type { CssVarScanResult as C, GlobalVarScanCacheKeyInput as G, MangleHybridHazards as M, PlanGlobalVarAliasesInput as P, RewriteGlobalVarCssAliasesOptions as R, ScanGlobalVarCssOptions as S, ValidateGlobalVarAliasInputsOptions as V, GlobalVarAliasPlan as a, GlobalVarCssAliasRewriteResult as b, CreateGlobalVarAliasValidationOptionsInput as c, GlobalVarAliasValidationResult as d, CssVarDefinition as e, CssVarLocation as f, CssVarReference as g, GlobalVarAliasDiagnostic as h, GlobalVarAliasDiagnosticSeverity as i, GlobalVarAliasEntry as j, GlobalVarCodeSource as k, GlobalVarCssAssetSource as l, GlobalVarCssSource as m, GlobalVarScanCacheEntry as n, ParsedTheme as o, RSCBoundaryViolation as p, RSCModuleRecord as q };
@@ -1,4 +1,4 @@
1
- import { GlobalVarUsageDiagnostic, CssVariableMangleValue, TransformSourceCodeOptions } from '@csszyx/compiler';
1
+ import { GlobalVarUsageDiagnostic, CssVariableMangleValue, TransformSourceCodeOptions, TokenData } from '@csszyx/compiler';
2
2
  import { PartialCsszyxConfig } from '@csszyx/types';
3
3
  import { Plugin } from 'esbuild';
4
4
  import { InputPluginOption } from 'rollup';
@@ -207,6 +207,250 @@ interface GlobalVarCssAliasRewriteResult {
207
207
  diagnostics: GlobalVarAliasDiagnostic[];
208
208
  }
209
209
 
210
+ /**
211
+ * Direct RSC boundary violation found in a transformed module.
212
+ */
213
+ interface RSCBoundaryViolation {
214
+ /** Forbidden runtime helper that crossed into an RSC server module. */
215
+ symbol: string;
216
+ /** Server module path where the import was found. */
217
+ path: string;
218
+ /** Import chain used in the fatal build error. */
219
+ importChain: string[];
220
+ }
221
+ /**
222
+ * RSC module metadata collected during the transform phase.
223
+ */
224
+ interface RSCModuleRecord {
225
+ /** Normalized absolute module ID. */
226
+ id: string;
227
+ /** True when this module is an RSC server module entry or has `'use server'`. */
228
+ isServer: boolean;
229
+ /** True when this module declares the client boundary. */
230
+ isClient: boolean;
231
+ /** Local modules imported by this file after path resolution. */
232
+ imports: string[];
233
+ /** Forbidden runtime imports found directly in this module. */
234
+ runtimeImports: Array<{
235
+ source: string;
236
+ symbols: string[];
237
+ }>;
238
+ }
239
+ /**
240
+ * Returns true when a module starts with the top-level `'use server'`
241
+ * directive. Comments and blank lines before the directive are allowed, but
242
+ * detection stops at the first real statement.
243
+ *
244
+ * @param code module source
245
+ * @returns true when the module has a top-level `'use server'` directive
246
+ */
247
+ declare function hasUseServerDirective(code: string): boolean;
248
+ /**
249
+ * Returns true when a module starts with the top-level `'use client'`
250
+ * directive.
251
+ *
252
+ * @param code module source
253
+ * @returns true when the module has a top-level `'use client'` directive
254
+ */
255
+ declare function hasUseClientDirective(code: string): boolean;
256
+ /**
257
+ * Detects modules that should be treated as RSC server modules by csszyx.
258
+ *
259
+ * @param code module source
260
+ * @param id module ID/path
261
+ * @returns true when the module is server-side for RSC boundary purposes
262
+ */
263
+ declare function isRSCServerModule(code: string, id: string): boolean;
264
+ /**
265
+ * Finds the first direct forbidden runtime helper import in an RSC server
266
+ * module.
267
+ *
268
+ * @param code module source
269
+ * @param id module ID/path
270
+ * @returns violation details, or null when the module is allowed
271
+ */
272
+ declare function findRSCBoundaryViolation(code: string, id: string): RSCBoundaryViolation | null;
273
+ /**
274
+ * Builds module metadata for the RSC graph walker.
275
+ *
276
+ * @param code module source
277
+ * @param id module ID/path
278
+ * @returns graph metadata for the module
279
+ */
280
+ declare function createRSCModuleRecord(code: string, id: string): RSCModuleRecord;
281
+ /**
282
+ * Removes a module record after the bundler watcher reports that the file was
283
+ * deleted.
284
+ *
285
+ * @param records module graph records keyed by normalized module ID
286
+ * @param id module ID/path from the watcher event
287
+ * @returns true when a stale record was removed
288
+ */
289
+ declare function deleteRSCModuleRecord(records: Map<string, RSCModuleRecord>, id: string): boolean;
290
+ /**
291
+ * Finds forbidden runtime helper imports reachable from an RSC server module.
292
+ * Traversal stops at `'use client'` modules because they define a separate
293
+ * client module graph.
294
+ *
295
+ * @param records module graph records keyed by normalized module ID
296
+ * @returns first graph violation, or null when the graph is allowed
297
+ */
298
+ declare function findRSCGraphViolation(records: Map<string, RSCModuleRecord>): RSCBoundaryViolation | null;
299
+ /**
300
+ * Throws the spec-format fatal RSC boundary error for graph-level violations.
301
+ *
302
+ * @param records module graph records keyed by normalized module ID
303
+ */
304
+ declare function assertNoRSCGraphViolation(records: Map<string, RSCModuleRecord>): void;
305
+ /**
306
+ * Throws the spec-format fatal RSC boundary error when a server module imports
307
+ * a forbidden csszyx runtime helper.
308
+ *
309
+ * @param code module source
310
+ * @param id module ID/path
311
+ */
312
+ declare function assertNoRSCBoundaryViolation(code: string, id: string): void;
313
+
314
+ /**
315
+ * Theme Scanner — parses Tailwind v4 @theme blocks from CSS files.
316
+ *
317
+ * Extracts custom design tokens and categorizes them by type so the
318
+ * type writer can generate accurate TypeScript augmentation.
319
+ *
320
+ * Supports:
321
+ * - Multiple @theme blocks per file
322
+ * - @theme inline { } syntax (inline keyword ignored)
323
+ * - @theme inside @layer (two-pass strip)
324
+ * - --color-brand-50 shade suffixes (deduped to 'brand')
325
+ * - Multi-file merge via mergeThemes()
326
+ */
327
+ /** Extracted and categorized custom tokens from @theme blocks. */
328
+ interface ParsedTheme {
329
+ /** Custom color names (from --color-*): e.g. ['brand', 'brand-dark'] */
330
+ colors: string[];
331
+ /** Custom spacing tokens (from --spacing-*): e.g. ['xl', '2xs'] */
332
+ spacings: string[];
333
+ /** Custom font families (from --font-*): e.g. ['display', 'body'] */
334
+ fonts: string[];
335
+ /** Custom font sizes (from --text-*): e.g. ['huge'] */
336
+ textSizes: string[];
337
+ /** Custom font weights (from --font-weight-*): e.g. ['chunky'] */
338
+ fontWeights: string[];
339
+ /** Custom border radii (from --radius-*): e.g. ['button'] */
340
+ radii: string[];
341
+ /** Custom shadows (from --shadow-*): e.g. ['card'] */
342
+ shadows: string[];
343
+ /** Custom responsive breakpoints (from --breakpoint-*): e.g. ['tablet', '3xl'] */
344
+ breakpoints: string[];
345
+ }
346
+ /**
347
+ * Parse all @theme blocks in a CSS file and extract design tokens.
348
+ *
349
+ * @param cssContent - Raw CSS file content
350
+ * @returns Categorized design tokens
351
+ */
352
+ declare function parseThemeBlocks(cssContent: string): ParsedTheme;
353
+ /**
354
+ * Merge multiple ParsedTheme objects into one, deduplicating tokens.
355
+ *
356
+ * @param themes - Array of parsed themes to merge
357
+ * @returns Merged theme with unique tokens per category
358
+ */
359
+ declare function mergeThemes(themes: ParsedTheme[]): ParsedTheme;
360
+ /**
361
+ * Check if a ParsedTheme has any tokens.
362
+ *
363
+ * @param theme - Parsed theme to check
364
+ * @returns True if at least one category has tokens
365
+ */
366
+ declare function hasTokens(theme: ParsedTheme): boolean;
367
+
368
+ /**
369
+ * Plugin state for mangle map management.
370
+ */
371
+ interface PluginState {
372
+ /**
373
+ * Every class csszyx wants Tailwind to generate CSS for — sz-generated
374
+ * classes plus raw author `className` values seen during the fallback scan.
375
+ * Drives the `@source` safelist; NOT the mangle map.
376
+ */
377
+ classes: Set<string>;
378
+ /** Merged @theme scan result — feeds the theme-groups virtual module. */
379
+ parsedTheme: ParsedTheme | null;
380
+ /**
381
+ * True once any processed CSS file was seen importing `tailwindcss`. Used to
382
+ * warn at build end when csszyx generated classes but nothing makes Tailwind
383
+ * emit their CSS (no entry → the classes resolve to no styles, silently).
384
+ */
385
+ sawTailwindEntry: boolean;
386
+ /**
387
+ * True once ANY CSS file passed through the transform hook. The missing-entry
388
+ * warning only fires when csszyx actually observed the CSS pipeline but found
389
+ * no `tailwindcss` entry — otherwise it false-positives in setups where CSS is
390
+ * handled outside this hook or not yet processed at build end (`astro check`,
391
+ * an early Astro build phase), where the build in fact emits valid CSS.
392
+ */
393
+ sawAnyCss: boolean;
394
+ /** Guards the missing-Tailwind-entry warning so it fires at most once. */
395
+ tailwindWarningEmitted: boolean;
396
+ /** Whether a Tailwind entry scoped content detection (source()/@source not). */
397
+ tailwindEntryScoped: boolean;
398
+ /** Guards the unscoped-monorepo warning so it fires at most once. */
399
+ contentScopeWarningEmitted: boolean;
400
+ /** Memoized `isMonorepoPackage(rootDir)` result; `undefined` until computed. */
401
+ inMonorepo?: boolean;
402
+ /**
403
+ * Classes csszyx generated by lowering `sz` props — the ONLY classes the
404
+ * mangle map may rename. Author-written `className` values are deliberately
405
+ * excluded: renaming them would break selectors an external stylesheet (or
406
+ * JS that references classes by name) owns.
407
+ */
408
+ ownedClasses: Set<string>;
409
+ /** Unresolvable-spread warnings surfaced to the build log in every mode. */
410
+ spreadWarnings: Set<string>;
411
+ /**
412
+ * Workspace-package files under `/packages/` that contain `sz` but were
413
+ * skipped by the hard-ignore (not under any `compileSources` dir). Surfaced at
414
+ * build end so the silent no-op (skipped `sz` → no CSS) becomes visible.
415
+ */
416
+ skippedSzFiles: Set<string>;
417
+ /** Guards the skipped-sz-files warning so it fires at most once. */
418
+ skipWarningEmitted: boolean;
419
+ /**
420
+ * Set once the safelist class set hits {@link MAX_SAFELIST_CLASSES} and extra
421
+ * classes are dropped — bounds memory/output growth from pathological input.
422
+ */
423
+ classesCapped: boolean;
424
+ mangleMap: Record<string, string>;
425
+ varMangleEntriesByFile: Map<string, Array<[string, string]>>;
426
+ varMangleMap: Record<string, CssVariableMangleValue>;
427
+ cssVarMetricsByFile: Map<string, CSSVariableMetrics>;
428
+ cssVarMetrics: CSSVariableMetrics;
429
+ checksum: string;
430
+ finalized: boolean;
431
+ rootDir: string;
432
+ /**
433
+ * Recovery tokens collected from szRecover JSX attributes across all
434
+ * transformed files. Aggregated by the `transform` hook (compiler emits
435
+ * the data-sz-recovery-token attribute and returns the per-file map),
436
+ * then serialised into the manifest script tag injected into SSR HTML.
437
+ */
438
+ recoveryTokens: Map<string, TokenData>;
439
+ /** RSC graph records collected from transformed TS/JS modules. */
440
+ rscModules: Map<string, RSCModuleRecord>;
441
+ /** Source files observed by the transform hook for global-var diagnostics. */
442
+ globalVarSourceFilesByFile: Map<string, string>;
443
+ /** Last validated global-var alias result for the current output hook. */
444
+ globalVarValidationResult: GlobalVarAliasValidationResult | null;
445
+ }
446
+ /** CSS variable mangling and hoisting metrics emitted for debugging. */
447
+ interface CSSVariableMetrics {
448
+ componentClassUses: number;
449
+ componentStyleDeclarations: number;
450
+ estimatedHoistedDeclarationsSaved: number;
451
+ scopedClassUses: number;
452
+ scopedStyleDeclarations: number;
453
+ }
210
454
  /**
211
455
  * Identity of the installed native engine binary for transform-cache keys.
212
456
  *
@@ -469,6 +713,28 @@ declare function skippedSzFilesMessage(files: readonly string[]): string;
469
713
  * @returns the posix relative path from the CSS file to the safelist file.
470
714
  */
471
715
  declare function computeSafelistRelPath(rootDir: string, safelistFilename: string, cssId: string): string;
716
+ /**
717
+ * Whether transformed source text must be retained for global-var alias
718
+ * validation. Retention is only consumed when `production.mangleGlobalVars`
719
+ * is explicitly enabled; recording without that consumer keeps the full text
720
+ * of every transformed JS/TS module alive for the plugin lifetime.
721
+ *
722
+ * @param config The `production.mangleGlobalVars` option value.
723
+ * @param config.enabled Whether global-var mangling is turned on.
724
+ * @returns True only when the feature is explicitly enabled.
725
+ */
726
+ declare function shouldTrackGlobalVarSources(config?: {
727
+ enabled?: boolean;
728
+ }): boolean;
729
+ /**
730
+ * Records source text available before bundling/minification for Phase H
731
+ * global-var diagnostics.
732
+ *
733
+ * @param state Plugin state to update.
734
+ * @param filename Source filename that owns the text.
735
+ * @param code Source text, or null to clear this file.
736
+ */
737
+ declare function recordGlobalVarSourceFile(state: Pick<PluginState, 'globalVarSourceFilesByFile'>, filename: string, code: string | null): void;
472
738
  /**
473
739
  * Extracts Phase H global custom-property aliases for manifest/debug tooling.
474
740
  *
@@ -540,5 +806,5 @@ declare const rollupPlugin: (options?: PartialCsszyxConfig) => InputPluginOption
540
806
  */
541
807
  declare const esbuildPlugin: (options?: PartialCsszyxConfig) => Plugin;
542
808
 
543
- export { isHardIgnoredPath as A, isMonorepoPackage as B, isPackagesSkippedSource as D, mangleCodeClassesSync as E, mangleHybridHazardMessage as F, missingTailwindEntryMessage as H, normalizeGlobalVarAliasesForCache as I, resolveCompileSourceDirs as J, resolveNativeCacheIdentity as K, rollupPlugin as L, shouldEmitWarning as N, shouldWarnMissingTailwindEntry as O, shouldWarnUnscopedMonorepo as Q, skippedSzFilesMessage as T, unscopedMonorepoMessage as U, vitePlugin as W, webpackPlugin as X, appendTailwindSourceDirective as o, collectMangleHybridHazards as p, computeSafelistRelPath as q, createGlobalVarMapAssetSource as r, cssHasContentScope as s, cssImportsTailwind as t, unplugin as u, esbuildPlugin as v, extractGlobalVarAliasesForManifest as w, fileMayContainSafelistableSz as x, hasInjectableTailwindCandidate as y, isCompileSourceOptedIn as z };
544
- export type { CssVarScanResult as C, GlobalVarScanCacheKeyInput as G, MangleHybridHazards as M, PlanGlobalVarAliasesInput as P, RewriteGlobalVarCssAliasesOptions as R, ScanGlobalVarCssOptions as S, ValidateGlobalVarAliasInputsOptions as V, GlobalVarAliasPlan as a, GlobalVarCssAliasRewriteResult as b, CreateGlobalVarAliasValidationOptionsInput as c, GlobalVarAliasValidationResult as d, CssVarDefinition as e, CssVarLocation as f, CssVarReference as g, GlobalVarAliasDiagnostic as h, GlobalVarAliasDiagnosticSeverity as i, GlobalVarAliasEntry as j, GlobalVarCodeSource as k, GlobalVarCssAssetSource as l, GlobalVarCssSource as m, GlobalVarScanCacheEntry as n };
809
+ export { normalizeGlobalVarAliasesForCache as $, unplugin as A, deleteRSCModuleRecord as B, esbuildPlugin as D, extractGlobalVarAliasesForManifest as E, fileMayContainSafelistableSz as F, findRSCBoundaryViolation as H, findRSCGraphViolation as I, hasInjectableTailwindCandidate as J, hasTokens as K, hasUseClientDirective as L, hasUseServerDirective as N, isCompileSourceOptedIn as O, isHardIgnoredPath as Q, isMonorepoPackage as T, isPackagesSkippedSource as U, isRSCServerModule as W, mangleCodeClassesSync as X, mangleHybridHazardMessage as Y, mergeThemes as Z, missingTailwindEntryMessage as _, parseThemeBlocks as a0, recordGlobalVarSourceFile as a1, resolveCompileSourceDirs as a2, resolveNativeCacheIdentity as a3, rollupPlugin as a4, shouldEmitWarning as a5, shouldTrackGlobalVarSources as a6, shouldWarnMissingTailwindEntry as a7, shouldWarnUnscopedMonorepo as a8, skippedSzFilesMessage as a9, unscopedMonorepoMessage as aa, vitePlugin as ab, webpackPlugin as ac, appendTailwindSourceDirective as r, assertNoRSCBoundaryViolation as s, assertNoRSCGraphViolation as t, collectMangleHybridHazards as u, computeSafelistRelPath as v, createGlobalVarMapAssetSource as w, createRSCModuleRecord as x, cssHasContentScope as y, cssImportsTailwind as z };
810
+ export type { CssVarScanResult as C, GlobalVarScanCacheKeyInput as G, MangleHybridHazards as M, PlanGlobalVarAliasesInput as P, RewriteGlobalVarCssAliasesOptions as R, ScanGlobalVarCssOptions as S, ValidateGlobalVarAliasInputsOptions as V, GlobalVarAliasPlan as a, GlobalVarCssAliasRewriteResult as b, CreateGlobalVarAliasValidationOptionsInput as c, GlobalVarAliasValidationResult as d, CssVarDefinition as e, CssVarLocation as f, CssVarReference as g, GlobalVarAliasDiagnostic as h, GlobalVarAliasDiagnosticSeverity as i, GlobalVarAliasEntry as j, GlobalVarCodeSource as k, GlobalVarCssAssetSource as l, GlobalVarCssSource as m, GlobalVarScanCacheEntry as n, ParsedTheme as o, RSCBoundaryViolation as p, RSCModuleRecord as q };