deepwoken 0.2.0 → 0.2.2

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/index.ts CHANGED
@@ -1,17 +1,23 @@
1
1
  export { ATTUNEMENT_STATS, CORE_STATS, WEAPON_STATS } from './types.js';
2
2
  export type { Aspect, Mantra, Outfit, Stat, Talent, Weapon } from './types.js';
3
+ export type { Atom, Clause, ClauseType, Reducability } from './requirement.js';
3
4
 
4
5
  import type { Aspect, Mantra, Outfit, Stat, Talent, Weapon } from './types.js';
6
+ import type { Clause } from './requirement.js';
5
7
 
6
8
  // dynamically import wasm bc the server will try to load wasm regardless man
7
9
  let WasmDeepData: any;
8
10
  let WasmStatMap: any;
11
+ let WasmRequirement: any;
12
+ let wasmNameToIdentifier: (name: string) => string;
9
13
 
10
14
  if (typeof window !== 'undefined') {
11
15
  const wasm = await import('./pkg/deepwoken.js');
12
16
  await wasm.default();
13
17
  WasmDeepData = wasm.DeepData;
14
18
  WasmStatMap = wasm.StatMap;
19
+ WasmRequirement = wasm.Requirement;
20
+ wasmNameToIdentifier = wasm.nameToIdentifier;
15
21
  }
16
22
 
