@lwrjs/router 0.10.0-alpha.9 → 0.10.0

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,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 a="LWR",i=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:`${a}4001`,message:"{0} must be an Element type",level:i},MISSING_CONTEXT:{code:`${a}4002`,message:"Could not find context to perform navigation action.",level:i},INVALID_CONTEXT:{code:`${a}4003`,message:"Cannot register navigation context; it must have this shape: { navigate, generateUrl, subscribe }",level:i},MULTIPLE_ROOTS:{code:`${a}4004`,message:"Router connection failed. There can only be one root router.",level:i},MULTIPLE_CHILDREN:{code:`${a}4005`,message:"Could not add to the navigation hierarchy. There can only be one child per navigation node.",level:i},MISSING_ROUTE:{code:`${a}4006`,message:'A route cannot be created to navigate to URL "{0}"',level:i,address:"{0}"},MISSING_URL:{code:`${a}4007`,message:'A URL cannot be created to navigate to route "{0}"',level:i,address:"{0}"},PRENAV_FAILED:{code:`${a}4008`,message:'A preNavigate hook listener blocked routing to "{0}"',level:2,address:"{0}"},MISSING_ROUTE_TEMPLATE:{code:`${a}4009`,message:'A route definition must contain a "uri" property.',level:i},MISSING_ROUTE_CMP:{code:`${a}4016`,message:"Expected a route view component with a default export.",level:i},MISSING_DATA_CONTEXT:{code:`${a}4018`,message:"Could not find context to retrieve navigation data.",level:i},INVALID_ROUTE_QUERY:{code:`${a}4019`,message:"Invalid query param in route definition.",level:i},MISSING_PAGE_BINDING:{code:`${a}4020`,message:"Route definition must provide page binding",level:i},INVALID_PAGE_BINDING:{code:`${a}4021`,message:"Invalid page binding in route definition",level:i},INVALID_URI_SYNTAX:{code:`${a}4022`,message:"Invalid uri syntax. URI cannot contain *, +, (, ), ",level:i},VIEW_IMPORT_FAILED:{code:`${a}4023`,message:'Error importing view with name "{0}", failure was: {1}',level:i,stack:"{2}"},VIEW_MISSING:{code:`${a}4024`,message:'Expected a view with name "{0}" in the viewset',level:i},VIEW_IMPORT_FAILED_WITH_SPECIFIER:{code:`${a}4025`,message:'Error importing module "{0}" from view with name "{1}", failure was: {2}',level:i,stack:"{3}"},NO_ROUTE_MATCH:{code:`${a}4026`,message:"A routing match cannot be found for: {0}",level:i},INVALID_ROUTE_HANDLER:{code:`${a}4027`,message:'Route definition "{0}" does not have a valid route handler module',level:i},DESTINATION_NOT_FOUND:{code:`${a}4028`,message:"Route handler returned 404: Not Found",level:i},DESTINATION_ERROR:{code:`${a}4029`,message:"Route handler returned error status {0}: {1}",level:i,stack:"{2}"}},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 g(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 f=g(new t(void 0)),m=g(new t(void 0)),p=new t(void 0),h=class extends(g(p)){async update(e,t){if(t){const n=e&&e.viewName?e.viewName:"default",o=t.viewset[n],r=o,a=r&&r.module||o;let i;if(a)try{const e=await a(),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;i=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 i=l(u.VIEW_MISSING,[n]);t.onComplete&&t.onComplete(i)}}};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=Symbol("Navigate"),w=Symbol("GenerateUrl"),O=Symbol("NavContext"),S=Symbol("NavContext");function C(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{[S](){if(!this[O]&&(this.dispatchEvent(new CustomEvent(_,{bubbles:!0,composed:!0,detail:{callback:e=>{this[O]=e}}})),!this[O]))throw new Error(c(u.MISSING_CONTEXT))}[N](e,t){this[S](),b(this[O],e,t)}async[w](e){return this[S](),E(this[O],e)}}}C.Navigate=N,C.GenerateUrl=w,C.NavContext=O;export{t as ContextInfo,m as CurrentPageReference,h as CurrentView,f as NavigationContext,C as NavigationMixin,g 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,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}"}},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};
2
+ //# sourceMappingURL=navigation.js.map
@@ -1 +1,2 @@
1
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 j="LWR",I=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:`${j}4001`,message:"{0} must be an Element type",level:I},MISSING_CONTEXT:{code:`${j}4002`,message:"Could not find context to perform navigation action.",level:I},INVALID_CONTEXT:{code:`${j}4003`,message:"Cannot register navigation context; it must have this shape: { navigate, generateUrl, subscribe }",level:I},MULTIPLE_ROOTS:{code:`${j}4004`,message:"Router connection failed. There can only be one root router.",level:I},MULTIPLE_CHILDREN:{code:`${j}4005`,message:"Could not add to the navigation hierarchy. There can only be one child per navigation node.",level:I},MISSING_ROUTE:{code:`${j}4006`,message:'A route cannot be created to navigate to URL "{0}"',level:I,address:"{0}"},MISSING_URL:{code:`${j}4007`,message:'A URL cannot be created to navigate to route "{0}"',level:I,address:"{0}"},PRENAV_FAILED:{code:`${j}4008`,message:'A preNavigate hook listener blocked routing to "{0}"',level:2,address:"{0}"},MISSING_ROUTE_TEMPLATE:{code:`${j}4009`,message:'A route definition must contain a "uri" property.',level:I},MISSING_ROUTE_CMP:{code:`${j}4016`,message:"Expected a route view component with a default export.",level:I},MISSING_DATA_CONTEXT:{code:`${j}4018`,message:"Could not find context to retrieve navigation data.",level:I},INVALID_ROUTE_QUERY:{code:`${j}4019`,message:"Invalid query param in route definition.",level:I},MISSING_PAGE_BINDING:{code:`${j}4020`,message:"Route definition must provide page binding",level:I},INVALID_PAGE_BINDING:{code:`${j}4021`,message:"Invalid page binding in route definition",level:I},INVALID_URI_SYNTAX:{code:`${j}4022`,message:"Invalid uri syntax. URI cannot contain *, +, (, ), ",level:I},VIEW_IMPORT_FAILED:{code:`${j}4023`,message:'Error importing view with name "{0}", failure was: {1}',level:I,stack:"{2}"},VIEW_MISSING:{code:`${j}4024`,message:'Expected a view with name "{0}" in the viewset',level:I},VIEW_IMPORT_FAILED_WITH_SPECIFIER:{code:`${j}4025`,message:'Error importing module "{0}" from view with name "{1}", failure was: {2}',level:I,stack:"{3}"},NO_ROUTE_MATCH:{code:`${j}4026`,message:"A routing match cannot be found for: {0}",level:I},INVALID_ROUTE_HANDLER:{code:`${j}4027`,message:'Route definition "{0}" does not have a valid route handler module',level:I},DESTINATION_NOT_FOUND:{code:`${j}4028`,message:"Route handler returned 404: Not Found",level:I},DESTINATION_ERROR:{code:`${j}4029`,message:"Route handler returned error status {0}: {1}",level:I,stack:"{2}"}};function N(e){return e.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1")}function D(e){return e&&e.sensitive?"":"i"}function A(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 T(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}}(A(e,t),t)}function _(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))}(A(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):_(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=T(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()).default;if(!r)throw new Error(P($.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 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};
2
+ //# sourceMappingURL=router.js.map
@@ -1 +1,2 @@
1
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="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}"}},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),M=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 $(){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=j?i(D):void 0,V=j?i(M):void 0,G=j?i(S):void 0;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=$(),this.errorNavFilters=$(),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,M),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)};M.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)};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"});export{te as default};
2
+ //# sourceMappingURL=routerContainer.js.map
@@ -29,6 +29,7 @@ __export(exports, {
29
29
  var import_routerErrors = __toModule(require("lwr/routerErrors"));
30
30
  var import_navigationApi = __toModule(require("./navigationApi"));
31
31
  var import_navigationMixinHacks = __toModule(require("lwr/navigationMixinHacks"));
32
+ var isSSR = typeof window === "undefined";
32
33
  var Navigate = Symbol("Navigate");
33
34
  var GenerateUrl = Symbol("GenerateUrl");
34
35
  var NavContext = Symbol("NavContext");
@@ -55,12 +56,18 @@ function NavigationMixin(Base) {
55
56
  }
56
57
  }
57
58
  [Navigate](pageRef, replace) {
58
- this[GetContext]();
59
- (0, import_navigationApi.navigate)(this[NavContext], pageRef, replace);
59
+ if (!isSSR) {
60
+ this[GetContext]();
61
+ (0, import_navigationApi.navigate)(this[NavContext], pageRef, replace);
62
+ }
60
63
  }
61
64
  async [GenerateUrl](pageRef) {
62
- this[GetContext]();
63
- return (0, import_navigationApi.generateUrl)(this[NavContext], pageRef);
65
+ if (!isSSR) {
66
+ this[GetContext]();
67
+ return (0, import_navigationApi.generateUrl)(this[NavContext], pageRef);
68
+ } else {
69
+ return null;
70
+ }
64
71
  }
65
72
  }
