@sanity/sdk-react 0.0.0-alpha.16 → 0.0.0-alpha.17
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/dist/_chunks-es/context.js +9 -1
- package/dist/_chunks-es/context.js.map +1 -1
- package/dist/_chunks-es/useLogOut.js +27 -14
- package/dist/_chunks-es/useLogOut.js.map +1 -1
- package/dist/components.js +169 -93
- package/dist/components.js.map +1 -1
- package/dist/hooks.d.ts +83 -60
- package/dist/hooks.js +449 -290
- package/dist/hooks.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +7 -4
- package/src/_exports/hooks.ts +1 -1
- package/src/components/SanityApp.tsx +3 -16
- package/src/hooks/document/useApplyActions.test.ts +5 -4
- package/src/hooks/document/useApplyActions.ts +10 -4
- package/src/hooks/document/useEditDocument.ts +29 -32
- package/src/hooks/helpers/createCallbackHook.tsx +3 -2
- package/src/hooks/helpers/createStateSourceHook.tsx +2 -6
- package/src/hooks/infiniteList/useInfiniteList.test.tsx +10 -10
- package/src/hooks/infiniteList/useInfiniteList.ts +39 -28
- package/src/hooks/paginatedList/usePaginatedList.ts +25 -13
- package/src/hooks/projection/useProjection.ts +3 -3
- package/src/hooks/query/useQuery.ts +25 -34
package/dist/hooks.js
CHANGED
|
@@ -1,87 +1,121 @@
|
|
|
1
1
|
import { createStateSourceHook, useSanityInstance, createCallbackHook } from "./_chunks-es/useLogOut.js";
|
|
2
2
|
import { useAuthState, useHandleCallback, useLogOut, useLoginUrls } from "./_chunks-es/useLogOut.js";
|
|
3
3
|
import { getTokenState, getCurrentUserState, getClientState, getOrCreateController, getOrCreateChannel, releaseChannel, getOrCreateNode, releaseNode, resolveDatasets, getDatasetsState, applyActions, getResourceId, resolveDocument, getDocumentState, subscribeDocumentEvents, getDocumentSyncStatus, editDocument, getPermissionsState, getQueryKey, parseQueryKey, getQueryState, resolveQuery, getPreviewState, resolvePreview, getProjectionState, resolveProjection, resolveProject, getProjectState, resolveProjects, getProjectsState, createUsersStore } from "@sanity/sdk";
|
|
4
|
-
import {
|
|
4
|
+
import { c } from "react/compiler-runtime";
|
|
5
|
+
import { useState, useEffect, useRef, useInsertionEffect, useSyncExternalStore, useTransition, useMemo } from "react";
|
|
5
6
|
import { firstValueFrom, filter, Observable, startWith, distinctUntilChanged, switchMap, EMPTY } from "rxjs";
|
|
6
7
|
const useAuthToken = createStateSourceHook(getTokenState), useCurrentUser = createStateSourceHook(getCurrentUserState), useClient = createStateSourceHook({
|
|
7
8
|
getState: getClientState,
|
|
8
9
|
getResourceId: (e) => e.resourceId
|
|
9
10
|
});
|
|
10
11
|
function useFrameConnection(options) {
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
12
|
+
const $ = c(27), {
|
|
13
|
+
onMessage,
|
|
14
|
+
targetOrigin,
|
|
15
|
+
name,
|
|
16
|
+
connectTo,
|
|
17
|
+
heartbeat
|
|
18
|
+
} = options, instance = useSanityInstance(), [status, setStatus] = useState("idle");
|
|
19
|
+
let t0, t1;
|
|
20
|
+
$[0] !== instance || $[1] !== targetOrigin ? (t1 = getOrCreateController(instance, targetOrigin), $[0] = instance, $[1] = targetOrigin, $[2] = t1) : t1 = $[2], t0 = t1;
|
|
21
|
+
const controller = t0;
|
|
22
|
+
let t2, t3;
|
|
23
|
+
$[3] !== connectTo || $[4] !== heartbeat || $[5] !== instance || $[6] !== name ? (t3 = getOrCreateChannel(instance, {
|
|
24
|
+
name,
|
|
25
|
+
connectTo,
|
|
26
|
+
heartbeat
|
|
27
|
+
}), $[3] = connectTo, $[4] = heartbeat, $[5] = instance, $[6] = name, $[7] = t3) : t3 = $[7], t2 = t3;
|
|
28
|
+
const channel = t2;
|
|
29
|
+
let t4, t5;
|
|
30
|
+
$[8] !== channel ? (t4 = () => channel ? channel.onStatus((event) => {
|
|
23
31
|
setStatus(event.status);
|
|
24
|
-
}) : void 0, [channel]), useEffect(
|
|
25
|
-
|
|
32
|
+
}) : void 0, t5 = [channel], $[8] = channel, $[9] = t4, $[10] = t5) : (t4 = $[9], t5 = $[10]), useEffect(t4, t5);
|
|
33
|
+
let t6, t7;
|
|
34
|
+
$[11] !== channel || $[12] !== onMessage ? (t6 = () => {
|
|
35
|
+
if (!channel || !onMessage)
|
|
36
|
+
return;
|
|
26
37
|
const unsubscribers = [];
|
|
27
|
-
return Object.entries(onMessage).forEach((
|
|
28
|
-
const
|
|
29
|
-
unsubscribers.push(
|
|
38
|
+
return Object.entries(onMessage).forEach((t82) => {
|
|
39
|
+
const [type, handler] = t82, unsubscribe_0 = channel.on(type, handler);
|
|
40
|
+
unsubscribers.push(unsubscribe_0);
|
|
30
41
|
}), () => {
|
|
31
|
-
unsubscribers.forEach(
|
|
42
|
+
unsubscribers.forEach(_temp$5);
|
|
32
43
|
};
|
|
33
|
-
}, [channel, onMessage]);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
}, t7 = [channel, onMessage], $[11] = channel, $[12] = onMessage, $[13] = t6, $[14] = t7) : (t6 = $[13], t7 = $[14]), useEffect(t6, t7);
|
|
45
|
+
let t8;
|
|
46
|
+
$[15] !== controller ? (t8 = (frameWindow) => {
|
|
47
|
+
const removeTarget = controller?.addTarget(frameWindow);
|
|
48
|
+
return () => {
|
|
49
|
+
removeTarget?.();
|
|
50
|
+
};
|
|
51
|
+
}, $[15] = controller, $[16] = t8) : t8 = $[16];
|
|
52
|
+
const connect = t8;
|
|
53
|
+
let t9;
|
|
54
|
+
$[17] !== channel ? (t9 = (type_0, data) => {
|
|
55
|
+
channel?.post(type_0, data);
|
|
56
|
+
}, $[17] = channel, $[18] = t9) : t9 = $[18];
|
|
57
|
+
const sendMessage = t9;
|
|
58
|
+
let t10, t11;
|
|
59
|
+
$[19] !== instance || $[20] !== name ? (t10 = () => () => {
|
|
49
60
|
releaseChannel(instance, name);
|
|
50
|
-
}, [name, instance]),
|
|
61
|
+
}, t11 = [name, instance], $[19] = instance, $[20] = name, $[21] = t10, $[22] = t11) : (t10 = $[21], t11 = $[22]), useEffect(t10, t11);
|
|
62
|
+
let t12;
|
|
63
|
+
return $[23] !== connect || $[24] !== sendMessage || $[25] !== status ? (t12 = {
|
|
51
64
|
connect,
|
|
52
65
|
sendMessage,
|
|
53
66
|
status
|
|
54
|
-
};
|
|
67
|
+
}, $[23] = connect, $[24] = sendMessage, $[25] = status, $[26] = t12) : t12 = $[26], t12;
|
|
68
|
+
}
|
|
69
|
+
function _temp$5(unsub) {
|
|
70
|
+
return unsub();
|
|
55
71
|
}
|
|
56
72
|
function useWindowConnection(options) {
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
73
|
+
const $ = c(23), {
|
|
74
|
+
name,
|
|
75
|
+
onMessage,
|
|
76
|
+
connectTo
|
|
77
|
+
} = options, instance = useSanityInstance(), [status, setStatus] = useState("idle");
|
|
78
|
+
let t0, t1;
|
|
79
|
+
$[0] !== connectTo || $[1] !== instance || $[2] !== name ? (t1 = getOrCreateNode(instance, {
|
|
80
|
+
name,
|
|
81
|
+
connectTo
|
|
82
|
+
}), $[0] = connectTo, $[1] = instance, $[2] = name, $[3] = t1) : t1 = $[3], t0 = t1;
|
|
83
|
+
const node = t0;
|
|
84
|
+
let t2;
|
|
85
|
+
$[4] !== node ? (t2 = () => node.onStatus((newStatus) => {
|
|
62
86
|
setStatus(newStatus);
|
|
63
|
-
}), [node,
|
|
64
|
-
|
|
87
|
+
}), $[4] = node, $[5] = t2) : t2 = $[5];
|
|
88
|
+
let t3;
|
|
89
|
+
$[6] !== instance || $[7] !== name || $[8] !== node ? (t3 = [node, instance, name], $[6] = instance, $[7] = name, $[8] = node, $[9] = t3) : t3 = $[9], useEffect(t2, t3);
|
|
90
|
+
let t4, t5;
|
|
91
|
+
$[10] !== node || $[11] !== onMessage ? (t4 = () => {
|
|
92
|
+
if (!onMessage)
|
|
93
|
+
return;
|
|
65
94
|
const unsubscribers = [];
|
|
66
|
-
return Object.entries(onMessage).forEach((
|
|
67
|
-
const
|
|
68
|
-
unsubscribers.push(
|
|
95
|
+
return Object.entries(onMessage).forEach((t62) => {
|
|
96
|
+
const [type, handler] = t62, unsubscribe_0 = node.on(type, handler);
|
|
97
|
+
unsubscribers.push(unsubscribe_0);
|
|
69
98
|
}), () => {
|
|
70
|
-
unsubscribers.forEach(
|
|
99
|
+
unsubscribers.forEach(_temp$4);
|
|
71
100
|
};
|
|
72
|
-
}, [node, onMessage]);
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
101
|
+
}, t5 = [node, onMessage], $[10] = node, $[11] = onMessage, $[12] = t4, $[13] = t5) : (t4 = $[12], t5 = $[13]), useEffect(t4, t5);
|
|
102
|
+
let t6;
|
|
103
|
+
$[14] !== node ? (t6 = (type_0, data) => {
|
|
104
|
+
node?.post(type_0, data);
|
|
105
|
+
}, $[14] = node, $[15] = t6) : t6 = $[15];
|
|
106
|
+
const sendMessage = t6;
|
|
107
|
+
let t7, t8;
|
|
108
|
+
$[16] !== instance || $[17] !== name ? (t7 = () => () => {
|
|
80
109
|
releaseNode(instance, name);
|
|
81
|
-
}, [instance, name]),
|
|
110
|
+
}, t8 = [instance, name], $[16] = instance, $[17] = name, $[18] = t7, $[19] = t8) : (t7 = $[18], t8 = $[19]), useEffect(t7, t8);
|
|
111
|
+
let t9;
|
|
112
|
+
return $[20] !== sendMessage || $[21] !== status ? (t9 = {
|
|
82
113
|
sendMessage,
|
|
83
114
|
status
|
|
84
|
-
};
|
|
115
|
+
}, $[20] = sendMessage, $[21] = status, $[22] = t9) : t9 = $[22], t9;
|
|
116
|
+
}
|
|
117
|
+
function _temp$4(unsub) {
|
|
118
|
+
return unsub();
|
|
85
119
|
}
|
|
86
120
|
const useDatasets = createStateSourceHook({
|
|
87
121
|
// remove `undefined` since we're suspending when that is the case
|
|
@@ -89,10 +123,10 @@ const useDatasets = createStateSourceHook({
|
|
|
89
123
|
shouldSuspend: (instance) => getDatasetsState(instance).getCurrent() === void 0,
|
|
90
124
|
suspender: resolveDatasets
|
|
91
125
|
});
|
|
92
|
-
function useApplyActions() {
|
|
93
|
-
return _useApplyActions();
|
|
126
|
+
function useApplyActions(resourceId) {
|
|
127
|
+
return _useApplyActions(resourceId)();
|
|
94
128
|
}
|
|
95
|
-
const _useApplyActions = createCallbackHook(applyActions);
|
|
129
|
+
const _useApplyActions = (resourceId) => createCallbackHook(applyActions, resourceId);
|
|
96
130
|
function useDocument(doc, path) {
|
|
97
131
|
return _useDocument(doc, path);
|
|
98
132
|
}
|
|
@@ -103,254 +137,365 @@ const _useDocument = createStateSourceHook({
|
|
|
103
137
|
getResourceId: (doc) => getResourceId(doc.resourceId)
|
|
104
138
|
});
|
|
105
139
|
function useDocumentEvent(handler, doc) {
|
|
106
|
-
const ref = useRef(handler);
|
|
107
|
-
|
|
140
|
+
const $ = c(8), ref = useRef(handler);
|
|
141
|
+
let t0;
|
|
142
|
+
$[0] !== handler ? (t0 = () => {
|
|
108
143
|
ref.current = handler;
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
|
|
144
|
+
}, $[0] = handler, $[1] = t0) : t0 = $[1], useInsertionEffect(t0);
|
|
145
|
+
let t1;
|
|
146
|
+
$[2] === Symbol.for("react.memo_cache_sentinel") ? (t1 = (documentEvent) => ref.current(documentEvent), $[2] = t1) : t1 = $[2];
|
|
147
|
+
const stableHandler = t1;
|
|
148
|
+
let t2;
|
|
149
|
+
$[3] !== doc.resourceId ? (t2 = getResourceId(doc.resourceId), $[3] = doc.resourceId, $[4] = t2) : t2 = $[4];
|
|
150
|
+
const instance = useSanityInstance(t2);
|
|
151
|
+
let t3, t4;
|
|
152
|
+
$[5] !== instance ? (t3 = () => subscribeDocumentEvents(instance, stableHandler), t4 = [instance, stableHandler], $[5] = instance, $[6] = t3, $[7] = t4) : (t3 = $[6], t4 = $[7]), useEffect(t3, t4);
|
|
112
153
|
}
|
|
113
154
|
const useDocumentSyncStatus = createStateSourceHook(getDocumentSyncStatus), ignoredKeys = ["_id", "_type", "_createdAt", "_updatedAt", "_rev"];
|
|
114
155
|
function useEditDocument(doc, path) {
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
156
|
+
const $ = c(8);
|
|
157
|
+
let t0;
|
|
158
|
+
$[0] !== doc.resourceId ? (t0 = getResourceId(doc.resourceId), $[0] = doc.resourceId, $[1] = t0) : t0 = $[1];
|
|
159
|
+
const resourceId = t0, documentId = doc._id, instance = useSanityInstance(resourceId), apply = useApplyActions(resourceId);
|
|
160
|
+
if (getDocumentState(instance, documentId).getCurrent() === void 0)
|
|
161
|
+
throw resolveDocument(instance, documentId);
|
|
162
|
+
let t1;
|
|
163
|
+
return $[2] !== apply || $[3] !== doc || $[4] !== documentId || $[5] !== instance || $[6] !== path ? (t1 = (updater) => {
|
|
164
|
+
if (path) {
|
|
165
|
+
const nextValue = typeof updater == "function" ? updater(getDocumentState(instance, documentId, path).getCurrent()) : updater;
|
|
166
|
+
return apply(editDocument(doc, {
|
|
167
|
+
set: {
|
|
168
|
+
[path]: nextValue
|
|
169
|
+
}
|
|
170
|
+
}));
|
|
171
|
+
}
|
|
172
|
+
const current = getDocumentState(instance, documentId).getCurrent(), nextValue_0 = typeof updater == "function" ? updater(current) : updater;
|
|
173
|
+
if (typeof nextValue_0 != "object" || !nextValue_0)
|
|
174
|
+
throw new Error("No path was provided to `useEditDocument` and the value provided was not a document object.");
|
|
175
|
+
const editActions = Object.keys({
|
|
176
|
+
...current,
|
|
177
|
+
...nextValue_0
|
|
178
|
+
}).filter(_temp$3).filter((key_0) => current?.[key_0] !== nextValue_0[key_0]).map((key_1) => key_1 in nextValue_0 ? editDocument(doc, {
|
|
179
|
+
set: {
|
|
180
|
+
[key_1]: nextValue_0[key_1]
|
|
125
181
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
return apply(editActions);
|
|
135
|
-
},
|
|
136
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
137
|
-
[apply, doc._id, instance, path]
|
|
138
|
-
);
|
|
182
|
+
}) : editDocument(doc, {
|
|
183
|
+
unset: [key_1]
|
|
184
|
+
}));
|
|
185
|
+
return apply(editActions);
|
|
186
|
+
}, $[2] = apply, $[3] = doc, $[4] = documentId, $[5] = instance, $[6] = path, $[7] = t1) : t1 = $[7], t1;
|
|
187
|
+
}
|
|
188
|
+
function _temp$3(key) {
|
|
189
|
+
return !ignoredKeys.includes(key);
|
|
139
190
|
}
|
|
140
191
|
function usePermissions(actions) {
|
|
192
|
+
const $ = c(5);
|
|
141
193
|
if (Array.isArray(actions)) {
|
|
142
|
-
const resourceIds = actions.map(
|
|
194
|
+
const resourceIds = actions.map(_temp$2);
|
|
143
195
|
if (new Set(resourceIds).size !== 1)
|
|
144
196
|
throw new Error("All actions must have the same resourceId");
|
|
145
197
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
() => getPermissionsState(instance, actions),
|
|
158
|
-
[actions, instance]
|
|
159
|
-
);
|
|
198
|
+
let t0;
|
|
199
|
+
$[0] !== actions ? (t0 = Array.isArray(actions) ? getResourceId(actions[0].resourceId) : getResourceId(actions.resourceId), $[0] = actions, $[1] = t0) : t0 = $[1];
|
|
200
|
+
const instance = useSanityInstance(t0);
|
|
201
|
+
if (getPermissionsState(instance, actions).getCurrent() === void 0)
|
|
202
|
+
throw firstValueFrom(getPermissionsState(instance, actions).observable.pipe(filter(_temp2$2)));
|
|
203
|
+
let t1, t2;
|
|
204
|
+
$[2] !== actions || $[3] !== instance ? (t2 = getPermissionsState(instance, actions), $[2] = actions, $[3] = instance, $[4] = t2) : t2 = $[4], t1 = t2;
|
|
205
|
+
const {
|
|
206
|
+
subscribe,
|
|
207
|
+
getCurrent
|
|
208
|
+
} = t1;
|
|
160
209
|
return useSyncExternalStore(subscribe, getCurrent);
|
|
161
210
|
}
|
|
211
|
+
function _temp2$2(result) {
|
|
212
|
+
return result !== void 0;
|
|
213
|
+
}
|
|
214
|
+
function _temp$2(action) {
|
|
215
|
+
return action.resourceId;
|
|
216
|
+
}
|
|
162
217
|
function useQuery(query, options) {
|
|
163
|
-
const instance = useSanityInstance(options?.resourceId), [isPending, startTransition] = useTransition(), queryKey = getQueryKey(query, options), [deferredQueryKey, setDeferredQueryKey] = useState(queryKey), deferred = useMemo(() => parseQueryKey(deferredQueryKey), [deferredQueryKey]), ref =
|
|
164
|
-
|
|
218
|
+
const instance = useSanityInstance(options?.resourceId), [isPending, startTransition] = useTransition(), queryKey = getQueryKey(query, options), [deferredQueryKey, setDeferredQueryKey] = useState(queryKey), deferred = useMemo(() => parseQueryKey(deferredQueryKey), [deferredQueryKey]), [ref, setRef] = useState(new AbortController());
|
|
219
|
+
useEffect(() => {
|
|
165
220
|
queryKey !== deferredQueryKey && startTransition(() => {
|
|
166
|
-
ref
|
|
221
|
+
ref && !ref.signal.aborted && (ref.abort(), setRef(new AbortController())), setDeferredQueryKey(queryKey);
|
|
167
222
|
});
|
|
168
|
-
}, [deferredQueryKey, queryKey]);
|
|
169
|
-
const {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
);
|
|
223
|
+
}, [deferredQueryKey, queryKey, ref]);
|
|
224
|
+
const {
|
|
225
|
+
getCurrent,
|
|
226
|
+
subscribe
|
|
227
|
+
} = useMemo(() => getQueryState(instance, deferred.query, deferred.options), [instance, deferred]);
|
|
173
228
|
if (getCurrent() === void 0)
|
|
174
|
-
throw resolveQuery(instance, deferred.query, {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
params,
|
|
181
|
-
search,
|
|
182
|
-
filter: filter2,
|
|
183
|
-
orderings,
|
|
184
|
-
...options
|
|
185
|
-
}) {
|
|
186
|
-
const perspective = options.perspective ?? DEFAULT_PERSPECTIVE$1, [limit, setLimit] = useState(pageSize), key = JSON.stringify({ filter: filter2, search, params, orderings, pageSize });
|
|
187
|
-
useEffect(() => {
|
|
188
|
-
setLimit(pageSize);
|
|
189
|
-
}, [key, pageSize]);
|
|
190
|
-
const filterClause = useMemo(() => {
|
|
191
|
-
const conditions = [];
|
|
192
|
-
return search?.trim() && conditions.push(`[@] match text::query("${search.trim()}")`), filter2 && conditions.push(`(${filter2})`), conditions.length ? `[${conditions.join(" && ")}]` : "";
|
|
193
|
-
}, [filter2, search]), orderClause = orderings ? `| order(${orderings.map(
|
|
194
|
-
(ordering) => [ordering.field, ordering.direction.toLowerCase()].map((str) => str.trim()).filter(Boolean).join(" ")
|
|
195
|
-
).join(",")})` : "", dataQuery = `*${filterClause}${orderClause}[0...${limit}]{_id,_type}`, countQuery = `count(*${filterClause})`, {
|
|
196
|
-
data: { count, data },
|
|
229
|
+
throw resolveQuery(instance, deferred.query, {
|
|
230
|
+
...deferred.options,
|
|
231
|
+
signal: ref.signal
|
|
232
|
+
});
|
|
233
|
+
return {
|
|
234
|
+
data: useSyncExternalStore(subscribe, getCurrent),
|
|
197
235
|
isPending
|
|
198
|
-
}
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
const DEFAULT_BATCH_SIZE = 25, DEFAULT_PERSPECTIVE$1 = "drafts";
|
|
239
|
+
function useInfiniteList(t0) {
|
|
240
|
+
const $ = c(31);
|
|
241
|
+
let filter2, options, orderings, params, search, t1;
|
|
242
|
+
$[0] !== t0 ? ({
|
|
243
|
+
batchSize: t1,
|
|
244
|
+
params,
|
|
245
|
+
search,
|
|
246
|
+
filter: filter2,
|
|
247
|
+
orderings,
|
|
248
|
+
...options
|
|
249
|
+
} = t0, $[0] = t0, $[1] = filter2, $[2] = options, $[3] = orderings, $[4] = params, $[5] = search, $[6] = t1) : (filter2 = $[1], options = $[2], orderings = $[3], params = $[4], search = $[5], t1 = $[6]);
|
|
250
|
+
const batchSize = t1 === void 0 ? DEFAULT_BATCH_SIZE : t1, perspective = options.perspective ?? DEFAULT_PERSPECTIVE$1, [limit, setLimit] = useState(batchSize);
|
|
251
|
+
let t2;
|
|
252
|
+
$[7] !== batchSize || $[8] !== filter2 || $[9] !== orderings || $[10] !== params || $[11] !== search ? (t2 = JSON.stringify({
|
|
253
|
+
filter: filter2,
|
|
254
|
+
search,
|
|
255
|
+
params,
|
|
256
|
+
orderings,
|
|
257
|
+
batchSize
|
|
258
|
+
}), $[7] = batchSize, $[8] = filter2, $[9] = orderings, $[10] = params, $[11] = search, $[12] = t2) : t2 = $[12];
|
|
259
|
+
const key = t2;
|
|
260
|
+
let t3;
|
|
261
|
+
$[13] !== batchSize ? (t3 = () => {
|
|
262
|
+
setLimit(batchSize);
|
|
263
|
+
}, $[13] = batchSize, $[14] = t3) : t3 = $[14];
|
|
264
|
+
let t4;
|
|
265
|
+
$[15] !== batchSize || $[16] !== key ? (t4 = [key, batchSize], $[15] = batchSize, $[16] = key, $[17] = t4) : t4 = $[17], useEffect(t3, t4);
|
|
266
|
+
let t5;
|
|
267
|
+
const conditions = [];
|
|
268
|
+
search?.trim() && conditions.push(`[@] match text::query("${search.trim()}")`), filter2 && conditions.push(`(${filter2})`), t5 = conditions.length ? `[${conditions.join(" && ")}]` : "";
|
|
269
|
+
const filterClause = t5, orderClause = orderings ? `| order(${orderings.map(_temp2$1).join(",")})` : "", dataQuery = `*${filterClause}${orderClause}[0...${limit}]{_id,_type}`, countQuery = `count(*${filterClause})`;
|
|
270
|
+
let t6;
|
|
271
|
+
$[18] !== options || $[19] !== params || $[20] !== perspective ? (t6 = {
|
|
199
272
|
...options,
|
|
200
273
|
params,
|
|
201
274
|
perspective
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
275
|
+
}, $[18] = options, $[19] = params, $[20] = perspective, $[21] = t6) : t6 = $[21];
|
|
276
|
+
const {
|
|
277
|
+
data: t7,
|
|
278
|
+
isPending
|
|
279
|
+
} = useQuery(`{"count":${countQuery},"data":${dataQuery}}`, t6), {
|
|
280
|
+
count,
|
|
281
|
+
data
|
|
282
|
+
} = t7, hasMore = data.length < count;
|
|
283
|
+
let t8;
|
|
284
|
+
$[22] !== batchSize || $[23] !== count ? (t8 = () => {
|
|
285
|
+
setLimit((prev) => Math.min(prev + batchSize, count));
|
|
286
|
+
}, $[22] = batchSize, $[23] = count, $[24] = t8) : t8 = $[24];
|
|
287
|
+
const loadMore = t8;
|
|
288
|
+
let t9, t10;
|
|
289
|
+
return $[25] !== count || $[26] !== data || $[27] !== hasMore || $[28] !== isPending || $[29] !== loadMore ? (t10 = {
|
|
290
|
+
data,
|
|
291
|
+
hasMore,
|
|
292
|
+
count,
|
|
293
|
+
isPending,
|
|
294
|
+
loadMore
|
|
295
|
+
}, $[25] = count, $[26] = data, $[27] = hasMore, $[28] = isPending, $[29] = loadMore, $[30] = t10) : t10 = $[30], t9 = t10, t9;
|
|
296
|
+
}
|
|
297
|
+
function _temp2$1(ordering) {
|
|
298
|
+
return [ordering.field, ordering.direction.toLowerCase()].map(_temp$1).filter(Boolean).join(" ");
|
|
299
|
+
}
|
|
300
|
+
function _temp$1(str) {
|
|
301
|
+
return str.trim();
|
|
209
302
|
}
|
|
210
303
|
const DEFAULT_PERSPECTIVE = "drafts";
|
|
211
|
-
function usePaginatedList({
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
orderings,
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
304
|
+
function usePaginatedList(t0) {
|
|
305
|
+
const $ = c(48);
|
|
306
|
+
let t1;
|
|
307
|
+
$[0] !== t0 ? (t1 = t0 === void 0 ? {} : t0, $[0] = t0, $[1] = t1) : t1 = $[1];
|
|
308
|
+
let options, orderings, search, t2, t3, t4;
|
|
309
|
+
$[2] !== t1 ? ({
|
|
310
|
+
filter: t2,
|
|
311
|
+
pageSize: t3,
|
|
312
|
+
params: t4,
|
|
313
|
+
orderings,
|
|
314
|
+
search,
|
|
315
|
+
...options
|
|
316
|
+
} = t1, $[2] = t1, $[3] = options, $[4] = orderings, $[5] = search, $[6] = t2, $[7] = t3, $[8] = t4) : (options = $[3], orderings = $[4], search = $[5], t2 = $[6], t3 = $[7], t4 = $[8]);
|
|
317
|
+
const filter2 = t2 === void 0 ? "" : t2, pageSize = t3 === void 0 ? 25 : t3;
|
|
318
|
+
let t5;
|
|
319
|
+
$[9] !== t4 ? (t5 = t4 === void 0 ? {} : t4, $[9] = t4, $[10] = t5) : t5 = $[10];
|
|
320
|
+
const params = t5, [pageIndex, setPageIndex] = useState(0);
|
|
321
|
+
let t6;
|
|
322
|
+
$[11] !== filter2 || $[12] !== orderings || $[13] !== pageSize || $[14] !== params || $[15] !== search ? (t6 = JSON.stringify({
|
|
323
|
+
filter: filter2,
|
|
324
|
+
search,
|
|
325
|
+
params,
|
|
326
|
+
orderings,
|
|
327
|
+
pageSize
|
|
328
|
+
}), $[11] = filter2, $[12] = orderings, $[13] = pageSize, $[14] = params, $[15] = search, $[16] = t6) : t6 = $[16];
|
|
329
|
+
const key = t6;
|
|
330
|
+
let t7;
|
|
331
|
+
$[17] === Symbol.for("react.memo_cache_sentinel") ? (t7 = () => {
|
|
221
332
|
setPageIndex(0);
|
|
222
|
-
}, [
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
).
|
|
229
|
-
|
|
333
|
+
}, $[17] = t7) : t7 = $[17];
|
|
334
|
+
let t8;
|
|
335
|
+
$[18] !== key ? (t8 = [key], $[18] = key, $[19] = t8) : t8 = $[19], useEffect(t7, t8);
|
|
336
|
+
const startIndex = pageIndex * pageSize, endIndex = (pageIndex + 1) * pageSize, perspective = options.perspective ?? DEFAULT_PERSPECTIVE;
|
|
337
|
+
let t9;
|
|
338
|
+
const conditions = [];
|
|
339
|
+
search?.trim() && conditions.push(`[@] match text::query("${search.trim()}")`), filter2 && conditions.push(`(${filter2})`), t9 = conditions.length ? `[${conditions.join(" && ")}]` : "";
|
|
340
|
+
const filterClause = t9, orderClause = orderings ? `| order(${orderings.map(_temp2).join(",")})` : "", dataQuery = `*${filterClause}${orderClause}[${startIndex}...${endIndex}]{_id,_type}`, countQuery = `count(*${filterClause})`;
|
|
341
|
+
let t10;
|
|
342
|
+
$[20] !== options || $[21] !== params || $[22] !== perspective ? (t10 = {
|
|
343
|
+
...options,
|
|
344
|
+
perspective,
|
|
345
|
+
params
|
|
346
|
+
}, $[20] = options, $[21] = params, $[22] = perspective, $[23] = t10) : t10 = $[23];
|
|
347
|
+
const {
|
|
348
|
+
data: t11,
|
|
230
349
|
isPending
|
|
231
|
-
} = useQuery(
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
totalPages,
|
|
273
|
-
startIndex,
|
|
274
|
-
endIndex,
|
|
275
|
-
count,
|
|
276
|
-
firstPage,
|
|
277
|
-
hasFirstPage,
|
|
278
|
-
previousPage,
|
|
279
|
-
hasPreviousPage,
|
|
280
|
-
nextPage,
|
|
281
|
-
hasNextPage,
|
|
282
|
-
lastPage,
|
|
283
|
-
hasLastPage,
|
|
284
|
-
goToPage
|
|
285
|
-
]
|
|
286
|
-
);
|
|
350
|
+
} = useQuery(`{"data":${dataQuery},"count":${countQuery}}`, t10), {
|
|
351
|
+
data,
|
|
352
|
+
count
|
|
353
|
+
} = t11, totalPages = Math.ceil(count / pageSize), currentPage = pageIndex + 1;
|
|
354
|
+
let t12;
|
|
355
|
+
$[24] === Symbol.for("react.memo_cache_sentinel") ? (t12 = () => setPageIndex(0), $[24] = t12) : t12 = $[24];
|
|
356
|
+
const firstPage = t12;
|
|
357
|
+
let t13;
|
|
358
|
+
$[25] === Symbol.for("react.memo_cache_sentinel") ? (t13 = () => setPageIndex(_temp3), $[25] = t13) : t13 = $[25];
|
|
359
|
+
const previousPage = t13;
|
|
360
|
+
let t14;
|
|
361
|
+
$[26] !== totalPages ? (t14 = () => setPageIndex((prev_0) => Math.min(prev_0 + 1, totalPages - 1)), $[26] = totalPages, $[27] = t14) : t14 = $[27];
|
|
362
|
+
const nextPage = t14;
|
|
363
|
+
let t15;
|
|
364
|
+
$[28] !== totalPages ? (t15 = () => setPageIndex(totalPages - 1), $[28] = totalPages, $[29] = t15) : t15 = $[29];
|
|
365
|
+
const lastPage = t15;
|
|
366
|
+
let t16;
|
|
367
|
+
$[30] !== totalPages ? (t16 = (pageNumber) => {
|
|
368
|
+
pageNumber < 1 || pageNumber > totalPages || setPageIndex(pageNumber - 1);
|
|
369
|
+
}, $[30] = totalPages, $[31] = t16) : t16 = $[31];
|
|
370
|
+
const goToPage = t16, hasFirstPage = pageIndex > 0, hasPreviousPage = pageIndex > 0, hasNextPage = pageIndex < totalPages - 1, hasLastPage = pageIndex < totalPages - 1;
|
|
371
|
+
let t17, t18;
|
|
372
|
+
return $[32] !== count || $[33] !== currentPage || $[34] !== data || $[35] !== endIndex || $[36] !== goToPage || $[37] !== hasFirstPage || $[38] !== hasLastPage || $[39] !== hasNextPage || $[40] !== hasPreviousPage || $[41] !== isPending || $[42] !== lastPage || $[43] !== nextPage || $[44] !== pageSize || $[45] !== startIndex || $[46] !== totalPages ? (t18 = {
|
|
373
|
+
data,
|
|
374
|
+
isPending,
|
|
375
|
+
pageSize,
|
|
376
|
+
currentPage,
|
|
377
|
+
totalPages,
|
|
378
|
+
startIndex,
|
|
379
|
+
endIndex,
|
|
380
|
+
count,
|
|
381
|
+
firstPage,
|
|
382
|
+
hasFirstPage,
|
|
383
|
+
previousPage,
|
|
384
|
+
hasPreviousPage,
|
|
385
|
+
nextPage,
|
|
386
|
+
hasNextPage,
|
|
387
|
+
lastPage,
|
|
388
|
+
hasLastPage,
|
|
389
|
+
goToPage
|
|
390
|
+
}, $[32] = count, $[33] = currentPage, $[34] = data, $[35] = endIndex, $[36] = goToPage, $[37] = hasFirstPage, $[38] = hasLastPage, $[39] = hasNextPage, $[40] = hasPreviousPage, $[41] = isPending, $[42] = lastPage, $[43] = nextPage, $[44] = pageSize, $[45] = startIndex, $[46] = totalPages, $[47] = t18) : t18 = $[47], t17 = t18, t17;
|
|
287
391
|
}
|
|
288
|
-
function
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
|
|
392
|
+
function _temp3(prev) {
|
|
393
|
+
return Math.max(prev - 1, 0);
|
|
394
|
+
}
|
|
395
|
+
function _temp2(ordering) {
|
|
396
|
+
return [ordering.field, ordering.direction.toLowerCase()].map(_temp).filter(Boolean).join(" ");
|
|
397
|
+
}
|
|
398
|
+
function _temp(str) {
|
|
399
|
+
return str.trim();
|
|
400
|
+
}
|
|
401
|
+
function usePreview(t0) {
|
|
402
|
+
const $ = c(12), {
|
|
403
|
+
document: t1,
|
|
404
|
+
ref
|
|
405
|
+
} = t0, {
|
|
406
|
+
_id,
|
|
407
|
+
_type
|
|
408
|
+
} = t1, instance = useSanityInstance();
|
|
409
|
+
let t2, t3;
|
|
410
|
+
$[0] !== _id || $[1] !== _type || $[2] !== instance ? (t3 = getPreviewState(instance, {
|
|
411
|
+
document: {
|
|
412
|
+
_id,
|
|
413
|
+
_type
|
|
414
|
+
}
|
|
415
|
+
}), $[0] = _id, $[1] = _type, $[2] = instance, $[3] = t3) : t3 = $[3], t2 = t3;
|
|
416
|
+
const stateSource = t2;
|
|
417
|
+
let t4;
|
|
418
|
+
$[4] !== ref || $[5] !== stateSource ? (t4 = (onStoreChanged) => {
|
|
419
|
+
const subscription = new Observable((observer) => {
|
|
420
|
+
if (typeof IntersectionObserver > "u" || typeof HTMLElement > "u")
|
|
421
|
+
return;
|
|
422
|
+
const intersectionObserver = new IntersectionObserver((t52) => {
|
|
423
|
+
const [entry] = t52;
|
|
424
|
+
return observer.next(entry.isIntersecting);
|
|
425
|
+
}, {
|
|
426
|
+
rootMargin: "0px",
|
|
427
|
+
threshold: 0
|
|
428
|
+
});
|
|
429
|
+
return ref?.current && ref.current instanceof HTMLElement && intersectionObserver.observe(ref.current), () => intersectionObserver.disconnect();
|
|
430
|
+
}).pipe(startWith(!1), distinctUntilChanged(), switchMap((isVisible) => isVisible ? new Observable((obs) => stateSource.subscribe(() => obs.next())) : EMPTY)).subscribe({
|
|
431
|
+
next: onStoreChanged
|
|
432
|
+
});
|
|
433
|
+
return () => subscription.unsubscribe();
|
|
434
|
+
}, $[4] = ref, $[5] = stateSource, $[6] = t4) : t4 = $[6];
|
|
435
|
+
const subscribe = t4;
|
|
436
|
+
let t5;
|
|
437
|
+
return $[7] !== _id || $[8] !== _type || $[9] !== instance || $[10] !== stateSource ? (t5 = () => {
|
|
313
438
|
const currentState = stateSource.getCurrent();
|
|
314
|
-
if (currentState.results === null)
|
|
439
|
+
if (currentState.results === null)
|
|
440
|
+
throw resolvePreview(instance, {
|
|
441
|
+
document: {
|
|
442
|
+
_id,
|
|
443
|
+
_type
|
|
444
|
+
}
|
|
445
|
+
});
|
|
315
446
|
return currentState;
|
|
316
|
-
}, [_id, _type, instance, stateSource]);
|
|
317
|
-
return useSyncExternalStore(subscribe, getSnapshot);
|
|
447
|
+
}, $[7] = _id, $[8] = _type, $[9] = instance, $[10] = stateSource, $[11] = t5) : t5 = $[11], useSyncExternalStore(subscribe, t5);
|
|
318
448
|
}
|
|
319
|
-
function useProjection({
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
([entry]) => observer.next(entry.isIntersecting),
|
|
334
|
-
{ rootMargin: "0px", threshold: 0 }
|
|
335
|
-
);
|
|
336
|
-
return ref?.current && ref.current instanceof HTMLElement && intersectionObserver.observe(ref.current), () => intersectionObserver.disconnect();
|
|
337
|
-
}).pipe(
|
|
338
|
-
startWith(!1),
|
|
339
|
-
distinctUntilChanged(),
|
|
340
|
-
switchMap(
|
|
341
|
-
(isVisible) => isVisible ? new Observable((obs) => stateSource.subscribe(() => obs.next())) : EMPTY
|
|
342
|
-
)
|
|
343
|
-
).subscribe({ next: onStoreChanged });
|
|
344
|
-
return () => subscription.unsubscribe();
|
|
449
|
+
function useProjection(t0) {
|
|
450
|
+
const $ = c(14), {
|
|
451
|
+
document: t1,
|
|
452
|
+
projection,
|
|
453
|
+
ref
|
|
454
|
+
} = t0, {
|
|
455
|
+
_id,
|
|
456
|
+
_type
|
|
457
|
+
} = t1, instance = useSanityInstance();
|
|
458
|
+
let t2, t3;
|
|
459
|
+
$[0] !== _id || $[1] !== _type || $[2] !== instance || $[3] !== projection ? (t3 = getProjectionState(instance, {
|
|
460
|
+
document: {
|
|
461
|
+
_id,
|
|
462
|
+
_type
|
|
345
463
|
},
|
|
346
|
-
|
|
347
|
-
),
|
|
464
|
+
projection
|
|
465
|
+
}), $[0] = _id, $[1] = _type, $[2] = instance, $[3] = projection, $[4] = t3) : t3 = $[4], t2 = t3;
|
|
466
|
+
const stateSource = t2;
|
|
467
|
+
let t4;
|
|
468
|
+
$[5] !== ref || $[6] !== stateSource ? (t4 = (onStoreChanged) => {
|
|
469
|
+
const subscription = new Observable((observer) => {
|
|
470
|
+
if (typeof IntersectionObserver > "u" || typeof HTMLElement > "u")
|
|
471
|
+
return;
|
|
472
|
+
const intersectionObserver = new IntersectionObserver((t52) => {
|
|
473
|
+
const [entry] = t52;
|
|
474
|
+
return observer.next(entry.isIntersecting);
|
|
475
|
+
}, {
|
|
476
|
+
rootMargin: "0px",
|
|
477
|
+
threshold: 0
|
|
478
|
+
});
|
|
479
|
+
return ref?.current && ref.current instanceof HTMLElement && intersectionObserver.observe(ref.current), () => intersectionObserver.disconnect();
|
|
480
|
+
}).pipe(startWith(!1), distinctUntilChanged(), switchMap((isVisible) => isVisible ? new Observable((obs) => stateSource.subscribe(() => obs.next())) : EMPTY)).subscribe({
|
|
481
|
+
next: onStoreChanged
|
|
482
|
+
});
|
|
483
|
+
return () => subscription.unsubscribe();
|
|
484
|
+
}, $[5] = ref, $[6] = stateSource, $[7] = t4) : t4 = $[7];
|
|
485
|
+
const subscribe = t4;
|
|
486
|
+
let t5;
|
|
487
|
+
return $[8] !== _id || $[9] !== _type || $[10] !== instance || $[11] !== projection || $[12] !== stateSource ? (t5 = () => {
|
|
348
488
|
const currentState = stateSource.getCurrent();
|
|
349
489
|
if (currentState.results === null)
|
|
350
|
-
throw resolveProjection(instance, {
|
|
490
|
+
throw resolveProjection(instance, {
|
|
491
|
+
document: {
|
|
492
|
+
_id,
|
|
493
|
+
_type
|
|
494
|
+
},
|
|
495
|
+
projection
|
|
496
|
+
});
|
|
351
497
|
return currentState;
|
|
352
|
-
}, [_id, _type, projection,
|
|
353
|
-
return useSyncExternalStore(subscribe, getSnapshot);
|
|
498
|
+
}, $[8] = _id, $[9] = _type, $[10] = instance, $[11] = projection, $[12] = stateSource, $[13] = t5) : t5 = $[13], useSyncExternalStore(subscribe, t5);
|
|
354
499
|
}
|
|
355
500
|
const useProject = createStateSourceHook({
|
|
356
501
|
// remove `undefined` since we're suspending when that is the case
|
|
@@ -364,24 +509,38 @@ const useProject = createStateSourceHook({
|
|
|
364
509
|
suspender: resolveProjects
|
|
365
510
|
});
|
|
366
511
|
function useUsers(params) {
|
|
367
|
-
const
|
|
368
|
-
|
|
512
|
+
const $ = c(15), instance = useSanityInstance(params.resourceId);
|
|
513
|
+
let t0;
|
|
514
|
+
$[0] !== instance ? (t0 = () => createUsersStore(instance), $[0] = instance, $[1] = t0) : t0 = $[1];
|
|
515
|
+
const [store] = useState(t0);
|
|
516
|
+
let t1, t2;
|
|
517
|
+
$[2] !== params.resourceId || $[3] !== params.resourceType || $[4] !== store ? (t1 = () => {
|
|
369
518
|
store.setOptions({
|
|
370
519
|
resourceType: params.resourceType,
|
|
371
520
|
resourceId: params.resourceId
|
|
372
521
|
});
|
|
373
|
-
}, [params.resourceType, params.resourceId, store]);
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
522
|
+
}, t2 = [params.resourceType, params.resourceId, store], $[2] = params.resourceId, $[3] = params.resourceType, $[4] = store, $[5] = t1, $[6] = t2) : (t1 = $[5], t2 = $[6]), useEffect(t1, t2);
|
|
523
|
+
let t3;
|
|
524
|
+
$[7] !== store ? (t3 = (onStoreChanged) => {
|
|
525
|
+
store.getState().getCurrent().initialFetchCompleted === !1 && store.resolveUsers();
|
|
526
|
+
const unsubscribe = store.getState().subscribe(onStoreChanged);
|
|
527
|
+
return () => {
|
|
528
|
+
unsubscribe(), store.dispose();
|
|
529
|
+
};
|
|
530
|
+
}, $[7] = store, $[8] = t3) : t3 = $[8];
|
|
531
|
+
const subscribe = t3;
|
|
532
|
+
let t4;
|
|
533
|
+
$[9] !== store ? (t4 = () => store.getState().getCurrent(), $[9] = store, $[10] = t4) : t4 = $[10];
|
|
534
|
+
const getSnapshot = t4, {
|
|
535
|
+
users,
|
|
536
|
+
hasMore
|
|
537
|
+
} = useSyncExternalStore(subscribe, getSnapshot) || {};
|
|
538
|
+
let t5;
|
|
539
|
+
return $[11] !== hasMore || $[12] !== store.loadMore || $[13] !== users ? (t5 = {
|
|
540
|
+
users,
|
|
541
|
+
hasMore,
|
|
542
|
+
loadMore: store.loadMore
|
|
543
|
+
}, $[11] = hasMore, $[12] = store.loadMore, $[13] = users, $[14] = t5) : t5 = $[14], t5;
|
|
385
544
|
}
|
|
386
545
|
export {
|
|
387
546
|
useApplyActions,
|