|
1 | 1 | import type { UseScriptOptions, DataKeys, SchemaAugmentations, ScriptBase } from '@unhead/schema'
|
2 |
| -import type { UseScriptInput, VueScriptInstance, MaybeComputedRefEntriesOnly } from '@unhead/vue' |
| 2 | +import type { UseScriptInput, VueScriptInstance } from '@unhead/vue' |
3 | 3 | import type { ComputedRef, Ref } from 'vue'
|
4 | 4 | import type { InferInput, ObjectSchema } from 'valibot'
|
5 | 5 | import type { Import } from 'unimport'
|
@@ -120,14 +120,31 @@ const emptyOptions = object({})
|
120 | 120 |
|
121 | 121 | export type EmptyOptionsSchema = typeof emptyOptions
|
122 | 122 |
|
123 |
| -export type RegistryScriptInput<T extends ObjectSchema<any, any> = EmptyOptionsSchema, Bundelable extends boolean = true, Usable extends boolean = false> = InferInput<T> & { |
124 |
| - /** |
125 |
| - * A unique key to use for the script, this can be used to load multiple of the same script with different options. |
126 |
| - */ |
127 |
| - key?: string |
128 |
| - scriptInput?: MaybeComputedRefEntriesOnly<Omit<ScriptBase & DataKeys & SchemaAugmentations['script'], 'src'>> |
129 |
| - scriptOptions?: Omit<NuxtUseScriptOptions, Bundelable extends true ? '' : 'bundle' | Usable extends true ? '' : 'use'> |
130 |
| -} |
| 123 | +type ScriptInput = ScriptBase & DataKeys & SchemaAugmentations['script'] |
| 124 | + |
| 125 | +export type RegistryScriptInput< |
| 126 | + T extends ObjectSchema<any, any> = EmptyOptionsSchema, |
| 127 | + Bundelable extends boolean = true, |
| 128 | + Usable extends boolean = false, |
| 129 | + CanBypassOptions extends boolean = true, |
| 130 | +> = |
| 131 | + (InferInput<T> |
| 132 | + & { |
| 133 | + /** |
| 134 | + * A unique key to use for the script, this can be used to load multiple of the same script with different options. |
| 135 | + */ |
| 136 | + key?: string |
| 137 | + scriptInput?: ScriptInput |
| 138 | + scriptOptions?: Omit<NuxtUseScriptOptions, Bundelable extends true ? '' : 'bundle' | Usable extends true ? '' : 'use'> |
| 139 | + }) |
| 140 | + | (CanBypassOptions extends true ? { |
| 141 | + /** |
| 142 | + * A unique key to use for the script, this can be used to load multiple of the same script with different options. |
| 143 | + */ |
| 144 | + key?: string |
| 145 | + scriptInput: Required<Pick<ScriptInput, 'src'>> & ScriptInput |
| 146 | + scriptOptions?: Omit<NuxtUseScriptOptions, Bundelable extends true ? '' : 'bundle' | Usable extends true ? '' : 'use'> |
| 147 | + } : never) |
131 | 148 |
|
132 | 149 | export interface RegistryScript {
|
133 | 150 | import?: Import // might just be a component
|
|
0 commit comments