@breautek/router 3.0.0 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/router.js CHANGED
@@ -13,788 +13,711 @@ function ___$insertStyle(css) {
13
13
  return css;
14
14
  }
15
15
 
16
- Object.defineProperty(exports, '__esModule', { value: true });
17
-
18
16
  var React = require('react');
19
17
  var events = require('events');
20
18
 
21
- function _interopNamespace(e) {
22
- if (e && e.__esModule) return e;
23
- var n = Object.create(null);
24
- if (e) {
25
- Object.keys(e).forEach(function (k) {
26
- if (k !== 'default') {
27
- var d = Object.getOwnPropertyDescriptor(e, k);
28
- Object.defineProperty(n, k, d.get ? d : {
29
- enumerable: true,
30
- get: function () { return e[k]; }
19
+ function _interopNamespaceDefault(e) {
20
+ var n = Object.create(null);
21
+ if (e) {
22
+ Object.keys(e).forEach(function (k) {
23
+ if (k !== 'default') {
24
+ var d = Object.getOwnPropertyDescriptor(e, k);
25
+ Object.defineProperty(n, k, d.get ? d : {
26
+ enumerable: true,
27
+ get: function () { return e[k]; }
28
+ });
29
+ }
31
30
  });
32
- }
33
- });
34
- }
35
- n["default"] = e;
36
- return Object.freeze(n);
31
+ }
32
+ n.default = e;
33
+ return Object.freeze(n);
37
34
  }
38
35
 
39
- var React__namespace = /*#__PURE__*/_interopNamespace(React);
36
+ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
40
37
 
41
- var runtime = {exports: {}};
38
+ const EVENT_URL_CHANGE = 'urlchange';
39
+ class RouterStrategy extends events.EventEmitter {
40
+ constructor(router) {
41
+ super();
42
+ this.$router = router;
43
+ this.$viewMountListeners = [];
44
+ this.$viewUnmountListneners = [];
45
+ }
46
+ addViewMountCallback(cb) {
47
+ this.$viewMountListeners.push(cb);
48
+ }
49
+ removeViewMountCallback(cb) {
50
+ let idx = this.$viewMountListeners.indexOf(cb);
51
+ if (idx > -1) {
52
+ this.$viewMountListeners.splice(idx, 1);
53
+ }
54
+ }
55
+ addViewUnmountCallback(cb) {
56
+ this.$viewUnmountListneners.push(cb);
57
+ }
58
+ removeViewUnmountCallback(cb) {
59
+ let idx = this.$viewUnmountListneners.indexOf(cb);
60
+ if (idx > -1) {
61
+ this.$viewUnmountListneners.splice(idx, 1);
62
+ }
63
+ }
64
+ /**
65
+ * @internal
66
+ * @param view
67
+ */
68
+ __onViewMount(view) {
69
+ for (let i = 0; i < this.$viewMountListeners.length; i++) {
70
+ this.$viewMountListeners[i](view);
71
+ }
72
+ }
73
+ /**
74
+ * @internal
75
+ * @param view
76
+ */
77
+ __onViewUnmount(view) {
78
+ for (let i = 0; i < this.$viewUnmountListneners.length; i++) {
79
+ this.$viewUnmountListneners[i](view);
80
+ }
81
+ }
82
+ /**
83
+ * Gets the router
84
+ */
85
+ getRouter() {
86
+ return this.$router;
87
+ }
88
+ /**
89
+ * Sets the browser title
90
+ *
91
+ * @param {string} title
92
+ */
93
+ setTitle(title) {
94
+ let head = document.head.getElementsByTagName('title')[0];
95
+ if (!head) {
96
+ head = document.createElement('title');
97
+ document.head.appendChild(head);
98
+ }
99
+ if (!title) {
100
+ title = '';
101
+ }
102
+ head.innerText = title.toString();
103
+ }
104
+ /**
105
+ * Listen for URL change events
106
+ *
107
+ * @param callback
108
+ */
109
+ addURLChangeCallback(callback) {
110
+ this.on(EVENT_URL_CHANGE, callback);
111
+ }
112
+ /**
113
+ * Removes an existing listener
114
+ *
115
+ * @param callback
116
+ */
117
+ removeURLChangeCallback(callback) {
118
+ this.off(EVENT_URL_CHANGE, callback);
119
+ }
120
+ /**
121
+ * navigate the history forward one entry. This is an alias for [go(1)]{@link go}
122
+ */
123
+ forward() {
124
+ this.go(1);
125
+ }
126
+ /**
127
+ * Navigate the history back one entry. This is an alias for [go(-1)]{@link go}
128
+ */
129
+ back() {
130
+ this.go(-1);
131
+ }
132
+ /**
133
+ * Returns true if can go back 1 entry.
134
+ * This is the same as calling [canGo(-1)]{@link canGo}
135
+ */
136
+ canBack() {
137
+ return this.canGo(-1);
138
+ }
139
+ /**
140
+ * Returns true if can go forward 1 entry.
141
+ * This is the same as calling [canGo(1)]{@link canGo}
142
+ */
143
+ canForward() {
144
+ return this.canGo(1);
145
+ }
146
+ /**
147
+ * Returns the URL one entry forward.
148
+ * This is the same as calling [peek(1)]{@link peek}
149
+ */
150
+ peekForward() {
151
+ return this.peek(1);
152
+ }
153
+ /**
154
+ * Returns the URL one entry back.
155
+ * This is the same as calling [peek(-1)]{@link peek}
156
+ */
157
+ peekBack() {
158
+ return this.peek(-1);
159
+ }
160
+ /**
161
+ * Fires the {@link EVENT_URL_CHANGE} event
162
+ * @param url
163
+ */
164
+ _fireURLChange(url) {
165
+ this.emit(EVENT_URL_CHANGE, url);
166
+ }
167
+ }
42
168
 
43
169
  /**
44
- * Copyright (c) 2014-present, Facebook, Inc.
45
- *
46
- * This source code is licensed under the MIT license found in the
47
- * LICENSE file in the root directory of this source tree.
48
- */
49
-
50
- (function (module) {
51
- var runtime = (function (exports) {
52
-
53
- var Op = Object.prototype;
54
- var hasOwn = Op.hasOwnProperty;
55
- var undefined$1; // More compressible than void 0.
56
- var $Symbol = typeof Symbol === "function" ? Symbol : {};
57
- var iteratorSymbol = $Symbol.iterator || "@@iterator";
58
- var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
59
- var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
60
-
61
- function define(obj, key, value) {
62
- Object.defineProperty(obj, key, {
63
- value: value,
64
- enumerable: true,
65
- configurable: true,
66
- writable: true
67
- });
68
- return obj[key];
69
- }
70
- try {
71
- // IE 8 has a broken Object.defineProperty that only works on DOM objects.
72
- define({}, "");
73
- } catch (err) {
74
- define = function(obj, key, value) {
75
- return obj[key] = value;
76
- };
77
- }
78
-
79
- function wrap(innerFn, outerFn, self, tryLocsList) {
80
- // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
81
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
82
- var generator = Object.create(protoGenerator.prototype);
83
- var context = new Context(tryLocsList || []);
84
-
85
- // The ._invoke method unifies the implementations of the .next,
86
- // .throw, and .return methods.
87
- generator._invoke = makeInvokeMethod(innerFn, self, context);
88
-
89
- return generator;
90
- }
91
- exports.wrap = wrap;
92
-
93
- // Try/catch helper to minimize deoptimizations. Returns a completion
94
- // record like context.tryEntries[i].completion. This interface could
95
- // have been (and was previously) designed to take a closure to be
96
- // invoked without arguments, but in all the cases we care about we
97
- // already have an existing method we want to call, so there's no need
98
- // to create a new function object. We can even get away with assuming
99
- // the method takes exactly one argument, since that happens to be true
100
- // in every case, so we don't have to touch the arguments object. The
101
- // only additional allocation required is the completion record, which
102
- // has a stable shape and so hopefully should be cheap to allocate.
103
- function tryCatch(fn, obj, arg) {
104
- try {
105
- return { type: "normal", arg: fn.call(obj, arg) };
106
- } catch (err) {
107
- return { type: "throw", arg: err };
108
- }
109
- }
110
-
111
- var GenStateSuspendedStart = "suspendedStart";
112
- var GenStateSuspendedYield = "suspendedYield";
113
- var GenStateExecuting = "executing";
114
- var GenStateCompleted = "completed";
115
-
116
- // Returning this object from the innerFn has the same effect as
117
- // breaking out of the dispatch switch statement.
118
- var ContinueSentinel = {};
119
-
120
- // Dummy constructor functions that we use as the .constructor and
121
- // .constructor.prototype properties for functions that return Generator
122
- // objects. For full spec compliance, you may wish to configure your
123
- // minifier not to mangle the names of these two functions.
124
- function Generator() {}
125
- function GeneratorFunction() {}
126
- function GeneratorFunctionPrototype() {}
127
-
128
- // This is a polyfill for %IteratorPrototype% for environments that
129
- // don't natively support it.
130
- var IteratorPrototype = {};
131
- define(IteratorPrototype, iteratorSymbol, function () {
132
- return this;
133
- });
134
-
135
- var getProto = Object.getPrototypeOf;
136
- var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
137
- if (NativeIteratorPrototype &&
138
- NativeIteratorPrototype !== Op &&
139
- hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
140
- // This environment has a native %IteratorPrototype%; use it instead
141
- // of the polyfill.
142
- IteratorPrototype = NativeIteratorPrototype;
143
- }
144
-
145
- var Gp = GeneratorFunctionPrototype.prototype =
146
- Generator.prototype = Object.create(IteratorPrototype);
147
- GeneratorFunction.prototype = GeneratorFunctionPrototype;
148
- define(Gp, "constructor", GeneratorFunctionPrototype);
149
- define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
150
- GeneratorFunction.displayName = define(
151
- GeneratorFunctionPrototype,
152
- toStringTagSymbol,
153
- "GeneratorFunction"
154
- );
155
-
156
- // Helper for defining the .next, .throw, and .return methods of the
157
- // Iterator interface in terms of a single ._invoke method.
158
- function defineIteratorMethods(prototype) {
159
- ["next", "throw", "return"].forEach(function(method) {
160
- define(prototype, method, function(arg) {
161
- return this._invoke(method, arg);
162
- });
163
- });
164
- }
165
-
166
- exports.isGeneratorFunction = function(genFun) {
167
- var ctor = typeof genFun === "function" && genFun.constructor;
168
- return ctor
169
- ? ctor === GeneratorFunction ||
170
- // For the native GeneratorFunction constructor, the best we can
171
- // do is to check its .name property.
172
- (ctor.displayName || ctor.name) === "GeneratorFunction"
173
- : false;
174
- };
175
-
176
- exports.mark = function(genFun) {
177
- if (Object.setPrototypeOf) {
178
- Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
179
- } else {
180
- genFun.__proto__ = GeneratorFunctionPrototype;
181
- define(genFun, toStringTagSymbol, "GeneratorFunction");
182
- }
183
- genFun.prototype = Object.create(Gp);
184
- return genFun;
185
- };
186
-
187
- // Within the body of any async function, `await x` is transformed to
188
- // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
189
- // `hasOwn.call(value, "__await")` to determine if the yielded value is
190
- // meant to be awaited.
191
- exports.awrap = function(arg) {
192
- return { __await: arg };
193
- };
194
-
195
- function AsyncIterator(generator, PromiseImpl) {
196
- function invoke(method, arg, resolve, reject) {
197
- var record = tryCatch(generator[method], generator, arg);
198
- if (record.type === "throw") {
199
- reject(record.arg);
200
- } else {
201
- var result = record.arg;
202
- var value = result.value;
203
- if (value &&
204
- typeof value === "object" &&
205
- hasOwn.call(value, "__await")) {
206
- return PromiseImpl.resolve(value.__await).then(function(value) {
207
- invoke("next", value, resolve, reject);
208
- }, function(err) {
209
- invoke("throw", err, resolve, reject);
210
- });
211
- }
212
-
213
- return PromiseImpl.resolve(value).then(function(unwrapped) {
214
- // When a yielded Promise is resolved, its final value becomes
215
- // the .value of the Promise<{value,done}> result for the
216
- // current iteration.
217
- result.value = unwrapped;
218
- resolve(result);
219
- }, function(error) {
220
- // If a rejected Promise was yielded, throw the rejection back
221
- // into the async generator function so it can be handled there.
222
- return invoke("throw", error, resolve, reject);
223
- });
224
- }
225
- }
226
-
227
- var previousPromise;
228
-
229
- function enqueue(method, arg) {
230
- function callInvokeWithMethodAndArg() {
231
- return new PromiseImpl(function(resolve, reject) {
232
- invoke(method, arg, resolve, reject);
233
- });
234
- }
235
-
236
- return previousPromise =
237
- // If enqueue has been called before, then we want to wait until
238
- // all previous Promises have been resolved before calling invoke,
239
- // so that results are always delivered in the correct order. If
240
- // enqueue has not been called before, then it is important to
241
- // call invoke immediately, without waiting on a callback to fire,
242
- // so that the async generator function has the opportunity to do
243
- // any necessary setup in a predictable way. This predictability
244
- // is why the Promise constructor synchronously invokes its
245
- // executor callback, and why async functions synchronously
246
- // execute code before the first await. Since we implement simple
247
- // async functions in terms of async generators, it is especially
248
- // important to get this right, even though it requires care.
249
- previousPromise ? previousPromise.then(
250
- callInvokeWithMethodAndArg,
251
- // Avoid propagating failures to Promises returned by later
252
- // invocations of the iterator.
253
- callInvokeWithMethodAndArg
254
- ) : callInvokeWithMethodAndArg();
255
- }
256
-
257
- // Define the unified helper method that is used to implement .next,
258
- // .throw, and .return (see defineIteratorMethods).
259
- this._invoke = enqueue;
260
- }
261
-
262
- defineIteratorMethods(AsyncIterator.prototype);
263
- define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
264
- return this;
265
- });
266
- exports.AsyncIterator = AsyncIterator;
267
-
268
- // Note that simple async functions are implemented on top of
269
- // AsyncIterator objects; they just return a Promise for the value of
270
- // the final result produced by the iterator.
271
- exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
272
- if (PromiseImpl === void 0) PromiseImpl = Promise;
273
-
274
- var iter = new AsyncIterator(
275
- wrap(innerFn, outerFn, self, tryLocsList),
276
- PromiseImpl
277
- );
278
-
279
- return exports.isGeneratorFunction(outerFn)
280
- ? iter // If outerFn is a generator, return the full iterator.
281
- : iter.next().then(function(result) {
282
- return result.done ? result.value : iter.next();
283
- });
284
- };
285
-
286
- function makeInvokeMethod(innerFn, self, context) {
287
- var state = GenStateSuspendedStart;
288
-
289
- return function invoke(method, arg) {
290
- if (state === GenStateExecuting) {
291
- throw new Error("Generator is already running");
292
- }
293
-
294
- if (state === GenStateCompleted) {
295
- if (method === "throw") {
296
- throw arg;
297
- }
298
-
299
- // Be forgiving, per 25.3.3.3.3 of the spec:
300
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
301
- return doneResult();
302
- }
303
-
304
- context.method = method;
305
- context.arg = arg;
306
-
307
- while (true) {
308
- var delegate = context.delegate;
309
- if (delegate) {
310
- var delegateResult = maybeInvokeDelegate(delegate, context);
311
- if (delegateResult) {
312
- if (delegateResult === ContinueSentinel) continue;
313
- return delegateResult;
314
- }
315
- }
316
-
317
- if (context.method === "next") {
318
- // Setting context._sent for legacy support of Babel's
319
- // function.sent implementation.
320
- context.sent = context._sent = context.arg;
321
-
322
- } else if (context.method === "throw") {
323
- if (state === GenStateSuspendedStart) {
324
- state = GenStateCompleted;
325
- throw context.arg;
326
- }
327
-
328
- context.dispatchException(context.arg);
329
-
330
- } else if (context.method === "return") {
331
- context.abrupt("return", context.arg);
332
- }
333
-
334
- state = GenStateExecuting;
335
-
336
- var record = tryCatch(innerFn, self, context);
337
- if (record.type === "normal") {
338
- // If an exception is thrown from innerFn, we leave state ===
339
- // GenStateExecuting and loop back for another invocation.
340
- state = context.done
341
- ? GenStateCompleted
342
- : GenStateSuspendedYield;
343
-
344
- if (record.arg === ContinueSentinel) {
345
- continue;
346
- }
347
-
348
- return {
349
- value: record.arg,
350
- done: context.done
351
- };
352
-
353
- } else if (record.type === "throw") {
354
- state = GenStateCompleted;
355
- // Dispatch the exception by looping back around to the
356
- // context.dispatchException(context.arg) call above.
357
- context.method = "throw";
358
- context.arg = record.arg;
359
- }
360
- }
361
- };
362
- }
363
-
364
- // Call delegate.iterator[context.method](context.arg) and handle the
365
- // result, either by returning a { value, done } result from the
366
- // delegate iterator, or by modifying context.method and context.arg,
367
- // setting context.delegate to null, and returning the ContinueSentinel.
368
- function maybeInvokeDelegate(delegate, context) {
369
- var method = delegate.iterator[context.method];
370
- if (method === undefined$1) {
371
- // A .throw or .return when the delegate iterator has no .throw
372
- // method always terminates the yield* loop.
373
- context.delegate = null;
374
-
375
- if (context.method === "throw") {
376
- // Note: ["return"] must be used for ES3 parsing compatibility.
377
- if (delegate.iterator["return"]) {
378
- // If the delegate iterator has a return method, give it a
379
- // chance to clean up.
380
- context.method = "return";
381
- context.arg = undefined$1;
382
- maybeInvokeDelegate(delegate, context);
383
-
384
- if (context.method === "throw") {
385
- // If maybeInvokeDelegate(context) changed context.method from
386
- // "return" to "throw", let that override the TypeError below.
387
- return ContinueSentinel;
388
- }
389
- }
390
-
391
- context.method = "throw";
392
- context.arg = new TypeError(
393
- "The iterator does not provide a 'throw' method");
394
- }
395
-
396
- return ContinueSentinel;
397
- }
398
-
399
- var record = tryCatch(method, delegate.iterator, context.arg);
400
-
401
- if (record.type === "throw") {
402
- context.method = "throw";
403
- context.arg = record.arg;
404
- context.delegate = null;
405
- return ContinueSentinel;
406
- }
407
-
408
- var info = record.arg;
409
-
410
- if (! info) {
411
- context.method = "throw";
412
- context.arg = new TypeError("iterator result is not an object");
413
- context.delegate = null;
414
- return ContinueSentinel;
415
- }
416
-
417
- if (info.done) {
418
- // Assign the result of the finished delegate to the temporary
419
- // variable specified by delegate.resultName (see delegateYield).
420
- context[delegate.resultName] = info.value;
421
-
422
- // Resume execution at the desired location (see delegateYield).
423
- context.next = delegate.nextLoc;
424
-
425
- // If context.method was "throw" but the delegate handled the
426
- // exception, let the outer generator proceed normally. If
427
- // context.method was "next", forget context.arg since it has been
428
- // "consumed" by the delegate iterator. If context.method was
429
- // "return", allow the original .return call to continue in the
430
- // outer generator.
431
- if (context.method !== "return") {
432
- context.method = "next";
433
- context.arg = undefined$1;
434
- }
435
-
436
- } else {
437
- // Re-yield the result returned by the delegate method.
438
- return info;
439
- }
440
-
441
- // The delegate iterator is finished, so forget it and continue with
442
- // the outer generator.
443
- context.delegate = null;
444
- return ContinueSentinel;
445
- }
446
-
447
- // Define Generator.prototype.{next,throw,return} in terms of the
448
- // unified ._invoke helper method.
449
- defineIteratorMethods(Gp);
450
-
451
- define(Gp, toStringTagSymbol, "Generator");
452
-
453
- // A Generator should always return itself as the iterator object when the
454
- // @@iterator function is called on it. Some browsers' implementations of the
455
- // iterator prototype chain incorrectly implement this, causing the Generator
456
- // object to not be returned from this call. This ensures that doesn't happen.
457
- // See https://github.com/facebook/regenerator/issues/274 for more details.
458
- define(Gp, iteratorSymbol, function() {
459
- return this;
460
- });
461
-
462
- define(Gp, "toString", function() {
463
- return "[object Generator]";
464
- });
465
-
466
- function pushTryEntry(locs) {
467
- var entry = { tryLoc: locs[0] };
468
-
469
- if (1 in locs) {
470
- entry.catchLoc = locs[1];
471
- }
472
-
473
- if (2 in locs) {
474
- entry.finallyLoc = locs[2];
475
- entry.afterLoc = locs[3];
476
- }
477
-
478
- this.tryEntries.push(entry);
479
- }
480
-
481
- function resetTryEntry(entry) {
482
- var record = entry.completion || {};
483
- record.type = "normal";
484
- delete record.arg;
485
- entry.completion = record;
486
- }
487
-
488
- function Context(tryLocsList) {
489
- // The root entry object (effectively a try statement without a catch
490
- // or a finally block) gives us a place to store values thrown from
491
- // locations where there is no enclosing try statement.
492
- this.tryEntries = [{ tryLoc: "root" }];
493
- tryLocsList.forEach(pushTryEntry, this);
494
- this.reset(true);
495
- }
496
-
497
- exports.keys = function(object) {
498
- var keys = [];
499
- for (var key in object) {
500
- keys.push(key);
501
- }
502
- keys.reverse();
503
-
504
- // Rather than returning an object with a next method, we keep
505
- // things simple and return the next function itself.
506
- return function next() {
507
- while (keys.length) {
508
- var key = keys.pop();
509
- if (key in object) {
510
- next.value = key;
511
- next.done = false;
512
- return next;
513
- }
514
- }
515
-
516
- // To avoid creating an additional object, we just hang the .value
517
- // and .done properties off the next function object itself. This
518
- // also ensures that the minifier will not anonymize the function.
519
- next.done = true;
520
- return next;
521
- };
522
- };
523
-
524
- function values(iterable) {
525
- if (iterable) {
526
- var iteratorMethod = iterable[iteratorSymbol];
527
- if (iteratorMethod) {
528
- return iteratorMethod.call(iterable);
529
- }
530
-
531
- if (typeof iterable.next === "function") {
532
- return iterable;
533
- }
534
-
535
- if (!isNaN(iterable.length)) {
536
- var i = -1, next = function next() {
537
- while (++i < iterable.length) {
538
- if (hasOwn.call(iterable, i)) {
539
- next.value = iterable[i];
540
- next.done = false;
541
- return next;
542
- }
543
- }
544
-
545
- next.value = undefined$1;
546
- next.done = true;
547
-
548
- return next;
549
- };
550
-
551
- return next.next = next;
552
- }
553
- }
554
-
555
- // Return an iterator with no values.
556
- return { next: doneResult };
557
- }
558
- exports.values = values;
559
-
560
- function doneResult() {
561
- return { value: undefined$1, done: true };
562
- }
563
-
564
- Context.prototype = {
565
- constructor: Context,
566
-
567
- reset: function(skipTempReset) {
568
- this.prev = 0;
569
- this.next = 0;
570
- // Resetting context._sent for legacy support of Babel's
571
- // function.sent implementation.
572
- this.sent = this._sent = undefined$1;
573
- this.done = false;
574
- this.delegate = null;
575
-
576
- this.method = "next";
577
- this.arg = undefined$1;
578
-
579
- this.tryEntries.forEach(resetTryEntry);
580
-
581
- if (!skipTempReset) {
582
- for (var name in this) {
583
- // Not sure about the optimal order of these conditions:
584
- if (name.charAt(0) === "t" &&
585
- hasOwn.call(this, name) &&
586
- !isNaN(+name.slice(1))) {
587
- this[name] = undefined$1;
588
- }
589
- }
590
- }
591
- },
592
-
593
- stop: function() {
594
- this.done = true;
595
-
596
- var rootEntry = this.tryEntries[0];
597
- var rootRecord = rootEntry.completion;
598
- if (rootRecord.type === "throw") {
599
- throw rootRecord.arg;
600
- }
601
-
602
- return this.rval;
603
- },
604
-
605
- dispatchException: function(exception) {
606
- if (this.done) {
607
- throw exception;
608
- }
609
-
610
- var context = this;
611
- function handle(loc, caught) {
612
- record.type = "throw";
613
- record.arg = exception;
614
- context.next = loc;
615
-
616
- if (caught) {
617
- // If the dispatched exception was caught by a catch block,
618
- // then let that catch block handle the exception normally.
619
- context.method = "next";
620
- context.arg = undefined$1;
621
- }
622
-
623
- return !! caught;
624
- }
625
-
626
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
627
- var entry = this.tryEntries[i];
628
- var record = entry.completion;
629
-
630
- if (entry.tryLoc === "root") {
631
- // Exception thrown outside of any try block that could handle
632
- // it, so set the completion value of the entire function to
633
- // throw the exception.
634
- return handle("end");
635
- }
636
-
637
- if (entry.tryLoc <= this.prev) {
638
- var hasCatch = hasOwn.call(entry, "catchLoc");
639
- var hasFinally = hasOwn.call(entry, "finallyLoc");
640
-
641
- if (hasCatch && hasFinally) {
642
- if (this.prev < entry.catchLoc) {
643
- return handle(entry.catchLoc, true);
644
- } else if (this.prev < entry.finallyLoc) {
645
- return handle(entry.finallyLoc);
646
- }
647
-
648
- } else if (hasCatch) {
649
- if (this.prev < entry.catchLoc) {
650
- return handle(entry.catchLoc, true);
651
- }
652
-
653
- } else if (hasFinally) {
654
- if (this.prev < entry.finallyLoc) {
655
- return handle(entry.finallyLoc);
656
- }
657
-
658
- } else {
659
- throw new Error("try statement without catch or finally");
660
- }
661
- }
662
- }
663
- },
664
-
665
- abrupt: function(type, arg) {
666
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
667
- var entry = this.tryEntries[i];
668
- if (entry.tryLoc <= this.prev &&
669
- hasOwn.call(entry, "finallyLoc") &&
670
- this.prev < entry.finallyLoc) {
671
- var finallyEntry = entry;
672
- break;
673
- }
674
- }
675
-
676
- if (finallyEntry &&
677
- (type === "break" ||
678
- type === "continue") &&
679
- finallyEntry.tryLoc <= arg &&
680
- arg <= finallyEntry.finallyLoc) {
681
- // Ignore the finally entry if control is not jumping to a
682
- // location outside the try/catch block.
683
- finallyEntry = null;
684
- }
685
-
686
- var record = finallyEntry ? finallyEntry.completion : {};
687
- record.type = type;
688
- record.arg = arg;
689
-
690
- if (finallyEntry) {
691
- this.method = "next";
692
- this.next = finallyEntry.finallyLoc;
693
- return ContinueSentinel;
694
- }
695
-
696
- return this.complete(record);
697
- },
698
-
699
- complete: function(record, afterLoc) {
700
- if (record.type === "throw") {
701
- throw record.arg;
702
- }
703
-
704
- if (record.type === "break" ||
705
- record.type === "continue") {
706
- this.next = record.arg;
707
- } else if (record.type === "return") {
708
- this.rval = this.arg = record.arg;
709
- this.method = "return";
710
- this.next = "end";
711
- } else if (record.type === "normal" && afterLoc) {
712
- this.next = afterLoc;
713
- }
714
-
715
- return ContinueSentinel;
716
- },
717
-
718
- finish: function(finallyLoc) {
719
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
720
- var entry = this.tryEntries[i];
721
- if (entry.finallyLoc === finallyLoc) {
722
- this.complete(entry.completion, entry.afterLoc);
723
- resetTryEntry(entry);
724
- return ContinueSentinel;
725
- }
726
- }
727
- },
728
-
729
- "catch": function(tryLoc) {
730
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
731
- var entry = this.tryEntries[i];
732
- if (entry.tryLoc === tryLoc) {
733
- var record = entry.completion;
734
- if (record.type === "throw") {
735
- var thrown = record.arg;
736
- resetTryEntry(entry);
737
- }
738
- return thrown;
739
- }
740
- }
741
-
742
- // The context.catch method must only be called with a location
743
- // argument that corresponds to a known catch block.
744
- throw new Error("illegal catch attempt");
745
- },
746
-
747
- delegateYield: function(iterable, resultName, nextLoc) {
748
- this.delegate = {
749
- iterator: values(iterable),
750
- resultName: resultName,
751
- nextLoc: nextLoc
752
- };
170
+ A {@link RouterStrategy} that manages a history stack using inline pound symbols `#`.
171
+ URLs will have a starting point `/#/`, as a default base.
172
+
173
+ For example, if you [pushState("mylink")]{@link pushState}, the url
174
+ `/#/mylink` will be produced.
175
+ */
176
+ class HashStrategy extends RouterStrategy {
177
+ constructor(router) {
178
+ super(router);
179
+ this.$base = '#';
180
+ this.$stack = [];
181
+ this.$position = -1;
182
+ this.$lastFiredLocation = null;
183
+ window.addEventListener('popstate', (ev) => {
184
+ let location = this.getLocation();
185
+ if (this.$lastFiredLocation !== location) {
186
+ this._fireURLChange(location);
187
+ }
188
+ });
189
+ window.addEventListener('hashchange', (e) => {
190
+ let location = this.getLocation();
191
+ if (this.$lastFiredLocation !== location) {
192
+ this._fireURLChange(location);
193
+ }
194
+ });
195
+ this.$init();
196
+ }
197
+ $init() {
198
+ this.pushState(this.getLocation());
199
+ }
200
+ getLocation() {
201
+ return window.location.hash.replace('#', '');
202
+ }
203
+ getLocationAt(position) {
204
+ return this.$stack[this.$position + position];
205
+ }
206
+ getHistoryLength() {
207
+ return this.$stack.length;
208
+ }
209
+ getScrollRestoration() {
210
+ return window.history.scrollRestoration;
211
+ }
212
+ canGo(to) {
213
+ return this.$stack[this.$position + to] !== undefined;
214
+ }
215
+ peek(to) {
216
+ return this.$stack[this.$position + to];
217
+ }
218
+ go(to) {
219
+ if (!this.canGo(to)) {
220
+ return;
221
+ }
222
+ this.$position += to;
223
+ let url = this.$stack[this.$position];
224
+ this.$navigate(url);
225
+ }
226
+ pushState(url, state) {
227
+ if (url === this.getLocation()) {
228
+ //We are already here, so do nothing.
229
+ return;
230
+ }
231
+ if (this.$stack.length === 0) {
232
+ this.$stack[++this.$position] = this.getLocation();
233
+ }
234
+ this.$stack[++this.$position] = url;
235
+ //clear everything after position.
236
+ this.$stack = this.$stack.slice(0, this.$position + 1);
237
+ this.$navigate(url);
238
+ }
239
+ replaceState(url, state) {
240
+ if (url === this.getLocation()) {
241
+ //We are already here, so do nothing.
242
+ return;
243
+ }
244
+ if (this.$position === -1) {
245
+ this.pushState(url, state);
246
+ }
247
+ else {
248
+ this.$stack[this.$position] = url;
249
+ this.$navigate(url);
250
+ }
251
+ }
252
+ clear() {
253
+ this.$stack = [];
254
+ this.$position = -1;
255
+ }
256
+ $navigate(url) {
257
+ window.location.hash = this.$base + url;
258
+ this._fireURLChange(this.getLocation());
259
+ }
260
+ _fireURLChange(url) {
261
+ this.$lastFiredLocation = url;
262
+ super._fireURLChange(url);
263
+ }
264
+ }
753
265
 
754
- if (this.method === "next") {
755
- // Deliberately forget the last sent value so that we don't
756
- // accidentally pass it on to the delegate.
757
- this.arg = undefined$1;
758
- }
266
+ /**
267
+ Alias for {@link HashStrategy}
268
+ */
269
+ // eslint-disable-next-line @typescript-eslint/naming-convention
270
+ let DefaultStrategy = HashStrategy;
759
271
 
760
- return ContinueSentinel;
761
- }
762
- };
272
+ /**
273
+ * Parses the URL for router paths and url-based variables.
274
+ */
275
+ class URLParser {
276
+ /**
277
+ *
278
+ * @param {string} pattern The URL pattern
279
+ * @param {boolean} allowPartialMatch If true, the pattern will match again urls that contains the pattern,
280
+ * even if it isn't an exact match.
281
+ * Defaults to false.
282
+ */
283
+ constructor(pattern, allowPartialMatch = false) {
284
+ this.$allowPartialMatch = allowPartialMatch;
285
+ this.$pattern = this.$stripURL(pattern);
286
+ }
287
+ /**
288
+ * Parses the URL and returns the url parameters.
289
+ * Returns null the url does not match the pattern
290
+ *
291
+ * @param {string} url The url to test
292
+ */
293
+ parse(url) {
294
+ url = this.$stripURL(url);
295
+ let parts = this.$getParts(url);
296
+ let patternParts = this.$getParts(this.$pattern);
297
+ if ((!this.$allowPartialMatch && parts.length !== patternParts.length) || url === '') {
298
+ return null;
299
+ }
300
+ let params = {};
301
+ for (let i = 0; i < patternParts.length; i++) {
302
+ let pPart = patternParts[i];
303
+ let uPart = parts[i];
304
+ if (uPart) {
305
+ if (pPart.charAt(0) === ':') {
306
+ params[pPart.slice(1)] = uPart;
307
+ }
308
+ else {
309
+ if (pPart !== uPart) {
310
+ return null;
311
+ }
312
+ }
313
+ }
314
+ else {
315
+ break;
316
+ }
317
+ }
318
+ return params;
319
+ }
320
+ /**
321
+ * Strips the url for parsing, removing leading and trailing forward slashes.
322
+ *
323
+ * @private
324
+ * @param {string} url URL to strip
325
+ */
326
+ $stripURL(url) {
327
+ while (url.charAt(0) === '/') {
328
+ url = url.slice(1);
329
+ }
330
+ while (url.charAt(url.length - 1) === '/') {
331
+ url = url.slice(0, url.length - 1);
332
+ }
333
+ return url;
334
+ }
335
+ /**
336
+ * Splits the url into an array of URL parts, separated by the forward slash
337
+ *
338
+ * @private
339
+ * @param {string} url URL to split
340
+ */
341
+ $getParts(url) {
342
+ url = this.$stripURL(url);
343
+ return url.split('/');
344
+ }
345
+ }
763
346
 
