@zh-keyboard/pinyin 1.0.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,35 +1,25 @@
1
1
  //#region data/rime-api.js
2
2
  async function createRimeModule(moduleArg = {}) {
3
- let moduleRtn;
4
- const Module = moduleArg;
5
- const ENVIRONMENT_IS_WEB = !!globalThis.window;
6
- const ENVIRONMENT_IS_WORKER = !!globalThis.WorkerGlobalScope;
7
- const ENVIRONMENT_IS_NODE = globalThis.process?.versions?.node && globalThis.process?.type != "renderer";
8
- if (ENVIRONMENT_IS_NODE) {
9
- const { createRequire } = await import("node:module");
10
- var require = createRequire(import.meta.url);
11
- }
12
- if (!Module.expectedDataFileDownloads) Module.expectedDataFileDownloads = 0;
13
- Module.expectedDataFileDownloads++;
3
+ var moduleRtn;
4
+ var Module = moduleArg;
5
+ var ENVIRONMENT_IS_WEB = true;
6
+ var ENVIRONMENT_IS_WORKER = false;
7
+ if (!Module["expectedDataFileDownloads"]) Module["expectedDataFileDownloads"] = 0;
8
+ Module["expectedDataFileDownloads"]++;
14
9
  (() => {
15
- const isPthread = typeof ENVIRONMENT_IS_PTHREAD != "undefined" && ENVIRONMENT_IS_PTHREAD;
16
- const isWasmWorker = typeof ENVIRONMENT_IS_WASM_WORKER != "undefined" && ENVIRONMENT_IS_WASM_WORKER;
10
+ var isPthread = typeof ENVIRONMENT_IS_PTHREAD != "undefined" && ENVIRONMENT_IS_PTHREAD;
11
+ var isWasmWorker = typeof ENVIRONMENT_IS_WASM_WORKER != "undefined" && ENVIRONMENT_IS_WASM_WORKER;
17
12
  if (isPthread || isWasmWorker) return;
18
- const isNode = globalThis.process && globalThis.process.versions && globalThis.process.versions.node && globalThis.process.type != "renderer";
19
13
  async function loadPackage(metadata) {
20
- let PACKAGE_PATH = "";
21
- if (typeof window === "object") PACKAGE_PATH = window.encodeURIComponent(`${window.location.pathname.substring(0, window.location.pathname.lastIndexOf("/"))}/`);
22
- else if (typeof process === "undefined" && typeof location !== "undefined") PACKAGE_PATH = encodeURIComponent(`${location.pathname.substring(0, location.pathname.lastIndexOf("/"))}/`);
23
- const PACKAGE_NAME = "/home/zzx/work/librime/wasm/dist/rime-api.data";
24
- const REMOTE_PACKAGE_BASE = "rime-api.data";
25
- const REMOTE_PACKAGE_NAME = Module.locateFile ? Module.locateFile(REMOTE_PACKAGE_BASE, "") : REMOTE_PACKAGE_BASE;
26
- const REMOTE_PACKAGE_SIZE = metadata.remote_package_size;
14
+ var PACKAGE_PATH = "";
15
+ if (typeof window === "object") PACKAGE_PATH = window["encodeURIComponent"](window.location.pathname.substring(0, window.location.pathname.lastIndexOf("/")) + "/");
16
+ else if (typeof process === "undefined" && typeof location !== "undefined") PACKAGE_PATH = encodeURIComponent(location.pathname.substring(0, location.pathname.lastIndexOf("/")) + "/");
17
+ var PACKAGE_NAME = "/home/zzx/work/librime/wasm/dist/rime-api.data";
18
+ var REMOTE_PACKAGE_BASE = "rime-api.data";
19
+ var REMOTE_PACKAGE_NAME = Module["locateFile"] ? Module["locateFile"](REMOTE_PACKAGE_BASE, "") : REMOTE_PACKAGE_BASE;
20
+ var REMOTE_PACKAGE_SIZE = metadata["remote_package_size"];
27
21
  async function fetchRemotePackage(packageName, packageSize) {
28
- if (isNode) {
29
- const contents = require("node:fs").readFileSync(packageName);
30
- return new Uint8Array(contents).buffer;
31
- }
32
- if (!Module.dataFileDownloads) Module.dataFileDownloads = {};
22
+ if (!Module["dataFileDownloads"]) Module["dataFileDownloads"] = {};
33
23
  try {
34
24
  var response = await fetch(packageName);
35
25
  } catch (e) {
@@ -40,24 +30,24 @@ async function createRimeModule(moduleArg = {}) {
40
30
  const headers = response.headers;
41
31
  const total = Number(headers.get("Content-Length") || packageSize);
42
32
  let loaded = 0;
43
- Module.setStatus && Module.setStatus("Downloading data...");
33
+ Module["setStatus"] && Module["setStatus"]("Downloading data...");
44
34
  const reader = response.body.getReader();
45
35
  while (1) {
46
- const { done, value } = await reader.read();
36
+ var { done, value } = await reader.read();
47
37
  if (done) break;
48
38
  chunks.push(value);
49
39
  loaded += value.length;
50
- Module.dataFileDownloads[packageName] = {
40
+ Module["dataFileDownloads"][packageName] = {
51
41
  loaded,
52
42
  total
53
43
  };
54
44
  let totalLoaded = 0;
55
45
  let totalSize = 0;
56
- for (const download of Object.values(Module.dataFileDownloads)) {
46
+ for (const download of Object.values(Module["dataFileDownloads"])) {
57
47
  totalLoaded += download.loaded;
58
48
  totalSize += download.total;
59
49
  }
60
- Module.setStatus && Module.setStatus(`Downloading data... (${totalLoaded}/${totalSize})`);
50
+ Module["setStatus"] && Module["setStatus"](`Downloading data... (${totalLoaded}/${totalSize})`);
61
51
  }
62
52
  const packageData = new Uint8Array(chunks.map((c) => c.length).reduce((a, b) => a + b, 0));
63
53
  let offset = 0;
@@ -67,41 +57,41 @@ async function createRimeModule(moduleArg = {}) {
67
57
  }
68
58
  return packageData.buffer;
69
59
  }
70
- let fetchPromise;
71
- let fetched = Module.getPreloadedPackage && Module.getPreloadedPackage(REMOTE_PACKAGE_NAME, REMOTE_PACKAGE_SIZE);
60
+ var fetchPromise;
61
+ var fetched = Module["getPreloadedPackage"] && Module["getPreloadedPackage"](REMOTE_PACKAGE_NAME, REMOTE_PACKAGE_SIZE);
72
62
  if (!fetched) fetchPromise = fetchRemotePackage(REMOTE_PACKAGE_NAME, REMOTE_PACKAGE_SIZE);
73
63
  async function runWithFS(Module$1) {
74
64
  function assert(check, msg) {
75
65
  if (!check) throw new Error(msg);
76
66
  }
77
- Module$1.FS_createPath("/", "rime", true, true);
78
- Module$1.FS_createPath("/rime", "opencc", true, true);
79
- for (const file of metadata.files) {
80
- const name = file.filename;
81
- Module$1.addRunDependency(`fp ${name}`);
67
+ Module$1["FS_createPath"]("/", "rime", true, true);
68
+ Module$1["FS_createPath"]("/rime", "opencc", true, true);
69
+ for (var file of metadata["files"]) {
70
+ var name = file["filename"];
71
+ Module$1["addRunDependency"](`fp ${name}`);
82
72
  }
83
73
  async function processPackageData(arrayBuffer) {
84
74
  assert(arrayBuffer, "Loading data file failed.");
85
- assert(arrayBuffer.constructor.name === ArrayBuffer.name, `bad input to processPackageData ${arrayBuffer.constructor.name}`);
86
- const byteArray = new Uint8Array(arrayBuffer);
87
- for (const file of metadata.files) {
88
- const name = file.filename;
89
- const data = byteArray.subarray(file.start, file.end);
90
- Module$1.FS_createDataFile(name, null, data, true, true, true);
91
- Module$1.removeRunDependency(`fp ${name}`);
75
+ assert(arrayBuffer.constructor.name === ArrayBuffer.name, "bad input to processPackageData " + arrayBuffer.constructor.name);
76
+ var byteArray = new Uint8Array(arrayBuffer);
77
+ for (var file$1 of metadata["files"]) {
78
+ var name$1 = file$1["filename"];
79
+ var data = byteArray.subarray(file$1["start"], file$1["end"]);
80
+ Module$1["FS_createDataFile"](name$1, null, data, true, true, true);
81
+ Module$1["removeRunDependency"](`fp ${name$1}`);
92
82
  }
93
- Module$1.removeRunDependency("datafile_/home/zzx/work/librime/wasm/dist/rime-api.data");
83
+ Module$1["removeRunDependency"]("datafile_/home/zzx/work/librime/wasm/dist/rime-api.data");
94
84
  }
95
- Module$1.addRunDependency("datafile_/home/zzx/work/librime/wasm/dist/rime-api.data");
96
- if (!Module$1.preloadResults) Module$1.preloadResults = {};
97
- Module$1.preloadResults[PACKAGE_NAME] = { fromCache: false };
85
+ Module$1["addRunDependency"]("datafile_/home/zzx/work/librime/wasm/dist/rime-api.data");
86
+ if (!Module$1["preloadResults"]) Module$1["preloadResults"] = {};
87
+ Module$1["preloadResults"][PACKAGE_NAME] = { fromCache: false };
98
88
  if (!fetched) fetched = await fetchPromise;
99
89
  processPackageData(fetched);
100
90
  }
101
- if (Module.calledRun) runWithFS(Module);
91
+ if (Module["calledRun"]) runWithFS(Module);
102
92
  else {
103
- if (!Module.preRun) Module.preRun = [];
104
- Module.preRun.push(runWithFS);
93
+ if (!Module["preRun"]) Module["preRun"] = [];
94
+ Module["preRun"].push(runWithFS);
105
95
  }
106
96
  }
107
97
  loadPackage({
@@ -140,82 +130,39 @@ async function createRimeModule(moduleArg = {}) {
140
130
  remote_package_size: 1027747
141
131
  });
142
132
  })();
143
- let arguments_ = [];
144
- let thisProgram = "./this.program";
145
- let quit_ = (status, toThrow) => {
133
+ var arguments_ = [];
134
+ var thisProgram = "./this.program";
135
+ var quit_ = (status, toThrow) => {
146
136
  throw toThrow;
147
137
  };
148
- const _scriptName = import.meta.url;
149
- let scriptDirectory = "";
138
+ var _scriptName = import.meta.url;
139
+ var scriptDirectory = "";
150
140
  function locateFile(path) {
151
- if (Module.locateFile) return Module.locateFile(path, scriptDirectory);
141
+ if (Module["locateFile"]) return Module["locateFile"](path, scriptDirectory);
152
142
  return scriptDirectory + path;
153
143
  }
154
- let readAsync, readBinary;
155
- if (ENVIRONMENT_IS_NODE) {
156
- var fs = require("node:fs");
157
- if (_scriptName.startsWith("file:")) scriptDirectory = `${require("node:path").dirname(require("node:url").fileURLToPath(_scriptName))}/`;
158
- readBinary = (filename) => {
159
- filename = isFileURI(filename) ? new URL(filename) : filename;
160
- const ret = fs.readFileSync(filename);
161
- return ret;
162
- };
163
- readAsync = async (filename, binary = true) => {
164
- filename = isFileURI(filename) ? new URL(filename) : filename;
165
- const ret = fs.readFileSync(filename, binary ? void 0 : "utf8");
166
- return ret;
167
- };
168
- if (process.argv.length > 1) thisProgram = process.argv[1].replace(/\\/g, "/");
169
- arguments_ = process.argv.slice(2);
170
- quit_ = (status, toThrow) => {
171
- process.exitCode = status;
172
- throw toThrow;
173
- };
174
- } else if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
144
+ var readAsync, readBinary;
145
+ if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
175
146
  try {
176
147
  scriptDirectory = new URL(".", _scriptName).href;
177
148
  } catch {}
178
- {
179
- if (ENVIRONMENT_IS_WORKER) readBinary = (url) => {
180
- const xhr = new XMLHttpRequest();
181
- xhr.open("GET", url, false);
182
- xhr.responseType = "arraybuffer";
183
- xhr.send(null);
184
- return new Uint8Array(xhr.response);
185
- };
186
- readAsync = async (url) => {
187
- if (isFileURI(url)) return new Promise((resolve, reject) => {
188
- const xhr = new XMLHttpRequest();
189
- xhr.open("GET", url, true);
190
- xhr.responseType = "arraybuffer";
191
- xhr.onload = () => {
192
- if (xhr.status == 200 || xhr.status == 0 && xhr.response) {
193
- resolve(xhr.response);
194
- return;
195
- }
196
- reject(xhr.status);
197
- };
198
- xhr.onerror = reject;
199
- xhr.send(null);
200
- });
201
- const response = await fetch(url, { credentials: "same-origin" });
202
- if (response.ok) return response.arrayBuffer();
203
- throw new Error(`${response.status} : ${response.url}`);
204
- };
205
- }
149
+ readAsync = async (url) => {
150
+ var response = await fetch(url, { credentials: "same-origin" });
151
+ if (response.ok) return response.arrayBuffer();
152
+ throw new Error(response.status + " : " + response.url);
153
+ };
206
154
  }
207
- let out = console.log.bind(console);
208
- let err = console.error.bind(console);
209
- let wasmBinary;
210
- let ABORT = false;
211
- let EXITSTATUS;
212
- var isFileURI = (filename) => filename.startsWith("file://");
213
- let readyPromiseResolve, readyPromiseReject;
214
- let HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAPF64;
215
- let HEAP64, HEAPU64;
216
- let runtimeInitialized = false;
155
+ var out = console.log.bind(console);
156
+ var err = console.error.bind(console);
157
+ var wasmBinary;
158
+ var ABORT = false;
159
+ var EXITSTATUS;
160
+ var readyPromiseResolve, readyPromiseReject;
161
+ var HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAPF64;
162
+ var HEAP64, HEAPU64;
163
+ var runtimeInitialized = false;
217
164
  function updateMemoryViews() {
218
- const b = wasmMemory.buffer;
165
+ var b = wasmMemory.buffer;
219
166
  HEAP8 = new Int8Array(b);
220
167
  HEAP16 = new Int16Array(b);
221
168
  HEAPU8 = new Uint8Array(b);
@@ -228,40 +175,40 @@ async function createRimeModule(moduleArg = {}) {
228
175
  HEAPU64 = new BigUint64Array(b);
229
176
  }
230
177
  function preRun() {
231
- if (Module.preRun) {
232
- if (typeof Module.preRun == "function") Module.preRun = [Module.preRun];
233
- while (Module.preRun.length) addOnPreRun(Module.preRun.shift());
178
+ if (Module["preRun"]) {
179
+ if (typeof Module["preRun"] == "function") Module["preRun"] = [Module["preRun"]];
180
+ while (Module["preRun"].length) addOnPreRun(Module["preRun"].shift());
234
181
  }
235
182
  callRuntimeCallbacks(onPreRuns);
236
183
  }
237
184
  function initRuntime() {
238
185
  runtimeInitialized = true;
239
- if (!Module.noFSInit && !FS.initialized) FS.init();
186
+ if (!Module["noFSInit"] && !FS.initialized) FS.init();
240
187
  TTY.init();
241
- wasmExports.Q();
188
+ wasmExports["Q"]();
242
189
  FS.ignorePermissions = false;
243
190
  }
244
191
  function postRun() {
245
- if (Module.postRun) {
246
- if (typeof Module.postRun == "function") Module.postRun = [Module.postRun];
247
- while (Module.postRun.length) addOnPostRun(Module.postRun.shift());
192
+ if (Module["postRun"]) {
193
+ if (typeof Module["postRun"] == "function") Module["postRun"] = [Module["postRun"]];
194
+ while (Module["postRun"].length) addOnPostRun(Module["postRun"].shift());
248
195
  }
249
196
  callRuntimeCallbacks(onPostRuns);
250
197
  }
251
198
  function abort(what) {
252
- Module.onAbort?.(what);
253
- what = `Aborted(${what})`;
199
+ Module["onAbort"]?.(what);
200
+ what = "Aborted(" + what + ")";
254
201
  err(what);
255
202
  ABORT = true;
256
203
  what += ". Build with -sASSERTIONS for more info.";
257
204
  if (runtimeInitialized) ___trap();
258
- const e = new WebAssembly.RuntimeError(what);
205
+ var e = new WebAssembly.RuntimeError(what);
259
206
  readyPromiseReject?.(e);
260
207
  throw e;
261
208
  }
262
- let wasmBinaryFile;
209
+ var wasmBinaryFile;
263
210
  function findWasmBinary() {
264
- if (Module.locateFile) return locateFile("rime-api.wasm");
211
+ if (Module["locateFile"]) return locateFile("rime-api.wasm");
265
212
  return new URL("rime-api.wasm", import.meta.url).href;
266
213
  }
267
214
  function getBinarySync(file) {
@@ -271,15 +218,15 @@ async function createRimeModule(moduleArg = {}) {
271
218
  }
272
219
  async function getWasmBinary(binaryFile) {
273
220
  if (!wasmBinary) try {
274
- const response = await readAsync(binaryFile);
221
+ var response = await readAsync(binaryFile);
275
222
  return new Uint8Array(response);
276
223
  } catch {}
277
224
  return getBinarySync(binaryFile);
278
225
  }
279
226
  async function instantiateArrayBuffer(binaryFile, imports) {
280
227
  try {
281
- const binary = await getWasmBinary(binaryFile);
282
- const instance = await WebAssembly.instantiate(binary, imports);
228
+ var binary = await getWasmBinary(binaryFile);
229
+ var instance = await WebAssembly.instantiate(binary, imports);
283
230
  return instance;
284
231
  } catch (reason) {
285
232
  err(`failed to asynchronously prepare wasm: ${reason}`);
@@ -287,9 +234,9 @@ async function createRimeModule(moduleArg = {}) {
287
234
  }
288
235
  }
289
236
  async function instantiateAsync(binary, binaryFile, imports) {
290
- if (!binary && !isFileURI(binaryFile) && !ENVIRONMENT_IS_NODE) try {
291
- const response = fetch(binaryFile, { credentials: "same-origin" });
292
- const instantiationResult = await WebAssembly.instantiateStreaming(response, imports);
237
+ if (!binary) try {
238
+ var response = fetch(binaryFile, { credentials: "same-origin" });
239
+ var instantiationResult = await WebAssembly.instantiateStreaming(response, imports);
293
240
  return instantiationResult;
294
241
  } catch (reason) {
295
242
  err(`wasm streaming compile failed: ${reason}`);
@@ -298,7 +245,7 @@ async function createRimeModule(moduleArg = {}) {
298
245
  return instantiateArrayBuffer(binaryFile, imports);
299
246
  }
300
247
  function getWasmImports() {
301
- const imports = { a: wasmImports };
248
+ var imports = { a: wasmImports };
302
249
  return imports;
303
250
  }
304
251
  async function createWasm() {
@@ -310,17 +257,17 @@ async function createRimeModule(moduleArg = {}) {
310
257
  return wasmExports;
311
258
  }
312
259
  function receiveInstantiationResult(result$1) {
313
- return receiveInstance(result$1.instance);
260
+ return receiveInstance(result$1["instance"]);
314
261
  }
315
- const info = getWasmImports();
316
- if (Module.instantiateWasm) return new Promise((resolve, reject) => {
317
- Module.instantiateWasm(info, (inst, mod) => {
262
+ var info = getWasmImports();
263
+ if (Module["instantiateWasm"]) return new Promise((resolve, reject) => {
264
+ Module["instantiateWasm"](info, (inst, mod) => {
318
265
  resolve(receiveInstance(inst, mod));
319
266
  });
320
267
  });
321
268
  wasmBinaryFile ??= findWasmBinary();
322
- const result = await instantiateAsync(wasmBinary, wasmBinaryFile, info);
323
- const exports = receiveInstantiationResult(result);
269
+ var result = await instantiateAsync(wasmBinary, wasmBinaryFile, info);
270
+ var exports = receiveInstantiationResult(result);
324
271
  return exports;
325
272
  }
326
273
  class ExitStatus {
@@ -337,17 +284,17 @@ async function createRimeModule(moduleArg = {}) {
337
284
  var addOnPostRun = (cb) => onPostRuns.push(cb);
338
285
  var onPreRuns = [];
339
286
  var addOnPreRun = (cb) => onPreRuns.push(cb);
340
- let noExitRuntime = true;
287
+ var noExitRuntime = true;
341
288
  var PATH = {
342
289
  isAbs: (path) => path.charAt(0) === "/",
343
290
  splitPath: (filename) => {
344
- const splitPathRe = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^/]+?)?(\.[^./]*|))\/*$/;
291
+ var splitPathRe = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
345
292
  return splitPathRe.exec(filename).slice(1);
346
293
  },
347
294
  normalizeArray: (parts, allowAboveRoot) => {
348
- let up = 0;
349
- for (let i = parts.length - 1; i >= 0; i--) {
350
- const last = parts[i];
295
+ var up = 0;
296
+ for (var i = parts.length - 1; i >= 0; i--) {
297
+ var last = parts[i];
351
298
  if (last === ".") parts.splice(i, 1);
352
299
  else if (last === "..") {
353
300
  parts.splice(i, 1);
@@ -361,44 +308,34 @@ async function createRimeModule(moduleArg = {}) {
361
308
  return parts;
362
309
  },
363
310
  normalize: (path) => {
364
- const isAbsolute = PATH.isAbs(path);
365
- const trailingSlash = path.slice(-1) === "/";
311
+ var isAbsolute = PATH.isAbs(path), trailingSlash = path.slice(-1) === "/";
366
312
  path = PATH.normalizeArray(path.split("/").filter((p) => !!p), !isAbsolute).join("/");
367
313
  if (!path && !isAbsolute) path = ".";
368
314
  if (path && trailingSlash) path += "/";
369
315
  return (isAbsolute ? "/" : "") + path;
370
316
  },
371
317
  dirname: (path) => {
372
- const result = PATH.splitPath(path);
373
- const root = result[0];
374
- let dir = result[1];
318
+ var result = PATH.splitPath(path), root = result[0], dir = result[1];
375
319
  if (!root && !dir) return ".";
376
320
  if (dir) dir = dir.slice(0, -1);
377
321
  return root + dir;
378
322
  },
379
- basename: (path) => path && path.match(/([^/]+|\/)\/*$/)[1],
323
+ basename: (path) => path && path.match(/([^\/]+|\/)\/*$/)[1],
380
324
  join: (...paths) => PATH.normalize(paths.join("/")),
381
- join2: (l, r) => PATH.normalize(`${l}/${r}`)
325
+ join2: (l, r) => PATH.normalize(l + "/" + r)
382
326
  };
383
- const initRandomFill = () => {
384
- if (ENVIRONMENT_IS_NODE) {
385
- const nodeCrypto = require("node:crypto");
386
- return (view) => nodeCrypto.randomFillSync(view);
387
- }
388
- return (view) => crypto.getRandomValues(view);
389
- };
390
- let randomFill = (view) => {
327
+ var initRandomFill = () => (view) => crypto.getRandomValues(view);
328
+ var randomFill = (view) => {
391
329
  (randomFill = initRandomFill())(view);
392
330
  };
393
331
  var PATH_FS = {
394
332
  resolve: (...args) => {
395
- let resolvedPath = "";
396
- let resolvedAbsolute = false;
397
- for (let i = args.length - 1; i >= -1 && !resolvedAbsolute; i--) {
398
- const path = i >= 0 ? args[i] : FS.cwd();
333
+ var resolvedPath = "", resolvedAbsolute = false;
334
+ for (var i = args.length - 1; i >= -1 && !resolvedAbsolute; i--) {
335
+ var path = i >= 0 ? args[i] : FS.cwd();
399
336
  if (typeof path != "string") throw new TypeError("Arguments to path.resolve must be strings");
400
337
  else if (!path) return "";
401
- resolvedPath = `${path}/${resolvedPath}`;
338
+ resolvedPath = path + "/" + resolvedPath;
402
339
  resolvedAbsolute = PATH.isAbs(path);
403
340
  }
404
341
  resolvedPath = PATH.normalizeArray(resolvedPath.split("/").filter((p) => !!p), !resolvedAbsolute).join("/");
@@ -408,44 +345,44 @@ async function createRimeModule(moduleArg = {}) {
408
345
  from = PATH_FS.resolve(from).slice(1);
409
346
  to = PATH_FS.resolve(to).slice(1);
410
347
  function trim(arr) {
411
- let start = 0;
348
+ var start = 0;
412
349
  for (; start < arr.length; start++) if (arr[start] !== "") break;
413
- let end = arr.length - 1;
350
+ var end = arr.length - 1;
414
351
  for (; end >= 0; end--) if (arr[end] !== "") break;
415
352
  if (start > end) return [];
416
353
  return arr.slice(start, end - start + 1);
417
354
  }
418
- const fromParts = trim(from.split("/"));
419
- const toParts = trim(to.split("/"));
420
- const length = Math.min(fromParts.length, toParts.length);
421
- let samePartsLength = length;
355
+ var fromParts = trim(from.split("/"));
356
+ var toParts = trim(to.split("/"));
357
+ var length = Math.min(fromParts.length, toParts.length);
358
+ var samePartsLength = length;
422
359
  for (var i = 0; i < length; i++) if (fromParts[i] !== toParts[i]) {
423
360
  samePartsLength = i;
424
361
  break;
425
362
  }
426
- let outputParts = [];
363
+ var outputParts = [];
427
364
  for (var i = samePartsLength; i < fromParts.length; i++) outputParts.push("..");
428
365
  outputParts = outputParts.concat(toParts.slice(samePartsLength));
429
366
  return outputParts.join("/");
430
367
  }
431
368
  };
432
- const UTF8Decoder = new TextDecoder();
433
- const findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
434
- const maxIdx = idx + maxBytesToRead;
369
+ var UTF8Decoder = new TextDecoder();
370
+ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
371
+ var maxIdx = idx + maxBytesToRead;
435
372
  if (ignoreNul) return maxIdx;
436
373
  while (heapOrArray[idx] && !(idx >= maxIdx)) ++idx;
437
374
  return idx;
438
375
  };
439
- const UTF8ArrayToString = (heapOrArray, idx = 0, maxBytesToRead, ignoreNul) => {
376
+ var UTF8ArrayToString = (heapOrArray, idx = 0, maxBytesToRead, ignoreNul) => {
440
377
  idx >>>= 0;
441
- const endPtr = findStringEnd(heapOrArray, idx, maxBytesToRead, ignoreNul);
378
+ var endPtr = findStringEnd(heapOrArray, idx, maxBytesToRead, ignoreNul);
442
379
  return UTF8Decoder.decode(heapOrArray.buffer ? heapOrArray.subarray(idx, endPtr) : new Uint8Array(heapOrArray.slice(idx, endPtr)));
443
380
  };
444
- let FS_stdin_getChar_buffer = [];
445
- const lengthBytesUTF8 = (str) => {
446
- let len = 0;
447
- for (let i = 0; i < str.length; ++i) {
448
- const c = str.charCodeAt(i);
381
+ var FS_stdin_getChar_buffer = [];
382
+ var lengthBytesUTF8 = (str) => {
383
+ var len = 0;
384
+ for (var i = 0; i < str.length; ++i) {
385
+ var c = str.charCodeAt(i);
449
386
  if (c <= 127) len++;
450
387
  else if (c <= 2047) len += 2;
451
388
  else if (c >= 55296 && c <= 57343) {
@@ -455,13 +392,13 @@ async function createRimeModule(moduleArg = {}) {
455
392
  }
456
393
  return len;
457
394
  };
458
- const stringToUTF8Array = (str, heap, outIdx, maxBytesToWrite) => {
395
+ var stringToUTF8Array = (str, heap, outIdx, maxBytesToWrite) => {
459
396
  outIdx >>>= 0;
460
397
  if (!(maxBytesToWrite > 0)) return 0;
461
- const startIdx = outIdx;
462
- const endIdx = outIdx + maxBytesToWrite - 1;
463
- for (let i = 0; i < str.length; ++i) {
464
- const u = str.codePointAt(i);
398
+ var startIdx = outIdx;
399
+ var endIdx = outIdx + maxBytesToWrite - 1;
400
+ for (var i = 0; i < str.length; ++i) {
401
+ var u = str.codePointAt(i);
465
402
  if (u <= 127) {
466
403
  if (outIdx >= endIdx) break;
467
404
  heap[outIdx++ >>> 0] = u;
@@ -486,29 +423,17 @@ async function createRimeModule(moduleArg = {}) {
486
423
  heap[outIdx >>> 0] = 0;
487
424
  return outIdx - startIdx;
488
425
  };
489
- const intArrayFromString = (stringy, dontAddNull, length) => {
490
- const len = length > 0 ? length : lengthBytesUTF8(stringy) + 1;
491
- const u8array = new Array(len);
492
- const numBytesWritten = stringToUTF8Array(stringy, u8array, 0, u8array.length);
426
+ var intArrayFromString = (stringy, dontAddNull, length) => {
427
+ var len = length > 0 ? length : lengthBytesUTF8(stringy) + 1;
428
+ var u8array = new Array(len);
429
+ var numBytesWritten = stringToUTF8Array(stringy, u8array, 0, u8array.length);
493
430
  if (dontAddNull) u8array.length = numBytesWritten;
494
431
  return u8array;
495
432
  };
496
- const FS_stdin_getChar = () => {
433
+ var FS_stdin_getChar = () => {
497
434
  if (!FS_stdin_getChar_buffer.length) {
498
- let result = null;
499
- if (ENVIRONMENT_IS_NODE) {
500
- const BUFSIZE = 256;
501
- const buf = Buffer.alloc(BUFSIZE);
502
- let bytesRead = 0;
503
- const fd = process.stdin.fd;
504
- try {
505
- bytesRead = fs.readSync(fd, buf, 0, BUFSIZE);
506
- } catch (e) {
507
- if (e.toString().includes("EOF")) bytesRead = 0;
508
- else throw e;
509
- }
510
- if (bytesRead > 0) result = buf.slice(0, bytesRead).toString("utf-8");
511
- } else if (globalThis.window?.prompt) {
435
+ var result = null;
436
+ if (globalThis.window?.prompt) {
512
437
  result = window.prompt("Input: ");
513
438
  if (result !== null) result += "\n";
514
439
  }
@@ -531,7 +456,7 @@ async function createRimeModule(moduleArg = {}) {
531
456
  },
532
457
  stream_ops: {
533
458
  open(stream) {
534
- const tty = TTY.ttys[stream.node.rdev];
459
+ var tty = TTY.ttys[stream.node.rdev];
535
460
  if (!tty) throw new FS.ErrnoError(43);
536
461
  stream.tty = tty;
537
462
  stream.seekable = false;
@@ -544,8 +469,8 @@ async function createRimeModule(moduleArg = {}) {
544
469
  },
545
470
  read(stream, buffer, offset, length, pos) {
546
471
  if (!stream.tty || !stream.tty.ops.get_char) throw new FS.ErrnoError(60);
547
- let bytesRead = 0;
548
- for (let i = 0; i < length; i++) {
472
+ var bytesRead = 0;
473
+ for (var i = 0; i < length; i++) {
549
474
  var result;
550
475
  try {
551
476
  result = stream.tty.ops.get_char(stream.tty);
@@ -651,11 +576,11 @@ async function createRimeModule(moduleArg = {}) {
651
576
  }
652
577
  }
653
578
  };
654
- const zeroMemory = (ptr, size) => HEAPU8.fill(0, ptr, ptr + size);
655
- const alignMemory = (size, alignment) => Math.ceil(size / alignment) * alignment;
656
- const mmapAlloc = (size) => {
579
+ var zeroMemory = (ptr, size) => HEAPU8.fill(0, ptr, ptr + size);
580
+ var alignMemory = (size, alignment) => Math.ceil(size / alignment) * alignment;
581
+ var mmapAlloc = (size) => {
657
582
  size = alignMemory(size, 65536);
658
- const ptr = _emscripten_builtin_memalign(65536, size);
583
+ var ptr = _emscripten_builtin_memalign(65536, size);
659
584
  if (ptr) zeroMemory(ptr, size);
660
585
  return ptr;
661
586
  };
@@ -710,7 +635,7 @@ async function createRimeModule(moduleArg = {}) {
710
635
  stream: FS.chrdev_stream_ops
711
636
  }
712
637
  };
713
- const node = FS.createNode(parent, name, mode, dev);
638
+ var node = FS.createNode(parent, name, mode, dev);
714
639
  if (FS.isDir(node.mode)) {
715
640
  node.node_ops = MEMFS.ops_table.dir.node;
716
641
  node.stream_ops = MEMFS.ops_table.dir.stream;
@@ -740,12 +665,12 @@ async function createRimeModule(moduleArg = {}) {
740
665
  return new Uint8Array(node.contents);
741
666
  },
742
667
  expandFileStorage(node, newCapacity) {
743
- const prevCapacity = node.contents ? node.contents.length : 0;
668
+ var prevCapacity = node.contents ? node.contents.length : 0;
744
669
  if (prevCapacity >= newCapacity) return;
745
- const CAPACITY_DOUBLING_MAX = 1024 * 1024;
670
+ var CAPACITY_DOUBLING_MAX = 1024 * 1024;
746
671
  newCapacity = Math.max(newCapacity, prevCapacity * (prevCapacity < CAPACITY_DOUBLING_MAX ? 2 : 1.125) >>> 0);
747
672
  if (prevCapacity != 0) newCapacity = Math.max(newCapacity, 256);
748
- const oldContents = node.contents;
673
+ var oldContents = node.contents;
749
674
  node.contents = new Uint8Array(newCapacity);
750
675
  if (node.usedBytes > 0) node.contents.set(oldContents.subarray(0, node.usedBytes), 0);
751
676
  },
@@ -755,7 +680,7 @@ async function createRimeModule(moduleArg = {}) {
755
680
  node.contents = null;
756
681
  node.usedBytes = 0;
757
682
  } else {
758
- const oldContents = node.contents;
683
+ var oldContents = node.contents;
759
684
  node.contents = new Uint8Array(newSize);
760
685
  if (oldContents) node.contents.set(oldContents.subarray(0, Math.min(newSize, node.usedBytes)));
761
686
  node.usedBytes = newSize;
@@ -763,7 +688,7 @@ async function createRimeModule(moduleArg = {}) {
763
688
  },
764
689
  node_ops: {
765
690
  getattr(node) {
766
- const attr = {};
691
+ var attr = {};
767
692
  attr.dev = FS.isChrdev(node.mode) ? node.id : 1;
768
693
  attr.ino = node.id;
769
694
  attr.mode = node.mode;
@@ -802,12 +727,12 @@ async function createRimeModule(moduleArg = {}) {
802
727
  return MEMFS.createNode(parent, name, mode, dev);
803
728
  },
804
729
  rename(old_node, new_dir, new_name) {
805
- let new_node;
730
+ var new_node;
806
731
  try {
807
732
  new_node = FS.lookupNode(new_dir, new_name);
808
733
  } catch (e) {}
809
734
  if (new_node) {
810
- if (FS.isDir(old_node.mode)) for (const i in new_node.contents) throw new FS.ErrnoError(55);
735
+ if (FS.isDir(old_node.mode)) for (var i in new_node.contents) throw new FS.ErrnoError(55);
811
736
  FS.hashRemoveNode(new_node);
812
737
  }
813
738
  delete old_node.parent.contents[old_node.name];
@@ -820,8 +745,8 @@ async function createRimeModule(moduleArg = {}) {
820
745
  parent.ctime = parent.mtime = Date.now();
821
746
  },
822
747
  rmdir(parent, name) {
823
- const node = FS.lookupNode(parent, name);
824
- for (const i in node.contents) throw new FS.ErrnoError(55);
748
+ var node = FS.lookupNode(parent, name);
749
+ for (var i in node.contents) throw new FS.ErrnoError(55);
825
750
  delete parent.contents[name];
826
751
  parent.ctime = parent.mtime = Date.now();
827
752
  },
@@ -833,7 +758,7 @@ async function createRimeModule(moduleArg = {}) {
833
758
  ];
834
759
  },
835
760
  symlink(parent, newname, oldpath) {
836
- const node = MEMFS.createNode(parent, newname, 41471, 0);
761
+ var node = MEMFS.createNode(parent, newname, 41471, 0);
837
762
  node.link = oldpath;
838
763
  return node;
839
764
  },
@@ -844,17 +769,17 @@ async function createRimeModule(moduleArg = {}) {
844
769
  },
845
770
  stream_ops: {
846
771
  read(stream, buffer, offset, length, position) {
847
- const contents = stream.node.contents;
772
+ var contents = stream.node.contents;
848
773
  if (position >= stream.node.usedBytes) return 0;
849
- const size = Math.min(stream.node.usedBytes - position, length);
774
+ var size = Math.min(stream.node.usedBytes - position, length);
850
775
  if (size > 8 && contents.subarray) buffer.set(contents.subarray(position, position + size), offset);
851
- else for (let i = 0; i < size; i++) buffer[offset + i] = contents[position + i];
776
+ else for (var i = 0; i < size; i++) buffer[offset + i] = contents[position + i];
852
777
  return size;
853
778
  },
854
779
  write(stream, buffer, offset, length, position, canOwn) {
855
780
  if (buffer.buffer === HEAP8.buffer) canOwn = false;
856
781
  if (!length) return 0;
857
- const node = stream.node;
782
+ var node = stream.node;
858
783
  node.mtime = node.ctime = Date.now();
859
784
  if (buffer.subarray && (!node.contents || node.contents.subarray)) {
860
785
  if (canOwn) {
@@ -872,12 +797,12 @@ async function createRimeModule(moduleArg = {}) {
872
797
  }
873
798
  MEMFS.expandFileStorage(node, position + length);
874
799
  if (node.contents.subarray && buffer.subarray) node.contents.set(buffer.subarray(offset, offset + length), position);
875
- else for (let i = 0; i < length; i++) node.contents[position + i] = buffer[offset + i];
800
+ else for (var i = 0; i < length; i++) node.contents[position + i] = buffer[offset + i];
876
801
  node.usedBytes = Math.max(node.usedBytes, position + length);
877
802
  return length;
878
803
  },
879
804
  llseek(stream, offset, whence) {
880
- let position = offset;
805
+ var position = offset;
881
806
  if (whence === 1) position += stream.position;
882
807
  else if (whence === 2) {
883
808
  if (FS.isFile(stream.node.mode)) position += stream.node.usedBytes;
@@ -887,9 +812,9 @@ async function createRimeModule(moduleArg = {}) {
887
812
  },
888
813
  mmap(stream, length, position, prot, flags) {
889
814
  if (!FS.isFile(stream.node.mode)) throw new FS.ErrnoError(43);
890
- let ptr;
891
- let allocated;
892
- let contents = stream.node.contents;
815
+ var ptr;
816
+ var allocated;
817
+ var contents = stream.node.contents;
893
818
  if (!(flags & 2) && contents && contents.buffer === HEAP8.buffer) {
894
819
  allocated = false;
895
820
  ptr = contents.byteOffset;
@@ -914,21 +839,21 @@ async function createRimeModule(moduleArg = {}) {
914
839
  }
915
840
  }
916
841
  };
917
- const FS_modeStringToFlags = (str) => {
918
- const flagModes = {
919
- "r": 0,
842
+ var FS_modeStringToFlags = (str) => {
843
+ var flagModes = {
844
+ r: 0,
920
845
  "r+": 2,
921
- "w": 577,
846
+ w: 577,
922
847
  "w+": 578,
923
- "a": 1089,
848
+ a: 1089,
924
849
  "a+": 1090
925
850
  };
926
- const flags = flagModes[str];
927
- if (typeof flags == "undefined") throw new TypeError(`Unknown file open mode: ${str}`);
851
+ var flags = flagModes[str];
852
+ if (typeof flags == "undefined") throw new Error(`Unknown file open mode: ${str}`);
928
853
  return flags;
929
854
  };
930
- const FS_getMode = (canRead, canWrite) => {
931
- let mode = 0;
855
+ var FS_getMode = (canRead, canWrite) => {
856
+ var mode = 0;
932
857
  if (canRead) mode |= 365;
933
858
  if (canWrite) mode |= 146;
934
859
  return mode;
@@ -951,13 +876,13 @@ async function createRimeModule(moduleArg = {}) {
951
876
  else if (mount.idbPersistState === "idb") mount.idbPersistState = "again";
952
877
  },
953
878
  mount: (mount) => {
954
- const mnt = MEMFS.mount(mount);
879
+ var mnt = MEMFS.mount(mount);
955
880
  if (mount?.opts?.autoPersist) {
956
881
  mount.idbPersistState = 0;
957
- const memfs_node_ops = mnt.node_ops;
882
+ var memfs_node_ops = mnt.node_ops;
958
883
  mnt.node_ops = { ...mnt.node_ops };
959
884
  mnt.node_ops.mknod = (parent, name, mode, dev) => {
960
- const node = memfs_node_ops.mknod(parent, name, mode, dev);
885
+ var node = memfs_node_ops.mknod(parent, name, mode, dev);
961
886
  node.node_ops = mnt.node_ops;
962
887
  node.idbfs_mount = mnt.mount;
963
888
  node.memfs_stream_ops = node.stream_ops;
@@ -967,7 +892,7 @@ async function createRimeModule(moduleArg = {}) {
967
892
  return node.memfs_stream_ops.write(stream, buffer, offset, length, position, canOwn);
968
893
  };
969
894
  node.stream_ops.close = (stream) => {
970
- const n = stream.node;
895
+ var n = stream.node;
971
896
  if (n.isModified) {
972
897
  IDBFS.queuePersist(n.idbfs_mount);
973
898
  n.isModified = false;
@@ -989,20 +914,20 @@ async function createRimeModule(moduleArg = {}) {
989
914
  if (err$1) return callback(err$1);
990
915
  IDBFS.getRemoteSet(mount, (err$2, remote) => {
991
916
  if (err$2) return callback(err$2);
992
- const src = populate ? remote : local;
993
- const dst = populate ? local : remote;
917
+ var src = populate ? remote : local;
918
+ var dst = populate ? local : remote;
994
919
  IDBFS.reconcile(src, dst, callback);
995
920
  });
996
921
  });
997
922
  },
998
923
  quit: () => {
999
- for (const value of Object.values(IDBFS.dbs)) value.close();
924
+ for (var value of Object.values(IDBFS.dbs)) value.close();
1000
925
  IDBFS.dbs = {};
1001
926
  },
1002
927
  getDB: (name, callback) => {
1003
- let db = IDBFS.dbs[name];
928
+ var db = IDBFS.dbs[name];
1004
929
  if (db) return callback(null, db);
1005
- let req;
930
+ var req;
1006
931
  try {
1007
932
  req = IDBFS.indexedDB().open(name, IDBFS.DB_VERSION);
1008
933
  } catch (e) {
@@ -1010,9 +935,9 @@ async function createRimeModule(moduleArg = {}) {
1010
935
  }
1011
936
  if (!req) return callback("Unable to connect to IndexedDB");
1012
937
  req.onupgradeneeded = (e) => {
1013
- const db$1 = e.target.result;
1014
- const transaction = e.target.transaction;
1015
- let fileStore;
938
+ var db$1 = e.target.result;
939
+ var transaction = e.target.transaction;
940
+ var fileStore;
1016
941
  if (db$1.objectStoreNames.contains(IDBFS.DB_STORE_NAME)) fileStore = transaction.objectStore(IDBFS.DB_STORE_NAME);
1017
942
  else fileStore = db$1.createObjectStore(IDBFS.DB_STORE_NAME);
1018
943
  if (!fileStore.indexNames.contains("timestamp")) fileStore.createIndex("timestamp", "timestamp", { unique: false });
@@ -1028,16 +953,16 @@ async function createRimeModule(moduleArg = {}) {
1028
953
  };
1029
954
  },
1030
955
  getLocalSet: (mount, callback) => {
1031
- const entries = {};
956
+ var entries = {};
1032
957
  function isRealDir(p) {
1033
958
  return p !== "." && p !== "..";
1034
959
  }
1035
960
  function toAbsolute(root) {
1036
961
  return (p) => PATH.join2(root, p);
1037
962
  }
1038
- const check = FS.readdir(mount.mountpoint).filter(isRealDir).map(toAbsolute(mount.mountpoint));
963
+ var check = FS.readdir(mount.mountpoint).filter(isRealDir).map(toAbsolute(mount.mountpoint));
1039
964
  while (check.length) {
1040
- const path = check.pop();
965
+ var path = check.pop();
1041
966
  var stat;
1042
967
  try {
1043
968
  stat = FS.stat(path);
@@ -1053,19 +978,19 @@ async function createRimeModule(moduleArg = {}) {
1053
978
  });
1054
979
  },
1055
980
  getRemoteSet: (mount, callback) => {
1056
- const entries = {};
981
+ var entries = {};
1057
982
  IDBFS.getDB(mount.mountpoint, (err$1, db) => {
1058
983
  if (err$1) return callback(err$1);
1059
984
  try {
1060
- const transaction = db.transaction([IDBFS.DB_STORE_NAME], "readonly");
985
+ var transaction = db.transaction([IDBFS.DB_STORE_NAME], "readonly");
1061
986
  transaction.onerror = (e) => {
1062
987
  callback(e.target.error);
1063
988
  e.preventDefault();
1064
989
  };
1065
- const store = transaction.objectStore(IDBFS.DB_STORE_NAME);
1066
- const index = store.index("timestamp");
990
+ var store = transaction.objectStore(IDBFS.DB_STORE_NAME);
991
+ var index = store.index("timestamp");
1067
992
  index.openKeyCursor().onsuccess = (event) => {
1068
- const cursor = event.target.result;
993
+ var cursor = event.target.result;
1069
994
  if (!cursor) return callback(null, {
1070
995
  type: "remote",
1071
996
  db,
@@ -1080,9 +1005,9 @@ async function createRimeModule(moduleArg = {}) {
1080
1005
  });
1081
1006
  },
1082
1007
  loadLocalEntry: (path, callback) => {
1083
- let stat, node;
1008
+ var stat, node;
1084
1009
  try {
1085
- const lookup = FS.lookupPath(path);
1010
+ var lookup = FS.lookupPath(path);
1086
1011
  node = lookup.node;
1087
1012
  stat = FS.stat(path);
1088
1013
  } catch (e) {
@@ -1103,11 +1028,11 @@ async function createRimeModule(moduleArg = {}) {
1103
1028
  },
1104
1029
  storeLocalEntry: (path, entry, callback) => {
1105
1030
  try {
1106
- if (FS.isDir(entry.mode)) FS.mkdirTree(path, entry.mode);
1107
- else if (FS.isFile(entry.mode)) FS.writeFile(path, entry.contents, { canOwn: true });
1031
+ if (FS.isDir(entry["mode"])) FS.mkdirTree(path, entry["mode"]);
1032
+ else if (FS.isFile(entry["mode"])) FS.writeFile(path, entry["contents"], { canOwn: true });
1108
1033
  else return callback(new Error("node type not supported"));
1109
- FS.chmod(path, entry.mode);
1110
- FS.utime(path, entry.timestamp, entry.timestamp);
1034
+ FS.chmod(path, entry["mode"]);
1035
+ FS.utime(path, entry["timestamp"], entry["timestamp"]);
1111
1036
  } catch (e) {
1112
1037
  return callback(e);
1113
1038
  }
@@ -1115,7 +1040,7 @@ async function createRimeModule(moduleArg = {}) {
1115
1040
  },
1116
1041
  removeLocalEntry: (path, callback) => {
1117
1042
  try {
1118
- const stat = FS.stat(path);
1043
+ var stat = FS.stat(path);
1119
1044
  if (FS.isDir(stat.mode)) FS.rmdir(path);
1120
1045
  else if (FS.isFile(stat.mode)) FS.unlink(path);
1121
1046
  } catch (e) {
@@ -1124,7 +1049,7 @@ async function createRimeModule(moduleArg = {}) {
1124
1049
  callback(null);
1125
1050
  },
1126
1051
  loadRemoteEntry: (store, path, callback) => {
1127
- const req = store.get(path);
1052
+ var req = store.get(path);
1128
1053
  req.onsuccess = (event) => callback(null, event.target.result);
1129
1054
  req.onerror = (e) => {
1130
1055
  callback(e.target.error);
@@ -1145,7 +1070,7 @@ async function createRimeModule(moduleArg = {}) {
1145
1070
  };
1146
1071
  },
1147
1072
  removeRemoteEntry: (store, path, callback) => {
1148
- const req = store.delete(path);
1073
+ var req = store.delete(path);
1149
1074
  req.onsuccess = (event) => callback();
1150
1075
  req.onerror = (e) => {
1151
1076
  callback(e.target.error);
@@ -1153,25 +1078,25 @@ async function createRimeModule(moduleArg = {}) {
1153
1078
  };
1154
1079
  },
1155
1080
  reconcile: (src, dst, callback) => {
1156
- let total = 0;
1157
- const create = [];
1081
+ var total = 0;
1082
+ var create = [];
1158
1083
  for (var [key, e] of Object.entries(src.entries)) {
1159
- const e2 = dst.entries[key];
1160
- if (!e2 || e.timestamp.getTime() != e2.timestamp.getTime()) {
1084
+ var e2 = dst.entries[key];
1085
+ if (!e2 || e["timestamp"].getTime() != e2["timestamp"].getTime()) {
1161
1086
  create.push(key);
1162
1087
  total++;
1163
1088
  }
1164
1089
  }
1165
- const remove = [];
1090
+ var remove = [];
1166
1091
  for (var key of Object.keys(dst.entries)) if (!src.entries[key]) {
1167
1092
  remove.push(key);
1168
1093
  total++;
1169
1094
  }
1170
1095
  if (!total) return callback(null);
1171
- let errored = false;
1172
- const db = src.type === "remote" ? src.db : dst.db;
1173
- const transaction = db.transaction([IDBFS.DB_STORE_NAME], "readwrite");
1174
- const store = transaction.objectStore(IDBFS.DB_STORE_NAME);
1096
+ var errored = false;
1097
+ var db = src.type === "remote" ? src.db : dst.db;
1098
+ var transaction = db.transaction([IDBFS.DB_STORE_NAME], "readwrite");
1099
+ var store = transaction.objectStore(IDBFS.DB_STORE_NAME);
1175
1100
  function done(err$1) {
1176
1101
  if (err$1 && !errored) {
1177
1102
  errored = true;
@@ -1185,53 +1110,53 @@ async function createRimeModule(moduleArg = {}) {
1185
1110
  transaction.oncomplete = (e$1) => {
1186
1111
  if (!errored) callback(null);
1187
1112
  };
1188
- for (const path of create.sort()) if (dst.type === "local") IDBFS.loadRemoteEntry(store, path, (err$1, entry) => {
1113
+ for (const path$1 of create.sort()) if (dst.type === "local") IDBFS.loadRemoteEntry(store, path$1, (err$1, entry) => {
1189
1114
  if (err$1) return done(err$1);
1190
- IDBFS.storeLocalEntry(path, entry, done);
1115
+ IDBFS.storeLocalEntry(path$1, entry, done);
1191
1116
  });
1192
- else IDBFS.loadLocalEntry(path, (err$1, entry) => {
1117
+ else IDBFS.loadLocalEntry(path$1, (err$1, entry) => {
1193
1118
  if (err$1) return done(err$1);
1194
- IDBFS.storeRemoteEntry(store, path, entry, done);
1119
+ IDBFS.storeRemoteEntry(store, path$1, entry, done);
1195
1120
  });
1196
- for (const path of remove.sort().reverse()) if (dst.type === "local") IDBFS.removeLocalEntry(path, done);
1121
+ for (var path of remove.sort().reverse()) if (dst.type === "local") IDBFS.removeLocalEntry(path, done);
1197
1122
  else IDBFS.removeRemoteEntry(store, path, done);
1198
1123
  }
1199
1124
  };
1200
- const asyncLoad = async (url) => {
1201
- const arrayBuffer = await readAsync(url);
1125
+ var asyncLoad = async (url) => {
1126
+ var arrayBuffer = await readAsync(url);
1202
1127
  return new Uint8Array(arrayBuffer);
1203
1128
  };
1204
- const FS_createDataFile = (...args) => FS.createDataFile(...args);
1205
- const getUniqueRunDependency = (id) => id;
1206
- let runDependencies = 0;
1207
- let dependenciesFulfilled = null;
1208
- const removeRunDependency = (id) => {
1129
+ var FS_createDataFile = (...args) => FS.createDataFile(...args);
1130
+ var getUniqueRunDependency = (id) => id;
1131
+ var runDependencies = 0;
1132
+ var dependenciesFulfilled = null;
1133
+ var removeRunDependency = (id) => {
1209
1134
  runDependencies--;
1210
- Module.monitorRunDependencies?.(runDependencies);
1135
+ Module["monitorRunDependencies"]?.(runDependencies);
1211
1136
  if (runDependencies == 0) {
1212
1137
  if (dependenciesFulfilled) {
1213
- const callback = dependenciesFulfilled;
1138
+ var callback = dependenciesFulfilled;
1214
1139
  dependenciesFulfilled = null;
1215
1140
  callback();
1216
1141
  }
1217
1142
  }
1218
1143
  };
1219
- const addRunDependency = (id) => {
1144
+ var addRunDependency = (id) => {
1220
1145
  runDependencies++;
1221
- Module.monitorRunDependencies?.(runDependencies);
1146
+ Module["monitorRunDependencies"]?.(runDependencies);
1222
1147
  };
1223
- let preloadPlugins = [];
1224
- const FS_handledByPreloadPlugin = async (byteArray, fullname) => {
1148
+ var preloadPlugins = [];
1149
+ var FS_handledByPreloadPlugin = async (byteArray, fullname) => {
1225
1150
  if (typeof Browser != "undefined") Browser.init();
1226
- for (const plugin of preloadPlugins) if (plugin.canHandle(fullname)) return plugin.handle(byteArray, fullname);
1151
+ for (var plugin of preloadPlugins) if (plugin["canHandle"](fullname)) return plugin["handle"](byteArray, fullname);
1227
1152
  return byteArray;
1228
1153
  };
1229
- const FS_preloadFile = async (parent, name, url, canRead, canWrite, dontCreateFile, canOwn, preFinish) => {
1230
- const fullname = name ? PATH_FS.resolve(PATH.join2(parent, name)) : parent;
1231
- const dep = getUniqueRunDependency(`cp ${fullname}`);
1154
+ var FS_preloadFile = async (parent, name, url, canRead, canWrite, dontCreateFile, canOwn, preFinish) => {
1155
+ var fullname = name ? PATH_FS.resolve(PATH.join2(parent, name)) : parent;
1156
+ var dep = getUniqueRunDependency(`cp ${fullname}`);
1232
1157
  addRunDependency(dep);
1233
1158
  try {
1234
- let byteArray = url;
1159
+ var byteArray = url;
1235
1160
  if (typeof url == "string") byteArray = await asyncLoad(url);
1236
1161
  byteArray = await FS_handledByPreloadPlugin(byteArray, fullname);
1237
1162
  preFinish?.();
@@ -1240,7 +1165,7 @@ async function createRimeModule(moduleArg = {}) {
1240
1165
  removeRunDependency(dep);
1241
1166
  }
1242
1167
  };
1243
- const FS_createPreloadedFile = (parent, name, url, canRead, canWrite, onload, onerror, dontCreateFile, canOwn, preFinish) => {
1168
+ var FS_createPreloadedFile = (parent, name, url, canRead, canWrite, onload, onerror, dontCreateFile, canOwn, preFinish) => {
1244
1169
  FS_preloadFile(parent, name, url, canRead, canWrite, dontCreateFile, canOwn, preFinish).then(onload).catch(onerror);
1245
1170
  };
1246
1171
  var FS = {
@@ -1329,19 +1254,19 @@ async function createRimeModule(moduleArg = {}) {
1329
1254
  lookupPath(path, opts = {}) {
1330
1255
  if (!path) throw new FS.ErrnoError(44);
1331
1256
  opts.follow_mount ??= true;
1332
- if (!PATH.isAbs(path)) path = `${FS.cwd()}/${path}`;
1333
- linkloop: for (let nlinks = 0; nlinks < 40; nlinks++) {
1334
- const parts = path.split("/").filter((p) => !!p);
1335
- let current = FS.root;
1336
- let current_path = "/";
1337
- for (let i = 0; i < parts.length; i++) {
1338
- const islast = i === parts.length - 1;
1257
+ if (!PATH.isAbs(path)) path = FS.cwd() + "/" + path;
1258
+ linkloop: for (var nlinks = 0; nlinks < 40; nlinks++) {
1259
+ var parts = path.split("/").filter((p) => !!p);
1260
+ var current = FS.root;
1261
+ var current_path = "/";
1262
+ for (var i = 0; i < parts.length; i++) {
1263
+ var islast = i === parts.length - 1;
1339
1264
  if (islast && opts.parent) break;
1340
1265
  if (parts[i] === ".") continue;
1341
1266
  if (parts[i] === "..") {
1342
1267
  current_path = PATH.dirname(current_path);
1343
1268
  if (FS.isRoot(current)) {
1344
- path = `${current_path}/${parts.slice(i + 1).join("/")}`;
1269
+ path = current_path + "/" + parts.slice(i + 1).join("/");
1345
1270
  nlinks--;
1346
1271
  continue linkloop;
1347
1272
  } else current = current.parent;
@@ -1357,9 +1282,9 @@ async function createRimeModule(moduleArg = {}) {
1357
1282
  if (FS.isMountpoint(current) && (!islast || opts.follow_mount)) current = current.mounted.root;
1358
1283
  if (FS.isLink(current.mode) && (!islast || opts.follow)) {
1359
1284
  if (!current.node_ops.readlink) throw new FS.ErrnoError(52);
1360
- let link = current.node_ops.readlink(current);
1361
- if (!PATH.isAbs(link)) link = `${PATH.dirname(current_path)}/${link}`;
1362
- path = `${link}/${parts.slice(i + 1).join("/")}`;
1285
+ var link = current.node_ops.readlink(current);
1286
+ if (!PATH.isAbs(link)) link = PATH.dirname(current_path) + "/" + link;
1287
+ path = link + "/" + parts.slice(i + 1).join("/");
1363
1288
  continue linkloop;
1364
1289
  }
1365
1290
  }
@@ -1371,10 +1296,10 @@ async function createRimeModule(moduleArg = {}) {
1371
1296
  throw new FS.ErrnoError(32);
1372
1297
  },
1373
1298
  getPath(node) {
1374
- let path;
1299
+ var path;
1375
1300
  while (true) {
1376
1301
  if (FS.isRoot(node)) {
1377
- const mount = node.mount.mountpoint;
1302
+ var mount = node.mount.mountpoint;
1378
1303
  if (!path) return mount;
1379
1304
  return mount[mount.length - 1] !== "/" ? `${mount}/${path}` : mount + path;
1380
1305
  }
@@ -1383,20 +1308,20 @@ async function createRimeModule(moduleArg = {}) {
1383
1308
  }
1384
1309
  },
1385
1310
  hashName(parentid, name) {
1386
- let hash = 0;
1387
- for (let i = 0; i < name.length; i++) hash = (hash << 5) - hash + name.charCodeAt(i) | 0;
1311
+ var hash = 0;
1312
+ for (var i = 0; i < name.length; i++) hash = (hash << 5) - hash + name.charCodeAt(i) | 0;
1388
1313
  return (parentid + hash >>> 0) % FS.nameTable.length;
1389
1314
  },
1390
1315
  hashAddNode(node) {
1391
- const hash = FS.hashName(node.parent.id, node.name);
1316
+ var hash = FS.hashName(node.parent.id, node.name);
1392
1317
  node.name_next = FS.nameTable[hash];
1393
1318
  FS.nameTable[hash] = node;
1394
1319
  },
1395
1320
  hashRemoveNode(node) {
1396
- const hash = FS.hashName(node.parent.id, node.name);
1321
+ var hash = FS.hashName(node.parent.id, node.name);
1397
1322
  if (FS.nameTable[hash] === node) FS.nameTable[hash] = node.name_next;
1398
1323
  else {
1399
- let current = FS.nameTable[hash];
1324
+ var current = FS.nameTable[hash];
1400
1325
  while (current) {
1401
1326
  if (current.name_next === node) {
1402
1327
  current.name_next = node.name_next;
@@ -1407,17 +1332,17 @@ async function createRimeModule(moduleArg = {}) {
1407
1332
  }
1408
1333
  },
1409
1334
  lookupNode(parent, name) {
1410
- const errCode = FS.mayLookup(parent);
1335
+ var errCode = FS.mayLookup(parent);
1411
1336
  if (errCode) throw new FS.ErrnoError(errCode);
1412
- const hash = FS.hashName(parent.id, name);
1413
- for (let node = FS.nameTable[hash]; node; node = node.name_next) {
1414
- const nodeName = node.name;
1337
+ var hash = FS.hashName(parent.id, name);
1338
+ for (var node = FS.nameTable[hash]; node; node = node.name_next) {
1339
+ var nodeName = node.name;
1415
1340
  if (node.parent.id === parent.id && nodeName === name) return node;
1416
1341
  }
1417
1342
  return FS.lookup(parent, name);
1418
1343
  },
1419
1344
  createNode(parent, name, mode, rdev) {
1420
- const node = new FS.FSNode(parent, name, mode, rdev);
1345
+ var node = new FS.FSNode(parent, name, mode, rdev);
1421
1346
  FS.hashAddNode(node);
1422
1347
  return node;
1423
1348
  },
@@ -1452,7 +1377,7 @@ async function createRimeModule(moduleArg = {}) {
1452
1377
  return (mode & 49152) === 49152;
1453
1378
  },
1454
1379
  flagsToPermissionString(flag) {
1455
- let perms = [
1380
+ var perms = [
1456
1381
  "r",
1457
1382
  "w",
1458
1383
  "rw"
@@ -1469,7 +1394,7 @@ async function createRimeModule(moduleArg = {}) {
1469
1394
  },
1470
1395
  mayLookup(dir) {
1471
1396
  if (!FS.isDir(dir.mode)) return 54;
1472
- const errCode = FS.nodePermissions(dir, "x");
1397
+ var errCode = FS.nodePermissions(dir, "x");
1473
1398
  if (errCode) return errCode;
1474
1399
  if (!dir.node_ops.lookup) return 2;
1475
1400
  return 0;
@@ -1477,19 +1402,19 @@ async function createRimeModule(moduleArg = {}) {
1477
1402
  mayCreate(dir, name) {
1478
1403
  if (!FS.isDir(dir.mode)) return 54;
1479
1404
  try {
1480
- const node = FS.lookupNode(dir, name);
1405
+ var node = FS.lookupNode(dir, name);
1481
1406
  return 20;
1482
1407
  } catch (e) {}
1483
1408
  return FS.nodePermissions(dir, "wx");
1484
1409
  },
1485
1410
  mayDelete(dir, name, isdir) {
1486
- let node;
1411
+ var node;
1487
1412
  try {
1488
1413
  node = FS.lookupNode(dir, name);
1489
1414
  } catch (e) {
1490
1415
  return e.errno;
1491
1416
  }
1492
- const errCode = FS.nodePermissions(dir, "wx");
1417
+ var errCode = FS.nodePermissions(dir, "wx");
1493
1418
  if (errCode) return errCode;
1494
1419
  if (isdir) {
1495
1420
  if (!FS.isDir(node.mode)) return 54;
@@ -1500,7 +1425,7 @@ async function createRimeModule(moduleArg = {}) {
1500
1425
  mayOpen(node, flags) {
1501
1426
  if (!node) return 44;
1502
1427
  if (FS.isLink(node.mode)) return 32;
1503
- const mode = FS.flagsToPermissionString(flags);
1428
+ var mode = FS.flagsToPermissionString(flags);
1504
1429
  if (FS.isDir(node.mode)) {
1505
1430
  if (mode !== "r" || flags & 576) return 31;
1506
1431
  }
@@ -1512,11 +1437,11 @@ async function createRimeModule(moduleArg = {}) {
1512
1437
  },
1513
1438
  MAX_OPEN_FDS: 4096,
1514
1439
  nextfd() {
1515
- for (let fd = 0; fd <= FS.MAX_OPEN_FDS; fd++) if (!FS.streams[fd]) return fd;
1440
+ for (var fd = 0; fd <= FS.MAX_OPEN_FDS; fd++) if (!FS.streams[fd]) return fd;
1516
1441
  throw new FS.ErrnoError(33);
1517
1442
  },
1518
1443
  getStreamChecked(fd) {
1519
- const stream = FS.getStream(fd);
1444
+ var stream = FS.getStream(fd);
1520
1445
  if (!stream) throw new FS.ErrnoError(8);
1521
1446
  return stream;
1522
1447
  },
@@ -1532,20 +1457,20 @@ async function createRimeModule(moduleArg = {}) {
1532
1457
  FS.streams[fd] = null;
1533
1458
  },
1534
1459
  dupStream(origStream, fd = -1) {
1535
- const stream = FS.createStream(origStream, fd);
1460
+ var stream = FS.createStream(origStream, fd);
1536
1461
  stream.stream_ops?.dup?.(stream);
1537
1462
  return stream;
1538
1463
  },
1539
1464
  doSetAttr(stream, node, attr) {
1540
- let setattr = stream?.stream_ops.setattr;
1541
- const arg = setattr ? stream : node;
1465
+ var setattr = stream?.stream_ops.setattr;
1466
+ var arg = setattr ? stream : node;
1542
1467
  setattr ??= node.node_ops.setattr;
1543
1468
  FS.checkOpExists(setattr, 63);
1544
1469
  setattr(arg, attr);
1545
1470
  },
1546
1471
  chrdev_stream_ops: {
1547
1472
  open(stream) {
1548
- const device = FS.getDevice(stream.node.rdev);
1473
+ var device = FS.getDevice(stream.node.rdev);
1549
1474
  stream.stream_ops = device.stream_ops;
1550
1475
  stream.stream_ops.open?.(stream);
1551
1476
  },
@@ -1561,10 +1486,10 @@ async function createRimeModule(moduleArg = {}) {
1561
1486
  },
1562
1487
  getDevice: (dev) => FS.devices[dev],
1563
1488
  getMounts(mount) {
1564
- const mounts = [];
1565
- const check = [mount];
1489
+ var mounts = [];
1490
+ var check = [mount];
1566
1491
  while (check.length) {
1567
- const m = check.pop();
1492
+ var m = check.pop();
1568
1493
  mounts.push(m);
1569
1494
  check.push(...m.mounts);
1570
1495
  }
@@ -1577,8 +1502,8 @@ async function createRimeModule(moduleArg = {}) {
1577
1502
  }
1578
1503
  FS.syncFSRequests++;
1579
1504
  if (FS.syncFSRequests > 1) err(`warning: ${FS.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);
1580
- const mounts = FS.getMounts(FS.root.mount);
1581
- let completed = 0;
1505
+ var mounts = FS.getMounts(FS.root.mount);
1506
+ var completed = 0;
1582
1507
  function doCallback(errCode) {
1583
1508
  FS.syncFSRequests--;
1584
1509
  return callback(errCode);
@@ -1593,28 +1518,28 @@ async function createRimeModule(moduleArg = {}) {
1593
1518
  }
1594
1519
  if (++completed >= mounts.length) doCallback(null);
1595
1520
  }
1596
- for (const mount of mounts) if (mount.type.syncfs) mount.type.syncfs(mount, populate, done);
1521
+ for (var mount of mounts) if (mount.type.syncfs) mount.type.syncfs(mount, populate, done);
1597
1522
  else done(null);
1598
1523
  },
1599
1524
  mount(type, opts, mountpoint) {
1600
- const root = mountpoint === "/";
1601
- const pseudo = !mountpoint;
1602
- let node;
1525
+ var root = mountpoint === "/";
1526
+ var pseudo = !mountpoint;
1527
+ var node;
1603
1528
  if (root && FS.root) throw new FS.ErrnoError(10);
1604
1529
  else if (!root && !pseudo) {
1605
- const lookup = FS.lookupPath(mountpoint, { follow_mount: false });
1530
+ var lookup = FS.lookupPath(mountpoint, { follow_mount: false });
1606
1531
  mountpoint = lookup.path;
1607
1532
  node = lookup.node;
1608
1533
  if (FS.isMountpoint(node)) throw new FS.ErrnoError(10);
1609
1534
  if (!FS.isDir(node.mode)) throw new FS.ErrnoError(54);
1610
1535
  }
1611
- const mount = {
1536
+ var mount = {
1612
1537
  type,
1613
1538
  opts,
1614
1539
  mountpoint,
1615
1540
  mounts: []
1616
1541
  };
1617
- const mountRoot = type.mount(mount);
1542
+ var mountRoot = type.mount(mount);
1618
1543
  mountRoot.mount = mount;
1619
1544
  mount.root = mountRoot;
1620
1545
  if (root) FS.root = mountRoot;
@@ -1625,30 +1550,30 @@ async function createRimeModule(moduleArg = {}) {
1625
1550
  return mountRoot;
1626
1551
  },
1627
1552
  unmount(mountpoint) {
1628
- const lookup = FS.lookupPath(mountpoint, { follow_mount: false });
1553
+ var lookup = FS.lookupPath(mountpoint, { follow_mount: false });
1629
1554
  if (!FS.isMountpoint(lookup.node)) throw new FS.ErrnoError(28);
1630
- const node = lookup.node;
1631
- const mount = node.mounted;
1632
- const mounts = FS.getMounts(mount);
1633
- for (let [hash, current] of Object.entries(FS.nameTable)) while (current) {
1634
- const next = current.name_next;
1555
+ var node = lookup.node;
1556
+ var mount = node.mounted;
1557
+ var mounts = FS.getMounts(mount);
1558
+ for (var [hash, current] of Object.entries(FS.nameTable)) while (current) {
1559
+ var next = current.name_next;
1635
1560
  if (mounts.includes(current.mount)) FS.destroyNode(current);
1636
1561
  current = next;
1637
1562
  }
1638
1563
  node.mounted = null;
1639
- const idx = node.mount.mounts.indexOf(mount);
1564
+ var idx = node.mount.mounts.indexOf(mount);
1640
1565
  node.mount.mounts.splice(idx, 1);
1641
1566
  },
1642
1567
  lookup(parent, name) {
1643
1568
  return parent.node_ops.lookup(parent, name);
1644
1569
  },
1645
1570
  mknod(path, mode, dev) {
1646
- const lookup = FS.lookupPath(path, { parent: true });
1647
- const parent = lookup.node;
1648
- const name = PATH.basename(path);
1571
+ var lookup = FS.lookupPath(path, { parent: true });
1572
+ var parent = lookup.node;
1573
+ var name = PATH.basename(path);
1649
1574
  if (!name) throw new FS.ErrnoError(28);
1650
1575
  if (name === "." || name === "..") throw new FS.ErrnoError(20);
1651
- const errCode = FS.mayCreate(parent, name);
1576
+ var errCode = FS.mayCreate(parent, name);
1652
1577
  if (errCode) throw new FS.ErrnoError(errCode);
1653
1578
  if (!parent.node_ops.mknod) throw new FS.ErrnoError(63);
1654
1579
  return parent.node_ops.mknod(parent, name, mode, dev);
@@ -1660,7 +1585,7 @@ async function createRimeModule(moduleArg = {}) {
1660
1585
  return FS.statfsNode(stream.node);
1661
1586
  },
1662
1587
  statfsNode(node) {
1663
- const rtn = {
1588
+ var rtn = {
1664
1589
  bsize: 4096,
1665
1590
  frsize: 4096,
1666
1591
  blocks: 1e6,
@@ -1686,9 +1611,9 @@ async function createRimeModule(moduleArg = {}) {
1686
1611
  return FS.mknod(path, mode, 0);
1687
1612
  },
1688
1613
  mkdirTree(path, mode) {
1689
- const dirs = path.split("/");
1690
- let d = "";
1691
- for (const dir of dirs) {
1614
+ var dirs = path.split("/");
1615
+ var d = "";
1616
+ for (var dir of dirs) {
1692
1617
  if (!dir) continue;
1693
1618
  if (d || PATH.isAbs(path)) d += "/";
1694
1619
  d += dir;
@@ -1709,39 +1634,39 @@ async function createRimeModule(moduleArg = {}) {
1709
1634
  },
1710
1635
  symlink(oldpath, newpath) {
1711
1636
  if (!PATH_FS.resolve(oldpath)) throw new FS.ErrnoError(44);
1712
- const lookup = FS.lookupPath(newpath, { parent: true });
1713
- const parent = lookup.node;
1637
+ var lookup = FS.lookupPath(newpath, { parent: true });
1638
+ var parent = lookup.node;
1714
1639
  if (!parent) throw new FS.ErrnoError(44);
1715
- const newname = PATH.basename(newpath);
1716
- const errCode = FS.mayCreate(parent, newname);
1640
+ var newname = PATH.basename(newpath);
1641
+ var errCode = FS.mayCreate(parent, newname);
1717
1642
  if (errCode) throw new FS.ErrnoError(errCode);
1718
1643
  if (!parent.node_ops.symlink) throw new FS.ErrnoError(63);
1719
1644
  return parent.node_ops.symlink(parent, newname, oldpath);
1720
1645
  },
1721
1646
  rename(old_path, new_path) {
1722
- const old_dirname = PATH.dirname(old_path);
1723
- const new_dirname = PATH.dirname(new_path);
1724
- const old_name = PATH.basename(old_path);
1725
- const new_name = PATH.basename(new_path);
1726
- let lookup, old_dir, new_dir;
1647
+ var old_dirname = PATH.dirname(old_path);
1648
+ var new_dirname = PATH.dirname(new_path);
1649
+ var old_name = PATH.basename(old_path);
1650
+ var new_name = PATH.basename(new_path);
1651
+ var lookup, old_dir, new_dir;
1727
1652
  lookup = FS.lookupPath(old_path, { parent: true });
1728
1653
  old_dir = lookup.node;
1729
1654
  lookup = FS.lookupPath(new_path, { parent: true });
1730
1655
  new_dir = lookup.node;
1731
1656
  if (!old_dir || !new_dir) throw new FS.ErrnoError(44);
1732
1657
  if (old_dir.mount !== new_dir.mount) throw new FS.ErrnoError(75);
1733
- const old_node = FS.lookupNode(old_dir, old_name);
1734
- let relative = PATH_FS.relative(old_path, new_dirname);
1658
+ var old_node = FS.lookupNode(old_dir, old_name);
1659
+ var relative = PATH_FS.relative(old_path, new_dirname);
1735
1660
  if (relative.charAt(0) !== ".") throw new FS.ErrnoError(28);
1736
1661
  relative = PATH_FS.relative(new_path, old_dirname);
1737
1662
  if (relative.charAt(0) !== ".") throw new FS.ErrnoError(55);
1738
- let new_node;
1663
+ var new_node;
1739
1664
  try {
1740
1665
  new_node = FS.lookupNode(new_dir, new_name);
1741
1666
  } catch (e) {}
1742
1667
  if (old_node === new_node) return;
1743
- const isdir = FS.isDir(old_node.mode);
1744
- let errCode = FS.mayDelete(old_dir, old_name, isdir);
1668
+ var isdir = FS.isDir(old_node.mode);
1669
+ var errCode = FS.mayDelete(old_dir, old_name, isdir);
1745
1670
  if (errCode) throw new FS.ErrnoError(errCode);
1746
1671
  errCode = new_node ? FS.mayDelete(new_dir, new_name, isdir) : FS.mayCreate(new_dir, new_name);
1747
1672
  if (errCode) throw new FS.ErrnoError(errCode);
@@ -1762,11 +1687,11 @@ async function createRimeModule(moduleArg = {}) {
1762
1687
  }
1763
1688
  },
1764
1689
  rmdir(path) {
1765
- const lookup = FS.lookupPath(path, { parent: true });
1766
- const parent = lookup.node;
1767
- const name = PATH.basename(path);
1768
- const node = FS.lookupNode(parent, name);
1769
- const errCode = FS.mayDelete(parent, name, true);
1690
+ var lookup = FS.lookupPath(path, { parent: true });
1691
+ var parent = lookup.node;
1692
+ var name = PATH.basename(path);
1693
+ var node = FS.lookupNode(parent, name);
1694
+ var errCode = FS.mayDelete(parent, name, true);
1770
1695
  if (errCode) throw new FS.ErrnoError(errCode);
1771
1696
  if (!parent.node_ops.rmdir) throw new FS.ErrnoError(63);
1772
1697
  if (FS.isMountpoint(node)) throw new FS.ErrnoError(10);
@@ -1774,18 +1699,18 @@ async function createRimeModule(moduleArg = {}) {
1774
1699
  FS.destroyNode(node);
1775
1700
  },
1776
1701
  readdir(path) {
1777
- const lookup = FS.lookupPath(path, { follow: true });
1778
- const node = lookup.node;
1779
- const readdir = FS.checkOpExists(node.node_ops.readdir, 54);
1702
+ var lookup = FS.lookupPath(path, { follow: true });
1703
+ var node = lookup.node;
1704
+ var readdir = FS.checkOpExists(node.node_ops.readdir, 54);
1780
1705
  return readdir(node);
1781
1706
  },
1782
1707
  unlink(path) {
1783
- const lookup = FS.lookupPath(path, { parent: true });
1784
- const parent = lookup.node;
1708
+ var lookup = FS.lookupPath(path, { parent: true });
1709
+ var parent = lookup.node;
1785
1710
  if (!parent) throw new FS.ErrnoError(44);
1786
- const name = PATH.basename(path);
1787
- const node = FS.lookupNode(parent, name);
1788
- const errCode = FS.mayDelete(parent, name, false);
1711
+ var name = PATH.basename(path);
1712
+ var node = FS.lookupNode(parent, name);
1713
+ var errCode = FS.mayDelete(parent, name, false);
1789
1714
  if (errCode) throw new FS.ErrnoError(errCode);
1790
1715
  if (!parent.node_ops.unlink) throw new FS.ErrnoError(63);
1791
1716
  if (FS.isMountpoint(node)) throw new FS.ErrnoError(10);
@@ -1793,23 +1718,23 @@ async function createRimeModule(moduleArg = {}) {
1793
1718
  FS.destroyNode(node);
1794
1719
  },
1795
1720
  readlink(path) {
1796
- const lookup = FS.lookupPath(path);
1797
- const link = lookup.node;
1721
+ var lookup = FS.lookupPath(path);
1722
+ var link = lookup.node;
1798
1723
  if (!link) throw new FS.ErrnoError(44);
1799
1724
  if (!link.node_ops.readlink) throw new FS.ErrnoError(28);
1800
1725
  return link.node_ops.readlink(link);
1801
1726
  },
1802
1727
  stat(path, dontFollow) {
1803
- const lookup = FS.lookupPath(path, { follow: !dontFollow });
1804
- const node = lookup.node;
1805
- const getattr = FS.checkOpExists(node.node_ops.getattr, 63);
1728
+ var lookup = FS.lookupPath(path, { follow: !dontFollow });
1729
+ var node = lookup.node;
1730
+ var getattr = FS.checkOpExists(node.node_ops.getattr, 63);
1806
1731
  return getattr(node);
1807
1732
  },
1808
1733
  fstat(fd) {
1809
- const stream = FS.getStreamChecked(fd);
1810
- const node = stream.node;
1811
- let getattr = stream.stream_ops.getattr;
1812
- const arg = getattr ? stream : node;
1734
+ var stream = FS.getStreamChecked(fd);
1735
+ var node = stream.node;
1736
+ var getattr = stream.stream_ops.getattr;
1737
+ var arg = getattr ? stream : node;
1813
1738
  getattr ??= node.node_ops.getattr;
1814
1739
  FS.checkOpExists(getattr, 63);
1815
1740
  return getattr(arg);
@@ -1825,9 +1750,9 @@ async function createRimeModule(moduleArg = {}) {
1825
1750
  });
1826
1751
  },
1827
1752
  chmod(path, mode, dontFollow) {
1828
- let node;
1753
+ var node;
1829
1754
  if (typeof path == "string") {
1830
- const lookup = FS.lookupPath(path, { follow: !dontFollow });
1755
+ var lookup = FS.lookupPath(path, { follow: !dontFollow });
1831
1756
  node = lookup.node;
1832
1757
  } else node = path;
1833
1758
  FS.doChmod(null, node, mode, dontFollow);
@@ -1836,7 +1761,7 @@ async function createRimeModule(moduleArg = {}) {
1836
1761
  FS.chmod(path, mode, true);
1837
1762
  },
1838
1763
  fchmod(fd, mode) {
1839
- const stream = FS.getStreamChecked(fd);
1764
+ var stream = FS.getStreamChecked(fd);
1840
1765
  FS.doChmod(stream, stream.node, mode, false);
1841
1766
  },
1842
1767
  doChown(stream, node, dontFollow) {
@@ -1846,9 +1771,9 @@ async function createRimeModule(moduleArg = {}) {
1846
1771
  });
1847
1772
  },
1848
1773
  chown(path, uid, gid, dontFollow) {
1849
- let node;
1774
+ var node;
1850
1775
  if (typeof path == "string") {
1851
- const lookup = FS.lookupPath(path, { follow: !dontFollow });
1776
+ var lookup = FS.lookupPath(path, { follow: !dontFollow });
1852
1777
  node = lookup.node;
1853
1778
  } else node = path;
1854
1779
  FS.doChown(null, node, dontFollow);
@@ -1857,13 +1782,13 @@ async function createRimeModule(moduleArg = {}) {
1857
1782
  FS.chown(path, uid, gid, true);
1858
1783
  },
1859
1784
  fchown(fd, uid, gid) {
1860
- const stream = FS.getStreamChecked(fd);
1785
+ var stream = FS.getStreamChecked(fd);
1861
1786
  FS.doChown(stream, stream.node, false);
1862
1787
  },
1863
1788
  doTruncate(stream, node, len) {
1864
1789
  if (FS.isDir(node.mode)) throw new FS.ErrnoError(31);
1865
1790
  if (!FS.isFile(node.mode)) throw new FS.ErrnoError(28);
1866
- const errCode = FS.nodePermissions(node, "w");
1791
+ var errCode = FS.nodePermissions(node, "w");
1867
1792
  if (errCode) throw new FS.ErrnoError(errCode);
1868
1793
  FS.doSetAttr(stream, node, {
1869
1794
  size: len,
@@ -1872,22 +1797,22 @@ async function createRimeModule(moduleArg = {}) {
1872
1797
  },
1873
1798
  truncate(path, len) {
1874
1799
  if (len < 0) throw new FS.ErrnoError(28);
1875
- let node;
1800
+ var node;
1876
1801
  if (typeof path == "string") {
1877
- const lookup = FS.lookupPath(path, { follow: true });
1802
+ var lookup = FS.lookupPath(path, { follow: true });
1878
1803
  node = lookup.node;
1879
1804
  } else node = path;
1880
1805
  FS.doTruncate(null, node, len);
1881
1806
  },
1882
1807
  ftruncate(fd, len) {
1883
- const stream = FS.getStreamChecked(fd);
1808
+ var stream = FS.getStreamChecked(fd);
1884
1809
  if (len < 0 || (stream.flags & 2097155) === 0) throw new FS.ErrnoError(28);
1885
1810
  FS.doTruncate(stream, stream.node, len);
1886
1811
  },
1887
1812
  utime(path, atime, mtime) {
1888
- const lookup = FS.lookupPath(path, { follow: true });
1889
- const node = lookup.node;
1890
- const setattr = FS.checkOpExists(node.node_ops.setattr, 63);
1813
+ var lookup = FS.lookupPath(path, { follow: true });
1814
+ var node = lookup.node;
1815
+ var setattr = FS.checkOpExists(node.node_ops.setattr, 63);
1891
1816
  setattr(node, {
1892
1817
  atime,
1893
1818
  mtime
@@ -1898,19 +1823,19 @@ async function createRimeModule(moduleArg = {}) {
1898
1823
  flags = typeof flags == "string" ? FS_modeStringToFlags(flags) : flags;
1899
1824
  if (flags & 64) mode = mode & 4095 | 32768;
1900
1825
  else mode = 0;
1901
- let node;
1902
- let isDirPath;
1826
+ var node;
1827
+ var isDirPath;
1903
1828
  if (typeof path == "object") node = path;
1904
1829
  else {
1905
1830
  isDirPath = path.endsWith("/");
1906
- const lookup = FS.lookupPath(path, {
1831
+ var lookup = FS.lookupPath(path, {
1907
1832
  follow: !(flags & 131072),
1908
1833
  noent_okay: true
1909
1834
  });
1910
1835
  node = lookup.node;
1911
1836
  path = lookup.path;
1912
1837
  }
1913
- let created = false;
1838
+ var created = false;
1914
1839
  if (flags & 64) if (node) {
1915
1840
  if (flags & 128) throw new FS.ErrnoError(20);
1916
1841
  } else if (isDirPath) throw new FS.ErrnoError(31);
@@ -1922,12 +1847,12 @@ async function createRimeModule(moduleArg = {}) {
1922
1847
  if (FS.isChrdev(node.mode)) flags &= -513;
1923
1848
  if (flags & 65536 && !FS.isDir(node.mode)) throw new FS.ErrnoError(54);
1924
1849
  if (!created) {
1925
- const errCode = FS.mayOpen(node, flags);
1850
+ var errCode = FS.mayOpen(node, flags);
1926
1851
  if (errCode) throw new FS.ErrnoError(errCode);
1927
1852
  }
1928
1853
  if (flags & 512 && !created) FS.truncate(node, 0);
1929
1854
  flags &= -131713;
1930
- const stream = FS.createStream({
1855
+ var stream = FS.createStream({
1931
1856
  node,
1932
1857
  path: FS.getPath(node),
1933
1858
  flags,
@@ -1970,10 +1895,10 @@ async function createRimeModule(moduleArg = {}) {
1970
1895
  if ((stream.flags & 2097155) === 1) throw new FS.ErrnoError(8);
1971
1896
  if (FS.isDir(stream.node.mode)) throw new FS.ErrnoError(31);
1972
1897
  if (!stream.stream_ops.read) throw new FS.ErrnoError(28);
1973
- const seeking = typeof position != "undefined";
1898
+ var seeking = typeof position != "undefined";
1974
1899
  if (!seeking) position = stream.position;
1975
1900
  else if (!stream.seekable) throw new FS.ErrnoError(70);
1976
- const bytesRead = stream.stream_ops.read(stream, buffer, offset, length, position);
1901
+ var bytesRead = stream.stream_ops.read(stream, buffer, offset, length, position);
1977
1902
  if (!seeking) stream.position += bytesRead;
1978
1903
  return bytesRead;
1979
1904
  },
@@ -1984,10 +1909,10 @@ async function createRimeModule(moduleArg = {}) {
1984
1909
  if (FS.isDir(stream.node.mode)) throw new FS.ErrnoError(31);
1985
1910
  if (!stream.stream_ops.write) throw new FS.ErrnoError(28);
1986
1911
  if (stream.seekable && stream.flags & 1024) FS.llseek(stream, 0, 2);
1987
- const seeking = typeof position != "undefined";
1912
+ var seeking = typeof position != "undefined";
1988
1913
  if (!seeking) position = stream.position;
1989
1914
  else if (!stream.seekable) throw new FS.ErrnoError(70);
1990
- const bytesWritten = stream.stream_ops.write(stream, buffer, offset, length, position, canOwn);
1915
+ var bytesWritten = stream.stream_ops.write(stream, buffer, offset, length, position, canOwn);
1991
1916
  if (!seeking) stream.position += bytesWritten;
1992
1917
  return bytesWritten;
1993
1918
  },
@@ -2010,10 +1935,10 @@ async function createRimeModule(moduleArg = {}) {
2010
1935
  opts.flags = opts.flags || 0;
2011
1936
  opts.encoding = opts.encoding || "binary";
2012
1937
  if (opts.encoding !== "utf8" && opts.encoding !== "binary") abort(`Invalid encoding type "${opts.encoding}"`);
2013
- const stream = FS.open(path, opts.flags);
2014
- const stat = FS.stat(path);
2015
- const length = stat.size;
2016
- let buf = new Uint8Array(length);
1938
+ var stream = FS.open(path, opts.flags);
1939
+ var stat = FS.stat(path);
1940
+ var length = stat.size;
1941
+ var buf = new Uint8Array(length);
2017
1942
  FS.read(stream, buf, 0, length, 0);
2018
1943
  if (opts.encoding === "utf8") buf = UTF8ArrayToString(buf);
2019
1944
  FS.close(stream);
@@ -2021,7 +1946,7 @@ async function createRimeModule(moduleArg = {}) {
2021
1946
  },
2022
1947
  writeFile(path, data, opts = {}) {
2023
1948
  opts.flags = opts.flags || 577;
2024
- const stream = FS.open(path, opts.flags, opts.mode);
1949
+ var stream = FS.open(path, opts.flags, opts.mode);
2025
1950
  if (typeof data == "string") data = new Uint8Array(intArrayFromString(data, true));
2026
1951
  if (ArrayBuffer.isView(data)) FS.write(stream, data, 0, data.byteLength, void 0, opts.canOwn);
2027
1952
  else abort("Unsupported data type");
@@ -2029,10 +1954,10 @@ async function createRimeModule(moduleArg = {}) {
2029
1954
  },
2030
1955
  cwd: () => FS.currentPath,
2031
1956
  chdir(path) {
2032
- const lookup = FS.lookupPath(path, { follow: true });
1957
+ var lookup = FS.lookupPath(path, { follow: true });
2033
1958
  if (lookup.node === null) throw new FS.ErrnoError(44);
2034
1959
  if (!FS.isDir(lookup.node.mode)) throw new FS.ErrnoError(54);
2035
- const errCode = FS.nodePermissions(lookup.node, "x");
1960
+ var errCode = FS.nodePermissions(lookup.node, "x");
2036
1961
  if (errCode) throw new FS.ErrnoError(errCode);
2037
1962
  FS.currentPath = lookup.path;
2038
1963
  },
@@ -2053,9 +1978,8 @@ async function createRimeModule(moduleArg = {}) {
2053
1978
  TTY.register(FS.makedev(6, 0), TTY.default_tty1_ops);
2054
1979
  FS.mkdev("/dev/tty", FS.makedev(5, 0));
2055
1980
  FS.mkdev("/dev/tty1", FS.makedev(6, 0));
2056
- const randomBuffer = new Uint8Array(1024);
2057
- let randomLeft = 0;
2058
- const randomByte = () => {
1981
+ var randomBuffer = new Uint8Array(1024), randomLeft = 0;
1982
+ var randomByte = () => {
2059
1983
  if (randomLeft === 0) {
2060
1984
  randomFill(randomBuffer);
2061
1985
  randomLeft = randomBuffer.byteLength;
@@ -2069,16 +1993,16 @@ async function createRimeModule(moduleArg = {}) {
2069
1993
  },
2070
1994
  createSpecialDirectories() {
2071
1995
  FS.mkdir("/proc");
2072
- const proc_self = FS.mkdir("/proc/self");
1996
+ var proc_self = FS.mkdir("/proc/self");
2073
1997
  FS.mkdir("/proc/self/fd");
2074
1998
  FS.mount({ mount() {
2075
- const node = FS.createNode(proc_self, "fd", 16895, 73);
1999
+ var node = FS.createNode(proc_self, "fd", 16895, 73);
2076
2000
  node.stream_ops = { llseek: MEMFS.stream_ops.llseek };
2077
2001
  node.node_ops = {
2078
2002
  lookup(parent, name) {
2079
- const fd = +name;
2080
- const stream = FS.getStreamChecked(fd);
2081
- const ret = {
2003
+ var fd = +name;
2004
+ var stream = FS.getStreamChecked(fd);
2005
+ var ret = {
2082
2006
  parent: null,
2083
2007
  mount: { mountpoint: "fake" },
2084
2008
  node_ops: { readlink: () => stream.path },
@@ -2101,12 +2025,12 @@ async function createRimeModule(moduleArg = {}) {
2101
2025
  else FS.symlink("/dev/tty", "/dev/stdout");
2102
2026
  if (error) FS.createDevice("/dev", "stderr", null, error);
2103
2027
  else FS.symlink("/dev/tty1", "/dev/stderr");
2104
- const stdin = FS.open("/dev/stdin", 0);
2105
- const stdout = FS.open("/dev/stdout", 1);
2106
- const stderr = FS.open("/dev/stderr", 1);
2028
+ var stdin = FS.open("/dev/stdin", 0);
2029
+ var stdout = FS.open("/dev/stdout", 1);
2030
+ var stderr = FS.open("/dev/stderr", 1);
2107
2031
  },
2108
2032
  staticInit() {
2109
- FS.nameTable = Array.from({ length: 4096 });
2033
+ FS.nameTable = new Array(4096);
2110
2034
  FS.mount(MEMFS, {}, "/");
2111
2035
  FS.createDefaultDirectories();
2112
2036
  FS.createDefaultDevices();
@@ -2118,17 +2042,17 @@ async function createRimeModule(moduleArg = {}) {
2118
2042
  },
2119
2043
  init(input, output, error) {
2120
2044
  FS.initialized = true;
2121
- input ??= Module.stdin;
2122
- output ??= Module.stdout;
2123
- error ??= Module.stderr;
2045
+ input ??= Module["stdin"];
2046
+ output ??= Module["stdout"];
2047
+ error ??= Module["stderr"];
2124
2048
  FS.createStandardStreams(input, output, error);
2125
2049
  },
2126
2050
  quit() {
2127
2051
  FS.initialized = false;
2128
- for (const stream of FS.streams) if (stream) FS.close(stream);
2052
+ for (var stream of FS.streams) if (stream) FS.close(stream);
2129
2053
  },
2130
2054
  findObject(path, dontResolveLastLink) {
2131
- const ret = FS.analyzePath(path, dontResolveLastLink);
2055
+ var ret = FS.analyzePath(path, dontResolveLastLink);
2132
2056
  if (!ret.exists) return null;
2133
2057
  return ret.object;
2134
2058
  },
@@ -2137,7 +2061,7 @@ async function createRimeModule(moduleArg = {}) {
2137
2061
  var lookup = FS.lookupPath(path, { follow: !dontResolveLastLink });
2138
2062
  path = lookup.path;
2139
2063
  } catch (e) {}
2140
- const ret = {
2064
+ var ret = {
2141
2065
  isRoot: false,
2142
2066
  exists: false,
2143
2067
  error: 0,
@@ -2167,9 +2091,9 @@ async function createRimeModule(moduleArg = {}) {
2167
2091
  },
2168
2092
  createPath(parent, path, canRead, canWrite) {
2169
2093
  parent = typeof parent == "string" ? parent : FS.getPath(parent);
2170
- const parts = path.split("/").reverse();
2094
+ var parts = path.split("/").reverse();
2171
2095
  while (parts.length) {
2172
- const part = parts.pop();
2096
+ var part = parts.pop();
2173
2097
  if (!part) continue;
2174
2098
  var current = PATH.join2(parent, part);
2175
2099
  try {
@@ -2182,36 +2106,36 @@ async function createRimeModule(moduleArg = {}) {
2182
2106
  return current;
2183
2107
  },
2184
2108
  createFile(parent, name, properties, canRead, canWrite) {
2185
- const path = PATH.join2(typeof parent == "string" ? parent : FS.getPath(parent), name);
2186
- const mode = FS_getMode(canRead, canWrite);
2109
+ var path = PATH.join2(typeof parent == "string" ? parent : FS.getPath(parent), name);
2110
+ var mode = FS_getMode(canRead, canWrite);
2187
2111
  return FS.create(path, mode);
2188
2112
  },
2189
2113
  createDataFile(parent, name, data, canRead, canWrite, canOwn) {
2190
- let path = name;
2114
+ var path = name;
2191
2115
  if (parent) {
2192
2116
  parent = typeof parent == "string" ? parent : FS.getPath(parent);
2193
2117
  path = name ? PATH.join2(parent, name) : parent;
2194
2118
  }
2195
- const mode = FS_getMode(canRead, canWrite);
2196
- const node = FS.create(path, mode);
2119
+ var mode = FS_getMode(canRead, canWrite);
2120
+ var node = FS.create(path, mode);
2197
2121
  if (data) {
2198
2122
  if (typeof data == "string") {
2199
- const arr = Array.from({ length: data.length });
2200
- for (let i = 0, len = data.length; i < len; ++i) arr[i] = data.charCodeAt(i);
2123
+ var arr = new Array(data.length);
2124
+ for (var i = 0, len = data.length; i < len; ++i) arr[i] = data.charCodeAt(i);
2201
2125
  data = arr;
2202
2126
  }
2203
2127
  FS.chmod(node, mode | 146);
2204
- const stream = FS.open(node, 577);
2128
+ var stream = FS.open(node, 577);
2205
2129
  FS.write(stream, data, 0, data.length, 0, canOwn);
2206
2130
  FS.close(stream);
2207
2131
  FS.chmod(node, mode);
2208
2132
  }
2209
2133
  },
2210
2134
  createDevice(parent, name, input, output) {
2211
- const path = PATH.join2(typeof parent == "string" ? parent : FS.getPath(parent), name);
2212
- const mode = FS_getMode(!!input, !!output);
2135
+ var path = PATH.join2(typeof parent == "string" ? parent : FS.getPath(parent), name);
2136
+ var mode = FS_getMode(!!input, !!output);
2213
2137
  FS.createDevice.major ??= 64;
2214
- const dev = FS.makedev(FS.createDevice.major++, 0);
2138
+ var dev = FS.makedev(FS.createDevice.major++, 0);
2215
2139
  FS.registerDevice(dev, {
2216
2140
  open(stream) {
2217
2141
  stream.seekable = false;
@@ -2220,8 +2144,8 @@ async function createRimeModule(moduleArg = {}) {
2220
2144
  if (output?.buffer?.length) output(10);
2221
2145
  },
2222
2146
  read(stream, buffer, offset, length, pos) {
2223
- let bytesRead = 0;
2224
- for (let i = 0; i < length; i++) {
2147
+ var bytesRead = 0;
2148
+ for (var i = 0; i < length; i++) {
2225
2149
  var result;
2226
2150
  try {
2227
2151
  result = input();
@@ -2263,45 +2187,45 @@ async function createRimeModule(moduleArg = {}) {
2263
2187
  chunks = [];
2264
2188
  get(idx) {
2265
2189
  if (idx > this.length - 1 || idx < 0) return void 0;
2266
- const chunkOffset = idx % this.chunkSize;
2267
- const chunkNum = idx / this.chunkSize | 0;
2190
+ var chunkOffset = idx % this.chunkSize;
2191
+ var chunkNum = idx / this.chunkSize | 0;
2268
2192
  return this.getter(chunkNum)[chunkOffset];
2269
2193
  }
2270
2194
  setDataGetter(getter) {
2271
2195
  this.getter = getter;
2272
2196
  }
2273
2197
  cacheLength() {
2274
- const xhr = new XMLHttpRequest();
2198
+ var xhr = new XMLHttpRequest();
2275
2199
  xhr.open("HEAD", url, false);
2276
2200
  xhr.send(null);
2277
- if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) abort(`Couldn't load ${url}. Status: ${xhr.status}`);
2278
- let datalength = Number(xhr.getResponseHeader("Content-length"));
2279
- let header;
2280
- const hasByteServing = (header = xhr.getResponseHeader("Accept-Ranges")) && header === "bytes";
2281
- const usesGzip = (header = xhr.getResponseHeader("Content-Encoding")) && header === "gzip";
2282
- let chunkSize = 1024 * 1024;
2201
+ if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) abort("Couldn't load " + url + ". Status: " + xhr.status);
2202
+ var datalength = Number(xhr.getResponseHeader("Content-length"));
2203
+ var header;
2204
+ var hasByteServing = (header = xhr.getResponseHeader("Accept-Ranges")) && header === "bytes";
2205
+ var usesGzip = (header = xhr.getResponseHeader("Content-Encoding")) && header === "gzip";
2206
+ var chunkSize = 1024 * 1024;
2283
2207
  if (!hasByteServing) chunkSize = datalength;
2284
- const doXHR = (from, to) => {
2285
- if (from > to) abort(`invalid range (${from}, ${to}) or no bytes requested!`);
2286
- if (to > datalength - 1) abort(`only ${datalength} bytes available! programmer error!`);
2287
- const xhr$1 = new XMLHttpRequest();
2208
+ var doXHR = (from, to) => {
2209
+ if (from > to) abort("invalid range (" + from + ", " + to + ") or no bytes requested!");
2210
+ if (to > datalength - 1) abort("only " + datalength + " bytes available! programmer error!");
2211
+ var xhr$1 = new XMLHttpRequest();
2288
2212
  xhr$1.open("GET", url, false);
2289
- if (datalength !== chunkSize) xhr$1.setRequestHeader("Range", `bytes=${from}-${to}`);
2213
+ if (datalength !== chunkSize) xhr$1.setRequestHeader("Range", "bytes=" + from + "-" + to);
2290
2214
  xhr$1.responseType = "arraybuffer";
2291
2215
  if (xhr$1.overrideMimeType) xhr$1.overrideMimeType("text/plain; charset=x-user-defined");
2292
2216
  xhr$1.send(null);
2293
- if (!(xhr$1.status >= 200 && xhr$1.status < 300 || xhr$1.status === 304)) abort(`Couldn't load ${url}. Status: ${xhr$1.status}`);
2217
+ if (!(xhr$1.status >= 200 && xhr$1.status < 300 || xhr$1.status === 304)) abort("Couldn't load " + url + ". Status: " + xhr$1.status);
2294
2218
  if (xhr$1.response !== void 0) return new Uint8Array(xhr$1.response || []);
2295
2219
  return intArrayFromString(xhr$1.responseText || "", true);
2296
2220
  };
2297
- const lazyArray = this;
2298
- lazyArray.setDataGetter((chunkNum) => {
2299
- const start = chunkNum * chunkSize;
2300
- let end = (chunkNum + 1) * chunkSize - 1;
2221
+ var lazyArray$1 = this;
2222
+ lazyArray$1.setDataGetter((chunkNum) => {
2223
+ var start = chunkNum * chunkSize;
2224
+ var end = (chunkNum + 1) * chunkSize - 1;
2301
2225
  end = Math.min(end, datalength - 1);
2302
- if (typeof lazyArray.chunks[chunkNum] == "undefined") lazyArray.chunks[chunkNum] = doXHR(start, end);
2303
- if (typeof lazyArray.chunks[chunkNum] == "undefined") abort("doXHR failed!");
2304
- return lazyArray.chunks[chunkNum];
2226
+ if (typeof lazyArray$1.chunks[chunkNum] == "undefined") lazyArray$1.chunks[chunkNum] = doXHR(start, end);
2227
+ if (typeof lazyArray$1.chunks[chunkNum] == "undefined") abort("doXHR failed!");
2228
+ return lazyArray$1.chunks[chunkNum];
2305
2229
  });
2306
2230
  if (usesGzip || !datalength) {
2307
2231
  chunkSize = datalength = 1;
@@ -2324,7 +2248,7 @@ async function createRimeModule(moduleArg = {}) {
2324
2248
  }
2325
2249
  if (globalThis.XMLHttpRequest) {
2326
2250
  if (!ENVIRONMENT_IS_WORKER) abort("Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc");
2327
- const lazyArray = new LazyUint8Array();
2251
+ var lazyArray = new LazyUint8Array();
2328
2252
  var properties = {
2329
2253
  isDevice: false,
2330
2254
  contents: lazyArray
@@ -2333,24 +2257,24 @@ async function createRimeModule(moduleArg = {}) {
2333
2257
  isDevice: false,
2334
2258
  url
2335
2259
  };
2336
- const node = FS.createFile(parent, name, properties, canRead, canWrite);
2260
+ var node = FS.createFile(parent, name, properties, canRead, canWrite);
2337
2261
  if (properties.contents) node.contents = properties.contents;
2338
2262
  else if (properties.url) {
2339
2263
  node.contents = null;
2340
2264
  node.url = properties.url;
2341
2265
  }
2342
- Object.defineProperties(node, { usedBytes: { get() {
2266
+ Object.defineProperties(node, { usedBytes: { get: function() {
2343
2267
  return this.contents.length;
2344
2268
  } } });
2345
- const stream_ops = {};
2269
+ var stream_ops = {};
2346
2270
  for (const [key, fn] of Object.entries(node.stream_ops)) stream_ops[key] = (...args) => {
2347
2271
  FS.forceLoadFile(node);
2348
2272
  return fn(...args);
2349
2273
  };
2350
2274
  function writeChunks(stream, buffer, offset, length, position) {
2351
- const contents = stream.node.contents;
2275
+ var contents = stream.node.contents;
2352
2276
  if (position >= contents.length) return 0;
2353
- const size = Math.min(contents.length - position, length);
2277
+ var size = Math.min(contents.length - position, length);
2354
2278
  if (contents.slice) for (var i = 0; i < size; i++) buffer[offset + i] = contents[position + i];
2355
2279
  else for (var i = 0; i < size; i++) buffer[offset + i] = contents.get(position + i);
2356
2280
  return size;
@@ -2361,7 +2285,7 @@ async function createRimeModule(moduleArg = {}) {
2361
2285
  };
2362
2286
  stream_ops.mmap = (stream, length, position, prot, flags) => {
2363
2287
  FS.forceLoadFile(node);
2364
- const ptr = mmapAlloc(length);
2288
+ var ptr = mmapAlloc(length);
2365
2289
  if (!ptr) throw new FS.ErrnoError(48);
2366
2290
  writeChunks(stream, HEAP8, ptr, length, position);
2367
2291
  return {
@@ -2373,26 +2297,26 @@ async function createRimeModule(moduleArg = {}) {
2373
2297
  return node;
2374
2298
  }
2375
2299
  };
2376
- const UTF8ToString = (ptr, maxBytesToRead, ignoreNul) => {
2300
+ var UTF8ToString = (ptr, maxBytesToRead, ignoreNul) => {
2377
2301
  ptr >>>= 0;
2378
2302
  if (!ptr) return "";
2379
- const end = findStringEnd(HEAPU8, ptr, maxBytesToRead, ignoreNul);
2303
+ var end = findStringEnd(HEAPU8, ptr, maxBytesToRead, ignoreNul);
2380
2304
  return UTF8Decoder.decode(HEAPU8.subarray(ptr >>> 0, end >>> 0));
2381
2305
  };
2382
2306
  var SYSCALLS = {
2383
2307
  calculateAt(dirfd, path, allowEmpty) {
2384
2308
  if (PATH.isAbs(path)) return path;
2385
- let dir;
2309
+ var dir;
2386
2310
  if (dirfd === -100) dir = FS.cwd();
2387
2311
  else {
2388
- const dirstream = SYSCALLS.getStreamFromFD(dirfd);
2312
+ var dirstream = SYSCALLS.getStreamFromFD(dirfd);
2389
2313
  dir = dirstream.path;
2390
2314
  }
2391
2315
  if (path.length == 0) {
2392
2316
  if (!allowEmpty) throw new FS.ErrnoError(44);
2393
2317
  return dir;
2394
2318
  }
2395
- return `${dir}/${path}`;
2319
+ return dir + "/" + path;
2396
2320
  },
2397
2321
  writeStat(buf, stat) {
2398
2322
  HEAPU32[buf >>> 2 >>> 0] = stat.dev;
@@ -2404,9 +2328,9 @@ async function createRimeModule(moduleArg = {}) {
2404
2328
  HEAP64[buf + 24 >>> 3 >>> 0] = BigInt(stat.size);
2405
2329
  HEAP32[buf + 32 >>> 2 >>> 0] = 4096;
2406
2330
  HEAP32[buf + 36 >>> 2 >>> 0] = stat.blocks;
2407
- const atime = stat.atime.getTime();
2408
- const mtime = stat.mtime.getTime();
2409
- const ctime = stat.ctime.getTime();
2331
+ var atime = stat.atime.getTime();
2332
+ var mtime = stat.mtime.getTime();
2333
+ var ctime = stat.ctime.getTime();
2410
2334
  HEAP64[buf + 40 >>> 3 >>> 0] = BigInt(Math.floor(atime / 1e3));
2411
2335
  HEAPU32[buf + 48 >>> 2 >>> 0] = atime % 1e3 * 1e3 * 1e3;
2412
2336
  HEAP64[buf + 56 >>> 3 >>> 0] = BigInt(Math.floor(mtime / 1e3));
@@ -2431,22 +2355,22 @@ async function createRimeModule(moduleArg = {}) {
2431
2355
  doMsync(addr, stream, len, flags, offset) {
2432
2356
  if (!FS.isFile(stream.node.mode)) throw new FS.ErrnoError(43);
2433
2357
  if (flags & 2) return 0;
2434
- const buffer = HEAPU8.slice(addr, addr + len);
2358
+ var buffer = HEAPU8.slice(addr, addr + len);
2435
2359
  FS.msync(stream, buffer, offset, len, flags);
2436
2360
  },
2437
2361
  getStreamFromFD(fd) {
2438
- const stream = FS.getStreamChecked(fd);
2362
+ var stream = FS.getStreamChecked(fd);
2439
2363
  return stream;
2440
2364
  },
2441
2365
  varargs: void 0,
2442
2366
  getStr(ptr) {
2443
- const ret = UTF8ToString(ptr);
2367
+ var ret = UTF8ToString(ptr);
2444
2368
  return ret;
2445
2369
  }
2446
2370
  };
2447
- const INT53_MAX = 9007199254740992;
2448
- const INT53_MIN = -9007199254740992;
2449
- const bigintToI53Checked = (num) => num < INT53_MIN || num > INT53_MAX ? Number.NaN : Number(num);
2371
+ var INT53_MAX = 9007199254740992;
2372
+ var INT53_MIN = -9007199254740992;
2373
+ var bigintToI53Checked = (num) => num < INT53_MIN || num > INT53_MAX ? NaN : Number(num);
2450
2374
  function ___syscall_chmod(path, mode) {
2451
2375
  path >>>= 0;
2452
2376
  try {
@@ -2464,10 +2388,10 @@ async function createRimeModule(moduleArg = {}) {
2464
2388
  path = SYSCALLS.getStr(path);
2465
2389
  path = SYSCALLS.calculateAt(dirfd, path);
2466
2390
  if (amode & -8) return -28;
2467
- const lookup = FS.lookupPath(path, { follow: true });
2468
- const node = lookup.node;
2391
+ var lookup = FS.lookupPath(path, { follow: true });
2392
+ var node = lookup.node;
2469
2393
  if (!node) return -44;
2470
- let perms = "";
2394
+ var perms = "";
2471
2395
  if (amode & 4) perms += "r";
2472
2396
  if (amode & 2) perms += "w";
2473
2397
  if (amode & 1) perms += "x";
@@ -2487,23 +2411,23 @@ async function createRimeModule(moduleArg = {}) {
2487
2411
  return -e.errno;
2488
2412
  }
2489
2413
  }
2490
- const syscallGetVarargI = () => {
2491
- const ret = HEAP32[+SYSCALLS.varargs >>> 2 >>> 0];
2414
+ var syscallGetVarargI = () => {
2415
+ var ret = HEAP32[+SYSCALLS.varargs >>> 2 >>> 0];
2492
2416
  SYSCALLS.varargs += 4;
2493
2417
  return ret;
2494
2418
  };
2495
- const syscallGetVarargP = syscallGetVarargI;
2419
+ var syscallGetVarargP = syscallGetVarargI;
2496
2420
  function ___syscall_fcntl64(fd, cmd, varargs) {
2497
2421
  varargs >>>= 0;
2498
2422
  SYSCALLS.varargs = varargs;
2499
2423
  try {
2500
- const stream = SYSCALLS.getStreamFromFD(fd);
2424
+ var stream = SYSCALLS.getStreamFromFD(fd);
2501
2425
  switch (cmd) {
2502
2426
  case 0: {
2503
2427
  var arg = syscallGetVarargI();
2504
2428
  if (arg < 0) return -28;
2505
2429
  while (FS.streams[arg]) arg++;
2506
- let newStream;
2430
+ var newStream;
2507
2431
  newStream = FS.dupStream(stream, arg);
2508
2432
  return newStream.fd;
2509
2433
  }
@@ -2517,7 +2441,7 @@ async function createRimeModule(moduleArg = {}) {
2517
2441
  }
2518
2442
  case 12: {
2519
2443
  var arg = syscallGetVarargP();
2520
- const offset = 0;
2444
+ var offset = 0;
2521
2445
  HEAP16[arg + offset >>> 1 >>> 0] = 2;
2522
2446
  return 0;
2523
2447
  }
@@ -2532,7 +2456,7 @@ async function createRimeModule(moduleArg = {}) {
2532
2456
  }
2533
2457
  function ___syscall_fdatasync(fd) {
2534
2458
  try {
2535
- const stream = SYSCALLS.getStreamFromFD(fd);
2459
+ var stream = SYSCALLS.getStreamFromFD(fd);
2536
2460
  return 0;
2537
2461
  } catch (e) {
2538
2462
  if (typeof FS == "undefined" || !(e.name === "ErrnoError")) throw e;
@@ -2559,14 +2483,14 @@ async function createRimeModule(moduleArg = {}) {
2559
2483
  return -e.errno;
2560
2484
  }
2561
2485
  }
2562
- const stringToUTF8 = (str, outPtr, maxBytesToWrite) => stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite);
2486
+ var stringToUTF8 = (str, outPtr, maxBytesToWrite) => stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite);
2563
2487
  function ___syscall_getcwd(buf, size) {
2564
2488
  buf >>>= 0;
2565
2489
  size >>>= 0;
2566
2490
  try {
2567
2491
  if (size === 0) return -28;
2568
- const cwd = FS.cwd();
2569
- const cwdLengthInBytes = lengthBytesUTF8(cwd) + 1;
2492
+ var cwd = FS.cwd();
2493
+ var cwdLengthInBytes = lengthBytesUTF8(cwd) + 1;
2570
2494
  if (size < cwdLengthInBytes) return -68;
2571
2495
  stringToUTF8(cwd, buf, size);
2572
2496
  return cwdLengthInBytes;
@@ -2579,22 +2503,22 @@ async function createRimeModule(moduleArg = {}) {
2579
2503
  dirp >>>= 0;
2580
2504
  count >>>= 0;
2581
2505
  try {
2582
- const stream = SYSCALLS.getStreamFromFD(fd);
2506
+ var stream = SYSCALLS.getStreamFromFD(fd);
2583
2507
  stream.getdents ||= FS.readdir(stream.path);
2584
- const struct_size = 280;
2585
- let pos = 0;
2586
- const off = FS.llseek(stream, 0, 1);
2587
- const startIdx = Math.floor(off / struct_size);
2588
- const endIdx = Math.min(stream.getdents.length, startIdx + Math.floor(count / struct_size));
2508
+ var struct_size = 280;
2509
+ var pos = 0;
2510
+ var off = FS.llseek(stream, 0, 1);
2511
+ var startIdx = Math.floor(off / struct_size);
2512
+ var endIdx = Math.min(stream.getdents.length, startIdx + Math.floor(count / struct_size));
2589
2513
  for (var idx = startIdx; idx < endIdx; idx++) {
2590
2514
  var id;
2591
2515
  var type;
2592
- const name = stream.getdents[idx];
2516
+ var name = stream.getdents[idx];
2593
2517
  if (name === ".") {
2594
2518
  id = stream.node.id;
2595
2519
  type = 4;
2596
2520
  } else if (name === "..") {
2597
- const lookup = FS.lookupPath(stream.path, { parent: true });
2521
+ var lookup = FS.lookupPath(stream.path, { parent: true });
2598
2522
  id = lookup.node.id;
2599
2523
  type = 4;
2600
2524
  } else {
@@ -2626,7 +2550,7 @@ async function createRimeModule(moduleArg = {}) {
2626
2550
  varargs >>>= 0;
2627
2551
  SYSCALLS.varargs = varargs;
2628
2552
  try {
2629
- const stream = SYSCALLS.getStreamFromFD(fd);
2553
+ var stream = SYSCALLS.getStreamFromFD(fd);
2630
2554
  switch (op) {
2631
2555
  case 21509: {
2632
2556
  if (!stream.tty) return -59;
@@ -2635,7 +2559,7 @@ async function createRimeModule(moduleArg = {}) {
2635
2559
  case 21505: {
2636
2560
  if (!stream.tty) return -59;
2637
2561
  if (stream.tty.ops.ioctl_tcgets) {
2638
- const termios = stream.tty.ops.ioctl_tcgets(stream);
2562
+ var termios = stream.tty.ops.ioctl_tcgets(stream);
2639
2563
  var argp = syscallGetVarargP();
2640
2564
  HEAP32[argp >>> 2 >>> 0] = termios.c_iflag || 0;
2641
2565
  HEAP32[argp + 4 >>> 2 >>> 0] = termios.c_oflag || 0;
@@ -2658,11 +2582,11 @@ async function createRimeModule(moduleArg = {}) {
2658
2582
  if (!stream.tty) return -59;
2659
2583
  if (stream.tty.ops.ioctl_tcsets) {
2660
2584
  var argp = syscallGetVarargP();
2661
- const c_iflag = HEAP32[argp >>> 2 >>> 0];
2662
- const c_oflag = HEAP32[argp + 4 >>> 2 >>> 0];
2663
- const c_cflag = HEAP32[argp + 8 >>> 2 >>> 0];
2664
- const c_lflag = HEAP32[argp + 12 >>> 2 >>> 0];
2665
- const c_cc = [];
2585
+ var c_iflag = HEAP32[argp >>> 2 >>> 0];
2586
+ var c_oflag = HEAP32[argp + 4 >>> 2 >>> 0];
2587
+ var c_cflag = HEAP32[argp + 8 >>> 2 >>> 0];
2588
+ var c_lflag = HEAP32[argp + 12 >>> 2 >>> 0];
2589
+ var c_cc = [];
2666
2590
  for (var i = 0; i < 32; i++) c_cc.push(HEAP8[argp + i + 17 >>> 0]);
2667
2591
  return stream.tty.ops.ioctl_tcsets(stream.tty, op, {
2668
2592
  c_iflag,
@@ -2692,7 +2616,7 @@ async function createRimeModule(moduleArg = {}) {
2692
2616
  case 21523: {
2693
2617
  if (!stream.tty) return -59;
2694
2618
  if (stream.tty.ops.ioctl_tiocgwinsz) {
2695
- const winsize = stream.tty.ops.ioctl_tiocgwinsz(stream.tty);
2619
+ var winsize = stream.tty.ops.ioctl_tiocgwinsz(stream.tty);
2696
2620
  var argp = syscallGetVarargP();
2697
2621
  HEAP16[argp >>> 1 >>> 0] = winsize[0];
2698
2622
  HEAP16[argp + 2 >>> 1 >>> 0] = winsize[1];
@@ -2742,8 +2666,8 @@ async function createRimeModule(moduleArg = {}) {
2742
2666
  buf >>>= 0;
2743
2667
  try {
2744
2668
  path = SYSCALLS.getStr(path);
2745
- const nofollow = flags & 256;
2746
- const allowEmpty = flags & 4096;
2669
+ var nofollow = flags & 256;
2670
+ var allowEmpty = flags & 4096;
2747
2671
  flags = flags & -6401;
2748
2672
  path = SYSCALLS.calculateAt(dirfd, path, allowEmpty);
2749
2673
  return SYSCALLS.writeStat(buf, nofollow ? FS.lstat(path) : FS.stat(path));
@@ -2759,7 +2683,7 @@ async function createRimeModule(moduleArg = {}) {
2759
2683
  try {
2760
2684
  path = SYSCALLS.getStr(path);
2761
2685
  path = SYSCALLS.calculateAt(dirfd, path);
2762
- const mode = varargs ? syscallGetVarargI() : 0;
2686
+ var mode = varargs ? syscallGetVarargI() : 0;
2763
2687
  return FS.open(path, flags, mode).fd;
2764
2688
  } catch (e) {
2765
2689
  if (typeof FS == "undefined" || !(e.name === "ErrnoError")) throw e;
@@ -2774,9 +2698,9 @@ async function createRimeModule(moduleArg = {}) {
2774
2698
  path = SYSCALLS.getStr(path);
2775
2699
  path = SYSCALLS.calculateAt(dirfd, path);
2776
2700
  if (bufsize <= 0) return -28;
2777
- const ret = FS.readlink(path);
2778
- const len = Math.min(bufsize, lengthBytesUTF8(ret));
2779
- const endChar = HEAP8[buf + len >>> 0];
2701
+ var ret = FS.readlink(path);
2702
+ var len = Math.min(bufsize, lengthBytesUTF8(ret));
2703
+ var endChar = HEAP8[buf + len >>> 0];
2780
2704
  stringToUTF8(ret, buf, bufsize + 1);
2781
2705
  HEAP8[buf + len >>> 0] = endChar;
2782
2706
  return len;
@@ -2849,14 +2773,14 @@ async function createRimeModule(moduleArg = {}) {
2849
2773
  return -e.errno;
2850
2774
  }
2851
2775
  }
2852
- const __abort_js = () => abort("");
2853
- let runtimeKeepaliveCounter = 0;
2854
- const __emscripten_runtime_keepalive_clear = () => {
2776
+ var __abort_js = () => abort("");
2777
+ var runtimeKeepaliveCounter = 0;
2778
+ var __emscripten_runtime_keepalive_clear = () => {
2855
2779
  noExitRuntime = false;
2856
2780
  runtimeKeepaliveCounter = 0;
2857
2781
  };
2858
- const isLeapYear = (year) => year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
2859
- const MONTH_DAYS_LEAP_CUMULATIVE = [
2782
+ var isLeapYear = (year) => year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
2783
+ var MONTH_DAYS_LEAP_CUMULATIVE = [
2860
2784
  0,
2861
2785
  31,
2862
2786
  60,
@@ -2870,7 +2794,7 @@ async function createRimeModule(moduleArg = {}) {
2870
2794
  305,
2871
2795
  335
2872
2796
  ];
2873
- const MONTH_DAYS_REGULAR_CUMULATIVE = [
2797
+ var MONTH_DAYS_REGULAR_CUMULATIVE = [
2874
2798
  0,
2875
2799
  31,
2876
2800
  59,
@@ -2884,16 +2808,16 @@ async function createRimeModule(moduleArg = {}) {
2884
2808
  304,
2885
2809
  334
2886
2810
  ];
2887
- const ydayFromDate = (date) => {
2888
- const leap = isLeapYear(date.getFullYear());
2889
- const monthDaysCumulative = leap ? MONTH_DAYS_LEAP_CUMULATIVE : MONTH_DAYS_REGULAR_CUMULATIVE;
2890
- const yday = monthDaysCumulative[date.getMonth()] + date.getDate() - 1;
2811
+ var ydayFromDate = (date) => {
2812
+ var leap = isLeapYear(date.getFullYear());
2813
+ var monthDaysCumulative = leap ? MONTH_DAYS_LEAP_CUMULATIVE : MONTH_DAYS_REGULAR_CUMULATIVE;
2814
+ var yday = monthDaysCumulative[date.getMonth()] + date.getDate() - 1;
2891
2815
  return yday;
2892
2816
  };
2893
2817
  function __localtime_js(time, tmPtr) {
2894
2818
  time = bigintToI53Checked(time);
2895
2819
  tmPtr >>>= 0;
2896
- const date = new Date(time * 1e3);
2820
+ var date = new Date(time * 1e3);
2897
2821
  HEAP32[tmPtr >>> 2 >>> 0] = date.getSeconds();
2898
2822
  HEAP32[tmPtr + 4 >>> 2 >>> 0] = date.getMinutes();
2899
2823
  HEAP32[tmPtr + 8 >>> 2 >>> 0] = date.getHours();
@@ -2901,13 +2825,13 @@ async function createRimeModule(moduleArg = {}) {
2901
2825
  HEAP32[tmPtr + 16 >>> 2 >>> 0] = date.getMonth();
2902
2826
  HEAP32[tmPtr + 20 >>> 2 >>> 0] = date.getFullYear() - 1900;
2903
2827
  HEAP32[tmPtr + 24 >>> 2 >>> 0] = date.getDay();
2904
- const yday = ydayFromDate(date) | 0;
2828
+ var yday = ydayFromDate(date) | 0;
2905
2829
  HEAP32[tmPtr + 28 >>> 2 >>> 0] = yday;
2906
2830
  HEAP32[tmPtr + 36 >>> 2 >>> 0] = -(date.getTimezoneOffset() * 60);
2907
- const start = new Date(date.getFullYear(), 0, 1);
2908
- const summerOffset = new Date(date.getFullYear(), 6, 1).getTimezoneOffset();
2909
- const winterOffset = start.getTimezoneOffset();
2910
- const dst = (summerOffset != winterOffset && date.getTimezoneOffset() == Math.min(winterOffset, summerOffset)) | 0;
2831
+ var start = new Date(date.getFullYear(), 0, 1);
2832
+ var summerOffset = new Date(date.getFullYear(), 6, 1).getTimezoneOffset();
2833
+ var winterOffset = start.getTimezoneOffset();
2834
+ var dst = (summerOffset != winterOffset && date.getTimezoneOffset() == Math.min(winterOffset, summerOffset)) | 0;
2911
2835
  HEAP32[tmPtr + 32 >>> 2 >>> 0] = dst;
2912
2836
  }
2913
2837
  function __mmap_js(len, prot, flags, fd, offset, allocated, addr) {
@@ -2916,9 +2840,9 @@ async function createRimeModule(moduleArg = {}) {
2916
2840
  allocated >>>= 0;
2917
2841
  addr >>>= 0;
2918
2842
  try {
2919
- const stream = SYSCALLS.getStreamFromFD(fd);
2920
- const res = FS.mmap(stream, len, offset, prot, flags);
2921
- const ptr = res.ptr;
2843
+ var stream = SYSCALLS.getStreamFromFD(fd);
2844
+ var res = FS.mmap(stream, len, offset, prot, flags);
2845
+ var ptr = res.ptr;
2922
2846
  HEAP32[allocated >>> 2 >>> 0] = res.allocated;
2923
2847
  HEAPU32[addr >>> 2 >>> 0] = ptr;
2924
2848
  return 0;
@@ -2932,40 +2856,40 @@ async function createRimeModule(moduleArg = {}) {
2932
2856
  len >>>= 0;
2933
2857
  offset = bigintToI53Checked(offset);
2934
2858
  try {
2935
- const stream = SYSCALLS.getStreamFromFD(fd);
2859
+ var stream = SYSCALLS.getStreamFromFD(fd);
2936
2860
  if (prot & 2) SYSCALLS.doMsync(addr, stream, len, flags, offset);
2937
2861
  } catch (e) {
2938
2862
  if (typeof FS == "undefined" || !(e.name === "ErrnoError")) throw e;
2939
2863
  return -e.errno;
2940
2864
  }
2941
2865
  }
2942
- const timers = {};
2943
- const handleException = (e) => {
2866
+ var timers = {};
2867
+ var handleException = (e) => {
2944
2868
  if (e instanceof ExitStatus || e == "unwind") return EXITSTATUS;
2945
2869
  quit_(1, e);
2946
2870
  };
2947
- const keepRuntimeAlive = () => noExitRuntime || runtimeKeepaliveCounter > 0;
2948
- const _proc_exit = (code) => {
2871
+ var keepRuntimeAlive = () => noExitRuntime || runtimeKeepaliveCounter > 0;
2872
+ var _proc_exit = (code) => {
2949
2873
  EXITSTATUS = code;
2950
2874
  if (!keepRuntimeAlive()) {
2951
- Module.onExit?.(code);
2875
+ Module["onExit"]?.(code);
2952
2876
  ABORT = true;
2953
2877
  }
2954
2878
  quit_(code, new ExitStatus(code));
2955
2879
  };
2956
- const exitJS = (status, implicit) => {
2880
+ var exitJS = (status, implicit) => {
2957
2881
  EXITSTATUS = status;
2958
2882
  _proc_exit(status);
2959
2883
  };
2960
- const _exit = exitJS;
2961
- const maybeExit = () => {
2884
+ var _exit = exitJS;
2885
+ var maybeExit = () => {
2962
2886
  if (!keepRuntimeAlive()) try {
2963
2887
  _exit(EXITSTATUS);
2964
2888
  } catch (e) {
2965
2889
  handleException(e);
2966
2890
  }
2967
2891
  };
2968
- const callUserCallback = (func) => {
2892
+ var callUserCallback = (func) => {
2969
2893
  if (ABORT) return;
2970
2894
  try {
2971
2895
  return func();
@@ -2975,14 +2899,14 @@ async function createRimeModule(moduleArg = {}) {
2975
2899
  maybeExit();
2976
2900
  }
2977
2901
  };
2978
- const _emscripten_get_now = () => performance.now();
2979
- const __setitimer_js = (which, timeout_ms) => {
2902
+ var _emscripten_get_now = () => performance.now();
2903
+ var __setitimer_js = (which, timeout_ms) => {
2980
2904
  if (timers[which]) {
2981
2905
  clearTimeout(timers[which].id);
2982
2906
  delete timers[which];
2983
2907
  }
2984
2908
  if (!timeout_ms) return 0;
2985
- const id = setTimeout(() => {
2909
+ var id = setTimeout(() => {
2986
2910
  delete timers[which];
2987
2911
  callUserCallback(() => __emscripten_timeout(which, _emscripten_get_now()));
2988
2912
  }, timeout_ms);
@@ -2992,28 +2916,28 @@ async function createRimeModule(moduleArg = {}) {
2992
2916
  };
2993
2917
  return 0;
2994
2918
  };
2995
- const __tzset_js = function(timezone, daylight, std_name, dst_name) {
2919
+ var __tzset_js = function(timezone, daylight, std_name, dst_name) {
2996
2920
  timezone >>>= 0;
2997
2921
  daylight >>>= 0;
2998
2922
  std_name >>>= 0;
2999
2923
  dst_name >>>= 0;
3000
- const currentYear = new Date().getFullYear();
3001
- const winter = new Date(currentYear, 0, 1);
3002
- const summer = new Date(currentYear, 6, 1);
3003
- const winterOffset = winter.getTimezoneOffset();
3004
- const summerOffset = summer.getTimezoneOffset();
3005
- const stdTimezoneOffset = Math.max(winterOffset, summerOffset);
2924
+ var currentYear = new Date().getFullYear();
2925
+ var winter = new Date(currentYear, 0, 1);
2926
+ var summer = new Date(currentYear, 6, 1);
2927
+ var winterOffset = winter.getTimezoneOffset();
2928
+ var summerOffset = summer.getTimezoneOffset();
2929
+ var stdTimezoneOffset = Math.max(winterOffset, summerOffset);
3006
2930
  HEAPU32[timezone >>> 2 >>> 0] = stdTimezoneOffset * 60;
3007
2931
  HEAP32[daylight >>> 2 >>> 0] = Number(winterOffset != summerOffset);
3008
- const extractZone = (timezoneOffset) => {
3009
- const sign = timezoneOffset >= 0 ? "-" : "+";
3010
- const absOffset = Math.abs(timezoneOffset);
3011
- const hours = String(Math.floor(absOffset / 60)).padStart(2, "0");
3012
- const minutes = String(absOffset % 60).padStart(2, "0");
2932
+ var extractZone = (timezoneOffset) => {
2933
+ var sign = timezoneOffset >= 0 ? "-" : "+";
2934
+ var absOffset = Math.abs(timezoneOffset);
2935
+ var hours = String(Math.floor(absOffset / 60)).padStart(2, "0");
2936
+ var minutes = String(absOffset % 60).padStart(2, "0");
3013
2937
  return `UTC${sign}${hours}${minutes}`;
3014
2938
  };
3015
- const winterName = extractZone(winterOffset);
3016
- const summerName = extractZone(summerOffset);
2939
+ var winterName = extractZone(winterOffset);
2940
+ var summerName = extractZone(summerOffset);
3017
2941
  if (summerOffset < winterOffset) {
3018
2942
  stringToUTF8(winterName, std_name, 17);
3019
2943
  stringToUTF8(summerName, dst_name, 17);
@@ -3022,25 +2946,25 @@ async function createRimeModule(moduleArg = {}) {
3022
2946
  stringToUTF8(summerName, std_name, 17);
3023
2947
  }
3024
2948
  };
3025
- const _emscripten_date_now = () => Date.now();
3026
- const nowIsMonotonic = 1;
3027
- const checkWasiClock = (clock_id) => clock_id >= 0 && clock_id <= 3;
2949
+ var _emscripten_date_now = () => Date.now();
2950
+ var nowIsMonotonic = 1;
2951
+ var checkWasiClock = (clock_id) => clock_id >= 0 && clock_id <= 3;
3028
2952
  function _clock_time_get(clk_id, ignored_precision, ptime) {
3029
2953
  ignored_precision = bigintToI53Checked(ignored_precision);
3030
2954
  ptime >>>= 0;
3031
2955
  if (!checkWasiClock(clk_id)) return 28;
3032
- let now;
2956
+ var now;
3033
2957
  if (clk_id === 0) now = _emscripten_date_now();
3034
2958
  else if (nowIsMonotonic) now = _emscripten_get_now();
3035
2959
  else return 52;
3036
- const nsec = Math.round(now * 1e3 * 1e3);
2960
+ var nsec = Math.round(now * 1e3 * 1e3);
3037
2961
  HEAP64[ptime >>> 3 >>> 0] = BigInt(nsec);
3038
2962
  return 0;
3039
2963
  }
3040
- const getHeapMax = () => 4294901760;
3041
- const growMemory = (size) => {
3042
- const oldHeapSize = wasmMemory.buffer.byteLength;
3043
- const pages = (size - oldHeapSize + 65535) / 65536 | 0;
2964
+ var getHeapMax = () => 4294901760;
2965
+ var growMemory = (size) => {
2966
+ var oldHeapSize = wasmMemory.buffer.byteLength;
2967
+ var pages = (size - oldHeapSize + 65535) / 65536 | 0;
3044
2968
  try {
3045
2969
  wasmMemory.grow(pages);
3046
2970
  updateMemoryViews();
@@ -3049,24 +2973,24 @@ async function createRimeModule(moduleArg = {}) {
3049
2973
  };
3050
2974
  function _emscripten_resize_heap(requestedSize) {
3051
2975
  requestedSize >>>= 0;
3052
- const oldSize = HEAPU8.length;
3053
- const maxHeapSize = getHeapMax();
2976
+ var oldSize = HEAPU8.length;
2977
+ var maxHeapSize = getHeapMax();
3054
2978
  if (requestedSize > maxHeapSize) return false;
3055
- for (let cutDown = 1; cutDown <= 4; cutDown *= 2) {
3056
- let overGrownHeapSize = oldSize * (1 + .2 / cutDown);
2979
+ for (var cutDown = 1; cutDown <= 4; cutDown *= 2) {
2980
+ var overGrownHeapSize = oldSize * (1 + .2 / cutDown);
3057
2981
  overGrownHeapSize = Math.min(overGrownHeapSize, requestedSize + 100663296);
3058
- const newSize = Math.min(maxHeapSize, alignMemory(Math.max(requestedSize, overGrownHeapSize), 65536));
3059
- const replacement = growMemory(newSize);
2982
+ var newSize = Math.min(maxHeapSize, alignMemory(Math.max(requestedSize, overGrownHeapSize), 65536));
2983
+ var replacement = growMemory(newSize);
3060
2984
  if (replacement) return true;
3061
2985
  }
3062
2986
  return false;
3063
2987
  }
3064
- const ENV = {};
3065
- const getExecutableName = () => thisProgram || "./this.program";
3066
- const getEnvStrings = () => {
2988
+ var ENV = {};
2989
+ var getExecutableName = () => thisProgram || "./this.program";
2990
+ var getEnvStrings = () => {
3067
2991
  if (!getEnvStrings.strings) {
3068
- const lang = `${(globalThis.navigator?.language ?? "C").replace("-", "_")}.UTF-8`;
3069
- const env = {
2992
+ var lang = (globalThis.navigator?.language ?? "C").replace("-", "_") + ".UTF-8";
2993
+ var env = {
3070
2994
  USER: "web_user",
3071
2995
  LOGNAME: "web_user",
3072
2996
  PATH: "/",
@@ -3077,7 +3001,7 @@ async function createRimeModule(moduleArg = {}) {
3077
3001
  };
3078
3002
  for (var x in ENV) if (ENV[x] === void 0) delete env[x];
3079
3003
  else env[x] = ENV[x];
3080
- const strings = [];
3004
+ var strings = [];
3081
3005
  for (var x in env) strings.push(`${x}=${env[x]}`);
3082
3006
  getEnvStrings.strings = strings;
3083
3007
  }
@@ -3086,10 +3010,10 @@ async function createRimeModule(moduleArg = {}) {
3086
3010
  function _environ_get(__environ, environ_buf) {
3087
3011
  __environ >>>= 0;
3088
3012
  environ_buf >>>= 0;
3089
- let bufSize = 0;
3090
- let envp = 0;
3091
- for (const string of getEnvStrings()) {
3092
- const ptr = environ_buf + bufSize;
3013
+ var bufSize = 0;
3014
+ var envp = 0;
3015
+ for (var string of getEnvStrings()) {
3016
+ var ptr = environ_buf + bufSize;
3093
3017
  HEAPU32[__environ + envp >>> 2 >>> 0] = ptr;
3094
3018
  bufSize += stringToUTF8(string, ptr, Infinity) + 1;
3095
3019
  envp += 4;
@@ -3099,16 +3023,16 @@ async function createRimeModule(moduleArg = {}) {
3099
3023
  function _environ_sizes_get(penviron_count, penviron_buf_size) {
3100
3024
  penviron_count >>>= 0;
3101
3025
  penviron_buf_size >>>= 0;
3102
- const strings = getEnvStrings();
3026
+ var strings = getEnvStrings();
3103
3027
  HEAPU32[penviron_count >>> 2 >>> 0] = strings.length;
3104
- let bufSize = 0;
3105
- for (const string of strings) bufSize += lengthBytesUTF8(string) + 1;
3028
+ var bufSize = 0;
3029
+ for (var string of strings) bufSize += lengthBytesUTF8(string) + 1;
3106
3030
  HEAPU32[penviron_buf_size >>> 2 >>> 0] = bufSize;
3107
3031
  return 0;
3108
3032
  }
3109
3033
  function _fd_close(fd) {
3110
3034
  try {
3111
- const stream = SYSCALLS.getStreamFromFD(fd);
3035
+ var stream = SYSCALLS.getStreamFromFD(fd);
3112
3036
  FS.close(stream);
3113
3037
  return 0;
3114
3038
  } catch (e) {
@@ -3119,11 +3043,11 @@ async function createRimeModule(moduleArg = {}) {
3119
3043
  function _fd_fdstat_get(fd, pbuf) {
3120
3044
  pbuf >>>= 0;
3121
3045
  try {
3122
- const rightsBase = 0;
3123
- const rightsInheriting = 0;
3124
- const flags = 0;
3046
+ var rightsBase = 0;
3047
+ var rightsInheriting = 0;
3048
+ var flags = 0;
3125
3049
  {
3126
- const stream = SYSCALLS.getStreamFromFD(fd);
3050
+ var stream = SYSCALLS.getStreamFromFD(fd);
3127
3051
  var type = stream.tty ? 2 : FS.isDir(stream.mode) ? 3 : FS.isLink(stream.mode) ? 7 : 4;
3128
3052
  }
3129
3053
  HEAP8[pbuf >>> 0] = type;
@@ -3136,13 +3060,13 @@ async function createRimeModule(moduleArg = {}) {
3136
3060
  return e.errno;
3137
3061
  }
3138
3062
  }
3139
- const doReadv = (stream, iov, iovcnt, offset) => {
3140
- let ret = 0;
3141
- for (let i = 0; i < iovcnt; i++) {
3142
- const ptr = HEAPU32[iov >>> 2 >>> 0];
3143
- const len = HEAPU32[iov + 4 >>> 2 >>> 0];
3063
+ var doReadv = (stream, iov, iovcnt, offset) => {
3064
+ var ret = 0;
3065
+ for (var i = 0; i < iovcnt; i++) {
3066
+ var ptr = HEAPU32[iov >>> 2 >>> 0];
3067
+ var len = HEAPU32[iov + 4 >>> 2 >>> 0];
3144
3068
  iov += 8;
3145
- const curr = FS.read(stream, HEAP8, ptr, len, offset);
3069
+ var curr = FS.read(stream, HEAP8, ptr, len, offset);
3146
3070
  if (curr < 0) return -1;
3147
3071
  ret += curr;
3148
3072
  if (curr < len) break;
@@ -3157,8 +3081,8 @@ async function createRimeModule(moduleArg = {}) {
3157
3081
  pnum >>>= 0;
3158
3082
  try {
3159
3083
  if (isNaN(offset)) return 61;
3160
- const stream = SYSCALLS.getStreamFromFD(fd);
3161
- const num = doReadv(stream, iov, iovcnt, offset);
3084
+ var stream = SYSCALLS.getStreamFromFD(fd);
3085
+ var num = doReadv(stream, iov, iovcnt, offset);
3162
3086
  HEAPU32[pnum >>> 2 >>> 0] = num;
3163
3087
  return 0;
3164
3088
  } catch (e) {
@@ -3171,8 +3095,8 @@ async function createRimeModule(moduleArg = {}) {
3171
3095
  iovcnt >>>= 0;
3172
3096
  pnum >>>= 0;
3173
3097
  try {
3174
- const stream = SYSCALLS.getStreamFromFD(fd);
3175
- const num = doReadv(stream, iov, iovcnt);
3098
+ var stream = SYSCALLS.getStreamFromFD(fd);
3099
+ var num = doReadv(stream, iov, iovcnt);
3176
3100
  HEAPU32[pnum >>> 2 >>> 0] = num;
3177
3101
  return 0;
3178
3102
  } catch (e) {
@@ -3185,7 +3109,7 @@ async function createRimeModule(moduleArg = {}) {
3185
3109
  newOffset >>>= 0;
3186
3110
  try {
3187
3111
  if (isNaN(offset)) return 61;
3188
- const stream = SYSCALLS.getStreamFromFD(fd);
3112
+ var stream = SYSCALLS.getStreamFromFD(fd);
3189
3113
  FS.llseek(stream, offset, whence);
3190
3114
  HEAP64[newOffset >>> 3 >>> 0] = BigInt(stream.position);
3191
3115
  if (stream.getdents && offset === 0 && whence === 0) stream.getdents = null;
@@ -3195,13 +3119,13 @@ async function createRimeModule(moduleArg = {}) {
3195
3119
  return e.errno;
3196
3120
  }
3197
3121
  }
3198
- const doWritev = (stream, iov, iovcnt, offset) => {
3199
- let ret = 0;
3200
- for (let i = 0; i < iovcnt; i++) {
3201
- const ptr = HEAPU32[iov >>> 2 >>> 0];
3202
- const len = HEAPU32[iov + 4 >>> 2 >>> 0];
3122
+ var doWritev = (stream, iov, iovcnt, offset) => {
3123
+ var ret = 0;
3124
+ for (var i = 0; i < iovcnt; i++) {
3125
+ var ptr = HEAPU32[iov >>> 2 >>> 0];
3126
+ var len = HEAPU32[iov + 4 >>> 2 >>> 0];
3203
3127
  iov += 8;
3204
- const curr = FS.write(stream, HEAP8, ptr, len, offset);
3128
+ var curr = FS.write(stream, HEAP8, ptr, len, offset);
3205
3129
  if (curr < 0) return -1;
3206
3130
  ret += curr;
3207
3131
  if (curr < len) break;
@@ -3214,8 +3138,8 @@ async function createRimeModule(moduleArg = {}) {
3214
3138
  iovcnt >>>= 0;
3215
3139
  pnum >>>= 0;
3216
3140
  try {
3217
- const stream = SYSCALLS.getStreamFromFD(fd);
3218
- const num = doWritev(stream, iov, iovcnt);
3141
+ var stream = SYSCALLS.getStreamFromFD(fd);
3142
+ var num = doWritev(stream, iov, iovcnt);
3219
3143
  HEAPU32[pnum >>> 2 >>> 0] = num;
3220
3144
  return 0;
3221
3145
  } catch (e) {
@@ -3234,31 +3158,31 @@ async function createRimeModule(moduleArg = {}) {
3234
3158
  return e.errno;
3235
3159
  }
3236
3160
  }
3237
- const getCFunc = (ident) => {
3238
- const func = Module[`_${ident}`];
3161
+ var getCFunc = (ident) => {
3162
+ var func = Module["_" + ident];
3239
3163
  return func;
3240
3164
  };
3241
- const writeArrayToMemory = (array, buffer) => {
3165
+ var writeArrayToMemory = (array, buffer) => {
3242
3166
  HEAP8.set(array, buffer >>> 0);
3243
3167
  };
3244
- const stackAlloc = (sz) => __emscripten_stack_alloc(sz);
3245
- const stringToUTF8OnStack = (str) => {
3246
- const size = lengthBytesUTF8(str) + 1;
3247
- const ret = stackAlloc(size);
3168
+ var stackAlloc = (sz) => __emscripten_stack_alloc(sz);
3169
+ var stringToUTF8OnStack = (str) => {
3170
+ var size = lengthBytesUTF8(str) + 1;
3171
+ var ret = stackAlloc(size);
3248
3172
  stringToUTF8(str, ret, size);
3249
3173
  return ret;
3250
3174
  };
3251
- const stackSave = () => _emscripten_stack_get_current();
3252
- const stackRestore = (val) => __emscripten_stack_restore(val);
3253
- const ccall = (ident, returnType, argTypes, args, opts) => {
3254
- const toC = {
3175
+ var stackSave = () => _emscripten_stack_get_current();
3176
+ var stackRestore = (val) => __emscripten_stack_restore(val);
3177
+ var ccall = (ident, returnType, argTypes, args, opts) => {
3178
+ var toC = {
3255
3179
  string: (str) => {
3256
- let ret$1 = 0;
3180
+ var ret$1 = 0;
3257
3181
  if (str !== null && str !== void 0 && str !== 0) ret$1 = stringToUTF8OnStack(str);
3258
3182
  return ret$1;
3259
3183
  },
3260
3184
  array: (arr) => {
3261
- const ret$1 = stackAlloc(arr.length);
3185
+ var ret$1 = stackAlloc(arr.length);
3262
3186
  writeArrayToMemory(arr, ret$1);
3263
3187
  return ret$1;
3264
3188
  }
@@ -3269,17 +3193,17 @@ async function createRimeModule(moduleArg = {}) {
3269
3193
  if (returnType === "boolean") return Boolean(ret$1);
3270
3194
  return ret$1;
3271
3195
  }
3272
- const func = getCFunc(ident);
3273
- const cArgs = [];
3274
- let stack = 0;
3275
- if (args) for (let i = 0; i < args.length; i++) {
3276
- const converter = toC[argTypes[i]];
3196
+ var func = getCFunc(ident);
3197
+ var cArgs = [];
3198
+ var stack = 0;
3199
+ if (args) for (var i = 0; i < args.length; i++) {
3200
+ var converter = toC[argTypes[i]];
3277
3201
  if (converter) {
3278
3202
  if (stack === 0) stack = stackSave();
3279
3203
  cArgs[i] = converter(args[i]);
3280
3204
  } else cArgs[i] = args[i];
3281
3205
  }
3282
- let ret = func(...cArgs);
3206
+ var ret = func(...cArgs);
3283
3207
  function onDone(ret$1) {
3284
3208
  if (stack !== 0) stackRestore(stack);
3285
3209
  return convertReturnValue(ret$1);
@@ -3287,56 +3211,56 @@ async function createRimeModule(moduleArg = {}) {
3287
3211
  ret = onDone(ret);
3288
3212
  return ret;
3289
3213
  };
3290
- const FS_createPath = (...args) => FS.createPath(...args);
3291
- const FS_unlink = (...args) => FS.unlink(...args);
3292
- const FS_createLazyFile = (...args) => FS.createLazyFile(...args);
3293
- const FS_createDevice = (...args) => FS.createDevice(...args);
3214
+ var FS_createPath = (...args) => FS.createPath(...args);
3215
+ var FS_unlink = (...args) => FS.unlink(...args);
3216
+ var FS_createLazyFile = (...args) => FS.createLazyFile(...args);
3217
+ var FS_createDevice = (...args) => FS.createDevice(...args);
3294
3218
  FS.createPreloadedFile = FS_createPreloadedFile;
3295
3219
  FS.preloadFile = FS_preloadFile;
3296
3220
  FS.staticInit();
3297
3221
  {
3298
- if (Module.noExitRuntime) noExitRuntime = Module.noExitRuntime;
3299
- if (Module.preloadPlugins) preloadPlugins = Module.preloadPlugins;
3300
- if (Module.print) out = Module.print;
3301
- if (Module.printErr) err = Module.printErr;
3302
- if (Module.wasmBinary) wasmBinary = Module.wasmBinary;
3303
- if (Module.arguments) arguments_ = Module.arguments;
3304
- if (Module.thisProgram) thisProgram = Module.thisProgram;
3305
- if (Module.preInit) {
3306
- if (typeof Module.preInit == "function") Module.preInit = [Module.preInit];
3307
- while (Module.preInit.length > 0) Module.preInit.shift()();
3222
+ if (Module["noExitRuntime"]) noExitRuntime = Module["noExitRuntime"];
3223
+ if (Module["preloadPlugins"]) preloadPlugins = Module["preloadPlugins"];
3224
+ if (Module["print"]) out = Module["print"];
3225
+ if (Module["printErr"]) err = Module["printErr"];
3226
+ if (Module["wasmBinary"]) wasmBinary = Module["wasmBinary"];
3227
+ if (Module["arguments"]) arguments_ = Module["arguments"];
3228
+ if (Module["thisProgram"]) thisProgram = Module["thisProgram"];
3229
+ if (Module["preInit"]) {
3230
+ if (typeof Module["preInit"] == "function") Module["preInit"] = [Module["preInit"]];
3231
+ while (Module["preInit"].length > 0) Module["preInit"].shift()();
3308
3232
  }
3309
3233
  }
3310
- Module.addRunDependency = addRunDependency;
3311
- Module.removeRunDependency = removeRunDependency;
3312
- Module.ccall = ccall;
3313
- Module.FS_preloadFile = FS_preloadFile;
3314
- Module.FS_unlink = FS_unlink;
3315
- Module.FS_createPath = FS_createPath;
3316
- Module.FS_createDevice = FS_createDevice;
3317
- Module.FS = FS;
3318
- Module.FS_createDataFile = FS_createDataFile;
3319
- Module.FS_createLazyFile = FS_createLazyFile;
3320
- let _free, _malloc, _rime_wasm_init, _rime_wasm_process_input, _rime_wasm_pick_candidate, _rime_wasm_flip_page, _rime_wasm_clear_input, _rime_wasm_set_option, _rime_wasm_get_version, _rime_wasm_destroy, _emscripten_builtin_memalign, __emscripten_timeout, ___trap, __emscripten_stack_restore, __emscripten_stack_alloc, _emscripten_stack_get_current, memory, __indirect_function_table, wasmMemory;
3234
+ Module["addRunDependency"] = addRunDependency;
3235
+ Module["removeRunDependency"] = removeRunDependency;
3236
+ Module["ccall"] = ccall;
3237
+ Module["FS_preloadFile"] = FS_preloadFile;
3238
+ Module["FS_unlink"] = FS_unlink;
3239
+ Module["FS_createPath"] = FS_createPath;
3240
+ Module["FS_createDevice"] = FS_createDevice;
3241
+ Module["FS"] = FS;
3242
+ Module["FS_createDataFile"] = FS_createDataFile;
3243
+ Module["FS_createLazyFile"] = FS_createLazyFile;
3244
+ var _free, _malloc, _rime_wasm_init, _rime_wasm_process_input, _rime_wasm_pick_candidate, _rime_wasm_flip_page, _rime_wasm_clear_input, _rime_wasm_set_option, _rime_wasm_get_version, _rime_wasm_destroy, _emscripten_builtin_memalign, __emscripten_timeout, ___trap, __emscripten_stack_restore, __emscripten_stack_alloc, _emscripten_stack_get_current, memory, __indirect_function_table, wasmMemory;
3321
3245
  function assignWasmExports(wasmExports$1) {
3322
- _free = Module._free = wasmExports$1.R;
3323
- _malloc = Module._malloc = wasmExports$1.S;
3324
- _rime_wasm_init = Module._rime_wasm_init = wasmExports$1.T;
3325
- _rime_wasm_process_input = Module._rime_wasm_process_input = wasmExports$1.U;
3326
- _rime_wasm_pick_candidate = Module._rime_wasm_pick_candidate = wasmExports$1.V;
3327
- _rime_wasm_flip_page = Module._rime_wasm_flip_page = wasmExports$1.W;
3328
- _rime_wasm_clear_input = Module._rime_wasm_clear_input = wasmExports$1.X;
3329
- _rime_wasm_set_option = Module._rime_wasm_set_option = wasmExports$1.Y;
3330
- _rime_wasm_get_version = Module._rime_wasm_get_version = wasmExports$1.Z;
3331
- _rime_wasm_destroy = Module._rime_wasm_destroy = wasmExports$1._;
3332
- _emscripten_builtin_memalign = wasmExports$1.$;
3333
- __emscripten_timeout = wasmExports$1.aa;
3334
- ___trap = wasmExports$1.ba;
3335
- __emscripten_stack_restore = wasmExports$1.ca;
3336
- __emscripten_stack_alloc = wasmExports$1.da;
3337
- _emscripten_stack_get_current = wasmExports$1.ea;
3338
- memory = wasmMemory = wasmExports$1.P;
3339
- __indirect_function_table = wasmExports$1.__indirect_function_table;
3246
+ _free = Module["_free"] = wasmExports$1["R"];
3247
+ _malloc = Module["_malloc"] = wasmExports$1["S"];
3248
+ _rime_wasm_init = Module["_rime_wasm_init"] = wasmExports$1["T"];
3249
+ _rime_wasm_process_input = Module["_rime_wasm_process_input"] = wasmExports$1["U"];
3250
+ _rime_wasm_pick_candidate = Module["_rime_wasm_pick_candidate"] = wasmExports$1["V"];
3251
+ _rime_wasm_flip_page = Module["_rime_wasm_flip_page"] = wasmExports$1["W"];
3252
+ _rime_wasm_clear_input = Module["_rime_wasm_clear_input"] = wasmExports$1["X"];
3253
+ _rime_wasm_set_option = Module["_rime_wasm_set_option"] = wasmExports$1["Y"];
3254
+ _rime_wasm_get_version = Module["_rime_wasm_get_version"] = wasmExports$1["Z"];
3255
+ _rime_wasm_destroy = Module["_rime_wasm_destroy"] = wasmExports$1["_"];
3256
+ _emscripten_builtin_memalign = wasmExports$1["$"];
3257
+ __emscripten_timeout = wasmExports$1["aa"];
3258
+ ___trap = wasmExports$1["ba"];
3259
+ __emscripten_stack_restore = wasmExports$1["ca"];
3260
+ __emscripten_stack_alloc = wasmExports$1["da"];
3261
+ _emscripten_stack_get_current = wasmExports$1["ea"];
3262
+ memory = wasmMemory = wasmExports$1["P"];
3263
+ __indirect_function_table = wasmExports$1["__indirect_function_table"];
3340
3264
  }
3341
3265
  var wasmImports = {
3342
3266
  r: ___syscall_chmod,
@@ -3383,13 +3307,13 @@ async function createRimeModule(moduleArg = {}) {
3383
3307
  };
3384
3308
  function applySignatureConversions(wasmExports$1) {
3385
3309
  wasmExports$1 = Object.assign({}, wasmExports$1);
3386
- const makeWrapper_pp = (f) => (a0) => f(a0) >>> 0;
3387
- const makeWrapper_ppp = (f) => (a0, a1) => f(a0, a1) >>> 0;
3388
- const makeWrapper_p = (f) => () => f() >>> 0;
3389
- wasmExports$1.S = makeWrapper_pp(wasmExports$1.S);
3390
- wasmExports$1.$ = makeWrapper_ppp(wasmExports$1.$);
3391
- wasmExports$1.da = makeWrapper_pp(wasmExports$1.da);
3392
- wasmExports$1.ea = makeWrapper_p(wasmExports$1.ea);
3310
+ var makeWrapper_pp = (f) => (a0) => f(a0) >>> 0;
3311
+ var makeWrapper_ppp = (f) => (a0, a1) => f(a0, a1) >>> 0;
3312
+ var makeWrapper_p = (f) => () => f() >>> 0;
3313
+ wasmExports$1["S"] = makeWrapper_pp(wasmExports$1["S"]);
3314
+ wasmExports$1["$"] = makeWrapper_ppp(wasmExports$1["$"]);
3315
+ wasmExports$1["da"] = makeWrapper_pp(wasmExports$1["da"]);
3316
+ wasmExports$1["ea"] = makeWrapper_p(wasmExports$1["ea"]);
3393
3317
  return wasmExports$1;
3394
3318
  }
3395
3319
  function run() {
@@ -3403,22 +3327,22 @@ async function createRimeModule(moduleArg = {}) {
3403
3327
  return;
3404
3328
  }
3405
3329
  function doRun() {
3406
- Module.calledRun = true;
3330
+ Module["calledRun"] = true;
3407
3331
  if (ABORT) return;
3408
3332
  initRuntime();
3409
3333
  readyPromiseResolve?.(Module);
3410
- Module.onRuntimeInitialized?.();
3334
+ Module["onRuntimeInitialized"]?.();
3411
3335
  postRun();
3412
3336
  }
3413
- if (Module.setStatus) {
3414
- Module.setStatus("Running...");
3337
+ if (Module["setStatus"]) {
3338
+ Module["setStatus"]("Running...");
3415
3339
  setTimeout(() => {
3416
- setTimeout(() => Module.setStatus(""), 1);
3340
+ setTimeout(() => Module["setStatus"](""), 1);
3417
3341
  doRun();
3418
3342
  }, 1);
3419
3343
  } else doRun();
3420
3344
  }
3421
- let wasmExports;
3345
+ var wasmExports;
3422
3346
  wasmExports = await createWasm();
3423
3347
  run();
3424
3348
  if (runtimeInitialized) moduleRtn = Module;