jaxs 0.7.0 → 0.7.2
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/dist/jaxs.d.ts +1028 -722
- package/dist/jaxs.js +1069 -752
- package/dist/jaxs.umd.cjs +1220 -1
- package/package.json +1 -1
package/dist/jaxs.umd.cjs
CHANGED
|
@@ -1 +1,1220 @@
|
|
|
1
|
-
(function(p,f){typeof exports=="object"&&typeof module<"u"?f(exports):typeof define=="function"&&define.amd?define(["exports"],f):(p=typeof globalThis<"u"?globalThis:p||self,f(p.jaxs={}))})(this,function(p){"use strict";const f=(e,t)=>t.createElement(e),nt=(e,t)=>{for(const s in t){if(s==="__self")continue;const n=t[s].toString();if(s==="value"){const r=e;r.value!==n&&(r.value=n)}else e.setAttribute(s,n)}},rt=(e,t,s)=>{const n={};for(const r in t){const i=t[r],a=l=>s(i,l);e.addEventListener(r,a),n[r]={domEvent:r,busEvent:i,listener:a}}e.eventMaps=n},it=(e,t,s,n)=>{const r=f(e,n.document);return nt(r,t),rt(r,s,n.publish),r},g="http://www.w3.org/2000/svg",ot={animate:!0,animateMotion:!0,animateTransform:!0,circle:!0,clipPath:!0,defs:!0,desc:!0,ellipse:!0,feBlend:!0,feColorMatrix:!0,feComponentTransfer:!0,feComposite:!0,feConvolveMatrix:!0,feDiffuseLighting:!0,feDisplacementMap:!0,feDistantLight:!0,feDropShadow:!0,feFlood:!0,feFuncA:!0,feFuncB:!0,feFuncG:!0,feFuncR:!0,feGaussianBlur:!0,feImage:!0,feMerge:!0,feMergeNode:!0,feMorphology:!0,feOffset:!0,fePointLight:!0,feSpecularLighting:!0,feSpotLight:!0,feTile:!0,feTurbulence:!0,filter:!0,foreignObject:!0,g:!0,image:!0,line:!0,linearGradient:!0,marker:!0,mask:!0,metadata:!0,mpath:!0,path:!0,pattern:!0,polygon:!0,polyline:!0,radialGradient:!0,rect:!0,script:!0,set:!0,stop:!0,style:!0,svg:!0,switch:!0,symbol:!0,text:!0,textPath:!0,title:!0,tspan:!0,use:!0,view:!0},ut=(e,t)=>!!(ot[e]||e==="a"&&t===g),at=(e,t,s)=>{const n=s.createElementNS(g,e);for(const r in t)r==="__self"||r==="xmlns"||n.setAttributeNS(null,r,t[r].toString());return n},ct=e=>e.namespaceURI===g,lt=(e,t)=>t.createTextNode(e);class ht{constructor(t){this.value=t.toString()}render(t){const s=lt(this.value,t.document);return s.__jsx="TextNode",[s]}}const dt=e=>typeof e=="string"||typeof e=="number",pt=e=>new ht(e),mt=e=>dt(e)?pt(e):e,ft=e=>bt(e).map(mt).flat(),bt=e=>Array.isArray(e)?e.flat():e?[e]:[],S=(e,t={})=>e||t.children||[],vt=(e,t="")=>{const s={},n={};for(const r in e){const i=e[r];if(r.match(/^on.+/i)){const a=r.slice(2).toLowerCase();n[a]=i?i.toString():""}else{if(i===!1)continue;r==="__source"?s.__source=e.__source:s[r]=gt(r,i,t)}}return{attributes:s,events:n}},gt=(e,t,s="")=>t==null?s:t.toString(),yt=(e,t)=>{const s=e||{},n=S(t,s);return s.children=s.children||n,s},T=(e,t,s,n=[])=>e.reduce(Et(t,s),n).flat(),Et=(e,t)=>(s,n)=>n?Array.isArray(n)?T(n,e,t,s):(n.render(e,t).forEach(r=>s.push(r)),s):s;class j{constructor(t){this.collection=ft(t)}render(t,s){this.parentElement=s;const n=this.generateDom(t);return this.attachToParent(n),n}generateDom(t){return T(this.collection,t,this.parentElement)}attachToParent(t){if(this.parentElement===void 0)return;const s=this.parentElement;t.forEach(n=>s.appendChild(n))}}class xt{constructor(t,s){this.type=t,this.attributes=s}generate(){return this.attributes.key||this.sourceKey()||this.createKeyFromAttributes()}sourceKey(){if(this.attributes.__source){const{fileName:t,lineNumber:s,columnNumber:n}=this.attributes.__source;return`${t}:${s}:${n}`}}createKeyFromAttributes(){const t=this.attributes.id?`#${this.attributes.id}`:"",s=this.attributes.type?`[type=${this.attributes.type}]`:"",n=this.attributes.name?`[name=${this.attributes.name}]`:"";return`${this.type}${t}${s}${n}`}}class At{constructor(t,s,n=[]){this.type=t;const{events:r,attributes:i}=vt(s);this.events=r,this.attributes=i,this.isSvg=ut(this.type,this.attributes.xmlns),this.children=new j(n)}render(t){const s=this.generateDom(t);return s?(this.children.render(t,s),[s]):[]}generateDom(t){return this.isSvg?this.generateSvgDom(t):this.generateHtmlDom(t)}generateHtmlDom(t){const s=it(this.type,this.attributes,this.events,t);return s.__jsx=this.jsxKey(),s}generateSvgDom(t){const s=at(this.type,this.attributes,t.document);return s.__jsx=this.jsxKey(),s}jsxKey(){return new xt(this.type,this.attributes).generate()}}const O=(e,t,...s)=>typeof e=="string"?new At(e,t,s):e(yt(t,s));O.fragment=(e,t)=>{const s=S(t,e);return new j(s)};class wt{constructor(t,s,n){this.template=t,this.selector=s,this.renderKit=n,this.dom=[]}renderAndAttach(t){this.parentElement=this.getParentElement(),this.dom=this.render({...t,parent:this.parentElement}),this.parentElement&&this.attach()}render(t){return this.template.render(t)}attach(){this.parentElement&&(this.parentElement.innerHTML=""),this.dom.forEach(t=>{this.parentElement&&this.parentElement.appendChild(t)})}getParentElement(){return this.renderKit.document.querySelector(this.selector)}}const Nt=(e,t,s)=>{const n=new wt(e,t,s);return n.renderAndAttach(s),n},M="go-to-href",k="go-to",b="navigation:location-change",$="navigation:route-change",_t=Object.freeze(Object.defineProperty({__proto__:null,linkNavigationEvent:M,locationChangeEvent:b,navigationEvent:k,routeChangeEvent:$},Symbol.toStringTag,{value:"Module"})),P=e=>{e.create("route",{host:"",path:"",query:{}})},D=e=>{const t=e.closest("[href]");return t&&t.getAttribute("href")||""},y=(e,{publish:t,window:s})=>{s.history.pushState(null,"",e),t(b,null)},F=(e,t)=>{if(!e||!e.target)return;e.preventDefault();const s=D(e.target);y(s,t)},L=e=>e.replace(/^\?/,"").split("&").reduce((t,s)=>{if(!s)return t;const n=s.split("=");return t[n[0]]=n[1],t},{}),z=(e,t)=>{const{state:s,publish:n,window:r}=t,{host:i,pathname:a,search:l}=r.location,u=a,d=L(l),c={host:i,path:u,query:d};s.store("route").update(c),n($,c)},B=e=>{const{subscribe:t}=e;t(M,F),t(k,(s,n)=>{y(s,n)})},V=e=>{const{publish:t,subscribe:s,state:n,window:r}=e;P(n),r.addEventListener("popstate",()=>t(b,null)),s(b,z)},K=e=>{setTimeout(()=>e.publish(b,null),0)},R=e=>{V(e),B(e),K(e)},St=Object.freeze(Object.defineProperty({__proto__:null,publishLocation:K,startNavigation:R,subscribeToHistoryChange:V,subscribeToNavigation:B},Symbol.toStringTag,{value:"Module"}));class U{constructor({window:t,document:s,publish:n,subscribe:r,bus:i,state:a,renderKit:l}){this.window=t,this.document=s,this.publish=n,this.subscribe=r,this.bus=i,this.state=a,this.renderKit=l,this.roots=[]}render(t,s){const n=Nt(t,s,this.renderKit);return this.roots.push(n),n}startNavigation(){R(this)}}const Tt=Object.freeze(Object.defineProperty({__proto__:null,App:U},Symbol.toStringTag,{value:"Module"}));class C{constructor(){this.lookup={}}add(t,s,n){this.ensureArrayFor(t);const r={listener:s,index:n,matcher:t};return this.lookup[t].push(r),()=>this.remove(r)}remove(t){this.lookup[t.matcher]&&(this.lookup[t.matcher]=this.lookup[t.matcher].reduce((s,n)=>(n!==t&&s.push(n),s),[]))}matches(t){return this.lookup[t]||[]}ensureArrayFor(t){this.lookup[t]||(this.lookup[t]=[])}}class I{constructor(){this.lookup=[]}add(t,s,n){const r={listener:s,index:n,matcher:t};return this.lookup.push(r),()=>this.remove(r)}remove(t){this.lookup=this.lookup.reduce((s,n)=>(n!==t&&s.push(n),s),[])}matches(t){return this.lookup.filter(s=>s.matcher.test(t))}}class jt{constructor({publish:t,event:s,payload:n,timer:r}){this.setNewTimeout=()=>{this.stopped||setTimeout(()=>{this.publishEvent(),this.setNewTimeout()},this.calculateNextTime())},this.calculateNextTime=()=>this.timer({timeDiff:this.diff(),callCount:this.callCount,stop:this.stop}),this.publish=t,this.event=s,this.payload=n||null,this.stop=this.stopTimeout.bind(this),this.stopped=!1,this.timer=r,this.startedAt=new Date().getTime(),this.callCount=0}start(){this.setNewTimeout()}diff(){return new Date().getTime()-this.startedAt}stopTimeout(){this.stopped=!0,this.timeoutId&&clearTimeout(this.timeoutId)}publishEvent(){this.stopped||(this.callCount+=1,this.publish(this.event,this.payload))}}const Ot=e=>{const{offset:t,period:s}=e,n=({callCount:r})=>t&&r==0?t:s;return{event:e.event,publish:e.publish,payload:e.payload,timer:n}},Mt=e=>{let t;"timer"in e?t=e:t=Ot(e);const s=new jt(t);return s.start(),s.stop};class q{constructor(){this.exactSubscriptions=new C,this.fuzzySubscriptions=new I,this.currentIndex=0}subscribe(t,s){let n;return typeof t=="string"?n=this.exactSubscriptions.add(t,s,this.currentIndex):n=this.fuzzySubscriptions.add(t,s,this.currentIndex),this.currentIndex+=1,n}publish(t,s){[...this.exactSubscriptions.matches(t),...this.fuzzySubscriptions.matches(t)].sort((r,i)=>r.index-i.index).forEach(r=>{r.listener(s,this.listenerOptions(t))})}addListenerOptions(t){this.options=t}listenerOptions(t){return{eventName:t,...this.options,publish:this.publish.bind(this)}}}const J=()=>{const e=new q;return{bus:e,publish:(n,r)=>e.publish(n,r),subscribe:(n,r)=>e.subscribe(n,r)}},kt=Object.freeze(Object.defineProperty({__proto__:null,ExactSubscriptions:C,FuzzySubscriptions:I,JaxsBus:q,createBus:J,publishPeriodically:Mt},Symbol.toStringTag,{value:"Module"})),v=e=>Array.isArray(e),E=e=>e!==null&&!v(e)&&typeof e=="object",$t=(e,t)=>e===t,Pt=(e,t)=>Object.keys(e).length===Object.keys(t).length,Dt=(e,t)=>!(E(e)&&E(t))||!Pt(e,t)?!1:Object.keys(e).every(s=>{const n=e[s],r=t[s];return x(n,r)}),Ft=(e,t)=>!(v(e)&&v(t))||e.length!==t.length?!1:e.every((s,n)=>{const r=t[n];return x(s,r)}),x=(e,t)=>E(e)?Dt(e,t):v(e)?Ft(e,t):$t(e,t);class A{constructor(t){this.name=t.name,this.parent=t.parent,this._value=t.value,this.initialValue=structuredClone(t.value)}get value(){return this._value}set value(t){throw new Error("Cannot set value directly. Use an updater!")}reset(){this._value=this.initialValue}update(t){if(typeof t=="function"){const s=this.getUpdatedValue(t);this.updateValue(s)}else this.updateValue(t)}updateValue(t){x(this._value,t)||(this._value=t,this.parent.notify(this.name))}getUpdatedValue(t){return t(this.value)}}class w{constructor(t){this.store=t}update(t){this.store.update(t)}reset(){this.store.update(this.store.initialValue)}get value(){return this.store.value}}class Lt extends w{updateAttribute(t,s){const n={...this.value};n[t]=s,this.update(n)}resetAttribute(t){const s={...this.value},n=this.store.initialValue[t];s[t]=n,this.update(s)}}const zt=e=>new Lt(e);class Bt extends w{push(t){const s=[...this.value,t];this.update(s)}pop(){const t=[...this.value],s=t.pop();return this.update(t),s}unshift(t){const s=[t,...this.value];this.update(s)}shift(){const t=[...this.value],s=t.shift();return this.update(t),s}addSorter(t,s){this[t]=()=>{this.sortBy(s)}}sortBy(t){const s=[...this.value];s.sort(t),this.update(s)}insertAt(t,s){const n=[...this.value];n.splice(t,0,s),this.update(n)}remove(t){const s=this.value.reduce((n,r)=>(r!==t&&n.push(r),n),[]);this.update(s)}removeBy(t){const s=this.value.reduce((n,r)=>(t(r)||n.push(r),n),[]);this.update(s)}}const Vt=e=>new Bt(e);class Kt extends w{toggle(){const t=!this.value;this.update(t)}setTrue(){this.update(!0)}setFalse(){this.update(!1)}}const Rt={object:zt,list:Vt,boolean:e=>new Kt(e)},N="state";class G{constructor(t){this.publisher=t,this.stores={},this.eventNamePrefix=N,this.notifications=new Set,this.inTransaction=!1}create(t,s){const n=new A({name:t,parent:this,value:s});return this.stores[t]=n,n}store(t){return this.stores[t]||new A({name:t,parent:this,value:void 0})}get(t){return this.store(t).value}getAll(t){return t.reduce((s,n)=>(s[n]=this.get(n),s),{})}notify(t){this.inTransaction?this.notifications.add(t):this.publish(t)}update(t,s){this.store(t).update(s)}transaction(t){this.inTransaction=!0,t(this.stores),this.inTransaction=!1,this.publishAll()}publishAll(){this.notifications.forEach(t=>{this.publish(t)}),this.notifications.clear()}publish(t){this.publisher(this.event(t),{state:this,store:this.store(t)})}event(t){return`${this.eventNamePrefix}:${t}`}}const H=e=>new G(e),Ut=Object.freeze(Object.defineProperty({__proto__:null,State:G,Store:A,createState:H,eventName:N,updaters:Rt},Symbol.toStringTag,{value:"Module"}));class Ct{constructor(t){this.setupDomEnvironment(t)}setup(){return this.setupBus(),this.setupState(),this.addBusOptions(),this.setRenderKit(),new U({window:this.window,document:this.document,publish:this.publish,subscribe:this.subscribe,bus:this.bus,state:this.state,renderKit:this.renderKit})}setupDomEnvironment(t){t.window?(this.window=t.window,this.document=this.window.document):t.document?(this.window=t.document.defaultView,this.document=t.document):(this.window=window,this.document=document)}setupBus(){const{publish:t,subscribe:s,bus:n}=J();this.publish=t,this.subscribe=s,this.bus=n}setupState(){this.state=H(this.publish)}addBusOptions(){this.bus.addListenerOptions({state:this.state,document:this.document,window:this.window})}setRenderKit(){this.renderKit={publish:this.publish,subscribe:this.subscribe,state:this.state,document:this.document,window:this.window}}}const It=(e={})=>{const s=new Ct(e).setup();return s.startNavigation(),s};var o=(e=>(e[e.removeNode=0]="removeNode",e[e.insertNode=1]="insertNode",e[e.replaceNode=2]="replaceNode",e[e.removeAttribute=3]="removeAttribute",e[e.addAttribute=4]="addAttribute",e[e.updateAttribute=5]="updateAttribute",e[e.removeEvent=6]="removeEvent",e[e.addEvent=7]="addEvent",e[e.updateEvent=8]="updateEvent",e[e.changeValue=9]="changeValue",e[e.changeText=10]="changeText",e))(o||{});const qt=Object.freeze(Object.defineProperty({__proto__:null,ChangeInstructionTypes:o},Symbol.toStringTag,{value:"Module"})),Jt=(e,t)=>({source:e,target:t,type:o.changeText,data:{}}),Gt=(e,t)=>({source:e,target:t,type:o.replaceNode,data:{}}),Ht=(e,t,s)=>({source:e,target:t,data:s,type:o.removeAttribute}),Qt=(e,t,s)=>({source:e,target:t,data:s,type:o.addAttribute}),Wt=(e,t,s)=>({source:e,target:t,data:s,type:o.updateAttribute}),Xt=(e,t,s)=>({source:e,target:t,data:s,type:o.removeEvent}),Yt=(e,t,s)=>({source:e,target:t,data:s,type:o.addEvent}),Zt=(e,t,s)=>({source:e,target:t,data:s,type:o.updateEvent}),Q=e=>({source:e,target:e,type:o.removeNode,data:{}}),_=(e,t)=>({target:e,source:e,type:o.insertNode,data:t}),te=(e,t,s)=>({source:e,target:t,type:o.changeValue,data:s}),ee=(e,t)=>e.type>t.type?1:e.type<t.type?-1:0,W={index:-1};class se{constructor(){this.map={}}populate(t){t.forEach((s,n)=>{const r=s.__jsx;r&&(this.map[r]=this.map[r]||[],this.map[r].push({element:s,index:n}))})}pullMatch(t){const s=t&&t.__jsx;return!s||!(this.map[s]&&this.map[s].length)?W:this.map[s].shift()}clear(t){const s=t&&t.__jsx;if(!(s&&this.map[s]&&this.map[s].length))return;const n=this.map[s];this.map[s]=n.reduce((r,i)=>(i.element!==t&&r.push(i),r),[])}check(t){const s=t&&t.__jsx;return s&&this.map[s]?this.map[s].length>0:!1}remaining(){return Object.values(this.map).flat()}}const X=e=>{const t=new se;return t.populate(e),t},Y=(e,t,s=!1)=>{const n=[],r=e.attributes,i=r.length,a=t.attributes,l=a.length;let u,d,c;for(u=0;u<i;u++){c=null;const h=r.item(u);if(h){for(d=0;d<l;d++){const m=a.item(d);if(m&&h.name==m.name){c=m;break}}c?h.value!==c.value&&n.push(Wt(e,t,{name:h.name,value:c.value,isSvg:s})):n.push(Ht(e,t,{name:h.name,isSvg:s}))}}for(u=0;u<l;u++){c=null;const h=a.item(u);if(h){for(d=0;d<i;d++){const m=r.item(d);if(m&&m.name==h.name){c=m;break}}c||n.push(Qt(e,t,{name:h.name,value:h.value,isSvg:s}))}}return n},ne=(e,t)=>{const s=[],n=e.eventMaps,r=t.eventMaps,i=Object.keys(n),a=Object.keys(r);return i.forEach(l=>{const u=n[l],d=r[l];d?d.busEvent!==u.busEvent&&s.push(Zt(e,t,{name:l,targetValue:d.listener,sourceValue:u.listener})):s.push(Xt(e,t,{name:u.domEvent,value:u.listener}))}),a.forEach(l=>{const u=n[l],d=r[l];u||s.push(Yt(e,t,{name:d.domEvent,value:d.listener}))}),s},re=e=>e.tagName!=="INPUT",ie=(e,t)=>e.value===t.value,oe=(e,t)=>{if(re(e)||ie(e,t))return[];const s=e,n=t;return[te(s,n,{name:"value",value:n.value})]},ue=(e,t)=>{const s=Y(e,t),n=ne(e,t),r=oe(e,t);return s.concat(n).concat(r)},ae=(e,t)=>Y(e,t,!0),ce=(e,t)=>e.textContent!==t.textContent?[Jt(e,t)]:[],le=(e,t,s)=>{let n=[];if(e.nodeType===1&&ct(e)){const r=e,i=t,a=ae(r,i),l=s(r.childNodes,i.childNodes,r);n=a.concat(l)}else if(e.nodeType===1){const r=e,i=t,a=ue(r,i),l=s(r.childNodes,i.childNodes,r);n=a.concat(l)}else e.nodeType===3&&(n=ce(e,t));return n},Z=(e,t,s)=>{const n=[],r=he(e,t),i=X(e),a=X(t),l=[];let u=0;for(;u<r;u++){const c=e[u],h=t[u];if(h&&a.check(h)){const m=i.pullMatch(h);a.clear(h),m.element?(m.index!==u&&n.push(_(m.element,{parent:s,index:u})),l.push({source:m.element,target:h})):c?a.check(c)?n.push(_(h,{parent:s,index:u})):(i.clear(c),n.push(Gt(c,h))):n.push(_(h,{parent:s,index:u}))}else c&&i.pullMatch(c).element&&n.push(Q(c))}i.remaining().forEach(({element:c})=>{n.push(Q(c))});const d=l.reduce((c,{source:h,target:m})=>c.concat(le(h,m,Z)),[]);return n.concat(d).sort(ee)},he=(e,t)=>{const s=e.length,n=t.length;return s>n?s:n},de=(e,t,s)=>{const n=Z(e,t,s);return n.forEach(r=>{pe(r)}),n},pe=e=>{(_e[e.type]||me)(e)},me=e=>{},fe=e=>{const{source:t,target:s}=e;t.nodeValue=s.textContent},be=e=>{const{source:t}=e;t.remove()},ve=e=>{const{target:t,data:s}=e,{parent:n,index:r}=s,i=n.childNodes[r];i?i&&i!==t&&n.insertBefore(t,i):n.appendChild(t)},ge=e=>{const{source:t,target:s}=e;t.replaceWith(s)},ye=e=>{const{source:t,data:s}=e,{name:n,isSvg:r}=s;r?t.removeAttributeNS(null,n):t.removeAttribute(n)},tt=e=>{const{source:t,data:s}=e,{name:n,value:r,isSvg:i}=s;i?t.setAttributeNS(null,n,r):t.setAttribute(n,r)},Ee=e=>{tt(e)},xe=e=>{const t=e.data,s=e.source,{name:n,value:r}=t;s.removeEventListener(n,r)},Ae=e=>{const t=e.data,s=e.source,{name:n,value:r}=t;s.addEventListener(n,r)},we=e=>{const t=e.data,s=e.source,{name:n,sourceValue:r,targetValue:i}=t;s.removeEventListener(n,r),s.addEventListener(n,i)},Ne=e=>{const t=e.data,s=e.source,{value:n}=t;s.value=n},_e={[o.changeText]:fe,[o.removeNode]:be,[o.insertNode]:ve,[o.replaceNode]:ge,[o.removeAttribute]:ye,[o.addAttribute]:tt,[o.updateAttribute]:Ee,[o.removeEvent]:xe,[o.addEvent]:Ae,[o.updateEvent]:we,[o.changeValue]:Ne},Se=(e,t,s)=>{const n=[...t];return e.forEach(r=>{Te(r,n,s)}),n},Te=(e,t,s)=>{const n=ke[e.type];n&&n(e,t,s)},je=(e,t)=>{const{source:s}=e,n=t.indexOf(s);n>=0&&t.splice(n,1)},Oe=(e,t,s)=>{const{target:n}=e,r=e.data,{index:i,parent:a}=r;s===a&&t.splice(i,0,n)},Me=(e,t)=>{const{target:s,source:n}=e,r=t.indexOf(n);r>=0&&(t[r]=s)},ke={[o.removeNode]:je,[o.insertNode]:Oe,[o.replaceNode]:Me};class $e{constructor({Template:t,subscriptions:s,attributes:n,viewModel:r}){this.Template=t,this.viewModel=r,this.attributes=n,this.subscriptions=s,this.dom=[],this.parentElement=null}render(t){return this.parentElement=t.parent,this.renderKit=t,this.subscribeForRerender(),this.dom=this.generateDom(t),this.dom}generateDom(t){const s={...this.attributes,...this.viewModel(t.state.getAll(this.subscriptions))},n=this.Template(s);return n?n.render(t):[]}rerender(){if(!this.parentElement&&this.dom[0]){const n=this.dom[0].parentElement;this.parentElement=n}const t=this.generateDom(this.renderKit),s=de(this.dom,t,this.parentElement);this.dom=Se(s,this.dom,this.parentElement)}subscribeForRerender(){const{subscribe:t}=this.renderKit;this.subscriptions.forEach(s=>{t(this.eventName(s),()=>this.rerender())})}eventName(t){return`${N}:${t}`}}const Pe=e=>e,et=({Template:e,viewModel:t,subscriptions:s})=>(s=s||[],t=t||Pe,n=>new $e({Template:e,viewModel:t,subscriptions:s,attributes:n})),De=Object.freeze(Object.defineProperty({__proto__:null,createRouteState:P,events:_t,extractQueryParams:L,findHref:D,navigate:y,onLinkClick:F,onLocationChange:z,start:St},Symbol.toStringTag,{value:"Module"})),Fe=e=>({path:t})=>t===e,Le=()=>!0,st=e=>({route:t})=>{const s=e.find(n=>n.match(t));return s&&s.Partial},ze=Object.freeze(Object.defineProperty({__proto__:null,buildRouter:st,catchAll:Le,exactPathMatch:Fe},Symbol.toStringTag,{value:"Module"})),Be=()=>({render:(e,t)=>[]}),Ve=e=>{const t=st(e);return et({Template:({route:n})=>(t({route:n})||Be)(),subscriptions:["route"]})};p.JaxsTypes=qt,p.appBuilding=Tt,p.bind=et,p.createApp=It,p.jsx=O,p.messageBus=kt,p.navigation=De,p.routedView=Ve,p.routing=ze,p.state=Ut,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
;(function (p, f) {
|
|
2
|
+
typeof exports == 'object' && typeof module < 'u'
|
|
3
|
+
? f(exports)
|
|
4
|
+
: typeof define == 'function' && define.amd
|
|
5
|
+
? define(['exports'], f)
|
|
6
|
+
: ((p = typeof globalThis < 'u' ? globalThis : p || self),
|
|
7
|
+
f((p.jaxs = {})))
|
|
8
|
+
})(this, function (p) {
|
|
9
|
+
'use strict'
|
|
10
|
+
const f = (e, t) => t.createElement(e),
|
|
11
|
+
nt = (e, t) => {
|
|
12
|
+
for (const s in t) {
|
|
13
|
+
if (s === '__self') continue
|
|
14
|
+
const n = t[s].toString()
|
|
15
|
+
if (s === 'value') {
|
|
16
|
+
const r = e
|
|
17
|
+
r.value !== n && (r.value = n)
|
|
18
|
+
} else e.setAttribute(s, n)
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
rt = (e, t, s) => {
|
|
22
|
+
const n = {}
|
|
23
|
+
for (const r in t) {
|
|
24
|
+
const i = t[r],
|
|
25
|
+
a = (l) => s(i, l)
|
|
26
|
+
e.addEventListener(r, a),
|
|
27
|
+
(n[r] = { domEvent: r, busEvent: i, listener: a })
|
|
28
|
+
}
|
|
29
|
+
e.eventMaps = n
|
|
30
|
+
},
|
|
31
|
+
it = (e, t, s, n) => {
|
|
32
|
+
const r = f(e, n.document)
|
|
33
|
+
return nt(r, t), rt(r, s, n.publish), r
|
|
34
|
+
},
|
|
35
|
+
g = 'http://www.w3.org/2000/svg',
|
|
36
|
+
ot = {
|
|
37
|
+
animate: !0,
|
|
38
|
+
animateMotion: !0,
|
|
39
|
+
animateTransform: !0,
|
|
40
|
+
circle: !0,
|
|
41
|
+
clipPath: !0,
|
|
42
|
+
defs: !0,
|
|
43
|
+
desc: !0,
|
|
44
|
+
ellipse: !0,
|
|
45
|
+
feBlend: !0,
|
|
46
|
+
feColorMatrix: !0,
|
|
47
|
+
feComponentTransfer: !0,
|
|
48
|
+
feComposite: !0,
|
|
49
|
+
feConvolveMatrix: !0,
|
|
50
|
+
feDiffuseLighting: !0,
|
|
51
|
+
feDisplacementMap: !0,
|
|
52
|
+
feDistantLight: !0,
|
|
53
|
+
feDropShadow: !0,
|
|
54
|
+
feFlood: !0,
|
|
55
|
+
feFuncA: !0,
|
|
56
|
+
feFuncB: !0,
|
|
57
|
+
feFuncG: !0,
|
|
58
|
+
feFuncR: !0,
|
|
59
|
+
feGaussianBlur: !0,
|
|
60
|
+
feImage: !0,
|
|
61
|
+
feMerge: !0,
|
|
62
|
+
feMergeNode: !0,
|
|
63
|
+
feMorphology: !0,
|
|
64
|
+
feOffset: !0,
|
|
65
|
+
fePointLight: !0,
|
|
66
|
+
feSpecularLighting: !0,
|
|
67
|
+
feSpotLight: !0,
|
|
68
|
+
feTile: !0,
|
|
69
|
+
feTurbulence: !0,
|
|
70
|
+
filter: !0,
|
|
71
|
+
foreignObject: !0,
|
|
72
|
+
g: !0,
|
|
73
|
+
image: !0,
|
|
74
|
+
line: !0,
|
|
75
|
+
linearGradient: !0,
|
|
76
|
+
marker: !0,
|
|
77
|
+
mask: !0,
|
|
78
|
+
metadata: !0,
|
|
79
|
+
mpath: !0,
|
|
80
|
+
path: !0,
|
|
81
|
+
pattern: !0,
|
|
82
|
+
polygon: !0,
|
|
83
|
+
polyline: !0,
|
|
84
|
+
radialGradient: !0,
|
|
85
|
+
rect: !0,
|
|
86
|
+
script: !0,
|
|
87
|
+
set: !0,
|
|
88
|
+
stop: !0,
|
|
89
|
+
style: !0,
|
|
90
|
+
svg: !0,
|
|
91
|
+
switch: !0,
|
|
92
|
+
symbol: !0,
|
|
93
|
+
text: !0,
|
|
94
|
+
textPath: !0,
|
|
95
|
+
title: !0,
|
|
96
|
+
tspan: !0,
|
|
97
|
+
use: !0,
|
|
98
|
+
view: !0,
|
|
99
|
+
},
|
|
100
|
+
ut = (e, t) => !!(ot[e] || (e === 'a' && t === g)),
|
|
101
|
+
at = (e, t, s) => {
|
|
102
|
+
const n = s.createElementNS(g, e)
|
|
103
|
+
for (const r in t)
|
|
104
|
+
r === '__self' ||
|
|
105
|
+
r === 'xmlns' ||
|
|
106
|
+
n.setAttributeNS(null, r, t[r].toString())
|
|
107
|
+
return n
|
|
108
|
+
},
|
|
109
|
+
ct = (e) => e.namespaceURI === g,
|
|
110
|
+
lt = (e, t) => t.createTextNode(e)
|
|
111
|
+
class ht {
|
|
112
|
+
constructor(t) {
|
|
113
|
+
this.value = t.toString()
|
|
114
|
+
}
|
|
115
|
+
render(t) {
|
|
116
|
+
const s = lt(this.value, t.document)
|
|
117
|
+
return (s.__jsx = 'TextNode'), [s]
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
const dt = (e) => typeof e == 'string' || typeof e == 'number',
|
|
121
|
+
pt = (e) => new ht(e),
|
|
122
|
+
mt = (e) => (dt(e) ? pt(e) : e),
|
|
123
|
+
ft = (e) => bt(e).map(mt).flat(),
|
|
124
|
+
bt = (e) => (Array.isArray(e) ? e.flat() : e ? [e] : []),
|
|
125
|
+
S = (e, t = {}) => e || t.children || [],
|
|
126
|
+
vt = (e, t = '') => {
|
|
127
|
+
const s = {},
|
|
128
|
+
n = {}
|
|
129
|
+
for (const r in e) {
|
|
130
|
+
const i = e[r]
|
|
131
|
+
if (r.match(/^on.+/i)) {
|
|
132
|
+
const a = r.slice(2).toLowerCase()
|
|
133
|
+
n[a] = i ? i.toString() : ''
|
|
134
|
+
} else {
|
|
135
|
+
if (i === !1) continue
|
|
136
|
+
r === '__source' ? (s.__source = e.__source) : (s[r] = gt(r, i, t))
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return { attributes: s, events: n }
|
|
140
|
+
},
|
|
141
|
+
gt = (e, t, s = '') => (t == null ? s : t.toString()),
|
|
142
|
+
yt = (e, t) => {
|
|
143
|
+
const s = e || {},
|
|
144
|
+
n = S(t, s)
|
|
145
|
+
return (s.children = s.children || n), s
|
|
146
|
+
},
|
|
147
|
+
T = (e, t, s, n = []) => e.reduce(Et(t, s), n).flat(),
|
|
148
|
+
Et = (e, t) => (s, n) =>
|
|
149
|
+
n
|
|
150
|
+
? Array.isArray(n)
|
|
151
|
+
? T(n, e, t, s)
|
|
152
|
+
: (n.render(e, t).forEach((r) => s.push(r)), s)
|
|
153
|
+
: s
|
|
154
|
+
class j {
|
|
155
|
+
constructor(t) {
|
|
156
|
+
this.collection = ft(t)
|
|
157
|
+
}
|
|
158
|
+
render(t, s) {
|
|
159
|
+
this.parentElement = s
|
|
160
|
+
const n = this.generateDom(t)
|
|
161
|
+
return this.attachToParent(n), n
|
|
162
|
+
}
|
|
163
|
+
generateDom(t) {
|
|
164
|
+
return T(this.collection, t, this.parentElement)
|
|
165
|
+
}
|
|
166
|
+
attachToParent(t) {
|
|
167
|
+
if (this.parentElement === void 0) return
|
|
168
|
+
const s = this.parentElement
|
|
169
|
+
t.forEach((n) => s.appendChild(n))
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
class At {
|
|
173
|
+
constructor(t, s) {
|
|
174
|
+
;(this.type = t), (this.attributes = s)
|
|
175
|
+
}
|
|
176
|
+
generate() {
|
|
177
|
+
return (
|
|
178
|
+
this.attributes.key ||
|
|
179
|
+
this.sourceKey() ||
|
|
180
|
+
this.createKeyFromAttributes()
|
|
181
|
+
)
|
|
182
|
+
}
|
|
183
|
+
sourceKey() {
|
|
184
|
+
if (this.attributes.__source) {
|
|
185
|
+
const {
|
|
186
|
+
fileName: t,
|
|
187
|
+
lineNumber: s,
|
|
188
|
+
columnNumber: n,
|
|
189
|
+
} = this.attributes.__source
|
|
190
|
+
return `${t}:${s}:${n}`
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
createKeyFromAttributes() {
|
|
194
|
+
const t = this.attributes.id ? `#${this.attributes.id}` : '',
|
|
195
|
+
s = this.attributes.type ? `[type=${this.attributes.type}]` : '',
|
|
196
|
+
n = this.attributes.name ? `[name=${this.attributes.name}]` : ''
|
|
197
|
+
return `${this.type}${t}${s}${n}`
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
class xt {
|
|
201
|
+
constructor(t, s, n = []) {
|
|
202
|
+
this.type = t
|
|
203
|
+
const { events: r, attributes: i } = vt(s)
|
|
204
|
+
;(this.events = r),
|
|
205
|
+
(this.attributes = i),
|
|
206
|
+
(this.isSvg = ut(this.type, this.attributes.xmlns)),
|
|
207
|
+
(this.children = new j(n))
|
|
208
|
+
}
|
|
209
|
+
render(t) {
|
|
210
|
+
const s = this.generateDom(t)
|
|
211
|
+
return s ? (this.children.render(t, s), [s]) : []
|
|
212
|
+
}
|
|
213
|
+
generateDom(t) {
|
|
214
|
+
return this.isSvg ? this.generateSvgDom(t) : this.generateHtmlDom(t)
|
|
215
|
+
}
|
|
216
|
+
generateHtmlDom(t) {
|
|
217
|
+
const s = it(this.type, this.attributes, this.events, t)
|
|
218
|
+
return (s.__jsx = this.jsxKey()), s
|
|
219
|
+
}
|
|
220
|
+
generateSvgDom(t) {
|
|
221
|
+
const s = at(this.type, this.attributes, t.document)
|
|
222
|
+
return (s.__jsx = this.jsxKey()), s
|
|
223
|
+
}
|
|
224
|
+
jsxKey() {
|
|
225
|
+
return new At(this.type, this.attributes).generate()
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
const O = (e, t, ...s) =>
|
|
229
|
+
typeof e == 'string' ? new xt(e, t, s) : e(yt(t, s))
|
|
230
|
+
O.fragment = (e, t) => {
|
|
231
|
+
const s = S(t, e)
|
|
232
|
+
return new j(s)
|
|
233
|
+
}
|
|
234
|
+
class wt {
|
|
235
|
+
constructor(t, s, n) {
|
|
236
|
+
;(this.template = t),
|
|
237
|
+
(this.selector = s),
|
|
238
|
+
(this.renderKit = n),
|
|
239
|
+
(this.dom = [])
|
|
240
|
+
}
|
|
241
|
+
renderAndAttach(t) {
|
|
242
|
+
;(this.parentElement = this.getParentElement()),
|
|
243
|
+
(this.dom = this.render({ ...t, parent: this.parentElement })),
|
|
244
|
+
this.parentElement && this.attach()
|
|
245
|
+
}
|
|
246
|
+
render(t) {
|
|
247
|
+
return this.template.render(t)
|
|
248
|
+
}
|
|
249
|
+
attach() {
|
|
250
|
+
this.parentElement && (this.parentElement.innerHTML = ''),
|
|
251
|
+
this.dom.forEach((t) => {
|
|
252
|
+
this.parentElement && this.parentElement.appendChild(t)
|
|
253
|
+
})
|
|
254
|
+
}
|
|
255
|
+
getParentElement() {
|
|
256
|
+
return this.renderKit.document.querySelector(this.selector)
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
const Nt = (e, t, s) => {
|
|
260
|
+
const n = new wt(e, t, s)
|
|
261
|
+
return n.renderAndAttach(s), n
|
|
262
|
+
},
|
|
263
|
+
M = 'go-to-href',
|
|
264
|
+
k = 'go-to',
|
|
265
|
+
b = 'navigation:location-change',
|
|
266
|
+
$ = 'navigation:route-change',
|
|
267
|
+
_t = Object.freeze(
|
|
268
|
+
Object.defineProperty(
|
|
269
|
+
{
|
|
270
|
+
__proto__: null,
|
|
271
|
+
linkNavigationEvent: M,
|
|
272
|
+
locationChangeEvent: b,
|
|
273
|
+
navigationEvent: k,
|
|
274
|
+
routeChangeEvent: $,
|
|
275
|
+
},
|
|
276
|
+
Symbol.toStringTag,
|
|
277
|
+
{ value: 'Module' },
|
|
278
|
+
),
|
|
279
|
+
),
|
|
280
|
+
D = (e) => {
|
|
281
|
+
e.create('route', { host: '', path: '', query: {} })
|
|
282
|
+
},
|
|
283
|
+
P = (e) => {
|
|
284
|
+
const t = e.closest('[href]')
|
|
285
|
+
return (t && t.getAttribute('href')) || ''
|
|
286
|
+
},
|
|
287
|
+
y = (e, { publish: t, window: s }) => {
|
|
288
|
+
s.history.pushState(null, '', e), t(b, null)
|
|
289
|
+
},
|
|
290
|
+
V = (e, t) => {
|
|
291
|
+
if (!e || !e.target) return
|
|
292
|
+
e.preventDefault()
|
|
293
|
+
const s = P(e.target)
|
|
294
|
+
y(s, t)
|
|
295
|
+
},
|
|
296
|
+
F = (e) =>
|
|
297
|
+
e
|
|
298
|
+
.replace(/^\?/, '')
|
|
299
|
+
.split('&')
|
|
300
|
+
.reduce((t, s) => {
|
|
301
|
+
if (!s) return t
|
|
302
|
+
const n = s.split('=')
|
|
303
|
+
return (t[n[0]] = n[1]), t
|
|
304
|
+
}, {}),
|
|
305
|
+
L = (e, t) => {
|
|
306
|
+
const { state: s, publish: n, window: r } = t,
|
|
307
|
+
{ host: i, pathname: a, search: l } = r.location,
|
|
308
|
+
u = a,
|
|
309
|
+
d = F(l),
|
|
310
|
+
c = { host: i, path: u, query: d }
|
|
311
|
+
s.store('route').update(c), n($, c)
|
|
312
|
+
},
|
|
313
|
+
z = (e) => {
|
|
314
|
+
const { subscribe: t } = e
|
|
315
|
+
t(M, V),
|
|
316
|
+
t(k, (s, n) => {
|
|
317
|
+
y(s, n)
|
|
318
|
+
})
|
|
319
|
+
},
|
|
320
|
+
B = (e) => {
|
|
321
|
+
const { publish: t, subscribe: s, state: n, window: r } = e
|
|
322
|
+
D(n), r.addEventListener('popstate', () => t(b, null)), s(b, L)
|
|
323
|
+
},
|
|
324
|
+
K = (e) => {
|
|
325
|
+
setTimeout(() => e.publish(b, null), 0)
|
|
326
|
+
},
|
|
327
|
+
R = (e) => {
|
|
328
|
+
B(e), z(e), K(e)
|
|
329
|
+
},
|
|
330
|
+
St = Object.freeze(
|
|
331
|
+
Object.defineProperty(
|
|
332
|
+
{
|
|
333
|
+
__proto__: null,
|
|
334
|
+
publishLocation: K,
|
|
335
|
+
startNavigation: R,
|
|
336
|
+
subscribeToHistoryChange: B,
|
|
337
|
+
subscribeToNavigation: z,
|
|
338
|
+
},
|
|
339
|
+
Symbol.toStringTag,
|
|
340
|
+
{ value: 'Module' },
|
|
341
|
+
),
|
|
342
|
+
)
|
|
343
|
+
class U {
|
|
344
|
+
constructor({
|
|
345
|
+
window: t,
|
|
346
|
+
document: s,
|
|
347
|
+
publish: n,
|
|
348
|
+
subscribe: r,
|
|
349
|
+
bus: i,
|
|
350
|
+
state: a,
|
|
351
|
+
renderKit: l,
|
|
352
|
+
}) {
|
|
353
|
+
;(this.window = t),
|
|
354
|
+
(this.document = s),
|
|
355
|
+
(this.publish = n),
|
|
356
|
+
(this.subscribe = r),
|
|
357
|
+
(this.bus = i),
|
|
358
|
+
(this.state = a),
|
|
359
|
+
(this.renderKit = l),
|
|
360
|
+
(this.roots = [])
|
|
361
|
+
}
|
|
362
|
+
render(t, s) {
|
|
363
|
+
const n = Nt(t, s, this.renderKit)
|
|
364
|
+
return this.roots.push(n), n
|
|
365
|
+
}
|
|
366
|
+
startNavigation() {
|
|
367
|
+
R(this)
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
const Tt = Object.freeze(
|
|
371
|
+
Object.defineProperty({ __proto__: null, App: U }, Symbol.toStringTag, {
|
|
372
|
+
value: 'Module',
|
|
373
|
+
}),
|
|
374
|
+
)
|
|
375
|
+
class C {
|
|
376
|
+
constructor() {
|
|
377
|
+
this.lookup = {}
|
|
378
|
+
}
|
|
379
|
+
add(t, s, n) {
|
|
380
|
+
this.ensureArrayFor(t)
|
|
381
|
+
const r = { listener: s, index: n, matcher: t }
|
|
382
|
+
return this.lookup[t].push(r), () => this.remove(r)
|
|
383
|
+
}
|
|
384
|
+
remove(t) {
|
|
385
|
+
this.lookup[t.matcher] &&
|
|
386
|
+
(this.lookup[t.matcher] = this.lookup[t.matcher].reduce(
|
|
387
|
+
(s, n) => (n !== t && s.push(n), s),
|
|
388
|
+
[],
|
|
389
|
+
))
|
|
390
|
+
}
|
|
391
|
+
matches(t) {
|
|
392
|
+
return this.lookup[t] || []
|
|
393
|
+
}
|
|
394
|
+
ensureArrayFor(t) {
|
|
395
|
+
this.lookup[t] || (this.lookup[t] = [])
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
class I {
|
|
399
|
+
constructor() {
|
|
400
|
+
this.lookup = []
|
|
401
|
+
}
|
|
402
|
+
add(t, s, n) {
|
|
403
|
+
const r = { listener: s, index: n, matcher: t }
|
|
404
|
+
return this.lookup.push(r), () => this.remove(r)
|
|
405
|
+
}
|
|
406
|
+
remove(t) {
|
|
407
|
+
this.lookup = this.lookup.reduce((s, n) => (n !== t && s.push(n), s), [])
|
|
408
|
+
}
|
|
409
|
+
matches(t) {
|
|
410
|
+
return this.lookup.filter((s) => s.matcher.test(t))
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
class jt {
|
|
414
|
+
constructor({ publish: t, event: s, payload: n, timer: r }) {
|
|
415
|
+
;(this.setNewTimeout = () => {
|
|
416
|
+
this.stopped ||
|
|
417
|
+
setTimeout(() => {
|
|
418
|
+
this.publishEvent(), this.setNewTimeout()
|
|
419
|
+
}, this.calculateNextTime())
|
|
420
|
+
}),
|
|
421
|
+
(this.calculateNextTime = () =>
|
|
422
|
+
this.timer({
|
|
423
|
+
timeDiff: this.diff(),
|
|
424
|
+
callCount: this.callCount,
|
|
425
|
+
stop: this.stop,
|
|
426
|
+
})),
|
|
427
|
+
(this.publish = t),
|
|
428
|
+
(this.event = s),
|
|
429
|
+
(this.payload = n || null),
|
|
430
|
+
(this.stop = this.stopTimeout.bind(this)),
|
|
431
|
+
(this.stopped = !1),
|
|
432
|
+
(this.timer = r),
|
|
433
|
+
(this.startedAt = new Date().getTime()),
|
|
434
|
+
(this.callCount = 0)
|
|
435
|
+
}
|
|
436
|
+
start() {
|
|
437
|
+
this.setNewTimeout()
|
|
438
|
+
}
|
|
439
|
+
diff() {
|
|
440
|
+
return new Date().getTime() - this.startedAt
|
|
441
|
+
}
|
|
442
|
+
stopTimeout() {
|
|
443
|
+
;(this.stopped = !0), this.timeoutId && clearTimeout(this.timeoutId)
|
|
444
|
+
}
|
|
445
|
+
publishEvent() {
|
|
446
|
+
this.stopped ||
|
|
447
|
+
((this.callCount += 1), this.publish(this.event, this.payload))
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
const Ot = (e) => {
|
|
451
|
+
const { offset: t, period: s } = e,
|
|
452
|
+
n = ({ callCount: r }) => (t && r == 0 ? t : s)
|
|
453
|
+
return {
|
|
454
|
+
event: e.event,
|
|
455
|
+
publish: e.publish,
|
|
456
|
+
payload: e.payload,
|
|
457
|
+
timer: n,
|
|
458
|
+
}
|
|
459
|
+
},
|
|
460
|
+
Mt = (e) => {
|
|
461
|
+
let t
|
|
462
|
+
'timer' in e ? (t = e) : (t = Ot(e))
|
|
463
|
+
const s = new jt(t)
|
|
464
|
+
return s.start(), s.stop
|
|
465
|
+
}
|
|
466
|
+
class q {
|
|
467
|
+
constructor() {
|
|
468
|
+
;(this.exactSubscriptions = new C()),
|
|
469
|
+
(this.fuzzySubscriptions = new I()),
|
|
470
|
+
(this.currentIndex = 0)
|
|
471
|
+
}
|
|
472
|
+
subscribe(t, s) {
|
|
473
|
+
let n
|
|
474
|
+
return (
|
|
475
|
+
typeof t == 'string'
|
|
476
|
+
? (n = this.exactSubscriptions.add(t, s, this.currentIndex))
|
|
477
|
+
: (n = this.fuzzySubscriptions.add(t, s, this.currentIndex)),
|
|
478
|
+
(this.currentIndex += 1),
|
|
479
|
+
n
|
|
480
|
+
)
|
|
481
|
+
}
|
|
482
|
+
publish(t, s) {
|
|
483
|
+
;[
|
|
484
|
+
...this.exactSubscriptions.matches(t),
|
|
485
|
+
...this.fuzzySubscriptions.matches(t),
|
|
486
|
+
]
|
|
487
|
+
.sort((r, i) => r.index - i.index)
|
|
488
|
+
.forEach((r) => {
|
|
489
|
+
r.listener(s, this.listenerOptions(t))
|
|
490
|
+
})
|
|
491
|
+
}
|
|
492
|
+
addListenerOptions(t) {
|
|
493
|
+
this.options = t
|
|
494
|
+
}
|
|
495
|
+
listenerOptions(t) {
|
|
496
|
+
return { eventName: t, ...this.options, publish: this.publish.bind(this) }
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
const J = () => {
|
|
500
|
+
const e = new q()
|
|
501
|
+
return {
|
|
502
|
+
bus: e,
|
|
503
|
+
publish: (n, r) => e.publish(n, r),
|
|
504
|
+
subscribe: (n, r) => e.subscribe(n, r),
|
|
505
|
+
}
|
|
506
|
+
},
|
|
507
|
+
kt = Object.freeze(
|
|
508
|
+
Object.defineProperty(
|
|
509
|
+
{
|
|
510
|
+
__proto__: null,
|
|
511
|
+
ExactSubscriptions: C,
|
|
512
|
+
FuzzySubscriptions: I,
|
|
513
|
+
JaxsBus: q,
|
|
514
|
+
createBus: J,
|
|
515
|
+
publishPeriodically: Mt,
|
|
516
|
+
},
|
|
517
|
+
Symbol.toStringTag,
|
|
518
|
+
{ value: 'Module' },
|
|
519
|
+
),
|
|
520
|
+
),
|
|
521
|
+
v = (e) => Array.isArray(e),
|
|
522
|
+
E = (e) => e !== null && !v(e) && typeof e == 'object',
|
|
523
|
+
$t = (e, t) => e === t,
|
|
524
|
+
Dt = (e, t) => Object.keys(e).length === Object.keys(t).length,
|
|
525
|
+
Pt = (e, t) =>
|
|
526
|
+
!(E(e) && E(t)) || !Dt(e, t)
|
|
527
|
+
? !1
|
|
528
|
+
: Object.keys(e).every((s) => {
|
|
529
|
+
const n = e[s],
|
|
530
|
+
r = t[s]
|
|
531
|
+
return A(n, r)
|
|
532
|
+
}),
|
|
533
|
+
Vt = (e, t) =>
|
|
534
|
+
!(v(e) && v(t)) || e.length !== t.length
|
|
535
|
+
? !1
|
|
536
|
+
: e.every((s, n) => {
|
|
537
|
+
const r = t[n]
|
|
538
|
+
return A(s, r)
|
|
539
|
+
}),
|
|
540
|
+
A = (e, t) => (E(e) ? Pt(e, t) : v(e) ? Vt(e, t) : $t(e, t))
|
|
541
|
+
class x {
|
|
542
|
+
constructor(t) {
|
|
543
|
+
;(this.name = t.name),
|
|
544
|
+
(this.parent = t.parent),
|
|
545
|
+
(this._value = structuredClone(t.value)),
|
|
546
|
+
(this.initialValue = structuredClone(t.value))
|
|
547
|
+
}
|
|
548
|
+
get value() {
|
|
549
|
+
return this._value
|
|
550
|
+
}
|
|
551
|
+
set value(t) {
|
|
552
|
+
throw new Error('Cannot set value directly. Use an updater!')
|
|
553
|
+
}
|
|
554
|
+
reset() {
|
|
555
|
+
this._value = structuredClone(this.initialValue)
|
|
556
|
+
}
|
|
557
|
+
update(t) {
|
|
558
|
+
if (typeof t == 'function') {
|
|
559
|
+
const s = this.getUpdatedValue(t)
|
|
560
|
+
this.updateValue(s)
|
|
561
|
+
} else this.updateValue(t)
|
|
562
|
+
}
|
|
563
|
+
updateValue(t) {
|
|
564
|
+
A(this._value, t) || ((this._value = t), this.parent.notify(this.name))
|
|
565
|
+
}
|
|
566
|
+
getUpdatedValue(t) {
|
|
567
|
+
return t(structuredClone(this.value))
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
class w {
|
|
571
|
+
constructor(t) {
|
|
572
|
+
this.store = t
|
|
573
|
+
}
|
|
574
|
+
update(t) {
|
|
575
|
+
this.store.update(t)
|
|
576
|
+
}
|
|
577
|
+
reset() {
|
|
578
|
+
this.store.update(this.store.initialValue)
|
|
579
|
+
}
|
|
580
|
+
get value() {
|
|
581
|
+
return this.store.value
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
class Ft extends w {
|
|
585
|
+
updateAttribute(t, s) {
|
|
586
|
+
const n = { ...this.value }
|
|
587
|
+
;(n[t] = s), this.update(n)
|
|
588
|
+
}
|
|
589
|
+
updateDynamicAttribute(t, s) {
|
|
590
|
+
this.isKey(t) && this.isValueType(t, s) && this.updateAttribute(t, s)
|
|
591
|
+
}
|
|
592
|
+
isKey(t) {
|
|
593
|
+
return t in this.store.initialValue
|
|
594
|
+
}
|
|
595
|
+
isValueType(t, s) {
|
|
596
|
+
return typeof this.store.initialValue[t] == typeof s
|
|
597
|
+
}
|
|
598
|
+
resetAttribute(t) {
|
|
599
|
+
const s = { ...this.value },
|
|
600
|
+
n = this.store.initialValue[t]
|
|
601
|
+
;(s[t] = n), this.update(s)
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
const Lt = (e) => new Ft(e)
|
|
605
|
+
class zt extends w {
|
|
606
|
+
push(t) {
|
|
607
|
+
const s = [...this.value, t]
|
|
608
|
+
this.update(s)
|
|
609
|
+
}
|
|
610
|
+
pop() {
|
|
611
|
+
const t = [...this.value],
|
|
612
|
+
s = t.pop()
|
|
613
|
+
return this.update(t), s
|
|
614
|
+
}
|
|
615
|
+
unshift(t) {
|
|
616
|
+
const s = [t, ...this.value]
|
|
617
|
+
this.update(s)
|
|
618
|
+
}
|
|
619
|
+
shift() {
|
|
620
|
+
const t = [...this.value],
|
|
621
|
+
s = t.shift()
|
|
622
|
+
return this.update(t), s
|
|
623
|
+
}
|
|
624
|
+
addSorter(t, s) {
|
|
625
|
+
this[t] = () => {
|
|
626
|
+
this.sortBy(s)
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
sortBy(t) {
|
|
630
|
+
const s = [...this.value]
|
|
631
|
+
s.sort(t), this.update(s)
|
|
632
|
+
}
|
|
633
|
+
insertAt(t, s) {
|
|
634
|
+
const n = [...this.value]
|
|
635
|
+
n.splice(t, 0, s), this.update(n)
|
|
636
|
+
}
|
|
637
|
+
remove(t) {
|
|
638
|
+
const s = this.value.reduce((n, r) => (r !== t && n.push(r), n), [])
|
|
639
|
+
this.update(s)
|
|
640
|
+
}
|
|
641
|
+
removeBy(t) {
|
|
642
|
+
const s = this.value.reduce((n, r) => (t(r) || n.push(r), n), [])
|
|
643
|
+
this.update(s)
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
const Bt = (e) => new zt(e)
|
|
647
|
+
class Kt extends w {
|
|
648
|
+
toggle() {
|
|
649
|
+
const t = !this.value
|
|
650
|
+
this.update(t)
|
|
651
|
+
}
|
|
652
|
+
setTrue() {
|
|
653
|
+
this.update(!0)
|
|
654
|
+
}
|
|
655
|
+
setFalse() {
|
|
656
|
+
this.update(!1)
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
const Rt = { object: Lt, list: Bt, boolean: (e) => new Kt(e) },
|
|
660
|
+
N = 'state'
|
|
661
|
+
class G {
|
|
662
|
+
constructor(t) {
|
|
663
|
+
;(this.publisher = t),
|
|
664
|
+
(this.stores = {}),
|
|
665
|
+
(this.eventNamePrefix = N),
|
|
666
|
+
(this.notifications = new Set()),
|
|
667
|
+
(this.inTransaction = !1)
|
|
668
|
+
}
|
|
669
|
+
create(t, s) {
|
|
670
|
+
const n = new x({ name: t, parent: this, value: s })
|
|
671
|
+
return (this.stores[t] = n), n
|
|
672
|
+
}
|
|
673
|
+
store(t) {
|
|
674
|
+
return this.stores[t] || new x({ name: t, parent: this, value: void 0 })
|
|
675
|
+
}
|
|
676
|
+
get(t) {
|
|
677
|
+
return this.store(t).value
|
|
678
|
+
}
|
|
679
|
+
getAll(t) {
|
|
680
|
+
return t.reduce((s, n) => ((s[n] = this.get(n)), s), {})
|
|
681
|
+
}
|
|
682
|
+
notify(t) {
|
|
683
|
+
this.inTransaction ? this.notifications.add(t) : this.publish(t)
|
|
684
|
+
}
|
|
685
|
+
update(t, s) {
|
|
686
|
+
this.store(t).update(s)
|
|
687
|
+
}
|
|
688
|
+
transaction(t) {
|
|
689
|
+
;(this.inTransaction = !0),
|
|
690
|
+
t(this.stores),
|
|
691
|
+
(this.inTransaction = !1),
|
|
692
|
+
this.publishAll()
|
|
693
|
+
}
|
|
694
|
+
publishAll() {
|
|
695
|
+
this.notifications.forEach((t) => {
|
|
696
|
+
this.publish(t)
|
|
697
|
+
}),
|
|
698
|
+
this.notifications.clear()
|
|
699
|
+
}
|
|
700
|
+
publish(t) {
|
|
701
|
+
this.publisher(this.event(t), { state: this, store: this.store(t) })
|
|
702
|
+
}
|
|
703
|
+
event(t) {
|
|
704
|
+
return `${this.eventNamePrefix}:${t}`
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
const H = (e) => new G(e),
|
|
708
|
+
Ut = Object.freeze(
|
|
709
|
+
Object.defineProperty(
|
|
710
|
+
{
|
|
711
|
+
__proto__: null,
|
|
712
|
+
State: G,
|
|
713
|
+
Store: x,
|
|
714
|
+
createState: H,
|
|
715
|
+
eventName: N,
|
|
716
|
+
updaters: Rt,
|
|
717
|
+
},
|
|
718
|
+
Symbol.toStringTag,
|
|
719
|
+
{ value: 'Module' },
|
|
720
|
+
),
|
|
721
|
+
)
|
|
722
|
+
class Ct {
|
|
723
|
+
constructor(t) {
|
|
724
|
+
this.setupDomEnvironment(t)
|
|
725
|
+
}
|
|
726
|
+
setup() {
|
|
727
|
+
return (
|
|
728
|
+
this.setupBus(),
|
|
729
|
+
this.setupState(),
|
|
730
|
+
this.addBusOptions(),
|
|
731
|
+
this.setRenderKit(),
|
|
732
|
+
new U({
|
|
733
|
+
window: this.window,
|
|
734
|
+
document: this.document,
|
|
735
|
+
publish: this.publish,
|
|
736
|
+
subscribe: this.subscribe,
|
|
737
|
+
bus: this.bus,
|
|
738
|
+
state: this.state,
|
|
739
|
+
renderKit: this.renderKit,
|
|
740
|
+
})
|
|
741
|
+
)
|
|
742
|
+
}
|
|
743
|
+
setupDomEnvironment(t) {
|
|
744
|
+
t.window
|
|
745
|
+
? ((this.window = t.window), (this.document = this.window.document))
|
|
746
|
+
: t.document
|
|
747
|
+
? ((this.window = t.document.defaultView),
|
|
748
|
+
(this.document = t.document))
|
|
749
|
+
: ((this.window = window), (this.document = document))
|
|
750
|
+
}
|
|
751
|
+
setupBus() {
|
|
752
|
+
const { publish: t, subscribe: s, bus: n } = J()
|
|
753
|
+
;(this.publish = t), (this.subscribe = s), (this.bus = n)
|
|
754
|
+
}
|
|
755
|
+
setupState() {
|
|
756
|
+
this.state = H(this.publish)
|
|
757
|
+
}
|
|
758
|
+
addBusOptions() {
|
|
759
|
+
this.bus.addListenerOptions({
|
|
760
|
+
state: this.state,
|
|
761
|
+
document: this.document,
|
|
762
|
+
window: this.window,
|
|
763
|
+
})
|
|
764
|
+
}
|
|
765
|
+
setRenderKit() {
|
|
766
|
+
this.renderKit = {
|
|
767
|
+
publish: this.publish,
|
|
768
|
+
subscribe: this.subscribe,
|
|
769
|
+
state: this.state,
|
|
770
|
+
document: this.document,
|
|
771
|
+
window: this.window,
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
const It = (e = {}) => {
|
|
776
|
+
const s = new Ct(e).setup()
|
|
777
|
+
return s.startNavigation(), s
|
|
778
|
+
}
|
|
779
|
+
var o = ((e) => (
|
|
780
|
+
(e[(e.removeNode = 0)] = 'removeNode'),
|
|
781
|
+
(e[(e.insertNode = 1)] = 'insertNode'),
|
|
782
|
+
(e[(e.replaceNode = 2)] = 'replaceNode'),
|
|
783
|
+
(e[(e.removeAttribute = 3)] = 'removeAttribute'),
|
|
784
|
+
(e[(e.addAttribute = 4)] = 'addAttribute'),
|
|
785
|
+
(e[(e.updateAttribute = 5)] = 'updateAttribute'),
|
|
786
|
+
(e[(e.removeEvent = 6)] = 'removeEvent'),
|
|
787
|
+
(e[(e.addEvent = 7)] = 'addEvent'),
|
|
788
|
+
(e[(e.updateEvent = 8)] = 'updateEvent'),
|
|
789
|
+
(e[(e.changeValue = 9)] = 'changeValue'),
|
|
790
|
+
(e[(e.changeText = 10)] = 'changeText'),
|
|
791
|
+
e
|
|
792
|
+
))(o || {})
|
|
793
|
+
const qt = Object.freeze(
|
|
794
|
+
Object.defineProperty(
|
|
795
|
+
{ __proto__: null, ChangeInstructionTypes: o },
|
|
796
|
+
Symbol.toStringTag,
|
|
797
|
+
{ value: 'Module' },
|
|
798
|
+
),
|
|
799
|
+
),
|
|
800
|
+
Jt = (e, t) => ({ source: e, target: t, type: o.changeText, data: {} }),
|
|
801
|
+
Gt = (e, t) => ({ source: e, target: t, type: o.replaceNode, data: {} }),
|
|
802
|
+
Ht = (e, t, s) => ({
|
|
803
|
+
source: e,
|
|
804
|
+
target: t,
|
|
805
|
+
data: s,
|
|
806
|
+
type: o.removeAttribute,
|
|
807
|
+
}),
|
|
808
|
+
Qt = (e, t, s) => ({ source: e, target: t, data: s, type: o.addAttribute }),
|
|
809
|
+
Wt = (e, t, s) => ({
|
|
810
|
+
source: e,
|
|
811
|
+
target: t,
|
|
812
|
+
data: s,
|
|
813
|
+
type: o.updateAttribute,
|
|
814
|
+
}),
|
|
815
|
+
Xt = (e, t, s) => ({ source: e, target: t, data: s, type: o.removeEvent }),
|
|
816
|
+
Yt = (e, t, s) => ({ source: e, target: t, data: s, type: o.addEvent }),
|
|
817
|
+
Zt = (e, t, s) => ({ source: e, target: t, data: s, type: o.updateEvent }),
|
|
818
|
+
Q = (e) => ({ source: e, target: e, type: o.removeNode, data: {} }),
|
|
819
|
+
_ = (e, t) => ({ target: e, source: e, type: o.insertNode, data: t }),
|
|
820
|
+
te = (e, t, s) => ({ source: e, target: t, type: o.changeValue, data: s }),
|
|
821
|
+
ee = (e, t) => (e.type > t.type ? 1 : e.type < t.type ? -1 : 0),
|
|
822
|
+
W = { index: -1 }
|
|
823
|
+
class se {
|
|
824
|
+
constructor() {
|
|
825
|
+
this.map = {}
|
|
826
|
+
}
|
|
827
|
+
populate(t) {
|
|
828
|
+
t.forEach((s, n) => {
|
|
829
|
+
const r = s.__jsx
|
|
830
|
+
r &&
|
|
831
|
+
((this.map[r] = this.map[r] || []),
|
|
832
|
+
this.map[r].push({ element: s, index: n }))
|
|
833
|
+
})
|
|
834
|
+
}
|
|
835
|
+
pullMatch(t) {
|
|
836
|
+
const s = t && t.__jsx
|
|
837
|
+
return !s || !(this.map[s] && this.map[s].length)
|
|
838
|
+
? W
|
|
839
|
+
: this.map[s].shift()
|
|
840
|
+
}
|
|
841
|
+
clear(t) {
|
|
842
|
+
const s = t && t.__jsx
|
|
843
|
+
if (!(s && this.map[s] && this.map[s].length)) return
|
|
844
|
+
const n = this.map[s]
|
|
845
|
+
this.map[s] = n.reduce((r, i) => (i.element !== t && r.push(i), r), [])
|
|
846
|
+
}
|
|
847
|
+
check(t) {
|
|
848
|
+
const s = t && t.__jsx
|
|
849
|
+
return s && this.map[s] ? this.map[s].length > 0 : !1
|
|
850
|
+
}
|
|
851
|
+
remaining() {
|
|
852
|
+
return Object.values(this.map).flat()
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
const X = (e) => {
|
|
856
|
+
const t = new se()
|
|
857
|
+
return t.populate(e), t
|
|
858
|
+
},
|
|
859
|
+
Y = (e, t, s = !1) => {
|
|
860
|
+
const n = [],
|
|
861
|
+
r = e.attributes,
|
|
862
|
+
i = r.length,
|
|
863
|
+
a = t.attributes,
|
|
864
|
+
l = a.length
|
|
865
|
+
let u, d, c
|
|
866
|
+
for (u = 0; u < i; u++) {
|
|
867
|
+
c = null
|
|
868
|
+
const h = r.item(u)
|
|
869
|
+
if (h) {
|
|
870
|
+
for (d = 0; d < l; d++) {
|
|
871
|
+
const m = a.item(d)
|
|
872
|
+
if (m && h.name == m.name) {
|
|
873
|
+
c = m
|
|
874
|
+
break
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
c
|
|
878
|
+
? h.value !== c.value &&
|
|
879
|
+
n.push(Wt(e, t, { name: h.name, value: c.value, isSvg: s }))
|
|
880
|
+
: n.push(Ht(e, t, { name: h.name, isSvg: s }))
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
for (u = 0; u < l; u++) {
|
|
884
|
+
c = null
|
|
885
|
+
const h = a.item(u)
|
|
886
|
+
if (h) {
|
|
887
|
+
for (d = 0; d < i; d++) {
|
|
888
|
+
const m = r.item(d)
|
|
889
|
+
if (m && m.name == h.name) {
|
|
890
|
+
c = m
|
|
891
|
+
break
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
c || n.push(Qt(e, t, { name: h.name, value: h.value, isSvg: s }))
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
return n
|
|
898
|
+
},
|
|
899
|
+
ne = (e, t) => {
|
|
900
|
+
const s = [],
|
|
901
|
+
n = e.eventMaps,
|
|
902
|
+
r = t.eventMaps,
|
|
903
|
+
i = Object.keys(n),
|
|
904
|
+
a = Object.keys(r)
|
|
905
|
+
return (
|
|
906
|
+
i.forEach((l) => {
|
|
907
|
+
const u = n[l],
|
|
908
|
+
d = r[l]
|
|
909
|
+
d
|
|
910
|
+
? d.busEvent !== u.busEvent &&
|
|
911
|
+
s.push(
|
|
912
|
+
Zt(e, t, {
|
|
913
|
+
name: l,
|
|
914
|
+
targetValue: d.listener,
|
|
915
|
+
sourceValue: u.listener,
|
|
916
|
+
}),
|
|
917
|
+
)
|
|
918
|
+
: s.push(Xt(e, t, { name: u.domEvent, value: u.listener }))
|
|
919
|
+
}),
|
|
920
|
+
a.forEach((l) => {
|
|
921
|
+
const u = n[l],
|
|
922
|
+
d = r[l]
|
|
923
|
+
u || s.push(Yt(e, t, { name: d.domEvent, value: d.listener }))
|
|
924
|
+
}),
|
|
925
|
+
s
|
|
926
|
+
)
|
|
927
|
+
},
|
|
928
|
+
re = (e) => e.tagName !== 'INPUT',
|
|
929
|
+
ie = (e, t) => e.value === t.value,
|
|
930
|
+
oe = (e, t) => {
|
|
931
|
+
if (re(e) || ie(e, t)) return []
|
|
932
|
+
const s = e,
|
|
933
|
+
n = t
|
|
934
|
+
return [te(s, n, { name: 'value', value: n.value })]
|
|
935
|
+
},
|
|
936
|
+
ue = (e, t) => {
|
|
937
|
+
const s = Y(e, t),
|
|
938
|
+
n = ne(e, t),
|
|
939
|
+
r = oe(e, t)
|
|
940
|
+
return s.concat(n).concat(r)
|
|
941
|
+
},
|
|
942
|
+
ae = (e, t) => Y(e, t, !0),
|
|
943
|
+
ce = (e, t) => (e.textContent !== t.textContent ? [Jt(e, t)] : []),
|
|
944
|
+
le = (e, t, s) => {
|
|
945
|
+
let n = []
|
|
946
|
+
if (e.nodeType === 1 && ct(e)) {
|
|
947
|
+
const r = e,
|
|
948
|
+
i = t,
|
|
949
|
+
a = ae(r, i),
|
|
950
|
+
l = s(r.childNodes, i.childNodes, r)
|
|
951
|
+
n = a.concat(l)
|
|
952
|
+
} else if (e.nodeType === 1) {
|
|
953
|
+
const r = e,
|
|
954
|
+
i = t,
|
|
955
|
+
a = ue(r, i),
|
|
956
|
+
l = s(r.childNodes, i.childNodes, r)
|
|
957
|
+
n = a.concat(l)
|
|
958
|
+
} else e.nodeType === 3 && (n = ce(e, t))
|
|
959
|
+
return n
|
|
960
|
+
},
|
|
961
|
+
Z = (e, t, s) => {
|
|
962
|
+
const n = [],
|
|
963
|
+
r = he(e, t),
|
|
964
|
+
i = X(e),
|
|
965
|
+
a = X(t),
|
|
966
|
+
l = []
|
|
967
|
+
let u = 0
|
|
968
|
+
for (; u < r; u++) {
|
|
969
|
+
const c = e[u],
|
|
970
|
+
h = t[u]
|
|
971
|
+
if (h && a.check(h)) {
|
|
972
|
+
const m = i.pullMatch(h)
|
|
973
|
+
a.clear(h),
|
|
974
|
+
m.element
|
|
975
|
+
? (m.index !== u && n.push(_(m.element, { parent: s, index: u })),
|
|
976
|
+
l.push({ source: m.element, target: h }))
|
|
977
|
+
: c
|
|
978
|
+
? a.check(c)
|
|
979
|
+
? n.push(_(h, { parent: s, index: u }))
|
|
980
|
+
: (i.clear(c), n.push(Gt(c, h)))
|
|
981
|
+
: n.push(_(h, { parent: s, index: u }))
|
|
982
|
+
} else c && i.pullMatch(c).element && n.push(Q(c))
|
|
983
|
+
}
|
|
984
|
+
i.remaining().forEach(({ element: c }) => {
|
|
985
|
+
n.push(Q(c))
|
|
986
|
+
})
|
|
987
|
+
const d = l.reduce(
|
|
988
|
+
(c, { source: h, target: m }) => c.concat(le(h, m, Z)),
|
|
989
|
+
[],
|
|
990
|
+
)
|
|
991
|
+
return n.concat(d).sort(ee)
|
|
992
|
+
},
|
|
993
|
+
he = (e, t) => {
|
|
994
|
+
const s = e.length,
|
|
995
|
+
n = t.length
|
|
996
|
+
return s > n ? s : n
|
|
997
|
+
},
|
|
998
|
+
de = (e, t, s) => {
|
|
999
|
+
const n = Z(e, t, s)
|
|
1000
|
+
return (
|
|
1001
|
+
n.forEach((r) => {
|
|
1002
|
+
pe(r)
|
|
1003
|
+
}),
|
|
1004
|
+
n
|
|
1005
|
+
)
|
|
1006
|
+
},
|
|
1007
|
+
pe = (e) => {
|
|
1008
|
+
;(_e[e.type] || me)(e)
|
|
1009
|
+
},
|
|
1010
|
+
me = (e) => {},
|
|
1011
|
+
fe = (e) => {
|
|
1012
|
+
const { source: t, target: s } = e
|
|
1013
|
+
t.nodeValue = s.textContent
|
|
1014
|
+
},
|
|
1015
|
+
be = (e) => {
|
|
1016
|
+
const { source: t } = e
|
|
1017
|
+
t.remove()
|
|
1018
|
+
},
|
|
1019
|
+
ve = (e) => {
|
|
1020
|
+
const { target: t, data: s } = e,
|
|
1021
|
+
{ parent: n, index: r } = s,
|
|
1022
|
+
i = n.childNodes[r]
|
|
1023
|
+
i ? i && i !== t && n.insertBefore(t, i) : n.appendChild(t)
|
|
1024
|
+
},
|
|
1025
|
+
ge = (e) => {
|
|
1026
|
+
const { source: t, target: s } = e
|
|
1027
|
+
t.replaceWith(s)
|
|
1028
|
+
},
|
|
1029
|
+
ye = (e) => {
|
|
1030
|
+
const { source: t, data: s } = e,
|
|
1031
|
+
{ name: n, isSvg: r } = s
|
|
1032
|
+
r ? t.removeAttributeNS(null, n) : t.removeAttribute(n)
|
|
1033
|
+
},
|
|
1034
|
+
tt = (e) => {
|
|
1035
|
+
const { source: t, data: s } = e,
|
|
1036
|
+
{ name: n, value: r, isSvg: i } = s
|
|
1037
|
+
i ? t.setAttributeNS(null, n, r) : t.setAttribute(n, r)
|
|
1038
|
+
},
|
|
1039
|
+
Ee = (e) => {
|
|
1040
|
+
tt(e)
|
|
1041
|
+
},
|
|
1042
|
+
Ae = (e) => {
|
|
1043
|
+
const t = e.data,
|
|
1044
|
+
s = e.source,
|
|
1045
|
+
{ name: n, value: r } = t
|
|
1046
|
+
s.removeEventListener(n, r)
|
|
1047
|
+
},
|
|
1048
|
+
xe = (e) => {
|
|
1049
|
+
const t = e.data,
|
|
1050
|
+
s = e.source,
|
|
1051
|
+
{ name: n, value: r } = t
|
|
1052
|
+
s.addEventListener(n, r)
|
|
1053
|
+
},
|
|
1054
|
+
we = (e) => {
|
|
1055
|
+
const t = e.data,
|
|
1056
|
+
s = e.source,
|
|
1057
|
+
{ name: n, sourceValue: r, targetValue: i } = t
|
|
1058
|
+
s.removeEventListener(n, r), s.addEventListener(n, i)
|
|
1059
|
+
},
|
|
1060
|
+
Ne = (e) => {
|
|
1061
|
+
const t = e.data,
|
|
1062
|
+
s = e.source,
|
|
1063
|
+
{ value: n } = t
|
|
1064
|
+
s.value = n
|
|
1065
|
+
},
|
|
1066
|
+
_e = {
|
|
1067
|
+
[o.changeText]: fe,
|
|
1068
|
+
[o.removeNode]: be,
|
|
1069
|
+
[o.insertNode]: ve,
|
|
1070
|
+
[o.replaceNode]: ge,
|
|
1071
|
+
[o.removeAttribute]: ye,
|
|
1072
|
+
[o.addAttribute]: tt,
|
|
1073
|
+
[o.updateAttribute]: Ee,
|
|
1074
|
+
[o.removeEvent]: Ae,
|
|
1075
|
+
[o.addEvent]: xe,
|
|
1076
|
+
[o.updateEvent]: we,
|
|
1077
|
+
[o.changeValue]: Ne,
|
|
1078
|
+
},
|
|
1079
|
+
Se = (e, t, s) => {
|
|
1080
|
+
const n = [...t]
|
|
1081
|
+
return (
|
|
1082
|
+
e.forEach((r) => {
|
|
1083
|
+
Te(r, n, s)
|
|
1084
|
+
}),
|
|
1085
|
+
n
|
|
1086
|
+
)
|
|
1087
|
+
},
|
|
1088
|
+
Te = (e, t, s) => {
|
|
1089
|
+
const n = ke[e.type]
|
|
1090
|
+
n && n(e, t, s)
|
|
1091
|
+
},
|
|
1092
|
+
je = (e, t) => {
|
|
1093
|
+
const { source: s } = e,
|
|
1094
|
+
n = t.indexOf(s)
|
|
1095
|
+
n >= 0 && t.splice(n, 1)
|
|
1096
|
+
},
|
|
1097
|
+
Oe = (e, t, s) => {
|
|
1098
|
+
const { target: n } = e,
|
|
1099
|
+
r = e.data,
|
|
1100
|
+
{ index: i, parent: a } = r
|
|
1101
|
+
s === a && t.splice(i, 0, n)
|
|
1102
|
+
},
|
|
1103
|
+
Me = (e, t) => {
|
|
1104
|
+
const { target: s, source: n } = e,
|
|
1105
|
+
r = t.indexOf(n)
|
|
1106
|
+
r >= 0 && (t[r] = s)
|
|
1107
|
+
},
|
|
1108
|
+
ke = { [o.removeNode]: je, [o.insertNode]: Oe, [o.replaceNode]: Me }
|
|
1109
|
+
class $e {
|
|
1110
|
+
constructor({
|
|
1111
|
+
Template: t,
|
|
1112
|
+
subscriptions: s,
|
|
1113
|
+
attributes: n,
|
|
1114
|
+
viewModel: r,
|
|
1115
|
+
}) {
|
|
1116
|
+
;(this.Template = t),
|
|
1117
|
+
(this.viewModel = r),
|
|
1118
|
+
(this.attributes = n),
|
|
1119
|
+
(this.subscriptions = s),
|
|
1120
|
+
(this.dom = []),
|
|
1121
|
+
(this.parentElement = null)
|
|
1122
|
+
}
|
|
1123
|
+
render(t) {
|
|
1124
|
+
return (
|
|
1125
|
+
(this.parentElement = t.parent),
|
|
1126
|
+
(this.renderKit = t),
|
|
1127
|
+
this.subscribeForRerender(),
|
|
1128
|
+
(this.dom = this.generateDom(t)),
|
|
1129
|
+
this.dom
|
|
1130
|
+
)
|
|
1131
|
+
}
|
|
1132
|
+
generateDom(t) {
|
|
1133
|
+
const s = {
|
|
1134
|
+
...this.attributes,
|
|
1135
|
+
...this.viewModel(t.state.getAll(this.subscriptions)),
|
|
1136
|
+
},
|
|
1137
|
+
n = this.Template(s)
|
|
1138
|
+
return n ? n.render(t) : []
|
|
1139
|
+
}
|
|
1140
|
+
rerender() {
|
|
1141
|
+
if (!this.parentElement && this.dom[0]) {
|
|
1142
|
+
const n = this.dom[0].parentElement
|
|
1143
|
+
this.parentElement = n
|
|
1144
|
+
}
|
|
1145
|
+
const t = this.generateDom(this.renderKit),
|
|
1146
|
+
s = de(this.dom, t, this.parentElement)
|
|
1147
|
+
this.dom = Se(s, this.dom, this.parentElement)
|
|
1148
|
+
}
|
|
1149
|
+
subscribeForRerender() {
|
|
1150
|
+
const { subscribe: t } = this.renderKit
|
|
1151
|
+
this.subscriptions.forEach((s) => {
|
|
1152
|
+
t(this.eventName(s), () => this.rerender())
|
|
1153
|
+
})
|
|
1154
|
+
}
|
|
1155
|
+
eventName(t) {
|
|
1156
|
+
return `${N}:${t}`
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
const De = (e) => e,
|
|
1160
|
+
et = ({ Template: e, viewModel: t, subscriptions: s }) => (
|
|
1161
|
+
(s = s || []),
|
|
1162
|
+
(t = t || De),
|
|
1163
|
+
(n) =>
|
|
1164
|
+
new $e({ Template: e, viewModel: t, subscriptions: s, attributes: n })
|
|
1165
|
+
),
|
|
1166
|
+
Pe = Object.freeze(
|
|
1167
|
+
Object.defineProperty(
|
|
1168
|
+
{
|
|
1169
|
+
__proto__: null,
|
|
1170
|
+
createRouteState: D,
|
|
1171
|
+
events: _t,
|
|
1172
|
+
extractQueryParams: F,
|
|
1173
|
+
findHref: P,
|
|
1174
|
+
navigate: y,
|
|
1175
|
+
onLinkClick: V,
|
|
1176
|
+
onLocationChange: L,
|
|
1177
|
+
start: St,
|
|
1178
|
+
},
|
|
1179
|
+
Symbol.toStringTag,
|
|
1180
|
+
{ value: 'Module' },
|
|
1181
|
+
),
|
|
1182
|
+
),
|
|
1183
|
+
Ve =
|
|
1184
|
+
(e) =>
|
|
1185
|
+
({ path: t }) =>
|
|
1186
|
+
t === e,
|
|
1187
|
+
Fe = () => !0,
|
|
1188
|
+
st =
|
|
1189
|
+
(e) =>
|
|
1190
|
+
({ route: t }) => {
|
|
1191
|
+
const s = e.find((n) => n.match(t))
|
|
1192
|
+
return s && s.Partial
|
|
1193
|
+
},
|
|
1194
|
+
Le = Object.freeze(
|
|
1195
|
+
Object.defineProperty(
|
|
1196
|
+
{ __proto__: null, buildRouter: st, catchAll: Fe, exactPathMatch: Ve },
|
|
1197
|
+
Symbol.toStringTag,
|
|
1198
|
+
{ value: 'Module' },
|
|
1199
|
+
),
|
|
1200
|
+
),
|
|
1201
|
+
ze = () => ({ render: (e, t) => [] }),
|
|
1202
|
+
Be = (e) => {
|
|
1203
|
+
const t = st(e)
|
|
1204
|
+
return et({
|
|
1205
|
+
Template: ({ route: n }) => (t({ route: n }) || ze)(),
|
|
1206
|
+
subscriptions: ['route'],
|
|
1207
|
+
})
|
|
1208
|
+
}
|
|
1209
|
+
;(p.JaxsTypes = qt),
|
|
1210
|
+
(p.appBuilding = Tt),
|
|
1211
|
+
(p.bind = et),
|
|
1212
|
+
(p.createApp = It),
|
|
1213
|
+
(p.jsx = O),
|
|
1214
|
+
(p.messageBus = kt),
|
|
1215
|
+
(p.navigation = Pe),
|
|
1216
|
+
(p.routedView = Be),
|
|
1217
|
+
(p.routing = Le),
|
|
1218
|
+
(p.state = Ut),
|
|
1219
|
+
Object.defineProperty(p, Symbol.toStringTag, { value: 'Module' })
|
|
1220
|
+
})
|