764
- // Regardless of whether this script is executing as a CommonJS module
765
- // or not, return the runtime object so that we can declare the variable
766
- // regeneratorRuntime in the outer scope, which allows this module to be
767
- // injected easily by `bin/regenerator --include-runtime script.js`.
768
- return exports;
347
+ /**
348
+ * This class is reponsible for determing which route to render
349
+ * based on the URL and the route url patterns.
350
+ */
351
+ class RouteMatcher {
352
+ constructor(routerStrategy) {
353
+ this.$strategy = routerStrategy;
354
+ }
355
+ $defaultNoRouteFunction(indexRoute, routes) {
356
+ return indexRoute;
357
+ }
358
+ /**
359
+ * Matches the url to the appropriate renderable route
360
+ *
361
+ * @param url
362
+ * @param children
363
+ * @param base
364
+ * @param indexRoute
365
+ * @param onNoRoute
366
+ */
367
+ match(url, children, base, indexRoute, onNoRoute) {
368
+ let componentToRender = null;
369
+ let params = null;
370
+ for (let i = 0; i < children.length; i++) {
371
+ let route = children[i];
372
+ let shouldAllowPartialMatching = !!route.props.children;
373
+ let parser = new URLParser(base + route.props.url, shouldAllowPartialMatching);
374
+ params = parser.parse(url);
375
+ if (params) {
376
+ componentToRender = route;
377
+ break;
378
+ }
379
+ }
380
+ if (!componentToRender) {
381
+ componentToRender = (onNoRoute ? onNoRoute : this.$defaultNoRouteFunction)(indexRoute, children);
382
+ }
383
+ if (!componentToRender) {
384
+ if (!base) {
385
+ console.warn('No routes matched, and no index route available.');
386
+ }
387
+ return null;
388
+ }
389
+ let props = {
390
+ url: url,
391
+ base: base + componentToRender.props.url,
392
+ matcher: this,
393
+ component: componentToRender.props.component,
394
+ entryTransition: componentToRender.props.entryTransition,
395
+ exitTransition: componentToRender.props.exitTransition,
396
+ componentProps: {
397
+ url: url,
398
+ router: this.$strategy
399
+ }
400
+ };
401
+ if (params) {
402
+ for (let i in params) {
403
+ props.componentProps[i] = params[i];
404
+ }
405
+ }
406
+ return React.cloneElement(componentToRender, props);
407
+ }
408
+ }
769
409
 
