vue-datocms 4.0.1 → 4.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # vue-datocms
2
2
 
3
- ![MIT](https://img.shields.io/npm/l/vue-datocms?style=for-the-badge) ![NPM](https://img.shields.io/npm/v/vue-datocms?style=for-the-badge) [![Build Status](https://img.shields.io/github/workflow/status/datocms/vue-datocms/Node.js%20CI?style=for-the-badge)](https://github.com/datocms/vue-datocms/actions/workflows/node.js.yml)
3
+ ![MIT](https://img.shields.io/npm/l/vue-datocms?style=for-the-badge) ![NPM](https://img.shields.io/npm/v/vue-datocms?style=for-the-badge) [![Build Status](https://img.shields.io/github/actions/workflow/status/datocms/vue-datocms/node.js.yml?branch=master&style=for-the-badge)](https://github.com/datocms/vue-datocms/actions/workflows/node.js.yml)
4
4
 
5
- A set of components and utilities to work faster with [DatoCMS](https://www.datocms.com/) in Vue.js environments. Integrates seamlessy with [DatoCMS's GraphQL Content Delivery API](https://www.datocms.com/docs/content-delivery-api).
5
+ A set of components and utilities to work faster with [DatoCMS](https://www.datocms.com/) in Vue.js environments. Integrates seamlessly with [DatoCMS's GraphQL Content Delivery API](https://www.datocms.com/docs/content-delivery-api).
6
6
 
7
7
  - Works with Vue 3 and Vue 2;
8
8
  - TypeScript ready;
@@ -43,9 +43,11 @@ Helpers:
43
43
  ## Installation
44
44
 
45
45
  ```
46
+ # First, install Vue
47
+ npm install vue
48
+ # Then install vue-datocms
46
49
  npm install vue-datocms
47
50
  ```
48
-
49
51
  ## Development
50
52
 
51
53
  This repository contains a number of examples. You can use them to locally test your changes to the package:
package/dist/index.cjs.js CHANGED
@@ -50,6 +50,22 @@ const useInView = ({ threshold, rootMargin }) => {
50
50
  return { inView, elRef };
51
51
  };
52
52
 
53
+ var __defProp$4 = Object.defineProperty;
54
+ var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
55
+ var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
56
+ var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
57
+ var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
58
+ var __spreadValues$4 = (a, b) => {
59
+ for (var prop in b || (b = {}))
60
+ if (__hasOwnProp$4.call(b, prop))
61
+ __defNormalProp$4(a, prop, b[prop]);
62
+ if (__getOwnPropSymbols$4)
63
+ for (var prop of __getOwnPropSymbols$4(b)) {
64
+ if (__propIsEnum$4.call(b, prop))
65
+ __defNormalProp$4(a, prop, b[prop]);
66
+ }
67
+ return a;
68
+ };
53
69
  const Source = vueDemi.defineComponent({
54
70
  props: {
55
71
  srcset: {
@@ -63,23 +79,36 @@ const Source = vueDemi.defineComponent({
63
79
  }
64
80
  },
65
81
  setup({ srcset, sizes, type }) {
66
- return () => vueDemi.h("source", {
67
- ...vueDemi.isVue2 && {
68
- attrs: {
69
- srcset,
70
- sizes,
71
- type
72
- }
73
- },
74
- ...vueDemi.isVue3 && {
82
+ return () => vueDemi.h("source", __spreadValues$4(__spreadValues$4({}, vueDemi.isVue2 && {
83
+ attrs: {
75
84
  srcset,
76
85
  sizes,
77
86
  type
78
87
  }
79
- });
88
+ }), vueDemi.isVue3 && {
89
+ srcset,
90
+ sizes,
91
+ type
92
+ }));
80
93
  }
81
94
  });
82
95
 
96
+ var __defProp$3 = Object.defineProperty;
97
+ var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
98
+ var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
99
+ var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
100
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
101
+ var __spreadValues$3 = (a, b) => {
102
+ for (var prop in b || (b = {}))
103
+ if (__hasOwnProp$3.call(b, prop))
104
+ __defNormalProp$3(a, prop, b[prop]);
105
+ if (__getOwnPropSymbols$3)
106
+ for (var prop of __getOwnPropSymbols$3(b)) {
107
+ if (__propIsEnum$3.call(b, prop))
108
+ __defNormalProp$3(a, prop, b[prop]);
109
+ }
110
+ return a;
111
+ };
83
112
  const universalBtoa = (str) => isSsr() ? Buffer.from(str.toString(), "binary").toString("base64") : window.btoa(str);
84
113
  const Sizer = vueDemi.defineComponent({
85
114
  props: {
@@ -102,27 +131,43 @@ const Sizer = vueDemi.defineComponent({
102
131
  },
103
132
  setup({ sizerClass, sizerStyle, width, height, explicitWidth }) {
104
133
  const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}"></svg>`;
105
- return () => vueDemi.h("img", {
134
+ return () => vueDemi.h("img", __spreadValues$3(__spreadValues$3({
106
135
  class: sizerClass,
107
- style: {
136
+ style: __spreadValues$3({
108
137
  display: "block",
109
- width: explicitWidth ? `${width}px` : "100%",
110
- ...sizerStyle
111
- },
112
- ...vueDemi.isVue2 && {
113
- attrs: {
114
- src: `data:image/svg+xml;base64,${universalBtoa(svg)}`,
115
- role: "presentation"
116
- }
117
- },
118
- ...vueDemi.isVue3 && {
138
+ width: explicitWidth ? `${width}px` : "100%"
139
+ }, sizerStyle)
140
+ }, vueDemi.isVue2 && {
141
+ attrs: {
119
142
  src: `data:image/svg+xml;base64,${universalBtoa(svg)}`,
120
143
  role: "presentation"
121
144
  }
122
- });
145
+ }), vueDemi.isVue3 && {
146
+ src: `data:image/svg+xml;base64,${universalBtoa(svg)}`,
147
+ role: "presentation"
148
+ }));
123
149
  }
124
150
  });
125
151
 
152
+ var __defProp$2 = Object.defineProperty;
153
+ var __defProps$2 = Object.defineProperties;
154
+ var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
155
+ var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
156
+ var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
157
+ var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
158
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
159
+ var __spreadValues$2 = (a, b) => {
160
+ for (var prop in b || (b = {}))
161
+ if (__hasOwnProp$2.call(b, prop))
162
+ __defNormalProp$2(a, prop, b[prop]);
163
+ if (__getOwnPropSymbols$2)
164
+ for (var prop of __getOwnPropSymbols$2(b)) {
165
+ if (__propIsEnum$2.call(b, prop))
166
+ __defNormalProp$2(a, prop, b[prop]);
167
+ }
168
+ return a;
169
+ };
170
+ var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
126
171
  const escape = (s) => {
127
172
  s = "" + s;
128
173
  s = s.replace(/&/g, "&amp;");
@@ -318,6 +363,7 @@ const Image = vueDemi.defineComponent({
318
363
  };
319
364
  },
320
365
  render() {
366
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
321
367
  const addImage = imageAddStrategy({
322
368
  lazyLoad: this.computedLazyLoad,
323
369
  inView: this.inView,
@@ -328,34 +374,29 @@ const Image = vueDemi.defineComponent({
328
374
  inView: this.inView,
329
375
  loaded: this.loaded
330
376
  });
331
- const webpSource = this.data.webpSrcSet && vueDemi.h(Source, {
332
- ...vueDemi.isVue2 && {
333
- props: {
334
- srcset: this.data.webpSrcSet,
335
- sizes: this.sizes ?? this.data.sizes ?? void 0,
336
- type: "image/webp"
337
- }
338
- },
339
- ...vueDemi.isVue3 && {
377
+ const webpSource = this.data.webpSrcSet && vueDemi.h(Source, __spreadValues$2(__spreadValues$2({}, vueDemi.isVue2 && {
378
+ props: {
340
379
  srcset: this.data.webpSrcSet,
341
- sizes: this.sizes ?? this.data.sizes ?? void 0,
380
+ sizes: (_b = (_a = this.sizes) != null ? _a : this.data.sizes) != null ? _b : void 0,
342
381
  type: "image/webp"
343
382
  }
344
- });
345
- const regularSource = this.data.srcSet && vueDemi.h(Source, {
346
- ...vueDemi.isVue2 && {
347
- props: {
348
- srcset: this.data.srcSet ?? buildSrcSet(this.data.src, this.data.width, this.srcSetCandidates),
349
- sizes: this.sizes ?? this.data.sizes ?? void 0
350
- }
351
- },
352
- ...vueDemi.isVue3 && {
353
- srcset: this.data.srcSet ?? buildSrcSet(this.data.src, this.data.width, this.srcSetCandidates),
354
- sizes: this.sizes ?? this.data.sizes ?? void 0
383
+ }), vueDemi.isVue3 && {
384
+ srcset: this.data.webpSrcSet,
385
+ sizes: (_d = (_c = this.sizes) != null ? _c : this.data.sizes) != null ? _d : void 0,
386
+ type: "image/webp"
387
+ }));
388
+ const regularSource = this.data.srcSet && vueDemi.h(Source, __spreadValues$2(__spreadValues$2({}, vueDemi.isVue2 && {
389
+ props: {
390
+ srcset: (_e = this.data.srcSet) != null ? _e : buildSrcSet(this.data.src, this.data.width, this.srcSetCandidates),
391
+ sizes: (_g = (_f = this.sizes) != null ? _f : this.data.sizes) != null ? _g : void 0
355
392
  }
356
- });
393
+ }), vueDemi.isVue3 && {
394
+ srcset: (_h = this.data.srcSet) != null ? _h : buildSrcSet(this.data.src, this.data.width, this.srcSetCandidates),
395
+ sizes: (_j = (_i = this.sizes) != null ? _i : this.data.sizes) != null ? _j : void 0
396
+ }));
357
397
  const transition = typeof this.fadeInDuration === "undefined" || this.fadeInDuration > 0 ? `opacity ${this.fadeInDuration || 500}ms ${this.fadeInDuration || 500}ms` : void 0;
358
398
  const placeholder = this.usePlaceholder && (this.data.bgColor || this.data.base64) ? vueDemi.h("div", {
399
+ "aria-hidden": "true",
359
400
  style: {
360
401
  backgroundImage: this.data.base64 ? `url(${this.data.base64})` : null,
361
402
  backgroundColor: this.data.bgColor,
@@ -372,34 +413,29 @@ const Image = vueDemi.defineComponent({
372
413
  }
373
414
  }) : null;
374
415
  const { width, aspectRatio } = this.data;
375
- const height = this.data.height ?? (aspectRatio ? width / aspectRatio : 0);
376
- const sizer = this.layout !== "fill" ? vueDemi.h(Sizer, {
377
- ...vueDemi.isVue2 && {
378
- props: {
379
- sizerClass: this.pictureClass,
380
- sizerStyle: this.pictureStyle,
381
- width,
382
- height,
383
- explicitWidth: this.explicitWidth
384
- }
385
- },
386
- ...vueDemi.isVue3 && {
416
+ const height = (_k = this.data.height) != null ? _k : aspectRatio ? width / aspectRatio : 0;
417
+ const sizer = this.layout !== "fill" ? vueDemi.h(Sizer, __spreadValues$2(__spreadValues$2({}, vueDemi.isVue2 && {
418
+ props: {
387
419
  sizerClass: this.pictureClass,
388
420
  sizerStyle: this.pictureStyle,
389
421
  width,
390
422
  height,
391
423
  explicitWidth: this.explicitWidth
392
424
  }
393
- }) : null;
425
+ }), vueDemi.isVue3 && {
426
+ sizerClass: this.pictureClass,
427
+ sizerStyle: this.pictureStyle,
428
+ width,
429
+ height,
430
+ explicitWidth: this.explicitWidth
431
+ })) : null;
394
432
  return vueDemi.h(
395
433
  "div",
396
434
  {
397
- style: {
435
+ style: __spreadValues$2(__spreadValues$2({
398
436
  display: this.explicitWidth ? "inline-block" : "block",
399
- overflow: "hidden",
400
- ...this.layout === "fill" ? absolutePositioning : this.layout === "intrinsic" ? { position: "relative", width: "100%", maxWidth: `${width}px` } : this.layout === "fixed" ? { position: "relative", width: `${width}px` } : { position: "relative" },
401
- ...this.rootStyle
402
- },
437
+ overflow: "hidden"
438
+ }, 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),
403
439
  ref: "elRef"
404
440
  },
405
441
  [
@@ -408,68 +444,36 @@ const Image = vueDemi.defineComponent({
408
444
  addImage && vueDemi.h("picture", null, [
409
445
  webpSource,
410
446
  regularSource,
411
- this.data.src && vueDemi.h("img", {
412
- ...vueDemi.isVue2 && {
413
- attrs: {
414
- src: this.data.src,
415
- alt: this.data.alt,
416
- title: this.data.title,
417
- fetchpriority: this.priority ? "high" : void 0
418
- },
419
- on: {
420
- load: this.handleLoad
421
- }
422
- },
423
- ...vueDemi.isVue3 && {
447
+ this.data.src && vueDemi.h("img", __spreadProps$2(__spreadValues$2(__spreadValues$2({}, vueDemi.isVue2 && {
448
+ attrs: {
424
449
  src: this.data.src,
425
450
  alt: this.data.alt,
426
451
  title: this.data.title,
427
- fetchpriority: this.priority ? "high" : void 0,
428
- onLoad: this.handleLoad
452
+ fetchpriority: this.priority ? "high" : void 0
429
453
  },
454
+ on: {
455
+ load: this.handleLoad
456
+ }
457
+ }), vueDemi.isVue3 && {
458
+ src: this.data.src,
459
+ alt: this.data.alt,
460
+ title: this.data.title,
461
+ fetchpriority: this.priority ? "high" : void 0,
462
+ onLoad: this.handleLoad
463
+ }), {
430
464
  ref: "imageRef",
431
465
  class: this.pictureClass,
432
- style: {
466
+ style: __spreadValues$2(__spreadProps$2(__spreadValues$2({
433
467
  opacity: showImage ? 1 : 0,
434
- transition,
435
- ...absolutePositioning,
468
+ transition
469
+ }, absolutePositioning), {
436
470
  objectFit: this.objectFit,
437
- objectPosition: this.objectPosition,
438
- ...this.pictureStyle
439
- }
440
- })
471
+ objectPosition: this.objectPosition
472
+ }), this.pictureStyle)
473
+ }))
441
474
  ]),
442
- vueDemi.h("noscript", {
443
- ...vueDemi.isVue2 && {
444
- domProps: {
445
- innerHTML: tag("picture", {}, [
446
- this.data.webpSrcSet && tag("source", {
447
- srcset: this.data.webpSrcSet,
448
- sizes: this.data.sizes,
449
- type: "image/webp"
450
- }),
451
- this.data.srcSet && tag("source", {
452
- srcset: this.data.srcSet,
453
- sizes: this.data.sizes
454
- }),
455
- tag("img", {
456
- src: this.data.src,
457
- alt: this.data.alt,
458
- title: this.data.title,
459
- class: this.pictureClass,
460
- style: toCss({
461
- ...absolutePositioning,
462
- objectFit: this.objectFit,
463
- objectPosition: this.objectPosition,
464
- ...this.pictureStyle
465
- }),
466
- loading: this.computedLazyLoad ? "lazy" : void 0,
467
- fetchpriority: this.priority ? "high" : void 0
468
- })
469
- ])
470
- }
471
- },
472
- ...vueDemi.isVue3 && {
475
+ vueDemi.h("noscript", __spreadValues$2(__spreadValues$2({}, vueDemi.isVue2 && {
476
+ domProps: {
473
477
  innerHTML: tag("picture", {}, [
474
478
  this.data.webpSrcSet && tag("source", {
475
479
  srcset: this.data.webpSrcSet,
@@ -485,13 +489,37 @@ const Image = vueDemi.defineComponent({
485
489
  alt: this.data.alt,
486
490
  title: this.data.title,
487
491
  class: this.pictureClass,
488
- style: toCss({ ...this.pictureStyle, ...absolutePositioning }),
492
+ style: toCss(__spreadValues$2(__spreadProps$2(__spreadValues$2({}, absolutePositioning), {
493
+ objectFit: this.objectFit,
494
+ objectPosition: this.objectPosition
495
+ }), this.pictureStyle)),
489
496
  loading: this.computedLazyLoad ? "lazy" : void 0,
490
497
  fetchpriority: this.priority ? "high" : void 0
491
498
  })
492
499
  ])
493
500
  }
494
- })
501
+ }), vueDemi.isVue3 && {
502
+ innerHTML: tag("picture", {}, [
503
+ this.data.webpSrcSet && tag("source", {
504
+ srcset: this.data.webpSrcSet,
505
+ sizes: this.data.sizes,
506
+ type: "image/webp"
507
+ }),
508
+ this.data.srcSet && tag("source", {
509
+ srcset: this.data.srcSet,
510
+ sizes: this.data.sizes
511
+ }),
512
+ tag("img", {
513
+ src: this.data.src,
514
+ alt: this.data.alt,
515
+ title: this.data.title,
516
+ class: this.pictureClass,
517
+ style: toCss(__spreadValues$2(__spreadValues$2({}, this.pictureStyle), absolutePositioning)),
518
+ loading: this.computedLazyLoad ? "lazy" : void 0,
519
+ fetchpriority: this.priority ? "high" : void 0
520
+ })
521
+ ])
522
+ }))
495
523
  ]
496
524
  );
497
525
  }
@@ -663,15 +691,66 @@ const DatocmsStructuredTextPlugin = {
663
691
  }
664
692
  };
665
693
 
666
- const useQuerySubscription = ({ enabled = true, initialData, query, token, ...other }) => {
694
+ var __defProp$1 = Object.defineProperty;
695
+ var __defProps$1 = Object.defineProperties;
696
+ var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
697
+ var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
698
+ var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
699
+ var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
700
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
701
+ var __spreadValues$1 = (a, b) => {
702
+ for (var prop in b || (b = {}))
703
+ if (__hasOwnProp$1.call(b, prop))
704
+ __defNormalProp$1(a, prop, b[prop]);
705
+ if (__getOwnPropSymbols$1)
706
+ for (var prop of __getOwnPropSymbols$1(b)) {
707
+ if (__propIsEnum$1.call(b, prop))
708
+ __defNormalProp$1(a, prop, b[prop]);
709
+ }
710
+ return a;
711
+ };
712
+ var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
713
+ var __objRest = (source, exclude) => {
714
+ var target = {};
715
+ for (var prop in source)
716
+ if (__hasOwnProp$1.call(source, prop) && exclude.indexOf(prop) < 0)
717
+ target[prop] = source[prop];
718
+ if (source != null && __getOwnPropSymbols$1)
719
+ for (var prop of __getOwnPropSymbols$1(source)) {
720
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$1.call(source, prop))
721
+ target[prop] = source[prop];
722
+ }
723
+ return target;
724
+ };
725
+ var __async$1 = (__this, __arguments, generator) => {
726
+ return new Promise((resolve, reject) => {
727
+ var fulfilled = (value) => {
728
+ try {
729
+ step(generator.next(value));
730
+ } catch (e) {
731
+ reject(e);
732
+ }
733
+ };
734
+ var rejected = (value) => {
735
+ try {
736
+ step(generator.throw(value));
737
+ } catch (e) {
738
+ reject(e);
739
+ }
740
+ };
741
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
742
+ step((generator = generator.apply(__this, __arguments)).next());
743
+ });
744
+ };
745
+ const useQuerySubscription = (_a) => {
746
+ var _b = _a, { enabled = true, initialData, query, token } = _b, other = __objRest(_b, ["enabled", "initialData", "query", "token"]);
667
747
  const error = vueDemi.ref(null);
668
748
  const data = vueDemi.ref(vueDemi.unref(initialData) || null);
669
749
  const status = vueDemi.ref(vueDemi.unref(enabled) ? "connecting" : "closed");
670
750
  const subscribeToQueryOptions = other;
671
- vueDemi.watchEffect(async (onCleanup) => {
751
+ vueDemi.watchEffect((onCleanup) => __async$1(void 0, null, function* () {
672
752
  if (query && token && vueDemi.unref(enabled)) {
673
- const unsubscribe = await datocmsListen.subscribeToQuery({
674
- ...subscribeToQueryOptions,
753
+ const unsubscribe = yield datocmsListen.subscribeToQuery(__spreadProps$1(__spreadValues$1({}, subscribeToQueryOptions), {
675
754
  query,
676
755
  token,
677
756
  onStatusChange: (connectionStatus) => {
@@ -685,13 +764,33 @@ const useQuerySubscription = ({ enabled = true, initialData, query, token, ...ot
685
764
  data.value = null;
686
765
  error.value = errorData;
687
766
  }
688
- });
767
+ }));
689
768
  onCleanup(unsubscribe);
690
769
  }
691
- });
770
+ }));
692
771
  return { data, status, error };
693
772
  };
694
773
 
774
+ var __async = (__this, __arguments, generator) => {
775
+ return new Promise((resolve, reject) => {
776
+ var fulfilled = (value) => {
777
+ try {
778
+ step(generator.next(value));
779
+ } catch (e) {
780
+ reject(e);
781
+ }
782
+ };
783
+ var rejected = (value) => {
784
+ try {
785
+ step(generator.throw(value));
786
+ } catch (e) {
787
+ reject(e);
788
+ }
789
+ };
790
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
791
+ step((generator = generator.apply(__this, __arguments)).next());
792
+ });
793
+ };
695
794
  const highlightPieces = (textWithHighlightMarker) => {
696
795
  return textWithHighlightMarker.split(/\[h\](.+?)\[\/h\]/g).map((text, index) => ({
697
796
  text,
@@ -699,10 +798,11 @@ const highlightPieces = (textWithHighlightMarker) => {
699
798
  }));
700
799
  };
701
800
  function useSiteSearch(config) {
801
+ var _a, _b, _c;
702
802
  const state = vueDemi.reactive({
703
- query: config.initialState?.query || "",
704
- page: config.initialState?.page || 0,
705
- locale: config.initialState?.locale
803
+ query: ((_a = config.initialState) == null ? void 0 : _a.query) || "",
804
+ page: ((_b = config.initialState) == null ? void 0 : _b.page) || 0,
805
+ locale: (_c = config.initialState) == null ? void 0 : _c.locale
706
806
  });
707
807
  const error = vueDemi.ref();
708
808
  const response = vueDemi.reactive({
@@ -713,7 +813,7 @@ function useSiteSearch(config) {
713
813
  const resultsPerPage = config.resultsPerPage || 8;
714
814
  vueDemi.watchEffect((onCleanup) => {
715
815
  let isCancelled = false;
716
- const run = async () => {
816
+ const run = () => __async(this, null, function* () {
717
817
  try {
718
818
  if (!state.query) {
719
819
  response.data = [];
@@ -734,7 +834,7 @@ function useSiteSearch(config) {
734
834
  if (config.fuzzySearch) {
735
835
  request.fuzzy = "true";
736
836
  }
737
- const results = await config.client.searchResults.rawList(request);
837
+ const results = yield config.client.searchResults.rawList(request);
738
838
  if (!isCancelled) {
739
839
  response.data = results.data;
740
840
  response.meta.total_count = results.meta.total_count;
@@ -749,7 +849,7 @@ function useSiteSearch(config) {
749
849
  error.value = "Unknown error!";
750
850
  }
751
851
  }
752
- };
852
+ });
753
853
  run();
754
854
  onCleanup(() => {
755
855
  isCancelled = true;
@@ -781,6 +881,25 @@ function useSiteSearch(config) {
781
881
  };
782
882
  }
783
883
 
884
+ var __defProp = Object.defineProperty;
885
+ var __defProps = Object.defineProperties;
886
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
887
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
888
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
889
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
890
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
891
+ var __spreadValues = (a, b) => {
892
+ for (var prop in b || (b = {}))
893
+ if (__hasOwnProp.call(b, prop))
894
+ __defNormalProp(a, prop, b[prop]);
895
+ if (__getOwnPropSymbols)
896
+ for (var prop of __getOwnPropSymbols(b)) {
897
+ if (__propIsEnum.call(b, prop))
898
+ __defNormalProp(a, prop, b[prop]);
899
+ }
900
+ return a;
901
+ };
902
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
784
903
  const toHead = (...args) => {
785
904
  const tags = [].concat(...args);
786
905
  const titleTag = tags && tags.find((t) => t.tag === "title");
@@ -788,16 +907,20 @@ const toHead = (...args) => {
788
907
  const linkTags = tags ? tags.filter((t) => t.tag === "link") : [];
789
908
  return {
790
909
  title: titleTag && titleTag.content,
791
- meta: metaTags.map((tag) => ({
792
- ...tag.attributes,
793
- hid: tag.attributes?.name || tag.attributes?.property,
794
- vmid: tag.attributes?.name || tag.attributes?.property
795
- })),
796
- link: linkTags.map((tag) => ({
797
- ...tag.attributes,
798
- hid: tag.attributes?.name || `${tag.attributes?.rel}-${tag.attributes?.sizes}`,
799
- vmid: tag.attributes?.name || `${tag.attributes?.rel}-${tag.attributes?.sizes}`
800
- }))
910
+ meta: metaTags.map((tag) => {
911
+ var _a, _b, _c, _d;
912
+ return __spreadProps(__spreadValues({}, tag.attributes), {
913
+ hid: ((_a = tag.attributes) == null ? void 0 : _a.name) || ((_b = tag.attributes) == null ? void 0 : _b.property),
914
+ vmid: ((_c = tag.attributes) == null ? void 0 : _c.name) || ((_d = tag.attributes) == null ? void 0 : _d.property)
915
+ });
916
+ }),
917
+ link: linkTags.map((tag) => {
918
+ var _a, _b, _c, _d, _e, _f;
919
+ return __spreadProps(__spreadValues({}, tag.attributes), {
920
+ hid: ((_a = tag.attributes) == null ? void 0 : _a.name) || `${(_b = tag.attributes) == null ? void 0 : _b.rel}-${(_c = tag.attributes) == null ? void 0 : _c.sizes}`,
921
+ vmid: ((_d = tag.attributes) == null ? void 0 : _d.name) || `${(_e = tag.attributes) == null ? void 0 : _e.rel}-${(_f = tag.attributes) == null ? void 0 : _f.sizes}`
922
+ });
923
+ })
801
924
  };
802
925
  };
803
926
 
package/dist/index.d.ts CHANGED
@@ -387,7 +387,7 @@ declare type EnabledQueryListenerOptions<QueryResult, QueryVariables> = {
387
387
  } & SubscribeToQueryOptions<QueryResult, QueryVariables>;
388
388
  declare type DisabledQueryListenerOptions<QueryResult, QueryVariables> = {
389
389
  /** Whether the subscription has to be performed or not */
390
- enabled: false | Ref<boolean>;
390
+ enabled: false | Ref<false>;
391
391
  /** The initial data to use while the initial request is being performed */
392
392
  initialData?: QueryResult;
393
393
  } & Partial<SubscribeToQueryOptions<QueryResult, QueryVariables>>;
@@ -44,6 +44,22 @@ const useInView = ({ threshold, rootMargin }) => {
44
44
  return { inView, elRef };
45
45
  };
46
46
 
47
+ var __defProp$4 = Object.defineProperty;
48
+ var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
49
+ var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
50
+ var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
51
+ var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
52
+ var __spreadValues$4 = (a, b) => {
53
+ for (var prop in b || (b = {}))
54
+ if (__hasOwnProp$4.call(b, prop))
55
+ __defNormalProp$4(a, prop, b[prop]);
56
+ if (__getOwnPropSymbols$4)
57
+ for (var prop of __getOwnPropSymbols$4(b)) {
58
+ if (__propIsEnum$4.call(b, prop))
59
+ __defNormalProp$4(a, prop, b[prop]);
60
+ }
61
+ return a;
62
+ };
47
63
  const Source = defineComponent({
48
64
  props: {
49
65
  srcset: {
@@ -57,23 +73,36 @@ const Source = defineComponent({
57
73
  }
58
74
  },
59
75
  setup({ srcset, sizes, type }) {
60
- return () => h("source", {
61
- ...isVue2 && {
62
- attrs: {
63
- srcset,
64
- sizes,
65
- type
66
- }
67
- },
68
- ...isVue3 && {
76
+ return () => h("source", __spreadValues$4(__spreadValues$4({}, isVue2 && {
77
+ attrs: {
69
78
  srcset,
70
79
  sizes,
71
80
  type
72
81
  }
73
- });
82
+ }), isVue3 && {
83
+ srcset,
84
+ sizes,
85
+ type
86
+ }));
74
87
  }
75
88
  });
76
89
 
90
+ var __defProp$3 = Object.defineProperty;
91
+ var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
92
+ var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
93
+ var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
94
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
95
+ var __spreadValues$3 = (a, b) => {
96
+ for (var prop in b || (b = {}))
97
+ if (__hasOwnProp$3.call(b, prop))
98
+ __defNormalProp$3(a, prop, b[prop]);
99
+ if (__getOwnPropSymbols$3)
100
+ for (var prop of __getOwnPropSymbols$3(b)) {
101
+ if (__propIsEnum$3.call(b, prop))
102
+ __defNormalProp$3(a, prop, b[prop]);
103
+ }
104
+ return a;
105
+ };
77
106
  const universalBtoa = (str) => isSsr() ? Buffer.from(str.toString(), "binary").toString("base64") : window.btoa(str);
78
107
  const Sizer = defineComponent({
79
108
  props: {
@@ -96,27 +125,43 @@ const Sizer = defineComponent({
96
125
  },
97
126
  setup({ sizerClass, sizerStyle, width, height, explicitWidth }) {
98
127
  const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}"></svg>`;
99
- return () => h("img", {
128
+ return () => h("img", __spreadValues$3(__spreadValues$3({
100
129
  class: sizerClass,
101
- style: {
130
+ style: __spreadValues$3({
102
131
  display: "block",
103
- width: explicitWidth ? `${width}px` : "100%",
104
- ...sizerStyle
105
- },
106
- ...isVue2 && {
107
- attrs: {
108
- src: `data:image/svg+xml;base64,${universalBtoa(svg)}`,
109
- role: "presentation"
110
- }
111
- },
112
- ...isVue3 && {
132
+ width: explicitWidth ? `${width}px` : "100%"
133
+ }, sizerStyle)
134
+ }, isVue2 && {
135
+ attrs: {
113
136
  src: `data:image/svg+xml;base64,${universalBtoa(svg)}`,
114
137
  role: "presentation"
115
138
  }
116
- });
139
+ }), isVue3 && {
140
+ src: `data:image/svg+xml;base64,${universalBtoa(svg)}`,
141
+ role: "presentation"
142
+ }));
117
143
  }
118
144
  });
119
145
 
146
+ var __defProp$2 = Object.defineProperty;
147
+ var __defProps$2 = Object.defineProperties;
148
+ var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
149
+ var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
150
+ var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
151
+ var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
152
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
153
+ var __spreadValues$2 = (a, b) => {
154
+ for (var prop in b || (b = {}))
155
+ if (__hasOwnProp$2.call(b, prop))
156
+ __defNormalProp$2(a, prop, b[prop]);
157
+ if (__getOwnPropSymbols$2)
158
+ for (var prop of __getOwnPropSymbols$2(b)) {
159
+ if (__propIsEnum$2.call(b, prop))
160
+ __defNormalProp$2(a, prop, b[prop]);
161
+ }
162
+ return a;
163
+ };
164
+ var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
120
165
  const escape = (s) => {
121
166
  s = "" + s;
122
167
  s = s.replace(/&/g, "&amp;");
@@ -312,6 +357,7 @@ const Image = defineComponent({
312
357
  };
313
358
  },
314
359
  render() {
360
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
315
361
  const addImage = imageAddStrategy({
316
362
  lazyLoad: this.computedLazyLoad,
317
363
  inView: this.inView,
@@ -322,34 +368,29 @@ const Image = defineComponent({
322
368
  inView: this.inView,
323
369
  loaded: this.loaded
324
370
  });
325
- const webpSource = this.data.webpSrcSet && h(Source, {
326
- ...isVue2 && {
327
- props: {
328
- srcset: this.data.webpSrcSet,
329
- sizes: this.sizes ?? this.data.sizes ?? void 0,
330
- type: "image/webp"
331
- }
332
- },
333
- ...isVue3 && {
371
+ const webpSource = this.data.webpSrcSet && h(Source, __spreadValues$2(__spreadValues$2({}, isVue2 && {
372
+ props: {
334
373
  srcset: this.data.webpSrcSet,
335
- sizes: this.sizes ?? this.data.sizes ?? void 0,
374
+ sizes: (_b = (_a = this.sizes) != null ? _a : this.data.sizes) != null ? _b : void 0,
336
375
  type: "image/webp"
337
376
  }
338
- });
339
- const regularSource = this.data.srcSet && h(Source, {
340
- ...isVue2 && {
341
- props: {
342
- srcset: this.data.srcSet ?? buildSrcSet(this.data.src, this.data.width, this.srcSetCandidates),
343
- sizes: this.sizes ?? this.data.sizes ?? void 0
344
- }
345
- },
346
- ...isVue3 && {
347
- srcset: this.data.srcSet ?? buildSrcSet(this.data.src, this.data.width, this.srcSetCandidates),
348
- sizes: this.sizes ?? this.data.sizes ?? void 0
377
+ }), isVue3 && {
378
+ srcset: this.data.webpSrcSet,
379
+ sizes: (_d = (_c = this.sizes) != null ? _c : this.data.sizes) != null ? _d : void 0,
380
+ type: "image/webp"
381
+ }));
382
+ const regularSource = this.data.srcSet && h(Source, __spreadValues$2(__spreadValues$2({}, isVue2 && {
383
+ props: {
384
+ srcset: (_e = this.data.srcSet) != null ? _e : buildSrcSet(this.data.src, this.data.width, this.srcSetCandidates),
385
+ sizes: (_g = (_f = this.sizes) != null ? _f : this.data.sizes) != null ? _g : void 0
349
386
  }
350
- });
387
+ }), isVue3 && {
388
+ srcset: (_h = this.data.srcSet) != null ? _h : buildSrcSet(this.data.src, this.data.width, this.srcSetCandidates),
389
+ sizes: (_j = (_i = this.sizes) != null ? _i : this.data.sizes) != null ? _j : void 0
390
+ }));
351
391
  const transition = typeof this.fadeInDuration === "undefined" || this.fadeInDuration > 0 ? `opacity ${this.fadeInDuration || 500}ms ${this.fadeInDuration || 500}ms` : void 0;
352
392
  const placeholder = this.usePlaceholder && (this.data.bgColor || this.data.base64) ? h("div", {
393
+ "aria-hidden": "true",
353
394
  style: {
354
395
  backgroundImage: this.data.base64 ? `url(${this.data.base64})` : null,
355
396
  backgroundColor: this.data.bgColor,
@@ -366,34 +407,29 @@ const Image = defineComponent({
366
407
  }
367
408
  }) : null;
368
409
  const { width, aspectRatio } = this.data;
369
- const height = this.data.height ?? (aspectRatio ? width / aspectRatio : 0);
370
- const sizer = this.layout !== "fill" ? h(Sizer, {
371
- ...isVue2 && {
372
- props: {
373
- sizerClass: this.pictureClass,
374
- sizerStyle: this.pictureStyle,
375
- width,
376
- height,
377
- explicitWidth: this.explicitWidth
378
- }
379
- },
380
- ...isVue3 && {
410
+ const height = (_k = this.data.height) != null ? _k : aspectRatio ? width / aspectRatio : 0;
411
+ const sizer = this.layout !== "fill" ? h(Sizer, __spreadValues$2(__spreadValues$2({}, isVue2 && {
412
+ props: {
381
413
  sizerClass: this.pictureClass,
382
414
  sizerStyle: this.pictureStyle,
383
415
  width,
384
416
  height,
385
417
  explicitWidth: this.explicitWidth
386
418
  }
387
- }) : null;
419
+ }), isVue3 && {
420
+ sizerClass: this.pictureClass,
421
+ sizerStyle: this.pictureStyle,
422
+ width,
423
+ height,
424
+ explicitWidth: this.explicitWidth
425
+ })) : null;
388
426
  return h(
389
427
  "div",
390
428
  {
391
- style: {
429
+ style: __spreadValues$2(__spreadValues$2({
392
430
  display: this.explicitWidth ? "inline-block" : "block",
393
- overflow: "hidden",
394
- ...this.layout === "fill" ? absolutePositioning : this.layout === "intrinsic" ? { position: "relative", width: "100%", maxWidth: `${width}px` } : this.layout === "fixed" ? { position: "relative", width: `${width}px` } : { position: "relative" },
395
- ...this.rootStyle
396
- },
431
+ overflow: "hidden"
432
+ }, 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),
397
433
  ref: "elRef"
398
434
  },
399
435
  [
@@ -402,68 +438,36 @@ const Image = defineComponent({
402
438
  addImage && h("picture", null, [
403
439
  webpSource,
404
440
  regularSource,
405
- this.data.src && h("img", {
406
- ...isVue2 && {
407
- attrs: {
408
- src: this.data.src,
409
- alt: this.data.alt,
410
- title: this.data.title,
411
- fetchpriority: this.priority ? "high" : void 0
412
- },
413
- on: {
414
- load: this.handleLoad
415
- }
416
- },
417
- ...isVue3 && {
441
+ this.data.src && h("img", __spreadProps$2(__spreadValues$2(__spreadValues$2({}, isVue2 && {
442
+ attrs: {
418
443
  src: this.data.src,
419
444
  alt: this.data.alt,
420
445
  title: this.data.title,
421
- fetchpriority: this.priority ? "high" : void 0,
422
- onLoad: this.handleLoad
446
+ fetchpriority: this.priority ? "high" : void 0
423
447
  },
448
+ on: {
449
+ load: this.handleLoad
450
+ }
451
+ }), isVue3 && {
452
+ src: this.data.src,
453
+ alt: this.data.alt,
454
+ title: this.data.title,
455
+ fetchpriority: this.priority ? "high" : void 0,
456
+ onLoad: this.handleLoad
457
+ }), {
424
458
  ref: "imageRef",
425
459
  class: this.pictureClass,
426
- style: {
460
+ style: __spreadValues$2(__spreadProps$2(__spreadValues$2({
427
461
  opacity: showImage ? 1 : 0,
428
- transition,
429
- ...absolutePositioning,
462
+ transition
463
+ }, absolutePositioning), {
430
464
  objectFit: this.objectFit,
431
- objectPosition: this.objectPosition,
432
- ...this.pictureStyle
433
- }
434
- })
465
+ objectPosition: this.objectPosition
466
+ }), this.pictureStyle)
467
+ }))
435
468
  ]),
436
- h("noscript", {
437
- ...isVue2 && {
438
- domProps: {
439
- innerHTML: tag("picture", {}, [
440
- this.data.webpSrcSet && tag("source", {
441
- srcset: this.data.webpSrcSet,
442
- sizes: this.data.sizes,
443
- type: "image/webp"
444
- }),
445
- this.data.srcSet && tag("source", {
446
- srcset: this.data.srcSet,
447
- sizes: this.data.sizes
448
- }),
449
- tag("img", {
450
- src: this.data.src,
451
- alt: this.data.alt,
452
- title: this.data.title,
453
- class: this.pictureClass,
454
- style: toCss({
455
- ...absolutePositioning,
456
- objectFit: this.objectFit,
457
- objectPosition: this.objectPosition,
458
- ...this.pictureStyle
459
- }),
460
- loading: this.computedLazyLoad ? "lazy" : void 0,
461
- fetchpriority: this.priority ? "high" : void 0
462
- })
463
- ])
464
- }
465
- },
466
- ...isVue3 && {
469
+ h("noscript", __spreadValues$2(__spreadValues$2({}, isVue2 && {
470
+ domProps: {
467
471
  innerHTML: tag("picture", {}, [
468
472
  this.data.webpSrcSet && tag("source", {
469
473
  srcset: this.data.webpSrcSet,
@@ -479,13 +483,37 @@ const Image = defineComponent({
479
483
  alt: this.data.alt,
480
484
  title: this.data.title,
481
485
  class: this.pictureClass,
482
- style: toCss({ ...this.pictureStyle, ...absolutePositioning }),
486
+ style: toCss(__spreadValues$2(__spreadProps$2(__spreadValues$2({}, absolutePositioning), {
487
+ objectFit: this.objectFit,
488
+ objectPosition: this.objectPosition
489
+ }), this.pictureStyle)),
483
490
  loading: this.computedLazyLoad ? "lazy" : void 0,
484
491
  fetchpriority: this.priority ? "high" : void 0
485
492
  })
486
493
  ])
487
494
  }
488
- })
495
+ }), isVue3 && {
496
+ innerHTML: tag("picture", {}, [
497
+ this.data.webpSrcSet && tag("source", {
498
+ srcset: this.data.webpSrcSet,
499
+ sizes: this.data.sizes,
500
+ type: "image/webp"
501
+ }),
502
+ this.data.srcSet && tag("source", {
503
+ srcset: this.data.srcSet,
504
+ sizes: this.data.sizes
505
+ }),
506
+ tag("img", {
507
+ src: this.data.src,
508
+ alt: this.data.alt,
509
+ title: this.data.title,
510
+ class: this.pictureClass,
511
+ style: toCss(__spreadValues$2(__spreadValues$2({}, this.pictureStyle), absolutePositioning)),
512
+ loading: this.computedLazyLoad ? "lazy" : void 0,
513
+ fetchpriority: this.priority ? "high" : void 0
514
+ })
515
+ ])
516
+ }))
489
517
  ]
490
518
  );
491
519
  }
@@ -657,15 +685,66 @@ const DatocmsStructuredTextPlugin = {
657
685
  }
658
686
  };
659
687
 
660
- const useQuerySubscription = ({ enabled = true, initialData, query, token, ...other }) => {
688
+ var __defProp$1 = Object.defineProperty;
689
+ var __defProps$1 = Object.defineProperties;
690
+ var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
691
+ var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
692
+ var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
693
+ var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
694
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
695
+ var __spreadValues$1 = (a, b) => {
696
+ for (var prop in b || (b = {}))
697
+ if (__hasOwnProp$1.call(b, prop))
698
+ __defNormalProp$1(a, prop, b[prop]);
699
+ if (__getOwnPropSymbols$1)
700
+ for (var prop of __getOwnPropSymbols$1(b)) {
701
+ if (__propIsEnum$1.call(b, prop))
702
+ __defNormalProp$1(a, prop, b[prop]);
703
+ }
704
+ return a;
705
+ };
706
+ var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
707
+ var __objRest = (source, exclude) => {
708
+ var target = {};
709
+ for (var prop in source)
710
+ if (__hasOwnProp$1.call(source, prop) && exclude.indexOf(prop) < 0)
711
+ target[prop] = source[prop];
712
+ if (source != null && __getOwnPropSymbols$1)
713
+ for (var prop of __getOwnPropSymbols$1(source)) {
714
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$1.call(source, prop))
715
+ target[prop] = source[prop];
716
+ }
717
+ return target;
718
+ };
719
+ var __async$1 = (__this, __arguments, generator) => {
720
+ return new Promise((resolve, reject) => {
721
+ var fulfilled = (value) => {
722
+ try {
723
+ step(generator.next(value));
724
+ } catch (e) {
725
+ reject(e);
726
+ }
727
+ };
728
+ var rejected = (value) => {
729
+ try {
730
+ step(generator.throw(value));
731
+ } catch (e) {
732
+ reject(e);
733
+ }
734
+ };
735
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
736
+ step((generator = generator.apply(__this, __arguments)).next());
737
+ });
738
+ };
739
+ const useQuerySubscription = (_a) => {
740
+ var _b = _a, { enabled = true, initialData, query, token } = _b, other = __objRest(_b, ["enabled", "initialData", "query", "token"]);
661
741
  const error = ref(null);
662
742
  const data = ref(unref(initialData) || null);
663
743
  const status = ref(unref(enabled) ? "connecting" : "closed");
664
744
  const subscribeToQueryOptions = other;
665
- watchEffect(async (onCleanup) => {
745
+ watchEffect((onCleanup) => __async$1(void 0, null, function* () {
666
746
  if (query && token && unref(enabled)) {
667
- const unsubscribe = await subscribeToQuery({
668
- ...subscribeToQueryOptions,
747
+ const unsubscribe = yield subscribeToQuery(__spreadProps$1(__spreadValues$1({}, subscribeToQueryOptions), {
669
748
  query,
670
749
  token,
671
750
  onStatusChange: (connectionStatus) => {
@@ -679,13 +758,33 @@ const useQuerySubscription = ({ enabled = true, initialData, query, token, ...ot
679
758
  data.value = null;
680
759
  error.value = errorData;
681
760
  }
682
- });
761
+ }));
683
762
  onCleanup(unsubscribe);
684
763
  }
685
- });
764
+ }));
686
765
  return { data, status, error };
687
766
  };
688
767
 
768
+ var __async = (__this, __arguments, generator) => {
769
+ return new Promise((resolve, reject) => {
770
+ var fulfilled = (value) => {
771
+ try {
772
+ step(generator.next(value));
773
+ } catch (e) {
774
+ reject(e);
775
+ }
776
+ };
777
+ var rejected = (value) => {
778
+ try {
779
+ step(generator.throw(value));
780
+ } catch (e) {
781
+ reject(e);
782
+ }
783
+ };
784
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
785
+ step((generator = generator.apply(__this, __arguments)).next());
786
+ });
787
+ };
689
788
  const highlightPieces = (textWithHighlightMarker) => {
690
789
  return textWithHighlightMarker.split(/\[h\](.+?)\[\/h\]/g).map((text, index) => ({
691
790
  text,
@@ -693,10 +792,11 @@ const highlightPieces = (textWithHighlightMarker) => {
693
792
  }));
694
793
  };
695
794
  function useSiteSearch(config) {
795
+ var _a, _b, _c;
696
796
  const state = reactive({
697
- query: config.initialState?.query || "",
698
- page: config.initialState?.page || 0,
699
- locale: config.initialState?.locale
797
+ query: ((_a = config.initialState) == null ? void 0 : _a.query) || "",
798
+ page: ((_b = config.initialState) == null ? void 0 : _b.page) || 0,
799
+ locale: (_c = config.initialState) == null ? void 0 : _c.locale
700
800
  });
701
801
  const error = ref();
702
802
  const response = reactive({
@@ -707,7 +807,7 @@ function useSiteSearch(config) {
707
807
  const resultsPerPage = config.resultsPerPage || 8;
708
808
  watchEffect((onCleanup) => {
709
809
  let isCancelled = false;
710
- const run = async () => {
810
+ const run = () => __async(this, null, function* () {
711
811
  try {
712
812
  if (!state.query) {
713
813
  response.data = [];
@@ -728,7 +828,7 @@ function useSiteSearch(config) {
728
828
  if (config.fuzzySearch) {
729
829
  request.fuzzy = "true";
730
830
  }
731
- const results = await config.client.searchResults.rawList(request);
831
+ const results = yield config.client.searchResults.rawList(request);
732
832
  if (!isCancelled) {
733
833
  response.data = results.data;
734
834
  response.meta.total_count = results.meta.total_count;
@@ -743,7 +843,7 @@ function useSiteSearch(config) {
743
843
  error.value = "Unknown error!";
744
844
  }
745
845
  }
746
- };
846
+ });
747
847
  run();
748
848
  onCleanup(() => {
749
849
  isCancelled = true;
@@ -775,6 +875,25 @@ function useSiteSearch(config) {
775
875
  };
776
876
  }
777
877
 
878
+ var __defProp = Object.defineProperty;
879
+ var __defProps = Object.defineProperties;
880
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
881
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
882
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
883
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
884
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
885
+ var __spreadValues = (a, b) => {
886
+ for (var prop in b || (b = {}))
887
+ if (__hasOwnProp.call(b, prop))
888
+ __defNormalProp(a, prop, b[prop]);
889
+ if (__getOwnPropSymbols)
890
+ for (var prop of __getOwnPropSymbols(b)) {
891
+ if (__propIsEnum.call(b, prop))
892
+ __defNormalProp(a, prop, b[prop]);
893
+ }
894
+ return a;
895
+ };
896
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
778
897
  const toHead = (...args) => {
779
898
  const tags = [].concat(...args);
780
899
  const titleTag = tags && tags.find((t) => t.tag === "title");
@@ -782,16 +901,20 @@ const toHead = (...args) => {
782
901
  const linkTags = tags ? tags.filter((t) => t.tag === "link") : [];
783
902
  return {
784
903
  title: titleTag && titleTag.content,
785
- meta: metaTags.map((tag) => ({
786
- ...tag.attributes,
787
- hid: tag.attributes?.name || tag.attributes?.property,
788
- vmid: tag.attributes?.name || tag.attributes?.property
789
- })),
790
- link: linkTags.map((tag) => ({
791
- ...tag.attributes,
792
- hid: tag.attributes?.name || `${tag.attributes?.rel}-${tag.attributes?.sizes}`,
793
- vmid: tag.attributes?.name || `${tag.attributes?.rel}-${tag.attributes?.sizes}`
794
- }))
904
+ meta: metaTags.map((tag) => {
905
+ var _a, _b, _c, _d;
906
+ return __spreadProps(__spreadValues({}, tag.attributes), {
907
+ hid: ((_a = tag.attributes) == null ? void 0 : _a.name) || ((_b = tag.attributes) == null ? void 0 : _b.property),
908
+ vmid: ((_c = tag.attributes) == null ? void 0 : _c.name) || ((_d = tag.attributes) == null ? void 0 : _d.property)
909
+ });
910
+ }),
911
+ link: linkTags.map((tag) => {
912
+ var _a, _b, _c, _d, _e, _f;
913
+ return __spreadProps(__spreadValues({}, tag.attributes), {
914
+ hid: ((_a = tag.attributes) == null ? void 0 : _a.name) || `${(_b = tag.attributes) == null ? void 0 : _b.rel}-${(_c = tag.attributes) == null ? void 0 : _c.sizes}`,
915
+ vmid: ((_d = tag.attributes) == null ? void 0 : _d.name) || `${(_e = tag.attributes) == null ? void 0 : _e.rel}-${(_f = tag.attributes) == null ? void 0 : _f.sizes}`
916
+ });
917
+ })
795
918
  };
796
919
  };
797
920
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-datocms",
3
- "version": "4.0.1",
3
+ "version": "4.0.3",
4
4
  "description": "A set of components and utilities to work faster with DatoCMS in Vue.js environments",
5
5
  "keywords": [
6
6
  "datocms",
@@ -46,7 +46,7 @@
46
46
  },
47
47
  "peerDependencies": {
48
48
  "@vue/composition-api": "^1.7.1",
49
- "vue": "^2.0.0 || >=3.0.0"
49
+ "vue": ">= 2.5 < 2.7 || >=3.0.0"
50
50
  },
51
51
  "peerDependenciesMeta": {
52
52
  "@vue/composition-api": {