ziex 0.0.1-dev.7 → 0.1.0-dev.1000

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.
@@ -0,0 +1,13 @@
1
+ import type { KVNamespace, SyncKVNamespace } from "../kv";
2
+ export type IndexedDbKVOptions = {
3
+ databaseName?: string;
4
+ storeName?: string;
5
+ namespace?: string;
6
+ };
7
+ export type BrowserKVOptions = IndexedDbKVOptions & {
8
+ storagePrefix?: string;
9
+ };
10
+ export declare function createIndexedDbKV(options?: IndexedDbKVOptions): KVNamespace;
11
+ export declare function createLocalStorageKV(options?: BrowserKVOptions): SyncKVNamespace;
12
+ export declare function hasJSPI(): boolean;
13
+ export declare function createBrowserKVBindings(options?: BrowserKVOptions): Record<string, KVNamespace>;
package/build.zig ADDED
@@ -0,0 +1,5 @@
1
+ const std = @import("std");
2
+
3
+ pub fn build(b: *std.Build) void {
4
+ _ = b; // stub
5
+ }
package/build.zig.zon ADDED
@@ -0,0 +1,7 @@
1
+ .{
2
+ .name = .ziex_js,
3
+ .fingerprint = 0x3428b4e119b455bf,
4
+ .version = "0.1.0-dev.804",
5
+ .minimum_zig_version = "0.15.2",
6
+ .paths = .{""},
7
+ }
@@ -0,0 +1,2 @@
1
+ export { Ziex, resolveModule } from "../app";
2
+ export type { WasmInput } from "../app";
@@ -0,0 +1,2 @@
1
+ export { createD1Imports } from "../db";
2
+ export type { D1Database, D1PreparedStatement, D1ExecResult, D1Value } from "../db";
@@ -0,0 +1,50 @@
1
+ import type { WsState } from "../runtime";
2
+ import type { KVNamespace } from "../kv";
3
+ import type { D1Database } from "../db";
4
+ type ConnState = WsState & {
5
+ topics: Set<string>;
6
+ };
7
+ /**
8
+ * Create a Durable Object class that handles WebSocket connections for a ZX app.
9
+ *
10
+ * Each DO instance corresponds to one "room" (keyed by pathname). All clients
11
+ * connecting to the same route share a DO instance, enabling pub/sub via
12
+ * `ctx.socket.subscribe()` / `ctx.socket.publish()`.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * // worker.ts
17
+ * import { Ziex } from "ziex";
18
+ * import { createWebSocketDO } from "ziex/cloudflare";
19
+ * import module from "./app.wasm";
20
+ *
21
+ * export const ZxWS = createWebSocketDO(module);
22
+ *
23
+ * export default new Ziex({
24
+ * module,
25
+ * websocket: (env) => env.ZxWS,
26
+ * });
27
+ * ```
28
+ */
29
+ export declare function createWebSocketDO(module: WebAssembly.Module, options?: {
30
+ /**
31
+ * KV namespace bindings for the DO. Pass a factory that receives the DO's
32
+ * `env` so bindings are resolved at runtime:
33
+ *
34
+ * ```ts
35
+ * createWebSocketDO(module, { kv: (env) => ({ default: env.KV }) })
36
+ * ```
37
+ */
38
+ kv?: (env: any) => Record<string, KVNamespace>;
39
+ db?: (env: any) => Record<string, D1Database>;
40
+ imports?: (mem: () => WebAssembly.Memory) => Record<string, Record<string, unknown>>;
41
+ }): {
42
+ new (state: any, env: any): {
43
+ readonly doState: any;
44
+ readonly env: any;
45
+ /** All active connections in this room, keyed by their server-side WebSocket. */
46
+ readonly connections: Map<WebSocket, ConnState>;
47
+ fetch(request: Request): Promise<Response>;
48
+ };
49
+ };
50
+ export {};
@@ -0,0 +1,4 @@
1
+ export * as worker from "../runtime";
2
+ export * as kv from "../kv";
3
+ export { Ziex } from "../app";
4
+ export { createWebSocketDO } from "./do";