@lwrjs/router 0.11.0-alpha.10 → 0.11.0-alpha.12

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,2 +1,2 @@
1
- function e(e){if(null==e)throw new TypeError("Provider must be defined.")}class t{constructor(e){this.infoMap=new WeakMap,this.defaultValue=e}getInfo(e){let t=this.infoMap.get(e);return void 0===t&&(t={consumers:new Set},this.infoMap.set(e,t)),t}setContext(t,n){e(t);const o=n,r=this.getInfo(t);r.contextValue=n,r.consumers.forEach((e=>e.provide(o))),0===r.consumers.size&&o?.onComplete&&o.onComplete()}getContext(t){e(t);const{contextValue:n}=this.getInfo(t);return void 0!==n?n:this.defaultValue}clearContext(t){e(t),this.infoMap.delete(t)}subscribeContext(t,n){e(t);const{consumers:o,contextValue:r}=this.getInfo(t);o.has(n)||(o.add(n),n.provide(r))}unsubscribeContext(t,n){e(t),this.getInfo(t).consumers.delete(n)}}function n(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function o(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?n(Object(o),!0).forEach((function(t){r(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):n(Object(o)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}function r(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t||"default");if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const i="LWR",a=1;function s(e,t){return Array.isArray(t)?e.replace(/\{([0-9]+)\}/g,((e,n)=>t[n])):e}function c(e,t){return`${e.code}: ${s(e.message,t)}`}function l(e,t){const n=o(o({},e),{},{message:s(e.message,t)});return e.address&&(n.address=s(e.address,t)),e.stack&&(n.stack=s(e.stack,t)),n}const u={INVALID_MIXIN_CMP:{code:`${i}4001`,message:"{0} must be an Element type",level:a},MISSING_CONTEXT:{code:`${i}4002`,message:"Could not find context to perform navigation action.",level:a},INVALID_CONTEXT:{code:`${i}4003`,message:"Cannot register navigation context; it must have this shape: { navigate, generateUrl, subscribe }",level:a},MULTIPLE_ROOTS:{code:`${i}4004`,message:"Router connection failed. There can only be one root router.",level:a},MULTIPLE_CHILDREN:{code:`${i}4005`,message:"Could not add to the navigation hierarchy. There can only be one child per navigation node.",level:a},MISSING_ROUTE:{code:`${i}4006`,message:'A route cannot be created to navigate to URL "{0}"',level:a,address:"{0}"},MISSING_URL:{code:`${i}4007`,message:'A URL cannot be created to navigate to route "{0}"',level:a,address:"{0}"},PRENAV_FAILED:{code:`${i}4008`,message:'A preNavigate hook listener blocked routing to "{0}"',level:2,address:"{0}"},MISSING_ROUTE_TEMPLATE:{code:`${i}4009`,message:'A route definition must contain a "uri" property.',level:a},MISSING_ROUTE_CMP:{code:`${i}4016`,message:"Expected a route view component with a default export.",level:a},MISSING_DATA_CONTEXT:{code:`${i}4018`,message:"Could not find context to retrieve navigation data.",level:a},INVALID_ROUTE_QUERY:{code:`${i}4019`,message:"Invalid query param in route definition.",level:a},MISSING_PAGE_BINDING:{code:`${i}4020`,message:"Route definition must provide page binding",level:a},INVALID_PAGE_BINDING:{code:`${i}4021`,message:"Invalid page binding in route definition",level:a},INVALID_URI_SYNTAX:{code:`${i}4022`,message:"Invalid uri syntax. URI cannot contain *, +, (, ), ",level:a},VIEW_IMPORT_FAILED:{code:`${i}4023`,message:'Error importing view with name "{0}", failure was: {1}',level:a,stack:"{2}"},VIEW_MISSING:{code:`${i}4024`,message:'Expected a view with name "{0}" in the viewset',level:a},VIEW_IMPORT_FAILED_WITH_SPECIFIER:{code:`${i}4025`,message:'Error importing module "{0}" from view with name "{1}", failure was: {2}',level:a,stack:"{3}"},NO_ROUTE_MATCH:{code:`${i}4026`,message:"A routing match cannot be found for: {0}",level:a},INVALID_ROUTE_HANDLER:{code:`${i}4027`,message:'Route definition "{0}" does not have a valid route handler module',level:a},DESTINATION_NOT_FOUND:{code:`${i}4028`,message:"Route handler returned 404: Not Found",level:a},DESTINATION_ERROR:{code:`${i}4029`,message:"Route handler returned error status {0}: {1}",level:a,stack:"{2}"},NO_INIT_URL:{code:`${i}4030`,message:'Cannot initialize a server router without a "url"',level:a}},d=new WeakMap;function v(e){const t=d.get(e);if(!t||!t.value)throw new Error(c(u.MISSING_CONTEXT));return t.value}function I(e,t){const n={id:e,value:t,update:e=>{n.value=e}};return d.set(n.id,n),n}function f(e){var t;return(t=class{constructor(e){this._callback=e}connect(){}disconnect(){}update(e,t){t&&this._callback(t)}static setContext(t,n){e.setContext(t,n)}static getContext(t){return e.getContext(t)}static clearContext(t){e.clearContext(t)}static subscribeContext(t,n){e.subscribeContext(t,n)}static unsubscribeContext(t,n){e.unsubscribeContext(t,n)}}).contextSchema={value:"required"},t}const g=f(new t(void 0)),m=f(new t(void 0)),p=new t(void 0),h=class extends(f(p)){async update(e,t){if(t){const n=e&&e.viewName?e.viewName:"default",o=t.viewset[n],r=o,i=r&&r.module||o;let a;if(i)try{const e=await i(),t=e&&e.default;if(!t||void 0===t.constructor)throw new Error("error occurred with view import");this._callback(t)}catch(e){const t=e;a=r.specifier?l(u.VIEW_IMPORT_FAILED_WITH_SPECIFIER,[r.specifier,n,t.message,t.stack||""]):l(u.VIEW_IMPORT_FAILED,[n,t.message,t.stack||""])}else a=l(u.VIEW_MISSING,[n]);t.onComplete&&t.onComplete(a)}}};function b(e,t,n){v(e).navigate(t,n)}function E(e,t){return v(e).generateUrl(t)}const _=`universalcontainergetnavigationcontext${Math.floor(65536*(1+Math.random())).toString(16).substring(1)}`,N="undefined"==typeof window,w=Symbol("Navigate"),O=Symbol("GenerateUrl"),S=Symbol("NavContext"),C=Symbol("NavContext");function T(e){!function(e,t,n){if(!e)throw new Error(c(t,n))}("function"==typeof e.prototype.dispatchEvent,u.INVALID_MIXIN_CMP,[e.toString()]);return class extends e{[C](){if(!this[S]&&(this.dispatchEvent(new CustomEvent(_,{bubbles:!0,composed:!0,detail:{callback:e=>{this[S]=e}}})),!this[S]))throw new Error(c(u.MISSING_CONTEXT))}[w](e,t){N||(this[C](),b(this[S],e,t))}async[O](e){return N?null:(this[C](),E(this[S],e))}}}T.Navigate=w,T.GenerateUrl=O,T.NavContext=S;export{t as ContextInfo,m as CurrentPageReference,h as CurrentView,g as NavigationContext,T as NavigationMixin,f as generateContextualWireAdapter,E as generateUrl,v as getNavigationHelm,b as navigate,I as registerNavigationHelm};
1
+ function e(e){if(null==e)throw new TypeError("Provider must be defined.")}class t{constructor(e){this.infoMap=new WeakMap,this.defaultValue=e}getInfo(e){let t=this.infoMap.get(e);return void 0===t&&(t={consumers:new Set},this.infoMap.set(e,t)),t}setContext(t,o){e(t);const n=o,a=this.getInfo(t);a.contextValue=o,a.consumers.forEach((e=>e.provide(n))),0===a.consumers.size&&n?.onComplete&&n.onComplete()}getContext(t){e(t);const{contextValue:o}=this.getInfo(t);return void 0!==o?o:this.defaultValue}clearContext(t){e(t),this.infoMap.delete(t)}subscribeContext(t,o){e(t);const{consumers:n,contextValue:a}=this.getInfo(t);n.has(o)||(n.add(o),o.provide(a))}unsubscribeContext(t,o){e(t),this.getInfo(t).consumers.delete(o)}}const o="LWR",n=1;function a(e,t){return Array.isArray(t)?e.replace(/\{([0-9]+)\}/g,((e,o)=>t[o])):e}function s(e,t){return`${e.code}: ${a(e.message,t)}`}function i(e,t){const o={...e,message:a(e.message,t)};return e.address&&(o.address=a(e.address,t)),e.stack&&(o.stack=a(e.stack,t)),o}const r={INVALID_MIXIN_CMP:{code:`${o}4001`,message:"{0} must be an Element type",level:n},MISSING_CONTEXT:{code:`${o}4002`,message:"Could not find context to perform navigation action.",level:n},INVALID_CONTEXT:{code:`${o}4003`,message:"Cannot register navigation context; it must have this shape: { navigate, generateUrl, subscribe }",level:n},MULTIPLE_ROOTS:{code:`${o}4004`,message:"Router connection failed. There can only be one root router.",level:n},MULTIPLE_CHILDREN:{code:`${o}4005`,message:"Could not add to the navigation hierarchy. There can only be one child per navigation node.",level:n},MISSING_ROUTE:{code:`${o}4006`,message:'A route cannot be created to navigate to URL "{0}"',level:n,address:"{0}"},MISSING_URL:{code:`${o}4007`,message:'A URL cannot be created to navigate to route "{0}"',level:n,address:"{0}"},PRENAV_FAILED:{code:`${o}4008`,message:'A preNavigate hook listener blocked routing to "{0}"',level:2,address:"{0}"},MISSING_ROUTE_TEMPLATE:{code:`${o}4009`,message:'A route definition must contain a "uri" property.',level:n},MISSING_ROUTE_CMP:{code:`${o}4016`,message:"Expected a route view component with a default export.",level:n},MISSING_DATA_CONTEXT:{code:`${o}4018`,message:"Could not find context to retrieve navigation data.",level:n},INVALID_ROUTE_QUERY:{code:`${o}4019`,message:"Invalid query param in route definition.",level:n},MISSING_PAGE_BINDING:{code:`${o}4020`,message:"Route definition must provide page binding",level:n},INVALID_PAGE_BINDING:{code:`${o}4021`,message:"Invalid page binding in route definition",level:n},INVALID_URI_SYNTAX:{code:`${o}4022`,message:"Invalid uri syntax. URI cannot contain *, +, (, ), ",level:n},VIEW_IMPORT_FAILED:{code:`${o}4023`,message:'Error importing view with name "{0}", failure was: {1}',level:n,stack:"{2}"},VIEW_MISSING:{code:`${o}4024`,message:'Expected a view with name "{0}" in the viewset',level:n},VIEW_IMPORT_FAILED_WITH_SPECIFIER:{code:`${o}4025`,message:'Error importing module "{0}" from view with name "{1}", failure was: {2}',level:n,stack:"{3}"},NO_ROUTE_MATCH:{code:`${o}4026`,message:"A routing match cannot be found for: {0}",level:n},INVALID_ROUTE_HANDLER:{code:`${o}4027`,message:'Route definition "{0}" does not have a valid route handler module',level:n},DESTINATION_NOT_FOUND:{code:`${o}4028`,message:"Route handler returned 404: Not Found",level:n},DESTINATION_ERROR:{code:`${o}4029`,message:"Route handler returned error status {0}: {1}",level:n,stack:"{2}"},NO_INIT_URL:{code:`${o}4030`,message:'Cannot initialize a server router without a "url"',level:n}},c=new WeakMap;function l(e){const t=c.get(e);if(!t||!t.value)throw new Error(s(r.MISSING_CONTEXT));return t.value}function d(e,t){const o={id:e,value:t,update:e=>{o.value=e}};return c.set(o.id,o),o}function u(e){var t;return(t=class{constructor(e){this._callback=e}connect(){}disconnect(){}update(e,t){t&&this._callback(t)}static setContext(t,o){e.setContext(t,o)}static getContext(t){return e.getContext(t)}static clearContext(t){e.clearContext(t)}static subscribeContext(t,o){e.subscribeContext(t,o)}static unsubscribeContext(t,o){e.unsubscribeContext(t,o)}}).contextSchema={value:"required"},t}const I=u(new t(void 0)),v=u(new t(void 0)),g=new t(void 0),m=class extends(u(g)){async update(e,t){if(t){const o=e&&e.viewName?e.viewName:"default",n=t.viewset[o],a=n,s=a&&a.module||n;let c;if(s)try{const e=await s(),t=e&&e.default;if(!t||void 0===t.constructor)throw new Error("error occurred with view import");this._callback(t)}catch(e){const t=e;c=a.specifier?i(r.VIEW_IMPORT_FAILED_WITH_SPECIFIER,[a.specifier,o,t.message,t.stack||""]):i(r.VIEW_IMPORT_FAILED,[o,t.message,t.stack||""])}else c=i(r.VIEW_MISSING,[o]);t.onComplete&&t.onComplete(c)}}};function h(e,t,o){l(e).navigate(t,o)}function f(e,t){return l(e).generateUrl(t)}const E=`universalcontainergetnavigationcontext${Math.floor(65536*(1+Math.random())).toString(16).substring(1)}`,_="undefined"==typeof window,N=Symbol("Navigate"),p=Symbol("GenerateUrl"),C=Symbol("NavContext"),T=Symbol("NavContext");function w(e){!function(e,t,o){if(!e)throw new Error(s(t,o))}("function"==typeof e.prototype.dispatchEvent,r.INVALID_MIXIN_CMP,[e.toString()]);return class extends e{[T](){if(!this[C]&&(this.dispatchEvent(new CustomEvent(E,{bubbles:!0,composed:!0,detail:{callback:e=>{this[C]=e}}})),!this[C]))throw new Error(s(r.MISSING_CONTEXT))}[N](e,t){_||(this[T](),h(this[C],e,t))}async[p](e){return _?null:(this[T](),f(this[C],e))}}}w.Navigate=N,w.GenerateUrl=p,w.NavContext=C;export{t as ContextInfo,v as CurrentPageReference,m as CurrentView,I as NavigationContext,w as NavigationMixin,u as generateContextualWireAdapter,f as generateUrl,l as getNavigationHelm,h as navigate,d as registerNavigationHelm};
2
2
  //# sourceMappingURL=navigation.js.map
@@ -1,2 +1,2 @@
1
- import{registerDecorators as e}from"lwc";function t(e=""){return e=e||"",decodeURIComponent(e)}function r(e){"/"!==(e=e||"/").charAt(0)&&(e="/"+e);const t=e.match(/^[^#?]+/);if(null!==t){const e=t[0];return"/"===e?"/":e.replace(/\/$/,"")}return"/"}function n(e){const r=(e=e||"").indexOf("#");r>=0&&(e=e.substring(0,r));const n=e.indexOf("?"),o=n>=0?e.substr(n+1):null,i={};return o&&o.split("&").forEach((e=>{if(e.indexOf("=")>=0){const[r,n=""]=e.split("=");i[t(r)]=t(n)}else i[t(e)]=null})),i}function o(e={}){const t=Object.keys(e);return t.length?`?${t.map((t=>{const r=e[t];return null===r?t:`${t}=${function(e=""){return e=e||"",encodeURIComponent(e)}(r)}`})).join("&")}`:""}function i(e){return!!(e&&e.length>1)&&e.startsWith(":")}function s(e){return!!e&&(!!i(e)&&e.substr(1))}function u(e){return Object.values(e).reduce(((e,{routeParamName:t})=>{const r=s(t);return r&&e.push(r),e}),[])}function c(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function a(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?c(Object(r),!0).forEach((function(t){l(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):c(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function l(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function f(e,r){const{regex:n,params:o}=r,i=n.exec(e);if(i){const[,...e]=i,r={};return o.forEach(((n,o)=>{const{name:i}=n,s=e[o];r[i]=s?t(s):s})),r}return null}function p(e,r){if(e&&r){const{queryMatcher:n}=r,o=n(e);if(o){const e={};return Object.keys(o).forEach((r=>{const n=o[r],{value:i,routeParamName:s}=n,u=s?s.substr(1):r;e[u]=i?t(i):i})),e}}return null}function d(e,t){if(t){const{original:{page:{type:o="",attributes:s={},state:u={}}={}}={}}=t,c=r(e),l=n(e),d=f(c,t),g=p(l,t);if(d&&g){const e=a(a({},d),g),r={};Object.keys(s).forEach((t=>{const n=s[t];let o;if(n&&i(n)){const t=n.substr(1);o=e[t]}else o=n;r[t]=o}));const n={};Object.keys(u).forEach((t=>{const r=u[t];let o;if(r&&i(r)){const t=r.substr(1);o=e[t]}else o=r;n[t]=o}));const c=function(e,t){const{compiledQuery:r}=t,n=Object.keys(r).filter((e=>{const{literalValue:t}=r[e];return!t})),o={};return Object.keys(e).forEach((t=>{const r=e[t];n.indexOf(t)<0&&(o[t]=r)})),o}(l,t);return{type:o,attributes:a({},r),state:a(a({},c),n)}}}return null}function g(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function b(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?g(Object(r),!0).forEach((function(t){m(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):g(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function m(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function y(e,t){const o=r(e),i=n(e),s=t?t.filter((e=>e.regex.test(o))):[],[u]=s.filter((e=>{const{queryMatcher:t}=e;return t(i)&&function(e,t,r){const{original:{patterns:n=null}={}}=r||{};if(n){const o=f(e,r),i=p(t,r),s=b(b({},o),i);return Object.keys(n).every((e=>{const t=n[e],r=new RegExp(t),o=s[e]||"";return r.test(o)}))}return!0}(o,i,e)}));return u||null}function h(e,t,r=""){r&&0===e.indexOf(r)&&(e=e.replace(r,""));const n=y(e,t);let o;if(!n)return null;{const t=d(e,n);if(t){return o={route:{id:n.original.id,attributes:b({},t.attributes),state:b({},t.state),pageReference:{type:t.type,attributes:b({},t.attributes),state:b({},t.state)}},routeDefinition:n},o}}return null}function O(e,t,r=""){const n=function(e,t){if(!e)return null;const{type:r,attributes:n={},state:o={}}=e;if(r){const[e]=t.filter((e=>{const{original:{page:{type:t=null,attributes:s={},state:u={}}={}}}=e,c=t===r,a=Object.keys(s).every((e=>Object.keys(n).indexOf(e)>=0)),l=Object.keys(s).length===Object.keys(n).length,f=Object.keys(u).every((e=>Object.keys(o).indexOf(e)>=0)),p=Object.keys(s).filter((e=>{const t=s[e];return!t||!i(t)})).every((e=>s[e]===n[e])),d=Object.keys(u).filter((e=>{const t=u[e];return null===t||!i(t)})).every((e=>u[e]===o[e]));return c&&a&&l&&p&&f&&d}));return e||null}return null}(e,t);return n?E(e,n,r):null}function v(e,t,r){const{attributeBindings:n,stateBindings:o}=r,{attributes:i,state:u}=t,c={};return e.forEach((e=>{const[t]=Object.keys(n).filter((t=>s(n[t])===e));if(t)c[e]=i[t];else{const[t]=Object.keys(o).filter((t=>s(o[t])===e));t&&(c[e]=u[t])}})),c}function E(e,t,r=""){const{params:n,original:{page:c={}}={},toPath:a,compiledQuery:l}=t,{attributes:f={},state:p={}}=c,d=a(v(n.filter((({name:e})=>"string"==typeof e)).map((({name:e})=>e)),e,{attributeBindings:f,stateBindings:p})),g=function(e,t,r){const{compiledQuery:n,original:{page:{state:o={}}}}=r,{state:u={}}=e||{},c={};Object.keys(u).filter((e=>!i(o[e]))).forEach((e=>c[e]=u[e]));const a={};return Object.keys(t).forEach((e=>{const r=t[e],[o]=Object.keys(n).filter((t=>{const r=n[t],{routeParamName:o}=r;return s(o)===e}));if(o){a[o]=r}})),b(b({},c),a)}(e,v(u(l),e,{attributeBindings:f,stateBindings:p}),t);return`${r}${d}${o(g)}`}function w(e,t=2){if(function(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}(e))try{Object.freeze(e),t>0&&Object.keys(e).forEach((r=>{if(function(e,t){return t in e}(e,r)){const n=e[r];n&&"object"==typeof n&&w(n,t-1)}}))}catch(e){}return e}const I="LWR",j=1;function P(e,t){return`${e.code}: ${function(e,t){return Array.isArray(t)?e.replace(/\{([0-9]+)\}/g,((e,r)=>t[r])):e}(e.message,t)}`}function R(e,t,r){if(!e)throw new Error(P(t,r))}const $={INVALID_MIXIN_CMP:{code:`${I}4001`,message:"{0} must be an Element type",level:j},MISSING_CONTEXT:{code:`${I}4002`,message:"Could not find context to perform navigation action.",level:j},INVALID_CONTEXT:{code:`${I}4003`,message:"Cannot register navigation context; it must have this shape: { navigate, generateUrl, subscribe }",level:j},MULTIPLE_ROOTS:{code:`${I}4004`,message:"Router connection failed. There can only be one root router.",level:j},MULTIPLE_CHILDREN:{code:`${I}4005`,message:"Could not add to the navigation hierarchy. There can only be one child per navigation node.",level:j},MISSING_ROUTE:{code:`${I}4006`,message:'A route cannot be created to navigate to URL "{0}"',level:j,address:"{0}"},MISSING_URL:{code:`${I}4007`,message:'A URL cannot be created to navigate to route "{0}"',level:j,address:"{0}"},PRENAV_FAILED:{code:`${I}4008`,message:'A preNavigate hook listener blocked routing to "{0}"',level:2,address:"{0}"},MISSING_ROUTE_TEMPLATE:{code:`${I}4009`,message:'A route definition must contain a "uri" property.',level:j},MISSING_ROUTE_CMP:{code:`${I}4016`,message:"Expected a route view component with a default export.",level:j},MISSING_DATA_CONTEXT:{code:`${I}4018`,message:"Could not find context to retrieve navigation data.",level:j},INVALID_ROUTE_QUERY:{code:`${I}4019`,message:"Invalid query param in route definition.",level:j},MISSING_PAGE_BINDING:{code:`${I}4020`,message:"Route definition must provide page binding",level:j},INVALID_PAGE_BINDING:{code:`${I}4021`,message:"Invalid page binding in route definition",level:j},INVALID_URI_SYNTAX:{code:`${I}4022`,message:"Invalid uri syntax. URI cannot contain *, +, (, ), ",level:j},VIEW_IMPORT_FAILED:{code:`${I}4023`,message:'Error importing view with name "{0}", failure was: {1}',level:j,stack:"{2}"},VIEW_MISSING:{code:`${I}4024`,message:'Expected a view with name "{0}" in the viewset',level:j},VIEW_IMPORT_FAILED_WITH_SPECIFIER:{code:`${I}4025`,message:'Error importing module "{0}" from view with name "{1}", failure was: {2}',level:j,stack:"{3}"},NO_ROUTE_MATCH:{code:`${I}4026`,message:"A routing match cannot be found for: {0}",level:j},INVALID_ROUTE_HANDLER:{code:`${I}4027`,message:'Route definition "{0}" does not have a valid route handler module',level:j},DESTINATION_NOT_FOUND:{code:`${I}4028`,message:"Route handler returned 404: Not Found",level:j},DESTINATION_ERROR:{code:`${I}4029`,message:"Route handler returned error status {0}: {1}",level:j,stack:"{2}"},NO_INIT_URL:{code:`${I}4030`,message:'Cannot initialize a server router without a "url"',level:j}};function N(e){return e.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1")}function D(e){return e&&e.sensitive?"":"i"}function T(e,t={}){const r=function(e){const t=[];let r=0;for(;r<e.length;){const n=e[r];if("*"!==n&&"+"!==n&&"?"!==n)if("\\"!==n)if("{"!==n)if("}"!==n)if(":"!==n)if("("!==n)t.push({type:"CHAR",index:r,value:e[r++]});else{let n=1,o="",i=r+1;if("?"===e[i])throw new TypeError(`Pattern cannot start with "?" at ${i}`);for(;i<e.length;)if("\\"!==e[i]){if(")"===e[i]){if(n--,0===n){i++;break}}else if("("===e[i]&&(n++,"?"!==e[i+1]))throw new TypeError(`Capturing groups are not allowed at ${i}`);o+=e[i++]}else o+=e[i++]+e[i++];if(n)throw new TypeError(`Unbalanced pattern at ${r}`);if(!o)throw new TypeError(`Missing pattern at ${r}`);t.push({type:"PATTERN",index:r,value:o}),r=i}else{let n="",o=r+1;for(;o<e.length;){const t=e.charCodeAt(o);if(!(t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122||95===t))break;n+=e[o++]}if(!n)throw new TypeError(`Missing parameter name at ${r}`);t.push({type:"NAME",index:r,value:n}),r=o}else t.push({type:"CLOSE",index:r,value:e[r++]});else t.push({type:"OPEN",index:r,value:e[r++]});else t.push({type:"ESCAPED_CHAR",index:r++,value:e[r++]});else t.push({type:"MODIFIER",index:r,value:e[r++]})}return t.push({type:"END",index:r,value:""}),t}(e),{prefixes:n="./"}=t,o=`[^${N(t.delimiter||"/#?")}]+?`,i=[];let s=0,u=0,c="";const a=e=>{if(u<r.length&&r[u].type===e)return r[u++].value},l=e=>{const t=a(e);if(void 0!==t)return t;const{type:n,index:o}=r[u];throw new TypeError(`Unexpected ${n} at ${o}, expected ${e}`)},f=()=>{let e,t="";for(;e=a("CHAR")||a("ESCAPED_CHAR");)t+=e;return t};for(;u<r.length;){const e=a("CHAR"),t=a("NAME"),r=a("PATTERN");if(t||r){let u=e||"";-1===n.indexOf(u)&&(c+=u,u=""),c&&(i.push(c),c=""),i.push({name:t||s++,prefix:u,suffix:"",pattern:r||o,modifier:a("MODIFIER")||""});continue}const u=e||a("ESCAPED_CHAR");if(u){c+=u;continue}c&&(i.push(c),c="");if(a("OPEN")){const e=f(),t=a("NAME")||"",r=a("PATTERN")||"",n=f();l("CLOSE"),i.push({name:t||(r?s++:""),pattern:t&&!r?o:r,prefix:e,suffix:n,modifier:a("MODIFIER")||""})}else l("END")}return i}function _(e,t){return function(e,t={}){const r=D(t),{encode:n=(e=>e),validate:o=!0}=t,i=e.map((e=>{if("object"==typeof e)return new RegExp(`^(?:${e.pattern})$`,r)}));return t=>{let r="";for(let s=0;s<e.length;s++){const u=e[s];if("string"==typeof u){r+=u;continue}const c=t?t[u.name]:void 0,a="?"===u.modifier||"*"===u.modifier,l="*"===u.modifier||"+"===u.modifier;if(Array.isArray(c)){if(!l)throw new TypeError(`Expected "${u.name}" to not repeat, but got an array`);if(0===c.length){if(a)continue;throw new TypeError(`Expected "${u.name}" to not be empty`)}for(let e=0;e<c.length;e++){const t=n(c[e],u);if(o&&!i[s].test(t))throw new TypeError(`Expected all "${u.name}" to match "${u.pattern}", but got "${t}"`);r+=u.prefix+t+u.suffix}continue}if("string"==typeof c||"number"==typeof c){const e=n(String(c),u);if(o&&!i[s].test(e))throw new TypeError(`Expected "${u.name}" to match "${u.pattern}", but got "${e}"`);r+=u.prefix+e+u.suffix;continue}if(a)continue;const f=l?"an array":"a string";throw new TypeError(`Expected "${u.name}" to be ${f}`)}return r}}(T(e,t),t)}function A(e,t,r){return function(e,t,r={}){const{strict:n=!1,start:o=!0,end:i=!0,encode:s=(e=>e)}=r,u=`[${N(r.endsWith||"")}]|$`,c=`[${N(r.delimiter||"/#?")}]`;let a=o?"^":"";for(const r of e)if("string"==typeof r)a+=N(s(r));else{const e=N(s(r.prefix)),n=N(s(r.suffix));if(r.pattern)if(t&&t.push(r),e||n)if("+"===r.modifier||"*"===r.modifier){const t="*"===r.modifier?"?":"";a+=`(?:${e}((?:${r.pattern})(?:${n}${e}(?:${r.pattern}))*)${n})${t}`}else a+=`(?:${e}(${r.pattern})${n})${r.modifier}`;else a+=`(${r.pattern})${r.modifier}`;else a+=`(?:${e}${n})${r.modifier}`}if(i)n||(a+=`${c}?`),a+=r.endsWith?`(?=${u})`:"$";else{const t=e[e.length-1],r="string"==typeof t?c.indexOf(t[t.length-1])>-1:void 0===t;n||(a+=`(?:${c}(?=${u}))?`),r||(a+=`(?=${c}|${u})`)}return new RegExp(a,D(r))}(T(e,r),t,r)}function x(e,t,r){return e instanceof RegExp?function(e,t){if(!t)return e;const r=e.source.match(/\((?!\?)/g);if(r)for(let e=0;e<r.length;e++)t.push({name:e,prefix:"",suffix:"",modifier:"",pattern:""});return e}(e,t):Array.isArray(e)?function(e,t,r){const n=e.map((e=>x(e,t,r).source));return new RegExp(`(?:${n.join("|")})`,D(r))}(e,t,r):A(e,t,r)}function S(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function U(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?S(Object(r),!0).forEach((function(t){C(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):S(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function C(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const{INVALID_ROUTE_QUERY:k,MISSING_ROUTE_TEMPLATE:M,MISSING_PAGE_BINDING:L,INVALID_PAGE_BINDING:V,INVALID_URI_SYNTAX:H}=$;function G(e){const{routes:t,caseSensitive:o}=e;return t.map((e=>function(e,t=!1){const o=[],{uri:c,page:a}=e;R(!!c,M),R(function(e=""){const t=["*","(",")",";"].some((t=>e.indexOf(t)>=0));return!t}(c),H),R(!!a,L);const l=r(c),f=n(c),p=x(l,o,{sensitive:t,end:!1!==e.exact}),d=_(l,{encode:encodeURIComponent}),g=function(e){const t={};return Object.keys(e).forEach((r=>{const n=e[r];R(!i(r)||null===n,k),i(r)?t[r.substr(1)]={routeParamName:r}:n&&i(n)?t[r]={routeParamName:n}:t[r]={literalValue:null===n?null:n}})),t}(f),b=function(e,t=!1){const r=r=>{const n=Object.keys(r),o=Object.keys(e);return o.every((e=>n.indexOf(e)>=0))?o.reduce(((n,o)=>{if(null===n)return null;const{literalValue:i,routeParamName:s}=e[o],u=r[o];let c=!0;return"string"==typeof i?c=t?i===u:i.toUpperCase()===(null==u?u:u.toUpperCase()):null===i&&(c=u===i),n=c?U(U({},n),{},{[o]:{value:u,routeParamName:s}}):null}),{}):null};return r}(g,t),m={original:e,regex:p,params:o,toPath:d,compiledQuery:g,queryMatcher:b};return R(function(e){const{original:{page:t}={},params:r,compiledQuery:n}=e,o=t?t.type:t,c=(t?t.attributes:t)||{},a=(t?t.state:t)||{};if("string"!=typeof o||"object"!=typeof c||"object"!=typeof a)return!1;const l=Object.values(r).map((({name:e})=>e)),f=u(n),p=[...l,...f],d=Object.values(c).filter(i).map(s),g=Object.values(a).filter(i).map(s),b=p.every((e=>"string"==typeof e&&(d.indexOf(e)>=0||g.indexOf(e)>=0))),m=p.length===d.length+g.length;return!!(t&&o&&c&&a&&b&&m)}(m),V),m}(e,o)))}function F(){let e,t,r=[];const n=n=>{r.filter((e=>null!==e)).forEach((e=>e.error&&e.error(n))),e=void 0,t=n};return{next:n=>{r.filter((e=>null!==e)).forEach((e=>e.next&&e.next(n))),e=n,t=void 0},error:n,complete:()=>{r.filter((e=>null!==e)).forEach((e=>e.complete&&e.complete())),r=[],e=void 0,t=void 0},subscribe:(o,i=!0)=>{(e=>{r.push(e)})(o),e&&i&&o.next(e),t&&n(t);const s=r.length-1;return{unsubscribe:()=>(e=>{r=[...r.slice(0,e),...r.slice(e+1)]})(s)}}}}function B(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function W(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?B(Object(r),!0).forEach((function(t){Q(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):B(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function Q(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class X{constructor(e){this.deprecatedConfig={},this.routeHandlerId=0,this.compiledRoutes=[],this.routeObservable=F(),this.config={basePath:e.basePath||"",caseSensitive:Boolean(e.caseSensitive),routes:e.routes||[],generateUrl:e=>O(e,this.compiledRoutes,this.config.basePath),parseUrl:e=>function(e,t,r=""){const n=h(e,t,r);return n&&n.route&&n.route.pageReference?n.route.pageReference:null}(e,this.compiledRoutes,this.config.basePath)};const{DEPRECATED_getRouteFromUrl:t,DEPRECATED_getUrlFromRoute:r}=e;t&&(this.deprecatedConfig.DEPRECATED_getRouteFromUrl=t),r&&(this.deprecatedConfig.DEPRECATED_getUrlFromRoute=r),this.compiledRoutes=G(this.config)}generateUrl(e){const{DEPRECATED_getUrlFromRoute:t}=this.deprecatedConfig;return t?t(e,this.config.generateUrl):this.config.generateUrl(e)}parseUrl(e){const{DEPRECATED_getRouteFromUrl:t}=this.deprecatedConfig;return t?t(e,this.config.parseUrl):this.config.parseUrl(e)}matchRoute(e){const t="string"==typeof e?e:this.generateUrl(e);if(null===t)return null;const r=h(t,this.compiledRoutes,this.config.basePath),n=r&&E(r.route.pageReference,r.routeDefinition,this.config.basePath);return r&&n?{pathMatch:n,route:r.route,routeDefinition:r.routeDefinition.original}:null}async resolveView(e){return new Promise(((t,r)=>{const n=this.matchRoute(e);return n?n.routeDefinition.handler?.().then((e=>{const o=e.default;if(!o)return r(P($.INVALID_ROUTE_HANDLER,[n.routeDefinition.id]));const i=new o(t);i&&i.update(n.route)})):r(P($.NO_ROUTE_MATCH,[JSON.stringify(e)]))}))}navigate(e){const t=this.matchRoute(e);if(!t)throw new Error(P($.MISSING_ROUTE,[JSON.stringify(e)]));this.pendingRoute=W({},t),this._mapView(this.pendingRoute)}subscribe(e,t){return this.routeObservable.subscribe({next:e,error:()=>{},complete:()=>{}},Boolean(t))}async _mapView(e){const t=Math.random();this.routeHandlerId=t;const r=await(e.routeDefinition.handler?.()),n=r?.default;if(!n)throw new Error(P($.INVALID_ROUTE_HANDLER,[e.routeDefinition.id]));return this.routeHandler=new n((e=>{this._updateView(t,e)})),this.routeHandler&&this.routeHandler.update(e.route),!0}_updateView(e,t){if(!t||e!==this.routeHandlerId)return;if(!this.pendingRoute)throw new Error("Trying to commit route state without a route");const r=w(t.viewset);this.routeObservable.next(W(W(W({},this.pendingRoute),t),{},{viewset:r}))}}function q(e={}){return new X(e)}e(X,{fields:["deprecatedConfig","routeHandlerId"]});export{q as createRouter};
1
+ function e(e=""){return e=e||"",decodeURIComponent(e)}function t(e){"/"!==(e=e||"/").charAt(0)&&(e="/"+e);const t=e.match(/^[^#?]+/);if(null!==t){const e=t[0];return"/"===e?"/":e.replace(/\/$/,"")}return"/"}function n(t){const n=(t=t||"").indexOf("#");n>=0&&(t=t.substring(0,n));const r=t.indexOf("?"),o=r>=0?t.substr(r+1):null,i={};return o&&o.split("&").forEach((t=>{if(t.indexOf("=")>=0){const[n,r=""]=t.split("=");i[e(n)]=e(r)}else i[e(t)]=null})),i}function r(e={}){const t=Object.keys(e);return t.length?`?${t.map((t=>{const n=e[t];return null===n?t:`${t}=${function(e=""){return e=e||"",encodeURIComponent(e)}(n)}`})).join("&")}`:""}function o(e){return!!(e&&e.length>1)&&e.startsWith(":")}function i(e){return!!e&&(!!o(e)&&e.substr(1))}function s(e){return Object.values(e).reduce(((e,{routeParamName:t})=>{const n=i(t);return n&&e.push(n),e}),[])}function a(t,n){const{regex:r,params:o}=n,i=r.exec(t);if(i){const[,...t]=i,n={};return o.forEach(((r,o)=>{const{name:i}=r,s=t[o];n[i]=s?e(s):s})),n}return null}function u(t,n){if(t&&n){const{queryMatcher:r}=n,o=r(t);if(o){const t={};return Object.keys(o).forEach((n=>{const r=o[n],{value:i,routeParamName:s}=r,a=s?s.substr(1):n;t[a]=i?e(i):i})),t}}return null}function c(e,r){if(r){const{original:{page:{type:i="",attributes:s={},state:c={}}={}}={}}=r,l=t(e),f=n(e),d=a(l,r),p=u(f,r);if(d&&p){const e={...d,...p},t={};Object.keys(s).forEach((n=>{const r=s[n];let i;if(r&&o(r)){const t=r.substr(1);i=e[t]}else i=r;t[n]=i}));const n={};Object.keys(c).forEach((t=>{const r=c[t];let i;if(r&&o(r)){const t=r.substr(1);i=e[t]}else i=r;n[t]=i}));const a=function(e,t){const{compiledQuery:n}=t,r=Object.keys(n).filter((e=>{const{literalValue:t}=n[e];return!t})),o={};return Object.keys(e).forEach((t=>{const n=e[t];r.indexOf(t)<0&&(o[t]=n)})),o}(f,r);return{type:i,attributes:{...t},state:{...a,...n}}}}return null}function l(e,r){const o=t(e),i=n(e),s=r?r.filter((e=>e.regex.test(o))):[],[c]=s.filter((e=>{const{queryMatcher:t}=e;return t(i)&&function(e,t,n){const{original:{patterns:r=null}={}}=n||{};if(r){const o={...a(e,n),...u(t,n)};return Object.keys(r).every((e=>{const t=r[e],n=new RegExp(t),i=o[e]||"";return n.test(i)}))}return!0}(o,i,e)}));return c||null}function f(e,t,n=""){n&&0===e.indexOf(n)&&(e=e.replace(n,""));const r=l(e,t);let o;if(!r)return null;{const t=c(e,r);if(t){return o={route:{id:r.original.id,attributes:{...t.attributes},state:{...t.state},pageReference:{type:t.type,attributes:{...t.attributes},state:{...t.state}}},routeDefinition:r},o}}return null}function d(e,t,n=""){const r=function(e,t){if(!e)return null;const{type:n,attributes:r={},state:i={}}=e;if(n){const[e]=t.filter((e=>{const{original:{page:{type:t=null,attributes:s={},state:a={}}={}}}=e,u=t===n,c=Object.keys(s).every((e=>Object.keys(r).indexOf(e)>=0)),l=Object.keys(s).length===Object.keys(r).length,f=Object.keys(a).every((e=>Object.keys(i).indexOf(e)>=0)),d=Object.keys(s).filter((e=>{const t=s[e];return!t||!o(t)})).every((e=>s[e]===r[e])),p=Object.keys(a).filter((e=>{const t=a[e];return null===t||!o(t)})).every((e=>a[e]===i[e]));return u&&c&&l&&d&&f&&p}));return e||null}return null}(e,t);return r?h(e,r,n):null}function p(e,t,n){const{attributeBindings:r,stateBindings:o}=n,{attributes:s,state:a}=t,u={};return e.forEach((e=>{const[t]=Object.keys(r).filter((t=>i(r[t])===e));if(t)u[e]=s[t];else{const[t]=Object.keys(o).filter((t=>i(o[t])===e));t&&(u[e]=a[t])}})),u}function h(e,t,n=""){const{params:a,original:{page:u={}}={},toPath:c,compiledQuery:l}=t,{attributes:f={},state:d={}}=u,h=c(p(a.filter((({name:e})=>"string"==typeof e)).map((({name:e})=>e)),e,{attributeBindings:f,stateBindings:d})),g=function(e,t,n){const{compiledQuery:r,original:{page:{state:s={}}}}=n,{state:a={}}=e||{},u={};Object.keys(a).filter((e=>!o(s[e]))).forEach((e=>u[e]=a[e]));const c={};return Object.keys(t).forEach((e=>{const n=t[e],[o]=Object.keys(r).filter((t=>{const n=r[t],{routeParamName:o}=n;return i(o)===e}));if(o){c[o]=n}})),{...u,...c}}(e,p(s(l),e,{attributeBindings:f,stateBindings:d}),t);return`${n}${h}${r(g)}`}function g(e,t=2){if(function(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}(e))try{Object.freeze(e),t>0&&Object.keys(e).forEach((n=>{if(function(e,t){return t in e}(e,n)){const r=e[n];r&&"object"==typeof r&&g(r,t-1)}}))}catch(e){}return e}const m="LWR",E=1;function y(e,t){return`${e.code}: ${function(e,t){return Array.isArray(t)?e.replace(/\{([0-9]+)\}/g,((e,n)=>t[n])):e}(e.message,t)}`}function b(e,t,n){if(!e)throw new Error(y(t,n))}const I={INVALID_MIXIN_CMP:{code:`${m}4001`,message:"{0} must be an Element type",level:E},MISSING_CONTEXT:{code:`${m}4002`,message:"Could not find context to perform navigation action.",level:E},INVALID_CONTEXT:{code:`${m}4003`,message:"Cannot register navigation context; it must have this shape: { navigate, generateUrl, subscribe }",level:E},MULTIPLE_ROOTS:{code:`${m}4004`,message:"Router connection failed. There can only be one root router.",level:E},MULTIPLE_CHILDREN:{code:`${m}4005`,message:"Could not add to the navigation hierarchy. There can only be one child per navigation node.",level:E},MISSING_ROUTE:{code:`${m}4006`,message:'A route cannot be created to navigate to URL "{0}"',level:E,address:"{0}"},MISSING_URL:{code:`${m}4007`,message:'A URL cannot be created to navigate to route "{0}"',level:E,address:"{0}"},PRENAV_FAILED:{code:`${m}4008`,message:'A preNavigate hook listener blocked routing to "{0}"',level:2,address:"{0}"},MISSING_ROUTE_TEMPLATE:{code:`${m}4009`,message:'A route definition must contain a "uri" property.',level:E},MISSING_ROUTE_CMP:{code:`${m}4016`,message:"Expected a route view component with a default export.",level:E},MISSING_DATA_CONTEXT:{code:`${m}4018`,message:"Could not find context to retrieve navigation data.",level:E},INVALID_ROUTE_QUERY:{code:`${m}4019`,message:"Invalid query param in route definition.",level:E},MISSING_PAGE_BINDING:{code:`${m}4020`,message:"Route definition must provide page binding",level:E},INVALID_PAGE_BINDING:{code:`${m}4021`,message:"Invalid page binding in route definition",level:E},INVALID_URI_SYNTAX:{code:`${m}4022`,message:"Invalid uri syntax. URI cannot contain *, +, (, ), ",level:E},VIEW_IMPORT_FAILED:{code:`${m}4023`,message:'Error importing view with name "{0}", failure was: {1}',level:E,stack:"{2}"},VIEW_MISSING:{code:`${m}4024`,message:'Expected a view with name "{0}" in the viewset',level:E},VIEW_IMPORT_FAILED_WITH_SPECIFIER:{code:`${m}4025`,message:'Error importing module "{0}" from view with name "{1}", failure was: {2}',level:E,stack:"{3}"},NO_ROUTE_MATCH:{code:`${m}4026`,message:"A routing match cannot be found for: {0}",level:E},INVALID_ROUTE_HANDLER:{code:`${m}4027`,message:'Route definition "{0}" does not have a valid route handler module',level:E},DESTINATION_NOT_FOUND:{code:`${m}4028`,message:"Route handler returned 404: Not Found",level:E},DESTINATION_ERROR:{code:`${m}4029`,message:"Route handler returned error status {0}: {1}",level:E,stack:"{2}"},NO_INIT_URL:{code:`${m}4030`,message:'Cannot initialize a server router without a "url"',level:E}};function v(e){return e.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1")}function R(e){return e&&e.sensitive?"":"i"}function $(e,t={}){const n=function(e){const t=[];let n=0;for(;n<e.length;){const r=e[n];if("*"!==r&&"+"!==r&&"?"!==r)if("\\"!==r)if("{"!==r)if("}"!==r)if(":"!==r)if("("!==r)t.push({type:"CHAR",index:n,value:e[n++]});else{let r=1,o="",i=n+1;if("?"===e[i])throw new TypeError(`Pattern cannot start with "?" at ${i}`);for(;i<e.length;)if("\\"!==e[i]){if(")"===e[i]){if(r--,0===r){i++;break}}else if("("===e[i]&&(r++,"?"!==e[i+1]))throw new TypeError(`Capturing groups are not allowed at ${i}`);o+=e[i++]}else o+=e[i++]+e[i++];if(r)throw new TypeError(`Unbalanced pattern at ${n}`);if(!o)throw new TypeError(`Missing pattern at ${n}`);t.push({type:"PATTERN",index:n,value:o}),n=i}else{let r="",o=n+1;for(;o<e.length;){const t=e.charCodeAt(o);if(!(t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122||95===t))break;r+=e[o++]}if(!r)throw new TypeError(`Missing parameter name at ${n}`);t.push({type:"NAME",index:n,value:r}),n=o}else t.push({type:"CLOSE",index:n,value:e[n++]});else t.push({type:"OPEN",index:n,value:e[n++]});else t.push({type:"ESCAPED_CHAR",index:n++,value:e[n++]});else t.push({type:"MODIFIER",index:n,value:e[n++]})}return t.push({type:"END",index:n,value:""}),t}(e),{prefixes:r="./"}=t,o=`[^${v(t.delimiter||"/#?")}]+?`,i=[];let s=0,a=0,u="";const c=e=>{if(a<n.length&&n[a].type===e)return n[a++].value},l=e=>{const t=c(e);if(void 0!==t)return t;const{type:r,index:o}=n[a];throw new TypeError(`Unexpected ${r} at ${o}, expected ${e}`)},f=()=>{let e,t="";for(;e=c("CHAR")||c("ESCAPED_CHAR");)t+=e;return t};for(;a<n.length;){const e=c("CHAR"),t=c("NAME"),n=c("PATTERN");if(t||n){let a=e||"";-1===r.indexOf(a)&&(u+=a,a=""),u&&(i.push(u),u=""),i.push({name:t||s++,prefix:a,suffix:"",pattern:n||o,modifier:c("MODIFIER")||""});continue}const a=e||c("ESCAPED_CHAR");if(a){u+=a;continue}u&&(i.push(u),u="");if(c("OPEN")){const e=f(),t=c("NAME")||"",n=c("PATTERN")||"",r=f();l("CLOSE"),i.push({name:t||(n?s++:""),pattern:t&&!n?o:n,prefix:e,suffix:r,modifier:c("MODIFIER")||""})}else l("END")}return i}function O(e,t){return function(e,t={}){const n=R(t),{encode:r=(e=>e),validate:o=!0}=t,i=e.map((e=>{if("object"==typeof e)return new RegExp(`^(?:${e.pattern})$`,n)}));return t=>{let n="";for(let s=0;s<e.length;s++){const a=e[s];if("string"==typeof a){n+=a;continue}const u=t?t[a.name]:void 0,c="?"===a.modifier||"*"===a.modifier,l="*"===a.modifier||"+"===a.modifier;if(Array.isArray(u)){if(!l)throw new TypeError(`Expected "${a.name}" to not repeat, but got an array`);if(0===u.length){if(c)continue;throw new TypeError(`Expected "${a.name}" to not be empty`)}for(let e=0;e<u.length;e++){const t=r(u[e],a);if(o&&!i[s].test(t))throw new TypeError(`Expected all "${a.name}" to match "${a.pattern}", but got "${t}"`);n+=a.prefix+t+a.suffix}continue}if("string"==typeof u||"number"==typeof u){const e=r(String(u),a);if(o&&!i[s].test(e))throw new TypeError(`Expected "${a.name}" to match "${a.pattern}", but got "${e}"`);n+=a.prefix+e+a.suffix;continue}if(c)continue;const f=l?"an array":"a string";throw new TypeError(`Expected "${a.name}" to be ${f}`)}return n}}($(e,t),t)}function N(e,t,n){return function(e,t,n={}){const{strict:r=!1,start:o=!0,end:i=!0,encode:s=(e=>e)}=n,a=`[${v(n.endsWith||"")}]|$`,u=`[${v(n.delimiter||"/#?")}]`;let c=o?"^":"";for(const n of e)if("string"==typeof n)c+=v(s(n));else{const e=v(s(n.prefix)),r=v(s(n.suffix));if(n.pattern)if(t&&t.push(n),e||r)if("+"===n.modifier||"*"===n.modifier){const t="*"===n.modifier?"?":"";c+=`(?:${e}((?:${n.pattern})(?:${r}${e}(?:${n.pattern}))*)${r})${t}`}else c+=`(?:${e}(${n.pattern})${r})${n.modifier}`;else c+=`(${n.pattern})${n.modifier}`;else c+=`(?:${e}${r})${n.modifier}`}if(i)r||(c+=`${u}?`),c+=n.endsWith?`(?=${a})`:"$";else{const t=e[e.length-1],n="string"==typeof t?u.indexOf(t[t.length-1])>-1:void 0===t;r||(c+=`(?:${u}(?=${a}))?`),n||(c+=`(?=${u}|${a})`)}return new RegExp(c,R(n))}($(e,n),t,n)}function _(e,t,n){return e instanceof RegExp?function(e,t){if(!t)return e;const n=e.source.match(/\((?!\?)/g);if(n)for(let e=0;e<n.length;e++)t.push({name:e,prefix:"",suffix:"",modifier:"",pattern:""});return e}(e,t):Array.isArray(e)?function(e,t,n){const r=e.map((e=>_(e,t,n).source));return new RegExp(`(?:${r.join("|")})`,R(n))}(e,t,n):N(e,t,n)}const{INVALID_ROUTE_QUERY:A,MISSING_ROUTE_TEMPLATE:x,MISSING_PAGE_BINDING:T,INVALID_PAGE_BINDING:w,INVALID_URI_SYNTAX:D}=I;function U(e){const{routes:r,caseSensitive:a}=e;return r.map((e=>function(e,r=!1){const a=[],{uri:u,page:c}=e;b(!!u,x),b(function(e=""){const t=["*","(",")",";"].some((t=>e.indexOf(t)>=0));return!t}(u),D),b(!!c,T);const l=t(u),f=n(u),d=_(l,a,{sensitive:r,end:!1!==e.exact}),p=O(l,{encode:encodeURIComponent}),h=function(e){const t={};return Object.keys(e).forEach((n=>{const r=e[n];b(!o(n)||null===r,A),o(n)?t[n.substr(1)]={routeParamName:n}:r&&o(r)?t[n]={routeParamName:r}:t[n]={literalValue:null===r?null:r}})),t}(f),g=function(e,t=!1){const n=n=>{const r=Object.keys(n),o=Object.keys(e);return o.every((e=>r.indexOf(e)>=0))?o.reduce(((r,o)=>{if(null===r)return null;const{literalValue:i,routeParamName:s}=e[o],a=n[o];let u=!0;return"string"==typeof i?u=t?i===a:i.toUpperCase()===(null==a?a:a.toUpperCase()):null===i&&(u=a===i),r=u?{...r,[o]:{value:a,routeParamName:s}}:null}),{}):null};return n}(h,r),m={original:e,regex:d,params:a,toPath:p,compiledQuery:h,queryMatcher:g};return b(function(e){const{original:{page:t}={},params:n,compiledQuery:r}=e,a=t?t.type:t,u=(t?t.attributes:t)||{},c=(t?t.state:t)||{};if("string"!=typeof a||"object"!=typeof u||"object"!=typeof c)return!1;const l=Object.values(n).map((({name:e})=>e)),f=s(r),d=[...l,...f],p=Object.values(u).filter(o).map(i),h=Object.values(c).filter(o).map(i),g=d.every((e=>"string"==typeof e&&(p.indexOf(e)>=0||h.indexOf(e)>=0))),m=d.length===p.length+h.length;return!!(t&&a&&u&&c&&g&&m)}(m),w),m}(e,a)))}function P(){let e,t,n=[];const r=r=>{n.filter((e=>null!==e)).forEach((e=>e.error&&e.error(r))),e=void 0,t=r};return{next:r=>{n.filter((e=>null!==e)).forEach((e=>e.next&&e.next(r))),e=r,t=void 0},error:r,complete:()=>{n.filter((e=>null!==e)).forEach((e=>e.complete&&e.complete())),n=[],e=void 0,t=void 0},subscribe:(o,i=!0)=>{(e=>{n.push(e)})(o),e&&i&&o.next(e),t&&r(t);const s=n.length-1;return{unsubscribe:()=>(e=>{n=[...n.slice(0,e),...n.slice(e+1)]})(s)}}}}class C{constructor(e){this.deprecatedConfig={},this.routeHandlerId=0,this.compiledRoutes=[],this.routeObservable=P(),this.config={basePath:e.basePath||"",caseSensitive:Boolean(e.caseSensitive),routes:e.routes||[],generateUrl:e=>d(e,this.compiledRoutes,this.config.basePath),parseUrl:e=>function(e,t,n=""){const r=f(e,t,n);return r&&r.route&&r.route.pageReference?r.route.pageReference:null}(e,this.compiledRoutes,this.config.basePath)};const{DEPRECATED_getRouteFromUrl:t,DEPRECATED_getUrlFromRoute:n}=e;t&&(this.deprecatedConfig.DEPRECATED_getRouteFromUrl=t),n&&(this.deprecatedConfig.DEPRECATED_getUrlFromRoute=n),this.compiledRoutes=U(this.config)}generateUrl(e){const{DEPRECATED_getUrlFromRoute:t}=this.deprecatedConfig;return t?t(e,this.config.generateUrl):this.config.generateUrl(e)}parseUrl(e){const{DEPRECATED_getRouteFromUrl:t}=this.deprecatedConfig;return t?t(e,this.config.parseUrl):this.config.parseUrl(e)}matchRoute(e){const t="string"==typeof e?e:this.generateUrl(e);if(null===t)return null;const n=f(t,this.compiledRoutes,this.config.basePath),r=n&&h(n.route.pageReference,n.routeDefinition,this.config.basePath);return n&&r?{pathMatch:r,route:n.route,routeDefinition:n.routeDefinition.original}:null}async resolveView(e){return new Promise(((t,n)=>{const r=this.matchRoute(e);return r?r.routeDefinition.handler?.().then((e=>{const o=e.default;if(!o)return n(y(I.INVALID_ROUTE_HANDLER,[r.routeDefinition.id]));const i=new o(t);i&&i.update(r.route)})):n(y(I.NO_ROUTE_MATCH,[JSON.stringify(e)]))}))}navigate(e){const t=this.matchRoute(e);if(!t)throw new Error(y(I.MISSING_ROUTE,[JSON.stringify(e)]));this.pendingRoute={...t},this._mapView(this.pendingRoute)}subscribe(e,t){return this.routeObservable.subscribe({next:e,error:()=>{},complete:()=>{}},Boolean(t))}async _mapView(e){const t=Math.random();this.routeHandlerId=t;const n=await(e.routeDefinition.handler?.()),r=n?.default;if(!r)throw new Error(y(I.INVALID_ROUTE_HANDLER,[e.routeDefinition.id]));return this.routeHandler=new r((e=>{this._updateView(t,e)})),this.routeHandler&&this.routeHandler.update(e.route),!0}_updateView(e,t){if(!t||e!==this.routeHandlerId)return;if(!this.pendingRoute)throw new Error("Trying to commit route state without a route");const n=g(t.viewset);this.routeObservable.next({...this.pendingRoute,...t,viewset:n})}}function S(e={}){return new C(e)}export{S as createRouter};
2
2
  //# sourceMappingURL=router.js.map
@@ -1,2 +1,2 @@
1
- import{parseFragment as e,registerTemplate as t,freezeTemplate as r,createContextProvider as i,registerDecorators as n,registerComponent as o,LightningElement as s}from"lwc";import{ROUTER_VIEW as a,ROUTER_NAV as c,ROUTER_ERROR as d}from"lwr/metrics";import{logOperationEnd as l,logOperationStart as h}from"lwr/profiler";var u=[function(e,t,r){return"span.router-title"+(e?"["+e+"]":"")+" {position: absolute;margin: -1px;border: 0;padding: 0;width: 1px;height: 1px;overflow: hidden;clip: rect(0 0 0 0);text-transform: none;white-space: nowrap;}"}];const p=e`<span class="router-title${0}" aria-live="polite" aria-atomic="true"${2}></span>`,v={key:0},g=[];function f(e,t,r,i){const{s:n,st:o,f:s}=e;return s([n("",v,g,r),o(p(),2)])}var m=t(f);function b(e){if(null==e)throw new TypeError("Provider must be defined.")}f.slots=[""],f.stylesheets=[],f.renderMode="light",u&&f.stylesheets.push.apply(f.stylesheets,u),f.stylesheetToken="lwc-7bis3qj4jjc",f.legacyStylesheetToken="lwr-routerContainer_routerContainer",r(f);class E{constructor(e){this.infoMap=new WeakMap,this.defaultValue=e}getInfo(e){let t=this.infoMap.get(e);return void 0===t&&(t={consumers:new Set},this.infoMap.set(e,t)),t}setContext(e,t){b(e);const r=t,i=this.getInfo(e);i.contextValue=t,i.consumers.forEach((e=>e.provide(r))),0===i.consumers.size&&r?.onComplete&&r.onComplete()}getContext(e){b(e);const{contextValue:t}=this.getInfo(e);return void 0!==t?t:this.defaultValue}clearContext(e){b(e),this.infoMap.delete(e)}subscribeContext(e,t){b(e);const{consumers:r,contextValue:i}=this.getInfo(e);r.has(t)||(r.add(t),t.provide(i))}unsubscribeContext(e,t){b(e),this.getInfo(e).consumers.delete(t)}}function I(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function w(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?I(Object(r),!0).forEach((function(t){N(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):I(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function N(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const y="LWR",_=1;function O(e,t){return Array.isArray(t)?e.replace(/\{([0-9]+)\}/g,((e,r)=>t[r])):e}function P(e,t){const r=w(w({},e),{},{message:O(e.message,t)});return e.address&&(r.address=O(e.address,t)),e.stack&&(r.stack=O(e.stack,t)),r}function R(e,t,r){if(!e)throw new Error(function(e,t){return`${e.code}: ${O(e.message,t)}`}(t,r))}const x={INVALID_MIXIN_CMP:{code:`${y}4001`,message:"{0} must be an Element type",level:_},MISSING_CONTEXT:{code:`${y}4002`,message:"Could not find context to perform navigation action.",level:_},INVALID_CONTEXT:{code:`${y}4003`,message:"Cannot register navigation context; it must have this shape: { navigate, generateUrl, subscribe }",level:_},MULTIPLE_ROOTS:{code:`${y}4004`,message:"Router connection failed. There can only be one root router.",level:_},MULTIPLE_CHILDREN:{code:`${y}4005`,message:"Could not add to the navigation hierarchy. There can only be one child per navigation node.",level:_},MISSING_ROUTE:{code:`${y}4006`,message:'A route cannot be created to navigate to URL "{0}"',level:_,address:"{0}"},MISSING_URL:{code:`${y}4007`,message:'A URL cannot be created to navigate to route "{0}"',level:_,address:"{0}"},PRENAV_FAILED:{code:`${y}4008`,message:'A preNavigate hook listener blocked routing to "{0}"',level:2,address:"{0}"},MISSING_ROUTE_TEMPLATE:{code:`${y}4009`,message:'A route definition must contain a "uri" property.',level:_},MISSING_ROUTE_CMP:{code:`${y}4016`,message:"Expected a route view component with a default export.",level:_},MISSING_DATA_CONTEXT:{code:`${y}4018`,message:"Could not find context to retrieve navigation data.",level:_},INVALID_ROUTE_QUERY:{code:`${y}4019`,message:"Invalid query param in route definition.",level:_},MISSING_PAGE_BINDING:{code:`${y}4020`,message:"Route definition must provide page binding",level:_},INVALID_PAGE_BINDING:{code:`${y}4021`,message:"Invalid page binding in route definition",level:_},INVALID_URI_SYNTAX:{code:`${y}4022`,message:"Invalid uri syntax. URI cannot contain *, +, (, ), ",level:_},VIEW_IMPORT_FAILED:{code:`${y}4023`,message:'Error importing view with name "{0}", failure was: {1}',level:_,stack:"{2}"},VIEW_MISSING:{code:`${y}4024`,message:'Expected a view with name "{0}" in the viewset',level:_},VIEW_IMPORT_FAILED_WITH_SPECIFIER:{code:`${y}4025`,message:'Error importing module "{0}" from view with name "{1}", failure was: {2}',level:_,stack:"{3}"},NO_ROUTE_MATCH:{code:`${y}4026`,message:"A routing match cannot be found for: {0}",level:_},INVALID_ROUTE_HANDLER:{code:`${y}4027`,message:'Route definition "{0}" does not have a valid route handler module',level:_},DESTINATION_NOT_FOUND:{code:`${y}4028`,message:"Route handler returned 404: Not Found",level:_},DESTINATION_ERROR:{code:`${y}4029`,message:"Route handler returned error status {0}: {1}",level:_,stack:"{2}"},NO_INIT_URL:{code:`${y}4030`,message:'Cannot initialize a server router without a "url"',level:_}},C=new WeakMap;function T(e){var t;return(t=class{constructor(e){this._callback=e}connect(){}disconnect(){}update(e,t){t&&this._callback(t)}static setContext(t,r){e.setContext(t,r)}static getContext(t){return e.getContext(t)}static clearContext(t){e.clearContext(t)}static subscribeContext(t,r){e.subscribeContext(t,r)}static unsubscribeContext(t,r){e.unsubscribeContext(t,r)}}).contextSchema={value:"required"},t}const S=T(new E(void 0)),D=T(new E(void 0)),A=new E(void 0),$=class extends(T(A)){async update(e,t){if(t){const r=e&&e.viewName?e.viewName:"default",i=t.viewset[r],n=i,o=n&&n.module||i;let s;if(o)try{const e=await o(),t=e&&e.default;if(!t||void 0===t.constructor)throw new Error("error occurred with view import");this._callback(t)}catch(e){const t=e;s=n.specifier?P(x.VIEW_IMPORT_FAILED_WITH_SPECIFIER,[n.specifier,r,t.message,t.stack||""]):P(x.VIEW_IMPORT_FAILED,[r,t.message,t.stack||""])}else s=P(x.VIEW_MISSING,[r]);t.onComplete&&t.onComplete(s)}}};function M(){const e=[],t=t=>{"function"==typeof t&&e.push(t)};return{add:(e=[])=>{Array.isArray(e)?e.forEach((e=>t(e))):t(e)},compile:t=>0===e.length?Promise.resolve(!0):e.reduce(((e,r)=>e.then((e=>!1===e?Promise.reject():Promise.resolve(r(t))))),Promise.resolve(!0)).then((e=>!1!==e)).catch((e=>{if(e instanceof Error)throw e;return!1})),empty:()=>0===e.length}}function L(e=""){return e=e||"",decodeURIComponent(e)}function U(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}const j="undefined"!=typeof document,k=`universalcontainergetnavigationcontext${U()}`,F=i(D),V=j?i($):void 0,G=i(S);function W(e,t,r,i){r&&i&&(i.setContext(t,e),r(t,{consumerConnectedCallback:i.subscribeContext.bind(i,t),consumerDisconnectedCallback:i.unsubscribeContext.bind(i,t)}))}function H(){let e,t,r=[];const i=i=>{r.filter((e=>null!==e)).forEach((e=>e.error&&e.error(i))),e=void 0,t=i};return{next:i=>{r.filter((e=>null!==e)).forEach((e=>e.next&&e.next(i))),e=i,t=void 0},error:i,complete:()=>{r.filter((e=>null!==e)).forEach((e=>e.complete&&e.complete())),r=[],e=void 0,t=void 0},subscribe:(n,o=!0)=>{(e=>{r.push(e)})(n),e&&o&&n.next(e),t&&i(t);const s=r.length-1;return{unsubscribe:()=>(e=>{r=[...r.slice(0,e),...r.slice(e+1)]})(s)}}}}function B(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function X(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?B(Object(r),!0).forEach((function(t){q(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):B(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function q(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const z=`universalcontainernavigationevent${U()}`,Y=`universalcontainerparentevent${U()}`;class J{constructor(e,t,r){this.pendingRoute=null,this.committedRoute=null,this.contextId=Object.freeze((()=>{})),this.connected=!1,this.preNavFilters=M(),this.errorNavFilters=M(),this._handleNavigationEvent=e=>{const t=e;if(t.detail&&"object"==typeof t.detail){const{url:e,replace:r,address:i}=t.detail;this.config.handleNavigation(i,r)?this.root&&!e?this.root.processError(P(x.MISSING_URL,[JSON.stringify(i)])):this.parent||this.process(e,r):t.stopPropagation()}},this._handleParentEvent=e=>{e.stopImmediatePropagation();const t=e;t&&t.detail&&"function"==typeof t.detail&&t.detail(this)},this.config={handleNavigation:e.handleNavigation||(()=>!0)},this.target=r||window,this.router=t,this.router.contextId=this.contextId,this.routeObservable=H()}get root(){if(!this.parent)return this;let e=this.parent;for(;e;){if(!e.parent)return e;e=e.parent}throw new Error("No root router could be found")}updateWires(e,t,r){if(r)this.processError(r);else{if(this.committedRoute&&e.route===this.committedRoute.route)return;l({id:a,specifier:this.eventId}),this.pendingRoute=this.pendingRoute||X(X({},e),{},{url:t}),this.committedRoute=X(X({},this.pendingRoute),e),D.setContext(this.target,e.route.pageReference),this.routeObservable.next(X(X({},this.committedRoute),{},{viewset:e.viewset})),l({id:c,specifier:this.eventId}),this.child&&this.child.process(this._stripUrlForChild(this.committedRoute.url))}}connect(){this._sendEvent(Y,(e=>{this.parent=e,e.addChild(this)}));const e={navigate:(e,t)=>this.navigate(e,t),generateUrl:e=>this.generateUrl(e),subscribe:(e,t)=>this.subscribe(e,t)};!function(e,t){const r={id:e,value:t,update:e=>{r.value=e}};C.set(r.id,r)}(this.contextId,e),W(this.contextId,this.target,G,S),W(void 0,this.target,F,D),W(void 0,this.target,V,$),this.router.subscribe((e=>{if(404===e.status)return void this.processError(P(x.DESTINATION_NOT_FOUND));if(e.status&&e.status>=400){const t=e.error||new Error;return void this.processError(P(x.DESTINATION_ERROR,[e.status.toString(),t.message,t.stack||""]))}const t=e.route.pageReference||{},r=this.router.generateUrl(t)||"";if(h({id:a,specifier:this.eventId}),e.viewset){const t={viewset:e.viewset,onComplete:this.updateWires.bind(this,e,r)};$.setContext(this.target,t)}else e.route.pageReference&&this.updateWires(e,r)}),!0),j&&(this.target.addEventListener(z,this._handleNavigationEvent),this.target.addEventListener(Y,this._handleParentEvent),this.target.addEventListener(k,(e=>{const t=e;t.detail.callback&&t.detail.callback(this.contextId)}))),this.connected=!0}disconnect(){this.target.removeEventListener(z,this._handleNavigationEvent),this.target.removeEventListener(Y,this._handleParentEvent),this.parent&&(this.parent.child=void 0),this.parent=void 0,this.child&&(this.child.parent=void 0),this.child=void 0,this.connected=!1}addPreNavigate(e){this.preNavFilters.add(e)}addErrorNavigate(e){this.errorNavFilters.add(e)}async addChild(e){if(await new Promise((t=>{setTimeout((()=>{R(!this.child,x.MULTIPLE_CHILDREN),this.child=e,t()}),0)})),this.child&&this.committedRoute){const e=this._stripUrlForChild(this.committedRoute.url);await this.child.preProcess(e)&&this.child.process(e)}}async process(e,t){this.eventId=(new Date).getTime().toString(),h({id:c,specifier:this.eventId});try{this.parent||await this.preProcess(e)}catch(e){if(e.code)return this.processError(e),!1;throw e}const r=this.router.parseUrl(e);return r&&this.router.navigate(r),!0}preProcess(e){const t=this.router.parseUrl(e),r=t&&this.router.matchRoute(t);if(!r)return Promise.reject(P(x.MISSING_ROUTE,[e]));this.pendingRoute=X({url:e},r);return(this.preNavFilters.empty()?Promise.resolve(!0):this.preNavFilters.compile({current:this.committedRoute||void 0,next:this.pendingRoute})).then((t=>t&&this.child?this.child.preProcess(this._stripUrlForChild(e)):t)).then((t=>t||Promise.reject(P(x.PRENAV_FAILED,[e]))))}processError(e){h({id:d}),this.errorNavFilters.compile(e),this.child&&this.child.processError(e)}navigate(e,t){let r=this.router.generateUrl(e);if(r){r=(this.parent&&this.parent.committedRoute&&this.parent.committedRoute.pathMatch||"").concat(r)}this._sendEvent(z,{url:r,replace:t,address:e})}generateUrl(e){const t=this.router.generateUrl(e);if(!t)return null;return`${this.parent&&this.parent.committedRoute&&this.parent.committedRoute.pathMatch||""}${t}`}subscribe(e,t){return this.routeObservable.subscribe({next:e,error:()=>{},complete:()=>{}},Boolean(t))}_sendEvent(e,t){j&&this.target.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:t}))}_stripUrlForChild(e){return this.pendingRoute&&0===e.indexOf(this.pendingRoute.pathMatch)?e.replace(this.pendingRoute.pathMatch,""):e}}function Q(e){const t=function(e=""){if((e=e||"").indexOf("://")<0){const t=window.location.port?`:${window.location.port}`:"",r=`${window.location.protocol}//${window.location.hostname}${t}`,i="/"===e.charAt(0)?"":"/";e=r+i+e}const t={},r=document.createElement("a");r.href=e;const i=r.search.substring(1);return i&&i.split("&").forEach((e=>{const[r,i=""]=e.split("=");t[L(r)]=L(i)})),{href:r.href,origin:`${r.protocol}//${r.hostname}${r.port?`:${r.port}`:""}`,pathname:r.pathname.replace(/(\/)?/,"/"),searchParams:t}}(e),r=t.href.replace(/:\d+/,""),i=t.origin.replace(/:\d+/,"");return r.replace(i,"")}class K extends J{constructor(){super(...arguments),this.historyDisabled=!1}connect(){super.connect(),this.historyDisabled||(j&&window.addEventListener("popstate",this.onpopstate.bind(this)),this.onpopstate())}onpopstate(){!this.parent&&j&&this.catchBrowserUpdate(Q(document.location.href))}disconnect(){super.disconnect(),j&&window.removeEventListener("popstate",this.onpopstate)}async process(e,t,r=!0){const i=await super.process(e);return i&&!this.historyDisabled&&r&&this.connected&&!this.parent&&(t?function(e,t){const r=t||{};window.history.replaceState(r,"",e)}(e):function(e,t){const r=t||{};window.history.pushState(r,"",e)}(e)),i}catchBrowserUpdate(e){this.process(e,!1,!1)}}let Z=!1;class ee extends s{constructor(){super(),this.router=void 0,this.historyDisabled=!1,this.currentTitle=j?document.title:""}connectedCallback(){const e={historyDisabled:this.historyDisabled,handleNavigation:this.handleNavigation.bind(this)};j&&this.router&&(this.routerApi=function(e,t={},r){const i=t.historyDisabled?new J(t,r,e):new K(t,r,e),n={addPreNavigate:e=>(i.addPreNavigate(e),n),addPostNavigate:e=>(i.subscribe(e),n),addErrorNavigate:e=>(i.addErrorNavigate(e),n),connect:()=>{i.connect(),R(!Z||!!i.parent,x.MULTIPLE_ROOTS),Z=Z||!i.parent,n.id=i.contextId},disconnect:()=>{Z=Z&&!!i.parent,i.disconnect()}};return n}(this,e,this.router),this.routerApi.addPreNavigate(this.preNavigate.bind(this)).addPostNavigate(this.postNavigate.bind(this)).addErrorNavigate(this.errorNavigate.bind(this)).connect())}preNavigate(e){const t=this._createEvent("prenavigate",e,!0);return this.dispatchEvent(t),!t.defaultPrevented}postNavigate(e){this.dispatchEvent(this._createEvent("postnavigate",e));const t=e.routeDefinition.metadata&&e.routeDefinition.metadata.title;t&&(this.currentTitle=t,document.title=t);const r=this.querySelector("span.router-title");r&&(r.innerHTML=this.currentTitle)}errorNavigate(e){return this.dispatchEvent(this._createEvent("errornavigate",e)),!0}handleNavigation(e,t){const r=this._createEvent("handlenavigation",{address:e,replace:t},!0);return this.dispatchEvent(r),!r.defaultPrevented}disconnectedCallback(){this.routerApi&&this.routerApi.disconnect()}_createEvent(e,t,r){return new CustomEvent(e,{detail:t,bubbles:!1,composed:!1,cancelable:r})}}ee.renderMode="light",n(ee,{publicProps:{router:{config:0},historyDisabled:{config:0}}});var te=o(ee,{tmpl:m,sel:"lwr-router-container",apiVersion:59});export{te as default};
1
+ import{parseFragment as e,registerTemplate as t,freezeTemplate as i,createContextProvider as r,registerDecorators as s,registerComponent as o,LightningElement as n}from"lwc";import{ROUTER_VIEW as a,ROUTER_NAV as c,ROUTER_ERROR as d}from"lwr/metrics";import{logOperationEnd as h,logOperationStart as l}from"lwr/profiler";var u=[function(e,t,i){return"span.router-title"+(e?"["+e+"]":"")+" {position: absolute;margin: -1px;border: 0;padding: 0;width: 1px;height: 1px;overflow: hidden;clip: rect(0 0 0 0);text-transform: none;white-space: nowrap;}"}];const p=e`<span class="router-title${0}" aria-live="polite" aria-atomic="true"${2}></span>`,v={key:0},g=[];function m(e,t,i,r){const{s:s,st:o}=e;return[s("",v,g,i),o(p(),2)]}var f=t(m);function E(e){if(null==e)throw new TypeError("Provider must be defined.")}m.slots=[""],m.stylesheets=[],m.renderMode="light",u&&m.stylesheets.push.apply(m.stylesheets,u),m.stylesheetToken="lwc-7bis3qj4jjc",m.legacyStylesheetToken="lwr-routerContainer_routerContainer",i(m);class I{constructor(e){this.infoMap=new WeakMap,this.defaultValue=e}getInfo(e){let t=this.infoMap.get(e);return void 0===t&&(t={consumers:new Set},this.infoMap.set(e,t)),t}setContext(e,t){E(e);const i=t,r=this.getInfo(e);r.contextValue=t,r.consumers.forEach((e=>e.provide(i))),0===r.consumers.size&&i?.onComplete&&i.onComplete()}getContext(e){E(e);const{contextValue:t}=this.getInfo(e);return void 0!==t?t:this.defaultValue}clearContext(e){E(e),this.infoMap.delete(e)}subscribeContext(e,t){E(e);const{consumers:i,contextValue:r}=this.getInfo(e);i.has(t)||(i.add(t),t.provide(r))}unsubscribeContext(e,t){E(e),this.getInfo(e).consumers.delete(t)}}const b="LWR",N=1;function w(e,t){return Array.isArray(t)?e.replace(/\{([0-9]+)\}/g,((e,i)=>t[i])):e}function _(e,t){const i={...e,message:w(e.message,t)};return e.address&&(i.address=w(e.address,t)),e.stack&&(i.stack=w(e.stack,t)),i}function R(e,t,i){if(!e)throw new Error(function(e,t){return`${e.code}: ${w(e.message,t)}`}(t,i))}const x={INVALID_MIXIN_CMP:{code:`${b}4001`,message:"{0} must be an Element type",level:N},MISSING_CONTEXT:{code:`${b}4002`,message:"Could not find context to perform navigation action.",level:N},INVALID_CONTEXT:{code:`${b}4003`,message:"Cannot register navigation context; it must have this shape: { navigate, generateUrl, subscribe }",level:N},MULTIPLE_ROOTS:{code:`${b}4004`,message:"Router connection failed. There can only be one root router.",level:N},MULTIPLE_CHILDREN:{code:`${b}4005`,message:"Could not add to the navigation hierarchy. There can only be one child per navigation node.",level:N},MISSING_ROUTE:{code:`${b}4006`,message:'A route cannot be created to navigate to URL "{0}"',level:N,address:"{0}"},MISSING_URL:{code:`${b}4007`,message:'A URL cannot be created to navigate to route "{0}"',level:N,address:"{0}"},PRENAV_FAILED:{code:`${b}4008`,message:'A preNavigate hook listener blocked routing to "{0}"',level:2,address:"{0}"},MISSING_ROUTE_TEMPLATE:{code:`${b}4009`,message:'A route definition must contain a "uri" property.',level:N},MISSING_ROUTE_CMP:{code:`${b}4016`,message:"Expected a route view component with a default export.",level:N},MISSING_DATA_CONTEXT:{code:`${b}4018`,message:"Could not find context to retrieve navigation data.",level:N},INVALID_ROUTE_QUERY:{code:`${b}4019`,message:"Invalid query param in route definition.",level:N},MISSING_PAGE_BINDING:{code:`${b}4020`,message:"Route definition must provide page binding",level:N},INVALID_PAGE_BINDING:{code:`${b}4021`,message:"Invalid page binding in route definition",level:N},INVALID_URI_SYNTAX:{code:`${b}4022`,message:"Invalid uri syntax. URI cannot contain *, +, (, ), ",level:N},VIEW_IMPORT_FAILED:{code:`${b}4023`,message:'Error importing view with name "{0}", failure was: {1}',level:N,stack:"{2}"},VIEW_MISSING:{code:`${b}4024`,message:'Expected a view with name "{0}" in the viewset',level:N},VIEW_IMPORT_FAILED_WITH_SPECIFIER:{code:`${b}4025`,message:'Error importing module "{0}" from view with name "{1}", failure was: {2}',level:N,stack:"{3}"},NO_ROUTE_MATCH:{code:`${b}4026`,message:"A routing match cannot be found for: {0}",level:N},INVALID_ROUTE_HANDLER:{code:`${b}4027`,message:'Route definition "{0}" does not have a valid route handler module',level:N},DESTINATION_NOT_FOUND:{code:`${b}4028`,message:"Route handler returned 404: Not Found",level:N},DESTINATION_ERROR:{code:`${b}4029`,message:"Route handler returned error status {0}: {1}",level:N,stack:"{2}"},NO_INIT_URL:{code:`${b}4030`,message:'Cannot initialize a server router without a "url"',level:N}},C=new WeakMap;function T(e){var t;return(t=class{constructor(e){this._callback=e}connect(){}disconnect(){}update(e,t){t&&this._callback(t)}static setContext(t,i){e.setContext(t,i)}static getContext(t){return e.getContext(t)}static clearContext(t){e.clearContext(t)}static subscribeContext(t,i){e.subscribeContext(t,i)}static unsubscribeContext(t,i){e.unsubscribeContext(t,i)}}).contextSchema={value:"required"},t}const P=T(new I(void 0)),y=T(new I(void 0)),S=new I(void 0),A=class extends(T(S)){async update(e,t){if(t){const i=e&&e.viewName?e.viewName:"default",r=t.viewset[i],s=r,o=s&&s.module||r;let n;if(o)try{const e=await o(),t=e&&e.default;if(!t||void 0===t.constructor)throw new Error("error occurred with view import");this._callback(t)}catch(e){const t=e;n=s.specifier?_(x.VIEW_IMPORT_FAILED_WITH_SPECIFIER,[s.specifier,i,t.message,t.stack||""]):_(x.VIEW_IMPORT_FAILED,[i,t.message,t.stack||""])}else n=_(x.VIEW_MISSING,[i]);t.onComplete&&t.onComplete(n)}}};function $(){const e=[],t=t=>{"function"==typeof t&&e.push(t)};return{add:(e=[])=>{Array.isArray(e)?e.forEach((e=>t(e))):t(e)},compile:t=>0===e.length?Promise.resolve(!0):e.reduce(((e,i)=>e.then((e=>!1===e?Promise.reject():Promise.resolve(i(t))))),Promise.resolve(!0)).then((e=>!1!==e)).catch((e=>{if(e instanceof Error)throw e;return!1})),empty:()=>0===e.length}}function M(e=""){return e=e||"",decodeURIComponent(e)}function L(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}const O="undefined"!=typeof document,U=`universalcontainergetnavigationcontext${L()}`,D=r(y),k=O?r(A):void 0,F=r(P);function V(e,t,i,r){i&&r&&(r.setContext(t,e),i(t,{consumerConnectedCallback:r.subscribeContext.bind(r,t),consumerDisconnectedCallback:r.unsubscribeContext.bind(r,t)}))}function G(){let e,t,i=[];const r=r=>{i.filter((e=>null!==e)).forEach((e=>e.error&&e.error(r))),e=void 0,t=r};return{next:r=>{i.filter((e=>null!==e)).forEach((e=>e.next&&e.next(r))),e=r,t=void 0},error:r,complete:()=>{i.filter((e=>null!==e)).forEach((e=>e.complete&&e.complete())),i=[],e=void 0,t=void 0},subscribe:(s,o=!0)=>{(e=>{i.push(e)})(s),e&&o&&s.next(e),t&&r(t);const n=i.length-1;return{unsubscribe:()=>(e=>{i=[...i.slice(0,e),...i.slice(e+1)]})(n)}}}}const W=`universalcontainernavigationevent${L()}`,j=`universalcontainerparentevent${L()}`;class H{constructor(e,t,i){this.pendingRoute=null,this.committedRoute=null,this.contextId=Object.freeze((()=>{})),this.connected=!1,this.preNavFilters=$(),this.errorNavFilters=$(),this._handleNavigationEvent=e=>{const t=e;if(t.detail&&"object"==typeof t.detail){const{url:e,replace:i,address:r}=t.detail;this.config.handleNavigation(r,i)?this.root&&!e?this.root.processError(_(x.MISSING_URL,[JSON.stringify(r)])):this.parent||this.process(e,i):t.stopPropagation()}},this._handleParentEvent=e=>{e.stopImmediatePropagation();const t=e;t&&t.detail&&"function"==typeof t.detail&&t.detail(this)},this.config={handleNavigation:e.handleNavigation||(()=>!0)},this.target=i||window,this.router=t,this.router.contextId=this.contextId,this.routeObservable=G()}get root(){if(!this.parent)return this;let e=this.parent;for(;e;){if(!e.parent)return e;e=e.parent}throw new Error("No root router could be found")}updateWires(e,t,i){if(i)this.processError(i);else{if(this.committedRoute&&e.route===this.committedRoute.route)return;h({id:a,specifier:this.eventId}),this.pendingRoute=this.pendingRoute||{...e,url:t},this.committedRoute={...this.pendingRoute,...e},y.setContext(this.target,e.route.pageReference),this.routeObservable.next({...this.committedRoute,viewset:e.viewset}),h({id:c,specifier:this.eventId}),this.child&&this.child.process(this._stripUrlForChild(this.committedRoute.url))}}connect(){this._sendEvent(j,(e=>{this.parent=e,e.addChild(this)}));const e={navigate:(e,t)=>this.navigate(e,t),generateUrl:e=>this.generateUrl(e),subscribe:(e,t)=>this.subscribe(e,t)};!function(e,t){const i={id:e,value:t,update:e=>{i.value=e}};C.set(i.id,i)}(this.contextId,e),V(this.contextId,this.target,F,P),V(void 0,this.target,D,y),V(void 0,this.target,k,A),this.router.subscribe((e=>{if(404===e.status)return void this.processError(_(x.DESTINATION_NOT_FOUND));if(e.status&&e.status>=400){const t=e.error||new Error;return void this.processError(_(x.DESTINATION_ERROR,[e.status.toString(),t.message,t.stack||""]))}const t=e.route.pageReference||{},i=this.router.generateUrl(t)||"";if(l({id:a,specifier:this.eventId}),e.viewset){const t={viewset:e.viewset,onComplete:this.updateWires.bind(this,e,i)};A.setContext(this.target,t)}else e.route.pageReference&&this.updateWires(e,i)}),!0),O&&(this.target.addEventListener(W,this._handleNavigationEvent),this.target.addEventListener(j,this._handleParentEvent),this.target.addEventListener(U,(e=>{const t=e;t.detail.callback&&t.detail.callback(this.contextId)}))),this.connected=!0}disconnect(){this.target.removeEventListener(W,this._handleNavigationEvent),this.target.removeEventListener(j,this._handleParentEvent),this.parent&&(this.parent.child=void 0),this.parent=void 0,this.child&&(this.child.parent=void 0),this.child=void 0,this.connected=!1}addPreNavigate(e){this.preNavFilters.add(e)}addErrorNavigate(e){this.errorNavFilters.add(e)}async addChild(e){if(await new Promise((t=>{setTimeout((()=>{R(!this.child,x.MULTIPLE_CHILDREN),this.child=e,t()}),0)})),this.child&&this.committedRoute){const e=this._stripUrlForChild(this.committedRoute.url);await this.child.preProcess(e)&&this.child.process(e)}}async process(e,t){this.eventId=(new Date).getTime().toString(),l({id:c,specifier:this.eventId});try{this.parent||await this.preProcess(e)}catch(e){if(e.code)return this.processError(e),!1;throw e}const i=this.router.parseUrl(e);return i&&this.router.navigate(i),!0}preProcess(e){const t=this.router.parseUrl(e),i=t&&this.router.matchRoute(t);if(!i)return Promise.reject(_(x.MISSING_ROUTE,[e]));this.pendingRoute={url:e,...i};return(this.preNavFilters.empty()?Promise.resolve(!0):this.preNavFilters.compile({current:this.committedRoute||void 0,next:this.pendingRoute})).then((t=>t&&this.child?this.child.preProcess(this._stripUrlForChild(e)):t)).then((t=>t||Promise.reject(_(x.PRENAV_FAILED,[e]))))}processError(e){l({id:d}),this.errorNavFilters.compile(e),this.child&&this.child.processError(e)}navigate(e,t){let i=this.router.generateUrl(e);if(i){i=(this.parent&&this.parent.committedRoute&&this.parent.committedRoute.pathMatch||"").concat(i)}this._sendEvent(W,{url:i,replace:t,address:e})}generateUrl(e){const t=this.router.generateUrl(e);if(!t)return null;return`${this.parent&&this.parent.committedRoute&&this.parent.committedRoute.pathMatch||""}${t}`}subscribe(e,t){return this.routeObservable.subscribe({next:e,error:()=>{},complete:()=>{}},Boolean(t))}_sendEvent(e,t){O&&this.target.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:t}))}_stripUrlForChild(e){return this.pendingRoute&&0===e.indexOf(this.pendingRoute.pathMatch)?e.replace(this.pendingRoute.pathMatch,""):e}}function B(e){const t=function(e=""){if((e=e||"").indexOf("://")<0){const t=window.location.port?`:${window.location.port}`:"",i=`${window.location.protocol}//${window.location.hostname}${t}`,r="/"===e.charAt(0)?"":"/";e=i+r+e}const t={},i=document.createElement("a");i.href=e;const r=i.search.substring(1);return r&&r.split("&").forEach((e=>{const[i,r=""]=e.split("=");t[M(i)]=M(r)})),{href:i.href,origin:`${i.protocol}//${i.hostname}${i.port?`:${i.port}`:""}`,pathname:i.pathname.replace(/(\/)?/,"/"),searchParams:t}}(e),i=t.href.replace(/:\d+/,""),r=t.origin.replace(/:\d+/,"");return i.replace(r,"")}class X extends H{constructor(){super(...arguments),this.historyDisabled=!1}connect(){super.connect(),this.historyDisabled||(O&&window.addEventListener("popstate",this.onpopstate.bind(this)),this.onpopstate())}onpopstate(){!this.parent&&O&&this.catchBrowserUpdate(B(document.location.href))}disconnect(){super.disconnect(),O&&window.removeEventListener("popstate",this.onpopstate)}async process(e,t,i=!0){const r=await super.process(e);return r&&!this.historyDisabled&&i&&this.connected&&!this.parent&&(t?function(e,t){const i=t||{};window.history.replaceState(i,"",e)}(e):function(e,t){const i=t||{};window.history.pushState(i,"",e)}(e)),r}catchBrowserUpdate(e){this.process(e,!1,!1)}}let q=!1;class z extends n{constructor(){super(),this.router=void 0,this.historyDisabled=!1,this.currentTitle=O?document.title:""}connectedCallback(){const e={historyDisabled:this.historyDisabled,handleNavigation:this.handleNavigation.bind(this)};O&&this.router&&(this.routerApi=function(e,t={},i){const r=t.historyDisabled?new H(t,i,e):new X(t,i,e),s={addPreNavigate:e=>(r.addPreNavigate(e),s),addPostNavigate:e=>(r.subscribe(e),s),addErrorNavigate:e=>(r.addErrorNavigate(e),s),connect:()=>{r.connect(),R(!q||!!r.parent,x.MULTIPLE_ROOTS),q=q||!r.parent,s.id=r.contextId},disconnect:()=>{q=q&&!!r.parent,r.disconnect()}};return s}(this,e,this.router),this.routerApi.addPreNavigate(this.preNavigate.bind(this)).addPostNavigate(this.postNavigate.bind(this)).addErrorNavigate(this.errorNavigate.bind(this)).connect())}preNavigate(e){const t=this._createEvent("prenavigate",e,!0);return this.dispatchEvent(t),!t.defaultPrevented}postNavigate(e){this.dispatchEvent(this._createEvent("postnavigate",e));const t=e.routeDefinition.metadata&&e.routeDefinition.metadata.title;t&&(this.currentTitle=t,document.title=t);const i=this.querySelector("span.router-title");i&&(i.innerHTML=this.currentTitle)}errorNavigate(e){return this.dispatchEvent(this._createEvent("errornavigate",e)),!0}handleNavigation(e,t){const i=this._createEvent("handlenavigation",{address:e,replace:t},!0);return this.dispatchEvent(i),!i.defaultPrevented}disconnectedCallback(){this.routerApi&&this.routerApi.disconnect()}_createEvent(e,t,i){return new CustomEvent(e,{detail:t,bubbles:!1,composed:!1,cancelable:i})}}z.renderMode="light",s(z,{publicProps:{router:{config:0},historyDisabled:{config:0}}});var Y=o(z,{tmpl:f,sel:"lwr-router-container",apiVersion:60});export{Y as default};
2
2
  //# sourceMappingURL=routerContainer.js.map
@@ -1,11 +1,11 @@
1
- import { Contextualizer } from 'lwc';
2
- import type { ContextualWireAdapter } from 'lwr/contextUtils';
3
- export declare const currentPageReferenceContextualizer: Contextualizer<import("lwr/routerUtils").PageReference>;
4
- export declare const currentViewContextualizer: Contextualizer<{
1
+ /// <reference types="lwc" />
2
+ import type { ContextualWireAdapter, LwcContextualizer } from 'lwr/contextUtils';
3
+ export declare const currentPageReferenceContextualizer: import("lwc").Contextualizer<import("lwr/routerUtils").PageReference>;
4
+ export declare const currentViewContextualizer: import("lwc").Contextualizer<{
5
5
  viewset: import("lwr/routerUtils").ViewSet;
6
6
  onComplete?: Function | undefined;
7
7
  }> | undefined;
8
- export declare const navigationContextContextualizer: Contextualizer<import("lwr/navigation").ContextId>;
8
+ export declare const navigationContextContextualizer: import("lwc").Contextualizer<import("lwr/navigation").ContextId>;
9
9
  /**
10
10
  *
11
11
  * @param {TContext} contextValue - Context API object
@@ -13,5 +13,5 @@ export declare const navigationContextContextualizer: Contextualizer<import("lwr
13
13
  * @param {Contextualizer} contextualizer - Function for providing this context to subtree nodes wired to a specific adapter
14
14
  * @param {ContextualWireAdapter<TContext, TEmit, TConfig>} contextualAdapter - Contextual wire adapter capable of subscribing to context changes
15
15
  */
16
- export declare function provideContext<TContext, TEmit, TConfig>(contextValue: TContext, providerNode: EventTarget, contextualizer?: Contextualizer, contextualAdapter?: ContextualWireAdapter<TContext, TEmit, TConfig>): void;
16
+ export declare function provideContext<TContext, TEmit, TConfig>(contextValue: TContext, providerNode: EventTarget, contextualizer?: LwcContextualizer, contextualAdapter?: ContextualWireAdapter<TContext, TEmit, TConfig>): void;
17
17
  //# sourceMappingURL=contextProvider.d.ts.map
@@ -14,7 +14,7 @@ export const navigationContextContextualizer = createContextProvider(NavigationC
14
14
  */
15
15
  export function provideContext(contextValue, providerNode, contextualizer, contextualAdapter) {
16
16
  if (contextualizer && contextualAdapter) {
17
- // Set up provider to give context to wire adpaters so that a component connected
17
+ // Set up provider to give context to wire adapters so that a component connected
18
18
  // under the providerNode subtree and wired to those adapters will receive this id
19
19
  contextualAdapter.setContext(providerNode, contextValue);
20
20
  contextualizer(providerNode, {
@@ -1,4 +1,4 @@
1
- import type { ContextConsumer } from 'lwc';
1
+ import type { LwcContextConsumer } from './contextUtils';
2
2
  /**
3
3
  * Manages context for various providers
4
4
  */
@@ -14,7 +14,7 @@ export declare class ContextInfo<TContext> {
14
14
  * @param targetProvider the context provider
15
15
  */
16
16
  getInfo(targetProvider: object): {
17
- consumers: Set<ContextConsumer>;
17
+ consumers: Set<LwcContextConsumer>;
18
18
  contextValue: TContext;
19
19
  };
20
20
  /**
@@ -48,13 +48,13 @@ export declare class ContextInfo<TContext> {
48
48
  * @param {Object} targetProvider
49
49
  * @param {ContextConsumer} consumer object with a provide(context) function property.
50
50
  */
51
- subscribeContext(targetProvider: object, consumer: ContextConsumer): void;
51
+ subscribeContext(targetProvider: object, consumer: LwcContextConsumer): void;
52
52
  /**
53
53
  * Unsubscribe a previously subscribed consumer from listening to changes on the
54
54
  * target
55
55
  * @param {Object} targetProvider
56
56
  * @param {ContextConsumer} consumer
57
57
  */
58
- unsubscribeContext(targetProvider: object, consumer: ContextConsumer): void;
58
+ unsubscribeContext(targetProvider: object, consumer: LwcContextConsumer): void;
59
59
  }
60
60
  //# sourceMappingURL=contextInfo.d.ts.map
@@ -1,4 +1,4 @@
1
- import type { ContextConsumer } from 'lwc';
1
+ import type { ContextConsumer, Contextualizer } from 'lwc';
2
2
  import { ContextInfo } from './contextInfo';
3
3
  export { ContextInfo };
4
4
  export type { NavigationHelm } from './navigationApiStore';
@@ -17,8 +17,10 @@ export interface ContextualWireAdapter<TContext, TConfig, TEmit> {
17
17
  setContext: (targetProvider: globalThis.EventTarget, contextValue: TContext) => void;
18
18
  getContext: (targetProvider: globalThis.EventTarget) => TContext;
19
19
  clearContext: (targetProvider: globalThis.EventTarget) => void;
20
- subscribeContext: (targetProvider: globalThis.EventTarget, consumer: ContextConsumer) => void;
21
- unsubscribeContext: (targetProvider: globalThis.EventTarget, consumer: ContextConsumer) => void;
20
+ subscribeContext: (targetProvider: globalThis.EventTarget, consumer: LwcContextConsumer) => void;
21
+ unsubscribeContext: (targetProvider: globalThis.EventTarget, consumer: LwcContextConsumer) => void;
22
22
  }
23
23
  export declare function generateContextualWireAdapter<TContext, TConfig = unknown, TEmit = TContext>(contextInstance: ContextInfo<TContext>): ContextualWireAdapter<TContext, TConfig, TEmit>;
24
+ export type LwcContextualizer = Contextualizer<Record<string, any>>;
25
+ export type LwcContextConsumer = ContextConsumer<Record<string, any>>;
24
26
  //# sourceMappingURL=contextUtils.d.ts.map
@@ -1,4 +1,3 @@
1
- /// <reference types="lwc" />
2
1
  import type { ViewSet } from 'lwr/router';
3
2
  import type { Constructable } from 'lwr/routerUtils';
4
3
  type ViewContext = {
@@ -22,8 +21,8 @@ export declare const CurrentView: {
22
21
  setContext: (targetProvider: EventTarget, contextValue: ViewContext) => void;
23
22
  getContext: (targetProvider: EventTarget) => ViewContext;
24
23
  clearContext: (targetProvider: EventTarget) => void;
25
- subscribeContext: (targetProvider: EventTarget, consumer: import("lwc").ContextConsumer<any>) => void;
26
- unsubscribeContext: (targetProvider: EventTarget, consumer: import("lwc").ContextConsumer<any>) => void;
24
+ subscribeContext: (targetProvider: EventTarget, consumer: import("lwr/contextUtils").LwcContextConsumer) => void;
25
+ unsubscribeContext: (targetProvider: EventTarget, consumer: import("lwr/contextUtils").LwcContextConsumer) => void;
27
26
  };
28
27
  export {};
29
28
  //# sourceMappingURL=currentView.d.ts.map
@@ -15,7 +15,7 @@ export const navigationContextContextualizer = createContextProvider(NavigationC
15
15
  */
16
16
  export function provideContext(contextValue, providerNode, contextualizer, contextualAdapter) {
17
17
  if (contextualizer && contextualAdapter) {
18
- // Set up provider to give context to wire adpaters so that a component connected
18
+ // Set up provider to give context to wire adapters so that a component connected
19
19
  // under the providerNode subtree and wired to those adapters will receive this id
20
20
  contextualAdapter.setContext(providerNode, contextValue);
21
21
  contextualizer(providerNode, {
@@ -86,4 +86,11 @@ export function generateContextualWireAdapter(contextInstance) {
86
86
  };
87
87
  };
88
88
  return Adapter;
89
- }
89
+ }
90
+
91
+ // Prior to LWC version 4.0.0, the types `Contextualizer` and `ContextConsumer` were not generic.
92
+ // Adding the ts-ignore in case this code is compiled with a version of LWC that is older than 4.0.
93
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
94
+ // @ts-ignore
95
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
96
+ // @ts-ignore
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
8
- "version": "0.11.0-alpha.10",
8
+ "version": "0.11.0-alpha.12",
9
9
  "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
10
10
  "repository": {
11
11
  "type": "git",
@@ -53,21 +53,23 @@
53
53
  "test:server": "jest --config ./jest.server.config.cjs"
54
54
  },
55
55
  "dependencies": {
56
- "@lwrjs/client-modules": "0.11.0-alpha.10",
57
- "@lwrjs/diagnostics": "0.11.0-alpha.10",
58
- "@lwrjs/shared-utils": "0.11.0-alpha.10",
56
+ "@lwrjs/client-modules": "0.11.0-alpha.12",
57
+ "@lwrjs/diagnostics": "0.11.0-alpha.12",
58
+ "@lwrjs/shared-utils": "0.11.0-alpha.12",
59
59
  "ajv": "6.12.6"
60
60
  },
61
61
  "devDependencies": {
62
62
  "@lwc/jest-preset": "^14.1.0",
63
+ "@lwrjs/fs-watch": "0.11.0-alpha.12",
63
64
  "@rollup/plugin-typescript": "^11.1.5",
64
65
  "jest": "^26.6.3",
65
66
  "rollup": "^2.78.0",
66
67
  "ts-jest": "^26.5.6",
68
+ "typescript": "^4.9.5",
67
69
  "utam": "2.2.0-alpha1"
68
70
  },
69
71
  "peerDependencies": {
70
- "lwc": "2.x || 3.x"
72
+ "lwc": "2.x || 3.x || 4.x"
71
73
  },
72
74
  "lwc": {
73
75
  "modules": [
@@ -96,5 +98,5 @@
96
98
  "volta": {
97
99
  "extends": "../../../package.json"
98
100
  },
99
- "gitHead": "34b1e289e8de12531f5624b64512e870157195d4"
101
+ "gitHead": "e19ffe5a48dc2b2b6d74d8acfa9658bedb5dd1ff"
100
102
  }
@@ -1,28 +0,0 @@
1
- import type { ViewSet } from 'lwr/router';
2
- import type { Constructable } from 'lwr/routerUtils';
3
- type ViewContext = {
4
- viewset: ViewSet;
5
- onComplete?: Function;
6
- } | undefined;
7
- type CurrentViewConfig = {
8
- viewName?: string;
9
- };
10
- /**
11
- * Services @wire(CurrentView) requests.
12
- * Hooks up to an Observable from the current navigation context.
13
- */
14
- export declare const CurrentView: {
15
- new (callback: (value: Constructable<object>) => void): {
16
- update(config: CurrentViewConfig, context: ViewContext): Promise<void>;
17
- _callback(value: Constructable<object>): void;
18
- connect(): void;
19
- disconnect(): void;
20
- };
21
- setContext: (targetProvider: EventTarget, contextValue: ViewContext) => void;
22
- getContext: (targetProvider: EventTarget) => ViewContext;
23
- clearContext: (targetProvider: EventTarget) => void;
24
- subscribeContext: (targetProvider: EventTarget, consumer: import("lwc").ContextConsumer<any>) => void;
25
- unsubscribeContext: (targetProvider: EventTarget, consumer: import("lwc").ContextConsumer<any>) => void;
26
- };
27
- export {};
28
- //# sourceMappingURL=currentView.d.ts.map