apprun 3.33.10 → 3.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/WHATSNEW.md +50 -3
- package/apprun.d.ts +2 -2
- package/dist/apprun-dev-tools.js +1 -1
- package/dist/apprun-dev-tools.js.map +1 -1
- package/dist/apprun-html.esm.js +1 -1
- package/dist/apprun-html.esm.js.map +1 -1
- package/dist/apprun-html.js +1 -1
- package/dist/apprun-html.js.map +1 -1
- package/dist/apprun-play-html.esm.js +1 -1
- package/dist/apprun-play-html.esm.js.map +1 -1
- package/dist/apprun-play.js +1 -1
- package/dist/apprun-play.js.map +1 -1
- package/dist/apprun.esm.js +1 -1
- package/dist/apprun.esm.js.map +1 -1
- package/dist/apprun.js +1 -1
- package/dist/apprun.js.map +1 -1
- package/esm/app.js +1 -1
- package/esm/app.js.map +1 -1
- package/esm/apprun.js +24 -20
- package/esm/apprun.js.map +1 -1
- package/esm/router.js +3 -0
- package/esm/router.js.map +1 -1
- package/index.html +1 -0
- package/jsx-runtime.js +1 -1
- package/jsx-runtime.js.map +1 -1
- package/package.json +1 -1
- package/src/app.ts +6 -5
- package/src/apprun.ts +27 -21
- package/src/router.ts +2 -1
package/dist/apprun.esm.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
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};
|
|
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.3.11");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(i.lastUrl!==t)if(i.lastUrl=t,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.version="3.35.0",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("debug",(n=>t)),i.on(S,t),i.on(x,t),i.route=E,i.on("route",(t=>i.route&&i.route(t))),"object"==typeof document&&document.addEventListener("DOMContentLoaded",(()=>{const t=document.body.hasAttribute("apprun-no-init")||i["no-init-route"]||!1,n=i.find("#")||i.find("#/")||!1;window.addEventListener("hashchange",(()=>E(location.hash))),window.addEventListener("popstate",(()=>E(location.pathname))),n?t&&E(location.hash):(t&&E(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),E(e.pathname))})))})),"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))})}}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
|
package/dist/apprun.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,eA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C,EAAOM,EAAIxC,EAClD,EAEIT,EAAI2P,UAAY,CAACC,EAAOC,KACpB7P,EAAIiP,EAAIjP,EAAIsF,cAAgBsK,EAAMtK,cAClCtF,EAAI4B,SAAWgO,EAAMhO,SACrB5B,EAAI2C,OAAS,CAACM,EAAIxC,IAASoP,EAASlN,OAAOlC,EAAMwC,GAC7C2M,EAAME,SAAWF,EAAME,QAAQzQ,WAAW,QAC1CW,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"}
|
|
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.3.11';\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 (app['lastUrl'] === url)\n return; // Prevent duplicate routing\n app['lastUrl'] = 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.version = '3.35.0';\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(ROUTER_404_EVENT, 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 const init_load = document.body.hasAttribute('apprun-no-init') || app['no-init-route'] || false;\n const use_hash = app.find('#') || app.find('#/') || false;\n // console.log(`AppRun ${app.version} started with ${use_hash ? 'hash' : 'path'} routing. Initial load: ${init_load ? 'disabled' : 'enabled'}.`);\n window.addEventListener('hashchange', () => route(location.hash));\n window.addEventListener('popstate', () => route(location.pathname));\n if (use_hash) {\n init_load && route(location.hash);\n }\n else {\n init_load && 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 route(menu.pathname);\n }\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 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}\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","version","h","Error","model","NOOP","addEventListener","init_load","hasAttribute","use_hash","location","hash","pathname","menu","tagName","closest","origin","preventDefault","pushState","use_render","use_react","React","ReactDOM","_root","createRoot"],"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,EAAGkB,MAAMtB,KA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AI3C,EACf2C,OAAsB,cAAImI,EAC1BnI,OAAiB,SAAIsF,GAEzBnF,EAAImQ,WAAa,CAACxN,EAAQgG,EAAO,KAEzB3I,EAAI2C,OADK,IAATgG,EACa,CAAC1F,EAAIxC,IAASkC,EAAOlC,EAAMwC,GAG3B,CAACA,EAAIxC,IAASkC,EAAOM,EAAIxC,EAClD,EAEIT,EAAIoQ,UAAY,CAACC,EAAOC,KACpBtQ,EAAIkP,EAAIlP,EAAIsF,cAAgB+K,EAAM/K,cAClCtF,EAAI4B,SAAWyO,EAAMzO,SACrB5B,EAAI2C,OAAS,CAACM,EAAIxC,IAAS6P,EAAS3N,OAAOlC,EAAMwC,GAC7CoN,EAAMpB,SAAWoB,EAAMpB,QAAQ5P,WAAW,QAC1CW,EAAI2C,OAAS,CAACM,EAAIxC,KACTwC,GAAOxC,IAEPwC,EAAGsN,QACJtN,EAAGsN,MAAQD,EAASE,WAAWvN,IACnCA,EAAGsN,MAAM5N,OAAOlC,GAAK,EAErC,CAEA"}
|
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="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})()));
|
|
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.3.11");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(o.A.lastUrl!==t)if(o.A.lastUrl=t,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.version="3.35.0",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("debug",(e=>t)),o.A.on(y,t),o.A.on(g,t),o.A.route=_,o.A.on("route",(t=>o.A.route&&o.A.route(t))),"object"==typeof document&&document.addEventListener("DOMContentLoaded",(()=>{const t=document.body.hasAttribute("apprun-no-init")||o.A["no-init-route"]||!1,e=o.A.find("#")||o.A.find("#/")||!1;window.addEventListener("hashchange",(()=>_(location.hash))),window.addEventListener("popstate",(()=>_(location.pathname))),e?t&&_(location.hash):(t&&_(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),_(n.pathname))})))})),"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})()));
|
|
2
2
|
//# sourceMappingURL=apprun.js.map
|