@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.
Files changed (50) hide show
  1. package/README.md +73 -73
  2. package/dist/client/200.html +9 -9
  3. package/dist/client/404.html +9 -9
  4. package/dist/client/_nuxt/BA8oXX6l.js +31 -0
  5. package/dist/client/_nuxt/{zTM8DS5E.js → D3k5CjNA.js} +1 -1
  6. package/dist/client/_nuxt/{Cg8NGlPg.js → D6UD5WyS.js} +1 -1
  7. package/dist/client/_nuxt/{DZ6siU6J.js → D9Ze639F.js} +1 -1
  8. package/dist/client/_nuxt/builds/latest.json +1 -1
  9. package/dist/client/_nuxt/builds/meta/a5c6ec68-62ae-43af-96d0-bdd9f64f38b1.json +1 -0
  10. package/dist/client/_nuxt/entry.Cts5wDvr.css +1 -0
  11. package/dist/client/_nuxt/error-404.-RjlvToe.css +1 -0
  12. package/dist/client/_nuxt/error-500.Bz7LXgZy.css +1 -0
  13. package/dist/client/index.html +9 -9
  14. package/dist/module.json +1 -1
  15. package/dist/module.mjs +84 -279
  16. package/dist/registry.mjs +33 -0
  17. package/dist/runtime/components/ScriptCarbonAds.vue +71 -71
  18. package/dist/runtime/components/ScriptCrisp.vue +84 -84
  19. package/dist/runtime/components/ScriptGoogleAdsense.vue +69 -69
  20. package/dist/runtime/components/ScriptGoogleMaps.vue +265 -265
  21. package/dist/runtime/components/ScriptIntercom.vue +93 -93
  22. package/dist/runtime/components/ScriptLemonSqueezy.vue +45 -45
  23. package/dist/runtime/components/ScriptLoadingIndicator.vue +22 -22
  24. package/dist/runtime/components/ScriptStripePricingTable.vue +68 -68
  25. package/dist/runtime/components/ScriptVimeoPlayer.vue +256 -256
  26. package/dist/runtime/components/ScriptYouTubePlayer.vue +171 -170
  27. package/dist/runtime/composables/useScript.js +3 -3
  28. package/dist/runtime/composables/useScriptEventPage.d.ts +1 -1
  29. package/dist/runtime/registry/crisp.d.ts +1 -1
  30. package/dist/runtime/registry/fathom-analytics.d.ts +1 -1
  31. package/dist/runtime/registry/google-adsense.d.ts +1 -1
  32. package/dist/runtime/registry/google-analytics.d.ts +19 -0
  33. package/dist/runtime/registry/google-analytics.js +40 -0
  34. package/dist/runtime/registry/google-tag-manager.d.ts +23 -0
  35. package/dist/runtime/registry/google-tag-manager.js +33 -0
  36. package/dist/runtime/registry/hotjar.d.ts +1 -1
  37. package/dist/runtime/registry/intercom.d.ts +1 -1
  38. package/dist/runtime/registry/matomo-analytics.d.ts +1 -1
  39. package/dist/runtime/registry/meta-pixel.d.ts +1 -1
  40. package/dist/runtime/registry/npm.d.ts +1 -1
  41. package/dist/runtime/registry/x-pixel.d.ts +1 -1
  42. package/dist/runtime/types.d.ts +41 -9
  43. package/dist/runtime/utils.d.ts +1 -1
  44. package/dist/runtime/utils.js +20 -4
  45. package/package.json +12 -11
  46. package/dist/client/_nuxt/BeuDC-PU.js +0 -31
  47. package/dist/client/_nuxt/builds/meta/9996546f-d612-4447-9ee7-fc387b136ee4.json +0 -1
  48. package/dist/client/_nuxt/entry.DvGwvmL9.css +0 -1
  49. package/dist/client/_nuxt/error-404.DXyehy0d.css +0 -1
  50. package/dist/client/_nuxt/error-500.a_92Fvyl.css +0 -1
