@nuxt/scripts 1.0.0-beta.2 → 1.0.0-beta.20

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 (165) hide show
  1. package/README.md +3 -3
  2. package/dist/client/200.html +1 -1
  3. package/dist/client/404.html +1 -1
  4. package/dist/client/_nuxt/{B66N9HCo.js → 9LJPrOyI.js} +1 -1
  5. package/dist/client/_nuxt/DFEfk2pB.js +162 -0
  6. package/dist/client/_nuxt/{DvH517bE.js → DMlY-BNa.js} +1 -1
  7. package/dist/client/_nuxt/{DfLgoB--.js → __ZZTkMj.js} +1 -1
  8. package/dist/client/_nuxt/builds/latest.json +1 -1
  9. package/dist/client/_nuxt/builds/meta/8212d4fa-7985-421b-815a-03a886e667d4.json +1 -0
  10. package/dist/client/_nuxt/entry.CACgbLJl.css +1 -0
  11. package/dist/client/_nuxt/error-404.CHeaW3dp.css +1 -0
  12. package/dist/client/_nuxt/error-500.DvOvWme_.css +1 -0
  13. package/dist/client/index.html +1 -1
  14. package/dist/module.d.mts +27 -18
  15. package/dist/module.d.ts +178 -0
  16. package/dist/module.json +1 -1
  17. package/dist/module.mjs +747 -527
  18. package/dist/registry.d.ts +6 -0
  19. package/dist/registry.mjs +74 -21
  20. package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.d.vue.ts +2 -2
  21. package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.vue +7 -7
  22. package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.vue.d.ts +2 -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 +1 -1
  29. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarkerClusterer.vue +6 -6
  30. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarkerClusterer.vue.d.ts +1 -1
  31. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPinElement.vue +5 -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.vue +1 -1
  36. package/dist/runtime/components/ScriptGoogleAdsense.vue +1 -1
  37. package/dist/runtime/components/ScriptGravatar.d.vue.ts +22 -0
  38. package/dist/runtime/components/ScriptGravatar.vue +46 -0
  39. package/dist/runtime/components/ScriptGravatar.vue.d.ts +22 -0
  40. package/dist/runtime/components/ScriptInstagramEmbed.vue +1 -1
  41. package/dist/runtime/components/ScriptIntercom.vue +4 -3
  42. package/dist/runtime/components/ScriptPayPalButtons.d.vue.ts +43 -32
  43. package/dist/runtime/components/ScriptPayPalButtons.vue +48 -79
  44. package/dist/runtime/components/ScriptPayPalButtons.vue.d.ts +43 -32
  45. package/dist/runtime/components/ScriptPayPalMessages.d.vue.ts +37 -23
  46. package/dist/runtime/components/ScriptPayPalMessages.vue +46 -50
  47. package/dist/runtime/components/ScriptPayPalMessages.vue.d.ts +37 -23
  48. package/dist/runtime/components/ScriptStripePricingTable.vue +2 -2
  49. package/dist/runtime/components/ScriptVimeoPlayer.d.vue.ts +9 -0
  50. package/dist/runtime/components/ScriptVimeoPlayer.vue +13 -10
  51. package/dist/runtime/components/ScriptVimeoPlayer.vue.d.ts +9 -0
  52. package/dist/runtime/components/ScriptXEmbed.d.vue.ts +1 -1
  53. package/dist/runtime/components/ScriptXEmbed.vue +1 -1
  54. package/dist/runtime/components/ScriptXEmbed.vue.d.ts +1 -1
  55. package/dist/runtime/components/ScriptYouTubePlayer.d.vue.ts +2 -2
  56. package/dist/runtime/components/ScriptYouTubePlayer.vue +11 -5
  57. package/dist/runtime/components/ScriptYouTubePlayer.vue.d.ts +2 -2
  58. package/dist/runtime/composables/useScript.js +11 -6
  59. package/dist/runtime/composables/useScriptEventPage.js +2 -2
  60. package/dist/runtime/composables/useScriptTriggerConsent.js +1 -1
  61. package/dist/runtime/composables/useScriptTriggerElement.js +1 -1
  62. package/dist/runtime/composables/useScriptTriggerIdleTimeout.js +1 -1
  63. package/dist/runtime/registry/clarity.d.ts +10 -15
  64. package/dist/runtime/registry/clarity.js +22 -31
  65. package/dist/runtime/registry/cloudflare-web-analytics.d.ts +2 -13
  66. package/dist/runtime/registry/cloudflare-web-analytics.js +2 -14
  67. package/dist/runtime/registry/crisp.d.ts +9 -39
  68. package/dist/runtime/registry/crisp.js +2 -33
  69. package/dist/runtime/registry/databuddy-analytics.d.ts +2 -35
  70. package/dist/runtime/registry/databuddy-analytics.js +20 -45
  71. package/dist/runtime/registry/fathom-analytics.d.ts +6 -25
  72. package/dist/runtime/registry/fathom-analytics.js +2 -24
  73. package/dist/runtime/registry/google-adsense.d.ts +2 -10
  74. package/dist/runtime/registry/google-adsense.js +2 -11
  75. package/dist/runtime/registry/google-analytics.d.ts +3 -5
  76. package/dist/runtime/registry/google-analytics.js +3 -8
  77. package/dist/runtime/registry/google-maps.d.ts +3 -9
  78. package/dist/runtime/registry/google-maps.js +2 -8
  79. package/dist/runtime/registry/google-recaptcha.d.ts +2 -6
  80. package/dist/runtime/registry/google-recaptcha.js +4 -12
  81. package/dist/runtime/registry/google-sign-in.d.ts +2 -13
  82. package/dist/runtime/registry/google-sign-in.js +2 -22
  83. package/dist/runtime/registry/google-tag-manager.d.ts +3 -28
  84. package/dist/runtime/registry/google-tag-manager.js +4 -27
  85. package/dist/runtime/registry/gravatar.d.ts +25 -0
  86. package/dist/runtime/registry/gravatar.js +32 -0
  87. package/dist/runtime/registry/hotjar.d.ts +3 -5
  88. package/dist/runtime/registry/hotjar.js +2 -5
  89. package/dist/runtime/registry/instagram-embed.d.ts +2 -17
  90. package/dist/runtime/registry/instagram-embed.js +4 -19
  91. package/dist/runtime/registry/intercom.d.ts +3 -11
  92. package/dist/runtime/registry/intercom.js +2 -12
  93. package/dist/runtime/registry/matomo-analytics.d.ts +2 -11
  94. package/dist/runtime/registry/matomo-analytics.js +3 -12
  95. package/dist/runtime/registry/meta-pixel.d.ts +3 -5
  96. package/dist/runtime/registry/meta-pixel.js +2 -4
  97. package/dist/runtime/registry/npm.d.ts +2 -6
  98. package/dist/runtime/registry/npm.js +2 -9
  99. package/dist/runtime/registry/paypal.d.ts +4 -25
  100. package/dist/runtime/registry/paypal.js +3 -66
  101. package/dist/runtime/registry/plausible-analytics.js +18 -13
  102. package/dist/runtime/registry/posthog.d.ts +10 -11
  103. package/dist/runtime/registry/posthog.js +7 -20
  104. package/dist/runtime/registry/reddit-pixel.d.ts +4 -5
  105. package/dist/runtime/registry/reddit-pixel.js +2 -4
  106. package/dist/runtime/registry/rybbit-analytics.d.ts +2 -14
  107. package/dist/runtime/registry/rybbit-analytics.js +7 -19
  108. package/dist/runtime/registry/schemas.d.ts +946 -0
  109. package/dist/runtime/registry/schemas.js +901 -0
  110. package/dist/runtime/registry/segment.d.ts +2 -5
  111. package/dist/runtime/registry/segment.js +2 -5
  112. package/dist/runtime/registry/snapchat-pixel.d.ts +3 -32
  113. package/dist/runtime/registry/snapchat-pixel.js +2 -20
  114. package/dist/runtime/registry/stripe.d.ts +3 -4
  115. package/dist/runtime/registry/stripe.js +2 -4
  116. package/dist/runtime/registry/tiktok-pixel.d.ts +3 -6
  117. package/dist/runtime/registry/tiktok-pixel.js +2 -6
  118. package/dist/runtime/registry/umami-analytics.d.ts +2 -31
  119. package/dist/runtime/registry/umami-analytics.js +2 -36
  120. package/dist/runtime/registry/vercel-analytics.d.ts +29 -0
  121. package/dist/runtime/registry/vercel-analytics.js +84 -0
  122. package/dist/runtime/registry/vimeo-player.d.ts +2 -2
  123. package/dist/runtime/registry/vimeo-player.js +1 -1
  124. package/dist/runtime/registry/x-embed.d.ts +2 -16
  125. package/dist/runtime/registry/x-embed.js +2 -17
  126. package/dist/runtime/registry/x-pixel.d.ts +3 -6
  127. package/dist/runtime/registry/x-pixel.js +2 -5
  128. package/dist/runtime/registry/youtube-player.d.ts +7 -7
  129. package/dist/runtime/registry/youtube-player.js +1 -1
  130. package/dist/runtime/server/google-static-maps-proxy.js +1 -1
  131. package/dist/runtime/server/{sw-handler.d.ts → gravatar-proxy.d.ts} +1 -1
  132. package/dist/runtime/server/gravatar-proxy.js +62 -0
  133. package/dist/runtime/server/instagram-embed-asset.js +2 -1
  134. package/dist/runtime/server/instagram-embed-image.js +2 -1
  135. package/dist/runtime/server/instagram-embed.js +22 -13
  136. package/dist/runtime/server/proxy-handler.js +161 -117
  137. package/dist/runtime/server/utils/privacy.d.ts +45 -1
  138. package/dist/runtime/server/utils/privacy.js +103 -40
  139. package/dist/runtime/server/x-embed.js +3 -2
  140. package/dist/runtime/types.d.ts +30 -24
  141. package/dist/runtime/utils/pure.d.ts +0 -4
  142. package/dist/runtime/utils/pure.js +0 -67
  143. package/dist/runtime/utils.d.ts +3 -3
  144. package/dist/runtime/utils.js +12 -7
  145. package/dist/shared/scripts.Crpn87WB.mjs +318 -0
  146. package/dist/stats.d.mts +39 -0
  147. package/dist/stats.d.ts +39 -0
  148. package/dist/stats.mjs +772 -0
  149. package/dist/types-source.d.mts +19 -0
  150. package/dist/types-source.d.ts +19 -0
  151. package/dist/types-source.mjs +975 -0
  152. package/package.json +42 -31
  153. package/dist/client/_nuxt/B8XOar-X.js +0 -162
  154. package/dist/client/_nuxt/builds/meta/133a46c5-a5c1-4a63-87d1-037947a5bcdb.json +0 -1
  155. package/dist/client/_nuxt/entry.D45OuV0w.css +0 -1
  156. package/dist/client/_nuxt/error-404.B57D-jUQ.css +0 -1
  157. package/dist/client/_nuxt/error-500.DTHUW7BI.css +0 -1
  158. package/dist/runtime/components/ScriptPayPalMarks.d.vue.ts +0 -52
  159. package/dist/runtime/components/ScriptPayPalMarks.vue +0 -69
  160. package/dist/runtime/components/ScriptPayPalMarks.vue.d.ts +0 -52
  161. package/dist/runtime/plugins/sw-register.client.d.ts +0 -2
  162. package/dist/runtime/plugins/sw-register.client.js +0 -12
  163. package/dist/runtime/server/sw-handler.js +0 -25
  164. package/dist/runtime/sw/proxy-sw.template.d.ts +0 -1
  165. package/dist/runtime/sw/proxy-sw.template.js +0 -54
