@umbraco-cms/backoffice 14.0.0--preview004-47909c4f → 14.0.0--preview004-93eb55a0
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
const C="**",P="\\.\\.\\/",A=/:([^\\/]+)/g,E="router-slot",f=window,m="native",T="prefix";function L(t,e){t.dispatchEvent(new CustomEvent("changestate",{detail:e}))}function o(t,e){f.dispatchEvent(new CustomEvent(t,{detail:e}))}function g(t,e,n,r){const s=Array.isArray(e)?e:[e];return s.forEach(a=>t.addEventListener(a,n,r)),()=>s.forEach(a=>t.removeEventListener(a,n,r))}function $(t){t.forEach(e=>e())}const S=[["pushState",["pushstate","changestate"]],["replaceState",["replacestate","changestate"]],["forward",["pushstate","changestate"]],["go",["pushstate","changestate"]],["back",["popstate"]]];function b(){for(const[t,e]of S)for(const n of e)M(history,t,n);window.addEventListener("popstate",t=>{if(x({eventName:"popstate"})){t.preventDefault(),t.stopPropagation();return}setTimeout(()=>o("changestate"),0)})}function M(t,e,n){const r=t[e];N(t,e,r),t[e]=(...s)=>{const a=s.length>2?s[2]:null;x({url:a,eventName:n})||(r.apply(t,s),o(n))}}function N(t,e,n){t[m]==null&&(t[m]={}),t[m][`${e}`]=n.bind(t)}function x(t){return!f.dispatchEvent(new CustomEvent("willchangestate",{cancelable:!0,detail:t}))}const H=document.createElement("a");function v(t={}){return p(window.location.pathname,t)}function W(t={}){return p(k(v(),I()),t)}function I(t={}){return R(".",t)}function R(t,e={}){return H.href=t,p(H.pathname,e)}function k(t,e){return t.replace(new RegExp(`^${e}`),"")}function _(){return window.location.search}function Z(){return q(_().substr(1))}function d(t){return p(t,{start:!1,end:!1})}function tt(t){return p(t,{start:!0,end:!0})}function p(t,{start:e=!0,end:n=!0}={}){return t=e&&!t.startsWith("/")?`/${t}`:!e&&t.startsWith("/")?t.slice(1):t,n&&!t.endsWith("/")?`${t}/`:!n&&t.endsWith("/")?t.slice(0,t.length-1):t}function q(t){if(t.length===0)return{};const e=t.split("&").map(n=>n.split("="));return Object.assign({},...e.map(n=>({[decodeURIComponent(n[0])]:n.length>1?decodeURIComponent(n[1]):""})))}function et(t){return Object.entries(t).map(([e,n])=>`${e}${n!=""?`=${encodeURIComponent(n)}`:""}`).join("&")}function nt(t,e=v()){return new RegExp(`^${d(t)}(/|$)`,"gm").test(d(e))}function F(t,e){const n=[],r=d(t.path.replace(A,(i,...u)=>(n.push(u[0]),"([^/]+)"))),s=t.path===C||t.path.length===0&&t.pathMatch!="full"?/^/:(()=>{switch(t.pathMatch||T){case"full":return new RegExp(`^${r}/?$`);case"suffix":return new RegExp(`^.*?${r}/?$`);case"fuzzy":return new RegExp(`^.*?${r}.*?$`);case"prefix":default:return new RegExp(`^[/]?${r}(?:/|$)`)}})(),a=e.match(s);if(a!=null){const i=n.reduce((c,l,X)=>(c[l]=a[X+1],c),{}),u=d(e.slice(0,a[0].length)),h=d(e.slice(a[0].length,e.length));return{route:t,match:a,params:i,fragments:{consumed:u,rest:h}}}return null}function O(t,e){for(const n of t){const r=F(n,e);if(r!=null)return r}return null}async function
|
|
1
|
+
const C="**",P="\\.\\.\\/",A=/:([^\\/]+)/g,E="router-slot",f=window,m="native",T="prefix";function L(t,e){t.dispatchEvent(new CustomEvent("changestate",{detail:e}))}function o(t,e){f.dispatchEvent(new CustomEvent(t,{detail:e}))}function g(t,e,n,r){const s=Array.isArray(e)?e:[e];return s.forEach(a=>t.addEventListener(a,n,r)),()=>s.forEach(a=>t.removeEventListener(a,n,r))}function $(t){t.forEach(e=>e())}const S=[["pushState",["pushstate","changestate"]],["replaceState",["replacestate","changestate"]],["forward",["pushstate","changestate"]],["go",["pushstate","changestate"]],["back",["popstate"]]];function b(){for(const[t,e]of S)for(const n of e)M(history,t,n);window.addEventListener("popstate",t=>{if(x({eventName:"popstate"})){t.preventDefault(),t.stopPropagation();return}setTimeout(()=>o("changestate"),0)})}function M(t,e,n){const r=t[e];N(t,e,r),t[e]=(...s)=>{const a=s.length>2?s[2]:null;x({url:a,eventName:n})||(r.apply(t,s),o(n))}}function N(t,e,n){t[m]==null&&(t[m]={}),t[m][`${e}`]=n.bind(t)}function x(t){return!f.dispatchEvent(new CustomEvent("willchangestate",{cancelable:!0,detail:t}))}const H=document.createElement("a");function v(t={}){return p(window.location.pathname,t)}function W(t={}){return p(k(v(),I()),t)}function I(t={}){return R(".",t)}function R(t,e={}){return H.href=t,p(H.pathname,e)}function k(t,e){return t.replace(new RegExp(`^${e}`),"")}function _(){return window.location.search}function Z(){return q(_().substr(1))}function d(t){return p(t,{start:!1,end:!1})}function tt(t){return p(t,{start:!0,end:!0})}function p(t,{start:e=!0,end:n=!0}={}){return t=e&&!t.startsWith("/")?`/${t}`:!e&&t.startsWith("/")?t.slice(1):t,n&&!t.endsWith("/")?`${t}/`:!n&&t.endsWith("/")?t.slice(0,t.length-1):t}function q(t){if(t.length===0)return{};const e=t.split("&").map(n=>n.split("="));return Object.assign({},...e.map(n=>({[decodeURIComponent(n[0])]:n.length>1?decodeURIComponent(n[1]):""})))}function et(t){return Object.entries(t).map(([e,n])=>`${e}${n!=""?`=${encodeURIComponent(n)}`:""}`).join("&")}function nt(t,e=v()){return new RegExp(`^${d(t)}(/|$)`,"gm").test(d(e))}function F(t,e){const n=[],r=d(t.path.replace(A,(i,...u)=>(n.push(u[0]),"([^/]+)"))),s=t.path===C||t.path.length===0&&t.pathMatch!="full"?/^/:(()=>{switch(t.pathMatch||T){case"full":return new RegExp(`^${r}/?$`);case"suffix":return new RegExp(`^.*?${r}/?$`);case"fuzzy":return new RegExp(`^.*?${r}.*?$`);case"prefix":default:return new RegExp(`^[/]?${r}(?:/|$)`)}})(),a=e.match(s);if(a!=null){const i=n.reduce((c,l,X)=>(c[l]=a[X+1],c),{}),u=d(e.slice(0,a[0].length)),h=d(e.slice(a[0].length,e.length));return{route:t,match:a,params:i,fragments:{consumed:u,rest:h}}}return null}function O(t,e){for(const n of t){const r=F(n,e);if(r!=null)return r}return null}async function U(t,e){let n=t.component;if(n instanceof Function)try{n=n()}catch(a){if(!(a instanceof TypeError))throw a}const r=await Promise.resolve(n);let s;return r instanceof HTMLElement?s=r:s=new(r.default?r.default:r),t.setup!=null&&t.setup(s,e),s}function D(t){return"redirectTo"in t}function G(t){return"resolve"in t}function j(t){let e=[t];for(;t.parent!=null;)t=t.parent,e.push(t);const n=e.reduce((s,a)=>({slot:a,child:s}),void 0),r=e.length;return{tree:n,depth:r}}function B(t,e){let n=t;const r=[];for(;n!=null&&n.slot.match!=null&&e>0;)r.push(n.slot.match.fragments.consumed),n=n.child,e--;return r}function w(t,e=""){const{tree:n,depth:r}=j(t);if(!e.startsWith("/")){let s=0;e.startsWith("./")&&(e=e.slice(2));const a=e.match(new RegExp(P,"g"));if(a!=null){s=a.length;const u=a.reduce((h,c)=>h+c.length,0);e=e.slice(u)}const i=B(n,r-1-s).filter(u=>u.length>0);e=`${i.join("/")}${i.length>0?"/":""}${e}`}return R(e,{end:!1})}function K(t,e){history.replaceState(history.state,"",`${w(t,e.redirectTo)}${e.preserveQuery?_():""}`)}function Q(t,e){if(t==null)return!0;const{route:n,fragments:r}=t,{route:s,fragments:a}=e,i=n==s;return r.consumed!=a.consumed||!i}function V(t){return y(t,E)}function y(t,e,n=0,r=0){const s=t.getRootNode();if(r>=n){const i=s.querySelector(e);if(i!=null&&i!=t)return i}const a=s.getRootNode();return a.host==null?null:y(a.host,e,n,++r)}function z(){const t=navigator.platform.toUpperCase().indexOf("WIN")!==-1;window.addEventListener("click",e=>{if(t&&e.ctrlKey||!t&&e.metaKey)return;const n="composedPath"in e?e.composedPath().find(s=>s instanceof HTMLAnchorElement):e.target;if(n==null||!(n instanceof HTMLAnchorElement)||!n.href.startsWith(location.origin)||n.target!==""&&n.target!=="_self"||n.dataset.routerSlot==="disabled")return;const r=n.pathname+n.search+n.hash;e.preventDefault(),history.pushState(null,"",r)})}const Y=document.createElement("template");Y.innerHTML="<slot></slot>",b(),z();class J extends HTMLElement{constructor(){super(),this.listeners=[],this._routes=[],this._lockParent=!1,this._routeMatch=null,this.addEventListener("router-slot:capture-parent",e=>{e.stopPropagation(),e.detail.parent=this}),this.render=this.render.bind(this),this.attachShadow({mode:"open"}).appendChild(Y.content.cloneNode(!0))}get routes(){return this._routes}set routes(e){this.clear(),this.add(e)}get parent(){return this._parent}set parent(e){this._lockParent=!0,this._setParent(e)}_setParent(e){this._parent!==e&&(this.detachListeners(),this._parent=e,this.attachListeners())}get isRoot(){return this.parent==null}get match(){return this._routeMatch}get route(){return this.match!=null?this.match.route:null}get fragments(){return this.match!=null?this.match.fragments:null}get params(){return this.match!=null?this.match.params:null}connectedCallback(){if(!this._lockParent){const e=new CustomEvent("router-slot:capture-parent",{composed:!0,bubbles:!0,detail:{parent:null}});this.parentNode?(this.parentNode.dispatchEvent(e),this._setParent(e.detail.parent??null)):this._setParent(null)}this.parent&&this.parent.match!==null&&this.match===null&&requestAnimationFrame(()=>{this.render()})}disconnectedCallback(){this.detachListeners()}queryParentRouterSlot(){return V(this)}constructAbsolutePath(e){return w(this,e)}add(e,n){this._routes.push(...e),n===void 0&&(n=this._routeMatch===null),n??(n=this.isRoot&&this.isConnected),n&&this.render().then()}clear(){this._routes.length=0}async render(){if(!this.isConnected)return;const e=this.parent!=null&&this.parent.fragments!=null?this.parent.fragments.rest:W();await this.renderPath(e)}attachListeners(){this.listeners.push(this.parent!=null?g(this.parent,"changestate",this.render):g(f,"changestate",this.render))}clearChildren(){for(;this.firstChild!=null;)this.firstChild.parentNode.removeChild(this.firstChild)}detachListeners(){$(this.listeners)}notifyChildRouters(e){this._routeMatch!==null&&requestAnimationFrame(()=>{L(this,e)})}async renderPath(e){const n=O(this._routes,e);if(n==null)return this._routeMatch=null,!1;const{route:r}=n,s={match:n,slot:this};try{const a=Q(this.match,n);if(a){let i=!1;const u=g(f,"changestate",()=>i=!0,{once:!0}),h=()=>{u()},c=()=>(h(),o("navigationcancel",s),o("navigationend",s),!1);if(o("navigationstart",s),r.guards!=null){for(const l of r.guards)if(!await l(s))return c()}if(this.notifyChildRouters(s),D(r))return h(),K(this,r),!1;if(G(r)){if(await r.resolve(s)===!1)return c()}else{const l=await U(r,s);if(i)return c();this.clearChildren(),this._routeMatch=n,l&&this.appendChild(l)}h()}else this.notifyChildRouters(s);return this._routeMatch=n,a&&(o("navigationsuccess",s),o("navigationend",s)),a}catch(a){throw o("navigationerror",s),o("navigationend",s),a}}}window.customElements.define(E,J);export{C as CATCH_ALL_WILDCARD,T as DEFAULT_PATH_MATCH,f as GLOBAL_ROUTER_EVENTS_TARGET,m as HISTORY_PATCH_NATIVE_KEY,A as PARAM_IDENTIFIER,E as ROUTER_SLOT_TAG_NAME,J as RouterSlot,P as TRAVERSE_FLAG,g as addListener,M as attachCallback,I as basePath,w as constructAbsolutePath,R as constructPathWithBasePath,o as dispatchGlobalRouterEvent,L as dispatchRouteChangeEvent,z as ensureAnchorHistory,b as ensureHistoryEvents,tt as ensureSlash,B as getFragments,K as handleRedirect,S as historyPatches,nt as isPathActive,D as isRedirectRoute,G as isResolverRoute,F as matchRoute,O as matchRoutes,v as path,W as pathWithoutBasePath,Z as query,y as queryParentRoots,V as queryParentRouterSlot,_ as queryString,$ as removeListeners,U as resolvePageComponent,N as saveNativeFunction,Q as shouldNavigate,p as slashify,d as stripSlash,k as stripStart,q as toQuery,et as toQueryString,j as traverseRouterTree};
|