ziex 0.1.0-dev.1458 → 0.1.0-dev.1466

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/wasm/index.js CHANGED
@@ -1,3 +1,28 @@
1
+ // src/wasm/constants.ts
2
+ var DOM_CMD_HEADER_SIZE = 8;
3
+ var DOM_CMD_RECORD_SIZE = 24;
4
+ var DomOp_CreateElement = 1;
5
+ var DomOp_CreateText = 2;
6
+ var DomOp_HydrateInsert = 3;
7
+ var DomOp_SetAttr = 4;
8
+ var DomOp_SetProp = 5;
9
+ var DomOp_RemoveAttr = 6;
10
+ var DomOp_SetNodeValue = 7;
11
+ var DomOp_SetInnerHtml = 8;
12
+ var DomOp_AppendChild = 9;
13
+ var DomOp_InsertBefore = 10;
14
+ var DomOp_RemoveChild = 11;
15
+ var DomOp_ReplaceChild = 12;
16
+ var CallbackType_Event = 0;
17
+ var CallbackType_FetchSuccess = 1;
18
+ var CallbackType_FetchError = 2;
19
+ var CallbackType_Timeout = 3;
20
+ var CallbackType_Interval = 4;
21
+ var CallbackType_WebSocketOpen = 5;
22
+ var CallbackType_WebSocketMessage = 6;
23
+ var CallbackType_WebSocketError = 7;
24
+ var CallbackType_WebSocketClose = 8;
25
+
1
26
  // ../../vendor/jsz/js/src/zigjs.ts
2
27
  var NAN_PREFIX = 2146959360;
