Skip to content

Commit

Permalink
fix: nuxt3 typescript support in nuxt.config.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
justintaddei committed Jun 27, 2024
1 parent be9743e commit 9aa28ec
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 27 deletions.
18 changes: 18 additions & 0 deletions nuxt/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { NuxtModule, ModuleOptions } from '@nuxt/schema';

interface VWaveModuleOptions extends ModuleOptions {
randomProp: string;
}
declare const module: NuxtModule<VWaveModuleOptions>;

declare module '@nuxt/schema' {
interface NuxtConfig { ['vWave']?: NuxtModule<VWaveModuleOptions> }
interface NuxtOptions { ['vWave']?: VWaveModuleOptions }
}

declare module 'nuxt/schema' {
interface NuxtConfig { ['vWave']?: NuxtModule<VWaveModuleOptions> }
interface NuxtOptions { ['vWave']?: VWaveModuleOptions }
}

export { VWaveModuleOptions, module as default };
13 changes: 0 additions & 13 deletions nuxt/index.js

This file was deleted.

25 changes: 25 additions & 0 deletions nuxt/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { defineNuxtModule, addPlugin, createResolver } from '@nuxt/kit'
import type { IVWavePluginOptions } from '../src/options'

type ModuleOptions = Partial<IVWavePluginOptions>

export default defineNuxtModule<ModuleOptions>({
meta: {
name: 'v-wave',
configKey: 'vWave',
compatibility: {
nuxt: '^3.0.0',
bridge: true
}
},
defaults: {
directive: "wave"
},
setup(options, nuxt) {
const { resolve } = createResolver(import.meta.url)

nuxt.options.runtimeConfig.public.vWave = options

addPlugin(resolve('./runtime/plugin.ts'))
}
})
8 changes: 0 additions & 8 deletions nuxt/meta.json

This file was deleted.

6 changes: 2 additions & 4 deletions nuxt/runtime/plugin.js → nuxt/runtime/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,16 @@ import { defineNuxtPlugin, useRuntimeConfig } from '#imports'
export default defineNuxtPlugin((app) => {
const options = useRuntimeConfig().public.vWave

const directive = options.directive || 'wave'

const { vWave, vWaveTrigger } = VWave.createLocalWaveDirective(options, app.vueApp)

app.vueApp.directive(directive, {
app.vueApp.directive(options.directive, {
...vWave,
getSSRProps() {
return {}
}
})

app.vueApp.directive(`${directive}-trigger`, {
app.vueApp.directive(`${options.directive}-trigger`, {
...vWaveTrigger,
getSSRProps() {
return {}
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"description": "The material-ripple directive for Vue that actually works",
"author": "Justin Taddei <justin@justintaddei.com> (https://justintaddei.com/)",
"type": "module",
"main": "dist/index.js",
"module": "dist/index.mjs",
"main": "dist/index.cjs",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"unpkg": "dist/index.global.js",
"files": ["dist/**/*", "nuxt/**/*"],
Expand Down

0 comments on commit 9aa28ec

Please sign in to comment.