770
- }(
771
- // If this script is executing as a CommonJS module, use module.exports
772
- // as the regeneratorRuntime namespace. Otherwise create a new empty
773
- // object. Either way, the resulting object will be used to initialize
774
- // the regeneratorRuntime variable at the top of this file.
775
- module.exports
776
- ));
410
+ class Router extends React__namespace.Component {
411
+ constructor(props) {
412
+ super(props);
413
+ // eslint-disable-next-line @typescript-eslint/naming-convention
414
+ let Strategy;
415
+ if (!props.strategy) {
416
+ Strategy = DefaultStrategy;
417
+ }
418
+ else {
419
+ Strategy = props.strategy;
420
+ }
421
+ let strategy = new Strategy(this);
422
+ this.state = {
423
+ strategy: strategy,
424
+ url: strategy.getLocation(),
425
+ shouldTransition: false
426
+ };
427
+ this.$lastRenderedRoute = null;
428
+ this.$onURLChange = this.$onURLChange.bind(this);
429
+ this.$matcher = new RouteMatcher(strategy);
430
+ }
431
+ static getInstance() {
432
+ if (!Router.$instance) {
433
+ return null;
434
+ }
435
+ return Router.$instance.getRouterStrategy();
436
+ }
437
+ /**
438
+ * Gets the current routing strategy
439
+ */
440
+ getRouterStrategy() {
441
+ return this.state.strategy;
442
+ }
443
+ /**
444
+ * @ignore
445
+ */
446
+ $onURLChange(url) {
447
+ if (url !== this.state.url) {
448
+ this.setState({
449
+ url: url,
450
+ shouldTransition: true
451
+ });
452
+ }
453
+ }
454
+ componentDidMount() {
455
+ Router.$instance = this;
456
+ this.state.strategy.addURLChangeCallback(this.$onURLChange);
457
+ }
458
+ /**
459
+ * @ignore
460
+ */
461
+ UNSAFE_componentWillReceiveProps(nextProps) {
462
+ if (nextProps.strategy && (this.state.strategy instanceof nextProps.strategy)) {
463
+ this.state.strategy.removeURLChangeCallback(this.$onURLChange);
464
+ let strat = new nextProps.strategy(this);
465
+ strat.addURLChangeCallback(this.$onURLChange);
466
+ this.setState({
467
+ strategy: strat
468
+ });
469
+ }
470
+ }
471
+ /**
472
+ * @ignore
473
+ */
474
+ componentWillUnmount() {
475
+ Router.$instance = null;
476
+ this.state.strategy.removeURLChangeCallback(this.$onURLChange);
477
+ }
478
+ /**
479
+ * @ignore
480
+ */
481
+ render() {
482
+ let currentRoute = this.$matcher.match(this.state.url || '/', this.$getChildren(), '', this.$getIndexRoute(), this.props.onNoRoute);
483
+ // eslint-disable-next-line @typescript-eslint/naming-convention
484
+ let Root = null;
485
+ if (this.props.component) {
486
+ Root = this.props.component;
487
+ }
488
+ if (this.state.shouldTransition && (currentRoute.props.entryTransition || (this.$lastRenderedRoute &&
489
+ this.$lastRenderedRoute.props.exitTransition))) {
490
+ this.$awaitingTransition = true;
491
+ let exiting = null;
492
+ if (this.$lastRenderedRoute) {
493
+ exiting = React__namespace.cloneElement(this.$lastRenderedRoute, {
494
+ ref: (route) => {
495
+ this.$exitingRoute = route;
496
+ }
497
+ });
498
+ }
499
+ // Incoming will always be safe to render, hence no defensive checks
500
+ let incoming = React__namespace.cloneElement(currentRoute, {
501
+ ref: (route) => {
502
+ this.$incomingRoute = route;
503
+ }
504
+ });
505
+ if (Root) {
506
+ return React__namespace.createElement(Root, { router: this.getRouterStrategy(), url: this.state.url }, [exiting, incoming]);
507
+ }
508
+ else {
509
+ return [exiting, incoming];
510
+ }
511
+ }
512
+ else {
513
+ this.$lastRenderedRoute = currentRoute;
514
+ if (Root) {
515
+ // currentRoute must be rendered as an array; because, exiting and incoming is rendered as an array.
516
+ // if currentRoute is not rendered as an array, a bug happens where the exiting screen is reloaded
517
+ // calling the constructor again.
518
+ return React__namespace.createElement(Root, { router: this.getRouterStrategy(), url: this.state.url }, [currentRoute]);
519
+ }
520
+ else {
521
+ return currentRoute;
522
+ }
523
+ }
524
+ }
525
+ /**
526
+ * @ignore
527
+ */
528
+ componentDidUpdate() {
529
+ if (this.$awaitingTransition) {
530
+ this.$awaitingTransition = false;
531
+ let exitTransitionPromise = null;
532
+ if (this.$exitingRoute && this.$exitingRoute.props.exitTransition) {
533
+ exitTransitionPromise = this.$exitingRoute.props.exitTransition.execute(this.$incomingRoute.getView(), this.$exitingRoute.getView());
534
+ }
535
+ else {
536
+ exitTransitionPromise = Promise.resolve();
537
+ }
538
+ exitTransitionPromise.then(() => {
539
+ let entryTransitionPromise = null;
540
+ if (this.$incomingRoute.props.entryTransition) {
541
+ entryTransitionPromise = this.$incomingRoute.props.entryTransition.execute(this.$incomingRoute.getView(), this.$exitingRoute.getView());
542
+ }
543
+ else {
544
+ entryTransitionPromise = Promise.resolve();
545
+ }
546
+ return entryTransitionPromise;
547
+ }).catch((error) => {
548
+ console.error(error);
549
+ }).then(() => {
550
+ this.$incomingRoute = null;
551
+ this.$exitingRoute = null;
552
+ this.setState({ shouldTransition: false });
553
+ });
554
+ }
555
+ }
556
+ /**
557
+ * Gets the number of history entries. Note this does not count the browser history.
558
+ * Only the history kept track during the life-cycle of the app.
559
+ */
560
+ getHistoryLength() {
561
+ return this.state.strategy.getHistoryLength();
562
+ }
563
+ /**
564
+ * Gets the scroll restoration mode
565
+ */
566
+ getScrollRestoration() {
567
+ return this.state.strategy.getScrollRestoration();
568
+ }
569
+ /**
570
+ *
571
+ * @param to An integer, positive means go forward, negative means go backwards. E.g:
572
+ * `1` move forward one step
573
+ * `-1` move backward one step
574
+ * `0` navigate to the current page (This is essentially a no-op)
575
+ */
576
+ go(to) {
577
+ this.state.strategy.go(to);
578
+ }
579
+ /**
580
+ * Go back one step. This is an alias for [pushState(-1)]{@link go}.
581
+ */
582
+ back() {
583
+ this.state.strategy.go(-1);
584
+ }
585
+ /**
586
+ * Go forward one step. This is an alias for [pushState(1)]{@link go}.
587
+ */
588
+ forward() {
589
+ this.state.strategy.go(1);
590
+ }
591
+ /**
592
+ * Gets the potential routes
593
+ */
594
+ $getChildren() {
595
+ let children = null;
596
+ if (this.props.children instanceof Array) {
597
+ children = this.props.children;
598
+ }
599
+ else {
600
+ children = [this.props.children];
601
+ }
602
+ return children;
603
+ }
604
+ /**
605
+ * Finds the index route. Returns null if there are no indexed routes.
606
+ */
607
+ $getIndexRoute() {
608
+ let children = this.$getChildren();
609
+ for (let i = 0; i < children.length; i++) {
610
+ let child = children[i];
611
+ if (child.props.index) {
612
+ return child;
613
+ }
614
+ }
615
+ return null;
616
+ }
617
+ }
618
+ /**
619
+ * @deprecated Use Router.getInstance() instead.
620
+ * @returns {RouterStrategy}
621
+ */
622
+ let getRouter = () => {
623
+ console.warn('getRouter() is deprecated. use Router.getInstance() instead.');
624
+ return Router.getInstance();
625
+ };
777
626
 
