* wip * pull out eval into the interpreter * fix web eval * fix DioxusChannel name * properly drop dioxus channel * use typescript dioxus chanel in desktop * add more comments to native eval * add desktop headless eval tests * expand web playwright eval tests * fix web headless tests * fix default hasher path * run eval tests on windows * restore desktop query drop code * remove data from drop desktop query message * catch syntax errors in desktop eval * catch js runtime errors in desktop * fix typo interprerter -> interpreter --------- Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
2 lines
1.1 KiB
JavaScript
2 lines
1.1 KiB
JavaScript
class Channel{pending;waiting;constructor(){this.pending=[],this.waiting=[]}send(data){if(this.waiting.length>0){this.waiting.shift()(data);return}this.pending.push(data)}async recv(){return new Promise((resolve,_reject)=>{if(this.pending.length>0){resolve(this.pending.shift());return}this.waiting.push(resolve)})}}class WeakDioxusChannel{inner;constructor(channel){this.inner=new WeakRef(channel)}rustSend(data){let channel=this.inner.deref();if(channel)channel.rustSend(data)}async rustRecv(){let channel=this.inner.deref();if(channel)return await channel.rustRecv()}}class DioxusChannel{weak(){return new WeakDioxusChannel(this)}}class WebDioxusChannel extends DioxusChannel{js_to_rust;rust_to_js;owner;constructor(owner){super();this.owner=owner,this.js_to_rust=new Channel,this.rust_to_js=new Channel}weak(){return new WeakDioxusChannel(this)}async recv(){return await this.rust_to_js.recv()}send(data){this.js_to_rust.send(data)}rustSend(data){this.rust_to_js.send(data)}async rustRecv(){return await this.js_to_rust.recv()}}export{WebDioxusChannel,WeakDioxusChannel,DioxusChannel,Channel};
|