@nuxt/scripts 0.13.2 → 1.0.0-beta.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. package/README.md +15 -0
  2. package/dist/client/200.html +1 -1
  3. package/dist/client/404.html +1 -1
  4. package/dist/client/_nuxt/48AF9EJD.js +1 -0
  5. package/dist/client/_nuxt/Bk6ed9rg.js +1 -0
  6. package/dist/client/_nuxt/C4Cj8gBr.js +162 -0
  7. package/dist/client/_nuxt/{Bje-0OHL.js → DP0kj6Xn.js} +1 -1
  8. package/dist/client/_nuxt/builds/latest.json +1 -1
  9. package/dist/client/_nuxt/builds/meta/919b81d8-ed3a-4222-8a40-df0031cc3b99.json +1 -0
  10. package/dist/client/_nuxt/entry.D45OuV0w.css +1 -0
  11. package/dist/client/_nuxt/error-404.B57D-jUQ.css +1 -0
  12. package/dist/client/_nuxt/error-500.DTHUW7BI.css +1 -0
  13. package/dist/client/index.html +1 -1
  14. package/dist/module.d.mts +113 -4
  15. package/dist/module.d.ts +176 -0
  16. package/dist/module.json +1 -1
  17. package/dist/module.mjs +780 -299
  18. package/dist/registry.d.ts +6 -0
  19. package/dist/registry.mjs +94 -18
  20. package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.d.vue.ts +30 -2
  21. package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.vue +40 -15
  22. package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.vue.d.ts +30 -2
  23. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsAdvancedMarkerElement.vue +6 -6
  24. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsCircle.vue +7 -7
  25. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsHeatmapLayer.vue +6 -6
  26. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsInfoWindow.vue +12 -12
  27. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarker.vue +6 -6
  28. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarkerClusterer.d.vue.ts +21 -9
  29. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarkerClusterer.vue +8 -8
  30. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarkerClusterer.vue.d.ts +21 -9
  31. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPinElement.vue +11 -5
  32. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolygon.vue +7 -7
  33. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolyline.vue +7 -7
  34. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsRectangle.vue +7 -7
  35. package/dist/runtime/components/ScriptCrisp.d.vue.ts +1 -1
  36. package/dist/runtime/components/ScriptCrisp.vue +1 -1
  37. package/dist/runtime/components/ScriptCrisp.vue.d.ts +1 -1
  38. package/dist/runtime/components/ScriptGoogleAdsense.vue +1 -1
  39. package/dist/runtime/components/ScriptInstagramEmbed.d.vue.ts +53 -0
  40. package/dist/runtime/components/ScriptInstagramEmbed.vue +38 -0
  41. package/dist/runtime/components/ScriptInstagramEmbed.vue.d.ts +53 -0
  42. package/dist/runtime/components/ScriptIntercom.d.vue.ts +1 -1
  43. package/dist/runtime/components/ScriptIntercom.vue +4 -3
  44. package/dist/runtime/components/ScriptIntercom.vue.d.ts +1 -1
  45. package/dist/runtime/components/ScriptPayPalButtons.d.vue.ts +2 -2
  46. package/dist/runtime/components/ScriptPayPalButtons.vue +13 -11
  47. package/dist/runtime/components/ScriptPayPalButtons.vue.d.ts +2 -2
  48. package/dist/runtime/components/ScriptPayPalMarks.d.vue.ts +2 -2
  49. package/dist/runtime/components/ScriptPayPalMarks.vue +10 -8
  50. package/dist/runtime/components/ScriptPayPalMarks.vue.d.ts +2 -2
  51. package/dist/runtime/components/ScriptPayPalMessages.d.vue.ts +2 -2
  52. package/dist/runtime/components/ScriptPayPalMessages.vue +11 -9
  53. package/dist/runtime/components/ScriptPayPalMessages.vue.d.ts +2 -2
  54. package/dist/runtime/components/ScriptStripePricingTable.vue +2 -2
  55. package/dist/runtime/components/ScriptVimeoPlayer.d.vue.ts +2 -2
  56. package/dist/runtime/components/ScriptVimeoPlayer.vue +1 -1
  57. package/dist/runtime/components/ScriptVimeoPlayer.vue.d.ts +2 -2
  58. package/dist/runtime/components/ScriptXEmbed.d.vue.ts +82 -0
  59. package/dist/runtime/components/ScriptXEmbed.vue +76 -0
  60. package/dist/runtime/components/ScriptXEmbed.vue.d.ts +82 -0
  61. package/dist/runtime/components/ScriptYouTubePlayer.d.vue.ts +12 -1
  62. package/dist/runtime/components/ScriptYouTubePlayer.vue +44 -16
  63. package/dist/runtime/components/ScriptYouTubePlayer.vue.d.ts +12 -1
  64. package/dist/runtime/composables/useScript.js +36 -5
  65. package/dist/runtime/composables/useScriptEventPage.js +2 -2
  66. package/dist/runtime/composables/useScriptTriggerConsent.js +1 -1
  67. package/dist/runtime/composables/useScriptTriggerElement.js +1 -1
  68. package/dist/runtime/composables/useScriptTriggerIdleTimeout.js +1 -1
  69. package/dist/runtime/composables/useScriptTriggerServiceWorker.d.ts +7 -0
  70. package/dist/runtime/composables/useScriptTriggerServiceWorker.js +39 -0
  71. package/dist/runtime/npm-script-stub.d.ts +20 -0
  72. package/dist/runtime/npm-script-stub.js +73 -0
  73. package/dist/runtime/registry/clarity.js +21 -25
  74. package/dist/runtime/registry/cloudflare-web-analytics.js +1 -1
  75. package/dist/runtime/registry/crisp.js +1 -1
  76. package/dist/runtime/registry/databuddy-analytics.js +1 -1
  77. package/dist/runtime/registry/fathom-analytics.js +1 -1
  78. package/dist/runtime/registry/google-adsense.js +1 -1
  79. package/dist/runtime/registry/google-analytics.js +2 -2
  80. package/dist/runtime/registry/google-maps.d.ts +1 -1
  81. package/dist/runtime/registry/google-maps.js +1 -1
  82. package/dist/runtime/registry/google-recaptcha.d.ts +27 -0
  83. package/dist/runtime/registry/google-recaptcha.js +45 -0
  84. package/dist/runtime/registry/google-sign-in.d.ts +84 -0
  85. package/dist/runtime/registry/google-sign-in.js +50 -0
  86. package/dist/runtime/registry/google-tag-manager.d.ts +4 -2
  87. package/dist/runtime/registry/google-tag-manager.js +16 -6
  88. package/dist/runtime/registry/hotjar.js +1 -1
  89. package/dist/runtime/registry/instagram-embed.d.ts +23 -0
  90. package/dist/runtime/registry/instagram-embed.js +22 -0
  91. package/dist/runtime/registry/intercom.js +1 -1
  92. package/dist/runtime/registry/lemon-squeezy.d.ts +0 -1
  93. package/dist/runtime/registry/matomo-analytics.js +3 -3
  94. package/dist/runtime/registry/meta-pixel.js +1 -1
  95. package/dist/runtime/registry/npm.js +1 -1
  96. package/dist/runtime/registry/paypal.d.ts +1 -1
  97. package/dist/runtime/registry/paypal.js +2 -2
  98. package/dist/runtime/registry/plausible-analytics.js +21 -13
  99. package/dist/runtime/registry/posthog.d.ts +27 -0
  100. package/dist/runtime/registry/posthog.js +88 -0
  101. package/dist/runtime/registry/reddit-pixel.js +1 -1
  102. package/dist/runtime/registry/rybbit-analytics.js +41 -9
  103. package/dist/runtime/registry/segment.js +1 -1
  104. package/dist/runtime/registry/snapchat-pixel.js +1 -1
  105. package/dist/runtime/registry/stripe.d.ts +1 -1
  106. package/dist/runtime/registry/stripe.js +1 -1
  107. package/dist/runtime/registry/tiktok-pixel.d.ts +44 -0
  108. package/dist/runtime/registry/tiktok-pixel.js +44 -0
  109. package/dist/runtime/registry/umami-analytics.js +1 -1
  110. package/dist/runtime/registry/vimeo-player.d.ts +2 -2
  111. package/dist/runtime/registry/vimeo-player.js +1 -1
  112. package/dist/runtime/registry/x-embed.d.ts +77 -0
  113. package/dist/runtime/registry/x-embed.js +41 -0
  114. package/dist/runtime/registry/x-pixel.js +1 -1
  115. package/dist/runtime/registry/youtube-player.d.ts +7 -7
  116. package/dist/runtime/registry/youtube-player.js +1 -1
  117. package/dist/runtime/server/google-static-maps-proxy.d.ts +2 -0
  118. package/dist/runtime/server/google-static-maps-proxy.js +54 -0
  119. package/dist/runtime/server/instagram-embed-asset.d.ts +2 -0
  120. package/dist/runtime/server/instagram-embed-asset.js +42 -0
  121. package/dist/runtime/server/instagram-embed-image.d.ts +2 -0
  122. package/dist/runtime/server/instagram-embed-image.js +54 -0
  123. package/dist/runtime/server/instagram-embed.d.ts +2 -0
  124. package/dist/runtime/server/instagram-embed.js +91 -0
  125. package/dist/runtime/server/proxy-handler.d.ts +6 -0
  126. package/dist/runtime/server/proxy-handler.js +264 -0
  127. package/dist/runtime/server/utils/privacy.d.ts +141 -0
  128. package/dist/runtime/server/utils/privacy.js +324 -0
  129. package/dist/runtime/server/x-embed-image.d.ts +2 -0
  130. package/dist/runtime/server/x-embed-image.js +53 -0
  131. package/dist/runtime/server/x-embed.d.ts +49 -0
  132. package/dist/runtime/server/x-embed.js +31 -0
  133. package/dist/runtime/types.d.ts +61 -20
  134. package/dist/runtime/utils/pure.d.ts +9 -0
  135. package/dist/runtime/utils/pure.js +0 -0
  136. package/dist/runtime/utils.d.ts +5 -4
  137. package/dist/runtime/utils.js +12 -2
  138. package/dist/shared/scripts.DLRgvHQg.mjs +288 -0
  139. package/dist/stats.d.mts +39 -0
  140. package/dist/stats.d.ts +39 -0
  141. package/dist/stats.mjs +711 -0
  142. package/dist/types.d.mts +1 -1
  143. package/package.json +59 -46
  144. package/dist/client/_nuxt/DMut0W-e.js +0 -162
  145. package/dist/client/_nuxt/builds/meta/5e0206fe-a683-423c-8d59-2596d0b16fee.json +0 -1
  146. package/dist/client/_nuxt/entry.BjfcJo5q.css +0 -1
  147. package/dist/client/_nuxt/error-404.B0ZhSNwd.css +0 -1
  148. package/dist/client/_nuxt/error-500.D4MdgPaC.css +0 -1
  149. package/dist/client/_nuxt/iNmKC7TZ.js +0 -1
  150. package/dist/client/_nuxt/rttsH3SL.js +0 -1
