Fossil SCM

Update the built-in Pikchr to the latest trunk check-in

drh 2026-04-03 11:02 trunk
Commit adc7bfce73ba88fc0a30d9b52ab0c8291b39646bdeb2e8512807d65dc42d6853
--- 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-v2813665466.js');
211
+ importScripts('pikchr-v8806526039.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-v2813665466.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-v8806526039.js');
212 /**
213 initPikchrModule() is installed via pikchr.js due to
214 building with:
215
216 emcc ... -sMODULARIZE=1 -sEXPORT_NAME=initPikchrModule
217
+30 -15
--- 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 "8a43b020141f772a0ac45291a7fd73041d2efba5e3665c6bd2f334ad9b2e9845"
31
-#define MANIFEST_VERSION "[8a43b02014]"
32
-#define MANIFEST_DATE "2025-03-19 16:19:43"
33
-#define MANIFEST_YEAR "2025"
34
-#define MANIFEST_ISODATE "20250319161943"
35
-#define MANIFEST_NUMERIC_DATE 20250319
36
-#define MANIFEST_NUMERIC_TIME 161943
30
+#define MANIFEST_UUID "a7f1c35bc0448daf15e2bafa36e510c1517534e620c452ecb314ed57d974f081"
31
+#define MANIFEST_VERSION "[a7f1c35bc0]"
32
+#define MANIFEST_DATE "2026-04-03 10:29:56"
33
+#define MANIFEST_YEAR "2026"
34
+#define MANIFEST_ISODATE "20260403102956"
35
+#define MANIFEST_NUMERIC_DATE 20260403
36
+#define MANIFEST_NUMERIC_TIME 102956
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"
@@ -7878,17 +7878,25 @@
78787878
depth--;
78797879
}
78807880
}
78817881
if( z[i]==')' ){
78827882
args[nArg].n = i - iStart;
7883
- /* Remove leading and trailing whitespace from each argument.
7884
- ** If what remains is one of $1, $2, ... $9 then transfer the
7885
- ** corresponding argument from the outer context */
7883
+ /* Remove leading and trailing whitespace from each argument (including
7884
+ ** backslash-escaped newlines). If what remains is one of $1, $2, ... $9
7885
+ ** then transfer the corresponding argument from the outer context */
78867886
for(j=0; j<=nArg; j++){
78877887
PToken *t = &args[j];
7888
- while( t->n>0 && IsSpace(t->z[0]) ){ t->n--; t->z++; }
7889
- while( t->n>0 && IsSpace(t->z[t->n-1]) ){ t->n--; }
7888
+ while( (t->n>0 && IsSpace(t->z[0]))
7889
+ || (t->n>1 && t->z[0]=='\\' && IsSpace(t->z[1]))
7890
+ ){
7891
+ t->z++;
7892
+ t->n--;
7893
+ }
7894
+ while( t->n>0 && IsSpace(t->z[t->n-1]) ){
7895
+ t->n--;
7896
+ if( t->n>0 && t->z[t->n-1]=='\\' ) t->n--;
7897
+ }
78907898
if( t->n==2 && t->z[0]=='$' && t->z[1]>='1' && t->z[1]<='9' ){
78917899
if( pOuter ) *t = pOuter[t->z[1]-'1'];
78927900
else t->n = 0;
78937901
}
78947902
}
@@ -8257,16 +8265,23 @@
82578265
free(zIn);
82588266
}
82598267
if( !bSvgOnly ){
82608268
printf("</body></html>\n");
82618269
}
8262
- return exitCode ? EXIT_FAILURE : EXIT_SUCCESS;
8270
+ return exitCode ? EXIT_FAILURE : EXIT_SUCCESS;
82638271
}
82648272
#endif /* PIKCHR_SHELL */
82658273
82668274
#ifdef PIKCHR_TCL
82678275
#include <tcl.h>
8276
+/* Compatability between Tcl8.6 and Tcl9.0 */
8277
+#if TCL_MAJOR_VERSION==9
8278
+# define CONST const
8279
+#elif !defined(Tcl_Size)
8280
+ typedef int Tcl_Size;
8281
+#endif
8282
+
82688283
/*
82698284
** An interface to TCL
82708285
**
82718286
** TCL command: pikchr $INPUTTEXT
82728287
**
@@ -8284,11 +8299,11 @@
82848299
*/
82858300
static int pik_tcl_command(
82868301
ClientData clientData, /* Not Used */
82878302
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
82888303
int objc, /* Number of arguments */
8289
- Tcl_Obj *const objv[] /* Command arguments */
8304
+ Tcl_Obj *CONST objv[] /* Command arguments */
82908305
){
82918306
int w, h; /* Width and height of the pikchr */
82928307
const char *zIn; /* Source text input */
82938308
char *zOut; /* SVG output text */
82948309
Tcl_Obj *pRes; /* The result TCL object */
@@ -8330,6 +8345,6 @@
83308345
83318346
83328347
#endif /* PIKCHR_TCL */
83338348
83348349
8335
-#line 8335 "pikchr.c"
8350
+#line 8350 "pikchr.c"
83368351
--- 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 "8a43b020141f772a0ac45291a7fd73041d2efba5e3665c6bd2f334ad9b2e9845"
31 #define MANIFEST_VERSION "[8a43b02014]"
32 #define MANIFEST_DATE "2025-03-19 16:19:43"
33 #define MANIFEST_YEAR "2025"
34 #define MANIFEST_ISODATE "20250319161943"
35 #define MANIFEST_NUMERIC_DATE 20250319
36 #define MANIFEST_NUMERIC_TIME 161943
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"
@@ -7878,17 +7878,25 @@
7878 depth--;
7879 }
7880 }
7881 if( z[i]==')' ){
7882 args[nArg].n = i - iStart;
7883 /* Remove leading and trailing whitespace from each argument.
7884 ** If what remains is one of $1, $2, ... $9 then transfer the
7885 ** corresponding argument from the outer context */
7886 for(j=0; j<=nArg; j++){
7887 PToken *t = &args[j];
7888 while( t->n>0 && IsSpace(t->z[0]) ){ t->n--; t->z++; }
7889 while( t->n>0 && IsSpace(t->z[t->n-1]) ){ t->n--; }
 
 
 
 
 
 
 
 
7890 if( t->n==2 && t->z[0]=='$' && t->z[1]>='1' && t->z[1]<='9' ){
7891 if( pOuter ) *t = pOuter[t->z[1]-'1'];
7892 else t->n = 0;
7893 }
7894 }
@@ -8257,16 +8265,23 @@
8257 free(zIn);
8258 }
8259 if( !bSvgOnly ){
8260 printf("</body></html>\n");
8261 }
8262 return exitCode ? EXIT_FAILURE : EXIT_SUCCESS;
8263 }
8264 #endif /* PIKCHR_SHELL */
8265
8266 #ifdef PIKCHR_TCL
8267 #include <tcl.h>
 
 
 
 
 
 
 
