@csszyx/types 0.9.0 → 0.9.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/README.md CHANGED
@@ -52,6 +52,7 @@ import type {
52
52
  CsszyxConfig, // Main configuration interface
53
53
  DevelopmentConfig, // Development mode options
54
54
  ProductionConfig, // Production mode options
55
+ GlobalVarMangleConfig, // Global CSS variable alias options
55
56
  BuildConfig, // Build pipeline options
56
57
  HydrationConfig, // Hydration safety options
57
58
  PerformanceConfig, // Performance optimization options
@@ -77,6 +78,10 @@ const userConfig: PartialCsszyxConfig = {
77
78
  },
78
79
  production: {
79
80
  mangle: true,
81
+ mangleGlobalVars: {
82
+ enabled: true,
83
+ tokens: ["--brand-primary"],
84
+ },
80
85
  },
81
86
  };
82
87
 
@@ -90,6 +95,28 @@ const config: CsszyxConfig = {
90
95
  };
91
96
  ```
92
97
 
98
+ #### Global Variable Alias Safety
99
+
100
+ `production.mangleGlobalVars` aliases explicit app-owned custom-property
101
+ `tokens` in Phase H v1. Tailwind-owned `@theme` namespaces are rejected by
102
+ shared config validation and must not be passed in `tokens` or `autoPrefix`.
103
+ `autoPrefix` remains blocked until CSS pre-scan support exists.
104
+
105
+ Use the option only for explicit tokens that are defined by the same production
106
+ build. Alias mode preserves the original custom-property names, rewrites static
107
+ `sz` references and CSS `var(--token)` references, and does not optimize runtime
108
+ fallback `sz={expr}` shapes.
109
+
110
+ `emitMap` defaults to `true` and emits `.csszyx/global-var-map.json` for tooling.
111
+ Set it to `false` only when the standalone map file is not needed; the build
112
+ manifest still carries `globalVarAliases`.
113
+
114
+ The reserved namespace list is exported as `TAILWIND_RESERVED_PREFIXES`, with
115
+ `isTailwindReservedCustomProperty(name)` for validation. It follows Tailwind's
116
+ theme variable namespace documentation. If Tailwind adds a new namespace, update
117
+ `packages/types/src/tailwind-reserved.ts` and add scanner/config tests in the
118
+ same change.
119
+
93
120
  ### Runtime Types (`/runtime`)
94
121
 
95
122
  Types for runtime operations:
package/dist/config.cjs CHANGED
@@ -1,56 +1,14 @@
1
1
  'use strict';
2
2
 
3
- const DEFAULT_DEVELOPMENT_CONFIG = {
4
- strictMode: false,
5
- debug: false
6
- };
7
- const DEFAULT_PRODUCTION_CONFIG = {
8
- mangle: true,
9
- contentHashing: true,
10
- injectChecksum: true,
11
- incrementalBuild: true,
12
- minify: true
13
- };
14
- const DEFAULT_BUILD_CONFIG = {
15
- tailwindConfig: "tailwind.config.js",
16
- outputDir: ".csszyx",
17
- cacheDir: ".csszyx/cache",
18
- cache: true,
19
- astBudgetLimit: 5e4,
20
- parser: "rust"
21
- };
22
- const DEFAULT_HYDRATION_CONFIG = {
23
- strict: true,
24
- defaultRecoveryMode: null,
25
- auditLog: true
26
- };
27
- const DEFAULT_PERFORMANCE_CONFIG = {
28
- parallel: true,
29
- optimizeVariables: true,
30
- zeroRuntime: true
31
- };
32
- const DEFAULT_CSSZYX_CONFIG = {
33
- development: DEFAULT_DEVELOPMENT_CONFIG,
34
- production: DEFAULT_PRODUCTION_CONFIG,
35
- build: DEFAULT_BUILD_CONFIG,
36
- hydration: DEFAULT_HYDRATION_CONFIG,
37
- performance: DEFAULT_PERFORMANCE_CONFIG
38
- };
39
- function getCurrentEnvironment() {
40
- const env = process.env.NODE_ENV;
41
- if (env === "production") {
42
- return "production";
43
- }
44
- if (env === "test") {
45
- return "test";
46
- }
47
- return "development";
48
- }
3
+ const config = require('./shared/types.BN-D_2jm.cjs');
49
4
 
50
- exports.DEFAULT_BUILD_CONFIG = DEFAULT_BUILD_CONFIG;
51
- exports.DEFAULT_CSSZYX_CONFIG = DEFAULT_CSSZYX_CONFIG;
52
- exports.DEFAULT_DEVELOPMENT_CONFIG = DEFAULT_DEVELOPMENT_CONFIG;
53
- exports.DEFAULT_HYDRATION_CONFIG = DEFAULT_HYDRATION_CONFIG;
54
- exports.DEFAULT_PERFORMANCE_CONFIG = DEFAULT_PERFORMANCE_CONFIG;
55
- exports.DEFAULT_PRODUCTION_CONFIG = DEFAULT_PRODUCTION_CONFIG;
56
- exports.getCurrentEnvironment = getCurrentEnvironment;
5
+
6
+
7
+ exports.DEFAULT_BUILD_CONFIG = config.DEFAULT_BUILD_CONFIG;
8
+ exports.DEFAULT_CSSZYX_CONFIG = config.DEFAULT_CSSZYX_CONFIG;
9
+ exports.DEFAULT_DEVELOPMENT_CONFIG = config.DEFAULT_DEVELOPMENT_CONFIG;
10
+ exports.DEFAULT_HYDRATION_CONFIG = config.DEFAULT_HYDRATION_CONFIG;
11
+ exports.DEFAULT_PERFORMANCE_CONFIG = config.DEFAULT_PERFORMANCE_CONFIG;
12
+ exports.DEFAULT_PRODUCTION_CONFIG = config.DEFAULT_PRODUCTION_CONFIG;
13
+ exports.getCurrentEnvironment = config.getCurrentEnvironment;
14
+ exports.validateGlobalVarMangleConfig = config.validateGlobalVarMangleConfig;
package/dist/config.d.cts CHANGED
@@ -1,9 +1,3 @@
1
- /**
2
- * Configuration types for csszyx.
3
- *
4
- * This module defines all configuration interfaces and types used
5
- * throughout the csszyx framework.
6
- */
7
1
  /**
8
2
  * Development mode configuration options.
9
3
  */
@@ -33,6 +27,37 @@ interface ProductionConfig {
33
27
  * @default true
34
28
  */
35
29
  mangle: boolean;
30
+ /**
31
+ * Enable CSS custom property name mangling and hoisting.
32
+ *
33
+ * This is an opt-in feature gate for the tiered CSS variable system.
34
+ * When disabled, dynamic `sz` values keep the existing `--_sz-*`
35
+ * variable names and no variable hoisting is applied.
36
+ *
37
+ * @default false
38
+ */
39
+ mangleVars: boolean;
40
+ /**
41
+ * Maximum cascade depth for component-tier CSS variable hoisting.
42
+ *
43
+ * Only used when `mangleVars` is enabled. Lower values prefer local scoped
44
+ * variables; higher values allow hoisting across deeper DOM subtrees.
45
+ *
46
+ * @default 5
47
+ */
48
+ mangleVarHoistMaxDepth: number;
49
+ /**
50
+ * Alias stable app-owned global CSS custom properties.
51
+ *
52
+ * This is the opt-in gate for the `g` tier. Phase H v1 is alias-only:
53
+ * original public custom-property declarations remain defined, and
54
+ * csszyx-owned references may use short generated aliases. Explicit
55
+ * `tokens` are supported first; `autoPrefix` remains blocked until CSS
56
+ * pre-scan support exists.
57
+ *
58
+ * @default undefined (disabled)
59
+ */
60
+ mangleGlobalVars?: GlobalVarMangleConfig;
36
61
  /**
37
62
  * Enable content hashing for immutable caching.
38
63
  *
@@ -58,6 +83,88 @@ interface ProductionConfig {
58
83
  */
59
84
  minify: boolean;
60
85
  }
86
+ /**
87
+ * Supported global custom-property optimization mode.
88
+ */
89
+ type GlobalVarMangleMode = 'alias';
90
+ /**
91
+ * Reaction to unsafe global custom-property usage.
92
+ */
93
+ type GlobalVarUnsafeUsageMode = 'error';
94
+ /**
95
+ * Configuration for app-owned global custom-property aliases.
96
+ */
97
+ interface GlobalVarMangleConfig {
98
+ /**
99
+ * Master switch for global custom-property aliasing.
100
+ *
101
+ * @default false
102
+ */
103
+ enabled: boolean;
104
+ /**
105
+ * Phase H v1 only supports alias mode.
106
+ *
107
+ * @default "alias"
108
+ */
109
+ mode?: GlobalVarMangleMode;
110
+ /**
111
+ * Explicit app-owned custom-property names to alias.
112
+ *
113
+ * Every token must include the leading `--`.
114
+ *
115
+ * @default []
116
+ */
117
+ tokens?: string[];
118
+ /**
119
+ * Optional app-owned prefix discovery. Empty string disables prefix
120
+ * discovery and requires explicit tokens.
121
+ *
122
+ * This must not default to a Tailwind namespace or the generated alias
123
+ * prefix.
124
+ *
125
+ * @default ""
126
+ */
127
+ autoPrefix?: string;
128
+ /**
129
+ * Prefix used for generated global aliases.
130
+ *
131
+ * Phase H v1 defaults to `---g`, then appends csszyx's z-y-x encoder
132
+ * output: `---gz`, `---gy`, `---gx`, ...
133
+ *
134
+ * @default "---g"
135
+ */
136
+ aliasPrefix?: string;
137
+ /**
138
+ * Unsafe usage handling. Phase H v1 keeps this as error-only.
139
+ *
140
+ * @default "error"
141
+ */
142
+ onUnsafeUsage?: GlobalVarUnsafeUsageMode;
143
+ /**
144
+ * Additional app-specific custom-property names or prefixes that must
145
+ * never be aliased. Tailwind-owned prefixes are reserved implicitly by the
146
+ * implementation.
147
+ *
148
+ * @default []
149
+ */
150
+ reserved?: string[];
151
+ /**
152
+ * Emit the standalone `.csszyx/global-var-map.json` tooling asset.
153
+ *
154
+ * `csszyx-manifest.json` still includes `globalVarAliases` when aliases
155
+ * exist, so disabling this only removes the extra dedicated map file.
156
+ *
157
+ * @default true
158
+ */
159
+ emitMap?: boolean;
160
+ }
161
+ /**
162
+ * Validates the Phase H global variable alias config shape.
163
+ *
164
+ * @param config User-provided global variable alias config.
165
+ * @returns Validation errors. Empty means the config shape is valid.
166
+ */
167
+ declare function validateGlobalVarMangleConfig(config: GlobalVarMangleConfig | undefined): string[];
61
168
  /**
62
169
  * Build pipeline configuration.
63
170
  */
@@ -268,5 +375,5 @@ type Environment = 'development' | 'production' | 'test';
268
375
  */
269
376
  declare function getCurrentEnvironment(): Environment;
270
377
 
271
- export { DEFAULT_BUILD_CONFIG, DEFAULT_CSSZYX_CONFIG, DEFAULT_DEVELOPMENT_CONFIG, DEFAULT_HYDRATION_CONFIG, DEFAULT_PERFORMANCE_CONFIG, DEFAULT_PRODUCTION_CONFIG, getCurrentEnvironment };
272
- export type { BuildConfig, CsszyxConfig, DevelopmentConfig, Environment, FilePattern, HydrationConfig, PartialCsszyxConfig, PerformanceConfig, ProductionConfig };
378
+ export { DEFAULT_BUILD_CONFIG, DEFAULT_CSSZYX_CONFIG, DEFAULT_DEVELOPMENT_CONFIG, DEFAULT_HYDRATION_CONFIG, DEFAULT_PERFORMANCE_CONFIG, DEFAULT_PRODUCTION_CONFIG, getCurrentEnvironment, validateGlobalVarMangleConfig };
379
+ export type { BuildConfig, CsszyxConfig, DevelopmentConfig, Environment, FilePattern, GlobalVarMangleConfig, GlobalVarMangleMode, GlobalVarUnsafeUsageMode, HydrationConfig, PartialCsszyxConfig, PerformanceConfig, ProductionConfig };
package/dist/config.d.mts CHANGED
@@ -1,9 +1,3 @@
1
- /**
2
- * Configuration types for csszyx.
3
- *
4
- * This module defines all configuration interfaces and types used
5
- * throughout the csszyx framework.
6
- */
7
1
  /**
8
2
  * Development mode configuration options.
9
3
  */
@@ -33,6 +27,37 @@ interface ProductionConfig {
33
27
  * @default true
34
28
  */
35
29
  mangle: boolean;
30
+ /**
31
+ * Enable CSS custom property name mangling and hoisting.
32
+ *
33
+ * This is an opt-in feature gate for the tiered CSS variable system.
34
+ * When disabled, dynamic `sz` values keep the existing `--_sz-*`
35
+ * variable names and no variable hoisting is applied.
36
+ *
37
+ * @default false
38
+ */
39
+ mangleVars: boolean;
40
+ /**
41
+ * Maximum cascade depth for component-tier CSS variable hoisting.
42
+ *
43
+ * Only used when `mangleVars` is enabled. Lower values prefer local scoped
44
+ * variables; higher values allow hoisting across deeper DOM subtrees.
45
+ *
46
+ * @default 5
47
+ */
48
+ mangleVarHoistMaxDepth: number;
49
+ /**
50
+ * Alias stable app-owned global CSS custom properties.
51
+ *
52
+ * This is the opt-in gate for the `g` tier. Phase H v1 is alias-only:
53
+ * original public custom-property declarations remain defined, and
54
+ * csszyx-owned references may use short generated aliases. Explicit
55
+ * `tokens` are supported first; `autoPrefix` remains blocked until CSS
56
+ * pre-scan support exists.
57
+ *
58
+ * @default undefined (disabled)
59
+ */
60
+ mangleGlobalVars?: GlobalVarMangleConfig;
36
61
  /**
37
62
  * Enable content hashing for immutable caching.
38
63
  *
@@ -58,6 +83,88 @@ interface ProductionConfig {
58
83
  */
59
84
  minify: boolean;
60
85
  }
86
+ /**
87
+ * Supported global custom-property optimization mode.
88
+ */
89
+ type GlobalVarMangleMode = 'alias';
90
+ /**
91
+ * Reaction to unsafe global custom-property usage.
92
+ */
93
+ type GlobalVarUnsafeUsageMode = 'error';
94
+ /**
95
+ * Configuration for app-owned global custom-property aliases.
96
+ */
97
+ interface GlobalVarMangleConfig {
98
+ /**
99
+ * Master switch for global custom-property aliasing.
100
+ *
101
+ * @default false
102
+ */
103
+ enabled: boolean;
104
+ /**
105
+ * Phase H v1 only supports alias mode.
106
+ *
107
+ * @default "alias"
108
+ */
109
+ mode?: GlobalVarMangleMode;
110
+ /**
111
+ * Explicit app-owned custom-property names to alias.
112
+ *
113
+ * Every token must include the leading `--`.
114
+ *
115
+ * @default []
116
+ */
117
+ tokens?: string[];
118
+ /**
119
+ * Optional app-owned prefix discovery. Empty string disables prefix
120
+ * discovery and requires explicit tokens.
121
+ *
122
+ * This must not default to a Tailwind namespace or the generated alias
123
+ * prefix.
124
+ *
125
+ * @default ""
126
+ */
127
+ autoPrefix?: string;
128
+ /**
129
+ * Prefix used for generated global aliases.
130
+ *
131
+ * Phase H v1 defaults to `---g`, then appends csszyx's z-y-x encoder
132
+ * output: `---gz`, `---gy`, `---gx`, ...
133
+ *
134
+ * @default "---g"
135
+ */
136
+ aliasPrefix?: string;
137
+ /**
138
+ * Unsafe usage handling. Phase H v1 keeps this as error-only.
139
+ *
140
+ * @default "error"
141
+ */
142
+ onUnsafeUsage?: GlobalVarUnsafeUsageMode;
143
+ /**
144
+ * Additional app-specific custom-property names or prefixes that must
145
+ * never be aliased. Tailwind-owned prefixes are reserved implicitly by the
146
+ * implementation.
147
+ *
148
+ * @default []
149
+ */
150
+ reserved?: string[];
151
+ /**
152
+ * Emit the standalone `.csszyx/global-var-map.json` tooling asset.
153
+ *
154
+ * `csszyx-manifest.json` still includes `globalVarAliases` when aliases
155
+ * exist, so disabling this only removes the extra dedicated map file.
156
+ *
157
+ * @default true
158
+ */
159
+ emitMap?: boolean;
160
+ }
161
+ /**
162
+ * Validates the Phase H global variable alias config shape.
163
+ *
164
+ * @param config User-provided global variable alias config.
165
+ * @returns Validation errors. Empty means the config shape is valid.
166
+ */
167
+ declare function validateGlobalVarMangleConfig(config: GlobalVarMangleConfig | undefined): string[];
61
168
  /**
62
169
  * Build pipeline configuration.
63
170
  */
@@ -268,5 +375,5 @@ type Environment = 'development' | 'production' | 'test';
268
375
  */
269
376
  declare function getCurrentEnvironment(): Environment;
270
377
 
271
- export { DEFAULT_BUILD_CONFIG, DEFAULT_CSSZYX_CONFIG, DEFAULT_DEVELOPMENT_CONFIG, DEFAULT_HYDRATION_CONFIG, DEFAULT_PERFORMANCE_CONFIG, DEFAULT_PRODUCTION_CONFIG, getCurrentEnvironment };
272
- export type { BuildConfig, CsszyxConfig, DevelopmentConfig, Environment, FilePattern, HydrationConfig, PartialCsszyxConfig, PerformanceConfig, ProductionConfig };
378
+ export { DEFAULT_BUILD_CONFIG, DEFAULT_CSSZYX_CONFIG, DEFAULT_DEVELOPMENT_CONFIG, DEFAULT_HYDRATION_CONFIG, DEFAULT_PERFORMANCE_CONFIG, DEFAULT_PRODUCTION_CONFIG, getCurrentEnvironment, validateGlobalVarMangleConfig };
379
+ export type { BuildConfig, CsszyxConfig, DevelopmentConfig, Environment, FilePattern, GlobalVarMangleConfig, GlobalVarMangleMode, GlobalVarUnsafeUsageMode, HydrationConfig, PartialCsszyxConfig, PerformanceConfig, ProductionConfig };
package/dist/config.mjs CHANGED
@@ -1,48 +1 @@
1
- const DEFAULT_DEVELOPMENT_CONFIG = {
2
- strictMode: false,
3
- debug: false
4
- };
5
- const DEFAULT_PRODUCTION_CONFIG = {
6
- mangle: true,
7
- contentHashing: true,
8
- injectChecksum: true,
9
- incrementalBuild: true,
10
- minify: true
11
- };
12
- const DEFAULT_BUILD_CONFIG = {
13
- tailwindConfig: "tailwind.config.js",
14
- outputDir: ".csszyx",
15
- cacheDir: ".csszyx/cache",
16
- cache: true,
17
- astBudgetLimit: 5e4,
18
- parser: "rust"
19
- };
20
- const DEFAULT_HYDRATION_CONFIG = {
21
- strict: true,
22
- defaultRecoveryMode: null,
23
- auditLog: true
24
- };
25
- const DEFAULT_PERFORMANCE_CONFIG = {
26
- parallel: true,
27
- optimizeVariables: true,
28
- zeroRuntime: true
29
- };
30
- const DEFAULT_CSSZYX_CONFIG = {
31
- development: DEFAULT_DEVELOPMENT_CONFIG,
32
- production: DEFAULT_PRODUCTION_CONFIG,
33
- build: DEFAULT_BUILD_CONFIG,
34
- hydration: DEFAULT_HYDRATION_CONFIG,
35
- performance: DEFAULT_PERFORMANCE_CONFIG
36
- };
37
- function getCurrentEnvironment() {
38
- const env = process.env.NODE_ENV;
39
- if (env === "production") {
40
- return "production";
41
- }
42
- if (env === "test") {
43
- return "test";
44
- }
45
- return "development";
46
- }
47
-
48
- export { DEFAULT_BUILD_CONFIG, DEFAULT_CSSZYX_CONFIG, DEFAULT_DEVELOPMENT_CONFIG, DEFAULT_HYDRATION_CONFIG, DEFAULT_PERFORMANCE_CONFIG, DEFAULT_PRODUCTION_CONFIG, getCurrentEnvironment };
1
+ export { D as DEFAULT_BUILD_CONFIG, a as DEFAULT_CSSZYX_CONFIG, b as DEFAULT_DEVELOPMENT_CONFIG, c as DEFAULT_HYDRATION_CONFIG, d as DEFAULT_PERFORMANCE_CONFIG, e as DEFAULT_PRODUCTION_CONFIG, g as getCurrentEnvironment, v as validateGlobalVarMangleConfig } from './shared/types.ClLdsRKs.mjs';
package/dist/index.cjs CHANGED
@@ -1,16 +1,21 @@
1
1
  'use strict';
2
2
 
3
- const config = require('./config.cjs');
3
+ const config = require('./shared/types.BN-D_2jm.cjs');
4
4
  const runtime = require('./runtime.cjs');
5
5
 
6
6
  const VERSION = "0.0.0";
7
7
 
8
+ exports.CSSZYX_GLOBAL_ALIAS_PREFIX = config.CSSZYX_GLOBAL_ALIAS_PREFIX;
8
9
  exports.DEFAULT_BUILD_CONFIG = config.DEFAULT_BUILD_CONFIG;
9
10
  exports.DEFAULT_CSSZYX_CONFIG = config.DEFAULT_CSSZYX_CONFIG;
10
11
  exports.DEFAULT_DEVELOPMENT_CONFIG = config.DEFAULT_DEVELOPMENT_CONFIG;
11
12
  exports.DEFAULT_HYDRATION_CONFIG = config.DEFAULT_HYDRATION_CONFIG;
12
13
  exports.DEFAULT_PERFORMANCE_CONFIG = config.DEFAULT_PERFORMANCE_CONFIG;
13
14
  exports.DEFAULT_PRODUCTION_CONFIG = config.DEFAULT_PRODUCTION_CONFIG;
15
+ exports.TAILWIND_RESERVED_PREFIXES = config.TAILWIND_RESERVED_PREFIXES;
14
16
  exports.getCurrentEnvironment = config.getCurrentEnvironment;
17
+ exports.isCsszyxGlobalAliasCustomProperty = config.isCsszyxGlobalAliasCustomProperty;
18
+ exports.isTailwindReservedCustomProperty = config.isTailwindReservedCustomProperty;
19
+ exports.validateGlobalVarMangleConfig = config.validateGlobalVarMangleConfig;
15
20
  exports.isCsszyxWindow = runtime.isCsszyxWindow;
16
21
  exports.VERSION = VERSION;
package/dist/index.d.cts CHANGED
@@ -1,8 +1,8 @@
1
1
  export { BuildPhase, BuildPhaseResult, BuildPhaseStatus, BuildResult, BuildStatistics, CacheEntry, CacheManager, CollisionResult, CompilerContext, CompilerOptions, CompilerPlugin, FileCompilationResult, GeneratedToken, MangleMapEntry, NodeLocation, TokenMetadata, TransformOptions, ValidationError, ValidationResult } from './compiler.cjs';
2
- export { BuildConfig, CsszyxConfig, DEFAULT_BUILD_CONFIG, DEFAULT_CSSZYX_CONFIG, DEFAULT_DEVELOPMENT_CONFIG, DEFAULT_HYDRATION_CONFIG, DEFAULT_PERFORMANCE_CONFIG, DEFAULT_PRODUCTION_CONFIG, DevelopmentConfig, Environment, HydrationConfig, PartialCsszyxConfig, PerformanceConfig, ProductionConfig, getCurrentEnvironment } from './config.cjs';
2
+ export { BuildConfig, CsszyxConfig, DEFAULT_BUILD_CONFIG, DEFAULT_CSSZYX_CONFIG, DEFAULT_DEVELOPMENT_CONFIG, DEFAULT_HYDRATION_CONFIG, DEFAULT_PERFORMANCE_CONFIG, DEFAULT_PRODUCTION_CONFIG, DevelopmentConfig, Environment, GlobalVarMangleConfig, GlobalVarMangleMode, GlobalVarUnsafeUsageMode, HydrationConfig, PartialCsszyxConfig, PerformanceConfig, ProductionConfig, getCurrentEnvironment, validateGlobalVarMangleConfig } from './config.cjs';
3
3
  import { SzPropValue, RecoveryMode } from '@csszyx/compiler';
4
4
  export { SzPropValue, SzProps } from '@csszyx/compiler';
5
- export { AuditLogEntry, ComponentPropsWithSz, CsszyxWindow, HydrationError, HydrationErrorType, MangleMap, MangleMapMetadata, PerformanceMetrics, RecoveryManifest, RecoveryMode, RuntimeState, SzProp, TokenData, VerificationResult, isCsszyxWindow } from './runtime.cjs';
5
+ export { AuditLogEntry, ComponentPropsWithSz, CssVariableMangleValue, CsszyxDebugHelpers, CsszyxWindow, HydrationError, HydrationErrorType, MangleMap, MangleMapMetadata, PerformanceMetrics, RecoveryManifest, RecoveryMode, RuntimeState, SzProp, TokenData, VerificationResult, isCsszyxWindow } from './runtime.cjs';
6
6
 
7
7
  /**
8
8
  * @csszyx/types - Core WASM Contract
@@ -116,6 +116,27 @@ declare module 'react' {
116
116
  }
117
117
  }
118
118
 
119
+ /** Tailwind v4 @theme namespaces that csszyx must never alias. */
120
+ declare const TAILWIND_RESERVED_PREFIXES: readonly ["--color-", "--font-", "--text-", "--font-weight-", "--tracking-", "--leading-", "--tab-size-", "--breakpoint-", "--container-", "--spacing-", "--radius-", "--shadow-", "--inset-shadow-", "--drop-shadow-", "--blur-", "--perspective-", "--zoom-", "--aspect-", "--ease-", "--animate-"];
121
+ /** Default csszyx Phase H generated global-alias namespace. */
122
+ declare const CSSZYX_GLOBAL_ALIAS_PREFIX = "---g";
123
+ /**
124
+ * Checks whether a custom-property name is in a Tailwind-owned theme namespace.
125
+ *
126
+ * @param name Custom-property name including the leading `--`.
127
+ * @returns true when the name belongs to a Tailwind reserved namespace.
128
+ */
129
+ declare function isTailwindReservedCustomProperty(name: string): boolean;
130
+ /**
131
+ * Checks whether a custom-property name collides with csszyx generated
132
+ * global-alias names.
133
+ *
134
+ * @param name Custom-property name including the leading `--`.
135
+ * @param aliasPrefix Active generated alias prefix.
136
+ * @returns true when the name belongs to csszyx's reserved generated alias namespace.
137
+ */
138
+ declare function isCsszyxGlobalAliasCustomProperty(name: string, aliasPrefix?: string): boolean;
139
+
119
140
  /**
120
141
  * @csszyx/types - Shared TypeScript types for csszyx.
121
142
  *
@@ -129,5 +150,5 @@ declare module 'react' {
129
150
  */
130
151
  declare const VERSION = "0.0.0";
131
152
 
132
- export { VERSION };
153
+ export { CSSZYX_GLOBAL_ALIAS_PREFIX, TAILWIND_RESERVED_PREFIXES, VERSION, isCsszyxGlobalAliasCustomProperty, isTailwindReservedCustomProperty };
133
154
  export type { CsszyxCorePkg, CsszyxCoreWasm };
package/dist/index.d.mts CHANGED
@@ -1,8 +1,8 @@
1
1
  export { BuildPhase, BuildPhaseResult, BuildPhaseStatus, BuildResult, BuildStatistics, CacheEntry, CacheManager, CollisionResult, CompilerContext, CompilerOptions, CompilerPlugin, FileCompilationResult, GeneratedToken, MangleMapEntry, NodeLocation, TokenMetadata, TransformOptions, ValidationError, ValidationResult } from './compiler.mjs';
2
- export { BuildConfig, CsszyxConfig, DEFAULT_BUILD_CONFIG, DEFAULT_CSSZYX_CONFIG, DEFAULT_DEVELOPMENT_CONFIG, DEFAULT_HYDRATION_CONFIG, DEFAULT_PERFORMANCE_CONFIG, DEFAULT_PRODUCTION_CONFIG, DevelopmentConfig, Environment, HydrationConfig, PartialCsszyxConfig, PerformanceConfig, ProductionConfig, getCurrentEnvironment } from './config.mjs';
2
+ export { BuildConfig, CsszyxConfig, DEFAULT_BUILD_CONFIG, DEFAULT_CSSZYX_CONFIG, DEFAULT_DEVELOPMENT_CONFIG, DEFAULT_HYDRATION_CONFIG, DEFAULT_PERFORMANCE_CONFIG, DEFAULT_PRODUCTION_CONFIG, DevelopmentConfig, Environment, GlobalVarMangleConfig, GlobalVarMangleMode, GlobalVarUnsafeUsageMode, HydrationConfig, PartialCsszyxConfig, PerformanceConfig, ProductionConfig, getCurrentEnvironment, validateGlobalVarMangleConfig } from './config.mjs';
3
3
  import { SzPropValue, RecoveryMode } from '@csszyx/compiler';
4
4
  export { SzPropValue, SzProps } from '@csszyx/compiler';
5
- export { AuditLogEntry, ComponentPropsWithSz, CsszyxWindow, HydrationError, HydrationErrorType, MangleMap, MangleMapMetadata, PerformanceMetrics, RecoveryManifest, RecoveryMode, RuntimeState, SzProp, TokenData, VerificationResult, isCsszyxWindow } from './runtime.mjs';
5
+ export { AuditLogEntry, ComponentPropsWithSz, CssVariableMangleValue, CsszyxDebugHelpers, CsszyxWindow, HydrationError, HydrationErrorType, MangleMap, MangleMapMetadata, PerformanceMetrics, RecoveryManifest, RecoveryMode, RuntimeState, SzProp, TokenData, VerificationResult, isCsszyxWindow } from './runtime.mjs';
6
6
 
7
7
  /**
8
8
  * @csszyx/types - Core WASM Contract
@@ -116,6 +116,27 @@ declare module 'react' {
116
116
  }
117
117
  }
118
118
 
119
+ /** Tailwind v4 @theme namespaces that csszyx must never alias. */
120
+ declare const TAILWIND_RESERVED_PREFIXES: readonly ["--color-", "--font-", "--text-", "--font-weight-", "--tracking-", "--leading-", "--tab-size-", "--breakpoint-", "--container-", "--spacing-", "--radius-", "--shadow-", "--inset-shadow-", "--drop-shadow-", "--blur-", "--perspective-", "--zoom-", "--aspect-", "--ease-", "--animate-"];
121
+ /** Default csszyx Phase H generated global-alias namespace. */
122
+ declare const CSSZYX_GLOBAL_ALIAS_PREFIX = "---g";
123
+ /**
124
+ * Checks whether a custom-property name is in a Tailwind-owned theme namespace.
125
+ *
126
+ * @param name Custom-property name including the leading `--`.
127
+ * @returns true when the name belongs to a Tailwind reserved namespace.
128
+ */
129
+ declare function isTailwindReservedCustomProperty(name: string): boolean;
130
+ /**
131
+ * Checks whether a custom-property name collides with csszyx generated
132
+ * global-alias names.
133
+ *
134
+ * @param name Custom-property name including the leading `--`.
135
+ * @param aliasPrefix Active generated alias prefix.
136
+ * @returns true when the name belongs to csszyx's reserved generated alias namespace.
137
+ */
138
+ declare function isCsszyxGlobalAliasCustomProperty(name: string, aliasPrefix?: string): boolean;
139
+
119
140
  /**
120
141
  * @csszyx/types - Shared TypeScript types for csszyx.
121
142
  *
@@ -129,5 +150,5 @@ declare module 'react' {
129
150
  */
130
151
  declare const VERSION = "0.0.0";
131
152
 
132
- export { VERSION };
153
+ export { CSSZYX_GLOBAL_ALIAS_PREFIX, TAILWIND_RESERVED_PREFIXES, VERSION, isCsszyxGlobalAliasCustomProperty, isTailwindReservedCustomProperty };
133
154
  export type { CsszyxCorePkg, CsszyxCoreWasm };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { DEFAULT_BUILD_CONFIG, DEFAULT_CSSZYX_CONFIG, DEFAULT_DEVELOPMENT_CONFIG, DEFAULT_HYDRATION_CONFIG, DEFAULT_PERFORMANCE_CONFIG, DEFAULT_PRODUCTION_CONFIG, getCurrentEnvironment } from './config.mjs';
1
+ export { C as CSSZYX_GLOBAL_ALIAS_PREFIX, D as DEFAULT_BUILD_CONFIG, a as DEFAULT_CSSZYX_CONFIG, b as DEFAULT_DEVELOPMENT_CONFIG, c as DEFAULT_HYDRATION_CONFIG, d as DEFAULT_PERFORMANCE_CONFIG, e as DEFAULT_PRODUCTION_CONFIG, T as TAILWIND_RESERVED_PREFIXES, g as getCurrentEnvironment, i as isCsszyxGlobalAliasCustomProperty, f as isTailwindReservedCustomProperty, v as validateGlobalVarMangleConfig } from './shared/types.ClLdsRKs.mjs';
2
2
  export { isCsszyxWindow } from './runtime.mjs';
3
3
 
4
4
  const VERSION = "0.0.0";
@@ -60,6 +60,34 @@ interface MangleMap {
60
60
  */
61
61
  [originalClass: string]: string;
62
62
  }
63
+ /**
64
+ * CSS variable mangle map values. One original variable can point to multiple
65
+ * emitted names when scoped and hoisted variables coexist.
66
+ */
67
+ type CssVariableMangleValue = string | string[];
68
+ /**
69
+ * Debug helper object injected as `window.__csszyx` by the unplugin.
70
+ */
71
+ interface CsszyxDebugHelpers {
72
+ /** Original class name to mangled class name. */
73
+ mangleMap: MangleMap;
74
+ /** Original CSS custom property to emitted custom property name(s). */
75
+ varMangleMap: Record<string, CssVariableMangleValue>;
76
+ /** Mangle-map checksum emitted on the root HTML element. */
77
+ checksum: string;
78
+ /** Decode a mangled class name back to the original class name. */
79
+ decode(className: string): string | undefined;
80
+ /** Encode an original class name to the mangled class name. */
81
+ encode(className: string): string | undefined;
82
+ /** Decode any emitted CSS custom property name back to original names. */
83
+ decodeVar(name: string): string[];
84
+ /** Encode an original CSS custom property name to emitted name(s). */
85
+ encodeVar(name: string): CssVariableMangleValue | undefined;
86
+ /** Decode a global alias back to its original custom-property name. */
87
+ decodeGlobalVar(alias: string): string | undefined;
88
+ /** Decode all classes on an element, preserving unknown classes. */
89
+ decodeAll(element: Element): string[];
90
+ }
63
91
  /**
64
92
  * Mangle map metadata.
65
93
  */
@@ -249,6 +277,10 @@ interface CsszyxWindow extends Window {
249
277
  * Debug mode flag
250
278
  */
251
279
  __SZ_DEBUG__?: boolean;
280
+ /**
281
+ * Debug helpers injected by csszyx build output.
282
+ */
283
+ __csszyx?: CsszyxDebugHelpers;
252
284
  }
253
285
  /**
254
286
  * Type guard to check if window has csszyx extensions.
@@ -259,4 +291,4 @@ interface CsszyxWindow extends Window {
259
291
  declare function isCsszyxWindow(win: Window): win is CsszyxWindow;
260
292
 
261
293
  export { isCsszyxWindow };
262
- export type { AuditLogEntry, ComponentPropsWithSz, CsszyxWindow, HydrationError, HydrationErrorType, MangleMap, MangleMapMetadata, PerformanceMetrics, RecoveryManifest, RecoveryMode, RuntimeState, SzProp, TokenData, VerificationResult };
294
+ export type { AuditLogEntry, ComponentPropsWithSz, CssVariableMangleValue, CsszyxDebugHelpers, CsszyxWindow, HydrationError, HydrationErrorType, MangleMap, MangleMapMetadata, PerformanceMetrics, RecoveryManifest, RecoveryMode, RuntimeState, SzProp, TokenData, VerificationResult };
@@ -60,6 +60,34 @@ interface MangleMap {
60
60
  */
61
61
  [originalClass: string]: string;
62
62
  }
63
+ /**
64
+ * CSS variable mangle map values. One original variable can point to multiple
65
+ * emitted names when scoped and hoisted variables coexist.
66
+ */
67
+ type CssVariableMangleValue = string | string[];
68
+ /**
69
+ * Debug helper object injected as `window.__csszyx` by the unplugin.
70
+ */
71
+ interface CsszyxDebugHelpers {
72
+ /** Original class name to mangled class name. */
73
+ mangleMap: MangleMap;
74
+ /** Original CSS custom property to emitted custom property name(s). */
75
+ varMangleMap: Record<string, CssVariableMangleValue>;
76
+ /** Mangle-map checksum emitted on the root HTML element. */
77
+ checksum: string;
78
+ /** Decode a mangled class name back to the original class name. */
79
+ decode(className: string): string | undefined;
80
+ /** Encode an original class name to the mangled class name. */
81
+ encode(className: string): string | undefined;
82
+ /** Decode any emitted CSS custom property name back to original names. */
83
+ decodeVar(name: string): string[];
84
+ /** Encode an original CSS custom property name to emitted name(s). */
85
+ encodeVar(name: string): CssVariableMangleValue | undefined;
86
+ /** Decode a global alias back to its original custom-property name. */
87
+ decodeGlobalVar(alias: string): string | undefined;
88
+ /** Decode all classes on an element, preserving unknown classes. */
89
+ decodeAll(element: Element): string[];
90
+ }
63
91
  /**
64
92
  * Mangle map metadata.
65
93
  */
@@ -249,6 +277,10 @@ interface CsszyxWindow extends Window {
249
277
  * Debug mode flag
250
278
  */
251
279
  __SZ_DEBUG__?: boolean;
280
+ /**
281
+ * Debug helpers injected by csszyx build output.
282
+ */
283
+ __csszyx?: CsszyxDebugHelpers;
252
284
  }
253
285
  /**
254
286
  * Type guard to check if window has csszyx extensions.
@@ -259,4 +291,4 @@ interface CsszyxWindow extends Window {
259
291
  declare function isCsszyxWindow(win: Window): win is CsszyxWindow;
260
292
 
261
293
  export { isCsszyxWindow };
262
- export type { AuditLogEntry, ComponentPropsWithSz, CsszyxWindow, HydrationError, HydrationErrorType, MangleMap, MangleMapMetadata, PerformanceMetrics, RecoveryManifest, RecoveryMode, RuntimeState, SzProp, TokenData, VerificationResult };
294
+ export type { AuditLogEntry, ComponentPropsWithSz, CssVariableMangleValue, CsszyxDebugHelpers, CsszyxWindow, HydrationError, HydrationErrorType, MangleMap, MangleMapMetadata, PerformanceMetrics, RecoveryManifest, RecoveryMode, RuntimeState, SzProp, TokenData, VerificationResult };
@@ -0,0 +1,171 @@
1
+ 'use strict';
2
+
3
+ const TAILWIND_RESERVED_PREFIXES = [
4
+ "--color-",
5
+ "--font-",
6
+ "--text-",
7
+ "--font-weight-",
8
+ "--tracking-",
9
+ "--leading-",
10
+ "--tab-size-",
11
+ "--breakpoint-",
12
+ "--container-",
13
+ "--spacing-",
14
+ "--radius-",
15
+ "--shadow-",
16
+ "--inset-shadow-",
17
+ "--drop-shadow-",
18
+ "--blur-",
19
+ "--perspective-",
20
+ "--zoom-",
21
+ "--aspect-",
22
+ "--ease-",
23
+ "--animate-"
24
+ ];
25
+ const CSSZYX_GLOBAL_ALIAS_PREFIX = "---g";
26
+ function isTailwindReservedCustomProperty(name) {
27
+ return TAILWIND_RESERVED_PREFIXES.some((prefix) => name.startsWith(prefix));
28
+ }
29
+ function isCsszyxGlobalAliasCustomProperty(name, aliasPrefix = CSSZYX_GLOBAL_ALIAS_PREFIX) {
30
+ return name.startsWith(aliasPrefix);
31
+ }
32
+
33
+ function validateGlobalVarMangleConfig(config) {
34
+ if (!config) {
35
+ return [];
36
+ }
37
+ const errors = [];
38
+ if (config.mode !== void 0 && config.mode !== "alias") {
39
+ errors.push("production.mangleGlobalVars.mode only supports 'alias' in Phase H v1.");
40
+ }
41
+ if (config.onUnsafeUsage !== void 0 && config.onUnsafeUsage !== "error") {
42
+ errors.push(
43
+ "production.mangleGlobalVars.onUnsafeUsage only supports 'error' in Phase H v1."
44
+ );
45
+ }
46
+ if (config.autoPrefix !== void 0 && !isValidCustomPropertyPrefix(config.autoPrefix)) {
47
+ errors.push('production.mangleGlobalVars.autoPrefix must be empty or start with "--".');
48
+ } else if (config.autoPrefix !== void 0 && config.autoPrefix !== "" && isTailwindReservedCustomProperty(config.autoPrefix)) {
49
+ errors.push(
50
+ `production.mangleGlobalVars.autoPrefix cannot target Tailwind reserved namespace "${config.autoPrefix}".`
51
+ );
52
+ } else if (config.autoPrefix !== void 0 && config.autoPrefix !== "" && isCsszyxGlobalAliasCustomProperty(config.autoPrefix, resolveGlobalVarAliasPrefix(config))) {
53
+ errors.push(
54
+ `production.mangleGlobalVars.autoPrefix cannot target csszyx reserved namespace "${resolveGlobalVarAliasPrefix(config)}*".`
55
+ );
56
+ }
57
+ if (config.aliasPrefix !== void 0 && (config.aliasPrefix === "" || !isValidCustomPropertyPrefix(config.aliasPrefix))) {
58
+ errors.push(
59
+ 'production.mangleGlobalVars.aliasPrefix must be non-empty and start with "--".'
60
+ );
61
+ } else if (config.aliasPrefix !== void 0 && isTailwindReservedCustomProperty(config.aliasPrefix)) {
62
+ errors.push(
63
+ `production.mangleGlobalVars.aliasPrefix cannot target Tailwind reserved namespace "${config.aliasPrefix}".`
64
+ );
65
+ } else if (config.autoPrefix !== void 0 && config.autoPrefix !== "" && config.aliasPrefix !== void 0 && prefixesOverlap(config.autoPrefix, config.aliasPrefix)) {
66
+ errors.push(
67
+ `production.mangleGlobalVars.aliasPrefix "${config.aliasPrefix}" must not overlap autoPrefix "${config.autoPrefix}".`
68
+ );
69
+ }
70
+ validateCustomPropertyList(
71
+ config.tokens,
72
+ "tokens",
73
+ errors,
74
+ resolveGlobalVarAliasPrefix(config)
75
+ );
76
+ validateCustomPropertyList(config.reserved, "reserved", errors);
77
+ return errors;
78
+ }
79
+ function isValidCustomPropertyPrefix(prefix) {
80
+ return prefix === "" || prefix.startsWith("--");
81
+ }
82
+ function resolveGlobalVarAliasPrefix(config) {
83
+ return config.aliasPrefix ?? CSSZYX_GLOBAL_ALIAS_PREFIX;
84
+ }
85
+ function prefixesOverlap(left, right) {
86
+ return left.startsWith(right) || right.startsWith(left);
87
+ }
88
+ function validateCustomPropertyList(values, field, errors, aliasPrefix = CSSZYX_GLOBAL_ALIAS_PREFIX) {
89
+ if (!values) {
90
+ return;
91
+ }
92
+ for (const value of values) {
93
+ if (!value.startsWith("--")) {
94
+ errors.push(`production.mangleGlobalVars.${field} entries must start with "--".`);
95
+ return;
96
+ }
97
+ if (field === "tokens" && isTailwindReservedCustomProperty(value)) {
98
+ errors.push(
99
+ `production.mangleGlobalVars.tokens cannot include Tailwind reserved namespace token "${value}".`
100
+ );
101
+ return;
102
+ }
103
+ if (field === "tokens" && isCsszyxGlobalAliasCustomProperty(value, aliasPrefix)) {
104
+ errors.push(
105
+ `production.mangleGlobalVars.tokens cannot include csszyx reserved namespace token "${value}".`
106
+ );
107
+ return;
108
+ }
109
+ }
110
+ }
111
+ const DEFAULT_DEVELOPMENT_CONFIG = {
112
+ strictMode: false,
113
+ debug: false
114
+ };
115
+ const DEFAULT_PRODUCTION_CONFIG = {
116
+ mangle: true,
117
+ mangleVars: false,
118
+ mangleVarHoistMaxDepth: 5,
119
+ contentHashing: true,
120
+ injectChecksum: true,
121
+ incrementalBuild: true,
122
+ minify: true
123
+ };
124
+ const DEFAULT_BUILD_CONFIG = {
125
+ tailwindConfig: "tailwind.config.js",
126
+ outputDir: ".csszyx",
127
+ cacheDir: ".csszyx/cache",
128
+ cache: true,
129
+ astBudgetLimit: 5e4,
130
+ parser: "rust"
131
+ };
132
+ const DEFAULT_HYDRATION_CONFIG = {
133
+ strict: true,
134
+ defaultRecoveryMode: null,
135
+ auditLog: true
136
+ };
137
+ const DEFAULT_PERFORMANCE_CONFIG = {
138
+ parallel: true,
139
+ optimizeVariables: true,
140
+ zeroRuntime: true
141
+ };
142
+ const DEFAULT_CSSZYX_CONFIG = {
143
+ development: DEFAULT_DEVELOPMENT_CONFIG,
144
+ production: DEFAULT_PRODUCTION_CONFIG,
145
+ build: DEFAULT_BUILD_CONFIG,
146
+ hydration: DEFAULT_HYDRATION_CONFIG,
147
+ performance: DEFAULT_PERFORMANCE_CONFIG
148
+ };
149
+ function getCurrentEnvironment() {
150
+ const env = process.env.NODE_ENV;
151
+ if (env === "production") {
152
+ return "production";
153
+ }
154
+ if (env === "test") {
155
+ return "test";
156
+ }
157
+ return "development";
158
+ }
159
+
160
+ exports.CSSZYX_GLOBAL_ALIAS_PREFIX = CSSZYX_GLOBAL_ALIAS_PREFIX;
161
+ exports.DEFAULT_BUILD_CONFIG = DEFAULT_BUILD_CONFIG;
162
+ exports.DEFAULT_CSSZYX_CONFIG = DEFAULT_CSSZYX_CONFIG;
163
+ exports.DEFAULT_DEVELOPMENT_CONFIG = DEFAULT_DEVELOPMENT_CONFIG;
164
+ exports.DEFAULT_HYDRATION_CONFIG = DEFAULT_HYDRATION_CONFIG;
165
+ exports.DEFAULT_PERFORMANCE_CONFIG = DEFAULT_PERFORMANCE_CONFIG;
166
+ exports.DEFAULT_PRODUCTION_CONFIG = DEFAULT_PRODUCTION_CONFIG;
167
+ exports.TAILWIND_RESERVED_PREFIXES = TAILWIND_RESERVED_PREFIXES;
168
+ exports.getCurrentEnvironment = getCurrentEnvironment;
169
+ exports.isCsszyxGlobalAliasCustomProperty = isCsszyxGlobalAliasCustomProperty;
170
+ exports.isTailwindReservedCustomProperty = isTailwindReservedCustomProperty;
171
+ exports.validateGlobalVarMangleConfig = validateGlobalVarMangleConfig;
@@ -0,0 +1,158 @@
1
+ const TAILWIND_RESERVED_PREFIXES = [
2
+ "--color-",
3
+ "--font-",
4
+ "--text-",
5
+ "--font-weight-",
6
+ "--tracking-",
7
+ "--leading-",
8
+ "--tab-size-",
9
+ "--breakpoint-",
10
+ "--container-",
11
+ "--spacing-",
12
+ "--radius-",
13
+ "--shadow-",
14
+ "--inset-shadow-",
15
+ "--drop-shadow-",
16
+ "--blur-",
17
+ "--perspective-",
18
+ "--zoom-",
19
+ "--aspect-",
20
+ "--ease-",
21
+ "--animate-"
22
+ ];
23
+ const CSSZYX_GLOBAL_ALIAS_PREFIX = "---g";
24
+ function isTailwindReservedCustomProperty(name) {
25
+ return TAILWIND_RESERVED_PREFIXES.some((prefix) => name.startsWith(prefix));
26
+ }
27
+ function isCsszyxGlobalAliasCustomProperty(name, aliasPrefix = CSSZYX_GLOBAL_ALIAS_PREFIX) {
28
+ return name.startsWith(aliasPrefix);
29
+ }
30
+
31
+ function validateGlobalVarMangleConfig(config) {
32
+ if (!config) {
33
+ return [];
34
+ }
35
+ const errors = [];
36
+ if (config.mode !== void 0 && config.mode !== "alias") {
37
+ errors.push("production.mangleGlobalVars.mode only supports 'alias' in Phase H v1.");
38
+ }
39
+ if (config.onUnsafeUsage !== void 0 && config.onUnsafeUsage !== "error") {
40
+ errors.push(
41
+ "production.mangleGlobalVars.onUnsafeUsage only supports 'error' in Phase H v1."
42
+ );
43
+ }
44
+ if (config.autoPrefix !== void 0 && !isValidCustomPropertyPrefix(config.autoPrefix)) {
45
+ errors.push('production.mangleGlobalVars.autoPrefix must be empty or start with "--".');
46
+ } else if (config.autoPrefix !== void 0 && config.autoPrefix !== "" && isTailwindReservedCustomProperty(config.autoPrefix)) {
47
+ errors.push(
48
+ `production.mangleGlobalVars.autoPrefix cannot target Tailwind reserved namespace "${config.autoPrefix}".`
49
+ );
50
+ } else if (config.autoPrefix !== void 0 && config.autoPrefix !== "" && isCsszyxGlobalAliasCustomProperty(config.autoPrefix, resolveGlobalVarAliasPrefix(config))) {
51
+ errors.push(
52
+ `production.mangleGlobalVars.autoPrefix cannot target csszyx reserved namespace "${resolveGlobalVarAliasPrefix(config)}*".`
53
+ );
54
+ }
55
+ if (config.aliasPrefix !== void 0 && (config.aliasPrefix === "" || !isValidCustomPropertyPrefix(config.aliasPrefix))) {
56
+ errors.push(
57
+ 'production.mangleGlobalVars.aliasPrefix must be non-empty and start with "--".'
58
+ );
59
+ } else if (config.aliasPrefix !== void 0 && isTailwindReservedCustomProperty(config.aliasPrefix)) {
60
+ errors.push(
61
+ `production.mangleGlobalVars.aliasPrefix cannot target Tailwind reserved namespace "${config.aliasPrefix}".`
62
+ );
63
+ } else if (config.autoPrefix !== void 0 && config.autoPrefix !== "" && config.aliasPrefix !== void 0 && prefixesOverlap(config.autoPrefix, config.aliasPrefix)) {
64
+ errors.push(
65
+ `production.mangleGlobalVars.aliasPrefix "${config.aliasPrefix}" must not overlap autoPrefix "${config.autoPrefix}".`
66
+ );
67
+ }
68
+ validateCustomPropertyList(
69
+ config.tokens,
70
+ "tokens",
71
+ errors,
72
+ resolveGlobalVarAliasPrefix(config)
73
+ );
74
+ validateCustomPropertyList(config.reserved, "reserved", errors);
75
+ return errors;
76
+ }
77
+ function isValidCustomPropertyPrefix(prefix) {
78
+ return prefix === "" || prefix.startsWith("--");
79
+ }
80
+ function resolveGlobalVarAliasPrefix(config) {
81
+ return config.aliasPrefix ?? CSSZYX_GLOBAL_ALIAS_PREFIX;
82
+ }
83
+ function prefixesOverlap(left, right) {
84
+ return left.startsWith(right) || right.startsWith(left);
85
+ }
86
+ function validateCustomPropertyList(values, field, errors, aliasPrefix = CSSZYX_GLOBAL_ALIAS_PREFIX) {
87
+ if (!values) {
88
+ return;
89
+ }
90
+ for (const value of values) {
91
+ if (!value.startsWith("--")) {
92
+ errors.push(`production.mangleGlobalVars.${field} entries must start with "--".`);
93
+ return;
94
+ }
95
+ if (field === "tokens" && isTailwindReservedCustomProperty(value)) {
96
+ errors.push(
97
+ `production.mangleGlobalVars.tokens cannot include Tailwind reserved namespace token "${value}".`
98
+ );
99
+ return;
100
+ }
101
+ if (field === "tokens" && isCsszyxGlobalAliasCustomProperty(value, aliasPrefix)) {
102
+ errors.push(
103
+ `production.mangleGlobalVars.tokens cannot include csszyx reserved namespace token "${value}".`
104
+ );
105
+ return;
106
+ }
107
+ }
108
+ }
109
+ const DEFAULT_DEVELOPMENT_CONFIG = {
110
+ strictMode: false,
111
+ debug: false
112
+ };
113
+ const DEFAULT_PRODUCTION_CONFIG = {
114
+ mangle: true,
115
+ mangleVars: false,
116
+ mangleVarHoistMaxDepth: 5,
117
+ contentHashing: true,
118
+ injectChecksum: true,
119
+ incrementalBuild: true,
120
+ minify: true
121
+ };
122
+ const DEFAULT_BUILD_CONFIG = {
123
+ tailwindConfig: "tailwind.config.js",
124
+ outputDir: ".csszyx",
125
+ cacheDir: ".csszyx/cache",
126
+ cache: true,
127
+ astBudgetLimit: 5e4,
128
+ parser: "rust"
129
+ };
130
+ const DEFAULT_HYDRATION_CONFIG = {
131
+ strict: true,
132
+ defaultRecoveryMode: null,
133
+ auditLog: true
134
+ };
135
+ const DEFAULT_PERFORMANCE_CONFIG = {
136
+ parallel: true,
137
+ optimizeVariables: true,
138
+ zeroRuntime: true
139
+ };
140
+ const DEFAULT_CSSZYX_CONFIG = {
141
+ development: DEFAULT_DEVELOPMENT_CONFIG,
142
+ production: DEFAULT_PRODUCTION_CONFIG,
143
+ build: DEFAULT_BUILD_CONFIG,
144
+ hydration: DEFAULT_HYDRATION_CONFIG,
145
+ performance: DEFAULT_PERFORMANCE_CONFIG
146
+ };
147
+ function getCurrentEnvironment() {
148
+ const env = process.env.NODE_ENV;
149
+ if (env === "production") {
150
+ return "production";
151
+ }
152
+ if (env === "test") {
153
+ return "test";
154
+ }
155
+ return "development";
156
+ }
157
+
158
+ export { CSSZYX_GLOBAL_ALIAS_PREFIX as C, DEFAULT_BUILD_CONFIG as D, TAILWIND_RESERVED_PREFIXES as T, DEFAULT_CSSZYX_CONFIG as a, DEFAULT_DEVELOPMENT_CONFIG as b, DEFAULT_HYDRATION_CONFIG as c, DEFAULT_PERFORMANCE_CONFIG as d, DEFAULT_PRODUCTION_CONFIG as e, isTailwindReservedCustomProperty as f, getCurrentEnvironment as g, isCsszyxGlobalAliasCustomProperty as i, validateGlobalVarMangleConfig as v };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@csszyx/types",
3
- "version": "0.9.0",
3
+ "version": "0.9.2",
4
4
  "description": "TypeScript definitions for csszyx",
5
5
  "keywords": [
6
6
  "csszyx",
@@ -54,7 +54,7 @@
54
54
  "@types/node": "^20.11.0",
55
55
  "typescript": "^6.0.3",
56
56
  "unbuild": "^3.6.1",
57
- "@csszyx/compiler": "0.9.0"
57
+ "@csszyx/compiler": "0.9.2"
58
58
  },
59
59
  "sideEffects": false,
60
60
  "engines": {