@inventreedb/ui 0.11.3 → 1.4.1

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 (165) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/dist/.vite/manifest.json +45 -5
  3. package/dist/_virtual/dynamic-import-helper.js +20 -0
  4. package/dist/_virtual/dynamic-import-helper.js.map +1 -0
  5. package/dist/components/Boundary.js +5 -4
  6. package/dist/components/Boundary.js.map +1 -1
  7. package/dist/components/InvenTreeTable.js +4 -3
  8. package/dist/components/InvenTreeTable.js.map +1 -1
  9. package/dist/components/RowActions.js +3 -2
  10. package/dist/components/RowActions.js.map +1 -1
  11. package/dist/components/TableColumnSelect.js +1 -1
  12. package/dist/components/TableColumnSelect.js.map +1 -1
  13. package/dist/components/TagsList.d.ts +3 -0
  14. package/dist/components/TagsList.js +21 -0
  15. package/dist/components/TagsList.js.map +1 -0
  16. package/dist/components/nav/DetailDrawer.d.ts +1 -0
  17. package/dist/components/nav/DetailDrawer.js +1 -0
  18. package/dist/components/nav/DetailDrawer.js.map +1 -1
  19. package/dist/enums/ApiEndpoints.d.ts +15 -4
  20. package/dist/enums/ApiEndpoints.js +15 -4
  21. package/dist/enums/ApiEndpoints.js.map +1 -1
  22. package/dist/enums/ModelInformation.d.ts +1 -0
  23. package/dist/enums/ModelInformation.js +55 -2
  24. package/dist/enums/ModelInformation.js.map +1 -1
  25. package/dist/enums/ModelType.d.ts +4 -1
  26. package/dist/enums/ModelType.js +3 -0
  27. package/dist/enums/ModelType.js.map +1 -1
  28. package/dist/enums/Roles.d.ts +1 -0
  29. package/dist/enums/Roles.js +1 -0
  30. package/dist/enums/Roles.js.map +1 -1
  31. package/dist/functions/Events.js +4 -3
  32. package/dist/functions/Events.js.map +1 -1
  33. package/dist/functions/Navigation.js +6 -3
  34. package/dist/functions/Navigation.js.map +1 -1
  35. package/dist/functions/Plugins.js +4 -2
  36. package/dist/functions/Plugins.js.map +1 -1
  37. package/dist/hooks/MonitorBackgroundTask.js +10 -8
  38. package/dist/hooks/MonitorBackgroundTask.js.map +1 -1
  39. package/dist/hooks/MonitorDataOutput.js +4 -3
  40. package/dist/hooks/MonitorDataOutput.js.map +1 -1
  41. package/dist/hooks/UseFilterSet.js +45 -7
  42. package/dist/hooks/UseFilterSet.js.map +1 -1
  43. package/dist/hooks/UseTable.js +1 -1
  44. package/dist/index.d.ts +6 -1
  45. package/dist/index.js +20 -11
  46. package/dist/index.js.map +1 -1
  47. package/dist/node_modules/@mantine/hooks/esm/use-debounced-value/use-debounced-value.js +40 -15
  48. package/dist/node_modules/@mantine/hooks/esm/use-debounced-value/use-debounced-value.js.map +1 -1
  49. package/dist/node_modules/@mantine/hooks/esm/use-document-visibility/use-document-visibility.js +1 -1
  50. package/dist/node_modules/@mantine/hooks/esm/use-document-visibility/use-document-visibility.js.map +1 -1
  51. package/dist/node_modules/@mantine/hooks/esm/use-local-storage/create-storage.js +57 -62
  52. package/dist/node_modules/@mantine/hooks/esm/use-local-storage/create-storage.js.map +1 -1
  53. package/dist/node_modules/@mantine/hooks/esm/use-local-storage/use-local-storage.js.map +1 -1
  54. package/dist/node_modules/@mantine/hooks/esm/use-window-event/use-window-event.js +5 -3
  55. package/dist/node_modules/@mantine/hooks/esm/use-window-event/use-window-event.js.map +1 -1
  56. package/dist/node_modules/@mantine/hooks/esm/utils/random-id/random-id.js.map +1 -1
  57. package/dist/node_modules/@remix-run/router/dist/router.js +10 -0
  58. package/dist/node_modules/@remix-run/router/dist/router.js.map +1 -1
  59. package/dist/node_modules/@sentry/browser/build/npm/esm/prod/report-dialog.js +2 -2
  60. package/dist/node_modules/@sentry/browser/build/npm/esm/prod/report-dialog.js.map +1 -1
  61. package/dist/node_modules/@sentry/core/build/esm/scope.js +6 -5
  62. package/dist/node_modules/@sentry/core/build/esm/scope.js.map +1 -1
  63. package/dist/node_modules/@sentry/core/build/esm/utils/chain-and-copy-promiselike.js +1 -1
  64. package/dist/node_modules/@sentry/core/build/esm/utils/chain-and-copy-promiselike.js.map +1 -1
  65. package/dist/node_modules/@sentry/core/build/esm/utils/is.js +1 -1
  66. package/dist/node_modules/@sentry/core/build/esm/utils/is.js.map +1 -1
  67. package/dist/node_modules/@sentry/core/build/esm/utils/misc.js +1 -1
  68. package/dist/node_modules/@sentry/core/build/esm/utils/misc.js.map +1 -1
  69. package/dist/node_modules/@sentry/core/build/esm/utils/randomSafeContext.js +1 -1
  70. package/dist/node_modules/@sentry/core/build/esm/utils/randomSafeContext.js.map +1 -1
  71. package/dist/node_modules/@sentry/core/build/esm/utils/time.js +1 -1
  72. package/dist/node_modules/@sentry/core/build/esm/utils/time.js.map +1 -1
  73. package/dist/node_modules/@tabler/icons-react/dist/esm/createReactComponent.js +6 -0
  74. package/dist/node_modules/@tabler/icons-react/dist/esm/createReactComponent.js.map +1 -1
  75. package/dist/node_modules/@tabler/icons-react/dist/esm/defaultAttributes.js +6 -0
  76. package/dist/node_modules/@tabler/icons-react/dist/esm/defaultAttributes.js.map +1 -1
  77. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconAdjustments.js +6 -0
  78. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconAdjustments.js.map +1 -1
  79. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconArrowRight.js +6 -0
  80. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconArrowRight.js.map +1 -1
  81. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCheck.js +6 -0
  82. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCheck.js.map +1 -1
  83. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconChevronLeft.js +6 -0
  84. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconChevronLeft.js.map +1 -1
  85. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCircleCheck.js +6 -0
  86. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCircleCheck.js.map +1 -1
  87. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCircleX.js +6 -0
  88. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCircleX.js.map +1 -1
  89. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCopy.js +6 -0
  90. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCopy.js.map +1 -1
  91. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconDots.js +6 -0
  92. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconDots.js.map +1 -1
  93. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconEdit.js +6 -0
  94. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconEdit.js.map +1 -1
  95. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconExclamationCircle.js +6 -0
  96. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconExclamationCircle.js.map +1 -1
  97. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconPlus.js +6 -0
  98. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconPlus.js.map +1 -1
  99. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconSearch.js +6 -0
  100. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconSearch.js.map +1 -1
  101. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconTag.js +14 -0
  102. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconTag.js.map +1 -0
  103. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconTrash.js +6 -0
  104. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconTrash.js.map +1 -1
  105. package/dist/node_modules/@tanstack/query-core/build/modern/focusManager.js +31 -20
  106. package/dist/node_modules/@tanstack/query-core/build/modern/focusManager.js.map +1 -1
  107. package/dist/node_modules/@tanstack/query-core/build/modern/onlineManager.js +27 -17
  108. package/dist/node_modules/@tanstack/query-core/build/modern/onlineManager.js.map +1 -1
  109. package/dist/node_modules/@tanstack/query-core/build/modern/queryObserver.js +179 -177
  110. package/dist/node_modules/@tanstack/query-core/build/modern/queryObserver.js.map +1 -1
  111. package/dist/node_modules/@tanstack/query-core/build/modern/timeoutManager.js +31 -21
  112. package/dist/node_modules/@tanstack/query-core/build/modern/timeoutManager.js.map +1 -1
  113. package/dist/node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.js +1 -1
  114. package/dist/node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.js.map +1 -1
  115. package/dist/node_modules/@tanstack/react-query/build/modern/suspense.js +1 -1
  116. package/dist/node_modules/@tanstack/react-query/build/modern/suspense.js.map +1 -1
  117. package/dist/node_modules/@tanstack/react-query/build/modern/useBaseQuery.js +7 -4
  118. package/dist/node_modules/@tanstack/react-query/build/modern/useBaseQuery.js.map +1 -1
  119. package/dist/node_modules/react/cjs/react-jsx-runtime.development.js +10 -1
  120. package/dist/node_modules/react/cjs/react-jsx-runtime.development.js.map +1 -1
  121. package/dist/node_modules/react/cjs/react-jsx-runtime.production.js +10 -1
  122. package/dist/node_modules/react/cjs/react-jsx-runtime.production.js.map +1 -1
  123. package/dist/node_modules/react-router/dist/index.js +11 -1
  124. package/dist/node_modules/react-router/dist/index.js.map +1 -1
  125. package/dist/node_modules/react-router-dom/dist/index.js +10 -0
  126. package/dist/node_modules/react-router-dom/dist/index.js.map +1 -1
  127. package/dist/plugin/InventreeHmrPlugin.d.ts +8 -0
  128. package/dist/plugin/InventreeHmrPlugin.js +21 -0
  129. package/dist/plugin/InventreeHmrPlugin.js.map +1 -0
  130. package/dist/plugin/LocalizedComponent.d.ts +9 -0
  131. package/dist/plugin/LocalizedComponent.js +57 -0
  132. package/dist/plugin/LocalizedComponent.js.map +1 -0
  133. package/dist/states/StoredTableState.js +2 -1
  134. package/dist/states/StoredTableState.js.map +1 -1
  135. package/dist/states/types.d.ts +3 -0
  136. package/dist/types/Filters.d.ts +11 -0
  137. package/dist/types/Forms.d.ts +6 -1
  138. package/dist/types/Panel.d.ts +26 -0
  139. package/dist/types/Plugins.d.ts +14 -2
  140. package/dist/types/Plugins.js +2 -2
  141. package/dist/types/Plugins.js.map +1 -1
  142. package/dist/types/Rendering.d.ts +54 -0
  143. package/dist/types/Tables.d.ts +7 -3
  144. package/lib/components/Boundary.tsx +7 -3
  145. package/lib/components/RowActions.tsx +2 -2
  146. package/lib/components/TableColumnSelect.tsx +1 -1
  147. package/lib/components/TagsList.tsx +27 -0
  148. package/lib/components/nav/DetailDrawer.tsx +1 -1
  149. package/lib/enums/ApiEndpoints.tsx +18 -4
  150. package/lib/enums/ModelInformation.tsx +26 -2
  151. package/lib/enums/ModelType.tsx +4 -1
  152. package/lib/enums/Roles.tsx +3 -0
  153. package/lib/functions/Navigation.tsx +1 -1
  154. package/lib/hooks/UseFilterSet.tsx +62 -11
  155. package/lib/index.ts +14 -1
  156. package/lib/plugin/InventreeHmrPlugin.tsx +40 -0
  157. package/lib/plugin/LocalizedComponent.tsx +85 -0
  158. package/lib/states/types.tsx +7 -0
  159. package/lib/types/Filters.tsx +19 -0
  160. package/lib/types/Forms.tsx +7 -1
  161. package/lib/types/Panel.tsx +30 -0
  162. package/lib/types/Plugins.tsx +20 -1
  163. package/lib/types/Rendering.tsx +61 -0
  164. package/lib/types/Tables.tsx +8 -3
  165. package/package.json +19 -18
