|
1 | 1 |
|
2 | 2 | function setAttributeInner(node,field,value,ns){if(ns==="style"){node.style.setProperty(field,value);return}if(ns){node.setAttributeNS(ns,field,value);return}switch(field){case"value":if(node.value!==value)node.value=value;break;case"initial_value":node.defaultValue=value;break;case"checked":node.checked=truthy(value);break;case"initial_checked":node.defaultChecked=truthy(value);break;case"selected":node.selected=truthy(value);break;case"initial_selected":node.defaultSelected=truthy(value);break;case"dangerous_inner_html":node.innerHTML=value;break;default:if(!truthy(value)&&isBoolAttr(field))node.removeAttribute(field);else node.setAttribute(field,value)}}var truthy=function(val){return val==="true"||val===!0},isBoolAttr=function(field){switch(field){case"allowfullscreen":case"allowpaymentrequest":case"async":case"autofocus":case"autoplay":case"checked":case"controls":case"default":case"defer":case"disabled":case"formnovalidate":case"hidden":case"ismap":case"itemscope":case"loop":case"multiple":case"muted":case"nomodule":case"novalidate":case"open":case"playsinline":case"readonly":case"required":case"reversed":case"selected":case"truespeed":case"webkitdirectory":return!0;default:return!1}};class BaseInterpreter{global;local;root;handler;nodes;stack;templates;m;constructor(){}initialize(root,handler=null){if(this.global={},this.local={},this.root=root,this.nodes=[root],this.stack=[root],this.templates={},handler)this.handler=handler}createListener(event_name,element,bubbles){if(bubbles)if(this.global[event_name]===void 0)this.global[event_name]={active:1,callback:this.handler},this.root.addEventListener(event_name,this.handler);else this.global[event_name].active++;else{const id=element.getAttribute("data-dioxus-id");if(!this.local[id])this.local[id]={};element.addEventListener(event_name,this.handler)}}removeListener(element,event_name,bubbles){if(bubbles)this.removeBubblingListener(event_name);else this.removeNonBubblingListener(element,event_name)}removeBubblingListener(event_name){if(this.global[event_name].active--,this.global[event_name].active===0)this.root.removeEventListener(event_name,this.global[event_name].callback),delete this.global[event_name]}removeNonBubblingListener(element,event_name){const id=element.getAttribute("data-dioxus-id");if(delete this.local[id][event_name],Object.keys(this.local[id]).length===0)delete this.local[id];element.removeEventListener(event_name,this.handler)}removeAllNonBubblingListeners(element){const id=element.getAttribute("data-dioxus-id");delete this.local[id]}getNode(id){return this.nodes[id]}appendChildren(id,many){const root=this.nodes[id],els=this.stack.splice(this.stack.length-many);for(let k=0;k<many;k++)root.appendChild(els[k])}loadChild(ptr,len){let node=this.stack[this.stack.length-1],ptr_end=ptr+len;for(;ptr<ptr_end;ptr++){let end=this.m.getUint8(ptr);for(node=node.firstChild;end>0;end--)node=node.nextSibling}return node}saveTemplate(nodes,tmpl_id){this.templates[tmpl_id]=nodes}hydrate(ids){const hydrateNodes=document.querySelectorAll("[data-node-hydration]");for(let i=0;i<hydrateNodes.length;i++){const hydrateNode=hydrateNodes[i],split=hydrateNode.getAttribute("data-node-hydration").split(","),id=ids[parseInt(split[0])];if(this.nodes[id]=hydrateNode,split.length>1){hydrateNode.listening=split.length-1,hydrateNode.setAttribute("data-dioxus-id",id.toString());for(let j=1;j<split.length;j++){const split2=split[j].split(":"),event_name=split2[0],bubbles=split2[1]==="1";this.createListener(event_name,hydrateNode,bubbles)}}}const treeWalker=document.createTreeWalker(document.body,NodeFilter.SHOW_COMMENT);let currentNode=treeWalker.nextNode();while(currentNode){const split=currentNode.textContent.split("node-id");if(split.length>1)this.nodes[ids[parseInt(split[1])]]=currentNode.nextSibling;currentNode=treeWalker.nextNode()}}setAttributeInner(node,field,value,ns){setAttributeInner(node,field,value,ns)}}export{BaseInterpreter};
|
3 | 3 |
|
4 |
| - let many,bubbles,value,id,field,ns; |
| 4 | + let bubbles,many,id,field,value,ns; |
5 | 5 | export class RawInterpreter extends BaseInterpreter {
|
6 | 6 | constructor(r) {
|
7 | 7 | super();
|
|
14 | 14 | this.e = null;
|
15 | 15 | this.z = null;
|
16 | 16 | this.metaflags = null;
|
17 |
| - this.attr = []; |
18 |
| - this.attr_cache_hit = null; |
19 |
| - this.attr_cache_idx; |
20 |
| - this.get_attr = function() { |
21 |
| - this.attr_cache_idx = this.u8buf[this.u8bufp++]; |
22 |
| - if(this.attr_cache_idx & 128){ |
23 |
| - this.attr_cache_hit=this.s.substring(this.sp,this.sp+=this.u8buf[this.u8bufp++]); |
24 |
| - this.attr[this.attr_cache_idx&4294967167]=this.attr_cache_hit; |
25 |
| - return this.attr_cache_hit; |
| 17 | + this.u32buf=null;this.u32bufp=null;this.evt = []; |
| 18 | + this.evt_cache_hit = null; |
| 19 | + this.evt_cache_idx; |
| 20 | + this.get_evt = function() { |
| 21 | + this.evt_cache_idx = this.u8buf[this.u8bufp++]; |
| 22 | + if(this.evt_cache_idx & 128){ |
| 23 | + this.evt_cache_hit=this.s.substring(this.sp,this.sp+=this.u8buf[this.u8bufp++]); |
| 24 | + this.evt[this.evt_cache_idx&4294967167]=this.evt_cache_hit; |
| 25 | + return this.evt_cache_hit; |
26 | 26 | }
|
27 | 27 | else{
|
28 |
| - return this.attr[this.attr_cache_idx&4294967167]; |
| 28 | + return this.evt[this.evt_cache_idx&4294967167]; |
| 29 | + } |
| 30 | + };this.ns_cache = []; |
| 31 | + this.ns_cache_cache_hit = null; |
| 32 | + this.ns_cache_cache_idx; |
| 33 | + this.get_ns_cache = function() { |
| 34 | + this.ns_cache_cache_idx = this.u8buf[this.u8bufp++]; |
| 35 | + if(this.ns_cache_cache_idx & 128){ |
| 36 | + this.ns_cache_cache_hit=this.s.substring(this.sp,this.sp+=this.u8buf[this.u8bufp++]); |
| 37 | + this.ns_cache[this.ns_cache_cache_idx&4294967167]=this.ns_cache_cache_hit; |
| 38 | + return this.ns_cache_cache_hit; |
| 39 | + } |
| 40 | + else{ |
| 41 | + return this.ns_cache[this.ns_cache_cache_idx&4294967167]; |
29 | 42 | }
|
30 |
| - };this.el = []; |
| 43 | + };this.s = "";this.lsp = null;this.sp = null;this.sl = null;this.c = new TextDecoder();this.el = []; |
31 | 44 | this.el_cache_hit = null;
|
32 | 45 | this.el_cache_idx;
|
33 | 46 | this.get_el = function() {
|
|
40 | 53 | else{
|
41 | 54 | return this.el[this.el_cache_idx&4294967167];
|
42 | 55 | }
|
43 |
| - };this.s = "";this.lsp = null;this.sp = null;this.sl = null;this.c = new TextDecoder();this.evt = []; |
44 |
| - this.evt_cache_hit = null; |
45 |
| - this.evt_cache_idx; |
46 |
| - this.get_evt = function() { |
47 |
| - this.evt_cache_idx = this.u8buf[this.u8bufp++]; |
48 |
| - if(this.evt_cache_idx & 128){ |
49 |
| - this.evt_cache_hit=this.s.substring(this.sp,this.sp+=this.u8buf[this.u8bufp++]); |
50 |
| - this.evt[this.evt_cache_idx&4294967167]=this.evt_cache_hit; |
51 |
| - return this.evt_cache_hit; |
| 56 | + };this.u16buf=null;this.u16bufp=null;this.u8buf=null;this.u8bufp=null;this.attr = []; |
| 57 | + this.attr_cache_hit = null; |
| 58 | + this.attr_cache_idx; |
| 59 | + this.get_attr = function() { |
| 60 | + this.attr_cache_idx = this.u8buf[this.u8bufp++]; |
| 61 | + if(this.attr_cache_idx & 128){ |
| 62 | + this.attr_cache_hit=this.s.substring(this.sp,this.sp+=this.u8buf[this.u8bufp++]); |
| 63 | + this.attr[this.attr_cache_idx&4294967167]=this.attr_cache_hit; |
| 64 | + return this.attr_cache_hit; |
52 | 65 | }
|
53 | 66 | else{
|
54 |
| - return this.evt[this.evt_cache_idx&4294967167]; |
| 67 | + return this.attr[this.attr_cache_idx&4294967167]; |
55 | 68 | }
|
56 | 69 | };this.namespace = [];
|
57 | 70 | this.namespace_cache_hit = null;
|
|
66 | 79 | else{
|
67 | 80 | return this.namespace[this.namespace_cache_idx&4294967167];
|
68 | 81 | }
|
69 |
| - };this.u32buf=null;this.u32bufp=null;this.u16buf=null;this.u16bufp=null;this.u8buf=null;this.u8bufp=null;this.ns_cache = []; |
70 |
| - this.ns_cache_cache_hit = null; |
71 |
| - this.ns_cache_cache_idx; |
72 |
| - this.get_ns_cache = function() { |
73 |
| - this.ns_cache_cache_idx = this.u8buf[this.u8bufp++]; |
74 |
| - if(this.ns_cache_cache_idx & 128){ |
75 |
| - this.ns_cache_cache_hit=this.s.substring(this.sp,this.sp+=this.u8buf[this.u8bufp++]); |
76 |
| - this.ns_cache[this.ns_cache_cache_idx&4294967167]=this.ns_cache_cache_hit; |
77 |
| - return this.ns_cache_cache_hit; |
78 |
| - } |
79 |
| - else{ |
80 |
| - return this.ns_cache[this.ns_cache_cache_idx&4294967167]; |
81 |
| - } |
82 | 82 | };
|
83 | 83 | }
|
84 | 84 |
|
|
92 | 92 | this.ls=this.m.getUint32(this.d+6*4,true);
|
93 | 93 | }
|
94 | 94 | this.p=this.ls;
|
95 |
| - if (this.metaflags&1){ |
| 95 | + if ((this.metaflags>>>3)&1){ |
| 96 | + this.t = this.m.getUint32(this.d+3*4,true); |
| 97 | + this.u32buf=new Uint32Array(this.m.buffer,this.t,((this.m.buffer.byteLength-this.t)-(this.m.buffer.byteLength-this.t)%4)/4); |
| 98 | + } |
| 99 | + this.u32bufp=0;if (this.metaflags&1){ |
96 | 100 | this.lsp = this.m.getUint32(this.d+1*4,true);
|
97 | 101 | }
|
98 | 102 | if ((this.metaflags>>>2)&1) {
|
|
118 | 122 | this.s = this.c.decode(new DataView(this.m.buffer, this.lsp, this.sl));
|
119 | 123 | }
|
120 | 124 | }
|
121 |
| - this.sp=0;if ((this.metaflags>>>3)&1){ |
122 |
| - this.t = this.m.getUint32(this.d+3*4,true); |
123 |
| - this.u32buf=new Uint32Array(this.m.buffer,this.t,((this.m.buffer.byteLength-this.t)-(this.m.buffer.byteLength-this.t)%4)/4); |
124 |
| - } |
125 |
| - this.u32bufp=0;if ((this.metaflags>>>4)&1){ |
| 125 | + this.sp=0;if ((this.metaflags>>>4)&1){ |
126 | 126 | this.t = this.m.getUint32(this.d+4*4,true);
|
127 | 127 | this.u16buf=new Uint16Array(this.m.buffer,this.t,((this.m.buffer.byteLength-this.t)-(this.m.buffer.byteLength-this.t)%2)/2);
|
128 | 128 | }
|
|
0 commit comments