@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.
@@ -1481,33 +1481,26 @@ class LiveClient {
1481
1481
  "welcome",
1482
1482
  "reconnect",
1483
1483
  "goaway"
1484
- ]), checkCors$ = fetchObservable(url, {
1484
+ ]).pipe(
1485
+ reconnectOnConnectionFailure(),
1486
+ operators.map((event) => {
1487
+ if (event.type === "message") {
1488
+ const { data, ...rest } = event;
1489
+ return { ...rest, tags: data.tags };
1490
+ }
1491
+ return event;
1492
+ })
1493
+ ), checkCors = fetchObservable(url, {
1485
1494
  method: "OPTIONS",
1486
1495
  mode: "cors",
1487
1496
  credentials: esOptions.withCredentials ? "include" : "omit",
1488
1497
  headers: esOptions.headers
1489
1498
  }).pipe(
1499
+ rxjs.mergeMap(() => rxjs.EMPTY),
1490
1500
  rxjs.catchError(() => {
1491
1501
  throw new CorsOriginError({ projectId: projectId2 });
1492
- }),
1493
- operators.shareReplay(1)
1494
- // run only once
1495
- ), observable = events.pipe(
1496
- rxjs.catchError((err) => (console.log("[live] err from catchError", err), checkCors$.pipe(
1497
- rxjs.mergeMap(() => (console.log("[live] err from checkCors$", err), rxjs.of(err))),
1498
- rxjs.mergeMap(() => {
1499
- throw console.log("[live] throwing err from checkCors$", err), err;
1500
- })
1501
- ))),
1502
- reconnectOnConnectionFailure(),
1503
- operators.map((event) => {
1504
- if (console.log("event", event), event.type === "message") {
1505
- const { data, ...rest } = event;
1506
- return { ...rest, tags: data.tags };
1507
- }
1508
- return event;
1509
1502
  })
1510
- ).pipe(
1503
+ ), observable = rxjs.concat(checkCors, events).pipe(
1511
1504
  operators.finalize(() => eventsCache.delete(key)),
1512
1505
  shareReplayLatest({
1513
1506
  predicate: (event) => event.type === "welcome"