@eveshipfit/dogma-engine 13.0.1 → 13.2.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,32 @@ 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 esf/1 document, as text.
550
+ */
551
+ export function load_esf(text: string): Fit;
552
+
553
+ /**
554
+ * Load a fit from an esf/1 link: the binary form, in base64url.
555
+ */
556
+ export function load_esf_link(link: string): Fit;
557
+
558
+ /**
559
+ * Load a fit from an ESI fitting, the fits a character saves in game.
560
+ */
561
+ export function load_esi_fitting(fitting: EsiFitting): Fit;
562
+
563
+ /**
564
+ * Load the fit of the ship that died from a killmail, as ESI returns it.
565
+ */
566
+ export function load_killmail(killmail: EsiKillmail): Fit;
567
+
568
+ /**
569
+ * Load a fit from an EVEShip.fit link, given its version and its payload
570
+ * once unbase64'd and gunzipped.
571
+ */
572
+ export function load_link(version: string, payload: string): Fit;
573
+
453
574
  /**
454
575
  * Load `names.dat`, so an EFT written in another language than English also
455
576
  * imports. Optional; without it only English names match. Has to be called
@@ -468,6 +589,21 @@ export function load_sde(bytes: Uint8Array): number;
468
589
  */
469
590
  export function save_eft(fit: Fit): string;
470
591
 
592
+ /**
593
+ * Write a fit as an esf/1 document, as text.
594
+ */
595
+ export function save_esf(fit: Fit): string;
596
+
597
+ /**
598
+ * Write a fit as an esf/1 link: the binary form, in base64url.
599
+ */
600
+ export function save_esf_link(fit: Fit): string;
601
+
602
+ /**
603
+ * Write a fit as an ESI fitting, the fits a character saves in game.
604
+ */
605
+ export function save_esi_fitting(fit: Fit): EsiFitting;
606
+
471
607
  export function set_panic_hook(): void;
472
608
 