66
73
  return Mixin;
@@ -4,7 +4,7 @@
4
4
  * SPDX-License-Identifier: MIT
5
5
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6
6
  */
7
- import { RouteInstance } from '../routerUtils/types';
7
+ import type { RouteInstance } from '../routerUtils/types';
8
8
  /**
9
9
  * Sets a history state.
10
10
 
@@ -10,6 +10,8 @@
10
10
  import { invariant, generateMessage, messages } from 'lwr/routerErrors';
11
11
  import { generateUrl, navigate } from './navigationApi';
12
12
  import { CONTEXT_ID_BACKDOOR } from 'lwr/navigationMixinHacks';
13
+ // eslint-disable-next-line lwr/no-unguarded-apis
14
+ const isSSR = typeof window === 'undefined';
13
15
  /*
14
16
  * Exports the NavigationMixin and CurrentPageReference wire adapter.
15
17
  * Uses the NavigationContext wire to retrieve the current navigation context/node.
@@ -59,12 +61,19 @@ function NavigationMixin(Base) {
59
61
  }
60
62
  }
61
63
  [Navigate](pageRef, replace) {
62
- this[GetContext]();
63
- navigate(this[NavContext], pageRef, replace);
64
+ if (!isSSR) {
65
+ this[GetContext]();
66
+ navigate(this[NavContext], pageRef, replace);
67
+ }
64
68
  }
65
69
  async [GenerateUrl](pageRef) {
66
- this[GetContext]();
67
- return generateUrl(this[NavContext], pageRef);
70
+ if (!isSSR) {
71
+ this[GetContext]();
72
+ return generateUrl(this[NavContext], pageRef);
73
+ }
74
+ else {
75
+ return null;
76
+ }
68
77
  }
69
78
  }
70
79
  return Mixin;
@@ -1,6 +1,6 @@
1
1
  import type { Key, PathFunction } from './pathToRegexp';
2
2
  import type { ContextId } from 'lwr/navigationContext';
3
- import { Unsubscriber } from 'lwr/observable';
3
+ import type { Unsubscriber } from 'lwr/observable';
4
4
  export type Module = Record<string | symbol | number, unknown>;
5
5
  export type Constructor<T = object> = new (...args: any[]) => T;
6
6
  export interface Constructable<T = object> {
@@ -12,6 +12,8 @@
12
12
  import { invariant, generateMessage, messages } from 'lwr/routerErrors';
13
13
  import { generateUrl, navigate } from './navigationApi';
14
14
  import { CONTEXT_ID_BACKDOOR } from 'lwr/navigationMixinHacks';
15
+ // eslint-disable-next-line lwr/no-unguarded-apis
16
+ const isSSR = typeof window === 'undefined';
15
17
 
16
18
  /*
17
19
  * Exports the NavigationMixin and CurrentPageReference wire adapter.
@@ -61,12 +63,18 @@ function NavigationMixin(Base) {
61
63
  }
62
64
  }
63
65
  [Navigate](pageRef, replace) {
64
- this[GetContext]();
65
- navigate(this[NavContext], pageRef, replace);
66
+ if (!isSSR) {
67
+ this[GetContext]();
68
+ navigate(this[NavContext], pageRef, replace);
69
+ }
66
70
  }
67
71
  async [GenerateUrl](pageRef) {
68
- this[GetContext]();
69
- return generateUrl(this[NavContext], pageRef);
72
+ if (!isSSR) {
73
+ this[GetContext]();
74
+ return generateUrl(this[NavContext], pageRef);
75
+ } else {
76
+ return null;
77
+ }
70
78
  }
71
79
  }
72
80
  return Mixin;
@@ -5,6 +5,6 @@
5
5
  </template>
6
6
  </div>
7
7
  <div class="outlet" role="region" tabindex="-1">
8
- <lwr-dynamic lwc:dynamic={viewCtor}></lwr-dynamic>
8
+ <lwr-dynamic lwc:dynamic={viewCtor} class="lwr-dynamic"></lwr-dynamic>
9
9
  </div>
10
10
  </template>
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
8
- "version": "0.10.0-alpha.9",
8
+ "version": "0.10.0",
9
9
  "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
10
10
  "repository": {
11
11
  "type": "git",
@@ -43,20 +43,31 @@
43
43
  "pageObjects"
44
44
  ],
45
45
  "scripts": {
46
- "build": "node ../../../bin/pack-lwc --dir src/modules build/modules && yarn utam:compile && yarn build:bundle",
46
+ "build:ts": "tsc -b",
47
+ "build": "yarn build:ts && node ../../../bin/pack-lwc --dir src/modules build/modules && yarn utam:compile && yarn build:bundle",
47
48
  "build:bundle": "rollup --config scripts/rollup.moduleBundle.config.cjs",
48
- "utam:compile": "utam -c utam.config.cjs -t module"
49
+ "utam:compile": "utam -c utam.config.cjs",
50
+ "clean": "rm -rf build",
51
+ "test": "yarn test:client && yarn test:server",
52
+ "test:client": "jest --config ./jest.config.cjs",
53
+ "test:server": "jest --config ./jest.server.config.cjs"
49
54
  },
50
55
  "dependencies": {
51
- "@lwrjs/client-modules": "0.10.0-alpha.9",
52
- "@lwrjs/diagnostics": "0.10.0-alpha.9",
53
- "@lwrjs/shared-utils": "0.10.0-alpha.9",
56
+ "@lwrjs/client-modules": "0.10.0",
57
+ "@lwrjs/diagnostics": "0.10.0",
58
+ "@lwrjs/shared-utils": "0.10.0",
54
59
  "ajv": "6.12.6"
55
60
  },
56
61
  "devDependencies": {
62
+ "@lwc/jest-preset": "^11.8.0",
57
63
  "@rollup/plugin-typescript": "^11.1.0",
64
+ "jest": "^26.6.3",
58
65
  "rollup": "^2.78.0",
59
- "utam": "^2.0.0"
66
+ "ts-jest": "^26.5.6",
67
+ "utam": "^2.0.2"
68
+ },
69
+ "peerDependencies": {
70
+ "lwc": "2.x || 3.x"
60
71
  },
61
72
  "lwc": {
62
73
  "modules": [
@@ -79,10 +90,10 @@
79
90
  ]
80
91
  },
81
92
  "engines": {
82
- "node": ">=16.0.0 <20"
93
+ "node": ">=16.0.0"
83
94
  },
84
95
  "volta": {
85
96
  "extends": "../../../package.json"
86
97
  },
87
- "gitHead": "6da48f5164ac881396055096a6c1e3d0f8d981aa"
98
+ "gitHead": "e6deaeef3db8aa079acefed508897eca19b3218a"
88
99
  }
@@ -5,7 +5,7 @@ var core = require('@utam/core');
5
5
 
6
6
  async function _utam_get_content(driver, root) {
7
7
  let _element = root;
8
- const _locator = core.By.css("lwr-dynamic");
8
+ const _locator = core.By.css(".lwr-dynamic");
9
9
  return _element.findElement(_locator);
10
10
  }
11
11
 
@@ -35,6 +35,18 @@ class Outlet extends core.UtamBaseRootPageObject {
35
35
  return element;
36
36
  }
37
37
 
38
+ /**
39
+ * Waits for the component inside the outlet to be available.
40
+ */
41
+ async waitForOutletContent() {
42
+ await this.waitFor(async () => {
43
+ const _statement0 = await this.__getRoot();
44
+ const _result0 = await _statement0.containsElement(core.By.css(".lwr-dynamic"), false);
45
+ return _result0;
46
+ });
47
+ return this;
48
+ }
49
+
38
50
  }
