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/runtime/kv.d.ts CHANGED
@@ -38,6 +38,7 @@ export { createKVImports } from "./kv/extern";
38
38
  import { type IndexedDbKVOptions } from "./kv/indexdb";
39
39
  export type BrowserKVOptions = IndexedDbKVOptions & {
40
40
  storagePrefix?: string;
41
+ forceLocalStorage?: boolean;
41
42
  };
42
43
  export declare function hasJSPI(): boolean;
43
44
  /** Prefer IndexedDB when JSPI is available, otherwise localStorage. */
package/runtime/kv.js CHANGED
@@ -528,8 +528,9 @@ function hasJSPI() {
528
528
  }
529
529
  function createBrowserKVBindings(options = {}) {
530
530
  const namespace = options.namespace ?? "default";
531
+ const isIndexedDb = hasJSPI() && !options.forceLocalStorage;
531
532
  return {
532
- [namespace]: hasJSPI() ? createIndexedDbKV(options) : createLocalStorageKV(options)
533
+ [namespace]: isIndexedDb ? createIndexedDbKV(options) : createLocalStorageKV(options)
533
534
  };
534
535
  }
535
536
  export {
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Numeric wire constants for the WASM↔JS ABI.
3
+ *
4
+ * Kept in a path-import-free module so esbuild's const-inlining heuristic can
5
+ * fold these into call sites across the bundle (#1317 / #1981):
6
+ * only `null` / `undefined` / `true` / `false` / integers / short reals, at the
7
+ * top of a scope with no `import`/`export … from "…"`.
8
+ *
9
+ * Must stay in sync with Zig (`dom_cmd.zig`, `host.zig` / `__zx_cb` types).
10
+ */
11
+ export declare const DOM_CMD_HEADER_SIZE = 8;
12
+ export declare const DOM_CMD_RECORD_SIZE = 24;
13
+ export declare const DomOp_CreateElement = 1;
14
+ export declare const DomOp_CreateText = 2;
15
+ export declare const DomOp_HydrateInsert = 3;
16
+ export declare const DomOp_SetAttr = 4;
17
+ export declare const DomOp_SetProp = 5;
18
+ export declare const DomOp_RemoveAttr = 6;
19
+ export declare const DomOp_SetNodeValue = 7;
20
+ export declare const DomOp_SetInnerHtml = 8;
21
+ export declare const DomOp_AppendChild = 9;
22
+ export declare const DomOp_InsertBefore = 10;
23
+ export declare const DomOp_RemoveChild = 11;
24
+ export declare const DomOp_ReplaceChild = 12;
25
+ export declare const CallbackType_Event = 0;
26
+ export declare const CallbackType_FetchSuccess = 1;
27
+ export declare const CallbackType_FetchError = 2;
28
+ export declare const CallbackType_Timeout = 3;
29
+ export declare const CallbackType_Interval = 4;
30
+ export declare const CallbackType_WebSocketOpen = 5;
31
+ export declare const CallbackType_WebSocketMessage = 6;
32
+ export declare const CallbackType_WebSocketError = 7;
33
+ export declare const CallbackType_WebSocketClose = 8;
package/wasm/core.d.ts CHANGED
@@ -1,23 +1,9 @@
1
1
  import { ZigJS } from "../../../../vendor/jsz/js/src";
2
- /**
3
- * Callback type ids - must match Zig. Plain number consts so names minify.
4
- */
5
- export declare const CallbackType_Event = 0;
6
- export declare const CallbackType_FetchSuccess = 1;
7
- export declare const CallbackType_FetchError = 2;
8
- export declare const CallbackType_Timeout = 3;
9
- export declare const CallbackType_Interval = 4;
10
- export declare const CallbackType_WebSocketOpen = 5;
11
- export declare const CallbackType_WebSocketMessage = 6;
12
- export declare const CallbackType_WebSocketError = 7;
13
- export declare const CallbackType_WebSocketClose = 8;
2
+ import { CallbackType_Event, CallbackType_FetchSuccess, CallbackType_FetchError, CallbackType_Timeout, CallbackType_Interval, CallbackType_WebSocketOpen, CallbackType_WebSocketMessage, CallbackType_WebSocketError, CallbackType_WebSocketClose } from "./constants";
3
+ export { CallbackType_Event, CallbackType_FetchSuccess, CallbackType_FetchError, CallbackType_Timeout, CallbackType_Interval, CallbackType_WebSocketOpen, CallbackType_WebSocketMessage, CallbackType_WebSocketError, CallbackType_WebSocketClose, } from "./constants";
14
4
  export type CallbackTypeValue = typeof CallbackType_Event | typeof CallbackType_FetchSuccess | typeof CallbackType_FetchError | typeof CallbackType_Timeout | typeof CallbackType_Interval | typeof CallbackType_WebSocketOpen | typeof CallbackType_WebSocketMessage | typeof CallbackType_WebSocketError | typeof CallbackType_WebSocketClose;
15
- export type CallbackHandler = (callbackType: number, id: bigint, dataRef: bigint) => void;
16
- export type FetchCompleteHandler = (fetchId: bigint, statusCode: number, bodyPtr: number, bodyLen: number, isError: number) => void;
17
- export type WsOnOpenHandler = (wsId: bigint, protocolPtr: number, protocolLen: number) => void;
18
- export type WsOnMessageHandler = (wsId: bigint, dataPtr: number, dataLen: number, isBinary: number) => void;
19
- export type WsOnErrorHandler = (wsId: bigint, msgPtr: number, msgLen: number) => void;
20
- export type WsOnCloseHandler = (wsId: bigint, code: number, reasonPtr: number, reasonLen: number, wasClean: number) => void;
5
+ /** Unified host→guest callback: (type, id, a, b, c). Extra args are msg-specific. */
6
+ export type CallbackHandler = (callbackType: number, id: bigint, a: bigint, b: bigint, c: bigint) => void;
21
7
  /**
22
8
  * Core WASM bridge - environment-agnostic (browser + edge).
23
9
  * No references to browser globals (document, window, WebSocket, HTMLFormElement).
@@ -49,9 +35,11 @@ export declare class ZxBridgeCore {
49
35
  #private;
50
36
  protected readonly _alloc: (size: number) => number;
51
37
  constructor(exports: WebAssembly.Exports);
38
+ /** Invoke the unified callback handler */
39
+ protected _invoke(type: CallbackTypeValue, id: bigint, a?: bigint, b?: bigint, c?: bigint): void;
52
40
  /**
53
41
  * Async fetch with full options support.
54
- * Calls __zx_fetch_complete when done.
42
+ * Completes via `__zx_cb(fetch_success|fetch_error, ...)`.
55
43
  */
56
44
  fetchAsync(urlPtr: number, urlLen: number, methodPtr: number, methodLen: number, headersPtr: number, headersLen: number, bodyPtr: number, bodyLen: number, timeoutMs: number, fetchId: bigint): void;
57
45
  /** Notify WASM that a fetch completed. `body` is raw bytes on success, text on error. */
@@ -0,0 +1,15 @@
1
+ /**
2
+ * DomCmd flush decoder — must match `src/runtime/client/dom_cmd.zig`.
3
+ *
4
+ * Buffer layout (little-endian):
5
+ * Header (8): u32 record_count, u32 flags (0 = absolute WASM ptr+len strings)
6
+ * Records (24 each): u8 op, u8 flags, u16 pad, u32 p0..p4
7
+ *
8
+ * String fields are absolute linear-memory pointers (same as the old per-op ABI).
9
+ */
10
+ export type DomFlushContext = {
11
+ domNodes: Map<number, Node>;
12
+ cleanupDomNodes: (node: Node) => void;
13
+ };
14
+ /** Apply a DomCmd buffer written at `ptr` with byte length `len`. */
15
+ export declare function flushDomCmds(ptr: number, len: number, ctx: DomFlushContext): void;
@@ -0,0 +1,2 @@
1
+ /** High-frequency event type bitmask -> `(bits & (1 << id)) !== 0`. */
2
+ export declare const HIGH_FREQ_EVENT_BITS = 3031040;
@@ -0,0 +1 @@
1
+ export declare const DELEGATED_EVENTS: readonly ['click', 'dblclick', 'input', 'change', 'submit', 'focusin', 'focusout', 'keydown', 'keyup', 'keypress', 'mouseenter', 'mouseleave', 'mousedown', 'mouseup', 'mousemove', 'touchstart', 'touchend', 'touchmove', 'scroll', 'wheel', 'pointerdown', 'pointermove', 'pointerup', 'pointercancel', 'pointerenter', 'pointerleave', 'lostpointercapture'];
@@ -0,0 +1,2 @@
1
+ export declare const SVG_TAG_START_INDEX = 140;
2
+ export declare const CUSTOM_TAG_INDEX = 199;
@@ -0,0 +1 @@
1
+ export declare const TAG_NAMES: readonly ['aside', 'fragment', 'iframe', 'slot', 'img', 'html', 'base', 'head', 'link', 'meta', 'script', 'style', 'title', 'address', 'article', 'body', 'h1', 'h6', 'footer', 'header', 'h2', 'h3', 'h4', 'h5', 'hgroup', 'nav', 'section', 'dd', 'dl', 'dt', 'div', 'figcaption', 'figure', 'hr', 'li', 'ol', 'ul', 'menu', 'main', 'p', 'picture', 'pre', 'a', 'abbr', 'b', 'bdi', 'bdo', 'br', 'cite', 'code', 'data', 'time', 'dfn', 'em', 'i', 'kbd', 'mark', 'q', 'blockquote', 'rp', 'ruby', 'rt', 'rtc', 'rb', 's', 'del', 'ins', 'samp', 'small', 'span', 'strong', 'sub', 'sup', 'u', 'var', 'wbr', 'area', 'map', 'audio', 'source', 'track', 'video', 'embed', 'object', 'param', 'canvas', 'noscript', 'caption', 'table', 'col', 'colgroup', 'tbody', 'tr', 'thead', 'tfoot', 'td', 'th', 'button', 'datalist', 'option', 'fieldset', 'label', 'form', 'input', 'keygen', 'legend', 'meter', 'optgroup', 'select', 'output', 'progress', 'textarea', 'details', 'dialog', 'menuitem', 'summary', 'content', 'element', 'shadow', 'template', 'acronym', 'applet', 'basefont', 'font', 'big', 'blink', 'center', 'command', 'dir', 'frame', 'frameset', 'isindex', 'listing', 'marquee', 'noembed', 'plaintext', 'spacer', 'strike', 'tt', 'xmp', 'animate', 'animateMotion', 'animateTransform', 'circle', 'clipPath', 'defs', 'desc', 'ellipse', 'feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feDropShadow', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence', 'filter', 'foreignObject', 'g', 'image', 'line', 'linearGradient', 'marker', 'mask', 'metadata', 'mpath', 'path', 'pattern', 'polygon', 'polyline', 'radialGradient', 'rect', 'set', 'stop', 'svg', 'switch', 'symbol', 'text', 'textPath', 'tspan', 'use', 'view', 'custom'];
package/wasm/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- export { CallbackType_Event, CallbackType_FetchSuccess, CallbackType_FetchError, CallbackType_Timeout, CallbackType_Interval, CallbackType_WebSocketOpen, CallbackType_WebSocketMessage, CallbackType_WebSocketError, CallbackType_WebSocketClose, jsz, storeValueGetRef, loadValueFromRef, releaseValueRef, textDecoder, textEncoder, getMemoryView, readString, writeBytes, writeBytesOut, writeJsonOut, bindWasmAlloc, ZxBridgeCore, } from "./core";
1
+ export { CallbackType_Event, CallbackType_FetchSuccess, CallbackType_FetchError, CallbackType_Timeout, CallbackType_Interval, CallbackType_WebSocketOpen, CallbackType_WebSocketMessage, CallbackType_WebSocketError, CallbackType_WebSocketClose, } from "./constants";
2
+ export { jsz, storeValueGetRef, loadValueFromRef, releaseValueRef, textDecoder, textEncoder, getMemoryView, readString, writeBytes, writeBytesOut, writeJsonOut, bindWasmAlloc, ZxBridgeCore, } from "./core";
2
3
  export type { CallbackTypeValue, WasmAllocRef } from "./core";
3
4
  import { ZxBridgeCore } from "./core";
4
5
  import { type KVNamespace } from "../runtime/kv";
@@ -18,7 +19,7 @@ export declare class ZxBridge extends ZxBridgeCore {
18
19
  submitFormActionAsync(form: HTMLFormElement, actionId: number, statesJson: string, fetchId: bigint): void;
19
20
  /**
20
21
  * Create and connect a WebSocket.
21
- * Calls __zx_ws_onopen, __zx_ws_onmessage, __zx_ws_onerror, __zx_ws_onclose.
22
+ * Completes via `__zx_cb(ws_open|ws_message|ws_error|ws_close, ...)`.
22
23
  */
23
24
  wsConnect(wsId: bigint, urlPtr: number, urlLen: number, protocolsPtr: number, protocolsLen: number): void;
24
25
  /** Send data over WebSocket */