@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.
- package/dist/index.browser.cjs +12 -19
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +14 -21
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +13 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +15 -22
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/data/live.ts +17 -32
- package/umd/sanityClient.js +12 -19
- package/umd/sanityClient.min.js +2 -2
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
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, 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 } from "./_chunks-es/isRecord.js";
|
|
6
6
|
import { stegaClean } from "./_chunks-es/stegaClean.js";
|
|
7
|
-
import { combineLatestWith, map, filter,
|
|
7
|
+
import { combineLatestWith, map, filter, finalize as finalize$1 } from "rxjs/operators";
|
|
8
8
|
import { getVersionFromId, isDraftId, getVersionId, getDraftId, isVersionId, getPublishedId } from "@sanity/client/csm";
|
|
9
9
|
import { customAlphabet } from "nanoid";
|
|
10
10
|
import { validateObject, validateInsert, requireDocumentId, validateDocumentId, requireDocumentType, printCreateVersionWithBaseIdWarning, resourceConfig, hasDataset, requestTag, printPreviewDraftsDeprecationWarning, validateApiPerspective, printCdnPreviewDraftsWarning, validateAssetType, resourceGuard, dataset, validateVersionIdMatch, defaultConfig, initConfig, printNoDefaultExport } from "./_chunks-es/config.js";
|
|
@@ -1296,33 +1296,26 @@ class LiveClient {
|
|
|
1296
1296
|
"welcome",
|
|
1297
1297
|
"reconnect",
|
|
1298
1298
|
"goaway"
|
|
1299
|
-
])
|
|
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, {
|
|
1300
1309
|
method: "OPTIONS",
|
|
1301
1310
|
mode: "cors",
|
|
1302
1311
|
credentials: esOptions.withCredentials ? "include" : "omit",
|
|
1303
1312
|
headers: esOptions.headers
|
|
1304
1313
|
}).pipe(
|
|
1314
|
+
mergeMap(() => EMPTY),
|
|
1305
1315
|
catchError(() => {
|
|
1306
1316
|
throw new CorsOriginError({ projectId });
|
|
1307
|
-
}),
|
|
1308
|
-
shareReplay$1(1)
|
|
1309
|
-
// run only once
|
|
1310
|
-
), observable2 = events.pipe(
|
|
1311
|
-
catchError((err) => (console.log("[live] err from catchError", err), checkCors$.pipe(
|
|
1312
|
-
mergeMap(() => (console.log("[live] err from checkCors$", err), of(err))),
|
|
1313
|
-
mergeMap(() => {
|
|
1314
|
-
throw console.log("[live] throwing err from checkCors$", err), err;
|
|
1315
|
-
})
|
|
1316
|
-
))),
|
|
1317
|
-
reconnectOnConnectionFailure(),
|
|
1318
|
-
map((event) => {
|
|
1319
|
-
if (console.log("event", event), event.type === "message") {
|
|
1320
|
-
const { data, ...rest } = event;
|
|
1321
|
-
return { ...rest, tags: data.tags };
|
|
1322
|
-
}
|
|
1323
|
-
return event;
|
|
1324
1317
|
})
|
|
1325
|
-
).pipe(
|
|
1318
|
+
), observable2 = concat(checkCors, events).pipe(
|
|
1326
1319
|
finalize$1(() => eventsCache.delete(key)),
|
|
1327
1320
|
shareReplayLatest({
|
|
1328
1321
|
predicate: (event) => event.type === "welcome"
|
|
@@ -2671,7 +2664,7 @@ function defineDeprecatedCreateClient(createClient2) {
|
|
|
2671
2664
|
return printNoDefaultExport(), createClient2(config);
|
|
2672
2665
|
};
|
|
2673
2666
|
}
|
|
2674
|
-
var name = "@sanity/client", version = "7.11.0
|
|
2667
|
+
var name = "@sanity/client", version = "7.11.0";
|
|
2675
2668
|
const middleware = [
|
|
2676
2669
|
debug({ verbose: !0, namespace: "sanity:client" }),
|
|
2677
2670
|
headers({ "User-Agent": `${name} ${version}` }),
|