@@ -1,71 +1,71 @@
1
- <script setup lang="ts">
2
- import { withQuery } from 'ufo'
3
- import { useScriptTriggerElement } from '../composables/useScriptTriggerElement'
4
- import { onBeforeUnmount, onMounted, ref } from '#imports'
5
- import type { ElementScriptTrigger } from '#nuxt-scripts'
6
-
7
- const props = defineProps<{
8
- serve: string
9
- placement: string
10
- /**
11
- * Defines the trigger event to load the script.
12
- */
13
- trigger?: ElementScriptTrigger
14
- }>()
15
-
16
- const emit = defineEmits<{
17
- error: [error: string | Event]
18
- ready: [HTMLScriptElement]
19
- }>()
20
-
21
- const attrId = `_carbonads_js`
22
- const carbonadsEl = ref<HTMLElement | null>(import.meta.client ? document.getElementById(attrId) : null)
23
- // syncs to useScript status
24
- const status = ref('awaitingLoad')
25
-
26
- function loadCarbon() {
27
- if (!carbonadsEl.value) {
28
- return
29
- }
30
- status.value = 'loading'
31
- const script = document.createElement('script')
32
- script.setAttribute('type', 'text/javascript')
33
- script.setAttribute('src', withQuery('https://cdn.carbonads.com/carbon.js', {
34
- serve: props.serve,
35
- placement: props.placement,
36
- }))
37
- script.setAttribute('id', attrId)
38
- script.onerror = (err) => {
39
- status.value = 'error'
40
- emit('error', err)
41
- }
42
- script.onload = () => {
43
- status.value = 'loaded'
44
- emit('ready', script)
45
- }
46
- carbonadsEl.value.appendChild(script)
47
- }
48
-
49
- onMounted(() => {
50
- if (!props.trigger) {
51
- loadCarbon()
52
- }
53
- else {
54
- useScriptTriggerElement({ trigger: props.trigger, el: carbonadsEl })
55
- }
56
- })
57
-
58
- onBeforeUnmount(() => {
59
- if (carbonadsEl.value) {
60
- carbonadsEl.value.remove()
61
- }
62
- })
63
- </script>
64
-
65
- <template>
66
- <div ref="carbonadsEl">
67
- <slot v-if="status === 'awaitingLoad'" name="awaitingLoad" />
68
- <slot v-else-if="status === 'loading'" name="loading" />
69
- <slot v-else-if="status === 'error'" name="error" />
70
- </div>
71
- </template>
1
+ <script setup lang="ts">
2
+ import { withQuery } from 'ufo'
3
+ import { useScriptTriggerElement } from '../composables/useScriptTriggerElement'
4
+ import { onBeforeUnmount, onMounted, ref } from '#imports'
5
+ import type { ElementScriptTrigger } from '#nuxt-scripts'
6
+
7
+ const props = defineProps<{
8
+ serve: string
9
+ placement: string
10
+ /**
11
+ * Defines the trigger event to load the script.
12
+ */
13
+ trigger?: ElementScriptTrigger
14
+ }>()
15
+
16
+ const emit = defineEmits<{
17
+ error: [error: string | Event]
18
+ ready: [HTMLScriptElement]
19
+ }>()
20
+
21
+ const attrId = `_carbonads_js`
22
+ const carbonadsEl = ref<HTMLElement | null>(import.meta.client ? document.getElementById(attrId) : null)
23
+ // syncs to useScript status
24
+ const status = ref('awaitingLoad')
25
+
26
+ function loadCarbon() {
27
+ if (!carbonadsEl.value) {
28
+ return
29
+ }
30
+ status.value = 'loading'
31
+ const script = document.createElement('script')
32
+ script.setAttribute('type', 'text/javascript')
33
+ script.setAttribute('src', withQuery('https://cdn.carbonads.com/carbon.js', {
34
+ serve: props.serve,
35
+ placement: props.placement,
36
+ }))
37
+ script.setAttribute('id', attrId)
38
+ script.onerror = (err) => {
39
+ status.value = 'error'
40
+ emit('error', err)
41
+ }
42
+ script.onload = () => {
43
+ status.value = 'loaded'
44
+ emit('ready', script)
45
+ }
46
+ carbonadsEl.value.appendChild(script)
47
+ }
48
+
49
+ onMounted(() => {
50
+ if (!props.trigger) {
51
+ loadCarbon()
52
+ }
53
+ else {
54
+ useScriptTriggerElement({ trigger: props.trigger, el: carbonadsEl })
55
+ }
56
+ })
57
+
58
+ onBeforeUnmount(() => {
59
+ if (carbonadsEl.value) {
60
+ carbonadsEl.value.remove()
61
+ }
62
+ })
63
+ </script>
64
+
65
+ <template>
66
+ <div ref="carbonadsEl">
67
+ <slot v-if="status === 'awaitingLoad'" name="awaitingLoad" />
68
+ <slot v-else-if="status === 'loading'" name="loading" />
69
+ <slot v-else-if="status === 'error'" name="error" />
70
+ </div>
71
+ </template>
@@ -1,84 +1,84 @@
1
- <script setup lang="ts">
2
- import { useScriptTriggerElement } from '../composables/useScriptTriggerElement'
3
- import { useScriptCrisp } from '../registry/crisp'
4
- import { ref, onMounted, onBeforeUnmount, watch } from '#imports'
5
- import type { ElementScriptTrigger } from '#nuxt-scripts'
6
-
7
- const props = withDefaults(defineProps<{
8
- /**
9
- * Defines the trigger event to load the script.
10
- */
11
- trigger?: ElementScriptTrigger
12
- id: string
13
- runtimeConfig?: {
14
- locale: string
15
- }
16
- tokenId?: string
17
- cookieDomain?: string
18
- cookieExpiry?: number
19
- }>(), {
20
- trigger: 'click',
21
- })
22
-
23
- const emits = defineEmits<{
24
- // our emit
25
- ready: [e: ReturnType<typeof useScriptCrisp>]
26
- error: []
27
- }>()
28
-
29
- const rootEl = ref(null)
30
- const trigger = useScriptTriggerElement({ trigger: props.trigger, el: rootEl })
31
-
32
- const isReady = ref(false)
33
- const crisp = useScriptCrisp({
34
- id: props.id,
35
- runtimeConfig: props.runtimeConfig,
36
- tokenId: props.tokenId,
37
- cookieDomain: props.cookieDomain,
38
- cookieExpiry: props.cookieExpiry,
39
- scriptOptions: {
40
- trigger,
41
- },
42
- })
43
- if (props.trigger === 'click')
44
- crisp.do('chat:open')
45
- const { $script } = crisp
46
-
47
- defineExpose({
48
- crisp,
49
- })
50
-
51
- let observer: MutationObserver
52
- onMounted(() => {
53
- watch($script.status, (status) => {
54
- if (status === 'loaded') {
55
- observer = new MutationObserver(() => {
56
- if (document.getElementById('crisp-chatbox')) {
57
- isReady.value = true
58
- emits('ready', crisp)
59
- observer.disconnect()
60
- }
61
- })
62
- observer.observe(document.body, { childList: true, subtree: true })
63
- }
64
- else if (status === 'error') {
65
- emits('error')
66
- }
67
- })
68
- })
69
- onBeforeUnmount(() => {
70
- observer?.disconnect()
71
- })
72
- </script>
73
-
74
- <template>
75
- <div
76
- ref="rootEl"
77
- :style="{ display: isReady ? 'none' : 'block' }"
78
- >
79
- <slot :ready="isReady" />
80
- <slot v-if="$script.status.value === 'awaitingLoad'" name="awaitingLoad" />
81
- <slot v-else-if="$script.status.value === 'loading' || !isReady" name="loading" />
82
- <slot v-else-if="$script.status.value === 'error'" name="error" />
83
- </div>
84
- </template>
1
+ <script setup lang="ts">
2
+ import { useScriptTriggerElement } from '../composables/useScriptTriggerElement'
3
+ import { useScriptCrisp } from '../registry/crisp'
4
+ import { ref, onMounted, onBeforeUnmount, watch } from '#imports'
5
+ import type { ElementScriptTrigger } from '#nuxt-scripts'
6
+
7
+ const props = withDefaults(defineProps<{
8
+ /**
9
+ * Defines the trigger event to load the script.
10
+ */
11
+ trigger?: ElementScriptTrigger
12
+ id: string
13
+ runtimeConfig?: {
14
+ locale: string
15
+ }
16
+ tokenId?: string
17
+ cookieDomain?: string
18
+ cookieExpiry?: number
19
+ }>(), {
20
+ trigger: 'click',
21
+ })
22
+
23
+ const emits = defineEmits<{
24
+ // our emit
25
+ ready: [e: ReturnType<typeof useScriptCrisp>]
26
+ error: []
27
+ }>()
28
+
29
+ const rootEl = ref(null)
30
+ const trigger = useScriptTriggerElement({ trigger: props.trigger, el: rootEl })
31
+
32
+ const isReady = ref(false)
33
+ const crisp = useScriptCrisp({
34
+ id: props.id,
35
+ runtimeConfig: props.runtimeConfig,
36
+ tokenId: props.tokenId,
37
+ cookieDomain: props.cookieDomain,
38
+ cookieExpiry: props.cookieExpiry,
39
+ scriptOptions: {
40
+ trigger,
41
+ },
42
+ })
43
+ if (props.trigger === 'click')
44
+ crisp.do('chat:open')
45
+ const { $script } = crisp
46
+
47
+ defineExpose({
48
+ crisp,
49
+ })
50
+
51
+ let observer: MutationObserver
52
+ onMounted(() => {
53
+ watch($script.status, (status) => {
54
+ if (status === 'loaded') {
55
+ observer = new MutationObserver(() => {
56
+ if (document.getElementById('crisp-chatbox')) {
57
+ isReady.value = true
58
+ emits('ready', crisp)
59
+ observer.disconnect()
60
+ }
61
+ })
62
+ observer.observe(document.body, { childList: true, subtree: true })
63
+ }
64
+ else if (status === 'error') {
65
+ emits('error')
66
+ }
67
+ })
68
+ })
69
+ onBeforeUnmount(() => {
70
+ observer?.disconnect()
71
+ })
72
+ </script>
73
+
74
+ <template>
75
+ <div
76
+ ref="rootEl"
77
+ :style="{ display: isReady ? 'none' : 'block' }"
78
+ >
79
+ <slot :ready="isReady" />
80
+ <slot v-if="$script.status.value === 'awaitingLoad'" name="awaitingLoad" />
81
+ <slot v-else-if="$script.status.value === 'loading' || !isReady" name="loading" />
82
+ <slot v-else-if="$script.status.value === 'error'" name="error" />
83
+ </div>
84
+ </template>
@@ -1,69 +1,69 @@
1
- <script setup lang="ts">
2
- import { useScriptTriggerElement } from '../composables/useScriptTriggerElement'
3
- import { useScriptGoogleAdsense } from '../registry/google-adsense'
4
- import { callOnce, onMounted, ref, watch } from '#imports'
5
- import type { ElementScriptTrigger } from '#nuxt-scripts'
6
-
7
- const props = withDefaults(defineProps<{
8
- dataAdClient: string
9
- dataAdSlot: string
10
- dataAdFormat?: 'auto'
11
- dataFullWidthResponsive?: boolean
12
- /**
13
- * Defines the trigger event to load the script.
14
- */
15
- trigger?: ElementScriptTrigger
16
- }>(), {
17
- dataAdFormat: 'auto',
18
- dataFullWidthResponsive: true,
19
- })
20
-
21
- const emits = defineEmits<{
22
- // our emit
23
- ready: [e: ReturnType<typeof useScriptGoogleAdsense>]
24
- error: []
25
- }>()
26
-
27
- const rootEl = ref(null)
28
- const trigger = useScriptTriggerElement({ trigger: props.trigger, el: rootEl })
29
-
30
- const instance = useScriptGoogleAdsense({
31
- client: props.dataAdClient,
32
- scriptOptions: {
33
- trigger,
34
- },
35
- })
36
-
37
- const { $script } = instance
38
-
39
- onMounted(() => {
40
- callOnce(() => {
41
- (window.adsbygoogle = window.adsbygoogle || []).push({})
42
- })
43
- watch(instance.$script.status, () => {
44
- if (instance.$script.status.value === 'loaded') {
45
- emits('ready', instance)
46
- }
47
- else if (instance.$script.status.value === 'error') {
48
- emits('error')
49
- }
50
- })
51
- })
52
- </script>
53
-
54
- <template>
55
- <ins
56
- ref="rootEl"
57
- class="adsbygoogle"
58
- style="display: block;"
59
- :data-ad-client="dataAdClient"
60
- :data-ad-slot="dataAdSlot"
61
- :data-ad-format="dataAdFormat"
62
- :data-full-width-responsive="dataFullWidthResponsive"
63
- v-bind="{ ...$attrs }"
64
- >
65
- <slot v-if="$script.status.value === 'awaitingLoad'" name="awaitingLoad" />
66
- <slot v-else-if="$script.status.value === 'loading'" name="loading" />
67
- <slot v-else-if="$script.status.value === 'error'" name="error" />
68
- </ins>
69
- </template>
1
+ <script setup lang="ts">
2
+ import { useScriptTriggerElement } from '../composables/useScriptTriggerElement'
3
+ import { useScriptGoogleAdsense } from '../registry/google-adsense'
4
+ import { callOnce, onMounted, ref, watch } from '#imports'
5
+ import type { ElementScriptTrigger } from '#nuxt-scripts'
6
+
7
+ const props = withDefaults(defineProps<{
8
+ dataAdClient: string
9
+ dataAdSlot: string
10
+ dataAdFormat?: 'auto'
11
+ dataFullWidthResponsive?: boolean
12
+ /**
13
+ * Defines the trigger event to load the script.
14
+ */
15
+ trigger?: ElementScriptTrigger
16
+ }>(), {
17
+ dataAdFormat: 'auto',
18
+ dataFullWidthResponsive: true,
19
+ })
20
+
21
+ const emits = defineEmits<{
22
+ // our emit
23
+ ready: [e: ReturnType<typeof useScriptGoogleAdsense>]
24
+ error: []
25
+ }>()
26
+
27
+ const rootEl = ref(null)
28
+ const trigger = useScriptTriggerElement({ trigger: props.trigger, el: rootEl })
29
+
30
+ const instance = useScriptGoogleAdsense({
31
+ client: props.dataAdClient,
32
+ scriptOptions: {
33
+ trigger,
34
+ },
35
+ })
36
+
37
+ const { $script } = instance
38
+
39
+ onMounted(() => {
40
+ callOnce(() => {
41
+ (window.adsbygoogle = window.adsbygoogle || []).push({})
42
+ })
43
+ watch(instance.$script.status, () => {
44
+ if (instance.$script.status.value === 'loaded') {
45
+ emits('ready', instance)
46
+ }
47
+ else if (instance.$script.status.value === 'error') {
48
+ emits('error')
49
+ }
50
+ })
51
+ })
52
+ </script>
53
+
54
+ <template>
55
+ <ins
56
+ ref="rootEl"
57
+ class="adsbygoogle"
58
+ style="display: block;"
59
+ :data-ad-client="dataAdClient"
60
+ :data-ad-slot="dataAdSlot"
61
+ :data-ad-format="dataAdFormat"
62
+ :data-full-width-responsive="dataFullWidthResponsive"
63
+ v-bind="{ ...$attrs }"
64
+ >
65
+ <slot v-if="$script.status.value === 'awaitingLoad'" name="awaitingLoad" />
66
+ <slot v-else-if="$script.status.value === 'loading'" name="loading" />
67
+ <slot v-else-if="$script.status.value === 'error'" name="error" />
68
+ </ins>
69
+ </template>