17
23
  export class DeepData {
@@ -46,8 +52,14 @@ export class DeepData {
46
52
  aspects(): Aspect[] { return this._wasm.aspects(); }
47
53
  }
48
54
 
55
+ /** Transforms the name of things ingame into a parsable identifier/key used in the database */
56
+ export function nameToIdentifier(name: string): string {
57
+ return wasmNameToIdentifier(name);
58
+ }
59
+
49
60
  export class StatMap {
50
- private _wasm: any;
61
+ /** @internal */
62
+ _wasm: any;
51
63
 
52
64
  constructor(map: Partial<Record<Stat, number>> = {}) {
53
65
  this._wasm = new WasmStatMap(map);
@@ -64,3 +76,19 @@ export class StatMap {
64
76
  set(stat: Stat, value: number) { this._wasm.set(stat, value); }
65
77
  toJSON(): Partial<Record<Stat, number>> { return this._wasm.toJSON(); }
66
78
  }
79
+
80
+ export class Requirement {
81
+ private _wasm: any;
82
+
83
+ constructor(input: string) {
84
+ this._wasm = new WasmRequirement(input);
85
+ }
86
+
87
+ satisfiedBy(stats: StatMap): boolean { return this._wasm.satisfiedBy(stats._wasm); }
88
+ isEmpty(): boolean { return this._wasm.isEmpty(); }
89
+ usedStats(): Stat[] { return this._wasm.usedStats(); }
90
+ name(): string | null { return this._wasm.name(); }
91
+ prereqs(): string[] { return this._wasm.prereqs(); }
92
+ clauses(): Clause[] { return this._wasm.clauses(); }
93
+ toString(): string { return this._wasm.toString(); }
94
+ }
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "deepwoken",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
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
+ "requirement.ts",
10
11
  "generated.ts",
11
12
  "pkg/deepwoken_bg.wasm",
12
13
  "pkg/deepwoken.js",
@@ -29,6 +29,19 @@ export class DeepData {
29
29
  weapons(): any;
30
30
  }
31
31
 
32
+ export class Requirement {
33
+ free(): void;
34
+ [Symbol.dispose](): void;
35
+ clauses(): any;
36
+ isEmpty(): boolean;
37
+ name(): string | undefined;
38
+ constructor(input: string);
39
+ prereqs(): any;
40
+ satisfiedBy(stats: StatMap): boolean;
41
+ toString(): string;
42
+ usedStats(): any;
43
+ }
44
+
32
45
  export class StatMap {
33
46
  free(): void;
34
47
  [Symbol.dispose](): void;
@@ -42,6 +55,11 @@ export class StatMap {
42
55
  toJSON(): any;
43
56
  }
44
57
 
58
+ /**
59
+ * Transforms the name of things ingame into an identifier/key used in the database
60
+ */
61
+ export function nameToIdentifier(name: string): string;
62
+
45
63
  export function shrineOrderDwb(pre: StatMap, racial: StatMap): StatMap;
46
64
 
47
65
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
@@ -49,6 +67,7 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
49
67
  export interface InitOutput {
50
68
  readonly memory: WebAssembly.Memory;
51
69
  readonly __wbg_deepdata_free: (a: number, b: number) => void;
70
+ readonly __wbg_requirement_free: (a: number, b: number) => void;
52
71
  readonly __wbg_statmap_free: (a: number, b: number) => void;
53
72
  readonly deepdata_aspects: (a: number) => [number, number, number];
54
73
  readonly deepdata_fetchLatest: () => any;
@@ -63,6 +82,15 @@ export interface InitOutput {
63
82
  readonly deepdata_outfits: (a: number) => [number, number, number];
64
83
  readonly deepdata_talents: (a: number) => [number, number, number];
65
84
  readonly deepdata_weapons: (a: number) => [number, number, number];
85
+ readonly nameToIdentifier: (a: number, b: number) => [number, number];
86
+ readonly requirement_clauses: (a: number) => [number, number, number];
87
+ readonly requirement_isEmpty: (a: number) => number;
88
+ readonly requirement_name: (a: number) => [number, number];
89
+ readonly requirement_new: (a: number, b: number) => [number, number, number];
90
+ readonly requirement_prereqs: (a: number) => [number, number, number];
91
+ readonly requirement_satisfiedBy: (a: number, b: number) => number;
92
+ readonly requirement_toString: (a: number) => [number, number];
93
+ readonly requirement_usedStats: (a: number) => [number, number, number];
66
94
  readonly shrineOrderDwb: (a: number, b: number) => number;
67
95
  readonly statmap_cost: (a: number) => number;
68
96
  readonly statmap_get: (a: number, b: number, c: number) => [number, number, number];
@@ -72,17 +100,18 @@ export interface InitOutput {
72
100
  readonly statmap_set: (a: number, b: number, c: number, d: number) => [number, number];
73
101
  readonly statmap_toJSON: (a: number) => [number, number, number];
74
102
  readonly statmap_shrineOrder: (a: number, b: number) => number;
75
- readonly wasm_bindgen__closure__destroy__hf10da1d08ed9fc18: (a: number, b: number) => void;
76
- readonly wasm_bindgen__closure__destroy__he46194fcf4899997: (a: number, b: number) => void;
77
- readonly wasm_bindgen__convert__closures_____invoke__h71bc5879fd2abe15: (a: number, b: number, c: any) => [number, number];
78
- readonly wasm_bindgen__convert__closures_____invoke__h2dcdf54066fbc735: (a: number, b: number, c: any, d: any) => void;
79
- readonly wasm_bindgen__convert__closures_____invoke__h8e5a743d58fae3f8: (a: number, b: number) => void;
103
+ readonly wasm_bindgen__closure__destroy__hfbac65673247baa3: (a: number, b: number) => void;
104
+ readonly wasm_bindgen__closure__destroy__h22f2fd8de233cef9: (a: number, b: number) => void;
105
+ readonly wasm_bindgen__convert__closures_____invoke__h462ab53fb1f380e1: (a: number, b: number, c: any) => [number, number];
106
+ readonly wasm_bindgen__convert__closures_____invoke__h3f8186ac2655158b: (a: number, b: number, c: any, d: any) => void;
107
+ readonly wasm_bindgen__convert__closures_____invoke__hcf18b6c4eb572639: (a: number, b: number) => void;
80
108
  readonly __wbindgen_malloc: (a: number, b: number) => number;
81
109
  readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
82
110
  readonly __wbindgen_exn_store: (a: number) => void;
83
111
  readonly __externref_table_alloc: () => number;
84
112
  readonly __wbindgen_externrefs: WebAssembly.Table;
85
113
  readonly __externref_table_dealloc: (a: number) => void;
114
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
86
115
  readonly __wbindgen_start: () => void;
87
116
  }
88
117
 
package/pkg/deepwoken.js CHANGED
@@ -172,6 +172,107 @@ export class DeepData {
172
172
  }
173
173
  if (Symbol.dispose) DeepData.prototype[Symbol.dispose] = DeepData.prototype.free;
174
174
 
175
+ export class Requirement {
176
+ __destroy_into_raw() {
177
+ const ptr = this.__wbg_ptr;
178
+ this.__wbg_ptr = 0;
179
+ RequirementFinalization.unregister(this);
180
+ return ptr;
181
+ }
182
+ free() {
183
+ const ptr = this.__destroy_into_raw();
184
+ wasm.__wbg_requirement_free(ptr, 0);
185
+ }
186
+ /**
187
+ * @returns {any}
188
+ */
189
+ clauses() {
190
+ const ret = wasm.requirement_clauses(this.__wbg_ptr);
191
+ if (ret[2]) {
192
+ throw takeFromExternrefTable0(ret[1]);
193
+ }
194
+ return takeFromExternrefTable0(ret[0]);
195
+ }
196
+ /**
197
+ * @returns {boolean}
198
+ */
199
+ isEmpty() {
200
+ const ret = wasm.requirement_isEmpty(this.__wbg_ptr);
201
+ return ret !== 0;
202
+ }
203
+ /**
204
+ * @returns {string | undefined}
205
+ */
206
+ name() {
207
+ const ret = wasm.requirement_name(this.__wbg_ptr);
208
+ let v1;
209
+ if (ret[0] !== 0) {
210
+ v1 = getStringFromWasm0(ret[0], ret[1]).slice();
211
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
212
+ }
213
+ return v1;
214
+ }
215
+ /**
216
+ * @param {string} input
217
+ */
218
+ constructor(input) {
219
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
220
+ const len0 = WASM_VECTOR_LEN;
221
+ const ret = wasm.requirement_new(ptr0, len0);
222
+ if (ret[2]) {
223
+ throw takeFromExternrefTable0(ret[1]);
224
+ }
225
+ this.__wbg_ptr = ret[0] >>> 0;
226
+ RequirementFinalization.register(this, this.__wbg_ptr, this);
227
+ return this;
228
+ }
229
+ /**
230
+ * @returns {any}
231
+ */
232
+ prereqs() {
233
+ const ret = wasm.requirement_prereqs(this.__wbg_ptr);
234
+ if (ret[2]) {
235
+ throw takeFromExternrefTable0(ret[1]);
236
+ }
237
+ return takeFromExternrefTable0(ret[0]);
238
+ }
239
+ /**
240
+ * @param {StatMap} stats
241
+ * @returns {boolean}
242
+ */
243
+ satisfiedBy(stats) {
244
+ _assertClass(stats, StatMap);
245
+ const ret = wasm.requirement_satisfiedBy(this.__wbg_ptr, stats.__wbg_ptr);
246
+ return ret !== 0;
247
+ }
248
+ /**
249
+ * @returns {string}
250
+ */
251
+ toString() {
252
+ let deferred1_0;
253
+ let deferred1_1;
254
+ try {
255
+ const ret = wasm.requirement_toString(this.__wbg_ptr);
256
+ deferred1_0 = ret[0];
257
+ deferred1_1 = ret[1];
258
+ return getStringFromWasm0(ret[0], ret[1]);
259
+ } finally {
260
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
261
+ }
262
+ }
263
+ /**
264
+ * @returns {any}
265
+ */
266
+ usedStats() {
267
+ const ret = wasm.requirement_usedStats(this.__wbg_ptr);
268
+ if (ret[2]) {
269
+ throw takeFromExternrefTable0(ret[1]);
270
+ }
271
+ return takeFromExternrefTable0(ret[0]);
272
+ }
273
+ }
274
+ if (Symbol.dispose) Requirement.prototype[Symbol.dispose] = Requirement.prototype.free;
275
+
175
276
  export class StatMap {
176
277
  static __wrap(ptr) {
177
278
  ptr = ptr >>> 0;
@@ -270,6 +371,26 @@ export class StatMap {
270
371
  }
271
372
  if (Symbol.dispose) StatMap.prototype[Symbol.dispose] = StatMap.prototype.free;
272
373
 
374
+ /**
375
+ * Transforms the name of things ingame into an identifier/key used in the database
376
+ * @param {string} name
377
+ * @returns {string}
378
+ */
379
+ export function nameToIdentifier(name) {
380
+ let deferred2_0;
381
+ let deferred2_1;
382
+ try {
383
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
384
+ const len0 = WASM_VECTOR_LEN;
385
+ const ret = wasm.nameToIdentifier(ptr0, len0);
386
+ deferred2_0 = ret[0];
387
+ deferred2_1 = ret[1];
388
+ return getStringFromWasm0(ret[0], ret[1]);
389
+ } finally {
390
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
391
+ }
392
+ }
393
+
273
394
  /**
274
395
  * @param {StatMap} pre
275
396
  * @param {StatMap} racial
@@ -513,7 +634,7 @@ function __wbg_get_imports() {
513
634
  const a = state0.a;
514
635
  state0.a = 0;
515
636
  try {
516
- return wasm_bindgen__convert__closures_____invoke__h2dcdf54066fbc735(a, state0.b, arg0, arg1);
637
+ return wasm_bindgen__convert__closures_____invoke__h3f8186ac2655158b(a, state0.b, arg0, arg1);
517
638
  } finally {
518
639
  state0.a = a;
519
640
  }
@@ -637,13 +758,13 @@ function __wbg_get_imports() {
637
758
  return ret;
638
759
  },
639
760
  __wbindgen_cast_0000000000000001: function(arg0, arg1) {
640
- // Cast intrinsic for `Closure(Closure { dtor_idx: 145, function: Function { arguments: [], shim_idx: 146, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
641
- const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__hf10da1d08ed9fc18, wasm_bindgen__convert__closures_____invoke__h8e5a743d58fae3f8);
761
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 146, function: Function { arguments: [], shim_idx: 147, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
762
+ const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__hfbac65673247baa3, wasm_bindgen__convert__closures_____invoke__hcf18b6c4eb572639);
642
763
  return ret;
643
764
  },
644
765
  __wbindgen_cast_0000000000000002: function(arg0, arg1) {
645
- // 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`.
646
- const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__he46194fcf4899997, wasm_bindgen__convert__closures_____invoke__h71bc5879fd2abe15);
766
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 166, function: Function { arguments: [Externref], shim_idx: 167, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
767
+ const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h22f2fd8de233cef9, wasm_bindgen__convert__closures_____invoke__h462ab53fb1f380e1);
647
768
  return ret;
648
769
  },
649
770
  __wbindgen_cast_0000000000000003: function(arg0) {
@@ -677,19 +798,19 @@ function __wbg_get_imports() {
677
798
  };
678
799
  }
679
800
 
680
- function wasm_bindgen__convert__closures_____invoke__h8e5a743d58fae3f8(arg0, arg1) {
681
- wasm.wasm_bindgen__convert__closures_____invoke__h8e5a743d58fae3f8(arg0, arg1);
801
+ function wasm_bindgen__convert__closures_____invoke__hcf18b6c4eb572639(arg0, arg1) {
802
+ wasm.wasm_bindgen__convert__closures_____invoke__hcf18b6c4eb572639(arg0, arg1);
682
803
  }
683
804
 
684
- function wasm_bindgen__convert__closures_____invoke__h71bc5879fd2abe15(arg0, arg1, arg2) {
685
- const ret = wasm.wasm_bindgen__convert__closures_____invoke__h71bc5879fd2abe15(arg0, arg1, arg2);
805
+ function wasm_bindgen__convert__closures_____invoke__h462ab53fb1f380e1(arg0, arg1, arg2) {
806
+ const ret = wasm.wasm_bindgen__convert__closures_____invoke__h462ab53fb1f380e1(arg0, arg1, arg2);
686
807
  if (ret[1]) {
687
808
  throw takeFromExternrefTable0(ret[0]);
688
809
  }
689
810
  }
690
811
 
691
- function wasm_bindgen__convert__closures_____invoke__h2dcdf54066fbc735(arg0, arg1, arg2, arg3) {
692
- wasm.wasm_bindgen__convert__closures_____invoke__h2dcdf54066fbc735(arg0, arg1, arg2, arg3);
812
+ function wasm_bindgen__convert__closures_____invoke__h3f8186ac2655158b(arg0, arg1, arg2, arg3) {
813
+ wasm.wasm_bindgen__convert__closures_____invoke__h3f8186ac2655158b(arg0, arg1, arg2, arg3);
693
814
  }
694
815
 
695
816
 
@@ -703,6 +824,9 @@ const __wbindgen_enum_RequestMode = ["same-origin", "no-cors", "cors", "navigate
703
824
  const DeepDataFinalization = (typeof FinalizationRegistry === 'undefined')
704
825
  ? { register: () => {}, unregister: () => {} }
705
826
  : new FinalizationRegistry(ptr => wasm.__wbg_deepdata_free(ptr >>> 0, 1));
827
+ const RequirementFinalization = (typeof FinalizationRegistry === 'undefined')
828
+ ? { register: () => {}, unregister: () => {} }
829
+ : new FinalizationRegistry(ptr => wasm.__wbg_requirement_free(ptr >>> 0, 1));
706
830
  const StatMapFinalization = (typeof FinalizationRegistry === 'undefined')
707
831
  ? { register: () => {}, unregister: () => {} }
708
832
  : new FinalizationRegistry(ptr => wasm.__wbg_statmap_free(ptr >>> 0, 1));
Binary file
package/requirement.ts ADDED
@@ -0,0 +1,15 @@
1
+ import type { Stat } from './generated.js';
2
+
3
+ export type Reducability = "reducible" | "strict";
4
+ export type ClauseType = "and" | "or";
5
+
6
+ export interface Atom {
7
+ reducability: Reducability;
8
+ value: number;
9
+ stats: Stat[];
10
+ }
11
+
12
+ export interface Clause {
13
+ clause_type: ClauseType;
14
+ atoms: Atom[];
15
+ }