8268 /*
8269 ** An interface to TCL
8270 **
8271 ** TCL command: pikchr $INPUTTEXT
8272 **
@@ -8284,11 +8299,11 @@
8284 */
8285 static int pik_tcl_command(
8286 ClientData clientData, /* Not Used */
8287 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
8288 int objc, /* Number of arguments */
8289 Tcl_Obj *const objv[] /* Command arguments */
8290 ){
8291 int w, h; /* Width and height of the pikchr */
8292 const char *zIn; /* Source text input */
8293 char *zOut; /* SVG output text */
8294 Tcl_Obj *pRes; /* The result TCL object */
@@ -8330,6 +8345,6 @@
8330
8331
8332 #endif /* PIKCHR_TCL */
8333
8334
8335 #line 8335 "pikchr.c"
8336
--- 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 "a7f1c35bc0448daf15e2bafa36e510c1517534e620c452ecb314ed57d974f081"
31 #define MANIFEST_VERSION "[a7f1c35bc0]"
32 #define MANIFEST_DATE "2026-04-03 10:29:56"
33 #define MANIFEST_YEAR "2026"
34 #define MANIFEST_ISODATE "20260403102956"
35 #define MANIFEST_NUMERIC_DATE 20260403
36 #define MANIFEST_NUMERIC_TIME 102956
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"
@@ -7878,17 +7878,25 @@
7878 depth--;
7879 }
7880 }
7881 if( z[i]==')' ){
7882 args[nArg].n = i - iStart;
7883 /* Remove leading and trailing whitespace from each argument (including
7884 ** backslash-escaped newlines). If what remains is one of $1, $2, ... $9
7885 ** then transfer the corresponding argument from the outer context */
7886 for(j=0; j<=nArg; j++){
7887 PToken *t = &args[j];
7888 while( (t->n>0 && IsSpace(t->z[0]))
7889 || (t->n>1 && t->z[0]=='\\' && IsSpace(t->z[1]))
7890 ){
7891 t->z++;
7892 t->n--;
7893 }
7894 while( t->n>0 && IsSpace(t->z[t->n-1]) ){
7895 t->n--;
7896 if( t->n>0 && t->z[t->n-1]=='\\' ) t->n--;
7897 }
7898 if( t->n==2 && t->z[0]=='$' && t->z[1]>='1' && t->z[1]<='9' ){
7899 if( pOuter ) *t = pOuter[t->z[1]-'1'];
7900 else t->n = 0;
7901 }
7902 }
@@ -8257,16 +8265,23 @@
8265 free(zIn);
8266 }
8267 if( !bSvgOnly ){
8268 printf("</body></html>\n");
8269 }
8270 return exitCode ? EXIT_FAILURE : EXIT_SUCCESS;
8271 }
8272 #endif /* PIKCHR_SHELL */
8273
8274 #ifdef PIKCHR_TCL
8275 #include <tcl.h>
8276 /* Compatability between Tcl8.6 and Tcl9.0 */
8277 #if TCL_MAJOR_VERSION==9
8278 # define CONST const
8279 #elif !defined(Tcl_Size)
8280 typedef int Tcl_Size;
8281 #endif
8282
8283 /*
8284 ** An interface to TCL
8285 **
8286 ** TCL command: pikchr $INPUTTEXT
8287 **
@@ -8284,11 +8299,11 @@
8299 */
8300 static int pik_tcl_command(
8301 ClientData clientData, /* Not Used */
8302 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
8303 int objc, /* Number of arguments */
8304 Tcl_Obj *CONST objv[] /* Command arguments */
8305 ){
8306 int w, h; /* Width and height of the pikchr */
8307 const char *zIn; /* Source text input */
8308 char *zOut; /* SVG output text */
8309 Tcl_Obj *pRes; /* The result TCL object */
@@ -8330,6 +8345,6 @@
8345
8346
8347 #endif /* PIKCHR_TCL */
8348
8349
8350 #line 8350 "pikchr.c"
8351
+284 -414
--- extsrc/pikchr.js
+++ extsrc/pikchr.js
@@ -1,14 +1,21 @@
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.
13
4
+// Single threaded MINIMAL_RUNTIME programs do not need access to
5
+// document.currentScript, so a simple export declaration is enough.
26
var initPikchrModule = (() => {
3
- var _scriptName = typeof document != 'undefined' ? document.currentScript?.src : undefined;
4
-
5
- return (
6
-function(moduleArg = {}) {
7
- var moduleRtn;
7
+ // When MODULARIZE this JS may be executed later,
8
+ // after document.currentScript is gone, so we save it.
9
+ // In EXPORT_ES6 mode we can just use 'import.meta.url'.
10
+ var _scriptName = globalThis.document?.currentScript?.src;
11
+ return async function(moduleArg = {}) {
12
+ var moduleRtn;
813
914
// include: shell.js
15
+// include: minimum_runtime_check.js
16
+// end include: minimum_runtime_check.js
1017
// The Module object: Our interface to the outside world. We import
1118
// and export values on it. There are various ways Module can be used:
1219
// 1. Not defined. We create it here
1320
// 2. A function parameter, function(moduleArg) => Promise<Module>
1421
// 3. pre-run appended it, var Module = {}; ..generated code..
@@ -20,33 +27,18 @@
2027
// after the generated code, you will need to define var Module = {};
2128
// before the code. Then that object will be used in the code, and you
2229
// can continue to use Module afterwards as well.
2330
var Module = moduleArg;
2431
25
-// Set up the promise that indicates the Module is initialized
26
-var readyPromiseResolve, readyPromiseReject;
27
-
28
-var readyPromise = new Promise((resolve, reject) => {
29
- readyPromiseResolve = resolve;
30
- readyPromiseReject = reject;
31
-});
32
-
3332
// Determine the runtime environment we are in. You can customize this by
3433
// setting the ENVIRONMENT setting at compile time (see settings.js).
3534
var ENVIRONMENT_IS_WEB = true;
3635
3736
var ENVIRONMENT_IS_WORKER = false;
3837
3938
// --pre-jses are emitted after the Module integration code, so that they can
4039
// refer to Module (if they choose; they can also define Module)
41
-// Sometimes an existing Module object exists with properties
42
-// meant to overwrite the default module functionality. Here
43
-// we collect those properties and reapply _after_ we configure
44
-// the current environment's defaults to avoid having to be so
45
-// defensive during initialization.
46
-var moduleOverrides = Object.assign({}, Module);
47
-
4840
var arguments_ = [];
4941
5042
var thisProgram = "./this.program";
5143
5244
var quit_ = (status, toThrow) => {
@@ -68,67 +60,31 @@
6860
6961
// Note that this includes Node.js workers when relevant (pthreads is enabled).
7062
// Node.js workers are detected as a combination of ENVIRONMENT_IS_WORKER and
7163
// ENVIRONMENT_IS_NODE.
7264
if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
73
- if (ENVIRONMENT_IS_WORKER) {
74
- // Check worker, not web, since window could be polyfilled
75
- scriptDirectory = self.location.href;
76
- } else if (typeof document != "undefined" && document.currentScript) {
77
- // web
78
- scriptDirectory = document.currentScript.src;
79
- }
80
- // When MODULARIZE, this JS may be executed later, after document.currentScript
81
- // is gone, so we saved it, and we use it here instead of any other info.
82
- if (_scriptName) {
83
- scriptDirectory = _scriptName;
84
- }
85
- // blob urls look like blob:http://site.com/etc/etc and we cannot infer anything from them.
86
- // otherwise, slice off the final part of the url to find the script directory.
87
- // if scriptDirectory does not contain a slash, lastIndexOf will return -1,
88
- // and scriptDirectory will correctly be replaced with an empty string.
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
- }
65
+ try {
66
+ scriptDirectory = new URL(".", _scriptName).href;
67
+ } catch {}
9668
{
9769
// include: web_or_worker_shell_read.js
98
- readAsync = url => fetch(url, {
99
- credentials: "same-origin"
100
- }).then(response => {
70
+ readAsync = async url => {
71
+ var response = await fetch(url, {
72
+ credentials: "same-origin"
73
+ });
10174
if (response.ok) {
10275
return response.arrayBuffer();
10376
}
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
-
114
-// Merge back in the overrides
115
-Object.assign(Module, moduleOverrides);
116
-
117
-// Free the object hierarchy contained in the overrides, this lets the GC
118
-// reclaim data used.
119
-moduleOverrides = null;
120
-
121
-// Emit code to handle expected values on the Module object. This applies Module.x
122
-// to the proper local x. This has two benefits: first, we only emit it if it is
123
-// expected to arrive, and second, by using a local everywhere else that can be
124
-// minified.
125
-if (Module["arguments"]) arguments_ = Module["arguments"];
126
-
127
-if (Module["thisProgram"]) thisProgram = Module["thisProgram"];
128
-
129
-// perform assertions in shell.js after we set up out() and err(), as otherwise if an assertion fails it cannot print the message
77
+ throw new Error(response.status + " : " + response.url);
78
+ };
79
+ }
80
+} else {}
81
+
82
+var out = console.log.bind(console);
83
+
84
+var err = console.error.bind(console);
85
+
13086
// end include: shell.js
13187
// include: preamble.js
13288
// === Preamble library stuff ===
13389
// Documentation for the public APIs defined in this file must be updated in:
13490
// site/source/docs/api_reference/preamble.js.rst
@@ -135,130 +91,87 @@
13591
// A prebuilt local version of the documentation is available at:
13692
// site/build/text/docs/api_reference/preamble.js.txt
13793
// You can also build docs locally as HTML or other formats in site/
13894
// An online HTML version (which may be of a different version of Emscripten)
13995
// is up at http://kripken.github.io/emscripten-site/docs/api_reference/preamble.js.html
140
-var wasmBinary = Module["wasmBinary"];
96
+var wasmBinary;
14197
14298
// Wasm globals
143
-var wasmMemory;
144
-
14599
//========================================
146100
// Runtime essentials
147101
//========================================
148102
// whether we are quitting the application. no code should run after this.
149103
// set in exit() and abort()
150104
var ABORT = false;
151105
152106
// set by exit() and abort(). Passed to 'onExit' handler.
153
-// NOTE: This is also used as the process return code code in shell environments
107
+// NOTE: This is also used as the process return code in shell environments
154108
// but only when noExitRuntime is false.
155109
var EXITSTATUS;
156110
111
+// include: runtime_common.js
112
+// include: runtime_stack_check.js
113
+// end include: runtime_stack_check.js
114
+// include: runtime_exceptions.js
115
+// end include: runtime_exceptions.js
116
+// include: runtime_debug.js
117
+// end include: runtime_debug.js
118
+var readyPromiseResolve, readyPromiseReject;
119
+
157120
// Memory management
158121
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;
159122
160
-// include: runtime_shared.js
123
+// BigInt64Array type is not correctly defined in closure
124
+var /** not-@type {!BigInt64Array} */ HEAP64, /* BigUint64Array type is not correctly defined in closure
125
+/** not-@type {!BigUint64Array} */ HEAPU64;
126
+
127
+var runtimeInitialized = false;
128
+
161129
function updateMemoryViews() {
162130
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);
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
-
131
+ HEAP8 = new Int8Array(b);
132
+ HEAP16 = new Int16Array(b);
133
+ HEAPU8 = new Uint8Array(b);
134
+ HEAPU16 = new Uint16Array(b);
135
+ HEAP32 = new Int32Array(b);
136
+ HEAPU32 = new Uint32Array(b);
137
+ HEAPF32 = new Float32Array(b);
138
+ HEAPF64 = new Float64Array(b);
139
+ HEAP64 = new BigInt64Array(b);
140
+ HEAPU64 = new BigUint64Array(b);
141
+}
142
+
143
+// include: memoryprofiler.js
144
+// end include: memoryprofiler.js
145
+// end include: runtime_common.js
187146
function preRun() {
188
- var preRuns = Module["preRun"];
189
- if (preRuns) {
190
- if (typeof preRuns == "function") preRuns = [ preRuns ];
191
- preRuns.forEach(addOnPreRun);
147
+ if (Module["preRun"]) {
148
+ if (typeof Module["preRun"] == "function") Module["preRun"] = [ Module["preRun"] ];
149
+ while (Module["preRun"].length) {
150
+ addOnPreRun(Module["preRun"].shift());
151
+ }
192152
}
193
- callRuntimeCallbacks(__ATPRERUN__);
153
+ // Begin ATPRERUNS hooks
154
+ callRuntimeCallbacks(onPreRuns);
194155
}
195156
196157
function initRuntime() {
197158
runtimeInitialized = true;
198
- callRuntimeCallbacks(__ATINIT__);
159
+ // No ATINITS hooks
160
+ wasmExports["e"]();
199161
}
200162
201163
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++;
243
- Module["monitorRunDependencies"]?.(runDependencies);
244
-}
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
- }
259
- }
164
+ // PThreads reuse the runtime from the main thread.
165
+ if (Module["postRun"]) {
166
+ if (typeof Module["postRun"] == "function") Module["postRun"] = [ Module["postRun"] ];
167
+ while (Module["postRun"].length) {
168
+ addOnPostRun(Module["postRun"].shift());
169
+ }
170
+ }
171
+ // Begin ATPOSTRUNS hooks
172
+ callRuntimeCallbacks(onPostRuns);
260173
}
261174
262175
/** @param {string|number=} what */ function abort(what) {
263176
Module["onAbort"]?.(what);
264177
what = "Aborted(" + what + ")";
@@ -278,163 +191,154 @@
278191
// Suppress closure compiler warning here. Closure compiler's builtin extern
279192
// definition for WebAssembly.RuntimeError claims it takes no arguments even
280193
// though it can.
281194
// TODO(https://github.com/google/closure-compiler/pull/3913): Remove if/when upstream closure gets fixed.
282195
/** @suppress {checkTypes} */ var e = new WebAssembly.RuntimeError(what);
283
- readyPromiseReject(e);
196
+ readyPromiseReject?.(e);
284197
// Throw the error whether or not MODULARIZE is set because abort is used
285198
// in code paths apart from instantiation where an exception is expected
286199
// to be thrown when abort is called.
287200
throw e;
288201
}
289202
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
203
+var wasmBinaryFile;
204
+
304205
function findWasmBinary() {
305
- var f = "pikchr-v2813665466.wasm";
306
- if (!isDataURI(f)) {
307
- return locateFile(f);
308
- }
309
- return f;
310
-}
311
-
312
-var wasmBinaryFile;
206
+ return locateFile("pikchr-v8806526039.wasm");
207
+}
313208
314209
function getBinarySync(file) {
315210
if (file == wasmBinaryFile && wasmBinary) {
316211
return new Uint8Array(wasmBinary);
317212
}
318213
if (readBinary) {
319214
return readBinary(file);
320215
}
216
+ // Throwing a plain string here, even though it not normally advisable since
217
+ // this gets turning into an `abort` in instantiateArrayBuffer.
321218
throw "both async and sync fetching of the wasm failed";
322219
}
323220
324
-function getBinaryPromise(binaryFile) {
221
+async function getWasmBinary(binaryFile) {
325222
// If we don't have the binary yet, load it asynchronously using readAsync.
326223
if (!wasmBinary) {
327224
// 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));
225
+ try {
226
+ var response = await readAsync(binaryFile);
227
+ return new Uint8Array(response);
228
+ } catch {}
330229
}
331230
// Otherwise, getBinarySync should be able to get it synchronously
332
- return Promise.resolve().then(() => getBinarySync(binaryFile));
231
+ return getBinarySync(binaryFile);
333232
}
334233
335
-function instantiateArrayBuffer(binaryFile, imports, receiver) {
336
- return getBinaryPromise(binaryFile).then(binary => WebAssembly.instantiate(binary, imports)).then(receiver, reason => {
234
+async function instantiateArrayBuffer(binaryFile, imports) {
235
+ try {
236
+ var binary = await getWasmBinary(binaryFile);
237
+ var instance = await WebAssembly.instantiate(binary, imports);
238
+ return instance;
239
+ } catch (reason) {
337240
err(`failed to asynchronously prepare wasm: ${reason}`);
338241
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);
242
+ }
243
+}
244
+
245
+async function instantiateAsync(binary, binaryFile, imports) {
246
+ if (!binary) {
247
+ try {
248
+ var response = fetch(binaryFile, {
249
+ credentials: "same-origin"
250
+ });
251
+ var instantiationResult = await WebAssembly.instantiateStreaming(response, imports);
252
+ return instantiationResult;
253
+ } catch (reason) {
254
+ // We expect the most common failure cause to be a bad MIME type for the binary,
255
+ // in which case falling back to ArrayBuffer instantiation should work.
256
+ err(`wasm streaming compile failed: ${reason}`);
257
+ err("falling back to ArrayBuffer instantiation");
258
+ }
259
+ }
260
+ return instantiateArrayBuffer(binaryFile, imports);
362261
}
363262
364263
function getWasmImports() {
365264
// prepare imports
366
- return {
265
+ var imports = {
367266
"a": wasmImports
368267
};
268
+ return imports;
369269
}
370270
371271
// Create the wasm instance.
372272
// Receives the wasm imports, returns the exports.
373
-function createWasm() {
374
- var info = getWasmImports();
273
+async function createWasm() {
375274
// Load the wasm module and create an instance of using native support in the JS engine.
376275
// handle a generated wasm instance, receiving its exports and
377276
// performing other necessary setup
378277
/** @param {WebAssembly.Module=} module*/ function receiveInstance(instance, module) {
379278
wasmExports = instance.exports;
380
- wasmMemory = wasmExports["d"];
279
+ assignWasmExports(wasmExports);
381280
updateMemoryViews();
382
- addOnInit(wasmExports["e"]);
383
- removeRunDependency("wasm-instantiate");
384281
return wasmExports;
385282
}
386
- // wait for the pthread pool (if any)
387
- addRunDependency("wasm-instantiate");
388283
// Prefer streaming instantiation if available.
389284
function receiveInstantiationResult(result) {
390285
// 'result' is a ResultObject object which has both the module and instance.
391286
// receiveInstance() will swap in the exports (to Module.asm) so they can be called
392287
// 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.
393288
// When the regression is fixed, can restore the above PTHREADS-enabled path.
394
- receiveInstance(result["instance"]);
289
+ return receiveInstance(result["instance"]);
395290
}
291
+ var info = getWasmImports();
396292
// User shell pages can write their own Module.instantiateWasm = function(imports, successCallback) callback
397293
// to manually instantiate the Wasm module themselves. This allows pages to
398294
// run the instantiation parallel to any other async startup actions they are
399295
// performing.
400296
// Also pthreads and wasm workers initialize the wasm instance through this
401297
// path.
402298
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
- }
299
+ return new Promise((resolve, reject) => {
300
+ Module["instantiateWasm"](info, (inst, mod) => {
301
+ resolve(receiveInstance(inst, mod));
302
+ });
303
+ });
410304
}
411305
wasmBinaryFile ??= findWasmBinary();
412
- // If instantiation fails, reject the module ready promise.
413
- instantiateAsync(wasmBinary, wasmBinaryFile, info, receiveInstantiationResult).catch(readyPromiseReject);
414
- return {};
306
+ var result = await instantiateAsync(wasmBinary, wasmBinaryFile, info);
307
+ var exports = receiveInstantiationResult(result);
308
+ return exports;
415309
}
416310
417
-// include: runtime_debug.js
418
-// end include: runtime_debug.js
419
-// === Body ===
420311
// 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;
312
+// Begin JS library code
313
+class ExitStatus {
314
+ name="ExitStatus";
315
+ constructor(status) {
316
+ this.message = `Program terminated with exit(${status})`;
317
+ this.status = status;
318
+ }
425319
}
426320
427321
var callRuntimeCallbacks = callbacks => {
428
- // Pass the module as the first argument.
429
- callbacks.forEach(f => f(Module));
322
+ while (callbacks.length > 0) {
323
+ // Pass the module as the first argument.
324
+ callbacks.shift()(Module);
325
+ }
430326
};
431327
328
+var onPostRuns = [];
329
+
330
+var addOnPostRun = cb => onPostRuns.push(cb);
331
+
332
+var onPreRuns = [];
333
+
334
+var addOnPreRun = cb => onPreRuns.push(cb);
335
+
432336
/**
433
- * @param {number} ptr
434
- * @param {string} type
435
- */ function getValue(ptr, type = "i8") {
337
+ * @param {number} ptr
338
+ * @param {string} type
339
+ */ function getValue(ptr, type = "i8") {
436340
if (type.endsWith("*")) type = "*";
437341
switch (type) {
438342
case "i1":
439343
return HEAP8[ptr];
440344
@@ -446,11 +350,11 @@
446350
447351
case "i32":
448352
return HEAP32[((ptr) >> 2)];
449353
450354
case "i64":
451
- abort("to do getValue(i64) use WASM_BIGINT");
355
+ return HEAP64[((ptr) >> 3)];
452356
453357
case "float":
454358
return HEAPF32[((ptr) >> 2)];
455359
456360
case "double":
@@ -462,17 +366,17 @@
462366
default:
463367
abort(`invalid type for getValue: ${type}`);
464368
}
465369
}
466370
467
-var noExitRuntime = Module["noExitRuntime"] || true;
371
+var noExitRuntime = true;
468372
469373
/**
470
- * @param {number} ptr
471
- * @param {number} value
472
- * @param {string} type
473
- */ function setValue(ptr, value, type = "i8") {
374
+ * @param {number} ptr
375
+ * @param {number} value
376
+ * @param {string} type
377
+ */ function setValue(ptr, value, type = "i8") {
474378
if (type.endsWith("*")) type = "*";
475379
switch (type) {
476380
case "i1":
477381
HEAP8[ptr] = value;
478382
break;
@@ -488,11 +392,12 @@
488392
case "i32":
489393
HEAP32[((ptr) >> 2)] = value;
490394
break;
491395
492396
case "i64":
493
- abort("to do setValue(i64) use WASM_BIGINT");
397
+ HEAP64[((ptr) >> 3)] = BigInt(value);
398
+ break;
494399
495400
case "float":
496401
HEAPF32[((ptr) >> 2)] = value;
497402
break;
498403
@@ -511,85 +416,42 @@
511416
512417
var stackRestore = val => __emscripten_stack_restore(val);
513418
514419
var stackSave = () => _emscripten_stack_get_current();
515420
516
-var UTF8Decoder = typeof TextDecoder != "undefined" ? new TextDecoder : undefined;
517
-
518
-/**
519
- * Given a pointer 'idx' to a null-terminated UTF8-encoded string in the given
520
- * array that contains uint8 values, returns a copy of that string as a
521
- * Javascript String object.
522
- * heapOrArray is either a regular array, or a JavaScript typed array view.
523
- * @param {number=} idx
524
- * @param {number=} maxBytesToRead
525
- * @return {string}
526
- */ var UTF8ArrayToString = (heapOrArray, idx = 0, maxBytesToRead = NaN) => {
527
- var endIdx = idx + maxBytesToRead;
528
- var endPtr = idx;
529
- // TextDecoder needs to know the byte length in advance, it doesn't stop on
530
- // null terminator by itself. Also, use the length info to avoid running tiny
531
- // strings through TextDecoder, since .subarray() allocates garbage.
532
- // (As a tiny code save trick, compare endPtr against endIdx using a negation,
533
- // so that undefined/NaN means Infinity)
534
- while (heapOrArray[endPtr] && !(endPtr >= endIdx)) ++endPtr;
535
- if (endPtr - idx > 16 && heapOrArray.buffer && UTF8Decoder) {
536
- return UTF8Decoder.decode(heapOrArray.subarray(idx, endPtr));
537
- }
538
- var str = "";
539
- // If building with TextDecoder, we have already computed the string length
540
- // above, so test loop end condition against that
541
- while (idx < endPtr) {
542
- // For UTF8 byte structure, see:
543
- // http://en.wikipedia.org/wiki/UTF-8#Description
544
- // https://www.ietf.org/rfc/rfc2279.txt
545
- // https://tools.ietf.org/html/rfc3629
546
- var u0 = heapOrArray[idx++];
547
- if (!(u0 & 128)) {
548
- str += String.fromCharCode(u0);
549
- continue;
550
- }
551
- var u1 = heapOrArray[idx++] & 63;
552
- if ((u0 & 224) == 192) {
553
- str += String.fromCharCode(((u0 & 31) << 6) | u1);
554
- continue;
555
- }
556
- var u2 = heapOrArray[idx++] & 63;
557
- if ((u0 & 240) == 224) {
558
- u0 = ((u0 & 15) << 12) | (u1 << 6) | u2;
559
- } else {
560
- u0 = ((u0 & 7) << 18) | (u1 << 12) | (u2 << 6) | (heapOrArray[idx++] & 63);
561
- }
562
- if (u0 < 65536) {
563
- str += String.fromCharCode(u0);
564
- } else {
565
- var ch = u0 - 65536;
566
- str += String.fromCharCode(55296 | (ch >> 10), 56320 | (ch & 1023));
567
- }
568
- }
569
- return str;
570
-};
571
-
572
-/**
573
- * Given a pointer 'ptr' to a null-terminated UTF8-encoded string in the
574
- * emscripten HEAP, returns a copy of that string as a Javascript String object.
575
- *
576
- * @param {number} ptr
577
- * @param {number=} maxBytesToRead - An optional length that specifies the
578
- * maximum number of bytes to read. You can omit this parameter to scan the
579
- * string until the first 0 byte. If maxBytesToRead is passed, and the string
580
- * at [ptr, ptr+maxBytesToReadr[ contains a null byte in the middle, then the
581
- * string will cut short at that byte index (i.e. maxBytesToRead will not
582
- * produce a string of exact length [ptr, ptr+maxBytesToRead[) N.B. mixing
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
-};
421
+var UTF8Decoder = new TextDecoder;
422
+
423
+var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
424
+ var maxIdx = idx + maxBytesToRead;
425
+ if (ignoreNul) return maxIdx;
426
+ // TextDecoder needs to know the byte length in advance, it doesn't stop on
427
+ // null terminator by itself.
428
+ // As a tiny code save trick, compare idx against maxIdx using a negation,
429
+ // so that maxBytesToRead=undefined/NaN means Infinity.
430
+ while (heapOrArray[idx] && !(idx >= maxIdx)) ++idx;
431
+ return idx;
432
+};
433
+
434
+/**
435
+ * Given a pointer 'ptr' to a null-terminated UTF8-encoded string in the
436
+ * emscripten HEAP, returns a copy of that string as a Javascript String object.
437
+ *
438
+ * @param {number} ptr
439
+ * @param {number=} maxBytesToRead - An optional length that specifies the
440
+ * maximum number of bytes to read. You can omit this parameter to scan the
441
+ * string until the first 0 byte. If maxBytesToRead is passed, and the string
442
+ * at [ptr, ptr+maxBytesToReadr[ contains a null byte in the middle, then the
443
+ * string will cut short at that byte index.
444
+ * @param {boolean=} ignoreNul - If true, the function will not stop on a NUL character.
445
+ * @return {string}
446
+ */ var UTF8ToString = (ptr, maxBytesToRead, ignoreNul) => {
447
+ if (!ptr) return "";
448
+ var end = findStringEnd(HEAPU8, ptr, maxBytesToRead, ignoreNul);
449
+ return UTF8Decoder.decode(HEAPU8.subarray(ptr, end));
450
+};
451
+
452
+var ___assert_fail = (condition, filename, line, func) => abort(`Assertion failed: ${UTF8ToString(condition)}, at: ` + [ filename ? UTF8ToString(filename) : "unknown filename", line, func ? UTF8ToString(func) : "unknown function" ]);
591453
592454
var abortOnCannotGrowMemory = requestedSize => {
593455
abort("OOM");
594456
};
595457
@@ -611,11 +473,11 @@
611473
ABORT = true;
612474
}
613475
quit_(code, new ExitStatus(code));
614476
};
615477
616
-/** @suppress {duplicate } */ /** @param {boolean|number=} implicit */ var exitJS = (status, implicit) => {
478
+/** @param {boolean|number=} implicit */ var exitJS = (status, implicit) => {
617479
EXITSTATUS = status;
618480
_proc_exit(status);
619481
};
620482
621483
var _exit = exitJS;
@@ -659,23 +521,14 @@
659521
if (!(maxBytesToWrite > 0)) return 0;
660522
var startIdx = outIdx;
661523
var endIdx = outIdx + maxBytesToWrite - 1;
662524
// -1 for string null terminator.
663525
for (var i = 0; i < str.length; ++i) {
664
- // Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code
665
- // unit, not a Unicode code point of the character! So decode
666
- // UTF16->UTF32->UTF8.
667
- // See http://unicode.org/faq/utf_bom.html#utf16-3
668526
// For UTF8 byte structure, see http://en.wikipedia.org/wiki/UTF-8#Description
669527
// and https://www.ietf.org/rfc/rfc2279.txt
670528
// and https://tools.ietf.org/html/rfc3629
671
- var u = str.charCodeAt(i);
672
- // possibly a lead surrogate
673
- if (u >= 55296 && u <= 57343) {
674
- var u1 = str.charCodeAt(++i);
675
- u = 65536 + ((u & 1023) << 10) | (u1 & 1023);
676
- }
529
+ var u = str.codePointAt(i);
677530
if (u <= 127) {
678531
if (outIdx >= endIdx) break;
679532
heap[outIdx++] = u;
680533
} else if (u <= 2047) {
681534
if (outIdx + 1 >= endIdx) break;
@@ -690,10 +543,13 @@
690543
if (outIdx + 3 >= endIdx) break;
691544
heap[outIdx++] = 240 | (u >> 18);
692545
heap[outIdx++] = 128 | ((u >> 12) & 63);
693546
heap[outIdx++] = 128 | ((u >> 6) & 63);
694547
heap[outIdx++] = 128 | (u & 63);
548
+ // Gotcha: if codePoint is over 0xFFFF, it is represented as a surrogate pair in UTF-16.
549
+ // We need to manually skip over the second code unit for correct iteration.
550
+ i++;
695551
}
696552
}
697553
// Null-terminate the pointer to the buffer.
698554
heap[outIdx] = 0;
699555
return outIdx - startIdx;
@@ -709,15 +565,15 @@
709565
stringToUTF8(str, ret, size);
710566
return ret;
711567
};
712568
713569
/**
714
- * @param {string|null=} returnType
715
- * @param {Array=} argTypes
716
- * @param {Arguments|Array=} args
717
- * @param {Object=} opts
718
- */ var ccall = (ident, returnType, argTypes, args, opts) => {
570
+ * @param {string|null=} returnType
571
+ * @param {Array=} argTypes
572
+ * @param {Array=} args
573
+ * @param {Object=} opts
574
+ */ var ccall = (ident, returnType, argTypes, args, opts) => {
719575
// For fast lookup of conversion functions
720576
var toC = {
721577
"string": str => {
722578
var ret = 0;
723579
if (str !== null && str !== undefined && str !== 0) {
@@ -761,14 +617,14 @@
761617
ret = onDone(ret);
762618
return ret;
763619
};
764620
765621
/**
766
- * @param {string=} returnType
767
- * @param {Array=} argTypes
768
- * @param {Object=} opts
769
- */ var cwrap = (ident, returnType, argTypes, opts) => {
622
+ * @param {string=} returnType
623
+ * @param {Array=} argTypes
624
+ * @param {Object=} opts
625
+ */ var cwrap = (ident, returnType, argTypes, opts) => {
770626
// When the function takes numbers and returns a number, we can just return
771627
// the original function
772628
var numericArgs = !argTypes || argTypes.every(type => type === "number" || type === "boolean");
773629
var numericRet = returnType !== "string";
774630
if (numericRet && numericArgs && !opts) {
@@ -775,32 +631,32 @@
775631
return getCFunc(ident);
776632
}
777633
return (...args) => ccall(ident, returnType, argTypes, args, opts);
778634
};
779635
780
-var wasmImports = {
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 ===
636
+// End JS library code
637
+// include: postlibrary.js
638
+// This file is included after the automatically-generated JS library code
639
+// but before the wasm module is created.
640
+{
641
+ // Begin ATMODULES hooks
642
+ if (Module["noExitRuntime"]) noExitRuntime = Module["noExitRuntime"];
643
+ if (Module["print"]) out = Module["print"];
644
+ if (Module["printErr"]) err = Module["printErr"];
645
+ if (Module["wasmBinary"]) wasmBinary = Module["wasmBinary"];
646
+ // End ATMODULES hooks
647
+ if (Module["arguments"]) arguments_ = Module["arguments"];
648
+ if (Module["thisProgram"]) thisProgram = Module["thisProgram"];
649
+ if (Module["preInit"]) {
650
+ if (typeof Module["preInit"] == "function") Module["preInit"] = [ Module["preInit"] ];
651
+ while (Module["preInit"].length > 0) {
652
+ Module["preInit"].shift()();
653
+ }
654
+ }
655
+}
656
+
657
+// Begin runtime exports
802658
Module["stackSave"] = stackSave;
803659
804660
Module["stackRestore"] = stackRestore;
805661
806662
Module["stackAlloc"] = stackAlloc;
@@ -811,42 +667,44 @@
811667
812668
Module["setValue"] = setValue;
813669
814670
Module["getValue"] = getValue;
815671
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;
672
+// End runtime exports
673
+// Begin JS library exports
674
+// End JS library exports
675
+// end include: postlibrary.js
676
+// Imports from the Wasm binary.
677
+var _pikchr_version, _pikchr, __emscripten_stack_restore, __emscripten_stack_alloc, _emscripten_stack_get_current, memory, __indirect_function_table, wasmMemory;
678
+
679
+function assignWasmExports(wasmExports) {
680
+ _pikchr_version = Module["_pikchr_version"] = wasmExports["f"];
681
+ _pikchr = Module["_pikchr"] = wasmExports["g"];
682
+ __emscripten_stack_restore = wasmExports["h"];
683
+ __emscripten_stack_alloc = wasmExports["i"];
684
+ _emscripten_stack_get_current = wasmExports["j"];
685
+ memory = wasmMemory = wasmExports["d"];
686
+ __indirect_function_table = wasmExports["__indirect_function_table"];
687
+}
688
+
689
+var wasmImports = {
690
+ /** @export */ a: ___assert_fail,
691
+ /** @export */ b: _emscripten_resize_heap,
692
+ /** @export */ c: _exit
824693
};
825694
826
-// try this again later, after new deps are fulfilled
695
+// include: postamble.js
696
+// === Auto-generated postamble setup entry stuff ===
827697
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
- }
698
+ preRun();
839699
function doRun() {
840700
// run may have just been called through dependencies being fulfilled just in this very frame,
841701
// or while the async setStatus time below was happening
842
- if (calledRun) return;
843
- calledRun = 1;
844
- Module["calledRun"] = 1;
702
+ Module["calledRun"] = true;
845703
if (ABORT) return;
846704
initRuntime();
847
- readyPromiseResolve(Module);
705
+ readyPromiseResolve?.(Module);
848706
Module["onRuntimeInitialized"]?.();
849707
postRun();
850708
}
851709
if (Module["setStatus"]) {
852710
Module["setStatus"]("Running...");
@@ -857,31 +715,43 @@
857715
} else {
858716
doRun();
859717
}
860718
}
861719
862
-if (Module["preInit"]) {
863
- if (typeof Module["preInit"] == "function") Module["preInit"] = [ Module["preInit"] ];
864
- while (Module["preInit"].length > 0) {
865
- Module["preInit"].pop()();
866
- }
867
-}
720
+var wasmExports;
721
+
722
+// In modularize mode the generated code is within a factory function so we
723
+// can use await here (since it's not top-level-await).
724
+wasmExports = await (createWasm());
868725
869726
run();
870727
871728
// end include: postamble.js
872729
// include: postamble_modularize.js
873730
// In MODULARIZE mode we wrap the generated code in a factory function
874731
// and return either the Module itself, or a promise of the module.
875732
// We assign to the `moduleRtn` global here and configure closure to see
876
-// this as and extern so it won't get minified.
877
-moduleRtn = readyPromise;
878
-
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);
733
+// this as an extern so it won't get minified.
734
+if (runtimeInitialized) {
735
+ moduleRtn = Module;
736
+} else {
737
+ // Set up the promise that indicates the Module is initialized
738
+ moduleRtn = new Promise((resolve, reject) => {
739
+ readyPromiseResolve = resolve;
740
+ readyPromiseReject = reject;
741
+ });
742
+}
743
+
744
+
745
+ return moduleRtn;
746
+ };
747
+})();
748
+
749
+// Export using a UMD style export, or ES6 exports if selected
750
+if (typeof exports === 'object' && typeof module === 'object') {
751
+ module.exports = initPikchrModule;
752
+ // This default export looks redundant, but it allows TS to import this
753
+ // commonjs style module.
754
+ module.exports.default = initPikchrModule;
755
+} else if (typeof define === 'function' && define['amd'])
756
+ define([], () => initPikchrModule);
757
+
888758
--- extsrc/pikchr.js
+++ extsrc/pikchr.js
@@ -1,14 +1,21 @@
 
 
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:
12 // 1. Not defined. We create it here
13 // 2. A function parameter, function(moduleArg) => Promise<Module>
14 // 3. pre-run appended it, var Module = {}; ..generated code..
@@ -20,33 +27,18 @@
20 // after the generated code, you will need to define var Module = {};
21 // before the code. Then that object will be used in the code, and you
22 // can continue to use Module afterwards as well.
23 var Module = moduleArg;
24
25 // Set up the promise that indicates the Module is initialized
26 var readyPromiseResolve, readyPromiseReject;
27
28 var readyPromise = new Promise((resolve, reject) => {
29 readyPromiseResolve = resolve;
30 readyPromiseReject = reject;
31 });
32
33 // Determine the runtime environment we are in. You can customize this by
34 // setting the ENVIRONMENT setting at compile time (see settings.js).
35 var ENVIRONMENT_IS_WEB = true;
36
37 var ENVIRONMENT_IS_WORKER = false;
38
39 // --pre-jses are emitted after the Module integration code, so that they can
40 // refer to Module (if they choose; they can also define Module)
41 // Sometimes an existing Module object exists with properties
42 // meant to overwrite the default module functionality. Here
43 // we collect those properties and reapply _after_ we configure
44 // the current environment's defaults to avoid having to be so
45 // defensive during initialization.
46 var moduleOverrides = Object.assign({}, Module);
47
48 var arguments_ = [];
49
50 var thisProgram = "./this.program";
51
52 var quit_ = (status, toThrow) => {
@@ -68,67 +60,31 @@
68
69 // Note that this includes Node.js workers when relevant (pthreads is enabled).
70 // Node.js workers are detected as a combination of ENVIRONMENT_IS_WORKER and
71 // ENVIRONMENT_IS_NODE.
72 if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
73 if (ENVIRONMENT_IS_WORKER) {
74 // Check worker, not web, since window could be polyfilled
75 scriptDirectory = self.location.href;
76 } else if (typeof document != "undefined" && document.currentScript) {
77 // web
78 scriptDirectory = document.currentScript.src;
79 }
80 // When MODULARIZE, this JS may be executed later, after document.currentScript
81 // is gone, so we saved it, and we use it here instead of any other info.
82 if (_scriptName) {
83 scriptDirectory = _scriptName;
84 }
85 // blob urls look like blob:http://site.com/etc/etc and we cannot infer anything from them.
86 // otherwise, slice off the final part of the url to find the script directory.
87 // if scriptDirectory does not contain a slash, lastIndexOf will return -1,
88 // and scriptDirectory will correctly be replaced with an empty string.
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
114 // Merge back in the overrides
115 Object.assign(Module, moduleOverrides);
116
117 // Free the object hierarchy contained in the overrides, this lets the GC
118 // reclaim data used.
119 moduleOverrides = null;
120
121 // Emit code to handle expected values on the Module object. This applies Module.x
122 // to the proper local x. This has two benefits: first, we only emit it if it is
123 // expected to arrive, and second, by using a local everywhere else that can be
124 // minified.
125 if (Module["arguments"]) arguments_ = Module["arguments"];
126
127 if (Module["thisProgram"]) thisProgram = Module["thisProgram"];
128
129 // perform assertions in shell.js after we set up out() and err(), as otherwise if an assertion fails it cannot print the message
130 // end include: shell.js
131 // include: preamble.js
132 // === Preamble library stuff ===
133 // Documentation for the public APIs defined in this file must be updated in:
134 // site/source/docs/api_reference/preamble.js.rst
@@ -135,130 +91,87 @@
135 // A prebuilt local version of the documentation is available at:
136 // site/build/text/docs/api_reference/preamble.js.txt
137 // You can also build docs locally as HTML or other formats in site/
138 // An online HTML version (which may be of a different version of Emscripten)
139 // is up at http://kripken.github.io/emscripten-site/docs/api_reference/preamble.js.html
140 var wasmBinary = Module["wasmBinary"];
141
142 // Wasm globals
143 var wasmMemory;
144
145 //========================================
146 // Runtime essentials
147 //========================================
148 // whether we are quitting the application. no code should run after this.
149 // set in exit() and abort()
150 var ABORT = false;
151
152 // set by exit() and abort(). Passed to 'onExit' handler.
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);
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++;
243 Module["monitorRunDependencies"]?.(runDependencies);
244 }
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 }
259 }
260 }
261
262 /** @param {string|number=} what */ function abort(what) {
263 Module["onAbort"]?.(what);
264 what = "Aborted(" + what + ")";
@@ -278,163 +191,154 @@
278 // Suppress closure compiler warning here. Closure compiler's builtin extern
279 // definition for WebAssembly.RuntimeError claims it takes no arguments even
280 // though it can.
281 // TODO(https://github.com/google/closure-compiler/pull/3913): Remove if/when upstream closure gets fixed.
282 /** @suppress {checkTypes} */ var e = new WebAssembly.RuntimeError(what);
283 readyPromiseReject(e);
284 // Throw the error whether or not MODULARIZE is set because abort is used
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-v2813665466.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 }
318 if (readBinary) {
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 {
367 "a": wasmImports
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");
388 // Prefer streaming instantiation if available.
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 = "*";
437 switch (type) {
438 case "i1":
439 return HEAP8[ptr];
440
@@ -446,11 +350,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":
@@ -462,17 +366,17 @@
462 default:
463 abort(`invalid type for getValue: ${type}`);
464 }
465 }
466
467 var noExitRuntime = Module["noExitRuntime"] || true;
468
469 /**
470 * @param {number} ptr
471 * @param {number} value
472 * @param {string} type
473 */ function setValue(ptr, value, type = "i8") {
474 if (type.endsWith("*")) type = "*";
475 switch (type) {
476 case "i1":
477 HEAP8[ptr] = value;
478 break;
@@ -488,11 +392,12 @@
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
@@ -511,85 +416,42 @@
511
512 var stackRestore = val => __emscripten_stack_restore(val);
513
514 var stackSave = () => _emscripten_stack_get_current();
515
516 var UTF8Decoder = typeof TextDecoder != "undefined" ? new TextDecoder : undefined;
517
518 /**
519 * Given a pointer 'idx' to a null-terminated UTF8-encoded string in the given
520 * array that contains uint8 values, returns a copy of that string as a
521 * Javascript String object.
522 * heapOrArray is either a regular array, or a JavaScript typed array view.
523 * @param {number=} idx
524 * @param {number=} maxBytesToRead
525 * @return {string}
526 */ var UTF8ArrayToString = (heapOrArray, idx = 0, maxBytesToRead = NaN) => {
527 var endIdx = idx + maxBytesToRead;
528 var endPtr = idx;
529 // TextDecoder needs to know the byte length in advance, it doesn't stop on
530 // null terminator by itself. Also, use the length info to avoid running tiny
531 // strings through TextDecoder, since .subarray() allocates garbage.
532 // (As a tiny code save trick, compare endPtr against endIdx using a negation,
533 // so that undefined/NaN means Infinity)
534 while (heapOrArray[endPtr] && !(endPtr >= endIdx)) ++endPtr;
535 if (endPtr - idx > 16 && heapOrArray.buffer && UTF8Decoder) {
536 return UTF8Decoder.decode(heapOrArray.subarray(idx, endPtr));
537 }
538 var str = "";
539 // If building with TextDecoder, we have already computed the string length
540 // above, so test loop end condition against that
541 while (idx < endPtr) {
542 // For UTF8 byte structure, see:
543 // http://en.wikipedia.org/wiki/UTF-8#Description
544 // https://www.ietf.org/rfc/rfc2279.txt
545 // https://tools.ietf.org/html/rfc3629
546 var u0 = heapOrArray[idx++];
547 if (!(u0 & 128)) {
548 str += String.fromCharCode(u0);
549 continue;
550 }
551 var u1 = heapOrArray[idx++] & 63;
552 if ((u0 & 224) == 192) {
553 str += String.fromCharCode(((u0 & 31) << 6) | u1);
554 continue;
555 }
556 var u2 = heapOrArray[idx++] & 63;
557 if ((u0 & 240) == 224) {
558 u0 = ((u0 & 15) << 12) | (u1 << 6) | u2;
559 } else {
560 u0 = ((u0 & 7) << 18) | (u1 << 12) | (u2 << 6) | (heapOrArray[idx++] & 63);
561 }
562 if (u0 < 65536) {
563 str += String.fromCharCode(u0);
564 } else {
565 var ch = u0 - 65536;
566 str += String.fromCharCode(55296 | (ch >> 10), 56320 | (ch & 1023));
567 }
568 }
569 return str;
570 };
571
572 /**
573 * Given a pointer 'ptr' to a null-terminated UTF8-encoded string in the
574 * emscripten HEAP, returns a copy of that string as a Javascript String object.
575 *
576 * @param {number} ptr
577 * @param {number=} maxBytesToRead - An optional length that specifies the
578 * maximum number of bytes to read. You can omit this parameter to scan the
579 * string until the first 0 byte. If maxBytesToRead is passed, and the string
580 * at [ptr, ptr+maxBytesToReadr[ contains a null byte in the middle, then the
581 * string will cut short at that byte index (i.e. maxBytesToRead will not
582 * produce a string of exact length [ptr, ptr+maxBytesToRead[) N.B. mixing
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
@@ -611,11 +473,11 @@
611 ABORT = true;
612 }
613 quit_(code, new ExitStatus(code));
614 };
615
616 /** @suppress {duplicate } */ /** @param {boolean|number=} implicit */ var exitJS = (status, implicit) => {
617 EXITSTATUS = status;
618 _proc_exit(status);
619 };
620
621 var _exit = exitJS;
@@ -659,23 +521,14 @@
659 if (!(maxBytesToWrite > 0)) return 0;
660 var startIdx = outIdx;
661 var endIdx = outIdx + maxBytesToWrite - 1;
662 // -1 for string null terminator.
663 for (var i = 0; i < str.length; ++i) {
664 // Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code
665 // unit, not a Unicode code point of the character! So decode
666 // UTF16->UTF32->UTF8.
667 // See http://unicode.org/faq/utf_bom.html#utf16-3
668 // For UTF8 byte structure, see http://en.wikipedia.org/wiki/UTF-8#Description
669 // and https://www.ietf.org/rfc/rfc2279.txt
670 // and https://tools.ietf.org/html/rfc3629
671 var u = str.charCodeAt(i);
672 // possibly a lead surrogate
673 if (u >= 55296 && u <= 57343) {
674 var u1 = str.charCodeAt(++i);
675 u = 65536 + ((u & 1023) << 10) | (u1 & 1023);
676 }
677 if (u <= 127) {
678 if (outIdx >= endIdx) break;
679 heap[outIdx++] = u;
680 } else if (u <= 2047) {
681 if (outIdx + 1 >= endIdx) break;
@@ -690,10 +543,13 @@
690 if (outIdx + 3 >= endIdx) break;
691 heap[outIdx++] = 240 | (u >> 18);
692 heap[outIdx++] = 128 | ((u >> 12) & 63);
693 heap[outIdx++] = 128 | ((u >> 6) & 63);
694 heap[outIdx++] = 128 | (u & 63);
 
 
 
695 }
696 }
697 // Null-terminate the pointer to the buffer.
698 heap[outIdx] = 0;
699 return outIdx - startIdx;
@@ -709,15 +565,15 @@
709 stringToUTF8(str, ret, size);
710 return ret;
711 };
712
713 /**
714 * @param {string|null=} returnType
715 * @param {Array=} argTypes
716 * @param {Arguments|Array=} args
717 * @param {Object=} opts
718 */ var ccall = (ident, returnType, argTypes, args, opts) => {
719 // For fast lookup of conversion functions
720 var toC = {
721 "string": str => {
722 var ret = 0;
723 if (str !== null && str !== undefined && str !== 0) {
@@ -761,14 +617,14 @@
761 ret = onDone(ret);
762 return ret;
763 };
764
765 /**
766 * @param {string=} returnType
767 * @param {Array=} argTypes
768 * @param {Object=} opts
769 */ var cwrap = (ident, returnType, argTypes, opts) => {
770 // When the function takes numbers and returns a number, we can just return
771 // the original function
772 var numericArgs = !argTypes || argTypes.every(type => type === "number" || type === "boolean");
773 var numericRet = returnType !== "string";
774 if (numericRet && numericArgs && !opts) {
@@ -775,32 +631,32 @@
775 return getCFunc(ident);
776 }
777 return (...args) => ccall(ident, returnType, argTypes, args, opts);
778 };
779
780 var wasmImports = {
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
804 Module["stackRestore"] = stackRestore;
805
806 Module["stackAlloc"] = stackAlloc;
@@ -811,42 +667,44 @@
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();
850 }
851 if (Module["setStatus"]) {
852 Module["setStatus"]("Running...");
@@ -857,31 +715,43 @@
857 } else {
858 doRun();
859 }
860 }
861
862 if (Module["preInit"]) {
863 if (typeof Module["preInit"] == "function") Module["preInit"] = [ Module["preInit"] ];
864 while (Module["preInit"].length > 0) {
865 Module["preInit"].pop()();
866 }
867 }
868
869 run();
870
871 // end include: postamble.js
872 // include: postamble_modularize.js
873 // In MODULARIZE mode we wrap the generated code in a factory function
874 // and return either the Module itself, or a promise of the module.
875 // We assign to the `moduleRtn` global here and configure closure to see
876 // this as and extern so it won't get minified.
877 moduleRtn = readyPromise;
878
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.js
+++ extsrc/pikchr.js
@@ -1,14 +1,21 @@
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 // Single threaded MINIMAL_RUNTIME programs do not need access to
5 // document.currentScript, so a simple export declaration is enough.
6 var initPikchrModule = (() => {
7 // When MODULARIZE this JS may be executed later,
8 // after document.currentScript is gone, so we save it.
9 // In EXPORT_ES6 mode we can just use 'import.meta.url'.
10 var _scriptName = globalThis.document?.currentScript?.src;
11 return async function(moduleArg = {}) {
12 var moduleRtn;
13
14 // include: shell.js
15 // include: minimum_runtime_check.js
16 // end include: minimum_runtime_check.js
17 // The Module object: Our interface to the outside world. We import
18 // and export values on it. There are various ways Module can be used:
19 // 1. Not defined. We create it here
20 // 2. A function parameter, function(moduleArg) => Promise<Module>
21 // 3. pre-run appended it, var Module = {}; ..generated code..
@@ -20,33 +27,18 @@
27 // after the generated code, you will need to define var Module = {};
28 // before the code. Then that object will be used in the code, and you
29 // can continue to use Module afterwards as well.
30 var Module = moduleArg;
31
 
 
 
 
 
 
 
 
32 // Determine the runtime environment we are in. You can customize this by
33 // setting the ENVIRONMENT setting at compile time (see settings.js).
34 var ENVIRONMENT_IS_WEB = true;
35
36 var ENVIRONMENT_IS_WORKER = false;
37
38 // --pre-jses are emitted after the Module integration code, so that they can
39 // refer to Module (if they choose; they can also define Module)
 
 
 
 
 
 
 
40 var arguments_ = [];
41
42 var thisProgram = "./this.program";
43
44 var quit_ = (status, toThrow) => {
@@ -68,67 +60,31 @@
60
61 // Note that this includes Node.js workers when relevant (pthreads is enabled).
62 // Node.js workers are detected as a combination of ENVIRONMENT_IS_WORKER and
63 // ENVIRONMENT_IS_NODE.
64 if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
65 try {
66 scriptDirectory = new URL(".", _scriptName).href;
67 } catch {}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68 {
69 // include: web_or_worker_shell_read.js
70 readAsync = async url => {
71 var response = await fetch(url, {
72 credentials: "same-origin"
73 });
74 if (response.ok) {
75 return response.arrayBuffer();
76 }
77 throw new Error(response.status + " : " + response.url);
78 };
79 }
80 } else {}
81
82 var out = console.log.bind(console);
83
84 var err = console.error.bind(console);
85
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86 // end include: shell.js
87 // include: preamble.js
88 // === Preamble library stuff ===
89 // Documentation for the public APIs defined in this file must be updated in:
90 // site/source/docs/api_reference/preamble.js.rst
@@ -135,130 +91,87 @@
91 // A prebuilt local version of the documentation is available at:
92 // site/build/text/docs/api_reference/preamble.js.txt
93 // You can also build docs locally as HTML or other formats in site/
94 // An online HTML version (which may be of a different version of Emscripten)
95 // is up at http://kripken.github.io/emscripten-site/docs/api_reference/preamble.js.html
96 var wasmBinary;
97
98 // Wasm globals
 
 
99 //========================================
100 // Runtime essentials
101 //========================================
102 // whether we are quitting the application. no code should run after this.
103 // set in exit() and abort()
104 var ABORT = false;
105
106 // set by exit() and abort(). Passed to 'onExit' handler.
107 // NOTE: This is also used as the process return code in shell environments
108 // but only when noExitRuntime is false.
109 var EXITSTATUS;
110
111 // include: runtime_common.js
112 // include: runtime_stack_check.js
113 // end include: runtime_stack_check.js
114 // include: runtime_exceptions.js
115 // end include: runtime_exceptions.js
116 // include: runtime_debug.js
117 // end include: runtime_debug.js
118 var readyPromiseResolve, readyPromiseReject;
119
120 // Memory management
121 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;
122
123 // BigInt64Array type is not correctly defined in closure
124 var /** not-@type {!BigInt64Array} */ HEAP64, /* BigUint64Array type is not correctly defined in closure
125 /** not-@type {!BigUint64Array} */ HEAPU64;
126
127 var runtimeInitialized = false;
128
129 function updateMemoryViews() {
130 var b = wasmMemory.buffer;
131 HEAP8 = new Int8Array(b);
132 HEAP16 = new Int16Array(b);
133 HEAPU8 = new Uint8Array(b);
134 HEAPU16 = new Uint16Array(b);
135 HEAP32 = new Int32Array(b);
136 HEAPU32 = new Uint32Array(b);
137 HEAPF32 = new Float32Array(b);
138 HEAPF64 = new Float64Array(b);
139 HEAP64 = new BigInt64Array(b);
140 HEAPU64 = new BigUint64Array(b);
141 }
142
143 // include: memoryprofiler.js
144 // end include: memoryprofiler.js
145 // end include: runtime_common.js
 
 
 
 
 
 
 
 
 
146 function preRun() {
147 if (Module["preRun"]) {
148 if (typeof Module["preRun"] == "function") Module["preRun"] = [ Module["preRun"] ];
149 while (Module["preRun"].length) {
150 addOnPreRun(Module["preRun"].shift());
151 }
152 }
153 // Begin ATPRERUNS hooks
154 callRuntimeCallbacks(onPreRuns);
155 }
156
157 function initRuntime() {
158 runtimeInitialized = true;
159 // No ATINITS hooks
160 wasmExports["e"]();
161 }
162
163 function postRun() {
164 // PThreads reuse the runtime from the main thread.
165 if (Module["postRun"]) {
166 if (typeof Module["postRun"] == "function") Module["postRun"] = [ Module["postRun"] ];
167 while (Module["postRun"].length) {
168 addOnPostRun(Module["postRun"].shift());
169 }
170 }
171 // Begin ATPOSTRUNS hooks
172 callRuntimeCallbacks(onPostRuns);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
173 }
174
175 /** @param {string|number=} what */ function abort(what) {
176 Module["onAbort"]?.(what);
177 what = "Aborted(" + what + ")";
@@ -278,163 +191,154 @@
191 // Suppress closure compiler warning here. Closure compiler's builtin extern
192 // definition for WebAssembly.RuntimeError claims it takes no arguments even
193 // though it can.
194 // TODO(https://github.com/google/closure-compiler/pull/3913): Remove if/when upstream closure gets fixed.
195 /** @suppress {checkTypes} */ var e = new WebAssembly.RuntimeError(what);
196 readyPromiseReject?.(e);
197 // Throw the error whether or not MODULARIZE is set because abort is used
198 // in code paths apart from instantiation where an exception is expected
199 // to be thrown when abort is called.
200 throw e;
201 }
202
203 var wasmBinaryFile;
204
 
 
 
 
 
 
 
 
 
 
 
 
205 function findWasmBinary() {
206 return locateFile("pikchr-v8806526039.wasm");
207 }
 
 
 
 
 
 
208
209 function getBinarySync(file) {
210 if (file == wasmBinaryFile && wasmBinary) {
211 return new Uint8Array(wasmBinary);
212 }
213 if (readBinary) {
214 return readBinary(file);
215 }
216 // Throwing a plain string here, even though it not normally advisable since
217 // this gets turning into an `abort` in instantiateArrayBuffer.
218 throw "both async and sync fetching of the wasm failed";
219 }
220
221 async function getWasmBinary(binaryFile) {
222 // If we don't have the binary yet, load it asynchronously using readAsync.
223 if (!wasmBinary) {
224 // Fetch the binary using readAsync
225 try {
226 var response = await readAsync(binaryFile);
227 return new Uint8Array(response);
228 } catch {}
229 }
230 // Otherwise, getBinarySync should be able to get it synchronously
231 return getBinarySync(binaryFile);
232 }
233
234 async function instantiateArrayBuffer(binaryFile, imports) {
235 try {
236 var binary = await getWasmBinary(binaryFile);
237 var instance = await WebAssembly.instantiate(binary, imports);
238 return instance;
239 } catch (reason) {
240 err(`failed to asynchronously prepare wasm: ${reason}`);
241 abort(reason);
242 }
243 }
244
245 async function instantiateAsync(binary, binaryFile, imports) {
246 if (!binary) {
247 try {
248 var response = fetch(binaryFile, {
249 credentials: "same-origin"
250 });
251 var instantiationResult = await WebAssembly.instantiateStreaming(response, imports);
252 return instantiationResult;
253 } catch (reason) {
254 // We expect the most common failure cause to be a bad MIME type for the binary,
255 // in which case falling back to ArrayBuffer instantiation should work.
256 err(`wasm streaming compile failed: ${reason}`);
257 err("falling back to ArrayBuffer instantiation");
258 }
259 }
260 return instantiateArrayBuffer(binaryFile, imports);
 
 
 
 
261 }
262
263 function getWasmImports() {
264 // prepare imports
265 var imports = {
266 "a": wasmImports
267 };
268 return imports;
269 }
270
271 // Create the wasm instance.
272 // Receives the wasm imports, returns the exports.
273 async function createWasm() {
 
274 // Load the wasm module and create an instance of using native support in the JS engine.
275 // handle a generated wasm instance, receiving its exports and
276 // performing other necessary setup
277 /** @param {WebAssembly.Module=} module*/ function receiveInstance(instance, module) {
278 wasmExports = instance.exports;
279 assignWasmExports(wasmExports);
280 updateMemoryViews();
 
 
281 return wasmExports;
282 }
 
 
283 // Prefer streaming instantiation if available.
284 function receiveInstantiationResult(result) {
285 // 'result' is a ResultObject object which has both the module and instance.
286 // receiveInstance() will swap in the exports (to Module.asm) so they can be called
287 // 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.
288 // When the regression is fixed, can restore the above PTHREADS-enabled path.
289 return receiveInstance(result["instance"]);
290 }
291 var info = getWasmImports();
292 // User shell pages can write their own Module.instantiateWasm = function(imports, successCallback) callback
293 // to manually instantiate the Wasm module themselves. This allows pages to
294 // run the instantiation parallel to any other async startup actions they are
295 // performing.
296 // Also pthreads and wasm workers initialize the wasm instance through this
297 // path.
298 if (Module["instantiateWasm"]) {
299 return new Promise((resolve, reject) => {
300 Module["instantiateWasm"](info, (inst, mod) => {
301 resolve(receiveInstance(inst, mod));
302 });
303 });
 
 
304 }
305 wasmBinaryFile ??= findWasmBinary();
306 var result = await instantiateAsync(wasmBinary, wasmBinaryFile, info);
307 var exports = receiveInstantiationResult(result);
308 return exports;
309 }
310
 
 
 
311 // end include: preamble.js
312 // Begin JS library code
313 class ExitStatus {
314 name="ExitStatus";
315 constructor(status) {
316 this.message = `Program terminated with exit(${status})`;
317 this.status = status;
318 }
319 }
320
321 var callRuntimeCallbacks = callbacks => {
322 while (callbacks.length > 0) {
323 // Pass the module as the first argument.
324 callbacks.shift()(Module);
325 }
326 };
327
328 var onPostRuns = [];
329
330 var addOnPostRun = cb => onPostRuns.push(cb);
331
332 var onPreRuns = [];
333
334 var addOnPreRun = cb => onPreRuns.push(cb);
335
336 /**
337 * @param {number} ptr
338 * @param {string} type
339 */ function getValue(ptr, type = "i8") {
340 if (type.endsWith("*")) type = "*";
341 switch (type) {
342 case "i1":
343 return HEAP8[ptr];
344
@@ -446,11 +350,11 @@
350
351 case "i32":
352 return HEAP32[((ptr) >> 2)];
353
354 case "i64":
355 return HEAP64[((ptr) >> 3)];
356
357 case "float":
358 return HEAPF32[((ptr) >> 2)];
359
360 case "double":
@@ -462,17 +366,17 @@
366 default:
367 abort(`invalid type for getValue: ${type}`);
368 }
369 }
370
371 var noExitRuntime = true;
372
373 /**
374 * @param {number} ptr
375 * @param {number} value
376 * @param {string} type
377 */ function setValue(ptr, value, type = "i8") {
378 if (type.endsWith("*")) type = "*";
379 switch (type) {
380 case "i1":
381 HEAP8[ptr] = value;
382 break;
@@ -488,11 +392,12 @@
392 case "i32":
393 HEAP32[((ptr) >> 2)] = value;
394 break;
395
396 case "i64":
397 HEAP64[((ptr) >> 3)] = BigInt(value);
398 break;
399
400 case "float":
401 HEAPF32[((ptr) >> 2)] = value;
402 break;
403
@@ -511,85 +416,42 @@
416
417 var stackRestore = val => __emscripten_stack_restore(val);
418
419 var stackSave = () => _emscripten_stack_get_current();
420
421 var UTF8Decoder = new TextDecoder;
422
423 var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
424 var maxIdx = idx + maxBytesToRead;
425 if (ignoreNul) return maxIdx;
426 // TextDecoder needs to know the byte length in advance, it doesn't stop on
427 // null terminator by itself.
428 // As a tiny code save trick, compare idx against maxIdx using a negation,
429 // so that maxBytesToRead=undefined/NaN means Infinity.
430 while (heapOrArray[idx] && !(idx >= maxIdx)) ++idx;
431 return idx;
432 };
433
434 /**
435 * Given a pointer 'ptr' to a null-terminated UTF8-encoded string in the
436 * emscripten HEAP, returns a copy of that string as a Javascript String object.
437 *
438 * @param {number} ptr
439 * @param {number=} maxBytesToRead - An optional length that specifies the
440 * maximum number of bytes to read. You can omit this parameter to scan the
441 * string until the first 0 byte. If maxBytesToRead is passed, and the string
442 * at [ptr, ptr+maxBytesToReadr[ contains a null byte in the middle, then the
443 * string will cut short at that byte index.
444 * @param {boolean=} ignoreNul - If true, the function will not stop on a NUL character.
445 * @return {string}
446 */ var UTF8ToString = (ptr, maxBytesToRead, ignoreNul) => {
447 if (!ptr) return "";
448 var end = findStringEnd(HEAPU8, ptr, maxBytesToRead, ignoreNul);
449 return UTF8Decoder.decode(HEAPU8.subarray(ptr, end));
450 };
451
452 var ___assert_fail = (condition, filename, line, func) => abort(`Assertion failed: ${UTF8ToString(condition)}, at: ` + [ filename ? UTF8ToString(filename) : "unknown filename", line, func ? UTF8ToString(func) : "unknown function" ]);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
453
454 var abortOnCannotGrowMemory = requestedSize => {
455 abort("OOM");
456 };
457
@@ -611,11 +473,11 @@
473 ABORT = true;
474 }
475 quit_(code, new ExitStatus(code));
476 };
477
478 /** @param {boolean|number=} implicit */ var exitJS = (status, implicit) => {
479 EXITSTATUS = status;
480 _proc_exit(status);
481 };
482
483 var _exit = exitJS;
@@ -659,23 +521,14 @@
521 if (!(maxBytesToWrite > 0)) return 0;
522 var startIdx = outIdx;
523 var endIdx = outIdx + maxBytesToWrite - 1;
524 // -1 for string null terminator.
525 for (var i = 0; i < str.length; ++i) {
 
 
 
 
526 // For UTF8 byte structure, see http://en.wikipedia.org/wiki/UTF-8#Description
527 // and https://www.ietf.org/rfc/rfc2279.txt
528 // and https://tools.ietf.org/html/rfc3629
529 var u = str.codePointAt(i);
 
 
 
 
 
530 if (u <= 127) {
531 if (outIdx >= endIdx) break;
532 heap[outIdx++] = u;
533 } else if (u <= 2047) {
534 if (outIdx + 1 >= endIdx) break;
@@ -690,10 +543,13 @@
543 if (outIdx + 3 >= endIdx) break;
544 heap[outIdx++] = 240 | (u >> 18);
545 heap[outIdx++] = 128 | ((u >> 12) & 63);
546 heap[outIdx++] = 128 | ((u >> 6) & 63);
547 heap[outIdx++] = 128 | (u & 63);
548 // Gotcha: if codePoint is over 0xFFFF, it is represented as a surrogate pair in UTF-16.
549 // We need to manually skip over the second code unit for correct iteration.
550 i++;
551 }
552 }
553 // Null-terminate the pointer to the buffer.
554 heap[outIdx] = 0;
555 return outIdx - startIdx;
@@ -709,15 +565,15 @@
565 stringToUTF8(str, ret, size);
566 return ret;
567 };
568
569 /**
570 * @param {string|null=} returnType
571 * @param {Array=} argTypes
572 * @param {Array=} args
573 * @param {Object=} opts
574 */ var ccall = (ident, returnType, argTypes, args, opts) => {
575 // For fast lookup of conversion functions
576 var toC = {
577 "string": str => {
578 var ret = 0;
579 if (str !== null && str !== undefined && str !== 0) {
@@ -761,14 +617,14 @@
617 ret = onDone(ret);
618 return ret;
619 };
620
621 /**
622 * @param {string=} returnType
623 * @param {Array=} argTypes
624 * @param {Object=} opts
625 */ var cwrap = (ident, returnType, argTypes, opts) => {
626 // When the function takes numbers and returns a number, we can just return
627 // the original function
628 var numericArgs = !argTypes || argTypes.every(type => type === "number" || type === "boolean");
629 var numericRet = returnType !== "string";
630 if (numericRet && numericArgs && !opts) {
@@ -775,32 +631,32 @@
631 return getCFunc(ident);
632 }
633 return (...args) => ccall(ident, returnType, argTypes, args, opts);
634 };
635
636 // End JS library code
637 // include: postlibrary.js
638 // This file is included after the automatically-generated JS library code
639 // but before the wasm module is created.
640 {
641 // Begin ATMODULES hooks
642 if (Module["noExitRuntime"]) noExitRuntime = Module["noExitRuntime"];
643 if (Module["print"]) out = Module["print"];
644 if (Module["printErr"]) err = Module["printErr"];
645 if (Module["wasmBinary"]) wasmBinary = Module["wasmBinary"];
646 // End ATMODULES hooks
647 if (Module["arguments"]) arguments_ = Module["arguments"];
648 if (Module["thisProgram"]) thisProgram = Module["thisProgram"];
649 if (Module["preInit"]) {
650 if (typeof Module["preInit"] == "function") Module["preInit"] = [ Module["preInit"] ];
651 while (Module["preInit"].length > 0) {
652 Module["preInit"].shift()();
653 }
654 }
655 }
656
657 // Begin runtime exports
658 Module["stackSave"] = stackSave;
659
660 Module["stackRestore"] = stackRestore;
661
662 Module["stackAlloc"] = stackAlloc;
@@ -811,42 +667,44 @@
667
668 Module["setValue"] = setValue;
669
670 Module["getValue"] = getValue;
671
672 // End runtime exports
673 // Begin JS library exports
674 // End JS library exports
675 // end include: postlibrary.js
676 // Imports from the Wasm binary.
677 var _pikchr_version, _pikchr, __emscripten_stack_restore, __emscripten_stack_alloc, _emscripten_stack_get_current, memory, __indirect_function_table, wasmMemory;
678
679 function assignWasmExports(wasmExports) {
680 _pikchr_version = Module["_pikchr_version"] = wasmExports["f"];
681 _pikchr = Module["_pikchr"] = wasmExports["g"];
682 __emscripten_stack_restore = wasmExports["h"];
683 __emscripten_stack_alloc = wasmExports["i"];
684 _emscripten_stack_get_current = wasmExports["j"];
685 memory = wasmMemory = wasmExports["d"];
686 __indirect_function_table = wasmExports["__indirect_function_table"];
687 }
688
689 var wasmImports = {
690 /** @export */ a: ___assert_fail,
691 /** @export */ b: _emscripten_resize_heap,
692 /** @export */ c: _exit
693 };
694
695 // include: postamble.js
696 // === Auto-generated postamble setup entry stuff ===
697 function run() {
698 preRun();
 
 
 
 
 
 
 
 
 
 
699 function doRun() {
700 // run may have just been called through dependencies being fulfilled just in this very frame,
701 // or while the async setStatus time below was happening
702 Module["calledRun"] = true;
 
 
703 if (ABORT) return;
704 initRuntime();
705 readyPromiseResolve?.(Module);
706 Module["onRuntimeInitialized"]?.();
707 postRun();
708 }
709 if (Module["setStatus"]) {
710 Module["setStatus"]("Running...");
@@ -857,31 +715,43 @@
715 } else {
716 doRun();
717 }
718 }
719
720 var wasmExports;
721
722 // In modularize mode the generated code is within a factory function so we
723 // can use await here (since it's not top-level-await).
724 wasmExports = await (createWasm());
 
725
726 run();
727
728 // end include: postamble.js
729 // include: postamble_modularize.js
730 // In MODULARIZE mode we wrap the generated code in a factory function
731 // and return either the Module itself, or a promise of the module.
732 // We assign to the `moduleRtn` global here and configure closure to see
733 // this as an extern so it won't get minified.
734 if (runtimeInitialized) {
735 moduleRtn = Module;
736 } else {
737 // Set up the promise that indicates the Module is initialized
738 moduleRtn = new Promise((resolve, reject) => {
739 readyPromiseResolve = resolve;
740 readyPromiseReject = reject;
741 });
742 }
743
744
745 return moduleRtn;
746 };
747 })();
748
749 // Export using a UMD style export, or ES6 exports if selected
750 if (typeof exports === 'object' && typeof module === 'object') {
751 module.exports = initPikchrModule;
752 // This default export looks redundant, but it allows TS to import this
753 // commonjs style module.
754 module.exports.default = initPikchrModule;
755 } else if (typeof define === 'function' && define['amd'])
756 define([], () => initPikchrModule);
757
758
--- 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