@tanstack/query-devtools 5.108.0 → 5.108.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/build/{DevtoolsComponent-e0KiEsCw.js → DevtoolsComponent-BBTUIw3a.js} +2 -2
  2. package/build/DevtoolsComponent-CqaQIX_J.cjs +45 -0
  3. package/build/DevtoolsComponent-KaCCT4mO.js +3 -0
  4. package/build/DevtoolsComponent-KaCCT4mO.js.map +1 -0
  5. package/build/DevtoolsComponent-NOj66Dgq.cjs +2 -0
  6. package/build/DevtoolsPanelComponent-1en47poS.js +3 -0
  7. package/build/DevtoolsPanelComponent-1en47poS.js.map +1 -0
  8. package/build/DevtoolsPanelComponent-C6-KUZMt.cjs +2 -0
  9. package/build/{DevtoolsPanelComponent-D9e2k2ne.js → DevtoolsPanelComponent-DA61oPj3.js} +2 -2
  10. package/build/DevtoolsPanelComponent-DHv0HzmU.cjs +52 -0
  11. package/build/{DevtoolsSubscriptionsProvider-CtZ2t7t0.js → DevtoolsSubscriptionsProvider-Cl_PUkf2.js} +1636 -2295
  12. package/build/{DevtoolsSubscriptionsProvider-D9zXQvDq.cjs → DevtoolsSubscriptionsProvider-DC-V1gB8.cjs} +2520 -3173
  13. package/build/DevtoolsSubscriptionsProvider-DpHm90Dj.js +10 -0
  14. package/build/DevtoolsSubscriptionsProvider-DpHm90Dj.js.map +1 -0
  15. package/build/DevtoolsSubscriptionsProvider-gZwQB0lN.cjs +9 -0
  16. package/build/dev.cjs +30 -30
  17. package/build/dev.js +11 -11
  18. package/build/index.cjs +1 -1
  19. package/build/index.d.cts +26 -10
  20. package/build/index.d.cts.map +1 -1
  21. package/build/index.d.ts +26 -10
  22. package/build/index.d.ts.map +1 -1
  23. package/build/index.js +1 -1
  24. package/build/index.js.map +1 -1
  25. package/build/{utils-CzP8C7c0.cjs → web-BD1Jlb-z.cjs} +43 -1036
  26. package/build/web-BRnEZuZ3.cjs +2 -0
  27. package/build/{utils-D7iZi04l.js → web-BZdVkndN.js} +42 -939
  28. package/build/web-da-lPyZC.js +3 -0
  29. package/build/web-da-lPyZC.js.map +1 -0
  30. package/package.json +3 -5
  31. package/src/Devtools.tsx +127 -1712
  32. package/src/Explorer.tsx +78 -285
  33. package/src/TanstackQueryDevtools.tsx +19 -10
  34. package/src/TanstackQueryDevtoolsPanel.tsx +19 -10
  35. package/src/contexts/PiPContext.tsx +4 -31
  36. package/src/contexts/types.ts +2 -2
  37. package/src/global.d.ts +1 -0
  38. package/src/styles.css +2158 -0
  39. package/src/styles.ts +49 -0
  40. package/src/utils.tsx +0 -23
  41. package/build/DevtoolsComponent-BGJcHYi5.cjs +0 -2
  42. package/build/DevtoolsComponent-KSaqMRUY.cjs +0 -45
  43. package/build/DevtoolsComponent-u2WBBkWz.js +0 -3
  44. package/build/DevtoolsComponent-u2WBBkWz.js.map +0 -1
  45. package/build/DevtoolsPanelComponent-1kShldEU.cjs +0 -2
  46. package/build/DevtoolsPanelComponent-CpAkTR9C.cjs +0 -52
  47. package/build/DevtoolsPanelComponent-DKq0vg7C.js +0 -3
  48. package/build/DevtoolsPanelComponent-DKq0vg7C.js.map +0 -1
  49. package/build/DevtoolsSubscriptionsProvider-BQAD7Uyk.js +0 -1292
  50. package/build/DevtoolsSubscriptionsProvider-BQAD7Uyk.js.map +0 -1
  51. package/build/DevtoolsSubscriptionsProvider-B_iiu5dm.cjs +0 -1291
  52. package/build/utils-DC2pN79q.js +0 -3
  53. package/build/utils-DC2pN79q.js.map +0 -1
  54. package/build/utils-DJl-N7L2.cjs +0 -2
@@ -1,5 +1,5 @@
1
1
  /* @refresh skip */
