@lwrjs/router 0.24.2 → 0.24.4

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 (40) hide show
  1. package/build/cjs/modules/lwr/contextProvider/contextProvider.cjs +24 -22
  2. package/build/cjs/modules/lwr/contextUtils/contextInfo.cjs +62 -8
  3. package/build/cjs/modules/lwr/contextUtils/contextUtils.cjs +55 -22
  4. package/build/cjs/modules/lwr/contextUtils/navigationApiStore.cjs +15 -19
  5. package/build/cjs/modules/lwr/currentPageReference/currentPageReference.cjs +17 -19
  6. package/build/cjs/modules/lwr/currentView/currentView.cjs +15 -19
  7. package/build/cjs/modules/lwr/domRouter/domRouter.cjs +208 -81
  8. package/build/cjs/modules/lwr/domRouterUtils/domRouterUtils.cjs +15 -19
  9. package/build/cjs/modules/lwr/domRouterUtils/historyUtils.cjs +16 -4
  10. package/build/cjs/modules/lwr/domRouterUtils/types.cjs +14 -2
  11. package/build/cjs/modules/lwr/domRouterUtils/uriUtils.cjs +15 -18
  12. package/build/cjs/modules/lwr/historyRouter/historyRouter.cjs +38 -25
  13. package/build/cjs/modules/lwr/navigation/constants.cjs +20 -8
  14. package/build/cjs/modules/lwr/navigation/navigation.cjs +19 -23
  15. package/build/cjs/modules/lwr/navigation/navigationApi.cjs +14 -18
  16. package/build/cjs/modules/lwr/navigation/navigationMixin.cjs +29 -29
  17. package/build/cjs/modules/lwr/navigationContext/navigationContext.cjs +14 -18
  18. package/build/cjs/modules/lwr/navigationMixinHacks/navigationMixinHacks.cjs +14 -18
  19. package/build/cjs/modules/lwr/observable/observable.cjs +16 -4
  20. package/build/cjs/modules/lwr/outlet/outlet.cjs +27 -55
  21. package/build/cjs/modules/lwr/router/router.cjs +130 -40
  22. package/build/cjs/modules/lwr/routerBridge/routerBridge.cjs +37 -29
  23. package/build/cjs/modules/lwr/routerContainer/routerContainer.cjs +47 -40
  24. package/build/cjs/modules/lwr/routerContainer/utils.cjs +40 -20
  25. package/build/cjs/modules/lwr/routerErrors/routerErrors.cjs +16 -4
  26. package/build/cjs/modules/lwr/routerUtils/domUtils.cjs +16 -4
  27. package/build/cjs/modules/lwr/routerUtils/filterUtils.cjs +35 -17
  28. package/build/cjs/modules/lwr/routerUtils/parseUtils.cjs +26 -30
  29. package/build/cjs/modules/lwr/routerUtils/pathToRegexp.cjs +63 -52
  30. package/build/cjs/modules/lwr/routerUtils/routeDefUtils.cjs +25 -28
  31. package/build/cjs/modules/lwr/routerUtils/routeUtils.cjs +30 -34
  32. package/build/cjs/modules/lwr/routerUtils/routerUtils.cjs +21 -25
  33. package/build/cjs/modules/lwr/routerUtils/typeUtils.cjs +21 -7
  34. package/build/cjs/modules/lwr/routerUtils/types.cjs +14 -2
  35. package/build/cjs/modules/lwr/routerUtils/uriUtils.cjs +17 -5
  36. package/build/cjs/modules/lwr/serverRouter/serverRouter.cjs +63 -28
  37. package/build/cjs/services/index.cjs +46 -37
  38. package/build/cjs/services/module-provider/index.cjs +42 -30
  39. package/build/cjs/services/module-provider/utils.cjs +37 -31
  40. package/package.json +6 -6
@@ -1,75 +1,63 @@
1
- var __create = Object.create;
2
1
  var __defProp = Object.defineProperty;
3
- var __getProtoOf = Object.getPrototypeOf;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
- var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
5
  var __export = (target, all) => {
9
6
  for (var name in all)
10
- __defProp(target, name, {get: all[name], enumerable: true});
7
+ __defProp(target, name, { get: all[name], enumerable: true });
11
8
  };
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});
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
14
  }
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);
15
+ return to;
22
16
  };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
