@sanity/client 7.11.0 → 7.11.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/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { getIt } from "get-it";
2
2
  import { adapter, environment } from "get-it";
3
3
  import { retry, jsonRequest, jsonResponse, progress, observable, debug, headers, agent } from "get-it/middleware";
4
- import { Observable, defer, of, isObservable, mergeMap, from, lastValueFrom, shareReplay, catchError, concat, throwError, timer, tap, finalize, share, merge, EMPTY, map as map$1, firstValueFrom } from "rxjs";
4
+ import { Observable, defer, of, isObservable, mergeMap, from, lastValueFrom, shareReplay, catchError, concat, throwError, timer, tap, finalize, share, merge, map as map$1, firstValueFrom } from "rxjs";
5
5
  import { isRecord } from "./_chunks-es/isRecord.js";
6
6
  import { stegaClean } from "./_chunks-es/stegaClean.js";
7
7
  import { combineLatestWith, map, filter, finalize as finalize$1 } from "rxjs/operators";
@@ -1296,26 +1296,31 @@ class LiveClient {
1296
1296
  "welcome",
1297
1297
  "reconnect",
1298
1298
  "goaway"
1299
- ]).pipe(
1300
- reconnectOnConnectionFailure(),
1301
- map((event) => {
1302
- if (event.type === "message") {
1303
- const { data, ...rest } = event;
1304
- return { ...rest, tags: data.tags };
1305
- }
1306
- return event;
1307
- })
1308
- ), checkCors = fetchObservable(url, {
1299
+ ]), checkCors = fetchObservable(url, {
1309
1300
  method: "OPTIONS",
1310
1301
  mode: "cors",
1311
1302
  credentials: esOptions.withCredentials ? "include" : "omit",
1312
1303
  headers: esOptions.headers
1313
1304
  }).pipe(
1314
- mergeMap(() => EMPTY),
1315
1305
  catchError(() => {
1316
1306
  throw new CorsOriginError({ projectId });
1317
1307
  })
1318
- ), observable2 = concat(checkCors, events).pipe(
1308
+ ), observable2 = events.pipe(
1309
+ reconnectOnConnectionFailure(),
1310
+ mergeMap((event) => event.type === "reconnect" ? checkCors.pipe(mergeMap(() => of(event))) : of(event)),
1311
+ catchError((err) => checkCors.pipe(
1312
+ mergeMap(() => {
1313
+ throw err;
1314
+ })
1315
+ )),
1316
+ map((event) => {
1317
+ if (event.type === "message") {
1318
+ const { data, ...rest } = event;
1319
+ return { ...rest, tags: data.tags };
1320
+ }
1321
+ return event;
1322
+ })
1323
+ ).pipe(
1319
1324
  finalize$1(() => eventsCache.delete(key)),
1320
1325
  shareReplayLatest({
1321
1326
  predicate: (event) => event.type === "welcome"
@@ -2664,7 +2669,7 @@ function defineDeprecatedCreateClient(createClient2) {
2664
2669
  return printNoDefaultExport(), createClient2(config);
2665
2670
  };
2666
2671
  }
2667
- var name = "@sanity/client", version = "7.11.0";
2672
+ var name = "@sanity/client", version = "7.11.1";
2668
2673
  const middleware = [
2669
2674
  debug({ verbose: !0, namespace: "sanity:client" }),
2670
2675
  headers({ "User-Agent": `${name} ${version}` }),