@nuxt/scripts 0.10.5 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/README.md +71 -71
  2. package/dist/client/200.html +10 -10
  3. package/dist/client/404.html +10 -10
  4. package/dist/client/_nuxt/{BOGJUGGn.js → BFM-Ncmx.js} +1 -1
  5. package/dist/client/_nuxt/{Bso10INu.js → BSA2bgdb.js} +1 -1
  6. package/dist/client/_nuxt/CtQNcfGE.js +1 -0
  7. package/dist/client/_nuxt/DuCkB5R-.js +21 -0
  8. package/dist/client/_nuxt/builds/latest.json +1 -1
  9. package/dist/client/_nuxt/builds/meta/e03354ab-f2ce-4d6b-8542-7b38262b3671.json +1 -0
  10. package/dist/client/_nuxt/{entry.CJckMUzn.css → entry.ipQkUTQD.css} +1 -1
  11. package/dist/client/_nuxt/error-404.BdjopNsg.css +1 -0
  12. package/dist/client/_nuxt/error-500.Bd7Z7Q7I.css +1 -0
  13. package/dist/client/index.html +10 -10
  14. package/dist/module.json +2 -2
  15. package/dist/module.mjs +7 -13
  16. package/dist/runtime/components/ScriptAriaLoadingIndicator.vue +5 -5
  17. package/dist/runtime/components/ScriptCarbonAds.vue +83 -83
  18. package/dist/runtime/components/ScriptCrisp.vue +94 -94
  19. package/dist/runtime/components/ScriptGoogleAdsense.vue +93 -93
  20. package/dist/runtime/components/ScriptGoogleMaps.vue +469 -469
  21. package/dist/runtime/components/ScriptIntercom.vue +103 -103
  22. package/dist/runtime/components/ScriptLemonSqueezy.vue +52 -52
  23. package/dist/runtime/components/ScriptLoadingIndicator.vue +22 -22
  24. package/dist/runtime/components/ScriptStripePricingTable.vue +74 -74
  25. package/dist/runtime/components/ScriptVimeoPlayer.vue +289 -289
  26. package/dist/runtime/components/ScriptYouTubePlayer.vue +215 -215
  27. package/dist/runtime/composables/useScript.d.ts +8 -4
  28. package/dist/runtime/composables/useScript.js +10 -59
  29. package/dist/runtime/registry/google-analytics.js +0 -3
  30. package/dist/runtime/registry/google-maps.d.ts +4 -10
  31. package/dist/runtime/registry/google-tag-manager.js +0 -3
  32. package/dist/runtime/registry/matomo-analytics.js +0 -4
  33. package/dist/runtime/registry/segment.js +0 -18
  34. package/dist/runtime/types.d.ts +2 -2
  35. package/dist/runtime/utils.js +1 -1
  36. package/package.json +32 -35
  37. package/dist/client/_nuxt/BqRljlc8.js +0 -21
  38. package/dist/client/_nuxt/CgFBdOe6.js +0 -1
  39. package/dist/client/_nuxt/builds/meta/a79d2e11-f9af-444c-b10e-0675b6cf7f55.json +0 -1
  40. package/dist/client/_nuxt/error-404.DrjQUyCj.css +0 -1
  41. package/dist/client/_nuxt/error-500.CIXIBnf9.css +0 -1
