@csszyx/types 0.6.2 → 0.8.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.
@@ -39,6 +39,10 @@ interface RecoveryManifest {
39
39
  * SHA-256 checksum of the tokens object for integrity verification
40
40
  */
41
41
  checksum: string;
42
+ /**
43
+ * SHA-256 checksum of the mangle map emitted in the HTML checksum attribute
44
+ */
45
+ mangleChecksum: string;
42
46
  /**
43
47
  * Map of recovery token → token data
44
48
  */
@@ -254,4 +258,5 @@ interface CsszyxWindow extends Window {
254
258
  */
255
259
  declare function isCsszyxWindow(win: Window): win is CsszyxWindow;
256
260
 
257
- export { type AuditLogEntry, type ComponentPropsWithSz, type CsszyxWindow, type HydrationError, type HydrationErrorType, type MangleMap, type MangleMapMetadata, type PerformanceMetrics, type RecoveryManifest, type RecoveryMode, type RuntimeState, type SzProp, type TokenData, type VerificationResult, isCsszyxWindow };
261
+ export { isCsszyxWindow };
262
+ export type { AuditLogEntry, ComponentPropsWithSz, CsszyxWindow, HydrationError, HydrationErrorType, MangleMap, MangleMapMetadata, PerformanceMetrics, RecoveryManifest, RecoveryMode, RuntimeState, SzProp, TokenData, VerificationResult };
@@ -0,0 +1,262 @@
1
+ /**
2
+ * Runtime types for csszyx.
3
+ *
4
+ * This module defines types used at runtime for hydration guards,
5
+ * recovery tokens, and mangle maps.
6
+ */
7
+ /**
8
+ * Recovery mode types.
9
+ */
10
+ type RecoveryMode = 'csr' | 'dev-only';
11
+ /**
12
+ * Token data stored in the recovery manifest.
13
+ */
14
+ interface TokenData {
15
+ /**
16
+ * Recovery mode ('csr' or 'dev-only')
17
+ */
18
+ mode: RecoveryMode;
19
+ /**
20
+ * Component name where the token was generated
21
+ */
22
+ component: string;
23
+ /**
24
+ * File path relative to project root
25
+ */
26
+ path: string;
27
+ }
28
+ /**
29
+ * Recovery manifest structure.
30
+ *
31
+ * Embedded in build output as JSON in a script tag with id "__SZ_RECOVERY_MANIFEST__".
32
+ */
33
+ interface RecoveryManifest {
34
+ /**
35
+ * Build ID (git hash or timestamp)
36
+ */
37
+ buildId: string;
38
+ /**
39
+ * SHA-256 checksum of the tokens object for integrity verification
40
+ */
41
+ checksum: string;
42
+ /**
43
+ * SHA-256 checksum of the mangle map emitted in the HTML checksum attribute
44
+ */
45
+ mangleChecksum: string;
46
+ /**
47
+ * Map of recovery token → token data
48
+ */
49
+ tokens: Record<string, TokenData>;
50
+ }
51
+ /**
52
+ * Mangle map structure.
53
+ *
54
+ * Maps original Tailwind class names to their minified equivalents.
55
+ * Embedded in build output as JSON in a script tag with id "__SZ_MANGLE_MAP__".
56
+ */
57
+ interface MangleMap {
58
+ /**
59
+ * Map of original class name → mangled class name
60
+ */
61
+ [originalClass: string]: string;
62
+ }
63
+ /**
64
+ * Mangle map metadata.
65
+ */
66
+ interface MangleMapMetadata {
67
+ /**
68
+ * Build ID
69
+ */
70
+ buildId: string;
71
+ /**
72
+ * Total number of classes in the map
73
+ */
74
+ classCount: number;
75
+ /**
76
+ * SHA-256 checksum of the map for validation
77
+ */
78
+ checksum: string;
79
+ /**
80
+ * Timestamp when the map was generated
81
+ */
82
+ timestamp: number;
83
+ }
84
+ /**
85
+ * Hydration error types.
86
+ */
87
+ type HydrationErrorType = 'checksum_mismatch' | 'map_missing' | 'invalid_token' | 'abort_failed';
88
+ /**
89
+ * Hydration error details.
90
+ */
91
+ interface HydrationError {
92
+ /**
93
+ * Error type
94
+ */
95
+ type: HydrationErrorType;
96
+ /**
97
+ * Error message
98
+ */
99
+ message: string;
100
+ /**
101
+ * Element where the error occurred (optional)
102
+ */
103
+ element?: HTMLElement;
104
+ /**
105
+ * Timestamp when error occurred
106
+ */
107
+ timestamp: number;
108
+ /**
109
+ * Stack trace (optional)
110
+ */
111
+ stack?: string;
112
+ }
113
+ /**
114
+ * Token verification result.
115
+ */
116
+ interface VerificationResult {
117
+ /**
118
+ * Whether the token is valid
119
+ */
120
+ valid: boolean;
121
+ /**
122
+ * Token data if valid
123
+ */
124
+ tokenData?: TokenData;
125
+ /**
126
+ * Error message if invalid
127
+ */
128
+ error?: string;
129
+ }
130
+ /**
131
+ * Runtime state interface.
132
+ */
133
+ interface RuntimeState {
134
+ /**
135
+ * Whether the runtime has been initialized
136
+ */
137
+ initialized: boolean;
138
+ /**
139
+ * Current environment
140
+ */
141
+ environment: 'development' | 'production' | 'test';
142
+ /**
143
+ * Whether CSR recovery is allowed
144
+ */
145
+ csrRecoveryAllowed: boolean;
146
+ /**
147
+ * Loaded recovery manifest
148
+ */
149
+ manifest?: RecoveryManifest;
150
+ /**
151
+ * Loaded mangle map
152
+ */
153
+ mangleMap?: MangleMap;
154
+ /**
155
+ * Recorded hydration errors
156
+ */
157
+ errors: HydrationError[];
158
+ /**
159
+ * Count of aborted subtrees
160
+ */
161
+ abortedCount: number;
162
+ }
163
+ /**
164
+ * JSX sz prop object type.
165
+ */
166
+ interface SzProp {
167
+ [key: string]: string | number | boolean | SzProp;
168
+ }
169
+ /**
170
+ * Component props with sz attribute.
171
+ */
172
+ interface ComponentPropsWithSz {
173
+ /**
174
+ * csszyx object syntax for Tailwind classes
175
+ */
176
+ sz?: SzProp | string;
177
+ /**
178
+ * Recovery mode (optional)
179
+ */
180
+ szRecover?: RecoveryMode;
181
+ /**
182
+ * Standard className prop (merged with sz)
183
+ */
184
+ className?: string;
185
+ }
186
+ /**
187
+ * Audit log entry.
188
+ */
189
+ interface AuditLogEntry {
190
+ /**
191
+ * Log level
192
+ */
193
+ level: 'info' | 'warn' | 'error';
194
+ /**
195
+ * Log message
196
+ */
197
+ message: string;
198
+ /**
199
+ * Timestamp
200
+ */
201
+ timestamp: number;
202
+ /**
203
+ * Additional metadata
204
+ */
205
+ metadata?: Record<string, unknown>;
206
+ }
207
+ /**
208
+ * Performance metrics.
209
+ */
210
+ interface PerformanceMetrics {
211
+ /**
212
+ * Time taken for hydration guard (ms)
213
+ */
214
+ hydrationGuardTime?: number;
215
+ /**
216
+ * Time taken for token verification (ms)
217
+ */
218
+ tokenVerificationTime?: number;
219
+ /**
220
+ * Total number of tokens verified
221
+ */
222
+ tokensVerified?: number;
223
+ /**
224
+ * Number of hydration errors
225
+ */
226
+ hydrationErrors?: number;
227
+ /**
228
+ * Memory usage (bytes)
229
+ */
230
+ memoryUsage?: number;
231
+ }
232
+ /**
233
+ * Global window interface extensions for csszyx.
234
+ */
235
+ interface CsszyxWindow extends Window {
236
+ /**
237
+ * Allow CSR recovery flag (development only)
238
+ */
239
+ __SZ_ALLOW_CSR_RECOVERY__?: boolean;
240
+ /**
241
+ * Runtime state
242
+ */
243
+ __SZ_RUNTIME_STATE__?: RuntimeState;
244
+ /**
245
+ * Performance metrics
246
+ */
247
+ __SZ_METRICS__?: PerformanceMetrics;
248
+ /**
249
+ * Debug mode flag
250
+ */
251
+ __SZ_DEBUG__?: boolean;
252
+ }
253
+ /**
254
+ * Type guard to check if window has csszyx extensions.
255
+ *
256
+ * @param {Window} win - Window object to check
257
+ * @returns {win is CsszyxWindow} True if window has csszyx extensions
258
+ */
259
+ declare function isCsszyxWindow(win: Window): win is CsszyxWindow;
260
+
261
+ export { isCsszyxWindow };
262
+ export type { AuditLogEntry, ComponentPropsWithSz, CsszyxWindow, HydrationError, HydrationErrorType, MangleMap, MangleMapMetadata, PerformanceMetrics, RecoveryManifest, RecoveryMode, RuntimeState, SzProp, TokenData, VerificationResult };
@@ -1,8 +1,5 @@
1
- // src/runtime.ts
2
1
  function isCsszyxWindow(win) {
3
2
  return "__SZ_RUNTIME_STATE__" in win || "__SZ_ALLOW_CSR_RECOVERY__" in win;
4
3
  }
5
4
 
6
- export {
7
- isCsszyxWindow
8
- };
5
+ export { isCsszyxWindow };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@csszyx/types",
3
- "version": "0.6.2",
3
+ "version": "0.8.0",
4
4
  "description": "TypeScript definitions for csszyx",
5
5
  "keywords": [
6
6
  "csszyx",
@@ -19,25 +19,25 @@
19
19
  "url": "https://github.com/nguyennhutien/csszyx/issues"
20
20
  },
21
21
  "type": "module",
22
- "main": "./dist/index.js",
23
- "module": "./dist/index.js",
24
- "types": "./dist/index.d.ts",
22
+ "main": "./dist/index.cjs",
23
+ "module": "./dist/index.mjs",
24
+ "types": "./dist/index.d.mts",
25
25
  "exports": {
26
26
  ".": {
27
- "types": "./dist/index.d.ts",
28
- "import": "./dist/index.js"
27
+ "types": "./dist/index.d.mts",
28
+ "import": "./dist/index.mjs"
29
29
  },
30
30
  "./config": {
31
- "types": "./dist/config.d.ts",
32
- "import": "./dist/config.js"
31
+ "types": "./dist/config.d.mts",
32
+ "import": "./dist/config.mjs"
33
33
  },
34
34
  "./runtime": {
35
- "types": "./dist/runtime.d.ts",
36
- "import": "./dist/runtime.js"
35
+ "types": "./dist/runtime.d.mts",
36
+ "import": "./dist/runtime.mjs"
37
37
  },
38
38
  "./compiler": {
39
- "types": "./dist/compiler.d.ts",
40
- "import": "./dist/compiler.js"
39
+ "types": "./dist/compiler.d.mts",
40
+ "import": "./dist/compiler.mjs"
41
41
  },
42
42
  "./jsx": {
43
43
  "types": "./dist/jsx.d.ts"
@@ -48,13 +48,17 @@
48
48
  ],
49
49
  "devDependencies": {
50
50
  "@types/node": "^20.11.0",
51
- "tsup": "^8.0.0",
52
- "typescript": "^5.3.3",
53
- "@csszyx/compiler": "0.6.2"
51
+ "typescript": "^6.0.3",
52
+ "unbuild": "^3.6.1",
53
+ "@csszyx/compiler": "0.8.0"
54
+ },
55
+ "sideEffects": false,
56
+ "engines": {
57
+ "node": ">=22.12.0"
54
58
  },
55
59
  "scripts": {
56
- "build": "tsup src/index.ts src/config.ts src/runtime.ts src/compiler.ts --format esm --dts && cp src/jsx.d.ts dist/jsx.d.ts",
57
- "dev": "tsup src/index.ts src/config.ts src/runtime.ts src/compiler.ts --format esm --dts --watch",
60
+ "build": "unbuild",
61
+ "dev": "unbuild --stub",
58
62
  "type-check": "tsc --noEmit"
59
63
  }
60
64
  }
package/dist/compiler.js DELETED
File without changes
package/dist/config.js DELETED
@@ -1,18 +0,0 @@
1
- import {
2
- DEFAULT_BUILD_CONFIG,
3
- DEFAULT_CSSZYX_CONFIG,
4
- DEFAULT_DEVELOPMENT_CONFIG,
5
- DEFAULT_HYDRATION_CONFIG,
6
- DEFAULT_PERFORMANCE_CONFIG,
7
- DEFAULT_PRODUCTION_CONFIG,
8
- getCurrentEnvironment
9
- } from "./chunk-IFAXISDF.js";
10
- export {
11
- DEFAULT_BUILD_CONFIG,
12
- DEFAULT_CSSZYX_CONFIG,
13
- DEFAULT_DEVELOPMENT_CONFIG,
14
- DEFAULT_HYDRATION_CONFIG,
15
- DEFAULT_PERFORMANCE_CONFIG,
16
- DEFAULT_PRODUCTION_CONFIG,
17
- getCurrentEnvironment
18
- };
package/dist/index.js DELETED
@@ -1,26 +0,0 @@
1
- import {
2
- DEFAULT_BUILD_CONFIG,
3
- DEFAULT_CSSZYX_CONFIG,
4
- DEFAULT_DEVELOPMENT_CONFIG,
5
- DEFAULT_HYDRATION_CONFIG,
6
- DEFAULT_PERFORMANCE_CONFIG,
7
- DEFAULT_PRODUCTION_CONFIG,
8
- getCurrentEnvironment
9
- } from "./chunk-IFAXISDF.js";
10
- import {
11
- isCsszyxWindow
12
- } from "./chunk-QAJB64L5.js";
13
-
14
- // src/index.ts
15
- var VERSION = "0.0.0";
16
- export {
17
- DEFAULT_BUILD_CONFIG,
18
- DEFAULT_CSSZYX_CONFIG,
19
- DEFAULT_DEVELOPMENT_CONFIG,
20
- DEFAULT_HYDRATION_CONFIG,
21
- DEFAULT_PERFORMANCE_CONFIG,
22
- DEFAULT_PRODUCTION_CONFIG,
23
- VERSION,
24
- getCurrentEnvironment,
25
- isCsszyxWindow
26
- };
package/dist/runtime.js DELETED
@@ -1,6 +0,0 @@
1
- import {
2
- isCsszyxWindow
3
- } from "./chunk-QAJB64L5.js";
4
- export {
5
- isCsszyxWindow
6
- };