@zh-keyboard/pinyin 1.1.0 → 1.1.2

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,22 @@
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;
17
- if (isPthread || isWasmWorker) return;
18
- const isNode = globalThis.process && globalThis.process.versions && globalThis.process.versions.node && globalThis.process.type != "renderer";
10
+ if (typeof ENVIRONMENT_IS_PTHREAD != "undefined" && ENVIRONMENT_IS_PTHREAD || typeof ENVIRONMENT_IS_WASM_WORKER != "undefined" && ENVIRONMENT_IS_WASM_WORKER) return;
19
11
  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;
12
+ if (typeof window === "object") window["encodeURIComponent"](window.location.pathname.substring(0, window.location.pathname.lastIndexOf("/")) + "/");
13
+ else if (typeof process === "undefined" && typeof location !== "undefined") encodeURIComponent(location.pathname.substring(0, location.pathname.lastIndexOf("/")) + "/");
14
+ var PACKAGE_NAME = "/home/zzx/work/librime/wasm/dist/rime-api.data";
15
+ var REMOTE_PACKAGE_BASE = "rime-api.data";
16
+ var REMOTE_PACKAGE_NAME = Module["locateFile"] ? Module["locateFile"](REMOTE_PACKAGE_BASE, "") : REMOTE_PACKAGE_BASE;
17
+ var REMOTE_PACKAGE_SIZE = metadata["remote_package_size"];
27
18
  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 = {};
19
+ if (!Module["dataFileDownloads"]) Module["dataFileDownloads"] = {};
33
20
  try {
34
21
  var response = await fetch(packageName);
35
22
  } catch (e) {
@@ -40,24 +27,24 @@ async function createRimeModule(moduleArg = {}) {
40
27
  const headers = response.headers;
41
28
  const total = Number(headers.get("Content-Length") || packageSize);
42
29
  let loaded = 0;
43
- Module.setStatus && Module.setStatus("Downloading data...");
30
+ Module["setStatus"] && Module["setStatus"]("Downloading data...");
44
31
  const reader = response.body.getReader();
45
32
  while (1) {
46
- const { done, value } = await reader.read();
33
+ var { done, value } = await reader.read();
47
34
  if (done) break;
48
35
  chunks.push(value);
49
36
  loaded += value.length;
50
- Module.dataFileDownloads[packageName] = {
37
+ Module["dataFileDownloads"][packageName] = {
51
38
  loaded,
52
39
  total
53
40
  };
54
41
  let totalLoaded = 0;
55
42
  let totalSize = 0;
56
- for (const download of Object.values(Module.dataFileDownloads)) {
43
+ for (const download of Object.values(Module["dataFileDownloads"])) {
57
44
  totalLoaded += download.loaded;
58
45
  totalSize += download.total;
59
46
  }
60
- Module.setStatus && Module.setStatus(`Downloading data... (${totalLoaded}/${totalSize})`);
47
+ Module["setStatus"] && Module["setStatus"](`Downloading data... (${totalLoaded}/${totalSize})`);
61
48
  }
62
49
  const packageData = new Uint8Array(chunks.map((c) => c.length).reduce((a, b) => a + b, 0));
63
50
  let offset = 0;
@@ -67,41 +54,41 @@ async function createRimeModule(moduleArg = {}) {
67
54
  }
68
55
  return packageData.buffer;
69
56
  }
70
- let fetchPromise;
71
- let fetched = Module.getPreloadedPackage && Module.getPreloadedPackage(REMOTE_PACKAGE_NAME, REMOTE_PACKAGE_SIZE);
57
+ var fetchPromise;
58
+ var fetched = Module["getPreloadedPackage"] && Module["getPreloadedPackage"](REMOTE_PACKAGE_NAME, REMOTE_PACKAGE_SIZE);
72
59
  if (!fetched) fetchPromise = fetchRemotePackage(REMOTE_PACKAGE_NAME, REMOTE_PACKAGE_SIZE);
73
- async function runWithFS(Module$1) {
60
+ async function runWithFS(Module) {
74
61
  function assert(check, msg) {
75
62
  if (!check) throw new Error(msg);
76
63
  }
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}`);
64
+ Module["FS_createPath"]("/", "rime", true, true);
65
+ Module["FS_createPath"]("/rime", "opencc", true, true);
66
+ for (var file of metadata["files"]) {
67
+ var name = file["filename"];
68
+ Module["addRunDependency"](`fp ${name}`);
82
69
  }
83
70
  async function processPackageData(arrayBuffer) {
84
71
  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}`);
72
+ assert(arrayBuffer.constructor.name === ArrayBuffer.name, "bad input to processPackageData " + arrayBuffer.constructor.name);
73
+ var byteArray = new Uint8Array(arrayBuffer);
74
+ for (var file of metadata["files"]) {
75
+ var name = file["filename"];
76
+ var data = byteArray.subarray(file["start"], file["end"]);
77
+ Module["FS_createDataFile"](name, null, data, true, true, true);
78
+ Module["removeRunDependency"](`fp ${name}`);
92
79
  }
93
- Module$1.removeRunDependency("datafile_/home/zzx/work/librime/wasm/dist/rime-api.data");
80
+ Module["removeRunDependency"]("datafile_/home/zzx/work/librime/wasm/dist/rime-api.data");
94
81
  }
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 };
82
+ Module["addRunDependency"]("datafile_/home/zzx/work/librime/wasm/dist/rime-api.data");
83
+ if (!Module["preloadResults"]) Module["preloadResults"] = {};
84
+ Module["preloadResults"][PACKAGE_NAME] = { fromCache: false };
98
85
  if (!fetched) fetched = await fetchPromise;
99
86
  processPackageData(fetched);
100
87
  }
101
- if (Module.calledRun) runWithFS(Module);
88
+ if (Module["calledRun"]) runWithFS(Module);
102
89
  else {
103
- if (!Module.preRun) Module.preRun = [];
104
- Module.preRun.push(runWithFS);
90
+ if (!Module["preRun"]) Module["preRun"] = [];
91
+ Module["preRun"].push(runWithFS);
105
92
  }
106
93
  }
107
94
  loadPackage({
@@ -140,128 +127,82 @@ async function createRimeModule(moduleArg = {}) {
140
127
  remote_package_size: 1027747
141
128
  });
142
129
  })();
143
- let arguments_ = [];
144
- let thisProgram = "./this.program";
145
- let quit_ = (status, toThrow) => {
130
+ var thisProgram = "./this.program";
131
+ var quit_ = (status, toThrow) => {
146
132
  throw toThrow;
147
133
  };
148
- const _scriptName = import.meta.url;
149
- let scriptDirectory = "";
134
+ var _scriptName = import.meta.url;
135
+ var scriptDirectory = "";
150
136
  function locateFile(path) {
151
- if (Module.locateFile) return Module.locateFile(path, scriptDirectory);
137
+ if (Module["locateFile"]) return Module["locateFile"](path, scriptDirectory);
152
138
  return scriptDirectory + path;
153
139
  }
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) {
140
+ var readAsync, readBinary;
141
+ if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
175
142
  try {
176
143
  scriptDirectory = new URL(".", _scriptName).href;
177
144
  } 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
- }
145
+ readAsync = async (url) => {
146
+ var response = await fetch(url, { credentials: "same-origin" });
147
+ if (response.ok) return response.arrayBuffer();
148
+ throw new Error(response.status + " : " + response.url);
149
+ };
206
150
  }
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;
151
+ var out = console.log.bind(console);
152
+ var err = console.error.bind(console);
153
+ var wasmBinary;
154
+ var ABORT = false;
155
+ var EXITSTATUS;
156
+ var readyPromiseResolve, readyPromiseReject, HEAP8, HEAPU8, HEAP16, HEAP32, HEAPU32, HEAP64;
157
+ var runtimeInitialized = false;
217
158
  function updateMemoryViews() {
218
- const b = wasmMemory.buffer;
159
+ var b = wasmMemory.buffer;
219
160
  HEAP8 = new Int8Array(b);
220
161
  HEAP16 = new Int16Array(b);
221
162
  HEAPU8 = new Uint8Array(b);
222
- HEAPU16 = new Uint16Array(b);
163
+ new Uint16Array(b);
223
164
  HEAP32 = new Int32Array(b);
224
165
  HEAPU32 = new Uint32Array(b);
225
- HEAPF32 = new Float32Array(b);
226
- HEAPF64 = new Float64Array(b);
166
+ new Float32Array(b);
167
+ new Float64Array(b);
227
168
  HEAP64 = new BigInt64Array(b);
228
- HEAPU64 = new BigUint64Array(b);
169
+ new BigUint64Array(b);
229
170
  }
230
171
  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());
172
+ if (Module["preRun"]) {
173
+ if (typeof Module["preRun"] == "function") Module["preRun"] = [Module["preRun"]];
174
+ while (Module["preRun"].length) addOnPreRun(Module["preRun"].shift());
234
175
  }
235
176
  callRuntimeCallbacks(onPreRuns);
236
177
  }
237
178
  function initRuntime() {
238
179
  runtimeInitialized = true;
239
- if (!Module.noFSInit && !FS.initialized) FS.init();
180
+ if (!Module["noFSInit"] && !FS.initialized) FS.init();
240
181
  TTY.init();
241
- wasmExports.Q();
182
+ wasmExports["Q"]();
242
183
  FS.ignorePermissions = false;
243
184
  }
244
185
  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());
186
+ if (Module["postRun"]) {
187
+ if (typeof Module["postRun"] == "function") Module["postRun"] = [Module["postRun"]];
188
+ while (Module["postRun"].length) addOnPostRun(Module["postRun"].shift());
248
189
  }
249
190
  callRuntimeCallbacks(onPostRuns);
250
191
  }
251
192
  function abort(what) {
252
- Module.onAbort?.(what);
253
- what = `Aborted(${what})`;
193
+ Module["onAbort"]?.(what);
194
+ what = "Aborted(" + what + ")";
254
195
  err(what);
255
196
  ABORT = true;
256
197
  what += ". Build with -sASSERTIONS for more info.";
257
198
  if (runtimeInitialized) ___trap();
258
- const e = new WebAssembly.RuntimeError(what);
199
+ var e = new WebAssembly.RuntimeError(what);
259
200
  readyPromiseReject?.(e);
260
201
  throw e;
261
202
  }
262
- let wasmBinaryFile;
203
+ var wasmBinaryFile;
263
204
  function findWasmBinary() {
264
- if (Module.locateFile) return locateFile("rime-api.wasm");
205
+ if (Module["locateFile"]) return locateFile("rime-api.wasm");
265
206
  return new URL("rime-api.wasm", import.meta.url).href;
266
207
  }
267
208
  function getBinarySync(file) {
@@ -271,26 +212,24 @@ async function createRimeModule(moduleArg = {}) {
271
212
  }
272
213
  async function getWasmBinary(binaryFile) {
273
214
  if (!wasmBinary) try {
274
- const response = await readAsync(binaryFile);
215
+ var response = await readAsync(binaryFile);
275
216
  return new Uint8Array(response);
276
217
  } catch {}
277
218
  return getBinarySync(binaryFile);
278
219
  }
279
220
  async function instantiateArrayBuffer(binaryFile, imports) {
280
221
  try {
281
- const binary = await getWasmBinary(binaryFile);
282
- const instance = await WebAssembly.instantiate(binary, imports);
283
- return instance;
222
+ var binary = await getWasmBinary(binaryFile);
223
+ return await WebAssembly.instantiate(binary, imports);
284
224
  } catch (reason) {
285
225
  err(`failed to asynchronously prepare wasm: ${reason}`);
286
226
  abort(reason);
287
227
  }
288
228
  }
289
229
  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);
