@sanity/sdk-react 2.17.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 ?? resource.activeDeployment?.manifest?.title ?? resource.title;
1310
+ return resource.manifest?.title || resource.activeDeployment?.manifest?.title || resource.title;
1311
1311
  }
1312
1312
  function useWindowTitle(viewTitle) {
1313
- const $ = c(8), [appTitle, setAppTitle] = useState(null);
1314
- let t0;
1315
- $[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t0 = {
1313
+ const [appTitle, setAppTitle] = useState(null), {
1314
+ fetch
1315
+ } = useWindowConnection({
1316
1316
  name: SDK_NODE_NAME,
1317
1317
  connectTo: SDK_CHANNEL_NAME
1318
- }, $[0] = t0) : t0 = $[0];
1319
- const {
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
- return (async function(signal) {
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 (t32) {
1334
- const err = t32;
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
- })(controller.signal), () => {
1332
+ }
1333
+ return fetchAppTitle(controller.signal), () => {
1340
1334
  controller.abort();
1341
1335
  };
1342
- }, t2 = [fetch], $[1] = fetch, $[2] = t1, $[3] = t2) : (t1 = $[2], t2 = $[3]), useEffect(t1, t2);
1343
- let t3, t4;
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
- }, t4 = [viewTitle, appTitle], $[4] = appTitle, $[5] = viewTitle, $[6] = t3, $[7] = t4) : (t3 = $[6], t4 = $[7]), useEffect(t3, t4);
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.17.0";
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];