@csszyx/unplugin 0.15.2 → 0.16.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.
@@ -4,6 +4,7 @@ import { Plugin } from 'esbuild';
4
4
  import { InputPluginOption } from 'rollup';
5
5
  import { UnpluginInstance, WebpackPluginInstance } from 'unplugin';
6
6
  import { PluginOption } from 'vite';
7
+ import { ClassAttributeSelector } from '../css-mangler.mjs';
7
8
 
8
9
  /** Source location for one CSS custom-property occurrence. */
9
10
  interface CssVarLocation {
@@ -655,6 +656,25 @@ interface MangleHybridHazards {
655
656
  * DOM class is rewritten to a token with no rule → the element loses styling.
656
657
  */
657
658
  orphans: string[];
659
+ /**
660
+ * Attribute selectors on `class` whose match depends on a name the map
661
+ * renamed. `[class*="bg-tag"]` matched `bg-tag-blue-bg` by text; after
662
+ * the rename the element carries `y4`, the rule stops applying, and
663
+ * nothing in the build says so — the CSS is intact and the page renders.
664
+ * Absent when the caller has no selector census.
665
+ */
666
+ selectorMatches?: MangleSelectorHazard[];
667
+ }
668
+ /** One attribute selector the mangle map breaks or newly satisfies. */
669
+ interface MangleSelectorHazard {
670
+ /** The selector as written: `[class*="bg-tag"]`, with ` i` when case-insensitive. */
671
+ selector: string;
672
+ /** The attribute value the selector compares against, unescaped. */
673
+ value: string;
674
+ /** Map keys the selector was matching by name, sorted; renamed, so it no longer does. */
675
+ renamed: string[];
676
+ /** Tokens the selector would start matching that no class name did before, sorted. */
677
+ matchedTokens: string[];
658
678
  }
659
679
  /**
660
680
  * Detect hybrid-mangle hazards from the accumulated per-asset mangle results.
@@ -662,9 +682,10 @@ interface MangleHybridHazards {
662
682
  * @param mangleMap - the full original→token map injected into the runtime.
663
683
  * @param mangledSources - map keys that were actually found and renamed in some CSS asset.
664
684
  * @param externalClasses - class names found in CSS that are NOT in the mangle map (non-csszyx).
665
- * @returns the colliding tokens and orphan sources (each sorted, deduped).
685
+ * @param attributeSelectors - every `[class …]` selector the emitted CSS contains.
686
+ * @returns the colliding tokens, orphan sources and selector hazards (each sorted, deduped).
666
687
  */
667
- declare function collectMangleHybridHazards(mangleMap: Record<string, string>, mangledSources: ReadonlySet<string>, externalClasses: ReadonlySet<string>): MangleHybridHazards;
688
+ declare function collectMangleHybridHazards(mangleMap: Record<string, string>, mangledSources: ReadonlySet<string>, externalClasses: ReadonlySet<string>, attributeSelectors?: readonly ClassAttributeSelector[]): MangleHybridHazards;
668
689
  /**
669
690
  * Build the hybrid-mangle hazard warning, or null when there is nothing to warn.
670
691
  *
@@ -799,6 +820,22 @@ declare function shouldEmitWarning(quiet: QuietMode, devOnly: boolean, isProduct
799
820
  * @returns True when the diagnostic is an unsilenced missing-CSS failure.
800
821
  */
801
822
  declare function shouldEmitMissingCssFallback(quiet: QuietMode, message: string): boolean;
823
+ /**
824
+ * Whether this run holds the advisory fallback list back and counts it instead.
825
+ *
826
+ * A build prints the count once the bundle closes, so holding the list back
827
+ * still leaves a reader a number to act on. A dev server never closes a bundle:
828
+ * anything held back there is held back for good, which is why serving lists
829
+ * its fallbacks whatever the environment says. `NODE_ENV` alone was the whole
830
+ * test, and a monorepo script that exports it while running a dev server turned
831
+ * every advisory into a number nothing would print.
832
+ *
833
+ * @param quiet - Resolved quiet mode.
834
+ * @param serving - Whether this is a dev server rather than a build.
835
+ * @param nodeEnv - `process.env.NODE_ENV` as the process sees it.
836
+ * @returns True when the list is withheld in favour of a count.
837
+ */
838
+ declare function shouldHoldAdvisories(quiet: QuietMode, serving: boolean, nodeEnv: string | undefined): boolean;
802
839
  /**
803
840
  * Emit one missing-CSS fallback through the caller's output channel.
804
841
  *
@@ -1042,5 +1079,5 @@ declare const rollupPlugin: (options?: PartialCsszyxConfig) => InputPluginOption
1042
1079
  */
1043
1080
  declare const esbuildPlugin: (options?: PartialCsszyxConfig) => Plugin;
1044
1081
 
1045
- export { lateMangleCensusMessage as $, deleteRSCModuleRecord as A, emitMissingCssFallback as B, esbuildPlugin as D, extractGlobalVarAliasesForManifest as E, fileMayContainSafelistableSz as F, findLocalImportSources as H, findRSCBoundaryViolation as I, findRSCGraphViolation as J, hasInjectableTailwindCandidate as K, hasTokens as L, hasUseClientDirective as N, hasUseServerDirective as O, isAdvisoryDiagnostic as T, isCompileSourceOptedIn as U, isHardIgnoredPath as W, isMangleableCssId as X, isMonorepoPackage as Y, isPackagesSkippedSource as Z, isRSCServerModule as _, mangleCodeClassesSync as a0, mangleEligibleClasses as a1, mangleHybridHazardMessage as a2, mergeThemes as a3, missingTailwindEntryMessage as a4, normalizeGlobalVarAliasesForCache as a5, parseThemeBlocks as a6, parseUtilityBlocks as a7, realContentHashDisabledMessage as a8, recordGlobalVarSourceFile as a9, resolveCompileSourceDirs as aa, resolveNativeCacheIdentity as ab, resolveQuietMode as ac, rollupPlugin as ad, scanCustomPropertyNames as ae, shouldEmitMissingCssFallback as af, shouldEmitWarning as ag, shouldTrackGlobalVarSources as ah, shouldWarnMissingTailwindEntry as ai, shouldWarnUnscopedMonorepo as aj, skippedSzFilesMessage as ak, suppressedAdvisoryMessage as al, unscopedMonorepoMessage as am, vitePlugin as an, watchModeMangleMessage as ao, webpackPlugin as ap, allocateMangleTokens as s, assertNoRSCBoundaryViolation as t, assertNoRSCGraphViolation as u, collectMangleHybridHazards as v, createGlobalVarMapAssetSource as w, createRSCModuleRecord as x, cssHasContentScope as y, unplugin as z };
1046
- export type { CssVarScanResult as C, GlobalVarScanCacheKeyInput as G, MangleHybridHazards as M, PlanGlobalVarAliasesInput as P, QuietMode as Q, 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, ParsedUtilities as p, RSCBoundaryViolation as q, RSCModuleRecord as r };
1082
+ export { isRSCServerModule as $, unplugin as A, deleteRSCModuleRecord as B, emitMissingCssFallback as D, esbuildPlugin as E, extractGlobalVarAliasesForManifest as F, fileMayContainSafelistableSz as H, findLocalImportSources as I, findRSCBoundaryViolation as J, findRSCGraphViolation as K, hasInjectableTailwindCandidate as L, hasTokens as N, hasUseClientDirective as O, hasUseServerDirective as T, isAdvisoryDiagnostic as U, isCompileSourceOptedIn as W, isHardIgnoredPath as X, isMangleableCssId as Y, isMonorepoPackage as Z, isPackagesSkippedSource as _, lateMangleCensusMessage as a0, mangleCodeClassesSync as a1, mangleEligibleClasses as a2, mangleHybridHazardMessage as a3, mergeThemes as a4, missingTailwindEntryMessage as a5, normalizeGlobalVarAliasesForCache as a6, parseThemeBlocks as a7, parseUtilityBlocks as a8, realContentHashDisabledMessage as a9, recordGlobalVarSourceFile as aa, resolveCompileSourceDirs as ab, resolveNativeCacheIdentity as ac, resolveQuietMode as ad, rollupPlugin as ae, scanCustomPropertyNames as af, shouldEmitMissingCssFallback as ag, shouldEmitWarning as ah, shouldHoldAdvisories as ai, shouldTrackGlobalVarSources as aj, shouldWarnMissingTailwindEntry as ak, shouldWarnUnscopedMonorepo as al, skippedSzFilesMessage as am, suppressedAdvisoryMessage as an, unscopedMonorepoMessage as ao, vitePlugin as ap, watchModeMangleMessage as aq, webpackPlugin as ar, allocateMangleTokens as t, assertNoRSCBoundaryViolation as u, assertNoRSCGraphViolation as v, collectMangleHybridHazards as w, createGlobalVarMapAssetSource as x, createRSCModuleRecord as y, cssHasContentScope as z };
1083
+ export type { CssVarScanResult as C, GlobalVarScanCacheKeyInput as G, MangleHybridHazards as M, PlanGlobalVarAliasesInput as P, QuietMode as Q, 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, MangleSelectorHazard as o, ParsedTheme as p, ParsedUtilities as q, RSCBoundaryViolation as r, RSCModuleRecord as s };
@@ -545,4 +545,4 @@ function evictMemoryCacheToBudget(cache, totalCodeChars, maxEntries, maxCodeChar
545
545
  return total;
546
546
  }
547
547
 
548
- 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, evictOldTransformCacheEntries as h, importedSpecifiersIn as i, recordSzvRegistryFile as j, recordCrossModuleForwards as k, recordSzObjectRegistryFile as l, mayExportSzvFactories as m, resolveCrossModuleStaticsFor as n, resolveProviderPath as o, evictMemoryCacheToBudget as p, resolveTransformCacheDir as r, specifierBases as s, writeTransformCache as w };
548
+ 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, evictOldTransformCacheEntries as h, importedSpecifiersIn as i, recordSzvRegistryFile as j, recordCrossModuleForwards as k, recordSzObjectRegistryFile as l, mayExportSzvFactories as m, resolveProviderPath as n, resolveCrossModuleStaticsFor as o, evictMemoryCacheToBudget as p, resolveTransformCacheDir as r, specifierBases as s, writeTransformCache as w };
@@ -587,4 +587,4 @@ function themeGroupsSpecifier(fromFile, themeGroupsFile) {
587
587
  return relative.startsWith("./") || relative.startsWith("../") ? relative : `./${relative}`;
588
588
  }