18
 
24
19
  // packages/@lwrjs/router/src/modules/lwr/domRouter/domRouter.ts
25
- __markAsModule(exports);
26
- __export(exports, {
20
+ var domRouter_exports = {};
21
+ __export(domRouter_exports, {
27
22
  DomRouterImpl: () => DomRouterImpl,
28
23
  NAV_EVENT: () => NAV_EVENT,
29
24
  PARENT_EVENT: () => PARENT_EVENT,
30
25
  createDomRouter: () => createDomRouter
31
26
  });
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"));
27
+ module.exports = __toCommonJS(domRouter_exports);
28
+ var import_navigation = require("lwr/navigation");
29
+ var import_contextProvider = require("lwr/contextProvider");
30
+ var import_routerErrors = require("lwr/routerErrors");
31
+ var import_routerUtils = require("lwr/routerUtils");
32
+ var import_observable = require("lwr/observable");
33
+ var import_metrics = require("lwr/metrics");
34
+ var import_profiler = require("lwr/profiler");
35
+ var import_navigationMixinHacks = require("lwr/navigationMixinHacks");
40
36
  var NAV_EVENT = `universalcontainernavigationevent${(0, import_routerUtils.guid)()}`;
41
37
  var PARENT_EVENT = `universalcontainerparentevent${(0, import_routerUtils.guid)()}`;
42
38
  var DomRouterImpl = class {
39
+ config;
40
+ target;
41
+ router;
42
+ pendingRoute = null;
43
+ committedRoute = null;
44
+ routeObservable;
45
+ eventId;
46
+ // used for instrumentation
47
+ contextId = Object.freeze(() => void 0);
48
+ connected = false;
49
+ parent;
50
+ child;
51
+ preNavFilters = (0, import_routerUtils.createFilterChain)();
52
+ errorNavFilters = (0, import_routerUtils.createFilterChain)();
53
+ /**
54
+ * Create and configure the Router.
55
+ *
56
+ * @param {object} config - The domRouter config object, all properties are optional
57
+ * @param {object} router - an optional Router
58
+ * @param {HTMLElement} target - DOM node to attach to
59
+ */
43
60
  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
61
  this.config = {
74
62
  handleNavigation: config.handleNavigation || (() => true)
75
63
  };
@@ -78,6 +66,9 @@ var DomRouterImpl = class {
78
66
  this.router.contextId = this.contextId;
79
67
  this.routeObservable = (0, import_observable.createObservable)();
80
68
  }
69
+ /**
70
+ * Search up the node chain until the root node is hit
71
+ */
81
72
  get root() {
82
73
  if (!this.parent) {
83
74
  return this;
@@ -91,6 +82,13 @@ var DomRouterImpl = class {
91
82
  }
92
83
  throw new Error("No root router could be found");
93
84
  }
85
+ /**
86
+ * Informs an wire listeners of routing changes/errors
87
+ *
88
+ * @param {RoutingResult} result - result object from navigation event
89
+ * @param {string} url - url from the page reference that triggered the navigation event
90
+ * @param {MessageObject} error - if an error occurred during the navigation
91
+ */
94
92
  updateWires(result, url, error) {
95
93
  if (error) {
96
94
  this.processError(error);
@@ -98,17 +96,20 @@ var DomRouterImpl = class {
98
96
  if (this.committedRoute && result.route === this.committedRoute.route) {
99
97
  return;
100
98
  }
101
- (0, import_profiler.logOperationEnd)({id: import_metrics.ROUTER_VIEW, specifier: this.eventId});
102
- this.pendingRoute = this.pendingRoute || {...result, url};
103
- this.committedRoute = {...this.pendingRoute, ...result};
99
+ (0, import_profiler.logOperationEnd)({ id: import_metrics.ROUTER_VIEW, specifier: this.eventId });
100
+ this.pendingRoute = this.pendingRoute || { ...result, url };
101
+ this.committedRoute = { ...this.pendingRoute, ...result };
104
102
  import_navigation.CurrentPageReference.setContext(this.target, result.route.pageReference);
105
- this.routeObservable.next({...this.committedRoute, viewset: result.viewset});
106
- (0, import_profiler.logOperationEnd)({id: import_metrics.ROUTER_NAV, specifier: this.eventId});
103
+ this.routeObservable.next({ ...this.committedRoute, viewset: result.viewset });
104
+ (0, import_profiler.logOperationEnd)({ id: import_metrics.ROUTER_NAV, specifier: this.eventId });
107
105
  if (this.child) {
108
106
  this.child.process(this._stripUrlForChild(this.committedRoute.url));
109
107
  }
110
108
  }
111
109
  }
110
+ /**
111
+ * Override to provide this router as a navigation context
112
+ */
112
113
  connect() {
113
114
  this._sendEvent(PARENT_EVENT, (router) => {
114
115
  this.parent = router;
@@ -131,16 +132,18 @@ var DomRouterImpl = class {
131
132
  }
132
133
  if (result.status && result.status >= 400) {
133
134
  const error = result.error || new Error();
134
- this.processError((0, import_routerErrors.generateMessageObject)(import_routerErrors.messages.DESTINATION_ERROR, [
135
- result.status.toString(),
136
- error.message,
137
- error.stack || ""
138
- ]));
135
+ this.processError(
136
+ (0, import_routerErrors.generateMessageObject)(import_routerErrors.messages.DESTINATION_ERROR, [
137
+ result.status.toString(),
138
+ error.message,
139
+ error.stack || ""
140
+ ])
141
+ );
139
142
  return;
140
143
  }
141
144
  const pageReference = result.route.pageReference || {};
142
145
  const url = this.router.generateUrl(pageReference) || "";
143
- (0, import_profiler.logOperationStart)({id: import_metrics.ROUTER_VIEW, specifier: this.eventId});
146
+ (0, import_profiler.logOperationStart)({ id: import_metrics.ROUTER_VIEW, specifier: this.eventId });
144
147
  if (result.viewset) {
145
148
  const currentViewContext = {
146
149
  viewset: result.viewset,
@@ -176,12 +179,28 @@ var DomRouterImpl = class {
176
179
  this.child = void 0;
177
180
  this.connected = false;
178
181
  }
182
+ /**
183
+ * Add listeners to this router hook which run BEFORE a new URL is processed (root -> leaf).
184
+ *
185
+ * @param {object | object[]} filters
186
+ */
179
187
  addPreNavigate(filters) {
180
188
  this.preNavFilters.add(filters);
181
189
  }
190
+ /**
191
+ * Add listeners to this router hook which run when there is an error navigating.
192
+ *
193
+ * @param {object | object[]} filters
194
+ */
182
195
  addErrorNavigate(filters) {
183
196
  this.errorNavFilters.add(filters);
184
197
  }
198
+ /**
199
+ * Override parent implementation.
200
+ * Pass the current state down to a new child.
201
+ *
202
+ * @param {child} child - Child router
203
+ */
185
204
  async addChild(child) {
186
205
  await new Promise((resolve) => {
187
206
  setTimeout(() => {
@@ -198,9 +217,23 @@ var DomRouterImpl = class {
198
217
  }
199
218
  }
200
219
  }
220
+ /**
221
+ * Process the current URL passed down by the parent router.
222
+ * Stop propagation of the navigation event if a preNavigate filter returns false.
223
+ *
224
+ * Update the current path and route matches.
225
+ * Update the observable to hold the new route.
226
+ *
227
+ * After processing, delegate to a child router, if it exists.
228
+ *
229
+ * @param {string} url - Relative URL string to process
230
+ * @param {NavigateOptions} options - Additional navigation options (i.e. switch root locale)
231
+ * @returns {boolean} - True if the processing was NOT blocked by a preNavigate listener
232
+ */
233
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
201
234
  async process(url, _shouldReplace, options, _updateHistory) {
202
- this.eventId = new Date().getTime().toString();
203
- (0, import_profiler.logOperationStart)({id: import_metrics.ROUTER_NAV, specifier: this.eventId});
235
+ this.eventId = (/* @__PURE__ */ new Date()).getTime().toString();
236
+ (0, import_profiler.logOperationStart)({ id: import_metrics.ROUTER_NAV, specifier: this.eventId });
204
237
  try {
205
238
  if (!this.parent) {
206
239
  await this.preProcess(url, options);
@@ -218,13 +251,22 @@ var DomRouterImpl = class {
218
251
  }
219
252
  return true;
220
253
  }
254
+ /**
255
+ * Run the preNavigate filters for this router.
256
+ * After processing, delegate to a child router, if it exists.
257
+ *
258
+ * @param {string} url - Relative URL string to process,
259
+ * cannot use a route since the processing is done in context
260
+ *
261
+ * @returns {Promise<boolean>} - Resolves to true if successful
262
+ */
221
263
  preProcess(url, options) {
222
264
  const address = this.router.parseUrl(url);
223
265
  const routingMatch = address && this.router.matchRoute(address, options);
224
266
  if (!routingMatch) {
225
267
  return Promise.reject((0, import_routerErrors.generateMessageObject)(import_routerErrors.messages.MISSING_ROUTE, [url]));
226
268
  }
227
- this.pendingRoute = {url, ...routingMatch};
269
+ this.pendingRoute = { url, ...routingMatch };
228
270
  const canGo = this.preNavFilters.empty() ? Promise.resolve(true) : this.preNavFilters.compile({
229
271
  current: this.committedRoute || void 0,
230
272
  next: this.pendingRoute
@@ -235,13 +277,28 @@ var DomRouterImpl = class {
235
277
  return canContinue || Promise.reject((0, import_routerErrors.generateMessageObject)(import_routerErrors.messages.PRENAV_FAILED, [url]));
236
278
  });
237
279
  }
280
+ /**
281
+ * Run the errorNavigate filters for this router.
282
+ * After processing, delegate to a child router, if it exists.
283
+ *
284
+ * @param {object} e - An error object to pass into the error hook listeners.
285
+ */
238
286
  processError(messageObject) {
239
- (0, import_profiler.logOperationStart)({id: import_metrics.ROUTER_ERROR});
287
+ (0, import_profiler.logOperationStart)({ id: import_metrics.ROUTER_ERROR });
240
288
  this.errorNavFilters.compile(messageObject);
241
289
  if (this.child) {
242
290
  this.child.processError(messageObject);
243
291
  }
244
292
  }
293
+ /**
294
+ * lightning/navigation
295
+ * Fire an event to send the navigation event up the DOM.
296
+ * The root router will be the last to catch the event if it is not stopped.
297
+ *
298
+ * @param {object} address - Address to navigate to
299
+ * @param {*} options - Usually a boolean; when true the previous browser history
300
+ * entry should be replaced by this one
301
+ */
245
302
  navigate(address, replace, options) {
246
303
  const routerOptions = this.filterNavigateOptions(options);
247
304
  let url = this.router.generateUrl(address, routerOptions);
@@ -249,8 +306,17 @@ var DomRouterImpl = class {
249
306
  const parentPath = this.parent && this.parent.committedRoute && this.parent.committedRoute.pathMatch || "";
250
307
  url = parentPath.concat(url);
251
308
  }
252
- this._sendEvent(NAV_EVENT, {url, replace, address});
309
+ this._sendEvent(NAV_EVENT, { url, replace, address });
253
310
  }
311
+ /**
312
+ * lightning/navigation
313
+ * Generate a URL based on the given route.
314
+ * Return the URL string.
315
+ *
316
+ * @param {object} route - Route to generate a url for
317
+ *
318
+ * @returns {string}
319
+ */
254
320
  generateUrl(address, options) {
255
321
  const routerOptions = this.filterNavigateOptions(options);
256
322
  const url = this.router.generateUrl(address, routerOptions);
@@ -260,6 +326,10 @@ var DomRouterImpl = class {
260
326
  const parentPath = this.parent && this.parent.committedRoute && this.parent.committedRoute.pathMatch || "";
261
327
  return `${parentPath}${url}`;
262
328
  }
329
+ /**
330
+ * Async version of generateUrl, used by the NavigationMixin and goes through the generateUrlFilter.
331
+ * @returns {Promise<string>}
332
+ */
263
333
  async generateUrlAsync(address, options) {
264
334
  const routerOptions = this.filterNavigateOptions(options);
265
335
  const url = await this.router.generateUrlAsync(address, routerOptions);
@@ -269,21 +339,74 @@ var DomRouterImpl = class {
269
339
  const parentPath = this.parent && this.parent.committedRoute && this.parent.committedRoute.pathMatch || "";
270
340
  return `${parentPath}${url}`;
271
341
  }
342
+ /**
343
+ * lightning/navigation
344
+ * Subscribe a callback to the Observable on the current route of this router.
345
+ *
346
+ * @param {function} callback - A callback function invoked when the navigation state changes
347
+ * callback(route, routeDef)
348
+ * @param {boolean} replay - Flag to determine if callback should be called with current route and data immediately
349
+ */
272
350
  subscribe(callback, replay) {
273
- return this.routeObservable.subscribe({
274
- next: callback,
275
- error: () => {
351
+ return this.routeObservable.subscribe(
352
+ {
353
+ next: callback,
354
+ error: () => {
355
+ },
356
+ complete: () => {
357
+ }
276
358
  },
277
- complete: () => {
278
- }
279
- }, Boolean(replay));
359
+ Boolean(replay)
360
+ );
280
361
  }
362
+ /**
363
+ * Inspect a navigation event bubbling up from a descendent component.
364
+ * This node can choose to stop the event by returning false.
365
+ * If propagation is not stopped, and this node is the root (no parent),
366
+ * then begin the root -> leaf processing of this new route.
367
+ * This will update the navigation event subscribers in each DomRouter, top down.
368
+ *
369
+ * @param {Event} event - With detail: { url, options }
370
+ */
371
+ _handleNavigationEvent = (event) => {
372
+ const navigationEvent = event;
373
+ if (navigationEvent.detail && typeof navigationEvent.detail === "object") {
374
+ const { url, replace, address } = navigationEvent.detail;
375
+ const continueNavigation = this.config.handleNavigation(address, replace);
376
+ if (!continueNavigation) {
377
+ navigationEvent.stopPropagation();
378
+ } else {
379
+ if (this.root && !url) {
380
+ this.root.processError(
381
+ (0, import_routerErrors.generateMessageObject)(import_routerErrors.messages.MISSING_URL, [JSON.stringify(address)])
382
+ );
383
+ } else if (!this.parent) {
384
+ this.process(url, replace);
385
+ }
386
+ }
387
+ }
388
+ };
389
+ /**
390
+ * Be discovered as a parent for descendent components.
391
+ * Stop immediate propagation because we only want 1 parent to be found.
392
+ *
393
+ * @param {Event} event - With detail: callback
394
+ */
395
+ _handleParentEvent = (event) => {
396
+ event.stopImmediatePropagation();
397
+ const parentRouterEvent = event;
398
+ if (parentRouterEvent && parentRouterEvent.detail && typeof parentRouterEvent.detail === "function") {
399
+ parentRouterEvent.detail(this);
400
+ }
401
+ };
281
402
  _sendEvent(name, payload) {
282
- import_routerUtils.hasDocument && this.target.dispatchEvent(new CustomEvent(name, {
283
- bubbles: true,
284
- composed: true,
285
- detail: payload
286
- }));
403
+ import_routerUtils.hasDocument && this.target.dispatchEvent(
404
+ new CustomEvent(name, {
405
+ bubbles: true,
406
+ composed: true,
407
+ detail: payload
408
+ })
409
+ );
287
410
  }
288
411
  _stripUrlForChild(url) {
289
412
  if (this.pendingRoute && url.indexOf(this.pendingRoute.pathMatch) === 0) {
@@ -291,10 +414,14 @@ var DomRouterImpl = class {
291
414
  }
292
415
  return url;
293
416
  }
417
+ /**
418
+ * Filter the navigate options based on if this is a root router or not.
419
+ */
294
420
  filterNavigateOptions(options) {
295
421
  const isRoot = !this.parent;
296
422
  const routerOptions = {
297
423
  ...options,
424
+ // Only allow switch locales if this is a root router
298
425
  locale: isRoot ? options?.locale : void 0
299
426
  };
300
427
  return routerOptions;
@@ -1,33 +1,29 @@
1
- var __create = Object.create;
2
1
  var __defProp = Object.defineProperty;
3
- var __getProtoOf = Object.getPrototypeOf;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
- var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
5
  var __export = (target, all) => {
9
6
  for (var name in all)
10
- __defProp(target, name, {get: all[name], enumerable: true});
7
+ __defProp(target, name, { get: all[name], enumerable: true });
11
8
  };
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});
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
14
  }
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);
15
+ return to;
22
16
  };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
18
 
24
19
  // packages/@lwrjs/router/src/modules/lwr/domRouterUtils/domRouterUtils.ts
25
- __markAsModule(exports);
26
- __export(exports, {
20
+ var domRouterUtils_exports = {};
21
+ __export(domRouterUtils_exports, {
27
22
  getRelativeUrl: () => import_uriUtils.getRelativeUrl,
28
23
  removeFragment: () => import_uriUtils.removeFragment,
29
24
  replace: () => import_historyUtils.replace,
30
25
  set: () => import_historyUtils.set
31
26
  });
32
- var import_uriUtils = __toModule(require("./uriUtils.cjs"));
33
- var import_historyUtils = __toModule(require("./historyUtils.cjs"));
27
+ module.exports = __toCommonJS(domRouterUtils_exports);
28
+ var import_uriUtils = require("./uriUtils.cjs");
29
+ var import_historyUtils = require("./historyUtils.cjs");
@@ -1,16 +1,28 @@
1
1
  var __defProp = Object.defineProperty;
2
- var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
3
5
  var __export = (target, all) => {
4
6
  for (var name in all)
5
- __defProp(target, name, {get: all[name], enumerable: true});
7
+ __defProp(target, name, { get: all[name], enumerable: true });
6
8
  };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
7
18
 
8
19
  // packages/@lwrjs/router/src/modules/lwr/domRouterUtils/historyUtils.ts
9
- __markAsModule(exports);
10
- __export(exports, {
20
+ var historyUtils_exports = {};
21
+ __export(historyUtils_exports, {
11
22
  replace: () => replace,
12
23
  set: () => set
13
24
  });
25
+ module.exports = __toCommonJS(historyUtils_exports);
14
26
  function set(path, route) {
15
27
  const data = route || {};
16
28
  window.history.pushState(data, "", path);
@@ -1,5 +1,17 @@
1
1
  var __defProp = Object.defineProperty;
2
- var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
3
14
 
4
15
  // packages/@lwrjs/router/src/modules/lwr/domRouterUtils/types.ts
5
- __markAsModule(exports);
16
+ var types_exports = {};
17
+ module.exports = __toCommonJS(types_exports);
@@ -1,34 +1,30 @@
1
- var __create = Object.create;
2
1
  var __defProp = Object.defineProperty;
3
- var __getProtoOf = Object.getPrototypeOf;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
- var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
5
  var __export = (target, all) => {
9
6
  for (var name in all)
10
- __defProp(target, name, {get: all[name], enumerable: true});
7
+ __defProp(target, name, { get: all[name], enumerable: true });
11
8
  };
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});
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
14
  }
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);
15
+ return to;
22
16
  };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
18
 
24
19
  // packages/@lwrjs/router/src/modules/lwr/domRouterUtils/uriUtils.ts
25
- __markAsModule(exports);
26
- __export(exports, {
20
+ var uriUtils_exports = {};
21
+ __export(uriUtils_exports, {
27
22
  getRelativeUrl: () => getRelativeUrl,
28
23
  getUrlObject: () => getUrlObject,
29
24
  removeFragment: () => removeFragment
30
25
  });
31
- var import_routerUtils = __toModule(require("lwr/routerUtils"));
26
+ module.exports = __toCommonJS(uriUtils_exports);
27
+ var import_routerUtils = require("lwr/routerUtils");
32
28
  function getUrlObject(url = "") {
33
29
  url = url || "";
34
30
  if (url.indexOf("://") < 0) {
@@ -51,6 +47,7 @@ function getUrlObject(url = "") {
51
47
  href: link.href,
52
48
  origin: `${link.protocol}//${link.hostname}${link.port ? `:${link.port}` : ""}`,
53
49
  pathname: link.pathname.replace(/(\/)?/, "/"),
50
+ // ensure there is a leading slash (IE11)
54
51
  searchParams
55
52
  };
56
53
  }