deepwoken 0.1.4 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/generated.ts ADDED
@@ -0,0 +1,7 @@
1
+ // AUTO-GENERATED by build.rs do not edit thanks
2
+
3
+ export type Stat = "Strength" | "Fortitude" | "Agility" | "Intelligence" | "Willpower" | "Charisma" | "Heavy" | "Medium" | "Light" | "Frostdraw" | "Flamecharm" | "Thundercall" | "Galebreathe" | "Shadowcast" | "Ironsing" | "Bloodrend";
4
+
5
+ export const CORE_STATS: Stat[] = ["Strength", "Fortitude", "Agility", "Intelligence", "Willpower", "Charisma"];
6
+ export const WEAPON_STATS: Stat[] = ["Heavy", "Medium", "Light"];
7
+ export const ATTUNEMENT_STATS: Stat[] = ["Flamecharm", "Frostdraw", "Thundercall", "Galebreathe", "Shadowcast", "Ironsing", "Bloodrend"];
package/index.ts CHANGED
@@ -1,22 +1,23 @@
1
- export type { Talent, Weapon, Mantra, Outfit, Aspect, Stat } from './types.js';
1
+ export { ATTUNEMENT_STATS, CORE_STATS, WEAPON_STATS } from './types.js';
2
+ export type { Aspect, Mantra, Outfit, Stat, Talent, Weapon } from './types.js';
2
3
 
3
- import wasmInit, { DeepData as WasmDeepData } from './pkg/deepwoken.js';
4
- import type { Talent, Weapon, Mantra, Outfit, Aspect, Stat } from './types.js';
4
+ import type { Aspect, Mantra, Outfit, Stat, Talent, Weapon } from './types.js';
5
+
6
+ // dynamically import wasm bc the server will try to load wasm regardless man
7
+ let WasmDeepData: any;
8
+ let WasmStatMap: any;
5
9
 
6
10
  if (typeof window !== 'undefined') {
7
- await wasmInit();
11
+ const wasm = await import('./pkg/deepwoken.js');
12
+ await wasm.default();
13
+ WasmDeepData = wasm.DeepData;
14
+ WasmStatMap = wasm.StatMap;
8
15
  }
9
16
 
