ziex 0.0.1-dev.1 → 0.0.1-dev.3
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 +7 -7
- package/index.d.ts +9 -2
- package/index.js +1 -1
- package/package.json +7 -2
- package/react/dom.d.ts +135 -0
- package/react/index.d.ts +2 -0
- package/react/index.js +1 -0
- package/react/types.d.ts +193 -0
- package/wasm/dom.d.ts +4 -0
- package/wasm/index.d.ts +2 -0
- package/wasm/index.js +1 -0
- package/wasm/types.d.ts +1 -0
- package/dom.d.ts +0 -11
- package/types.d.ts +0 -25
package/README.md
CHANGED
|
@@ -27,7 +27,7 @@ winget install -e --id zig.zig # Windows
|
|
|
27
27
|
|
|
28
28
|
## Quick Example
|
|
29
29
|
|
|
30
|
-
```tsx site/pages/
|
|
30
|
+
```tsx site/pages/examples/overview.zx
|
|
31
31
|
pub fn QuickExample(allocator: zx.Allocator) zx.Component {
|
|
32
32
|
const is_loading = true;
|
|
33
33
|
const chars = "Hello, ZX Dev!";
|
|
@@ -84,10 +84,10 @@ const zx = @import("zx");
|
|
|
84
84
|
- [x] Routing
|
|
85
85
|
- [x] File-system Routing
|
|
86
86
|
- [x] Search Parameters
|
|
87
|
-
- [
|
|
87
|
+
- [x] Path Segments
|
|
88
88
|
- [x] Components
|
|
89
89
|
- [x] Control Flow
|
|
90
|
-
- [
|
|
90
|
+
- [x] `if`
|
|
91
91
|
- [ ] `if` nested
|
|
92
92
|
- [x] `if/else`
|
|
93
93
|
- [x] `if/else` nested
|
|
@@ -95,8 +95,8 @@ const zx = @import("zx");
|
|
|
95
95
|
- [x] `for` nested
|
|
96
96
|
- [x] `switch`
|
|
97
97
|
- [x] `switch` nested
|
|
98
|
-
- [
|
|
99
|
-
- [
|
|
98
|
+
- [x] `while`
|
|
99
|
+
- [x] `while` nested
|
|
100
100
|
- [x] Assets
|
|
101
101
|
- [x] Copying
|
|
102
102
|
- [x] Serving
|
|
@@ -108,14 +108,14 @@ const zx = @import("zx");
|
|
|
108
108
|
- [ ] Middleware
|
|
109
109
|
- [ ] API Endpoints
|
|
110
110
|
- [ ] Server Actions
|
|
111
|
-
- [
|
|
111
|
+
- [x] CLI
|
|
112
112
|
- [x] `init` Project Template
|
|
113
113
|
- [x] `transpile` Transpile .zx files to Zig source code
|
|
114
114
|
- [x] `serve` Serve the project
|
|
115
115
|
- [x] `dev` HMR or Rebuild on Change
|
|
116
116
|
- [x] `fmt` Format the ZX source code (_Alpha_)
|
|
117
117
|
- [x] `export` Generate static site assets
|
|
118
|
-
- [
|
|
118
|
+
- [x] `bundle` Bundle the ZX executable with public/assets and exe
|
|
119
119
|
- [x] `version` Show the version of the ZX CLI
|
|
120
120
|
- [x] `update` Update the version of ZX dependency
|
|
121
121
|
- [x] `upgrade` Upgrade the version of ZX CLI
|
package/index.d.ts
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
1
|
+
export declare const zx: BuildZon;
|
|
2
|
+
type BuildZon = {
|
|
3
|
+
version: string;
|
|
4
|
+
description: string;
|
|
5
|
+
repository: string;
|
|
6
|
+
fingerprint: number;
|
|
7
|
+
minimum_zig_version: string;
|
|
8
|
+
};
|
|
9
|
+
export {};
|
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
var i={name:"zx",version:"0.0.1-dev.228",description:"ZX is a framework for building web applications with Zig.",repository:"https://github.com/nurulhudaapon/zx",fingerprint:14616285862371232000,minimum_zig_version:"0.15.2",dependencies:{httpz:{url:"git+https://github.com/nurulhudaapon/httpz.git#7268154f43f5827bf78668e8e79a00f2ebe4db13",hash:"httpz-0.0.0-PNVzrBgtBwCVkSJyophIX6WHwDR0r8XhBGQr96Kk-1El"},zli:{url:"git+https://github.com/nurulhudaapon/cliz.git#aff3b54879e7514afaf8c87f1abe22121b8992d4",hash:"zli-4.3.0-LeUjpu_fAABOSVASSCW2fFh8SFVNHrxQGDXGPNzcSE_i"}},paths:["build.zig","build.zig.zon","src"]};export{i as zx};
|
package/package.json
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
"description": "ZX is a framework for building web applications with Zig.",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"version": "0.0.1-dev.3",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./index.js",
|
|
9
|
+
"./react": "./react/index.js",
|
|
10
|
+
"./wasm": "./wasm/index.js"
|
|
11
|
+
},
|
|
6
12
|
"homepage": "https://github.com/nurulhudaapon/zx",
|
|
7
13
|
"repository": {
|
|
8
14
|
"type": "git",
|
|
@@ -23,6 +29,5 @@
|
|
|
23
29
|
"author": "Nurul Huda (Apon) <me@nurulhudaapon.com>",
|
|
24
30
|
"license": "MIT",
|
|
25
31
|
"module": "index.js",
|
|
26
|
-
"types": "index.d.ts"
|
|
27
|
-
"version": "0.0.1-dev.1"
|
|
32
|
+
"types": "index.d.ts"
|
|
28
33
|
}
|
package/react/dom.d.ts
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import type { ComponentMetadata } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Result of preparing a component for hydration.
|
|
4
|
+
*
|
|
5
|
+
* Contains all the necessary data to render a React component into its server-rendered container.
|
|
6
|
+
*/
|
|
7
|
+
export type PreparedComponent = {
|
|
8
|
+
/**
|
|
9
|
+
* The HTML element where the component should be rendered.
|
|
10
|
+
*
|
|
11
|
+
* This is the DOM node that was server-rendered by ZX with the component's unique ID.
|
|
12
|
+
* The element already exists in the DOM and contains the server-rendered fallback content.
|
|
13
|
+
* React will hydrate this element, replacing its contents with the interactive component.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```tsx
|
|
17
|
+
* // The DOM node corresponds to HTML like:
|
|
18
|
+
* // <div id="zx-dcde04c415da9d1b15ca2690d8b497ae" data-props="...">...</div>
|
|
19
|
+
*
|
|
20
|
+
* const { domNode } = await prepareComponent(component);
|
|
21
|
+
* createRoot(domNode).render(<Component {...props} />);
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
domNode: HTMLElement;
|
|
25
|
+
/**
|
|
26
|
+
* Component props parsed from the server-rendered HTML.
|
|
27
|
+
*
|
|
28
|
+
* Props are extracted from the `data-props` attribute (JSON-encoded) on the component's
|
|
29
|
+
* container element. If the component has children from server side then they are automatically converted to
|
|
30
|
+
* `dangerouslySetInnerHTML` for React compatibility.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```tsx
|
|
34
|
+
* // Server-rendered HTML:
|
|
35
|
+
* // <div data-props='{"max_count":10,"label":"Counter"}' data-children="<span>0</span>">...</div>
|
|
36
|
+
*
|
|
37
|
+
* const { props } = await prepareComponent(component);
|
|
38
|
+
* // props = {
|
|
39
|
+
* // max_count: 10,
|
|
40
|
+
* // label: "Counter",
|
|
41
|
+
* // dangerouslySetInnerHTML: { __html: "<span>0</span>" }
|
|
42
|
+
* // }
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
props: Record<string, any> & {
|
|
46
|
+
/**
|
|
47
|
+
* React's special prop for setting inner HTML directly.
|
|
48
|
+
*
|
|
49
|
+
* Automatically added when the component has children in the ZX file. The HTML string
|
|
50
|
+
* is extracted from the `data-children` attribute on the server-rendered element.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```tsx
|
|
54
|
+
* // In ZX file:
|
|
55
|
+
* <MyComponent @rendering={.csr}>
|
|
56
|
+
* <p>Child content</p>
|
|
57
|
+
* </MyComponent>
|
|
58
|
+
*
|
|
59
|
+
* // Results in:
|
|
60
|
+
* // props.dangerouslySetInnerHTML = { __html: "<p>Child content</p>" }
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
dangerouslySetInnerHTML?: {
|
|
64
|
+
__html: string;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* The loaded React component function ready to render.
|
|
69
|
+
*
|
|
70
|
+
* This is the default export from the component module, lazy-loaded via the component's
|
|
71
|
+
* import function. The component is ready to be rendered with React's `createRoot().render()`.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```tsx
|
|
75
|
+
* const { Component, props, domNode } = await prepareComponent(component);
|
|
76
|
+
*
|
|
77
|
+
* // Component is the default export from the component file:
|
|
78
|
+
* // export default function CounterComponent({ max_count }: { max_count: number }) {
|
|
79
|
+
* // return <div>Count: {max_count}</div>;
|
|
80
|
+
* // }
|
|
81
|
+
*
|
|
82
|
+
* createRoot(domNode).render(<Component {...props} />);
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
Component: (props: any) => React.ReactElement;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Prepares a client-side component for hydration by locating its DOM container, extracting
|
|
89
|
+
* props and children from server-rendered HTML attributes, and lazy-loading the component module.
|
|
90
|
+
*
|
|
91
|
+
* This function bridges server-rendered HTML (from ZX's Zig transpiler) and client-side React
|
|
92
|
+
* components. It reads data attributes (`data-props`, `data-children`) from the DOM element
|
|
93
|
+
* with the component's unique ID, then lazy-loads the component module for rendering.
|
|
94
|
+
*
|
|
95
|
+
* @param component - The component metadata containing ID, import function, and other metadata
|
|
96
|
+
* needed to locate and load the component
|
|
97
|
+
*
|
|
98
|
+
* @returns A Promise that resolves to a `PreparedComponent` object containing the DOM node,
|
|
99
|
+
* parsed props, and the loaded React component function
|
|
100
|
+
*
|
|
101
|
+
* @throws {Error} If the component's container element cannot be found in the DOM. This typically
|
|
102
|
+
* happens if the component ID doesn't match any element, the script runs before
|
|
103
|
+
* the HTML is loaded, or there's a mismatch between server and client metadata
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```tsx
|
|
107
|
+
* // Basic usage with React:
|
|
108
|
+
* import { createRoot } from "react-dom/client";
|
|
109
|
+
* import { prepareComponent } from "ziex";
|
|
110
|
+
* import { components } from "@ziex/components";
|
|
111
|
+
*
|
|
112
|
+
* for (const component of components) {
|
|
113
|
+
* prepareComponent(component).then(({ domNode, Component, props }) => {
|
|
114
|
+
* createRoot(domNode).render(<Component {...props} />);
|
|
115
|
+
* }).catch(console.error);
|
|
116
|
+
* }
|
|
117
|
+
* ```
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```tsx
|
|
121
|
+
* // With async/await:
|
|
122
|
+
* async function hydrateComponent(component: ComponentMetadata) {
|
|
123
|
+
* try {
|
|
124
|
+
* const { domNode, Component, props } = await prepareComponent(component);
|
|
125
|
+
* createRoot(domNode).render(<Component {...props} />);
|
|
126
|
+
* } catch (error) {
|
|
127
|
+
* console.error(`Failed to hydrate ${component.name}:`, error);
|
|
128
|
+
* }
|
|
129
|
+
* }
|
|
130
|
+
*
|
|
131
|
+
* Promise.all(components.map(hydrateComponent));
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
export declare function prepareComponent(component: ComponentMetadata): Promise<PreparedComponent>;
|
|
135
|
+
export declare function filterComponents(components: ComponentMetadata[]): ComponentMetadata[];
|
package/react/index.d.ts
ADDED
package/react/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
async function S(k){let G=document.getElementById(k.id);if(!G)throw Error(`Root element ${k.id} not found`,{cause:k});let J=JSON.parse(G.getAttribute("data-props")||"{}"),K=G.getAttribute("data-children")??void 0;if(K)J.dangerouslySetInnerHTML={__html:K};let Q=await k.import();return{domNode:G,props:J,Component:Q}}function U(k){let G=window.location.pathname;return k.filter((J)=>J.route===G||!J.route)}export{S as prepareComponent,U as filterComponents};
|
package/react/types.d.ts
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Metadata for a client-side component used within a ZX file.
|
|
3
|
+
*
|
|
4
|
+
* This type represents the metadata for components that are marked with the `@rendering` attribute
|
|
5
|
+
* in ZX files. When a component is declared with `@rendering={.csr}` or `@rendering={.csz}` in a
|
|
6
|
+
* `.zx` file, the ZX transpiler generates a `ComponentMetadata` entry that is included in the
|
|
7
|
+
* generated `components` array.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* // In a ZX file (page.zx):
|
|
12
|
+
* <CounterComponent @rendering={.csr} max_count={10} />
|
|
13
|
+
*
|
|
14
|
+
* // Generated components array (components.ts):
|
|
15
|
+
* export const components: ComponentMetadata[] = [
|
|
16
|
+
* {
|
|
17
|
+
* name: "CounterComponent",
|
|
18
|
+
* path: "./components/CounterComponent.tsx",
|
|
19
|
+
* id: "zx-dcde04c415da9d1b15ca2690d8b497ae",
|
|
20
|
+
* type: "csr",
|
|
21
|
+
* import: () => import('./components/CounterComponent.tsx')
|
|
22
|
+
* }
|
|
23
|
+
* ];
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```tsx
|
|
28
|
+
* // Using ComponentMetadata with prepareComponent:
|
|
29
|
+
* import { prepareComponent, type ComponentMetadata } from "ziex";
|
|
30
|
+
*
|
|
31
|
+
* for (const component of components) {
|
|
32
|
+
* const { domNode, props, Component } = await prepareComponent(component);
|
|
33
|
+
* // Render component to DOM node
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export type ComponentMetadata = {
|
|
38
|
+
/**
|
|
39
|
+
* The name of the component as declared in the ZX file.
|
|
40
|
+
*
|
|
41
|
+
* This is the tag name used in JSX syntax within `.zx` files. It corresponds to the component
|
|
42
|
+
* identifier used in the component declaration (e.g., `<CounterComponent />`).
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```tsx
|
|
46
|
+
* // In ZX file:
|
|
47
|
+
* <CounterComponent @rendering={.csr} />
|
|
48
|
+
*
|
|
49
|
+
* // name will be: "CounterComponent"
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
name: string;
|
|
53
|
+
/**
|
|
54
|
+
* The file path to the component module.
|
|
55
|
+
*
|
|
56
|
+
* This is the relative or absolute path to the component file that will be dynamically imported
|
|
57
|
+
* at runtime. For CSR components, this typically points to a `.tsx` or `.jsx` file. For CSZ
|
|
58
|
+
* components, this points to a Zig component file.
|
|
59
|
+
*
|
|
60
|
+
* The path is determined from the `@jsImport` directive in the ZX file, or defaults to
|
|
61
|
+
* `./{componentName}.tsx` if not explicitly specified.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```tsx
|
|
65
|
+
* // In ZX file:
|
|
66
|
+
* const CounterComponent = @jsImport("components/Counter.tsx");
|
|
67
|
+
* <CounterComponent @rendering={.csr} />
|
|
68
|
+
*
|
|
69
|
+
* // path will be: "components/Counter.tsx"
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```tsx
|
|
74
|
+
* // Without explicit @jsImport:
|
|
75
|
+
* <MyComponent @rendering={.csr} />
|
|
76
|
+
*
|
|
77
|
+
* // path will default to: "./MyComponent.tsx"
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
path: string;
|
|
81
|
+
/**
|
|
82
|
+
* The route of of the component in which page the component was used,
|
|
83
|
+
* null in case the component was used in other non-page/layout context.
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
route: string | null;
|
|
87
|
+
/**
|
|
88
|
+
* A unique HTML element identifier for the component's root DOM node.
|
|
89
|
+
*
|
|
90
|
+
* This ID is generated by hashing the component's path and name using MD5, then formatting it
|
|
91
|
+
* as a hex string with the "zx-" prefix. The ID is used to locate the component's container
|
|
92
|
+
* element in the DOM during client-side hydration.
|
|
93
|
+
*
|
|
94
|
+
* The ID format is: `zx-{32 hex characters}` (e.g., `zx-dcde04c415da9d1b15ca2690d8b497ae`)
|
|
95
|
+
*
|
|
96
|
+
* When the same component is used multiple times on a page, each instance gets the same base ID
|
|
97
|
+
* since they share the same path and name. The ZX runtime uses this ID along with `data-props`
|
|
98
|
+
* and `data-children` attributes to hydrate the component with the correct props and children.
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```tsx
|
|
102
|
+
* // Component metadata:
|
|
103
|
+
* {
|
|
104
|
+
* name: "CounterComponent",
|
|
105
|
+
* path: "./components/Counter.tsx",
|
|
106
|
+
* id: "zx-dcde04c415da9d1b15ca2690d8b497ae"
|
|
107
|
+
* }
|
|
108
|
+
*
|
|
109
|
+
* // Generated HTML:
|
|
110
|
+
* <div id="zx-dcde04c415da9d1b15ca2690d8b497ae"
|
|
111
|
+
* data-props='{"max_count":10}'
|
|
112
|
+
* data-children="...">
|
|
113
|
+
* <!-- Server-rendered content -->
|
|
114
|
+
* </div>
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
id: string;
|
|
118
|
+
/**
|
|
119
|
+
* The rendering type of the component, determining how it will be rendered on the client.
|
|
120
|
+
*
|
|
121
|
+
* - **"csr"** (Client Side React): The component is a React component that will be rendered
|
|
122
|
+
* using React's client-side rendering. The component file should export a default React
|
|
123
|
+
* component function. This is the most common type for interactive UI components.
|
|
124
|
+
*
|
|
125
|
+
* - **"csz"** (Client Side Zig): The component is a Zig component that will be compiled to
|
|
126
|
+
* WebAssembly and rendered on the client side. This allows you to use Zig's performance
|
|
127
|
+
* and type safety for client-side components.
|
|
128
|
+
*
|
|
129
|
+
* The type is determined by the `@rendering` attribute value in the ZX file (`.csr` or `.csz`).
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* ```tsx
|
|
133
|
+
* // CSR component (React):
|
|
134
|
+
* <CounterComponent @rendering={.csr} max_count={10} />
|
|
135
|
+
* // type: "csr"
|
|
136
|
+
*
|
|
137
|
+
* // Component file (CounterComponent.tsx):
|
|
138
|
+
* export default function CounterComponent({ max_count }: { max_count: number }) {
|
|
139
|
+
* return <div>Count: {max_count}</div>;
|
|
140
|
+
* }
|
|
141
|
+
* ```
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```tsx
|
|
145
|
+
* // CSZ component (Zig/WASM):
|
|
146
|
+
* <CounterComponent @rendering={.csz} />
|
|
147
|
+
* // type: "csz"
|
|
148
|
+
*
|
|
149
|
+
* // Component file (CounterComponent.zig):
|
|
150
|
+
* pub fn CounterComponent(allocator: zx.Allocator) zx.Component {
|
|
151
|
+
* return (<div @allocator={allocator}>Counter</div>);
|
|
152
|
+
* }
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
type: "csr" | "csz";
|
|
156
|
+
/**
|
|
157
|
+
* A lazy-loading function that dynamically imports the component module.
|
|
158
|
+
*
|
|
159
|
+
* This function returns a Promise that resolves to the component function. It enables
|
|
160
|
+
* code-splitting and lazy loading of components, improving initial page load performance
|
|
161
|
+
* by only loading components when they are needed.
|
|
162
|
+
*
|
|
163
|
+
* For CSR components, the imported module should export a default React component.
|
|
164
|
+
* For CSZ components, the import mechanism depends on the WASM module structure.
|
|
165
|
+
*
|
|
166
|
+
* The function is called during client-side hydration to load and render the component
|
|
167
|
+
* into its corresponding DOM container element.
|
|
168
|
+
*
|
|
169
|
+
* @returns A Promise that resolves to a component function that accepts props and returns a React element.
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* ```tsx
|
|
173
|
+
* // Component metadata:
|
|
174
|
+
* {
|
|
175
|
+
* import: () => import('./components/CounterComponent.tsx')
|
|
176
|
+
* }
|
|
177
|
+
*
|
|
178
|
+
* // Usage:
|
|
179
|
+
* const Component = await component.import();
|
|
180
|
+
* // Component is now the default export from CounterComponent.tsx
|
|
181
|
+
* ```
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* ```tsx
|
|
185
|
+
* // With prepareComponent helper:
|
|
186
|
+
* import { prepareComponent } from "ziex";
|
|
187
|
+
*
|
|
188
|
+
* const { Component, props, domNode } = await prepareComponent(component);
|
|
189
|
+
* // Component is loaded and ready to render with props
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
192
|
+
import: () => Promise<(props: any) => React.ReactElement>;
|
|
193
|
+
};
|
package/wasm/dom.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ComponentMetadata } from "./types";
|
|
2
|
+
export type PreparedComponent = {};
|
|
3
|
+
export declare function prepareComponent(component: ComponentMetadata): Promise<PreparedComponent>;
|
|
4
|
+
export declare function filterComponents(components: ComponentMetadata[]): ComponentMetadata[];
|
package/wasm/index.d.ts
ADDED
package/wasm/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
async function o(e){throw Error("Not implemented")}function t(e){throw Error("Not implemented")}export{o as prepareComponent,t as filterComponents};
|
package/wasm/types.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type ComponentMetadata = {};
|
package/dom.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { ComponentMetadata } from "./types";
|
|
2
|
-
/**
|
|
3
|
-
* Prepare a component for rendering
|
|
4
|
-
* @param component - The component to prepare
|
|
5
|
-
* @returns The component, props, and DOM node
|
|
6
|
-
*/
|
|
7
|
-
export declare function prepareComponent(component: ComponentMetadata): Promise<{
|
|
8
|
-
domNode: HTMLElement;
|
|
9
|
-
props: any;
|
|
10
|
-
Component: (props: unknown) => React.ReactElement;
|
|
11
|
-
}>;
|
package/types.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The metadata for a component that was used within ZX file
|
|
3
|
-
*/
|
|
4
|
-
export type ComponentMetadata = {
|
|
5
|
-
/**
|
|
6
|
-
* The name of the component, this is what name was used in the component declaration
|
|
7
|
-
* e.g. <CounterComponent />
|
|
8
|
-
*/
|
|
9
|
-
name: string;
|
|
10
|
-
/**
|
|
11
|
-
* The path to the component, this is the path to the component file
|
|
12
|
-
* e.g. ./components/CounterComponent.tsx
|
|
13
|
-
*/
|
|
14
|
-
path: string;
|
|
15
|
-
/**
|
|
16
|
-
* The id of the component, this is a unique identifier for the component and an additinal index in case the same component is used multiple times
|
|
17
|
-
* e.g. zx-1234567890 or zx-1234567890-1
|
|
18
|
-
*/
|
|
19
|
-
id: string;
|
|
20
|
-
/**
|
|
21
|
-
* The import function for the component, this is the function that will be used to import the component
|
|
22
|
-
* e.g. () => import('./components/CounterComponent.tsx')
|
|
23
|
-
*/
|
|
24
|
-
import: () => Promise<(props: unknown) => React.ReactElement>;
|
|
25
|
-
};
|