@@ -14,7 +14,7 @@ type __VLS_Props = {
14
14
  trigger?: ElementScriptTrigger;
15
15
  };
16
16
  declare var __VLS_1: {
17
- ready: any;
17
+ ready: boolean;
18
18
  }, __VLS_3: {}, __VLS_5: {}, __VLS_7: {};
19
19
  type __VLS_Slots = {} & {
20
20
  default?: (props: typeof __VLS_1) => any;
@@ -1,6 +1,6 @@
1
- import { type HTMLAttributes, type ReservedProps } from 'vue';
2
- import type { OnApproveActions, OnApproveData, OnCancelledActions, OnClickActions, OnShippingAddressChangeActions, OnShippingAddressChangeData, OnShippingOptionsChangeActions, OnShippingOptionsChangeData, PayPalButtonsComponentOptions, OnInitActions } from '@paypal/paypal-js';
3
1
  import type { ElementScriptTrigger } from '#nuxt-scripts/types';
2
+ import type { OnApproveActions, OnApproveData, OnCancelledActions, OnClickActions, OnInitActions, OnShippingAddressChangeActions, OnShippingAddressChangeData, OnShippingOptionsChangeActions, OnShippingOptionsChangeData, PayPalButtonsComponentOptions } from '@paypal/paypal-js';
3
+ import type { HTMLAttributes, ReservedProps } from 'vue';
4
4
  import type { PayPalInput } from '../registry/paypal.js';
5
5
  type __VLS_Props = {
6
6
  /**
@@ -1,11 +1,8 @@
1
1
  <script setup>
2
- import { computed, onMounted, ref, shallowRef, watch } from "vue";
3
2
  import { defu } from "defu";
4
- import { useScriptPayPal } from "../registry/paypal";
3
+ import { computed, onBeforeUnmount, onMounted, ref, resolveComponent, shallowRef, watch } from "vue";
5
4
  import { useScriptTriggerElement } from "../composables/useScriptTriggerElement";
6
- import { onBeforeUnmount, resolveComponent } from "vue";
7
- const el = ref(null);
8
- const rootEl = ref(null);
5
+ import { useScriptPayPal } from "../registry/paypal";
9
6
  const props = defineProps({
10
7
  rootAttrs: { type: Object, required: false },
11
8
  trigger: { type: [String, Array, Boolean], required: false, default: "visible" },
@@ -14,21 +11,24 @@ const props = defineProps({
14
11
  paypalScriptOptions: { type: Object, required: false, default: () => ({}) },
15
12
  disabled: { type: Boolean, required: false, default: false }
16
13
  });
14
+ const emit = defineEmits(["approve", "error", "cancel", "clickButtons", "shippingOptionsChange", "shippingAddressChange", "init"]);
15
+ const el = ref(null);
16
+ const rootEl = ref(null);
17
17
  const ready = ref(false);
18
18
  const { onLoaded, status } = useScriptPayPal({
19
19
  clientId: props.clientId,
20
20
  ...props.paypalScriptOptions
21
21
  });
22
- const emit = defineEmits(["approve", "error", "cancel", "clickButtons", "shippingOptionsChange", "shippingAddressChange", "init"]);
23
22
  const initActions = shallowRef(null);
24
- const handleDisabled = () => {
25
- if (!initActions.value) return;
23
+ function handleDisabled() {
24
+ if (!initActions.value)
25
+ return;
26
26
  if (props.disabled) {
27
27
  initActions.value.disable();
28
28
  } else {
29
29
  initActions.value.enable();
30
30
  }
31
- };
31
+ }
32
32
  const options = computed(() => {
33
33
  const _options = {
34
34
  onApprove: async (data, actions) => {
@@ -69,12 +69,14 @@ watch(() => props.disabled, handleDisabled);
69
69
  const buttonInst = shallowRef();
70
70
  onMounted(() => {
71
71
  onLoaded(async ({ paypal }) => {
72
- if (!el.value) return;
72
+ if (!el.value)
73
+ return;
73
74
  buttonInst.value = paypal?.Buttons?.(options.value);
74
75
  await buttonInst.value?.render(el.value);
75
76
  ready.value = true;
76
77
  watch(() => options.value, async (_options) => {
77
- if (!el.value) return;
78
+ if (!el.value)
79
+ return;
78
80
  await buttonInst.value?.updateProps(_options);
79
81
  });
80
82
  });
@@ -1,6 +1,6 @@
1
- import { type HTMLAttributes, type ReservedProps } from 'vue';
2
- import type { OnApproveActions, OnApproveData, OnCancelledActions, OnClickActions, OnShippingAddressChangeActions, OnShippingAddressChangeData, OnShippingOptionsChangeActions, OnShippingOptionsChangeData, PayPalButtonsComponentOptions, OnInitActions } from '@paypal/paypal-js';
3
1
  import type { ElementScriptTrigger } from '#nuxt-scripts/types';
2
+ import type { OnApproveActions, OnApproveData, OnCancelledActions, OnClickActions, OnInitActions, OnShippingAddressChangeActions, OnShippingAddressChangeData, OnShippingOptionsChangeActions, OnShippingOptionsChangeData, PayPalButtonsComponentOptions } from '@paypal/paypal-js';
3
+ import type { HTMLAttributes, ReservedProps } from 'vue';
4
4
  import type { PayPalInput } from '../registry/paypal.js';
5
5
  type __VLS_Props = {
6
6
  /**
@@ -1,6 +1,6 @@
1
- import { type HTMLAttributes, type ReservedProps } from 'vue';
2
- import type { PayPalMarksComponentOptions } from '@paypal/paypal-js';
3
1
  import type { ElementScriptTrigger } from '#nuxt-scripts/types';
2
+ import type { PayPalMarksComponentOptions } from '@paypal/paypal-js';
3
+ import type { HTMLAttributes, ReservedProps } from 'vue';
4
4
  import type { PayPalInput } from '../registry/paypal.js';
5
5
  type __VLS_Props = {
6
6
  /**
@@ -1,11 +1,8 @@
1
1
  <script setup>
2
- import { computed, onMounted, ref, shallowRef, watch } from "vue";
3
2
  import { defu } from "defu";
4
- import { useScriptPayPal } from "../registry/paypal";
3
+ import { computed, onBeforeUnmount, onMounted, ref, resolveComponent, shallowRef, watch } from "vue";
5
4
  import { useScriptTriggerElement } from "../composables/useScriptTriggerElement";
6
- import { onBeforeUnmount, resolveComponent } from "vue";
7
- const el = ref(null);
8
- const rootEl = ref(null);
5
+ import { useScriptPayPal } from "../registry/paypal";
9
6
  const props = defineProps({
10
7
  rootAttrs: { type: Object, required: false },
11
8
  trigger: { type: [String, Array, Boolean], required: false, default: "visible" },
@@ -13,6 +10,8 @@ const props = defineProps({
13
10
  marksOptions: { type: Object, required: false, default: () => ({}) },
14
11
  paypalScriptOptions: { type: Object, required: false, default: () => ({}) }
15
12
  });
13
+ const el = ref(null);
14
+ const rootEl = ref(null);
16
15
  const ready = ref(false);
17
16
  const { onLoaded, status } = useScriptPayPal({
18
17
  clientId: props.clientId,
@@ -21,12 +20,14 @@ const { onLoaded, status } = useScriptPayPal({
21
20
  const marksInst = shallowRef();
22
21
  onMounted(() => {
23
22
  onLoaded(async ({ paypal }) => {
24
- if (!el.value) return;
23
+ if (!el.value)
24
+ return;
25
25
  marksInst.value = paypal?.Marks?.(props.marksOptions);
26
26
  await marksInst.value?.render(el.value);
27
27
  ready.value = true;
28
28
  watch(() => props.marksOptions, async (_options) => {
29
- if (!el.value) return;
29
+ if (!el.value)
30
+ return;
30
31
  destroy();
31
32
  marksInst.value = paypal?.Marks?.(_options);
32
33
  await marksInst.value?.render(el.value);
@@ -34,7 +35,8 @@ onMounted(() => {
34
35
  });
35
36
  });
36
37
  function destroy() {
37
- if (!el.value) return;
38
+ if (!el.value)
39
+ return;
38
40
  el.value?.replaceChildren();
39
41
  }
40
42
  onBeforeUnmount(() => {
@@ -1,6 +1,6 @@
1
- import { type HTMLAttributes, type ReservedProps } from 'vue';
2
- import type { PayPalMarksComponentOptions } from '@paypal/paypal-js';
3
1
  import type { ElementScriptTrigger } from '#nuxt-scripts/types';
2
+ import type { PayPalMarksComponentOptions } from '@paypal/paypal-js';
3
+ import type { HTMLAttributes, ReservedProps } from 'vue';
4
4
  import type { PayPalInput } from '../registry/paypal.js';
5
5
  type __VLS_Props = {
6
6
  /**
@@ -1,6 +1,6 @@
1
- import { type HTMLAttributes, type ReservedProps } from 'vue';
2
- import type { PayPalMessagesComponentOptions } from '@paypal/paypal-js';
3
1
  import type { ElementScriptTrigger } from '#nuxt-scripts/types';
2
+ import type { PayPalMessagesComponentOptions } from '@paypal/paypal-js';
3
+ import type { HTMLAttributes, ReservedProps } from 'vue';
4
4
  import type { PayPalInput } from '../registry/paypal.js';
5
5
  type __VLS_Props = {
6
6
  /**
@@ -1,11 +1,8 @@
1
1
  <script setup>
2
- import { computed, onMounted, ref, shallowRef, watch } from "vue";
3
2
  import { defu } from "defu";
4
- import { useScriptPayPal } from "../registry/paypal";
3
+ import { computed, onBeforeUnmount, onMounted, ref, resolveComponent, shallowRef, watch } from "vue";
5
4
  import { useScriptTriggerElement } from "../composables/useScriptTriggerElement";
6
- import { onBeforeUnmount, resolveComponent } from "vue";
7
- const el = ref(null);
8
- const rootEl = ref(null);
5
+ import { useScriptPayPal } from "../registry/paypal";
9
6
  const props = defineProps({
10
7
  rootAttrs: { type: Object, required: false },
11
8
  trigger: { type: [String, Array, Boolean], required: false, default: "visible" },
@@ -15,6 +12,9 @@ const props = defineProps({
15
12
  partnerAttributionId: { type: String, required: false },
16
13
  paypalScriptOptions: { type: Object, required: false, default: () => ({}) }
17
14
  });
15
+ const emit = defineEmits(["apply", "clickMessages", "render"]);
16
+ const el = ref(null);
17
+ const rootEl = ref(null);
18
18
  const ready = ref(false);
19
19
  const { onLoaded, status } = useScriptPayPal({
20
20
  clientId: props.clientId,
@@ -22,7 +22,6 @@ const { onLoaded, status } = useScriptPayPal({
22
22
  partnerAttributionId: props.partnerAttributionId,
23
23
  ...props.paypalScriptOptions
24
24
  });
25
- const emit = defineEmits(["apply", "clickMessages", "render"]);
26
25
  const options = computed(() => {
27
26
  const _options = {
28
27
  onApply: (data) => {
@@ -43,19 +42,22 @@ const options = computed(() => {
43
42
  const messageInst = shallowRef();
44
43
  onMounted(() => {
45
44
  onLoaded(async ({ paypal }) => {
46
- if (!el.value) return;
45
+ if (!el.value)
46
+ return;
47
47
  messageInst.value = paypal?.Messages?.(options.value);
48
48
  await messageInst.value?.render(el.value);
49
49
  ready.value = true;
50
50
  watch(() => options.value, async (_options) => {
51
- if (!el.value) return;
51
+ if (!el.value)
52
+ return;
52
53
  messageInst.value = paypal?.Messages?.(_options);
53
54
  await messageInst.value?.render(el.value);
54
55
  });
55
56
  });
56
57
  });
57
58
  function destroy() {
58
- if (!el.value) return;
59
+ if (!el.value)
60
+ return;
59
61
  el.value?.replaceChildren();
60
62
  }
61
63
  onBeforeUnmount(() => {
@@ -1,6 +1,6 @@
1
- import { type HTMLAttributes, type ReservedProps } from 'vue';
2
- import type { PayPalMessagesComponentOptions } from '@paypal/paypal-js';
3
1
  import type { ElementScriptTrigger } from '#nuxt-scripts/types';
2
+ import type { PayPalMessagesComponentOptions } from '@paypal/paypal-js';
3
+ import type { HTMLAttributes, ReservedProps } from 'vue';
4
4
  import type { PayPalInput } from '../registry/paypal.js';
5
5
  type __VLS_Props = {
6
6
  /**
@@ -1,7 +1,7 @@
1
1
  <script setup>
2
- import { ref, computed, onBeforeUnmount, onMounted, watch } from "vue";
3
- import { useScriptTriggerElement } from "../composables/useScriptTriggerElement";
2
+ import { computed, onBeforeUnmount, onMounted, ref, watch } from "vue";
4
3
  import { useScript } from "../composables/useScript";
4
+ import { useScriptTriggerElement } from "../composables/useScriptTriggerElement";
5
5
  const props = defineProps({
6
6
  trigger: { type: [String, Array, Boolean], required: false, default: "visible" },
7
7
  publishableKey: { type: String, required: true },
@@ -64,6 +64,7 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
64
64
  getPlaybackRate: () => Promise<number> | undefined;
65
65
  setPlaybackRate: (rate: number) => Promise<number> | undefined;
66
66
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
67
+ progress: (event: import("@vimeo/player").TimeEvent, player: Vimeo.Player) => any;
67
68
  error: (event: import("@vimeo/player").Error, player: Vimeo.Player) => any;
68
69
  loaded: (event: import("@vimeo/player").LoadedEvent, player: Vimeo.Player) => any;
69
70
  cuechange: (event: import("@vimeo/player").CueChangeEvent, player: Vimeo.Player) => any;
@@ -72,7 +73,6 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
72
73
  pause: (event: import("@vimeo/player").TimeEvent, player: Vimeo.Player) => any;
73
74
  play: (event: import("@vimeo/player").TimeEvent, player: Vimeo.Player) => any;
74
75
  playing: (event: import("@vimeo/player").TimeEvent, player: Vimeo.Player) => any;
75
- progress: (event: import("@vimeo/player").TimeEvent, player: Vimeo.Player) => any;
76
76
  resize: (event: import("@vimeo/player").ResizeEvent, player: Vimeo.Player) => any;
77
77
  seeked: (event: import("@vimeo/player").TimeEvent, player: Vimeo.Player) => any;
78
78
  seeking: (event: import("@vimeo/player").TimeEvent, player: Vimeo.Player) => any;
@@ -90,6 +90,7 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
90
90
  enterpictureinpicture: (event: never, player: Vimeo.Player) => any;
91
91
  leavepictureinpicture: (event: never, player: Vimeo.Player) => any;
92
92
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
93
+ onProgress?: ((event: import("@vimeo/player").TimeEvent, player: Vimeo.Player) => any) | undefined;
93
94
  onError?: ((event: import("@vimeo/player").Error, player: Vimeo.Player) => any) | undefined;
94
95
  onLoaded?: ((event: import("@vimeo/player").LoadedEvent, player: Vimeo.Player) => any) | undefined;
95
96
  onCuechange?: ((event: import("@vimeo/player").CueChangeEvent, player: Vimeo.Player) => any) | undefined;
@@ -98,7 +99,6 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
98
99
  onPause?: ((event: import("@vimeo/player").TimeEvent, player: Vimeo.Player) => any) | undefined;
99
100
  onPlay?: ((event: import("@vimeo/player").TimeEvent, player: Vimeo.Player) => any) | undefined;
100
101
  onPlaying?: ((event: import("@vimeo/player").TimeEvent, player: Vimeo.Player) => any) | undefined;
101
- onProgress?: ((event: import("@vimeo/player").TimeEvent, player: Vimeo.Player) => any) | undefined;
102
102
  onResize?: ((event: import("@vimeo/player").ResizeEvent, player: Vimeo.Player) => any) | undefined;
103
103
  onSeeked?: ((event: import("@vimeo/player").TimeEvent, player: Vimeo.Player) => any) | undefined;
104
104
  onSeeking?: ((event: import("@vimeo/player").TimeEvent, player: Vimeo.Player) => any) | undefined;
@@ -1,7 +1,7 @@
1
1
  <script setup>
2
- import { computed, onBeforeUnmount, onMounted, ref, watch } from "vue";
3
2
  import { defu } from "defu";
4
3
  import { useAsyncData, useHead } from "nuxt/app";
4
+ import { computed, onBeforeUnmount, onMounted, ref, watch } from "vue";
5
5
  import { useScriptTriggerElement } from "../composables/useScriptTriggerElement";
6
6
  import { useScriptVimeoPlayer } from "../registry/vimeo-player";
7
7
  import ScriptAriaLoadingIndicator from "./ScriptAriaLoadingIndicator.vue";
@@ -64,6 +64,7 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
64
64
  getPlaybackRate: () => Promise<number> | undefined;
65
65
  setPlaybackRate: (rate: number) => Promise<number> | undefined;
66
66
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
67
+ progress: (event: import("@vimeo/player").TimeEvent, player: Vimeo.Player) => any;
67
68
  error: (event: import("@vimeo/player").Error, player: Vimeo.Player) => any;
68
69
  loaded: (event: import("@vimeo/player").LoadedEvent, player: Vimeo.Player) => any;
69
70
  cuechange: (event: import("@vimeo/player").CueChangeEvent, player: Vimeo.Player) => any;
@@ -72,7 +73,6 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
72
73
  pause: (event: import("@vimeo/player").TimeEvent, player: Vimeo.Player) => any;
73
74
  play: (event: import("@vimeo/player").TimeEvent, player: Vimeo.Player) => any;
74
75
  playing: (event: import("@vimeo/player").TimeEvent, player: Vimeo.Player) => any;
75
- progress: (event: import("@vimeo/player").TimeEvent, player: Vimeo.Player) => any;
76
76
  resize: (event: import("@vimeo/player").ResizeEvent, player: Vimeo.Player) => any;
77
77
  seeked: (event: import("@vimeo/player").TimeEvent, player: Vimeo.Player) => any;
78
78
  seeking: (event: import("@vimeo/player").TimeEvent, player: Vimeo.Player) => any;
@@ -90,6 +90,7 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
90
90
  enterpictureinpicture: (event: never, player: Vimeo.Player) => any;
91
91
  leavepictureinpicture: (event: never, player: Vimeo.Player) => any;
92
92
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
93
+ onProgress?: ((event: import("@vimeo/player").TimeEvent, player: Vimeo.Player) => any) | undefined;
93
94
  onError?: ((event: import("@vimeo/player").Error, player: Vimeo.Player) => any) | undefined;
94
95
  onLoaded?: ((event: import("@vimeo/player").LoadedEvent, player: Vimeo.Player) => any) | undefined;
95
96
  onCuechange?: ((event: import("@vimeo/player").CueChangeEvent, player: Vimeo.Player) => any) | undefined;
@@ -98,7 +99,6 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
98
99
  onPause?: ((event: import("@vimeo/player").TimeEvent, player: Vimeo.Player) => any) | undefined;
99
100
  onPlay?: ((event: import("@vimeo/player").TimeEvent, player: Vimeo.Player) => any) | undefined;
100
101
  onPlaying?: ((event: import("@vimeo/player").TimeEvent, player: Vimeo.Player) => any) | undefined;
101
- onProgress?: ((event: import("@vimeo/player").TimeEvent, player: Vimeo.Player) => any) | undefined;
102
102
  onResize?: ((event: import("@vimeo/player").ResizeEvent, player: Vimeo.Player) => any) | undefined;
103
103
  onSeeked?: ((event: import("@vimeo/player").TimeEvent, player: Vimeo.Player) => any) | undefined;
104
104
  onSeeking?: ((event: import("@vimeo/player").TimeEvent, player: Vimeo.Player) => any) | undefined;
@@ -0,0 +1,82 @@
1
+ import type { HTMLAttributes } from 'vue';
2
+ import type { XEmbedTweetData } from '../registry/x-embed.js';
3
+ type __VLS_Props = {
4
+ /**
5
+ * The tweet ID to embed
6
+ */
7
+ tweetId: string;
8
+ /**
9
+ * Custom API endpoint for fetching tweet data
10
+ * @default '/_scripts/x-embed'
11
+ */
12
+ apiEndpoint?: string;
13
+ /**
14
+ * Custom image proxy endpoint
15
+ * @default '/_scripts/x-embed-image'
16
+ */
17
+ imageProxyEndpoint?: string;
18
+ /**
19
+ * Root element attributes
20
+ */
21
+ rootAttrs?: HTMLAttributes;
22
+ };
23
+ declare var __VLS_1: {}, __VLS_3: {
24
+ error: import("nuxt/app").NuxtError<unknown> | undefined;
25
+ }, __VLS_5: {
26
+ tweet: XEmbedTweetData;
27
+ userName: string;
28
+ userHandle: string;
29
+ userAvatar: string;
30
+ userAvatarOriginal: string;
31
+ isVerified: boolean | undefined;
32
+ text: string;
33
+ datetime: string;
34
+ createdAt: Date;
35
+ likes: number;
36
+ likesFormatted: string;
37
+ replies: number;
38
+ repliesFormatted: string;
39
+ photos: {
40
+ proxiedUrl: string;
41
+ url: string;
42
+ width: number;
43
+ height: number;
44
+ }[] | undefined;
45
+ video: {
46
+ posterProxied: string;
47
+ poster: string;
48
+ variants: Array<{
49
+ type: string;
50
+ src: string;
51
+ }>;
52
+ } | null;
53
+ tweetUrl: string;
54
+ userUrl: string;
55
+ quotedTweet: XEmbedTweetData | undefined;
56
+ isReply: boolean;
57
+ replyToUser: string | undefined;
58
+ proxyImage: (url: string) => string;
59
+ };
60
+ type __VLS_Slots = {} & {
61
+ loading?: (props: typeof __VLS_1) => any;
62
+ } & {
63
+ error?: (props: typeof __VLS_3) => any;
64
+ } & {
65
+ default?: (props: typeof __VLS_5) => any;
66
+ };
67
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
68
+ tweet: import("vue").Ref<XEmbedTweetData | undefined, XEmbedTweetData | undefined>;
69
+ status: import("vue").Ref<import("nuxt/app").AsyncDataRequestStatus, import("nuxt/app").AsyncDataRequestStatus>;
70
+ error: import("vue").Ref<import("nuxt/app").NuxtError<unknown> | undefined, import("nuxt/app").NuxtError<unknown> | undefined>;
71
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
72
+ apiEndpoint: string;
73
+ imageProxyEndpoint: string;
74
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
75
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
76
+ declare const _default: typeof __VLS_export;
77
+ export default _default;
78
+ type __VLS_WithSlots<T, S> = T & {
79
+ new (): {
80
+ $slots: S;
81
+ };
82
+ };
@@ -0,0 +1,76 @@
1
+ <script setup>
2
+ import { useAsyncData } from "nuxt/app";
3
+ import { computed } from "vue";
4
+ import { formatCount, formatTweetDate, proxyXImageUrl } from "../registry/x-embed";
5
+ const props = defineProps({
6
+ tweetId: { type: String, required: true },
7
+ apiEndpoint: { type: String, required: false, default: "/api/_scripts/x-embed" },
8
+ imageProxyEndpoint: { type: String, required: false, default: "/api/_scripts/x-embed-image" },
9
+ rootAttrs: { type: Object, required: false }
10
+ });
11
+ const cacheKey = computed(() => `x-embed-${props.tweetId}`);
12
+ const { data: tweet, status, error } = useAsyncData(
13
+ cacheKey,
14
+ () => $fetch(`${props.apiEndpoint}?id=${props.tweetId}`)
15
+ );
16
+ const slotProps = computed(() => {
17
+ if (!tweet.value)
18
+ return null;
19
+ const t = tweet.value;
20
+ return {
21
+ // Raw data
22
+ tweet: t,
23
+ // User info
24
+ userName: t.user.name,
25
+ userHandle: t.user.screen_name,
26
+ userAvatar: proxyXImageUrl(t.user.profile_image_url_https, props.imageProxyEndpoint),
27
+ userAvatarOriginal: t.user.profile_image_url_https,
28
+ isVerified: t.user.verified || t.user.is_blue_verified,
29
+ // Tweet content
30
+ text: t.text,
31
+ // Formatted values
32
+ datetime: formatTweetDate(t.created_at),
33
+ createdAt: new Date(t.created_at),
34
+ likes: t.favorite_count,
35
+ likesFormatted: formatCount(t.favorite_count),
36
+ replies: t.conversation_count,
37
+ repliesFormatted: formatCount(t.conversation_count),
38
+ // Media
39
+ photos: t.photos?.map((p) => ({
40
+ ...p,
41
+ proxiedUrl: proxyXImageUrl(p.url, props.imageProxyEndpoint)
42
+ })),
43
+ video: t.video ? {
44
+ ...t.video,
45
+ posterProxied: proxyXImageUrl(t.video.poster, props.imageProxyEndpoint)
46
+ } : null,
47
+ // Links
48
+ tweetUrl: `https://x.com/${t.user.screen_name}/status/${t.id_str}`,
49
+ userUrl: `https://x.com/${t.user.screen_name}`,
50
+ // Quoted tweet
51
+ quotedTweet: t.quoted_tweet,
52
+ // Reply context
53
+ isReply: !!t.parent,
54
+ replyToUser: t.parent?.user.screen_name,
55
+ // Helpers
56
+ proxyImage: (url) => proxyXImageUrl(url, props.imageProxyEndpoint)
57
+ };
58
+ });
59
+ defineExpose({
60
+ tweet,
61
+ status,
62
+ error
63
+ });
64
+ </script>
65
+
66
+ <template>
67
+ <div v-bind="rootAttrs">
68
+ <slot v-if="status === 'pending'" name="loading">
69
+ <div>Loading tweet...</div>
70
+ </slot>
71
+ <slot v-else-if="status === 'error'" name="error" :error="error">
72
+ <div>Failed to load tweet</div>
73
+ </slot>
74
+ <slot v-else-if="slotProps" v-bind="slotProps" />
75
+ </div>
76
+ </template>
@@ -0,0 +1,82 @@
1
+ import type { HTMLAttributes } from 'vue';
2
+ import type { XEmbedTweetData } from '../registry/x-embed.js';
3
+ type __VLS_Props = {
4
+ /**
5
+ * The tweet ID to embed
6
+ */
7
+ tweetId: string;
8
+ /**
9
+ * Custom API endpoint for fetching tweet data
10
+ * @default '/_scripts/x-embed'
11
+ */
12
+ apiEndpoint?: string;
13
+ /**
14
+ * Custom image proxy endpoint
15
+ * @default '/_scripts/x-embed-image'
16
+ */
17
+ imageProxyEndpoint?: string;
18
+ /**
19
+ * Root element attributes
20
+ */
21
+ rootAttrs?: HTMLAttributes;
22
+ };
23
+ declare var __VLS_1: {}, __VLS_3: {
24
+ error: import("nuxt/app").NuxtError<unknown> | undefined;
25
+ }, __VLS_5: {
26
+ tweet: XEmbedTweetData;
27
+ userName: string;
28
+ userHandle: string;
29
+ userAvatar: string;
30
+ userAvatarOriginal: string;
31
+ isVerified: boolean | undefined;
32
+ text: string;
33
+ datetime: string;
34
+ createdAt: Date;
35
+ likes: number;
36
+ likesFormatted: string;
37
+ replies: number;
38
+ repliesFormatted: string;
39
+ photos: {
40
+ proxiedUrl: string;
41
+ url: string;
42
+ width: number;
43
+ height: number;
44
+ }[] | undefined;
45
+ video: {
46
+ posterProxied: string;
47
+ poster: string;
48
+ variants: Array<{
49
+ type: string;
50
+ src: string;
51
+ }>;
52
+ } | null;
53
+ tweetUrl: string;
54
+ userUrl: string;
55
+ quotedTweet: XEmbedTweetData | undefined;
56
+ isReply: boolean;
57
+ replyToUser: string | undefined;
58
+ proxyImage: (url: string) => string;
59
+ };
60
+ type __VLS_Slots = {} & {
61
+ loading?: (props: typeof __VLS_1) => any;
62
+ } & {
63
+ error?: (props: typeof __VLS_3) => any;
64
+ } & {
65
+ default?: (props: typeof __VLS_5) => any;
66
+ };
67
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
68
+ tweet: import("vue").Ref<XEmbedTweetData | undefined, XEmbedTweetData | undefined>;
69
+ status: import("vue").Ref<import("nuxt/app").AsyncDataRequestStatus, import("nuxt/app").AsyncDataRequestStatus>;
70
+ error: import("vue").Ref<import("nuxt/app").NuxtError<unknown> | undefined, import("nuxt/app").NuxtError<unknown> | undefined>;
71
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
72
+ apiEndpoint: string;
73
+ imageProxyEndpoint: string;
74
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
75
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
76
+ declare const _default: typeof __VLS_export;
77
+ export default _default;
78
+ type __VLS_WithSlots<T, S> = T & {
79
+ new (): {
80
+ $slots: S;
81
+ };
82
+ };
@@ -10,6 +10,7 @@ type __VLS_Props = {
10
10
  playerVars?: YT.PlayerVars;
11
11
  width?: number;
12
12
  height?: number;
13
+ ratio?: string;
13
14
  /**
14
15
  * Whether to use youtube-nocookie.com for embedding.
15
16
  *
@@ -19,9 +20,15 @@ type __VLS_Props = {
19
20
  playerOptions?: YT.PlayerOptions;
20
21
  thumbnailSize?: YoutubeThumbnailSize;
21
22
  webp?: boolean;
23
+ /**
24
+ * Object-fit for the placeholder image.
25
+ *
26
+ * @default 'cover'
27
+ */
28
+ placeholderObjectFit?: 'cover' | 'contain' | 'fill' | 'none' | 'scale-down';
22
29
  };
23
30
  declare var __VLS_1: {
24
- placeholder: any;
31
+ placeholder: string;
25
32
  }, __VLS_3: {}, __VLS_10: {}, __VLS_12: {}, __VLS_14: {};
26
33
  type __VLS_Slots = {} & {
27
34
  placeholder?: (props: typeof __VLS_1) => any;
@@ -42,20 +49,24 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
42
49
  "state-change": (e: YT.OnStateChangeEvent, target: YT.Player) => any;
43
50
  "playback-quality-change": (e: YT.OnPlaybackQualityChangeEvent, target: YT.Player) => any;
44
51
  "playback-rate-change": (e: YT.OnPlaybackRateChangeEvent, target: YT.Player) => any;
52
+ "api-change": (e: YT.PlayerEvent, target: YT.Player) => any;
45
53
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
46
54
  onError?: ((e: YT.OnErrorEvent, target: YT.Player) => any) | undefined;
47
55
  onReady?: ((e: YT.PlayerEvent) => any) | undefined;
48
56
  "onState-change"?: ((e: YT.OnStateChangeEvent, target: YT.Player) => any) | undefined;
49
57
  "onPlayback-quality-change"?: ((e: YT.OnPlaybackQualityChangeEvent, target: YT.Player) => any) | undefined;
50
58
  "onPlayback-rate-change"?: ((e: YT.OnPlaybackRateChangeEvent, target: YT.Player) => any) | undefined;
59
+ "onApi-change"?: ((e: YT.PlayerEvent, target: YT.Player) => any) | undefined;
51
60
  }>, {
52
61
  trigger: ElementScriptTrigger;
53
62
  width: number;
54
63
  height: number;
55
64
  playerVars: YT.PlayerVars;
65
+ ratio: string;
56
66
  cookies: boolean;
57
67
  thumbnailSize: YoutubeThumbnailSize;
58
68
  webp: boolean;
69
+ placeholderObjectFit: "cover" | "contain" | "fill" | "none" | "scale-down";
59
70
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
60
71
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
61
72
  declare const _default: typeof __VLS_export;