@@ -1,103 +1,103 @@
1
- <script setup lang="ts">
2
- import { ref, onMounted, watch, onBeforeUnmount, computed } from 'vue'
3
- import { useScriptIntercom } from '../registry/intercom'
4
- import { useScriptTriggerElement } from '../composables/useScriptTriggerElement'
5
- import type { ElementScriptTrigger } from '#nuxt-scripts/types'
6
-
7
- const props = withDefaults(defineProps<{
8
- appId: string
9
- apiBase?: string
10
- name?: string
11
- email?: string
12
- userId?: string
13
- // customizing the messenger
14
- alignment?: 'left' | 'right'
15
- horizontalPadding?: number
16
- verticalPadding?: number
17
- /**
18
- * Defines the trigger event to load the script.
19
- */
20
- trigger?: ElementScriptTrigger
21
- }>(), {
22
- trigger: 'click',
23
- })
24
-
25
- const emits = defineEmits<{
26
- // our emit
27
- ready: [e: ReturnType<typeof useScriptIntercom>]
28
- error: []
29
- }>()
30
-
31
- const rootEl = ref(null)
32
- const trigger = useScriptTriggerElement({ trigger: props.trigger, el: rootEl })
33
-
34
- const isReady = ref(false)
35
- const intercom = useScriptIntercom({
36
- app_id: props.appId,
37
- // @ts-expect-error untyped
38
- app_base: props.apiBase,
39
- name: props.name,
40
- email: props.email,
41
- user_id: props.userId,
42
- alignment: props.alignment,
43
- horizontal_padding: props.horizontalPadding,
44
- vertical_padding: props.verticalPadding,
45
- scriptOptions: {
46
- trigger,
47
- },
48
- })
49
- const { status, onLoaded } = intercom
50
- if (props.trigger === 'click') {
51
- onLoaded((instance) => {
52
- instance.Intercom('show')
53
- })
54
- }
55
-
56
- defineExpose({
57
- intercom,
58
- })
59
-
60
- let observer: MutationObserver
61
- onMounted(() => {
62
- watch(status, (status) => {
63
- if (status === 'loading') {
64
- observer = new MutationObserver(() => {
65
- if (document.getElementById('intercom-frame')) {
66
- isReady.value = true
67
- emits('ready', intercom)
68
- observer.disconnect()
69
- }
70
- })
71
- observer.observe(document.body, { childList: true, subtree: true })
72
- }
73
- else if (status === 'error')
74
- emits('error')
75
- })
76
- })
77
- onBeforeUnmount(() => {
78
- observer?.disconnect()
79
- })
80
-
81
- const rootAttrs = computed(() => {
82
- return {
83
- style: {
84
- display: isReady.value ? 'none' : 'block',
85
- bottom: `${props.verticalPadding || 20}px`,
86
- [props.alignment || 'right']: `${props.horizontalPadding || 20}px`,
87
- },
88
- ...(trigger instanceof Promise ? trigger.ssrAttrs || {} : {}),
89
- }
90
- })
91
- </script>
92
-
93
- <template>
94
- <div
95
- ref="rootEl"
96
- v-bind="rootAttrs"
97
- >
98
- <slot :ready="isReady" />
99
- <slot v-if="status === 'awaitingLoad'" name="awaitingLoad" />
100
- <slot v-else-if="status === 'loading' || !isReady" name="loading" />
101
- <slot v-else-if="status === 'error'" name="error" />
102
- </div>
103
- </template>
1
+ <script setup lang="ts">
2
+ import { ref, onMounted, watch, onBeforeUnmount, computed } from 'vue'
3
+ import { useScriptIntercom } from '../registry/intercom'
4
+ import { useScriptTriggerElement } from '../composables/useScriptTriggerElement'
5
+ import type { ElementScriptTrigger } from '#nuxt-scripts/types'
6
+
7
+ const props = withDefaults(defineProps<{
8
+ appId: string
9
+ apiBase?: string
10
+ name?: string
11
+ email?: string
12
+ userId?: string
13
+ // customizing the messenger
14
+ alignment?: 'left' | 'right'
15
+ horizontalPadding?: number
16
+ verticalPadding?: number
17
+ /**
18
+ * Defines the trigger event to load the script.
19
+ */
20
+ trigger?: ElementScriptTrigger
21
+ }>(), {
22
+ trigger: 'click',
23
+ })
24
+
25
+ const emits = defineEmits<{
26
+ // our emit
27
+ ready: [e: ReturnType<typeof useScriptIntercom>]
28
+ error: []
29
+ }>()
30
+
31
+ const rootEl = ref(null)
32
+ const trigger = useScriptTriggerElement({ trigger: props.trigger, el: rootEl })
33
+
34
+ const isReady = ref(false)
35
+ const intercom = useScriptIntercom({
36
+ app_id: props.appId,
37
+ // @ts-expect-error untyped
38
+ app_base: props.apiBase,
39
+ name: props.name,
40
+ email: props.email,
41
+ user_id: props.userId,
42
+ alignment: props.alignment,
43
+ horizontal_padding: props.horizontalPadding,
44
+ vertical_padding: props.verticalPadding,
45
+ scriptOptions: {
46
+ trigger,
47
+ },
48
+ })
49
+ const { status, onLoaded } = intercom
50
+ if (props.trigger === 'click') {
51
+ onLoaded((instance) => {
52
+ instance.Intercom('show')
53
+ })
54
+ }
55
+
56
+ defineExpose({
57
+ intercom,
58
+ })
59
+
60
+ let observer: MutationObserver
61
+ onMounted(() => {
62
+ watch(status, (status) => {
63
+ if (status === 'loading') {
64
+ observer = new MutationObserver(() => {
65
+ if (document.getElementById('intercom-frame')) {
66
+ isReady.value = true
67
+ emits('ready', intercom)
68
+ observer.disconnect()
69
+ }
70
+ })
71
+ observer.observe(document.body, { childList: true, subtree: true })
72
+ }
73
+ else if (status === 'error')
74
+ emits('error')
75
+ })
76
+ })
77
+ onBeforeUnmount(() => {
78
+ observer?.disconnect()
79
+ })
80
+
81
+ const rootAttrs = computed(() => {
82
+ return {
83
+ style: {
84
+ display: isReady.value ? 'none' : 'block',
85
+ bottom: `${props.verticalPadding || 20}px`,
86
+ [props.alignment || 'right']: `${props.horizontalPadding || 20}px`,
87
+ },
88
+ ...(trigger instanceof Promise ? trigger.ssrAttrs || {} : {}),
89
+ }
90
+ })
91
+ </script>
92
+
93
+ <template>
94
+ <div
95
+ ref="rootEl"
96
+ v-bind="rootAttrs"
97
+ >
98
+ <slot :ready="isReady" />
99
+ <slot v-if="status === 'awaitingLoad'" name="awaitingLoad" />
100
+ <slot v-else-if="status === 'loading' || !isReady" name="loading" />
101
+ <slot v-else-if="status === 'error'" name="error" />
102
+ </div>
103
+ </template>
@@ -1,52 +1,52 @@
1
- <script lang="ts" setup>
2
- import { computed, onMounted, ref } from 'vue'
3
- import type { ElementScriptTrigger } from '../types'
4
- import { useScriptTriggerElement } from '../composables/useScriptTriggerElement'
5
- import { useScriptLemonSqueezy } from '../registry/lemon-squeezy'
6
- import type { LemonSqueezyEventPayload } from '../registry/lemon-squeezy'
7
-
8
- const props = withDefaults(defineProps<{
9
- trigger?: ElementScriptTrigger
10
- }>(), {
11
- trigger: 'visible',
12
- })
13
-
14
- const emits = defineEmits<{
15
- ready: [ReturnType<typeof useScriptLemonSqueezy>]
16
- lemonSqueezyEvent: [LemonSqueezyEventPayload]
17
- }>()
18
-
19
- const rootEl = ref<HTMLElement | null>(null)
20
- const trigger = useScriptTriggerElement({ trigger: props.trigger, el: rootEl })
21
- const instance = useScriptLemonSqueezy({
22
- scriptOptions: {
23
- trigger,
24
- },
25
- })
26
- onMounted(() => {
27
- rootEl.value?.querySelectorAll('a[href]').forEach((a) => {
28
- a.classList.add('lemonsqueezy-button')
29
- })
30
- instance.onLoaded(({ Setup, Refresh }) => {
31
- Setup({
32
- eventHandler(event) {
33
- emits('lemonSqueezyEvent', event)
34
- },
35
- })
36
- Refresh()
37
- emits('ready', instance)
38
- })
39
- })
40
-
41
- const rootAttrs = computed(() => {
42
- return {
43
- ...(trigger instanceof Promise ? trigger.ssrAttrs || {} : {}),
44
- }
45
- })
46
- </script>
47
-
48
- <template>
49
- <div ref="rootEl" v-bind="rootAttrs">
50
- <slot />
51
- </div>
52
- </template>
1
+ <script lang="ts" setup>
2
+ import { computed, onMounted, ref } from 'vue'
3
+ import type { ElementScriptTrigger } from '../types'
4
+ import { useScriptTriggerElement } from '../composables/useScriptTriggerElement'
5
+ import { useScriptLemonSqueezy } from '../registry/lemon-squeezy'
6
+ import type { LemonSqueezyEventPayload } from '../registry/lemon-squeezy'
7
+
8
+ const props = withDefaults(defineProps<{
9
+ trigger?: ElementScriptTrigger
10
+ }>(), {
11
+ trigger: 'visible',
12
+ })
13
+
14
+ const emits = defineEmits<{
15
+ ready: [ReturnType<typeof useScriptLemonSqueezy>]
16
+ lemonSqueezyEvent: [LemonSqueezyEventPayload]
17
+ }>()
18
+
19
+ const rootEl = ref<HTMLElement | null>(null)
20
+ const trigger = useScriptTriggerElement({ trigger: props.trigger, el: rootEl })
21
+ const instance = useScriptLemonSqueezy({
22
+ scriptOptions: {
23
+ trigger,
24
+ },
25
+ })
26
+ onMounted(() => {
27
+ rootEl.value?.querySelectorAll('a[href]').forEach((a) => {
28
+ a.classList.add('lemonsqueezy-button')
29
+ })
30
+ instance.onLoaded(({ Setup, Refresh }) => {
31
+ Setup({
32
+ eventHandler(event) {
33
+ emits('lemonSqueezyEvent', event)
34
+ },
35
+ })
36
+ Refresh()
37
+ emits('ready', instance)
38
+ })
39
+ })
40
+
41
+ const rootAttrs = computed(() => {
42
+ return {
43
+ ...(trigger instanceof Promise ? trigger.ssrAttrs || {} : {}),
44
+ }
45
+ })
46
+ </script>
47
+
48
+ <template>
49
+ <div ref="rootEl" v-bind="rootAttrs">
50
+ <slot />
51
+ </div>
52
+ </template>
@@ -1,24 +1,24 @@
1
- <script setup lang="ts">
2
- import { computed } from 'vue'
3
-
4
- const props = withDefaults(defineProps<{
5
- color?: string
6
- size?: number
7
- }>(), {
8
- color: 'currentColor',
9
- size: 30,
10
- })
11
-
12
- const styles = computed(() => ({
13
- width: `${props.size}px`,
14
- height: `${props.size}px`,
15
- }))
16
- </script>
17
-
18
- <template>
19
- <div class="loader" :styles="styles" aria-label="Loading..." role="status" />
20
- </template>
21
-
1
+ <script setup lang="ts">
2
+ import { computed } from 'vue'
3
+
4
+ const props = withDefaults(defineProps<{
5
+ color?: string
6
+ size?: number
7
+ }>(), {
8
+ color: 'currentColor',
9
+ size: 30,
10
+ })
11
+
12
+ const styles = computed(() => ({
13
+ width: `${props.size}px`,
14
+ height: `${props.size}px`,
15
+ }))
16
+ </script>
17
+
18
+ <template>
19
+ <div class="loader" :styles="styles" aria-label="Loading..." role="status" />
20
+ </template>
21
+
22
22
  <style scoped>
