ziex 0.1.0-dev.1367 → 0.1.0-dev.1377

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.
Files changed (39) hide show
  1. package/aws-lambda/index.js +20 -29
  2. package/build.zig +118 -2
  3. package/build.zig.zon +13 -2
  4. package/cloudflare/index.js +1635 -1854
  5. package/index.js +155 -216
  6. package/{pkg/ziex/src/react → jsx}/dom.d.ts +5 -9
  7. package/{pkg/ziex/src/react → jsx}/index.d.ts +1 -1
  8. package/{react → jsx}/index.js +19 -25
  9. package/{pkg/ziex/src/react → jsx}/types.d.ts +14 -9
  10. package/package.json +6 -14
  11. package/vercel/index.js +0 -15
  12. package/wasm/index.js +253 -261
  13. package/wasm/init.dev.js +242 -189
  14. package/wasm/init.js +3 -3
  15. package/pkg/ziex/src/zx.d.ts +0 -1
  16. package/vendor/jsz/js/src/index.d.ts +0 -1
  17. package/vendor/jsz/js/src/zigjs.d.ts +0 -107
  18. /package/{pkg/ziex/src/app.d.ts → app.d.ts} +0 -0
  19. /package/{pkg/ziex/src/aws-lambda → aws-lambda}/index.d.ts +0 -0
  20. /package/{pkg/ziex/src/browser → browser}/kv.d.ts +0 -0
  21. /package/{pkg/ziex/src/cloudflare → cloudflare}/app.d.ts +0 -0
  22. /package/{pkg/ziex/src/cloudflare → cloudflare}/db.d.ts +0 -0
  23. /package/{pkg/ziex/src/cloudflare → cloudflare}/do.d.ts +0 -0
  24. /package/{pkg/ziex/src/cloudflare → cloudflare}/index.d.ts +0 -0
  25. /package/{pkg/ziex/src/cloudflare → cloudflare}/kv.d.ts +0 -0
  26. /package/{pkg/ziex/src/cloudflare → cloudflare}/worker.d.ts +0 -0
  27. /package/{pkg/ziex/src/db.d.ts → db.d.ts} +0 -0
  28. /package/{pkg/ziex/src/fetch.d.ts → fetch.d.ts} +0 -0
  29. /package/{pkg/ziex/src/index.d.ts → index.d.ts} +0 -0
  30. /package/{pkg/ziex/src/kv.d.ts → kv.d.ts} +0 -0
  31. /package/{pkg/ziex/src/runtime.d.ts → runtime.d.ts} +0 -0
  32. /package/{pkg/ziex/src/vercel → vercel}/index.d.ts +0 -0
  33. /package/{pkg/ziex/src/wasi.d.ts → wasi.d.ts} +0 -0
  34. /package/{pkg/ziex/src/wasm → wasm}/core.d.ts +0 -0
  35. /package/{pkg/ziex/src/wasm → wasm}/dom.d.ts +0 -0
  36. /package/{pkg/ziex/src/wasm → wasm}/index.d.ts +0 -0
  37. /package/{pkg/ziex/src/wasm → wasm}/init.d.ts +0 -0
  38. /package/{pkg/ziex/src/wasm → wasm}/types.d.ts +0 -0
  39. /package/{pkg/ziex/src/wasm → wasm}/wasi.d.ts +0 -0
@@ -1,12 +1,8 @@
1
- import type { ComponentMetadata } from "./types";
1
+ import type { ComponentFn, ComponentMetadata } from "./types";
2
2
  export type PreparedComponent = {
3
3
  domNode: HTMLElement;
4
- props: Record<string, any> & {
5
- dangerouslySetInnerHTML?: {
6
- __html: string;
7
- };
8
- };
9
- Component: (props: any) => React.ReactElement;
4
+ props: Record<string, any>;
5
+ Component: ComponentFn;
10
6
  };
11
7
  export declare function prepareComponent(component: ComponentMetadata): Promise<PreparedComponent>;
12
8
  export declare function filterComponents(components: ComponentMetadata[]): ComponentMetadata[];
@@ -17,5 +13,5 @@ export type DiscoveredComponent = {
17
13
  container: HTMLElement;
18
14
  };
19
15
  export declare function discoverComponents(): DiscoveredComponent[];