589
589
 
590
- export { CHECKSUM_PLACEHOLDER as C, MANGLE_RUNTIME_VIRTUAL_ID as M, RESOLVED_VIRTUAL_MODULE_ID as R, THEME_GROUPS_VIRTUAL_ID as T, VAR_MANGLE_MAP_PLACEHOLDER as V, parseUtilityBlocks as a, insertAfterUseDirective as b, createMangleRuntimeModule as c, createThemeGroupsModule as d, ensureThemeGroupsFile as e, createMangleMapModule as f, RESOLVED_VIRTUAL_CHECKSUM_ID as g, hasTokens as h, injectNextRuntimeImports as i, createChecksumModule as j, RESOLVED_MANGLE_RUNTIME_VIRTUAL_ID as k, RESOLVED_THEME_GROUPS_VIRTUAL_ID as l, mergeThemes as m, isVirtualModule as n, discoverProjectTheme as o, parseThemeBlocks as p, CENSUS_PLACEHOLDER as q, resolveVirtualModule as r, scanCustomPropertyNames as s, themeGroupsSpecifier as t, importsRuntimeHelper as u, findRuntimeImportClause as v, THEME_GROUPS_FILE_MARKER as w, runtimeHelperGroupsFromUsage as x, MANGLE_MAP_PLACEHOLDER as y };
590
+ export { CHECKSUM_PLACEHOLDER as C, MANGLE_RUNTIME_VIRTUAL_ID as M, RESOLVED_VIRTUAL_MODULE_ID as R, THEME_GROUPS_VIRTUAL_ID as T, VAR_MANGLE_MAP_PLACEHOLDER as V, parseUtilityBlocks as a, insertAfterUseDirective as b, createMangleRuntimeModule as c, createMangleMapModule as d, ensureThemeGroupsFile as e, RESOLVED_VIRTUAL_CHECKSUM_ID as f, createChecksumModule as g, hasTokens as h, injectNextRuntimeImports as i, RESOLVED_MANGLE_RUNTIME_VIRTUAL_ID as j, RESOLVED_THEME_GROUPS_VIRTUAL_ID as k, createThemeGroupsModule as l, mergeThemes as m, isVirtualModule as n, discoverProjectTheme as o, parseThemeBlocks as p, CENSUS_PLACEHOLDER as q, resolveVirtualModule as r, scanCustomPropertyNames as s, themeGroupsSpecifier as t, importsRuntimeHelper as u, findRuntimeImportClause as v, THEME_GROUPS_FILE_MARKER as w, runtimeHelperGroupsFromUsage as x, MANGLE_MAP_PLACEHOLDER as y };