Fossil SCM

Merge the latest trunk enhancements into the fts5-chat-search branch.

drh 2024-07-02 11:10 fts5-chat-search merge
Commit b35b293defa64846829627bb22093a2a6f82aa55416866e4c6df927925d44f57
+6 -5
--- extsrc/pikchr.c
+++ extsrc/pikchr.c
@@ -267,11 +267,11 @@
267267
268268
/* Extra token types not generated by LEMON but needed by the
269269
** tokenizer
270270
*/
271271
#define T_PARAMETER 253 /* $1, $2, ..., $9 */
272
-#define T_WHITESPACE 254 /* Whitespace of comments */
272
+#define T_WHITESPACE 254 /* Whitespace or comments */
273273
#define T_ERROR 255 /* Any text that is not a valid token */
274274
275275
/* Directions of movement */
276276
#define DIR_RIGHT 0
277277
#define DIR_DOWN 1
@@ -6122,11 +6122,11 @@
61226122
return;
61236123
}
61246124
pObj->mProp |= A_AT;
61256125
pObj->eWith = pEdge ? pEdge->eEdge : CP_C;
61266126
if( pObj->eWith>=CP_END ){
6127
- int dir = pObj->eWith==CP_END ? pObj->outDir : pObj->inDir;
6127
+ int dir = pObj->eWith==CP_END ? pObj->outDir : (pObj->inDir+2)%4;
61286128
pObj->eWith = eDirToCp[dir];
61296129
}
61306130
pObj->with = *pAt;
61316131
}
61326132
@@ -7436,11 +7436,11 @@
74367436
}
74377437
case ' ':
74387438
case '\t':
74397439
case '\f':
74407440
case '\r': {
7441
- for(i=1; (c = z[i])==' ' || c=='\t' || c=='\r' || c=='\t'; i++){}
7441
+ for(i=1; (c = z[i])==' ' || c=='\t' || c=='\r' || c=='\f'; i++){}
74427442
pToken->eType = T_WHITESPACE;
74437443
return i;
74447444
}
74457445
case '#': {
74467446
for(i=1; (c = z[i])!=0 && c!='\n'; i++){}
@@ -7999,10 +7999,11 @@
79997999
fprintf(stderr, "usage: %s [OPTIONS] FILE ...\n", argv0);
80008000
fprintf(stderr,
80018001
"Convert Pikchr input files into SVG. Filename \"-\" means stdin.\n"
80028002
"All output goes to stdout.\n"
80038003
"Options:\n"
8004
+ " --dark-mode Generate \"dark mode\" output\n"
80048005
" --dont-stop Process all files even if earlier files have errors\n"
80058006
" --svg-only Emit raw SVG without the HTML wrapper\n"
80068007
);
80078008
exit(1);
80088009
}
@@ -8137,11 +8138,11 @@
81378138
continue;
81388139
}
81398140
zIn = readFile(argv[i]);
81408141
if( zIn==0 ) continue;
81418142
zOut = pikchr(zIn, "pikchr", mFlags, &w, &h);
8142
- if( w<0 ) exitCode = 1;
8143
+ if( w<0 && !bDontStop ) exitCode = 1;
81438144
if( zOut==0 ){
81448145
fprintf(stderr, "pikchr() returns NULL. Out of memory?\n");
81458146
if( !bDontStop ) exit(1);
81468147
}else if( bSvgOnly ){
81478148
printf("%s\n", zOut);
@@ -8240,6 +8241,6 @@
82408241
82418242
82428243
#endif /* PIKCHR_TCL */
82438244
82448245
8245
-#line 8270 "pikchr.c"
8246
+#line 8271 "pikchr.c"
82468247
--- extsrc/pikchr.c
+++ extsrc/pikchr.c
@@ -267,11 +267,11 @@
267
268 /* Extra token types not generated by LEMON but needed by the
269 ** tokenizer
270 */
271 #define T_PARAMETER 253 /* $1, $2, ..., $9 */
272 #define T_WHITESPACE 254 /* Whitespace of comments */
273 #define T_ERROR 255 /* Any text that is not a valid token */
274
275 /* Directions of movement */
276 #define DIR_RIGHT 0
277 #define DIR_DOWN 1
@@ -6122,11 +6122,11 @@
6122 return;
6123 }
6124 pObj->mProp |= A_AT;
6125 pObj->eWith = pEdge ? pEdge->eEdge : CP_C;
6126 if( pObj->eWith>=CP_END ){
6127 int dir = pObj->eWith==CP_END ? pObj->outDir : pObj->inDir;
6128 pObj->eWith = eDirToCp[dir];
6129 }
6130 pObj->with = *pAt;
6131 }
6132
@@ -7436,11 +7436,11 @@
7436 }
7437 case ' ':
7438 case '\t':
7439 case '\f':
7440 case '\r': {
7441 for(i=1; (c = z[i])==' ' || c=='\t' || c=='\r' || c=='\t'; i++){}
7442 pToken->eType = T_WHITESPACE;
7443 return i;
7444 }
7445 case '#': {
7446 for(i=1; (c = z[i])!=0 && c!='\n'; i++){}
@@ -7999,10 +7999,11 @@
7999 fprintf(stderr, "usage: %s [OPTIONS] FILE ...\n", argv0);
8000 fprintf(stderr,
8001 "Convert Pikchr input files into SVG. Filename \"-\" means stdin.\n"
8002 "All output goes to stdout.\n"
8003 "Options:\n"
 
8004 " --dont-stop Process all files even if earlier files have errors\n"
8005 " --svg-only Emit raw SVG without the HTML wrapper\n"
8006 );
8007 exit(1);
8008 }
@@ -8137,11 +8138,11 @@
8137 continue;
8138 }
8139 zIn = readFile(argv[i]);
8140 if( zIn==0 ) continue;
8141 zOut = pikchr(zIn, "pikchr", mFlags, &w, &h);
8142 if( w<0 ) exitCode = 1;
8143 if( zOut==0 ){
8144 fprintf(stderr, "pikchr() returns NULL. Out of memory?\n");
8145 if( !bDontStop ) exit(1);
8146 }else if( bSvgOnly ){
8147 printf("%s\n", zOut);
@@ -8240,6 +8241,6 @@
8240
8241
8242 #endif /* PIKCHR_TCL */
8243
8244
8245 #line 8270 "pikchr.c"
8246
--- extsrc/pikchr.c
+++ extsrc/pikchr.c
@@ -267,11 +267,11 @@
267
268 /* Extra token types not generated by LEMON but needed by the
269 ** tokenizer
270 */
271 #define T_PARAMETER 253 /* $1, $2, ..., $9 */
272 #define T_WHITESPACE 254 /* Whitespace or comments */
273 #define T_ERROR 255 /* Any text that is not a valid token */
274
275 /* Directions of movement */
276 #define DIR_RIGHT 0
277 #define DIR_DOWN 1
@@ -6122,11 +6122,11 @@
6122 return;
6123 }
6124 pObj->mProp |= A_AT;
6125 pObj->eWith = pEdge ? pEdge->eEdge : CP_C;
6126 if( pObj->eWith>=CP_END ){
6127 int dir = pObj->eWith==CP_END ? pObj->outDir : (pObj->inDir+2)%4;
6128 pObj->eWith = eDirToCp[dir];
6129 }
6130 pObj->with = *pAt;
6131 }
6132
@@ -7436,11 +7436,11 @@
7436 }
7437 case ' ':
7438 case '\t':
7439 case '\f':
7440 case '\r': {
7441 for(i=1; (c = z[i])==' ' || c=='\t' || c=='\r' || c=='\f'; i++){}
7442 pToken->eType = T_WHITESPACE;
7443 return i;
7444 }
7445 case '#': {
7446 for(i=1; (c = z[i])!=0 && c!='\n'; i++){}
@@ -7999,10 +7999,11 @@
7999 fprintf(stderr, "usage: %s [OPTIONS] FILE ...\n", argv0);
8000 fprintf(stderr,
8001 "Convert Pikchr input files into SVG. Filename \"-\" means stdin.\n"
8002 "All output goes to stdout.\n"
8003 "Options:\n"
8004 " --dark-mode Generate \"dark mode\" output\n"
8005 " --dont-stop Process all files even if earlier files have errors\n"
8006 " --svg-only Emit raw SVG without the HTML wrapper\n"
8007 );
8008 exit(1);
8009 }
@@ -8137,11 +8138,11 @@
8138 continue;
8139 }
8140 zIn = readFile(argv[i]);
8141 if( zIn==0 ) continue;
8142 zOut = pikchr(zIn, "pikchr", mFlags, &w, &h);
8143 if( w<0 && !bDontStop ) exitCode = 1;
8144 if( zOut==0 ){
8145 fprintf(stderr, "pikchr() returns NULL. Out of memory?\n");
8146 if( !bDontStop ) exit(1);
8147 }else if( bSvgOnly ){
8148 printf("%s\n", zOut);
@@ -8240,6 +8241,6 @@
8241
8242
8243 #endif /* PIKCHR_TCL */
8244
8245
8246 #line 8271 "pikchr.c"
8247
+384 -385
--- extsrc/pikchr.js
+++ extsrc/pikchr.js
@@ -1,17 +1,18 @@
11
22
var initPikchrModule = (() => {
33
var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;
44
55
return (
6
-function(moduleArg = {}) {
6
+function(config) {
7
+ var initPikchrModule = config || {};
78
8
-var Module = moduleArg;
9
+var Module = typeof initPikchrModule != "undefined" ? initPikchrModule : {};
910
1011
var readyPromiseResolve, readyPromiseReject;
1112
12
-Module["ready"] = new Promise((resolve, reject) => {
13
+Module["ready"] = new Promise(function(resolve, reject) {
1314
readyPromiseResolve = resolve;
1415
readyPromiseReject = reject;
1516
});
1617
1718
var moduleOverrides = Object.assign({}, Module);
@@ -35,11 +36,11 @@
3536
return Module["locateFile"](path, scriptDirectory);
3637
}
3738
return scriptDirectory + path;
3839
}
3940
40
-var read_, readAsync, readBinary;
41
+var read_, readAsync, readBinary, setWindowTitle;
4142
4243
if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
4344
if (ENVIRONMENT_IS_WORKER) {
4445
scriptDirectory = self.location.href;
4546
} else if (typeof document != "undefined" && document.currentScript) {
@@ -46,51 +47,52 @@
4647
scriptDirectory = document.currentScript.src;
4748
}
4849
if (_scriptDir) {
4950
scriptDirectory = _scriptDir;
5051
}
51
- if (scriptDirectory.startsWith("blob:")) {
52
- scriptDirectory = "";
52
+ if (scriptDirectory.indexOf("blob:") !== 0) {
53
+ scriptDirectory = scriptDirectory.substr(0, scriptDirectory.replace(/[?#].*/, "").lastIndexOf("/") + 1);
5354
} else {
54
- scriptDirectory = scriptDirectory.substr(0, scriptDirectory.replace(/[?#].*/, "").lastIndexOf("/") + 1);
55
+ scriptDirectory = "";
5556
}
5657
{
5758
read_ = url => {
58
- var xhr = new XMLHttpRequest;
59
+ var xhr = new XMLHttpRequest();
5960
xhr.open("GET", url, false);
6061
xhr.send(null);
6162
return xhr.responseText;
6263
};
6364
if (ENVIRONMENT_IS_WORKER) {
6465
readBinary = url => {
65
- var xhr = new XMLHttpRequest;
66
+ var xhr = new XMLHttpRequest();
6667
xhr.open("GET", url, false);
6768
xhr.responseType = "arraybuffer";
6869
xhr.send(null);
69
- return new Uint8Array(/** @type{!ArrayBuffer} */ (xhr.response));
70
+ return new Uint8Array(xhr.response);
7071
};
7172
}
7273
readAsync = (url, onload, onerror) => {
73
- var xhr = new XMLHttpRequest;
74
+ var xhr = new XMLHttpRequest();
7475
xhr.open("GET", url, true);
7576
xhr.responseType = "arraybuffer";
7677
xhr.onload = () => {
77
- if (xhr.status == 200 || (xhr.status == 0 && xhr.response)) {
78
+ if (xhr.status == 200 || xhr.status == 0 && xhr.response) {
7879
onload(xhr.response);
7980
return;
8081
}
8182
onerror();
8283
};
8384
xhr.onerror = onerror;
8485
xhr.send(null);
8586
};
8687
}
88
+ setWindowTitle = title => document.title = title;
8789
} else {}
8890
8991
var out = Module["print"] || console.log.bind(console);
9092
91
-var err = Module["printErr"] || console.error.bind(console);
93
+var err = Module["printErr"] || console.warn.bind(console);
9294
9395
Object.assign(Module, moduleOverrides);
9496
9597
moduleOverrides = null;
9698
@@ -102,10 +104,12 @@
102104
103105
var wasmBinary;
104106
105107
if (Module["wasmBinary"]) wasmBinary = Module["wasmBinary"];
106108
109
+var noExitRuntime = Module["noExitRuntime"] || true;
110
+
107111
if (typeof WebAssembly != "object") {
108112
abort("no native wasm support detected");
109113
}
110114
111115
var wasmMemory;
@@ -112,31 +116,118 @@
112116
113117
var ABORT = false;
114118
115119
var EXITSTATUS;
116120
117
-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;
121
+var UTF8Decoder = typeof TextDecoder != "undefined" ? new TextDecoder("utf8") : undefined;
122
+
123
+function UTF8ArrayToString(heapOrArray, idx, maxBytesToRead) {
124
+ var endIdx = idx + maxBytesToRead;
125
+ var endPtr = idx;
126
+ while (heapOrArray[endPtr] && !(endPtr >= endIdx)) ++endPtr;
127
+ if (endPtr - idx > 16 && heapOrArray.buffer && UTF8Decoder) {
128
+ return UTF8Decoder.decode(heapOrArray.subarray(idx, endPtr));
129
+ }
130
+ var str = "";
131
+ while (idx < endPtr) {
132
+ var u0 = heapOrArray[idx++];
133
+ if (!(u0 & 128)) {
134
+ str += String.fromCharCode(u0);
135
+ continue;
136
+ }
137
+ var u1 = heapOrArray[idx++] & 63;
138
+ if ((u0 & 224) == 192) {
139
+ str += String.fromCharCode((u0 & 31) << 6 | u1);
140
+ continue;
141
+ }
142
+ var u2 = heapOrArray[idx++] & 63;
143
+ if ((u0 & 240) == 224) {
144
+ u0 = (u0 & 15) << 12 | u1 << 6 | u2;
145
+ } else {
146
+ u0 = (u0 & 7) << 18 | u1 << 12 | u2 << 6 | heapOrArray[idx++] & 63;
147
+ }
148
+ if (u0 < 65536) {
149
+ str += String.fromCharCode(u0);
150
+ } else {
151
+ var ch = u0 - 65536;
152
+ str += String.fromCharCode(55296 | ch >> 10, 56320 | ch & 1023);
153
+ }
154
+ }
155
+ return str;
156
+}
157
+
158
+function UTF8ToString(ptr, maxBytesToRead) {
159
+ return ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead) : "";
160
+}
161
+
162
+function stringToUTF8Array(str, heap, outIdx, maxBytesToWrite) {
163
+ if (!(maxBytesToWrite > 0)) return 0;
164
+ var startIdx = outIdx;
165
+ var endIdx = outIdx + maxBytesToWrite - 1;
166
+ for (var i = 0; i < str.length; ++i) {
167
+ var u = str.charCodeAt(i);
168
+ if (u >= 55296 && u <= 57343) {
169
+ var u1 = str.charCodeAt(++i);
170
+ u = 65536 + ((u & 1023) << 10) | u1 & 1023;
171
+ }
172
+ if (u <= 127) {
173
+ if (outIdx >= endIdx) break;
174
+ heap[outIdx++] = u;
175
+ } else if (u <= 2047) {
176
+ if (outIdx + 1 >= endIdx) break;
177
+ heap[outIdx++] = 192 | u >> 6;
178
+ heap[outIdx++] = 128 | u & 63;
179
+ } else if (u <= 65535) {
180
+ if (outIdx + 2 >= endIdx) break;
181
+ heap[outIdx++] = 224 | u >> 12;
182
+ heap[outIdx++] = 128 | u >> 6 & 63;
183
+ heap[outIdx++] = 128 | u & 63;
184
+ } else {
185
+ if (outIdx + 3 >= endIdx) break;
186
+ heap[outIdx++] = 240 | u >> 18;
187
+ heap[outIdx++] = 128 | u >> 12 & 63;
188
+ heap[outIdx++] = 128 | u >> 6 & 63;
189
+ heap[outIdx++] = 128 | u & 63;
190
+ }
191
+ }
192
+ heap[outIdx] = 0;
193
+ return outIdx - startIdx;
194
+}
195
+
196
+function stringToUTF8(str, outPtr, maxBytesToWrite) {
197
+ return stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite);
198
+}
199
+
200
+var HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAPF64;
118201
119202
function updateMemoryViews() {
120203
var b = wasmMemory.buffer;
121204
Module["HEAP8"] = HEAP8 = new Int8Array(b);
122205
Module["HEAP16"] = HEAP16 = new Int16Array(b);
206
+ Module["HEAP32"] = HEAP32 = new Int32Array(b);
123207
Module["HEAPU8"] = HEAPU8 = new Uint8Array(b);
124208
Module["HEAPU16"] = HEAPU16 = new Uint16Array(b);
125
- Module["HEAP32"] = HEAP32 = new Int32Array(b);
126209
Module["HEAPU32"] = HEAPU32 = new Uint32Array(b);
127210
Module["HEAPF32"] = HEAPF32 = new Float32Array(b);
128211
Module["HEAPF64"] = HEAPF64 = new Float64Array(b);
129212
}
213
+
214
+var INITIAL_MEMORY = Module["INITIAL_MEMORY"] || 16777216;
215
+
216
+var wasmTable;
130217
131218
var __ATPRERUN__ = [];
132219
133220
var __ATINIT__ = [];
134221
135222
var __ATPOSTRUN__ = [];
136223
137224
var runtimeInitialized = false;
225
+
226
+function keepRuntimeAlive() {
227
+ return noExitRuntime;
228
+}
138229
139230
function preRun() {
140231
if (Module["preRun"]) {
141232
if (typeof Module["preRun"] == "function") Module["preRun"] = [ Module["preRun"] ];
142233
while (Module["preRun"].length) {
@@ -179,16 +270,20 @@
179270
180271
var dependenciesFulfilled = null;
181272
182273
function addRunDependency(id) {
183274
runDependencies++;
184
- Module["monitorRunDependencies"]?.(runDependencies);
275
+ if (Module["monitorRunDependencies"]) {
276
+ Module["monitorRunDependencies"](runDependencies);
277
+ }
185278
}
186279
187280
function removeRunDependency(id) {
188281
runDependencies--;
189
- Module["monitorRunDependencies"]?.(runDependencies);
282
+ if (Module["monitorRunDependencies"]) {
283
+ Module["monitorRunDependencies"](runDependencies);
284
+ }
190285
if (runDependencies == 0) {
191286
if (runDependencyWatcher !== null) {
192287
clearInterval(runDependencyWatcher);
193288
runDependencyWatcher = null;
194289
}
@@ -198,382 +293,278 @@
198293
callback();
199294
}
200295
}
201296
}
202297
203
-/** @param {string|number=} what */ function abort(what) {
204
- Module["onAbort"]?.(what);
298
+function abort(what) {
299
+ if (Module["onAbort"]) {
300
+ Module["onAbort"](what);
301
+ }
205302
what = "Aborted(" + what + ")";
206303
err(what);
207304
ABORT = true;
208305
EXITSTATUS = 1;
209306
what += ". Build with -sASSERTIONS for more info.";
210
- /** @suppress {checkTypes} */ var e = new WebAssembly.RuntimeError(what);
307
+ var e = new WebAssembly.RuntimeError(what);
211308
readyPromiseReject(e);
212309
throw e;
213310
}
214311
215312
var dataURIPrefix = "data:application/octet-stream;base64,";
216313
217
-/**
218
- * Indicates whether filename is a base64 data URI.
219
- * @noinline
220
- */ var isDataURI = filename => filename.startsWith(dataURIPrefix);
314
+function isDataURI(filename) {
315
+ return filename.startsWith(dataURIPrefix);
316
+}
221317
222318
var wasmBinaryFile;
223319
224320
wasmBinaryFile = "pikchr.wasm";
225321
226322
if (!isDataURI(wasmBinaryFile)) {
227323
wasmBinaryFile = locateFile(wasmBinaryFile);
228324
}
229325
230
-function getBinarySync(file) {
231
- if (file == wasmBinaryFile && wasmBinary) {
232
- return new Uint8Array(wasmBinary);
233
- }
234
- if (readBinary) {
235
- return readBinary(file);
236
- }
237
- throw "both async and sync fetching of the wasm failed";
238
-}
239
-
240
-function getBinaryPromise(binaryFile) {
241
- if (!wasmBinary && (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER)) {
242
- if (typeof fetch == "function") {
243
- return fetch(binaryFile, {
244
- credentials: "same-origin"
245
- }).then(response => {
246
- if (!response["ok"]) {
247
- throw `failed to load wasm binary file at '${binaryFile}'`;
248
- }
249
- return response["arrayBuffer"]();
250
- }).catch(() => getBinarySync(binaryFile));
251
- }
252
- }
253
- return Promise.resolve().then(() => getBinarySync(binaryFile));
254
-}
255
-
256
-function instantiateArrayBuffer(binaryFile, imports, receiver) {
257
- return getBinaryPromise(binaryFile).then(binary => WebAssembly.instantiate(binary, imports)).then(instance => instance).then(receiver, reason => {
258
- err(`failed to asynchronously prepare wasm: ${reason}`);
259
- abort(reason);
260
- });
261
-}
262
-
263
-function instantiateAsync(binary, binaryFile, imports, callback) {
264
- if (!binary && typeof WebAssembly.instantiateStreaming == "function" && !isDataURI(binaryFile) && typeof fetch == "function") {
265
- return fetch(binaryFile, {
266
- credentials: "same-origin"
267
- }).then(response => {
268
- /** @suppress {checkTypes} */ var result = WebAssembly.instantiateStreaming(response, imports);
269
- return result.then(callback, function(reason) {
270
- err(`wasm streaming compile failed: ${reason}`);
271
- err("falling back to ArrayBuffer instantiation");
272
- return instantiateArrayBuffer(binaryFile, imports, callback);
273
- });
274
- });
275
- }
276
- return instantiateArrayBuffer(binaryFile, imports, callback);
326
+function getBinary(file) {
327
+ try {
328
+ if (file == wasmBinaryFile && wasmBinary) {
329
+ return new Uint8Array(wasmBinary);
330
+ }
331
+ if (readBinary) {
332
+ return readBinary(file);
333
+ }
334
+ throw "both async and sync fetching of the wasm failed";
335
+ } catch (err) {
336
+ abort(err);
337
+ }
338
+}
339
+
340
+function getBinaryPromise() {
341
+ if (!wasmBinary && (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER)) {
342
+ if (typeof fetch == "function") {
343
+ return fetch(wasmBinaryFile, {
344
+ credentials: "same-origin"
345
+ }).then(function(response) {
346
+ if (!response["ok"]) {
347
+ throw "failed to load wasm binary file at '" + wasmBinaryFile + "'";
348
+ }
349
+ return response["arrayBuffer"]();
350
+ }).catch(function() {
351
+ return getBinary(wasmBinaryFile);
352
+ });
353
+ }
354
+ }
355
+ return Promise.resolve().then(function() {
356
+ return getBinary(wasmBinaryFile);
357
+ });
277358
}
278359
279360
function createWasm() {
280361
var info = {
281
- "a": wasmImports
362
+ "a": asmLibraryArg
282363
};
283
- /** @param {WebAssembly.Module=} module*/ function receiveInstance(instance, module) {
284
- wasmExports = instance.exports;
285
- wasmMemory = wasmExports["d"];
364
+ function receiveInstance(instance, module) {
365
+ var exports = instance.exports;
366
+ Module["asm"] = exports;
367
+ wasmMemory = Module["asm"]["d"];
286368
updateMemoryViews();
287
- addOnInit(wasmExports["e"]);
369
+ wasmTable = Module["asm"]["g"];
370
+ addOnInit(Module["asm"]["e"]);
288371
removeRunDependency("wasm-instantiate");
289
- return wasmExports;
290372
}
291373
addRunDependency("wasm-instantiate");
292374
function receiveInstantiationResult(result) {
293375
receiveInstance(result["instance"]);
294376
}
295
- if (Module["instantiateWasm"]) {
296
- try {
297
- return Module["instantiateWasm"](info, receiveInstance);
298
- } catch (e) {
299
- err(`Module.instantiateWasm callback failed with error: ${e}`);
300
- readyPromiseReject(e);
301
- }
302
- }
303
- instantiateAsync(wasmBinary, wasmBinaryFile, info, receiveInstantiationResult).catch(readyPromiseReject);
304
- return {};
305
-}
306
-
307
-/** @constructor */ function ExitStatus(status) {
308
- this.name = "ExitStatus";
309
- this.message = `Program terminated with exit(${status})`;
310
- this.status = status;
311
-}
312
-
313
-var callRuntimeCallbacks = callbacks => {
314
- while (callbacks.length > 0) {
315
- callbacks.shift()(Module);
316
- }
317
-};
318
-
319
-/**
320
- * @param {number} ptr
321
- * @param {string} type
322
- */ function getValue(ptr, type = "i8") {
323
- if (type.endsWith("*")) type = "*";
324
- switch (type) {
325
- case "i1":
326
- return HEAP8[((ptr) >> 0)];
327
-
328
- case "i8":
329
- return HEAP8[((ptr) >> 0)];
330
-
331
- case "i16":
332
- return HEAP16[((ptr) >> 1)];
333
-
334
- case "i32":
335
- return HEAP32[((ptr) >> 2)];
336
-
337
- case "i64":
338
- abort("to do getValue(i64) use WASM_BIGINT");
339
-
340
- case "float":
341
- return HEAPF32[((ptr) >> 2)];
342
-
343
- case "double":
344
- return HEAPF64[((ptr) >> 3)];
345
-
346
- case "*":
347
- return HEAPU32[((ptr) >> 2)];
348
-
349
- default:
350
- abort(`invalid type for getValue: ${type}`);
351
- }
352
-}
353
-
354
-var noExitRuntime = Module["noExitRuntime"] || true;
355
-
356
-/**
357
- * @param {number} ptr
358
- * @param {number} value
359
- * @param {string} type
360
- */ function setValue(ptr, value, type = "i8") {
361
- if (type.endsWith("*")) type = "*";
362
- switch (type) {
363
- case "i1":
364
- HEAP8[((ptr) >> 0)] = value;
365
- break;
366
-
367
- case "i8":
368
- HEAP8[((ptr) >> 0)] = value;
369
- break;
370
-
371
- case "i16":
372
- HEAP16[((ptr) >> 1)] = value;
373
- break;
374
-
375
- case "i32":
376
- HEAP32[((ptr) >> 2)] = value;
377
- break;
378
-
379
- case "i64":
380
- abort("to do setValue(i64) use WASM_BIGINT");
381
-
382
- case "float":
383
- HEAPF32[((ptr) >> 2)] = value;
384
- break;
385
-
386
- case "double":
387
- HEAPF64[((ptr) >> 3)] = value;
388
- break;
389
-
390
- case "*":
391
- HEAPU32[((ptr) >> 2)] = value;
392
- break;
393
-
394
- default:
395
- abort(`invalid type for setValue: ${type}`);
396
- }
397
-}
398
-
399
-var UTF8Decoder = typeof TextDecoder != "undefined" ? new TextDecoder("utf8") : undefined;
400
-
401
-/**
402
- * Given a pointer 'idx' to a null-terminated UTF8-encoded string in the given
403
- * array that contains uint8 values, returns a copy of that string as a
404
- * Javascript String object.
405
- * heapOrArray is either a regular array, or a JavaScript typed array view.
406
- * @param {number} idx
407
- * @param {number=} maxBytesToRead
408
- * @return {string}
409
- */ var UTF8ArrayToString = (heapOrArray, idx, maxBytesToRead) => {
410
- var endIdx = idx + maxBytesToRead;
411
- var endPtr = idx;
412
- while (heapOrArray[endPtr] && !(endPtr >= endIdx)) ++endPtr;
413
- if (endPtr - idx > 16 && heapOrArray.buffer && UTF8Decoder) {
414
- return UTF8Decoder.decode(heapOrArray.subarray(idx, endPtr));
415
- }
416
- var str = "";
417
- while (idx < endPtr) {
418
- var u0 = heapOrArray[idx++];
419
- if (!(u0 & 128)) {
420
- str += String.fromCharCode(u0);
421
- continue;
422
- }
423
- var u1 = heapOrArray[idx++] & 63;
424
- if ((u0 & 224) == 192) {
425
- str += String.fromCharCode(((u0 & 31) << 6) | u1);
426
- continue;
427
- }
428
- var u2 = heapOrArray[idx++] & 63;
429
- if ((u0 & 240) == 224) {
430
- u0 = ((u0 & 15) << 12) | (u1 << 6) | u2;
431
- } else {
432
- u0 = ((u0 & 7) << 18) | (u1 << 12) | (u2 << 6) | (heapOrArray[idx++] & 63);
433
- }
434
- if (u0 < 65536) {
435
- str += String.fromCharCode(u0);
436
- } else {
437
- var ch = u0 - 65536;
438
- str += String.fromCharCode(55296 | (ch >> 10), 56320 | (ch & 1023));
439
- }
440
- }
441
- return str;
442
-};
443
-
444
-/**
445
- * Given a pointer 'ptr' to a null-terminated UTF8-encoded string in the
446
- * emscripten HEAP, returns a copy of that string as a Javascript String object.
447
- *
448
- * @param {number} ptr
449
- * @param {number=} maxBytesToRead - An optional length that specifies the
450
- * maximum number of bytes to read. You can omit this parameter to scan the
451
- * string until the first 0 byte. If maxBytesToRead is passed, and the string
452
- * at [ptr, ptr+maxBytesToReadr[ contains a null byte in the middle, then the
453
- * string will cut short at that byte index (i.e. maxBytesToRead will not
454
- * produce a string of exact length [ptr, ptr+maxBytesToRead[) N.B. mixing
455
- * frequent uses of UTF8ToString() with and without maxBytesToRead may throw
456
- * JS JIT optimizations off, so it is worth to consider consistently using one
457
- * @return {string}
458
- */ var UTF8ToString = (ptr, maxBytesToRead) => ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead) : "";
459
-
460
-var ___assert_fail = (condition, filename, line, func) => {
461
- abort(`Assertion failed: ${UTF8ToString(condition)}, at: ` + [ filename ? UTF8ToString(filename) : "unknown filename", line, func ? UTF8ToString(func) : "unknown function" ]);
462
-};
463
-
464
-var abortOnCannotGrowMemory = requestedSize => {
465
- abort("OOM");
466
-};
467
-
468
-var _emscripten_resize_heap = requestedSize => {
469
- var oldSize = HEAPU8.length;
470
- requestedSize >>>= 0;
471
- abortOnCannotGrowMemory(requestedSize);
472
-};
473
-
474
-var runtimeKeepaliveCounter = 0;
475
-
476
-var keepRuntimeAlive = () => noExitRuntime || runtimeKeepaliveCounter > 0;
477
-
478
-var _proc_exit = code => {
479
- EXITSTATUS = code;
480
- if (!keepRuntimeAlive()) {
481
- Module["onExit"]?.(code);
482
- ABORT = true;
483
- }
484
- quit_(code, new ExitStatus(code));
485
-};
486
-
487
-/** @param {boolean|number=} implicit */ var exitJS = (status, implicit) => {
488
- EXITSTATUS = status;
489
- _proc_exit(status);
490
-};
491
-
492
-var _exit = exitJS;
493
-
494
-var getCFunc = ident => {
495
- var func = Module["_" + ident];
496
- return func;
497
-};
498
-
499
-var writeArrayToMemory = (array, buffer) => {
500
- HEAP8.set(array, buffer);
501
-};
502
-
503
-var lengthBytesUTF8 = str => {
504
- var len = 0;
505
- for (var i = 0; i < str.length; ++i) {
506
- var c = str.charCodeAt(i);
507
- if (c <= 127) {
508
- len++;
509
- } else if (c <= 2047) {
510
- len += 2;
511
- } else if (c >= 55296 && c <= 57343) {
512
- len += 4;
513
- ++i;
514
- } else {
515
- len += 3;
516
- }
517
- }
518
- return len;
519
-};
520
-
521
-var stringToUTF8Array = (str, heap, outIdx, maxBytesToWrite) => {
522
- if (!(maxBytesToWrite > 0)) return 0;
523
- var startIdx = outIdx;
524
- var endIdx = outIdx + maxBytesToWrite - 1;
525
- for (var i = 0; i < str.length; ++i) {
526
- var u = str.charCodeAt(i);
527
- if (u >= 55296 && u <= 57343) {
528
- var u1 = str.charCodeAt(++i);
529
- u = 65536 + ((u & 1023) << 10) | (u1 & 1023);
530
- }
531
- if (u <= 127) {
532
- if (outIdx >= endIdx) break;
533
- heap[outIdx++] = u;
534
- } else if (u <= 2047) {
535
- if (outIdx + 1 >= endIdx) break;
536
- heap[outIdx++] = 192 | (u >> 6);
537
- heap[outIdx++] = 128 | (u & 63);
538
- } else if (u <= 65535) {
539
- if (outIdx + 2 >= endIdx) break;
540
- heap[outIdx++] = 224 | (u >> 12);
541
- heap[outIdx++] = 128 | ((u >> 6) & 63);
542
- heap[outIdx++] = 128 | (u & 63);
543
- } else {
544
- if (outIdx + 3 >= endIdx) break;
545
- heap[outIdx++] = 240 | (u >> 18);
546
- heap[outIdx++] = 128 | ((u >> 12) & 63);
547
- heap[outIdx++] = 128 | ((u >> 6) & 63);
548
- heap[outIdx++] = 128 | (u & 63);
549
- }
550
- }
551
- heap[outIdx] = 0;
552
- return outIdx - startIdx;
553
-};
554
-
555
-var stringToUTF8 = (str, outPtr, maxBytesToWrite) => stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite);
556
-
557
-var stringToUTF8OnStack = str => {
558
- var size = lengthBytesUTF8(str) + 1;
559
- var ret = stackAlloc(size);
560
- stringToUTF8(str, ret, size);
561
- return ret;
562
-};
563
-
564
-/**
565
- * @param {string|null=} returnType
566
- * @param {Array=} argTypes
567
- * @param {Arguments|Array=} args
568
- * @param {Object=} opts
569
- */ var ccall = (ident, returnType, argTypes, args, opts) => {
377
+ function instantiateArrayBuffer(receiver) {
378
+ return getBinaryPromise().then(function(binary) {
379
+ return WebAssembly.instantiate(binary, info);
380
+ }).then(function(instance) {
381
+ return instance;
382
+ }).then(receiver, function(reason) {
383
+ err("failed to asynchronously prepare wasm: " + reason);
384
+ abort(reason);
385
+ });
386
+ }
387
+ function instantiateAsync() {
388
+ if (!wasmBinary && typeof WebAssembly.instantiateStreaming == "function" && !isDataURI(wasmBinaryFile) && typeof fetch == "function") {
389
+ return fetch(wasmBinaryFile, {
390
+ credentials: "same-origin"
391
+ }).then(function(response) {
392
+ var result = WebAssembly.instantiateStreaming(response, info);
393
+ return result.then(receiveInstantiationResult, function(reason) {
394
+ err("wasm streaming compile failed: " + reason);
395
+ err("falling back to ArrayBuffer instantiation");
396
+ return instantiateArrayBuffer(receiveInstantiationResult);
397
+ });
398
+ });
399
+ } else {
400
+ return instantiateArrayBuffer(receiveInstantiationResult);
401
+ }
402
+ }
403
+ if (Module["instantiateWasm"]) {
404
+ try {
405
+ var exports = Module["instantiateWasm"](info, receiveInstance);
406
+ return exports;
407
+ } catch (e) {
408
+ err("Module.instantiateWasm callback failed with error: " + e);
409
+ readyPromiseReject(e);
410
+ }
411
+ }
412
+ instantiateAsync().catch(readyPromiseReject);
413
+ return {};
414
+}
415
+
416
+var tempDouble;
417
+
418
+var tempI64;
419
+
420
+function ExitStatus(status) {
421
+ this.name = "ExitStatus";
422
+ this.message = "Program terminated with exit(" + status + ")";
423
+ this.status = status;
424
+}
425
+
426
+function callRuntimeCallbacks(callbacks) {
427
+ while (callbacks.length > 0) {
428
+ callbacks.shift()(Module);
429
+ }
430
+}
431
+
432
+function getValue(ptr, type = "i8") {
433
+ if (type.endsWith("*")) type = "*";
434
+ switch (type) {
435
+ case "i1":
436
+ return HEAP8[ptr >> 0];
437
+
438
+ case "i8":
439
+ return HEAP8[ptr >> 0];
440
+
441
+ case "i16":
442
+ return HEAP16[ptr >> 1];
443
+
444
+ case "i32":
445
+ return HEAP32[ptr >> 2];
446
+
447
+ case "i64":
448
+ return HEAP32[ptr >> 2];
449
+
450
+ case "float":
451
+ return HEAPF32[ptr >> 2];
452
+
453
+ case "double":
454
+ return HEAPF64[ptr >> 3];
455
+
456
+ case "*":
457
+ return HEAPU32[ptr >> 2];
458
+
459
+ default:
460
+ abort("invalid type for getValue: " + type);
461
+ }
462
+ return null;
463
+}
464
+
465
+function setValue(ptr, value, type = "i8") {
466
+ if (type.endsWith("*")) type = "*";
467
+ switch (type) {
468
+ case "i1":
469
+ HEAP8[ptr >> 0] = value;
470
+ break;
471
+
472
+ case "i8":
473
+ HEAP8[ptr >> 0] = value;
474
+ break;
475
+
476
+ case "i16":
477
+ HEAP16[ptr >> 1] = value;
478
+ break;
479
+
480
+ case "i32":
481
+ HEAP32[ptr >> 2] = value;
482
+ break;
483
+
484
+ case "i64":
485
+ tempI64 = [ value >>> 0, (tempDouble = value, +Math.abs(tempDouble) >= 1 ? tempDouble > 0 ? (Math.min(+Math.floor(tempDouble / 4294967296), 4294967295) | 0) >>> 0 : ~~+Math.ceil((tempDouble - +(~~tempDouble >>> 0)) / 4294967296) >>> 0 : 0) ],
486
+ HEAP32[ptr >> 2] = tempI64[0], HEAP32[ptr + 4 >> 2] = tempI64[1];
487
+ break;
488
+
489
+ case "float":
490
+ HEAPF32[ptr >> 2] = value;
491
+ break;
492
+
493
+ case "double":
494
+ HEAPF64[ptr >> 3] = value;
495
+ break;
496
+
497
+ case "*":
498
+ HEAPU32[ptr >> 2] = value;
499
+ break;
500
+
501
+ default:
502
+ abort("invalid type for setValue: " + type);
503
+ }
504
+}
505
+
506
+function ___assert_fail(condition, filename, line, func) {
507
+ abort("Assertion failed: " + UTF8ToString(condition) + ", at: " + [ filename ? UTF8ToString(filename) : "unknown filename", line, func ? UTF8ToString(func) : "unknown function" ]);
508
+}
509
+
510
+function abortOnCannotGrowMemory(requestedSize) {
511
+ abort("OOM");
512
+}
513
+
514
+function _emscripten_resize_heap(requestedSize) {
515
+ var oldSize = HEAPU8.length;
516
+ requestedSize = requestedSize >>> 0;
517
+ abortOnCannotGrowMemory(requestedSize);
518
+}
519
+
520
+var SYSCALLS = {
521
+ varargs: undefined,
522
+ get: function() {
523
+ SYSCALLS.varargs += 4;
524
+ var ret = HEAP32[SYSCALLS.varargs - 4 >> 2];
525
+ return ret;
526
+ },
527
+ getStr: function(ptr) {
528
+ var ret = UTF8ToString(ptr);
529
+ return ret;
530
+ }
531
+};
532
+
533
+function _proc_exit(code) {
534
+ EXITSTATUS = code;
535
+ if (!keepRuntimeAlive()) {
536
+ if (Module["onExit"]) Module["onExit"](code);
537
+ ABORT = true;
538
+ }
539
+ quit_(code, new ExitStatus(code));
540
+}
541
+
542
+function exitJS(status, implicit) {
543
+ EXITSTATUS = status;
544
+ _proc_exit(status);
545
+}
546
+
547
+var _exit = exitJS;
548
+
549
+function getCFunc(ident) {
550
+ var func = Module["_" + ident];
551
+ return func;
552
+}
553
+
554
+function writeArrayToMemory(array, buffer) {
555
+ HEAP8.set(array, buffer);
556
+}
557
+
558
+function ccall(ident, returnType, argTypes, args, opts) {
570559
var toC = {
571560
"string": str => {
572561
var ret = 0;
573562
if (str !== null && str !== undefined && str !== 0) {
574
- ret = stringToUTF8OnStack(str);
563
+ var len = (str.length << 2) + 1;
564
+ ret = stackAlloc(len);
565
+ stringToUTF8(str, ret, len);
575566
}
576567
return ret;
577568
},
578569
"array": arr => {
579570
var ret = stackAlloc(arr.length);
@@ -607,46 +598,51 @@
607598
if (stack !== 0) stackRestore(stack);
608599
return convertReturnValue(ret);
609600
}
610601
ret = onDone(ret);
611602
return ret;
612
-};
613
-
614
-/**
615
- * @param {string=} returnType
616
- * @param {Array=} argTypes
617
- * @param {Object=} opts
618
- */ var cwrap = (ident, returnType, argTypes, opts) => {
619
- var numericArgs = !argTypes || argTypes.every(type => type === "number" || type === "boolean");
603
+}
604
+
605
+function cwrap(ident, returnType, argTypes, opts) {
606
+ argTypes = argTypes || [];
607
+ var numericArgs = argTypes.every(type => type === "number" || type === "boolean");
620608
var numericRet = returnType !== "string";
621609
if (numericRet && numericArgs && !opts) {
622610
return getCFunc(ident);
623611
}
624612
return function() {
625613
return ccall(ident, returnType, argTypes, arguments, opts);
626614
};
627
-};
628
-
629
-var wasmImports = {
630
- /** @export */ a: ___assert_fail,
631
- /** @export */ b: _emscripten_resize_heap,
632
- /** @export */ c: _exit
633
-};
634
-
635
-var wasmExports = createWasm();
636
-
637
-var ___wasm_call_ctors = () => (___wasm_call_ctors = wasmExports["e"])();
638
-
639
-var _pikchr = Module["_pikchr"] = (a0, a1, a2, a3, a4) => (_pikchr = Module["_pikchr"] = wasmExports["f"])(a0, a1, a2, a3, a4);
640
-
641
-var stackSave = () => (stackSave = wasmExports["h"])();
642
-
643
-var stackRestore = a0 => (stackRestore = wasmExports["i"])(a0);
644
-
645
-var stackAlloc = a0 => (stackAlloc = wasmExports["j"])(a0);
646
-
647
-Module["stackAlloc"] = stackAlloc;
615
+}
616
+
617
+var asmLibraryArg = {
618
+ "a": ___assert_fail,
619
+ "b": _emscripten_resize_heap,
620
+ "c": _exit
621
+};
622
+
623
+var asm = createWasm();
624
+
625
+var ___wasm_call_ctors = Module["___wasm_call_ctors"] = function() {
626
+ return (___wasm_call_ctors = Module["___wasm_call_ctors"] = Module["asm"]["e"]).apply(null, arguments);
627
+};
628
+
629
+var _pikchr = Module["_pikchr"] = function() {
630
+ return (_pikchr = Module["_pikchr"] = Module["asm"]["f"]).apply(null, arguments);
631
+};
632
+
633
+var stackSave = Module["stackSave"] = function() {
634
+ return (stackSave = Module["stackSave"] = Module["asm"]["h"]).apply(null, arguments);
635
+};
636
+
637
+var stackRestore = Module["stackRestore"] = function() {
638
+ return (stackRestore = Module["stackRestore"] = Module["asm"]["i"]).apply(null, arguments);
639
+};
640
+
641
+var stackAlloc = Module["stackAlloc"] = function() {
642
+ return (stackAlloc = Module["stackAlloc"] = Module["asm"]["j"]).apply(null, arguments);
643
+};
648644
649645
Module["stackSave"] = stackSave;
650646
651647
Module["stackRestore"] = stackRestore;
652648
@@ -661,11 +657,12 @@
661657
dependenciesFulfilled = function runCaller() {
662658
if (!calledRun) run();
663659
if (!calledRun) dependenciesFulfilled = runCaller;
664660
};
665661
666
-function run() {
662
+function run(args) {
663
+ args = args || arguments_;
667664
if (runDependencies > 0) {
668665
return;
669666
}
670667
preRun();
671668
if (runDependencies > 0) {
@@ -702,13 +699,15 @@
702699
}
703700
704701
run();
705702
706703
707
- return moduleArg.ready
704
+ return initPikchrModule.ready
708705
}
709706
);
710707
})();
711708
if (typeof exports === 'object' && typeof module === 'object')
712709
module.exports = initPikchrModule;
713710
else if (typeof define === 'function' && define['amd'])
714
- define([], () => initPikchrModule);
711
+ define([], function() { return initPikchrModule; });
712
+else if (typeof exports === 'object')
713
+ exports["initPikchrModule"] = initPikchrModule;
715714
--- extsrc/pikchr.js
+++ extsrc/pikchr.js
@@ -1,17 +1,18 @@
1
2 var initPikchrModule = (() => {
3 var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;
4
5 return (
6 function(moduleArg = {}) {
 
7
8 var Module = moduleArg;
9
10 var readyPromiseResolve, readyPromiseReject;
11
12 Module["ready"] = new Promise((resolve, reject) => {
13 readyPromiseResolve = resolve;
14 readyPromiseReject = reject;
15 });
16
17 var moduleOverrides = Object.assign({}, Module);
@@ -35,11 +36,11 @@
35 return Module["locateFile"](path, scriptDirectory);
36 }
37 return scriptDirectory + path;
38 }
39
40 var read_, readAsync, readBinary;
41
42 if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
43 if (ENVIRONMENT_IS_WORKER) {
44 scriptDirectory = self.location.href;
45 } else if (typeof document != "undefined" && document.currentScript) {
@@ -46,51 +47,52 @@
46 scriptDirectory = document.currentScript.src;
47 }
48 if (_scriptDir) {
49 scriptDirectory = _scriptDir;
50 }
51 if (scriptDirectory.startsWith("blob:")) {
52 scriptDirectory = "";
53 } else {
54 scriptDirectory = scriptDirectory.substr(0, scriptDirectory.replace(/[?#].*/, "").lastIndexOf("/") + 1);
55 }
56 {
57 read_ = url => {
58 var xhr = new XMLHttpRequest;
59 xhr.open("GET", url, false);
60 xhr.send(null);
61 return xhr.responseText;
62 };
63 if (ENVIRONMENT_IS_WORKER) {
64 readBinary = url => {
65 var xhr = new XMLHttpRequest;
66 xhr.open("GET", url, false);
67 xhr.responseType = "arraybuffer";
68 xhr.send(null);
69 return new Uint8Array(/** @type{!ArrayBuffer} */ (xhr.response));
70 };
71 }
72 readAsync = (url, onload, onerror) => {
73 var xhr = new XMLHttpRequest;
74 xhr.open("GET", url, true);
75 xhr.responseType = "arraybuffer";
76 xhr.onload = () => {
77 if (xhr.status == 200 || (xhr.status == 0 && xhr.response)) {
78 onload(xhr.response);
79 return;
80 }
81 onerror();
82 };
83 xhr.onerror = onerror;
84 xhr.send(null);
85 };
86 }
 
87 } else {}
88
89 var out = Module["print"] || console.log.bind(console);
90
91 var err = Module["printErr"] || console.error.bind(console);
92
93 Object.assign(Module, moduleOverrides);
94
95 moduleOverrides = null;
96
@@ -102,10 +104,12 @@
102
103 var wasmBinary;
104
105 if (Module["wasmBinary"]) wasmBinary = Module["wasmBinary"];
106
 
 
107 if (typeof WebAssembly != "object") {
108 abort("no native wasm support detected");
109 }
110
111 var wasmMemory;
@@ -112,31 +116,118 @@
112
113 var ABORT = false;
114
115 var EXITSTATUS;
116
117 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;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
119 function updateMemoryViews() {
120 var b = wasmMemory.buffer;
121 Module["HEAP8"] = HEAP8 = new Int8Array(b);
122 Module["HEAP16"] = HEAP16 = new Int16Array(b);
 
123 Module["HEAPU8"] = HEAPU8 = new Uint8Array(b);
124 Module["HEAPU16"] = HEAPU16 = new Uint16Array(b);
125 Module["HEAP32"] = HEAP32 = new Int32Array(b);
126 Module["HEAPU32"] = HEAPU32 = new Uint32Array(b);
127 Module["HEAPF32"] = HEAPF32 = new Float32Array(b);
128 Module["HEAPF64"] = HEAPF64 = new Float64Array(b);
129 }
 
 
 
 
130
131 var __ATPRERUN__ = [];
132
133 var __ATINIT__ = [];
134
135 var __ATPOSTRUN__ = [];
136
137 var runtimeInitialized = false;
 
 
 
 
138
139 function preRun() {
140 if (Module["preRun"]) {
141 if (typeof Module["preRun"] == "function") Module["preRun"] = [ Module["preRun"] ];
142 while (Module["preRun"].length) {
@@ -179,16 +270,20 @@
179
180 var dependenciesFulfilled = null;
181
182 function addRunDependency(id) {
183 runDependencies++;
184 Module["monitorRunDependencies"]?.(runDependencies);
 
 
185 }
186
187 function removeRunDependency(id) {
188 runDependencies--;
189 Module["monitorRunDependencies"]?.(runDependencies);
 
 
190 if (runDependencies == 0) {
191 if (runDependencyWatcher !== null) {
192 clearInterval(runDependencyWatcher);
193 runDependencyWatcher = null;
194 }
@@ -198,382 +293,278 @@
198 callback();
199 }
200 }
201 }
202
203 /** @param {string|number=} what */ function abort(what) {
204 Module["onAbort"]?.(what);
 
 
205 what = "Aborted(" + what + ")";
206 err(what);
207 ABORT = true;
208 EXITSTATUS = 1;
209 what += ". Build with -sASSERTIONS for more info.";
210 /** @suppress {checkTypes} */ var e = new WebAssembly.RuntimeError(what);
211 readyPromiseReject(e);
212 throw e;
213 }
214
215 var dataURIPrefix = "data:application/octet-stream;base64,";
216
217 /**
218 * Indicates whether filename is a base64 data URI.
219 * @noinline
220 */ var isDataURI = filename => filename.startsWith(dataURIPrefix);
221
222 var wasmBinaryFile;
223
224 wasmBinaryFile = "pikchr.wasm";
225
226 if (!isDataURI(wasmBinaryFile)) {
227 wasmBinaryFile = locateFile(wasmBinaryFile);
228 }
229
230 function getBinarySync(file) {
231 if (file == wasmBinaryFile && wasmBinary) {
232 return new Uint8Array(wasmBinary);
233 }
234 if (readBinary) {
235 return readBinary(file);
236 }
237 throw "both async and sync fetching of the wasm failed";
238 }
239
240 function getBinaryPromise(binaryFile) {
241 if (!wasmBinary && (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER)) {
242 if (typeof fetch == "function") {
243 return fetch(binaryFile, {
244 credentials: "same-origin"
245 }).then(response => {
246 if (!response["ok"]) {
247 throw `failed to load wasm binary file at '${binaryFile}'`;
248 }
249 return response["arrayBuffer"]();
250 }).catch(() => getBinarySync(binaryFile));
251 }
252 }
253 return Promise.resolve().then(() => getBinarySync(binaryFile));
254 }
255
256 function instantiateArrayBuffer(binaryFile, imports, receiver) {
257 return getBinaryPromise(binaryFile).then(binary => WebAssembly.instantiate(binary, imports)).then(instance => instance).then(receiver, reason => {
258 err(`failed to asynchronously prepare wasm: ${reason}`);
259 abort(reason);
260 });
261 }
262
263 function instantiateAsync(binary, binaryFile, imports, callback) {
264 if (!binary && typeof WebAssembly.instantiateStreaming == "function" && !isDataURI(binaryFile) && typeof fetch == "function") {
265 return fetch(binaryFile, {
266 credentials: "same-origin"
267 }).then(response => {
268 /** @suppress {checkTypes} */ var result = WebAssembly.instantiateStreaming(response, imports);
269 return result.then(callback, function(reason) {
270 err(`wasm streaming compile failed: ${reason}`);
271 err("falling back to ArrayBuffer instantiation");
272 return instantiateArrayBuffer(binaryFile, imports, callback);
273 });
274 });
275 }
276 return instantiateArrayBuffer(binaryFile, imports, callback);
277 }
278
279 function createWasm() {
280 var info = {
281 "a": wasmImports
282 };
283 /** @param {WebAssembly.Module=} module*/ function receiveInstance(instance, module) {
284 wasmExports = instance.exports;
285 wasmMemory = wasmExports["d"];
 
286 updateMemoryViews();
287 addOnInit(wasmExports["e"]);
 
288 removeRunDependency("wasm-instantiate");
289 return wasmExports;
290 }
291 addRunDependency("wasm-instantiate");
292 function receiveInstantiationResult(result) {
293 receiveInstance(result["instance"]);
294 }
295 if (Module["instantiateWasm"]) {
296 try {
297 return Module["instantiateWasm"](info, receiveInstance);
298 } catch (e) {
299 err(`Module.instantiateWasm callback failed with error: ${e}`);
300 readyPromiseReject(e);
301 }
302 }
303 instantiateAsync(wasmBinary, wasmBinaryFile, info, receiveInstantiationResult).catch(readyPromiseReject);
304 return {};
305 }
306
307 /** @constructor */ function ExitStatus(status) {
308 this.name = "ExitStatus";
309 this.message = `Program terminated with exit(${status})`;
310 this.status = status;
311 }
312
313 var callRuntimeCallbacks = callbacks => {
314 while (callbacks.length > 0) {
315 callbacks.shift()(Module);
316 }
317 };
318
319 /**
320 * @param {number} ptr
321 * @param {string} type
322 */ function getValue(ptr, type = "i8") {
323 if (type.endsWith("*")) type = "*";
324 switch (type) {
325 case "i1":
326 return HEAP8[((ptr) >> 0)];
327
328 case "i8":
329 return HEAP8[((ptr) >> 0)];
330
331 case "i16":
332 return HEAP16[((ptr) >> 1)];
333
334 case "i32":
335 return HEAP32[((ptr) >> 2)];
336
337 case "i64":
338 abort("to do getValue(i64) use WASM_BIGINT");
339
340 case "float":
341 return HEAPF32[((ptr) >> 2)];
342
343 case "double":
344 return HEAPF64[((ptr) >> 3)];
345
346 case "*":
347 return HEAPU32[((ptr) >> 2)];
348
349 default:
350 abort(`invalid type for getValue: ${type}`);
351 }
352 }
353
354 var noExitRuntime = Module["noExitRuntime"] || true;
355
356 /**
357 * @param {number} ptr
358 * @param {number} value
359 * @param {string} type
360 */ function setValue(ptr, value, type = "i8") {
361 if (type.endsWith("*")) type = "*";
362 switch (type) {
363 case "i1":
364 HEAP8[((ptr) >> 0)] = value;
365 break;
366
367 case "i8":
368 HEAP8[((ptr) >> 0)] = value;
369 break;
370
371 case "i16":
372 HEAP16[((ptr) >> 1)] = value;
373 break;
374
375 case "i32":
376 HEAP32[((ptr) >> 2)] = value;
377 break;
378
379 case "i64":
380 abort("to do setValue(i64) use WASM_BIGINT");
381
382 case "float":
383 HEAPF32[((ptr) >> 2)] = value;
384 break;
385
386 case "double":
387 HEAPF64[((ptr) >> 3)] = value;
388 break;
389
390 case "*":
391 HEAPU32[((ptr) >> 2)] = value;
392 break;
393
394 default:
395 abort(`invalid type for setValue: ${type}`);
396 }
397 }
398
399 var UTF8Decoder = typeof TextDecoder != "undefined" ? new TextDecoder("utf8") : undefined;
400
401 /**
402 * Given a pointer 'idx' to a null-terminated UTF8-encoded string in the given
403 * array that contains uint8 values, returns a copy of that string as a
404 * Javascript String object.
405 * heapOrArray is either a regular array, or a JavaScript typed array view.
406 * @param {number} idx
407 * @param {number=} maxBytesToRead
408 * @return {string}
409 */ var UTF8ArrayToString = (heapOrArray, idx, maxBytesToRead) => {
410 var endIdx = idx + maxBytesToRead;
411 var endPtr = idx;
412 while (heapOrArray[endPtr] && !(endPtr >= endIdx)) ++endPtr;
413 if (endPtr - idx > 16 && heapOrArray.buffer && UTF8Decoder) {
414 return UTF8Decoder.decode(heapOrArray.subarray(idx, endPtr));
415 }
416 var str = "";
417 while (idx < endPtr) {
418 var u0 = heapOrArray[idx++];
419 if (!(u0 & 128)) {
420 str += String.fromCharCode(u0);
421 continue;
422 }
423 var u1 = heapOrArray[idx++] & 63;
424 if ((u0 & 224) == 192) {
425 str += String.fromCharCode(((u0 & 31) << 6) | u1);
426 continue;
427 }
428 var u2 = heapOrArray[idx++] & 63;
429 if ((u0 & 240) == 224) {
430 u0 = ((u0 & 15) << 12) | (u1 << 6) | u2;
431 } else {
432 u0 = ((u0 & 7) << 18) | (u1 << 12) | (u2 << 6) | (heapOrArray[idx++] & 63);
433 }
434 if (u0 < 65536) {
435 str += String.fromCharCode(u0);
436 } else {
437 var ch = u0 - 65536;
438 str += String.fromCharCode(55296 | (ch >> 10), 56320 | (ch & 1023));
439 }
440 }
441 return str;
442 };
443
444 /**
445 * Given a pointer 'ptr' to a null-terminated UTF8-encoded string in the
446 * emscripten HEAP, returns a copy of that string as a Javascript String object.
447 *
448 * @param {number} ptr
449 * @param {number=} maxBytesToRead - An optional length that specifies the
450 * maximum number of bytes to read. You can omit this parameter to scan the
451 * string until the first 0 byte. If maxBytesToRead is passed, and the string
452 * at [ptr, ptr+maxBytesToReadr[ contains a null byte in the middle, then the
453 * string will cut short at that byte index (i.e. maxBytesToRead will not
454 * produce a string of exact length [ptr, ptr+maxBytesToRead[) N.B. mixing
455 * frequent uses of UTF8ToString() with and without maxBytesToRead may throw
456 * JS JIT optimizations off, so it is worth to consider consistently using one
457 * @return {string}
458 */ var UTF8ToString = (ptr, maxBytesToRead) => ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead) : "";
459
460 var ___assert_fail = (condition, filename, line, func) => {
461 abort(`Assertion failed: ${UTF8ToString(condition)}, at: ` + [ filename ? UTF8ToString(filename) : "unknown filename", line, func ? UTF8ToString(func) : "unknown function" ]);
462 };
463
464 var abortOnCannotGrowMemory = requestedSize => {
465 abort("OOM");
466 };
467
468 var _emscripten_resize_heap = requestedSize => {
469 var oldSize = HEAPU8.length;
470 requestedSize >>>= 0;
471 abortOnCannotGrowMemory(requestedSize);
472 };
473
474 var runtimeKeepaliveCounter = 0;
475
476 var keepRuntimeAlive = () => noExitRuntime || runtimeKeepaliveCounter > 0;
477
478 var _proc_exit = code => {
479 EXITSTATUS = code;
480 if (!keepRuntimeAlive()) {
481 Module["onExit"]?.(code);
482 ABORT = true;
483 }
484 quit_(code, new ExitStatus(code));
485 };
486
487 /** @param {boolean|number=} implicit */ var exitJS = (status, implicit) => {
488 EXITSTATUS = status;
489 _proc_exit(status);
490 };
491
492 var _exit = exitJS;
493
494 var getCFunc = ident => {
495 var func = Module["_" + ident];
496 return func;
497 };
498
499 var writeArrayToMemory = (array, buffer) => {
500 HEAP8.set(array, buffer);
501 };
502
503 var lengthBytesUTF8 = str => {
504 var len = 0;
505 for (var i = 0; i < str.length; ++i) {
506 var c = str.charCodeAt(i);
507 if (c <= 127) {
508 len++;
509 } else if (c <= 2047) {
510 len += 2;
511 } else if (c >= 55296 && c <= 57343) {
512 len += 4;
513 ++i;
514 } else {
515 len += 3;
516 }
517 }
518 return len;
519 };
520
521 var stringToUTF8Array = (str, heap, outIdx, maxBytesToWrite) => {
522 if (!(maxBytesToWrite > 0)) return 0;
523 var startIdx = outIdx;
524 var endIdx = outIdx + maxBytesToWrite - 1;
525 for (var i = 0; i < str.length; ++i) {
526 var u = str.charCodeAt(i);
527 if (u >= 55296 && u <= 57343) {
528 var u1 = str.charCodeAt(++i);
529 u = 65536 + ((u & 1023) << 10) | (u1 & 1023);
530 }
531 if (u <= 127) {
532 if (outIdx >= endIdx) break;
533 heap[outIdx++] = u;
534 } else if (u <= 2047) {
535 if (outIdx + 1 >= endIdx) break;
536 heap[outIdx++] = 192 | (u >> 6);
537 heap[outIdx++] = 128 | (u & 63);
538 } else if (u <= 65535) {
539 if (outIdx + 2 >= endIdx) break;
540 heap[outIdx++] = 224 | (u >> 12);
541 heap[outIdx++] = 128 | ((u >> 6) & 63);
542 heap[outIdx++] = 128 | (u & 63);
543 } else {
544 if (outIdx + 3 >= endIdx) break;
545 heap[outIdx++] = 240 | (u >> 18);
546 heap[outIdx++] = 128 | ((u >> 12) & 63);
547 heap[outIdx++] = 128 | ((u >> 6) & 63);
548 heap[outIdx++] = 128 | (u & 63);
549 }
550 }
551 heap[outIdx] = 0;
552 return outIdx - startIdx;
553 };
554
555 var stringToUTF8 = (str, outPtr, maxBytesToWrite) => stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite);
556
557 var stringToUTF8OnStack = str => {
558 var size = lengthBytesUTF8(str) + 1;
559 var ret = stackAlloc(size);
560 stringToUTF8(str, ret, size);
561 return ret;
562 };
563
564 /**
565 * @param {string|null=} returnType
566 * @param {Array=} argTypes
567 * @param {Arguments|Array=} args
568 * @param {Object=} opts
569 */ var ccall = (ident, returnType, argTypes, args, opts) => {
570 var toC = {
571 "string": str => {
572 var ret = 0;
573 if (str !== null && str !== undefined && str !== 0) {
574 ret = stringToUTF8OnStack(str);
 
 
575 }
576 return ret;
577 },
578 "array": arr => {
579 var ret = stackAlloc(arr.length);
@@ -607,46 +598,51 @@
607 if (stack !== 0) stackRestore(stack);
608 return convertReturnValue(ret);
609 }
610 ret = onDone(ret);
611 return ret;
612 };
613
614 /**
615 * @param {string=} returnType
616 * @param {Array=} argTypes
617 * @param {Object=} opts
618 */ var cwrap = (ident, returnType, argTypes, opts) => {
619 var numericArgs = !argTypes || argTypes.every(type => type === "number" || type === "boolean");
620 var numericRet = returnType !== "string";
621 if (numericRet && numericArgs && !opts) {
622 return getCFunc(ident);
623 }
624 return function() {
625 return ccall(ident, returnType, argTypes, arguments, opts);
626 };
627 };
628
629 var wasmImports = {
630 /** @export */ a: ___assert_fail,
631 /** @export */ b: _emscripten_resize_heap,
632 /** @export */ c: _exit
633 };
634
635 var wasmExports = createWasm();
636
637 var ___wasm_call_ctors = () => (___wasm_call_ctors = wasmExports["e"])();
638
639 var _pikchr = Module["_pikchr"] = (a0, a1, a2, a3, a4) => (_pikchr = Module["_pikchr"] = wasmExports["f"])(a0, a1, a2, a3, a4);
640
641 var stackSave = () => (stackSave = wasmExports["h"])();
642
643 var stackRestore = a0 => (stackRestore = wasmExports["i"])(a0);
644
645 var stackAlloc = a0 => (stackAlloc = wasmExports["j"])(a0);
646
647 Module["stackAlloc"] = stackAlloc;
 
 
 
 
 
 
 
 
648
649 Module["stackSave"] = stackSave;
650
651 Module["stackRestore"] = stackRestore;
652
@@ -661,11 +657,12 @@
661 dependenciesFulfilled = function runCaller() {
662 if (!calledRun) run();
663 if (!calledRun) dependenciesFulfilled = runCaller;
664 };
665
666 function run() {
 
667 if (runDependencies > 0) {
668 return;
669 }
670 preRun();
671 if (runDependencies > 0) {
@@ -702,13 +699,15 @@
702 }
703
704 run();
705
706
707 return moduleArg.ready
708 }
709 );
710 })();
711 if (typeof exports === 'object' && typeof module === 'object')
712 module.exports = initPikchrModule;
713 else if (typeof define === 'function' && define['amd'])
714 define([], () => initPikchrModule);
 
 
715
--- extsrc/pikchr.js
+++ extsrc/pikchr.js
@@ -1,17 +1,18 @@
1
2 var initPikchrModule = (() => {
3 var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;
4
5 return (
6 function(config) {
7 var initPikchrModule = config || {};
8
9 var Module = typeof initPikchrModule != "undefined" ? initPikchrModule : {};
10
11 var readyPromiseResolve, readyPromiseReject;
12
13 Module["ready"] = new Promise(function(resolve, reject) {
14 readyPromiseResolve = resolve;
15 readyPromiseReject = reject;
16 });
17
18 var moduleOverrides = Object.assign({}, Module);
@@ -35,11 +36,11 @@
36 return Module["locateFile"](path, scriptDirectory);
37 }
38 return scriptDirectory + path;
39 }
40
41 var read_, readAsync, readBinary, setWindowTitle;
42
43 if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
44 if (ENVIRONMENT_IS_WORKER) {
45 scriptDirectory = self.location.href;
46 } else if (typeof document != "undefined" && document.currentScript) {
@@ -46,51 +47,52 @@
47 scriptDirectory = document.currentScript.src;
48 }
49 if (_scriptDir) {
50 scriptDirectory = _scriptDir;
51 }
52 if (scriptDirectory.indexOf("blob:") !== 0) {
53 scriptDirectory = scriptDirectory.substr(0, scriptDirectory.replace(/[?#].*/, "").lastIndexOf("/") + 1);
54 } else {
55 scriptDirectory = "";
56 }
57 {
58 read_ = url => {
59 var xhr = new XMLHttpRequest();
60 xhr.open("GET", url, false);
61 xhr.send(null);
62 return xhr.responseText;
63 };
64 if (ENVIRONMENT_IS_WORKER) {
65 readBinary = url => {
66 var xhr = new XMLHttpRequest();
67 xhr.open("GET", url, false);
68 xhr.responseType = "arraybuffer";
69 xhr.send(null);
70 return new Uint8Array(xhr.response);
71 };
72 }
73 readAsync = (url, onload, onerror) => {
74 var xhr = new XMLHttpRequest();
75 xhr.open("GET", url, true);
76 xhr.responseType = "arraybuffer";
77 xhr.onload = () => {
78 if (xhr.status == 200 || xhr.status == 0 && xhr.response) {
79 onload(xhr.response);
80 return;
81 }
82 onerror();
83 };
84 xhr.onerror = onerror;
85 xhr.send(null);
86 };
87 }
88 setWindowTitle = title => document.title = title;
89 } else {}
90
91 var out = Module["print"] || console.log.bind(console);
92
93 var err = Module["printErr"] || console.warn.bind(console);
94
95 Object.assign(Module, moduleOverrides);
96
97 moduleOverrides = null;
98
@@ -102,10 +104,12 @@
104
105 var wasmBinary;
106
107 if (Module["wasmBinary"]) wasmBinary = Module["wasmBinary"];
108
109 var noExitRuntime = Module["noExitRuntime"] || true;
110
111 if (typeof WebAssembly != "object") {
112 abort("no native wasm support detected");
113 }
114
115 var wasmMemory;
@@ -112,31 +116,118 @@
116
117 var ABORT = false;
118
119 var EXITSTATUS;
120
121 var UTF8Decoder = typeof TextDecoder != "undefined" ? new TextDecoder("utf8") : undefined;
122
123 function UTF8ArrayToString(heapOrArray, idx, maxBytesToRead) {
124 var endIdx = idx + maxBytesToRead;
125 var endPtr = idx;
126 while (heapOrArray[endPtr] && !(endPtr >= endIdx)) ++endPtr;
127 if (endPtr - idx > 16 && heapOrArray.buffer && UTF8Decoder) {
128 return UTF8Decoder.decode(heapOrArray.subarray(idx, endPtr));
129 }
130 var str = "";
131 while (idx < endPtr) {
132 var u0 = heapOrArray[idx++];
133 if (!(u0 & 128)) {
134 str += String.fromCharCode(u0);
135 continue;
136 }
137 var u1 = heapOrArray[idx++] & 63;
138 if ((u0 & 224) == 192) {
139 str += String.fromCharCode((u0 & 31) << 6 | u1);
140 continue;
141 }
142 var u2 = heapOrArray[idx++] & 63;
143 if ((u0 & 240) == 224) {
144 u0 = (u0 & 15) << 12 | u1 << 6 | u2;
145 } else {
146 u0 = (u0 & 7) << 18 | u1 << 12 | u2 << 6 | heapOrArray[idx++] & 63;
147 }
148 if (u0 < 65536) {
149 str += String.fromCharCode(u0);
150 } else {
151 var ch = u0 - 65536;
152 str += String.fromCharCode(55296 | ch >> 10, 56320 | ch & 1023);
153 }
154 }
155 return str;
156 }
157
158 function UTF8ToString(ptr, maxBytesToRead) {
159 return ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead) : "";
160 }
161
162 function stringToUTF8Array(str, heap, outIdx, maxBytesToWrite) {
163 if (!(maxBytesToWrite > 0)) return 0;
164 var startIdx = outIdx;
165 var endIdx = outIdx + maxBytesToWrite - 1;
166 for (var i = 0; i < str.length; ++i) {
167 var u = str.charCodeAt(i);
168 if (u >= 55296 && u <= 57343) {
169 var u1 = str.charCodeAt(++i);
170 u = 65536 + ((u & 1023) << 10) | u1 & 1023;
171 }
172 if (u <= 127) {
173 if (outIdx >= endIdx) break;
174 heap[outIdx++] = u;
175 } else if (u <= 2047) {
176 if (outIdx + 1 >= endIdx) break;
177 heap[outIdx++] = 192 | u >> 6;
178 heap[outIdx++] = 128 | u & 63;
179 } else if (u <= 65535) {
180 if (outIdx + 2 >= endIdx) break;
181 heap[outIdx++] = 224 | u >> 12;
182 heap[outIdx++] = 128 | u >> 6 & 63;
183 heap[outIdx++] = 128 | u & 63;
184 } else {
185 if (outIdx + 3 >= endIdx) break;
186 heap[outIdx++] = 240 | u >> 18;
187 heap[outIdx++] = 128 | u >> 12 & 63;
188 heap[outIdx++] = 128 | u >> 6 & 63;
189 heap[outIdx++] = 128 | u & 63;
190 }
191 }
192 heap[outIdx] = 0;
193 return outIdx - startIdx;
194 }
195
196 function stringToUTF8(str, outPtr, maxBytesToWrite) {
197 return stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite);
198 }
199
200 var HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAPF64;
201
202 function updateMemoryViews() {
203 var b = wasmMemory.buffer;
204 Module["HEAP8"] = HEAP8 = new Int8Array(b);
205 Module["HEAP16"] = HEAP16 = new Int16Array(b);
206 Module["HEAP32"] = HEAP32 = new Int32Array(b);
207 Module["HEAPU8"] = HEAPU8 = new Uint8Array(b);
208 Module["HEAPU16"] = HEAPU16 = new Uint16Array(b);
 
209 Module["HEAPU32"] = HEAPU32 = new Uint32Array(b);
210 Module["HEAPF32"] = HEAPF32 = new Float32Array(b);
211 Module["HEAPF64"] = HEAPF64 = new Float64Array(b);
212 }
213
214 var INITIAL_MEMORY = Module["INITIAL_MEMORY"] || 16777216;
215
216 var wasmTable;
217
218 var __ATPRERUN__ = [];
219
220 var __ATINIT__ = [];
221
222 var __ATPOSTRUN__ = [];
223
224 var runtimeInitialized = false;
225
226 function keepRuntimeAlive() {
227 return noExitRuntime;
228 }
229
230 function preRun() {
231 if (Module["preRun"]) {
232 if (typeof Module["preRun"] == "function") Module["preRun"] = [ Module["preRun"] ];
233 while (Module["preRun"].length) {
@@ -179,16 +270,20 @@
270
271 var dependenciesFulfilled = null;
272
273 function addRunDependency(id) {
274 runDependencies++;
275 if (Module["monitorRunDependencies"]) {
276 Module["monitorRunDependencies"](runDependencies);
277 }
278 }
279
280 function removeRunDependency(id) {
281 runDependencies--;
282 if (Module["monitorRunDependencies"]) {
283 Module["monitorRunDependencies"](runDependencies);
284 }
285 if (runDependencies == 0) {
286 if (runDependencyWatcher !== null) {
287 clearInterval(runDependencyWatcher);
288 runDependencyWatcher = null;
289 }
@@ -198,382 +293,278 @@
293 callback();
294 }
295 }
296 }
297
298 function abort(what) {
299 if (Module["onAbort"]) {
300 Module["onAbort"](what);
301 }
302 what = "Aborted(" + what + ")";
303 err(what);
304 ABORT = true;
305 EXITSTATUS = 1;
306 what += ". Build with -sASSERTIONS for more info.";
307 var e = new WebAssembly.RuntimeError(what);
308 readyPromiseReject(e);
309 throw e;
310 }
311
312 var dataURIPrefix = "data:application/octet-stream;base64,";
313
314 function isDataURI(filename) {
315 return filename.startsWith(dataURIPrefix);
316 }
 
317
318 var wasmBinaryFile;
319
320 wasmBinaryFile = "pikchr.wasm";
321
322 if (!isDataURI(wasmBinaryFile)) {
323 wasmBinaryFile = locateFile(wasmBinaryFile);
324 }
325
326 function getBinary(file) {
327 try {
328 if (file == wasmBinaryFile && wasmBinary) {
329 return new Uint8Array(wasmBinary);
330 }
331 if (readBinary) {
332 return readBinary(file);
333 }
334 throw "both async and sync fetching of the wasm failed";
335 } catch (err) {
336 abort(err);
337 }
338 }
339
340 function getBinaryPromise() {
341 if (!wasmBinary && (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER)) {
342 if (typeof fetch == "function") {
343 return fetch(wasmBinaryFile, {
344 credentials: "same-origin"
345 }).then(function(response) {
346 if (!response["ok"]) {
347 throw "failed to load wasm binary file at '" + wasmBinaryFile + "'";
348 }
349 return response["arrayBuffer"]();
350 }).catch(function() {
351 return getBinary(wasmBinaryFile);
352 });
353 }
354 }
355 return Promise.resolve().then(function() {
356 return getBinary(wasmBinaryFile);
357 });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
358 }
359
360 function createWasm() {
361 var info = {
362 "a": asmLibraryArg
363 };
364 function receiveInstance(instance, module) {
365 var exports = instance.exports;
366 Module["asm"] = exports;
367 wasmMemory = Module["asm"]["d"];
368 updateMemoryViews();
369 wasmTable = Module["asm"]["g"];
370 addOnInit(Module["asm"]["e"]);
371 removeRunDependency("wasm-instantiate");
 
372 }
373 addRunDependency("wasm-instantiate");
374 function receiveInstantiationResult(result) {
375 receiveInstance(result["instance"]);
376 }
377 function instantiateArrayBuffer(receiver) {
378 return getBinaryPromise().then(function(binary) {
379 return WebAssembly.instantiate(binary, info);
380 }).then(function(instance) {
381 return instance;
382 }).then(receiver, function(reason) {
383 err("failed to asynchronously prepare wasm: " + reason);
384 abort(reason);
385 });
386 }
387 function instantiateAsync() {
388 if (!wasmBinary && typeof WebAssembly.instantiateStreaming == "function" && !isDataURI(wasmBinaryFile) && typeof fetch == "function") {
389 return fetch(wasmBinaryFile, {
390 credentials: "same-origin"
391 }).then(function(response) {
392 var result = WebAssembly.instantiateStreaming(response, info);
393 return result.then(receiveInstantiationResult, function(reason) {
394 err("wasm streaming compile failed: " + reason);
395 err("falling back to ArrayBuffer instantiation");
396 return instantiateArrayBuffer(receiveInstantiationResult);
397 });
398 });
399 } else {
400 return instantiateArrayBuffer(receiveInstantiationResult);
401 }
402 }
403 if (Module["instantiateWasm"]) {
404 try {
405 var exports = Module["instantiateWasm"](info, receiveInstance);
406 return exports;
407 } catch (e) {
408 err("Module.instantiateWasm callback failed with error: " + e);
409 readyPromiseReject(e);
410 }
411 }
412 instantiateAsync().catch(readyPromiseReject);
413 return {};
414 }
415
416 var tempDouble;
417
418 var tempI64;
419
420 function ExitStatus(status) {
421 this.name = "ExitStatus";
422 this.message = "Program terminated with exit(" + status + ")";
423 this.status = status;
424 }
425
426 function callRuntimeCallbacks(callbacks) {
427 while (callbacks.length > 0) {
428 callbacks.shift()(Module);
429 }
430 }
431
432 function getValue(ptr, type = "i8") {
433 if (type.endsWith("*")) type = "*";
434 switch (type) {
435 case "i1":
436 return HEAP8[ptr >> 0];
437
438 case "i8":
439 return HEAP8[ptr >> 0];
440
441 case "i16":
442 return HEAP16[ptr >> 1];
443
444 case "i32":
445 return HEAP32[ptr >> 2];
446
447 case "i64":
448 return HEAP32[ptr >> 2];
449
450 case "float":
451 return HEAPF32[ptr >> 2];
452
453 case "double":
454 return HEAPF64[ptr >> 3];
455
456 case "*":
457 return HEAPU32[ptr >> 2];
458
459 default:
460 abort("invalid type for getValue: " + type);
461 }
462 return null;
463 }
464
465 function setValue(ptr, value, type = "i8") {
466 if (type.endsWith("*")) type = "*";
467 switch (type) {
468 case "i1":
469 HEAP8[ptr >> 0] = value;
470 break;
471
472 case "i8":
473 HEAP8[ptr >> 0] = value;
474 break;
475
476 case "i16":
477 HEAP16[ptr >> 1] = value;
478 break;
479
480 case "i32":
481 HEAP32[ptr >> 2] = value;
482 break;
483
484 case "i64":
485 tempI64 = [ value >>> 0, (tempDouble = value, +Math.abs(tempDouble) >= 1 ? tempDouble > 0 ? (Math.min(+Math.floor(tempDouble / 4294967296), 4294967295) | 0) >>> 0 : ~~+Math.ceil((tempDouble - +(~~tempDouble >>> 0)) / 4294967296) >>> 0 : 0) ],
486 HEAP32[ptr >> 2] = tempI64[0], HEAP32[ptr + 4 >> 2] = tempI64[1];
487 break;
488
489 case "float":
490 HEAPF32[ptr >> 2] = value;
491 break;
492
493 case "double":
494 HEAPF64[ptr >> 3] = value;
495 break;
496
497 case "*":
498 HEAPU32[ptr >> 2] = value;
499 break;
500
501 default:
502 abort("invalid type for setValue: " + type);
503 }
504 }
505
506 function ___assert_fail(condition, filename, line, func) {
507 abort("Assertion failed: " + UTF8ToString(condition) + ", at: " + [ filename ? UTF8ToString(filename) : "unknown filename", line, func ? UTF8ToString(func) : "unknown function" ]);
508 }
509
510 function abortOnCannotGrowMemory(requestedSize) {
511 abort("OOM");
512 }
513
514 function _emscripten_resize_heap(requestedSize) {
515 var oldSize = HEAPU8.length;
516 requestedSize = requestedSize >>> 0;
517 abortOnCannotGrowMemory(requestedSize);
518 }
519
520 var SYSCALLS = {
521 varargs: undefined,
522 get: function() {
523 SYSCALLS.varargs += 4;
524 var ret = HEAP32[SYSCALLS.varargs - 4 >> 2];
525 return ret;
526 },
527 getStr: function(ptr) {
528 var ret = UTF8ToString(ptr);
529 return ret;
530 }
531 };
532
533 function _proc_exit(code) {
534 EXITSTATUS = code;
535 if (!keepRuntimeAlive()) {
536 if (Module["onExit"]) Module["onExit"](code);
537 ABORT = true;
538 }
539 quit_(code, new ExitStatus(code));
540 }
541
542 function exitJS(status, implicit) {
543 EXITSTATUS = status;
544 _proc_exit(status);
545 }
546
547 var _exit = exitJS;
548
549 function getCFunc(ident) {
550 var func = Module["_" + ident];
551 return func;
552 }
553
554 function writeArrayToMemory(array, buffer) {
555 HEAP8.set(array, buffer);
556 }
557
558 function ccall(ident, returnType, argTypes, args, opts) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
559 var toC = {
560 "string": str => {
561 var ret = 0;
562 if (str !== null && str !== undefined && str !== 0) {
563 var len = (str.length << 2) + 1;
564 ret = stackAlloc(len);
565 stringToUTF8(str, ret, len);
566 }
567 return ret;
568 },
569 "array": arr => {
570 var ret = stackAlloc(arr.length);
@@ -607,46 +598,51 @@
598 if (stack !== 0) stackRestore(stack);
599 return convertReturnValue(ret);
600 }
601 ret = onDone(ret);
602 return ret;
603 }
604
605 function cwrap(ident, returnType, argTypes, opts) {
606 argTypes = argTypes || [];
607 var numericArgs = argTypes.every(type => type === "number" || type === "boolean");
 
 
 
608 var numericRet = returnType !== "string";
609 if (numericRet && numericArgs && !opts) {
610 return getCFunc(ident);
611 }
612 return function() {
613 return ccall(ident, returnType, argTypes, arguments, opts);
614 };
615 }
616
617 var asmLibraryArg = {
618 "a": ___assert_fail,
619 "b": _emscripten_resize_heap,
620 "c": _exit
621 };
622
623 var asm = createWasm();
624
625 var ___wasm_call_ctors = Module["___wasm_call_ctors"] = function() {
626 return (___wasm_call_ctors = Module["___wasm_call_ctors"] = Module["asm"]["e"]).apply(null, arguments);
627 };
628
629 var _pikchr = Module["_pikchr"] = function() {
630 return (_pikchr = Module["_pikchr"] = Module["asm"]["f"]).apply(null, arguments);
631 };
632
633 var stackSave = Module["stackSave"] = function() {
634 return (stackSave = Module["stackSave"] = Module["asm"]["h"]).apply(null, arguments);
635 };
636
637 var stackRestore = Module["stackRestore"] = function() {
638 return (stackRestore = Module["stackRestore"] = Module["asm"]["i"]).apply(null, arguments);
639 };
640
641 var stackAlloc = Module["stackAlloc"] = function() {
642 return (stackAlloc = Module["stackAlloc"] = Module["asm"]["j"]).apply(null, arguments);
643 };
644
645 Module["stackSave"] = stackSave;
646
647 Module["stackRestore"] = stackRestore;
648
@@ -661,11 +657,12 @@
657 dependenciesFulfilled = function runCaller() {
658 if (!calledRun) run();
659 if (!calledRun) dependenciesFulfilled = runCaller;
660 };
661
662 function run(args) {
663 args = args || arguments_;
664 if (runDependencies > 0) {
665 return;
666 }
667 preRun();
668 if (runDependencies > 0) {
@@ -702,13 +699,15 @@
699 }
700
701 run();
702
703
704 return initPikchrModule.ready
705 }
706 );
707 })();
708 if (typeof exports === 'object' && typeof module === 'object')
709 module.exports = initPikchrModule;
710 else if (typeof define === 'function' && define['amd'])
711 define([], function() { return initPikchrModule; });
712 else if (typeof exports === 'object')
713 exports["initPikchrModule"] = initPikchrModule;
714
--- 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
+2 -1
--- src/db.c
+++ src/db.c
@@ -3230,11 +3230,12 @@
32303230
** repository file from which to copy the initial settings. When a template
32313231
** repository is used, almost all of the settings accessible from the setup
32323232
** page, either directly or indirectly, will be copied. Normal users and
32333233
** their associated permissions will not be copied; however, the system
32343234
** default users "anonymous", "nobody", "reader", "developer", and their
3235
-** associated permissions will be copied.
3235
+** associated permissions will be copied. In case of SQL errors, rebuild the
3236
+** template repository and try again.
32363237
**
32373238
** Options:
32383239
** --template FILE Copy settings from repository file
32393240
** -A|--admin-user USERNAME Select given USERNAME as admin user
32403241
** --date-override DATETIME Use DATETIME as time of the initial check-in
32413242
--- src/db.c
+++ src/db.c
@@ -3230,11 +3230,12 @@
3230 ** repository file from which to copy the initial settings. When a template
3231 ** repository is used, almost all of the settings accessible from the setup
3232 ** page, either directly or indirectly, will be copied. Normal users and
3233 ** their associated permissions will not be copied; however, the system
3234 ** default users "anonymous", "nobody", "reader", "developer", and their
3235 ** associated permissions will be copied.
 
3236 **
3237 ** Options:
3238 ** --template FILE Copy settings from repository file
3239 ** -A|--admin-user USERNAME Select given USERNAME as admin user
3240 ** --date-override DATETIME Use DATETIME as time of the initial check-in
3241
--- src/db.c
+++ src/db.c
@@ -3230,11 +3230,12 @@
3230 ** repository file from which to copy the initial settings. When a template
3231 ** repository is used, almost all of the settings accessible from the setup
3232 ** page, either directly or indirectly, will be copied. Normal users and
3233 ** their associated permissions will not be copied; however, the system
3234 ** default users "anonymous", "nobody", "reader", "developer", and their
3235 ** associated permissions will be copied. In case of SQL errors, rebuild the
3236 ** template repository and try again.
3237 **
3238 ** Options:
3239 ** --template FILE Copy settings from repository file
3240 ** -A|--admin-user USERNAME Select given USERNAME as admin user
3241 ** --date-override DATETIME Use DATETIME as time of the initial check-in
3242
--- src/main.mk
+++ src/main.mk
@@ -271,10 +271,11 @@
271271
$(SRCDIR)/sounds/f.wav \
272272
$(SRCDIR)/style.admin_log.css \
273273
$(SRCDIR)/style.chat.css \
274274
$(SRCDIR)/style.fileedit.css \
275275
$(SRCDIR)/style.pikchrshow.css \
276
+ $(SRCDIR)/style.uvlist.css \
276277
$(SRCDIR)/style.wikiedit.css \
277278
$(SRCDIR)/tree.js \
278279
$(SRCDIR)/useredit.js \
279280
$(SRCDIR)/wiki.wiki
280281
281282
--- src/main.mk
+++ src/main.mk
@@ -271,10 +271,11 @@
271 $(SRCDIR)/sounds/f.wav \
272 $(SRCDIR)/style.admin_log.css \
273 $(SRCDIR)/style.chat.css \
274 $(SRCDIR)/style.fileedit.css \
275 $(SRCDIR)/style.pikchrshow.css \
 
276 $(SRCDIR)/style.wikiedit.css \
277 $(SRCDIR)/tree.js \
278 $(SRCDIR)/useredit.js \
279 $(SRCDIR)/wiki.wiki
280
281
--- src/main.mk
+++ src/main.mk
@@ -271,10 +271,11 @@
271 $(SRCDIR)/sounds/f.wav \
272 $(SRCDIR)/style.admin_log.css \
273 $(SRCDIR)/style.chat.css \
274 $(SRCDIR)/style.fileedit.css \
275 $(SRCDIR)/style.pikchrshow.css \
276 $(SRCDIR)/style.uvlist.css \
277 $(SRCDIR)/style.wikiedit.css \
278 $(SRCDIR)/tree.js \
279 $(SRCDIR)/useredit.js \
280 $(SRCDIR)/wiki.wiki
281
282
--- src/rebuild.c
+++ src/rebuild.c
@@ -140,10 +140,15 @@
140140
}
141141
142142
/* Do the fossil-2.0 updates to the schema. (2017-02-28)
143143
*/
144144
rebuild_schema_update_2_0();
145
+
146
+ /* Add the user.jx and reportfmt.jx columns if they are missing. (2022-11-18)
147
+ */
148
+ user_update_user_table();
149
+ report_update_reportfmt_table();
145150
}
146151
147152
/*
148153
** Update the repository schema for Fossil version 2.0. (2017-02-28)
149154
** (1) Change the CHECK constraint on BLOB.UUID so that the length
150155
151156
ADDED src/style.uvlist.css
--- src/rebuild.c
+++ src/rebuild.c
@@ -140,10 +140,15 @@
140 }
141
142 /* Do the fossil-2.0 updates to the schema. (2017-02-28)
143 */
144 rebuild_schema_update_2_0();
 
 
 
 
 
145 }
146
147 /*
148 ** Update the repository schema for Fossil version 2.0. (2017-02-28)
149 ** (1) Change the CHECK constraint on BLOB.UUID so that the length
150
151 DDED src/style.uvlist.css
--- src/rebuild.c
+++ src/rebuild.c
@@ -140,10 +140,15 @@
140 }
141
142 /* Do the fossil-2.0 updates to the schema. (2017-02-28)
143 */
144 rebuild_schema_update_2_0();
145
146 /* Add the user.jx and reportfmt.jx columns if they are missing. (2022-11-18)
147 */
148 user_update_user_table();
149 report_update_reportfmt_table();
150 }
151
152 /*
153 ** Update the repository schema for Fossil version 2.0. (2017-02-28)
154 ** (1) Change the CHECK constraint on BLOB.UUID so that the length
155
156 DDED src/style.uvlist.css
--- a/src/style.uvlist.css
+++ b/src/style.uvlist.css
@@ -0,0 +1,7 @@
1
+body.uvlist input {
2
+ margin: 0.5em;
3
+}
4
+
5
+body.uvlist form {
6
+ display: block;
7
+}
--- a/src/style.uvlist.css
+++ b/src/style.uvlist.css
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
--- a/src/style.uvlist.css
+++ b/src/style.uvlist.css
@@ -0,0 +1,7 @@
1 body.uvlist input {
2 margin: 0.5em;
3 }
4
5 body.uvlist form {
6 display: block;
7 }
--- src/unversioned.c
+++ src/unversioned.c
@@ -520,10 +520,64 @@
520520
db_end_transaction(0);
521521
}else{
522522
usage("add|cat|edit|export|list|revert|remove|sync|touch");
523523
}
524524
}
525
+
526
+/*
527
+** Emit an HTML form for uploading a new unversioned file if
528
+** the current user has WrUnver permissions, else this is
529
+** a no-op.
530
+**
531
+** If this function detects that the form it emits has been submitted,
532
+** it will add the uploaded file to the unversioned file list before
533
+** returning.
534
+**
535
+** Intended only for use by /uvlist, and its form's action is that
536
+** page.
537
+*/
538
+static void uvlist_upload(void){
539
+ const char * aContent;
540
+ if( !g.perm.WrUnver ) return;
541
+ aContent = P("f");
542
+ if( aContent!=0 ){
543
+ const char * const zName = P("f:filename");
544
+ int const nContent = atoi(PD("f:bytes","0"));
545
+ const char * zError = 0;
546
+ Blob content;
547
+ if( zName[0]==0 ){
548
+ zError = "be an empty string";
549
+ }else if( contains_whitespace(zName) ){
550
+ zError = "contain spaces";
551
+ }
552
+ if( zError ){
553
+ fossil_fatal("Unversioned filenames may not %s: %h",
554
+ zError, zName);
555
+ }
556
+ unversioned_schema();
557
+ db_begin_transaction();
558
+ content_rcvid_init("#!fossil /uvlist upload");
559
+ blob_init(&content, aContent, nContent);
560
+ unversioned_write(zName, &content, time(0));
561
+ blob_reset(&content);
562
+ db_end_transaction(0);
563
+ CX("<div>Added: %h</div>", zName);
564
+ }
565
+ form_begin("enctype='multipart/form-data'", "%R/uvlist");
566
+ @ <label for='uvupload'>Upload unversioned file:</label>
567
+ @ <input type='file' id='uvupload' name='f'/>
568
+ @ <input type='submit' id='uvsubmit' value='Upload' disabled='disabled'/>
569
+ @ </form>
570
+ @ <script nonce='%h(style_nonce())'>;/* unversioned.c:%d(__LINE__) */
571
+ @ var upl = document.getElementById('uvupload');
572
+ @ var sbm = document.getElementById('uvsubmit');
573
+ @ upl.onchange = function(){
574
+ @ if (!upl.value) sbm.setAttribute('disabled', 'disabled');
575
+ @ else sbm.removeAttribute('disabled');
576
+ @ }
577
+ @ </script>
578
+}
525579
526580
/*
527581
** WEBPAGE: uvlist
528582
**
529583
** Display a list of all unversioned files in the repository.
@@ -545,10 +599,11 @@
545599
login_check_credentials();
546600
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
547601
cgi_check_for_malice();
548602
etag_check(ETAG_DATA,0);
549603
style_header("Unversioned Files");
604
+ uvlist_upload();
550605
if( !db_table_exists("repository","unversioned") ){
551606
@ No unversioned files on this server
552607
style_finish_page();
553608
return;
554609
}
555610
--- src/unversioned.c
+++ src/unversioned.c
@@ -520,10 +520,64 @@
520 db_end_transaction(0);
521 }else{
522 usage("add|cat|edit|export|list|revert|remove|sync|touch");
523 }
524 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
525
526 /*
527 ** WEBPAGE: uvlist
528 **
529 ** Display a list of all unversioned files in the repository.
@@ -545,10 +599,11 @@
545 login_check_credentials();
546 if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
547 cgi_check_for_malice();
548 etag_check(ETAG_DATA,0);
549 style_header("Unversioned Files");
 
550 if( !db_table_exists("repository","unversioned") ){
551 @ No unversioned files on this server
552 style_finish_page();
553 return;
554 }
555
--- src/unversioned.c
+++ src/unversioned.c
@@ -520,10 +520,64 @@
520 db_end_transaction(0);
521 }else{
522 usage("add|cat|edit|export|list|revert|remove|sync|touch");
523 }
524 }
525
526 /*
527 ** Emit an HTML form for uploading a new unversioned file if
528 ** the current user has WrUnver permissions, else this is
529 ** a no-op.
530 **
531 ** If this function detects that the form it emits has been submitted,
532 ** it will add the uploaded file to the unversioned file list before
533 ** returning.
534 **
535 ** Intended only for use by /uvlist, and its form's action is that
536 ** page.
537 */
538 static void uvlist_upload(void){
539 const char * aContent;
540 if( !g.perm.WrUnver ) return;
541 aContent = P("f");
542 if( aContent!=0 ){
543 const char * const zName = P("f:filename");
544 int const nContent = atoi(PD("f:bytes","0"));
545 const char * zError = 0;
546 Blob content;
547 if( zName[0]==0 ){
548 zError = "be an empty string";
549 }else if( contains_whitespace(zName) ){
550 zError = "contain spaces";
551 }
552 if( zError ){
553 fossil_fatal("Unversioned filenames may not %s: %h",
554 zError, zName);
555 }
556 unversioned_schema();
557 db_begin_transaction();
558 content_rcvid_init("#!fossil /uvlist upload");
559 blob_init(&content, aContent, nContent);
560 unversioned_write(zName, &content, time(0));
561 blob_reset(&content);
562 db_end_transaction(0);
563 CX("<div>Added: %h</div>", zName);
564 }
565 form_begin("enctype='multipart/form-data'", "%R/uvlist");
566 @ <label for='uvupload'>Upload unversioned file:</label>
567 @ <input type='file' id='uvupload' name='f'/>
568 @ <input type='submit' id='uvsubmit' value='Upload' disabled='disabled'/>
569 @ </form>
570 @ <script nonce='%h(style_nonce())'>;/* unversioned.c:%d(__LINE__) */
571 @ var upl = document.getElementById('uvupload');
572 @ var sbm = document.getElementById('uvsubmit');
573 @ upl.onchange = function(){
574 @ if (!upl.value) sbm.setAttribute('disabled', 'disabled');
575 @ else sbm.removeAttribute('disabled');
576 @ }
577 @ </script>
578 }
579
580 /*
581 ** WEBPAGE: uvlist
582 **
583 ** Display a list of all unversioned files in the repository.
@@ -545,10 +599,11 @@
599 login_check_credentials();
600 if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
601 cgi_check_for_malice();
602 etag_check(ETAG_DATA,0);
603 style_header("Unversioned Files");
604 uvlist_upload();
605 if( !db_table_exists("repository","unversioned") ){
606 @ No unversioned files on this server
607 style_finish_page();
608 return;
609 }
610
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -657,10 +657,11 @@
657657
$(SRCDIR)/sounds/f.wav \
658658
$(SRCDIR)/style.admin_log.css \
659659
$(SRCDIR)/style.chat.css \
660660
$(SRCDIR)/style.fileedit.css \
661661
$(SRCDIR)/style.pikchrshow.css \
662
+ $(SRCDIR)/style.uvlist.css \
662663
$(SRCDIR)/style.wikiedit.css \
663664
$(SRCDIR)/tree.js \
664665
$(SRCDIR)/useredit.js \
665666
$(SRCDIR)/wiki.wiki
666667
667668
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -657,10 +657,11 @@
657 $(SRCDIR)/sounds/f.wav \
658 $(SRCDIR)/style.admin_log.css \
659 $(SRCDIR)/style.chat.css \
660 $(SRCDIR)/style.fileedit.css \
661 $(SRCDIR)/style.pikchrshow.css \
 
662 $(SRCDIR)/style.wikiedit.css \
663 $(SRCDIR)/tree.js \
664 $(SRCDIR)/useredit.js \
665 $(SRCDIR)/wiki.wiki
666
667
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -657,10 +657,11 @@
657 $(SRCDIR)/sounds/f.wav \
658 $(SRCDIR)/style.admin_log.css \
659 $(SRCDIR)/style.chat.css \
660 $(SRCDIR)/style.fileedit.css \
661 $(SRCDIR)/style.pikchrshow.css \
662 $(SRCDIR)/style.uvlist.css \
663 $(SRCDIR)/style.wikiedit.css \
664 $(SRCDIR)/tree.js \
665 $(SRCDIR)/useredit.js \
666 $(SRCDIR)/wiki.wiki
667
668
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -615,10 +615,11 @@
615615
"$(SRCDIR)\sounds\f.wav" \
616616
"$(SRCDIR)\style.admin_log.css" \
617617
"$(SRCDIR)\style.chat.css" \
618618
"$(SRCDIR)\style.fileedit.css" \
619619
"$(SRCDIR)\style.pikchrshow.css" \
620
+ "$(SRCDIR)\style.uvlist.css" \
620621
"$(SRCDIR)\style.wikiedit.css" \
621622
"$(SRCDIR)\tree.js" \
622623
"$(SRCDIR)\useredit.js" \
623624
"$(SRCDIR)\wiki.wiki"
624625
@@ -1244,10 +1245,11 @@
12441245
echo "$(SRCDIR)\sounds/f.wav" >> $@
12451246
echo "$(SRCDIR)\style.admin_log.css" >> $@
12461247
echo "$(SRCDIR)\style.chat.css" >> $@
12471248
echo "$(SRCDIR)\style.fileedit.css" >> $@
12481249
echo "$(SRCDIR)\style.pikchrshow.css" >> $@
1250
+ echo "$(SRCDIR)\style.uvlist.css" >> $@
12491251
echo "$(SRCDIR)\style.wikiedit.css" >> $@
12501252
echo "$(SRCDIR)\tree.js" >> $@
12511253
echo "$(SRCDIR)\useredit.js" >> $@
12521254
echo "$(SRCDIR)\wiki.wiki" >> $@
12531255
12541256
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -615,10 +615,11 @@
615 "$(SRCDIR)\sounds\f.wav" \
616 "$(SRCDIR)\style.admin_log.css" \
617 "$(SRCDIR)\style.chat.css" \
618 "$(SRCDIR)\style.fileedit.css" \
619 "$(SRCDIR)\style.pikchrshow.css" \
 
620 "$(SRCDIR)\style.wikiedit.css" \
621 "$(SRCDIR)\tree.js" \
622 "$(SRCDIR)\useredit.js" \
623 "$(SRCDIR)\wiki.wiki"
624
@@ -1244,10 +1245,11 @@
1244 echo "$(SRCDIR)\sounds/f.wav" >> $@
1245 echo "$(SRCDIR)\style.admin_log.css" >> $@
1246 echo "$(SRCDIR)\style.chat.css" >> $@
1247 echo "$(SRCDIR)\style.fileedit.css" >> $@
1248 echo "$(SRCDIR)\style.pikchrshow.css" >> $@
 
1249 echo "$(SRCDIR)\style.wikiedit.css" >> $@
1250 echo "$(SRCDIR)\tree.js" >> $@
1251 echo "$(SRCDIR)\useredit.js" >> $@
1252 echo "$(SRCDIR)\wiki.wiki" >> $@
1253
1254
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -615,10 +615,11 @@
615 "$(SRCDIR)\sounds\f.wav" \
616 "$(SRCDIR)\style.admin_log.css" \
617 "$(SRCDIR)\style.chat.css" \
618 "$(SRCDIR)\style.fileedit.css" \
619 "$(SRCDIR)\style.pikchrshow.css" \
620 "$(SRCDIR)\style.uvlist.css" \
621 "$(SRCDIR)\style.wikiedit.css" \
622 "$(SRCDIR)\tree.js" \
623 "$(SRCDIR)\useredit.js" \
624 "$(SRCDIR)\wiki.wiki"
625
@@ -1244,10 +1245,11 @@
1245 echo "$(SRCDIR)\sounds/f.wav" >> $@
1246 echo "$(SRCDIR)\style.admin_log.css" >> $@
1247 echo "$(SRCDIR)\style.chat.css" >> $@
1248 echo "$(SRCDIR)\style.fileedit.css" >> $@
1249 echo "$(SRCDIR)\style.pikchrshow.css" >> $@
1250 echo "$(SRCDIR)\style.uvlist.css" >> $@
1251 echo "$(SRCDIR)\style.wikiedit.css" >> $@
1252 echo "$(SRCDIR)\tree.js" >> $@
1253 echo "$(SRCDIR)\useredit.js" >> $@
1254 echo "$(SRCDIR)\wiki.wiki" >> $@
1255
1256
--- www/changes.wiki
+++ www/changes.wiki
@@ -11,11 +11,12 @@
1111
which is more familiar to Git users. Retain the legacy name for
1212
compatibility.
1313
* Add new query parameters to the [/help?cmd=/timeline|/timeline page]:
1414
d2=, p2=, and dp2=.
1515
* Add options to the [/help?cmd=tag|fossil tag] command that will list tag values
16
-
16
+ * Add ability to upload unversioned files via the [/help?cmd=/uvlist|/uvlist page].
17
+
1718
1819
<h2 id='v2_24'>Changes for version 2.24 (2024-04-23)</h2>
1920
2021
* Apache change work-around &rarr; As part of a security fix, the Apache webserver
2122
mod_cgi module has stopped relaying the Content-Length field of the HTTP
2223
--- www/changes.wiki
+++ www/changes.wiki
@@ -11,11 +11,12 @@
11 which is more familiar to Git users. Retain the legacy name for
12 compatibility.
13 * Add new query parameters to the [/help?cmd=/timeline|/timeline page]:
14 d2=, p2=, and dp2=.
15 * Add options to the [/help?cmd=tag|fossil tag] command that will list tag values
16
 
17
18 <h2 id='v2_24'>Changes for version 2.24 (2024-04-23)</h2>
19
20 * Apache change work-around &rarr; As part of a security fix, the Apache webserver
21 mod_cgi module has stopped relaying the Content-Length field of the HTTP
22
--- www/changes.wiki
+++ www/changes.wiki
@@ -11,11 +11,12 @@
11 which is more familiar to Git users. Retain the legacy name for
12 compatibility.
13 * Add new query parameters to the [/help?cmd=/timeline|/timeline page]:
14 d2=, p2=, and dp2=.
15 * Add options to the [/help?cmd=tag|fossil tag] command that will list tag values
16 * Add ability to upload unversioned files via the [/help?cmd=/uvlist|/uvlist page].
17
18
19 <h2 id='v2_24'>Changes for version 2.24 (2024-04-23)</h2>
20
21 * Apache change work-around &rarr; As part of a security fix, the Apache webserver
22 mod_cgi module has stopped relaying the Content-Length field of the HTTP
23

Keyboard Shortcuts

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