@eveshipfit/dogma-engine 13.0.1 → 13.1.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.
package/README.md CHANGED
@@ -30,6 +30,10 @@ import wasmInit, {
30
30
  load_sde,
31
31
  load_eft,
32
32
  save_eft,
33
+ load_esi_fitting,
34
+ save_esi_fitting,
35
+ load_killmail,
36
+ load_link,
33
37
  calculate,
34
38
  beacon,
35
39
  } from "@eveshipfit/dogma-engine";
@@ -53,6 +57,13 @@ const withBeacon = calculate({ ...fit, incoming: beacon(beaconTypeId) });
53
57
  const imported = calculate(load_eft("[Rifter, My Rifter]\n200mm AutoCannon I"));
54
58
  /* And to write a fit back out as EFT: */
55
59
  const eft = save_eft(fit);
60
+ /* Or if you have a fitting a character saved in game, as ESI returns it (and the other way around): */
61
+ const fromEsi = load_esi_fitting(fitting);
62
+ const toEsi = save_esi_fitting(fit);
63
+ /* Or if you have a killmail, as ESI returns it, for the fit of the ship that died: */
64
+ const fromKillmail = load_killmail(killmail);
65
+ /* Or if you have an EVEShip.fit link, `<version>:<payload>`, with the payload gunzipped and unbase64'd: */
66
+ const fromLink = load_link(version, payload);
56
67
 
57
68
  /* What EVE would not let you fly, in `violations` of the calculation: */
58
69
  const validated = calculate(fit, { validate: true });
@@ -10,6 +10,47 @@ export interface Charge {
10
10
  type_id: number;
11
11
  }
12
12
 
13
+ /**
14
+ * A fitting as ESI saves it for a character.
15
+ */
16
+ export interface EsiFitting {
17
+ /**
18
+ * Only on fittings ESI returns.
19
+ */
20
+ fitting_id?: number;
21
+ /**
22
+ * The name of the fitting.
23
+ */
24
+ name: string;
25
+ /**
26
+ * The description of the fitting.
27
+ */
28
+ description?: string;
29
+ /**
30
+ * The type id of the ship.
31
+ */
32
+ ship_type_id: number;
33
+ /**
34
+ * Everything on and in the ship.
35
+ */
36
+ items: EsiFittingItem[];
37
+ }
38
+
39
+ /**
40
+ * A killmail as ESI returns it; only what a fit is made from. Anything else
41
+ * in it is ignored.
42
+ */
43
+ export interface EsiKillmail {
44
+ /**
45
+ * The id of the killmail.
46
+ */
47
+ killmail_id: number;
48
+ /**
49
+ * The ship that died.
50
+ */
51
+ victim: EsiKillmailVictim;
52
+ }
53
+
13
54
  /**
14
55
  * A module, drone, fighter squadron, implant, booster or item in cargo.
15
56
  */
@@ -138,6 +179,46 @@ export interface Fit {
138
179
  incoming?: Projection;
139
180
  }
140
181
 
182
+ /**
183
+ * An item of a killmail.
184
+ */
185
+ export interface EsiKillmailItem {
186
+ /**
187
+ * An inventory flag, like 27 for the first high slot.
188
+ */
189
+ flag: number;
190
+ /**
191
+ * The type id of the item.
192
+ */
193
+ item_type_id: number;
194
+ /**
195
+ * How many of the item were destroyed.
196
+ */
197
+ quantity_destroyed?: number;
198
+ /**
199
+ * How many of the item dropped.
200
+ */
201
+ quantity_dropped?: number;
202
+ }
203
+
204
+ /**
205
+ * An item of an ESI fitting.
206
+ */
207
+ export interface EsiFittingItem {
208
+ /**
209
+ * An inventory flag by name, like `HiSlot0`, `DroneBay` or `Cargo`.
210
+ */
211
+ flag: string;
212
+ /**
213
+ * How many of the item.
214
+ */
215
+ quantity: number;
216
+ /**
217
+ * The type id of the item.
218
+ */
219
+ type_id: number;
220
+ }
221
+
141
222
  /**
142
223
  * How a modifier changes an attribute. They are applied in this order.
143
224
  */
