@sanity/sdk-react 2.0.0 → 2.0.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/README.md +1 -1
- package/dist/index.d.ts +9 -0
- package/dist/index.js +132 -78
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/_exports/sdk-react.ts +1 -0
- package/src/components/auth/AuthBoundary.test.tsx +30 -19
- package/src/components/auth/AuthBoundary.tsx +6 -3
- package/src/components/auth/LoginError.tsx +13 -5
- package/src/context/ComlinkTokenRefresh.test.tsx +221 -0
- package/src/context/ComlinkTokenRefresh.tsx +125 -0
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<p align="center">
|
|
2
2
|
<a href="https://sanity.io">
|
|
3
|
-
<img src="https://cdn.sanity.io/images/3do82whm/next/
|
|
3
|
+
<img src="https://cdn.sanity.io/images/3do82whm/next/d6cf401d52c33b7a5a354a14ab7de94dea2f0c02-192x192.svg" />
|
|
4
4
|
</a>
|
|
5
5
|
<h1 align="center">Sanity App SDK (React)</h1>
|
|
6
6
|
</p>
|
package/dist/index.d.ts
CHANGED
|
@@ -21,7 +21,9 @@ import {PathChangeMessage} from '@sanity/message-protocol'
|
|
|
21
21
|
import {PerspectiveHandle} from '@sanity/sdk'
|
|
22
22
|
import {PreviewValue} from '@sanity/sdk'
|
|
23
23
|
import {ProjectHandle} from '@sanity/sdk'
|
|
24
|
+
import {PropsWithChildren} from 'react'
|
|
24
25
|
import {QueryOptions} from '@sanity/sdk'
|
|
26
|
+
import {default as React_2} from 'react'
|
|
25
27
|
import {ReactElement} from 'react'
|
|
26
28
|
import {ReactNode} from 'react'
|
|
27
29
|
import {ReleaseDocument} from '@sanity/sdk'
|
|
@@ -118,6 +120,13 @@ export declare interface AuthBoundaryProps {
|
|
|
118
120
|
*/
|
|
119
121
|
export declare type ComlinkStatus = 'idle' | 'handshaking' | 'connected' | 'disconnected'
|
|
120
122
|
|
|
123
|
+
/**
|
|
124
|
+
* This provider is used to provide the Comlink token refresh feature.
|
|
125
|
+
* It is used to automatically request a new token on 401 error if enabled.
|
|
126
|
+
* @public
|
|
127
|
+
*/
|
|
128
|
+
export declare const ComlinkTokenRefreshProvider: React_2.FC<PropsWithChildren>
|
|
129
|
+
|
|
121
130
|
declare interface DashboardResource {
|
|
122
131
|
id: string
|
|
123
132
|
name: string
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { c } from "react-compiler-runtime";
|
|
3
|
-
import { getAuthState, getLoginUrlState, observeOrganizationVerificationState, handleAuthCallback, logout,
|
|
3
|
+
import { getAuthState, getNodeState, getIsInDashboardState, setAuthToken, AuthStateType, getLoginUrlState, observeOrganizationVerificationState, handleAuthCallback, logout, createSanityInstance, getTokenState, getCurrentUserState, getDashboardOrganizationId, getClientState, getOrCreateController, getOrCreateChannel, releaseChannel, getFavoritesState, resolveFavoritesState, resolveDatasets, getDatasetsState, applyDocumentActions, resolveDocument, getDocumentState, subscribeDocumentEvents, getPermissionsState, getDocumentSyncStatus, editDocument, getQueryKey, parseQueryKey, getQueryState, resolveQuery, createGroqSearchFilter, getPreviewState, resolvePreview, getProjectionState, resolveProjection, resolveProject, getProjectState, resolveProjects, getProjectsState, getActiveReleasesState, getPerspectiveState, getUsersKey, parseUsersKey, getUsersState, resolveUsers, loadMoreUsers } from "@sanity/sdk";
|
|
4
4
|
export * from "@sanity/sdk";
|
|
5
|
-
import { createContext, useContext, useSyncExternalStore,
|
|
5
|
+
import { createContext, useContext, useSyncExternalStore, useRef, useEffect, useState, Suspense, useMemo, useCallback, useInsertionEffect, useTransition } from "react";
|
|
6
6
|
import { ErrorBoundary } from "react-error-boundary";
|
|
7
|
-
import { ClientError } from "@sanity/client";
|
|
8
|
-
import { identity, firstValueFrom, filter, Observable, startWith, distinctUntilChanged, switchMap, EMPTY } from "rxjs";
|
|
9
7
|
import { SDK_CHANNEL_NAME, SDK_NODE_NAME } from "@sanity/message-protocol";
|
|
8
|
+
import { firstValueFrom, filter, identity, Observable, startWith, distinctUntilChanged, switchMap, EMPTY } from "rxjs";
|
|
9
|
+
import { ClientError } from "@sanity/client";
|
|
10
10
|
import { pick } from "lodash-es";
|
|
11
11
|
const SanityInstanceContext = createContext(null), useSanityInstance = (config) => {
|
|
12
12
|
const $ = c(3), instance = useContext(SanityInstanceContext);
|
|
@@ -38,7 +38,108 @@ function createStateSourceHook(options) {
|
|
|
38
38
|
}
|
|
39
39
|
return useHook;
|
|
40
40
|
}
|
|
41
|
-
const useAuthState = createStateSourceHook(getAuthState)
|
|
41
|
+
const useAuthState = createStateSourceHook(getAuthState), useNodeState = createStateSourceHook({
|
|
42
|
+
getState: getNodeState,
|
|
43
|
+
shouldSuspend: (instance, nodeInput) => getNodeState(instance, nodeInput).getCurrent() === void 0,
|
|
44
|
+
suspender: (instance, nodeInput) => firstValueFrom(getNodeState(instance, nodeInput).observable.pipe(filter(Boolean)))
|
|
45
|
+
});
|
|
46
|
+
function useWindowConnection(t0) {
|
|
47
|
+
const $ = c(19), {
|
|
48
|
+
name,
|
|
49
|
+
connectTo,
|
|
50
|
+
onMessage
|
|
51
|
+
} = t0;
|
|
52
|
+
let t1;
|
|
53
|
+
$[0] !== connectTo || $[1] !== name ? (t1 = {
|
|
54
|
+
name,
|
|
55
|
+
connectTo
|
|
56
|
+
}, $[0] = connectTo, $[1] = name, $[2] = t1) : t1 = $[2];
|
|
57
|
+
const {
|
|
58
|
+
node
|
|
59
|
+
} = useNodeState(t1);
|
|
60
|
+
let t2;
|
|
61
|
+
$[3] === Symbol.for("react.memo_cache_sentinel") ? (t2 = [], $[3] = t2) : t2 = $[3];
|
|
62
|
+
const messageUnsubscribers = useRef(t2), instance = useSanityInstance();
|
|
63
|
+
let t3;
|
|
64
|
+
$[4] !== node || $[5] !== onMessage ? (t3 = () => (onMessage && Object.entries(onMessage).forEach((t42) => {
|
|
65
|
+
const [type, handler] = t42, messageUnsubscribe = node.on(type, handler);
|
|
66
|
+
messageUnsubscribe && messageUnsubscribers.current.push(messageUnsubscribe);
|
|
67
|
+
}), () => {
|
|
68
|
+
messageUnsubscribers.current.forEach(_temp$6), messageUnsubscribers.current = [];
|
|
69
|
+
}), $[4] = node, $[5] = onMessage, $[6] = t3) : t3 = $[6];
|
|
70
|
+
let t4;
|
|
71
|
+
$[7] !== instance || $[8] !== name || $[9] !== node || $[10] !== onMessage ? (t4 = [instance, name, onMessage, node], $[7] = instance, $[8] = name, $[9] = node, $[10] = onMessage, $[11] = t4) : t4 = $[11], useEffect(t3, t4);
|
|
72
|
+
let t5;
|
|
73
|
+
$[12] !== node ? (t5 = (type_0, data) => {
|
|
74
|
+
node.post(type_0, data);
|
|
75
|
+
}, $[12] = node, $[13] = t5) : t5 = $[13];
|
|
76
|
+
const sendMessage = t5;
|
|
77
|
+
let t6;
|
|
78
|
+
$[14] !== node ? (t6 = (type_1, data_0, fetchOptions) => node.fetch(type_1, data_0, fetchOptions ?? {}), $[14] = node, $[15] = t6) : t6 = $[15];
|
|
79
|
+
const fetch = t6;
|
|
80
|
+
let t7;
|
|
81
|
+
return $[16] !== fetch || $[17] !== sendMessage ? (t7 = {
|
|
82
|
+
sendMessage,
|
|
83
|
+
fetch
|
|
84
|
+
}, $[16] = fetch, $[17] = sendMessage, $[18] = t7) : t7 = $[18], t7;
|
|
85
|
+
}
|
|
86
|
+
function _temp$6(unsubscribe) {
|
|
87
|
+
return unsubscribe();
|
|
88
|
+
}
|
|
89
|
+
const DEFAULT_RESPONSE_TIMEOUT = 1e4;
|
|
90
|
+
function DashboardTokenRefresh(t0) {
|
|
91
|
+
const $ = c(14), {
|
|
92
|
+
children
|
|
93
|
+
} = t0, instance = useSanityInstance(), isTokenRefreshInProgress = useRef(!1), timeoutRef = useRef(null), processed401ErrorRef = useRef(null), authState = useAuthState();
|
|
94
|
+
let t1;
|
|
95
|
+
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t1 = () => {
|
|
96
|
+
timeoutRef.current && (clearTimeout(timeoutRef.current), timeoutRef.current = null);
|
|
97
|
+
}, $[0] = t1) : t1 = $[0];
|
|
98
|
+
const clearRefreshTimeout = t1;
|
|
99
|
+
let t2;
|
|
100
|
+
$[1] === Symbol.for("react.memo_cache_sentinel") ? (t2 = {
|
|
101
|
+
name: SDK_NODE_NAME,
|
|
102
|
+
connectTo: SDK_CHANNEL_NAME
|
|
103
|
+
}, $[1] = t2) : t2 = $[1];
|
|
104
|
+
const windowConnection = useWindowConnection(t2);
|
|
105
|
+
let t3;
|
|
106
|
+
$[2] !== instance || $[3] !== windowConnection ? (t3 = async () => {
|
|
107
|
+
if (!isTokenRefreshInProgress.current) {
|
|
108
|
+
isTokenRefreshInProgress.current = !0, clearRefreshTimeout(), timeoutRef.current = setTimeout(() => {
|
|
109
|
+
isTokenRefreshInProgress.current && (isTokenRefreshInProgress.current = !1), timeoutRef.current = null;
|
|
110
|
+
}, DEFAULT_RESPONSE_TIMEOUT);
|
|
111
|
+
try {
|
|
112
|
+
const res = await windowConnection.fetch("dashboard/v1/auth/tokens/create");
|
|
113
|
+
clearRefreshTimeout(), res.token && setAuthToken(instance, res.token), isTokenRefreshInProgress.current = !1;
|
|
114
|
+
} catch {
|
|
115
|
+
isTokenRefreshInProgress.current = !1, clearRefreshTimeout();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}, $[2] = instance, $[3] = windowConnection, $[4] = t3) : t3 = $[4];
|
|
119
|
+
const requestNewToken = t3;
|
|
120
|
+
let t4, t5;
|
|
121
|
+
$[5] === Symbol.for("react.memo_cache_sentinel") ? (t4 = () => () => {
|
|
122
|
+
clearRefreshTimeout();
|
|
123
|
+
}, t5 = [clearRefreshTimeout], $[5] = t4, $[6] = t5) : (t4 = $[5], t5 = $[6]), useEffect(t4, t5);
|
|
124
|
+
let t6;
|
|
125
|
+
$[7] !== authState.error || $[8] !== authState.type || $[9] !== requestNewToken ? (t6 = () => {
|
|
126
|
+
const has401Error = authState.type === AuthStateType.ERROR && authState.error && authState.error?.statusCode === 401 && !isTokenRefreshInProgress.current && processed401ErrorRef.current !== authState.error, isLoggedOut = authState.type === AuthStateType.LOGGED_OUT && !isTokenRefreshInProgress.current;
|
|
127
|
+
has401Error || isLoggedOut ? (processed401ErrorRef.current = authState.type === AuthStateType.ERROR ? authState.error : void 0, requestNewToken()) : (authState.type !== AuthStateType.ERROR || processed401ErrorRef.current !== (authState.type === AuthStateType.ERROR ? authState.error : void 0)) && (processed401ErrorRef.current = null);
|
|
128
|
+
}, $[7] = authState.error, $[8] = authState.type, $[9] = requestNewToken, $[10] = t6) : t6 = $[10];
|
|
129
|
+
let t7;
|
|
130
|
+
return $[11] !== authState || $[12] !== requestNewToken ? (t7 = [authState, requestNewToken], $[11] = authState, $[12] = requestNewToken, $[13] = t7) : t7 = $[13], useEffect(t6, t7), children;
|
|
131
|
+
}
|
|
132
|
+
const ComlinkTokenRefreshProvider = (t0) => {
|
|
133
|
+
const $ = c(2), {
|
|
134
|
+
children
|
|
135
|
+
} = t0, instance = useSanityInstance();
|
|
136
|
+
let t1;
|
|
137
|
+
if (t1 = getIsInDashboardState(instance).getCurrent(), t1) {
|
|
138
|
+
let t2;
|
|
139
|
+
return $[0] !== children ? (t2 = /* @__PURE__ */ jsx(DashboardTokenRefresh, { children }), $[0] = children, $[1] = t2) : t2 = $[1], t2;
|
|
140
|
+
}
|
|
141
|
+
return children;
|
|
142
|
+
};
|
|
42
143
|
function useLoginUrl() {
|
|
43
144
|
const $ = c(2), instance = useSanityInstance();
|
|
44
145
|
let t0, t1;
|
|
@@ -96,19 +197,19 @@ function LoginCallback() {
|
|
|
96
197
|
let t0, t1;
|
|
97
198
|
return $[0] !== handleAuthCallback2 ? (t0 = () => {
|
|
98
199
|
const url = new URL(location.href);
|
|
99
|
-
handleAuthCallback2(url.toString()).then(_temp$
|
|
200
|
+
handleAuthCallback2(url.toString()).then(_temp$5);
|
|
100
201
|
}, t1 = [handleAuthCallback2], $[0] = handleAuthCallback2, $[1] = t0, $[2] = t1) : (t0 = $[1], t1 = $[2]), useEffect(t0, t1), null;
|
|
101
202
|
}
|
|
102
|
-
function _temp$
|
|
203
|
+
function _temp$5(replacementLocation) {
|
|
103
204
|
replacementLocation && history.replaceState(null, "", replacementLocation);
|
|
104
205
|
}
|
|
105
206
|
const useLogOut = createCallbackHook(logout);
|
|
106
207
|
function LoginError(t0) {
|
|
107
|
-
const $ = c(
|
|
208
|
+
const $ = c(23), {
|
|
108
209
|
error,
|
|
109
210
|
resetErrorBoundary
|
|
110
211
|
} = t0;
|
|
111
|
-
if (!(error instanceof AuthError || error instanceof ConfigurationError))
|
|
212
|
+
if (!(error instanceof AuthError || error instanceof ConfigurationError || error instanceof ClientError))
|
|
112
213
|
throw error;
|
|
113
214
|
const logout2 = useLogOut(), authState = useAuthState(), [authErrorMessage, setAuthErrorMessage] = useState("Please try again or contact support if the problem persists.");
|
|
114
215
|
let t1;
|
|
@@ -117,36 +218,36 @@ function LoginError(t0) {
|
|
|
117
218
|
}, $[0] = logout2, $[1] = resetErrorBoundary, $[2] = t1) : t1 = $[2];
|
|
118
219
|
const handleRetry = t1;
|
|
119
220
|
let t2;
|
|
120
|
-
$[3] !== authState.
|
|
121
|
-
if (
|
|
122
|
-
if (
|
|
221
|
+
$[3] !== authState.type || $[4] !== error || $[5] !== handleRetry ? (t2 = () => {
|
|
222
|
+
if (error instanceof ClientError) {
|
|
223
|
+
if (error.statusCode === 401)
|
|
123
224
|
handleRetry();
|
|
124
|
-
else if (
|
|
125
|
-
const errorMessage =
|
|
225
|
+
else if (error.statusCode === 404) {
|
|
226
|
+
const errorMessage = error.response.body.message || "";
|
|
126
227
|
errorMessage.startsWith("Session with sid") && errorMessage.endsWith("not found") ? setAuthErrorMessage("The session ID is invalid or expired.") : setAuthErrorMessage("The login link is invalid or expired. Please try again.");
|
|
127
228
|
}
|
|
128
229
|
}
|
|
129
230
|
authState.type !== AuthStateType.ERROR && error instanceof ConfigurationError && setAuthErrorMessage(error.message);
|
|
130
|
-
}, $[3] = authState.
|
|
231
|
+
}, $[3] = authState.type, $[4] = error, $[5] = handleRetry, $[6] = t2) : t2 = $[6];
|
|
131
232
|
let t3;
|
|
132
|
-
$[
|
|
233
|
+
$[7] !== authState || $[8] !== error || $[9] !== handleRetry ? (t3 = [authState, handleRetry, error], $[7] = authState, $[8] = error, $[9] = handleRetry, $[10] = t3) : t3 = $[10], useEffect(t2, t3);
|
|
133
234
|
const t4 = error instanceof AuthError ? "Authentication Error" : "Configuration Error";
|
|
134
235
|
let t5;
|
|
135
|
-
$[
|
|
236
|
+
$[11] !== t4 ? (t5 = /* @__PURE__ */ jsx("h2", { className: "sc-login-error__title", children: t4 }), $[11] = t4, $[12] = t5) : t5 = $[12];
|
|
136
237
|
let t6;
|
|
137
|
-
$[
|
|
238
|
+
$[13] !== authErrorMessage ? (t6 = /* @__PURE__ */ jsx("p", { className: "sc-login-error__description", children: authErrorMessage }), $[13] = authErrorMessage, $[14] = t6) : t6 = $[14];
|
|
138
239
|
let t7;
|
|
139
|
-
$[
|
|
240
|
+
$[15] !== t5 || $[16] !== t6 ? (t7 = /* @__PURE__ */ jsxs("div", { className: "sc-login-error__content", children: [
|
|
140
241
|
t5,
|
|
141
242
|
t6
|
|
142
|
-
] }), $[
|
|
243
|
+
] }), $[15] = t5, $[16] = t6, $[17] = t7) : t7 = $[17];
|
|
143
244
|
let t8;
|
|
144
|
-
$[
|
|
245
|
+
$[18] !== handleRetry ? (t8 = /* @__PURE__ */ jsx("button", { className: "sc-login-error__button", onClick: handleRetry, children: "Retry" }), $[18] = handleRetry, $[19] = t8) : t8 = $[19];
|
|
145
246
|
let t9;
|
|
146
|
-
return $[
|
|
247
|
+
return $[20] !== t7 || $[21] !== t8 ? (t9 = /* @__PURE__ */ jsxs("div", { className: "sc-login-error", children: [
|
|
147
248
|
t7,
|
|
148
249
|
t8
|
|
149
|
-
] }), $[
|
|
250
|
+
] }), $[20] = t7, $[21] = t8, $[22] = t9) : t9 = $[22], t9;
|
|
150
251
|
}
|
|
151
252
|
if (isInIframe() && !document.querySelector("[data-sanity-core]")) {
|
|
152
253
|
const parsedUrl = new URL(window.location.href), mode = new URLSearchParams(parsedUrl.hash.slice(1)).get("mode"), script = document.createElement("script");
|
|
@@ -168,7 +269,7 @@ function AuthBoundary(t0) {
|
|
|
168
269
|
let t4;
|
|
169
270
|
$[5] !== props ? (t4 = /* @__PURE__ */ jsx(AuthSwitch, { ...props }), $[5] = props, $[6] = t4) : t4 = $[6];
|
|
170
271
|
let t5;
|
|
171
|
-
return $[7] !== FallbackComponent || $[8] !== t4 ? (t5 = /* @__PURE__ */ jsx(ErrorBoundary, { FallbackComponent, children: t4 }), $[7] = FallbackComponent, $[8] = t4, $[9] = t5) : t5 = $[9], t5;
|
|
272
|
+
return $[7] !== FallbackComponent || $[8] !== t4 ? (t5 = /* @__PURE__ */ jsx(ComlinkTokenRefreshProvider, { children: /* @__PURE__ */ jsx(ErrorBoundary, { FallbackComponent, children: t4 }) }), $[7] = FallbackComponent, $[8] = t4, $[9] = t5) : t5 = $[9], t5;
|
|
172
273
|
}
|
|
173
274
|
function AuthSwitch(t0) {
|
|
174
275
|
const $ = c(13);
|
|
@@ -260,9 +361,9 @@ function SanityApp(t0) {
|
|
|
260
361
|
}
|
|
261
362
|
function _temp2$1() {
|
|
262
363
|
let timeout;
|
|
263
|
-
return !isInIframe() && !isLocalUrl(window) && (timeout = setTimeout(_temp$
|
|
364
|
+
return !isInIframe() && !isLocalUrl(window) && (timeout = setTimeout(_temp$4, 1e3)), () => clearTimeout(timeout);
|
|
264
365
|
}
|
|
265
|
-
function _temp$
|
|
366
|
+
function _temp$4() {
|
|
266
367
|
console.warn("Redirecting to core", REDIRECT_URL), window.location.replace(REDIRECT_URL);
|
|
267
368
|
}
|
|
268
369
|
const useAuthToken = createStateSourceHook(getTokenState), useCurrentUser = createStateSourceHook(getCurrentUserState);
|
|
@@ -304,7 +405,7 @@ function useFrameConnection(options) {
|
|
|
304
405
|
const [type, handler] = t22, unsubscribe = channel.on(type, handler);
|
|
305
406
|
messageUnsubscribers.push(unsubscribe);
|
|
306
407
|
}), () => {
|
|
307
|
-
messageUnsubscribers.forEach(_temp$
|
|
408
|
+
messageUnsubscribers.forEach(_temp$3), releaseChannel(instance, name), channelRef.current = null, controllerRef.current = null;
|
|
308
409
|
};
|
|
309
410
|
}, t1 = [targetOrigin, name, connectTo, heartbeat, onMessage, instance, onStatus], $[0] = connectTo, $[1] = heartbeat, $[2] = instance, $[3] = name, $[4] = onMessage, $[5] = onStatus, $[6] = targetOrigin, $[7] = t0, $[8] = t1) : (t0 = $[7], t1 = $[8]), useEffect(t0, t1);
|
|
310
411
|
let t2;
|
|
@@ -326,57 +427,9 @@ function useFrameConnection(options) {
|
|
|
326
427
|
sendMessage
|
|
327
428
|
}, $[11] = t4) : t4 = $[11], t4;
|
|
328
429
|
}
|
|
329
|
-
function _temp$
|
|
430
|
+
function _temp$3(unsub) {
|
|
330
431
|
return unsub();
|
|
331
432
|
}
|
|
332
|
-
const useNodeState = createStateSourceHook({
|
|
333
|
-
getState: getNodeState,
|
|
334
|
-
shouldSuspend: (instance, nodeInput) => getNodeState(instance, nodeInput).getCurrent() === void 0,
|
|
335
|
-
suspender: (instance, nodeInput) => firstValueFrom(getNodeState(instance, nodeInput).observable.pipe(filter(Boolean)))
|
|
336
|
-
});
|
|
337
|
-
function useWindowConnection(t0) {
|
|
338
|
-
const $ = c(19), {
|
|
339
|
-
name,
|
|
340
|
-
connectTo,
|
|
341
|
-
onMessage
|
|
342
|
-
} = t0;
|
|
343
|
-
let t1;
|
|
344
|
-
$[0] !== connectTo || $[1] !== name ? (t1 = {
|
|
345
|
-
name,
|
|
346
|
-
connectTo
|
|
347
|
-
}, $[0] = connectTo, $[1] = name, $[2] = t1) : t1 = $[2];
|
|
348
|
-
const {
|
|
349
|
-
node
|
|
350
|
-
} = useNodeState(t1);
|
|
351
|
-
let t2;
|
|
352
|
-
$[3] === Symbol.for("react.memo_cache_sentinel") ? (t2 = [], $[3] = t2) : t2 = $[3];
|
|
353
|
-
const messageUnsubscribers = useRef(t2), instance = useSanityInstance();
|
|
354
|
-
let t3;
|
|
355
|
-
$[4] !== node || $[5] !== onMessage ? (t3 = () => (onMessage && Object.entries(onMessage).forEach((t42) => {
|
|
356
|
-
const [type, handler] = t42, messageUnsubscribe = node.on(type, handler);
|
|
357
|
-
messageUnsubscribe && messageUnsubscribers.current.push(messageUnsubscribe);
|
|
358
|
-
}), () => {
|
|
359
|
-
messageUnsubscribers.current.forEach(_temp$3), messageUnsubscribers.current = [];
|
|
360
|
-
}), $[4] = node, $[5] = onMessage, $[6] = t3) : t3 = $[6];
|
|
361
|
-
let t4;
|
|
362
|
-
$[7] !== instance || $[8] !== name || $[9] !== node || $[10] !== onMessage ? (t4 = [instance, name, onMessage, node], $[7] = instance, $[8] = name, $[9] = node, $[10] = onMessage, $[11] = t4) : t4 = $[11], useEffect(t3, t4);
|
|
363
|
-
let t5;
|
|
364
|
-
$[12] !== node ? (t5 = (type_0, data) => {
|
|
365
|
-
node.post(type_0, data);
|
|
366
|
-
}, $[12] = node, $[13] = t5) : t5 = $[13];
|
|
367
|
-
const sendMessage = t5;
|
|
368
|
-
let t6;
|
|
369
|
-
$[14] !== node ? (t6 = (type_1, data_0, fetchOptions) => node.fetch(type_1, data_0, fetchOptions ?? {}), $[14] = node, $[15] = t6) : t6 = $[15];
|
|
370
|
-
const fetch = t6;
|
|
371
|
-
let t7;
|
|
372
|
-
return $[16] !== fetch || $[17] !== sendMessage ? (t7 = {
|
|
373
|
-
sendMessage,
|
|
374
|
-
fetch
|
|
375
|
-
}, $[16] = fetch, $[17] = sendMessage, $[18] = t7) : t7 = $[18], t7;
|
|
376
|
-
}
|
|
377
|
-
function _temp$3(unsubscribe) {
|
|
378
|
-
return unsubscribe();
|
|
379
|
-
}
|
|
380
433
|
function useDashboardNavigate(navigateFn) {
|
|
381
434
|
const $ = c(2);
|
|
382
435
|
let t0;
|
|
@@ -1059,7 +1112,7 @@ function useUsers(options) {
|
|
|
1059
1112
|
loadMore
|
|
1060
1113
|
};
|
|
1061
1114
|
}
|
|
1062
|
-
var version = "2.0.
|
|
1115
|
+
var version = "2.0.1";
|
|
1063
1116
|
function getEnv(key) {
|
|
1064
1117
|
if (typeof import.meta < "u" && import.meta.env)
|
|
1065
1118
|
return import.meta.env[key];
|
|
@@ -1071,6 +1124,7 @@ function getEnv(key) {
|
|
|
1071
1124
|
const REACT_SDK_VERSION = getEnv("PKG_VERSION") || `${version}-development`;
|
|
1072
1125
|
export {
|
|
1073
1126
|
AuthBoundary,
|
|
1127
|
+
ComlinkTokenRefreshProvider,
|
|
1074
1128
|
REACT_SDK_VERSION,
|
|
1075
1129
|
ResourceProvider,
|
|
1076
1130
|
SDKProvider,
|