@lwrjs/router 0.6.4 → 0.7.0-alpha.2

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.
Files changed (52) hide show
  1. package/build/bundle/prod/lwr/navigation/navigation.js +1 -1
  2. package/build/bundle/prod/lwr/router/router.js +1 -1
  3. package/build/bundle/prod/lwr/routerContainer/routerContainer.js +1 -1
  4. package/build/cjs/modules/lwr/contextProvider/contextProvider.cjs +45 -0
  5. package/build/cjs/modules/lwr/contextUtils/contextInfo.cjs +58 -0
  6. package/build/cjs/modules/lwr/contextUtils/contextUtils.cjs +66 -0
  7. package/build/cjs/modules/lwr/contextUtils/navigationApiStore.cjs +49 -0
  8. package/build/cjs/modules/lwr/currentPageReference/currentPageReference.cjs +31 -0
  9. package/build/cjs/modules/lwr/currentRoute/currentRoute.cjs +31 -0
  10. package/build/cjs/modules/lwr/currentView/currentView.cjs +74 -0
  11. package/build/cjs/modules/lwr/domRouter/domRouter.cjs +271 -0
  12. package/build/cjs/modules/lwr/domRouterUtils/domRouterUtils.cjs +32 -0
  13. package/build/cjs/modules/lwr/domRouterUtils/historyUtils.cjs +21 -0
  14. package/build/cjs/modules/lwr/domRouterUtils/types.cjs +5 -0
  15. package/build/cjs/modules/lwr/domRouterUtils/uriUtils.cjs +66 -0
  16. package/build/cjs/modules/lwr/historyRouter/historyRouter.cjs +70 -0
  17. package/build/cjs/modules/lwr/navigation/navigation.cjs +45 -0
  18. package/build/cjs/modules/lwr/navigation/navigationApi.cjs +38 -0
  19. package/build/cjs/modules/lwr/navigation/navigationMixin.cjs +70 -0
  20. package/build/cjs/modules/lwr/navigationContext/navigationContext.cjs +31 -0
  21. package/build/cjs/modules/lwr/navigationMixinHacks/navigationMixinHacks.cjs +30 -0
  22. package/build/cjs/modules/lwr/observable/observable.cjs +58 -0
  23. package/build/cjs/modules/lwr/outlet/outlet.cjs +89 -0
  24. package/build/cjs/modules/lwr/router/router.cjs +150 -0
  25. package/build/cjs/modules/lwr/routerBridge/routerBridge.cjs +84 -0
  26. package/build/cjs/modules/lwr/routerContainer/routerContainer.cjs +99 -0
  27. package/build/cjs/modules/lwr/routerContainer/utils.cjs +60 -0
  28. package/build/cjs/modules/lwr/routerErrors/routerErrors.cjs +155 -0
  29. package/build/cjs/modules/lwr/routerUtils/filterUtils.cjs +50 -0
  30. package/build/cjs/modules/lwr/routerUtils/parseUtils.cjs +142 -0
  31. package/build/cjs/modules/lwr/routerUtils/pathToRegexp.cjs +340 -0
  32. package/build/cjs/modules/lwr/routerUtils/routeDefUtils.cjs +164 -0
  33. package/build/cjs/modules/lwr/routerUtils/routeUtils.cjs +179 -0
  34. package/build/cjs/modules/lwr/routerUtils/routerUtils.cjs +55 -0
  35. package/build/cjs/modules/lwr/routerUtils/typeUtils.cjs +74 -0
  36. package/build/cjs/modules/lwr/routerUtils/types.cjs +5 -0
  37. package/build/cjs/modules/lwr/routerUtils/uriUtils.cjs +85 -0
  38. package/build/cjs/services/index.cjs +121 -0
  39. package/build/cjs/services/module-provider/index.cjs +133 -0
  40. package/build/cjs/services/module-provider/utils.cjs +104 -0
  41. package/build/modules/lwr/domRouter/domRouter.d.ts +1 -0
  42. package/build/modules/lwr/domRouter/domRouter.js +37 -4
  43. package/build/modules/lwr/routerUtils/types.d.ts +1 -1
  44. package/build/services/index.d.ts +27 -0
  45. package/build/services/index.js +103 -0
  46. package/build/services/module-provider/index.d.ts +22 -0
  47. package/build/services/module-provider/index.js +126 -0
  48. package/build/services/module-provider/utils.d.ts +26 -0
  49. package/build/services/module-provider/utils.js +109 -0
  50. package/package.json +47 -11
  51. package/index.js +0 -1
  52. package/lwc.config.json +0 -20
