From 0dd15bce72bdcbcafc1315a4d3690a75c32ef22e Mon Sep 17 00:00:00 2001 From: Andrey Kyrdyumov Date: Fri, 30 Jun 2017 12:43:51 +0600 Subject: [PATCH] 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 --- types/mina/index.d.ts | 50 +++++++++++++++++++++++++++++++++++++ types/mina/tsconfig.json | 21 ++++++++++++++++ types/mina/tslint.json | 1 + types/snapsvg/index.d.ts | 50 +++---------------------------------- types/snapsvg/tsconfig.json | 2 +- 5 files changed, 77 insertions(+), 47 deletions(-) create mode 100644 types/mina/index.d.ts create mode 100644 types/mina/tsconfig.json create mode 100644 types/mina/tslint.json diff --git a/types/mina/index.d.ts b/types/mina/index.d.ts new file mode 100644 index 0000000000..7a2d37e9cb --- /dev/null +++ b/types/mina/index.d.ts @@ -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 , Mattanja Kern , Andrey Kurdyumov +// 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; +} diff --git a/types/mina/tsconfig.json b/types/mina/tsconfig.json new file mode 100644 index 0000000000..a2cbd4e379 --- /dev/null +++ b/types/mina/tsconfig.json @@ -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" + ] +} diff --git a/types/mina/tslint.json b/types/mina/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/mina/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/snapsvg/index.d.ts b/types/snapsvg/index.d.ts index b58c938d74..ff0e9d09a9 100644 --- a/types/snapsvg/index.d.ts +++ b/types/snapsvg/index.d.ts @@ -1,53 +1,11 @@ // Type definitions for Snap-SVG 0.4.1 // Project: https://github.com/adobe-webplatform/Snap.svg -// Definitions by: Lars Klein , Mattanja Kern +// Definitions by: Lars Klein , Mattanja Kern , Andrey Kurdyumov // 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; -} +export = Snap; +export as namespace Snap; declare function Snap(width:number|string,height:number|string):Snap.Paper; declare function Snap(query:string):Snap.Paper; diff --git a/types/snapsvg/tsconfig.json b/types/snapsvg/tsconfig.json index 9e42ed48a9..0f4b962e7f 100644 --- a/types/snapsvg/tsconfig.json +++ b/types/snapsvg/tsconfig.json @@ -22,4 +22,4 @@ "test/2.ts", "test/3.ts" ] -} \ No newline at end of file +}