@@ -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 { Components, PageTypes, SdkInstance } from '@paypal/paypal-js/sdk-v6';
3
+ import type { HTMLAttributes, ReservedProps } from 'vue';
4
4
  import type { PayPalInput } from '../registry/paypal.js';
5
5
  type __VLS_Props = {
6
6
  /**
@@ -12,55 +12,66 @@ type __VLS_Props = {
12
12
  */
13
13
  trigger?: ElementScriptTrigger;
14
14
  /**
15
- * The client id for the paypal script.
15
+ * Client ID or client token for PayPal SDK v6 authentication.
16
16
  */
17
17
  clientId?: string;
18
18
  /**
19
- * The options for the paypal buttons.
19
+ * Server-generated client token for SDK v6.
20
20
  */
21
- buttonOptions?: PayPalButtonsComponentOptions;
21
+ clientToken?: string;
22
22
  /**
23
- * The paypal script options.
23
+ * The v6 SDK components to load.
24
+ * @default ['paypal-payments']
24
25
  */
25
- paypalScriptOptions?: Partial<PayPalInput>;
26
+ components?: Components[];
27
+ /**
28
+ * The page type context hint.
29
+ */
30
+ pageType?: PageTypes;
31
+ /**
32
+ * The locale for the SDK (BCP-47 code).
33
+ */
34
+ locale?: string;
26
35
  /**
27
- * Disables the paypal buttons.
36
+ * The merchant ID(s).
28
37
  */
29
- disabled?: boolean;
38
+ merchantId?: string | string[];
39
+ /**
40
+ * Partner attribution ID for revenue sharing.
41
+ */
42
+ partnerAttributionId?: string;
43
+ /**
44
+ * The paypal script options.
45
+ */
46
+ paypalScriptOptions?: Partial<PayPalInput>;
30
47
  };
