ziex 0.1.0-dev.1458 → 0.1.0-dev.1567

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 CHANGED
@@ -6,10 +6,11 @@ A full-stack web framework for Zig. Declarative UI components using familiar pat
6
6
 
7
7
  Ziex combines the power and performance of Zig with the expressiveness and simplicity of declarative UI, enabling you to build fast, type-safe web applications.
8
8
 
9
- **[Documentation →](https://ziex.dev/learn)**
10
9
 
11
10
  > **Note:** Most of the API and syntax are finalized and stable, and server-side rendering (SSR) features are production-ready, Ziex continues to evolve with ongoing improvements to client-side rendering and state management, see the [roadmap](#roadmap). You can start using the documented features today, as they are stable and unlikely to change. Areas still under development are not yet documented and will be added as they mature. See [versions](#versions) for Zig and Ziex versions compatibility.
12
11
 
12
+ **[Documentation →](https://ziex.dev/learn)**
13
+
13
14
  ## Getting Started
14
15
 
15
16
  ### 1. Installing CLI (optional)
@@ -181,13 +182,6 @@ The [`0.1.0`](https://github.com/ziex-dev/ziex/milestone/2) release will indicat
181
182
 
182
183
  The [`1.0.0`](https://github.com/ziex-dev/ziex/milestone/6) release will signify long-term support for that major version, receiving bug fixes and minor updates.
183
184
 
184
- ## Editor Support
185
-
186
- - [VSCode](https://marketplace.visualstudio.com/items?itemName=ziex.ziex)/[VSCode Forks](https://open-vsx.org/extension/ziex/ziex)
187
- - [Neovim](/ide/neovim/)
188
- - [Helix](/ide/helix/)
189
- - [Zed](/ide/zed/)
190
-
191
185
  ## Community
192
186
 
193
187
  - [Discord](https://ziex.dev/r/discord)
@@ -198,4 +192,4 @@ The [`1.0.0`](https://github.com/ziex-dev/ziex/milestone/6) release will signify
198
192
 
199
193
  ## Contributing
200
194
 
201
- Contributions are welcome! Currently trying out Ziex and reporting issues for edge cases and providing feedback are greatly appreciated.
195
+ Contributions are welcome! Trying out Ziex, reporting issues (especially edge cases), and providing feedback are greatly appreciated. You can also look through the [open issues](https://github.com/ziex-dev/ziex/issues) to find something to work on.
package/app.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import type { DurableObjectNamespace } from "./runtime";
2
1
  import type { KVNamespace } from "./runtime/kv";
3
2
  import type { Database } from "./runtime/db";
4
3
  import type { WASI } from "./runtime/wasi";
@@ -16,18 +15,27 @@ export type WasmInput = WebAssembly.Module | ArrayBuffer | ArrayBufferView | Res
16
15
  * The result is NOT cached here - cache it at the call site if needed.
17
16
  */
18
17
  export declare function resolveModule(input: WasmInput): Promise<WebAssembly.Module>;
19
- /** Keys of `Env` whose value extends {@link KVNamespace}. */
18
+ /** Keys of `Env` with a KV-like binding (host KV types rarely `extends` our interface). */
20
19
  type KVKey<Env> = {
21
- [K in keyof Env]: Env[K] extends KVNamespace ? K : never;
20
+ [K in keyof Env]-?: Env[K] extends {
21
+ get(...args: any[]): any;
22
+ put(...args: any[]): any;
23
+ } ? K : never;
22
24
  }[keyof Env];
23
- /** Keys of `Env` whose value extends {@link DurableObjectNamespace}. */
24
- type DOKey<Env> = {
25
- [K in keyof Env]: Env[K] extends DurableObjectNamespace ? K : never;
25
+ /** Keys of `Env` whose value is a sticky long-lived fetch namespace. */
26
+ export type StickyKey<Env> = {
27
+ [K in keyof Env]-?: Env[K] extends {
28
+ idFromName(name: string): any;
29
+ get(id: any, ...args: any[]): any;
30
+ } ? K : never;
26
31
  }[keyof Env];
32
+ /** Keys of `Env` with a SQL prepare() binding (e.g. D1). */
27
33
  type DBKey<Env> = {
28
- [K in keyof Env]: Env[K] extends Database ? K : never;
34
+ [K in keyof Env]-?: Env[K] extends {
35
+ prepare(query: string): any;
36
+ } ? K : never;
29
37
  }[keyof Env];
30
- type ZiexOptions<Env> = {
38
+ export type ZiexOptions<Env = Record<string, unknown>> = {
31
39
  /** WASM module - accepts any {@link WasmInput}. Resolved and cached on first request. */
32
40
  module: WasmInput;
33
41
  /** Optional pre-configured WASI instance. */
@@ -58,15 +66,10 @@ type ZiexOptions<Env> = {
58
66
  */
59
67
  db?: DBKey<Env> | Record<string, DBKey<Env>>;
60
68
  /**
61
- * Env key whose value is a `DurableObjectNamespace` for WebSocket pub/sub.
62
- * Requires `createWebSocketDO` export on the worker.
63
- *
64
- * @example
65
- * ```ts
66
- * websocket: "ChatRoom"
67
- * ```
69
+ * Env binding for sticky long-lived fetch (WebSocket upgrades, etc.).
70
+ * Prefer platform helpers (e.g. `stateful(app, binding)` on Cloudflare) over setting this directly.
68
71
  */
69
- websocket?: DOKey<Env>;
72
+ sticky?: StickyKey<Env>;
70
73
  };
71
74
  /**
72
75
  * Main Ziex application class. Mirrors the Hono API style - construct once,
@@ -77,12 +80,11 @@ type ZiexOptions<Env> = {
77
80
  * @example Cloudflare Workers / wrangler
78
81
  * ```ts
79
82
  * import { Ziex } from "ziex";
83
+ * import { stateful } from "ziex/cloudflare";
80
84
  * import module from "./app.wasm";
81
85
  *
82
- * const app = new Ziex<Env>({
83
- * module,
84
- * kv: (env) => ({ default: env.KV }),
85
- * });
86
+ * const app = new Ziex<Env>({ module, kv: "KV", db: "DB" });
87
+ * export const ChatRoom = stateful(app, { binding: "CHAT_ROOM" });
86
88
  * export default app;
87
89
  * ```
88
90
  *
@@ -105,10 +107,23 @@ type ZiexOptions<Env> = {
105
107
  * ```
106
108
  */
107
109
  export declare class Ziex<Env = Record<string, unknown>> {
108
- private readonly options;
110
+ /** @internal Platform adapters read shared config from here. */
111
+ protected readonly options: ZiexOptions<Env>;
109
112
  private resolved;
110
113
  constructor(options: ZiexOptions<Env>);
111
- private getModule;
114
+ protected getModule(): Promise<WebAssembly.Module>;
115
+ /**
116
+ * Enable sticky upgrade forwarding and return host config for platform adapters
117
+ * (e.g. Cloudflare {@linkcode stateful}).
118
+ *
119
+ * Requires `options.module` to already be a compiled `WebAssembly.Module`.
120
+ */
121
+ stickyHost(binding: StickyKey<Env>): {
122
+ module: WebAssembly.Module;
123
+ imports: ((mem: () => WebAssembly.Memory) => WebAssembly.Imports) | undefined;
124
+ kv: (env: Env) => Record<string, KVNamespace> | undefined;
125
+ db: (env: Env) => Record<string, Database> | undefined;
126
+ };
112
127
  private resolveKV;
113
128
  private resolveDB;
114
129
  /**
package/build.zig.zon CHANGED
@@ -2,6 +2,6 @@
2
2
  .name = .ziex_js,
3
3
  .fingerprint = 3758452767932569023,
4
4
  .version = "0.1.0-dev",
5
- .minimum_zig_version = "0.17.0-dev.1465+8b2d0ce21",
5
+ .minimum_zig_version = "0.17.0",
6
6
  .paths = .{""},
7
7
  }
package/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export { Ziex } from "./app";
2
- export type { WasmInput } from "./app";
2
+ export type { WasmInput, ZiexOptions, StickyKey } from "./app";