@sanity/client 7.11.0-live-cors → 7.11.1-allow-live.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/README.md CHANGED
@@ -2295,20 +2295,25 @@ const client = createClient({
2295
2295
  })
2296
2296
 
2297
2297
  // Basic usage with video asset ID
2298
- const playbackInfo = await client.mediaLibrary.video.getPlaybackInfo('video-30rh9U3GDEK3ToiId1Zje4uvalC-mp4')
2298
+ const playbackInfo = await client.mediaLibrary.video.getPlaybackInfo(
2299
+ 'video-30rh9U3GDEK3ToiId1Zje4uvalC-mp4',
2300
+ )
2299
2301
 
2300
2302
  // With transformations
2301
- const playbackInfo = await client.mediaLibrary.video.getPlaybackInfo('video-30rh9U3GDEK3ToiId1Zje4uvalC-mp4', {
2302
- transformations: {
2303
- thumbnail: { width: 300, format: 'webp', fit: 'smartcrop' },
2304
- animated: { width: 200, fps: 15, format: 'webp' }
2303
+ const playbackInfo = await client.mediaLibrary.video.getPlaybackInfo(
2304
+ 'video-30rh9U3GDEK3ToiId1Zje4uvalC-mp4',
2305
+ {
2306
+ transformations: {
2307
+ thumbnail: {width: 300, format: 'webp', fit: 'smartcrop'},
2308
+ animated: {width: 200, fps: 15, format: 'webp'},
2309
+ },
2310
+ expiration: 3600, // seconds
2305
2311
  },
2306
- expiration: 3600 // seconds
2307
- })
2312
+ )
2308
2313
 
2309
2314
  // Using Global Dataset Reference (GDR)
2310
2315
  const playbackInfo = await client.mediaLibrary.video.getPlaybackInfo({
2311
- _ref: 'media-library:mlZxz9rvqf76:30rh9U3GDEK3ToiId1Zje4uvalC'
2316
+ _ref: 'media-library:mlZxz9rvqf76:30rh9U3GDEK3ToiId1Zje4uvalC',
2312
2317
  })
2313
2318
  ```
2314
2319
 
@@ -2329,19 +2334,19 @@ The response contains playback URLs and metadata:
2329
2334
  // Signed playback response (when video requires authentication)
2330
2335
  {
2331
2336
  id: "30rh9U3GDEK3ToiId1Zje4uvalC",
2332
- stream: {
2337
+ stream: {
2333
2338
  url: "https://stream.m.sanity-cdn.com/...",
2334
2339
  token: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..."
2335
2340
  },
2336
- thumbnail: {
2341
+ thumbnail: {
2337
2342
  url: "https://image.m.sanity-cdn.com/...",
2338
2343
  token: "eyJ0a2VuIjoiVGh1bWJuYWlsVG9rZW4tMTIz..."
2339
2344
  },
2340
- animated: {
2345
+ animated: {
2341
2346
  url: "https://image.m.sanity-cdn.com/...",
2342
2347
  token: "eyJ0a2VuIjoiQW5pbWF0ZWRUb2tlbi1kZWY..."
2343
2348
  },
2344
- storyboard: {
2349
+ storyboard: {
2345
2350
  url: "https://storyboard.m.sanity-cdn.com/...",
2346
2351
  token: "eyJ0a2VuIjoiU3Rvcnlib2FyZFRva2VuLTc4..."
2347
2352
  },
@@ -2355,7 +2360,9 @@ The response contains playback URLs and metadata:
2355
2360
  ```js
2356
2361
  import {getPlaybackTokens, isSignedPlaybackInfo} from '@sanity/client/media-library'
2357
2362
 
2358
- const playbackInfo = await client.mediaLibrary.video.getPlaybackInfo('video-30rh9U3GDEK3ToiId1Zje4uvalC-mp4')
2363
+ const playbackInfo = await client.mediaLibrary.video.getPlaybackInfo(
2364
+ 'video-30rh9U3GDEK3ToiId1Zje4uvalC-mp4',
2365
+ )
2359
2366
 
2360
2367
  // Check if the response requires signed URLs
2361
2368
  if (isSignedPlaybackInfo(playbackInfo)) {
@@ -2368,7 +2375,7 @@ if (isSignedPlaybackInfo(playbackInfo)) {
2368
2375
  // animated: "eyJ0a2VuIjoiQW5pbWF0ZWRUb2tlbi1kZWY...",
2369
2376
  // storyboard: "eyJ0a2VuIjoiU3Rvcnlib2FyZFRva2VuLTc4..."
2370
2377
  // }
2371
-
2378
+
2372
2379
  // Use with Mux Player or other compatible players
2373
2380
  // The tokens authenticate access to the video resources
2374
2381
  }
@@ -1448,7 +1448,6 @@ class LiveClient {
1448
1448
  includeDrafts = !1,
1449
1449
  tag: _tag
1450
1450
  } = {}) {
1451
- resourceGuard("live", this.#client.config());
1452
1451
  const {
1453
1452
  projectId: projectId2,
1454
1453
  apiVersion: _apiVersion,
@@ -1481,7 +1480,7 @@ class LiveClient {
1481
1480
  "welcome",
1482
1481
  "reconnect",
1483
1482
  "goaway"
1484
- ]), checkCors$ = fetchObservable(url, {
1483
+ ]), checkCors = fetchObservable(url, {
1485
1484
  method: "OPTIONS",
1486
1485
  mode: "cors",
1487
1486
  credentials: esOptions.withCredentials ? "include" : "omit",
@@ -1489,19 +1488,17 @@ class LiveClient {
1489
1488
  }).pipe(
1490
1489
  rxjs.catchError(() => {
1491
1490
  throw new CorsOriginError({ projectId: projectId2 });
1492
- }),
1493
- operators.shareReplay(1)
1494
- // run only once
1491
+ })
1495
1492
  ), 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))),
1493
+ reconnectOnConnectionFailure(),
1494
+ rxjs.mergeMap((event) => event.type === "reconnect" ? checkCors.pipe(rxjs.mergeMap(() => rxjs.of(event))) : rxjs.of(event)),
1495
+ rxjs.catchError((err) => checkCors.pipe(
1498
1496
  rxjs.mergeMap(() => {
1499
- throw console.log("[live] throwing err from checkCors$", err), err;
1497
+ throw err;
1500
1498
  })
1501
- ))),
1502
- reconnectOnConnectionFailure(),
1499
+ )),
1503
1500
  operators.map((event) => {
1504
- if (console.log("event", event), event.type === "message") {
1501
+ if (event.type === "message") {
1505
1502
  const { data, ...rest } = event;
1506
1503
  return { ...rest, tags: data.tags };
1507
1504
  }