778
- try {
779
- regeneratorRuntime = runtime;
780
- } catch (accidentalStrictMode) {
781
- // This module should not be running in strict mode, so the above
782
- // assignment should always work unless something is misconfigured. Just
783
- // in case runtime.js accidentally runs in strict mode, in modern engines
784
- // we can explicitly access globalThis. In older engines we can escape
785
- // strict mode using a global Function call. This could conceivably fail
786
- // if a Content Security Policy forbids using Function, but in that case
787
- // the proper solution is to fix the accidental strict mode problem. If
788
- // you've misconfigured your bundler to force strict mode and applied a
789
- // CSP to forbid Function, and you're not willing to fix either of those
790
- // problems, please detail your unique predicament in a GitHub issue.
791
- if (typeof globalThis === "object") {
792
- globalThis.regeneratorRuntime = runtime;
793
- } else {
794
- Function("r", "regeneratorRuntime = r")(runtime);
795
- }
796
- }
797
- } (runtime));
627
+ /**
628
+ * @notice Using the URLStrategy requires some backend configuration
629
+ * to route URLs back to application.
630
+ *
631
+ * To make this easier, by default these URLs are prefixed with
632
+ * `/r/` to easily differentiate between URLs that needs to be re-routed back
633
+ * to the application vs other resources such as images.
634
+ */
635
+ class URLStrategy extends RouterStrategy {
636
+ /**
637
+ *
638
+ * @param {Router} router
639
+ */
640
+ constructor(router) {
641
+ super(router);
642
+ this.$base = window.location.origin + '/r';
643
+ this.$stack = [];
644
+ this.$position = -1;
645
+ window.addEventListener('popstate', () => {
646
+ this._fireURLChange(this.getLocation());
647
+ });
648
+ this.$init();
649
+ }
650
+ $init() {
651
+ this.pushState(this.getLocation());
652
+ }
653
+ getLocation() {
654
+ return window.location.pathname.replace('/r', '');
655
+ }
656
+ getLocationAt(position) {
657
+ return this.$stack[this.$position + position];
658
+ }
659
+ getHistoryLength() {
660
+ return window.history.length;
661
+ }
662
+ getScrollRestoration() {
663
+ return window.history.scrollRestoration;
664
+ }
665
+ peek(to) {
666
+ return this.$stack[this.$position + to];
667
+ }
668
+ canGo(to) {
669
+ return this.$stack[this.$position + to] !== undefined;
670
+ }
671
+ go(to) {
672
+ if (!this.canGo(to)) {
673
+ return;
674
+ }
675
+ this.$position += to;
676
+ this.$navigate(this.$stack[this.$position]);
677
+ }
678
+ pushState(url, state) {
679
+ if (state) {
680
+ console.warn('Warning: The state parameter is not implemented yet.');
681
+ }
682
+ if (url === this.getLocation()) {
683
+ //We are already here, so do nothing.
684
+ return;
685
+ }
686
+ this.$stack[++this.$position] = url;
687
+ //clear everything after position.
688
+ this.$stack = this.$stack.slice(0, this.$position + 1);
689
+ this.$navigate(url);
690
+ }
691
+ replaceState(url, state) {
692
+ if (state) {
693
+ console.warn('Warning: The state parameter is not implemented yet.');
694
+ }
695
+ if (url === this.getLocation()) {
696
+ //We are already here, so do nothing.
697
+ return;
698
+ }
699
+ if (this.$position === -1) {
700
+ this.pushState(url, state);
701
+ }
702
+ else {
703
+ this.$stack[this.$position] = url;
704
+ this.$navigate(url);
705
+ }
706
+ }
707
+ clear() {
708
+ this.$stack = [];
709
+ this.$position = -1;
710
+ }
711
+ $navigate(url, replace = false) {
712
+ if (replace) {
713
+ window.history.replaceState({}, null, this.$base + url);
714
+ }
715
+ else {
716
+ window.history.pushState({}, null, this.$base + url);
717
+ }
718
+ this._fireURLChange(this.getLocation());
719
+ }
720
+ }
798
721
 
799
722
  /******************************************************************************
800
723
  Copyright (c) Microsoft Corporation.
@@ -810,33 +733,8 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
810
733
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
811
734
  PERFORMANCE OF THIS SOFTWARE.
812
735
  ***************************************************************************** */
813
- /* global Reflect, Promise */
736
+ /* global Reflect, Promise, SuppressedError, Symbol */
814
737
 
815
- var extendStatics = function(d, b) {
816
- extendStatics = Object.setPrototypeOf ||
817
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
818
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
819
- return extendStatics(d, b);
820
- };
821
-
822
- function __extends(d, b) {
823
- if (typeof b !== "function" && b !== null)
824
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
825
- extendStatics(d, b);
826
- function __() { this.constructor = d; }
827
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
828
- }
829
-
830
- var __assign = function() {
831
- __assign = Object.assign || function __assign(t) {
832
- for (var s, i = 1, n = arguments.length; i < n; i++) {
833
- s = arguments[i];
834
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
835
- }
836
- return t;
837
- };
838
- return __assign.apply(this, arguments);
839
- };
840
738
 
841
739
  function __awaiter(thisArg, _arguments, P, generator) {
842
740
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
@@ -848,983 +746,278 @@ function __awaiter(thisArg, _arguments, P, generator) {
848
746
  });
849
747
  }
850
748
 
