Skip to content

Commit

Permalink
plugin typings
Browse files Browse the repository at this point in the history
  • Loading branch information
aaburkov committed Dec 3, 2021
1 parent f653198 commit 8cd4c1f
Show file tree
Hide file tree
Showing 17 changed files with 62 additions and 62 deletions.
4 changes: 2 additions & 2 deletions dist/main.js

Large diffs are not rendered by default.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 10 additions & 0 deletions dist/types/v-snow/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { PluginObject } from "vue";
import { DirectiveBinding } from "vue/types/options";
import component from "./Component.vue";
import Scene from "./Scene";
export declare const directive: {
inserted(el: HTMLElement, binding: DirectiveBinding): void;
update(el: HTMLElement, binding: DirectiveBinding): void;
};
declare const plugin: PluginObject<any>;
export { plugin as default, component as VSnowContainer, directive as VSnowDirective, Scene as VSnowFunction };
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion dist/v-snow.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/v-snow.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"files": [
"dist/v-snow.js",
"dist/v-snow.min.js",
"dist/typings/v-snow"
"dist/types/v-snow"
],
"typings": "dist/typings",
"version": "1.0.1",
"typings": "dist/types/v-snow/index.d.ts",
"version": "1.0.33",
"author": "Alexander Burkov <[email protected]>",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion src/v-snow/Scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { _debounce } from "./utils";
const defaultSceneConfig: SceneConfig = {
color: "#FFFFFF",
opacity: 1,
density: 100,
density: 50,
fall_speed: 2,
size: 10,
zIndex: "999"
Expand Down
50 changes: 0 additions & 50 deletions src/v-snow/index.js

This file was deleted.

39 changes: 39 additions & 0 deletions src/v-snow/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { PluginObject } from "vue";
import { DirectiveBinding } from "vue/types/options";
import component from "./Component.vue";
import Scene from "./Scene";

const statefulDirective = () => {
let scene: Scene;
return {
inserted(el: HTMLElement, binding: DirectiveBinding) {
scene = new Scene(el, binding.value);
scene.start();
},
update(el: HTMLElement, binding: DirectiveBinding) {
scene.updateConfig(binding.value);
}
};
};

export const directive = statefulDirective();

const plugin: PluginObject<any> = {
install(Vue) {
Vue.directive("snow", directive);
Vue.component("VueSnow", component);
}
};

// auto install
if (typeof window !== "undefined" && window.Vue) {
plugin.install(window.Vue, {});
(window as any).vsnow = plugin;
}

export {
plugin as default,
component as VSnowContainer,
directive as VSnowDirective,
Scene as VSnowFunction
};
5 changes: 3 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"experimentalDecorators": true,
"noImplicitAny": false,
"declaration": true,
"declarationDir": "./dist/typings"
"declarationDir": "./dist/types"
},
"include": ["./src/**/*"]
"include": ["./src/**/*"],
"exclude": ["node_modules", "**/__tests__/*"]
}
4 changes: 2 additions & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ const TerserPlugin = require("terser-webpack-plugin");
module.exports = {
mode: "production",
entry: {
"v-snow": "./src/v-snow/index.js",
"v-snow.min": "./src/v-snow/index.js",
"v-snow": "./src/v-snow/index.ts",
"v-snow.min": "./src/v-snow/index.ts",
main: "./src/main.js"
},
output: {
Expand Down

0 comments on commit 8cd4c1f

Please sign in to comment.