apprun 3.33.9 → 3.33.10

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.
Files changed (71) hide show
  1. package/.clinerules +1 -0
  2. package/LICENSE +1 -1
  3. package/README.md +1 -1
  4. package/WHATSNEW.md +59 -0
  5. package/apprun.d.ts +6 -0
  6. package/dist/apprun-dev-tools.js +1 -1
  7. package/dist/apprun-dev-tools.js.map +1 -1
  8. package/dist/apprun-html.esm.js +21 -4
  9. package/dist/apprun-html.esm.js.map +1 -1
  10. package/dist/apprun-html.js +1 -1
  11. package/dist/apprun-html.js.LICENSE.txt +6 -0
  12. package/dist/apprun-html.js.map +1 -1
  13. package/dist/apprun-play-html.esm.js +21 -4
  14. package/dist/apprun-play-html.esm.js.map +1 -1
  15. package/dist/apprun-play.js +1 -1
  16. package/dist/apprun-play.js.map +1 -1
  17. package/dist/apprun.esm.js +1 -1
  18. package/dist/apprun.esm.js.map +1 -1
  19. package/dist/apprun.js +1 -1
  20. package/dist/apprun.js.map +1 -1
  21. package/esm/app.js +37 -9
  22. package/esm/app.js.map +1 -1
  23. package/esm/apprun-code.js.map +1 -1
  24. package/esm/apprun-dev-tools-tests.js.map +1 -1
  25. package/esm/apprun-dev-tools.js.map +1 -1
  26. package/esm/apprun-html.js.map +1 -1
  27. package/esm/apprun-play.js.map +1 -1
  28. package/esm/apprun.js +55 -3
  29. package/esm/apprun.js.map +1 -1
  30. package/esm/component.js +59 -1
  31. package/esm/component.js.map +1 -1
  32. package/esm/decorator.js +33 -0
  33. package/esm/decorator.js.map +1 -1
  34. package/esm/directive.js +31 -0
  35. package/esm/directive.js.map +1 -1
  36. package/esm/router.js +24 -0
  37. package/esm/router.js.map +1 -1
  38. package/esm/types.js +28 -0
  39. package/esm/types.js.map +1 -1
  40. package/esm/vdom-lit-html.js +19 -17
  41. package/esm/vdom-lit-html.js.map +1 -1
  42. package/esm/vdom-my.js.map +1 -1
  43. package/esm/vdom-patch.js.map +1 -1
  44. package/esm/vdom-to-html.js.map +1 -1
  45. package/esm/vdom.js +24 -0
  46. package/esm/vdom.js.map +1 -1
  47. package/esm/web-component.js +32 -0
  48. package/esm/web-component.js.map +1 -1
  49. package/index.html +2 -2
  50. package/jest.config.js +63 -0
  51. package/jest.setup.js +47 -0
  52. package/jsx-runtime.js +1 -1
  53. package/jsx-runtime.js.map +1 -1
  54. package/package.json +16 -43
  55. package/react.js +0 -15
  56. package/rollup.config.js +27 -10
  57. package/src/app.ts +61 -28
  58. package/src/apprun.ts +82 -7
  59. package/src/component.ts +57 -1
  60. package/src/decorator.ts +34 -1
  61. package/src/directive.ts +33 -1
  62. package/src/global.d.ts +22 -0
  63. package/src/router.ts +26 -1
  64. package/src/types/apprun.d.ts +56 -0
  65. package/src/types.ts +30 -1
  66. package/src/vdom-lit-html.ts +21 -19
  67. package/src/vdom.ts +25 -2
  68. package/src/web-component.ts +33 -0
  69. package/tsconfig.jest.json +27 -3
  70. package/tsconfig.json +3 -3
  71. package/webpack.config.cjs +9 -2
