Fossil SCM

Update pikchr to the latest check-in.

drh 2025-03-05 12:11 wasm-cache-workaround
Commit 95b8022b0c810ef67673eb829d78e8356cf48dd3fec115f7f6de1f49cadf8ada
--- extsrc/pikchr-worker.js
+++ extsrc/pikchr-worker.js
@@ -206,11 +206,11 @@
206206
data:{step: ++f.last.step, text: text||null}
207207
});
208208
}
209209
};
210210
211
- importScripts('pikchr-v23459876.js');
211
+ importScripts('pikchr-v32459876.js');
212212
/**
213213
initPikchrModule() is installed via pikchr.js due to
214214
building with:
215215
216216
emcc ... -sMODULARIZE=1 -sEXPORT_NAME=initPikchrModule
217217
--- extsrc/pikchr-worker.js
+++ extsrc/pikchr-worker.js
@@ -206,11 +206,11 @@
206 data:{step: ++f.last.step, text: text||null}
207 });
208 }
209 };
210
211 importScripts('pikchr-v23459876.js');
212 /**
213 initPikchrModule() is installed via pikchr.js due to
214 building with:
215
216 emcc ... -sMODULARIZE=1 -sEXPORT_NAME=initPikchrModule
217
--- extsrc/pikchr-worker.js
+++ extsrc/pikchr-worker.js
@@ -206,11 +206,11 @@
206 data:{step: ++f.last.step, text: text||null}
207 });
208 }
209 };
210
211 importScripts('pikchr-v32459876.js');
212 /**
213 initPikchrModule() is installed via pikchr.js due to
214 building with:
215
216 emcc ... -sMODULARIZE=1 -sEXPORT_NAME=initPikchrModule
217
+6 -6
--- extsrc/pikchr.c
+++ extsrc/pikchr.c
@@ -25,17 +25,17 @@
2525
** The following is the concatenation of all %include directives from the
2626
** input grammar file:
2727
*/
2828
/************ Begin %include sections from the grammar ************************/
2929
#line 1 "VERSION.h"
30
-#define MANIFEST_UUID "8049a858f59d2d13957ba0bdc27f261e72e212368bfe7de119e39ada6f6e0d47"
31
-#define MANIFEST_VERSION "[8049a858f5]"
32
-#define MANIFEST_DATE "2025-03-05 00:34:20"
30
+#define MANIFEST_UUID "052f07296e76ab2312caf2a4bf6237e574b3e533c7a36ee8f34db833baa3efb4"
31
+#define MANIFEST_VERSION "[052f07296e]"
32
+#define MANIFEST_DATE "2025-03-05 10:54:16"
3333
#define MANIFEST_YEAR "2025"
34
-#define MANIFEST_ISODATE "20250305003420"
34
+#define MANIFEST_ISODATE "20250305105416"
3535
#define MANIFEST_NUMERIC_DATE 20250305
36
-#define MANIFEST_NUMERIC_TIME 3420
36
+#define MANIFEST_NUMERIC_TIME 105416
3737
#define RELEASE_VERSION "1.0"
3838
#define RELEASE_VERSION_NUMBER 10000
3939
#define RELEASE_RESOURCE_VERSION 1,0,0,0
4040
#define COMPILER "gcc-13.3.0"
4141
#line 2 "pikchr.y"
@@ -7974,11 +7974,11 @@
79747974
*/
79757975
const char *pikchr_version(void)
79767976
/* Emscripten workaround, else it chokes on the inlined version */;
79777977
79787978
const char *pikchr_version(void){
7979
- return RELEASE_VERSION " " MANIFEST_DATE;
7979
+ return RELEASE_VERSION " " MANIFEST_ISODATE;
79807980
}
79817981
79827982
/*
79837983
** Parse the PIKCHR script contained in zText[]. Return a rendering. Or
79847984
** if an error is encountered, return the error text. The error message
79857985
--- extsrc/pikchr.c
+++ extsrc/pikchr.c
@@ -25,17 +25,17 @@
25 ** The following is the concatenation of all %include directives from the
26 ** input grammar file:
27 */
28 /************ Begin %include sections from the grammar ************************/
29 #line 1 "VERSION.h"
30 #define MANIFEST_UUID "8049a858f59d2d13957ba0bdc27f261e72e212368bfe7de119e39ada6f6e0d47"
31 #define MANIFEST_VERSION "[8049a858f5]"
32 #define MANIFEST_DATE "2025-03-05 00:34:20"
33 #define MANIFEST_YEAR "2025"
34 #define MANIFEST_ISODATE "20250305003420"
35 #define MANIFEST_NUMERIC_DATE 20250305
36 #define MANIFEST_NUMERIC_TIME 3420
37 #define RELEASE_VERSION "1.0"
38 #define RELEASE_VERSION_NUMBER 10000
39 #define RELEASE_RESOURCE_VERSION 1,0,0,0
40 #define COMPILER "gcc-13.3.0"
41 #line 2 "pikchr.y"
@@ -7974,11 +7974,11 @@
7974 */
7975 const char *pikchr_version(void)
7976 /* Emscripten workaround, else it chokes on the inlined version */;
7977
7978 const char *pikchr_version(void){
7979 return RELEASE_VERSION " " MANIFEST_DATE;
7980 }
7981
7982 /*
7983 ** Parse the PIKCHR script contained in zText[]. Return a rendering. Or
7984 ** if an error is encountered, return the error text. The error message
7985
--- extsrc/pikchr.c
+++ extsrc/pikchr.c
@@ -25,17 +25,17 @@
25 ** The following is the concatenation of all %include directives from the
26 ** input grammar file:
27 */
28 /************ Begin %include sections from the grammar ************************/
29 #line 1 "VERSION.h"
30 #define MANIFEST_UUID "052f07296e76ab2312caf2a4bf6237e574b3e533c7a36ee8f34db833baa3efb4"
31 #define MANIFEST_VERSION "[052f07296e]"
32 #define MANIFEST_DATE "2025-03-05 10:54:16"
33 #define MANIFEST_YEAR "2025"
34 #define MANIFEST_ISODATE "20250305105416"
35 #define MANIFEST_NUMERIC_DATE 20250305
36 #define MANIFEST_NUMERIC_TIME 105416
37 #define RELEASE_VERSION "1.0"
38 #define RELEASE_VERSION_NUMBER 10000
39 #define RELEASE_RESOURCE_VERSION 1,0,0,0
40 #define COMPILER "gcc-13.3.0"
41 #line 2 "pikchr.y"
@@ -7974,11 +7974,11 @@
7974 */
7975 const char *pikchr_version(void)
7976 /* Emscripten workaround, else it chokes on the inlined version */;
7977
7978 const char *pikchr_version(void){
7979 return RELEASE_VERSION " " MANIFEST_ISODATE;
7980 }
7981
7982 /*
7983 ** Parse the PIKCHR script contained in zText[]. Return a rendering. Or
7984 ** if an error is encountered, return the error text. The error message
7985
+168 -132
--- extsrc/pikchr.js
+++ extsrc/pikchr.js
@@ -1,10 +1,11 @@
1
+
12
var initPikchrModule = (() => {
23
var _scriptName = typeof document != 'undefined' ? document.currentScript?.src : undefined;
34
45
return (
5
-async function(moduleArg = {}) {
6
+function(moduleArg = {}) {
67
var moduleRtn;
78
89
// include: shell.js
910
// The Module object: Our interface to the outside world. We import
1011
// and export values on it. There are various ways Module can be used:
@@ -88,25 +89,25 @@
8889
// If scriptDirectory contains a query (starting with ?) or a fragment (starting with #),
8990
// they are removed because they could contain a slash.
9091
if (scriptDirectory.startsWith("blob:")) {
9192
scriptDirectory = "";
9293
} else {
93
- scriptDirectory = scriptDirectory.slice(0, scriptDirectory.replace(/[?#].*/, "").lastIndexOf("/") + 1);
94
+ scriptDirectory = scriptDirectory.substr(0, scriptDirectory.replace(/[?#].*/, "").lastIndexOf("/") + 1);
9495
}
9596
{
9697
// include: web_or_worker_shell_read.js
97
- readAsync = async url => {
98
- var response = await fetch(url, {
99
- credentials: "same-origin"
100
- });
98
+ readAsync = url => fetch(url, {
99
+ credentials: "same-origin"
100
+ }).then(response => {
101101
if (response.ok) {
102102
return response.arrayBuffer();
103103
}
104
- throw new Error(response.status + " : " + response.url);
105
- };
104
+ return Promise.reject(new Error(response.status + " : " + response.url));
105
+ });
106106
}
107
-} else {}
107
+} else // end include: web_or_worker_shell_read.js
108
+{}
108109
109110
var out = Module["print"] || console.log.bind(console);
110111
111112
var err = Module["printErr"] || console.error.bind(console);
112113
@@ -152,25 +153,13 @@
152153
// NOTE: This is also used as the process return code code in shell environments
153154
// but only when noExitRuntime is false.
154155
var EXITSTATUS;
155156
156157
// Memory management
157
-var /** @type {!Int8Array} */ HEAP8, /** @type {!Uint8Array} */ HEAPU8, /** @type {!Int16Array} */ HEAP16, /** @type {!Uint16Array} */ HEAPU16, /** @type {!Int32Array} */ HEAP32, /** @type {!Uint32Array} */ HEAPU32, /** @type {!Float32Array} */ HEAPF32, /* BigInt64Array type is not correctly defined in closure
158
-/** not-@type {!BigInt64Array} */ HEAP64, /* BigUint64Array type is not correctly defined in closure
159
-/** not-t@type {!BigUint64Array} */ HEAPU64, /** @type {!Float64Array} */ HEAPF64;
160
-
161
-var runtimeInitialized = false;
158
+var /** @type {!Int8Array} */ HEAP8, /** @type {!Uint8Array} */ HEAPU8, /** @type {!Int16Array} */ HEAP16, /** @type {!Uint16Array} */ HEAPU16, /** @type {!Int32Array} */ HEAP32, /** @type {!Uint32Array} */ HEAPU32, /** @type {!Float32Array} */ HEAPF32, /** @type {!Float64Array} */ HEAPF64;
162159
163160
// include: runtime_shared.js
164
-// include: runtime_stack_check.js
165
-// end include: runtime_stack_check.js
166
-// include: runtime_exceptions.js
167
-// end include: runtime_exceptions.js
168
-// include: runtime_debug.js
169
-// end include: runtime_debug.js
170
-// include: memoryprofiler.js
171
-// end include: memoryprofiler.js
172161
function updateMemoryViews() {
173162
var b = wasmMemory.buffer;
174163
Module["HEAP8"] = HEAP8 = new Int8Array(b);
175164
Module["HEAP16"] = HEAP16 = new Int16Array(b);
176165
Module["HEAPU8"] = HEAPU8 = new Uint8Array(b);
@@ -177,48 +166,77 @@
177166
Module["HEAPU16"] = HEAPU16 = new Uint16Array(b);
178167
Module["HEAP32"] = HEAP32 = new Int32Array(b);
179168
Module["HEAPU32"] = HEAPU32 = new Uint32Array(b);
180169
Module["HEAPF32"] = HEAPF32 = new Float32Array(b);
181170
Module["HEAPF64"] = HEAPF64 = new Float64Array(b);
182
- Module["HEAP64"] = HEAP64 = new BigInt64Array(b);
183
- Module["HEAPU64"] = HEAPU64 = new BigUint64Array(b);
184171
}
185172
186173
// end include: runtime_shared.js
174
+// include: runtime_stack_check.js
175
+// end include: runtime_stack_check.js
176
+var __ATPRERUN__ = [];
177
+
178
+// functions called before the runtime is initialized
179
+var __ATINIT__ = [];
180
+
181
+// functions called during shutdown
182
+var __ATPOSTRUN__ = [];
183
+
184
+// functions called after the main() is called
185
+var runtimeInitialized = false;
186
+
187187
function preRun() {
188
- if (Module["preRun"]) {
189
- if (typeof Module["preRun"] == "function") Module["preRun"] = [ Module["preRun"] ];
190
- while (Module["preRun"].length) {
191
- addOnPreRun(Module["preRun"].shift());
192
- }
188
+ var preRuns = Module["preRun"];
189
+ if (preRuns) {
190
+ if (typeof preRuns == "function") preRuns = [ preRuns ];
191
+ preRuns.forEach(addOnPreRun);
193192
}
194
- callRuntimeCallbacks(onPreRuns);
193
+ callRuntimeCallbacks(__ATPRERUN__);
195194
}
196195
197196
function initRuntime() {
198197
runtimeInitialized = true;
199
- wasmExports["e"]();
198
+ callRuntimeCallbacks(__ATINIT__);
200199
}
201200
202201
function postRun() {
203
- if (Module["postRun"]) {
204
- if (typeof Module["postRun"] == "function") Module["postRun"] = [ Module["postRun"] ];
205
- while (Module["postRun"].length) {
206
- addOnPostRun(Module["postRun"].shift());
207
- }
202
+ var postRuns = Module["postRun"];
203
+ if (postRuns) {
204
+ if (typeof postRuns == "function") postRuns = [ postRuns ];
205
+ postRuns.forEach(addOnPostRun);
208206
}
209
- callRuntimeCallbacks(onPostRuns);
207
+ callRuntimeCallbacks(__ATPOSTRUN__);
208
+}
209
+
210
+function addOnPreRun(cb) {
211
+ __ATPRERUN__.unshift(cb);
212
+}
213
+
214
+function addOnInit(cb) {
215
+ __ATINIT__.unshift(cb);
216
+}
217
+
218
+function addOnPostRun(cb) {
219
+ __ATPOSTRUN__.unshift(cb);
210220
}
211221
222
+// include: runtime_math.js
223
+// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul
224
+// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/fround
225
+// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32
226
+// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc
227
+// end include: runtime_math.js
212228
// A counter of dependencies for calling run(). If we need to
213229
// do asynchronous work before running, increment this and
214230
// decrement it. Incrementing must happen in a place like
215231
// Module.preRun (used by emcc to add file preloading).
216232
// Note that you can add dependencies in preRun, even though
217233
// it happens right before run - run will be postponed until
218234
// the dependencies are met.
219235
var runDependencies = 0;
236
+
237
+var runDependencyWatcher = null;
220238
221239
var dependenciesFulfilled = null;
222240
223241
function addRunDependency(id) {
224242
runDependencies++;
@@ -227,10 +245,14 @@
227245
228246
function removeRunDependency(id) {
229247
runDependencies--;
230248
Module["monitorRunDependencies"]?.(runDependencies);
231249
if (runDependencies == 0) {
250
+ if (runDependencyWatcher !== null) {
251
+ clearInterval(runDependencyWatcher);
252
+ runDependencyWatcher = null;
253
+ }
232254
if (dependenciesFulfilled) {
233255
var callback = dependenciesFulfilled;
234256
dependenciesFulfilled = null;
235257
callback();
236258
}
@@ -263,15 +285,33 @@
263285
// in code paths apart from instantiation where an exception is expected
264286
// to be thrown when abort is called.
265287
throw e;
266288
}
267289
268
-var wasmBinaryFile;
290
+// include: memoryprofiler.js
291
+// end include: memoryprofiler.js
292
+// include: URIUtils.js
293
+// Prefix of data URIs emitted by SINGLE_FILE and related options.
294
+var dataURIPrefix = "data:application/octet-stream;base64,";
269295
296
+/**
297
+ * Indicates whether filename is a base64 data URI.
298
+ * @noinline
299
+ */ var isDataURI = filename => filename.startsWith(dataURIPrefix);
300
+
301
+// end include: URIUtils.js
302
+// include: runtime_exceptions.js
303
+// end include: runtime_exceptions.js
270304
function findWasmBinary() {
271
- return locateFile("pikchr.wasm");
305
+ var f = "pikchr-v09854133.wasm";
306
+ if (!isDataURI(f)) {
307
+ return locateFile(f);
308
+ }
309
+ return f;
272310
}
311
+
312
+var wasmBinaryFile;
273313
274314
function getBinarySync(file) {
275315
if (file == wasmBinaryFile && wasmBinary) {
276316
return new Uint8Array(wasmBinary);
277317
}
@@ -279,50 +319,48 @@
279319
return readBinary(file);
280320
}
281321
throw "both async and sync fetching of the wasm failed";
282322
}
283323
284
-async function getWasmBinary(binaryFile) {
324
+function getBinaryPromise(binaryFile) {
285325
// If we don't have the binary yet, load it asynchronously using readAsync.
286326
if (!wasmBinary) {
287327
// Fetch the binary using readAsync
288
- try {
289
- var response = await readAsync(binaryFile);
290
- return new Uint8Array(response);
291
- } catch {}
328
+ return readAsync(binaryFile).then(response => new Uint8Array(/** @type{!ArrayBuffer} */ (response)), // Fall back to getBinarySync if readAsync fails
329
+ () => getBinarySync(binaryFile));
292330
}
293331
// Otherwise, getBinarySync should be able to get it synchronously
294
- return getBinarySync(binaryFile);
332
+ return Promise.resolve().then(() => getBinarySync(binaryFile));
295333
}
296334
297
-async function instantiateArrayBuffer(binaryFile, imports) {
298
- try {
299
- var binary = await getWasmBinary(binaryFile);
300
- var instance = await WebAssembly.instantiate(binary, imports);
301
- return instance;
302
- } catch (reason) {
335
+function instantiateArrayBuffer(binaryFile, imports, receiver) {
336
+ return getBinaryPromise(binaryFile).then(binary => WebAssembly.instantiate(binary, imports)).then(receiver, reason => {
303337
err(`failed to asynchronously prepare wasm: ${reason}`);
304338
abort(reason);
305
- }
339
+ });
306340
}
307341
308
-async function instantiateAsync(binary, binaryFile, imports) {
309
- if (!binary && typeof WebAssembly.instantiateStreaming == "function") {
310
- try {
311
- var response = fetch(binaryFile, {
312
- credentials: "same-origin"
342
+function instantiateAsync(binary, binaryFile, imports, callback) {
343
+ if (!binary && typeof WebAssembly.instantiateStreaming == "function" && !isDataURI(binaryFile) && typeof fetch == "function") {
344
+ return fetch(binaryFile, {
345
+ credentials: "same-origin"
346
+ }).then(response => {
347
+ // Suppress closure warning here since the upstream definition for
348
+ // instantiateStreaming only allows Promise<Repsponse> rather than
349
+ // an actual Response.
350
+ // TODO(https://github.com/google/closure-compiler/pull/3913): Remove if/when upstream closure is fixed.
351
+ /** @suppress {checkTypes} */ var result = WebAssembly.instantiateStreaming(response, imports);
352
+ return result.then(callback, function(reason) {
353
+ // We expect the most common failure cause to be a bad MIME type for the binary,
354
+ // in which case falling back to ArrayBuffer instantiation should work.
355
+ err(`wasm streaming compile failed: ${reason}`);
356
+ err("falling back to ArrayBuffer instantiation");
357
+ return instantiateArrayBuffer(binaryFile, imports, callback);
313358
});
314
- var instantiationResult = await WebAssembly.instantiateStreaming(response, imports);
315
- return instantiationResult;
316
- } catch (reason) {
317
- // We expect the most common failure cause to be a bad MIME type for the binary,
318
- // in which case falling back to ArrayBuffer instantiation should work.
319
- err(`wasm streaming compile failed: ${reason}`);
320
- err("falling back to ArrayBuffer instantiation");
321
- }
322
- }
323
- return instantiateArrayBuffer(binaryFile, imports);
359
+ });
360
+ }
361
+ return instantiateArrayBuffer(binaryFile, imports, callback);
324362
}
325363
326364
function getWasmImports() {
327365
// prepare imports
328366
return {
@@ -330,18 +368,20 @@
330368
};
331369
}
332370
333371
// Create the wasm instance.
334372
// Receives the wasm imports, returns the exports.
335
-async function createWasm() {
373
+function createWasm() {
374
+ var info = getWasmImports();
336375
// Load the wasm module and create an instance of using native support in the JS engine.
337376
// handle a generated wasm instance, receiving its exports and
338377
// performing other necessary setup
339378
/** @param {WebAssembly.Module=} module*/ function receiveInstance(instance, module) {
340379
wasmExports = instance.exports;
341380
wasmMemory = wasmExports["d"];
342381
updateMemoryViews();
382
+ addOnInit(wasmExports["e"]);
343383
removeRunDependency("wasm-instantiate");
344384
return wasmExports;
345385
}
346386
// wait for the pthread pool (if any)
347387
addRunDependency("wasm-instantiate");
@@ -349,64 +389,48 @@
349389
function receiveInstantiationResult(result) {
350390
// 'result' is a ResultObject object which has both the module and instance.
351391
// receiveInstance() will swap in the exports (to Module.asm) so they can be called
352392
// 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.
353393
// When the regression is fixed, can restore the above PTHREADS-enabled path.
354
- return receiveInstance(result["instance"]);
394
+ receiveInstance(result["instance"]);
355395
}
356
- var info = getWasmImports();
357396
// User shell pages can write their own Module.instantiateWasm = function(imports, successCallback) callback
358397
// to manually instantiate the Wasm module themselves. This allows pages to
359398
// run the instantiation parallel to any other async startup actions they are
360399
// performing.
361400
// Also pthreads and wasm workers initialize the wasm instance through this
362401
// path.
363402
if (Module["instantiateWasm"]) {
364
- return new Promise((resolve, reject) => {
365
- Module["instantiateWasm"](info, (mod, inst) => {
366
- receiveInstance(mod, inst);
367
- resolve(mod.exports);
368
- });
369
- });
403
+ try {
404
+ return Module["instantiateWasm"](info, receiveInstance);
405
+ } catch (e) {
406
+ err(`Module.instantiateWasm callback failed with error: ${e}`);
407
+ // If instantiation fails, reject the module ready promise.
408
+ readyPromiseReject(e);
409
+ }
370410
}
371411
wasmBinaryFile ??= findWasmBinary();
372
- try {
373
- var result = await instantiateAsync(wasmBinary, wasmBinaryFile, info);
374
- var exports = receiveInstantiationResult(result);
375
- return exports;
376
- } catch (e) {
377
- // If instantiation fails, reject the module ready promise.
378
- readyPromiseReject(e);
379
- return Promise.reject(e);
380
- }
412
+ // If instantiation fails, reject the module ready promise.
413
+ instantiateAsync(wasmBinary, wasmBinaryFile, info, receiveInstantiationResult).catch(readyPromiseReject);
414
+ return {};
381415
}
382416
417
+// include: runtime_debug.js
418
+// end include: runtime_debug.js
383419
// === Body ===
384420
// end include: preamble.js
385
-class ExitStatus {
386
- name="ExitStatus";
387
- constructor(status) {
388
- this.message = `Program terminated with exit(${status})`;
389
- this.status = status;
390
- }
421
+/** @constructor */ function ExitStatus(status) {
422
+ this.name = "ExitStatus";
423
+ this.message = `Program terminated with exit(${status})`;
424
+ this.status = status;
391425
}
392426
393427
var callRuntimeCallbacks = callbacks => {
394
- while (callbacks.length > 0) {
395
- // Pass the module as the first argument.
396
- callbacks.shift()(Module);
397
- }
428
+ // Pass the module as the first argument.
429
+ callbacks.forEach(f => f(Module));
398430
};
399431
400
-var onPostRuns = [];
401
-
402
-var addOnPostRun = cb => onPostRuns.unshift(cb);
403
-
404
-var onPreRuns = [];
405
-
406
-var addOnPreRun = cb => onPreRuns.unshift(cb);
407
-
408432
/**
409433
* @param {number} ptr
410434
* @param {string} type
411435
*/ function getValue(ptr, type = "i8") {
412436
if (type.endsWith("*")) type = "*";
@@ -422,11 +446,11 @@
422446
423447
case "i32":
424448
return HEAP32[((ptr) >> 2)];
425449
426450
case "i64":
427
- return HEAP64[((ptr) >> 3)];
451
+ abort("to do getValue(i64) use WASM_BIGINT");
428452
429453
case "float":
430454
return HEAPF32[((ptr) >> 2)];
431455
432456
case "double":
@@ -464,12 +488,11 @@
464488
case "i32":
465489
HEAP32[((ptr) >> 2)] = value;
466490
break;
467491
468492
case "i64":
469
- HEAP64[((ptr) >> 3)] = BigInt(value);
470
- break;
493
+ abort("to do setValue(i64) use WASM_BIGINT");
471494
472495
case "float":
473496
HEAPF32[((ptr) >> 2)] = value;
474497
break;
475498
@@ -560,11 +583,13 @@
560583
* frequent uses of UTF8ToString() with and without maxBytesToRead may throw
561584
* JS JIT optimizations off, so it is worth to consider consistently using one
562585
* @return {string}
563586
*/ var UTF8ToString = (ptr, maxBytesToRead) => ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead) : "";
564587
565
-var ___assert_fail = (condition, filename, line, func) => abort(`Assertion failed: ${UTF8ToString(condition)}, at: ` + [ filename ? UTF8ToString(filename) : "unknown filename", line, func ? UTF8ToString(func) : "unknown function" ]);
588
+var ___assert_fail = (condition, filename, line, func) => {
589
+ abort(`Assertion failed: ${UTF8ToString(condition)}, at: ` + [ filename ? UTF8ToString(filename) : "unknown filename", line, func ? UTF8ToString(func) : "unknown function" ]);
590
+};
566591
567592
var abortOnCannotGrowMemory = requestedSize => {
568593
abort("OOM");
569594
};
570595
@@ -756,23 +781,23 @@
756781
/** @export */ a: ___assert_fail,
757782
/** @export */ b: _emscripten_resize_heap,
758783
/** @export */ c: _exit
759784
};
760785
761
-var wasmExports = await createWasm();
762
-
763
-var ___wasm_call_ctors = wasmExports["e"];
764
-
765
-var _pikchr_version = Module["_pikchr_version"] = wasmExports["g"];
766
-
767
-var _pikchr = Module["_pikchr"] = wasmExports["h"];
768
-
769
-var __emscripten_stack_restore = wasmExports["i"];
770
-
771
-var __emscripten_stack_alloc = wasmExports["j"];
772
-
773
-var _emscripten_stack_get_current = wasmExports["k"];
786
+var wasmExports = createWasm();
787
+
788
+var ___wasm_call_ctors = () => (___wasm_call_ctors = wasmExports["e"])();
789
+
790
+var _pikchr_version = Module["_pikchr_version"] = () => (_pikchr_version = Module["_pikchr_version"] = wasmExports["g"])();
791
+
792
+var _pikchr = Module["_pikchr"] = (a0, a1, a2, a3, a4) => (_pikchr = Module["_pikchr"] = wasmExports["h"])(a0, a1, a2, a3, a4);
793
+
794
+var __emscripten_stack_restore = a0 => (__emscripten_stack_restore = wasmExports["i"])(a0);
795
+
796
+var __emscripten_stack_alloc = a0 => (__emscripten_stack_alloc = wasmExports["j"])(a0);
797
+
798
+var _emscripten_stack_get_current = () => (_emscripten_stack_get_current = wasmExports["k"])();
774799
775800
// include: postamble.js
776801
// === Auto-generated postamble setup entry stuff ===
777802
Module["stackSave"] = stackSave;
778803
@@ -786,25 +811,39 @@
786811
787812
Module["setValue"] = setValue;
788813
789814
Module["getValue"] = getValue;
790815
816
+var calledRun;
817
+
818
+var calledPrerun;
819
+
820
+dependenciesFulfilled = function runCaller() {
821
+ // If run has never been called, and we should call run (INVOKE_RUN is true, and Module.noInitialRun is not false)
822
+ if (!calledRun) run();
823
+ if (!calledRun) dependenciesFulfilled = runCaller;
824
+};
825
+
826
+// try this again later, after new deps are fulfilled
791827
function run() {
792828
if (runDependencies > 0) {
793
- dependenciesFulfilled = run;
794829
return;
795830
}
796
- preRun();
797
- // a preRun added a dependency, run will be called later
798
- if (runDependencies > 0) {
799
- dependenciesFulfilled = run;
800
- return;
831
+ if (!calledPrerun) {
832
+ calledPrerun = 1;
833
+ preRun();
834
+ // a preRun added a dependency, run will be called later
835
+ if (runDependencies > 0) {
836
+ return;
837
+ }
801838
}
802839
function doRun() {
803840
// run may have just been called through dependencies being fulfilled just in this very frame,
804841
// or while the async setStatus time below was happening
805
- Module["calledRun"] = true;
842
+ if (calledRun) return;
843
+ calledRun = 1;
844
+ Module["calledRun"] = 1;
806845
if (ABORT) return;
807846
initRuntime();
808847
readyPromiseResolve(Module);
809848
Module["onRuntimeInitialized"]?.();
810849
postRun();
@@ -840,12 +879,9 @@
840879
841880
return moduleRtn;
842881
}
843882
);
844883
})();
845
-if (typeof exports === 'object' && typeof module === 'object') {
884
+if (typeof exports === 'object' && typeof module === 'object')
846885
module.exports = initPikchrModule;
847
- // This default export looks redundant, but it allows TS to import this
848
- // commonjs style module.
849
- module.exports.default = initPikchrModule;
850
-} else if (typeof define === 'function' && define['amd'])
886
+else if (typeof define === 'function' && define['amd'])
851887
define([], () => initPikchrModule);
852888
--- extsrc/pikchr.js
+++ extsrc/pikchr.js
@@ -1,10 +1,11 @@
 
1 var initPikchrModule = (() => {
2 var _scriptName = typeof document != 'undefined' ? document.currentScript?.src : undefined;
3
4 return (
5 async function(moduleArg = {}) {
6 var moduleRtn;
7
8 // include: shell.js
9 // The Module object: Our interface to the outside world. We import
10 // and export values on it. There are various ways Module can be used:
@@ -88,25 +89,25 @@
88 // If scriptDirectory contains a query (starting with ?) or a fragment (starting with #),
89 // they are removed because they could contain a slash.
90 if (scriptDirectory.startsWith("blob:")) {
91 scriptDirectory = "";
92 } else {
93 scriptDirectory = scriptDirectory.slice(0, scriptDirectory.replace(/[?#].*/, "").lastIndexOf("/") + 1);
94 }
95 {
96 // include: web_or_worker_shell_read.js
97 readAsync = async url => {
98 var response = await fetch(url, {
99 credentials: "same-origin"
100 });
101 if (response.ok) {
102 return response.arrayBuffer();
103 }
104 throw new Error(response.status + " : " + response.url);
105 };
106 }
107 } else {}
 
108
109 var out = Module["print"] || console.log.bind(console);
110
111 var err = Module["printErr"] || console.error.bind(console);
112
@@ -152,25 +153,13 @@
152 // NOTE: This is also used as the process return code code in shell environments
153 // but only when noExitRuntime is false.
154 var EXITSTATUS;
155
156 // Memory management
157 var /** @type {!Int8Array} */ HEAP8, /** @type {!Uint8Array} */ HEAPU8, /** @type {!Int16Array} */ HEAP16, /** @type {!Uint16Array} */ HEAPU16, /** @type {!Int32Array} */ HEAP32, /** @type {!Uint32Array} */ HEAPU32, /** @type {!Float32Array} */ HEAPF32, /* BigInt64Array type is not correctly defined in closure
158 /** not-@type {!BigInt64Array} */ HEAP64, /* BigUint64Array type is not correctly defined in closure
159 /** not-t@type {!BigUint64Array} */ HEAPU64, /** @type {!Float64Array} */ HEAPF64;
160
161 var runtimeInitialized = false;
162
163 // include: runtime_shared.js
164 // include: runtime_stack_check.js
165 // end include: runtime_stack_check.js
166 // include: runtime_exceptions.js
167 // end include: runtime_exceptions.js
168 // include: runtime_debug.js
169 // end include: runtime_debug.js
170 // include: memoryprofiler.js
171 // end include: memoryprofiler.js
172 function updateMemoryViews() {
173 var b = wasmMemory.buffer;
174 Module["HEAP8"] = HEAP8 = new Int8Array(b);
175 Module["HEAP16"] = HEAP16 = new Int16Array(b);
176 Module["HEAPU8"] = HEAPU8 = new Uint8Array(b);
@@ -177,48 +166,77 @@
177 Module["HEAPU16"] = HEAPU16 = new Uint16Array(b);
178 Module["HEAP32"] = HEAP32 = new Int32Array(b);
179 Module["HEAPU32"] = HEAPU32 = new Uint32Array(b);
180 Module["HEAPF32"] = HEAPF32 = new Float32Array(b);
181 Module["HEAPF64"] = HEAPF64 = new Float64Array(b);
182 Module["HEAP64"] = HEAP64 = new BigInt64Array(b);
183 Module["HEAPU64"] = HEAPU64 = new BigUint64Array(b);
184 }
185
186 // end include: runtime_shared.js
 
 
 
 
 
 
 
 
 
 
 
 
 
187 function preRun() {
188 if (Module["preRun"]) {
189 if (typeof Module["preRun"] == "function") Module["preRun"] = [ Module["preRun"] ];
190 while (Module["preRun"].length) {
191 addOnPreRun(Module["preRun"].shift());
192 }
193 }
194 callRuntimeCallbacks(onPreRuns);
195 }
196
197 function initRuntime() {
198 runtimeInitialized = true;
199 wasmExports["e"]();
200 }
201
202 function postRun() {
203 if (Module["postRun"]) {
204 if (typeof Module["postRun"] == "function") Module["postRun"] = [ Module["postRun"] ];
205 while (Module["postRun"].length) {
206 addOnPostRun(Module["postRun"].shift());
207 }
208 }
209 callRuntimeCallbacks(onPostRuns);
 
 
 
 
 
 
 
 
 
 
 
 
210 }
211
 
 
 
 
 
 
212 // A counter of dependencies for calling run(). If we need to
213 // do asynchronous work before running, increment this and
214 // decrement it. Incrementing must happen in a place like
215 // Module.preRun (used by emcc to add file preloading).
216 // Note that you can add dependencies in preRun, even though
217 // it happens right before run - run will be postponed until
218 // the dependencies are met.
219 var runDependencies = 0;
 
 
220
221 var dependenciesFulfilled = null;
222
223 function addRunDependency(id) {
224 runDependencies++;
@@ -227,10 +245,14 @@
227
228 function removeRunDependency(id) {
229 runDependencies--;
230 Module["monitorRunDependencies"]?.(runDependencies);
231 if (runDependencies == 0) {
 
 
 
 
232 if (dependenciesFulfilled) {
233 var callback = dependenciesFulfilled;
234 dependenciesFulfilled = null;
235 callback();
236 }
@@ -263,15 +285,33 @@
263 // in code paths apart from instantiation where an exception is expected
264 // to be thrown when abort is called.
265 throw e;
266 }
267
268 var wasmBinaryFile;
 
 
 
 
269
 
 
 
 
 
 
 
 
270 function findWasmBinary() {
271 return locateFile("pikchr.wasm");
 
 
 
 
272 }
 
 
273
274 function getBinarySync(file) {
275 if (file == wasmBinaryFile && wasmBinary) {
276 return new Uint8Array(wasmBinary);
277 }
@@ -279,50 +319,48 @@
279 return readBinary(file);
280 }
281 throw "both async and sync fetching of the wasm failed";
282 }
283
284 async function getWasmBinary(binaryFile) {
285 // If we don't have the binary yet, load it asynchronously using readAsync.
286 if (!wasmBinary) {
287 // Fetch the binary using readAsync
288 try {
289 var response = await readAsync(binaryFile);
290 return new Uint8Array(response);
291 } catch {}
292 }
293 // Otherwise, getBinarySync should be able to get it synchronously
294 return getBinarySync(binaryFile);
295 }
296
297 async function instantiateArrayBuffer(binaryFile, imports) {
298 try {
299 var binary = await getWasmBinary(binaryFile);
300 var instance = await WebAssembly.instantiate(binary, imports);
301 return instance;
302 } catch (reason) {
303 err(`failed to asynchronously prepare wasm: ${reason}`);
304 abort(reason);
305 }
306 }
307
308 async function instantiateAsync(binary, binaryFile, imports) {
309 if (!binary && typeof WebAssembly.instantiateStreaming == "function") {
310 try {
311 var response = fetch(binaryFile, {
312 credentials: "same-origin"
 
 
 
 
 
 
 
 
 
 
 
313 });
314 var instantiationResult = await WebAssembly.instantiateStreaming(response, imports);
315 return instantiationResult;
316 } catch (reason) {
317 // We expect the most common failure cause to be a bad MIME type for the binary,
318 // in which case falling back to ArrayBuffer instantiation should work.
319 err(`wasm streaming compile failed: ${reason}`);
320 err("falling back to ArrayBuffer instantiation");
321 }
322 }
323 return instantiateArrayBuffer(binaryFile, imports);
324 }
325
326 function getWasmImports() {
327 // prepare imports
328 return {
@@ -330,18 +368,20 @@
330 };
331 }
332
333 // Create the wasm instance.
334 // Receives the wasm imports, returns the exports.
335 async function createWasm() {
 
336 // Load the wasm module and create an instance of using native support in the JS engine.
337 // handle a generated wasm instance, receiving its exports and
338 // performing other necessary setup
339 /** @param {WebAssembly.Module=} module*/ function receiveInstance(instance, module) {
340 wasmExports = instance.exports;
341 wasmMemory = wasmExports["d"];
342 updateMemoryViews();
 
343 removeRunDependency("wasm-instantiate");
344 return wasmExports;
345 }
346 // wait for the pthread pool (if any)
347 addRunDependency("wasm-instantiate");
@@ -349,64 +389,48 @@
349 function receiveInstantiationResult(result) {
350 // 'result' is a ResultObject object which has both the module and instance.
351 // receiveInstance() will swap in the exports (to Module.asm) so they can be called
352 // 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.
353 // When the regression is fixed, can restore the above PTHREADS-enabled path.
354 return receiveInstance(result["instance"]);
355 }
356 var info = getWasmImports();
357 // User shell pages can write their own Module.instantiateWasm = function(imports, successCallback) callback
358 // to manually instantiate the Wasm module themselves. This allows pages to
359 // run the instantiation parallel to any other async startup actions they are
360 // performing.
361 // Also pthreads and wasm workers initialize the wasm instance through this
362 // path.
363 if (Module["instantiateWasm"]) {
364 return new Promise((resolve, reject) => {
365 Module["instantiateWasm"](info, (mod, inst) => {
366 receiveInstance(mod, inst);
367 resolve(mod.exports);
368 });
369 });
 
370 }
371 wasmBinaryFile ??= findWasmBinary();
372 try {
373 var result = await instantiateAsync(wasmBinary, wasmBinaryFile, info);
374 var exports = receiveInstantiationResult(result);
375 return exports;
376 } catch (e) {
377 // If instantiation fails, reject the module ready promise.
378 readyPromiseReject(e);
379 return Promise.reject(e);
380 }
381 }
382
 
 
383 // === Body ===
384 // end include: preamble.js
385 class ExitStatus {
386 name="ExitStatus";
387 constructor(status) {
388 this.message = `Program terminated with exit(${status})`;
389 this.status = status;
390 }
391 }
392
393 var callRuntimeCallbacks = callbacks => {
394 while (callbacks.length > 0) {
395 // Pass the module as the first argument.
396 callbacks.shift()(Module);
397 }
398 };
399
400 var onPostRuns = [];
401
402 var addOnPostRun = cb => onPostRuns.unshift(cb);
403
404 var onPreRuns = [];
405
406 var addOnPreRun = cb => onPreRuns.unshift(cb);
407
408 /**
409 * @param {number} ptr
410 * @param {string} type
411 */ function getValue(ptr, type = "i8") {
412 if (type.endsWith("*")) type = "*";
@@ -422,11 +446,11 @@
422
423 case "i32":
424 return HEAP32[((ptr) >> 2)];
425
426 case "i64":
427 return HEAP64[((ptr) >> 3)];
428
429 case "float":
430 return HEAPF32[((ptr) >> 2)];
431
432 case "double":
@@ -464,12 +488,11 @@
464 case "i32":
465 HEAP32[((ptr) >> 2)] = value;
466 break;
467
468 case "i64":
469 HEAP64[((ptr) >> 3)] = BigInt(value);
470 break;
471
472 case "float":
473 HEAPF32[((ptr) >> 2)] = value;
474 break;
475
@@ -560,11 +583,13 @@
560 * frequent uses of UTF8ToString() with and without maxBytesToRead may throw
561 * JS JIT optimizations off, so it is worth to consider consistently using one
562 * @return {string}
563 */ var UTF8ToString = (ptr, maxBytesToRead) => ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead) : "";
564
565 var ___assert_fail = (condition, filename, line, func) => abort(`Assertion failed: ${UTF8ToString(condition)}, at: ` + [ filename ? UTF8ToString(filename) : "unknown filename", line, func ? UTF8ToString(func) : "unknown function" ]);
 
 
566
567 var abortOnCannotGrowMemory = requestedSize => {
568 abort("OOM");
569 };
570
@@ -756,23 +781,23 @@
756 /** @export */ a: ___assert_fail,
757 /** @export */ b: _emscripten_resize_heap,
758 /** @export */ c: _exit
759 };
760
761 var wasmExports = await createWasm();
762
763 var ___wasm_call_ctors = wasmExports["e"];
764
765 var _pikchr_version = Module["_pikchr_version"] = wasmExports["g"];
766
767 var _pikchr = Module["_pikchr"] = wasmExports["h"];
768
769 var __emscripten_stack_restore = wasmExports["i"];
770
771 var __emscripten_stack_alloc = wasmExports["j"];
772
773 var _emscripten_stack_get_current = wasmExports["k"];
774
775 // include: postamble.js
776 // === Auto-generated postamble setup entry stuff ===
777 Module["stackSave"] = stackSave;
778
@@ -786,25 +811,39 @@
786
787 Module["setValue"] = setValue;
788
789 Module["getValue"] = getValue;
790
 
 
 
 
 
 
 
 
 
 
 
791 function run() {
792 if (runDependencies > 0) {
793 dependenciesFulfilled = run;
794 return;
795 }
796 preRun();
797 // a preRun added a dependency, run will be called later
798 if (runDependencies > 0) {
799 dependenciesFulfilled = run;
800 return;
 
 
801 }
802 function doRun() {
803 // run may have just been called through dependencies being fulfilled just in this very frame,
804 // or while the async setStatus time below was happening
805 Module["calledRun"] = true;
 
 
806 if (ABORT) return;
807 initRuntime();
808 readyPromiseResolve(Module);
809 Module["onRuntimeInitialized"]?.();
810 postRun();
@@ -840,12 +879,9 @@
840
841 return moduleRtn;
842 }
843 );
844 })();
845 if (typeof exports === 'object' && typeof module === 'object') {
846 module.exports = initPikchrModule;
847 // This default export looks redundant, but it allows TS to import this
848 // commonjs style module.
849 module.exports.default = initPikchrModule;
850 } else if (typeof define === 'function' && define['amd'])
851 define([], () => initPikchrModule);
852
--- extsrc/pikchr.js
+++ extsrc/pikchr.js
@@ -1,10 +1,11 @@
1
2 var initPikchrModule = (() => {
3 var _scriptName = typeof document != 'undefined' ? document.currentScript?.src : undefined;
4
5 return (
6 function(moduleArg = {}) {
7 var moduleRtn;
8
9 // include: shell.js
10 // The Module object: Our interface to the outside world. We import
11 // and export values on it. There are various ways Module can be used:
@@ -88,25 +89,25 @@
89 // If scriptDirectory contains a query (starting with ?) or a fragment (starting with #),
90 // they are removed because they could contain a slash.
91 if (scriptDirectory.startsWith("blob:")) {
92 scriptDirectory = "";
93 } else {
94 scriptDirectory = scriptDirectory.substr(0, scriptDirectory.replace(/[?#].*/, "").lastIndexOf("/") + 1);
95 }
96 {
97 // include: web_or_worker_shell_read.js
98 readAsync = url => fetch(url, {
99 credentials: "same-origin"
100 }).then(response => {
 
101 if (response.ok) {
102 return response.arrayBuffer();
103 }
104 return Promise.reject(new Error(response.status + " : " + response.url));
105 });
106 }
107 } else // end include: web_or_worker_shell_read.js
108 {}
109
110 var out = Module["print"] || console.log.bind(console);
111
112 var err = Module["printErr"] || console.error.bind(console);
113
@@ -152,25 +153,13 @@
153 // NOTE: This is also used as the process return code code in shell environments
154 // but only when noExitRuntime is false.
155 var EXITSTATUS;
156
157 // Memory management
158 var /** @type {!Int8Array} */ HEAP8, /** @type {!Uint8Array} */ HEAPU8, /** @type {!Int16Array} */ HEAP16, /** @type {!Uint16Array} */ HEAPU16, /** @type {!Int32Array} */ HEAP32, /** @type {!Uint32Array} */ HEAPU32, /** @type {!Float32Array} */ HEAPF32, /** @type {!Float64Array} */ HEAPF64;
 
 
 
 
159
160 // include: runtime_shared.js
 
 
 
 
 
 
 
 
161 function updateMemoryViews() {
162 var b = wasmMemory.buffer;
163 Module["HEAP8"] = HEAP8 = new Int8Array(b);
164 Module["HEAP16"] = HEAP16 = new Int16Array(b);
165 Module["HEAPU8"] = HEAPU8 = new Uint8Array(b);
@@ -177,48 +166,77 @@
166 Module["HEAPU16"] = HEAPU16 = new Uint16Array(b);
167 Module["HEAP32"] = HEAP32 = new Int32Array(b);
168 Module["HEAPU32"] = HEAPU32 = new Uint32Array(b);
169 Module["HEAPF32"] = HEAPF32 = new Float32Array(b);
170 Module["HEAPF64"] = HEAPF64 = new Float64Array(b);
 
 
171 }
172
173 // end include: runtime_shared.js
174 // include: runtime_stack_check.js
175 // end include: runtime_stack_check.js
176 var __ATPRERUN__ = [];
177
178 // functions called before the runtime is initialized
179 var __ATINIT__ = [];
180
181 // functions called during shutdown
182 var __ATPOSTRUN__ = [];
183
184 // functions called after the main() is called
185 var runtimeInitialized = false;
186
187 function preRun() {
188 var preRuns = Module["preRun"];
189 if (preRuns) {
190 if (typeof preRuns == "function") preRuns = [ preRuns ];
191 preRuns.forEach(addOnPreRun);
 
192 }
193 callRuntimeCallbacks(__ATPRERUN__);
194 }
195
196 function initRuntime() {
197 runtimeInitialized = true;
198 callRuntimeCallbacks(__ATINIT__);
199 }
200
201 function postRun() {
202 var postRuns = Module["postRun"];
203 if (postRuns) {
204 if (typeof postRuns == "function") postRuns = [ postRuns ];
205 postRuns.forEach(addOnPostRun);
 
206 }
207 callRuntimeCallbacks(__ATPOSTRUN__);
208 }
209
210 function addOnPreRun(cb) {
211 __ATPRERUN__.unshift(cb);
212 }
213
214 function addOnInit(cb) {
215 __ATINIT__.unshift(cb);
216 }
217
218 function addOnPostRun(cb) {
219 __ATPOSTRUN__.unshift(cb);
220 }
221
222 // include: runtime_math.js
223 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul
224 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/fround
225 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32
226 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc
227 // end include: runtime_math.js
228 // A counter of dependencies for calling run(). If we need to
229 // do asynchronous work before running, increment this and
230 // decrement it. Incrementing must happen in a place like
231 // Module.preRun (used by emcc to add file preloading).
232 // Note that you can add dependencies in preRun, even though
233 // it happens right before run - run will be postponed until
234 // the dependencies are met.
235 var runDependencies = 0;
236
237 var runDependencyWatcher = null;
238
239 var dependenciesFulfilled = null;
240
241 function addRunDependency(id) {
242 runDependencies++;
@@ -227,10 +245,14 @@
245
246 function removeRunDependency(id) {
247 runDependencies--;
248 Module["monitorRunDependencies"]?.(runDependencies);
249 if (runDependencies == 0) {
250 if (runDependencyWatcher !== null) {
251 clearInterval(runDependencyWatcher);
252 runDependencyWatcher = null;
253 }
254 if (dependenciesFulfilled) {
255 var callback = dependenciesFulfilled;
256 dependenciesFulfilled = null;
257 callback();
258 }
@@ -263,15 +285,33 @@
285 // in code paths apart from instantiation where an exception is expected
286 // to be thrown when abort is called.
287 throw e;
288 }
289
290 // include: memoryprofiler.js
291 // end include: memoryprofiler.js
292 // include: URIUtils.js
293 // Prefix of data URIs emitted by SINGLE_FILE and related options.
294 var dataURIPrefix = "data:application/octet-stream;base64,";
295
296 /**
297 * Indicates whether filename is a base64 data URI.
298 * @noinline
299 */ var isDataURI = filename => filename.startsWith(dataURIPrefix);
300
301 // end include: URIUtils.js
302 // include: runtime_exceptions.js
303 // end include: runtime_exceptions.js
304 function findWasmBinary() {
305 var f = "pikchr-v09854133.wasm";
306 if (!isDataURI(f)) {
307 return locateFile(f);
308 }
309 return f;
310 }
311
312 var wasmBinaryFile;
313
314 function getBinarySync(file) {
315 if (file == wasmBinaryFile && wasmBinary) {
316 return new Uint8Array(wasmBinary);
317 }
@@ -279,50 +319,48 @@
319 return readBinary(file);
320 }
321 throw "both async and sync fetching of the wasm failed";
322 }
323
324 function getBinaryPromise(binaryFile) {
325 // If we don't have the binary yet, load it asynchronously using readAsync.
326 if (!wasmBinary) {
327 // Fetch the binary using readAsync
328 return readAsync(binaryFile).then(response => new Uint8Array(/** @type{!ArrayBuffer} */ (response)), // Fall back to getBinarySync if readAsync fails
329 () => getBinarySync(binaryFile));
 
 
330 }
331 // Otherwise, getBinarySync should be able to get it synchronously
332 return Promise.resolve().then(() => getBinarySync(binaryFile));
333 }
334
335 function instantiateArrayBuffer(binaryFile, imports, receiver) {
336 return getBinaryPromise(binaryFile).then(binary => WebAssembly.instantiate(binary, imports)).then(receiver, reason => {
 
 
 
 
337 err(`failed to asynchronously prepare wasm: ${reason}`);
338 abort(reason);
339 });
340 }
341
342 function instantiateAsync(binary, binaryFile, imports, callback) {
343 if (!binary && typeof WebAssembly.instantiateStreaming == "function" && !isDataURI(binaryFile) && typeof fetch == "function") {
344 return fetch(binaryFile, {
345 credentials: "same-origin"
346 }).then(response => {
347 // Suppress closure warning here since the upstream definition for
348 // instantiateStreaming only allows Promise<Repsponse> rather than
349 // an actual Response.
350 // TODO(https://github.com/google/closure-compiler/pull/3913): Remove if/when upstream closure is fixed.
351 /** @suppress {checkTypes} */ var result = WebAssembly.instantiateStreaming(response, imports);
352 return result.then(callback, function(reason) {
353 // We expect the most common failure cause to be a bad MIME type for the binary,
354 // in which case falling back to ArrayBuffer instantiation should work.
355 err(`wasm streaming compile failed: ${reason}`);
356 err("falling back to ArrayBuffer instantiation");
357 return instantiateArrayBuffer(binaryFile, imports, callback);
358 });
359 });
360 }
361 return instantiateArrayBuffer(binaryFile, imports, callback);
 
 
 
 
 
 
 
362 }
363
364 function getWasmImports() {
365 // prepare imports
366 return {
@@ -330,18 +368,20 @@
368 };
369 }
370
371 // Create the wasm instance.
372 // Receives the wasm imports, returns the exports.
373 function createWasm() {
374 var info = getWasmImports();
375 // Load the wasm module and create an instance of using native support in the JS engine.
376 // handle a generated wasm instance, receiving its exports and
377 // performing other necessary setup
378 /** @param {WebAssembly.Module=} module*/ function receiveInstance(instance, module) {
379 wasmExports = instance.exports;
380 wasmMemory = wasmExports["d"];
381 updateMemoryViews();
382 addOnInit(wasmExports["e"]);
383 removeRunDependency("wasm-instantiate");
384 return wasmExports;
385 }
386 // wait for the pthread pool (if any)
387 addRunDependency("wasm-instantiate");
@@ -349,64 +389,48 @@
389 function receiveInstantiationResult(result) {
390 // 'result' is a ResultObject object which has both the module and instance.
391 // receiveInstance() will swap in the exports (to Module.asm) so they can be called
392 // 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.
393 // When the regression is fixed, can restore the above PTHREADS-enabled path.
394 receiveInstance(result["instance"]);
395 }
 
396 // User shell pages can write their own Module.instantiateWasm = function(imports, successCallback) callback
397 // to manually instantiate the Wasm module themselves. This allows pages to
398 // run the instantiation parallel to any other async startup actions they are
399 // performing.
400 // Also pthreads and wasm workers initialize the wasm instance through this
401 // path.
402 if (Module["instantiateWasm"]) {
403 try {
404 return Module["instantiateWasm"](info, receiveInstance);
405 } catch (e) {
406 err(`Module.instantiateWasm callback failed with error: ${e}`);
407 // If instantiation fails, reject the module ready promise.
408 readyPromiseReject(e);
409 }
410 }
411 wasmBinaryFile ??= findWasmBinary();
412 // If instantiation fails, reject the module ready promise.
413 instantiateAsync(wasmBinary, wasmBinaryFile, info, receiveInstantiationResult).catch(readyPromiseReject);
414 return {};
 
 
 
 
 
 
415 }
416
417 // include: runtime_debug.js
418 // end include: runtime_debug.js
419 // === Body ===
420 // end include: preamble.js
421 /** @constructor */ function ExitStatus(status) {
422 this.name = "ExitStatus";
423 this.message = `Program terminated with exit(${status})`;
424 this.status = status;
 
 
425 }
426
427 var callRuntimeCallbacks = callbacks => {
428 // Pass the module as the first argument.
429 callbacks.forEach(f => f(Module));
 
 
430 };
431
 
 
 
 
 
 
 
 
432 /**
433 * @param {number} ptr
434 * @param {string} type
435 */ function getValue(ptr, type = "i8") {
436 if (type.endsWith("*")) type = "*";
@@ -422,11 +446,11 @@
446
447 case "i32":
448 return HEAP32[((ptr) >> 2)];
449
450 case "i64":
451 abort("to do getValue(i64) use WASM_BIGINT");
452
453 case "float":
454 return HEAPF32[((ptr) >> 2)];
455
456 case "double":
@@ -464,12 +488,11 @@
488 case "i32":
489 HEAP32[((ptr) >> 2)] = value;
490 break;
491
492 case "i64":
493 abort("to do setValue(i64) use WASM_BIGINT");
 
494
495 case "float":
496 HEAPF32[((ptr) >> 2)] = value;
497 break;
498
@@ -560,11 +583,13 @@
583 * frequent uses of UTF8ToString() with and without maxBytesToRead may throw
584 * JS JIT optimizations off, so it is worth to consider consistently using one
585 * @return {string}
586 */ var UTF8ToString = (ptr, maxBytesToRead) => ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead) : "";
587
588 var ___assert_fail = (condition, filename, line, func) => {
589 abort(`Assertion failed: ${UTF8ToString(condition)}, at: ` + [ filename ? UTF8ToString(filename) : "unknown filename", line, func ? UTF8ToString(func) : "unknown function" ]);
590 };
591
592 var abortOnCannotGrowMemory = requestedSize => {
593 abort("OOM");
594 };
595
@@ -756,23 +781,23 @@
781 /** @export */ a: ___assert_fail,
782 /** @export */ b: _emscripten_resize_heap,
783 /** @export */ c: _exit
784 };
785
786 var wasmExports = createWasm();
787
788 var ___wasm_call_ctors = () => (___wasm_call_ctors = wasmExports["e"])();
789
790 var _pikchr_version = Module["_pikchr_version"] = () => (_pikchr_version = Module["_pikchr_version"] = wasmExports["g"])();
791
792 var _pikchr = Module["_pikchr"] = (a0, a1, a2, a3, a4) => (_pikchr = Module["_pikchr"] = wasmExports["h"])(a0, a1, a2, a3, a4);
793
794 var __emscripten_stack_restore = a0 => (__emscripten_stack_restore = wasmExports["i"])(a0);
795
796 var __emscripten_stack_alloc = a0 => (__emscripten_stack_alloc = wasmExports["j"])(a0);
797
798 var _emscripten_stack_get_current = () => (_emscripten_stack_get_current = wasmExports["k"])();
799
800 // include: postamble.js
801 // === Auto-generated postamble setup entry stuff ===
802 Module["stackSave"] = stackSave;
803
@@ -786,25 +811,39 @@
811
812 Module["setValue"] = setValue;
813
814 Module["getValue"] = getValue;
815
816 var calledRun;
817
818 var calledPrerun;
819
820 dependenciesFulfilled = function runCaller() {
821 // If run has never been called, and we should call run (INVOKE_RUN is true, and Module.noInitialRun is not false)
822 if (!calledRun) run();
823 if (!calledRun) dependenciesFulfilled = runCaller;
824 };
825
826 // try this again later, after new deps are fulfilled
827 function run() {
828 if (runDependencies > 0) {
 
829 return;
830 }
831 if (!calledPrerun) {
832 calledPrerun = 1;
833 preRun();
834 // a preRun added a dependency, run will be called later
835 if (runDependencies > 0) {
836 return;
837 }
838 }
839 function doRun() {
840 // run may have just been called through dependencies being fulfilled just in this very frame,
841 // or while the async setStatus time below was happening
842 if (calledRun) return;
843 calledRun = 1;
844 Module["calledRun"] = 1;
845 if (ABORT) return;
846 initRuntime();
847 readyPromiseResolve(Module);
848 Module["onRuntimeInitialized"]?.();
849 postRun();
@@ -840,12 +879,9 @@
879
880 return moduleRtn;
881 }
882 );
883 })();
884 if (typeof exports === 'object' && typeof module === 'object')
885 module.exports = initPikchrModule;
886 else if (typeof define === 'function' && define['amd'])
 
 
 
887 define([], () => initPikchrModule);
888
--- extsrc/pikchr.wasm
+++ extsrc/pikchr.wasm
cannot compute difference between binary files
11
--- extsrc/pikchr.wasm
+++ extsrc/pikchr.wasm
0 annot compute difference between binary files
1
--- extsrc/pikchr.wasm
+++ extsrc/pikchr.wasm
0 annot compute difference between binary files
1

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button