@elice/material-shared-utils 1.251120.1 → 1.260128.0-rc.0
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/cjs/_virtual/_rollupPluginBabelHelpers.js +177 -376
- package/cjs/_virtual/index.js +5 -0
- package/cjs/_virtual/use-sync-external-store-shim.production.js +5 -0
- package/cjs/hooks/useHelpyLogo.js +3 -7
- package/cjs/index.js +4 -4
- package/cjs/material-config/MaterialConfigContext.d.ts +0 -1
- package/cjs/material-config/MaterialConfigContext.js +2 -2
- package/cjs/material-fetch/useMaterialFetch.d.ts +2 -47
- package/cjs/material-fetch/useMaterialFetch.js +1 -4
- package/cjs/material-fetch/useMaterialFetchRaw.d.ts +1 -1
- package/cjs/material-fetch/useMaterialFetchRaw.js +12 -19
- package/cjs/material-hoc/withMaterial.d.ts +1 -1
- package/cjs/material-hoc/withMaterial.js +0 -1
- package/cjs/node_modules/@tanstack/query-core/build/lib/focusManager.js +93 -0
- package/cjs/node_modules/@tanstack/query-core/build/lib/notifyManager.js +101 -0
- package/cjs/node_modules/@tanstack/query-core/build/lib/onlineManager.js +95 -0
- package/cjs/node_modules/@tanstack/query-core/build/lib/queryObserver.js +571 -0
- package/cjs/node_modules/@tanstack/query-core/build/lib/retryer.js +21 -0
- package/cjs/node_modules/@tanstack/query-core/build/lib/subscribable.js +33 -0
- package/cjs/node_modules/@tanstack/query-core/build/lib/utils.js +154 -0
- package/cjs/node_modules/@tanstack/react-query/build/lib/QueryClientProvider.js +65 -0
- package/cjs/node_modules/@tanstack/react-query/build/lib/QueryErrorResetBoundary.js +46 -0
- package/cjs/node_modules/@tanstack/react-query/build/lib/errorBoundaryUtils.js +52 -0
- package/cjs/node_modules/@tanstack/react-query/build/lib/isRestoring.js +31 -0
- package/cjs/node_modules/@tanstack/react-query/build/lib/suspense.js +39 -0
- package/cjs/node_modules/@tanstack/react-query/build/lib/useBaseQuery.js +94 -0
- package/cjs/node_modules/@tanstack/react-query/build/lib/useQuery.js +14 -0
- package/cjs/node_modules/@tanstack/react-query/build/lib/useSyncExternalStore.js +9 -0
- package/cjs/node_modules/@tanstack/react-query/build/lib/utils.js +12 -0
- package/cjs/node_modules/rxjs/dist/esm5/internal/BehaviorSubject.js +39 -0
- package/cjs/node_modules/rxjs/dist/esm5/internal/Observable.js +105 -0
- package/cjs/node_modules/rxjs/dist/esm5/internal/Subject.js +165 -0
- package/cjs/node_modules/rxjs/dist/esm5/internal/Subscriber.js +157 -0
- package/cjs/node_modules/rxjs/dist/esm5/internal/Subscription.js +148 -0
- package/cjs/node_modules/rxjs/dist/esm5/internal/config.js +6 -0
- package/cjs/node_modules/rxjs/dist/esm5/internal/scheduler/timeoutProvider.js +19 -0
- package/cjs/node_modules/rxjs/dist/esm5/internal/symbol/observable.js +5 -0
- package/cjs/node_modules/rxjs/dist/esm5/internal/util/ObjectUnsubscribedError.js +13 -0
- package/cjs/node_modules/rxjs/dist/esm5/internal/util/UnsubscriptionError.js +16 -0
- package/cjs/node_modules/rxjs/dist/esm5/internal/util/arrRemove.js +10 -0
- package/cjs/node_modules/rxjs/dist/esm5/internal/util/createErrorClass.js +14 -0
- package/cjs/node_modules/rxjs/dist/esm5/internal/util/errorContext.js +9 -0
- package/cjs/node_modules/rxjs/dist/esm5/internal/util/identity.js +7 -0
- package/cjs/node_modules/rxjs/dist/esm5/internal/util/isFunction.js +7 -0
- package/cjs/node_modules/rxjs/dist/esm5/internal/util/noop.js +5 -0
- package/cjs/node_modules/rxjs/dist/esm5/internal/util/pipe.js +17 -0
- package/cjs/node_modules/rxjs/dist/esm5/internal/util/reportUnhandledError.js +13 -0
- package/cjs/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js +77 -0
- package/cjs/node_modules/use-sync-external-store/shim/index.js +13 -0
- package/es/_virtual/_rollupPluginBabelHelpers.js +176 -376
- package/es/_virtual/index.js +3 -0
- package/es/_virtual/use-sync-external-store-shim.production.js +3 -0
- package/es/hooks/useCallbackProp.js +3 -3
- package/es/hooks/useDeepClonedCompareEffect.js +2 -2
- package/es/hooks/useHelpyLogo.js +2 -6
- package/es/index.js +2 -2
- package/es/material-config/MaterialConfigContext.d.ts +0 -1
- package/es/material-config/MaterialConfigContext.js +1 -1
- package/es/material-config/MaterialConfigProvider.js +5 -5
- package/es/material-fetch/useMaterialFetch.d.ts +2 -47
- package/es/material-fetch/useMaterialFetch.js +1 -4
- package/es/material-fetch/useMaterialFetchRaw.d.ts +1 -1
- package/es/material-fetch/useMaterialFetchRaw.js +13 -20
- package/es/material-hoc/withMaterial.d.ts +1 -1
- package/es/material-hoc/withMaterial.js +0 -1
- package/es/node_modules/@tanstack/query-core/build/lib/focusManager.js +90 -0
- package/es/node_modules/@tanstack/query-core/build/lib/notifyManager.js +98 -0
- package/es/node_modules/@tanstack/query-core/build/lib/onlineManager.js +92 -0
- package/es/node_modules/@tanstack/query-core/build/lib/queryObserver.js +569 -0
- package/es/node_modules/@tanstack/query-core/build/lib/retryer.js +17 -0
- package/es/node_modules/@tanstack/query-core/build/lib/subscribable.js +31 -0
- package/es/node_modules/@tanstack/query-core/build/lib/utils.js +140 -0
- package/es/node_modules/@tanstack/react-query/build/lib/QueryClientProvider.js +42 -0
- package/es/node_modules/@tanstack/react-query/build/lib/QueryErrorResetBoundary.js +24 -0
- package/es/node_modules/@tanstack/react-query/build/lib/errorBoundaryUtils.js +28 -0
- package/es/node_modules/@tanstack/react-query/build/lib/isRestoring.js +9 -0
- package/es/node_modules/@tanstack/react-query/build/lib/suspense.js +34 -0
- package/es/node_modules/@tanstack/react-query/build/lib/useBaseQuery.js +72 -0
- package/es/node_modules/@tanstack/react-query/build/lib/useQuery.js +12 -0
- package/es/node_modules/@tanstack/react-query/build/lib/useSyncExternalStore.js +7 -0
- package/es/node_modules/@tanstack/react-query/build/lib/utils.js +10 -0
- package/es/node_modules/rxjs/dist/esm5/internal/BehaviorSubject.js +37 -0
- package/es/node_modules/rxjs/dist/esm5/internal/Observable.js +103 -0
- package/es/node_modules/rxjs/dist/esm5/internal/Subject.js +162 -0
- package/es/node_modules/rxjs/dist/esm5/internal/Subscriber.js +153 -0
- package/es/node_modules/rxjs/dist/esm5/internal/Subscription.js +144 -0
- package/es/node_modules/rxjs/dist/esm5/internal/config.js +4 -0
- package/es/node_modules/rxjs/dist/esm5/internal/scheduler/timeoutProvider.js +17 -0
- package/es/node_modules/rxjs/dist/esm5/internal/symbol/observable.js +3 -0
- package/es/node_modules/rxjs/dist/esm5/internal/util/ObjectUnsubscribedError.js +11 -0
- package/es/node_modules/rxjs/dist/esm5/internal/util/UnsubscriptionError.js +14 -0
- package/es/node_modules/rxjs/dist/esm5/internal/util/arrRemove.js +8 -0
- package/es/node_modules/rxjs/dist/esm5/internal/util/createErrorClass.js +12 -0
- package/es/node_modules/rxjs/dist/esm5/internal/util/errorContext.js +7 -0
- package/es/node_modules/rxjs/dist/esm5/internal/util/identity.js +5 -0
- package/es/node_modules/rxjs/dist/esm5/internal/util/isFunction.js +5 -0
- package/es/node_modules/rxjs/dist/esm5/internal/util/noop.js +3 -0
- package/es/node_modules/rxjs/dist/esm5/internal/util/pipe.js +15 -0
- package/es/node_modules/rxjs/dist/esm5/internal/util/reportUnhandledError.js +11 -0
- package/es/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js +69 -0
- package/es/node_modules/use-sync-external-store/shim/index.js +11 -0
- package/package.json +6 -4
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// TYPES
|
|
4
|
+
// UTILS
|
|
5
|
+
const isServer = typeof window === 'undefined' || 'Deno' in window;
|
|
6
|
+
function noop() {
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
function isValidTimeout(value) {
|
|
10
|
+
return typeof value === 'number' && value >= 0 && value !== Infinity;
|
|
11
|
+
}
|
|
12
|
+
function timeUntilStale(updatedAt, staleTime) {
|
|
13
|
+
return Math.max(updatedAt + (staleTime || 0) - Date.now(), 0);
|
|
14
|
+
}
|
|
15
|
+
function parseQueryArgs(arg1, arg2, arg3) {
|
|
16
|
+
if (!isQueryKey(arg1)) {
|
|
17
|
+
return arg1;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return { ...arg2,
|
|
21
|
+
queryKey: arg1
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* This function returns `a` if `b` is deeply equal.
|
|
26
|
+
* If not, it will replace any deeply equal children of `b` with those of `a`.
|
|
27
|
+
* This can be used for structural sharing between JSON values for example.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
function replaceEqualDeep(a, b, depth = 0) {
|
|
31
|
+
if (a === b) {
|
|
32
|
+
return a;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (depth > 500) return b;
|
|
36
|
+
const array = isPlainArray(a) && isPlainArray(b);
|
|
37
|
+
|
|
38
|
+
if (array || isPlainObject(a) && isPlainObject(b)) {
|
|
39
|
+
const aSize = array ? a.length : Object.keys(a).length;
|
|
40
|
+
const bItems = array ? b : Object.keys(b);
|
|
41
|
+
const bSize = bItems.length;
|
|
42
|
+
const copy = array ? [] : {};
|
|
43
|
+
let equalItems = 0;
|
|
44
|
+
|
|
45
|
+
for (let i = 0; i < bSize; i++) {
|
|
46
|
+
const key = array ? i : bItems[i];
|
|
47
|
+
copy[key] = replaceEqualDeep(a[key], b[key], depth + 1);
|
|
48
|
+
|
|
49
|
+
if (copy[key] === a[key]) {
|
|
50
|
+
equalItems++;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return aSize === bSize && equalItems === aSize ? a : copy;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return b;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Shallow compare objects. Only works with objects that always have the same properties.
|
|
61
|
+
*/
|
|
62
|
+
|
|
63
|
+
function shallowEqualObjects(a, b) {
|
|
64
|
+
if (a && !b || b && !a) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
for (const key in a) {
|
|
69
|
+
if (a[key] !== b[key]) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
function isPlainArray(value) {
|
|
77
|
+
return Array.isArray(value) && value.length === Object.keys(value).length;
|
|
78
|
+
} // Copied from: https://github.com/jonschlinkert/is-plain-object
|
|
79
|
+
|
|
80
|
+
function isPlainObject(o) {
|
|
81
|
+
if (!hasObjectPrototype(o)) {
|
|
82
|
+
return false;
|
|
83
|
+
} // If has modified constructor
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
const ctor = o.constructor;
|
|
87
|
+
|
|
88
|
+
if (typeof ctor === 'undefined') {
|
|
89
|
+
return true;
|
|
90
|
+
} // If has modified prototype
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
const prot = ctor.prototype;
|
|
94
|
+
|
|
95
|
+
if (!hasObjectPrototype(prot)) {
|
|
96
|
+
return false;
|
|
97
|
+
} // If constructor does not have an Object-specific method
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
if (!prot.hasOwnProperty('isPrototypeOf')) {
|
|
101
|
+
return false;
|
|
102
|
+
} // Most likely a plain Object
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function hasObjectPrototype(o) {
|
|
109
|
+
return Object.prototype.toString.call(o) === '[object Object]';
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function isQueryKey(value) {
|
|
113
|
+
return Array.isArray(value);
|
|
114
|
+
}
|
|
115
|
+
function sleep(timeout) {
|
|
116
|
+
return new Promise(resolve => {
|
|
117
|
+
setTimeout(resolve, timeout);
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Schedules a microtask.
|
|
122
|
+
* This can be useful to schedule state updates after rendering.
|
|
123
|
+
*/
|
|
124
|
+
|
|
125
|
+
function scheduleMicrotask(callback) {
|
|
126
|
+
sleep(0).then(callback);
|
|
127
|
+
}
|
|
128
|
+
function replaceData(prevData, data, options) {
|
|
129
|
+
// Use prev data if an isDataEqual function is defined and returns `true`
|
|
130
|
+
if (options.isDataEqual != null && options.isDataEqual(prevData, data)) {
|
|
131
|
+
return prevData;
|
|
132
|
+
} else if (typeof options.structuralSharing === 'function') {
|
|
133
|
+
return options.structuralSharing(prevData, data);
|
|
134
|
+
} else if (options.structuralSharing !== false) {
|
|
135
|
+
// Structurally share data between prev and new data if needed
|
|
136
|
+
return replaceEqualDeep(prevData, data);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return data;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
exports.isPlainArray = isPlainArray;
|
|
143
|
+
exports.isPlainObject = isPlainObject;
|
|
144
|
+
exports.isQueryKey = isQueryKey;
|
|
145
|
+
exports.isServer = isServer;
|
|
146
|
+
exports.isValidTimeout = isValidTimeout;
|
|
147
|
+
exports.noop = noop;
|
|
148
|
+
exports.parseQueryArgs = parseQueryArgs;
|
|
149
|
+
exports.replaceData = replaceData;
|
|
150
|
+
exports.replaceEqualDeep = replaceEqualDeep;
|
|
151
|
+
exports.scheduleMicrotask = scheduleMicrotask;
|
|
152
|
+
exports.shallowEqualObjects = shallowEqualObjects;
|
|
153
|
+
exports.sleep = sleep;
|
|
154
|
+
exports.timeUntilStale = timeUntilStale;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
|
|
7
|
+
function _interopNamespaceCompat(e) {
|
|
8
|
+
if (e && typeof e === 'object' && 'default' in e) return e;
|
|
9
|
+
var n = Object.create(null);
|
|
10
|
+
if (e) {
|
|
11
|
+
Object.keys(e).forEach(function (k) {
|
|
12
|
+
if (k !== 'default') {
|
|
13
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () { return e[k]; }
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
n.default = e;
|
|
22
|
+
return Object.freeze(n);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceCompat(React);
|
|
26
|
+
|
|
27
|
+
const defaultContext = /*#__PURE__*/React__namespace.createContext(undefined);
|
|
28
|
+
const QueryClientSharingContext = /*#__PURE__*/React__namespace.createContext(false); // If we are given a context, we will use it.
|
|
29
|
+
// Otherwise, if contextSharing is on, we share the first and at least one
|
|
30
|
+
// instance of the context across the window
|
|
31
|
+
// to ensure that if React Query is used across
|
|
32
|
+
// different bundles or microfrontends they will
|
|
33
|
+
// all use the same **instance** of context, regardless
|
|
34
|
+
// of module scoping.
|
|
35
|
+
|
|
36
|
+
function getQueryClientContext(context, contextSharing) {
|
|
37
|
+
if (context) {
|
|
38
|
+
return context;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (contextSharing && typeof window !== 'undefined') {
|
|
42
|
+
if (!window.ReactQueryClientContext) {
|
|
43
|
+
window.ReactQueryClientContext = defaultContext;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return window.ReactQueryClientContext;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return defaultContext;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const useQueryClient = ({
|
|
53
|
+
context
|
|
54
|
+
} = {}) => {
|
|
55
|
+
const queryClient = React__namespace.useContext(getQueryClientContext(context, React__namespace.useContext(QueryClientSharingContext)));
|
|
56
|
+
|
|
57
|
+
if (!queryClient) {
|
|
58
|
+
throw new Error('No QueryClient set, use QueryClientProvider to set one');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return queryClient;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
exports.defaultContext = defaultContext;
|
|
65
|
+
exports.useQueryClient = useQueryClient;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
|
|
7
|
+
function _interopNamespaceCompat(e) {
|
|
8
|
+
if (e && typeof e === 'object' && 'default' in e) return e;
|
|
9
|
+
var n = Object.create(null);
|
|
10
|
+
if (e) {
|
|
11
|
+
Object.keys(e).forEach(function (k) {
|
|
12
|
+
if (k !== 'default') {
|
|
13
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () { return e[k]; }
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
n.default = e;
|
|
22
|
+
return Object.freeze(n);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceCompat(React);
|
|
26
|
+
|
|
27
|
+
function createValue() {
|
|
28
|
+
let isReset = false;
|
|
29
|
+
return {
|
|
30
|
+
clearReset: () => {
|
|
31
|
+
isReset = false;
|
|
32
|
+
},
|
|
33
|
+
reset: () => {
|
|
34
|
+
isReset = true;
|
|
35
|
+
},
|
|
36
|
+
isReset: () => {
|
|
37
|
+
return isReset;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const QueryErrorResetBoundaryContext = /*#__PURE__*/React__namespace.createContext(createValue()); // HOOK
|
|
43
|
+
|
|
44
|
+
const useQueryErrorResetBoundary = () => React__namespace.useContext(QueryErrorResetBoundaryContext); // COMPONENT
|
|
45
|
+
|
|
46
|
+
exports.useQueryErrorResetBoundary = useQueryErrorResetBoundary;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var utils = require('./utils.js');
|
|
7
|
+
|
|
8
|
+
function _interopNamespaceCompat(e) {
|
|
9
|
+
if (e && typeof e === 'object' && 'default' in e) return e;
|
|
10
|
+
var n = Object.create(null);
|
|
11
|
+
if (e) {
|
|
12
|
+
Object.keys(e).forEach(function (k) {
|
|
13
|
+
if (k !== 'default') {
|
|
14
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
15
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return e[k]; }
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
n.default = e;
|
|
23
|
+
return Object.freeze(n);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceCompat(React);
|
|
27
|
+
|
|
28
|
+
const ensurePreventErrorBoundaryRetry = (options, errorResetBoundary) => {
|
|
29
|
+
if (options.suspense || options.useErrorBoundary) {
|
|
30
|
+
// Prevent retrying failed query if the error boundary has not been reset yet
|
|
31
|
+
if (!errorResetBoundary.isReset()) {
|
|
32
|
+
options.retryOnMount = false;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const useClearResetErrorBoundary = errorResetBoundary => {
|
|
37
|
+
React__namespace.useEffect(() => {
|
|
38
|
+
errorResetBoundary.clearReset();
|
|
39
|
+
}, [errorResetBoundary]);
|
|
40
|
+
};
|
|
41
|
+
const getHasError = ({
|
|
42
|
+
result,
|
|
43
|
+
errorResetBoundary,
|
|
44
|
+
useErrorBoundary,
|
|
45
|
+
query
|
|
46
|
+
}) => {
|
|
47
|
+
return result.isError && !errorResetBoundary.isReset() && !result.isFetching && utils.shouldThrowError(useErrorBoundary, [result.error, query]);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
exports.ensurePreventErrorBoundaryRetry = ensurePreventErrorBoundaryRetry;
|
|
51
|
+
exports.getHasError = getHasError;
|
|
52
|
+
exports.useClearResetErrorBoundary = useClearResetErrorBoundary;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
|
|
7
|
+
function _interopNamespaceCompat(e) {
|
|
8
|
+
if (e && typeof e === 'object' && 'default' in e) return e;
|
|
9
|
+
var n = Object.create(null);
|
|
10
|
+
if (e) {
|
|
11
|
+
Object.keys(e).forEach(function (k) {
|
|
12
|
+
if (k !== 'default') {
|
|
13
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () { return e[k]; }
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
n.default = e;
|
|
22
|
+
return Object.freeze(n);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceCompat(React);
|
|
26
|
+
|
|
27
|
+
const IsRestoringContext = /*#__PURE__*/React__namespace.createContext(false);
|
|
28
|
+
const useIsRestoring = () => React__namespace.useContext(IsRestoringContext);
|
|
29
|
+
IsRestoringContext.Provider;
|
|
30
|
+
|
|
31
|
+
exports.useIsRestoring = useIsRestoring;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Ensures minimum staleTime and cacheTime values when suspense is enabled.
|
|
5
|
+
* Despite the name, this function guards both staleTime and cacheTime to prevent
|
|
6
|
+
* infinite re-render loops with synchronous queries.
|
|
7
|
+
*
|
|
8
|
+
* @deprecated in v5 - replaced by ensureSuspenseTimers
|
|
9
|
+
*/
|
|
10
|
+
const ensureStaleTime = defaultedOptions => {
|
|
11
|
+
if (defaultedOptions.suspense) {
|
|
12
|
+
// Always set stale time when using suspense to prevent
|
|
13
|
+
// fetching again when directly mounting after suspending
|
|
14
|
+
if (typeof defaultedOptions.staleTime !== 'number') {
|
|
15
|
+
defaultedOptions.staleTime = 1000;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (typeof defaultedOptions.cacheTime === 'number') {
|
|
19
|
+
defaultedOptions.cacheTime = Math.max(defaultedOptions.cacheTime, 1000);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const willFetch = (result, isRestoring) => result.isLoading && result.isFetching && !isRestoring;
|
|
24
|
+
const shouldSuspend = (defaultedOptions, result, isRestoring) => (defaultedOptions == null ? void 0 : defaultedOptions.suspense) && willFetch(result, isRestoring);
|
|
25
|
+
const fetchOptimistic = (defaultedOptions, observer, errorResetBoundary) => observer.fetchOptimistic(defaultedOptions).then(({
|
|
26
|
+
data
|
|
27
|
+
}) => {
|
|
28
|
+
defaultedOptions.onSuccess == null ? void 0 : defaultedOptions.onSuccess(data);
|
|
29
|
+
defaultedOptions.onSettled == null ? void 0 : defaultedOptions.onSettled(data, null);
|
|
30
|
+
}).catch(error => {
|
|
31
|
+
errorResetBoundary.clearReset();
|
|
32
|
+
defaultedOptions.onError == null ? void 0 : defaultedOptions.onError(error);
|
|
33
|
+
defaultedOptions.onSettled == null ? void 0 : defaultedOptions.onSettled(undefined, error);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
exports.ensureStaleTime = ensureStaleTime;
|
|
37
|
+
exports.fetchOptimistic = fetchOptimistic;
|
|
38
|
+
exports.shouldSuspend = shouldSuspend;
|
|
39
|
+
exports.willFetch = willFetch;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var useSyncExternalStore = require('./useSyncExternalStore.js');
|
|
7
|
+
var QueryErrorResetBoundary = require('./QueryErrorResetBoundary.js');
|
|
8
|
+
var QueryClientProvider = require('./QueryClientProvider.js');
|
|
9
|
+
var isRestoring = require('./isRestoring.js');
|
|
10
|
+
var errorBoundaryUtils = require('./errorBoundaryUtils.js');
|
|
11
|
+
var suspense = require('./suspense.js');
|
|
12
|
+
var notifyManager = require('../../../query-core/build/lib/notifyManager.js');
|
|
13
|
+
|
|
14
|
+
function _interopNamespaceCompat(e) {
|
|
15
|
+
if (e && typeof e === 'object' && 'default' in e) return e;
|
|
16
|
+
var n = Object.create(null);
|
|
17
|
+
if (e) {
|
|
18
|
+
Object.keys(e).forEach(function (k) {
|
|
19
|
+
if (k !== 'default') {
|
|
20
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
21
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () { return e[k]; }
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
n.default = e;
|
|
29
|
+
return Object.freeze(n);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceCompat(React);
|
|
33
|
+
|
|
34
|
+
function useBaseQuery(options, Observer) {
|
|
35
|
+
const queryClient = QueryClientProvider.useQueryClient({
|
|
36
|
+
context: options.context
|
|
37
|
+
});
|
|
38
|
+
const isRestoring$1 = isRestoring.useIsRestoring();
|
|
39
|
+
const errorResetBoundary = QueryErrorResetBoundary.useQueryErrorResetBoundary();
|
|
40
|
+
const defaultedOptions = queryClient.defaultQueryOptions(options); // Make sure results are optimistically set in fetching state before subscribing or updating options
|
|
41
|
+
|
|
42
|
+
defaultedOptions._optimisticResults = isRestoring$1 ? 'isRestoring' : 'optimistic'; // Include callbacks in batch renders
|
|
43
|
+
|
|
44
|
+
if (defaultedOptions.onError) {
|
|
45
|
+
defaultedOptions.onError = notifyManager.notifyManager.batchCalls(defaultedOptions.onError);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (defaultedOptions.onSuccess) {
|
|
49
|
+
defaultedOptions.onSuccess = notifyManager.notifyManager.batchCalls(defaultedOptions.onSuccess);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (defaultedOptions.onSettled) {
|
|
53
|
+
defaultedOptions.onSettled = notifyManager.notifyManager.batchCalls(defaultedOptions.onSettled);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
suspense.ensureStaleTime(defaultedOptions);
|
|
57
|
+
errorBoundaryUtils.ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary);
|
|
58
|
+
errorBoundaryUtils.useClearResetErrorBoundary(errorResetBoundary);
|
|
59
|
+
const [observer] = React__namespace.useState(() => new Observer(queryClient, defaultedOptions));
|
|
60
|
+
const result = observer.getOptimisticResult(defaultedOptions);
|
|
61
|
+
useSyncExternalStore.useSyncExternalStore(React__namespace.useCallback(onStoreChange => {
|
|
62
|
+
const unsubscribe = isRestoring$1 ? () => undefined : observer.subscribe(notifyManager.notifyManager.batchCalls(onStoreChange)); // Update result to make sure we did not miss any query updates
|
|
63
|
+
// between creating the observer and subscribing to it.
|
|
64
|
+
|
|
65
|
+
observer.updateResult();
|
|
66
|
+
return unsubscribe;
|
|
67
|
+
}, [observer, isRestoring$1]), () => observer.getCurrentResult(), () => observer.getCurrentResult());
|
|
68
|
+
React__namespace.useEffect(() => {
|
|
69
|
+
// Do not notify on updates because of changes in the options because
|
|
70
|
+
// these changes should already be reflected in the optimistic result.
|
|
71
|
+
observer.setOptions(defaultedOptions, {
|
|
72
|
+
listeners: false
|
|
73
|
+
});
|
|
74
|
+
}, [defaultedOptions, observer]); // Handle suspense
|
|
75
|
+
|
|
76
|
+
if (suspense.shouldSuspend(defaultedOptions, result, isRestoring$1)) {
|
|
77
|
+
throw suspense.fetchOptimistic(defaultedOptions, observer, errorResetBoundary);
|
|
78
|
+
} // Handle error boundary
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
if (errorBoundaryUtils.getHasError({
|
|
82
|
+
result,
|
|
83
|
+
errorResetBoundary,
|
|
84
|
+
useErrorBoundary: defaultedOptions.useErrorBoundary,
|
|
85
|
+
query: observer.getCurrentQuery()
|
|
86
|
+
})) {
|
|
87
|
+
throw result.error;
|
|
88
|
+
} // Handle result property usage tracking
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
return !defaultedOptions.notifyOnChangeProps ? observer.trackResult(result) : result;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
exports.useBaseQuery = useBaseQuery;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
var useBaseQuery = require('./useBaseQuery.js');
|
|
6
|
+
var utils = require('../../../query-core/build/lib/utils.js');
|
|
7
|
+
var queryObserver = require('../../../query-core/build/lib/queryObserver.js');
|
|
8
|
+
|
|
9
|
+
function useQuery(arg1, arg2, arg3) {
|
|
10
|
+
const parsedOptions = utils.parseQueryArgs(arg1, arg2);
|
|
11
|
+
return useBaseQuery.useBaseQuery(parsedOptions, queryObserver.QueryObserver);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
exports.useQuery = useQuery;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function shouldThrowError(_useErrorBoundary, params) {
|
|
4
|
+
// Allow useErrorBoundary function to override throwing behavior on a per-error basis
|
|
5
|
+
if (typeof _useErrorBoundary === 'function') {
|
|
6
|
+
return _useErrorBoundary(...params);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
return !!_useErrorBoundary;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
exports.shouldThrowError = shouldThrowError;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tslib = require('tslib');
|
|
4
|
+
var Subject = require('./Subject.js');
|
|
5
|
+
|
|
6
|
+
var BehaviorSubject = (function (_super) {
|
|
7
|
+
tslib.__extends(BehaviorSubject, _super);
|
|
8
|
+
function BehaviorSubject(_value) {
|
|
9
|
+
var _this = _super.call(this) || this;
|
|
10
|
+
_this._value = _value;
|
|
11
|
+
return _this;
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(BehaviorSubject.prototype, "value", {
|
|
14
|
+
get: function () {
|
|
15
|
+
return this.getValue();
|
|
16
|
+
},
|
|
17
|
+
enumerable: false,
|
|
18
|
+
configurable: true
|
|
19
|
+
});
|
|
20
|
+
BehaviorSubject.prototype._subscribe = function (subscriber) {
|
|
21
|
+
var subscription = _super.prototype._subscribe.call(this, subscriber);
|
|
22
|
+
!subscription.closed && subscriber.next(this._value);
|
|
23
|
+
return subscription;
|
|
24
|
+
};
|
|
25
|
+
BehaviorSubject.prototype.getValue = function () {
|
|
26
|
+
var _a = this, hasError = _a.hasError, thrownError = _a.thrownError, _value = _a._value;
|
|
27
|
+
if (hasError) {
|
|
28
|
+
throw thrownError;
|
|
29
|
+
}
|
|
30
|
+
this._throwIfClosed();
|
|
31
|
+
return _value;
|
|
32
|
+
};
|
|
33
|
+
BehaviorSubject.prototype.next = function (value) {
|
|
34
|
+
_super.prototype.next.call(this, (this._value = value));
|
|
35
|
+
};
|
|
36
|
+
return BehaviorSubject;
|
|
37
|
+
}(Subject.Subject));
|
|
38
|
+
|
|
39
|
+
exports.BehaviorSubject = BehaviorSubject;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var Subscriber = require('./Subscriber.js');
|
|
4
|
+
var Subscription = require('./Subscription.js');
|
|
5
|
+
var observable = require('./symbol/observable.js');
|
|
6
|
+
var pipe = require('./util/pipe.js');
|
|
7
|
+
var config = require('./config.js');
|
|
8
|
+
var isFunction = require('./util/isFunction.js');
|
|
9
|
+
var errorContext = require('./util/errorContext.js');
|
|
10
|
+
|
|
11
|
+
var Observable = (function () {
|
|
12
|
+
function Observable(subscribe) {
|
|
13
|
+
if (subscribe) {
|
|
14
|
+
this._subscribe = subscribe;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
Observable.prototype.lift = function (operator) {
|
|
18
|
+
var observable = new Observable();
|
|
19
|
+
observable.source = this;
|
|
20
|
+
observable.operator = operator;
|
|
21
|
+
return observable;
|
|
22
|
+
};
|
|
23
|
+
Observable.prototype.subscribe = function (observerOrNext, error, complete) {
|
|
24
|
+
var _this = this;
|
|
25
|
+
var subscriber = isSubscriber(observerOrNext) ? observerOrNext : new Subscriber.SafeSubscriber(observerOrNext, error, complete);
|
|
26
|
+
errorContext.errorContext(function () {
|
|
27
|
+
var _a = _this, operator = _a.operator, source = _a.source;
|
|
28
|
+
subscriber.add(operator
|
|
29
|
+
?
|
|
30
|
+
operator.call(subscriber, source)
|
|
31
|
+
: source
|
|
32
|
+
?
|
|
33
|
+
_this._subscribe(subscriber)
|
|
34
|
+
:
|
|
35
|
+
_this._trySubscribe(subscriber));
|
|
36
|
+
});
|
|
37
|
+
return subscriber;
|
|
38
|
+
};
|
|
39
|
+
Observable.prototype._trySubscribe = function (sink) {
|
|
40
|
+
try {
|
|
41
|
+
return this._subscribe(sink);
|
|
42
|
+
}
|
|
43
|
+
catch (err) {
|
|
44
|
+
sink.error(err);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
Observable.prototype.forEach = function (next, promiseCtor) {
|
|
48
|
+
var _this = this;
|
|
49
|
+
promiseCtor = getPromiseCtor(promiseCtor);
|
|
50
|
+
return new promiseCtor(function (resolve, reject) {
|
|
51
|
+
var subscriber = new Subscriber.SafeSubscriber({
|
|
52
|
+
next: function (value) {
|
|
53
|
+
try {
|
|
54
|
+
next(value);
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
reject(err);
|
|
58
|
+
subscriber.unsubscribe();
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
error: reject,
|
|
62
|
+
complete: resolve,
|
|
63
|
+
});
|
|
64
|
+
_this.subscribe(subscriber);
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
Observable.prototype._subscribe = function (subscriber) {
|
|
68
|
+
var _a;
|
|
69
|
+
return (_a = this.source) === null || _a === void 0 ? void 0 : _a.subscribe(subscriber);
|
|
70
|
+
};
|
|
71
|
+
Observable.prototype[observable.observable] = function () {
|
|
72
|
+
return this;
|
|
73
|
+
};
|
|
74
|
+
Observable.prototype.pipe = function () {
|
|
75
|
+
var operations = [];
|
|
76
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
77
|
+
operations[_i] = arguments[_i];
|
|
78
|
+
}
|
|
79
|
+
return pipe.pipeFromArray(operations)(this);
|
|
80
|
+
};
|
|
81
|
+
Observable.prototype.toPromise = function (promiseCtor) {
|
|
82
|
+
var _this = this;
|
|
83
|
+
promiseCtor = getPromiseCtor(promiseCtor);
|
|
84
|
+
return new promiseCtor(function (resolve, reject) {
|
|
85
|
+
var value;
|
|
86
|
+
_this.subscribe(function (x) { return (value = x); }, function (err) { return reject(err); }, function () { return resolve(value); });
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
Observable.create = function (subscribe) {
|
|
90
|
+
return new Observable(subscribe);
|
|
91
|
+
};
|
|
92
|
+
return Observable;
|
|
93
|
+
}());
|
|
94
|
+
function getPromiseCtor(promiseCtor) {
|
|
95
|
+
var _a;
|
|
96
|
+
return (_a = promiseCtor !== null && promiseCtor !== void 0 ? promiseCtor : config.config.Promise) !== null && _a !== void 0 ? _a : Promise;
|
|
97
|
+
}
|
|
98
|
+
function isObserver(value) {
|
|
99
|
+
return value && isFunction.isFunction(value.next) && isFunction.isFunction(value.error) && isFunction.isFunction(value.complete);
|
|
100
|
+
}
|
|
101
|
+
function isSubscriber(value) {
|
|
102
|
+
return (value && value instanceof Subscriber.Subscriber) || (isObserver(value) && Subscription.isSubscription(value));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
exports.Observable = Observable;
|