ziex 0.0.1-dev.0 → 0.0.1-dev.1

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/dom.d.ts ADDED
@@ -0,0 +1,11 @@
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/index.d.ts CHANGED
@@ -1,8 +1,2 @@
1
- export declare const components: ComponentMetadata[];
2
- type ComponentMetadata = {
3
- name: string;
4
- path: string;
5
- id: string;
6
- import: () => Promise<(props: unknown) => React.ReactElement>;
7
- };
8
- export {};
1
+ export type { ComponentMetadata } from './types';
2
+ export { prepareComponent } from './dom';
package/index.js CHANGED
@@ -1 +1 @@
1
- var n="{[ZX_COMPONENTS]s}";export{n as components};
1
+ async function k(y){let x=document.getElementById(y.id);if(!x)throw Error(`Root element ${y.id} not found`);let f=JSON.parse(x.getAttribute("data-props")||"{}"),b=x.getAttribute("data-children")??void 0;if(b)f.dangerouslySetInnerHTML={__html:b};let j=await y.import();return{domNode:x,props:f,Component:j}}export{k as prepareComponent};
package/package.json CHANGED
@@ -3,7 +3,6 @@
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.0",
7
6
  "homepage": "https://github.com/nurulhudaapon/zx",
8
7
  "repository": {
9
8
  "type": "git",
@@ -24,5 +23,6 @@
24
23
  "author": "Nurul Huda (Apon) <me@nurulhudaapon.com>",
25
24
  "license": "MIT",
26
25
  "module": "index.js",
27
- "types": "index.d.ts"
26
+ "types": "index.d.ts",
27
+ "version": "0.0.1-dev.1"
28
28
  }
package/types.d.ts ADDED
@@ -0,0 +1,25 @@
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
+ };