@wsxjs/wsx-router 0.0.21 → 0.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.js +164 -157
- package/package.json +5 -5
- package/src/WsxLink.wsx +2 -0
- package/src/WsxRouter.wsx +3 -0
- package/src/WsxView.wsx +2 -0
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const N=require("@wsxjs/wsx-core");var _e=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Se(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var ge={exports:{}};(function(n){(function(e,t){n.exports?n.exports=t():e.log=t()})(_e,function(){var e=function(){},t="undefined",r=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),g=["trace","debug","info","warn","error"],v={},f=null;function _(o,c){var i=o[c];if(typeof i.bind=="function")return i.bind(o);try{return Function.prototype.bind.call(i,o)}catch{return function(){return Function.prototype.apply.apply(i,[o,arguments])}}}function y(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function T(o){return o==="debug"&&(o="log"),typeof console===t?!1:o==="trace"&&r?y:console[o]!==void 0?_(console,o):console.log!==void 0?_(console,"log"):e}function j(){for(var o=this.getLevel(),c=0;c<g.length;c++){var i=g[c];this[i]=c<o?e:this.methodFactory(i,o,this.name)}if(this.log=this.debug,typeof console===t&&o<this.levels.SILENT)return"No console available for logging"}function V(o){return function(){typeof console!==t&&(j.call(this),this[o].apply(this,arguments))}}function P(o,c,i){return T(o)||V.apply(this,arguments)}function B(o,c){var i=this,u,A,k,R="loglevel";typeof o=="string"?R+=":"+o:typeof o=="symbol"&&(R=void 0);function D(h){var l=(g[h]||"silent").toUpperCase();if(!(typeof window===t||!R)){try{window.localStorage[R]=l;return}catch{}try{window.document.cookie=encodeURIComponent(R)+"="+l+";"}catch{}}}function E(){var h;if(!(typeof window===t||!R)){try{h=window.localStorage[R]}catch{}if(typeof h===t)try{var l=window.document.cookie,x=encodeURIComponent(R),C=l.indexOf(x+"=");C!==-1&&(h=/^([^;]+)/.exec(l.slice(C+x.length+1))[1])}catch{}return i.levels[h]===void 0&&(h=void 0),h}}function L(){if(!(typeof window===t||!R)){try{window.localStorage.removeItem(R)}catch{}try{window.document.cookie=encodeURIComponent(R)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function p(h){var l=h;if(typeof l=="string"&&i.levels[l.toUpperCase()]!==void 0&&(l=i.levels[l.toUpperCase()]),typeof l=="number"&&l>=0&&l<=i.levels.SILENT)return l;throw new TypeError("log.setLevel() called with invalid level: "+h)}i.name=o,i.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},i.methodFactory=c||P,i.getLevel=function(){return k??A??u},i.setLevel=function(h,l){return k=p(h),l!==!1&&D(k),j.call(i)},i.setDefaultLevel=function(h){A=p(h),E()||i.setLevel(h,!1)},i.resetLevel=function(){k=null,L(),j.call(i)},i.enableAll=function(h){i.setLevel(i.levels.TRACE,h)},i.disableAll=function(h){i.setLevel(i.levels.SILENT,h)},i.rebuild=function(){if(f!==i&&(u=p(f.getLevel())),j.call(i),f===i)for(var h in v)v[h].rebuild()},u=p(f?f.getLevel():"WARN");var m=E();m!=null&&(k=p(m)),j.call(i)}f=new B,f.getLogger=function(c){if(typeof c!="symbol"&&typeof c!="string"||c==="")throw new TypeError("You must supply a name when creating a logger.");var i=v[c];return i||(i=v[c]=new B(c,f.methodFactory)),i};var s=typeof window!==t?window.log:void 0;return f.noConflict=function(){return typeof window!==t&&window.log===f&&(window.log=s),f},f.getLoggers=function(){return v},f.default=f,f})})(ge);var Ie=ge.exports;const ke=Se(Ie),pe={trace:"trace",debug:"debug",info:"info",warn:"warn",error:"error",silent:"silent"},We={0:"trace",1:"debug",2:"info",3:"warn",4:"error",5:"silent"};function se(){var n,e;if(typeof process<"u")return process.env.NODE_ENV==="production"||process.env.MODE==="production";try{const t=globalThis;if((e=(n=t.import)==null?void 0:n.meta)!=null&&e.env){const r=t.import.meta.env;return r.MODE==="production"||r.PROD===!0}}catch{}return!1}const te={name:"WSX",level:se()?"info":"debug",pretty:!se()};function Ae(n={}){const{name:e,level:t}={...te,...n},r=e||te.name,g=ke.getLogger(r),v=t||te.level;return g.setLevel(pe[v]),g}function Y(n,e){return n?`[${n}] ${e}`:e}class ve{constructor(e={}){this.isProd=se(),this.name=e.name||te.name,this.currentLevel=e.level||te.level,this.logInstance=Ae(e)}debug(e,...t){if(!this.isProd||this.shouldLog("debug")){const r=Y(this.name,e);t.length>0?this.logInstance.debug(r,...t):this.logInstance.debug(r)}}info(e,...t){if(this.shouldLog("info")){const r=Y(this.name,e);t.length>0?this.logInstance.info(r,...t):this.logInstance.info(r)}}warn(e,...t){const r=Y(this.name,e);t.length>0?this.logInstance.warn(r,...t):this.logInstance.warn(r)}error(e,...t){const r=Y(this.name,e);t.length>0?this.logInstance.error(r,...t):this.logInstance.error(r)}fatal(e,...t){const r=Y(this.name,e);t.length>0?this.logInstance.error(`[FATAL] ${r}`,...t):this.logInstance.error(`[FATAL] ${r}`)}trace(e,...t){if(!this.isProd||this.shouldLog("trace")){const r=Y(this.name,e);t.length>0?this.logInstance.trace(r,...t):this.logInstance.trace(r)}}shouldLog(e){const t=["trace","debug","info","warn","error","silent"],r=t.indexOf(this.currentLevel);return t.indexOf(e)>=r}getLoglevelLogger(){return this.logInstance}setLevel(e){this.currentLevel=e,this.logInstance.setLevel(pe[e])}getLevel(){const e=this.logInstance.getLevel();return We[e]||this.currentLevel}}new ve;function re(n,e={}){return new ve({...e,name:e.name||`WSX:${n}`})}const Te=re("RouterUtils"),Z=class Z{static _setCurrentRoute(e){Z._currentRoute=e}static navigate(e,t=!1){t?window.history.replaceState(null,"",e):window.history.pushState(null,"",e),window.dispatchEvent(new PopStateEvent("popstate")),Te.debug(`Navigated to: ${e} (replace: ${t})`)}static getCurrentRoute(){if(Z._currentRoute)return Z._currentRoute;const e=new URL(window.location.href);return{path:e.pathname,params:{},query:Object.fromEntries(e.searchParams.entries()),hash:e.hash.slice(1)}}static parseRoute(e,t){var r;if(e===t)return{route:e,params:{},exact:!0};if(e==="*")return{route:e,params:{},exact:!1};if(e.includes(":")){const g=((r=e.match(/:([^/]+)/g))==null?void 0:r.map(y=>y.slice(1)))||[],v=e.replace(/:[^/]+/g,"([^/]+)"),f=new RegExp(`^${v}$`),_=t.match(f);if(_&&g.length>0){const y={};return g.forEach((T,j)=>{y[T]=_[j+1]}),{route:e,params:y,exact:!0}}}if(e.endsWith("/*")){const g=e.slice(0,-2);if(t.startsWith(g))return{route:e,params:{},exact:!1}}return null}static buildPath(e,t={}){let r=e;return Object.entries(t).forEach(([g,v])=>{r=r.replace(`:${g}`,encodeURIComponent(v))}),r}static isRouteActive(e,t=!1){const r=window.location.pathname;return t?r===e:e==="/"?r==="/":r.startsWith(e)}static getRouteDepth(e){return e.split("/").filter(t=>t.length>0).length}static getParentRoute(e){const t=e.split("/").filter(r=>r.length>0);return t.length<=1?"/":(t.pop(),"/"+t.join("/"))}static joinPaths(...e){return e.map(t=>t.replace(/^\/+|\/+$/g,"")).filter(t=>t.length>0).join("/").replace(/^/,"/")}static isExternalUrl(e){return/^https?:\/\//.test(e)||/^mailto:/.test(e)||/^tel:/.test(e)}static getQueryParam(e){return new URL(window.location.href).searchParams.get(e)}static setQueryParam(e,t,r=!1){const g=new URL(window.location.href);g.searchParams.set(e,t);const v=g.pathname+g.search+g.hash;this.navigate(v,r)}static removeQueryParam(e,t=!1){const r=new URL(window.location.href);r.searchParams.delete(e);const g=r.pathname+r.search+r.hash;this.navigate(g,t)}static goBack(){window.history.back()}static goForward(){window.history.forward()}static replace(e){this.navigate(e,!0)}static getHistoryLength(){return window.history.length}static onRouteChange(e){const t=()=>{const r=this.getCurrentRoute();e(r)};return document.addEventListener("route-changed",t),()=>{document.removeEventListener("route-changed",t)}}};Z._currentRoute=null;let ne=Z;const ae=":host{display:grid;width:100%}.router-outlet{width:100%}:host>wsx-view{grid-area:1 / 1}";var me;let be,ye;function q(n,e,t){return(e=we(e))in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function je(n,e,t,r,g,v){function f(s,o,c){return function(i,u){return c&&c(i),s[o].call(i,u)}}function _(s,o){for(var c=0;c<s.length;c++)s[c].call(o);return o}function y(s,o,c,i){if(typeof s!="function"&&(i||s!==void 0))throw new TypeError(o+" must "+(c||"be")+" a function"+(i?"":" or undefined"));return s}function T(s,o,c,i,u,A,k,R,D,E,L,p,m){function h(d){if(!m(d))throw new TypeError("Attempted to access private element on non-instance")}var l,x=o[0],C=o[3],W=!R;if(!W){c||Array.isArray(x)||(x=[x]);var a={},S=[],w=u===3?"get":u===4||p?"set":"value";E?(L||p?a={get:ce(function(){return C(this)},i,"get"),set:function(d){o[4](this,d)}}:a[w]=C,L||ce(a[w],i,u===2?"":w)):L||(a=Object.getOwnPropertyDescriptor(s,i))}for(var b=s,U=x.length-1;U>=0;U-=c?2:1){var G=x[U],K=c?x[U-1]:void 0,J={},O={kind:["field","accessor","method","getter","setter","class"][u],name:i,metadata:A,addInitializer:(function(d,I){if(d.v)throw Error("attempted to call addInitializer after decoration was finished");y(I,"An initializer","be",!0),k.push(I)}).bind(null,J)};try{if(W)(l=y(G.call(K,b,O),"class decorators","return"))&&(b=l);else{var M,z;O.static=D,O.private=E,E?u===2?M=function(d){return h(d),a.value}:(u<4&&(M=f(a,"get",h)),u!==3&&(z=f(a,"set",h))):(M=function(d){return d[i]},(u<2||u===4)&&(z=function(d,I){d[i]=I}));var Q=O.access={has:E?m.bind():function(d){return i in d}};if(M&&(Q.get=M),z&&(Q.set=z),b=G.call(K,p?{get:a.get,set:a.set}:a[w],O),p){if(typeof b=="object"&&b)(l=y(b.get,"accessor.get"))&&(a.get=l),(l=y(b.set,"accessor.set"))&&(a.set=l),(l=y(b.init,"accessor.init"))&&S.push(l);else if(b!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0")}else y(b,(L?"field":"method")+" decorators","return")&&(L?S.push(b):a[w]=b)}}finally{J.v=!0}}return(L||p)&&R.push(function(d,I){for(var F=S.length-1;F>=0;F--)I=S[F].call(d,I);return I}),L||W||(E?p?R.push(f(a,"get"),f(a,"set")):R.push(u===2?a[w]:f.call.bind(a[w])):Object.defineProperty(s,i,a)),b}function j(s,o){return Object.defineProperty(s,Symbol.metadata||Symbol.for("Symbol.metadata"),{configurable:!0,enumerable:!0,value:o})}if(arguments.length>=6)var V=v[Symbol.metadata||Symbol.for("Symbol.metadata")];var P=Object.create(V??null),B=function(s,o,c,i){var u,A,k=[],R=function(w){return Me(w)===s},D=new Map;function E(w){w&&k.push(_.bind(null,w))}for(var L=0;L<o.length;L++){var p=o[L];if(Array.isArray(p)){var m=p[1],h=p[2],l=p.length>3,x=16&m,C=!!(8&m),W=(m&=7)==0,a=h+"/"+C;if(!W&&!l){var S=D.get(a);if(S===!0||S===3&&m!==4||S===4&&m!==3)throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: "+h);D.set(a,!(m>2)||m)}T(C?s:s.prototype,p,x,l?"#"+h:we(h),m,i,C?A=A||[]:u=u||[],k,C,l,W,m===1,C&&l?R:c)}}return E(u),E(A),k}(n,e,g,P);return t.length||j(n,P),{e:B,get c(){var s=[];return t.length&&[j(T(n,[t],r,n.name,5,P,s),P),_.bind(null,s,n)]}}}function we(n){var e=Oe(n,"string");return typeof e=="symbol"?e:e+""}function Oe(n,e){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}function ce(n,e,t){typeof e=="symbol"&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(n,"name",{configurable:!0,value:t?t+" "+e:e})}catch{}return n}function Me(n){if(Object(n)!==n)throw TypeError("right-hand side of 'in' should be an object, got "+(n!==null?typeof n:"null"));return n}const $=re("WsxRouter");ye=[N.autoRegister({tagName:"wsx-router"})];exports.WsxRouter=void 0;class Pe extends N.LightComponent{constructor(){super({styles:ae,styleName:"wsx-router"}),q(this,"_autoStyles",ae),q(this,"views",new Map),q(this,"currentView",null),q(this,"currentPath",""),q(this,"isHandlingRoute",!1),q(this,"compiledRoutes",new Map),q(this,"matchCache",new Map),q(this,"enableViewTransitions",!0),q(this,"scrollRestoration","manual"),q(this,"handleRouteChange",()=>{if(this.isHandlingRoute){$.debug("Route change already in progress, skipping");return}this.views.size===0&&(this.collectViews(),$.debug(`WsxRouter re-collected views: ${this.views.size}`)),this.isHandlingRoute=!0;try{const e=window.location.pathname;$.debug(`WsxRouter: Route changed to: ${e}`);const t=new CustomEvent("before-navigate",{detail:{to:e,from:this.currentPath},bubbles:!0,cancelable:!0});if(!this.dispatchEvent(t)){$.debug(`Navigation to ${e} was cancelled`);return}this.performNavigation(e)}finally{requestAnimationFrame(()=>{this.isHandlingRoute=!1})}}),q(this,"interceptLinks",e=>{const t=e.target.closest("a");if(!t)return;const r=t.getAttribute("href");!r||r.startsWith("http")||r.startsWith("#")||(e.preventDefault(),this.navigate(r))})}render(){return N.jsx("div",{class:"router-outlet"})}onRendered(){this.views.size===0&&(this.collectViews(),$.debug("WsxRouter collected views in onRendered:",this.views.size)),this.views.size>0&&!this.currentView&&requestAnimationFrame(()=>{this.handleRouteChange()})}onConnected(){$.debug("WsxRouter connected to DOM"),"scrollRestoration"in history&&(history.scrollRestoration=this.scrollRestoration),window.addEventListener("popstate",this.handleRouteChange),this.addEventListener("click",this.interceptLinks),requestAnimationFrame(()=>{this.views.size===0&&(this.collectViews(),$.debug(`WsxRouter collected views in onConnected: ${this.views.size}`)),requestAnimationFrame(()=>{$.debug(`WsxRouter handling initial route: ${window.location.pathname}`),this.handleRouteChange()})})}onDisconnected(){window.removeEventListener("popstate",this.handleRouteChange)}collectViews(){const e=Array.from(this.children).filter(t=>t.tagName.toLowerCase()==="wsx-view");$.debug(`WsxRouter found ${e.length} views`),this.views.clear(),this.compiledRoutes.clear(),this.matchCache.clear(),e.forEach(t=>{const r=t.getAttribute("route")||"/";if(this.views.set(r,t),$.debug(`WsxRouter registered route: ${r}`),r.includes(":")){const g=r.replace(/:[^/]+/g,"([^/]+)"),v=new RegExp(`^${g}$`);this.compiledRoutes.set(r,v),$.debug(`WsxRouter compiled regex for route: ${r} -> ${v}`)}t.style.display="none"})}performNavigation(e){const t=()=>{const r=this.matchRoute(e);if(r){r.style.display="block",r.style.visibility="visible";const g=r.getAttribute("route")||"/";$.debug(`Showing view for route: ${g}`);for(const[j,V]of this.views)V!==r&&(V.style.display="none",V.style.visibility="");this.currentView=r;const v=this.extractParams(g,e);$.debug(`Extracted params for route ${g} and path ${e}:`,v),v&&requestAnimationFrame(()=>{r.setAttribute("params",JSON.stringify(v)),$.debug(`Set params attribute on view: ${JSON.stringify(v)}`)});const f=window.location.href||`${window.location.pathname}${window.location.search}${window.location.hash}`,_=new URL(f,window.location.origin||"http://localhost"),y={path:e,params:v||{},query:Object.fromEntries(_.searchParams.entries()),hash:_.hash.slice(1)};ne._setCurrentRoute(y),$.debug("Updated RouterUtils._currentRoute:",y);const T=new CustomEvent("route-changed",{detail:y,bubbles:!0});document.dispatchEvent(T)}else{for(const[y,T]of this.views)T.style.display="none";this.currentView=null,$.warn(`No view found for path: ${e}`);const g=window.location.href||`${window.location.pathname}${window.location.search}${window.location.hash}`,v=new URL(g,window.location.origin||"http://localhost"),f={path:e,params:{},query:Object.fromEntries(v.searchParams.entries()),hash:v.hash.slice(1)};ne._setCurrentRoute(f);const _=new CustomEvent("route-changed",{detail:f,bubbles:!0});document.dispatchEvent(_)}this.handleScrollRestoration(e),this.dispatchEvent(new CustomEvent("after-navigate",{detail:{to:e,from:this.currentPath},bubbles:!0})),this.currentPath=e};this.enableViewTransitions&&"startViewTransition"in document?document.startViewTransition(t):t()}handleScrollRestoration(e){this.scrollRestoration==="manual"&&(this.isBackNavigation()||(window.scrollTo(0,0),$.debug("Scrolled to top for forward navigation")))}isBackNavigation(){var e;return"navigation"in performance&&performance.navigation?performance.navigation.type===2:((e=window.history.state)==null?void 0:e.navigationType)==="back"}matchRoute(e){if($.warn(`matchRoute called for path: ${e}, views count: ${this.views.size}`),this.matchCache.has(e)){const r=this.matchCache.get(e);return $.warn(`matchRoute: found in cache, route: ${r}`),this.views.get(r)||null}if(this.views.has(e))return this.matchCache.set(e,e),$.warn(`matchRoute: exact match found for ${e}`),this.views.get(e);$.warn(`matchRoute: checking parameter routes, compiledRoutes count: ${this.compiledRoutes.size}`);for(const[r,g]of this.views)if(r.includes(":")){const v=this.compiledRoutes.get(r);if(v){const f=v.test(e);if($.warn(`matchRoute: testing route ${r} against ${e}, matches: ${f}`),f)return this.matchCache.set(e,r),$.warn(`matchRoute: parameter match found, route: ${r}, path: ${e}`),g}else $.warn(`matchRoute: route ${r} has ':' but no compiled regex found`)}const t=this.views.get("*")||null;return t?(this.matchCache.set(e,"*"),$.warn(`matchRoute: wildcard match found for ${e}`)):$.warn(`matchRoute: no match found for ${e}, no wildcard view available`),t}extractParams(e,t){var y;if(!e.includes(":"))return null;const r=((y=e.match(/:([^/]+)/g))==null?void 0:y.map(T=>T.slice(1)))||[],g=e.replace(/:[^/]+/g,"([^/]+)"),v=new RegExp(`^${g}$`),f=t.match(v);if(!f||!r.length)return null;const _={};return r.forEach((T,j)=>{_[T]=f[j+1]}),_}clearMatchCache(){this.matchCache.clear(),$.debug("WsxRouter cleared match cache")}setViewTransitions(e){this.enableViewTransitions=e,$.debug(`View Transitions ${e?"enabled":"disabled"}`)}setScrollRestoration(e){this.scrollRestoration=e,"scrollRestoration"in history&&(history.scrollRestoration=e),$.debug(`Scroll Restoration set to ${e}`)}navigate(e){window.history.pushState(null,"",e),this.handleRouteChange()}}me=Pe;[exports.WsxRouter,be]=je(me,[],ye,0,void 0,N.LightComponent).c;be();const De=":host{display:block;width:100%;height:100%}.route-view{width:100%;height:100%;position:relative}:host([loading]) .route-view{opacity:.5;transition:opacity .3s ease}:host([error]) .route-view{border:1px solid var(--error-color, #ff0000);padding:1rem}.route-view.entering{animation:fadeIn .3s ease-out}.route-view.leaving{animation:fadeOut .3s ease-in}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}@keyframes fadeOut{0%{opacity:1}to{opacity:0}}";var Le;let Re,xe;function ee(n,e,t){return(e=Ee(e))in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function Ve(n,e,t,r,g,v){function f(s,o,c){return function(i,u){return c&&c(i),s[o].call(i,u)}}function _(s,o){for(var c=0;c<s.length;c++)s[c].call(o);return o}function y(s,o,c,i){if(typeof s!="function"&&(i||s!==void 0))throw new TypeError(o+" must "+(c||"be")+" a function"+(i?"":" or undefined"));return s}function T(s,o,c,i,u,A,k,R,D,E,L,p,m){function h(d){if(!m(d))throw new TypeError("Attempted to access private element on non-instance")}var l,x=o[0],C=o[3],W=!R;if(!W){c||Array.isArray(x)||(x=[x]);var a={},S=[],w=u===3?"get":u===4||p?"set":"value";E?(L||p?a={get:le(function(){return C(this)},i,"get"),set:function(d){o[4](this,d)}}:a[w]=C,L||le(a[w],i,u===2?"":w)):L||(a=Object.getOwnPropertyDescriptor(s,i))}for(var b=s,U=x.length-1;U>=0;U-=c?2:1){var G=x[U],K=c?x[U-1]:void 0,J={},O={kind:["field","accessor","method","getter","setter","class"][u],name:i,metadata:A,addInitializer:(function(d,I){if(d.v)throw Error("attempted to call addInitializer after decoration was finished");y(I,"An initializer","be",!0),k.push(I)}).bind(null,J)};try{if(W)(l=y(G.call(K,b,O),"class decorators","return"))&&(b=l);else{var M,z;O.static=D,O.private=E,E?u===2?M=function(d){return h(d),a.value}:(u<4&&(M=f(a,"get",h)),u!==3&&(z=f(a,"set",h))):(M=function(d){return d[i]},(u<2||u===4)&&(z=function(d,I){d[i]=I}));var Q=O.access={has:E?m.bind():function(d){return i in d}};if(M&&(Q.get=M),z&&(Q.set=z),b=G.call(K,p?{get:a.get,set:a.set}:a[w],O),p){if(typeof b=="object"&&b)(l=y(b.get,"accessor.get"))&&(a.get=l),(l=y(b.set,"accessor.set"))&&(a.set=l),(l=y(b.init,"accessor.init"))&&S.push(l);else if(b!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0")}else y(b,(L?"field":"method")+" decorators","return")&&(L?S.push(b):a[w]=b)}}finally{J.v=!0}}return(L||p)&&R.push(function(d,I){for(var F=S.length-1;F>=0;F--)I=S[F].call(d,I);return I}),L||W||(E?p?R.push(f(a,"get"),f(a,"set")):R.push(u===2?a[w]:f.call.bind(a[w])):Object.defineProperty(s,i,a)),b}function j(s,o){return Object.defineProperty(s,Symbol.metadata||Symbol.for("Symbol.metadata"),{configurable:!0,enumerable:!0,value:o})}if(arguments.length>=6)var V=v[Symbol.metadata||Symbol.for("Symbol.metadata")];var P=Object.create(V??null),B=function(s,o,c,i){var u,A,k=[],R=function(w){return ze(w)===s},D=new Map;function E(w){w&&k.push(_.bind(null,w))}for(var L=0;L<o.length;L++){var p=o[L];if(Array.isArray(p)){var m=p[1],h=p[2],l=p.length>3,x=16&m,C=!!(8&m),W=(m&=7)==0,a=h+"/"+C;if(!W&&!l){var S=D.get(a);if(S===!0||S===3&&m!==4||S===4&&m!==3)throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: "+h);D.set(a,!(m>2)||m)}T(C?s:s.prototype,p,x,l?"#"+h:Ee(h),m,i,C?A=A||[]:u=u||[],k,C,l,W,m===1,C&&l?R:c)}}return E(u),E(A),k}(n,e,g,P);return t.length||j(n,P),{e:B,get c(){var s=[];return t.length&&[j(T(n,[t],r,n.name,5,P,s),P),_.bind(null,s,n)]}}}function Ee(n){var e=Ue(n,"string");return typeof e=="symbol"?e:e+""}function Ue(n,e){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}function le(n,e,t){typeof e=="symbol"&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(n,"name",{configurable:!0,value:t?t+" "+e:e})}catch{}return n}function ze(n){if(Object(n)!==n)throw TypeError("right-hand side of 'in' should be an object, got "+(n!==null?typeof n:"null"));return n}const H=re("WsxView");xe=[N.autoRegister({tagName:"wsx-view"})];exports.WsxView=void 0;class Ne extends N.LightComponent{constructor(){super(),ee(this,"_autoStyles",De),ee(this,"_component",""),ee(this,"params",void 0),ee(this,"componentInstance",null),ee(this,"isLoading",!1);let e=this.reactive({});Object.defineProperty(this,"params",{get:()=>e,set:t=>{e=t!==null&&typeof t<"u"&&(Array.isArray(t)||typeof t=="object")?this.reactive(t):t,this.scheduleRerender()},enumerable:!0,configurable:!0})}get component(){return this._component}set component(e){this._component=e||"",this._component&&requestAnimationFrame(()=>{this.connected&&!this.componentInstance&&!this.isLoading&&this.loadComponent(this._component||"")})}render(){return N.jsx("div",{class:"route-view"})}onConnected(){requestAnimationFrame(()=>{!this.connected||this.isLoading||this.componentInstance||this.component&&this.loadComponent(this.component)})}async loadComponent(e){if(!(!this.connected||this.isLoading||this.componentInstance)){this.isLoading=!0;try{const t=this.componentInstance;if(t&&(t.remove(),this.componentInstance=null),!customElements.get(e)){H.warn(`Component ${e} not found in customElements registry`),this.isLoading=!1;return}H.warn(`WsxView: Creating instance of ${e}`),this.componentInstance=document.createElement(e),Object.keys(this.params).length>0&&(H.warn(`WsxView: Setting initial params on ${e}:`,this.params),Object.entries(this.params).forEach(([v,f])=>{this.componentInstance.setAttribute(v,f)}));const g=this.querySelector(".route-view");if(g){if(H.warn(`WsxView: Appending ${e} to container`),!customElements.get(e)){H.error(`WsxView: Component ${e} is not registered in customElements registry!`),this.isLoading=!1,this.componentInstance=null;return}g.appendChild(this.componentInstance),H.warn(`WsxView: Component ${e} appended successfully, waiting for connectedCallback...`),setTimeout(()=>{this.componentInstance&&this.componentInstance.isConnected?H.warn(`WsxView: Component ${e} is now connected to DOM`):H.error(`WsxView: Component ${e} was not connected to DOM!`)},0)}else H.error("WsxView: Route view container not found"),this.componentInstance=null}catch(t){H.warn(`Error loading component ${e}:`,t),this.componentInstance=null}finally{this.isLoading=!1,H.warn(`WsxView: loadComponent for ${e} completed, isLoading=${this.isLoading}`)}}}onDisconnected(){this.componentInstance&&(this.componentInstance.remove(),this.componentInstance=null)}}Le=Ne;[exports.WsxView,Re]=Ve(Le,[],xe,0,void 0,N.LightComponent).c;Re();const Fe=':host{display:inline-block;min-width:fit-content;min-height:fit-content;width:auto;height:auto}.wsx-link{color:var(--link-color, #007bff);text-decoration:var(--link-decoration, underline);cursor:pointer;transition:color .2s ease;display:inline-block;min-height:1.2em;line-height:1.2}.wsx-link:hover{color:var(--link-hover-color, #0056b3);text-decoration:var(--link-hover-decoration, underline)}.wsx-link:focus{outline:2px solid var(--link-focus-color, var(--focus-color, #dc2626));outline-offset:2px}.wsx-link.active{color:var(--link-active-color, #6c757d);font-weight:var(--link-active-weight, bold)}:host([disabled]) .wsx-link{color:var(--link-disabled-color, #6c757d);cursor:not-allowed;pointer-events:none}:host([external]) .wsx-link:after{content:"↗";font-size:.8em;margin-left:.2em;opacity:.7}:host([variant="button"]) .wsx-link{background-color:var(--button-bg, #007bff);color:var(--button-color, white);padding:.5rem 1rem;border-radius:.25rem;text-decoration:none;display:inline-block}:host([variant="button"]) .wsx-link:hover{background-color:var(--button-hover-bg, #0056b3);color:var(--button-hover-color, white)}:host([variant="tab"]) .wsx-link{padding:.5rem 1rem;border-bottom:2px solid transparent;text-decoration:none}:host([variant="tab"]) .wsx-link.active{border-bottom-color:var(--tab-active-border, #007bff)}';var ie,oe;let ue,Ce,he;function X(n,e,t){return(e=$e(e))in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function qe(n,e,t,r,g,v){function f(s,o,c){return function(i,u){return c&&c(i),s[o].call(i,u)}}function _(s,o){for(var c=0;c<s.length;c++)s[c].call(o);return o}function y(s,o,c,i){if(typeof s!="function"&&(i||s!==void 0))throw new TypeError(o+" must "+(c||"be")+" a function"+(i?"":" or undefined"));return s}function T(s,o,c,i,u,A,k,R,D,E,L,p,m){function h(d){if(!m(d))throw new TypeError("Attempted to access private element on non-instance")}var l,x=o[0],C=o[3],W=!R;if(!W){c||Array.isArray(x)||(x=[x]);var a={},S=[],w=u===3?"get":u===4||p?"set":"value";E?(L||p?a={get:fe(function(){return C(this)},i,"get"),set:function(d){o[4](this,d)}}:a[w]=C,L||fe(a[w],i,u===2?"":w)):L||(a=Object.getOwnPropertyDescriptor(s,i))}for(var b=s,U=x.length-1;U>=0;U-=c?2:1){var G=x[U],K=c?x[U-1]:void 0,J={},O={kind:["field","accessor","method","getter","setter","class"][u],name:i,metadata:A,addInitializer:(function(d,I){if(d.v)throw Error("attempted to call addInitializer after decoration was finished");y(I,"An initializer","be",!0),k.push(I)}).bind(null,J)};try{if(W)(l=y(G.call(K,b,O),"class decorators","return"))&&(b=l);else{var M,z;O.static=D,O.private=E,E?u===2?M=function(d){return h(d),a.value}:(u<4&&(M=f(a,"get",h)),u!==3&&(z=f(a,"set",h))):(M=function(d){return d[i]},(u<2||u===4)&&(z=function(d,I){d[i]=I}));var Q=O.access={has:E?m.bind():function(d){return i in d}};if(M&&(Q.get=M),z&&(Q.set=z),b=G.call(K,p?{get:a.get,set:a.set}:a[w],O),p){if(typeof b=="object"&&b)(l=y(b.get,"accessor.get"))&&(a.get=l),(l=y(b.set,"accessor.set"))&&(a.set=l),(l=y(b.init,"accessor.init"))&&S.push(l);else if(b!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0")}else y(b,(L?"field":"method")+" decorators","return")&&(L?S.push(b):a[w]=b)}}finally{J.v=!0}}return(L||p)&&R.push(function(d,I){for(var F=S.length-1;F>=0;F--)I=S[F].call(d,I);return I}),L||W||(E?p?R.push(f(a,"get"),f(a,"set")):R.push(u===2?a[w]:f.call.bind(a[w])):Object.defineProperty(s,i,a)),b}function j(s,o){return Object.defineProperty(s,Symbol.metadata||Symbol.for("Symbol.metadata"),{configurable:!0,enumerable:!0,value:o})}if(arguments.length>=6)var V=v[Symbol.metadata||Symbol.for("Symbol.metadata")];var P=Object.create(V??null),B=function(s,o,c,i){var u,A,k=[],R=function(w){return Be(w)===s},D=new Map;function E(w){w&&k.push(_.bind(null,w))}for(var L=0;L<o.length;L++){var p=o[L];if(Array.isArray(p)){var m=p[1],h=p[2],l=p.length>3,x=16&m,C=!!(8&m),W=(m&=7)==0,a=h+"/"+C;if(!W&&!l){var S=D.get(a);if(S===!0||S===3&&m!==4||S===4&&m!==3)throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: "+h);D.set(a,!(m>2)||m)}T(C?s:s.prototype,p,x,l?"#"+h:$e(h),m,i,C?A=A||[]:u=u||[],k,C,l,W,m===1,C&&l?R:c)}}return E(u),E(A),k}(n,e,g,P);return t.length||j(n,P),{e:B,get c(){var s=[];return t.length&&[j(T(n,[t],r,n.name,5,P,s),P),_.bind(null,s,n)]}}}function $e(n){var e=He(n,"string");return typeof e=="symbol"?e:e+""}function He(n,e){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}function fe(n,e,t){typeof e=="symbol"&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(n,"name",{configurable:!0,value:t?t+" "+e:e})}catch{}return n}function Be(n){if(Object(n)!==n)throw TypeError("right-hand side of 'in' should be an object, got "+(n!==null?typeof n:"null"));return n}function Ge(n){return n}const de=re("WsxLink");Ce=[N.autoRegister({tagName:"wsx-link"})];exports.WsxLink=void 0;new(he=(oe=class extends N.WebComponent{constructor(){super(),X(this,"_autoStyles",Fe),X(this,"to",void 0),X(this,"activeClass",void 0),X(this,"handleClick",v=>{if(v.preventDefault(),!this.to){de.warn("No 'to' attribute specified");return}if(this.isExternalLink(this.to)){window.open(this.to,"_blank");return}this.replace?window.history.replaceState(null,"",this.to):window.history.pushState(null,"",this.to),window.dispatchEvent(new PopStateEvent("popstate")),de.debug(`Navigated to: ${this.to}`)}),X(this,"updateActiveState",()=>{var y;const v=window.location.pathname,f=this.exact?v===this.to:v.startsWith(this.to)&&this.to!=="/",_=(y=this.shadowRoot)==null?void 0:y.querySelector("a");_&&(f?(_.classList.add(this.activeClass),this.setAttribute("active","")):(_.classList.remove(this.activeClass),this.removeAttribute("active")))});const[e,t]=this.useState("to","");Object.defineProperty(this,"to",{get:e,set:t,enumerable:!0,configurable:!0});const[r,g]=this.useState("activeClass","active");Object.defineProperty(this,"activeClass",{get:r,set:g,enumerable:!0,configurable:!0})}get replace(){return this.hasAttribute("replace")}get exact(){return this.hasAttribute("exact")}render(){return N.jsx("a",{href:this.to,class:"wsx-link",onClick:this.handleClick,part:"link"},N.jsx("slot",null))}onConnected(){this.to=this.to||"",this.activeClass=this.activeClass||"active";const e=this.shadowRoot.querySelector(".wsx-link");e&&(e.href=this.to),window.addEventListener("popstate",this.updateActiveState),document.addEventListener("route-changed",this.updateActiveState),this.updateActiveState()}onDisconnected(){window.removeEventListener("popstate",this.updateActiveState),document.removeEventListener("route-changed",this.updateActiveState)}onAttributeChanged(e,t,r){switch(e){case"to":this.to=r||"",this.updateActiveState();break;case"replace":this.replace=r!==null&&r!=="false";break;case"active-class":this.activeClass=r||"active",this.updateActiveState();break;case"exact":this.exact=r!==null&&r!=="false",this.updateActiveState();break}}isExternalLink(e){return e.startsWith("http://")||e.startsWith("https://")||e.startsWith("mailto:")||e.startsWith("tel:")}navigate(){this.to&&this.handleClick(new MouseEvent("click",{bubbles:!0,cancelable:!0}))}},[exports.WsxLink,ue]=qe(oe,[],Ce,0,void 0,N.WebComponent).c,oe),ie=class extends Ge{constructor(){super(exports.WsxLink),X(this,"observedAttributes",["to","replace","active-class","exact"]),ue()}},X(ie,he,void 0),ie);exports.RouterUtils=ne;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const N=require("@wsxjs/wsx-core");var _e=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Se(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var ge={exports:{}};(function(n){(function(e,t){n.exports?n.exports=t():e.log=t()})(_e,function(){var e=function(){},t="undefined",r=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),g=["trace","debug","info","warn","error"],v={},d=null;function _(o,c){var i=o[c];if(typeof i.bind=="function")return i.bind(o);try{return Function.prototype.bind.call(i,o)}catch{return function(){return Function.prototype.apply.apply(i,[o,arguments])}}}function y(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function T(o){return o==="debug"&&(o="log"),typeof console===t?!1:o==="trace"&&r?y:console[o]!==void 0?_(console,o):console.log!==void 0?_(console,"log"):e}function j(){for(var o=this.getLevel(),c=0;c<g.length;c++){var i=g[c];this[i]=c<o?e:this.methodFactory(i,o,this.name)}if(this.log=this.debug,typeof console===t&&o<this.levels.SILENT)return"No console available for logging"}function V(o){return function(){typeof console!==t&&(j.call(this),this[o].apply(this,arguments))}}function D(o,c,i){return T(o)||V.apply(this,arguments)}function B(o,c){var i=this,u,A,k,R="loglevel";typeof o=="string"?R+=":"+o:typeof o=="symbol"&&(R=void 0);function P(h){var l=(g[h]||"silent").toUpperCase();if(!(typeof window===t||!R)){try{window.localStorage[R]=l;return}catch{}try{window.document.cookie=encodeURIComponent(R)+"="+l+";"}catch{}}}function C(){var h;if(!(typeof window===t||!R)){try{h=window.localStorage[R]}catch{}if(typeof h===t)try{var l=window.document.cookie,x=encodeURIComponent(R),E=l.indexOf(x+"=");E!==-1&&(h=/^([^;]+)/.exec(l.slice(E+x.length+1))[1])}catch{}return i.levels[h]===void 0&&(h=void 0),h}}function L(){if(!(typeof window===t||!R)){try{window.localStorage.removeItem(R)}catch{}try{window.document.cookie=encodeURIComponent(R)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function p(h){var l=h;if(typeof l=="string"&&i.levels[l.toUpperCase()]!==void 0&&(l=i.levels[l.toUpperCase()]),typeof l=="number"&&l>=0&&l<=i.levels.SILENT)return l;throw new TypeError("log.setLevel() called with invalid level: "+h)}i.name=o,i.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},i.methodFactory=c||D,i.getLevel=function(){return k??A??u},i.setLevel=function(h,l){return k=p(h),l!==!1&&P(k),j.call(i)},i.setDefaultLevel=function(h){A=p(h),C()||i.setLevel(h,!1)},i.resetLevel=function(){k=null,L(),j.call(i)},i.enableAll=function(h){i.setLevel(i.levels.TRACE,h)},i.disableAll=function(h){i.setLevel(i.levels.SILENT,h)},i.rebuild=function(){if(d!==i&&(u=p(d.getLevel())),j.call(i),d===i)for(var h in v)v[h].rebuild()},u=p(d?d.getLevel():"WARN");var m=C();m!=null&&(k=p(m)),j.call(i)}d=new B,d.getLogger=function(c){if(typeof c!="symbol"&&typeof c!="string"||c==="")throw new TypeError("You must supply a name when creating a logger.");var i=v[c];return i||(i=v[c]=new B(c,d.methodFactory)),i};var s=typeof window!==t?window.log:void 0;return d.noConflict=function(){return typeof window!==t&&window.log===d&&(window.log=s),d},d.getLoggers=function(){return v},d.default=d,d})})(ge);var Ie=ge.exports;const ke=Se(Ie),pe={trace:"trace",debug:"debug",info:"info",warn:"warn",error:"error",silent:"silent"},We={0:"trace",1:"debug",2:"info",3:"warn",4:"error",5:"silent"};function se(){var n,e;if(typeof process<"u")return process.env.NODE_ENV==="production"||process.env.MODE==="production";try{const t=globalThis;if((e=(n=t.import)==null?void 0:n.meta)!=null&&e.env){const r=t.import.meta.env;return r.MODE==="production"||r.PROD===!0}}catch{}return!1}const te={name:"WSX",level:se()?"info":"debug",pretty:!se()};function Ae(n={}){const{name:e,level:t}={...te,...n},r=e||te.name,g=ke.getLogger(r),v=t||te.level;return g.setLevel(pe[v]),g}function Y(n,e){return n?`[${n}] ${e}`:e}class ve{constructor(e={}){this.isProd=se(),this.name=e.name||te.name,this.currentLevel=e.level||te.level,this.logInstance=Ae(e)}debug(e,...t){if(!this.isProd||this.shouldLog("debug")){const r=Y(this.name,e);t.length>0?this.logInstance.debug(r,...t):this.logInstance.debug(r)}}info(e,...t){if(this.shouldLog("info")){const r=Y(this.name,e);t.length>0?this.logInstance.info(r,...t):this.logInstance.info(r)}}warn(e,...t){const r=Y(this.name,e);t.length>0?this.logInstance.warn(r,...t):this.logInstance.warn(r)}error(e,...t){const r=Y(this.name,e);t.length>0?this.logInstance.error(r,...t):this.logInstance.error(r)}fatal(e,...t){const r=Y(this.name,e);t.length>0?this.logInstance.error(`[FATAL] ${r}`,...t):this.logInstance.error(`[FATAL] ${r}`)}trace(e,...t){if(!this.isProd||this.shouldLog("trace")){const r=Y(this.name,e);t.length>0?this.logInstance.trace(r,...t):this.logInstance.trace(r)}}shouldLog(e){const t=["trace","debug","info","warn","error","silent"],r=t.indexOf(this.currentLevel);return t.indexOf(e)>=r}getLoglevelLogger(){return this.logInstance}setLevel(e){this.currentLevel=e,this.logInstance.setLevel(pe[e])}getLevel(){const e=this.logInstance.getLevel();return We[e]||this.currentLevel}}new ve;function re(n,e={}){return new ve({...e,name:e.name||`WSX:${n}`})}const Te=re("RouterUtils"),Z=class Z{static _setCurrentRoute(e){Z._currentRoute=e}static navigate(e,t=!1){t?window.history.replaceState(null,"",e):window.history.pushState(null,"",e),window.dispatchEvent(new PopStateEvent("popstate")),Te.debug(`Navigated to: ${e} (replace: ${t})`)}static getCurrentRoute(){if(Z._currentRoute)return Z._currentRoute;const e=new URL(window.location.href);return{path:e.pathname,params:{},query:Object.fromEntries(e.searchParams.entries()),hash:e.hash.slice(1)}}static parseRoute(e,t){var r;if(e===t)return{route:e,params:{},exact:!0};if(e==="*")return{route:e,params:{},exact:!1};if(e.includes(":")){const g=((r=e.match(/:([^/]+)/g))==null?void 0:r.map(y=>y.slice(1)))||[],v=e.replace(/:[^/]+/g,"([^/]+)"),d=new RegExp(`^${v}$`),_=t.match(d);if(_&&g.length>0){const y={};return g.forEach((T,j)=>{y[T]=_[j+1]}),{route:e,params:y,exact:!0}}}if(e.endsWith("/*")){const g=e.slice(0,-2);if(t.startsWith(g))return{route:e,params:{},exact:!1}}return null}static buildPath(e,t={}){let r=e;return Object.entries(t).forEach(([g,v])=>{r=r.replace(`:${g}`,encodeURIComponent(v))}),r}static isRouteActive(e,t=!1){const r=window.location.pathname;return t?r===e:e==="/"?r==="/":r.startsWith(e)}static getRouteDepth(e){return e.split("/").filter(t=>t.length>0).length}static getParentRoute(e){const t=e.split("/").filter(r=>r.length>0);return t.length<=1?"/":(t.pop(),"/"+t.join("/"))}static joinPaths(...e){return e.map(t=>t.replace(/^\/+|\/+$/g,"")).filter(t=>t.length>0).join("/").replace(/^/,"/")}static isExternalUrl(e){return/^https?:\/\//.test(e)||/^mailto:/.test(e)||/^tel:/.test(e)}static getQueryParam(e){return new URL(window.location.href).searchParams.get(e)}static setQueryParam(e,t,r=!1){const g=new URL(window.location.href);g.searchParams.set(e,t);const v=g.pathname+g.search+g.hash;this.navigate(v,r)}static removeQueryParam(e,t=!1){const r=new URL(window.location.href);r.searchParams.delete(e);const g=r.pathname+r.search+r.hash;this.navigate(g,t)}static goBack(){window.history.back()}static goForward(){window.history.forward()}static replace(e){this.navigate(e,!0)}static getHistoryLength(){return window.history.length}static onRouteChange(e){const t=()=>{const r=this.getCurrentRoute();e(r)};return document.addEventListener("route-changed",t),()=>{document.removeEventListener("route-changed",t)}}};Z._currentRoute=null;let ne=Z;const ae=":host{display:grid;width:100%}.router-outlet{width:100%}:host>wsx-view{grid-area:1 / 1}";var me;let be,ye;function q(n,e,t){return(e=we(e))in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function je(n,e,t,r,g,v){function d(s,o,c){return function(i,u){return c&&c(i),s[o].call(i,u)}}function _(s,o){for(var c=0;c<s.length;c++)s[c].call(o);return o}function y(s,o,c,i){if(typeof s!="function"&&(i||s!==void 0))throw new TypeError(o+" must "+(c||"be")+" a function"+(i?"":" or undefined"));return s}function T(s,o,c,i,u,A,k,R,P,C,L,p,m){function h(f){if(!m(f))throw new TypeError("Attempted to access private element on non-instance")}var l,x=o[0],E=o[3],W=!R;if(!W){c||Array.isArray(x)||(x=[x]);var a={},S=[],w=u===3?"get":u===4||p?"set":"value";C?(L||p?a={get:ce(function(){return E(this)},i,"get"),set:function(f){o[4](this,f)}}:a[w]=E,L||ce(a[w],i,u===2?"":w)):L||(a=Object.getOwnPropertyDescriptor(s,i))}for(var b=s,U=x.length-1;U>=0;U-=c?2:1){var G=x[U],K=c?x[U-1]:void 0,J={},O={kind:["field","accessor","method","getter","setter","class"][u],name:i,metadata:A,addInitializer:(function(f,I){if(f.v)throw Error("attempted to call addInitializer after decoration was finished");y(I,"An initializer","be",!0),k.push(I)}).bind(null,J)};try{if(W)(l=y(G.call(K,b,O),"class decorators","return"))&&(b=l);else{var M,z;O.static=P,O.private=C,C?u===2?M=function(f){return h(f),a.value}:(u<4&&(M=d(a,"get",h)),u!==3&&(z=d(a,"set",h))):(M=function(f){return f[i]},(u<2||u===4)&&(z=function(f,I){f[i]=I}));var Q=O.access={has:C?m.bind():function(f){return i in f}};if(M&&(Q.get=M),z&&(Q.set=z),b=G.call(K,p?{get:a.get,set:a.set}:a[w],O),p){if(typeof b=="object"&&b)(l=y(b.get,"accessor.get"))&&(a.get=l),(l=y(b.set,"accessor.set"))&&(a.set=l),(l=y(b.init,"accessor.init"))&&S.push(l);else if(b!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0")}else y(b,(L?"field":"method")+" decorators","return")&&(L?S.push(b):a[w]=b)}}finally{J.v=!0}}return(L||p)&&R.push(function(f,I){for(var F=S.length-1;F>=0;F--)I=S[F].call(f,I);return I}),L||W||(C?p?R.push(d(a,"get"),d(a,"set")):R.push(u===2?a[w]:d.call.bind(a[w])):Object.defineProperty(s,i,a)),b}function j(s,o){return Object.defineProperty(s,Symbol.metadata||Symbol.for("Symbol.metadata"),{configurable:!0,enumerable:!0,value:o})}if(arguments.length>=6)var V=v[Symbol.metadata||Symbol.for("Symbol.metadata")];var D=Object.create(V??null),B=function(s,o,c,i){var u,A,k=[],R=function(w){return Me(w)===s},P=new Map;function C(w){w&&k.push(_.bind(null,w))}for(var L=0;L<o.length;L++){var p=o[L];if(Array.isArray(p)){var m=p[1],h=p[2],l=p.length>3,x=16&m,E=!!(8&m),W=(m&=7)==0,a=h+"/"+E;if(!W&&!l){var S=P.get(a);if(S===!0||S===3&&m!==4||S===4&&m!==3)throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: "+h);P.set(a,!(m>2)||m)}T(E?s:s.prototype,p,x,l?"#"+h:we(h),m,i,E?A=A||[]:u=u||[],k,E,l,W,m===1,E&&l?R:c)}}return C(u),C(A),k}(n,e,g,D);return t.length||j(n,D),{e:B,get c(){var s=[];return t.length&&[j(T(n,[t],r,n.name,5,D,s),D),_.bind(null,s,n)]}}}function we(n){var e=Oe(n,"string");return typeof e=="symbol"?e:e+""}function Oe(n,e){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}function ce(n,e,t){typeof e=="symbol"&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(n,"name",{configurable:!0,value:t?t+" "+e:e})}catch{}return n}function Me(n){if(Object(n)!==n)throw TypeError("right-hand side of 'in' should be an object, got "+(n!==null?typeof n:"null"));return n}const $=re("WsxRouter");ye=[N.autoRegister({tagName:"wsx-router"})];exports.WsxRouter=void 0;class De extends N.LightComponent{constructor(){super({styles:ae,styleName:"wsx-router"}),q(this,"_autoStyles",ae),q(this,"views",new Map),q(this,"currentView",null),q(this,"currentPath",""),q(this,"isHandlingRoute",!1),q(this,"compiledRoutes",new Map),q(this,"matchCache",new Map),q(this,"enableViewTransitions",!0),q(this,"scrollRestoration","manual"),q(this,"handleRouteChange",()=>{if(this.isHandlingRoute){$.debug("Route change already in progress, skipping");return}this.views.size===0&&(this.collectViews(),$.debug(`WsxRouter re-collected views: ${this.views.size}`)),this.isHandlingRoute=!0;try{const e=window.location.pathname;$.debug(`WsxRouter: Route changed to: ${e}`);const t=new CustomEvent("before-navigate",{detail:{to:e,from:this.currentPath},bubbles:!0,cancelable:!0});if(!this.dispatchEvent(t)){$.debug(`Navigation to ${e} was cancelled`);return}this.performNavigation(e)}finally{requestAnimationFrame(()=>{this.isHandlingRoute=!1})}}),q(this,"interceptLinks",e=>{const t=e.target.closest("a");if(!t)return;const r=t.getAttribute("href");!r||r.startsWith("http")||r.startsWith("#")||(e.preventDefault(),this.navigate(r))})}render(){return N.jsx("div",{class:"router-outlet"})}onRendered(){var e;(e=super.onRendered)==null||e.call(this),this.views.size===0&&(this.collectViews(),$.debug("WsxRouter collected views in onRendered:",this.views.size)),this.views.size>0&&!this.currentView&&requestAnimationFrame(()=>{this.handleRouteChange()})}onConnected(){var e;(e=super.onConnected)==null||e.call(this),$.debug("WsxRouter connected to DOM"),"scrollRestoration"in history&&(history.scrollRestoration=this.scrollRestoration),window.addEventListener("popstate",this.handleRouteChange),this.addEventListener("click",this.interceptLinks),requestAnimationFrame(()=>{this.views.size===0&&(this.collectViews(),$.debug(`WsxRouter collected views in onConnected: ${this.views.size}`)),requestAnimationFrame(()=>{$.debug(`WsxRouter handling initial route: ${window.location.pathname}`),this.handleRouteChange()})})}onDisconnected(){var e;(e=super.onDisconnected)==null||e.call(this),window.removeEventListener("popstate",this.handleRouteChange)}collectViews(){const e=Array.from(this.children).filter(t=>t.tagName.toLowerCase()==="wsx-view");$.debug(`WsxRouter found ${e.length} views`),this.views.clear(),this.compiledRoutes.clear(),this.matchCache.clear(),e.forEach(t=>{const r=t.getAttribute("route")||"/";if(this.views.set(r,t),$.debug(`WsxRouter registered route: ${r}`),r.includes(":")){const g=r.replace(/:[^/]+/g,"([^/]+)"),v=new RegExp(`^${g}$`);this.compiledRoutes.set(r,v),$.debug(`WsxRouter compiled regex for route: ${r} -> ${v}`)}t.style.display="none"})}performNavigation(e){const t=()=>{const r=this.matchRoute(e);if(r){r.style.display="block",r.style.visibility="visible";const g=r.getAttribute("route")||"/";$.debug(`Showing view for route: ${g}`);for(const[j,V]of this.views)V!==r&&(V.style.display="none",V.style.visibility="");this.currentView=r;const v=this.extractParams(g,e);$.debug(`Extracted params for route ${g} and path ${e}:`,v),v&&requestAnimationFrame(()=>{r.setAttribute("params",JSON.stringify(v)),$.debug(`Set params attribute on view: ${JSON.stringify(v)}`)});const d=window.location.href||`${window.location.pathname}${window.location.search}${window.location.hash}`,_=new URL(d,window.location.origin||"http://localhost"),y={path:e,params:v||{},query:Object.fromEntries(_.searchParams.entries()),hash:_.hash.slice(1)};ne._setCurrentRoute(y),$.debug("Updated RouterUtils._currentRoute:",y);const T=new CustomEvent("route-changed",{detail:y,bubbles:!0});document.dispatchEvent(T)}else{for(const[y,T]of this.views)T.style.display="none";this.currentView=null,$.warn(`No view found for path: ${e}`);const g=window.location.href||`${window.location.pathname}${window.location.search}${window.location.hash}`,v=new URL(g,window.location.origin||"http://localhost"),d={path:e,params:{},query:Object.fromEntries(v.searchParams.entries()),hash:v.hash.slice(1)};ne._setCurrentRoute(d);const _=new CustomEvent("route-changed",{detail:d,bubbles:!0});document.dispatchEvent(_)}this.handleScrollRestoration(e),this.dispatchEvent(new CustomEvent("after-navigate",{detail:{to:e,from:this.currentPath},bubbles:!0})),this.currentPath=e};this.enableViewTransitions&&"startViewTransition"in document?document.startViewTransition(t):t()}handleScrollRestoration(e){this.scrollRestoration==="manual"&&(this.isBackNavigation()||(window.scrollTo(0,0),$.debug("Scrolled to top for forward navigation")))}isBackNavigation(){var e;return"navigation"in performance&&performance.navigation?performance.navigation.type===2:((e=window.history.state)==null?void 0:e.navigationType)==="back"}matchRoute(e){if($.warn(`matchRoute called for path: ${e}, views count: ${this.views.size}`),this.matchCache.has(e)){const r=this.matchCache.get(e);return $.warn(`matchRoute: found in cache, route: ${r}`),this.views.get(r)||null}if(this.views.has(e))return this.matchCache.set(e,e),$.warn(`matchRoute: exact match found for ${e}`),this.views.get(e);$.warn(`matchRoute: checking parameter routes, compiledRoutes count: ${this.compiledRoutes.size}`);for(const[r,g]of this.views)if(r.includes(":")){const v=this.compiledRoutes.get(r);if(v){const d=v.test(e);if($.warn(`matchRoute: testing route ${r} against ${e}, matches: ${d}`),d)return this.matchCache.set(e,r),$.warn(`matchRoute: parameter match found, route: ${r}, path: ${e}`),g}else $.warn(`matchRoute: route ${r} has ':' but no compiled regex found`)}const t=this.views.get("*")||null;return t?(this.matchCache.set(e,"*"),$.warn(`matchRoute: wildcard match found for ${e}`)):$.warn(`matchRoute: no match found for ${e}, no wildcard view available`),t}extractParams(e,t){var y;if(!e.includes(":"))return null;const r=((y=e.match(/:([^/]+)/g))==null?void 0:y.map(T=>T.slice(1)))||[],g=e.replace(/:[^/]+/g,"([^/]+)"),v=new RegExp(`^${g}$`),d=t.match(v);if(!d||!r.length)return null;const _={};return r.forEach((T,j)=>{_[T]=d[j+1]}),_}clearMatchCache(){this.matchCache.clear(),$.debug("WsxRouter cleared match cache")}setViewTransitions(e){this.enableViewTransitions=e,$.debug(`View Transitions ${e?"enabled":"disabled"}`)}setScrollRestoration(e){this.scrollRestoration=e,"scrollRestoration"in history&&(history.scrollRestoration=e),$.debug(`Scroll Restoration set to ${e}`)}navigate(e){window.history.pushState(null,"",e),this.handleRouteChange()}}me=De;[exports.WsxRouter,be]=je(me,[],ye,0,void 0,N.LightComponent).c;be();const Pe=":host{display:block;width:100%;height:100%}.route-view{width:100%;height:100%;position:relative}:host([loading]) .route-view{opacity:.5;transition:opacity .3s ease}:host([error]) .route-view{border:1px solid var(--error-color, #ff0000);padding:1rem}.route-view.entering{animation:fadeIn .3s ease-out}.route-view.leaving{animation:fadeOut .3s ease-in}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}@keyframes fadeOut{0%{opacity:1}to{opacity:0}}";var Le;let Re,xe;function ee(n,e,t){return(e=Ce(e))in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function Ve(n,e,t,r,g,v){function d(s,o,c){return function(i,u){return c&&c(i),s[o].call(i,u)}}function _(s,o){for(var c=0;c<s.length;c++)s[c].call(o);return o}function y(s,o,c,i){if(typeof s!="function"&&(i||s!==void 0))throw new TypeError(o+" must "+(c||"be")+" a function"+(i?"":" or undefined"));return s}function T(s,o,c,i,u,A,k,R,P,C,L,p,m){function h(f){if(!m(f))throw new TypeError("Attempted to access private element on non-instance")}var l,x=o[0],E=o[3],W=!R;if(!W){c||Array.isArray(x)||(x=[x]);var a={},S=[],w=u===3?"get":u===4||p?"set":"value";C?(L||p?a={get:le(function(){return E(this)},i,"get"),set:function(f){o[4](this,f)}}:a[w]=E,L||le(a[w],i,u===2?"":w)):L||(a=Object.getOwnPropertyDescriptor(s,i))}for(var b=s,U=x.length-1;U>=0;U-=c?2:1){var G=x[U],K=c?x[U-1]:void 0,J={},O={kind:["field","accessor","method","getter","setter","class"][u],name:i,metadata:A,addInitializer:(function(f,I){if(f.v)throw Error("attempted to call addInitializer after decoration was finished");y(I,"An initializer","be",!0),k.push(I)}).bind(null,J)};try{if(W)(l=y(G.call(K,b,O),"class decorators","return"))&&(b=l);else{var M,z;O.static=P,O.private=C,C?u===2?M=function(f){return h(f),a.value}:(u<4&&(M=d(a,"get",h)),u!==3&&(z=d(a,"set",h))):(M=function(f){return f[i]},(u<2||u===4)&&(z=function(f,I){f[i]=I}));var Q=O.access={has:C?m.bind():function(f){return i in f}};if(M&&(Q.get=M),z&&(Q.set=z),b=G.call(K,p?{get:a.get,set:a.set}:a[w],O),p){if(typeof b=="object"&&b)(l=y(b.get,"accessor.get"))&&(a.get=l),(l=y(b.set,"accessor.set"))&&(a.set=l),(l=y(b.init,"accessor.init"))&&S.push(l);else if(b!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0")}else y(b,(L?"field":"method")+" decorators","return")&&(L?S.push(b):a[w]=b)}}finally{J.v=!0}}return(L||p)&&R.push(function(f,I){for(var F=S.length-1;F>=0;F--)I=S[F].call(f,I);return I}),L||W||(C?p?R.push(d(a,"get"),d(a,"set")):R.push(u===2?a[w]:d.call.bind(a[w])):Object.defineProperty(s,i,a)),b}function j(s,o){return Object.defineProperty(s,Symbol.metadata||Symbol.for("Symbol.metadata"),{configurable:!0,enumerable:!0,value:o})}if(arguments.length>=6)var V=v[Symbol.metadata||Symbol.for("Symbol.metadata")];var D=Object.create(V??null),B=function(s,o,c,i){var u,A,k=[],R=function(w){return ze(w)===s},P=new Map;function C(w){w&&k.push(_.bind(null,w))}for(var L=0;L<o.length;L++){var p=o[L];if(Array.isArray(p)){var m=p[1],h=p[2],l=p.length>3,x=16&m,E=!!(8&m),W=(m&=7)==0,a=h+"/"+E;if(!W&&!l){var S=P.get(a);if(S===!0||S===3&&m!==4||S===4&&m!==3)throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: "+h);P.set(a,!(m>2)||m)}T(E?s:s.prototype,p,x,l?"#"+h:Ce(h),m,i,E?A=A||[]:u=u||[],k,E,l,W,m===1,E&&l?R:c)}}return C(u),C(A),k}(n,e,g,D);return t.length||j(n,D),{e:B,get c(){var s=[];return t.length&&[j(T(n,[t],r,n.name,5,D,s),D),_.bind(null,s,n)]}}}function Ce(n){var e=Ue(n,"string");return typeof e=="symbol"?e:e+""}function Ue(n,e){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}function le(n,e,t){typeof e=="symbol"&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(n,"name",{configurable:!0,value:t?t+" "+e:e})}catch{}return n}function ze(n){if(Object(n)!==n)throw TypeError("right-hand side of 'in' should be an object, got "+(n!==null?typeof n:"null"));return n}const H=re("WsxView");xe=[N.autoRegister({tagName:"wsx-view"})];exports.WsxView=void 0;class Ne extends N.LightComponent{constructor(){super(),ee(this,"_autoStyles",Pe),ee(this,"_component",""),ee(this,"params",void 0),ee(this,"componentInstance",null),ee(this,"isLoading",!1);let e=this.reactive({});Object.defineProperty(this,"params",{get:()=>e,set:t=>{e=t!==null&&typeof t<"u"&&(Array.isArray(t)||typeof t=="object")?this.reactive(t):t,this.scheduleRerender()},enumerable:!0,configurable:!0})}get component(){return this._component}set component(e){this._component=e||"",this._component&&requestAnimationFrame(()=>{this.connected&&!this.componentInstance&&!this.isLoading&&this.loadComponent(this._component||"")})}render(){return N.jsx("div",{class:"route-view"})}onConnected(){var e;(e=super.onConnected)==null||e.call(this),requestAnimationFrame(()=>{!this.connected||this.isLoading||this.componentInstance||this.component&&this.loadComponent(this.component)})}async loadComponent(e){if(!(!this.connected||this.isLoading||this.componentInstance)){this.isLoading=!0;try{const t=this.componentInstance;if(t&&(t.remove(),this.componentInstance=null),!customElements.get(e)){H.warn(`Component ${e} not found in customElements registry`),this.isLoading=!1;return}H.warn(`WsxView: Creating instance of ${e}`),this.componentInstance=document.createElement(e),Object.keys(this.params).length>0&&(H.warn(`WsxView: Setting initial params on ${e}:`,this.params),Object.entries(this.params).forEach(([v,d])=>{this.componentInstance.setAttribute(v,d)}));const g=this.querySelector(".route-view");if(g){if(H.warn(`WsxView: Appending ${e} to container`),!customElements.get(e)){H.error(`WsxView: Component ${e} is not registered in customElements registry!`),this.isLoading=!1,this.componentInstance=null;return}g.appendChild(this.componentInstance),H.warn(`WsxView: Component ${e} appended successfully, waiting for connectedCallback...`),setTimeout(()=>{this.componentInstance&&this.componentInstance.isConnected?H.warn(`WsxView: Component ${e} is now connected to DOM`):H.error(`WsxView: Component ${e} was not connected to DOM!`)},0)}else H.error("WsxView: Route view container not found"),this.componentInstance=null}catch(t){H.warn(`Error loading component ${e}:`,t),this.componentInstance=null}finally{this.isLoading=!1,H.warn(`WsxView: loadComponent for ${e} completed, isLoading=${this.isLoading}`)}}}onDisconnected(){var e;(e=super.onDisconnected)==null||e.call(this),this.componentInstance&&(this.componentInstance.remove(),this.componentInstance=null)}}Le=Ne;[exports.WsxView,Re]=Ve(Le,[],xe,0,void 0,N.LightComponent).c;Re();const Fe=':host{display:inline-block;min-width:fit-content;min-height:fit-content;width:auto;height:auto}.wsx-link{color:var(--link-color, #007bff);text-decoration:var(--link-decoration, underline);cursor:pointer;transition:color .2s ease;display:inline-block;min-height:1.2em;line-height:1.2}.wsx-link:hover{color:var(--link-hover-color, #0056b3);text-decoration:var(--link-hover-decoration, underline)}.wsx-link:focus{outline:2px solid var(--link-focus-color, var(--focus-color, #dc2626));outline-offset:2px}.wsx-link.active{color:var(--link-active-color, #6c757d);font-weight:var(--link-active-weight, bold)}:host([disabled]) .wsx-link{color:var(--link-disabled-color, #6c757d);cursor:not-allowed;pointer-events:none}:host([external]) .wsx-link:after{content:"↗";font-size:.8em;margin-left:.2em;opacity:.7}:host([variant="button"]) .wsx-link{background-color:var(--button-bg, #007bff);color:var(--button-color, white);padding:.5rem 1rem;border-radius:.25rem;text-decoration:none;display:inline-block}:host([variant="button"]) .wsx-link:hover{background-color:var(--button-hover-bg, #0056b3);color:var(--button-hover-color, white)}:host([variant="tab"]) .wsx-link{padding:.5rem 1rem;border-bottom:2px solid transparent;text-decoration:none}:host([variant="tab"]) .wsx-link.active{border-bottom-color:var(--tab-active-border, #007bff)}';var ie,oe;let ue,Ee,he;function X(n,e,t){return(e=$e(e))in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function qe(n,e,t,r,g,v){function d(s,o,c){return function(i,u){return c&&c(i),s[o].call(i,u)}}function _(s,o){for(var c=0;c<s.length;c++)s[c].call(o);return o}function y(s,o,c,i){if(typeof s!="function"&&(i||s!==void 0))throw new TypeError(o+" must "+(c||"be")+" a function"+(i?"":" or undefined"));return s}function T(s,o,c,i,u,A,k,R,P,C,L,p,m){function h(f){if(!m(f))throw new TypeError("Attempted to access private element on non-instance")}var l,x=o[0],E=o[3],W=!R;if(!W){c||Array.isArray(x)||(x=[x]);var a={},S=[],w=u===3?"get":u===4||p?"set":"value";C?(L||p?a={get:de(function(){return E(this)},i,"get"),set:function(f){o[4](this,f)}}:a[w]=E,L||de(a[w],i,u===2?"":w)):L||(a=Object.getOwnPropertyDescriptor(s,i))}for(var b=s,U=x.length-1;U>=0;U-=c?2:1){var G=x[U],K=c?x[U-1]:void 0,J={},O={kind:["field","accessor","method","getter","setter","class"][u],name:i,metadata:A,addInitializer:(function(f,I){if(f.v)throw Error("attempted to call addInitializer after decoration was finished");y(I,"An initializer","be",!0),k.push(I)}).bind(null,J)};try{if(W)(l=y(G.call(K,b,O),"class decorators","return"))&&(b=l);else{var M,z;O.static=P,O.private=C,C?u===2?M=function(f){return h(f),a.value}:(u<4&&(M=d(a,"get",h)),u!==3&&(z=d(a,"set",h))):(M=function(f){return f[i]},(u<2||u===4)&&(z=function(f,I){f[i]=I}));var Q=O.access={has:C?m.bind():function(f){return i in f}};if(M&&(Q.get=M),z&&(Q.set=z),b=G.call(K,p?{get:a.get,set:a.set}:a[w],O),p){if(typeof b=="object"&&b)(l=y(b.get,"accessor.get"))&&(a.get=l),(l=y(b.set,"accessor.set"))&&(a.set=l),(l=y(b.init,"accessor.init"))&&S.push(l);else if(b!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0")}else y(b,(L?"field":"method")+" decorators","return")&&(L?S.push(b):a[w]=b)}}finally{J.v=!0}}return(L||p)&&R.push(function(f,I){for(var F=S.length-1;F>=0;F--)I=S[F].call(f,I);return I}),L||W||(C?p?R.push(d(a,"get"),d(a,"set")):R.push(u===2?a[w]:d.call.bind(a[w])):Object.defineProperty(s,i,a)),b}function j(s,o){return Object.defineProperty(s,Symbol.metadata||Symbol.for("Symbol.metadata"),{configurable:!0,enumerable:!0,value:o})}if(arguments.length>=6)var V=v[Symbol.metadata||Symbol.for("Symbol.metadata")];var D=Object.create(V??null),B=function(s,o,c,i){var u,A,k=[],R=function(w){return Be(w)===s},P=new Map;function C(w){w&&k.push(_.bind(null,w))}for(var L=0;L<o.length;L++){var p=o[L];if(Array.isArray(p)){var m=p[1],h=p[2],l=p.length>3,x=16&m,E=!!(8&m),W=(m&=7)==0,a=h+"/"+E;if(!W&&!l){var S=P.get(a);if(S===!0||S===3&&m!==4||S===4&&m!==3)throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: "+h);P.set(a,!(m>2)||m)}T(E?s:s.prototype,p,x,l?"#"+h:$e(h),m,i,E?A=A||[]:u=u||[],k,E,l,W,m===1,E&&l?R:c)}}return C(u),C(A),k}(n,e,g,D);return t.length||j(n,D),{e:B,get c(){var s=[];return t.length&&[j(T(n,[t],r,n.name,5,D,s),D),_.bind(null,s,n)]}}}function $e(n){var e=He(n,"string");return typeof e=="symbol"?e:e+""}function He(n,e){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}function de(n,e,t){typeof e=="symbol"&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(n,"name",{configurable:!0,value:t?t+" "+e:e})}catch{}return n}function Be(n){if(Object(n)!==n)throw TypeError("right-hand side of 'in' should be an object, got "+(n!==null?typeof n:"null"));return n}function Ge(n){return n}const fe=re("WsxLink");Ee=[N.autoRegister({tagName:"wsx-link"})];exports.WsxLink=void 0;new(he=(oe=class extends N.WebComponent{constructor(){super(),X(this,"_autoStyles",Fe),X(this,"to",void 0),X(this,"activeClass",void 0),X(this,"handleClick",v=>{if(v.preventDefault(),!this.to){fe.warn("No 'to' attribute specified");return}if(this.isExternalLink(this.to)){window.open(this.to,"_blank");return}this.replace?window.history.replaceState(null,"",this.to):window.history.pushState(null,"",this.to),window.dispatchEvent(new PopStateEvent("popstate")),fe.debug(`Navigated to: ${this.to}`)}),X(this,"updateActiveState",()=>{var y;const v=window.location.pathname,d=this.exact?v===this.to:v.startsWith(this.to)&&this.to!=="/",_=(y=this.shadowRoot)==null?void 0:y.querySelector("a");_&&(d?(_.classList.add(this.activeClass),this.setAttribute("active","")):(_.classList.remove(this.activeClass),this.removeAttribute("active")))});const[e,t]=this.useState("to","");Object.defineProperty(this,"to",{get:e,set:t,enumerable:!0,configurable:!0});const[r,g]=this.useState("activeClass","active");Object.defineProperty(this,"activeClass",{get:r,set:g,enumerable:!0,configurable:!0})}get replace(){return this.hasAttribute("replace")}get exact(){return this.hasAttribute("exact")}render(){return N.jsx("a",{href:this.to,class:"wsx-link",onClick:this.handleClick,part:"link"},N.jsx("slot",null))}onConnected(){var t;(t=super.onConnected)==null||t.call(this),this.to=this.to||"",this.activeClass=this.activeClass||"active";const e=this.shadowRoot.querySelector(".wsx-link");e&&(e.href=this.to),window.addEventListener("popstate",this.updateActiveState),document.addEventListener("route-changed",this.updateActiveState),this.updateActiveState()}onDisconnected(){var e;(e=super.onDisconnected)==null||e.call(this),window.removeEventListener("popstate",this.updateActiveState),document.removeEventListener("route-changed",this.updateActiveState)}onAttributeChanged(e,t,r){switch(e){case"to":this.to=r||"",this.updateActiveState();break;case"replace":this.replace=r!==null&&r!=="false";break;case"active-class":this.activeClass=r||"active",this.updateActiveState();break;case"exact":this.exact=r!==null&&r!=="false",this.updateActiveState();break}}isExternalLink(e){return e.startsWith("http://")||e.startsWith("https://")||e.startsWith("mailto:")||e.startsWith("tel:")}navigate(){this.to&&this.handleClick(new MouseEvent("click",{bubbles:!0,cancelable:!0}))}},[exports.WsxLink,ue]=qe(oe,[],Ee,0,void 0,N.WebComponent).c,oe),ie=class extends Ge{constructor(){super(exports.WsxLink),X(this,"observedAttributes",["to","replace","active-class","exact"]),ue()}},X(ie,he,void 0),ie);exports.RouterUtils=ne;
|
package/dist/index.js
CHANGED
|
@@ -15,7 +15,7 @@ var ye = { exports: {} };
|
|
|
15
15
|
"info",
|
|
16
16
|
"warn",
|
|
17
17
|
"error"
|
|
18
|
-
], v = {},
|
|
18
|
+
], v = {}, d = null;
|
|
19
19
|
function _(o, c) {
|
|
20
20
|
var i = o[c];
|
|
21
21
|
if (typeof i.bind == "function")
|
|
@@ -47,36 +47,36 @@ var ye = { exports: {} };
|
|
|
47
47
|
typeof console !== t && (O.call(this), this[o].apply(this, arguments));
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
|
-
function
|
|
50
|
+
function M(o, c, i) {
|
|
51
51
|
return T(o) || V.apply(this, arguments);
|
|
52
52
|
}
|
|
53
53
|
function H(o, c) {
|
|
54
|
-
var i = this, u, A, k,
|
|
55
|
-
typeof o == "string" ?
|
|
54
|
+
var i = this, u, A, k, L = "loglevel";
|
|
55
|
+
typeof o == "string" ? L += ":" + o : typeof o == "symbol" && (L = void 0);
|
|
56
56
|
function P(h) {
|
|
57
57
|
var l = (g[h] || "silent").toUpperCase();
|
|
58
|
-
if (!(typeof window === t || !
|
|
58
|
+
if (!(typeof window === t || !L)) {
|
|
59
59
|
try {
|
|
60
|
-
window.localStorage[
|
|
60
|
+
window.localStorage[L] = l;
|
|
61
61
|
return;
|
|
62
62
|
} catch {
|
|
63
63
|
}
|
|
64
64
|
try {
|
|
65
|
-
window.document.cookie = encodeURIComponent(
|
|
65
|
+
window.document.cookie = encodeURIComponent(L) + "=" + l + ";";
|
|
66
66
|
} catch {
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
function E() {
|
|
71
71
|
var h;
|
|
72
|
-
if (!(typeof window === t || !
|
|
72
|
+
if (!(typeof window === t || !L)) {
|
|
73
73
|
try {
|
|
74
|
-
h = window.localStorage[
|
|
74
|
+
h = window.localStorage[L];
|
|
75
75
|
} catch {
|
|
76
76
|
}
|
|
77
77
|
if (typeof h === t)
|
|
78
78
|
try {
|
|
79
|
-
var l = window.document.cookie, x = encodeURIComponent(
|
|
79
|
+
var l = window.document.cookie, x = encodeURIComponent(L), C = l.indexOf(x + "=");
|
|
80
80
|
C !== -1 && (h = /^([^;]+)/.exec(
|
|
81
81
|
l.slice(C + x.length + 1)
|
|
82
82
|
)[1]);
|
|
@@ -85,14 +85,14 @@ var ye = { exports: {} };
|
|
|
85
85
|
return i.levels[h] === void 0 && (h = void 0), h;
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
|
-
function
|
|
89
|
-
if (!(typeof window === t || !
|
|
88
|
+
function R() {
|
|
89
|
+
if (!(typeof window === t || !L)) {
|
|
90
90
|
try {
|
|
91
|
-
window.localStorage.removeItem(
|
|
91
|
+
window.localStorage.removeItem(L);
|
|
92
92
|
} catch {
|
|
93
93
|
}
|
|
94
94
|
try {
|
|
95
|
-
window.document.cookie = encodeURIComponent(
|
|
95
|
+
window.document.cookie = encodeURIComponent(L) + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
|
|
96
96
|
} catch {
|
|
97
97
|
}
|
|
98
98
|
}
|
|
@@ -110,43 +110,43 @@ var ye = { exports: {} };
|
|
|
110
110
|
WARN: 3,
|
|
111
111
|
ERROR: 4,
|
|
112
112
|
SILENT: 5
|
|
113
|
-
}, i.methodFactory = c ||
|
|
113
|
+
}, i.methodFactory = c || M, i.getLevel = function() {
|
|
114
114
|
return k ?? A ?? u;
|
|
115
115
|
}, i.setLevel = function(h, l) {
|
|
116
116
|
return k = p(h), l !== !1 && P(k), O.call(i);
|
|
117
117
|
}, i.setDefaultLevel = function(h) {
|
|
118
118
|
A = p(h), E() || i.setLevel(h, !1);
|
|
119
119
|
}, i.resetLevel = function() {
|
|
120
|
-
k = null,
|
|
120
|
+
k = null, R(), O.call(i);
|
|
121
121
|
}, i.enableAll = function(h) {
|
|
122
122
|
i.setLevel(i.levels.TRACE, h);
|
|
123
123
|
}, i.disableAll = function(h) {
|
|
124
124
|
i.setLevel(i.levels.SILENT, h);
|
|
125
125
|
}, i.rebuild = function() {
|
|
126
|
-
if (
|
|
126
|
+
if (d !== i && (u = p(d.getLevel())), O.call(i), d === i)
|
|
127
127
|
for (var h in v)
|
|
128
128
|
v[h].rebuild();
|
|
129
129
|
}, u = p(
|
|
130
|
-
|
|
130
|
+
d ? d.getLevel() : "WARN"
|
|
131
131
|
);
|
|
132
132
|
var m = E();
|
|
133
133
|
m != null && (k = p(m)), O.call(i);
|
|
134
134
|
}
|
|
135
|
-
|
|
135
|
+
d = new H(), d.getLogger = function(c) {
|
|
136
136
|
if (typeof c != "symbol" && typeof c != "string" || c === "")
|
|
137
137
|
throw new TypeError("You must supply a name when creating a logger.");
|
|
138
138
|
var i = v[c];
|
|
139
139
|
return i || (i = v[c] = new H(
|
|
140
140
|
c,
|
|
141
|
-
|
|
141
|
+
d.methodFactory
|
|
142
142
|
)), i;
|
|
143
143
|
};
|
|
144
144
|
var s = typeof window !== t ? window.log : void 0;
|
|
145
|
-
return
|
|
146
|
-
return typeof window !== t && window.log ===
|
|
147
|
-
},
|
|
145
|
+
return d.noConflict = function() {
|
|
146
|
+
return typeof window !== t && window.log === d && (window.log = s), d;
|
|
147
|
+
}, d.getLoggers = function() {
|
|
148
148
|
return v;
|
|
149
|
-
},
|
|
149
|
+
}, d.default = d, d;
|
|
150
150
|
});
|
|
151
151
|
})(ye);
|
|
152
152
|
var Te = ye.exports;
|
|
@@ -184,7 +184,7 @@ const ee = {
|
|
|
184
184
|
level: ae() ? "info" : "debug",
|
|
185
185
|
pretty: !ae()
|
|
186
186
|
};
|
|
187
|
-
function
|
|
187
|
+
function De(n = {}) {
|
|
188
188
|
const { name: e, level: t } = { ...ee, ...n }, r = e || ee.name, g = Oe.getLogger(r), v = t || ee.level;
|
|
189
189
|
return g.setLevel(be[v]), g;
|
|
190
190
|
}
|
|
@@ -193,7 +193,7 @@ function X(n, e) {
|
|
|
193
193
|
}
|
|
194
194
|
class we {
|
|
195
195
|
constructor(e = {}) {
|
|
196
|
-
this.isProd = ae(), this.name = e.name || ee.name, this.currentLevel = e.level || ee.level, this.logInstance =
|
|
196
|
+
this.isProd = ae(), this.name = e.name || ee.name, this.currentLevel = e.level || ee.level, this.logInstance = De(e);
|
|
197
197
|
}
|
|
198
198
|
debug(e, ...t) {
|
|
199
199
|
if (!this.isProd || this.shouldLog("debug")) {
|
|
@@ -259,7 +259,7 @@ function ie(n, e = {}) {
|
|
|
259
259
|
name: e.name || `WSX:${n}`
|
|
260
260
|
});
|
|
261
261
|
}
|
|
262
|
-
const
|
|
262
|
+
const Me = ie("RouterUtils"), Y = class Y {
|
|
263
263
|
/**
|
|
264
264
|
* 设置当前路由信息(由 WsxRouter 内部调用)
|
|
265
265
|
* @internal
|
|
@@ -271,7 +271,7 @@ const De = ie("RouterUtils"), Y = class Y {
|
|
|
271
271
|
* 编程式导航
|
|
272
272
|
*/
|
|
273
273
|
static navigate(e, t = !1) {
|
|
274
|
-
t ? window.history.replaceState(null, "", e) : window.history.pushState(null, "", e), window.dispatchEvent(new PopStateEvent("popstate")),
|
|
274
|
+
t ? window.history.replaceState(null, "", e) : window.history.pushState(null, "", e), window.dispatchEvent(new PopStateEvent("popstate")), Me.debug(`Navigated to: ${e} (replace: ${t})`);
|
|
275
275
|
}
|
|
276
276
|
/**
|
|
277
277
|
* 获取当前路由信息
|
|
@@ -308,7 +308,7 @@ const De = ie("RouterUtils"), Y = class Y {
|
|
|
308
308
|
exact: !1
|
|
309
309
|
};
|
|
310
310
|
if (e.includes(":")) {
|
|
311
|
-
const g = ((r = e.match(/:([^/]+)/g)) == null ? void 0 : r.map((b) => b.slice(1))) || [], v = e.replace(/:[^/]+/g, "([^/]+)"),
|
|
311
|
+
const g = ((r = e.match(/:([^/]+)/g)) == null ? void 0 : r.map((b) => b.slice(1))) || [], v = e.replace(/:[^/]+/g, "([^/]+)"), d = new RegExp(`^${v}$`), _ = t.match(d);
|
|
312
312
|
if (_ && g.length > 0) {
|
|
313
313
|
const b = {};
|
|
314
314
|
return g.forEach((T, O) => {
|
|
@@ -444,13 +444,13 @@ const De = ie("RouterUtils"), Y = class Y {
|
|
|
444
444
|
Y._currentRoute = null;
|
|
445
445
|
let ne = Y;
|
|
446
446
|
const ue = ":host{display:grid;width:100%}.router-outlet{width:100%}:host>wsx-view{grid-area:1 / 1}";
|
|
447
|
-
var
|
|
448
|
-
let
|
|
447
|
+
var Re;
|
|
448
|
+
let Le, xe;
|
|
449
449
|
function F(n, e, t) {
|
|
450
450
|
return (e = Ee(e)) in n ? Object.defineProperty(n, e, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : n[e] = t, n;
|
|
451
451
|
}
|
|
452
452
|
function Pe(n, e, t, r, g, v) {
|
|
453
|
-
function
|
|
453
|
+
function d(s, o, c) {
|
|
454
454
|
return function(i, u) {
|
|
455
455
|
return c && c(i), s[o].call(i, u);
|
|
456
456
|
};
|
|
@@ -463,66 +463,66 @@ function Pe(n, e, t, r, g, v) {
|
|
|
463
463
|
if (typeof s != "function" && (i || s !== void 0)) throw new TypeError(o + " must " + (c || "be") + " a function" + (i ? "" : " or undefined"));
|
|
464
464
|
return s;
|
|
465
465
|
}
|
|
466
|
-
function T(s, o, c, i, u, A, k,
|
|
467
|
-
function h(
|
|
468
|
-
if (!m(
|
|
466
|
+
function T(s, o, c, i, u, A, k, L, P, E, R, p, m) {
|
|
467
|
+
function h(f) {
|
|
468
|
+
if (!m(f)) throw new TypeError("Attempted to access private element on non-instance");
|
|
469
469
|
}
|
|
470
|
-
var l, x = o[0], C = o[3], W = !
|
|
470
|
+
var l, x = o[0], C = o[3], W = !L;
|
|
471
471
|
if (!W) {
|
|
472
472
|
c || Array.isArray(x) || (x = [x]);
|
|
473
473
|
var a = {}, I = [], w = u === 3 ? "get" : u === 4 || p ? "set" : "value";
|
|
474
|
-
E ? (
|
|
474
|
+
E ? (R || p ? a = { get: he(function() {
|
|
475
475
|
return C(this);
|
|
476
|
-
}, i, "get"), set: function(
|
|
477
|
-
o[4](this,
|
|
478
|
-
} } : a[w] = C,
|
|
476
|
+
}, i, "get"), set: function(f) {
|
|
477
|
+
o[4](this, f);
|
|
478
|
+
} } : a[w] = C, R || he(a[w], i, u === 2 ? "" : w)) : R || (a = Object.getOwnPropertyDescriptor(s, i));
|
|
479
479
|
}
|
|
480
480
|
for (var y = s, U = x.length - 1; U >= 0; U -= c ? 2 : 1) {
|
|
481
|
-
var B = x[U], G = c ? x[U - 1] : void 0, K = {}, j = { kind: ["field", "accessor", "method", "getter", "setter", "class"][u], name: i, metadata: A, addInitializer: (function(
|
|
482
|
-
if (
|
|
481
|
+
var B = x[U], G = c ? x[U - 1] : void 0, K = {}, j = { kind: ["field", "accessor", "method", "getter", "setter", "class"][u], name: i, metadata: A, addInitializer: (function(f, S) {
|
|
482
|
+
if (f.v) throw Error("attempted to call addInitializer after decoration was finished");
|
|
483
483
|
b(S, "An initializer", "be", !0), k.push(S);
|
|
484
484
|
}).bind(null, K) };
|
|
485
485
|
try {
|
|
486
486
|
if (W) (l = b(B.call(G, y, j), "class decorators", "return")) && (y = l);
|
|
487
487
|
else {
|
|
488
|
-
var
|
|
489
|
-
j.static = P, j.private = E, E ? u === 2 ?
|
|
490
|
-
return h(
|
|
491
|
-
} : (u < 4 && (
|
|
492
|
-
return
|
|
493
|
-
}, (u < 2 || u === 4) && (z = function(
|
|
494
|
-
|
|
488
|
+
var D, z;
|
|
489
|
+
j.static = P, j.private = E, E ? u === 2 ? D = function(f) {
|
|
490
|
+
return h(f), a.value;
|
|
491
|
+
} : (u < 4 && (D = d(a, "get", h)), u !== 3 && (z = d(a, "set", h))) : (D = function(f) {
|
|
492
|
+
return f[i];
|
|
493
|
+
}, (u < 2 || u === 4) && (z = function(f, S) {
|
|
494
|
+
f[i] = S;
|
|
495
495
|
}));
|
|
496
|
-
var J = j.access = { has: E ? m.bind() : function(
|
|
497
|
-
return i in
|
|
496
|
+
var J = j.access = { has: E ? m.bind() : function(f) {
|
|
497
|
+
return i in f;
|
|
498
498
|
} };
|
|
499
|
-
if (
|
|
499
|
+
if (D && (J.get = D), z && (J.set = z), y = B.call(G, p ? { get: a.get, set: a.set } : a[w], j), p) {
|
|
500
500
|
if (typeof y == "object" && y) (l = b(y.get, "accessor.get")) && (a.get = l), (l = b(y.set, "accessor.set")) && (a.set = l), (l = b(y.init, "accessor.init")) && I.push(l);
|
|
501
501
|
else if (y !== void 0) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
|
502
|
-
} else b(y, (
|
|
502
|
+
} else b(y, (R ? "field" : "method") + " decorators", "return") && (R ? I.push(y) : a[w] = y);
|
|
503
503
|
}
|
|
504
504
|
} finally {
|
|
505
505
|
K.v = !0;
|
|
506
506
|
}
|
|
507
507
|
}
|
|
508
|
-
return (
|
|
509
|
-
for (var N = I.length - 1; N >= 0; N--) S = I[N].call(
|
|
508
|
+
return (R || p) && L.push(function(f, S) {
|
|
509
|
+
for (var N = I.length - 1; N >= 0; N--) S = I[N].call(f, S);
|
|
510
510
|
return S;
|
|
511
|
-
}),
|
|
511
|
+
}), R || W || (E ? p ? L.push(d(a, "get"), d(a, "set")) : L.push(u === 2 ? a[w] : d.call.bind(a[w])) : Object.defineProperty(s, i, a)), y;
|
|
512
512
|
}
|
|
513
513
|
function O(s, o) {
|
|
514
514
|
return Object.defineProperty(s, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: o });
|
|
515
515
|
}
|
|
516
516
|
if (arguments.length >= 6) var V = v[Symbol.metadata || Symbol.for("Symbol.metadata")];
|
|
517
|
-
var
|
|
518
|
-
var u, A, k = [],
|
|
517
|
+
var M = Object.create(V ?? null), H = function(s, o, c, i) {
|
|
518
|
+
var u, A, k = [], L = function(w) {
|
|
519
519
|
return Ue(w) === s;
|
|
520
520
|
}, P = /* @__PURE__ */ new Map();
|
|
521
521
|
function E(w) {
|
|
522
522
|
w && k.push(_.bind(null, w));
|
|
523
523
|
}
|
|
524
|
-
for (var
|
|
525
|
-
var p = o[
|
|
524
|
+
for (var R = 0; R < o.length; R++) {
|
|
525
|
+
var p = o[R];
|
|
526
526
|
if (Array.isArray(p)) {
|
|
527
527
|
var m = p[1], h = p[2], l = p.length > 3, x = 16 & m, C = !!(8 & m), W = (m &= 7) == 0, a = h + "/" + C;
|
|
528
528
|
if (!W && !l) {
|
|
@@ -530,14 +530,14 @@ function Pe(n, e, t, r, g, v) {
|
|
|
530
530
|
if (I === !0 || I === 3 && m !== 4 || I === 4 && m !== 3) throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + h);
|
|
531
531
|
P.set(a, !(m > 2) || m);
|
|
532
532
|
}
|
|
533
|
-
T(C ? s : s.prototype, p, x, l ? "#" + h : Ee(h), m, i, C ? A = A || [] : u = u || [], k, C, l, W, m === 1, C && l ?
|
|
533
|
+
T(C ? s : s.prototype, p, x, l ? "#" + h : Ee(h), m, i, C ? A = A || [] : u = u || [], k, C, l, W, m === 1, C && l ? L : c);
|
|
534
534
|
}
|
|
535
535
|
}
|
|
536
536
|
return E(u), E(A), k;
|
|
537
|
-
}(n, e, g,
|
|
538
|
-
return t.length || O(n,
|
|
537
|
+
}(n, e, g, M);
|
|
538
|
+
return t.length || O(n, M), { e: H, get c() {
|
|
539
539
|
var s = [];
|
|
540
|
-
return t.length && [O(T(n, [t], r, n.name, 5,
|
|
540
|
+
return t.length && [O(T(n, [t], r, n.name, 5, M, s), M), _.bind(null, s, n)];
|
|
541
541
|
} };
|
|
542
542
|
}
|
|
543
543
|
function Ee(n) {
|
|
@@ -614,19 +614,22 @@ class Ne extends re {
|
|
|
614
614
|
return /* @__PURE__ */ te("div", { class: "router-outlet" });
|
|
615
615
|
}
|
|
616
616
|
onRendered() {
|
|
617
|
-
|
|
617
|
+
var e;
|
|
618
|
+
(e = super.onRendered) == null || e.call(this), this.views.size === 0 && (this.collectViews(), $.debug("WsxRouter collected views in onRendered:", this.views.size)), this.views.size > 0 && !this.currentView && requestAnimationFrame(() => {
|
|
618
619
|
this.handleRouteChange();
|
|
619
620
|
});
|
|
620
621
|
}
|
|
621
622
|
onConnected() {
|
|
622
|
-
|
|
623
|
+
var e;
|
|
624
|
+
(e = super.onConnected) == null || e.call(this), $.debug("WsxRouter connected to DOM"), "scrollRestoration" in history && (history.scrollRestoration = this.scrollRestoration), window.addEventListener("popstate", this.handleRouteChange), this.addEventListener("click", this.interceptLinks), requestAnimationFrame(() => {
|
|
623
625
|
this.views.size === 0 && (this.collectViews(), $.debug(`WsxRouter collected views in onConnected: ${this.views.size}`)), requestAnimationFrame(() => {
|
|
624
626
|
$.debug(`WsxRouter handling initial route: ${window.location.pathname}`), this.handleRouteChange();
|
|
625
627
|
});
|
|
626
628
|
});
|
|
627
629
|
}
|
|
628
630
|
onDisconnected() {
|
|
629
|
-
|
|
631
|
+
var e;
|
|
632
|
+
(e = super.onDisconnected) == null || e.call(this), window.removeEventListener("popstate", this.handleRouteChange);
|
|
630
633
|
}
|
|
631
634
|
collectViews() {
|
|
632
635
|
const e = Array.from(this.children).filter((t) => t.tagName.toLowerCase() === "wsx-view");
|
|
@@ -656,7 +659,7 @@ class Ne extends re {
|
|
|
656
659
|
$.debug(`Extracted params for route ${g} and path ${e}:`, v), v && requestAnimationFrame(() => {
|
|
657
660
|
r.setAttribute("params", JSON.stringify(v)), $.debug(`Set params attribute on view: ${JSON.stringify(v)}`);
|
|
658
661
|
});
|
|
659
|
-
const
|
|
662
|
+
const d = window.location.href || `${window.location.pathname}${window.location.search}${window.location.hash}`, _ = new URL(d, window.location.origin || "http://localhost"), b = {
|
|
660
663
|
path: e,
|
|
661
664
|
params: v || {},
|
|
662
665
|
query: Object.fromEntries(_.searchParams.entries()),
|
|
@@ -672,15 +675,15 @@ class Ne extends re {
|
|
|
672
675
|
for (const [b, T] of this.views)
|
|
673
676
|
T.style.display = "none";
|
|
674
677
|
this.currentView = null, $.warn(`No view found for path: ${e}`);
|
|
675
|
-
const g = window.location.href || `${window.location.pathname}${window.location.search}${window.location.hash}`, v = new URL(g, window.location.origin || "http://localhost"),
|
|
678
|
+
const g = window.location.href || `${window.location.pathname}${window.location.search}${window.location.hash}`, v = new URL(g, window.location.origin || "http://localhost"), d = {
|
|
676
679
|
path: e,
|
|
677
680
|
params: {},
|
|
678
681
|
query: Object.fromEntries(v.searchParams.entries()),
|
|
679
682
|
hash: v.hash.slice(1)
|
|
680
683
|
};
|
|
681
|
-
ne._setCurrentRoute(
|
|
684
|
+
ne._setCurrentRoute(d);
|
|
682
685
|
const _ = new CustomEvent("route-changed", {
|
|
683
|
-
detail:
|
|
686
|
+
detail: d,
|
|
684
687
|
bubbles: !0
|
|
685
688
|
});
|
|
686
689
|
document.dispatchEvent(_);
|
|
@@ -720,8 +723,8 @@ class Ne extends re {
|
|
|
720
723
|
if (r.includes(":")) {
|
|
721
724
|
const v = this.compiledRoutes.get(r);
|
|
722
725
|
if (v) {
|
|
723
|
-
const
|
|
724
|
-
if ($.warn(`matchRoute: testing route ${r} against ${e}, matches: ${
|
|
726
|
+
const d = v.test(e);
|
|
727
|
+
if ($.warn(`matchRoute: testing route ${r} against ${e}, matches: ${d}`), d)
|
|
725
728
|
return this.matchCache.set(e, r), $.warn(`matchRoute: parameter match found, route: ${r}, path: ${e}`), g;
|
|
726
729
|
} else
|
|
727
730
|
$.warn(`matchRoute: route ${r} has ':' but no compiled regex found`);
|
|
@@ -732,11 +735,11 @@ class Ne extends re {
|
|
|
732
735
|
extractParams(e, t) {
|
|
733
736
|
var b;
|
|
734
737
|
if (!e.includes(":")) return null;
|
|
735
|
-
const r = ((b = e.match(/:([^/]+)/g)) == null ? void 0 : b.map((T) => T.slice(1))) || [], g = e.replace(/:[^/]+/g, "([^/]+)"), v = new RegExp(`^${g}$`),
|
|
736
|
-
if (!
|
|
738
|
+
const r = ((b = e.match(/:([^/]+)/g)) == null ? void 0 : b.map((T) => T.slice(1))) || [], g = e.replace(/:[^/]+/g, "([^/]+)"), v = new RegExp(`^${g}$`), d = t.match(v);
|
|
739
|
+
if (!d || !r.length) return null;
|
|
737
740
|
const _ = {};
|
|
738
741
|
return r.forEach((T, O) => {
|
|
739
|
-
_[T] =
|
|
742
|
+
_[T] = d[O + 1];
|
|
740
743
|
}), _;
|
|
741
744
|
}
|
|
742
745
|
/**
|
|
@@ -765,9 +768,9 @@ class Ne extends re {
|
|
|
765
768
|
window.history.pushState(null, "", e), this.handleRouteChange();
|
|
766
769
|
}
|
|
767
770
|
}
|
|
768
|
-
|
|
769
|
-
[ze,
|
|
770
|
-
|
|
771
|
+
Re = Ne;
|
|
772
|
+
[ze, Le] = Pe(Re, [], xe, 0, void 0, re).c;
|
|
773
|
+
Le();
|
|
771
774
|
const Fe = ":host{display:block;width:100%;height:100%}.route-view{width:100%;height:100%;position:relative}:host([loading]) .route-view{opacity:.5;transition:opacity .3s ease}:host([error]) .route-view{border:1px solid var(--error-color, #ff0000);padding:1rem}.route-view.entering{animation:fadeIn .3s ease-out}.route-view.leaving{animation:fadeOut .3s ease-in}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}@keyframes fadeOut{0%{opacity:1}to{opacity:0}}";
|
|
772
775
|
var Ce;
|
|
773
776
|
let $e, _e;
|
|
@@ -775,7 +778,7 @@ function Z(n, e, t) {
|
|
|
775
778
|
return (e = Ie(e)) in n ? Object.defineProperty(n, e, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : n[e] = t, n;
|
|
776
779
|
}
|
|
777
780
|
function qe(n, e, t, r, g, v) {
|
|
778
|
-
function
|
|
781
|
+
function d(s, o, c) {
|
|
779
782
|
return function(i, u) {
|
|
780
783
|
return c && c(i), s[o].call(i, u);
|
|
781
784
|
};
|
|
@@ -788,66 +791,66 @@ function qe(n, e, t, r, g, v) {
|
|
|
788
791
|
if (typeof s != "function" && (i || s !== void 0)) throw new TypeError(o + " must " + (c || "be") + " a function" + (i ? "" : " or undefined"));
|
|
789
792
|
return s;
|
|
790
793
|
}
|
|
791
|
-
function T(s, o, c, i, u, A, k,
|
|
792
|
-
function h(
|
|
793
|
-
if (!m(
|
|
794
|
+
function T(s, o, c, i, u, A, k, L, P, E, R, p, m) {
|
|
795
|
+
function h(f) {
|
|
796
|
+
if (!m(f)) throw new TypeError("Attempted to access private element on non-instance");
|
|
794
797
|
}
|
|
795
|
-
var l, x = o[0], C = o[3], W = !
|
|
798
|
+
var l, x = o[0], C = o[3], W = !L;
|
|
796
799
|
if (!W) {
|
|
797
800
|
c || Array.isArray(x) || (x = [x]);
|
|
798
801
|
var a = {}, I = [], w = u === 3 ? "get" : u === 4 || p ? "set" : "value";
|
|
799
|
-
E ? (
|
|
802
|
+
E ? (R || p ? a = { get: de(function() {
|
|
800
803
|
return C(this);
|
|
801
|
-
}, i, "get"), set: function(
|
|
802
|
-
o[4](this,
|
|
803
|
-
} } : a[w] = C,
|
|
804
|
+
}, i, "get"), set: function(f) {
|
|
805
|
+
o[4](this, f);
|
|
806
|
+
} } : a[w] = C, R || de(a[w], i, u === 2 ? "" : w)) : R || (a = Object.getOwnPropertyDescriptor(s, i));
|
|
804
807
|
}
|
|
805
808
|
for (var y = s, U = x.length - 1; U >= 0; U -= c ? 2 : 1) {
|
|
806
|
-
var B = x[U], G = c ? x[U - 1] : void 0, K = {}, j = { kind: ["field", "accessor", "method", "getter", "setter", "class"][u], name: i, metadata: A, addInitializer: (function(
|
|
807
|
-
if (
|
|
809
|
+
var B = x[U], G = c ? x[U - 1] : void 0, K = {}, j = { kind: ["field", "accessor", "method", "getter", "setter", "class"][u], name: i, metadata: A, addInitializer: (function(f, S) {
|
|
810
|
+
if (f.v) throw Error("attempted to call addInitializer after decoration was finished");
|
|
808
811
|
b(S, "An initializer", "be", !0), k.push(S);
|
|
809
812
|
}).bind(null, K) };
|
|
810
813
|
try {
|
|
811
814
|
if (W) (l = b(B.call(G, y, j), "class decorators", "return")) && (y = l);
|
|
812
815
|
else {
|
|
813
|
-
var
|
|
814
|
-
j.static = P, j.private = E, E ? u === 2 ?
|
|
815
|
-
return h(
|
|
816
|
-
} : (u < 4 && (
|
|
817
|
-
return
|
|
818
|
-
}, (u < 2 || u === 4) && (z = function(
|
|
819
|
-
|
|
816
|
+
var D, z;
|
|
817
|
+
j.static = P, j.private = E, E ? u === 2 ? D = function(f) {
|
|
818
|
+
return h(f), a.value;
|
|
819
|
+
} : (u < 4 && (D = d(a, "get", h)), u !== 3 && (z = d(a, "set", h))) : (D = function(f) {
|
|
820
|
+
return f[i];
|
|
821
|
+
}, (u < 2 || u === 4) && (z = function(f, S) {
|
|
822
|
+
f[i] = S;
|
|
820
823
|
}));
|
|
821
|
-
var J = j.access = { has: E ? m.bind() : function(
|
|
822
|
-
return i in
|
|
824
|
+
var J = j.access = { has: E ? m.bind() : function(f) {
|
|
825
|
+
return i in f;
|
|
823
826
|
} };
|
|
824
|
-
if (
|
|
827
|
+
if (D && (J.get = D), z && (J.set = z), y = B.call(G, p ? { get: a.get, set: a.set } : a[w], j), p) {
|
|
825
828
|
if (typeof y == "object" && y) (l = b(y.get, "accessor.get")) && (a.get = l), (l = b(y.set, "accessor.set")) && (a.set = l), (l = b(y.init, "accessor.init")) && I.push(l);
|
|
826
829
|
else if (y !== void 0) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
|
827
|
-
} else b(y, (
|
|
830
|
+
} else b(y, (R ? "field" : "method") + " decorators", "return") && (R ? I.push(y) : a[w] = y);
|
|
828
831
|
}
|
|
829
832
|
} finally {
|
|
830
833
|
K.v = !0;
|
|
831
834
|
}
|
|
832
835
|
}
|
|
833
|
-
return (
|
|
834
|
-
for (var N = I.length - 1; N >= 0; N--) S = I[N].call(
|
|
836
|
+
return (R || p) && L.push(function(f, S) {
|
|
837
|
+
for (var N = I.length - 1; N >= 0; N--) S = I[N].call(f, S);
|
|
835
838
|
return S;
|
|
836
|
-
}),
|
|
839
|
+
}), R || W || (E ? p ? L.push(d(a, "get"), d(a, "set")) : L.push(u === 2 ? a[w] : d.call.bind(a[w])) : Object.defineProperty(s, i, a)), y;
|
|
837
840
|
}
|
|
838
841
|
function O(s, o) {
|
|
839
842
|
return Object.defineProperty(s, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: o });
|
|
840
843
|
}
|
|
841
844
|
if (arguments.length >= 6) var V = v[Symbol.metadata || Symbol.for("Symbol.metadata")];
|
|
842
|
-
var
|
|
843
|
-
var u, A, k = [],
|
|
845
|
+
var M = Object.create(V ?? null), H = function(s, o, c, i) {
|
|
846
|
+
var u, A, k = [], L = function(w) {
|
|
844
847
|
return Be(w) === s;
|
|
845
848
|
}, P = /* @__PURE__ */ new Map();
|
|
846
849
|
function E(w) {
|
|
847
850
|
w && k.push(_.bind(null, w));
|
|
848
851
|
}
|
|
849
|
-
for (var
|
|
850
|
-
var p = o[
|
|
852
|
+
for (var R = 0; R < o.length; R++) {
|
|
853
|
+
var p = o[R];
|
|
851
854
|
if (Array.isArray(p)) {
|
|
852
855
|
var m = p[1], h = p[2], l = p.length > 3, x = 16 & m, C = !!(8 & m), W = (m &= 7) == 0, a = h + "/" + C;
|
|
853
856
|
if (!W && !l) {
|
|
@@ -855,14 +858,14 @@ function qe(n, e, t, r, g, v) {
|
|
|
855
858
|
if (I === !0 || I === 3 && m !== 4 || I === 4 && m !== 3) throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + h);
|
|
856
859
|
P.set(a, !(m > 2) || m);
|
|
857
860
|
}
|
|
858
|
-
T(C ? s : s.prototype, p, x, l ? "#" + h : Ie(h), m, i, C ? A = A || [] : u = u || [], k, C, l, W, m === 1, C && l ?
|
|
861
|
+
T(C ? s : s.prototype, p, x, l ? "#" + h : Ie(h), m, i, C ? A = A || [] : u = u || [], k, C, l, W, m === 1, C && l ? L : c);
|
|
859
862
|
}
|
|
860
863
|
}
|
|
861
864
|
return E(u), E(A), k;
|
|
862
|
-
}(n, e, g,
|
|
863
|
-
return t.length || O(n,
|
|
865
|
+
}(n, e, g, M);
|
|
866
|
+
return t.length || O(n, M), { e: H, get c() {
|
|
864
867
|
var s = [];
|
|
865
|
-
return t.length && [O(T(n, [t], r, n.name, 5,
|
|
868
|
+
return t.length && [O(T(n, [t], r, n.name, 5, M, s), M), _.bind(null, s, n)];
|
|
866
869
|
} };
|
|
867
870
|
}
|
|
868
871
|
function Ie(n) {
|
|
@@ -879,7 +882,7 @@ function He(n, e) {
|
|
|
879
882
|
}
|
|
880
883
|
return String(n);
|
|
881
884
|
}
|
|
882
|
-
function
|
|
885
|
+
function de(n, e, t) {
|
|
883
886
|
typeof e == "symbol" && (e = (e = e.description) ? "[" + e + "]" : "");
|
|
884
887
|
try {
|
|
885
888
|
Object.defineProperty(n, "name", { configurable: !0, value: t ? t + " " + e : e });
|
|
@@ -922,7 +925,8 @@ class Ke extends re {
|
|
|
922
925
|
return /* @__PURE__ */ te("div", { class: "route-view" });
|
|
923
926
|
}
|
|
924
927
|
onConnected() {
|
|
925
|
-
|
|
928
|
+
var e;
|
|
929
|
+
(e = super.onConnected) == null || e.call(this), requestAnimationFrame(() => {
|
|
926
930
|
!this.connected || this.isLoading || this.componentInstance || this.component && this.loadComponent(this.component);
|
|
927
931
|
});
|
|
928
932
|
}
|
|
@@ -935,8 +939,8 @@ class Ke extends re {
|
|
|
935
939
|
q.warn(`Component ${e} not found in customElements registry`), this.isLoading = !1;
|
|
936
940
|
return;
|
|
937
941
|
}
|
|
938
|
-
q.warn(`WsxView: Creating instance of ${e}`), this.componentInstance = document.createElement(e), Object.keys(this.params).length > 0 && (q.warn(`WsxView: Setting initial params on ${e}:`, this.params), Object.entries(this.params).forEach(([v,
|
|
939
|
-
this.componentInstance.setAttribute(v,
|
|
942
|
+
q.warn(`WsxView: Creating instance of ${e}`), this.componentInstance = document.createElement(e), Object.keys(this.params).length > 0 && (q.warn(`WsxView: Setting initial params on ${e}:`, this.params), Object.entries(this.params).forEach(([v, d]) => {
|
|
943
|
+
this.componentInstance.setAttribute(v, d);
|
|
940
944
|
}));
|
|
941
945
|
const g = this.querySelector(".route-view");
|
|
942
946
|
if (g) {
|
|
@@ -957,7 +961,8 @@ class Ke extends re {
|
|
|
957
961
|
}
|
|
958
962
|
}
|
|
959
963
|
onDisconnected() {
|
|
960
|
-
|
|
964
|
+
var e;
|
|
965
|
+
(e = super.onDisconnected) == null || e.call(this), this.componentInstance && (this.componentInstance.remove(), this.componentInstance = null);
|
|
961
966
|
}
|
|
962
967
|
}
|
|
963
968
|
Ce = Ke;
|
|
@@ -965,12 +970,12 @@ Ce = Ke;
|
|
|
965
970
|
$e();
|
|
966
971
|
const Je = ':host{display:inline-block;min-width:fit-content;min-height:fit-content;width:auto;height:auto}.wsx-link{color:var(--link-color, #007bff);text-decoration:var(--link-decoration, underline);cursor:pointer;transition:color .2s ease;display:inline-block;min-height:1.2em;line-height:1.2}.wsx-link:hover{color:var(--link-hover-color, #0056b3);text-decoration:var(--link-hover-decoration, underline)}.wsx-link:focus{outline:2px solid var(--link-focus-color, var(--focus-color, #dc2626));outline-offset:2px}.wsx-link.active{color:var(--link-active-color, #6c757d);font-weight:var(--link-active-weight, bold)}:host([disabled]) .wsx-link{color:var(--link-disabled-color, #6c757d);cursor:not-allowed;pointer-events:none}:host([external]) .wsx-link:after{content:"↗";font-size:.8em;margin-left:.2em;opacity:.7}:host([variant="button"]) .wsx-link{background-color:var(--button-bg, #007bff);color:var(--button-color, white);padding:.5rem 1rem;border-radius:.25rem;text-decoration:none;display:inline-block}:host([variant="button"]) .wsx-link:hover{background-color:var(--button-hover-bg, #0056b3);color:var(--button-hover-color, white)}:host([variant="tab"]) .wsx-link{padding:.5rem 1rem;border-bottom:2px solid transparent;text-decoration:none}:host([variant="tab"]) .wsx-link.active{border-bottom-color:var(--tab-active-border, #007bff)}';
|
|
967
972
|
var oe, se;
|
|
968
|
-
let
|
|
973
|
+
let fe, Se, ge;
|
|
969
974
|
function Q(n, e, t) {
|
|
970
975
|
return (e = ke(e)) in n ? Object.defineProperty(n, e, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : n[e] = t, n;
|
|
971
976
|
}
|
|
972
977
|
function Qe(n, e, t, r, g, v) {
|
|
973
|
-
function
|
|
978
|
+
function d(s, o, c) {
|
|
974
979
|
return function(i, u) {
|
|
975
980
|
return c && c(i), s[o].call(i, u);
|
|
976
981
|
};
|
|
@@ -983,66 +988,66 @@ function Qe(n, e, t, r, g, v) {
|
|
|
983
988
|
if (typeof s != "function" && (i || s !== void 0)) throw new TypeError(o + " must " + (c || "be") + " a function" + (i ? "" : " or undefined"));
|
|
984
989
|
return s;
|
|
985
990
|
}
|
|
986
|
-
function T(s, o, c, i, u, A, k,
|
|
987
|
-
function h(
|
|
988
|
-
if (!m(
|
|
991
|
+
function T(s, o, c, i, u, A, k, L, P, E, R, p, m) {
|
|
992
|
+
function h(f) {
|
|
993
|
+
if (!m(f)) throw new TypeError("Attempted to access private element on non-instance");
|
|
989
994
|
}
|
|
990
|
-
var l, x = o[0], C = o[3], W = !
|
|
995
|
+
var l, x = o[0], C = o[3], W = !L;
|
|
991
996
|
if (!W) {
|
|
992
997
|
c || Array.isArray(x) || (x = [x]);
|
|
993
998
|
var a = {}, I = [], w = u === 3 ? "get" : u === 4 || p ? "set" : "value";
|
|
994
|
-
E ? (
|
|
999
|
+
E ? (R || p ? a = { get: pe(function() {
|
|
995
1000
|
return C(this);
|
|
996
|
-
}, i, "get"), set: function(
|
|
997
|
-
o[4](this,
|
|
998
|
-
} } : a[w] = C,
|
|
1001
|
+
}, i, "get"), set: function(f) {
|
|
1002
|
+
o[4](this, f);
|
|
1003
|
+
} } : a[w] = C, R || pe(a[w], i, u === 2 ? "" : w)) : R || (a = Object.getOwnPropertyDescriptor(s, i));
|
|
999
1004
|
}
|
|
1000
1005
|
for (var y = s, U = x.length - 1; U >= 0; U -= c ? 2 : 1) {
|
|
1001
|
-
var B = x[U], G = c ? x[U - 1] : void 0, K = {}, j = { kind: ["field", "accessor", "method", "getter", "setter", "class"][u], name: i, metadata: A, addInitializer: (function(
|
|
1002
|
-
if (
|
|
1006
|
+
var B = x[U], G = c ? x[U - 1] : void 0, K = {}, j = { kind: ["field", "accessor", "method", "getter", "setter", "class"][u], name: i, metadata: A, addInitializer: (function(f, S) {
|
|
1007
|
+
if (f.v) throw Error("attempted to call addInitializer after decoration was finished");
|
|
1003
1008
|
b(S, "An initializer", "be", !0), k.push(S);
|
|
1004
1009
|
}).bind(null, K) };
|
|
1005
1010
|
try {
|
|
1006
1011
|
if (W) (l = b(B.call(G, y, j), "class decorators", "return")) && (y = l);
|
|
1007
1012
|
else {
|
|
1008
|
-
var
|
|
1009
|
-
j.static = P, j.private = E, E ? u === 2 ?
|
|
1010
|
-
return h(
|
|
1011
|
-
} : (u < 4 && (
|
|
1012
|
-
return
|
|
1013
|
-
}, (u < 2 || u === 4) && (z = function(
|
|
1014
|
-
|
|
1013
|
+
var D, z;
|
|
1014
|
+
j.static = P, j.private = E, E ? u === 2 ? D = function(f) {
|
|
1015
|
+
return h(f), a.value;
|
|
1016
|
+
} : (u < 4 && (D = d(a, "get", h)), u !== 3 && (z = d(a, "set", h))) : (D = function(f) {
|
|
1017
|
+
return f[i];
|
|
1018
|
+
}, (u < 2 || u === 4) && (z = function(f, S) {
|
|
1019
|
+
f[i] = S;
|
|
1015
1020
|
}));
|
|
1016
|
-
var J = j.access = { has: E ? m.bind() : function(
|
|
1017
|
-
return i in
|
|
1021
|
+
var J = j.access = { has: E ? m.bind() : function(f) {
|
|
1022
|
+
return i in f;
|
|
1018
1023
|
} };
|
|
1019
|
-
if (
|
|
1024
|
+
if (D && (J.get = D), z && (J.set = z), y = B.call(G, p ? { get: a.get, set: a.set } : a[w], j), p) {
|
|
1020
1025
|
if (typeof y == "object" && y) (l = b(y.get, "accessor.get")) && (a.get = l), (l = b(y.set, "accessor.set")) && (a.set = l), (l = b(y.init, "accessor.init")) && I.push(l);
|
|
1021
1026
|
else if (y !== void 0) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
|
1022
|
-
} else b(y, (
|
|
1027
|
+
} else b(y, (R ? "field" : "method") + " decorators", "return") && (R ? I.push(y) : a[w] = y);
|
|
1023
1028
|
}
|
|
1024
1029
|
} finally {
|
|
1025
1030
|
K.v = !0;
|
|
1026
1031
|
}
|
|
1027
1032
|
}
|
|
1028
|
-
return (
|
|
1029
|
-
for (var N = I.length - 1; N >= 0; N--) S = I[N].call(
|
|
1033
|
+
return (R || p) && L.push(function(f, S) {
|
|
1034
|
+
for (var N = I.length - 1; N >= 0; N--) S = I[N].call(f, S);
|
|
1030
1035
|
return S;
|
|
1031
|
-
}),
|
|
1036
|
+
}), R || W || (E ? p ? L.push(d(a, "get"), d(a, "set")) : L.push(u === 2 ? a[w] : d.call.bind(a[w])) : Object.defineProperty(s, i, a)), y;
|
|
1032
1037
|
}
|
|
1033
1038
|
function O(s, o) {
|
|
1034
1039
|
return Object.defineProperty(s, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: o });
|
|
1035
1040
|
}
|
|
1036
1041
|
if (arguments.length >= 6) var V = v[Symbol.metadata || Symbol.for("Symbol.metadata")];
|
|
1037
|
-
var
|
|
1038
|
-
var u, A, k = [],
|
|
1042
|
+
var M = Object.create(V ?? null), H = function(s, o, c, i) {
|
|
1043
|
+
var u, A, k = [], L = function(w) {
|
|
1039
1044
|
return Ye(w) === s;
|
|
1040
1045
|
}, P = /* @__PURE__ */ new Map();
|
|
1041
1046
|
function E(w) {
|
|
1042
1047
|
w && k.push(_.bind(null, w));
|
|
1043
1048
|
}
|
|
1044
|
-
for (var
|
|
1045
|
-
var p = o[
|
|
1049
|
+
for (var R = 0; R < o.length; R++) {
|
|
1050
|
+
var p = o[R];
|
|
1046
1051
|
if (Array.isArray(p)) {
|
|
1047
1052
|
var m = p[1], h = p[2], l = p.length > 3, x = 16 & m, C = !!(8 & m), W = (m &= 7) == 0, a = h + "/" + C;
|
|
1048
1053
|
if (!W && !l) {
|
|
@@ -1050,14 +1055,14 @@ function Qe(n, e, t, r, g, v) {
|
|
|
1050
1055
|
if (I === !0 || I === 3 && m !== 4 || I === 4 && m !== 3) throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + h);
|
|
1051
1056
|
P.set(a, !(m > 2) || m);
|
|
1052
1057
|
}
|
|
1053
|
-
T(C ? s : s.prototype, p, x, l ? "#" + h : ke(h), m, i, C ? A = A || [] : u = u || [], k, C, l, W, m === 1, C && l ?
|
|
1058
|
+
T(C ? s : s.prototype, p, x, l ? "#" + h : ke(h), m, i, C ? A = A || [] : u = u || [], k, C, l, W, m === 1, C && l ? L : c);
|
|
1054
1059
|
}
|
|
1055
1060
|
}
|
|
1056
1061
|
return E(u), E(A), k;
|
|
1057
|
-
}(n, e, g,
|
|
1058
|
-
return t.length || O(n,
|
|
1062
|
+
}(n, e, g, M);
|
|
1063
|
+
return t.length || O(n, M), { e: H, get c() {
|
|
1059
1064
|
var s = [];
|
|
1060
|
-
return t.length && [O(T(n, [t], r, n.name, 5,
|
|
1065
|
+
return t.length && [O(T(n, [t], r, n.name, 5, M, s), M), _.bind(null, s, n)];
|
|
1061
1066
|
} };
|
|
1062
1067
|
}
|
|
1063
1068
|
function ke(n) {
|
|
@@ -1108,8 +1113,8 @@ new (ge = (se = class extends le {
|
|
|
1108
1113
|
this.replace ? window.history.replaceState(null, "", this.to) : window.history.pushState(null, "", this.to), window.dispatchEvent(new PopStateEvent("popstate")), ve.debug(`Navigated to: ${this.to}`);
|
|
1109
1114
|
}), Q(this, "updateActiveState", () => {
|
|
1110
1115
|
var b;
|
|
1111
|
-
const v = window.location.pathname,
|
|
1112
|
-
_ && (
|
|
1116
|
+
const v = window.location.pathname, d = this.exact ? v === this.to : v.startsWith(this.to) && this.to !== "/", _ = (b = this.shadowRoot) == null ? void 0 : b.querySelector("a");
|
|
1117
|
+
_ && (d ? (_.classList.add(this.activeClass), this.setAttribute("active", "")) : (_.classList.remove(this.activeClass), this.removeAttribute("active")));
|
|
1113
1118
|
});
|
|
1114
1119
|
const [e, t] = this.useState("to", "");
|
|
1115
1120
|
Object.defineProperty(this, "to", {
|
|
@@ -1136,12 +1141,14 @@ new (ge = (se = class extends le {
|
|
|
1136
1141
|
return /* @__PURE__ */ te("a", { href: this.to, class: "wsx-link", onClick: this.handleClick, part: "link" }, /* @__PURE__ */ te("slot", null));
|
|
1137
1142
|
}
|
|
1138
1143
|
onConnected() {
|
|
1139
|
-
|
|
1144
|
+
var t;
|
|
1145
|
+
(t = super.onConnected) == null || t.call(this), this.to = this.to || "", this.activeClass = this.activeClass || "active";
|
|
1140
1146
|
const e = this.shadowRoot.querySelector(".wsx-link");
|
|
1141
1147
|
e && (e.href = this.to), window.addEventListener("popstate", this.updateActiveState), document.addEventListener("route-changed", this.updateActiveState), this.updateActiveState();
|
|
1142
1148
|
}
|
|
1143
1149
|
onDisconnected() {
|
|
1144
|
-
|
|
1150
|
+
var e;
|
|
1151
|
+
(e = super.onDisconnected) == null || e.call(this), window.removeEventListener("popstate", this.updateActiveState), document.removeEventListener("route-changed", this.updateActiveState);
|
|
1145
1152
|
}
|
|
1146
1153
|
onAttributeChanged(e, t, r) {
|
|
1147
1154
|
switch (e) {
|
|
@@ -1171,9 +1178,9 @@ new (ge = (se = class extends le {
|
|
|
1171
1178
|
cancelable: !0
|
|
1172
1179
|
}));
|
|
1173
1180
|
}
|
|
1174
|
-
}, [me,
|
|
1181
|
+
}, [me, fe] = Qe(se, [], Se, 0, void 0, le).c, se), oe = class extends Ze {
|
|
1175
1182
|
constructor() {
|
|
1176
|
-
super(me), Q(this, "observedAttributes", ["to", "replace", "active-class", "exact"]),
|
|
1183
|
+
super(me), Q(this, "observedAttributes", ["to", "replace", "active-class", "exact"]), fe();
|
|
1177
1184
|
}
|
|
1178
1185
|
}, Q(oe, ge, void 0), oe)();
|
|
1179
1186
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wsxjs/wsx-router",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.22",
|
|
4
4
|
"description": "WSX Router - Native History API-based routing for WSXJS",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"!**/test"
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@wsxjs/wsx-
|
|
22
|
-
"@wsxjs/wsx-
|
|
21
|
+
"@wsxjs/wsx-core": "0.0.22",
|
|
22
|
+
"@wsxjs/wsx-logger": "0.0.22"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@typescript-eslint/eslint-plugin": "^8.37.0",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"typescript": "^5.0.0",
|
|
32
32
|
"vite": "^5.4.19",
|
|
33
33
|
"vitest": "^2.1.8",
|
|
34
|
-
"@wsxjs/
|
|
35
|
-
"@wsxjs/
|
|
34
|
+
"@wsxjs/eslint-plugin-wsx": "0.0.22",
|
|
35
|
+
"@wsxjs/wsx-vite-plugin": "0.0.22"
|
|
36
36
|
},
|
|
37
37
|
"keywords": [
|
|
38
38
|
"wsx",
|
package/src/WsxLink.wsx
CHANGED
|
@@ -44,6 +44,7 @@ export default class WsxLink extends WebComponent {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
protected onConnected() {
|
|
47
|
+
super.onConnected?.();
|
|
47
48
|
// Initialize attributes from HTML when connected
|
|
48
49
|
this.to = this.to || "";
|
|
49
50
|
this.activeClass = this.activeClass || "active";
|
|
@@ -63,6 +64,7 @@ export default class WsxLink extends WebComponent {
|
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
protected onDisconnected() {
|
|
67
|
+
super.onDisconnected?.();
|
|
66
68
|
window.removeEventListener("popstate", this.updateActiveState);
|
|
67
69
|
document.removeEventListener("route-changed", this.updateActiveState);
|
|
68
70
|
}
|
package/src/WsxRouter.wsx
CHANGED
|
@@ -53,6 +53,7 @@ export default class WsxRouter extends LightComponent {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
protected onRendered() {
|
|
56
|
+
super.onRendered?.();
|
|
56
57
|
// 在渲染完成后也收集视图和处理路由(作为备用)
|
|
57
58
|
// 注意:onRendered 可能不会被调用(如果 hasActualContent 为 true)
|
|
58
59
|
// 所以主要逻辑在 onConnected() 中
|
|
@@ -70,6 +71,7 @@ export default class WsxRouter extends LightComponent {
|
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
protected onConnected() {
|
|
74
|
+
super.onConnected?.();
|
|
73
75
|
logger.debug("WsxRouter connected to DOM");
|
|
74
76
|
|
|
75
77
|
// RFC 0033: 设置浏览器滚动恢复模式
|
|
@@ -103,6 +105,7 @@ export default class WsxRouter extends LightComponent {
|
|
|
103
105
|
}
|
|
104
106
|
|
|
105
107
|
protected onDisconnected() {
|
|
108
|
+
super.onDisconnected?.();
|
|
106
109
|
window.removeEventListener("popstate", this.handleRouteChange);
|
|
107
110
|
}
|
|
108
111
|
|
package/src/WsxView.wsx
CHANGED
|
@@ -48,6 +48,7 @@ export default class WsxView extends LightComponent {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
protected onConnected() {
|
|
51
|
+
super.onConnected?.();
|
|
51
52
|
// 延迟加载,避免在 connectedCallback 中同步执行
|
|
52
53
|
requestAnimationFrame(() => {
|
|
53
54
|
// 重新检查,防止在延迟期间已经加载
|
|
@@ -138,6 +139,7 @@ export default class WsxView extends LightComponent {
|
|
|
138
139
|
}
|
|
139
140
|
|
|
140
141
|
protected onDisconnected() {
|
|
142
|
+
super.onDisconnected?.();
|
|
141
143
|
// 清理组件实例
|
|
142
144
|
if (this.componentInstance) {
|
|
143
145
|
this.componentInstance.remove();
|