vue-datocms 5.1.2 → 6.0.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.
@@ -1,5 +1,5 @@
1
- import hypenateStyleName from 'hyphenate-style-name';
2
1
  import { ref, onMounted, onBeforeUnmount, defineComponent, h, watchEffect, unref, reactive, computed, toRaw } from 'vue';
2
+ import hypenateStyleName from 'hyphenate-style-name';
3
3
  import { render, renderNodeRule, defaultMetaTransformer } from 'datocms-structured-text-generic-html-renderer';
4
4
  export { renderMarkRule, renderNodeRule, renderNodeRule as renderRule } from 'datocms-structured-text-generic-html-renderer';
5
5
  import { isRoot, isInlineItem, RenderError, isStructuredText, isItemLink, isBlock } from 'datocms-structured-text-utils';
@@ -12,8 +12,57 @@ const isSsr = () => {
12
12
  const isIntersectionObserverAvailable = () => {
13
13
  return isSsr() ? false : !!window.IntersectionObserver;
14
14
  };
15
+ const universalBtoa = (str) => isSsr() ? Buffer.from(str.toString(), "binary").toString("base64") : window.btoa(str);
16
+ const absolutePositioning = {
17
+ position: "absolute",
18
+ left: "0px",
19
+ top: "0px",
20
+ width: "100%",
21
+ height: "100%"
22
+ };
23
+ const escapeString = (s) => {
24
+ let result = `${s}`;
25
+ result = result.replace(/&/g, "&");
26
+ result = result.replace(/</g, "&lt;");
27
+ result = result.replace(/>/g, "&gt;");
28
+ result = result.replace(/"/g, "&quot;");
29
+ result = result.replace(/'/g, "&#39;");
30
+ return result;
31
+ };
32
+ const toCss = (object) => {
33
+ if (!object) {
34
+ return null;
35
+ }
36
+ let result = "";
37
+ for (const styleName in object) {
38
+ if (Object.prototype.hasOwnProperty.call(object, styleName) && object[styleName]) {
39
+ result += `${hypenateStyleName(styleName)}: ${object[styleName]}; `;
40
+ }
41
+ }
42
+ return result.length > 0 ? result : null;
43
+ };
44
+ const tag = (tagName, attrs, content) => {
45
+ const serializedAttrs = [];
46
+ if (attrs) {
47
+ for (const attrName in attrs) {
48
+ if (Object.prototype.hasOwnProperty.call(attrs, attrName)) {
49
+ const value = attrs[attrName];
50
+ if (value) {
51
+ serializedAttrs.push(
52
+ `${escapeString(attrName)}="${escapeString(value)}"`
53
+ );
54
+ }
55
+ }
56
+ }
57
+ }
58
+ const attrsString = serializedAttrs.length > 0 ? ` ${serializedAttrs.join(" ")}` : "";
59
+ return content ? `<${tagName}${attrsString}>${content.join("")}</${tagName}>` : `<${tagName}${attrsString} />`;
60
+ };
15
61
 
16
- const useInView = ({ threshold, rootMargin }) => {
62
+ const useInView = ({
63
+ threshold,
64
+ rootMargin
65
+ }) => {
17
66
  const observer = ref(null);
18
67
  const elRef = ref(null);
19
68
  const inView = ref(false);
@@ -65,23 +114,69 @@ const Source = defineComponent({
65
114
  }
66
115
  });
67
116
 
68
- var __defProp$5 = Object.defineProperty;
69
- var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
70
- var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
71
- var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
72
- var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
73
- var __spreadValues$5 = (a, b) => {
117
+ const bogusBaseUrl = "https://example.com/";
118
+ const buildSrcSet = (src, width, candidateMultipliers) => {
119
+ if (!src || !width) {
120
+ return void 0;
121
+ }
122
+ return candidateMultipliers.map((multiplier) => {
123
+ const url = new URL(src, bogusBaseUrl);
124
+ if (multiplier !== 1) {
125
+ url.searchParams.set("dpr", `${multiplier}`);
126
+ const maxH = url.searchParams.get("max-h");
127
+ const maxW = url.searchParams.get("max-w");
128
+ if (maxH) {
129
+ url.searchParams.set(
130
+ "max-h",
131
+ `${Math.floor(Number.parseInt(maxH) * multiplier)}`
132
+ );
133
+ }
134
+ if (maxW) {
135
+ url.searchParams.set(
136
+ "max-w",
137
+ `${Math.floor(Number.parseInt(maxW) * multiplier)}`
138
+ );
139
+ }
140
+ }
141
+ const finalWidth = Math.floor(width * multiplier);
142
+ if (finalWidth < 50) {
143
+ return null;
144
+ }
145
+ return `${url.toString().replace(bogusBaseUrl, "/")} ${finalWidth}w`;
146
+ }).filter(Boolean).join(",");
147
+ };
148
+ function buildWebpSource(data, sizes) {
149
+ var _a;
150
+ return data.webpSrcSet && h(Source, {
151
+ srcset: data.webpSrcSet,
152
+ sizes: (_a = sizes != null ? sizes : data.sizes) != null ? _a : void 0,
153
+ type: "image/webp"
154
+ });
155
+ }
156
+ function buildRegularSource(data, sizes, srcSetCandidates) {
157
+ var _a, _b;
158
+ return h(Source, {
159
+ srcset: (_a = data.srcSet) != null ? _a : buildSrcSet(data.src, data.width, srcSetCandidates),
160
+ sizes: (_b = sizes != null ? sizes : data.sizes) != null ? _b : void 0
161
+ });
162
+ }
163
+
164
+ var __defProp$6 = Object.defineProperty;
165
+ var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
166
+ var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
167
+ var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
168
+ var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
169
+ var __spreadValues$6 = (a, b) => {
74
170
  for (var prop in b || (b = {}))
75
- if (__hasOwnProp$6.call(b, prop))
76
- __defNormalProp$5(a, prop, b[prop]);
77
- if (__getOwnPropSymbols$6)
78
- for (var prop of __getOwnPropSymbols$6(b)) {
79
- if (__propIsEnum$6.call(b, prop))
80
- __defNormalProp$5(a, prop, b[prop]);
171
+ if (__hasOwnProp$7.call(b, prop))
172
+ __defNormalProp$6(a, prop, b[prop]);
173
+ if (__getOwnPropSymbols$7)
174
+ for (var prop of __getOwnPropSymbols$7(b)) {
175
+ if (__propIsEnum$7.call(b, prop))
176
+ __defNormalProp$6(a, prop, b[prop]);
81
177
  }
82
178
  return a;
83
179
  };
84
- const universalBtoa = (str) => isSsr() ? Buffer.from(str.toString(), "binary").toString("base64") : window.btoa(str);
85
180
  const Sizer = defineComponent({
86
181
  props: {
87
182
  sizerClass: {
@@ -96,89 +191,43 @@ const Sizer = defineComponent({
96
191
  },
97
192
  height: {
98
193
  type: Number
99
- },
100
- explicitWidth: {
101
- type: Boolean
102
194
  }
103
195
  },
104
- setup({ sizerClass, sizerStyle, width, height, explicitWidth }) {
196
+ setup({ sizerClass, sizerStyle, width, height }) {
105
197
  const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}"></svg>`;
106
198
  return () => h("img", {
107
199
  class: sizerClass,
108
- style: __spreadValues$5({
200
+ style: __spreadValues$6({
109
201
  display: "block",
110
- width: explicitWidth ? `${width}px` : "100%"
202
+ width: "100%"
111
203
  }, sizerStyle),
112
204
  src: `data:image/svg+xml;base64,${universalBtoa(svg)}`,
113
- role: "presentation"
205
+ "aria-hidden": "true"
114
206
  });
115
207
  }
116
208
  });
117
209
 
118
- var __defProp$4 = Object.defineProperty;
210
+ var __defProp$5 = Object.defineProperty;
119
211
  var __defProps$3 = Object.defineProperties;
120
212
  var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
121
- var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
122
- var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
123
- var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
124
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
125
- var __spreadValues$4 = (a, b) => {
213
+ var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
214
+ var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
215
+ var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
216
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
217
+ var __spreadValues$5 = (a, b) => {
126
218
  for (var prop in b || (b = {}))
127
- if (__hasOwnProp$5.call(b, prop))
128
- __defNormalProp$4(a, prop, b[prop]);
129
- if (__getOwnPropSymbols$5)
130
- for (var prop of __getOwnPropSymbols$5(b)) {
131
- if (__propIsEnum$5.call(b, prop))
132
- __defNormalProp$4(a, prop, b[prop]);
219
+ if (__hasOwnProp$6.call(b, prop))
220
+ __defNormalProp$5(a, prop, b[prop]);
221
+ if (__getOwnPropSymbols$6)
222
+ for (var prop of __getOwnPropSymbols$6(b)) {
223
+ if (__propIsEnum$6.call(b, prop))
224
+ __defNormalProp$5(a, prop, b[prop]);
133
225
  }
134
226
  return a;
135
227
  };
136
228
  var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
137
- const escape = (s) => {
138
- s = "" + s;
139
- s = s.replace(/&/g, "&amp;");
140
- s = s.replace(/</g, "&lt;");
141
- s = s.replace(/>/g, "&gt;");
142
- s = s.replace(/"/g, "&quot;");
143
- s = s.replace(/'/g, "&#39;");
144
- return s;
145
- };
146
- const toCss = (object) => {
147
- if (!object) {
148
- return null;
149
- }
150
- let result = "";
151
- for (var styleName in object) {
152
- if (Object.prototype.hasOwnProperty.call(object, styleName) && object[styleName]) {
153
- result += `${hypenateStyleName(styleName)}: ${object[styleName]}; `;
154
- }
155
- }
156
- return result.length > 0 ? result : null;
157
- };
158
- const tag = (tagName, attrs, content) => {
159
- const serializedAttrs = [];
160
- if (attrs) {
161
- for (var attrName in attrs) {
162
- if (Object.prototype.hasOwnProperty.call(attrs, attrName)) {
163
- const value = attrs[attrName];
164
- if (value) {
165
- serializedAttrs.push(`${escape(attrName)}="${escape(value)}"`);
166
- }
167
- }
168
- }
169
- }
170
- const attrsString = serializedAttrs.length > 0 ? ` ${serializedAttrs.join(" ")}` : "";
171
- return content ? `<${tagName}${attrsString}>${content.join("")}</${tagName}>` : `<${tagName}${attrsString} />`;
172
- };
173
- const absolutePositioning = {
174
- position: "absolute",
175
- left: "0px",
176
- top: "0px",
177
- width: "100%",
178
- height: "100%"
179
- };
180
- const imageAddStrategy = ({ lazyLoad, inView, loaded }) => {
181
- if (!lazyLoad) {
229
+ const imageAddStrategy = ({ priority, inView, loaded }) => {
230
+ if (priority) {
182
231
  return true;
183
232
  }
184
233
  if (isSsr()) {
@@ -189,8 +238,8 @@ const imageAddStrategy = ({ lazyLoad, inView, loaded }) => {
189
238
  }
190
239
  return true;
191
240
  };
192
- const imageShowStrategy = ({ lazyLoad, loaded }) => {
193
- if (!lazyLoad) {
241
+ const imageShowStrategy = ({ priority, loaded }) => {
242
+ if (priority) {
194
243
  return true;
195
244
  }
196
245
  if (isSsr()) {
@@ -201,38 +250,10 @@ const imageShowStrategy = ({ lazyLoad, loaded }) => {
201
250
  }
202
251
  return true;
203
252
  };
204
- const buildSrcSet = (src, width, candidateMultipliers) => {
205
- if (!src || !width) {
206
- return void 0;
207
- }
208
- return candidateMultipliers.map((multiplier) => {
209
- const url = new URL(src);
210
- if (multiplier !== 1) {
211
- url.searchParams.set("dpr", `${multiplier}`);
212
- const maxH = url.searchParams.get("max-h");
213
- const maxW = url.searchParams.get("max-w");
214
- if (maxH) {
215
- url.searchParams.set(
216
- "max-h",
217
- `${Math.floor(parseInt(maxH) * multiplier)}`
218
- );
219
- }
220
- if (maxW) {
221
- url.searchParams.set(
222
- "max-w",
223
- `${Math.floor(parseInt(maxW) * multiplier)}`
224
- );
225
- }
226
- }
227
- const finalWidth = Math.floor(width * multiplier);
228
- if (finalWidth < 50) {
229
- return null;
230
- }
231
- return `${url.toString()} ${finalWidth}w`;
232
- }).filter(Boolean).join(",");
233
- };
234
- const Image = defineComponent({
253
+ const Image$1 = defineComponent({
235
254
  name: "DatocmsImage",
255
+ inheritAttrs: false,
256
+ emits: ["load"],
236
257
  props: {
237
258
  data: {
238
259
  type: Object,
@@ -241,6 +262,9 @@ const Image = defineComponent({
241
262
  pictureClass: {
242
263
  type: String
243
264
  },
265
+ placeholderClass: {
266
+ type: String
267
+ },
244
268
  fadeInDuration: {
245
269
  type: Number
246
270
  },
@@ -255,24 +279,17 @@ const Image = defineComponent({
255
279
  type: String,
256
280
  default: "0px 0px 0px 0px"
257
281
  },
258
- lazyLoad: {
259
- type: Boolean,
260
- default: true
261
- },
262
- rootStyle: {
282
+ pictureStyle: {
263
283
  type: Object,
264
284
  default: () => ({})
265
285
  },
266
- pictureStyle: {
286
+ placeholderStyle: {
267
287
  type: Object,
268
288
  default: () => ({})
269
289
  },
270
- explicitWidth: {
271
- type: Boolean
272
- },
273
290
  layout: {
274
291
  type: String,
275
- default: () => "responsive",
292
+ default: () => "intrinsic",
276
293
  validator: (value) => ["intrinsic", "fixed", "responsive", "fill"].includes(value)
277
294
  },
278
295
  objectFit: {
@@ -300,16 +317,16 @@ const Image = defineComponent({
300
317
  default: () => [0.25, 0.5, 0.75, 1, 1.5, 2, 3, 4]
301
318
  }
302
319
  },
303
- setup(props) {
320
+ setup(props, { emit, expose }) {
304
321
  const loaded = ref(false);
305
322
  function handleLoad() {
323
+ emit("load");
306
324
  loaded.value = true;
307
325
  }
308
- const { inView, elRef } = useInView({
326
+ const { inView, elRef: rootRef } = useInView({
309
327
  threshold: props.intersectionThreshold || props.intersectionTreshold || 0,
310
328
  rootMargin: props.intersectionMargin || "0px 0px 0px 0px"
311
329
  });
312
- const computedLazyLoad = ref(props.priority ? false : props.lazyLoad);
313
330
  const imageRef = ref();
314
331
  watchEffect(() => {
315
332
  if (!imageRef.value) {
@@ -319,71 +336,78 @@ const Image = defineComponent({
319
336
  handleLoad();
320
337
  }
321
338
  });
339
+ expose({
340
+ rootRef,
341
+ imageRef
342
+ });
322
343
  return {
323
344
  inView,
324
- elRef,
345
+ rootRef,
325
346
  loaded,
326
347
  handleLoad,
327
- computedLazyLoad,
328
348
  imageRef
329
349
  };
330
350
  },
331
351
  render() {
332
352
  var _a, _b, _c, _d, _e, _f;
333
353
  const addImage = imageAddStrategy({
334
- lazyLoad: this.computedLazyLoad,
354
+ priority: this.priority,
335
355
  inView: this.inView,
336
356
  loaded: this.loaded
337
357
  });
338
358
  const showImage = imageShowStrategy({
339
- lazyLoad: this.computedLazyLoad,
359
+ priority: this.priority,
340
360
  inView: this.inView,
341
361
  loaded: this.loaded
342
362
  });
343
- const webpSource = this.data.webpSrcSet && h(Source, {
344
- srcset: this.data.webpSrcSet,
345
- sizes: (_b = (_a = this.sizes) != null ? _a : this.data.sizes) != null ? _b : void 0,
346
- type: "image/webp"
347
- });
348
- const regularSource = this.data.srcSet && h(Source, {
349
- srcset: (_c = this.data.srcSet) != null ? _c : buildSrcSet(this.data.src, this.data.width, this.srcSetCandidates),
350
- sizes: (_e = (_d = this.sizes) != null ? _d : this.data.sizes) != null ? _e : void 0
351
- });
352
- const transition = typeof this.fadeInDuration === "undefined" || this.fadeInDuration > 0 ? `opacity ${this.fadeInDuration || 500}ms ${this.fadeInDuration || 500}ms` : void 0;
353
- const placeholder = this.usePlaceholder && (this.data.bgColor || this.data.base64) ? h("div", {
363
+ const webpSource = buildWebpSource(this.data, this.sizes);
364
+ const regularSource = buildRegularSource(
365
+ this.data,
366
+ this.sizes,
367
+ this.srcSetCandidates
368
+ );
369
+ const transition = typeof this.fadeInDuration === "undefined" || this.fadeInDuration > 0 ? `opacity ${this.fadeInDuration || 500}ms` : void 0;
370
+ const basePlaceholderStyle = __spreadValues$5({
371
+ transition,
372
+ opacity: showImage ? 0 : 1,
373
+ position: "absolute",
374
+ left: "-5%",
375
+ top: "-5%",
376
+ width: "110%",
377
+ height: "auto",
378
+ maxWidth: "none",
379
+ maxHeight: "none"
380
+ }, this.placeholderStyle);
381
+ const placeholder = this.usePlaceholder && this.data.base64 ? h("img", {
354
382
  "aria-hidden": "true",
355
- style: {
356
- backgroundImage: this.data.base64 ? `url(${this.data.base64})` : null,
357
- backgroundColor: this.data.bgColor,
358
- backgroundSize: "cover",
359
- opacity: showImage ? 0 : 1,
383
+ src: this.data.base64,
384
+ class: this.placeholderClass,
385
+ style: __spreadValues$5({
360
386
  objectFit: this.objectFit,
361
- objectPosition: this.objectPosition,
362
- transition,
363
- position: "absolute",
364
- left: "-5%",
365
- top: "-5%",
366
- width: "110%",
367
- height: "110%"
368
- }
387
+ objectPosition: this.objectPosition
388
+ }, basePlaceholderStyle)
389
+ }) : this.usePlaceholder && this.data.bgColor ? h("div", {
390
+ class: this.placeholderClass,
391
+ style: __spreadValues$5({
392
+ backgroundColor: this.data.bgColor
393
+ }, basePlaceholderStyle)
369
394
  }) : null;
370
395
  const { width, aspectRatio } = this.data;
371
- const height = (_f = this.data.height) != null ? _f : aspectRatio ? width / aspectRatio : 0;
396
+ const height = (_a = this.data.height) != null ? _a : aspectRatio ? width / aspectRatio : 0;
372
397
  const sizer = this.layout !== "fill" ? h(Sizer, {
373
398
  sizerClass: this.pictureClass,
374
399
  sizerStyle: this.pictureStyle,
375
400
  width,
376
- height,
377
- explicitWidth: this.explicitWidth
401
+ height
378
402
  }) : null;
379
403
  return h(
380
404
  "div",
381
405
  {
382
- style: __spreadValues$4(__spreadValues$4({
383
- display: this.explicitWidth ? "inline-block" : "block",
406
+ class: this.$attrs.class,
407
+ style: __spreadValues$5(__spreadValues$5({
384
408
  overflow: "hidden"
385
- }, this.layout === "fill" ? absolutePositioning : this.layout === "intrinsic" ? { position: "relative", width: "100%", maxWidth: `${width}px` } : this.layout === "fixed" ? { position: "relative", width: `${width}px` } : { position: "relative" }), this.rootStyle),
386
- ref: "elRef"
409
+ }, this.layout === "fill" ? absolutePositioning : this.layout === "intrinsic" ? { position: "relative", width: "100%", maxWidth: `${width}px` } : this.layout === "fixed" ? { position: "relative", width: `${width}px` } : { position: "relative", width: "100%" }), this.$attrs.style || {}),
410
+ ref: "rootRef"
387
411
  },
388
412
  [
389
413
  sizer,
@@ -399,7 +423,7 @@ const Image = defineComponent({
399
423
  onLoad: this.handleLoad,
400
424
  ref: "imageRef",
401
425
  class: this.pictureClass,
402
- style: __spreadValues$4(__spreadProps$3(__spreadValues$4({
426
+ style: __spreadValues$5(__spreadProps$3(__spreadValues$5({
403
427
  opacity: showImage ? 1 : 0,
404
428
  transition
405
429
  }, absolutePositioning), {
@@ -412,20 +436,27 @@ const Image = defineComponent({
412
436
  innerHTML: tag("picture", {}, [
413
437
  this.data.webpSrcSet && tag("source", {
414
438
  srcset: this.data.webpSrcSet,
415
- sizes: this.data.sizes,
439
+ sizes: (_c = (_b = this.sizes) != null ? _b : this.data.sizes) != null ? _c : void 0,
416
440
  type: "image/webp"
417
441
  }),
418
- this.data.srcSet && tag("source", {
419
- srcset: this.data.srcSet,
420
- sizes: this.data.sizes
442
+ tag("source", {
443
+ srcset: (_d = this.data.srcSet) != null ? _d : buildSrcSet(
444
+ this.data.src,
445
+ this.data.width,
446
+ this.srcSetCandidates
447
+ ),
448
+ sizes: (_f = (_e = this.sizes) != null ? _e : this.data.sizes) != null ? _f : void 0
421
449
  }),
422
450
  tag("img", {
423
451
  src: this.data.src,
424
452
  alt: this.data.alt,
425
453
  title: this.data.title,
426
454
  class: this.pictureClass,
427
- style: toCss(__spreadValues$4(__spreadValues$4({}, this.pictureStyle), absolutePositioning)),
428
- loading: this.computedLazyLoad ? "lazy" : void 0,
455
+ style: toCss(__spreadValues$5(__spreadProps$3(__spreadValues$5({}, absolutePositioning), {
456
+ objectFit: this.objectFit,
457
+ objectPosition: this.objectPosition
458
+ }), this.pictureStyle)),
459
+ loading: this.priority ? void 0 : "lazy",
429
460
  fetchpriority: this.priority ? "high" : void 0
430
461
  })
431
462
  ])
@@ -436,7 +467,123 @@ const Image = defineComponent({
436
467
  });
437
468
  const DatocmsImagePlugin = {
438
469
  install: (Vue) => {
439
- Vue.component("DatocmsImage", Image);
470
+ Vue.component("DatocmsImage", Image$1);
471
+ }
472
+ };
473
+
474
+ var __defProp$4 = Object.defineProperty;
475
+ var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
476
+ var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
477
+ var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
478
+ var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
479
+ var __spreadValues$4 = (a, b) => {
480
+ for (var prop in b || (b = {}))
481
+ if (__hasOwnProp$5.call(b, prop))
482
+ __defNormalProp$4(a, prop, b[prop]);
483
+ if (__getOwnPropSymbols$5)
484
+ for (var prop of __getOwnPropSymbols$5(b)) {
485
+ if (__propIsEnum$5.call(b, prop))
486
+ __defNormalProp$4(a, prop, b[prop]);
487
+ }
488
+ return a;
489
+ };
490
+ const NakedImage = defineComponent({
491
+ name: "DatocmsNakedImage",
492
+ inheritAttrs: false,
493
+ props: {
494
+ data: {
495
+ type: Object,
496
+ required: true
497
+ },
498
+ usePlaceholder: {
499
+ type: Boolean,
500
+ default: true
501
+ },
502
+ sizes: {
503
+ type: String
504
+ },
505
+ priority: {
506
+ type: Boolean,
507
+ default: false
508
+ },
509
+ srcSetCandidates: {
510
+ type: Array,
511
+ validator: (values) => values.every((value) => {
512
+ return typeof value === "number";
513
+ }),
514
+ default: () => [0.25, 0.5, 0.75, 1, 1.5, 2, 3, 4]
515
+ }
516
+ },
517
+ setup(_props, { emit, expose }) {
518
+ const loaded = ref(false);
519
+ function handleLoad() {
520
+ emit("load");
521
+ loaded.value = true;
522
+ }
523
+ const imageRef = ref();
524
+ watchEffect(() => {
525
+ if (!imageRef.value) {
526
+ return;
527
+ }
528
+ if (imageRef.value.complete && imageRef.value.naturalWidth) {
529
+ handleLoad();
530
+ }
531
+ });
532
+ expose({
533
+ imageRef
534
+ });
535
+ return {
536
+ loaded,
537
+ handleLoad,
538
+ imageRef
539
+ };
540
+ },
541
+ render() {
542
+ var _a;
543
+ const webpSource = buildWebpSource(this.data, this.sizes);
544
+ const regularSource = buildRegularSource(
545
+ this.data,
546
+ this.sizes,
547
+ this.srcSetCandidates
548
+ );
549
+ const { width } = this.data;
550
+ const height = (_a = this.data.height) != null ? _a : Math.round(this.data.aspectRatio ? width / this.data.aspectRatio : 0);
551
+ const sizingStyle = {
552
+ aspectRatio: `${width} / ${height}`,
553
+ width: "100%",
554
+ maxWidth: `${width}px`,
555
+ height: "auto"
556
+ };
557
+ const placeholderStyle = this.usePlaceholder && !this.loaded && this.data.base64 ? {
558
+ backgroundImage: `url("${this.data.base64}")`,
559
+ backgroundSize: "cover",
560
+ backgroundRepeat: "no-repeat",
561
+ backgroundPosition: "50% 50%",
562
+ color: "transparent"
563
+ } : this.usePlaceholder && !this.loaded && this.data.bgColor ? {
564
+ backgroundColor: this.data.bgColor,
565
+ color: "transparent"
566
+ } : void 0;
567
+ return h("picture", null, [
568
+ webpSource,
569
+ regularSource,
570
+ this.data.src && h("img", {
571
+ ref: "imageRef",
572
+ src: this.data.src,
573
+ alt: this.data.alt,
574
+ onLoad: this.handleLoad,
575
+ title: this.data.title,
576
+ fetchpriority: this.priority ? "high" : void 0,
577
+ loading: this.priority ? void 0 : "lazy",
578
+ style: __spreadValues$4(__spreadValues$4(__spreadValues$4({}, placeholderStyle), sizingStyle), this.$attrs.style || {}),
579
+ class: this.$attrs.class
580
+ })
581
+ ]);
582
+ }
583
+ });
584
+ const DatocmsNakedImagePlugin = {
585
+ install: (Vue) => {
586
+ Vue.component("DatocmsNakedImage", Image);
440
587
  }
441
588
  };
442
589
 
@@ -1005,7 +1152,15 @@ const VideoPlayer = defineComponent({
1005
1152
  "cuePointsChange"
1006
1153
  ],
1007
1154
  setup: (_a) => {
1008
- var _b = _a, { data = {}, disableCookies = true, preload = "metadata" } = _b, otherProps = __objRest$1(_b, ["data", "disableCookies", "preload"]);
1155
+ var _b = _a, {
1156
+ data = {},
1157
+ disableCookies = true,
1158
+ preload = "metadata"
1159
+ } = _b, otherProps = __objRest$1(_b, [
1160
+ "data",
1161
+ "disableCookies",
1162
+ "preload"
1163
+ ]);
1009
1164
  import('@mux/mux-player');
1010
1165
  const muxPlayerRef = ref();
1011
1166
  const computedProps = __spreadProps$2(__spreadValues$2({}, useVideoPlayer({ data })), {
@@ -1162,10 +1317,22 @@ var __async$1 = (__this, __arguments, generator) => {
1162
1317
  });
1163
1318
  };
1164
1319
  const useQuerySubscription = (_a) => {
1165
- var _b = _a, { enabled = true, initialData, query, token } = _b, other = __objRest(_b, ["enabled", "initialData", "query", "token"]);
1320
+ var _b = _a, {
1321
+ enabled = true,
1322
+ initialData,
1323
+ query,
1324
+ token
1325
+ } = _b, other = __objRest(_b, [
1326
+ "enabled",
1327
+ "initialData",
1328
+ "query",
1329
+ "token"
1330
+ ]);
1166
1331
  const error = ref(null);
1167
1332
  const data = ref(unref(initialData) || null);
1168
- const status = ref(unref(enabled) ? "connecting" : "closed");
1333
+ const status = ref(
1334
+ unref(enabled) ? "connecting" : "closed"
1335
+ );
1169
1336
  const subscribeToQueryOptions = other;
1170
1337
  watchEffect((onCleanup) => __async$1(void 0, null, function* () {
1171
1338
  if (query && token && unref(enabled)) {
@@ -1343,4 +1510,4 @@ const toHead = (...args) => {
1343
1510
  };
1344
1511
  };
1345
1512
 
1346
- export { DatocmsImagePlugin, DatocmsStructuredTextPlugin, DatocmsVideoPlayerPlugin, Image, StructuredText, VideoPlayer, appendKeyToValidElement, defaultAdapter, isKeyOf, isNil, toHead, toNativeAttrName, toNativeAttrValue, useQuerySubscription, useSiteSearch, useVideoPlayer };
1513
+ export { DatocmsImagePlugin, DatocmsNakedImagePlugin, DatocmsStructuredTextPlugin, DatocmsVideoPlayerPlugin, Image$1 as Image, NakedImage, StructuredText, VideoPlayer, appendKeyToValidElement, defaultAdapter, isKeyOf, isNil, toHead, toNativeAttrName, toNativeAttrValue, useQuerySubscription, useSiteSearch, useVideoPlayer };