20
- export type ComponentRegistry = Record<string, () => Promise<(props: any) => React.ReactElement>>;
21
- export declare function hydrateAll(registry: ComponentRegistry, render: (container: HTMLElement, Component: (props: any) => React.ReactElement, props: Record<string, any>) => void): Promise<void>;
16
+ export type ComponentRegistry = Record<string, () => Promise<ComponentFn>>;
17
+ export declare function hydrateAll(registry: ComponentRegistry, render: (container: HTMLElement, Component: ComponentFn, props: Record<string, any>) => void): Promise<void>;
@@ -1,2 +1,2 @@
1
1
  export { prepareComponent, filterComponents, discoverComponents, hydrateAll, type PreparedComponent, type DiscoveredComponent, type ComponentRegistry, } from "./dom";
2
- export type { ComponentMetadata } from "./types";
2
+ export type { ComponentMetadata, ComponentFn, JsxElement } from "./types";
@@ -1,23 +1,12 @@
1
- var __defProp = Object.defineProperty;
2
- var __returnValue = (v) => v;
3
- function __exportSetter(name, newValue) {
4
- this[name] = __returnValue.bind(null, newValue);
5
- }
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, {
9
- get: all[name],
10
- enumerable: true,
11
- configurable: true,
12
- set: __exportSetter.bind(all, name)
13
- });
14
- };
15
-
16
- // src/react/dom.ts
1
+ // src/jsx/dom.ts
17
2
  function findCommentMarker(id) {
18
3
  const startPrefix = `$${id} `;
19
4
  const endMarker = `/$${id}`;
20
- const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_COMMENT, null);
5
+ const walker = document.createTreeWalker(
6
+ document.body,
7
+ NodeFilter.SHOW_COMMENT,
8
+ null
9
+ );
21
10
  let startComment = null;
22
11
  let endComment = null;
23
12
  let name = "";
@@ -34,7 +23,8 @@ function findCommentMarker(id) {
34
23
  const jsonStr = content.slice(jsonStart);
35
24
  try {
36
25
  props = JSON.parse(jsonStr);
37
- } catch {}
26
+ } catch {
27
+ }
38
28
  } else {
39
29
  name = content.trim();
40
30
  }
@@ -77,7 +67,11 @@ function filterComponents(components) {
77
67
  }
78
68
  function discoverComponents() {
79
69
  const components = [];
80
- const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_COMMENT, null);
70
+ const walker = document.createTreeWalker(
71
+ document.body,
72
+ NodeFilter.SHOW_COMMENT,
73
+ null
74
+ );
81
75
  const markers = [];
82
76
  let node;
83
77
  while (node = walker.nextNode()) {
@@ -97,7 +91,8 @@ function discoverComponents() {
97
91
  name = content.slice(0, jsonStart).trim();
98
92
  try {
99
93
  props = JSON.parse(content.slice(jsonStart));
100
- } catch {}
94
+ } catch {
95
+ }
101
96
  } else {
102
97
  name = content.trim();
103
98
  }
@@ -112,8 +107,7 @@ function discoverComponents() {
112
107
  }
113
108
  }
114
109
  for (const marker of markers) {
115
- if (!marker.endComment)
116
- continue;
110
+ if (!marker.endComment) continue;
117
111
  const container = createContainerBetweenMarkers(marker.startComment, marker.endComment);
118
112
  components.push({
119
113
  id: marker.id,
@@ -141,8 +135,8 @@ async function hydrateAll(registry, render) {
141
135
  }));
142
136
  }
143
137
  export {
144
- prepareComponent,
145
- hydrateAll,
138
+ discoverComponents,
146
139
  filterComponents,
147
- discoverComponents
140
+ hydrateAll,
141
+ prepareComponent
148
142
  };
@@ -26,7 +26,7 @@
26
26
  * @example
27
27
  * ```tsx
28
28
  * // Using ComponentMetadata with prepareComponent:
29
- * import { prepareComponent, type ComponentMetadata } from "ziex";
29
+ * import { prepareComponent, type ComponentMetadata } from "ziex/jsx";
30
30
  *
31
31
  * for (const component of components) {
32
32
  * const { domNode, props, Component } = await prepareComponent(component);
@@ -34,6 +34,11 @@
34
34
  * }
35
35
  * ```
36
36
  */
