@nuxt/scripts 0.5.1 → 0.6.1
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 +2 -2
- package/dist/client/200.html +19 -16
- package/dist/client/404.html +19 -16
- package/dist/client/_nuxt/B474tPdy.js +66 -0
- package/dist/client/_nuxt/{DMNuDhJC.js → BN0jYG70.js} +1 -1
- package/dist/client/_nuxt/Buoqr_Oi.js +2 -0
- package/dist/client/_nuxt/C2pTd85Q.js +1 -0
- package/dist/client/_nuxt/{DCjyzNN-.js → D4FSFK-1.js} +1 -1
- package/dist/client/_nuxt/DAP_O-zg.js +1 -0
- package/dist/client/_nuxt/{o8H-iTt6.js → DG8tVHNj.js} +1 -1
- package/dist/client/_nuxt/DKGhHdqV.js +31 -0
- package/dist/client/_nuxt/DVC_qXWv.js +1 -0
- package/dist/client/_nuxt/{NL97_oaV.js → GPY1wEXZ.js} +1 -1
- package/dist/client/_nuxt/RyEv5ndP.js +1 -0
- package/dist/client/_nuxt/VQMr7AbF.js +1 -0
- package/dist/client/_nuxt/builds/latest.json +1 -1
- package/dist/client/_nuxt/builds/meta/4f39734b-85e5-476e-ae38-d6452686955c.json +1 -0
- package/dist/client/_nuxt/cW9vKj3g.js +1 -0
- package/dist/client/_nuxt/entry.DvGwvmL9.css +1 -0
- package/dist/client/_nuxt/error-404.DXyehy0d.css +1 -0
- package/dist/client/_nuxt/error-500.a_92Fvyl.css +1 -0
- package/dist/client/index.html +19 -16
- package/dist/module.d.mts +3 -3
- package/dist/module.d.ts +3 -3
- package/dist/module.json +2 -2
- package/dist/module.mjs +191 -59
- package/dist/registry.mjs +15 -2
- package/dist/runtime/components/ScriptCarbonAds.vue +5 -4
- package/dist/runtime/components/ScriptCrisp.vue +84 -0
- package/dist/runtime/components/ScriptGoogleAdsense.vue +23 -4
- package/dist/runtime/components/ScriptGoogleMaps.vue +15 -14
- package/dist/runtime/components/ScriptIntercom.vue +93 -0
- package/dist/runtime/components/ScriptLemonSqueezy.vue +45 -0
- package/dist/runtime/components/ScriptLoadingIndicator.vue +12 -3
- package/dist/runtime/components/ScriptStripePricingTable.vue +30 -18
- package/dist/runtime/components/ScriptVimeoPlayer.vue +13 -3
- package/dist/runtime/components/ScriptYouTubePlayer.vue +13 -3
- package/dist/runtime/composables/useScript.js +6 -1
- package/dist/runtime/composables/useScriptEventPage.d.ts +5 -0
- package/dist/runtime/composables/{useAnalyticsPageEvent.js → useScriptEventPage.js} +1 -1
- package/dist/runtime/composables/{useConsentScriptTrigger.d.ts → useScriptTriggerConsent.d.ts} +1 -1
- package/dist/runtime/composables/{useConsentScriptTrigger.js → useScriptTriggerConsent.js} +1 -1
- package/dist/runtime/composables/{useElementScriptTrigger.d.ts → useScriptTriggerElement.d.ts} +1 -1
- package/dist/runtime/composables/{useElementScriptTrigger.js → useScriptTriggerElement.js} +5 -4
- package/dist/runtime/registry/crisp.d.ts +62 -0
- package/dist/runtime/registry/crisp.js +76 -0
- package/dist/runtime/registry/google-adsense.d.ts +1 -1
- package/dist/runtime/registry/intercom.d.ts +1 -1
- package/dist/runtime/registry/lemon-squeezy.d.ts +19 -12
- package/dist/runtime/registry/stripe.d.ts +0 -1
- package/dist/runtime/registry/vimeo-player.d.ts +1 -1
- package/dist/runtime/registry/youtube-player.d.ts +0 -1
- package/dist/runtime/types.d.ts +14 -8
- package/dist/runtime/utils.js +2 -1
- package/dist/types.d.mts +2 -10
- package/dist/types.d.ts +2 -10
- package/package.json +36 -28
- package/dist/client/_nuxt/Bn0B8vkx.js +0 -1
- package/dist/client/_nuxt/BvlfuC5v.js +0 -31
- package/dist/client/_nuxt/Bx89rGXK.js +0 -1
- package/dist/client/_nuxt/CoEqzGFw.js +0 -44
- package/dist/client/_nuxt/builds/meta/b4275645-e497-405e-b7c0-87516033342e.json +0 -1
- package/dist/client/_nuxt/entry.8LvBfYHJ.css +0 -1
- package/dist/client/_nuxt/error-404.Dbi768NS.css +0 -1
- package/dist/client/_nuxt/error-500.C23YdqXl.css +0 -1
- package/dist/client/_nuxt/jmWmhCGR.js +0 -1
- package/dist/runtime/components/ScriptLemonSqueezyButton.vue +0 -41
- package/dist/runtime/composables/useAnalyticsPageEvent.d.ts +0 -2
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { useScriptIntercom } from '../registry/intercom'
|
|
3
|
+
import { useScriptTriggerElement } from '../composables/useScriptTriggerElement'
|
|
4
|
+
import { ref, onMounted, watch, onBeforeUnmount } from '#imports'
|
|
5
|
+
import type { ElementScriptTrigger } from '#nuxt-scripts'
|
|
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
|
+
if (props.trigger === 'click')
|
|
50
|
+
intercom.Intercom('show')
|
|
51
|
+
const { $script } = intercom
|
|
52
|
+
|
|
53
|
+
defineExpose({
|
|
54
|
+
intercom,
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
let observer: MutationObserver
|
|
58
|
+
onMounted(() => {
|
|
59
|
+
watch($script.status, (status) => {
|
|
60
|
+
if (status === 'loading') {
|
|
61
|
+
observer = new MutationObserver(() => {
|
|
62
|
+
if (document.getElementById('intercom-frame')) {
|
|
63
|
+
isReady.value = true
|
|
64
|
+
emits('ready', intercom)
|
|
65
|
+
observer.disconnect()
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
observer.observe(document.body, { childList: true, subtree: true })
|
|
69
|
+
}
|
|
70
|
+
else if (status === 'error')
|
|
71
|
+
emits('error')
|
|
72
|
+
})
|
|
73
|
+
})
|
|
74
|
+
onBeforeUnmount(() => {
|
|
75
|
+
observer?.disconnect()
|
|
76
|
+
})
|
|
77
|
+
</script>
|
|
78
|
+
|
|
79
|
+
<template>
|
|
80
|
+
<div
|
|
81
|
+
ref="rootEl"
|
|
82
|
+
:style="{
|
|
83
|
+
display: isReady ? 'none' : 'block',
|
|
84
|
+
bottom: `${verticalPadding || 20}px`,
|
|
85
|
+
[alignment || 'right']: `${horizontalPadding || 20}px`,
|
|
86
|
+
}"
|
|
87
|
+
>
|
|
88
|
+
<slot :ready="isReady" />
|
|
89
|
+
<slot v-if="$script.status.value === 'awaitingLoad'" name="awaitingLoad" />
|
|
90
|
+
<slot v-else-if="$script.status.value === 'loading' || !isReady" name="loading" />
|
|
91
|
+
<slot v-else-if="$script.status.value === 'error'" name="error" />
|
|
92
|
+
</div>
|
|
93
|
+
</template>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import type { ElementScriptTrigger } from '../types'
|
|
3
|
+
import { useScriptTriggerElement } from '../composables/useScriptTriggerElement'
|
|
4
|
+
import { useScriptLemonSqueezy } from '../registry/lemon-squeezy'
|
|
5
|
+
import type { LemonSqueezyEventPayload } from '../registry/lemon-squeezy'
|
|
6
|
+
import { onMounted, ref } from '#imports'
|
|
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 instance = useScriptLemonSqueezy({
|
|
21
|
+
scriptOptions: {
|
|
22
|
+
trigger: useScriptTriggerElement({ trigger: props.trigger, el: rootEl }),
|
|
23
|
+
},
|
|
24
|
+
})
|
|
25
|
+
onMounted(() => {
|
|
26
|
+
rootEl.value?.querySelectorAll('a[href]').forEach((a) => {
|
|
27
|
+
a.classList.add('lemonsqueezy-button')
|
|
28
|
+
})
|
|
29
|
+
instance.$script.then(({ Setup, Refresh }) => {
|
|
30
|
+
Setup({
|
|
31
|
+
eventHandler(event) {
|
|
32
|
+
emits('lemonSqueezyEvent', event)
|
|
33
|
+
},
|
|
34
|
+
})
|
|
35
|
+
Refresh()
|
|
36
|
+
emits('ready', instance)
|
|
37
|
+
})
|
|
38
|
+
})
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
<template>
|
|
42
|
+
<div ref="rootEl">
|
|
43
|
+
<slot />
|
|
44
|
+
</div>
|
|
45
|
+
</template>
|
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
|
|
2
|
+
import { computed } from '#imports'
|
|
3
|
+
|
|
4
|
+
const props = withDefaults(defineProps<{
|
|
3
5
|
color?: string
|
|
6
|
+
size?: number
|
|
4
7
|
}>(), {
|
|
5
8
|
color: 'currentColor',
|
|
9
|
+
size: 30,
|
|
6
10
|
})
|
|
11
|
+
|
|
12
|
+
const styles = computed(() => ({
|
|
13
|
+
width: `${props.size}px`,
|
|
14
|
+
height: `${props.size}px`,
|
|
15
|
+
}))
|
|
7
16
|
</script>
|
|
8
17
|
|
|
9
18
|
<template>
|
|
10
|
-
<div class="loader" aria-label="Loading..." role="status" />
|
|
19
|
+
<div class="loader" :styles="styles" aria-label="Loading..." role="status" />
|
|
11
20
|
</template>
|
|
12
21
|
|
|
13
22
|
<style scoped>
|
|
14
|
-
.loader{animation:rotation 1s linear infinite;border:5px solid v-bind(color);border-bottom-color:transparent;border-radius:50%;
|
|
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)}}
|
|
15
24
|
</style>
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { ref } from 'vue'
|
|
3
3
|
import type { ElementScriptTrigger } from '../types'
|
|
4
|
-
import {
|
|
4
|
+
import { useScriptTriggerElement } from '../composables/useScriptTriggerElement'
|
|
5
|
+
import { useScript } from '../composables/useScript'
|
|
6
|
+
import { onBeforeUnmount, onMounted, watch } from '#imports'
|
|
5
7
|
|
|
6
8
|
const props = withDefaults(defineProps<{
|
|
7
9
|
trigger?: ElementScriptTrigger
|
|
@@ -15,30 +17,39 @@ const props = withDefaults(defineProps<{
|
|
|
15
17
|
})
|
|
16
18
|
|
|
17
19
|
const emit = defineEmits<{
|
|
18
|
-
ready: []
|
|
20
|
+
ready: [ReturnType<typeof useScript>]
|
|
21
|
+
error: []
|
|
19
22
|
}>()
|
|
20
23
|
|
|
21
24
|
const rootEl = ref<HTMLDivElement | undefined>()
|
|
22
25
|
const containerEl = ref<HTMLDivElement | undefined>()
|
|
23
|
-
const
|
|
24
|
-
trigger:
|
|
26
|
+
const instance = useScript(`https://js.stripe.com/v3/pricing-table.js`, {
|
|
27
|
+
trigger: useScriptTriggerElement({ trigger: props.trigger, el: rootEl }),
|
|
25
28
|
})
|
|
29
|
+
const { $script } = instance
|
|
26
30
|
|
|
27
31
|
const pricingTable = ref<HTMLElement | undefined>()
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
32
|
+
onMounted(() => {
|
|
33
|
+
$script.then(() => {
|
|
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($script.status, (status) => {
|
|
49
|
+
if (status === 'error') {
|
|
50
|
+
emit('error')
|
|
51
|
+
}
|
|
52
|
+
})
|
|
42
53
|
})
|
|
43
54
|
|
|
44
55
|
onBeforeUnmount(() => {
|
|
@@ -51,6 +62,7 @@ onBeforeUnmount(() => {
|
|
|
51
62
|
<div ref="containerEl" />
|
|
52
63
|
<slot v-if="$script.status.value === 'loading'" name="loading" />
|
|
53
64
|
<slot v-if="$script.status.value === 'awaitingLoad'" name="awaitingLoad" />
|
|
65
|
+
<slot v-else-if="$script.status.value === 'error'" name="error" />
|
|
54
66
|
<slot />
|
|
55
67
|
</div>
|
|
56
68
|
</template>
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
/// <reference types="vimeo__player" />
|
|
3
|
-
import {
|
|
3
|
+
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
|
4
|
+
import type { HTMLAttributes, ImgHTMLAttributes } from 'vue'
|
|
4
5
|
import { defu } from 'defu'
|
|
5
6
|
import type { ElementScriptTrigger } from '../types'
|
|
6
|
-
import {
|
|
7
|
+
import { useScriptTriggerElement } from '../composables/useScriptTriggerElement'
|
|
8
|
+
import { useScriptVimeoPlayer } from '../registry/vimeo-player'
|
|
9
|
+
import { useAsyncData, useHead } from '#imports'
|
|
7
10
|
|
|
8
11
|
const props = withDefaults(defineProps<{
|
|
9
12
|
// custom
|
|
@@ -111,7 +114,7 @@ const events: (keyof TEmits)[] = [
|
|
|
111
114
|
const elVimeo = ref()
|
|
112
115
|
const rootEl = ref()
|
|
113
116
|
|
|
114
|
-
const trigger =
|
|
117
|
+
const trigger = useScriptTriggerElement({ trigger: props.trigger, el: rootEl })
|
|
115
118
|
let clickTriggered = false
|
|
116
119
|
if (props.trigger === 'mousedown') {
|
|
117
120
|
trigger.then(() => {
|
|
@@ -187,6 +190,12 @@ onMounted(() => {
|
|
|
187
190
|
watch(() => props.id, (v) => {
|
|
188
191
|
v && player?.loadVideo(Number(v))
|
|
189
192
|
})
|
|
193
|
+
watch($script.status, (status) => {
|
|
194
|
+
if (status === 'error') {
|
|
195
|
+
// @ts-expect-error untyped
|
|
196
|
+
emits('error')
|
|
197
|
+
}
|
|
198
|
+
})
|
|
190
199
|
})
|
|
191
200
|
|
|
192
201
|
const rootAttrs = computed(() => {
|
|
@@ -239,6 +248,7 @@ onBeforeUnmount(() => player?.unload())
|
|
|
239
248
|
<ScriptLoadingIndicator color="white" />
|
|
240
249
|
</slot>
|
|
241
250
|
<slot v-if="$script.status.value === 'awaitingLoad'" name="awaitingLoad" />
|
|
251
|
+
<slot v-else-if="$script.status.value === 'error'" name="error" />
|
|
242
252
|
<slot />
|
|
243
253
|
</div>
|
|
244
254
|
</template>
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
/// <reference types="youtube" />
|
|
3
|
-
import {
|
|
3
|
+
import { computed, onMounted, ref, watch } from 'vue'
|
|
4
|
+
import type { HTMLAttributes, ImgHTMLAttributes, Ref } from 'vue'
|
|
4
5
|
import { defu } from 'defu'
|
|
5
6
|
import type { ElementScriptTrigger } from '../types'
|
|
6
|
-
import {
|
|
7
|
+
import { useScriptTriggerElement } from '../composables/useScriptTriggerElement'
|
|
8
|
+
import { useScriptYouTubePlayer } from '../registry/youtube-player'
|
|
9
|
+
import { useHead } from '#imports'
|
|
7
10
|
|
|
8
11
|
const props = withDefaults(defineProps<{
|
|
9
12
|
placeholderAttrs?: ImgHTMLAttributes
|
|
@@ -40,7 +43,7 @@ const events: (keyof YT.Events)[] = [
|
|
|
40
43
|
const rootEl = ref()
|
|
41
44
|
const youtubeEl = ref()
|
|
42
45
|
const ready = ref(false)
|
|
43
|
-
const trigger =
|
|
46
|
+
const trigger = useScriptTriggerElement({ trigger: props.trigger, el: rootEl })
|
|
44
47
|
const { $script } = useScriptYouTubePlayer({
|
|
45
48
|
scriptOptions: {
|
|
46
49
|
trigger,
|
|
@@ -82,6 +85,12 @@ onMounted(() => {
|
|
|
82
85
|
}])),
|
|
83
86
|
})
|
|
84
87
|
})
|
|
88
|
+
watch($script.status, (status) => {
|
|
89
|
+
if (status === 'error') {
|
|
90
|
+
// @ts-expect-error untyped
|
|
91
|
+
emits('error')
|
|
92
|
+
}
|
|
93
|
+
})
|
|
85
94
|
})
|
|
86
95
|
|
|
87
96
|
defineExpose({
|
|
@@ -156,5 +165,6 @@ const placeholderAttrs = computed(() => {
|
|
|
156
165
|
<ScriptLoadingIndicator />
|
|
157
166
|
</slot>
|
|
158
167
|
<slot v-if="$script.status.value === 'awaitingLoad'" name="awaitingLoad" />
|
|
168
|
+
<slot v-else-if="$script.status.value === 'error'" name="error" />
|
|
159
169
|
</div>
|
|
160
170
|
</template>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { hashCode } from "@unhead/shared";
|
|
2
2
|
import { defu } from "defu";
|
|
3
3
|
import { useScript as _useScript } from "@unhead/vue";
|
|
4
|
-
import { injectHead, onNuxtReady, useNuxtApp, useRuntimeConfig } from "#imports";
|
|
4
|
+
import { injectHead, onNuxtReady, useNuxtApp, useRuntimeConfig, reactive } from "#imports";
|
|
5
5
|
function useNuxtScriptRuntimeConfig() {
|
|
6
6
|
return useRuntimeConfig().public["nuxt-scripts"];
|
|
7
7
|
}
|
|
@@ -12,6 +12,10 @@ export function useScript(input, options) {
|
|
|
12
12
|
options.trigger = onNuxtReady;
|
|
13
13
|
const nuxtApp = useNuxtApp();
|
|
14
14
|
const id = input.key || input.src || hashCode(typeof input.innerHTML === "string" ? input.innerHTML : "");
|
|
15
|
+
nuxtApp.$scripts = nuxtApp.$scripts || reactive({});
|
|
16
|
+
if (nuxtApp.$scripts[id]) {
|
|
17
|
+
return nuxtApp.$scripts[id];
|
|
18
|
+
}
|
|
15
19
|
if (import.meta.client) {
|
|
16
20
|
if (!nuxtApp._scripts?.[id]) {
|
|
17
21
|
performance?.mark?.("mark_feature_usage", {
|
|
@@ -22,6 +26,7 @@ export function useScript(input, options) {
|
|
|
22
26
|
}
|
|
23
27
|
}
|
|
24
28
|
const instance = _useScript(input, options);
|
|
29
|
+
nuxtApp.$scripts[id] = instance;
|
|
25
30
|
if (import.meta.dev && import.meta.client) {
|
|
26
31
|
let syncScripts = function() {
|
|
27
32
|
nuxtApp._scripts[instance.$script.id] = payload;
|
package/dist/runtime/composables/{useConsentScriptTrigger.d.ts → useScriptTriggerConsent.d.ts}
RENAMED
|
@@ -9,5 +9,5 @@ interface UseConsentScriptTriggerApi extends Promise<void> {
|
|
|
9
9
|
* Load a script once consent has been provided either through a resolvable `consent` or calling the `accept` method.
|
|
10
10
|
* @param options
|
|
11
11
|
*/
|
|
12
|
-
export declare function
|
|
12
|
+
export declare function useScriptTriggerConsent(options?: ConsentScriptTriggerOptions): UseConsentScriptTriggerApi;
|
|
13
13
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isRef, onNuxtReady, ref, requestIdleCallback, toValue, tryUseNuxtApp, watch } from "#imports";
|
|
2
|
-
export function
|
|
2
|
+
export function useScriptTriggerConsent(options) {
|
|
3
3
|
if (import.meta.server)
|
|
4
4
|
return new Promise(() => {
|
|
5
5
|
});
|
package/dist/runtime/composables/{useElementScriptTrigger.d.ts → useScriptTriggerElement.d.ts}
RENAMED
|
@@ -14,4 +14,4 @@ export interface ElementScriptTriggerOptions {
|
|
|
14
14
|
/**
|
|
15
15
|
* Create a trigger for an element to load a script based on specific element events.
|
|
16
16
|
*/
|
|
17
|
-
export declare function
|
|
17
|
+
export declare function useScriptTriggerElement(options: ElementScriptTriggerOptions): Promise<void>;
|
|
@@ -22,20 +22,21 @@ function useElementVisibilityPromise(element) {
|
|
|
22
22
|
observer.stop();
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
|
-
export function
|
|
25
|
+
export function useScriptTriggerElement(options) {
|
|
26
26
|
const { el, trigger } = options;
|
|
27
27
|
if (import.meta.server || !el)
|
|
28
28
|
return new Promise(() => {
|
|
29
29
|
});
|
|
30
|
-
|
|
30
|
+
const triggers = (Array.isArray(options.trigger) ? options.trigger : [options.trigger]).filter(Boolean);
|
|
31
|
+
if (el && triggers.some((t) => ["visibility", "visible"].includes(t)))
|
|
31
32
|
return useElementVisibilityPromise(el);
|
|
32
33
|
if (!trigger)
|
|
33
34
|
return Promise.resolve();
|
|
34
|
-
if (
|
|
35
|
+
if (!triggers.includes("immediate")) {
|
|
35
36
|
return new Promise((resolve) => {
|
|
36
37
|
const _ = useEventListener(
|
|
37
38
|
typeof el !== "undefined" ? el : document.body,
|
|
38
|
-
|
|
39
|
+
triggers,
|
|
39
40
|
() => {
|
|
40
41
|
resolve();
|
|
41
42
|
_();
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { RegistryScriptInput } from '#nuxt-scripts';
|
|
2
|
+
export declare const CrispOptions: import("valibot").ObjectSchema<{
|
|
3
|
+
/**
|
|
4
|
+
* The Crisp ID.
|
|
5
|
+
*/
|
|
6
|
+
readonly id: import("valibot").StringSchema<undefined>;
|
|
7
|
+
/**
|
|
8
|
+
* Extra configuration options. Used to configure the locale.
|
|
9
|
+
* Same as CRISP_RUNTIME_CONFIG.
|
|
10
|
+
* @see https://docs.crisp.chat/guides/chatbox-sdks/web-sdk/language-customization/
|
|
11
|
+
*/
|
|
12
|
+
readonly runtimeConfig: import("valibot").OptionalSchema<import("valibot").ObjectSchema<{
|
|
13
|
+
readonly locale: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, never>;
|
|
14
|
+
}, undefined>, never>;
|
|
15
|
+
/**
|
|
16
|
+
* Associated a session, equivalent to using CRISP_TOKEN_ID variable.
|
|
17
|
+
* Same as CRISP_TOKEN_ID.
|
|
18
|
+
* @see https://docs.crisp.chat/guides/chatbox-sdks/web-sdk/session-continuity/
|
|
19
|
+
*/
|
|
20
|
+
readonly tokenId: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, never>;
|
|
21
|
+
/**
|
|
22
|
+
* Restrict the domain that the Crisp cookie is set on.
|
|
23
|
+
* Same as CRISP_COOKIE_DOMAIN.
|
|
24
|
+
* @see https://docs.crisp.chat/guides/chatbox-sdks/web-sdk/cookie-policies/
|
|
25
|
+
*/
|
|
26
|
+
readonly cookieDomain: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, never>;
|
|
27
|
+
/**
|
|
28
|
+
* The cookie expiry in seconds.
|
|
29
|
+
* Same as CRISP_COOKIE_EXPIRATION.
|
|
30
|
+
* @see https://docs.crisp.chat/guides/chatbox-sdks/web-sdk/cookie-policies/#change-cookie-expiration-date
|
|
31
|
+
*/
|
|
32
|
+
readonly cookieExpiry: import("valibot").OptionalSchema<import("valibot").NumberSchema<undefined>, never>;
|
|
33
|
+
}, undefined>;
|
|
34
|
+
export type CrispInput = RegistryScriptInput<typeof CrispOptions, false>;
|
|
35
|
+
export interface CrispApi {
|
|
36
|
+
push: (...args: any[]) => void;
|
|
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;
|
|
38
|
+
set: (name: 'message:text' | 'session:data' | 'session:segments' | 'session:event' | 'user:email' | 'user:phone' | 'user:nickname' | 'user:avatar' | 'user:company' | string, value: any) => void;
|
|
39
|
+
get: (name: 'chat:unread:count' | 'message:text' | 'session:identifier' | 'session:data' | 'user:email' | 'user:phone' | 'user:nickname' | 'user:avatar' | 'user:company' | string) => any;
|
|
40
|
+
do: (name: 'chat:open' | 'chat:close' | 'chat:toggle' | 'chat:show' | 'chat:hide' | 'helpdesk:search' | 'helpdesk:article:open' | 'helpdesk:query' | 'overlay:open' | 'overlay:close' | 'message:send' | 'message:show' | 'message:read' | 'message:thread:start' | 'message:thread:end' | 'session:reset' | 'trigger:run' | string, arg2?: any) => any;
|
|
41
|
+
on: (name: 'session:loaded' | 'chat:initiated' | 'chat:opened' | 'chat:closed' | 'message:sent' | 'message:received' | 'message:compose:sent' | 'message:compose:received' | 'user:email:changed' | 'user:phone:changed' | 'user:nickname:changed' | 'user:avatar:changed' | 'website:availability:changed' | 'helpdesk:queried' | string, callback: (...args: any[]) => any) => void;
|
|
42
|
+
off: (name: 'session:loaded' | 'chat:initiated' | 'chat:opened' | 'chat:closed' | 'message:sent' | 'message:received' | 'message:compose:sent' | 'message:compose:received' | 'user:email:changed' | 'user:phone:changed' | 'user:nickname:changed' | 'user:avatar:changed' | 'website:availability:changed' | 'helpdesk:queried' | string, callback: (...args: any[]) => any) => void;
|
|
43
|
+
config: (options: any) => void;
|
|
44
|
+
help: () => void;
|
|
45
|
+
[key: string]: any;
|
|
46
|
+
}
|
|
47
|
+
declare global {
|
|
48
|
+
interface Window {
|
|
49
|
+
CRISP_READY_TRIGGER: () => void;
|
|
50
|
+
CRISP_WEBSITE_ID: string;
|
|
51
|
+
CRISP_RUNTIME_CONFIG?: {
|
|
52
|
+
locale?: string;
|
|
53
|
+
};
|
|
54
|
+
CRISP_COOKIE_DOMAIN?: string;
|
|
55
|
+
CRISP_COOKIE_EXPIRATION?: number;
|
|
56
|
+
CRISP_TOKEN_ID?: string;
|
|
57
|
+
$crisp: CrispApi;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
export declare function useScriptCrisp<T extends CrispApi>(_options?: CrispInput): T & {
|
|
61
|
+
$script: Promise<T> & import("@unhead/vue").VueScriptInstance<T>;
|
|
62
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { useRegistryScript } from "../utils.js";
|
|
2
|
+
import { object, string, optional, number } from "#nuxt-scripts-validator";
|
|
3
|
+
export const CrispOptions = object({
|
|
4
|
+
/**
|
|
5
|
+
* The Crisp ID.
|
|
6
|
+
*/
|
|
7
|
+
id: string(),
|
|
8
|
+
/**
|
|
9
|
+
* Extra configuration options. Used to configure the locale.
|
|
10
|
+
* Same as CRISP_RUNTIME_CONFIG.
|
|
11
|
+
* @see https://docs.crisp.chat/guides/chatbox-sdks/web-sdk/language-customization/
|
|
12
|
+
*/
|
|
13
|
+
runtimeConfig: optional(object({
|
|
14
|
+
locale: optional(string())
|
|
15
|
+
})),
|
|
16
|
+
/**
|
|
17
|
+
* Associated a session, equivalent to using CRISP_TOKEN_ID variable.
|
|
18
|
+
* Same as CRISP_TOKEN_ID.
|
|
19
|
+
* @see https://docs.crisp.chat/guides/chatbox-sdks/web-sdk/session-continuity/
|
|
20
|
+
*/
|
|
21
|
+
tokenId: optional(string()),
|
|
22
|
+
/**
|
|
23
|
+
* Restrict the domain that the Crisp cookie is set on.
|
|
24
|
+
* Same as CRISP_COOKIE_DOMAIN.
|
|
25
|
+
* @see https://docs.crisp.chat/guides/chatbox-sdks/web-sdk/cookie-policies/
|
|
26
|
+
*/
|
|
27
|
+
cookieDomain: optional(string()),
|
|
28
|
+
/**
|
|
29
|
+
* The cookie expiry in seconds.
|
|
30
|
+
* Same as CRISP_COOKIE_EXPIRATION.
|
|
31
|
+
* @see https://docs.crisp.chat/guides/chatbox-sdks/web-sdk/cookie-policies/#change-cookie-expiration-date
|
|
32
|
+
*/
|
|
33
|
+
cookieExpiry: optional(number())
|
|
34
|
+
});
|
|
35
|
+
export function useScriptCrisp(_options) {
|
|
36
|
+
let readyPromise = Promise.resolve();
|
|
37
|
+
return useRegistryScript("crisp", (options) => ({
|
|
38
|
+
scriptInput: {
|
|
39
|
+
src: "https://client.crisp.chat/l.js"
|
|
40
|
+
// can't be bundled
|
|
41
|
+
},
|
|
42
|
+
schema: import.meta.dev ? CrispOptions : void 0,
|
|
43
|
+
scriptOptions: {
|
|
44
|
+
use() {
|
|
45
|
+
const wrapFn = (fn) => window.$crisp?.[fn] || ((...args) => {
|
|
46
|
+
readyPromise.then(() => window.$crisp[fn](...args));
|
|
47
|
+
});
|
|
48
|
+
return {
|
|
49
|
+
push: window.$crisp.push,
|
|
50
|
+
do: wrapFn("do"),
|
|
51
|
+
set: wrapFn("set"),
|
|
52
|
+
get: wrapFn("get"),
|
|
53
|
+
on: wrapFn("on"),
|
|
54
|
+
off: wrapFn("off"),
|
|
55
|
+
config: wrapFn("config"),
|
|
56
|
+
help: wrapFn("help")
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
clientInit: import.meta.server ? void 0 : () => {
|
|
61
|
+
window.$crisp = [];
|
|
62
|
+
window.CRISP_WEBSITE_ID = options.id;
|
|
63
|
+
if (options.runtimeConfig?.locale)
|
|
64
|
+
window.CRISP_RUNTIME_CONFIG = { locale: options.runtimeConfig.locale };
|
|
65
|
+
if (options.cookieDomain)
|
|
66
|
+
window.CRISP_COOKIE_DOMAIN = options.cookieDomain;
|
|
67
|
+
if (options.cookieExpiry)
|
|
68
|
+
window.CRISP_COOKIE_EXPIRATION = options.cookieExpiry;
|
|
69
|
+
if (options.tokenId)
|
|
70
|
+
window.CRISP_TOKEN_ID = options.tokenId;
|
|
71
|
+
readyPromise = new Promise((resolve) => {
|
|
72
|
+
window.CRISP_READY_TRIGGER = resolve;
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}), _options);
|
|
76
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { InferInput } from '#nuxt-scripts-validator';
|
|
2
2
|
import type { RegistryScriptInput } from '#nuxt-scripts';
|
|
3
3
|
export declare const IntercomOptions: import("valibot").ObjectSchema<{
|
|
4
4
|
readonly app_id: import("valibot").StringSchema<undefined>;
|
|
@@ -1,23 +1,30 @@
|
|
|
1
1
|
import type { RegistryScriptInput } from '#nuxt-scripts';
|
|
2
2
|
export type LemonSqueezyInput = RegistryScriptInput;
|
|
3
|
+
export type LemonSqueezyEventPayload = {
|
|
4
|
+
event: 'Checkout.Success';
|
|
5
|
+
data: Record<string, any>;
|
|
6
|
+
} & {
|
|
7
|
+
event: 'Checkout.ViewCart';
|
|
8
|
+
data: Record<string, any>;
|
|
9
|
+
} & {
|
|
10
|
+
event: 'GA.ViewCart';
|
|
11
|
+
data: Record<string, any>;
|
|
12
|
+
} & {
|
|
13
|
+
event: 'PaymentMethodUpdate.Mounted';
|
|
14
|
+
} & {
|
|
15
|
+
event: 'PaymentMethodUpdate.Closed';
|
|
16
|
+
} & {
|
|
17
|
+
event: 'PaymentMethodUpdate.Updated';
|
|
18
|
+
} & {
|
|
19
|
+
event: string;
|
|
20
|
+
};
|
|
3
21
|
export interface LemonSqueezyApi {
|
|
4
22
|
/**
|
|
5
23
|
* Initialises Lemon.js on your page.
|
|
6
24
|
* @param options - An object with a single property, eventHandler, which is a function that will be called when Lemon.js emits an event.
|
|
7
25
|
*/
|
|
8
26
|
Setup: (options: {
|
|
9
|
-
eventHandler: (event:
|
|
10
|
-
event: 'Checkout.Success';
|
|
11
|
-
data: Record<string, any>;
|
|
12
|
-
} & {
|
|
13
|
-
event: 'PaymentMethodUpdate.Mounted';
|
|
14
|
-
} & {
|
|
15
|
-
event: 'PaymentMethodUpdate.Closed';
|
|
16
|
-
} & {
|
|
17
|
-
event: 'PaymentMethodUpdate.Updated';
|
|
18
|
-
} & {
|
|
19
|
-
event: string;
|
|
20
|
-
}) => void;
|
|
27
|
+
eventHandler: (event: LemonSqueezyEventPayload) => void;
|
|
21
28
|
}) => void;
|
|
22
29
|
/**
|
|
23
30
|
* Refreshes `lemonsqueezy-button` listeners on the page.
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="stripe-v3" />
|
|
2
1
|
import type { RegistryScriptInput } from '#nuxt-scripts';
|
|
3
2
|
export declare const StripeOptions: import("valibot").ObjectSchema<{
|
|
4
3
|
readonly advancedFraudSignals: import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, never>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type Vimeo from '
|
|
1
|
+
import type Vimeo from '@vimeo/player';
|
|
2
2
|
import type { RegistryScriptInput } from '#nuxt-scripts';
|
|
3
3
|
type Constructor<T extends new (...args: any) => any> = T extends new (...args: infer A) => infer R ? new (...args: A) => R : never;
|
|
4
4
|
export interface VimeoPlayerApi {
|