@litert-lm/core 0.15.0 → 0.17.0

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.
@@ -193,8 +193,6 @@ var EXITSTATUS;
193
193
  */ var isFileURI = filename => filename.startsWith("file://");
194
194
 
195
195
  // include: runtime_common.js
196
- // include: runtime_stack_check.js
197
- // end include: runtime_stack_check.js
198
196
  // include: runtime_exceptions.js
199
197
  // Base Emscripten EH error class
200
198
  class EmscriptenEH {}
@@ -207,8 +205,17 @@ class EmscriptenSjLj extends EmscriptenEH {}
207
205
  // Memory management
208
206
  var runtimeInitialized = false;
209
207
 
208
+ // When ALLOW_MEMORY_GROWTH is enabled, the conversion from Wasm
209
+ // memory to ArrayBuffer requires some additional logic.
210
+ function getMemoryBuffer() {
211
+ return wasmMemory.buffer;
212
+ }
213
+
210
214
  function updateMemoryViews() {
211
- var b = wasmMemory.buffer;
215
+ // If we already have a heap that is resizeable/growable buffer we don't
216
+ // need to do anything in updateMemoryViews.
217
+ if (HEAP8?.buffer?.resizable) return;
218
+ var b = getMemoryBuffer();
212
219
  HEAP8 = new Int8Array(b);
213
220
  HEAP16 = new Int16Array(b);
214
221
  Module["HEAPU8"] = HEAPU8 = new Uint8Array(b);
@@ -225,11 +232,10 @@ function updateMemoryViews() {
225
232
  // end include: memoryprofiler.js
226
233
  // end include: runtime_common.js
227
234
  function preRun() {
228
- if (Module["preRun"]) {
229
- if (typeof Module["preRun"] == "function") Module["preRun"] = [ Module["preRun"] ];
230
- while (Module["preRun"].length) {
231
- addOnPreRun(Module["preRun"].shift());
232
- }
235
+ var preRun = Module["preRun"];
236
+ if (preRun) {
237
+ if (typeof preRun == "function") preRun = [ preRun ];
238
+ onPreRuns.push(...preRun);
233
239
  }
234
240
  // Begin ATPRERUNS hooks
235
241
  callRuntimeCallbacks(onPreRuns);
@@ -247,12 +253,10 @@ function initRuntime() {
247
253
  }
248
254
 
249
255
  function postRun() {
250
- // PThreads reuse the runtime from the main thread.
251
- if (Module["postRun"]) {
252
- if (typeof Module["postRun"] == "function") Module["postRun"] = [ Module["postRun"] ];
253
- while (Module["postRun"].length) {
254
- addOnPostRun(Module["postRun"].shift());
255
- }
256
+ var postRun = Module["postRun"];
257
+ if (postRun) {
258
+ if (typeof postRun == "function") postRun = [ postRun ];
259
+ onPostRuns.push(...postRun);
256
260
  }
257
261
  // Begin ATPOSTRUNS hooks
258
262
  callRuntimeCallbacks(onPostRuns);
@@ -294,9 +298,6 @@ function findWasmBinary() {
294
298
  }
295
299
 
296
300
  function getBinarySync(file) {
297
- if (file == wasmBinaryFile && wasmBinary) {
298
- return new Uint8Array(wasmBinary);
299
- }
300
301
  if (readBinary) {
301
302
  return readBinary(file);
302
303
  }
@@ -366,7 +367,7 @@ async function createWasm() {
366
367
  // Load the wasm module and create an instance of using native support in the JS engine.
367
368
  // handle a generated wasm instance, receiving its exports and
368
369
  // performing other necessary setup
369
- /** @param {WebAssembly.Module=} module*/ function receiveInstance(instance, module) {
370
+ function receiveInstance(instance) {
370
371
  wasmExports = instance.exports;
371
372
  wasmExports = Asyncify.instrumentWasmExports(wasmExports);
372
373
  wasmExports = applySignatureConversions(wasmExports);
@@ -389,11 +390,10 @@ async function createWasm() {
389
390
  // performing.
390
391
  // Also pthreads and wasm workers initialize the wasm instance through this
391
392
  // path.
392
- if (Module["instantiateWasm"]) {
393
- return new Promise((resolve, reject) => {
394
- Module["instantiateWasm"](info, (inst, mod) => {
395
- resolve(receiveInstance(inst, mod));
396
- });
393
+ var instantiateWasm = Module["instantiateWasm"];
394
+ if (instantiateWasm) {
395
+ return new Promise(resolve => {
396
+ instantiateWasm(info, inst => resolve(receiveInstance(inst)));
397
397
  });
398
398
  }
399
399
  wasmBinaryFile ??= findWasmBinary();
@@ -468,7 +468,7 @@ var callUserCallback = func => {
468
468
  };
469
469
 
470
470
  function getFullscreenElement() {
471
- return document.fullscreenElement || document.mozFullScreenElement || document.webkitFullscreenElement || document.webkitCurrentFullScreenElement || document.msFullscreenElement;
471
+ return document.fullscreenElement ?? document.webkitFullscreenElement;
472
472
  }
473
473
 
474
474
  /** @param {number=} timeout */ var safeSetTimeout = (func, timeout) => setTimeout(() => {
@@ -486,12 +486,15 @@ var warnOnce = text => {
486
486
 
487
487
  var preloadPlugins = [];
488
488
 
489
+ /** @type {!Int32Array} */ var HEAP32;
490
+
491
+ /** @type {!Uint32Array} */ var HEAPU32;
492
+
489
493
  var Browser = {
490
494
  useWebGL: false,
491
495
  isFullscreen: false,
492
496
  pointerLock: false,
493
497
  moduleContextCreatedCallbacks: [],
494
- workers: [],
495
498
  preloadedImages: {},
496
499
  preloadedAudios: {},
497
500
  getCanvas: () => Module["canvas"],
@@ -558,7 +561,7 @@ var Browser = {
558
561
  var url = URL.createObjectURL(b);
559
562
  // XXX we never revoke this!
560
563
  var audio = new Audio;
561
- audio.addEventListener("canplaythrough", () => finish(audio), false);
564
+ audio.addEventListener("canplaythrough", () => finish(audio));
562
565
  // use addEventListener due to chromium bug 124926
563
566
  audio.onerror = event => {
564
567
  if (done) return;
@@ -606,14 +609,14 @@ var Browser = {
606
609
  if (canvas) {
607
610
  // forced aspect ratio can be enabled by defining 'forcedAspectRatio' on Module
608
611
  // Module['forcedAspectRatio'] = 4 / 3;
609
- document.addEventListener("pointerlockchange", pointerLockChange, false);
612
+ document.addEventListener("pointerlockchange", pointerLockChange);
610
613
  if (Module["elementPointerLock"]) {
611
614
  canvas.addEventListener("click", ev => {
612
615
  if (!Browser.pointerLock && Browser.getCanvas().requestPointerLock) {
613
616
  Browser.getCanvas().requestPointerLock();
614
617
  ev.preventDefault();
615
618
  }
616
- }, false);
619
+ });
617
620
  }
618
621
  }
619
622
  },
@@ -687,32 +690,30 @@ var Browser = {
687
690
  Browser.updateCanvasDimensions(canvas);
688
691
  }
689
692
  }
690
- Module["onFullScreen"]?.(Browser.isFullscreen);
691
- Module["onFullscreen"]?.(Browser.isFullscreen);
692
693
  }
693
694
  if (!Browser.fullscreenHandlersInstalled) {
694
695
  Browser.fullscreenHandlersInstalled = true;
695
- document.addEventListener("fullscreenchange", fullscreenChange, false);
696
- document.addEventListener("mozfullscreenchange", fullscreenChange, false);
697
- document.addEventListener("webkitfullscreenchange", fullscreenChange, false);
698
- document.addEventListener("MSFullscreenChange", fullscreenChange, false);
696
+ document.addEventListener("fullscreenchange", fullscreenChange);
697
+ document.addEventListener("webkitfullscreenchange", fullscreenChange);
699
698
  }
700
699
  // create a new parent to ensure the canvas has no siblings. this allows browsers to optimize full screen performance when its parent is the full screen root
701
700
  var canvasContainer = document.createElement("div");
702
701
  canvas.parentNode.insertBefore(canvasContainer, canvas);
703
702
  canvasContainer.appendChild(canvas);
704
703
  // use parent of canvas as full screen root to allow aspect ratio correction (Firefox stretches the root to screen size)
705
- canvasContainer.requestFullscreen = canvasContainer["requestFullscreen"] || canvasContainer["mozRequestFullScreen"] || canvasContainer["msRequestFullscreen"] || (canvasContainer["webkitRequestFullscreen"] ? () => canvasContainer["webkitRequestFullscreen"](Element["ALLOW_KEYBOARD_INPUT"]) : null) || (canvasContainer["webkitRequestFullScreen"] ? () => canvasContainer["webkitRequestFullScreen"](Element["ALLOW_KEYBOARD_INPUT"]) : null);
704
+ // Safari didn't support Element.requestFullscreen until 16.4
705
+ // See: https://developer.mozilla.org/en-US/docs/Web/API/Element/requestFullscreen
706
+ /** @suppress {checkTypes} */ canvasContainer.requestFullscreen ??= (canvasContainer["webkitRequestFullscreen"] ? () => canvasContainer["webkitRequestFullscreen"](Element.ALLOW_KEYBOARD_INPUT) : null) ?? (canvasContainer["webkitRequestFullScreen"] ? () => canvasContainer["webkitRequestFullScreen"](Element.ALLOW_KEYBOARD_INPUT) : null);
706
707
  canvasContainer.requestFullscreen();
707
708
  },
708
709
  exitFullscreen() {
709
710
  // This is workaround for chrome. Trying to exit from fullscreen
710
- // not in fullscreen state will cause "TypeError: Document not active"
711
+ // not in fullscreen state will cause 'TypeError: Document not active'
711
712
  // in chrome. See https://github.com/emscripten-core/emscripten/pull/8236
712
713
  if (!Browser.isFullscreen) {
713
714
  return false;
714
715
  }
715
- var CFS = document["exitFullscreen"] || document["cancelFullScreen"] || document["mozCancelFullScreen"] || document["msExitFullscreen"] || document["webkitCancelFullScreen"] || (() => {});
716
+ var CFS = document.exitFullscreen ?? document["webkitCancelFullScreen"];
716
717
  CFS.apply(document, []);
717
718
  return true;
718
719
  },
@@ -734,14 +735,7 @@ var Browser = {
734
735
  }[name.slice(name.lastIndexOf(".") + 1)];
735
736
  },
736
737
  getUserMedia(func) {
737
- window.getUserMedia ||= navigator["getUserMedia"] || navigator["mozGetUserMedia"];
738
- window.getUserMedia(func);
739
- },
740
- getMovementX(event) {
741
- return event["movementX"] || event["mozMovementX"] || event["webkitMovementX"] || 0;
742
- },
743
- getMovementY(event) {
744
- return event["movementY"] || event["mozMovementY"] || event["webkitMovementY"] || 0;
738
+ return navigator.mediaDevices.getUserMedia(func);
745
739
  },
746
740
  getMouseWheelDelta(event) {
747
741
  var delta = 0;
@@ -819,13 +813,8 @@ var Browser = {
819
813
  if (Browser.pointerLock) {
820
814
  // When the pointer is locked, calculate the coordinates
821
815
  // based on the movement of the mouse.
822
- // Workaround for Firefox bug 764498
823
- if (event.type != "mousemove" && ("mozMovementX" in event)) {
824
- Browser.mouseMovementX = Browser.mouseMovementY = 0;
825
- } else {
826
- Browser.mouseMovementX = Browser.getMovementX(event);
827
- Browser.mouseMovementY = Browser.getMovementY(event);
828
- }
816
+ Browser.mouseMovementX = event.movementX;
817
+ Browser.mouseMovementY = event.movementY;
829
818
  // add the mouse delta to the current absolute mouse position
830
819
  Browser.mouseX += Browser.mouseMovementX;
831
820
  Browser.mouseY += Browser.mouseMovementY;
@@ -894,13 +883,6 @@ var Browser = {
894
883
  }
895
884
  var w = wNative;
896
885
  var h = hNative;
897
- if (Module["forcedAspectRatio"] > 0) {
898
- if (w / h < Module["forcedAspectRatio"]) {
899
- w = Math.round(h * Module["forcedAspectRatio"]);
900
- } else {
901
- h = Math.round(w / Module["forcedAspectRatio"]);
902
- }
903
- }
904
886
  if ((getFullscreenElement() === canvas.parentNode) && (typeof screen != "undefined")) {
905
887
  var factor = Math.min(screen.width / w, screen.height / h);
906
888
  w = Math.round(w * factor);
@@ -929,26 +911,8 @@ var Browser = {
929
911
  }
930
912
  };
931
913
 
932
- /** @type {!Int16Array} */ var HEAP16;
933
-
934
- /** @type {!Int32Array} */ var HEAP32;
935
-
936
- /** not-@type {!BigInt64Array} */ var HEAP64;
937
-
938
914
  /** @type {!Int8Array} */ var HEAP8;
939
915
 
940
- /** @type {!Float32Array} */ var HEAPF32;
941
-
942
- /** @type {!Float64Array} */ var HEAPF64;
943
-
944
- /** @type {!Uint16Array} */ var HEAPU16;
945
-
946
- /** @type {!Uint32Array} */ var HEAPU32;
947
-
948
- /** not-@type {!BigUint64Array} */ var HEAPU64;
949
-
950
- /** @type {!Uint8Array} */ var HEAPU8;
951
-
952
916
  var callRuntimeCallbacks = callbacks => {
953
917
  while (callbacks.length > 0) {
954
918
  // Pass the module as the first argument.
@@ -958,12 +922,8 @@ var callRuntimeCallbacks = callbacks => {
958
922
 
959
923
  var onPostRuns = [];
960
924
 
961
- var addOnPostRun = cb => onPostRuns.push(cb);
962
-
963
925
  var onPreRuns = [];
964
926
 
965
- var addOnPreRun = cb => onPreRuns.push(cb);
966
-
967
927
  var noExitRuntime = true;
968
928
 
969
929
  var stackRestore = val => __emscripten_stack_restore(val);
@@ -1103,7 +1063,7 @@ var initRandomFill = () => {
1103
1063
  // This block is not needed on v19+ since crypto.getRandomValues is builtin
1104
1064
  if (ENVIRONMENT_IS_NODE) {
1105
1065
  var nodeCrypto = require("node:crypto");
1106
- return view => nodeCrypto.randomFillSync(view);
1066
+ return view => (nodeCrypto.randomFillSync(view), 0);
1107
1067
  }
1108
1068
  return view => (crypto.getRandomValues(view), 0);
1109
1069
  };
@@ -1165,7 +1125,13 @@ var PATH_FS = {
1165
1125
 
1166
1126
  var UTF8Decoder = new TextDecoder;
1167
1127
 
1168
- var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
1128
+ /**
1129
+ * heapOrArray is either a regular array, or a JavaScript typed array view.
1130
+ * @param {number} idx
1131
+ * @param {number=} maxBytesToRead
1132
+ * @param {boolean=} ignoreNul
1133
+ * @return {number}
1134
+ */ var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
1169
1135
  var maxIdx = idx + maxBytesToRead;
1170
1136
  if (ignoreNul) return maxIdx;
1171
1137
  // TextDecoder needs to know the byte length in advance, it doesn't stop on
@@ -1430,6 +1396,8 @@ var TTY = {
1430
1396
  }
1431
1397
  };
1432
1398
 
1399
+ /** @type {!Uint8Array} */ var HEAPU8;
1400
+
1433
1401
  var zeroMemory = (ptr, size) => HEAPU8.fill(0, ptr, ptr + size);
1434
1402
 
1435
1403
  var alignMemory = (size, alignment) => Math.ceil(size / alignment) * alignment;
@@ -1791,23 +1759,26 @@ var FS_createDataFile = (...args) => FS.createDataFile(...args);
1791
1759
 
1792
1760
  var getUniqueRunDependency = id => id;
1793
1761
 
1762
+ var dependenciesPromise = null;
1763
+
1764
+ var resolveRunDependencies = async () => dependenciesPromise;
1765
+
1794
1766
  var runDependencies = 0;
1795
1767
 
1796
- var dependenciesFulfilled = null;
1768
+ var dependenciesPromiseResolve = null;
1797
1769
 
1798
1770
  var removeRunDependency = id => {
1799
1771
  runDependencies--;
1800
1772
  Module["monitorRunDependencies"]?.(runDependencies);
1801
- if (runDependencies == 0) {
1802
- if (dependenciesFulfilled) {
1803
- var callback = dependenciesFulfilled;
1804
- dependenciesFulfilled = null;
1805
- callback();
1806
- }
1773
+ if (!runDependencies) {
1774
+ dependenciesPromiseResolve();
1807
1775
  }
1808
1776
  };
1809
1777
 
1810
1778
  var addRunDependency = id => {
1779
+ if (!runDependencies) {
1780
+ dependenciesPromise = new Promise(resolve => dependenciesPromiseResolve = resolve);
1781
+ }
1811
1782
  runDependencies++;
1812
1783
  Module["monitorRunDependencies"]?.(runDependencies);
1813
1784
  };
@@ -1941,6 +1912,53 @@ var FS = {
1941
1912
  get isDevice() {
1942
1913
  return FS.isChrdev(this.mode);
1943
1914
  }
1915
+ // The per-inode readiness wait-queue. The node carries a Set of listener
1916
+ // entries {cb}; producers (SOCKFS, PIPEFS) call notifyListeners on a
1917
+ // readiness transition, and poll()/epoll consume it. It lives on the node
1918
+ // (not the fd) so dup'd fds share one queue. Only nodes that derive real
1919
+ // readiness (sockets, pipes, and an epoll's own node) ever use this -
1920
+ // always-ready types (regular files, ttys) never register or notify.
1921
+ addListener(cb, exclusive = false) {
1922
+ var entry = {
1923
+ cb,
1924
+ exclusive
1925
+ };
1926
+ var listeners = (this.listeners ??= new Set);
1927
+ listeners.add(entry);
1928
+ return {
1929
+ listeners,
1930
+ entry
1931
+ };
1932
+ }
1933
+ notifyListeners(flags) {
1934
+ // Iterates the set without copying, which is safe ONLY under a
1935
+ // load-bearing contract that every internal listener must honour:
1936
+ // 1. A listener must not run user code synchronously (a poll waiter only
1937
+ // resolves a Promise; an epoll registration only re-lists +
1938
+ // re-notifies; the epoll callback only schedules a tick). User code
1939
+ // runs on a later tick, never inside this loop.
1940
+ // 2. A listener may delete entries only from ITS OWN waiter, never from
1941
+ // a sibling node's set that may be mid-iteration. (Deleting an entry
1942
+ // of the set being iterated here is fine - a Set tolerates removal of
1943
+ // a not-yet-visited entry mid-iteration; mutating a *different* node's
1944
+ // set is fine because that set is not being iterated.)
1945
+ // Violating either gives silently skipped wakeups that are near-impossible
1946
+ // to reproduce. Any new producer/listener must preserve it.
1947
+ if (!this.listeners) return;
1948
+ // Fire every non-exclusive listener. Among EPOLLEXCLUSIVE registrations
1949
+ // (one fd watched by several epolls) wake only one, rotating round-robin
1950
+ // per node, to avoid a thundering herd. (Only epoll registrations are ever
1951
+ // exclusive; poll waiters and a node's own consumers are not.)
1952
+ var excl;
1953
+ for (var entry of this.listeners) {
1954
+ if (entry.exclusive) (excl ||= []).push(entry); else entry.cb(flags);
1955
+ }
1956
+ if (excl) {
1957
+ var i = (this.exclTurn || 0) % excl.length;
1958
+ this.exclTurn = i + 1;
1959
+ excl[i].cb(flags);
1960
+ }
1961
+ }
1944
1962
  },
1945
1963
  lookupPath(path, opts = {}) {
1946
1964
  if (!path) {
@@ -2486,6 +2504,27 @@ var FS = {
2486
2504
  }
2487
2505
  return parent.node_ops.symlink(parent, newname, oldpath);
2488
2506
  },
2507
+ link(oldpath, newpath, flags) {
2508
+ var lookup = FS.lookupPath(newpath, {
2509
+ parent: true
2510
+ });
2511
+ var parent = lookup.node;
2512
+ if (!parent) {
2513
+ throw new FS.ErrnoError(44);
2514
+ }
2515
+ var newname = PATH.basename(newpath);
2516
+ var errCode = FS.mayCreate(parent, newname);
2517
+ if (errCode) {
2518
+ throw new FS.ErrnoError(errCode);
2519
+ }
2520
+ // Hardlinks are only supported by filesystem backends that provide a
2521
+ // `link` node op (e.g. NODERAWFS backed by the host). NODEFS omits it:
2522
+ // a host hardlink cannot be confined to the mount root.
2523
+ if (!parent.node_ops.link) {
2524
+ throw new FS.ErrnoError(34);
2525
+ }
2526
+ return parent.node_ops.link(parent, newname, oldpath, flags);
2527
+ },
2489
2528
  rename(old_path, new_path) {
2490
2529
  var old_dirname = PATH.dirname(old_path);
2491
2530
  var new_dirname = PATH.dirname(new_path);
@@ -2743,15 +2782,14 @@ var FS = {
2743
2782
  }
2744
2783
  FS.doTruncate(stream, stream.node, len);
2745
2784
  },
2746
- utime(path, atime, mtime) {
2785
+ utime(path, atime, mtime, dontFollow) {
2747
2786
  var lookup = FS.lookupPath(path, {
2748
- follow: true
2787
+ follow: !dontFollow
2749
2788
  });
2750
- var node = lookup.node;
2751
- var setattr = FS.checkOpExists(node.node_ops.setattr, 63);
2752
- setattr(node, {
2789
+ FS.doSetAttr(null, lookup.node, {
2753
2790
  atime,
2754
- mtime
2791
+ mtime,
2792
+ dontFollow
2755
2793
  });
2756
2794
  },
2757
2795
  open(path, flags, mode = 438) {
@@ -2853,6 +2891,11 @@ var FS = {
2853
2891
  }
2854
2892
  if (stream.getdents) stream.getdents = null;
2855
2893
  // free readdir state
2894
+ // The fd is going away: wake anything waiting on it (poll/epoll) with
2895
+ // POLLNVAL so a blocking wait unblocks and an epoll registration is evicted
2896
+ // on its next derive. Only sockets/pipes/epoll ever carry a wait-queue, so
2897
+ // for every other stream (incl. nodeless noderawfs stdio) this is a no-op.
2898
+ stream.node?.notifyListeners(32);
2856
2899
  try {
2857
2900
  if (stream.stream_ops.close) {
2858
2901
  stream.stream_ops.close(stream);
@@ -3320,7 +3363,7 @@ var FS = {
3320
3363
  var xhr = new XMLHttpRequest;
3321
3364
  xhr.open("HEAD", url, false);
3322
3365
  xhr.send(null);
3323
- if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) abort("Couldn't load " + url + ". Status: " + xhr.status);
3366
+ if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) abort(`Couldn't load ${url}. Status: ${xhr.status}`);
3324
3367
  var datalength = Number(xhr.getResponseHeader("Content-length"));
3325
3368
  var header;
3326
3369
  var hasByteServing = (header = xhr.getResponseHeader("Accept-Ranges")) && header === "bytes";
@@ -3335,14 +3378,14 @@ var FS = {
3335
3378
  // TODO: Use mozResponseArrayBuffer, responseStream, etc. if available.
3336
3379
  var xhr = new XMLHttpRequest;
3337
3380
  xhr.open("GET", url, false);
3338
- if (datalength !== chunkSize) xhr.setRequestHeader("Range", "bytes=" + from + "-" + to);
3381
+ if (datalength !== chunkSize) xhr.setRequestHeader("Range", `bytes=${from}-${to}`);
3339
3382
  // Some hints to the browser that we want binary data.
3340
3383
  xhr.responseType = "arraybuffer";
3341
3384
  if (xhr.overrideMimeType) {
3342
3385
  xhr.overrideMimeType("text/plain; charset=x-user-defined");
3343
3386
  }
3344
3387
  xhr.send(null);
3345
- if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) abort("Couldn't load " + url + ". Status: " + xhr.status);
3388
+ if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) abort(`Couldn't load ${url}. Status: ${xhr.status}`);
3346
3389
  if (xhr.response !== undefined) {
3347
3390
  return new Uint8Array(/** @type{Array<number>} */ (xhr.response || []));
3348
3391
  }
@@ -3484,6 +3527,8 @@ var FS = {
3484
3527
  return UTF8Decoder.decode(HEAPU8.subarray(ptr >>> 0, end >>> 0));
3485
3528
  };
3486
3529
 
3530
+ /** not-@type {!BigInt64Array} */ var HEAP64;
3531
+
3487
3532
  var SYSCALLS = {
3488
3533
  currentUmask: 18,
3489
3534
  calculateAt(dirfd, path, allowEmpty) {
@@ -3549,7 +3594,7 @@ var SYSCALLS = {
3549
3594
  // MAP_PRIVATE calls need not to be synced back to underlying fs
3550
3595
  return 0;
3551
3596
  }
3552
- var buffer = HEAPU8.slice(addr, addr + len);
3597
+ var buffer = HEAPU8.subarray(addr >>> 0, addr + len >>> 0);
3553
3598
  FS.msync(stream, buffer, offset, len, flags);
3554
3599
  },
3555
3600
  getStreamFromFD(fd) {
@@ -3612,6 +3657,8 @@ var syscallGetVarargI = () => {
3612
3657
 
3613
3658
  var syscallGetVarargP = syscallGetVarargI;
3614
3659
 
3660
+ /** @type {!Int16Array} */ var HEAP16;
3661
+
3615
3662
  function ___syscall_fcntl64(fd, cmd, varargs) {
3616
3663
  varargs >>>= 0;
3617
3664
  SYSCALLS.varargs = varargs;
@@ -3769,6 +3816,8 @@ function ___syscall_getdents64(fd, dirp, count) {
3769
3816
  }
3770
3817
  }
3771
3818
 
3819
+ var ___syscall_getuid32 = () => 0;
3820
+
3772
3821
  function ___syscall_ioctl(fd, op, varargs) {
3773
3822
  varargs >>>= 0;
3774
3823
  SYSCALLS.varargs = varargs;
@@ -4023,6 +4072,7 @@ function ___syscall_utimensat(dirfd, path, times, flags) {
4023
4072
  path >>>= 0;
4024
4073
  times >>>= 0;
4025
4074
  try {
4075
+ var nofollow = flags & 256;
4026
4076
  path = SYSCALLS.getStr(path);
4027
4077
  path = SYSCALLS.calculateAt(dirfd, path, true);
4028
4078
  var now = Date.now(), atime, mtime;
@@ -4053,7 +4103,7 @@ function ___syscall_utimensat(dirfd, path, times, flags) {
4053
4103
  // null here means UTIME_OMIT was passed. If both were set to UTIME_OMIT then
4054
4104
  // we can skip the call completely.
4055
4105
  if ((mtime ?? atime) !== null) {
4056
- FS.utime(path, atime, mtime);
4106
+ FS.utime(path, atime, mtime, nofollow);
4057
4107
  }
4058
4108
  return 0;
4059
4109
  } catch (e) {
@@ -4084,12 +4134,12 @@ var registeredTypes = {};
4084
4134
 
4085
4135
  var typeDependencies = {};
4086
4136
 
4087
- var InternalError = class InternalError extends Error {
4137
+ class InternalError extends Error {
4088
4138
  constructor(message) {
4089
4139
  super(message);
4090
4140
  this.name = "InternalError";
4091
4141
  }
4092
- };
4142
+ }
4093
4143
 
4094
4144
  var throwInternalError = message => {
4095
4145
  throw new InternalError(message);
@@ -4201,12 +4251,12 @@ var AsciiToString = ptr => {
4201
4251
  }
4202
4252
  };
4203
4253
 
4204
- var BindingError = class BindingError extends Error {
4254
+ class BindingError extends Error {
4205
4255
  constructor(message) {
4206
4256
  super(message);
4207
4257
  this.name = "BindingError";
4208
4258
  }
4209
- };
4259
+ }
4210
4260
 
4211
4261
  var throwBindingError = message => {
4212
4262
  throw new BindingError(message);
@@ -4237,6 +4287,10 @@ var throwBindingError = message => {
4237
4287
  return sharedRegisterType(rawType, registeredInstance, options);
4238
4288
  }
4239
4289
 
4290
+ /** @type {!Uint16Array} */ var HEAPU16;
4291
+
4292
+ /** not-@type {!BigUint64Array} */ var HEAPU64;
4293
+
4240
4294
  var integerReadValueFromPointer = (name, width, signed) => {
4241
4295
  // integers are quite common, so generate very specialized functions
4242
4296
  switch (width) {
@@ -5021,12 +5075,12 @@ function craftInvokerFunction(humanName, argTypes, classType, cppInvokerFunc, cp
5021
5075
  // isAsync: Optional. If true, returns an async function. Async bindings are only supported with JSPI.
5022
5076
  var argCount = argTypes.length;
5023
5077
  if (argCount < 2) {
5024
- throwBindingError("argTypes array size mismatch! Must at least get return value and 'this' types!");
5078
+ throwBindingError("argTypes array size mismatch! Must at least get return value and receiver (this) types!");
5025
5079
  }
5026
5080
  var isClassMethodFunc = (argTypes[1] !== null && classType !== null);
5027
5081
  // Free functions with signature "void function()" do not need an invoker that marshalls between wire types.
5028
5082
  // TODO: This omits argument count check - enable only at -O3 or similar.
5029
- // if (ENABLE_UNSAFE_OPTS && argCount == 2 && argTypes[0].name == "void" && !isClassMethodFunc) {
5083
+ // if (ENABLE_UNSAFE_OPTS && argCount == 2 && argTypes[0].name == 'void' && !isClassMethodFunc) {
5030
5084
  // return FUNCTION_TABLE[fn];
5031
5085
  // }
5032
5086
  // Determine if we need to use a dynamic stack to store the destructors for the function parameters.
@@ -5448,6 +5502,10 @@ function __embind_register_enum_value(rawEnumType, name, enumValue) {
5448
5502
  }
5449
5503
  }
5450
5504
 
5505
+ /** @type {!Float32Array} */ var HEAPF32;
5506
+
5507
+ /** @type {!Float64Array} */ var HEAPF64;
5508
+
5451
5509
  var floatReadValueFromPointer = (name, width) => {
5452
5510
  switch (width) {
5453
5511
  case 4:
@@ -5699,9 +5757,7 @@ var UTF16ToString = (ptr, maxBytesToRead, ignoreNul) => {
5699
5757
  return UTF16Decoder.decode(HEAPU16.subarray(idx >>> 0, endIdx >>> 0));
5700
5758
  };
5701
5759
 
5702
- var stringToUTF16 = (str, outPtr, maxBytesToWrite) => {
5703
- // Backwards compatibility: if max bytes is not specified, assume unsafe unbounded write is allowed.
5704
- maxBytesToWrite ??= 2147483647;
5760
+ var stringToUTF16 = (str, outPtr, maxBytesToWrite = 2147483647) => {
5705
5761
  if (maxBytesToWrite < 2) return 0;
5706
5762
  maxBytesToWrite -= 2;
5707
5763
  // Null terminator.
@@ -5734,10 +5790,8 @@ var UTF32ToString = (ptr, maxBytesToRead, ignoreNul) => {
5734
5790
  return str;
5735
5791
  };
5736
5792
 
5737
- var stringToUTF32 = (str, outPtr, maxBytesToWrite) => {
5793
+ var stringToUTF32 = (str, outPtr, maxBytesToWrite = 2147483647) => {
5738
5794
  outPtr >>>= 0;
5739
- // Backwards compatibility: if max bytes is not specified, assume unsafe unbounded write is allowed.
5740
- maxBytesToWrite ??= 2147483647;
5741
5795
  if (maxBytesToWrite < 4) return 0;
5742
5796
  var startPtr = outPtr;
5743
5797
  var endPtr = startPtr + maxBytesToWrite - 4;
@@ -6056,6 +6110,9 @@ function __gmtime_js(time, tmPtr) {
6056
6110
  time = bigintToI53Checked(time);
6057
6111
  tmPtr >>>= 0;
6058
6112
  var date = new Date(time * 1e3);
6113
+ if (isNaN(date.getTime())) {
6114
+ return 1;
6115
+ }
6059
6116
  HEAP32[((tmPtr) >>> 2) >>> 0] = date.getUTCSeconds();
6060
6117
  HEAP32[(((tmPtr) + (4)) >>> 2) >>> 0] = date.getUTCMinutes();
6061
6118
  HEAP32[(((tmPtr) + (8)) >>> 2) >>> 0] = date.getUTCHours();
@@ -6066,6 +6123,7 @@ function __gmtime_js(time, tmPtr) {
6066
6123
  var start = Date.UTC(date.getUTCFullYear(), 0, 1, 0, 0, 0, 0);
6067
6124
  var yday = ((date.getTime() - start) / (1e3 * 60 * 60 * 24)) | 0;
6068
6125
  HEAP32[(((tmPtr) + (28)) >>> 2) >>> 0] = yday;
6126
+ return 0;
6069
6127
  }
6070
6128
 
6071
6129
  var isLeapYear = year => year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
@@ -6086,6 +6144,9 @@ function __localtime_js(time, tmPtr) {
6086
6144
  time = bigintToI53Checked(time);
6087
6145
  tmPtr >>>= 0;
6088
6146
  var date = new Date(time * 1e3);
6147
+ if (isNaN(date.getTime())) {
6148
+ return 1;
6149
+ }
6089
6150
  HEAP32[((tmPtr) >>> 2) >>> 0] = date.getSeconds();
6090
6151
  HEAP32[(((tmPtr) + (4)) >>> 2) >>> 0] = date.getMinutes();
6091
6152
  HEAP32[(((tmPtr) + (8)) >>> 2) >>> 0] = date.getHours();
@@ -6102,6 +6163,7 @@ function __localtime_js(time, tmPtr) {
6102
6163
  var winterOffset = start.getTimezoneOffset();
6103
6164
  var dst = (summerOffset != winterOffset && date.getTimezoneOffset() == Math.min(winterOffset, summerOffset)) | 0;
6104
6165
  HEAP32[(((tmPtr) + (32)) >>> 2) >>> 0] = dst;
6166
+ return 0;
6105
6167
  }
6106
6168
 
6107
6169
  var __mktime_js = function(tmPtr) {
@@ -6123,13 +6185,17 @@ var __mktime_js = function(tmPtr) {
6123
6185
  // DST is in December in South
6124
6186
  if (dst < 0) {
6125
6187
  // Attention: some regions don't have DST at all.
6126
- HEAP32[(((tmPtr) + (32)) >>> 2) >>> 0] = Number(summerOffset != winterOffset && dstOffset == guessedOffset);
6188
+ dst = Number(summerOffset != winterOffset && dstOffset == guessedOffset);
6127
6189
  } else if ((dst > 0) != (dstOffset == guessedOffset)) {
6128
6190
  var nonDstOffset = Math.max(winterOffset, summerOffset);
6129
6191
  var trueOffset = dst > 0 ? dstOffset : nonDstOffset;
6130
6192
  // Don't try setMinutes(date.getMinutes() + ...) -- it's messed up.
6131
6193
  date.setTime(date.getTime() + (trueOffset - guessedOffset) * 6e4);
6194
+ if (isNaN(date.getTime())) {
6195
+ return -1;
6196
+ }
6132
6197
  }
6198
+ HEAP32[(((tmPtr) + (32)) >>> 2) >>> 0] = dst;
6133
6199
  HEAP32[(((tmPtr) + (24)) >>> 2) >>> 0] = date.getDay();
6134
6200
  var yday = ydayFromDate(date) | 0;
6135
6201
  HEAP32[(((tmPtr) + (28)) >>> 2) >>> 0] = yday;
@@ -6465,7 +6531,7 @@ function _emscripten_stack_unwind_buffer(addr, buffer, count) {
6465
6531
  ++offset;
6466
6532
  }
6467
6533
  for (var i = 0; i < count && stack[i + offset]; ++i) {
6468
- HEAP32[(((buffer) + (i * 4)) >>> 2) >>> 0] = convertFrameToPC(stack[i + offset]);
6534
+ HEAPU32[(((buffer) + (i * 4)) >>> 2) >>> 0] = convertFrameToPC(stack[i + offset]);
6469
6535
  }
6470
6536
  return i;
6471
6537
  }
@@ -6949,6 +7015,28 @@ var WebGPU = {
6949
7015
  HEAP32[(((infoStruct) + (40)) >>> 2) >>> 0] = adapterType;
6950
7016
  HEAPU32[(((infoStruct) + (44)) >>> 2) >>> 0] = 0;
6951
7017
  HEAPU32[(((infoStruct) + (48)) >>> 2) >>> 0] = 0;
7018
+ WebGPU.iterateExtensions(infoStruct, {
7019
+ 327739: ext => {
7020
+ let configCount = 0;
7021
+ let configsPtr = 0;
7022
+ if (info.subgroupMatrixConfigs) {
7023
+ configCount = info.subgroupMatrixConfigs.length;
7024
+ configsPtr = _malloc(configCount * 20);
7025
+ for (const [i, cfg] of info.subgroupMatrixConfigs.entries()) {
7026
+ const ptr = configsPtr + i * 20;
7027
+ const componentType = WebGPU.SubgroupMatrixComponentType.indexOf(cfg.componentType);
7028
+ const resultComponentType = WebGPU.SubgroupMatrixComponentType.indexOf(cfg.resultComponentType);
7029
+ HEAP32[((ptr) >>> 2) >>> 0] = componentType;
7030
+ HEAP32[(((ptr) + (4)) >>> 2) >>> 0] = resultComponentType;
7031
+ HEAPU32[(((ptr) + (8)) >>> 2) >>> 0] = cfg.M;
7032
+ HEAPU32[(((ptr) + (12)) >>> 2) >>> 0] = cfg.N;
7033
+ HEAPU32[(((ptr) + (16)) >>> 2) >>> 0] = cfg.K;
7034
+ }
7035
+ }
7036
+ HEAPU32[(((ext) + (12)) >>> 2) >>> 0] = configsPtr;
7037
+ HEAPU32[(((ext) + (8)) >>> 2) >>> 0] = configCount;
7038
+ }
7039
+ });
6952
7040
  },
6953
7041
  AddressMode: [ , "clamp-to-edge", "repeat", "mirror-repeat" ],
6954
7042
  BlendFactor: [ , "zero", "one", "src", "one-minus-src", "src-alpha", "one-minus-src-alpha", "dst", "one-minus-dst", "dst-alpha", "one-minus-dst-alpha", "src-alpha-saturated", "constant", "one-minus-constant", "src1", "one-minus-src1", "src1-alpha", "one-minus-src1-alpha" ],
@@ -6987,7 +7075,8 @@ var WebGPU = {
6987
7075
  22: "texture-component-swizzle",
6988
7076
  23: "subgroup-size-control",
6989
7077
  327692: "chromium-experimental-unorm16-texture-formats",
6990
- 327729: "chromium-experimental-multi-draw-indirect"
7078
+ 327729: "chromium-experimental-multi-draw-indirect",
7079
+ 327732: "chromium-experimental-subgroup-matrix"
6991
7080
  },
6992
7081
  FilterMode: [ , "nearest", "linear" ],
6993
7082
  FrontFace: [ , "ccw", "cw" ],
@@ -7005,6 +7094,7 @@ var WebGPU = {
7005
7094
  StencilOperation: [ , "keep", "zero", "replace", "invert", "increment-clamp", "decrement-clamp", "increment-wrap", "decrement-wrap" ],
7006
7095
  StorageTextureAccess: [ , , "write-only", "read-only", "read-write" ],
7007
7096
  StoreOp: [ , "store", "discard" ],
7097
+ SubgroupMatrixComponentType: [ , "f32", "f16", "u32", "i32", "u8", "i8" ],
7008
7098
  SurfaceGetCurrentTextureStatus: [ , "success-optimal", "success-suboptimal", "timeout", "outdated", "lost", "error" ],
7009
7099
  TextureAspect: [ , "all", "stencil-only", "depth-only" ],
7010
7100
  TextureDimension: [ , "1d", "2d", "3d" ],
@@ -7014,7 +7104,7 @@ var WebGPU = {
7014
7104
  ToneMappingMode: [ , "standard", "extended" ],
7015
7105
  VertexFormat: [ , "uint8", "uint8x2", "uint8x4", "sint8", "sint8x2", "sint8x4", "unorm8", "unorm8x2", "unorm8x4", "snorm8", "snorm8x2", "snorm8x4", "uint16", "uint16x2", "uint16x4", "sint16", "sint16x2", "sint16x4", "unorm16", "unorm16x2", "unorm16x4", "snorm16", "snorm16x2", "snorm16x4", "float16", "float16x2", "float16x4", "float32", "float32x2", "float32x3", "float32x4", "uint32", "uint32x2", "uint32x3", "uint32x4", "sint32", "sint32x2", "sint32x3", "sint32x4", "unorm10-10-10-2", "unorm8x4-bgra", "snorm10-10-10-2" ],
7016
7106
  VertexStepMode: [ , "vertex", "instance" ],
7017
- WGSLLanguageFeatureName: [ , "readonly_and_readwrite_storage_textures", "packed_4x8_integer_dot_product", "unrestricted_pointer_parameters", "pointer_composite_access", "uniform_buffer_standard_layout", "subgroup_id", "texture_and_sampler_let", "subgroup_uniformity", "texture_formats_tier1", "linear_indexing", "immediate_address_space" ]
7107
+ WGSLLanguageFeatureName: [ , "readonly_and_readwrite_storage_textures", "packed_4x8_integer_dot_product", "unrestricted_pointer_parameters", "pointer_composite_access", "uniform_buffer_standard_layout", "subgroup_id", "texture_and_sampler_let", "subgroup_uniformity", "texture_formats_tier1", "linear_indexing", "immediate_address_space", "buffer_view", "swizzle_assignment", "fragment_depth" ]
7018
7108
  };
7019
7109
 
7020
7110
  function _emscripten_webgpu_get_device() {
@@ -7342,7 +7432,17 @@ function _fd_close(fd) {
7342
7432
  var ptr = HEAPU32[((iov) >>> 2) >>> 0];
7343
7433
  var len = HEAPU32[(((iov) + (4)) >>> 2) >>> 0];
7344
7434
  iov += 8;
7345
- var curr = FS.read(stream, HEAP8, ptr, len, offset);
7435
+ try {
7436
+ var curr = FS.read(stream, HEAP8, ptr, len, offset);
7437
+ } catch (e) {
7438
+ // On a non-blocking stream a subsequent read may would-block after we
7439
+ // already gathered data. POSIX readv is a single gather-read: return
7440
+ // what we have rather than failing the whole call.
7441
+ if (ret > 0 && e instanceof FS.ErrnoError && (e.errno == 6 || e.errno == 6)) {
7442
+ break;
7443
+ }
7444
+ throw e;
7445
+ }
7346
7446
  if (curr < 0) return -1;
7347
7447
  ret += curr;
7348
7448
  if (curr < len) break;
@@ -7404,23 +7504,27 @@ function _fd_seek(fd, offset, whence, newOffset) {
7404
7504
  }
7405
7505
 
7406
7506
  /** @param {number=} offset */ var doWritev = (stream, iov, iovcnt, offset) => {
7407
- var ret = 0;
7408
- for (var i = 0; i < iovcnt; i++) {
7507
+ // Gather all iovecs into one contiguous buffer and issue a single
7508
+ // FS.write, matching POSIX writev's single gather-write semantics (as
7509
+ // __syscall_sendmsg already does). Per-iovec writes fragment a stream
7510
+ // socket send into multiple segments, breaking stream byte semantics.
7511
+ if (iovcnt == 1) {
7512
+ // Single iovec: write directly from HEAP8, no gather buffer needed.
7513
+ return FS.write(stream, HEAP8, HEAPU32[((iov) >>> 2) >>> 0], HEAPU32[(((iov) + (4)) >>> 2) >>> 0], offset);
7514
+ }
7515
+ var total = 0;
7516
+ for (var i = 0, p = iov; i < iovcnt; i++, p += 8) {
7517
+ total += HEAPU32[(((p) + (4)) >>> 2) >>> 0];
7518
+ }
7519
+ var view = new Uint8Array(total);
7520
+ var voff = 0;
7521
+ for (var i = 0; i < iovcnt; i++, iov += 8) {
7409
7522
  var ptr = HEAPU32[((iov) >>> 2) >>> 0];
7410
7523
  var len = HEAPU32[(((iov) + (4)) >>> 2) >>> 0];
7411
- iov += 8;
7412
- var curr = FS.write(stream, HEAP8, ptr, len, offset);
7413
- if (curr < 0) return -1;
7414
- ret += curr;
7415
- if (curr < len) {
7416
- // No more space to write.
7417
- break;
7418
- }
7419
- if (typeof offset != "undefined") {
7420
- offset += curr;
7421
- }
7524
+ view.set(HEAPU8.subarray(ptr >>> 0, ptr + len >>> 0), voff);
7525
+ voff += len;
7422
7526
  }
7423
- return ret;
7527
+ return FS.write(stream, view, 0, total, offset);
7424
7528
  };
7425
7529
 
7426
7530
  function _fd_write(fd, iov, iovcnt, pnum) {
@@ -7588,6 +7692,14 @@ function _wgpuComputePassEncoderSetPipeline(passPtr, pipelinePtr) {
7588
7692
  pass.setPipeline(pipeline);
7589
7693
  }
7590
7694
 
7695
+ function _wgpuComputePipelineGetBindGroupLayout(pipelinePtr, groupIndex) {
7696
+ pipelinePtr >>>= 0;
7697
+ var pipeline = WebGPU.getJsObject(pipelinePtr);
7698
+ var ptr = _emwgpuCreateBindGroupLayout(0);
7699
+ WebGPU.Internals.jsObjectInsert(ptr, pipeline.getBindGroupLayout(groupIndex));
7700
+ return ptr;
7701
+ }
7702
+
7591
7703
  var _wgpuDeviceCreateBindGroup = function(devicePtr, descriptor) {
7592
7704
  devicePtr >>>= 0;
7593
7705
  descriptor >>>= 0;
@@ -7944,18 +8056,19 @@ init_RegisteredPointer();
7944
8056
  // but before the wasm module is created.
7945
8057
  {
7946
8058
  // Begin ATMODULES hooks
7947
- if (Module["preloadPlugins"]) preloadPlugins = Module["preloadPlugins"];
7948
8059
  if (Module["noExitRuntime"]) noExitRuntime = Module["noExitRuntime"];
7949
8060
  if (Module["print"]) out = Module["print"];
7950
8061
  if (Module["printErr"]) err = Module["printErr"];
7951
- if (Module["wasmBinary"]) wasmBinary = Module["wasmBinary"];
7952
8062
  // End ATMODULES hooks
7953
8063
  if (Module["arguments"]) programArgs = Module["arguments"];
7954
8064
  if (Module["thisProgram"]) thisProgram = Module["thisProgram"];
7955
- if (Module["preInit"]) {
7956
- if (typeof Module["preInit"] == "function") Module["preInit"] = [ Module["preInit"] ];
7957
- while (Module["preInit"].length > 0) {
7958
- Module["preInit"].shift()();
8065
+ var preInit = Module["preInit"];
8066
+ if (preInit) {
8067
+ if (typeof preInit == "function") Module["preInit"] = preInit = [ preInit ];
8068
+ // Written as a loop so that preInit functions that themselves add more
8069
+ // preInit functions. Is this actually needed?
8070
+ while (preInit.length > 0) {
8071
+ preInit.shift()();
7959
8072
  }
7960
8073
  }
7961
8074
  }
@@ -7984,8 +8097,8 @@ Module["FS_createLazyFile"] = FS_createLazyFile;
7984
8097
  // End JS library exports
7985
8098
  // end include: postlibrary.js
7986
8099
  var ASM_CONSTS = {
7987
- 2207593: () => !!Module["preinitializedWebGPUDevice"],
7988
- 2207644: $0 => {
8100
+ 2287801: () => !!Module["preinitializedWebGPUDevice"],
8101
+ 2287852: $0 => {
7989
8102
  const device = WebGPU.getJsObject($0);
7990
8103
  return device.features.has("subgroups");
7991
8104
  }
@@ -8085,12 +8198,19 @@ function __asyncjs__CallStreamWeightsOnWeb(tfl_ids, wgpu_buffers, offsets, lengt
8085
8198
  console.error("Stream weights callback is not registered or is not a function");
8086
8199
  return 1;
8087
8200
  }
8088
- const tflIdsArray = new Int32Array(Module.HEAP32.buffer, tfl_ids, count);
8089
- const wgpuBuffersArray = new Uint32Array(Module.HEAPU32.buffer, wgpu_buffers, count);
8090
- const offsetsArray = new Float64Array(Module.HEAPF64.buffer, offsets, count);
8091
- const lengthsArray = new Float64Array(Module.HEAPF64.buffer, lengths, count);
8201
+ const view = new DataView(Module.HEAPU8.buffer);
8202
+ const tflIdsArray = new Int32Array(count);
8203
+ const wgpuBuffersArray = new Uint32Array(count);
8204
+ const offsetsArray = new Float64Array(count);
8205
+ const lengthsArray = new Float64Array(count);
8206
+ for (let i = 0; i < count; i++) {
8207
+ tflIdsArray[i] = view.getInt32(tfl_ids + i * 4, true);
8208
+ wgpuBuffersArray[i] = view.getUint32(wgpu_buffers + i * 4, true);
8209
+ offsetsArray[i] = view.getFloat64(offsets + i * 8, true);
8210
+ lengthsArray[i] = view.getFloat64(lengths + i * 8, true);
8211
+ }
8092
8212
  try {
8093
- await callback(new Int32Array(tflIdsArray), new Uint32Array(wgpuBuffersArray), new Float64Array(offsetsArray), new Float64Array(lengthsArray));
8213
+ await callback(tflIdsArray, wgpuBuffersArray, offsetsArray, lengthsArray);
8094
8214
  } catch (e) {
8095
8215
  console.error("Error in streamWeightsOnWeb:", e);
8096
8216
  return 1;
@@ -8214,6 +8334,7 @@ var wasmImports = {
8214
8334
  /** @export */ __syscall_ftruncate64: ___syscall_ftruncate64,
8215
8335
  /** @export */ __syscall_getcwd: ___syscall_getcwd,
8216
8336
  /** @export */ __syscall_getdents64: ___syscall_getdents64,
8337
+ /** @export */ __syscall_getuid32: ___syscall_getuid32,
8217
8338
  /** @export */ __syscall_ioctl: ___syscall_ioctl,
8218
8339
  /** @export */ __syscall_lstat64: ___syscall_lstat64,
8219
8340
  /** @export */ __syscall_mkdirat: ___syscall_mkdirat,
@@ -8315,6 +8436,7 @@ var wasmImports = {
8315
8436
  /** @export */ wgpuComputePassEncoderEnd: _wgpuComputePassEncoderEnd,
8316
8437
  /** @export */ wgpuComputePassEncoderSetBindGroup: _wgpuComputePassEncoderSetBindGroup,
8317
8438
  /** @export */ wgpuComputePassEncoderSetPipeline: _wgpuComputePassEncoderSetPipeline,
8439
+ /** @export */ wgpuComputePipelineGetBindGroupLayout: _wgpuComputePipelineGetBindGroupLayout,
8318
8440
  /** @export */ wgpuDeviceCreateBindGroup: _wgpuDeviceCreateBindGroup,
8319
8441
  /** @export */ wgpuDeviceCreateBindGroupLayout: _wgpuDeviceCreateBindGroupLayout,
8320
8442
  /** @export */ wgpuDeviceCreateCommandEncoder: _wgpuDeviceCreateCommandEncoder,
@@ -8357,37 +8479,22 @@ function applySignatureConversions(wasmExports) {
8357
8479
  // include: postamble.js
8358
8480
  // === Auto-generated postamble setup entry stuff ===
8359
8481
  async function run() {
8360
- if (runDependencies > 0) {
8361
- await new Promise(resolve => dependenciesFulfilled = resolve);
8362
- }
8363
8482
  preRun();
8364
- // a preRun added a dependency, run will be called later
8365
- if (runDependencies > 0) {
8366
- await new Promise(resolve => dependenciesFulfilled = resolve);
8367
- }
8368
- async function doRun() {
8369
- // run may have just been called through dependencies being fulfilled just in this very frame,
8370
- // or while the async setStatus time below was happening
8371
- Module["calledRun"] = true;
8372
- if (ABORT) return;
8373
- initRuntime();
8374
- Module["onRuntimeInitialized"]?.();
8375
- postRun();
8376
- }
8377
- if (Module["setStatus"]) {
8378
- Module["setStatus"]("Running...");
8379
- // Yield the main thread to allow the browser to paint "Running...", then clear
8380
- // the status text after the synchronous doRun() completes.
8381
- await new Promise(resolve => {
8382
- setTimeout(() => {
8383
- setTimeout(() => Module["setStatus"](""), 1);
8384
- doRun();
8385
- resolve();
8386
- }, 1);
8387
- });
8388
- } else {
8389
- doRun();
8390
- }
8483
+ if (runDependencies) {
8484
+ await resolveRunDependencies();
8485
+ }
8486
+ var setStatus = Module["setStatus"];
8487
+ if (setStatus) {
8488
+ setStatus("Running...");
8489
+ // Yield to the event loop to allow the browser to paint "Running..."
8490
+ await new Promise(resolve => setTimeout(resolve, 1));
8491
+ // Then we want to clear the status text, but only after the rest of this function runs.
8492
+ setTimeout(setStatus, 1, "");
8493
+ }
8494
+ if (ABORT) return;
8495
+ initRuntime();
8496
+ Module["onRuntimeInitialized"]?.();
8497
+ postRun();
8391
8498
  }
8392
8499
 
8393
8500
  var wasmExports;