ziex 0.0.1-dev.2 → 0.0.1-dev.4

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
@@ -27,7 +27,7 @@ winget install -e --id zig.zig # Windows
27
27
 
28
28
  ## Quick Example
29
29
 
30
- ```tsx site/pages/docs/example/overview.zx
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
- - [ ] Path Segments
87
+ - [x] Path Segments
88
88
  - [x] Components
89
89
  - [x] Control Flow
90
- - [ ] `if`
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
- - [ ] `while`
99
- - [ ] `while` nested
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
- - [ ] CLI
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
- - [ ] `bundle` Bundle the ZX executable with public/assets and exe
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 type { ComponentMetadata } from "./types";
2
- export { prepareComponent, type PreparedComponent } from "./dom";
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
- async function S(G){let k=document.getElementById(G.id);if(!k)throw Error(`Root element ${G.id} not found`);let J=JSON.parse(k.getAttribute("data-props")||"{}"),K=k.getAttribute("data-children")??void 0;if(K)J.dangerouslySetInnerHTML={__html:K};let Q=await G.import();return{domNode:k,props:J,Component:Q}}export{S as prepareComponent};
1
+ var i={name:"zx",version:"0.0.1-dev.230",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
@@ -1,9 +1,14 @@
1
1
  {
2
2
  "name": "ziex",
3
- "version": "0.0.1-dev.2",
4
3
  "description": "ZX is a framework for building web applications with Zig.",
5
4
  "main": "index.js",
6
5
  "type": "module",
6
+ "version": "0.0.1-dev.4",
7
+ "exports": {
8
+ ".": "./index.js",
9
+ "./react": "./react/index.js",
10
+ "./wasm": "./wasm/index.js"
11
+ },
7
12
  "homepage": "https://github.com/nurulhudaapon/zx",
8
13
  "repository": {
9
14
  "type": "git",
@@ -132,3 +132,4 @@ export type PreparedComponent = {
132
132
  * ```
133
133
  */
134
134
  export declare function prepareComponent(component: ComponentMetadata): Promise<PreparedComponent>;
135
+ export declare function filterComponents(components: ComponentMetadata[]): ComponentMetadata[];
@@ -0,0 +1,2 @@
1
+ export { prepareComponent, filterComponents, type PreparedComponent } from "./dom";
2
+ export type { ComponentMetadata } from "./types";
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};
@@ -78,6 +78,12 @@ export type ComponentMetadata = {
78
78
  * ```
79
79
  */
80
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;
81
87
  /**
82
88
  * A unique HTML element identifier for the component's root DOM node.
83
89
  *
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[];
@@ -0,0 +1,3 @@
1
+ import type { InitOptions } from "./types";
2
+ export type { InitOptions } from "./types";
3
+ export declare function init(options?: InitOptions): Promise<void>;
package/wasm/index.js ADDED
@@ -0,0 +1 @@
1
+ var U={nan:0,null:1,true:2,false:3,undefined:4,globalThis:5,runtime:6};var _=new TextEncoder,D=new TextDecoder("utf-8");class W{memory;values=[NaN,null,!0,!1,void 0,globalThis,this];idPool=[];importObject(){return{"zig-js":{valueGet:this.valueGet.bind(this),valueSet:this.valueSet.bind(this),valueDeinit:this.valueDeinit.bind(this),valueObjectCreate:this.valueObjectCreate.bind(this),valueStringCreate:this.valueStringCreate.bind(this),valueStringLen:this.valueStringLen.bind(this),valueStringCopy:this.valueStringCopy.bind(this),valueNew:this.valueNew.bind(this),funcApply:this.funcApply.bind(this)}}}valueGet(m,n,c,s){let x=this.loadValue(n),O=this.loadString(c,s),y=Reflect.get(x,O);this.storeValue(m,y)}valueSet(m,n,c,s){let x=this.loadValue(m),O=this.loadString(n,c),y=this.loadRef(s);Reflect.set(x,O,y)}valueDeinit(m){if(m>6)this.values[m]=null,this.idPool.push(m)}valueObjectCreate(m){this.storeValue(m,{})}valueStringCreate(m,n,c){let s=this.loadString(n,c);this.storeValue(m,s)}valueStringLen(m){let n=this.loadValue(m);return _.encode(n).byteLength}valueStringCopy(m,n,c){if(this.memory==null)return;let s=this.loadValue(m),x=_.encode(s);if(x.byteLength>c)return;new Uint8Array(this.memory.buffer,n,x.length).set(x)}valueNew(m,n,c,s){let x=this.loadValue(n),O=[];for(let j=0;j<s;j++)O.push(this.loadRef(c+j*8));let y=Reflect.construct(x,O);this.storeValue(m,y)}funcApply(m,n,c,s,x){let O=this.loadValue(n),y=this.loadRef(c),j=[];for(let z=0;z<x;z++)j.push(this.loadRef(s+z*8));let B=Reflect.apply(O,y,j);this.storeValue(m,B)}loadValue(m){return this.values[m]}deleteValue(m){let n=this.values[m];return this.valueDeinit(m),n}loadRef(m){if(this.memory==null)return;let c=new DataView(this.memory.buffer).getFloat64(m,!0);if(!isNaN(c))return c;let s=this.loadRefId(m);return this.values[s]}loadRefId(m){if(this.memory==null)return 0;return new DataView(this.memory.buffer).getUint32(m,!0)}storeValue(m,n){if(this.memory==null)return;let c=new DataView(this.memory.buffer);if(typeof n==="number"){if(isNaN(n))c.setUint32(m,U.nan,!0),c.setUint32(m+4,2146959360,!0);else c.setFloat64(m,n,!0);return}if(n===null){c.setUint32(m,U.null,!0),c.setUint32(m+4,2146959360,!0);return}if(n===void 0){c.setUint32(m,U.undefined,!0),c.setUint32(m+4,2146959360,!0);return}let s=this.idPool.pop();if(s===void 0)s=this.values.length;this.values[s]=n;let x=0;switch(typeof n){case"object":x=1;break;case"string":x=2;break;case"symbol":x=3;break;case"function":x=4;break}c.setUint32(m,Number(s),!0),c.setUint32(m+4,2146959360|x,!0)}loadString(m,n){if(this.memory==null)return"";let s=new Uint8ClampedArray(this.memory.buffer,m,Number(n)).slice();return D.decode(s)}}var E="/assets/main.wasm",b=new W,F={module:{},env:{},...b.importObject()};async function Z(m={}){let n=await(await fetch(m?.url??E)).arrayBuffer(),{instance:c}=await WebAssembly.instantiate(n,F);b.memory=c.exports.memory,window._zx=c.exports;let s=c.exports.main;s()}export{Z as init};
@@ -0,0 +1,9 @@
1
+ export type ComponentMetadata = {};
2
+ export type InitOptions = {
3
+ url?: string;
4
+ };
5
+ declare global {
6
+ interface Window {
7
+ _zx: Record<string, (...args: any[]) => void>;
8
+ }
9
+ }