@@ -1,2 +1,2 @@
1
- class t{constructor(){this._events={}}on(t,e,n={}){this._events[t]=this._events[t]||[],this._events[t].push({fn:e,options:n})}off(t,e){const n=this._events[t]||[];this._events[t]=n.filter((t=>t.fn!==e))}find(t){return this._events[t]}run(t,...e){const n=this.getSubscribers(t,this._events);return console.assert(n&&n.length>0,"No subscriber for event: "+t),n.forEach((n=>{const{fn:i,options:s}=n;return s.delay?this.delay(t,i,e,s):Object.keys(s).length>0?i.apply(this,[...e,s]):i.apply(this,e),!n.options.once})),n.length}once(t,e,n={}){this.on(t,e,Object.assign(Object.assign({},n),{once:!0}))}delay(t,e,n,i){i._t&&clearTimeout(i._t),i._t=setTimeout((()=>{clearTimeout(i._t),Object.keys(i).length>0?e.apply(this,[...n,i]):e.apply(this,n)}),i.delay)}runAsync(t,...e){const n=this.getSubscribers(t,this._events);console.assert(n&&n.length>0,"No subscriber for event: "+t);const i=n.map((t=>{const{fn:n,options:i}=t;return Object.keys(i).length>0?n.apply(this,[...e,i]):n.apply(this,e)}));return Promise.all(i)}query(t,...e){return this.runAsync(t,...e)}getSubscribers(t,e){const n=e[t]||[];return e[t]=n.filter((t=>!t.options.once)),Object.keys(e).filter((e=>e.endsWith("*")&&t.startsWith(e.replace("*","")))).sort(((t,e)=>e.length-t.length)).forEach((i=>n.push(...e[i].map((e=>Object.assign(Object.assign({},e),{options:Object.assign(Object.assign({},e.options),{event:t})})))))),n}}let e;const n="object"==typeof self&&self.self===self&&self||"object"==typeof global&&global.global===global&&global;n.app&&n._AppRunVersions?e=n.app:(e=new t,n.app=e,n._AppRunVersions="AppRun-3");var i=e;const s=(t,e)=>(e?t.state[e]:t.state)||"",o=(t,e,n)=>{if(e){const i=t.state||{};i[e]=n,t.setState(i)}else t.setState(n)},r=(t,e)=>{if(Array.isArray(t))return t.map((t=>r(t,e)));{let{type:n,tag:c,props:h,children:u}=t;return c=c||n,u=u||(null==h?void 0:h.children),h&&Object.keys(h).forEach((t=>{t.startsWith("$")&&(((t,e,n,r)=>{if(t.startsWith("$on")){const n=e[t];if(t=t.substring(1),"boolean"==typeof n)e[t]=e=>r.run?r.run(t,e):i.run(t,e);else if("string"==typeof n)e[t]=t=>r.run?r.run(n,t):i.run(n,t);else if("function"==typeof n)e[t]=t=>r.setState(n(r.state,t));else if(Array.isArray(n)){const[s,...o]=n;"string"==typeof s?e[t]=t=>r.run?r.run(s,...o,t):i.run(s,...o,t):"function"==typeof s&&(e[t]=t=>r.setState(s(r.state,...o,t)))}}else if("$bind"===t){const i=e.type||"text",c="string"==typeof e[t]?e[t]:e.name;if("input"===n)switch(i){case"checkbox":e.checked=s(r,c),e.onclick=t=>o(r,c||t.target.name,t.target.checked);break;case"radio":e.checked=s(r,c)===e.value,e.onclick=t=>o(r,c||t.target.name,t.target.value);break;case"number":case"range":e.value=s(r,c),e.oninput=t=>o(r,c||t.target.name,Number(t.target.value));break;default:e.value=s(r,c),e.oninput=t=>o(r,c||t.target.name,t.target.value)}else"select"===n?(e.value=s(r,c),e.onchange=t=>{t.target.multiple||o(r,c||t.target.name,t.target.value)}):"option"===n?(e.selected=s(r,c),e.onclick=t=>o(r,c||t.target.name,t.target.selected)):"textarea"===n&&(e.innerHTML=s(r,c),e.oninput=t=>o(r,c||t.target.name,t.target.value))}else i.run("$",{key:t,tag:n,props:e,component:r})})(t,h,c,e),delete h[t])})),u&&r(u,e),t}};function c(t,...e){return u(e)}const h="_props";function u(t){const e=[],n=t=>{null!=t&&""!==t&&!1!==t&&e.push("function"==typeof t||"object"==typeof t?t:`${t}`)};return t&&t.forEach((t=>{Array.isArray(t)?t.forEach((t=>n(t))):n(t)})),e}const l=new WeakMap,f=(t,e,n={})=>{if(null==e||!1===e)return;!function(t,e,n={}){if(null==e||!1===e)return;if(e=g(e,n),!t)return;const i="SVG"===t.nodeName;Array.isArray(e)?d(t,e,i):d(t,[e],i)}("string"==typeof t&&t?document.getElementById(t)||document.querySelector(t):t,e=r(e,n),n)};function a(t,e,n){3!==e._op&&(n=n||"svg"===e.tag,!function(t,e){const n=t.nodeName,i=`${e.tag||""}`;return n.toUpperCase()===i.toUpperCase()}(t,e)?t.parentNode.replaceChild(y(e,n),t):(!(2&e._op)&&d(t,e.children,n),!(1&e._op)&&m(t,e.props,n)))}function d(t,e,n){var i,s;const o=(null===(i=t.childNodes)||void 0===i?void 0:i.length)||0,r=(null==e?void 0:e.length)||0,c=Math.min(o,r);for(let i=0;i<c;i++){const s=e[i];if(3===s._op)continue;const o=t.childNodes[i];if("string"==typeof s)o.textContent!==s&&(3===o.nodeType?o.nodeValue=s:t.replaceChild(b(s),o));else if(s instanceof HTMLElement||s instanceof SVGElement)t.insertBefore(s,o);else{const e=s.props&&s.props.key;if(e)if(o.key===e)a(t.childNodes[i],s,n);else{const r=l[e];if(r){const e=r.nextSibling;t.insertBefore(r,o),e?t.insertBefore(o,e):t.appendChild(o),a(t.childNodes[i],s,n)}else t.replaceChild(y(s,n),o)}else a(t.childNodes[i],s,n)}}let h=(null===(s=t.childNodes)||void 0===s?void 0:s.length)||0;for(;h>c;)t.removeChild(t.lastChild),h--;if(r>c){const i=document.createDocumentFragment();for(let t=c;t<e.length;t++)i.appendChild(y(e[t],n));t.appendChild(i)}}const p=t=>{const e=document.createElement("section");return e.insertAdjacentHTML("afterbegin",t),Array.from(e.children)};function b(t){if(0===(null==t?void 0:t.indexOf("_html:"))){const e=document.createElement("div");return e.insertAdjacentHTML("afterbegin",t.substring(6)),e}return document.createTextNode(null!=t?t:"")}function y(t,e){if(t instanceof HTMLElement||t instanceof SVGElement)return t;if("string"==typeof t)return b(t);if(!t.tag||"function"==typeof t.tag)return b(JSON.stringify(t));const n=(e=e||"svg"===t.tag)?document.createElementNS("http://www.w3.org/2000/svg",t.tag):document.createElement(t.tag);return m(n,t.props,e),t.children&&t.children.forEach((t=>n.appendChild(y(t,e)))),n}function m(t,e,n){const i=t[h]||{};e=function(t,e){e.class=e.class||e.className,delete e.className;const n={};return t&&Object.keys(t).forEach((t=>n[t]=null)),e&&Object.keys(e).forEach((t=>n[t]=e[t])),n}(i,e||{}),t[h]=e;for(const i in e){const s=e[i];if(i.startsWith("data-")){const e=i.substring(5).replace(/-(\w)/g,(t=>t[1].toUpperCase()));t.dataset[e]!==s&&(s||""===s?t.dataset[e]=s:delete t.dataset[e])}else if("style"===i)if(t.style.cssText&&(t.style.cssText=""),"string"==typeof s)t.style.cssText=s;else for(const e in s)t.style[e]!==s[e]&&(t.style[e]=s[e]);else if(i.startsWith("xlink")){const e=i.replace("xlink","").toLowerCase();null==s||!1===s?t.removeAttributeNS("http://www.w3.org/1999/xlink",e):t.setAttributeNS("http://www.w3.org/1999/xlink",e,s)}else i.startsWith("on")?s&&"function"!=typeof s?"string"==typeof s&&(s?t.setAttribute(i,s):t.removeAttribute(i)):t[i]=s:/^id$|^class$|^list$|^readonly$|^contenteditable$|^role|-|^for$/g.test(i)||n?t.getAttribute(i)!==s&&(s?t.setAttribute(i,s):t.removeAttribute(i)):t[i]!==s&&(t[i]=s);"key"===i&&s&&(l[s]=t)}e&&"function"==typeof e.ref&&window.requestAnimationFrame((()=>e.ref(t)))}function g(t,e,n=0){var i;if("string"==typeof t)return t;if(Array.isArray(t))return t.map((t=>g(t,e,n++)));let s=t;if(t&&"function"==typeof t.tag&&Object.getPrototypeOf(t.tag).t&&(s=function(t,e,n){const{tag:i,props:s,children:o}=t;let r=`_${n}`,c=s&&s.id;c?r=c:c=`_${n}${Date.now()}`;let h="section";s&&s.as&&(h=s.as,delete s.as),e.i||(e.i={});let u=e.i[r];if(u&&u instanceof i&&u.element)u.renderState(u.state);else{const t=document.createElement(h);u=e.i[r]=new i(Object.assign(Object.assign({},s),{children:o})).mount(t,{render:!0})}if(u.mounted){const t=u.mounted(s,o,u.state);void 0!==t&&u.setState(t)}return m(u.element,s,!1),u.element}(t,e,n)),s&&Array.isArray(s.children)){const t=null===(i=s.props)||void 0===i?void 0:i._component;if(t){let e=0;s.children=s.children.map((n=>g(n,t,e++)))}else s.children=s.children.map((t=>g(t,e,n++)))}return s}const w=(t,e={})=>class extends HTMLElement{constructor(){super()}get component(){return this._component}get state(){return this._component.state}static get observedAttributes(){return(e.observedAttributes||[]).map((t=>t.toLowerCase()))}connectedCallback(){if(this.isConnected&&!this._component){const n=e||{};this._shadowRoot=n.shadow?this.attachShadow({mode:"open"}):this;const i=n.observedAttributes||[],s=i.reduce(((t,e)=>{const n=e.toLowerCase();return n!==e&&(t[n]=e),t}),{});this._attrMap=t=>s[t]||t;const o={};Array.from(this.attributes).forEach((t=>o[this._attrMap(t.name)]=t.value)),i.forEach((t=>{void 0!==this[t]&&(o[t]=this[t]),Object.defineProperty(this,t,{get:()=>o[t],set(e){this.attributeChangedCallback(t,o[t],e)},configurable:!0,enumerable:!0})})),requestAnimationFrame((()=>{const e=this.children?Array.from(this.children):[];if(this._component=new t(Object.assign(Object.assign({},o),{children:e})).mount(this._shadowRoot,n),this._component._props=o,this._component.dispatchEvent=this.dispatchEvent.bind(this),this._component.mounted){const t=this._component.mounted(o,e,this._component.state);void 0!==t&&(this._component.state=t)}this.on=this._component.on.bind(this._component),this.run=this._component.run.bind(this._component),!1!==n.render&&this._component.run(".")}))}}disconnectedCallback(){var t,e,n,i;null===(e=null===(t=this._component)||void 0===t?void 0:t.unload)||void 0===e||e.call(t),null===(i=null===(n=this._component)||void 0===n?void 0:n.unmount)||void 0===i||i.call(n),this._component=null}attributeChangedCallback(t,n,i){if(this._component){const s=this._attrMap(t);this._component._props[s]=i,this._component.run("attributeChanged",s,n,i),i!==n&&!1!==e.render&&window.requestAnimationFrame((()=>{this._component.run(".")}))}}};var v=(t,e,n)=>{"undefined"!=typeof customElements&&customElements.define(t,w(e,n))};const j={meta:new WeakMap,defineMetadata(t,e,n){this.meta.has(n)||this.meta.set(n,{}),this.meta.get(n)[t]=e},getMetadataKeys(t){return t=Object.getPrototypeOf(t),this.meta.get(t)?Object.keys(this.meta.get(t)):[]},getMetadata(t,e){return e=Object.getPrototypeOf(e),this.meta.get(e)?this.meta.get(e)[t]:null}};function O(t,e={}){return(n,i,s)=>{const o=t?t.toString():i;return j.defineMetadata(`apprun-update:${o}`,{name:o,key:i,options:e},n),s}}function $(t,e={}){return function(n,i){const s=t?t.toString():i;j.defineMetadata(`apprun-update:${s}`,{name:s,key:i,options:e},n)}}function k(t,e){return function(n){return v(t,n,e),n}}const A=new Map;i.find("get-components")||i.on("get-components",(t=>t.components=A));const _=t=>t;class M{renderState(t,e=null){if(!this.view)return;let n=e||this.view(t);if(i.debug&&i.run("debug",{component:this,_:n?".":"-",state:t,vdom:n,el:this.element}),"object"!=typeof document)return;const s="string"==typeof this.element&&this.element?document.getElementById(this.element)||document.querySelector(this.element):this.element;if(!s)return;const o="_c";this.unload?s._component===this&&s.getAttribute(o)===this.tracking_id||(this.tracking_id=(new Date).valueOf().toString(),s.setAttribute(o,this.tracking_id),"undefined"!=typeof MutationObserver&&(this.observer||(this.observer=new MutationObserver((t=>{t[0].oldValue!==this.tracking_id&&document.body.contains(s)||(this.unload(this.state),this.observer.disconnect(),this.observer=null)}))),this.observer.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeOldValue:!0,attributeFilter:[o]}))):s.removeAttribute&&s.removeAttribute(o),s._component=this,!e&&n&&(n=r(n,this),this.options.transition&&document&&document.startViewTransition?document.startViewTransition((()=>i.render(s,n,this))):i.render(s,n,this)),this.rendered&&this.rendered(this.state)}setState(t,e={render:!0,history:!1}){if(t instanceof Promise)Promise.resolve(t).then((n=>{this.setState(n,e),this._state=t}));else{if(this._state=t,null==t)return;this.state=t,!1!==e.render&&(e.transition&&document&&document.startViewTransition?document.startViewTransition((()=>this.renderState(t))):this.renderState(t)),!1!==e.history&&this.enable_history&&(this._history=[...this._history,t],this._history_idx=this._history.length-1),"function"==typeof e.callback&&e.callback(this.state)}}constructor(e,n,i,s){this.state=e,this.view=n,this.update=i,this.options=s,this._app=new t,this._actions=[],this._global_events=[],this._history=[],this._history_idx=-1,this._history_prev=()=>{this._history_idx--,this._history_idx>=0?this.setState(this._history[this._history_idx],{render:!0,history:!1}):this._history_idx=0},this._history_next=()=>{this._history_idx++,this._history_idx<this._history.length?this.setState(this._history[this._history_idx],{render:!0,history:!1}):this._history_idx=this._history.length-1},this.start=(t=null,e)=>{if(this.mount(t,Object.assign({render:!0},e)),this.mounted&&"function"==typeof this.mounted){const t=this.mounted({},[],this.state);void 0!==t&&this.setState(t)}return this}}mount(t=null,e){var n,s;return console.assert(!this.element,"Component already mounted."),this.options=e=Object.assign(Object.assign({},this.options),e),this.element=t,this.global_event=e.global_event,this.enable_history=!!e.history,this.enable_history&&(this.on(e.history.prev||"history-prev",this._history_prev),this.on(e.history.next||"history-next",this._history_next)),e.route&&(this.update=this.update||{},this.update[e.route]||(this.update[e.route]=_)),this.add_actions(),this.state=null!==(s=null!==(n=this.state)&&void 0!==n?n:this.model)&&void 0!==s?s:{},"function"==typeof this.state&&(this.state=this.state()),this.setState(this.state,{render:!!e.render,history:!0}),i.debug&&(A.get(t)?A.get(t).push(this):A.set(t,[this])),this}is_global_event(t){return t&&(this.global_event||this._global_events.indexOf(t)>=0||t.startsWith("#")||t.startsWith("/")||t.startsWith("@"))}add_action(t,e,n={}){e&&"function"==typeof e&&(n.global&&this._global_events.push(t),this.on(t,((...s)=>{i.debug&&i.run("debug",{component:this,_:">",event:t,p:s,current_state:this.state,options:n});const o=e(this.state,...s);i.debug&&i.run("debug",{component:this,_:"<",event:t,p:s,newState:o,state:this.state,options:n}),this.setState(o,n)}),n))}add_actions(){const t=this.update||{};j.getMetadataKeys(this).forEach((e=>{if(e.startsWith("apprun-update:")){const n=j.getMetadata(e,this);t[n.name]=[this[n.key].bind(this),n.options]}}));const e={};Array.isArray(t)?t.forEach((t=>{const[n,i,s]=t;n.toString().split(",").forEach((t=>e[t.trim()]=[i,s]))})):Object.keys(t).forEach((n=>{const i=t[n];("function"==typeof i||Array.isArray(i))&&n.split(",").forEach((t=>e[t.trim()]=i))})),e["."]||(e["."]=_),Object.keys(e).forEach((t=>{const n=e[t];"function"==typeof n?this.add_action(t,n):Array.isArray(n)&&this.add_action(t,n[0],n[1])}))}run(t,...e){if(this.state instanceof Promise)return Promise.resolve(this.state).then((n=>{this.state=n,this.run(t,...e)}));{const n=t.toString();return this.is_global_event(n)?i.run(n,...e):this._app.run(n,...e)}}on(t,e,n){const s=t.toString();return this._actions.push({name:s,fn:e}),this.is_global_event(s)?i.on(s,e,n):this._app.on(s,e,n)}runAsync(t,...e){const n=t.toString();return this.is_global_event(n)?i.runAsync(n,...e):this._app.runAsync(n,...e)}query(t,...e){return this.runAsync(t,...e)}unmount(){var t;null===(t=this.observer)||void 0===t||t.disconnect(),this._actions.forEach((t=>{const{name:e,fn:n}=t;this.is_global_event(e)?i.off(e,n):this._app.off(e,n)}))}}M.t=!0;const x="//",E="///",S=t=>{if(t||(t="#"),t.startsWith("#")){const[e,...n]=t.split("/");i.run(e,...n)||i.run(E,e,...n),i.run(x,e,...n)}else if(t.startsWith("/")){const[e,n,...s]=t.split("/");i.run("/"+n,...s)||i.run(E,"/"+n,...s),i.run(x,"/"+n,...s)}else i.run(t)||i.run(E,t),i.run(x,t)};if(!i.start){i.h=i.createElement=function(t,e,...n){const i=u(n);if("string"==typeof t)return{tag:t,props:e,children:i};if(Array.isArray(t))return t;if(void 0===t&&n)return i;if(Object.getPrototypeOf(t).t)return{tag:t,props:e,children:i};if("function"==typeof t)return t(e,i);throw new Error(`Unknown tag in vdom ${t}`)},i.render=f,i.Fragment=c,i.webComponent=v,i.safeHTML=p,i.start=(t,e,n,i,s)=>{const o=Object.assign({render:!0,global_event:!0},s),r=new M(e,n,i);return s&&s.rendered&&(r.rendered=s.rendered),s&&s.mounted&&(r.mounted=s.mounted),r.start(t,o),r};const t=t=>{};i.on("$",t),i.on("debug",(e=>t)),i.on(x,t),i.on("#",t),i.route=S,i.on("route",(t=>i.route&&i.route(t))),"object"==typeof document&&document.addEventListener("DOMContentLoaded",(()=>{i.route===S&&(window.onpopstate=()=>S(location.hash),document.body.hasAttribute("apprun-no-init")||i["no-init-route"]||S(location.hash))})),"object"==typeof window&&(window.Component=M,window._React=window.React,window.React=i,window.on=$,window.customElement=k,window.safeHTML=p),i.use_render=(t,e=0)=>i.render=0===e?(e,n)=>t(n,e):(e,n)=>t(e,n),i.use_react=(t,e)=>{i.h=i.createElement=t.createElement,i.Fragment=t.Fragment,i.render=(t,n)=>e.render(n,t),t.version&&t.version.startsWith("18")&&(i.render=(t,n)=>{t&&n&&(t._root||(t._root=e.createRoot(t)),t._root.render(n))})}}export{t as App,M as Component,c as Fragment,E as ROUTER_404_EVENT,x as ROUTER_EVENT,i as app,k as customElement,i as default,O as event,$ as on,p as safeHTML,O as update};
1
+ class t{constructor(){this._events={}}on(t,n,e={}){this._events[t]=this._events[t]||[],this._events[t].push({fn:n,options:e})}off(t,n){const e=this._events[t]||[];this._events[t]=e.filter((t=>t.fn!==n))}find(t){return this._events[t]}run(t,...n){const e=this.getSubscribers(t,this._events);return console.assert(e&&e.length>0,"No subscriber for event: "+t),e.forEach((e=>{const{fn:i,options:s}=e;return s.delay?this.delay(t,i,n,s):Object.keys(s).length>0?i.apply(this,[...n,s]):i.apply(this,n),!e.options.once})),e.length}once(t,n,e={}){this.on(t,n,Object.assign(Object.assign({},e),{once:!0}))}delay(t,n,e,i){i._t&&clearTimeout(i._t),i._t=setTimeout((()=>{clearTimeout(i._t),Object.keys(i).length>0?n.apply(this,[...e,i]):n.apply(this,e)}),i.delay)}runAsync(t,...n){const e=this.getSubscribers(t,this._events);console.assert(e&&e.length>0,"No subscriber for event: "+t);const i=e.map((t=>{const{fn:e,options:i}=t;return Object.keys(i).length>0?e.apply(this,[...n,i]):e.apply(this,n)}));return Promise.all(i)}query(t,...n){return this.runAsync(t,...n)}getSubscribers(t,n){const e=n[t]||[];return n[t]=e.filter((t=>!t.options.once)),Object.keys(n).filter((n=>n.endsWith("*")&&t.startsWith(n.replace("*","")))).sort(((t,n)=>n.length-t.length)).forEach((i=>e.push(...n[i].map((n=>Object.assign(Object.assign({},n),{options:Object.assign(Object.assign({},n.options),{event:t})})))))),e}}let n;const e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};e.app&&e._AppRunVersions?n=e.app:(n=new t,e.app=n,e._AppRunVersions="AppRun-3");var i=n;const s=(t,n)=>(n?t.state[n]:t.state)||"",o=(t,n,e)=>{if(n){const i=t.state||{};i[n]=e,t.setState(i)}else t.setState(e)},r=(t,n)=>{if(Array.isArray(t))return t.map((t=>r(t,n)));{let{type:e,tag:c,props:h,children:u}=t;return c=c||e,u=u||(null==h?void 0:h.children),h&&Object.keys(h).forEach((t=>{t.startsWith("$")&&(((t,n,e,r)=>{if(t.startsWith("$on")){const e=n[t];if(t=t.substring(1),"boolean"==typeof e)n[t]=n=>r.run?r.run(t,n):i.run(t,n);else if("string"==typeof e)n[t]=t=>r.run?r.run(e,t):i.run(e,t);else if("function"==typeof e)n[t]=t=>r.setState(e(r.state,t));else if(Array.isArray(e)){const[s,...o]=e;"string"==typeof s?n[t]=t=>r.run?r.run(s,...o,t):i.run(s,...o,t):"function"==typeof s&&(n[t]=t=>r.setState(s(r.state,...o,t)))}}else if("$bind"===t){const i=n.type||"text",c="string"==typeof n[t]?n[t]:n.name;if("input"===e)switch(i){case"checkbox":n.checked=s(r,c),n.onclick=t=>o(r,c||t.target.name,t.target.checked);break;case"radio":n.checked=s(r,c)===n.value,n.onclick=t=>o(r,c||t.target.name,t.target.value);break;case"number":case"range":n.value=s(r,c),n.oninput=t=>o(r,c||t.target.name,Number(t.target.value));break;default:n.value=s(r,c),n.oninput=t=>o(r,c||t.target.name,t.target.value)}else"select"===e?(n.value=s(r,c),n.onchange=t=>{t.target.multiple||o(r,c||t.target.name,t.target.value)}):"option"===e?(n.selected=s(r,c),n.onclick=t=>o(r,c||t.target.name,t.target.selected)):"textarea"===e&&(n.innerHTML=s(r,c),n.oninput=t=>o(r,c||t.target.name,t.target.value))}else i.run("$",{key:t,tag:e,props:n,component:r})})(t,h,c,n),delete h[t])})),u&&r(u,n),t}};function c(t,...n){return u(n)}const h="_props";function u(t){const n=[],e=t=>{null!=t&&""!==t&&!1!==t&&n.push("function"==typeof t||"object"==typeof t?t:`${t}`)};return t&&t.forEach((t=>{Array.isArray(t)?t.forEach((t=>e(t))):e(t)})),n}const l=new WeakMap,f=(t,n,e={})=>{if(null==n||!1===n)return;!function(t,n,e={}){if(null==n||!1===n)return;if(n=w(n,e),!t)return;const i="SVG"===t.nodeName;Array.isArray(n)?d(t,n,i):d(t,[n],i)}("string"==typeof t&&t?document.getElementById(t)||document.querySelector(t):t,n=r(n,e),e)};function a(t,n,e){3!==n._op&&(e=e||"svg"===n.tag,!function(t,n){const e=t.nodeName,i=`${n.tag||""}`;return e.toUpperCase()===i.toUpperCase()}(t,n)?t.parentNode.replaceChild(y(n,e),t):(!(2&n._op)&&d(t,n.children,e),!(1&n._op)&&m(t,n.props,e)))}function d(t,n,e){var i,s;const o=(null===(i=t.childNodes)||void 0===i?void 0:i.length)||0,r=(null==n?void 0:n.length)||0,c=Math.min(o,r);for(let i=0;i<c;i++){const s=n[i];if(3===s._op)continue;const o=t.childNodes[i];if("string"==typeof s)o.textContent!==s&&(3===o.nodeType?o.nodeValue=s:t.replaceChild(b(s),o));else if(s instanceof HTMLElement||s instanceof SVGElement)t.insertBefore(s,o);else{const n=s.props&&s.props.key;if(n)if(o.key===n)a(t.childNodes[i],s,e);else{const r=l[n];if(r){const n=r.nextSibling;t.insertBefore(r,o),n?t.insertBefore(o,n):t.appendChild(o),a(t.childNodes[i],s,e)}else t.replaceChild(y(s,e),o)}else a(t.childNodes[i],s,e)}}let h=(null===(s=t.childNodes)||void 0===s?void 0:s.length)||0;for(;h>c;)t.removeChild(t.lastChild),h--;if(r>c){const i=document.createDocumentFragment();for(let t=c;t<n.length;t++)i.appendChild(y(n[t],e));t.appendChild(i)}}const p=t=>{const n=document.createElement("section");return n.insertAdjacentHTML("afterbegin",t),Array.from(n.children)};function b(t){if(0===(null==t?void 0:t.indexOf("_html:"))){const n=document.createElement("div");return n.insertAdjacentHTML("afterbegin",t.substring(6)),n}return document.createTextNode(null!=t?t:"")}function y(t,n){if(t instanceof HTMLElement||t instanceof SVGElement)return t;if("string"==typeof t)return b(t);if(!t.tag||"function"==typeof t.tag)return b(JSON.stringify(t));const e=(n=n||"svg"===t.tag)?document.createElementNS("http://www.w3.org/2000/svg",t.tag):document.createElement(t.tag);return m(e,t.props,n),t.children&&t.children.forEach((t=>e.appendChild(y(t,n)))),e}function m(t,n,e){const i=t[h]||{};n=function(t,n){n.class=n.class||n.className,delete n.className;const e={};return t&&Object.keys(t).forEach((t=>e[t]=null)),Object.keys(n).forEach((t=>e[t]=n[t])),e}(i,n||{}),t[h]=n;for(const i in n){const s=n[i];if(i.startsWith("data-")){const n=i.substring(5).replace(/-(\w)/g,(t=>t[1].toUpperCase()));t.dataset[n]!==s&&(s||""===s?t.dataset[n]=s:delete t.dataset[n])}else if("style"===i)if(t.style.cssText&&(t.style.cssText=""),"string"==typeof s)t.style.cssText=s;else for(const n in s)t.style[n]!==s[n]&&(t.style[n]=s[n]);else if(i.startsWith("xlink")){const n=i.replace("xlink","").toLowerCase();null==s||!1===s?t.removeAttributeNS("http://www.w3.org/1999/xlink",n):t.setAttributeNS("http://www.w3.org/1999/xlink",n,s)}else i.startsWith("on")?s&&"function"!=typeof s?"string"==typeof s&&(s?t.setAttribute(i,s):t.removeAttribute(i)):t[i]=s:/^id$|^class$|^list$|^readonly$|^contenteditable$|^role|-|^for$/g.test(i)||e?t.getAttribute(i)!==s&&(s?t.setAttribute(i,s):t.removeAttribute(i)):t[i]!==s&&(t[i]=s);"key"===i&&s&&(l[s]=t)}n&&"function"==typeof n.ref&&window.requestAnimationFrame((()=>n.ref(t)))}function w(t,n,e=0){var i;if("string"==typeof t)return t;if(Array.isArray(t))return t.map((t=>w(t,n,e++)));let s=t;if(t&&"function"==typeof t.tag&&Object.getPrototypeOf(t.tag).t&&(s=function(t,n,e){const{tag:i,props:s,children:o}=t;let r=`_${e}`,c=s&&s.id;c?r=c:c=`_${e}${Date.now()}`;let h="section";s&&s.as&&(h=s.as,delete s.as),n.i||(n.i={});let u=n.i[r];if(u&&u instanceof i&&u.element)u.renderState(u.state);else{const t=document.createElement(h);u=n.i[r]=new i(Object.assign(Object.assign({},s),{children:o})).mount(t,{render:!0})}if(u.mounted){const t=u.mounted(s,o,u.state);void 0!==t&&u.setState(t)}return m(u.element,s,!1),u.element}(t,n,e)),s&&Array.isArray(s.children)){const t=null===(i=s.props)||void 0===i?void 0:i._component;if(t){let n=0;s.children=s.children.map((e=>w(e,t,n++)))}else s.children=s.children.map((t=>w(t,n,e++)))}return s}const v=(t,n={})=>class extends HTMLElement{constructor(){super()}get component(){return this._component}get state(){return this._component.state}static get observedAttributes(){return(n.observedAttributes||[]).map((t=>t.toLowerCase()))}connectedCallback(){if(this.isConnected&&!this._component){const e=n||{};this._shadowRoot=e.shadow?this.attachShadow({mode:"open"}):this;const i=e.observedAttributes||[],s=i.reduce(((t,n)=>{const e=n.toLowerCase();return e!==n&&(t[e]=n),t}),{});this._attrMap=t=>s[t]||t;const o={};Array.from(this.attributes).forEach((t=>o[this._attrMap(t.name)]=t.value)),i.forEach((t=>{void 0!==this[t]&&(o[t]=this[t]),Object.defineProperty(this,t,{get:()=>o[t],set(n){this.attributeChangedCallback(t,o[t],n)},configurable:!0,enumerable:!0})})),requestAnimationFrame((()=>{const n=this.children?Array.from(this.children):[];if(this._component=new t(Object.assign(Object.assign({},o),{children:n})).mount(this._shadowRoot,e),this._component._props=o,this._component.dispatchEvent=this.dispatchEvent.bind(this),this._component.mounted){const t=this._component.mounted(o,n,this._component.state);void 0!==t&&(this._component.state=t)}this.on=this._component.on.bind(this._component),this.run=this._component.run.bind(this._component),!1!==e.render&&this._component.run(".")}))}}disconnectedCallback(){var t,n,e,i;null===(n=null===(t=this._component)||void 0===t?void 0:t.unload)||void 0===n||n.call(t),null===(i=null===(e=this._component)||void 0===e?void 0:e.unmount)||void 0===i||i.call(e),this._component=null}attributeChangedCallback(t,e,i){if(this._component){const s=this._attrMap(t);this._component._props[s]=i,this._component.run("attributeChanged",s,e,i),i!==e&&!1!==n.render&&window.requestAnimationFrame((()=>{this._component.run(".")}))}}};var g=(t,n,e)=>{"undefined"!=typeof customElements&&customElements.define(t,v(n,e))};const O={meta:new WeakMap,defineMetadata(t,n,e){this.meta.has(e)||this.meta.set(e,{}),this.meta.get(e)[t]=n},getMetadataKeys(t){return t=Object.getPrototypeOf(t),this.meta.get(t)?Object.keys(this.meta.get(t)):[]},getMetadata(t,n){return n=Object.getPrototypeOf(n),this.meta.get(n)?this.meta.get(n)[t]:null}};function j(t,n={}){return(e,i,s)=>{const o=t?t.toString():i;return O.defineMetadata(`apprun-update:${o}`,{name:o,key:i,options:n},e),s}}function k(t,n={}){return function(e,i){const s=t?t.toString():i;O.defineMetadata(`apprun-update:${s}`,{name:s,key:i,options:n},e)}}function A(t,n){return function(e){return g(t,e,n),e}}const $=new Map;i.find("get-components")||i.on("get-components",(t=>t.components=$));const _=t=>t;class M{renderState(t,n=null){if(!this.view)return;let e=n||this.view(t);if(i.debug&&i.run("debug",{component:this,_:e?".":"-",state:t,vdom:e,el:this.element}),"object"!=typeof document)return;const s="string"==typeof this.element&&this.element?document.getElementById(this.element)||document.querySelector(this.element):this.element;if(!s)return;const o="_c";this.unload?s._component===this&&s.getAttribute(o)===this.tracking_id||(this.tracking_id=(new Date).valueOf().toString(),s.setAttribute(o,this.tracking_id),"undefined"!=typeof MutationObserver&&(this.observer||(this.observer=new MutationObserver((t=>{t[0].oldValue!==this.tracking_id&&document.body.contains(s)||(this.unload(this.state),this.observer.disconnect(),this.observer=null)}))),this.observer.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeOldValue:!0,attributeFilter:[o]}))):s.removeAttribute&&s.removeAttribute(o),s._component=this,!n&&e&&(e=r(e,this),this.options.transition&&document&&document.startViewTransition?document.startViewTransition((()=>i.render(s,e,this))):i.render(s,e,this)),this.rendered&&this.rendered(this.state)}setState(t,n={render:!0,history:!1}){const e=async t=>{try{for(;;){const{value:e,done:i}=await t.next();if(i)break;this.setState(e,n)}}catch(t){console.error("Error in async iterator:",t)}},i=t;if(null==i?void 0:i[Symbol.asyncIterator])this.setState(e(i[Symbol.asyncIterator]()),n);else if((null==i?void 0:i[Symbol.iterator])&&"function"==typeof i.next)for(const t of i)this.setState(t,n);else if(t&&t instanceof Promise)Promise.resolve(t).then((e=>{this.setState(e,n),this._state=t}));else{if(this._state=t,null==t)return;this.state=t,!1!==n.render&&(n.transition&&document&&document.startViewTransition?document.startViewTransition((()=>this.renderState(t))):this.renderState(t)),!1!==n.history&&this.enable_history&&(this._history=[...this._history,t],this._history_idx=this._history.length-1),"function"==typeof n.callback&&n.callback(this.state)}}constructor(n,e,i,s){this.state=n,this.view=e,this.update=i,this.options=s,this._app=new t,this._actions=[],this._global_events=[],this._history=[],this._history_idx=-1,this._history_prev=()=>{this._history_idx--,this._history_idx>=0?this.setState(this._history[this._history_idx],{render:!0,history:!1}):this._history_idx=0},this._history_next=()=>{this._history_idx++,this._history_idx<this._history.length?this.setState(this._history[this._history_idx],{render:!0,history:!1}):this._history_idx=this._history.length-1},this.start=(t=null,n)=>{if(this.mount(t,Object.assign({render:!0},n)),this.mounted&&"function"==typeof this.mounted){const t=this.mounted({},[],this.state);void 0!==t&&this.setState(t)}return this}}mount(t=null,n){var e,s;return console.assert(!this.element,"Component already mounted."),this.options=n=Object.assign(Object.assign({},this.options),n),this.element=t,this.global_event=n.global_event,this.enable_history=!!n.history,this.enable_history&&(this.on(n.history.prev||"history-prev",this._history_prev),this.on(n.history.next||"history-next",this._history_next)),n.route&&(this.update=this.update||{},this.update[n.route]||(this.update[n.route]=_)),this.add_actions(),this.state=null!==(s=null!==(e=this.state)&&void 0!==e?e:this.model)&&void 0!==s?s:{},"function"==typeof this.state&&(this.state=this.state()),this.setState(this.state,{render:!!n.render,history:!0}),i.debug&&($.get(t)?$.get(t).push(this):$.set(t,[this])),this}is_global_event(t){return t&&(this.global_event||this._global_events.indexOf(t)>=0||t.startsWith("#")||t.startsWith("/")||t.startsWith("@"))}add_action(t,n,e={}){n&&"function"==typeof n&&(e.global&&this._global_events.push(t),this.on(t,((...s)=>{i.debug&&i.run("debug",{component:this,_:">",event:t,p:s,current_state:this.state,options:e});const o=n(this.state,...s);i.debug&&i.run("debug",{component:this,_:"<",event:t,p:s,newState:o,state:this.state,options:e}),this.setState(o,e)}),e))}add_actions(){const t=this.update||{};O.getMetadataKeys(this).forEach((n=>{if(n.startsWith("apprun-update:")){const e=O.getMetadata(n,this);t[e.name]=[this[e.key].bind(this),e.options]}}));const n={};Array.isArray(t)?t.forEach((t=>{const[e,i,s]=t;e.toString().split(",").forEach((t=>n[t.trim()]=[i,s]))})):Object.keys(t).forEach((e=>{const i=t[e];("function"==typeof i||Array.isArray(i))&&e.split(",").forEach((t=>n[t.trim()]=i))})),n["."]||(n["."]=_),Object.keys(n).forEach((t=>{const e=n[t];"function"==typeof e?this.add_action(t,e):Array.isArray(e)&&this.add_action(t,e[0],e[1])}))}run(t,...n){if(this.state instanceof Promise)return Promise.resolve(this.state).then((e=>{this.state=e,this.run(t,...n)}));{const e=t.toString();return this.is_global_event(e)?i.run(e,...n):this._app.run(e,...n)}}on(t,n,e){const s=t.toString();return this._actions.push({name:s,fn:n}),this.is_global_event(s)?i.on(s,n,e):this._app.on(s,n,e)}runAsync(t,...n){const e=t.toString();return this.is_global_event(e)?i.runAsync(e,...n):this._app.runAsync(e,...n)}query(t,...n){return this.runAsync(t,...n)}unmount(){var t;null===(t=this.observer)||void 0===t||t.disconnect(),this._actions.forEach((t=>{const{name:n,fn:e}=t;this.is_global_event(n)?i.off(n,e):this._app.off(n,e)}))}}M.t=!0;const S="//",x="///",E=t=>{if(t||(t="#"),t.startsWith("#")){const[n,...e]=t.split("/");i.run(n,...e)||i.run(x,n,...e),i.run(S,n,...e)}else if(t.startsWith("/")){const[n,e,...s]=t.split("/");i.run("/"+e,...s)||i.run(x,"/"+e,...s),i.run(S,"/"+e,...s)}else i.run(t)||i.run(x,t),i.run(S,t)};if(!i.start){i.h=i.createElement=function(t,n,...e){const i=u(e);if("string"==typeof t)return{tag:t,props:n,children:i};if(Array.isArray(t))return t;if(void 0===t&&e)return i;if(Object.getPrototypeOf(t).t)return{tag:t,props:n,children:i};if("function"==typeof t)return t(n,i);throw new Error(`Unknown tag in vdom ${t}`)},i.render=f,i.Fragment=c,i.webComponent=g,i.safeHTML=p,i.start=(t,n,e,i,s)=>{const o=Object.assign({render:!0,global_event:!0},s),r=new M(n,e,i);return s&&s.rendered&&(r.rendered=s.rendered),s&&s.mounted&&(r.mounted=s.mounted),r.start(t,o),r};const t=t=>{};i.on("$",t),i.on("debug",(n=>t)),i.on(S,t),i.on("#",t),i.route=E,i.on("route",(t=>i.route&&i.route(t))),"object"==typeof document&&document.addEventListener("DOMContentLoaded",(()=>{i.route===E&&(window.onpopstate=()=>E(location.hash),document.body.hasAttribute("apprun-no-init")||i["no-init-route"]||E(location.hash))})),"object"==typeof window&&(window.Component=M,window._React=window.React,window.React=i,window.on=k,window.customElement=A,window.safeHTML=p),i.use_render=(t,n=0)=>{i.render=0===n?(n,e)=>t(e,n):(n,e)=>t(n,e)},i.use_react=(t,n)=>{i.h=i.createElement=t.createElement,i.Fragment=t.Fragment,i.render=(t,e)=>n.render(e,t),t.version&&t.version.startsWith("18")&&(i.render=(t,e)=>{t&&e&&(t._root||(t._root=n.createRoot(t)),t._root.render(e))})},i.use_prettyLink=()=>{window.onload=()=>i.route(location.pathname),window.addEventListener("popstate",(()=>i.route(location.pathname))),document.body.addEventListener("click",(t=>{const n=t.target,e="A"===n.tagName?n:n.closest("a");e&&e.origin===location.origin&&(t.preventDefault(),history.pushState(null,"",e.pathname),i.route(e.pathname))}))}}export{t as App,M as Component,c as Fragment,x as ROUTER_404_EVENT,S as ROUTER_EVENT,i as app,A as customElement,i as default,j as event,k as on,p as safeHTML,j as update};
2
2
  //# sourceMappingURL=apprun.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"apprun.esm.js","sources":["../src/app.ts","../src/directive.ts","../src/vdom-my.ts","../src/web-component.ts","../src/decorator.ts","../src/component.ts","../src/router.ts","../src/apprun.ts"],"sourcesContent":["import { EventOptions} from './types'\nexport class App {\n\n _events: Object;\n\n public start;\n public h;\n public createElement;\n public render;\n public Fragment;\n public webComponent;\n public safeHTML;\n public use_render;\n public use_react;\n\n constructor() {\n this._events = {};\n }\n\n on(name: string, fn: (...args) => void, options: EventOptions = {}): void {\n this._events[name] = this._events[name] || [];\n this._events[name].push({ fn, options });\n }\n\n off(name: string, fn: (...args) => void): void {\n const subscribers = this._events[name] || [];\n\n this._events[name] = subscribers.filter((sub) => sub.fn !== fn);\n }\n\n find(name: string): any {\n return this._events[name];\n }\n\n run(name: string, ...args): number {\n const subscribers = this.getSubscribers(name, this._events);\n console.assert(subscribers && subscribers.length > 0, 'No subscriber for event: ' + name);\n subscribers.forEach((sub) => {\n const { fn, options } = sub;\n if (options.delay) {\n this.delay(name, fn, args, options);\n } else {\n Object.keys(options).length > 0 ? fn.apply(this, [...args, options]) : fn.apply(this, args);\n }\n return !sub.options.once;\n });\n\n return subscribers.length;\n }\n\n once(name: string, fn, options: EventOptions = {}): void {\n this.on(name, fn, { ...options, once: true });\n }\n\n private delay(name, fn, args, options): void {\n if (options._t) clearTimeout(options._t);\n options._t = setTimeout(() => {\n clearTimeout(options._t);\n Object.keys(options).length > 0 ? fn.apply(this, [...args, options]) : fn.apply(this, args);\n }, options.delay);\n }\n\n runAsync(name: string, ...args): Promise<any[]> {\n const subscribers = this.getSubscribers(name, this._events);\n console.assert(subscribers && subscribers.length > 0, 'No subscriber for event: ' + name);\n const promises = subscribers.map(sub => {\n const { fn, options } = sub;\n return Object.keys(options).length > 0 ? fn.apply(this, [...args, options]) : fn.apply(this, args);\n });\n return Promise.all(promises);\n }\n\n query(name: string, ...args): Promise<any[]> {\n return this.runAsync(name, ...args);\n }\n\n private getSubscribers(name: string, events) {\n const subscribers = events[name] || [];\n\n // Update the list of subscribers by pulling out those which will run once.\n // We must do this update prior to running any of the events in case they\n // cause additional events to be turned off or on.\n events[name] = subscribers.filter((sub) => {\n return !sub.options.once;\n });\n Object.keys(events).filter(evt => evt.endsWith('*') && name.startsWith(evt.replace('*', '')))\n .sort((a, b) => b.length - a.length)\n .forEach(evt => subscribers.push(...events[evt].map(sub => ({\n ...sub,\n options: { ...sub.options, event: name }\n }))));\n return subscribers;\n }\n}\n\nconst AppRunVersions = 'AppRun-3';\nlet app: App;\nconst root = (typeof self === 'object' && self.self === self && self) ||\n (typeof global === 'object' && global.global === global && global)\nif (root['app'] && root['_AppRunVersions']) {\n app = root['app'];\n} else {\n app = new App();\n root['app'] = app;\n root['_AppRunVersions'] = AppRunVersions;\n}\nexport default app;\n","import app from './app';\n\nconst getStateValue = (component, name) => {\n return (name ? component['state'][name] : component['state']) || '';\n}\n\nconst setStateValue = (component, name, value) => {\n if (name) {\n const state = component['state'] || {};\n state[name] = value;\n component.setState(state);\n } else {\n component.setState(value);\n }\n}\n\nconst apply_directive = (key: string, props: {}, tag, component) => {\n if (key.startsWith('$on')) {\n const event = props[key];\n key = key.substring(1)\n if (typeof event === 'boolean') {\n props[key] = e => component.run ? component.run(key, e) : app.run(key, e);\n } else if (typeof event === 'string') {\n props[key] = e => component.run ? component.run(event, e) : app.run(event, e);\n } else if (typeof event === 'function') {\n props[key] = e => component.setState(event(component.state, e));\n } else if (Array.isArray(event)) {\n const [handler, ...p] = event;\n if (typeof handler === 'string') {\n props[key] = e => component.run ? component.run(handler, ...p, e) : app.run(handler, ...p, e);\n } else if (typeof handler === 'function') {\n props[key] = e => component.setState(handler(component.state, ...p, e));\n }\n }\n\n } else if (key === '$bind') {\n const type = props['type'] || 'text';\n const name = typeof props[key] === 'string' ? props[key] : props['name'];\n if (tag === 'input') {\n switch (type) {\n case 'checkbox':\n props['checked'] = getStateValue(component, name);\n props['onclick'] = e => setStateValue(component, name || e.target.name, e.target.checked);\n break;\n case 'radio':\n props['checked'] = getStateValue(component, name) === props['value'];\n props['onclick'] = e => setStateValue(component, name || e.target.name, e.target.value);\n break;\n case 'number':\n case 'range':\n props['value'] = getStateValue(component, name);\n props['oninput'] = e => setStateValue(component, name || e.target.name, Number(e.target.value));\n break;\n default:\n props['value'] = getStateValue(component, name);\n props['oninput'] = e => setStateValue(component, name || e.target.name, e.target.value);\n }\n } else if (tag === 'select') {\n props['value'] = getStateValue(component, name);\n props['onchange'] = e => {\n if (!e.target.multiple) { // multiple selection use $bind on option\n setStateValue(component, name || e.target.name, e.target.value);\n }\n }\n } else if (tag === 'option') {\n props['selected'] = getStateValue(component, name);\n props['onclick'] = e => setStateValue(component, name || e.target.name, e.target.selected);\n } else if (tag === 'textarea') {\n props['innerHTML'] = getStateValue(component, name);\n props['oninput'] = e => setStateValue(component, name || e.target.name, e.target.value);\n }\n } else {\n app.run('$', { key, tag, props, component });\n }\n}\n\nconst directive = (vdom, component) => {\n if (Array.isArray(vdom)) {\n return vdom.map(element => directive(element, component));\n } else {\n let { type, tag, props, children } = vdom;\n tag = tag || type;\n children = children || props?.children;\n if (props) Object.keys(props).forEach(key => {\n if (key.startsWith('$')) {\n apply_directive(key, props, tag, component);\n delete props[key];\n }\n });\n if (children) directive(children, component);\n return vdom;\n }\n}\n\nexport default directive;","import { VDOM, VNode } from './types';\nimport directive from './directive';\nexport type Element = any; //HTMLElement | SVGSVGElement | SVGElement;\n\nexport function Fragment(props, ...children): any[] {\n return collect(children);\n}\n\nconst ATTR_PROPS = '_props';\n\nfunction collect(children) {\n const ch = [];\n const push = (c) => {\n if (c !== null && c !== undefined && c !== '' && c !== false) {\n ch.push((typeof c === 'function' || typeof c === 'object') ? c : `${c}`);\n }\n }\n children && children.forEach(c => {\n if (Array.isArray(c)) {\n c.forEach(i => push(i));\n } else {\n push(c);\n }\n });\n return ch;\n}\n\nexport function createElement(tag: string | Function | [], props?: {}, ...children) {\n const ch = collect(children);\n if (typeof tag === 'string') return { tag, props, children: ch };\n else if (Array.isArray(tag)) return tag; // JSX fragments - babel\n else if (tag === undefined && children) return ch; // JSX fragments - typescript\n else if (Object.getPrototypeOf(tag).__isAppRunComponent) return { tag, props, children: ch } // createComponent(tag, { ...props, children });\n else if (typeof tag === 'function') return tag(props, ch);\n else throw new Error(`Unknown tag in vdom ${tag}`);\n};\n\nconst keyCache = new WeakMap();\n\nexport const updateElement = (element: Element | string, nodes: VDOM, component = {}) => {\n // tslint:disable-next-line\n if (nodes == null || nodes === false) return;\n const el = (typeof element === 'string' && element) ?\n document.getElementById(element) || document.querySelector(element) : element;\n nodes = directive(nodes, component);\n render(el, nodes, component);\n}\n\nfunction render(element: Element, nodes: VDOM, parent = {}) {\n // tslint:disable-next-line\n if (nodes == null || nodes === false) return;\n nodes = createComponent(nodes, parent);\n if (!element) return;\n const isSvg = element.nodeName === \"SVG\";\n if (Array.isArray(nodes)) {\n updateChildren(element, nodes, isSvg);\n } else {\n updateChildren(element, [nodes], isSvg);\n }\n}\n\nfunction same(el: Element, node: VNode) {\n // if (!el || !node) return false;\n const key1 = el.nodeName;\n const key2 = `${node.tag || ''}`;\n return key1.toUpperCase() === key2.toUpperCase();\n}\n\nfunction update(element: Element, node: VNode, isSvg: boolean) {\n if (node['_op'] === 3) return;\n // console.assert(!!element);\n isSvg = isSvg || node.tag === \"svg\";\n if (!same(element, node)) {\n element.parentNode.replaceChild(create(node, isSvg), element);\n return;\n }\n !(node['_op'] & 2) && updateChildren(element, node.children, isSvg);\n !(node['_op'] & 1) && updateProps(element, node.props, isSvg);\n}\n\nfunction updateChildren(element, children, isSvg: boolean) {\n const old_len = element.childNodes?.length || 0;\n const new_len = children?.length || 0;\n const len = Math.min(old_len, new_len);\n for (let i = 0; i < len; i++) {\n const child = children[i];\n if (child['_op'] === 3) continue;\n const el = element.childNodes[i];\n if (typeof child === 'string') {\n if (el.textContent !== child) {\n if (el.nodeType === 3) {\n el.nodeValue = child\n } else {\n element.replaceChild(createText(child), el);\n }\n }\n } else if (child instanceof HTMLElement || child instanceof SVGElement) {\n element.insertBefore(child, el);\n } else {\n const key = child.props && child.props['key'];\n if (key) {\n if (el.key === key) {\n update(element.childNodes[i], child, isSvg);\n } else {\n // console.log(el.key, key);\n const old = keyCache[key];\n if (old) {\n const temp = old.nextSibling;\n element.insertBefore(old, el);\n temp ? element.insertBefore(el, temp) : element.appendChild(el);\n update(element.childNodes[i], child, isSvg);\n } else {\n element.replaceChild(create(child, isSvg), el);\n }\n }\n } else {\n update(element.childNodes[i], child, isSvg);\n }\n }\n }\n\n let n = element.childNodes?.length || 0;\n while (n > len) {\n element.removeChild(element.lastChild);\n n--;\n }\n\n if (new_len > len) {\n const d = document.createDocumentFragment();\n for (let i = len; i < children.length; i++) {\n d.appendChild(create(children[i], isSvg));\n }\n element.appendChild(d);\n }\n}\n\nexport const safeHTML = (html: string) => {\n const div = document.createElement('section');\n div.insertAdjacentHTML('afterbegin', html)\n return Array.from(div.children);\n}\n\nfunction createText(node) {\n if (node?.indexOf('_html:') === 0) { // ?\n const div = document.createElement('div');\n div.insertAdjacentHTML('afterbegin', node.substring(6))\n return div;\n } else {\n return document.createTextNode(node??'');\n }\n}\n\nfunction create(node: VNode | string | HTMLElement | SVGElement, isSvg: boolean): Element {\n // console.assert(node !== null && node !== undefined);\n if ((node instanceof HTMLElement) || (node instanceof SVGElement)) return node;\n if (typeof node === \"string\") return createText(node);\n if (!node.tag || (typeof node.tag === 'function')) return createText(JSON.stringify(node));\n isSvg = isSvg || node.tag === \"svg\";\n const element = isSvg\n ? document.createElementNS(\"http://www.w3.org/2000/svg\", node.tag)\n : document.createElement(node.tag);\n\n updateProps(element, node.props, isSvg);\n if (node.children) node.children.forEach(child => element.appendChild(create(child, isSvg)));\n return element\n}\n\nfunction mergeProps(oldProps: {}, newProps: {}): {} {\n newProps['class'] = newProps['class'] || newProps['className'];\n delete newProps['className'];\n const props = {};\n if (oldProps) Object.keys(oldProps).forEach(p => props[p] = null);\n if (newProps) Object.keys(newProps).forEach(p => props[p] = newProps[p]);\n return props;\n}\n\nexport function updateProps(element: Element, props: {}, isSvg) {\n // console.assert(!!element);\n const cached = element[ATTR_PROPS] || {};\n props = mergeProps(cached, props || {});\n element[ATTR_PROPS] = props;\n\n for (const name in props) {\n const value = props[name];\n // if (cached[name] === value) continue;\n // console.log('updateProps', name, value);\n if (name.startsWith('data-')) {\n const dname = name.substring(5);\n const cname = dname.replace(/-(\\w)/g, (match) => match[1].toUpperCase());\n if (element.dataset[cname] !== value) {\n if (value || value === \"\") element.dataset[cname] = value;\n else delete element.dataset[cname];\n }\n } else if (name === 'style') {\n if (element.style.cssText) element.style.cssText = '';\n if (typeof value === 'string') element.style.cssText = value;\n else {\n for (const s in value) {\n if (element.style[s] !== value[s]) element.style[s] = value[s];\n }\n }\n } else if (name.startsWith('xlink')) {\n const xname = name.replace('xlink', '').toLowerCase();\n if (value == null || value === false) {\n element.removeAttributeNS('http://www.w3.org/1999/xlink', xname);\n } else {\n element.setAttributeNS('http://www.w3.org/1999/xlink', xname, value);\n }\n } else if (name.startsWith('on')) {\n if (!value || typeof value === 'function') {\n element[name] = value;\n } else if (typeof value === 'string') {\n if (value) element.setAttribute(name, value);\n else element.removeAttribute(name);\n }\n } else if (/^id$|^class$|^list$|^readonly$|^contenteditable$|^role|-|^for$/g.test(name) || isSvg) {\n if (element.getAttribute(name) !== value) {\n if (value) element.setAttribute(name, value);\n else element.removeAttribute(name);\n }\n } else if (element[name] !== value) {\n element[name] = value;\n }\n if (name === 'key' && value) keyCache[value] = element;\n }\n if (props && typeof props['ref'] === 'function') {\n window.requestAnimationFrame(() => props['ref'](element));\n }\n}\n\nfunction render_component(node, parent, idx) {\n const { tag, props, children } = node;\n let key = `_${idx}`;\n let id = props && props['id'];\n if (!id) id = `_${idx}${Date.now()}`;\n else key = id;\n let asTag = 'section';\n if (props && props['as']) {\n asTag = props['as'];\n delete props['as'];\n }\n if (!parent.__componentCache) parent.__componentCache = {};\n let component = parent.__componentCache[key];\n if (!component || !(component instanceof tag) || !component.element) {\n const element = document.createElement(asTag);\n component = parent.__componentCache[key] = new tag({ ...props, children }).mount(element, { render: true });\n } else {\n component.renderState(component.state);\n }\n if (component.mounted) {\n const new_state = component.mounted(props, children, component.state);\n (typeof new_state !== 'undefined') && component.setState(new_state);\n }\n updateProps(component.element, props, false);\n return component.element;\n}\n\nfunction createComponent(node, parent, idx = 0) {\n if (typeof node === 'string') return node;\n if (Array.isArray(node)) return node.map(child => createComponent(child, parent, idx++));\n let vdom = node;\n if (node && typeof node.tag === 'function' && Object.getPrototypeOf(node.tag).__isAppRunComponent) {\n vdom = render_component(node, parent, idx);\n }\n if (vdom && Array.isArray(vdom.children)) {\n const new_parent = vdom.props?._component;\n if (new_parent) {\n let i = 0;\n vdom.children = vdom.children.map(child => createComponent(child, new_parent, i++));\n } else {\n vdom.children = vdom.children.map(child => createComponent(child, parent, idx++));\n }\n }\n return vdom;\n}\n","declare var customElements;\n\nexport type CustomElementOptions = {\n render?: boolean;\n shadow?: boolean;\n history?: boolean;\n global_event?: boolean;\n observedAttributes?: string[];\n};\n\nexport const customElement = (componentClass, options: CustomElementOptions = {}) => class CustomElement extends HTMLElement {\n private _shadowRoot;\n private _component;\n private _attrMap: (arg0: string) => string;\n public on;\n public run;\n constructor() {\n super();\n }\n get component() { return this._component; }\n get state() { return this._component.state; }\n\n static get observedAttributes() {\n // attributes need to be set to lowercase in order to get observed\n return (options.observedAttributes || []).map(attr => attr.toLowerCase());\n }\n\n connectedCallback() {\n if (this.isConnected && !this._component) {\n const opts = options || {};\n this._shadowRoot = opts.shadow ? this.attachShadow({ mode: 'open' }) : this;\n const observedAttributes = (opts.observedAttributes || [])\n\n const attrMap = observedAttributes.reduce((map, name) => {\n const lc = name.toLowerCase()\n if (lc !== name) {\n map[lc] = name\n }\n return map\n }, {})\n this._attrMap = (name: string) : string => attrMap[name] || name\n\n const props = {};\n Array.from(this.attributes).forEach(item => props[this._attrMap(item.name)] = item.value);\n\n // add getters/ setters to allow observation on observedAttributes\n observedAttributes.forEach(name => {\n if (this[name] !== undefined) props[name] = this[name];\n Object.defineProperty(this, name, {\n get(): any {\n return props[name];\n },\n set(this: CustomElement, value: unknown) {\n // trigger change event\n this.attributeChangedCallback(name, props[name], value)\n },\n configurable: true,\n enumerable: true\n });\n })\n\n requestAnimationFrame(() => {\n const children = this.children ? Array.from(this.children) : [];\n // children.forEach(el => el.parentElement.removeChild(el));\n this._component = new componentClass({ ...props, children }).mount(this._shadowRoot, opts);\n // attach props to component\n this._component._props = props;\n // expose dispatchEvent\n this._component.dispatchEvent = this.dispatchEvent.bind(this)\n if (this._component.mounted) {\n const new_state = this._component.mounted(props, children, this._component.state);\n if (typeof new_state !== 'undefined') this._component.state = new_state;\n }\n this.on = this._component.on.bind(this._component);\n this.run = this._component.run.bind(this._component);\n if (!(opts.render === false)) this._component.run('.');\n });\n }\n }\n\n disconnectedCallback() {\n this._component?.unload?.();\n this._component?.unmount?.();\n this._component = null;\n }\n\n attributeChangedCallback(name: string, oldValue: unknown, value: unknown) {\n if (this._component) {\n // camelCase attributes arrive only in lowercase\n const mappedName = this._attrMap(name);\n // store the new property/ attribute\n this._component._props[mappedName] = value;\n this._component.run('attributeChanged', mappedName, oldValue, value);\n\n if (value !== oldValue && !(options.render === false)) {\n window.requestAnimationFrame(() => {\n // re-render state with new combined props on next animation frame\n this._component.run('.')\n })\n }\n }\n }\n}\n\nexport default (name: string, componentClass, options?: CustomElementOptions) => {\n (typeof customElements !== 'undefined') && customElements.define(name, customElement(componentClass, options))\n}\n","import webComponent, { CustomElementOptions } from './web-component';\n\n// tslint:disable:no-invalid-this\nexport const Reflect = {\n\n meta: new WeakMap(),\n\n defineMetadata(metadataKey, metadataValue, target) {\n if (!this.meta.has(target)) this.meta.set(target, {});\n this.meta.get(target)[metadataKey] = metadataValue;\n },\n\n getMetadataKeys(target) {\n target = Object.getPrototypeOf(target);\n return this.meta.get(target) ? Object.keys(this.meta.get(target)) : [];\n },\n\n getMetadata(metadataKey, target) {\n target = Object.getPrototypeOf(target);\n return this.meta.get(target) ? this.meta.get(target)[metadataKey] : null;\n }\n}\n\nexport function update<E=string>(events?: E, options: any = {}) {\n return (target: any, key: string, descriptor: any) => {\n const name = events ? events.toString() : key;\n Reflect.defineMetadata(`apprun-update:${name}`,\n { name, key, options }, target);\n return descriptor;\n }\n}\n\nexport function on<E = string>(events?: E, options: any = {}) {\n return function (target: any, key: string) {\n const name = events ? events.toString() : key;\n Reflect.defineMetadata(`apprun-update:${name}`,\n { name, key, options }, target)\n }\n}\n\nexport function customElement(name: string, options?: CustomElementOptions) {\n return function _customElement<T extends { new(...args: any[]): {} }>(constructor: T) {\n webComponent(name, constructor, options);\n return constructor;\n }\n}\n\n","\r\nimport app, { App } from './app';\r\nimport { Reflect } from './decorator'\r\nimport { View, Update, ActionDef, ActionOptions, MountOptions, EventOptions } from './types';\r\nimport directive from './directive';\r\n\r\nconst componentCache = new Map();\r\nif (!app.find('get-components')) app.on('get-components', o => o.components = componentCache);\r\n\r\nconst REFRESH = state => state;\r\n\r\nexport class Component<T = any, E = any> {\r\n static __isAppRunComponent = true;\r\n private _app = new App();\r\n private _actions = [];\r\n private _global_events = [];\r\n private _state;\r\n private _history = [];\r\n private _history_idx = -1;\r\n private enable_history;\r\n private global_event;\r\n public element;\r\n public rendered;\r\n public mounted;\r\n public unload;\r\n private tracking_id;\r\n private observer;\r\n\r\n\r\n private renderState(state: T, vdom = null) {\r\n if (!this.view) return;\r\n let html = vdom || this.view(state);\r\n app['debug'] && app.run('debug', {\r\n component: this,\r\n _: html ? '.' : '-',\r\n state,\r\n vdom: html,\r\n el: this.element\r\n });\r\n\r\n if (typeof document !== 'object') return;\r\n\r\n const el = (typeof this.element === 'string' && this.element) ?\r\n document.getElementById(this.element) || document.querySelector(this.element) : this.element;\r\n\r\n if (!el) return;\r\n const tracking_attr = '_c';\r\n if (!this.unload) {\r\n el.removeAttribute && el.removeAttribute(tracking_attr);\r\n } else if (el['_component'] !== this || el.getAttribute(tracking_attr) !== this.tracking_id) {\r\n this.tracking_id = new Date().valueOf().toString();\r\n el.setAttribute(tracking_attr, this.tracking_id);\r\n if (typeof MutationObserver !== 'undefined') {\r\n if (!this.observer) this.observer = new MutationObserver(changes => {\r\n if (changes[0].oldValue === this.tracking_id || !document.body.contains(el)) {\r\n this.unload(this.state);\r\n this.observer.disconnect();\r\n this.observer = null;\r\n }\r\n });\r\n this.observer.observe(document.body, {\r\n childList: true, subtree: true,\r\n attributes: true, attributeOldValue: true, attributeFilter: [tracking_attr]\r\n });\r\n }\r\n }\r\n el['_component'] = this;\r\n\r\n if (!vdom && html) {\r\n html = directive(html, this);\r\n if (this.options.transition && document && document['startViewTransition']) {\r\n document['startViewTransition'](() => app.render(el, html, this));\r\n } else {\r\n app.render(el, html, this);\r\n }\r\n }\r\n this.rendered && this.rendered(this.state);\r\n }\r\n\r\n public setState(state: T, options: ActionOptions & EventOptions\r\n = { render: true, history: false }) {\r\n if (state instanceof Promise) {\r\n // Promise will not be saved or rendered\r\n // state will be saved and rendered when promise is resolved\r\n Promise.resolve(state).then(v => {\r\n this.setState(v, options);\r\n this._state = state;\r\n });\r\n } else {\r\n this._state = state;\r\n if (state == null) return;\r\n this.state = state;\r\n if (options.render !== false) {\r\n // before render state\r\n if (options.transition && document && document['startViewTransition']) {\r\n document['startViewTransition'](() => this.renderState(state));\r\n } else {\r\n this.renderState(state);\r\n }\r\n }\r\n if (options.history !== false && this.enable_history) {\r\n this._history = [...this._history, state];\r\n this._history_idx = this._history.length - 1;\r\n }\r\n if (typeof options.callback === 'function') options.callback(this.state);\r\n }\r\n }\r\n\r\n private _history_prev = () => {\r\n this._history_idx--;\r\n if (this._history_idx >= 0) {\r\n this.setState(this._history[this._history_idx], { render: true, history: false });\r\n }\r\n else {\r\n this._history_idx = 0;\r\n }\r\n };\r\n\r\n private _history_next = () => {\r\n this._history_idx++;\r\n if (this._history_idx < this._history.length) {\r\n this.setState(this._history[this._history_idx], { render: true, history: false });\r\n }\r\n else {\r\n this._history_idx = this._history.length - 1;\r\n }\r\n };\r\n\r\n constructor(\r\n protected state?: T,\r\n protected view?: View<T>,\r\n protected update?: Update<T, E>,\r\n protected options?) {\r\n }\r\n\r\n start = (element = null, options?: MountOptions): Component<T, E> => {\r\n this.mount(element, { render: true, ...options });\r\n if (this.mounted && typeof this.mounted === 'function') {\r\n const new_state = this.mounted({}, [], this.state);\r\n (typeof new_state !== 'undefined') && this.setState(new_state);\r\n }\r\n return this;\r\n }\r\n\r\n public mount(element = null, options?: MountOptions): Component<T, E> {\r\n console.assert(!this.element, 'Component already mounted.')\r\n this.options = options = { ...this.options, ...options };\r\n this.element = element;\r\n this.global_event = options.global_event;\r\n this.enable_history = !!options.history;\r\n\r\n if (this.enable_history) {\r\n this.on(options.history.prev || 'history-prev', this._history_prev);\r\n this.on(options.history.next || 'history-next', this._history_next);\r\n }\r\n\r\n if (options.route) {\r\n this.update = this.update || {};\r\n if (!this.update[options.route]) this.update[options.route] = REFRESH;\r\n }\r\n\r\n this.add_actions();\r\n this.state = this.state ?? this['model'] ?? {};\r\n if (typeof this.state === 'function') this.state = this.state();\r\n\r\n this.setState(this.state, { render: !!options.render, history: true });\r\n\r\n if (app['debug']) {\r\n if (componentCache.get(element)) { componentCache.get(element).push(this) }\r\n else { componentCache.set(element, [this]) }\r\n }\r\n return this;\r\n }\r\n\r\n is_global_event(name: string): boolean {\r\n return name && (\r\n this.global_event ||\r\n this._global_events.indexOf(name) >= 0 ||\r\n name.startsWith('#') || name.startsWith('/') || name.startsWith('@'));\r\n }\r\n\r\n add_action(name: string, action, options: ActionOptions = {}) {\r\n if (!action || typeof action !== 'function') return;\r\n if (options.global) this._global_events.push(name);\r\n this.on(name as any, (...p) => {\r\n\r\n app['debug'] && app.run('debug', {\r\n component: this,\r\n _: '>',\r\n event: name, p,\r\n current_state: this.state,\r\n options\r\n });\r\n\r\n const newState = action(this.state, ...p);\r\n\r\n app['debug'] && app.run('debug', {\r\n component: this,\r\n _: '<',\r\n event: name, p,\r\n newState,\r\n state: this.state,\r\n options\r\n });\r\n\r\n this.setState(newState, options)\r\n }, options);\r\n }\r\n\r\n add_actions() {\r\n const actions = this.update || {};\r\n Reflect.getMetadataKeys(this).forEach(key => {\r\n if (key.startsWith('apprun-update:')) {\r\n const meta = Reflect.getMetadata(key, this)\r\n actions[meta.name] = [this[meta.key].bind(this), meta.options];\r\n }\r\n })\r\n\r\n const all = {};\r\n if (Array.isArray(actions)) {\r\n actions.forEach(act => {\r\n const [name, action, opts] = act as ActionDef<T, E>;\r\n const names = name.toString();\r\n names.split(',').forEach(n => all[n.trim()] = [action, opts])\r\n })\r\n } else {\r\n Object.keys(actions).forEach(name => {\r\n const action = actions[name];\r\n if (typeof action === 'function' || Array.isArray(action)) {\r\n name.split(',').forEach(n => all[n.trim()] = action)\r\n }\r\n })\r\n }\r\n\r\n if (!all['.']) all['.'] = REFRESH;\r\n Object.keys(all).forEach(name => {\r\n const action = all[name];\r\n if (typeof action === 'function') {\r\n this.add_action(name, action);\r\n } else if (Array.isArray(action)) {\r\n this.add_action(name, action[0], action[1]);\r\n }\r\n });\r\n }\r\n\r\n public run(event: E, ...args) {\r\n if (this.state instanceof Promise) {\r\n return Promise.resolve(this.state).then(state => {\r\n this.state = state;\r\n this.run(event, ...args)\r\n });\r\n } else {\r\n const name = event.toString();\r\n return this.is_global_event(name) ?\r\n app.run(name, ...args) :\r\n this._app.run(name, ...args);\r\n }\r\n }\r\n\r\n public on(event: E, fn: (...args) => void, options?: any) {\r\n const name = event.toString();\r\n this._actions.push({ name, fn });\r\n return this.is_global_event(name) ?\r\n app.on(name, fn, options) :\r\n this._app.on(name, fn, options);\r\n }\r\n\r\n public runAsync(event: E, ...args) {\r\n const name = event.toString();\r\n return this.is_global_event(name) ?\r\n app.runAsync(name, ...args) :\r\n this._app.runAsync(name, ...args);\r\n }\r\n\r\n // obsolete\r\n public query(event: E, ...args) {\r\n return this.runAsync(event, ...args);\r\n }\r\n\r\n public unmount() {\r\n this.observer?.disconnect();\r\n this._actions.forEach(action => {\r\n const { name, fn } = action;\r\n this.is_global_event(name) ?\r\n app.off(name, fn) :\r\n this._app.off(name, fn);\r\n });\r\n }\r\n}\r\n","import app from './app';\n\nexport type Route = (url: string, ...args: any[]) => any;\n\nexport const ROUTER_EVENT: string = '//';\nexport const ROUTER_404_EVENT: string = '///';\n\nexport const route: Route = (url: string) => {\n if (!url) url = '#';\n if (url.startsWith('#')) {\n const [name, ...rest] = url.split('/');\n app.run(name, ...rest) || app.run(ROUTER_404_EVENT, name, ...rest);\n app.run(ROUTER_EVENT, name, ...rest);\n } else if (url.startsWith('/')) {\n const [_, name, ...rest] = url.split('/');\n app.run('/' + name, ...rest) || app.run(ROUTER_404_EVENT, '/' + name, ...rest);\n app.run(ROUTER_EVENT, '/' + name, ...rest);\n } else {\n app.run(url) || app.run(ROUTER_404_EVENT, url);\n app.run(ROUTER_EVENT, url);\n }\n}\nexport default route;","import app, { App } from './app';\nimport { createElement, render, Fragment, safeHTML } from './vdom';\nimport { Component } from './component';\nimport { VNode, View, Action, Update, EventOptions, ActionOptions, MountOptions, AppStartOptions } from './types';\nimport { on, update, customElement } from './decorator';\nimport webComponent, { CustomElementOptions } from './web-component';\nimport { Route, route, ROUTER_EVENT, ROUTER_404_EVENT } from './router';\n\nexport type StatelessComponent<T = {}> = (args: T) => string | VNode | void;\nexport { App, app, Component, View, Action, Update, on, update, EventOptions, ActionOptions, MountOptions, Fragment, safeHTML }\nexport { update as event };\nexport { ROUTER_EVENT, ROUTER_404_EVENT };\nexport { customElement, CustomElementOptions, AppStartOptions };\nexport default app as IApp;\n\nexport interface IApp {\n start<T, E = any>(element?: Element | string, model?: T, view?: View<T>, update?: Update<T, E>,\n options?: AppStartOptions<T>): Component<T, E>;\n on(name: string, fn: (...args: any[]) => void, options?: any): void;\n off(name: string, fn: (...args: any[]) => void): void;\n run(name: string, ...args: any[]): number;\n find(name: string): any | any[];\n h(tag: string | Function, props, ...children): VNode | VNode[];\n createElement(tag: string | Function, props, ...children): VNode | VNode[];\n render(element: Element | string, node: VNode): void;\n Fragment(props, ...children): any[];\n route?: Route;\n webComponent(name: string, componentClass, options?: CustomElementOptions): void;\n safeHTML(html: string): any[];\n use_render(render, mode?: 0 | 1);\n use_react(createRoot);\n}\n\nif (!app.start) {\n app.h = app.createElement = createElement;\n app.render = render;\n app.Fragment = Fragment;\n app.webComponent = webComponent;\n app.safeHTML = safeHTML;\n\n app.start = <T, E = any>(element?: Element | string, model?: T, view?: View<T>, update?: Update<T, E>,\n options?: AppStartOptions<T>): Component<T, E> => {\n const opts = { render: true, global_event: true, ...options };\n const component = new Component<T, E>(model, view, update);\n if (options && options.rendered) component.rendered = options.rendered;\n if (options && options.mounted) component.mounted = options.mounted;\n component.start(element, opts);\n return component;\n };\n\n const NOOP = _ => {/* Intentionally empty */ }\n app.on('$', NOOP);\n app.on('debug', _ => NOOP);\n app.on(ROUTER_EVENT, NOOP);\n app.on('#', NOOP);\n app['route'] = route;\n app.on('route', url => app['route'] && app['route'](url));\n\n if (typeof document === 'object') {\n document.addEventListener(\"DOMContentLoaded\", () => {\n if (app['route'] === route) {\n window.onpopstate = () => route(location.hash);\n document.body.hasAttribute('apprun-no-init') || app['no-init-route'] || route(location.hash);\n }\n });\n }\n\n if (typeof window === 'object') {\n window['Component'] = Component;\n window['_React'] = window['React'];\n window['React'] = app;\n window['on'] = on;\n window['customElement'] = customElement;\n window['safeHTML'] = safeHTML;\n }\n\n app.use_render = (render, mode = 0) =>\n mode === 0 ?\n app.render = (el, vdom) => render(vdom, el) : // react style\n app.render = (el, vdom) => render(el, vdom); // apprun style\n\n app.use_react = (React, ReactDOM) => {\n app.h = app.createElement = React.createElement;\n app.Fragment = React.Fragment;\n app.render = (el, vdom) => ReactDOM.render(vdom, el);\n if (React.version && React.version.startsWith('18')) {\n app.render = (el, vdom) => {\n if (!el || !vdom) return;\n if (!el._root) el._root = ReactDOM.createRoot(el);\n el._root.render(vdom);\n }\n }\n }\n}\n"],"names":["App","constructor","this","_events","on","name","fn","options","push","off","subscribers","filter","sub","find","run","args","getSubscribers","console","assert","length","forEach","delay","Object","keys","apply","once","assign","_t","clearTimeout","setTimeout","runAsync","promises","map","Promise","all","query","events","evt","endsWith","startsWith","replace","sort","a","b","event","app","root","self","global","app$1","getStateValue","component","setStateValue","value","state","setState","directive","vdom","Array","isArray","element","type","tag","props","children","key","substring","e","handler","p","target","checked","Number","multiple","selected","apply_directive","Fragment","collect","ATTR_PROPS","ch","c","i","keyCache","WeakMap","updateElement","nodes","parent","createComponent","isSvg","nodeName","updateChildren","render","document","getElementById","querySelector","update","node","el","key1","key2","toUpperCase","same","parentNode","replaceChild","create","updateProps","old_len","_a","childNodes","new_len","len","Math","min","child","textContent","nodeType","nodeValue","createText","HTMLElement","SVGElement","insertBefore","old","temp","nextSibling","appendChild","n","_b","removeChild","lastChild","d","createDocumentFragment","safeHTML","html","div","createElement","insertAdjacentHTML","from","indexOf","createTextNode","JSON","stringify","createElementNS","cached","oldProps","newProps","mergeProps","cname","match","dataset","style","cssText","s","xname","toLowerCase","removeAttributeNS","setAttributeNS","setAttribute","removeAttribute","test","getAttribute","window","requestAnimationFrame","idx","getPrototypeOf","__isAppRunComponent","id","Date","now","asTag","__componentCache","renderState","mount","mounted","new_state","render_component","new_parent","_component","customElement","componentClass","super","observedAttributes","attr","connectedCallback","isConnected","opts","_shadowRoot","shadow","attachShadow","mode","attrMap","reduce","lc","_attrMap","attributes","item","undefined","defineProperty","get","set","attributeChangedCallback","configurable","enumerable","_props","dispatchEvent","bind","disconnectedCallback","unload","_d","_c","unmount","oldValue","mappedName","webComponent","customElements","define","Reflect","meta","defineMetadata","metadataKey","metadataValue","has","getMetadataKeys","getMetadata","descriptor","toString","componentCache","Map","o","components","REFRESH","Component","view","_","tracking_attr","tracking_id","valueOf","MutationObserver","observer","changes","body","contains","disconnect","observe","childList","subtree","attributeOldValue","attributeFilter","transition","rendered","history","resolve","then","v","_state","enable_history","_history","_history_idx","callback","_app","_actions","_global_events","_history_prev","_history_next","start","global_event","prev","next","route","add_actions","is_global_event","add_action","action","current_state","newState","actions","act","split","trim","ROUTER_EVENT","ROUTER_404_EVENT","url","rest","h","Error","model","NOOP","addEventListener","onpopstate","location","hash","hasAttribute","use_render","use_react","React","ReactDOM","version","_root","createRoot"],"mappings":"MACaA,EAcX,WAAAC,GACEC,KAAKC,QAAU,EAChB,CAED,EAAAC,CAAGC,EAAcC,EAAuBC,EAAwB,CAAA,GAC9DL,KAAKC,QAAQE,GAAQH,KAAKC,QAAQE,IAAS,GAC3CH,KAAKC,QAAQE,GAAMG,KAAK,CAAEF,KAAIC,WAC/B,CAED,GAAAE,CAAIJ,EAAcC,GAChB,MAAMI,EAAcR,KAAKC,QAAQE,IAAS,GAE1CH,KAAKC,QAAQE,GAAQK,EAAYC,QAAQC,GAAQA,EAAIN,KAAOA,GAC7D,CAED,IAAAO,CAAKR,GACH,OAAOH,KAAKC,QAAQE,EACrB,CAED,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R,EAAcO,GACrBhP,EAAIzC,GAAG,IAAKyR,GACZhP,EAAW,MAAI8N,EACf9N,EAAIzC,GAAG,SAASoR,GAAO3O,EAAW,OAAKA,EAAW,MAAE2O,KAE5B,iBAAb5L,UACTA,SAASkM,iBAAiB,oBAAoB,KACxCjP,EAAW,QAAM8N,IACnB3G,OAAO+H,WAAa,IAAMpB,EAAMqB,SAASC,MACzCrM,SAASmJ,KAAKmD,aAAa,mBAAqBrP,EAAI,kBAAoB8N,EAAMqB,SAASC,MACxF,IAIiB,iBAAXjI,SACTA,OAAkB,UAAIsE,EACtBtE,OAAe,OAAIA,OAAc,MACjCA,OAAc,MAAInH,EAClBmH,OAAW,GAAI5J,EACf4J,OAAsB,cAAIiB,EAC1BjB,OAAiB,SAAI7B,GAGvBtF,EAAIsP,WAAa,CAACxM,EAAQiG,EAAO,IAE7B/I,EAAI8C,OADG,IAATiG,EACe,CAAC3F,EAAIxC,IAASkC,EAAOlC,EAAMwC,GAC3B,CAACA,EAAIxC,IAASkC,EAAOM,EAAIxC,GAE1CZ,EAAIuP,UAAY,CAACC,EAAOC,KACtBzP,EAAI6O,EAAI7O,EAAIyF,cAAgB+J,EAAM/J,cAClCzF,EAAI+B,SAAWyN,EAAMzN,SACrB/B,EAAI8C,OAAS,CAACM,EAAIxC,IAAS6O,EAAS3M,OAAOlC,EAAMwC,GAC7CoM,EAAME,SAAWF,EAAME,QAAQhQ,WAAW,QAC5CM,EAAI8C,OAAS,CAACM,EAAIxC,KACXwC,GAAOxC,IACPwC,EAAGuM,QAAOvM,EAAGuM,MAAQF,EAASG,WAAWxM,IAC9CA,EAAGuM,MAAM7M,OAAOlC,GAAK,EAExB,CAEJ"}
