@tanstack/react-router-devtools 0.0.1-beta.45 → 0.0.1-beta.55

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.
@@ -9,10 +9,10 @@
9
9
  * @license MIT
10
10
  */
11
11
  (function (global, factory) {
12
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('use-sync-external-store/shim')) :
13
- typeof define === 'function' && define.amd ? define(['exports', 'react', 'use-sync-external-store/shim'], factory) :
14
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ReactRouterDevtools = {}, global.React, global.shim));
15
- })(this, (function (exports, React, shim) { 'use strict';
12
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('use-sync-external-store/shim/with-selector')) :
13
+ typeof define === 'function' && define.amd ? define(['exports', 'react', 'use-sync-external-store/shim/with-selector'], factory) :
14
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ReactRouterDevtools = {}, global.React, global.withSelector));
15
+ })(this, (function (exports, React, withSelector) { 'use strict';
16
16
 
17
17
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
18
18
 
@@ -52,395 +52,18 @@
52
52
  return _extends.apply(this, arguments);
53
53
  }
54
54
 
55
- // src/core.ts
56
- var CurrentReaction = void 0;
57
- var CurrentGets = null;
58
- var CurrentGetsIndex = 0;
59
- var EffectQueue = null;
60
- var CacheClean = 0;
61
- var CacheCheck = 1;
62
- var CacheDirty = 2;
63
- var Root;
64
- var Reactive = class {
65
- value;
66
- fn;
67
- observers = null;
68
- sources = null;
69
- state;
70
- effect;
71
- cleanups = null;
72
- alwaysUpdate = false;
73
- constructor(fnOrValue, type) {
74
- if (type != 0 /* Signal */) {
75
- this.fn = fnOrValue;
76
- this.value = void 0;
77
- this.state = CacheDirty;
78
- if (Root)
79
- Root.push(this);
80
- else
81
- console.error("Memos and effects must be wrapped in a createRoot");
82
- this.effect = type == 2 /* Effect */;
83
- if (this.effect)
84
- this.update();
85
- } else {
86
- this.fn = void 0;
87
- this.value = fnOrValue;
88
- this.state = CacheClean;
89
- this.effect = false;
90
- }
91
- }
92
- get() {
93
- if (CurrentReaction) {
94
- if (!CurrentGets && CurrentReaction.sources && CurrentReaction.sources[CurrentGetsIndex] == this) {
95
- CurrentGetsIndex++;
96
- } else {
97
- if (!CurrentGets)
98
- CurrentGets = [this];
99
- else
100
- CurrentGets.push(this);
101
- }
102
- }
103
- if (this.fn)
104
- this.updateIfNecessary();
105
- return this.value;
106
- }
107
- set(value) {
108
- const notInBatch = !EffectQueue;
109
- const newValue = typeof value === "function" ? value(this.value) : value;
110
- if ((this.value !== newValue || this.alwaysUpdate) && this.observers) {
111
- for (let i = 0; i < this.observers.length; i++) {
112
- this.observers[i].stale(CacheDirty);
113
- }
114
- }
115
- this.value = newValue;
116
- if (notInBatch)
117
- stabilize();
118
- return newValue;
119
- }
120
- stale(state) {
121
- if (this.state < state) {
122
- if (this.state === CacheClean && this.effect) {
123
- if (EffectQueue)
124
- EffectQueue.push(this);
125
- else
126
- EffectQueue = [this];
127
- }
128
- this.state = state;
129
- if (this.observers) {
130
- for (let i = 0; i < this.observers.length; i++) {
131
- this.observers[i].stale(CacheCheck);
132
- }
133
- }
134
- }
135
- }
136
- update() {
137
- const oldValue = this.value;
138
- const prevReaction = CurrentReaction;
139
- const prevGets = CurrentGets;
140
- const prevIndex = CurrentGetsIndex;
141
- CurrentReaction = this;
142
- CurrentGets = null;
143
- CurrentGetsIndex = 0;
144
- try {
145
- if (this.cleanups) {
146
- this.cleanups.forEach((c) => c());
147
- this.cleanups = null;
148
- }
149
- this.value = this.fn();
150
- if (CurrentGets) {
151
- this.removeParentObservers(CurrentGetsIndex);
152
- if (this.sources && CurrentGetsIndex > 0) {
153
- this.sources.length = CurrentGetsIndex + CurrentGets.length;
154
- for (let i = 0; i < CurrentGets.length; i++) {
155
- this.sources[CurrentGetsIndex + i] = CurrentGets[i];
156
- }
157
- } else {
158
- this.sources = CurrentGets;
159
- }
160
- for (let i = CurrentGetsIndex; i < this.sources.length; i++) {
161
- const source = this.sources[i];
162
- if (!source.observers) {
163
- source.observers = [this];
164
- } else {
165
- source.observers.push(this);
166
- }
167
- }
168
- } else if (this.sources && CurrentGetsIndex < this.sources.length) {
169
- this.removeParentObservers(CurrentGetsIndex);
170
- this.sources.length = CurrentGetsIndex;
171
- }
172
- } finally {
173
- CurrentGets = prevGets;
174
- CurrentReaction = prevReaction;
175
- CurrentGetsIndex = prevIndex;
176
- }
177
- if ((oldValue !== this.value || this.alwaysUpdate) && this.observers) {
178
- for (let i = 0; i < this.observers.length; i++) {
179
- this.observers[i].state = CacheDirty;
180
- }
181
- }
182
- this.state = CacheClean;
183
- }
184
- updateIfNecessary() {
185
- if (this.state === CacheCheck) {
186
- for (const source of this.sources) {
187
- source.updateIfNecessary();
188
- if (this.state === CacheDirty) {
189
- break;
190
- }
191
- }
192
- }
193
- if (this.state === CacheDirty) {
194
- this.update();
195
- }
196
- this.state = CacheClean;
197
- }
198
- removeParentObservers(index) {
199
- if (!this.sources)
200
- return;
201
- for (let i = index; i < this.sources.length; i++) {
202
- const source = this.sources[i];
203
- const swap = source.observers.findIndex((v) => v === this);
204
- source.observers[swap] = source.observers[source.observers.length - 1];
205
- source.observers.pop();
206
- }
207
- }
208
- destroy() {
209
- if (this.cleanups) {
210
- this.cleanups.forEach((c) => c());
211
- this.cleanups = null;
212
- }
213
- this.removeParentObservers(0);
214
- }
215
- };
216
- function stabilize() {
217
- if (!EffectQueue)
218
- return;
219
- for (let i = 0; i < EffectQueue.length; i++) {
220
- EffectQueue[i].get();
221
- }
222
- EffectQueue = null;
223
- }
224
- function createEffect(fn) {
225
- const effect = new Reactive(fn, 2 /* Effect */);
226
- return effect.get.bind(effect);
227
- }
228
- function createRoot(fn) {
229
- let root = [];
230
- Root = root;
231
- fn();
232
- Root = null;
233
- return () => {
234
- if (!root)
235
- return;
236
- root.forEach((r) => r.destroy());
237
- root = null;
238
- };
239
- }
240
- function batch(fn) {
241
- EffectQueue = [];
242
- let out = fn();
243
- stabilize();
244
- return out;
245
- }
246
- function untrack(fn) {
247
- const listener = CurrentReaction;
248
- CurrentReaction = void 0;
249
- try {
250
- return fn();
251
- } finally {
252
- CurrentReaction = listener;
253
- }
254
- }
255
-
256
- // src/store.ts
257
- var $RAW = Symbol("store-raw");
258
- var $TRACK = Symbol("track");
259
- var $PROXY = Symbol("store-proxy");
260
- var $NODE = Symbol("store-node");
261
- function wrap(value) {
262
- let p = value[$PROXY];
263
- if (!p) {
264
- Object.defineProperty(value, $PROXY, {
265
- value: p = new Proxy(value, proxyTraps)
266
- });
267
- if (!Array.isArray(value)) {
268
- const keys = Object.keys(value);
269
- const desc = Object.getOwnPropertyDescriptors(value);
270
- for (let i = 0, l = keys.length; i < l; i++) {
271
- const prop = keys[i];
272
- if (desc[prop].get) {
273
- const get = desc[prop].get.bind(p);
274
- Object.defineProperty(value, prop, {
275
- enumerable: desc[prop].enumerable,
276
- get
277
- });
278
- }
279
- }
280
- }
281
- }
282
- return p;
283
- }
284
- function isWrappable(obj) {
285
- let proto;
286
- return obj != null && typeof obj === "object" && (obj[$PROXY] || !(proto = Object.getPrototypeOf(obj)) || proto === Object.prototype || Array.isArray(obj));
287
- }
288
- function unwrap(item, set = /* @__PURE__ */ new Set()) {
289
- let result, unwrapped, v, prop;
290
- if (result = item != null && item[$RAW])
291
- return result;
292
- if (!isWrappable(item) || set.has(item))
293
- return item;
294
- if (Array.isArray(item)) {
295
- if (Object.isFrozen(item))
296
- item = item.slice(0);
297
- else
298
- set.add(item);
299
- for (let i = 0, l = item.length; i < l; i++) {
300
- v = item[i];
301
- if ((unwrapped = unwrap(v, set)) !== v)
302
- item[i] = unwrapped;
303
- }
304
- } else {
305
- if (Object.isFrozen(item))
306
- item = Object.assign({}, item);
307
- else
308
- set.add(item);
309
- const keys = Object.keys(item);
310
- const desc = Object.getOwnPropertyDescriptors(item);
311
- for (let i = 0, l = keys.length; i < l; i++) {
312
- prop = keys[i];
313
- if (desc[prop].get)
314
- continue;
315
- v = item[prop];
316
- if ((unwrapped = unwrap(v, set)) !== v)
317
- item[prop] = unwrapped;
318
- }
319
- }
320
- return item;
321
- }
322
- function getDataNodes(target) {
323
- let nodes = target[$NODE];
324
- if (!nodes)
325
- Object.defineProperty(target, $NODE, { value: nodes = {} });
326
- return nodes;
327
- }
328
- function getDataNode(nodes, property, value) {
329
- return nodes[property] || (nodes[property] = createDataNode(value));
330
- }
331
- function proxyDescriptor(target, property) {
332
- const desc = Reflect.getOwnPropertyDescriptor(target, property);
333
- if (!desc || desc.get || !desc.configurable || property === $PROXY || property === $NODE)
334
- return desc;
335
- delete desc.value;
336
- delete desc.writable;
337
- desc.get = () => target[$PROXY][property];
338
- return desc;
339
- }
340
- function trackSelf(target) {
341
- if (CurrentReaction) {
342
- const nodes = getDataNodes(target);
343
- (nodes._ || (nodes._ = createDataNode())).get();
344
- }
345
- }
346
- function ownKeys(target) {
347
- trackSelf(target);
348
- return Reflect.ownKeys(target);
349
- }
350
- function createDataNode(value) {
351
- const s = new Reactive(value, 0);
352
- s.alwaysUpdate = true;
353
- return s;
354
- }
355
- var Writing = false;
356
- var proxyTraps = {
357
- get(target, property, receiver) {
358
- if (property === $RAW)
359
- return target;
360
- if (property === $PROXY)
361
- return receiver;
362
- if (property === $TRACK) {
363
- trackSelf(target);
364
- return receiver;
365
- }
366
- const nodes = getDataNodes(target);
367
- const tracked = nodes.hasOwnProperty(property);
368
- let value = tracked ? nodes[property].get() : target[property];
369
- if (property === $NODE || property === "__proto__")
370
- return value;
371
- if (!tracked) {
372
- const desc = Object.getOwnPropertyDescriptor(target, property);
373
- if (CurrentReaction && (typeof value !== "function" || target.hasOwnProperty(property)) && !(desc && desc.get))
374
- value = getDataNode(nodes, property, value).get();
375
- }
376
- return isWrappable(value) ? wrap(value) : value;
377
- },
378
- has(target, property) {
379
- if (property === $RAW || property === $PROXY || property === $TRACK || property === $NODE || property === "__proto__")
380
- return true;
381
- this.get(target, property, target);
382
- return property in target;
383
- },
384
- set(target, property, value) {
385
- Writing && setProperty(target, property, unwrap(value));
386
- return true;
387
- },
388
- deleteProperty(target, property) {
389
- Writing && setProperty(target, property, void 0, true);
390
- return true;
391
- },
392
- ownKeys,
393
- getOwnPropertyDescriptor: proxyDescriptor
394
- };
395
- function setProperty(state, property, value, deleting = false) {
396
- if (!deleting && state[property] === value)
397
- return;
398
- const prev = state[property];
399
- const len = state.length;
400
- if (deleting)
401
- delete state[property];
402
- else
403
- state[property] = value;
404
- const nodes = getDataNodes(state);
405
- let node;
406
- if (node = getDataNode(nodes, property, prev))
407
- node.set(() => value);
408
- if (Array.isArray(state) && state.length !== len)
409
- (node = getDataNode(nodes, "length", len)) && node.set(state.length);
410
- (node = nodes._) && node.set();
411
- }
412
- function createStore(store) {
413
- const unwrappedStore = unwrap(store);
414
- const wrappedStore = wrap(unwrappedStore);
415
- const setStore = (fn) => {
416
- batch(() => {
417
- try {
418
- Writing = true;
419
- fn(wrappedStore);
420
- } finally {
421
- Writing = false;
422
- }
423
- });
424
- };
425
- return [wrappedStore, setStore];
426
- }
427
-
428
- var isProduction = "development" === 'production';
429
55
  var prefix = 'Invariant failed';
430
56
  function invariant(condition, message) {
431
57
  if (condition) {
432
58
  return;
433
59
  }
434
- if (isProduction) {
435
- throw new Error(prefix);
436
- }
437
60
  var provided = typeof message === 'function' ? message() : message;
438
61
  var value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
439
62
  throw new Error(value);
440
63
  }
441
64
 
442
65
  /**
443
- * router-core
66
+ * router
444
67
  *
445
68
  * Copyright (c) TanStack
446
69
  *
@@ -464,114 +87,61 @@
464
87
  }
465
88
 
466
89
  /**
467
- * This function returns `a` if `b` is deeply equal.
468
- * If not, it will replace any deeply equal children of `b` with those of `a`.
469
- * This can be used for structural sharing between JSON values for example.
90
+ * react-store
91
+ *
92
+ * Copyright (c) TanStack
93
+ *
94
+ * This source code is licensed under the MIT license found in the
95
+ * LICENSE.md file in the root directory of this source tree.
96
+ *
97
+ * @license MIT
470
98
  */
471
- function sharedClone(prev, next, touchAll) {
472
- const things = new Map();
473
- function recurse(prev, next) {
474
- if (prev === next) {
475
- return prev;
476
- }
477
- if (things.has(next)) {
478
- return things.get(next);
479
- }
480
- const prevIsArray = Array.isArray(prev);
481
- const nextIsArray = Array.isArray(next);
482
- const prevIsObj = isPlainObject(prev);
483
- const nextIsObj = isPlainObject(next);
484
- const isArray = prevIsArray && nextIsArray;
485
- const isObj = prevIsObj && nextIsObj;
486
- const isSameStructure = isArray || isObj;
487
99
 
488
- // Both are arrays or objects
489
- if (isSameStructure) {
490
- const aSize = isArray ? prev.length : Object.keys(prev).length;
491
- const bItems = isArray ? next : Object.keys(next);
492
- const bSize = bItems.length;
493
- const copy = isArray ? [] : {};
494
- let equalItems = 0;
495
- for (let i = 0; i < bSize; i++) {
496
- const key = isArray ? i : bItems[i];
497
- if (copy[key] === prev[key]) {
498
- equalItems++;
499
- }
500
- }
501
- if (aSize === bSize && equalItems === aSize) {
502
- things.set(next, prev);
503
- return prev;
504
- }
505
- things.set(next, copy);
506
- for (let i = 0; i < bSize; i++) {
507
- const key = isArray ? i : bItems[i];
508
- if (typeof bItems[i] === 'function') {
509
- copy[key] = prev[key];
510
- } else {
511
- copy[key] = recurse(prev[key], next[key]);
512
- }
513
- if (copy[key] === prev[key]) {
514
- equalItems++;
515
- }
516
- }
517
- return copy;
518
- }
519
- if (nextIsArray) {
520
- const copy = [];
521
- things.set(next, copy);
522
- for (let i = 0; i < next.length; i++) {
523
- copy[i] = recurse(undefined, next[i]);
524
- }
525
- return copy;
526
- }
527
- if (nextIsObj) {
528
- const copy = {};
529
- things.set(next, copy);
530
- const nextKeys = Object.keys(next);
531
- for (let i = 0; i < nextKeys.length; i++) {
532
- const key = nextKeys[i];
533
- copy[key] = recurse(undefined, next[key]);
534
- }
535
- return copy;
536
- }
537
- return next;
538
- }
539
- return recurse(prev, next);
100
+ function useStore(store, selector = d => d, compareShallow) {
101
+ const slice = withSelector.useSyncExternalStoreWithSelector(store.subscribe, () => store.state, () => store.state, selector, compareShallow ? shallow : undefined);
102
+ return slice;
540
103
  }
541
-
542
- // Copied from: https://github.com/jonschlinkert/is-plain-object
543
- function isPlainObject(o) {
544
- if (!hasObjectPrototype(o)) {
545
- return false;
546
- }
547
-
548
- // If has modified constructor
549
- const ctor = o.constructor;
550
- if (typeof ctor === 'undefined') {
104
+ function shallow(objA, objB) {
105
+ if (Object.is(objA, objB)) {
551
106
  return true;
552
107
  }
553
-
554
- // If has modified prototype
555
- const prot = ctor.prototype;
556
- if (!hasObjectPrototype(prot)) {
108
+ if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
557
109
  return false;
558
110
  }
559
111
 
560
- // If constructor does not have an Object-specific method
561
- if (!prot.hasOwnProperty('isPrototypeOf')) {
112
+ // if (objA instanceof Map && objB instanceof Map) {
113
+ // if (objA.size !== objB.size) return false
114
+
115
+ // for (const [key, value] of objA) {
116
+ // if (!Object.is(value, objB.get(key))) {
117
+ // return false
118
+ // }
119
+ // }
120
+ // return true
121
+ // }
122
+
123
+ // if (objA instanceof Set && objB instanceof Set) {
124
+ // if (objA.size !== objB.size) return false
125
+
126
+ // for (const value of objA) {
127
+ // if (!objB.has(value)) {
128
+ // return false
129
+ // }
130
+ // }
131
+ // return true
132
+ // }
133
+
134
+ const keysA = Object.keys(objA);
135
+ if (keysA.length !== Object.keys(objB).length) {
562
136
  return false;
563
137
  }
564
-
565
- // Most likely a plain Object
138
+ for (let i = 0; i < keysA.length; i++) {
139
+ if (!Object.prototype.hasOwnProperty.call(objB, keysA[i]) || !Object.is(objA[keysA[i]], objB[keysA[i]])) {
140
+ return false;
141
+ }
142
+ }
566
143
  return true;
567
144
  }
568
- function hasObjectPrototype(o) {
569
- return Object.prototype.toString.call(o) === '[object Object]';
570
- }
571
-
572
- var _window$document;
573
- // Detect if we're in the DOM
574
- typeof window === 'undefined' || !((_window$document = window.document) != null && _window$document.createElement);
575
145
 
576
146
  /**
577
147
  * react-router
@@ -584,904 +154,14 @@
584
154
  * @license MIT
585
155
  */
586
156
  const routerContext = /*#__PURE__*/React__namespace.createContext(null);
587
- const EMPTY = {};
588
- const __useStoreValue = (seed, selector) => {
589
- const valueRef = React__namespace.useRef(EMPTY);
590
-
591
- // If there is no selector, track the seed
592
- // If there is a selector, do not track the seed
593
- const getValue = () => !selector ? seed() : selector(untrack(() => seed()));
594
-
595
- // If empty, initialize the value
596
- if (valueRef.current === EMPTY) {
597
- valueRef.current = sharedClone(undefined, getValue());
598
- }
599
-
600
- // Snapshot should just return the current cached value
601
- const getSnapshot = React__namespace.useCallback(() => valueRef.current, []);
602
- const getStore = React__namespace.useCallback(cb => {
603
- // A root is necessary to track effects
604
- return createRoot(() => {
605
- createEffect(() => {
606
- // Read and update the value
607
- // getValue will handle which values are accessed and
608
- // thus tracked.
609
- // sharedClone will both recursively track the end result
610
- // and ensure that the previous value is structurally shared
611
- // into the new version.
612
- valueRef.current = unwrap(
613
- // Unwrap the value to get rid of any proxy structures
614
- sharedClone(valueRef.current, getValue()));
615
- cb();
616
- });
617
- });
618
- }, []);
619
- return shim.useSyncExternalStore(getStore, getSnapshot, getSnapshot);
620
- };
621
- const [store, setStore] = createStore({
622
- foo: 'foo',
623
- bar: {
624
- baz: 'baz'
625
- }
626
- });
627
- createRoot(() => {
628
- let prev;
629
- createEffect(() => {
630
- console.log('effect');
631
- const next = sharedClone(prev, store);
632
- console.log(next);
633
- prev = untrack(() => next);
634
- });
635
- });
636
- setStore(s => {
637
- s.foo = '1';
638
- });
639
- setStore(s => {
640
- s.bar.baz = '2';
641
- });
642
157
  function useRouter() {
643
158
  const value = React__namespace.useContext(routerContext);
644
159
  warning(!value, 'useRouter must be used inside a <Router> component!');
645
160
  return value.router;
646
161
  }
647
- function useRouterStore(selector) {
162
+ function useRouterStore(selector, shallow) {
648
163
  const router = useRouter();
649
- return __useStoreValue(() => router.store, selector);
650
- }
651
-
652
- function requiredArgs(required, args) {
653
- if (args.length < required) {
654
- throw new TypeError(required + ' argument' + (required > 1 ? 's' : '') + ' required, but only ' + args.length + ' present');
655
- }
656
- }
657
-
658
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
659
- /**
660
- * @name toDate
661
- * @category Common Helpers
662
- * @summary Convert the given argument to an instance of Date.
663
- *
664
- * @description
665
- * Convert the given argument to an instance of Date.
666
- *
667
- * If the argument is an instance of Date, the function returns its clone.
668
- *
669
- * If the argument is a number, it is treated as a timestamp.
670
- *
671
- * If the argument is none of the above, the function returns Invalid Date.
672
- *
673
- * **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`.
674
- *
675
- * @param {Date|Number} argument - the value to convert
676
- * @returns {Date} the parsed date in the local time zone
677
- * @throws {TypeError} 1 argument required
678
- *
679
- * @example
680
- * // Clone the date:
681
- * const result = toDate(new Date(2014, 1, 11, 11, 30, 30))
682
- * //=> Tue Feb 11 2014 11:30:30
683
- *
684
- * @example
685
- * // Convert the timestamp to date:
686
- * const result = toDate(1392098430000)
687
- * //=> Tue Feb 11 2014 11:30:30
688
- */
689
-
690
- function toDate(argument) {
691
- requiredArgs(1, arguments);
692
- var argStr = Object.prototype.toString.call(argument); // Clone the date
693
-
694
- if (argument instanceof Date || _typeof(argument) === 'object' && argStr === '[object Date]') {
695
- // Prevent the date to lose the milliseconds when passed to new Date() in IE10
696
- return new Date(argument.getTime());
697
- } else if (typeof argument === 'number' || argStr === '[object Number]') {
698
- return new Date(argument);
699
- } else {
700
- if ((typeof argument === 'string' || argStr === '[object String]') && typeof console !== 'undefined') {
701
- // eslint-disable-next-line no-console
702
- console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments"); // eslint-disable-next-line no-console
703
-
704
- console.warn(new Error().stack);
705
- }
706
-
707
- return new Date(NaN);
708
- }
709
- }
710
-
711
- var defaultOptions = {};
712
- function getDefaultOptions() {
713
- return defaultOptions;
714
- }
715
-
716
- /**
717
- * Google Chrome as of 67.0.3396.87 introduced timezones with offset that includes seconds.
718
- * They usually appear for dates that denote time before the timezones were introduced
719
- * (e.g. for 'Europe/Prague' timezone the offset is GMT+00:57:44 before 1 October 1891
720
- * and GMT+01:00:00 after that date)
721
- *
722
- * Date#getTimezoneOffset returns the offset in minutes and would return 57 for the example above,
723
- * which would lead to incorrect calculations.
724
- *
725
- * This function returns the timezone offset in milliseconds that takes seconds in account.
726
- */
727
- function getTimezoneOffsetInMilliseconds(date) {
728
- var utcDate = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()));
729
- utcDate.setUTCFullYear(date.getFullYear());
730
- return date.getTime() - utcDate.getTime();
731
- }
732
-
733
- /**
734
- * @name compareAsc
735
- * @category Common Helpers
736
- * @summary Compare the two dates and return -1, 0 or 1.
737
- *
738
- * @description
739
- * Compare the two dates and return 1 if the first date is after the second,
740
- * -1 if the first date is before the second or 0 if dates are equal.
741
- *
742
- * @param {Date|Number} dateLeft - the first date to compare
743
- * @param {Date|Number} dateRight - the second date to compare
744
- * @returns {Number} the result of the comparison
745
- * @throws {TypeError} 2 arguments required
746
- *
747
- * @example
748
- * // Compare 11 February 1987 and 10 July 1989:
749
- * const result = compareAsc(new Date(1987, 1, 11), new Date(1989, 6, 10))
750
- * //=> -1
751
- *
752
- * @example
753
- * // Sort the array of dates:
754
- * const result = [
755
- * new Date(1995, 6, 2),
756
- * new Date(1987, 1, 11),
757
- * new Date(1989, 6, 10)
758
- * ].sort(compareAsc)
759
- * //=> [
760
- * // Wed Feb 11 1987 00:00:00,
761
- * // Mon Jul 10 1989 00:00:00,
762
- * // Sun Jul 02 1995 00:00:00
763
- * // ]
764
- */
765
-
766
- function compareAsc(dirtyDateLeft, dirtyDateRight) {
767
- requiredArgs(2, arguments);
768
- var dateLeft = toDate(dirtyDateLeft);
769
- var dateRight = toDate(dirtyDateRight);
770
- var diff = dateLeft.getTime() - dateRight.getTime();
771
-
772
- if (diff < 0) {
773
- return -1;
774
- } else if (diff > 0) {
775
- return 1; // Return 0 if diff is 0; return NaN if diff is NaN
776
- } else {
777
- return diff;
778
- }
779
- }
780
-
781
- var formatDistanceLocale = {
782
- lessThanXSeconds: {
783
- one: 'less than a second',
784
- other: 'less than {{count}} seconds'
785
- },
786
- xSeconds: {
787
- one: '1 second',
788
- other: '{{count}} seconds'
789
- },
790
- halfAMinute: 'half a minute',
791
- lessThanXMinutes: {
792
- one: 'less than a minute',
793
- other: 'less than {{count}} minutes'
794
- },
795
- xMinutes: {
796
- one: '1 minute',
797
- other: '{{count}} minutes'
798
- },
799
- aboutXHours: {
800
- one: 'about 1 hour',
801
- other: 'about {{count}} hours'
802
- },
803
- xHours: {
804
- one: '1 hour',
805
- other: '{{count}} hours'
806
- },
807
- xDays: {
808
- one: '1 day',
809
- other: '{{count}} days'
810
- },
811
- aboutXWeeks: {
812
- one: 'about 1 week',
813
- other: 'about {{count}} weeks'
814
- },
815
- xWeeks: {
816
- one: '1 week',
817
- other: '{{count}} weeks'
818
- },
819
- aboutXMonths: {
820
- one: 'about 1 month',
821
- other: 'about {{count}} months'
822
- },
823
- xMonths: {
824
- one: '1 month',
825
- other: '{{count}} months'
826
- },
827
- aboutXYears: {
828
- one: 'about 1 year',
829
- other: 'about {{count}} years'
830
- },
831
- xYears: {
832
- one: '1 year',
833
- other: '{{count}} years'
834
- },
835
- overXYears: {
836
- one: 'over 1 year',
837
- other: 'over {{count}} years'
838
- },
839
- almostXYears: {
840
- one: 'almost 1 year',
841
- other: 'almost {{count}} years'
842
- }
843
- };
844
-
845
- var formatDistance = function formatDistance(token, count, options) {
846
- var result;
847
- var tokenValue = formatDistanceLocale[token];
848
-
849
- if (typeof tokenValue === 'string') {
850
- result = tokenValue;
851
- } else if (count === 1) {
852
- result = tokenValue.one;
853
- } else {
854
- result = tokenValue.other.replace('{{count}}', count.toString());
855
- }
856
-
857
- if (options !== null && options !== void 0 && options.addSuffix) {
858
- if (options.comparison && options.comparison > 0) {
859
- return 'in ' + result;
860
- } else {
861
- return result + ' ago';
862
- }
863
- }
864
-
865
- return result;
866
- };
867
-
868
- var formatDistance$1 = formatDistance;
869
-
870
- function buildFormatLongFn(args) {
871
- return function () {
872
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
873
- // TODO: Remove String()
874
- var width = options.width ? String(options.width) : args.defaultWidth;
875
- var format = args.formats[width] || args.formats[args.defaultWidth];
876
- return format;
877
- };
878
- }
879
-
880
- var dateFormats = {
881
- full: 'EEEE, MMMM do, y',
882
- long: 'MMMM do, y',
883
- medium: 'MMM d, y',
884
- short: 'MM/dd/yyyy'
885
- };
886
- var timeFormats = {
887
- full: 'h:mm:ss a zzzz',
888
- long: 'h:mm:ss a z',
889
- medium: 'h:mm:ss a',
890
- short: 'h:mm a'
891
- };
892
- var dateTimeFormats = {
893
- full: "{{date}} 'at' {{time}}",
894
- long: "{{date}} 'at' {{time}}",
895
- medium: '{{date}}, {{time}}',
896
- short: '{{date}}, {{time}}'
897
- };
898
- var formatLong = {
899
- date: buildFormatLongFn({
900
- formats: dateFormats,
901
- defaultWidth: 'full'
902
- }),
903
- time: buildFormatLongFn({
904
- formats: timeFormats,
905
- defaultWidth: 'full'
906
- }),
907
- dateTime: buildFormatLongFn({
908
- formats: dateTimeFormats,
909
- defaultWidth: 'full'
910
- })
911
- };
912
- var formatLong$1 = formatLong;
913
-
914
- var formatRelativeLocale = {
915
- lastWeek: "'last' eeee 'at' p",
916
- yesterday: "'yesterday at' p",
917
- today: "'today at' p",
918
- tomorrow: "'tomorrow at' p",
919
- nextWeek: "eeee 'at' p",
920
- other: 'P'
921
- };
922
-
923
- var formatRelative = function formatRelative(token, _date, _baseDate, _options) {
924
- return formatRelativeLocale[token];
925
- };
926
-
927
- var formatRelative$1 = formatRelative;
928
-
929
- function buildLocalizeFn(args) {
930
- return function (dirtyIndex, options) {
931
- var context = options !== null && options !== void 0 && options.context ? String(options.context) : 'standalone';
932
- var valuesArray;
933
-
934
- if (context === 'formatting' && args.formattingValues) {
935
- var defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
936
- var width = options !== null && options !== void 0 && options.width ? String(options.width) : defaultWidth;
937
- valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
938
- } else {
939
- var _defaultWidth = args.defaultWidth;
940
-
941
- var _width = options !== null && options !== void 0 && options.width ? String(options.width) : args.defaultWidth;
942
-
943
- valuesArray = args.values[_width] || args.values[_defaultWidth];
944
- }
945
-
946
- var index = args.argumentCallback ? args.argumentCallback(dirtyIndex) : dirtyIndex; // @ts-ignore: For some reason TypeScript just don't want to match it, no matter how hard we try. I challenge you to try to remove it!
947
-
948
- return valuesArray[index];
949
- };
950
- }
951
-
952
- var eraValues = {
953
- narrow: ['B', 'A'],
954
- abbreviated: ['BC', 'AD'],
955
- wide: ['Before Christ', 'Anno Domini']
956
- };
957
- var quarterValues = {
958
- narrow: ['1', '2', '3', '4'],
959
- abbreviated: ['Q1', 'Q2', 'Q3', 'Q4'],
960
- wide: ['1st quarter', '2nd quarter', '3rd quarter', '4th quarter']
961
- }; // Note: in English, the names of days of the week and months are capitalized.
962
- // If you are making a new locale based on this one, check if the same is true for the language you're working on.
963
- // Generally, formatted dates should look like they are in the middle of a sentence,
964
- // e.g. in Spanish language the weekdays and months should be in the lowercase.
965
-
966
- var monthValues = {
967
- narrow: ['J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D'],
968
- abbreviated: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
969
- wide: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
970
- };
971
- var dayValues = {
972
- narrow: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
973
- short: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
974
- abbreviated: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
975
- wide: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
976
- };
977
- var dayPeriodValues = {
978
- narrow: {
979
- am: 'a',
980
- pm: 'p',
981
- midnight: 'mi',
982
- noon: 'n',
983
- morning: 'morning',
984
- afternoon: 'afternoon',
985
- evening: 'evening',
986
- night: 'night'
987
- },
988
- abbreviated: {
989
- am: 'AM',
990
- pm: 'PM',
991
- midnight: 'midnight',
992
- noon: 'noon',
993
- morning: 'morning',
994
- afternoon: 'afternoon',
995
- evening: 'evening',
996
- night: 'night'
997
- },
998
- wide: {
999
- am: 'a.m.',
1000
- pm: 'p.m.',
1001
- midnight: 'midnight',
1002
- noon: 'noon',
1003
- morning: 'morning',
1004
- afternoon: 'afternoon',
1005
- evening: 'evening',
1006
- night: 'night'
1007
- }
1008
- };
1009
- var formattingDayPeriodValues = {
1010
- narrow: {
1011
- am: 'a',
1012
- pm: 'p',
1013
- midnight: 'mi',
1014
- noon: 'n',
1015
- morning: 'in the morning',
1016
- afternoon: 'in the afternoon',
1017
- evening: 'in the evening',
1018
- night: 'at night'
1019
- },
1020
- abbreviated: {
1021
- am: 'AM',
1022
- pm: 'PM',
1023
- midnight: 'midnight',
1024
- noon: 'noon',
1025
- morning: 'in the morning',
1026
- afternoon: 'in the afternoon',
1027
- evening: 'in the evening',
1028
- night: 'at night'
1029
- },
1030
- wide: {
1031
- am: 'a.m.',
1032
- pm: 'p.m.',
1033
- midnight: 'midnight',
1034
- noon: 'noon',
1035
- morning: 'in the morning',
1036
- afternoon: 'in the afternoon',
1037
- evening: 'in the evening',
1038
- night: 'at night'
1039
- }
1040
- };
1041
-
1042
- var ordinalNumber = function ordinalNumber(dirtyNumber, _options) {
1043
- var number = Number(dirtyNumber); // If ordinal numbers depend on context, for example,
1044
- // if they are different for different grammatical genders,
1045
- // use `options.unit`.
1046
- //
1047
- // `unit` can be 'year', 'quarter', 'month', 'week', 'date', 'dayOfYear',
1048
- // 'day', 'hour', 'minute', 'second'.
1049
-
1050
- var rem100 = number % 100;
1051
-
1052
- if (rem100 > 20 || rem100 < 10) {
1053
- switch (rem100 % 10) {
1054
- case 1:
1055
- return number + 'st';
1056
-
1057
- case 2:
1058
- return number + 'nd';
1059
-
1060
- case 3:
1061
- return number + 'rd';
1062
- }
1063
- }
1064
-
1065
- return number + 'th';
1066
- };
1067
-
1068
- var localize = {
1069
- ordinalNumber: ordinalNumber,
1070
- era: buildLocalizeFn({
1071
- values: eraValues,
1072
- defaultWidth: 'wide'
1073
- }),
1074
- quarter: buildLocalizeFn({
1075
- values: quarterValues,
1076
- defaultWidth: 'wide',
1077
- argumentCallback: function argumentCallback(quarter) {
1078
- return quarter - 1;
1079
- }
1080
- }),
1081
- month: buildLocalizeFn({
1082
- values: monthValues,
1083
- defaultWidth: 'wide'
1084
- }),
1085
- day: buildLocalizeFn({
1086
- values: dayValues,
1087
- defaultWidth: 'wide'
1088
- }),
1089
- dayPeriod: buildLocalizeFn({
1090
- values: dayPeriodValues,
1091
- defaultWidth: 'wide',
1092
- formattingValues: formattingDayPeriodValues,
1093
- defaultFormattingWidth: 'wide'
1094
- })
1095
- };
1096
- var localize$1 = localize;
1097
-
1098
- function buildMatchFn(args) {
1099
- return function (string) {
1100
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1101
- var width = options.width;
1102
- var matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
1103
- var matchResult = string.match(matchPattern);
1104
-
1105
- if (!matchResult) {
1106
- return null;
1107
- }
1108
-
1109
- var matchedString = matchResult[0];
1110
- var parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
1111
- var key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, function (pattern) {
1112
- return pattern.test(matchedString);
1113
- }) : findKey(parsePatterns, function (pattern) {
1114
- return pattern.test(matchedString);
1115
- });
1116
- var value;
1117
- value = args.valueCallback ? args.valueCallback(key) : key;
1118
- value = options.valueCallback ? options.valueCallback(value) : value;
1119
- var rest = string.slice(matchedString.length);
1120
- return {
1121
- value: value,
1122
- rest: rest
1123
- };
1124
- };
1125
- }
1126
-
1127
- function findKey(object, predicate) {
1128
- for (var key in object) {
1129
- if (object.hasOwnProperty(key) && predicate(object[key])) {
1130
- return key;
1131
- }
1132
- }
1133
-
1134
- return undefined;
1135
- }
1136
-
1137
- function findIndex(array, predicate) {
1138
- for (var key = 0; key < array.length; key++) {
1139
- if (predicate(array[key])) {
1140
- return key;
1141
- }
1142
- }
1143
-
1144
- return undefined;
1145
- }
1146
-
1147
- function buildMatchPatternFn(args) {
1148
- return function (string) {
1149
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1150
- var matchResult = string.match(args.matchPattern);
1151
- if (!matchResult) return null;
1152
- var matchedString = matchResult[0];
1153
- var parseResult = string.match(args.parsePattern);
1154
- if (!parseResult) return null;
1155
- var value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
1156
- value = options.valueCallback ? options.valueCallback(value) : value;
1157
- var rest = string.slice(matchedString.length);
1158
- return {
1159
- value: value,
1160
- rest: rest
1161
- };
1162
- };
1163
- }
1164
-
1165
- var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
1166
- var parseOrdinalNumberPattern = /\d+/i;
1167
- var matchEraPatterns = {
1168
- narrow: /^(b|a)/i,
1169
- abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
1170
- wide: /^(before christ|before common era|anno domini|common era)/i
1171
- };
1172
- var parseEraPatterns = {
1173
- any: [/^b/i, /^(a|c)/i]
1174
- };
1175
- var matchQuarterPatterns = {
1176
- narrow: /^[1234]/i,
1177
- abbreviated: /^q[1234]/i,
1178
- wide: /^[1234](th|st|nd|rd)? quarter/i
1179
- };
1180
- var parseQuarterPatterns = {
1181
- any: [/1/i, /2/i, /3/i, /4/i]
1182
- };
1183
- var matchMonthPatterns = {
1184
- narrow: /^[jfmasond]/i,
1185
- abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
1186
- wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
1187
- };
1188
- var parseMonthPatterns = {
1189
- narrow: [/^j/i, /^f/i, /^m/i, /^a/i, /^m/i, /^j/i, /^j/i, /^a/i, /^s/i, /^o/i, /^n/i, /^d/i],
1190
- any: [/^ja/i, /^f/i, /^mar/i, /^ap/i, /^may/i, /^jun/i, /^jul/i, /^au/i, /^s/i, /^o/i, /^n/i, /^d/i]
1191
- };
1192
- var matchDayPatterns = {
1193
- narrow: /^[smtwf]/i,
1194
- short: /^(su|mo|tu|we|th|fr|sa)/i,
1195
- abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
1196
- wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
1197
- };
1198
- var parseDayPatterns = {
1199
- narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
1200
- any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
1201
- };
1202
- var matchDayPeriodPatterns = {
1203
- narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
1204
- any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
1205
- };
1206
- var parseDayPeriodPatterns = {
1207
- any: {
1208
- am: /^a/i,
1209
- pm: /^p/i,
1210
- midnight: /^mi/i,
1211
- noon: /^no/i,
1212
- morning: /morning/i,
1213
- afternoon: /afternoon/i,
1214
- evening: /evening/i,
1215
- night: /night/i
1216
- }
1217
- };
1218
- var match = {
1219
- ordinalNumber: buildMatchPatternFn({
1220
- matchPattern: matchOrdinalNumberPattern,
1221
- parsePattern: parseOrdinalNumberPattern,
1222
- valueCallback: function valueCallback(value) {
1223
- return parseInt(value, 10);
1224
- }
1225
- }),
1226
- era: buildMatchFn({
1227
- matchPatterns: matchEraPatterns,
1228
- defaultMatchWidth: 'wide',
1229
- parsePatterns: parseEraPatterns,
1230
- defaultParseWidth: 'any'
1231
- }),
1232
- quarter: buildMatchFn({
1233
- matchPatterns: matchQuarterPatterns,
1234
- defaultMatchWidth: 'wide',
1235
- parsePatterns: parseQuarterPatterns,
1236
- defaultParseWidth: 'any',
1237
- valueCallback: function valueCallback(index) {
1238
- return index + 1;
1239
- }
1240
- }),
1241
- month: buildMatchFn({
1242
- matchPatterns: matchMonthPatterns,
1243
- defaultMatchWidth: 'wide',
1244
- parsePatterns: parseMonthPatterns,
1245
- defaultParseWidth: 'any'
1246
- }),
1247
- day: buildMatchFn({
1248
- matchPatterns: matchDayPatterns,
1249
- defaultMatchWidth: 'wide',
1250
- parsePatterns: parseDayPatterns,
1251
- defaultParseWidth: 'any'
1252
- }),
1253
- dayPeriod: buildMatchFn({
1254
- matchPatterns: matchDayPeriodPatterns,
1255
- defaultMatchWidth: 'any',
1256
- parsePatterns: parseDayPeriodPatterns,
1257
- defaultParseWidth: 'any'
1258
- })
1259
- };
1260
- var match$1 = match;
1261
-
1262
- /**
1263
- * @type {Locale}
1264
- * @category Locales
1265
- * @summary English locale (United States).
1266
- * @language English
1267
- * @iso-639-2 eng
1268
- * @author Sasha Koss [@kossnocorp]{@link https://github.com/kossnocorp}
1269
- * @author Lesha Koss [@leshakoss]{@link https://github.com/leshakoss}
1270
- */
1271
- var locale = {
1272
- code: 'en-US',
1273
- formatDistance: formatDistance$1,
1274
- formatLong: formatLong$1,
1275
- formatRelative: formatRelative$1,
1276
- localize: localize$1,
1277
- match: match$1,
1278
- options: {
1279
- weekStartsOn: 0
1280
- /* Sunday */
1281
- ,
1282
- firstWeekContainsDate: 1
1283
- }
1284
- };
1285
- var defaultLocale = locale;
1286
-
1287
- function assign(target, object) {
1288
- if (target == null) {
1289
- throw new TypeError('assign requires that input parameter not be null or undefined');
1290
- }
1291
-
1292
- for (var property in object) {
1293
- if (Object.prototype.hasOwnProperty.call(object, property)) {
1294
- target[property] = object[property];
1295
- }
1296
- }
1297
-
1298
- return target;
1299
- }
1300
-
1301
- function cloneObject(object) {
1302
- return assign({}, object);
1303
- }
1304
-
1305
- var MILLISECONDS_IN_MINUTE = 1000 * 60;
1306
- var MINUTES_IN_DAY = 60 * 24;
1307
- var MINUTES_IN_MONTH = MINUTES_IN_DAY * 30;
1308
- var MINUTES_IN_YEAR = MINUTES_IN_DAY * 365;
1309
- /**
1310
- * @name formatDistanceStrict
1311
- * @category Common Helpers
1312
- * @summary Return the distance between the given dates in words.
1313
- *
1314
- * @description
1315
- * Return the distance between the given dates in words, using strict units.
1316
- * This is like `formatDistance`, but does not use helpers like 'almost', 'over',
1317
- * 'less than' and the like.
1318
- *
1319
- * | Distance between dates | Result |
1320
- * |------------------------|---------------------|
1321
- * | 0 ... 59 secs | [0..59] seconds |
1322
- * | 1 ... 59 mins | [1..59] minutes |
1323
- * | 1 ... 23 hrs | [1..23] hours |
1324
- * | 1 ... 29 days | [1..29] days |
1325
- * | 1 ... 11 months | [1..11] months |
1326
- * | 1 ... N years | [1..N] years |
1327
- *
1328
- * @param {Date|Number} date - the date
1329
- * @param {Date|Number} baseDate - the date to compare with
1330
- * @param {Object} [options] - an object with options.
1331
- * @param {Boolean} [options.addSuffix=false] - result indicates if the second date is earlier or later than the first
1332
- * @param {'second'|'minute'|'hour'|'day'|'month'|'year'} [options.unit] - if specified, will force a unit
1333
- * @param {'floor'|'ceil'|'round'} [options.roundingMethod='round'] - which way to round partial units
1334
- * @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale}
1335
- * @returns {String} the distance in words
1336
- * @throws {TypeError} 2 arguments required
1337
- * @throws {RangeError} `date` must not be Invalid Date
1338
- * @throws {RangeError} `baseDate` must not be Invalid Date
1339
- * @throws {RangeError} `options.roundingMethod` must be 'floor', 'ceil' or 'round'
1340
- * @throws {RangeError} `options.unit` must be 'second', 'minute', 'hour', 'day', 'month' or 'year'
1341
- * @throws {RangeError} `options.locale` must contain `formatDistance` property
1342
- *
1343
- * @example
1344
- * // What is the distance between 2 July 2014 and 1 January 2015?
1345
- * const result = formatDistanceStrict(new Date(2014, 6, 2), new Date(2015, 0, 2))
1346
- * //=> '6 months'
1347
- *
1348
- * @example
1349
- * // What is the distance between 1 January 2015 00:00:15
1350
- * // and 1 January 2015 00:00:00?
1351
- * const result = formatDistanceStrict(
1352
- * new Date(2015, 0, 1, 0, 0, 15),
1353
- * new Date(2015, 0, 1, 0, 0, 0)
1354
- * )
1355
- * //=> '15 seconds'
1356
- *
1357
- * @example
1358
- * // What is the distance from 1 January 2016
1359
- * // to 1 January 2015, with a suffix?
1360
- * const result = formatDistanceStrict(new Date(2015, 0, 1), new Date(2016, 0, 1), {
1361
- * addSuffix: true
1362
- * })
1363
- * //=> '1 year ago'
1364
- *
1365
- * @example
1366
- * // What is the distance from 1 January 2016
1367
- * // to 1 January 2015, in minutes?
1368
- * const result = formatDistanceStrict(new Date(2016, 0, 1), new Date(2015, 0, 1), {
1369
- * unit: 'minute'
1370
- * })
1371
- * //=> '525600 minutes'
1372
- *
1373
- * @example
1374
- * // What is the distance from 1 January 2015
1375
- * // to 28 January 2015, in months, rounded up?
1376
- * const result = formatDistanceStrict(new Date(2015, 0, 28), new Date(2015, 0, 1), {
1377
- * unit: 'month',
1378
- * roundingMethod: 'ceil'
1379
- * })
1380
- * //=> '1 month'
1381
- *
1382
- * @example
1383
- * // What is the distance between 1 August 2016 and 1 January 2015 in Esperanto?
1384
- * import { eoLocale } from 'date-fns/locale/eo'
1385
- * const result = formatDistanceStrict(new Date(2016, 7, 1), new Date(2015, 0, 1), {
1386
- * locale: eoLocale
1387
- * })
1388
- * //=> '1 jaro'
1389
- */
1390
-
1391
- function formatDistanceStrict(dirtyDate, dirtyBaseDate, options) {
1392
- var _ref, _options$locale, _options$roundingMeth;
1393
-
1394
- requiredArgs(2, arguments);
1395
- var defaultOptions = getDefaultOptions();
1396
- var locale = (_ref = (_options$locale = options === null || options === void 0 ? void 0 : options.locale) !== null && _options$locale !== void 0 ? _options$locale : defaultOptions.locale) !== null && _ref !== void 0 ? _ref : defaultLocale;
1397
-
1398
- if (!locale.formatDistance) {
1399
- throw new RangeError('locale must contain localize.formatDistance property');
1400
- }
1401
-
1402
- var comparison = compareAsc(dirtyDate, dirtyBaseDate);
1403
-
1404
- if (isNaN(comparison)) {
1405
- throw new RangeError('Invalid time value');
1406
- }
1407
-
1408
- var localizeOptions = assign(cloneObject(options), {
1409
- addSuffix: Boolean(options === null || options === void 0 ? void 0 : options.addSuffix),
1410
- comparison: comparison
1411
- });
1412
- var dateLeft;
1413
- var dateRight;
1414
-
1415
- if (comparison > 0) {
1416
- dateLeft = toDate(dirtyBaseDate);
1417
- dateRight = toDate(dirtyDate);
1418
- } else {
1419
- dateLeft = toDate(dirtyDate);
1420
- dateRight = toDate(dirtyBaseDate);
1421
- }
1422
-
1423
- var roundingMethod = String((_options$roundingMeth = options === null || options === void 0 ? void 0 : options.roundingMethod) !== null && _options$roundingMeth !== void 0 ? _options$roundingMeth : 'round');
1424
- var roundingMethodFn;
1425
-
1426
- if (roundingMethod === 'floor') {
1427
- roundingMethodFn = Math.floor;
1428
- } else if (roundingMethod === 'ceil') {
1429
- roundingMethodFn = Math.ceil;
1430
- } else if (roundingMethod === 'round') {
1431
- roundingMethodFn = Math.round;
1432
- } else {
1433
- throw new RangeError("roundingMethod must be 'floor', 'ceil' or 'round'");
1434
- }
1435
-
1436
- var milliseconds = dateRight.getTime() - dateLeft.getTime();
1437
- var minutes = milliseconds / MILLISECONDS_IN_MINUTE;
1438
- var timezoneOffset = getTimezoneOffsetInMilliseconds(dateRight) - getTimezoneOffsetInMilliseconds(dateLeft); // Use DST-normalized difference in minutes for years, months and days;
1439
- // use regular difference in minutes for hours, minutes and seconds.
1440
-
1441
- var dstNormalizedMinutes = (milliseconds - timezoneOffset) / MILLISECONDS_IN_MINUTE;
1442
- var defaultUnit = options === null || options === void 0 ? void 0 : options.unit;
1443
- var unit;
1444
-
1445
- if (!defaultUnit) {
1446
- if (minutes < 1) {
1447
- unit = 'second';
1448
- } else if (minutes < 60) {
1449
- unit = 'minute';
1450
- } else if (minutes < MINUTES_IN_DAY) {
1451
- unit = 'hour';
1452
- } else if (dstNormalizedMinutes < MINUTES_IN_MONTH) {
1453
- unit = 'day';
1454
- } else if (dstNormalizedMinutes < MINUTES_IN_YEAR) {
1455
- unit = 'month';
1456
- } else {
1457
- unit = 'year';
1458
- }
1459
- } else {
1460
- unit = String(defaultUnit);
1461
- } // 0 up to 60 seconds
1462
-
1463
-
1464
- if (unit === 'second') {
1465
- var seconds = roundingMethodFn(milliseconds / 1000);
1466
- return locale.formatDistance('xSeconds', seconds, localizeOptions); // 1 up to 60 mins
1467
- } else if (unit === 'minute') {
1468
- var roundedMinutes = roundingMethodFn(minutes);
1469
- return locale.formatDistance('xMinutes', roundedMinutes, localizeOptions); // 1 up to 24 hours
1470
- } else if (unit === 'hour') {
1471
- var hours = roundingMethodFn(minutes / 60);
1472
- return locale.formatDistance('xHours', hours, localizeOptions); // 1 up to 30 days
1473
- } else if (unit === 'day') {
1474
- var days = roundingMethodFn(dstNormalizedMinutes / MINUTES_IN_DAY);
1475
- return locale.formatDistance('xDays', days, localizeOptions); // 1 up to 12 months
1476
- } else if (unit === 'month') {
1477
- var months = roundingMethodFn(dstNormalizedMinutes / MINUTES_IN_MONTH);
1478
- return months === 12 && defaultUnit !== 'month' ? locale.formatDistance('xYears', 1, localizeOptions) : locale.formatDistance('xMonths', months, localizeOptions); // 1 year up to max Date
1479
- } else if (unit === 'year') {
1480
- var years = roundingMethodFn(dstNormalizedMinutes / MINUTES_IN_YEAR);
1481
- return locale.formatDistance('xYears', years, localizeOptions);
1482
- }
1483
-
1484
- throw new RangeError("unit must be 'second', 'minute', 'hour', 'day', 'month' or 'year'");
164
+ return useStore(router.store, selector, shallow);
1485
165
  }
1486
166
 
1487
167
  const getItem = key => {
@@ -1534,11 +214,10 @@
1534
214
  warning: '#ffb200'
1535
215
  };
1536
216
  const ThemeContext = /*#__PURE__*/React__default["default"].createContext(defaultTheme);
1537
- function ThemeProvider(_ref) {
1538
- let {
1539
- theme,
1540
- ...rest
1541
- } = _ref;
217
+ function ThemeProvider({
218
+ theme,
219
+ ...rest
220
+ }) {
1542
221
  return /*#__PURE__*/React__default["default"].createElement(ThemeContext.Provider, _extends({
1543
222
  value: theme
1544
223
  }, rest));
@@ -1567,12 +246,9 @@
1567
246
  const matcher = window.matchMedia(query);
1568
247
 
1569
248
  // Create our handler
1570
- const onChange = _ref => {
1571
- let {
1572
- matches
1573
- } = _ref;
1574
- return setIsMatch(matches);
1575
- };
249
+ const onChange = ({
250
+ matches
251
+ }) => setIsMatch(matches);
1576
252
 
1577
253
  // Listen for changes
1578
254
  matcher.addListener(onChange);
@@ -1588,31 +264,15 @@
1588
264
 
1589
265
  const isServer$1 = typeof window === 'undefined';
1590
266
  function getStatusColor(match, theme) {
1591
- return match.store.isFetching ? theme.active : match.store.status === 'error' ? theme.danger : match.store.status === 'success' ? theme.success : theme.gray;
267
+ return match.store.state.status === 'pending' ? theme.active : match.store.state.status === 'error' ? theme.danger : match.store.state.status === 'success' ? theme.success : theme.gray;
1592
268
  }
1593
-
1594
- // export function getQueryStatusLabel(query: Query) {
1595
- // return query.state.isFetching
1596
- // ? 'fetching'
1597
- // : !query.getObserversCount()
1598
- // ? 'inactive'
1599
- // : query.isStale()
1600
- // ? 'stale'
1601
- // : 'fresh'
1602
- // }
1603
-
1604
- function styled(type, newStyles, queries) {
1605
- if (queries === void 0) {
1606
- queries = {};
1607
- }
1608
- return /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) => {
1609
- let {
1610
- style,
1611
- ...rest
1612
- } = _ref;
269
+ function styled(type, newStyles, queries = {}) {
270
+ return /*#__PURE__*/React__default["default"].forwardRef(({
271
+ style,
272
+ ...rest
273
+ }, ref) => {
1613
274
  const theme = useTheme();
1614
- const mediaStyles = Object.entries(queries).reduce((current, _ref2) => {
1615
- let [key, value] = _ref2;
275
+ const mediaStyles = Object.entries(queries).reduce((current, [key, value]) => {
1616
276
  // eslint-disable-next-line react-hooks/rules-of-hooks
1617
277
  return useMediaQuery(key) ? {
1618
278
  ...current,
@@ -1679,33 +339,6 @@
1679
339
  throw error;
1680
340
  }));
1681
341
  }
1682
- function multiSortBy(arr, accessors) {
1683
- if (accessors === void 0) {
1684
- accessors = [d => d];
1685
- }
1686
- return arr.map((d, i) => [d, i]).sort((_ref3, _ref4) => {
1687
- let [a, ai] = _ref3;
1688
- let [b, bi] = _ref4;
1689
- for (const accessor of accessors) {
1690
- const ao = accessor(a);
1691
- const bo = accessor(b);
1692
- if (typeof ao === 'undefined') {
1693
- if (typeof bo === 'undefined') {
1694
- continue;
1695
- }
1696
- return 1;
1697
- }
1698
- if (ao === bo) {
1699
- continue;
1700
- }
1701
- return ao > bo ? 1 : -1;
1702
- }
1703
- return ai - bi;
1704
- }).map(_ref5 => {
1705
- let [d] = _ref5;
1706
- return d;
1707
- });
1708
- }
1709
342
 
1710
343
  const Panel = styled('div', (_props, theme) => ({
1711
344
  fontSize: 'clamp(12px, 1.5vw, 14px)',
@@ -1764,38 +397,6 @@
1764
397
  const Code = styled('code', {
1765
398
  fontSize: '.9em'
1766
399
  });
1767
- styled('input', (_props, theme) => ({
1768
- backgroundColor: theme.inputBackgroundColor,
1769
- border: 0,
1770
- borderRadius: '.2em',
1771
- color: theme.inputTextColor,
1772
- fontSize: '.9em',
1773
- lineHeight: `1.3`,
1774
- padding: '.3em .4em'
1775
- }));
1776
- styled('select', (_props, theme) => ({
1777
- display: `inline-block`,
1778
- fontSize: `.9em`,
1779
- fontFamily: `sans-serif`,
1780
- fontWeight: 'normal',
1781
- lineHeight: `1.3`,
1782
- padding: `.3em 1.5em .3em .5em`,
1783
- height: 'auto',
1784
- border: 0,
1785
- borderRadius: `.2em`,
1786
- appearance: `none`,
1787
- WebkitAppearance: 'none',
1788
- backgroundColor: theme.inputBackgroundColor,
1789
- backgroundImage: `url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100' fill='%23444444'><polygon points='0,25 100,25 50,75'/></svg>")`,
1790
- backgroundRepeat: `no-repeat`,
1791
- backgroundPosition: `right .55em center`,
1792
- backgroundSize: `.65em auto, 100%`,
1793
- color: theme.inputTextColor
1794
- }), {
1795
- '(max-width: 500px)': {
1796
- display: 'none'
1797
- }
1798
- });
1799
400
 
1800
401
  const Entry = styled('div', {
1801
402
  fontFamily: 'Menlo, monospace',
@@ -1832,20 +433,17 @@
1832
433
  color: 'grey',
1833
434
  fontSize: '.7em'
1834
435
  });
1835
- const Expander = _ref => {
1836
- let {
1837
- expanded,
1838
- style = {}
1839
- } = _ref;
1840
- return /*#__PURE__*/React__namespace.createElement("span", {
1841
- style: {
1842
- display: 'inline-block',
1843
- transition: 'all .1s ease',
1844
- transform: `rotate(${expanded ? 90 : 0}deg) ${style.transform || ''}`,
1845
- ...style
1846
- }
1847
- }, "\u25B6");
1848
- };
436
+ const Expander = ({
437
+ expanded,
438
+ style = {}
439
+ }) => /*#__PURE__*/React__namespace.createElement("span", {
440
+ style: {
441
+ display: 'inline-block',
442
+ transition: 'all .1s ease',
443
+ transform: `rotate(${expanded ? 90 : 0}deg) ${style.transform || ''}`,
444
+ ...style
445
+ }
446
+ }, "\u25B6");
1849
447
  /**
1850
448
  * Chunk elements in the array by size
1851
449
  *
@@ -1865,19 +463,18 @@
1865
463
  }
1866
464
  return result;
1867
465
  }
1868
- const DefaultRenderer = _ref2 => {
1869
- let {
1870
- handleEntry,
1871
- label,
1872
- value,
1873
- subEntries = [],
1874
- subEntryPages = [],
1875
- type,
1876
- expanded = false,
1877
- toggleExpanded,
1878
- pageSize,
1879
- renderer
1880
- } = _ref2;
466
+ const DefaultRenderer = ({
467
+ handleEntry,
468
+ label,
469
+ value,
470
+ subEntries = [],
471
+ subEntryPages = [],
472
+ type,
473
+ expanded = false,
474
+ toggleExpanded,
475
+ pageSize,
476
+ renderer
477
+ }) => {
1881
478
  const [expandedPages, setExpandedPages] = React__namespace.useState([]);
1882
479
  const [valueSnapshot, setValueSnapshot] = React__namespace.useState(undefined);
1883
480
  const refreshValueSnapshot = () => {
@@ -1910,14 +507,13 @@
1910
507
  function isIterable(x) {
1911
508
  return Symbol.iterator in x;
1912
509
  }
1913
- function Explorer(_ref3) {
1914
- let {
1915
- value,
1916
- defaultExpanded,
1917
- renderer = DefaultRenderer,
1918
- pageSize = 100,
1919
- ...rest
1920
- } = _ref3;
510
+ function Explorer({
511
+ value,
512
+ defaultExpanded,
513
+ renderer = DefaultRenderer,
514
+ pageSize = 100,
515
+ ...rest
516
+ }) {
1921
517
  const [expanded, setExpanded] = React__namespace.useState(Boolean(defaultExpanded));
1922
518
  const toggleExpanded = React__namespace.useCallback(() => setExpanded(old => !old), []);
1923
519
  let type = typeof value;
@@ -1925,7 +521,7 @@
1925
521
  const makeProperty = sub => {
1926
522
  const subDefaultExpanded = defaultExpanded === true ? {
1927
523
  [sub.label]: true
1928
- } : defaultExpanded == null ? void 0 : defaultExpanded[sub.label];
524
+ } : defaultExpanded?.[sub.label];
1929
525
  return {
1930
526
  ...sub,
1931
527
  defaultExpanded: subDefaultExpanded
@@ -1945,13 +541,10 @@
1945
541
  }));
1946
542
  } else if (typeof value === 'object' && value !== null) {
1947
543
  type = 'object';
1948
- subEntries = Object.entries(value).map(_ref4 => {
1949
- let [key, val] = _ref4;
1950
- return makeProperty({
1951
- label: key,
1952
- value: val
1953
- });
1954
- });
544
+ subEntries = Object.entries(value).map(([key, val]) => makeProperty({
545
+ label: key,
546
+ value: val
547
+ }));
1955
548
  }
1956
549
  const subEntryPages = chunkArray(subEntries, pageSize);
1957
550
  return renderer({
@@ -2001,16 +594,15 @@
2001
594
  }
2002
595
  }, "ROUTER"));
2003
596
  }
2004
- function TanStackRouterDevtools(_ref) {
2005
- let {
2006
- initialIsOpen,
2007
- panelProps = {},
2008
- closeButtonProps = {},
2009
- toggleButtonProps = {},
2010
- position = 'bottom-left',
2011
- containerElement: Container = 'footer',
2012
- router
2013
- } = _ref;
597
+ function TanStackRouterDevtools({
598
+ initialIsOpen,
599
+ panelProps = {},
600
+ closeButtonProps = {},
601
+ toggleButtonProps = {},
602
+ position = 'bottom-left',
603
+ containerElement: Container = 'footer',
604
+ router
605
+ }) {
2014
606
  const rootRef = React__default["default"].useRef(null);
2015
607
  const panelRef = React__default["default"].useRef(null);
2016
608
  const [isOpen, setIsOpen] = useLocalStorage('tanstackRouterDevtoolsOpen', initialIsOpen);
@@ -2023,12 +615,12 @@
2023
615
 
2024
616
  setIsResizing(true);
2025
617
  const dragInfo = {
2026
- originalHeight: (panelElement == null ? void 0 : panelElement.getBoundingClientRect().height) ?? 0,
618
+ originalHeight: panelElement?.getBoundingClientRect().height ?? 0,
2027
619
  pageY: startEvent.pageY
2028
620
  };
2029
621
  const run = moveEvent => {
2030
622
  const delta = dragInfo.pageY - moveEvent.pageY;
2031
- const newHeight = (dragInfo == null ? void 0 : dragInfo.originalHeight) + delta;
623
+ const newHeight = dragInfo?.originalHeight + delta;
2032
624
  setDevtoolsHeight(newHeight);
2033
625
  if (newHeight < 70) {
2034
626
  setIsOpen(false);
@@ -2074,12 +666,10 @@
2074
666
  }, [isResolvedOpen]);
2075
667
  React__default["default"][isServer ? 'useEffect' : 'useLayoutEffect'](() => {
2076
668
  if (isResolvedOpen) {
2077
- var _rootRef$current, _rootRef$current$pare;
2078
- const previousValue = (_rootRef$current = rootRef.current) == null ? void 0 : (_rootRef$current$pare = _rootRef$current.parentElement) == null ? void 0 : _rootRef$current$pare.style.paddingBottom;
669
+ const previousValue = rootRef.current?.parentElement?.style.paddingBottom;
2079
670
  const run = () => {
2080
- var _panelRef$current, _rootRef$current2;
2081
- const containerHeight = (_panelRef$current = panelRef.current) == null ? void 0 : _panelRef$current.getBoundingClientRect().height;
2082
- if ((_rootRef$current2 = rootRef.current) != null && _rootRef$current2.parentElement) {
671
+ const containerHeight = panelRef.current?.getBoundingClientRect().height;
672
+ if (rootRef.current?.parentElement) {
2083
673
  rootRef.current.parentElement.style.paddingBottom = `${containerHeight}px`;
2084
674
  }
2085
675
  };
@@ -2087,9 +677,8 @@
2087
677
  if (typeof window !== 'undefined') {
2088
678
  window.addEventListener('resize', run);
2089
679
  return () => {
2090
- var _rootRef$current3;
2091
680
  window.removeEventListener('resize', run);
2092
- if ((_rootRef$current3 = rootRef.current) != null && _rootRef$current3.parentElement && typeof previousValue === 'string') {
681
+ if (rootRef.current?.parentElement && typeof previousValue === 'string') {
2093
682
  rootRef.current.parentElement.style.paddingBottom = previousValue;
2094
683
  }
2095
684
  };
@@ -2219,7 +808,6 @@
2219
808
  })) : null);
2220
809
  }
2221
810
  const TanStackRouterDevtoolsPanel = /*#__PURE__*/React__default["default"].forwardRef(function TanStackRouterDevtoolsPanel(props, ref) {
2222
- var _Object$values, _Object$values$find, _router$store$current, _router$store$pending, _router$store$pending2, _last, _last2, _last3, _last4, _last5, _last6;
2223
811
  const {
2224
812
  isOpen = true,
2225
813
  setIsOpen,
@@ -2228,7 +816,7 @@
2228
816
  ...panelProps
2229
817
  } = props;
2230
818
  const routerContextValue = React__default["default"].useContext(routerContext);
2231
- const router = userRouter ?? (routerContextValue == null ? void 0 : routerContextValue.router);
819
+ const router = userRouter ?? routerContextValue?.router;
2232
820
  invariant(router, 'No router was found for the TanStack Router Devtools. Please place the devtools in the <RouterProvider> component tree or pass the router instance to the devtools manually.');
2233
821
  useRouterStore();
2234
822
  const [activeRouteId, setActiveRouteId] = useLocalStorage('tanstackRouterDevtoolsActiveRouteId', '');
@@ -2236,11 +824,22 @@
2236
824
  React__default["default"].useEffect(() => {
2237
825
  setActiveMatchId('');
2238
826
  }, [activeRouteId]);
2239
- const activeMatch = ((_Object$values = Object.values(router.store.matchCache)) == null ? void 0 : (_Object$values$find = _Object$values.find(d => d.match.matchId === activeMatchId)) == null ? void 0 : _Object$values$find.match) ?? ((_router$store$current = router.store.currentMatches) == null ? void 0 : _router$store$current.find(d => d.routeId === activeRouteId));
2240
- const matchCacheValues = multiSortBy(Object.keys(router.store.matchCache).filter(key => {
2241
- const cacheEntry = router.store.matchCache[key];
2242
- return cacheEntry.gc > Date.now();
2243
- }).map(key => router.store.matchCache[key]), [d => d.match.store.isFetching ? -1 : 1, d => -d.match.store.updatedAt]);
827
+ const allMatches = React__default["default"].useMemo(() => [...Object.values(router.store.state.currentMatches), ...Object.values(router.store.state.pendingMatches ?? [])], [router.store.state.currentMatches, router.store.state.pendingMatches]);
828
+ const activeMatch = allMatches?.find(d => d.id === activeMatchId) || allMatches?.find(d => d.route.id === activeRouteId);
829
+
830
+ // const matchCacheValues = multiSortBy(
831
+ // Object.keys(router.store.state.matchCache)
832
+ // .filter((key) => {
833
+ // const cacheEntry = router.store.state.matchCache[key]!
834
+ // return cacheEntry.gc > Date.now()
835
+ // })
836
+ // .map((key) => router.store.state.matchCache[key]!),
837
+ // [
838
+ // (d) => (d.match.store.state.isFetching ? -1 : 1),
839
+ // (d) => -d.match.store.state.updatedAt!,
840
+ // ],
841
+ // )
842
+
2244
843
  return /*#__PURE__*/React__default["default"].createElement(ThemeProvider, {
2245
844
  theme: defaultTheme
2246
845
  }, /*#__PURE__*/React__default["default"].createElement(Panel, _extends({
@@ -2365,12 +964,12 @@
2365
964
  top: 0,
2366
965
  zIndex: 1
2367
966
  }
2368
- }, "Active Matches"), router.store.currentMatches.map((match, i) => {
967
+ }, "Active Matches"), router.store.state.currentMatches.map((match, i) => {
2369
968
  return /*#__PURE__*/React__default["default"].createElement("div", {
2370
- key: match.routeId || i,
969
+ key: match.route.id || i,
2371
970
  role: "button",
2372
- "aria-label": `Open match details for ${match.routeId}`,
2373
- onClick: () => setActiveRouteId(activeRouteId === match.routeId ? '' : match.routeId),
971
+ "aria-label": `Open match details for ${match.route.id}`,
972
+ onClick: () => setActiveRouteId(activeRouteId === match.route.id ? '' : match.route.id),
2374
973
  style: {
2375
974
  display: 'flex',
2376
975
  borderBottom: `solid 1px ${defaultTheme.grayAlt}`,
@@ -2395,8 +994,8 @@
2395
994
  style: {
2396
995
  padding: '.5em'
2397
996
  }
2398
- }, `${match.matchId}`));
2399
- }), (_router$store$pending = router.store.pendingMatches) != null && _router$store$pending.length ? /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("div", {
997
+ }, `${match.id}`));
998
+ }), router.store.state.pendingMatches?.length ? /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("div", {
2400
999
  style: {
2401
1000
  marginTop: '2rem',
2402
1001
  padding: '.5em',
@@ -2405,12 +1004,12 @@
2405
1004
  top: 0,
2406
1005
  zIndex: 1
2407
1006
  }
2408
- }, "Pending Matches"), (_router$store$pending2 = router.store.pendingMatches) == null ? void 0 : _router$store$pending2.map((match, i) => {
1007
+ }, "Pending Matches"), router.store.state.pendingMatches?.map((match, i) => {
2409
1008
  return /*#__PURE__*/React__default["default"].createElement("div", {
2410
- key: match.routeId || i,
1009
+ key: match.route.id || i,
2411
1010
  role: "button",
2412
- "aria-label": `Open match details for ${match.routeId}`,
2413
- onClick: () => setActiveRouteId(activeRouteId === match.routeId ? '' : match.routeId),
1011
+ "aria-label": `Open match details for ${match.route.id}`,
1012
+ onClick: () => setActiveRouteId(activeRouteId === match.route.id ? '' : match.route.id),
2414
1013
  style: {
2415
1014
  display: 'flex',
2416
1015
  borderBottom: `solid 1px ${defaultTheme.grayAlt}`,
@@ -2434,74 +1033,7 @@
2434
1033
  style: {
2435
1034
  padding: '.5em'
2436
1035
  }
2437
- }, `${match.matchId}`));
2438
- })) : null, matchCacheValues.length ? /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("div", {
2439
- style: {
2440
- marginTop: '2rem',
2441
- padding: '.5em',
2442
- background: defaultTheme.backgroundAlt,
2443
- position: 'sticky',
2444
- top: 0,
2445
- bottom: 0,
2446
- zIndex: 1,
2447
- display: 'flex',
2448
- alignItems: 'center',
2449
- justifyContent: 'space-between'
2450
- }
2451
- }, /*#__PURE__*/React__default["default"].createElement("div", null, "Match Cache"), /*#__PURE__*/React__default["default"].createElement(Button, {
2452
- onClick: () => {
2453
- router.setStore(s => s.matchCache = {});
2454
- }
2455
- }, "Clear")), matchCacheValues.map((d, i) => {
2456
- const {
2457
- match,
2458
- gc
2459
- } = d;
2460
- return /*#__PURE__*/React__default["default"].createElement("div", {
2461
- key: match.matchId || i,
2462
- role: "button",
2463
- "aria-label": `Open match details for ${match.matchId}`,
2464
- onClick: () => setActiveMatchId(activeMatchId === match.matchId ? '' : match.matchId),
2465
- style: {
2466
- display: 'flex',
2467
- borderBottom: `solid 1px ${defaultTheme.grayAlt}`,
2468
- cursor: 'pointer',
2469
- background: match === activeMatch ? 'rgba(255,255,255,.1)' : undefined
2470
- }
2471
- }, /*#__PURE__*/React__default["default"].createElement("div", {
2472
- style: {
2473
- display: 'flex',
2474
- flexDirection: 'column',
2475
- padding: '.5rem',
2476
- gap: '.3rem'
2477
- }
2478
- }, /*#__PURE__*/React__default["default"].createElement("div", {
2479
- style: {
2480
- display: 'flex',
2481
- alignItems: 'center',
2482
- gap: '.5rem'
2483
- }
2484
- }, /*#__PURE__*/React__default["default"].createElement("div", {
2485
- style: {
2486
- flex: '0 0 auto',
2487
- width: '1.3rem',
2488
- height: '1.3rem',
2489
- background: getStatusColor(match, defaultTheme),
2490
- alignItems: 'center',
2491
- justifyContent: 'center',
2492
- fontWeight: 'bold',
2493
- borderRadius: '.25rem',
2494
- transition: 'all .2s ease-out'
2495
- }
2496
- }), /*#__PURE__*/React__default["default"].createElement(Code, null, `${match.matchId}`)), /*#__PURE__*/React__default["default"].createElement("span", {
2497
- style: {
2498
- fontSize: '.7rem',
2499
- opacity: '.5',
2500
- lineHeight: 1
2501
- }
2502
- }, "Expires", ' ', formatDistanceStrict(new Date(gc), new Date(), {
2503
- addSuffix: true
2504
- }))));
1036
+ }, `${match.id}`));
2505
1037
  })) : null), activeMatch ? /*#__PURE__*/React__default["default"].createElement(ActivePanel, null, /*#__PURE__*/React__default["default"].createElement("div", {
2506
1038
  style: {
2507
1039
  padding: '.5em',
@@ -2519,19 +1051,15 @@
2519
1051
  style: {
2520
1052
  lineHeight: '1.8em'
2521
1053
  }
2522
- }, JSON.stringify(activeMatch.matchId, null, 2)))), /*#__PURE__*/React__default["default"].createElement("tr", null, /*#__PURE__*/React__default["default"].createElement("td", {
1054
+ }, JSON.stringify(activeMatch.id, null, 2)))), /*#__PURE__*/React__default["default"].createElement("tr", null, /*#__PURE__*/React__default["default"].createElement("td", {
2523
1055
  style: {
2524
1056
  opacity: '.5'
2525
1057
  }
2526
- }, "Status"), /*#__PURE__*/React__default["default"].createElement("td", null, activeMatch.store.status)), /*#__PURE__*/React__default["default"].createElement("tr", null, /*#__PURE__*/React__default["default"].createElement("td", {
1058
+ }, "Status"), /*#__PURE__*/React__default["default"].createElement("td", null, activeMatch.store.state.status)), /*#__PURE__*/React__default["default"].createElement("tr", null, /*#__PURE__*/React__default["default"].createElement("td", {
2527
1059
  style: {
2528
1060
  opacity: '.5'
2529
1061
  }
2530
- }, "Invalid"), /*#__PURE__*/React__default["default"].createElement("td", null, activeMatch.store.isInvalid.toString())), /*#__PURE__*/React__default["default"].createElement("tr", null, /*#__PURE__*/React__default["default"].createElement("td", {
2531
- style: {
2532
- opacity: '.5'
2533
- }
2534
- }, "Last Updated"), /*#__PURE__*/React__default["default"].createElement("td", null, activeMatch.store.updatedAt ? new Date(activeMatch.store.updatedAt).toLocaleTimeString() : 'N/A'))))), /*#__PURE__*/React__default["default"].createElement("div", {
1062
+ }, "Last Updated"), /*#__PURE__*/React__default["default"].createElement("td", null, activeMatch.store.state.updatedAt ? new Date(activeMatch.store.state.updatedAt).toLocaleTimeString() : 'N/A'))))), /*#__PURE__*/React__default["default"].createElement("div", {
2535
1063
  style: {
2536
1064
  background: defaultTheme.backgroundAlt,
2537
1065
  padding: '.5em',
@@ -2545,15 +1073,6 @@
2545
1073
  padding: '0.5em'
2546
1074
  }
2547
1075
  }, /*#__PURE__*/React__default["default"].createElement(Button, {
2548
- type: "button",
2549
- onClick: () => {
2550
- activeMatch.invalidate();
2551
- },
2552
- style: {
2553
- background: defaultTheme.warning,
2554
- color: defaultTheme.inputTextColor
2555
- }
2556
- }, "Invalidate"), ' ', /*#__PURE__*/React__default["default"].createElement(Button, {
2557
1076
  type: "button",
2558
1077
  onClick: () => activeMatch.load(),
2559
1078
  style: {
@@ -2595,36 +1114,13 @@
2595
1114
  bottom: 0,
2596
1115
  zIndex: 1
2597
1116
  }
2598
- }, "All Loader Data"), /*#__PURE__*/React__default["default"].createElement("div", {
2599
- style: {
2600
- padding: '.5em'
2601
- }
2602
- }, Object.keys(((_last = last(router.store.currentMatches)) == null ? void 0 : _last.store.loaderData) || {}).length ? /*#__PURE__*/React__default["default"].createElement(Explorer, {
2603
- value: ((_last2 = last(router.store.currentMatches)) == null ? void 0 : _last2.store.loaderData) || {},
2604
- defaultExpanded: Object.keys(((_last3 = last(router.store.currentMatches)) == null ? void 0 : _last3.store.loaderData) || {}).reduce((obj, next) => {
2605
- obj[next] = {};
2606
- return obj;
2607
- }, {})
2608
- }) : /*#__PURE__*/React__default["default"].createElement("em", {
2609
- style: {
2610
- opacity: 0.5
2611
- }
2612
- }, '{ }')), /*#__PURE__*/React__default["default"].createElement("div", {
2613
- style: {
2614
- padding: '.5em',
2615
- background: defaultTheme.backgroundAlt,
2616
- position: 'sticky',
2617
- top: 0,
2618
- bottom: 0,
2619
- zIndex: 1
2620
- }
2621
1117
  }, "Search Params"), /*#__PURE__*/React__default["default"].createElement("div", {
2622
1118
  style: {
2623
1119
  padding: '.5em'
2624
1120
  }
2625
- }, Object.keys(((_last4 = last(router.store.currentMatches)) == null ? void 0 : _last4.store.search) || {}).length ? /*#__PURE__*/React__default["default"].createElement(Explorer, {
2626
- value: ((_last5 = last(router.store.currentMatches)) == null ? void 0 : _last5.store.search) || {},
2627
- defaultExpanded: Object.keys(((_last6 = last(router.store.currentMatches)) == null ? void 0 : _last6.store.search) || {}).reduce((obj, next) => {
1121
+ }, Object.keys(last(router.store.state.currentMatches)?.store.state.search || {}).length ? /*#__PURE__*/React__default["default"].createElement(Explorer, {
1122
+ value: last(router.store.state.currentMatches)?.store.state.search || {},
1123
+ defaultExpanded: Object.keys(last(router.store.state.currentMatches)?.store.state.search || {}).reduce((obj, next) => {
2628
1124
  obj[next] = {};
2629
1125
  return obj;
2630
1126
  }, {})