@lwrjs/router 0.8.0-alpha.1 → 0.8.0-alpha.11
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/navigation/navigation.js +1 -1
- package/build/bundle/prod/lwr/routerContainer/routerContainer.js +1 -1
- package/build/cjs/modules/lwr/contextProvider/contextProvider.cjs +0 -2
- package/build/cjs/modules/lwr/domRouter/domRouter.cjs +1 -2
- package/build/cjs/modules/lwr/navigation/navigation.cjs +0 -2
- package/build/modules/lwr/contextProvider/contextProvider.d.ts +0 -1
- package/build/modules/lwr/contextProvider/contextProvider.js +1 -2
- package/build/modules/lwr/domRouter/domRouter.js +4 -4
- package/build/modules/lwr/navigation/navigation.d.ts +0 -1
- package/build/modules/lwr/navigation/navigation.js +0 -2
- package/build/modules/lwr/routerUtils/types.d.ts +2 -0
- package/package.json +5 -5
- package/build/cjs/modules/lwr/currentRoute/currentRoute.cjs +0 -31
- package/build/modules/lwr/currentRoute/currentRoute.d.ts +0 -9
- package/build/modules/lwr/currentRoute/currentRoute.js +0 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
import{registerDecorators as e}from"lwc";function t(e){if(null==e)throw new TypeError("Provider must be defined.")}class n{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,n){t(e);const o=this.getInfo(e);o.contextValue=n,o.consumers.forEach((e=>e.provide(n)))}getContext(e){t(e);const{contextValue:n}=this.getInfo(e);return void 0!==n?n:this.defaultValue}clearContext(e){t(e),this.infoMap.delete(e)}subscribeContext(e,n){t(e);const{consumers:o,contextValue:r}=this.getInfo(e);o.has(n)||(o.add(n),n.provide(r))}unsubscribeContext(e,n){t(e),this.getInfo(e).consumers.delete(n)}}function o(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 r(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach((function(t){a(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}e(n,{fields:["infoMap"]});const 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=r(r({},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:"LWR4001",message:"{0} must be an Element type",level:i},MISSING_CONTEXT:{code:"LWR4002",message:"Could not find context to perform navigation action.",level:i},INVALID_CONTEXT:{code:"LWR4003",message:"Cannot register navigation context; it must have this shape: { navigate, generateUrl, subscribe }",level:i},MULTIPLE_ROOTS:{code:"LWR4004",message:"Router connection failed. There can only be one root router.",level:i},MULTIPLE_CHILDREN:{code:"LWR4005",message:"Could not add to the navigation hierarchy. There can only be one child per navigation node.",level:i},MISSING_ROUTE:{code:"LWR4006",message:'A route cannot be created to navigate to URL "{0}"',level:i,address:"{0}"},MISSING_URL:{code:"LWR4007",message:'A URL cannot be created to navigate to route "{0}"',level:i,address:"{0}"},PRENAV_FAILED:{code:"LWR4008",message:'A preNavigate hook listener blocked routing to "{0}"',level:2,address:"{0}"},MISSING_ROUTE_TEMPLATE:{code:"LWR4009",message:'A route definition must contain a "uri" property.',level:i},MISSING_ROUTE_CMP:{code:"LWR4016",message:"Expected a route view component with a default export.",level:i},MISSING_DATA_CONTEXT:{code:"LWR4018",message:"Could not find context to retrieve navigation data.",level:i},INVALID_ROUTE_QUERY:{code:"LWR4019",message:"Invalid query param in route definition.",level:i},MISSING_PAGE_BINDING:{code:"LWR4020",message:"Route definition must provide page binding",level:i},INVALID_PAGE_BINDING:{code:"LWR4021",message:"Invalid page binding in route definition",level:i},INVALID_URI_SYNTAX:{code:"LWR4022",message:"Invalid uri syntax. URI cannot contain *, +, (, ), ",level:i},VIEW_IMPORT_FAILED:{code:"LWR4023",message:'Error importing view with name "{0}", failure was: {1}',level:i,stack:"{2}"},VIEW_MISSING:{code:"LWR4024",message:'Expected a view with name "{0}" in the viewset',level:i},VIEW_IMPORT_FAILED_WITH_SPECIFIER:{code:"LWR4025",message:'Error importing module "{0}" from view with name "{1}", failure was: {2}',level:i,stack:"{3}"},NO_ROUTE_MATCH:{code:"LWR4026",message:"A routing match cannot be found for: {0}",level:i},INVALID_ROUTE_HANDLER:{code:"LWR4027",message:'Route definition "{0}" does not have a valid route handler module',level:i}},d=new WeakMap;function
|
|
1
|
+
import{registerDecorators as e}from"lwc";function t(e){if(null==e)throw new TypeError("Provider must be defined.")}class n{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,n){t(e);const o=this.getInfo(e);o.contextValue=n,o.consumers.forEach((e=>e.provide(n)))}getContext(e){t(e);const{contextValue:n}=this.getInfo(e);return void 0!==n?n:this.defaultValue}clearContext(e){t(e),this.infoMap.delete(e)}subscribeContext(e,n){t(e);const{consumers:o,contextValue:r}=this.getInfo(e);o.has(n)||(o.add(n),n.provide(r))}unsubscribeContext(e,n){t(e),this.getInfo(e).consumers.delete(n)}}function o(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 r(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach((function(t){a(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}e(n,{fields:["infoMap"]});const 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=r(r({},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:"LWR4001",message:"{0} must be an Element type",level:i},MISSING_CONTEXT:{code:"LWR4002",message:"Could not find context to perform navigation action.",level:i},INVALID_CONTEXT:{code:"LWR4003",message:"Cannot register navigation context; it must have this shape: { navigate, generateUrl, subscribe }",level:i},MULTIPLE_ROOTS:{code:"LWR4004",message:"Router connection failed. There can only be one root router.",level:i},MULTIPLE_CHILDREN:{code:"LWR4005",message:"Could not add to the navigation hierarchy. There can only be one child per navigation node.",level:i},MISSING_ROUTE:{code:"LWR4006",message:'A route cannot be created to navigate to URL "{0}"',level:i,address:"{0}"},MISSING_URL:{code:"LWR4007",message:'A URL cannot be created to navigate to route "{0}"',level:i,address:"{0}"},PRENAV_FAILED:{code:"LWR4008",message:'A preNavigate hook listener blocked routing to "{0}"',level:2,address:"{0}"},MISSING_ROUTE_TEMPLATE:{code:"LWR4009",message:'A route definition must contain a "uri" property.',level:i},MISSING_ROUTE_CMP:{code:"LWR4016",message:"Expected a route view component with a default export.",level:i},MISSING_DATA_CONTEXT:{code:"LWR4018",message:"Could not find context to retrieve navigation data.",level:i},INVALID_ROUTE_QUERY:{code:"LWR4019",message:"Invalid query param in route definition.",level:i},MISSING_PAGE_BINDING:{code:"LWR4020",message:"Route definition must provide page binding",level:i},INVALID_PAGE_BINDING:{code:"LWR4021",message:"Invalid page binding in route definition",level:i},INVALID_URI_SYNTAX:{code:"LWR4022",message:"Invalid uri syntax. URI cannot contain *, +, (, ), ",level:i},VIEW_IMPORT_FAILED:{code:"LWR4023",message:'Error importing view with name "{0}", failure was: {1}',level:i,stack:"{2}"},VIEW_MISSING:{code:"LWR4024",message:'Expected a view with name "{0}" in the viewset',level:i},VIEW_IMPORT_FAILED_WITH_SPECIFIER:{code:"LWR4025",message:'Error importing module "{0}" from view with name "{1}", failure was: {2}',level:i,stack:"{3}"},NO_ROUTE_MATCH:{code:"LWR4026",message:"A routing match cannot be found for: {0}",level:i},INVALID_ROUTE_HANDLER:{code:"LWR4027",message:'Route definition "{0}" does not have a valid route handler module',level:i}},d=new WeakMap;function I(e){const t=d.get(e);if(!t||!t.value)throw new Error(c(u.MISSING_CONTEXT));return t.value}function v(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 n(void 0)),m=g(new n(void 0)),p=new n(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){I(e).navigate(t,n)}function E(e,t){return I(e).generateUrl(t)}const _=`universalcontainergetnavigationcontext${Math.floor(65536*(1+Math.random())).toString(16).substring(1)}`,R=Symbol("Navigate"),w=Symbol("GenerateUrl"),L=Symbol("NavContext"),N=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{[N](){if(!this[L]&&(this.dispatchEvent(new CustomEvent(_,{bubbles:!0,composed:!0,detail:{callback:e=>{this[L]=e}}})),!this[L]))throw new Error(c(u.MISSING_CONTEXT))}[R](e,t){this[N](),b(this[L],e,t)}async[w](e){return this[N](),E(this[L],e)}}}C.Navigate=R,C.GenerateUrl=w,C.NavContext=L;export{n as ContextInfo,m as CurrentPageReference,h as CurrentView,f as NavigationContext,C as NavigationMixin,g as generateContextualWireAdapter,E as generateUrl,I as getNavigationHelm,b as navigate,v as registerNavigationHelm};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{registerTemplate as e,freezeTemplate as t,registerDecorators as r,createContextProvider as i,registerComponent as n,LightningElement as o}from"lwc";import{ROUTER_VIEW as s,ROUTER_NAV as a,ROUTER_ERROR as c}from"lwr/metrics";import{logOperationEnd as d,logOperationStart as l}from"lwr/profiler";var h=[function(e,t,r){return"span"+(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 u={key:0},p=[],v={attrs:{"aria-live":"polite","aria-atomic":"true"},context:{lwc:{dom:"manual"}},key:1};function g(e,t,r,i){const{s:n,h:o}=e;return[n("",u,p,r),o("span",v)]}var m=e(g);function f(e){if(null==e)throw new TypeError("Provider must be defined.")}g.slots=[""],g.stylesheets=[],h&&g.stylesheets.push.apply(g.stylesheets,h),h&&(g.stylesheetToken="lwr-routerContainer_routerContainer"),t(g);class b{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){f(e);const r=this.getInfo(e);r.contextValue=t,r.consumers.forEach((e=>e.provide(t)))}getContext(e){f(e);const{contextValue:t}=this.getInfo(e);return void 0!==t?t:this.defaultValue}clearContext(e){f(e),this.infoMap.delete(e)}subscribeContext(e,t){f(e);const{consumers:r,contextValue:i}=this.getInfo(e);r.has(t)||(r.add(t),t.provide(i))}unsubscribeContext(e,t){f(e),this.getInfo(e).consumers.delete(t)}}function E(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?E(Object(r),!0).forEach((function(t){I(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):E(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function I(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}r(b,{fields:["infoMap"]});const R=1;function N(e,t){return Array.isArray(t)?e.replace(/\{([0-9]+)\}/g,((e,r)=>t[r])):e}function _(e,t){const r=w(w({},e),{},{message:N(e.message,t)});return e.address&&(r.address=N(e.address,t)),e.stack&&(r.stack=N(e.stack,t)),r}function y(e,t,r){if(!e)throw new Error(function(e,t){return`${e.code}: ${N(e.message,t)}`}(t,r))}const P={INVALID_MIXIN_CMP:{code:"LWR4001",message:"{0} must be an Element type",level:R},MISSING_CONTEXT:{code:"LWR4002",message:"Could not find context to perform navigation action.",level:R},INVALID_CONTEXT:{code:"LWR4003",message:"Cannot register navigation context; it must have this shape: { navigate, generateUrl, subscribe }",level:R},MULTIPLE_ROOTS:{code:"LWR4004",message:"Router connection failed. There can only be one root router.",level:R},MULTIPLE_CHILDREN:{code:"LWR4005",message:"Could not add to the navigation hierarchy. There can only be one child per navigation node.",level:R},MISSING_ROUTE:{code:"LWR4006",message:'A route cannot be created to navigate to URL "{0}"',level:R,address:"{0}"},MISSING_URL:{code:"LWR4007",message:'A URL cannot be created to navigate to route "{0}"',level:R,address:"{0}"},PRENAV_FAILED:{code:"LWR4008",message:'A preNavigate hook listener blocked routing to "{0}"',level:2,address:"{0}"},MISSING_ROUTE_TEMPLATE:{code:"LWR4009",message:'A route definition must contain a "uri" property.',level:R},MISSING_ROUTE_CMP:{code:"LWR4016",message:"Expected a route view component with a default export.",level:R},MISSING_DATA_CONTEXT:{code:"LWR4018",message:"Could not find context to retrieve navigation data.",level:R},INVALID_ROUTE_QUERY:{code:"LWR4019",message:"Invalid query param in route definition.",level:R},MISSING_PAGE_BINDING:{code:"LWR4020",message:"Route definition must provide page binding",level:R},INVALID_PAGE_BINDING:{code:"LWR4021",message:"Invalid page binding in route definition",level:R},INVALID_URI_SYNTAX:{code:"LWR4022",message:"Invalid uri syntax. URI cannot contain *, +, (, ), ",level:R},VIEW_IMPORT_FAILED:{code:"LWR4023",message:'Error importing view with name "{0}", failure was: {1}',level:R,stack:"{2}"},VIEW_MISSING:{code:"LWR4024",message:'Expected a view with name "{0}" in the viewset',level:R},VIEW_IMPORT_FAILED_WITH_SPECIFIER:{code:"LWR4025",message:'Error importing module "{0}" from view with name "{1}", failure was: {2}',level:R,stack:"{3}"},NO_ROUTE_MATCH:{code:"LWR4026",message:"A routing match cannot be found for: {0}",level:R},INVALID_ROUTE_HANDLER:{code:"LWR4027",message:'Route definition "{0}" does not have a valid route handler module',level:R}},O=new WeakMap;function x(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 L=x(new b(void 0)),C=x(new b(void 0)),T=x(new b(void 0)),D=new b(void 0),S=class extends(x(D)){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.VIEW_IMPORT_FAILED_WITH_SPECIFIER,[n.specifier,r,t.message,t.stack||""]):_(P.VIEW_IMPORT_FAILED,[r,t.message,t.stack||""])}else s=_(P.VIEW_MISSING,[r]);t.onComplete&&t.onComplete(s)}}};function M(){const e=[],t=t=>{"function"==typeof t&&e.push(t)};return{add:(e=[])=>{Array.isArray(e)?e.forEach((e=>t(e))):t(e)},compile:t=>0===e.length?Promise.resolve(!0):e.reduce(((e,r)=>e.then((e=>!1===e?Promise.reject():Promise.resolve(r(t))))),Promise.resolve(!0)).then((e=>!1!==e)).catch((e=>{if(e instanceof Error)throw e;return!1})),empty:()=>0===e.length}}function A(e=""){return e=e||"",decodeURIComponent(e)}function U(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}const W=`universalcontainergetnavigationcontext${U()}`,j=i(T),k=i(C),F=i(S),V=i(L);function G(e,t,r,i){i.setContext(t,e),r(t,{consumerConnectedCallback:i.subscribeContext.bind(i,t),consumerDisconnectedCallback:i.unsubscribeContext.bind(i,t)})}function $(){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 H(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 B(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?H(Object(r),!0).forEach((function(t){X(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):H(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function X(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const q=`universalcontainernavigationevent${U()}`,Y=`universalcontainerparentevent${U()}`;class z{constructor(e,t,r){this.pendingRoute=null,this.committedRoute=null,this.contextId=Object.freeze((()=>{})),this.connected=!1,this.preNavFilters=M(),this.errorNavFilters=M(),this._handleNavigationEvent=e=>{const t=e;if(t.detail&&"object"==typeof t.detail){const{url:e,replace:r,address:i}=t.detail;this.config.handleNavigation(i,r)?this.root&&!e?this.root.processError(_(P.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.routeObservable=$()}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;d({id:s,specifier:this.eventId}),this.pendingRoute=this.pendingRoute||B(B({},e),{},{url:t}),this.committedRoute=B(B({},this.pendingRoute),e),C.setContext(this.target,e.route.pageReference),T.setContext(this.target,this.committedRoute.route),this.routeObservable.next(B(B({},this.committedRoute),{},{viewset:e.viewset})),d({id:a,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}};O.set(r.id,r)}(this.contextId,e),G(this.contextId,this.target,V,L),G(void 0,this.target,k,C),G(void 0,this.target,j,T),G(void 0,this.target,F,S),this.router.subscribe((e=>{const t=e.route.pageReference||{},r=this.router.generateUrl(t)||"";if(l({id:s,specifier:this.eventId}),e.viewset){const t={viewset:e.viewset,onComplete:this.updateWires.bind(this,e,r)};S.setContext(this.target,t)}else e.route.pageReference&&this.updateWires(e,r)}),!0),this.target.addEventListener(q,this._handleNavigationEvent),this.target.addEventListener(Y,this._handleParentEvent),this.target.addEventListener(W,(e=>{const t=e;t.detail.callback&&t.detail.callback(this.contextId)})),this.connected=!0}disconnect(){this.target.removeEventListener(q,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((()=>{y(!this.child,P.MULTIPLE_CHILDREN),this.child=e,t()}),0)})),this.child&&this.committedRoute){const e=this._stripUrlForChild(this.committedRoute.url);await this.child.preProcess(e)&&this.child.process(e)}}async process(e,t){this.eventId=(new Date).getTime().toString(),l({id:a,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.MISSING_ROUTE,[e]));this.pendingRoute=B({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.PRENAV_FAILED,[e]))))}processError(e){l({id:c}),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(q,{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){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 J(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[A(r)]=A(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,"")}r(z,{fields:["pendingRoute","committedRoute","contextId","connected","preNavFilters","errorNavFilters","_handleNavigationEvent","_handleParentEvent"]});class Q extends z{constructor(...e){super(...e),this.historyDisabled=!1}connect(){super.connect(),this.historyDisabled||(window.addEventListener("popstate",this.onpopstate.bind(this)),this.onpopstate())}onpopstate(){this.parent||this.catchBrowserUpdate(J(document.location.href))}disconnect(){super.disconnect(),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)}}r(Q,{fields:["historyDisabled"]});let K=!1;class Z extends o{constructor(){super(),this.router=void 0,this.historyDisabled=!1,this.currentTitle=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 z(t,r,e):new Q(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(),y(!K||!!i.parent,P.MULTIPLE_ROOTS),K=K||!i.parent,n.id=i.contextId},disconnect:()=>{K=K&&!!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),this.template.querySelector("span").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})}}r(Z,{publicProps:{router:{config:0},historyDisabled:{config:0}}});var ee=n(Z,{tmpl:m});export default ee;
|
|
1
|
+
import{registerTemplate as e,freezeTemplate as t,registerDecorators as r,createContextProvider as i,registerComponent as n,LightningElement as o}from"lwc";import{ROUTER_VIEW as s,ROUTER_NAV as a,ROUTER_ERROR as c}from"lwr/metrics";import{logOperationEnd as d,logOperationStart as l}from"lwr/profiler";var h=[function(e,t,r){return"span"+(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 u={key:0},p=[],v={attrs:{"aria-live":"polite","aria-atomic":"true"},context:{lwc:{dom:"manual"}},key:1};function g(e,t,r,i){const{s:n,h:o}=e;return[n("",u,p,r),o("span",v)]}var f=e(g);function m(e){if(null==e)throw new TypeError("Provider must be defined.")}g.slots=[""],g.stylesheets=[],h&&g.stylesheets.push.apply(g.stylesheets,h),h&&(g.stylesheetToken="lwr-routerContainer_routerContainer"),t(g);class b{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){m(e);const r=this.getInfo(e);r.contextValue=t,r.consumers.forEach((e=>e.provide(t)))}getContext(e){m(e);const{contextValue:t}=this.getInfo(e);return void 0!==t?t:this.defaultValue}clearContext(e){m(e),this.infoMap.delete(e)}subscribeContext(e,t){m(e);const{consumers:r,contextValue:i}=this.getInfo(e);r.has(t)||(r.add(t),t.provide(i))}unsubscribeContext(e,t){m(e),this.getInfo(e).consumers.delete(t)}}function E(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 I(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?E(Object(r),!0).forEach((function(t){w(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):E(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function w(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}r(b,{fields:["infoMap"]});const R=1;function N(e,t){return Array.isArray(t)?e.replace(/\{([0-9]+)\}/g,((e,r)=>t[r])):e}function _(e,t){const r=I(I({},e),{},{message:N(e.message,t)});return e.address&&(r.address=N(e.address,t)),e.stack&&(r.stack=N(e.stack,t)),r}function y(e,t,r){if(!e)throw new Error(function(e,t){return`${e.code}: ${N(e.message,t)}`}(t,r))}const P={INVALID_MIXIN_CMP:{code:"LWR4001",message:"{0} must be an Element type",level:R},MISSING_CONTEXT:{code:"LWR4002",message:"Could not find context to perform navigation action.",level:R},INVALID_CONTEXT:{code:"LWR4003",message:"Cannot register navigation context; it must have this shape: { navigate, generateUrl, subscribe }",level:R},MULTIPLE_ROOTS:{code:"LWR4004",message:"Router connection failed. There can only be one root router.",level:R},MULTIPLE_CHILDREN:{code:"LWR4005",message:"Could not add to the navigation hierarchy. There can only be one child per navigation node.",level:R},MISSING_ROUTE:{code:"LWR4006",message:'A route cannot be created to navigate to URL "{0}"',level:R,address:"{0}"},MISSING_URL:{code:"LWR4007",message:'A URL cannot be created to navigate to route "{0}"',level:R,address:"{0}"},PRENAV_FAILED:{code:"LWR4008",message:'A preNavigate hook listener blocked routing to "{0}"',level:2,address:"{0}"},MISSING_ROUTE_TEMPLATE:{code:"LWR4009",message:'A route definition must contain a "uri" property.',level:R},MISSING_ROUTE_CMP:{code:"LWR4016",message:"Expected a route view component with a default export.",level:R},MISSING_DATA_CONTEXT:{code:"LWR4018",message:"Could not find context to retrieve navigation data.",level:R},INVALID_ROUTE_QUERY:{code:"LWR4019",message:"Invalid query param in route definition.",level:R},MISSING_PAGE_BINDING:{code:"LWR4020",message:"Route definition must provide page binding",level:R},INVALID_PAGE_BINDING:{code:"LWR4021",message:"Invalid page binding in route definition",level:R},INVALID_URI_SYNTAX:{code:"LWR4022",message:"Invalid uri syntax. URI cannot contain *, +, (, ), ",level:R},VIEW_IMPORT_FAILED:{code:"LWR4023",message:'Error importing view with name "{0}", failure was: {1}',level:R,stack:"{2}"},VIEW_MISSING:{code:"LWR4024",message:'Expected a view with name "{0}" in the viewset',level:R},VIEW_IMPORT_FAILED_WITH_SPECIFIER:{code:"LWR4025",message:'Error importing module "{0}" from view with name "{1}", failure was: {2}',level:R,stack:"{3}"},NO_ROUTE_MATCH:{code:"LWR4026",message:"A routing match cannot be found for: {0}",level:R},INVALID_ROUTE_HANDLER:{code:"LWR4027",message:'Route definition "{0}" does not have a valid route handler module',level:R}},O=new WeakMap;function x(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 L=x(new b(void 0)),C=x(new b(void 0)),T=new b(void 0),D=class extends(x(T)){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.VIEW_IMPORT_FAILED_WITH_SPECIFIER,[n.specifier,r,t.message,t.stack||""]):_(P.VIEW_IMPORT_FAILED,[r,t.message,t.stack||""])}else s=_(P.VIEW_MISSING,[r]);t.onComplete&&t.onComplete(s)}}};function S(){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 M(e=""){return e=e||"",decodeURIComponent(e)}function A(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}const U=`universalcontainergetnavigationcontext${A()}`,W=i(C),j=i(D),k=i(L);function F(e,t,r,i){i.setContext(t,e),r(t,{consumerConnectedCallback:i.subscribeContext.bind(i,t),consumerDisconnectedCallback:i.unsubscribeContext.bind(i,t)})}function V(){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 G(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 $(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){H(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 H(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const B=`universalcontainernavigationevent${A()}`,X=`universalcontainerparentevent${A()}`;class q{constructor(e,t,r){this.pendingRoute=null,this.committedRoute=null,this.contextId=Object.freeze((()=>{})),this.connected=!1,this.preNavFilters=S(),this.errorNavFilters=S(),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.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=V()}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;d({id:s,specifier:this.eventId}),this.pendingRoute=this.pendingRoute||$($({},e),{},{url:t}),this.committedRoute=$($({},this.pendingRoute),e),C.setContext(this.target,e.route.pageReference),this.routeObservable.next($($({},this.committedRoute),{},{viewset:e.viewset})),d({id:a,specifier:this.eventId}),this.child&&this.child.process(this._stripUrlForChild(this.committedRoute.url))}}connect(){this._sendEvent(X,(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}};O.set(r.id,r)}(this.contextId,e),F(this.contextId,this.target,k,L),F(void 0,this.target,W,C),F(void 0,this.target,j,D),this.router.subscribe((e=>{const t=e.route.pageReference||{},r=this.router.generateUrl(t)||"";if(l({id:s,specifier:this.eventId}),e.viewset){const t={viewset:e.viewset,onComplete:this.updateWires.bind(this,e,r)};D.setContext(this.target,t)}else e.route.pageReference&&this.updateWires(e,r)}),!0),this.target.addEventListener(B,this._handleNavigationEvent),this.target.addEventListener(X,this._handleParentEvent),this.target.addEventListener(U,(e=>{const t=e;t.detail.callback&&t.detail.callback(this.contextId)})),this.connected=!0}disconnect(){this.target.removeEventListener(B,this._handleNavigationEvent),this.target.removeEventListener(X,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((()=>{y(!this.child,P.MULTIPLE_CHILDREN),this.child=e,t()}),0)})),this.child&&this.committedRoute){const e=this._stripUrlForChild(this.committedRoute.url);await this.child.preProcess(e)&&this.child.process(e)}}async process(e,t){this.eventId=(new Date).getTime().toString(),l({id:a,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.MISSING_ROUTE,[e]));this.pendingRoute=$({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.PRENAV_FAILED,[e]))))}processError(e){l({id:c}),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(B,{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){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 Y(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[M(r)]=M(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,"")}r(q,{fields:["pendingRoute","committedRoute","contextId","connected","preNavFilters","errorNavFilters","_handleNavigationEvent","_handleParentEvent"]});class z extends q{constructor(...e){super(...e),this.historyDisabled=!1}connect(){super.connect(),this.historyDisabled||(window.addEventListener("popstate",this.onpopstate.bind(this)),this.onpopstate())}onpopstate(){this.parent||this.catchBrowserUpdate(Y(document.location.href))}disconnect(){super.disconnect(),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)}}r(z,{fields:["historyDisabled"]});let J=!1;class Q extends o{constructor(){super(),this.router=void 0,this.historyDisabled=!1,this.currentTitle=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 q(t,r,e):new z(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(),y(!J||!!i.parent,P.MULTIPLE_ROOTS),J=J||!i.parent,n.id=i.contextId},disconnect:()=>{J=J&&!!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),this.template.querySelector("span").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})}}r(Q,{publicProps:{router:{config:0},historyDisabled:{config:0}}});var K=n(Q,{tmpl:f});export default K;
|
|
@@ -25,14 +25,12 @@ var __toModule = (module2) => {
|
|
|
25
25
|
__markAsModule(exports);
|
|
26
26
|
__export(exports, {
|
|
27
27
|
currentPageReferenceContextualizer: () => currentPageReferenceContextualizer,
|
|
28
|
-
currentRouteContextualizer: () => currentRouteContextualizer,
|
|
29
28
|
currentViewContextualizer: () => currentViewContextualizer,
|
|
30
29
|
navigationContextContextualizer: () => navigationContextContextualizer,
|
|
31
30
|
provideContext: () => provideContext
|
|
32
31
|
});
|
|
33
32
|
var import_lwc = __toModule(require("lwc"));
|
|
34
33
|
var import_navigation = __toModule(require("lwr/navigation"));
|
|
35
|
-
var currentRouteContextualizer = (0, import_lwc.createContextProvider)(import_navigation.CurrentRoute);
|
|
36
34
|
var currentPageReferenceContextualizer = (0, import_lwc.createContextProvider)(import_navigation.CurrentPageReference);
|
|
37
35
|
var currentViewContextualizer = (0, import_lwc.createContextProvider)(import_navigation.CurrentView);
|
|
38
36
|
var navigationContextContextualizer = (0, import_lwc.createContextProvider)(import_navigation.NavigationContext);
|
|
@@ -75,6 +75,7 @@ var DomRouterImpl = class {
|
|
|
75
75
|
};
|
|
76
76
|
this.target = target || window;
|
|
77
77
|
this.router = router;
|
|
78
|
+
this.router.contextId = this.contextId;
|
|
78
79
|
this.routeObservable = (0, import_observable.createObservable)();
|
|
79
80
|
}
|
|
80
81
|
get root() {
|
|
@@ -101,7 +102,6 @@ var DomRouterImpl = class {
|
|
|
101
102
|
this.pendingRoute = this.pendingRoute || {...result, url};
|
|
102
103
|
this.committedRoute = {...this.pendingRoute, ...result};
|
|
103
104
|
import_navigation.CurrentPageReference.setContext(this.target, result.route.pageReference);
|
|
104
|
-
import_navigation.CurrentRoute.setContext(this.target, this.committedRoute.route);
|
|
105
105
|
this.routeObservable.next({...this.committedRoute, viewset: result.viewset});
|
|
106
106
|
(0, import_profiler.logOperationEnd)({id: import_metrics.ROUTER_NAV, specifier: this.eventId});
|
|
107
107
|
if (this.child) {
|
|
@@ -122,7 +122,6 @@ var DomRouterImpl = class {
|
|
|
122
122
|
(0, import_navigation.registerNavigationHelm)(this.contextId, contextApi);
|
|
123
123
|
(0, import_contextProvider.provideContext)(this.contextId, this.target, import_contextProvider.navigationContextContextualizer, import_navigation.NavigationContext);
|
|
124
124
|
(0, import_contextProvider.provideContext)(void 0, this.target, import_contextProvider.currentPageReferenceContextualizer, import_navigation.CurrentPageReference);
|
|
125
|
-
(0, import_contextProvider.provideContext)(void 0, this.target, import_contextProvider.currentRouteContextualizer, import_navigation.CurrentRoute);
|
|
126
125
|
(0, import_contextProvider.provideContext)(void 0, this.target, import_contextProvider.currentViewContextualizer, import_navigation.CurrentView);
|
|
127
126
|
this.router.subscribe((result) => {
|
|
128
127
|
const pageReference = result.route.pageReference || {};
|
|
@@ -26,7 +26,6 @@ __markAsModule(exports);
|
|
|
26
26
|
__export(exports, {
|
|
27
27
|
ContextInfo: () => import_contextUtils.ContextInfo,
|
|
28
28
|
CurrentPageReference: () => import_currentPageReference.CurrentPageReference,
|
|
29
|
-
CurrentRoute: () => import_currentRoute.CurrentRoute,
|
|
30
29
|
CurrentView: () => import_currentView.CurrentView,
|
|
31
30
|
NavigationContext: () => import_navigationContext.NavigationContext,
|
|
32
31
|
NavigationMixin: () => import_navigationMixin.NavigationMixin,
|
|
@@ -38,7 +37,6 @@ __export(exports, {
|
|
|
38
37
|
});
|
|
39
38
|
var import_navigationContext = __toModule(require("lwr/navigationContext"));
|
|
40
39
|
var import_currentPageReference = __toModule(require("lwr/currentPageReference"));
|
|
41
|
-
var import_currentRoute = __toModule(require("lwr/currentRoute"));
|
|
42
40
|
var import_currentView = __toModule(require("lwr/currentView"));
|
|
43
41
|
var import_contextUtils = __toModule(require("lwr/contextUtils"));
|
|
44
42
|
var import_navigationApi = __toModule(require("./navigationApi"));
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Contextualizer } from 'lwc';
|
|
2
2
|
import type { ContextualWireAdapter } from 'lwr/contextUtils';
|
|
3
|
-
export declare const currentRouteContextualizer: Contextualizer;
|
|
4
3
|
export declare const currentPageReferenceContextualizer: Contextualizer;
|
|
5
4
|
export declare const currentViewContextualizer: Contextualizer;
|
|
6
5
|
export declare const navigationContextContextualizer: Contextualizer;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { createContextProvider } from 'lwc';
|
|
2
|
-
import { CurrentPageReference,
|
|
3
|
-
export const currentRouteContextualizer = createContextProvider(CurrentRoute);
|
|
2
|
+
import { CurrentPageReference, CurrentView, NavigationContext } from 'lwr/navigation';
|
|
4
3
|
export const currentPageReferenceContextualizer = createContextProvider(CurrentPageReference);
|
|
5
4
|
export const currentViewContextualizer = createContextProvider(CurrentView);
|
|
6
5
|
export const navigationContextContextualizer = createContextProvider(NavigationContext);
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* SPDX-License-Identifier: MIT
|
|
7
7
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
8
8
|
*/
|
|
9
|
-
import { CurrentPageReference,
|
|
10
|
-
import { currentPageReferenceContextualizer,
|
|
9
|
+
import { CurrentPageReference, CurrentView, NavigationContext, registerNavigationHelm } from 'lwr/navigation';
|
|
10
|
+
import { currentPageReferenceContextualizer, currentViewContextualizer, navigationContextContextualizer, provideContext } from 'lwr/contextProvider';
|
|
11
11
|
import { generateMessageObject, invariant, messages } from 'lwr/routerErrors';
|
|
12
12
|
import { createFilterChain, guid } from 'lwr/routerUtils';
|
|
13
13
|
import { createObservable } from 'lwr/observable'; // @ts-ignore Need to import from client-modules package
|
|
@@ -42,6 +42,8 @@ export class DomRouterImpl {
|
|
|
42
42
|
};
|
|
43
43
|
this.target = target || window;
|
|
44
44
|
this.router = router;
|
|
45
|
+
this.router.contextId = this.contextId; // give the underlying router access to the context
|
|
46
|
+
|
|
45
47
|
this.routeObservable = createObservable();
|
|
46
48
|
}
|
|
47
49
|
/**
|
|
@@ -106,7 +108,6 @@ export class DomRouterImpl {
|
|
|
106
108
|
...result
|
|
107
109
|
};
|
|
108
110
|
CurrentPageReference.setContext(this.target, result.route.pageReference);
|
|
109
|
-
CurrentRoute.setContext(this.target, this.committedRoute.route);
|
|
110
111
|
this.routeObservable.next({ ...this.committedRoute,
|
|
111
112
|
viewset: result.viewset
|
|
112
113
|
});
|
|
@@ -141,7 +142,6 @@ export class DomRouterImpl {
|
|
|
141
142
|
|
|
142
143
|
provideContext(this.contextId, this.target, navigationContextContextualizer, NavigationContext);
|
|
143
144
|
provideContext(undefined, this.target, currentPageReferenceContextualizer, CurrentPageReference);
|
|
144
|
-
provideContext(undefined, this.target, currentRouteContextualizer, CurrentRoute);
|
|
145
145
|
provideContext(undefined, this.target, currentViewContextualizer, CurrentView);
|
|
146
146
|
this.router.subscribe(result => {
|
|
147
147
|
const pageReference = result.route.pageReference || {};
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export { NavigationContext } from 'lwr/navigationContext';
|
|
8
8
|
export { CurrentPageReference } from 'lwr/currentPageReference';
|
|
9
|
-
export { CurrentRoute } from 'lwr/currentRoute';
|
|
10
9
|
export { CurrentView } from 'lwr/currentView';
|
|
11
10
|
export type { ContextId } from 'lwr/navigationContext';
|
|
12
11
|
export type { PageReference, RouteInstance } from 'lwr/router';
|
|
@@ -9,8 +9,6 @@ export { NavigationContext } from 'lwr/navigationContext'; // provides ContextId
|
|
|
9
9
|
|
|
10
10
|
export { CurrentPageReference } from 'lwr/currentPageReference'; // provides PageReference
|
|
11
11
|
|
|
12
|
-
export { CurrentRoute } from 'lwr/currentRoute'; // Provides RouteInstance
|
|
13
|
-
|
|
14
12
|
export { CurrentView } from 'lwr/currentView'; // Provides Constructable
|
|
15
13
|
|
|
16
14
|
// The LWR Navigation context singleton (i.e. CACHE in lwr/contextUtils#navigationApiStore)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Key, PathFunction } from './pathToRegexp';
|
|
2
|
+
import type { ContextId } from 'lwr/navigationContext';
|
|
2
3
|
import { Unsubscriber } from 'lwr/observable';
|
|
3
4
|
export declare type Module = Record<string | symbol | number, unknown>;
|
|
4
5
|
export declare type Constructor<T = object> = new (...args: any[]) => T;
|
|
@@ -16,6 +17,7 @@ export declare type ViewMapper<TAddress> = {
|
|
|
16
17
|
navigate(address: TAddress): void;
|
|
17
18
|
subscribe(callback: RouteCallback, replay?: boolean): Unsubscriber;
|
|
18
19
|
resolveView(address: TAddress): Promise<RouteDestination>;
|
|
20
|
+
contextId?: ContextId;
|
|
19
21
|
};
|
|
20
22
|
export declare type Router<TAddress = string> = ViewMapper<TAddress> & UrlMapper<TAddress> & RouteMatcher<TAddress>;
|
|
21
23
|
export interface DEPRECATED_getRouteFromUrl {
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
8
|
-
"version": "0.8.0-alpha.
|
|
8
|
+
"version": "0.8.0-alpha.11",
|
|
9
9
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
"utam:compile": "utam -c utam.config.cjs -t module"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@lwrjs/client-modules": "0.8.0-alpha.
|
|
52
|
-
"@lwrjs/diagnostics": "0.8.0-alpha.
|
|
53
|
-
"@lwrjs/shared-utils": "0.8.0-alpha.
|
|
51
|
+
"@lwrjs/client-modules": "0.8.0-alpha.11",
|
|
52
|
+
"@lwrjs/diagnostics": "0.8.0-alpha.11",
|
|
53
|
+
"@lwrjs/shared-utils": "0.8.0-alpha.11",
|
|
54
54
|
"ajv": "6.12.6"
|
|
55
55
|
},
|
|
56
56
|
"lwc": {
|
|
@@ -76,5 +76,5 @@
|
|
|
76
76
|
"engines": {
|
|
77
77
|
"node": ">=14.15.4 <19"
|
|
78
78
|
},
|
|
79
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "e8a2c6811e4a52227219f2d94648e0eae9800fbc"
|
|
80
80
|
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, {get: all[name], enumerable: true});
|
|
11
|
-
};
|
|
12
|
-
var __exportStar = (target, module2, desc) => {
|
|
13
|
-
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(module2))
|
|
15
|
-
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
16
|
-
__defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable});
|
|
17
|
-
}
|
|
18
|
-
return target;
|
|
19
|
-
};
|
|
20
|
-
var __toModule = (module2) => {
|
|
21
|
-
return __exportStar(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2);
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
// packages/@lwrjs/router/src/modules/lwr/currentRoute/currentRoute.ts
|
|
25
|
-
__markAsModule(exports);
|
|
26
|
-
__export(exports, {
|
|
27
|
-
CurrentRoute: () => CurrentRoute
|
|
28
|
-
});
|
|
29
|
-
var import_contextUtils = __toModule(require("lwr/contextUtils"));
|
|
30
|
-
var CURRENT_ROUTE_CONTEXT = new import_contextUtils.ContextInfo(void 0);
|
|
31
|
-
var CurrentRoute = (0, import_contextUtils.generateContextualWireAdapter)(CURRENT_ROUTE_CONTEXT);
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { RouteInstance } from 'lwr/router';
|
|
2
|
-
declare type RouteContext = RouteInstance | undefined;
|
|
3
|
-
/**
|
|
4
|
-
* Services @wire(CurrentRoute) requests.
|
|
5
|
-
* Hooks up to an Observable from the current navigation context.
|
|
6
|
-
*/
|
|
7
|
-
export declare const CurrentRoute: import("lwr/contextUtils").ContextualWireAdapter<RouteContext, unknown, RouteContext>;
|
|
8
|
-
export {};
|
|
9
|
-
//# sourceMappingURL=currentRoute.d.ts.map
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { generateContextualWireAdapter, ContextInfo } from 'lwr/contextUtils';
|
|
2
|
-
const CURRENT_ROUTE_CONTEXT = new ContextInfo(undefined);
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Services @wire(CurrentRoute) requests.
|
|
6
|
-
* Hooks up to an Observable from the current navigation context.
|
|
7
|
-
*/
|
|
8
|
-
export const CurrentRoute = generateContextualWireAdapter(CURRENT_ROUTE_CONTEXT);
|