ballistics-engine 0.32.0 → 0.33.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.
@@ -1,684 +1,9 @@
1
1
  /* @ts-self-types="./ballistics_engine.d.ts" */
2
-
3
- /**
4
- * Object-oriented calculator for programmatic use
5
- * Provides a type-safe, fluent API alternative to the CLI interface
6
- */
7
- export class Calculator {
8
- static __wrap(ptr) {
9
- const obj = Object.create(Calculator.prototype);
10
- obj.__wbg_ptr = ptr;
11
- CalculatorFinalization.register(obj, obj.__wbg_ptr, obj);
12
- return obj;
13
- }
14
- __destroy_into_raw() {
15
- const ptr = this.__wbg_ptr;
16
- this.__wbg_ptr = 0;
17
- CalculatorFinalization.unregister(this);
18
- return ptr;
19
- }
20
- free() {
21
- const ptr = this.__destroy_into_raw();
22
- wasm.__wbg_calculator_free(ptr, 0);
23
- }
24
- /**
25
- * Add a downrange wind segment: `speed_mph` from `direction_deg`
26
- * (wind-FROM: 0 = headwind, 90 = from the right) out to `until_yards`.
27
- * Each segment applies from the previous boundary to `until_yards`; wind is
28
- * zero beyond the last segment. When any segment is added it overrides the
29
- * scalar `setWind` value. Repeatable.
30
- * @param {number} speed_mph
31
- * @param {number} direction_deg
32
- * @param {number} until_yards
33
- * @returns {Calculator}
34
- */
35
- addWindSegment(speed_mph, direction_deg, until_yards) {
36
- const ptr = this.__destroy_into_raw();
37
- const ret = wasm.calculator_addWindSegment(ptr, speed_mph, direction_deg, until_yards);
38
- return Calculator.__wrap(ret);
39
- }
40
- /**
41
- * Calculate trajectory and return result as JavaScript object
42
- * Returns: { range_yards, drop_inches, windage_inches, velocity_fps, energy_ftlb, time_sec }
43
- * @param {number} range_yards
44
- * @returns {any}
45
- */
46
- calculateTrajectory(range_yards) {
47
- const ret = wasm.calculator_calculateTrajectory(this.__wbg_ptr, range_yards);
48
- if (ret[2]) {
49
- throw takeFromExternrefTable0(ret[1]);
50
- }
51
- return takeFromExternrefTable0(ret[0]);
52
- }
53
- /**
54
- * Remove all downrange wind segments (reverts to the scalar `setWind`).
55
- * @returns {Calculator}
56
- */
57
- clearWindSegments() {
58
- const ptr = this.__destroy_into_raw();
59
- const ret = wasm.calculator_clearWindSegments(ptr);
60
- return Calculator.__wrap(ret);
61
- }
62
- /**
63
- * @param {boolean} enabled
64
- * @param {number | null} [latitude]
65
- * @returns {Calculator}
66
- */
67
- enableCoriolis(enabled, latitude) {
68
- const ptr = this.__destroy_into_raw();
69
- const ret = wasm.calculator_enableCoriolis(ptr, enabled, !isLikeNone(latitude), isLikeNone(latitude) ? 0 : latitude);
70
- return Calculator.__wrap(ret);
71
- }
72
- /**
73
- * @param {boolean} enabled
74
- * @param {number | null} [twist_rate]
75
- * @returns {Calculator}
76
- */
77
- enableSpinDrift(enabled, twist_rate) {
78
- const ptr = this.__destroy_into_raw();
79
- const ret = wasm.calculator_enableSpinDrift(ptr, enabled, !isLikeNone(twist_rate), isLikeNone(twist_rate) ? 0 : twist_rate);
80
- return Calculator.__wrap(ret);
81
- }
82
- /**
83
- * Get full trajectory table as array of points
84
- * Returns array of: [{ range_yards, drop_inches, windage_inches, velocity_fps, energy_ftlb, time_sec }, ...]
85
- * @returns {any}
86
- */
87
- getFullTrajectory() {
88
- const ret = wasm.calculator_getFullTrajectory(this.__wbg_ptr);
89
- if (ret[2]) {
90
- throw takeFromExternrefTable0(ret[1]);
91
- }
92
- return takeFromExternrefTable0(ret[0]);
93
- }
94
- /**
95
- * Create a new calculator with default values
96
- * Defaults: .308 Winchester 168gr at 2700 fps, standard atmosphere
97
- */
98
- constructor() {
99
- const ret = wasm.calculator_new();
100
- this.__wbg_ptr = ret;
101
- CalculatorFinalization.register(this, this.__wbg_ptr, this);
102
- return this;
103
- }
104
- /**
105
- * @param {number} altitude_ft
106
- * @returns {Calculator}
107
- */
108
- setAltitude(altitude_ft) {
109
- const ptr = this.__destroy_into_raw();
110
- const ret = wasm.calculator_setAltitude(ptr, altitude_ft);
111
- return Calculator.__wrap(ret);
112
- }
113
- /**
114
- * @param {number} bc
115
- * @returns {Calculator}
116
- */
117
- setBC(bc) {
118
- const ptr = this.__destroy_into_raw();
119
- const ret = wasm.calculator_setBC(ptr, bc);
120
- return Calculator.__wrap(ret);
121
- }
122
- /**
123
- * @param {number} diameter_inches
124
- * @returns {Calculator}
125
- */
126
- setDiameter(diameter_inches) {
127
- const ptr = this.__destroy_into_raw();
128
- const ret = wasm.calculator_setDiameter(ptr, diameter_inches);
129
- return Calculator.__wrap(ret);
130
- }
131
- /**
132
- * @param {string} model
133
- * @returns {Calculator}
134
- */
135
- setDragModel(model) {
136
- const ptr = this.__destroy_into_raw();
137
- const ptr0 = passStringToWasm0(model, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
138
- const len0 = WASM_VECTOR_LEN;
139
- const ret = wasm.calculator_setDragModel(ptr, ptr0, len0);
140
- return Calculator.__wrap(ret);
141
- }
142
- /**
143
- * @param {number} humidity
144
- * @returns {Calculator}
145
- */
146
- setHumidity(humidity) {
147
- const ptr = this.__destroy_into_raw();
148
- const ret = wasm.calculator_setHumidity(ptr, humidity);
149
- return Calculator.__wrap(ret);
150
- }
151
- /**
152
- * @param {number} mass_grains
153
- * @returns {Calculator}
154
- */
155
- setMass(mass_grains) {
156
- const ptr = this.__destroy_into_raw();
157
- const ret = wasm.calculator_setMass(ptr, mass_grains);
158
- return Calculator.__wrap(ret);
159
- }
160
- /**
161
- * @param {number} range_yards
162
- * @returns {Calculator}
163
- */
164
- setMaxRange(range_yards) {
165
- const ptr = this.__destroy_into_raw();
166
- const ret = wasm.calculator_setMaxRange(ptr, range_yards);
167
- return Calculator.__wrap(ret);
168
- }
169
- /**
170
- * @param {number} pressure_inhg
171
- * @returns {Calculator}
172
- */
173
- setPressure(pressure_inhg) {
174
- const ptr = this.__destroy_into_raw();
175
- const ret = wasm.calculator_setPressure(ptr, pressure_inhg);
176
- return Calculator.__wrap(ret);
177
- }
178
- /**
179
- * MBA-1368: compass bearing of the shot (degrees, 0 = north, 90 = east) —
180
- * required by `setWindReference("compass")`; also feeds Coriolis when enabled.
181
- * @param {number} bearing_deg
182
- * @returns {Calculator}
183
- */
184
- setShotDirection(bearing_deg) {
185
- const ptr = this.__destroy_into_raw();
186
- const ret = wasm.calculator_setShotDirection(ptr, bearing_deg);
187
- return Calculator.__wrap(ret);
188
- }
189
- /**
190
- * @param {number} height_inches
191
- * @returns {Calculator}
192
- */
193
- setSightHeight(height_inches) {
194
- const ptr = this.__destroy_into_raw();
195
- const ret = wasm.calculator_setSightHeight(ptr, height_inches);
196
- return Calculator.__wrap(ret);
197
- }
198
- /**
199
- * @param {number} temp_f
200
- * @returns {Calculator}
201
- */
202
- setTemperature(temp_f) {
203
- const ptr = this.__destroy_into_raw();
204
- const ret = wasm.calculator_setTemperature(ptr, temp_f);
205
- return Calculator.__wrap(ret);
206
- }
207
- /**
208
- * @param {number} velocity_fps
209
- * @returns {Calculator}
210
- */
211
- setVelocity(velocity_fps) {
212
- const ptr = this.__destroy_into_raw();
213
- const ret = wasm.calculator_setVelocity(ptr, velocity_fps);
214
- return Calculator.__wrap(ret);
215
- }
216
- /**
217
- * @param {number} speed_mph
218
- * @param {number} direction_deg
219
- * @returns {Calculator}
220
- */
221
- setWind(speed_mph, direction_deg) {
222
- const ptr = this.__destroy_into_raw();
223
- const ret = wasm.calculator_setWind(ptr, speed_mph, direction_deg);
224
- return Calculator.__wrap(ret);
225
- }
226
- /**
227
- * MBA-1368: choose the wind entry frame — "shooter" (default; wind-FROM angles
228
- * relative to the line of fire) or "compass" (earth-fixed bearings, 0 = north,
229
- * covering `setWind` AND every `addWindSegment` direction, re-referenced against
230
- * the shot azimuth at solve time). Compass mode requires `setShotDirection`;
231
- * invalid values surface when the command runs. Additive method — no existing
232
- * signature changed.
233
- * @param {string} mode
234
- * @returns {Calculator}
235
- */
236
- setWindReference(mode) {
237
- const ptr = this.__destroy_into_raw();
238
- const ptr0 = passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
239
- const len0 = WASM_VECTOR_LEN;
240
- const ret = wasm.calculator_setWindReference(ptr, ptr0, len0);
241
- return Calculator.__wrap(ret);
242
- }
243
- /**
244
- * @param {number} range_yards
245
- * @returns {Calculator}
246
- */
247
- setZeroRange(range_yards) {
248
- const ptr = this.__destroy_into_raw();
249
- const ret = wasm.calculator_setZeroRange(ptr, range_yards);
250
- return Calculator.__wrap(ret);
251
- }
252
- }
253
- if (Symbol.dispose) Calculator.prototype[Symbol.dispose] = Calculator.prototype.free;
254
-
255
- export class WasmBallistics {
256
- __destroy_into_raw() {
257
- const ptr = this.__wbg_ptr;
258
- this.__wbg_ptr = 0;
259
- WasmBallisticsFinalization.unregister(this);
260
- return ptr;
261
- }
262
- free() {
263
- const ptr = this.__destroy_into_raw();
264
- wasm.__wbg_wasmballistics_free(ptr, 0);
265
- }
266
- /**
267
- * Unload any custom drag table previously installed via [`Self::load_drag_table`],
268
- * reverting every subsequent `trajectory`, `zero`, `lead`, and `monte-carlo` run to the
269
- * standard G-model + BC drag (the `-b`/`--bc` value with the selected G1/G7 curve).
270
- *
271
- * The inverse of `loadDragTable`. It lets a single engine instance alternate between a
272
- * measured-curve (CDM) solve and a plain G7-BC solve without constructing a second
273
- * instance: `load → solve CDM → clear → solve G7`, with the G7 half uncontaminated —
274
- * the same load/clear pattern `clearWindSegments` provides for segmented wind.
275
- *
276
- * Returns `true` if a table was loaded (and is now cleared), `false` if none was loaded
277
- * (a harmless no-op). Idempotent.
278
- * @returns {boolean}
279
- */
280
- clearDragTable() {
281
- const ret = wasm.wasmballistics_clearDragTable(this.__wbg_ptr);
282
- return ret !== 0;
283
- }
284
- /**
285
- * Report whether a BC5D table is currently loaded.
286
- * @returns {boolean}
287
- */
288
- hasBc5dTable() {
289
- const ret = wasm.wasmballistics_hasBc5dTable(this.__wbg_ptr);
290
- return ret !== 0;
291
- }
292
- /**
293
- * Report whether a custom drag table is currently loaded.
294
- * @returns {boolean}
295
- */
296
- hasDragTable() {
297
- const ret = wasm.wasmballistics_hasDragTable(this.__wbg_ptr);
298
- return ret !== 0;
299
- }
300
- /**
301
- * Load a BC5D correction table from the raw bytes of a `bc5d_<caliber>.bin`
302
- * file. The host (browser `fetch()` or Node `fs`/`fetch`) is responsible
303
- * for retrieving the file — WASM has no filesystem or network — and passes
304
- * the bytes here.
305
- *
306
- * Once loaded, any `trajectory` run that includes `--use-bc-segments` will
307
- * apply velocity-dependent BC segments synthesized from this table. Load a
308
- * table matching the bullet's caliber (e.g. `bc5d_308.bin` for a .308).
309
- *
310
- * Returns a short human-readable summary of the loaded table. Replaces any
311
- * previously loaded table.
312
- * @param {Uint8Array} bytes
313
- * @returns {string}
314
- */
315
- loadBc5dTable(bytes) {
316
- let deferred3_0;
317
- let deferred3_1;
318
- try {
319
- const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
320
- const len0 = WASM_VECTOR_LEN;
321
- const ret = wasm.wasmballistics_loadBc5dTable(this.__wbg_ptr, ptr0, len0);
322
- var ptr2 = ret[0];
323
- var len2 = ret[1];
324
- if (ret[3]) {
325
- ptr2 = 0; len2 = 0;
326
- throw takeFromExternrefTable0(ret[2]);
327
- }
328
- deferred3_0 = ptr2;
329
- deferred3_1 = len2;
330
- return getStringFromWasm0(ptr2, len2);
331
- } finally {
332
- wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
333
- }
334
- }
335
- /**
336
- * Load a custom Mach:Cd drag table (MBA-1328) — a measured or manufacturer-published
337
- * drag curve (Hornady CDM data, a Lapua/Doppler-radar-derived deck, or your own) — from
338
- * the raw bytes of a CSV file. The host (browser `fetch()` or Node `fs`/`fetch`) is
339
- * responsible for retrieving the file — WASM has no filesystem or network — and passes
340
- * the bytes here, mirroring [`Self::load_bc5d_table`].
341
- *
342
- * The bytes must be valid UTF-8 CSV text; parsing is delegated to
343
- * [`crate::drag::DragTable::from_csv_str`] — the SAME parser native `--drag-table`
344
- * uses — so the accepted format is identical: two columns `mach,cd` per line, blank
345
- * lines and `#` comments ignored, a single leading textual header row tolerated, Mach
346
- * strictly ascending with at least 2 points, Cd finite and > 0.
347
- *
348
- * Once loaded, EVERY subsequent `trajectory`, `zero`, `lead`, and `monte-carlo` run
349
- * applies the table automatically — no `--use-*` gate flag is needed (unlike a loaded
350
- * BC5D table, which only takes effect with `--use-bc-segments`). A loaded table is a
351
- * full physical substitute for the G-model + BC (see `calculate_drag_coefficient`):
352
- * `-b`/`--bc` may still be supplied but is ignored for drag once a table is active
353
- * (matching the native `--drag-table` CLI semantics documented in CLI_USAGE.md).
354
- *
355
- * Returns a short human-readable summary of the loaded table (point count + Mach
356
- * range). Replaces any previously loaded table.
357
- *
358
- * MBA-1409: also accepts `.drg` vendor drag-curve text (the same format the native
359
- * `--drag-table` CLI accepts by `.drg` file extension) as a fallback. WASM has no
360
- * filesystem and thus no extension to dispatch on, so the bytes are tried as CSV first
361
- * (exactly as before this change); only on CSV failure, if the text
362
- * [`crate::drag_file::looks_like_drg`], it is retried through
363
- * [`crate::drag_file::parse_drg`]. If both fail, the returned error names both formats.
364
- * @param {Uint8Array} bytes
365
- * @returns {string}
366
- */
367
- loadDragTable(bytes) {
368
- let deferred3_0;
369
- let deferred3_1;
370
- try {
371
- const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
372
- const len0 = WASM_VECTOR_LEN;
373
- const ret = wasm.wasmballistics_loadDragTable(this.__wbg_ptr, ptr0, len0);
374
- var ptr2 = ret[0];
375
- var len2 = ret[1];
376
- if (ret[3]) {
377
- ptr2 = 0; len2 = 0;
378
- throw takeFromExternrefTable0(ret[2]);
379
- }
380
- deferred3_0 = ptr2;
381
- deferred3_1 = len2;
382
- return getStringFromWasm0(ptr2, len2);
383
- } finally {
384
- wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
385
- }
386
- }
387
- constructor() {
388
- const ret = wasm.wasmballistics_new();
389
- this.__wbg_ptr = ret;
390
- WasmBallisticsFinalization.register(this, this.__wbg_ptr, this);
391
- return this;
392
- }
393
- /**
394
- * Run a command and return the output
395
- * @param {string} command
396
- * @returns {string}
397
- */
398
- runCommand(command) {
399
- let deferred3_0;
400
- let deferred3_1;
401
- try {
402
- const ptr0 = passStringToWasm0(command, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
403
- const len0 = WASM_VECTOR_LEN;
404
- const ret = wasm.wasmballistics_runCommand(this.__wbg_ptr, ptr0, len0);
405
- var ptr2 = ret[0];
406
- var len2 = ret[1];
407
- if (ret[3]) {
408
- ptr2 = 0; len2 = 0;
409
- throw takeFromExternrefTable0(ret[2]);
410
- }
411
- deferred3_0 = ptr2;
412
- deferred3_1 = len2;
413
- return getStringFromWasm0(ptr2, len2);
414
- } finally {
415
- wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
416
- }
417
- }
418
- }
419
- if (Symbol.dispose) WasmBallistics.prototype[Symbol.dispose] = WasmBallistics.prototype.free;
420
- function __wbg_get_imports() {
421
- const import0 = {
422
- __proto__: null,
423
- __wbg___wbindgen_throw_344f42d3211c4765: function(arg0, arg1) {
424
- throw new Error(getStringFromWasm0(arg0, arg1));
425
- },
426
- __wbg_getRandomValues_cc7f052a444bb2ce: function() { return handleError(function (arg0, arg1) {
427
- globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
428
- }, arguments); },
429
- __wbg_new_32b398fb48b6d94a: function() {
430
- const ret = new Array();
431
- return ret;
432
- },
433
- __wbg_new_da52cf8fe3429cb2: function() {
434
- const ret = new Object();
435
- return ret;
436
- },
437
- __wbg_push_d2ae3af0c1217ae6: function(arg0, arg1) {
438
- const ret = arg0.push(arg1);
439
- return ret;
440
- },
441
- __wbg_set_8535240470bf2500: function() { return handleError(function (arg0, arg1, arg2) {
442
- const ret = Reflect.set(arg0, arg1, arg2);
443
- return ret;
444
- }, arguments); },
445
- __wbindgen_cast_0000000000000001: function(arg0) {
446
- // Cast intrinsic for `F64 -> Externref`.
447
- const ret = arg0;
448
- return ret;
449
- },
450
- __wbindgen_cast_0000000000000002: function(arg0, arg1) {
451
- // Cast intrinsic for `Ref(String) -> Externref`.
452
- const ret = getStringFromWasm0(arg0, arg1);
453
- return ret;
454
- },
455
- __wbindgen_init_externref_table: function() {
456
- const table = wasm.__wbindgen_externrefs;
457
- const offset = table.grow(4);
458
- table.set(0, undefined);
459
- table.set(offset + 0, undefined);
460
- table.set(offset + 1, null);
461
- table.set(offset + 2, true);
462
- table.set(offset + 3, false);
463
- },
464
- };
465
- return {
466
- __proto__: null,
467
- "./ballistics_engine_bg.js": import0,
468
- };
469
- }
470
-
471
- const CalculatorFinalization = (typeof FinalizationRegistry === 'undefined')
472
- ? { register: () => {}, unregister: () => {} }
473
- : new FinalizationRegistry(ptr => wasm.__wbg_calculator_free(ptr, 1));
474
- const WasmBallisticsFinalization = (typeof FinalizationRegistry === 'undefined')
475
- ? { register: () => {}, unregister: () => {} }
476
- : new FinalizationRegistry(ptr => wasm.__wbg_wasmballistics_free(ptr, 1));
477
-
478
- function addToExternrefTable0(obj) {
479
- const idx = wasm.__externref_table_alloc();
480
- wasm.__wbindgen_externrefs.set(idx, obj);
481
- return idx;
482
- }
483
-
484
- function getArrayU8FromWasm0(ptr, len) {
485
- ptr = ptr >>> 0;
486
- return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
487
- }
488
-
489
- function getStringFromWasm0(ptr, len) {
490
- return decodeText(ptr >>> 0, len);
491
- }
492
-
493
- let cachedUint8ArrayMemory0 = null;
494
- function getUint8ArrayMemory0() {
495
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
496
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
497
- }
498
- return cachedUint8ArrayMemory0;
499
- }
500
-
501
- function handleError(f, args) {
502
- try {
503
- return f.apply(this, args);
504
- } catch (e) {
505
- const idx = addToExternrefTable0(e);
506
- wasm.__wbindgen_exn_store(idx);
507
- }
508
- }
509
-
510
- function isLikeNone(x) {
511
- return x === undefined || x === null;
512
- }
513
-
514
- function passArray8ToWasm0(arg, malloc) {
515
- const ptr = malloc(arg.length * 1, 1) >>> 0;
516
- getUint8ArrayMemory0().set(arg, ptr / 1);
517
- WASM_VECTOR_LEN = arg.length;
518
- return ptr;
519
- }
520
-
521
- function passStringToWasm0(arg, malloc, realloc) {
522
- if (realloc === undefined) {
523
- const buf = cachedTextEncoder.encode(arg);
524
- const ptr = malloc(buf.length, 1) >>> 0;
525
- getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
526
- WASM_VECTOR_LEN = buf.length;
527
- return ptr;
528
- }
529
-
530
- let len = arg.length;
531
- let ptr = malloc(len, 1) >>> 0;
532
-
533
- const mem = getUint8ArrayMemory0();
534
-
535
- let offset = 0;
536
-
537
- for (; offset < len; offset++) {
538
- const code = arg.charCodeAt(offset);
539
- if (code > 0x7F) break;
540
- mem[ptr + offset] = code;
541
- }
542
- if (offset !== len) {
543
- if (offset !== 0) {
544
- arg = arg.slice(offset);
545
- }
546
- ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
547
- const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
548
- const ret = cachedTextEncoder.encodeInto(arg, view);
549
-
550
- offset += ret.written;
551
- ptr = realloc(ptr, len, offset, 1) >>> 0;
552
- }
553
-
554
- WASM_VECTOR_LEN = offset;
555
- return ptr;
556
- }
557
-
558
- function takeFromExternrefTable0(idx) {
559
- const value = wasm.__wbindgen_externrefs.get(idx);
560
- wasm.__externref_table_dealloc(idx);
561
- return value;
562
- }
563
-
564
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
565
- cachedTextDecoder.decode();
566
- const MAX_SAFARI_DECODE_BYTES = 2146435072;
567
- let numBytesDecoded = 0;
568
- function decodeText(ptr, len) {
569
- numBytesDecoded += len;
570
- if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
571
- cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
572
- cachedTextDecoder.decode();
573
- numBytesDecoded = len;
574
- }
575
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
576
- }
577
-
578
- const cachedTextEncoder = new TextEncoder();
579
-
580
- if (!('encodeInto' in cachedTextEncoder)) {
581
- cachedTextEncoder.encodeInto = function (arg, view) {
582
- const buf = cachedTextEncoder.encode(arg);
583
- view.set(buf);
584
- return {
585
- read: arg.length,
586
- written: buf.length
587
- };
588
- };
589
- }
590
-
591
- let WASM_VECTOR_LEN = 0;
592
-
593
- let wasmModule, wasmInstance, wasm;
594
- function __wbg_finalize_init(instance, module) {
595
- wasmInstance = instance;
596
- wasm = instance.exports;
597
- wasmModule = module;
598
- cachedUint8ArrayMemory0 = null;
599
- wasm.__wbindgen_start();
600
- return wasm;
601
- }
602
-
603
- async function __wbg_load(module, imports) {
604
- if (typeof Response === 'function' && module instanceof Response) {
605
- if (typeof WebAssembly.instantiateStreaming === 'function') {
606
- try {
607
- return await WebAssembly.instantiateStreaming(module, imports);
608
- } catch (e) {
609
- const validResponse = module.ok && expectedResponseType(module.type);
610
-
611
- if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
612
- console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
613
-
614
- } else { throw e; }
615
- }
616
- }
617
-
618
- const bytes = await module.arrayBuffer();
619
- return await WebAssembly.instantiate(bytes, imports);
620
- } else {
621
- const instance = await WebAssembly.instantiate(module, imports);
622
-
623
- if (instance instanceof WebAssembly.Instance) {
624
- return { instance, module };
625
- } else {
626
- return instance;
627
- }
628
- }
629
-
630
- function expectedResponseType(type) {
631
- switch (type) {
632
- case 'basic': case 'cors': case 'default': return true;
633
- }
634
- return false;
635
- }
636
- }
637
-
638
- function initSync(module) {
639
- if (wasm !== undefined) return wasm;
640
-
641
-
642
- if (module !== undefined) {
643
- if (Object.getPrototypeOf(module) === Object.prototype) {
644
- ({module} = module)
645
- } else {
646
- console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
647
- }
648
- }
649
-
650
- const imports = __wbg_get_imports();
651
- if (!(module instanceof WebAssembly.Module)) {
652
- module = new WebAssembly.Module(module);
653
- }
654
- const instance = new WebAssembly.Instance(module, imports);
655
- return __wbg_finalize_init(instance, module);
656
- }
657
-
658
- async function __wbg_init(module_or_path) {
659
- if (wasm !== undefined) return wasm;
660
-
661
-
662
- if (module_or_path !== undefined) {
663
- if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
664
- ({module_or_path} = module_or_path)
665
- } else {
666
- console.warn('using deprecated parameters for the initialization function; pass a single object instead')
667
- }
668
- }
669
-
670
- if (module_or_path === undefined) {
671
- module_or_path = new URL('ballistics_engine_bg.wasm', import.meta.url);
672
- }
673
- const imports = __wbg_get_imports();
674
-
675
- if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
676
- module_or_path = fetch(module_or_path);
677
- }
678
-
679
- const { instance, module } = await __wbg_load(await module_or_path, imports);
680
-
681
- return __wbg_finalize_init(instance, module);
682
- }
683
-
684
- export { initSync, __wbg_init as default };
2
+ import * as wasm from "./ballistics_engine_bg.wasm";
3
+ import { __wbg_set_wasm } from "./ballistics_engine_bg.js";
4
+
5
+ __wbg_set_wasm(wasm);
6
+ wasm.__wbindgen_start();
7
+ export {
8
+ Calculator, WasmBallistics
9
+ } from "./ballistics_engine_bg.js";