1
+ {"version":3,"file":"apprun.esm.js","sources":["../esm/app.js","../esm/directive.js","../esm/vdom-my.js","../esm/web-component.js","../esm/decorator.js","../esm/component.js","../esm/router.js","../esm/apprun.js"],"sourcesContent":["/**\n * Core AppRun application class and singleton instance\n *\n * This file provides:\n * 1. App class - The core event system implementation with pub/sub capabilities\n * - on(): Subscribe to events\n * - off(): Unsubscribe from events\n * - run(): Publish events synchronously\n * - runAsync(): Publish events asynchronously\n * - query(): Alias for runAsync\n *\n * 2. Default app singleton - Global event bus instance\n * - Created once and reused across the application\n * - Stored in global scope (window/global)\n * - Version tracked to prevent duplicate instances\n *\n * Usage:\n * ```ts\n * // Subscribe to events\n * app.on('event-name', (state, ...args) => {\n * // Handle event\n * });\n *\n * // Publish events\n * app.run('event-name', ...args);\n * ```\n */\nexport class App {\n constructor() {\n this._events = {};\n }\n on(name, fn, options = {}) {\n this._events[name] = this._events[name] || [];\n this._events[name].push({ fn, options });\n }\n off(name, fn) {\n const subscribers = this._events[name] || [];\n this._events[name] = subscribers.filter((sub) => sub.fn !== fn);\n }\n find(name) {\n return this._events[name];\n }\n run(name, ...args) {\n const subscribers = this.getSubscribers(name, this._events);\n console.assert(subscribers && subscribers.length > 0, 'No subscriber for event: ' + name);\n subscribers.forEach((sub) => {\n const { fn, options } = sub;\n if (options.delay) {\n this.delay(name, fn, args, options);\n }\n else {\n Object.keys(options).length > 0 ? fn.apply(this, [...args, options]) : fn.apply(this, args);\n }\n return !sub.options.once;\n });\n return subscribers.length;\n }\n once(name, fn, options = {}) {\n this.on(name, fn, Object.assign(Object.assign({}, options), { once: true }));\n }\n delay(name, fn, args, options) {\n if (options._t)\n clearTimeout(options._t);\n options._t = setTimeout(() => {\n clearTimeout(options._t);\n Object.keys(options).length > 0 ? fn.apply(this, [...args, options]) : fn.apply(this, args);\n }, options.delay);\n }\n runAsync(name, ...args) {\n const subscribers = this.getSubscribers(name, this._events);\n console.assert(subscribers && subscribers.length > 0, 'No subscriber for event: ' + name);\n const promises = subscribers.map(sub => {\n const { fn, options } = sub;\n return Object.keys(options).length > 0 ? fn.apply(this, [...args, options]) : fn.apply(this, args);\n });\n return Promise.all(promises);\n }\n query(name, ...args) {\n return this.runAsync(name, ...args);\n }\n getSubscribers(name, events) {\n const subscribers = events[name] || [];\n // Update the list of subscribers by pulling out those which will run once.\n // We must do this update prior to running any of the events in case they\n // cause additional events to be turned off or on.\n events[name] = subscribers.filter((sub) => {\n return !sub.options.once;\n });\n Object.keys(events).filter(evt => evt.endsWith('*') && name.startsWith(evt.replace('*', '')))\n .sort((a, b) => b.length - a.length)\n .forEach(evt => subscribers.push(...events[evt].map(sub => (Object.assign(Object.assign({}, sub), { options: Object.assign(Object.assign({}, sub.options), { event: name }) })))));\n return subscribers;\n }\n}\nconst AppRunVersions = 'AppRun-3';\nlet _app;\nconst root = (typeof window !== 'undefined' ? window :\n typeof global !== 'undefined' ? global :\n typeof self !== 'undefined' ? self : {});\nif (root.app && root._AppRunVersions) {\n _app = root.app;\n}\nelse {\n _app = new App();\n root.app = _app;\n root._AppRunVersions = AppRunVersions;\n}\nexport default _app;\n//# sourceMappingURL=app.js.map","/**\n * Component Directives Implementation\n *\n * This file provides built-in directives for components:\n * 1. Event Binding\n * - $on: Bind DOM events to component events\n * - Supports event delegation and parameters\n * - Handles function, string, and array event handlers\n *\n * 2. Two-way Data Binding\n * - $bind: Sync form elements with component state\n * - Handles input types: text, checkbox, radio, select\n * - Automatic value type conversion\n * - Support for complex property paths\n *\n * 3. Custom Directives\n * - Extensible directive system\n * - Processes virtual DOM during rendering\n * - Supports custom attribute directives\n *\n * Usage:\n * ```tsx\n * // Event binding\n * <button $onclick=\"event-name\">Click</button>\n * <input $oninput={e => setState(e.target.value)} />\n *\n * // Two-way binding\n * <input $bind=\"state.property\" />\n * <select $bind=\"selected\">...</select>\n * ```\n */\nimport app from './app';\nconst getStateValue = (component, name) => {\n return (name ? component['state'][name] : component['state']) || '';\n};\nconst setStateValue = (component, name, value) => {\n if (name) {\n const state = component['state'] || {};\n state[name] = value;\n component.setState(state);\n }\n else {\n component.setState(value);\n }\n};\nconst apply_directive = (key, props, tag, component) => {\n if (key.startsWith('$on')) {\n const event = props[key];\n key = key.substring(1);\n if (typeof event === 'boolean') {\n props[key] = e => component.run ? component.run(key, e) : app.run(key, e);\n }\n else if (typeof event === 'string') {\n props[key] = e => component.run ? component.run(event, e) : app.run(event, e);\n }\n else if (typeof event === 'function') {\n props[key] = e => component.setState(event(component.state, e));\n }\n else if (Array.isArray(event)) {\n const [handler, ...p] = event;\n if (typeof handler === 'string') {\n props[key] = e => component.run ? component.run(handler, ...p, e) : app.run(handler, ...p, e);\n }\n else if (typeof handler === 'function') {\n props[key] = e => component.setState(handler(component.state, ...p, e));\n }\n }\n }\n else if (key === '$bind') {\n const type = props['type'] || 'text';\n const name = typeof props[key] === 'string' ? props[key] : props['name'];\n if (tag === 'input') {\n switch (type) {\n case 'checkbox':\n props['checked'] = getStateValue(component, name);\n props['onclick'] = e => setStateValue(component, name || e.target.name, e.target.checked);\n break;\n case 'radio':\n props['checked'] = getStateValue(component, name) === props['value'];\n props['onclick'] = e => setStateValue(component, name || e.target.name, e.target.value);\n break;\n case 'number':\n case 'range':\n props['value'] = getStateValue(component, name);\n props['oninput'] = e => setStateValue(component, name || e.target.name, Number(e.target.value));\n break;\n default:\n props['value'] = getStateValue(component, name);\n props['oninput'] = e => setStateValue(component, name || e.target.name, e.target.value);\n }\n }\n else if (tag === 'select') {\n props['value'] = getStateValue(component, name);\n props['onchange'] = e => {\n if (!e.target.multiple) { // multiple selection use $bind on option\n setStateValue(component, name || e.target.name, e.target.value);\n }\n };\n }\n else if (tag === 'option') {\n props['selected'] = getStateValue(component, name);\n props['onclick'] = e => setStateValue(component, name || e.target.name, e.target.selected);\n }\n else if (tag === 'textarea') {\n props['innerHTML'] = getStateValue(component, name);\n props['oninput'] = e => setStateValue(component, name || e.target.name, e.target.value);\n }\n }\n else {\n app.run('$', { key, tag, props, component });\n }\n};\nconst directive = (vdom, component) => {\n if (Array.isArray(vdom)) {\n return vdom.map(element => directive(element, component));\n }\n else {\n let { type, tag, props, children } = vdom;\n tag = tag || type;\n children = children || (props === null || props === void 0 ? void 0 : props.children);\n if (props)\n Object.keys(props).forEach(key => {\n if (key.startsWith('$')) {\n apply_directive(key, props, tag, component);\n delete props[key];\n }\n });\n if (children)\n directive(children, component);\n return vdom;\n }\n};\nexport default directive;\n//# sourceMappingURL=directive.js.map","import directive from './directive';\nexport function Fragment(props, ...children) {\n return collect(children);\n}\nconst ATTR_PROPS = '_props';\nfunction collect(children) {\n const ch = [];\n const push = (c) => {\n if (c !== null && c !== undefined && c !== '' && c !== false) {\n ch.push((typeof c === 'function' || typeof c === 'object') ? c : `${c}`);\n }\n };\n children && children.forEach(c => {\n if (Array.isArray(c)) {\n c.forEach(i => push(i));\n }\n else {\n push(c);\n }\n });\n return ch;\n}\nexport function createElement(tag, props, ...children) {\n const ch = collect(children);\n if (typeof tag === 'string')\n return { tag, props, children: ch };\n else if (Array.isArray(tag))\n return tag; // JSX fragments - babel\n else if (tag === undefined && children)\n return ch; // JSX fragments - typescript\n else if (Object.getPrototypeOf(tag).__isAppRunComponent)\n return { tag, props, children: ch }; // createComponent(tag, { ...props, children });\n else if (typeof tag === 'function')\n return tag(props, ch);\n else\n throw new Error(`Unknown tag in vdom ${tag}`);\n}\n;\nconst keyCache = new WeakMap();\nexport const updateElement = (element, nodes, component = {}) => {\n // tslint:disable-next-line\n if (nodes == null || nodes === false)\n return;\n const el = (typeof element === 'string' && element) ?\n document.getElementById(element) || document.querySelector(element) : element;\n nodes = directive(nodes, component);\n render(el, nodes, component);\n};\nfunction render(element, nodes, parent = {}) {\n // tslint:disable-next-line\n if (nodes == null || nodes === false)\n return;\n nodes = createComponent(nodes, parent);\n if (!element)\n return;\n const isSvg = element.nodeName === \"SVG\";\n if (Array.isArray(nodes)) {\n updateChildren(element, nodes, isSvg);\n }\n else {\n updateChildren(element, [nodes], isSvg);\n }\n}\nfunction same(el, node) {\n // if (!el || !node) return false;\n const key1 = el.nodeName;\n const key2 = `${node.tag || ''}`;\n return key1.toUpperCase() === key2.toUpperCase();\n}\nfunction update(element, node, isSvg) {\n if (node['_op'] === 3)\n return;\n // console.assert(!!element);\n isSvg = isSvg || node.tag === \"svg\";\n if (!same(element, node)) {\n element.parentNode.replaceChild(create(node, isSvg), element);\n return;\n }\n !(node['_op'] & 2) && updateChildren(element, node.children, isSvg);\n !(node['_op'] & 1) && updateProps(element, node.props, isSvg);\n}\nfunction updateChildren(element, children, isSvg) {\n var _a, _b;\n const old_len = ((_a = element.childNodes) === null || _a === void 0 ? void 0 : _a.length) || 0;\n const new_len = (children === null || children === void 0 ? void 0 : children.length) || 0;\n const len = Math.min(old_len, new_len);\n for (let i = 0; i < len; i++) {\n const child = children[i];\n if (child['_op'] === 3)\n continue;\n const el = element.childNodes[i];\n if (typeof child === 'string') {\n if (el.textContent !== child) {\n if (el.nodeType === 3) {\n el.nodeValue = child;\n }\n else {\n element.replaceChild(createText(child), el);\n }\n }\n }\n else if (child instanceof HTMLElement || child instanceof SVGElement) {\n element.insertBefore(child, el);\n }\n else {\n const key = child.props && child.props['key'];\n if (key) {\n if (el.key === key) {\n update(element.childNodes[i], child, isSvg);\n }\n else {\n // console.log(el.key, key);\n const old = keyCache[key];\n if (old) {\n const temp = old.nextSibling;\n element.insertBefore(old, el);\n temp ? element.insertBefore(el, temp) : element.appendChild(el);\n update(element.childNodes[i], child, isSvg);\n }\n else {\n element.replaceChild(create(child, isSvg), el);\n }\n }\n }\n else {\n update(element.childNodes[i], child, isSvg);\n }\n }\n }\n let n = ((_b = element.childNodes) === null || _b === void 0 ? void 0 : _b.length) || 0;\n while (n > len) {\n element.removeChild(element.lastChild);\n n--;\n }\n if (new_len > len) {\n const d = document.createDocumentFragment();\n for (let i = len; i < children.length; i++) {\n d.appendChild(create(children[i], isSvg));\n }\n element.appendChild(d);\n }\n}\nexport const safeHTML = (html) => {\n const div = document.createElement('section');\n div.insertAdjacentHTML('afterbegin', html);\n return Array.from(div.children);\n};\nfunction createText(node) {\n if ((node === null || node === void 0 ? void 0 : node.indexOf('_html:')) === 0) { // ?\n const div = document.createElement('div');\n div.insertAdjacentHTML('afterbegin', node.substring(6));\n return div;\n }\n else {\n return document.createTextNode(node !== null && node !== void 0 ? node : '');\n }\n}\nfunction create(node, isSvg) {\n // console.assert(node !== null && node !== undefined);\n if ((node instanceof HTMLElement) || (node instanceof SVGElement))\n return node;\n if (typeof node === \"string\")\n return createText(node);\n if (!node.tag || (typeof node.tag === 'function'))\n return createText(JSON.stringify(node));\n isSvg = isSvg || node.tag === \"svg\";\n const element = isSvg\n ? document.createElementNS(\"http://www.w3.org/2000/svg\", node.tag)\n : document.createElement(node.tag);\n updateProps(element, node.props, isSvg);\n if (node.children)\n node.children.forEach(child => element.appendChild(create(child, isSvg)));\n return element;\n}\nfunction mergeProps(oldProps, newProps) {\n newProps['class'] = newProps['class'] || newProps['className'];\n delete newProps['className'];\n const props = {};\n if (oldProps)\n Object.keys(oldProps).forEach(p => props[p] = null);\n if (newProps)\n Object.keys(newProps).forEach(p => props[p] = newProps[p]);\n return props;\n}\nexport function updateProps(element, props, isSvg) {\n // console.assert(!!element);\n const cached = element[ATTR_PROPS] || {};\n props = mergeProps(cached, props || {});\n element[ATTR_PROPS] = props;\n for (const name in props) {\n const value = props[name];\n // if (cached[name] === value) continue;\n // console.log('updateProps', name, value);\n if (name.startsWith('data-')) {\n const dname = name.substring(5);\n const cname = dname.replace(/-(\\w)/g, (match) => match[1].toUpperCase());\n if (element.dataset[cname] !== value) {\n if (value || value === \"\")\n element.dataset[cname] = value;\n else\n delete element.dataset[cname];\n }\n }\n else if (name === 'style') {\n if (element.style.cssText)\n element.style.cssText = '';\n if (typeof value === 'string')\n element.style.cssText = value;\n else {\n for (const s in value) {\n if (element.style[s] !== value[s])\n element.style[s] = value[s];\n }\n }\n }\n else if (name.startsWith('xlink')) {\n const xname = name.replace('xlink', '').toLowerCase();\n if (value == null || value === false) {\n element.removeAttributeNS('http://www.w3.org/1999/xlink', xname);\n }\n else {\n element.setAttributeNS('http://www.w3.org/1999/xlink', xname, value);\n }\n }\n else if (name.startsWith('on')) {\n if (!value || typeof value === 'function') {\n element[name] = value;\n }\n else if (typeof value === 'string') {\n if (value)\n element.setAttribute(name, value);\n else\n element.removeAttribute(name);\n }\n }\n else if (/^id$|^class$|^list$|^readonly$|^contenteditable$|^role|-|^for$/g.test(name) || isSvg) {\n if (element.getAttribute(name) !== value) {\n if (value)\n element.setAttribute(name, value);\n else\n element.removeAttribute(name);\n }\n }\n else if (element[name] !== value) {\n element[name] = value;\n }\n if (name === 'key' && value)\n keyCache[value] = element;\n }\n if (props && typeof props['ref'] === 'function') {\n window.requestAnimationFrame(() => props['ref'](element));\n }\n}\nfunction render_component(node, parent, idx) {\n const { tag, props, children } = node;\n let key = `_${idx}`;\n let id = props && props['id'];\n if (!id)\n id = `_${idx}${Date.now()}`;\n else\n key = id;\n let asTag = 'section';\n if (props && props['as']) {\n asTag = props['as'];\n delete props['as'];\n }\n if (!parent.__componentCache)\n parent.__componentCache = {};\n let component = parent.__componentCache[key];\n if (!component || !(component instanceof tag) || !component.element) {\n const element = document.createElement(asTag);\n component = parent.__componentCache[key] = new tag(Object.assign(Object.assign({}, props), { children })).mount(element, { render: true });\n }\n else {\n component.renderState(component.state);\n }\n if (component.mounted) {\n const new_state = component.mounted(props, children, component.state);\n (typeof new_state !== 'undefined') && component.setState(new_state);\n }\n updateProps(component.element, props, false);\n return component.element;\n}\nfunction createComponent(node, parent, idx = 0) {\n var _a;\n if (typeof node === 'string')\n return node;\n if (Array.isArray(node))\n return node.map(child => createComponent(child, parent, idx++));\n let vdom = node;\n if (node && typeof node.tag === 'function' && Object.getPrototypeOf(node.tag).__isAppRunComponent) {\n vdom = render_component(node, parent, idx);\n }\n if (vdom && Array.isArray(vdom.children)) {\n const new_parent = (_a = vdom.props) === null || _a === void 0 ? void 0 : _a._component;\n if (new_parent) {\n let i = 0;\n vdom.children = vdom.children.map(child => createComponent(child, new_parent, i++));\n }\n else {\n vdom.children = vdom.children.map(child => createComponent(child, parent, idx++));\n }\n }\n return vdom;\n}\n//# sourceMappingURL=vdom-my.js.map","/**\n * Web Components Integration\n *\n * This file enables using AppRun components as Web Components:\n * 1. Custom Element Creation\n * - Converts AppRun components to custom elements\n * - Handles lifecycle (connected, disconnected, etc)\n * - Manages shadow DOM and light DOM rendering\n *\n * 2. Property/Attribute Sync\n * - Observes attribute changes\n * - Updates component state automatically\n * - Handles camelCase/kebab-case conversion\n * - Supports complex property types\n *\n * 3. Event Handling\n * - Proxies events between component and element\n * - Supports both global and local events\n * - Maintains proper event bubbling\n *\n * Usage:\n * ```ts\n * // Register web component\n * @customElement('my-element')\n * class MyComponent extends Component {\n * // Regular AppRun component code\n * }\n *\n * // Use in HTML\n * <my-element name=\"value\"></my-element>\n * ```\n */\nexport const customElement = (componentClass, options = {}) => class CustomElement extends HTMLElement {\n constructor() {\n super();\n }\n get component() { return this._component; }\n get state() { return this._component.state; }\n static get observedAttributes() {\n // attributes need to be set to lowercase in order to get observed\n return (options.observedAttributes || []).map(attr => attr.toLowerCase());\n }\n connectedCallback() {\n if (this.isConnected && !this._component) {\n const opts = options || {};\n this._shadowRoot = opts.shadow ? this.attachShadow({ mode: 'open' }) : this;\n const observedAttributes = (opts.observedAttributes || []);\n const attrMap = observedAttributes.reduce((map, name) => {\n const lc = name.toLowerCase();\n if (lc !== name) {\n map[lc] = name;\n }\n return map;\n }, {});\n this._attrMap = (name) => attrMap[name] || name;\n const props = {};\n Array.from(this.attributes).forEach(item => props[this._attrMap(item.name)] = item.value);\n // add getters/ setters to allow observation on observedAttributes\n observedAttributes.forEach(name => {\n if (this[name] !== undefined)\n props[name] = this[name];\n Object.defineProperty(this, name, {\n get() {\n return props[name];\n },\n set(value) {\n // trigger change event\n this.attributeChangedCallback(name, props[name], value);\n },\n configurable: true,\n enumerable: true\n });\n });\n requestAnimationFrame(() => {\n const children = this.children ? Array.from(this.children) : [];\n // children.forEach(el => el.parentElement.removeChild(el));\n this._component = new componentClass(Object.assign(Object.assign({}, props), { children })).mount(this._shadowRoot, opts);\n // attach props to component\n this._component._props = props;\n // expose dispatchEvent\n this._component.dispatchEvent = this.dispatchEvent.bind(this);\n if (this._component.mounted) {\n const new_state = this._component.mounted(props, children, this._component.state);\n if (typeof new_state !== 'undefined')\n this._component.state = new_state;\n }\n this.on = this._component.on.bind(this._component);\n this.run = this._component.run.bind(this._component);\n if (!(opts.render === false))\n this._component.run('.');\n });\n }\n }\n disconnectedCallback() {\n var _a, _b, _c, _d;\n (_b = (_a = this._component) === null || _a === void 0 ? void 0 : _a.unload) === null || _b === void 0 ? void 0 : _b.call(_a);\n (_d = (_c = this._component) === null || _c === void 0 ? void 0 : _c.unmount) === null || _d === void 0 ? void 0 : _d.call(_c);\n this._component = null;\n }\n attributeChangedCallback(name, oldValue, value) {\n if (this._component) {\n // camelCase attributes arrive only in lowercase\n const mappedName = this._attrMap(name);\n // store the new property/ attribute\n this._component._props[mappedName] = value;\n this._component.run('attributeChanged', mappedName, oldValue, value);\n if (value !== oldValue && !(options.render === false)) {\n window.requestAnimationFrame(() => {\n // re-render state with new combined props on next animation frame\n this._component.run('.');\n });\n }\n }\n }\n};\nexport default (name, componentClass, options) => {\n (typeof customElements !== 'undefined') && customElements.define(name, customElement(componentClass, options));\n};\n//# sourceMappingURL=web-component.js.map","import webComponent from './web-component';\n/**\n * TypeScript Decorators for AppRun Components\n *\n * This file provides decorators that enable:\n * 1. Event Handler Registration\n * - @on(): Subscribe to events with options\n * - @update(): Define state updates with metadata\n *\n * 2. Web Component Integration\n * - @customElement(): Register as custom element with options\n * - Handles shadow DOM and attribute observation\n *\n * 3. Metadata Management\n * - Custom Reflect implementation for decorator metadata\n * - Stores event handler and update metadata\n * - Supports runtime reflection for dynamic behavior\n *\n * Usage:\n * ```ts\n * @customElement('my-element')\n * class MyComponent extends Component {\n * @on('event')\n * handler(state, ...args) {\n * // Handle event\n * }\n *\n * @update('event')\n * updater(state, ...args) {\n * // Update state\n * }\n * }\n * ```\n */\n// tslint:disable:no-invalid-this\nexport const Reflect = {\n meta: new WeakMap(),\n defineMetadata(metadataKey, metadataValue, target) {\n if (!this.meta.has(target))\n this.meta.set(target, {});\n this.meta.get(target)[metadataKey] = metadataValue;\n },\n getMetadataKeys(target) {\n target = Object.getPrototypeOf(target);\n return this.meta.get(target) ? Object.keys(this.meta.get(target)) : [];\n },\n getMetadata(metadataKey, target) {\n target = Object.getPrototypeOf(target);\n return this.meta.get(target) ? this.meta.get(target)[metadataKey] : null;\n }\n};\nexport function update(events, options = {}) {\n return (target, key, descriptor) => {\n const name = events ? events.toString() : key;\n Reflect.defineMetadata(`apprun-update:${name}`, { name, key, options }, target);\n return descriptor;\n };\n}\nexport function on(events, options = {}) {\n return function (target, key) {\n const name = events ? events.toString() : key;\n Reflect.defineMetadata(`apprun-update:${name}`, { name, key, options }, target);\n };\n}\nexport function customElement(name, options) {\n return function _customElement(constructor) {\n webComponent(name, constructor, options);\n return constructor;\n };\n}\n//# sourceMappingURL=decorator.js.map","/**\n * AppRun Component System Implementation\n *\n * This file provides the Component class which is the foundation for:\n * 1. State Management\n * - Maintains component state\n * - Handles state updates\n * - Supports state history\n *\n * 2. View Rendering\n * - Renders virtual DOM to real DOM\n * - Handles component lifecycle (mounted, rendered, unload)\n * - Supports shadow DOM and web components\n *\n * 3. Event Handling\n * - Local and global event subscription\n * - Event handler registration via decorators\n * - Action to state updates\n *\n * Usage:\n * ```ts\n * class MyComponent extends Component {\n * state = // Initial state\n * view = state => // Return virtual DOM\n * update = {\n * 'event': (state, ...args) => // Return new state\n * }\n * }\n *\n * // Mount component\n * new MyComponent().mount('element-id');\n * ```\n */\nimport app, { App } from './app';\nimport { Reflect } from './decorator';\nimport directive from './directive';\nconst componentCache = new Map();\nif (!app.find('get-components'))\n app.on('get-components', o => o.components = componentCache);\nconst REFRESH = state => state;\nexport class Component {\n renderState(state, vdom = null) {\n if (!this.view)\n return;\n let html = vdom || this.view(state);\n app['debug'] && app.run('debug', {\n component: this,\n _: html ? '.' : '-',\n state,\n vdom: html,\n el: this.element\n });\n if (typeof document !== 'object')\n return;\n const el = (typeof this.element === 'string' && this.element) ?\n document.getElementById(this.element) || document.querySelector(this.element) : this.element;\n if (!el)\n return;\n const tracking_attr = '_c';\n if (!this.unload) {\n el.removeAttribute && el.removeAttribute(tracking_attr);\n }\n else if (el['_component'] !== this || el.getAttribute(tracking_attr) !== this.tracking_id) {\n this.tracking_id = new Date().valueOf().toString();\n el.setAttribute(tracking_attr, this.tracking_id);\n if (typeof MutationObserver !== 'undefined') {\n if (!this.observer)\n this.observer = new MutationObserver(changes => {\n if (changes[0].oldValue === this.tracking_id || !document.body.contains(el)) {\n this.unload(this.state);\n this.observer.disconnect();\n this.observer = null;\n }\n });\n this.observer.observe(document.body, {\n childList: true, subtree: true,\n attributes: true, attributeOldValue: true, attributeFilter: [tracking_attr]\n });\n }\n }\n el['_component'] = this;\n if (!vdom && html) {\n html = directive(html, this);\n if (this.options.transition && document && document['startViewTransition']) {\n document['startViewTransition'](() => app.render(el, html, this));\n }\n else {\n app.render(el, html, this);\n }\n }\n this.rendered && this.rendered(this.state);\n }\n setState(state, options = { render: true, history: false }) {\n const handleAsyncIterator = async (iterator) => {\n try {\n while (true) {\n const { value, done } = await iterator.next();\n if (done)\n break;\n this.setState(value, options);\n }\n }\n catch (e) {\n console.error('Error in async iterator:', e);\n }\n };\n const result = state;\n if (result === null || result === void 0 ? void 0 : result[Symbol.asyncIterator]) {\n // handleAsyncIterator(result[Symbol.asyncIterator]());\n this.setState(handleAsyncIterator(result[Symbol.asyncIterator]()), options);\n return;\n }\n else if ((result === null || result === void 0 ? void 0 : result[Symbol.iterator]) && typeof result.next === \"function\") {\n for (const value of result) {\n this.setState(value, options);\n }\n return;\n }\n else if (state && state instanceof Promise) {\n // Promise will not be saved or rendered\n // state will be saved and rendered when promise is resolved\n Promise.resolve(state).then(v => {\n this.setState(v, options);\n this._state = state;\n });\n }\n else {\n this._state = state;\n if (state == null)\n return;\n this.state = state;\n if (options.render !== false) {\n // before render state\n if (options.transition && document && document['startViewTransition']) {\n document['startViewTransition'](() => this.renderState(state));\n }\n else {\n this.renderState(state);\n }\n }\n if (options.history !== false && this.enable_history) {\n this._history = [...this._history, state];\n this._history_idx = this._history.length - 1;\n }\n if (typeof options.callback === 'function')\n options.callback(this.state);\n }\n }\n constructor(state, view, update, options) {\n this.state = state;\n this.view = view;\n this.update = update;\n this.options = options;\n this._app = new App();\n this._actions = [];\n this._global_events = [];\n this._history = [];\n this._history_idx = -1;\n this._history_prev = () => {\n this._history_idx--;\n if (this._history_idx >= 0) {\n this.setState(this._history[this._history_idx], { render: true, history: false });\n }\n else {\n this._history_idx = 0;\n }\n };\n this._history_next = () => {\n this._history_idx++;\n if (this._history_idx < this._history.length) {\n this.setState(this._history[this._history_idx], { render: true, history: false });\n }\n else {\n this._history_idx = this._history.length - 1;\n }\n };\n this.start = (element = null, options) => {\n this.mount(element, Object.assign({ render: true }, options));\n if (this.mounted && typeof this.mounted === 'function') {\n const new_state = this.mounted({}, [], this.state);\n (typeof new_state !== 'undefined') && this.setState(new_state);\n }\n return this;\n };\n }\n mount(element = null, options) {\n var _a, _b;\n console.assert(!this.element, 'Component already mounted.');\n this.options = options = Object.assign(Object.assign({}, this.options), options);\n this.element = element;\n this.global_event = options.global_event;\n this.enable_history = !!options.history;\n if (this.enable_history) {\n this.on(options.history.prev || 'history-prev', this._history_prev);\n this.on(options.history.next || 'history-next', this._history_next);\n }\n if (options.route) {\n this.update = this.update || {};\n if (!this.update[options.route])\n this.update[options.route] = REFRESH;\n }\n this.add_actions();\n this.state = (_b = (_a = this.state) !== null && _a !== void 0 ? _a : this['model']) !== null && _b !== void 0 ? _b : {};\n if (typeof this.state === 'function')\n this.state = this.state();\n this.setState(this.state, { render: !!options.render, history: true });\n if (app['debug']) {\n if (componentCache.get(element)) {\n componentCache.get(element).push(this);\n }\n else {\n componentCache.set(element, [this]);\n }\n }\n return this;\n }\n is_global_event(name) {\n return name && (this.global_event ||\n this._global_events.indexOf(name) >= 0 ||\n name.startsWith('#') || name.startsWith('/') || name.startsWith('@'));\n }\n add_action(name, action, options = {}) {\n if (!action || typeof action !== 'function')\n return;\n if (options.global)\n this._global_events.push(name);\n this.on(name, (...p) => {\n app['debug'] && app.run('debug', {\n component: this,\n _: '>',\n event: name, p,\n current_state: this.state,\n options\n });\n const newState = action(this.state, ...p);\n app['debug'] && app.run('debug', {\n component: this,\n _: '<',\n event: name, p,\n newState,\n state: this.state,\n options\n });\n this.setState(newState, options);\n }, options);\n }\n add_actions() {\n const actions = this.update || {};\n Reflect.getMetadataKeys(this).forEach(key => {\n if (key.startsWith('apprun-update:')) {\n const meta = Reflect.getMetadata(key, this);\n actions[meta.name] = [this[meta.key].bind(this), meta.options];\n }\n });\n const all = {};\n if (Array.isArray(actions)) {\n actions.forEach(act => {\n const [name, action, opts] = act;\n const names = name.toString();\n names.split(',').forEach(n => all[n.trim()] = [action, opts]);\n });\n }\n else {\n Object.keys(actions).forEach(name => {\n const action = actions[name];\n if (typeof action === 'function' || Array.isArray(action)) {\n name.split(',').forEach(n => all[n.trim()] = action);\n }\n });\n }\n if (!all['.'])\n all['.'] = REFRESH;\n Object.keys(all).forEach(name => {\n const action = all[name];\n if (typeof action === 'function') {\n this.add_action(name, action);\n }\n else if (Array.isArray(action)) {\n this.add_action(name, action[0], action[1]);\n }\n });\n }\n run(event, ...args) {\n if (this.state instanceof Promise) {\n return Promise.resolve(this.state).then(state => {\n this.state = state;\n this.run(event, ...args);\n });\n }\n else {\n const name = event.toString();\n return this.is_global_event(name) ?\n app.run(name, ...args) :\n this._app.run(name, ...args);\n }\n }\n on(event, fn, options) {\n const name = event.toString();\n this._actions.push({ name, fn });\n return this.is_global_event(name) ?\n app.on(name, fn, options) :\n this._app.on(name, fn, options);\n }\n runAsync(event, ...args) {\n const name = event.toString();\n return this.is_global_event(name) ?\n app.runAsync(name, ...args) :\n this._app.runAsync(name, ...args);\n }\n // obsolete\n query(event, ...args) {\n return this.runAsync(event, ...args);\n }\n unmount() {\n var _a;\n (_a = this.observer) === null || _a === void 0 ? void 0 : _a.disconnect();\n this._actions.forEach(action => {\n const { name, fn } = action;\n this.is_global_event(name) ?\n app.off(name, fn) :\n this._app.off(name, fn);\n });\n }\n}\nComponent.__isAppRunComponent = true;\n//# sourceMappingURL=component.js.map","/**\n * AppRun Router Implementation\n *\n * This file provides URL routing capabilities:\n * 1. Hash-based routing (#/path)\n * 2. Path-based routing (/path)\n * 3. Event-based navigation\n *\n * Features:\n * - Automatic route event firing\n * - 404 handling via ROUTER_404_EVENT\n * - History API integration\n * - Route parameter parsing\n *\n * Usage:\n * ```ts\n * // Handle routes\n * app.on('#/home', () => // Show home page);\n * app.on('#/users/:id', (id) => // Show user profile);\n *\n * // Navigate programmatically\n * app.run('route', '#/home');\n * ```\n */\nimport app from './app';\nexport const ROUTER_EVENT = '//';\nexport const ROUTER_404_EVENT = '///';\nexport const route = (url) => {\n if (!url)\n url = '#';\n if (url.startsWith('#')) {\n const [name, ...rest] = url.split('/');\n app.run(name, ...rest) || app.run(ROUTER_404_EVENT, name, ...rest);\n app.run(ROUTER_EVENT, name, ...rest);\n }\n else if (url.startsWith('/')) {\n const [_, name, ...rest] = url.split('/');\n app.run('/' + name, ...rest) || app.run(ROUTER_404_EVENT, '/' + name, ...rest);\n app.run(ROUTER_EVENT, '/' + name, ...rest);\n }\n else {\n app.run(url) || app.run(ROUTER_404_EVENT, url);\n app.run(ROUTER_EVENT, url);\n }\n};\nexport default route;\n//# sourceMappingURL=router.js.map","/**\n * Main AppRun framework entry point\n *\n * This file:\n * 1. Assembles core AppRun modules into a complete framework\n * 2. Exports public API and types\n * 3. Initializes global app instance with:\n * - Virtual DOM rendering\n * - Component system\n * - Router\n * - Web component support\n *\n * Key exports:\n * - app: Global event system instance\n * - Component: Base component class\n * - Decorators: @on, @update, @customElement\n * - Router events and configuration\n * - Web component registration\n *\n * Usage:\n * ```ts\n * import { app, Component } from 'apprun';\n *\n * // Create components\n * class MyComponent extends Component {\n * state = // Initial state\n * view = state => // Render view\n * update = {\n * 'event': (state, ...args) => // Handle events\n * }\n * }\n * ```\n */\nimport app, { App } from './app';\nimport { createElement, render, Fragment, safeHTML } from './vdom';\nimport { Component } from './component';\nimport { on, update, customElement } from './decorator';\nimport webComponent from './web-component';\nimport { route, ROUTER_EVENT, ROUTER_404_EVENT } from './router';\nexport { App, app, Component, on, update, Fragment, safeHTML };\nexport { update as event };\nexport { ROUTER_EVENT, ROUTER_404_EVENT };\nexport { customElement };\nexport default app;\nif (!app.start) {\n app.h = app.createElement = createElement;\n app.render = render;\n app.Fragment = Fragment;\n app.webComponent = webComponent;\n app.safeHTML = safeHTML;\n app.start = (element, model, view, update, options) => {\n const opts = Object.assign({ render: true, global_event: true }, options);\n const component = new Component(model, view, update);\n if (options && options.rendered)\n component.rendered = options.rendered;\n if (options && options.mounted)\n component.mounted = options.mounted;\n component.start(element, opts);\n return component;\n };\n const NOOP = _ => { };\n app.on('$', NOOP);\n app.on('debug', _ => NOOP);\n app.on(ROUTER_EVENT, NOOP);\n app.on('#', NOOP);\n app['route'] = route;\n app.on('route', url => app['route'] && app['route'](url));\n if (typeof document === 'object') {\n document.addEventListener(\"DOMContentLoaded\", () => {\n if (app['route'] === route) {\n window.onpopstate = () => route(location.hash);\n document.body.hasAttribute('apprun-no-init') || app['no-init-route'] || route(location.hash);\n }\n });\n }\n if (typeof window === 'object') {\n window['Component'] = Component;\n window['_React'] = window['React'];\n window['React'] = app;\n window['on'] = on;\n window['customElement'] = customElement;\n window['safeHTML'] = safeHTML;\n }\n app.use_render = (render, mode = 0) => {\n if (mode === 0) {\n app.render = (el, vdom) => render(vdom, el); // react style\n }\n else {\n app.render = (el, vdom) => render(el, vdom); // apprun style\n }\n };\n app.use_react = (React, ReactDOM) => {\n app.h = app.createElement = React.createElement;\n app.Fragment = React.Fragment;\n app.render = (el, vdom) => ReactDOM.render(vdom, el);\n if (React.version && React.version.startsWith('18')) {\n app.render = (el, vdom) => {\n if (!el || !vdom)\n return;\n if (!el._root)\n el._root = ReactDOM.createRoot(el);\n el._root.render(vdom);\n };\n }\n };\n app.use_prettyLink = () => {\n window.onload = () => app.route(location.pathname);\n window.addEventListener(\"popstate\", () => app.route(location.pathname));\n document.body.addEventListener('click', e => {\n const element = e.target;\n const menu = (element.tagName === 'A' ? element : element.closest('a'));\n if (menu &&\n menu.origin === location.origin) {\n e.preventDefault();\n history.pushState(null, '', menu.pathname);\n app.route(menu.pathname);\n }\n });\n };\n}\n//# sourceMappingURL=apprun.js.map"],"names":["App","constructor","this","_events","on","name","fn","options","push","off","subscribers","filter","sub","find","run","args","getSubscribers","console","assert","length","forEach","delay","Object","keys","apply","once","assign","_t","clearTimeout","setTimeout","runAsync","promises","map","Promise","all","query","events","evt","endsWith","startsWith","replace","sort","a","b","event","_app","root","window","global","self","app","_AppRunVersions","getStateValue","component","setStateValue","value","state","setState","directive","vdom","Array","isArray","element","type","tag","props","children","key","substring","e","handler","p","target","checked","Number","multiple","selected","apply_directive","Fragment","collect","ATTR_PROPS","ch","c","i","keyCache","WeakMap","updateElement","nodes","parent","createComponent","isSvg","nodeName","updateChildren","render","document","getElementById","querySelector","update","node","el","key1","key2","toUpperCase","same","parentNode","replaceChild","create","updateProps","_a","_b","old_len","childNodes","new_len","len","Math","min","child","textContent","nodeType","nodeValue","createText","HTMLElement","SVGElement","insertBefore","old","temp","nextSibling","appendChild","n","removeChild","lastChild","d","createDocumentFragment","safeHTML","html","div","createElement","insertAdjacentHTML","from","indexOf","createTextNode","JSON","stringify","createElementNS","cached","oldProps","newProps","mergeProps","cname","match","dataset","style","cssText","s","xname","toLowerCase","removeAttributeNS","setAttributeNS","setAttribute","removeAttribute","test","getAttribute","requestAnimationFrame","idx","getPrototypeOf","__isAppRunComponent","id","Date","now","asTag","__componentCache","renderState","mount","mounted","new_state","render_component","new_parent","_component","customElement","componentClass","super","observedAttributes","attr","connectedCallback","isConnected","opts","_shadowRoot","shadow","attachShadow","mode","attrMap","reduce","lc","_attrMap","attributes","item","undefined","defineProperty","get","set","attributeChangedCallback","configurable","enumerable","_props","dispatchEvent","bind","disconnectedCallback","_c","_d","unload","call","unmount","oldValue","mappedName","webComponent","customElements","define","Reflect","meta","defineMetadata","metadataKey","metadataValue","has","getMetadataKeys","getMetadata","descriptor","toString","componentCache","Map","o","components","REFRESH","Component","view","_","tracking_attr","tracking_id","valueOf","MutationObserver","observer","changes","body","contains","disconnect","observe","childList","subtree","attributeOldValue","attributeFilter","transition","rendered","history","handleAsyncIterator","async","iterator","done","next","error","result","Symbol","asyncIterator","resolve","then","v","_state","enable_history","_history","_history_idx","callback","_actions","_global_events","_history_prev","_history_next","start","global_event","prev","route","add_actions","is_global_event","add_action","action","current_state","newState","actions","act","split","trim","ROUTER_EVENT","ROUTER_404_EVENT","url","rest","h","Error","model","NOOP","addEventListener","onpopstate","location","hash","hasAttribute","use_render","use_react","React","ReactDOM","version","_root","createRoot","use_prettyLink","onload","pathname","menu","tagName","closest","origin","preventDefault","pushState"],"mappings":"AA2BO,MAAMA,EACT,WAAAC,GACIC,KAAKC,QAAU,CAAE,CACzB,CACI,EAAAC,CAAGC,EAAMC,EAAIC,EAAU,CAAA,GACnBL,KAAKC,QAAQE,GAAQH,KAAKC,QAAQE,IAAS,GAC3CH,KAAKC,QAAQE,GAAMG,KAAK,CAAEF,KAAIC,WACtC,CACI,GAAAE,CAAIJ,EAAMC,GACN,MAAMI,EAAcR,KAAKC,QAAQE,IAAS,GAC1CH,KAAKC,QAAQE,GAAQK,EAAYC,QAAQC,GAAQA,EAAIN,KAAOA,GACpE,CACI,IAAAO,CAAKR,GACD,OAAOH,KAAKC,QAAQE,EAC5B,CACI,GAAAS,CAAIT,KAASU,GACT,MAAML,EAAcR,KAAKc,eAAeX,EAAMH,KAAKC,SAYnD,OAXAc,QAAQC,OAAOR,GAAeA,EAAYS,OAAS,EAAG,4BAA8Bd,GACpFK,EAAYU,SAASR,IACjB,MAAMN,GAAEA,EAAEC,QAAEA,GAAYK,EAOxB,OANIL,EAAQc,MACRnB,KAAKmB,MAAMhB,EAAMC,EAAIS,EAAMR,GAG3Be,OAAOC,KAAKhB,GAASY,OAAS,EAAIb,EAAGk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W,EAAI2C,OAAS,CAACM,EAAIxC,KACTwC,GAAOxC,IAEPwC,EAAG8M,QACJ9M,EAAG8M,MAAQF,EAASG,WAAW/M,IACnCA,EAAG8M,MAAMpN,OAAOlC,GAAK,EAErC,EAEIT,EAAIiQ,eAAiB,KACjBpQ,OAAOqQ,OAAS,IAAMlQ,EAAIkO,MAAMqB,SAASY,UACzCtQ,OAAOwP,iBAAiB,YAAY,IAAMrP,EAAIkO,MAAMqB,SAASY,YAC7DvN,SAASmJ,KAAKsD,iBAAiB,SAASlO,IACpC,MAAMP,EAAUO,EAAEG,OACZ8O,EAA4B,MAApBxP,EAAQyP,QAAkBzP,EAAUA,EAAQ0P,QAAQ,KAC9DF,GACAA,EAAKG,SAAWhB,SAASgB,SACzBpP,EAAEqP,iBACF/D,QAAQgE,UAAU,KAAM,GAAIL,EAAKD,UACjCnQ,EAAIkO,MAAMkC,EAAKD,UAC/B,GACU,CAEV"}
package/dist/apprun.js CHANGED
@@ -1,2 +1,2 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.apprun=e():t.apprun=e()}(this,(()=>(()=>{"use strict";var t={859:(t,e,n)=>{n.d(e,{A:()=>r,q:()=>s});class s{constructor(){this._events={}}on(t,e,n={}){this._events[t]=this._events[t]||[],this._events[t].push({fn:e,options:n})}off(t,e){const n=this._events[t]||[];this._events[t]=n.filter((t=>t.fn!==e))}find(t){return this._events[t]}run(t,...e){const n=this.getSubscribers(t,this._events);return console.assert(n&&n.length>0,"No subscriber for event: "+t),n.forEach((n=>{const{fn:s,options:o}=n;return o.delay?this.delay(t,s,e,o):Object.keys(o).length>0?s.apply(this,[...e,o]):s.apply(this,e),!n.options.once})),n.length}once(t,e,n={}){this.on(t,e,Object.assign(Object.assign({},n),{once:!0}))}delay(t,e,n,s){s._t&&clearTimeout(s._t),s._t=setTimeout((()=>{clearTimeout(s._t),Object.keys(s).length>0?e.apply(this,[...n,s]):e.apply(this,n)}),s.delay)}runAsync(t,...e){const n=this.getSubscribers(t,this._events);console.assert(n&&n.length>0,"No subscriber for event: "+t);const s=n.map((t=>{const{fn:n,options:s}=t;return Object.keys(s).length>0?n.apply(this,[...e,s]):n.apply(this,e)}));return Promise.all(s)}query(t,...e){return this.runAsync(t,...e)}getSubscribers(t,e){const n=e[t]||[];return e[t]=n.filter((t=>!t.options.once)),Object.keys(e).filter((e=>e.endsWith("*")&&t.startsWith(e.replace("*","")))).sort(((t,e)=>e.length-t.length)).forEach((s=>n.push(...e[s].map((e=>Object.assign(Object.assign({},e),{options:Object.assign(Object.assign({},e.options),{event:t})})))))),n}}let o;const i="object"==typeof self&&self.self===self&&self||"object"==typeof n.g&&n.g.global===n.g&&n.g;i.app&&i._AppRunVersions?o=i.app:(o=new s,i.app=o,i._AppRunVersions="AppRun-3");const r=o},741:(t,e,n)=>{n.d(e,{A:()=>a});var s=n(859);const o=(t,e)=>(e?t.state[e]:t.state)||"",i=(t,e,n)=>{if(e){const s=t.state||{};s[e]=n,t.setState(s)}else t.setState(n)},r=(t,e)=>{if(Array.isArray(t))return t.map((t=>r(t,e)));{let{type:n,tag:a,props:c,children:h}=t;return a=a||n,h=h||(null==c?void 0:c.children),c&&Object.keys(c).forEach((t=>{t.startsWith("$")&&(((t,e,n,r)=>{if(t.startsWith("$on")){const n=e[t];if(t=t.substring(1),"boolean"==typeof n)e[t]=e=>r.run?r.run(t,e):s.A.run(t,e);else if("string"==typeof n)e[t]=t=>r.run?r.run(n,t):s.A.run(n,t);else if("function"==typeof n)e[t]=t=>r.setState(n(r.state,t));else if(Array.isArray(n)){const[o,...i]=n;"string"==typeof o?e[t]=t=>r.run?r.run(o,...i,t):s.A.run(o,...i,t):"function"==typeof o&&(e[t]=t=>r.setState(o(r.state,...i,t)))}}else if("$bind"===t){const s=e.type||"text",a="string"==typeof e[t]?e[t]:e.name;if("input"===n)switch(s){case"checkbox":e.checked=o(r,a),e.onclick=t=>i(r,a||t.target.name,t.target.checked);break;case"radio":e.checked=o(r,a)===e.value,e.onclick=t=>i(r,a||t.target.name,t.target.value);break;case"number":case"range":e.value=o(r,a),e.oninput=t=>i(r,a||t.target.name,Number(t.target.value));break;default:e.value=o(r,a),e.oninput=t=>i(r,a||t.target.name,t.target.value)}else"select"===n?(e.value=o(r,a),e.onchange=t=>{t.target.multiple||i(r,a||t.target.name,t.target.value)}):"option"===n?(e.selected=o(r,a),e.onclick=t=>i(r,a||t.target.name,t.target.selected)):"textarea"===n&&(e.innerHTML=o(r,a),e.oninput=t=>i(r,a||t.target.name,t.target.value))}else s.A.run("$",{key:t,tag:n,props:e,component:r})})(t,c,a,e),delete c[t])})),h&&r(h,e),t}},a=r},791:(t,e,n)=>{n.d(e,{FK:()=>o,cJ:()=>h,n:()=>a,t_:()=>d});var s=n(741);function o(t,...e){return r(e)}const i="_props";function r(t){const e=[],n=t=>{null!=t&&""!==t&&!1!==t&&e.push("function"==typeof t||"object"==typeof t?t:`${t}`)};return t&&t.forEach((t=>{Array.isArray(t)?t.forEach((t=>n(t))):n(t)})),e}function a(t,e,...n){const s=r(n);if("string"==typeof t)return{tag:t,props:e,children:s};if(Array.isArray(t))return t;if(void 0===t&&n)return s;if(Object.getPrototypeOf(t).__isAppRunComponent)return{tag:t,props:e,children:s};if("function"==typeof t)return t(e,s);throw new Error(`Unknown tag in vdom ${t}`)}const c=new WeakMap,h=(t,e,n={})=>{null!=e&&!1!==e&&function(t,e,n={}){if(null==e||!1===e)return;if(e=g(e,n),!t)return;const s="SVG"===t.nodeName;Array.isArray(e)?l(t,e,s):l(t,[e],s)}("string"==typeof t&&t?document.getElementById(t)||document.querySelector(t):t,e=(0,s.A)(e,n),n)};function u(t,e,n){3!==e._op&&(n=n||"svg"===e.tag,function(t,e){const n=t.nodeName,s=`${e.tag||""}`;return n.toUpperCase()===s.toUpperCase()}(t,e)?(!(2&e._op)&&l(t,e.children,n),!(1&e._op)&&m(t,e.props,n)):t.parentNode.replaceChild(f(e,n),t))}function l(t,e,n){var s,o;const i=(null===(s=t.childNodes)||void 0===s?void 0:s.length)||0,r=(null==e?void 0:e.length)||0,a=Math.min(i,r);for(let s=0;s<a;s++){const o=e[s];if(3===o._op)continue;const i=t.childNodes[s];if("string"==typeof o)i.textContent!==o&&(3===i.nodeType?i.nodeValue=o:t.replaceChild(p(o),i));else if(o instanceof HTMLElement||o instanceof SVGElement)t.insertBefore(o,i);else{const e=o.props&&o.props.key;if(e)if(i.key===e)u(t.childNodes[s],o,n);else{const r=c[e];if(r){const e=r.nextSibling;t.insertBefore(r,i),e?t.insertBefore(i,e):t.appendChild(i),u(t.childNodes[s],o,n)}else t.replaceChild(f(o,n),i)}else u(t.childNodes[s],o,n)}}let h=(null===(o=t.childNodes)||void 0===o?void 0:o.length)||0;for(;h>a;)t.removeChild(t.lastChild),h--;if(r>a){const s=document.createDocumentFragment();for(let t=a;t<e.length;t++)s.appendChild(f(e[t],n));t.appendChild(s)}}const d=t=>{const e=document.createElement("section");return e.insertAdjacentHTML("afterbegin",t),Array.from(e.children)};function p(t){if(0===(null==t?void 0:t.indexOf("_html:"))){const e=document.createElement("div");return e.insertAdjacentHTML("afterbegin",t.substring(6)),e}return document.createTextNode(null!=t?t:"")}function f(t,e){if(t instanceof HTMLElement||t instanceof SVGElement)return t;if("string"==typeof t)return p(t);if(!t.tag||"function"==typeof t.tag)return p(JSON.stringify(t));const n=(e=e||"svg"===t.tag)?document.createElementNS("http://www.w3.org/2000/svg",t.tag):document.createElement(t.tag);return m(n,t.props,e),t.children&&t.children.forEach((t=>n.appendChild(f(t,e)))),n}function m(t,e,n){const s=t[i]||{};e=function(t,e){e.class=e.class||e.className,delete e.className;const n={};return t&&Object.keys(t).forEach((t=>n[t]=null)),e&&Object.keys(e).forEach((t=>n[t]=e[t])),n}(s,e||{}),t[i]=e;for(const s in e){const o=e[s];if(s.startsWith("data-")){const e=s.substring(5).replace(/-(\w)/g,(t=>t[1].toUpperCase()));t.dataset[e]!==o&&(o||""===o?t.dataset[e]=o:delete t.dataset[e])}else if("style"===s)if(t.style.cssText&&(t.style.cssText=""),"string"==typeof o)t.style.cssText=o;else for(const e in o)t.style[e]!==o[e]&&(t.style[e]=o[e]);else if(s.startsWith("xlink")){const e=s.replace("xlink","").toLowerCase();null==o||!1===o?t.removeAttributeNS("http://www.w3.org/1999/xlink",e):t.setAttributeNS("http://www.w3.org/1999/xlink",e,o)}else s.startsWith("on")?o&&"function"!=typeof o?"string"==typeof o&&(o?t.setAttribute(s,o):t.removeAttribute(s)):t[s]=o:/^id$|^class$|^list$|^readonly$|^contenteditable$|^role|-|^for$/g.test(s)||n?t.getAttribute(s)!==o&&(o?t.setAttribute(s,o):t.removeAttribute(s)):t[s]!==o&&(t[s]=o);"key"===s&&o&&(c[o]=t)}e&&"function"==typeof e.ref&&window.requestAnimationFrame((()=>e.ref(t)))}function g(t,e,n=0){var s;if("string"==typeof t)return t;if(Array.isArray(t))return t.map((t=>g(t,e,n++)));let o=t;if(t&&"function"==typeof t.tag&&Object.getPrototypeOf(t.tag).__isAppRunComponent&&(o=function(t,e,n){const{tag:s,props:o,children:i}=t;let r=`_${n}`,a=o&&o.id;a?r=a:a=`_${n}${Date.now()}`;let c="section";o&&o.as&&(c=o.as,delete o.as),e.__componentCache||(e.__componentCache={});let h=e.__componentCache[r];if(h&&h instanceof s&&h.element)h.renderState(h.state);else{const t=document.createElement(c);h=e.__componentCache[r]=new s(Object.assign(Object.assign({},o),{children:i})).mount(t,{render:!0})}if(h.mounted){const t=h.mounted(o,i,h.state);void 0!==t&&h.setState(t)}return m(h.element,o,!1),h.element}(t,e,n)),o&&Array.isArray(o.children)){const t=null===(s=o.props)||void 0===s?void 0:s._component;if(t){let e=0;o.children=o.children.map((n=>g(n,t,e++)))}else o.children=o.children.map((t=>g(t,e,n++)))}return o}},320:(t,e,n)=>{n.d(e,{Fragment:()=>s.FK,createElement:()=>s.n,render:()=>s.cJ,safeHTML:()=>s.t_});var s=n(791)}},e={};function n(s){var o=e[s];if(void 0!==o)return o.exports;var i=e[s]={exports:{}};return t[s](i,i.exports,n),i.exports}n.d=(t,e)=>{for(var s in e)n.o(e,s)&&!n.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:e[s]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var s={};n.r(s),n.d(s,{App:()=>o.q,Component:()=>m,Fragment:()=>i.Fragment,ROUTER_404_EVENT:()=>y,ROUTER_EVENT:()=>g,app:()=>o.A,customElement:()=>l,default:()=>b,event:()=>h,on:()=>u,safeHTML:()=>i.safeHTML,update:()=>h});var o=n(859),i=n(320);const r=(t,e={})=>class extends HTMLElement{constructor(){super()}get component(){return this._component}get state(){return this._component.state}static get observedAttributes(){return(e.observedAttributes||[]).map((t=>t.toLowerCase()))}connectedCallback(){if(this.isConnected&&!this._component){const n=e||{};this._shadowRoot=n.shadow?this.attachShadow({mode:"open"}):this;const s=n.observedAttributes||[],o=s.reduce(((t,e)=>{const n=e.toLowerCase();return n!==e&&(t[n]=e),t}),{});this._attrMap=t=>o[t]||t;const i={};Array.from(this.attributes).forEach((t=>i[this._attrMap(t.name)]=t.value)),s.forEach((t=>{void 0!==this[t]&&(i[t]=this[t]),Object.defineProperty(this,t,{get:()=>i[t],set(e){this.attributeChangedCallback(t,i[t],e)},configurable:!0,enumerable:!0})})),requestAnimationFrame((()=>{const e=this.children?Array.from(this.children):[];if(this._component=new t(Object.assign(Object.assign({},i),{children:e})).mount(this._shadowRoot,n),this._component._props=i,this._component.dispatchEvent=this.dispatchEvent.bind(this),this._component.mounted){const t=this._component.mounted(i,e,this._component.state);void 0!==t&&(this._component.state=t)}this.on=this._component.on.bind(this._component),this.run=this._component.run.bind(this._component),!1!==n.render&&this._component.run(".")}))}}disconnectedCallback(){var t,e,n,s;null===(e=null===(t=this._component)||void 0===t?void 0:t.unload)||void 0===e||e.call(t),null===(s=null===(n=this._component)||void 0===n?void 0:n.unmount)||void 0===s||s.call(n),this._component=null}attributeChangedCallback(t,n,s){if(this._component){const o=this._attrMap(t);this._component._props[o]=s,this._component.run("attributeChanged",o,n,s),s!==n&&!1!==e.render&&window.requestAnimationFrame((()=>{this._component.run(".")}))}}},a=(t,e,n)=>{"undefined"!=typeof customElements&&customElements.define(t,r(e,n))},c={meta:new WeakMap,defineMetadata(t,e,n){this.meta.has(n)||this.meta.set(n,{}),this.meta.get(n)[t]=e},getMetadataKeys(t){return t=Object.getPrototypeOf(t),this.meta.get(t)?Object.keys(this.meta.get(t)):[]},getMetadata(t,e){return e=Object.getPrototypeOf(e),this.meta.get(e)?this.meta.get(e)[t]:null}};function h(t,e={}){return(n,s,o)=>{const i=t?t.toString():s;return c.defineMetadata(`apprun-update:${i}`,{name:i,key:s,options:e},n),o}}function u(t,e={}){return function(n,s){const o=t?t.toString():s;c.defineMetadata(`apprun-update:${o}`,{name:o,key:s,options:e},n)}}function l(t,e){return function(n){return a(t,n,e),n}}var d=n(741);const p=new Map;o.A.find("get-components")||o.A.on("get-components",(t=>t.components=p));const f=t=>t;class m{renderState(t,e=null){if(!this.view)return;let n=e||this.view(t);if(o.A.debug&&o.A.run("debug",{component:this,_:n?".":"-",state:t,vdom:n,el:this.element}),"object"!=typeof document)return;const s="string"==typeof this.element&&this.element?document.getElementById(this.element)||document.querySelector(this.element):this.element;if(!s)return;const i="_c";this.unload?s._component===this&&s.getAttribute(i)===this.tracking_id||(this.tracking_id=(new Date).valueOf().toString(),s.setAttribute(i,this.tracking_id),"undefined"!=typeof MutationObserver&&(this.observer||(this.observer=new MutationObserver((t=>{t[0].oldValue!==this.tracking_id&&document.body.contains(s)||(this.unload(this.state),this.observer.disconnect(),this.observer=null)}))),this.observer.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeOldValue:!0,attributeFilter:[i]}))):s.removeAttribute&&s.removeAttribute(i),s._component=this,!e&&n&&(n=(0,d.A)(n,this),this.options.transition&&document&&document.startViewTransition?document.startViewTransition((()=>o.A.render(s,n,this))):o.A.render(s,n,this)),this.rendered&&this.rendered(this.state)}setState(t,e={render:!0,history:!1}){if(t instanceof Promise)Promise.resolve(t).then((n=>{this.setState(n,e),this._state=t}));else{if(this._state=t,null==t)return;this.state=t,!1!==e.render&&(e.transition&&document&&document.startViewTransition?document.startViewTransition((()=>this.renderState(t))):this.renderState(t)),!1!==e.history&&this.enable_history&&(this._history=[...this._history,t],this._history_idx=this._history.length-1),"function"==typeof e.callback&&e.callback(this.state)}}constructor(t,e,n,s){this.state=t,this.view=e,this.update=n,this.options=s,this._app=new o.q,this._actions=[],this._global_events=[],this._history=[],this._history_idx=-1,this._history_prev=()=>{this._history_idx--,this._history_idx>=0?this.setState(this._history[this._history_idx],{render:!0,history:!1}):this._history_idx=0},this._history_next=()=>{this._history_idx++,this._history_idx<this._history.length?this.setState(this._history[this._history_idx],{render:!0,history:!1}):this._history_idx=this._history.length-1},this.start=(t=null,e)=>{if(this.mount(t,Object.assign({render:!0},e)),this.mounted&&"function"==typeof this.mounted){const t=this.mounted({},[],this.state);void 0!==t&&this.setState(t)}return this}}mount(t=null,e){var n,s;return console.assert(!this.element,"Component already mounted."),this.options=e=Object.assign(Object.assign({},this.options),e),this.element=t,this.global_event=e.global_event,this.enable_history=!!e.history,this.enable_history&&(this.on(e.history.prev||"history-prev",this._history_prev),this.on(e.history.next||"history-next",this._history_next)),e.route&&(this.update=this.update||{},this.update[e.route]||(this.update[e.route]=f)),this.add_actions(),this.state=null!==(s=null!==(n=this.state)&&void 0!==n?n:this.model)&&void 0!==s?s:{},"function"==typeof this.state&&(this.state=this.state()),this.setState(this.state,{render:!!e.render,history:!0}),o.A.debug&&(p.get(t)?p.get(t).push(this):p.set(t,[this])),this}is_global_event(t){return t&&(this.global_event||this._global_events.indexOf(t)>=0||t.startsWith("#")||t.startsWith("/")||t.startsWith("@"))}add_action(t,e,n={}){e&&"function"==typeof e&&(n.global&&this._global_events.push(t),this.on(t,((...s)=>{o.A.debug&&o.A.run("debug",{component:this,_:">",event:t,p:s,current_state:this.state,options:n});const i=e(this.state,...s);o.A.debug&&o.A.run("debug",{component:this,_:"<",event:t,p:s,newState:i,state:this.state,options:n}),this.setState(i,n)}),n))}add_actions(){const t=this.update||{};c.getMetadataKeys(this).forEach((e=>{if(e.startsWith("apprun-update:")){const n=c.getMetadata(e,this);t[n.name]=[this[n.key].bind(this),n.options]}}));const e={};Array.isArray(t)?t.forEach((t=>{const[n,s,o]=t;n.toString().split(",").forEach((t=>e[t.trim()]=[s,o]))})):Object.keys(t).forEach((n=>{const s=t[n];("function"==typeof s||Array.isArray(s))&&n.split(",").forEach((t=>e[t.trim()]=s))})),e["."]||(e["."]=f),Object.keys(e).forEach((t=>{const n=e[t];"function"==typeof n?this.add_action(t,n):Array.isArray(n)&&this.add_action(t,n[0],n[1])}))}run(t,...e){if(this.state instanceof Promise)return Promise.resolve(this.state).then((n=>{this.state=n,this.run(t,...e)}));{const n=t.toString();return this.is_global_event(n)?o.A.run(n,...e):this._app.run(n,...e)}}on(t,e,n){const s=t.toString();return this._actions.push({name:s,fn:e}),this.is_global_event(s)?o.A.on(s,e,n):this._app.on(s,e,n)}runAsync(t,...e){const n=t.toString();return this.is_global_event(n)?o.A.runAsync(n,...e):this._app.runAsync(n,...e)}query(t,...e){return this.runAsync(t,...e)}unmount(){var t;null===(t=this.observer)||void 0===t||t.disconnect(),this._actions.forEach((t=>{const{name:e,fn:n}=t;this.is_global_event(e)?o.A.off(e,n):this._app.off(e,n)}))}}m.__isAppRunComponent=!0;const g="//",y="///",_=t=>{if(t||(t="#"),t.startsWith("#")){const[e,...n]=t.split("/");o.A.run(e,...n)||o.A.run(y,e,...n),o.A.run(g,e,...n)}else if(t.startsWith("/")){const[e,n,...s]=t.split("/");o.A.run("/"+n,...s)||o.A.run(y,"/"+n,...s),o.A.run(g,"/"+n,...s)}else o.A.run(t)||o.A.run(y,t),o.A.run(g,t)},b=o.A;if(!o.A.start){o.A.h=o.A.createElement=i.createElement,o.A.render=i.render,o.A.Fragment=i.Fragment,o.A.webComponent=a,o.A.safeHTML=i.safeHTML,o.A.start=(t,e,n,s,o)=>{const i=Object.assign({render:!0,global_event:!0},o),r=new m(e,n,s);return o&&o.rendered&&(r.rendered=o.rendered),o&&o.mounted&&(r.mounted=o.mounted),r.start(t,i),r};const t=t=>{};o.A.on("$",t),o.A.on("debug",(e=>t)),o.A.on(g,t),o.A.on("#",t),o.A.route=_,o.A.on("route",(t=>o.A.route&&o.A.route(t))),"object"==typeof document&&document.addEventListener("DOMContentLoaded",(()=>{o.A.route===_&&(window.onpopstate=()=>_(location.hash),document.body.hasAttribute("apprun-no-init")||o.A["no-init-route"]||_(location.hash))})),"object"==typeof window&&(window.Component=m,window._React=window.React,window.React=o.A,window.on=u,window.customElement=l,window.safeHTML=i.safeHTML),o.A.use_render=(t,e=0)=>o.A.render=0===e?(e,n)=>t(n,e):(e,n)=>t(e,n),o.A.use_react=(t,e)=>{o.A.h=o.A.createElement=t.createElement,o.A.Fragment=t.Fragment,o.A.render=(t,n)=>e.render(n,t),t.version&&t.version.startsWith("18")&&(o.A.render=(t,n)=>{t&&n&&(t._root||(t._root=e.createRoot(t)),t._root.render(n))})}}return s})()));
1
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.apprun=e():t.apprun=e()}(this,(()=>(()=>{"use strict";var t={859:(t,e,n)=>{n.d(e,{A:()=>r,q:()=>s});class s{constructor(){this._events={}}on(t,e,n={}){this._events[t]=this._events[t]||[],this._events[t].push({fn:e,options:n})}off(t,e){const n=this._events[t]||[];this._events[t]=n.filter((t=>t.fn!==e))}find(t){return this._events[t]}run(t,...e){const n=this.getSubscribers(t,this._events);return console.assert(n&&n.length>0,"No subscriber for event: "+t),n.forEach((n=>{const{fn:s,options:o}=n;return o.delay?this.delay(t,s,e,o):Object.keys(o).length>0?s.apply(this,[...e,o]):s.apply(this,e),!n.options.once})),n.length}once(t,e,n={}){this.on(t,e,Object.assign(Object.assign({},n),{once:!0}))}delay(t,e,n,s){s._t&&clearTimeout(s._t),s._t=setTimeout((()=>{clearTimeout(s._t),Object.keys(s).length>0?e.apply(this,[...n,s]):e.apply(this,n)}),s.delay)}runAsync(t,...e){const n=this.getSubscribers(t,this._events);console.assert(n&&n.length>0,"No subscriber for event: "+t);const s=n.map((t=>{const{fn:n,options:s}=t;return Object.keys(s).length>0?n.apply(this,[...e,s]):n.apply(this,e)}));return Promise.all(s)}query(t,...e){return this.runAsync(t,...e)}getSubscribers(t,e){const n=e[t]||[];return e[t]=n.filter((t=>!t.options.once)),Object.keys(e).filter((e=>e.endsWith("*")&&t.startsWith(e.replace("*","")))).sort(((t,e)=>e.length-t.length)).forEach((s=>n.push(...e[s].map((e=>Object.assign(Object.assign({},e),{options:Object.assign(Object.assign({},e.options),{event:t})})))))),n}}let o;const i="undefined"!=typeof window?window:void 0!==n.g?n.g:"undefined"!=typeof self?self:{};i.app&&i._AppRunVersions?o=i.app:(o=new s,i.app=o,i._AppRunVersions="AppRun-3");const r=o},741:(t,e,n)=>{n.d(e,{A:()=>a});var s=n(859);const o=(t,e)=>(e?t.state[e]:t.state)||"",i=(t,e,n)=>{if(e){const s=t.state||{};s[e]=n,t.setState(s)}else t.setState(n)},r=(t,e)=>{if(Array.isArray(t))return t.map((t=>r(t,e)));{let{type:n,tag:a,props:c,children:h}=t;return a=a||n,h=h||(null==c?void 0:c.children),c&&Object.keys(c).forEach((t=>{t.startsWith("$")&&(((t,e,n,r)=>{if(t.startsWith("$on")){const n=e[t];if(t=t.substring(1),"boolean"==typeof n)e[t]=e=>r.run?r.run(t,e):s.A.run(t,e);else if("string"==typeof n)e[t]=t=>r.run?r.run(n,t):s.A.run(n,t);else if("function"==typeof n)e[t]=t=>r.setState(n(r.state,t));else if(Array.isArray(n)){const[o,...i]=n;"string"==typeof o?e[t]=t=>r.run?r.run(o,...i,t):s.A.run(o,...i,t):"function"==typeof o&&(e[t]=t=>r.setState(o(r.state,...i,t)))}}else if("$bind"===t){const s=e.type||"text",a="string"==typeof e[t]?e[t]:e.name;if("input"===n)switch(s){case"checkbox":e.checked=o(r,a),e.onclick=t=>i(r,a||t.target.name,t.target.checked);break;case"radio":e.checked=o(r,a)===e.value,e.onclick=t=>i(r,a||t.target.name,t.target.value);break;case"number":case"range":e.value=o(r,a),e.oninput=t=>i(r,a||t.target.name,Number(t.target.value));break;default:e.value=o(r,a),e.oninput=t=>i(r,a||t.target.name,t.target.value)}else"select"===n?(e.value=o(r,a),e.onchange=t=>{t.target.multiple||i(r,a||t.target.name,t.target.value)}):"option"===n?(e.selected=o(r,a),e.onclick=t=>i(r,a||t.target.name,t.target.selected)):"textarea"===n&&(e.innerHTML=o(r,a),e.oninput=t=>i(r,a||t.target.name,t.target.value))}else s.A.run("$",{key:t,tag:n,props:e,component:r})})(t,c,a,e),delete c[t])})),h&&r(h,e),t}},a=r},791:(t,e,n)=>{n.d(e,{FK:()=>o,cJ:()=>h,n:()=>a,t_:()=>d});var s=n(741);function o(t,...e){return r(e)}const i="_props";function r(t){const e=[],n=t=>{null!=t&&""!==t&&!1!==t&&e.push("function"==typeof t||"object"==typeof t?t:`${t}`)};return t&&t.forEach((t=>{Array.isArray(t)?t.forEach((t=>n(t))):n(t)})),e}function a(t,e,...n){const s=r(n);if("string"==typeof t)return{tag:t,props:e,children:s};if(Array.isArray(t))return t;if(void 0===t&&n)return s;if(Object.getPrototypeOf(t).__isAppRunComponent)return{tag:t,props:e,children:s};if("function"==typeof t)return t(e,s);throw new Error(`Unknown tag in vdom ${t}`)}const c=new WeakMap,h=(t,e,n={})=>{null!=e&&!1!==e&&function(t,e,n={}){if(null==e||!1===e)return;if(e=y(e,n),!t)return;const s="SVG"===t.nodeName;Array.isArray(e)?l(t,e,s):l(t,[e],s)}("string"==typeof t&&t?document.getElementById(t)||document.querySelector(t):t,e=(0,s.A)(e,n),n)};function u(t,e,n){3!==e._op&&(n=n||"svg"===e.tag,function(t,e){const n=t.nodeName,s=`${e.tag||""}`;return n.toUpperCase()===s.toUpperCase()}(t,e)?(!(2&e._op)&&l(t,e.children,n),!(1&e._op)&&m(t,e.props,n)):t.parentNode.replaceChild(f(e,n),t))}function l(t,e,n){var s,o;const i=(null===(s=t.childNodes)||void 0===s?void 0:s.length)||0,r=(null==e?void 0:e.length)||0,a=Math.min(i,r);for(let s=0;s<a;s++){const o=e[s];if(3===o._op)continue;const i=t.childNodes[s];if("string"==typeof o)i.textContent!==o&&(3===i.nodeType?i.nodeValue=o:t.replaceChild(p(o),i));else if(o instanceof HTMLElement||o instanceof SVGElement)t.insertBefore(o,i);else{const e=o.props&&o.props.key;if(e)if(i.key===e)u(t.childNodes[s],o,n);else{const r=c[e];if(r){const e=r.nextSibling;t.insertBefore(r,i),e?t.insertBefore(i,e):t.appendChild(i),u(t.childNodes[s],o,n)}else t.replaceChild(f(o,n),i)}else u(t.childNodes[s],o,n)}}let h=(null===(o=t.childNodes)||void 0===o?void 0:o.length)||0;for(;h>a;)t.removeChild(t.lastChild),h--;if(r>a){const s=document.createDocumentFragment();for(let t=a;t<e.length;t++)s.appendChild(f(e[t],n));t.appendChild(s)}}const d=t=>{const e=document.createElement("section");return e.insertAdjacentHTML("afterbegin",t),Array.from(e.children)};function p(t){if(0===(null==t?void 0:t.indexOf("_html:"))){const e=document.createElement("div");return e.insertAdjacentHTML("afterbegin",t.substring(6)),e}return document.createTextNode(null!=t?t:"")}function f(t,e){if(t instanceof HTMLElement||t instanceof SVGElement)return t;if("string"==typeof t)return p(t);if(!t.tag||"function"==typeof t.tag)return p(JSON.stringify(t));const n=(e=e||"svg"===t.tag)?document.createElementNS("http://www.w3.org/2000/svg",t.tag):document.createElement(t.tag);return m(n,t.props,e),t.children&&t.children.forEach((t=>n.appendChild(f(t,e)))),n}function m(t,e,n){const s=t[i]||{};e=function(t,e){e.class=e.class||e.className,delete e.className;const n={};return t&&Object.keys(t).forEach((t=>n[t]=null)),e&&Object.keys(e).forEach((t=>n[t]=e[t])),n}(s,e||{}),t[i]=e;for(const s in e){const o=e[s];if(s.startsWith("data-")){const e=s.substring(5).replace(/-(\w)/g,(t=>t[1].toUpperCase()));t.dataset[e]!==o&&(o||""===o?t.dataset[e]=o:delete t.dataset[e])}else if("style"===s)if(t.style.cssText&&(t.style.cssText=""),"string"==typeof o)t.style.cssText=o;else for(const e in o)t.style[e]!==o[e]&&(t.style[e]=o[e]);else if(s.startsWith("xlink")){const e=s.replace("xlink","").toLowerCase();null==o||!1===o?t.removeAttributeNS("http://www.w3.org/1999/xlink",e):t.setAttributeNS("http://www.w3.org/1999/xlink",e,o)}else s.startsWith("on")?o&&"function"!=typeof o?"string"==typeof o&&(o?t.setAttribute(s,o):t.removeAttribute(s)):t[s]=o:/^id$|^class$|^list$|^readonly$|^contenteditable$|^role|-|^for$/g.test(s)||n?t.getAttribute(s)!==o&&(o?t.setAttribute(s,o):t.removeAttribute(s)):t[s]!==o&&(t[s]=o);"key"===s&&o&&(c[o]=t)}e&&"function"==typeof e.ref&&window.requestAnimationFrame((()=>e.ref(t)))}function y(t,e,n=0){var s;if("string"==typeof t)return t;if(Array.isArray(t))return t.map((t=>y(t,e,n++)));let o=t;if(t&&"function"==typeof t.tag&&Object.getPrototypeOf(t.tag).__isAppRunComponent&&(o=function(t,e,n){const{tag:s,props:o,children:i}=t;let r=`_${n}`,a=o&&o.id;a?r=a:a=`_${n}${Date.now()}`;let c="section";o&&o.as&&(c=o.as,delete o.as),e.__componentCache||(e.__componentCache={});let h=e.__componentCache[r];if(h&&h instanceof s&&h.element)h.renderState(h.state);else{const t=document.createElement(c);h=e.__componentCache[r]=new s(Object.assign(Object.assign({},o),{children:i})).mount(t,{render:!0})}if(h.mounted){const t=h.mounted(o,i,h.state);void 0!==t&&h.setState(t)}return m(h.element,o,!1),h.element}(t,e,n)),o&&Array.isArray(o.children)){const t=null===(s=o.props)||void 0===s?void 0:s._component;if(t){let e=0;o.children=o.children.map((n=>y(n,t,e++)))}else o.children=o.children.map((t=>y(t,e,n++)))}return o}},320:(t,e,n)=>{n.d(e,{Fragment:()=>s.FK,createElement:()=>s.n,render:()=>s.cJ,safeHTML:()=>s.t_});var s=n(791)}},e={};function n(s){var o=e[s];if(void 0!==o)return o.exports;var i=e[s]={exports:{}};return t[s](i,i.exports,n),i.exports}n.d=(t,e)=>{for(var s in e)n.o(e,s)&&!n.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:e[s]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var s={};n.r(s),n.d(s,{App:()=>o.q,Component:()=>m,Fragment:()=>i.Fragment,ROUTER_404_EVENT:()=>g,ROUTER_EVENT:()=>y,app:()=>o.A,customElement:()=>l,default:()=>b,event:()=>h,on:()=>u,safeHTML:()=>i.safeHTML,update:()=>h});var o=n(859),i=n(320);const r=(t,e={})=>class extends HTMLElement{constructor(){super()}get component(){return this._component}get state(){return this._component.state}static get observedAttributes(){return(e.observedAttributes||[]).map((t=>t.toLowerCase()))}connectedCallback(){if(this.isConnected&&!this._component){const n=e||{};this._shadowRoot=n.shadow?this.attachShadow({mode:"open"}):this;const s=n.observedAttributes||[],o=s.reduce(((t,e)=>{const n=e.toLowerCase();return n!==e&&(t[n]=e),t}),{});this._attrMap=t=>o[t]||t;const i={};Array.from(this.attributes).forEach((t=>i[this._attrMap(t.name)]=t.value)),s.forEach((t=>{void 0!==this[t]&&(i[t]=this[t]),Object.defineProperty(this,t,{get:()=>i[t],set(e){this.attributeChangedCallback(t,i[t],e)},configurable:!0,enumerable:!0})})),requestAnimationFrame((()=>{const e=this.children?Array.from(this.children):[];if(this._component=new t(Object.assign(Object.assign({},i),{children:e})).mount(this._shadowRoot,n),this._component._props=i,this._component.dispatchEvent=this.dispatchEvent.bind(this),this._component.mounted){const t=this._component.mounted(i,e,this._component.state);void 0!==t&&(this._component.state=t)}this.on=this._component.on.bind(this._component),this.run=this._component.run.bind(this._component),!1!==n.render&&this._component.run(".")}))}}disconnectedCallback(){var t,e,n,s;null===(e=null===(t=this._component)||void 0===t?void 0:t.unload)||void 0===e||e.call(t),null===(s=null===(n=this._component)||void 0===n?void 0:n.unmount)||void 0===s||s.call(n),this._component=null}attributeChangedCallback(t,n,s){if(this._component){const o=this._attrMap(t);this._component._props[o]=s,this._component.run("attributeChanged",o,n,s),s!==n&&!1!==e.render&&window.requestAnimationFrame((()=>{this._component.run(".")}))}}},a=(t,e,n)=>{"undefined"!=typeof customElements&&customElements.define(t,r(e,n))},c={meta:new WeakMap,defineMetadata(t,e,n){this.meta.has(n)||this.meta.set(n,{}),this.meta.get(n)[t]=e},getMetadataKeys(t){return t=Object.getPrototypeOf(t),this.meta.get(t)?Object.keys(this.meta.get(t)):[]},getMetadata(t,e){return e=Object.getPrototypeOf(e),this.meta.get(e)?this.meta.get(e)[t]:null}};function h(t,e={}){return(n,s,o)=>{const i=t?t.toString():s;return c.defineMetadata(`apprun-update:${i}`,{name:i,key:s,options:e},n),o}}function u(t,e={}){return function(n,s){const o=t?t.toString():s;c.defineMetadata(`apprun-update:${o}`,{name:o,key:s,options:e},n)}}function l(t,e){return function(n){return a(t,n,e),n}}var d=n(741);const p=new Map;o.A.find("get-components")||o.A.on("get-components",(t=>t.components=p));const f=t=>t;class m{renderState(t,e=null){if(!this.view)return;let n=e||this.view(t);if(o.A.debug&&o.A.run("debug",{component:this,_:n?".":"-",state:t,vdom:n,el:this.element}),"object"!=typeof document)return;const s="string"==typeof this.element&&this.element?document.getElementById(this.element)||document.querySelector(this.element):this.element;if(!s)return;const i="_c";this.unload?s._component===this&&s.getAttribute(i)===this.tracking_id||(this.tracking_id=(new Date).valueOf().toString(),s.setAttribute(i,this.tracking_id),"undefined"!=typeof MutationObserver&&(this.observer||(this.observer=new MutationObserver((t=>{t[0].oldValue!==this.tracking_id&&document.body.contains(s)||(this.unload(this.state),this.observer.disconnect(),this.observer=null)}))),this.observer.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeOldValue:!0,attributeFilter:[i]}))):s.removeAttribute&&s.removeAttribute(i),s._component=this,!e&&n&&(n=(0,d.A)(n,this),this.options.transition&&document&&document.startViewTransition?document.startViewTransition((()=>o.A.render(s,n,this))):o.A.render(s,n,this)),this.rendered&&this.rendered(this.state)}setState(t,e={render:!0,history:!1}){const n=t;if(null==n?void 0:n[Symbol.asyncIterator])this.setState((async t=>{try{for(;;){const{value:n,done:s}=await t.next();if(s)break;this.setState(n,e)}}catch(t){console.error("Error in async iterator:",t)}})(n[Symbol.asyncIterator]()),e);else if((null==n?void 0:n[Symbol.iterator])&&"function"==typeof n.next)for(const t of n)this.setState(t,e);else if(t&&t instanceof Promise)Promise.resolve(t).then((n=>{this.setState(n,e),this._state=t}));else{if(this._state=t,null==t)return;this.state=t,!1!==e.render&&(e.transition&&document&&document.startViewTransition?document.startViewTransition((()=>this.renderState(t))):this.renderState(t)),!1!==e.history&&this.enable_history&&(this._history=[...this._history,t],this._history_idx=this._history.length-1),"function"==typeof e.callback&&e.callback(this.state)}}constructor(t,e,n,s){this.state=t,this.view=e,this.update=n,this.options=s,this._app=new o.q,this._actions=[],this._global_events=[],this._history=[],this._history_idx=-1,this._history_prev=()=>{this._history_idx--,this._history_idx>=0?this.setState(this._history[this._history_idx],{render:!0,history:!1}):this._history_idx=0},this._history_next=()=>{this._history_idx++,this._history_idx<this._history.length?this.setState(this._history[this._history_idx],{render:!0,history:!1}):this._history_idx=this._history.length-1},this.start=(t=null,e)=>{if(this.mount(t,Object.assign({render:!0},e)),this.mounted&&"function"==typeof this.mounted){const t=this.mounted({},[],this.state);void 0!==t&&this.setState(t)}return this}}mount(t=null,e){var n,s;return console.assert(!this.element,"Component already mounted."),this.options=e=Object.assign(Object.assign({},this.options),e),this.element=t,this.global_event=e.global_event,this.enable_history=!!e.history,this.enable_history&&(this.on(e.history.prev||"history-prev",this._history_prev),this.on(e.history.next||"history-next",this._history_next)),e.route&&(this.update=this.update||{},this.update[e.route]||(this.update[e.route]=f)),this.add_actions(),this.state=null!==(s=null!==(n=this.state)&&void 0!==n?n:this.model)&&void 0!==s?s:{},"function"==typeof this.state&&(this.state=this.state()),this.setState(this.state,{render:!!e.render,history:!0}),o.A.debug&&(p.get(t)?p.get(t).push(this):p.set(t,[this])),this}is_global_event(t){return t&&(this.global_event||this._global_events.indexOf(t)>=0||t.startsWith("#")||t.startsWith("/")||t.startsWith("@"))}add_action(t,e,n={}){e&&"function"==typeof e&&(n.global&&this._global_events.push(t),this.on(t,((...s)=>{o.A.debug&&o.A.run("debug",{component:this,_:">",event:t,p:s,current_state:this.state,options:n});const i=e(this.state,...s);o.A.debug&&o.A.run("debug",{component:this,_:"<",event:t,p:s,newState:i,state:this.state,options:n}),this.setState(i,n)}),n))}add_actions(){const t=this.update||{};c.getMetadataKeys(this).forEach((e=>{if(e.startsWith("apprun-update:")){const n=c.getMetadata(e,this);t[n.name]=[this[n.key].bind(this),n.options]}}));const e={};Array.isArray(t)?t.forEach((t=>{const[n,s,o]=t;n.toString().split(",").forEach((t=>e[t.trim()]=[s,o]))})):Object.keys(t).forEach((n=>{const s=t[n];("function"==typeof s||Array.isArray(s))&&n.split(",").forEach((t=>e[t.trim()]=s))})),e["."]||(e["."]=f),Object.keys(e).forEach((t=>{const n=e[t];"function"==typeof n?this.add_action(t,n):Array.isArray(n)&&this.add_action(t,n[0],n[1])}))}run(t,...e){if(this.state instanceof Promise)return Promise.resolve(this.state).then((n=>{this.state=n,this.run(t,...e)}));{const n=t.toString();return this.is_global_event(n)?o.A.run(n,...e):this._app.run(n,...e)}}on(t,e,n){const s=t.toString();return this._actions.push({name:s,fn:e}),this.is_global_event(s)?o.A.on(s,e,n):this._app.on(s,e,n)}runAsync(t,...e){const n=t.toString();return this.is_global_event(n)?o.A.runAsync(n,...e):this._app.runAsync(n,...e)}query(t,...e){return this.runAsync(t,...e)}unmount(){var t;null===(t=this.observer)||void 0===t||t.disconnect(),this._actions.forEach((t=>{const{name:e,fn:n}=t;this.is_global_event(e)?o.A.off(e,n):this._app.off(e,n)}))}}m.__isAppRunComponent=!0;const y="//",g="///",_=t=>{if(t||(t="#"),t.startsWith("#")){const[e,...n]=t.split("/");o.A.run(e,...n)||o.A.run(g,e,...n),o.A.run(y,e,...n)}else if(t.startsWith("/")){const[e,n,...s]=t.split("/");o.A.run("/"+n,...s)||o.A.run(g,"/"+n,...s),o.A.run(y,"/"+n,...s)}else o.A.run(t)||o.A.run(g,t),o.A.run(y,t)},b=o.A;if(!o.A.start){o.A.h=o.A.createElement=i.createElement,o.A.render=i.render,o.A.Fragment=i.Fragment,o.A.webComponent=a,o.A.safeHTML=i.safeHTML,o.A.start=(t,e,n,s,o)=>{const i=Object.assign({render:!0,global_event:!0},o),r=new m(e,n,s);return o&&o.rendered&&(r.rendered=o.rendered),o&&o.mounted&&(r.mounted=o.mounted),r.start(t,i),r};const t=t=>{};o.A.on("$",t),o.A.on("debug",(e=>t)),o.A.on(y,t),o.A.on("#",t),o.A.route=_,o.A.on("route",(t=>o.A.route&&o.A.route(t))),"object"==typeof document&&document.addEventListener("DOMContentLoaded",(()=>{o.A.route===_&&(window.onpopstate=()=>_(location.hash),document.body.hasAttribute("apprun-no-init")||o.A["no-init-route"]||_(location.hash))})),"object"==typeof window&&(window.Component=m,window._React=window.React,window.React=o.A,window.on=u,window.customElement=l,window.safeHTML=i.safeHTML),o.A.use_render=(t,e=0)=>{o.A.render=0===e?(e,n)=>t(n,e):(e,n)=>t(e,n)},o.A.use_react=(t,e)=>{o.A.h=o.A.createElement=t.createElement,o.A.Fragment=t.Fragment,o.A.render=(t,n)=>e.render(n,t),t.version&&t.version.startsWith("18")&&(o.A.render=(t,n)=>{t&&n&&(t._root||(t._root=e.createRoot(t)),t._root.render(n))})},o.A.use_prettyLink=()=>{window.onload=()=>o.A.route(location.pathname),window.addEventListener("popstate",(()=>o.A.route(location.pathname))),document.body.addEventListener("click",(t=>{const e=t.target,n="A"===e.tagName?e:e.closest("a");n&&n.origin===location.origin&&(t.preventDefault(),history.pushState(null,"",n.pathname),o.A.route(n.pathname))}))}}return s})()));
2
2
  //# sourceMappingURL=apprun.js.map