293
- return instantiationResult;
230
+ if (!binary) try {
231
+ var response = fetch(binaryFile, { credentials: "same-origin" });
232
+ return await WebAssembly.instantiateStreaming(response, imports);
294
233
  } catch (reason) {
295
234
  err(`wasm streaming compile failed: ${reason}`);
296
235
  err("falling back to ArrayBuffer instantiation");
@@ -298,8 +237,7 @@ async function createRimeModule(moduleArg = {}) {
298
237
  return instantiateArrayBuffer(binaryFile, imports);
299
238
  }
300
239
  function getWasmImports() {
301
- const imports = { a: wasmImports };
302
- return imports;
240
+ return { a: wasmImports };
303
241
  }
304
242
  async function createWasm() {
305
243
  function receiveInstance(instance, module) {
@@ -309,19 +247,17 @@ async function createRimeModule(moduleArg = {}) {
309
247
  updateMemoryViews();
310
248
  return wasmExports;
311
249
  }
312
- function receiveInstantiationResult(result$1) {
313
- return receiveInstance(result$1.instance);
250
+ function receiveInstantiationResult(result) {
251
+ return receiveInstance(result["instance"]);
314
252
  }
315
- const info = getWasmImports();
316
- if (Module.instantiateWasm) return new Promise((resolve, reject) => {
317
- Module.instantiateWasm(info, (inst, mod) => {
253
+ var info = getWasmImports();
254
+ if (Module["instantiateWasm"]) return new Promise((resolve, reject) => {
255
+ Module["instantiateWasm"](info, (inst, mod) => {
318
256
  resolve(receiveInstance(inst, mod));
319
257
  });
320
258
  });
321
259
  wasmBinaryFile ??= findWasmBinary();
322
- const result = await instantiateAsync(wasmBinary, wasmBinaryFile, info);
323
- const exports = receiveInstantiationResult(result);
324
- return exports;
260
+ return receiveInstantiationResult(await instantiateAsync(wasmBinary, wasmBinaryFile, info));
325
261
  }
326
262
  class ExitStatus {
327
263
  name = "ExitStatus";
@@ -337,17 +273,16 @@ async function createRimeModule(moduleArg = {}) {
337
273
  var addOnPostRun = (cb) => onPostRuns.push(cb);
338
274
  var onPreRuns = [];
339
275
  var addOnPreRun = (cb) => onPreRuns.push(cb);
340
- let noExitRuntime = true;
276
+ var noExitRuntime = true;
341
277
  var PATH = {
342
278
  isAbs: (path) => path.charAt(0) === "/",
343
279
  splitPath: (filename) => {
344
- const splitPathRe = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^/]+?)?(\.[^./]*|))\/*$/;
345
- return splitPathRe.exec(filename).slice(1);
280
+ return /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(filename).slice(1);
346
281
  },
347
282
  normalizeArray: (parts, allowAboveRoot) => {
348
- let up = 0;
349
- for (let i = parts.length - 1; i >= 0; i--) {
350
- const last = parts[i];
283
+ var up = 0;
284
+ for (var i = parts.length - 1; i >= 0; i--) {
285
+ var last = parts[i];
351
286
  if (last === ".") parts.splice(i, 1);
352
287
  else if (last === "..") {
353
288
  parts.splice(i, 1);
@@ -361,44 +296,34 @@ async function createRimeModule(moduleArg = {}) {
361
296
  return parts;
362
297
  },
363
298
  normalize: (path) => {
364
- const isAbsolute = PATH.isAbs(path);
365
- const trailingSlash = path.slice(-1) === "/";
299
+ var isAbsolute = PATH.isAbs(path), trailingSlash = path.slice(-1) === "/";
366
300
  path = PATH.normalizeArray(path.split("/").filter((p) => !!p), !isAbsolute).join("/");
367
301
  if (!path && !isAbsolute) path = ".";
368
302
  if (path && trailingSlash) path += "/";
369
303
  return (isAbsolute ? "/" : "") + path;
370
304
  },
371
305
  dirname: (path) => {
372
- const result = PATH.splitPath(path);
373
- const root = result[0];
374
- let dir = result[1];
306
+ var result = PATH.splitPath(path), root = result[0], dir = result[1];
375
307
  if (!root && !dir) return ".";
376
308
  if (dir) dir = dir.slice(0, -1);
377
309
  return root + dir;
378
310
  },
379
- basename: (path) => path && path.match(/([^/]+|\/)\/*$/)[1],
311
+ basename: (path) => path && path.match(/([^\/]+|\/)\/*$/)[1],
380
312
  join: (...paths) => PATH.normalize(paths.join("/")),
381
- join2: (l, r) => PATH.normalize(`${l}/${r}`)
382
- };
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);
313
+ join2: (l, r) => PATH.normalize(l + "/" + r)
389
314
  };
390
- let randomFill = (view) => {
315
+ var initRandomFill = () => (view) => crypto.getRandomValues(view);
316
+ var randomFill = (view) => {
391
317
  (randomFill = initRandomFill())(view);
392
318
  };
393
319
  var PATH_FS = {
394
320
  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();
321
+ var resolvedPath = "", resolvedAbsolute = false;
322
+ for (var i = args.length - 1; i >= -1 && !resolvedAbsolute; i--) {
323
+ var path = i >= 0 ? args[i] : FS.cwd();
399
324
  if (typeof path != "string") throw new TypeError("Arguments to path.resolve must be strings");
400
325
  else if (!path) return "";
401
- resolvedPath = `${path}/${resolvedPath}`;
326
+ resolvedPath = path + "/" + resolvedPath;
402
327
  resolvedAbsolute = PATH.isAbs(path);
403
328
  }
404
329
  resolvedPath = PATH.normalizeArray(resolvedPath.split("/").filter((p) => !!p), !resolvedAbsolute).join("/");
@@ -408,44 +333,44 @@ async function createRimeModule(moduleArg = {}) {
408
333
  from = PATH_FS.resolve(from).slice(1);
409
334
  to = PATH_FS.resolve(to).slice(1);
410
335
  function trim(arr) {
411
- let start = 0;
336
+ var start = 0;
412
337
  for (; start < arr.length; start++) if (arr[start] !== "") break;
413
- let end = arr.length - 1;
338
+ var end = arr.length - 1;
414
339
  for (; end >= 0; end--) if (arr[end] !== "") break;
415
340
  if (start > end) return [];
416
341
  return arr.slice(start, end - start + 1);
417
342
  }
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;
343
+ var fromParts = trim(from.split("/"));
344
+ var toParts = trim(to.split("/"));
345
+ var length = Math.min(fromParts.length, toParts.length);
346
+ var samePartsLength = length;
422
347
  for (var i = 0; i < length; i++) if (fromParts[i] !== toParts[i]) {
423
348
  samePartsLength = i;
424
349
  break;
425
350
  }
426
- let outputParts = [];
351
+ var outputParts = [];
427
352
  for (var i = samePartsLength; i < fromParts.length; i++) outputParts.push("..");
428
353
  outputParts = outputParts.concat(toParts.slice(samePartsLength));
429
354
  return outputParts.join("/");
430
355
  }
431
356
  };
432
- const UTF8Decoder = new TextDecoder();
433
- const findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
434
- const maxIdx = idx + maxBytesToRead;
357
+ var UTF8Decoder = new TextDecoder();
358
+ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
359
+ var maxIdx = idx + maxBytesToRead;
435
360
  if (ignoreNul) return maxIdx;
436
361
  while (heapOrArray[idx] && !(idx >= maxIdx)) ++idx;
437
362
  return idx;
438
363
  };
439
- const UTF8ArrayToString = (heapOrArray, idx = 0, maxBytesToRead, ignoreNul) => {
364
+ var UTF8ArrayToString = (heapOrArray, idx = 0, maxBytesToRead, ignoreNul) => {
440
365
  idx >>>= 0;
441
- const endPtr = findStringEnd(heapOrArray, idx, maxBytesToRead, ignoreNul);
366
+ var endPtr = findStringEnd(heapOrArray, idx, maxBytesToRead, ignoreNul);
442
367
  return UTF8Decoder.decode(heapOrArray.buffer ? heapOrArray.subarray(idx, endPtr) : new Uint8Array(heapOrArray.slice(idx, endPtr)));
443
368
  };
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);
369
+ var FS_stdin_getChar_buffer = [];
370
+ var lengthBytesUTF8 = (str) => {
371
+ var len = 0;
372
+ for (var i = 0; i < str.length; ++i) {
373
+ var c = str.charCodeAt(i);
449
374
  if (c <= 127) len++;
450
375
  else if (c <= 2047) len += 2;
451
376
  else if (c >= 55296 && c <= 57343) {
@@ -455,13 +380,13 @@ async function createRimeModule(moduleArg = {}) {
455
380
  }
456
381
  return len;
457
382
  };
458
- const stringToUTF8Array = (str, heap, outIdx, maxBytesToWrite) => {
383
+ var stringToUTF8Array = (str, heap, outIdx, maxBytesToWrite) => {
459
384
  outIdx >>>= 0;
460
385
  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);
386
+ var startIdx = outIdx;
387
+ var endIdx = outIdx + maxBytesToWrite - 1;
388
+ for (var i = 0; i < str.length; ++i) {
389
+ var u = str.codePointAt(i);
465
390
  if (u <= 127) {
466
391
  if (outIdx >= endIdx) break;
467
392
  heap[outIdx++ >>> 0] = u;
@@ -486,29 +411,17 @@ async function createRimeModule(moduleArg = {}) {
486
411
  heap[outIdx >>> 0] = 0;
487
412
  return outIdx - startIdx;
488
413
  };
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);
414
+ var intArrayFromString = (stringy, dontAddNull, length) => {
415
+ var len = length > 0 ? length : lengthBytesUTF8(stringy) + 1;
416
+ var u8array = new Array(len);
417
+ var numBytesWritten = stringToUTF8Array(stringy, u8array, 0, u8array.length);
493
418
  if (dontAddNull) u8array.length = numBytesWritten;
494
419
  return u8array;
495
420
  };
496
- const FS_stdin_getChar = () => {
421
+ var FS_stdin_getChar = () => {
497
422
  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) {
423
+ var result = null;
424
+ if (globalThis.window?.prompt) {
512
425
  result = window.prompt("Input: ");
513
426
  if (result !== null) result += "\n";
514
427
  }
@@ -531,7 +444,7 @@ async function createRimeModule(moduleArg = {}) {
531
444
  },
532
445
  stream_ops: {
533
446
  open(stream) {
534
- const tty = TTY.ttys[stream.node.rdev];
447
+ var tty = TTY.ttys[stream.node.rdev];
535
448
  if (!tty) throw new FS.ErrnoError(43);
536
449
  stream.tty = tty;
537
450
  stream.seekable = false;
@@ -544,8 +457,8 @@ async function createRimeModule(moduleArg = {}) {
544
457
  },
545
458
  read(stream, buffer, offset, length, pos) {
546
459
  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++) {
460
+ var bytesRead = 0;
461
+ for (var i = 0; i < length; i++) {
549
462
  var result;
550
463
  try {
551
464
  result = stream.tty.ops.get_char(stream.tty);
@@ -651,11 +564,11 @@ async function createRimeModule(moduleArg = {}) {
651
564
  }
652
565
  }
653
566
  };
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) => {
567
+ var zeroMemory = (ptr, size) => HEAPU8.fill(0, ptr, ptr + size);
568
+ var alignMemory = (size, alignment) => Math.ceil(size / alignment) * alignment;
569
+ var mmapAlloc = (size) => {
657
570
  size = alignMemory(size, 65536);
658
- const ptr = _emscripten_builtin_memalign(65536, size);
571
+ var ptr = _emscripten_builtin_memalign(65536, size);
659
572
  if (ptr) zeroMemory(ptr, size);
660
573
  return ptr;
661
574
  };
@@ -710,7 +623,7 @@ async function createRimeModule(moduleArg = {}) {
710
623
  stream: FS.chrdev_stream_ops
711
624
  }
712
625
  };
713
- const node = FS.createNode(parent, name, mode, dev);
626
+ var node = FS.createNode(parent, name, mode, dev);
714
627
  if (FS.isDir(node.mode)) {
715
628
  node.node_ops = MEMFS.ops_table.dir.node;
716
629
  node.stream_ops = MEMFS.ops_table.dir.stream;
@@ -740,12 +653,11 @@ async function createRimeModule(moduleArg = {}) {
740
653
  return new Uint8Array(node.contents);
741
654
  },
742
655
  expandFileStorage(node, newCapacity) {
743
- const prevCapacity = node.contents ? node.contents.length : 0;
656
+ var prevCapacity = node.contents ? node.contents.length : 0;
744
657
  if (prevCapacity >= newCapacity) return;
745
- const CAPACITY_DOUBLING_MAX = 1024 * 1024;
746
- newCapacity = Math.max(newCapacity, prevCapacity * (prevCapacity < CAPACITY_DOUBLING_MAX ? 2 : 1.125) >>> 0);
658
+ newCapacity = Math.max(newCapacity, prevCapacity * (prevCapacity < 1024 * 1024 ? 2 : 1.125) >>> 0);
747
659
  if (prevCapacity != 0) newCapacity = Math.max(newCapacity, 256);
748
- const oldContents = node.contents;
660
+ var oldContents = node.contents;
749
661
  node.contents = new Uint8Array(newCapacity);
750
662
  if (node.usedBytes > 0) node.contents.set(oldContents.subarray(0, node.usedBytes), 0);
751
663
  },
@@ -755,7 +667,7 @@ async function createRimeModule(moduleArg = {}) {
755
667
  node.contents = null;
756
668
  node.usedBytes = 0;
757
669
  } else {
758
- const oldContents = node.contents;
670
+ var oldContents = node.contents;
759
671
  node.contents = new Uint8Array(newSize);
760
672
  if (oldContents) node.contents.set(oldContents.subarray(0, Math.min(newSize, node.usedBytes)));
761
673
  node.usedBytes = newSize;
@@ -763,7 +675,7 @@ async function createRimeModule(moduleArg = {}) {
763
675
  },
764
676
  node_ops: {
765
677
  getattr(node) {
766
- const attr = {};
678
+ var attr = {};
767
679
  attr.dev = FS.isChrdev(node.mode) ? node.id : 1;
768
680
  attr.ino = node.id;
769
681
  attr.mode = node.mode;
@@ -802,12 +714,12 @@ async function createRimeModule(moduleArg = {}) {
802
714
  return MEMFS.createNode(parent, name, mode, dev);
803
715
  },
804
716
  rename(old_node, new_dir, new_name) {
805
- let new_node;
717
+ var new_node;
806
718
  try {
807
719
  new_node = FS.lookupNode(new_dir, new_name);
808
720
  } catch (e) {}
809
721
  if (new_node) {
810
- if (FS.isDir(old_node.mode)) for (const i in new_node.contents) throw new FS.ErrnoError(55);
722
+ if (FS.isDir(old_node.mode)) for (var i in new_node.contents) throw new FS.ErrnoError(55);
811
723
  FS.hashRemoveNode(new_node);
812
724
  }
813
725
  delete old_node.parent.contents[old_node.name];
@@ -820,8 +732,7 @@ async function createRimeModule(moduleArg = {}) {
820
732
  parent.ctime = parent.mtime = Date.now();
821
733
  },
822
734
  rmdir(parent, name) {
823
- const node = FS.lookupNode(parent, name);
824
- for (const i in node.contents) throw new FS.ErrnoError(55);
735
+ for (var i in FS.lookupNode(parent, name).contents) throw new FS.ErrnoError(55);
825
736
  delete parent.contents[name];
826
737
  parent.ctime = parent.mtime = Date.now();
827
738
  },
@@ -833,7 +744,7 @@ async function createRimeModule(moduleArg = {}) {
833
744
  ];
834
745
  },
835
746
  symlink(parent, newname, oldpath) {
836
- const node = MEMFS.createNode(parent, newname, 41471, 0);
747
+ var node = MEMFS.createNode(parent, newname, 41471, 0);
837
748
  node.link = oldpath;
838
749
  return node;
839
750
  },
@@ -844,17 +755,17 @@ async function createRimeModule(moduleArg = {}) {
844
755
  },
845
756
  stream_ops: {
846
757
  read(stream, buffer, offset, length, position) {
847
- const contents = stream.node.contents;
758
+ var contents = stream.node.contents;
848
759
  if (position >= stream.node.usedBytes) return 0;
849
- const size = Math.min(stream.node.usedBytes - position, length);
760
+ var size = Math.min(stream.node.usedBytes - position, length);
850
761
  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];
762
+ else for (var i = 0; i < size; i++) buffer[offset + i] = contents[position + i];
852
763
  return size;
853
764
  },
854
765
  write(stream, buffer, offset, length, position, canOwn) {
855
766
  if (buffer.buffer === HEAP8.buffer) canOwn = false;
856
767
  if (!length) return 0;
857
- const node = stream.node;
768
+ var node = stream.node;
858
769
  node.mtime = node.ctime = Date.now();
859
770
  if (buffer.subarray && (!node.contents || node.contents.subarray)) {
860
771
  if (canOwn) {
@@ -872,12 +783,12 @@ async function createRimeModule(moduleArg = {}) {
872
783
  }
873
784
  MEMFS.expandFileStorage(node, position + length);
874
785
  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];
786
+ else for (var i = 0; i < length; i++) node.contents[position + i] = buffer[offset + i];
876
787
  node.usedBytes = Math.max(node.usedBytes, position + length);
877
788
  return length;
878
789
  },
879
790
  llseek(stream, offset, whence) {
880
- let position = offset;
791
+ var position = offset;
881
792
  if (whence === 1) position += stream.position;
882
793
  else if (whence === 2) {
883
794
  if (FS.isFile(stream.node.mode)) position += stream.node.usedBytes;
@@ -887,9 +798,9 @@ async function createRimeModule(moduleArg = {}) {
887
798
  },
888
799
  mmap(stream, length, position, prot, flags) {
889
800
  if (!FS.isFile(stream.node.mode)) throw new FS.ErrnoError(43);
890
- let ptr;
891
- let allocated;
892
- let contents = stream.node.contents;
801
+ var ptr;
802
+ var allocated;
803
+ var contents = stream.node.contents;
893
804
  if (!(flags & 2) && contents && contents.buffer === HEAP8.buffer) {
894
805
  allocated = false;
895
806
  ptr = contents.byteOffset;
@@ -914,21 +825,20 @@ async function createRimeModule(moduleArg = {}) {
914
825
  }
915
826
  }
916
827
  };
917
- const FS_modeStringToFlags = (str) => {
918
- const flagModes = {
919
- "r": 0,
828
+ var FS_modeStringToFlags = (str) => {
829
+ var flags = {
830
+ r: 0,
920
831
  "r+": 2,
921
- "w": 577,
832
+ w: 577,
922
833
  "w+": 578,
923
- "a": 1089,
834
+ a: 1089,
924
835
  "a+": 1090
925
- };
926
- const flags = flagModes[str];
927
- if (typeof flags == "undefined") throw new TypeError(`Unknown file open mode: ${str}`);
836
+ }[str];
837
+ if (typeof flags == "undefined") throw new Error(`Unknown file open mode: ${str}`);
928
838
  return flags;
929
839
  };
930
- const FS_getMode = (canRead, canWrite) => {
931
- let mode = 0;
840
+ var FS_getMode = (canRead, canWrite) => {
841
+ var mode = 0;
932
842
  if (canRead) mode |= 365;
933
843
  if (canWrite) mode |= 146;
934
844
  return mode;
@@ -951,13 +861,13 @@ async function createRimeModule(moduleArg = {}) {
951
861
  else if (mount.idbPersistState === "idb") mount.idbPersistState = "again";
952
862
  },
953
863
  mount: (mount) => {
954
- const mnt = MEMFS.mount(mount);
864
+ var mnt = MEMFS.mount(mount);
955
865
  if (mount?.opts?.autoPersist) {
956
866
  mount.idbPersistState = 0;
957
- const memfs_node_ops = mnt.node_ops;
867
+ var memfs_node_ops = mnt.node_ops;
958
868
  mnt.node_ops = { ...mnt.node_ops };
959
869
  mnt.node_ops.mknod = (parent, name, mode, dev) => {
960
- const node = memfs_node_ops.mknod(parent, name, mode, dev);
870
+ var node = memfs_node_ops.mknod(parent, name, mode, dev);
961
871
  node.node_ops = mnt.node_ops;
962
872
  node.idbfs_mount = mnt.mount;
963
873
  node.memfs_stream_ops = node.stream_ops;
@@ -967,7 +877,7 @@ async function createRimeModule(moduleArg = {}) {
967
877
  return node.memfs_stream_ops.write(stream, buffer, offset, length, position, canOwn);
968
878
  };
969
879
  node.stream_ops.close = (stream) => {
970
- const n = stream.node;
880
+ var n = stream.node;
971
881
  if (n.isModified) {
972
882
  IDBFS.queuePersist(n.idbfs_mount);
973
883
  n.isModified = false;
@@ -985,24 +895,24 @@ async function createRimeModule(moduleArg = {}) {
985
895
  return mnt;
986
896
  },
987
897
  syncfs: (mount, populate, callback) => {
988
- IDBFS.getLocalSet(mount, (err$1, local) => {
989
- if (err$1) return callback(err$1);
990
- IDBFS.getRemoteSet(mount, (err$2, remote) => {
991
- if (err$2) return callback(err$2);
992
- const src = populate ? remote : local;
993
- const dst = populate ? local : remote;
898
+ IDBFS.getLocalSet(mount, (err, local) => {
899
+ if (err) return callback(err);
900
+ IDBFS.getRemoteSet(mount, (err, remote) => {
901
+ if (err) return callback(err);
902
+ var src = populate ? remote : local;
903
+ var dst = populate ? local : remote;
994
904
  IDBFS.reconcile(src, dst, callback);
995
905
  });
996
906
  });
997
907
  },
998
908
  quit: () => {
999
- for (const value of Object.values(IDBFS.dbs)) value.close();
909
+ for (var value of Object.values(IDBFS.dbs)) value.close();
1000
910
  IDBFS.dbs = {};
1001
911
  },
1002
912
  getDB: (name, callback) => {
1003
- let db = IDBFS.dbs[name];
913
+ var db = IDBFS.dbs[name];
1004
914
  if (db) return callback(null, db);
1005
- let req;
915
+ var req;
1006
916
  try {
1007
917
  req = IDBFS.indexedDB().open(name, IDBFS.DB_VERSION);
1008
918
  } catch (e) {
@@ -1010,11 +920,11 @@ async function createRimeModule(moduleArg = {}) {
1010
920
  }
1011
921
  if (!req) return callback("Unable to connect to IndexedDB");
1012
922
  req.onupgradeneeded = (e) => {
1013
- const db$1 = e.target.result;
1014
- const transaction = e.target.transaction;
1015
- let fileStore;
1016
- if (db$1.objectStoreNames.contains(IDBFS.DB_STORE_NAME)) fileStore = transaction.objectStore(IDBFS.DB_STORE_NAME);
1017
- else fileStore = db$1.createObjectStore(IDBFS.DB_STORE_NAME);
923
+ var db = e.target.result;
924
+ var transaction = e.target.transaction;
925
+ var fileStore;
926
+ if (db.objectStoreNames.contains(IDBFS.DB_STORE_NAME)) fileStore = transaction.objectStore(IDBFS.DB_STORE_NAME);
927
+ else fileStore = db.createObjectStore(IDBFS.DB_STORE_NAME);
1018
928
  if (!fileStore.indexNames.contains("timestamp")) fileStore.createIndex("timestamp", "timestamp", { unique: false });
1019
929
  };
1020
930
  req.onsuccess = () => {
@@ -1028,16 +938,16 @@ async function createRimeModule(moduleArg = {}) {
1028
938
  };
1029
939
  },
1030
940
  getLocalSet: (mount, callback) => {
1031
- const entries = {};
941
+ var entries = {};
1032
942
  function isRealDir(p) {
1033
943
  return p !== "." && p !== "..";
1034
944
  }
1035
945
  function toAbsolute(root) {
1036
946
  return (p) => PATH.join2(root, p);
1037
947
  }
1038
- const check = FS.readdir(mount.mountpoint).filter(isRealDir).map(toAbsolute(mount.mountpoint));
948
+ var check = FS.readdir(mount.mountpoint).filter(isRealDir).map(toAbsolute(mount.mountpoint));
1039
949
  while (check.length) {
1040
- const path = check.pop();
950
+ var path = check.pop();
1041
951
  var stat;
1042
952
  try {
1043
953
  stat = FS.stat(path);
@@ -1053,19 +963,18 @@ async function createRimeModule(moduleArg = {}) {
1053
963
  });
1054
964
  },
1055
965
  getRemoteSet: (mount, callback) => {
1056
- const entries = {};
1057
- IDBFS.getDB(mount.mountpoint, (err$1, db) => {
1058
- if (err$1) return callback(err$1);
966
+ var entries = {};
967
+ IDBFS.getDB(mount.mountpoint, (err, db) => {
968
+ if (err) return callback(err);
1059
969
  try {
1060
- const transaction = db.transaction([IDBFS.DB_STORE_NAME], "readonly");
970
+ var transaction = db.transaction([IDBFS.DB_STORE_NAME], "readonly");
1061
971
  transaction.onerror = (e) => {
1062
972
  callback(e.target.error);
1063
973
  e.preventDefault();
1064
974
  };
1065
- const store = transaction.objectStore(IDBFS.DB_STORE_NAME);
1066
- const index = store.index("timestamp");
975
+ var index = transaction.objectStore(IDBFS.DB_STORE_NAME).index("timestamp");
1067
976
  index.openKeyCursor().onsuccess = (event) => {
1068
- const cursor = event.target.result;
977
+ var cursor = event.target.result;
1069
978
  if (!cursor) return callback(null, {
1070
979
  type: "remote",
1071
980
  db,
@@ -1080,10 +989,9 @@ async function createRimeModule(moduleArg = {}) {
1080
989
  });
1081
990
  },
1082
991
  loadLocalEntry: (path, callback) => {
1083
- let stat, node;
992
+ var stat, node;
1084
993
  try {
1085
- const lookup = FS.lookupPath(path);
1086
- node = lookup.node;
994
+ node = FS.lookupPath(path).node;
1087
995
  stat = FS.stat(path);
1088
996
  } catch (e) {
1089
997
  return callback(e);
@@ -1099,15 +1007,15 @@ async function createRimeModule(moduleArg = {}) {
1099
1007
  mode: stat.mode,
1100
1008
  contents: node.contents
1101
1009
  });
1102
- } else return callback(new Error("node type not supported"));
1010
+ } else return callback(/* @__PURE__ */ new Error("node type not supported"));
1103
1011
  },
1104
1012
  storeLocalEntry: (path, entry, callback) => {
1105
1013
  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 });
1108
- else return callback(new Error("node type not supported"));
1109
- FS.chmod(path, entry.mode);
1110
- FS.utime(path, entry.timestamp, entry.timestamp);
1014
+ if (FS.isDir(entry["mode"])) FS.mkdirTree(path, entry["mode"]);
1015
+ else if (FS.isFile(entry["mode"])) FS.writeFile(path, entry["contents"], { canOwn: true });
1016
+ else return callback(/* @__PURE__ */ new Error("node type not supported"));
1017
+ FS.chmod(path, entry["mode"]);
1018
+ FS.utime(path, entry["timestamp"], entry["timestamp"]);
1111
1019
  } catch (e) {
1112
1020
  return callback(e);
1113
1021
  }
@@ -1115,7 +1023,7 @@ async function createRimeModule(moduleArg = {}) {
1115
1023
  },
1116
1024
  removeLocalEntry: (path, callback) => {
1117
1025
  try {
1118
- const stat = FS.stat(path);
1026
+ var stat = FS.stat(path);
1119
1027
  if (FS.isDir(stat.mode)) FS.rmdir(path);
1120
1028
  else if (FS.isFile(stat.mode)) FS.unlink(path);
1121
1029
  } catch (e) {
@@ -1124,7 +1032,7 @@ async function createRimeModule(moduleArg = {}) {
1124
1032
  callback(null);
1125
1033
  },
1126
1034
  loadRemoteEntry: (store, path, callback) => {
1127
- const req = store.get(path);
1035
+ var req = store.get(path);
1128
1036
  req.onsuccess = (event) => callback(null, event.target.result);
1129
1037
  req.onerror = (e) => {
1130
1038
  callback(e.target.error);
@@ -1145,7 +1053,7 @@ async function createRimeModule(moduleArg = {}) {
1145
1053
  };
1146
1054
  },
1147
1055
  removeRemoteEntry: (store, path, callback) => {
1148
- const req = store.delete(path);
1056
+ var req = store.delete(path);
1149
1057
  req.onsuccess = (event) => callback();
1150
1058
  req.onerror = (e) => {
1151
1059
  callback(e.target.error);
@@ -1153,85 +1061,84 @@ async function createRimeModule(moduleArg = {}) {
1153
1061
  };
1154
1062
  },
1155
1063
  reconcile: (src, dst, callback) => {
1156
- let total = 0;
1157
- const create = [];
1064
+ var total = 0;
1065
+ var create = [];
1158
1066
  for (var [key, e] of Object.entries(src.entries)) {
1159
- const e2 = dst.entries[key];
1160
- if (!e2 || e.timestamp.getTime() != e2.timestamp.getTime()) {
1067
+ var e2 = dst.entries[key];
1068
+ if (!e2 || e["timestamp"].getTime() != e2["timestamp"].getTime()) {
1161
1069
  create.push(key);
1162
1070
  total++;
1163
1071
  }
1164
1072
  }
1165
- const remove = [];
1073
+ var remove = [];
1166
1074
  for (var key of Object.keys(dst.entries)) if (!src.entries[key]) {
1167
1075
  remove.push(key);
1168
1076
  total++;
1169
1077
  }
1170
1078
  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);
1175
- function done(err$1) {
1176
- if (err$1 && !errored) {
1079
+ var errored = false;
1080
+ var transaction = (src.type === "remote" ? src.db : dst.db).transaction([IDBFS.DB_STORE_NAME], "readwrite");
1081
+ var store = transaction.objectStore(IDBFS.DB_STORE_NAME);
1082
+ function done(err) {
1083
+ if (err && !errored) {
1177
1084
  errored = true;
1178
- return callback(err$1);
1085
+ return callback(err);
1179
1086
  }
1180
1087
  }
1181
- transaction.onerror = transaction.onabort = (e$1) => {
1182
- done(e$1.target.error);
1183
- e$1.preventDefault();
1088
+ transaction.onerror = transaction.onabort = (e) => {
1089
+ done(e.target.error);
1090
+ e.preventDefault();
1184
1091
  };
1185
- transaction.oncomplete = (e$1) => {
1092
+ transaction.oncomplete = (e) => {
1186
1093
  if (!errored) callback(null);
1187
1094
  };
1188
- for (const path of create.sort()) if (dst.type === "local") IDBFS.loadRemoteEntry(store, path, (err$1, entry) => {
1189
- if (err$1) return done(err$1);
1095
+ for (const path of create.sort()) if (dst.type === "local") IDBFS.loadRemoteEntry(store, path, (err, entry) => {
1096
+ if (err) return done(err);
1190
1097
  IDBFS.storeLocalEntry(path, entry, done);
1191
1098
  });
1192
- else IDBFS.loadLocalEntry(path, (err$1, entry) => {
1193
- if (err$1) return done(err$1);
1099
+ else IDBFS.loadLocalEntry(path, (err, entry) => {
1100
+ if (err) return done(err);
1194
1101
  IDBFS.storeRemoteEntry(store, path, entry, done);
1195
1102
  });
1196
- for (const path of remove.sort().reverse()) if (dst.type === "local") IDBFS.removeLocalEntry(path, done);
1103
+ for (var path of remove.sort().reverse()) if (dst.type === "local") IDBFS.removeLocalEntry(path, done);
1197
1104
  else IDBFS.removeRemoteEntry(store, path, done);
1198
1105
  }
1199
1106
  };
1200
- const asyncLoad = async (url) => {
1201
- const arrayBuffer = await readAsync(url);
1107
+ var asyncLoad = async (url) => {
1108
+ var arrayBuffer = await readAsync(url);
1202
1109
  return new Uint8Array(arrayBuffer);
1203
1110
  };
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) => {
1111
+ var FS_createDataFile = (...args) => FS.createDataFile(...args);
1112
+ var getUniqueRunDependency = (id) => id;
1113
+ var runDependencies = 0;
1114
+ var dependenciesFulfilled = null;
1115
+ var removeRunDependency = (id) => {
1209
1116
  runDependencies--;
1210
- Module.monitorRunDependencies?.(runDependencies);
1117
+ Module["monitorRunDependencies"]?.(runDependencies);
1211
1118
  if (runDependencies == 0) {
1212
1119
  if (dependenciesFulfilled) {
1213
- const callback = dependenciesFulfilled;
1120
+ var callback = dependenciesFulfilled;
1214
1121
  dependenciesFulfilled = null;
1215
1122
  callback();
1216
1123
  }
1217
1124
  }
1218
1125
  };
1219
- const addRunDependency = (id) => {
1126
+ var addRunDependency = (id) => {
1220
1127
  runDependencies++;
1221
- Module.monitorRunDependencies?.(runDependencies);
1128
+ Module["monitorRunDependencies"]?.(runDependencies);
1222
1129
  };
1223
- let preloadPlugins = [];
1224
- const FS_handledByPreloadPlugin = async (byteArray, fullname) => {
1130
+ var preloadPlugins = [];
1131
+ var FS_handledByPreloadPlugin = async (byteArray, fullname) => {
1225
1132
  if (typeof Browser != "undefined") Browser.init();
1226
- for (const plugin of preloadPlugins) if (plugin.canHandle(fullname)) return plugin.handle(byteArray, fullname);
1133
+ for (var plugin of preloadPlugins) if (plugin["canHandle"](fullname)) return plugin["handle"](byteArray, fullname);
1227
1134
  return byteArray;
1228
1135
  };
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}`);
1136
+ var FS_preloadFile = async (parent, name, url, canRead, canWrite, dontCreateFile, canOwn, preFinish) => {
1137
+ var fullname = name ? PATH_FS.resolve(PATH.join2(parent, name)) : parent;
1138
+ var dep = getUniqueRunDependency(`cp ${fullname}`);
1232
1139
  addRunDependency(dep);
1233
1140
  try {
1234
- let byteArray = url;
1141
+ var byteArray = url;
1235
1142
  if (typeof url == "string") byteArray = await asyncLoad(url);
1236
1143
  byteArray = await FS_handledByPreloadPlugin(byteArray, fullname);
1237
1144
  preFinish?.();
@@ -1240,7 +1147,7 @@ async function createRimeModule(moduleArg = {}) {
1240
1147
  removeRunDependency(dep);
1241
1148
  }
1242
1149
  };
1243
- const FS_createPreloadedFile = (parent, name, url, canRead, canWrite, onload, onerror, dontCreateFile, canOwn, preFinish) => {
1150
+ var FS_createPreloadedFile = (parent, name, url, canRead, canWrite, onload, onerror, dontCreateFile, canOwn, preFinish) => {
1244
1151
  FS_preloadFile(parent, name, url, canRead, canWrite, dontCreateFile, canOwn, preFinish).then(onload).catch(onerror);
1245
1152
  };
1246
1153
  var FS = {
@@ -1329,19 +1236,19 @@ async function createRimeModule(moduleArg = {}) {
1329
1236
  lookupPath(path, opts = {}) {
1330
1237
  if (!path) throw new FS.ErrnoError(44);
1331
1238
  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;
1239
+ if (!PATH.isAbs(path)) path = FS.cwd() + "/" + path;
1240
+ linkloop: for (var nlinks = 0; nlinks < 40; nlinks++) {
1241
+ var parts = path.split("/").filter((p) => !!p);
1242
+ var current = FS.root;
1243
+ var current_path = "/";
1244
+ for (var i = 0; i < parts.length; i++) {
1245
+ var islast = i === parts.length - 1;
1339
1246
  if (islast && opts.parent) break;
1340
1247
  if (parts[i] === ".") continue;
1341
1248
  if (parts[i] === "..") {
1342
1249
  current_path = PATH.dirname(current_path);
1343
1250
  if (FS.isRoot(current)) {
1344
- path = `${current_path}/${parts.slice(i + 1).join("/")}`;
1251
+ path = current_path + "/" + parts.slice(i + 1).join("/");
1345
1252
  nlinks--;
1346
1253
  continue linkloop;
1347
1254
  } else current = current.parent;
@@ -1357,9 +1264,9 @@ async function createRimeModule(moduleArg = {}) {
1357
1264
  if (FS.isMountpoint(current) && (!islast || opts.follow_mount)) current = current.mounted.root;
1358
1265
  if (FS.isLink(current.mode) && (!islast || opts.follow)) {
1359
1266
  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("/")}`;
1267
+ var link = current.node_ops.readlink(current);
1268
+ if (!PATH.isAbs(link)) link = PATH.dirname(current_path) + "/" + link;
1269
+ path = link + "/" + parts.slice(i + 1).join("/");
1363
1270
  continue linkloop;
1364
1271
  }
1365
1272
  }
@@ -1371,10 +1278,10 @@ async function createRimeModule(moduleArg = {}) {
1371
1278
  throw new FS.ErrnoError(32);
1372
1279
  },
1373
1280
  getPath(node) {
1374
- let path;
1281
+ var path;
1375
1282
  while (true) {
1376
1283
  if (FS.isRoot(node)) {
1377
- const mount = node.mount.mountpoint;
1284
+ var mount = node.mount.mountpoint;
1378
1285
  if (!path) return mount;
1379
1286
  return mount[mount.length - 1] !== "/" ? `${mount}/${path}` : mount + path;
1380
1287
  }
@@ -1383,20 +1290,20 @@ async function createRimeModule(moduleArg = {}) {
1383
1290
  }
1384
1291
  },
1385
1292
  hashName(parentid, name) {
1386
- let hash = 0;
1387
- for (let i = 0; i < name.length; i++) hash = (hash << 5) - hash + name.charCodeAt(i) | 0;
1293
+ var hash = 0;
1294
+ for (var i = 0; i < name.length; i++) hash = (hash << 5) - hash + name.charCodeAt(i) | 0;
1388
1295
  return (parentid + hash >>> 0) % FS.nameTable.length;
1389
1296
  },
1390
1297
  hashAddNode(node) {
1391
- const hash = FS.hashName(node.parent.id, node.name);
1298
+ var hash = FS.hashName(node.parent.id, node.name);
1392
1299
  node.name_next = FS.nameTable[hash];
1393
1300
  FS.nameTable[hash] = node;
1394
1301
  },
1395
1302
  hashRemoveNode(node) {
1396
- const hash = FS.hashName(node.parent.id, node.name);
1303
+ var hash = FS.hashName(node.parent.id, node.name);
1397
1304
  if (FS.nameTable[hash] === node) FS.nameTable[hash] = node.name_next;
1398
1305
  else {
1399
- let current = FS.nameTable[hash];
1306
+ var current = FS.nameTable[hash];
1400
1307
  while (current) {
1401
1308
  if (current.name_next === node) {
1402
1309
  current.name_next = node.name_next;
@@ -1407,17 +1314,17 @@ async function createRimeModule(moduleArg = {}) {
1407
1314
  }
1408
1315
  },
1409
1316
  lookupNode(parent, name) {
1410
- const errCode = FS.mayLookup(parent);
1317
+ var errCode = FS.mayLookup(parent);
1411
1318
  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;
1319
+ var hash = FS.hashName(parent.id, name);
1320
+ for (var node = FS.nameTable[hash]; node; node = node.name_next) {
1321
+ var nodeName = node.name;
1415
1322
  if (node.parent.id === parent.id && nodeName === name) return node;
1416
1323
  }
1417
1324
  return FS.lookup(parent, name);
1418
1325
  },
1419
1326
  createNode(parent, name, mode, rdev) {
1420
- const node = new FS.FSNode(parent, name, mode, rdev);
1327
+ var node = new FS.FSNode(parent, name, mode, rdev);
1421
1328
  FS.hashAddNode(node);
1422
1329
  return node;
1423
1330
  },
@@ -1452,7 +1359,7 @@ async function createRimeModule(moduleArg = {}) {
1452
1359
  return (mode & 49152) === 49152;
1453
1360
  },
1454
1361
  flagsToPermissionString(flag) {
1455
- let perms = [
1362
+ var perms = [
1456
1363
  "r",
1457
1364
  "w",
1458
1365
  "rw"
@@ -1469,7 +1376,7 @@ async function createRimeModule(moduleArg = {}) {
1469
1376
  },
1470
1377
  mayLookup(dir) {
1471
1378
  if (!FS.isDir(dir.mode)) return 54;
1472
- const errCode = FS.nodePermissions(dir, "x");
1379
+ var errCode = FS.nodePermissions(dir, "x");
1473
1380
  if (errCode) return errCode;
1474
1381
  if (!dir.node_ops.lookup) return 2;
1475
1382
  return 0;
@@ -1477,19 +1384,19 @@ async function createRimeModule(moduleArg = {}) {
1477
1384
  mayCreate(dir, name) {
1478
1385
  if (!FS.isDir(dir.mode)) return 54;
1479
1386
  try {
1480
- const node = FS.lookupNode(dir, name);
1387
+ FS.lookupNode(dir, name);
1481
1388
  return 20;
1482
1389
  } catch (e) {}
1483
1390
  return FS.nodePermissions(dir, "wx");
1484
1391
  },
1485
1392
  mayDelete(dir, name, isdir) {
1486
- let node;
1393
+ var node;
1487
1394
  try {
1488
1395
  node = FS.lookupNode(dir, name);
1489
1396
  } catch (e) {
1490
1397
  return e.errno;
1491
1398
  }
1492
- const errCode = FS.nodePermissions(dir, "wx");
1399
+ var errCode = FS.nodePermissions(dir, "wx");
1493
1400
  if (errCode) return errCode;
1494
1401
  if (isdir) {
1495
1402
  if (!FS.isDir(node.mode)) return 54;
@@ -1500,23 +1407,23 @@ async function createRimeModule(moduleArg = {}) {
1500
1407
  mayOpen(node, flags) {
1501
1408
  if (!node) return 44;
1502
1409
  if (FS.isLink(node.mode)) return 32;
1503
- const mode = FS.flagsToPermissionString(flags);
1410
+ var mode = FS.flagsToPermissionString(flags);
1504
1411
  if (FS.isDir(node.mode)) {
1505
1412
  if (mode !== "r" || flags & 576) return 31;
1506
1413
  }
1507
1414
  return FS.nodePermissions(node, mode);
1508
1415
  },
1509
- checkOpExists(op, err$1) {
1510
- if (!op) throw new FS.ErrnoError(err$1);
1416
+ checkOpExists(op, err) {
1417
+ if (!op) throw new FS.ErrnoError(err);
1511
1418
  return op;
1512
1419
  },
1513
1420
  MAX_OPEN_FDS: 4096,
1514
1421
  nextfd() {
1515
- for (let fd = 0; fd <= FS.MAX_OPEN_FDS; fd++) if (!FS.streams[fd]) return fd;
1422
+ for (var fd = 0; fd <= FS.MAX_OPEN_FDS; fd++) if (!FS.streams[fd]) return fd;
1516
1423
  throw new FS.ErrnoError(33);
1517
1424
  },
1518
1425
  getStreamChecked(fd) {
1519
- const stream = FS.getStream(fd);
1426
+ var stream = FS.getStream(fd);
1520
1427
  if (!stream) throw new FS.ErrnoError(8);
1521
1428
  return stream;
1522
1429
  },
@@ -1532,21 +1439,20 @@ async function createRimeModule(moduleArg = {}) {
1532
1439
  FS.streams[fd] = null;
1533
1440
  },
1534
1441
  dupStream(origStream, fd = -1) {
1535
- const stream = FS.createStream(origStream, fd);
1442
+ var stream = FS.createStream(origStream, fd);
1536
1443
  stream.stream_ops?.dup?.(stream);
1537
1444
  return stream;
1538
1445
  },
1539
1446
  doSetAttr(stream, node, attr) {
1540
- let setattr = stream?.stream_ops.setattr;
1541
- const arg = setattr ? stream : node;
1447
+ var setattr = stream?.stream_ops.setattr;
1448
+ var arg = setattr ? stream : node;
1542
1449
  setattr ??= node.node_ops.setattr;
1543
1450
  FS.checkOpExists(setattr, 63);
1544
1451
  setattr(arg, attr);
1545
1452
  },
1546
1453
  chrdev_stream_ops: {
1547
1454
  open(stream) {
1548
- const device = FS.getDevice(stream.node.rdev);
1549
- stream.stream_ops = device.stream_ops;
1455
+ stream.stream_ops = FS.getDevice(stream.node.rdev).stream_ops;
1550
1456
  stream.stream_ops.open?.(stream);
1551
1457
  },
1552
1458
  llseek() {
@@ -1561,10 +1467,10 @@ async function createRimeModule(moduleArg = {}) {
1561
1467
  },
1562
1468
  getDevice: (dev) => FS.devices[dev],
1563
1469
  getMounts(mount) {
1564
- const mounts = [];
1565
- const check = [mount];
1470
+ var mounts = [];
1471
+ var check = [mount];
1566
1472
  while (check.length) {
1567
- const m = check.pop();
1473
+ var m = check.pop();
1568
1474
  mounts.push(m);
1569
1475
  check.push(...m.mounts);
1570
1476
  }
@@ -1577,8 +1483,8 @@ async function createRimeModule(moduleArg = {}) {
1577
1483
  }
1578
1484
  FS.syncFSRequests++;
1579
1485
  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;
1486
+ var mounts = FS.getMounts(FS.root.mount);
1487
+ var completed = 0;
1582
1488
  function doCallback(errCode) {
1583
1489
  FS.syncFSRequests--;
1584
1490
  return callback(errCode);
@@ -1593,28 +1499,28 @@ async function createRimeModule(moduleArg = {}) {
1593
1499
  }
1594
1500
  if (++completed >= mounts.length) doCallback(null);
1595
1501
  }
1596
- for (const mount of mounts) if (mount.type.syncfs) mount.type.syncfs(mount, populate, done);
1502
+ for (var mount of mounts) if (mount.type.syncfs) mount.type.syncfs(mount, populate, done);
1597
1503
  else done(null);
1598
1504
  },
1599
1505
  mount(type, opts, mountpoint) {
1600
- const root = mountpoint === "/";
1601
- const pseudo = !mountpoint;
1602
- let node;
1506
+ var root = mountpoint === "/";
1507
+ var pseudo = !mountpoint;
1508
+ var node;
1603
1509
  if (root && FS.root) throw new FS.ErrnoError(10);
1604
1510
  else if (!root && !pseudo) {
1605
- const lookup = FS.lookupPath(mountpoint, { follow_mount: false });
1511
+ var lookup = FS.lookupPath(mountpoint, { follow_mount: false });
1606
1512
  mountpoint = lookup.path;
1607
1513
  node = lookup.node;
1608
1514
  if (FS.isMountpoint(node)) throw new FS.ErrnoError(10);
1609
1515
  if (!FS.isDir(node.mode)) throw new FS.ErrnoError(54);
1610
1516
  }
1611
- const mount = {
1517
+ var mount = {
1612
1518
  type,
1613
1519
  opts,
1614
1520
  mountpoint,
1615
1521
  mounts: []
1616
1522
  };
1617
- const mountRoot = type.mount(mount);
1523
+ var mountRoot = type.mount(mount);
1618
1524
  mountRoot.mount = mount;
1619
1525
  mount.root = mountRoot;
1620
1526
  if (root) FS.root = mountRoot;
@@ -1625,30 +1531,29 @@ async function createRimeModule(moduleArg = {}) {
1625
1531
  return mountRoot;
1626
1532
  },
1627
1533
  unmount(mountpoint) {
1628
- const lookup = FS.lookupPath(mountpoint, { follow_mount: false });
1534
+ var lookup = FS.lookupPath(mountpoint, { follow_mount: false });
1629
1535
  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;
1536
+ var node = lookup.node;
1537
+ var mount = node.mounted;
1538
+ var mounts = FS.getMounts(mount);
1539
+ for (var [hash, current] of Object.entries(FS.nameTable)) while (current) {
1540
+ var next = current.name_next;
1635
1541
  if (mounts.includes(current.mount)) FS.destroyNode(current);
1636
1542
  current = next;
1637
1543
  }
1638
1544
  node.mounted = null;
1639
- const idx = node.mount.mounts.indexOf(mount);
1545
+ var idx = node.mount.mounts.indexOf(mount);
1640
1546
  node.mount.mounts.splice(idx, 1);
1641
1547
  },
1642
1548
  lookup(parent, name) {
1643
1549
  return parent.node_ops.lookup(parent, name);
1644
1550
  },
1645
1551
  mknod(path, mode, dev) {
1646
- const lookup = FS.lookupPath(path, { parent: true });
1647
- const parent = lookup.node;
1648
- const name = PATH.basename(path);
1552
+ var parent = FS.lookupPath(path, { parent: true }).node;
1553
+ var name = PATH.basename(path);
1649
1554
  if (!name) throw new FS.ErrnoError(28);
1650
1555
  if (name === "." || name === "..") throw new FS.ErrnoError(20);
1651
- const errCode = FS.mayCreate(parent, name);
1556
+ var errCode = FS.mayCreate(parent, name);
1652
1557
  if (errCode) throw new FS.ErrnoError(errCode);
1653
1558
  if (!parent.node_ops.mknod) throw new FS.ErrnoError(63);
1654
1559
  return parent.node_ops.mknod(parent, name, mode, dev);
@@ -1660,7 +1565,7 @@ async function createRimeModule(moduleArg = {}) {
1660
1565
  return FS.statfsNode(stream.node);
1661
1566
  },
1662
1567
  statfsNode(node) {
1663
- const rtn = {
1568
+ var rtn = {
1664
1569
  bsize: 4096,
1665
1570
  frsize: 4096,
1666
1571
  blocks: 1e6,
@@ -1686,9 +1591,9 @@ async function createRimeModule(moduleArg = {}) {
1686
1591
  return FS.mknod(path, mode, 0);
1687
1592
  },
1688
1593
  mkdirTree(path, mode) {
1689
- const dirs = path.split("/");
1690
- let d = "";
1691
- for (const dir of dirs) {
1594
+ var dirs = path.split("/");
1595
+ var d = "";
1596
+ for (var dir of dirs) {
1692
1597
  if (!dir) continue;
1693
1598
  if (d || PATH.isAbs(path)) d += "/";
1694
1599
  d += dir;
@@ -1709,39 +1614,36 @@ async function createRimeModule(moduleArg = {}) {
1709
1614
  },
1710
1615
  symlink(oldpath, newpath) {
1711
1616
  if (!PATH_FS.resolve(oldpath)) throw new FS.ErrnoError(44);
1712
- const lookup = FS.lookupPath(newpath, { parent: true });
1713
- const parent = lookup.node;
1617
+ var parent = FS.lookupPath(newpath, { parent: true }).node;
1714
1618
  if (!parent) throw new FS.ErrnoError(44);
1715
- const newname = PATH.basename(newpath);
1716
- const errCode = FS.mayCreate(parent, newname);
1619
+ var newname = PATH.basename(newpath);
1620
+ var errCode = FS.mayCreate(parent, newname);
1717
1621
  if (errCode) throw new FS.ErrnoError(errCode);
1718
1622
  if (!parent.node_ops.symlink) throw new FS.ErrnoError(63);
1719
1623
  return parent.node_ops.symlink(parent, newname, oldpath);
1720
1624
  },
1721
1625
  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;
1727
- lookup = FS.lookupPath(old_path, { parent: true });
1728
- old_dir = lookup.node;
1626
+ var old_dirname = PATH.dirname(old_path);
1627
+ var new_dirname = PATH.dirname(new_path);
1628
+ var old_name = PATH.basename(old_path);
1629
+ var new_name = PATH.basename(new_path);
1630
+ var lookup = FS.lookupPath(old_path, { parent: true }), old_dir = lookup.node, new_dir;
1729
1631
  lookup = FS.lookupPath(new_path, { parent: true });
1730
1632
  new_dir = lookup.node;
1731
1633
  if (!old_dir || !new_dir) throw new FS.ErrnoError(44);
1732
1634
  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);
1635
+ var old_node = FS.lookupNode(old_dir, old_name);
1636
+ var relative = PATH_FS.relative(old_path, new_dirname);
1735
1637
  if (relative.charAt(0) !== ".") throw new FS.ErrnoError(28);
1736
1638
  relative = PATH_FS.relative(new_path, old_dirname);
1737
1639
  if (relative.charAt(0) !== ".") throw new FS.ErrnoError(55);
1738
- let new_node;
1640
+ var new_node;
1739
1641
  try {
1740
1642
  new_node = FS.lookupNode(new_dir, new_name);
1741
1643
  } catch (e) {}
1742
1644
  if (old_node === new_node) return;
1743
- const isdir = FS.isDir(old_node.mode);
1744
- let errCode = FS.mayDelete(old_dir, old_name, isdir);
1645
+ var isdir = FS.isDir(old_node.mode);
1646
+ var errCode = FS.mayDelete(old_dir, old_name, isdir);
1745
1647
  if (errCode) throw new FS.ErrnoError(errCode);
1746
1648
  errCode = new_node ? FS.mayDelete(new_dir, new_name, isdir) : FS.mayCreate(new_dir, new_name);
1747
1649
  if (errCode) throw new FS.ErrnoError(errCode);
@@ -1762,11 +1664,10 @@ async function createRimeModule(moduleArg = {}) {
1762
1664
  }
1763
1665
  },
1764
1666
  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);
1667
+ var parent = FS.lookupPath(path, { parent: true }).node;
1668
+ var name = PATH.basename(path);
1669
+ var node = FS.lookupNode(parent, name);
1670
+ var errCode = FS.mayDelete(parent, name, true);
1770
1671
  if (errCode) throw new FS.ErrnoError(errCode);
1771
1672
  if (!parent.node_ops.rmdir) throw new FS.ErrnoError(63);
1772
1673
  if (FS.isMountpoint(node)) throw new FS.ErrnoError(10);
@@ -1774,18 +1675,15 @@ async function createRimeModule(moduleArg = {}) {
1774
1675
  FS.destroyNode(node);
1775
1676
  },
1776
1677
  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);
1780
- return readdir(node);
1678
+ var node = FS.lookupPath(path, { follow: true }).node;
1679
+ return FS.checkOpExists(node.node_ops.readdir, 54)(node);
1781
1680
  },
1782
1681
  unlink(path) {
1783
- const lookup = FS.lookupPath(path, { parent: true });
1784
- const parent = lookup.node;
1682
+ var parent = FS.lookupPath(path, { parent: true }).node;
1785
1683
  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);
1684
+ var name = PATH.basename(path);
1685
+ var node = FS.lookupNode(parent, name);
1686
+ var errCode = FS.mayDelete(parent, name, false);
1789
1687
  if (errCode) throw new FS.ErrnoError(errCode);
1790
1688
  if (!parent.node_ops.unlink) throw new FS.ErrnoError(63);
1791
1689
  if (FS.isMountpoint(node)) throw new FS.ErrnoError(10);
@@ -1793,23 +1691,20 @@ async function createRimeModule(moduleArg = {}) {
1793
1691
  FS.destroyNode(node);
1794
1692
  },
1795
1693
  readlink(path) {
1796
- const lookup = FS.lookupPath(path);
1797
- const link = lookup.node;
1694
+ var link = FS.lookupPath(path).node;
1798
1695
  if (!link) throw new FS.ErrnoError(44);
1799
1696
  if (!link.node_ops.readlink) throw new FS.ErrnoError(28);
1800
1697
  return link.node_ops.readlink(link);
1801
1698
  },
1802
1699
  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);
1806
- return getattr(node);
1700
+ var node = FS.lookupPath(path, { follow: !dontFollow }).node;
1701
+ return FS.checkOpExists(node.node_ops.getattr, 63)(node);
1807
1702
  },
1808
1703
  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;
1704
+ var stream = FS.getStreamChecked(fd);
1705
+ var node = stream.node;
1706
+ var getattr = stream.stream_ops.getattr;
1707
+ var arg = getattr ? stream : node;
1813
1708
  getattr ??= node.node_ops.getattr;
1814
1709
  FS.checkOpExists(getattr, 63);
1815
1710
  return getattr(arg);
@@ -1825,18 +1720,16 @@ async function createRimeModule(moduleArg = {}) {
1825
1720
  });
1826
1721
  },
1827
1722
  chmod(path, mode, dontFollow) {
1828
- let node;
1829
- if (typeof path == "string") {
1830
- const lookup = FS.lookupPath(path, { follow: !dontFollow });
1831
- node = lookup.node;
1832
- } else node = path;
1723
+ var node;
1724
+ if (typeof path == "string") node = FS.lookupPath(path, { follow: !dontFollow }).node;
1725
+ else node = path;
1833
1726
  FS.doChmod(null, node, mode, dontFollow);
1834
1727
  },
1835
1728
  lchmod(path, mode) {
1836
1729
  FS.chmod(path, mode, true);
1837
1730
  },
1838
1731
  fchmod(fd, mode) {
1839
- const stream = FS.getStreamChecked(fd);
1732
+ var stream = FS.getStreamChecked(fd);
1840
1733
  FS.doChmod(stream, stream.node, mode, false);
1841
1734
  },
1842
1735
  doChown(stream, node, dontFollow) {
@@ -1846,24 +1739,22 @@ async function createRimeModule(moduleArg = {}) {
1846
1739
  });
1847
1740
  },
1848
1741
  chown(path, uid, gid, dontFollow) {
1849
- let node;
1850
- if (typeof path == "string") {
1851
- const lookup = FS.lookupPath(path, { follow: !dontFollow });
1852
- node = lookup.node;
1853
- } else node = path;
1742
+ var node;
1743
+ if (typeof path == "string") node = FS.lookupPath(path, { follow: !dontFollow }).node;
1744
+ else node = path;
1854
1745
  FS.doChown(null, node, dontFollow);
1855
1746
  },
1856
1747
  lchown(path, uid, gid) {
1857
1748
  FS.chown(path, uid, gid, true);
1858
1749
  },
1859
1750
  fchown(fd, uid, gid) {
1860
- const stream = FS.getStreamChecked(fd);
1751
+ var stream = FS.getStreamChecked(fd);
1861
1752
  FS.doChown(stream, stream.node, false);
1862
1753
  },
1863
1754
  doTruncate(stream, node, len) {
1864
1755
  if (FS.isDir(node.mode)) throw new FS.ErrnoError(31);
1865
1756
  if (!FS.isFile(node.mode)) throw new FS.ErrnoError(28);
1866
- const errCode = FS.nodePermissions(node, "w");
1757
+ var errCode = FS.nodePermissions(node, "w");
1867
1758
  if (errCode) throw new FS.ErrnoError(errCode);
1868
1759
  FS.doSetAttr(stream, node, {
1869
1760
  size: len,
@@ -1872,23 +1763,19 @@ async function createRimeModule(moduleArg = {}) {
1872
1763
  },
1873
1764
  truncate(path, len) {
1874
1765
  if (len < 0) throw new FS.ErrnoError(28);
1875
- let node;
1876
- if (typeof path == "string") {
1877
- const lookup = FS.lookupPath(path, { follow: true });
1878
- node = lookup.node;
1879
- } else node = path;
1766
+ var node;
1767
+ if (typeof path == "string") node = FS.lookupPath(path, { follow: true }).node;
1768
+ else node = path;
1880
1769
  FS.doTruncate(null, node, len);
1881
1770
  },
1882
1771
  ftruncate(fd, len) {
1883
- const stream = FS.getStreamChecked(fd);
1772
+ var stream = FS.getStreamChecked(fd);
1884
1773
  if (len < 0 || (stream.flags & 2097155) === 0) throw new FS.ErrnoError(28);
1885
1774
  FS.doTruncate(stream, stream.node, len);
1886
1775
  },
1887
1776
  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);
1891
- setattr(node, {
1777
+ var node = FS.lookupPath(path, { follow: true }).node;
1778
+ FS.checkOpExists(node.node_ops.setattr, 63)(node, {
1892
1779
  atime,
1893
1780
  mtime
1894
1781
  });
@@ -1898,19 +1785,19 @@ async function createRimeModule(moduleArg = {}) {
1898
1785
  flags = typeof flags == "string" ? FS_modeStringToFlags(flags) : flags;
1899
1786
  if (flags & 64) mode = mode & 4095 | 32768;
1900
1787
  else mode = 0;
1901
- let node;
1902
- let isDirPath;
1788
+ var node;
1789
+ var isDirPath;
1903
1790
  if (typeof path == "object") node = path;
1904
1791
  else {
1905
1792
  isDirPath = path.endsWith("/");
1906
- const lookup = FS.lookupPath(path, {
1793
+ var lookup = FS.lookupPath(path, {
1907
1794
  follow: !(flags & 131072),
1908
1795
  noent_okay: true
1909
1796
  });
1910
1797
  node = lookup.node;
1911
1798
  path = lookup.path;
1912
1799
  }
1913
- let created = false;
1800
+ var created = false;
1914
1801
  if (flags & 64) if (node) {
1915
1802
  if (flags & 128) throw new FS.ErrnoError(20);
1916
1803
  } else if (isDirPath) throw new FS.ErrnoError(31);
@@ -1922,12 +1809,12 @@ async function createRimeModule(moduleArg = {}) {
1922
1809
  if (FS.isChrdev(node.mode)) flags &= -513;
1923
1810
  if (flags & 65536 && !FS.isDir(node.mode)) throw new FS.ErrnoError(54);
1924
1811
  if (!created) {
1925
- const errCode = FS.mayOpen(node, flags);
1812
+ var errCode = FS.mayOpen(node, flags);
1926
1813
  if (errCode) throw new FS.ErrnoError(errCode);
1927
1814
  }
1928
1815
  if (flags & 512 && !created) FS.truncate(node, 0);
1929
1816
  flags &= -131713;
1930
- const stream = FS.createStream({
1817
+ var stream = FS.createStream({
1931
1818
  node,
1932
1819
  path: FS.getPath(node),
1933
1820
  flags,
@@ -1970,10 +1857,10 @@ async function createRimeModule(moduleArg = {}) {
1970
1857
  if ((stream.flags & 2097155) === 1) throw new FS.ErrnoError(8);
1971
1858
  if (FS.isDir(stream.node.mode)) throw new FS.ErrnoError(31);
1972
1859
  if (!stream.stream_ops.read) throw new FS.ErrnoError(28);
1973
- const seeking = typeof position != "undefined";
1860
+ var seeking = typeof position != "undefined";
1974
1861
  if (!seeking) position = stream.position;
1975
1862
  else if (!stream.seekable) throw new FS.ErrnoError(70);
1976
- const bytesRead = stream.stream_ops.read(stream, buffer, offset, length, position);
1863
+ var bytesRead = stream.stream_ops.read(stream, buffer, offset, length, position);
1977
1864
  if (!seeking) stream.position += bytesRead;
1978
1865
  return bytesRead;
1979
1866
  },
@@ -1984,10 +1871,10 @@ async function createRimeModule(moduleArg = {}) {
1984
1871
  if (FS.isDir(stream.node.mode)) throw new FS.ErrnoError(31);
1985
1872
  if (!stream.stream_ops.write) throw new FS.ErrnoError(28);
1986
1873
  if (stream.seekable && stream.flags & 1024) FS.llseek(stream, 0, 2);
1987
- const seeking = typeof position != "undefined";
1874
+ var seeking = typeof position != "undefined";
1988
1875
  if (!seeking) position = stream.position;
1989
1876
  else if (!stream.seekable) throw new FS.ErrnoError(70);
1990
- const bytesWritten = stream.stream_ops.write(stream, buffer, offset, length, position, canOwn);
1877
+ var bytesWritten = stream.stream_ops.write(stream, buffer, offset, length, position, canOwn);
1991
1878
  if (!seeking) stream.position += bytesWritten;
1992
1879
  return bytesWritten;
1993
1880
  },
@@ -2010,10 +1897,9 @@ async function createRimeModule(moduleArg = {}) {
2010
1897
  opts.flags = opts.flags || 0;
2011
1898
  opts.encoding = opts.encoding || "binary";
2012
1899
  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);
1900
+ var stream = FS.open(path, opts.flags);
1901
+ var length = FS.stat(path).size;
1902
+ var buf = new Uint8Array(length);
2017
1903
  FS.read(stream, buf, 0, length, 0);
2018
1904
  if (opts.encoding === "utf8") buf = UTF8ArrayToString(buf);
2019
1905
  FS.close(stream);
@@ -2021,7 +1907,7 @@ async function createRimeModule(moduleArg = {}) {
2021
1907
  },
2022
1908
  writeFile(path, data, opts = {}) {
2023
1909
  opts.flags = opts.flags || 577;
2024
- const stream = FS.open(path, opts.flags, opts.mode);
1910
+ var stream = FS.open(path, opts.flags, opts.mode);
2025
1911
  if (typeof data == "string") data = new Uint8Array(intArrayFromString(data, true));
2026
1912
  if (ArrayBuffer.isView(data)) FS.write(stream, data, 0, data.byteLength, void 0, opts.canOwn);
2027
1913
  else abort("Unsupported data type");
@@ -2029,10 +1915,10 @@ async function createRimeModule(moduleArg = {}) {
2029
1915
  },
2030
1916
  cwd: () => FS.currentPath,
2031
1917
  chdir(path) {
2032
- const lookup = FS.lookupPath(path, { follow: true });
1918
+ var lookup = FS.lookupPath(path, { follow: true });
2033
1919
  if (lookup.node === null) throw new FS.ErrnoError(44);
2034
1920
  if (!FS.isDir(lookup.node.mode)) throw new FS.ErrnoError(54);
2035
- const errCode = FS.nodePermissions(lookup.node, "x");
1921
+ var errCode = FS.nodePermissions(lookup.node, "x");
2036
1922
  if (errCode) throw new FS.ErrnoError(errCode);
2037
1923
  FS.currentPath = lookup.path;
2038
1924
  },
@@ -2053,9 +1939,8 @@ async function createRimeModule(moduleArg = {}) {
2053
1939
  TTY.register(FS.makedev(6, 0), TTY.default_tty1_ops);
2054
1940
  FS.mkdev("/dev/tty", FS.makedev(5, 0));
2055
1941
  FS.mkdev("/dev/tty1", FS.makedev(6, 0));
2056
- const randomBuffer = new Uint8Array(1024);
2057
- let randomLeft = 0;
2058
- const randomByte = () => {
1942
+ var randomBuffer = new Uint8Array(1024), randomLeft = 0;
1943
+ var randomByte = () => {
2059
1944
  if (randomLeft === 0) {
2060
1945
  randomFill(randomBuffer);
2061
1946
  randomLeft = randomBuffer.byteLength;
@@ -2069,16 +1954,16 @@ async function createRimeModule(moduleArg = {}) {
2069
1954
  },
2070
1955
  createSpecialDirectories() {
2071
1956
  FS.mkdir("/proc");
2072
- const proc_self = FS.mkdir("/proc/self");
1957
+ var proc_self = FS.mkdir("/proc/self");
2073
1958
  FS.mkdir("/proc/self/fd");
2074
1959
  FS.mount({ mount() {
2075
- const node = FS.createNode(proc_self, "fd", 16895, 73);
1960
+ var node = FS.createNode(proc_self, "fd", 16895, 73);
2076
1961
  node.stream_ops = { llseek: MEMFS.stream_ops.llseek };
2077
1962
  node.node_ops = {
2078
1963
  lookup(parent, name) {
2079
- const fd = +name;
2080
- const stream = FS.getStreamChecked(fd);
2081
- const ret = {
1964
+ var fd = +name;
1965
+ var stream = FS.getStreamChecked(fd);
1966
+ var ret = {
2082
1967
  parent: null,
2083
1968
  mount: { mountpoint: "fake" },
2084
1969
  node_ops: { readlink: () => stream.path },
@@ -2101,12 +1986,12 @@ async function createRimeModule(moduleArg = {}) {
2101
1986
  else FS.symlink("/dev/tty", "/dev/stdout");
2102
1987
  if (error) FS.createDevice("/dev", "stderr", null, error);
2103
1988
  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);
1989
+ FS.open("/dev/stdin", 0);
1990
+ FS.open("/dev/stdout", 1);
1991
+ FS.open("/dev/stderr", 1);
2107
1992
  },
2108
1993
  staticInit() {
2109
- FS.nameTable = Array.from({ length: 4096 });
1994
+ FS.nameTable = new Array(4096);
2110
1995
  FS.mount(MEMFS, {}, "/");
2111
1996
  FS.createDefaultDirectories();
2112
1997
  FS.createDefaultDevices();
@@ -2118,17 +2003,17 @@ async function createRimeModule(moduleArg = {}) {
2118
2003
  },
2119
2004
  init(input, output, error) {
2120
2005
  FS.initialized = true;
2121
- input ??= Module.stdin;
2122
- output ??= Module.stdout;
2123
- error ??= Module.stderr;
2006
+ input ??= Module["stdin"];
2007
+ output ??= Module["stdout"];
2008
+ error ??= Module["stderr"];
2124
2009
  FS.createStandardStreams(input, output, error);
2125
2010
  },
2126
2011
  quit() {
2127
2012
  FS.initialized = false;
2128
- for (const stream of FS.streams) if (stream) FS.close(stream);
2013
+ for (var stream of FS.streams) if (stream) FS.close(stream);
2129
2014
  },
2130
2015
  findObject(path, dontResolveLastLink) {
2131
- const ret = FS.analyzePath(path, dontResolveLastLink);
2016
+ var ret = FS.analyzePath(path, dontResolveLastLink);
2132
2017
  if (!ret.exists) return null;
2133
2018
  return ret.object;
2134
2019
  },
@@ -2137,7 +2022,7 @@ async function createRimeModule(moduleArg = {}) {
2137
2022
  var lookup = FS.lookupPath(path, { follow: !dontResolveLastLink });
2138
2023
  path = lookup.path;
2139
2024
  } catch (e) {}
2140
- const ret = {
2025
+ var ret = {
2141
2026
  isRoot: false,
2142
2027
  exists: false,
2143
2028
  error: 0,
@@ -2167,9 +2052,9 @@ async function createRimeModule(moduleArg = {}) {
2167
2052
  },
2168
2053
  createPath(parent, path, canRead, canWrite) {
2169
2054
  parent = typeof parent == "string" ? parent : FS.getPath(parent);
2170
- const parts = path.split("/").reverse();
2055
+ var parts = path.split("/").reverse();
2171
2056
  while (parts.length) {
2172
- const part = parts.pop();
2057
+ var part = parts.pop();
2173
2058
  if (!part) continue;
2174
2059
  var current = PATH.join2(parent, part);
2175
2060
  try {
@@ -2182,36 +2067,36 @@ async function createRimeModule(moduleArg = {}) {
2182
2067
  return current;
2183
2068
  },
2184
2069
  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);
2070
+ var path = PATH.join2(typeof parent == "string" ? parent : FS.getPath(parent), name);
2071
+ var mode = FS_getMode(canRead, canWrite);
2187
2072
  return FS.create(path, mode);
2188
2073
  },
2189
2074
  createDataFile(parent, name, data, canRead, canWrite, canOwn) {
2190
- let path = name;
2075
+ var path = name;
2191
2076
  if (parent) {
2192
2077
  parent = typeof parent == "string" ? parent : FS.getPath(parent);
2193
2078
  path = name ? PATH.join2(parent, name) : parent;
2194
2079
  }
2195
- const mode = FS_getMode(canRead, canWrite);
2196
- const node = FS.create(path, mode);
2080
+ var mode = FS_getMode(canRead, canWrite);
2081
+ var node = FS.create(path, mode);
2197
2082
  if (data) {
2198
2083
  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);
2084
+ var arr = new Array(data.length);
2085
+ for (var i = 0, len = data.length; i < len; ++i) arr[i] = data.charCodeAt(i);
2201
2086
  data = arr;
2202
2087
  }
2203
2088
  FS.chmod(node, mode | 146);
2204
- const stream = FS.open(node, 577);
2089
+ var stream = FS.open(node, 577);
2205
2090
  FS.write(stream, data, 0, data.length, 0, canOwn);
2206
2091
  FS.close(stream);
2207
2092
  FS.chmod(node, mode);
2208
2093
  }
2209
2094
  },
2210
2095
  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);
2096
+ var path = PATH.join2(typeof parent == "string" ? parent : FS.getPath(parent), name);
2097
+ var mode = FS_getMode(!!input, !!output);
2213
2098
  FS.createDevice.major ??= 64;
2214
- const dev = FS.makedev(FS.createDevice.major++, 0);
2099
+ var dev = FS.makedev(FS.createDevice.major++, 0);
2215
2100
  FS.registerDevice(dev, {
2216
2101
  open(stream) {
2217
2102
  stream.seekable = false;
@@ -2220,8 +2105,8 @@ async function createRimeModule(moduleArg = {}) {
2220
2105
  if (output?.buffer?.length) output(10);
2221
2106
  },
2222
2107
  read(stream, buffer, offset, length, pos) {
2223
- let bytesRead = 0;
2224
- for (let i = 0; i < length; i++) {
2108
+ var bytesRead = 0;
2109
+ for (var i = 0; i < length; i++) {
2225
2110
  var result;
2226
2111
  try {
2227
2112
  result = input();
@@ -2262,42 +2147,42 @@ async function createRimeModule(moduleArg = {}) {
2262
2147
  lengthKnown = false;
2263
2148
  chunks = [];
2264
2149
  get(idx) {
2265
- if (idx > this.length - 1 || idx < 0) return void 0;
2266
- const chunkOffset = idx % this.chunkSize;
2267
- const chunkNum = idx / this.chunkSize | 0;
2150
+ if (idx > this.length - 1 || idx < 0) return;
2151
+ var chunkOffset = idx % this.chunkSize;
2152
+ var chunkNum = idx / this.chunkSize | 0;
2268
2153
  return this.getter(chunkNum)[chunkOffset];
2269
2154
  }
2270
2155
  setDataGetter(getter) {
2271
2156
  this.getter = getter;
2272
2157
  }
2273
2158
  cacheLength() {
2274
- const xhr = new XMLHttpRequest();
2159
+ var xhr = new XMLHttpRequest();
2275
2160
  xhr.open("HEAD", url, false);
2276
2161
  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;
2162
+ if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) abort("Couldn't load " + url + ". Status: " + xhr.status);
2163
+ var datalength = Number(xhr.getResponseHeader("Content-length"));
2164
+ var header;
2165
+ var hasByteServing = (header = xhr.getResponseHeader("Accept-Ranges")) && header === "bytes";
2166
+ var usesGzip = (header = xhr.getResponseHeader("Content-Encoding")) && header === "gzip";
2167
+ var chunkSize = 1024 * 1024;
2283
2168
  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();
2288
- xhr$1.open("GET", url, false);
2289
- if (datalength !== chunkSize) xhr$1.setRequestHeader("Range", `bytes=${from}-${to}`);
2290
- xhr$1.responseType = "arraybuffer";
2291
- if (xhr$1.overrideMimeType) xhr$1.overrideMimeType("text/plain; charset=x-user-defined");
2292
- 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}`);
2294
- if (xhr$1.response !== void 0) return new Uint8Array(xhr$1.response || []);
2295
- return intArrayFromString(xhr$1.responseText || "", true);
2169
+ var doXHR = (from, to) => {
2170
+ if (from > to) abort("invalid range (" + from + ", " + to + ") or no bytes requested!");
2171
+ if (to > datalength - 1) abort("only " + datalength + " bytes available! programmer error!");
2172
+ var xhr = new XMLHttpRequest();
2173
+ xhr.open("GET", url, false);
2174
+ if (datalength !== chunkSize) xhr.setRequestHeader("Range", "bytes=" + from + "-" + to);
2175
+ xhr.responseType = "arraybuffer";
2176
+ if (xhr.overrideMimeType) xhr.overrideMimeType("text/plain; charset=x-user-defined");
2177
+ xhr.send(null);
2178
+ if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) abort("Couldn't load " + url + ". Status: " + xhr.status);
2179
+ if (xhr.response !== void 0) return new Uint8Array(xhr.response || []);
2180
+ return intArrayFromString(xhr.responseText || "", true);
2296
2181
  };
2297
- const lazyArray = this;
2182
+ var lazyArray = this;
2298
2183
  lazyArray.setDataGetter((chunkNum) => {
2299
- const start = chunkNum * chunkSize;
2300
- let end = (chunkNum + 1) * chunkSize - 1;
2184
+ var start = chunkNum * chunkSize;
2185
+ var end = (chunkNum + 1) * chunkSize - 1;
2301
2186
  end = Math.min(end, datalength - 1);
2302
2187
  if (typeof lazyArray.chunks[chunkNum] == "undefined") lazyArray.chunks[chunkNum] = doXHR(start, end);
2303
2188
  if (typeof lazyArray.chunks[chunkNum] == "undefined") abort("doXHR failed!");
@@ -2324,33 +2209,32 @@ async function createRimeModule(moduleArg = {}) {
2324
2209
  }
2325
2210
  if (globalThis.XMLHttpRequest) {
2326
2211
  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();
2328
2212
  var properties = {
2329
2213
  isDevice: false,
2330
- contents: lazyArray
2214
+ contents: new LazyUint8Array()
2331
2215
  };
2332
2216
  } else var properties = {
2333
2217
  isDevice: false,
2334
2218
  url
2335
2219
  };
2336
- const node = FS.createFile(parent, name, properties, canRead, canWrite);
2220
+ var node = FS.createFile(parent, name, properties, canRead, canWrite);
2337
2221
  if (properties.contents) node.contents = properties.contents;
2338
2222
  else if (properties.url) {
2339
2223
  node.contents = null;
2340
2224
  node.url = properties.url;
2341
2225
  }
2342
- Object.defineProperties(node, { usedBytes: { get() {
2226
+ Object.defineProperties(node, { usedBytes: { get: function() {
2343
2227
  return this.contents.length;
2344
2228
  } } });
2345
- const stream_ops = {};
2229
+ var stream_ops = {};
2346
2230
  for (const [key, fn] of Object.entries(node.stream_ops)) stream_ops[key] = (...args) => {
2347
2231
  FS.forceLoadFile(node);
2348
2232
  return fn(...args);
2349
2233
  };
2350
2234
  function writeChunks(stream, buffer, offset, length, position) {
2351
- const contents = stream.node.contents;
2235
+ var contents = stream.node.contents;
2352
2236
  if (position >= contents.length) return 0;
2353
- const size = Math.min(contents.length - position, length);
2237
+ var size = Math.min(contents.length - position, length);
2354
2238
  if (contents.slice) for (var i = 0; i < size; i++) buffer[offset + i] = contents[position + i];
2355
2239
  else for (var i = 0; i < size; i++) buffer[offset + i] = contents.get(position + i);
2356
2240
  return size;
@@ -2361,7 +2245,7 @@ async function createRimeModule(moduleArg = {}) {
2361
2245
  };
2362
2246
  stream_ops.mmap = (stream, length, position, prot, flags) => {
2363
2247
  FS.forceLoadFile(node);
2364
- const ptr = mmapAlloc(length);
2248
+ var ptr = mmapAlloc(length);
2365
2249
  if (!ptr) throw new FS.ErrnoError(48);
2366
2250
  writeChunks(stream, HEAP8, ptr, length, position);
2367
2251
  return {
@@ -2373,26 +2257,23 @@ async function createRimeModule(moduleArg = {}) {
2373
2257
  return node;
2374
2258
  }
2375
2259
  };
2376
- const UTF8ToString = (ptr, maxBytesToRead, ignoreNul) => {
2260
+ var UTF8ToString = (ptr, maxBytesToRead, ignoreNul) => {
2377
2261
  ptr >>>= 0;
2378
2262
  if (!ptr) return "";
2379
- const end = findStringEnd(HEAPU8, ptr, maxBytesToRead, ignoreNul);
2263
+ var end = findStringEnd(HEAPU8, ptr, maxBytesToRead, ignoreNul);
2380
2264
  return UTF8Decoder.decode(HEAPU8.subarray(ptr >>> 0, end >>> 0));
2381
2265
  };
2382
2266
  var SYSCALLS = {
2383
2267
  calculateAt(dirfd, path, allowEmpty) {
2384
2268
  if (PATH.isAbs(path)) return path;
2385
- let dir;
2269
+ var dir;
2386
2270
  if (dirfd === -100) dir = FS.cwd();
2387
- else {
2388
- const dirstream = SYSCALLS.getStreamFromFD(dirfd);
2389
- dir = dirstream.path;
2390
- }
2271
+ else dir = SYSCALLS.getStreamFromFD(dirfd).path;
2391
2272
  if (path.length == 0) {
2392
2273
  if (!allowEmpty) throw new FS.ErrnoError(44);
2393
2274
  return dir;
2394
2275
  }
2395
- return `${dir}/${path}`;
2276
+ return dir + "/" + path;
2396
2277
  },
2397
2278
  writeStat(buf, stat) {
2398
2279
  HEAPU32[buf >>> 2 >>> 0] = stat.dev;
@@ -2404,9 +2285,9 @@ async function createRimeModule(moduleArg = {}) {
2404
2285
  HEAP64[buf + 24 >>> 3 >>> 0] = BigInt(stat.size);
2405
2286
  HEAP32[buf + 32 >>> 2 >>> 0] = 4096;
2406
2287
  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();
2288
+ var atime = stat.atime.getTime();
2289
+ var mtime = stat.mtime.getTime();
2290
+ var ctime = stat.ctime.getTime();
2410
2291
  HEAP64[buf + 40 >>> 3 >>> 0] = BigInt(Math.floor(atime / 1e3));
2411
2292
  HEAPU32[buf + 48 >>> 2 >>> 0] = atime % 1e3 * 1e3 * 1e3;
2412
2293
  HEAP64[buf + 56 >>> 3 >>> 0] = BigInt(Math.floor(mtime / 1e3));
@@ -2431,22 +2312,20 @@ async function createRimeModule(moduleArg = {}) {
2431
2312
  doMsync(addr, stream, len, flags, offset) {
2432
2313
  if (!FS.isFile(stream.node.mode)) throw new FS.ErrnoError(43);
2433
2314
  if (flags & 2) return 0;
2434
- const buffer = HEAPU8.slice(addr, addr + len);
2315
+ var buffer = HEAPU8.slice(addr, addr + len);
2435
2316
  FS.msync(stream, buffer, offset, len, flags);
2436
2317
  },
2437
2318
  getStreamFromFD(fd) {
2438
- const stream = FS.getStreamChecked(fd);
2439
- return stream;
2319
+ return FS.getStreamChecked(fd);
2440
2320
  },
2441
2321
  varargs: void 0,
2442
2322
  getStr(ptr) {
2443
- const ret = UTF8ToString(ptr);
2444
- return ret;
2323
+ return UTF8ToString(ptr);
2445
2324
  }
2446
2325
  };
2447
- const INT53_MAX = 9007199254740992;
2448
- const INT53_MIN = -9007199254740992;
2449
- const bigintToI53Checked = (num) => num < INT53_MIN || num > INT53_MAX ? Number.NaN : Number(num);
2326
+ var INT53_MAX = 9007199254740992;
2327
+ var INT53_MIN = -9007199254740992;
2328
+ var bigintToI53Checked = (num) => num < INT53_MIN || num > INT53_MAX ? NaN : Number(num);
2450
2329
  function ___syscall_chmod(path, mode) {
2451
2330
  path >>>= 0;
2452
2331
  try {
@@ -2464,10 +2343,9 @@ async function createRimeModule(moduleArg = {}) {
2464
2343
  path = SYSCALLS.getStr(path);
2465
2344
  path = SYSCALLS.calculateAt(dirfd, path);
2466
2345
  if (amode & -8) return -28;
2467
- const lookup = FS.lookupPath(path, { follow: true });
2468
- const node = lookup.node;
2346
+ var node = FS.lookupPath(path, { follow: true }).node;
2469
2347
  if (!node) return -44;
2470
- let perms = "";
2348
+ var perms = "";
2471
2349
  if (amode & 4) perms += "r";
2472
2350
  if (amode & 2) perms += "w";
2473
2351
  if (amode & 1) perms += "x";
@@ -2487,40 +2365,35 @@ async function createRimeModule(moduleArg = {}) {
2487
2365
  return -e.errno;
2488
2366
  }
2489
2367
  }
2490
- const syscallGetVarargI = () => {
2491
- const ret = HEAP32[+SYSCALLS.varargs >>> 2 >>> 0];
2368
+ var syscallGetVarargI = () => {
2369
+ var ret = HEAP32[+SYSCALLS.varargs >>> 2 >>> 0];
2492
2370
  SYSCALLS.varargs += 4;
2493
2371
  return ret;
2494
2372
  };
2495
- const syscallGetVarargP = syscallGetVarargI;
2373
+ var syscallGetVarargP = syscallGetVarargI;
2496
2374
  function ___syscall_fcntl64(fd, cmd, varargs) {
2497
2375
  varargs >>>= 0;
2498
2376
  SYSCALLS.varargs = varargs;
2499
2377
  try {
2500
- const stream = SYSCALLS.getStreamFromFD(fd);
2378
+ var stream = SYSCALLS.getStreamFromFD(fd);
2501
2379
  switch (cmd) {
2502
- case 0: {
2380
+ case 0:
2503
2381
  var arg = syscallGetVarargI();
2504
2382
  if (arg < 0) return -28;
2505
2383
  while (FS.streams[arg]) arg++;
2506
- let newStream;
2507
- newStream = FS.dupStream(stream, arg);
2508
- return newStream.fd;
2509
- }
2384
+ return FS.dupStream(stream, arg).fd;
2510
2385
  case 1:
2511
2386
  case 2: return 0;
2512
2387
  case 3: return stream.flags;
2513
- case 4: {
2388
+ case 4:
2514
2389
  var arg = syscallGetVarargI();
2515
2390
  stream.flags |= arg;
2516
2391
  return 0;
2517
- }
2518
- case 12: {
2392
+ case 12:
2519
2393
  var arg = syscallGetVarargP();
2520
- const offset = 0;
2394
+ var offset = 0;
2521
2395
  HEAP16[arg + offset >>> 1 >>> 0] = 2;
2522
2396
  return 0;
2523
- }
2524
2397
  case 13:
2525
2398
  case 14: return 0;
2526
2399
  }
@@ -2532,7 +2405,7 @@ async function createRimeModule(moduleArg = {}) {
2532
2405
  }
2533
2406
  function ___syscall_fdatasync(fd) {
2534
2407
  try {
2535
- const stream = SYSCALLS.getStreamFromFD(fd);
2408
+ SYSCALLS.getStreamFromFD(fd);
2536
2409
  return 0;
2537
2410
  } catch (e) {
2538
2411
  if (typeof FS == "undefined" || !(e.name === "ErrnoError")) throw e;
@@ -2559,14 +2432,14 @@ async function createRimeModule(moduleArg = {}) {
2559
2432
  return -e.errno;
2560
2433
  }
2561
2434
  }
2562
- const stringToUTF8 = (str, outPtr, maxBytesToWrite) => stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite);
2435
+ var stringToUTF8 = (str, outPtr, maxBytesToWrite) => stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite);
2563
2436
  function ___syscall_getcwd(buf, size) {
2564
2437
  buf >>>= 0;
2565
2438
  size >>>= 0;
2566
2439
  try {
2567
2440
  if (size === 0) return -28;
2568
- const cwd = FS.cwd();
2569
- const cwdLengthInBytes = lengthBytesUTF8(cwd) + 1;
2441
+ var cwd = FS.cwd();
2442
+ var cwdLengthInBytes = lengthBytesUTF8(cwd) + 1;
2570
2443
  if (size < cwdLengthInBytes) return -68;
2571
2444
  stringToUTF8(cwd, buf, size);
2572
2445
  return cwdLengthInBytes;
@@ -2579,23 +2452,22 @@ async function createRimeModule(moduleArg = {}) {
2579
2452
  dirp >>>= 0;
2580
2453
  count >>>= 0;
2581
2454
  try {
2582
- const stream = SYSCALLS.getStreamFromFD(fd);
2455
+ var stream = SYSCALLS.getStreamFromFD(fd);
2583
2456
  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));
2457
+ var struct_size = 280;
2458
+ var pos = 0;
2459
+ var off = FS.llseek(stream, 0, 1);
2460
+ var startIdx = Math.floor(off / struct_size);
2461
+ var endIdx = Math.min(stream.getdents.length, startIdx + Math.floor(count / struct_size));
2589
2462
  for (var idx = startIdx; idx < endIdx; idx++) {
2590
2463
  var id;
2591
2464
  var type;
2592
- const name = stream.getdents[idx];
2465
+ var name = stream.getdents[idx];
2593
2466
  if (name === ".") {
2594
2467
  id = stream.node.id;
2595
2468
  type = 4;
2596
2469
  } else if (name === "..") {
2597
- const lookup = FS.lookupPath(stream.path, { parent: true });
2598
- id = lookup.node.id;
2470
+ id = FS.lookupPath(stream.path, { parent: true }).node.id;
2599
2471
  type = 4;
2600
2472
  } else {
2601
2473
  var child;
@@ -2626,16 +2498,15 @@ async function createRimeModule(moduleArg = {}) {
2626
2498
  varargs >>>= 0;
2627
2499
  SYSCALLS.varargs = varargs;
2628
2500
  try {
2629
- const stream = SYSCALLS.getStreamFromFD(fd);
2501
+ var stream = SYSCALLS.getStreamFromFD(fd);
2630
2502
  switch (op) {
2631
- case 21509: {
2503
+ case 21509:
2632
2504
  if (!stream.tty) return -59;
2633
2505
  return 0;
2634
- }
2635
- case 21505: {
2506
+ case 21505:
2636
2507
  if (!stream.tty) return -59;
2637
2508
  if (stream.tty.ops.ioctl_tcgets) {
2638
- const termios = stream.tty.ops.ioctl_tcgets(stream);
2509
+ var termios = stream.tty.ops.ioctl_tcgets(stream);
2639
2510
  var argp = syscallGetVarargP();
2640
2511
  HEAP32[argp >>> 2 >>> 0] = termios.c_iflag || 0;
2641
2512
  HEAP32[argp + 4 >>> 2 >>> 0] = termios.c_oflag || 0;
@@ -2645,24 +2516,22 @@ async function createRimeModule(moduleArg = {}) {
2645
2516
  return 0;
2646
2517
  }
2647
2518
  return 0;
2648
- }
2649
2519
  case 21510:
2650
2520
  case 21511:
2651
- case 21512: {
2521
+ case 21512:
2652
2522
  if (!stream.tty) return -59;
2653
2523
  return 0;
2654
- }
2655
2524
  case 21506:
2656
2525
  case 21507:
2657
- case 21508: {
2526
+ case 21508:
2658
2527
  if (!stream.tty) return -59;
2659
2528
  if (stream.tty.ops.ioctl_tcsets) {
2660
2529
  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 = [];
2530
+ var c_iflag = HEAP32[argp >>> 2 >>> 0];
2531
+ var c_oflag = HEAP32[argp + 4 >>> 2 >>> 0];
2532
+ var c_cflag = HEAP32[argp + 8 >>> 2 >>> 0];
2533
+ var c_lflag = HEAP32[argp + 12 >>> 2 >>> 0];
2534
+ var c_cc = [];
2666
2535
  for (var i = 0; i < 32; i++) c_cc.push(HEAP8[argp + i + 17 >>> 0]);
2667
2536
  return stream.tty.ops.ioctl_tcsets(stream.tty, op, {
2668
2537
  c_iflag,
@@ -2673,40 +2542,33 @@ async function createRimeModule(moduleArg = {}) {
2673
2542
  });
2674
2543
  }
2675
2544
  return 0;
2676
- }
2677
- case 21519: {
2545
+ case 21519:
2678
2546
  if (!stream.tty) return -59;
2679
2547
  var argp = syscallGetVarargP();
2680
2548
  HEAP32[argp >>> 2 >>> 0] = 0;
2681
2549
  return 0;
2682
- }
2683
- case 21520: {
2550
+ case 21520:
2684
2551
  if (!stream.tty) return -59;
2685
2552
  return -28;
2686
- }
2687
2553
  case 21537:
2688
- case 21531: {
2554
+ case 21531:
2689
2555
  var argp = syscallGetVarargP();
2690
2556
  return FS.ioctl(stream, op, argp);
2691
- }
2692
- case 21523: {
2557
+ case 21523:
2693
2558
  if (!stream.tty) return -59;
2694
2559
  if (stream.tty.ops.ioctl_tiocgwinsz) {
2695
- const winsize = stream.tty.ops.ioctl_tiocgwinsz(stream.tty);
2560
+ var winsize = stream.tty.ops.ioctl_tiocgwinsz(stream.tty);
2696
2561
  var argp = syscallGetVarargP();
2697
2562
  HEAP16[argp >>> 1 >>> 0] = winsize[0];
2698
2563
  HEAP16[argp + 2 >>> 1 >>> 0] = winsize[1];
2699
2564
  }
2700
2565
  return 0;
2701
- }
2702
- case 21524: {
2566
+ case 21524:
2703
2567
  if (!stream.tty) return -59;
2704
2568
  return 0;
2705
- }
2706
- case 21515: {
2569
+ case 21515:
2707
2570
  if (!stream.tty) return -59;
2708
2571
  return 0;
2709
- }
2710
2572
  default: return -28;
2711
2573
  }
2712
2574
  } catch (e) {
@@ -2742,8 +2604,8 @@ async function createRimeModule(moduleArg = {}) {
2742
2604
  buf >>>= 0;
2743
2605
  try {
2744
2606
  path = SYSCALLS.getStr(path);
2745
- const nofollow = flags & 256;
2746
- const allowEmpty = flags & 4096;
2607
+ var nofollow = flags & 256;
2608
+ var allowEmpty = flags & 4096;
2747
2609
  flags = flags & -6401;
2748
2610
  path = SYSCALLS.calculateAt(dirfd, path, allowEmpty);
2749
2611
  return SYSCALLS.writeStat(buf, nofollow ? FS.lstat(path) : FS.stat(path));
@@ -2759,7 +2621,7 @@ async function createRimeModule(moduleArg = {}) {
2759
2621
  try {
2760
2622
  path = SYSCALLS.getStr(path);
2761
2623
  path = SYSCALLS.calculateAt(dirfd, path);
2762
- const mode = varargs ? syscallGetVarargI() : 0;
2624
+ var mode = varargs ? syscallGetVarargI() : 0;
2763
2625
  return FS.open(path, flags, mode).fd;
2764
2626
  } catch (e) {
2765
2627
  if (typeof FS == "undefined" || !(e.name === "ErrnoError")) throw e;
@@ -2774,9 +2636,9 @@ async function createRimeModule(moduleArg = {}) {
2774
2636
  path = SYSCALLS.getStr(path);
2775
2637
  path = SYSCALLS.calculateAt(dirfd, path);
2776
2638
  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];
2639
+ var ret = FS.readlink(path);
2640
+ var len = Math.min(bufsize, lengthBytesUTF8(ret));
2641
+ var endChar = HEAP8[buf + len >>> 0];
2780
2642
  stringToUTF8(ret, buf, bufsize + 1);
2781
2643
  HEAP8[buf + len >>> 0] = endChar;
2782
2644
  return len;
@@ -2849,14 +2711,14 @@ async function createRimeModule(moduleArg = {}) {
2849
2711
  return -e.errno;
2850
2712
  }
2851
2713
  }
2852
- const __abort_js = () => abort("");
2853
- let runtimeKeepaliveCounter = 0;
2854
- const __emscripten_runtime_keepalive_clear = () => {
2714
+ var __abort_js = () => abort("");
2715
+ var runtimeKeepaliveCounter = 0;
2716
+ var __emscripten_runtime_keepalive_clear = () => {
2855
2717
  noExitRuntime = false;
2856
2718
  runtimeKeepaliveCounter = 0;
2857
2719
  };
2858
- const isLeapYear = (year) => year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
2859
- const MONTH_DAYS_LEAP_CUMULATIVE = [
2720
+ var isLeapYear = (year) => year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
2721
+ var MONTH_DAYS_LEAP_CUMULATIVE = [
2860
2722
  0,
2861
2723
  31,
2862
2724
  60,
@@ -2870,7 +2732,7 @@ async function createRimeModule(moduleArg = {}) {
2870
2732
  305,
2871
2733
  335
2872
2734
  ];
2873
- const MONTH_DAYS_REGULAR_CUMULATIVE = [
2735
+ var MONTH_DAYS_REGULAR_CUMULATIVE = [
2874
2736
  0,
2875
2737
  31,
2876
2738
  59,
@@ -2884,16 +2746,13 @@ async function createRimeModule(moduleArg = {}) {
2884
2746
  304,
2885
2747
  334
2886
2748
  ];
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;
2891
- return yday;
2749
+ var ydayFromDate = (date) => {
2750
+ return (isLeapYear(date.getFullYear()) ? MONTH_DAYS_LEAP_CUMULATIVE : MONTH_DAYS_REGULAR_CUMULATIVE)[date.getMonth()] + date.getDate() - 1;
2892
2751
  };
2893
2752
  function __localtime_js(time, tmPtr) {
2894
2753
  time = bigintToI53Checked(time);
2895
2754
  tmPtr >>>= 0;
2896
- const date = new Date(time * 1e3);
2755
+ var date = /* @__PURE__ */ new Date(time * 1e3);
2897
2756
  HEAP32[tmPtr >>> 2 >>> 0] = date.getSeconds();
2898
2757
  HEAP32[tmPtr + 4 >>> 2 >>> 0] = date.getMinutes();
2899
2758
  HEAP32[tmPtr + 8 >>> 2 >>> 0] = date.getHours();
@@ -2901,13 +2760,13 @@ async function createRimeModule(moduleArg = {}) {
2901
2760
  HEAP32[tmPtr + 16 >>> 2 >>> 0] = date.getMonth();
2902
2761
  HEAP32[tmPtr + 20 >>> 2 >>> 0] = date.getFullYear() - 1900;
2903
2762
  HEAP32[tmPtr + 24 >>> 2 >>> 0] = date.getDay();
2904
- const yday = ydayFromDate(date) | 0;
2763
+ var yday = ydayFromDate(date) | 0;
2905
2764
  HEAP32[tmPtr + 28 >>> 2 >>> 0] = yday;
2906
2765
  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;
2766
+ var start = new Date(date.getFullYear(), 0, 1);
2767
+ var summerOffset = new Date(date.getFullYear(), 6, 1).getTimezoneOffset();
2768
+ var winterOffset = start.getTimezoneOffset();
2769
+ var dst = (summerOffset != winterOffset && date.getTimezoneOffset() == Math.min(winterOffset, summerOffset)) | 0;
2911
2770
  HEAP32[tmPtr + 32 >>> 2 >>> 0] = dst;
2912
2771
  }
2913
2772
  function __mmap_js(len, prot, flags, fd, offset, allocated, addr) {
@@ -2916,9 +2775,9 @@ async function createRimeModule(moduleArg = {}) {
2916
2775
  allocated >>>= 0;
2917
2776
  addr >>>= 0;
2918
2777
  try {
2919
- const stream = SYSCALLS.getStreamFromFD(fd);
2920
- const res = FS.mmap(stream, len, offset, prot, flags);
2921
- const ptr = res.ptr;
2778
+ var stream = SYSCALLS.getStreamFromFD(fd);
2779
+ var res = FS.mmap(stream, len, offset, prot, flags);
2780
+ var ptr = res.ptr;
2922
2781
  HEAP32[allocated >>> 2 >>> 0] = res.allocated;
2923
2782
  HEAPU32[addr >>> 2 >>> 0] = ptr;
2924
2783
  return 0;
@@ -2932,40 +2791,40 @@ async function createRimeModule(moduleArg = {}) {
2932
2791
  len >>>= 0;
2933
2792
  offset = bigintToI53Checked(offset);
2934
2793
  try {
2935
- const stream = SYSCALLS.getStreamFromFD(fd);
2794
+ var stream = SYSCALLS.getStreamFromFD(fd);
2936
2795
  if (prot & 2) SYSCALLS.doMsync(addr, stream, len, flags, offset);
2937
2796
  } catch (e) {
2938
2797
  if (typeof FS == "undefined" || !(e.name === "ErrnoError")) throw e;
2939
2798
  return -e.errno;
2940
2799
  }
2941
2800
  }
2942
- const timers = {};
2943
- const handleException = (e) => {
2801
+ var timers = {};
2802
+ var handleException = (e) => {
2944
2803
  if (e instanceof ExitStatus || e == "unwind") return EXITSTATUS;
2945
2804
  quit_(1, e);
2946
2805
  };
2947
- const keepRuntimeAlive = () => noExitRuntime || runtimeKeepaliveCounter > 0;
2948
- const _proc_exit = (code) => {
2806
+ var keepRuntimeAlive = () => noExitRuntime || runtimeKeepaliveCounter > 0;
2807
+ var _proc_exit = (code) => {
2949
2808
  EXITSTATUS = code;
2950
2809
  if (!keepRuntimeAlive()) {
2951
- Module.onExit?.(code);
2810
+ Module["onExit"]?.(code);
2952
2811
  ABORT = true;
2953
2812
  }
2954
2813
  quit_(code, new ExitStatus(code));
2955
2814
  };
2956
- const exitJS = (status, implicit) => {
2815
+ var exitJS = (status, implicit) => {
2957
2816
  EXITSTATUS = status;
2958
2817
  _proc_exit(status);
2959
2818
  };
2960
- const _exit = exitJS;
2961
- const maybeExit = () => {
2819
+ var _exit = exitJS;
2820
+ var maybeExit = () => {
2962
2821
  if (!keepRuntimeAlive()) try {
2963
2822
  _exit(EXITSTATUS);
2964
2823
  } catch (e) {
2965
2824
  handleException(e);
2966
2825
  }
2967
2826
  };
2968
- const callUserCallback = (func) => {
2827
+ var callUserCallback = (func) => {
2969
2828
  if (ABORT) return;
2970
2829
  try {
2971
2830
  return func();
@@ -2975,45 +2834,42 @@ async function createRimeModule(moduleArg = {}) {
2975
2834
  maybeExit();
2976
2835
  }
2977
2836
  };
2978
- const _emscripten_get_now = () => performance.now();
2979
- const __setitimer_js = (which, timeout_ms) => {
2837
+ var _emscripten_get_now = () => performance.now();
2838
+ var __setitimer_js = (which, timeout_ms) => {
2980
2839
  if (timers[which]) {
2981
2840
  clearTimeout(timers[which].id);
2982
2841
  delete timers[which];
2983
2842
  }
2984
2843
  if (!timeout_ms) return 0;
2985
- const id = setTimeout(() => {
2986
- delete timers[which];
2987
- callUserCallback(() => __emscripten_timeout(which, _emscripten_get_now()));
2988
- }, timeout_ms);
2989
2844
  timers[which] = {
2990
- id,
2845
+ id: setTimeout(() => {
2846
+ delete timers[which];
2847
+ callUserCallback(() => __emscripten_timeout(which, _emscripten_get_now()));
2848
+ }, timeout_ms),
2991
2849
  timeout_ms
2992
2850
  };
2993
2851
  return 0;
2994
2852
  };
2995
- const __tzset_js = function(timezone, daylight, std_name, dst_name) {
2853
+ var __tzset_js = function(timezone, daylight, std_name, dst_name) {
2996
2854
  timezone >>>= 0;
2997
2855
  daylight >>>= 0;
2998
2856
  std_name >>>= 0;
2999
2857
  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);
2858
+ var currentYear = (/* @__PURE__ */ new Date()).getFullYear();
2859
+ var winter = new Date(currentYear, 0, 1);
2860
+ var summer = new Date(currentYear, 6, 1);
2861
+ var winterOffset = winter.getTimezoneOffset();
2862
+ var summerOffset = summer.getTimezoneOffset();
2863
+ var stdTimezoneOffset = Math.max(winterOffset, summerOffset);
3006
2864
  HEAPU32[timezone >>> 2 >>> 0] = stdTimezoneOffset * 60;
3007
2865
  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");
3013
- return `UTC${sign}${hours}${minutes}`;
2866
+ var extractZone = (timezoneOffset) => {
2867
+ var sign = timezoneOffset >= 0 ? "-" : "+";
2868
+ var absOffset = Math.abs(timezoneOffset);
2869
+ return `UTC${sign}${String(Math.floor(absOffset / 60)).padStart(2, "0")}${String(absOffset % 60).padStart(2, "0")}`;
3014
2870
  };
3015
- const winterName = extractZone(winterOffset);
3016
- const summerName = extractZone(summerOffset);
2871
+ var winterName = extractZone(winterOffset);
2872
+ var summerName = extractZone(summerOffset);
3017
2873
  if (summerOffset < winterOffset) {
3018
2874
  stringToUTF8(winterName, std_name, 17);
3019
2875
  stringToUTF8(summerName, dst_name, 17);
@@ -3022,25 +2878,24 @@ async function createRimeModule(moduleArg = {}) {
3022
2878
  stringToUTF8(summerName, std_name, 17);
3023
2879
  }
3024
2880
  };
3025
- const _emscripten_date_now = () => Date.now();
3026
- const nowIsMonotonic = 1;
3027
- const checkWasiClock = (clock_id) => clock_id >= 0 && clock_id <= 3;
2881
+ var _emscripten_date_now = () => Date.now();
2882
+ var nowIsMonotonic = 1;
2883
+ var checkWasiClock = (clock_id) => clock_id >= 0 && clock_id <= 3;
3028
2884
  function _clock_time_get(clk_id, ignored_precision, ptime) {
3029
2885
  ignored_precision = bigintToI53Checked(ignored_precision);
3030
2886
  ptime >>>= 0;
3031
2887
  if (!checkWasiClock(clk_id)) return 28;
3032
- let now;
2888
+ var now;
3033
2889
  if (clk_id === 0) now = _emscripten_date_now();
3034
2890
  else if (nowIsMonotonic) now = _emscripten_get_now();
3035
2891
  else return 52;
3036
- const nsec = Math.round(now * 1e3 * 1e3);
2892
+ var nsec = Math.round(now * 1e3 * 1e3);
3037
2893
  HEAP64[ptime >>> 3 >>> 0] = BigInt(nsec);
3038
2894
  return 0;
3039
2895
  }
3040
- const getHeapMax = () => 4294901760;
3041
- const growMemory = (size) => {
3042
- const oldHeapSize = wasmMemory.buffer.byteLength;
3043
- const pages = (size - oldHeapSize + 65535) / 65536 | 0;
2896
+ var getHeapMax = () => 4294901760;
2897
+ var growMemory = (size) => {
2898
+ var pages = (size - wasmMemory.buffer.byteLength + 65535) / 65536 | 0;
3044
2899
  try {
3045
2900
  wasmMemory.grow(pages);
3046
2901
  updateMemoryViews();
@@ -3049,35 +2904,32 @@ async function createRimeModule(moduleArg = {}) {
3049
2904
  };
3050
2905
  function _emscripten_resize_heap(requestedSize) {
3051
2906
  requestedSize >>>= 0;
3052
- const oldSize = HEAPU8.length;
3053
- const maxHeapSize = getHeapMax();
2907
+ var oldSize = HEAPU8.length;
2908
+ var maxHeapSize = getHeapMax();
3054
2909
  if (requestedSize > maxHeapSize) return false;
3055
- for (let cutDown = 1; cutDown <= 4; cutDown *= 2) {
3056
- let overGrownHeapSize = oldSize * (1 + .2 / cutDown);
2910
+ for (var cutDown = 1; cutDown <= 4; cutDown *= 2) {
2911
+ var overGrownHeapSize = oldSize * (1 + .2 / cutDown);
3057
2912
  overGrownHeapSize = Math.min(overGrownHeapSize, requestedSize + 100663296);
3058
- const newSize = Math.min(maxHeapSize, alignMemory(Math.max(requestedSize, overGrownHeapSize), 65536));
3059
- const replacement = growMemory(newSize);
3060
- if (replacement) return true;
2913
+ if (growMemory(Math.min(maxHeapSize, alignMemory(Math.max(requestedSize, overGrownHeapSize), 65536)))) return true;
3061
2914
  }
3062
2915
  return false;
3063
2916
  }
3064
- const ENV = {};
3065
- const getExecutableName = () => thisProgram || "./this.program";
3066
- const getEnvStrings = () => {
2917
+ var ENV = {};
2918
+ var getExecutableName = () => thisProgram || "./this.program";
2919
+ var getEnvStrings = () => {
3067
2920
  if (!getEnvStrings.strings) {
3068
- const lang = `${(globalThis.navigator?.language ?? "C").replace("-", "_")}.UTF-8`;
3069
- const env = {
2921
+ var env = {
3070
2922
  USER: "web_user",
3071
2923
  LOGNAME: "web_user",
3072
2924
  PATH: "/",
3073
2925
  PWD: "/",
3074
2926
  HOME: "/home/web_user",
3075
- LANG: lang,
2927
+ LANG: (globalThis.navigator?.language ?? "C").replace("-", "_") + ".UTF-8",
3076
2928
  _: getExecutableName()
3077
2929
  };
3078
2930
  for (var x in ENV) if (ENV[x] === void 0) delete env[x];
3079
2931
  else env[x] = ENV[x];
3080
- const strings = [];
2932
+ var strings = [];
3081
2933
  for (var x in env) strings.push(`${x}=${env[x]}`);
3082
2934
  getEnvStrings.strings = strings;
3083
2935
  }
@@ -3086,10 +2938,10 @@ async function createRimeModule(moduleArg = {}) {
3086
2938
  function _environ_get(__environ, environ_buf) {
3087
2939
  __environ >>>= 0;
3088
2940
  environ_buf >>>= 0;
3089
- let bufSize = 0;
3090
- let envp = 0;
3091
- for (const string of getEnvStrings()) {
3092
- const ptr = environ_buf + bufSize;
2941
+ var bufSize = 0;
2942
+ var envp = 0;
2943
+ for (var string of getEnvStrings()) {
2944
+ var ptr = environ_buf + bufSize;
3093
2945
  HEAPU32[__environ + envp >>> 2 >>> 0] = ptr;
3094
2946
  bufSize += stringToUTF8(string, ptr, Infinity) + 1;
3095
2947
  envp += 4;
@@ -3099,16 +2951,16 @@ async function createRimeModule(moduleArg = {}) {
3099
2951
  function _environ_sizes_get(penviron_count, penviron_buf_size) {
3100
2952
  penviron_count >>>= 0;
3101
2953
  penviron_buf_size >>>= 0;
3102
- const strings = getEnvStrings();
2954
+ var strings = getEnvStrings();
3103
2955
  HEAPU32[penviron_count >>> 2 >>> 0] = strings.length;
3104
- let bufSize = 0;
3105
- for (const string of strings) bufSize += lengthBytesUTF8(string) + 1;
2956
+ var bufSize = 0;
2957
+ for (var string of strings) bufSize += lengthBytesUTF8(string) + 1;
3106
2958
  HEAPU32[penviron_buf_size >>> 2 >>> 0] = bufSize;
3107
2959
  return 0;
3108
2960
  }
3109
2961
  function _fd_close(fd) {
3110
2962
  try {
3111
- const stream = SYSCALLS.getStreamFromFD(fd);
2963
+ var stream = SYSCALLS.getStreamFromFD(fd);
3112
2964
  FS.close(stream);
3113
2965
  return 0;
3114
2966
  } catch (e) {
@@ -3119,13 +2971,11 @@ async function createRimeModule(moduleArg = {}) {
3119
2971
  function _fd_fdstat_get(fd, pbuf) {
3120
2972
  pbuf >>>= 0;
3121
2973
  try {
3122
- const rightsBase = 0;
3123
- const rightsInheriting = 0;
3124
- const flags = 0;
3125
- {
3126
- const stream = SYSCALLS.getStreamFromFD(fd);
3127
- var type = stream.tty ? 2 : FS.isDir(stream.mode) ? 3 : FS.isLink(stream.mode) ? 7 : 4;
3128
- }
2974
+ var rightsBase = 0;
2975
+ var rightsInheriting = 0;
2976
+ var flags = 0;
2977
+ var stream = SYSCALLS.getStreamFromFD(fd);
2978
+ var type = stream.tty ? 2 : FS.isDir(stream.mode) ? 3 : FS.isLink(stream.mode) ? 7 : 4;
3129
2979
  HEAP8[pbuf >>> 0] = type;
3130
2980
  HEAP16[pbuf + 2 >>> 1 >>> 0] = flags;
3131
2981
  HEAP64[pbuf + 8 >>> 3 >>> 0] = BigInt(rightsBase);
@@ -3136,13 +2986,13 @@ async function createRimeModule(moduleArg = {}) {
3136
2986
  return e.errno;
3137
2987
  }
3138
2988
  }
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];
2989
+ var doReadv = (stream, iov, iovcnt, offset) => {
2990
+ var ret = 0;
2991
+ for (var i = 0; i < iovcnt; i++) {
2992
+ var ptr = HEAPU32[iov >>> 2 >>> 0];
2993
+ var len = HEAPU32[iov + 4 >>> 2 >>> 0];
3144
2994
  iov += 8;
3145
- const curr = FS.read(stream, HEAP8, ptr, len, offset);
2995
+ var curr = FS.read(stream, HEAP8, ptr, len, offset);
3146
2996
  if (curr < 0) return -1;
3147
2997
  ret += curr;
3148
2998
  if (curr < len) break;
@@ -3157,8 +3007,7 @@ async function createRimeModule(moduleArg = {}) {
3157
3007
  pnum >>>= 0;
3158
3008
  try {
3159
3009
  if (isNaN(offset)) return 61;
3160
- const stream = SYSCALLS.getStreamFromFD(fd);
3161
- const num = doReadv(stream, iov, iovcnt, offset);
3010
+ var num = doReadv(SYSCALLS.getStreamFromFD(fd), iov, iovcnt, offset);
3162
3011
  HEAPU32[pnum >>> 2 >>> 0] = num;
3163
3012
  return 0;
3164
3013
  } catch (e) {
@@ -3171,8 +3020,7 @@ async function createRimeModule(moduleArg = {}) {
3171
3020
  iovcnt >>>= 0;
3172
3021
  pnum >>>= 0;
3173
3022
  try {
3174
- const stream = SYSCALLS.getStreamFromFD(fd);
3175
- const num = doReadv(stream, iov, iovcnt);
3023
+ var num = doReadv(SYSCALLS.getStreamFromFD(fd), iov, iovcnt);
3176
3024
  HEAPU32[pnum >>> 2 >>> 0] = num;
3177
3025
  return 0;
3178
3026
  } catch (e) {
@@ -3185,7 +3033,7 @@ async function createRimeModule(moduleArg = {}) {
3185
3033
  newOffset >>>= 0;
3186
3034
  try {
3187
3035
  if (isNaN(offset)) return 61;
3188
- const stream = SYSCALLS.getStreamFromFD(fd);
3036
+ var stream = SYSCALLS.getStreamFromFD(fd);
3189
3037
  FS.llseek(stream, offset, whence);
3190
3038
  HEAP64[newOffset >>> 3 >>> 0] = BigInt(stream.position);
3191
3039
  if (stream.getdents && offset === 0 && whence === 0) stream.getdents = null;
@@ -3195,13 +3043,13 @@ async function createRimeModule(moduleArg = {}) {
3195
3043
  return e.errno;
3196
3044
  }
3197
3045
  }
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];
3046
+ var doWritev = (stream, iov, iovcnt, offset) => {
3047
+ var ret = 0;
3048
+ for (var i = 0; i < iovcnt; i++) {
3049
+ var ptr = HEAPU32[iov >>> 2 >>> 0];
3050
+ var len = HEAPU32[iov + 4 >>> 2 >>> 0];
3203
3051
  iov += 8;
3204
- const curr = FS.write(stream, HEAP8, ptr, len, offset);
3052
+ var curr = FS.write(stream, HEAP8, ptr, len, offset);
3205
3053
  if (curr < 0) return -1;
3206
3054
  ret += curr;
3207
3055
  if (curr < len) break;
@@ -3214,8 +3062,7 @@ async function createRimeModule(moduleArg = {}) {
3214
3062
  iovcnt >>>= 0;
3215
3063
  pnum >>>= 0;
3216
3064
  try {
3217
- const stream = SYSCALLS.getStreamFromFD(fd);
3218
- const num = doWritev(stream, iov, iovcnt);
3065
+ var num = doWritev(SYSCALLS.getStreamFromFD(fd), iov, iovcnt);
3219
3066
  HEAPU32[pnum >>> 2 >>> 0] = num;
3220
3067
  return 0;
3221
3068
  } catch (e) {
@@ -3234,109 +3081,106 @@ async function createRimeModule(moduleArg = {}) {
3234
3081
  return e.errno;
3235
3082
  }
3236
3083
  }
3237
- const getCFunc = (ident) => {
3238
- const func = Module[`_${ident}`];
3239
- return func;
3084
+ var getCFunc = (ident) => {
3085
+ return Module["_" + ident];
3240
3086
  };
3241
- const writeArrayToMemory = (array, buffer) => {
3087
+ var writeArrayToMemory = (array, buffer) => {
3242
3088
  HEAP8.set(array, buffer >>> 0);
3243
3089
  };
3244
- const stackAlloc = (sz) => __emscripten_stack_alloc(sz);
3245
- const stringToUTF8OnStack = (str) => {
3246
- const size = lengthBytesUTF8(str) + 1;
3247
- const ret = stackAlloc(size);
3090
+ var stackAlloc = (sz) => __emscripten_stack_alloc(sz);
3091
+ var stringToUTF8OnStack = (str) => {
3092
+ var size = lengthBytesUTF8(str) + 1;
3093
+ var ret = stackAlloc(size);
3248
3094
  stringToUTF8(str, ret, size);
3249
3095
  return ret;
3250
3096
  };
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 = {
3097
+ var stackSave = () => _emscripten_stack_get_current();
3098
+ var stackRestore = (val) => __emscripten_stack_restore(val);
3099
+ var ccall = (ident, returnType, argTypes, args, opts) => {
3100
+ var toC = {
3255
3101
  string: (str) => {
3256
- let ret$1 = 0;
3257
- if (str !== null && str !== void 0 && str !== 0) ret$1 = stringToUTF8OnStack(str);
3258
- return ret$1;
3102
+ var ret = 0;
3103
+ if (str !== null && str !== void 0 && str !== 0) ret = stringToUTF8OnStack(str);
3104
+ return ret;
3259
3105
  },
3260
3106
  array: (arr) => {
3261
- const ret$1 = stackAlloc(arr.length);
3262
- writeArrayToMemory(arr, ret$1);
3263
- return ret$1;
3107
+ var ret = stackAlloc(arr.length);
3108
+ writeArrayToMemory(arr, ret);
3109
+ return ret;
3264
3110
  }
3265
3111
  };
3266
- function convertReturnValue(ret$1) {
3267
- if (returnType === "string") return UTF8ToString(ret$1);
3268
- if (returnType === "pointer") return ret$1 >>> 0;
3269
- if (returnType === "boolean") return Boolean(ret$1);
3270
- return ret$1;
3271
- }
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]];
3112
+ function convertReturnValue(ret) {
3113
+ if (returnType === "string") return UTF8ToString(ret);
3114
+ if (returnType === "pointer") return ret >>> 0;
3115
+ if (returnType === "boolean") return Boolean(ret);
3116
+ return ret;
3117
+ }
3118
+ var func = getCFunc(ident);
3119
+ var cArgs = [];
3120
+ var stack = 0;
3121
+ if (args) for (var i = 0; i < args.length; i++) {
3122
+ var converter = toC[argTypes[i]];
3277
3123
  if (converter) {
3278
3124
  if (stack === 0) stack = stackSave();
3279
3125
  cArgs[i] = converter(args[i]);
3280
3126
  } else cArgs[i] = args[i];
3281
3127
  }
3282
- let ret = func(...cArgs);
3283
- function onDone(ret$1) {
3128
+ var ret = func(...cArgs);
3129
+ function onDone(ret) {
3284
3130
  if (stack !== 0) stackRestore(stack);
3285
- return convertReturnValue(ret$1);
3131
+ return convertReturnValue(ret);
3286
3132
  }
3287
3133
  ret = onDone(ret);
3288
3134
  return ret;
3289
3135
  };
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);
3136
+ var FS_createPath = (...args) => FS.createPath(...args);
3137
+ var FS_unlink = (...args) => FS.unlink(...args);
3138
+ var FS_createLazyFile = (...args) => FS.createLazyFile(...args);
3139
+ var FS_createDevice = (...args) => FS.createDevice(...args);
3294
3140
  FS.createPreloadedFile = FS_createPreloadedFile;
3295
3141
  FS.preloadFile = FS_preloadFile;
3296
3142
  FS.staticInit();
3297
- {
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()();
3308
- }
3143
+ if (Module["noExitRuntime"]) noExitRuntime = Module["noExitRuntime"];
3144
+ if (Module["preloadPlugins"]) preloadPlugins = Module["preloadPlugins"];
3145
+ if (Module["print"]) out = Module["print"];
3146
+ if (Module["printErr"]) err = Module["printErr"];
3147
+ if (Module["wasmBinary"]) wasmBinary = Module["wasmBinary"];
3148
+ if (Module["arguments"]) Module["arguments"];
3149
+ if (Module["thisProgram"]) thisProgram = Module["thisProgram"];
3150
+ if (Module["preInit"]) {
3151
+ if (typeof Module["preInit"] == "function") Module["preInit"] = [Module["preInit"]];
3152
+ while (Module["preInit"].length > 0) Module["preInit"].shift()();
3309
3153
  }
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;
3321
- 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;
3154
+ Module["addRunDependency"] = addRunDependency;
3155
+ Module["removeRunDependency"] = removeRunDependency;
3156
+ Module["ccall"] = ccall;
3157
+ Module["FS_preloadFile"] = FS_preloadFile;
3158
+ Module["FS_unlink"] = FS_unlink;
3159
+ Module["FS_createPath"] = FS_createPath;
3160
+ Module["FS_createDevice"] = FS_createDevice;
3161
+ Module["FS"] = FS;
3162
+ Module["FS_createDataFile"] = FS_createDataFile;
3163
+ Module["FS_createLazyFile"] = FS_createLazyFile;
3164
+ var _emscripten_builtin_memalign, __emscripten_timeout, ___trap, __emscripten_stack_restore, __emscripten_stack_alloc, _emscripten_stack_get_current, wasmMemory;
3165
+ function assignWasmExports(wasmExports) {
3166
+ Module["_free"] = wasmExports["R"];
3167
+ Module["_malloc"] = wasmExports["S"];
3168
+ Module["_rime_wasm_init"] = wasmExports["T"];
3169
+ Module["_rime_wasm_process_input"] = wasmExports["U"];
3170
+ Module["_rime_wasm_pick_candidate"] = wasmExports["V"];
3171
+ Module["_rime_wasm_flip_page"] = wasmExports["W"];
3172
+ Module["_rime_wasm_clear_input"] = wasmExports["X"];
3173
+ Module["_rime_wasm_set_option"] = wasmExports["Y"];
3174
+ Module["_rime_wasm_get_version"] = wasmExports["Z"];
3175
+ Module["_rime_wasm_destroy"] = wasmExports["_"];
3176
+ _emscripten_builtin_memalign = wasmExports["$"];
3177
+ __emscripten_timeout = wasmExports["aa"];
3178
+ ___trap = wasmExports["ba"];
3179
+ __emscripten_stack_restore = wasmExports["ca"];
3180
+ __emscripten_stack_alloc = wasmExports["da"];
3181
+ _emscripten_stack_get_current = wasmExports["ea"];
3182
+ wasmMemory = wasmExports["P"];
3183
+ wasmExports["__indirect_function_table"];
3340
3184
  }
3341
3185
  var wasmImports = {
3342
3186
  r: ___syscall_chmod,
@@ -3381,16 +3225,16 @@ async function createRimeModule(moduleArg = {}) {
3381
3225
  m: _proc_exit,
3382
3226
  p: _random_get
3383
3227
  };
3384
- function applySignatureConversions(wasmExports$1) {
3385
- 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);
3393
- return wasmExports$1;
3228
+ function applySignatureConversions(wasmExports) {
3229
+ wasmExports = Object.assign({}, wasmExports);
3230
+ var makeWrapper_pp = (f) => (a0) => f(a0) >>> 0;
3231
+ var makeWrapper_ppp = (f) => (a0, a1) => f(a0, a1) >>> 0;
3232
+ var makeWrapper_p = (f) => () => f() >>> 0;
3233
+ wasmExports["S"] = makeWrapper_pp(wasmExports["S"]);
3234
+ wasmExports["$"] = makeWrapper_ppp(wasmExports["$"]);
3235
+ wasmExports["da"] = makeWrapper_pp(wasmExports["da"]);
3236
+ wasmExports["ea"] = makeWrapper_p(wasmExports["ea"]);
3237
+ return wasmExports;
3394
3238
  }
3395
3239
  function run() {
3396
3240
  if (runDependencies > 0) {
@@ -3403,23 +3247,22 @@ async function createRimeModule(moduleArg = {}) {
3403
3247
  return;
3404
3248
  }
3405
3249
  function doRun() {
3406
- Module.calledRun = true;
3250
+ Module["calledRun"] = true;
3407
3251
  if (ABORT) return;
3408
3252
  initRuntime();
3409
3253
  readyPromiseResolve?.(Module);
3410
- Module.onRuntimeInitialized?.();
3254
+ Module["onRuntimeInitialized"]?.();
3411
3255
  postRun();
3412
3256
  }
3413
- if (Module.setStatus) {
3414
- Module.setStatus("Running...");
3257
+ if (Module["setStatus"]) {
3258
+ Module["setStatus"]("Running...");
3415
3259
  setTimeout(() => {
3416
- setTimeout(() => Module.setStatus(""), 1);
3260
+ setTimeout(() => Module["setStatus"](""), 1);
3417
3261
  doRun();
3418
3262
  }, 1);
3419
3263
  } else doRun();
3420
3264
  }
3421
- let wasmExports;
3422
- wasmExports = await createWasm();
3265
+ var wasmExports = await createWasm();
3423
3266
  run();
3424
3267
  if (runtimeInitialized) moduleRtn = Module;
3425
3268
  else moduleRtn = new Promise((resolve, reject) => {
@@ -3428,8 +3271,6 @@ async function createRimeModule(moduleArg = {}) {
3428
3271
  });
3429
3272
  return moduleRtn;
3430
3273
  }
3431
- var rime_api_default = createRimeModule;
3432
-
3433
3274
  //#endregion
3434
3275
  //#region src/rime.ts
3435
3276
  function syncfs(module, populate) {
@@ -3442,7 +3283,7 @@ function syncfs(module, populate) {
3442
3283
  }
3443
3284
  async function createRimeEngine(options = {}) {
3444
3285
  const wasmDir = options.wasmDir ?? ".";
3445
- const Module = await rime_api_default({ locateFile(file) {
3286
+ const Module = await createRimeModule({ locateFile(file) {
3446
3287
  return `${wasmDir}/${file}`;
3447
3288
  } });
3448
3289
  try {
@@ -3479,7 +3320,7 @@ async function createRimeEngine(options = {}) {
3479
3320
  const json = Module.ccall(fn, "string", argTypes, args);
3480
3321
  return JSON.parse(json);
3481
3322
  }
3482
- const engine = {
3323
+ return {
3483
3324
  processInput(keys) {
3484
3325
  return callJson("rime_wasm_process_input", ["string"], [keys]);
3485
3326
  },
@@ -3510,9 +3351,7 @@ async function createRimeEngine(options = {}) {
3510
3351
  syncfs(Module, false).catch(() => {});
3511
3352
  }
3512
3353
  };
3513
- return engine;
3514
3354
  }
3515
-
3516
3355
  //#endregion
3517
3356
  //#region src/index.ts
3518
3357
  /**
@@ -3558,23 +3397,19 @@ var RimePinyinEngine = class {
3558
3397
  return state;
3559
3398
  }
3560
3399
  async pickCandidate(index) {
3561
- const engine = await this.getEngine();
3562
- return engine.pickCandidate(index);
3400
+ return (await this.getEngine()).pickCandidate(index);
3563
3401
  }
3564
3402
  async clearInput() {
3565
- const engine = await this.getEngine();
3566
- return engine.clearInput();
3403
+ return (await this.getEngine()).clearInput();
3567
3404
  }
3568
3405
  async setSimplified(simplified) {
3569
- const engine = await this.getEngine();
3570
- return engine.setOption("zh_simp", simplified);
3406
+ return (await this.getEngine()).setOption("zh_simp", simplified);
3571
3407
  }
3572
3408
  async destroy() {
3573
- const engine = await this.getEngine();
3574
- return engine.destroy();
3409
+ return (await this.getEngine()).destroy();
3575
3410
  }
3576
3411
  };
3577
-
3578
3412
  //#endregion
3579
3413
  export { RimePinyinEngine };
3414
+
3580
3415
  //# sourceMappingURL=index.mjs.map