@sanity/client 6.14.1 → 6.14.2

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.
Files changed (53) hide show
  1. package/dist/_chunks/browserMiddleware-BHXO2Lcy.cjs +1491 -0
  2. package/dist/_chunks/{browserMiddleware-FpdqDQ1o.cjs.map → browserMiddleware-BHXO2Lcy.cjs.map} +1 -1
  3. package/dist/_chunks/browserMiddleware-jPnXCUlp.js +1474 -0
  4. package/dist/_chunks/{browserMiddleware-DhUBf_19.js.map → browserMiddleware-jPnXCUlp.js.map} +1 -1
  5. package/dist/_chunks/nodeMiddleware-CrO2pNEp.js +1491 -0
  6. package/dist/_chunks/{nodeMiddleware-BSZoKrW0.js.map → nodeMiddleware-CrO2pNEp.js.map} +1 -1
  7. package/dist/_chunks/nodeMiddleware-JJNfI4Rf.cjs +1508 -0
  8. package/dist/_chunks/{nodeMiddleware-DmcqX3kz.cjs.map → nodeMiddleware-JJNfI4Rf.cjs.map} +1 -1
  9. package/dist/_chunks/resolveEditInfo-BNCwZySb.cjs +284 -0
  10. package/dist/_chunks/{resolveEditInfo-BB1WiUDY.cjs.map → resolveEditInfo-BNCwZySb.cjs.map} +1 -1
  11. package/dist/_chunks/resolveEditInfo-qA5twkfC.js +285 -0
  12. package/dist/_chunks/{resolveEditInfo-Cf8D1Agp.js.map → resolveEditInfo-qA5twkfC.js.map} +1 -1
  13. package/dist/_chunks/stegaEncodeSourceMap-B9_uz7Zb.cjs +166 -0
  14. package/dist/_chunks/{stegaEncodeSourceMap-8TjLXjYU.cjs.map → stegaEncodeSourceMap-B9_uz7Zb.cjs.map} +1 -1
  15. package/dist/_chunks/stegaEncodeSourceMap-BvBJpbrr.cjs +329 -0
  16. package/dist/_chunks/{stegaEncodeSourceMap-DIcuvN0P.cjs.map → stegaEncodeSourceMap-BvBJpbrr.cjs.map} +1 -1
  17. package/dist/_chunks/stegaEncodeSourceMap-De3F_oJN.js +330 -0
  18. package/dist/_chunks/{stegaEncodeSourceMap-DLon0Yls.js.map → stegaEncodeSourceMap-De3F_oJN.js.map} +1 -1
  19. package/dist/_chunks/stegaEncodeSourceMap-bRxIGJ-b.js +168 -0
  20. package/dist/_chunks/{stegaEncodeSourceMap-DU95idpa.js.map → stegaEncodeSourceMap-bRxIGJ-b.js.map} +1 -1
  21. package/dist/csm.cjs +22 -56
  22. package/dist/csm.cjs.map +1 -1
  23. package/dist/csm.js +36 -54
  24. package/dist/csm.js.map +1 -1
  25. package/dist/index.browser.cjs +15 -21
  26. package/dist/index.browser.cjs.map +1 -1
  27. package/dist/index.browser.js +24 -15
  28. package/dist/index.browser.js.map +1 -1
  29. package/dist/index.cjs +15 -21
  30. package/dist/index.cjs.map +1 -1
  31. package/dist/index.js +24 -15
  32. package/dist/index.js.map +1 -1
  33. package/dist/stega.browser.cjs +12 -17
  34. package/dist/stega.browser.cjs.map +1 -1
  35. package/dist/stega.browser.js +26 -11
  36. package/dist/stega.browser.js.map +1 -1
  37. package/dist/stega.cjs +12 -17
  38. package/dist/stega.cjs.map +1 -1
  39. package/dist/stega.js +26 -11
  40. package/dist/stega.js.map +1 -1
  41. package/package.json +3 -3
  42. package/umd/sanityClient.js +2670 -3360
  43. package/umd/sanityClient.min.js +3 -3
  44. package/dist/_chunks/browserMiddleware-DhUBf_19.js +0 -1761
  45. package/dist/_chunks/browserMiddleware-FpdqDQ1o.cjs +0 -1777
  46. package/dist/_chunks/nodeMiddleware-BSZoKrW0.js +0 -1780
  47. package/dist/_chunks/nodeMiddleware-DmcqX3kz.cjs +0 -1796
  48. package/dist/_chunks/resolveEditInfo-BB1WiUDY.cjs +0 -422
  49. package/dist/_chunks/resolveEditInfo-Cf8D1Agp.js +0 -406
  50. package/dist/_chunks/stegaEncodeSourceMap-8TjLXjYU.cjs +0 -229
  51. package/dist/_chunks/stegaEncodeSourceMap-DIcuvN0P.cjs +0 -486
  52. package/dist/_chunks/stegaEncodeSourceMap-DLon0Yls.js +0 -482
  53. package/dist/_chunks/stegaEncodeSourceMap-DU95idpa.js +0 -225
