@csszyx/core 0.3.1 → 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.
@@ -1,612 +1,123 @@
1
- /* @ts-self-types="./csszyx_core.d.ts" */
2
1
 
3
- /**
4
- * WASM bindings for JavaScript interop
5
- */
6
- class WasmCollisionDetector {
7
- __destroy_into_raw() {
8
- const ptr = this.__wbg_ptr;
9
- this.__wbg_ptr = 0;
10
- WasmCollisionDetectorFinalization.unregister(this);
11
- return ptr;
12
- }
13
- free() {
14
- const ptr = this.__destroy_into_raw();
15
- wasm.__wbg_wasmcollisiondetector_free(ptr, 0);
16
- }
17
- /**
18
- * Adds a CSS value and returns its variable name (WASM binding).
19
- *
20
- * # Arguments
21
- *
22
- * * `value` - CSS value to hash
23
- *
24
- * # Returns
25
- *
26
- * Variable name (e.g., "--v-abc123" or "--v-abc123-def456")
27
- * @param {string} value
28
- * @returns {string}
29
- */
30
- add(value) {
31
- let deferred2_0;
32
- let deferred2_1;
33
- try {
34
- const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
35
- const len0 = WASM_VECTOR_LEN;
36
- const ret = wasm.wasmcollisiondetector_add(this.__wbg_ptr, ptr0, len0);
37
- deferred2_0 = ret[0];
38
- deferred2_1 = ret[1];
39
- return getStringFromWasm0(ret[0], ret[1]);
40
- } finally {
41
- wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
42
- }
43
- }
44
- /**
45
- * Gets the total number of variables (WASM binding).
46
- *
47
- * # Returns
48
- *
49
- * Number of unique CSS values
50
- * @returns {number}
51
- */
52
- count() {
53
- const ret = wasm.wasmcollisiondetector_count(this.__wbg_ptr);
54
- return ret >>> 0;
55
- }
56
- /**
57
- * Checks if any collision occurred (WASM binding).
58
- *
59
- * # Returns
60
- *
61
- * `true` if collision detected
62
- * @returns {boolean}
63
- */
64
- has_collision() {
65
- const ret = wasm.wasmcollisiondetector_has_collision(this.__wbg_ptr);
66
- return ret !== 0;
67
- }
68
- /**
69
- * Creates a new collision detector (WASM binding).
70
- */
71
- constructor() {
72
- const ret = wasm.wasmcollisiondetector_new();
73
- this.__wbg_ptr = ret >>> 0;
74
- WasmCollisionDetectorFinalization.register(this, this.__wbg_ptr, this);
75
- return this;
76
- }
2
+ let imports = {};
3
+ imports['__wbindgen_placeholder__'] = module.exports;
4
+ let wasm;
5
+ const { TextDecoder, TextEncoder } = require(`util`);
6
+
7
+ const heap = new Array(128).fill(undefined);
8
+
9
+ heap.push(undefined, null, true, false);
10
+
11
+ function getObject(idx) { return heap[idx]; }
12
+
13
+ let heap_next = heap.length;
14
+
15
+ function dropObject(idx) {
16
+ if (idx < 132) return;
17
+ heap[idx] = heap_next;
18
+ heap_next = idx;
77
19
  }
78
- if (Symbol.dispose) WasmCollisionDetector.prototype[Symbol.dispose] = WasmCollisionDetector.prototype.free;
79
- exports.WasmCollisionDetector = WasmCollisionDetector;
80
20
 
81
- /**
82
- * Computes a deterministic SHA-256 checksum for a mangle map.
83
- *
84
- * The checksum is designed to be:
85
- * 1. **Deterministic**: Same map always produces same checksum
86
- * 2. **Collision-resistant**: Different maps produce different checksums
87
- * 3. **Compact**: 16-character hex string (64 bits of SHA-256)
88
- *
89
- * # Algorithm
90
- *
91
- * 1. Sort all entries by original class name (determinism)
92
- * 2. Create canonical string: "orig1:mangle1|orig2:mangle2|..."
93
- * 3. Compute SHA-256 hash
94
- * 4. Take first 16 hex characters (64 bits, ~1.8e19 possible values)
95
- *
96
- * # Arguments
97
- *
98
- * * `map` - The mangle map to checksum
99
- *
100
- * # Returns
101
- *
102
- * A 16-character hex string checksum
103
- *
104
- * # Performance
105
- *
106
- * - Time complexity: O(n log n) for sorting + O(n) for hashing
107
- * - Space complexity: O(n) for canonical string
108
- * - Typical runtime: ~10-50µs for 1000 entries (10-15x faster than JS)
109
- *
110
- * # Security
111
- *
112
- * While we only use 64 bits of SHA-256, this provides sufficient collision
113
- * resistance for our use case (detecting accidental mismatches, not
114
- * cryptographic attacks). Birthday paradox gives us ~4 billion hashes
115
- * before 50% collision probability.
116
- *
117
- * # Examples
118
- *
119
- * ```ignore
120
- * // This function is wasm_bindgen — call from JS, not Rust directly.
121
- * // Use compute_checksum_internal() for pure-Rust usage.
122
- * let checksum = compute_mangle_checksum(js_map);
123
- * ```
124
- * @param {any} map
125
- * @returns {string}
126
- */
127
- function compute_mangle_checksum(map) {
128
- let deferred2_0;
129
- let deferred2_1;
130
- try {
131
- const ret = wasm.compute_mangle_checksum(map);
132
- var ptr1 = ret[0];
133
- var len1 = ret[1];
134
- if (ret[3]) {
135
- ptr1 = 0; len1 = 0;
136
- throw takeFromExternrefTable0(ret[2]);
137
- }
138
- deferred2_0 = ptr1;
139
- deferred2_1 = len1;
140
- return getStringFromWasm0(ptr1, len1);
141
- } finally {
142
- wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
143
- }
21
+ function takeObject(idx) {
22
+ const ret = getObject(idx);
23
+ dropObject(idx);
24
+ return ret;
144
25
  }
145
- exports.compute_mangle_checksum = compute_mangle_checksum;
146
26
 
147
- /**
148
- * Encodes an index to a reversed tier-based Base62 string.
149
- *
150
- * # Arguments
151
- *
152
- * * `index` - The zero-based index to encode
153
- *
154
- * # Returns
155
- *
156
- * A Base62 encoded string following tier-based rules with reversed sequence
157
- *
158
- * # Performance
159
- *
160
- * - Time complexity: O(log n)
161
- * - Space complexity: O(log n)
162
- * - Average: ~5ns per encoding (measured on x86_64)
163
- *
164
- * # Examples
165
- *
166
- * ```
167
- * use csszyx_core::encoder::encode;
168
- *
169
- * // Tier 1: Single letters (reversed)
170
- * assert_eq!(encode(0), "z");
171
- * assert_eq!(encode(25), "a");
172
- * assert_eq!(encode(26), "Z");
173
- * assert_eq!(encode(51), "A");
174
- *
175
- * // Tier 2: Letter + digit (both reversed)
176
- * assert_eq!(encode(52), "z9");
177
- * assert_eq!(encode(53), "z8");
178
- * assert_eq!(encode(571), "A0");
179
- *
180
- * // Tier 3: Two letters (both reversed)
181
- * assert_eq!(encode(572), "zz");
182
- * assert_eq!(encode(573), "zy");
183
- * ```
184
- * @param {number} index
185
- * @returns {string}
186
- */
187
- function encode(index) {
188
- let deferred1_0;
189
- let deferred1_1;
190
- try {
191
- const ret = wasm.encode(index);
192
- deferred1_0 = ret[0];
193
- deferred1_1 = ret[1];
194
- return getStringFromWasm0(ret[0], ret[1]);
195
- } finally {
196
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
27
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
28
+
29
+ cachedTextDecoder.decode();
30
+
31
+ let cachedUint8ArrayMemory0 = null;
32
+
33
+ function getUint8ArrayMemory0() {
34
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
35
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
197
36
  }
37
+ return cachedUint8ArrayMemory0;
198
38
  }
199
- exports.encode = encode;
200
39
 
201
- /**
202
- * Generates a cryptographic token for a recovery declaration.
203
- *
204
- * # Arguments
205
- *
206
- * * `component` - Component name
207
- * * `path` - Absolute file path
208
- * * `line` - Line number in source
209
- * * `column` - Column number in source
210
- * * `mode` - Recovery mode ('csr' or 'dev-only')
211
- * * `build_id` - Build identifier (git hash or timestamp)
212
- *
213
- * # Returns
214
- *
215
- * A 12-character Base62 encoded token (first 12 chars of SHA-256 hash)
216
- *
217
- * # Security
218
- *
219
- * - Uses SHA-256 for cryptographic strength
220
- * - Includes source location for uniqueness
221
- * - Build ID ensures different builds have different tokens
222
- * - Base62 encoding for URL safety
223
- *
224
- * # Examples
225
- *
226
- * ```
227
- * use csszyx_core::token::generate_token;
228
- *
229
- * let token = generate_token(
230
- * "DataTable",
231
- * "/src/components/DataTable.tsx",
232
- * 42,
233
- * 8,
234
- * "csr",
235
- * "abc123def456"
236
- * );
237
- *
238
- * assert_eq!(token.len(), 12);
239
- * ```
240
- * @param {string} component
241
- * @param {string} path
242
- * @param {number} line
243
- * @param {number} column
244
- * @param {string} mode
245
- * @param {string} build_id
246
- * @returns {string}
247
- */
248
- function generate_token(component, path, line, column, mode, build_id) {
249
- let deferred5_0;
250
- let deferred5_1;
251
- try {
252
- const ptr0 = passStringToWasm0(component, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
253
- const len0 = WASM_VECTOR_LEN;
254
- const ptr1 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
255
- const len1 = WASM_VECTOR_LEN;
256
- const ptr2 = passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
257
- const len2 = WASM_VECTOR_LEN;
258
- const ptr3 = passStringToWasm0(build_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
259
- const len3 = WASM_VECTOR_LEN;
260
- const ret = wasm.generate_token(ptr0, len0, ptr1, len1, line, column, ptr2, len2, ptr3, len3);
261
- deferred5_0 = ret[0];
262
- deferred5_1 = ret[1];
263
- return getStringFromWasm0(ret[0], ret[1]);
264
- } finally {
265
- wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
266
- }
40
+ function getStringFromWasm0(ptr, len) {
41
+ ptr = ptr >>> 0;
42
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
267
43
  }
268
- exports.generate_token = generate_token;
269
44
 
270
- /**
271
- * Initializes the WASM module.
272
- *
273
- * Should be called once before using any functions.
274
- *
275
- * # Examples
276
- *
277
- * ```javascript
278
- * import init, { encode } from 'csszyx-core';
279
- *
280
- * await init();
281
- * const id = encode(42);
282
- * ```
283
- */
284
- function init() {
285
- wasm.init();
45
+ function addHeapObject(obj) {
46
+ if (heap_next === heap.length) heap.push(heap.length + 1);
47
+ const idx = heap_next;
48
+ heap_next = heap[idx];
49
+
50
+ heap[idx] = obj;
51
+ return idx;
286
52
  }
287
- exports.init = init;
288
53
 
289
- /**
290
- * Transforms a csszyx sz object into a Tailwind CSS className string in Rust for maximum performance.
291
- *
292
- * Phase 3 Enhancements:
293
- * - Handles nested variants (hover, focus, md, etc.)
294
- * - Handles negative values (m: -4 -> -m-4)
295
- * - Handles boolean flags
296
- * @param {any} val
297
- * @returns {string}
298
- */
299
- function transform_sz(val) {
300
- let deferred2_0;
301
- let deferred2_1;
302
- try {
303
- const ret = wasm.transform_sz(val);
304
- var ptr1 = ret[0];
305
- var len1 = ret[1];
306
- if (ret[3]) {
307
- ptr1 = 0; len1 = 0;
308
- throw takeFromExternrefTable0(ret[2]);
309
- }
310
- deferred2_0 = ptr1;
311
- deferred2_1 = len1;
312
- return getStringFromWasm0(ptr1, len1);
313
- } finally {
314
- wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
315
- }
54
+ function isLikeNone(x) {
55
+ return x === undefined || x === null;
316
56
  }
317
- exports.transform_sz = transform_sz;
318
57
 
319
- /**
320
- * WASM-exposed checksum verification.
321
- *
322
- * # Arguments
323
- *
324
- * * `map` - JavaScript object representing the mangle map
325
- * * `expected_checksum` - The expected checksum string
326
- *
327
- * # Returns
328
- *
329
- * `true` if checksum matches, `false` otherwise
330
- * @param {any} map
331
- * @param {string} expected_checksum
332
- * @returns {boolean}
333
- */
334
- function verify_mangle_checksum(map, expected_checksum) {
335
- const ptr0 = passStringToWasm0(expected_checksum, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
336
- const len0 = WASM_VECTOR_LEN;
337
- const ret = wasm.verify_mangle_checksum(map, ptr0, len0);
338
- if (ret[2]) {
339
- throw takeFromExternrefTable0(ret[1]);
58
+ let cachedDataViewMemory0 = null;
59
+
60
+ function getDataViewMemory0() {
61
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
62
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
340
63
  }
341
- return ret[0] !== 0;
64
+ return cachedDataViewMemory0;
342
65
  }
343
- exports.verify_mangle_checksum = verify_mangle_checksum;
344
66
 
345
- /**
346
- * Verifies a token against component information.
347
- *
348
- * # Arguments
349
- *
350
- * * `token` - Token to verify
351
- * * `component` - Component name
352
- * * `path` - File path
353
- * * `line` - Line number
354
- * * `column` - Column number
355
- * * `mode` - Recovery mode
356
- * * `build_id` - Build identifier
357
- *
358
- * # Returns
359
- *
360
- * `true` if token matches, `false` otherwise
361
- * @param {string} token
362
- * @param {string} component
363
- * @param {string} path
364
- * @param {number} line
365
- * @param {number} column
366
- * @param {string} mode
367
- * @param {string} build_id
368
- * @returns {boolean}
369
- */
370
- function verify_token(token, component, path, line, column, mode, build_id) {
371
- const ptr0 = passStringToWasm0(token, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
372
- const len0 = WASM_VECTOR_LEN;
373
- const ptr1 = passStringToWasm0(component, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
374
- const len1 = WASM_VECTOR_LEN;
375
- const ptr2 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
376
- const len2 = WASM_VECTOR_LEN;
377
- const ptr3 = passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
378
- const len3 = WASM_VECTOR_LEN;
379
- const ptr4 = passStringToWasm0(build_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
380
- const len4 = WASM_VECTOR_LEN;
381
- const ret = wasm.verify_token(ptr0, len0, ptr1, len1, ptr2, len2, line, column, ptr3, len3, ptr4, len4);
382
- return ret !== 0;
383
- }
384
- exports.verify_token = verify_token;
67
+ let WASM_VECTOR_LEN = 0;
385
68
 
386
- /**
387
- * Gets the version of csszyx-core.
388
- *
389
- * # Returns
390
- *
391
- * Version string
392
- * @returns {string}
393
- */
394
- function version() {
395
- let deferred1_0;
396
- let deferred1_1;
397
- try {
398
- const ret = wasm.version();
399
- deferred1_0 = ret[0];
400
- deferred1_1 = ret[1];
401
- return getStringFromWasm0(ret[0], ret[1]);
402
- } finally {
403
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
404
- }
69
+ let cachedTextEncoder = new TextEncoder('utf-8');
70
+
71
+ const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
72
+ ? function (arg, view) {
73
+ return cachedTextEncoder.encodeInto(arg, view);
405
74
  }
406
- exports.version = version;
407
-
408
- function __wbg_get_imports() {
409
- const import0 = {
410
- __proto__: null,
411
- __wbg_Error_8c4e43fe74559d73: function(arg0, arg1) {
412
- const ret = Error(getStringFromWasm0(arg0, arg1));
413
- return ret;
414
- },
415
- __wbg_String_8f0eb39a4a4c2f66: function(arg0, arg1) {
416
- const ret = String(arg1);
417
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
418
- const len1 = WASM_VECTOR_LEN;
419
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
420
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
421
- },
422
- __wbg___wbindgen_bigint_get_as_i64_8fcf4ce7f1ca72a2: function(arg0, arg1) {
423
- const v = arg1;
424
- const ret = typeof(v) === 'bigint' ? v : undefined;
425
- getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
426
- getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
427
- },
428
- __wbg___wbindgen_boolean_get_bbbb1c18aa2f5e25: function(arg0) {
429
- const v = arg0;
430
- const ret = typeof(v) === 'boolean' ? v : undefined;
431
- return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
432
- },
433
- __wbg___wbindgen_debug_string_0bc8482c6e3508ae: function(arg0, arg1) {
434
- const ret = debugString(arg1);
435
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
436
- const len1 = WASM_VECTOR_LEN;
437
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
438
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
439
- },
440
- __wbg___wbindgen_in_47fa6863be6f2f25: function(arg0, arg1) {
441
- const ret = arg0 in arg1;
442
- return ret;
443
- },
444
- __wbg___wbindgen_is_bigint_31b12575b56f32fc: function(arg0) {
445
- const ret = typeof(arg0) === 'bigint';
446
- return ret;
447
- },
448
- __wbg___wbindgen_is_function_0095a73b8b156f76: function(arg0) {
449
- const ret = typeof(arg0) === 'function';
450
- return ret;
451
- },
452
- __wbg___wbindgen_is_object_5ae8e5880f2c1fbd: function(arg0) {
453
- const val = arg0;
454
- const ret = typeof(val) === 'object' && val !== null;
455
- return ret;
456
- },
457
- __wbg___wbindgen_jsval_eq_11888390b0186270: function(arg0, arg1) {
458
- const ret = arg0 === arg1;
459
- return ret;
460
- },
461
- __wbg___wbindgen_jsval_loose_eq_9dd77d8cd6671811: function(arg0, arg1) {
462
- const ret = arg0 == arg1;
463
- return ret;
464
- },
465
- __wbg___wbindgen_number_get_8ff4255516ccad3e: function(arg0, arg1) {
466
- const obj = arg1;
467
- const ret = typeof(obj) === 'number' ? obj : undefined;
468
- getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
469
- getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
470
- },
471
- __wbg___wbindgen_string_get_72fb696202c56729: function(arg0, arg1) {
472
- const obj = arg1;
473
- const ret = typeof(obj) === 'string' ? obj : undefined;
474
- var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
475
- var len1 = WASM_VECTOR_LEN;
476
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
477
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
478
- },
479
- __wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
480
- throw new Error(getStringFromWasm0(arg0, arg1));
481
- },
482
- __wbg_call_389efe28435a9388: function() { return handleError(function (arg0, arg1) {
483
- const ret = arg0.call(arg1);
484
- return ret;
485
- }, arguments); },
486
- __wbg_done_57b39ecd9addfe81: function(arg0) {
487
- const ret = arg0.done;
488
- return ret;
489
- },
490
- __wbg_entries_58c7934c745daac7: function(arg0) {
491
- const ret = Object.entries(arg0);
492
- return ret;
493
- },
494
- __wbg_get_9b94d73e6221f75c: function(arg0, arg1) {
495
- const ret = arg0[arg1 >>> 0];
496
- return ret;
497
- },
498
- __wbg_get_b3ed3ad4be2bc8ac: function() { return handleError(function (arg0, arg1) {
499
- const ret = Reflect.get(arg0, arg1);
500
- return ret;
501
- }, arguments); },
502
- __wbg_instanceof_ArrayBuffer_c367199e2fa2aa04: function(arg0) {
503
- let result;
504
- try {
505
- result = arg0 instanceof ArrayBuffer;
506
- } catch (_) {
507
- result = false;
508
- }
509
- const ret = result;
510
- return ret;
511
- },
512
- __wbg_instanceof_Map_53af74335dec57f4: function(arg0) {
513
- let result;
514
- try {
515
- result = arg0 instanceof Map;
516
- } catch (_) {
517
- result = false;
518
- }
519
- const ret = result;
520
- return ret;
521
- },
522
- __wbg_instanceof_Uint8Array_9b9075935c74707c: function(arg0) {
523
- let result;
524
- try {
525
- result = arg0 instanceof Uint8Array;
526
- } catch (_) {
527
- result = false;
528
- }
529
- const ret = result;
530
- return ret;
531
- },
532
- __wbg_isArray_d314bb98fcf08331: function(arg0) {
533
- const ret = Array.isArray(arg0);
534
- return ret;
535
- },
536
- __wbg_isSafeInteger_bfbc7332a9768d2a: function(arg0) {
537
- const ret = Number.isSafeInteger(arg0);
538
- return ret;
539
- },
540
- __wbg_iterator_6ff6560ca1568e55: function() {
541
- const ret = Symbol.iterator;
542
- return ret;
543
- },
544
- __wbg_length_32ed9a279acd054c: function(arg0) {
545
- const ret = arg0.length;
546
- return ret;
547
- },
548
- __wbg_length_35a7bace40f36eac: function(arg0) {
549
- const ret = arg0.length;
550
- return ret;
551
- },
552
- __wbg_new_dd2b680c8bf6ae29: function(arg0) {
553
- const ret = new Uint8Array(arg0);
554
- return ret;
555
- },
556
- __wbg_next_3482f54c49e8af19: function() { return handleError(function (arg0) {
557
- const ret = arg0.next();
558
- return ret;
559
- }, arguments); },
560
- __wbg_next_418f80d8f5303233: function(arg0) {
561
- const ret = arg0.next;
562
- return ret;
563
- },
564
- __wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {
565
- Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
566
- },
567
- __wbg_value_0546255b415e96c1: function(arg0) {
568
- const ret = arg0.value;
569
- return ret;
570
- },
571
- __wbindgen_cast_0000000000000001: function(arg0) {
572
- // Cast intrinsic for `I64 -> Externref`.
573
- const ret = arg0;
574
- return ret;
575
- },
576
- __wbindgen_cast_0000000000000002: function(arg0, arg1) {
577
- // Cast intrinsic for `Ref(String) -> Externref`.
578
- const ret = getStringFromWasm0(arg0, arg1);
579
- return ret;
580
- },
581
- __wbindgen_cast_0000000000000003: function(arg0) {
582
- // Cast intrinsic for `U64 -> Externref`.
583
- const ret = BigInt.asUintN(64, arg0);
584
- return ret;
585
- },
586
- __wbindgen_init_externref_table: function() {
587
- const table = wasm.__wbindgen_externrefs;
588
- const offset = table.grow(4);
589
- table.set(0, undefined);
590
- table.set(offset + 0, undefined);
591
- table.set(offset + 1, null);
592
- table.set(offset + 2, true);
593
- table.set(offset + 3, false);
594
- },
595
- };
75
+ : function (arg, view) {
76
+ const buf = cachedTextEncoder.encode(arg);
77
+ view.set(buf);
596
78
  return {
597
- __proto__: null,
598
- "./csszyx_core_bg.js": import0,
79
+ read: arg.length,
80
+ written: buf.length
599
81
  };
600
- }
82
+ });
601
83
 
602
- const WasmCollisionDetectorFinalization = (typeof FinalizationRegistry === 'undefined')
603
- ? { register: () => {}, unregister: () => {} }
604
- : new FinalizationRegistry(ptr => wasm.__wbg_wasmcollisiondetector_free(ptr >>> 0, 1));
84
+ function passStringToWasm0(arg, malloc, realloc) {
605
85
 
606
- function addToExternrefTable0(obj) {
607
- const idx = wasm.__externref_table_alloc();
608
- wasm.__wbindgen_externrefs.set(idx, obj);
609
- return idx;
86
+ if (realloc === undefined) {
87
+ const buf = cachedTextEncoder.encode(arg);
88
+ const ptr = malloc(buf.length, 1) >>> 0;
89
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
90
+ WASM_VECTOR_LEN = buf.length;
91
+ return ptr;
92
+ }
93
+
94
+ let len = arg.length;
95
+ let ptr = malloc(len, 1) >>> 0;
96
+
97
+ const mem = getUint8ArrayMemory0();
98
+
99
+ let offset = 0;
100
+
101
+ for (; offset < len; offset++) {
102
+ const code = arg.charCodeAt(offset);
103
+ if (code > 0x7F) break;
104
+ mem[ptr + offset] = code;
105
+ }
106
+
107
+ if (offset !== len) {
108
+ if (offset !== 0) {
109
+ arg = arg.slice(offset);
110
+ }
111
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
112
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
113
+ const ret = encodeString(arg, view);
114
+
115
+ offset += ret.written;
116
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
117
+ }
118
+
119
+ WASM_VECTOR_LEN = offset;
120
+ return ptr;
610
121
  }
611
122
 
612
123
  function debugString(val) {
@@ -650,7 +161,7 @@ function debugString(val) {
650
161
  // Test for built-in
651
162
  const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
652
163
  let className;
653
- if (builtInMatches && builtInMatches.length > 1) {
164
+ if (builtInMatches.length > 1) {
654
165
  className = builtInMatches[1];
655
166
  } else {
656
167
  // Failed to match the standard '[object ClassName]'
@@ -673,112 +184,679 @@ function debugString(val) {
673
184
  // TODO we could test for more things here, like `Set`s and `Map`s.
674
185
  return className;
675
186
  }
187
+ /**
188
+ * Transforms a csszyx sz object into a Tailwind CSS className string in Rust for maximum performance.
189
+ *
190
+ * Phase 3 Enhancements:
191
+ * - Handles nested variants (hover, focus, md, etc.)
192
+ * - Handles negative values (m: -4 -> -m-4)
193
+ * - Handles boolean flags
194
+ * @param {any} val
195
+ * @returns {string}
196
+ */
197
+ module.exports.transform_sz = function(val) {
198
+ let deferred2_0;
199
+ let deferred2_1;
200
+ try {
201
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
202
+ wasm.transform_sz(retptr, addHeapObject(val));
203
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
204
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
205
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
206
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
207
+ var ptr1 = r0;
208
+ var len1 = r1;
209
+ if (r3) {
210
+ ptr1 = 0; len1 = 0;
211
+ throw takeObject(r2);
212
+ }
213
+ deferred2_0 = ptr1;
214
+ deferred2_1 = len1;
215
+ return getStringFromWasm0(ptr1, len1);
216
+ } finally {
217
+ wasm.__wbindgen_add_to_stack_pointer(16);
218
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
219
+ }
220
+ };
676
221
 
677
- function getArrayU8FromWasm0(ptr, len) {
678
- ptr = ptr >>> 0;
679
- return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
680
- }
222
+ /**
223
+ * Gets the version of csszyx-core.
224
+ *
225
+ * # Returns
226
+ *
227
+ * Version string
228
+ * @returns {string}
229
+ */
230
+ module.exports.version = function() {
231
+ let deferred1_0;
232
+ let deferred1_1;
233
+ try {
234
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
235
+ wasm.version(retptr);
236
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
237
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
238
+ deferred1_0 = r0;
239
+ deferred1_1 = r1;
240
+ return getStringFromWasm0(r0, r1);
241
+ } finally {
242
+ wasm.__wbindgen_add_to_stack_pointer(16);
243
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
244
+ }
245
+ };
681
246
 
682
- let cachedDataViewMemory0 = null;
683
- function getDataViewMemory0() {
684
- if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
685
- cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
247
+ /**
248
+ * Initializes the WASM module.
249
+ *
250
+ * Should be called once before using any functions.
251
+ *
252
+ * # Examples
253
+ *
254
+ * ```javascript
255
+ * import init, { encode } from 'csszyx-core';
256
+ *
257
+ * await init();
258
+ * const id = encode(42);
259
+ * ```
260
+ */
261
+ module.exports.init = function() {
262
+ wasm.init();
263
+ };
264
+
265
+ /**
266
+ * Generates a cryptographic token for a recovery declaration.
267
+ *
268
+ * # Arguments
269
+ *
270
+ * * `component` - Component name
271
+ * * `path` - Absolute file path
272
+ * * `line` - Line number in source
273
+ * * `column` - Column number in source
274
+ * * `mode` - Recovery mode ('csr' or 'dev-only')
275
+ * * `build_id` - Build identifier (git hash or timestamp)
276
+ *
277
+ * # Returns
278
+ *
279
+ * A 12-character Base62 encoded token (first 12 chars of SHA-256 hash)
280
+ *
281
+ * # Security
282
+ *
283
+ * - Uses SHA-256 for cryptographic strength
284
+ * - Includes source location for uniqueness
285
+ * - Build ID ensures different builds have different tokens
286
+ * - Base62 encoding for URL safety
287
+ *
288
+ * # Examples
289
+ *
290
+ * ```
291
+ * use csszyx_core::token::generate_token;
292
+ *
293
+ * let token = generate_token(
294
+ * "DataTable",
295
+ * "/src/components/DataTable.tsx",
296
+ * 42,
297
+ * 8,
298
+ * "csr",
299
+ * "abc123def456"
300
+ * );
301
+ *
302
+ * assert_eq!(token.len(), 12);
303
+ * ```
304
+ * @param {string} component
305
+ * @param {string} path
306
+ * @param {number} line
307
+ * @param {number} column
308
+ * @param {string} mode
309
+ * @param {string} build_id
310
+ * @returns {string}
311
+ */
312
+ module.exports.generate_token = function(component, path, line, column, mode, build_id) {
313
+ let deferred5_0;
314
+ let deferred5_1;
315
+ try {
316
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
317
+ const ptr0 = passStringToWasm0(component, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
318
+ const len0 = WASM_VECTOR_LEN;
319
+ const ptr1 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
320
+ const len1 = WASM_VECTOR_LEN;
321
+ const ptr2 = passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
322
+ const len2 = WASM_VECTOR_LEN;
323
+ const ptr3 = passStringToWasm0(build_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
324
+ const len3 = WASM_VECTOR_LEN;
325
+ wasm.generate_token(retptr, ptr0, len0, ptr1, len1, line, column, ptr2, len2, ptr3, len3);
326
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
327
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
328
+ deferred5_0 = r0;
329
+ deferred5_1 = r1;
330
+ return getStringFromWasm0(r0, r1);
331
+ } finally {
332
+ wasm.__wbindgen_add_to_stack_pointer(16);
333
+ wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
686
334
  }
687
- return cachedDataViewMemory0;
688
- }
335
+ };
689
336
 
690
- function getStringFromWasm0(ptr, len) {
691
- ptr = ptr >>> 0;
692
- return decodeText(ptr, len);
693
- }
337
+ /**
338
+ * Verifies a token against component information.
339
+ *
340
+ * # Arguments
341
+ *
342
+ * * `token` - Token to verify
343
+ * * `component` - Component name
344
+ * * `path` - File path
345
+ * * `line` - Line number
346
+ * * `column` - Column number
347
+ * * `mode` - Recovery mode
348
+ * * `build_id` - Build identifier
349
+ *
350
+ * # Returns
351
+ *
352
+ * `true` if token matches, `false` otherwise
353
+ * @param {string} token
354
+ * @param {string} component
355
+ * @param {string} path
356
+ * @param {number} line
357
+ * @param {number} column
358
+ * @param {string} mode
359
+ * @param {string} build_id
360
+ * @returns {boolean}
361
+ */
362
+ module.exports.verify_token = function(token, component, path, line, column, mode, build_id) {
363
+ const ptr0 = passStringToWasm0(token, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
364
+ const len0 = WASM_VECTOR_LEN;
365
+ const ptr1 = passStringToWasm0(component, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
366
+ const len1 = WASM_VECTOR_LEN;
367
+ const ptr2 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
368
+ const len2 = WASM_VECTOR_LEN;
369
+ const ptr3 = passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
370
+ const len3 = WASM_VECTOR_LEN;
371
+ const ptr4 = passStringToWasm0(build_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
372
+ const len4 = WASM_VECTOR_LEN;
373
+ const ret = wasm.verify_token(ptr0, len0, ptr1, len1, ptr2, len2, line, column, ptr3, len3, ptr4, len4);
374
+ return ret !== 0;
375
+ };
694
376
 
695
- let cachedUint8ArrayMemory0 = null;
696
- function getUint8ArrayMemory0() {
697
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
698
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
377
+ /**
378
+ * WASM-exposed checksum verification.
379
+ *
380
+ * # Arguments
381
+ *
382
+ * * `map` - JavaScript object representing the mangle map
383
+ * * `expected_checksum` - The expected checksum string
384
+ *
385
+ * # Returns
386
+ *
387
+ * `true` if checksum matches, `false` otherwise
388
+ * @param {any} map
389
+ * @param {string} expected_checksum
390
+ * @returns {boolean}
391
+ */
392
+ module.exports.verify_mangle_checksum = function(map, expected_checksum) {
393
+ try {
394
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
395
+ const ptr0 = passStringToWasm0(expected_checksum, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
396
+ const len0 = WASM_VECTOR_LEN;
397
+ wasm.verify_mangle_checksum(retptr, addHeapObject(map), ptr0, len0);
398
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
399
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
400
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
401
+ if (r2) {
402
+ throw takeObject(r1);
403
+ }
404
+ return r0 !== 0;
405
+ } finally {
406
+ wasm.__wbindgen_add_to_stack_pointer(16);
699
407
  }
700
- return cachedUint8ArrayMemory0;
701
- }
408
+ };
409
+
410
+ /**
411
+ * Computes a deterministic SHA-256 checksum for a mangle map.
412
+ *
413
+ * The checksum is designed to be:
414
+ * 1. **Deterministic**: Same map always produces same checksum
415
+ * 2. **Collision-resistant**: Different maps produce different checksums
416
+ * 3. **Compact**: 16-character hex string (64 bits of SHA-256)
417
+ *
418
+ * # Algorithm
419
+ *
420
+ * 1. Sort all entries by original class name (determinism)
421
+ * 2. Create canonical string: "orig1:mangle1|orig2:mangle2|..."
422
+ * 3. Compute SHA-256 hash
423
+ * 4. Take first 16 hex characters (64 bits, ~1.8e19 possible values)
424
+ *
425
+ * # Arguments
426
+ *
427
+ * * `map` - The mangle map to checksum
428
+ *
429
+ * # Returns
430
+ *
431
+ * A 16-character hex string checksum
432
+ *
433
+ * # Performance
434
+ *
435
+ * - Time complexity: O(n log n) for sorting + O(n) for hashing
436
+ * - Space complexity: O(n) for canonical string
437
+ * - Typical runtime: ~10-50µs for 1000 entries (10-15x faster than JS)
438
+ *
439
+ * # Security
440
+ *
441
+ * While we only use 64 bits of SHA-256, this provides sufficient collision
442
+ * resistance for our use case (detecting accidental mismatches, not
443
+ * cryptographic attacks). Birthday paradox gives us ~4 billion hashes
444
+ * before 50% collision probability.
445
+ *
446
+ * # Examples
447
+ *
448
+ * ```ignore
449
+ * // This function is wasm_bindgen — call from JS, not Rust directly.
450
+ * // Use compute_checksum_internal() for pure-Rust usage.
451
+ * let checksum = compute_mangle_checksum(js_map);
452
+ * ```
453
+ * @param {any} map
454
+ * @returns {string}
455
+ */
456
+ module.exports.compute_mangle_checksum = function(map) {
457
+ let deferred2_0;
458
+ let deferred2_1;
459
+ try {
460
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
461
+ wasm.compute_mangle_checksum(retptr, addHeapObject(map));
462
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
463
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
464
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
465
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
466
+ var ptr1 = r0;
467
+ var len1 = r1;
468
+ if (r3) {
469
+ ptr1 = 0; len1 = 0;
470
+ throw takeObject(r2);
471
+ }
472
+ deferred2_0 = ptr1;
473
+ deferred2_1 = len1;
474
+ return getStringFromWasm0(ptr1, len1);
475
+ } finally {
476
+ wasm.__wbindgen_add_to_stack_pointer(16);
477
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
478
+ }
479
+ };
480
+
481
+ /**
482
+ * Encodes an index to a reversed tier-based Base62 string.
483
+ *
484
+ * # Arguments
485
+ *
486
+ * * `index` - The zero-based index to encode
487
+ *
488
+ * # Returns
489
+ *
490
+ * A Base62 encoded string following tier-based rules with reversed sequence
491
+ *
492
+ * # Performance
493
+ *
494
+ * - Time complexity: O(log n)
495
+ * - Space complexity: O(log n)
496
+ * - Average: ~5ns per encoding (measured on x86_64)
497
+ *
498
+ * # Examples
499
+ *
500
+ * ```
501
+ * use csszyx_core::encoder::encode;
502
+ *
503
+ * // Tier 1: Single letters (reversed)
504
+ * assert_eq!(encode(0), "z");
505
+ * assert_eq!(encode(25), "a");
506
+ * assert_eq!(encode(26), "Z");
507
+ * assert_eq!(encode(51), "A");
508
+ *
509
+ * // Tier 2: Letter + digit (both reversed)
510
+ * assert_eq!(encode(52), "z9");
511
+ * assert_eq!(encode(53), "z8");
512
+ * assert_eq!(encode(571), "A0");
513
+ *
514
+ * // Tier 3: Two letters (both reversed)
515
+ * assert_eq!(encode(572), "zz");
516
+ * assert_eq!(encode(573), "zy");
517
+ * ```
518
+ * @param {number} index
519
+ * @returns {string}
520
+ */
521
+ module.exports.encode = function(index) {
522
+ let deferred1_0;
523
+ let deferred1_1;
524
+ try {
525
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
526
+ wasm.encode(retptr, index);
527
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
528
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
529
+ deferred1_0 = r0;
530
+ deferred1_1 = r1;
531
+ return getStringFromWasm0(r0, r1);
532
+ } finally {
533
+ wasm.__wbindgen_add_to_stack_pointer(16);
534
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
535
+ }
536
+ };
702
537
 
703
538
  function handleError(f, args) {
704
539
  try {
705
540
  return f.apply(this, args);
706
541
  } catch (e) {
707
- const idx = addToExternrefTable0(e);
708
- wasm.__wbindgen_exn_store(idx);
542
+ wasm.__wbindgen_exn_store(addHeapObject(e));
709
543
  }
710
544
  }
711
545
 
712
- function isLikeNone(x) {
713
- return x === undefined || x === null;
714
- }
546
+ const WasmCollisionDetectorFinalization = (typeof FinalizationRegistry === 'undefined')
547
+ ? { register: () => {}, unregister: () => {} }
548
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmcollisiondetector_free(ptr >>> 0, 1));
549
+ /**
550
+ * WASM bindings for JavaScript interop
551
+ */
552
+ class WasmCollisionDetector {
715
553
 
716
- function passStringToWasm0(arg, malloc, realloc) {
717
- if (realloc === undefined) {
718
- const buf = cachedTextEncoder.encode(arg);
719
- const ptr = malloc(buf.length, 1) >>> 0;
720
- getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
721
- WASM_VECTOR_LEN = buf.length;
554
+ __destroy_into_raw() {
555
+ const ptr = this.__wbg_ptr;
556
+ this.__wbg_ptr = 0;
557
+ WasmCollisionDetectorFinalization.unregister(this);
722
558
  return ptr;
723
559
  }
724
560
 
725
- let len = arg.length;
726
- let ptr = malloc(len, 1) >>> 0;
727
-
728
- const mem = getUint8ArrayMemory0();
729
-
730
- let offset = 0;
731
-
732
- for (; offset < len; offset++) {
733
- const code = arg.charCodeAt(offset);
734
- if (code > 0x7F) break;
735
- mem[ptr + offset] = code;
561
+ free() {
562
+ const ptr = this.__destroy_into_raw();
563
+ wasm.__wbg_wasmcollisiondetector_free(ptr, 0);
736
564
  }
737
- if (offset !== len) {
738
- if (offset !== 0) {
739
- arg = arg.slice(offset);
565
+ /**
566
+ * Checks if any collision occurred (WASM binding).
567
+ *
568
+ * # Returns
569
+ *
570
+ * `true` if collision detected
571
+ * @returns {boolean}
572
+ */
573
+ has_collision() {
574
+ const ret = wasm.wasmcollisiondetector_has_collision(this.__wbg_ptr);
575
+ return ret !== 0;
576
+ }
577
+ /**
578
+ * Adds a CSS value and returns its variable name (WASM binding).
579
+ *
580
+ * # Arguments
581
+ *
582
+ * * `value` - CSS value to hash
583
+ *
584
+ * # Returns
585
+ *
586
+ * Variable name (e.g., "--v-abc123" or "--v-abc123-def456")
587
+ * @param {string} value
588
+ * @returns {string}
589
+ */
590
+ add(value) {
591
+ let deferred2_0;
592
+ let deferred2_1;
593
+ try {
594
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
595
+ const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
596
+ const len0 = WASM_VECTOR_LEN;
597
+ wasm.wasmcollisiondetector_add(retptr, this.__wbg_ptr, ptr0, len0);
598
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
599
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
600
+ deferred2_0 = r0;
601
+ deferred2_1 = r1;
602
+ return getStringFromWasm0(r0, r1);
603
+ } finally {
604
+ wasm.__wbindgen_add_to_stack_pointer(16);
605
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
740
606
  }
741
- ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
742
- const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
743
- const ret = cachedTextEncoder.encodeInto(arg, view);
744
-
745
- offset += ret.written;
746
- ptr = realloc(ptr, len, offset, 1) >>> 0;
747
607
  }
748
-
749
- WASM_VECTOR_LEN = offset;
750
- return ptr;
751
- }
752
-
753
- function takeFromExternrefTable0(idx) {
754
- const value = wasm.__wbindgen_externrefs.get(idx);
755
- wasm.__externref_table_dealloc(idx);
756
- return value;
608
+ /**
609
+ * Creates a new collision detector (WASM binding).
610
+ */
611
+ constructor() {
612
+ const ret = wasm.wasmcollisiondetector_new();
613
+ this.__wbg_ptr = ret >>> 0;
614
+ WasmCollisionDetectorFinalization.register(this, this.__wbg_ptr, this);
615
+ return this;
616
+ }
617
+ /**
618
+ * Gets the total number of variables (WASM binding).
619
+ *
620
+ * # Returns
621
+ *
622
+ * Number of unique CSS values
623
+ * @returns {number}
624
+ */
625
+ count() {
626
+ const ret = wasm.wasmcollisiondetector_count(this.__wbg_ptr);
627
+ return ret >>> 0;
628
+ }
757
629
  }
630
+ module.exports.WasmCollisionDetector = WasmCollisionDetector;
631
+
632
+ module.exports.__wbindgen_object_drop_ref = function(arg0) {
633
+ takeObject(arg0);
634
+ };
635
+
636
+ module.exports.__wbindgen_error_new = function(arg0, arg1) {
637
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
638
+ return addHeapObject(ret);
639
+ };
640
+
641
+ module.exports.__wbindgen_boolean_get = function(arg0) {
642
+ const v = getObject(arg0);
643
+ const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2;
644
+ return ret;
645
+ };
646
+
647
+ module.exports.__wbindgen_is_bigint = function(arg0) {
648
+ const ret = typeof(getObject(arg0)) === 'bigint';
649
+ return ret;
650
+ };
651
+
652
+ module.exports.__wbindgen_number_get = function(arg0, arg1) {
653
+ const obj = getObject(arg1);
654
+ const ret = typeof(obj) === 'number' ? obj : undefined;
655
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
656
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
657
+ };
658
+
659
+ module.exports.__wbindgen_string_get = function(arg0, arg1) {
660
+ const obj = getObject(arg1);
661
+ const ret = typeof(obj) === 'string' ? obj : undefined;
662
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
663
+ var len1 = WASM_VECTOR_LEN;
664
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
665
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
666
+ };
667
+
668
+ module.exports.__wbindgen_is_object = function(arg0) {
669
+ const val = getObject(arg0);
670
+ const ret = typeof(val) === 'object' && val !== null;
671
+ return ret;
672
+ };
673
+
674
+ module.exports.__wbindgen_in = function(arg0, arg1) {
675
+ const ret = getObject(arg0) in getObject(arg1);
676
+ return ret;
677
+ };
678
+
679
+ module.exports.__wbindgen_bigint_from_i64 = function(arg0) {
680
+ const ret = arg0;
681
+ return addHeapObject(ret);
682
+ };
683
+
684
+ module.exports.__wbindgen_jsval_eq = function(arg0, arg1) {
685
+ const ret = getObject(arg0) === getObject(arg1);
686
+ return ret;
687
+ };
688
+
689
+ module.exports.__wbindgen_bigint_from_u64 = function(arg0) {
690
+ const ret = BigInt.asUintN(64, arg0);
691
+ return addHeapObject(ret);
692
+ };
693
+
694
+ module.exports.__wbindgen_string_new = function(arg0, arg1) {
695
+ const ret = getStringFromWasm0(arg0, arg1);
696
+ return addHeapObject(ret);
697
+ };
698
+
699
+ module.exports.__wbindgen_jsval_loose_eq = function(arg0, arg1) {
700
+ const ret = getObject(arg0) == getObject(arg1);
701
+ return ret;
702
+ };
703
+
704
+ module.exports.__wbg_String_b9412f8799faab3e = function(arg0, arg1) {
705
+ const ret = String(getObject(arg1));
706
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
707
+ const len1 = WASM_VECTOR_LEN;
708
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
709
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
710
+ };
711
+
712
+ module.exports.__wbg_call_1084a111329e68ce = function() { return handleError(function (arg0, arg1) {
713
+ const ret = getObject(arg0).call(getObject(arg1));
714
+ return addHeapObject(ret);
715
+ }, arguments) };
716
+
717
+ module.exports.__wbg_new_ea1883e1e5e86686 = function(arg0) {
718
+ const ret = new Uint8Array(getObject(arg0));
719
+ return addHeapObject(ret);
720
+ };
721
+
722
+ module.exports.__wbg_buffer_b7b08af79b0b0974 = function(arg0) {
723
+ const ret = getObject(arg0).buffer;
724
+ return addHeapObject(ret);
725
+ };
726
+
727
+ module.exports.__wbg_set_d1e79e2388520f18 = function(arg0, arg1, arg2) {
728
+ getObject(arg0).set(getObject(arg1), arg2 >>> 0);
729
+ };
730
+
731
+ module.exports.__wbg_length_8339fcf5d8ecd12e = function(arg0) {
732
+ const ret = getObject(arg0).length;
733
+ return ret;
734
+ };
735
+
736
+ module.exports.__wbg_done_bfda7aa8f252b39f = function(arg0) {
737
+ const ret = getObject(arg0).done;
738
+ return ret;
739
+ };
740
+
741
+ module.exports.__wbg_value_6d39332ab4788d86 = function(arg0) {
742
+ const ret = getObject(arg0).value;
743
+ return addHeapObject(ret);
744
+ };
745
+
746
+ module.exports.__wbg_instanceof_Map_763ce0e95960d55e = function(arg0) {
747
+ let result;
748
+ try {
749
+ result = getObject(arg0) instanceof Map;
750
+ } catch (_) {
751
+ result = false;
752
+ }
753
+ const ret = result;
754
+ return ret;
755
+ };
758
756
 
759
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
760
- cachedTextDecoder.decode();
761
- function decodeText(ptr, len) {
762
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
763
- }
757
+ module.exports.__wbg_instanceof_Uint8Array_247a91427532499e = function(arg0) {
758
+ let result;
759
+ try {
760
+ result = getObject(arg0) instanceof Uint8Array;
761
+ } catch (_) {
762
+ result = false;
763
+ }
764
+ const ret = result;
765
+ return ret;
766
+ };
764
767
 
765
- const cachedTextEncoder = new TextEncoder();
768
+ module.exports.__wbg_instanceof_ArrayBuffer_61dfc3198373c902 = function(arg0) {
769
+ let result;
770
+ try {
771
+ result = getObject(arg0) instanceof ArrayBuffer;
772
+ } catch (_) {
773
+ result = false;
774
+ }
775
+ const ret = result;
776
+ return ret;
777
+ };
778
+
779
+ module.exports.__wbg_get_3baa728f9d58d3f6 = function(arg0, arg1) {
780
+ const ret = getObject(arg0)[arg1 >>> 0];
781
+ return addHeapObject(ret);
782
+ };
783
+
784
+ module.exports.__wbg_length_ae22078168b726f5 = function(arg0) {
785
+ const ret = getObject(arg0).length;
786
+ return ret;
787
+ };
788
+
789
+ module.exports.__wbg_isArray_8364a5371e9737d8 = function(arg0) {
790
+ const ret = Array.isArray(getObject(arg0));
791
+ return ret;
792
+ };
793
+
794
+ module.exports.__wbg_isSafeInteger_7f1ed56200d90674 = function(arg0) {
795
+ const ret = Number.isSafeInteger(getObject(arg0));
796
+ return ret;
797
+ };
798
+
799
+ module.exports.__wbg_entries_7a0e06255456ebcd = function(arg0) {
800
+ const ret = Object.entries(getObject(arg0));
801
+ return addHeapObject(ret);
802
+ };
803
+
804
+ module.exports.__wbg_iterator_888179a48810a9fe = function() {
805
+ const ret = Symbol.iterator;
806
+ return addHeapObject(ret);
807
+ };
808
+
809
+ module.exports.__wbg_get_224d16597dbbfd96 = function() { return handleError(function (arg0, arg1) {
810
+ const ret = Reflect.get(getObject(arg0), getObject(arg1));
811
+ return addHeapObject(ret);
812
+ }, arguments) };
813
+
814
+ module.exports.__wbindgen_is_function = function(arg0) {
815
+ const ret = typeof(getObject(arg0)) === 'function';
816
+ return ret;
817
+ };
818
+
819
+ module.exports.__wbg_next_de3e9db4440638b2 = function(arg0) {
820
+ const ret = getObject(arg0).next;
821
+ return addHeapObject(ret);
822
+ };
823
+
824
+ module.exports.__wbg_next_f9cb570345655b9a = function() { return handleError(function (arg0) {
825
+ const ret = getObject(arg0).next();
826
+ return addHeapObject(ret);
827
+ }, arguments) };
828
+
829
+ module.exports.__wbindgen_bigint_get_as_i64 = function(arg0, arg1) {
830
+ const v = getObject(arg1);
831
+ const ret = typeof(v) === 'bigint' ? v : undefined;
832
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
833
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
834
+ };
835
+
836
+ module.exports.__wbindgen_memory = function() {
837
+ const ret = wasm.memory;
838
+ return addHeapObject(ret);
839
+ };
840
+
841
+ module.exports.__wbindgen_throw = function(arg0, arg1) {
842
+ throw new Error(getStringFromWasm0(arg0, arg1));
843
+ };
844
+
845
+ module.exports.__wbindgen_debug_string = function(arg0, arg1) {
846
+ const ret = debugString(getObject(arg1));
847
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
848
+ const len1 = WASM_VECTOR_LEN;
849
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
850
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
851
+ };
766
852
 
767
- if (!('encodeInto' in cachedTextEncoder)) {
768
- cachedTextEncoder.encodeInto = function (arg, view) {
769
- const buf = cachedTextEncoder.encode(arg);
770
- view.set(buf);
771
- return {
772
- read: arg.length,
773
- written: buf.length
774
- };
775
- };
776
- }
853
+ const path = require('path').join(__dirname, 'csszyx_core_bg.wasm');
854
+ const bytes = require('fs').readFileSync(path);
777
855
 
778
- let WASM_VECTOR_LEN = 0;
856
+ const wasmModule = new WebAssembly.Module(bytes);
857
+ const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
858
+ wasm = wasmInstance.exports;
859
+ module.exports.__wasm = wasm;
779
860
 
780
- const wasmPath = `${__dirname}/csszyx_core_bg.wasm`;
781
- const wasmBytes = require('fs').readFileSync(wasmPath);
782
- const wasmModule = new WebAssembly.Module(wasmBytes);
783
- const wasm = new WebAssembly.Instance(wasmModule, __wbg_get_imports()).exports;
784
861
  wasm.__wbindgen_start();
862
+