@@ -370,6 +451,20 @@ export interface Ship {
370
451
  */
371
452
  export type State = "offline" | "online" | "active" | "overload";
372
453
 
454
+ /**
455
+ * The victim of a killmail.
456
+ */
457
+ export interface EsiKillmailVictim {
458
+ /**
459
+ * The type id of the ship.
460
+ */
461
+ ship_type_id: number;
462
+ /**
463
+ * Everything on and in the ship.
464
+ */
465
+ items?: EsiKillmailItem[];
466
+ }
467
+
373
468
  /**
374
469
  * What [`calculate()`] reports on top of the values.
375
470
  */
@@ -450,6 +545,22 @@ export function calculate(fit: Fit, options?: Options | null): Calculation;
450
545
  */
451
546
  export function load_eft(eft: string): Fit;
452
547
 
548
+ /**
549
+ * Load a fit from an ESI fitting, the fits a character saves in game.
550
+ */
551
+ export function load_esi_fitting(fitting: EsiFitting): Fit;
552
+
553
+ /**
554
+ * Load the fit of the ship that died from a killmail, as ESI returns it.
555
+ */
556
+ export function load_killmail(killmail: EsiKillmail): Fit;
557
+
558
+ /**
559
+ * Load a fit from an EVEShip.fit link, given its version and its payload
560
+ * once unbase64'd and gunzipped.
561
+ */
562
+ export function load_link(version: string, payload: string): Fit;
563
+
453
564
  /**
454
565
  * Load `names.dat`, so an EFT written in another language than English also
455
566
  * imports. Optional; without it only English names match. Has to be called
@@ -468,6 +579,11 @@ export function load_sde(bytes: Uint8Array): number;
468
579
  */
469
580
  export function save_eft(fit: Fit): string;
470
581
 
582
+ /**
583
+ * Write a fit as an ESI fitting, the fits a character saves in game.
584
+ */
585
+ export function save_esi_fitting(fit: Fit): EsiFitting;
586
+
471
587
  export function set_panic_hook(): void;
472
588
 
473
589
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
@@ -477,9 +593,13 @@ export interface InitOutput {
477
593
  readonly beacon: (a: number) => [number, number, number];
478
594
  readonly calculate: (a: any, b: number) => [number, number, number];
479
595
  readonly load_eft: (a: number, b: number) => [number, number, number];
596
+ readonly load_esi_fitting: (a: any) => [number, number, number];
597
+ readonly load_killmail: (a: any) => [number, number, number];
598
+ readonly load_link: (a: number, b: number, c: number, d: number) => [number, number, number];
480
599
  readonly load_names: (a: number, b: number) => [number, number, number];
481
600
  readonly load_sde: (a: number, b: number) => [number, number, number];
482
601
  readonly save_eft: (a: any) => [number, number, number, number];
602
+ readonly save_esi_fitting: (a: any) => [number, number, number];
483
603
  readonly set_panic_hook: () => void;
484
604
  readonly __wbindgen_malloc: (a: number, b: number) => number;
485
605
  readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
@@ -43,6 +43,51 @@ export function load_eft(eft) {
43
43
  return takeFromExternrefTable0(ret[0]);
44
44
  }
45
45
 
46
+ /**
47
+ * Load a fit from an ESI fitting, the fits a character saves in game.
48
+ * @param {EsiFitting} fitting
49
+ * @returns {Fit}
50
+ */
51
+ export function load_esi_fitting(fitting) {
52
+ const ret = wasm.load_esi_fitting(fitting);
53
+ if (ret[2]) {
54
+ throw takeFromExternrefTable0(ret[1]);
55
+ }
56
+ return takeFromExternrefTable0(ret[0]);
57
+ }
58
+
59
+ /**
60
+ * Load the fit of the ship that died from a killmail, as ESI returns it.
61
+ * @param {EsiKillmail} killmail
62
+ * @returns {Fit}
63
+ */
64
+ export function load_killmail(killmail) {
65
+ const ret = wasm.load_killmail(killmail);
66
+ if (ret[2]) {
67
+ throw takeFromExternrefTable0(ret[1]);
68
+ }
69
+ return takeFromExternrefTable0(ret[0]);
70
+ }
71
+
72
+ /**
73
+ * Load a fit from an EVEShip.fit link, given its version and its payload
74
+ * once unbase64'd and gunzipped.
75
+ * @param {string} version
76
+ * @param {string} payload
77
+ * @returns {Fit}
78
+ */
79
+ export function load_link(version, payload) {
80
+ const ptr0 = passStringToWasm0(version, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
81
+ const len0 = WASM_VECTOR_LEN;
82
+ const ptr1 = passStringToWasm0(payload, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
83
+ const len1 = WASM_VECTOR_LEN;
84
+ const ret = wasm.load_link(ptr0, len0, ptr1, len1);
85
+ if (ret[2]) {
86
+ throw takeFromExternrefTable0(ret[1]);
87
+ }
88
+ return takeFromExternrefTable0(ret[0]);
89
+ }
90
+
46
91
  /**
47
92
  * Load `names.dat`, so an EFT written in another language than English also
48
93
  * imports. Optional; without it only English names match. Has to be called
@@ -100,6 +145,19 @@ export function save_eft(fit) {
100
145
  }
101
146
  }
102
147
 
148
+ /**
149
+ * Write a fit as an ESI fitting, the fits a character saves in game.
150
+ * @param {Fit} fit
151
+ * @returns {EsiFitting}
152
+ */
153
+ export function save_esi_fitting(fit) {
154
+ const ret = wasm.save_esi_fitting(fit);
155
+ if (ret[2]) {
156
+ throw takeFromExternrefTable0(ret[1]);
157
+ }
158
+ return takeFromExternrefTable0(ret[0]);
159
+ }
160
+
103
161
  export function set_panic_hook() {
104
162
  wasm.set_panic_hook();
105
163
  }
Binary file
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "EVEShipFit Team <info@eveship.fit>"
6
6
  ],
7
7
  "description": "Library to calculate statistics for EVE Online ship fits",
8
- "version": "13.0.1",
8
+ "version": "13.1.0",
9
9
  "license": "MIT",
10
10
  "repository": {
11
11
  "type": "git",