@sanity/client 7.5.0-live-cors.3 → 7.6.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 +7 -0
- package/dist/index.browser.cjs +3 -16
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +32 -2
- package/dist/index.browser.d.ts +32 -2
- package/dist/index.browser.js +3 -16
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +4 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +32 -2
- package/dist/index.d.ts +32 -2
- package/dist/index.js +4 -17
- package/dist/index.js.map +1 -1
- package/dist/stega.browser.d.cts +32 -2
- package/dist/stega.browser.d.ts +32 -2
- package/dist/stega.d.cts +32 -2
- package/dist/stega.d.ts +32 -2
- package/package.json +1 -1
- package/src/agent/actions/transform.ts +32 -2
- package/src/data/live.ts +3 -23
- package/umd/sanityClient.js +3 -16
- package/umd/sanityClient.min.js +2 -2
package/README.md
CHANGED
|
@@ -2138,6 +2138,13 @@ For example:
|
|
|
2138
2138
|
- `target: {path: ['wrapper', 'title'], operation: {type: 'image-description', sourcePath: ['array', {_key: 'abc'}, 'image'] }`
|
|
2139
2139
|
- `target: {path: ['wrapper'], include: ['portableTextField'], operation: {type: 'image-description', sourcePath: ['image', 'asset'] }, instruction: 'Use formatting and headings to describe the image in great detail' }`
|
|
2140
2140
|
|
|
2141
|
+
|
|
2142
|
+
###### Targeting images outside the document (URL)
|
|
2143
|
+
If the source image is available on a https URL outside the target document, it is possible to get a description for it using `imageUrl`.
|
|
2144
|
+
|
|
2145
|
+
Example:
|
|
2146
|
+
- `target: {path: ['description'], operation: operation: {type: 'image-description', imageUrL: 'https://www.sanity.io/static/images/favicons/android-icon-192x192.png?v=2' }`
|
|
2147
|
+
|
|
2141
2148
|
##### Example: Field-based transformation
|
|
2142
2149
|
|
|
2143
2150
|
```ts
|
package/dist/index.browser.cjs
CHANGED
|
@@ -1459,30 +1459,17 @@ class LiveClient {
|
|
|
1459
1459
|
}
|
|
1460
1460
|
return event;
|
|
1461
1461
|
})
|
|
1462
|
-
)
|
|
1463
|
-
console.log("YES THIS IS THE CORS VERSION with the allowed origin check");
|
|
1464
|
-
const isAllowedOrigin = (origin2) => [
|
|
1465
|
-
/^http:\/\/localhost:/,
|
|
1466
|
-
/^http:\/\/127\.0\.0\.1:/,
|
|
1467
|
-
/^https:\/\/[^.]*\.sanity\.studio$/,
|
|
1468
|
-
/^https:\/\/[^.]*\.studio\.sanity\.work$/,
|
|
1469
|
-
/^https:\/\/[^.]*\.sanity\.work$/,
|
|
1470
|
-
/^https:\/\/[^.]*\.sanity\.io$/
|
|
1471
|
-
].some((pattern) => pattern.test(origin2)), checkCors = fetchObservable(url, {
|
|
1462
|
+
), checkCors = fetchObservable(url, {
|
|
1472
1463
|
method: "OPTIONS",
|
|
1473
1464
|
mode: "cors",
|
|
1474
1465
|
credentials: esOptions.withCredentials ? "include" : "omit",
|
|
1475
|
-
headers:
|
|
1476
|
-
...esOptions.headers,
|
|
1477
|
-
"Access-Control-Request-Headers": "authorization"
|
|
1478
|
-
// for this preflight check, ensure we send what the browser would send if needed
|
|
1479
|
-
}
|
|
1466
|
+
headers: esOptions.headers
|
|
1480
1467
|
}).pipe(
|
|
1481
1468
|
rxjs.mergeMap(() => rxjs.EMPTY),
|
|
1482
1469
|
rxjs.catchError(() => {
|
|
1483
1470
|
throw new CorsOriginError({ projectId: projectId2 });
|
|
1484
1471
|
})
|
|
1485
|
-
),
|
|
1472
|
+
), observable = rxjs.concat(checkCors, events).pipe(
|
|
1486
1473
|
operators.finalize(() => eventsCache.delete(key)),
|
|
1487
1474
|
shareReplayLatest({
|
|
1488
1475
|
predicate: (event) => event.type === "welcome"
|