vue-datocms 5.1.2-0 → 6.0.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.cjs.js CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var hypenateStyleName = require('hyphenate-style-name');
6
5
  var vue = require('vue');
6
+ var hypenateStyleName = require('hyphenate-style-name');
7
7
  var datocmsStructuredTextGenericHtmlRenderer = require('datocms-structured-text-generic-html-renderer');
8
8
  var datocmsStructuredTextUtils = require('datocms-structured-text-utils');
9
9
  var datocmsListen = require('datocms-listen');
@@ -36,8 +36,57 @@ const isSsr = () => {
36
36
  const isIntersectionObserverAvailable = () => {
37
37
  return isSsr() ? false : !!window.IntersectionObserver;
38
38
  };
39
+ const universalBtoa = (str) => isSsr() ? Buffer.from(str.toString(), "binary").toString("base64") : window.btoa(str);
40
+ const absolutePositioning = {
41
+ position: "absolute",
42
+ left: "0px",
43
+ top: "0px",
44
+ width: "100%",
45
+ height: "100%"
46
+ };
47
+ const escapeString = (s) => {
48
+ let result = `${s}`;
49
+ result = result.replace(/&/g, "&");
50
+ result = result.replace(/</g, "&lt;");
51
+ result = result.replace(/>/g, "&gt;");
52
+ result = result.replace(/"/g, "&quot;");
53
+ result = result.replace(/'/g, "&#39;");
54
+ return result;
55
+ };
56
+ const toCss = (object) => {
57
+ if (!object) {
58
+ return null;
59
+ }
60
+ let result = "";
61
+ for (const styleName in object) {
62
+ if (Object.prototype.hasOwnProperty.call(object, styleName) && object[styleName]) {
63
+ result += `${hypenateStyleName__default["default"](styleName)}: ${object[styleName]}; `;
64
+ }
65
+ }
66
+ return result.length > 0 ? result : null;
67
+ };
68
+ const tag = (tagName, attrs, content) => {
69
+ const serializedAttrs = [];
70
+ if (attrs) {
71
+ for (const attrName in attrs) {
72
+ if (Object.prototype.hasOwnProperty.call(attrs, attrName)) {
73
+ const value = attrs[attrName];
74
+ if (value) {
75
+ serializedAttrs.push(
76
+ `${escapeString(attrName)}="${escapeString(value)}"`
77
+ );
78
+ }
79
+ }
80
+ }
81
+ }
82
+ const attrsString = serializedAttrs.length > 0 ? ` ${serializedAttrs.join(" ")}` : "";
83
+ return content ? `<${tagName}${attrsString}>${content.join("")}</${tagName}>` : `<${tagName}${attrsString} />`;
84
+ };
39
85
 
40
- const useInView = ({ threshold, rootMargin }) => {
86
+ const useInView = ({
87
+ threshold,
88
+ rootMargin
89
+ }) => {
41
90
  const observer = vue.ref(null);
42
91
  const elRef = vue.ref(null);
43
92
  const inView = vue.ref(false);
@@ -89,23 +138,69 @@ const Source = vue.defineComponent({
89
138
  }
90
139
  });
91
140
 
92
- var __defProp$5 = Object.defineProperty;
93
- var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
94
- var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
95
- var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
96
- var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
97
- var __spreadValues$5 = (a, b) => {
141
+ const bogusBaseUrl = "https://example.com/";
142
+ const buildSrcSet = (src, width, candidateMultipliers) => {
143
+ if (!src || !width) {
144
+ return void 0;
145
+ }
146
+ return candidateMultipliers.map((multiplier) => {
147
+ const url = new URL(src, bogusBaseUrl);
148
+ if (multiplier !== 1) {
149
+ url.searchParams.set("dpr", `${multiplier}`);
150
+ const maxH = url.searchParams.get("max-h");
151
+ const maxW = url.searchParams.get("max-w");
152
+ if (maxH) {
153
+ url.searchParams.set(
154
+ "max-h",
155
+ `${Math.floor(Number.parseInt(maxH) * multiplier)}`
156
+ );
157
+ }
158
+ if (maxW) {
159
+ url.searchParams.set(
160
+ "max-w",
161
+ `${Math.floor(Number.parseInt(maxW) * multiplier)}`
162
+ );
163
+ }
164
+ }
165
+ const finalWidth = Math.floor(width * multiplier);
166
+ if (finalWidth < 50) {
167
+ return null;
168
+ }
169
+ return `${url.toString().replace(bogusBaseUrl, "/")} ${finalWidth}w`;
170
+ }).filter(Boolean).join(",");
171
+ };
172
+ function buildWebpSource(data, sizes) {
173
+ var _a;
174
+ return data.webpSrcSet && vue.h(Source, {
175
+ srcset: data.webpSrcSet,
176
+ sizes: (_a = sizes != null ? sizes : data.sizes) != null ? _a : void 0,
177
+ type: "image/webp"
178
+ });
179
+ }
180
+ function buildRegularSource(data, sizes, srcSetCandidates) {
181
+ var _a, _b;
182
+ return vue.h(Source, {
183
+ srcset: (_a = data.srcSet) != null ? _a : buildSrcSet(data.src, data.width, srcSetCandidates),
184
+ sizes: (_b = sizes != null ? sizes : data.sizes) != null ? _b : void 0
185
+ });
186
+ }
187
+
188
+ var __defProp$6 = Object.defineProperty;
189
+ var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
190
+ var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
191
+ var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
192
+ var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
193
+ var __spreadValues$6 = (a, b) => {
98
194
  for (var prop in b || (b = {}))
99
- if (__hasOwnProp$6.call(b, prop))
100
- __defNormalProp$5(a, prop, b[prop]);
101
- if (__getOwnPropSymbols$6)
102
- for (var prop of __getOwnPropSymbols$6(b)) {
103
- if (__propIsEnum$6.call(b, prop))
104
- __defNormalProp$5(a, prop, b[prop]);
195
+ if (__hasOwnProp$7.call(b, prop))
196
+ __defNormalProp$6(a, prop, b[prop]);
197
+ if (__getOwnPropSymbols$7)
198
+ for (var prop of __getOwnPropSymbols$7(b)) {
199
+ if (__propIsEnum$7.call(b, prop))
200
+ __defNormalProp$6(a, prop, b[prop]);
105
201
  }
106
202
  return a;
107
203
  };
108
- const universalBtoa = (str) => isSsr() ? Buffer.from(str.toString(), "binary").toString("base64") : window.btoa(str);
109
204
  const Sizer = vue.defineComponent({
110
205
  props: {
111
206
  sizerClass: {
@@ -120,89 +215,43 @@ const Sizer = vue.defineComponent({
120
215
  },
121
216
  height: {
122
217
  type: Number
123
- },
124
- explicitWidth: {
125
- type: Boolean
126
218
  }
127
219
  },
128
- setup({ sizerClass, sizerStyle, width, height, explicitWidth }) {
220
+ setup({ sizerClass, sizerStyle, width, height }) {
129
221
  const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}"></svg>`;
130
222
  return () => vue.h("img", {
131
223
  class: sizerClass,
132
- style: __spreadValues$5({
224
+ style: __spreadValues$6({
133
225
  display: "block",
134
- width: explicitWidth ? `${width}px` : "100%"
226
+ width: "100%"
135
227
  }, sizerStyle),
136
228
  src: `data:image/svg+xml;base64,${universalBtoa(svg)}`,
137
- role: "presentation"
229
+ "aria-hidden": "true"
138
230
  });
139
231
  }
140
232
  });
141
233
 
142
- var __defProp$4 = Object.defineProperty;
234
+ var __defProp$5 = Object.defineProperty;
143
235
  var __defProps$3 = Object.defineProperties;
144
236
  var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
145
- var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
146
- var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
147
- var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
148
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
149
- var __spreadValues$4 = (a, b) => {
237
+ var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
238
+ var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
239
+ var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
240
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
241
+ var __spreadValues$5 = (a, b) => {
150
242
  for (var prop in b || (b = {}))
151
- if (__hasOwnProp$5.call(b, prop))
152
- __defNormalProp$4(a, prop, b[prop]);
153
- if (__getOwnPropSymbols$5)
154
- for (var prop of __getOwnPropSymbols$5(b)) {
155
- if (__propIsEnum$5.call(b, prop))
156
- __defNormalProp$4(a, prop, b[prop]);
243
+ if (__hasOwnProp$6.call(b, prop))
244
+ __defNormalProp$5(a, prop, b[prop]);
245
+ if (__getOwnPropSymbols$6)
246
+ for (var prop of __getOwnPropSymbols$6(b)) {
247
+ if (__propIsEnum$6.call(b, prop))
248
+ __defNormalProp$5(a, prop, b[prop]);
157
249
  }
158
250
  return a;
159
251
  };
160
252
  var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
161
- const escape = (s) => {
162
- s = "" + s;
163
- s = s.replace(/&/g, "&amp;");
164
- s = s.replace(/</g, "&lt;");
165
- s = s.replace(/>/g, "&gt;");
166
- s = s.replace(/"/g, "&quot;");
167
- s = s.replace(/'/g, "&#39;");
168
- return s;
169
- };
170
- const toCss = (object) => {
171
- if (!object) {
172
- return null;
173
- }
174
- let result = "";
175
- for (var styleName in object) {
176
- if (Object.prototype.hasOwnProperty.call(object, styleName) && object[styleName]) {
177
- result += `${hypenateStyleName__default["default"](styleName)}: ${object[styleName]}; `;
178
- }
179
- }
180
- return result.length > 0 ? result : null;
181
- };
182
- const tag = (tagName, attrs, content) => {
183
- const serializedAttrs = [];
184
- if (attrs) {
185
- for (var attrName in attrs) {
186
- if (Object.prototype.hasOwnProperty.call(attrs, attrName)) {
187
- const value = attrs[attrName];
188
- if (value) {
189
- serializedAttrs.push(`${escape(attrName)}="${escape(value)}"`);
190
- }
191
- }
192
- }
193
- }
194
- const attrsString = serializedAttrs.length > 0 ? ` ${serializedAttrs.join(" ")}` : "";
195
- return content ? `<${tagName}${attrsString}>${content.join("")}</${tagName}>` : `<${tagName}${attrsString} />`;
196
- };
197
- const absolutePositioning = {
198
- position: "absolute",
199
- left: "0px",
200
- top: "0px",
201
- width: "100%",
202
- height: "100%"
203
- };
204
- const imageAddStrategy = ({ lazyLoad, inView, loaded }) => {
205
- if (!lazyLoad) {
253
+ const imageAddStrategy = ({ priority, inView, loaded }) => {
254
+ if (priority) {
206
255
  return true;
207
256
  }
208
257
  if (isSsr()) {
@@ -213,8 +262,8 @@ const imageAddStrategy = ({ lazyLoad, inView, loaded }) => {
213
262
  }
214
263
  return true;
215
264
  };
216
- const imageShowStrategy = ({ lazyLoad, loaded }) => {
217
- if (!lazyLoad) {
265
+ const imageShowStrategy = ({ priority, loaded }) => {
266
+ if (priority) {
218
267
  return true;
219
268
  }
220
269
  if (isSsr()) {
@@ -225,38 +274,10 @@ const imageShowStrategy = ({ lazyLoad, loaded }) => {
225
274
  }
226
275
  return true;
227
276
  };
228
- const buildSrcSet = (src, width, candidateMultipliers) => {
229
- if (!src || !width) {
230
- return void 0;
231
- }
232
- return candidateMultipliers.map((multiplier) => {
233
- const url = new URL(src);
234
- if (multiplier !== 1) {
235
- url.searchParams.set("dpr", `${multiplier}`);
236
- const maxH = url.searchParams.get("max-h");
237
- const maxW = url.searchParams.get("max-w");
238
- if (maxH) {
239
- url.searchParams.set(
240
- "max-h",
241
- `${Math.floor(parseInt(maxH) * multiplier)}`
242
- );
243
- }
244
- if (maxW) {
245
- url.searchParams.set(
246
- "max-w",
247
- `${Math.floor(parseInt(maxW) * multiplier)}`
248
- );
249
- }
250
- }
251
- const finalWidth = Math.floor(width * multiplier);
252
- if (finalWidth < 50) {
253
- return null;
254
- }
255
- return `${url.toString()} ${finalWidth}w`;
256
- }).filter(Boolean).join(",");
257
- };
258
- const Image = vue.defineComponent({
277
+ const Image$1 = vue.defineComponent({
259
278
  name: "DatocmsImage",
279
+ inheritAttrs: false,
280
+ emits: ["load"],
260
281
  props: {
261
282
  data: {
262
283
  type: Object,
@@ -265,6 +286,9 @@ const Image = vue.defineComponent({
265
286
  pictureClass: {
266
287
  type: String
267
288
  },
289
+ placeholderClass: {
290
+ type: String
291
+ },
268
292
  fadeInDuration: {
269
293
  type: Number
270
294
  },
@@ -279,24 +303,17 @@ const Image = vue.defineComponent({
279
303
  type: String,
280
304
  default: "0px 0px 0px 0px"
281
305
  },
282
- lazyLoad: {
283
- type: Boolean,
284
- default: true
285
- },
286
- rootStyle: {
306
+ pictureStyle: {
287
307
  type: Object,
288
308
  default: () => ({})
289
309
  },
290
- pictureStyle: {
310
+ placeholderStyle: {
291
311
  type: Object,
292
312
  default: () => ({})
293
313
  },
294
- explicitWidth: {
295
- type: Boolean
296
- },
297
314
  layout: {
298
315
  type: String,
299
- default: () => "responsive",
316
+ default: () => "intrinsic",
300
317
  validator: (value) => ["intrinsic", "fixed", "responsive", "fill"].includes(value)
301
318
  },
302
319
  objectFit: {
@@ -324,16 +341,16 @@ const Image = vue.defineComponent({
324
341
  default: () => [0.25, 0.5, 0.75, 1, 1.5, 2, 3, 4]
325
342
  }
326
343
  },
327
- setup(props) {
344
+ setup(props, { emit, expose }) {
328
345
  const loaded = vue.ref(false);
329
346
  function handleLoad() {
347
+ emit("load");
330
348
  loaded.value = true;
331
349
  }
332
- const { inView, elRef } = useInView({
350
+ const { inView, elRef: rootRef } = useInView({
333
351
  threshold: props.intersectionThreshold || props.intersectionTreshold || 0,
334
352
  rootMargin: props.intersectionMargin || "0px 0px 0px 0px"
335
353
  });
336
- const computedLazyLoad = vue.ref(props.priority ? false : props.lazyLoad);
337
354
  const imageRef = vue.ref();
338
355
  vue.watchEffect(() => {
339
356
  if (!imageRef.value) {
@@ -343,71 +360,78 @@ const Image = vue.defineComponent({
343
360
  handleLoad();
344
361
  }
345
362
  });
363
+ expose({
364
+ rootRef,
365
+ imageRef
366
+ });
346
367
  return {
347
368
  inView,
348
- elRef,
369
+ rootRef,
349
370
  loaded,
350
371
  handleLoad,
351
- computedLazyLoad,
352
372
  imageRef
353
373
  };
354
374
  },
355
375
  render() {
356
376
  var _a, _b, _c, _d, _e, _f;
357
377
  const addImage = imageAddStrategy({
358
- lazyLoad: this.computedLazyLoad,
378
+ priority: this.priority,
359
379
  inView: this.inView,
360
380
  loaded: this.loaded
361
381
  });
362
382
  const showImage = imageShowStrategy({
363
- lazyLoad: this.computedLazyLoad,
383
+ priority: this.priority,
364
384
  inView: this.inView,
365
385
  loaded: this.loaded
366
386
  });
367
- const webpSource = this.data.webpSrcSet && vue.h(Source, {
368
- srcset: this.data.webpSrcSet,
369
- sizes: (_b = (_a = this.sizes) != null ? _a : this.data.sizes) != null ? _b : void 0,
370
- type: "image/webp"
371
- });
372
- const regularSource = this.data.srcSet && vue.h(Source, {
373
- srcset: (_c = this.data.srcSet) != null ? _c : buildSrcSet(this.data.src, this.data.width, this.srcSetCandidates),
374
- sizes: (_e = (_d = this.sizes) != null ? _d : this.data.sizes) != null ? _e : void 0
375
- });
376
- const transition = typeof this.fadeInDuration === "undefined" || this.fadeInDuration > 0 ? `opacity ${this.fadeInDuration || 500}ms ${this.fadeInDuration || 500}ms` : void 0;
377
- const placeholder = this.usePlaceholder && (this.data.bgColor || this.data.base64) ? vue.h("div", {
387
+ const webpSource = buildWebpSource(this.data, this.sizes);
388
+ const regularSource = buildRegularSource(
389
+ this.data,
390
+ this.sizes,
391
+ this.srcSetCandidates
392
+ );
393
+ const transition = typeof this.fadeInDuration === "undefined" || this.fadeInDuration > 0 ? `opacity ${this.fadeInDuration || 500}ms` : void 0;
394
+ const basePlaceholderStyle = __spreadValues$5({
395
+ transition,
396
+ opacity: showImage ? 0 : 1,
397
+ position: "absolute",
398
+ left: "-5%",
399
+ top: "-5%",
400
+ width: "110%",
401
+ height: "110%",
402
+ maxWidth: "none",
403
+ maxHeight: "none"
404
+ }, this.placeholderStyle);
405
+ const placeholder = this.usePlaceholder && this.data.base64 ? vue.h("img", {
378
406
  "aria-hidden": "true",
379
- style: {
380
- backgroundImage: this.data.base64 ? `url(${this.data.base64})` : null,
381
- backgroundColor: this.data.bgColor,
382
- backgroundSize: "cover",
383
- opacity: showImage ? 0 : 1,
407
+ src: this.data.base64,
408
+ class: this.placeholderClass,
409
+ style: __spreadValues$5({
384
410
  objectFit: this.objectFit,
385
- objectPosition: this.objectPosition,
386
- transition,
387
- position: "absolute",
388
- left: "-5%",
389
- top: "-5%",
390
- width: "110%",
391
- height: "110%"
392
- }
411
+ objectPosition: this.objectPosition
412
+ }, basePlaceholderStyle)
413
+ }) : this.usePlaceholder && this.data.bgColor ? vue.h("div", {
414
+ class: this.placeholderClass,
415
+ style: __spreadValues$5({
416
+ backgroundColor: this.data.bgColor
417
+ }, basePlaceholderStyle)
393
418
  }) : null;
394
419
  const { width, aspectRatio } = this.data;
395
- const height = (_f = this.data.height) != null ? _f : aspectRatio ? width / aspectRatio : 0;
420
+ const height = (_a = this.data.height) != null ? _a : aspectRatio ? width / aspectRatio : 0;
396
421
  const sizer = this.layout !== "fill" ? vue.h(Sizer, {
397
422
  sizerClass: this.pictureClass,
398
423
  sizerStyle: this.pictureStyle,
399
424
  width,
400
- height,
401
- explicitWidth: this.explicitWidth
425
+ height
402
426
  }) : null;
403
427
  return vue.h(
404
428
  "div",
405
429
  {
406
- style: __spreadValues$4(__spreadValues$4({
407
- display: this.explicitWidth ? "inline-block" : "block",
430
+ class: this.$attrs.class,
431
+ style: __spreadValues$5(__spreadValues$5({
408
432
  overflow: "hidden"
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" }), this.rootStyle),
410
- ref: "elRef"
433
+ }, 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 || {}),
434
+ ref: "rootRef"
411
435
  },
412
436
  [
413
437
  sizer,
@@ -423,7 +447,7 @@ const Image = vue.defineComponent({
423
447
  onLoad: this.handleLoad,
424
448
  ref: "imageRef",
425
449
  class: this.pictureClass,
426
- style: __spreadValues$4(__spreadProps$3(__spreadValues$4({
450
+ style: __spreadValues$5(__spreadProps$3(__spreadValues$5({
427
451
  opacity: showImage ? 1 : 0,
428
452
  transition
429
453
  }, absolutePositioning), {
@@ -436,20 +460,27 @@ const Image = vue.defineComponent({
436
460
  innerHTML: tag("picture", {}, [
437
461
  this.data.webpSrcSet && tag("source", {
438
462
  srcset: this.data.webpSrcSet,
439
- sizes: this.data.sizes,
463
+ sizes: (_c = (_b = this.sizes) != null ? _b : this.data.sizes) != null ? _c : void 0,
440
464
  type: "image/webp"
441
465
  }),
442
- this.data.srcSet && tag("source", {
443
- srcset: this.data.srcSet,
444
- sizes: this.data.sizes
466
+ tag("source", {
467
+ srcset: (_d = this.data.srcSet) != null ? _d : buildSrcSet(
468
+ this.data.src,
469
+ this.data.width,
470
+ this.srcSetCandidates
471
+ ),
472
+ sizes: (_f = (_e = this.sizes) != null ? _e : this.data.sizes) != null ? _f : void 0
445
473
  }),
446
474
  tag("img", {
447
475
  src: this.data.src,
448
476
  alt: this.data.alt,
449
477
  title: this.data.title,
450
478
  class: this.pictureClass,
451
- style: toCss(__spreadValues$4(__spreadValues$4({}, this.pictureStyle), absolutePositioning)),
452
- loading: this.computedLazyLoad ? "lazy" : void 0,
479
+ style: toCss(__spreadValues$5(__spreadProps$3(__spreadValues$5({}, absolutePositioning), {
480
+ objectFit: this.objectFit,
481
+ objectPosition: this.objectPosition
482
+ }), this.pictureStyle)),
483
+ loading: this.priority ? void 0 : "lazy",
453
484
  fetchpriority: this.priority ? "high" : void 0
454
485
  })
455
486
  ])
@@ -460,7 +491,123 @@ const Image = vue.defineComponent({
460
491
  });
461
492
  const DatocmsImagePlugin = {
462
493
  install: (Vue) => {
463
- Vue.component("DatocmsImage", Image);
494
+ Vue.component("DatocmsImage", Image$1);
495
+ }
496
+ };
497
+
498
+ var __defProp$4 = Object.defineProperty;
499
+ var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
500
+ var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
501
+ var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
502
+ var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
503
+ var __spreadValues$4 = (a, b) => {
504
+ for (var prop in b || (b = {}))
505
+ if (__hasOwnProp$5.call(b, prop))
506
+ __defNormalProp$4(a, prop, b[prop]);
507
+ if (__getOwnPropSymbols$5)
508
+ for (var prop of __getOwnPropSymbols$5(b)) {
509
+ if (__propIsEnum$5.call(b, prop))
510
+ __defNormalProp$4(a, prop, b[prop]);
511
+ }
512
+ return a;
513
+ };
514
+ const NakedImage = vue.defineComponent({
515
+ name: "DatocmsNakedImage",
516
+ inheritAttrs: false,
517
+ props: {
518
+ data: {
519
+ type: Object,
520
+ required: true
521
+ },
522
+ usePlaceholder: {
523
+ type: Boolean,
524
+ default: true
525
+ },
526
+ sizes: {
527
+ type: String
528
+ },
529
+ priority: {
530
+ type: Boolean,
531
+ default: false
532
+ },
533
+ srcSetCandidates: {
534
+ type: Array,
535
+ validator: (values) => values.every((value) => {
536
+ return typeof value === "number";
537
+ }),
538
+ default: () => [0.25, 0.5, 0.75, 1, 1.5, 2, 3, 4]
539
+ }
540
+ },
541
+ setup(_props, { emit, expose }) {
542
+ const loaded = vue.ref(false);
543
+ function handleLoad() {
544
+ emit("load");
545
+ loaded.value = true;
546
+ }
547
+ const imageRef = vue.ref();
548
+ vue.watchEffect(() => {
549
+ if (!imageRef.value) {
550
+ return;
551
+ }
552
+ if (imageRef.value.complete && imageRef.value.naturalWidth) {
553
+ handleLoad();
554
+ }
555
+ });
556
+ expose({
557
+ imageRef
558
+ });
559
+ return {
560
+ loaded,
561
+ handleLoad,
562
+ imageRef
563
+ };
564
+ },
565
+ render() {
566
+ var _a;
567
+ const webpSource = buildWebpSource(this.data, this.sizes);
568
+ const regularSource = buildRegularSource(
569
+ this.data,
570
+ this.sizes,
571
+ this.srcSetCandidates
572
+ );
573
+ const { width } = this.data;
574
+ const height = (_a = this.data.height) != null ? _a : Math.round(this.data.aspectRatio ? width / this.data.aspectRatio : 0);
575
+ const sizingStyle = {
576
+ aspectRatio: `${width} / ${height}`,
577
+ width: "100%",
578
+ maxWidth: `${width}px`,
579
+ height: "auto"
580
+ };
581
+ const placeholderStyle = this.usePlaceholder && !this.loaded && this.data.base64 ? {
582
+ backgroundImage: `url(${this.data.base64})`,
583
+ backgroundSize: "cover",
584
+ backgroundRepeat: "no-repeat",
585
+ backgroundPosition: "50% 50%",
586
+ color: "transparent"
587
+ } : this.usePlaceholder && !this.loaded && this.data.bgColor ? {
588
+ backgroundColor: this.data.bgColor,
589
+ color: "transparent"
590
+ } : void 0;
591
+ return vue.h("picture", null, [
592
+ webpSource,
593
+ regularSource,
594
+ this.data.src && vue.h("img", {
595
+ ref: "imageRef",
596
+ src: this.data.src,
597
+ alt: this.data.alt,
598
+ onLoad: this.handleLoad,
599
+ title: this.data.title,
600
+ fetchpriority: this.priority ? "high" : void 0,
601
+ loading: this.priority ? void 0 : "lazy",
602
+ style: __spreadValues$4(__spreadValues$4(__spreadValues$4({}, placeholderStyle), sizingStyle), this.$attrs.style || {}),
603
+ class: this.$attrs.class
604
+ })
605
+ ]);
606
+ }
607
+ });
608
+ const DatocmsNakedImagePlugin = {
609
+ install: (Vue) => {
610
+ Vue.component("DatocmsNakedImage", Image);
464
611
  }
465
612
  };
466
613
 
@@ -1029,7 +1176,15 @@ const VideoPlayer = vue.defineComponent({
1029
1176
  "cuePointsChange"
1030
1177
  ],
1031
1178
  setup: (_a) => {
1032
- var _b = _a, { data = {}, disableCookies = true, preload = "metadata" } = _b, otherProps = __objRest$1(_b, ["data", "disableCookies", "preload"]);
1179
+ var _b = _a, {
1180
+ data = {},
1181
+ disableCookies = true,
1182
+ preload = "metadata"
1183
+ } = _b, otherProps = __objRest$1(_b, [
1184
+ "data",
1185
+ "disableCookies",
1186
+ "preload"
1187
+ ]);
1033
1188
  Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('@mux/mux-player')); });
1034
1189
  const muxPlayerRef = vue.ref();
1035
1190
  const computedProps = __spreadProps$2(__spreadValues$2({}, useVideoPlayer({ data })), {
@@ -1186,10 +1341,22 @@ var __async$1 = (__this, __arguments, generator) => {
1186
1341
  });
1187
1342
  };
1188
1343
  const useQuerySubscription = (_a) => {
1189
- var _b = _a, { enabled = true, initialData, query, token } = _b, other = __objRest(_b, ["enabled", "initialData", "query", "token"]);
1344
+ var _b = _a, {
1345
+ enabled = true,
1346
+ initialData,
1347
+ query,
1348
+ token
1349
+ } = _b, other = __objRest(_b, [
1350
+ "enabled",
1351
+ "initialData",
1352
+ "query",
1353
+ "token"
1354
+ ]);
1190
1355
  const error = vue.ref(null);
1191
1356
  const data = vue.ref(vue.unref(initialData) || null);
1192
- const status = vue.ref(vue.unref(enabled) ? "connecting" : "closed");
1357
+ const status = vue.ref(
1358
+ vue.unref(enabled) ? "connecting" : "closed"
1359
+ );
1193
1360
  const subscribeToQueryOptions = other;
1194
1361
  vue.watchEffect((onCleanup) => __async$1(void 0, null, function* () {
1195
1362
  if (query && token && vue.unref(enabled)) {
@@ -1384,9 +1551,11 @@ Object.defineProperty(exports, 'RenderError', {
1384
1551
  get: function () { return datocmsStructuredTextUtils.RenderError; }
1385
1552
  });
1386
1553
  exports.DatocmsImagePlugin = DatocmsImagePlugin;
1554
+ exports.DatocmsNakedImagePlugin = DatocmsNakedImagePlugin;
1387
1555
  exports.DatocmsStructuredTextPlugin = DatocmsStructuredTextPlugin;
1388
1556
  exports.DatocmsVideoPlayerPlugin = DatocmsVideoPlayerPlugin;
1389
- exports.Image = Image;
1557
+ exports.Image = Image$1;
1558
+ exports.NakedImage = NakedImage;
1390
1559
  exports.StructuredText = StructuredText;
1391
1560
  exports.VideoPlayer = VideoPlayer;
1392
1561
  exports.appendKeyToValidElement = appendKeyToValidElement;