@@ -1,3 +1,12 @@
1
+ var __typeError = (msg) => {
2
+ throw TypeError(msg);
3
+ };
4
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
5
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
6
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
7
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
8
+ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
9
+ var _client, _currentQuery, _currentQueryInitialState, _currentResult, _currentResultState, _currentResultOptions, _currentThenable, _selectError, _selectFn, _selectResult, _lastQueryWithDefinedData, _staleTimeoutId, _refetchIntervalId, _currentRefetchInterval, _trackedProps, _QueryObserver_instances, executeFetch_fn, updateStaleTimeout_fn, computeRefetchInterval_fn, updateRefetchInterval_fn, updateTimers_fn, clearStaleTimeout_fn, clearRefetchInterval_fn, updateQuery_fn, notify_fn, _a;
1
10
  import { focusManager } from "./focusManager.js";
2
11
  import { environmentManager } from "./environmentManager.js";
3
12
  import { notifyManager } from "./notifyManager.js";
@@ -6,45 +15,46 @@ import { Subscribable } from "./subscribable.js";
6
15
  import { pendingThenable } from "./thenable.js";
7
16
  import { resolveEnabled, shallowEqualObjects, resolveStaleTime, noop, isValidTimeout, timeUntilStale, replaceData } from "./utils.js";
8
17
  import { timeoutManager } from "./timeoutManager.js";
