ziex 0.1.0-dev.1000 → 0.1.0-dev.1050
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/app.d.ts +10 -10
- package/cloudflare/index.js +12 -0
- package/package.json +2 -2
- package/runtime.d.ts +2 -2
- package/vercel/index.d.ts +1 -1
- package/wasm/core.d.ts +3 -3
- package/wasm/index.d.ts +1 -1
- package/wasm/index.js +12 -0
- package/wasm/init.js +12 -0
- package/wasm/wasi.d.ts +3 -3
package/app.d.ts
CHANGED
|
@@ -4,16 +4,16 @@ import type { D1Database } from "./db";
|
|
|
4
4
|
import type { WASI } from "./wasi";
|
|
5
5
|
/**
|
|
6
6
|
* Anything that can be resolved to a `WebAssembly.Module`:
|
|
7
|
-
* - `WebAssembly.Module`
|
|
8
|
-
* - `ArrayBuffer` / `ArrayBufferView`
|
|
9
|
-
* - `Response`
|
|
10
|
-
* - `string`
|
|
11
|
-
* - `URL`
|
|
7
|
+
* - `WebAssembly.Module` - already compiled (Cloudflare Workers, wrangler)
|
|
8
|
+
* - `ArrayBuffer` / `ArrayBufferView` - raw WASM bytes
|
|
9
|
+
* - `Response` - a fetch() response whose body is the WASM binary
|
|
10
|
+
* - `string` - an HTTP(S) URL or an absolute file path (Bun)
|
|
11
|
+
* - `URL` - a URL object
|
|
12
12
|
*/
|
|
13
13
|
export type WasmInput = WebAssembly.Module | ArrayBuffer | ArrayBufferView | Response | string | URL;
|
|
14
14
|
/**
|
|
15
15
|
* Resolve any supported WASM input to a compiled `WebAssembly.Module`.
|
|
16
|
-
* The result is NOT cached here
|
|
16
|
+
* The result is NOT cached here - cache it at the call site if needed.
|
|
17
17
|
*/
|
|
18
18
|
export declare function resolveModule(input: WasmInput): Promise<WebAssembly.Module>;
|
|
19
19
|
/** Keys of `Env` whose value extends {@link KVNamespace}. */
|
|
@@ -28,7 +28,7 @@ type DBKey<Env> = {
|
|
|
28
28
|
[K in keyof Env]: Env[K] extends D1Database ? K : never;
|
|
29
29
|
}[keyof Env];
|
|
30
30
|
type ZiexOptions<Env> = {
|
|
31
|
-
/** WASM module
|
|
31
|
+
/** WASM module - accepts any {@link WasmInput}. Resolved and cached on first request. */
|
|
32
32
|
module: WasmInput;
|
|
33
33
|
/** Optional pre-configured WASI instance. */
|
|
34
34
|
wasi?: WASI;
|
|
@@ -37,8 +37,8 @@ type ZiexOptions<Env> = {
|
|
|
37
37
|
/**
|
|
38
38
|
* KV namespace bindings. Two forms are supported:
|
|
39
39
|
*
|
|
40
|
-
* - **Env key**: a single key from `Env` whose value is a `KVNamespace`
|
|
41
|
-
* - **Name map**: `{ [bindingName]: envKey }`
|
|
40
|
+
* - **Env key**: a single key from `Env` whose value is a `KVNamespace` - used as the `"default"` binding.
|
|
41
|
+
* - **Name map**: `{ [bindingName]: envKey }` - map namespace names to env keys.
|
|
42
42
|
*
|
|
43
43
|
* @example Single env key (becomes the "default" binding)
|
|
44
44
|
* ```ts
|
|
@@ -69,7 +69,7 @@ type ZiexOptions<Env> = {
|
|
|
69
69
|
websocket?: DOKey<Env>;
|
|
70
70
|
};
|
|
71
71
|
/**
|
|
72
|
-
* Main Ziex application class. Mirrors the Hono API style
|
|
72
|
+
* Main Ziex application class. Mirrors the Hono API style - construct once,
|
|
73
73
|
* export as default, and the runtime calls `fetch` for you.
|
|
74
74
|
*
|
|
75
75
|
* Works on Cloudflare Workers, Bun, and Vercel Edge out of the box.
|
package/cloudflare/index.js
CHANGED
|
@@ -828,6 +828,18 @@ class ZxBridge extends ZxBridgeCore {
|
|
|
828
828
|
_sa: (vnodeId, namePtr, nameLen, valPtr, valLen) => {
|
|
829
829
|
domNodes.get(vnodeId)?.setAttribute(readString(namePtr, nameLen), readString(valPtr, valLen));
|
|
830
830
|
},
|
|
831
|
+
_sp: (vnodeId, namePtr, nameLen, valPtr, valLen) => {
|
|
832
|
+
const el = domNodes.get(vnodeId);
|
|
833
|
+
if (el) {
|
|
834
|
+
const name = readString(namePtr, nameLen);
|
|
835
|
+
const val = readString(valPtr, valLen);
|
|
836
|
+
if (name === "checked" || name === "selected" || name === "muted") {
|
|
837
|
+
el[name] = val !== "false";
|
|
838
|
+
} else {
|
|
839
|
+
el[name] = val;
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
},
|
|
831
843
|
_ra: (vnodeId, namePtr, nameLen) => {
|
|
832
844
|
domNodes.get(vnodeId)?.removeAttribute(readString(namePtr, nameLen));
|
|
833
845
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ziex",
|
|
3
|
-
"version": "0.1.0-dev.
|
|
3
|
+
"version": "0.1.0-dev.1050",
|
|
4
4
|
"description": "ZX is a framework for building web applications with Zig.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"license": "MIT",
|
|
38
38
|
"scripts": {},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@ziex/cli": "0.1.0-dev.
|
|
40
|
+
"@ziex/cli": "0.1.0-dev.1050"
|
|
41
41
|
},
|
|
42
42
|
"peerDependenciesMeta": {
|
|
43
43
|
"react": {
|
package/runtime.d.ts
CHANGED
|
@@ -58,9 +58,9 @@ export declare function run({ request, env, ctx, module, kv: kvBindings, db: dbB
|
|
|
58
58
|
waitUntil(promise: Promise<unknown>): void;
|
|
59
59
|
};
|
|
60
60
|
module: WebAssembly.Module;
|
|
61
|
-
/** KV namespace bindings
|
|
61
|
+
/** KV namespace bindings - `{ default: env.KV, otherName: env.OTHER_KV }` */
|
|
62
62
|
kv?: Record<string, KVNamespace>;
|
|
63
|
-
/** D1 bindings
|
|
63
|
+
/** D1 bindings - `{ default: env.DB, analytics: env.ANALYTICS_DB }` */
|
|
64
64
|
db?: Record<string, D1Database>;
|
|
65
65
|
imports?: (mem: () => WebAssembly.Memory) => Record<string, Record<string, unknown>>;
|
|
66
66
|
wasi?: WASI;
|
package/vercel/index.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ type FetchApp = {
|
|
|
20
20
|
* Wrap a Ziex app as a Vercel Edge Function handler.
|
|
21
21
|
*
|
|
22
22
|
* Returns a standard `(req: Request) => Promise<Response>` function.
|
|
23
|
-
* Vercel's edge runtime calls it directly
|
|
23
|
+
* Vercel's edge runtime calls it directly - just export it as default.
|
|
24
24
|
*/
|
|
25
25
|
export declare function handle(app: FetchApp): (req: Request) => Promise<Response>;
|
|
26
26
|
export {};
|
package/wasm/core.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ZigJS } from "../../../../vendor/jsz/js/src";
|
|
2
2
|
/**
|
|
3
|
-
* Core WASM bridge
|
|
3
|
+
* Core WASM bridge - environment-agnostic (browser + edge).
|
|
4
4
|
* Contains no references to browser globals (document, window, WebSocket, HTMLFormElement).
|
|
5
5
|
*/
|
|
6
6
|
export declare const CallbackType: {
|
|
@@ -24,7 +24,7 @@ export type WsOnCloseHandler = (wsId: bigint, code: number, reasonPtr: number, r
|
|
|
24
24
|
export declare const jsz: ZigJS;
|
|
25
25
|
/** Store a value using jsz.storeValue and get the 64-bit reference. */
|
|
26
26
|
export declare function storeValueGetRef(val: any): bigint;
|
|
27
|
-
/** Shared encoder/decoder
|
|
27
|
+
/** Shared encoder/decoder - avoids allocating new instances on every call. */
|
|
28
28
|
export declare const textDecoder: TextDecoder;
|
|
29
29
|
export declare const textEncoder: TextEncoder;
|
|
30
30
|
export declare function getMemoryView(): Uint8Array;
|
|
@@ -35,7 +35,7 @@ export declare function writeBytes(ptr: number, data: Uint8Array): void;
|
|
|
35
35
|
export declare function wrapPromisingExport<F extends (...args: any[]) => any>(fn: F | undefined): F | undefined;
|
|
36
36
|
export declare function invokeWasmExport<F extends (...args: any[]) => any>(fn: F | undefined, ...args: Parameters<F>): void;
|
|
37
37
|
/**
|
|
38
|
-
* Core ZX Bridge
|
|
38
|
+
* Core ZX Bridge - works in both browser and edge runtimes.
|
|
39
39
|
* Contains fetch, timers, and logging. No DOM or browser-WebSocket references.
|
|
40
40
|
*
|
|
41
41
|
* Extend this class in browser environments to add DOM and WebSocket support.
|
package/wasm/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export type { CallbackTypeValue } from "./core";
|
|
|
3
3
|
import { ZxBridgeCore } from "./core";
|
|
4
4
|
import { type KVNamespace } from "../kv";
|
|
5
5
|
/**
|
|
6
|
-
* Browser ZX Bridge
|
|
6
|
+
* Browser ZX Bridge - extends ZxBridgeCore with DOM, WebSocket, and form-action support.
|
|
7
7
|
* Import this from environments that have access to browser globals.
|
|
8
8
|
* For edge runtimes, import ZxBridgeCore from ./core instead.
|
|
9
9
|
*/
|
package/wasm/index.js
CHANGED
|
@@ -828,6 +828,18 @@ class ZxBridge extends ZxBridgeCore {
|
|
|
828
828
|
_sa: (vnodeId, namePtr, nameLen, valPtr, valLen) => {
|
|
829
829
|
domNodes.get(vnodeId)?.setAttribute(readString(namePtr, nameLen), readString(valPtr, valLen));
|
|
830
830
|
},
|
|
831
|
+
_sp: (vnodeId, namePtr, nameLen, valPtr, valLen) => {
|
|
832
|
+
const el = domNodes.get(vnodeId);
|
|
833
|
+
if (el) {
|
|
834
|
+
const name = readString(namePtr, nameLen);
|
|
835
|
+
const val = readString(valPtr, valLen);
|
|
836
|
+
if (name === "checked" || name === "selected" || name === "muted") {
|
|
837
|
+
el[name] = val !== "false";
|
|
838
|
+
} else {
|
|
839
|
+
el[name] = val;
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
},
|
|
831
843
|
_ra: (vnodeId, namePtr, nameLen) => {
|
|
832
844
|
domNodes.get(vnodeId)?.removeAttribute(readString(namePtr, nameLen));
|
|
833
845
|
},
|
package/wasm/init.js
CHANGED
|
@@ -790,6 +790,18 @@ class ZxBridge extends ZxBridgeCore {
|
|
|
790
790
|
_sa: (vnodeId, namePtr, nameLen, valPtr, valLen) => {
|
|
791
791
|
domNodes.get(vnodeId)?.setAttribute(readString(namePtr, nameLen), readString(valPtr, valLen));
|
|
792
792
|
},
|
|
793
|
+
_sp: (vnodeId, namePtr, nameLen, valPtr, valLen) => {
|
|
794
|
+
const el = domNodes.get(vnodeId);
|
|
795
|
+
if (el) {
|
|
796
|
+
const name = readString(namePtr, nameLen);
|
|
797
|
+
const val = readString(valPtr, valLen);
|
|
798
|
+
if (name === "checked" || name === "selected" || name === "muted") {
|
|
799
|
+
el[name] = val !== "false";
|
|
800
|
+
} else {
|
|
801
|
+
el[name] = val;
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
},
|
|
793
805
|
_ra: (vnodeId, namePtr, nameLen) => {
|
|
794
806
|
domNodes.get(vnodeId)?.removeAttribute(readString(namePtr, nameLen));
|
|
795
807
|
},
|
package/wasm/wasi.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* WASI/edge WASM bridge
|
|
2
|
+
* WASI/edge WASM bridge - zero dependencies on ZigJS (jsz) or browser globals.
|
|
3
3
|
*
|
|
4
4
|
* Import this (and only this) from edge/server runtimes. It provides the
|
|
5
5
|
* minimal __zx import namespace needed by server-side WASM: log, fetch, and
|
|
6
|
-
* timers. The jsz importObject is intentionally omitted
|
|
6
|
+
* timers. The jsz importObject is intentionally omitted - the server binary
|
|
7
7
|
* does not use jsz value-passing.
|
|
8
8
|
*/
|
|
9
9
|
export declare class ZxWasiBridge {
|
|
@@ -18,7 +18,7 @@ export declare class ZxWasiBridge {
|
|
|
18
18
|
* Create the WASI import object for WASM instantiation.
|
|
19
19
|
*
|
|
20
20
|
* Returns only the `__zx` namespace (log, fetch, timers).
|
|
21
|
-
* Does NOT include jsz.importObject()
|
|
21
|
+
* Does NOT include jsz.importObject() - the server binary does not use jsz.
|
|
22
22
|
*/
|
|
23
23
|
static createImportObject(bridgeRef: {
|
|
24
24
|
current: ZxWasiBridge | null;
|