@sanity/sdk-react 2.16.0 → 2.18.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
|
@@ -1307,48 +1307,39 @@ function useRecordDocumentHistoryEvent(t0) {
|
|
|
1307
1307
|
}, $[8] = recordEvent, $[9] = t3) : t3 = $[9], t3;
|
|
1308
1308
|
}
|
|
1309
1309
|
function resolveAppTitle(resource) {
|
|
1310
|
-
return resource.manifest?.title
|
|
1310
|
+
return resource.manifest?.title || resource.activeDeployment?.manifest?.title || resource.title;
|
|
1311
1311
|
}
|
|
1312
1312
|
function useWindowTitle(viewTitle) {
|
|
1313
|
-
const
|
|
1314
|
-
|
|
1315
|
-
|
|
1313
|
+
const [appTitle, setAppTitle] = useState(null), {
|
|
1314
|
+
fetch
|
|
1315
|
+
} = useWindowConnection({
|
|
1316
1316
|
name: SDK_NODE_NAME,
|
|
1317
1317
|
connectTo: SDK_CHANNEL_NAME
|
|
1318
|
-
}
|
|
1319
|
-
|
|
1320
|
-
fetch
|
|
1321
|
-
} = useWindowConnection(t0);
|
|
1322
|
-
let t1, t2;
|
|
1323
|
-
$[1] !== fetch ? (t1 = () => {
|
|
1324
|
-
if (!fetch)
|
|
1325
|
-
return;
|
|
1318
|
+
});
|
|
1319
|
+
useEffect(() => {
|
|
1320
|
+
if (!fetch) return;
|
|
1326
1321
|
const controller = new AbortController();
|
|
1327
|
-
|
|
1322
|
+
async function fetchAppTitle(signal) {
|
|
1328
1323
|
try {
|
|
1329
1324
|
const data = await fetch("dashboard/v1/context", void 0, {
|
|
1330
1325
|
signal
|
|
1331
|
-
}), title = resolveAppTitle(data.context.resource);
|
|
1326
|
+
}), title = resolveAppTitle(data.context.resource) || document.title;
|
|
1332
1327
|
title && setAppTitle(title);
|
|
1333
|
-
} catch (
|
|
1334
|
-
|
|
1335
|
-
if (err instanceof Error && err.name === "AbortError")
|
|
1336
|
-
return;
|
|
1328
|
+
} catch (err) {
|
|
1329
|
+
if (err instanceof Error && err.name === "AbortError") return;
|
|
1337
1330
|
console.error("Failed to fetch app title from dashboard context:", err);
|
|
1338
1331
|
}
|
|
1339
|
-
}
|
|
1332
|
+
}
|
|
1333
|
+
return fetchAppTitle(controller.signal), () => {
|
|
1340
1334
|
controller.abort();
|
|
1341
1335
|
};
|
|
1342
|
-
},
|
|
1343
|
-
|
|
1344
|
-
$[4] !== appTitle || $[5] !== viewTitle ? (t3 = () => {
|
|
1345
|
-
if (!appTitle)
|
|
1346
|
-
return;
|
|
1336
|
+
}, [fetch]), useEffect(() => {
|
|
1337
|
+
if (!appTitle) return;
|
|
1347
1338
|
const previous = document.title;
|
|
1348
1339
|
return document.title = viewTitle ? `${viewTitle} | ${appTitle}` : appTitle, () => {
|
|
1349
1340
|
document.title = previous;
|
|
1350
1341
|
};
|
|
1351
|
-
},
|
|
1342
|
+
}, [viewTitle, appTitle]);
|
|
1352
1343
|
}
|
|
1353
1344
|
function useResolvedProjectId(options) {
|
|
1354
1345
|
const $ = c(6);
|
|
@@ -2024,7 +2015,7 @@ function useUsers(options) {
|
|
|
2024
2015
|
loadMore
|
|
2025
2016
|
}, $[20] = data, $[21] = hasMore, $[22] = isPending, $[23] = loadMore, $[24] = t8) : t8 = $[24], t8;
|
|
2026
2017
|
}
|
|
2027
|
-
var version = "2.
|
|
2018
|
+
var version = "2.18.0";
|
|
2028
2019
|
function getEnv(key) {
|
|
2029
2020
|
if (typeof import.meta < "u" && import.meta.env)
|
|
2030
2021
|
return import.meta.env[key];
|