@eveshipfit/dogma-engine 8.0.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/LICENSE +19 -0
- package/README.md +96 -0
- package/esf_dogma_engine.d.ts +12 -0
- package/esf_dogma_engine.js +9 -0
- package/esf_dogma_engine_bg.js +449 -0
- package/esf_dogma_engine_bg.wasm +0 -0
- package/package.json +26 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2023 EVEShipFit Team
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# EVEShip.fit's Dogma Engine
|
|
2
|
+
|
|
3
|
+
This library calculates accurately statistics of an EVE Online ship fit.
|
|
4
|
+
|
|
5
|
+
The input are several data-files provided by EVE Online, together with a ship fit.
|
|
6
|
+
The output are all the Dogma attributes, containing all the details of the ship.
|
|
7
|
+
|
|
8
|
+
## Implementation
|
|
9
|
+
|
|
10
|
+
This Dogma engine implements a multi-pass approach.
|
|
11
|
+
|
|
12
|
+
- [pass 1](./src/calculate/pass_1.rs): collect all the Dogma attributes of the hull and modules.
|
|
13
|
+
- [pass 2](./src/calculate/pass_2.rs): collect all the Dogma effects of the hull and modules.
|
|
14
|
+
- [pass 3](./src/calculate/pass_3.rs): apply all the Dogma effects to the hull/modules, calculating the actual Dogma attribute values.
|
|
15
|
+
- [pass 4](./src/calculate/pass_4.rs): augment the Dogma attributes with EVEShip.fit specific attributes, that are too complex for the Dogma itself to handle.
|
|
16
|
+
|
|
17
|
+
## EVEShip.fit's specific attributes
|
|
18
|
+
|
|
19
|
+
`Pass 4` create Dogma attributes that do not exist in-game, but are rather complicated to calculate.
|
|
20
|
+
To make rendering a fit easier, these are calculated by this library, and presented as new Dogma attributes.
|
|
21
|
+
|
|
22
|
+
Their identifier is always a negative value, to visually separate them.
|
|
23
|
+
What additional attributes exist are defined in [EVEShipFit/sde-patched](https://github.com/EVEShipFit/sde-patched) repository.
|
|
24
|
+
|
|
25
|
+
## Development
|
|
26
|
+
|
|
27
|
+
Make sure you have [Rust installed](https://www.rust-lang.org/tools/install).
|
|
28
|
+
|
|
29
|
+
Next, we need the data-files.
|
|
30
|
+
They are Flatbuffers, built by [sde-patched](https://github.com/EVEShipFit/sde-patched) and published on npm as [`@eveshipfit/sde`](https://www.npmjs.com/package/@eveshipfit/sde):
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npm ci
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
- `sde.dat` holds everything needed to calculate a fit.
|
|
37
|
+
- `names.dat` holds the type names in the other seven languages EVE supports.
|
|
38
|
+
It is optional.
|
|
39
|
+
|
|
40
|
+
English names live in `sde.dat`, so an EFT-fit written in English imports without it; `names.dat` is only consulted when a name does not match.
|
|
41
|
+
|
|
42
|
+
After that, we can run the application.
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
flatc --rust --gen-onefile -o src/sde/ node_modules/@eveshipfit/sde/specs/eve.fbs node_modules/@eveshipfit/sde/specs/names.fbs
|
|
46
|
+
cargo run --release --no-default-features --features rust
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
The regression suite reads the same paths; set `ESF_SDE` and `ESF_NAMES` to point it elsewhere.
|
|
50
|
+
|
|
51
|
+
## Regression
|
|
52
|
+
|
|
53
|
+
The engine is locked down by snapshot tests.
|
|
54
|
+
A case calculates one fit with one set of skills, and compares the result against a stored snapshot in [tests/snapshots](./tests/snapshots).
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
cargo test
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
If failures are expected differences, use `insta` to resolve them:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
cargo install cargo-insta
|
|
64
|
+
cargo insta review
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Integration
|
|
68
|
+
|
|
69
|
+
### Javascript (WebAssembly)
|
|
70
|
+
|
|
71
|
+
The primary goal of this library is to build a WebAssembly variant that can easily be used in the browser.
|
|
72
|
+
This means that there is no need for a server-component, and everything can be calculated in the browser.
|
|
73
|
+
|
|
74
|
+
This is done with [wasm-pack](https://rustwasm.github.io/wasm-pack/):
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
cargo install wasm-pack
|
|
78
|
+
wasm-pack build --release -- --no-default-features --features wasm
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
In the `pkg` folder is now a NPM module to use.
|
|
82
|
+
|
|
83
|
+
Javascript hands over `sde.dat` once, and every lookup after that happens inside WebAssembly.
|
|
84
|
+
The file is a Flatbuffer, so nothing is parsed: the bytes are used where they land.
|
|
85
|
+
|
|
86
|
+
```js
|
|
87
|
+
import init, { init as initPanicHook, load_sde, calculate } from "@eveshipfit/dogma-engine";
|
|
88
|
+
|
|
89
|
+
await init();
|
|
90
|
+
initPanicHook();
|
|
91
|
+
|
|
92
|
+
const sde = await fetch("/sde.dat").then((response) => response.arrayBuffer());
|
|
93
|
+
const buildNumber = load_sde(new Uint8Array(sde));
|
|
94
|
+
|
|
95
|
+
const statistics = calculate(fit, skills);
|
|
96
|
+
```
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
export function calculate(js_esf_fit: any, js_skills: any): any;
|
|
5
|
+
|
|
6
|
+
export function init(): void;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Load `sde.dat`. Has to be called before `calculate`; calling it twice is an
|
|
10
|
+
* error, as the first buffer is borrowed for the rest of the session.
|
|
11
|
+
*/
|
|
12
|
+
export function load_sde(bytes: Uint8Array): number;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/* @ts-self-types="./esf_dogma_engine.d.ts" */
|
|
2
|
+
import * as wasm from "./esf_dogma_engine_bg.wasm";
|
|
3
|
+
import { __wbg_set_wasm } from "./esf_dogma_engine_bg.js";
|
|
4
|
+
|
|
5
|
+
__wbg_set_wasm(wasm);
|
|
6
|
+
wasm.__wbindgen_start();
|
|
7
|
+
export {
|
|
8
|
+
calculate, init, load_sde
|
|
9
|
+
} from "./esf_dogma_engine_bg.js";
|
|
@@ -0,0 +1,449 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {any} js_esf_fit
|
|
3
|
+
* @param {any} js_skills
|
|
4
|
+
* @returns {any}
|
|
5
|
+
*/
|
|
6
|
+
export function calculate(js_esf_fit, js_skills) {
|
|
7
|
+
const ret = wasm.calculate(js_esf_fit, js_skills);
|
|
8
|
+
if (ret[2]) {
|
|
9
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
10
|
+
}
|
|
11
|
+
return takeFromExternrefTable0(ret[0]);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function init() {
|
|
15
|
+
wasm.init();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Load `sde.dat`. Has to be called before `calculate`; calling it twice is an
|
|
20
|
+
* error, as the first buffer is borrowed for the rest of the session.
|
|
21
|
+
* @param {Uint8Array} bytes
|
|
22
|
+
* @returns {number}
|
|
23
|
+
*/
|
|
24
|
+
export function load_sde(bytes) {
|
|
25
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
26
|
+
const len0 = WASM_VECTOR_LEN;
|
|
27
|
+
const ret = wasm.load_sde(ptr0, len0);
|
|
28
|
+
if (ret[2]) {
|
|
29
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
30
|
+
}
|
|
31
|
+
return ret[0];
|
|
32
|
+
}
|
|
33
|
+
export function __wbg_Error_67e7344beaa85059(arg0, arg1) {
|
|
34
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
35
|
+
return ret;
|
|
36
|
+
}
|
|
37
|
+
export function __wbg_Number_c54e7112a3fa7e3e(arg0) {
|
|
38
|
+
const ret = Number(arg0);
|
|
39
|
+
return ret;
|
|
40
|
+
}
|
|
41
|
+
export function __wbg_String_8564e559799eccda(arg0, arg1) {
|
|
42
|
+
const ret = String(arg1);
|
|
43
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
44
|
+
const len1 = WASM_VECTOR_LEN;
|
|
45
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
46
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
47
|
+
}
|
|
48
|
+
export function __wbg___wbindgen_boolean_get_7a12af2b3f899c5a(arg0) {
|
|
49
|
+
const v = arg0;
|
|
50
|
+
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
51
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
52
|
+
}
|
|
53
|
+
export function __wbg___wbindgen_debug_string_0e68cf47c9cbd9b0(arg0, arg1) {
|
|
54
|
+
const ret = debugString(arg1);
|
|
55
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
56
|
+
const len1 = WASM_VECTOR_LEN;
|
|
57
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
58
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
59
|
+
}
|
|
60
|
+
export function __wbg___wbindgen_in_50072d4d6e45c193(arg0, arg1) {
|
|
61
|
+
const ret = arg0 in arg1;
|
|
62
|
+
return ret;
|
|
63
|
+
}
|
|
64
|
+
export function __wbg___wbindgen_is_function_fcda5e3902d732fe(arg0) {
|
|
65
|
+
const ret = typeof(arg0) === 'function';
|
|
66
|
+
return ret;
|
|
67
|
+
}
|
|
68
|
+
export function __wbg___wbindgen_is_object_edb6b15aa3afe12e(arg0) {
|
|
69
|
+
const val = arg0;
|
|
70
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
71
|
+
return ret;
|
|
72
|
+
}
|
|
73
|
+
export function __wbg___wbindgen_is_string_c4f7cb494a2a21f1(arg0) {
|
|
74
|
+
const ret = typeof(arg0) === 'string';
|
|
75
|
+
return ret;
|
|
76
|
+
}
|
|
77
|
+
export function __wbg___wbindgen_is_undefined_8c687d0b90d5b524(arg0) {
|
|
78
|
+
const ret = arg0 === undefined;
|
|
79
|
+
return ret;
|
|
80
|
+
}
|
|
81
|
+
export function __wbg___wbindgen_jsval_loose_eq_3c30021c243b64cd(arg0, arg1) {
|
|
82
|
+
const ret = arg0 == arg1;
|
|
83
|
+
return ret;
|
|
84
|
+
}
|
|
85
|
+
export function __wbg___wbindgen_number_get_1dc732b810cb937c(arg0, arg1) {
|
|
86
|
+
const obj = arg1;
|
|
87
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
88
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
89
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
90
|
+
}
|
|
91
|
+
export function __wbg___wbindgen_string_get_92ab86bb19cbc12f(arg0, arg1) {
|
|
92
|
+
const obj = arg1;
|
|
93
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
94
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
95
|
+
var len1 = WASM_VECTOR_LEN;
|
|
96
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
97
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
98
|
+
}
|
|
99
|
+
export function __wbg___wbindgen_throw_5d9e815e6fdf150f(arg0, arg1) {
|
|
100
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
101
|
+
}
|
|
102
|
+
export function __wbg_call_269c5566fbede3eb() { return handleError(function (arg0, arg1) {
|
|
103
|
+
const ret = arg0.call(arg1);
|
|
104
|
+
return ret;
|
|
105
|
+
}, arguments); }
|
|
106
|
+
export function __wbg_done_cffed884d87aa22e(arg0) {
|
|
107
|
+
const ret = arg0.done;
|
|
108
|
+
return ret;
|
|
109
|
+
}
|
|
110
|
+
export function __wbg_entries_972a87586902cf87(arg0) {
|
|
111
|
+
const ret = Object.entries(arg0);
|
|
112
|
+
return ret;
|
|
113
|
+
}
|
|
114
|
+
export function __wbg_error_757e9472f8410341(arg0, arg1) {
|
|
115
|
+
let deferred0_0;
|
|
116
|
+
let deferred0_1;
|
|
117
|
+
try {
|
|
118
|
+
deferred0_0 = arg0;
|
|
119
|
+
deferred0_1 = arg1;
|
|
120
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
121
|
+
} finally {
|
|
122
|
+
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
export function __wbg_get_6cf5a4d4d8ad3c5a() { return handleError(function (arg0, arg1) {
|
|
126
|
+
const ret = Reflect.get(arg0, arg1);
|
|
127
|
+
return ret;
|
|
128
|
+
}, arguments); }
|
|
129
|
+
export function __wbg_get_b1f0ab13c737f856(arg0, arg1) {
|
|
130
|
+
const ret = arg0[arg1 >>> 0];
|
|
131
|
+
return ret;
|
|
132
|
+
}
|
|
133
|
+
export function __wbg_get_unchecked_363572bdd397d473(arg0, arg1) {
|
|
134
|
+
const ret = arg0[arg1 >>> 0];
|
|
135
|
+
return ret;
|
|
136
|
+
}
|
|
137
|
+
export function __wbg_get_with_ref_key_6412cf3094599694(arg0, arg1) {
|
|
138
|
+
const ret = arg0[arg1];
|
|
139
|
+
return ret;
|
|
140
|
+
}
|
|
141
|
+
export function __wbg_instanceof_ArrayBuffer_d4ff01f8247925ae(arg0) {
|
|
142
|
+
let result;
|
|
143
|
+
try {
|
|
144
|
+
result = arg0 instanceof ArrayBuffer;
|
|
145
|
+
} catch (_) {
|
|
146
|
+
result = false;
|
|
147
|
+
}
|
|
148
|
+
const ret = result;
|
|
149
|
+
return ret;
|
|
150
|
+
}
|
|
151
|
+
export function __wbg_instanceof_Uint8Array_598adc0fef426aa8(arg0) {
|
|
152
|
+
let result;
|
|
153
|
+
try {
|
|
154
|
+
result = arg0 instanceof Uint8Array;
|
|
155
|
+
} catch (_) {
|
|
156
|
+
result = false;
|
|
157
|
+
}
|
|
158
|
+
const ret = result;
|
|
159
|
+
return ret;
|
|
160
|
+
}
|
|
161
|
+
export function __wbg_isArray_5674713bb7b79043(arg0) {
|
|
162
|
+
const ret = Array.isArray(arg0);
|
|
163
|
+
return ret;
|
|
164
|
+
}
|
|
165
|
+
export function __wbg_isSafeInteger_8f51c743827d1ec5(arg0) {
|
|
166
|
+
const ret = Number.isSafeInteger(arg0);
|
|
167
|
+
return ret;
|
|
168
|
+
}
|
|
169
|
+
export function __wbg_iterator_22ddeb808cf55a6f() {
|
|
170
|
+
const ret = Symbol.iterator;
|
|
171
|
+
return ret;
|
|
172
|
+
}
|
|
173
|
+
export function __wbg_length_31bdaf014f5fbde2(arg0) {
|
|
174
|
+
const ret = arg0.length;
|
|
175
|
+
return ret;
|
|
176
|
+
}
|
|
177
|
+
export function __wbg_length_4e1adc0d42e23620(arg0) {
|
|
178
|
+
const ret = arg0.length;
|
|
179
|
+
return ret;
|
|
180
|
+
}
|
|
181
|
+
export function __wbg_new_1da3429bc3c4541c(arg0) {
|
|
182
|
+
const ret = new Uint8Array(arg0);
|
|
183
|
+
return ret;
|
|
184
|
+
}
|
|
185
|
+
export function __wbg_new_227d7c05414eb861() {
|
|
186
|
+
const ret = new Error();
|
|
187
|
+
return ret;
|
|
188
|
+
}
|
|
189
|
+
export function __wbg_new_8d36e20aa758e411() {
|
|
190
|
+
const ret = new Map();
|
|
191
|
+
return ret;
|
|
192
|
+
}
|
|
193
|
+
export function __wbg_new_bebc3f4757acf305() {
|
|
194
|
+
const ret = new Object();
|
|
195
|
+
return ret;
|
|
196
|
+
}
|
|
197
|
+
export function __wbg_new_ffa92086ea89f79c() {
|
|
198
|
+
const ret = new Array();
|
|
199
|
+
return ret;
|
|
200
|
+
}
|
|
201
|
+
export function __wbg_next_95053e306b1c3aed(arg0) {
|
|
202
|
+
const ret = arg0.next;
|
|
203
|
+
return ret;
|
|
204
|
+
}
|
|
205
|
+
export function __wbg_next_f31ecb8646d2c605() { return handleError(function (arg0) {
|
|
206
|
+
const ret = arg0.next();
|
|
207
|
+
return ret;
|
|
208
|
+
}, arguments); }
|
|
209
|
+
export function __wbg_prototypesetcall_ae9f5e7459250748(arg0, arg1, arg2) {
|
|
210
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
211
|
+
}
|
|
212
|
+
export function __wbg_set_13d25b81ab403f5e(arg0, arg1, arg2) {
|
|
213
|
+
arg0[arg1 >>> 0] = arg2;
|
|
214
|
+
}
|
|
215
|
+
export function __wbg_set_6be42768c690e380(arg0, arg1, arg2) {
|
|
216
|
+
arg0[arg1] = arg2;
|
|
217
|
+
}
|
|
218
|
+
export function __wbg_set_bf6dde4923b9b059(arg0, arg1, arg2) {
|
|
219
|
+
const ret = arg0.set(arg1, arg2);
|
|
220
|
+
return ret;
|
|
221
|
+
}
|
|
222
|
+
export function __wbg_stack_3b0d974bbf31e44f(arg0, arg1) {
|
|
223
|
+
const ret = arg1.stack;
|
|
224
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
225
|
+
const len1 = WASM_VECTOR_LEN;
|
|
226
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
227
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
228
|
+
}
|
|
229
|
+
export function __wbg_value_c227f843d21da141(arg0) {
|
|
230
|
+
const ret = arg0.value;
|
|
231
|
+
return ret;
|
|
232
|
+
}
|
|
233
|
+
export function __wbindgen_generic_0000000000000001(arg0) {
|
|
234
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
235
|
+
const ret = arg0;
|
|
236
|
+
return ret;
|
|
237
|
+
}
|
|
238
|
+
export function __wbindgen_generic_0000000000000002(arg0, arg1) {
|
|
239
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
240
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
241
|
+
return ret;
|
|
242
|
+
}
|
|
243
|
+
export function __wbindgen_generic_0000000000000003(arg0) {
|
|
244
|
+
// Cast intrinsic for `U64 -> Externref`.
|
|
245
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
246
|
+
return ret;
|
|
247
|
+
}
|
|
248
|
+
export function __wbindgen_init_externref_table() {
|
|
249
|
+
const table = wasm.__wbindgen_externrefs;
|
|
250
|
+
const offset = table.grow(4);
|
|
251
|
+
table.set(0, undefined);
|
|
252
|
+
table.set(offset + 0, undefined);
|
|
253
|
+
table.set(offset + 1, null);
|
|
254
|
+
table.set(offset + 2, true);
|
|
255
|
+
table.set(offset + 3, false);
|
|
256
|
+
}
|
|
257
|
+
function addToExternrefTable0(obj) {
|
|
258
|
+
const idx = wasm.__externref_table_alloc();
|
|
259
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
260
|
+
return idx;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
function debugString(val) {
|
|
264
|
+
// primitive types
|
|
265
|
+
const type = typeof val;
|
|
266
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
267
|
+
return `${val}`;
|
|
268
|
+
}
|
|
269
|
+
if (type == 'string') {
|
|
270
|
+
return `"${val}"`;
|
|
271
|
+
}
|
|
272
|
+
if (type == 'symbol') {
|
|
273
|
+
const description = val.description;
|
|
274
|
+
if (description == null) {
|
|
275
|
+
return 'Symbol';
|
|
276
|
+
} else {
|
|
277
|
+
return `Symbol(${description})`;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
if (type == 'function') {
|
|
281
|
+
const name = val.name;
|
|
282
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
283
|
+
return `Function(${name})`;
|
|
284
|
+
} else {
|
|
285
|
+
return 'Function';
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
// objects
|
|
289
|
+
if (Array.isArray(val)) {
|
|
290
|
+
const length = val.length;
|
|
291
|
+
let debug = '[';
|
|
292
|
+
if (length > 0) {
|
|
293
|
+
debug += debugString(val[0]);
|
|
294
|
+
}
|
|
295
|
+
for(let i = 1; i < length; i++) {
|
|
296
|
+
debug += ', ' + debugString(val[i]);
|
|
297
|
+
}
|
|
298
|
+
debug += ']';
|
|
299
|
+
return debug;
|
|
300
|
+
}
|
|
301
|
+
// Test for built-in
|
|
302
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
303
|
+
let className;
|
|
304
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
305
|
+
className = builtInMatches[1];
|
|
306
|
+
} else {
|
|
307
|
+
// Failed to match the standard '[object ClassName]'
|
|
308
|
+
return toString.call(val);
|
|
309
|
+
}
|
|
310
|
+
if (className == 'Object') {
|
|
311
|
+
// we're a user defined class or Object
|
|
312
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
313
|
+
// easier than looping through ownProperties of `val`.
|
|
314
|
+
try {
|
|
315
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
316
|
+
} catch (_) {
|
|
317
|
+
return 'Object';
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
// errors
|
|
321
|
+
if (val instanceof Error) {
|
|
322
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
323
|
+
}
|
|
324
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
325
|
+
return className;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
329
|
+
ptr = ptr >>> 0;
|
|
330
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
let cachedDataViewMemory0 = null;
|
|
334
|
+
function getDataViewMemory0() {
|
|
335
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
336
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
337
|
+
}
|
|
338
|
+
return cachedDataViewMemory0;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
function getStringFromWasm0(ptr, len) {
|
|
342
|
+
return decodeText(ptr >>> 0, len);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
let cachedUint8ArrayMemory0 = null;
|
|
346
|
+
function getUint8ArrayMemory0() {
|
|
347
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
348
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
349
|
+
}
|
|
350
|
+
return cachedUint8ArrayMemory0;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
function handleError(f, args) {
|
|
354
|
+
try {
|
|
355
|
+
return f.apply(this, args);
|
|
356
|
+
} catch (e) {
|
|
357
|
+
const idx = addToExternrefTable0(e);
|
|
358
|
+
wasm.__wbindgen_exn_store(idx);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
function isLikeNone(x) {
|
|
363
|
+
return x === undefined || x === null;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
367
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
368
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
369
|
+
WASM_VECTOR_LEN = arg.length;
|
|
370
|
+
return ptr;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
374
|
+
if (realloc === undefined) {
|
|
375
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
376
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
377
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
378
|
+
WASM_VECTOR_LEN = buf.length;
|
|
379
|
+
return ptr;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
let len = arg.length;
|
|
383
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
384
|
+
|
|
385
|
+
const mem = getUint8ArrayMemory0();
|
|
386
|
+
|
|
387
|
+
let offset = 0;
|
|
388
|
+
|
|
389
|
+
for (; offset < len; offset++) {
|
|
390
|
+
const code = arg.charCodeAt(offset);
|
|
391
|
+
if (code > 0x7F) break;
|
|
392
|
+
mem[ptr + offset] = code;
|
|
393
|
+
}
|
|
394
|
+
if (offset !== len) {
|
|
395
|
+
if (offset !== 0) {
|
|
396
|
+
arg = arg.slice(offset);
|
|
397
|
+
}
|
|
398
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
399
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
400
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
401
|
+
|
|
402
|
+
offset += ret.written;
|
|
403
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
WASM_VECTOR_LEN = offset;
|
|
407
|
+
return ptr;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
function takeFromExternrefTable0(idx) {
|
|
411
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
412
|
+
wasm.__externref_table_dealloc(idx);
|
|
413
|
+
return value;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
417
|
+
cachedTextDecoder.decode();
|
|
418
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
419
|
+
let numBytesDecoded = 0;
|
|
420
|
+
function decodeText(ptr, len) {
|
|
421
|
+
numBytesDecoded += len;
|
|
422
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
423
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
424
|
+
cachedTextDecoder.decode();
|
|
425
|
+
numBytesDecoded = len;
|
|
426
|
+
}
|
|
427
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
const cachedTextEncoder = new TextEncoder();
|
|
431
|
+
|
|
432
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
433
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
434
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
435
|
+
view.set(buf);
|
|
436
|
+
return {
|
|
437
|
+
read: arg.length,
|
|
438
|
+
written: buf.length
|
|
439
|
+
};
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
let WASM_VECTOR_LEN = 0;
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
let wasm;
|
|
447
|
+
export function __wbg_set_wasm(val) {
|
|
448
|
+
wasm = val;
|
|
449
|
+
}
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@eveshipfit/dogma-engine",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"collaborators": [
|
|
5
|
+
"EVEShipFit Team <info@eveship.fit>"
|
|
6
|
+
],
|
|
7
|
+
"description": "Library to calculate statistics for EVE Online ship fits",
|
|
8
|
+
"version": "8.0.0",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/EVEShipFit/dogma-engine"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"esf_dogma_engine_bg.wasm",
|
|
16
|
+
"esf_dogma_engine.js",
|
|
17
|
+
"esf_dogma_engine_bg.js",
|
|
18
|
+
"esf_dogma_engine.d.ts"
|
|
19
|
+
],
|
|
20
|
+
"main": "esf_dogma_engine.js",
|
|
21
|
+
"types": "esf_dogma_engine.d.ts",
|
|
22
|
+
"sideEffects": [
|
|
23
|
+
"./esf_dogma_engine.js",
|
|
24
|
+
"./snippets/*"
|
|
25
|
+
]
|
|
26
|
+
}
|