3
28
  var predefined = {
@@ -314,15 +339,6 @@ function createFetchImports(getMemory) {
314
339
  }
315
340
 
316
341
  // src/wasm/core.ts
317
- var CallbackType_Event = 0;
318
- var CallbackType_FetchSuccess = 1;
319
- var CallbackType_FetchError = 2;
320
- var CallbackType_Timeout = 3;
321
- var CallbackType_Interval = 4;
322
- var CallbackType_WebSocketOpen = 5;
323
- var CallbackType_WebSocketMessage = 6;
324
- var CallbackType_WebSocketError = 7;
325
- var CallbackType_WebSocketClose = 8;
326
342
  var jsz = new ZigJS();
327
343
  var tempRefBuffer = new ArrayBuffer(8);
328
344
  var tempRefView = new DataView(tempRefBuffer);
@@ -391,30 +407,26 @@ function invokeWasmExport(fn, ...args) {
391
407
  var ZxBridgeCore = class _ZxBridgeCore {
392
408
  #intervals = /* @__PURE__ */ new Map();
393
409
  #handler;
394
- #fetchCompleteHandler;
395
410
  constructor(exports) {
396
411
  this._alloc = exports.__zx_alloc;
397
412
  this.#handler = wrapPromisingExport(exports.__zx_cb);
398
- const fetchCompleteHandler = wrapPromisingExport(exports.__zx_fetch_complete);
399
- if (!fetchCompleteHandler) {
400
- throw new Error("__zx_fetch_complete not exported from WASM");
413
+ if (!this.#handler) {
414
+ console.warn("__zx_cb not exported from WASM");
401
415
  }
402
- this.#fetchCompleteHandler = fetchCompleteHandler;
403
416
  if (exports.memory) jsz.memory = exports.memory;
404
417
  }
405
418
  /** Invoke the unified callback handler */
406
- #invoke(type, id, data) {
419
+ _invoke(type, id, a = 0n, b = 0n, c = 0n) {
407
420
  const handler = this.#handler;
408
421
  if (!handler) {
409
422
  console.warn("__zx_cb not exported from WASM");
410
423
  return;
411
424
  }
412
- const dataRef = storeValueGetRef(data);
413
- invokeWasmExport(handler, type, id, dataRef);
425
+ invokeWasmExport(handler, type, id, a, b, c);
414
426
  }
415
427
  /**
416
428
  * Async fetch with full options support.
417
- * Calls __zx_fetch_complete when done.
429
+ * Completes via `__zx_cb(fetch_success|fetch_error, ...)`.
418
430
  */
419
431
  fetchAsync(urlPtr, urlLen, methodPtr, methodLen, headersPtr, headersLen, bodyPtr, bodyLen, timeoutMs, fetchId) {
420
432
  const url = readString(urlPtr, urlLen);
@@ -453,23 +465,23 @@ var ZxBridgeCore = class _ZxBridgeCore {
453
465
  }
454
466
  /** Notify WASM that a fetch completed. `body` is raw bytes on success, text on error. */
455
467
  _notifyFetchComplete(fetchId, statusCode, body, isError) {
456
- const handler = this.#fetchCompleteHandler;
457
468
  const encoded = typeof body === "string" ? textEncoder.encode(body) : body;
458
469
  const ptr = this._alloc(encoded.length) >>> 0;
459
470
  if (!ptr && encoded.length > 0) return;
460
471
  writeBytes(ptr, encoded);
461
- invokeWasmExport(handler, fetchId, statusCode, ptr, encoded.length, isError ? 1 : 0);
472
+ const type = isError ? CallbackType_FetchError : CallbackType_FetchSuccess;
473
+ this._invoke(type, fetchId, BigInt(statusCode), BigInt(ptr), BigInt(encoded.length));
462
474
  }
463
475
  /** Set a timeout and callback when it fires */
464
476
  setTimeout(callbackId, delayMs) {
465
477
  setTimeout(() => {
466
- this.#invoke(3, callbackId, null);
478
+ this._invoke(CallbackType_Timeout, callbackId);
467
479
  }, delayMs);
468
480
  }
469
481
  /** Set an interval and callback each time it fires */
470
482
  setInterval(callbackId, intervalMs) {
471
483
  const handle = setInterval(() => {
472
- this.#invoke(4, callbackId, null);
484
+ this._invoke(CallbackType_Interval, callbackId);
473
485
  }, intervalMs);
474
486
  this.#intervals.set(callbackId, handle);
475
487
  }
@@ -584,251 +596,598 @@ function bindWasmAlloc(allocRef, exports) {
584
596
  allocRef[0] = exports.__zx_alloc;
585
597
  }
586
598
 
587
- // src/runtime/kv/extern.ts
588
- function putOptions(ttlSeconds) {
589
- if (ttlSeconds < 60) return void 0;
590
- return { expirationTtl: ttlSeconds };
591
- }
592
- function isSyncKVNamespace(binding) {
593
- const candidate = binding;
594
- return typeof candidate.getSync === "function" && typeof candidate.putSync === "function" && typeof candidate.deleteSync === "function" && typeof candidate.listSync === "function";
595
- }
596
- function createKVImports(bindings, getMemory, allocRef) {
597
- const encoder2 = new TextEncoder();
598
- const decoder2 = new TextDecoder();
599
- function readStr(ptr, len) {
600
- return decoder2.decode(new Uint8Array(getMemory().buffer, ptr, len));
601
- }
602
- function binding(ns) {
603
- return bindings[ns] ?? bindings["default"] ?? null;
604
- }
605
- const Suspending = WebAssembly.Suspending;
606
- if (typeof Suspending !== "function") {
607
- let syncBinding2 = function(ns) {
608
- const candidate = binding(ns);
609
- return candidate && isSyncKVNamespace(candidate) ? candidate : null;
610
- };
611
- var syncBinding = syncBinding2;
612
- return {
613
- kv_get: (ns_ptr, ns_len, key_ptr, key_len, out_ptr) => {
614
- const b = syncBinding2(readStr(ns_ptr, ns_len));
615
- if (!b) return -1;
616
- const value = b.getSync(readStr(key_ptr, key_len));
617
- if (value === null) return -1;
618
- return writeBytesOut(getMemory, allocRef, out_ptr, encoder2.encode(value));
619
- },
620
- kv_put: (ns_ptr, ns_len, key_ptr, key_len, val_ptr, val_len, ttl_seconds) => {
621
- const b = syncBinding2(readStr(ns_ptr, ns_len));
622
- if (!b) return 0;
623
- b.putSync(readStr(key_ptr, key_len), readStr(val_ptr, val_len), putOptions(ttl_seconds));
624
- return 0;
625
- },
626
- kv_delete: (ns_ptr, ns_len, key_ptr, key_len) => {
627
- const b = syncBinding2(readStr(ns_ptr, ns_len));
628
- if (!b) return 0;
629
- b.deleteSync(readStr(key_ptr, key_len));
630
- return 0;
631
- },
632
- kv_list: (ns_ptr, ns_len, pfx_ptr, pfx_len, out_ptr) => {
633
- const b = syncBinding2(readStr(ns_ptr, ns_len));
634
- if (!b) return writeJsonOut(getMemory, allocRef, out_ptr, []);
635
- const prefix = readStr(pfx_ptr, pfx_len);
636
- const result = b.listSync(prefix.length > 0 ? { prefix } : void 0);
637
- return writeJsonOut(getMemory, allocRef, out_ptr, result.keys.map((k) => k.name));
638
- }
639
- };
640
- }
641
- return {
642
- kv_get: new Suspending(async (ns_ptr, ns_len, key_ptr, key_len, out_ptr) => {
643
- const b = binding(readStr(ns_ptr, ns_len));
644
- if (!b) return -1;
645
- const value = await b.get(readStr(key_ptr, key_len));
646
- if (value === null) return -1;
647
- return writeBytesOut(getMemory, allocRef, out_ptr, encoder2.encode(value));
648
- }),
649
- kv_put: new Suspending(async (ns_ptr, ns_len, key_ptr, key_len, val_ptr, val_len, ttl_seconds) => {
650
- const b = binding(readStr(ns_ptr, ns_len));
651
- if (!b) return -1;
652
- await b.put(readStr(key_ptr, key_len), readStr(val_ptr, val_len), putOptions(ttl_seconds));
653
- return 0;
654
- }),
655
- kv_delete: new Suspending(async (ns_ptr, ns_len, key_ptr, key_len) => {
656
- const b = binding(readStr(ns_ptr, ns_len));
657
- if (!b) return -1;
658
- await b.delete(readStr(key_ptr, key_len));
659
- return 0;
660
- }),
661
- kv_list: new Suspending(async (ns_ptr, ns_len, prefix_ptr, prefix_len, out_ptr) => {
662
- const b = binding(readStr(ns_ptr, ns_len));
663
- if (!b) return writeJsonOut(getMemory, allocRef, out_ptr, []);
664
- const prefix = readStr(prefix_ptr, prefix_len);
665
- const result = await b.list(prefix.length > 0 ? { prefix } : void 0);
666
- const names = result.keys.map((k) => k.name);
667
- if (names.length === 0) {
668
- new DataView(getMemory().buffer).setUint32(out_ptr, 0, true);
669
- return 0;
670
- }
671
- return writeJsonOut(getMemory, allocRef, out_ptr, names);
672
- })
673
- };
674
- }
675
-
676
- // src/runtime/kv/localstorage.ts
677
- function getLocalStorage() {
678
- if (typeof localStorage === "undefined") {
679
- throw new Error("localStorage is not available in this environment");
680
- }
681
- return localStorage;
682
- }
683
- function createLocalStorageKV(options = {}) {
684
- const storage = getLocalStorage();
685
- const namespace = options.namespace ?? "default";
686
- const storagePrefix = options.storagePrefix ?? "ziex-kv";
687
- const scopedKey = (key) => `${storagePrefix}:${namespace}:${key}`;
688
- const namespacePrefix = scopedKey("");
689
- return {
690
- getSync(key) {
691
- return storage.getItem(scopedKey(key));
692
- },
693
- async get(key) {
694
- return this.getSync(key);
695
- },
696
- putSync(key, value) {
697
- storage.setItem(scopedKey(key), value);
698
- },
699
- async put(key, value) {
700
- this.putSync(key, value);
701
- },
702
- deleteSync(key) {
703
- storage.removeItem(scopedKey(key));
704
- },
705
- async delete(key) {
706
- this.deleteSync(key);
707
- },
708
- listSync(options2) {
709
- const prefix = namespacePrefix + (options2?.prefix ?? "");
710
- const keys = [];
711
- for (let i = 0; i < storage.length; i += 1) {
712
- const key = storage.key(i);
713
- if (!key || !key.startsWith(prefix)) continue;
714
- keys.push({ name: key.slice(namespacePrefix.length) });
715
- }
716
- return { keys };
717
- },
718
- async list(options2) {
719
- return this.listSync(options2);
720
- }
721
- };
722
- }
723
-
724
- // src/runtime/kv/indexdb.ts
725
- function getIndexedDb() {
726
- if (typeof indexedDB === "undefined") {
727
- throw new Error("IndexedDB is not available in this environment");
728
- }
729
- return indexedDB;
730
- }
731
- function requestToPromise(request) {
732
- return new Promise((resolve, reject) => {
733
- request.onsuccess = () => resolve(request.result);
734
- request.onerror = () => reject(request.error ?? new Error("IndexedDB request failed"));
735
- });
736
- }
737
- function transactionToPromise(transaction) {
738
- return new Promise((resolve, reject) => {
739
- transaction.oncomplete = () => resolve();
740
- transaction.onabort = () => reject(transaction.error ?? new Error("IndexedDB transaction aborted"));
741
- transaction.onerror = () => reject(transaction.error ?? new Error("IndexedDB transaction failed"));
742
- });
743
- }
744
- function createIndexedDbKV(options = {}) {
745
- const databaseName = options.databaseName ?? "ziex-kv";
746
- const storeName = options.storeName ?? "kv";
747
- const namespace = options.namespace ?? "default";
748
- const dbPromise = new Promise((resolve, reject) => {
749
- const request = getIndexedDb().open(databaseName, 1);
750
- request.onupgradeneeded = () => {
751
- const db = request.result;
752
- if (!db.objectStoreNames.contains(storeName)) {
753
- db.createObjectStore(storeName);
754
- }
755
- };
756
- request.onsuccess = () => resolve(request.result);
757
- request.onerror = () => reject(request.error ?? new Error("Failed to open IndexedDB"));
758
- });
759
- const scopedKey = (key) => `${namespace}:${key}`;
760
- return {
761
- async get(key) {
762
- const db = await dbPromise;
763
- const tx = db.transaction(storeName, "readonly");
764
- const store = tx.objectStore(storeName);
765
- const value = await requestToPromise(store.get(scopedKey(key)));
766
- await transactionToPromise(tx);
767
- return typeof value === "string" ? value : null;
768
- },
769
- async put(key, value) {
770
- const db = await dbPromise;
771
- const tx = db.transaction(storeName, "readwrite");
772
- tx.objectStore(storeName).put(value, scopedKey(key));
773
- await transactionToPromise(tx);
774
- },
775
- async delete(key) {
776
- const db = await dbPromise;
777
- const tx = db.transaction(storeName, "readwrite");
778
- tx.objectStore(storeName).delete(scopedKey(key));
779
- await transactionToPromise(tx);
780
- },
781
- async list(options2) {
782
- const db = await dbPromise;
783
- const tx = db.transaction(storeName, "readonly");
784
- const store = tx.objectStore(storeName);
785
- const keys = await requestToPromise(store.getAllKeys());
786
- await transactionToPromise(tx);
787
- const prefix = scopedKey(options2?.prefix ?? "");
788
- return {
789
- keys: keys.filter((key) => typeof key === "string" && key.startsWith(prefix)).map((key) => ({ name: key.slice(namespace.length + 1) }))
790
- };
791
- }
792
- };
793
- }
794
-
795
- // src/runtime/kv.ts
796
- function hasJSPI() {
797
- return typeof WebAssembly.Suspending === "function" && typeof WebAssembly.promising === "function";
798
- }
799
- function createBrowserKVBindings(options = {}) {
800
- const namespace = options.namespace ?? "default";
801
- return {
802
- [namespace]: hasJSPI() ? createIndexedDbKV(options) : createLocalStorageKV(options)
803
- };
804
- }
805
-
806
- // src/wasm/index.ts
807
- var ZxBridge = class extends ZxBridgeCore {
808
- #websockets = /* @__PURE__ */ new Map();
809
- #wsOnOpenHandler;
810
- #wsOnMessageHandler;
811
- #wsOnErrorHandler;
812
- #wsOnCloseHandler;
813
- #eventbridge;
814
- #eventbridgeAsync;
815
- constructor(exports) {
816
- super(exports);
817
- this.#wsOnOpenHandler = wrapPromisingExport(exports.__zx_ws_onopen);
818
- this.#wsOnMessageHandler = wrapPromisingExport(exports.__zx_ws_onmessage);
819
- this.#wsOnErrorHandler = wrapPromisingExport(exports.__zx_ws_onerror);
820
- this.#wsOnCloseHandler = wrapPromisingExport(exports.__zx_ws_onclose);
821
- this.#eventbridge = exports.__zx_eventbridge;
822
- this.#eventbridgeAsync = wrapPromisingExport(
823
- exports.__zx_eventbridge_async ?? exports.__zx_eventbridge
824
- );
825
- }
826
- hasEventHandler(velementId, eventTypeId) {
827
- return !!((eventHandlersPresent.get(velementId) ?? 0) & 1 << eventTypeId);
828
- }
829
- eventMaySuspend(velementId, eventTypeId) {
830
- return !!((eventHandlersSuspend.get(velementId) ?? 0) & 1 << eventTypeId);
831
- }
599
+ // src/wasm/generated/tags.ts
600
+ var TAG_NAMES = [
601
+ "aside",
602
+ "fragment",
603
+ "iframe",
604
+ "slot",
605
+ "img",
606
+ "html",
607
+ "base",
608
+ "head",
609
+ "link",
610
+ "meta",
611
+ "script",
612
+ "style",
613
+ "title",
614
+ "address",
615
+ "article",
616
+ "body",
617
+ "h1",
618
+ "h6",
619
+ "footer",
620
+ "header",
621
+ "h2",
622
+ "h3",
623
+ "h4",
624
+ "h5",
625
+ "hgroup",
626
+ "nav",
627
+ "section",
628
+ "dd",
629
+ "dl",
630
+ "dt",
631
+ "div",
632
+ "figcaption",
633
+ "figure",
634
+ "hr",
635
+ "li",
636
+ "ol",
637
+ "ul",
638
+ "menu",
639
+ "main",
640
+ "p",
641
+ "picture",
642
+ "pre",
643
+ "a",
644
+ "abbr",
645
+ "b",
646
+ "bdi",
647
+ "bdo",
648
+ "br",
649
+ "cite",
650
+ "code",
651
+ "data",
652
+ "time",
653
+ "dfn",
654
+ "em",
655
+ "i",
656
+ "kbd",
657
+ "mark",
658
+ "q",
659
+ "blockquote",
660
+ "rp",
661
+ "ruby",
662
+ "rt",
663
+ "rtc",
664
+ "rb",
665
+ "s",
666
+ "del",
667
+ "ins",
668
+ "samp",
669
+ "small",
670
+ "span",
671
+ "strong",
672
+ "sub",
673
+ "sup",
674
+ "u",
675
+ "var",
676
+ "wbr",
677
+ "area",
678
+ "map",
679
+ "audio",
680
+ "source",
681
+ "track",
682
+ "video",
683
+ "embed",
684
+ "object",
685
+ "param",
686
+ "canvas",
687
+ "noscript",
688
+ "caption",
689
+ "table",
690
+ "col",
691
+ "colgroup",
692
+ "tbody",
693
+ "tr",
694
+ "thead",
695
+ "tfoot",
696
+ "td",
697
+ "th",
698
+ "button",
699
+ "datalist",
700
+ "option",
701
+ "fieldset",
702
+ "label",
703
+ "form",
704
+ "input",
705
+ "keygen",
706
+ "legend",
707
+ "meter",
708
+ "optgroup",
709
+ "select",
710
+ "output",
711
+ "progress",
712
+ "textarea",
713
+ "details",
714
+ "dialog",
715
+ "menuitem",
716
+ "summary",
717
+ "content",
718
+ "element",
719
+ "shadow",
720
+ "template",
721
+ "acronym",
722
+ "applet",
723
+ "basefont",
724
+ "font",
725
+ "big",
726
+ "blink",
727
+ "center",
728
+ "command",
729
+ "dir",
730
+ "frame",
731
+ "frameset",
732
+ "isindex",
733
+ "listing",
734
+ "marquee",
735
+ "noembed",
736
+ "plaintext",
737
+ "spacer",
738
+ "strike",
739
+ "tt",
740
+ "xmp",
741
+ "animate",
742
+ "animateMotion",
743
+ "animateTransform",
744
+ "circle",
745
+ "clipPath",
746
+ "defs",
747
+ "desc",
748
+ "ellipse",
749
+ "feBlend",
750
+ "feColorMatrix",
751
+ "feComponentTransfer",
752
+ "feComposite",
753
+ "feConvolveMatrix",
754
+ "feDiffuseLighting",
755
+ "feDisplacementMap",
756
+ "feDistantLight",
757
+ "feDropShadow",
758
+ "feFlood",
759
+ "feFuncA",
760
+ "feFuncB",
761
+ "feFuncG",
762
+ "feFuncR",
763
+ "feGaussianBlur",
764
+ "feImage",
765
+ "feMerge",
766
+ "feMergeNode",
767
+ "feMorphology",
768
+ "feOffset",
769
+ "fePointLight",
770
+ "feSpecularLighting",
771
+ "feSpotLight",
772
+ "feTile",
773
+ "feTurbulence",
774
+ "filter",
775
+ "foreignObject",
776
+ "g",
777
+ "image",
778
+ "line",
779
+ "linearGradient",
780
+ "marker",
781
+ "mask",
782
+ "metadata",
783
+ "mpath",
784
+ "path",
785
+ "pattern",
786
+ "polygon",
787
+ "polyline",
788
+ "radialGradient",
789
+ "rect",
790
+ "set",
791
+ "stop",
792
+ "svg",
793
+ "switch",
794
+ "symbol",
795
+ "text",
796
+ "textPath",
797
+ "tspan",
798
+ "use",
799
+ "view",
800
+ "custom"
801
+ ];
802
+
803
+ // src/wasm/generated/tag_indices.ts
804
+ var SVG_TAG_START_INDEX = 140;
805
+ var CUSTOM_TAG_INDEX = 199;
806
+
807
+ // src/wasm/dom_cmd.ts
808
+ function flushDomCmds(ptr, len, ctx) {
809
+ const start = ptr >>> 0;
810
+ const length = len >>> 0;
811
+ if (length < DOM_CMD_HEADER_SIZE) return;
812
+ const mem = getMemoryView();
813
+ if (start + length > mem.byteLength) return;
814
+ const view = new DataView(mem.buffer, mem.byteOffset + start, length);
815
+ const count = view.getUint32(0, true);
816
+ const recordsBytes = count * DOM_CMD_RECORD_SIZE;
817
+ if (DOM_CMD_HEADER_SIZE + recordsBytes > length) return;
818
+ const { domNodes: domNodes2, cleanupDomNodes: cleanupDomNodes2 } = ctx;
819
+ for (let i = 0; i < count; i++) {
820
+ const off = DOM_CMD_HEADER_SIZE + i * DOM_CMD_RECORD_SIZE;
821
+ const op = view.getUint8(off);
822
+ const p0 = view.getUint32(off + 4, true);
823
+ const p1 = view.getUint32(off + 8, true);
824
+ const p2 = view.getUint32(off + 12, true);
825
+ const p3 = view.getUint32(off + 16, true);
826
+ const p4 = view.getUint32(off + 20, true);
827
+ switch (op) {
828
+ case DomOp_CreateElement: {
829
+ const isCustom = p0 === CUSTOM_TAG_INDEX;
830
+ const tagName = isCustom ? readString(p2, p3) : TAG_NAMES[p0];
831
+ const el = !isCustom && p0 >= SVG_TAG_START_INDEX ? document.createElementNS("http://www.w3.org/2000/svg", tagName) : document.createElement(tagName);
832
+ el.__zx_ref = p1;
833
+ domNodes2.set(p1, el);
834
+ break;
835
+ }
836
+ case DomOp_CreateText: {
837
+ const node = document.createTextNode(readString(p0, p1));
838
+ node.__zx_ref = p2;
839
+ domNodes2.set(p2, node);
840
+ break;
841
+ }
842
+ case DomOp_HydrateInsert: {
843
+ const child = domNodes2.get(p0);
844
+ const ref = BigInt(p1) | BigInt(p2) << 32n;
845
+ const end = loadValueFromRef(ref);
846
+ if (!child || !end?.parentNode) break;
847
+ end.parentNode.insertBefore(child, end);
848
+ break;
849
+ }
850
+ case DomOp_SetAttr: {
851
+ domNodes2.get(p0)?.setAttribute(readString(p1, p2), readString(p3, p4));
852
+ break;
853
+ }
854
+ case DomOp_SetProp: {
855
+ const el = domNodes2.get(p0);
856
+ if (el) {
857
+ const name = readString(p1, p2);
858
+ const val = readString(p3, p4);
859
+ if (name === "checked" || name === "selected" || name === "muted") {
860
+ el[name] = val !== "false";
861
+ } else {
862
+ el[name] = val;
863
+ }
864
+ }
865
+ break;
866
+ }
867
+ case DomOp_RemoveAttr: {
868
+ domNodes2.get(p0)?.removeAttribute(readString(p1, p2));
869
+ break;
870
+ }
871
+ case DomOp_SetNodeValue: {
872
+ const node = domNodes2.get(p0);
873
+ if (node) node.nodeValue = readString(p1, p2);
874
+ break;
875
+ }
876
+ case DomOp_SetInnerHtml: {
877
+ const el = domNodes2.get(p0);
878
+ if (el) el.innerHTML = readString(p1, p2);
879
+ break;
880
+ }
881
+ case DomOp_AppendChild: {
882
+ const parent = domNodes2.get(p0);
883
+ const child = domNodes2.get(p1);
884
+ if (parent && child) parent.appendChild(child);
885
+ break;
886
+ }
887
+ case DomOp_InsertBefore: {
888
+ const parent = domNodes2.get(p0);
889
+ const child = domNodes2.get(p1);
890
+ const refNode = domNodes2.get(p2) ?? null;
891
+ if (parent && child) parent.insertBefore(child, refNode);
892
+ break;
893
+ }
894
+ case DomOp_RemoveChild: {
895
+ const parent = domNodes2.get(p0);
896
+ const child = domNodes2.get(p1);
897
+ if (parent && child) {
898
+ parent.removeChild(child);
899
+ cleanupDomNodes2(child);
900
+ }
901
+ break;
902
+ }
903
+ case DomOp_ReplaceChild: {
904
+ const parent = domNodes2.get(p0);
905
+ const newChild = domNodes2.get(p1);
906
+ const oldChild = domNodes2.get(p2);
907
+ if (parent && newChild && oldChild) {
908
+ parent.replaceChild(newChild, oldChild);
909
+ cleanupDomNodes2(oldChild);
910
+ }
911
+ break;
912
+ }
913
+ default:
914
+ break;
915
+ }
916
+ }
917
+ }
918
+
919
+ // src/runtime/kv/extern.ts
920
+ function putOptions(ttlSeconds) {
921
+ if (ttlSeconds < 60) return void 0;
922
+ return { expirationTtl: ttlSeconds };
923
+ }
924
+ function isSyncKVNamespace(binding) {
925
+ const candidate = binding;
926
+ return typeof candidate.getSync === "function" && typeof candidate.putSync === "function" && typeof candidate.deleteSync === "function" && typeof candidate.listSync === "function";
927
+ }
928
+ function createKVImports(bindings, getMemory, allocRef) {
929
+ const encoder2 = new TextEncoder();
930
+ const decoder2 = new TextDecoder();
931
+ function readStr(ptr, len) {
932
+ return decoder2.decode(new Uint8Array(getMemory().buffer, ptr, len));
933
+ }
934
+ function binding(ns) {
935
+ return bindings[ns] ?? bindings["default"] ?? null;
936
+ }
937
+ const Suspending = WebAssembly.Suspending;
938
+ if (typeof Suspending !== "function") {
939
+ let syncBinding2 = function(ns) {
940
+ const candidate = binding(ns);
941
+ return candidate && isSyncKVNamespace(candidate) ? candidate : null;
942
+ };
943
+ var syncBinding = syncBinding2;
944
+ return {
945
+ kv_get: (ns_ptr, ns_len, key_ptr, key_len, out_ptr) => {
946
+ const b = syncBinding2(readStr(ns_ptr, ns_len));
947
+ if (!b) return -1;
948
+ const value = b.getSync(readStr(key_ptr, key_len));
949
+ if (value === null) return -1;
950
+ return writeBytesOut(getMemory, allocRef, out_ptr, encoder2.encode(value));
951
+ },
952
+ kv_put: (ns_ptr, ns_len, key_ptr, key_len, val_ptr, val_len, ttl_seconds) => {
953
+ const b = syncBinding2(readStr(ns_ptr, ns_len));
954
+ if (!b) return 0;
955
+ b.putSync(readStr(key_ptr, key_len), readStr(val_ptr, val_len), putOptions(ttl_seconds));
956
+ return 0;
957
+ },
958
+ kv_delete: (ns_ptr, ns_len, key_ptr, key_len) => {
959
+ const b = syncBinding2(readStr(ns_ptr, ns_len));
960
+ if (!b) return 0;
961
+ b.deleteSync(readStr(key_ptr, key_len));
962
+ return 0;
963
+ },
964
+ kv_list: (ns_ptr, ns_len, pfx_ptr, pfx_len, out_ptr) => {
965
+ const b = syncBinding2(readStr(ns_ptr, ns_len));
966
+ if (!b) return writeJsonOut(getMemory, allocRef, out_ptr, []);
967
+ const prefix = readStr(pfx_ptr, pfx_len);
968
+ const result = b.listSync(prefix.length > 0 ? { prefix } : void 0);
969
+ return writeJsonOut(getMemory, allocRef, out_ptr, result.keys.map((k) => k.name));
970
+ }
971
+ };
972
+ }
973
+ return {
974
+ kv_get: new Suspending(async (ns_ptr, ns_len, key_ptr, key_len, out_ptr) => {
975
+ const b = binding(readStr(ns_ptr, ns_len));
976
+ if (!b) return -1;
977
+ const value = await b.get(readStr(key_ptr, key_len));
978
+ if (value === null) return -1;
979
+ return writeBytesOut(getMemory, allocRef, out_ptr, encoder2.encode(value));
980
+ }),
981
+ kv_put: new Suspending(async (ns_ptr, ns_len, key_ptr, key_len, val_ptr, val_len, ttl_seconds) => {
982
+ const b = binding(readStr(ns_ptr, ns_len));
983
+ if (!b) return -1;
984
+ await b.put(readStr(key_ptr, key_len), readStr(val_ptr, val_len), putOptions(ttl_seconds));
985
+ return 0;
986
+ }),
987
+ kv_delete: new Suspending(async (ns_ptr, ns_len, key_ptr, key_len) => {
988
+ const b = binding(readStr(ns_ptr, ns_len));
989
+ if (!b) return -1;
990
+ await b.delete(readStr(key_ptr, key_len));
991
+ return 0;
992
+ }),
993
+ kv_list: new Suspending(async (ns_ptr, ns_len, prefix_ptr, prefix_len, out_ptr) => {
994
+ const b = binding(readStr(ns_ptr, ns_len));
995
+ if (!b) return writeJsonOut(getMemory, allocRef, out_ptr, []);
996
+ const prefix = readStr(prefix_ptr, prefix_len);
997
+ const result = await b.list(prefix.length > 0 ? { prefix } : void 0);
998
+ const names = result.keys.map((k) => k.name);
999
+ if (names.length === 0) {
1000
+ new DataView(getMemory().buffer).setUint32(out_ptr, 0, true);
1001
+ return 0;
1002
+ }
1003
+ return writeJsonOut(getMemory, allocRef, out_ptr, names);
1004
+ })
1005
+ };
1006
+ }
1007
+
1008
+ // src/runtime/kv/localstorage.ts
1009
+ function getLocalStorage() {
1010
+ if (typeof localStorage === "undefined") {
1011
+ throw new Error("localStorage is not available in this environment");
1012
+ }
1013
+ return localStorage;
1014
+ }
1015
+ function createLocalStorageKV(options = {}) {
1016
+ const storage = getLocalStorage();
1017
+ const namespace = options.namespace ?? "default";
1018
+ const storagePrefix = options.storagePrefix ?? "ziex-kv";
1019
+ const scopedKey = (key) => `${storagePrefix}:${namespace}:${key}`;
1020
+ const namespacePrefix = scopedKey("");
1021
+ return {
1022
+ getSync(key) {
1023
+ return storage.getItem(scopedKey(key));
1024
+ },
1025
+ async get(key) {
1026
+ return this.getSync(key);
1027
+ },
1028
+ putSync(key, value) {
1029
+ storage.setItem(scopedKey(key), value);
1030
+ },
1031
+ async put(key, value) {
1032
+ this.putSync(key, value);
1033
+ },
1034
+ deleteSync(key) {
1035
+ storage.removeItem(scopedKey(key));
1036
+ },
1037
+ async delete(key) {
1038
+ this.deleteSync(key);
1039
+ },
1040
+ listSync(options2) {
1041
+ const prefix = namespacePrefix + (options2?.prefix ?? "");
1042
+ const keys = [];
1043
+ for (let i = 0; i < storage.length; i += 1) {
1044
+ const key = storage.key(i);
1045
+ if (!key || !key.startsWith(prefix)) continue;
1046
+ keys.push({ name: key.slice(namespacePrefix.length) });
1047
+ }
1048
+ return { keys };
1049
+ },
1050
+ async list(options2) {
1051
+ return this.listSync(options2);
1052
+ }
1053
+ };
1054
+ }
1055
+
1056
+ // src/runtime/kv/indexdb.ts
1057
+ function getIndexedDb() {
1058
+ if (typeof indexedDB === "undefined") {
1059
+ throw new Error("IndexedDB is not available in this environment");
1060
+ }
1061
+ return indexedDB;
1062
+ }
1063
+ function requestToPromise(request) {
1064
+ return new Promise((resolve, reject) => {
1065
+ request.onsuccess = () => resolve(request.result);
1066
+ request.onerror = () => reject(request.error ?? new Error("IndexedDB request failed"));
1067
+ });
1068
+ }
1069
+ function transactionToPromise(transaction) {
1070
+ return new Promise((resolve, reject) => {
1071
+ transaction.oncomplete = () => resolve();
1072
+ transaction.onabort = () => reject(transaction.error ?? new Error("IndexedDB transaction aborted"));
1073
+ transaction.onerror = () => reject(transaction.error ?? new Error("IndexedDB transaction failed"));
1074
+ });
1075
+ }
1076
+ function createIndexedDbKV(options = {}) {
1077
+ const databaseName = options.databaseName ?? "ziex-kv";
1078
+ const storeName = options.storeName ?? "kv";
1079
+ const namespace = options.namespace ?? "default";
1080
+ const dbPromise = new Promise((resolve, reject) => {
1081
+ const request = getIndexedDb().open(databaseName, 1);
1082
+ request.onupgradeneeded = () => {
1083
+ const db = request.result;
1084
+ if (!db.objectStoreNames.contains(storeName)) {
1085
+ db.createObjectStore(storeName);
1086
+ }
1087
+ };
1088
+ request.onsuccess = () => resolve(request.result);
1089
+ request.onerror = () => reject(request.error ?? new Error("Failed to open IndexedDB"));
1090
+ });
1091
+ const scopedKey = (key) => `${namespace}:${key}`;
1092
+ return {
1093
+ async get(key) {
1094
+ const db = await dbPromise;
1095
+ const tx = db.transaction(storeName, "readonly");
1096
+ const store = tx.objectStore(storeName);
1097
+ const value = await requestToPromise(store.get(scopedKey(key)));
1098
+ await transactionToPromise(tx);
1099
+ return typeof value === "string" ? value : null;
1100
+ },
1101
+ async put(key, value) {
1102
+ const db = await dbPromise;
1103
+ const tx = db.transaction(storeName, "readwrite");
1104
+ tx.objectStore(storeName).put(value, scopedKey(key));
1105
+ await transactionToPromise(tx);
1106
+ },
1107
+ async delete(key) {
1108
+ const db = await dbPromise;
1109
+ const tx = db.transaction(storeName, "readwrite");
1110
+ tx.objectStore(storeName).delete(scopedKey(key));
1111
+ await transactionToPromise(tx);
1112
+ },
1113
+ async list(options2) {
1114
+ const db = await dbPromise;
1115
+ const tx = db.transaction(storeName, "readonly");
1116
+ const store = tx.objectStore(storeName);
1117
+ const keys = await requestToPromise(store.getAllKeys());
1118
+ await transactionToPromise(tx);
1119
+ const prefix = scopedKey(options2?.prefix ?? "");
1120
+ return {
1121
+ keys: keys.filter((key) => typeof key === "string" && key.startsWith(prefix)).map((key) => ({ name: key.slice(namespace.length + 1) }))
1122
+ };
1123
+ }
1124
+ };
1125
+ }
1126
+
1127
+ // src/runtime/kv.ts
1128
+ function hasJSPI() {
1129
+ return typeof WebAssembly.Suspending === "function" && typeof WebAssembly.promising === "function";
1130
+ }
1131
+ function createBrowserKVBindings(options = {}) {
1132
+ const namespace = options.namespace ?? "default";
1133
+ const isIndexedDb = hasJSPI() && !options.forceLocalStorage;
1134
+ return {
1135
+ [namespace]: isIndexedDb ? createIndexedDbKV(options) : createLocalStorageKV(options)
1136
+ };
1137
+ }
1138
+
1139
+ // src/wasm/generated/events.ts
1140
+ var DELEGATED_EVENTS = [
1141
+ "click",
1142
+ "dblclick",
1143
+ "input",
1144
+ "change",
1145
+ "submit",
1146
+ "focusin",
1147
+ "focusout",
1148
+ "keydown",
1149
+ "keyup",
1150
+ "keypress",
1151
+ "mouseenter",
1152
+ "mouseleave",
1153
+ "mousedown",
1154
+ "mouseup",
1155
+ "mousemove",
1156
+ "touchstart",
1157
+ "touchend",
1158
+ "touchmove",
1159
+ "scroll",
1160
+ "wheel",
1161
+ "pointerdown",
1162
+ "pointermove",
1163
+ "pointerup",
1164
+ "pointercancel",
1165
+ "pointerenter",
1166
+ "pointerleave",
1167
+ "lostpointercapture"
1168
+ ];
1169
+
1170
+ // src/wasm/generated/event_bits.ts
1171
+ var HIGH_FREQ_EVENT_BITS = 3031040;
1172
+
1173
+ // src/wasm/index.ts
1174
+ var ZxBridge = class extends ZxBridgeCore {
1175
+ #websockets = /* @__PURE__ */ new Map();
1176
+ #eventbridge;
1177
+ #eventbridgeAsync;
1178
+ constructor(exports) {
1179
+ super(exports);
1180
+ this.#eventbridge = exports.__zx_eventbridge;
1181
+ this.#eventbridgeAsync = wrapPromisingExport(
1182
+ exports.__zx_eventbridge_async ?? exports.__zx_eventbridge
1183
+ );
1184
+ }
1185
+ hasEventHandler(velementId, eventTypeId) {
1186
+ return !!((eventHandlersPresent.get(velementId) ?? 0) & 1 << eventTypeId);
1187
+ }
1188
+ eventMaySuspend(velementId, eventTypeId) {
1189
+ return !!((eventHandlersSuspend.get(velementId) ?? 0) & 1 << eventTypeId);
1190
+ }
832
1191
  setEventHandlerMode(velementId, eventTypeId, maySuspend) {
833
1192
  const bit = 1 << eventTypeId;
834
1193
  const present = (eventHandlersPresent.get(velementId) ?? 0) | bit;
@@ -843,8 +1202,8 @@ var ZxBridge = class extends ZxBridgeCore {
843
1202
  const present = eventHandlersPresent.get(velementId) ?? 0;
844
1203
  eventHandlersPresent.delete(velementId);
845
1204
  eventHandlersSuspend.delete(velementId);
846
- for (const eventTypeId of HIGH_FREQ_EVENT_IDS) {
847
- if (present & 1 << eventTypeId) maybeRemoveHighFreqListener(eventTypeId);
1205
+ for (let bits = present & HIGH_FREQ_EVENT_BITS; bits !== 0; bits &= bits - 1) {
1206
+ maybeRemoveHighFreqListener(31 - Math.clz32(bits));
848
1207
  }
849
1208
  }
850
1209
  /** Submit a form action with bound-state round-trip. */
@@ -866,7 +1225,7 @@ var ZxBridge = class extends ZxBridgeCore {
866
1225
  }
867
1226
  /**
868
1227
  * Create and connect a WebSocket.
869
- * Calls __zx_ws_onopen, __zx_ws_onmessage, __zx_ws_onerror, __zx_ws_onclose.
1228
+ * Completes via `__zx_cb(ws_open|ws_message|ws_error|ws_close, ...)`.
870
1229
  */
871
1230
  wsConnect(wsId, urlPtr, urlLen, protocolsPtr, protocolsLen) {
872
1231
  const url = readString(urlPtr, urlLen);
@@ -876,42 +1235,32 @@ var ZxBridge = class extends ZxBridgeCore {
876
1235
  const ws = protocols && protocols.length > 0 ? new WebSocket(url, protocols) : new WebSocket(url);
877
1236
  ws.binaryType = "arraybuffer";
878
1237
  ws.onopen = () => {
879
- const handler = this.#wsOnOpenHandler;
880
- if (!handler) return;
881
1238
  const protocol = ws.protocol || "";
882
1239
  const [ptr, len] = this._writeStringToWasm(protocol);
883
- invokeWasmExport(handler, wsId, ptr, len);
1240
+ this._invoke(CallbackType_WebSocketOpen, wsId, BigInt(ptr), BigInt(len));
884
1241
  };
885
1242
  ws.onmessage = (event) => {
886
- const handler = this.#wsOnMessageHandler;
887
- if (!handler) return;
888
1243
  const isBinary = event.data instanceof ArrayBuffer;
889
1244
  const data = isBinary ? new Uint8Array(event.data) : textEncoder.encode(event.data);
890
1245
  const [ptr, len] = this.writeBytesToWasm(data);
891
- invokeWasmExport(handler, wsId, ptr, len, isBinary ? 1 : 0);
1246
+ this._invoke(CallbackType_WebSocketMessage, wsId, BigInt(ptr), BigInt(len), BigInt(isBinary ? 1 : 0));
892
1247
  };
893
1248
  ws.onerror = (_event) => {
894
- const handler = this.#wsOnErrorHandler;
895
- if (!handler) return;
896
1249
  const [ptr, len] = this._writeStringToWasm("WebSocket error");
897
- invokeWasmExport(handler, wsId, ptr, len);
1250
+ this._invoke(CallbackType_WebSocketError, wsId, BigInt(ptr), BigInt(len));
898
1251
  };
899
1252
  ws.onclose = (event) => {
900
- const handler = this.#wsOnCloseHandler;
901
- if (!handler) return;
902
1253
  const reason = event.reason || "";
903
1254
  const [ptr, len] = this._writeStringToWasm(reason);
904
- invokeWasmExport(handler, wsId, event.code, ptr, len, event.wasClean ? 1 : 0);
1255
+ const c = BigInt(len) | BigInt(event.wasClean ? 1 : 0) << 32n;
1256
+ this._invoke(CallbackType_WebSocketClose, wsId, BigInt(event.code), BigInt(ptr), c);
905
1257
  this.#websockets.delete(wsId);
906
1258
  };
907
1259
  this.#websockets.set(wsId, ws);
908
1260
  } catch (error) {
909
- const handler = this.#wsOnErrorHandler;
910
- if (handler) {
911
- const msg = error instanceof Error ? error.message : "WebSocket connection failed";
912
- const [ptr, len] = this._writeStringToWasm(msg);
913
- invokeWasmExport(handler, wsId, ptr, len);
914
- }
1261
+ const msg = error instanceof Error ? error.message : "WebSocket connection failed";
1262
+ const [ptr, len] = this._writeStringToWasm(msg);
1263
+ this._invoke(CallbackType_WebSocketError, wsId, BigInt(ptr), BigInt(len));
915
1264
  }
916
1265
  }
917
1266
  /** Send data over WebSocket */
@@ -1012,79 +1361,11 @@ var ZxBridge = class extends ZxBridgeCore {
1012
1361
  _wsClose: (wsId, code, reasonPtr, reasonLen) => {
1013
1362
  bridgeRef[0]?.wsClose(wsId, code, reasonPtr, reasonLen);
1014
1363
  },
1015
- _ce: (id, vnodeId) => {
1016
- const nid = Number(vnodeId);
1017
- const tagName = TAG_NAMES[id];
1018
- const el = id >= SVG_TAG_START_INDEX ? document.createElementNS("http://www.w3.org/2000/svg", tagName) : document.createElement(tagName);
1019
- el.__zx_ref = nid;
1020
- domNodes.set(nid, el);
1021
- },
1022
- _ct: (ptr, len, vnodeId) => {
1023
- const nid = Number(vnodeId);
1024
- const node = document.createTextNode(readString(ptr, len));
1025
- node.__zx_ref = nid;
1026
- domNodes.set(nid, node);
1027
- },
1028
- /** Insert vnode before a jsz-held end comment (hydration). */
1029
- _ih: (vnodeId, endCommentRef) => {
1030
- const child = domNodes.get(Number(vnodeId));
1031
- const end = loadValueFromRef(endCommentRef);
1032
- if (!child || !end?.parentNode) return;
1033
- end.parentNode.insertBefore(child, end);
1034
- },
1035
- _sa: (vnodeId, namePtr, nameLen, valPtr, valLen) => {
1036
- domNodes.get(Number(vnodeId))?.setAttribute(readString(namePtr, nameLen), readString(valPtr, valLen));
1037
- },
1038
- _sp: (vnodeId, namePtr, nameLen, valPtr, valLen) => {
1039
- const el = domNodes.get(Number(vnodeId));
1040
- if (el) {
1041
- const name = readString(namePtr, nameLen);
1042
- const val = readString(valPtr, valLen);
1043
- if (name === "checked" || name === "selected" || name === "muted") {
1044
- el[name] = val !== "false";
1045
- } else {
1046
- el[name] = val;
1047
- }
1048
- }
1049
- },
1050
- _ra: (vnodeId, namePtr, nameLen) => {
1051
- domNodes.get(Number(vnodeId))?.removeAttribute(readString(namePtr, nameLen));
1052
- },
1053
- _snv: (vnodeId, ptr, len) => {
1054
- const node = domNodes.get(Number(vnodeId));
1055
- if (node) node.nodeValue = readString(ptr, len);
1056
- },
1057
- _srh: (vnodeId, ptr, len) => {
1058
- const el = domNodes.get(Number(vnodeId));
1059
- if (el) el.innerHTML = readString(ptr, len);
1060
- },
1061
- _ac: (parentId, childId) => {
1062
- const parent = domNodes.get(Number(parentId));
1063
- const child = domNodes.get(Number(childId));
1064
- if (parent && child) parent.appendChild(child);
1065
- },
1066
- _ib: (parentId, childId, refId) => {
1067
- const parent = domNodes.get(Number(parentId));
1068
- const child = domNodes.get(Number(childId));
1069
- const ref = domNodes.get(Number(refId)) ?? null;
1070
- if (parent && child) parent.insertBefore(child, ref);
1071
- },
1072
- _rc: (parentId, childId) => {
1073
- const parent = domNodes.get(Number(parentId));
1074
- const child = domNodes.get(Number(childId));
1075
- if (parent && child) {
1076
- parent.removeChild(child);
1077
- cleanupDomNodes(child);
1078
- }
1079
- },
1080
- _rpc: (parentId, newId, oldId) => {
1081
- const parent = domNodes.get(Number(parentId));
1082
- const newChild = domNodes.get(Number(newId));
1083
- const oldChild = domNodes.get(Number(oldId));
1084
- if (parent && newChild && oldChild) {
1085
- parent.replaceChild(newChild, oldChild);
1086
- cleanupDomNodes(oldChild);
1087
- }
1364
+ _flush: (ptr, len) => {
1365
+ flushDomCmds(ptr, len, {
1366
+ domNodes,
1367
+ cleanupDomNodes
1368
+ });
1088
1369
  },
1089
1370
  _getLocationHref: (bufPtr, bufLen) => {
1090
1371
  const bytes = textEncoder.encode(window.location.href);
@@ -1149,247 +1430,10 @@ function cleanupDomNodes(node) {
1149
1430
  const children = n.childNodes;
1150
1431
  for (let i = 0; i < children.length; i++) stack.push(children[i]);
1151
1432
  }
1152
- for (const eventTypeId of HIGH_FREQ_EVENT_IDS) {
1153
- if (highFreqBits & 1 << eventTypeId) maybeRemoveHighFreqListener(eventTypeId);
1433
+ for (let bits = highFreqBits & HIGH_FREQ_EVENT_BITS; bits !== 0; bits &= bits - 1) {
1434
+ maybeRemoveHighFreqListener(31 - Math.clz32(bits));
1154
1435
  }
1155
1436
  }
1156
- var SVG_TAG_START_INDEX = 140;
1157
- var TAG_NAMES = [
1158
- "aside",
1159
- "fragment",
1160
- "iframe",
1161
- "slot",
1162
- "img",
1163
- "html",
1164
- "base",
1165
- "head",
1166
- "link",
1167
- "meta",
1168
- "script",
1169
- "style",
1170
- "title",
1171
- "address",
1172
- "article",
1173
- "body",
1174
- "h1",
1175
- "h6",
1176
- "footer",
1177
- "header",
1178
- "h2",
1179
- "h3",
1180
- "h4",
1181
- "h5",
1182
- "hgroup",
1183
- "nav",
1184
- "section",
1185
- "dd",
1186
- "dl",
1187
- "dt",
1188
- "div",
1189
- "figcaption",
1190
- "figure",
1191
- "hr",
1192
- "li",
1193
- "ol",
1194
- "ul",
1195
- "menu",
1196
- "main",
1197
- "p",
1198
- "picture",
1199
- "pre",
1200
- "a",
1201
- "abbr",
1202
- "b",
1203
- "bdi",
1204
- "bdo",
1205
- "br",
1206
- "cite",
1207
- "code",
1208
- "data",
1209
- "time",
1210
- "dfn",
1211
- "em",
1212
- "i",
1213
- "kbd",
1214
- "mark",
1215
- "q",
1216
- "blockquote",
1217
- "rp",
1218
- "ruby",
1219
- "rt",
1220
- "rtc",
1221
- "rb",
1222
- "s",
1223
- "del",
1224
- "ins",
1225
- "samp",
1226
- "small",
1227
- "span",
1228
- "strong",
1229
- "sub",
1230
- "sup",
1231
- "u",
1232
- "var",
1233
- "wbr",
1234
- "area",
1235
- "map",
1236
- "audio",
1237
- "source",
1238
- "track",
1239
- "video",
1240
- "embed",
1241
- "object",
1242
- "param",
1243
- "canvas",
1244
- "noscript",
1245
- "caption",
1246
- "table",
1247
- "col",
1248
- "colgroup",
1249
- "tbody",
1250
- "tr",
1251
- "thead",
1252
- "tfoot",
1253
- "td",
1254
- "th",
1255
- "button",
1256
- "datalist",
1257
- "option",
1258
- "fieldset",
1259
- "label",
1260
- "form",
1261
- "input",
1262
- "keygen",
1263
- "legend",
1264
- "meter",
1265
- "optgroup",
1266
- "select",
1267
- "output",
1268
- "progress",
1269
- "textarea",
1270
- "details",
1271
- "dialog",
1272
- "menuitem",
1273
- "summary",
1274
- "content",
1275
- "element",
1276
- "shadow",
1277
- "template",
1278
- "acronym",
1279
- "applet",
1280
- "basefont",
1281
- "font",
1282
- "big",
1283
- "blink",
1284
- "center",
1285
- "command",
1286
- "dir",
1287
- "frame",
1288
- "frameset",
1289
- "isindex",
1290
- "listing",
1291
- "marquee",
1292
- "noembed",
1293
- "plaintext",
1294
- "spacer",
1295
- "strike",
1296
- "tt",
1297
- "xmp",
1298
- // SVG Tags
1299
- "animate",
1300
- "animateMotion",
1301
- "animateTransform",
1302
- "circle",
1303
- "clipPath",
1304
- "defs",
1305
- "desc",
1306
- "ellipse",
1307
- "feBlend",
1308
- "feColorMatrix",
1309
- "feComponentTransfer",
1310
- "feComposite",
1311
- "feConvolveMatrix",
1312
- "feDiffuseLighting",
1313
- "feDisplacementMap",
1314
- "feDistantLight",
1315
- "feDropShadow",
1316
- "feFlood",
1317
- "feFuncA",
1318
- "feFuncB",
1319
- "feFuncG",
1320
- "feFuncR",
1321
- "feGaussianBlur",
1322
- "feImage",
1323
- "feMerge",
1324
- "feMergeNode",
1325
- "feMorphology",
1326
- "feOffset",
1327
- "fePointLight",
1328
- "feSpecularLighting",
1329
- "feSpotLight",
1330
- "feTile",
1331
- "feTurbulence",
1332
- "filter",
1333
- "foreignObject",
1334
- "g",
1335
- "image",
1336
- "line",
1337
- "linearGradient",
1338
- "marker",
1339
- "mask",
1340
- "metadata",
1341
- "mpath",
1342
- "path",
1343
- "pattern",
1344
- "polygon",
1345
- "polyline",
1346
- "radialGradient",
1347
- "rect",
1348
- "set",
1349
- "stop",
1350
- "svg",
1351
- "switch",
1352
- "symbol",
1353
- "text",
1354
- "textPath",
1355
- "tspan",
1356
- "use",
1357
- "view"
1358
- ];
1359
- var DELEGATED_EVENTS = [
1360
- "click",
1361
- "dblclick",
1362
- "input",
1363
- "change",
1364
- "submit",
1365
- // focus/blur do not bubble - listen to focusin/focusout instead.
1366
- "focusin",
1367
- "focusout",
1368
- "keydown",
1369
- "keyup",
1370
- "keypress",
1371
- "mouseenter",
1372
- "mouseleave",
1373
- "mousedown",
1374
- "mouseup",
1375
- "mousemove",
1376
- "touchstart",
1377
- "touchend",
1378
- "touchmove",
1379
- "scroll",
1380
- "wheel",
1381
- "pointerdown",
1382
- "pointermove",
1383
- "pointerup",
1384
- "pointercancel"
1385
- ];
1386
- var HIGH_FREQ_EVENT_IDS = new Set([
1387
- DELEGATED_EVENTS.indexOf("mousemove"),
1388
- DELEGATED_EVENTS.indexOf("pointermove"),
1389
- DELEGATED_EVENTS.indexOf("wheel"),
1390
- DELEGATED_EVENTS.indexOf("scroll"),
1391
- DELEGATED_EVENTS.indexOf("touchmove")
1392
- ].filter((id) => id >= 0));
1393
1437
  var delegationState = null;
1394
1438
  function makeDelegatedListener(bridge, eventTypeId) {
1395
1439
  return (event) => {
@@ -1437,7 +1481,7 @@ function anyHandlerForType(eventTypeId) {
1437
1481
  return false;
1438
1482
  }
1439
1483
  function maybeRemoveHighFreqListener(eventTypeId) {
1440
- if (!HIGH_FREQ_EVENT_IDS.has(eventTypeId)) return;
1484
+ if ((HIGH_FREQ_EVENT_BITS & 1 << eventTypeId) === 0) return;
1441
1485
  if (anyHandlerForType(eventTypeId)) return;
1442
1486
  const state = delegationState;
1443
1487
  if (!state) return;
@@ -1453,7 +1497,7 @@ function initEventDelegation(bridge, rootSelector = "body") {
1453
1497
  };
1454
1498
  delegationState = { root, bridge, attached: /* @__PURE__ */ new Map() };
1455
1499
  for (let eventTypeId = 0; eventTypeId < DELEGATED_EVENTS.length; eventTypeId++) {
1456
- if (HIGH_FREQ_EVENT_IDS.has(eventTypeId)) continue;
1500
+ if ((HIGH_FREQ_EVENT_BITS & 1 << eventTypeId) !== 0) continue;
1457
1501
  ensureDelegatedListener(eventTypeId);
1458
1502
  }
1459
1503
  return () => {