31
- declare var __VLS_1: {}, __VLS_3: {}, __VLS_10: {}, __VLS_12: {}, __VLS_14: {};
48
+ declare var __VLS_1: {
49
+ sdkInstance: SdkInstance<Components[]> | undefined;
50
+ }, __VLS_3: {}, __VLS_5: {}, __VLS_12: {}, __VLS_14: {};
32
51
  type __VLS_Slots = {} & {
33
- placeholder?: (props: typeof __VLS_1) => any;
52
+ default?: (props: typeof __VLS_1) => any;
34
53
  } & {
35
- loading?: (props: typeof __VLS_3) => any;
54
+ placeholder?: (props: typeof __VLS_3) => any;
36
55
  } & {
37
- awaitingLoad?: (props: typeof __VLS_10) => any;
56
+ loading?: (props: typeof __VLS_5) => any;
38
57
  } & {
39
- error?: (props: typeof __VLS_12) => any;
58
+ awaitingLoad?: (props: typeof __VLS_12) => any;
40
59
  } & {
41
- default?: (props: typeof __VLS_14) => any;
60
+ error?: (props: typeof __VLS_14) => any;
42
61
  };
43
- declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
44
- error: (error: Record<string, unknown>) => any;
45
- init: (data: Record<string, unknown>, actions: OnInitActions) => any;
46
- cancel: (data: Record<string, unknown>, actions: OnCancelledActions) => any;
47
- approve: (data: OnApproveData, actions: OnApproveActions) => any;
48
- clickButtons: (data: Record<string, unknown>, actions: OnClickActions) => any;
49
- shippingOptionsChange: (data: OnShippingOptionsChangeData, actions: OnShippingOptionsChangeActions) => any;
50
- shippingAddressChange: (data: OnShippingAddressChangeData, actions: OnShippingAddressChangeActions) => any;
62
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
63
+ /** The PayPal SDK v6 instance for creating payment sessions, checking eligibility, etc. */
64
+ sdkInstance: import("vue").ShallowRef<SdkInstance<Components[]> | undefined, SdkInstance<Components[]> | undefined>;
65
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
66
+ error: (error: unknown) => any;
67
+ ready: (instance: SdkInstance<Components[]>) => any;
51
68
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
52
- onError?: ((error: Record<string, unknown>) => any) | undefined;
53
- onInit?: ((data: Record<string, unknown>, actions: OnInitActions) => any) | undefined;
54
- onCancel?: ((data: Record<string, unknown>, actions: OnCancelledActions) => any) | undefined;
55
- onApprove?: ((data: OnApproveData, actions: OnApproveActions) => any) | undefined;
56
- onClickButtons?: ((data: Record<string, unknown>, actions: OnClickActions) => any) | undefined;
57
- onShippingOptionsChange?: ((data: OnShippingOptionsChangeData, actions: OnShippingOptionsChangeActions) => any) | undefined;
58
- onShippingAddressChange?: ((data: OnShippingAddressChangeData, actions: OnShippingAddressChangeActions) => any) | undefined;
69
+ onError?: ((error: unknown) => any) | undefined;
70
+ onReady?: ((instance: SdkInstance<Components[]>) => any) | undefined;
59
71
  }>, {
60
72
  trigger: ElementScriptTrigger;
61
- disabled: boolean;
62
73
  clientId: string;
63
- buttonOptions: PayPalButtonsComponentOptions;
74
+ components: Components[];
64
75
  paypalScriptOptions: Partial<PayPalInput>;
65
76
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
66
77
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
@@ -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 { PageTypes, PayPalMessagesOptions, PayPalMessagesSession } from '@paypal/paypal-js/sdk-v6';
3
+ import type { HTMLAttributes, ReservedProps } from 'vue';
4
4
  import type { PayPalInput } from '../registry/paypal.js';
5
5
  type __VLS_Props = {
6
6
  /**
@@ -12,51 +12,65 @@ type __VLS_Props = {
12
12
  */
13
13
  trigger?: ElementScriptTrigger;
14
14
  /**
15
- * The client id for the paypal script.
15
+ * Client ID or client token for PayPal SDK v6 authentication.
16
16
  */
17
17
  clientId?: string;
18
18
  /**
19
- * The options for the paypal buttons.
19
+ * Server-generated client token for SDK v6.
20
20
  */
21
- messagesOptions?: PayPalMessagesComponentOptions;
21
+ clientToken?: string;
22
22
  /**
23
- * The merchant id for the paypal script.
23
+ * The merchant ID for the paypal script.
24
24
  */
25
- merchantId?: string;
25
+ merchantId?: string | string[];
26
26
  /**
27
- * The partner attribution id for the paypal script.
27
+ * The partner attribution ID.
28
28
  */
29
29
  partnerAttributionId?: string;
30
30
  /**
31
- * The options for the paypal scipt.
31
+ * The page type context hint.
32
+ */
33
+ pageType?: PageTypes;
34
+ /**
35
+ * The locale for the SDK (BCP-47 code).
36
+ */
37
+ locale?: string;
38
+ /**
39
+ * Options for the PayPal Messages session.
40
+ */
41
+ messagesOptions?: PayPalMessagesOptions;
42
+ /**
43
+ * The paypal script options.
32
44
  */
33
45
  paypalScriptOptions?: Partial<PayPalInput>;
34
46
  };
35
- declare var __VLS_1: {}, __VLS_3: {}, __VLS_10: {}, __VLS_12: {}, __VLS_14: {};
47
+ declare var __VLS_1: {
48
+ messagesSession: PayPalMessagesSession | undefined;
49
+ }, __VLS_3: {}, __VLS_5: {}, __VLS_12: {}, __VLS_14: {};
36
50
  type __VLS_Slots = {} & {
37
- placeholder?: (props: typeof __VLS_1) => any;
51
+ default?: (props: typeof __VLS_1) => any;
38
52
  } & {
39
- loading?: (props: typeof __VLS_3) => any;
53
+ placeholder?: (props: typeof __VLS_3) => any;
40
54
  } & {
41
- awaitingLoad?: (props: typeof __VLS_10) => any;
55
+ loading?: (props: typeof __VLS_5) => any;
42
56
  } & {
43
- error?: (props: typeof __VLS_12) => any;
57
+ awaitingLoad?: (props: typeof __VLS_12) => any;
44
58
  } & {
45
- default?: (props: typeof __VLS_14) => any;
59
+ error?: (props: typeof __VLS_14) => any;
46
60
  };
47
- declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
48
- render: (data: Record<string, unknown>) => any;
49
- apply: (data: Record<string, unknown>) => any;
50
- clickMessages: (data: Record<string, unknown>) => any;
61
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
62
+ messagesSession: import("vue").ShallowRef<PayPalMessagesSession | undefined, PayPalMessagesSession | undefined>;
63
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
64
+ error: (error: unknown) => any;
65
+ ready: (session: PayPalMessagesSession) => any;
51
66
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
52
- onRender?: ((data: Record<string, unknown>) => any) | undefined;
53
- onApply?: ((data: Record<string, unknown>) => any) | undefined;
54
- onClickMessages?: ((data: Record<string, unknown>) => any) | undefined;
67
+ onError?: ((error: unknown) => any) | undefined;
68
+ onReady?: ((session: PayPalMessagesSession) => any) | undefined;
55
69
  }>, {
56
70
  trigger: ElementScriptTrigger;
57
71
  clientId: string;
58
72
  paypalScriptOptions: Partial<PayPalInput>;
59
- messagesOptions: PayPalMessagesComponentOptions;
73
+ messagesOptions: PayPalMessagesOptions;
60
74
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
61
75
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
62
76
  declare const _default: typeof __VLS_export;
@@ -1,72 +1,67 @@
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 } 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" },
12
9
  clientId: { type: String, required: false, default: "test" },