37
+ /**
38
+ * Opaque JSX element from any JSX library (React, Solid, Preact, etc.).
39
+ */
40
+ export type JsxElement = unknown;
41
+ export type ComponentFn = (props: any) => JsxElement;
37
42
  export type ComponentMetadata = {
38
43
  /**
39
44
  * The name of the component as declared in the ZX file.
@@ -115,9 +120,9 @@ export type ComponentMetadata = {
115
120
  /**
116
121
  * The rendering type of the component, determining how it will be rendered on the client.
117
122
  *
118
- * - **"react"** (Client Side React): The component is a React component that will be rendered
119
- * using React's client-side rendering. The component file should export a default React
120
- * component function. This is the most common type for interactive UI components.
123
+ * - **"react"** (Client Side JSX): The component is a JSX component that will be rendered
124
+ * client-side with a JSX library (React, Solid, Preact, etc.). The component file should
125
+ * export a default JSX component function.
121
126
  *
122
127
  * - **"client"** (Client Side Zig): The component is a Zig component that will be compiled to
123
128
  * WebAssembly and rendered on the client side. This allows you to use Zig's performance
@@ -127,7 +132,7 @@ export type ComponentMetadata = {
127
132
  *
128
133
  * @example
129
134
  * ```tsx
130
- * // CSR component (React):
135
+ * // CSR component (JSX):
131
136
  * <CounterComponent @rendering={.react} max_count={10} />
132
137
  * // type: "react"
133
138
  *
@@ -157,13 +162,13 @@ export type ComponentMetadata = {
157
162
  * code-splitting and lazy loading of components, improving initial page load performance
158
163
  * by only loading components when they are needed.
159
164
  *
160
- * For CSR components, the imported module should export a default React component.
165
+ * For CSR components, the imported module should export a default JSX component.
161
166
  * For Client components, the import mechanism depends on the WASM module structure.
162
167
  *
163
168
  * The function is called during client-side hydration to load and render the component
164
169
  * into its corresponding DOM container element.
165
170
  *
166
- * @returns A Promise that resolves to a component function that accepts props and returns a React element.
171
+ * @returns A Promise that resolves to a component function that accepts props and returns a JSX element.
167
172
  *
168
173
  * @example
169
174
  * ```tsx
@@ -180,11 +185,11 @@ export type ComponentMetadata = {
180
185
  * @example
181
186
  * ```tsx
182
187
  * // With prepareComponent helper:
183
- * import { prepareComponent } from "ziex";
188
+ * import { prepareComponent } from "ziex/jsx";
184
189
  *
185
190
  * const { Component, props, domNode } = await prepareComponent(component);
186
191
  * // Component is loaded and ready to render with props
187
192
  * ```
188
193
  */
189
- import: () => Promise<(props: any) => React.ReactElement>;
194
+ import: () => Promise<ComponentFn>;
190
195
  };
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "ziex",
3
- "version": "0.1.0-dev.1367",
3
+ "version": "0.1.0-dev.1377",
4
+ "types": "index.d.ts",
4
5
  "description": "Ziex is a framework for building web applications with Zig.",
5
6
  "main": "index.js",
6
7
  "type": "module",
@@ -9,7 +10,7 @@
9
10
  },
10
11
  "exports": {
11
12
  ".": "./index.js",
12
- "./react": "./react/index.js",
13
+ "./jsx": "./jsx/index.js",
13
14
  "./wasm": "./wasm/index.js",
14
15
  "./wasm/init": "./wasm/init.js",
15
16
  "./cloudflare": "./cloudflare/index.js",
@@ -37,16 +38,7 @@
37
38
  "license": "MIT",
38
39
  "scripts": {},
39
40
  "dependencies": {
40
- "@ziex/cli": "0.1.0-dev.1367"
41
+ "@ziex/cli": "0.1.0-dev.1377"
41
42
  },
42
- "peerDependenciesMeta": {
43
- "react": {
44
- "optional": true
45
- },
46
- "react-dom": {
47
- "optional": true
48
- }
49
- },
50
- "module": "index.js",
51
- "types": "index.d.ts"
52
- }
43
+ "module": "index.js"
44
+ }
package/vercel/index.js CHANGED
@@ -1,18 +1,3 @@
1
- var __defProp = Object.defineProperty;
2
- var __returnValue = (v) => v;
3
- function __exportSetter(name, newValue) {
4
- this[name] = __returnValue.bind(null, newValue);
5
- }
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, {
9
- get: all[name],
10
- enumerable: true,
11
- configurable: true,
12
- set: __exportSetter.bind(all, name)
13
- });
14
- };
15
-
16
1
  // src/vercel/index.ts
17
2
  function handle(app) {
18
3
  return (req) => app.fetch(req);