@@ -0,0 +1,271 @@
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/domRouter/domRouter.ts
25
+ __markAsModule(exports);
26
+ __export(exports, {
27
+ DomRouterImpl: () => DomRouterImpl,
28
+ NAV_EVENT: () => NAV_EVENT,
29
+ PARENT_EVENT: () => PARENT_EVENT,
30
+ createDomRouter: () => createDomRouter
31
+ });
32
+ var import_navigation = __toModule(require("lwr/navigation"));
33
+ var import_contextProvider = __toModule(require("lwr/contextProvider"));
34
+ var import_routerErrors = __toModule(require("lwr/routerErrors"));
35
+ var import_routerUtils = __toModule(require("lwr/routerUtils"));
36
+ var import_observable = __toModule(require("lwr/observable"));
37
+ var import_metrics = __toModule(require("lwr/metrics"));
38
+ var import_profiler = __toModule(require("lwr/profiler"));
39
+ var import_navigationMixinHacks = __toModule(require("lwr/navigationMixinHacks"));
40
+ var NAV_EVENT = `universalcontainernavigationevent${(0, import_routerUtils.guid)()}`;
41
+ var PARENT_EVENT = `universalcontainerparentevent${(0, import_routerUtils.guid)()}`;
42
+ var DomRouterImpl = class {
43
+ constructor(config, router, target) {
44
+ this.pendingRoute = null;
45
+ this.committedRoute = null;
46
+ this.contextId = Object.freeze(() => void 0);
47
+ this.connected = false;
48
+ this.preNavFilters = (0, import_routerUtils.createFilterChain)();
49
+ this.errorNavFilters = (0, import_routerUtils.createFilterChain)();
50
+ this._handleNavigationEvent = (event) => {
51
+ const navigationEvent = event;
52
+ if (navigationEvent.detail && typeof navigationEvent.detail === "object") {
53
+ const {url, replace, address} = navigationEvent.detail;
54
+ const continueNavigation = this.config.handleNavigation(address, replace);
55
+ if (!continueNavigation) {
56
+ navigationEvent.stopPropagation();
57
+ } else {
58
+ if (this.root && !url) {
59
+ this.root.processError((0, import_routerErrors.generateMessageObject)(import_routerErrors.messages.MISSING_URL, [JSON.stringify(address)]));
60
+ } else if (!this.parent) {
61
+ this.process(url, replace);
62
+ }
63
+ }
64
+ }
65
+ };
66
+ this._handleParentEvent = (event) => {
67
+ event.stopImmediatePropagation();
68
+ const parentRouterEvent = event;
69
+ if (parentRouterEvent && parentRouterEvent.detail && typeof parentRouterEvent.detail === "function") {
70
+ parentRouterEvent.detail(this);
71
+ }
72
+ };
73
+ this.config = {
74
+ handleNavigation: config.handleNavigation || (() => true)
75
+ };
76
+ this.target = target || window;
77
+ this.router = router;
78
+ this.routeObservable = (0, import_observable.createObservable)();
79
+ }
80
+ get root() {
81
+ if (!this.parent) {
82
+ return this;
83
+ }
84
+ let maybe = this.parent;
85
+ while (maybe) {
86
+ if (!maybe.parent) {
87
+ return maybe;
88
+ }
89
+ maybe = maybe.parent;
90
+ }
91
+ throw new Error("No root router could be found");
92
+ }
93
+ updateWires(result, url, error) {
94
+ if (error) {
95
+ this.processError(error);
96
+ } else {
97
+ if (this.committedRoute && result.route === this.committedRoute.route) {
98
+ return;
99
+ }
100
+ (0, import_profiler.logOperationEnd)({id: import_metrics.ROUTER_VIEW, specifier: this.eventId});
101
+ this.pendingRoute = this.pendingRoute || {...result, url};
102
+ this.committedRoute = {...this.pendingRoute, ...result};
103
+ import_navigation.CurrentPageReference.setContext(this.target, result.route.pageReference);
104
+ import_navigation.CurrentRoute.setContext(this.target, this.committedRoute.route);
105
+ this.routeObservable.next({...this.committedRoute, viewset: result.viewset});
106
+ (0, import_profiler.logOperationEnd)({id: import_metrics.ROUTER_NAV, specifier: this.eventId});
107
+ if (this.child) {
108
+ this.child.process(this._stripUrlForChild(this.committedRoute.url));
109
+ }
110
+ }
111
+ }
112
+ connect() {
113
+ this._sendEvent(PARENT_EVENT, (router) => {
114
+ this.parent = router;
115
+ router.addChild(this);
116
+ });
117
+ const contextApi = {
118
+ navigate: (address, replace) => this.navigate(address, replace),
119
+ generateUrl: (address) => this.generateUrl(address),
120
+ subscribe: (callback, replay) => this.subscribe(callback, replay)
121
+ };
122
+ (0, import_navigation.registerNavigationHelm)(this.contextId, contextApi);
123
+ (0, import_contextProvider.provideContext)(this.contextId, this.target, import_contextProvider.navigationContextContextualizer, import_navigation.NavigationContext);
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
+ (0, import_contextProvider.provideContext)(void 0, this.target, import_contextProvider.currentViewContextualizer, import_navigation.CurrentView);
127
+ this.router.subscribe((result) => {
128
+ const pageReference = result.route.pageReference || {};
129
+ const url = this.router.generateUrl(pageReference) || "";
130
+ (0, import_profiler.logOperationStart)({id: import_metrics.ROUTER_VIEW, specifier: this.eventId});
131
+ if (result.viewset) {
132
+ const currentViewContext = {
133
+ viewset: result.viewset,
134
+ onComplete: this.updateWires.bind(this, result, url)
135
+ };
136
+ import_navigation.CurrentView.setContext(this.target, currentViewContext);
137
+ } else if (result.route.pageReference) {
138
+ this.updateWires(result, url);
139
+ }
140
+ }, true);
141
+ this.target.addEventListener(NAV_EVENT, this._handleNavigationEvent);
142
+ this.target.addEventListener(PARENT_EVENT, this._handleParentEvent);
143
+ this.target.addEventListener(import_navigationMixinHacks.CONTEXT_ID_BACKDOOR, (event) => {
144
+ const navCtxEvent = event;
145
+ if (navCtxEvent.detail.callback) {
146
+ navCtxEvent.detail.callback(this.contextId);
147
+ }
148
+ });
149
+ this.connected = true;
150
+ }
151
+ disconnect() {
152
+ this.target.removeEventListener(NAV_EVENT, this._handleNavigationEvent);
153
+ this.target.removeEventListener(PARENT_EVENT, this._handleParentEvent);
154
+ if (this.parent) {
155
+ this.parent.child = void 0;
156
+ }
157
+ this.parent = void 0;
158
+ if (this.child) {
159
+ this.child.parent = void 0;
160
+ }
161
+ this.child = void 0;
162
+ this.connected = false;
163
+ }
164
+ addPreNavigate(filters) {
165
+ this.preNavFilters.add(filters);
166
+ }
167
+ addErrorNavigate(filters) {
168
+ this.errorNavFilters.add(filters);
169
+ }
170
+ async addChild(child) {
171
+ await new Promise((resolve) => {
172
+ setTimeout(() => {
173
+ (0, import_routerErrors.invariant)(!this.child, import_routerErrors.messages.MULTIPLE_CHILDREN);
174
+ this.child = child;
175
+ resolve();
176
+ }, 0);
177
+ });
178
+ if (this.child && this.committedRoute) {
179
+ const url = this._stripUrlForChild(this.committedRoute.url);
180
+ const canContinue = await this.child.preProcess(url);
181
+ if (canContinue) {
182
+ this.child.process(url);
183
+ }
184
+ }
185
+ }
186
+ async process(url, replace) {
187
+ this.eventId = new Date().getTime().toString();
188
+ (0, import_profiler.logOperationStart)({id: import_metrics.ROUTER_NAV, specifier: this.eventId});
189
+ try {
190
+ if (!this.parent) {
191
+ await this.preProcess(url);
192
+ }
193
+ } catch (e) {
194
+ if (e.code) {
195
+ this.processError(e);
196
+ return false;
197
+ }
198
+ throw e;
199
+ }
200
+ const address = this.router.parseUrl(url);
201
+ if (address) {
202
+ this.router.navigate(address);
203
+ }
204
+ return true;
205
+ }
206
+ preProcess(url) {
207
+ const address = this.router.parseUrl(url);
208
+ const routingMatch = address && this.router.matchRoute(address);
209
+ if (!routingMatch) {
210
+ return Promise.reject((0, import_routerErrors.generateMessageObject)(import_routerErrors.messages.MISSING_ROUTE, [url]));
211
+ }
212
+ this.pendingRoute = {url, ...routingMatch};
213
+ const canGo = this.preNavFilters.empty() ? Promise.resolve(true) : this.preNavFilters.compile({
214
+ current: this.committedRoute || void 0,
215
+ next: this.pendingRoute
216
+ });
217
+ return canGo.then((canContinue) => {
218
+ return canContinue && this.child ? this.child.preProcess(this._stripUrlForChild(url)) : canContinue;
219
+ }).then((canContinue) => {
220
+ return canContinue || Promise.reject((0, import_routerErrors.generateMessageObject)(import_routerErrors.messages.PRENAV_FAILED, [url]));
221
+ });
222
+ }
223
+ processError(messageObject) {
224
+ (0, import_profiler.logOperationStart)({id: import_metrics.ROUTER_ERROR});
225
+ this.errorNavFilters.compile(messageObject);
226
+ if (this.child) {
227
+ this.child.processError(messageObject);
228
+ }
229
+ }
230
+ navigate(address, replace) {
231
+ let url = this.router.generateUrl(address);
232
+ if (url) {
233
+ const parentPath = this.parent && this.parent.committedRoute && this.parent.committedRoute.pathMatch || "";
234
+ url = parentPath.concat(url);
235
+ }
236
+ this._sendEvent(NAV_EVENT, {url, replace, address});
237
+ }
238
+ generateUrl(address) {
239
+ const url = this.router.generateUrl(address);
240
+ if (!url) {
241
+ return null;
242
+ }
243
+ const parentPath = this.parent && this.parent.committedRoute && this.parent.committedRoute.pathMatch || "";
244
+ return `${parentPath}${url}`;
245
+ }
246
+ subscribe(callback, replay) {
247
+ return this.routeObservable.subscribe({
248
+ next: callback,
249
+ error: () => {
250
+ },
251
+ complete: () => {
252
+ }
253
+ }, Boolean(replay));
254
+ }
255
+ _sendEvent(name, payload) {
256
+ this.target.dispatchEvent(new CustomEvent(name, {
257
+ bubbles: true,
258
+ composed: true,
259
+ detail: payload
260
+ }));
261
+ }
262
+ _stripUrlForChild(url) {
263
+ if (this.pendingRoute && url.indexOf(this.pendingRoute.pathMatch) === 0) {
264
+ return url.replace(this.pendingRoute.pathMatch, "");
265
+ }
266
+ return url;
267
+ }
268
+ };
269
+ function createDomRouter(config, router, target) {
270
+ return new DomRouterImpl(config, router, target);
271
+ }
@@ -0,0 +1,32 @@
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/domRouterUtils/domRouterUtils.ts
25
+ __markAsModule(exports);
26
+ __export(exports, {
27
+ getRelativeUrl: () => import_uriUtils.getRelativeUrl,
28
+ replace: () => import_historyUtils.replace,
29
+ set: () => import_historyUtils.set
30
+ });
31
+ var import_uriUtils = __toModule(require("./uriUtils"));
32
+ var import_historyUtils = __toModule(require("./historyUtils"));
@@ -0,0 +1,21 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
3
+ var __export = (target, all) => {
4
+ for (var name in all)
5
+ __defProp(target, name, {get: all[name], enumerable: true});
6
+ };
7
+
8
+ // packages/@lwrjs/router/src/modules/lwr/domRouterUtils/historyUtils.ts
9
+ __markAsModule(exports);
10
+ __export(exports, {
11
+ replace: () => replace,
12
+ set: () => set
13
+ });
14
+ function set(path, route) {
15
+ const data = route || {};
16
+ window.history.pushState(data, "", path);
17
+ }
18
+ function replace(path, route) {
19
+ const data = route || {};
20
+ window.history.replaceState(data, "", path);
21
+ }
@@ -0,0 +1,5 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
3
+
4
+ // packages/@lwrjs/router/src/modules/lwr/domRouterUtils/types.ts
5
+ __markAsModule(exports);
@@ -0,0 +1,66 @@
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/domRouterUtils/uriUtils.ts
25
+ __markAsModule(exports);
26
+ __export(exports, {
27
+ getPathFromAnyUrl: () => getPathFromAnyUrl,
28
+ getRelativeUrl: () => getRelativeUrl,
29
+ getUrlObject: () => getUrlObject
30
+ });
31
+ var import_routerUtils = __toModule(require("lwr/routerUtils"));
32
+ function getUrlObject(url = "") {
33
+ url = url || "";
34
+ if (url.indexOf("://") < 0) {
35
+ const port = window.location.port ? `:${window.location.port}` : "";
36
+ const origin = `${window.location.protocol}//${window.location.hostname}${port}`;
37
+ const prefix = url.charAt(0) === "/" ? "" : "/";
38
+ url = origin + prefix + url;
39
+ }
40
+ const searchParams = {};
41
+ const link = document.createElement("a");
42
+ link.href = url;
43
+ const queryStr = link.search.substring(1);
44
+ if (queryStr) {
45
+ queryStr.split("&").forEach((pair) => {
46
+ const [key, value = ""] = pair.split("=");
47
+ searchParams[(0, import_routerUtils.decode)(key)] = (0, import_routerUtils.decode)(value);
48
+ });
49
+ }
50
+ return {
51
+ href: link.href,
52
+ origin: `${link.protocol}//${link.hostname}${link.port ? `:${link.port}` : ""}`,
53
+ pathname: link.pathname.replace(/(\/)?/, "/"),
54
+ searchParams
55
+ };
56
+ }
57
+ function getRelativeUrl(url) {
58
+ const urlObj = getUrlObject(url);
59
+ const href = urlObj.href.replace(/:\d+/, "");
60
+ const origin = urlObj.origin.replace(/:\d+/, "");
61
+ return href.replace(origin, "");
62
+ }
63
+ function getPathFromAnyUrl(url) {
64
+ const path = getUrlObject(url).pathname;
65
+ return path === "/" ? "/" : path.replace(/\/$/, "");
66
+ }
@@ -0,0 +1,70 @@
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/historyRouter/historyRouter.ts
25
+ __markAsModule(exports);
26
+ __export(exports, {
27
+ HistoryRouter: () => HistoryRouter,
28
+ createHistoryRouter: () => createHistoryRouter
29
+ });
30
+ var import_domRouter = __toModule(require("lwr/domRouter"));
31
+ var import_domRouterUtils = __toModule(require("lwr/domRouterUtils"));
32
+ var HistoryRouter = class extends import_domRouter.DomRouterImpl {
33
+ constructor() {
34
+ super(...arguments);
35
+ this.historyDisabled = false;
36
+ }
37
+ connect() {
38
+ super.connect();
39
+ if (!this.historyDisabled) {
40
+ window.addEventListener("popstate", this.onpopstate.bind(this));
41
+ this.onpopstate();
42
+ }
43
+ }
44
+ onpopstate() {
45
+ if (!this.parent) {
46
+ this.catchBrowserUpdate((0, import_domRouterUtils.getRelativeUrl)(document.location.href));
47
+ }
48
+ }
49
+ disconnect() {
50
+ super.disconnect();
51
+ window.removeEventListener("popstate", this.onpopstate);
52
+ }
53
+ async process(url, shouldReplace, updateHistory = true) {
54
+ const canContinue = await super.process(url);
55
+ if (canContinue && !this.historyDisabled && updateHistory && this.connected && !this.parent) {
56
+ if (shouldReplace) {
57
+ (0, import_domRouterUtils.replace)(url);
58
+ } else {
59
+ (0, import_domRouterUtils.set)(url);
60
+ }
61
+ }
62
+ return canContinue;
63
+ }
64
+ catchBrowserUpdate(url) {
65
+ this.process(url, false, false);
66
+ }
67
+ };
68
+ function createHistoryRouter(config, router, target) {
69
+ return new HistoryRouter(config, router, target);
70
+ }
@@ -0,0 +1,45 @@
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/navigation/navigation.ts
25
+ __markAsModule(exports);
26
+ __export(exports, {
27
+ ContextInfo: () => import_contextUtils.ContextInfo,
28
+ CurrentPageReference: () => import_currentPageReference.CurrentPageReference,
29
+ CurrentRoute: () => import_currentRoute.CurrentRoute,
30
+ CurrentView: () => import_currentView.CurrentView,
31
+ NavigationContext: () => import_navigationContext.NavigationContext,
32
+ NavigationMixin: () => import_navigationMixin.NavigationMixin,
33
+ generateContextualWireAdapter: () => import_contextUtils.generateContextualWireAdapter,
34
+ generateUrl: () => import_navigationApi.generateUrl,
35
+ getNavigationHelm: () => import_contextUtils.getNavigationHelm,
36
+ navigate: () => import_navigationApi.navigate,
37
+ registerNavigationHelm: () => import_contextUtils.registerNavigationHelm
38
+ });
39
+ var import_navigationContext = __toModule(require("lwr/navigationContext"));
40
+ var import_currentPageReference = __toModule(require("lwr/currentPageReference"));
41
+ var import_currentRoute = __toModule(require("lwr/currentRoute"));
42
+ var import_currentView = __toModule(require("lwr/currentView"));
43
+ var import_contextUtils = __toModule(require("lwr/contextUtils"));
44
+ var import_navigationApi = __toModule(require("./navigationApi"));
45
+ var import_navigationMixin = __toModule(require("./navigationMixin"));
@@ -0,0 +1,38 @@
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/navigation/navigationApi.ts
25
+ __markAsModule(exports);
26
+ __export(exports, {
27
+ generateUrl: () => generateUrl,
28
+ navigate: () => navigate
29
+ });
30
+ var import_contextUtils = __toModule(require("lwr/contextUtils"));
31
+ function navigate(context, pageReference, replace) {
32
+ const api = (0, import_contextUtils.getNavigationHelm)(context);
33
+ api.navigate(pageReference, replace);
34
+ }
35
+ function generateUrl(context, pageReference) {
36
+ const api = (0, import_contextUtils.getNavigationHelm)(context);
37
+ return api.generateUrl(pageReference);
38
+ }
@@ -0,0 +1,70 @@
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/navigation/navigationMixin.ts
25
+ __markAsModule(exports);
26
+ __export(exports, {
27
+ NavigationMixin: () => NavigationMixin
28
+ });
29
+ var import_routerErrors = __toModule(require("lwr/routerErrors"));
30
+ var import_navigationApi = __toModule(require("./navigationApi"));
31
+ var import_navigationMixinHacks = __toModule(require("lwr/navigationMixinHacks"));
32
+ var Navigate = Symbol("Navigate");
33
+ var GenerateUrl = Symbol("GenerateUrl");
34
+ var NavContext = Symbol("NavContext");
35
+ var GetContext = Symbol("NavContext");
36
+ function NavigationMixin(Base) {
37
+ (0, import_routerErrors.invariant)(typeof Base.prototype.dispatchEvent === "function", import_routerErrors.messages.INVALID_MIXIN_CMP, [
38
+ Base.toString()
39
+ ]);
40
+ class Mixin extends Base {
41
+ [GetContext]() {
42
+ if (!this[NavContext]) {
43
+ this.dispatchEvent(new CustomEvent(import_navigationMixinHacks.CONTEXT_ID_BACKDOOR, {
44
+ bubbles: true,
45
+ composed: true,
46
+ detail: {
47
+ callback: (contextId) => {
48
+ this[NavContext] = contextId;
49
+ }
50
+ }
51
+ }));
52
+ if (!this[NavContext]) {
53
+ throw new Error((0, import_routerErrors.generateMessage)(import_routerErrors.messages.MISSING_CONTEXT));
54
+ }
55
+ }
56
+ }
57
+ [Navigate](pageRef, replace) {
58
+ this[GetContext]();
59
+ (0, import_navigationApi.navigate)(this[NavContext], pageRef, replace);
60
+ }
61
+ async [GenerateUrl](pageRef) {
62
+ this[GetContext]();
63
+ return (0, import_navigationApi.generateUrl)(this[NavContext], pageRef);
64
+ }
65
+ }
66
+ return Mixin;
67
+ }
68
+ NavigationMixin.Navigate = Navigate;
69
+ NavigationMixin.GenerateUrl = GenerateUrl;
70
+ NavigationMixin.NavContext = NavContext;
@@ -0,0 +1,31 @@
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/navigationContext/navigationContext.ts
25
+ __markAsModule(exports);
26
+ __export(exports, {
27
+ NavigationContext: () => NavigationContext
28
+ });
29
+ var import_contextUtils = __toModule(require("lwr/contextUtils"));
30
+ var NAVIGATION_CONTEXT = new import_contextUtils.ContextInfo(void 0);
31
+ var NavigationContext = (0, import_contextUtils.generateContextualWireAdapter)(NAVIGATION_CONTEXT);