@adobe/design-data-wasm 0.4.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.
@@ -0,0 +1,981 @@
1
+ /* @ts-self-types="./design_data_wasm.d.ts" */
2
+
3
+ /**
4
+ * A loaded token dataset you can query, validate, resolve, and diff.
5
+ *
6
+ * ```js
7
+ * import init, { Dataset } from "@adobe/design-data-wasm";
8
+ * await init();
9
+ *
10
+ * // Use the canonical embedded Spectrum dataset:
11
+ * const ds = Dataset.embedded();
12
+ * const results = ds.query("property=color,colorScheme=dark");
13
+ *
14
+ * // Or load your own tokens:
15
+ * const tokens = await fetch("/tokens.json").then(r => r.json());
16
+ * const ds2 = Dataset.fromTokens(tokens);
17
+ * ```
18
+ */
19
+ export class Dataset {
20
+ static __wrap(ptr) {
21
+ const obj = Object.create(Dataset.prototype);
22
+ obj.__wbg_ptr = ptr;
23
+ DatasetFinalization.register(obj, obj.__wbg_ptr, obj);
24
+ return obj;
25
+ }
26
+ __destroy_into_raw() {
27
+ const ptr = this.__wbg_ptr;
28
+ this.__wbg_ptr = 0;
29
+ DatasetFinalization.unregister(this);
30
+ return ptr;
31
+ }
32
+ free() {
33
+ const ptr = this.__destroy_into_raw();
34
+ wasm.__wbg_dataset_free(ptr, 0);
35
+ }
36
+ /**
37
+ * Compute the semantic diff between this dataset and another.
38
+ *
39
+ * Returns a [`DiffResult`] with arrays of renamed, deprecated, reverted, added,
40
+ * deleted, and updated tokens.
41
+ *
42
+ * ```js
43
+ * const oldDs = Dataset.fromTokens(oldTokens);
44
+ * const newDs = Dataset.fromTokens(newTokens);
45
+ * const diff = oldDs.diff(newDs);
46
+ * console.log(`${diff.added.length} tokens added`);
47
+ * ```
48
+ * @param {Dataset} other
49
+ * @returns {DiffResult}
50
+ */
51
+ diff(other) {
52
+ _assertClass(other, Dataset);
53
+ const ret = wasm.dataset_diff(this.__wbg_ptr, other.__wbg_ptr);
54
+ if (ret[2]) {
55
+ throw takeFromExternrefTable0(ret[1]);
56
+ }
57
+ return takeFromExternrefTable0(ret[0]);
58
+ }
59
+ /**
60
+ * Open the canonical embedded Spectrum dataset from the prebuilt cache.
61
+ *
62
+ * The cache is opened once and reused; subsequent calls are cheap.
63
+ *
64
+ * Throws if the embedded cache was not generated (run `moon run sdk-wasm:cache-build`).
65
+ * @returns {Dataset}
66
+ */
67
+ static embedded() {
68
+ const ret = wasm.dataset_embedded();
69
+ if (ret[2]) {
70
+ throw takeFromExternrefTable0(ret[1]);
71
+ }
72
+ return Dataset.__wrap(ret[0]);
73
+ }
74
+ /**
75
+ * Build a dataset from an array of raw token JSON objects.
76
+ *
77
+ * Accepts the same format as the cascade token JSON files — an array of token
78
+ * objects each with a `name` object (e.g. `{ "name": { "property": "..." }, "value": ... }`).
79
+ *
80
+ * ```js
81
+ * const tokens = await fetch("/spectrum-tokens.json").then(r => r.json());
82
+ * const ds = Dataset.fromTokens(tokens);
83
+ * ```
84
+ * @param {any} tokens_json
85
+ * @returns {Dataset}
86
+ */
87
+ static fromTokens(tokens_json) {
88
+ const ret = wasm.dataset_fromTokens(tokens_json);
89
+ if (ret[2]) {
90
+ throw takeFromExternrefTable0(ret[1]);
91
+ }
92
+ return Dataset.__wrap(ret[0]);
93
+ }
94
+ /**
95
+ * Emit a structural overview of the dataset for agent session start.
96
+ *
97
+ * Returns a plain JS object with the same shape as `design-data primer --format json`:
98
+ * `{ specVersion, tokenCount, modeSets, components, taxonomyFields, manifest, provenance }`.
99
+ *
100
+ * For the embedded Spectrum dataset (`Dataset.embedded()`), `taxonomyFields` and
101
+ * `manifest` are baked into the prebuilt `.redb` blob by the `cache-build` task.
102
+ * For in-memory datasets (`Dataset.fromTokens()`), both are empty / null.
103
+ *
104
+ * `provenance.source` is:
105
+ * - `"embedded"` when created via `Dataset.embedded()` (includes `designDataVersion`)
106
+ * - `"in-memory"` when created via `Dataset.fromTokens()`
107
+ * @returns {any}
108
+ */
109
+ primer() {
110
+ const ret = wasm.dataset_primer(this.__wbg_ptr);
111
+ if (ret[2]) {
112
+ throw takeFromExternrefTable0(ret[1]);
113
+ }
114
+ return takeFromExternrefTable0(ret[0]);
115
+ }
116
+ /**
117
+ * Filter tokens using a query expression.
118
+ *
119
+ * **Syntax:** `key=value` pairs separated by `,` (AND) or `|` (OR).
120
+ * Use `!=` for negation and `*` as a wildcard suffix or prefix.
121
+ * Valid keys: `property`, `component`, `variant`, `state`, `colorScheme`,
122
+ * `scale`, `contrast`, `uuid`, `$schema`.
123
+ *
124
+ * ```js
125
+ * const results = ds.query("property=color,colorScheme=dark");
126
+ * const all = ds.query(""); // returns all tokens
127
+ * ```
128
+ * @param {string} filter_expr
129
+ * @returns {TokenResultArray}
130
+ */
131
+ query(filter_expr) {
132
+ const ptr0 = passStringToWasm0(filter_expr, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
133
+ const len0 = WASM_VECTOR_LEN;
134
+ const ret = wasm.dataset_query(this.__wbg_ptr, ptr0, len0);
135
+ if (ret[2]) {
136
+ throw takeFromExternrefTable0(ret[1]);
137
+ }
138
+ return takeFromExternrefTable0(ret[0]);
139
+ }
140
+ /**
141
+ * Resolve a token for a given property in a specific context.
142
+ *
143
+ * The `context` object maps mode-set names to their active mode values —
144
+ * e.g. `{ colorScheme: "dark", scale: "medium" }`.
145
+ *
146
+ * Returns the winning token record plus its specificity, or `undefined` if
147
+ * no token matches the property+context combination.
148
+ *
149
+ * ```js
150
+ * const result = ds.resolve("background", { colorScheme: "dark", scale: "medium" });
151
+ * if (result) console.log(result.token.raw.value);
152
+ * ```
153
+ * @param {string} property
154
+ * @param {ResolutionContext} context
155
+ * @returns {ResolveResult | undefined}
156
+ */
157
+ resolve(property, context) {
158
+ const ptr0 = passStringToWasm0(property, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
159
+ const len0 = WASM_VECTOR_LEN;
160
+ const ret = wasm.dataset_resolve(this.__wbg_ptr, ptr0, len0, context);
161
+ if (ret[2]) {
162
+ throw takeFromExternrefTable0(ret[1]);
163
+ }
164
+ return takeFromExternrefTable0(ret[0]);
165
+ }
166
+ /**
167
+ * Resolve a legacy token reference by slug in a given context, returning
168
+ * the terminal value and the full alias chain.
169
+ *
170
+ * Bridges the legacy *object-map* slug model used by `docs/s2-tokens-viewer`
171
+ * to the cascade dataset. The wasm `resolve()` method resolves by *property*
172
+ * name in a mode-set context; this method resolves by *legacy slug* and a flat
173
+ * context map matching name-object fields.
174
+ *
175
+ * Context keys mirror cascade name-object fields:
176
+ * - `{ colorScheme: "light" | "dark" | "wireframe" }`
177
+ * - `{ scale: "desktop" | "mobile" }`
178
+ *
179
+ * The candidate with the most matching context fields wins; tie-breaking is
180
+ * stable (secondary sort by uuid ascending). When an alias chain passes through
181
+ * a set-level UUID, the context-appropriate child is selected so that e.g.
182
+ * `{accent-color-900}` under `{ colorScheme: "dark" }` correctly resolves to
183
+ * the dark variant of `{blue-900}`.
184
+ *
185
+ * Dangling aliases (a `$ref` target absent from the embedded dataset) are
186
+ * handled gracefully: the walk stops and the partial chain is returned with
187
+ * `value: undefined`.
188
+ *
189
+ * ```js
190
+ * const r = ds.resolveReference("{accent-color-100}", { colorScheme: "light" });
191
+ * // r.chain → ["{accent-color-100}", "{blue-100}", "rgb(245, 249, 255)"]
192
+ * // r.value → "rgb(245, 249, 255)"
193
+ * ```
194
+ * @param {string} token_ref
195
+ * @param {ResolutionContext} context
196
+ * @returns {ReferenceChainResult | undefined}
197
+ */
198
+ resolveReference(token_ref, context) {
199
+ const ptr0 = passStringToWasm0(token_ref, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
200
+ const len0 = WASM_VECTOR_LEN;
201
+ const ret = wasm.dataset_resolveReference(this.__wbg_ptr, ptr0, len0, context);
202
+ if (ret[2]) {
203
+ throw takeFromExternrefTable0(ret[1]);
204
+ }
205
+ return takeFromExternrefTable0(ret[0]);
206
+ }
207
+ /**
208
+ * Rank existing tokens by similarity to a natural-language `intent` string.
209
+ *
210
+ * Uses Jaccard similarity over the bag-of-words formed from each token's
211
+ * key segments, name-object field values, and description text. Optionally
212
+ * filter to tokens matching a specific `propertyHint` (e.g. `"color"`).
213
+ *
214
+ * ```js
215
+ * const results = ds.suggest("primary button background", undefined, 5);
216
+ * ```
217
+ * @param {string} intent
218
+ * @param {string | null | undefined} property_hint
219
+ * @param {number} limit
220
+ * @returns {SuggestResultArray}
221
+ */
222
+ suggest(intent, property_hint, limit) {
223
+ const ptr0 = passStringToWasm0(intent, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
224
+ const len0 = WASM_VECTOR_LEN;
225
+ var ptr1 = isLikeNone(property_hint) ? 0 : passStringToWasm0(property_hint, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
226
+ var len1 = WASM_VECTOR_LEN;
227
+ const ret = wasm.dataset_suggest(this.__wbg_ptr, ptr0, len0, ptr1, len1, limit);
228
+ if (ret[2]) {
229
+ throw takeFromExternrefTable0(ret[1]);
230
+ }
231
+ return takeFromExternrefTable0(ret[0]);
232
+ }
233
+ /**
234
+ * Return the number of tokens in the dataset.
235
+ * @returns {number}
236
+ */
237
+ tokenCount() {
238
+ const ret = wasm.dataset_tokenCount(this.__wbg_ptr);
239
+ return ret >>> 0;
240
+ }
241
+ /**
242
+ * Run relational validation rules over the dataset.
243
+ *
244
+ * Returns a [`ValidationResult`] with `valid`, `errors`, and `warnings`.
245
+ * This runs the same rules as `design-data validate` but without structural
246
+ * (JSON Schema) checks — those require filesystem access unavailable in wasm.
247
+ *
248
+ * ```js
249
+ * const result = ds.validate();
250
+ * if (!result.valid) console.error(result.errors);
251
+ * ```
252
+ * @returns {ValidationResult}
253
+ */
254
+ validate() {
255
+ const ret = wasm.dataset_validate(this.__wbg_ptr);
256
+ return ret;
257
+ }
258
+ }
259
+ if (Symbol.dispose) Dataset.prototype[Symbol.dispose] = Dataset.prototype.free;
260
+
261
+ /**
262
+ * Find a registry entry by its ID or one of its aliases.
263
+ *
264
+ * Returns `undefined` if not found.
265
+ * Equivalent to `@adobe/design-system-registry`'s `findValue(registry, searchTerm)`.
266
+ * @param {any} registry
267
+ * @param {string} search_term
268
+ * @returns {any}
269
+ */
270
+ export function findValue(registry, search_term) {
271
+ const ptr0 = passStringToWasm0(search_term, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
272
+ const len0 = WASM_VECTOR_LEN;
273
+ const ret = wasm.findValue(registry, ptr0, len0);
274
+ if (ret[2]) {
275
+ throw takeFromExternrefTable0(ret[1]);
276
+ }
277
+ return takeFromExternrefTable0(ret[0]);
278
+ }
279
+
280
+ /**
281
+ * Return all non-deprecated value entries.
282
+ *
283
+ * Equivalent to `@adobe/design-system-registry`'s `getActiveValues(registry)`.
284
+ * @param {any} registry
285
+ * @returns {any}
286
+ */
287
+ export function getActiveValues(registry) {
288
+ const ret = wasm.getActiveValues(registry);
289
+ if (ret[2]) {
290
+ throw takeFromExternrefTable0(ret[1]);
291
+ }
292
+ return takeFromExternrefTable0(ret[0]);
293
+ }
294
+
295
+ /**
296
+ * Return the list of advisory field names (fields whose values are informational,
297
+ * not normative — e.g. `"variant"`, `"state"`).
298
+ * @returns {string[]}
299
+ */
300
+ export function getAdvisoryFields() {
301
+ const ret = wasm.getAdvisoryFields();
302
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
303
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
304
+ return v1;
305
+ }
306
+
307
+ /**
308
+ * Return the default value entry, or `undefined` if none is marked as default.
309
+ *
310
+ * Equivalent to `@adobe/design-system-registry`'s `getDefault(registry)`.
311
+ * @param {any} registry
312
+ * @returns {any}
313
+ */
314
+ export function getDefault(registry) {
315
+ const ret = wasm.getDefault(registry);
316
+ if (ret[2]) {
317
+ throw takeFromExternrefTable0(ret[1]);
318
+ }
319
+ return takeFromExternrefTable0(ret[0]);
320
+ }
321
+
322
+ /**
323
+ * Return all IDs (and aliases) registered for a given field name.
324
+ *
325
+ * `fieldName` should be the canonical field key as used in token `name` objects —
326
+ * e.g. `"property"`, `"component"`, `"variant"`, `"state"`.
327
+ *
328
+ * Returns `undefined` if the field is not in the embedded registry.
329
+ * @param {string} field_name
330
+ * @returns {string[] | undefined}
331
+ */
332
+ export function getFieldValues(field_name) {
333
+ const ptr0 = passStringToWasm0(field_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
334
+ const len0 = WASM_VECTOR_LEN;
335
+ const ret = wasm.getFieldValues(ptr0, len0);
336
+ let v2;
337
+ if (ret[0] !== 0) {
338
+ v2 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
339
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
340
+ }
341
+ return v2;
342
+ }
343
+
344
+ /**
345
+ * Return the list of field names that can be used as filter keys in query
346
+ * expressions (e.g. `"property"`, `"component"`, `"$schema"`).
347
+ *
348
+ * This is the canonical set maintained in `design_data_core::query::ALLOWED_KEYS`,
349
+ * exposed here so callers do not need to hard-code it.
350
+ * @returns {string[]}
351
+ */
352
+ export function getIndexedFields() {
353
+ const ret = wasm.getIndexedFields();
354
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
355
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
356
+ return v1;
357
+ }
358
+
359
+ /**
360
+ * Return all value IDs from a registry vocabulary object.
361
+ *
362
+ * Equivalent to `@adobe/design-system-registry`'s `getValues(registry)`.
363
+ * @param {any} registry
364
+ * @returns {string[]}
365
+ */
366
+ export function getValues(registry) {
367
+ const ret = wasm.getValues(registry);
368
+ if (ret[3]) {
369
+ throw takeFromExternrefTable0(ret[2]);
370
+ }
371
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
372
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
373
+ return v1;
374
+ }
375
+
376
+ /**
377
+ * Return `true` if `value` (an ID or alias) is registered for `fieldName`.
378
+ * @param {string} field_name
379
+ * @param {string} value
380
+ * @returns {boolean}
381
+ */
382
+ export function hasFieldValue(field_name, value) {
383
+ const ptr0 = passStringToWasm0(field_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
384
+ const len0 = WASM_VECTOR_LEN;
385
+ const ptr1 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
386
+ const len1 = WASM_VECTOR_LEN;
387
+ const ret = wasm.hasFieldValue(ptr0, len0, ptr1, len1);
388
+ return ret !== 0;
389
+ }
390
+
391
+ /**
392
+ * Return `true` if `searchTerm` matches any value ID or alias in the registry.
393
+ *
394
+ * Equivalent to `@adobe/design-system-registry`'s `hasValue(registry, searchTerm)`.
395
+ * @param {any} registry
396
+ * @param {string} search_term
397
+ * @returns {boolean}
398
+ */
399
+ export function hasValue(registry, search_term) {
400
+ const ptr0 = passStringToWasm0(search_term, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
401
+ const len0 = WASM_VECTOR_LEN;
402
+ const ret = wasm.hasValue(registry, ptr0, len0);
403
+ if (ret[2]) {
404
+ throw takeFromExternrefTable0(ret[1]);
405
+ }
406
+ return ret[0] !== 0;
407
+ }
408
+
409
+ /**
410
+ * Initialise the panic hook so that Rust panics are forwarded to the browser console.
411
+ *
412
+ * Call this once when the wasm module loads. Idempotent.
413
+ */
414
+ export function init() {
415
+ wasm.init();
416
+ }
417
+ function __wbg_get_imports() {
418
+ const import0 = {
419
+ __proto__: null,
420
+ __wbg_Error_ef53bc310eb298a0: function(arg0, arg1) {
421
+ const ret = Error(getStringFromWasm0(arg0, arg1));
422
+ return ret;
423
+ },
424
+ __wbg_Number_6b506e6536831eaa: function(arg0) {
425
+ const ret = Number(arg0);
426
+ return ret;
427
+ },
428
+ __wbg_String_8564e559799eccda: function(arg0, arg1) {
429
+ const ret = String(arg1);
430
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
431
+ const len1 = WASM_VECTOR_LEN;
432
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
433
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
434
+ },
435
+ __wbg___wbindgen_bigint_get_as_i64_38130e98eecd467d: function(arg0, arg1) {
436
+ const v = arg1;
437
+ const ret = typeof(v) === 'bigint' ? v : undefined;
438
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
439
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
440
+ },
441
+ __wbg___wbindgen_boolean_get_1a45e2c38d4d41b9: function(arg0) {
442
+ const v = arg0;
443
+ const ret = typeof(v) === 'boolean' ? v : undefined;
444
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
445
+ },
446
+ __wbg___wbindgen_debug_string_0accd80f45e5faa2: function(arg0, arg1) {
447
+ const ret = debugString(arg1);
448
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
449
+ const len1 = WASM_VECTOR_LEN;
450
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
451
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
452
+ },
453
+ __wbg___wbindgen_in_70a403a56e771704: function(arg0, arg1) {
454
+ const ret = arg0 in arg1;
455
+ return ret;
456
+ },
457
+ __wbg___wbindgen_is_bigint_6ffd6468a9bc44b9: function(arg0) {
458
+ const ret = typeof(arg0) === 'bigint';
459
+ return ret;
460
+ },
461
+ __wbg___wbindgen_is_function_754e9f305ff6029e: function(arg0) {
462
+ const ret = typeof(arg0) === 'function';
463
+ return ret;
464
+ },
465
+ __wbg___wbindgen_is_object_56732c2bc353f41d: function(arg0) {
466
+ const val = arg0;
467
+ const ret = typeof(val) === 'object' && val !== null;
468
+ return ret;
469
+ },
470
+ __wbg___wbindgen_is_string_c236cabd84a4d769: function(arg0) {
471
+ const ret = typeof(arg0) === 'string';
472
+ return ret;
473
+ },
474
+ __wbg___wbindgen_is_undefined_67b456be8673d3d7: function(arg0) {
475
+ const ret = arg0 === undefined;
476
+ return ret;
477
+ },
478
+ __wbg___wbindgen_jsval_eq_1068e624fa87f6ab: function(arg0, arg1) {
479
+ const ret = arg0 === arg1;
480
+ return ret;
481
+ },
482
+ __wbg___wbindgen_jsval_loose_eq_2c56564c75129511: function(arg0, arg1) {
483
+ const ret = arg0 == arg1;
484
+ return ret;
485
+ },
486
+ __wbg___wbindgen_number_get_9bb1761122181af2: function(arg0, arg1) {
487
+ const obj = arg1;
488
+ const ret = typeof(obj) === 'number' ? obj : undefined;
489
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
490
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
491
+ },
492
+ __wbg___wbindgen_string_get_72bdf95d3ae505b1: function(arg0, arg1) {
493
+ const obj = arg1;
494
+ const ret = typeof(obj) === 'string' ? obj : undefined;
495
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
496
+ var len1 = WASM_VECTOR_LEN;
497
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
498
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
499
+ },
500
+ __wbg___wbindgen_throw_1506f2235d1bdba0: function(arg0, arg1) {
501
+ throw new Error(getStringFromWasm0(arg0, arg1));
502
+ },
503
+ __wbg_call_8a89609d89f6608a: function() { return handleError(function (arg0, arg1) {
504
+ const ret = arg0.call(arg1);
505
+ return ret;
506
+ }, arguments); },
507
+ __wbg_done_60cf307fcc680536: function(arg0) {
508
+ const ret = arg0.done;
509
+ return ret;
510
+ },
511
+ __wbg_entries_04b37a02507f1713: function(arg0) {
512
+ const ret = Object.entries(arg0);
513
+ return ret;
514
+ },
515
+ __wbg_error_a6fa202b58aa1cd3: function(arg0, arg1) {
516
+ let deferred0_0;
517
+ let deferred0_1;
518
+ try {
519
+ deferred0_0 = arg0;
520
+ deferred0_1 = arg1;
521
+ console.error(getStringFromWasm0(arg0, arg1));
522
+ } finally {
523
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
524
+ }
525
+ },
526
+ __wbg_getRandomValues_3f44b700395062e5: function() { return handleError(function (arg0, arg1) {
527
+ globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
528
+ }, arguments); },
529
+ __wbg_get_1f8f054ddbaa7db2: function() { return handleError(function (arg0, arg1) {
530
+ const ret = Reflect.get(arg0, arg1);
531
+ return ret;
532
+ }, arguments); },
533
+ __wbg_get_2b48c7d0d006a781: function(arg0, arg1) {
534
+ const ret = arg0[arg1 >>> 0];
535
+ return ret;
536
+ },
537
+ __wbg_get_unchecked_33f6e5c9e2f2d6b2: function(arg0, arg1) {
538
+ const ret = arg0[arg1 >>> 0];
539
+ return ret;
540
+ },
541
+ __wbg_get_with_ref_key_6412cf3094599694: function(arg0, arg1) {
542
+ const ret = arg0[arg1];
543
+ return ret;
544
+ },
545
+ __wbg_instanceof_ArrayBuffer_8f49811467741499: function(arg0) {
546
+ let result;
547
+ try {
548
+ result = arg0 instanceof ArrayBuffer;
549
+ } catch (_) {
550
+ result = false;
551
+ }
552
+ const ret = result;
553
+ return ret;
554
+ },
555
+ __wbg_instanceof_Map_9fc06d9a951bcee6: function(arg0) {
556
+ let result;
557
+ try {
558
+ result = arg0 instanceof Map;
559
+ } catch (_) {
560
+ result = false;
561
+ }
562
+ const ret = result;
563
+ return ret;
564
+ },
565
+ __wbg_instanceof_Uint8Array_86f30649f63ef9c2: function(arg0) {
566
+ let result;
567
+ try {
568
+ result = arg0 instanceof Uint8Array;
569
+ } catch (_) {
570
+ result = false;
571
+ }
572
+ const ret = result;
573
+ return ret;
574
+ },
575
+ __wbg_isArray_67c2c9c4313f4448: function(arg0) {
576
+ const ret = Array.isArray(arg0);
577
+ return ret;
578
+ },
579
+ __wbg_isSafeInteger_66acec27e09e99a7: function(arg0) {
580
+ const ret = Number.isSafeInteger(arg0);
581
+ return ret;
582
+ },
583
+ __wbg_iterator_8732428d309e270e: function() {
584
+ const ret = Symbol.iterator;
585
+ return ret;
586
+ },
587
+ __wbg_length_4a591ecaa01354d9: function(arg0) {
588
+ const ret = arg0.length;
589
+ return ret;
590
+ },
591
+ __wbg_length_66f1a4b2e9026940: function(arg0) {
592
+ const ret = arg0.length;
593
+ return ret;
594
+ },
595
+ __wbg_new_227d7c05414eb861: function() {
596
+ const ret = new Error();
597
+ return ret;
598
+ },
599
+ __wbg_new_50bb5ebeecef71a8: function(arg0, arg1) {
600
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
601
+ return ret;
602
+ },
603
+ __wbg_new_578aeef4b6b94378: function(arg0) {
604
+ const ret = new Uint8Array(arg0);
605
+ return ret;
606
+ },
607
+ __wbg_new_622fc80556be2e26: function() {
608
+ const ret = new Map();
609
+ return ret;
610
+ },
611
+ __wbg_new_ce1ab61c1c2b300d: function() {
612
+ const ret = new Object();
613
+ return ret;
614
+ },
615
+ __wbg_new_d90091b82fdf5b91: function() {
616
+ const ret = new Array();
617
+ return ret;
618
+ },
619
+ __wbg_next_9e03acdf51c4960d: function(arg0) {
620
+ const ret = arg0.next;
621
+ return ret;
622
+ },
623
+ __wbg_next_eb8ca7351fa27906: function() { return handleError(function (arg0) {
624
+ const ret = arg0.next();
625
+ return ret;
626
+ }, arguments); },
627
+ __wbg_prototypesetcall_3249fc62a0fafa30: function(arg0, arg1, arg2) {
628
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
629
+ },
630
+ __wbg_set_52b1e1eb5bed906a: function(arg0, arg1, arg2) {
631
+ const ret = arg0.set(arg1, arg2);
632
+ return ret;
633
+ },
634
+ __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
635
+ arg0[arg1] = arg2;
636
+ },
637
+ __wbg_set_dca99999bba88a9a: function(arg0, arg1, arg2) {
638
+ arg0[arg1 >>> 0] = arg2;
639
+ },
640
+ __wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {
641
+ const ret = arg1.stack;
642
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
643
+ const len1 = WASM_VECTOR_LEN;
644
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
645
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
646
+ },
647
+ __wbg_value_f3625092ee4b37f4: function(arg0) {
648
+ const ret = arg0.value;
649
+ return ret;
650
+ },
651
+ __wbindgen_cast_0000000000000001: function(arg0) {
652
+ // Cast intrinsic for `F64 -> Externref`.
653
+ const ret = arg0;
654
+ return ret;
655
+ },
656
+ __wbindgen_cast_0000000000000002: function(arg0) {
657
+ // Cast intrinsic for `I64 -> Externref`.
658
+ const ret = arg0;
659
+ return ret;
660
+ },
661
+ __wbindgen_cast_0000000000000003: function(arg0, arg1) {
662
+ // Cast intrinsic for `Ref(String) -> Externref`.
663
+ const ret = getStringFromWasm0(arg0, arg1);
664
+ return ret;
665
+ },
666
+ __wbindgen_cast_0000000000000004: function(arg0) {
667
+ // Cast intrinsic for `U64 -> Externref`.
668
+ const ret = BigInt.asUintN(64, arg0);
669
+ return ret;
670
+ },
671
+ __wbindgen_init_externref_table: function() {
672
+ const table = wasm.__wbindgen_externrefs;
673
+ const offset = table.grow(4);
674
+ table.set(0, undefined);
675
+ table.set(offset + 0, undefined);
676
+ table.set(offset + 1, null);
677
+ table.set(offset + 2, true);
678
+ table.set(offset + 3, false);
679
+ },
680
+ };
681
+ return {
682
+ __proto__: null,
683
+ "./design_data_wasm_bg.js": import0,
684
+ };
685
+ }
686
+
687
+ const DatasetFinalization = (typeof FinalizationRegistry === 'undefined')
688
+ ? { register: () => {}, unregister: () => {} }
689
+ : new FinalizationRegistry(ptr => wasm.__wbg_dataset_free(ptr, 1));
690
+
691
+ function addToExternrefTable0(obj) {
692
+ const idx = wasm.__externref_table_alloc();
693
+ wasm.__wbindgen_externrefs.set(idx, obj);
694
+ return idx;
695
+ }
696
+
697
+ function _assertClass(instance, klass) {
698
+ if (!(instance instanceof klass)) {
699
+ throw new Error(`expected instance of ${klass.name}`);
700
+ }
701
+ }
702
+
703
+ function debugString(val) {
704
+ // primitive types
705
+ const type = typeof val;
706
+ if (type == 'number' || type == 'boolean' || val == null) {
707
+ return `${val}`;
708
+ }
709
+ if (type == 'string') {
710
+ return `"${val}"`;
711
+ }
712
+ if (type == 'symbol') {
713
+ const description = val.description;
714
+ if (description == null) {
715
+ return 'Symbol';
716
+ } else {
717
+ return `Symbol(${description})`;
718
+ }
719
+ }
720
+ if (type == 'function') {
721
+ const name = val.name;
722
+ if (typeof name == 'string' && name.length > 0) {
723
+ return `Function(${name})`;
724
+ } else {
725
+ return 'Function';
726
+ }
727
+ }
728
+ // objects
729
+ if (Array.isArray(val)) {
730
+ const length = val.length;
731
+ let debug = '[';
732
+ if (length > 0) {
733
+ debug += debugString(val[0]);
734
+ }
735
+ for(let i = 1; i < length; i++) {
736
+ debug += ', ' + debugString(val[i]);
737
+ }
738
+ debug += ']';
739
+ return debug;
740
+ }
741
+ // Test for built-in
742
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
743
+ let className;
744
+ if (builtInMatches && builtInMatches.length > 1) {
745
+ className = builtInMatches[1];
746
+ } else {
747
+ // Failed to match the standard '[object ClassName]'
748
+ return toString.call(val);
749
+ }
750
+ if (className == 'Object') {
751
+ // we're a user defined class or Object
752
+ // JSON.stringify avoids problems with cycles, and is generally much
753
+ // easier than looping through ownProperties of `val`.
754
+ try {
755
+ return 'Object(' + JSON.stringify(val) + ')';
756
+ } catch (_) {
757
+ return 'Object';
758
+ }
759
+ }
760
+ // errors
761
+ if (val instanceof Error) {
762
+ return `${val.name}: ${val.message}\n${val.stack}`;
763
+ }
764
+ // TODO we could test for more things here, like `Set`s and `Map`s.
765
+ return className;
766
+ }
767
+
768
+ function getArrayJsValueFromWasm0(ptr, len) {
769
+ ptr = ptr >>> 0;
770
+ const mem = getDataViewMemory0();
771
+ const result = [];
772
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
773
+ result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
774
+ }
775
+ wasm.__externref_drop_slice(ptr, len);
776
+ return result;
777
+ }
778
+
779
+ function getArrayU8FromWasm0(ptr, len) {
780
+ ptr = ptr >>> 0;
781
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
782
+ }
783
+
784
+ let cachedDataViewMemory0 = null;
785
+ function getDataViewMemory0() {
786
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
787
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
788
+ }
789
+ return cachedDataViewMemory0;
790
+ }
791
+
792
+ function getStringFromWasm0(ptr, len) {
793
+ return decodeText(ptr >>> 0, len);
794
+ }
795
+
796
+ let cachedUint8ArrayMemory0 = null;
797
+ function getUint8ArrayMemory0() {
798
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
799
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
800
+ }
801
+ return cachedUint8ArrayMemory0;
802
+ }
803
+
804
+ function handleError(f, args) {
805
+ try {
806
+ return f.apply(this, args);
807
+ } catch (e) {
808
+ const idx = addToExternrefTable0(e);
809
+ wasm.__wbindgen_exn_store(idx);
810
+ }
811
+ }
812
+
813
+ function isLikeNone(x) {
814
+ return x === undefined || x === null;
815
+ }
816
+
817
+ function passStringToWasm0(arg, malloc, realloc) {
818
+ if (realloc === undefined) {
819
+ const buf = cachedTextEncoder.encode(arg);
820
+ const ptr = malloc(buf.length, 1) >>> 0;
821
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
822
+ WASM_VECTOR_LEN = buf.length;
823
+ return ptr;
824
+ }
825
+
826
+ let len = arg.length;
827
+ let ptr = malloc(len, 1) >>> 0;
828
+
829
+ const mem = getUint8ArrayMemory0();
830
+
831
+ let offset = 0;
832
+
833
+ for (; offset < len; offset++) {
834
+ const code = arg.charCodeAt(offset);
835
+ if (code > 0x7F) break;
836
+ mem[ptr + offset] = code;
837
+ }
838
+ if (offset !== len) {
839
+ if (offset !== 0) {
840
+ arg = arg.slice(offset);
841
+ }
842
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
843
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
844
+ const ret = cachedTextEncoder.encodeInto(arg, view);
845
+
846
+ offset += ret.written;
847
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
848
+ }
849
+
850
+ WASM_VECTOR_LEN = offset;
851
+ return ptr;
852
+ }
853
+
854
+ function takeFromExternrefTable0(idx) {
855
+ const value = wasm.__wbindgen_externrefs.get(idx);
856
+ wasm.__externref_table_dealloc(idx);
857
+ return value;
858
+ }
859
+
860
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
861
+ cachedTextDecoder.decode();
862
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
863
+ let numBytesDecoded = 0;
864
+ function decodeText(ptr, len) {
865
+ numBytesDecoded += len;
866
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
867
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
868
+ cachedTextDecoder.decode();
869
+ numBytesDecoded = len;
870
+ }
871
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
872
+ }
873
+
874
+ const cachedTextEncoder = new TextEncoder();
875
+
876
+ if (!('encodeInto' in cachedTextEncoder)) {
877
+ cachedTextEncoder.encodeInto = function (arg, view) {
878
+ const buf = cachedTextEncoder.encode(arg);
879
+ view.set(buf);
880
+ return {
881
+ read: arg.length,
882
+ written: buf.length
883
+ };
884
+ };
885
+ }
886
+
887
+ let WASM_VECTOR_LEN = 0;
888
+
889
+ let wasmModule, wasmInstance, wasm;
890
+ function __wbg_finalize_init(instance, module) {
891
+ wasmInstance = instance;
892
+ wasm = instance.exports;
893
+ wasmModule = module;
894
+ cachedDataViewMemory0 = null;
895
+ cachedUint8ArrayMemory0 = null;
896
+ wasm.__wbindgen_start();
897
+ return wasm;
898
+ }
899
+
900
+ async function __wbg_load(module, imports) {
901
+ if (typeof Response === 'function' && module instanceof Response) {
902
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
903
+ try {
904
+ return await WebAssembly.instantiateStreaming(module, imports);
905
+ } catch (e) {
906
+ const validResponse = module.ok && expectedResponseType(module.type);
907
+
908
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
909
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
910
+
911
+ } else { throw e; }
912
+ }
913
+ }
914
+
915
+ const bytes = await module.arrayBuffer();
916
+ return await WebAssembly.instantiate(bytes, imports);
917
+ } else {
918
+ const instance = await WebAssembly.instantiate(module, imports);
919
+
920
+ if (instance instanceof WebAssembly.Instance) {
921
+ return { instance, module };
922
+ } else {
923
+ return instance;
924
+ }
925
+ }
926
+
927
+ function expectedResponseType(type) {
928
+ switch (type) {
929
+ case 'basic': case 'cors': case 'default': return true;
930
+ }
931
+ return false;
932
+ }
933
+ }
934
+
935
+ function initSync(module) {
936
+ if (wasm !== undefined) return wasm;
937
+
938
+
939
+ if (module !== undefined) {
940
+ if (Object.getPrototypeOf(module) === Object.prototype) {
941
+ ({module} = module)
942
+ } else {
943
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
944
+ }
945
+ }
946
+
947
+ const imports = __wbg_get_imports();
948
+ if (!(module instanceof WebAssembly.Module)) {
949
+ module = new WebAssembly.Module(module);
950
+ }
951
+ const instance = new WebAssembly.Instance(module, imports);
952
+ return __wbg_finalize_init(instance, module);
953
+ }
954
+
955
+ async function __wbg_init(module_or_path) {
956
+ if (wasm !== undefined) return wasm;
957
+
958
+
959
+ if (module_or_path !== undefined) {
960
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
961
+ ({module_or_path} = module_or_path)
962
+ } else {
963
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
964
+ }
965
+ }
966
+
967
+ if (module_or_path === undefined) {
968
+ module_or_path = new URL('design_data_wasm_bg.wasm', import.meta.url);
969
+ }
970
+ const imports = __wbg_get_imports();
971
+
972
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
973
+ module_or_path = fetch(module_or_path);
974
+ }
975
+
976
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
977
+
978
+ return __wbg_finalize_init(instance, module);
979
+ }
980
+
981
+ export { initSync, __wbg_init as default };