851
- function __generator(thisArg, body) {
852
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
853
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
854
- function verb(n) { return function (v) { return step([n, v]); }; }
855
- function step(op) {
856
- if (f) throw new TypeError("Generator is already executing.");
857
- while (_) try {
858
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
859
- if (y = 0, t) op = [op[0] & 2, t.value];
860
- switch (op[0]) {
861
- case 0: case 1: t = op; break;
862
- case 4: _.label++; return { value: op[1], done: false };
863
- case 5: _.label++; y = op[1]; op = [0]; continue;
864
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
865
- default:
866
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
867
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
868
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
869
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
870
- if (t[2]) _.ops.pop();
871
- _.trys.pop(); continue;
872
- }
873
- op = body.call(thisArg, _);
874
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
875
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
876
- }
877
- }
878
-
879
- var EVENT_URL_CHANGE = 'urlchange';
880
- var RouterStrategy = /** @class */ (function (_super) {
881
- __extends(RouterStrategy, _super);
882
- function RouterStrategy(router) {
883
- var _this = _super.call(this) || this;
884
- _this.$router = router;
885
- return _this;
886
- }
887
- /**
888
- * Gets the router
889
- */
890
- RouterStrategy.prototype.getRouter = function () {
891
- return this.$router;
892
- };
893
- /**
894
- * Sets the browser title
895
- *
896
- * @param {string} title
897
- */
898
- RouterStrategy.prototype.setTitle = function (title) {
899
- var head = document.head.getElementsByTagName('title')[0];
900
- if (!head) {
901
- head = document.createElement('title');
902
- document.head.appendChild(head);
903
- }
904
- if (!title) {
905
- title = '';
906
- }
907
- head.innerText = title.toString();
908
- };
909
- /**
910
- * Listen for URL change events
911
- *
912
- * @param callback
913
- */
914
- RouterStrategy.prototype.addURLChangeCallback = function (callback) {
915
- this.on(EVENT_URL_CHANGE, callback);
916
- };
917
- /**
918
- * Removes an existing listener
919
- *
920
- * @param callback
921
- */
922
- RouterStrategy.prototype.removeURLChangeCallback = function (callback) {
923
- this.off(EVENT_URL_CHANGE, callback);
924
- };
925
- /**
926
- * navigate the history forward one entry. This is an alias for [go(1)]{@link go}
927
- */
928
- RouterStrategy.prototype.forward = function () {
929
- this.go(1);
930
- };
931
- /**
932
- * Navigate the history back one entry. This is an alias for [go(-1)]{@link go}
933
- */
934
- RouterStrategy.prototype.back = function () {
935
- this.go(-1);
936
- };
937
- /**
938
- * Returns true if can go back 1 entry.
939
- * This is the same as calling [canGo(-1)]{@link canGo}
940
- */
941
- RouterStrategy.prototype.canBack = function () {
942
- return this.canGo(-1);
943
- };
944
- /**
945
- * Returns true if can go forward 1 entry.
946
- * This is the same as calling [canGo(1)]{@link canGo}
947
- */
948
- RouterStrategy.prototype.canForward = function () {
949
- return this.canGo(1);
950
- };
951
- /**
952
- * Returns the URL one entry forward.
953
- * This is the same as calling [peek(1)]{@link peek}
954
- */
955
- RouterStrategy.prototype.peekForward = function () {
956
- return this.peek(1);
957
- };
958
- /**
959
- * Returns the URL one entry back.
960
- * This is the same as calling [peek(-1)]{@link peek}
961
- */
962
- RouterStrategy.prototype.peekBack = function () {
963
- return this.peek(-1);
964
- };
965
- /**
966
- * Fires the {@link EVENT_URL_CHANGE} event
967
- * @param url
968
- */
969
- RouterStrategy.prototype._fireURLChange = function (url) {
970
- this.emit(EVENT_URL_CHANGE, url);
971
- };
972
- return RouterStrategy;
973
- }(events.EventEmitter));
974
-
975
- /**
976
- A {@link RouterStrategy} that manages a history stack using inline pound symbols `#`.
977
- URLs will have a starting point `/#/`, as a default base.
978
-
979
- For example, if you [pushState("mylink")]{@link pushState}, the url
980
- `/#/mylink` will be produced.
981
- */
982
- var HashStrategy = /** @class */ (function (_super) {
983
- __extends(HashStrategy, _super);
984
- function HashStrategy(router) {
985
- var _this = _super.call(this, router) || this;
986
- _this.$base = '#';
987
- _this.$stack = [];
988
- _this.$position = -1;
989
- _this.$lastFiredLocation = null; //this.getLocation();
990
- window.addEventListener('popstate', function (ev) {
991
- var location = _this.getLocation();
992
- if (_this.$lastFiredLocation !== location) {
993
- _this._fireURLChange(location);
994
- }
995
- });
996
- window.addEventListener('hashchange', function (e) {
997
- var location = _this.getLocation();
998
- if (_this.$lastFiredLocation !== location) {
999
- _this._fireURLChange(location);
1000
- }
1001
- });
1002
- _this.$init();
1003
- return _this;
1004
- }
1005
- HashStrategy.prototype.$init = function () {
1006
- this.pushState(this.getLocation());
1007
- };
1008
- HashStrategy.prototype.getLocation = function () {
1009
- return window.location.hash.replace('#', '');
1010
- };
1011
- HashStrategy.prototype.getLocationAt = function (position) {
1012
- return this.$stack[this.$position + position];
1013
- };
1014
- HashStrategy.prototype.getHistoryLength = function () {
1015
- return this.$stack.length;
1016
- };
1017
- HashStrategy.prototype.getScrollRestoration = function () {
1018
- return window.history.scrollRestoration;
1019
- };
1020
- HashStrategy.prototype.canGo = function (to) {
1021
- return this.$stack[this.$position + to] !== undefined;
1022
- };
1023
- HashStrategy.prototype.peek = function (to) {
1024
- return this.$stack[this.$position + to];
1025
- };
1026
- HashStrategy.prototype.go = function (to) {
1027
- if (!this.canGo(to)) {
1028
- return;
1029
- }
1030
- this.$position += to;
1031
- var url = this.$stack[this.$position];
1032
- this.$navigate(url);
1033
- };
1034
- HashStrategy.prototype.pushState = function (url, state) {
1035
- if (url === this.getLocation()) {
1036
- //We are already here, so do nothing.
1037
- return;
1038
- }
1039
- if (this.$stack.length === 0) {
1040
- this.$stack[++this.$position] = this.getLocation();
1041
- }
1042
- this.$stack[++this.$position] = url;
1043
- //clear everything after position.
1044
- this.$stack = this.$stack.slice(0, this.$position + 1);
1045
- this.$navigate(url);
1046
- };
1047
- HashStrategy.prototype.replaceState = function (url, state) {
1048
- if (url === this.getLocation()) {
1049
- //We are already here, so do nothing.
1050
- return;
1051
- }
1052
- if (this.$position === -1) {
1053
- this.pushState(url, state);
1054
- }
1055
- else {
1056
- this.$stack[this.$position] = url;
1057
- this.$navigate(url);
1058
- }
1059
- };
1060
- HashStrategy.prototype.clear = function () {
1061
- this.$stack = [];
1062
- this.$position = -1;
1063
- };
1064
- HashStrategy.prototype.$navigate = function (url) {
1065
- window.location.hash = this.$base + url;
1066
- this._fireURLChange(this.getLocation());
1067
- };
1068
- HashStrategy.prototype._fireURLChange = function (url) {
1069
- this.$lastFiredLocation = url;
1070
- _super.prototype._fireURLChange.call(this, url);
1071
- };
1072
- return HashStrategy;
1073
- }(RouterStrategy));
1074
-
1075
- /**
1076
- Alias for {@link HashStrategy}
1077
- */
1078
- // eslint-disable-next-line @typescript-eslint/naming-convention
1079
- var DefaultStrategy = HashStrategy;
1080
-
1081
- /**
1082
- * Parses the URL for router paths and url-based variables.
1083
- */
1084
- var URLParser = /** @class */ (function () {
1085
- /**
1086
- *
1087
- * @param {string} pattern The URL pattern
1088
- * @param {boolean} allowPartialMatch If true, the pattern will match again urls that contains the pattern,
1089
- * even if it isn't an exact match.
1090
- * Defaults to false.
1091
- */
1092
- function URLParser(pattern, allowPartialMatch) {
1093
- if (allowPartialMatch === void 0) { allowPartialMatch = false; }
1094
- this.$allowPartialMatch = allowPartialMatch;
1095
- this.$pattern = this.$stripURL(pattern);
1096
- }
1097
- /**
1098
- * Parses the URL and returns the url parameters.
1099
- * Returns null the url does not match the pattern
1100
- *
1101
- * @param {string} url The url to test
1102
- */
1103
- URLParser.prototype.parse = function (url) {
1104
- url = this.$stripURL(url);
1105
- var parts = this.$getParts(url);
1106
- var patternParts = this.$getParts(this.$pattern);
1107
- if ((!this.$allowPartialMatch && parts.length !== patternParts.length) || url === '') {
1108
- return null;
1109
- }
1110
- var params = {};
1111
- for (var i = 0; i < patternParts.length; i++) {
1112
- var pPart = patternParts[i];
1113
- var uPart = parts[i];
1114
- if (uPart) {
1115
- if (pPart.charAt(0) === ':') {
1116
- params[pPart.slice(1)] = uPart;
1117
- }
1118
- else {
1119
- if (pPart !== uPart) {
1120
- return null;
1121
- }
1122
- }
1123
- }
1124
- else {
1125
- break;
1126
- }
1127
- }
1128
- return params;
1129
- };
1130
- /**
1131
- * Strips the url for parsing, removing leading and trailing forward slashes.
1132
- *
1133
- * @private
1134
- * @param {string} url URL to strip
1135
- */
1136
- URLParser.prototype.$stripURL = function (url) {
1137
- while (url.charAt(0) === '/') {
1138
- url = url.slice(1);
1139
- }
1140
- while (url.charAt(url.length - 1) === '/') {
1141
- url = url.slice(0, url.length - 1);
1142
- }
1143
- return url;
1144
- };
1145
- /**
1146
- * Splits the url into an array of URL parts, separated by the forward slash
1147
- *
1148
- * @private
1149
- * @param {string} url URL to split
1150
- */
1151
- URLParser.prototype.$getParts = function (url) {
1152
- url = this.$stripURL(url);
1153
- return url.split('/');
1154
- };
1155
- return URLParser;
1156
- }());
1157
-
1158
- /**
1159
- * This class is reponsible for determing which route to render
1160
- * based on the URL and the route url patterns.
1161
- */
1162
- var RouteMatcher = /** @class */ (function () {
1163
- function RouteMatcher(routerStrategy) {
1164
- this.$strategy = routerStrategy;
1165
- }
1166
- RouteMatcher.prototype.$defaultNoRouteFunction = function (indexRoute, routes) {
1167
- return indexRoute;
1168
- };
1169
- /**
1170
- * Matches the url to the appropriate renderable route
1171
- *
1172
- * @param url
1173
- * @param children
1174
- * @param base
1175
- * @param indexRoute
1176
- * @param onNoRoute
1177
- */
1178
- RouteMatcher.prototype.match = function (url, children, base, indexRoute, onNoRoute) {
1179
- var componentToRender = null;
1180
- var params = null;
1181
- for (var i = 0; i < children.length; i++) {
1182
- var route = children[i];
1183
- var shouldAllowPartialMatching = !!route.props.children;
1184
- var parser = new URLParser(base + route.props.url, shouldAllowPartialMatching);
1185
- params = parser.parse(url);
1186
- if (params) {
1187
- componentToRender = route;
1188
- break;
1189
- }
1190
- }
1191
- if (!componentToRender) {
1192
- componentToRender = (onNoRoute ? onNoRoute : this.$defaultNoRouteFunction)(indexRoute, children);
1193
- }
1194
- if (!componentToRender) {
1195
- if (!base) {
1196
- console.warn('No routes matched, and no index route available.');
1197
- }
1198
- return null;
1199
- }
1200
- var props = {
1201
- url: url,
1202
- base: base + componentToRender.props.url,
1203
- matcher: this,
1204
- component: componentToRender.props.component,
1205
- entryTransition: componentToRender.props.entryTransition,
1206
- exitTransition: componentToRender.props.exitTransition,
1207
- componentProps: {
1208
- url: url,
1209
- router: this.$strategy
1210
- }
1211
- };
1212
- if (params) {
1213
- for (var i in params) {
1214
- props.componentProps[i] = params[i];
1215
- }
1216
- }
1217
- return React.cloneElement(componentToRender, props);
1218
- };
1219
- return RouteMatcher;
1220
- }());
1221
-
1222
- var Router = /** @class */ (function (_super) {
1223
- __extends(Router, _super);
1224
- function Router(props) {
1225
- var _this = _super.call(this, props) || this;
1226
- // eslint-disable-next-line @typescript-eslint/naming-convention
1227
- var Strategy;
1228
- if (!props.strategy) {
1229
- Strategy = DefaultStrategy;
1230
- }
1231
- else {
1232
- Strategy = props.strategy;
1233
- }
1234
- var strategy = new Strategy(_this);
1235
- _this.state = {
1236
- strategy: strategy,
1237
- url: strategy.getLocation(),
1238
- shouldTransition: false
1239
- };
1240
- _this.$lastRenderedRoute = null;
1241
- _this.$onURLChange = _this.$onURLChange.bind(_this);
1242
- _this.$matcher = new RouteMatcher(strategy);
1243
- return _this;
1244
- }
1245
- Router.getInstance = function () {
1246
- if (!Router.$instance) {
1247
- return null;
1248
- }
1249
- return Router.$instance.getRouterStrategy();
1250
- };
1251
- /**
1252
- * Gets the current routing strategy
1253
- */
1254
- Router.prototype.getRouterStrategy = function () {
1255
- return this.state.strategy;
1256
- };
1257
- /**
1258
- * @ignore
1259
- */
1260
- Router.prototype.$onURLChange = function (url) {
1261
- if (url !== this.state.url) {
1262
- this.setState({
1263
- url: url,
1264
- shouldTransition: true
1265
- });
1266
- }
1267
- };
1268
- Router.prototype.componentDidMount = function () {
1269
- Router.$instance = this;
1270
- this.state.strategy.addURLChangeCallback(this.$onURLChange);
1271
- };
1272
- /**
1273
- * @ignore
1274
- */
1275
- Router.prototype.UNSAFE_componentWillReceiveProps = function (nextProps) {
1276
- if (nextProps.strategy && (this.state.strategy instanceof nextProps.strategy)) {
1277
- this.state.strategy.removeURLChangeCallback(this.$onURLChange);
1278
- var strat = new nextProps.strategy(this);
1279
- strat.addURLChangeCallback(this.$onURLChange);
1280
- this.setState({
1281
- strategy: strat
1282
- });
1283
- }
1284
- };
1285
- /**
1286
- * @ignore
1287
- */
1288
- Router.prototype.componentWillUnmount = function () {
1289
- Router.$instance = null;
1290
- this.state.strategy.removeURLChangeCallback(this.$onURLChange);
1291
- };
1292
- /**
1293
- * @ignore
1294
- */
1295
- Router.prototype.render = function () {
1296
- var _this = this;
1297
- var currentRoute = this.$matcher.match(this.state.url || '/', this.$getChildren(), '', this.$getIndexRoute(), this.props.onNoRoute);
1298
- // eslint-disable-next-line @typescript-eslint/naming-convention
1299
- var Root = null;
1300
- if (this.props.component) {
1301
- Root = this.props.component;
1302
- }
1303
- if (this.state.shouldTransition && (currentRoute.props.entryTransition || (this.$lastRenderedRoute &&
1304
- this.$lastRenderedRoute.props.exitTransition))) {
1305
- this.$awaitingTransition = true;
1306
- var exiting = null;
1307
- if (this.$lastRenderedRoute) {
1308
- exiting = React__namespace.cloneElement(this.$lastRenderedRoute, {
1309
- ref: function (route) {
1310
- _this.$exitingRoute = route;
1311
- }
1312
- });
1313
- }
1314
- // Incoming will always be safe to render, hence no defensive checks
1315
- var incoming = React__namespace.cloneElement(currentRoute, {
1316
- ref: function (route) {
1317
- _this.$incomingRoute = route;
1318
- }
1319
- });
1320
- if (Root) {
1321
- return React__namespace.createElement(Root, { router: this.getRouterStrategy(), url: this.state.url }, [exiting, incoming]);
1322
- }
1323
- else {
1324
- return [exiting, incoming];
1325
- }
1326
- }
1327
- else {
1328
- this.$lastRenderedRoute = currentRoute;
1329
- if (Root) {
1330
- // currentRoute must be rendered as an array; because, exiting and incoming is rendered as an array.
1331
- // if currentRoute is not rendered as an array, a bug happens where the exiting screen is reloaded
1332
- // calling the constructor again.
1333
- return React__namespace.createElement(Root, { router: this.getRouterStrategy(), url: this.state.url }, [currentRoute]);
1334
- }
1335
- else {
1336
- return currentRoute;
1337
- }
1338
- }
1339
- };
1340
- /**
1341
- * @ignore
1342
- */
1343
- Router.prototype.componentDidUpdate = function () {
1344
- var _this = this;
1345
- if (this.$awaitingTransition) {
1346
- this.$awaitingTransition = false;
1347
- var exitTransitionPromise = null;
1348
- if (this.$exitingRoute && this.$exitingRoute.props.exitTransition) {
1349
- exitTransitionPromise = this.$exitingRoute.props.exitTransition.execute(this.$incomingRoute.getView(), this.$exitingRoute.getView());
1350
- }
1351
- else {
1352
- exitTransitionPromise = Promise.resolve();
1353
- }
1354
- exitTransitionPromise.then(function () {
1355
- var entryTransitionPromise = null;
1356
- if (_this.$incomingRoute.props.entryTransition) {
1357
- entryTransitionPromise = _this.$incomingRoute.props.entryTransition.execute(_this.$incomingRoute.getView(), _this.$exitingRoute.getView());
1358
- }
1359
- else {
1360
- entryTransitionPromise = Promise.resolve();
1361
- }
1362
- return entryTransitionPromise;
1363
- })["catch"](function (error) {
1364
- console.error(error);
1365
- }).then(function () {
1366
- _this.$incomingRoute = null;
1367
- _this.$exitingRoute = null;
1368
- _this.setState({ shouldTransition: false });
1369
- });
1370
- }
1371
- };
1372
- /**
1373
- * Gets the number of history entries. Note this does not count the browser history.
1374
- * Only the history kept track during the life-cycle of the app.
1375
- */
1376
- Router.prototype.getHistoryLength = function () {
1377
- return this.state.strategy.getHistoryLength();
1378
- };
1379
- /**
1380
- * Gets the scroll restoration mode
1381
- */
1382
- Router.prototype.getScrollRestoration = function () {
1383
- return this.state.strategy.getScrollRestoration();
1384
- };
1385
- /**
1386
- *
1387
- * @param to An integer, positive means go forward, negative means go backwards. E.g:
1388
- * `1` move forward one step
1389
- * `-1` move backward one step
1390
- * `0` navigate to the current page (This is essentially a no-op)
1391
- */
1392
- Router.prototype.go = function (to) {
1393
- this.state.strategy.go(to);
1394
- };
1395
- /**
1396
- * Go back one step. This is an alias for [pushState(-1)]{@link go}.
1397
- */
1398
- Router.prototype.back = function () {
1399
- this.state.strategy.go(-1);
1400
- };
1401
- /**
1402
- * Go forward one step. This is an alias for [pushState(1)]{@link go}.
1403
- */
1404
- Router.prototype.forward = function () {
1405
- this.state.strategy.go(1);
1406
- };
1407
- /**
1408
- * Gets the potential routes
1409
- */
1410
- Router.prototype.$getChildren = function () {
1411
- var children = null;
1412
- if (this.props.children instanceof Array) {
1413
- children = this.props.children;
1414
- }
1415
- else {
1416
- children = [this.props.children];
1417
- }
1418
- return children;
1419
- };
1420
- /**
1421
- * Finds the index route. Returns null if there are no indexed routes.
1422
- */
1423
- Router.prototype.$getIndexRoute = function () {
1424
- var children = this.$getChildren();
1425
- for (var i = 0; i < children.length; i++) {
1426
- var child = children[i];
1427
- if (child.props.index) {
1428
- return child;
1429
- }
1430
- }
1431
- return null;
1432
- };
1433
- return Router;
1434
- }(React__namespace.Component));
1435
- var getRouter = function () {
1436
- console.warn('getRouter() is deprecated. use Router.getInstance() instead.');
1437
- return Router.getInstance();
749
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
750
+ var e = new Error(message);
751
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
1438
752
  };
1439
753
 
1440
- /**
1441
- * @notice Using the URLStrategy requires some backend configuration
1442
- * to route URLs back to application.
1443
- *
1444
- * To make this easier, by default these URLs are prefixed with
1445
- * `/r/` to easily differentiate between URLs that needs to be re-routed back
1446
- * to the application vs other resources such as images.
1447
- */
1448
- var URLStrategy = /** @class */ (function (_super) {
1449
- __extends(URLStrategy, _super);
1450
- /**
1451
- *
1452
- * @param {Router} router
1453
- */
1454
- function URLStrategy(router) {
1455
- var _this = _super.call(this, router) || this;
1456
- _this.$base = window.location.origin + '/r';
1457
- _this.$stack = [];
1458
- _this.$position = -1;
1459
- window.addEventListener('popstate', function () {
1460
- _this._fireURLChange(_this.getLocation());
1461
- });
1462
- _this.$init();
1463
- return _this;
1464
- }
1465
- URLStrategy.prototype.$init = function () {
1466
- this.pushState(this.getLocation());
1467
- };
1468
- URLStrategy.prototype.getLocation = function () {
1469
- return window.location.pathname.replace('/r', '');
1470
- };
1471
- URLStrategy.prototype.getLocationAt = function (position) {
1472
- return this.$stack[this.$position + position];
1473
- };
1474
- URLStrategy.prototype.getHistoryLength = function () {
1475
- return window.history.length;
1476
- };
1477
- URLStrategy.prototype.getScrollRestoration = function () {
1478
- return window.history.scrollRestoration;
1479
- };
1480
- URLStrategy.prototype.peek = function (to) {
1481
- return this.$stack[this.$position + to];
1482
- };
1483
- URLStrategy.prototype.canGo = function (to) {
1484
- return this.$stack[this.$position + to] !== undefined;
1485
- };
1486
- URLStrategy.prototype.go = function (to) {
1487
- if (!this.canGo(to)) {
1488
- return;
1489
- }
1490
- this.$position += to;
1491
- this.$navigate(this.$stack[this.$position]);
1492
- };
1493
- URLStrategy.prototype.pushState = function (url, state) {
1494
- if (state) {
1495
- console.warn('Warning: The state parameter is not implemented yet.');
1496
- }
1497
- if (url === this.getLocation()) {
1498
- //We are already here, so do nothing.
1499
- return;
1500
- }
1501
- this.$stack[++this.$position] = url;
1502
- //clear everything after position.
1503
- this.$stack = this.$stack.slice(0, this.$position + 1);
1504
- this.$navigate(url);
1505
- };
1506
- URLStrategy.prototype.replaceState = function (url, state) {
1507
- if (state) {
1508
- console.warn('Warning: The state parameter is not implemented yet.');
1509
- }
1510
- if (url === this.getLocation()) {
1511
- //We are already here, so do nothing.
1512
- return;
1513
- }
1514
- if (this.$position === -1) {
1515
- this.pushState(url, state);
1516
- }
1517
- else {
1518
- this.$stack[this.$position] = url;
1519
- this.$navigate(url);
1520
- }
1521
- };
1522
- URLStrategy.prototype.clear = function () {
1523
- this.$stack = [];
1524
- this.$position = -1;
1525
- };
1526
- URLStrategy.prototype.$navigate = function (url, replace) {
1527
- if (replace === void 0) { replace = false; }
1528
- if (replace) {
1529
- window.history.replaceState({}, null, this.$base + url);
1530
- }
1531
- else {
1532
- window.history.pushState({}, null, this.$base + url);
1533
- }
1534
- this._fireURLChange(this.getLocation());
1535
- };
1536
- return URLStrategy;
1537
- }(RouterStrategy));
1538
-
1539
754
  ___$insertStyle(".View {\n position: static;\n top: 0px;\n left: 0px;\n width: 100%;\n height: 100%;\n z-index: 1;\n}");
1540
755
 
1541
- var View = /** @class */ (function (_super) {
1542
- __extends(View, _super);
1543
- /**
1544
- * @param props See [IViewProps]
1545
- */
1546
- function View(props) {
1547
- var _this = _super.call(this, props) || this;
1548
- _this.$node = null;
1549
- return _this;
1550
- }
1551
- /**
1552
- * Return the CSS class on this view
1553
- */
1554
- View.prototype.getCSSClass = function () {
1555
- return '';
1556
- };
1557
- /**
1558
- * Override to return a webpack API style stylesheet
1559
- */
1560
- View.prototype.getViewStylesheet = function () {
1561
- return null;
1562
- };
1563
- /**
1564
- * @ignore
1565
- */
1566
- View.prototype.componentDidMount = function () {
1567
- var _this = this;
1568
- this.getTitle().then(function (title) {
1569
- _this.props.router.setTitle(title);
1570
- });
1571
- var stylesheet = this.getViewStylesheet();
1572
- if (stylesheet) {
1573
- stylesheet.use();
1574
- }
1575
- };
1576
- /**
1577
- * @ignore
1578
- */
1579
- View.prototype.componentWillUnmount = function () {
1580
- var stylesheet = this.getViewStylesheet();
1581
- if (stylesheet) {
1582
- stylesheet.unuse();
1583
- }
1584
- };
1585
- /**
1586
- * Gets the underlying HTML node for this View
1587
- */
1588
- View.prototype.getNode = function () {
1589
- return this.$node;
1590
- };
1591
- /**
1592
- * Get the title of this view
1593
- */
1594
- View.prototype.getTitle = function () {
1595
- return __awaiter(this, void 0, void 0, function () {
1596
- return __generator(this, function (_a) {
1597
- return [2 /*return*/, null];
1598
- });
1599
- });
1600
- };
1601
- /**
1602
- * Get the inline styles for this view.
1603
- * Use React style notation.
1604
- */
1605
- View.prototype.getViewStyles = function () {
1606
- return {};
1607
- };
1608
- View.prototype.render = function () {
1609
- var _this = this;
1610
- var cssClass = this.getCSSClass();
1611
- return (React__namespace.createElement("div", { className: "View".concat(cssClass ? ' ' + cssClass : ''), ref: function (n) { _this.$node = n; }, style: this.getViewStyles() }, this._renderView()));
1612
- };
1613
- return View;
1614
- }(React__namespace.Component));
756
+ class View extends React__namespace.Component {
757
+ /**
758
+ * @param props See [IViewProps]
759
+ */
760
+ constructor(props) {
761
+ super(props);
762
+ this.$node = null;
763
+ }
764
+ /**
765
+ * Return the CSS class on this view
766
+ */
767
+ getCSSClass() {
768
+ return '';
769
+ }
770
+ /**
771
+ * Override to return a webpack API style stylesheet
772
+ */
773
+ getViewStylesheet() {
774
+ return null;
775
+ }
776
+ /**
777
+ * @ignore
778
+ */
779
+ componentDidMount() {
780
+ this.getTitle().then((title) => {
781
+ this.props.router.setTitle(title);
782
+ });
783
+ let stylesheet = this.getViewStylesheet();
784
+ if (stylesheet) {
785
+ stylesheet.use();
786
+ }
787
+ this.props.router.__onViewMount(this);
788
+ }
789
+ /**
790
+ * @ignore
791
+ */
792
+ componentWillUnmount() {
793
+ let stylesheet = this.getViewStylesheet();
794
+ if (stylesheet) {
795
+ stylesheet.unuse();
796
+ }
797
+ this.props.router.__onViewUnmount(this);
798
+ }
799
+ /**
800
+ * Gets the underlying HTML node for this View
801
+ */
802
+ getNode() {
803
+ return this.$node;
804
+ }
805
+ /**
806
+ * Get the title of this view
807
+ */
808
+ getTitle() {
809
+ return __awaiter(this, void 0, void 0, function* () {
810
+ return null;
811
+ });
812
+ }
813
+ /**
814
+ * Get the inline styles for this view.
815
+ * Use React style notation.
816
+ */
817
+ getViewStyles() {
818
+ return {};
819
+ }
820
+ render() {
821
+ let cssClass = this.getCSSClass();
822
+ return (React__namespace.createElement("div", { className: `View${cssClass ? ' ' + cssClass : ''}`, ref: (n) => { this.$node = n; }, style: this.getViewStyles() }, this._renderView()));
823
+ }
824
+ }
1615
825
 
1616
- /**
1617
- * This class represents a route that renders a {@link View} component
1618
- */
1619
- var Route = /** @class */ (function (_super) {
1620
- __extends(Route, _super);
1621
- function Route(props) {
1622
- var _this = _super.call(this, props) || this;
1623
- _this.render;
1624
- return _this;
1625
- }
1626
- Route.prototype.render = function () {
1627
- return this.$getComponentsToRender(this);
1628
- };
1629
- Route.prototype.getView = function () {
1630
- return this.$node;
1631
- };
1632
- Route.prototype.$getComponentsToRender = function (component) {
1633
- var _this = this;
1634
- var url = component.props.url;
1635
- var base = component.props.base || '';
1636
- // eslint-disable-next-line @typescript-eslint/naming-convention
1637
- var ViewComponent = component.props.component;
1638
- var child;
1639
- var routeComponent = component.props.matcher.match(url, this.$getChildren(component), base);
1640
- if (routeComponent) {
1641
- child = this.$getComponentsToRender(routeComponent);
1642
- }
1643
- return (React__namespace.createElement(ViewComponent, __assign({}, component.props.componentProps, { ref: function (node) {
1644
- if (node) {
1645
- if (node instanceof View) {
1646
- _this.$node = node;
1647
- }
1648
- else {
1649
- throw new Error('Routed components should be a View, but got ' + Object.getPrototypeOf(node).constructor.name + ' instead.');
1650
- }
1651
- }
1652
- else {
1653
- _this.$node = null;
1654
- }
1655
- } }), child));
1656
- };
1657
- Route.prototype.$getChildren = function (component) {
1658
- var children = null;
1659
- if (!component) {
1660
- component = this;
1661
- }
1662
- if (!component.props.children) {
1663
- return [];
1664
- }
1665
- if (component.props.children instanceof Array) {
1666
- children = component.props.children;
1667
- }
1668
- else {
1669
- children = [component.props.children];
1670
- }
1671
- return children;
1672
- };
1673
- return Route;
1674
- }(React__namespace.Component));
826
+ /**
827
+ * This class represents a route that renders a {@link View} component
828
+ */
829
+ class Route extends React__namespace.Component {
830
+ constructor(props) {
831
+ super(props);
832
+ this.render;
833
+ }
834
+ render() {
835
+ return this.$getComponentsToRender(this);
836
+ }
837
+ getView() {
838
+ return this.$node;
839
+ }
840
+ $getComponentsToRender(component) {
841
+ let url = component.props.url;
842
+ let base = component.props.base || '';
843
+ // eslint-disable-next-line @typescript-eslint/naming-convention
844
+ let ViewComponent = component.props.component;
845
+ let child;
846
+ let routeComponent = component.props.matcher.match(url, this.$getChildren(component), base);
847
+ if (routeComponent) {
848
+ child = this.$getComponentsToRender(routeComponent);
849
+ }
850
+ return (React__namespace.createElement(ViewComponent, Object.assign({}, component.props.componentProps, { ref: (node) => {
851
+ if (node) {
852
+ if (node instanceof View) {
853
+ this.$node = node;
854
+ }
855
+ else {
856
+ throw new Error('Routed components should be a View, but got ' + Object.getPrototypeOf(node).constructor.name + ' instead.');
857
+ }
858
+ }
859
+ else {
860
+ this.$node = null;
861
+ }
862
+ } }), child));
863
+ }
864
+ $getChildren(component) {
865
+ let children = null;
866
+ if (!component) {
867
+ component = this;
868
+ }
869
+ if (!component.props.children) {
870
+ return [];
871
+ }
872
+ if (component.props.children instanceof Array) {
873
+ children = component.props.children;
874
+ }
875
+ else {
876
+ children = [component.props.children];
877
+ }
878
+ return children;
879
+ }
880
+ }
1675
881
 
1676
- var TransitionStrategy = /** @class */ (function () {
1677
- function TransitionStrategy() {
1678
- }
1679
- /**
1680
- * Invoked when the transition should begin.
1681
- * The promise should only resolve once the transition
1682
- * has ran to completion.
1683
- *
1684
- * The `incomingView` is the view that the user is navigating to.
1685
- * The `exitingView` is te view that the user is currently on, and is leaving.
1686
- *
1687
- * Both views will be rendered and are free to be manipulated in anyway that is desired,
1688
- * however, the incomingView should be positioned in it's natural position by the end
1689
- * of the transition to avoid "snapping" behaviour.
1690
- *
1691
- * @param {View} incomingView
1692
- * @param {View} exitingView
1693
- */
1694
- TransitionStrategy.prototype.execute = function (incomingView, exitingView) {
1695
- return __awaiter(this, void 0, void 0, function () {
1696
- return __generator(this, function (_a) {
1697
- switch (_a.label) {
1698
- case 0: return [4 /*yield*/, this._execute(incomingView, exitingView)];
1699
- case 1:
1700
- _a.sent();
1701
- return [2 /*return*/];
1702
- }
1703
- });
1704
- });
1705
- };
1706
- return TransitionStrategy;
1707
- }());
882
+ class TransitionStrategy {
883
+ constructor() { }
884
+ /**
885
+ * Invoked when the transition should begin.
886
+ * The promise should only resolve once the transition
887
+ * has ran to completion.
888
+ *
889
+ * The `incomingView` is the view that the user is navigating to.
890
+ * The `exitingView` is te view that the user is currently on, and is leaving.
891
+ *
892
+ * Both views will be rendered and are free to be manipulated in anyway that is desired,
893
+ * however, the incomingView should be positioned in it's natural position by the end
894
+ * of the transition to avoid "snapping" behaviour.
895
+ *
896
+ * @param {View} incomingView
897
+ * @param {View} exitingView
898
+ */
899
+ execute(incomingView, exitingView) {
900
+ return __awaiter(this, void 0, void 0, function* () {
901
+ yield this._execute(incomingView, exitingView);
902
+ });
903
+ }
904
+ }
1708
905
 
1709
- exports.TransitionSlideDirection = void 0;
1710
- (function (TransitionSlideDirection) {
1711
- TransitionSlideDirection[TransitionSlideDirection["LEFT"] = 1] = "LEFT";
1712
- TransitionSlideDirection[TransitionSlideDirection["RIGHT"] = 2] = "RIGHT";
1713
- TransitionSlideDirection[TransitionSlideDirection["UP"] = 3] = "UP";
1714
- TransitionSlideDirection[TransitionSlideDirection["DOWN"] = 4] = "DOWN";
1715
- })(exports.TransitionSlideDirection || (exports.TransitionSlideDirection = {}));
1716
- var TransitionSlide = /** @class */ (function (_super) {
1717
- __extends(TransitionSlide, _super);
1718
- function TransitionSlide(slideDirection, slideSpeed) {
1719
- var _this = _super.call(this) || this;
1720
- _this.$slideDirection = slideDirection || exports.TransitionSlideDirection.LEFT;
1721
- _this.$slideSpeed = slideSpeed || 0.25;
1722
- return _this;
1723
- }
1724
- TransitionSlide.prototype._execute = function (incoming, exiting) {
1725
- var _this = this;
1726
- return new Promise(function (resolve, reject) {
1727
- var incomingNode = incoming.getNode();
1728
- var exitingNode = exiting.getNode();
1729
- //First set initial transition CSS
1730
- incomingNode.style.willChange = 'transform';
1731
- incomingNode.style.transform = 'translate3d(0,0,0)';
1732
- incomingNode.style.pointerEvents = 'none';
1733
- incomingNode.style.zIndex = '1';
1734
- exitingNode.style.willChange = 'transform';
1735
- exitingNode.style.transform = 'translate3d(0,0,0)';
1736
- exitingNode.style.pointerEvents = 'none';
1737
- exitingNode.style.zIndex = '2';
1738
- switch (_this.$slideDirection) {
1739
- case exports.TransitionSlideDirection.LEFT:
1740
- incomingNode.style.left = '100%';
1741
- exitingNode.style.left = '0%';
1742
- break;
1743
- case exports.TransitionSlideDirection.RIGHT:
1744
- incomingNode.style.left = '-100%';
1745
- exitingNode.style.left = '0%';
1746
- break;
1747
- case exports.TransitionSlideDirection.UP:
1748
- incomingNode.style.top = '100%';
1749
- exitingNode.style.top = '0%';
1750
- break;
1751
- case exports.TransitionSlideDirection.DOWN:
1752
- incomingNode.style.top = '-100%';
1753
- exitingNode.style.top = '0%';
1754
- break;
1755
- }
1756
- //Set the appropriate transition string
1757
- var transitionString = _this.$getTransitionString(_this.$slideDirection);
1758
- incomingNode.style.transition = transitionString;
1759
- exitingNode.style.transition = transitionString;
1760
- //Add transition listener
1761
- var onTransitionEnd = function () {
1762
- //cleanup
1763
- incomingNode.removeEventListener('transitionend', onTransitionEnd);
1764
- incomingNode.style.willChange = '';
1765
- incomingNode.style.transform = '';
1766
- incomingNode.style.pointerEvents = '';
1767
- incomingNode.style.transition = '';
1768
- incomingNode.style.top = '0px';
1769
- incomingNode.style.left = '0px';
1770
- incomingNode.style.zIndex = '';
1771
- exitingNode.style.willChange = '';
1772
- exitingNode.style.transform = '';
1773
- exitingNode.style.pointerEvents = '';
1774
- exitingNode.style.transition = '';
1775
- exitingNode.style.top = '0px';
1776
- exitingNode.style.left = '0px';
1777
- exitingNode.style.zIndex = '';
1778
- //And we're done
1779
- resolve();
1780
- };
1781
- incomingNode.addEventListener('transitionend', onTransitionEnd);
1782
- //Apply transition logic
1783
- setTimeout(function () {
1784
- switch (_this.$slideDirection) {
1785
- case exports.TransitionSlideDirection.LEFT:
1786
- incomingNode.style.left = '0%';
1787
- exitingNode.style.left = '-100%';
1788
- break;
1789
- case exports.TransitionSlideDirection.RIGHT:
1790
- incomingNode.style.left = '0%';
1791
- exitingNode.style.left = '100%';
1792
- break;
1793
- case exports.TransitionSlideDirection.UP:
1794
- incomingNode.style.top = '0%';
1795
- exitingNode.style.top = '-100%';
1796
- break;
1797
- case exports.TransitionSlideDirection.DOWN:
1798
- incomingNode.style.top = '0%';
1799
- exitingNode.style.top = '100%';
1800
- break;
1801
- }
1802
- }, 1);
1803
- });
1804
- };
1805
- TransitionSlide.prototype.$getTransitionString = function (direction) {
1806
- var dir = null;
1807
- var speed = "".concat(this.$slideSpeed, "s");
1808
- switch (direction) {
1809
- case exports.TransitionSlideDirection.LEFT:
1810
- case exports.TransitionSlideDirection.RIGHT:
1811
- dir = 'left';
1812
- break;
1813
- case exports.TransitionSlideDirection.UP:
1814
- case exports.TransitionSlideDirection.DOWN:
1815
- dir = 'top';
1816
- break;
1817
- }
1818
- return "".concat(dir, " ").concat(speed, " ").concat(this.$getSlideStyle());
1819
- };
1820
- TransitionSlide.prototype.$getSlideStyle = function () {
1821
- return 'ease-in-out';
1822
- };
1823
- return TransitionSlide;
1824
- }(TransitionStrategy));
906
+ exports.TransitionSlideDirection = void 0;
907
+ (function (TransitionSlideDirection) {
908
+ TransitionSlideDirection[TransitionSlideDirection["LEFT"] = 1] = "LEFT";
909
+ TransitionSlideDirection[TransitionSlideDirection["RIGHT"] = 2] = "RIGHT";
910
+ TransitionSlideDirection[TransitionSlideDirection["UP"] = 3] = "UP";
911
+ TransitionSlideDirection[TransitionSlideDirection["DOWN"] = 4] = "DOWN";
912
+ })(exports.TransitionSlideDirection || (exports.TransitionSlideDirection = {}));
913
+ class TransitionSlide extends TransitionStrategy {
914
+ constructor(slideDirection, slideSpeed) {
915
+ super();
916
+ this.$slideDirection = slideDirection || exports.TransitionSlideDirection.LEFT;
917
+ this.$slideSpeed = slideSpeed || 0.25;
918
+ }
919
+ _execute(incoming, exiting) {
920
+ return new Promise((resolve, reject) => {
921
+ let incomingNode = incoming.getNode();
922
+ let exitingNode = exiting.getNode();
923
+ //First set initial transition CSS
924
+ incomingNode.style.willChange = 'transform';
925
+ incomingNode.style.transform = 'translate3d(0,0,0)';
926
+ incomingNode.style.pointerEvents = 'none';
927
+ incomingNode.style.zIndex = '1';
928
+ exitingNode.style.willChange = 'transform';
929
+ exitingNode.style.transform = 'translate3d(0,0,0)';
930
+ exitingNode.style.pointerEvents = 'none';
931
+ exitingNode.style.zIndex = '2';
932
+ switch (this.$slideDirection) {
933
+ case exports.TransitionSlideDirection.LEFT:
934
+ incomingNode.style.left = '100%';
935
+ exitingNode.style.left = '0%';
936
+ break;
937
+ case exports.TransitionSlideDirection.RIGHT:
938
+ incomingNode.style.left = '-100%';
939
+ exitingNode.style.left = '0%';
940
+ break;
941
+ case exports.TransitionSlideDirection.UP:
942
+ incomingNode.style.top = '100%';
943
+ exitingNode.style.top = '0%';
944
+ break;
945
+ case exports.TransitionSlideDirection.DOWN:
946
+ incomingNode.style.top = '-100%';
947
+ exitingNode.style.top = '0%';
948
+ break;
949
+ }
950
+ //Set the appropriate transition string
951
+ let transitionString = this.$getTransitionString(this.$slideDirection);
952
+ incomingNode.style.transition = transitionString;
953
+ exitingNode.style.transition = transitionString;
954
+ //Add transition listener
955
+ let onTransitionEnd = () => {
956
+ //cleanup
957
+ incomingNode.removeEventListener('transitionend', onTransitionEnd);
958
+ incomingNode.style.willChange = '';
959
+ incomingNode.style.transform = '';
960
+ incomingNode.style.pointerEvents = '';
961
+ incomingNode.style.transition = '';
962
+ incomingNode.style.top = '0px';
963
+ incomingNode.style.left = '0px';
964
+ incomingNode.style.zIndex = '';
965
+ exitingNode.style.willChange = '';
966
+ exitingNode.style.transform = '';
967
+ exitingNode.style.pointerEvents = '';
968
+ exitingNode.style.transition = '';
969
+ exitingNode.style.top = '0px';
970
+ exitingNode.style.left = '0px';
971
+ exitingNode.style.zIndex = '';
972
+ //And we're done
973
+ resolve();
974
+ };
975
+ incomingNode.addEventListener('transitionend', onTransitionEnd);
976
+ //Apply transition logic
977
+ setTimeout(() => {
978
+ switch (this.$slideDirection) {
979
+ case exports.TransitionSlideDirection.LEFT:
980
+ incomingNode.style.left = '0%';
981
+ exitingNode.style.left = '-100%';
982
+ break;
983
+ case exports.TransitionSlideDirection.RIGHT:
984
+ incomingNode.style.left = '0%';
985
+ exitingNode.style.left = '100%';
986
+ break;
987
+ case exports.TransitionSlideDirection.UP:
988
+ incomingNode.style.top = '0%';
989
+ exitingNode.style.top = '-100%';
990
+ break;
991
+ case exports.TransitionSlideDirection.DOWN:
992
+ incomingNode.style.top = '0%';
993
+ exitingNode.style.top = '100%';
994
+ break;
995
+ }
996
+ }, 1);
997
+ });
998
+ }
999
+ $getTransitionString(direction) {
1000
+ let dir = null;
1001
+ let speed = `${this.$slideSpeed}s`;
1002
+ switch (direction) {
1003
+ case exports.TransitionSlideDirection.LEFT:
1004
+ case exports.TransitionSlideDirection.RIGHT:
1005
+ dir = 'left';
1006
+ break;
1007
+ case exports.TransitionSlideDirection.UP:
1008
+ case exports.TransitionSlideDirection.DOWN:
1009
+ dir = 'top';
1010
+ break;
1011
+ }
1012
+ return `${dir} ${speed} ${this.$getSlideStyle()}`;
1013
+ }
1014
+ $getSlideStyle() {
1015
+ return 'ease-in-out';
1016
+ }
1017
+ }
1825
1018
 
1826
1019
  var name = "@breautek/router";
1827
- var version = "3.0.0";
1020
+ var version = "4.0.0";
1828
1021
  var description = "An alternate react router.";
1829
1022
  var main = "dist/router.js";
1830
1023
  var types = "dist/src/api.d.ts";
@@ -1835,12 +1028,10 @@ var publishConfig = {
1835
1028
  var scripts = {
1836
1029
  test: "jest",
1837
1030
  lint: "eslint --ext .ts,.tsx '?(src|spec)/**/*.?(ts|tsx)' --cache",
1838
- build: "rollup -c rollup.config.js",
1031
+ build: "rollup -c rollup.config.js --bundleConfigAsCjs",
1839
1032
  "publish-beta": "npm publish --tag beta",
1840
1033
  prepublishOnly: "npm run build",
1841
- changelog: "auto-changelog --output CHANGELOG.md -p --release-summary --ignore-commit-pattern chore",
1842
- docs: "typedoc --excludePrivate --includeVersion -readme ./README.md --out ./docs ./src/api.ts",
1843
- version: "npm run-script build && npm run-script docs && npm run changelog && git add CHANGELOG.md docs && git commit -m 'chore: changelog'",
1034
+ version: "npm run-script build",
1844
1035
  postversion: "git push && git push --tags"
1845
1036
  };
1846
1037
  var repository = {
@@ -1858,51 +1049,37 @@ var author = "norman@normanbreau.com";
1858
1049
  var license = "MIT";
1859
1050
  var homepage = "https://github.com/breautek/router";
1860
1051
  var peerDependencies = {
1861
- react: ">=16.9.0 <17.0.0",
1862
- "react-dom": ">=16.9.0 <17.0.0"
1052
+ react: "16.x || 17.x || 18.x",
1053
+ "react-dom": "16.x || 17.x || 18.x"
1863
1054
  };
1864
1055
  var devDependencies = {
1865
- "@babel/core": "7.18.5",
1866
- "@babel/plugin-syntax-dynamic-import": "7.8.3",
1867
- "@babel/preset-env": "7.18.2",
1868
- "@babel/preset-react": "7.17.12",
1869
- "@babel/preset-typescript": "7.17.12",
1870
- "@babel/register": "7.17.7",
1871
- "@rollup/plugin-babel": "5.3.1",
1872
- "@rollup/plugin-commonjs": "22.0.0",
1873
- "@rollup/plugin-json": "4.1.0",
1874
- "@rollup/plugin-node-resolve": "13.3.0",
1875
- "@types/enzyme": "3.10.12",
1876
- "@types/enzyme-adapter-react-16": "1.0.6",
1877
- "@types/jest": "27.5.1",
1878
- "@types/react": "16.14.4",
1879
- "@types/react-dom": "16.9.11",
1880
- "@types/react-test-renderer": "17.0.1",
1881
- "@typescript-eslint/eslint-plugin": "5.29.0",
1882
- "@typescript-eslint/parser": "5.29.0",
1883
- ajv: "8.11.0",
1884
- "auto-changelog": "2.4.0",
1885
- "babel-jest": "27.5.1",
1886
- enzyme: "3.11.0",
1887
- "enzyme-adapter-react-16": "1.15.6",
1888
- eslint: "8.18.0",
1889
- "eslint-plugin-react": "7.30.0",
1890
- glob: "8.0.3",
1056
+ "@rollup/plugin-commonjs": "25.0.3",
1057
+ "@rollup/plugin-json": "6.0.0",
1058
+ "@rollup/plugin-node-resolve": "15.1.0",
1059
+ "@testing-library/jest-dom": "5.16.5",
1060
+ "@testing-library/react": "14.0.0",
1061
+ "@types/jest": "29.5.3",
1062
+ "@types/react": "18.2.15",
1063
+ "@types/react-dom": "18.2.7",
1064
+ "@typescript-eslint/eslint-plugin": "6.1.0",
1065
+ "@typescript-eslint/parser": "6.1.0",
1066
+ ajv: "8.12.0",
1067
+ eslint: "8.45.0",
1068
+ "eslint-plugin-react": "7.32.2",
1069
+ glob: "10.3.3",
1891
1070
  "ignore-styles": "5.0.1",
1892
- jest: "27.5.1",
1893
- "node-sass": "7.0.1",
1894
- react: "16.14.0",
1895
- "react-dom": "16.14.0",
1896
- "regenerator-runtime": "0.13.9",
1897
- rollup: "2.75.7",
1071
+ jest: "29.6.1",
1072
+ "jest-environment-jsdom": "29.6.1",
1073
+ "node-sass": "9.0.0",
1074
+ react: "18.2.0",
1075
+ "react-dom": "18.2.0",
1076
+ rollup: "3.26.3",
1898
1077
  "rollup-plugin-progress": "1.1.2",
1899
- "rollup-plugin-sass": "1.2.12",
1900
- "rollup-plugin-typescript2": "0.32.1",
1901
- "ts-jest": "27.1.3",
1902
- "ts-node": "10.8.1",
1903
- typedoc: "0.22.17",
1904
- "typedoc-plugin-markdown": "3.12.1",
1905
- typescript: "4.6.4"
1078
+ "rollup-plugin-sass": "1.12.19",
1079
+ "rollup-plugin-typescript2": "0.35.0",
1080
+ "ts-jest": "29.1.1",
1081
+ "ts-node": "10.9.1",
1082
+ typescript: "5.1.6"
1906
1083
  };
1907
1084
  var packageInfo = {
1908
1085
  name: name,
@@ -1922,7 +1099,7 @@ var packageInfo = {
1922
1099
  devDependencies: devDependencies
1923
1100
  };
1924
1101
 
1925
- var VERSION = packageInfo.version;
1102
+ const VERSION = packageInfo.version;
1926
1103
 
1927
1104
  exports.DefaultStrategy = DefaultStrategy;
1928
1105
  exports.EVENT_URL_CHANGE = EVENT_URL_CHANGE;