@sanity/client 7.11.0-live-cors → 7.11.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.
@@ -1,9 +1,9 @@
1
1
  import { getIt } from "get-it";
2
2
  import { adapter, environment } from "get-it";
3
3
  import { retry, jsonRequest, jsonResponse, progress, observable } from "get-it/middleware";
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";
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";
5
5
  import { isRecord, stegaClean } from "./_chunks-es/stegaClean.js";
6
- import { combineLatestWith, map, filter, shareReplay as shareReplay$1, finalize as finalize$1 } from "rxjs/operators";
6
+ import { combineLatestWith, map, filter, finalize as finalize$1 } from "rxjs/operators";
7
7
  import { getVersionFromId, isDraftId, getVersionId, getDraftId, isVersionId, getPublishedId } from "@sanity/client/csm";
8
8
  import { customAlphabet } from "nanoid";
9
9
  const NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
@@ -1465,33 +1465,26 @@ class LiveClient {
1465
1465
  "welcome",
1466
1466
  "reconnect",
1467
1467
  "goaway"
1468
- ]), checkCors$ = fetchObservable(url, {
1468
+ ]).pipe(
1469
+ reconnectOnConnectionFailure(),
1470
+ map((event) => {
1471
+ if (event.type === "message") {
1472
+ const { data, ...rest } = event;
1473
+ return { ...rest, tags: data.tags };
1474
+ }
1475
+ return event;
1476
+ })
1477
+ ), checkCors = fetchObservable(url, {
1469
1478
  method: "OPTIONS",
1470
1479
  mode: "cors",
1471
1480
  credentials: esOptions.withCredentials ? "include" : "omit",
1472
1481
  headers: esOptions.headers
1473
1482
  }).pipe(
1483
+ mergeMap(() => EMPTY),
1474
1484
  catchError(() => {
1475
1485
  throw new CorsOriginError({ projectId: projectId2 });
1476
- }),
1477
- shareReplay$1(1)
1478
- // run only once
1479
- ), observable2 = events.pipe(
1480
- catchError((err) => (console.log("[live] err from catchError", err), checkCors$.pipe(
1481
- mergeMap(() => (console.log("[live] err from checkCors$", err), of(err))),
1482
- mergeMap(() => {
1483
- throw console.log("[live] throwing err from checkCors$", err), err;
1484
- })
1485
- ))),
1486
- reconnectOnConnectionFailure(),
1487
- map((event) => {
1488
- if (console.log("event", event), event.type === "message") {
1489
- const { data, ...rest } = event;
1490
- return { ...rest, tags: data.tags };
1491
- }
1492
- return event;
1493
1486
  })
1494
- ).pipe(
1487
+ ), observable2 = concat(checkCors, events).pipe(
1495
1488
  finalize$1(() => eventsCache.delete(key)),
1496
1489
  shareReplayLatest({
1497
1490
  predicate: (event) => event.type === "welcome"