Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: type issues #33

Merged
merged 2 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/runtime/composables/createScriptConsentTrigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function createScriptConsentTrigger(options?: ConsentPromiseOptions): Cre
}, { immediate: true })
}
}
})
}) as CreateScriptConsentTriggerApi
// we augment the promise with a consent API
promise.accept = () => {
consented.value = true
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/composables/useAnalyticsPageEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function useAnalyticsPageEvent(onChange?: (payload: TrackedPage) => void)
Promise.race([
// possibly no head update is needed
new Promise(resolve => setTimeout(resolve, 100)),
new Promise((resolve) => {
new Promise<void>((resolve) => {
stopDomWatcher = head.hooks.hook('dom:rendered', () => resolve())
}),
]).finally(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/composables/useElementScriptTrigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ export function useElementScriptTrigger(trigger: ElementScriptTrigger | undefine
return new Promise<void>(() => {})

const activeRef = trigger ? (trigger === 'mouseover' ? useElementHover(el) : useElementVisibility(el)) : ref(false)
return trigger ? new Promise<void>(resolve => watchOnce(activeRef, resolve)) : Promise.resolve()
return trigger ? new Promise<void>(resolve => watchOnce([activeRef], () => resolve())) : Promise.resolve()
}
4 changes: 2 additions & 2 deletions src/runtime/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import type { GoogleMapsInput } from '~/src/runtime/registry/google-maps'
import type { GoogleTagManagerInput } from '~/src/runtime/registry/google-tag-manager'
import type { MatomoAnalyticsInput } from '~/src/runtime/registry/matomo-analytics'
import type { StripeInput } from '~/src/runtime/registry/stripe'
import type { VimeoInput } from '~/src/runtime/registry/vimeo'
import type { VimeoPlayerInput } from '~/src/runtime/registry/vimeo-player'
import type { XPixelInput } from '~/src/runtime/registry/x-pixel'

export type NuxtUseScriptOptions<T = any> = Omit<UseScriptOptions<T>, 'trigger'> & {
Expand Down Expand Up @@ -87,7 +87,7 @@ export interface ScriptRegistry {
matomoAnalytics?: ScriptRegistryEntry<MatomoAnalyticsInput>
segment?: ScriptRegistryEntry<SegmentInput>
stripe?: ScriptRegistryEntry<StripeInput>
vimeo?: ScriptRegistryEntry<VimeoInput>
vimeo?: ScriptRegistryEntry<VimeoPlayerInput>
xPixel?: ScriptRegistryEntry<XPixelInput>
}

Expand Down
1 change: 0 additions & 1 deletion src/runtime/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ type OptionsFn<O extends ObjectSchema<any>> = (options: Input<O>) => ({

export function registryScript<T extends Record<string | symbol, any>, O extends ObjectSchema<any>>(key: string, optionsFn: OptionsFn<O>, _userOptions?: RegistryScriptInput<O>) {
const runtimeConfig = useRuntimeConfig().public.scripts || {}
// @ts-expect-error untyped
const runtimeOptions = runtimeConfig[key]
const userOptions = Object.assign(_userOptions || {}, runtimeOptions || {})
const options = optionsFn(userOptions)
Expand Down
Loading