ziex 0.1.0-dev.1466 → 0.1.0-dev.1568
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 -9
- package/app.d.ts +37 -22
- package/build.zig.zon +1 -1
- package/index.d.ts +1 -1
- package/index.js +239 -218
- package/package.json +2 -2
- package/platforms/aws-lambda/index.d.ts +1 -1
- package/platforms/cloudflare/app.d.ts +31 -1
- package/platforms/cloudflare/index.d.ts +5 -4
- package/platforms/cloudflare/index.js +1722 -1645
- package/platforms/cloudflare/kv.d.ts +4 -2
- package/platforms/cloudflare/stateful.d.ts +26 -0
- package/platforms/cloudflare/worker.d.ts +1 -2
- package/platforms/vercel/index.d.ts +1 -1
- package/runtime/index.d.ts +20 -10
- package/runtime/kv/indexdb.d.ts +11 -3
- package/runtime/kv/localstorage.d.ts +11 -3
- package/runtime/kv/memory.d.ts +13 -6
- package/runtime/kv.d.ts +16 -18
- package/runtime/kv.js +178 -241
- package/runtime/wasi.d.ts +2 -7
- package/wasm/dom_cmd.d.ts +0 -9
- package/wasm/index.js +224 -188
- package/wasm/init.dev.js +224 -188
- package/wasm/init.js +3 -3
- package/platforms/cloudflare/do.d.ts +0 -50
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Cloudflare KV
|
|
2
|
+
* Cloudflare KV can be used as a {@link KVNamespace} binding
|
|
3
|
+
* (`delete` is accepted as `del` by the host imports).
|
|
3
4
|
*/
|
|
4
|
-
export {
|
|
5
|
+
export { createKVImports } from "../../runtime/kv";
|
|
5
6
|
export type { KVNamespace } from "../../runtime/kv";
|
|
7
|
+
export { get, put, del, list } from "../../runtime/kv/memory";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { WsState } from "../../runtime";
|
|
2
|
+
import type { KVNamespace } from "../../runtime/kv";
|
|
3
|
+
import type { Database } from "../../runtime/db";
|
|
4
|
+
type ConnState = WsState & {
|
|
5
|
+
topics: Set<string>;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Build a sticky long-lived fetch class for the host runtime.
|
|
9
|
+
*
|
|
10
|
+
* Prefer {@link stateful} so the handler reuses the app's module/kv/db.
|
|
11
|
+
*
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
export declare function createStatefulFetch(module: WebAssembly.Module, options?: {
|
|
15
|
+
kv?: (env: any) => Record<string, KVNamespace>;
|
|
16
|
+
db?: (env: any) => Record<string, Database>;
|
|
17
|
+
imports?: (mem: () => WebAssembly.Memory) => WebAssembly.Imports;
|
|
18
|
+
}): {
|
|
19
|
+
new (state: any, env: any): {
|
|
20
|
+
readonly state: any;
|
|
21
|
+
readonly env: any;
|
|
22
|
+
readonly connections: Map<WebSocket, ConnState>;
|
|
23
|
+
fetch(request: Request): Promise<Response>;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
export {};
|
package/runtime/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { WASI } from "./wasi";
|
|
2
|
-
import {
|
|
2
|
+
import type { KVNamespace } from "./kv";
|
|
3
3
|
import type { Database } from "./db";
|
|
4
|
-
/** Minimal
|
|
5
|
-
export type
|
|
4
|
+
/** Minimal sticky long-lived fetch namespace shape (e.g. Cloudflare Durable Object binding). */
|
|
5
|
+
export type StickyNamespace = {
|
|
6
6
|
idFromName(name: string): unknown;
|
|
7
|
-
get(id:
|
|
8
|
-
fetch(
|
|
7
|
+
get(id: any): {
|
|
8
|
+
fetch(request: Request): Promise<Response>;
|
|
9
9
|
};
|
|
10
10
|
};
|
|
11
11
|
export type WsState = {
|
|
@@ -21,6 +21,16 @@ export type WsState = {
|
|
|
21
21
|
publish?: (topic: string, data: Uint8Array) => number;
|
|
22
22
|
isSubscribed?: (topic: string) => boolean;
|
|
23
23
|
};
|
|
24
|
+
type HttpState = {
|
|
25
|
+
committed: boolean;
|
|
26
|
+
ended: boolean;
|
|
27
|
+
status: number;
|
|
28
|
+
streaming: boolean;
|
|
29
|
+
headers: Headers;
|
|
30
|
+
bodyChunks: Uint8Array[];
|
|
31
|
+
streamWriter: WritableStreamDefaultWriter<Uint8Array> | null;
|
|
32
|
+
};
|
|
33
|
+
export declare function buildHttpImports(mem: () => WebAssembly.Memory, http: HttpState): WebAssembly.ModuleImports;
|
|
24
34
|
/** Build the __zx_ws import object for a given connection state. */
|
|
25
35
|
export declare function buildWsImports(Suspending: any, mem: () => WebAssembly.Memory, decoder: TextDecoder, ws: WsState): WebAssembly.ModuleImports;
|
|
26
36
|
/** Create WebSocketPair, wire message/close listeners, flush pending writes. */
|
|
@@ -42,7 +52,7 @@ export declare function attachWebSocket(ws: WsState): {
|
|
|
42
52
|
* });
|
|
43
53
|
* ```
|
|
44
54
|
*/
|
|
45
|
-
export declare function run({ request, env, ctx, module, kv: kvBindings, db: dbBindings, imports, wasi,
|
|
55
|
+
export declare function run({ request, env, ctx, module, kv: kvBindings, db: dbBindings, imports, wasi, sticky, }: {
|
|
46
56
|
request: Request;
|
|
47
57
|
env?: unknown;
|
|
48
58
|
ctx?: {
|
|
@@ -56,9 +66,9 @@ export declare function run({ request, env, ctx, module, kv: kvBindings, db: dbB
|
|
|
56
66
|
imports?: (mem: () => WebAssembly.Memory) => WebAssembly.Imports;
|
|
57
67
|
wasi?: WASI;
|
|
58
68
|
/**
|
|
59
|
-
*
|
|
60
|
-
* When provided,
|
|
61
|
-
* the DO so that pub/sub works across multiple connected clients.
|
|
69
|
+
* Sticky namespace for long-lived fetch (WebSocket upgrades).
|
|
70
|
+
* When provided, upgrade requests are forwarded so pub/sub works across clients.
|
|
62
71
|
*/
|
|
63
|
-
|
|
72
|
+
sticky?: StickyNamespace;
|
|
64
73
|
}): Promise<Response>;
|
|
74
|
+
export {};
|
package/runtime/kv/indexdb.d.ts
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
export type IndexedDbKVOptions = {
|
|
1
|
+
export type Options = {
|
|
3
2
|
databaseName?: string;
|
|
4
3
|
storeName?: string;
|
|
5
4
|
namespace?: string;
|
|
6
5
|
};
|
|
7
|
-
export declare function
|
|
6
|
+
export declare function get(key: string): Promise<string | null>;
|
|
7
|
+
export declare function put(key: string, value: string): Promise<void>;
|
|
8
|
+
export declare function del(key: string): Promise<void>;
|
|
9
|
+
export declare function list(options?: {
|
|
10
|
+
prefix?: string;
|
|
11
|
+
}): Promise<{
|
|
12
|
+
keys: {
|
|
13
|
+
name: string;
|
|
14
|
+
}[];
|
|
15
|
+
}>;
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
export type LocalStorageKVOptions = {
|
|
1
|
+
export type Options = {
|
|
3
2
|
namespace?: string;
|
|
4
3
|
storagePrefix?: string;
|
|
5
4
|
};
|
|
6
|
-
export declare function
|
|
5
|
+
export declare function get(key: string): string | null;
|
|
6
|
+
export declare function put(key: string, value: string): void;
|
|
7
|
+
export declare function del(key: string): void;
|
|
8
|
+
export declare function list(options?: {
|
|
9
|
+
prefix?: string;
|
|
10
|
+
}): {
|
|
11
|
+
keys: {
|
|
12
|
+
name: string;
|
|
13
|
+
}[];
|
|
14
|
+
};
|
package/runtime/kv/memory.d.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export declare function
|
|
1
|
+
export declare function get(key: string): Promise<string | null>;
|
|
2
|
+
export declare function put(key: string, value: string, options?: {
|
|
3
|
+
expiration?: number;
|
|
4
|
+
expirationTtl?: number;
|
|
5
|
+
}): Promise<void>;
|
|
6
|
+
export declare function del(key: string): Promise<void>;
|
|
7
|
+
export declare function list(options?: {
|
|
8
|
+
prefix?: string;
|
|
9
|
+
}): Promise<{
|
|
10
|
+
keys: {
|
|
11
|
+
name: string;
|
|
12
|
+
}[];
|
|
13
|
+
}>;
|
package/runtime/kv.d.ts
CHANGED
|
@@ -1,29 +1,32 @@
|
|
|
1
1
|
export type { WasmAllocRef } from "../wasm/core";
|
|
2
|
-
|
|
2
|
+
export { createKVImports } from "./kv/extern";
|
|
3
|
+
import { type Options as IndexedDbOptions } from "./kv/indexdb";
|
|
4
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
5
|
+
/** Key/value namespace binding (get/put/del/list). */
|
|
3
6
|
export interface KVNamespace {
|
|
4
|
-
get(key: string):
|
|
7
|
+
get(key: string): MaybePromise<string | null>;
|
|
5
8
|
put(key: string, value: string, options?: {
|
|
6
9
|
expiration?: number;
|
|
7
10
|
expirationTtl?: number;
|
|
8
|
-
}):
|
|
9
|
-
|
|
11
|
+
}): MaybePromise<void>;
|
|
12
|
+
del(key: string): MaybePromise<void>;
|
|
10
13
|
list(options?: {
|
|
11
14
|
prefix?: string;
|
|
12
|
-
}):
|
|
15
|
+
}): MaybePromise<{
|
|
13
16
|
keys: {
|
|
14
17
|
name: string;
|
|
15
18
|
}[];
|
|
16
19
|
}>;
|
|
17
20
|
}
|
|
18
|
-
/** Synchronous KV used when JSPI is unavailable (e.g. localStorage). */
|
|
19
|
-
export interface SyncKVNamespace
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
/** Synchronous KV used when JSPI is unavailable (e.g. localStorage). Same method names, sync returns. */
|
|
22
|
+
export interface SyncKVNamespace {
|
|
23
|
+
get(key: string): string | null;
|
|
24
|
+
put(key: string, value: string, options?: {
|
|
22
25
|
expiration?: number;
|
|
23
26
|
expirationTtl?: number;
|
|
24
27
|
}): void;
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
del(key: string): void;
|
|
29
|
+
list(options?: {
|
|
27
30
|
prefix?: string;
|
|
28
31
|
}): {
|
|
29
32
|
keys: {
|
|
@@ -31,15 +34,10 @@ export interface SyncKVNamespace extends KVNamespace {
|
|
|
31
34
|
}[];
|
|
32
35
|
};
|
|
33
36
|
}
|
|
34
|
-
export
|
|
35
|
-
export { createLocalStorageKV, type LocalStorageKVOptions } from "./kv/localstorage";
|
|
36
|
-
export { createIndexedDbKV, type IndexedDbKVOptions } from "./kv/indexdb";
|
|
37
|
-
export { createKVImports } from "./kv/extern";
|
|
38
|
-
import { type IndexedDbKVOptions } from "./kv/indexdb";
|
|
39
|
-
export type BrowserKVOptions = IndexedDbKVOptions & {
|
|
37
|
+
export type BrowserKVOptions = IndexedDbOptions & {
|
|
40
38
|
storagePrefix?: string;
|
|
41
39
|
forceLocalStorage?: boolean;
|
|
42
40
|
};
|
|
43
|
-
export declare
|
|
41
|
+
export declare const hasJspi: boolean;
|
|
44
42
|
/** Prefer IndexedDB when JSPI is available, otherwise localStorage. */
|
|
45
43
|
export declare function createBrowserKVBindings(options?: BrowserKVOptions): Record<string, KVNamespace>;
|