23
23
  .loader{animation:rotation 1s linear infinite;border:5px solid v-bind(color);border-bottom-color:transparent;border-radius:50%;box-sizing:border-box;display:inline-block;opacity:.5}@keyframes rotation{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}
24
- </style>
24
+ </style>
@@ -1,74 +1,74 @@
1
- <script setup lang="ts">
2
- import { ref, computed, onBeforeUnmount, onMounted, watch } from 'vue'
3
- import type { ElementScriptTrigger } from '../types'
4
- import { useScriptTriggerElement } from '../composables/useScriptTriggerElement'
5
- import { useScript } from '../composables/useScript'
6
-
7
- const props = withDefaults(defineProps<{
8
- trigger?: ElementScriptTrigger
9
- publishableKey: string
10
- pricingTableId: string
11
- clientReferenceId?: string
12
- customerEmail?: string
13
- customerSessionClientSecret?: string
14
- }>(), {
15
- trigger: 'visible',
16
- })
17
-
18
- const emit = defineEmits<{
19
- ready: [ReturnType<typeof useScript>]
20
- error: []
21
- }>()
22
-
23
- const rootEl = ref<HTMLDivElement | undefined>()
24
- const containerEl = ref<HTMLDivElement | undefined>()
25
- const trigger = useScriptTriggerElement({ trigger: props.trigger, el: rootEl })
26
- const instance = useScript(`https://js.stripe.com/v3/pricing-table.js`, {
27
- trigger,
28
- })
29
- const { onLoaded, status } = instance
30
-
31
- const pricingTable = ref<HTMLElement | undefined>()
32
- onMounted(() => {
33
- onLoaded(() => {
34
- const StripePricingTable = window.customElements.get('stripe-pricing-table')!
35
- const stripePricingTable = new StripePricingTable()
36
- stripePricingTable.setAttribute('publishable-key', props.publishableKey)
37
- stripePricingTable.setAttribute('pricing-table-id', props.pricingTableId)
38
- if (props.clientReferenceId)
39
- stripePricingTable.setAttribute('client-reference-id', props.clientReferenceId)
40
- if (props.customerEmail)
41
- stripePricingTable.setAttribute('customer-email', props.customerEmail)
42
- if (props.customerSessionClientSecret)
43
- stripePricingTable.setAttribute('customer-session-client-secret', props.customerSessionClientSecret)
44
- pricingTable.value = stripePricingTable
45
- rootEl.value!.appendChild(stripePricingTable)
46
- emit('ready', instance)
47
- })
48
- watch(status, (status) => {
49
- if (status === 'error') {
50
- emit('error')
51
- }
52
- })
53
- })
54
-
55
- onBeforeUnmount(() => {
56
- pricingTable.value?.remove()
57
- })
58
-
59
- const rootAttrs = computed(() => {
60
- return {
61
- ...(trigger instanceof Promise ? trigger.ssrAttrs || {} : {}),
62
- }
63
- })
64
- </script>
65
-
66
- <template>
67
- <div ref="rootEl" v-bind="rootAttrs">
68
- <div ref="containerEl" />
69
- <slot v-if="status === 'loading'" name="loading" />
70
- <slot v-if="status === 'awaitingLoad'" name="awaitingLoad" />
71
- <slot v-else-if="status === 'error'" name="error" />
72
- <slot />
73
- </div>
74
- </template>
1
+ <script setup lang="ts">
2
+ import { ref, computed, onBeforeUnmount, onMounted, watch } from 'vue'
3
+ import type { ElementScriptTrigger } from '../types'
4
+ import { useScriptTriggerElement } from '../composables/useScriptTriggerElement'
5
+ import { useScript } from '#imports'
6
+
7
+ const props = withDefaults(defineProps<{
8
+ trigger?: ElementScriptTrigger
9
+ publishableKey: string
10
+ pricingTableId: string
11
+ clientReferenceId?: string
12
+ customerEmail?: string
13
+ customerSessionClientSecret?: string
14
+ }>(), {
15
+ trigger: 'visible',
16
+ })
17
+
18
+ const emit = defineEmits<{
19
+ ready: [ReturnType<typeof useScript>]
20
+ error: []
21
+ }>()
22
+
23
+ const rootEl = ref<HTMLDivElement | undefined>()
24
+ const containerEl = ref<HTMLDivElement | undefined>()
25
+ const trigger = useScriptTriggerElement({ trigger: props.trigger, el: rootEl })
26
+ const instance = useScript(`https://js.stripe.com/v3/pricing-table.js`, {
27
+ trigger,
28
+ })
29
+ const { onLoaded, status } = instance
30
+
31
+ const pricingTable = ref<HTMLElement | undefined>()
32
+ onMounted(() => {
33
+ onLoaded(() => {
34
+ const StripePricingTable = window.customElements.get('stripe-pricing-table')!
35
+ const stripePricingTable = new StripePricingTable()
36
+ stripePricingTable.setAttribute('publishable-key', props.publishableKey)
37
+ stripePricingTable.setAttribute('pricing-table-id', props.pricingTableId)
38
+ if (props.clientReferenceId)
39
+ stripePricingTable.setAttribute('client-reference-id', props.clientReferenceId)
40
+ if (props.customerEmail)
41
+ stripePricingTable.setAttribute('customer-email', props.customerEmail)
42
+ if (props.customerSessionClientSecret)
43
+ stripePricingTable.setAttribute('customer-session-client-secret', props.customerSessionClientSecret)
44
+ pricingTable.value = stripePricingTable
45
+ rootEl.value!.appendChild(stripePricingTable)
46
+ emit('ready', instance)
47
+ })
48
+ watch(status, (status) => {
49
+ if (status === 'error') {
50
+ emit('error')
51
+ }
52
+ })
53
+ })
54
+
55
+ onBeforeUnmount(() => {
56
+ pricingTable.value?.remove()
57
+ })
58
+
59
+ const rootAttrs = computed(() => {
60
+ return {
61
+ ...(trigger instanceof Promise ? trigger.ssrAttrs || {} : {}),
62
+ }
63
+ })
64
+ </script>
65
+
66
+ <template>
67
+ <div ref="rootEl" v-bind="rootAttrs">
68
+ <div ref="containerEl" />
69
+ <slot v-if="status === 'loading'" name="loading" />
70
+ <slot v-if="status === 'awaitingLoad'" name="awaitingLoad" />
71
+ <slot v-else-if="status === 'error'" name="error" />
72
+ <slot />
73
+ </div>
74
+ </template>