2
- // ../../node_modules/.pnpm/solid-js@1.9.18/node_modules/solid-js/dist/solid.js
2
+ // ../../node_modules/.pnpm/solid-js@1.9.20/node_modules/solid-js/dist/solid.js
3
3
  const sharedConfig = {
4
4
  context: void 0,
5
5
  registry: void 0,
@@ -347,6 +347,14 @@ function children(fn) {
347
347
  return memo;
348
348
  }
349
349
  let SuspenseContext;
350
+ function repairObserverSlots(source) {
351
+ source.observerSlots = source.observers.map((observer, slot) => {
352
+ const sources = observer.sources;
353
+ if (!sources) return -1;
354
+ for (let i = sources.length - 1; i >= 0; i--) if (sources[i] === source && observer.sourceSlots && observer.sourceSlots[i] === slot) return i;
355
+ return sources.lastIndexOf(source);
356
+ });
357
+ }
350
358
  function readSignal() {
351
359
  const runningTransition = Transition && Transition.running;
352
360
  if (this.sources && (runningTransition ? this.tState : this.state)) {
@@ -363,16 +371,21 @@ function readSignal() {
363
371
  if (!observers || observers[observers.length - 1] !== Listener) {
364
372
  const sSlot = observers ? observers.length : 0;
365
373
  if (!Listener.sources) {
366
- Listener.sources = [this];
367
- Listener.sourceSlots = [sSlot];
374
+ const sources = [this];
375
+ const sourceSlots = [sSlot];
376
+ Listener.sources = sources;
377
+ Listener.sourceSlots = sourceSlots;
368
378
  } else {
369
379
  Listener.sources.push(this);
370
380
  Listener.sourceSlots.push(sSlot);
371
381
  }
372
382
  if (!observers) {
373
- this.observers = [Listener];
374
- this.observerSlots = [Listener.sources.length - 1];
383
+ const newObservers = [Listener];
384
+ const newObserverSlots = [Listener.sources.length - 1];
385
+ this.observers = newObservers;
386
+ this.observerSlots = newObserverSlots;
375
387
  } else {
388
+ if (!this.observerSlots || this.observerSlots.length !== observers.length) repairObserverSlots(this);
376
389
  observers.push(Listener);
377
390
  this.observerSlots.push(Listener.sources.length - 1);
378
391
  }
@@ -415,7 +428,7 @@ function writeSignal(node, value, isComp) {
415
428
  }
416
429
  function updateComputation(node) {
417
430
  if (!node.fn) return;
418
- cleanNode(node);
431
+ cleanNode(node, true);
419
432
  const time = ExecCount;
420
433
  runComputation(node, Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value, time);
421
434
  if (Transition && !Transition.running && Transition.sources.has(node)) queueMicrotask(() => {
@@ -437,11 +450,11 @@ function runComputation(node, value, time) {
437
450
  if (node.pure) {
438
451
  if (Transition && Transition.running) {
439
452
  node.tState = STALE;
440
- node.tOwned && node.tOwned.forEach(cleanNode);
453
+ node.tOwned && node.tOwned.forEach((n) => cleanNode(n));
441
454
  node.tOwned = void 0;
442
455
  } else {
443
456
  node.state = STALE;
444
- node.owned && node.owned.forEach(cleanNode);
457
+ node.owned && node.owned.forEach((n) => cleanNode(n));
445
458
  node.owned = null;
446
459
  }
447
460
  }
@@ -626,11 +639,18 @@ function markDownstream(node) {
626
639
  }
627
640
  }
628
641
  }
629
- function cleanNode(node) {
642
+ function releaseTransitionSource(node) {
643
+ if (Transition && Transition.sources.has(node)) {
644
+ Transition.sources.delete(node);
645
+ delete node.tValue;
646
+ }
647
+ }
648
+ function cleanNode(node, recompute) {
630
649
  let i;
631
650
  if (node.sources) while (node.sources.length) {
632
651
  const source = node.sources.pop(), index = node.sourceSlots.pop(), obs = source.observers;
633
652
  if (obs && obs.length) {
653
+ if (!source.observerSlots || source.observerSlots.length !== obs.length) repairObserverSlots(source);
634
654
  const n = obs.pop(), s = source.observerSlots.pop();
635
655
  if (index < obs.length) {
636
656
  n.sourceSlots[s] = index;
@@ -638,6 +658,7 @@ function cleanNode(node) {
638
658
  source.observerSlots[index] = s;
639
659
  }
640
660
  }
661
+ if (!recompute && (!obs || !obs.length) && Transition) releaseTransitionSource(source);
641
662
  }
642
663
  if (node.tOwned) {
643
664
  for (i = node.tOwned.length - 1; i >= 0; i--) cleanNode(node.tOwned[i]);
@@ -648,6 +669,7 @@ function cleanNode(node) {
648
669
  for (i = node.owned.length - 1; i >= 0; i--) cleanNode(node.owned[i]);
649
670
  node.owned = null;
650
671
  }
672
+ if (!recompute) releaseTransitionSource(node);
651
673
  if (node.cleanups) {
652
674
  for (i = node.cleanups.length - 1; i >= 0; i--) node.cleanups[i]();
653
675
  node.cleanups = null;
@@ -659,6 +681,7 @@ function reset(node, top) {
659
681
  if (!top) {
660
682
  node.tState = 0;
661
683
  Transition.disposed.add(node);
684
+ releaseTransitionSource(node);
662
685
  }
663
686
  if (node.owned) for (let i = 0; i < node.owned.length; i++) reset(node.owned[i]);
664
687
  }
@@ -1094,7 +1117,7 @@ function Switch(props) {
1094
1117
  function Match(props) {
1095
1118
  return props;
1096
1119
  }
1097
- // ../../node_modules/.pnpm/solid-js@1.9.18/node_modules/solid-js/web/dist/web.js
1120
+ // ../../node_modules/.pnpm/solid-js@1.9.20/node_modules/solid-js/web/dist/web.js
1098
1121
  const Properties = /*#__PURE__*/ new Set([
1099
1122
  "className",
1100
1123
  "value",
@@ -1428,11 +1451,15 @@ function render(code, element, init, options = {}) {
1428
1451
  element.textContent = "";
1429
1452
  };
1430
1453
  }
1454
+ let policy;
1455
+ function setTrustedTypesPolicy(value) {
1456
+ policy = value;
1457
+ }
1431
1458
  function template(html, isImportNode, isSVG, isMathML) {
1432
1459
  let node;
1433
1460
  const create = () => {
1434
1461
  const t = isMathML ? document.createElementNS("http://www.w3.org/1998/Math/MathML", "template") : document.createElement("template");
1435
- t.innerHTML = html;
1462
+ t.innerHTML = policy ? policy.createHTML(html) : html;
1436
1463
  return isSVG ? t.content.firstChild.firstChild : isMathML ? t.firstChild : t.content.firstChild;
1437
1464
  };
1438
1465
  const fn = isImportNode ? () => untrack(() => document.importNode(node || (node = create()), true)) : () => (node || (node = create())).cloneNode(true);
@@ -1545,7 +1572,7 @@ function assign(node, props, isSVG, skipChildren, prevProps = {}, skipRef = fals
1545
1572
  props || (props = {});
1546
1573
  for (const prop in prevProps) if (!(prop in props)) {
1547
1574
  if (prop === "children") continue;
1548
- prevProps[prop] = assignProp$1(node, prop, null, prevProps[prop], isSVG, skipRef, props);
1575
+ prevProps[prop] = assignProp(node, prop, null, prevProps[prop], isSVG, skipRef, props);
1549
1576
  }
1550
1577
  for (const prop in props) {
1551
1578
  if (prop === "children") {
@@ -1553,7 +1580,7 @@ function assign(node, props, isSVG, skipChildren, prevProps = {}, skipRef = fals
1553
1580
  continue;
1554
1581
  }
1555
1582
  const value = props[prop];
1556
- prevProps[prop] = assignProp$1(node, prop, value, prevProps[prop], isSVG, skipRef, props);
1583
+ prevProps[prop] = assignProp(node, prop, value, prevProps[prop], isSVG, skipRef, props);
1557
1584
  }
1558
1585
  }
1559
1586
  function getNextElement(template) {
@@ -1573,7 +1600,7 @@ function toggleClassKey(node, key, value) {
1573
1600
  const classNames = key.trim().split(/\s+/);
1574
1601
  for (let i = 0, nameLen = classNames.length; i < nameLen; i++) node.classList.toggle(classNames[i], value);
1575
1602
  }
1576
- function assignProp$1(node, prop, value, prev, isSVG, skipRef, props) {
1603
+ function assignProp(node, prop, value, prev, isSVG, skipRef, props) {
1577
1604
  let isCE, isProp, isChildProp, propAlias, forceProp;
1578
1605
  if (prop === "style") return style(node, value, prev);
1579
1606
  if (prop === "classList") return classList(node, value, prev);
@@ -1842,928 +1869,4 @@ function Dynamic(props) {
1842
1869
  const [, others] = splitProps(props, ["component"]);
1843
1870
  return createDynamic(() => props.component, others);
1844
1871
  }
1845
- // ../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/double-indexed-kv.js
1846
- var DoubleIndexedKV = class {
1847
- constructor() {
1848
- this.keyToValue = /* @__PURE__ */ new Map();
1849
- this.valueToKey = /* @__PURE__ */ new Map();
1850
- }
1851
- set(key, value) {
1852
- this.keyToValue.set(key, value);
1853
- this.valueToKey.set(value, key);
1854
- }
1855
- getByKey(key) {
1856
- return this.keyToValue.get(key);
1857
- }
1858
- getByValue(value) {
1859
- return this.valueToKey.get(value);
1860
- }
1861
- clear() {
1862
- this.keyToValue.clear();
1863
- this.valueToKey.clear();
1864
- }
1865
- };
1866
- // ../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/registry.js
1867
- var Registry = class {
1868
- constructor(generateIdentifier) {
1869
- this.generateIdentifier = generateIdentifier;
1870
- this.kv = new DoubleIndexedKV();
1871
- }
1872
- register(value, identifier) {
1873
- if (this.kv.getByValue(value)) return;
1874
- if (!identifier) identifier = this.generateIdentifier(value);
1875
- this.kv.set(identifier, value);
1876
- }
1877
- clear() {
1878
- this.kv.clear();
1879
- }
1880
- getIdentifier(value) {
1881
- return this.kv.getByValue(value);
1882
- }
1883
- getValue(identifier) {
1884
- return this.kv.getByKey(identifier);
1885
- }
1886
- };
1887
- // ../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/class-registry.js
1888
- var ClassRegistry = class extends Registry {
1889
- constructor() {
1890
- super((c) => c.name);
1891
- this.classToAllowedProps = /* @__PURE__ */ new Map();
1892
- }
1893
- register(value, options) {
1894
- if (typeof options === "object") {
1895
- if (options.allowProps) this.classToAllowedProps.set(value, options.allowProps);
1896
- super.register(value, options.identifier);
1897
- } else super.register(value, options);
1898
- }
1899
- getAllowedProps(value) {
1900
- return this.classToAllowedProps.get(value);
1901
- }
1902
- };
1903
- // ../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/util.js
1904
- function valuesOfObj(record) {
1905
- if ("values" in Object) return Object.values(record);
1906
- const values = [];
1907
- for (const key in record) if (record.hasOwnProperty(key)) values.push(record[key]);
1908
- return values;
1909
- }
1910
- function find(record, predicate) {
1911
- const values = valuesOfObj(record);
1912
- if ("find" in values) return values.find(predicate);
1913
- const valuesNotNever = values;
1914
- for (let i = 0; i < valuesNotNever.length; i++) {
1915
- const value = valuesNotNever[i];
1916
- if (predicate(value)) return value;
1917
- }
1918
- }
1919
- function forEach(record, run) {
1920
- Object.entries(record).forEach(([key, value]) => run(value, key));
1921
- }
1922
- function includes(arr, value) {
1923
- return arr.indexOf(value) !== -1;
1924
- }
1925
- function findArr(record, predicate) {
1926
- for (let i = 0; i < record.length; i++) {
1927
- const value = record[i];
1928
- if (predicate(value)) return value;
1929
- }
1930
- }
1931
- // ../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/custom-transformer-registry.js
1932
- var CustomTransformerRegistry = class {
1933
- constructor() {
1934
- this.transfomers = {};
1935
- }
1936
- register(transformer) {
1937
- this.transfomers[transformer.name] = transformer;
1938
- }
1939
- findApplicable(v) {
1940
- return find(this.transfomers, (transformer) => transformer.isApplicable(v));
1941
- }
1942
- findByName(name) {
1943
- return this.transfomers[name];
1944
- }
1945
- };
1946
- // ../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/is.js
1947
- const getType$1 = (payload) => Object.prototype.toString.call(payload).slice(8, -1);
1948
- const isUndefined = (payload) => typeof payload === "undefined";
1949
- const isNull = (payload) => payload === null;
1950
- const isPlainObject$2 = (payload) => {
1951
- if (typeof payload !== "object" || payload === null) return false;
1952
- if (payload === Object.prototype) return false;
1953
- if (Object.getPrototypeOf(payload) === null) return true;
1954
- return Object.getPrototypeOf(payload) === Object.prototype;
1955
- };
1956
- const isEmptyObject = (payload) => isPlainObject$2(payload) && Object.keys(payload).length === 0;
1957
- const isArray$1 = (payload) => Array.isArray(payload);
1958
- const isString = (payload) => typeof payload === "string";
1959
- const isNumber = (payload) => typeof payload === "number" && !isNaN(payload);
1960
- const isBoolean = (payload) => typeof payload === "boolean";
1961
- const isRegExp = (payload) => payload instanceof RegExp;
1962
- const isMap = (payload) => payload instanceof Map;
1963
- const isSet = (payload) => payload instanceof Set;
1964
- const isSymbol = (payload) => getType$1(payload) === "Symbol";
1965
- const isDate = (payload) => payload instanceof Date && !isNaN(payload.valueOf());
1966
- const isError = (payload) => payload instanceof Error;
1967
- const isNaNValue = (payload) => typeof payload === "number" && isNaN(payload);
1968
- const isPrimitive = (payload) => isBoolean(payload) || isNull(payload) || isUndefined(payload) || isNumber(payload) || isString(payload) || isSymbol(payload);
1969
- const isBigint = (payload) => typeof payload === "bigint";
1970
- const isInfinite = (payload) => payload === Infinity || payload === -Infinity;
1971
- const isTypedArray = (payload) => ArrayBuffer.isView(payload) && !(payload instanceof DataView);
1972
- const isURL = (payload) => payload instanceof URL;
1973
- // ../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/pathstringifier.js
1974
- const escapeKey = (key) => key.replace(/\\/g, "\\\\").replace(/\./g, "\\.");
1975
- const stringifyPath = (path) => path.map(String).map(escapeKey).join(".");
1976
- const parsePath = (string, legacyPaths) => {
1977
- const result = [];
1978
- let segment = "";
1979
- for (let i = 0; i < string.length; i++) {
1980
- let char = string.charAt(i);
1981
- if (!legacyPaths && char === "\\") {
1982
- const escaped = string.charAt(i + 1);
1983
- if (escaped === "\\") {
1984
- segment += "\\";
1985
- i++;
1986
- continue;
1987
- } else if (escaped !== ".") throw Error("invalid path");
1988
- }
1989
- if (char === "\\" && string.charAt(i + 1) === ".") {
1990
- segment += ".";
1991
- i++;
1992
- continue;
1993
- }
1994
- if (char === ".") {
1995
- result.push(segment);
1996
- segment = "";
1997
- continue;
1998
- }
1999
- segment += char;
2000
- }
2001
- const lastSegment = segment;
2002
- result.push(lastSegment);
2003
- return result;
2004
- };
2005
- // ../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/transformer.js
2006
- function simpleTransformation(isApplicable, annotation, transform, untransform) {
2007
- return {
2008
- isApplicable,
2009
- annotation,
2010
- transform,
2011
- untransform
2012
- };
2013
- }
2014
- const simpleRules = [
2015
- simpleTransformation(isUndefined, "undefined", () => null, () => void 0),
2016
- simpleTransformation(isBigint, "bigint", (v) => v.toString(), (v) => {
2017
- if (typeof BigInt !== "undefined") return BigInt(v);
2018
- console.error("Please add a BigInt polyfill.");
2019
- return v;
2020
- }),
2021
- simpleTransformation(isDate, "Date", (v) => v.toISOString(), (v) => new Date(v)),
2022
- simpleTransformation(isError, "Error", (v, superJson) => {
2023
- const baseError = {
2024
- name: v.name,
2025
- message: v.message
2026
- };
2027
- if ("cause" in v) baseError.cause = v.cause;
2028
- superJson.allowedErrorProps.forEach((prop) => {
2029
- baseError[prop] = v[prop];
2030
- });
2031
- return baseError;
2032
- }, (v, superJson) => {
2033
- const e = new Error(v.message, { cause: v.cause });
2034
- e.name = v.name;
2035
- e.stack = v.stack;
2036
- superJson.allowedErrorProps.forEach((prop) => {
2037
- e[prop] = v[prop];
2038
- });
2039
- return e;
2040
- }),
2041
- simpleTransformation(isRegExp, "regexp", (v) => "" + v, (regex) => {
2042
- const body = regex.slice(1, regex.lastIndexOf("/"));
2043
- const flags = regex.slice(regex.lastIndexOf("/") + 1);
2044
- return new RegExp(body, flags);
2045
- }),
2046
- simpleTransformation(isSet, "set", (v) => [...v.values()], (v) => new Set(v)),
2047
- simpleTransformation(isMap, "map", (v) => [...v.entries()], (v) => new Map(v)),
2048
- simpleTransformation((v) => isNaNValue(v) || isInfinite(v), "number", (v) => {
2049
- if (isNaNValue(v)) return "NaN";
2050
- if (v > 0) return "Infinity";
2051
- else return "-Infinity";
2052
- }, Number),
2053
- simpleTransformation((v) => v === 0 && 1 / v === -Infinity, "number", () => {
2054
- return "-0";
2055
- }, Number),
2056
- simpleTransformation(isURL, "URL", (v) => v.toString(), (v) => new URL(v))
2057
- ];
2058
- function compositeTransformation(isApplicable, annotation, transform, untransform) {
2059
- return {
2060
- isApplicable,
2061
- annotation,
2062
- transform,
2063
- untransform
2064
- };
2065
- }
2066
- const symbolRule = compositeTransformation((s, superJson) => {
2067
- if (isSymbol(s)) return !!superJson.symbolRegistry.getIdentifier(s);
2068
- return false;
2069
- }, (s, superJson) => {
2070
- return ["symbol", superJson.symbolRegistry.getIdentifier(s)];
2071
- }, (v) => v.description, (_, a, superJson) => {
2072
- const value = superJson.symbolRegistry.getValue(a[1]);
2073
- if (!value) throw new Error("Trying to deserialize unknown symbol");
2074
- return value;
2075
- });
2076
- const constructorToName = [
2077
- Int8Array,
2078
- Uint8Array,
2079
- Int16Array,
2080
- Uint16Array,
2081
- Int32Array,
2082
- Uint32Array,
2083
- Float32Array,
2084
- Float64Array,
2085
- Uint8ClampedArray
2086
- ].reduce((obj, ctor) => {
2087
- obj[ctor.name] = ctor;
2088
- return obj;
2089
- }, {});
2090
- const typedArrayRule = compositeTransformation(isTypedArray, (v) => ["typed-array", v.constructor.name], (v) => [...v], (v, a) => {
2091
- const ctor = constructorToName[a[1]];
2092
- if (!ctor) throw new Error("Trying to deserialize unknown typed array");
2093
- return new ctor(v);
2094
- });
2095
- function isInstanceOfRegisteredClass(potentialClass, superJson) {
2096
- if (potentialClass?.constructor) return !!superJson.classRegistry.getIdentifier(potentialClass.constructor);
2097
- return false;
2098
- }
2099
- const classRule = compositeTransformation(isInstanceOfRegisteredClass, (clazz, superJson) => {
2100
- return ["class", superJson.classRegistry.getIdentifier(clazz.constructor)];
2101
- }, (clazz, superJson) => {
2102
- const allowedProps = superJson.classRegistry.getAllowedProps(clazz.constructor);
2103
- if (!allowedProps) return { ...clazz };
2104
- const result = {};
2105
- allowedProps.forEach((prop) => {
2106
- result[prop] = clazz[prop];
2107
- });
2108
- return result;
2109
- }, (v, a, superJson) => {
2110
- const clazz = superJson.classRegistry.getValue(a[1]);
2111
- if (!clazz) throw new Error(`Trying to deserialize unknown class '${a[1]}' - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564`);
2112
- return Object.assign(Object.create(clazz.prototype), v);
2113
- });
2114
- const customRule = compositeTransformation((value, superJson) => {
2115
- return !!superJson.customTransformerRegistry.findApplicable(value);
2116
- }, (value, superJson) => {
2117
- return ["custom", superJson.customTransformerRegistry.findApplicable(value).name];
2118
- }, (value, superJson) => {
2119
- return superJson.customTransformerRegistry.findApplicable(value).serialize(value);
2120
- }, (v, a, superJson) => {
2121
- const transformer = superJson.customTransformerRegistry.findByName(a[1]);
2122
- if (!transformer) throw new Error("Trying to deserialize unknown custom value");
2123
- return transformer.deserialize(v);
2124
- });
2125
- const compositeRules = [
2126
- classRule,
2127
- symbolRule,
2128
- customRule,
2129
- typedArrayRule
2130
- ];
2131
- const transformValue = (value, superJson) => {
2132
- const applicableCompositeRule = findArr(compositeRules, (rule) => rule.isApplicable(value, superJson));
2133
- if (applicableCompositeRule) return {
2134
- value: applicableCompositeRule.transform(value, superJson),
2135
- type: applicableCompositeRule.annotation(value, superJson)
2136
- };
2137
- const applicableSimpleRule = findArr(simpleRules, (rule) => rule.isApplicable(value, superJson));
2138
- if (applicableSimpleRule) return {
2139
- value: applicableSimpleRule.transform(value, superJson),
2140
- type: applicableSimpleRule.annotation
2141
- };
2142
- };
2143
- const simpleRulesByAnnotation = {};
2144
- simpleRules.forEach((rule) => {
2145
- simpleRulesByAnnotation[rule.annotation] = rule;
2146
- });
2147
- const untransformValue = (json, type, superJson) => {
2148
- if (isArray$1(type)) switch (type[0]) {
2149
- case "symbol": return symbolRule.untransform(json, type, superJson);
2150
- case "class": return classRule.untransform(json, type, superJson);
2151
- case "custom": return customRule.untransform(json, type, superJson);
2152
- case "typed-array": return typedArrayRule.untransform(json, type, superJson);
2153
- default: throw new Error("Unknown transformation: " + type);
2154
- }
2155
- else {
2156
- const transformation = simpleRulesByAnnotation[type];
2157
- if (!transformation) throw new Error("Unknown transformation: " + type);
2158
- return transformation.untransform(json, superJson);
2159
- }
2160
- };
2161
- // ../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/accessDeep.js
2162
- const getNthKey = (value, n) => {
2163
- if (n > value.size) throw new Error("index out of bounds");
2164
- const keys = value.keys();
2165
- while (n > 0) {
2166
- keys.next();
2167
- n--;
2168
- }
2169
- return keys.next().value;
2170
- };
2171
- function validatePath(path) {
2172
- if (includes(path, "__proto__")) throw new Error("__proto__ is not allowed as a property");
2173
- if (includes(path, "prototype")) throw new Error("prototype is not allowed as a property");
2174
- if (includes(path, "constructor")) throw new Error("constructor is not allowed as a property");
2175
- }
2176
- const getDeep = (object, path) => {
2177
- validatePath(path);
2178
- for (let i = 0; i < path.length; i++) {
2179
- const key = path[i];
2180
- if (isSet(object)) object = getNthKey(object, +key);
2181
- else if (isMap(object)) {
2182
- const row = +key;
2183
- const type = +path[++i] === 0 ? "key" : "value";
2184
- const keyOfRow = getNthKey(object, row);
2185
- switch (type) {
2186
- case "key":
2187
- object = keyOfRow;
2188
- break;
2189
- case "value": object = object.get(keyOfRow);
2190
- }
2191
- } else object = object[key];
2192
- }
2193
- return object;
2194
- };
2195
- const setDeep = (object, path, mapper) => {
2196
- validatePath(path);
2197
- if (path.length === 0) return mapper(object);
2198
- let parent = object;
2199
- for (let i = 0; i < path.length - 1; i++) {
2200
- const key = path[i];
2201
- if (isArray$1(parent)) {
2202
- const index = +key;
2203
- parent = parent[index];
2204
- } else if (isPlainObject$2(parent)) parent = parent[key];
2205
- else if (isSet(parent)) {
2206
- const row = +key;
2207
- parent = getNthKey(parent, row);
2208
- } else if (isMap(parent)) {
2209
- if (i === path.length - 2) break;
2210
- const row = +key;
2211
- const type = +path[++i] === 0 ? "key" : "value";
2212
- const keyOfRow = getNthKey(parent, row);
2213
- switch (type) {
2214
- case "key":
2215
- parent = keyOfRow;
2216
- break;
2217
- case "value": parent = parent.get(keyOfRow);
2218
- }
2219
- }
2220
- }
2221
- const lastKey = path[path.length - 1];
2222
- if (isArray$1(parent)) parent[+lastKey] = mapper(parent[+lastKey]);
2223
- else if (isPlainObject$2(parent)) parent[lastKey] = mapper(parent[lastKey]);
2224
- if (isSet(parent)) {
2225
- const oldValue = getNthKey(parent, +lastKey);
2226
- const newValue = mapper(oldValue);
2227
- if (oldValue !== newValue) {
2228
- parent.delete(oldValue);
2229
- parent.add(newValue);
2230
- }
2231
- }
2232
- if (isMap(parent)) {
2233
- const row = +path[path.length - 2];
2234
- const keyToRow = getNthKey(parent, row);
2235
- switch (+lastKey === 0 ? "key" : "value") {
2236
- case "key": {
2237
- const newKey = mapper(keyToRow);
2238
- parent.set(newKey, parent.get(keyToRow));
2239
- if (newKey !== keyToRow) parent.delete(keyToRow);
2240
- break;
2241
- }
2242
- case "value": parent.set(keyToRow, mapper(parent.get(keyToRow)));
2243
- }
2244
- }
2245
- return object;
2246
- };
2247
- // ../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/plainer.js
2248
- const enableLegacyPaths = (version) => version < 1;
2249
- function traverse(tree, walker, version, origin = []) {
2250
- if (!tree) return;
2251
- const legacyPaths = enableLegacyPaths(version);
2252
- if (!isArray$1(tree)) {
2253
- forEach(tree, (subtree, key) => traverse(subtree, walker, version, [...origin, ...parsePath(key, legacyPaths)]));
2254
- return;
2255
- }
2256
- const [nodeValue, children] = tree;
2257
- if (children) forEach(children, (child, key) => {
2258
- traverse(child, walker, version, [...origin, ...parsePath(key, legacyPaths)]);
2259
- });
2260
- walker(nodeValue, origin);
2261
- }
2262
- function applyValueAnnotations(plain, annotations, version, superJson) {
2263
- traverse(annotations, (type, path) => {
2264
- plain = setDeep(plain, path, (v) => untransformValue(v, type, superJson));
2265
- }, version);
2266
- return plain;
2267
- }
2268
- function applyReferentialEqualityAnnotations(plain, annotations, version) {
2269
- const legacyPaths = enableLegacyPaths(version);
2270
- function apply(identicalPaths, path) {
2271
- const object = getDeep(plain, parsePath(path, legacyPaths));
2272
- identicalPaths.map((path) => parsePath(path, legacyPaths)).forEach((identicalObjectPath) => {
2273
- plain = setDeep(plain, identicalObjectPath, () => object);
2274
- });
2275
- }
2276
- if (isArray$1(annotations)) {
2277
- const [root, other] = annotations;
2278
- root.forEach((identicalPath) => {
2279
- plain = setDeep(plain, parsePath(identicalPath, legacyPaths), () => plain);
2280
- });
2281
- if (other) forEach(other, apply);
2282
- } else forEach(annotations, apply);
2283
- return plain;
2284
- }
2285
- const isDeep = (object, superJson) => isPlainObject$2(object) || isArray$1(object) || isMap(object) || isSet(object) || isError(object) || isInstanceOfRegisteredClass(object, superJson);
2286
- function addIdentity(object, path, identities) {
2287
- const existingSet = identities.get(object);
2288
- if (existingSet) existingSet.push(path);
2289
- else identities.set(object, [path]);
2290
- }
2291
- function generateReferentialEqualityAnnotations(identitites, dedupe) {
2292
- const result = {};
2293
- let rootEqualityPaths = void 0;
2294
- identitites.forEach((paths) => {
2295
- if (paths.length <= 1) return;
2296
- if (!dedupe) paths = paths.map((path) => path.map(String)).sort((a, b) => a.length - b.length);
2297
- const [representativePath, ...identicalPaths] = paths;
2298
- if (representativePath.length === 0) rootEqualityPaths = identicalPaths.map(stringifyPath);
2299
- else result[stringifyPath(representativePath)] = identicalPaths.map(stringifyPath);
2300
- });
2301
- if (rootEqualityPaths) {
2302
- if (isEmptyObject(result)) return [rootEqualityPaths];
2303
- else return [rootEqualityPaths, result];
2304
- } else return isEmptyObject(result) ? void 0 : result;
2305
- }
2306
- const walker = (object, identities, superJson, dedupe, path = [], objectsInThisPath = [], seenObjects = /* @__PURE__ */ new Map()) => {
2307
- const primitive = isPrimitive(object);
2308
- if (!primitive) {
2309
- addIdentity(object, path, identities);
2310
- const seen = seenObjects.get(object);
2311
- if (seen) return dedupe ? { transformedValue: null } : seen;
2312
- }
2313
- if (!isDeep(object, superJson)) {
2314
- const transformed = transformValue(object, superJson);
2315
- const result = transformed ? {
2316
- transformedValue: transformed.value,
2317
- annotations: [transformed.type]
2318
- } : { transformedValue: object };
2319
- if (!primitive) seenObjects.set(object, result);
2320
- return result;
2321
- }
2322
- if (includes(objectsInThisPath, object)) return { transformedValue: null };
2323
- const transformationResult = transformValue(object, superJson);
2324
- const transformed = transformationResult?.value ?? object;
2325
- const transformedValue = isArray$1(transformed) ? [] : {};
2326
- const innerAnnotations = {};
2327
- forEach(transformed, (value, index) => {
2328
- if (index === "__proto__" || index === "constructor" || index === "prototype") throw new Error(`Detected property ${index}. This is a prototype pollution risk, please remove it from your object.`);
2329
- const recursiveResult = walker(value, identities, superJson, dedupe, [...path, index], [...objectsInThisPath, object], seenObjects);
2330
- transformedValue[index] = recursiveResult.transformedValue;
2331
- if (isArray$1(recursiveResult.annotations)) innerAnnotations[escapeKey(index)] = recursiveResult.annotations;
2332
- else if (isPlainObject$2(recursiveResult.annotations)) forEach(recursiveResult.annotations, (tree, key) => {
2333
- innerAnnotations[escapeKey(index) + "." + key] = tree;
2334
- });
2335
- });
2336
- const result = isEmptyObject(innerAnnotations) ? {
2337
- transformedValue,
2338
- annotations: !!transformationResult ? [transformationResult.type] : void 0
2339
- } : {
2340
- transformedValue,
2341
- annotations: !!transformationResult ? [transformationResult.type, innerAnnotations] : innerAnnotations
2342
- };
2343
- if (!primitive) seenObjects.set(object, result);
2344
- return result;
2345
- };
2346
- // ../../node_modules/.pnpm/is-what@5.5.0/node_modules/is-what/dist/getType.js
2347
- /** Returns the object type of the given payload */
2348
- function getType(payload) {
2349
- return Object.prototype.toString.call(payload).slice(8, -1);
2350
- }
2351
- // ../../node_modules/.pnpm/is-what@5.5.0/node_modules/is-what/dist/isArray.js
2352
- /** Returns whether the payload is an array */
2353
- function isArray(payload) {
2354
- return getType(payload) === "Array";
2355
- }
2356
- // ../../node_modules/.pnpm/is-what@5.5.0/node_modules/is-what/dist/isPlainObject.js
2357
- /**
2358
- * Returns whether the payload is a plain JavaScript object (excluding special classes or objects
2359
- * with other prototypes)
2360
- */
2361
- function isPlainObject$1(payload) {
2362
- if (getType(payload) !== "Object") return false;
2363
- const prototype = Object.getPrototypeOf(payload);
2364
- return !!prototype && prototype.constructor === Object && prototype === Object.prototype;
2365
- }
2366
- // ../../node_modules/.pnpm/copy-anything@4.0.5/node_modules/copy-anything/dist/index.js
2367
- function assignProp(carry, key, newVal, originalObject, includeNonenumerable) {
2368
- const propType = {}.propertyIsEnumerable.call(originalObject, key) ? "enumerable" : "nonenumerable";
2369
- if (propType === "enumerable") carry[key] = newVal;
2370
- if (includeNonenumerable && propType === "nonenumerable") Object.defineProperty(carry, key, {
2371
- value: newVal,
2372
- enumerable: false,
2373
- writable: true,
2374
- configurable: true
2375
- });
2376
- }
2377
- /**
2378
- * Copy (clone) an object and all its props recursively to get rid of any prop referenced of the
2379
- * original object. Arrays are also cloned, however objects inside arrays are still linked.
2380
- *
2381
- * @param target Target can be anything
2382
- * @param [options={}] See type {@link Options} for more details.
2383
- *
2384
- * - `{ props: ['key1'] }` will only copy the `key1` property. When using this you will need to cast
2385
- * the return type manually (in order to keep the TS implementation in here simple I didn't
2386
- * built a complex auto resolved type for those few cases people want to use this option)
2387
- * - `{ nonenumerable: true }` will copy all non-enumerable properties. Default is `{}`
2388
- *
2389
- * @returns The target with replaced values
2390
- */
2391
- function copy(target, options = {}) {
2392
- if (isArray(target)) return target.map((item) => copy(item, options));
2393
- if (!isPlainObject$1(target)) return target;
2394
- const props = Object.getOwnPropertyNames(target);
2395
- const symbols = Object.getOwnPropertySymbols(target);
2396
- return [...props, ...symbols].reduce((carry, key) => {
2397
- if (key === "__proto__") return carry;
2398
- if (isArray(options.props) && !options.props.includes(key)) return carry;
2399
- const val = target[key];
2400
- assignProp(carry, key, copy(val, options), target, options.nonenumerable);
2401
- return carry;
2402
- }, {});
2403
- }
2404
- // ../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/index.js
2405
- var SuperJSON = class {
2406
- /**
2407
- * @param dedupeReferentialEqualities If true, SuperJSON will make sure only one instance of referentially equal objects are serialized and the rest are replaced with `null`.
2408
- */
2409
- constructor({ dedupe = false } = {}) {
2410
- this.classRegistry = new ClassRegistry();
2411
- this.symbolRegistry = new Registry((s) => s.description ?? "");
2412
- this.customTransformerRegistry = new CustomTransformerRegistry();
2413
- this.allowedErrorProps = [];
2414
- this.dedupe = dedupe;
2415
- }
2416
- serialize(object) {
2417
- const identities = /* @__PURE__ */ new Map();
2418
- const output = walker(object, identities, this, this.dedupe);
2419
- const res = { json: output.transformedValue };
2420
- if (output.annotations) res.meta = {
2421
- ...res.meta,
2422
- values: output.annotations
2423
- };
2424
- const equalityAnnotations = generateReferentialEqualityAnnotations(identities, this.dedupe);
2425
- if (equalityAnnotations) res.meta = {
2426
- ...res.meta,
2427
- referentialEqualities: equalityAnnotations
2428
- };
2429
- if (res.meta) res.meta.v = 1;
2430
- return res;
2431
- }
2432
- deserialize(payload, options) {
2433
- const { json, meta } = payload;
2434
- let result = options?.inPlace ? json : copy(json);
2435
- if (meta?.values) result = applyValueAnnotations(result, meta.values, meta.v ?? 0, this);
2436
- if (meta?.referentialEqualities) result = applyReferentialEqualityAnnotations(result, meta.referentialEqualities, meta.v ?? 0);
2437
- return result;
2438
- }
2439
- stringify(object) {
2440
- return JSON.stringify(this.serialize(object));
2441
- }
2442
- parse(string) {
2443
- return this.deserialize(JSON.parse(string), { inPlace: true });
2444
- }
2445
- registerClass(v, options) {
2446
- this.classRegistry.register(v, options);
2447
- }
2448
- registerSymbol(v, identifier) {
2449
- this.symbolRegistry.register(v, identifier);
2450
- }
2451
- registerCustom(transformer, name) {
2452
- this.customTransformerRegistry.register({
2453
- name,
2454
- ...transformer
2455
- });
2456
- }
2457
- allowErrorProps(...props) {
2458
- this.allowedErrorProps.push(...props);
2459
- }
2460
- };
2461
- SuperJSON.defaultInstance = new SuperJSON();
2462
- SuperJSON.serialize = SuperJSON.defaultInstance.serialize.bind(SuperJSON.defaultInstance);
2463
- SuperJSON.deserialize = SuperJSON.defaultInstance.deserialize.bind(SuperJSON.defaultInstance);
2464
- SuperJSON.stringify = SuperJSON.defaultInstance.stringify.bind(SuperJSON.defaultInstance);
2465
- SuperJSON.parse = SuperJSON.defaultInstance.parse.bind(SuperJSON.defaultInstance);
2466
- SuperJSON.registerClass = SuperJSON.defaultInstance.registerClass.bind(SuperJSON.defaultInstance);
2467
- SuperJSON.registerSymbol = SuperJSON.defaultInstance.registerSymbol.bind(SuperJSON.defaultInstance);
2468
- SuperJSON.registerCustom = SuperJSON.defaultInstance.registerCustom.bind(SuperJSON.defaultInstance);
2469
- SuperJSON.allowErrorProps = SuperJSON.defaultInstance.allowErrorProps.bind(SuperJSON.defaultInstance);
2470
- const serialize = SuperJSON.serialize;
2471
- SuperJSON.deserialize;
2472
- const stringify = SuperJSON.stringify;
2473
- SuperJSON.parse;
2474
- SuperJSON.registerClass;
2475
- SuperJSON.registerCustom;
2476
- SuperJSON.registerSymbol;
2477
- SuperJSON.allowErrorProps;
2478
- // src/nativeObjectType.ts
2479
- /**
2480
- * Checks an object's internal slots with an intrinsic operation.
2481
- * @param value - The inspected object.
2482
- * @param type - The native brand to check.
2483
- * @returns Whether the intrinsic operation accepts the object.
2484
- */
2485
- function hasNativeBrand(value, type) {
2486
- try {
2487
- switch (type) {
2488
- case "Map":
2489
- Map.prototype.has.call(value, void 0);
2490
- return true;
2491
- case "Set":
2492
- Set.prototype.has.call(value, void 0);
2493
- return true;
2494
- case "String":
2495
- String.prototype.valueOf.call(value);
2496
- return true;
2497
- }
2498
- } catch {
2499
- return false;
2500
- }
2501
- }
2502
- /**
2503
- * Identifies native collections and String wrappers across realms without reading accessors.
2504
- * @param value - The inspected value.
2505
- * @returns Its native brand, or undefined for other values and failed inspections.
2506
- */
2507
- function getNativeObjectType(value) {
2508
- if (value === null || typeof value !== "object") return void 0;
2509
- try {
2510
- if (Array.isArray(value) || ArrayBuffer.isView(value)) return void 0;
2511
- const length = Object.getOwnPropertyDescriptor(value, "length");
2512
- if (typeof length?.value === "number" && !length.enumerable && !length.writable && !length.configurable && hasNativeBrand(value, "String")) return "String";
2513
- const parent = Object.getPrototypeOf(value);
2514
- if (parent === null) {
2515
- if (hasNativeBrand(value, "Map")) return "Map";
2516
- if (hasNativeBrand(value, "Set")) return "Set";
2517
- return;
2518
- }
2519
- if (parent === Object.prototype) return void 0;
2520
- let prototype = value;
2521
- for (let depth = 0; prototype && depth <= 500; depth++) {
2522
- const tag = Object.getOwnPropertyDescriptor(prototype, Symbol.toStringTag)?.value;
2523
- if ((tag === "Map" || tag === "Set") && hasNativeBrand(value, tag)) return tag;
2524
- prototype = Object.getPrototypeOf(prototype);
2525
- }
2526
- return;
2527
- } catch {
2528
- return;
2529
- }
2530
- }
2531
- // src/utils.tsx
2532
- /**
2533
- * Returns the status label of a query: fetching, inactive (no observers), paused, stale, or fresh,
2534
- * checked in that order.
2535
- * @param query - The query to label.
2536
- * @returns One of `'fetching'`, `'inactive'`, `'paused'`, `'stale'`, or `'fresh'`.
2537
- */
2538
- function getQueryStatusLabel(query) {
2539
- return query.state.fetchStatus === "fetching" ? "fetching" : !query.getObserversCount() ? "inactive" : query.state.fetchStatus === "paused" ? "paused" : query.isStale() ? "stale" : "fresh";
2540
- }
2541
- /**
2542
- * Appends a capitalized side to a CSS property name, e.g. `border` and `left` to `borderLeft`.
2543
- * @param prop - The property name.
2544
- * @param side - The side to append.
2545
- * @returns The sided property name.
2546
- */
2547
- function getSidedProp(prop, side) {
2548
- return `${prop}${side.charAt(0).toUpperCase() + side.slice(1)}`;
2549
- }
2550
- /**
2551
- * Returns the color of a query's status: blue while fetching, gray without observers, purple while
2552
- * paused, yellow when stale, otherwise green.
2553
- * @param params - The query's `queryState`, `observerCount`, and `isStale`.
2554
- * @returns The color name.
2555
- */
2556
- function getQueryStatusColor({ queryState, observerCount, isStale }) {
2557
- return queryState?.fetchStatus === "fetching" ? "blue" : !observerCount ? "gray" : queryState?.fetchStatus === "paused" ? "purple" : isStale ? "yellow" : "green";
2558
- }
2559
- /**
2560
- * Returns the color of a mutation's status: purple while paused, red on error, yellow while pending,
2561
- * green on success, otherwise gray.
2562
- * @param params - The mutation's `status` and `isPaused`.
2563
- * @returns The color name.
2564
- */
2565
- function getMutationStatusColor({ status, isPaused }) {
2566
- return isPaused ? "purple" : status === "error" ? "red" : status === "pending" ? "yellow" : status === "success" ? "green" : "gray";
2567
- }
2568
- /**
2569
- * Returns the color of a query status label.
2570
- * @param label - A label returned by {@link getQueryStatusLabel}.
2571
- * @returns The color name.
2572
- */
2573
- function getQueryStatusColorByLabel(label) {
2574
- return label === "fresh" ? "green" : label === "stale" ? "yellow" : label === "paused" ? "purple" : label === "inactive" ? "gray" : "blue";
2575
- }
2576
- /**
2577
- * Displays a string regardless of the type of the data.
2578
- * @param value - Value to be stringified
2579
- * @param beautify - Formats json to multiline
2580
- * @returns The value serialized with `superjson`, as a JSON string.
2581
- */
2582
- const displayValue = (value, beautify = false) => {
2583
- const { json } = serialize(value);
2584
- return JSON.stringify(json, null, beautify ? 2 : void 0);
2585
- };
2586
- const getStatusRank = (q) => q.state.fetchStatus !== "idle" ? 0 : !q.getObserversCount() ? 3 : q.isStale() ? 2 : 1;
2587
- const queryHashSort = (a, b) => a.queryHash.localeCompare(b.queryHash);
2588
- const dateSort = (a, b) => {
2589
- const diff = b.state.dataUpdatedAt - a.state.dataUpdatedAt;
2590
- return diff < 0 ? -1 : diff > 0 ? 1 : 0;
2591
- };
2592
- const statusAndDateSort = (a, b) => {
2593
- if (getStatusRank(a) === getStatusRank(b)) return dateSort(a, b);
2594
- return getStatusRank(a) > getStatusRank(b) ? 1 : -1;
2595
- };
2596
- const sortFns = {
2597
- status: statusAndDateSort,
2598
- "query hash": queryHashSort,
2599
- "last updated": dateSort
2600
- };
2601
- const getMutationStatusRank = (m) => m.state.isPaused ? 0 : m.state.status === "error" ? 2 : m.state.status === "pending" ? 1 : 3;
2602
- const mutationDateSort = (a, b) => a.state.submittedAt < b.state.submittedAt ? 1 : -1;
2603
- const mutationStatusSort = (a, b) => {
2604
- if (getMutationStatusRank(a) === getMutationStatusRank(b)) return mutationDateSort(a, b);
2605
- return getMutationStatusRank(a) > getMutationStatusRank(b) ? 1 : -1;
2606
- };
2607
- const mutationSortFns = {
2608
- status: mutationStatusSort,
2609
- "last updated": mutationDateSort
2610
- };
2611
- /**
2612
- * Converts a length in `rem` to pixels, using the root element's font size.
2613
- * @param rem - The length in `rem`.
2614
- * @returns The length in pixels.
2615
- */
2616
- const convertRemToPixels = (rem) => {
2617
- return rem * parseFloat(getComputedStyle(document.documentElement).fontSize);
2618
- };
2619
- /**
2620
- * Tracks the user's `prefers-color-scheme` setting.
2621
- * @returns An accessor of `'light'` or `'dark'`, updated when the setting
2622
- * changes.
2623
- */
2624
- const getPreferredColorScheme = () => {
2625
- const [colorScheme, setColorScheme] = createSignal("dark");
2626
- onMount(() => {
2627
- const query = window.matchMedia("(prefers-color-scheme: dark)");
2628
- setColorScheme(query.matches ? "dark" : "light");
2629
- const listener = (e) => {
2630
- setColorScheme(e.matches ? "dark" : "light");
2631
- };
2632
- query.addEventListener("change", listener);
2633
- onCleanup(() => query.removeEventListener("change", listener));
2634
- });
2635
- return colorScheme;
2636
- };
2637
- /**
2638
- * Checks whether a value is a plain object without invoking accessors, including across realms.
2639
- * @param value - The data to inspect.
2640
- * @returns Whether the value can be copied as a record.
2641
- */
2642
- function isPlainObject(value) {
2643
- if (value === null || typeof value !== "object") return false;
2644
- try {
2645
- const prototype = Object.getPrototypeOf(value);
2646
- if (prototype === null) return true;
2647
- const constructor = Object.getOwnPropertyDescriptor(prototype, "constructor")?.value;
2648
- return typeof constructor === "function" && Object.getOwnPropertyDescriptor(constructor, "prototype")?.value === prototype && Function.prototype.toString.call(constructor) === Function.prototype.toString.call(Object);
2649
- } catch {
2650
- return false;
2651
- }
2652
- }
2653
- /**
2654
- * Updates nested data by path.
2655
- * @param oldData - Data to be updated
2656
- * @param updatePath - Path to the data to be updated
2657
- * @param value - New value
2658
- * @returns A copy of `oldData` with the value at `updatePath` replaced.
2659
- */
2660
- const updateNestedDataByPath = (oldData, updatePath, value) => {
2661
- if (updatePath.length === 0) return value;
2662
- const type = getNativeObjectType(oldData);
2663
- if (type === "Map") {
2664
- const newData = new Map(Map.prototype.entries.call(oldData));
2665
- if (updatePath.length === 1) {
2666
- newData.set(updatePath[0], value);
2667
- return newData;
2668
- }
2669
- const [head, ...tail] = updatePath;
2670
- newData.set(head, updateNestedDataByPath(newData.get(head), tail, value));
2671
- return newData;
2672
- }
2673
- if (type === "Set") {
2674
- const setAsArray = updateNestedDataByPath(Array.from(Set.prototype.values.call(oldData)), updatePath, value);
2675
- return new Set(setAsArray);
2676
- }
2677
- if (Array.isArray(oldData)) {
2678
- const newData = [...oldData];
2679
- if (updatePath.length === 1) {
2680
- newData[updatePath[0]] = value;
2681
- return newData;
2682
- }
2683
- const [head, ...tail] = updatePath;
2684
- newData[head] = updateNestedDataByPath(newData[head], tail, value);
2685
- return newData;
2686
- }
2687
- if (isPlainObject(oldData)) {
2688
- const descriptors = Object.getOwnPropertyDescriptors(oldData);
2689
- const [head, ...tail] = updatePath;
2690
- if (head === void 0) return oldData;
2691
- const previous = Object.getOwnPropertyDescriptor(oldData, head);
2692
- if (tail.length && (!previous || !("value" in previous))) return oldData;
2693
- return Object.create(Object.getPrototypeOf(oldData), {
2694
- ...descriptors,
2695
- [head]: {
2696
- value: tail.length ? updateNestedDataByPath(previous?.value, tail, value) : value,
2697
- enumerable: previous?.enumerable ?? true,
2698
- configurable: true,
2699
- writable: true
2700
- }
2701
- });
2702
- }
2703
- return oldData;
2704
- };
2705
- /**
2706
- * Deletes nested data by path.
2707
- * @param oldData - Data to be updated
2708
- * @param deletePath - Path to the data to be deleted
2709
- * @returns newData without the deleted items by path
2710
- */
2711
- const deleteNestedDataByPath = (oldData, deletePath) => {
2712
- const type = getNativeObjectType(oldData);
2713
- if (type === "Map") {
2714
- const newData = new Map(Map.prototype.entries.call(oldData));
2715
- if (deletePath.length === 1) {
2716
- newData.delete(deletePath[0]);
2717
- return newData;
2718
- }
2719
- const [head, ...tail] = deletePath;
2720
- newData.set(head, deleteNestedDataByPath(newData.get(head), tail));
2721
- return newData;
2722
- }
2723
- if (type === "Set") {
2724
- const setAsArray = deleteNestedDataByPath(Array.from(Set.prototype.values.call(oldData)), deletePath);
2725
- return new Set(setAsArray);
2726
- }
2727
- if (Array.isArray(oldData)) {
2728
- const newData = [...oldData];
2729
- if (deletePath.length === 1) return newData.filter((_, idx) => idx.toString() !== deletePath[0]);
2730
- const [head, ...tail] = deletePath;
2731
- newData[head] = deleteNestedDataByPath(newData[head], tail);
2732
- return newData;
2733
- }
2734
- if (isPlainObject(oldData)) {
2735
- const descriptors = Object.getOwnPropertyDescriptors(oldData);
2736
- const [head, ...tail] = deletePath;
2737
- if (head === void 0) return oldData;
2738
- if (tail.length === 0) delete descriptors[head];
2739
- else {
2740
- const previous = Object.getOwnPropertyDescriptor(oldData, head);
2741
- if (!previous || !("value" in previous)) return oldData;
2742
- descriptors[head] = {
2743
- ...previous,
2744
- value: deleteNestedDataByPath(previous.value, tail)
2745
- };
2746
- }
2747
- return Object.create(Object.getPrototypeOf(oldData), descriptors);
2748
- }
2749
- return oldData;
2750
- };
2751
- /**
2752
- * Sets up the goober stylesheet with a `nonce`, for pages with a Content Security Policy. Without a
2753
- * `nonce`, it does nothing and goober creates the stylesheet itself.
2754
- * @param nonce - The nonce to set on the style tag.
2755
- * @param target - The shadow root to add the style tag to, instead of `document.head`.
2756
- */
2757
- const setupStyleSheet = (nonce, target) => {
2758
- if (!nonce) return;
2759
- window.__nonce__ = nonce;
2760
- const root = target ?? document.head;
2761
- if (root.querySelector("#_goober")) return;
2762
- const styleTag = document.createElement("style");
2763
- const textNode = document.createTextNode("");
2764
- styleTag.appendChild(textNode);
2765
- styleTag.id = "_goober";
2766
- styleTag.setAttribute("nonce", nonce);
2767
- root.appendChild(styleTag);
2768
- };
2769
- export { on as $, template as A, createComponent as B, delegateEvents as C, setAttribute as D, render as E, Index as F, createRenderEffect as G, createContext as H, Match as I, createUniqueId as J, createRoot as K, Show as L, $PROXY as M, $TRACK as N, setStyleProperty as O, For as P, mergeProps as Q, Switch as R, clearDelegatedEvents as S, memo as T, createEffect as U, createComputed as V, createMemo as W, getOwner as X, getListener as Y, lazy as Z, stringify as _, getPreferredColorScheme as a, useTransition as at, addEventListener as b, getQueryStatusLabel as c, mutationSortFns as d, onCleanup as et, setupStyleSheet as f, serialize as g, getNativeObjectType as h, getMutationStatusColor as i, useContext as it, use as j, spread as k, getSidedProp as l, updateNestedDataByPath as m, deleteNestedDataByPath as n, splitProps as nt, getQueryStatusColor as o, sortFns as p, createSignal as q, displayValue as r, untrack as rt, getQueryStatusColorByLabel as s, convertRemToPixels as t, onMount as tt, isPlainObject as u, Dynamic as v, insert as w, className as x, Portal as y, batch as z };
1872
+ export { createRoot as A, splitProps as B, batch as C, createEffect as D, createContext as E, lazy as F, useContext as H, mergeProps as I, on as L, createUniqueId as M, getListener as N, createMemo as O, getOwner as P, onCleanup as R, Switch as S, createComputed as T, useTransition as U, untrack as V, $TRACK as _, clearDelegatedEvents as a, Match as b, memo as c, setStyleProperty as d, setTrustedTypesPolicy as f, $PROXY as g, use as h, className as i, createSignal as j, createRenderEffect as k, render as l, template as m, Portal as n, delegateEvents as o, spread as p, addEventListener as r, insert as s, Dynamic as t, setAttribute as u, For as v, createComponent as w, Show as x, Index as y, onMount as z };