From d081c374471e925dc21a562e17d48a108b0bec98 Mon Sep 17 00:00:00 2001 From: harlan Date: Sun, 31 Mar 2024 21:37:00 +1100 Subject: [PATCH] refactor: misc improvements --- src/kit.ts | 2 +- src/module.ts | 8 ++++++-- src/runtime/types.ts | 5 +++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/kit.ts b/src/kit.ts index f38c6a9c..7537aa00 100644 --- a/src/kit.ts +++ b/src/kit.ts @@ -6,7 +6,7 @@ export function extendTypes(module: string, template: (options: { typesPath: str const { resolve } = createResolver(import.meta.url) // paths.d.ts addTemplate({ - filename: `module/${module}.d.ts`, + filename: `modules/${module}.d.ts`, getContents: async () => { const typesPath = relative(resolve(nuxt!.options.rootDir, nuxt!.options.buildDir, 'module'), resolve('runtime/types')) const s = await template({ typesPath }) diff --git a/src/module.ts b/src/module.ts index 579e5ba5..bc1d8db9 100644 --- a/src/module.ts +++ b/src/module.ts @@ -34,7 +34,11 @@ export interface ModuleOptions { * @default '/_scripts/' */ prefix?: string - /** Currently scripts assets are exposed as public assets as part of the build. This will be configurable in future */ + /** + * Scripts assets are exposed as public assets as part of the build. + * + * TODO Make configurable in future. + */ strategy?: 'public' } /** @@ -163,7 +167,7 @@ export default defineNuxtModule({ export default defineNuxtPlugin({ name: "${name}:init", setup() { -${config.globals?.map(g => !Array.isArray(g) +${(config.globals || []).map(g => !Array.isArray(g) ? ` useScript("${g.toString()}")` : g.length === 2 ? ` useScript(${JSON.stringify(g[0])}, ${JSON.stringify(g[1])} })` diff --git a/src/runtime/types.ts b/src/runtime/types.ts index 46a14273..c8059f50 100644 --- a/src/runtime/types.ts +++ b/src/runtime/types.ts @@ -55,9 +55,10 @@ export interface NuxtAppScript { $script: VueScriptInstance events: { type: string - fn?: string + fn?: string | symbol args?: any - trigger?: string + status?: string + trigger?: NuxtUseScriptOptions['trigger'] at: number }[] }