Make SnapSVG accessible from WebPack

I have to add export = Snap to make project accessible from projects which using webpack, mina object was not accessibly now, but in runtime it was still perfectly fine to have it in the code. Thus I extract mina package as separate global dependency. For code which use SnapSVG as global dependency this will work as earlier, but for those who want to use SnapSVG with WebPack it will reflect how mina available after importing SnapSVG
This commit is contained in:
Andrey Kyrdyumov
2017-06-30 12:43:51 +06:00
parent 8ec8fc20f5
commit 0dd15bce72
5 changed files with 77 additions and 47 deletions

50
types/mina/index.d.ts vendored Normal file
View File

@@ -0,0 +1,50 @@
// Type definitions for mina Snap-SVG 0.4.1
// Project: https://github.com/adobe-webplatform/Snap.svg
// Definitions by: Lars Klein <https://github.com/lhk>, Mattanja Kern <https://github.com/mattanja>, Andrey Kurdyumov <https://github.com/kant2002>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare function mina(a:number, A:number, b:number, B:number, get:Function, set:Function, easing?:(num:number)=>number):mina.AnimationDescriptor;
declare namespace mina {
export interface MinaAnimation {
id: string;
duration: Function;
easing: Function;
speed: Function;
status: Function;
stop: Function;
}
export interface AnimationDescriptor {
id: string;
start: number;
end: number;
b: number;
s: number;
dur: number;
spd: number;
get(): number;
set(slave: number): number;
easing(input: number): number;
status(): number;
status(newStatus: number): void;
speed(): number;
speed(newSpeed: number): void;
duration(): number;
duration(newDuration: number): void;
stop(): void;
pause(): void;
resume(): void;
update(): void;
}
export function backin(n:number):number;
export function backout(n:number):number;
export function bounce(n:number):number;
export function easein(n:number):number;
export function easeinout(n:number):number;
export function easeout(n:number):number;
export function elastic(n:number):number;
export function getById(id:string):AnimationDescriptor;
export function linear(n:number):number;
export function time():number;
}

21
types/mina/tsconfig.json Normal file
View File

@@ -0,0 +1,21 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts"
]
}

1
types/mina/tslint.json Normal file
View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

View File

@@ -1,53 +1,11 @@
// Type definitions for Snap-SVG 0.4.1
// Project: https://github.com/adobe-webplatform/Snap.svg
// Definitions by: Lars Klein <https://github.com/lhk>, Mattanja Kern <https://github.com/mattanja>
// Definitions by: Lars Klein <https://github.com/lhk>, Mattanja Kern <https://github.com/mattanja>, Andrey Kurdyumov <https://github.com/kant2002>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="mina" />
declare function mina(a:number, A:number, b:number, B:number, get:Function, set:Function, easing?:(num:number)=>number):mina.AnimationDescriptor;
declare namespace mina {
export interface MinaAnimation {
id: string;
duration: Function;
easing: Function;
speed: Function;
status: Function;
stop: Function;
}
export interface AnimationDescriptor {
id: string;
start: number;
end: number;
b: number;
s: number;
dur: number;
spd: number;
get(): number;
set(slave: number): number;
easing(input: number): number;
status(): number;
status(newStatus: number): void;
speed(): number;
speed(newSpeed: number): void;
duration(): number;
duration(newDuration: number): void;
stop(): void;
pause(): void;
resume(): void;
update(): void;
}
export function backin(n:number):number;
export function backout(n:number):number;
export function bounce(n:number):number;
export function easein(n:number):number;
export function easeinout(n:number):number;
export function easeout(n:number):number;
export function elastic(n:number):number;
export function getById(id:string):AnimationDescriptor;
export function linear(n:number):number;
export function time():number;
}
export = Snap;
export as namespace Snap;
declare function Snap(width:number|string,height:number|string):Snap.Paper;
declare function Snap(query:string):Snap.Paper;

View File

@@ -22,4 +22,4 @@
"test/2.ts",
"test/3.ts"
]
}
}