@tanstack/react-query-devtools 5.0.0-alpha.6 → 5.0.0-alpha.60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/build/lib/__tests__/devtools.test.d.ts +1 -1
  2. package/build/lib/__tests__/devtools.test.d.ts.map +1 -0
  3. package/build/lib/__tests__/utils.d.ts +2 -1
  4. package/build/lib/__tests__/utils.d.ts.map +1 -0
  5. package/build/lib/devtools.cjs +65 -0
  6. package/build/lib/devtools.cjs.map +1 -0
  7. package/build/lib/devtools.d.ts +11 -91
  8. package/build/lib/devtools.d.ts.map +1 -0
  9. package/build/lib/devtools.js +56 -913
  10. package/build/lib/devtools.js.map +1 -1
  11. package/build/lib/index.cjs +18 -0
  12. package/build/lib/index.cjs.map +1 -0
  13. package/build/lib/index.d.ts +1 -1
  14. package/build/lib/index.d.ts.map +1 -0
  15. package/build/lib/index.js +11 -9
  16. package/build/lib/index.js.map +1 -1
  17. package/build/lib/index.prod.cjs +70 -0
  18. package/build/lib/index.prod.cjs.map +1 -0
  19. package/build/lib/{index.prod.d.ts → index.prod.d.ts/index.d.ts} +1 -1
  20. package/build/lib/index.prod.js +59 -1571
  21. package/build/lib/index.prod.js.map +1 -1
  22. package/package.json +25 -26
  23. package/src/__tests__/devtools.test.tsx +1 -1009
  24. package/src/devtools.tsx +67 -1306
  25. package/src/index.ts +6 -6
  26. package/build/lib/Explorer.d.ts +0 -50
  27. package/build/lib/Explorer.esm.js +0 -253
  28. package/build/lib/Explorer.esm.js.map +0 -1
  29. package/build/lib/Explorer.js +0 -287
  30. package/build/lib/Explorer.js.map +0 -1
  31. package/build/lib/Explorer.mjs +0 -253
  32. package/build/lib/Explorer.mjs.map +0 -1
  33. package/build/lib/Logo.d.ts +0 -1
  34. package/build/lib/Logo.esm.js +0 -32
  35. package/build/lib/Logo.esm.js.map +0 -1
  36. package/build/lib/Logo.js +0 -55
  37. package/build/lib/Logo.js.map +0 -1
  38. package/build/lib/Logo.mjs +0 -32
  39. package/build/lib/Logo.mjs.map +0 -1
  40. package/build/lib/__tests__/Explorer.test.d.ts +0 -1
  41. package/build/lib/_virtual/_rollupPluginBabelHelpers.esm.js +0 -17
  42. package/build/lib/_virtual/_rollupPluginBabelHelpers.esm.js.map +0 -1
  43. package/build/lib/_virtual/_rollupPluginBabelHelpers.js +0 -19
  44. package/build/lib/_virtual/_rollupPluginBabelHelpers.js.map +0 -1
  45. package/build/lib/_virtual/_rollupPluginBabelHelpers.mjs +0 -17
  46. package/build/lib/_virtual/_rollupPluginBabelHelpers.mjs.map +0 -1
  47. package/build/lib/devtools.esm.js +0 -899
  48. package/build/lib/devtools.esm.js.map +0 -1
  49. package/build/lib/devtools.mjs +0 -868
  50. package/build/lib/devtools.mjs.map +0 -1
  51. package/build/lib/index.esm.js +0 -11
  52. package/build/lib/index.esm.js.map +0 -1
  53. package/build/lib/index.mjs +0 -11
  54. package/build/lib/index.mjs.map +0 -1
  55. package/build/lib/index.prod.esm.js +0 -1559
  56. package/build/lib/index.prod.esm.js.map +0 -1
  57. package/build/lib/index.prod.mjs +0 -1528
  58. package/build/lib/index.prod.mjs.map +0 -1
  59. package/build/lib/noop.d.ts +0 -2
  60. package/build/lib/screenreader.d.ts +0 -3
  61. package/build/lib/screenreader.esm.js +0 -17
  62. package/build/lib/screenreader.esm.js.map +0 -1
  63. package/build/lib/screenreader.js +0 -40
  64. package/build/lib/screenreader.js.map +0 -1
  65. package/build/lib/screenreader.mjs +0 -17
  66. package/build/lib/screenreader.mjs.map +0 -1
  67. package/build/lib/styledComponents.d.ts +0 -9
  68. package/build/lib/styledComponents.esm.js +0 -95
  69. package/build/lib/styledComponents.esm.js.map +0 -1
  70. package/build/lib/styledComponents.js +0 -104
  71. package/build/lib/styledComponents.js.map +0 -1
  72. package/build/lib/styledComponents.mjs +0 -95
  73. package/build/lib/styledComponents.mjs.map +0 -1
  74. package/build/lib/theme.d.ts +0 -36
  75. package/build/lib/theme.esm.js +0 -32
  76. package/build/lib/theme.esm.js.map +0 -1
  77. package/build/lib/theme.js +0 -55
  78. package/build/lib/theme.js.map +0 -1
  79. package/build/lib/theme.mjs +0 -32
  80. package/build/lib/theme.mjs.map +0 -1
  81. package/build/lib/useLocalStorage.d.ts +0 -1
  82. package/build/lib/useLocalStorage.esm.js +0 -40
  83. package/build/lib/useLocalStorage.esm.js.map +0 -1
  84. package/build/lib/useLocalStorage.js +0 -63
  85. package/build/lib/useLocalStorage.js.map +0 -1
  86. package/build/lib/useLocalStorage.mjs +0 -40
  87. package/build/lib/useLocalStorage.mjs.map +0 -1
  88. package/build/lib/useMediaQuery.d.ts +0 -1
  89. package/build/lib/useMediaQuery.esm.js +0 -36
  90. package/build/lib/useMediaQuery.esm.js.map +0 -1
  91. package/build/lib/useMediaQuery.js +0 -59
  92. package/build/lib/useMediaQuery.js.map +0 -1
  93. package/build/lib/useMediaQuery.mjs +0 -36
  94. package/build/lib/useMediaQuery.mjs.map +0 -1
  95. package/build/lib/utils.d.ts +0 -79
  96. package/build/lib/utils.esm.js +0 -184
  97. package/build/lib/utils.esm.js.map +0 -1
  98. package/build/lib/utils.js +0 -218
  99. package/build/lib/utils.js.map +0 -1
  100. package/build/lib/utils.mjs +0 -184
  101. package/build/lib/utils.mjs.map +0 -1
  102. package/build/umd/index.development.js +0 -3195
  103. package/build/umd/index.development.js.map +0 -1
  104. package/build/umd/index.production.js +0 -2
  105. package/build/umd/index.production.js.map +0 -1
  106. package/src/Explorer.tsx +0 -385
  107. package/src/Logo.tsx +0 -32
  108. package/src/__tests__/Explorer.test.tsx +0 -150
  109. package/src/noop.ts +0 -7
  110. package/src/screenreader.tsx +0 -16
  111. package/src/styledComponents.ts +0 -110
  112. package/src/theme.tsx +0 -33
  113. package/src/useLocalStorage.ts +0 -52
  114. package/src/useMediaQuery.ts +0 -34
  115. package/src/utils.ts +0 -319
