ziex 0.0.1-dev.3 → 0.0.1-dev.5

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/index.js CHANGED
@@ -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};
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
@@ -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.3",
7
6
  "exports": {
8
7
  ".": "./index.js",
9
8
  "./react": "./react/index.js",
@@ -29,5 +28,6 @@
29
28
  "author": "Nurul Huda (Apon) <me@nurulhudaapon.com>",
30
29
  "license": "MIT",
31
30
  "module": "index.js",
32
- "types": "index.d.ts"
33
- }
31
+ "types": "index.d.ts",
32
+ "version": "0.0.1-dev.5"
33
+ }
package/wasm/index.d.ts CHANGED
@@ -1,2 +1,19 @@
1
- export { prepareComponent, filterComponents, type PreparedComponent } from "./dom";
2
- export type { ComponentMetadata } from "./types";
1
+ declare class ZXInstance {
2
+ exports: Record<string, (...args: any[]) => void>;
3
+ events: Event[];
4
+ constructor({ exports, events }: ZXInstanceOptions);
5
+ }
6
+ export declare function init(options?: InitOptions): Promise<void>;
7
+ export type InitOptions = {
8
+ url?: string;
9
+ };
10
+ type ZXInstanceOptions = {
11
+ exports: Record<string, (...args: any[]) => void>;
12
+ events?: Event[];
13
+ };
14
+ declare global {
15
+ interface Window {
16
+ _zx: ZXInstance;
17
+ }
18
+ }
19
+ export {};
package/wasm/index.js CHANGED
@@ -1 +1 @@
1
- async function o(e){throw Error("Not implemented")}function t(e){throw Error("Not implemented")}export{o as prepareComponent,t as filterComponents};
1
+ var z={nan:0,null:1,true:2,false:3,undefined:4,globalThis:5,runtime:6};var W=new TextEncoder,j=new TextDecoder("utf-8");class E{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(n,s,c,m){let x=this.loadValue(s),o=this.loadString(c,m),O=Reflect.get(x,o);this.storeValue(n,O)}valueSet(n,s,c,m){let x=this.loadValue(n),o=this.loadString(s,c),O=this.loadRef(m);Reflect.set(x,o,O)}valueDeinit(n){if(n>6)this.values[n]=null,this.idPool.push(n)}valueObjectCreate(n){this.storeValue(n,{})}valueStringCreate(n,s,c){let m=this.loadString(s,c);this.storeValue(n,m)}valueStringLen(n){let s=this.loadValue(n);return W.encode(s).byteLength}valueStringCopy(n,s,c){if(this.memory==null)return;let m=this.loadValue(n),x=W.encode(m);if(x.byteLength>c)return;new Uint8Array(this.memory.buffer,s,x.length).set(x)}valueNew(n,s,c,m){let x=this.loadValue(s),o=[];for(let Z=0;Z<m;Z++)o.push(this.loadRef(c+Z*8));let O=Reflect.construct(x,o);this.storeValue(n,O)}funcApply(n,s,c,m,x){let o=this.loadValue(s),O=this.loadRef(c),Z=[];for(let y=0;y<x;y++)Z.push(this.loadRef(m+y*8));let b=Reflect.apply(o,O,Z);this.storeValue(n,b)}loadValue(n){return this.values[n]}deleteValue(n){let s=this.values[n];return this.valueDeinit(n),s}loadRef(n){if(this.memory==null)return;let c=new DataView(this.memory.buffer).getFloat64(n,!0);if(!isNaN(c))return c;let m=this.loadRefId(n);return this.values[m]}loadRefId(n){if(this.memory==null)return 0;return new DataView(this.memory.buffer).getUint32(n,!0)}storeValue(n,s){if(this.memory==null)return;let c=new DataView(this.memory.buffer);if(typeof s==="number"){if(isNaN(s))c.setUint32(n,z.nan,!0),c.setUint32(n+4,2146959360,!0);else c.setFloat64(n,s,!0);return}if(s===null){c.setUint32(n,z.null,!0),c.setUint32(n+4,2146959360,!0);return}if(s===void 0){c.setUint32(n,z.undefined,!0),c.setUint32(n+4,2146959360,!0);return}let m=this.idPool.pop();if(m===void 0)m=this.values.length;this.values[m]=s;let x=0;switch(typeof s){case"object":x=1;break;case"string":x=2;break;case"symbol":x=3;break;case"function":x=4;break}c.setUint32(n,Number(m),!0),c.setUint32(n+4,2146959360|x,!0)}loadString(n,s){if(this.memory==null)return"";let m=new Uint8ClampedArray(this.memory.buffer,n,Number(s)).slice();return j.decode(m)}}var R="/assets/main.wasm",X=new E,U={module:{},env:{},...X.importObject()};class _{exports;events;constructor({exports:n,events:s}){this.exports=n,this.events=s??[]}}async function J(n={}){let s=await(await fetch(n?.url??R)).arrayBuffer(),{instance:c}=await WebAssembly.instantiate(s,U);X.memory=c.exports.memory,window._zx=new _({exports:c.exports});let m=c.exports.main;m()}export{J as init};