@@ -1,406 +0,0 @@
1
- const rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
2
- const reKeySegment = /_key\s*==\s*['"](.*)['"]/;
3
- const reIndexTuple = /^\d*:\d*$/;
4
- function isIndexSegment(segment) {
5
- return typeof segment === "number" || typeof segment === "string" && /^\[\d+\]$/.test(segment);
6
- }
7
- function isKeySegment(segment) {
8
- if (typeof segment === "string") {
9
- return reKeySegment.test(segment.trim());
10
- }
11
- return typeof segment === "object" && "_key" in segment;
12
- }
13
- function isIndexTuple(segment) {
14
- if (typeof segment === "string" && reIndexTuple.test(segment)) {
15
- return true;
16
- }
17
- if (!Array.isArray(segment) || segment.length !== 2) {
18
- return false;
19
- }
20
- const [from, to] = segment;
21
- return (typeof from === "number" || from === "") && (typeof to === "number" || to === "");
22
- }
23
- function get(obj, path, defaultVal) {
24
- const select = typeof path === "string" ? fromString(path) : path;
25
- if (!Array.isArray(select)) {
26
- throw new Error("Path must be an array or a string");
27
- }
28
- let acc = obj;
29
- for (let i = 0; i < select.length; i++) {
30
- const segment = select[i];
31
- if (isIndexSegment(segment)) {
32
- if (!Array.isArray(acc)) {
33
- return defaultVal;
34
- }
35
- acc = acc[segment];
36
- }
37
- if (isKeySegment(segment)) {
38
- if (!Array.isArray(acc)) {
39
- return defaultVal;
40
- }
41
- acc = acc.find((item) => item._key === segment._key);
42
- }
43
- if (typeof segment === "string") {
44
- acc = typeof acc === "object" && acc !== null ? acc[segment] : void 0;
45
- }
46
- if (typeof acc === "undefined") {
47
- return defaultVal;
48
- }
49
- }
50
- return acc;
51
- }
52
- function toString(path) {
53
- if (!Array.isArray(path)) {
54
- throw new Error("Path is not an array");
55
- }
56
- return path.reduce((target, segment, i) => {
57
- const segmentType = typeof segment;
58
- if (segmentType === "number") {
59
- return `${target}[${segment}]`;
60
- }
61
- if (segmentType === "string") {
62
- const separator = i === 0 ? "" : ".";
63
- return `${target}${separator}${segment}`;
64
- }
65
- if (isKeySegment(segment) && segment._key) {
66
- return `${target}[_key=="${segment._key}"]`;
67
- }
68
- if (Array.isArray(segment)) {
69
- const [from, to] = segment;
70
- return `${target}[${from}:${to}]`;
71
- }
72
- throw new Error(`Unsupported path segment \`${JSON.stringify(segment)}\``);
73
- }, "");
74
- }
75
- function fromString(path) {
76
- if (typeof path !== "string") {
77
- throw new Error("Path is not a string");
78
- }
79
- const segments = path.match(rePropName);
80
- if (!segments) {
81
- throw new Error("Invalid path string");
82
- }
83
- return segments.map(parsePathSegment);
84
- }
85
- function parsePathSegment(segment) {
86
- if (isIndexSegment(segment)) {
87
- return parseIndexSegment(segment);
88
- }
89
- if (isKeySegment(segment)) {
90
- return parseKeySegment(segment);
91
- }
92
- if (isIndexTuple(segment)) {
93
- return parseIndexTupleSegment(segment);
94
- }
95
- return segment;
96
- }
97
- function parseIndexSegment(segment) {
98
- return Number(segment.replace(/[^\d]/g, ""));
99
- }
100
- function parseKeySegment(segment) {
101
- const segments = segment.match(reKeySegment);
102
- return { _key: segments[1] };
103
- }
104
- function parseIndexTupleSegment(segment) {
105
- const [from, to] = segment.split(":").map((seg) => seg === "" ? seg : Number(seg));
106
- return [from, to];
107
- }
108
-
109
- var studioPath = /*#__PURE__*/Object.freeze({
110
- __proto__: null,
111
- fromString: fromString,
112
- get: get,
113
- isIndexSegment: isIndexSegment,
114
- isIndexTuple: isIndexTuple,
115
- isKeySegment: isKeySegment,
116
- reKeySegment: reKeySegment,
117
- toString: toString
118
- });
119
-
120
- const DRAFTS_PREFIX = "drafts.";
121
- function getPublishedId(id) {
122
- if (id.startsWith(DRAFTS_PREFIX)) {
123
- return id.slice(DRAFTS_PREFIX.length);
124
- }
125
- return id;
126
- }
127
-
128
- const ESCAPE = {
129
- "\f": "\\f",
130
- "\n": "\\n",
131
- "\r": "\\r",
132
- " ": "\\t",
133
- "'": "\\'",
134
- "\\": "\\\\"
135
- };
136
- const UNESCAPE = {
137
- "\\f": "\f",
138
- "\\n": "\n",
139
- "\\r": "\r",
140
- "\\t": " ",
141
- "\\'": "'",
142
- "\\\\": "\\"
143
- };
144
- function jsonPath(path) {
145
- return `$${path.map((segment) => {
146
- if (typeof segment === "string") {
147
- const escapedKey = segment.replace(/[\f\n\r\t'\\]/g, (match) => {
148
- return ESCAPE[match];
149
- });
150
- return `['${escapedKey}']`;
151
- }
152
- if (typeof segment === "number") {
153
- return `[${segment}]`;
154
- }
155
- if (segment._key !== "") {
156
- const escapedKey = segment._key.replace(/['\\]/g, (match) => {
157
- return ESCAPE[match];
158
- });
159
- return `[?(@._key=='${escapedKey}')]`;
160
- }
161
- return `[${segment._index}]`;
162
- }).join("")}`;
163
- }
164
- function parseJsonPath(path) {
165
- const parsed = [];
166
- const parseRe = /\['(.*?)'\]|\[(\d+)\]|\[\?\(@\._key=='(.*?)'\)\]/g;
167
- let match;
168
- while ((match = parseRe.exec(path)) !== null) {
169
- if (match[1] !== void 0) {
170
- const key = match[1].replace(/\\(\\|f|n|r|t|')/g, (m) => {
171
- return UNESCAPE[m];
172
- });
173
- parsed.push(key);
174
- continue;
175
- }
176
- if (match[2] !== void 0) {
177
- parsed.push(parseInt(match[2], 10));
178
- continue;
179
- }
180
- if (match[3] !== void 0) {
181
- const _key = match[3].replace(/\\(\\')/g, (m) => {
182
- return UNESCAPE[m];
183
- });
184
- parsed.push({
185
- _key,
186
- _index: -1
187
- });
188
- continue;
189
- }
190
- }
191
- return parsed;
192
- }
193
- function jsonPathToStudioPath(path) {
194
- return path.map((segment) => {
195
- if (typeof segment === "string") {
196
- return segment;
197
- }
198
- if (typeof segment === "number") {
199
- return segment;
200
- }
201
- if (segment._key !== "") {
202
- return { _key: segment._key };
203
- }
204
- if (segment._index !== -1) {
205
- return segment._index;
206
- }
207
- throw new Error(`invalid segment:${JSON.stringify(segment)}`);
208
- });
209
- }
210
- function studioPathToJsonPath(path) {
211
- const parsedPath = typeof path === "string" ? fromString(path) : path;
212
- return parsedPath.map((segment) => {
213
- if (typeof segment === "string") {
214
- return segment;
215
- }
216
- if (typeof segment === "number") {
217
- return segment;
218
- }
219
- if (Array.isArray(segment)) {
220
- throw new Error(`IndexTuple segments aren't supported:${JSON.stringify(segment)}`);
221
- }
222
- if (isContentSourceMapParsedPathKeyedSegment(segment)) {
223
- return segment;
224
- }
225
- if (segment._key) {
226
- return { _key: segment._key, _index: -1 };
227
- }
228
- throw new Error(`invalid segment:${JSON.stringify(segment)}`);
229
- });
230
- }
231
- function isContentSourceMapParsedPathKeyedSegment(segment) {
232
- return typeof segment === "object" && "_key" in segment && "_index" in segment;
233
- }
234
- function jsonPathToMappingPath(path) {
235
- return path.map((segment) => {
236
- if (typeof segment === "string") {
237
- return segment;
238
- }
239
- if (typeof segment === "number") {
240
- return segment;
241
- }
242
- if (segment._index !== -1) {
243
- return segment._index;
244
- }
245
- throw new Error(`invalid segment:${JSON.stringify(segment)}`);
246
- });
247
- }
248
-
249
- function resolveMapping(resultPath, csm) {
250
- if (!(csm == null ? void 0 : csm.mappings)) {
251
- return void 0;
252
- }
253
- const resultMappingPath = jsonPath(jsonPathToMappingPath(resultPath));
254
- if (csm.mappings[resultMappingPath] !== void 0) {
255
- return {
256
- mapping: csm.mappings[resultMappingPath],
257
- matchedPath: resultMappingPath,
258
- pathSuffix: ""
259
- };
260
- }
261
- const mappings = Object.entries(csm.mappings).filter(([key]) => resultMappingPath.startsWith(key)).sort(([key1], [key2]) => key2.length - key1.length);
262
- if (mappings.length == 0) {
263
- return void 0;
264
- }
265
- const [matchedPath, mapping] = mappings[0];
266
- const pathSuffix = resultMappingPath.substring(matchedPath.length);
267
- return { mapping, matchedPath, pathSuffix };
268
- }
269
-
270
- function isArray(value) {
271
- return value !== null && Array.isArray(value);
272
- }
273
-
274
- function isRecord(value) {
275
- return typeof value === "object" && value !== null;
276
- }
277
-
278
- function walkMap(value, mappingFn, path = []) {
279
- if (isArray(value)) {
280
- return value.map((v, idx) => {
281
- if (isRecord(v)) {
282
- const _key = v["_key"];
283
- if (typeof _key === "string") {
284
- return walkMap(v, mappingFn, path.concat({ _key, _index: idx }));
285
- }
286
- }
287
- return walkMap(v, mappingFn, path.concat(idx));
288
- });
289
- }
290
- if (isRecord(value)) {
291
- return Object.fromEntries(
292
- Object.entries(value).map(([k, v]) => [k, walkMap(v, mappingFn, path.concat(k))])
293
- );
294
- }
295
- return mappingFn(value, path);
296
- }
297
-
298
- function createEditUrl(options) {
299
- const {
300
- baseUrl,
301
- workspace: _workspace = "default",
302
- tool: _tool = "default",
303
- id: _id,
304
- type,
305
- path,
306
- projectId,
307
- dataset
308
- } = options;
309
- if (!baseUrl) {
310
- throw new Error("baseUrl is required");
311
- }
312
- if (!path) {
313
- throw new Error("path is required");
314
- }
315
- if (!_id) {
316
- throw new Error("id is required");
317
- }
318
- if (baseUrl !== "/" && baseUrl.endsWith("/")) {
319
- throw new Error("baseUrl must not end with a slash");
320
- }
321
- const workspace = _workspace === "default" ? void 0 : _workspace;
322
- const tool = _tool === "default" ? void 0 : _tool;
323
- const id = getPublishedId(_id);
324
- const stringifiedPath = Array.isArray(path) ? toString(jsonPathToStudioPath(path)) : path;
325
- const searchParams = new URLSearchParams({
326
- baseUrl,
327
- id,
328
- type,
329
- path: stringifiedPath
330
- });
331
- if (workspace) {
332
- searchParams.set("workspace", workspace);
333
- }
334
- if (tool) {
335
- searchParams.set("tool", tool);
336
- }
337
- if (projectId) {
338
- searchParams.set("projectId", projectId);
339
- }
340
- if (dataset) {
341
- searchParams.set("dataset", dataset);
342
- }
343
- const segments = [baseUrl === "/" ? "" : baseUrl];
344
- if (workspace) {
345
- segments.push(workspace);
346
- }
347
- const routerParams = [
348
- "mode=presentation",
349
- `id=${id}`,
350
- `type=${type}`,
351
- `path=${encodeURIComponent(stringifiedPath)}`
352
- ];
353
- if (tool) {
354
- routerParams.push(`tool=${tool}`);
355
- }
356
- segments.push("intent", "edit", `${routerParams.join(";")}?${searchParams}`);
357
- return segments.join("/");
358
- }
359
-
360
- function resolveEditInfo(options) {
361
- const { resultSourceMap: csm, resultPath } = options;
362
- const { mapping, pathSuffix } = resolveMapping(resultPath, csm) || {};
363
- if (!mapping) {
364
- return void 0;
365
- }
366
- if (mapping.source.type === "literal") {
367
- return void 0;
368
- }
369
- if (mapping.source.type === "unknown") {
370
- return void 0;
371
- }
372
- const sourceDoc = csm.documents[mapping.source.document];
373
- const sourcePath = csm.paths[mapping.source.path];
374
- if (sourceDoc && sourcePath) {
375
- const { baseUrl, workspace, tool } = resolveStudioBaseRoute(
376
- typeof options.studioUrl === "function" ? options.studioUrl(sourceDoc) : options.studioUrl
377
- );
378
- if (!baseUrl)
379
- return void 0;
380
- const { _id, _type, _projectId, _dataset } = sourceDoc;
381
- return {
382
- baseUrl,
383
- workspace,
384
- tool,
385
- id: _id,
386
- type: _type,
387
- path: parseJsonPath(sourcePath + pathSuffix),
388
- projectId: _projectId,
389
- dataset: _dataset
390
- };
391
- }
392
- return void 0;
393
- }
394
- function resolveStudioBaseRoute(studioUrl) {
395
- let baseUrl = typeof studioUrl === "string" ? studioUrl : studioUrl.baseUrl;
396
- if (baseUrl !== "/") {
397
- baseUrl = baseUrl.replace(/\/$/, "");
398
- }
399
- if (typeof studioUrl === "string") {
400
- return { baseUrl };
401
- }
402
- return { ...studioUrl, baseUrl };
403
- }
404
-
405
- export { DRAFTS_PREFIX, createEditUrl, get, getPublishedId, jsonPath, jsonPathToStudioPath, parseJsonPath, reKeySegment, resolveEditInfo, resolveMapping, resolveStudioBaseRoute, studioPath, studioPathToJsonPath, toString, walkMap };
406
- //# sourceMappingURL=resolveEditInfo-Cf8D1Agp.js.map
@@ -1,229 +0,0 @@
1
- 'use strict';
2
-
3
- var nodeMiddleware = require('./nodeMiddleware-DmcqX3kz.cjs');
4
- var resolveEditInfo = require('./resolveEditInfo-BB1WiUDY.cjs');
5
-
6
- function encodeIntoResult(result, csm, encoder) {
7
- return resolveEditInfo.walkMap(result, (value, path) => {
8
- if (typeof value !== "string") {
9
- return value;
10
- }
11
- const resolveMappingResult = resolveEditInfo.resolveMapping(path, csm);
12
- if (!resolveMappingResult) {
13
- return value;
14
- }
15
- const { mapping, matchedPath } = resolveMappingResult;
16
- if (mapping.type !== "value") {
17
- return value;
18
- }
19
- if (mapping.source.type !== "documentValue") {
20
- return value;
21
- }
22
- const sourceDocument = csm.documents[mapping.source.document];
23
- const sourcePath = csm.paths[mapping.source.path];
24
- const matchPathSegments = resolveEditInfo.parseJsonPath(matchedPath);
25
- const sourcePathSegments = resolveEditInfo.parseJsonPath(sourcePath);
26
- const fullSourceSegments = sourcePathSegments.concat(path.slice(matchPathSegments.length));
27
- return encoder({
28
- sourcePath: fullSourceSegments,
29
- sourceDocument,
30
- resultPath: path,
31
- value
32
- });
33
- });
34
- }
35
-
36
- const filterDefault = ({ sourcePath, value }) => {
37
- if (isValidDate(value) || isValidURL(value)) {
38
- return false;
39
- }
40
- const endPath = sourcePath.at(-1);
41
- if (sourcePath.at(-2) === "slug" && endPath === "current") {
42
- return false;
43
- }
44
- if (typeof endPath === "string" && endPath.startsWith("_")) {
45
- return false;
46
- }
47
- if (typeof endPath === "number" && sourcePath.at(-2) === "marks") {
48
- return false;
49
- }
50
- if (endPath === "href" && typeof sourcePath.at(-2) === "number" && sourcePath.at(-3) === "markDefs") {
51
- return false;
52
- }
53
- if (endPath === "style" || endPath === "listItem") {
54
- return false;
55
- }
56
- if (sourcePath.some(
57
- (path) => path === "meta" || path === "metadata" || path === "openGraph" || path === "seo"
58
- )) {
59
- return false;
60
- }
61
- if (typeof endPath === "string" && denylist.has(endPath)) {
62
- return false;
63
- }
64
- return true;
65
- };
66
- const denylist = /* @__PURE__ */ new Set([
67
- "color",
68
- "colour",
69
- "currency",
70
- "email",
71
- "format",
72
- "gid",
73
- "hex",
74
- "href",
75
- "hsl",
76
- "hsla",
77
- "icon",
78
- "id",
79
- "index",
80
- "key",
81
- "language",
82
- "layout",
83
- "link",
84
- "linkAction",
85
- "locale",
86
- "lqip",
87
- "page",
88
- "path",
89
- "ref",
90
- "rgb",
91
- "rgba",
92
- "route",
93
- "secret",
94
- "slug",
95
- "status",
96
- "tag",
97
- "template",
98
- "theme",
99
- "type",
100
- "unit",
101
- "url",
102
- "username",
103
- "variant",
104
- "website"
105
- ]);
106
- function isValidDate(dateString) {
107
- return /^\d{4}-\d{2}-\d{2}/.test(dateString) ? Boolean(Date.parse(dateString)) : false;
108
- }
109
- function isValidURL(url) {
110
- try {
111
- new URL(url, url.startsWith("/") ? "https://acme.com" : void 0);
112
- } catch {
113
- return false;
114
- }
115
- return true;
116
- }
117
-
118
- const TRUNCATE_LENGTH = 20;
119
- function stegaEncodeSourceMap(result, resultSourceMap, config) {
120
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
121
- const { filter, logger, enabled } = config;
122
- if (!enabled) {
123
- const msg = "config.enabled must be true, don't call this function otherwise";
124
- (_a = logger == null ? void 0 : logger.error) == null ? void 0 : _a.call(logger, `[@sanity/client]: ${msg}`, { result, resultSourceMap, config });
125
- throw new TypeError(msg);
126
- }
127
- if (!resultSourceMap) {
128
- (_b = logger == null ? void 0 : logger.error) == null ? void 0 : _b.call(logger, "[@sanity/client]: Missing Content Source Map from response body", {
129
- result,
130
- resultSourceMap,
131
- config
132
- });
133
- return result;
134
- }
135
- if (!config.studioUrl) {
136
- const msg = "config.studioUrl must be defined";
137
- (_c = logger == null ? void 0 : logger.error) == null ? void 0 : _c.call(logger, `[@sanity/client]: ${msg}`, { result, resultSourceMap, config });
138
- throw new TypeError(msg);
139
- }
140
- const report = {
141
- encoded: [],
142
- skipped: []
143
- };
144
- const resultWithStega = encodeIntoResult(
145
- result,
146
- resultSourceMap,
147
- ({ sourcePath, sourceDocument, resultPath, value }) => {
148
- if ((typeof filter === "function" ? filter({ sourcePath, resultPath, filterDefault, sourceDocument, value }) : filterDefault({ sourcePath, resultPath, filterDefault, sourceDocument, value })) === false) {
149
- if (logger) {
150
- report.skipped.push({
151
- path: prettyPathForLogging(sourcePath),
152
- value: `${value.slice(0, TRUNCATE_LENGTH)}${value.length > TRUNCATE_LENGTH ? "..." : ""}`,
153
- length: value.length
154
- });
155
- }
156
- return value;
157
- }
158
- if (logger) {
159
- report.encoded.push({
160
- path: prettyPathForLogging(sourcePath),
161
- value: `${value.slice(0, TRUNCATE_LENGTH)}${value.length > TRUNCATE_LENGTH ? "..." : ""}`,
162
- length: value.length
163
- });
164
- }
165
- const { baseUrl, workspace, tool } = resolveEditInfo.resolveStudioBaseRoute(
166
- typeof config.studioUrl === "function" ? config.studioUrl(sourceDocument) : config.studioUrl
167
- );
168
- if (!baseUrl)
169
- return value;
170
- const { _id: id, _type: type, _projectId: projectId, _dataset: dataset } = sourceDocument;
171
- return nodeMiddleware.b(
172
- value,
173
- {
174
- origin: "sanity.io",
175
- href: resolveEditInfo.createEditUrl({
176
- baseUrl,
177
- workspace,
178
- tool,
179
- id,
180
- type,
181
- path: sourcePath,
182
- ...!config.omitCrossDatasetReferenceData && { dataset, projectId }
183
- })
184
- },
185
- // We use custom logic to determine if we should skip encoding
186
- false
187
- );
188
- }
189
- );
190
- if (logger) {
191
- const isSkipping = report.skipped.length;
192
- const isEncoding = report.encoded.length;
193
- if (isSkipping || isEncoding) {
194
- (_d = (logger == null ? void 0 : logger.groupCollapsed) || logger.log) == null ? void 0 : _d("[@sanity/client]: Encoding source map into result");
195
- (_e = logger.log) == null ? void 0 : _e.call(
196
- logger,
197
- `[@sanity/client]: Paths encoded: ${report.encoded.length}, skipped: ${report.skipped.length}`
198
- );
199
- }
200
- if (report.encoded.length > 0) {
201
- (_f = logger == null ? void 0 : logger.log) == null ? void 0 : _f.call(logger, `[@sanity/client]: Table of encoded paths`);
202
- (_g = (logger == null ? void 0 : logger.table) || logger.log) == null ? void 0 : _g(report.encoded);
203
- }
204
- if (report.skipped.length > 0) {
205
- const skipped = /* @__PURE__ */ new Set();
206
- for (const { path } of report.skipped) {
207
- skipped.add(path.replace(resolveEditInfo.reKeySegment, "0").replace(/\[\d+\]/g, "[]"));
208
- }
209
- (_h = logger == null ? void 0 : logger.log) == null ? void 0 : _h.call(logger, `[@sanity/client]: List of skipped paths`, [...skipped.values()]);
210
- }
211
- if (isSkipping || isEncoding) {
212
- (_i = logger == null ? void 0 : logger.groupEnd) == null ? void 0 : _i.call(logger);
213
- }
214
- }
215
- return resultWithStega;
216
- }
217
- function prettyPathForLogging(path) {
218
- return resolveEditInfo.toString(resolveEditInfo.jsonPathToStudioPath(path));
219
- }
220
-
221
- var stegaEncodeSourceMap$1 = /*#__PURE__*/Object.freeze({
222
- __proto__: null,
223
- stegaEncodeSourceMap: stegaEncodeSourceMap
224
- });
225
-
226
- exports.encodeIntoResult = encodeIntoResult;
227
- exports.stegaEncodeSourceMap = stegaEncodeSourceMap;
228
- exports.stegaEncodeSourceMap$1 = stegaEncodeSourceMap$1;
229
- //# sourceMappingURL=stegaEncodeSourceMap-8TjLXjYU.cjs.map