@sanity/sdk-react 2.7.0 → 2.8.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/dist/index.js
CHANGED
|
@@ -298,25 +298,40 @@ function _temp$6(replacementLocation) {
|
|
|
298
298
|
}
|
|
299
299
|
const useLogOut = createCallbackHook(logout);
|
|
300
300
|
function LoginError(t0) {
|
|
301
|
-
const $ = c(
|
|
301
|
+
const $ = c(23), {
|
|
302
302
|
error,
|
|
303
303
|
resetErrorBoundary
|
|
304
304
|
} = t0;
|
|
305
305
|
if (!(error instanceof AuthError || error instanceof ConfigurationError || error instanceof ClientError))
|
|
306
306
|
throw error;
|
|
307
|
-
const logout2 = useLogOut(), authState = useAuthState(),
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
}
|
|
312
|
-
const handleRetry = t1;
|
|
307
|
+
const logout2 = useLogOut(), authState = useAuthState(), {
|
|
308
|
+
config: t1
|
|
309
|
+
} = useSanityInstance(), {
|
|
310
|
+
projectId
|
|
311
|
+
} = t1, [authErrorMessage, setAuthErrorMessage] = useState("Please try again or contact support if the problem persists."), [showRetryCta, setShowRetryCta] = useState(!0);
|
|
313
312
|
let t2;
|
|
314
|
-
$[
|
|
313
|
+
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t2 = {
|
|
314
|
+
name: SDK_NODE_NAME,
|
|
315
|
+
connectTo: SDK_CHANNEL_NAME
|
|
316
|
+
}, $[0] = t2) : t2 = $[0];
|
|
317
|
+
const {
|
|
318
|
+
fetch
|
|
319
|
+
} = useWindowConnection(t2);
|
|
320
|
+
let t3;
|
|
321
|
+
$[1] !== logout2 || $[2] !== resetErrorBoundary ? (t3 = async () => {
|
|
322
|
+
await logout2(), resetErrorBoundary();
|
|
323
|
+
}, $[1] = logout2, $[2] = resetErrorBoundary, $[3] = t3) : t3 = $[3];
|
|
324
|
+
const handleRetry = t3;
|
|
325
|
+
let t4;
|
|
326
|
+
$[4] !== authState.type || $[5] !== error || $[6] !== fetch || $[7] !== handleRetry || $[8] !== projectId ? (t4 = () => {
|
|
315
327
|
if (error instanceof ClientError) {
|
|
316
328
|
if (error.statusCode === 401)
|
|
317
329
|
if (isProjectUserNotFoundClientError(error)) {
|
|
318
330
|
const description = getClientErrorApiDescription(error);
|
|
319
|
-
description && setAuthErrorMessage(description), setShowRetryCta(!1)
|
|
331
|
+
description && setAuthErrorMessage(description), setShowRetryCta(!1), fetch("dashboard/v1/auth/access/request", {
|
|
332
|
+
resourceType: "project",
|
|
333
|
+
resourceId: projectId
|
|
334
|
+
});
|
|
320
335
|
} else
|
|
321
336
|
setShowRetryCta(!0), handleRetry();
|
|
322
337
|
else if (error.statusCode === 404) {
|
|
@@ -325,17 +340,17 @@ function LoginError(t0) {
|
|
|
325
340
|
}
|
|
326
341
|
}
|
|
327
342
|
authState.type !== AuthStateType.ERROR && error instanceof ConfigurationError && (setAuthErrorMessage(error.message), setShowRetryCta(!0));
|
|
328
|
-
}, $[
|
|
329
|
-
let t3;
|
|
330
|
-
$[7] !== authState || $[8] !== error || $[9] !== handleRetry ? (t3 = [authState, handleRetry, error], $[7] = authState, $[8] = error, $[9] = handleRetry, $[10] = t3) : t3 = $[10], useEffect(t2, t3);
|
|
331
|
-
const t4 = error instanceof AuthError ? "Authentication Error" : "Configuration Error";
|
|
343
|
+
}, $[4] = authState.type, $[5] = error, $[6] = fetch, $[7] = handleRetry, $[8] = projectId, $[9] = t4) : t4 = $[9];
|
|
332
344
|
let t5;
|
|
333
|
-
$[11] !==
|
|
345
|
+
$[10] !== authState || $[11] !== error || $[12] !== fetch || $[13] !== handleRetry || $[14] !== projectId ? (t5 = [authState, handleRetry, error, fetch, projectId], $[10] = authState, $[11] = error, $[12] = fetch, $[13] = handleRetry, $[14] = projectId, $[15] = t5) : t5 = $[15], useEffect(t4, t5);
|
|
346
|
+
const t6 = error instanceof AuthError ? "Authentication Error" : "Configuration Error";
|
|
347
|
+
let t7;
|
|
348
|
+
$[16] !== handleRetry || $[17] !== showRetryCta ? (t7 = showRetryCta ? {
|
|
334
349
|
text: "Retry",
|
|
335
350
|
onClick: handleRetry
|
|
336
|
-
} : void 0, $[
|
|
337
|
-
let
|
|
338
|
-
return $[
|
|
351
|
+
} : void 0, $[16] = handleRetry, $[17] = showRetryCta, $[18] = t7) : t7 = $[18];
|
|
352
|
+
let t8;
|
|
353
|
+
return $[19] !== authErrorMessage || $[20] !== t6 || $[21] !== t7 ? (t8 = /* @__PURE__ */ jsx(Error$1, { heading: t6, description: authErrorMessage, cta: t7 }), $[19] = authErrorMessage, $[20] = t6, $[21] = t7, $[22] = t8) : t8 = $[22], t8;
|
|
339
354
|
}
|
|
340
355
|
if (isInIframe() && !document.querySelector("[data-sanity-core]")) {
|
|
341
356
|
const parsedUrl = new URL(window.location.href), mode = new URLSearchParams(parsedUrl.hash.slice(1)).get("mode"), script = document.createElement("script");
|
|
@@ -1475,7 +1490,7 @@ function useUsers(options) {
|
|
|
1475
1490
|
loadMore
|
|
1476
1491
|
};
|
|
1477
1492
|
}
|
|
1478
|
-
var version = "2.
|
|
1493
|
+
var version = "2.8.0";
|
|
1479
1494
|
function getEnv(key) {
|
|
1480
1495
|
if (typeof import.meta < "u" && import.meta.env)
|
|
1481
1496
|
return import.meta.env[key];
|