ziex 0.1.0-dev.787 → 0.1.0-dev.805
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/README.md +3 -1
- package/app.d.ts +112 -0
- package/build.zig +5 -0
- package/build.zig.zon +7 -0
- package/cloudflare/app.d.ts +2 -95
- package/cloudflare/do.d.ts +48 -0
- package/cloudflare/index.d.ts +4 -4
- package/cloudflare/index.js +470 -276
- package/cloudflare/kv.d.ts +2 -27
- package/cloudflare/worker.d.ts +3 -148
- package/index.d.ts +2 -1
- package/index.js +257 -1028
- package/kv.d.ts +27 -0
- package/package.json +1 -5
- package/runtime.d.ts +70 -0
- package/wasi.d.ts +61 -0
- package/wasm/core.d.ts +78 -0
- package/wasm/index.d.ts +9 -35
- package/wasm/index.js +103 -59
- package/wasm/init.js +97 -59
- package/wasm/wasi.d.ts +28 -0
- package/hono/index.d.ts +0 -92
- package/hono/index.js +0 -1515
package/cloudflare/kv.d.ts
CHANGED
|
@@ -1,27 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
put(key: string, value: string, options?: {
|
|
4
|
-
expiration?: number;
|
|
5
|
-
expirationTtl?: number;
|
|
6
|
-
}): Promise<void>;
|
|
7
|
-
delete(key: string): Promise<void>;
|
|
8
|
-
list(options?: {
|
|
9
|
-
prefix?: string;
|
|
10
|
-
}): Promise<{
|
|
11
|
-
keys: {
|
|
12
|
-
name: string;
|
|
13
|
-
}[];
|
|
14
|
-
}>;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* In-memory KV namespace. Used as the default shim on platforms that don't
|
|
18
|
-
* provide a real KV binding (e.g. Vercel). Data lives only for the lifetime
|
|
19
|
-
* of the isolate instance.
|
|
20
|
-
*/
|
|
21
|
-
export declare function createMemoryKV(): KVNamespace;
|
|
22
|
-
/**
|
|
23
|
-
* Create a `__zx_kv` import object for use with `worker.run({ kv: ... })`.
|
|
24
|
-
* Always returns a valid import object. When JSPI is unavailable all KV
|
|
25
|
-
* operations are stubbed (get → not-found, put/delete → success, list → []).
|
|
26
|
-
*/
|
|
27
|
-
export declare function createKVImports(bindings: Record<string, KVNamespace>, getMemory: () => WebAssembly.Memory): Record<string, unknown>;
|
|
1
|
+
export { createMemoryKV, createKVImports } from "../kv";
|
|
2
|
+
export type { KVNamespace } from "../kv";
|
package/cloudflare/worker.d.ts
CHANGED
|
@@ -1,148 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* Pass `kv` as a map of binding names → KV namespaces. The Zig side selects
|
|
5
|
-
* a binding via `zx.kv.scope("name")`; the top-level `zx.kv.*` functions use
|
|
6
|
-
* `"default"`.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```ts
|
|
10
|
-
* return worker.run({
|
|
11
|
-
* request, env, ctx, wasmModule,
|
|
12
|
-
* kv: { default: env.KV, users: env.USERS_KV },
|
|
13
|
-
* });
|
|
14
|
-
* ```
|
|
15
|
-
*/
|
|
16
|
-
/** Minimal Durable Object namespace shape needed for WebSocket routing. */
|
|
17
|
-
type DurableObjectNamespace = {
|
|
18
|
-
idFromName(name: string): unknown;
|
|
19
|
-
get(id: unknown): {
|
|
20
|
-
fetch(req: Request): Promise<Response>;
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
export declare function run({ request, env, ctx, module, kv: kvBindings, imports, wasi, websocket: doNamespace, }: {
|
|
24
|
-
request: Request;
|
|
25
|
-
env?: unknown;
|
|
26
|
-
ctx?: {
|
|
27
|
-
waitUntil(promise: Promise<unknown>): void;
|
|
28
|
-
};
|
|
29
|
-
module: WebAssembly.Module;
|
|
30
|
-
/** KV namespace bindings — `{ default: env.KV, otherName: env.OTHER_KV }` */
|
|
31
|
-
kv?: Record<string, import("./kv").KVNamespace>;
|
|
32
|
-
imports?: (mem: () => WebAssembly.Memory) => Record<string, Record<string, unknown>>;
|
|
33
|
-
wasi?: WASI;
|
|
34
|
-
/**
|
|
35
|
-
* Durable Object namespace to use for WebSocket connections.
|
|
36
|
-
* When provided, WebSocket upgrade requests are automatically forwarded to
|
|
37
|
-
* the DO so that pub/sub works across multiple connected clients.
|
|
38
|
-
*
|
|
39
|
-
* The DO class must be created with `createWebSocketDO` and exported from
|
|
40
|
-
* your worker:
|
|
41
|
-
*
|
|
42
|
-
* ```ts
|
|
43
|
-
* export const MyDO = createWebSocketDO(module);
|
|
44
|
-
* export default {
|
|
45
|
-
* fetch: (req, env, ctx) => run({ request: req, ctx, module, websocket: env.MyDO }),
|
|
46
|
-
* };
|
|
47
|
-
* ```
|
|
48
|
-
*/
|
|
49
|
-
websocket?: DurableObjectNamespace;
|
|
50
|
-
}): Promise<Response>;
|
|
51
|
-
type WsState = {
|
|
52
|
-
upgraded: boolean;
|
|
53
|
-
server: WebSocket | null;
|
|
54
|
-
pendingWrites: Uint8Array[];
|
|
55
|
-
messageQueue: Uint8Array[];
|
|
56
|
-
recvResolve: ((bytes: Uint8Array | null) => void) | null;
|
|
57
|
-
/** Resolved when ws_recv is called for the first time (WASM has entered the message loop). */
|
|
58
|
-
_resolveFirstSuspend?: () => void;
|
|
59
|
-
subscribe?: (topic: string) => void;
|
|
60
|
-
unsubscribe?: (topic: string) => void;
|
|
61
|
-
publish?: (topic: string, data: Uint8Array) => number;
|
|
62
|
-
isSubscribed?: (topic: string) => boolean;
|
|
63
|
-
};
|
|
64
|
-
type ConnState = WsState & {
|
|
65
|
-
topics: Set<string>;
|
|
66
|
-
};
|
|
67
|
-
/**
|
|
68
|
-
* Create a Durable Object class that handles WebSocket connections for a ZX app.
|
|
69
|
-
*
|
|
70
|
-
* Each DO instance corresponds to one "room" (keyed by pathname). All clients
|
|
71
|
-
* connecting to the same route share a DO instance, enabling pub/sub via
|
|
72
|
-
* `ctx.socket.subscribe()` / `ctx.socket.publish()`.
|
|
73
|
-
*
|
|
74
|
-
* @example
|
|
75
|
-
* ```ts
|
|
76
|
-
* // worker.ts
|
|
77
|
-
* import { run, createWebSocketDO } from "ziex/cloudflare";
|
|
78
|
-
* import module from "./app.wasm";
|
|
79
|
-
*
|
|
80
|
-
* export const ZxWS = createWebSocketDO(module);
|
|
81
|
-
*
|
|
82
|
-
* export default {
|
|
83
|
-
* fetch: (req: Request, env: any, ctx: any) =>
|
|
84
|
-
* run({ request: req, ctx, module, websocket: env.ZxWS }),
|
|
85
|
-
* };
|
|
86
|
-
* ```
|
|
87
|
-
*/
|
|
88
|
-
export declare function createWebSocketDO(module: WebAssembly.Module, options?: {
|
|
89
|
-
/**
|
|
90
|
-
* KV namespace bindings for the DO. Pass a factory that receives the DO's
|
|
91
|
-
* `env` so bindings are resolved at runtime:
|
|
92
|
-
*
|
|
93
|
-
* ```ts
|
|
94
|
-
* createWebSocketDO(module, { kv: (env) => ({ default: env.KV }) })
|
|
95
|
-
* ```
|
|
96
|
-
*/
|
|
97
|
-
kv?: (env: any) => Record<string, import("./kv").KVNamespace>;
|
|
98
|
-
imports?: (mem: () => WebAssembly.Memory) => Record<string, Record<string, unknown>>;
|
|
99
|
-
}): {
|
|
100
|
-
new (state: any, env: any): {
|
|
101
|
-
readonly doState: any;
|
|
102
|
-
readonly env: any;
|
|
103
|
-
/** All active connections in this room, keyed by their server-side WebSocket. */
|
|
104
|
-
readonly connections: Map<WebSocket, ConnState>;
|
|
105
|
-
fetch(request: Request): Promise<Response>;
|
|
106
|
-
};
|
|
107
|
-
};
|
|
108
|
-
export declare function prepare({ request, env, ctx, }: {
|
|
109
|
-
request: Request;
|
|
110
|
-
env: unknown;
|
|
111
|
-
ctx: unknown;
|
|
112
|
-
}): {
|
|
113
|
-
args: string[];
|
|
114
|
-
stdout: TransformStream<any, any>;
|
|
115
|
-
stderr: TransformStream<any, any>;
|
|
116
|
-
stdin: ReadableStream<Uint8Array<ArrayBufferLike>> | undefined;
|
|
117
|
-
};
|
|
118
|
-
export declare function respond({ exec, stdout, stderr, }: {
|
|
119
|
-
exec: Promise<number | undefined>;
|
|
120
|
-
stdout: TransformStream;
|
|
121
|
-
stderr: TransformStream | ReadableStream<Uint8Array>;
|
|
122
|
-
}): Promise<Response>;
|
|
123
|
-
type WASI = {
|
|
124
|
-
args?: Array<string>;
|
|
125
|
-
env?: Array<string>;
|
|
126
|
-
fds?: Array<unknown>;
|
|
127
|
-
inst?: {
|
|
128
|
-
exports: {
|
|
129
|
-
memory: WebAssembly.Memory;
|
|
130
|
-
};
|
|
131
|
-
};
|
|
132
|
-
wasiImport: Record<string, Function> | {
|
|
133
|
-
[key: string]: (...args: Array<any>) => unknown;
|
|
134
|
-
};
|
|
135
|
-
start(instance: {
|
|
136
|
-
exports: {
|
|
137
|
-
memory: WebAssembly.Memory;
|
|
138
|
-
_start: () => unknown;
|
|
139
|
-
};
|
|
140
|
-
}): number;
|
|
141
|
-
initialize?(instance: {
|
|
142
|
-
exports: {
|
|
143
|
-
memory: WebAssembly.Memory;
|
|
144
|
-
_initialize?: () => unknown;
|
|
145
|
-
};
|
|
146
|
-
}): void;
|
|
147
|
-
};
|
|
148
|
-
export {};
|
|
1
|
+
export { run, buildWsImports, attachWebSocket } from "../runtime";
|
|
2
|
+
export type { DurableObjectNamespace, WsState } from "../runtime";
|
|
3
|
+
export { createWebSocketDO } from "./do";
|
package/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { Ziex } from "./
|
|
1
|
+
export { Ziex } from "./app";
|
|
2
|
+
export type { WasmInput } from "./app";
|