@nuxt/scripts 0.11.13 → 0.12.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/dist/client/200.html +1 -1
- package/dist/client/404.html +1 -1
- package/dist/client/_nuxt/B1l158TM.js +179 -0
- package/dist/client/_nuxt/CEpyMuZa.js +1 -0
- package/dist/client/_nuxt/CVO1_9PV.js +1 -0
- package/dist/client/_nuxt/Cp-IABpG.js +1 -0
- package/dist/client/_nuxt/D0r3Knsf.js +1 -0
- package/dist/client/_nuxt/DlfHMoPT.js +1 -0
- package/dist/client/_nuxt/DyLGGY9L.js +1 -0
- package/dist/client/_nuxt/builds/latest.json +1 -1
- package/dist/client/_nuxt/builds/meta/ab2a05b7-9c93-484e-ae04-bd1f39e5f3c1.json +1 -0
- package/dist/client/_nuxt/entry.Bb8Z00UZ.css +1 -0
- package/dist/client/_nuxt/error-404.pWWosX5v.css +1 -0
- package/dist/client/_nuxt/error-500.DHpVpAn4.css +1 -0
- package/dist/client/_nuxt/n57rOy2v.js +1 -0
- package/dist/client/index.html +1 -1
- package/dist/module.d.mts +6 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +167 -42
- package/dist/registry.mjs +30 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.d.vue.ts +0 -0
- package/dist/runtime/components/{ScriptGoogleMaps.vue → GoogleMaps/ScriptGoogleMaps.vue} +17 -13
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.vue.d.ts +0 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsAdvancedMarkerElement.d.vue.ts +61 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsAdvancedMarkerElement.vue +86 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsAdvancedMarkerElement.vue.d.ts +61 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsCircle.d.vue.ts +33 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsCircle.vue +62 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsCircle.vue.d.ts +33 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsHeatmapLayer.d.vue.ts +5 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsHeatmapLayer.vue +32 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsHeatmapLayer.vue.d.ts +5 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsInfoWindow.d.vue.ts +35 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsInfoWindow.vue +88 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsInfoWindow.vue.d.ts +35 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarker.d.vue.ts +61 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarker.vue +85 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarker.vue.d.ts +61 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarkerClusterer.d.vue.ts +27 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarkerClusterer.vue +62 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarkerClusterer.vue.d.ts +27 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPinElement.d.vue.ts +5 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPinElement.vue +37 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPinElement.vue.d.ts +5 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolygon.d.vue.ts +29 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolygon.vue +60 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolygon.vue.d.ts +29 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolyline.d.vue.ts +29 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolyline.vue +60 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolyline.vue.d.ts +29 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsRectangle.d.vue.ts +31 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsRectangle.vue +61 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsRectangle.vue.d.ts +31 -0
- package/dist/runtime/components/ScriptAriaLoadingIndicator.d.vue.ts +2 -0
- package/dist/runtime/components/ScriptCarbonAds.d.vue.ts +32 -0
- package/dist/runtime/components/ScriptCrisp.d.vue.ts +44 -0
- package/dist/runtime/components/ScriptGoogleAdsense.d.vue.ts +37 -0
- package/dist/runtime/components/ScriptIntercom.d.vue.ts +45 -0
- package/dist/runtime/components/ScriptLemonSqueezy.d.vue.ts +24 -0
- package/dist/runtime/components/ScriptLoadingIndicator.d.vue.ts +9 -0
- package/dist/runtime/components/ScriptLoadingIndicator.vue.d.ts +1 -1
- package/dist/runtime/components/ScriptPayPalButtons.d.vue.ts +72 -0
- package/dist/runtime/components/ScriptPayPalButtons.vue +116 -0
- package/dist/runtime/components/ScriptPayPalButtons.vue.d.ts +72 -0
- package/dist/runtime/components/ScriptPayPalMarks.d.vue.ts +51 -0
- package/dist/runtime/components/ScriptPayPalMarks.vue +69 -0
- package/dist/runtime/components/ScriptPayPalMarks.vue.d.ts +51 -0
- package/dist/runtime/components/ScriptPayPalMessages.d.vue.ts +67 -0
- package/dist/runtime/components/ScriptPayPalMessages.vue +90 -0
- package/dist/runtime/components/ScriptPayPalMessages.vue.d.ts +67 -0
- package/dist/runtime/components/ScriptStripePricingTable.d.vue.ts +35 -0
- package/dist/runtime/components/ScriptStripePricingTable.vue +1 -1
- package/dist/runtime/components/ScriptVimeoPlayer.d.vue.ts +127 -0
- package/dist/runtime/components/ScriptVimeoPlayer.vue.d.ts +2 -2
- package/dist/runtime/components/ScriptYouTubePlayer.d.vue.ts +66 -0
- package/dist/runtime/composables/useScript.js +35 -2
- package/dist/runtime/composables/useScriptEventPage.js +6 -2
- package/dist/runtime/composables/useScriptTriggerIdleTimeout.d.ts +10 -0
- package/dist/runtime/composables/useScriptTriggerIdleTimeout.js +22 -0
- package/dist/runtime/composables/useScriptTriggerInteraction.d.ts +15 -0
- package/dist/runtime/composables/useScriptTriggerInteraction.js +35 -0
- package/dist/runtime/logger.d.ts +1 -0
- package/dist/runtime/logger.js +6 -0
- package/dist/runtime/registry/databuddy-analytics.d.ts +77 -0
- package/dist/runtime/registry/databuddy-analytics.js +103 -0
- package/dist/runtime/registry/google-analytics.d.ts +1 -1
- package/dist/runtime/registry/google-analytics.js +5 -5
- package/dist/runtime/registry/google-tag-manager.js +3 -5
- package/dist/runtime/registry/matomo-analytics.d.ts +1 -0
- package/dist/runtime/registry/matomo-analytics.js +27 -4
- package/dist/runtime/registry/paypal.d.ts +34 -0
- package/dist/runtime/registry/paypal.js +86 -0
- package/dist/runtime/registry/reddit-pixel.d.ts +18 -0
- package/dist/runtime/registry/reddit-pixel.js +36 -0
- package/dist/runtime/registry/stripe.d.ts +2 -2
- package/dist/runtime/registry/stripe.js +1 -1
- package/dist/runtime/types.d.ts +18 -7
- package/dist/runtime/utils.d.ts +5 -2
- package/dist/runtime/utils.js +49 -19
- package/package.json +26 -19
- package/dist/client/_nuxt/1mHV-1pA.js +0 -1
- package/dist/client/_nuxt/7VVldQq3.js +0 -1
- package/dist/client/_nuxt/CQGAJOTU.js +0 -21
- package/dist/client/_nuxt/CYHtqd0e.js +0 -1
- package/dist/client/_nuxt/builds/meta/8ed6dba0-c6c1-426f-804b-f7cbe9d62b69.json +0 -1
- package/dist/client/_nuxt/entry.tbizjOMR.css +0 -1
- package/dist/client/_nuxt/error-404.CDmSTChJ.css +0 -1
- package/dist/client/_nuxt/error-500.DpcyFY5F.css +0 -1
- package/dist/runtime/components/ScriptGoogleMaps.vue.d.ts +0 -145
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type HTMLAttributes, type ReservedProps } from 'vue';
|
|
2
|
+
import type { PayPalMarksComponentOptions } from '@paypal/paypal-js';
|
|
3
|
+
import type { ElementScriptTrigger } from '#nuxt-scripts/types';
|
|
4
|
+
import type { PayPalInput } from '../registry/paypal.js';
|
|
5
|
+
type __VLS_Props = {
|
|
6
|
+
/**
|
|
7
|
+
* Customize the root element attributes.
|
|
8
|
+
*/
|
|
9
|
+
rootAttrs?: HTMLAttributes & ReservedProps & Record<string, unknown>;
|
|
10
|
+
/**
|
|
11
|
+
* Defines the trigger event to load the script.
|
|
12
|
+
*/
|
|
13
|
+
trigger?: ElementScriptTrigger;
|
|
14
|
+
/**
|
|
15
|
+
* The client id for the paypal script.
|
|
16
|
+
*/
|
|
17
|
+
clientId?: string;
|
|
18
|
+
/**
|
|
19
|
+
* The options for the paypal marks.
|
|
20
|
+
*/
|
|
21
|
+
marksOptions?: PayPalMarksComponentOptions;
|
|
22
|
+
/**
|
|
23
|
+
* The paypal script options.
|
|
24
|
+
*/
|
|
25
|
+
paypalScriptOptions?: Partial<PayPalInput>;
|
|
26
|
+
};
|
|
27
|
+
declare var __VLS_1: {}, __VLS_3: {}, __VLS_10: {}, __VLS_12: {}, __VLS_14: {};
|
|
28
|
+
type __VLS_Slots = {} & {
|
|
29
|
+
placeholder?: (props: typeof __VLS_1) => any;
|
|
30
|
+
} & {
|
|
31
|
+
loading?: (props: typeof __VLS_3) => any;
|
|
32
|
+
} & {
|
|
33
|
+
awaitingLoad?: (props: typeof __VLS_10) => any;
|
|
34
|
+
} & {
|
|
35
|
+
error?: (props: typeof __VLS_12) => any;
|
|
36
|
+
} & {
|
|
37
|
+
default?: (props: typeof __VLS_14) => any;
|
|
38
|
+
};
|
|
39
|
+
declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
40
|
+
trigger: ElementScriptTrigger;
|
|
41
|
+
clientId: string;
|
|
42
|
+
paypalScriptOptions: Partial<PayPalInput>;
|
|
43
|
+
marksOptions: PayPalMarksComponentOptions;
|
|
44
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
45
|
+
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
46
|
+
export default _default;
|
|
47
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
48
|
+
new (): {
|
|
49
|
+
$slots: S;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { type HTMLAttributes, type ReservedProps } from 'vue';
|
|
2
|
+
import type { PayPalMessagesComponentOptions } from '@paypal/paypal-js';
|
|
3
|
+
import type { ElementScriptTrigger } from '#nuxt-scripts/types';
|
|
4
|
+
import type { PayPalInput } from '../registry/paypal.js';
|
|
5
|
+
type __VLS_Props = {
|
|
6
|
+
/**
|
|
7
|
+
* Customize the root element attributes.
|
|
8
|
+
*/
|
|
9
|
+
rootAttrs?: HTMLAttributes & ReservedProps & Record<string, unknown>;
|
|
10
|
+
/**
|
|
11
|
+
* Defines the trigger event to load the script.
|
|
12
|
+
*/
|
|
13
|
+
trigger?: ElementScriptTrigger;
|
|
14
|
+
/**
|
|
15
|
+
* The client id for the paypal script.
|
|
16
|
+
*/
|
|
17
|
+
clientId?: string;
|
|
18
|
+
/**
|
|
19
|
+
* The options for the paypal buttons.
|
|
20
|
+
*/
|
|
21
|
+
messagesOptions?: PayPalMessagesComponentOptions;
|
|
22
|
+
/**
|
|
23
|
+
* The merchant id for the paypal script.
|
|
24
|
+
*/
|
|
25
|
+
merchantId?: string;
|
|
26
|
+
/**
|
|
27
|
+
* The partner attribution id for the paypal script.
|
|
28
|
+
*/
|
|
29
|
+
partnerAttributionId?: string;
|
|
30
|
+
/**
|
|
31
|
+
* The options for the paypal scipt.
|
|
32
|
+
*/
|
|
33
|
+
paypalScriptOptions?: Partial<PayPalInput>;
|
|
34
|
+
};
|
|
35
|
+
declare var __VLS_1: {}, __VLS_3: {}, __VLS_10: {}, __VLS_12: {}, __VLS_14: {};
|
|
36
|
+
type __VLS_Slots = {} & {
|
|
37
|
+
placeholder?: (props: typeof __VLS_1) => any;
|
|
38
|
+
} & {
|
|
39
|
+
loading?: (props: typeof __VLS_3) => any;
|
|
40
|
+
} & {
|
|
41
|
+
awaitingLoad?: (props: typeof __VLS_10) => any;
|
|
42
|
+
} & {
|
|
43
|
+
error?: (props: typeof __VLS_12) => any;
|
|
44
|
+
} & {
|
|
45
|
+
default?: (props: typeof __VLS_14) => any;
|
|
46
|
+
};
|
|
47
|
+
declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
48
|
+
render: (data: Record<string, unknown>) => any;
|
|
49
|
+
apply: (data: Record<string, unknown>) => any;
|
|
50
|
+
clickMessages: (data: Record<string, unknown>) => any;
|
|
51
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
52
|
+
onRender?: ((data: Record<string, unknown>) => any) | undefined;
|
|
53
|
+
onApply?: ((data: Record<string, unknown>) => any) | undefined;
|
|
54
|
+
onClickMessages?: ((data: Record<string, unknown>) => any) | undefined;
|
|
55
|
+
}>, {
|
|
56
|
+
trigger: ElementScriptTrigger;
|
|
57
|
+
clientId: string;
|
|
58
|
+
paypalScriptOptions: Partial<PayPalInput>;
|
|
59
|
+
messagesOptions: PayPalMessagesComponentOptions;
|
|
60
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
61
|
+
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
62
|
+
export default _default;
|
|
63
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
64
|
+
new (): {
|
|
65
|
+
$slots: S;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed, onMounted, ref, shallowRef, watch } from "vue";
|
|
3
|
+
import { defu } from "defu";
|
|
4
|
+
import { useScriptPayPal } from "../registry/paypal";
|
|
5
|
+
import { useScriptTriggerElement } from "../composables/useScriptTriggerElement";
|
|
6
|
+
import { onBeforeUnmount, resolveComponent } from "vue";
|
|
7
|
+
const el = ref(null);
|
|
8
|
+
const rootEl = ref(null);
|
|
9
|
+
const props = defineProps({
|
|
10
|
+
rootAttrs: { type: Object, required: false },
|
|
11
|
+
trigger: { type: [String, Array, Boolean], required: false, default: "visible" },
|
|
12
|
+
clientId: { type: String, required: false, default: "test" },
|
|
13
|
+
messagesOptions: { type: Object, required: false, default: () => ({}) },
|
|
14
|
+
merchantId: { type: String, required: false },
|
|
15
|
+
partnerAttributionId: { type: String, required: false },
|
|
16
|
+
paypalScriptOptions: { type: Object, required: false, default: () => ({}) }
|
|
17
|
+
});
|
|
18
|
+
const ready = ref(false);
|
|
19
|
+
const { onLoaded, status } = useScriptPayPal({
|
|
20
|
+
clientId: props.clientId,
|
|
21
|
+
merchantId: props.merchantId,
|
|
22
|
+
partnerAttributionId: props.partnerAttributionId,
|
|
23
|
+
...props.paypalScriptOptions
|
|
24
|
+
});
|
|
25
|
+
const emit = defineEmits(["apply", "clickMessages", "render"]);
|
|
26
|
+
const options = computed(() => {
|
|
27
|
+
const _options = {
|
|
28
|
+
onApply: (data) => {
|
|
29
|
+
emit("apply", data);
|
|
30
|
+
return props.messagesOptions?.onApply?.(data);
|
|
31
|
+
},
|
|
32
|
+
onClick: (data) => {
|
|
33
|
+
emit("clickMessages", data);
|
|
34
|
+
return props.messagesOptions?.onClick?.(data);
|
|
35
|
+
},
|
|
36
|
+
onRender: (data) => {
|
|
37
|
+
emit("render", data);
|
|
38
|
+
return props.messagesOptions?.onRender?.(data);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
return defu(_options, props.messagesOptions);
|
|
42
|
+
});
|
|
43
|
+
const messageInst = shallowRef();
|
|
44
|
+
onMounted(() => {
|
|
45
|
+
onLoaded(async ({ paypal }) => {
|
|
46
|
+
if (!el.value) return;
|
|
47
|
+
messageInst.value = paypal?.Messages?.(options.value);
|
|
48
|
+
await messageInst.value?.render(el.value);
|
|
49
|
+
ready.value = true;
|
|
50
|
+
watch(() => options.value, async (_options) => {
|
|
51
|
+
if (!el.value) return;
|
|
52
|
+
messageInst.value = paypal?.Messages?.(_options);
|
|
53
|
+
await messageInst.value?.render(el.value);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
function destroy() {
|
|
58
|
+
if (!el.value) return;
|
|
59
|
+
el.value?.replaceChildren();
|
|
60
|
+
}
|
|
61
|
+
onBeforeUnmount(() => {
|
|
62
|
+
destroy();
|
|
63
|
+
});
|
|
64
|
+
const ScriptLoadingIndicator = resolveComponent("ScriptLoadingIndicator");
|
|
65
|
+
const trigger = useScriptTriggerElement({ trigger: props.trigger, el: rootEl });
|
|
66
|
+
const rootAttrs = computed(() => {
|
|
67
|
+
return defu(props.rootAttrs, {
|
|
68
|
+
"aria-busy": status.value === "loading",
|
|
69
|
+
"aria-label": status.value === "awaitingLoad" ? "PayPal Script Placeholder" : status.value === "loading" ? "PayPal Buttons Loading" : "PayPal Buttons",
|
|
70
|
+
"aria-live": "polite",
|
|
71
|
+
"role": "application",
|
|
72
|
+
...trigger instanceof Promise ? trigger.ssrAttrs || {} : {}
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
</script>
|
|
76
|
+
|
|
77
|
+
<template>
|
|
78
|
+
<div v-bind="rootAttrs" id="test">
|
|
79
|
+
<div v-show="ready" ref="el" />
|
|
80
|
+
<slot v-if="!ready" name="placeholder">
|
|
81
|
+
placeholder
|
|
82
|
+
</slot>
|
|
83
|
+
<slot v-if="status !== 'awaitingLoad' && !ready" name="loading">
|
|
84
|
+
<ScriptLoadingIndicator color="black" />
|
|
85
|
+
</slot>
|
|
86
|
+
<slot v-if="status === 'awaitingLoad'" name="awaitingLoad" />
|
|
87
|
+
<slot v-else-if="status === 'error'" name="error" />
|
|
88
|
+
<slot />
|
|
89
|
+
</div>
|
|
90
|
+
</template>
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { type HTMLAttributes, type ReservedProps } from 'vue';
|
|
2
|
+
import type { PayPalMessagesComponentOptions } from '@paypal/paypal-js';
|
|
3
|
+
import type { ElementScriptTrigger } from '#nuxt-scripts/types';
|
|
4
|
+
import type { PayPalInput } from '../registry/paypal.js';
|
|
5
|
+
type __VLS_Props = {
|
|
6
|
+
/**
|
|
7
|
+
* Customize the root element attributes.
|
|
8
|
+
*/
|
|
9
|
+
rootAttrs?: HTMLAttributes & ReservedProps & Record<string, unknown>;
|
|
10
|
+
/**
|
|
11
|
+
* Defines the trigger event to load the script.
|
|
12
|
+
*/
|
|
13
|
+
trigger?: ElementScriptTrigger;
|
|
14
|
+
/**
|
|
15
|
+
* The client id for the paypal script.
|
|
16
|
+
*/
|
|
17
|
+
clientId?: string;
|
|
18
|
+
/**
|
|
19
|
+
* The options for the paypal buttons.
|
|
20
|
+
*/
|
|
21
|
+
messagesOptions?: PayPalMessagesComponentOptions;
|
|
22
|
+
/**
|
|
23
|
+
* The merchant id for the paypal script.
|
|
24
|
+
*/
|
|
25
|
+
merchantId?: string;
|
|
26
|
+
/**
|
|
27
|
+
* The partner attribution id for the paypal script.
|
|
28
|
+
*/
|
|
29
|
+
partnerAttributionId?: string;
|
|
30
|
+
/**
|
|
31
|
+
* The options for the paypal scipt.
|
|
32
|
+
*/
|
|
33
|
+
paypalScriptOptions?: Partial<PayPalInput>;
|
|
34
|
+
};
|
|
35
|
+
declare var __VLS_1: {}, __VLS_3: {}, __VLS_10: {}, __VLS_12: {}, __VLS_14: {};
|
|
36
|
+
type __VLS_Slots = {} & {
|
|
37
|
+
placeholder?: (props: typeof __VLS_1) => any;
|
|
38
|
+
} & {
|
|
39
|
+
loading?: (props: typeof __VLS_3) => any;
|
|
40
|
+
} & {
|
|
41
|
+
awaitingLoad?: (props: typeof __VLS_10) => any;
|
|
42
|
+
} & {
|
|
43
|
+
error?: (props: typeof __VLS_12) => any;
|
|
44
|
+
} & {
|
|
45
|
+
default?: (props: typeof __VLS_14) => any;
|
|
46
|
+
};
|
|
47
|
+
declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
48
|
+
render: (data: Record<string, unknown>) => any;
|
|
49
|
+
apply: (data: Record<string, unknown>) => any;
|
|
50
|
+
clickMessages: (data: Record<string, unknown>) => any;
|
|
51
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
52
|
+
onRender?: ((data: Record<string, unknown>) => any) | undefined;
|
|
53
|
+
onApply?: ((data: Record<string, unknown>) => any) | undefined;
|
|
54
|
+
onClickMessages?: ((data: Record<string, unknown>) => any) | undefined;
|
|
55
|
+
}>, {
|
|
56
|
+
trigger: ElementScriptTrigger;
|
|
57
|
+
clientId: string;
|
|
58
|
+
paypalScriptOptions: Partial<PayPalInput>;
|
|
59
|
+
messagesOptions: PayPalMessagesComponentOptions;
|
|
60
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
61
|
+
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
62
|
+
export default _default;
|
|
63
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
64
|
+
new (): {
|
|
65
|
+
$slots: S;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ElementScriptTrigger } from '../types.js';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
trigger?: ElementScriptTrigger;
|
|
4
|
+
publishableKey: string;
|
|
5
|
+
pricingTableId: string;
|
|
6
|
+
clientReferenceId?: string;
|
|
7
|
+
customerEmail?: string;
|
|
8
|
+
customerSessionClientSecret?: string;
|
|
9
|
+
};
|
|
10
|
+
declare var __VLS_1: {}, __VLS_3: {}, __VLS_5: {}, __VLS_7: {};
|
|
11
|
+
type __VLS_Slots = {} & {
|
|
12
|
+
loading?: (props: typeof __VLS_1) => any;
|
|
13
|
+
} & {
|
|
14
|
+
awaitingLoad?: (props: typeof __VLS_3) => any;
|
|
15
|
+
} & {
|
|
16
|
+
error?: (props: typeof __VLS_5) => any;
|
|
17
|
+
} & {
|
|
18
|
+
default?: (props: typeof __VLS_7) => any;
|
|
19
|
+
};
|
|
20
|
+
declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
21
|
+
error: () => any;
|
|
22
|
+
ready: (args_0: import("../types.js").UseScriptContext<Record<string | symbol, any>>) => any;
|
|
23
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
24
|
+
onError?: (() => any) | undefined;
|
|
25
|
+
onReady?: ((args_0: import("../types.js").UseScriptContext<Record<string | symbol, any>>) => any) | undefined;
|
|
26
|
+
}>, {
|
|
27
|
+
trigger: ElementScriptTrigger;
|
|
28
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
29
|
+
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
30
|
+
export default _default;
|
|
31
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
32
|
+
new (): {
|
|
33
|
+
$slots: S;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { ref, computed, onBeforeUnmount, onMounted, watch } from "vue";
|
|
3
3
|
import { useScriptTriggerElement } from "../composables/useScriptTriggerElement";
|
|
4
|
-
import { useScript } from "
|
|
4
|
+
import { useScript } from "../composables/useScript";
|
|
5
5
|
const props = defineProps({
|
|
6
6
|
trigger: { type: [String, Array, Boolean], required: false, default: "visible" },
|
|
7
7
|
publishableKey: { type: String, required: true },
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import type { HTMLAttributes, ImgHTMLAttributes } from 'vue';
|
|
2
|
+
import type { ElementScriptTrigger } from '../types.js';
|
|
3
|
+
interface VimeoOptions {
|
|
4
|
+
id?: number | undefined;
|
|
5
|
+
url?: string | undefined;
|
|
6
|
+
autopause?: boolean | undefined;
|
|
7
|
+
autoplay?: boolean | undefined;
|
|
8
|
+
background?: boolean | undefined;
|
|
9
|
+
byline?: boolean | undefined;
|
|
10
|
+
color?: string | undefined;
|
|
11
|
+
controls?: boolean | undefined;
|
|
12
|
+
dnt?: boolean | undefined;
|
|
13
|
+
height?: number | undefined;
|
|
14
|
+
interactive_params?: string | undefined;
|
|
15
|
+
keyboard?: boolean | undefined;
|
|
16
|
+
loop?: boolean | undefined;
|
|
17
|
+
maxheight?: number | undefined;
|
|
18
|
+
maxwidth?: number | undefined;
|
|
19
|
+
muted?: boolean | undefined;
|
|
20
|
+
pip?: boolean | undefined;
|
|
21
|
+
playsinline?: boolean | undefined;
|
|
22
|
+
portrait?: boolean | undefined;
|
|
23
|
+
responsive?: boolean | undefined;
|
|
24
|
+
speed?: boolean | undefined;
|
|
25
|
+
quality?: Vimeo.VimeoVideoQuality | undefined;
|
|
26
|
+
texttrack?: string | undefined;
|
|
27
|
+
title?: boolean | undefined;
|
|
28
|
+
transparent?: boolean | undefined;
|
|
29
|
+
width?: number | undefined;
|
|
30
|
+
}
|
|
31
|
+
type __VLS_Props = {
|
|
32
|
+
trigger?: ElementScriptTrigger;
|
|
33
|
+
placeholderAttrs?: ImgHTMLAttributes;
|
|
34
|
+
rootAttrs?: HTMLAttributes;
|
|
35
|
+
aboveTheFold?: boolean;
|
|
36
|
+
vimeoOptions?: VimeoOptions;
|
|
37
|
+
id?: number | undefined;
|
|
38
|
+
url?: string | undefined;
|
|
39
|
+
};
|
|
40
|
+
declare var __VLS_1: any, __VLS_3: {}, __VLS_9: {}, __VLS_11: {}, __VLS_13: {};
|
|
41
|
+
type __VLS_Slots = {} & {
|
|
42
|
+
placeholder?: (props: typeof __VLS_1) => any;
|
|
43
|
+
} & {
|
|
44
|
+
loading?: (props: typeof __VLS_3) => any;
|
|
45
|
+
} & {
|
|
46
|
+
awaitingLoad?: (props: typeof __VLS_9) => any;
|
|
47
|
+
} & {
|
|
48
|
+
error?: (props: typeof __VLS_11) => any;
|
|
49
|
+
} & {
|
|
50
|
+
default?: (props: typeof __VLS_13) => any;
|
|
51
|
+
};
|
|
52
|
+
declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {
|
|
53
|
+
play: () => Promise<void> | undefined;
|
|
54
|
+
pause: () => Promise<void> | undefined;
|
|
55
|
+
getDuration: () => Promise<number> | undefined;
|
|
56
|
+
getCurrentTime: () => Promise<number> | undefined;
|
|
57
|
+
setCurrentTime: (time: number) => Promise<number> | undefined;
|
|
58
|
+
getVolume: () => Promise<number> | undefined;
|
|
59
|
+
setVolume: (volume: number) => Promise<number> | undefined;
|
|
60
|
+
getPaused: () => Promise<boolean> | undefined;
|
|
61
|
+
getEnded: () => Promise<boolean> | undefined;
|
|
62
|
+
getLoop: () => Promise<boolean> | undefined;
|
|
63
|
+
setLoop: (loop: boolean) => Promise<boolean> | undefined;
|
|
64
|
+
getPlaybackRate: () => Promise<number> | undefined;
|
|
65
|
+
setPlaybackRate: (rate: number) => Promise<number> | undefined;
|
|
66
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
67
|
+
error: (event: import("@vimeo/player").Error, player: Vimeo.Player) => any;
|
|
68
|
+
loaded: (event: import("@vimeo/player").LoadedEvent, player: Vimeo.Player) => any;
|
|
69
|
+
cuechange: (event: import("@vimeo/player").CueChangeEvent, player: Vimeo.Player) => any;
|
|
70
|
+
durationchange: (event: import("@vimeo/player").DurationChangeEvent, player: Vimeo.Player) => any;
|
|
71
|
+
ended: (event: import("@vimeo/player").TimeEvent, player: Vimeo.Player) => any;
|
|
72
|
+
pause: (event: import("@vimeo/player").TimeEvent, player: Vimeo.Player) => any;
|
|
73
|
+
play: (event: import("@vimeo/player").TimeEvent, player: Vimeo.Player) => any;
|
|
74
|
+
playing: (event: import("@vimeo/player").TimeEvent, player: Vimeo.Player) => any;
|
|
75
|
+
progress: (event: import("@vimeo/player").TimeEvent, player: Vimeo.Player) => any;
|
|
76
|
+
resize: (event: import("@vimeo/player").ResizeEvent, player: Vimeo.Player) => any;
|
|
77
|
+
seeked: (event: import("@vimeo/player").TimeEvent, player: Vimeo.Player) => any;
|
|
78
|
+
seeking: (event: import("@vimeo/player").TimeEvent, player: Vimeo.Player) => any;
|
|
79
|
+
timeupdate: (event: import("@vimeo/player").TimeEvent, player: Vimeo.Player) => any;
|
|
80
|
+
volumechange: (event: import("@vimeo/player").VolumeChangeEvent, player: Vimeo.Player) => any;
|
|
81
|
+
fullscreenchange: (event: import("@vimeo/player").FullScreenChangeEvent, player: Vimeo.Player) => any;
|
|
82
|
+
texttrackchange: (event: import("@vimeo/player").TextTrackChangeEvent, player: Vimeo.Player) => any;
|
|
83
|
+
chapterchange: (event: import("@vimeo/player").VimeoChapter, player: Vimeo.Player) => any;
|
|
84
|
+
cuepoint: (event: import("@vimeo/player").CuePointEvent, player: Vimeo.Player) => any;
|
|
85
|
+
playbackratechange: (event: import("@vimeo/player").PlaybackRateEvent, player: Vimeo.Player) => any;
|
|
86
|
+
bufferstart: (event: never, player: Vimeo.Player) => any;
|
|
87
|
+
bufferend: (event: never, player: Vimeo.Player) => any;
|
|
88
|
+
qualitychange: (event: import("@vimeo/player").QualityChangeEvent, player: Vimeo.Player) => any;
|
|
89
|
+
camerachange: (event: import("@vimeo/player").VimeoCameraProps, player: Vimeo.Player) => any;
|
|
90
|
+
enterpictureinpicture: (event: never, player: Vimeo.Player) => any;
|
|
91
|
+
leavepictureinpicture: (event: never, player: Vimeo.Player) => any;
|
|
92
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
93
|
+
onError?: ((event: import("@vimeo/player").Error, player: Vimeo.Player) => any) | undefined;
|
|
94
|
+
onLoaded?: ((event: import("@vimeo/player").LoadedEvent, player: Vimeo.Player) => any) | undefined;
|
|
95
|
+
onCuechange?: ((event: import("@vimeo/player").CueChangeEvent, player: Vimeo.Player) => any) | undefined;
|
|
96
|
+
onDurationchange?: ((event: import("@vimeo/player").DurationChangeEvent, player: Vimeo.Player) => any) | undefined;
|
|
97
|
+
onEnded?: ((event: import("@vimeo/player").TimeEvent, player: Vimeo.Player) => any) | undefined;
|
|
98
|
+
onPause?: ((event: import("@vimeo/player").TimeEvent, player: Vimeo.Player) => any) | undefined;
|
|
99
|
+
onPlay?: ((event: import("@vimeo/player").TimeEvent, player: Vimeo.Player) => any) | undefined;
|
|
100
|
+
onPlaying?: ((event: import("@vimeo/player").TimeEvent, player: Vimeo.Player) => any) | undefined;
|
|
101
|
+
onProgress?: ((event: import("@vimeo/player").TimeEvent, player: Vimeo.Player) => any) | undefined;
|
|
102
|
+
onResize?: ((event: import("@vimeo/player").ResizeEvent, player: Vimeo.Player) => any) | undefined;
|
|
103
|
+
onSeeked?: ((event: import("@vimeo/player").TimeEvent, player: Vimeo.Player) => any) | undefined;
|
|
104
|
+
onSeeking?: ((event: import("@vimeo/player").TimeEvent, player: Vimeo.Player) => any) | undefined;
|
|
105
|
+
onTimeupdate?: ((event: import("@vimeo/player").TimeEvent, player: Vimeo.Player) => any) | undefined;
|
|
106
|
+
onVolumechange?: ((event: import("@vimeo/player").VolumeChangeEvent, player: Vimeo.Player) => any) | undefined;
|
|
107
|
+
onFullscreenchange?: ((event: import("@vimeo/player").FullScreenChangeEvent, player: Vimeo.Player) => any) | undefined;
|
|
108
|
+
onTexttrackchange?: ((event: import("@vimeo/player").TextTrackChangeEvent, player: Vimeo.Player) => any) | undefined;
|
|
109
|
+
onChapterchange?: ((event: import("@vimeo/player").VimeoChapter, player: Vimeo.Player) => any) | undefined;
|
|
110
|
+
onCuepoint?: ((event: import("@vimeo/player").CuePointEvent, player: Vimeo.Player) => any) | undefined;
|
|
111
|
+
onPlaybackratechange?: ((event: import("@vimeo/player").PlaybackRateEvent, player: Vimeo.Player) => any) | undefined;
|
|
112
|
+
onBufferstart?: ((event: never, player: Vimeo.Player) => any) | undefined;
|
|
113
|
+
onBufferend?: ((event: never, player: Vimeo.Player) => any) | undefined;
|
|
114
|
+
onQualitychange?: ((event: import("@vimeo/player").QualityChangeEvent, player: Vimeo.Player) => any) | undefined;
|
|
115
|
+
onCamerachange?: ((event: import("@vimeo/player").VimeoCameraProps, player: Vimeo.Player) => any) | undefined;
|
|
116
|
+
onEnterpictureinpicture?: ((event: never, player: Vimeo.Player) => any) | undefined;
|
|
117
|
+
onLeavepictureinpicture?: ((event: never, player: Vimeo.Player) => any) | undefined;
|
|
118
|
+
}>, {
|
|
119
|
+
trigger: ElementScriptTrigger;
|
|
120
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
121
|
+
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
122
|
+
export default _default;
|
|
123
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
124
|
+
new (): {
|
|
125
|
+
$slots: S;
|
|
126
|
+
};
|
|
127
|
+
};
|
|
@@ -64,8 +64,8 @@ declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {
|
|
|
64
64
|
getPlaybackRate: () => Promise<number> | undefined;
|
|
65
65
|
setPlaybackRate: (rate: number) => Promise<number> | undefined;
|
|
66
66
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
67
|
-
loaded: (event: import("@vimeo/player").LoadedEvent, player: Vimeo.Player) => any;
|
|
68
67
|
error: (event: import("@vimeo/player").Error, player: Vimeo.Player) => any;
|
|
68
|
+
loaded: (event: import("@vimeo/player").LoadedEvent, player: Vimeo.Player) => any;
|
|
69
69
|
cuechange: (event: import("@vimeo/player").CueChangeEvent, player: Vimeo.Player) => any;
|
|
70
70
|
durationchange: (event: import("@vimeo/player").DurationChangeEvent, player: Vimeo.Player) => any;
|
|
71
71
|
ended: (event: import("@vimeo/player").TimeEvent, player: Vimeo.Player) => any;
|
|
@@ -90,8 +90,8 @@ declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {
|
|
|
90
90
|
enterpictureinpicture: (event: never, player: Vimeo.Player) => any;
|
|
91
91
|
leavepictureinpicture: (event: never, player: Vimeo.Player) => any;
|
|
92
92
|
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
93
|
-
onLoaded?: ((event: import("@vimeo/player").LoadedEvent, player: Vimeo.Player) => any) | undefined;
|
|
94
93
|
onError?: ((event: import("@vimeo/player").Error, player: Vimeo.Player) => any) | undefined;
|
|
94
|
+
onLoaded?: ((event: import("@vimeo/player").LoadedEvent, player: Vimeo.Player) => any) | undefined;
|
|
95
95
|
onCuechange?: ((event: import("@vimeo/player").CueChangeEvent, player: Vimeo.Player) => any) | undefined;
|
|
96
96
|
onDurationchange?: ((event: import("@vimeo/player").DurationChangeEvent, player: Vimeo.Player) => any) | undefined;
|
|
97
97
|
onEnded?: ((event: import("@vimeo/player").TimeEvent, player: Vimeo.Player) => any) | undefined;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { HTMLAttributes, ImgHTMLAttributes, Ref } from 'vue';
|
|
2
|
+
import type { ElementScriptTrigger } from '../types.js';
|
|
3
|
+
export type YoutubeThumbnailSize = '1' | '2' | '3' | 'default' | 'mq1' | 'mq2' | 'mq3' | 'mqdefault' | '0' | 'hq1' | 'hq2' | 'hq3' | 'hqdefault' | 'sd1' | 'sd2' | 'sd3' | 'sddefault' | 'hq720' | 'maxresdefault';
|
|
4
|
+
type __VLS_Props = {
|
|
5
|
+
placeholderAttrs?: ImgHTMLAttributes;
|
|
6
|
+
rootAttrs?: HTMLAttributes;
|
|
7
|
+
aboveTheFold?: boolean;
|
|
8
|
+
trigger?: ElementScriptTrigger;
|
|
9
|
+
videoId: string;
|
|
10
|
+
playerVars?: YT.PlayerVars;
|
|
11
|
+
width?: number;
|
|
12
|
+
height?: number;
|
|
13
|
+
/**
|
|
14
|
+
* Whether to use youtube-nocookie.com for embedding.
|
|
15
|
+
*
|
|
16
|
+
* @default false
|
|
17
|
+
*/
|
|
18
|
+
cookies?: boolean;
|
|
19
|
+
playerOptions?: YT.PlayerOptions;
|
|
20
|
+
thumbnailSize?: YoutubeThumbnailSize;
|
|
21
|
+
webp?: boolean;
|
|
22
|
+
};
|
|
23
|
+
declare var __VLS_1: {
|
|
24
|
+
placeholder: any;
|
|
25
|
+
}, __VLS_3: {}, __VLS_9: {}, __VLS_11: {}, __VLS_13: {};
|
|
26
|
+
type __VLS_Slots = {} & {
|
|
27
|
+
placeholder?: (props: typeof __VLS_1) => any;
|
|
28
|
+
} & {
|
|
29
|
+
loading?: (props: typeof __VLS_3) => any;
|
|
30
|
+
} & {
|
|
31
|
+
awaitingLoad?: (props: typeof __VLS_9) => any;
|
|
32
|
+
} & {
|
|
33
|
+
error?: (props: typeof __VLS_11) => any;
|
|
34
|
+
} & {
|
|
35
|
+
default?: (props: typeof __VLS_13) => any;
|
|
36
|
+
};
|
|
37
|
+
declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {
|
|
38
|
+
player: Ref<YT.Player | undefined, YT.Player | undefined>;
|
|
39
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
40
|
+
error: (e: YT.OnErrorEvent, target: YT.Player) => any;
|
|
41
|
+
ready: (e: YT.PlayerEvent) => any;
|
|
42
|
+
"state-change": (e: YT.OnStateChangeEvent, target: YT.Player) => any;
|
|
43
|
+
"playback-quality-change": (e: YT.OnPlaybackQualityChangeEvent, target: YT.Player) => any;
|
|
44
|
+
"playback-rate-change": (e: YT.OnPlaybackRateChangeEvent, target: YT.Player) => any;
|
|
45
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
46
|
+
onError?: ((e: YT.OnErrorEvent, target: YT.Player) => any) | undefined;
|
|
47
|
+
onReady?: ((e: YT.PlayerEvent) => any) | undefined;
|
|
48
|
+
"onState-change"?: ((e: YT.OnStateChangeEvent, target: YT.Player) => any) | undefined;
|
|
49
|
+
"onPlayback-quality-change"?: ((e: YT.OnPlaybackQualityChangeEvent, target: YT.Player) => any) | undefined;
|
|
50
|
+
"onPlayback-rate-change"?: ((e: YT.OnPlaybackRateChangeEvent, target: YT.Player) => any) | undefined;
|
|
51
|
+
}>, {
|
|
52
|
+
trigger: ElementScriptTrigger;
|
|
53
|
+
width: number;
|
|
54
|
+
height: number;
|
|
55
|
+
playerVars: YT.PlayerVars;
|
|
56
|
+
cookies: boolean;
|
|
57
|
+
thumbnailSize: YoutubeThumbnailSize;
|
|
58
|
+
webp: boolean;
|
|
59
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
60
|
+
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
61
|
+
export default _default;
|
|
62
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
63
|
+
new (): {
|
|
64
|
+
$slots: S;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { defu } from "defu";
|
|
2
2
|
import { useScript as _useScript } from "@unhead/vue/scripts";
|
|
3
3
|
import { reactive } from "vue";
|
|
4
|
-
import { onNuxtReady, useNuxtApp, useRuntimeConfig, injectHead } from "
|
|
4
|
+
import { onNuxtReady, useNuxtApp, useRuntimeConfig, injectHead } from "nuxt/app";
|
|
5
|
+
import { logger } from "../logger.js";
|
|
5
6
|
function useNuxtScriptRuntimeConfig() {
|
|
6
7
|
return useRuntimeConfig().public["nuxt-scripts"];
|
|
7
8
|
}
|
|
@@ -11,6 +12,10 @@ export function resolveScriptKey(input) {
|
|
|
11
12
|
export function useScript(input, options) {
|
|
12
13
|
input = typeof input === "string" ? { src: input } : input;
|
|
13
14
|
options = defu(options, useNuxtScriptRuntimeConfig()?.defaultScriptOptions);
|
|
15
|
+
if (import.meta.dev && options.bundle === "unsupported") {
|
|
16
|
+
console.warn("[Nuxt Scripts] Bundling is not supported for dynamic script sources. Static URLs are required for bundling.");
|
|
17
|
+
options.bundle = false;
|
|
18
|
+
}
|
|
14
19
|
const id = String(resolveScriptKey(input));
|
|
15
20
|
const nuxtApp = useNuxtApp();
|
|
16
21
|
options.head = options.head || injectHead();
|
|
@@ -19,7 +24,20 @@ export function useScript(input, options) {
|
|
|
19
24
|
}
|
|
20
25
|
nuxtApp.$scripts = nuxtApp.$scripts || reactive({});
|
|
21
26
|
const exists = !!nuxtApp.$scripts?.[id];
|
|
22
|
-
|
|
27
|
+
const err = options._validate?.();
|
|
28
|
+
if (import.meta.dev && import.meta.client && err) {
|
|
29
|
+
options.trigger = new Promise(() => {
|
|
30
|
+
});
|
|
31
|
+
if (!exists) {
|
|
32
|
+
let out = `Skipping script \`${id}\` due to invalid options:
|
|
33
|
+
`;
|
|
34
|
+
for (const e of err.issues) {
|
|
35
|
+
out += ` ${e.message}
|
|
36
|
+
`;
|
|
37
|
+
}
|
|
38
|
+
logger.info(out);
|
|
39
|
+
}
|
|
40
|
+
} else if (options.trigger === "onNuxtReady" || options.trigger === "client") {
|
|
23
41
|
if (!options.warmupStrategy) {
|
|
24
42
|
options.warmupStrategy = "preload";
|
|
25
43
|
}
|
|
@@ -33,6 +51,13 @@ export function useScript(input, options) {
|
|
|
33
51
|
nuxtApp.$scripts[id] = void 0;
|
|
34
52
|
return _remove();
|
|
35
53
|
};
|
|
54
|
+
const _load = instance.load;
|
|
55
|
+
instance.load = async () => {
|
|
56
|
+
if (err) {
|
|
57
|
+
return Promise.reject(err);
|
|
58
|
+
}
|
|
59
|
+
return _load();
|
|
60
|
+
};
|
|
36
61
|
nuxtApp.$scripts[id] = instance;
|
|
37
62
|
if (import.meta.dev && import.meta.client) {
|
|
38
63
|
let syncScripts = function() {
|
|
@@ -72,6 +97,14 @@ export function useScript(input, options) {
|
|
|
72
97
|
syncScripts();
|
|
73
98
|
});
|
|
74
99
|
payload.$script = instance;
|
|
100
|
+
if (err) {
|
|
101
|
+
payload.events.push({
|
|
102
|
+
type: "status",
|
|
103
|
+
status: "validation-failed",
|
|
104
|
+
args: err,
|
|
105
|
+
at: Date.now()
|
|
106
|
+
});
|
|
107
|
+
}
|
|
75
108
|
payload.events.push({
|
|
76
109
|
type: "status",
|
|
77
110
|
status: "awaitingLoad",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useNuxtApp, useRoute, injectHead } from "nuxt/app";
|
|
2
|
-
import { ref } from "vue";
|
|
2
|
+
import { ref, onScopeDispose } from "vue";
|
|
3
3
|
export function useScriptEventPage(onChange) {
|
|
4
4
|
const nuxt = useNuxtApp();
|
|
5
5
|
const route = useRoute();
|
|
@@ -13,7 +13,7 @@ export function useScriptEventPage(onChange) {
|
|
|
13
13
|
let lastPayload = { path: "", title: "" };
|
|
14
14
|
let stopDomWatcher = () => {
|
|
15
15
|
};
|
|
16
|
-
nuxt.hooks.hook("page:finish", () => {
|
|
16
|
+
const stopPageFinishHook = nuxt.hooks.hook("page:finish", () => {
|
|
17
17
|
Promise.race([
|
|
18
18
|
// possibly no head update is needed
|
|
19
19
|
new Promise((resolve) => setTimeout(resolve, 100)),
|
|
@@ -33,5 +33,9 @@ export function useScriptEventPage(onChange) {
|
|
|
33
33
|
}
|
|
34
34
|
});
|
|
35
35
|
});
|
|
36
|
+
onScopeDispose(() => {
|
|
37
|
+
stopDomWatcher();
|
|
38
|
+
stopPageFinishHook();
|
|
39
|
+
});
|
|
36
40
|
return payload;
|
|
37
41
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface IdleTimeoutScriptTriggerOptions {
|
|
2
|
+
/**
|
|
3
|
+
* The timeout in milliseconds to wait before loading the script.
|
|
4
|
+
*/
|
|
5
|
+
timeout: number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Create a trigger that loads a script after an idle timeout once Nuxt is ready.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useScriptTriggerIdleTimeout(options: IdleTimeoutScriptTriggerOptions): Promise<boolean>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { tryOnScopeDispose } from "@vueuse/shared";
|
|
2
|
+
import { useTimeoutFn } from "@vueuse/core";
|
|
3
|
+
import { onNuxtReady } from "nuxt/app";
|
|
4
|
+
export function useScriptTriggerIdleTimeout(options) {
|
|
5
|
+
if (import.meta.server) {
|
|
6
|
+
return new Promise(() => {
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
const { timeout } = options;
|
|
10
|
+
return new Promise((resolve) => {
|
|
11
|
+
onNuxtReady(() => {
|
|
12
|
+
const { start, stop } = useTimeoutFn(() => {
|
|
13
|
+
resolve(true);
|
|
14
|
+
}, timeout, { immediate: false });
|
|
15
|
+
start();
|
|
16
|
+
tryOnScopeDispose(() => {
|
|
17
|
+
stop();
|
|
18
|
+
resolve(false);
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
}
|