39
51
 
40
52
  module.exports = Outlet;
@@ -9,5 +9,9 @@ import { Driver as _Driver, Element as _Element, Locator as _Locator, ContainerC
9
9
  */
10
10
  export default class Outlet extends _UtamBaseRootPageObject {
11
11
  constructor(driver: _Driver, element?: _Element, locator?: _Locator);
12
+ /**
13
+ * Waits for the component inside the outlet to be available.
14
+ */
15
+ waitForOutletContent(): Promise<this>;
12
16
  getContent<T extends _UtamBasePageObject>(ContainerCtor: _ContainerCtor<T>): Promise<T>;
13
17
  }
@@ -3,7 +3,7 @@ import { By as _By, createUtamMixinCtor as _createUtamMixinCtor, UtamBaseRootPag
3
3
 
4
4
  async function _utam_get_content(driver, root) {
5
5
  let _element = root;
6
- const _locator = _By.css("lwr-dynamic");
6
+ const _locator = _By.css(".lwr-dynamic");
7
7
  return _element.findElement(_locator);
8
8
  }
9
9
 
@@ -33,4 +33,16 @@ export default class Outlet extends _UtamBaseRootPageObject {
33
33
  return element;
34
34
  }
35
35
 
36
+ /**
37
+ * Waits for the component inside the outlet to be available.
38
+ */
39
+ async waitForOutletContent() {
40
+ await this.waitFor(async () => {
41
+ const _statement0 = await this.__getRoot();
42
+ const _result0 = await _statement0.containsElement(_By.css(".lwr-dynamic"), false);
43
+ return _result0;
44
+ });
45
+ return this;
46
+ }
47
+
36
48
  }