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