@@ -171,7 +171,7 @@ export function useScript<T extends Record<symbol | string, any> = Record<symbol
171171throw new Error ( 'useScript with partytown requires a src' )
172172}
173173useHead ( {
174- script : [ { src, type : 'text/partytown' } ] ,
174+ script : [ { src, type : 'text/partytown' as 'text/javascript' } ] ,
175175} )
176176const nuxtApp = useNuxtApp ( ) as NuxtScriptsApp
177177ensureScripts ( nuxtApp )
@@ -238,10 +238,11 @@ export function useScript<T extends Record<symbol | string, any> = Record<symbol
238238// browser hint optimizations
239239const nuxtApp = useNuxtApp ( ) as NuxtScriptsApp
240240const id = String ( resolveScriptKey ( input ) )
241- options . head = options . head || injectHead ( )
241+ options . head = options . head || injectHead ( ) as NonNullable < typeof options . head >
242242if ( ! options . head ) {
243243throw new Error ( 'useScript() has been called without Nuxt context.' )
244244}
245+ const headHooks = options . head . hooks !
245246ensureScripts ( nuxtApp )
246247const exists = ! ! ( nuxtApp . $scripts as Record < string , any > ) ?. [ id ]
247248
@@ -318,7 +319,7 @@ export function useScript<T extends Record<symbol | string, any> = Record<symbol
318319 ...ctx ,
319320trigger : typeof trigger === 'object' ? ( trigger instanceof Promise ? 'promise' : JSON . stringify ( trigger ) ) : trigger ,
320321} )
321- options . head . hooks . hook ( 'script:updated' , ( entry ) => {
322+ headHooks . hook ( 'script:updated' , ( entry ) => {
322323if ( entry . script . id !== instance . id )
323324return
324325const status = entry . script . status
@@ -369,7 +370,7 @@ export function useScript<T extends Record<symbol | string, any> = Record<symbol
369370}
370371
371372if ( ! nuxtApp . _scripts [ instance . id ] ) {
372- options . head . hooks . hook ( 'script:updated' , ( ctx ) => {
373+ headHooks . hook ( 'script:updated' , ( ctx ) => {
373374if ( ctx . script . id !== instance . id )
374375return
375376// convert the status to a timestamp
@@ -382,7 +383,7 @@ export function useScript<T extends Record<symbol | string, any> = Record<symbol
382383syncScripts ( )
383384} )
384385// @ts -expect-error untyped
385- options . head . hooks . hook ( 'script:instance-fn' , ( ctx ) => {
386+ headHooks . hook ( 'script:instance-fn' , ( ctx ) => {
386387if ( ctx . script . id !== instance . id || String ( ctx . fn ) . startsWith ( '__v_' ) )
387388return
388389// log all events
0 commit comments