10
- import { coreStats, weaponStats, attunementStats } from './pkg/deepwoken.js';
11
-
12
- export const CORE_STATS: Stat[] = coreStats();
13
- export const WEAPON_STATS: Stat[] = weaponStats();
14
- export const ATTUNEMENT_STATS: Stat[] = attunementStats();
15
-
16
17
  export class DeepData {
17
- private _wasm: WasmDeepData;
18
+ private _wasm: any;
18
19
 
19
- private constructor(wasm: WasmDeepData) {
20
+ private constructor(wasm: any) {
20
21
  this._wasm = wasm;
21
22
  }
22
23
 
@@ -44,3 +45,16 @@ export class DeepData {
44
45
  outfits(): Outfit[] { return this._wasm.outfits(); }
45
46
  aspects(): Aspect[] { return this._wasm.aspects(); }
46
47
  }
48
+
49
+ export class StatMap {
50
+ private _wasm: any;
51
+
52
+ constructor(map: Partial<Record<Stat, number>> = {}) {
53
+ this._wasm = new WasmStatMap(map);
54
+ }
55
+
56
+ /* The total build cost, accounting for multi-attunement shenanigans */
57
+ cost(): number { return this._wasm.cost(); }
58
+ get(stat: Stat): number { return this._wasm.get(stat); }
59
+ set(stat: Stat, value: number) { this._wasm.set(stat, value); }
60
+ }
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "deepwoken",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "type": "module",
5
5
  "main": "index.ts",
6
6
  "types": "index.ts",
7
7
  "files": [
8
8
  "index.ts",
9
9
  "types.ts",
10
+ "generated.ts",
10
11
  "pkg/deepwoken_bg.wasm",
11
12
  "pkg/deepwoken.js",
12
13
  "pkg/deepwoken.d.ts"
@@ -29,19 +29,21 @@ export class DeepData {
29
29
  weapons(): any;
30
30
  }
31
31
 
32
- export function attunementStats(): any;
33
-
34
- export function coreStats(): any;
35
-
36
- export function weaponStats(): any;
32
+ export class StatMap {
33
+ free(): void;
34
+ [Symbol.dispose](): void;
35
+ cost(): number;
36
+ get(stat: string): number;
37
+ constructor(map: any);
38
+ set(stat: string, value: number): void;
39
+ }
37
40
 
38
41
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
39
42
 
40
43
  export interface InitOutput {
41
44
  readonly memory: WebAssembly.Memory;
42
45
  readonly __wbg_deepdata_free: (a: number, b: number) => void;
43
- readonly attunementStats: () => [number, number, number];
44
- readonly coreStats: () => [number, number, number];
46
+ readonly __wbg_statmap_free: (a: number, b: number) => void;
45
47
  readonly deepdata_aspects: (a: number) => [number, number, number];
46
48
  readonly deepdata_fetchLatest: () => any;
47
49
  readonly deepdata_fetchLatestFrom: (a: number, b: number, c: number, d: number) => any;
@@ -55,7 +57,10 @@ export interface InitOutput {
55
57
  readonly deepdata_outfits: (a: number) => [number, number, number];
56
58
  readonly deepdata_talents: (a: number) => [number, number, number];
57
59
  readonly deepdata_weapons: (a: number) => [number, number, number];
58
- readonly weaponStats: () => [number, number, number];
60
+ readonly statmap_cost: (a: number) => number;
61
+ readonly statmap_get: (a: number, b: number, c: number) => [number, number, number];
62
+ readonly statmap_new: (a: any) => [number, number, number];
63
+ readonly statmap_set: (a: number, b: number, c: number, d: number) => [number, number];
59
64
  readonly wasm_bindgen__closure__destroy__hf10da1d08ed9fc18: (a: number, b: number) => void;
60
65
  readonly wasm_bindgen__closure__destroy__he46194fcf4899997: (a: number, b: number) => void;
61
66
  readonly wasm_bindgen__convert__closures_____invoke__h71bc5879fd2abe15: (a: number, b: number, c: any) => [number, number];
package/pkg/deepwoken.js CHANGED
@@ -172,38 +172,63 @@ export class DeepData {
172
172
  }
173
173
  if (Symbol.dispose) DeepData.prototype[Symbol.dispose] = DeepData.prototype.free;
174
174
 
175
- /**
176
- * @returns {any}
177
- */
178
- export function attunementStats() {
179
- const ret = wasm.attunementStats();
180
- if (ret[2]) {
181
- throw takeFromExternrefTable0(ret[1]);
182
- }
183
- return takeFromExternrefTable0(ret[0]);
184
- }
185
-
186
- /**
187
- * @returns {any}
188
- */
189
- export function coreStats() {
190
- const ret = wasm.coreStats();
191
- if (ret[2]) {
192
- throw takeFromExternrefTable0(ret[1]);
175
+ export class StatMap {
176
+ __destroy_into_raw() {
177
+ const ptr = this.__wbg_ptr;
178
+ this.__wbg_ptr = 0;
179
+ StatMapFinalization.unregister(this);
180
+ return ptr;
193
181
  }
194
- return takeFromExternrefTable0(ret[0]);
195
- }
196
-
197
- /**
198
- * @returns {any}
199
- */
200
- export function weaponStats() {
201
- const ret = wasm.weaponStats();
202
- if (ret[2]) {
203
- throw takeFromExternrefTable0(ret[1]);
182
+ free() {
183
+ const ptr = this.__destroy_into_raw();
184
+ wasm.__wbg_statmap_free(ptr, 0);
185
+ }
186
+ /**
187
+ * @returns {number}
188
+ */
189
+ cost() {
190
+ const ret = wasm.statmap_cost(this.__wbg_ptr);
191
+ return ret;
192
+ }
193
+ /**
194
+ * @param {string} stat
195
+ * @returns {number}
196
+ */
197
+ get(stat) {
198
+ const ptr0 = passStringToWasm0(stat, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
199
+ const len0 = WASM_VECTOR_LEN;
200
+ const ret = wasm.statmap_get(this.__wbg_ptr, ptr0, len0);
201
+ if (ret[2]) {
202
+ throw takeFromExternrefTable0(ret[1]);
203
+ }
204
+ return ret[0];
205
+ }
206
+ /**
207
+ * @param {any} map
208
+ */
209
+ constructor(map) {
210
+ const ret = wasm.statmap_new(map);
211
+ if (ret[2]) {
212
+ throw takeFromExternrefTable0(ret[1]);
213
+ }
214
+ this.__wbg_ptr = ret[0] >>> 0;
215
+ StatMapFinalization.register(this, this.__wbg_ptr, this);
216
+ return this;
217
+ }
218
+ /**
219
+ * @param {string} stat
220
+ * @param {number} value
221
+ */
222
+ set(stat, value) {
223
+ const ptr0 = passStringToWasm0(stat, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
224
+ const len0 = WASM_VECTOR_LEN;
225
+ const ret = wasm.statmap_set(this.__wbg_ptr, ptr0, len0, value);
226
+ if (ret[1]) {
227
+ throw takeFromExternrefTable0(ret[0]);
228
+ }
204
229
  }
205
- return takeFromExternrefTable0(ret[0]);
206
230
  }
231
+ if (Symbol.dispose) StatMap.prototype[Symbol.dispose] = StatMap.prototype.free;
207
232
 
208
233
  function __wbg_get_imports() {
209
234
  const import0 = {
@@ -212,6 +237,10 @@ function __wbg_get_imports() {
212
237
  const ret = Error(getStringFromWasm0(arg0, arg1));
213
238
  return ret;
214
239
  },
240
+ __wbg_Number_7da99b0afe51b89a: function(arg0) {
241
+ const ret = Number(arg0);
242
+ return ret;
243
+ },
215
244
  __wbg_String_8564e559799eccda: function(arg0, arg1) {
216
245
  const ret = String(arg1);
217
246
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
@@ -219,6 +248,17 @@ function __wbg_get_imports() {
219
248
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
220
249
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
221
250
  },
251
+ __wbg___wbindgen_bigint_get_as_i64_a4925bc53b16f3d6: function(arg0, arg1) {
252
+ const v = arg1;
253
+ const ret = typeof(v) === 'bigint' ? v : undefined;
254
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
255
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
256
+ },
257
+ __wbg___wbindgen_boolean_get_4a348b369b009243: function(arg0) {
258
+ const v = arg0;
259
+ const ret = typeof(v) === 'boolean' ? v : undefined;
260
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
261
+ },
222
262
  __wbg___wbindgen_debug_string_43c7ccb034739216: function(arg0, arg1) {
223
263
  const ret = debugString(arg1);
224
264
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
@@ -226,6 +266,10 @@ function __wbg_get_imports() {
226
266
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
227
267
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
228
268
  },
269
+ __wbg___wbindgen_is_bigint_15e2d080220c7748: function(arg0) {
270
+ const ret = typeof(arg0) === 'bigint';
271
+ return ret;
272
+ },
229
273
  __wbg___wbindgen_is_function_18bea6e84080c016: function(arg0) {
230
274
  const ret = typeof(arg0) === 'function';
231
275
  return ret;
@@ -243,6 +287,20 @@ function __wbg_get_imports() {
243
287
  const ret = arg0 === undefined;
244
288
  return ret;
245
289
  },
290
+ __wbg___wbindgen_jsval_eq_65f99081d9ee8f4d: function(arg0, arg1) {
291
+ const ret = arg0 === arg1;
292
+ return ret;
293
+ },
294
+ __wbg___wbindgen_jsval_loose_eq_1a2067dfb025b5ec: function(arg0, arg1) {
295
+ const ret = arg0 == arg1;
296
+ return ret;
297
+ },
298
+ __wbg___wbindgen_number_get_eed4462ef92e1bed: function(arg0, arg1) {
299
+ const obj = arg1;
300
+ const ret = typeof(obj) === 'number' ? obj : undefined;
301
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
302
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
303
+ },
246
304
  __wbg___wbindgen_string_get_d09f733449cbf7a2: function(arg0, arg1) {
247
305
  const obj = arg1;
248
306
  const ret = typeof(obj) === 'string' ? obj : undefined;
@@ -290,6 +348,10 @@ function __wbg_get_imports() {
290
348
  const ret = arg0.done;
291
349
  return ret;
292
350
  },
351
+ __wbg_entries_d58050057c0390ac: function(arg0) {
352
+ const ret = Object.entries(arg0);
353
+ return ret;
354
+ },
293
355
  __wbg_fetch_8508e14acc7090e7: function(arg0, arg1) {
294
356
  const ret = arg0.fetch(arg1);
295
357
  return ret;
@@ -302,6 +364,14 @@ function __wbg_get_imports() {
302
364
  const ret = Reflect.get(arg0, arg1);
303
365
  return ret;
304
366
  }, arguments); },
367
+ __wbg_get_c40e2c3262995a8e: function(arg0, arg1) {
368
+ const ret = arg0[arg1 >>> 0];
369
+ return ret;
370
+ },
371
+ __wbg_get_unchecked_3de5bfaaea65f86b: function(arg0, arg1) {
372
+ const ret = arg0[arg1 >>> 0];
373
+ return ret;
374
+ },
305
375
  __wbg_has_393943c179c58bfe: function() { return handleError(function (arg0, arg1) {
306
376
  const ret = Reflect.has(arg0, arg1);
307
377
  return ret;
@@ -310,6 +380,16 @@ function __wbg_get_imports() {
310
380
  const ret = arg0.headers;
311
381
  return ret;
312
382
  },
383
+ __wbg_instanceof_ArrayBuffer_d8e4e51f1cf7287a: function(arg0) {
384
+ let result;
385
+ try {
386
+ result = arg0 instanceof ArrayBuffer;
387
+ } catch (_) {
388
+ result = false;
389
+ }
390
+ const ret = result;
391
+ return ret;
392
+ },
313
393
  __wbg_instanceof_Response_4d70bea95d48a514: function(arg0) {
314
394
  let result;
315
395
  try {
@@ -320,10 +400,28 @@ function __wbg_get_imports() {
320
400
  const ret = result;
321
401
  return ret;
322
402
  },
403
+ __wbg_instanceof_Uint8Array_6e48d83da6091cc8: function(arg0) {
404
+ let result;
405
+ try {
406
+ result = arg0 instanceof Uint8Array;
407
+ } catch (_) {
408
+ result = false;
409
+ }
410
+ const ret = result;
411
+ return ret;
412
+ },
413
+ __wbg_isSafeInteger_6709fb28be12d738: function(arg0) {
414
+ const ret = Number.isSafeInteger(arg0);
415
+ return ret;
416
+ },
323
417
  __wbg_iterator_e77d2b7575cca5a7: function() {
324
418
  const ret = Symbol.iterator;
325
419
  return ret;
326
420
  },
421
+ __wbg_length_00dd7227fd4626ad: function(arg0) {
422
+ const ret = arg0.length;
423
+ return ret;
424
+ },
327
425
  __wbg_length_5e07cf181b2745fb: function(arg0) {
328
426
  const ret = arg0.length;
329
427
  return ret;
@@ -487,12 +585,12 @@ function __wbg_get_imports() {
487
585
  return ret;
488
586
  },
489
587
  __wbindgen_cast_0000000000000001: function(arg0, arg1) {
490
- // Cast intrinsic for `Closure(Closure { dtor_idx: 140, function: Function { arguments: [], shim_idx: 141, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
588
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 145, function: Function { arguments: [], shim_idx: 146, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
491
589
  const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__hf10da1d08ed9fc18, wasm_bindgen__convert__closures_____invoke__h8e5a743d58fae3f8);
492
590
  return ret;
493
591
  },
494
592
  __wbindgen_cast_0000000000000002: function(arg0, arg1) {
495
- // Cast intrinsic for `Closure(Closure { dtor_idx: 165, function: Function { arguments: [Externref], shim_idx: 166, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
593
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 169, function: Function { arguments: [Externref], shim_idx: 170, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
496
594
  const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__he46194fcf4899997, wasm_bindgen__convert__closures_____invoke__h71bc5879fd2abe15);
497
595
  return ret;
498
596
  },
@@ -553,6 +651,9 @@ const __wbindgen_enum_RequestMode = ["same-origin", "no-cors", "cors", "navigate
553
651
  const DeepDataFinalization = (typeof FinalizationRegistry === 'undefined')
554
652
  ? { register: () => {}, unregister: () => {} }
555
653
  : new FinalizationRegistry(ptr => wasm.__wbg_deepdata_free(ptr >>> 0, 1));
654
+ const StatMapFinalization = (typeof FinalizationRegistry === 'undefined')
655
+ ? { register: () => {}, unregister: () => {} }
656
+ : new FinalizationRegistry(ptr => wasm.__wbg_statmap_free(ptr >>> 0, 1));
556
657
 
557
658
  function addToExternrefTable0(obj) {
558
659
  const idx = wasm.__externref_table_alloc();
Binary file
package/types.ts CHANGED
@@ -1,10 +1,7 @@
1
- // copy the rust provided types (is there a better way to mirror types? man)
1
+ export type { Stat } from './generated.js';
2
+ export { CORE_STATS, WEAPON_STATS, ATTUNEMENT_STATS } from './generated.js';
2
3
 
3
- export type Stat =
4
- | "Strength" | "Fortitude" | "Agility" | "Intelligence" | "Willpower" | "Charisma"
5
- | "Heavy" | "Medium" | "Light"
6
- | "Frostdraw" | "Flamecharm" | "Thundercall" | "Galebreathe" | "Shadowcast" | "Ironsing" | "Bloodrend"
7
- | "Total";
4
+ import type { Stat } from './generated.js';
8
5
 
9
6
  export interface Talent {
10
7
  name: string;