@@ -1,3195 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@tanstack/react-query')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'react', '@tanstack/react-query'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ReactQueryDevtools = {}, global.React, global.ReactQuery));
5
- })(this, (function (exports, React, reactQuery) { 'use strict';
6
-
7
- function _interopNamespaceDefault(e) {
8
- var n = Object.create(null);
9
- if (e) {
10
- Object.keys(e).forEach(function (k) {
11
- if (k !== 'default') {
12
- var d = Object.getOwnPropertyDescriptor(e, k);
13
- Object.defineProperty(n, k, d.get ? d : {
14
- enumerable: true,
15
- get: function () { return e[k]; }
16
- });
17
- }
18
- });
19
- }
20
- n.default = e;
21
- return Object.freeze(n);
22
- }
23
-
24
- var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
25
-
26
- function _extends() {
27
- _extends = Object.assign ? Object.assign.bind() : function (target) {
28
- for (var i = 1; i < arguments.length; i++) {
29
- var source = arguments[i];
30
- for (var key in source) {
31
- if (Object.prototype.hasOwnProperty.call(source, key)) {
32
- target[key] = source[key];
33
- }
34
- }
35
- }
36
- return target;
37
- };
38
- return _extends.apply(this, arguments);
39
- }
40
-
41
- /**
42
- * match-sorter-utils
43
- *
44
- * Copyright (c) TanStack
45
- *
46
- * This source code is licensed under the MIT license found in the
47
- * LICENSE.md file in the root directory of this source tree.
48
- *
49
- * @license MIT
50
- */
51
- const characterMap = {
52
- À: 'A',
53
- Á: 'A',
54
- Â: 'A',
55
- Ã: 'A',
56
- Ä: 'A',
57
- Å: 'A',
58
- Ấ: 'A',
59
- Ắ: 'A',
60
- Ẳ: 'A',
61
- Ẵ: 'A',
62
- Ặ: 'A',
63
- Æ: 'AE',
64
- Ầ: 'A',
65
- Ằ: 'A',
66
- Ȃ: 'A',
67
- Ç: 'C',
68
- Ḉ: 'C',
69
- È: 'E',
70
- É: 'E',
71
- Ê: 'E',
72
- Ë: 'E',
73
- Ế: 'E',
74
- Ḗ: 'E',
75
- Ề: 'E',
76
- Ḕ: 'E',
77
- Ḝ: 'E',
78
- Ȇ: 'E',
79
- Ì: 'I',
80
- Í: 'I',
81
- Î: 'I',
82
- Ï: 'I',
83
- Ḯ: 'I',
84
- Ȋ: 'I',
85
- Ð: 'D',
86
- Ñ: 'N',
87
- Ò: 'O',
88
- Ó: 'O',
89
- Ô: 'O',
90
- Õ: 'O',
91
- Ö: 'O',
92
- Ø: 'O',
93
- Ố: 'O',
94
- Ṍ: 'O',
95
- Ṓ: 'O',
96
- Ȏ: 'O',
97
- Ù: 'U',
98
- Ú: 'U',
99
- Û: 'U',
100
- Ü: 'U',
101
- Ý: 'Y',
102
- à: 'a',
103
- á: 'a',
104
- â: 'a',
105
- ã: 'a',
106
- ä: 'a',
107
- å: 'a',
108
- ấ: 'a',
109
- ắ: 'a',
110
- ẳ: 'a',
111
- ẵ: 'a',
112
- ặ: 'a',
113
- æ: 'ae',
114
- ầ: 'a',
115
- ằ: 'a',
116
- ȃ: 'a',
117
- ç: 'c',
118
- ḉ: 'c',
119
- è: 'e',
120
- é: 'e',
121
- ê: 'e',
122
- ë: 'e',
123
- ế: 'e',
124
- ḗ: 'e',
125
- ề: 'e',
126
- ḕ: 'e',
127
- ḝ: 'e',
128
- ȇ: 'e',
129
- ì: 'i',
130
- í: 'i',
131
- î: 'i',
132
- ï: 'i',
133
- ḯ: 'i',
134
- ȋ: 'i',
135
- ð: 'd',
136
- ñ: 'n',
137
- ò: 'o',
138
- ó: 'o',
139
- ô: 'o',
140
- õ: 'o',
141
- ö: 'o',
142
- ø: 'o',
143
- ố: 'o',
144
- ṍ: 'o',
145
- ṓ: 'o',
146
- ȏ: 'o',
147
- ù: 'u',
148
- ú: 'u',
149
- û: 'u',
150
- ü: 'u',
151
- ý: 'y',
152
- ÿ: 'y',
153
- Ā: 'A',
154
- ā: 'a',
155
- Ă: 'A',
156
- ă: 'a',
157
- Ą: 'A',
158
- ą: 'a',
159
- Ć: 'C',
160
- ć: 'c',
161
- Ĉ: 'C',
162
- ĉ: 'c',
163
- Ċ: 'C',
164
- ċ: 'c',
165
- Č: 'C',
166
- č: 'c',
167
- C̆: 'C',
168
- c̆: 'c',
169
- Ď: 'D',
170
- ď: 'd',
171
- Đ: 'D',
172
- đ: 'd',
173
- Ē: 'E',
174
- ē: 'e',
175
- Ĕ: 'E',
176
- ĕ: 'e',
177
- Ė: 'E',
178
- ė: 'e',
179
- Ę: 'E',
180
- ę: 'e',
181
- Ě: 'E',
182
- ě: 'e',
183
- Ĝ: 'G',
184
- Ǵ: 'G',
185
- ĝ: 'g',
186
- ǵ: 'g',
187
- Ğ: 'G',
188
- ğ: 'g',
189
- Ġ: 'G',
190
- ġ: 'g',
191
- Ģ: 'G',
192
- ģ: 'g',
193
- Ĥ: 'H',
194
- ĥ: 'h',
195
- Ħ: 'H',
196
- ħ: 'h',
197
- Ḫ: 'H',
198
- ḫ: 'h',
199
- Ĩ: 'I',
200
- ĩ: 'i',
201
- Ī: 'I',
202
- ī: 'i',
203
- Ĭ: 'I',
204
- ĭ: 'i',
205
- Į: 'I',
206
- į: 'i',
207
- İ: 'I',
208
- ı: 'i',
209
- IJ: 'IJ',
210
- ij: 'ij',
211
- Ĵ: 'J',
212
- ĵ: 'j',
213
- Ķ: 'K',
214
- ķ: 'k',
215
- Ḱ: 'K',
216
- ḱ: 'k',
217
- K̆: 'K',
218
- k̆: 'k',
219
- Ĺ: 'L',
220
- ĺ: 'l',
221
- Ļ: 'L',
222
- ļ: 'l',
223
- Ľ: 'L',
224
- ľ: 'l',
225
- Ŀ: 'L',
226
- ŀ: 'l',
227
- Ł: 'l',
228
- ł: 'l',
229
- Ḿ: 'M',
230
- ḿ: 'm',
231
- M̆: 'M',
232
- m̆: 'm',
233
- Ń: 'N',
234
- ń: 'n',
235
- Ņ: 'N',
236
- ņ: 'n',
237
- Ň: 'N',
238
- ň: 'n',
239
- ʼn: 'n',
240
- N̆: 'N',
241
- n̆: 'n',
242
- Ō: 'O',
243
- ō: 'o',
244
- Ŏ: 'O',
245
- ŏ: 'o',
246
- Ő: 'O',
247
- ő: 'o',
248
- Œ: 'OE',
249
- œ: 'oe',
250
- P̆: 'P',
251
- p̆: 'p',
252
- Ŕ: 'R',
253
- ŕ: 'r',
254
- Ŗ: 'R',
255
- ŗ: 'r',
256
- Ř: 'R',
257
- ř: 'r',
258
- R̆: 'R',
259
- r̆: 'r',
260
- Ȓ: 'R',
261
- ȓ: 'r',
262
- Ś: 'S',
263
- ś: 's',
264
- Ŝ: 'S',
265
- ŝ: 's',
266
- Ş: 'S',
267
- Ș: 'S',
268
- ș: 's',
269
- ş: 's',
270
- Š: 'S',
271
- š: 's',
272
- Ţ: 'T',
273
- ţ: 't',
274
- ț: 't',
275
- Ț: 'T',
276
- Ť: 'T',
277
- ť: 't',
278
- Ŧ: 'T',
279
- ŧ: 't',
280
- T̆: 'T',
281
- t̆: 't',
282
- Ũ: 'U',
283
- ũ: 'u',
284
- Ū: 'U',
285
- ū: 'u',
286
- Ŭ: 'U',
287
- ŭ: 'u',
288
- Ů: 'U',
289
- ů: 'u',
290
- Ű: 'U',
291
- ű: 'u',
292
- Ų: 'U',
293
- ų: 'u',
294
- Ȗ: 'U',
295
- ȗ: 'u',
296
- V̆: 'V',
297
- v̆: 'v',
298
- Ŵ: 'W',
299
- ŵ: 'w',
300
- Ẃ: 'W',
301
- ẃ: 'w',
302
- X̆: 'X',
303
- x̆: 'x',
304
- Ŷ: 'Y',
305
- ŷ: 'y',
306
- Ÿ: 'Y',
307
- Y̆: 'Y',
308
- y̆: 'y',
309
- Ź: 'Z',
310
- ź: 'z',
311
- Ż: 'Z',
312
- ż: 'z',
313
- Ž: 'Z',
314
- ž: 'z',
315
- ſ: 's',
316
- ƒ: 'f',
317
- Ơ: 'O',
318
- ơ: 'o',
319
- Ư: 'U',
320
- ư: 'u',
321
- Ǎ: 'A',
322
- ǎ: 'a',
323
- Ǐ: 'I',
324
- ǐ: 'i',
325
- Ǒ: 'O',
326
- ǒ: 'o',
327
- Ǔ: 'U',
328
- ǔ: 'u',
329
- Ǖ: 'U',
330
- ǖ: 'u',
331
- Ǘ: 'U',
332
- ǘ: 'u',
333
- Ǚ: 'U',
334
- ǚ: 'u',
335
- Ǜ: 'U',
336
- ǜ: 'u',
337
- Ứ: 'U',
338
- ứ: 'u',
339
- Ṹ: 'U',
340
- ṹ: 'u',
341
- Ǻ: 'A',
342
- ǻ: 'a',
343
- Ǽ: 'AE',
344
- ǽ: 'ae',
345
- Ǿ: 'O',
346
- ǿ: 'o',
347
- Þ: 'TH',
348
- þ: 'th',
349
- Ṕ: 'P',
350
- ṕ: 'p',
351
- Ṥ: 'S',
352
- ṥ: 's',
353
- X́: 'X',
354
- x́: 'x',
355
- Ѓ: 'Г',
356
- ѓ: 'г',
357
- Ќ: 'К',
358
- ќ: 'к',
359
- A̋: 'A',
360
- a̋: 'a',
361
- E̋: 'E',
362
- e̋: 'e',
363
- I̋: 'I',
364
- i̋: 'i',
365
- Ǹ: 'N',
366
- ǹ: 'n',
367
- Ồ: 'O',
368
- ồ: 'o',
369
- Ṑ: 'O',
370
- ṑ: 'o',
371
- Ừ: 'U',
372
- ừ: 'u',
373
- Ẁ: 'W',
374
- ẁ: 'w',
375
- Ỳ: 'Y',
376
- ỳ: 'y',
377
- Ȁ: 'A',
378
- ȁ: 'a',
379
- Ȅ: 'E',
380
- ȅ: 'e',
381
- Ȉ: 'I',
382
- ȉ: 'i',
383
- Ȍ: 'O',
384
- ȍ: 'o',
385
- Ȑ: 'R',
386
- ȑ: 'r',
387
- Ȕ: 'U',
388
- ȕ: 'u',
389
- B̌: 'B',
390
- b̌: 'b',
391
- Č̣: 'C',
392
- č̣: 'c',
393
- Ê̌: 'E',
394
- ê̌: 'e',
395
- F̌: 'F',
396
- f̌: 'f',
397
- Ǧ: 'G',
398
- ǧ: 'g',
399
- Ȟ: 'H',
400
- ȟ: 'h',
401
- J̌: 'J',
402
- ǰ: 'j',
403
- Ǩ: 'K',
404
- ǩ: 'k',
405
- M̌: 'M',
406
- m̌: 'm',
407
- P̌: 'P',
408
- p̌: 'p',
409
- Q̌: 'Q',
410
- q̌: 'q',
411
- Ř̩: 'R',
412
- ř̩: 'r',
413
- Ṧ: 'S',
414
- ṧ: 's',
415
- V̌: 'V',
416
- v̌: 'v',
417
- W̌: 'W',
418
- w̌: 'w',
419
- X̌: 'X',
420
- x̌: 'x',
421
- Y̌: 'Y',
422
- y̌: 'y',
423
- A̧: 'A',
424
- a̧: 'a',
425
- B̧: 'B',
426
- b̧: 'b',
427
- Ḑ: 'D',
428
- ḑ: 'd',
429
- Ȩ: 'E',
430
- ȩ: 'e',
431
- Ɛ̧: 'E',
432
- ɛ̧: 'e',
433
- Ḩ: 'H',
434
- ḩ: 'h',
435
- I̧: 'I',
436
- i̧: 'i',
437
- Ɨ̧: 'I',
438
- ɨ̧: 'i',
439
- M̧: 'M',
440
- m̧: 'm',
441
- O̧: 'O',
442
- o̧: 'o',
443
- Q̧: 'Q',
444
- q̧: 'q',
445
- U̧: 'U',
446
- u̧: 'u',
447
- X̧: 'X',
448
- x̧: 'x',
449
- Z̧: 'Z',
450
- z̧: 'z'
451
- };
452
- const chars = Object.keys(characterMap).join('|');
453
- const allAccents = new RegExp(chars, 'g');
454
- function removeAccents(str) {
455
- return str.replace(allAccents, match => {
456
- return characterMap[match];
457
- });
458
- }
459
-
460
- /**
461
- * @name match-sorter
462
- * @license MIT license.
463
- * @copyright (c) 2099 Kent C. Dodds
464
- * @author Kent C. Dodds <me@kentcdodds.com> (https://kentcdodds.com)
465
- */
466
- const rankings = {
467
- CASE_SENSITIVE_EQUAL: 7,
468
- EQUAL: 6,
469
- STARTS_WITH: 5,
470
- WORD_STARTS_WITH: 4,
471
- CONTAINS: 3,
472
- ACRONYM: 2,
473
- MATCHES: 1,
474
- NO_MATCH: 0
475
- };
476
- /**
477
- * Gets the highest ranking for value for the given item based on its values for the given keys
478
- * @param {*} item - the item to rank
479
- * @param {Array} keys - the keys to get values from the item for the ranking
480
- * @param {String} value - the value to rank against
481
- * @param {Object} options - options to control the ranking
482
- * @return {{rank: Number, accessorIndex: Number, accessorThreshold: Number}} - the highest ranking
483
- */
484
- function rankItem(item, value, options) {
485
- var _options$threshold;
486
- options = options || {};
487
- options.threshold = (_options$threshold = options.threshold) != null ? _options$threshold : rankings.MATCHES;
488
- if (!options.accessors) {
489
- // if keys is not specified, then we assume the item given is ready to be matched
490
- const rank = getMatchRanking(item, value, options);
491
- return {
492
- // ends up being duplicate of 'item' in matches but consistent
493
- rankedValue: item,
494
- rank,
495
- accessorIndex: -1,
496
- accessorThreshold: options.threshold,
497
- passed: rank >= options.threshold
498
- };
499
- }
500
- const valuesToRank = getAllValuesToRank(item, options.accessors);
501
- const rankingInfo = {
502
- rankedValue: item,
503
- rank: rankings.NO_MATCH,
504
- accessorIndex: -1,
505
- accessorThreshold: options.threshold,
506
- passed: false
507
- };
508
- for (let i = 0; i < valuesToRank.length; i++) {
509
- const rankValue = valuesToRank[i];
510
- let newRank = getMatchRanking(rankValue.itemValue, value, options);
511
- const {
512
- minRanking,
513
- maxRanking,
514
- threshold = options.threshold
515
- } = rankValue.attributes;
516
- if (newRank < minRanking && newRank >= rankings.MATCHES) {
517
- newRank = minRanking;
518
- } else if (newRank > maxRanking) {
519
- newRank = maxRanking;
520
- }
521
- newRank = Math.min(newRank, maxRanking);
522
- if (newRank >= threshold && newRank > rankingInfo.rank) {
523
- rankingInfo.rank = newRank;
524
- rankingInfo.passed = true;
525
- rankingInfo.accessorIndex = i;
526
- rankingInfo.accessorThreshold = threshold;
527
- rankingInfo.rankedValue = rankValue.itemValue;
528
- }
529
- }
530
- return rankingInfo;
531
- }
532
-
533
- /**
534
- * Gives a rankings score based on how well the two strings match.
535
- * @param {String} testString - the string to test against
536
- * @param {String} stringToRank - the string to rank
537
- * @param {Object} options - options for the match (like keepDiacritics for comparison)
538
- * @returns {Number} the ranking for how well stringToRank matches testString
539
- */
540
- function getMatchRanking(testString, stringToRank, options) {
541
- testString = prepareValueForComparison(testString, options);
542
- stringToRank = prepareValueForComparison(stringToRank, options);
543
-
544
- // too long
545
- if (stringToRank.length > testString.length) {
546
- return rankings.NO_MATCH;
547
- }
548
-
549
- // case sensitive equals
550
- if (testString === stringToRank) {
551
- return rankings.CASE_SENSITIVE_EQUAL;
552
- }
553
-
554
- // Lower casing before further comparison
555
- testString = testString.toLowerCase();
556
- stringToRank = stringToRank.toLowerCase();
557
-
558
- // case insensitive equals
559
- if (testString === stringToRank) {
560
- return rankings.EQUAL;
561
- }
562
-
563
- // starts with
564
- if (testString.startsWith(stringToRank)) {
565
- return rankings.STARTS_WITH;
566
- }
567
-
568
- // word starts with
569
- if (testString.includes(` ${stringToRank}`)) {
570
- return rankings.WORD_STARTS_WITH;
571
- }
572
-
573
- // contains
574
- if (testString.includes(stringToRank)) {
575
- return rankings.CONTAINS;
576
- } else if (stringToRank.length === 1) {
577
- // If the only character in the given stringToRank
578
- // isn't even contained in the testString, then
579
- // it's definitely not a match.
580
- return rankings.NO_MATCH;
581
- }
582
-
583
- // acronym
584
- if (getAcronym(testString).includes(stringToRank)) {
585
- return rankings.ACRONYM;
586
- }
587
-
588
- // will return a number between rankings.MATCHES and
589
- // rankings.MATCHES + 1 depending on how close of a match it is.
590
- return getClosenessRanking(testString, stringToRank);
591
- }
592
-
593
- /**
594
- * Generates an acronym for a string.
595
- *
596
- * @param {String} string the string for which to produce the acronym
597
- * @returns {String} the acronym
598
- */
599
- function getAcronym(string) {
600
- let acronym = '';
601
- const wordsInString = string.split(' ');
602
- wordsInString.forEach(wordInString => {
603
- const splitByHyphenWords = wordInString.split('-');
604
- splitByHyphenWords.forEach(splitByHyphenWord => {
605
- acronym += splitByHyphenWord.substr(0, 1);
606
- });
607
- });
608
- return acronym;
609
- }
610
-
611
- /**
612
- * Returns a score based on how spread apart the
613
- * characters from the stringToRank are within the testString.
614
- * A number close to rankings.MATCHES represents a loose match. A number close
615
- * to rankings.MATCHES + 1 represents a tighter match.
616
- * @param {String} testString - the string to test against
617
- * @param {String} stringToRank - the string to rank
618
- * @returns {Number} the number between rankings.MATCHES and
619
- * rankings.MATCHES + 1 for how well stringToRank matches testString
620
- */
621
- function getClosenessRanking(testString, stringToRank) {
622
- let matchingInOrderCharCount = 0;
623
- let charNumber = 0;
624
- function findMatchingCharacter(matchChar, string, index) {
625
- for (let j = index, J = string.length; j < J; j++) {
626
- const stringChar = string[j];
627
- if (stringChar === matchChar) {
628
- matchingInOrderCharCount += 1;
629
- return j + 1;
630
- }
631
- }
632
- return -1;
633
- }
634
- function getRanking(spread) {
635
- const spreadPercentage = 1 / spread;
636
- const inOrderPercentage = matchingInOrderCharCount / stringToRank.length;
637
- const ranking = rankings.MATCHES + inOrderPercentage * spreadPercentage;
638
- return ranking;
639
- }
640
- const firstIndex = findMatchingCharacter(stringToRank[0], testString, 0);
641
- if (firstIndex < 0) {
642
- return rankings.NO_MATCH;
643
- }
644
- charNumber = firstIndex;
645
- for (let i = 1, I = stringToRank.length; i < I; i++) {
646
- const matchChar = stringToRank[i];
647
- charNumber = findMatchingCharacter(matchChar, testString, charNumber);
648
- const found = charNumber > -1;
649
- if (!found) {
650
- return rankings.NO_MATCH;
651
- }
652
- }
653
- const spread = charNumber - firstIndex;
654
- return getRanking(spread);
655
- }
656
-
657
- /**
658
- * Prepares value for comparison by stringifying it, removing diacritics (if specified)
659
- * @param {String} value - the value to clean
660
- * @param {Object} options - {keepDiacritics: whether to remove diacritics}
661
- * @return {String} the prepared value
662
- */
663
- function prepareValueForComparison(value, _ref) {
664
- let {
665
- keepDiacritics
666
- } = _ref;
667
- // value might not actually be a string at this point (we don't get to choose)
668
- // so part of preparing the value for comparison is ensure that it is a string
669
- value = `${value}`; // toString
670
- if (!keepDiacritics) {
671
- value = removeAccents(value);
672
- }
673
- return value;
674
- }
675
-
676
- /**
677
- * Gets value for key in item at arbitrarily nested keypath
678
- * @param {Object} item - the item
679
- * @param {Object|Function} key - the potentially nested keypath or property callback
680
- * @return {Array} - an array containing the value(s) at the nested keypath
681
- */
682
- function getItemValues(item, accessor) {
683
- let accessorFn = accessor;
684
- if (typeof accessor === 'object') {
685
- accessorFn = accessor.accessor;
686
- }
687
- const value = accessorFn(item);
688
-
689
- // because `value` can also be undefined
690
- if (value == null) {
691
- return [];
692
- }
693
- if (Array.isArray(value)) {
694
- return value;
695
- }
696
- return [String(value)];
697
- }
698
-
699
- /**
700
- * Gets all the values for the given keys in the given item and returns an array of those values
701
- * @param item - the item from which the values will be retrieved
702
- * @param keys - the keys to use to retrieve the values
703
- * @return objects with {itemValue, attributes}
704
- */
705
- function getAllValuesToRank(item, accessors) {
706
- const allValues = [];
707
- for (let j = 0, J = accessors.length; j < J; j++) {
708
- const accessor = accessors[j];
709
- const attributes = getAccessorAttributes(accessor);
710
- const itemValues = getItemValues(item, accessor);
711
- for (let i = 0, I = itemValues.length; i < I; i++) {
712
- allValues.push({
713
- itemValue: itemValues[i],
714
- attributes
715
- });
716
- }
717
- }
718
- return allValues;
719
- }
720
- const defaultKeyAttributes = {
721
- maxRanking: Infinity,
722
- minRanking: -Infinity
723
- };
724
- /**
725
- * Gets all the attributes for the given accessor
726
- * @param accessor - the accessor from which the attributes will be retrieved
727
- * @return object containing the accessor's attributes
728
- */
729
- function getAccessorAttributes(accessor) {
730
- if (typeof accessor === 'function') {
731
- return defaultKeyAttributes;
732
- }
733
- return {
734
- ...defaultKeyAttributes,
735
- ...accessor
736
- };
737
- }
738
-
739
- const getItem = key => {
740
- try {
741
- const itemValue = localStorage.getItem(key);
742
- if (typeof itemValue === 'string') {
743
- return JSON.parse(itemValue);
744
- }
745
- return undefined;
746
- } catch {
747
- return undefined;
748
- }
749
- };
750
- function useLocalStorage(key, defaultValue) {
751
- const [value, setValue] = React__namespace.useState();
752
- React__namespace.useEffect(() => {
753
- const initialValue = getItem(key);
754
- if (typeof initialValue === 'undefined' || initialValue === null) {
755
- setValue(typeof defaultValue === 'function' ? defaultValue() : defaultValue);
756
- } else {
757
- setValue(initialValue);
758
- }
759
- }, [defaultValue, key]);
760
- const setter = React__namespace.useCallback(updater => {
761
- setValue(old => {
762
- let newVal = updater;
763
- if (typeof updater == 'function') {
764
- newVal = updater(old);
765
- }
766
- try {
767
- localStorage.setItem(key, JSON.stringify(newVal));
768
- } catch {}
769
- return newVal;
770
- });
771
- }, [key]);
772
- return [value, setter];
773
- }
774
-
775
- var DoubleIndexedKV = /** @class */ (function () {
776
- function DoubleIndexedKV() {
777
- this.keyToValue = new Map();
778
- this.valueToKey = new Map();
779
- }
780
- DoubleIndexedKV.prototype.set = function (key, value) {
781
- this.keyToValue.set(key, value);
782
- this.valueToKey.set(value, key);
783
- };
784
- DoubleIndexedKV.prototype.getByKey = function (key) {
785
- return this.keyToValue.get(key);
786
- };
787
- DoubleIndexedKV.prototype.getByValue = function (value) {
788
- return this.valueToKey.get(value);
789
- };
790
- DoubleIndexedKV.prototype.clear = function () {
791
- this.keyToValue.clear();
792
- this.valueToKey.clear();
793
- };
794
- return DoubleIndexedKV;
795
- }());
796
-
797
- var Registry = /** @class */ (function () {
798
- function Registry(generateIdentifier) {
799
- this.generateIdentifier = generateIdentifier;
800
- this.kv = new DoubleIndexedKV();
801
- }
802
- Registry.prototype.register = function (value, identifier) {
803
- if (this.kv.getByValue(value)) {
804
- return;
805
- }
806
- if (!identifier) {
807
- identifier = this.generateIdentifier(value);
808
- }
809
- {
810
- var alreadyRegistered = this.kv.getByKey(identifier);
811
- if (alreadyRegistered && alreadyRegistered !== value) {
812
- console.debug("Ambiguous class \"" + identifier + "\", provide a unique identifier.");
813
- }
814
- }
815
- this.kv.set(identifier, value);
816
- };
817
- Registry.prototype.clear = function () {
818
- this.kv.clear();
819
- };
820
- Registry.prototype.getIdentifier = function (value) {
821
- return this.kv.getByValue(value);
822
- };
823
- Registry.prototype.getValue = function (identifier) {
824
- return this.kv.getByKey(identifier);
825
- };
826
- return Registry;
827
- }());
828
-
829
- var __extends = (undefined && undefined.__extends) || (function () {
830
- var extendStatics = function (d, b) {
831
- extendStatics = Object.setPrototypeOf ||
832
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
833
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
834
- return extendStatics(d, b);
835
- };
836
- return function (d, b) {
837
- if (typeof b !== "function" && b !== null)
838
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
839
- extendStatics(d, b);
840
- function __() { this.constructor = d; }
841
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
842
- };
843
- })();
844
- var _ClassRegistry = /** @class */ (function (_super) {
845
- __extends(_ClassRegistry, _super);
846
- function _ClassRegistry() {
847
- var _this = _super.call(this, function (c) { return c.name; }) || this;
848
- _this.classToAllowedProps = new Map();
849
- return _this;
850
- }
851
- _ClassRegistry.prototype.register = function (value, options) {
852
- if (typeof options === 'object') {
853
- if (options.allowProps) {
854
- this.classToAllowedProps.set(value, options.allowProps);
855
- }
856
- _super.prototype.register.call(this, value, options.identifier);
857
- }
858
- else {
859
- _super.prototype.register.call(this, value, options);
860
- }
861
- };
862
- _ClassRegistry.prototype.getAllowedProps = function (value) {
863
- return this.classToAllowedProps.get(value);
864
- };
865
- return _ClassRegistry;
866
- }(Registry));
867
- var ClassRegistry = new _ClassRegistry();
868
-
869
- var SymbolRegistry = new Registry(function (s) { var _a; return (_a = s.description) !== null && _a !== void 0 ? _a : ''; });
870
-
871
- var __read$3 = (undefined && undefined.__read) || function (o, n) {
872
- var m = typeof Symbol === "function" && o[Symbol.iterator];
873
- if (!m) return o;
874
- var i = m.call(o), r, ar = [], e;
875
- try {
876
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
877
- }
878
- catch (error) { e = { error: error }; }
879
- finally {
880
- try {
881
- if (r && !r.done && (m = i["return"])) m.call(i);
882
- }
883
- finally { if (e) throw e.error; }
884
- }
885
- return ar;
886
- };
887
- function valuesOfObj(record) {
888
- if ('values' in Object) {
889
- // eslint-disable-next-line es5/no-es6-methods
890
- return Object.values(record);
891
- }
892
- var values = [];
893
- // eslint-disable-next-line no-restricted-syntax
894
- for (var key in record) {
895
- if (record.hasOwnProperty(key)) {
896
- values.push(record[key]);
897
- }
898
- }
899
- return values;
900
- }
901
- function find(record, predicate) {
902
- var values = valuesOfObj(record);
903
- if ('find' in values) {
904
- // eslint-disable-next-line es5/no-es6-methods
905
- return values.find(predicate);
906
- }
907
- var valuesNotNever = values;
908
- for (var i = 0; i < valuesNotNever.length; i++) {
909
- var value = valuesNotNever[i];
910
- if (predicate(value)) {
911
- return value;
912
- }
913
- }
914
- return undefined;
915
- }
916
- function forEach(record, run) {
917
- Object.entries(record).forEach(function (_a) {
918
- var _b = __read$3(_a, 2), key = _b[0], value = _b[1];
919
- return run(value, key);
920
- });
921
- }
922
- function includes(arr, value) {
923
- return arr.indexOf(value) !== -1;
924
- }
925
- function findArr(record, predicate) {
926
- for (var i = 0; i < record.length; i++) {
927
- var value = record[i];
928
- if (predicate(value)) {
929
- return value;
930
- }
931
- }
932
- return undefined;
933
- }
934
-
935
- var transfomers = {};
936
- var CustomTransformerRegistry = {
937
- register: function (transformer) {
938
- transfomers[transformer.name] = transformer;
939
- },
940
- findApplicable: function (v) {
941
- return find(transfomers, function (transformer) { return transformer.isApplicable(v); });
942
- },
943
- findByName: function (name) {
944
- return transfomers[name];
945
- }
946
- };
947
-
948
- var __read$2 = (undefined && undefined.__read) || function (o, n) {
949
- var m = typeof Symbol === "function" && o[Symbol.iterator];
950
- if (!m) return o;
951
- var i = m.call(o), r, ar = [], e;
952
- try {
953
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
954
- }
955
- catch (error) { e = { error: error }; }
956
- finally {
957
- try {
958
- if (r && !r.done && (m = i["return"])) m.call(i);
959
- }
960
- finally { if (e) throw e.error; }
961
- }
962
- return ar;
963
- };
964
- var __spreadArray$2 = (undefined && undefined.__spreadArray) || function (to, from) {
965
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
966
- to[j] = from[i];
967
- return to;
968
- };
969
- var allowedErrorProps = [];
970
- var allowErrorProps = function () {
971
- var props = [];
972
- for (var _i = 0; _i < arguments.length; _i++) {
973
- props[_i] = arguments[_i];
974
- }
975
- allowedErrorProps.push.apply(allowedErrorProps, __spreadArray$2([], __read$2(props)));
976
- };
977
-
978
- var getType$1 = function (payload) {
979
- return Object.prototype.toString.call(payload).slice(8, -1);
980
- };
981
- var isUndefined = function (payload) {
982
- return typeof payload === 'undefined';
983
- };
984
- var isNull = function (payload) { return payload === null; };
985
- var isPlainObject$1 = function (payload) {
986
- if (getType$1(payload) !== 'Object')
987
- return false;
988
- if (Object.getPrototypeOf(payload) === null)
989
- return true;
990
- if (payload === Object.prototype)
991
- return false;
992
- return (payload.constructor === Object &&
993
- Object.getPrototypeOf(payload) === Object.prototype);
994
- };
995
- var isEmptyObject = function (payload) {
996
- return isPlainObject$1(payload) && Object.keys(payload).length === 0;
997
- };
998
- var isArray$1 = function (payload) {
999
- return Array.isArray(payload);
1000
- };
1001
- var isString = function (payload) {
1002
- return typeof payload === 'string';
1003
- };
1004
- var isNumber = function (payload) {
1005
- return typeof payload === 'number' && !isNaN(payload);
1006
- };
1007
- var isBoolean = function (payload) {
1008
- return typeof payload === 'boolean';
1009
- };
1010
- var isRegExp = function (payload) {
1011
- return payload instanceof RegExp;
1012
- };
1013
- var isMap = function (payload) {
1014
- return payload instanceof Map;
1015
- };
1016
- var isSet = function (payload) {
1017
- return payload instanceof Set;
1018
- };
1019
- var isSymbol = function (payload) {
1020
- return getType$1(payload) === 'Symbol';
1021
- };
1022
- var isDate = function (payload) {
1023
- return payload instanceof Date && !isNaN(payload.valueOf());
1024
- };
1025
- var isError = function (payload) {
1026
- return payload instanceof Error;
1027
- };
1028
- var isNaNValue = function (payload) {
1029
- return typeof payload === 'number' && isNaN(payload);
1030
- };
1031
- var isPrimitive = function (payload) {
1032
- return isBoolean(payload) ||
1033
- isNull(payload) ||
1034
- isUndefined(payload) ||
1035
- isNumber(payload) ||
1036
- isString(payload) ||
1037
- isSymbol(payload);
1038
- };
1039
- var isBigint = function (payload) {
1040
- return typeof payload === 'bigint';
1041
- };
1042
- var isInfinite = function (payload) {
1043
- return payload === Infinity || payload === -Infinity;
1044
- };
1045
- var isTypedArray = function (payload) {
1046
- return ArrayBuffer.isView(payload) && !(payload instanceof DataView);
1047
- };
1048
- var isURL = function (payload) { return payload instanceof URL; };
1049
-
1050
- var escapeKey = function (key) { return key.replace(/\./g, '\\.'); };
1051
- var stringifyPath = function (path) {
1052
- return path
1053
- .map(String)
1054
- .map(escapeKey)
1055
- .join('.');
1056
- };
1057
- var parsePath = function (string) {
1058
- var result = [];
1059
- var segment = '';
1060
- for (var i = 0; i < string.length; i++) {
1061
- var char = string.charAt(i);
1062
- var isEscapedDot = char === '\\' && string.charAt(i + 1) === '.';
1063
- if (isEscapedDot) {
1064
- segment += '.';
1065
- i++;
1066
- continue;
1067
- }
1068
- var isEndOfSegment = char === '.';
1069
- if (isEndOfSegment) {
1070
- result.push(segment);
1071
- segment = '';
1072
- continue;
1073
- }
1074
- segment += char;
1075
- }
1076
- var lastSegment = segment;
1077
- result.push(lastSegment);
1078
- return result;
1079
- };
1080
-
1081
- var __assign$1 = (undefined && undefined.__assign) || function () {
1082
- __assign$1 = Object.assign || function(t) {
1083
- for (var s, i = 1, n = arguments.length; i < n; i++) {
1084
- s = arguments[i];
1085
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
1086
- t[p] = s[p];
1087
- }
1088
- return t;
1089
- };
1090
- return __assign$1.apply(this, arguments);
1091
- };
1092
- var __read$1 = (undefined && undefined.__read) || function (o, n) {
1093
- var m = typeof Symbol === "function" && o[Symbol.iterator];
1094
- if (!m) return o;
1095
- var i = m.call(o), r, ar = [], e;
1096
- try {
1097
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
1098
- }
1099
- catch (error) { e = { error: error }; }
1100
- finally {
1101
- try {
1102
- if (r && !r.done && (m = i["return"])) m.call(i);
1103
- }
1104
- finally { if (e) throw e.error; }
1105
- }
1106
- return ar;
1107
- };
1108
- var __spreadArray$1 = (undefined && undefined.__spreadArray) || function (to, from) {
1109
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
1110
- to[j] = from[i];
1111
- return to;
1112
- };
1113
- function simpleTransformation(isApplicable, annotation, transform, untransform) {
1114
- return {
1115
- isApplicable: isApplicable,
1116
- annotation: annotation,
1117
- transform: transform,
1118
- untransform: untransform
1119
- };
1120
- }
1121
- var simpleRules = [
1122
- simpleTransformation(isUndefined, 'undefined', function () { return null; }, function () { return undefined; }),
1123
- simpleTransformation(isBigint, 'bigint', function (v) { return v.toString(); }, function (v) {
1124
- if (typeof BigInt !== 'undefined') {
1125
- return BigInt(v);
1126
- }
1127
- console.error('Please add a BigInt polyfill.');
1128
- return v;
1129
- }),
1130
- simpleTransformation(isDate, 'Date', function (v) { return v.toISOString(); }, function (v) { return new Date(v); }),
1131
- simpleTransformation(isError, 'Error', function (v) {
1132
- var baseError = {
1133
- name: v.name,
1134
- message: v.message
1135
- };
1136
- allowedErrorProps.forEach(function (prop) {
1137
- baseError[prop] = v[prop];
1138
- });
1139
- return baseError;
1140
- }, function (v) {
1141
- var e = new Error(v.message);
1142
- e.name = v.name;
1143
- e.stack = v.stack;
1144
- allowedErrorProps.forEach(function (prop) {
1145
- e[prop] = v[prop];
1146
- });
1147
- return e;
1148
- }),
1149
- simpleTransformation(isRegExp, 'regexp', function (v) { return '' + v; }, function (regex) {
1150
- var body = regex.slice(1, regex.lastIndexOf('/'));
1151
- var flags = regex.slice(regex.lastIndexOf('/') + 1);
1152
- return new RegExp(body, flags);
1153
- }),
1154
- simpleTransformation(isSet, 'set',
1155
- // (sets only exist in es6+)
1156
- // eslint-disable-next-line es5/no-es6-methods
1157
- function (v) { return __spreadArray$1([], __read$1(v.values())); }, function (v) { return new Set(v); }),
1158
- simpleTransformation(isMap, 'map', function (v) { return __spreadArray$1([], __read$1(v.entries())); }, function (v) { return new Map(v); }),
1159
- simpleTransformation(function (v) { return isNaNValue(v) || isInfinite(v); }, 'number', function (v) {
1160
- if (isNaNValue(v)) {
1161
- return 'NaN';
1162
- }
1163
- if (v > 0) {
1164
- return 'Infinity';
1165
- }
1166
- else {
1167
- return '-Infinity';
1168
- }
1169
- }, Number),
1170
- simpleTransformation(function (v) { return v === 0 && 1 / v === -Infinity; }, 'number', function () {
1171
- return '-0';
1172
- }, Number),
1173
- simpleTransformation(isURL, 'URL', function (v) { return v.toString(); }, function (v) { return new URL(v); }),
1174
- ];
1175
- function compositeTransformation(isApplicable, annotation, transform, untransform) {
1176
- return {
1177
- isApplicable: isApplicable,
1178
- annotation: annotation,
1179
- transform: transform,
1180
- untransform: untransform
1181
- };
1182
- }
1183
- var symbolRule = compositeTransformation(function (s) {
1184
- if (isSymbol(s)) {
1185
- var isRegistered = !!SymbolRegistry.getIdentifier(s);
1186
- return isRegistered;
1187
- }
1188
- return false;
1189
- }, function (s) {
1190
- var identifier = SymbolRegistry.getIdentifier(s);
1191
- return ['symbol', identifier];
1192
- }, function (v) { return v.description; }, function (_, a) {
1193
- var value = SymbolRegistry.getValue(a[1]);
1194
- if (!value) {
1195
- throw new Error('Trying to deserialize unknown symbol');
1196
- }
1197
- return value;
1198
- });
1199
- var constructorToName = [
1200
- Int8Array,
1201
- Uint8Array,
1202
- Int16Array,
1203
- Uint16Array,
1204
- Int32Array,
1205
- Uint32Array,
1206
- Float32Array,
1207
- Float64Array,
1208
- Uint8ClampedArray,
1209
- ].reduce(function (obj, ctor) {
1210
- obj[ctor.name] = ctor;
1211
- return obj;
1212
- }, {});
1213
- var typedArrayRule = compositeTransformation(isTypedArray, function (v) { return ['typed-array', v.constructor.name]; }, function (v) { return __spreadArray$1([], __read$1(v)); }, function (v, a) {
1214
- var ctor = constructorToName[a[1]];
1215
- if (!ctor) {
1216
- throw new Error('Trying to deserialize unknown typed array');
1217
- }
1218
- return new ctor(v);
1219
- });
1220
- function isInstanceOfRegisteredClass(potentialClass) {
1221
- if (potentialClass === null || potentialClass === void 0 ? void 0 : potentialClass.constructor) {
1222
- var isRegistered = !!ClassRegistry.getIdentifier(potentialClass.constructor);
1223
- return isRegistered;
1224
- }
1225
- return false;
1226
- }
1227
- var classRule = compositeTransformation(isInstanceOfRegisteredClass, function (clazz) {
1228
- var identifier = ClassRegistry.getIdentifier(clazz.constructor);
1229
- return ['class', identifier];
1230
- }, function (clazz) {
1231
- var allowedProps = ClassRegistry.getAllowedProps(clazz.constructor);
1232
- if (!allowedProps) {
1233
- return __assign$1({}, clazz);
1234
- }
1235
- var result = {};
1236
- allowedProps.forEach(function (prop) {
1237
- result[prop] = clazz[prop];
1238
- });
1239
- return result;
1240
- }, function (v, a) {
1241
- var clazz = ClassRegistry.getValue(a[1]);
1242
- if (!clazz) {
1243
- throw new Error('Trying to deserialize unknown class - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564');
1244
- }
1245
- return Object.assign(Object.create(clazz.prototype), v);
1246
- });
1247
- var customRule = compositeTransformation(function (value) {
1248
- return !!CustomTransformerRegistry.findApplicable(value);
1249
- }, function (value) {
1250
- var transformer = CustomTransformerRegistry.findApplicable(value);
1251
- return ['custom', transformer.name];
1252
- }, function (value) {
1253
- var transformer = CustomTransformerRegistry.findApplicable(value);
1254
- return transformer.serialize(value);
1255
- }, function (v, a) {
1256
- var transformer = CustomTransformerRegistry.findByName(a[1]);
1257
- if (!transformer) {
1258
- throw new Error('Trying to deserialize unknown custom value');
1259
- }
1260
- return transformer.deserialize(v);
1261
- });
1262
- var compositeRules = [classRule, symbolRule, customRule, typedArrayRule];
1263
- var transformValue = function (value) {
1264
- var applicableCompositeRule = findArr(compositeRules, function (rule) {
1265
- return rule.isApplicable(value);
1266
- });
1267
- if (applicableCompositeRule) {
1268
- return {
1269
- value: applicableCompositeRule.transform(value),
1270
- type: applicableCompositeRule.annotation(value)
1271
- };
1272
- }
1273
- var applicableSimpleRule = findArr(simpleRules, function (rule) {
1274
- return rule.isApplicable(value);
1275
- });
1276
- if (applicableSimpleRule) {
1277
- return {
1278
- value: applicableSimpleRule.transform(value),
1279
- type: applicableSimpleRule.annotation
1280
- };
1281
- }
1282
- return undefined;
1283
- };
1284
- var simpleRulesByAnnotation = {};
1285
- simpleRules.forEach(function (rule) {
1286
- simpleRulesByAnnotation[rule.annotation] = rule;
1287
- });
1288
- var untransformValue = function (json, type) {
1289
- if (isArray$1(type)) {
1290
- switch (type[0]) {
1291
- case 'symbol':
1292
- return symbolRule.untransform(json, type);
1293
- case 'class':
1294
- return classRule.untransform(json, type);
1295
- case 'custom':
1296
- return customRule.untransform(json, type);
1297
- case 'typed-array':
1298
- return typedArrayRule.untransform(json, type);
1299
- default:
1300
- throw new Error('Unknown transformation: ' + type);
1301
- }
1302
- }
1303
- else {
1304
- var transformation = simpleRulesByAnnotation[type];
1305
- if (!transformation) {
1306
- throw new Error('Unknown transformation: ' + type);
1307
- }
1308
- return transformation.untransform(json);
1309
- }
1310
- };
1311
-
1312
- var getNthKey = function (value, n) {
1313
- var keys = value.keys();
1314
- while (n > 0) {
1315
- keys.next();
1316
- n--;
1317
- }
1318
- return keys.next().value;
1319
- };
1320
- function validatePath(path) {
1321
- if (includes(path, '__proto__')) {
1322
- throw new Error('__proto__ is not allowed as a property');
1323
- }
1324
- if (includes(path, 'prototype')) {
1325
- throw new Error('prototype is not allowed as a property');
1326
- }
1327
- if (includes(path, 'constructor')) {
1328
- throw new Error('constructor is not allowed as a property');
1329
- }
1330
- }
1331
- var getDeep = function (object, path) {
1332
- validatePath(path);
1333
- path.forEach(function (key) {
1334
- object = object[key];
1335
- });
1336
- return object;
1337
- };
1338
- var setDeep = function (object, path, mapper) {
1339
- validatePath(path);
1340
- if (path.length === 0) {
1341
- return mapper(object);
1342
- }
1343
- var parent = object;
1344
- for (var i = 0; i < path.length - 1; i++) {
1345
- var key = path[i];
1346
- if (isArray$1(parent)) {
1347
- var index = +key;
1348
- parent = parent[index];
1349
- }
1350
- else if (isPlainObject$1(parent)) {
1351
- parent = parent[key];
1352
- }
1353
- else if (isSet(parent)) {
1354
- var row = +key;
1355
- parent = getNthKey(parent, row);
1356
- }
1357
- else if (isMap(parent)) {
1358
- var isEnd = i === path.length - 2;
1359
- if (isEnd) {
1360
- break;
1361
- }
1362
- var row = +key;
1363
- var type = +path[++i] === 0 ? 'key' : 'value';
1364
- var keyOfRow = getNthKey(parent, row);
1365
- switch (type) {
1366
- case 'key':
1367
- parent = keyOfRow;
1368
- break;
1369
- case 'value':
1370
- parent = parent.get(keyOfRow);
1371
- break;
1372
- }
1373
- }
1374
- }
1375
- var lastKey = path[path.length - 1];
1376
- if (isArray$1(parent) || isPlainObject$1(parent)) {
1377
- parent[lastKey] = mapper(parent[lastKey]);
1378
- }
1379
- if (isSet(parent)) {
1380
- var oldValue = getNthKey(parent, +lastKey);
1381
- var newValue = mapper(oldValue);
1382
- if (oldValue !== newValue) {
1383
- parent["delete"](oldValue);
1384
- parent.add(newValue);
1385
- }
1386
- }
1387
- if (isMap(parent)) {
1388
- var row = +path[path.length - 2];
1389
- var keyToRow = getNthKey(parent, row);
1390
- var type = +lastKey === 0 ? 'key' : 'value';
1391
- switch (type) {
1392
- case 'key': {
1393
- var newKey = mapper(keyToRow);
1394
- parent.set(newKey, parent.get(keyToRow));
1395
- if (newKey !== keyToRow) {
1396
- parent["delete"](keyToRow);
1397
- }
1398
- break;
1399
- }
1400
- case 'value': {
1401
- parent.set(keyToRow, mapper(parent.get(keyToRow)));
1402
- break;
1403
- }
1404
- }
1405
- }
1406
- return object;
1407
- };
1408
-
1409
- var __read = (undefined && undefined.__read) || function (o, n) {
1410
- var m = typeof Symbol === "function" && o[Symbol.iterator];
1411
- if (!m) return o;
1412
- var i = m.call(o), r, ar = [], e;
1413
- try {
1414
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
1415
- }
1416
- catch (error) { e = { error: error }; }
1417
- finally {
1418
- try {
1419
- if (r && !r.done && (m = i["return"])) m.call(i);
1420
- }
1421
- finally { if (e) throw e.error; }
1422
- }
1423
- return ar;
1424
- };
1425
- var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from) {
1426
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
1427
- to[j] = from[i];
1428
- return to;
1429
- };
1430
- function traverse(tree, walker, origin) {
1431
- if (origin === void 0) { origin = []; }
1432
- if (!tree) {
1433
- return;
1434
- }
1435
- if (!isArray$1(tree)) {
1436
- forEach(tree, function (subtree, key) {
1437
- return traverse(subtree, walker, __spreadArray(__spreadArray([], __read(origin)), __read(parsePath(key))));
1438
- });
1439
- return;
1440
- }
1441
- var _a = __read(tree, 2), nodeValue = _a[0], children = _a[1];
1442
- if (children) {
1443
- forEach(children, function (child, key) {
1444
- traverse(child, walker, __spreadArray(__spreadArray([], __read(origin)), __read(parsePath(key))));
1445
- });
1446
- }
1447
- walker(nodeValue, origin);
1448
- }
1449
- function applyValueAnnotations(plain, annotations) {
1450
- traverse(annotations, function (type, path) {
1451
- plain = setDeep(plain, path, function (v) { return untransformValue(v, type); });
1452
- });
1453
- return plain;
1454
- }
1455
- function applyReferentialEqualityAnnotations(plain, annotations) {
1456
- function apply(identicalPaths, path) {
1457
- var object = getDeep(plain, parsePath(path));
1458
- identicalPaths.map(parsePath).forEach(function (identicalObjectPath) {
1459
- plain = setDeep(plain, identicalObjectPath, function () { return object; });
1460
- });
1461
- }
1462
- if (isArray$1(annotations)) {
1463
- var _a = __read(annotations, 2), root = _a[0], other = _a[1];
1464
- root.forEach(function (identicalPath) {
1465
- plain = setDeep(plain, parsePath(identicalPath), function () { return plain; });
1466
- });
1467
- if (other) {
1468
- forEach(other, apply);
1469
- }
1470
- }
1471
- else {
1472
- forEach(annotations, apply);
1473
- }
1474
- return plain;
1475
- }
1476
- var isDeep = function (object) {
1477
- return isPlainObject$1(object) ||
1478
- isArray$1(object) ||
1479
- isMap(object) ||
1480
- isSet(object) ||
1481
- isInstanceOfRegisteredClass(object);
1482
- };
1483
- function addIdentity(object, path, identities) {
1484
- var existingSet = identities.get(object);
1485
- if (existingSet) {
1486
- existingSet.push(path);
1487
- }
1488
- else {
1489
- identities.set(object, [path]);
1490
- }
1491
- }
1492
- function generateReferentialEqualityAnnotations(identitites) {
1493
- var result = {};
1494
- var rootEqualityPaths = undefined;
1495
- identitites.forEach(function (paths) {
1496
- if (paths.length <= 1) {
1497
- return;
1498
- }
1499
- var _a = __read(paths
1500
- .map(function (path) { return path.map(String); })
1501
- .sort(function (a, b) { return a.length - b.length; })), shortestPath = _a[0], identicalPaths = _a.slice(1);
1502
- if (shortestPath.length === 0) {
1503
- rootEqualityPaths = identicalPaths.map(stringifyPath);
1504
- }
1505
- else {
1506
- result[stringifyPath(shortestPath)] = identicalPaths.map(stringifyPath);
1507
- }
1508
- });
1509
- if (rootEqualityPaths) {
1510
- if (isEmptyObject(result)) {
1511
- return [rootEqualityPaths];
1512
- }
1513
- else {
1514
- return [rootEqualityPaths, result];
1515
- }
1516
- }
1517
- else {
1518
- return isEmptyObject(result) ? undefined : result;
1519
- }
1520
- }
1521
- var walker = function (object, identities, path, objectsInThisPath) {
1522
- var _a;
1523
- if (path === void 0) { path = []; }
1524
- if (objectsInThisPath === void 0) { objectsInThisPath = []; }
1525
- if (!isPrimitive(object)) {
1526
- addIdentity(object, path, identities);
1527
- }
1528
- if (!isDeep(object)) {
1529
- var transformed_1 = transformValue(object);
1530
- if (transformed_1) {
1531
- return {
1532
- transformedValue: transformed_1.value,
1533
- annotations: [transformed_1.type]
1534
- };
1535
- }
1536
- else {
1537
- return {
1538
- transformedValue: object
1539
- };
1540
- }
1541
- }
1542
- if (includes(objectsInThisPath, object)) {
1543
- return {
1544
- transformedValue: null
1545
- };
1546
- }
1547
- var transformationResult = transformValue(object);
1548
- var transformed = (_a = transformationResult === null || transformationResult === void 0 ? void 0 : transformationResult.value) !== null && _a !== void 0 ? _a : object;
1549
- if (!isPrimitive(object)) {
1550
- objectsInThisPath = __spreadArray(__spreadArray([], __read(objectsInThisPath)), [object]);
1551
- }
1552
- var transformedValue = isArray$1(transformed) ? [] : {};
1553
- var innerAnnotations = {};
1554
- forEach(transformed, function (value, index) {
1555
- var recursiveResult = walker(value, identities, __spreadArray(__spreadArray([], __read(path)), [index]), objectsInThisPath);
1556
- transformedValue[index] = recursiveResult.transformedValue;
1557
- if (isArray$1(recursiveResult.annotations)) {
1558
- innerAnnotations[index] = recursiveResult.annotations;
1559
- }
1560
- else if (isPlainObject$1(recursiveResult.annotations)) {
1561
- forEach(recursiveResult.annotations, function (tree, key) {
1562
- innerAnnotations[escapeKey(index) + '.' + key] = tree;
1563
- });
1564
- }
1565
- });
1566
- if (isEmptyObject(innerAnnotations)) {
1567
- return {
1568
- transformedValue: transformedValue,
1569
- annotations: !!transformationResult
1570
- ? [transformationResult.type]
1571
- : undefined
1572
- };
1573
- }
1574
- else {
1575
- return {
1576
- transformedValue: transformedValue,
1577
- annotations: !!transformationResult
1578
- ? [transformationResult.type, innerAnnotations]
1579
- : innerAnnotations
1580
- };
1581
- }
1582
- };
1583
-
1584
- /**
1585
- * Returns the object type of the given payload
1586
- *
1587
- * @param {*} payload
1588
- * @returns {string}
1589
- */
1590
- function getType(payload) {
1591
- return Object.prototype.toString.call(payload).slice(8, -1);
1592
- }
1593
- /**
1594
- * Returns whether the payload is a plain JavaScript object (excluding special classes or objects with other prototypes)
1595
- *
1596
- * @param {*} payload
1597
- * @returns {payload is PlainObject}
1598
- */
1599
- function isPlainObject(payload) {
1600
- if (getType(payload) !== 'Object')
1601
- return false;
1602
- return payload.constructor === Object && Object.getPrototypeOf(payload) === Object.prototype;
1603
- }
1604
- /**
1605
- * Returns whether the payload is an array
1606
- *
1607
- * @param {any} payload
1608
- * @returns {payload is any[]}
1609
- */
1610
- function isArray(payload) {
1611
- return getType(payload) === 'Array';
1612
- }
1613
-
1614
- function assignProp(carry, key, newVal, originalObject, includeNonenumerable) {
1615
- const propType = {}.propertyIsEnumerable.call(originalObject, key)
1616
- ? 'enumerable'
1617
- : 'nonenumerable';
1618
- if (propType === 'enumerable')
1619
- carry[key] = newVal;
1620
- if (includeNonenumerable && propType === 'nonenumerable') {
1621
- Object.defineProperty(carry, key, {
1622
- value: newVal,
1623
- enumerable: false,
1624
- writable: true,
1625
- configurable: true,
1626
- });
1627
- }
1628
- }
1629
- /**
1630
- * Copy (clone) an object and all its props recursively to get rid of any prop referenced of the original object. Arrays are also cloned, however objects inside arrays are still linked.
1631
- *
1632
- * @export
1633
- * @template T
1634
- * @param {T} target Target can be anything
1635
- * @param {Options} [options = {}] Options can be `props` or `nonenumerable`
1636
- * @returns {T} the target with replaced values
1637
- * @export
1638
- */
1639
- function copy(target, options = {}) {
1640
- if (isArray(target)) {
1641
- return target.map((item) => copy(item, options));
1642
- }
1643
- if (!isPlainObject(target)) {
1644
- return target;
1645
- }
1646
- const props = Object.getOwnPropertyNames(target);
1647
- const symbols = Object.getOwnPropertySymbols(target);
1648
- return [...props, ...symbols].reduce((carry, key) => {
1649
- if (isArray(options.props) && !options.props.includes(key)) {
1650
- return carry;
1651
- }
1652
- const val = target[key];
1653
- const newVal = copy(val, options);
1654
- assignProp(carry, key, newVal, target, options.nonenumerable);
1655
- return carry;
1656
- }, {});
1657
- }
1658
-
1659
- var __assign = (undefined && undefined.__assign) || function () {
1660
- __assign = Object.assign || function(t) {
1661
- for (var s, i = 1, n = arguments.length; i < n; i++) {
1662
- s = arguments[i];
1663
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
1664
- t[p] = s[p];
1665
- }
1666
- return t;
1667
- };
1668
- return __assign.apply(this, arguments);
1669
- };
1670
- var serialize = function (object) {
1671
- var identities = new Map();
1672
- var output = walker(object, identities);
1673
- var res = {
1674
- json: output.transformedValue
1675
- };
1676
- if (output.annotations) {
1677
- res.meta = __assign(__assign({}, res.meta), { values: output.annotations });
1678
- }
1679
- var equalityAnnotations = generateReferentialEqualityAnnotations(identities);
1680
- if (equalityAnnotations) {
1681
- res.meta = __assign(__assign({}, res.meta), { referentialEqualities: equalityAnnotations });
1682
- }
1683
- return res;
1684
- };
1685
- var deserialize = function (payload) {
1686
- var json = payload.json, meta = payload.meta;
1687
- var result = copy(json);
1688
- if (meta === null || meta === void 0 ? void 0 : meta.values) {
1689
- result = applyValueAnnotations(result, meta.values);
1690
- }
1691
- if (meta === null || meta === void 0 ? void 0 : meta.referentialEqualities) {
1692
- result = applyReferentialEqualityAnnotations(result, meta.referentialEqualities);
1693
- }
1694
- return result;
1695
- };
1696
- var stringify = function (object) {
1697
- return JSON.stringify(serialize(object));
1698
- };
1699
- var parse = function (string) {
1700
- return deserialize(JSON.parse(string));
1701
- };
1702
- var registerClass = function (v, options) {
1703
- return ClassRegistry.register(v, options);
1704
- };
1705
- var registerSymbol = function (v, identifier) {
1706
- return SymbolRegistry.register(v, identifier);
1707
- };
1708
- var registerCustom = function (transformer, name) {
1709
- return CustomTransformerRegistry.register(__assign({ name: name }, transformer));
1710
- };
1711
- var superjson = {
1712
- stringify: stringify,
1713
- parse: parse,
1714
- serialize: serialize,
1715
- deserialize: deserialize,
1716
- registerClass: registerClass,
1717
- registerSymbol: registerSymbol,
1718
- registerCustom: registerCustom,
1719
- allowErrorProps: allowErrorProps
1720
- };
1721
-
1722
- const defaultTheme = {
1723
- background: '#0b1521',
1724
- backgroundAlt: '#132337',
1725
- foreground: 'white',
1726
- gray: '#3f4e60',
1727
- grayAlt: '#222e3e',
1728
- inputBackgroundColor: '#fff',
1729
- inputTextColor: '#000',
1730
- success: '#00ab52',
1731
- danger: '#ff0085',
1732
- active: '#006bff',
1733
- paused: '#8c49eb',
1734
- warning: '#ffb200'
1735
- };
1736
- const ThemeContext = /*#__PURE__*/React__namespace.createContext(defaultTheme);
1737
- function ThemeProvider({
1738
- theme,
1739
- ...rest
1740
- }) {
1741
- return /*#__PURE__*/React__namespace.createElement(ThemeContext.Provider, _extends({
1742
- value: theme
1743
- }, rest));
1744
- }
1745
- function useTheme() {
1746
- return React__namespace.useContext(ThemeContext);
1747
- }
1748
-
1749
- function useMediaQuery(query) {
1750
- // Keep track of the preference in state, start with the current match
1751
- const [isMatch, setIsMatch] = React__namespace.useState(() => {
1752
- if (typeof window !== 'undefined') {
1753
- return window.matchMedia(query).matches;
1754
- }
1755
- return;
1756
- });
1757
-
1758
- // Watch for changes
1759
- React__namespace.useEffect(() => {
1760
- if (typeof window !== 'undefined') {
1761
- // Create a matcher
1762
- const matcher = window.matchMedia(query);
1763
-
1764
- // Create our handler
1765
- const onChange = ({
1766
- matches
1767
- }) => setIsMatch(matches);
1768
-
1769
- // Listen for changes
1770
- matcher.addListener(onChange);
1771
- return () => {
1772
- // Stop listening for changes
1773
- matcher.removeListener(onChange);
1774
- };
1775
- }
1776
- return;
1777
- }, [isMatch, query, setIsMatch]);
1778
- return isMatch;
1779
- }
1780
-
1781
- function getQueryStatusColor({
1782
- queryState,
1783
- observerCount,
1784
- isStale,
1785
- theme
1786
- }) {
1787
- return queryState.fetchStatus === 'fetching' ? theme.active : !observerCount ? theme.gray : queryState.fetchStatus === 'paused' ? theme.paused : isStale ? theme.warning : theme.success;
1788
- }
1789
- function getQueryStatusLabel(query) {
1790
- return query.state.fetchStatus === 'fetching' ? 'fetching' : !query.getObserversCount() ? 'inactive' : query.state.fetchStatus === 'paused' ? 'paused' : query.isStale() ? 'stale' : 'fresh';
1791
- }
1792
- function styled(type, newStyles, queries = {}) {
1793
- return /*#__PURE__*/React__namespace.forwardRef(({
1794
- style,
1795
- ...rest
1796
- }, ref) => {
1797
- const theme = useTheme();
1798
- const mediaStyles = Object.entries(queries).reduce((current, [key, value]) => {
1799
- // eslint-disable-next-line react-hooks/rules-of-hooks
1800
- return useMediaQuery(key) ? {
1801
- ...current,
1802
- ...(typeof value === 'function' ? value(rest, theme) : value)
1803
- } : current;
1804
- }, {});
1805
- return /*#__PURE__*/React__namespace.createElement(type, {
1806
- ...rest,
1807
- style: {
1808
- ...(typeof newStyles === 'function' ? newStyles(rest, theme) : newStyles),
1809
- ...style,
1810
- ...mediaStyles
1811
- },
1812
- ref
1813
- });
1814
- });
1815
- }
1816
- function useIsMounted() {
1817
- const mountedRef = React__namespace.useRef(false);
1818
- const isMounted = React__namespace.useCallback(() => mountedRef.current, []);
1819
- React__namespace.useEffect(() => {
1820
- mountedRef.current = true;
1821
- return () => {
1822
- mountedRef.current = false;
1823
- };
1824
- }, []);
1825
- return isMounted;
1826
- }
1827
-
1828
- /**
1829
- * Displays a string regardless the type of the data
1830
- * @param {unknown} value Value to be stringified
1831
- * @param {boolean} beautify Formats json to multiline
1832
- */
1833
- const displayValue = (value, beautify = false) => {
1834
- const {
1835
- json
1836
- } = superjson.serialize(value);
1837
- return JSON.stringify(json, null, beautify ? 2 : undefined);
1838
- };
1839
-
1840
- // Sorting functions
1841
-
1842
- const getStatusRank = q => q.state.fetchStatus !== 'idle' ? 0 : !q.getObserversCount() ? 3 : q.isStale() ? 2 : 1;
1843
- const queryHashSort = (a, b) => a.queryHash.localeCompare(b.queryHash);
1844
- const dateSort = (a, b) => a.state.dataUpdatedAt < b.state.dataUpdatedAt ? 1 : -1;
1845
- const statusAndDateSort = (a, b) => {
1846
- if (getStatusRank(a) === getStatusRank(b)) {
1847
- return dateSort(a, b);
1848
- }
1849
- return getStatusRank(a) > getStatusRank(b) ? 1 : -1;
1850
- };
1851
- const sortFns = {
1852
- 'Status > Last Updated': statusAndDateSort,
1853
- 'Query Hash': queryHashSort,
1854
- 'Last Updated': dateSort
1855
- };
1856
- const minPanelSize = 70;
1857
- const defaultPanelSize = 500;
1858
- const sides = {
1859
- top: 'bottom',
1860
- bottom: 'top',
1861
- left: 'right',
1862
- right: 'left'
1863
- };
1864
- /**
1865
- * Check if the given side is vertical (left/right)
1866
- */
1867
- function isVerticalSide(side) {
1868
- return ['left', 'right'].includes(side);
1869
- }
1870
- /**
1871
- * Get the opposite side, eg 'left' => 'right'. 'top' => 'bottom', etc
1872
- */
1873
- function getOppositeSide(side) {
1874
- return sides[side];
1875
- }
1876
- /**
1877
- * Given as css prop it will return a sided css prop based on a given side
1878
- * Example given `border` and `right` it return `borderRight`
1879
- */
1880
- function getSidedProp(prop, side) {
1881
- return `${prop}${side.charAt(0).toUpperCase() + side.slice(1)}`;
1882
- }
1883
- function getSidePanelStyle({
1884
- position = 'bottom',
1885
- height,
1886
- width,
1887
- devtoolsTheme,
1888
- isOpen,
1889
- isResizing,
1890
- panelStyle
1891
- }) {
1892
- const oppositeSide = getOppositeSide(position);
1893
- const borderSide = getSidedProp('border', oppositeSide);
1894
- const isVertical = isVerticalSide(position);
1895
- return {
1896
- ...panelStyle,
1897
- direction: 'ltr',
1898
- position: 'fixed',
1899
- [position]: 0,
1900
- [borderSide]: `1px solid ${devtoolsTheme.gray}`,
1901
- transformOrigin: oppositeSide,
1902
- boxShadow: '0 0 20px rgba(0,0,0,.3)',
1903
- zIndex: 99999,
1904
- // visibility will be toggled after transitions, but set initial state here
1905
- visibility: isOpen ? 'visible' : 'hidden',
1906
- ...(isResizing ? {
1907
- transition: `none`
1908
- } : {
1909
- transition: `all .2s ease`
1910
- }),
1911
- ...(isOpen ? {
1912
- opacity: 1,
1913
- pointerEvents: 'all',
1914
- transform: isVertical ? `translateX(0) scale(1)` : `translateY(0) scale(1)`
1915
- } : {
1916
- opacity: 0,
1917
- pointerEvents: 'none',
1918
- transform: isVertical ? `translateX(15px) scale(1.02)` : `translateY(15px) scale(1.02)`
1919
- }),
1920
- ...(isVertical ? {
1921
- top: 0,
1922
- height: '100vh',
1923
- maxWidth: '90%',
1924
- width: typeof width === 'number' && width >= minPanelSize ? width : defaultPanelSize
1925
- } : {
1926
- left: 0,
1927
- width: '100%',
1928
- maxHeight: '90%',
1929
- height: typeof height === 'number' && height >= minPanelSize ? height : defaultPanelSize
1930
- })
1931
- };
1932
- }
1933
-
1934
- /**
1935
- * Get resize handle style based on a given side
1936
- */
1937
- function getResizeHandleStyle(position = 'bottom') {
1938
- const isVertical = isVerticalSide(position);
1939
- const oppositeSide = getOppositeSide(position);
1940
- const marginSide = getSidedProp('margin', oppositeSide);
1941
- return {
1942
- position: 'absolute',
1943
- cursor: isVertical ? 'col-resize' : 'row-resize',
1944
- zIndex: 100000,
1945
- [oppositeSide]: 0,
1946
- [marginSide]: `-4px`,
1947
- ...(isVertical ? {
1948
- top: 0,
1949
- height: '100%',
1950
- width: '4px'
1951
- } : {
1952
- width: '100%',
1953
- height: '4px'
1954
- })
1955
- };
1956
- }
1957
-
1958
- const Panel = styled('div', (_props, theme) => ({
1959
- fontSize: 'clamp(12px, 1.5vw, 14px)',
1960
- fontFamily: `sans-serif`,
1961
- display: 'flex',
1962
- backgroundColor: theme.background,
1963
- color: theme.foreground
1964
- }), {
1965
- '(max-width: 700px)': {
1966
- flexDirection: 'column'
1967
- },
1968
- '(max-width: 600px)': {
1969
- fontSize: '.9em'
1970
- // flexDirection: 'column',
1971
- }
1972
- });
1973
-
1974
- const ActiveQueryPanel = styled('div', () => ({
1975
- flex: '1 1 500px',
1976
- display: 'flex',
1977
- flexDirection: 'column',
1978
- overflow: 'auto',
1979
- height: '100%'
1980
- }), {
1981
- '(max-width: 700px)': (_props, theme) => ({
1982
- borderTop: `2px solid ${theme.gray}`
1983
- })
1984
- });
1985
- const Button = styled('button', (props, theme) => ({
1986
- appearance: 'none',
1987
- fontSize: '.9em',
1988
- fontWeight: 'bold',
1989
- background: theme.gray,
1990
- border: '0',
1991
- borderRadius: '.3em',
1992
- color: 'white',
1993
- padding: '.5em',
1994
- opacity: props.disabled ? '.5' : undefined,
1995
- cursor: 'pointer'
1996
- }));
1997
- const QueryKeys = styled('span', {
1998
- display: 'flex',
1999
- flexWrap: 'wrap',
2000
- gap: '0.5em',
2001
- fontSize: '0.9em'
2002
- });
2003
- const QueryKey = styled('span', {
2004
- display: 'inline-flex',
2005
- alignItems: 'center',
2006
- padding: '.2em .4em',
2007
- fontWeight: 'bold',
2008
- textShadow: '0 0 10px black',
2009
- borderRadius: '.2em'
2010
- });
2011
- const Code = styled('code', {
2012
- fontSize: '.9em',
2013
- color: 'inherit',
2014
- background: 'inherit'
2015
- });
2016
- const Input = styled('input', (_props, theme) => ({
2017
- backgroundColor: theme.inputBackgroundColor,
2018
- border: 0,
2019
- borderRadius: '.2em',
2020
- color: theme.inputTextColor,
2021
- fontSize: '.9em',
2022
- lineHeight: `1.3`,
2023
- padding: '.3em .4em'
2024
- }));
2025
- const Select = styled('select', (_props, theme) => ({
2026
- display: `inline-block`,
2027
- fontSize: `.9em`,
2028
- fontFamily: `sans-serif`,
2029
- fontWeight: 'normal',
2030
- lineHeight: `1.3`,
2031
- padding: `.3em 1.5em .3em .5em`,
2032
- height: 'auto',
2033
- border: 0,
2034
- borderRadius: `.2em`,
2035
- appearance: `none`,
2036
- WebkitAppearance: 'none',
2037
- backgroundColor: theme.inputBackgroundColor,
2038
- 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>")`,
2039
- backgroundRepeat: `no-repeat`,
2040
- backgroundPosition: `right .55em center`,
2041
- backgroundSize: `.65em auto, 100%`,
2042
- color: theme.inputTextColor
2043
- }), {
2044
- '(max-width: 500px)': {
2045
- display: 'none'
2046
- }
2047
- });
2048
-
2049
- function ScreenReader({
2050
- text
2051
- }) {
2052
- return /*#__PURE__*/React__namespace.createElement("span", {
2053
- style: {
2054
- position: 'absolute',
2055
- width: '0.1px',
2056
- height: '0.1px',
2057
- overflow: 'hidden'
2058
- }
2059
- }, text);
2060
- }
2061
-
2062
- const Entry = styled('div', {
2063
- fontFamily: 'Menlo, monospace',
2064
- fontSize: '1em',
2065
- lineHeight: '1.7',
2066
- outline: 'none',
2067
- wordBreak: 'break-word'
2068
- });
2069
- const Label = styled('span', {
2070
- color: 'white'
2071
- });
2072
- const LabelButton = styled('button', {
2073
- cursor: 'pointer',
2074
- color: 'white'
2075
- });
2076
- const ExpandButton = styled('button', {
2077
- cursor: 'pointer',
2078
- color: 'inherit',
2079
- font: 'inherit',
2080
- outline: 'inherit',
2081
- background: 'transparent',
2082
- border: 'none',
2083
- padding: 0
2084
- });
2085
- const CopyButton = ({
2086
- value
2087
- }) => {
2088
- const [copyState, setCopyState] = React__namespace.useState('NoCopy');
2089
- return /*#__PURE__*/React__namespace.createElement("button", {
2090
- onClick: copyState === 'NoCopy' ? () => {
2091
- navigator.clipboard.writeText(superjson.stringify(value)).then(() => {
2092
- setCopyState('SuccessCopy');
2093
- setTimeout(() => {
2094
- setCopyState('NoCopy');
2095
- }, 1500);
2096
- }, err => {
2097
- console.error('Failed to copy: ', err);
2098
- setCopyState('ErrorCopy');
2099
- setTimeout(() => {
2100
- setCopyState('NoCopy');
2101
- }, 1500);
2102
- });
2103
- } : undefined,
2104
- style: {
2105
- cursor: 'pointer',
2106
- color: 'inherit',
2107
- font: 'inherit',
2108
- outline: 'inherit',
2109
- background: 'transparent',
2110
- border: 'none',
2111
- padding: 0
2112
- }
2113
- }, copyState === 'NoCopy' ? /*#__PURE__*/React__namespace.createElement(Copier, null) : copyState === 'SuccessCopy' ? /*#__PURE__*/React__namespace.createElement(CopiedCopier, null) : /*#__PURE__*/React__namespace.createElement(ErrorCopier, null));
2114
- };
2115
- const Value = styled('span', (_props, theme) => ({
2116
- color: theme.danger
2117
- }));
2118
- const SubEntries = styled('div', {
2119
- marginLeft: '.1em',
2120
- paddingLeft: '1em',
2121
- borderLeft: '2px solid rgba(0,0,0,.15)'
2122
- });
2123
- const Info = styled('span', {
2124
- color: 'grey',
2125
- fontSize: '.7em'
2126
- });
2127
- const Expander = ({
2128
- expanded,
2129
- style = {}
2130
- }) => /*#__PURE__*/React__namespace.createElement("span", {
2131
- style: {
2132
- display: 'inline-block',
2133
- transition: 'all .1s ease',
2134
- transform: `rotate(${expanded ? 90 : 0}deg) ${style.transform || ''}`,
2135
- ...style
2136
- }
2137
- }, "\u25B6");
2138
- const Copier = () => /*#__PURE__*/React__namespace.createElement("span", {
2139
- "aria-label": "Copy object to clipboard",
2140
- title: "Copy object to clipboard",
2141
- style: {
2142
- paddingLeft: '1em'
2143
- }
2144
- }, /*#__PURE__*/React__namespace.createElement("svg", {
2145
- height: "12",
2146
- viewBox: "0 0 16 12",
2147
- width: "10"
2148
- }, /*#__PURE__*/React__namespace.createElement("path", {
2149
- fill: "currentColor",
2150
- d: "M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"
2151
- }), /*#__PURE__*/React__namespace.createElement("path", {
2152
- fill: "currentColor",
2153
- d: "M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"
2154
- })));
2155
- const ErrorCopier = () => /*#__PURE__*/React__namespace.createElement("span", {
2156
- "aria-label": "Failed copying to clipboard",
2157
- title: "Failed copying to clipboard",
2158
- style: {
2159
- paddingLeft: '1em',
2160
- display: 'flex',
2161
- alignItems: 'center'
2162
- }
2163
- }, /*#__PURE__*/React__namespace.createElement("svg", {
2164
- height: "12",
2165
- viewBox: "0 0 16 12",
2166
- width: "10",
2167
- display: "block"
2168
- }, /*#__PURE__*/React__namespace.createElement("path", {
2169
- fill: "red",
2170
- d: "M3.72 3.72a.75.75 0 011.06 0L8 6.94l3.22-3.22a.75.75 0 111.06 1.06L9.06 8l3.22 3.22a.75.75 0 11-1.06 1.06L8 9.06l-3.22 3.22a.75.75 0 01-1.06-1.06L6.94 8 3.72 4.78a.75.75 0 010-1.06z"
2171
- })), /*#__PURE__*/React__namespace.createElement("span", {
2172
- style: {
2173
- color: 'red',
2174
- fontSize: '12px',
2175
- paddingLeft: '4px',
2176
- position: 'relative',
2177
- top: '2px'
2178
- }
2179
- }, "See console"));
2180
- const CopiedCopier = () => /*#__PURE__*/React__namespace.createElement("span", {
2181
- "aria-label": "Object copied to clipboard",
2182
- title: "Object copied to clipboard",
2183
- style: {
2184
- paddingLeft: '1em',
2185
- display: 'inline-block',
2186
- verticalAlign: 'middle'
2187
- }
2188
- }, /*#__PURE__*/React__namespace.createElement("svg", {
2189
- height: "16",
2190
- viewBox: "0 0 16 16",
2191
- width: "16",
2192
- display: "block"
2193
- }, /*#__PURE__*/React__namespace.createElement("path", {
2194
- fill: "green",
2195
- d: "M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"
2196
- })));
2197
- /**
2198
- * Chunk elements in the array by size
2199
- *
2200
- * when the array cannot be chunked evenly by size, the last chunk will be
2201
- * filled with the remaining elements
2202
- *
2203
- * @example
2204
- * chunkArray(['a','b', 'c', 'd', 'e'], 2) // returns [['a','b'], ['c', 'd'], ['e']]
2205
- */
2206
- function chunkArray(array, size) {
2207
- if (size < 1) return [];
2208
- let i = 0;
2209
- const result = [];
2210
- while (i < array.length) {
2211
- result.push(array.slice(i, i + size));
2212
- i = i + size;
2213
- }
2214
- return result;
2215
- }
2216
- const DefaultRenderer = ({
2217
- handleEntry,
2218
- label,
2219
- value,
2220
- subEntries = [],
2221
- subEntryPages = [],
2222
- type,
2223
- expanded = false,
2224
- copyable = false,
2225
- toggleExpanded,
2226
- pageSize
2227
- }) => {
2228
- const [expandedPages, setExpandedPages] = React__namespace.useState([]);
2229
- return /*#__PURE__*/React__namespace.createElement(Entry, {
2230
- key: label
2231
- }, subEntryPages.length ? /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement(ExpandButton, {
2232
- onClick: () => toggleExpanded()
2233
- }, /*#__PURE__*/React__namespace.createElement(Expander, {
2234
- expanded: expanded
2235
- }), " ", label, ' ', /*#__PURE__*/React__namespace.createElement(Info, null, String(type).toLowerCase() === 'iterable' ? '(Iterable) ' : '', subEntries.length, " ", subEntries.length > 1 ? `items` : `item`)), copyable ? /*#__PURE__*/React__namespace.createElement(CopyButton, {
2236
- value: value
2237
- }) : null, expanded ? subEntryPages.length === 1 ? /*#__PURE__*/React__namespace.createElement(SubEntries, null, subEntries.map(handleEntry)) : /*#__PURE__*/React__namespace.createElement(SubEntries, null, subEntryPages.map((entries, index) => /*#__PURE__*/React__namespace.createElement("div", {
2238
- key: index
2239
- }, /*#__PURE__*/React__namespace.createElement(Entry, null, /*#__PURE__*/React__namespace.createElement(LabelButton, {
2240
- onClick: () => setExpandedPages(old => old.includes(index) ? old.filter(d => d !== index) : [...old, index])
2241
- }, /*#__PURE__*/React__namespace.createElement(Expander, {
2242
- expanded: expanded
2243
- }), " [", index * pageSize, " ...", ' ', index * pageSize + pageSize - 1, "]"), expandedPages.includes(index) ? /*#__PURE__*/React__namespace.createElement(SubEntries, null, entries.map(handleEntry)) : null)))) : null) : /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement(Label, null, label, ":"), " ", /*#__PURE__*/React__namespace.createElement(Value, null, displayValue(value))));
2244
- };
2245
- function isIterable(x) {
2246
- return Symbol.iterator in x;
2247
- }
2248
- function Explorer({
2249
- value,
2250
- defaultExpanded,
2251
- renderer = DefaultRenderer,
2252
- pageSize = 100,
2253
- copyable = false,
2254
- ...rest
2255
- }) {
2256
- const [expanded, setExpanded] = React__namespace.useState(Boolean(defaultExpanded));
2257
- const toggleExpanded = React__namespace.useCallback(() => setExpanded(old => !old), []);
2258
- let type = typeof value;
2259
- let subEntries = [];
2260
- const makeProperty = sub => {
2261
- const subDefaultExpanded = defaultExpanded === true ? {
2262
- [sub.label]: true
2263
- } : defaultExpanded?.[sub.label];
2264
- return {
2265
- ...sub,
2266
- defaultExpanded: subDefaultExpanded
2267
- };
2268
- };
2269
- if (Array.isArray(value)) {
2270
- type = 'array';
2271
- subEntries = value.map((d, i) => makeProperty({
2272
- label: i.toString(),
2273
- value: d
2274
- }));
2275
- } else if (value !== null && typeof value === 'object' && isIterable(value) && typeof value[Symbol.iterator] === 'function') {
2276
- type = 'Iterable';
2277
- subEntries = Array.from(value, (val, i) => makeProperty({
2278
- label: i.toString(),
2279
- value: val
2280
- }));
2281
- } else if (typeof value === 'object' && value !== null) {
2282
- type = 'object';
2283
- subEntries = Object.entries(value).map(([key, val]) => makeProperty({
2284
- label: key,
2285
- value: val
2286
- }));
2287
- }
2288
- const subEntryPages = chunkArray(subEntries, pageSize);
2289
- return renderer({
2290
- handleEntry: entry => /*#__PURE__*/React__namespace.createElement(Explorer, _extends({
2291
- key: entry.label,
2292
- value: value,
2293
- renderer: renderer,
2294
- copyable: copyable
2295
- }, rest, entry)),
2296
- type,
2297
- subEntries,
2298
- subEntryPages,
2299
- value,
2300
- expanded,
2301
- copyable,
2302
- toggleExpanded,
2303
- pageSize,
2304
- ...rest
2305
- });
2306
- }
2307
-
2308
- function Logo(props) {
2309
- return /*#__PURE__*/React__namespace.createElement("svg", _extends({
2310
- width: "40px",
2311
- height: "40px",
2312
- viewBox: "0 0 190 190",
2313
- version: "1.1"
2314
- }, props), /*#__PURE__*/React__namespace.createElement("g", {
2315
- stroke: "none",
2316
- strokeWidth: "1",
2317
- fill: "none",
2318
- fillRule: "evenodd"
2319
- }, /*#__PURE__*/React__namespace.createElement("g", {
2320
- transform: "translate(-33.000000, 0.000000)"
2321
- }, /*#__PURE__*/React__namespace.createElement("path", {
2322
- d: "M72.7239712,61.3436237 C69.631224,46.362877 68.9675112,34.8727722 70.9666331,26.5293551 C72.1555965,21.5671678 74.3293088,17.5190846 77.6346064,14.5984631 C81.1241394,11.5150478 85.5360327,10.0020122 90.493257,10.0020122 C98.6712013,10.0020122 107.26826,13.7273214 116.455725,20.8044264 C120.20312,23.6910458 124.092437,27.170411 128.131651,31.2444746 C128.45314,30.8310265 128.816542,30.4410453 129.22143,30.0806152 C140.64098,19.9149716 150.255245,13.5989272 158.478408,11.1636507 C163.367899,9.715636 167.958526,9.57768202 172.138936,10.983031 C176.551631,12.4664684 180.06766,15.5329489 182.548314,19.8281091 C186.642288,26.9166735 187.721918,36.2310983 186.195595,47.7320243 C185.573451,52.4199112 184.50985,57.5263831 183.007094,63.0593153 C183.574045,63.1277086 184.142416,63.2532808 184.705041,63.4395297 C199.193932,68.2358678 209.453582,73.3937462 215.665021,79.2882839 C219.360669,82.7953831 221.773972,86.6998434 222.646365,91.0218204 C223.567176,95.5836746 222.669313,100.159332 220.191548,104.451297 C216.105211,111.529614 208.591643,117.11221 197.887587,121.534031 C193.589552,123.309539 188.726579,124.917559 183.293259,126.363748 C183.541176,126.92292 183.733521,127.516759 183.862138,128.139758 C186.954886,143.120505 187.618598,154.61061 185.619477,162.954027 C184.430513,167.916214 182.256801,171.964297 178.951503,174.884919 C175.46197,177.968334 171.050077,179.48137 166.092853,179.48137 C157.914908,179.48137 149.31785,175.756061 140.130385,168.678956 C136.343104,165.761613 132.410866,162.238839 128.325434,158.108619 C127.905075,158.765474 127.388968,159.376011 126.77857,159.919385 C115.35902,170.085028 105.744755,176.401073 97.5215915,178.836349 C92.6321009,180.284364 88.0414736,180.422318 83.8610636,179.016969 C79.4483686,177.533532 75.9323404,174.467051 73.4516862,170.171891 C69.3577116,163.083327 68.2780823,153.768902 69.8044053,142.267976 C70.449038,137.410634 71.56762,132.103898 73.1575891,126.339009 C72.5361041,126.276104 71.9120754,126.144816 71.2949591,125.940529 C56.8060684,121.144191 46.5464184,115.986312 40.3349789,110.091775 C36.6393312,106.584675 34.2260275,102.680215 33.3536352,98.3582381 C32.4328237,93.7963839 33.3306866,89.2207269 35.8084524,84.9287618 C39.8947886,77.8504443 47.4083565,72.2678481 58.1124133,67.8460273 C62.5385143,66.0176154 67.5637208,64.366822 73.1939394,62.8874674 C72.9933393,62.3969171 72.8349374,61.8811235 72.7239712,61.3436237 Z",
2323
- fill: "#002C4B",
2324
- fillRule: "nonzero",
2325
- transform: "translate(128.000000, 95.000000) scale(-1, 1) translate(-128.000000, -95.000000) "
2326
- }), /*#__PURE__*/React__namespace.createElement("path", {
2327
- d: "M113.396882,64 L142.608177,64 C144.399254,64 146.053521,64.958025 146.944933,66.5115174 L161.577138,92.0115174 C162.461464,93.5526583 162.461464,95.4473417 161.577138,96.9884826 L146.944933,122.488483 C146.053521,124.041975 144.399254,125 142.608177,125 L113.396882,125 C111.605806,125 109.951539,124.041975 109.060126,122.488483 L94.4279211,96.9884826 C93.543596,95.4473417 93.543596,93.5526583 94.4279211,92.0115174 L109.060126,66.5115174 C109.951539,64.958025 111.605806,64 113.396882,64 Z M138.987827,70.2765273 C140.779849,70.2765273 142.434839,71.2355558 143.325899,72.7903404 L154.343038,92.0138131 C155.225607,93.5537825 155.225607,95.4462175 154.343038,96.9861869 L143.325899,116.20966 C142.434839,117.764444 140.779849,118.723473 138.987827,118.723473 L117.017233,118.723473 C115.225211,118.723473 113.570221,117.764444 112.67916,116.20966 L101.662022,96.9861869 C100.779452,95.4462175 100.779452,93.5537825 101.662022,92.0138131 L112.67916,72.7903404 C113.570221,71.2355558 115.225211,70.2765273 117.017233,70.2765273 L138.987827,70.2765273 Z M135.080648,77.1414791 L120.924411,77.1414791 C119.134228,77.1414791 117.480644,78.0985567 116.5889,79.6508285 L116.5889,79.6508285 L109.489217,92.0093494 C108.603232,93.5515958 108.603232,95.4484042 109.489217,96.9906506 L109.489217,96.9906506 L116.5889,109.349172 C117.480644,110.901443 119.134228,111.858521 120.924411,111.858521 L120.924411,111.858521 L135.080648,111.858521 C136.870831,111.858521 138.524416,110.901443 139.41616,109.349172 L139.41616,109.349172 L146.515843,96.9906506 C147.401828,95.4484042 147.401828,93.5515958 146.515843,92.0093494 L146.515843,92.0093494 L139.41616,79.6508285 C138.524416,78.0985567 136.870831,77.1414791 135.080648,77.1414791 L135.080648,77.1414791 Z M131.319186,83.7122186 C133.108028,83.7122186 134.760587,84.6678753 135.652827,86.2183156 L138.983552,92.0060969 C139.87203,93.5500005 139.87203,95.4499995 138.983552,96.9939031 L135.652827,102.781684 C134.760587,104.332125 133.108028,105.287781 131.319186,105.287781 L124.685874,105.287781 C122.897032,105.287781 121.244473,104.332125 120.352233,102.781684 L117.021508,96.9939031 C116.13303,95.4499995 116.13303,93.5500005 117.021508,92.0060969 L120.352233,86.2183156 C121.244473,84.6678753 122.897032,83.7122186 124.685874,83.7122186 L131.319186,83.7122186 Z M128.003794,90.1848875 C126.459294,90.1848875 125.034382,91.0072828 124.263005,92.3424437 C123.491732,93.6774232 123.491732,95.3225768 124.263005,96.6575563 C125.034382,97.9927172 126.459294,98.8151125 128.001266,98.8151125 L128.001266,98.8151125 C129.545766,98.8151125 130.970678,97.9927172 131.742055,96.6575563 C132.513327,95.3225768 132.513327,93.6774232 131.742055,92.3424437 C130.970678,91.0072828 129.545766,90.1848875 128.003794,90.1848875 L128.003794,90.1848875 Z M93,94.5009646 L100.767764,94.5009646",
2328
- fill: "#FFD94C"
2329
- }), /*#__PURE__*/React__namespace.createElement("path", {
2330
- d: "M87.8601729,108.357758 C89.1715224,107.608286 90.8360246,108.074601 91.5779424,109.399303 L91.5779424,109.399303 L92.0525843,110.24352 C95.8563392,116.982993 99.8190116,123.380176 103.940602,129.435068 C108.807881,136.585427 114.28184,143.82411 120.362479,151.151115 C121.316878,152.30114 121.184944,154.011176 120.065686,154.997937 L120.065686,154.997937 L119.454208,155.534625 C99.3465389,173.103314 86.2778188,176.612552 80.2480482,166.062341 C74.3500652,155.742717 76.4844915,136.982888 86.6513274,109.782853 C86.876818,109.179582 87.3045861,108.675291 87.8601729,108.357758 Z M173.534177,129.041504 C174.986131,128.785177 176.375496,129.742138 176.65963,131.194242 L176.65963,131.194242 L176.812815,131.986376 C181.782365,157.995459 178.283348,171 166.315764,171 C154.609745,171 139.708724,159.909007 121.612702,137.727022 C121.211349,137.235047 120.994572,136.617371 121,135.981509 C121.013158,134.480686 122.235785,133.274651 123.730918,133.287756 L123.730918,133.287756 L124.684654,133.294531 C132.305698,133.335994 139.714387,133.071591 146.910723,132.501323 C155.409039,131.82788 164.283523,130.674607 173.534177,129.041504 Z M180.408726,73.8119663 C180.932139,72.4026903 182.508386,71.6634537 183.954581,72.149012 L183.954581,72.149012 L184.742552,72.4154854 C210.583763,81.217922 220.402356,90.8916805 214.198332,101.436761 C208.129904,111.751366 190.484347,119.260339 161.26166,123.963678 C160.613529,124.067994 159.948643,123.945969 159.382735,123.618843 C158.047025,122.846729 157.602046,121.158214 158.388848,119.847438 L158.388848,119.847438 L158.889328,119.0105 C162.877183,112.31633 166.481358,105.654262 169.701854,99.0242957 C173.50501,91.1948179 177.073967,82.7907081 180.408726,73.8119663 Z M94.7383398,66.0363218 C95.3864708,65.9320063 96.0513565,66.0540315 96.6172646,66.3811573 C97.9529754,67.153271 98.3979538,68.8417862 97.6111517,70.1525615 L97.6111517,70.1525615 L97.1106718,70.9895001 C93.1228168,77.6836699 89.5186416,84.3457379 86.2981462,90.9757043 C82.49499,98.8051821 78.9260328,107.209292 75.5912744,116.188034 C75.0678608,117.59731 73.4916142,118.336546 72.045419,117.850988 L72.045419,117.850988 L71.2574475,117.584515 C45.4162372,108.782078 35.597644,99.1083195 41.8016679,88.5632391 C47.8700957,78.2486335 65.515653,70.7396611 94.7383398,66.0363218 Z M136.545792,34.4653746 C156.653461,16.8966864 169.722181,13.3874478 175.751952,23.9376587 C181.649935,34.2572826 179.515508,53.0171122 169.348673,80.2171474 C169.123182,80.8204179 168.695414,81.324709 168.139827,81.6422422 C166.828478,82.3917144 165.163975,81.9253986 164.422058,80.6006966 L164.422058,80.6006966 L163.947416,79.7564798 C160.143661,73.0170065 156.180988,66.6198239 152.059398,60.564932 C147.192119,53.4145727 141.71816,46.1758903 135.637521,38.8488847 C134.683122,37.6988602 134.815056,35.9888243 135.934314,35.0020629 L135.934314,35.0020629 Z M90.6842361,18 C102.390255,18 117.291276,29.0909926 135.387298,51.2729777 C135.788651,51.7649527 136.005428,52.3826288 136,53.0184911 C135.986842,54.5193144 134.764215,55.7253489 133.269082,55.7122445 L133.269082,55.7122445 L132.315346,55.7054689 C124.694302,55.6640063 117.285613,55.9284091 110.089277,56.4986773 C101.590961,57.17212 92.7164767,58.325393 83.4658235,59.9584962 C82.0138691,60.2148231 80.6245044,59.2578618 80.3403697,57.805758 L80.3403697,57.805758 L80.1871846,57.0136235 C75.2176347,31.0045412 78.7166519,18 90.6842361,18 Z",
2331
- fill: "#FF4154"
2332
- }))));
2333
- }
2334
-
2335
- function ReactQueryDevtools$1({
2336
- initialIsOpen,
2337
- panelProps = {},
2338
- closeButtonProps = {},
2339
- toggleButtonProps = {},
2340
- position = 'bottom-left',
2341
- containerElement: Container = 'aside',
2342
- queryClient,
2343
- styleNonce,
2344
- panelPosition: initialPanelPosition = 'bottom',
2345
- errorTypes = []
2346
- }) {
2347
- const rootRef = React__namespace.useRef(null);
2348
- const panelRef = React__namespace.useRef(null);
2349
- const [isOpen, setIsOpen] = useLocalStorage('reactQueryDevtoolsOpen', initialIsOpen);
2350
- const [devtoolsHeight, setDevtoolsHeight] = useLocalStorage('reactQueryDevtoolsHeight', defaultPanelSize);
2351
- const [devtoolsWidth, setDevtoolsWidth] = useLocalStorage('reactQueryDevtoolsWidth', defaultPanelSize);
2352
- const [panelPosition = 'bottom', setPanelPosition] = useLocalStorage('reactQueryDevtoolsPanelPosition', initialPanelPosition);
2353
- const [isResolvedOpen, setIsResolvedOpen] = React__namespace.useState(false);
2354
- const [isResizing, setIsResizing] = React__namespace.useState(false);
2355
- const isMounted = useIsMounted();
2356
- const handleDragStart = (panelElement, startEvent) => {
2357
- if (!panelElement) return;
2358
- if (startEvent.button !== 0) return; // Only allow left click for drag
2359
- const isVertical = isVerticalSide(panelPosition);
2360
- setIsResizing(true);
2361
- const {
2362
- height,
2363
- width
2364
- } = panelElement.getBoundingClientRect();
2365
- const startX = startEvent.clientX;
2366
- const startY = startEvent.clientY;
2367
- let newSize = 0;
2368
- const run = moveEvent => {
2369
- // prevent mouse selecting stuff with mouse drag
2370
- moveEvent.preventDefault();
2371
-
2372
- // calculate the correct size based on mouse position and current panel position
2373
- // hint: it is different formula for the opposite sides
2374
- if (isVertical) {
2375
- newSize = width + (panelPosition === 'right' ? startX - moveEvent.clientX : moveEvent.clientX - startX);
2376
- setDevtoolsWidth(newSize);
2377
- } else {
2378
- newSize = height + (panelPosition === 'bottom' ? startY - moveEvent.clientY : moveEvent.clientY - startY);
2379
- setDevtoolsHeight(newSize);
2380
- }
2381
- if (newSize < minPanelSize) {
2382
- setIsOpen(false);
2383
- } else {
2384
- setIsOpen(true);
2385
- }
2386
- };
2387
- const unsub = () => {
2388
- if (isResizing) {
2389
- setIsResizing(false);
2390
- }
2391
- document.removeEventListener('mousemove', run, false);
2392
- document.removeEventListener('mouseUp', unsub, false);
2393
- };
2394
- document.addEventListener('mousemove', run, false);
2395
- document.addEventListener('mouseup', unsub, false);
2396
- };
2397
- React__namespace.useEffect(() => {
2398
- setIsResolvedOpen(isOpen ?? false);
2399
- }, [isOpen, isResolvedOpen, setIsResolvedOpen]);
2400
-
2401
- // Toggle panel visibility before/after transition (depending on direction).
2402
- // Prevents focusing in a closed panel.
2403
- React__namespace.useEffect(() => {
2404
- const ref = panelRef.current;
2405
- if (ref) {
2406
- const handlePanelTransitionStart = () => {
2407
- if (isResolvedOpen) {
2408
- ref.style.visibility = 'visible';
2409
- }
2410
- };
2411
- const handlePanelTransitionEnd = () => {
2412
- if (!isResolvedOpen) {
2413
- ref.style.visibility = 'hidden';
2414
- }
2415
- };
2416
- ref.addEventListener('transitionstart', handlePanelTransitionStart);
2417
- ref.addEventListener('transitionend', handlePanelTransitionEnd);
2418
- return () => {
2419
- ref.removeEventListener('transitionstart', handlePanelTransitionStart);
2420
- ref.removeEventListener('transitionend', handlePanelTransitionEnd);
2421
- };
2422
- }
2423
- return;
2424
- }, [isResolvedOpen]);
2425
- React__namespace.useEffect(() => {
2426
- if (isResolvedOpen && rootRef.current?.parentElement) {
2427
- const {
2428
- parentElement
2429
- } = rootRef.current;
2430
- const styleProp = getSidedProp('padding', panelPosition);
2431
- const isVertical = isVerticalSide(panelPosition);
2432
- const previousPaddings = (({
2433
- padding,
2434
- paddingTop,
2435
- paddingBottom,
2436
- paddingLeft,
2437
- paddingRight
2438
- }) => ({
2439
- padding,
2440
- paddingTop,
2441
- paddingBottom,
2442
- paddingLeft,
2443
- paddingRight
2444
- }))(parentElement.style);
2445
- const run = () => {
2446
- // reset the padding
2447
- parentElement.style.padding = '0px';
2448
- parentElement.style.paddingTop = '0px';
2449
- parentElement.style.paddingBottom = '0px';
2450
- parentElement.style.paddingLeft = '0px';
2451
- parentElement.style.paddingRight = '0px';
2452
- // set the new padding based on the new panel position
2453
-
2454
- parentElement.style[styleProp] = `${isVertical ? devtoolsWidth : devtoolsHeight}px`;
2455
- };
2456
- run();
2457
- if (typeof window !== 'undefined') {
2458
- window.addEventListener('resize', run);
2459
- return () => {
2460
- window.removeEventListener('resize', run);
2461
- Object.entries(previousPaddings).forEach(([property, previousValue]) => {
2462
- parentElement.style[property] = previousValue;
2463
- });
2464
- };
2465
- }
2466
- }
2467
- return;
2468
- }, [isResolvedOpen, panelPosition, devtoolsHeight, devtoolsWidth]);
2469
- const {
2470
- style: panelStyle = {},
2471
- ...otherPanelProps
2472
- } = panelProps;
2473
- const {
2474
- style: toggleButtonStyle = {},
2475
- onClick: onToggleClick,
2476
- ...otherToggleButtonProps
2477
- } = toggleButtonProps;
2478
-
2479
- // get computed style based on panel position
2480
- const style = getSidePanelStyle({
2481
- position: panelPosition,
2482
- devtoolsTheme: defaultTheme,
2483
- isOpen: isResolvedOpen,
2484
- height: devtoolsHeight,
2485
- width: devtoolsWidth,
2486
- isResizing,
2487
- panelStyle
2488
- });
2489
-
2490
- // Do not render on the server
2491
- if (!isMounted()) return null;
2492
- return /*#__PURE__*/React__namespace.createElement(Container, {
2493
- ref: rootRef,
2494
- className: "ReactQueryDevtools",
2495
- "aria-label": "React Query Devtools"
2496
- }, /*#__PURE__*/React__namespace.createElement(ThemeProvider, {
2497
- theme: defaultTheme
2498
- }, /*#__PURE__*/React__namespace.createElement(ReactQueryDevtoolsPanel$1, _extends({
2499
- ref: panelRef,
2500
- queryClient: queryClient,
2501
- styleNonce: styleNonce,
2502
- position: panelPosition,
2503
- onPositionChange: setPanelPosition,
2504
- showCloseButton: true,
2505
- closeButtonProps: closeButtonProps
2506
- }, otherPanelProps, {
2507
- style: style,
2508
- isOpen: isResolvedOpen,
2509
- setIsOpen: setIsOpen,
2510
- onDragStart: e => handleDragStart(panelRef.current, e),
2511
- errorTypes: errorTypes
2512
- }))), !isResolvedOpen ? /*#__PURE__*/React__namespace.createElement("button", _extends({
2513
- type: "button"
2514
- }, otherToggleButtonProps, {
2515
- "aria-label": "Open React Query Devtools",
2516
- "aria-controls": "ReactQueryDevtoolsPanel",
2517
- "aria-haspopup": "true",
2518
- "aria-expanded": "false",
2519
- onClick: e => {
2520
- setIsOpen(true);
2521
- onToggleClick?.(e);
2522
- },
2523
- style: {
2524
- background: 'none',
2525
- border: 0,
2526
- padding: 0,
2527
- position: 'fixed',
2528
- zIndex: 99999,
2529
- display: 'inline-flex',
2530
- fontSize: '1.5em',
2531
- margin: '.5em',
2532
- cursor: 'pointer',
2533
- width: 'fit-content',
2534
- ...(position === 'top-right' ? {
2535
- top: '0',
2536
- right: '0'
2537
- } : position === 'top-left' ? {
2538
- top: '0',
2539
- left: '0'
2540
- } : position === 'bottom-right' ? {
2541
- bottom: '0',
2542
- right: '0'
2543
- } : {
2544
- bottom: '0',
2545
- left: '0'
2546
- }),
2547
- ...toggleButtonStyle
2548
- }
2549
- }), /*#__PURE__*/React__namespace.createElement(Logo, {
2550
- "aria-hidden": true
2551
- }), /*#__PURE__*/React__namespace.createElement(ScreenReader, {
2552
- text: "Open React Query Devtools"
2553
- })) : null);
2554
- }
2555
- const useSubscribeToQueryCache = (queryCache, getSnapshot, skip = false) => {
2556
- return React__namespace.useSyncExternalStore(React__namespace.useCallback(onStoreChange => {
2557
- if (!skip) return queryCache.subscribe(reactQuery.notifyManager.batchCalls(onStoreChange));
2558
- return () => {
2559
- return;
2560
- };
2561
- }, [queryCache, skip]), getSnapshot, getSnapshot);
2562
- };
2563
- const ReactQueryDevtoolsPanel$1 = /*#__PURE__*/React__namespace.forwardRef(function ReactQueryDevtoolsPanel(props, ref) {
2564
- const {
2565
- isOpen = true,
2566
- styleNonce,
2567
- setIsOpen,
2568
- queryClient,
2569
- onDragStart,
2570
- onPositionChange,
2571
- showCloseButton,
2572
- position,
2573
- closeButtonProps = {},
2574
- errorTypes = [],
2575
- ...panelProps
2576
- } = props;
2577
- const {
2578
- onClick: onCloseClick,
2579
- ...otherCloseButtonProps
2580
- } = closeButtonProps;
2581
- const client = reactQuery.useQueryClient(queryClient);
2582
- const queryCache = client.getQueryCache();
2583
- const [sort, setSort] = useLocalStorage('reactQueryDevtoolsSortFn', Object.keys(sortFns)[0]);
2584
- const [filter, setFilter] = useLocalStorage('reactQueryDevtoolsFilter', '');
2585
- const [baseSort, setBaseSort] = useLocalStorage('reactQueryDevtoolsBaseSort', 1);
2586
- const sortFn = React__namespace.useMemo(() => sortFns[sort], [sort]);
2587
- const queriesCount = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().length, !isOpen);
2588
- const [activeQueryHash, setActiveQueryHash] = useLocalStorage('reactQueryDevtoolsActiveQueryHash', '');
2589
- const queries = React__namespace.useMemo(() => {
2590
- const unsortedQueries = queryCache.getAll();
2591
- if (queriesCount === 0) {
2592
- return [];
2593
- }
2594
- const filtered = filter ? unsortedQueries.filter(item => rankItem(item.queryHash, filter).passed) : [...unsortedQueries];
2595
- const sorted = sortFn ? filtered.sort((a, b) => sortFn(a, b) * baseSort) : filtered;
2596
- return sorted;
2597
- }, [baseSort, sortFn, filter, queriesCount, queryCache]);
2598
- const [isMockOffline, setMockOffline] = React__namespace.useState(false);
2599
- return /*#__PURE__*/React__namespace.createElement(ThemeProvider, {
2600
- theme: defaultTheme
2601
- }, /*#__PURE__*/React__namespace.createElement(Panel, _extends({
2602
- ref: ref,
2603
- className: "ReactQueryDevtoolsPanel",
2604
- "aria-label": "React Query Devtools Panel",
2605
- id: "ReactQueryDevtoolsPanel"
2606
- }, panelProps, {
2607
- style: {
2608
- height: defaultPanelSize,
2609
- position: 'relative',
2610
- ...panelProps.style
2611
- }
2612
- }), /*#__PURE__*/React__namespace.createElement("style", {
2613
- nonce: styleNonce,
2614
- dangerouslySetInnerHTML: {
2615
- __html: `
2616
- .ReactQueryDevtoolsPanel * {
2617
- scrollbar-color: ${defaultTheme.backgroundAlt} ${defaultTheme.gray};
2618
- }
2619
-
2620
- .ReactQueryDevtoolsPanel *::-webkit-scrollbar, .ReactQueryDevtoolsPanel scrollbar {
2621
- width: 1em;
2622
- height: 1em;
2623
- }
2624
-
2625
- .ReactQueryDevtoolsPanel *::-webkit-scrollbar-track, .ReactQueryDevtoolsPanel scrollbar-track {
2626
- background: ${defaultTheme.backgroundAlt};
2627
- }
2628
-
2629
- .ReactQueryDevtoolsPanel *::-webkit-scrollbar-thumb, .ReactQueryDevtoolsPanel scrollbar-thumb {
2630
- background: ${defaultTheme.gray};
2631
- border-radius: .5em;
2632
- border: 3px solid ${defaultTheme.backgroundAlt};
2633
- }
2634
- `
2635
- }
2636
- }), /*#__PURE__*/React__namespace.createElement("div", {
2637
- style: getResizeHandleStyle(position),
2638
- onMouseDown: onDragStart
2639
- }), isOpen && /*#__PURE__*/React__namespace.createElement("div", {
2640
- style: {
2641
- flex: '1 1 500px',
2642
- minHeight: '40%',
2643
- maxHeight: '100%',
2644
- overflow: 'auto',
2645
- borderRight: `1px solid ${defaultTheme.grayAlt}`,
2646
- display: 'flex',
2647
- flexDirection: 'column'
2648
- }
2649
- }, /*#__PURE__*/React__namespace.createElement("div", {
2650
- style: {
2651
- padding: '.5em',
2652
- background: defaultTheme.backgroundAlt,
2653
- display: 'flex',
2654
- justifyContent: 'space-between',
2655
- alignItems: 'center'
2656
- }
2657
- }, /*#__PURE__*/React__namespace.createElement("button", {
2658
- type: "button",
2659
- "aria-label": "Close React Query Devtools",
2660
- "aria-controls": "ReactQueryDevtoolsPanel",
2661
- "aria-haspopup": "true",
2662
- "aria-expanded": "true",
2663
- onClick: () => setIsOpen(false),
2664
- style: {
2665
- display: 'inline-flex',
2666
- background: 'none',
2667
- border: 0,
2668
- padding: 0,
2669
- marginRight: '.5em',
2670
- cursor: 'pointer'
2671
- }
2672
- }, /*#__PURE__*/React__namespace.createElement(Logo, {
2673
- "aria-hidden": true
2674
- }), /*#__PURE__*/React__namespace.createElement(ScreenReader, {
2675
- text: "Close React Query Devtools"
2676
- })), /*#__PURE__*/React__namespace.createElement("div", {
2677
- style: {
2678
- display: 'flex',
2679
- flexDirection: 'column'
2680
- }
2681
- }, /*#__PURE__*/React__namespace.createElement("div", {
2682
- style: {
2683
- display: 'flex',
2684
- justifyContent: 'space-between',
2685
- alignItems: 'center',
2686
- marginBottom: '.5em'
2687
- }
2688
- }, /*#__PURE__*/React__namespace.createElement(QueryStatusCount, {
2689
- queryCache: queryCache
2690
- }), position && onPositionChange ? /*#__PURE__*/React__namespace.createElement(Select, {
2691
- "aria-label": "Panel position",
2692
- value: position,
2693
- style: {
2694
- marginInlineStart: '.5em'
2695
- },
2696
- onChange: e => onPositionChange(e.target.value)
2697
- }, /*#__PURE__*/React__namespace.createElement("option", {
2698
- value: "left"
2699
- }, "Left"), /*#__PURE__*/React__namespace.createElement("option", {
2700
- value: "right"
2701
- }, "Right"), /*#__PURE__*/React__namespace.createElement("option", {
2702
- value: "top"
2703
- }, "Top"), /*#__PURE__*/React__namespace.createElement("option", {
2704
- value: "bottom"
2705
- }, "Bottom")) : null), /*#__PURE__*/React__namespace.createElement("div", {
2706
- style: {
2707
- display: 'flex',
2708
- alignItems: 'center',
2709
- flexWrap: 'wrap',
2710
- gap: '0.5em'
2711
- }
2712
- }, /*#__PURE__*/React__namespace.createElement(Input, {
2713
- placeholder: "Filter",
2714
- "aria-label": "Filter by queryhash",
2715
- value: filter ?? '',
2716
- onChange: e => setFilter(e.target.value),
2717
- onKeyDown: e => {
2718
- if (e.key === 'Escape') setFilter('');
2719
- },
2720
- style: {
2721
- flex: '1',
2722
- width: '100%'
2723
- }
2724
- }), /*#__PURE__*/React__namespace.createElement(Select, {
2725
- "aria-label": "Sort queries",
2726
- value: sort,
2727
- onChange: e => setSort(e.target.value),
2728
- style: {
2729
- flex: '1',
2730
- minWidth: 75,
2731
- marginRight: '.5em'
2732
- }
2733
- }, Object.keys(sortFns).map(key => /*#__PURE__*/React__namespace.createElement("option", {
2734
- key: key,
2735
- value: key
2736
- }, "Sort by ", key))), /*#__PURE__*/React__namespace.createElement(Button, {
2737
- type: "button",
2738
- onClick: () => setBaseSort(old => old * -1),
2739
- style: {
2740
- padding: '.3em .4em',
2741
- marginRight: '.5em'
2742
- }
2743
- }, baseSort === 1 ? '⬆ Asc' : '⬇ Desc'), /*#__PURE__*/React__namespace.createElement(Button, {
2744
- type: "button",
2745
- onClick: () => {
2746
- if (isMockOffline) {
2747
- reactQuery.onlineManager.setOnline(undefined);
2748
- setMockOffline(false);
2749
- window.dispatchEvent(new Event('online'));
2750
- } else {
2751
- reactQuery.onlineManager.setOnline(false);
2752
- setMockOffline(true);
2753
- }
2754
- },
2755
- "aria-label": isMockOffline ? 'Restore offline mock' : 'Mock offline behavior',
2756
- title: isMockOffline ? 'Restore offline mock' : 'Mock offline behavior',
2757
- style: {
2758
- padding: '0',
2759
- height: '2em'
2760
- }
2761
- }, /*#__PURE__*/React__namespace.createElement("svg", {
2762
- xmlns: "http://www.w3.org/2000/svg",
2763
- width: "2em",
2764
- height: "2em",
2765
- viewBox: "0 0 24 24",
2766
- stroke: isMockOffline ? defaultTheme.danger : 'currentColor',
2767
- fill: "none"
2768
- }, isMockOffline ? /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement("path", {
2769
- stroke: "none",
2770
- d: "M0 0h24v24H0z",
2771
- fill: "none"
2772
- }), /*#__PURE__*/React__namespace.createElement("line", {
2773
- x1: "12",
2774
- y1: "18",
2775
- x2: "12.01",
2776
- y2: "18"
2777
- }), /*#__PURE__*/React__namespace.createElement("path", {
2778
- d: "M9.172 15.172a4 4 0 0 1 5.656 0"
2779
- }), /*#__PURE__*/React__namespace.createElement("path", {
2780
- d: "M6.343 12.343a7.963 7.963 0 0 1 3.864 -2.14m4.163 .155a7.965 7.965 0 0 1 3.287 2"
2781
- }), /*#__PURE__*/React__namespace.createElement("path", {
2782
- d: "M3.515 9.515a12 12 0 0 1 3.544 -2.455m3.101 -.92a12 12 0 0 1 10.325 3.374"
2783
- }), /*#__PURE__*/React__namespace.createElement("line", {
2784
- x1: "3",
2785
- y1: "3",
2786
- x2: "21",
2787
- y2: "21"
2788
- })) : /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement("path", {
2789
- stroke: "none",
2790
- d: "M0 0h24v24H0z",
2791
- fill: "none"
2792
- }), /*#__PURE__*/React__namespace.createElement("line", {
2793
- x1: "12",
2794
- y1: "18",
2795
- x2: "12.01",
2796
- y2: "18"
2797
- }), /*#__PURE__*/React__namespace.createElement("path", {
2798
- d: "M9.172 15.172a4 4 0 0 1 5.656 0"
2799
- }), /*#__PURE__*/React__namespace.createElement("path", {
2800
- d: "M6.343 12.343a8 8 0 0 1 11.314 0"
2801
- }), /*#__PURE__*/React__namespace.createElement("path", {
2802
- d: "M3.515 9.515c4.686 -4.687 12.284 -4.687 17 0"
2803
- }))), /*#__PURE__*/React__namespace.createElement(ScreenReader, {
2804
- text: isMockOffline ? 'Restore offline mock' : 'Mock offline behavior'
2805
- }))))), /*#__PURE__*/React__namespace.createElement("div", {
2806
- style: {
2807
- overflowY: 'auto',
2808
- flex: '1'
2809
- }
2810
- }, queries.map(query => {
2811
- return /*#__PURE__*/React__namespace.createElement(QueryRow, {
2812
- queryKey: query.queryKey,
2813
- activeQueryHash: activeQueryHash,
2814
- setActiveQueryHash: setActiveQueryHash,
2815
- key: query.queryHash,
2816
- queryCache: queryCache
2817
- });
2818
- }))), activeQueryHash && isOpen ? /*#__PURE__*/React__namespace.createElement(ActiveQuery, {
2819
- activeQueryHash: activeQueryHash,
2820
- queryCache: queryCache,
2821
- queryClient: client,
2822
- errorTypes: errorTypes
2823
- }) : null, showCloseButton ? /*#__PURE__*/React__namespace.createElement(Button, _extends({
2824
- type: "button",
2825
- "aria-controls": "ReactQueryDevtoolsPanel",
2826
- "aria-haspopup": "true",
2827
- "aria-expanded": "true"
2828
- }, otherCloseButtonProps, {
2829
- style: {
2830
- position: 'absolute',
2831
- zIndex: 99999,
2832
- margin: '.5em',
2833
- bottom: 0,
2834
- left: 0,
2835
- ...otherCloseButtonProps.style
2836
- },
2837
- onClick: e => {
2838
- setIsOpen(false);
2839
- onCloseClick?.(e);
2840
- }
2841
- }), "Close") : null));
2842
- });
2843
- const ActiveQuery = ({
2844
- queryCache,
2845
- activeQueryHash,
2846
- queryClient,
2847
- errorTypes
2848
- }) => {
2849
- const activeQuery = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().find(query => query.queryHash === activeQueryHash));
2850
- const activeQueryState = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().find(query => query.queryHash === activeQueryHash)?.state);
2851
- const isStale = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().find(query => query.queryHash === activeQueryHash)?.isStale()) ?? false;
2852
- const observerCount = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().find(query => query.queryHash === activeQueryHash)?.getObserversCount()) ?? 0;
2853
- const handleRefetch = () => {
2854
- const promise = activeQuery?.fetch();
2855
- promise?.catch(noop);
2856
- };
2857
- const currentErrorTypeName = React.useMemo(() => {
2858
- if (activeQuery && activeQueryState?.error) {
2859
- const errorType = errorTypes.find(type => type.initializer(activeQuery).toString() === activeQueryState.error?.toString());
2860
- return errorType?.name;
2861
- }
2862
- return undefined;
2863
- }, [activeQuery, activeQueryState?.error, errorTypes]);
2864
- if (!activeQuery || !activeQueryState) {
2865
- return null;
2866
- }
2867
- const triggerError = errorType => {
2868
- const error = errorType?.initializer(activeQuery) ?? new Error('Unknown error from devtools');
2869
- const __previousQueryOptions = activeQuery.options;
2870
- activeQuery.setState({
2871
- status: 'error',
2872
- error,
2873
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
2874
- fetchMeta: {
2875
- ...activeQuery.state.fetchMeta,
2876
- __previousQueryOptions
2877
- }
2878
- });
2879
- };
2880
- const restoreQueryAfterLoadingOrError = () => {
2881
- activeQuery.fetch(activeQuery.state.fetchMeta.__previousQueryOptions, {
2882
- // Make sure this fetch will cancel the previous one
2883
- cancelRefetch: true
2884
- });
2885
- };
2886
- return /*#__PURE__*/React__namespace.createElement(ActiveQueryPanel, null, /*#__PURE__*/React__namespace.createElement("div", {
2887
- style: {
2888
- padding: '.5em',
2889
- background: defaultTheme.backgroundAlt,
2890
- position: 'sticky',
2891
- top: 0,
2892
- zIndex: 1
2893
- }
2894
- }, "Query Details"), /*#__PURE__*/React__namespace.createElement("div", {
2895
- style: {
2896
- padding: '.5em'
2897
- }
2898
- }, /*#__PURE__*/React__namespace.createElement("div", {
2899
- style: {
2900
- marginBottom: '.5em',
2901
- display: 'flex',
2902
- alignItems: 'flex-start',
2903
- justifyContent: 'space-between'
2904
- }
2905
- }, /*#__PURE__*/React__namespace.createElement(Code, {
2906
- style: {
2907
- lineHeight: '1.8em'
2908
- }
2909
- }, /*#__PURE__*/React__namespace.createElement("pre", {
2910
- style: {
2911
- margin: 0,
2912
- padding: 0,
2913
- overflow: 'auto'
2914
- }
2915
- }, displayValue(activeQuery.queryKey, true))), /*#__PURE__*/React__namespace.createElement("span", {
2916
- style: {
2917
- padding: '0.3em .6em',
2918
- borderRadius: '0.4em',
2919
- fontWeight: 'bold',
2920
- textShadow: '0 2px 10px black',
2921
- background: getQueryStatusColor({
2922
- queryState: activeQueryState,
2923
- isStale: isStale,
2924
- observerCount: observerCount,
2925
- theme: defaultTheme
2926
- }),
2927
- flexShrink: 0
2928
- }
2929
- }, getQueryStatusLabel(activeQuery))), /*#__PURE__*/React__namespace.createElement("div", {
2930
- style: {
2931
- marginBottom: '.5em',
2932
- display: 'flex',
2933
- alignItems: 'center',
2934
- justifyContent: 'space-between'
2935
- }
2936
- }, "Observers: ", /*#__PURE__*/React__namespace.createElement(Code, null, observerCount)), /*#__PURE__*/React__namespace.createElement("div", {
2937
- style: {
2938
- display: 'flex',
2939
- alignItems: 'center',
2940
- justifyContent: 'space-between'
2941
- }
2942
- }, "Last Updated:", ' ', /*#__PURE__*/React__namespace.createElement(Code, null, new Date(activeQueryState.dataUpdatedAt).toLocaleTimeString()))), /*#__PURE__*/React__namespace.createElement("div", {
2943
- style: {
2944
- background: defaultTheme.backgroundAlt,
2945
- padding: '.5em',
2946
- position: 'sticky',
2947
- top: 0,
2948
- zIndex: 1
2949
- }
2950
- }, "Actions"), /*#__PURE__*/React__namespace.createElement("div", {
2951
- style: {
2952
- padding: '0.5em',
2953
- display: 'flex',
2954
- flexWrap: 'wrap',
2955
- gap: '0.5em',
2956
- alignItems: 'flex-end'
2957
- }
2958
- }, /*#__PURE__*/React__namespace.createElement(Button, {
2959
- type: "button",
2960
- onClick: handleRefetch,
2961
- disabled: activeQueryState.fetchStatus === 'fetching',
2962
- style: {
2963
- background: defaultTheme.active
2964
- }
2965
- }, "Refetch"), ' ', /*#__PURE__*/React__namespace.createElement(Button, {
2966
- type: "button",
2967
- onClick: () => queryClient.invalidateQueries(activeQuery),
2968
- style: {
2969
- background: defaultTheme.warning,
2970
- color: defaultTheme.inputTextColor
2971
- }
2972
- }, "Invalidate"), ' ', /*#__PURE__*/React__namespace.createElement(Button, {
2973
- type: "button",
2974
- onClick: () => queryClient.resetQueries(activeQuery),
2975
- style: {
2976
- background: defaultTheme.gray
2977
- }
2978
- }, "Reset"), ' ', /*#__PURE__*/React__namespace.createElement(Button, {
2979
- type: "button",
2980
- onClick: () => queryClient.removeQueries(activeQuery),
2981
- style: {
2982
- background: defaultTheme.danger
2983
- }
2984
- }, "Remove"), ' ', /*#__PURE__*/React__namespace.createElement(Button, {
2985
- type: "button",
2986
- onClick: () => {
2987
- if (activeQuery.state.data === undefined) {
2988
- restoreQueryAfterLoadingOrError();
2989
- } else {
2990
- const __previousQueryOptions = activeQuery.options;
2991
- // Trigger a fetch in order to trigger suspense as well.
2992
- activeQuery.fetch({
2993
- ...__previousQueryOptions,
2994
- queryFn: () => {
2995
- return new Promise(() => {
2996
- // Never resolve
2997
- });
2998
- },
2999
- gcTime: -1
3000
- });
3001
- activeQuery.setState({
3002
- data: undefined,
3003
- status: 'pending',
3004
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
3005
- fetchMeta: {
3006
- ...activeQuery.state.fetchMeta,
3007
- __previousQueryOptions
3008
- }
3009
- });
3010
- }
3011
- },
3012
- style: {
3013
- background: defaultTheme.paused
3014
- }
3015
- }, activeQuery.state.status === 'pending' ? 'Restore' : 'Trigger', ' ', "loading"), ' ', errorTypes.length === 0 || activeQuery.state.status === 'error' ? /*#__PURE__*/React__namespace.createElement(Button, {
3016
- type: "button",
3017
- onClick: () => {
3018
- if (!activeQuery.state.error) {
3019
- triggerError();
3020
- } else {
3021
- queryClient.resetQueries(activeQuery);
3022
- }
3023
- },
3024
- style: {
3025
- background: defaultTheme.danger
3026
- }
3027
- }, activeQuery.state.status === 'error' ? 'Restore' : 'Trigger', " error") : /*#__PURE__*/React__namespace.createElement("label", null, "Trigger error:", /*#__PURE__*/React__namespace.createElement(Select, {
3028
- value: currentErrorTypeName ?? '',
3029
- style: {
3030
- marginInlineStart: '.5em'
3031
- },
3032
- onChange: e => {
3033
- const errorType = errorTypes.find(t => t.name === e.target.value);
3034
- triggerError(errorType);
3035
- }
3036
- }, /*#__PURE__*/React__namespace.createElement("option", {
3037
- key: "",
3038
- value: ""
3039
- }), errorTypes.map(errorType => /*#__PURE__*/React__namespace.createElement("option", {
3040
- key: errorType.name,
3041
- value: errorType.name
3042
- }, errorType.name))))), /*#__PURE__*/React__namespace.createElement("div", {
3043
- style: {
3044
- background: defaultTheme.backgroundAlt,
3045
- padding: '.5em',
3046
- position: 'sticky',
3047
- top: 0,
3048
- zIndex: 1
3049
- }
3050
- }, "Data Explorer"), /*#__PURE__*/React__namespace.createElement("div", {
3051
- style: {
3052
- padding: '.5em'
3053
- }
3054
- }, /*#__PURE__*/React__namespace.createElement(Explorer, {
3055
- label: "Data",
3056
- value: activeQueryState.data,
3057
- defaultExpanded: {},
3058
- copyable: true
3059
- })), /*#__PURE__*/React__namespace.createElement("div", {
3060
- style: {
3061
- background: defaultTheme.backgroundAlt,
3062
- padding: '.5em',
3063
- position: 'sticky',
3064
- top: 0,
3065
- zIndex: 1
3066
- }
3067
- }, "Query Explorer"), /*#__PURE__*/React__namespace.createElement("div", {
3068
- style: {
3069
- padding: '.5em'
3070
- }
3071
- }, /*#__PURE__*/React__namespace.createElement(Explorer, {
3072
- label: "Query",
3073
- value: activeQuery,
3074
- defaultExpanded: {
3075
- queryKey: true
3076
- }
3077
- })));
3078
- };
3079
- const QueryStatusCount = ({
3080
- queryCache
3081
- }) => {
3082
- const hasFresh = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().filter(q => getQueryStatusLabel(q) === 'fresh').length);
3083
- const hasFetching = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().filter(q => getQueryStatusLabel(q) === 'fetching').length);
3084
- const hasPaused = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().filter(q => getQueryStatusLabel(q) === 'paused').length);
3085
- const hasStale = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().filter(q => getQueryStatusLabel(q) === 'stale').length);
3086
- const hasInactive = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().filter(q => getQueryStatusLabel(q) === 'inactive').length);
3087
- return /*#__PURE__*/React__namespace.createElement(QueryKeys, null, /*#__PURE__*/React__namespace.createElement(QueryKey, {
3088
- style: {
3089
- background: defaultTheme.success,
3090
- opacity: hasFresh ? 1 : 0.3
3091
- }
3092
- }, "fresh ", /*#__PURE__*/React__namespace.createElement(Code, null, "(", hasFresh, ")")), ' ', /*#__PURE__*/React__namespace.createElement(QueryKey, {
3093
- style: {
3094
- background: defaultTheme.active,
3095
- opacity: hasFetching ? 1 : 0.3
3096
- }
3097
- }, "fetching ", /*#__PURE__*/React__namespace.createElement(Code, null, "(", hasFetching, ")")), ' ', /*#__PURE__*/React__namespace.createElement(QueryKey, {
3098
- style: {
3099
- background: defaultTheme.paused,
3100
- opacity: hasPaused ? 1 : 0.3
3101
- }
3102
- }, "paused ", /*#__PURE__*/React__namespace.createElement(Code, null, "(", hasPaused, ")")), ' ', /*#__PURE__*/React__namespace.createElement(QueryKey, {
3103
- style: {
3104
- background: defaultTheme.warning,
3105
- color: 'black',
3106
- textShadow: '0',
3107
- opacity: hasStale ? 1 : 0.3
3108
- }
3109
- }, "stale ", /*#__PURE__*/React__namespace.createElement(Code, null, "(", hasStale, ")")), ' ', /*#__PURE__*/React__namespace.createElement(QueryKey, {
3110
- style: {
3111
- background: defaultTheme.gray,
3112
- opacity: hasInactive ? 1 : 0.3
3113
- }
3114
- }, "inactive ", /*#__PURE__*/React__namespace.createElement(Code, null, "(", hasInactive, ")")));
3115
- };
3116
- const QueryRow = /*#__PURE__*/React__namespace.memo(({
3117
- queryKey,
3118
- setActiveQueryHash,
3119
- activeQueryHash,
3120
- queryCache
3121
- }) => {
3122
- const queryHash = useSubscribeToQueryCache(queryCache, () => queryCache.find({
3123
- queryKey
3124
- })?.queryHash) ?? '';
3125
- const queryState = useSubscribeToQueryCache(queryCache, () => queryCache.find({
3126
- queryKey
3127
- })?.state);
3128
- const isStale = useSubscribeToQueryCache(queryCache, () => queryCache.find({
3129
- queryKey
3130
- })?.isStale()) ?? false;
3131
- const isDisabled = useSubscribeToQueryCache(queryCache, () => queryCache.find({
3132
- queryKey
3133
- })?.isDisabled()) ?? false;
3134
- const observerCount = useSubscribeToQueryCache(queryCache, () => queryCache.find({
3135
- queryKey
3136
- })?.getObserversCount()) ?? 0;
3137
- if (!queryState) {
3138
- return null;
3139
- }
3140
- return /*#__PURE__*/React__namespace.createElement("div", {
3141
- role: "button",
3142
- "aria-label": `Open query details for ${queryHash}`,
3143
- onClick: () => setActiveQueryHash(activeQueryHash === queryHash ? '' : queryHash),
3144
- style: {
3145
- display: 'flex',
3146
- borderBottom: `solid 1px ${defaultTheme.grayAlt}`,
3147
- cursor: 'pointer',
3148
- background: queryHash === activeQueryHash ? 'rgba(255,255,255,.1)' : undefined
3149
- }
3150
- }, /*#__PURE__*/React__namespace.createElement("div", {
3151
- style: {
3152
- flex: '0 0 auto',
3153
- width: '2em',
3154
- height: '2em',
3155
- background: getQueryStatusColor({
3156
- queryState,
3157
- isStale,
3158
- observerCount,
3159
- theme: defaultTheme
3160
- }),
3161
- display: 'flex',
3162
- alignItems: 'center',
3163
- justifyContent: 'center',
3164
- fontWeight: 'bold',
3165
- textShadow: isStale ? '0' : '0 0 10px black',
3166
- color: isStale ? 'black' : 'white'
3167
- }
3168
- }, observerCount), isDisabled ? /*#__PURE__*/React__namespace.createElement("div", {
3169
- style: {
3170
- flex: '0 0 auto',
3171
- height: '2em',
3172
- background: defaultTheme.gray,
3173
- display: 'flex',
3174
- alignItems: 'center',
3175
- fontWeight: 'bold',
3176
- padding: '0 0.5em'
3177
- }
3178
- }, "disabled") : null, /*#__PURE__*/React__namespace.createElement(Code, {
3179
- style: {
3180
- padding: '.5em'
3181
- }
3182
- }, `${queryHash}`));
3183
- });
3184
-
3185
- // eslint-disable-next-line @typescript-eslint/no-empty-function
3186
- function noop() {}
3187
-
3188
- const ReactQueryDevtools = ReactQueryDevtools$1;
3189
- const ReactQueryDevtoolsPanel = ReactQueryDevtoolsPanel$1;
3190
-
3191
- exports.ReactQueryDevtools = ReactQueryDevtools;
3192
- exports.ReactQueryDevtoolsPanel = ReactQueryDevtoolsPanel;
3193
-
3194
- }));
3195
- //# sourceMappingURL=index.development.js.map