@csszyx/core 0.4.0 → 0.5.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.
- package/package.json +3 -3
- package/pkg/csszyx_core.d.ts +245 -226
- package/pkg/csszyx_core.js +2 -4
- package/pkg/csszyx_core_bg.js +727 -642
- package/pkg/csszyx_core_bg.wasm +0 -0
- package/pkg/csszyx_core_bg.wasm.d.ts +19 -21
- package/pkg-node/csszyx_core.d.ts +245 -226
- package/pkg-node/csszyx_core.js +746 -668
- package/pkg-node/csszyx_core_bg.wasm +0 -0
- package/pkg-node/csszyx_core_bg.wasm.d.ts +19 -21
package/pkg/csszyx_core_bg.wasm
CHANGED
|
Binary file
|
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export
|
|
18
|
-
export
|
|
19
|
-
export
|
|
20
|
-
export
|
|
21
|
-
export
|
|
22
|
-
export
|
|
23
|
-
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
24
|
-
export const __wbindgen_start: () => void;
|
|
4
|
+
export function __wbg_wasmcollisiondetector_free(a: number, b: number): void;
|
|
5
|
+
export function compute_mangle_checksum(a: number, b: number): void;
|
|
6
|
+
export function encode(a: number, b: number): void;
|
|
7
|
+
export function generate_token(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number): void;
|
|
8
|
+
export function init(): void;
|
|
9
|
+
export function transform_sz(a: number, b: number): void;
|
|
10
|
+
export function verify_mangle_checksum(a: number, b: number, c: number, d: number): void;
|
|
11
|
+
export function verify_token(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number): number;
|
|
12
|
+
export function version(a: number): void;
|
|
13
|
+
export function wasmcollisiondetector_add(a: number, b: number, c: number, d: number): void;
|
|
14
|
+
export function wasmcollisiondetector_count(a: number): number;
|
|
15
|
+
export function wasmcollisiondetector_has_collision(a: number): number;
|
|
16
|
+
export function wasmcollisiondetector_new(): number;
|
|
17
|
+
export function __wbindgen_malloc(a: number, b: number): number;
|
|
18
|
+
export function __wbindgen_realloc(a: number, b: number, c: number, d: number): number;
|
|
19
|
+
export function __wbindgen_add_to_stack_pointer(a: number): number;
|
|
20
|
+
export function __wbindgen_free(a: number, b: number, c: number): void;
|
|
21
|
+
export function __wbindgen_exn_store(a: number): void;
|
|
22
|
+
export function __wbindgen_start(): void;
|
|
@@ -1,238 +1,257 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
-
|
|
4
3
|
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
* * `value` - CSS value to hash
|
|
16
|
-
*
|
|
17
|
-
* # Returns
|
|
18
|
-
*
|
|
19
|
-
* Variable name (e.g., "--v-abc123" or "--v-abc123-def456")
|
|
20
|
-
*/
|
|
21
|
-
add(value: string): string;
|
|
22
|
-
/**
|
|
23
|
-
* Gets the total number of variables (WASM binding).
|
|
24
|
-
*
|
|
25
|
-
* # Returns
|
|
26
|
-
*
|
|
27
|
-
* Number of unique CSS values
|
|
28
|
-
*/
|
|
29
|
-
count(): number;
|
|
30
|
-
/**
|
|
31
|
-
* Checks if any collision occurred (WASM binding).
|
|
32
|
-
*
|
|
33
|
-
* # Returns
|
|
34
|
-
*
|
|
35
|
-
* `true` if collision detected
|
|
36
|
-
*/
|
|
37
|
-
has_collision(): boolean;
|
|
38
|
-
/**
|
|
39
|
-
* Creates a new collision detector (WASM binding).
|
|
40
|
-
*/
|
|
41
|
-
constructor();
|
|
42
|
-
}
|
|
43
|
-
|
|
4
|
+
* Transforms a csszyx sz object into a Tailwind CSS className string in Rust for maximum performance.
|
|
5
|
+
*
|
|
6
|
+
* Phase 3 Enhancements:
|
|
7
|
+
* - Handles nested variants (hover, focus, md, etc.)
|
|
8
|
+
* - Handles negative values (m: -4 -> -m-4)
|
|
9
|
+
* - Handles boolean flags
|
|
10
|
+
* @param {any} val
|
|
11
|
+
* @returns {string}
|
|
12
|
+
*/
|
|
13
|
+
export function transform_sz(val: any): string;
|
|
44
14
|
/**
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
*
|
|
54
|
-
* 1. Sort all entries by original class name (determinism)
|
|
55
|
-
* 2. Create canonical string: "orig1:mangle1|orig2:mangle2|..."
|
|
56
|
-
* 3. Compute SHA-256 hash
|
|
57
|
-
* 4. Take first 16 hex characters (64 bits, ~1.8e19 possible values)
|
|
58
|
-
*
|
|
59
|
-
* # Arguments
|
|
60
|
-
*
|
|
61
|
-
* * `map` - The mangle map to checksum
|
|
62
|
-
*
|
|
63
|
-
* # Returns
|
|
64
|
-
*
|
|
65
|
-
* A 16-character hex string checksum
|
|
66
|
-
*
|
|
67
|
-
* # Performance
|
|
68
|
-
*
|
|
69
|
-
* - Time complexity: O(n log n) for sorting + O(n) for hashing
|
|
70
|
-
* - Space complexity: O(n) for canonical string
|
|
71
|
-
* - Typical runtime: ~10-50µs for 1000 entries (10-15x faster than JS)
|
|
72
|
-
*
|
|
73
|
-
* # Security
|
|
74
|
-
*
|
|
75
|
-
* While we only use 64 bits of SHA-256, this provides sufficient collision
|
|
76
|
-
* resistance for our use case (detecting accidental mismatches, not
|
|
77
|
-
* cryptographic attacks). Birthday paradox gives us ~4 billion hashes
|
|
78
|
-
* before 50% collision probability.
|
|
79
|
-
*
|
|
80
|
-
* # Examples
|
|
81
|
-
*
|
|
82
|
-
* ```ignore
|
|
83
|
-
* // This function is wasm_bindgen — call from JS, not Rust directly.
|
|
84
|
-
* // Use compute_checksum_internal() for pure-Rust usage.
|
|
85
|
-
* let checksum = compute_mangle_checksum(js_map);
|
|
86
|
-
* ```
|
|
87
|
-
*/
|
|
88
|
-
export function compute_mangle_checksum(map: any): string;
|
|
89
|
-
|
|
15
|
+
* Gets the version of csszyx-core.
|
|
16
|
+
*
|
|
17
|
+
* # Returns
|
|
18
|
+
*
|
|
19
|
+
* Version string
|
|
20
|
+
* @returns {string}
|
|
21
|
+
*/
|
|
22
|
+
export function version(): string;
|
|
90
23
|
/**
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
* - Average: ~5ns per encoding (measured on x86_64)
|
|
106
|
-
*
|
|
107
|
-
* # Examples
|
|
108
|
-
*
|
|
109
|
-
* ```
|
|
110
|
-
* use csszyx_core::encoder::encode;
|
|
111
|
-
*
|
|
112
|
-
* // Tier 1: Single letters (reversed)
|
|
113
|
-
* assert_eq!(encode(0), "z");
|
|
114
|
-
* assert_eq!(encode(25), "a");
|
|
115
|
-
* assert_eq!(encode(26), "Z");
|
|
116
|
-
* assert_eq!(encode(51), "A");
|
|
117
|
-
*
|
|
118
|
-
* // Tier 2: Letter + digit (both reversed)
|
|
119
|
-
* assert_eq!(encode(52), "z9");
|
|
120
|
-
* assert_eq!(encode(53), "z8");
|
|
121
|
-
* assert_eq!(encode(571), "A0");
|
|
122
|
-
*
|
|
123
|
-
* // Tier 3: Two letters (both reversed)
|
|
124
|
-
* assert_eq!(encode(572), "zz");
|
|
125
|
-
* assert_eq!(encode(573), "zy");
|
|
126
|
-
* ```
|
|
127
|
-
*/
|
|
128
|
-
export function encode(index: number): string;
|
|
129
|
-
|
|
24
|
+
* Initializes the WASM module.
|
|
25
|
+
*
|
|
26
|
+
* Should be called once before using any functions.
|
|
27
|
+
*
|
|
28
|
+
* # Examples
|
|
29
|
+
*
|
|
30
|
+
* ```javascript
|
|
31
|
+
* import init, { encode } from 'csszyx-core';
|
|
32
|
+
*
|
|
33
|
+
* await init();
|
|
34
|
+
* const id = encode(42);
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export function init(): void;
|
|
130
38
|
/**
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
39
|
+
* Generates a cryptographic token for a recovery declaration.
|
|
40
|
+
*
|
|
41
|
+
* # Arguments
|
|
42
|
+
*
|
|
43
|
+
* * `component` - Component name
|
|
44
|
+
* * `path` - Absolute file path
|
|
45
|
+
* * `line` - Line number in source
|
|
46
|
+
* * `column` - Column number in source
|
|
47
|
+
* * `mode` - Recovery mode ('csr' or 'dev-only')
|
|
48
|
+
* * `build_id` - Build identifier (git hash or timestamp)
|
|
49
|
+
*
|
|
50
|
+
* # Returns
|
|
51
|
+
*
|
|
52
|
+
* A 12-character Base62 encoded token (first 12 chars of SHA-256 hash)
|
|
53
|
+
*
|
|
54
|
+
* # Security
|
|
55
|
+
*
|
|
56
|
+
* - Uses SHA-256 for cryptographic strength
|
|
57
|
+
* - Includes source location for uniqueness
|
|
58
|
+
* - Build ID ensures different builds have different tokens
|
|
59
|
+
* - Base62 encoding for URL safety
|
|
60
|
+
*
|
|
61
|
+
* # Examples
|
|
62
|
+
*
|
|
63
|
+
* ```
|
|
64
|
+
* use csszyx_core::token::generate_token;
|
|
65
|
+
*
|
|
66
|
+
* let token = generate_token(
|
|
67
|
+
* "DataTable",
|
|
68
|
+
* "/src/components/DataTable.tsx",
|
|
69
|
+
* 42,
|
|
70
|
+
* 8,
|
|
71
|
+
* "csr",
|
|
72
|
+
* "abc123def456"
|
|
73
|
+
* );
|
|
74
|
+
*
|
|
75
|
+
* assert_eq!(token.len(), 12);
|
|
76
|
+
* ```
|
|
77
|
+
* @param {string} component
|
|
78
|
+
* @param {string} path
|
|
79
|
+
* @param {number} line
|
|
80
|
+
* @param {number} column
|
|
81
|
+
* @param {string} mode
|
|
82
|
+
* @param {string} build_id
|
|
83
|
+
* @returns {string}
|
|
84
|
+
*/
|
|
170
85
|
export function generate_token(component: string, path: string, line: number, column: number, mode: string, build_id: string): string;
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* Initializes the WASM module.
|
|
174
|
-
*
|
|
175
|
-
* Should be called once before using any functions.
|
|
176
|
-
*
|
|
177
|
-
* # Examples
|
|
178
|
-
*
|
|
179
|
-
* ```javascript
|
|
180
|
-
* import init, { encode } from 'csszyx-core';
|
|
181
|
-
*
|
|
182
|
-
* await init();
|
|
183
|
-
* const id = encode(42);
|
|
184
|
-
* ```
|
|
185
|
-
*/
|
|
186
|
-
export function init(): void;
|
|
187
|
-
|
|
188
86
|
/**
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
* -
|
|
194
|
-
* -
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
87
|
+
* Verifies a token against component information.
|
|
88
|
+
*
|
|
89
|
+
* # Arguments
|
|
90
|
+
*
|
|
91
|
+
* * `token` - Token to verify
|
|
92
|
+
* * `component` - Component name
|
|
93
|
+
* * `path` - File path
|
|
94
|
+
* * `line` - Line number
|
|
95
|
+
* * `column` - Column number
|
|
96
|
+
* * `mode` - Recovery mode
|
|
97
|
+
* * `build_id` - Build identifier
|
|
98
|
+
*
|
|
99
|
+
* # Returns
|
|
100
|
+
*
|
|
101
|
+
* `true` if token matches, `false` otherwise
|
|
102
|
+
* @param {string} token
|
|
103
|
+
* @param {string} component
|
|
104
|
+
* @param {string} path
|
|
105
|
+
* @param {number} line
|
|
106
|
+
* @param {number} column
|
|
107
|
+
* @param {string} mode
|
|
108
|
+
* @param {string} build_id
|
|
109
|
+
* @returns {boolean}
|
|
110
|
+
*/
|
|
111
|
+
export function verify_token(token: string, component: string, path: string, line: number, column: number, mode: string, build_id: string): boolean;
|
|
198
112
|
/**
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
113
|
+
* WASM-exposed checksum verification.
|
|
114
|
+
*
|
|
115
|
+
* # Arguments
|
|
116
|
+
*
|
|
117
|
+
* * `map` - JavaScript object representing the mangle map
|
|
118
|
+
* * `expected_checksum` - The expected checksum string
|
|
119
|
+
*
|
|
120
|
+
* # Returns
|
|
121
|
+
*
|
|
122
|
+
* `true` if checksum matches, `false` otherwise
|
|
123
|
+
* @param {any} map
|
|
124
|
+
* @param {string} expected_checksum
|
|
125
|
+
* @returns {boolean}
|
|
126
|
+
*/
|
|
210
127
|
export function verify_mangle_checksum(map: any, expected_checksum: string): boolean;
|
|
211
|
-
|
|
212
128
|
/**
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
129
|
+
* Computes a deterministic SHA-256 checksum for a mangle map.
|
|
130
|
+
*
|
|
131
|
+
* The checksum is designed to be:
|
|
132
|
+
* 1. **Deterministic**: Same map always produces same checksum
|
|
133
|
+
* 2. **Collision-resistant**: Different maps produce different checksums
|
|
134
|
+
* 3. **Compact**: 16-character hex string (64 bits of SHA-256)
|
|
135
|
+
*
|
|
136
|
+
* # Algorithm
|
|
137
|
+
*
|
|
138
|
+
* 1. Sort all entries by original class name (determinism)
|
|
139
|
+
* 2. Create canonical string: "orig1:mangle1|orig2:mangle2|..."
|
|
140
|
+
* 3. Compute SHA-256 hash
|
|
141
|
+
* 4. Take first 16 hex characters (64 bits, ~1.8e19 possible values)
|
|
142
|
+
*
|
|
143
|
+
* # Arguments
|
|
144
|
+
*
|
|
145
|
+
* * `map` - The mangle map to checksum
|
|
146
|
+
*
|
|
147
|
+
* # Returns
|
|
148
|
+
*
|
|
149
|
+
* A 16-character hex string checksum
|
|
150
|
+
*
|
|
151
|
+
* # Performance
|
|
152
|
+
*
|
|
153
|
+
* - Time complexity: O(n log n) for sorting + O(n) for hashing
|
|
154
|
+
* - Space complexity: O(n) for canonical string
|
|
155
|
+
* - Typical runtime: ~10-50µs for 1000 entries (10-15x faster than JS)
|
|
156
|
+
*
|
|
157
|
+
* # Security
|
|
158
|
+
*
|
|
159
|
+
* While we only use 64 bits of SHA-256, this provides sufficient collision
|
|
160
|
+
* resistance for our use case (detecting accidental mismatches, not
|
|
161
|
+
* cryptographic attacks). Birthday paradox gives us ~4 billion hashes
|
|
162
|
+
* before 50% collision probability.
|
|
163
|
+
*
|
|
164
|
+
* # Examples
|
|
165
|
+
*
|
|
166
|
+
* ```ignore
|
|
167
|
+
* // This function is wasm_bindgen — call from JS, not Rust directly.
|
|
168
|
+
* // Use compute_checksum_internal() for pure-Rust usage.
|
|
169
|
+
* let checksum = compute_mangle_checksum(js_map);
|
|
170
|
+
* ```
|
|
171
|
+
* @param {any} map
|
|
172
|
+
* @returns {string}
|
|
173
|
+
*/
|
|
174
|
+
export function compute_mangle_checksum(map: any): string;
|
|
231
175
|
/**
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
*
|
|
237
|
-
|
|
238
|
-
|
|
176
|
+
* Encodes an index to a reversed tier-based Base62 string.
|
|
177
|
+
*
|
|
178
|
+
* # Arguments
|
|
179
|
+
*
|
|
180
|
+
* * `index` - The zero-based index to encode
|
|
181
|
+
*
|
|
182
|
+
* # Returns
|
|
183
|
+
*
|
|
184
|
+
* A Base62 encoded string following tier-based rules with reversed sequence
|
|
185
|
+
*
|
|
186
|
+
* # Performance
|
|
187
|
+
*
|
|
188
|
+
* - Time complexity: O(log n)
|
|
189
|
+
* - Space complexity: O(log n)
|
|
190
|
+
* - Average: ~5ns per encoding (measured on x86_64)
|
|
191
|
+
*
|
|
192
|
+
* # Examples
|
|
193
|
+
*
|
|
194
|
+
* ```
|
|
195
|
+
* use csszyx_core::encoder::encode;
|
|
196
|
+
*
|
|
197
|
+
* // Tier 1: Single letters (reversed)
|
|
198
|
+
* assert_eq!(encode(0), "z");
|
|
199
|
+
* assert_eq!(encode(25), "a");
|
|
200
|
+
* assert_eq!(encode(26), "Z");
|
|
201
|
+
* assert_eq!(encode(51), "A");
|
|
202
|
+
*
|
|
203
|
+
* // Tier 2: Letter + digit (both reversed)
|
|
204
|
+
* assert_eq!(encode(52), "z9");
|
|
205
|
+
* assert_eq!(encode(53), "z8");
|
|
206
|
+
* assert_eq!(encode(571), "A0");
|
|
207
|
+
*
|
|
208
|
+
* // Tier 3: Two letters (both reversed)
|
|
209
|
+
* assert_eq!(encode(572), "zz");
|
|
210
|
+
* assert_eq!(encode(573), "zy");
|
|
211
|
+
* ```
|
|
212
|
+
* @param {number} index
|
|
213
|
+
* @returns {string}
|
|
214
|
+
*/
|
|
215
|
+
export function encode(index: number): string;
|
|
216
|
+
/**
|
|
217
|
+
* WASM bindings for JavaScript interop
|
|
218
|
+
*/
|
|
219
|
+
export class WasmCollisionDetector {
|
|
220
|
+
free(): void;
|
|
221
|
+
/**
|
|
222
|
+
* Checks if any collision occurred (WASM binding).
|
|
223
|
+
*
|
|
224
|
+
* # Returns
|
|
225
|
+
*
|
|
226
|
+
* `true` if collision detected
|
|
227
|
+
* @returns {boolean}
|
|
228
|
+
*/
|
|
229
|
+
has_collision(): boolean;
|
|
230
|
+
/**
|
|
231
|
+
* Adds a CSS value and returns its variable name (WASM binding).
|
|
232
|
+
*
|
|
233
|
+
* # Arguments
|
|
234
|
+
*
|
|
235
|
+
* * `value` - CSS value to hash
|
|
236
|
+
*
|
|
237
|
+
* # Returns
|
|
238
|
+
*
|
|
239
|
+
* Variable name (e.g., "--v-abc123" or "--v-abc123-def456")
|
|
240
|
+
* @param {string} value
|
|
241
|
+
* @returns {string}
|
|
242
|
+
*/
|
|
243
|
+
add(value: string): string;
|
|
244
|
+
/**
|
|
245
|
+
* Creates a new collision detector (WASM binding).
|
|
246
|
+
*/
|
|
247
|
+
constructor();
|
|
248
|
+
/**
|
|
249
|
+
* Gets the total number of variables (WASM binding).
|
|
250
|
+
*
|
|
251
|
+
* # Returns
|
|
252
|
+
*
|
|
253
|
+
* Number of unique CSS values
|
|
254
|
+
* @returns {number}
|
|
255
|
+
*/
|
|
256
|
+
count(): number;
|
|
257
|
+
}
|