astroceleste-engine 0.0.1

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 ADDED
@@ -0,0 +1,44 @@
1
+ # astroceleste-engine (WebAssembly)
2
+
3
+ [![npm](https://img.shields.io/npm/v/astroceleste-engine.svg)](https://www.npmjs.com/package/astroceleste-engine)
4
+
5
+ > **Experimental (0.0.x):** the API may change in any release. Pin an exact version.
6
+
7
+ Astrological chart calculation on NASA JPL ephemerides, compiled to WebAssembly from the
8
+ Rust [astroceleste-engine](https://github.com/ffalcinelli/astroceleste-engine). Charts are
9
+ computed entirely in the browser (or Node), identical to the Astroceleste server.
10
+
11
+ ```js
12
+ import init, { Engine, synastry, derivedChart } from "astroceleste-engine";
13
+
14
+ await init();
15
+ const engine = new Engine();
16
+ const kernel = await (await fetch("/ephemeris/de440s.bsp")).arrayBuffer();
17
+ engine.addKernel("de440s.bsp", new Uint8Array(kernel));
18
+
19
+ const chart = engine.chart({
20
+ utc: "1987-05-17T14:30:00Z",
21
+ latitude: 41.9,
22
+ longitude: 12.5,
23
+ house_system: "P", // optional: P, W, E, O
24
+ zodiac_type: "sidereal", // optional: tropical (default) or sidereal
25
+ ayanamsa: "lahiri", // optional
26
+ });
27
+ const horary = engine.horary(request); // chart + horary_data
28
+ const transit = engine.transit(chart.planets, request);
29
+ synastry(chartA.planets, chartB.planets);
30
+ derivedChart(chart, 5);
31
+ ```
32
+
33
+ To ship a smaller kernel, cut the range you need (positions are unchanged inside it):
34
+
35
+ ```js
36
+ import { excerptKernel } from "astroceleste-engine";
37
+ const small = excerptKernel(fullKernelBytes, 2415020.5, 2488069.5); // 1900-2100, ~21 MB
38
+ ```
39
+
40
+ Errors are thrown as `Error` objects with a `code` (`ephemeris_out_of_range`,
41
+ `invalid_input`, `invalid_kernel`).
42
+
43
+ JPL kernels: https://ssd.jpl.nasa.gov/ftp/eph/planets/bsp/ (`de440s.bsp` covers 1849-2150,
44
+ 32 MB). Licensed under MIT OR Apache-2.0.
@@ -0,0 +1,105 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * Chart calculator over JPL kernels loaded from memory.
6
+ */
7
+ export class Engine {
8
+ free(): void;
9
+ [Symbol.dispose](): void;
10
+ /**
11
+ * Add a JPL SPK kernel (e.g. de440s.bsp). Kernels are used in the order added: a
12
+ * date is computed with the first one covering it.
13
+ */
14
+ addKernel(name: string, bytes: Uint8Array): void;
15
+ /**
16
+ * The chart of a moment and place.
17
+ */
18
+ chart(request: any): any;
19
+ /**
20
+ * A chart with its horary analysis under `horary_data`.
21
+ */
22
+ horary(request: any): any;
23
+ constructor();
24
+ /**
25
+ * Whether a loaded kernel covers this UT Julian date.
26
+ */
27
+ supports(jd: number): boolean;
28
+ /**
29
+ * The sky of `request`, with its cross-aspects to `natalPlanets`.
30
+ */
31
+ transit(natal_planets: any, request: any): any;
32
+ /**
33
+ * `[firstJD, lastJD]` covered by the loaded kernels, or `undefined`.
34
+ */
35
+ readonly coverage: Float64Array | undefined;
36
+ }
37
+
38
+ /**
39
+ * A derived (turned) chart: radix house `rootHouse` becomes house 1.
40
+ */
41
+ export function derivedChart(base_chart: any, root_house: number, custom_name?: string | null): any;
42
+
43
+ /**
44
+ * A smaller kernel covering TDB Julian dates `startJd`..`endJd`, with positions
45
+ * identical to `kernel`'s inside that range (e.g. to ship 1900-2100 of de440s).
46
+ */
47
+ export function excerptKernel(kernel: Uint8Array, start_jd: number, end_jd: number): Uint8Array;
48
+
49
+ /**
50
+ * Julian day of an ISO 8601 UTC date-time, as the chart calculation uses it.
51
+ */
52
+ export function julianDay(utc: string): number;
53
+
54
+ /**
55
+ * Cross-aspects from chart B's planets (overlay) to chart A's (base).
56
+ */
57
+ export function synastry(chart_a_planets: any, chart_b_planets: any, orb_settings: any): any;
58
+
59
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
60
+
61
+ export interface InitOutput {
62
+ readonly memory: WebAssembly.Memory;
63
+ readonly __wbg_engine_free: (a: number, b: number) => void;
64
+ readonly derivedChart: (a: any, b: number, c: number, d: number) => [number, number, number];
65
+ readonly engine_addKernel: (a: number, b: number, c: number, d: number, e: number) => [number, number];
66
+ readonly engine_chart: (a: number, b: any) => [number, number, number];
67
+ readonly engine_coverage: (a: number) => [number, number];
68
+ readonly engine_horary: (a: number, b: any) => [number, number, number];
69
+ readonly engine_new: () => number;
70
+ readonly engine_supports: (a: number, b: number) => number;
71
+ readonly engine_transit: (a: number, b: any, c: any) => [number, number, number];
72
+ readonly excerptKernel: (a: number, b: number, c: number, d: number) => [number, number, number, number];
73
+ readonly julianDay: (a: number, b: number) => [number, number, number];
74
+ readonly synastry: (a: any, b: any, c: any) => [number, number, number];
75
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
76
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
77
+ readonly __wbindgen_exn_store: (a: number) => void;
78
+ readonly __externref_table_alloc: () => number;
79
+ readonly __wbindgen_externrefs: WebAssembly.Table;
80
+ readonly __externref_table_dealloc: (a: number) => void;
81
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
82
+ readonly __wbindgen_start: () => void;
83
+ }
84
+
85
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
86
+
87
+ /**
88
+ * Instantiates the given `module`, which can either be bytes or
89
+ * a precompiled `WebAssembly.Module`.
90
+ *
91
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
92
+ *
93
+ * @returns {InitOutput}
94
+ */
95
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
96
+
97
+ /**
98
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
99
+ * for everything else, calls `WebAssembly.instantiate` directly.
100
+ *
101
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
102
+ *
103
+ * @returns {Promise<InitOutput>}
104
+ */
105
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
@@ -0,0 +1,718 @@
1
+ /* @ts-self-types="./astroceleste_engine_wasm.d.ts" */
2
+
3
+ /**
4
+ * Chart calculator over JPL kernels loaded from memory.
5
+ */
6
+ export class Engine {
7
+ __destroy_into_raw() {
8
+ const ptr = this.__wbg_ptr;
9
+ this.__wbg_ptr = 0;
10
+ EngineFinalization.unregister(this);
11
+ return ptr;
12
+ }
13
+ free() {
14
+ const ptr = this.__destroy_into_raw();
15
+ wasm.__wbg_engine_free(ptr, 0);
16
+ }
17
+ /**
18
+ * Add a JPL SPK kernel (e.g. de440s.bsp). Kernels are used in the order added: a
19
+ * date is computed with the first one covering it.
20
+ * @param {string} name
21
+ * @param {Uint8Array} bytes
22
+ */
23
+ addKernel(name, bytes) {
24
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
25
+ const len0 = WASM_VECTOR_LEN;
26
+ const ptr1 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
27
+ const len1 = WASM_VECTOR_LEN;
28
+ const ret = wasm.engine_addKernel(this.__wbg_ptr, ptr0, len0, ptr1, len1);
29
+ if (ret[1]) {
30
+ throw takeFromExternrefTable0(ret[0]);
31
+ }
32
+ }
33
+ /**
34
+ * The chart of a moment and place.
35
+ * @param {any} request
36
+ * @returns {any}
37
+ */
38
+ chart(request) {
39
+ const ret = wasm.engine_chart(this.__wbg_ptr, request);
40
+ if (ret[2]) {
41
+ throw takeFromExternrefTable0(ret[1]);
42
+ }
43
+ return takeFromExternrefTable0(ret[0]);
44
+ }
45
+ /**
46
+ * `[firstJD, lastJD]` covered by the loaded kernels, or `undefined`.
47
+ * @returns {Float64Array | undefined}
48
+ */
49
+ get coverage() {
50
+ const ret = wasm.engine_coverage(this.__wbg_ptr);
51
+ let v1;
52
+ if (ret[0] !== 0) {
53
+ v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
54
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
55
+ }
56
+ return v1;
57
+ }
58
+ /**
59
+ * A chart with its horary analysis under `horary_data`.
60
+ * @param {any} request
61
+ * @returns {any}
62
+ */
63
+ horary(request) {
64
+ const ret = wasm.engine_horary(this.__wbg_ptr, request);
65
+ if (ret[2]) {
66
+ throw takeFromExternrefTable0(ret[1]);
67
+ }
68
+ return takeFromExternrefTable0(ret[0]);
69
+ }
70
+ constructor() {
71
+ const ret = wasm.engine_new();
72
+ this.__wbg_ptr = ret;
73
+ EngineFinalization.register(this, this.__wbg_ptr, this);
74
+ return this;
75
+ }
76
+ /**
77
+ * Whether a loaded kernel covers this UT Julian date.
78
+ * @param {number} jd
79
+ * @returns {boolean}
80
+ */
81
+ supports(jd) {
82
+ const ret = wasm.engine_supports(this.__wbg_ptr, jd);
83
+ return ret !== 0;
84
+ }
85
+ /**
86
+ * The sky of `request`, with its cross-aspects to `natalPlanets`.
87
+ * @param {any} natal_planets
88
+ * @param {any} request
89
+ * @returns {any}
90
+ */
91
+ transit(natal_planets, request) {
92
+ const ret = wasm.engine_transit(this.__wbg_ptr, natal_planets, request);
93
+ if (ret[2]) {
94
+ throw takeFromExternrefTable0(ret[1]);
95
+ }
96
+ return takeFromExternrefTable0(ret[0]);
97
+ }
98
+ }
99
+ if (Symbol.dispose) Engine.prototype[Symbol.dispose] = Engine.prototype.free;
100
+
101
+ /**
102
+ * A derived (turned) chart: radix house `rootHouse` becomes house 1.
103
+ * @param {any} base_chart
104
+ * @param {number} root_house
105
+ * @param {string | null} [custom_name]
106
+ * @returns {any}
107
+ */
108
+ export function derivedChart(base_chart, root_house, custom_name) {
109
+ var ptr0 = isLikeNone(custom_name) ? 0 : passStringToWasm0(custom_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
110
+ var len0 = WASM_VECTOR_LEN;
111
+ const ret = wasm.derivedChart(base_chart, root_house, ptr0, len0);
112
+ if (ret[2]) {
113
+ throw takeFromExternrefTable0(ret[1]);
114
+ }
115
+ return takeFromExternrefTable0(ret[0]);
116
+ }
117
+
118
+ /**
119
+ * A smaller kernel covering TDB Julian dates `startJd`..`endJd`, with positions
120
+ * identical to `kernel`'s inside that range (e.g. to ship 1900-2100 of de440s).
121
+ * @param {Uint8Array} kernel
122
+ * @param {number} start_jd
123
+ * @param {number} end_jd
124
+ * @returns {Uint8Array}
125
+ */
126
+ export function excerptKernel(kernel, start_jd, end_jd) {
127
+ const ptr0 = passArray8ToWasm0(kernel, wasm.__wbindgen_malloc);
128
+ const len0 = WASM_VECTOR_LEN;
129
+ const ret = wasm.excerptKernel(ptr0, len0, start_jd, end_jd);
130
+ if (ret[3]) {
131
+ throw takeFromExternrefTable0(ret[2]);
132
+ }
133
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
134
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
135
+ return v2;
136
+ }
137
+
138
+ /**
139
+ * Julian day of an ISO 8601 UTC date-time, as the chart calculation uses it.
140
+ * @param {string} utc
141
+ * @returns {number}
142
+ */
143
+ export function julianDay(utc) {
144
+ const ptr0 = passStringToWasm0(utc, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
145
+ const len0 = WASM_VECTOR_LEN;
146
+ const ret = wasm.julianDay(ptr0, len0);
147
+ if (ret[2]) {
148
+ throw takeFromExternrefTable0(ret[1]);
149
+ }
150
+ return ret[0];
151
+ }
152
+
153
+ /**
154
+ * Cross-aspects from chart B's planets (overlay) to chart A's (base).
155
+ * @param {any} chart_a_planets
156
+ * @param {any} chart_b_planets
157
+ * @param {any} orb_settings
158
+ * @returns {any}
159
+ */
160
+ export function synastry(chart_a_planets, chart_b_planets, orb_settings) {
161
+ const ret = wasm.synastry(chart_a_planets, chart_b_planets, orb_settings);
162
+ if (ret[2]) {
163
+ throw takeFromExternrefTable0(ret[1]);
164
+ }
165
+ return takeFromExternrefTable0(ret[0]);
166
+ }
167
+ function __wbg_get_imports() {
168
+ const import0 = {
169
+ __proto__: null,
170
+ __wbg_Error_67e7344beaa85059: function(arg0, arg1) {
171
+ const ret = Error(getStringFromWasm0(arg0, arg1));
172
+ return ret;
173
+ },
174
+ __wbg_String_8564e559799eccda: function(arg0, arg1) {
175
+ const ret = String(arg1);
176
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
177
+ const len1 = WASM_VECTOR_LEN;
178
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
179
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
180
+ },
181
+ __wbg___wbindgen_bigint_get_as_i64_b482365c149396c8: function(arg0, arg1) {
182
+ const v = arg1;
183
+ const ret = typeof(v) === 'bigint' ? v : undefined;
184
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
185
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
186
+ },
187
+ __wbg___wbindgen_boolean_get_7a12af2b3f899c5a: function(arg0) {
188
+ const v = arg0;
189
+ const ret = typeof(v) === 'boolean' ? v : undefined;
190
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
191
+ },
192
+ __wbg___wbindgen_debug_string_0e68cf47c9cbd9b0: function(arg0, arg1) {
193
+ const ret = debugString(arg1);
194
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
195
+ const len1 = WASM_VECTOR_LEN;
196
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
197
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
198
+ },
199
+ __wbg___wbindgen_in_50072d4d6e45c193: function(arg0, arg1) {
200
+ const ret = arg0 in arg1;
201
+ return ret;
202
+ },
203
+ __wbg___wbindgen_is_bigint_60fc0336cb14f5d7: function(arg0) {
204
+ const ret = typeof(arg0) === 'bigint';
205
+ return ret;
206
+ },
207
+ __wbg___wbindgen_is_function_fcda5e3902d732fe: function(arg0) {
208
+ const ret = typeof(arg0) === 'function';
209
+ return ret;
210
+ },
211
+ __wbg___wbindgen_is_null_5160b3e381865372: function(arg0) {
212
+ const ret = arg0 === null;
213
+ return ret;
214
+ },
215
+ __wbg___wbindgen_is_object_edb6b15aa3afe12e: function(arg0) {
216
+ const val = arg0;
217
+ const ret = typeof(val) === 'object' && val !== null;
218
+ return ret;
219
+ },
220
+ __wbg___wbindgen_is_string_c4f7cb494a2a21f1: function(arg0) {
221
+ const ret = typeof(arg0) === 'string';
222
+ return ret;
223
+ },
224
+ __wbg___wbindgen_is_undefined_8c687d0b90d5b524: function(arg0) {
225
+ const ret = arg0 === undefined;
226
+ return ret;
227
+ },
228
+ __wbg___wbindgen_jsval_eq_9fdcd3c0a860dd3b: function(arg0, arg1) {
229
+ const ret = arg0 === arg1;
230
+ return ret;
231
+ },
232
+ __wbg___wbindgen_jsval_loose_eq_3c30021c243b64cd: function(arg0, arg1) {
233
+ const ret = arg0 == arg1;
234
+ return ret;
235
+ },
236
+ __wbg___wbindgen_number_get_1dc732b810cb937c: function(arg0, arg1) {
237
+ const obj = arg1;
238
+ const ret = typeof(obj) === 'number' ? obj : undefined;
239
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
240
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
241
+ },
242
+ __wbg___wbindgen_string_get_92ab86bb19cbc12f: function(arg0, arg1) {
243
+ const obj = arg1;
244
+ const ret = typeof(obj) === 'string' ? obj : undefined;
245
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
246
+ var len1 = WASM_VECTOR_LEN;
247
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
248
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
249
+ },
250
+ __wbg___wbindgen_throw_5d9e815e6fdf150f: function(arg0, arg1) {
251
+ throw new Error(getStringFromWasm0(arg0, arg1));
252
+ },
253
+ __wbg_call_269c5566fbede3eb: function() { return handleError(function (arg0, arg1) {
254
+ const ret = arg0.call(arg1);
255
+ return ret;
256
+ }, arguments); },
257
+ __wbg_done_cffed884d87aa22e: function(arg0) {
258
+ const ret = arg0.done;
259
+ return ret;
260
+ },
261
+ __wbg_entries_972a87586902cf87: function(arg0) {
262
+ const ret = Object.entries(arg0);
263
+ return ret;
264
+ },
265
+ __wbg_get_6cf5a4d4d8ad3c5a: function() { return handleError(function (arg0, arg1) {
266
+ const ret = Reflect.get(arg0, arg1);
267
+ return ret;
268
+ }, arguments); },
269
+ __wbg_get_b1f0ab13c737f856: function(arg0, arg1) {
270
+ const ret = arg0[arg1 >>> 0];
271
+ return ret;
272
+ },
273
+ __wbg_get_unchecked_363572bdd397d473: function(arg0, arg1) {
274
+ const ret = arg0[arg1 >>> 0];
275
+ return ret;
276
+ },
277
+ __wbg_get_with_ref_key_6412cf3094599694: function(arg0, arg1) {
278
+ const ret = arg0[arg1];
279
+ return ret;
280
+ },
281
+ __wbg_instanceof_ArrayBuffer_d4ff01f8247925ae: function(arg0) {
282
+ let result;
283
+ try {
284
+ result = arg0 instanceof ArrayBuffer;
285
+ } catch (_) {
286
+ result = false;
287
+ }
288
+ const ret = result;
289
+ return ret;
290
+ },
291
+ __wbg_instanceof_Map_1ff6a2b54c899f0d: function(arg0) {
292
+ let result;
293
+ try {
294
+ result = arg0 instanceof Map;
295
+ } catch (_) {
296
+ result = false;
297
+ }
298
+ const ret = result;
299
+ return ret;
300
+ },
301
+ __wbg_instanceof_Uint8Array_598adc0fef426aa8: function(arg0) {
302
+ let result;
303
+ try {
304
+ result = arg0 instanceof Uint8Array;
305
+ } catch (_) {
306
+ result = false;
307
+ }
308
+ const ret = result;
309
+ return ret;
310
+ },
311
+ __wbg_isArray_5674713bb7b79043: function(arg0) {
312
+ const ret = Array.isArray(arg0);
313
+ return ret;
314
+ },
315
+ __wbg_isSafeInteger_8f51c743827d1ec5: function(arg0) {
316
+ const ret = Number.isSafeInteger(arg0);
317
+ return ret;
318
+ },
319
+ __wbg_iterator_22ddeb808cf55a6f: function() {
320
+ const ret = Symbol.iterator;
321
+ return ret;
322
+ },
323
+ __wbg_length_31bdaf014f5fbde2: function(arg0) {
324
+ const ret = arg0.length;
325
+ return ret;
326
+ },
327
+ __wbg_length_4e1adc0d42e23620: function(arg0) {
328
+ const ret = arg0.length;
329
+ return ret;
330
+ },
331
+ __wbg_new_1da3429bc3c4541c: function(arg0) {
332
+ const ret = new Uint8Array(arg0);
333
+ return ret;
334
+ },
335
+ __wbg_new_8d36e20aa758e411: function() {
336
+ const ret = new Map();
337
+ return ret;
338
+ },
339
+ __wbg_new_a32a1ab6c6655abe: function(arg0, arg1) {
340
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
341
+ return ret;
342
+ },
343
+ __wbg_new_bebc3f4757acf305: function() {
344
+ const ret = new Object();
345
+ return ret;
346
+ },
347
+ __wbg_new_ffa92086ea89f79c: function() {
348
+ const ret = new Array();
349
+ return ret;
350
+ },
351
+ __wbg_next_95053e306b1c3aed: function(arg0) {
352
+ const ret = arg0.next;
353
+ return ret;
354
+ },
355
+ __wbg_next_f31ecb8646d2c605: function() { return handleError(function (arg0) {
356
+ const ret = arg0.next();
357
+ return ret;
358
+ }, arguments); },
359
+ __wbg_prototypesetcall_ae9f5e7459250748: function(arg0, arg1, arg2) {
360
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
361
+ },
362
+ __wbg_set_13d25b81ab403f5e: function(arg0, arg1, arg2) {
363
+ arg0[arg1 >>> 0] = arg2;
364
+ },
365
+ __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
366
+ arg0[arg1] = arg2;
367
+ },
368
+ __wbg_set_a377297433dfea63: function() { return handleError(function (arg0, arg1, arg2) {
369
+ const ret = Reflect.set(arg0, arg1, arg2);
370
+ return ret;
371
+ }, arguments); },
372
+ __wbg_set_bf6dde4923b9b059: function(arg0, arg1, arg2) {
373
+ const ret = arg0.set(arg1, arg2);
374
+ return ret;
375
+ },
376
+ __wbg_value_c227f843d21da141: function(arg0) {
377
+ const ret = arg0.value;
378
+ return ret;
379
+ },
380
+ __wbindgen_generic_0000000000000001: function(arg0) {
381
+ // Cast intrinsic for `F64 -> Externref`.
382
+ const ret = arg0;
383
+ return ret;
384
+ },
385
+ __wbindgen_generic_0000000000000002: function(arg0) {
386
+ // Cast intrinsic for `I64 -> Externref`.
387
+ const ret = arg0;
388
+ return ret;
389
+ },
390
+ __wbindgen_generic_0000000000000003: function(arg0, arg1) {
391
+ // Cast intrinsic for `Ref(String) -> Externref`.
392
+ const ret = getStringFromWasm0(arg0, arg1);
393
+ return ret;
394
+ },
395
+ __wbindgen_generic_0000000000000004: function(arg0) {
396
+ // Cast intrinsic for `U64 -> Externref`.
397
+ const ret = BigInt.asUintN(64, arg0);
398
+ return ret;
399
+ },
400
+ __wbindgen_init_externref_table: function() {
401
+ const table = wasm.__wbindgen_externrefs;
402
+ const offset = table.grow(4);
403
+ table.set(0, undefined);
404
+ table.set(offset + 0, undefined);
405
+ table.set(offset + 1, null);
406
+ table.set(offset + 2, true);
407
+ table.set(offset + 3, false);
408
+ },
409
+ };
410
+ return {
411
+ __proto__: null,
412
+ "./astroceleste_engine_wasm_bg.js": import0,
413
+ };
414
+ }
415
+
416
+ const EngineFinalization = (typeof FinalizationRegistry === 'undefined')
417
+ ? { register: () => {}, unregister: () => {} }
418
+ : new FinalizationRegistry(ptr => wasm.__wbg_engine_free(ptr, 1));
419
+
420
+ function addToExternrefTable0(obj) {
421
+ const idx = wasm.__externref_table_alloc();
422
+ wasm.__wbindgen_externrefs.set(idx, obj);
423
+ return idx;
424
+ }
425
+
426
+ function debugString(val) {
427
+ // primitive types
428
+ const type = typeof val;
429
+ if (type == 'number' || type == 'boolean' || val == null) {
430
+ return `${val}`;
431
+ }
432
+ if (type == 'string') {
433
+ return `"${val}"`;
434
+ }
435
+ if (type == 'symbol') {
436
+ const description = val.description;
437
+ if (description == null) {
438
+ return 'Symbol';
439
+ } else {
440
+ return `Symbol(${description})`;
441
+ }
442
+ }
443
+ if (type == 'function') {
444
+ const name = val.name;
445
+ if (typeof name == 'string' && name.length > 0) {
446
+ return `Function(${name})`;
447
+ } else {
448
+ return 'Function';
449
+ }
450
+ }
451
+ // objects
452
+ if (Array.isArray(val)) {
453
+ const length = val.length;
454
+ let debug = '[';
455
+ if (length > 0) {
456
+ debug += debugString(val[0]);
457
+ }
458
+ for(let i = 1; i < length; i++) {
459
+ debug += ', ' + debugString(val[i]);
460
+ }
461
+ debug += ']';
462
+ return debug;
463
+ }
464
+ // Test for built-in
465
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
466
+ let className;
467
+ if (builtInMatches && builtInMatches.length > 1) {
468
+ className = builtInMatches[1];
469
+ } else {
470
+ // Failed to match the standard '[object ClassName]'
471
+ return toString.call(val);
472
+ }
473
+ if (className == 'Object') {
474
+ // we're a user defined class or Object
475
+ // JSON.stringify avoids problems with cycles, and is generally much
476
+ // easier than looping through ownProperties of `val`.
477
+ try {
478
+ return 'Object(' + JSON.stringify(val) + ')';
479
+ } catch (_) {
480
+ return 'Object';
481
+ }
482
+ }
483
+ // errors
484
+ if (val instanceof Error) {
485
+ return `${val.name}: ${val.message}\n${val.stack}`;
486
+ }
487
+ // TODO we could test for more things here, like `Set`s and `Map`s.
488
+ return className;
489
+ }
490
+
491
+ function getArrayF64FromWasm0(ptr, len) {
492
+ ptr = ptr >>> 0;
493
+ return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
494
+ }
495
+
496
+ function getArrayU8FromWasm0(ptr, len) {
497
+ ptr = ptr >>> 0;
498
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
499
+ }
500
+
501
+ let cachedDataViewMemory0 = null;
502
+ function getDataViewMemory0() {
503
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
504
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
505
+ }
506
+ return cachedDataViewMemory0;
507
+ }
508
+
509
+ let cachedFloat64ArrayMemory0 = null;
510
+ function getFloat64ArrayMemory0() {
511
+ if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
512
+ cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
513
+ }
514
+ return cachedFloat64ArrayMemory0;
515
+ }
516
+
517
+ function getStringFromWasm0(ptr, len) {
518
+ return decodeText(ptr >>> 0, len);
519
+ }
520
+
521
+ let cachedUint8ArrayMemory0 = null;
522
+ function getUint8ArrayMemory0() {
523
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
524
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
525
+ }
526
+ return cachedUint8ArrayMemory0;
527
+ }
528
+
529
+ function handleError(f, args) {
530
+ try {
531
+ return f.apply(this, args);
532
+ } catch (e) {
533
+ const idx = addToExternrefTable0(e);
534
+ wasm.__wbindgen_exn_store(idx);
535
+ }
536
+ }
537
+
538
+ function isLikeNone(x) {
539
+ return x === undefined || x === null;
540
+ }
541
+
542
+ function passArray8ToWasm0(arg, malloc) {
543
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
544
+ getUint8ArrayMemory0().set(arg, ptr / 1);
545
+ WASM_VECTOR_LEN = arg.length;
546
+ return ptr;
547
+ }
548
+
549
+ function passStringToWasm0(arg, malloc, realloc) {
550
+ if (realloc === undefined) {
551
+ const buf = cachedTextEncoder.encode(arg);
552
+ const ptr = malloc(buf.length, 1) >>> 0;
553
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
554
+ WASM_VECTOR_LEN = buf.length;
555
+ return ptr;
556
+ }
557
+
558
+ let len = arg.length;
559
+ let ptr = malloc(len, 1) >>> 0;
560
+
561
+ const mem = getUint8ArrayMemory0();
562
+
563
+ let offset = 0;
564
+
565
+ for (; offset < len; offset++) {
566
+ const code = arg.charCodeAt(offset);
567
+ if (code > 0x7F) break;
568
+ mem[ptr + offset] = code;
569
+ }
570
+ if (offset !== len) {
571
+ if (offset !== 0) {
572
+ arg = arg.slice(offset);
573
+ }
574
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
575
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
576
+ const ret = cachedTextEncoder.encodeInto(arg, view);
577
+
578
+ offset += ret.written;
579
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
580
+ }
581
+
582
+ WASM_VECTOR_LEN = offset;
583
+ return ptr;
584
+ }
585
+
586
+ function takeFromExternrefTable0(idx) {
587
+ const value = wasm.__wbindgen_externrefs.get(idx);
588
+ wasm.__externref_table_dealloc(idx);
589
+ return value;
590
+ }
591
+
592
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
593
+ cachedTextDecoder.decode();
594
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
595
+ let numBytesDecoded = 0;
596
+ function decodeText(ptr, len) {
597
+ numBytesDecoded += len;
598
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
599
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
600
+ cachedTextDecoder.decode();
601
+ numBytesDecoded = len;
602
+ }
603
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
604
+ }
605
+
606
+ const cachedTextEncoder = new TextEncoder();
607
+
608
+ if (!('encodeInto' in cachedTextEncoder)) {
609
+ cachedTextEncoder.encodeInto = function (arg, view) {
610
+ const buf = cachedTextEncoder.encode(arg);
611
+ view.set(buf);
612
+ return {
613
+ read: arg.length,
614
+ written: buf.length
615
+ };
616
+ };
617
+ }
618
+
619
+ let WASM_VECTOR_LEN = 0;
620
+
621
+ let wasmModule, wasmInstance, wasm;
622
+ function __wbg_finalize_init(instance, module) {
623
+ wasmInstance = instance;
624
+ wasm = instance.exports;
625
+ wasmModule = module;
626
+ cachedDataViewMemory0 = null;
627
+ cachedFloat64ArrayMemory0 = null;
628
+ cachedUint8ArrayMemory0 = null;
629
+ wasm.__wbindgen_start();
630
+ return wasm;
631
+ }
632
+
633
+ async function __wbg_load(module, imports) {
634
+ if (typeof Response === 'function' && module instanceof Response) {
635
+ if (!module.ok) {
636
+ throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
637
+ }
638
+
639
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
640
+ try {
641
+ return await WebAssembly.instantiateStreaming(module, imports);
642
+ } catch (e) {
643
+ const validResponse = expectedResponseType(module.type);
644
+
645
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
646
+ 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);
647
+
648
+ } else { throw e; }
649
+ }
650
+ }
651
+
652
+ const bytes = await module.arrayBuffer();
653
+ return await WebAssembly.instantiate(bytes, imports);
654
+ } else {
655
+ const instance = await WebAssembly.instantiate(module, imports);
656
+
657
+ if (instance instanceof WebAssembly.Instance) {
658
+ return { instance, module };
659
+ } else {
660
+ return instance;
661
+ }
662
+ }
663
+
664
+ function expectedResponseType(type) {
665
+ switch (type) {
666
+ case 'basic': case 'cors': case 'default': return true;
667
+ }
668
+ return false;
669
+ }
670
+ }
671
+
672
+ function initSync(module) {
673
+ if (wasm !== undefined) return wasm;
674
+
675
+
676
+ if (module !== undefined) {
677
+ if (Object.getPrototypeOf(module) === Object.prototype) {
678
+ ({module} = module)
679
+ } else {
680
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
681
+ }
682
+ }
683
+
684
+ const imports = __wbg_get_imports();
685
+ if (!(module instanceof WebAssembly.Module)) {
686
+ module = new WebAssembly.Module(module);
687
+ }
688
+ const instance = new WebAssembly.Instance(module, imports);
689
+ return __wbg_finalize_init(instance, module);
690
+ }
691
+
692
+ async function __wbg_init(module_or_path) {
693
+ if (wasm !== undefined) return wasm;
694
+
695
+
696
+ if (module_or_path !== undefined) {
697
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
698
+ ({module_or_path} = module_or_path)
699
+ } else {
700
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
701
+ }
702
+ }
703
+
704
+ if (module_or_path === undefined) {
705
+ module_or_path = new URL('astroceleste_engine_wasm_bg.wasm', import.meta.url);
706
+ }
707
+ const imports = __wbg_get_imports();
708
+
709
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
710
+ module_or_path = fetch(module_or_path);
711
+ }
712
+
713
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
714
+
715
+ return __wbg_finalize_init(instance, module);
716
+ }
717
+
718
+ export { initSync, __wbg_init as default };
Binary file
package/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "astroceleste-engine",
3
+ "type": "module",
4
+ "description": "WebAssembly bindings for astroceleste-engine",
5
+ "version": "0.0.1",
6
+ "license": "MIT OR Apache-2.0",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/ffalcinelli/astroceleste-engine"
10
+ },
11
+ "files": [
12
+ "astroceleste_engine_wasm_bg.wasm",
13
+ "astroceleste_engine_wasm.js",
14
+ "astroceleste_engine_wasm.d.ts"
15
+ ],
16
+ "main": "astroceleste_engine_wasm.js",
17
+ "types": "astroceleste_engine_wasm.d.ts",
18
+ "sideEffects": [
19
+ "./snippets/*"
20
+ ]
21
+ }