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