473
609
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
@@ -477,9 +613,17 @@ export interface InitOutput {
477
613
  readonly beacon: (a: number) => [number, number, number];
478
614
  readonly calculate: (a: any, b: number) => [number, number, number];
479
615
  readonly load_eft: (a: number, b: number) => [number, number, number];
616
+ readonly load_esf: (a: number, b: number) => [number, number, number];
617
+ readonly load_esf_link: (a: number, b: number) => [number, number, number];
618
+ readonly load_esi_fitting: (a: any) => [number, number, number];
619
+ readonly load_killmail: (a: any) => [number, number, number];
620
+ readonly load_link: (a: number, b: number, c: number, d: number) => [number, number, number];
480
621
  readonly load_names: (a: number, b: number) => [number, number, number];
481
622
  readonly load_sde: (a: number, b: number) => [number, number, number];
482
623
  readonly save_eft: (a: any) => [number, number, number, number];
624
+ readonly save_esf: (a: any) => [number, number, number, number];
625
+ readonly save_esf_link: (a: any) => [number, number, number, number];
626
+ readonly save_esi_fitting: (a: any) => [number, number, number];
483
627
  readonly set_panic_hook: () => void;
484
628
  readonly __wbindgen_malloc: (a: number, b: number) => number;
485
629
  readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
@@ -43,6 +43,81 @@ export function load_eft(eft) {
43
43
  return takeFromExternrefTable0(ret[0]);
44
44
  }
45
45
 
46
+ /**
47
+ * Load a fit from an esf/1 document, as text.
48
+ * @param {string} text
49
+ * @returns {Fit}
50
+ */
51
+ export function load_esf(text) {
52
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
53
+ const len0 = WASM_VECTOR_LEN;
54
+ const ret = wasm.load_esf(ptr0, len0);
55
+ if (ret[2]) {
56
+ throw takeFromExternrefTable0(ret[1]);
57
+ }
58
+ return takeFromExternrefTable0(ret[0]);
59
+ }
60
+
61
+ /**
62
+ * Load a fit from an esf/1 link: the binary form, in base64url.
63
+ * @param {string} link
64
+ * @returns {Fit}
65
+ */
66
+ export function load_esf_link(link) {
67
+ const ptr0 = passStringToWasm0(link, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
68
+ const len0 = WASM_VECTOR_LEN;
69
+ const ret = wasm.load_esf_link(ptr0, len0);
70
+ if (ret[2]) {
71
+ throw takeFromExternrefTable0(ret[1]);
72
+ }
73
+ return takeFromExternrefTable0(ret[0]);
74
+ }
75
+
76
+ /**
77
+ * Load a fit from an ESI fitting, the fits a character saves in game.
78
+ * @param {EsiFitting} fitting
79
+ * @returns {Fit}
80
+ */
81
+ export function load_esi_fitting(fitting) {
82
+ const ret = wasm.load_esi_fitting(fitting);
83
+ if (ret[2]) {
84
+ throw takeFromExternrefTable0(ret[1]);
85
+ }
86
+ return takeFromExternrefTable0(ret[0]);
87
+ }
88
+
89
+ /**
90
+ * Load the fit of the ship that died from a killmail, as ESI returns it.
91
+ * @param {EsiKillmail} killmail
92
+ * @returns {Fit}
93
+ */
94
+ export function load_killmail(killmail) {
95
+ const ret = wasm.load_killmail(killmail);
96
+ if (ret[2]) {
97
+ throw takeFromExternrefTable0(ret[1]);
98
+ }
99
+ return takeFromExternrefTable0(ret[0]);
100
+ }
101
+
102
+ /**
103
+ * Load a fit from an EVEShip.fit link, given its version and its payload
104
+ * once unbase64'd and gunzipped.
105
+ * @param {string} version
106
+ * @param {string} payload
107
+ * @returns {Fit}
108
+ */
109
+ export function load_link(version, payload) {
110
+ const ptr0 = passStringToWasm0(version, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
111
+ const len0 = WASM_VECTOR_LEN;
112
+ const ptr1 = passStringToWasm0(payload, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
113
+ const len1 = WASM_VECTOR_LEN;
114
+ const ret = wasm.load_link(ptr0, len0, ptr1, len1);
115
+ if (ret[2]) {
116
+ throw takeFromExternrefTable0(ret[1]);
117
+ }
118
+ return takeFromExternrefTable0(ret[0]);
119
+ }
120
+
46
121
  /**
47
122
  * Load `names.dat`, so an EFT written in another language than English also
48
123
  * imports. Optional; without it only English names match. Has to be called
@@ -100,6 +175,67 @@ export function save_eft(fit) {
100
175
  }
101
176
  }
102
177
 
178
+ /**
179
+ * Write a fit as an esf/1 document, as text.
180
+ * @param {Fit} fit
181
+ * @returns {string}
182
+ */
183
+ export function save_esf(fit) {
184
+ let deferred2_0;
185
+ let deferred2_1;
186
+ try {
187
+ const ret = wasm.save_esf(fit);
188
+ var ptr1 = ret[0];
189
+ var len1 = ret[1];
190
+ if (ret[3]) {
191
+ ptr1 = 0; len1 = 0;
192
+ throw takeFromExternrefTable0(ret[2]);
193
+ }
194
+ deferred2_0 = ptr1;
195
+ deferred2_1 = len1;
196
+ return getStringFromWasm0(ptr1, len1);
197
+ } finally {
198
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
199
+ }
200
+ }
201
+
202
+ /**
203
+ * Write a fit as an esf/1 link: the binary form, in base64url.
204
+ * @param {Fit} fit
205
+ * @returns {string}
206
+ */
207
+ export function save_esf_link(fit) {
208
+ let deferred2_0;
209
+ let deferred2_1;
210
+ try {
211
+ const ret = wasm.save_esf_link(fit);
212
+ var ptr1 = ret[0];
213
+ var len1 = ret[1];
214
+ if (ret[3]) {
215
+ ptr1 = 0; len1 = 0;
216
+ throw takeFromExternrefTable0(ret[2]);
217
+ }
218
+ deferred2_0 = ptr1;
219
+ deferred2_1 = len1;
220
+ return getStringFromWasm0(ptr1, len1);
221
+ } finally {
222
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
223
+ }
224
+ }
225
+
226
+ /**
227
+ * Write a fit as an ESI fitting, the fits a character saves in game.
228
+ * @param {Fit} fit
229
+ * @returns {EsiFitting}
230
+ */
231
+ export function save_esi_fitting(fit) {
232
+ const ret = wasm.save_esi_fitting(fit);
233
+ if (ret[2]) {
234
+ throw takeFromExternrefTable0(ret[1]);
235
+ }
236
+ return takeFromExternrefTable0(ret[0]);
237
+ }
238
+
103
239
  export function set_panic_hook() {
104
240
  wasm.set_panic_hook();
105
241
  }
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.2.0",
9
9
  "license": "MIT",
10
10
  "repository": {
11
11
  "type": "git",