@wsxjs/wsx-router 0.0.13 → 0.0.14
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 +248 -249
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("@wsxjs/wsx-core"),nt=":host{display:block;width:100%;height:100%}.router-outlet{width:100%;height:100%}";var ft;let pt,vt;function Y(r,t,e){return(t=mt(t))in r?Object.defineProperty(r,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):r[t]=e,r}function xt(r,t,e,n,g,R){function C(i,c,u){return function(s,a){return u&&u(s),i[c].call(s,a)}}function O(i,c){for(var u=0;u<i.length;u++)i[u].call(c);return c}function b(i,c,u,s){if(typeof i!="function"&&(s||i!==void 0))throw new TypeError(c+" must "+(u||"be")+" a function"+(s?"":" or undefined"));return i}function T(i,c,u,s,a,$,L,j,N,y,m,f,p){function w(l){if(!p(l))throw new TypeError("Attempted to access private element on non-instance")}var h,x=c[0],k=c[3],_=!j;if(!_){u||Array.isArray(x)||(x=[x]);var o={},E=[],v=a===3?"get":a===4||f?"set":"value";y?(m||f?o={get:it(function(){return k(this)},s,"get"),set:function(l){c[4](this,l)}}:o[v]=k,m||it(o[v],s,a===2?"":v)):m||(o=Object.getOwnPropertyDescriptor(i,s))}for(var d=i,P=x.length-1;P>=0;P-=u?2:1){var H=x[P],K=u?x[P-1]:void 0,Q={},W={kind:["field","accessor","method","getter","setter","class"][a],name:s,metadata:$,addInitializer:(function(l,S){if(l.v)throw Error("attempted to call addInitializer after decoration was finished");b(S,"An initializer","be",!0),L.push(S)}).bind(null,Q)};try{if(_)(h=b(H.call(K,d,W),"class decorators","return"))&&(d=h);else{var A,z;W.static=N,W.private=y,y?a===2?A=function(l){return w(l),o.value}:(a<4&&(A=C(o,"get",w)),a!==3&&(z=C(o,"set",w))):(A=function(l){return l[s]},(a<2||a===4)&&(z=function(l,S){l[s]=S}));var J=W.access={has:y?p.bind():function(l){return s in l}};if(A&&(J.get=A),z&&(J.set=z),d=H.call(K,f?{get:o.get,set:o.set}:o[v],W),f){if(typeof d=="object"&&d)(h=b(d.get,"accessor.get"))&&(o.get=h),(h=b(d.set,"accessor.set"))&&(o.set=h),(h=b(d.init,"accessor.init"))&&E.push(h);else if(d!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0")}else b(d,(m?"field":"method")+" decorators","return")&&(m?E.push(d):o[v]=d)}}finally{Q.v=!0}}return(m||f)&&j.push(function(l,S){for(var V=E.length-1;V>=0;V--)S=E[V].call(l,S);return S}),m||_||(y?f?j.push(C(o,"get"),C(o,"set")):j.push(a===2?o[v]:C.call.bind(o[v])):Object.defineProperty(i,s,o)),d}function U(i,c){return Object.defineProperty(i,Symbol.metadata||Symbol.for("Symbol.metadata"),{configurable:!0,enumerable:!0,value:c})}if(arguments.length>=6)var q=R[Symbol.metadata||Symbol.for("Symbol.metadata")];var D=Object.create(q??null),X=function(i,c,u,s){var a,$,L=[],j=function(v){return Et(v)===i},N=new Map;function y(v){v&&L.push(O.bind(null,v))}for(var m=0;m<c.length;m++){var f=c[m];if(Array.isArray(f)){var p=f[1],w=f[2],h=f.length>3,x=16&p,k=!!(8&p),_=(p&=7)==0,o=w+"/"+k;if(!_&&!h){var E=N.get(o);if(E===!0||E===3&&p!==4||E===4&&p!==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: "+w);N.set(o,!(p>2)||p)}T(k?i:i.prototype,f,x,h?"#"+w:mt(w),p,s,k?$=$||[]:a=a||[],L,k,h,_,p===1,k&&h?j:u)}}return y(a),y($),L}(r,t,g,D);return e.length||U(r,D),{e:X,get c(){var i=[];return e.length&&[U(T(r,[e],n,r.name,5,D,i),D),O.bind(null,i,r)]}}}function mt(r){var t=kt(r,"string");return typeof t=="symbol"?t:t+""}function kt(r,t){if(typeof r!="object"||!r)return r;var e=r[Symbol.toPrimitive];if(e!==void 0){var n=e.call(r,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(r)}function it(r,t,e){typeof t=="symbol"&&(t=(t=t.description)?"["+t+"]":"");try{Object.defineProperty(r,"name",{configurable:!0,value:e?e+" "+t:t})}catch{}return r}function Et(r){if(Object(r)!==r)throw TypeError("right-hand side of 'in' should be an object, got "+(r!==null?typeof r:"null"));return r}const B=I.createLogger("WsxRouter");vt=[I.autoRegister({tagName:"wsx-router"})];exports.WsxRouter=void 0;class St extends I.LightComponent{constructor(){super({styles:nt,styleName:"wsx-router"}),Y(this,"_autoStyles",nt),Y(this,"views",new Map),Y(this,"currentView",null),Y(this,"handleRouteChange",()=>{const t=window.location.pathname;B.debug(`Route changed to: ${t}`),this.currentView&&(this.currentView.style.display="none",B.debug("Hiding previous view"));const e=this.matchRoute(t);if(e){e.style.display="block",this.currentView=e,B.debug(`Showing view for route: ${e.getAttribute("route")}`);const n=this.extractParams(e.getAttribute("route")||"/",t);n&&e.setAttribute("params",JSON.stringify(n))}else B.warn(`No view found for path: ${t}`);this.dispatchEvent(new CustomEvent("route-changed",{detail:{path:t,view:e},bubbles:!0,composed:!0}))}),Y(this,"interceptLinks",t=>{const e=t.target.closest("a");if(!e)return;const n=e.getAttribute("href");!n||n.startsWith("http")||n.startsWith("#")||(t.preventDefault(),this.navigate(n))})}render(){return I.jsx("div",{class:"router-outlet"})}onConnected(){B.debug("WsxRouter connected to DOM"),this.collectViews(),B.debug("WsxRouter collected views:",this.views.size),window.addEventListener("popstate",this.handleRouteChange),this.addEventListener("click",this.interceptLinks),this.handleRouteChange()}onDisconnected(){window.removeEventListener("popstate",this.handleRouteChange)}collectViews(){const t=Array.from(this.children).filter(e=>e.tagName.toLowerCase()==="wsx-view");B.debug("WsxRouter found views:",t.length),t.forEach(e=>{const n=e.getAttribute("route")||"/";this.views.set(n,e),e.style.display="none",B.debug(`WsxRouter hiding view for route: ${n}`)})}matchRoute(t){if(this.views.has(t))return this.views.get(t);for(const[e,n]of this.views)if(e.includes(":")){const g=e.replace(/:[^/]+/g,"([^/]+)");if(new RegExp(`^${g}$`).test(t))return n}return this.views.get("*")||null}extractParams(t,e){var b;if(!t.includes(":"))return null;const n=((b=t.match(/:([^/]+)/g))==null?void 0:b.map(T=>T.slice(1)))||[],g=t.replace(/:[^/]+/g,"([^/]+)"),R=new RegExp(`^${g}$`),C=e.match(R);if(!C||!n.length)return null;const O={};return n.forEach((T,U)=>{O[T]=C[U+1]}),O}navigate(t){window.history.pushState(null,"",t),this.handleRouteChange()}}ft=St;[exports.WsxRouter,pt]=xt(ft,[],vt,0,void 0,I.LightComponent).c;pt();const ot=":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 Z,F;let st,gt,at;function G(r,t,e){return(t=bt(t))in r?Object.defineProperty(r,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):r[t]=e,r}function Ct(r,t,e,n,g,R){function C(i,c,u){return function(s,a){return u&&u(s),i[c].call(s,a)}}function O(i,c){for(var u=0;u<i.length;u++)i[u].call(c);return c}function b(i,c,u,s){if(typeof i!="function"&&(s||i!==void 0))throw new TypeError(c+" must "+(u||"be")+" a function"+(s?"":" or undefined"));return i}function T(i,c,u,s,a,$,L,j,N,y,m,f,p){function w(l){if(!p(l))throw new TypeError("Attempted to access private element on non-instance")}var h,x=c[0],k=c[3],_=!j;if(!_){u||Array.isArray(x)||(x=[x]);var o={},E=[],v=a===3?"get":a===4||f?"set":"value";y?(m||f?o={get:ct(function(){return k(this)},s,"get"),set:function(l){c[4](this,l)}}:o[v]=k,m||ct(o[v],s,a===2?"":v)):m||(o=Object.getOwnPropertyDescriptor(i,s))}for(var d=i,P=x.length-1;P>=0;P-=u?2:1){var H=x[P],K=u?x[P-1]:void 0,Q={},W={kind:["field","accessor","method","getter","setter","class"][a],name:s,metadata:$,addInitializer:(function(l,S){if(l.v)throw Error("attempted to call addInitializer after decoration was finished");b(S,"An initializer","be",!0),L.push(S)}).bind(null,Q)};try{if(_)(h=b(H.call(K,d,W),"class decorators","return"))&&(d=h);else{var A,z;W.static=N,W.private=y,y?a===2?A=function(l){return w(l),o.value}:(a<4&&(A=C(o,"get",w)),a!==3&&(z=C(o,"set",w))):(A=function(l){return l[s]},(a<2||a===4)&&(z=function(l,S){l[s]=S}));var J=W.access={has:y?p.bind():function(l){return s in l}};if(A&&(J.get=A),z&&(J.set=z),d=H.call(K,f?{get:o.get,set:o.set}:o[v],W),f){if(typeof d=="object"&&d)(h=b(d.get,"accessor.get"))&&(o.get=h),(h=b(d.set,"accessor.set"))&&(o.set=h),(h=b(d.init,"accessor.init"))&&E.push(h);else if(d!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0")}else b(d,(m?"field":"method")+" decorators","return")&&(m?E.push(d):o[v]=d)}}finally{Q.v=!0}}return(m||f)&&j.push(function(l,S){for(var V=E.length-1;V>=0;V--)S=E[V].call(l,S);return S}),m||_||(y?f?j.push(C(o,"get"),C(o,"set")):j.push(a===2?o[v]:C.call.bind(o[v])):Object.defineProperty(i,s,o)),d}function U(i,c){return Object.defineProperty(i,Symbol.metadata||Symbol.for("Symbol.metadata"),{configurable:!0,enumerable:!0,value:c})}if(arguments.length>=6)var q=R[Symbol.metadata||Symbol.for("Symbol.metadata")];var D=Object.create(q??null),X=function(i,c,u,s){var a,$,L=[],j=function(v){return jt(v)===i},N=new Map;function y(v){v&&L.push(O.bind(null,v))}for(var m=0;m<c.length;m++){var f=c[m];if(Array.isArray(f)){var p=f[1],w=f[2],h=f.length>3,x=16&p,k=!!(8&p),_=(p&=7)==0,o=w+"/"+k;if(!_&&!h){var E=N.get(o);if(E===!0||E===3&&p!==4||E===4&&p!==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: "+w);N.set(o,!(p>2)||p)}T(k?i:i.prototype,f,x,h?"#"+w:bt(w),p,s,k?$=$||[]:a=a||[],L,k,h,_,p===1,k&&h?j:u)}}return y(a),y($),L}(r,t,g,D);return e.length||U(r,D),{e:X,get c(){var i=[];return e.length&&[U(T(r,[e],n,r.name,5,D,i),D),O.bind(null,i,r)]}}}function bt(r){var t=Rt(r,"string");return typeof t=="symbol"?t:t+""}function Rt(r,t){if(typeof r!="object"||!r)return r;var e=r[Symbol.toPrimitive];if(e!==void 0){var n=e.call(r,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(r)}function ct(r,t,e){typeof t=="symbol"&&(t=(t=t.description)?"["+t+"]":"");try{Object.defineProperty(r,"name",{configurable:!0,value:e?e+" "+t:t})}catch{}return r}function jt(r){if(Object(r)!==r)throw TypeError("right-hand side of 'in' should be an object, got "+(r!==null?typeof r:"null"));return r}function _t(r){return r}const tt=I.createLogger("WsxView");gt=[I.autoRegister({tagName:"wsx-view"})];exports.WsxView=void 0;new(at=(F=class extends I.LightComponent{constructor(){super({styles:ot,styleName:"wsx-view"}),G(this,"_autoStyles",ot),G(this,"component",null),G(this,"params",{}),G(this,"componentInstance",null)}render(){return I.jsx("div",{class:"route-view"})}onConnected(){const t=this.getAttribute("component");t&&!this.componentInstance&&this.loadComponent(t)}onAttributeChanged(t,e,n){if(t==="component"&&n&&!this.componentInstance)this.loadComponent(n);else if(t==="params"&&this.componentInstance)try{this.params=JSON.parse(n),Object.entries(this.params).forEach(([g,R])=>{this.componentInstance.setAttribute(g,R)})}catch(g){tt.error("Failed to parse params:",g)}}async loadComponent(t){if(this.componentInstance&&(this.componentInstance.remove(),this.componentInstance=null),!customElements.get(t)){tt.warn(`Component ${t} not found in customElements registry`);return}this.componentInstance=document.createElement(t),Object.keys(this.params).length>0&&Object.entries(this.params).forEach(([g,R])=>{this.componentInstance.setAttribute(g,R)});const n=this.querySelector(".route-view");n?n.appendChild(this.componentInstance):tt.error("Route view container not found")}onDisconnected(){this.componentInstance&&(this.componentInstance.remove(),this.componentInstance=null)}},[exports.WsxView,st]=Ct(F,[],gt,0,void 0,I.LightComponent).c,F),Z=class extends _t{constructor(){super(exports.WsxView),G(this,"observedAttributes",["route","component","params"]),st()}},G(Z,at,void 0),Z);const $t=':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, #007bff);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 et,rt;let lt,yt,ut;function M(r,t,e){return(t=wt(t))in r?Object.defineProperty(r,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):r[t]=e,r}function Lt(r,t,e,n,g,R){function C(i,c,u){return function(s,a){return u&&u(s),i[c].call(s,a)}}function O(i,c){for(var u=0;u<i.length;u++)i[u].call(c);return c}function b(i,c,u,s){if(typeof i!="function"&&(s||i!==void 0))throw new TypeError(c+" must "+(u||"be")+" a function"+(s?"":" or undefined"));return i}function T(i,c,u,s,a,$,L,j,N,y,m,f,p){function w(l){if(!p(l))throw new TypeError("Attempted to access private element on non-instance")}var h,x=c[0],k=c[3],_=!j;if(!_){u||Array.isArray(x)||(x=[x]);var o={},E=[],v=a===3?"get":a===4||f?"set":"value";y?(m||f?o={get:ht(function(){return k(this)},s,"get"),set:function(l){c[4](this,l)}}:o[v]=k,m||ht(o[v],s,a===2?"":v)):m||(o=Object.getOwnPropertyDescriptor(i,s))}for(var d=i,P=x.length-1;P>=0;P-=u?2:1){var H=x[P],K=u?x[P-1]:void 0,Q={},W={kind:["field","accessor","method","getter","setter","class"][a],name:s,metadata:$,addInitializer:(function(l,S){if(l.v)throw Error("attempted to call addInitializer after decoration was finished");b(S,"An initializer","be",!0),L.push(S)}).bind(null,Q)};try{if(_)(h=b(H.call(K,d,W),"class decorators","return"))&&(d=h);else{var A,z;W.static=N,W.private=y,y?a===2?A=function(l){return w(l),o.value}:(a<4&&(A=C(o,"get",w)),a!==3&&(z=C(o,"set",w))):(A=function(l){return l[s]},(a<2||a===4)&&(z=function(l,S){l[s]=S}));var J=W.access={has:y?p.bind():function(l){return s in l}};if(A&&(J.get=A),z&&(J.set=z),d=H.call(K,f?{get:o.get,set:o.set}:o[v],W),f){if(typeof d=="object"&&d)(h=b(d.get,"accessor.get"))&&(o.get=h),(h=b(d.set,"accessor.set"))&&(o.set=h),(h=b(d.init,"accessor.init"))&&E.push(h);else if(d!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0")}else b(d,(m?"field":"method")+" decorators","return")&&(m?E.push(d):o[v]=d)}}finally{Q.v=!0}}return(m||f)&&j.push(function(l,S){for(var V=E.length-1;V>=0;V--)S=E[V].call(l,S);return S}),m||_||(y?f?j.push(C(o,"get"),C(o,"set")):j.push(a===2?o[v]:C.call.bind(o[v])):Object.defineProperty(i,s,o)),d}function U(i,c){return Object.defineProperty(i,Symbol.metadata||Symbol.for("Symbol.metadata"),{configurable:!0,enumerable:!0,value:c})}if(arguments.length>=6)var q=R[Symbol.metadata||Symbol.for("Symbol.metadata")];var D=Object.create(q??null),X=function(i,c,u,s){var a,$,L=[],j=function(v){return At(v)===i},N=new Map;function y(v){v&&L.push(O.bind(null,v))}for(var m=0;m<c.length;m++){var f=c[m];if(Array.isArray(f)){var p=f[1],w=f[2],h=f.length>3,x=16&p,k=!!(8&p),_=(p&=7)==0,o=w+"/"+k;if(!_&&!h){var E=N.get(o);if(E===!0||E===3&&p!==4||E===4&&p!==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: "+w);N.set(o,!(p>2)||p)}T(k?i:i.prototype,f,x,h?"#"+w:wt(w),p,s,k?$=$||[]:a=a||[],L,k,h,_,p===1,k&&h?j:u)}}return y(a),y($),L}(r,t,g,D);return e.length||U(r,D),{e:X,get c(){var i=[];return e.length&&[U(T(r,[e],n,r.name,5,D,i),D),O.bind(null,i,r)]}}}function wt(r){var t=Wt(r,"string");return typeof t=="symbol"?t:t+""}function Wt(r,t){if(typeof r!="object"||!r)return r;var e=r[Symbol.toPrimitive];if(e!==void 0){var n=e.call(r,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(r)}function ht(r,t,e){typeof t=="symbol"&&(t=(t=t.description)?"["+t+"]":"");try{Object.defineProperty(r,"name",{configurable:!0,value:e?e+" "+t:t})}catch{}return r}function At(r){if(Object(r)!==r)throw TypeError("right-hand side of 'in' should be an object, got "+(r!==null?typeof r:"null"));return r}function It(r){return r}const dt=I.createLogger("WsxLink");yt=[I.autoRegister({tagName:"wsx-link"})];exports.WsxLink=void 0;new(ut=(rt=class extends I.WebComponent{constructor(...t){super(...t),M(this,"_autoStyles",$t),M(this,"to",""),M(this,"replace",!1),M(this,"activeClass","active"),M(this,"exact",!1),M(this,"handleClick",e=>{if(e.preventDefault(),!this.to){dt.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")),dt.debug(`Navigated to: ${this.to}`)}),M(this,"updateActiveState",()=>{var R;const e=window.location.pathname,n=this.exact?e===this.to:e.startsWith(this.to)&&this.to!=="/",g=(R=this.shadowRoot)==null?void 0:R.querySelector("a");g&&(n?(g.classList.add(this.activeClass),this.setAttribute("active","")):(g.classList.remove(this.activeClass),this.removeAttribute("active")))})}render(){return I.jsx("a",{href:this.to,class:"wsx-link",onClick:this.handleClick,part:"link"},I.jsx("slot",null))}onConnected(){this.to=this.getAttribute("to")||"",this.replace=this.hasAttribute("replace"),this.activeClass=this.getAttribute("active-class")||"active",this.exact=this.hasAttribute("exact");const t=this.shadowRoot.querySelector(".wsx-link");t&&(t.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(t,e,n){switch(t){case"to":this.to=n||"",this.rerender(),this.updateActiveState();break;case"replace":this.replace=n!==null&&n!=="false";break;case"active-class":this.activeClass=n||"active",this.updateActiveState();break;case"exact":this.exact=n!==null&&n!=="false",this.updateActiveState();break}}isExternalLink(t){return t.startsWith("http://")||t.startsWith("https://")||t.startsWith("mailto:")||t.startsWith("tel:")}navigate(){this.to&&this.handleClick(new MouseEvent("click",{bubbles:!0,cancelable:!0}))}},[exports.WsxLink,lt]=Lt(rt,[],yt,0,void 0,I.WebComponent).c,rt),et=class extends It{constructor(){super(exports.WsxLink),M(this,"observedAttributes",["to","replace","active-class","exact"]),lt()}},M(et,ut,void 0),et);const Ot=I.createLogger("RouterUtils");class Tt{static navigate(t,e=!1){e?window.history.replaceState(null,"",t):window.history.pushState(null,"",t),window.dispatchEvent(new PopStateEvent("popstate")),Ot.debug(`Navigated to: ${t} (replace: ${e})`)}static getCurrentRoute(){const t=new URL(window.location.href);return{path:t.pathname,params:{},query:Object.fromEntries(t.searchParams.entries()),hash:t.hash.slice(1)}}static parseRoute(t,e){var n;if(t===e)return{route:t,params:{},exact:!0};if(t==="*")return{route:t,params:{},exact:!1};if(t.includes(":")){const g=((n=t.match(/:([^/]+)/g))==null?void 0:n.map(b=>b.slice(1)))||[],R=t.replace(/:[^/]+/g,"([^/]+)"),C=new RegExp(`^${R}$`),O=e.match(C);if(O&&g.length>0){const b={};return g.forEach((T,U)=>{b[T]=O[U+1]}),{route:t,params:b,exact:!0}}}if(t.endsWith("/*")){const g=t.slice(0,-2);if(e.startsWith(g))return{route:t,params:{},exact:!1}}return null}static buildPath(t,e={}){let n=t;return Object.entries(e).forEach(([g,R])=>{n=n.replace(`:${g}`,encodeURIComponent(R))}),n}static isRouteActive(t,e=!1){const n=window.location.pathname;return e?n===t:t==="/"?n==="/":n.startsWith(t)}static getRouteDepth(t){return t.split("/").filter(e=>e.length>0).length}static getParentRoute(t){const e=t.split("/").filter(n=>n.length>0);return e.length<=1?"/":(e.pop(),"/"+e.join("/"))}static joinPaths(...t){return t.map(e=>e.replace(/^\/+|\/+$/g,"")).filter(e=>e.length>0).join("/").replace(/^/,"/")}static isExternalUrl(t){return/^https?:\/\//.test(t)||/^mailto:/.test(t)||/^tel:/.test(t)}static getQueryParam(t){return new URL(window.location.href).searchParams.get(t)}static setQueryParam(t,e,n=!1){const g=new URL(window.location.href);g.searchParams.set(t,e);const R=g.pathname+g.search+g.hash;this.navigate(R,n)}static removeQueryParam(t,e=!1){const n=new URL(window.location.href);n.searchParams.delete(t);const g=n.pathname+n.search+n.hash;this.navigate(g,e)}static goBack(){window.history.back()}static goForward(){window.history.forward()}static replace(t){this.navigate(t,!0)}static getHistoryLength(){return window.history.length}static onRouteChange(t){const e=()=>{const n=this.getCurrentRoute();t(n)};return window.addEventListener("popstate",e),document.addEventListener("route-changed",e),()=>{window.removeEventListener("popstate",e),document.removeEventListener("route-changed",e)}}}exports.RouterUtils=Tt;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("@wsxjs/wsx-core"),nt=":host{display:block;width:100%;height:100%}.router-outlet{width:100%;height:100%}";var ft;let pt,dt;function X(r,t,e){return(t=mt(t))in r?Object.defineProperty(r,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):r[t]=e,r}function wt(r,t,e,n,v,j){function S(i,c,l){return function(a,o){return l&&l(a),i[c].call(a,o)}}function O(i,c){for(var l=0;l<i.length;l++)i[l].call(c);return c}function y(i,c,l,a){if(typeof i!="function"&&(a||i!==void 0))throw new TypeError(c+" must "+(l||"be")+" a function"+(a?"":" or undefined"));return i}function T(i,c,l,a,o,_,W,L,N,b,g,p,d){function w(u){if(!d(u))throw new TypeError("Attempted to access private element on non-instance")}var h,x=c[0],E=c[3],$=!L;if(!$){l||Array.isArray(x)||(x=[x]);var s={},C=[],m=o===3?"get":o===4||p?"set":"value";b?(g||p?s={get:it(function(){return E(this)},a,"get"),set:function(u){c[4](this,u)}}:s[m]=E,g||it(s[m],a,o===2?"":m)):g||(s=Object.getOwnPropertyDescriptor(i,a))}for(var f=i,P=x.length-1;P>=0;P-=l?2:1){var q=x[P],H=l?x[P-1]:void 0,K={},A={kind:["field","accessor","method","getter","setter","class"][o],name:a,metadata:_,addInitializer:(function(u,R){if(u.v)throw Error("attempted to call addInitializer after decoration was finished");y(R,"An initializer","be",!0),W.push(R)}).bind(null,K)};try{if($)(h=y(q.call(H,f,A),"class decorators","return"))&&(f=h);else{var k,U;A.static=N,A.private=b,b?o===2?k=function(u){return w(u),s.value}:(o<4&&(k=S(s,"get",w)),o!==3&&(U=S(s,"set",w))):(k=function(u){return u[a]},(o<2||o===4)&&(U=function(u,R){u[a]=R}));var Q=A.access={has:b?d.bind():function(u){return a in u}};if(k&&(Q.get=k),U&&(Q.set=U),f=q.call(H,p?{get:s.get,set:s.set}:s[m],A),p){if(typeof f=="object"&&f)(h=y(f.get,"accessor.get"))&&(s.get=h),(h=y(f.set,"accessor.set"))&&(s.set=h),(h=y(f.init,"accessor.init"))&&C.push(h);else if(f!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0")}else y(f,(g?"field":"method")+" decorators","return")&&(g?C.push(f):s[m]=f)}}finally{K.v=!0}}return(g||p)&&L.push(function(u,R){for(var V=C.length-1;V>=0;V--)R=C[V].call(u,R);return R}),g||$||(b?p?L.push(S(s,"get"),S(s,"set")):L.push(o===2?s[m]:S.call.bind(s[m])):Object.defineProperty(i,a,s)),f}function z(i,c){return Object.defineProperty(i,Symbol.metadata||Symbol.for("Symbol.metadata"),{configurable:!0,enumerable:!0,value:c})}if(arguments.length>=6)var M=j[Symbol.metadata||Symbol.for("Symbol.metadata")];var D=Object.create(M??null),G=function(i,c,l,a){var o,_,W=[],L=function(m){return Et(m)===i},N=new Map;function b(m){m&&W.push(O.bind(null,m))}for(var g=0;g<c.length;g++){var p=c[g];if(Array.isArray(p)){var d=p[1],w=p[2],h=p.length>3,x=16&d,E=!!(8&d),$=(d&=7)==0,s=w+"/"+E;if(!$&&!h){var C=N.get(s);if(C===!0||C===3&&d!==4||C===4&&d!==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: "+w);N.set(s,!(d>2)||d)}T(E?i:i.prototype,p,x,h?"#"+w:mt(w),d,a,E?_=_||[]:o=o||[],W,E,h,$,d===1,E&&h?L:l)}}return b(o),b(_),W}(r,t,v,D);return e.length||z(r,D),{e:G,get c(){var i=[];return e.length&&[z(T(r,[e],n,r.name,5,D,i),D),O.bind(null,i,r)]}}}function mt(r){var t=xt(r,"string");return typeof t=="symbol"?t:t+""}function xt(r,t){if(typeof r!="object"||!r)return r;var e=r[Symbol.toPrimitive];if(e!==void 0){var n=e.call(r,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(r)}function it(r,t,e){typeof t=="symbol"&&(t=(t=t.description)?"["+t+"]":"");try{Object.defineProperty(r,"name",{configurable:!0,value:e?e+" "+t:t})}catch{}return r}function Et(r){if(Object(r)!==r)throw TypeError("right-hand side of 'in' should be an object, got "+(r!==null?typeof r:"null"));return r}const J=I.createLogger("WsxRouter");dt=[I.autoRegister({tagName:"wsx-router"})];exports.WsxRouter=void 0;class Ct extends I.LightComponent{constructor(){super({styles:nt,styleName:"wsx-router"}),X(this,"_autoStyles",nt),X(this,"views",new Map),X(this,"currentView",null),X(this,"handleRouteChange",()=>{const t=window.location.pathname;J.debug(`Route changed to: ${t}`),this.currentView&&(this.currentView.style.display="none",J.debug("Hiding previous view"));const e=this.matchRoute(t);if(e){e.style.display="block",this.currentView=e,J.debug(`Showing view for route: ${e.getAttribute("route")}`);const n=this.extractParams(e.getAttribute("route")||"/",t);n&&e.setAttribute("params",JSON.stringify(n))}else J.warn(`No view found for path: ${t}`);this.dispatchEvent(new CustomEvent("route-changed",{detail:{path:t,view:e},bubbles:!0,composed:!0}))}),X(this,"interceptLinks",t=>{const e=t.target.closest("a");if(!e)return;const n=e.getAttribute("href");!n||n.startsWith("http")||n.startsWith("#")||(t.preventDefault(),this.navigate(n))})}render(){return I.jsx("div",{class:"router-outlet"})}onConnected(){J.debug("WsxRouter connected to DOM"),this.collectViews(),J.debug("WsxRouter collected views:",this.views.size),window.addEventListener("popstate",this.handleRouteChange),this.addEventListener("click",this.interceptLinks),this.handleRouteChange()}onDisconnected(){window.removeEventListener("popstate",this.handleRouteChange)}collectViews(){const t=Array.from(this.children).filter(e=>e.tagName.toLowerCase()==="wsx-view");J.debug("WsxRouter found views:",t.length),t.forEach(e=>{const n=e.getAttribute("route")||"/";this.views.set(n,e),e.style.display="none",J.debug(`WsxRouter hiding view for route: ${n}`)})}matchRoute(t){if(this.views.has(t))return this.views.get(t);for(const[e,n]of this.views)if(e.includes(":")){const v=e.replace(/:[^/]+/g,"([^/]+)");if(new RegExp(`^${v}$`).test(t))return n}return this.views.get("*")||null}extractParams(t,e){var y;if(!t.includes(":"))return null;const n=((y=t.match(/:([^/]+)/g))==null?void 0:y.map(T=>T.slice(1)))||[],v=t.replace(/:[^/]+/g,"([^/]+)"),j=new RegExp(`^${v}$`),S=e.match(j);if(!S||!n.length)return null;const O={};return n.forEach((T,z)=>{O[T]=S[z+1]}),O}navigate(t){window.history.pushState(null,"",t),this.handleRouteChange()}}ft=Ct;[exports.WsxRouter,pt]=wt(ft,[],dt,0,void 0,I.LightComponent).c;pt();const Rt=":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 Z,F;let st,gt,at;function Y(r,t,e){return(t=vt(t))in r?Object.defineProperty(r,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):r[t]=e,r}function St(r,t,e,n,v,j){function S(i,c,l){return function(a,o){return l&&l(a),i[c].call(a,o)}}function O(i,c){for(var l=0;l<i.length;l++)i[l].call(c);return c}function y(i,c,l,a){if(typeof i!="function"&&(a||i!==void 0))throw new TypeError(c+" must "+(l||"be")+" a function"+(a?"":" or undefined"));return i}function T(i,c,l,a,o,_,W,L,N,b,g,p,d){function w(u){if(!d(u))throw new TypeError("Attempted to access private element on non-instance")}var h,x=c[0],E=c[3],$=!L;if(!$){l||Array.isArray(x)||(x=[x]);var s={},C=[],m=o===3?"get":o===4||p?"set":"value";b?(g||p?s={get:ot(function(){return E(this)},a,"get"),set:function(u){c[4](this,u)}}:s[m]=E,g||ot(s[m],a,o===2?"":m)):g||(s=Object.getOwnPropertyDescriptor(i,a))}for(var f=i,P=x.length-1;P>=0;P-=l?2:1){var q=x[P],H=l?x[P-1]:void 0,K={},A={kind:["field","accessor","method","getter","setter","class"][o],name:a,metadata:_,addInitializer:(function(u,R){if(u.v)throw Error("attempted to call addInitializer after decoration was finished");y(R,"An initializer","be",!0),W.push(R)}).bind(null,K)};try{if($)(h=y(q.call(H,f,A),"class decorators","return"))&&(f=h);else{var k,U;A.static=N,A.private=b,b?o===2?k=function(u){return w(u),s.value}:(o<4&&(k=S(s,"get",w)),o!==3&&(U=S(s,"set",w))):(k=function(u){return u[a]},(o<2||o===4)&&(U=function(u,R){u[a]=R}));var Q=A.access={has:b?d.bind():function(u){return a in u}};if(k&&(Q.get=k),U&&(Q.set=U),f=q.call(H,p?{get:s.get,set:s.set}:s[m],A),p){if(typeof f=="object"&&f)(h=y(f.get,"accessor.get"))&&(s.get=h),(h=y(f.set,"accessor.set"))&&(s.set=h),(h=y(f.init,"accessor.init"))&&C.push(h);else if(f!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0")}else y(f,(g?"field":"method")+" decorators","return")&&(g?C.push(f):s[m]=f)}}finally{K.v=!0}}return(g||p)&&L.push(function(u,R){for(var V=C.length-1;V>=0;V--)R=C[V].call(u,R);return R}),g||$||(b?p?L.push(S(s,"get"),S(s,"set")):L.push(o===2?s[m]:S.call.bind(s[m])):Object.defineProperty(i,a,s)),f}function z(i,c){return Object.defineProperty(i,Symbol.metadata||Symbol.for("Symbol.metadata"),{configurable:!0,enumerable:!0,value:c})}if(arguments.length>=6)var M=j[Symbol.metadata||Symbol.for("Symbol.metadata")];var D=Object.create(M??null),G=function(i,c,l,a){var o,_,W=[],L=function(m){return Lt(m)===i},N=new Map;function b(m){m&&W.push(O.bind(null,m))}for(var g=0;g<c.length;g++){var p=c[g];if(Array.isArray(p)){var d=p[1],w=p[2],h=p.length>3,x=16&d,E=!!(8&d),$=(d&=7)==0,s=w+"/"+E;if(!$&&!h){var C=N.get(s);if(C===!0||C===3&&d!==4||C===4&&d!==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: "+w);N.set(s,!(d>2)||d)}T(E?i:i.prototype,p,x,h?"#"+w:vt(w),d,a,E?_=_||[]:o=o||[],W,E,h,$,d===1,E&&h?L:l)}}return b(o),b(_),W}(r,t,v,D);return e.length||z(r,D),{e:G,get c(){var i=[];return e.length&&[z(T(r,[e],n,r.name,5,D,i),D),O.bind(null,i,r)]}}}function vt(r){var t=jt(r,"string");return typeof t=="symbol"?t:t+""}function jt(r,t){if(typeof r!="object"||!r)return r;var e=r[Symbol.toPrimitive];if(e!==void 0){var n=e.call(r,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(r)}function ot(r,t,e){typeof t=="symbol"&&(t=(t=t.description)?"["+t+"]":"");try{Object.defineProperty(r,"name",{configurable:!0,value:e?e+" "+t:t})}catch{}return r}function Lt(r){if(Object(r)!==r)throw TypeError("right-hand side of 'in' should be an object, got "+(r!==null?typeof r:"null"));return r}function $t(r){return r}const tt=I.createLogger("WsxView");gt=[I.autoRegister({tagName:"wsx-view"})];exports.WsxView=void 0;new(at=(F=class extends I.LightComponent{constructor(){super({styles:Rt,styleName:"wsx-view"}),Y(this,"component",null),Y(this,"params",{}),Y(this,"componentInstance",null)}render(){return I.jsx("div",{class:"route-view"})}onConnected(){const t=this.getAttribute("component");t&&!this.componentInstance&&this.loadComponent(t)}onAttributeChanged(t,e,n){if(t==="component"&&n&&!this.componentInstance)this.loadComponent(n);else if(t==="params"&&this.componentInstance)try{this.params=JSON.parse(n),Object.entries(this.params).forEach(([v,j])=>{this.componentInstance.setAttribute(v,j)})}catch(v){tt.error("Failed to parse params:",v)}}async loadComponent(t){if(this.componentInstance&&(this.componentInstance.remove(),this.componentInstance=null),!customElements.get(t)){tt.warn(`Component ${t} not found in customElements registry`);return}this.componentInstance=document.createElement(t),Object.keys(this.params).length>0&&Object.entries(this.params).forEach(([v,j])=>{this.componentInstance.setAttribute(v,j)});const n=this.querySelector(".route-view");n?n.appendChild(this.componentInstance):tt.error("Route view container not found")}onDisconnected(){this.componentInstance&&(this.componentInstance.remove(),this.componentInstance=null)}},[exports.WsxView,st]=St(F,[],gt,0,void 0,I.LightComponent).c,F),Z=class extends $t{constructor(){super(exports.WsxView),Y(this,"observedAttributes",["route","component","params"]),st()}},Y(Z,at,void 0),Z);var et,rt;let ct,yt,ut;function B(r,t,e){return(t=bt(t))in r?Object.defineProperty(r,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):r[t]=e,r}function _t(r,t,e,n,v,j){function S(i,c,l){return function(a,o){return l&&l(a),i[c].call(a,o)}}function O(i,c){for(var l=0;l<i.length;l++)i[l].call(c);return c}function y(i,c,l,a){if(typeof i!="function"&&(a||i!==void 0))throw new TypeError(c+" must "+(l||"be")+" a function"+(a?"":" or undefined"));return i}function T(i,c,l,a,o,_,W,L,N,b,g,p,d){function w(u){if(!d(u))throw new TypeError("Attempted to access private element on non-instance")}var h,x=c[0],E=c[3],$=!L;if(!$){l||Array.isArray(x)||(x=[x]);var s={},C=[],m=o===3?"get":o===4||p?"set":"value";b?(g||p?s={get:lt(function(){return E(this)},a,"get"),set:function(u){c[4](this,u)}}:s[m]=E,g||lt(s[m],a,o===2?"":m)):g||(s=Object.getOwnPropertyDescriptor(i,a))}for(var f=i,P=x.length-1;P>=0;P-=l?2:1){var q=x[P],H=l?x[P-1]:void 0,K={},A={kind:["field","accessor","method","getter","setter","class"][o],name:a,metadata:_,addInitializer:(function(u,R){if(u.v)throw Error("attempted to call addInitializer after decoration was finished");y(R,"An initializer","be",!0),W.push(R)}).bind(null,K)};try{if($)(h=y(q.call(H,f,A),"class decorators","return"))&&(f=h);else{var k,U;A.static=N,A.private=b,b?o===2?k=function(u){return w(u),s.value}:(o<4&&(k=S(s,"get",w)),o!==3&&(U=S(s,"set",w))):(k=function(u){return u[a]},(o<2||o===4)&&(U=function(u,R){u[a]=R}));var Q=A.access={has:b?d.bind():function(u){return a in u}};if(k&&(Q.get=k),U&&(Q.set=U),f=q.call(H,p?{get:s.get,set:s.set}:s[m],A),p){if(typeof f=="object"&&f)(h=y(f.get,"accessor.get"))&&(s.get=h),(h=y(f.set,"accessor.set"))&&(s.set=h),(h=y(f.init,"accessor.init"))&&C.push(h);else if(f!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0")}else y(f,(g?"field":"method")+" decorators","return")&&(g?C.push(f):s[m]=f)}}finally{K.v=!0}}return(g||p)&&L.push(function(u,R){for(var V=C.length-1;V>=0;V--)R=C[V].call(u,R);return R}),g||$||(b?p?L.push(S(s,"get"),S(s,"set")):L.push(o===2?s[m]:S.call.bind(s[m])):Object.defineProperty(i,a,s)),f}function z(i,c){return Object.defineProperty(i,Symbol.metadata||Symbol.for("Symbol.metadata"),{configurable:!0,enumerable:!0,value:c})}if(arguments.length>=6)var M=j[Symbol.metadata||Symbol.for("Symbol.metadata")];var D=Object.create(M??null),G=function(i,c,l,a){var o,_,W=[],L=function(m){return At(m)===i},N=new Map;function b(m){m&&W.push(O.bind(null,m))}for(var g=0;g<c.length;g++){var p=c[g];if(Array.isArray(p)){var d=p[1],w=p[2],h=p.length>3,x=16&d,E=!!(8&d),$=(d&=7)==0,s=w+"/"+E;if(!$&&!h){var C=N.get(s);if(C===!0||C===3&&d!==4||C===4&&d!==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: "+w);N.set(s,!(d>2)||d)}T(E?i:i.prototype,p,x,h?"#"+w:bt(w),d,a,E?_=_||[]:o=o||[],W,E,h,$,d===1,E&&h?L:l)}}return b(o),b(_),W}(r,t,v,D);return e.length||z(r,D),{e:G,get c(){var i=[];return e.length&&[z(T(r,[e],n,r.name,5,D,i),D),O.bind(null,i,r)]}}}function bt(r){var t=Wt(r,"string");return typeof t=="symbol"?t:t+""}function Wt(r,t){if(typeof r!="object"||!r)return r;var e=r[Symbol.toPrimitive];if(e!==void 0){var n=e.call(r,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(r)}function lt(r,t,e){typeof t=="symbol"&&(t=(t=t.description)?"["+t+"]":"");try{Object.defineProperty(r,"name",{configurable:!0,value:e?e+" "+t:t})}catch{}return r}function At(r){if(Object(r)!==r)throw TypeError("right-hand side of 'in' should be an object, got "+(r!==null?typeof r:"null"));return r}function kt(r){return r}const ht=I.createLogger("WsxLink");yt=[I.autoRegister({tagName:"wsx-link"})];exports.WsxLink=void 0;new(ut=(rt=class extends I.WebComponent{constructor(...t){super(...t),B(this,"to",""),B(this,"replace",!1),B(this,"activeClass","active"),B(this,"exact",!1),B(this,"handleClick",e=>{if(e.preventDefault(),!this.to){ht.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")),ht.debug(`Navigated to: ${this.to}`)}),B(this,"updateActiveState",()=>{var j;const e=window.location.pathname,n=this.exact?e===this.to:e.startsWith(this.to)&&this.to!=="/",v=(j=this.shadowRoot)==null?void 0:j.querySelector("a");v&&(n?(v.classList.add(this.activeClass),this.setAttribute("active","")):(v.classList.remove(this.activeClass),this.removeAttribute("active")))})}render(){return I.jsx("a",{href:this.to,class:"wsx-link",onClick:this.handleClick,part:"link"},I.jsx("slot",null))}onConnected(){this.to=this.getAttribute("to")||"",this.replace=this.hasAttribute("replace"),this.activeClass=this.getAttribute("active-class")||"active",this.exact=this.hasAttribute("exact");const t=this.shadowRoot.querySelector(".wsx-link");t&&(t.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(t,e,n){switch(t){case"to":this.to=n||"",this.rerender(),this.updateActiveState();break;case"replace":this.replace=n!==null&&n!=="false";break;case"active-class":this.activeClass=n||"active",this.updateActiveState();break;case"exact":this.exact=n!==null&&n!=="false",this.updateActiveState();break}}isExternalLink(t){return t.startsWith("http://")||t.startsWith("https://")||t.startsWith("mailto:")||t.startsWith("tel:")}navigate(){this.to&&this.handleClick(new MouseEvent("click",{bubbles:!0,cancelable:!0}))}},[exports.WsxLink,ct]=_t(rt,[],yt,0,void 0,I.WebComponent).c,rt),et=class extends kt{constructor(){super(exports.WsxLink),B(this,"observedAttributes",["to","replace","active-class","exact"]),ct()}},B(et,ut,void 0),et);const It=I.createLogger("RouterUtils");class Ot{static navigate(t,e=!1){e?window.history.replaceState(null,"",t):window.history.pushState(null,"",t),window.dispatchEvent(new PopStateEvent("popstate")),It.debug(`Navigated to: ${t} (replace: ${e})`)}static getCurrentRoute(){const t=new URL(window.location.href);return{path:t.pathname,params:{},query:Object.fromEntries(t.searchParams.entries()),hash:t.hash.slice(1)}}static parseRoute(t,e){var n;if(t===e)return{route:t,params:{},exact:!0};if(t==="*")return{route:t,params:{},exact:!1};if(t.includes(":")){const v=((n=t.match(/:([^/]+)/g))==null?void 0:n.map(y=>y.slice(1)))||[],j=t.replace(/:[^/]+/g,"([^/]+)"),S=new RegExp(`^${j}$`),O=e.match(S);if(O&&v.length>0){const y={};return v.forEach((T,z)=>{y[T]=O[z+1]}),{route:t,params:y,exact:!0}}}if(t.endsWith("/*")){const v=t.slice(0,-2);if(e.startsWith(v))return{route:t,params:{},exact:!1}}return null}static buildPath(t,e={}){let n=t;return Object.entries(e).forEach(([v,j])=>{n=n.replace(`:${v}`,encodeURIComponent(j))}),n}static isRouteActive(t,e=!1){const n=window.location.pathname;return e?n===t:t==="/"?n==="/":n.startsWith(t)}static getRouteDepth(t){return t.split("/").filter(e=>e.length>0).length}static getParentRoute(t){const e=t.split("/").filter(n=>n.length>0);return e.length<=1?"/":(e.pop(),"/"+e.join("/"))}static joinPaths(...t){return t.map(e=>e.replace(/^\/+|\/+$/g,"")).filter(e=>e.length>0).join("/").replace(/^/,"/")}static isExternalUrl(t){return/^https?:\/\//.test(t)||/^mailto:/.test(t)||/^tel:/.test(t)}static getQueryParam(t){return new URL(window.location.href).searchParams.get(t)}static setQueryParam(t,e,n=!1){const v=new URL(window.location.href);v.searchParams.set(t,e);const j=v.pathname+v.search+v.hash;this.navigate(j,n)}static removeQueryParam(t,e=!1){const n=new URL(window.location.href);n.searchParams.delete(t);const v=n.pathname+n.search+n.hash;this.navigate(v,e)}static goBack(){window.history.back()}static goForward(){window.history.forward()}static replace(t){this.navigate(t,!0)}static getHistoryLength(){return window.history.length}static onRouteChange(t){const e=()=>{const n=this.getCurrentRoute();t(n)};return window.addEventListener("popstate",e),document.addEventListener("route-changed",e),()=>{window.removeEventListener("popstate",e),document.removeEventListener("route-changed",e)}}}exports.RouterUtils=Ot;
|
package/dist/index.js
CHANGED
|
@@ -1,102 +1,102 @@
|
|
|
1
|
-
import { createLogger as F, autoRegister as
|
|
2
|
-
const
|
|
1
|
+
import { createLogger as F, autoRegister as st, LightComponent as Y, jsx as Z, WebComponent as at } from "@wsxjs/wsx-core";
|
|
2
|
+
const ot = ":host{display:block;width:100%;height:100%}.router-outlet{width:100%;height:100%}";
|
|
3
3
|
var yt;
|
|
4
|
-
let
|
|
5
|
-
function
|
|
6
|
-
return (t =
|
|
4
|
+
let bt, wt;
|
|
5
|
+
function G(r, t, e) {
|
|
6
|
+
return (t = xt(t)) in r ? Object.defineProperty(r, t, { value: e, enumerable: !0, configurable: !0, writable: !0 }) : r[t] = e, r;
|
|
7
7
|
}
|
|
8
|
-
function Ct(r, t, e, n, g,
|
|
9
|
-
function _(i, c,
|
|
10
|
-
return function(
|
|
11
|
-
return
|
|
8
|
+
function Ct(r, t, e, n, g, C) {
|
|
9
|
+
function _(i, c, l) {
|
|
10
|
+
return function(a, o) {
|
|
11
|
+
return l && l(a), i[c].call(a, o);
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
14
|
function I(i, c) {
|
|
15
|
-
for (var
|
|
15
|
+
for (var l = 0; l < i.length; l++) i[l].call(c);
|
|
16
16
|
return c;
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
if (typeof i != "function" && (
|
|
18
|
+
function y(i, c, l, a) {
|
|
19
|
+
if (typeof i != "function" && (a || i !== void 0)) throw new TypeError(c + " must " + (l || "be") + " a function" + (a ? "" : " or undefined"));
|
|
20
20
|
return i;
|
|
21
21
|
}
|
|
22
|
-
function O(i, c,
|
|
23
|
-
function w(
|
|
24
|
-
if (!
|
|
22
|
+
function O(i, c, l, a, o, A, W, $, D, b, v, p, d) {
|
|
23
|
+
function w(u) {
|
|
24
|
+
if (!d(u)) throw new TypeError("Attempted to access private element on non-instance");
|
|
25
25
|
}
|
|
26
|
-
var h, x = c[0],
|
|
27
|
-
if (
|
|
28
|
-
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
return
|
|
32
|
-
},
|
|
33
|
-
c[4](this,
|
|
34
|
-
} } :
|
|
26
|
+
var h, x = c[0], E = c[3], j = !$;
|
|
27
|
+
if (!j) {
|
|
28
|
+
l || Array.isArray(x) || (x = [x]);
|
|
29
|
+
var s = {}, R = [], m = o === 3 ? "get" : o === 4 || p ? "set" : "value";
|
|
30
|
+
b ? (v || p ? s = { get: ct(function() {
|
|
31
|
+
return E(this);
|
|
32
|
+
}, a, "get"), set: function(u) {
|
|
33
|
+
c[4](this, u);
|
|
34
|
+
} } : s[m] = E, v || ct(s[m], a, o === 2 ? "" : m)) : v || (s = Object.getOwnPropertyDescriptor(i, a));
|
|
35
35
|
}
|
|
36
|
-
for (var f = i, N = x.length - 1; N >= 0; N -=
|
|
37
|
-
var
|
|
38
|
-
if (
|
|
39
|
-
|
|
40
|
-
}).bind(null,
|
|
36
|
+
for (var f = i, N = x.length - 1; N >= 0; N -= l ? 2 : 1) {
|
|
37
|
+
var M = x[N], H = l ? x[N - 1] : void 0, q = {}, L = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: a, metadata: A, addInitializer: (function(u, S) {
|
|
38
|
+
if (u.v) throw Error("attempted to call addInitializer after decoration was finished");
|
|
39
|
+
y(S, "An initializer", "be", !0), W.push(S);
|
|
40
|
+
}).bind(null, q) };
|
|
41
41
|
try {
|
|
42
|
-
if (
|
|
42
|
+
if (j) (h = y(M.call(H, f, L), "class decorators", "return")) && (f = h);
|
|
43
43
|
else {
|
|
44
|
-
var
|
|
45
|
-
|
|
46
|
-
return w(
|
|
47
|
-
} : (
|
|
48
|
-
return
|
|
49
|
-
}, (
|
|
50
|
-
|
|
44
|
+
var k, P;
|
|
45
|
+
L.static = D, L.private = b, b ? o === 2 ? k = function(u) {
|
|
46
|
+
return w(u), s.value;
|
|
47
|
+
} : (o < 4 && (k = _(s, "get", w)), o !== 3 && (P = _(s, "set", w))) : (k = function(u) {
|
|
48
|
+
return u[a];
|
|
49
|
+
}, (o < 2 || o === 4) && (P = function(u, S) {
|
|
50
|
+
u[a] = S;
|
|
51
51
|
}));
|
|
52
|
-
var
|
|
53
|
-
return
|
|
52
|
+
var K = L.access = { has: b ? d.bind() : function(u) {
|
|
53
|
+
return a in u;
|
|
54
54
|
} };
|
|
55
|
-
if (
|
|
56
|
-
if (typeof f == "object" && f) (h =
|
|
55
|
+
if (k && (K.get = k), P && (K.set = P), f = M.call(H, p ? { get: s.get, set: s.set } : s[m], L), p) {
|
|
56
|
+
if (typeof f == "object" && f) (h = y(f.get, "accessor.get")) && (s.get = h), (h = y(f.set, "accessor.set")) && (s.set = h), (h = y(f.init, "accessor.init")) && R.push(h);
|
|
57
57
|
else if (f !== void 0) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
|
58
|
-
} else
|
|
58
|
+
} else y(f, (v ? "field" : "method") + " decorators", "return") && (v ? R.push(f) : s[m] = f);
|
|
59
59
|
}
|
|
60
60
|
} finally {
|
|
61
|
-
|
|
61
|
+
q.v = !0;
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
return (
|
|
65
|
-
for (var U =
|
|
64
|
+
return (v || p) && $.push(function(u, S) {
|
|
65
|
+
for (var U = R.length - 1; U >= 0; U--) S = R[U].call(u, S);
|
|
66
66
|
return S;
|
|
67
|
-
}),
|
|
67
|
+
}), v || j || (b ? p ? $.push(_(s, "get"), _(s, "set")) : $.push(o === 2 ? s[m] : _.call.bind(s[m])) : Object.defineProperty(i, a, s)), f;
|
|
68
68
|
}
|
|
69
69
|
function z(i, c) {
|
|
70
70
|
return Object.defineProperty(i, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: c });
|
|
71
71
|
}
|
|
72
|
-
if (arguments.length >= 6) var
|
|
73
|
-
var T = Object.create(
|
|
74
|
-
var
|
|
75
|
-
return jt(
|
|
72
|
+
if (arguments.length >= 6) var V = C[Symbol.metadata || Symbol.for("Symbol.metadata")];
|
|
73
|
+
var T = Object.create(V ?? null), B = function(i, c, l, a) {
|
|
74
|
+
var o, A, W = [], $ = function(m) {
|
|
75
|
+
return jt(m) === i;
|
|
76
76
|
}, D = /* @__PURE__ */ new Map();
|
|
77
|
-
function
|
|
78
|
-
|
|
77
|
+
function b(m) {
|
|
78
|
+
m && W.push(I.bind(null, m));
|
|
79
79
|
}
|
|
80
|
-
for (var
|
|
81
|
-
var
|
|
82
|
-
if (Array.isArray(
|
|
83
|
-
var
|
|
84
|
-
if (
|
|
85
|
-
var
|
|
86
|
-
if (
|
|
87
|
-
D.set(
|
|
80
|
+
for (var v = 0; v < c.length; v++) {
|
|
81
|
+
var p = c[v];
|
|
82
|
+
if (Array.isArray(p)) {
|
|
83
|
+
var d = p[1], w = p[2], h = p.length > 3, x = 16 & d, E = !!(8 & d), j = (d &= 7) == 0, s = w + "/" + E;
|
|
84
|
+
if (!j && !h) {
|
|
85
|
+
var R = D.get(s);
|
|
86
|
+
if (R === !0 || R === 3 && d !== 4 || R === 4 && d !== 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: " + w);
|
|
87
|
+
D.set(s, !(d > 2) || d);
|
|
88
88
|
}
|
|
89
|
-
O(
|
|
89
|
+
O(E ? i : i.prototype, p, x, h ? "#" + w : xt(w), d, a, E ? A = A || [] : o = o || [], W, E, h, j, d === 1, E && h ? $ : l);
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
return
|
|
92
|
+
return b(o), b(A), W;
|
|
93
93
|
}(r, t, g, T);
|
|
94
|
-
return e.length || z(r, T), { e:
|
|
94
|
+
return e.length || z(r, T), { e: B, get c() {
|
|
95
95
|
var i = [];
|
|
96
96
|
return e.length && [z(O(r, [e], n, r.name, 5, T, i), T), I.bind(null, i, r)];
|
|
97
97
|
} };
|
|
98
98
|
}
|
|
99
|
-
function
|
|
99
|
+
function xt(r) {
|
|
100
100
|
var t = $t(r, "string");
|
|
101
101
|
return typeof t == "symbol" ? t : t + "";
|
|
102
102
|
}
|
|
@@ -122,26 +122,26 @@ function jt(r) {
|
|
|
122
122
|
if (Object(r) !== r) throw TypeError("right-hand side of 'in' should be an object, got " + (r !== null ? typeof r : "null"));
|
|
123
123
|
return r;
|
|
124
124
|
}
|
|
125
|
-
const
|
|
126
|
-
|
|
125
|
+
const Q = F("WsxRouter");
|
|
126
|
+
wt = [st({
|
|
127
127
|
tagName: "wsx-router"
|
|
128
128
|
})];
|
|
129
129
|
let At;
|
|
130
130
|
class Wt extends Y {
|
|
131
131
|
constructor() {
|
|
132
132
|
super({
|
|
133
|
-
styles:
|
|
133
|
+
styles: ot,
|
|
134
134
|
styleName: "wsx-router"
|
|
135
|
-
}),
|
|
135
|
+
}), G(this, "_autoStyles", ot), G(this, "views", /* @__PURE__ */ new Map()), G(this, "currentView", null), G(this, "handleRouteChange", () => {
|
|
136
136
|
const t = window.location.pathname;
|
|
137
|
-
|
|
137
|
+
Q.debug(`Route changed to: ${t}`), this.currentView && (this.currentView.style.display = "none", Q.debug("Hiding previous view"));
|
|
138
138
|
const e = this.matchRoute(t);
|
|
139
139
|
if (e) {
|
|
140
|
-
e.style.display = "block", this.currentView = e,
|
|
140
|
+
e.style.display = "block", this.currentView = e, Q.debug(`Showing view for route: ${e.getAttribute("route")}`);
|
|
141
141
|
const n = this.extractParams(e.getAttribute("route") || "/", t);
|
|
142
142
|
n && e.setAttribute("params", JSON.stringify(n));
|
|
143
143
|
} else
|
|
144
|
-
|
|
144
|
+
Q.warn(`No view found for path: ${t}`);
|
|
145
145
|
this.dispatchEvent(new CustomEvent("route-changed", {
|
|
146
146
|
detail: {
|
|
147
147
|
path: t,
|
|
@@ -150,7 +150,7 @@ class Wt extends Y {
|
|
|
150
150
|
bubbles: !0,
|
|
151
151
|
composed: !0
|
|
152
152
|
}));
|
|
153
|
-
}),
|
|
153
|
+
}), G(this, "interceptLinks", (t) => {
|
|
154
154
|
const e = t.target.closest("a");
|
|
155
155
|
if (!e) return;
|
|
156
156
|
const n = e.getAttribute("href");
|
|
@@ -161,16 +161,16 @@ class Wt extends Y {
|
|
|
161
161
|
return /* @__PURE__ */ Z("div", { class: "router-outlet" });
|
|
162
162
|
}
|
|
163
163
|
onConnected() {
|
|
164
|
-
|
|
164
|
+
Q.debug("WsxRouter connected to DOM"), this.collectViews(), Q.debug("WsxRouter collected views:", this.views.size), window.addEventListener("popstate", this.handleRouteChange), this.addEventListener("click", this.interceptLinks), this.handleRouteChange();
|
|
165
165
|
}
|
|
166
166
|
onDisconnected() {
|
|
167
167
|
window.removeEventListener("popstate", this.handleRouteChange);
|
|
168
168
|
}
|
|
169
169
|
collectViews() {
|
|
170
170
|
const t = Array.from(this.children).filter((e) => e.tagName.toLowerCase() === "wsx-view");
|
|
171
|
-
|
|
171
|
+
Q.debug("WsxRouter found views:", t.length), t.forEach((e) => {
|
|
172
172
|
const n = e.getAttribute("route") || "/";
|
|
173
|
-
this.views.set(n, e), e.style.display = "none",
|
|
173
|
+
this.views.set(n, e), e.style.display = "none", Q.debug(`WsxRouter hiding view for route: ${n}`);
|
|
174
174
|
});
|
|
175
175
|
}
|
|
176
176
|
matchRoute(t) {
|
|
@@ -185,9 +185,9 @@ class Wt extends Y {
|
|
|
185
185
|
return this.views.get("*") || null;
|
|
186
186
|
}
|
|
187
187
|
extractParams(t, e) {
|
|
188
|
-
var
|
|
188
|
+
var y;
|
|
189
189
|
if (!t.includes(":")) return null;
|
|
190
|
-
const n = ((
|
|
190
|
+
const n = ((y = t.match(/:([^/]+)/g)) == null ? void 0 : y.map((O) => O.slice(1))) || [], g = t.replace(/:[^/]+/g, "([^/]+)"), C = new RegExp(`^${g}$`), _ = e.match(C);
|
|
191
191
|
if (!_ || !n.length) return null;
|
|
192
192
|
const I = {};
|
|
193
193
|
return n.forEach((O, z) => {
|
|
@@ -202,106 +202,106 @@ class Wt extends Y {
|
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
204
|
yt = Wt;
|
|
205
|
-
[At,
|
|
206
|
-
|
|
207
|
-
const
|
|
205
|
+
[At, bt] = Ct(yt, [], wt, 0, void 0, Y).c;
|
|
206
|
+
bt();
|
|
207
|
+
const Lt = ":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}}";
|
|
208
208
|
var tt, et;
|
|
209
|
-
let ut, Et,
|
|
210
|
-
function
|
|
211
|
-
return (t =
|
|
209
|
+
let ut, Et, lt;
|
|
210
|
+
function X(r, t, e) {
|
|
211
|
+
return (t = Rt(t)) in r ? Object.defineProperty(r, t, { value: e, enumerable: !0, configurable: !0, writable: !0 }) : r[t] = e, r;
|
|
212
212
|
}
|
|
213
|
-
function
|
|
214
|
-
function _(i, c,
|
|
215
|
-
return function(
|
|
216
|
-
return
|
|
213
|
+
function kt(r, t, e, n, g, C) {
|
|
214
|
+
function _(i, c, l) {
|
|
215
|
+
return function(a, o) {
|
|
216
|
+
return l && l(a), i[c].call(a, o);
|
|
217
217
|
};
|
|
218
218
|
}
|
|
219
219
|
function I(i, c) {
|
|
220
|
-
for (var
|
|
220
|
+
for (var l = 0; l < i.length; l++) i[l].call(c);
|
|
221
221
|
return c;
|
|
222
222
|
}
|
|
223
|
-
function
|
|
224
|
-
if (typeof i != "function" && (
|
|
223
|
+
function y(i, c, l, a) {
|
|
224
|
+
if (typeof i != "function" && (a || i !== void 0)) throw new TypeError(c + " must " + (l || "be") + " a function" + (a ? "" : " or undefined"));
|
|
225
225
|
return i;
|
|
226
226
|
}
|
|
227
|
-
function O(i, c,
|
|
228
|
-
function w(
|
|
229
|
-
if (!
|
|
227
|
+
function O(i, c, l, a, o, A, W, $, D, b, v, p, d) {
|
|
228
|
+
function w(u) {
|
|
229
|
+
if (!d(u)) throw new TypeError("Attempted to access private element on non-instance");
|
|
230
230
|
}
|
|
231
|
-
var h, x = c[0],
|
|
232
|
-
if (
|
|
233
|
-
|
|
234
|
-
var
|
|
235
|
-
|
|
236
|
-
return
|
|
237
|
-
},
|
|
238
|
-
c[4](this,
|
|
239
|
-
} } :
|
|
231
|
+
var h, x = c[0], E = c[3], j = !$;
|
|
232
|
+
if (!j) {
|
|
233
|
+
l || Array.isArray(x) || (x = [x]);
|
|
234
|
+
var s = {}, R = [], m = o === 3 ? "get" : o === 4 || p ? "set" : "value";
|
|
235
|
+
b ? (v || p ? s = { get: ht(function() {
|
|
236
|
+
return E(this);
|
|
237
|
+
}, a, "get"), set: function(u) {
|
|
238
|
+
c[4](this, u);
|
|
239
|
+
} } : s[m] = E, v || ht(s[m], a, o === 2 ? "" : m)) : v || (s = Object.getOwnPropertyDescriptor(i, a));
|
|
240
240
|
}
|
|
241
|
-
for (var f = i, N = x.length - 1; N >= 0; N -=
|
|
242
|
-
var
|
|
243
|
-
if (
|
|
244
|
-
|
|
245
|
-
}).bind(null,
|
|
241
|
+
for (var f = i, N = x.length - 1; N >= 0; N -= l ? 2 : 1) {
|
|
242
|
+
var M = x[N], H = l ? x[N - 1] : void 0, q = {}, L = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: a, metadata: A, addInitializer: (function(u, S) {
|
|
243
|
+
if (u.v) throw Error("attempted to call addInitializer after decoration was finished");
|
|
244
|
+
y(S, "An initializer", "be", !0), W.push(S);
|
|
245
|
+
}).bind(null, q) };
|
|
246
246
|
try {
|
|
247
|
-
if (
|
|
247
|
+
if (j) (h = y(M.call(H, f, L), "class decorators", "return")) && (f = h);
|
|
248
248
|
else {
|
|
249
|
-
var
|
|
250
|
-
|
|
251
|
-
return w(
|
|
252
|
-
} : (
|
|
253
|
-
return
|
|
254
|
-
}, (
|
|
255
|
-
|
|
249
|
+
var k, P;
|
|
250
|
+
L.static = D, L.private = b, b ? o === 2 ? k = function(u) {
|
|
251
|
+
return w(u), s.value;
|
|
252
|
+
} : (o < 4 && (k = _(s, "get", w)), o !== 3 && (P = _(s, "set", w))) : (k = function(u) {
|
|
253
|
+
return u[a];
|
|
254
|
+
}, (o < 2 || o === 4) && (P = function(u, S) {
|
|
255
|
+
u[a] = S;
|
|
256
256
|
}));
|
|
257
|
-
var
|
|
258
|
-
return
|
|
257
|
+
var K = L.access = { has: b ? d.bind() : function(u) {
|
|
258
|
+
return a in u;
|
|
259
259
|
} };
|
|
260
|
-
if (
|
|
261
|
-
if (typeof f == "object" && f) (h =
|
|
260
|
+
if (k && (K.get = k), P && (K.set = P), f = M.call(H, p ? { get: s.get, set: s.set } : s[m], L), p) {
|
|
261
|
+
if (typeof f == "object" && f) (h = y(f.get, "accessor.get")) && (s.get = h), (h = y(f.set, "accessor.set")) && (s.set = h), (h = y(f.init, "accessor.init")) && R.push(h);
|
|
262
262
|
else if (f !== void 0) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
|
263
|
-
} else
|
|
263
|
+
} else y(f, (v ? "field" : "method") + " decorators", "return") && (v ? R.push(f) : s[m] = f);
|
|
264
264
|
}
|
|
265
265
|
} finally {
|
|
266
|
-
|
|
266
|
+
q.v = !0;
|
|
267
267
|
}
|
|
268
268
|
}
|
|
269
|
-
return (
|
|
270
|
-
for (var U =
|
|
269
|
+
return (v || p) && $.push(function(u, S) {
|
|
270
|
+
for (var U = R.length - 1; U >= 0; U--) S = R[U].call(u, S);
|
|
271
271
|
return S;
|
|
272
|
-
}),
|
|
272
|
+
}), v || j || (b ? p ? $.push(_(s, "get"), _(s, "set")) : $.push(o === 2 ? s[m] : _.call.bind(s[m])) : Object.defineProperty(i, a, s)), f;
|
|
273
273
|
}
|
|
274
274
|
function z(i, c) {
|
|
275
275
|
return Object.defineProperty(i, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: c });
|
|
276
276
|
}
|
|
277
|
-
if (arguments.length >= 6) var
|
|
278
|
-
var T = Object.create(
|
|
279
|
-
var
|
|
280
|
-
return Ot(
|
|
277
|
+
if (arguments.length >= 6) var V = C[Symbol.metadata || Symbol.for("Symbol.metadata")];
|
|
278
|
+
var T = Object.create(V ?? null), B = function(i, c, l, a) {
|
|
279
|
+
var o, A, W = [], $ = function(m) {
|
|
280
|
+
return Ot(m) === i;
|
|
281
281
|
}, D = /* @__PURE__ */ new Map();
|
|
282
|
-
function
|
|
283
|
-
|
|
282
|
+
function b(m) {
|
|
283
|
+
m && W.push(I.bind(null, m));
|
|
284
284
|
}
|
|
285
|
-
for (var
|
|
286
|
-
var
|
|
287
|
-
if (Array.isArray(
|
|
288
|
-
var
|
|
289
|
-
if (
|
|
290
|
-
var
|
|
291
|
-
if (
|
|
292
|
-
D.set(
|
|
285
|
+
for (var v = 0; v < c.length; v++) {
|
|
286
|
+
var p = c[v];
|
|
287
|
+
if (Array.isArray(p)) {
|
|
288
|
+
var d = p[1], w = p[2], h = p.length > 3, x = 16 & d, E = !!(8 & d), j = (d &= 7) == 0, s = w + "/" + E;
|
|
289
|
+
if (!j && !h) {
|
|
290
|
+
var R = D.get(s);
|
|
291
|
+
if (R === !0 || R === 3 && d !== 4 || R === 4 && d !== 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: " + w);
|
|
292
|
+
D.set(s, !(d > 2) || d);
|
|
293
293
|
}
|
|
294
|
-
O(
|
|
294
|
+
O(E ? i : i.prototype, p, x, h ? "#" + w : Rt(w), d, a, E ? A = A || [] : o = o || [], W, E, h, j, d === 1, E && h ? $ : l);
|
|
295
295
|
}
|
|
296
296
|
}
|
|
297
|
-
return
|
|
297
|
+
return b(o), b(A), W;
|
|
298
298
|
}(r, t, g, T);
|
|
299
|
-
return e.length || z(r, T), { e:
|
|
299
|
+
return e.length || z(r, T), { e: B, get c() {
|
|
300
300
|
var i = [];
|
|
301
301
|
return e.length && [z(O(r, [e], n, r.name, 5, T, i), T), I.bind(null, i, r)];
|
|
302
302
|
} };
|
|
303
303
|
}
|
|
304
|
-
function
|
|
304
|
+
function Rt(r) {
|
|
305
305
|
var t = It(r, "string");
|
|
306
306
|
return typeof t == "symbol" ? t : t + "";
|
|
307
307
|
}
|
|
@@ -315,7 +315,7 @@ function It(r, t) {
|
|
|
315
315
|
}
|
|
316
316
|
return (t === "string" ? String : Number)(r);
|
|
317
317
|
}
|
|
318
|
-
function
|
|
318
|
+
function ht(r, t, e) {
|
|
319
319
|
typeof t == "symbol" && (t = (t = t.description) ? "[" + t + "]" : "");
|
|
320
320
|
try {
|
|
321
321
|
Object.defineProperty(r, "name", { configurable: !0, value: e ? e + " " + t : t });
|
|
@@ -331,16 +331,16 @@ function Tt(r) {
|
|
|
331
331
|
return r;
|
|
332
332
|
}
|
|
333
333
|
const rt = F("WsxView");
|
|
334
|
-
Et = [
|
|
334
|
+
Et = [st({
|
|
335
335
|
tagName: "wsx-view"
|
|
336
336
|
})];
|
|
337
|
-
let
|
|
338
|
-
new (
|
|
337
|
+
let ft;
|
|
338
|
+
new (lt = (et = class extends Y {
|
|
339
339
|
constructor() {
|
|
340
340
|
super({
|
|
341
|
-
styles:
|
|
341
|
+
styles: Lt,
|
|
342
342
|
styleName: "wsx-view"
|
|
343
|
-
}),
|
|
343
|
+
}), X(this, "component", null), X(this, "params", {}), X(this, "componentInstance", null);
|
|
344
344
|
}
|
|
345
345
|
render() {
|
|
346
346
|
return /* @__PURE__ */ Z("div", { class: "route-view" });
|
|
@@ -354,8 +354,8 @@ new (ht = (et = class extends Y {
|
|
|
354
354
|
this.loadComponent(n);
|
|
355
355
|
else if (t === "params" && this.componentInstance)
|
|
356
356
|
try {
|
|
357
|
-
this.params = JSON.parse(n), Object.entries(this.params).forEach(([g,
|
|
358
|
-
this.componentInstance.setAttribute(g,
|
|
357
|
+
this.params = JSON.parse(n), Object.entries(this.params).forEach(([g, C]) => {
|
|
358
|
+
this.componentInstance.setAttribute(g, C);
|
|
359
359
|
});
|
|
360
360
|
} catch (g) {
|
|
361
361
|
rt.error("Failed to parse params:", g);
|
|
@@ -366,8 +366,8 @@ new (ht = (et = class extends Y {
|
|
|
366
366
|
rt.warn(`Component ${t} not found in customElements registry`);
|
|
367
367
|
return;
|
|
368
368
|
}
|
|
369
|
-
this.componentInstance = document.createElement(t), Object.keys(this.params).length > 0 && Object.entries(this.params).forEach(([g,
|
|
370
|
-
this.componentInstance.setAttribute(g,
|
|
369
|
+
this.componentInstance = document.createElement(t), Object.keys(this.params).length > 0 && Object.entries(this.params).forEach(([g, C]) => {
|
|
370
|
+
this.componentInstance.setAttribute(g, C);
|
|
371
371
|
});
|
|
372
372
|
const n = this.querySelector(".route-view");
|
|
373
373
|
n ? n.appendChild(this.componentInstance) : rt.error("Route view container not found");
|
|
@@ -375,113 +375,112 @@ new (ht = (et = class extends Y {
|
|
|
375
375
|
onDisconnected() {
|
|
376
376
|
this.componentInstance && (this.componentInstance.remove(), this.componentInstance = null);
|
|
377
377
|
}
|
|
378
|
-
}, [
|
|
378
|
+
}, [ft, ut] = kt(et, [], Et, 0, void 0, Y).c, et), tt = class extends Tt {
|
|
379
379
|
constructor() {
|
|
380
|
-
super(
|
|
380
|
+
super(ft), X(this, "observedAttributes", ["route", "component", "params"]), ut();
|
|
381
381
|
}
|
|
382
|
-
},
|
|
383
|
-
const Dt = ':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, #007bff);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)}';
|
|
382
|
+
}, X(tt, lt, void 0), tt)();
|
|
384
383
|
var nt, it;
|
|
385
|
-
let pt,
|
|
386
|
-
function
|
|
387
|
-
return (t =
|
|
384
|
+
let pt, St, dt;
|
|
385
|
+
function J(r, t, e) {
|
|
386
|
+
return (t = _t(t)) in r ? Object.defineProperty(r, t, { value: e, enumerable: !0, configurable: !0, writable: !0 }) : r[t] = e, r;
|
|
388
387
|
}
|
|
389
|
-
function
|
|
390
|
-
function _(i, c,
|
|
391
|
-
return function(
|
|
392
|
-
return
|
|
388
|
+
function Dt(r, t, e, n, g, C) {
|
|
389
|
+
function _(i, c, l) {
|
|
390
|
+
return function(a, o) {
|
|
391
|
+
return l && l(a), i[c].call(a, o);
|
|
393
392
|
};
|
|
394
393
|
}
|
|
395
394
|
function I(i, c) {
|
|
396
|
-
for (var
|
|
395
|
+
for (var l = 0; l < i.length; l++) i[l].call(c);
|
|
397
396
|
return c;
|
|
398
397
|
}
|
|
399
|
-
function
|
|
400
|
-
if (typeof i != "function" && (
|
|
398
|
+
function y(i, c, l, a) {
|
|
399
|
+
if (typeof i != "function" && (a || i !== void 0)) throw new TypeError(c + " must " + (l || "be") + " a function" + (a ? "" : " or undefined"));
|
|
401
400
|
return i;
|
|
402
401
|
}
|
|
403
|
-
function O(i, c,
|
|
404
|
-
function w(
|
|
405
|
-
if (!
|
|
402
|
+
function O(i, c, l, a, o, A, W, $, D, b, v, p, d) {
|
|
403
|
+
function w(u) {
|
|
404
|
+
if (!d(u)) throw new TypeError("Attempted to access private element on non-instance");
|
|
406
405
|
}
|
|
407
|
-
var h, x = c[0],
|
|
408
|
-
if (
|
|
409
|
-
|
|
410
|
-
var
|
|
411
|
-
|
|
412
|
-
return
|
|
413
|
-
},
|
|
414
|
-
c[4](this,
|
|
415
|
-
} } :
|
|
406
|
+
var h, x = c[0], E = c[3], j = !$;
|
|
407
|
+
if (!j) {
|
|
408
|
+
l || Array.isArray(x) || (x = [x]);
|
|
409
|
+
var s = {}, R = [], m = o === 3 ? "get" : o === 4 || p ? "set" : "value";
|
|
410
|
+
b ? (v || p ? s = { get: mt(function() {
|
|
411
|
+
return E(this);
|
|
412
|
+
}, a, "get"), set: function(u) {
|
|
413
|
+
c[4](this, u);
|
|
414
|
+
} } : s[m] = E, v || mt(s[m], a, o === 2 ? "" : m)) : v || (s = Object.getOwnPropertyDescriptor(i, a));
|
|
416
415
|
}
|
|
417
|
-
for (var f = i, N = x.length - 1; N >= 0; N -=
|
|
418
|
-
var
|
|
419
|
-
if (
|
|
420
|
-
|
|
421
|
-
}).bind(null,
|
|
416
|
+
for (var f = i, N = x.length - 1; N >= 0; N -= l ? 2 : 1) {
|
|
417
|
+
var M = x[N], H = l ? x[N - 1] : void 0, q = {}, L = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: a, metadata: A, addInitializer: (function(u, S) {
|
|
418
|
+
if (u.v) throw Error("attempted to call addInitializer after decoration was finished");
|
|
419
|
+
y(S, "An initializer", "be", !0), W.push(S);
|
|
420
|
+
}).bind(null, q) };
|
|
422
421
|
try {
|
|
423
|
-
if (
|
|
422
|
+
if (j) (h = y(M.call(H, f, L), "class decorators", "return")) && (f = h);
|
|
424
423
|
else {
|
|
425
|
-
var
|
|
426
|
-
|
|
427
|
-
return w(
|
|
428
|
-
} : (
|
|
429
|
-
return
|
|
430
|
-
}, (
|
|
431
|
-
|
|
424
|
+
var k, P;
|
|
425
|
+
L.static = D, L.private = b, b ? o === 2 ? k = function(u) {
|
|
426
|
+
return w(u), s.value;
|
|
427
|
+
} : (o < 4 && (k = _(s, "get", w)), o !== 3 && (P = _(s, "set", w))) : (k = function(u) {
|
|
428
|
+
return u[a];
|
|
429
|
+
}, (o < 2 || o === 4) && (P = function(u, S) {
|
|
430
|
+
u[a] = S;
|
|
432
431
|
}));
|
|
433
|
-
var
|
|
434
|
-
return
|
|
432
|
+
var K = L.access = { has: b ? d.bind() : function(u) {
|
|
433
|
+
return a in u;
|
|
435
434
|
} };
|
|
436
|
-
if (
|
|
437
|
-
if (typeof f == "object" && f) (h =
|
|
435
|
+
if (k && (K.get = k), P && (K.set = P), f = M.call(H, p ? { get: s.get, set: s.set } : s[m], L), p) {
|
|
436
|
+
if (typeof f == "object" && f) (h = y(f.get, "accessor.get")) && (s.get = h), (h = y(f.set, "accessor.set")) && (s.set = h), (h = y(f.init, "accessor.init")) && R.push(h);
|
|
438
437
|
else if (f !== void 0) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
|
439
|
-
} else
|
|
438
|
+
} else y(f, (v ? "field" : "method") + " decorators", "return") && (v ? R.push(f) : s[m] = f);
|
|
440
439
|
}
|
|
441
440
|
} finally {
|
|
442
|
-
|
|
441
|
+
q.v = !0;
|
|
443
442
|
}
|
|
444
443
|
}
|
|
445
|
-
return (
|
|
446
|
-
for (var U =
|
|
444
|
+
return (v || p) && $.push(function(u, S) {
|
|
445
|
+
for (var U = R.length - 1; U >= 0; U--) S = R[U].call(u, S);
|
|
447
446
|
return S;
|
|
448
|
-
}),
|
|
447
|
+
}), v || j || (b ? p ? $.push(_(s, "get"), _(s, "set")) : $.push(o === 2 ? s[m] : _.call.bind(s[m])) : Object.defineProperty(i, a, s)), f;
|
|
449
448
|
}
|
|
450
449
|
function z(i, c) {
|
|
451
450
|
return Object.defineProperty(i, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: c });
|
|
452
451
|
}
|
|
453
|
-
if (arguments.length >= 6) var
|
|
454
|
-
var T = Object.create(
|
|
455
|
-
var
|
|
456
|
-
return
|
|
452
|
+
if (arguments.length >= 6) var V = C[Symbol.metadata || Symbol.for("Symbol.metadata")];
|
|
453
|
+
var T = Object.create(V ?? null), B = function(i, c, l, a) {
|
|
454
|
+
var o, A, W = [], $ = function(m) {
|
|
455
|
+
return Pt(m) === i;
|
|
457
456
|
}, D = /* @__PURE__ */ new Map();
|
|
458
|
-
function
|
|
459
|
-
|
|
457
|
+
function b(m) {
|
|
458
|
+
m && W.push(I.bind(null, m));
|
|
460
459
|
}
|
|
461
|
-
for (var
|
|
462
|
-
var
|
|
463
|
-
if (Array.isArray(
|
|
464
|
-
var
|
|
465
|
-
if (
|
|
466
|
-
var
|
|
467
|
-
if (
|
|
468
|
-
D.set(
|
|
460
|
+
for (var v = 0; v < c.length; v++) {
|
|
461
|
+
var p = c[v];
|
|
462
|
+
if (Array.isArray(p)) {
|
|
463
|
+
var d = p[1], w = p[2], h = p.length > 3, x = 16 & d, E = !!(8 & d), j = (d &= 7) == 0, s = w + "/" + E;
|
|
464
|
+
if (!j && !h) {
|
|
465
|
+
var R = D.get(s);
|
|
466
|
+
if (R === !0 || R === 3 && d !== 4 || R === 4 && d !== 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: " + w);
|
|
467
|
+
D.set(s, !(d > 2) || d);
|
|
469
468
|
}
|
|
470
|
-
O(
|
|
469
|
+
O(E ? i : i.prototype, p, x, h ? "#" + w : _t(w), d, a, E ? A = A || [] : o = o || [], W, E, h, j, d === 1, E && h ? $ : l);
|
|
471
470
|
}
|
|
472
471
|
}
|
|
473
|
-
return
|
|
472
|
+
return b(o), b(A), W;
|
|
474
473
|
}(r, t, g, T);
|
|
475
|
-
return e.length || z(r, T), { e:
|
|
474
|
+
return e.length || z(r, T), { e: B, get c() {
|
|
476
475
|
var i = [];
|
|
477
476
|
return e.length && [z(O(r, [e], n, r.name, 5, T, i), T), I.bind(null, i, r)];
|
|
478
477
|
} };
|
|
479
478
|
}
|
|
480
|
-
function
|
|
481
|
-
var t =
|
|
479
|
+
function _t(r) {
|
|
480
|
+
var t = Nt(r, "string");
|
|
482
481
|
return typeof t == "symbol" ? t : t + "";
|
|
483
482
|
}
|
|
484
|
-
function
|
|
483
|
+
function Nt(r, t) {
|
|
485
484
|
if (typeof r != "object" || !r) return r;
|
|
486
485
|
var e = r[Symbol.toPrimitive];
|
|
487
486
|
if (e !== void 0) {
|
|
@@ -499,33 +498,33 @@ function mt(r, t, e) {
|
|
|
499
498
|
}
|
|
500
499
|
return r;
|
|
501
500
|
}
|
|
502
|
-
function
|
|
501
|
+
function Pt(r) {
|
|
503
502
|
if (Object(r) !== r) throw TypeError("right-hand side of 'in' should be an object, got " + (r !== null ? typeof r : "null"));
|
|
504
503
|
return r;
|
|
505
504
|
}
|
|
506
|
-
function
|
|
505
|
+
function zt(r) {
|
|
507
506
|
return r;
|
|
508
507
|
}
|
|
509
|
-
const
|
|
510
|
-
|
|
508
|
+
const vt = F("WsxLink");
|
|
509
|
+
St = [st({
|
|
511
510
|
tagName: "wsx-link"
|
|
512
511
|
})];
|
|
513
|
-
let
|
|
514
|
-
new (
|
|
512
|
+
let gt;
|
|
513
|
+
new (dt = (it = class extends at {
|
|
515
514
|
constructor(...t) {
|
|
516
|
-
super(...t),
|
|
515
|
+
super(...t), J(this, "to", ""), J(this, "replace", !1), J(this, "activeClass", "active"), J(this, "exact", !1), J(this, "handleClick", (e) => {
|
|
517
516
|
if (e.preventDefault(), !this.to) {
|
|
518
|
-
|
|
517
|
+
vt.warn("No 'to' attribute specified");
|
|
519
518
|
return;
|
|
520
519
|
}
|
|
521
520
|
if (this.isExternalLink(this.to)) {
|
|
522
521
|
window.open(this.to, "_blank");
|
|
523
522
|
return;
|
|
524
523
|
}
|
|
525
|
-
this.replace ? window.history.replaceState(null, "", this.to) : window.history.pushState(null, "", this.to), window.dispatchEvent(new PopStateEvent("popstate")),
|
|
526
|
-
}),
|
|
527
|
-
var
|
|
528
|
-
const e = window.location.pathname, n = this.exact ? e === this.to : e.startsWith(this.to) && this.to !== "/", g = (
|
|
524
|
+
this.replace ? window.history.replaceState(null, "", this.to) : window.history.pushState(null, "", this.to), window.dispatchEvent(new PopStateEvent("popstate")), vt.debug(`Navigated to: ${this.to}`);
|
|
525
|
+
}), J(this, "updateActiveState", () => {
|
|
526
|
+
var C;
|
|
527
|
+
const e = window.location.pathname, n = this.exact ? e === this.to : e.startsWith(this.to) && this.to !== "/", g = (C = this.shadowRoot) == null ? void 0 : C.querySelector("a");
|
|
529
528
|
g && (n ? (g.classList.add(this.activeClass), this.setAttribute("active", "")) : (g.classList.remove(this.activeClass), this.removeAttribute("active")));
|
|
530
529
|
});
|
|
531
530
|
}
|
|
@@ -568,18 +567,18 @@ new (vt = (it = class extends st {
|
|
|
568
567
|
cancelable: !0
|
|
569
568
|
}));
|
|
570
569
|
}
|
|
571
|
-
}, [
|
|
570
|
+
}, [gt, pt] = Dt(it, [], St, 0, void 0, at).c, it), nt = class extends zt {
|
|
572
571
|
constructor() {
|
|
573
|
-
super(
|
|
572
|
+
super(gt), J(this, "observedAttributes", ["to", "replace", "active-class", "exact"]), pt();
|
|
574
573
|
}
|
|
575
|
-
},
|
|
576
|
-
const
|
|
577
|
-
class
|
|
574
|
+
}, J(nt, dt, void 0), nt)();
|
|
575
|
+
const Ut = F("RouterUtils");
|
|
576
|
+
class qt {
|
|
578
577
|
/**
|
|
579
578
|
* 编程式导航
|
|
580
579
|
*/
|
|
581
580
|
static navigate(t, e = !1) {
|
|
582
|
-
e ? window.history.replaceState(null, "", t) : window.history.pushState(null, "", t), window.dispatchEvent(new PopStateEvent("popstate")),
|
|
581
|
+
e ? window.history.replaceState(null, "", t) : window.history.pushState(null, "", t), window.dispatchEvent(new PopStateEvent("popstate")), Ut.debug(`Navigated to: ${t} (replace: ${e})`);
|
|
583
582
|
}
|
|
584
583
|
/**
|
|
585
584
|
* 获取当前路由信息
|
|
@@ -613,14 +612,14 @@ class Kt {
|
|
|
613
612
|
exact: !1
|
|
614
613
|
};
|
|
615
614
|
if (t.includes(":")) {
|
|
616
|
-
const g = ((n = t.match(/:([^/]+)/g)) == null ? void 0 : n.map((
|
|
615
|
+
const g = ((n = t.match(/:([^/]+)/g)) == null ? void 0 : n.map((y) => y.slice(1))) || [], C = t.replace(/:[^/]+/g, "([^/]+)"), _ = new RegExp(`^${C}$`), I = e.match(_);
|
|
617
616
|
if (I && g.length > 0) {
|
|
618
|
-
const
|
|
617
|
+
const y = {};
|
|
619
618
|
return g.forEach((O, z) => {
|
|
620
|
-
|
|
619
|
+
y[O] = I[z + 1];
|
|
621
620
|
}), {
|
|
622
621
|
route: t,
|
|
623
|
-
params:
|
|
622
|
+
params: y,
|
|
624
623
|
exact: !0
|
|
625
624
|
};
|
|
626
625
|
}
|
|
@@ -641,8 +640,8 @@ class Kt {
|
|
|
641
640
|
*/
|
|
642
641
|
static buildPath(t, e = {}) {
|
|
643
642
|
let n = t;
|
|
644
|
-
return Object.entries(e).forEach(([g,
|
|
645
|
-
n = n.replace(`:${g}`, encodeURIComponent(
|
|
643
|
+
return Object.entries(e).forEach(([g, C]) => {
|
|
644
|
+
n = n.replace(`:${g}`, encodeURIComponent(C));
|
|
646
645
|
}), n;
|
|
647
646
|
}
|
|
648
647
|
/**
|
|
@@ -689,8 +688,8 @@ class Kt {
|
|
|
689
688
|
static setQueryParam(t, e, n = !1) {
|
|
690
689
|
const g = new URL(window.location.href);
|
|
691
690
|
g.searchParams.set(t, e);
|
|
692
|
-
const
|
|
693
|
-
this.navigate(
|
|
691
|
+
const C = g.pathname + g.search + g.hash;
|
|
692
|
+
this.navigate(C, n);
|
|
694
693
|
}
|
|
695
694
|
/**
|
|
696
695
|
* 删除查询参数
|
|
@@ -739,8 +738,8 @@ class Kt {
|
|
|
739
738
|
}
|
|
740
739
|
}
|
|
741
740
|
export {
|
|
742
|
-
|
|
743
|
-
|
|
741
|
+
qt as RouterUtils,
|
|
742
|
+
gt as WsxLink,
|
|
744
743
|
At as WsxRouter,
|
|
745
|
-
|
|
744
|
+
ft as WsxView
|
|
746
745
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wsxjs/wsx-router",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.14",
|
|
4
4
|
"description": "WSX Router - Native History API-based routing for WSX Framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"!**/test"
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@wsxjs/wsx-core": "0.0.
|
|
21
|
+
"@wsxjs/wsx-core": "0.0.14"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@typescript-eslint/eslint-plugin": "^8.37.0",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"typescript": "^5.0.0",
|
|
31
31
|
"vite": "^5.4.19",
|
|
32
32
|
"vitest": "^2.1.8",
|
|
33
|
-
"@wsxjs/
|
|
34
|
-
"@wsxjs/
|
|
33
|
+
"@wsxjs/wsx-vite-plugin": "0.0.14",
|
|
34
|
+
"@wsxjs/eslint-plugin-wsx": "0.0.14"
|
|
35
35
|
},
|
|
36
36
|
"keywords": [
|
|
37
37
|
"wsx",
|