@lwrjs/router 0.12.0-alpha.8 → 0.12.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.
- package/build/bundle/prod/lwr/router/router.js +1 -1
- package/build/cjs/modules/lwr/routerUtils/routeUtils.cjs +9 -5
- package/build/cjs/modules/lwr/routerUtils/routerUtils.cjs +1 -5
- package/build/es/modules/lwr/routerUtils/routeUtils.d.ts +6 -5
- package/build/es/modules/lwr/routerUtils/routeUtils.js +4 -1
- package/build/es/modules/lwr/routerUtils/routerUtils.d.ts +1 -3
- package/build/es/modules/lwr/routerUtils/routerUtils.js +1 -5
- package/build/modules/lwr/navigation/navigation.js-meta.xml +3 -0
- package/build/modules/lwr/outlet/outlet.js-meta.xml +3 -0
- package/build/modules/lwr/router/router.js-meta.xml +3 -0
- package/build/modules/lwr/routerContainer/routerContainer.js-meta.xml +3 -0
- package/build/modules/lwr/routerUtils/routeUtils.js +5 -1
- package/build/modules/lwr/routerUtils/routerUtils.js +2 -6
- package/package.json +7 -7
- package/pageObjects/outlet.d.cts +18 -0
|
@@ -1,2 +1,2 @@
|
|
|
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="",r=P,o){if(n&&0===e?.indexOf(n)&&(e=e.replace(n,"")),o?.locale||r?.locale){const t=`/${o?.locale||r.locale}`;0===e?.indexOf(t)&&(e=e.replace(t,""))}const i=l(e,t);let s;if(!i)return null;{const t=c(e,i);if(t){return s={route:{id:i.original.id,attributes:{...t.attributes},state:{...t.state},pageReference:{type:t.type,attributes:{...t.attributes},state:{...t.state}}},routeDefinition:i},s}}return null}function d(e,t,n="",r=P,i){const s=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 s?h(e,s,n,r,i):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="",a=P,u){const{params:c,original:{page:l={}}={},toPath:f,compiledQuery:d}=t,{attributes:h={},state:g={}}=l,m=f(p(c.filter((({name:e})=>"string"==typeof e)).map((({name:e})=>e)),e,{attributeBindings:h,stateBindings:g})),E=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(d),e,{attributeBindings:h,stateBindings:g}),t),y=r(E),b=u?.locale||a&&a.locale;return`${n}${b!==a.defaultLocale?`/${b}`:""}${m}${y}`}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)))}const P={locale:"en-US",defaultLocale:"en-US"};function C(){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 S{constructor(e){this.deprecatedConfig={},this.routeHandlerId=0,this.compiledRoutes=[],this.routeObservable=C(),this.config={basePath:e.basePath||"",i18n:e.i18n||P,caseSensitive:Boolean(e.caseSensitive),routes:e.routes||[],generateUrl:(e,t)=>d(e,this.compiledRoutes,this.config.basePath,this.config.i18n,t),parseUrl:e=>function(e,t,n="",r=P){const o=f(e,t,n,r);return o&&o.route&&o.route.pageReference?o.route.pageReference:null}(e,this.compiledRoutes,this.config.basePath,this.config.i18n)};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,t){const{DEPRECATED_getUrlFromRoute:n}=this.deprecatedConfig;return n?n(e,this.config.generateUrl,t):this.config.generateUrl(e,t)}parseUrl(e){const{DEPRECATED_getRouteFromUrl:t}=this.deprecatedConfig;return t?t(e,this.config.parseUrl):this.config.parseUrl(e)}matchRoute(e,t){const n="string"==typeof e?e:this.generateUrl(e,t);if(null===n)return null;const r=f(n,this.compiledRoutes,this.config.basePath,this.config.i18n,t),o=r&&h(r.route.pageReference,r.routeDefinition,this.config.basePath,this.config.i18n,t);return r&&o?{pathMatch:o,route:r.route,routeDefinition:r.routeDefinition.original}:null}async resolveView(e,t){return new Promise(((n,r)=>{const o=this.matchRoute(e,t);return o?o.routeDefinition.handler?.().then((e=>{const t=e.default;if(!t)return r(y(I.INVALID_ROUTE_HANDLER,[o.routeDefinition.id]));const i=new t(n);i&&i.update(o.route)})):r(y(I.NO_ROUTE_MATCH,[JSON.stringify(e)]))}))}navigate(e,t){const n=this.matchRoute(e,t);if(!n)throw new Error(y(I.MISSING_ROUTE,[JSON.stringify(e)]));this.pendingRoute={...n},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 j(e={}){return new S(e)}export{j 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}const l={locale:"en-US",defaultLocale:"en-US"};function f(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 d(e,t,n="",r=l,o){if(n&&0===e?.indexOf(n)&&(e=e.replace(n,"")),o?.locale||r?.locale){const t=`/${o?.locale||r.locale}`;0===e?.indexOf(t)&&(e=e.replace(t,""))}const i=f(e,t);let s;if(!i)return null;{const t=c(e,i);if(t){return s={route:{id:i.original.id,attributes:{...t.attributes},state:{...t.state},pageReference:{type:t.type,attributes:{...t.attributes},state:{...t.state}}},routeDefinition:i},s}}return null}function p(e,t,n="",r=l,i){const s=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 s?g(e,s,n,r,i):null}function h(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 g(e,t,n="",a=l,u){const{params:c,original:{page:f={}}={},toPath:d,compiledQuery:p}=t,{attributes:g={},state:m={}}=f,E=d(h(c.filter((({name:e})=>"string"==typeof e)).map((({name:e})=>e)),e,{attributeBindings:g,stateBindings:m})),y=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,h(s(p),e,{attributeBindings:g,stateBindings:m}),t),b=r(y),I=u?.locale||a&&a.locale;return`${n}${I!==a.defaultLocale?`/${I}`:""}${E}${b}`}function m(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&&m(r,t-1)}}))}catch(e){}return e}const E="LWR",y=1;function b(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 I(e,t,n){if(!e)throw new Error(b(t,n))}const v={INVALID_MIXIN_CMP:{code:`${E}4001`,message:"{0} must be an Element type",level:y},MISSING_CONTEXT:{code:`${E}4002`,message:"Could not find context to perform navigation action.",level:y},INVALID_CONTEXT:{code:`${E}4003`,message:"Cannot register navigation context; it must have this shape: { navigate, generateUrl, subscribe }",level:y},MULTIPLE_ROOTS:{code:`${E}4004`,message:"Router connection failed. There can only be one root router.",level:y},MULTIPLE_CHILDREN:{code:`${E}4005`,message:"Could not add to the navigation hierarchy. There can only be one child per navigation node.",level:y},MISSING_ROUTE:{code:`${E}4006`,message:'A route cannot be created to navigate to URL "{0}"',level:y,address:"{0}"},MISSING_URL:{code:`${E}4007`,message:'A URL cannot be created to navigate to route "{0}"',level:y,address:"{0}"},PRENAV_FAILED:{code:`${E}4008`,message:'A preNavigate hook listener blocked routing to "{0}"',level:2,address:"{0}"},MISSING_ROUTE_TEMPLATE:{code:`${E}4009`,message:'A route definition must contain a "uri" property.',level:y},MISSING_ROUTE_CMP:{code:`${E}4016`,message:"Expected a route view component with a default export.",level:y},MISSING_DATA_CONTEXT:{code:`${E}4018`,message:"Could not find context to retrieve navigation data.",level:y},INVALID_ROUTE_QUERY:{code:`${E}4019`,message:"Invalid query param in route definition.",level:y},MISSING_PAGE_BINDING:{code:`${E}4020`,message:"Route definition must provide page binding",level:y},INVALID_PAGE_BINDING:{code:`${E}4021`,message:"Invalid page binding in route definition",level:y},INVALID_URI_SYNTAX:{code:`${E}4022`,message:"Invalid uri syntax. URI cannot contain *, +, (, ), ",level:y},VIEW_IMPORT_FAILED:{code:`${E}4023`,message:'Error importing view with name "{0}", failure was: {1}',level:y,stack:"{2}"},VIEW_MISSING:{code:`${E}4024`,message:'Expected a view with name "{0}" in the viewset',level:y},VIEW_IMPORT_FAILED_WITH_SPECIFIER:{code:`${E}4025`,message:'Error importing module "{0}" from view with name "{1}", failure was: {2}',level:y,stack:"{3}"},NO_ROUTE_MATCH:{code:`${E}4026`,message:"A routing match cannot be found for: {0}",level:y},INVALID_ROUTE_HANDLER:{code:`${E}4027`,message:'Route definition "{0}" does not have a valid route handler module',level:y},DESTINATION_NOT_FOUND:{code:`${E}4028`,message:"Route handler returned 404: Not Found",level:y},DESTINATION_ERROR:{code:`${E}4029`,message:"Route handler returned error status {0}: {1}",level:y,stack:"{2}"},NO_INIT_URL:{code:`${E}4030`,message:'Cannot initialize a server router without a "url"',level:y}};function R(e){return e.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1")}function $(e){return e&&e.sensitive?"":"i"}function O(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=`[^${R(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 N(e,t){return function(e,t={}){const n=$(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}}(O(e,t),t)}function _(e,t,n){return function(e,t,n={}){const{strict:r=!1,start:o=!0,end:i=!0,encode:s=(e=>e)}=n,a=`[${R(n.endsWith||"")}]|$`,u=`[${R(n.delimiter||"/#?")}]`;let c=o?"^":"";for(const n of e)if("string"==typeof n)c+=R(s(n));else{const e=R(s(n.prefix)),r=R(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,$(n))}(O(e,n),t,n)}function A(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=>A(e,t,n).source));return new RegExp(`(?:${r.join("|")})`,$(n))}(e,t,n):_(e,t,n)}const{INVALID_ROUTE_QUERY:x,MISSING_ROUTE_TEMPLATE:T,MISSING_PAGE_BINDING:w,INVALID_PAGE_BINDING:D,INVALID_URI_SYNTAX:U}=v;function P(e){const{routes:r,caseSensitive:a}=e;return r.map((e=>function(e,r=!1){const a=[],{uri:u,page:c}=e;I(!!u,T),I(function(e=""){const t=["*","(",")",";"].some((t=>e.indexOf(t)>=0));return!t}(u),U),I(!!c,w);const l=t(u),f=n(u),d=A(l,a,{sensitive:r,end:!1!==e.exact}),p=N(l,{encode:encodeURIComponent}),h=function(e){const t={};return Object.keys(e).forEach((n=>{const r=e[n];I(!o(n)||null===r,x),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 I(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),D),m}(e,a)))}function C(){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 S{constructor(e){this.deprecatedConfig={},this.routeHandlerId=0,this.compiledRoutes=[],this.routeObservable=C(),this.config={basePath:e.basePath||"",i18n:e.i18n||l,caseSensitive:Boolean(e.caseSensitive),routes:e.routes||[],generateUrl:(e,t)=>p(e,this.compiledRoutes,this.config.basePath,this.config.i18n,t),parseUrl:e=>function(e,t,n="",r=l){const o=d(e,t,n,r);return o&&o.route&&o.route.pageReference?o.route.pageReference:null}(e,this.compiledRoutes,this.config.basePath,this.config.i18n)};const{DEPRECATED_getRouteFromUrl:t,DEPRECATED_getUrlFromRoute:n}=e;t&&(this.deprecatedConfig.DEPRECATED_getRouteFromUrl=t),n&&(this.deprecatedConfig.DEPRECATED_getUrlFromRoute=n),this.compiledRoutes=P(this.config)}generateUrl(e,t){const{DEPRECATED_getUrlFromRoute:n}=this.deprecatedConfig;return n?n(e,this.config.generateUrl,t):this.config.generateUrl(e,t)}parseUrl(e){const{DEPRECATED_getRouteFromUrl:t}=this.deprecatedConfig;return t?t(e,this.config.parseUrl):this.config.parseUrl(e)}matchRoute(e,t){const n="string"==typeof e?e:this.generateUrl(e,t);if(null===n)return null;const r=d(n,this.compiledRoutes,this.config.basePath,this.config.i18n,t),o=r&&g(r.route.pageReference,r.routeDefinition,this.config.basePath,this.config.i18n,t);return r&&o?{pathMatch:o,route:r.route,routeDefinition:r.routeDefinition.original}:null}async resolveView(e,t){return new Promise(((n,r)=>{const o=this.matchRoute(e,t);return o?o.routeDefinition.handler?.().then((e=>{const t=e.default;if(!t)return r(b(v.INVALID_ROUTE_HANDLER,[o.routeDefinition.id]));const i=new t(n);i&&i.update(o.route)})):r(b(v.NO_ROUTE_MATCH,[JSON.stringify(e)]))}))}navigate(e,t){const n=this.matchRoute(e,t);if(!n)throw new Error(b(v.MISSING_ROUTE,[JSON.stringify(e)]));this.pendingRoute={...n},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(b(v.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=m(t.viewset);this.routeObservable.next({...this.pendingRoute,...t,viewset:n})}}function j(e={}){return new S(e)}export{j as createRouter};
|
|
2
2
|
//# sourceMappingURL=router.js.map
|
|
@@ -24,6 +24,7 @@ var __toModule = (module2) => {
|
|
|
24
24
|
// packages/@lwrjs/router/src/modules/lwr/routerUtils/routeUtils.ts
|
|
25
25
|
__markAsModule(exports);
|
|
26
26
|
__export(exports, {
|
|
27
|
+
DEFAULT_I18N_ROUTER_CONFIG: () => DEFAULT_I18N_ROUTER_CONFIG,
|
|
27
28
|
getPageReferenceFromUrl: () => getPageReferenceFromUrl,
|
|
28
29
|
getUrlFromPageReference: () => getUrlFromPageReference,
|
|
29
30
|
getUrlFromPageReferenceAndRouteDef: () => getUrlFromPageReferenceAndRouteDef,
|
|
@@ -31,7 +32,10 @@ __export(exports, {
|
|
|
31
32
|
});
|
|
32
33
|
var import_uriUtils = __toModule(require("./uriUtils"));
|
|
33
34
|
var import_routeDefUtils = __toModule(require("./routeDefUtils"));
|
|
34
|
-
var
|
|
35
|
+
var DEFAULT_I18N_ROUTER_CONFIG = {
|
|
36
|
+
locale: "en-US",
|
|
37
|
+
defaultLocale: "en-US"
|
|
38
|
+
};
|
|
35
39
|
function isRoutePatternsMatched(path, queryObj, routeDef) {
|
|
36
40
|
const {original: {patterns = null} = {}} = routeDef || {};
|
|
37
41
|
if (patterns) {
|
|
@@ -60,7 +64,7 @@ function getRouteDefinitionForUri(uri, routeDefs) {
|
|
|
60
64
|
});
|
|
61
65
|
return matched || null;
|
|
62
66
|
}
|
|
63
|
-
function matchRouteByUrl(url, routeDefs, basePath = "", i18n =
|
|
67
|
+
function matchRouteByUrl(url, routeDefs, basePath = "", i18n = DEFAULT_I18N_ROUTER_CONFIG, options) {
|
|
64
68
|
if (basePath && url?.indexOf(basePath) === 0) {
|
|
65
69
|
url = url.replace(basePath, "");
|
|
66
70
|
}
|
|
@@ -96,7 +100,7 @@ function matchRouteByUrl(url, routeDefs, basePath = "", i18n = import_routerUtil
|
|
|
96
100
|
}
|
|
97
101
|
return null;
|
|
98
102
|
}
|
|
99
|
-
function getUrlFromPageReference(pageReference, routeDefs, basePath = "", i18n =
|
|
103
|
+
function getUrlFromPageReference(pageReference, routeDefs, basePath = "", i18n = DEFAULT_I18N_ROUTER_CONFIG, options) {
|
|
100
104
|
const routeDef = (0, import_routeDefUtils.matchRouteDefinitionByPageReference)(pageReference, routeDefs);
|
|
101
105
|
if (routeDef) {
|
|
102
106
|
return getUrlFromPageReferenceAndRouteDef(pageReference, routeDef, basePath, i18n, options);
|
|
@@ -124,7 +128,7 @@ function extractBindingValues(parameters, pageReference, pageBindings) {
|
|
|
124
128
|
});
|
|
125
129
|
return parameterValueMapping;
|
|
126
130
|
}
|
|
127
|
-
function getUrlFromPageReferenceAndRouteDef(pageReference, routeDef, basePath = "", i18n =
|
|
131
|
+
function getUrlFromPageReferenceAndRouteDef(pageReference, routeDef, basePath = "", i18n = DEFAULT_I18N_ROUTER_CONFIG, options) {
|
|
128
132
|
const {params, original: {page = {}} = {}, toPath, compiledQuery} = routeDef;
|
|
129
133
|
const {attributes: attributeBindings = {}, state: stateBindings = {}} = page;
|
|
130
134
|
const pathParamNames = params.filter(({name}) => {
|
|
@@ -179,7 +183,7 @@ function getQueryObjectForParametersAndPageReference(pageReference, queryParamet
|
|
|
179
183
|
...queryParamKeyValueMap
|
|
180
184
|
};
|
|
181
185
|
}
|
|
182
|
-
function getPageReferenceFromUrl(url, routeDefs, basePath = "", i18n =
|
|
186
|
+
function getPageReferenceFromUrl(url, routeDefs, basePath = "", i18n = DEFAULT_I18N_ROUTER_CONFIG) {
|
|
183
187
|
const routingMatch = matchRouteByUrl(url, routeDefs, basePath, i18n);
|
|
184
188
|
if (routingMatch && routingMatch.route && routingMatch.route.pageReference) {
|
|
185
189
|
return routingMatch.route.pageReference;
|
|
@@ -24,7 +24,7 @@ var __toModule = (module2) => {
|
|
|
24
24
|
// packages/@lwrjs/router/src/modules/lwr/routerUtils/routerUtils.ts
|
|
25
25
|
__markAsModule(exports);
|
|
26
26
|
__export(exports, {
|
|
27
|
-
DEFAULT_I18N_ROUTER_CONFIG: () => DEFAULT_I18N_ROUTER_CONFIG,
|
|
27
|
+
DEFAULT_I18N_ROUTER_CONFIG: () => import_routeUtils.DEFAULT_I18N_ROUTER_CONFIG,
|
|
28
28
|
createFilterChain: () => import_filterUtils.createFilterChain,
|
|
29
29
|
decode: () => import_uriUtils.decode,
|
|
30
30
|
encode: () => import_uriUtils.encode,
|
|
@@ -56,7 +56,3 @@ var pathToRegexp = {
|
|
|
56
56
|
pathToRegexp: import_pathToRegexp.pathToRegexp,
|
|
57
57
|
compile: import_pathToRegexp.compile
|
|
58
58
|
};
|
|
59
|
-
var DEFAULT_I18N_ROUTER_CONFIG = {
|
|
60
|
-
locale: "en-US",
|
|
61
|
-
defaultLocale: "en-US"
|
|
62
|
-
};
|
|
@@ -4,7 +4,8 @@
|
|
|
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 type { CompiledRouteDefinition, CompiledRoutingMatch, NavigateOptions, PageReference } from './types';
|
|
7
|
+
import type { CompiledRouteDefinition, CompiledRoutingMatch, I18nRouterConfig, NavigateOptions, PageReference } from './types';
|
|
8
|
+
export declare const DEFAULT_I18N_ROUTER_CONFIG: I18nRouterConfig;
|
|
8
9
|
/**
|
|
9
10
|
* f(URL, routes[]?) -> route
|
|
10
11
|
* Match a URL's path to a Route Definition, use these to build a route.
|
|
@@ -16,7 +17,7 @@ import type { CompiledRouteDefinition, CompiledRoutingMatch, NavigateOptions, Pa
|
|
|
16
17
|
*
|
|
17
18
|
* @returns {object}
|
|
18
19
|
*/
|
|
19
|
-
export declare function matchRouteByUrl(url: string, routeDefs: CompiledRouteDefinition[], basePath?: string, i18n?:
|
|
20
|
+
export declare function matchRouteByUrl(url: string, routeDefs: CompiledRouteDefinition[], basePath?: string, i18n?: I18nRouterConfig, options?: NavigateOptions): CompiledRoutingMatch | null;
|
|
20
21
|
/**
|
|
21
22
|
* Serializes the given pageReference into a url based on the first route definition
|
|
22
23
|
* with a binding the pageReference matches against.
|
|
@@ -25,16 +26,16 @@ export declare function matchRouteByUrl(url: string, routeDefs: CompiledRouteDef
|
|
|
25
26
|
* @param basePath Base path for the url
|
|
26
27
|
* @returns the url or null if no match
|
|
27
28
|
*/
|
|
28
|
-
export declare function getUrlFromPageReference(pageReference: PageReference, routeDefs: CompiledRouteDefinition[], basePath?: string, i18n?:
|
|
29
|
+
export declare function getUrlFromPageReference(pageReference: PageReference, routeDefs: CompiledRouteDefinition[], basePath?: string, i18n?: I18nRouterConfig, options?: NavigateOptions): string | null;
|
|
29
30
|
/**
|
|
30
31
|
* Generates a url for the given pageReference using the given routeDef
|
|
31
32
|
* @param pageReference pageReference to serialize
|
|
32
33
|
* @param routeDef routeDef to that defines how serialize the given pageReference
|
|
33
34
|
* @returns url for the given pageReference
|
|
34
35
|
*/
|
|
35
|
-
export declare function getUrlFromPageReferenceAndRouteDef(pageReference: PageReference, routeDef: CompiledRouteDefinition, basePath?: string, i18n?:
|
|
36
|
+
export declare function getUrlFromPageReferenceAndRouteDef(pageReference: PageReference, routeDef: CompiledRouteDefinition, basePath?: string, i18n?: I18nRouterConfig, options?: NavigateOptions): string;
|
|
36
37
|
/**
|
|
37
38
|
* Obtains the pageReference for the given URL
|
|
38
39
|
*/
|
|
39
|
-
export declare function getPageReferenceFromUrl(url: string, routeDefs: CompiledRouteDefinition[], basePath?: string, i18n?:
|
|
40
|
+
export declare function getPageReferenceFromUrl(url: string, routeDefs: CompiledRouteDefinition[], basePath?: string, i18n?: I18nRouterConfig): PageReference | null;
|
|
40
41
|
//# sourceMappingURL=routeUtils.d.ts.map
|
|
@@ -6,7 +6,10 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { getPathFromUrl, getQueryFromUrl, getQueryString, isParam, getParamName, getQueryNames, } from './uriUtils';
|
|
8
8
|
import { getPageReferenceFromUriAndRouteDef, matchRouteDefinitionByPageReference, getPathParams, getQueryParams, } from './routeDefUtils';
|
|
9
|
-
|
|
9
|
+
export const DEFAULT_I18N_ROUTER_CONFIG = {
|
|
10
|
+
locale: 'en-US',
|
|
11
|
+
defaultLocale: 'en-US',
|
|
12
|
+
};
|
|
10
13
|
/**
|
|
11
14
|
* Returns true if the given path & queryObj match the patterns (if any) defined in the routeDef
|
|
12
15
|
*
|
|
@@ -6,11 +6,10 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export { createFilterChain } from './filterUtils';
|
|
8
8
|
export { getPageReferenceFromUriAndRouteDef } from './routeDefUtils';
|
|
9
|
-
export { getUrlFromPageReference, getPageReferenceFromUrl, matchRouteByUrl, getUrlFromPageReferenceAndRouteDef, } from './routeUtils';
|
|
9
|
+
export { DEFAULT_I18N_ROUTER_CONFIG, getUrlFromPageReference, getPageReferenceFromUrl, matchRouteByUrl, getUrlFromPageReferenceAndRouteDef, } from './routeUtils';
|
|
10
10
|
export { isObject, freeze, guid, isValidRoute } from './typeUtils';
|
|
11
11
|
export { parseRoutes } from './parseUtils';
|
|
12
12
|
import { pathToRegexp as ptr, compile as ptrCompile } from './pathToRegexp';
|
|
13
|
-
import type { I18nRouterConfig } from './types';
|
|
14
13
|
export declare const pathToRegexp: {
|
|
15
14
|
pathToRegexp: typeof ptr;
|
|
16
15
|
compile: typeof ptrCompile;
|
|
@@ -20,5 +19,4 @@ export { hasDocument } from './domUtils';
|
|
|
20
19
|
export type { Key } from './pathToRegexp';
|
|
21
20
|
export type { Filter, FilterChain } from './filterUtils';
|
|
22
21
|
export type { CompiledRouteDefinition, CompiledRoutingMatch, Constructor, Constructable, MessageObject, Module, PageReference, RouteCallback, RouteDefinition, RouteHandler, RouteHandlerCallback, RouteHandlerClass, RouteHandlerModule, Router, RouterConfig, RouteDestination, RouteInstance, RoutingMatch, RoutingResult, StringAttributes, UrlMapper, ViewSet, ViewInfo, RouterSerializationConfig, } from './types';
|
|
23
|
-
export declare const DEFAULT_I18N_ROUTER_CONFIG: I18nRouterConfig;
|
|
24
22
|
//# sourceMappingURL=routerUtils.d.ts.map
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export { createFilterChain } from './filterUtils';
|
|
8
8
|
export { getPageReferenceFromUriAndRouteDef } from './routeDefUtils';
|
|
9
|
-
export { getUrlFromPageReference, getPageReferenceFromUrl, matchRouteByUrl, getUrlFromPageReferenceAndRouteDef, } from './routeUtils';
|
|
9
|
+
export { DEFAULT_I18N_ROUTER_CONFIG, getUrlFromPageReference, getPageReferenceFromUrl, matchRouteByUrl, getUrlFromPageReferenceAndRouteDef, } from './routeUtils';
|
|
10
10
|
export { isObject, freeze, guid, isValidRoute } from './typeUtils';
|
|
11
11
|
export { parseRoutes } from './parseUtils';
|
|
12
12
|
import { pathToRegexp as ptr, compile as ptrCompile } from './pathToRegexp';
|
|
@@ -16,8 +16,4 @@ export const pathToRegexp = {
|
|
|
16
16
|
};
|
|
17
17
|
export { getPathFromUrl, getQueryFromUrl, getQueryString, encode, decode } from './uriUtils';
|
|
18
18
|
export { hasDocument } from './domUtils';
|
|
19
|
-
export const DEFAULT_I18N_ROUTER_CONFIG = {
|
|
20
|
-
locale: 'en-US',
|
|
21
|
-
defaultLocale: 'en-US',
|
|
22
|
-
};
|
|
23
19
|
//# sourceMappingURL=routerUtils.js.map
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
2
|
<LightningComponentBundle xmlns="xmlns=http://soap.sforce.com/2006/04/metadata">
|
|
3
3
|
<isExposed>true</isExposed>
|
|
4
|
+
<capabilities>
|
|
5
|
+
<capability>lightning__ServerRenderableWithHydration</capability>
|
|
6
|
+
</capabilities>
|
|
4
7
|
</LightningComponentBundle>
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
2
|
<LightningComponentBundle xmlns="xmlns=http://soap.sforce.com/2006/04/metadata">
|
|
3
3
|
<isExposed>true</isExposed>
|
|
4
|
+
<capabilities>
|
|
5
|
+
<capability>lightning__ServerRenderableWithHydration</capability>
|
|
6
|
+
</capabilities>
|
|
4
7
|
</LightningComponentBundle>
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
2
|
<LightningComponentBundle xmlns="xmlns=http://soap.sforce.com/2006/04/metadata">
|
|
3
3
|
<isExposed>true</isExposed>
|
|
4
|
+
<capabilities>
|
|
5
|
+
<capability>lightning__ServerRenderableWithHydration</capability>
|
|
6
|
+
</capabilities>
|
|
4
7
|
</LightningComponentBundle>
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
2
|
<LightningComponentBundle xmlns="xmlns=http://soap.sforce.com/2006/04/metadata">
|
|
3
3
|
<isExposed>true</isExposed>
|
|
4
|
+
<capabilities>
|
|
5
|
+
<capability>lightning__ServerRenderableWithHydration</capability>
|
|
6
|
+
</capabilities>
|
|
4
7
|
</LightningComponentBundle>
|
|
@@ -7,7 +7,11 @@
|
|
|
7
7
|
|
|
8
8
|
import { getPathFromUrl, getQueryFromUrl, getQueryString, isParam, getParamName, getQueryNames } from './uriUtils';
|
|
9
9
|
import { getPageReferenceFromUriAndRouteDef, matchRouteDefinitionByPageReference, getPathParams, getQueryParams } from './routeDefUtils';
|
|
10
|
-
|
|
10
|
+
export const DEFAULT_I18N_ROUTER_CONFIG = {
|
|
11
|
+
locale: 'en-US',
|
|
12
|
+
defaultLocale: 'en-US'
|
|
13
|
+
};
|
|
14
|
+
|
|
11
15
|
/**
|
|
12
16
|
* Returns true if the given path & queryObj match the patterns (if any) defined in the routeDef
|
|
13
17
|
*
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
export { createFilterChain } from './filterUtils';
|
|
9
9
|
export { getPageReferenceFromUriAndRouteDef } from './routeDefUtils';
|
|
10
|
-
export { getUrlFromPageReference, getPageReferenceFromUrl, matchRouteByUrl, getUrlFromPageReferenceAndRouteDef } from './routeUtils';
|
|
10
|
+
export { DEFAULT_I18N_ROUTER_CONFIG, getUrlFromPageReference, getPageReferenceFromUrl, matchRouteByUrl, getUrlFromPageReferenceAndRouteDef } from './routeUtils';
|
|
11
11
|
export { isObject, freeze, guid, isValidRoute } from './typeUtils';
|
|
12
12
|
export { parseRoutes } from './parseUtils';
|
|
13
13
|
import { pathToRegexp as ptr, compile as ptrCompile } from './pathToRegexp';
|
|
@@ -16,8 +16,4 @@ export const pathToRegexp = {
|
|
|
16
16
|
compile: ptrCompile
|
|
17
17
|
};
|
|
18
18
|
export { getPathFromUrl, getQueryFromUrl, getQueryString, encode, decode } from './uriUtils';
|
|
19
|
-
export { hasDocument } from './domUtils';
|
|
20
|
-
export const DEFAULT_I18N_ROUTER_CONFIG = {
|
|
21
|
-
locale: 'en-US',
|
|
22
|
-
defaultLocale: 'en-US'
|
|
23
|
-
};
|
|
19
|
+
export { hasDocument } from './domUtils';
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
8
|
-
"version": "0.12.0
|
|
8
|
+
"version": "0.12.0",
|
|
9
9
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
@@ -53,20 +53,20 @@
|
|
|
53
53
|
"test:server": "jest --config ./jest.server.config.cjs"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@lwrjs/client-modules": "0.12.0
|
|
57
|
-
"@lwrjs/diagnostics": "0.12.0
|
|
58
|
-
"@lwrjs/shared-utils": "0.12.0
|
|
56
|
+
"@lwrjs/client-modules": "0.12.0",
|
|
57
|
+
"@lwrjs/diagnostics": "0.12.0",
|
|
58
|
+
"@lwrjs/shared-utils": "0.12.0",
|
|
59
59
|
"ajv": "6.12.6"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@lwc/jest-preset": "^14.3.0",
|
|
63
|
-
"@lwrjs/fs-watch": "0.12.0
|
|
63
|
+
"@lwrjs/fs-watch": "0.12.0",
|
|
64
64
|
"@rollup/plugin-typescript": "^11.1.6",
|
|
65
65
|
"jest": "^26.6.3",
|
|
66
66
|
"rollup": "^2.78.0",
|
|
67
67
|
"ts-jest": "^26.5.6",
|
|
68
68
|
"typescript": "^4.9.5",
|
|
69
|
-
"utam": "
|
|
69
|
+
"utam": "3.0.0"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
72
|
"lwc": ">= 2.x"
|
|
@@ -98,5 +98,5 @@
|
|
|
98
98
|
"volta": {
|
|
99
99
|
"extends": "../../../package.json"
|
|
100
100
|
},
|
|
101
|
-
"gitHead": "
|
|
101
|
+
"gitHead": "90f93604b26003e1e1eb85bb0d1f34f4fc9e9ff9"
|
|
102
102
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
import { Driver as _Driver, Element as _Element, Locator as _Locator, ContainerCtor as _ContainerCtor, UtamBasePageObject as _UtamBasePageObject, UtamBaseRootPageObject as _UtamBaseRootPageObject } from '@utam/core';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @lwrjs/router Outlet dynamically renders LWC view components.
|
|
6
|
+
* generated from JSON src/modules/lwr/outlet/__utam__/outlet.utam.json
|
|
7
|
+
* @version 0.10
|
|
8
|
+
* @author lwr-js
|
|
9
|
+
*/
|
|
10
|
+
declare class Outlet extends _UtamBaseRootPageObject {
|
|
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>;
|
|
16
|
+
getContent<T extends _UtamBasePageObject>(ContainerCtor: _ContainerCtor<T>): Promise<T>;
|
|
17
|
+
}
|
|
18
|
+
export = Outlet;
|