@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.
- package/CHANGELOG.md +39 -0
- package/dist/.vite/manifest.json +45 -5
- package/dist/_virtual/dynamic-import-helper.js +20 -0
- package/dist/_virtual/dynamic-import-helper.js.map +1 -0
- package/dist/components/Boundary.js +5 -4
- package/dist/components/Boundary.js.map +1 -1
- package/dist/components/InvenTreeTable.js +4 -3
- package/dist/components/InvenTreeTable.js.map +1 -1
- package/dist/components/RowActions.js +3 -2
- package/dist/components/RowActions.js.map +1 -1
- package/dist/components/TableColumnSelect.js +1 -1
- package/dist/components/TableColumnSelect.js.map +1 -1
- package/dist/components/TagsList.d.ts +3 -0
- package/dist/components/TagsList.js +21 -0
- package/dist/components/TagsList.js.map +1 -0
- package/dist/components/nav/DetailDrawer.d.ts +1 -0
- package/dist/components/nav/DetailDrawer.js +1 -0
- package/dist/components/nav/DetailDrawer.js.map +1 -1
- package/dist/enums/ApiEndpoints.d.ts +15 -4
- package/dist/enums/ApiEndpoints.js +15 -4
- package/dist/enums/ApiEndpoints.js.map +1 -1
- package/dist/enums/ModelInformation.d.ts +1 -0
- package/dist/enums/ModelInformation.js +55 -2
- package/dist/enums/ModelInformation.js.map +1 -1
- package/dist/enums/ModelType.d.ts +4 -1
- package/dist/enums/ModelType.js +3 -0
- package/dist/enums/ModelType.js.map +1 -1
- package/dist/enums/Roles.d.ts +1 -0
- package/dist/enums/Roles.js +1 -0
- package/dist/enums/Roles.js.map +1 -1
- package/dist/functions/Events.js +4 -3
- package/dist/functions/Events.js.map +1 -1
- package/dist/functions/Navigation.js +6 -3
- package/dist/functions/Navigation.js.map +1 -1
- package/dist/functions/Plugins.js +4 -2
- package/dist/functions/Plugins.js.map +1 -1
- package/dist/hooks/MonitorBackgroundTask.js +10 -8
- package/dist/hooks/MonitorBackgroundTask.js.map +1 -1
- package/dist/hooks/MonitorDataOutput.js +4 -3
- package/dist/hooks/MonitorDataOutput.js.map +1 -1
- package/dist/hooks/UseFilterSet.js +45 -7
- package/dist/hooks/UseFilterSet.js.map +1 -1
- package/dist/hooks/UseTable.js +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +20 -11
- package/dist/index.js.map +1 -1
- package/dist/node_modules/@mantine/hooks/esm/use-debounced-value/use-debounced-value.js +40 -15
- package/dist/node_modules/@mantine/hooks/esm/use-debounced-value/use-debounced-value.js.map +1 -1
- package/dist/node_modules/@mantine/hooks/esm/use-document-visibility/use-document-visibility.js +1 -1
- package/dist/node_modules/@mantine/hooks/esm/use-document-visibility/use-document-visibility.js.map +1 -1
- package/dist/node_modules/@mantine/hooks/esm/use-local-storage/create-storage.js +57 -62
- package/dist/node_modules/@mantine/hooks/esm/use-local-storage/create-storage.js.map +1 -1
- package/dist/node_modules/@mantine/hooks/esm/use-local-storage/use-local-storage.js.map +1 -1
- package/dist/node_modules/@mantine/hooks/esm/use-window-event/use-window-event.js +5 -3
- package/dist/node_modules/@mantine/hooks/esm/use-window-event/use-window-event.js.map +1 -1
- package/dist/node_modules/@mantine/hooks/esm/utils/random-id/random-id.js.map +1 -1
- package/dist/node_modules/@remix-run/router/dist/router.js +10 -0
- package/dist/node_modules/@remix-run/router/dist/router.js.map +1 -1
- package/dist/node_modules/@sentry/browser/build/npm/esm/prod/report-dialog.js +2 -2
- package/dist/node_modules/@sentry/browser/build/npm/esm/prod/report-dialog.js.map +1 -1
- package/dist/node_modules/@sentry/core/build/esm/scope.js +6 -5
- package/dist/node_modules/@sentry/core/build/esm/scope.js.map +1 -1
- package/dist/node_modules/@sentry/core/build/esm/utils/chain-and-copy-promiselike.js +1 -1
- package/dist/node_modules/@sentry/core/build/esm/utils/chain-and-copy-promiselike.js.map +1 -1
- package/dist/node_modules/@sentry/core/build/esm/utils/is.js +1 -1
- package/dist/node_modules/@sentry/core/build/esm/utils/is.js.map +1 -1
- package/dist/node_modules/@sentry/core/build/esm/utils/misc.js +1 -1
- package/dist/node_modules/@sentry/core/build/esm/utils/misc.js.map +1 -1
- package/dist/node_modules/@sentry/core/build/esm/utils/randomSafeContext.js +1 -1
- package/dist/node_modules/@sentry/core/build/esm/utils/randomSafeContext.js.map +1 -1
- package/dist/node_modules/@sentry/core/build/esm/utils/time.js +1 -1
- package/dist/node_modules/@sentry/core/build/esm/utils/time.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/createReactComponent.js +6 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/createReactComponent.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/defaultAttributes.js +6 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/defaultAttributes.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconAdjustments.js +6 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconAdjustments.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconArrowRight.js +6 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconArrowRight.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCheck.js +6 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCheck.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconChevronLeft.js +6 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconChevronLeft.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCircleCheck.js +6 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCircleCheck.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCircleX.js +6 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCircleX.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCopy.js +6 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCopy.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconDots.js +6 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconDots.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconEdit.js +6 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconEdit.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconExclamationCircle.js +6 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconExclamationCircle.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconPlus.js +6 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconPlus.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconSearch.js +6 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconSearch.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconTag.js +14 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconTag.js.map +1 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconTrash.js +6 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconTrash.js.map +1 -1
- package/dist/node_modules/@tanstack/query-core/build/modern/focusManager.js +31 -20
- package/dist/node_modules/@tanstack/query-core/build/modern/focusManager.js.map +1 -1
- package/dist/node_modules/@tanstack/query-core/build/modern/onlineManager.js +27 -17
- package/dist/node_modules/@tanstack/query-core/build/modern/onlineManager.js.map +1 -1
- package/dist/node_modules/@tanstack/query-core/build/modern/queryObserver.js +179 -177
- package/dist/node_modules/@tanstack/query-core/build/modern/queryObserver.js.map +1 -1
- package/dist/node_modules/@tanstack/query-core/build/modern/timeoutManager.js +31 -21
- package/dist/node_modules/@tanstack/query-core/build/modern/timeoutManager.js.map +1 -1
- package/dist/node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.js +1 -1
- package/dist/node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.js.map +1 -1
- package/dist/node_modules/@tanstack/react-query/build/modern/suspense.js +1 -1
- package/dist/node_modules/@tanstack/react-query/build/modern/suspense.js.map +1 -1
- package/dist/node_modules/@tanstack/react-query/build/modern/useBaseQuery.js +7 -4
- package/dist/node_modules/@tanstack/react-query/build/modern/useBaseQuery.js.map +1 -1
- package/dist/node_modules/react/cjs/react-jsx-runtime.development.js +10 -1
- package/dist/node_modules/react/cjs/react-jsx-runtime.development.js.map +1 -1
- package/dist/node_modules/react/cjs/react-jsx-runtime.production.js +10 -1
- package/dist/node_modules/react/cjs/react-jsx-runtime.production.js.map +1 -1
- package/dist/node_modules/react-router/dist/index.js +11 -1
- package/dist/node_modules/react-router/dist/index.js.map +1 -1
- package/dist/node_modules/react-router-dom/dist/index.js +10 -0
- package/dist/node_modules/react-router-dom/dist/index.js.map +1 -1
- package/dist/plugin/InventreeHmrPlugin.d.ts +8 -0
- package/dist/plugin/InventreeHmrPlugin.js +21 -0
- package/dist/plugin/InventreeHmrPlugin.js.map +1 -0
- package/dist/plugin/LocalizedComponent.d.ts +9 -0
- package/dist/plugin/LocalizedComponent.js +57 -0
- package/dist/plugin/LocalizedComponent.js.map +1 -0
- package/dist/states/StoredTableState.js +2 -1
- package/dist/states/StoredTableState.js.map +1 -1
- package/dist/states/types.d.ts +3 -0
- package/dist/types/Filters.d.ts +11 -0
- package/dist/types/Forms.d.ts +6 -1
- package/dist/types/Panel.d.ts +26 -0
- package/dist/types/Plugins.d.ts +14 -2
- package/dist/types/Plugins.js +2 -2
- package/dist/types/Plugins.js.map +1 -1
- package/dist/types/Rendering.d.ts +54 -0
- package/dist/types/Tables.d.ts +7 -3
- package/lib/components/Boundary.tsx +7 -3
- package/lib/components/RowActions.tsx +2 -2
- package/lib/components/TableColumnSelect.tsx +1 -1
- package/lib/components/TagsList.tsx +27 -0
- package/lib/components/nav/DetailDrawer.tsx +1 -1
- package/lib/enums/ApiEndpoints.tsx +18 -4
- package/lib/enums/ModelInformation.tsx +26 -2
- package/lib/enums/ModelType.tsx +4 -1
- package/lib/enums/Roles.tsx +3 -0
- package/lib/functions/Navigation.tsx +1 -1
- package/lib/hooks/UseFilterSet.tsx +62 -11
- package/lib/index.ts +14 -1
- package/lib/plugin/InventreeHmrPlugin.tsx +40 -0
- package/lib/plugin/LocalizedComponent.tsx +85 -0
- package/lib/states/types.tsx +7 -0
- package/lib/types/Filters.tsx +19 -0
- package/lib/types/Forms.tsx +7 -1
- package/lib/types/Panel.tsx +30 -0
- package/lib/types/Plugins.tsx +20 -1
- package/lib/types/Rendering.tsx +61 -0
- package/lib/types/Tables.tsx +8 -3
- 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
|
|
14
|
-
this
|
|
15
|
-
this
|
|
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
|
|
42
|
-
if (shouldFetchOnMount(this
|
|
43
|
-
this
|
|
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
|
|
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
|
|
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
|
|
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
|
|
72
|
-
this
|
|
73
|
-
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
|
|
78
|
-
this.options = this
|
|
79
|
-
if (this.options.enabled !== void 0 && typeof this.options.enabled !== "boolean" && typeof this.options.enabled !== "function" && typeof resolveEnabled(this.options.enabled, this
|
|
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
|
|
85
|
-
this
|
|
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
|
|
97
|
+
__privateGet(this, _client).getQueryCache().notify({
|
|
88
98
|
type: "observerOptionsUpdated",
|
|
89
|
-
query: this
|
|
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
|
|
105
|
+
__privateGet(this, _currentQuery),
|
|
96
106
|
prevQuery,
|
|
97
107
|
this.options,
|
|
98
108
|
prevOptions
|
|
99
109
|
)) {
|
|
100
|
-
this
|
|
110
|
+
__privateMethod(this, _QueryObserver_instances, executeFetch_fn).call(this);
|
|
101
111
|
}
|
|
102
112
|
this.updateResult();
|
|
103
|
-
if (mounted && (this
|
|
104
|
-
this
|
|
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
|
|
107
|
-
if (mounted && (this
|
|
108
|
-
this
|
|
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
|
|
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
|
|
116
|
-
this
|
|
117
|
-
this
|
|
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
|
|
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
|
|
138
|
+
onPropTracked == null ? void 0 : onPropTracked(key);
|
|
129
139
|
if (key === "promise") {
|
|
130
140
|
this.trackProp("data");
|
|
131
|
-
if (!this.options.experimental_prefetchInRender && this
|
|
132
|
-
this
|
|
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
|
|
154
|
+
__privateGet(this, _trackedProps).add(key);
|
|
145
155
|
}
|
|
146
156
|
getCurrentQuery() {
|
|
147
|
-
return this
|
|
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
|
|
156
|
-
const query = this
|
|
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
|
|
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
|
|
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
|
-
|
|
179
|
+
var _a2;
|
|
180
|
+
const prevQuery = __privateGet(this, _currentQuery);
|
|
229
181
|
const prevOptions = this.options;
|
|
230
|
-
const prevResult = this
|
|
231
|
-
const prevResultState = this
|
|
232
|
-
const prevResultOptions = this
|
|
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
|
|
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
|
|
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
|
|
264
|
-
this
|
|
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
|
|
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
|
|
279
|
-
data = this
|
|
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
|
|
234
|
+
__privateSet(this, _selectFn, options.select);
|
|
283
235
|
data = options.select(data);
|
|
284
|
-
data = replaceData(prevResult
|
|
285
|
-
this
|
|
286
|
-
this
|
|
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
|
|
240
|
+
__privateSet(this, _selectError, selectError);
|
|
289
241
|
}
|
|
290
242
|
}
|
|
291
243
|
}
|
|
292
|
-
if (this
|
|
293
|
-
error = this
|
|
294
|
-
data = this
|
|
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
|
|
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
|
|
295
|
+
const pending = __privateSet(this, _currentThenable, nextResult.promise = pendingThenable());
|
|
344
296
|
finalizeThenableIfPossible(pending);
|
|
345
297
|
};
|
|
346
|
-
const prevThenable = this
|
|
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
|
|
369
|
-
const nextResult = this.createResult(this
|
|
370
|
-
this
|
|
371
|
-
this
|
|
372
|
-
if (this
|
|
373
|
-
this
|
|
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
|
|
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
|
|
337
|
+
if (notifyOnChangePropsValue === "all" || !notifyOnChangePropsValue && !__privateGet(this, _trackedProps).size) {
|
|
386
338
|
return true;
|
|
387
339
|
}
|
|
388
340
|
const includedProps = new Set(
|
|
389
|
-
notifyOnChangePropsValue ?? this
|
|
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
|
|
346
|
+
return Object.keys(__privateGet(this, _currentResult)).some((key) => {
|
|
395
347
|
const typedKey = key;
|
|
396
|
-
const changed = this
|
|
348
|
+
const changed = __privateGet(this, _currentResult)[typedKey] !== prevResult[typedKey];
|
|
397
349
|
return changed && includedProps.has(typedKey);
|
|
398
350
|
});
|
|
399
351
|
};
|
|
400
|
-
this
|
|
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
|
|
357
|
+
__privateMethod(this, _QueryObserver_instances, updateTimers_fn).call(this);
|
|
419
358
|
}
|
|
420
359
|
}
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
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
|
}
|