9
- var QueryObserver = class extends Subscribable {
18
+ var QueryObserver = (_a = class extends Subscribable {
10
19
  constructor(client, options) {
11
20
  super();
21
+ __privateAdd(this, _QueryObserver_instances);
22
+ __privateAdd(this, _client);
23
+ __privateAdd(this, _currentQuery);
24
+ __privateAdd(this, _currentQueryInitialState);
25
+ __privateAdd(this, _currentResult);
26
+ __privateAdd(this, _currentResultState);
27
+ __privateAdd(this, _currentResultOptions);
28
+ __privateAdd(this, _currentThenable);
29
+ __privateAdd(this, _selectError);
30
+ __privateAdd(this, _selectFn);
31
+ __privateAdd(this, _selectResult);
32
+ // This property keeps track of the last query with defined data.
33
+ // It will be used to pass the previous data and query to the placeholder function between renders.
34
+ __privateAdd(this, _lastQueryWithDefinedData);
35
+ __privateAdd(this, _staleTimeoutId);
36
+ __privateAdd(this, _refetchIntervalId);
37
+ __privateAdd(this, _currentRefetchInterval);
38
+ __privateAdd(this, _trackedProps, /* @__PURE__ */ new Set());
12
39
  this.options = options;
13
- this.#client = client;
14
- this.#selectError = null;
15
- this.#currentThenable = pendingThenable();
40
+ __privateSet(this, _client, client);
41
+ __privateSet(this, _selectError, null);
42
+ __privateSet(this, _currentThenable, pendingThenable());
16
43
  this.bindMethods();
17
44
  this.setOptions(options);
18
45
  }
19
- #client;
20
- #currentQuery = void 0;
21
- #currentQueryInitialState = void 0;
22
- #currentResult = void 0;
23
- #currentResultState;
24
- #currentResultOptions;
25
- #currentThenable;
26
- #selectError;
27
- #selectFn;
28
- #selectResult;
29
- // This property keeps track of the last query with defined data.
30
- // It will be used to pass the previous data and query to the placeholder function between renders.
31
- #lastQueryWithDefinedData;
32
- #staleTimeoutId;
33
- #refetchIntervalId;
34
- #currentRefetchInterval;
35
- #trackedProps = /* @__PURE__ */ new Set();
36
46
  bindMethods() {
37
47
  this.refetch = this.refetch.bind(this);
38
48
  }
39
49
  onSubscribe() {
40
50
  if (this.listeners.size === 1) {
41
- this.#currentQuery.addObserver(this);
42
- if (shouldFetchOnMount(this.#currentQuery, this.options)) {
43
- this.#executeFetch();
51
+ __privateGet(this, _currentQuery).addObserver(this);
52
+ if (shouldFetchOnMount(__privateGet(this, _currentQuery), this.options)) {
53
+ __privateMethod(this, _QueryObserver_instances, executeFetch_fn).call(this);
44
54
  } else {
45
55
  this.updateResult();
46
56
  }
47
- this.#updateTimers();
57
+ __privateMethod(this, _QueryObserver_instances, updateTimers_fn).call(this);
48
58
  }
49
59
  }
50
60
  onUnsubscribe() {
@@ -54,82 +64,82 @@ var QueryObserver = class extends Subscribable {
54
64
  }
55
65
  shouldFetchOnReconnect() {
56
66
  return shouldFetchOn(
57
- this.#currentQuery,
67
+ __privateGet(this, _currentQuery),
58
68
  this.options,
59
69
  this.options.refetchOnReconnect
60
70
  );
61
71
  }
62
72
  shouldFetchOnWindowFocus() {
63
73
  return shouldFetchOn(
64
- this.#currentQuery,
74
+ __privateGet(this, _currentQuery),
65
75
  this.options,
66
76
  this.options.refetchOnWindowFocus
67
77
  );
68
78
  }
69
79
  destroy() {
70
80
  this.listeners = /* @__PURE__ */ new Set();
71
- this.#clearStaleTimeout();
72
- this.#clearRefetchInterval();
73
- this.#currentQuery.removeObserver(this);
81
+ __privateMethod(this, _QueryObserver_instances, clearStaleTimeout_fn).call(this);
82
+ __privateMethod(this, _QueryObserver_instances, clearRefetchInterval_fn).call(this);
83
+ __privateGet(this, _currentQuery).removeObserver(this);
74
84
  }
75
85
  setOptions(options) {
76
86
  const prevOptions = this.options;
77
- const prevQuery = this.#currentQuery;
78
- this.options = this.#client.defaultQueryOptions(options);
79
- if (this.options.enabled !== void 0 && typeof this.options.enabled !== "boolean" && typeof this.options.enabled !== "function" && typeof resolveEnabled(this.options.enabled, this.#currentQuery) !== "boolean") {
87
+ const prevQuery = __privateGet(this, _currentQuery);
88
+ this.options = __privateGet(this, _client).defaultQueryOptions(options);
89
+ if (this.options.enabled !== void 0 && typeof this.options.enabled !== "boolean" && typeof this.options.enabled !== "function" && typeof resolveEnabled(this.options.enabled, __privateGet(this, _currentQuery)) !== "boolean") {
80
90
  throw new Error(
81
91
  "Expected enabled to be a boolean or a callback that returns a boolean"
82
92
  );
83
93
  }
84
- this.#updateQuery();
85
- this.#currentQuery.setOptions(this.options);
94
+ __privateMethod(this, _QueryObserver_instances, updateQuery_fn).call(this);
95
+ __privateGet(this, _currentQuery).setOptions(this.options);
86
96
  if (prevOptions._defaulted && !shallowEqualObjects(this.options, prevOptions)) {
87
- this.#client.getQueryCache().notify({
97
+ __privateGet(this, _client).getQueryCache().notify({
88
98
  type: "observerOptionsUpdated",
89
- query: this.#currentQuery,
99
+ query: __privateGet(this, _currentQuery),
90
100
  observer: this
91
101
  });
92
102
  }
93
103
  const mounted = this.hasListeners();
94
104
  if (mounted && shouldFetchOptionally(
95
- this.#currentQuery,
105
+ __privateGet(this, _currentQuery),
96
106
  prevQuery,
97
107
  this.options,
98
108
  prevOptions
99
109
  )) {
100
- this.#executeFetch();
110
+ __privateMethod(this, _QueryObserver_instances, executeFetch_fn).call(this);
101
111
  }
102
112
  this.updateResult();
103
- if (mounted && (this.#currentQuery !== prevQuery || resolveEnabled(this.options.enabled, this.#currentQuery) !== resolveEnabled(prevOptions.enabled, this.#currentQuery) || resolveStaleTime(this.options.staleTime, this.#currentQuery) !== resolveStaleTime(prevOptions.staleTime, this.#currentQuery))) {
104
- this.#updateStaleTimeout();
113
+ if (mounted && (__privateGet(this, _currentQuery) !== prevQuery || resolveEnabled(this.options.enabled, __privateGet(this, _currentQuery)) !== resolveEnabled(prevOptions.enabled, __privateGet(this, _currentQuery)) || resolveStaleTime(this.options.staleTime, __privateGet(this, _currentQuery)) !== resolveStaleTime(prevOptions.staleTime, __privateGet(this, _currentQuery)))) {
114
+ __privateMethod(this, _QueryObserver_instances, updateStaleTimeout_fn).call(this);
105
115
  }
106
- const nextRefetchInterval = this.#computeRefetchInterval();
107
- if (mounted && (this.#currentQuery !== prevQuery || resolveEnabled(this.options.enabled, this.#currentQuery) !== resolveEnabled(prevOptions.enabled, this.#currentQuery) || nextRefetchInterval !== this.#currentRefetchInterval)) {
108
- this.#updateRefetchInterval(nextRefetchInterval);
116
+ const nextRefetchInterval = __privateMethod(this, _QueryObserver_instances, computeRefetchInterval_fn).call(this);
117
+ if (mounted && (__privateGet(this, _currentQuery) !== prevQuery || resolveEnabled(this.options.enabled, __privateGet(this, _currentQuery)) !== resolveEnabled(prevOptions.enabled, __privateGet(this, _currentQuery)) || nextRefetchInterval !== __privateGet(this, _currentRefetchInterval))) {
118
+ __privateMethod(this, _QueryObserver_instances, updateRefetchInterval_fn).call(this, nextRefetchInterval);
109
119
  }
110
120
  }
111
121
  getOptimisticResult(options) {
112
- const query = this.#client.getQueryCache().build(this.#client, options);
122
+ const query = __privateGet(this, _client).getQueryCache().build(__privateGet(this, _client), options);
113
123
  const result = this.createResult(query, options);
114
124
  if (shouldAssignObserverCurrentProperties(this, result)) {
115
- this.#currentResult = result;
116
- this.#currentResultOptions = this.options;
117
- this.#currentResultState = this.#currentQuery.state;
125
+ __privateSet(this, _currentResult, result);
126
+ __privateSet(this, _currentResultOptions, this.options);
127
+ __privateSet(this, _currentResultState, __privateGet(this, _currentQuery).state);
118
128
  }
119
129
  return result;
120
130
  }
121
131
  getCurrentResult() {
122
- return this.#currentResult;
132
+ return __privateGet(this, _currentResult);
123
133
  }
124
134
  trackResult(result, onPropTracked) {
125
135
  return new Proxy(result, {
126
136
  get: (target, key) => {
127
137
  this.trackProp(key);
128
- onPropTracked?.(key);
138
+ onPropTracked == null ? void 0 : onPropTracked(key);
129
139
  if (key === "promise") {
130
140
  this.trackProp("data");
131
- if (!this.options.experimental_prefetchInRender && this.#currentThenable.status === "pending") {
132
- this.#currentThenable.reject(
141
+ if (!this.options.experimental_prefetchInRender && __privateGet(this, _currentThenable).status === "pending") {
142
+ __privateGet(this, _currentThenable).reject(
133
143
  new Error(
134
144
  "experimental_prefetchInRender feature flag is not enabled"
135
145
  )
@@ -141,10 +151,10 @@ var QueryObserver = class extends Subscribable {
141
151
  });
142
152
  }
143
153
  trackProp(key) {
144
- this.#trackedProps.add(key);
154
+ __privateGet(this, _trackedProps).add(key);
145
155
  }
146
156
  getCurrentQuery() {
147
- return this.#currentQuery;
157
+ return __privateGet(this, _currentQuery);
148
158
  }
149
159
  refetch({ ...options } = {}) {
150
160
  return this.fetch({
@@ -152,86 +162,28 @@ var QueryObserver = class extends Subscribable {
152
162
  });
153
163
  }
154
164
  fetchOptimistic(options) {
155
- const defaultedOptions = this.#client.defaultQueryOptions(options);
156
- const query = this.#client.getQueryCache().build(this.#client, defaultedOptions);
165
+ const defaultedOptions = __privateGet(this, _client).defaultQueryOptions(options);
166
+ const query = __privateGet(this, _client).getQueryCache().build(__privateGet(this, _client), defaultedOptions);
157
167
  return query.fetch().then(() => this.createResult(query, defaultedOptions));
158
168
  }
159
169
  fetch(fetchOptions) {
160
- return this.#executeFetch({
170
+ return __privateMethod(this, _QueryObserver_instances, executeFetch_fn).call(this, {
161
171
  ...fetchOptions,
162
172
  cancelRefetch: fetchOptions.cancelRefetch ?? true
163
173
  }).then(() => {
164
174
  this.updateResult();
165
- return this.#currentResult;
175
+ return __privateGet(this, _currentResult);
166
176
  });
167
177
  }
168
- #executeFetch(fetchOptions) {
169
- this.#updateQuery();
170
- let promise = this.#currentQuery.fetch(
171
- this.options,
172
- fetchOptions
173
- );
174
- if (!fetchOptions?.throwOnError) {
175
- promise = promise.catch(noop);
176
- }
177
- return promise;
178
- }
179
- #updateStaleTimeout() {
180
- this.#clearStaleTimeout();
181
- const staleTime = resolveStaleTime(
182
- this.options.staleTime,
183
- this.#currentQuery
184
- );
185
- if (environmentManager.isServer() || this.#currentResult.isStale || !isValidTimeout(staleTime)) {
186
- return;
187
- }
188
- const time = timeUntilStale(this.#currentResult.dataUpdatedAt, staleTime);
189
- const timeout = time + 1;
190
- this.#staleTimeoutId = timeoutManager.setTimeout(() => {
191
- if (!this.#currentResult.isStale) {
192
- this.updateResult();
193
- }
194
- }, timeout);
195
- }
196
- #computeRefetchInterval() {
197
- return (typeof this.options.refetchInterval === "function" ? this.options.refetchInterval(this.#currentQuery) : this.options.refetchInterval) ?? false;
198
- }
199
- #updateRefetchInterval(nextInterval) {
200
- this.#clearRefetchInterval();
201
- this.#currentRefetchInterval = nextInterval;
202
- if (environmentManager.isServer() || resolveEnabled(this.options.enabled, this.#currentQuery) === false || !isValidTimeout(this.#currentRefetchInterval) || this.#currentRefetchInterval === 0) {
203
- return;
204
- }
205
- this.#refetchIntervalId = timeoutManager.setInterval(() => {
206
- if (this.options.refetchIntervalInBackground || focusManager.isFocused()) {
207
- this.#executeFetch();
208
- }
209
- }, this.#currentRefetchInterval);
210
- }
211
- #updateTimers() {
212
- this.#updateStaleTimeout();
213
- this.#updateRefetchInterval(this.#computeRefetchInterval());
214
- }
215
- #clearStaleTimeout() {
216
- if (this.#staleTimeoutId) {
217
- timeoutManager.clearTimeout(this.#staleTimeoutId);
218
- this.#staleTimeoutId = void 0;
219
- }
220
- }
221
- #clearRefetchInterval() {
222
- if (this.#refetchIntervalId) {
223
- timeoutManager.clearInterval(this.#refetchIntervalId);
224
- this.#refetchIntervalId = void 0;
225
- }
226
- }
227
178
  createResult(query, options) {
228
- const prevQuery = this.#currentQuery;
179
+ var _a2;
180
+ const prevQuery = __privateGet(this, _currentQuery);
229
181
  const prevOptions = this.options;
230
- const prevResult = this.#currentResult;
231
- const prevResultState = this.#currentResultState;
232
- const prevResultOptions = this.#currentResultOptions;
182
+ const prevResult = __privateGet(this, _currentResult);
183
+ const prevResultState = __privateGet(this, _currentResultState);
184
+ const prevResultOptions = __privateGet(this, _currentResultOptions);
233
185
  const queryChange = query !== prevQuery;
234
- const queryInitialState = queryChange ? query.state : this.#currentQueryInitialState;
186
+ const queryInitialState = queryChange ? query.state : __privateGet(this, _currentQueryInitialState);
235
187
  const { state } = query;
236
188
  let newState = { ...state };
237
189
  let isPlaceholderData = false;
@@ -255,19 +207,19 @@ var QueryObserver = class extends Subscribable {
255
207
  let skipSelect = false;
256
208
  if (options.placeholderData !== void 0 && data === void 0 && status === "pending") {
257
209
  let placeholderData;
258
- if (prevResult?.isPlaceholderData && options.placeholderData === prevResultOptions?.placeholderData) {
210
+ if ((prevResult == null ? void 0 : prevResult.isPlaceholderData) && options.placeholderData === (prevResultOptions == null ? void 0 : prevResultOptions.placeholderData)) {
259
211
  placeholderData = prevResult.data;
260
212
  skipSelect = true;
261
213
  } else {
262
214
  placeholderData = typeof options.placeholderData === "function" ? options.placeholderData(
263
- this.#lastQueryWithDefinedData?.state.data,
264
- this.#lastQueryWithDefinedData
215
+ (_a2 = __privateGet(this, _lastQueryWithDefinedData)) == null ? void 0 : _a2.state.data,
216
+ __privateGet(this, _lastQueryWithDefinedData)
265
217
  ) : options.placeholderData;
266
218
  }
267
219
  if (placeholderData !== void 0) {
268
220
  status = "success";
269
221
  data = replaceData(
270
- prevResult?.data,
222
+ prevResult == null ? void 0 : prevResult.data,
271
223
  placeholderData,
272
224
  options
273
225
  );
@@ -275,23 +227,23 @@ var QueryObserver = class extends Subscribable {
275
227
  }
276
228
  }
277
229
  if (options.select && data !== void 0 && !skipSelect) {
278
- if (prevResult && data === prevResultState?.data && options.select === this.#selectFn) {
279
- data = this.#selectResult;
230
+ if (prevResult && data === (prevResultState == null ? void 0 : prevResultState.data) && options.select === __privateGet(this, _selectFn)) {
231
+ data = __privateGet(this, _selectResult);
280
232
  } else {
281
233
  try {
282
- this.#selectFn = options.select;
234
+ __privateSet(this, _selectFn, options.select);
283
235
  data = options.select(data);
284
- data = replaceData(prevResult?.data, data, options);
285
- this.#selectResult = data;
286
- this.#selectError = null;
236
+ data = replaceData(prevResult == null ? void 0 : prevResult.data, data, options);
237
+ __privateSet(this, _selectResult, data);
238
+ __privateSet(this, _selectError, null);
287
239
  } catch (selectError) {
288
- this.#selectError = selectError;
240
+ __privateSet(this, _selectError, selectError);
289
241
  }
290
242
  }
291
243
  }
292
- if (this.#selectError) {
293
- error = this.#selectError;
294
- data = this.#selectResult;
244
+ if (__privateGet(this, _selectError)) {
245
+ error = __privateGet(this, _selectError);
246
+ data = __privateGet(this, _selectResult);
295
247
  errorUpdatedAt = Date.now();
296
248
  status = "error";
297
249
  }
@@ -325,7 +277,7 @@ var QueryObserver = class extends Subscribable {
325
277
  isRefetchError: isError && hasData,
326
278
  isStale: isStale(query, options),
327
279
  refetch: this.refetch,
328
- promise: this.#currentThenable,
280
+ promise: __privateGet(this, _currentThenable),
329
281
  isEnabled: resolveEnabled(options.enabled, query) !== false
330
282
  };
331
283
  const nextResult = result;
@@ -340,10 +292,10 @@ var QueryObserver = class extends Subscribable {
340
292
  }
341
293
  };
342
294
  const recreateThenable = () => {
343
- const pending = this.#currentThenable = nextResult.promise = pendingThenable();
295
+ const pending = __privateSet(this, _currentThenable, nextResult.promise = pendingThenable());
344
296
  finalizeThenableIfPossible(pending);
345
297
  };
346
- const prevThenable = this.#currentThenable;
298
+ const prevThenable = __privateGet(this, _currentThenable);
347
299
  switch (prevThenable.status) {
348
300
  case "pending":
349
301
  if (query.queryHash === prevQuery.queryHash) {
@@ -365,73 +317,123 @@ var QueryObserver = class extends Subscribable {
365
317
  return nextResult;
366
318
  }
367
319
  updateResult() {
368
- const prevResult = this.#currentResult;
369
- const nextResult = this.createResult(this.#currentQuery, this.options);
370
- this.#currentResultState = this.#currentQuery.state;
371
- this.#currentResultOptions = this.options;
372
- if (this.#currentResultState.data !== void 0) {
373
- this.#lastQueryWithDefinedData = this.#currentQuery;
320
+ const prevResult = __privateGet(this, _currentResult);
321
+ const nextResult = this.createResult(__privateGet(this, _currentQuery), this.options);
322
+ __privateSet(this, _currentResultState, __privateGet(this, _currentQuery).state);
323
+ __privateSet(this, _currentResultOptions, this.options);
324
+ if (__privateGet(this, _currentResultState).data !== void 0) {
325
+ __privateSet(this, _lastQueryWithDefinedData, __privateGet(this, _currentQuery));
374
326
  }
375
327
  if (shallowEqualObjects(nextResult, prevResult)) {
376
328
  return;
377
329
  }
378
- this.#currentResult = nextResult;
330
+ __privateSet(this, _currentResult, nextResult);
379
331
  const shouldNotifyListeners = () => {
380
332
  if (!prevResult) {
381
333
  return true;
382
334
  }
383
335
  const { notifyOnChangeProps } = this.options;
384
336
  const notifyOnChangePropsValue = typeof notifyOnChangeProps === "function" ? notifyOnChangeProps() : notifyOnChangeProps;
385
- if (notifyOnChangePropsValue === "all" || !notifyOnChangePropsValue && !this.#trackedProps.size) {
337
+ if (notifyOnChangePropsValue === "all" || !notifyOnChangePropsValue && !__privateGet(this, _trackedProps).size) {
386
338
  return true;
387
339
  }
388
340
  const includedProps = new Set(
389
- notifyOnChangePropsValue ?? this.#trackedProps
341
+ notifyOnChangePropsValue ?? __privateGet(this, _trackedProps)
390
342
  );
391
343
  if (this.options.throwOnError) {
392
344
  includedProps.add("error");
393
345
  }
394
- return Object.keys(this.#currentResult).some((key) => {
346
+ return Object.keys(__privateGet(this, _currentResult)).some((key) => {
395
347
  const typedKey = key;
396
- const changed = this.#currentResult[typedKey] !== prevResult[typedKey];
348
+ const changed = __privateGet(this, _currentResult)[typedKey] !== prevResult[typedKey];
397
349
  return changed && includedProps.has(typedKey);
398
350
  });
399
351
  };
400
- this.#notify({ listeners: shouldNotifyListeners() });
401
- }
402
- #updateQuery() {
403
- const query = this.#client.getQueryCache().build(this.#client, this.options);
404
- if (query === this.#currentQuery) {
405
- return;
406
- }
407
- const prevQuery = this.#currentQuery;
408
- this.#currentQuery = query;
409
- this.#currentQueryInitialState = query.state;
410
- if (this.hasListeners()) {
411
- prevQuery?.removeObserver(this);
412
- query.addObserver(this);
413
- }
352
+ __privateMethod(this, _QueryObserver_instances, notify_fn).call(this, { listeners: shouldNotifyListeners() });
414
353
  }
415
354
  onQueryUpdate() {
416
355
  this.updateResult();
417
356
  if (this.hasListeners()) {
418
- this.#updateTimers();
357
+ __privateMethod(this, _QueryObserver_instances, updateTimers_fn).call(this);
419
358
  }
420
359
  }
421
- #notify(notifyOptions) {
422
- notifyManager.batch(() => {
423
- if (notifyOptions.listeners) {
424
- this.listeners.forEach((listener) => {
425
- listener(this.#currentResult);
426
- });
427
- }
428
- this.#client.getQueryCache().notify({
429
- query: this.#currentQuery,
430
- type: "observerResultsUpdated"
360
+ }, _client = new WeakMap(), _currentQuery = new WeakMap(), _currentQueryInitialState = new WeakMap(), _currentResult = new WeakMap(), _currentResultState = new WeakMap(), _currentResultOptions = new WeakMap(), _currentThenable = new WeakMap(), _selectError = new WeakMap(), _selectFn = new WeakMap(), _selectResult = new WeakMap(), _lastQueryWithDefinedData = new WeakMap(), _staleTimeoutId = new WeakMap(), _refetchIntervalId = new WeakMap(), _currentRefetchInterval = new WeakMap(), _trackedProps = new WeakMap(), _QueryObserver_instances = new WeakSet(), executeFetch_fn = function(fetchOptions) {
361
+ __privateMethod(this, _QueryObserver_instances, updateQuery_fn).call(this);
362
+ let promise = __privateGet(this, _currentQuery).fetch(
363
+ this.options,
364
+ fetchOptions
365
+ );
366
+ if (!(fetchOptions == null ? void 0 : fetchOptions.throwOnError)) {
367
+ promise = promise.catch(noop);
368
+ }
369
+ return promise;
370
+ }, updateStaleTimeout_fn = function() {
371
+ __privateMethod(this, _QueryObserver_instances, clearStaleTimeout_fn).call(this);
372
+ const staleTime = resolveStaleTime(
373
+ this.options.staleTime,
374
+ __privateGet(this, _currentQuery)
375
+ );
376
+ if (environmentManager.isServer() || __privateGet(this, _currentResult).isStale || !isValidTimeout(staleTime)) {
377
+ return;
378
+ }
379
+ const time = timeUntilStale(__privateGet(this, _currentResult).dataUpdatedAt, staleTime);
380
+ const timeout = time + 1;
381
+ __privateSet(this, _staleTimeoutId, timeoutManager.setTimeout(() => {
382
+ if (!__privateGet(this, _currentResult).isStale) {
383
+ this.updateResult();
384
+ }
385
+ }, timeout));
386
+ }, computeRefetchInterval_fn = function() {
387
+ return (typeof this.options.refetchInterval === "function" ? this.options.refetchInterval(__privateGet(this, _currentQuery)) : this.options.refetchInterval) ?? false;
388
+ }, updateRefetchInterval_fn = function(nextInterval) {
389
+ __privateMethod(this, _QueryObserver_instances, clearRefetchInterval_fn).call(this);
390
+ __privateSet(this, _currentRefetchInterval, nextInterval);
391
+ if (environmentManager.isServer() || resolveEnabled(this.options.enabled, __privateGet(this, _currentQuery)) === false || !isValidTimeout(__privateGet(this, _currentRefetchInterval)) || __privateGet(this, _currentRefetchInterval) === 0) {
392
+ return;
393
+ }
394
+ __privateSet(this, _refetchIntervalId, timeoutManager.setInterval(() => {
395
+ if (this.options.refetchIntervalInBackground || focusManager.isFocused()) {
396
+ __privateMethod(this, _QueryObserver_instances, executeFetch_fn).call(this);
397
+ }
398
+ }, __privateGet(this, _currentRefetchInterval)));
399
+ }, updateTimers_fn = function() {
400
+ __privateMethod(this, _QueryObserver_instances, updateStaleTimeout_fn).call(this);
401
+ __privateMethod(this, _QueryObserver_instances, updateRefetchInterval_fn).call(this, __privateMethod(this, _QueryObserver_instances, computeRefetchInterval_fn).call(this));
402
+ }, clearStaleTimeout_fn = function() {
403
+ if (__privateGet(this, _staleTimeoutId)) {
404
+ timeoutManager.clearTimeout(__privateGet(this, _staleTimeoutId));
405
+ __privateSet(this, _staleTimeoutId, void 0);
406
+ }
407
+ }, clearRefetchInterval_fn = function() {
408
+ if (__privateGet(this, _refetchIntervalId)) {
409
+ timeoutManager.clearInterval(__privateGet(this, _refetchIntervalId));
410
+ __privateSet(this, _refetchIntervalId, void 0);
411
+ }
412
+ }, updateQuery_fn = function() {
413
+ const query = __privateGet(this, _client).getQueryCache().build(__privateGet(this, _client), this.options);
414
+ if (query === __privateGet(this, _currentQuery)) {
415
+ return;
416
+ }
417
+ const prevQuery = __privateGet(this, _currentQuery);
418
+ __privateSet(this, _currentQuery, query);
419
+ __privateSet(this, _currentQueryInitialState, query.state);
420
+ if (this.hasListeners()) {
421
+ prevQuery == null ? void 0 : prevQuery.removeObserver(this);
422
+ query.addObserver(this);
423
+ }
424
+ }, notify_fn = function(notifyOptions) {
425
+ notifyManager.batch(() => {
426
+ if (notifyOptions.listeners) {
427
+ this.listeners.forEach((listener) => {
428
+ listener(__privateGet(this, _currentResult));
431
429
  });
430
+ }
431
+ __privateGet(this, _client).getQueryCache().notify({
432
+ query: __privateGet(this, _currentQuery),
433
+ type: "observerResultsUpdated"
432
434
  });
433
- }
434
- };
435
+ });
436
+ }, _a);
435
437
  function shouldLoadOnMount(query, options) {
436
438
  return resolveEnabled(options.enabled, query) !== false && query.state.data === void 0 && !(query.state.status === "error" && options.retryOnMount === false);
437
439
  }