ziex 0.0.1-dev.5 → 0.0.1-dev.6
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 +2 -2
- package/wasm/index.d.ts +6 -3
- package/wasm/index.js +1 -1
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.243",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"},zig_js:{url:"git+https://github.com/nurulhudaapon/jsz.git#04db83c617da1956ac5adc1cb9ba1e434c1cb6fd",hash:"zig_js-0.0.0-rjCAV-6GAADxFug7rDmPH-uM_XcnJ5NmuAMJCAscMjhi"}},paths:["build.zig","build.zig.zon","src"]};export{i as zx};
|
package/package.json
CHANGED
package/wasm/index.d.ts
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
declare class ZXInstance {
|
|
2
|
-
|
|
2
|
+
#private;
|
|
3
|
+
exports: WebAssembly.Exports;
|
|
3
4
|
events: Event[];
|
|
5
|
+
actions: Record<string, (eventId: number) => void>;
|
|
4
6
|
constructor({ exports, events }: ZXInstanceOptions);
|
|
7
|
+
addEvent(event: Event): number;
|
|
5
8
|
}
|
|
6
9
|
export declare function init(options?: InitOptions): Promise<void>;
|
|
7
10
|
export type InitOptions = {
|
|
8
11
|
url?: string;
|
|
9
12
|
};
|
|
10
13
|
type ZXInstanceOptions = {
|
|
11
|
-
exports:
|
|
12
|
-
events?:
|
|
14
|
+
exports: ZXInstance['exports'];
|
|
15
|
+
events?: ZXInstance['events'];
|
|
13
16
|
};
|
|
14
17
|
declare global {
|
|
15
18
|
interface Window {
|
package/wasm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var E={nan:0,null:1,true:2,false:3,undefined:4,globalThis:5,runtime:6};var b=new TextEncoder,Z=new TextDecoder("utf-8");class p{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,t,s,c){let o=this.loadValue(t),e=this.loadString(s,c),x=Reflect.get(o,e);this.storeValue(n,x)}valueSet(n,t,s,c){let o=this.loadValue(n),e=this.loadString(t,s),x=this.loadRef(c);Reflect.set(o,e,x)}valueDeinit(n){if(n>6)this.values[n]=null,this.idPool.push(n)}valueObjectCreate(n){this.storeValue(n,{})}valueStringCreate(n,t,s){let c=this.loadString(t,s);this.storeValue(n,c)}valueStringLen(n){let t=this.loadValue(n);return b.encode(t).byteLength}valueStringCopy(n,t,s){if(this.memory==null)return;let c=this.loadValue(n),o=b.encode(c);if(o.byteLength>s)return;new Uint8Array(this.memory.buffer,t,o.length).set(o)}valueNew(n,t,s,c){let o=this.loadValue(t),e=[];for(let m=0;m<c;m++)e.push(this.loadRef(s+m*8));let x=Reflect.construct(o,e);this.storeValue(n,x)}funcApply(n,t,s,c,o){let e=this.loadValue(t),x=this.loadRef(s),m=[];for(let h=0;h<o;h++)m.push(this.loadRef(c+h*8));let X=Reflect.apply(e,x,m);this.storeValue(n,X)}loadValue(n){return this.values[n]}deleteValue(n){let t=this.values[n];return this.valueDeinit(n),t}loadRef(n){if(this.memory==null)return;let s=new DataView(this.memory.buffer).getFloat64(n,!0);if(!isNaN(s))return s;let c=this.loadRefId(n);return this.values[c]}loadRefId(n){if(this.memory==null)return 0;return new DataView(this.memory.buffer).getUint32(n,!0)}storeValue(n,t){if(this.memory==null)return;let s=new DataView(this.memory.buffer);if(typeof t==="number"){if(isNaN(t))s.setUint32(n,E.nan,!0),s.setUint32(n+4,2146959360,!0);else s.setFloat64(n,t,!0);return}if(t===null){s.setUint32(n,E.null,!0),s.setUint32(n+4,2146959360,!0);return}if(t===void 0){s.setUint32(n,E.undefined,!0),s.setUint32(n+4,2146959360,!0);return}let c=this.idPool.pop();if(c===void 0)c=this.values.length;this.values[c]=t;let o=0;switch(typeof t){case"object":o=1;break;case"string":o=2;break;case"symbol":o=3;break;case"function":o=4;break}s.setUint32(n,Number(c),!0),s.setUint32(n+4,2146959360|o,!0)}loadString(n,t){if(this.memory==null)return"";let c=new Uint8ClampedArray(this.memory.buffer,n,Number(t)).slice();return Z.decode(c)}}var W="/assets/main.wasm",y=100,i=new p,I={module:{},env:{},...i.importObject()};class O{exports;events;actions;constructor({exports:n,events:t=[]}){this.exports=n,this.events=t,this.actions={},Object.entries(n).forEach(([s,c])=>{if(typeof c!=="function")return;this.actions[s]=this.#n.bind(this,s)})}addEvent(n){if(this.events.length>=y)this.events.length=0;return this.events.push(n)-1}#n(n,...t){let s=this.exports[n];if(typeof s!=="function")throw Error(`Action ${n} is not a function`);let c=this.addEvent(t[0]);return s(c)}}async function M(n={}){let t=n?.url??W,{instance:s}=await WebAssembly.instantiateStreaming(fetch(t),I);i.memory=s.exports.memory,window._zx=new O({exports:s.exports});let c=s.exports.mainClient;if(typeof c==="function")c()}export{M as init};
|