UNPKG

@loom-js/core

Version:

A reactive, component-driven, JavaScript framework.

3 lines (2 loc) 19.5 kB
const appendChildContext=(e={},t,n)=>{if(e.children=e.children||new Map,"function"==typeof t&&["contextFunction","activityContextFunction"].includes(t.name)){let t=e.children.get(n);return t||(t={},e.children.set(n,t)),t.parent=e,t}e.children.delete(n)},getContextRootAnchor=e=>Array.isArray(e.root)?e.root[0]:e.root,getShareableContext=e=>({children:e.children,chunks:e.chunks,ctxScopes:e.ctxScopes,fingerPrint:e.fingerPrint,fragment:e.fragment,key:e.key,lifeCycleState:e.lifeCycleState?.value,node:e.node,parent:e.parent,props:e.props,root:e.root,values:e.values}),e={activity:!0,console:!0,creation:!0,error:!0,mutations:!0,updates:!0,warn:!0};let t=!1;let n=["abort","animationcancel","animationend","animationiteration","auxclick","blur","cancel","canplay","canplaythrough","change","click","close","contextmenu","cuechange","dblclick","drag","dragend","dragenter","dragexit","dragleave","dragover","dragstart","durationchange","ended","error","focus","formdata","gotpointercapture","input","invalid","keydown","keypress","keyup","load","loadeddata","loadedmetadata","loadend","loadstart","lostpointercapture","mousedown","mouseenter","mouseleave","mousemove","mouseout","mouseover","mouseup","pause","play","playing","pointercancel","pointerdown","pointerenter","pointerleave","pointermove","pointerout","pointerover","pointerup","reset","resize","scroll","select","selectionchange","selectstart","submit","touchcancel","touchstart","transitioncancel","transitionend","transitionrun","transitionstart","wheel"];const getConfig=()=>({events:n,TOKEN:o,tokenRe:r,tokenReGlobal:a}),getTokenRe=e=>new RegExp(`${o}|${window.encodeURIComponent(o)}`,e),syncConfig=()=>Object.assign(i,getConfig());let o="⚡",r=getTokenRe(),a=getTokenRe("g");const appendEvents=e=>{n=n.concat(e),syncConfig()},canDebug=e=>"production"!==globalThis.process?.env.NODE_ENV&&t&&t[e],i=getConfig(),setDebug=(n=!0,o=e)=>t=n&&Object.assign(t,o),setToken=e=>(o=e,r=getTokenRe(),a=getTokenRe("g"),syncConfig(),o),c=new Proxy(globalThis.console,{get(e,t,n){const o=e[t];return o instanceof Function?function(...t){if(canDebug("console"))return o.apply(this===n?e:this,t)}:o}}),s=new WeakMap,d=new WeakMap,getDepsForProp=(e,t)=>{const n=d.get(e)||new Map,o=n.get(t)||new Set;return n.set(t,o),d.set(e,n),o},reactiveEffect=(e,t)=>{const effect=()=>{s.set(t,effect),e(t),s.set(t,null)};effect()},reactive=(e,t=((e,t)=>e!==t))=>{const n=new Proxy(e,{get:function(e,t){return((e,t,n)=>{const o=s.get(n);o&&getDepsForProp(e,t).add(o)})(e,t,n),e[t]},set:function(e,n,o){const r=e[n];return t(r,o)&&(e[n]=o,((e,t)=>{getDepsForProp(e,t).forEach((e=>e()))})(e,n)),!0}});return n},l=new Map,u={creation(e){if(e.lifeCycleState){const t=getContextRootAnchor(e);t&&!l.has(t)&&(l.set(t,e),e.lifeCycleState.value="created")}},observe(e){const t=canDebug("mutations"),n=new MutationObserver(domChanged);t&&c.groupCollapsed("loom (Mounting...)"),n.observe(e,{childList:!0,subtree:!0}),l.forEach(((e,n)=>{const o=getContextRootAnchor(e);o&&document.contains(o)&&e.lifeCycleState?(e.lifeCycleState.value="mounted",t&&c.info((e.key?`\`${e.key}\` `:"")+"mounted",n,getShareableContext(e))):l.delete(n)})),t&&c.groupEnd()},preRender(e){e.lifeCycleState&&(e.lifeCycleState.value="beforeRender")},postRender(e){e.lifeCycleState&&(e.lifeCycleState.value="rendered")}},domChanged=e=>{const t=canDebug("mutations");t&&c.groupCollapsed("loom (Mutating...)"),e.forEach((({addedNodes:e,removedNodes:n,type:o})=>{if("childList"===o){if(n.length){const cleanUp=e=>{const n=l.get(e);n?.lifeCycleState&&(l.delete(e),n.lifeCycleState.value="unmounted",t&&c.info((n.key?`\`${n.key}\` `:"")+"unmounted",e,getShareableContext(n)))};n.forEach((e=>{const t=document.createTreeWalker(e,window.NodeFilter.SHOW_ELEMENT);for(cleanUp(t.currentNode);t.nextNode();){const e=t.currentNode;cleanUp(e)}}))}if(e.length){const handleMount=e=>{const n=l.get(e);n?.lifeCycleState&&(n.lifeCycleState.value="mounted",t&&c.info((n.key?`\`${n.key}\` `:"")+"mounted",e,getShareableContext(n)))};e.forEach((e=>{const t=document.createTreeWalker(e,window.NodeFilter.SHOW_ELEMENT);for(handleMount(t.currentNode);t.nextNode();){const e=t.currentNode;handleMount(e)}}))}}})),t&&c.groupEnd()},createLifeCycleHook=(e,{ctx:t,handler:n})=>{const o=t.ref?.[e];t[e]="function"==typeof o?e=>n(e)&o(e):n},lifeCycleStateUpdateEffect=(e,t)=>{switch(t.value){case"created":e.created?.(e.root);break;case"beforeRender":e.beforeRender?.(e.root);break;case"rendered":e.rendered?.(e.root);break;case"mounted":e.mounted?.(e.root);break;case"unmounted":e.unmounted?.(e.root)}},memoizedRefContext=(e,t)=>()=>{let n=t.next().value;return n||(n=refContext(),e.refs?.add(n),n)},refContext=()=>({onBeforeRender(e){this.beforeRender=e},onCreated(e){this.created=e},onMounted(e){this.mounted=e},onRendered(e){this.rendered=e},onUnmounted(e){this.unmounted=e}}),deepDiffObject=(e,t)=>Object.entries(e).some((([e,n])=>isObject(n)&&isObject(t[e])?deepDiffObject(n,t[e]):n!==t[e])),isObject=e=>null!==e&&"object"==typeof e&&!Array.isArray(e),resolveValue=(e,t={})=>{if("function"==typeof e){let n;if(["contextFunction","activityContextFunction"].includes(e.name)){n=e(t).root}else n=e();return n instanceof NodeList?Array.from(n):n&&"function"!=typeof n?n:""}return e instanceof NodeList?Array.from(e):e||0===e?e:""},updateLiveNode=([e,t])=>{let n;return Array.isArray(e)?(n=e.splice(0,1)[0],e.forEach((e=>e.remove()))):n=e,n&&!n.isSameNode(t)?(n.replaceWith(...Array.isArray(t)?t:[t]),t):n||t};const textUpdater=(e,t,n)=>{const o=resolveValue(t,n);if(o instanceof Element)e=updateLiveNode([e,o]);else if(Array.isArray(o))e=handleArrayValue([e,o],n);else{const t=getNewTextValue(o);e=updateLiveNode([e,t])}return e},getNewTextValue=e=>e instanceof Text?e:document.createTextNode(String(e)),handleArrayValue=([e,t],n)=>{const o=Array.isArray(e),r=o?e[0]?.parentElement:e?.parentElement;let a;return t.length||t.push(document.createTextNode("")),a=t.map(((t,a)=>{const i="function"==typeof(c=t)&&"contextFunction"===c.name?c({},!0):{};var c;const s=appendChildContext(n,t,i.key||a),d=resolveValue(t,s),l=d instanceof HTMLElement||d instanceof SVGElement,u=l||d instanceof Comment?d:getNewTextValue(d);if(o){if(l&&!e[a]?.isSameNode(u)||!l){const t=e[a];e.includes(u)&&e.splice(e.indexOf(u),1),e.splice(a,0,u),t&&!u.contains(t)?r?.insertBefore(u,t):r?.appendChild(u)}}else e?.isSameNode(u)||r?.insertBefore(u,e);return u})),o?e.slice(t.length).forEach((e=>e.remove())):e?.remove(),a},activity=(e,t,n={})=>{const o=new Map,r="function"==typeof t,a=r?t:isObject(t)?t?.transform:void 0,{deep:i=!1,force:c=!1}=r?n:t||{};let s=c;const resolveCurrentValue=e=>isObject(e)&&"Object"===e.constructor.name?Object.assign({},e):e;let d=resolveCurrentValue(e);const l=reactive({value:d},((e,t)=>{let n=!1;return n=!!s||(i&&isObject(e)&&isObject(t)?((e,t)=>Object.entries(e).some((([e,n])=>n!==t[e])))(e,t):e!==t),d=n?resolveCurrentValue(t):e,n})),update=e=>{l.value=e},value=()=>resolveCurrentValue(d);try{isObject(e)&&Object.freeze(e)}catch(e){}return{effect:e=>function activityContextFunction(t={}){const renderEffect=()=>{const e=o.get(t),n=e&&e({value:l.value});t.root=textUpdater(t.root,n,"function"==typeof n&&"activityContextFunction"===n.name?appendChildContext(t,n,0):t)};return t.ctxScopes=t.ctxScopes||new Map,t.root&&o.has(t)?(o.set(t,e),renderEffect()):(o.set(t,e),reactiveEffect(renderEffect,l)),t},initialValue:e,reset:()=>update(e),update(e,t=s){s=t,"function"==typeof a?a({input:e,update:update,value:value()}):update(e),s=c},value:value,watch(e){reactiveEffect((()=>e({value:l.value})),l)}}},mount=(e=document.body,t,n=null)=>{const doMount=t=>{const o=Array.isArray(t)?t:[t];switch(n){case null:e.replaceChildren(...o);break;case!1:e.prepend(...o);break;default:e.append(...o)}};if(t.hasOwnProperty("root")){const e=t;e.root&&doMount(e.root)}else doMount(t)},init=({app:e,append:t=null,globalConfig:n={},onAppMounted:o,root:r=document.body})=>{bootstrap(),configApp(n);const a=e();(null===r||r instanceof HTMLHeadElement||r instanceof HTMLBodyElement)&&((r=document.createElement("div")).id="loom-app",mount(void 0,r,!1)),mount(r,a,t),u.observe(r),"function"==typeof o&&o(r)},bootstrap=()=>{globalThis.loom={console:c}},configApp=({debug:e,debugScope:t,events:n,token:o})=>{void 0!==e&&setDebug(e,t),n&&appendEvents(n),o&&setToken(o)},getPaths=e=>{const getNewPath=t=>{const n=[];do{t.parentNode&&(n.unshift(Array.from(t.parentNode.childNodes).indexOf(t)),t=t.parentNode)}while(t!==e.root);return n},handleTreeNode=e=>{if(e instanceof HTMLElement||e instanceof SVGElement){const n=Array.from(e.attributes).filter((e=>i.tokenRe.test(e.value)));if(n.length){const o=getNewPath(e);n.forEach((e=>t.add([o,e])))}}else if((e instanceof Text||e instanceof Comment)&&i.tokenRe.test(e.textContent||"")){const n=getNewPath(e),o=e.textContent?.matchAll(i.tokenReGlobal);for(;o?.next().value;)t.add([n,void 0])}},t=new Set;for(;e.nextNode();)handleTreeNode(e.currentNode);return t},memo=(e,t=((...e)=>JSON.stringify(e)))=>{const n=new Map;return(...o)=>{const r=t(...o);if(!n.has(r)){const t=e((e=>()=>n.delete(e))(r),...o);return t&&n.set(r,t),t}return n.get(r)}},getSpecialAttrUpdate=(e,t)=>{let n;const o=t.nodeName.slice(1),r={};switch(!0){case"attrs"===o:n=f.attrs.bind(null,{attr:t,dynamicNode:e,nodeName:o});break;case"on"===o:n=f.on.bind(null,{attr:t,dynamicNode:e,listenerCtx:r,nodeName:o});break;case i.events.includes(o):r.eventListener=void 0,n=f.event.bind(null,{attr:t,dynamicNode:e,listenerCtx:r,nodeName:o});break;default:n=f.default.bind(null,{attr:t,dynamicNode:e,nodeName:o})}return e.hasAttribute(t.name)&&e.removeAttribute(t.name),n},getStandardAttrUpdate=(e,t)=>n=>{let o="$"===t.nodeName[0]?t.nodeName.slice(1):t.nodeName;const r=resolveValue(n),a=e;if(Boolean(r))switch(!0){case"type"===o&&"number"===r&&isNaN(a.value):a.value="",a.setAttribute(o,String(r));break;case"value"===o:a.value=String(r);break;case"style"===o&&Array.isArray(r):mergeAndSetStyleValues(a,r);break;case"style"===o&&isObject(r):Object.entries(r).forEach((([e,t])=>{(t||0===t)&&a.style.setProperty(e,String(t))}));break;default:a.setAttribute(o,String(r))}else a.removeAttribute(o)},mergeAndSetStyleValues=(e,t)=>{const handleStyleArg=t=>{"string"==typeof t?t.split(";").forEach((t=>{if(t){const[n,o]=t.split(":"),r=n?.trim(),a=o?.trim();a&&r&&e.style.setProperty(r,a)}})):"function"!=typeof t||["contextFunction","activityContextFunction"].includes(t.name)?isObject(t)&&Object.entries(t).forEach((([t,n])=>{(n||0===n)&&e.style.setProperty(t,String(n))})):handleStyleArg(t())};t.flat().forEach(handleStyleArg)},overrideEventListener=({attr:e,dynamicNode:t,listenerCtx:n,nodeName:o,override:r})=>{const a=t;"function"==typeof n?.eventListener&&a.removeEventListener(o,n?.eventListener,!1),"function"==typeof r&&n?(n.eventListener=r,a.addEventListener(o,n.eventListener,!1)):r&&canDebug("warn")&&c.warn(`[Template Update Warning] The provided special attribute ("${e.nodeName}") contains a value of ${JSON.stringify(r)} which may not be the intended value. While this is non-breaking, a valid value would be falsy or an event-listener.`)},f={attrs:({attr:e,dynamicNode:t,nodeName:n},o)=>{if(!o||!isObject(o))return void(o&&canDebug("warn")&&c.warn(`${e?.nodeName} must be an object literal.`));const r=t;Object.entries(o).forEach((([e,t])=>{const o=resolveValue(t);if(Boolean(o))switch(!0){case"className"===e&&"string"==typeof o:o&&r.setAttribute("class",o);break;case"style"===e&&Array.isArray(o):mergeAndSetStyleValues(r,o);break;case"style"===e&&isObject(o):Object.entries(o).forEach((([e,t])=>{(t||0===t)&&r.style.setProperty(e,String(t))}));break;default:r.setAttribute(e,String(o))}else r.removeAttribute(n)}))},default:({attr:e,dynamicNode:t},n)=>{getStandardAttrUpdate(t,e)(n)},event:({attr:e,dynamicNode:t,listenerCtx:n,nodeName:o},r)=>{overrideEventListener({attr:e,dynamicNode:t,listenerCtx:n,nodeName:o,override:r})},on:({attr:e,dynamicNode:t,listenerCtx:n},o)=>{o&&isObject(o)?Object.entries(o).forEach((([o,r])=>{const a=n;i.events.includes(o)&&(a[o]?.eventListener!==r&&(a[o]=a[o]||{eventListener:r}),overrideEventListener({attr:e,dynamicNode:t,listenerCtx:a[o],nodeName:o,override:r}))})):o&&canDebug("warn")&&c.warn(`${e?.nodeName} must be an object literal.`)}},setReactiveUpdates=(e,t,n)=>reactiveEffect((o=>{const r=o[t],a=appendChildContext(n,r,t);canDebug("updates")&&c.info("should update",{updateValue:r}),e(r,a)}),n.values),setUpdatesForPaths=(e,t,n)=>{const o=memo(((e,...t)=>((e,t)=>e.reduce(((e,t)=>e.childNodes[t]),t))(...t))),r=memo(((e,...t)=>((e,t)=>new Set((e?.textContent||"").split(i.TOKEN).reduce(((e,n,o,r)=>{if(n&&t.appendChild(document.createTextNode(n)),o<r.length-1){const n=document.createTextNode(i.TOKEN);e.push(t.appendChild(n))}return e}),[])).values())(...t)),((...[e])=>e));Array.from(e).map((([e,t])=>[o(e,n),t])).forEach((([e,n],o)=>{if(n){const r=((e,t)=>"$"===t.nodeName[0]?getSpecialAttrUpdate(e,t):getStandardAttrUpdate(e,t))(e,n);setReactiveUpdates(r,o,t)}else if(e instanceof Text||void 0===e){const n=document.createDocumentFragment(),a=r(e,n).next().value;if(a){const r=function getTextUpdate(e){let t=e;return(...e)=>t=textUpdater(t,...e)}(a);e?.replaceWith(n),setReactiveUpdates(r,o,t)}else console.warn("[Template Update Warning] The live node is undefined, therefore the update could not be created.")}}))},p=new Map,m=new WeakSet;function htmlParser(e,...t){const n=this,o=/^<>/.test(e[0]?.trim()??"");if(!p.has(e)){const t=document.createRange().createContextualFragment(e.join(i.TOKEN));o&&t.childNodes[0]&&(t.childNodes[0].textContent=t.childNodes[0].textContent?.replace("<>","")||null);const n=document.createTreeWalker(t,window.NodeFilter.SHOW_ALL);p.set(e,{fragment:t,paths:getPaths(n)})}if(n.chunks===e&&m.has(n)&&document.contains((Array.isArray(n.root)?n.root[0]?.parentElement:n.root)??null)){const e=canDebug("updates");u.preRender(n),e&&c.groupCollapsed(`loom (Updating${n.key?` \`${n.key}\``:""}...)`,getShareableContext(n)),t.forEach(((t,o)=>{e&&c.info({newValue:t,oldValue:n.values[o]}),n.values[o]=t})),e&&c.info("completed",getShareableContext(n)),e&&c.groupEnd()}else{const{fragment:r=document.createDocumentFragment(),paths:a=new Set}=p.get(e)||{},i=r.cloneNode(!0),c=t.reduce(((e,t,n)=>(e[n]=t,e)),{});n.chunks=e,n.values=reactive(c,((e,t)=>{const isContextFunction=e=>"function"==typeof e&&["contextFunction","activityContextFunction"].includes(e.name);switch(!0){case e instanceof Node&&t instanceof Node:return!e.isSameNode(t);case isContextFunction(e)&&isContextFunction(t):return!0;case isObject(e)&&isObject(t):return deepDiffObject(e,t);default:return e!==t}})),o?(n.fragment=!0,n.root=Array.from(i.childNodes)):n.root=i.children[0],u.creation(n),u.preRender(n),setUpdatesForPaths(a,n,i),m.add(n)}return u.postRender(n),n}const component=e=>(t={})=>function contextFunction(n={},o=!1){const r=n.ctxScopes?n.ctxScopes.get(e):null,a=r||(n.ctxScopes?{}:n);let i;if(!n.root||void 0===r){const r=t.ref;a.children=new Map,a.fragment=!1,a.fingerPrint=e,a.lifeCycles=(e=>{const t=reactive({value:null});return reactiveEffect((t=>lifeCycleStateUpdateEffect(e,t)),t),e.lifeCycleState=t,{onBeforeRender(t){!e.beforeRender&&createLifeCycleHook("beforeRender",{ctx:e,handler:t})},onCreated(t){!e.created&&createLifeCycleHook("created",{ctx:e,handler:t})},onMounted(t){!e.mounted&&createLifeCycleHook("mounted",{ctx:e,handler:t})},onRendered(t){!e.rendered&&createLifeCycleHook("rendered",{ctx:e,handler:t})},onUnmounted(t){!e.unmounted&&createLifeCycleHook("unmounted",{ctx:e,handler:t})}}})(a),a.node=()=>a.root,a.refs=new Set,a.render=htmlParser.bind(a),r&&(a.ref=r,a.ref.node=a.node,a.beforeRender=a.ref.beforeRender,a.created=a.ref.created,a.mounted=a.ref.mounted,a.rendered=a.ref.rendered,a.unmounted=a.ref.unmounted,!o&&delete t.ref),n.ctxScopes&&(a.parent=n,n.ctxScopes.set(e,a))}return a.key=t.key,a.props={...t,children:Array.isArray(t.children)?t.children.flat():t.children},o?a:(i=a.refs.values(),e(a.render,{...a.props,...a.lifeCycles,createRef:memoizedRefContext(a,i),ctxRefs:()=>a.refs.values(),node:a.node}))},h=new Map,lazyImport=(e,t)=>{const n=h;if(n.has(e))return n.get(e);const o=activity(void 0,(async({input:e,update:t})=>{t(await e())}));return n.set(e,o),o.update(t),o};const didRouteChange$1=({origin:e,pathname:t,search:n})=>e!==window.location.origin||t!==window.location.pathname||n!==window.location.search,y=new class Router{fallback=()=>Promise.resolve(void 0);matchedRoute;params={};pathImporter;pathname;pathSegmentRx="(?:\\/(\\w+[\\w|-]*))";routeActivity;routesConfig;constructor(){this.routeActivity=activity(this.getRouteValue(window.location),{transform:({input:e,update:t})=>this.transform(e,t)})}createRoutes({config:e={},fallback:t=(()=>Promise.resolve(void 0))}){return this.routesConfig=e,this.fallback=t,this.routeActivity.update(window.location),window.addEventListener("popstate",(()=>this.routeActivity.update(window.location))),e=>this.pageRouteEffect(e)}routeEffect(e){const{effect:t}=this.routeActivity;return t(e)}redirect(e){this.route(null,{href:e,replace:!0})}route(e,t){if(e?.ctrlKey||e?.metaKey)return;const n=t?.replace?"replaceState":"pushState",o=t?.href||(e?.currentTarget).href,r=Object.assign({},window.location);e?.preventDefault(),window.history[n]({},"route",o),didRouteChange$1(r)&&this.routeActivity.update(window.location)}watchRoute(e){const{watch:t}=this.routeActivity;t(e)}getRouteValue(e){return{raw:e,matchedRoute:this.matchedRoute,params:this.params,pathname:this.pathname}}pageRouteEffect(e){const{effect:t,update:n}=lazyImport("page-route",this.fallback);let o;return this.watchRoute((({value:t})=>{if(o===this.matchedRoute)return;o=this.matchedRoute;n((async()=>{const{default:n}=await this.pathImporter();return n({...e,routeProps:t})}))})),t((({value:e})=>e))}parseParams(e,t){const n=e.match(/\/:(\w+)\/?/);n&&n.slice(1).forEach(((e,n)=>{this.params[e]=t[n]||""}))}transform(e,t){if(!this.routesConfig)return;const{pathname:n}=sanitizeLocation(e);let o=[],[r,a]=Object.entries(this.routesConfig).find((([e])=>{const t=e.replace(/\/:\w+\/?/,`${this.pathSegmentRx}?`),r=n.match(new RegExp(`^${t}$`));return!!r&&(o=r.slice(1),!0)}))||[];r&&this.validateRoute(n,a)&&(this.matchedRoute=r,this.pathImporter=a,this.pathname=n,this.parseParams(r,o),t(this.getRouteValue(e)))}validateRoute(e,t){if(!t){const t=this.routesConfig?.["/"];if(t)return console.warn(`No path found for ${e}. Falling back to '/'.`),this.redirect("/"),!1;throw new Error(`No path found for ${e}`)}return!0}},createRoutes=e=>y.createRoutes(e),routeEffect=e=>y.routeEffect(e),redirect=e=>y.redirect(e),route=(...e)=>y.route(...e),watchRoute=e=>y.watchRoute(e),sanitizeLocation=({pathname:e,...t})=>({...t,pathname:e.length>1&&"/"===e[e.length-1]?e.slice(0,e.length-1):e}),v=activity(window.location,{force:!0}),{update:g,watch:w}=v;window.addEventListener("popstate",(()=>g(window.location)));const b=w,router=e=>{const{effect:t}=v;return t(e)},onRoute=(e,t)=>{const n=t?.replace?"replaceState":"pushState",o=t?.href||(e?.currentTarget).href,r=Object.assign({},window.location);e?.preventDefault(),window.history[n]({},"onRoute",o),didRouteChange(r)&&g(window.location)},didRouteChange=({origin:e,pathname:t,search:n})=>e!==window.location.origin||t!==window.location.pathname||n!==window.location.search;export{activity,appendEvents,canDebug,component,i as config,createRoutes,init,lazyImport,onRoute,b as onRouteUpdate,redirect,route,routeEffect,router,sanitizeLocation,setDebug,setToken,watchRoute}; //# sourceMappingURL=index.mjs.map