ziex 0.0.1-dev.3 → 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/index.js +1 -1
- package/package.json +1 -1
- package/wasm/index.d.ts +3 -2
- package/wasm/index.js +1 -1
- package/wasm/types.d.ts +8 -0
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var i={name:"zx",version:"0.0.1-dev.
|
|
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
package/wasm/index.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export type {
|
|
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
CHANGED
|
@@ -1 +1 @@
|
|
|
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};
|