13
- messagesOptions: { type: Object, required: false, default: () => ({}) },
14
- merchantId: { type: String, required: false },
10
+ clientToken: { type: String, required: false },
11
+ merchantId: { type: [String, Array], required: false },
15
12
  partnerAttributionId: { type: String, required: false },
13
+ pageType: { type: String, required: false },
14
+ locale: { type: String, required: false },
15
+ messagesOptions: { type: Object, required: false, default: () => ({}) },
16
16
  paypalScriptOptions: { type: Object, required: false, default: () => ({}) }
17
17
  });
18
+ const emit = defineEmits(["ready", "error"]);
19
+ const el = ref(null);
20
+ const rootEl = ref(null);
18
21
  const ready = ref(false);
22
+ const failed = ref(false);
23
+ const messagesSession = shallowRef();
19
24
  const { onLoaded, status } = useScriptPayPal({
20
- clientId: props.clientId,
21
- merchantId: props.merchantId,
22
- partnerAttributionId: props.partnerAttributionId,
25
+ ...props.clientToken ? { clientToken: props.clientToken } : { clientId: props.clientId },
23
26
  ...props.paypalScriptOptions
24
27
  });
25
- const emit = defineEmits(["apply", "clickMessages", "render"]);
26
- const options = computed(() => {
27
- const _options = {
28
- onApply: (data) => {
29
- emit("apply", data);
30
- return props.messagesOptions?.onApply?.(data);
31
- },
32
- onClick: (data) => {
33
- emit("clickMessages", data);
34
- return props.messagesOptions?.onClick?.(data);
35
- },
36
- onRender: (data) => {
37
- emit("render", data);
38
- return props.messagesOptions?.onRender?.(data);
39
- }
40
- };
41
- return defu(_options, props.messagesOptions);
42
- });
43
- const messageInst = shallowRef();
44
28
  onMounted(() => {
45
29
  onLoaded(async ({ paypal }) => {
46
- if (!el.value) return;
47
- messageInst.value = paypal?.Messages?.(options.value);
48
- await messageInst.value?.render(el.value);
49
- ready.value = true;
50
- watch(() => options.value, async (_options) => {
51
- if (!el.value) return;
52
- messageInst.value = paypal?.Messages?.(_options);
53
- await messageInst.value?.render(el.value);
54
- });
30
+ if (!el.value)
31
+ return;
32
+ const components = ["paypal-messages"];
33
+ const instanceOptions = {
34
+ ...props.clientToken ? { clientToken: props.clientToken } : { clientId: props.clientId },
35
+ components,
36
+ ...props.pageType && { pageType: props.pageType },
37
+ ...props.locale && { locale: props.locale },
38
+ ...props.merchantId && { merchantId: props.merchantId },
39
+ ...props.partnerAttributionId && { partnerAttributionId: props.partnerAttributionId }
40
+ };
41
+ try {
42
+ const instance = await paypal.createInstance(instanceOptions);
43
+ messagesSession.value = instance.createPayPalMessages(props.messagesOptions);
44
+ ready.value = true;
45
+ emit("ready", messagesSession.value);
46
+ } catch (err) {
47
+ messagesSession.value = void 0;
48
+ failed.value = true;
49
+ emit("error", err);
50
+ }
55
51
  });
56
52
  });
