litlaunch-library-api 0.2.7-tweak.2 → 0.2.7-tweak.4
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/litlaunch-library-api-0.2.7+tweak.4-wasm32-emscripten-release.mjs +803 -0
- package/{litlaunch-library-api-0.2.7+tweak.2-wasm32-emscripten-release.wasm → litlaunch-library-api-0.2.7+tweak.4-wasm32-emscripten-release.wasm} +0 -0
- package/package.json +6 -6
- package/litlaunch-library-api-0.2.7+tweak.2-wasm32-emscripten-release.mjs +0 -2
|
@@ -0,0 +1,803 @@
|
|
|
1
|
+
// This code implements the `-sMODULARIZE` settings by taking the generated
|
|
2
|
+
// JS program code (INNER_JS_CODE) and wrapping it in a factory function.
|
|
3
|
+
|
|
4
|
+
// When targeting node and ES6 we use `await import ..` in the generated code
|
|
5
|
+
// so the outer function needs to be marked as async.
|
|
6
|
+
async function LitLaunchLibraryApi(moduleArg = {}) {
|
|
7
|
+
var Module = moduleArg;
|
|
8
|
+
// include: shell.js
|
|
9
|
+
// include: minimum_runtime_check.js
|
|
10
|
+
// end include: minimum_runtime_check.js
|
|
11
|
+
// The Module object: Our interface to the outside world. We import
|
|
12
|
+
// and export values on it. There are various ways Module can be used:
|
|
13
|
+
// 1. Not defined. We create it here
|
|
14
|
+
// 2. A function parameter, function(moduleArg) => Promise<Module>
|
|
15
|
+
// 3. pre-run appended it, var Module = {}; ..generated code..
|
|
16
|
+
// 4. External script tag defines var Module.
|
|
17
|
+
// We need to check if Module already exists (e.g. case 3 above).
|
|
18
|
+
// Substitution will be replaced with actual code on later stage of the build,
|
|
19
|
+
// this way Closure Compiler will not mangle it (e.g. case 4. above).
|
|
20
|
+
// Note that if you want to run closure, and also to use Module
|
|
21
|
+
// after the generated code, you will need to define var Module = {};
|
|
22
|
+
// before the code. Then that object will be used in the code, and you
|
|
23
|
+
// can continue to use Module afterwards as well.
|
|
24
|
+
// Determine the runtime environment we are in. You can customize this by
|
|
25
|
+
// setting the ENVIRONMENT setting at compile time (see settings.js).
|
|
26
|
+
// Attempt to auto-detect the environment
|
|
27
|
+
var ENVIRONMENT_IS_WEB = !!globalThis.window;
|
|
28
|
+
|
|
29
|
+
var ENVIRONMENT_IS_WORKER = !!globalThis.WorkerGlobalScope;
|
|
30
|
+
|
|
31
|
+
// N.b. Electron.js environment is simultaneously a NODE-environment, but
|
|
32
|
+
// also a web environment.
|
|
33
|
+
var ENVIRONMENT_IS_NODE = globalThis.process?.versions?.node && globalThis.process?.type != "renderer";
|
|
34
|
+
|
|
35
|
+
if (ENVIRONMENT_IS_NODE) {
|
|
36
|
+
// When building an ES module `require` is not normally available.
|
|
37
|
+
// We need to use `createRequire()` to construct the require()` function.
|
|
38
|
+
const {createRequire} = await ((import("node:module")));
|
|
39
|
+
/** @suppress{duplicate} */ var require = createRequire(import.meta.url);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// --pre-jses are emitted after the Module integration code, so that they can
|
|
43
|
+
// refer to Module (if they choose; they can also define Module)
|
|
44
|
+
var programArgs = [];
|
|
45
|
+
|
|
46
|
+
var thisProgram = "./this.program";
|
|
47
|
+
|
|
48
|
+
var quit_ = (status, toThrow) => {
|
|
49
|
+
throw toThrow;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
var _scriptName = import.meta.url;
|
|
53
|
+
|
|
54
|
+
// `/` should be present at the end if `scriptDirectory` is not empty
|
|
55
|
+
var scriptDirectory = "";
|
|
56
|
+
|
|
57
|
+
function locateFile(path) {
|
|
58
|
+
if (Module["locateFile"]) {
|
|
59
|
+
return Module["locateFile"](path, scriptDirectory);
|
|
60
|
+
}
|
|
61
|
+
return scriptDirectory + path;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Hooks that are implemented differently in different runtime environments.
|
|
65
|
+
var readAsync, readBinary;
|
|
66
|
+
|
|
67
|
+
if (ENVIRONMENT_IS_NODE) {
|
|
68
|
+
// These modules will usually be used on Node.js. Load them eagerly to avoid
|
|
69
|
+
// the complexity of lazy-loading.
|
|
70
|
+
var fs = require("node:fs");
|
|
71
|
+
if (_scriptName.startsWith("file:")) {
|
|
72
|
+
scriptDirectory = require("node:path").dirname(require("node:url").fileURLToPath(_scriptName)) + "/";
|
|
73
|
+
}
|
|
74
|
+
// include: node_shell_read.js
|
|
75
|
+
readBinary = filename => {
|
|
76
|
+
// We need to re-wrap `file://` strings to URLs.
|
|
77
|
+
filename = isFileURI(filename) ? new URL(filename) : filename;
|
|
78
|
+
var ret = fs.readFileSync(filename);
|
|
79
|
+
return ret;
|
|
80
|
+
};
|
|
81
|
+
readAsync = async (filename, binary = true) => {
|
|
82
|
+
// See the comment in the `readBinary` function.
|
|
83
|
+
filename = isFileURI(filename) ? new URL(filename) : filename;
|
|
84
|
+
var ret = fs.readFileSync(filename, binary ? undefined : "utf8");
|
|
85
|
+
return ret;
|
|
86
|
+
};
|
|
87
|
+
// end include: node_shell_read.js
|
|
88
|
+
if (process.argv.length > 1) {
|
|
89
|
+
thisProgram = process.argv[1].replace(/\\/g, "/");
|
|
90
|
+
}
|
|
91
|
+
programArgs = process.argv.slice(2);
|
|
92
|
+
quit_ = (status, toThrow) => {
|
|
93
|
+
process.exitCode = status;
|
|
94
|
+
throw toThrow;
|
|
95
|
+
};
|
|
96
|
+
} else // Note that this includes Node.js workers when relevant (pthreads is enabled).
|
|
97
|
+
// Node.js workers are detected as a combination of ENVIRONMENT_IS_WORKER and
|
|
98
|
+
// ENVIRONMENT_IS_NODE.
|
|
99
|
+
if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
|
|
100
|
+
try {
|
|
101
|
+
scriptDirectory = new URL(".", _scriptName).href;
|
|
102
|
+
} catch {}
|
|
103
|
+
{
|
|
104
|
+
// include: web_or_worker_shell_read.js
|
|
105
|
+
if (ENVIRONMENT_IS_WORKER) {
|
|
106
|
+
readBinary = url => {
|
|
107
|
+
var xhr = new XMLHttpRequest;
|
|
108
|
+
xhr.open("GET", url, false);
|
|
109
|
+
xhr.responseType = "arraybuffer";
|
|
110
|
+
xhr.send(null);
|
|
111
|
+
return new Uint8Array(/** @type{!ArrayBuffer} */ (xhr.response));
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
readAsync = async url => {
|
|
115
|
+
// Fetch has some additional restrictions over XHR, like it can't be used on a file:// url.
|
|
116
|
+
// See https://github.com/github/fetch/pull/92#issuecomment-140665932
|
|
117
|
+
// Cordova or Electron apps are typically loaded from a file:// url.
|
|
118
|
+
// So use XHR on webview if URL is a file URL.
|
|
119
|
+
if (isFileURI(url)) {
|
|
120
|
+
return new Promise((resolve, reject) => {
|
|
121
|
+
var xhr = new XMLHttpRequest;
|
|
122
|
+
xhr.open("GET", url, true);
|
|
123
|
+
xhr.responseType = "arraybuffer";
|
|
124
|
+
xhr.onload = () => {
|
|
125
|
+
if (xhr.status == 200 || (xhr.status == 0 && xhr.response)) {
|
|
126
|
+
// file URLs can return 0
|
|
127
|
+
resolve(xhr.response);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
reject(xhr.status);
|
|
131
|
+
};
|
|
132
|
+
xhr.onerror = reject;
|
|
133
|
+
xhr.send(null);
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
var response = await fetch(url, {
|
|
137
|
+
credentials: "same-origin"
|
|
138
|
+
});
|
|
139
|
+
if (response.ok) {
|
|
140
|
+
return response.arrayBuffer();
|
|
141
|
+
}
|
|
142
|
+
throw new Error(response.status + " : " + response.url);
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
} else {}
|
|
146
|
+
|
|
147
|
+
var out = console.log.bind(console);
|
|
148
|
+
|
|
149
|
+
var err = console.error.bind(console);
|
|
150
|
+
|
|
151
|
+
// end include: shell.js
|
|
152
|
+
// include: preamble.js
|
|
153
|
+
// === Preamble library stuff ===
|
|
154
|
+
// Documentation for the public APIs defined in this file must be updated in:
|
|
155
|
+
// site/source/docs/api_reference/preamble.js.rst
|
|
156
|
+
// A prebuilt local version of the documentation is available at:
|
|
157
|
+
// site/build/text/docs/api_reference/preamble.js.txt
|
|
158
|
+
// You can also build docs locally as HTML or other formats in site/
|
|
159
|
+
// An online HTML version (which may be of a different version of Emscripten)
|
|
160
|
+
// is up at http://kripken.github.io/emscripten-site/docs/api_reference/preamble.js.html
|
|
161
|
+
var wasmBinary;
|
|
162
|
+
|
|
163
|
+
// Wasm globals
|
|
164
|
+
//========================================
|
|
165
|
+
// Runtime essentials
|
|
166
|
+
//========================================
|
|
167
|
+
// whether we are quitting the application. no code should run after this.
|
|
168
|
+
// set in exit() and abort()
|
|
169
|
+
var ABORT = false;
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Indicates whether filename is delivered via file protocol (as opposed to http/https)
|
|
173
|
+
* @noinline
|
|
174
|
+
*/ var isFileURI = filename => filename.startsWith("file://");
|
|
175
|
+
|
|
176
|
+
// include: runtime_common.js
|
|
177
|
+
// include: runtime_exceptions.js
|
|
178
|
+
// Base Emscripten EH error class
|
|
179
|
+
class EmscriptenEH {}
|
|
180
|
+
|
|
181
|
+
class EmscriptenSjLj extends EmscriptenEH {}
|
|
182
|
+
|
|
183
|
+
// end include: runtime_exceptions.js
|
|
184
|
+
// include: runtime_debug.js
|
|
185
|
+
// end include: runtime_debug.js
|
|
186
|
+
// Memory management
|
|
187
|
+
var runtimeInitialized = false;
|
|
188
|
+
|
|
189
|
+
// When ALLOW_MEMORY_GROWTH is enabled, the conversion from Wasm
|
|
190
|
+
// memory to ArrayBuffer requires some additional logic.
|
|
191
|
+
function getMemoryBuffer() {
|
|
192
|
+
return wasmMemory.buffer;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function updateMemoryViews() {
|
|
196
|
+
// If we already have a heap that is resizeable/growable buffer we don't
|
|
197
|
+
// need to do anything in updateMemoryViews.
|
|
198
|
+
if (HEAP8?.buffer?.resizable) return;
|
|
199
|
+
var b = getMemoryBuffer();
|
|
200
|
+
HEAP8 = new Int8Array(b);
|
|
201
|
+
HEAPU8 = new Uint8Array(b);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// include: memoryprofiler.js
|
|
205
|
+
// end include: memoryprofiler.js
|
|
206
|
+
// end include: runtime_common.js
|
|
207
|
+
function preRun() {
|
|
208
|
+
var preRun = Module["preRun"];
|
|
209
|
+
if (preRun) {
|
|
210
|
+
if (typeof preRun === "function") preRun = [ preRun ];
|
|
211
|
+
onPreRuns.push(...preRun);
|
|
212
|
+
}
|
|
213
|
+
// Begin ATPRERUNS hooks
|
|
214
|
+
callRuntimeCallbacks(onPreRuns);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function initRuntime() {
|
|
218
|
+
runtimeInitialized = true;
|
|
219
|
+
// No ATINITS hooks
|
|
220
|
+
wasmExports["c"]();
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function postRun() {
|
|
224
|
+
var postRun = Module["postRun"];
|
|
225
|
+
if (postRun) {
|
|
226
|
+
if (typeof postRun === "function") postRun = [ postRun ];
|
|
227
|
+
onPostRuns.push(...postRun);
|
|
228
|
+
}
|
|
229
|
+
// Begin ATPOSTRUNS hooks
|
|
230
|
+
callRuntimeCallbacks(onPostRuns);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* @param {string|number=} what
|
|
235
|
+
*/ function abort(what) {
|
|
236
|
+
Module["onAbort"]?.(what);
|
|
237
|
+
what = `Aborted(${what})`;
|
|
238
|
+
// TODO(sbc): Should we remove printing and leave it up to whoever
|
|
239
|
+
// catches the exception?
|
|
240
|
+
err(what);
|
|
241
|
+
ABORT = true;
|
|
242
|
+
what += ". Build with -sASSERTIONS for more info.";
|
|
243
|
+
// Use a wasm runtime error, because a JS error might be seen as a foreign
|
|
244
|
+
// exception, which means we'd run destructors on it. We need the error to
|
|
245
|
+
// simply make the program stop.
|
|
246
|
+
// FIXME This approach does not work in Wasm EH because it currently does not assume
|
|
247
|
+
// all RuntimeErrors are from traps; it decides whether a RuntimeError is from
|
|
248
|
+
// a trap or not based on a hidden field within the object. So at the moment
|
|
249
|
+
// we don't have a way of throwing a wasm trap from JS. TODO Make a JS API that
|
|
250
|
+
// allows this in the wasm spec.
|
|
251
|
+
throw new WebAssembly.RuntimeError(what);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
var wasmBinaryFile;
|
|
255
|
+
|
|
256
|
+
function findWasmBinary() {
|
|
257
|
+
if (Module["locateFile"]) {
|
|
258
|
+
return locateFile("litlaunch-library-api-0.2.7+tweak.4-wasm32-emscripten-release.wasm");
|
|
259
|
+
}
|
|
260
|
+
// Use bundler-friendly `new URL(..., import.meta.url)` pattern; works in browsers too.
|
|
261
|
+
return new URL("litlaunch-library-api-0.2.7+tweak.4-wasm32-emscripten-release.wasm", import.meta.url).href;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function getBinarySync(file) {
|
|
265
|
+
if (readBinary) {
|
|
266
|
+
return readBinary(file);
|
|
267
|
+
}
|
|
268
|
+
// Throwing a plain string here, even though it not normally advisable since
|
|
269
|
+
// this gets turning into an `abort` in instantiateArrayBuffer.
|
|
270
|
+
throw "both async and sync fetching of the wasm failed";
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
async function getWasmBinary(binaryFile) {
|
|
274
|
+
// If we don't have the binary yet, load it asynchronously using readAsync.
|
|
275
|
+
if (!wasmBinary) {
|
|
276
|
+
// Fetch the binary using readAsync
|
|
277
|
+
try {
|
|
278
|
+
// Await so a rejection is caught and falls back to getBinarySync.
|
|
279
|
+
return await readAsync(binaryFile);
|
|
280
|
+
} catch {}
|
|
281
|
+
}
|
|
282
|
+
// Otherwise, getBinarySync should be able to get it synchronously
|
|
283
|
+
return getBinarySync(binaryFile);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
async function instantiateArrayBuffer(binaryFile, imports) {
|
|
287
|
+
try {
|
|
288
|
+
var binary = await getWasmBinary(binaryFile);
|
|
289
|
+
var instance = await WebAssembly.instantiate(binary, imports);
|
|
290
|
+
return instance;
|
|
291
|
+
} catch (reason) {
|
|
292
|
+
err(`failed to asynchronously prepare wasm: ${reason}`);
|
|
293
|
+
abort(reason);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
async function instantiateAsync(binary, binaryFile, imports) {
|
|
298
|
+
if (!binary && !isFileURI(binaryFile) && !ENVIRONMENT_IS_NODE) {
|
|
299
|
+
try {
|
|
300
|
+
var response = fetch(binaryFile, {
|
|
301
|
+
credentials: "same-origin"
|
|
302
|
+
});
|
|
303
|
+
var instantiationResult = await WebAssembly.instantiateStreaming(response, imports);
|
|
304
|
+
return instantiationResult;
|
|
305
|
+
} catch (reason) {
|
|
306
|
+
// We expect the most common failure cause to be a bad MIME type for the binary,
|
|
307
|
+
// in which case falling back to ArrayBuffer instantiation should work.
|
|
308
|
+
err(`wasm streaming compile failed: ${reason}`);
|
|
309
|
+
err("falling back to ArrayBuffer instantiation");
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
return instantiateArrayBuffer(binaryFile, imports);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
function getWasmImports() {
|
|
316
|
+
// prepare imports
|
|
317
|
+
var imports = {
|
|
318
|
+
"a": wasmImports
|
|
319
|
+
};
|
|
320
|
+
return imports;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// Create the wasm instance.
|
|
324
|
+
// Receives the wasm imports, returns the exports.
|
|
325
|
+
async function createWasm() {
|
|
326
|
+
// Load the wasm module and create an instance of using native support in the JS engine.
|
|
327
|
+
// handle a generated wasm instance, receiving its exports and
|
|
328
|
+
// performing other necessary setup
|
|
329
|
+
function receiveInstance(instance) {
|
|
330
|
+
wasmExports = instance.exports;
|
|
331
|
+
assignWasmExports(wasmExports);
|
|
332
|
+
updateMemoryViews();
|
|
333
|
+
return wasmExports;
|
|
334
|
+
}
|
|
335
|
+
// Prefer streaming instantiation if available.
|
|
336
|
+
function receiveInstantiationResult(result) {
|
|
337
|
+
// 'result' is a ResultObject object which has both the module and instance.
|
|
338
|
+
// receiveInstance() will swap in the exports (to Module.asm) so they can be called
|
|
339
|
+
// TODO: Due to Closure regression https://github.com/google/closure-compiler/issues/3193, the above line no longer optimizes out down to the following line.
|
|
340
|
+
// When the regression is fixed, can restore the above PTHREADS-enabled path.
|
|
341
|
+
return receiveInstance(result["instance"]);
|
|
342
|
+
}
|
|
343
|
+
var info = getWasmImports();
|
|
344
|
+
// User shell pages can write their own Module.instantiateWasm = function(imports, successCallback) callback
|
|
345
|
+
// to manually instantiate the Wasm module themselves. This allows pages to
|
|
346
|
+
// run the instantiation parallel to any other async startup actions they are
|
|
347
|
+
// performing.
|
|
348
|
+
// Also pthreads and wasm workers initialize the wasm instance through this
|
|
349
|
+
// path.
|
|
350
|
+
var instantiateWasm = Module["instantiateWasm"];
|
|
351
|
+
if (instantiateWasm) {
|
|
352
|
+
return new Promise(resolve => {
|
|
353
|
+
instantiateWasm(info, inst => resolve(receiveInstance(inst)));
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
wasmBinaryFile ??= findWasmBinary();
|
|
357
|
+
var result = await instantiateAsync(wasmBinary, wasmBinaryFile, info);
|
|
358
|
+
var exports = receiveInstantiationResult(result);
|
|
359
|
+
return exports;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
// end include: preamble.js
|
|
363
|
+
// Begin JS library code
|
|
364
|
+
class ExitStatus {
|
|
365
|
+
name="ExitStatus";
|
|
366
|
+
constructor(status) {
|
|
367
|
+
this.message = `Program terminated with exit(${status})`;
|
|
368
|
+
this.status = status;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/** @type {!Int8Array} */ var HEAP8;
|
|
373
|
+
|
|
374
|
+
var callRuntimeCallbacks = callbacks => {
|
|
375
|
+
while (callbacks.length > 0) {
|
|
376
|
+
// Pass the module as the first argument.
|
|
377
|
+
callbacks.shift()(Module);
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
var onPostRuns = [];
|
|
382
|
+
|
|
383
|
+
var onPreRuns = [];
|
|
384
|
+
|
|
385
|
+
var noExitRuntime = true;
|
|
386
|
+
|
|
387
|
+
var stackRestore = val => __emscripten_stack_restore(val);
|
|
388
|
+
|
|
389
|
+
var stackSave = () => _emscripten_stack_get_current();
|
|
390
|
+
|
|
391
|
+
/** @type {!Uint8Array} */ var HEAPU8;
|
|
392
|
+
|
|
393
|
+
var alignMemory = (size, alignment) => Math.ceil(size / alignment) * alignment;
|
|
394
|
+
|
|
395
|
+
var getHeapMax = () => // Stay one Wasm page short of 4GB: while e.g. Chrome is able to allocate
|
|
396
|
+
// full 4GB Wasm memories, the size will wrap back to 0 bytes in Wasm side
|
|
397
|
+
// for any code that deals with heap sizes, which would require special
|
|
398
|
+
// casing all heap size related code to treat 0 specially.
|
|
399
|
+
2147483648;
|
|
400
|
+
|
|
401
|
+
var growMemory = size => {
|
|
402
|
+
var oldHeapSize = wasmMemory.buffer.byteLength;
|
|
403
|
+
var pages = ((size - oldHeapSize + 65535) / 65536) | 0;
|
|
404
|
+
try {
|
|
405
|
+
// round size grow request up to wasm page size (fixed 64KB per spec)
|
|
406
|
+
wasmMemory.grow(pages);
|
|
407
|
+
// .grow() takes a delta compared to the previous size
|
|
408
|
+
updateMemoryViews();
|
|
409
|
+
return 1;
|
|
410
|
+
} catch (e) {}
|
|
411
|
+
};
|
|
412
|
+
|
|
413
|
+
var _emscripten_resize_heap = requestedSize => {
|
|
414
|
+
var oldSize = HEAPU8.length;
|
|
415
|
+
// With CAN_ADDRESS_2GB or MEMORY64, pointers are already unsigned.
|
|
416
|
+
requestedSize >>>= 0;
|
|
417
|
+
// With multithreaded builds, races can happen (another thread might increase the size
|
|
418
|
+
// in between), so return a failure, and let the caller retry.
|
|
419
|
+
// Memory resize rules:
|
|
420
|
+
// 1. Always increase heap size to at least the requested size, rounded up
|
|
421
|
+
// to next page multiple.
|
|
422
|
+
// 2a. If MEMORY_GROWTH_LINEAR_STEP == -1, excessively resize the heap
|
|
423
|
+
// geometrically: increase the heap size according to
|
|
424
|
+
// MEMORY_GROWTH_GEOMETRIC_STEP factor (default +20%), At most
|
|
425
|
+
// overreserve by MEMORY_GROWTH_GEOMETRIC_CAP bytes (default 96MB).
|
|
426
|
+
// 2b. If MEMORY_GROWTH_LINEAR_STEP != -1, excessively resize the heap
|
|
427
|
+
// linearly: increase the heap size by at least
|
|
428
|
+
// MEMORY_GROWTH_LINEAR_STEP bytes.
|
|
429
|
+
// 3. Max size for the heap is capped at 2048MB-WASM_PAGE_SIZE, or by
|
|
430
|
+
// MAXIMUM_MEMORY, or by ASAN limit, depending on which is smallest
|
|
431
|
+
// 4. If we were unable to allocate as much memory, it may be due to
|
|
432
|
+
// over-eager decision to excessively reserve due to (3) above.
|
|
433
|
+
// Hence if an allocation fails, cut down on the amount of excess
|
|
434
|
+
// growth, in an attempt to succeed to perform a smaller allocation.
|
|
435
|
+
// A limit is set for how much we can grow. We should not exceed that
|
|
436
|
+
// (the wasm binary specifies it, so if we tried, we'd fail anyhow).
|
|
437
|
+
var maxHeapSize = getHeapMax();
|
|
438
|
+
if (requestedSize > maxHeapSize) {
|
|
439
|
+
return false;
|
|
440
|
+
}
|
|
441
|
+
// Loop through potential heap size increases. If we attempt a too eager
|
|
442
|
+
// reservation that fails, cut down on the attempted size and reserve a
|
|
443
|
+
// smaller bump instead. (max 3 times, chosen somewhat arbitrarily)
|
|
444
|
+
for (var cutDown = 1; cutDown <= 4; cutDown *= 2) {
|
|
445
|
+
var overGrownHeapSize = oldSize * (1 + .2 / cutDown);
|
|
446
|
+
// ensure geometric growth
|
|
447
|
+
// but limit overreserving (default to capping at +96MB overgrowth at most)
|
|
448
|
+
overGrownHeapSize = Math.min(overGrownHeapSize, requestedSize + 100663296);
|
|
449
|
+
var newSize = Math.min(maxHeapSize, alignMemory(Math.max(requestedSize, overGrownHeapSize), 65536));
|
|
450
|
+
var replacement = growMemory(newSize);
|
|
451
|
+
if (replacement) {
|
|
452
|
+
return true;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
return false;
|
|
456
|
+
};
|
|
457
|
+
|
|
458
|
+
var UTF8Decoder = globalThis.TextDecoder && new TextDecoder;
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* heapOrArray is either a regular array, or a JavaScript typed array view.
|
|
462
|
+
* @param {number} idx
|
|
463
|
+
* @param {number=} maxBytesToRead
|
|
464
|
+
* @param {boolean=} ignoreNul
|
|
465
|
+
* @return {number}
|
|
466
|
+
*/ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
467
|
+
var maxIdx = idx + maxBytesToRead;
|
|
468
|
+
if (ignoreNul) return maxIdx;
|
|
469
|
+
// TextDecoder needs to know the byte length in advance, it doesn't stop on
|
|
470
|
+
// null terminator by itself.
|
|
471
|
+
// As a tiny code save trick, compare idx against maxIdx using a negation,
|
|
472
|
+
// so that maxBytesToRead=undefined/NaN means Infinity.
|
|
473
|
+
while (heapOrArray[idx] && !(idx >= maxIdx)) ++idx;
|
|
474
|
+
return idx;
|
|
475
|
+
};
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* Given a pointer 'idx' to a null-terminated UTF8-encoded string in the given
|
|
479
|
+
* array that contains uint8 values, returns a copy of that string as a
|
|
480
|
+
* Javascript String object.
|
|
481
|
+
* heapOrArray is either a regular array, or a JavaScript typed array view.
|
|
482
|
+
* @param {number=} idx
|
|
483
|
+
* @param {number=} maxBytesToRead
|
|
484
|
+
* @param {boolean=} ignoreNul - If true, the function will not stop on a NUL character.
|
|
485
|
+
* @return {string}
|
|
486
|
+
*/ var UTF8ArrayToString = (heapOrArray, idx = 0, maxBytesToRead, ignoreNul) => {
|
|
487
|
+
var endPtr = findStringEnd(heapOrArray, idx, maxBytesToRead, ignoreNul);
|
|
488
|
+
// When using conditional TextDecoder, skip it for short strings as the overhead of the native call is not worth it.
|
|
489
|
+
if (endPtr - idx > 16 && heapOrArray.buffer && UTF8Decoder) {
|
|
490
|
+
return UTF8Decoder.decode(heapOrArray.subarray(idx, endPtr));
|
|
491
|
+
}
|
|
492
|
+
var str = "";
|
|
493
|
+
while (idx < endPtr) {
|
|
494
|
+
// For UTF8 byte structure, see:
|
|
495
|
+
// http://en.wikipedia.org/wiki/UTF-8#Description
|
|
496
|
+
// https://www.ietf.org/rfc/rfc2279.txt
|
|
497
|
+
// https://tools.ietf.org/html/rfc3629
|
|
498
|
+
var u0 = heapOrArray[idx++];
|
|
499
|
+
if (!(u0 & 128)) {
|
|
500
|
+
str += String.fromCharCode(u0);
|
|
501
|
+
continue;
|
|
502
|
+
}
|
|
503
|
+
var u1 = heapOrArray[idx++] & 63;
|
|
504
|
+
if ((u0 & 224) == 192) {
|
|
505
|
+
str += String.fromCharCode(((u0 & 31) << 6) | u1);
|
|
506
|
+
continue;
|
|
507
|
+
}
|
|
508
|
+
var u2 = heapOrArray[idx++] & 63;
|
|
509
|
+
if ((u0 & 240) == 224) {
|
|
510
|
+
u0 = ((u0 & 15) << 12) | (u1 << 6) | u2;
|
|
511
|
+
} else {
|
|
512
|
+
u0 = ((u0 & 7) << 18) | (u1 << 12) | (u2 << 6) | (heapOrArray[idx++] & 63);
|
|
513
|
+
}
|
|
514
|
+
if (u0 < 65536) {
|
|
515
|
+
str += String.fromCharCode(u0);
|
|
516
|
+
} else {
|
|
517
|
+
var ch = u0 - 65536;
|
|
518
|
+
str += String.fromCharCode(55296 | (ch >> 10), 56320 | (ch & 1023));
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
return str;
|
|
522
|
+
};
|
|
523
|
+
|
|
524
|
+
/**
|
|
525
|
+
* Given a pointer 'ptr' to a null-terminated UTF8-encoded string in the
|
|
526
|
+
* emscripten HEAP, returns a copy of that string as a Javascript String object.
|
|
527
|
+
*
|
|
528
|
+
* @param {number} ptr
|
|
529
|
+
* @param {number=} maxBytesToRead - An optional length that specifies the
|
|
530
|
+
* maximum number of bytes to read. You can omit this parameter to scan the
|
|
531
|
+
* string until the first 0 byte. If maxBytesToRead is passed, and the string
|
|
532
|
+
* at [ptr, ptr+maxBytesToReadr[ contains a null byte in the middle, then the
|
|
533
|
+
* string will cut short at that byte index.
|
|
534
|
+
* @param {boolean=} ignoreNul - If true, the function will not stop on a NUL character.
|
|
535
|
+
* @return {string}
|
|
536
|
+
*/ var UTF8ToString = (ptr, maxBytesToRead, ignoreNul) => {
|
|
537
|
+
var rtn = ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead, ignoreNul) : "";
|
|
538
|
+
return rtn;
|
|
539
|
+
};
|
|
540
|
+
|
|
541
|
+
var getCFunc = ident => {
|
|
542
|
+
var func = Module["_" + ident];
|
|
543
|
+
// closure exported function
|
|
544
|
+
return func;
|
|
545
|
+
};
|
|
546
|
+
|
|
547
|
+
var stackAlloc = sz => __emscripten_stack_alloc(sz);
|
|
548
|
+
|
|
549
|
+
var lengthBytesUTF8 = str => {
|
|
550
|
+
var len = 0;
|
|
551
|
+
for (var i = 0; i < str.length; ++i) {
|
|
552
|
+
var u = str.codePointAt(i);
|
|
553
|
+
if (u <= 127) {
|
|
554
|
+
len++;
|
|
555
|
+
} else if (u <= 2047) {
|
|
556
|
+
len += 2;
|
|
557
|
+
} else if (u <= 65535) {
|
|
558
|
+
len += 3;
|
|
559
|
+
} else {
|
|
560
|
+
len += 4;
|
|
561
|
+
// Gotcha: if codePoint is over 0xFFFF, it is represented as a surrogate pair in UTF-16.
|
|
562
|
+
// We need to manually skip over the second code unit for correct iteration.
|
|
563
|
+
i++;
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
return len;
|
|
567
|
+
};
|
|
568
|
+
|
|
569
|
+
var stringToUTF8Array = (str, heap, outIdx, maxBytesToWrite) => {
|
|
570
|
+
// Parameter maxBytesToWrite is not optional. Negative values, 0, null,
|
|
571
|
+
// undefined and false each don't write out any bytes.
|
|
572
|
+
if (!(maxBytesToWrite > 0)) return 0;
|
|
573
|
+
var startIdx = outIdx;
|
|
574
|
+
var endIdx = outIdx + maxBytesToWrite - 1;
|
|
575
|
+
// -1 for string null terminator.
|
|
576
|
+
for (var i = 0; i < str.length; ++i) {
|
|
577
|
+
// For UTF8 byte structure, see http://en.wikipedia.org/wiki/UTF-8#Description
|
|
578
|
+
// and https://www.ietf.org/rfc/rfc2279.txt
|
|
579
|
+
// and https://tools.ietf.org/html/rfc3629
|
|
580
|
+
var u = str.codePointAt(i);
|
|
581
|
+
if (u <= 127) {
|
|
582
|
+
if (outIdx >= endIdx) break;
|
|
583
|
+
heap[outIdx++] = u;
|
|
584
|
+
} else if (u <= 2047) {
|
|
585
|
+
if (outIdx + 1 >= endIdx) break;
|
|
586
|
+
heap[outIdx++] = 192 | (u >> 6);
|
|
587
|
+
heap[outIdx++] = 128 | (u & 63);
|
|
588
|
+
} else if (u <= 65535) {
|
|
589
|
+
if (outIdx + 2 >= endIdx) break;
|
|
590
|
+
heap[outIdx++] = 224 | (u >> 12);
|
|
591
|
+
heap[outIdx++] = 128 | ((u >> 6) & 63);
|
|
592
|
+
heap[outIdx++] = 128 | (u & 63);
|
|
593
|
+
} else {
|
|
594
|
+
if (outIdx + 3 >= endIdx) break;
|
|
595
|
+
heap[outIdx++] = 240 | (u >> 18);
|
|
596
|
+
heap[outIdx++] = 128 | ((u >> 12) & 63);
|
|
597
|
+
heap[outIdx++] = 128 | ((u >> 6) & 63);
|
|
598
|
+
heap[outIdx++] = 128 | (u & 63);
|
|
599
|
+
// Gotcha: if codePoint is over 0xFFFF, it is represented as a surrogate pair in UTF-16.
|
|
600
|
+
// We need to manually skip over the second code unit for correct iteration.
|
|
601
|
+
i++;
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
// Null-terminate the pointer to the buffer.
|
|
605
|
+
heap[outIdx] = 0;
|
|
606
|
+
return outIdx - startIdx;
|
|
607
|
+
};
|
|
608
|
+
|
|
609
|
+
var stringToUTF8 = (str, outPtr, maxBytesToWrite) => stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite);
|
|
610
|
+
|
|
611
|
+
var stringToUTF8OnStack = str => {
|
|
612
|
+
var size = lengthBytesUTF8(str) + 1;
|
|
613
|
+
var ret = stackAlloc(size);
|
|
614
|
+
stringToUTF8(str, ret, size);
|
|
615
|
+
return ret;
|
|
616
|
+
};
|
|
617
|
+
|
|
618
|
+
var writeArrayToMemory = (array, buffer) => {
|
|
619
|
+
HEAP8.set(array, buffer);
|
|
620
|
+
};
|
|
621
|
+
|
|
622
|
+
/**
|
|
623
|
+
* @param {string|null=} returnType
|
|
624
|
+
* @param {Array=} argTypes
|
|
625
|
+
* @param {Array=} args
|
|
626
|
+
* @param {Object=} opts
|
|
627
|
+
*/ var ccall = (ident, returnType, argTypes, args, opts) => {
|
|
628
|
+
// For fast lookup of conversion functions
|
|
629
|
+
var toC = {
|
|
630
|
+
"string": str => {
|
|
631
|
+
var ret = 0;
|
|
632
|
+
if (str !== null && str !== undefined && str !== 0) {
|
|
633
|
+
// null string
|
|
634
|
+
ret = stringToUTF8OnStack(str);
|
|
635
|
+
}
|
|
636
|
+
return ret;
|
|
637
|
+
},
|
|
638
|
+
"array": arr => {
|
|
639
|
+
var ret = stackAlloc(arr.length);
|
|
640
|
+
writeArrayToMemory(arr, ret);
|
|
641
|
+
return ret;
|
|
642
|
+
}
|
|
643
|
+
};
|
|
644
|
+
function convertReturnValue(ret) {
|
|
645
|
+
if (returnType === "string") {
|
|
646
|
+
return UTF8ToString(ret);
|
|
647
|
+
}
|
|
648
|
+
if (returnType === "boolean") return Boolean(ret);
|
|
649
|
+
return ret;
|
|
650
|
+
}
|
|
651
|
+
var func = getCFunc(ident);
|
|
652
|
+
var cArgs = [];
|
|
653
|
+
var stack = 0;
|
|
654
|
+
if (args) {
|
|
655
|
+
for (var i = 0; i < args.length; i++) {
|
|
656
|
+
var converter = toC[argTypes[i]];
|
|
657
|
+
if (converter) {
|
|
658
|
+
if (!stack) stack = stackSave();
|
|
659
|
+
cArgs[i] = converter(args[i]);
|
|
660
|
+
} else {
|
|
661
|
+
cArgs[i] = args[i];
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
var ret = func(...cArgs);
|
|
666
|
+
function onDone(ret) {
|
|
667
|
+
if (stack) stackRestore(stack);
|
|
668
|
+
return convertReturnValue(ret);
|
|
669
|
+
}
|
|
670
|
+
ret = onDone(ret);
|
|
671
|
+
return ret;
|
|
672
|
+
};
|
|
673
|
+
|
|
674
|
+
/**
|
|
675
|
+
* @param {string=} returnType
|
|
676
|
+
* @param {Array=} argTypes
|
|
677
|
+
* @param {Object=} opts
|
|
678
|
+
*/ var cwrap = (ident, returnType, argTypes, opts) => {
|
|
679
|
+
// When the function takes numbers and returns a number, we can just return
|
|
680
|
+
// the original function
|
|
681
|
+
var numericArgs = !argTypes || argTypes.every(type => type === "number" || type === "boolean");
|
|
682
|
+
var numericRet = returnType !== "string";
|
|
683
|
+
if (numericRet && numericArgs && !opts) {
|
|
684
|
+
return getCFunc(ident);
|
|
685
|
+
}
|
|
686
|
+
return (...args) => ccall(ident, returnType, argTypes, args, opts);
|
|
687
|
+
};
|
|
688
|
+
|
|
689
|
+
var stringToNewUTF8 = str => {
|
|
690
|
+
var size = lengthBytesUTF8(str) + 1;
|
|
691
|
+
var ret = _malloc(size);
|
|
692
|
+
if (ret) stringToUTF8(str, ret, size);
|
|
693
|
+
return ret;
|
|
694
|
+
};
|
|
695
|
+
|
|
696
|
+
// End JS library code
|
|
697
|
+
// include: postlibrary.js
|
|
698
|
+
// This file is included after the automatically-generated JS library code
|
|
699
|
+
// but before the wasm module is created.
|
|
700
|
+
{
|
|
701
|
+
// Begin ATMODULES hooks
|
|
702
|
+
if (Module["noExitRuntime"]) noExitRuntime = Module["noExitRuntime"];
|
|
703
|
+
if (Module["print"]) out = Module["print"];
|
|
704
|
+
if (Module["printErr"]) err = Module["printErr"];
|
|
705
|
+
// End ATMODULES hooks
|
|
706
|
+
if (Module["arguments"]) programArgs = Module["arguments"];
|
|
707
|
+
if (Module["thisProgram"]) thisProgram = Module["thisProgram"];
|
|
708
|
+
var preInit = Module["preInit"];
|
|
709
|
+
if (preInit) {
|
|
710
|
+
if (typeof preInit === "function") Module["preInit"] = preInit = [ preInit ];
|
|
711
|
+
// Written as a loop so that preInit functions that themselves add more
|
|
712
|
+
// preInit functions. Is this actually needed?
|
|
713
|
+
while (preInit.length > 0) {
|
|
714
|
+
preInit.shift()();
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
// Begin runtime exports
|
|
720
|
+
Module["ccall"] = ccall;
|
|
721
|
+
|
|
722
|
+
Module["cwrap"] = cwrap;
|
|
723
|
+
|
|
724
|
+
Module["UTF8ToString"] = UTF8ToString;
|
|
725
|
+
|
|
726
|
+
Module["stringToNewUTF8"] = stringToNewUTF8;
|
|
727
|
+
|
|
728
|
+
// End runtime exports
|
|
729
|
+
// Begin JS library exports
|
|
730
|
+
// End JS library exports
|
|
731
|
+
// end include: postlibrary.js
|
|
732
|
+
// Imports from the Wasm binary.
|
|
733
|
+
var _newResourceLocation, _resourceLocationToString, _freeResourceLocation, _getSemVer2_0_0Comparator, _applyVersionComparator, _newVersionComparator, _freeVersionComparator, _newModule, _moduleToString, _freeModule, _newVersion, _versionToString, _freeVersion, _versionComparatorToString, _newDependencyDict, _addToDependencyDict, _removeFromDependencyDictAndFree, _dependencyDictToString, _dependencyDictElementToString, _freeDependencyDict, _initLibraryApi, _freeLitLaunchLibraryApi, _malloc, _free, __emscripten_stack_restore, __emscripten_stack_alloc, _emscripten_stack_get_current, memory, __indirect_function_table, wasmMemory;
|
|
734
|
+
|
|
735
|
+
function assignWasmExports(wasmExports) {
|
|
736
|
+
_newResourceLocation = Module["_newResourceLocation"] = wasmExports["d"];
|
|
737
|
+
_resourceLocationToString = Module["_resourceLocationToString"] = wasmExports["e"];
|
|
738
|
+
_freeResourceLocation = Module["_freeResourceLocation"] = wasmExports["f"];
|
|
739
|
+
_getSemVer2_0_0Comparator = Module["_getSemVer2_0_0Comparator"] = wasmExports["g"];
|
|
740
|
+
_applyVersionComparator = Module["_applyVersionComparator"] = wasmExports["h"];
|
|
741
|
+
_newVersionComparator = Module["_newVersionComparator"] = wasmExports["i"];
|
|
742
|
+
_freeVersionComparator = Module["_freeVersionComparator"] = wasmExports["j"];
|
|
743
|
+
_newModule = Module["_newModule"] = wasmExports["k"];
|
|
744
|
+
_moduleToString = Module["_moduleToString"] = wasmExports["l"];
|
|
745
|
+
_freeModule = Module["_freeModule"] = wasmExports["m"];
|
|
746
|
+
_newVersion = Module["_newVersion"] = wasmExports["n"];
|
|
747
|
+
_versionToString = Module["_versionToString"] = wasmExports["o"];
|
|
748
|
+
_freeVersion = Module["_freeVersion"] = wasmExports["p"];
|
|
749
|
+
_versionComparatorToString = Module["_versionComparatorToString"] = wasmExports["q"];
|
|
750
|
+
_newDependencyDict = Module["_newDependencyDict"] = wasmExports["r"];
|
|
751
|
+
_addToDependencyDict = Module["_addToDependencyDict"] = wasmExports["s"];
|
|
752
|
+
_removeFromDependencyDictAndFree = Module["_removeFromDependencyDictAndFree"] = wasmExports["t"];
|
|
753
|
+
_dependencyDictToString = Module["_dependencyDictToString"] = wasmExports["u"];
|
|
754
|
+
_dependencyDictElementToString = Module["_dependencyDictElementToString"] = wasmExports["v"];
|
|
755
|
+
_freeDependencyDict = Module["_freeDependencyDict"] = wasmExports["w"];
|
|
756
|
+
_initLibraryApi = Module["_initLibraryApi"] = wasmExports["x"];
|
|
757
|
+
_freeLitLaunchLibraryApi = Module["_freeLitLaunchLibraryApi"] = wasmExports["y"];
|
|
758
|
+
_malloc = Module["_malloc"] = wasmExports["z"];
|
|
759
|
+
_free = Module["_free"] = wasmExports["A"];
|
|
760
|
+
__emscripten_stack_restore = wasmExports["B"];
|
|
761
|
+
__emscripten_stack_alloc = wasmExports["C"];
|
|
762
|
+
_emscripten_stack_get_current = wasmExports["D"];
|
|
763
|
+
memory = wasmMemory = wasmExports["b"];
|
|
764
|
+
__indirect_function_table = wasmExports["__indirect_function_table"];
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
var wasmImports = {
|
|
768
|
+
/** @export */ a: _emscripten_resize_heap
|
|
769
|
+
};
|
|
770
|
+
|
|
771
|
+
// include: postamble.js
|
|
772
|
+
// === Auto-generated postamble setup entry stuff ===
|
|
773
|
+
async function run() {
|
|
774
|
+
preRun();
|
|
775
|
+
var setStatus = Module["setStatus"];
|
|
776
|
+
if (setStatus) {
|
|
777
|
+
setStatus("Running...");
|
|
778
|
+
// Yield to the event loop to allow the browser to paint "Running..."
|
|
779
|
+
await new Promise(resolve => setTimeout(resolve, 1));
|
|
780
|
+
// Then we want to clear the status text, but only after the rest of this function runs.
|
|
781
|
+
setTimeout(setStatus, 1, "");
|
|
782
|
+
}
|
|
783
|
+
if (ABORT) return;
|
|
784
|
+
initRuntime();
|
|
785
|
+
Module["onRuntimeInitialized"]?.();
|
|
786
|
+
postRun();
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
var wasmExports;
|
|
790
|
+
|
|
791
|
+
// In modularize mode the generated code is within a factory function so we
|
|
792
|
+
// can use await here (since it's not top-level-await).
|
|
793
|
+
wasmExports = await createWasm();
|
|
794
|
+
|
|
795
|
+
await run();
|
|
796
|
+
|
|
797
|
+
|
|
798
|
+
return Module;
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
// Export using a UMD style export, or ES6 exports if selected
|
|
802
|
+
export default LitLaunchLibraryApi;
|
|
803
|
+
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "litlaunch-library-api",
|
|
3
|
-
"version": "0.2.7-tweak.
|
|
3
|
+
"version": "0.2.7-tweak.4",
|
|
4
4
|
"description": "WebAssembly build of the LitLaunch library API.",
|
|
5
5
|
"license": "GPL-3.0-or-later",
|
|
6
6
|
"author": "Angelina Michalek (Codetoil)",
|
|
@@ -10,19 +10,19 @@
|
|
|
10
10
|
"directory": "litlaunch-library-api"
|
|
11
11
|
},
|
|
12
12
|
"type": "module",
|
|
13
|
-
"main": "./litlaunch-library-api-0.2.7+tweak.
|
|
13
|
+
"main": "./litlaunch-library-api-0.2.7+tweak.4-wasm32-emscripten-release.mjs",
|
|
14
14
|
"types": "./index.d.mts",
|
|
15
15
|
"exports": {
|
|
16
16
|
".": {
|
|
17
17
|
"types": "./index.d.mts",
|
|
18
|
-
"default": "./litlaunch-library-api-0.2.7+tweak.
|
|
18
|
+
"default": "./litlaunch-library-api-0.2.7+tweak.4-wasm32-emscripten-release.mjs"
|
|
19
19
|
},
|
|
20
|
-
"./wasm": "./litlaunch-library-api-0.2.7+tweak.
|
|
20
|
+
"./wasm": "./litlaunch-library-api-0.2.7+tweak.4-wasm32-emscripten-release.wasm",
|
|
21
21
|
"./package.json": "./package.json"
|
|
22
22
|
},
|
|
23
23
|
"files": [
|
|
24
|
-
"litlaunch-library-api-0.2.7+tweak.
|
|
25
|
-
"litlaunch-library-api-0.2.7+tweak.
|
|
24
|
+
"litlaunch-library-api-0.2.7+tweak.4-wasm32-emscripten-release.mjs",
|
|
25
|
+
"litlaunch-library-api-0.2.7+tweak.4-wasm32-emscripten-release.wasm",
|
|
26
26
|
"index.d.mts",
|
|
27
27
|
"LICENSE.md",
|
|
28
28
|
"LICENSE-C-SEMVER"
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
async function LitLaunchLibraryApi(moduleArg={}){var Module=moduleArg;var ENVIRONMENT_IS_WEB=!!globalThis.window;var ENVIRONMENT_IS_WORKER=!!globalThis.WorkerGlobalScope;var ENVIRONMENT_IS_NODE=globalThis.process?.versions?.node&&globalThis.process?.type!="renderer";if(ENVIRONMENT_IS_NODE){const{createRequire}=await(import("node:module"));var require=createRequire(import.meta.url)}var _scriptName=import.meta.url;var scriptDirectory="";function locateFile(path){if(Module["locateFile"])return Module["locateFile"](path,scriptDirectory);return scriptDirectory+path}var readAsync,readBinary;if(ENVIRONMENT_IS_NODE){var fs=require("node:fs");if(_scriptName.startsWith("file:"))scriptDirectory=require("node:path").dirname(require("node:url").fileURLToPath(_scriptName))+"/";readBinary=filename=>{filename=isFileURI(filename)?new URL(filename):filename;var ret=fs.readFileSync(filename);return ret};readAsync=async(filename,binary=true)=>{filename=isFileURI(filename)?new URL(filename):filename;var ret=fs.readFileSync(filename,binary?void 0:"utf8");return ret};if(process.argv.length>1)process.argv[1].replace(/\\/g,"/");process.argv.slice(2);0}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){try{scriptDirectory=new URL(".",_scriptName).href}catch{}if(ENVIRONMENT_IS_WORKER)readBinary=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)};readAsync=async url=>{if(isFileURI(url))return new Promise((resolve,reject)=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=()=>{if(xhr.status==200||xhr.status==0&&xhr.response){resolve(xhr.response);return}reject(xhr.status)};xhr.onerror=reject;xhr.send(null)});var response=await fetch(url,{credentials:"same-origin"});if(response.ok)return response.arrayBuffer();throw new Error(response.status+" : "+response.url)}}console.log.bind(console);var err=console.error.bind(console);var ABORT=false;var isFileURI=filename=>filename.startsWith("file://");function getMemoryBuffer(){return wasmMemory.buffer}function updateMemoryViews(){if(HEAP8?.buffer?.resizable)return;var b=getMemoryBuffer();HEAP8=new Int8Array(b);HEAPU8=new Uint8Array(b)}function preRun(){var preRun=Module["preRun"];if(preRun){if(typeof preRun==="function")preRun=[preRun];onPreRuns.push(...preRun)}callRuntimeCallbacks(onPreRuns)}function initRuntime(){0;wasmExports["c"]()}function postRun(){var postRun=Module["postRun"];if(postRun){if(typeof postRun==="function")postRun=[postRun];onPostRuns.push(...postRun)}callRuntimeCallbacks(onPostRuns)}function abort(what){Module["onAbort"]?.(what);what=`Aborted(${what})`;err(what);ABORT=true;what+=". Build with -sASSERTIONS for more info.";throw new WebAssembly.RuntimeError(what)}var wasmBinaryFile;function findWasmBinary(){if(Module["locateFile"])return locateFile("litlaunch-library-api-0.2.7+tweak.2-wasm32-emscripten-release.wasm");return new URL("litlaunch-library-api-0.2.7+tweak.2-wasm32-emscripten-release.wasm",import.meta.url).href}function getBinarySync(file){if(readBinary)return readBinary(file);throw"both async and sync fetching of the wasm failed"}async function getWasmBinary(binaryFile){if(true)try{return await readAsync(binaryFile)}catch{}return getBinarySync(binaryFile)}async function instantiateArrayBuffer(binaryFile,imports){try{var binary=await getWasmBinary(binaryFile);var instance=await WebAssembly.instantiate(binary,imports);return instance}catch(reason){err(`failed to asynchronously prepare wasm: ${reason}`);abort(reason)}}async function instantiateAsync(binary,binaryFile,imports){if(!binary&&!isFileURI(binaryFile)&&!ENVIRONMENT_IS_NODE)try{var response=fetch(binaryFile,{credentials:"same-origin"});var instantiationResult=await WebAssembly.instantiateStreaming(response,imports);return instantiationResult}catch(reason){err(`wasm streaming compile failed: ${reason}`);err("falling back to ArrayBuffer instantiation")}return instantiateArrayBuffer(binaryFile,imports)}function getWasmImports(){var imports={a:wasmImports};return imports}var HEAP8;var callRuntimeCallbacks=callbacks=>{while(callbacks.length>0)callbacks.shift()(Module)};var onPostRuns=[];var onPreRuns=[];var stackRestore=val=>__emscripten_stack_restore(val);var stackSave=()=>_emscripten_stack_get_current();var HEAPU8;var alignMemory=(size,alignment)=>Math.ceil(size/alignment)*alignment;var getHeapMax=()=>2147483648;var growMemory=size=>{var oldHeapSize=wasmMemory.buffer.byteLength;var pages=(size-oldHeapSize+65535)/65536|0;try{wasmMemory.grow(pages);updateMemoryViews();return 1}catch(e){}};var UTF8Decoder=globalThis.TextDecoder&&new TextDecoder;var findStringEnd=(heapOrArray,idx,maxBytesToRead,ignoreNul)=>{var maxIdx=idx+maxBytesToRead;if(ignoreNul)return maxIdx;while(heapOrArray[idx]&&!(idx>=maxIdx))++idx;return idx};var UTF8ArrayToString=(heapOrArray,idx=0,maxBytesToRead,ignoreNul)=>{var endPtr=findStringEnd(heapOrArray,idx,maxBytesToRead,ignoreNul);if(endPtr-idx>16&&heapOrArray.buffer&&UTF8Decoder)return UTF8Decoder.decode(heapOrArray.subarray(idx,endPtr));var str="";while(idx<endPtr){var u0=heapOrArray[idx++];if(!(u0&128)){str+=String.fromCharCode(u0);continue}var u1=heapOrArray[idx++]&63;if((u0&224)==192){str+=String.fromCharCode((u0&31)<<6|u1);continue}var u2=heapOrArray[idx++]&63;if((u0&240)==224)u0=(u0&15)<<12|u1<<6|u2;else u0=(u0&7)<<18|u1<<12|u2<<6|heapOrArray[idx++]&63;if(u0<65536)str+=String.fromCharCode(u0);else{var ch=u0-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}}return str};var UTF8ToString=(ptr,maxBytesToRead,ignoreNul)=>{var rtn=ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead,ignoreNul):"";return rtn};var getCFunc=ident=>{var func=Module["_"+ident];return func};var stackAlloc=sz=>__emscripten_stack_alloc(sz);var lengthBytesUTF8=str=>{var len=0;for(var i=0;i<str.length;++i){var u=str.codePointAt(i);if(u<=127)len++;else if(u<=2047)len+=2;else if(u<=65535)len+=3;else{len+=4;i++}}return len};var stringToUTF8Array=(str,heap,outIdx,maxBytesToWrite)=>{if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i<str.length;++i){var u=str.codePointAt(i);if(u<=127){if(outIdx>=endIdx)break;heap[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++]=192|u>>6;heap[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++]=224|u>>12;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}else{if(outIdx+3>=endIdx)break;heap[outIdx++]=240|u>>18;heap[outIdx++]=128|u>>12&63;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63;i++}}heap[outIdx]=0;return outIdx-startIdx};var stringToUTF8=(str,outPtr,maxBytesToWrite)=>stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite);var stringToUTF8OnStack=str=>{var size=lengthBytesUTF8(str)+1;var ret=stackAlloc(size);stringToUTF8(str,ret,size);return ret};var writeArrayToMemory=(array,buffer)=>{HEAP8.set(array,buffer)};var ccall=(ident,returnType,argTypes,args)=>{var toC={string:str=>{var ret=0;if(str!==null&&str!==void 0&&str!==0)ret=stringToUTF8OnStack(str);return ret},array:arr=>{var ret=stackAlloc(arr.length);writeArrayToMemory(arr,ret);return ret}};function convertReturnValue(ret){if(returnType==="string")return UTF8ToString(ret);if(returnType==="boolean")return Boolean(ret);return ret}var func=getCFunc(ident);var cArgs=[];var stack=0;if(args)for(var i=0;i<args.length;i++){var converter=toC[argTypes[i]];if(converter){if(!stack)stack=stackSave();cArgs[i]=converter(args[i])}else cArgs[i]=args[i]}var ret=func(...cArgs);ret=function(ret){if(stack)stackRestore(stack);return convertReturnValue(ret)}(ret);return ret};if(Module["noExitRuntime"])Module["noExitRuntime"];if(Module["print"])Module["print"];if(Module["printErr"])err=Module["printErr"];if(Module["arguments"])Module["arguments"];if(Module["thisProgram"])Module["thisProgram"];var preInit=Module["preInit"];if(preInit){if(typeof preInit==="function")Module["preInit"]=preInit=[preInit];while(preInit.length>0)preInit.shift()()}Module["ccall"]=ccall;Module["cwrap"]=(ident,returnType,argTypes,opts)=>{var numericArgs=!argTypes||argTypes.every(type=>type==="number"||type==="boolean");var numericRet=returnType!=="string";if(numericRet&&numericArgs&&!opts)return getCFunc(ident);return(...args)=>ccall(ident,returnType,argTypes,args)};Module["UTF8ToString"]=UTF8ToString;Module["stringToNewUTF8"]=str=>{var size=lengthBytesUTF8(str)+1;var ret=_malloc(size);if(ret)stringToUTF8(str,ret,size);return ret};var _malloc,__emscripten_stack_restore,__emscripten_stack_alloc,_emscripten_stack_get_current,wasmMemory;function assignWasmExports(wasmExports){Module["_newResourceLocation"]=wasmExports["d"];Module["_resourceLocationToString"]=wasmExports["e"];Module["_freeResourceLocation"]=wasmExports["f"];Module["_getSemVer2_0_0Comparator"]=wasmExports["g"];Module["_applyVersionComparator"]=wasmExports["h"];Module["_newVersionComparator"]=wasmExports["i"];Module["_freeVersionComparator"]=wasmExports["j"];Module["_newModule"]=wasmExports["k"];Module["_moduleToString"]=wasmExports["l"];Module["_freeModule"]=wasmExports["m"];Module["_newVersion"]=wasmExports["n"];Module["_versionToString"]=wasmExports["o"];Module["_freeVersion"]=wasmExports["p"];Module["_versionComparatorToString"]=wasmExports["q"];Module["_newDependencyDict"]=wasmExports["r"];Module["_addToDependencyDict"]=wasmExports["s"];Module["_removeFromDependencyDictAndFree"]=wasmExports["t"];Module["_dependencyDictToString"]=wasmExports["u"];Module["_dependencyDictElementToString"]=wasmExports["v"];Module["_freeDependencyDict"]=wasmExports["w"];Module["_initLibraryApi"]=wasmExports["x"];Module["_freeLitLaunchLibraryApi"]=wasmExports["y"];_malloc=Module["_malloc"]=wasmExports["z"];Module["_free"]=wasmExports["A"];__emscripten_stack_restore=wasmExports["B"];__emscripten_stack_alloc=wasmExports["C"];_emscripten_stack_get_current=wasmExports["D"];wasmMemory=wasmExports["b"];wasmExports["__indirect_function_table"]}var wasmImports={a:requestedSize=>{var oldSize=HEAPU8.length;requestedSize>>>=0;var maxHeapSize=getHeapMax();if(requestedSize>maxHeapSize)return false;for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignMemory(Math.max(requestedSize,overGrownHeapSize),65536));var replacement=growMemory(newSize);if(replacement)return true}return false}};var wasmExports;wasmExports=await async function(){function receiveInstance(instance){wasmExports=instance.exports;assignWasmExports(wasmExports);updateMemoryViews();return wasmExports}var info=getWasmImports();var instantiateWasm=Module["instantiateWasm"];if(instantiateWasm)return new Promise(resolve=>{instantiateWasm(info,inst=>resolve(receiveInstance(inst)))});wasmBinaryFile??=findWasmBinary();var result=await instantiateAsync(void 0,wasmBinaryFile,info);var exports=function(result){return receiveInstance(result["instance"])}(result);return exports}();await async function(){preRun();var setStatus=Module["setStatus"];if(setStatus){setStatus("Running...");await new Promise(resolve=>setTimeout(resolve,1));setTimeout(setStatus,1,"")}if(ABORT)return;initRuntime();Module["onRuntimeInitialized"]?.();postRun()}();
|
|
2
|
-
;return Module}export default LitLaunchLibraryApi;
|