@b10cks/client 1.3.0 → 1.5.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.mjs CHANGED
@@ -1,14 +1,28 @@
1
- function p(s) {
2
- if (s != null) {
3
- if (typeof s == "boolean" || typeof s == "number") return String(s);
4
- if (typeof s == "string") return s;
5
- if (typeof s == "object" && !Array.isArray(s)) {
6
- const t = s;
1
+ function _(i) {
2
+ if (!i) return;
3
+ if (i.type === "email") {
4
+ const n = new URLSearchParams();
5
+ i.subject && n.set("subject", i.subject), i.body && n.set("body", i.body), i.cc && n.set("cc", i.cc), i.bcc && n.set("bcc", i.bcc);
6
+ const s = n.toString();
7
+ return { href: `mailto:${i.email}${s ? `?${s}` : ""}`, target: "_self" };
8
+ }
9
+ if (i.type === "asset")
10
+ return;
11
+ const t = i.target ?? "_self";
12
+ let e = i.url ?? "";
13
+ return "anchor" in i && i.anchor && (e = `${e.trimEnd()}#${i.anchor}`), { href: e, target: t };
14
+ }
15
+ function A(i) {
16
+ if (i != null) {
17
+ if (typeof i == "boolean" || typeof i == "number") return String(i);
18
+ if (typeof i == "string") return i;
19
+ if (typeof i == "object" && !Array.isArray(i)) {
20
+ const t = i;
7
21
  if ("null" in t) return "null:";
8
22
  if ("!null" in t) return "!null:";
9
23
  if ("between" in t) {
10
- const [i, n] = t.between;
11
- return `${i}...${n}`;
24
+ const [n, s] = t.between;
25
+ return `${n}...${s}`;
12
26
  }
13
27
  const e = [
14
28
  "eq",
@@ -26,50 +40,50 @@ function p(s) {
26
40
  "empty",
27
41
  "!empty"
28
42
  ];
29
- for (const i of e)
30
- if (i in t) {
31
- const n = t[i];
32
- return Array.isArray(n) ? `${i}:${n.join(",")}` : `${i}:${String(n)}`;
43
+ for (const n of e)
44
+ if (n in t) {
45
+ const s = t[n];
46
+ return Array.isArray(s) ? `${n}:${s.join(",")}` : `${n}:${String(s)}`;
33
47
  }
34
48
  }
35
49
  }
36
50
  }
37
- function R(s) {
51
+ function S(i) {
38
52
  const t = {};
39
- for (const [e, i] of Object.entries(s)) {
40
- const n = p(i);
41
- n !== void 0 && (t[e] = n);
53
+ for (const [e, n] of Object.entries(i)) {
54
+ const s = A(n);
55
+ s !== void 0 && (t[e] = s);
42
56
  }
43
57
  return t;
44
58
  }
45
- function h(s, t, e) {
46
- const i = t && typeof t == "object" ? R(t) : {}, n = Array.isArray(e) ? { sort: e.join(",") } : e != null ? { sort: e } : {};
47
- return { ...s, ...i, ...n };
59
+ function g(i, t, e) {
60
+ const n = t && typeof t == "object" ? S(t) : {}, s = Array.isArray(e) ? { sort: e.join(",") } : e != null ? { sort: e } : {};
61
+ return { ...i, ...n, ...s };
48
62
  }
49
- class v {
63
+ class P {
50
64
  constructor(t) {
51
65
  this.client = t;
52
66
  }
53
67
  redirectsCache = null;
54
68
  configCache = /* @__PURE__ */ new Map();
55
69
  async getResource(t, e = {}) {
56
- const i = await this.client.get(t, e);
57
- return this.unwrapResource(i);
70
+ const n = await this.client.get(t, e);
71
+ return this.unwrapResource(n);
58
72
  }
59
- async getCollection(t, e = {}, i = {}) {
60
- if (i.allPages)
73
+ async getCollection(t, e = {}, n = {}) {
74
+ if (n.allPages)
61
75
  return this.client.getAll(t, e);
62
- const n = await this.client.get(t, e);
63
- return this.unwrapCollection(n);
76
+ const s = await this.client.get(t, e);
77
+ return this.unwrapCollection(s);
64
78
  }
65
79
  async getContent(t, e = {}) {
66
80
  return this.getResource(`contents/${t}`, e);
67
81
  }
68
82
  async getContents(t = {}, e = {}) {
69
- const { filter: i, sort: n, ...r } = t;
83
+ const { filter: n, sort: s, ...r } = t;
70
84
  return this.getCollection(
71
85
  "contents",
72
- h(r, i, n),
86
+ g(r, n, s),
73
87
  e
74
88
  );
75
89
  }
@@ -77,10 +91,10 @@ class v {
77
91
  return this.getResource(`blocks/${t}`, e);
78
92
  }
79
93
  async getBlocks(t = {}, e = {}) {
80
- const { filter: i, ...n } = t;
94
+ const { filter: n, ...s } = t;
81
95
  return this.getCollection(
82
96
  "blocks",
83
- h(n, i, void 0),
97
+ g(s, n, void 0),
84
98
  e
85
99
  );
86
100
  }
@@ -92,17 +106,17 @@ class v {
92
106
  if (typeof e == "object" && e !== null && "data" in e && "meta" in e)
93
107
  return e;
94
108
  if (typeof e == "object" && e !== null && "data" in e) {
95
- const i = e.data;
96
- if (typeof i == "object" && i !== null && "meta" in i && "data" in i)
97
- return i;
109
+ const n = e.data;
110
+ if (typeof n == "object" && n !== null && "meta" in n && "data" in n)
111
+ return n;
98
112
  }
99
113
  return e;
100
114
  }
101
115
  async getSitemap(t = {}, e = {}) {
102
116
  return this.getCollection("sitemap", t, e);
103
117
  }
104
- async getDataEntries(t, e = {}, i = {}) {
105
- return this.getCollection(`datasources/${t}/entries`, e, i);
118
+ async getDataEntries(t, e = {}, n = {}) {
119
+ return this.getCollection(`datasources/${t}/entries`, e, n);
106
120
  }
107
121
  async getDataSources(t = {}, e = {}) {
108
122
  return this.getCollection("datasources", t, e);
@@ -118,33 +132,33 @@ class v {
118
132
  return this.client.post("redirects/lookup", { source: t });
119
133
  }
120
134
  async getRedirects(t = {}, e = !1) {
121
- const { allPages: i = !1, forceRefresh: n = !1 } = typeof e == "boolean" ? { allPages: !0, forceRefresh: e } : e;
122
- if (i && this.redirectsCache && !n)
135
+ const { allPages: n = !1, forceRefresh: s = !1 } = typeof e == "boolean" ? { allPages: !0, forceRefresh: e } : e;
136
+ if (n && this.redirectsCache && !s)
123
137
  return this.redirectsCache;
124
- const { filter: r, ...o } = t, a = h(o, r, void 0), f = await this.getCollection("redirects", a, { allPages: i }), l = Object.fromEntries(
125
- f.map(({ source: d, target: g, status_code: y }) => [d, { target: g, status_code: y }])
138
+ const { filter: r, ...o } = t, a = g(o, r, void 0), c = await this.getCollection("redirects", a, { allPages: n }), d = Object.fromEntries(
139
+ c.map(({ source: p, target: u, status_code: f }) => [p, { target: u, status_code: f }])
126
140
  );
127
- return i && (this.redirectsCache = l), l;
141
+ return n && (this.redirectsCache = d), d;
128
142
  }
129
143
  async getConfig({
130
144
  slug: t = "_config",
131
145
  language_iso: e,
132
- language: i,
133
- bypassCache: n = !1,
146
+ language: n,
147
+ bypassCache: s = !1,
134
148
  ...r
135
149
  } = {}) {
136
- const o = e ?? i, a = JSON.stringify({ slug: t, language_iso: o, ...r });
137
- if (!n && this.configCache.has(a))
150
+ const o = e ?? n, a = JSON.stringify({ slug: t, language_iso: o, ...r });
151
+ if (!s && this.configCache.has(a))
138
152
  return this.configCache.get(a);
139
- const l = (await this.getContent(t, {
153
+ const d = (await this.getContent(t, {
140
154
  ...r,
141
155
  language_iso: o
142
156
  })).content ?? {};
143
- return n || this.configCache.set(a, l), l;
157
+ return s || this.configCache.set(a, d), d;
144
158
  }
145
159
  async syncRevision(t = 426713400) {
146
- const i = (await this.getSpace()).rv || t;
147
- return this.client.setRv(i), i;
160
+ const n = (await this.getSpace()).rv || t;
161
+ return this.client.setRv(n), n;
148
162
  }
149
163
  clearCache() {
150
164
  this.redirectsCache = null, this.configCache.clear();
@@ -164,23 +178,34 @@ class v {
164
178
  return [];
165
179
  }
166
180
  }
167
- function w(s) {
168
- return new v(s);
181
+ function L(i) {
182
+ return new P(i);
169
183
  }
170
- class c {
184
+ const T = /* @__PURE__ */ new Set([
185
+ "CONTENT_UPDATE",
186
+ "CONTENT_PATCH",
187
+ "SELECT_UPDATE",
188
+ "HOVER_UPDATE",
189
+ "FIELD_UPDATE",
190
+ "FIELD_SELECT"
191
+ ]), j = "B10CKS_BRIDGE_READY";
192
+ class h {
171
193
  static instance;
172
194
  listeners = {};
173
195
  initialized = !1;
196
+ allowedOrigins = null;
197
+ /** Origin of the editor, captured from the first trusted message. */
198
+ parentOrigin = null;
174
199
  constructor() {
175
200
  }
176
201
  static getInstance() {
177
- return c.instance || (c.instance = new c()), c.instance;
202
+ return h.instance || (h.instance = new h()), h.instance;
178
203
  }
179
- init() {
180
- !this.isInPreviewMode() || this.initialized || (window.addEventListener("message", this.handleMessage), this.initialized = !0);
204
+ init(t = {}) {
205
+ !this.isInPreviewMode() || this.initialized || (this.allowedOrigins = t.allowedOrigins ?? null, window.addEventListener("message", this.handleMessage), this.initialized = !0, window.parent.postMessage({ type: j }, "*"));
181
206
  }
182
207
  destroy() {
183
- this.initialized && typeof window < "u" && window.removeEventListener("message", this.handleMessage), this.initialized = !1;
208
+ this.initialized && typeof window < "u" && window.removeEventListener("message", this.handleMessage), this.initialized = !1, this.parentOrigin = null;
184
209
  for (const t of Object.keys(this.listeners))
185
210
  this.listeners[t]?.clear();
186
211
  }
@@ -191,84 +216,279 @@ class c {
191
216
  if (!this.isInPreviewMode())
192
217
  return () => {
193
218
  };
194
- const i = this.listeners[t] || /* @__PURE__ */ new Set();
195
- return this.listeners[t] = i, i.add(e), () => {
196
- i.delete(e);
219
+ const n = this.listeners[t] || /* @__PURE__ */ new Set();
220
+ return this.listeners[t] = n, n.add(e), () => {
221
+ n.delete(e);
197
222
  };
198
223
  }
199
224
  selectItem(t) {
200
- this.isInPreviewMode() && window.parent.postMessage(
201
- {
202
- type: "SELECT_UPDATE",
203
- payload: { selectedItem: t }
204
- },
205
- "*"
206
- );
225
+ this.post("SELECT_UPDATE", { selectedItem: t });
207
226
  }
208
- updateField(t, e, i) {
209
- this.isInPreviewMode() && window.parent.postMessage(
210
- {
211
- type: "FIELD_UPDATE",
212
- payload: { itemId: t, field: e, value: i }
213
- },
214
- "*"
215
- );
227
+ /** Deep-select a nested field (e.g. a rich text field) in the editor. */
228
+ selectField(t, e) {
229
+ this.post("FIELD_SELECT", { itemId: t, path: e });
230
+ }
231
+ /** @deprecated Prefer {@link updateFieldAt} with a path. */
232
+ updateField(t, e, n) {
233
+ this.post("FIELD_UPDATE", { itemId: t, field: e, value: n });
234
+ }
235
+ /** Stream an inline edit back to the editor, addressed by path. */
236
+ updateFieldAt(t, e, n) {
237
+ this.post("FIELD_UPDATE", { itemId: t, path: e, value: n });
238
+ }
239
+ post(t, e) {
240
+ this.isInPreviewMode() && window.parent.postMessage({ type: t, payload: e }, this.parentOrigin ?? "*");
216
241
  }
217
242
  handleMessage = (t) => {
218
- if (!t.data || typeof t.data != "object")
243
+ if (!this.isOriginTrusted(t.origin) || !t.data || typeof t.data != "object")
219
244
  return;
220
- const { type: e, payload: i } = t.data;
221
- !e || !i || this.notify(e, i);
245
+ const { type: e, payload: n } = t.data;
246
+ !e || !T.has(e) || !n || (!this.parentOrigin && t.origin && t.origin !== "null" && (this.parentOrigin = t.origin), this.notify(e, n));
222
247
  };
248
+ isOriginTrusted(t) {
249
+ return this.parentOrigin ? t === this.parentOrigin : this.allowedOrigins ? this.allowedOrigins.includes(t) : !0;
250
+ }
223
251
  notify(t, e) {
224
- const i = this.listeners[t];
225
- if (i)
226
- for (const n of i)
227
- n(e);
252
+ const n = this.listeners[t];
253
+ if (n)
254
+ for (const s of n)
255
+ s(e);
256
+ }
257
+ }
258
+ const l = h.getInstance(), v = "b10cks-preview-style", C = "--b10cks-scroll-offset";
259
+ function E() {
260
+ if (typeof document > "u" || document.getElementById(v))
261
+ return;
262
+ const i = document.createElement("style");
263
+ i.id = v, i.textContent = `
264
+ .b10cks-preview { scroll-margin-top: var(${C}, 0px); }
265
+ .b10cks-hover,
266
+ .b10cks-preview:hover {
267
+ outline: 2px dashed rgba(59, 130, 246, 0.5);
268
+ outline-offset: 2px;
269
+ }
270
+ .b10cks-selected {
271
+ outline: 2px solid rgb(59, 130, 246) !important;
272
+ outline-offset: 2px;
273
+ }
274
+ `, document.head.appendChild(i);
275
+ }
276
+ function F(i) {
277
+ if (typeof document > "u")
278
+ return;
279
+ const t = typeof i == "number" ? `${i}px` : i;
280
+ document.documentElement.style.setProperty(C, t);
281
+ }
282
+ function O(i, t) {
283
+ if (!l.isInPreviewMode() || !t.id)
284
+ return () => {
285
+ };
286
+ E();
287
+ const { id: e, onSelectChange: n, onHoverChange: s, scrollOnSelect: r = !0 } = t;
288
+ i.classList.add("b10cks-preview");
289
+ const o = (u) => {
290
+ u.preventDefault(), u.stopPropagation(), l.selectItem(e);
291
+ }, a = ({ selectedItem: u }) => {
292
+ const f = u === e;
293
+ i.classList.toggle("b10cks-selected", f), f && r && k(i), n?.(f);
294
+ }, c = ({ selectedItem: u }) => {
295
+ const f = u === e;
296
+ i.classList.toggle("b10cks-hover", f), s?.(f);
297
+ };
298
+ i.addEventListener("click", o);
299
+ const d = l.on("SELECT_UPDATE", a), p = l.on("HOVER_UPDATE", c);
300
+ return () => {
301
+ i.removeEventListener("click", o), d(), p(), i.classList.remove("b10cks-preview", "b10cks-selected", "b10cks-hover");
302
+ };
303
+ }
304
+ function $(i, t) {
305
+ if (!l.isInPreviewMode() || !t.id)
306
+ return () => {
307
+ };
308
+ const { id: e, field: n, path: s, mode: r = "inline" } = t;
309
+ if (r === "select") {
310
+ E(), i.classList.add("b10cks-preview");
311
+ const a = (c) => {
312
+ c.preventDefault(), c.stopPropagation(), s ? l.selectField(e, s) : l.selectItem(e);
313
+ };
314
+ return i.addEventListener("click", a), () => {
315
+ i.removeEventListener("click", a), i.classList.remove("b10cks-preview");
316
+ };
317
+ }
318
+ i.setAttribute("contenteditable", "true");
319
+ const o = (a) => {
320
+ const c = a.target.innerText;
321
+ s ? l.updateFieldAt(e, s, c) : l.updateField(e, n ?? "", c);
322
+ };
323
+ return i.addEventListener("input", o), () => {
324
+ i.removeEventListener("input", o), i.removeAttribute("contenteditable");
325
+ };
326
+ }
327
+ function k(i) {
328
+ typeof i.scrollIntoView == "function" && i.scrollIntoView({ block: "nearest", behavior: "smooth" });
329
+ }
330
+ function D(i, t) {
331
+ let e = i;
332
+ for (const n of t) {
333
+ if (e == null || typeof e != "object")
334
+ return;
335
+ e = e[n];
336
+ }
337
+ return e;
338
+ }
339
+ function m(i, t, e) {
340
+ if (t.length === 0)
341
+ return e;
342
+ const [n, ...s] = t;
343
+ if (n === void 0)
344
+ return e;
345
+ if (typeof n == "number") {
346
+ const o = Array.isArray(i) ? i.slice() : [];
347
+ return o[n] = m(o[n], s, e), o;
348
+ }
349
+ const r = i && typeof i == "object" && !Array.isArray(i) ? { ...i } : {};
350
+ return r[n] = m(r[n], s, e), r;
351
+ }
352
+ class I {
353
+ content;
354
+ listeners = /* @__PURE__ */ new Set();
355
+ constructor(t) {
356
+ this.content = t;
357
+ }
358
+ subscribe = (t) => (this.listeners.add(t), () => {
359
+ this.listeners.delete(t);
360
+ });
361
+ getSnapshot = () => this.content;
362
+ setContent(t) {
363
+ this.content = t, this.emit();
364
+ }
365
+ patch(t, e) {
366
+ this.content = m(this.content, t, e), this.emit();
367
+ }
368
+ emit() {
369
+ for (const t of this.listeners)
370
+ t();
371
+ }
372
+ }
373
+ function U(i) {
374
+ const t = l.on("CONTENT_UPDATE", ({ content: n }) => {
375
+ i.setContent(n);
376
+ }), e = l.on("CONTENT_PATCH", ({ path: n, value: s }) => {
377
+ i.patch(n, s);
378
+ });
379
+ return () => {
380
+ t(), e();
381
+ };
382
+ }
383
+ function w(i) {
384
+ return (i ?? "").trim().replace(/^\/+|\/+$/g, "");
385
+ }
386
+ function R(i, t) {
387
+ const e = w(i), n = w(t);
388
+ if (!n)
389
+ return e && e !== "home" ? `/${e}` : "/";
390
+ if (!e || e === "home")
391
+ return `/${n}`;
392
+ const s = `${n}/`;
393
+ return e === n || e.startsWith(s) ? `/${e}` : `/${n}/${e}`;
394
+ }
395
+ function b(i, t) {
396
+ if (!t) return null;
397
+ try {
398
+ return new URL(i, t).toString();
399
+ } catch {
400
+ return null;
228
401
  }
229
402
  }
230
- const b = c.getInstance(), C = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
403
+ function y(i) {
404
+ return i.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
405
+ }
406
+ function x(i, t = {}) {
407
+ const { siteUrl: e, locale: n } = t, s = /* @__PURE__ */ new Set();
408
+ return i.filter((r) => {
409
+ if (n && r.language_iso !== n || r.meta?.robots?.toLowerCase().includes("noindex")) return !1;
410
+ const o = R(r.full_slug, r.language_iso), a = e ? b(o, e) ?? o : o;
411
+ return s.has(a) ? !1 : (s.add(a), !0);
412
+ });
413
+ }
414
+ function z(i, t) {
415
+ return [
416
+ '<?xml version="1.0" encoding="UTF-8"?>',
417
+ '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">',
418
+ i.map((n) => {
419
+ const s = R(n.full_slug, n.language_iso), r = t ? b(s, t) : s;
420
+ if (!r) return "";
421
+ const o = [" <url>", ` <loc>${y(r)}</loc>`];
422
+ return n.published_at && o.push(` <lastmod>${y(n.published_at)}</lastmod>`), o.push(" </url>"), o.join(`
423
+ `);
424
+ }).filter(Boolean).join(`
425
+ `),
426
+ "</urlset>"
427
+ ].join(`
428
+ `);
429
+ }
430
+ function M(i, t) {
431
+ return [
432
+ '<?xml version="1.0" encoding="UTF-8"?>',
433
+ '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">',
434
+ i.map((n) => {
435
+ const s = t ? b(n, t) : n;
436
+ return s ? [" <sitemap>", ` <loc>${y(s)}</loc>`, " </sitemap>"].join(`
437
+ `) : "";
438
+ }).filter(Boolean).join(`
439
+ `),
440
+ "</sitemapindex>"
441
+ ].join(`
442
+ `);
443
+ }
444
+ const N = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
231
445
  __proto__: null
232
446
  }, Symbol.toStringTag, { value: "Module" }));
233
- let u = 0;
234
- class m {
447
+ class V {
235
448
  baseUrl;
236
449
  token;
237
450
  vid;
238
451
  fetchClient;
239
452
  getRvFn;
240
453
  setRvFn;
454
+ /**
455
+ * Per-instance revision store, used when no `getRv`/`setRv` callbacks are
456
+ * supplied. Kept on the instance (not module scope) so concurrent requests
457
+ * in a server runtime cannot leak revisions into one another. Server callers
458
+ * that need request-scoped persistence should pass `getRv`/`setRv`.
459
+ */
460
+ rvValue = 0;
241
461
  constructor(t, e) {
242
462
  this.baseUrl = t.baseUrl.endsWith("/") ? t.baseUrl.slice(0, -1) : t.baseUrl, this.token = t.token;
243
- const i = typeof globalThis.fetch == "function" ? globalThis.fetch.bind(globalThis) : null;
463
+ const n = typeof globalThis.fetch == "function" ? globalThis.fetch.bind(globalThis) : null;
244
464
  if (t.fetchClient)
245
465
  this.fetchClient = t.fetchClient;
246
- else if (i)
247
- this.fetchClient = i;
466
+ else if (n)
467
+ this.fetchClient = n;
248
468
  else
249
469
  throw new Error(
250
470
  "No fetch implementation available. Provide `fetchClient` in ApiClient options."
251
471
  );
252
472
  this.getRvFn = t.getRv, this.setRvFn = t.setRv;
253
- const n = this.resolveRequestUrl(e);
254
- this.vid = t.version || "published", this.setRv(n?.searchParams.get("b10cks_rv") || t.rv || u);
473
+ const s = this.resolveRequestUrl(e);
474
+ this.vid = t.version || "published", this.setRv(s?.searchParams.get("b10cks_rv") || t.rv || 0);
255
475
  }
256
476
  async get(t, e = {}) {
257
- const i = this.buildUrl(t, {
477
+ const n = this.buildUrl(t, {
258
478
  vid: this.vid,
259
- ...e,
260
479
  rv: this.getRv(),
480
+ ...e,
261
481
  token: this.token
262
- }), n = await this.fetchClient(i), r = await this.parseResponse(n);
482
+ }), s = await this.fetchClient(n), r = await this.parseResponse(s);
263
483
  return this.hasRevision(r) && this.setRv(r.rv), r;
264
484
  }
265
- async post(t, e, i = {}) {
266
- const n = this.buildUrl(t, {
485
+ async post(t, e, n = {}) {
486
+ const s = this.buildUrl(t, {
267
487
  vid: this.vid,
268
- ...i,
269
488
  rv: this.getRv(),
489
+ ...n,
270
490
  token: this.token
271
- }), r = await this.fetchClient(n, {
491
+ }), r = await this.fetchClient(s, {
272
492
  method: "POST",
273
493
  headers: { "Content-Type": "application/json" },
274
494
  body: e !== void 0 ? JSON.stringify(e) : void 0
@@ -276,25 +496,25 @@ class m {
276
496
  return this.parseResponse(r);
277
497
  }
278
498
  async getAll(t, e = {}) {
279
- const i = await this.get(t, {
499
+ const n = await this.get(t, {
280
500
  ...e,
281
501
  page: 1
282
- }), n = this.normalizeCollectionResponse(i);
283
- if (n.rv && this.setRv(n.rv), !n.meta || n.meta.last_page <= 1)
284
- return n.data;
502
+ }), s = this.normalizeCollectionResponse(n);
503
+ if (s.rv && this.setRv(s.rv), !s.meta || s.meta.last_page <= 1)
504
+ return s.data;
285
505
  const r = Array.from(
286
- { length: n.meta.last_page - 1 },
287
- (a, f) => this.get(t, { ...e, page: f + 2 })
506
+ { length: s.meta.last_page - 1 },
507
+ (a, c) => this.get(t, { ...e, page: c + 2 })
288
508
  ), o = await Promise.all(r);
289
- return n.data.concat(
509
+ return s.data.concat(
290
510
  o.flatMap((a) => this.normalizeCollectionResponse(a).data)
291
511
  );
292
512
  }
293
513
  setRv(t) {
294
- this.setRvFn ? this.setRvFn(t) : u = t;
514
+ this.setRvFn ? this.setRvFn(t) : this.rvValue = t;
295
515
  }
296
516
  getRv() {
297
- return this.getRvFn ? this.getRvFn() : u;
517
+ return this.getRvFn ? this.getRvFn() : this.rvValue;
298
518
  }
299
519
  async parseResponse(t) {
300
520
  if (this.isFetchResponse(t)) {
@@ -318,18 +538,18 @@ class m {
318
538
  if (typeof t == "object" && t !== null && "data" in t) {
319
539
  const {
320
540
  data: e,
321
- meta: i,
322
- rv: n
541
+ meta: n,
542
+ rv: s
323
543
  } = t;
324
- return { data: e, meta: i, rv: n };
544
+ return { data: e, meta: n, rv: s };
325
545
  }
326
546
  return { data: [], meta: void 0, rv: void 0 };
327
547
  }
328
548
  buildUrl(t, e) {
329
- const i = new URL(`${this.baseUrl}/v1/${t}`);
330
- return Object.entries(e).forEach(([n, r]) => {
331
- r != null && i.searchParams.append(n, String(r));
332
- }), i.toString();
549
+ const n = new URL(`${this.baseUrl}/v1/${t}`);
550
+ return Object.entries(e).forEach(([s, r]) => {
551
+ r != null && n.searchParams.append(s, String(r));
552
+ }), n.toString();
333
553
  }
334
554
  resolveRequestUrl(t) {
335
555
  return t ? t instanceof URL ? t : new URL(t, "http://localhost") : null;
@@ -345,12 +565,26 @@ class m {
345
565
  }
346
566
  }
347
567
  export {
348
- m as ApiClient,
349
- v as B10cksDataApi,
350
- c as PreviewBridge,
351
- w as createB10cksDataApi,
352
- b as previewBridge,
353
- R as serializeFilter,
354
- C as types
568
+ V as ApiClient,
569
+ P as B10cksDataApi,
570
+ h as PreviewBridge,
571
+ I as PreviewStore,
572
+ O as attachEditable,
573
+ $ as attachEditableField,
574
+ U as bindPreviewStore,
575
+ R as buildLocalizedPath,
576
+ L as createB10cksDataApi,
577
+ E as ensurePreviewStyles,
578
+ x as filterSitemapEntries,
579
+ D as getAtPath,
580
+ w as normalizePathSegment,
581
+ l as previewBridge,
582
+ M as renderSitemapIndex,
583
+ z as renderSitemapXml,
584
+ _ as resolveB10cksLink,
585
+ S as serializeFilter,
586
+ m as setAtPath,
587
+ F as setPreviewScrollOffset,
588
+ N as types
355
589
  };
356
590
  //# sourceMappingURL=index.mjs.map