57
- function destroy() {
58
- if (!el.value) return;
59
- el.value?.replaceChildren();
60
- }
61
53
  onBeforeUnmount(() => {
62
- destroy();
54
+ messagesSession.value = void 0;
55
+ });
56
+ defineExpose({
57
+ messagesSession
63
58
  });
64
59
  const ScriptLoadingIndicator = resolveComponent("ScriptLoadingIndicator");
65
60
  const trigger = useScriptTriggerElement({ trigger: props.trigger, el: rootEl });
66
61
  const rootAttrs = computed(() => {
67
62
  return defu(props.rootAttrs, {
68
63
  "aria-busy": status.value === "loading",
69
- "aria-label": status.value === "awaitingLoad" ? "PayPal Script Placeholder" : status.value === "loading" ? "PayPal Buttons Loading" : "PayPal Buttons",
64
+ "aria-label": status.value === "awaitingLoad" ? "PayPal Script Placeholder" : status.value === "loading" ? "PayPal Messages Loading" : "PayPal Messages",
70
65
  "aria-live": "polite",
71
66
  "role": "application",
72
67
  ...trigger instanceof Promise ? trigger.ssrAttrs || {} : {}
@@ -75,16 +70,17 @@ const rootAttrs = computed(() => {
75
70
  </script>
76
71
 
77
72
  <template>
78
- <div v-bind="rootAttrs" id="test">
79
- <div v-show="ready" ref="el" />
80
- <slot v-if="!ready" name="placeholder">
73
+ <div ref="rootEl" v-bind="rootAttrs">
74
+ <div ref="el">
75
+ <slot v-if="ready" name="default" :messages-session="messagesSession" />
76
+ </div>
77
+ <slot v-if="status !== 'error' && !ready && !failed" name="placeholder">
81
78
  placeholder
82
79
  </slot>
83
- <slot v-if="status !== 'awaitingLoad' && !ready" name="loading">
80
+ <slot v-if="status !== 'awaitingLoad' && status !== 'error' && !ready && !failed" name="loading">
84
81
  <ScriptLoadingIndicator color="black" />
85
82
  </slot>
86
83
  <slot v-if="status === 'awaitingLoad'" name="awaitingLoad" />
87
- <slot v-else-if="status === 'error'" name="error" />
88
- <slot />
84
+ <slot v-else-if="status === 'error' || failed" name="error" />
89
85
  </div>
90
86
  </template>
@@ -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 { PageTypes, PayPalMessagesOptions, PayPalMessagesSession } from '@paypal/paypal-js/sdk-v6';
3
+ import type { HTMLAttributes, ReservedProps } from 'vue';
4
4
  import type { PayPalInput } from '../registry/paypal.js';
5
5
  type __VLS_Props = {
6
6
  /**
@@ -12,51 +12,65 @@ type __VLS_Props = {
12
12
  */
13
13
  trigger?: ElementScriptTrigger;
14
14
  /**
15
- * The client id for the paypal script.
15
+ * Client ID or client token for PayPal SDK v6 authentication.
16
16
  */
17
17
  clientId?: string;
18
18
  /**
19
- * The options for the paypal buttons.
19
+ * Server-generated client token for SDK v6.
20
20
  */
21
- messagesOptions?: PayPalMessagesComponentOptions;
21
+ clientToken?: string;
22
22
  /**
23
- * The merchant id for the paypal script.
23
+ * The merchant ID for the paypal script.
24
24
  */
25
- merchantId?: string;
25
+ merchantId?: string | string[];
26
26
  /**
27
- * The partner attribution id for the paypal script.
27
+ * The partner attribution ID.
28
28
  */
29
29
  partnerAttributionId?: string;
30
30
  /**
31
- * The options for the paypal scipt.
31
+ * The page type context hint.
32
+ */
33
+ pageType?: PageTypes;
34
+ /**
35
+ * The locale for the SDK (BCP-47 code).
36
+ */
37
+ locale?: string;
38
+ /**
39
+ * Options for the PayPal Messages session.
40
+ */
41
+ messagesOptions?: PayPalMessagesOptions;
42
+ /**
43
+ * The paypal script options.
32
44
  */
33
45
  paypalScriptOptions?: Partial<PayPalInput>;
34
46
  };
35
- declare var __VLS_1: {}, __VLS_3: {}, __VLS_10: {}, __VLS_12: {}, __VLS_14: {};
47
+ declare var __VLS_1: {
48
+ messagesSession: PayPalMessagesSession | undefined;
49
+ }, __VLS_3: {}, __VLS_5: {}, __VLS_12: {}, __VLS_14: {};
36
50
  type __VLS_Slots = {} & {
37
- placeholder?: (props: typeof __VLS_1) => any;
51
+ default?: (props: typeof __VLS_1) => any;
38
52
  } & {
39
- loading?: (props: typeof __VLS_3) => any;
53
+ placeholder?: (props: typeof __VLS_3) => any;
40
54
  } & {
41
- awaitingLoad?: (props: typeof __VLS_10) => any;
55
+ loading?: (props: typeof __VLS_5) => any;
42
56
  } & {
43
- error?: (props: typeof __VLS_12) => any;
57
+ awaitingLoad?: (props: typeof __VLS_12) => any;
44
58
  } & {
45
- default?: (props: typeof __VLS_14) => any;
59
+ error?: (props: typeof __VLS_14) => any;
46
60
  };
47
- declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
48
- render: (data: Record<string, unknown>) => any;
49
- apply: (data: Record<string, unknown>) => any;
50
- clickMessages: (data: Record<string, unknown>) => any;
61
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
62
+ messagesSession: import("vue").ShallowRef<PayPalMessagesSession | undefined, PayPalMessagesSession | undefined>;
63
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
64
+ error: (error: unknown) => any;
65
+ ready: (session: PayPalMessagesSession) => any;
51
66
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
52
- onRender?: ((data: Record<string, unknown>) => any) | undefined;
53
- onApply?: ((data: Record<string, unknown>) => any) | undefined;
54
- onClickMessages?: ((data: Record<string, unknown>) => any) | undefined;
67
+ onError?: ((error: unknown) => any) | undefined;
68
+ onReady?: ((session: PayPalMessagesSession) => any) | undefined;
55
69
  }>, {
56
70
  trigger: ElementScriptTrigger;
57
71
  clientId: string;
58
72
  paypalScriptOptions: Partial<PayPalInput>;
59
- messagesOptions: PayPalMessagesComponentOptions;
73
+ messagesOptions: PayPalMessagesOptions;
60
74
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
61
75
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
62
76
  declare const _default: typeof __VLS_export;
@@ -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 },
@@ -36,6 +36,13 @@ type __VLS_Props = {
36
36
  vimeoOptions?: VimeoOptions;
37
37
  id?: number | undefined;
38
38
  url?: string | undefined;
39
+ ratio?: string;
40
+ /**
41
+ * Object-fit for the placeholder image.
42
+ *
43
+ * @default 'contain'
44
+ */
45
+ placeholderObjectFit?: 'cover' | 'contain' | 'fill' | 'none' | 'scale-down';
39
46
  };
40
47
  declare var __VLS_1: any, __VLS_3: {}, __VLS_10: {}, __VLS_12: {}, __VLS_14: {};
41
48
  type __VLS_Slots = {} & {
@@ -117,6 +124,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
117
124
  onLeavepictureinpicture?: ((event: never, player: Vimeo.Player) => any) | undefined;
118
125
  }>, {
119
126
  trigger: ElementScriptTrigger;
127
+ ratio: string;
128
+ placeholderObjectFit: "cover" | "contain" | "fill" | "none" | "scale-down";
120
129
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
121
130
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
122
131
  declare const _default: typeof __VLS_export;
@@ -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";
@@ -12,7 +12,9 @@ const props = defineProps({
12
12
  aboveTheFold: { type: Boolean, required: false },
13
13
  vimeoOptions: { type: Object, required: false },
14
14
  id: { type: null, required: false },
15
- url: { type: null, required: false }
15
+ url: { type: null, required: false },
16
+ ratio: { type: String, required: false, default: "16/9" },
17
+ placeholderObjectFit: { type: String, required: false, default: "contain" }
16
18
  });
17
19
  const emits = defineEmits(["play", "playing", "pause", "ended", "timeupdate", "progress", "seeking", "seeked", "texttrackchange", "chapterchange", "cuechange", "cuepoint", "volumechange", "playbackratechange", "bufferstart", "bufferend", "error", "loaded", "durationchange", "fullscreenchange", "qualitychange", "camerachange", "resize", "enterpictureinpicture", "leavepictureinpicture"]);
18
20
  const events = [
@@ -153,12 +155,13 @@ const rootAttrs = computed(() => {
153
155
  "aria-live": "polite",
154
156
  "role": "application",
155
157
  "style": {
156
- maxWidth: "100%",
157
- width: `auto`,
158
- height: "auto",
159
- aspectRatio: `16/9`,
160
- position: "relative",
161
- backgroundColor: "black"
158
+ "--vimeo-ratio": props.ratio,
159
+ "maxWidth": "100%",
160
+ "width": `auto`,
161
+ "height": "auto",
162
+ "aspectRatio": props.ratio,
163
+ "position": "relative",
164
+ "backgroundColor": "black"
162
165
  },
163
166
  ...trigger instanceof Promise ? trigger.ssrAttrs || {} : {}
164
167
  });
@@ -173,7 +176,7 @@ const placeholderAttrs = computed(() => {
173
176
  style: {
174
177
  cursor: "pointer",
175
178
  width: "100%",
176
- objectFit: "contain",
179
+ objectFit: props.placeholderObjectFit,
177
180
  height: "100%"
178
181
  }
179
182
  });
@@ -197,5 +200,5 @@ onBeforeUnmount(() => player?.unload());
197
200
  </template>
198
201
 
199
202
  <style>
200
- .vimeo-player iframe{aspect-ratio:16/9;height:auto;max-width:100%!important;width:100%}
203
+ .vimeo-player iframe{aspect-ratio:var(--vimeo-ratio,16/9);height:auto;max-width:100%!important;width:100%}
201
204
  </style>
@@ -36,6 +36,13 @@ type __VLS_Props = {
36
36
  vimeoOptions?: VimeoOptions;
37
37
  id?: number | undefined;
38
38
  url?: string | undefined;
39
+ ratio?: string;
40
+ /**
41
+ * Object-fit for the placeholder image.
42
+ *
43
+ * @default 'contain'
44
+ */
45
+ placeholderObjectFit?: 'cover' | 'contain' | 'fill' | 'none' | 'scale-down';
39
46
  };
40
47
  declare var __VLS_1: any, __VLS_3: {}, __VLS_10: {}, __VLS_12: {}, __VLS_14: {};
41
48
  type __VLS_Slots = {} & {
@@ -117,6 +124,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
117
124
  onLeavepictureinpicture?: ((event: never, player: Vimeo.Player) => any) | undefined;
118
125
  }>, {
119
126
  trigger: ElementScriptTrigger;
127
+ ratio: string;
128
+ placeholderObjectFit: "cover" | "contain" | "fill" | "none" | "scale-down";
120
129
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
121
130
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
122
131
  declare const _default: typeof __VLS_export;
@@ -7,7 +7,7 @@ type __VLS_Props = {
7
7
  tweetId: string;
8
8
  /**
9
9
  * Custom API endpoint for fetching tweet data
10
- * @default '/_scripts/x-embed'
10
+ * @default '/api/_scripts/x-embed'
11
11
  */
12
12
  apiEndpoint?: string;
13
13
  /**
@@ -1,6 +1,6 @@
1
1
  <script setup>
2
- import { computed } from "vue";
3
2
  import { useAsyncData } from "nuxt/app";
3
+ import { computed } from "vue";
4
4
  import { formatCount, formatTweetDate, proxyXImageUrl } from "../registry/x-embed";
5
5
  const props = defineProps({
6
6
  tweetId: { type: String, required: true },
@@ -7,7 +7,7 @@ type __VLS_Props = {
7
7
  tweetId: string;
8
8
  /**
9
9
  * Custom API endpoint for fetching tweet data
10
- * @default '/_scripts/x-embed'
10
+ * @default '/api/_scripts/x-embed'
11
11
  */
12
12
  apiEndpoint?: string;
13
13
  /**
@@ -61,12 +61,12 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
61
61
  trigger: ElementScriptTrigger;
62
62
  width: number;
63
63
  height: number;
64
- playerVars: YT.PlayerVars;
65
64
  ratio: string;
65
+ placeholderObjectFit: "cover" | "contain" | "fill" | "none" | "scale-down";
66
+ playerVars: YT.PlayerVars;
66
67
  cookies: boolean;
67
68
  thumbnailSize: YoutubeThumbnailSize;
68
69
  webp: boolean;
69
- placeholderObjectFit: "cover" | "contain" | "fill" | "none" | "scale-down";
70
70
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
71
71
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
72
72
  declare const _default: typeof __VLS_export;
@@ -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 { useHead } from "nuxt/app";
4
+ import { computed, onBeforeUnmount, onMounted, ref, watch } from "vue";
5
5
  import { useScriptTriggerElement } from "../composables/useScriptTriggerElement";
6
6
  import { useScriptYouTubePlayer } from "../registry/youtube-player";
7
7
  import ScriptAriaLoadingIndicator from "./ScriptAriaLoadingIndicator.vue";
@@ -30,6 +30,7 @@ const events = [
30
30
  "onError",
31
31
  "onApiChange"
32
32
  ];
33
+ const CAMEL_CASE_RE = /([A-Z])/g;
33
34
  const rootEl = ref();
34
35
  const youtubeEl = ref();
35
36
  const ready = ref(false);
@@ -70,9 +71,11 @@ onMounted(() => {
70
71
  onLoaded(async (instance) => {
71
72
  if (!isTriggered.value && trigger instanceof Promise) {
72
73
  const triggered = await trigger;
73
- if (!triggered) return;
74
+ if (!triggered)
75
+ return;
74
76
  }
75
- if (!youtubeEl.value) return;
77
+ if (!youtubeEl.value)
78
+ return;
76
79
  const YouTube = instance.YT instanceof Promise ? await instance.YT : instance.YT;
77
80
  await new Promise((resolve) => {
78
81
  if (typeof YT.Player === "undefined")
@@ -80,7 +83,8 @@ onMounted(() => {
80
83
  else
81
84
  resolve();
82
85
  });
83
- if (!youtubeEl.value) return;
86
+ if (!youtubeEl.value)
87
+ return;
84
88
  player.value = new YT.Player(youtubeEl.value, {
85
89
  host: !props.cookies ? "https://www.youtube-nocookie.com" : "https://www.youtube.com",
86
90
  videoId: props.videoId,
@@ -89,7 +93,7 @@ onMounted(() => {
89
93
  playerVars: props.playerVars,
90
94
  ...props.playerOptions,
91
95
  events: Object.fromEntries(events.map((event) => [event, (e) => {
92
- const emitEventName = event.replace(/([A-Z])/g, "-$1").replace("on-", "").toLowerCase();
96
+ const emitEventName = event.replace(CAMEL_CASE_RE, "-$1").replace("on-", "").toLowerCase();
93
97
  emits(emitEventName, e);
94
98
  if (event === "onReady") {
95
99
  ready.value = true;
@@ -151,6 +155,8 @@ const placeholderAttrs = computed(() => {
151
155
  src: isFallbackPlaceHolder.value ? fallbackPlaceHolder.value : placeholder.value,
152
156
  alt: "",
153
157
  loading: props.aboveTheFold ? "eager" : "lazy",
158
+ // @ts-expect-error untyped
159
+ fetchpriority: props.aboveTheFold ? "high" : void 0,
154
160
  style: {
155
161
  width: "100%",
156
162
  objectFit: props.placeholderObjectFit,