@nuxt/scripts 0.6.3 → 0.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +73 -73
- package/dist/client/200.html +9 -9
- package/dist/client/404.html +9 -9
- package/dist/client/_nuxt/BA8oXX6l.js +31 -0
- package/dist/client/_nuxt/{zTM8DS5E.js → D3k5CjNA.js} +1 -1
- package/dist/client/_nuxt/{Cg8NGlPg.js → D6UD5WyS.js} +1 -1
- package/dist/client/_nuxt/{DZ6siU6J.js → D9Ze639F.js} +1 -1
- package/dist/client/_nuxt/builds/latest.json +1 -1
- package/dist/client/_nuxt/builds/meta/a5c6ec68-62ae-43af-96d0-bdd9f64f38b1.json +1 -0
- package/dist/client/_nuxt/entry.Cts5wDvr.css +1 -0
- package/dist/client/_nuxt/error-404.-RjlvToe.css +1 -0
- package/dist/client/_nuxt/error-500.Bz7LXgZy.css +1 -0
- package/dist/client/index.html +9 -9
- package/dist/module.json +1 -1
- package/dist/module.mjs +84 -279
- package/dist/registry.mjs +33 -0
- package/dist/runtime/components/ScriptCarbonAds.vue +71 -71
- package/dist/runtime/components/ScriptCrisp.vue +84 -84
- package/dist/runtime/components/ScriptGoogleAdsense.vue +69 -69
- package/dist/runtime/components/ScriptGoogleMaps.vue +265 -265
- package/dist/runtime/components/ScriptIntercom.vue +93 -93
- package/dist/runtime/components/ScriptLemonSqueezy.vue +45 -45
- package/dist/runtime/components/ScriptLoadingIndicator.vue +22 -22
- package/dist/runtime/components/ScriptStripePricingTable.vue +68 -68
- package/dist/runtime/components/ScriptVimeoPlayer.vue +256 -256
- package/dist/runtime/components/ScriptYouTubePlayer.vue +171 -170
- package/dist/runtime/composables/useScript.js +3 -3
- package/dist/runtime/composables/useScriptEventPage.d.ts +1 -1
- package/dist/runtime/registry/crisp.d.ts +1 -1
- package/dist/runtime/registry/fathom-analytics.d.ts +1 -1
- package/dist/runtime/registry/google-adsense.d.ts +1 -1
- package/dist/runtime/registry/google-analytics.d.ts +19 -0
- package/dist/runtime/registry/google-analytics.js +40 -0
- package/dist/runtime/registry/google-tag-manager.d.ts +23 -0
- package/dist/runtime/registry/google-tag-manager.js +33 -0
- package/dist/runtime/registry/hotjar.d.ts +1 -1
- package/dist/runtime/registry/intercom.d.ts +1 -1
- package/dist/runtime/registry/matomo-analytics.d.ts +1 -1
- package/dist/runtime/registry/meta-pixel.d.ts +1 -1
- package/dist/runtime/registry/npm.d.ts +1 -1
- package/dist/runtime/registry/x-pixel.d.ts +1 -1
- package/dist/runtime/types.d.ts +41 -9
- package/dist/runtime/utils.d.ts +1 -1
- package/dist/runtime/utils.js +20 -4
- package/package.json +12 -11
- package/dist/client/_nuxt/BeuDC-PU.js +0 -31
- package/dist/client/_nuxt/builds/meta/9996546f-d612-4447-9ee7-fc387b136ee4.json +0 -1
- package/dist/client/_nuxt/entry.DvGwvmL9.css +0 -1
- package/dist/client/_nuxt/error-404.DXyehy0d.css +0 -1
- package/dist/client/_nuxt/error-500.a_92Fvyl.css +0 -1
|
@@ -1,170 +1,171 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
/// <reference types="youtube" />
|
|
3
|
-
import { computed, onMounted, ref, watch } from 'vue'
|
|
4
|
-
import type { HTMLAttributes, ImgHTMLAttributes, Ref } from 'vue'
|
|
5
|
-
import { defu } from 'defu'
|
|
6
|
-
import type { ElementScriptTrigger } from '../types'
|
|
7
|
-
import { useScriptTriggerElement } from '../composables/useScriptTriggerElement'
|
|
8
|
-
import { useScriptYouTubePlayer } from '../registry/youtube-player'
|
|
9
|
-
import { useHead } from '#imports'
|
|
10
|
-
|
|
11
|
-
const props = withDefaults(defineProps<{
|
|
12
|
-
placeholderAttrs?: ImgHTMLAttributes
|
|
13
|
-
rootAttrs?: HTMLAttributes
|
|
14
|
-
aboveTheFold?: boolean
|
|
15
|
-
trigger?: ElementScriptTrigger
|
|
16
|
-
videoId: string
|
|
17
|
-
playerVars?: YT.PlayerVars
|
|
18
|
-
width?: number
|
|
19
|
-
height?: number
|
|
20
|
-
}>(), {
|
|
21
|
-
trigger: 'mousedown',
|
|
22
|
-
// @ts-expect-error untyped
|
|
23
|
-
playerVars: { autoplay: 0, playsinline: 1 },
|
|
24
|
-
width: 640,
|
|
25
|
-
height: 480,
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
const emits = defineEmits<{
|
|
29
|
-
'ready': [e: YT.PlayerEvent]
|
|
30
|
-
'state-change': [e: YT.OnStateChangeEvent, target: YT.Player]
|
|
31
|
-
'playback-quality-change': [e: YT.OnPlaybackQualityChangeEvent, target: YT.Player]
|
|
32
|
-
'playback-rate-change': [e: YT.OnPlaybackRateChangeEvent, target: YT.Player]
|
|
33
|
-
'error': [e: YT.OnErrorEvent, target: YT.Player]
|
|
34
|
-
}>()
|
|
35
|
-
const events: (keyof YT.Events)[] = [
|
|
36
|
-
'onReady',
|
|
37
|
-
'onStateChange',
|
|
38
|
-
'onPlaybackQualityChange',
|
|
39
|
-
'onPlaybackRateChange',
|
|
40
|
-
'onError',
|
|
41
|
-
'onApiChange',
|
|
42
|
-
]
|
|
43
|
-
const rootEl = ref()
|
|
44
|
-
const youtubeEl = ref()
|
|
45
|
-
const ready = ref(false)
|
|
46
|
-
const trigger = useScriptTriggerElement({ trigger: props.trigger, el: rootEl })
|
|
47
|
-
const { $script } = useScriptYouTubePlayer({
|
|
48
|
-
scriptOptions: {
|
|
49
|
-
trigger,
|
|
50
|
-
},
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
const player: Ref<YT.Player | undefined> = ref()
|
|
54
|
-
let clickTriggered = false
|
|
55
|
-
if (props.trigger === 'mousedown') {
|
|
56
|
-
trigger.then(() => {
|
|
57
|
-
clickTriggered = true
|
|
58
|
-
})
|
|
59
|
-
}
|
|
60
|
-
onMounted(() => {
|
|
61
|
-
$script.then(async (instance) => {
|
|
62
|
-
const YouTube: typeof YT & { ready: (fn: () => void) => void } = await instance.YT
|
|
63
|
-
await new Promise<void>((resolve) => {
|
|
64
|
-
if (typeof YT.Player === 'undefined')
|
|
65
|
-
YouTube.ready(resolve)
|
|
66
|
-
else
|
|
67
|
-
resolve()
|
|
68
|
-
})
|
|
69
|
-
player.value = new YT.Player(youtubeEl.value, {
|
|
70
|
-
...props,
|
|
71
|
-
events: Object.fromEntries(events.map(event => [event, (e: any) => {
|
|
72
|
-
const emitEventName = event.replace(/([A-Z])/g, '-$1').replace('on-', '').toLowerCase()
|
|
73
|
-
// @ts-expect-error untyped
|
|
74
|
-
emits(emitEventName, e)
|
|
75
|
-
if (event === 'onReady') {
|
|
76
|
-
ready.value = true
|
|
77
|
-
if (clickTriggered) {
|
|
78
|
-
player.value?.playVideo()
|
|
79
|
-
clickTriggered = false
|
|
80
|
-
}
|
|
81
|
-
watch(() => props.videoId, () => {
|
|
82
|
-
player.value?.loadVideoById(props.videoId)
|
|
83
|
-
})
|
|
84
|
-
}
|
|
85
|
-
}])),
|
|
86
|
-
})
|
|
87
|
-
})
|
|
88
|
-
watch($script.status, (status) => {
|
|
89
|
-
if (status === 'error') {
|
|
90
|
-
// @ts-expect-error untyped
|
|
91
|
-
emits('error')
|
|
92
|
-
}
|
|
93
|
-
})
|
|
94
|
-
})
|
|
95
|
-
|
|
96
|
-
defineExpose({
|
|
97
|
-
player,
|
|
98
|
-
})
|
|
99
|
-
|
|
100
|
-
const rootAttrs = computed(() => {
|
|
101
|
-
return defu(props.rootAttrs, {
|
|
102
|
-
'aria-busy': $script.status.value === 'loading',
|
|
103
|
-
'aria-label': $script.status.value === 'awaitingLoad'
|
|
104
|
-
? 'YouTube Player - Placeholder'
|
|
105
|
-
: $script.status.value === 'loading'
|
|
106
|
-
? 'YouTube Player - Loading'
|
|
107
|
-
: 'YouTube Player - Loaded',
|
|
108
|
-
'aria-live': 'polite',
|
|
109
|
-
'role': 'application',
|
|
110
|
-
'style': {
|
|
111
|
-
cursor: 'pointer',
|
|
112
|
-
position: 'relative',
|
|
113
|
-
backgroundColor: 'black',
|
|
114
|
-
maxWidth: '100%',
|
|
115
|
-
width: `${props.width}px`,
|
|
116
|
-
height: `'auto'`,
|
|
117
|
-
aspectRatio: `${props.width}/${props.height}`,
|
|
118
|
-
},
|
|
119
|
-
}) as HTMLAttributes
|
|
120
|
-
})
|
|
121
|
-
|
|
122
|
-
const placeholder = computed(() => `https://i.ytimg.com/vi_webp/${props.videoId}/sddefault.webp`)
|
|
123
|
-
|
|
124
|
-
if (import.meta.server) {
|
|
125
|
-
// dns-prefetch https://i.vimeocdn.com
|
|
126
|
-
useHead({
|
|
127
|
-
link: [
|
|
128
|
-
{
|
|
129
|
-
rel: props.aboveTheFold ? 'preconnect' : 'dns-prefetch',
|
|
130
|
-
href: 'https://i.ytimg.com',
|
|
131
|
-
},
|
|
132
|
-
props.aboveTheFold
|
|
133
|
-
// we can preload the placeholder image
|
|
134
|
-
? {
|
|
135
|
-
rel: 'preload',
|
|
136
|
-
as: 'image',
|
|
137
|
-
href: placeholder.value,
|
|
138
|
-
}
|
|
139
|
-
: {},
|
|
140
|
-
],
|
|
141
|
-
})
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
const placeholderAttrs = computed(() => {
|
|
145
|
-
return defu(props.placeholderAttrs, {
|
|
146
|
-
src: placeholder.value,
|
|
147
|
-
alt: '',
|
|
148
|
-
loading: props.aboveTheFold ? 'eager' : 'lazy',
|
|
149
|
-
style: {
|
|
150
|
-
width: '100%',
|
|
151
|
-
objectFit: 'contain',
|
|
152
|
-
height: '100%',
|
|
153
|
-
},
|
|
154
|
-
} satisfies ImgHTMLAttributes)
|
|
155
|
-
})
|
|
156
|
-
</script>
|
|
157
|
-
|
|
158
|
-
<template>
|
|
159
|
-
<div ref="rootEl" v-bind="rootAttrs">
|
|
160
|
-
<div ref="youtubeEl" style="width: 100%; height: 100%; position: absolute; top: 0; left: 0;" />
|
|
161
|
-
<slot v-if="!ready" :placeholder="placeholder" name="placeholder">
|
|
162
|
-
<img v-bind="placeholderAttrs">
|
|
163
|
-
</slot>
|
|
164
|
-
<slot v-if="$script.status.value === 'loading'" name="loading">
|
|
165
|
-
<ScriptLoadingIndicator />
|
|
166
|
-
</slot>
|
|
167
|
-
<slot v-if="$script.status.value === 'awaitingLoad'" name="awaitingLoad" />
|
|
168
|
-
<slot v-else-if="$script.status.value === 'error'" name="error" />
|
|
169
|
-
|
|
170
|
-
</
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/// <reference types="youtube" />
|
|
3
|
+
import { computed, onMounted, ref, watch } from 'vue'
|
|
4
|
+
import type { HTMLAttributes, ImgHTMLAttributes, Ref } from 'vue'
|
|
5
|
+
import { defu } from 'defu'
|
|
6
|
+
import type { ElementScriptTrigger } from '../types'
|
|
7
|
+
import { useScriptTriggerElement } from '../composables/useScriptTriggerElement'
|
|
8
|
+
import { useScriptYouTubePlayer } from '../registry/youtube-player'
|
|
9
|
+
import { useHead } from '#imports'
|
|
10
|
+
|
|
11
|
+
const props = withDefaults(defineProps<{
|
|
12
|
+
placeholderAttrs?: ImgHTMLAttributes
|
|
13
|
+
rootAttrs?: HTMLAttributes
|
|
14
|
+
aboveTheFold?: boolean
|
|
15
|
+
trigger?: ElementScriptTrigger
|
|
16
|
+
videoId: string
|
|
17
|
+
playerVars?: YT.PlayerVars
|
|
18
|
+
width?: number
|
|
19
|
+
height?: number
|
|
20
|
+
}>(), {
|
|
21
|
+
trigger: 'mousedown',
|
|
22
|
+
// @ts-expect-error untyped
|
|
23
|
+
playerVars: { autoplay: 0, playsinline: 1 },
|
|
24
|
+
width: 640,
|
|
25
|
+
height: 480,
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
const emits = defineEmits<{
|
|
29
|
+
'ready': [e: YT.PlayerEvent]
|
|
30
|
+
'state-change': [e: YT.OnStateChangeEvent, target: YT.Player]
|
|
31
|
+
'playback-quality-change': [e: YT.OnPlaybackQualityChangeEvent, target: YT.Player]
|
|
32
|
+
'playback-rate-change': [e: YT.OnPlaybackRateChangeEvent, target: YT.Player]
|
|
33
|
+
'error': [e: YT.OnErrorEvent, target: YT.Player]
|
|
34
|
+
}>()
|
|
35
|
+
const events: (keyof YT.Events)[] = [
|
|
36
|
+
'onReady',
|
|
37
|
+
'onStateChange',
|
|
38
|
+
'onPlaybackQualityChange',
|
|
39
|
+
'onPlaybackRateChange',
|
|
40
|
+
'onError',
|
|
41
|
+
'onApiChange',
|
|
42
|
+
]
|
|
43
|
+
const rootEl = ref()
|
|
44
|
+
const youtubeEl = ref()
|
|
45
|
+
const ready = ref(false)
|
|
46
|
+
const trigger = useScriptTriggerElement({ trigger: props.trigger, el: rootEl })
|
|
47
|
+
const { $script } = useScriptYouTubePlayer({
|
|
48
|
+
scriptOptions: {
|
|
49
|
+
trigger,
|
|
50
|
+
},
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
const player: Ref<YT.Player | undefined> = ref()
|
|
54
|
+
let clickTriggered = false
|
|
55
|
+
if (props.trigger === 'mousedown') {
|
|
56
|
+
trigger.then(() => {
|
|
57
|
+
clickTriggered = true
|
|
58
|
+
})
|
|
59
|
+
}
|
|
60
|
+
onMounted(() => {
|
|
61
|
+
$script.then(async (instance) => {
|
|
62
|
+
const YouTube: typeof YT & { ready: (fn: () => void) => void } = await instance.YT
|
|
63
|
+
await new Promise<void>((resolve) => {
|
|
64
|
+
if (typeof YT.Player === 'undefined')
|
|
65
|
+
YouTube.ready(resolve)
|
|
66
|
+
else
|
|
67
|
+
resolve()
|
|
68
|
+
})
|
|
69
|
+
player.value = new YT.Player(youtubeEl.value, {
|
|
70
|
+
...props,
|
|
71
|
+
events: Object.fromEntries(events.map(event => [event, (e: any) => {
|
|
72
|
+
const emitEventName = event.replace(/([A-Z])/g, '-$1').replace('on-', '').toLowerCase()
|
|
73
|
+
// @ts-expect-error untyped
|
|
74
|
+
emits(emitEventName, e)
|
|
75
|
+
if (event === 'onReady') {
|
|
76
|
+
ready.value = true
|
|
77
|
+
if (clickTriggered) {
|
|
78
|
+
player.value?.playVideo()
|
|
79
|
+
clickTriggered = false
|
|
80
|
+
}
|
|
81
|
+
watch(() => props.videoId, () => {
|
|
82
|
+
player.value?.loadVideoById(props.videoId)
|
|
83
|
+
})
|
|
84
|
+
}
|
|
85
|
+
}])),
|
|
86
|
+
})
|
|
87
|
+
})
|
|
88
|
+
watch($script.status, (status) => {
|
|
89
|
+
if (status === 'error') {
|
|
90
|
+
// @ts-expect-error untyped
|
|
91
|
+
emits('error')
|
|
92
|
+
}
|
|
93
|
+
})
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
defineExpose({
|
|
97
|
+
player,
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
const rootAttrs = computed(() => {
|
|
101
|
+
return defu(props.rootAttrs, {
|
|
102
|
+
'aria-busy': $script.status.value === 'loading',
|
|
103
|
+
'aria-label': $script.status.value === 'awaitingLoad'
|
|
104
|
+
? 'YouTube Player - Placeholder'
|
|
105
|
+
: $script.status.value === 'loading'
|
|
106
|
+
? 'YouTube Player - Loading'
|
|
107
|
+
: 'YouTube Player - Loaded',
|
|
108
|
+
'aria-live': 'polite',
|
|
109
|
+
'role': 'application',
|
|
110
|
+
'style': {
|
|
111
|
+
cursor: 'pointer',
|
|
112
|
+
position: 'relative',
|
|
113
|
+
backgroundColor: 'black',
|
|
114
|
+
maxWidth: '100%',
|
|
115
|
+
width: `${props.width}px`,
|
|
116
|
+
height: `'auto'`,
|
|
117
|
+
aspectRatio: `${props.width}/${props.height}`,
|
|
118
|
+
},
|
|
119
|
+
}) as HTMLAttributes
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
const placeholder = computed(() => `https://i.ytimg.com/vi_webp/${props.videoId}/sddefault.webp`)
|
|
123
|
+
|
|
124
|
+
if (import.meta.server) {
|
|
125
|
+
// dns-prefetch https://i.vimeocdn.com
|
|
126
|
+
useHead({
|
|
127
|
+
link: [
|
|
128
|
+
{
|
|
129
|
+
rel: props.aboveTheFold ? 'preconnect' : 'dns-prefetch',
|
|
130
|
+
href: 'https://i.ytimg.com',
|
|
131
|
+
},
|
|
132
|
+
props.aboveTheFold
|
|
133
|
+
// we can preload the placeholder image
|
|
134
|
+
? {
|
|
135
|
+
rel: 'preload',
|
|
136
|
+
as: 'image',
|
|
137
|
+
href: placeholder.value,
|
|
138
|
+
}
|
|
139
|
+
: {},
|
|
140
|
+
],
|
|
141
|
+
})
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const placeholderAttrs = computed(() => {
|
|
145
|
+
return defu(props.placeholderAttrs, {
|
|
146
|
+
src: placeholder.value,
|
|
147
|
+
alt: '',
|
|
148
|
+
loading: props.aboveTheFold ? 'eager' : 'lazy',
|
|
149
|
+
style: {
|
|
150
|
+
width: '100%',
|
|
151
|
+
objectFit: 'contain',
|
|
152
|
+
height: '100%',
|
|
153
|
+
},
|
|
154
|
+
} satisfies ImgHTMLAttributes)
|
|
155
|
+
})
|
|
156
|
+
</script>
|
|
157
|
+
|
|
158
|
+
<template>
|
|
159
|
+
<div ref="rootEl" v-bind="rootAttrs">
|
|
160
|
+
<div ref="youtubeEl" style="width: 100%; height: 100%; position: absolute; top: 0; left: 0;" />
|
|
161
|
+
<slot v-if="!ready" :placeholder="placeholder" name="placeholder">
|
|
162
|
+
<img v-bind="placeholderAttrs">
|
|
163
|
+
</slot>
|
|
164
|
+
<slot v-if="$script.status.value === 'loading'" name="loading">
|
|
165
|
+
<ScriptLoadingIndicator />
|
|
166
|
+
</slot>
|
|
167
|
+
<slot v-if="$script.status.value === 'awaitingLoad'" name="awaitingLoad" />
|
|
168
|
+
<slot v-else-if="$script.status.value === 'error'" name="error" />
|
|
169
|
+
<slot />
|
|
170
|
+
</div>
|
|
171
|
+
</template>
|
|
@@ -20,7 +20,7 @@ export function useScript(input, options) {
|
|
|
20
20
|
if (!nuxtApp._scripts?.[id]) {
|
|
21
21
|
performance?.mark?.("mark_feature_usage", {
|
|
22
22
|
detail: {
|
|
23
|
-
feature: `nuxt-scripts:${id}`
|
|
23
|
+
feature: options.performanceMarkFeature ?? `nuxt-scripts:${id}`
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
26
|
}
|
|
@@ -33,7 +33,7 @@ export function useScript(input, options) {
|
|
|
33
33
|
nuxtApp.hooks.callHook("scripts:updated", { scripts: nuxtApp._scripts });
|
|
34
34
|
};
|
|
35
35
|
const payload = {
|
|
36
|
-
|
|
36
|
+
...options.devtools,
|
|
37
37
|
src: input.src,
|
|
38
38
|
$script: null,
|
|
39
39
|
events: []
|
|
@@ -53,7 +53,7 @@ export function useScript(input, options) {
|
|
|
53
53
|
syncScripts();
|
|
54
54
|
});
|
|
55
55
|
head.hooks.hook("script:instance-fn", (ctx) => {
|
|
56
|
-
if (ctx.script.id !== instance.$script.id)
|
|
56
|
+
if (ctx.script.id !== instance.$script.id || String(ctx.fn).startsWith("__v_"))
|
|
57
57
|
return;
|
|
58
58
|
payload.events.push({
|
|
59
59
|
type: "fn-call",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TrackedPage } from '#nuxt-scripts';
|
|
2
|
-
export declare function useScriptEventPage(onChange?: (payload: TrackedPage) => void): import("
|
|
2
|
+
export declare function useScriptEventPage(onChange?: (payload: TrackedPage) => void): import("#imports").Ref<{
|
|
3
3
|
title?: string;
|
|
4
4
|
path: string;
|
|
5
5
|
}>;
|
|
@@ -31,7 +31,7 @@ export declare const CrispOptions: import("valibot").ObjectSchema<{
|
|
|
31
31
|
*/
|
|
32
32
|
readonly cookieExpiry: import("valibot").OptionalSchema<import("valibot").NumberSchema<undefined>, never>;
|
|
33
33
|
}, undefined>;
|
|
34
|
-
export type CrispInput = RegistryScriptInput<typeof CrispOptions, false>;
|
|
34
|
+
export type CrispInput = RegistryScriptInput<typeof CrispOptions, false, false, false>;
|
|
35
35
|
export interface CrispApi {
|
|
36
36
|
push: (...args: any[]) => void;
|
|
37
37
|
is: (name: 'chat:opened' | 'chat:closed' | 'chat:visible' | 'chat:hidden' | 'chat:small' | 'chat:large' | 'session:ongoing' | 'website:available' | 'overlay:opened' | 'overlay:closed' | string) => boolean;
|
|
@@ -21,7 +21,7 @@ export declare const FathomAnalyticsOptions: import("valibot").ObjectSchema<{
|
|
|
21
21
|
*/
|
|
22
22
|
readonly honorDnt: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, never>;
|
|
23
23
|
}, undefined>;
|
|
24
|
-
export type FathomAnalyticsInput = RegistryScriptInput<typeof FathomAnalyticsOptions, false>;
|
|
24
|
+
export type FathomAnalyticsInput = RegistryScriptInput<typeof FathomAnalyticsOptions, false, false, false>;
|
|
25
25
|
export interface FathomAnalyticsApi {
|
|
26
26
|
beacon: (ctx: {
|
|
27
27
|
url: string;
|
|
@@ -5,7 +5,7 @@ export declare const GoogleAdsenseOptions: import("valibot").ObjectSchema<{
|
|
|
5
5
|
*/
|
|
6
6
|
readonly client: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, never>;
|
|
7
7
|
}, undefined>;
|
|
8
|
-
export type GoogleAdsenseInput = RegistryScriptInput<typeof GoogleAdsenseOptions>;
|
|
8
|
+
export type GoogleAdsenseInput = RegistryScriptInput<typeof GoogleAdsenseOptions, true, false, false>;
|
|
9
9
|
export interface GoogleAdsenseApi {
|
|
10
10
|
/**
|
|
11
11
|
* The Google Adsense API.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { DataLayer, GTag } from 'third-party-capital';
|
|
2
|
+
import type { RegistryScriptInput } from '#nuxt-scripts';
|
|
3
|
+
export declare const GoogleAnalyticsOptions: import("valibot").ObjectSchema<{
|
|
4
|
+
readonly id: import("valibot").StringSchema<undefined>;
|
|
5
|
+
readonly l: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, never>;
|
|
6
|
+
}, undefined>;
|
|
7
|
+
export type GoogleAnalyticsInput = RegistryScriptInput<typeof GoogleAnalyticsOptions>;
|
|
8
|
+
export declare function useScriptGoogleAnalytics(_options?: GoogleAnalyticsInput): {
|
|
9
|
+
dataLayer: DataLayer;
|
|
10
|
+
gtag: GTag;
|
|
11
|
+
} & {
|
|
12
|
+
$script: Promise<{
|
|
13
|
+
dataLayer: DataLayer;
|
|
14
|
+
gtag: GTag;
|
|
15
|
+
}> & import("@unhead/vue").VueScriptInstance<{
|
|
16
|
+
dataLayer: DataLayer;
|
|
17
|
+
gtag: GTag;
|
|
18
|
+
}>;
|
|
19
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { withQuery } from "ufo";
|
|
2
|
+
import { useRegistryScript } from "#nuxt-scripts-utils";
|
|
3
|
+
import { object, string, optional } from "#nuxt-scripts-validator";
|
|
4
|
+
export const GoogleAnalyticsOptions = object({
|
|
5
|
+
id: string(),
|
|
6
|
+
l: optional(string())
|
|
7
|
+
});
|
|
8
|
+
function use(options) {
|
|
9
|
+
const gtag = function(...args) {
|
|
10
|
+
window[options.l ?? "dataLayer"].push(args);
|
|
11
|
+
};
|
|
12
|
+
return {
|
|
13
|
+
dataLayer: window[options.l ?? "dataLayer"],
|
|
14
|
+
gtag
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export function useScriptGoogleAnalytics(_options) {
|
|
18
|
+
return useRegistryScript(_options?.key || "googleAnalytics", (options) => ({
|
|
19
|
+
scriptInput: {
|
|
20
|
+
src: withQuery("https://www.googletagmanager.com/gtag/js", { id: options?.id, l: options?.l })
|
|
21
|
+
},
|
|
22
|
+
schema: import.meta.dev ? GoogleAnalyticsOptions : void 0,
|
|
23
|
+
scriptOptions: {
|
|
24
|
+
use: () => use(options),
|
|
25
|
+
stub: import.meta.client ? void 0 : ({ fn }) => {
|
|
26
|
+
return fn === "dataLayer" ? [] : void 0;
|
|
27
|
+
},
|
|
28
|
+
performanceMarkFeature: "nuxt-third-parties-ga",
|
|
29
|
+
...{ tagPriority: 1 }
|
|
30
|
+
},
|
|
31
|
+
// eslint-disable-next-line
|
|
32
|
+
// @ts-ignore
|
|
33
|
+
// eslint-disable-next-line
|
|
34
|
+
clientInit: import.meta.server ? void 0 : () => {
|
|
35
|
+
window[options?.l ?? "dataLayer"] = window[options?.l ?? "dataLayer"] || [];
|
|
36
|
+
window[options?.l ?? "dataLayer"].push({ "js": /* @__PURE__ */ new Date() });
|
|
37
|
+
window[options?.l ?? "dataLayer"].push({ "config": options?.id });
|
|
38
|
+
}
|
|
39
|
+
}), _options);
|
|
40
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { GoogleTagManagerApi, DataLayer } from 'third-party-capital';
|
|
2
|
+
import type { RegistryScriptInput } from '#nuxt-scripts';
|
|
3
|
+
declare global {
|
|
4
|
+
interface Window extends GoogleTagManagerApi {
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
export declare const GoogleTagManagerOptions: import("valibot").ObjectSchema<{
|
|
8
|
+
readonly id: import("valibot").StringSchema<undefined>;
|
|
9
|
+
readonly l: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, never>;
|
|
10
|
+
}, undefined>;
|
|
11
|
+
export type GoogleTagManagerInput = RegistryScriptInput<typeof GoogleTagManagerOptions>;
|
|
12
|
+
export declare function useScriptGoogleTagManager(_options?: GoogleTagManagerInput): {
|
|
13
|
+
dataLayer: DataLayer;
|
|
14
|
+
google_tag_manager: import("third-party-capital").GoogleTagManagerInstance;
|
|
15
|
+
} & {
|
|
16
|
+
$script: Promise<{
|
|
17
|
+
dataLayer: DataLayer;
|
|
18
|
+
google_tag_manager: import("third-party-capital").GoogleTagManagerInstance;
|
|
19
|
+
}> & import("@unhead/vue").VueScriptInstance<{
|
|
20
|
+
dataLayer: DataLayer;
|
|
21
|
+
google_tag_manager: import("third-party-capital").GoogleTagManagerInstance;
|
|
22
|
+
}>;
|
|
23
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { withQuery } from "ufo";
|
|
2
|
+
import { useRegistryScript } from "#nuxt-scripts-utils";
|
|
3
|
+
import { object, string, optional } from "#nuxt-scripts-validator";
|
|
4
|
+
export const GoogleTagManagerOptions = object({
|
|
5
|
+
id: string(),
|
|
6
|
+
l: optional(string())
|
|
7
|
+
});
|
|
8
|
+
function use(options) {
|
|
9
|
+
return { dataLayer: window[options.l ?? "dataLayer"], google_tag_manager: window.google_tag_manager };
|
|
10
|
+
}
|
|
11
|
+
export function useScriptGoogleTagManager(_options) {
|
|
12
|
+
return useRegistryScript(_options?.key || "googleTagManager", (options) => ({
|
|
13
|
+
scriptInput: {
|
|
14
|
+
src: withQuery("https://www.googletagmanager.com/gtm.js", { id: options?.id, l: options?.l })
|
|
15
|
+
},
|
|
16
|
+
schema: import.meta.dev ? GoogleTagManagerOptions : void 0,
|
|
17
|
+
scriptOptions: {
|
|
18
|
+
use: () => use(options),
|
|
19
|
+
stub: import.meta.client ? void 0 : ({ fn }) => {
|
|
20
|
+
return fn === "dataLayer" ? [] : void 0;
|
|
21
|
+
},
|
|
22
|
+
performanceMarkFeature: "nuxt-third-parties-gtm",
|
|
23
|
+
...{ tagPriority: 1 }
|
|
24
|
+
},
|
|
25
|
+
// eslint-disable-next-line
|
|
26
|
+
// @ts-ignore
|
|
27
|
+
// eslint-disable-next-line
|
|
28
|
+
clientInit: import.meta.server ? void 0 : () => {
|
|
29
|
+
window[options?.l ?? "dataLayer"] = window[options?.l ?? "dataLayer"] || [];
|
|
30
|
+
window[options?.l ?? "dataLayer"].push({ "gtm.start": (/* @__PURE__ */ new Date()).getTime(), event: "gtm.js" });
|
|
31
|
+
}
|
|
32
|
+
}), _options);
|
|
33
|
+
}
|
|
@@ -16,7 +16,7 @@ export declare const HotjarOptions: import("valibot").ObjectSchema<{
|
|
|
16
16
|
readonly id: import("valibot").NumberSchema<undefined>;
|
|
17
17
|
readonly sv: import("valibot").OptionalSchema<import("valibot").NumberSchema<undefined>, never>;
|
|
18
18
|
}, undefined>;
|
|
19
|
-
export type HotjarInput = RegistryScriptInput<typeof HotjarOptions>;
|
|
19
|
+
export type HotjarInput = RegistryScriptInput<typeof HotjarOptions, true, false, false>;
|
|
20
20
|
export declare function useScriptHotjar<T extends HotjarApi>(_options?: HotjarInput): T & {
|
|
21
21
|
$script: Promise<T> & import("@unhead/vue").VueScriptInstance<T>;
|
|
22
22
|
};
|
|
@@ -10,7 +10,7 @@ export declare const IntercomOptions: import("valibot").ObjectSchema<{
|
|
|
10
10
|
readonly horizontal_padding: import("valibot").OptionalSchema<import("valibot").NumberSchema<undefined>, never>;
|
|
11
11
|
readonly vertical_padding: import("valibot").OptionalSchema<import("valibot").NumberSchema<undefined>, never>;
|
|
12
12
|
}, undefined>;
|
|
13
|
-
export type IntercomInput = RegistryScriptInput<typeof IntercomOptions>;
|
|
13
|
+
export type IntercomInput = RegistryScriptInput<typeof IntercomOptions, true, false, false>;
|
|
14
14
|
export interface IntercomApi {
|
|
15
15
|
Intercom: ((event: 'boot', data?: InferInput<typeof IntercomOptions>) => void) & ((event: 'shutdown') => void) & ((event: 'update', options?: InferInput<typeof IntercomOptions>) => void) & ((event: 'hide') => void) & ((event: 'show') => void) & ((event: 'showSpace', spaceName: 'home' | 'messages' | 'help' | 'news' | 'tasks' | 'tickets' | string) => void) & ((event: 'showMessages') => void) & ((event: 'showNewMessage', content?: string) => void) & ((event: 'onHide', fn: () => void) => void) & ((event: 'onShow', fn: () => void) => void) & ((event: 'onUnreadCountChange', fn: () => void) => void) & ((event: 'trackEvent', eventName: string, metadata?: Record<string, any>) => void) & ((event: 'getVisitorId') => Promise<string>) & ((event: 'startTour', tourId: string | number) => void) & ((event: 'showArticle', articleId: string | number) => void) & ((event: 'showNews', newsItemId: string | number) => void) & ((event: 'startSurvey', surveyId: string | number) => void) & ((event: 'startChecklist', checklistId: string | number) => void) & ((event: 'showTicket', ticketId: string | number) => void) & ((event: 'showConversation', conversationId: string | number) => void) & ((event: 'onUserEmailSupplied', fn: () => void) => void) & ((event: string, ...params: any[]) => void);
|
|
16
16
|
}
|
|
@@ -5,7 +5,7 @@ export declare const MatomoAnalyticsOptions: import("valibot").ObjectSchema<{
|
|
|
5
5
|
readonly trackPageView: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, never>;
|
|
6
6
|
readonly enableLinkTracking: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, never>;
|
|
7
7
|
}, undefined>;
|
|
8
|
-
export type MatomoAnalyticsInput = RegistryScriptInput<typeof MatomoAnalyticsOptions, false>;
|
|
8
|
+
export type MatomoAnalyticsInput = RegistryScriptInput<typeof MatomoAnalyticsOptions, false, false, false>;
|
|
9
9
|
interface MatomoAnalyticsApi {
|
|
10
10
|
_paq: unknown[];
|
|
11
11
|
}
|
|
@@ -35,7 +35,7 @@ declare global {
|
|
|
35
35
|
export declare const MetaPixelOptions: import("valibot").ObjectSchema<{
|
|
36
36
|
readonly id: import("valibot").UnionSchema<[import("valibot").StringSchema<undefined>, import("valibot").NumberSchema<undefined>], undefined>;
|
|
37
37
|
}, undefined>;
|
|
38
|
-
export type MetaPixelInput = RegistryScriptInput<typeof MetaPixelOptions>;
|
|
38
|
+
export type MetaPixelInput = RegistryScriptInput<typeof MetaPixelOptions, true, false, false>;
|
|
39
39
|
export declare function useScriptMetaPixel<T extends MetaPixelApi>(_options?: MetaPixelInput): T & {
|
|
40
40
|
$script: Promise<T> & import("@unhead/vue").VueScriptInstance<T>;
|
|
41
41
|
};
|
|
@@ -5,7 +5,7 @@ export declare const NpmOptions: import("valibot").ObjectSchema<{
|
|
|
5
5
|
readonly version: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, never>;
|
|
6
6
|
readonly type: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, never>;
|
|
7
7
|
}, undefined>;
|
|
8
|
-
export type NpmInput = RegistryScriptInput<typeof NpmOptions>;
|
|
8
|
+
export type NpmInput = RegistryScriptInput<typeof NpmOptions, true, true, false>;
|
|
9
9
|
export declare function useScriptNpm<T extends Record<string | symbol, any>>(_options: NpmInput): T & {
|
|
10
10
|
$script: Promise<T> & import("@unhead/vue").VueScriptInstance<T>;
|
|
11
11
|
};
|
|
@@ -31,7 +31,7 @@ export declare const XPixelOptions: import("valibot").ObjectSchema<{
|
|
|
31
31
|
readonly id: import("valibot").StringSchema<undefined>;
|
|
32
32
|
readonly version: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, never>;
|
|
33
33
|
}, undefined>;
|
|
34
|
-
export type XPixelInput = RegistryScriptInput<typeof XPixelOptions>;
|
|
34
|
+
export type XPixelInput = RegistryScriptInput<typeof XPixelOptions, true, false, false>;
|
|
35
35
|
export declare function useScriptXPixel<T extends XPixelApi>(_options?: XPixelInput): T & {
|
|
36
36
|
$script: Promise<T> & import("@unhead/vue").VueScriptInstance<T>;
|
|
37
37
|
};
|