From 6c8b9def6a4df7728c3d254fbeac902a6a425f65 Mon Sep 17 00:00:00 2001 From: Corbin Crutchley Date: Wed, 11 Sep 2019 22:02:38 -0700 Subject: [PATCH] Fix 0.8 typings, add type tests (#786) * Fixes typing issues with 0.8 and add initial typing tests * Fix error in utils typing import * Confirmed fixed build, test, and type test, left comments * Moved lengthy `@core` typings to subfiles and barrel index * Initial work to get configure composure working * Fixed error introduced in prior commit, improved type tests * Fixed issues with plugin or types being null * Code cleanup, final fixes * add type tests to CI * Added initial 3.1 types * Move @core/jimp to a class rather than an interface * Minor cleanup, linting, etc --- .circleci/config.yml | 16 + package.json | 9 +- packages/cli/src/load-font.ts | 2 +- packages/core/index.d.ts | 335 -------------- packages/core/package.json | 2 +- packages/core/types/etc.d.ts | 87 ++++ packages/core/types/functions.d.ts | 17 + packages/core/types/index.d.ts | 9 + packages/core/types/jimp.d.ts | 189 ++++++++ packages/core/types/plugins.d.ts | 57 +++ packages/core/types/utils.d.ts | 54 +++ packages/custom/index.d.ts | 14 - packages/custom/package.json | 2 +- packages/custom/types/index.d.ts | 48 ++ packages/custom/types/test.ts | 152 ++++++ packages/custom/types/tsconfig.json | 18 + packages/jimp/index.d.ts | 27 -- packages/jimp/package.json | 9 +- packages/jimp/types/index.d.ts | 590 ++++++++++++++++++++++++ packages/jimp/types/test.ts | 14 + packages/jimp/types/ts3.1/index.d.ts | 29 ++ packages/jimp/types/ts3.1/test.ts | 14 + packages/jimp/types/ts3.1/tsconfig.json | 18 + packages/jimp/types/tsconfig.json | 18 + packages/plugin-blit/index.d.ts | 2 +- packages/plugin-blur/index.d.ts | 4 +- packages/plugin-color/index.d.ts | 4 +- packages/plugin-contain/index.d.ts | 4 +- packages/plugin-cover/index.d.ts | 4 +- packages/plugin-displace/index.d.ts | 2 +- packages/plugin-dither/index.d.ts | 4 +- packages/plugin-flip/index.d.ts | 4 +- packages/plugin-gaussian/index.d.ts | 4 +- packages/plugin-invert/index.d.ts | 4 +- packages/plugin-mask/index.d.ts | 2 +- packages/plugin-normalize/index.d.ts | 4 +- packages/plugin-rotate/index.d.ts | 4 +- packages/plugin-scale/index.d.ts | 4 +- packages/plugin-threshold/package.json | 4 +- packages/plugins/index.d.ts | 2 +- packages/utils/index.d.ts | 2 +- yarn.lock | 168 ++++++- 42 files changed, 1530 insertions(+), 426 deletions(-) delete mode 100644 packages/core/index.d.ts create mode 100644 packages/core/types/etc.d.ts create mode 100644 packages/core/types/functions.d.ts create mode 100644 packages/core/types/index.d.ts create mode 100644 packages/core/types/jimp.d.ts create mode 100644 packages/core/types/plugins.d.ts create mode 100644 packages/core/types/utils.d.ts delete mode 100644 packages/custom/index.d.ts create mode 100644 packages/custom/types/index.d.ts create mode 100644 packages/custom/types/test.ts create mode 100644 packages/custom/types/tsconfig.json delete mode 100644 packages/jimp/index.d.ts create mode 100644 packages/jimp/types/index.d.ts create mode 100644 packages/jimp/types/test.ts create mode 100644 packages/jimp/types/ts3.1/index.d.ts create mode 100644 packages/jimp/types/ts3.1/test.ts create mode 100644 packages/jimp/types/ts3.1/tsconfig.json create mode 100644 packages/jimp/types/tsconfig.json diff --git a/.circleci/config.yml b/.circleci/config.yml index b324d57f7..05cfb164c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -45,6 +45,15 @@ jobs: name: Lint command: yarn lint + test-types: + <<: *defaults + steps: + - attach_workspace: + at: ~/jimp + - run: + name: Test Types + command: yarn tsTest:custom && yarn tsTest:main + build-node6.14: working_directory: ~/jimp-6.14 docker: @@ -115,17 +124,24 @@ workflows: requires: - install + - test-types: + requires: + - install + - build-node6.14: requires: - lint + - test-types - build-node8: requires: - lint + - test-types - build-node10: requires: - lint + - test-types - release: requires: diff --git a/package.json b/package.json index 7364a36f9..b27290776 100644 --- a/package.json +++ b/package.json @@ -8,8 +8,8 @@ "repository": "oliver-moran/jimp", "author": "Andrew Lisowski ", "publishConfig": { - "registry":"https://registry.npmjs.org/" - }, + "registry": "https://registry.npmjs.org/" + }, "scripts": { "lint": "xo", "test": "cross-env BABEL_ENV=test mocha --require @babel/register './packages/**/test/**/*.test.js' --require ts-node/register ./packages/**/test/*.test.ts", @@ -20,7 +20,9 @@ "clean:build": "rm -rf packages/**/es packages/**/dist", "build": "npm run clean:build && lerna run build --stream", "build:watch": "lerna run build:watch --parallel", - "release": "auto shipit" + "release": "auto shipit", + "tsTest:custom": "dtslint packages/custom/types --expectOnly", + "tsTest:main": "dtslint packages/jimp/types --expectOnly" }, "devDependencies": { "@babel/cli": "^7.1.0", @@ -36,6 +38,7 @@ "babel-plugin-source-map-support": "^2.0.1", "babel-plugin-transform-inline-environment-variables": "^0.4.3", "cross-env": "^5.2.0", + "dtslint": "^0.9.6", "eslint-plugin-prettier": "^2.6.2", "express": "^4.16.3", "husky": "^1.0.0-rc.15", diff --git a/packages/cli/src/load-font.ts b/packages/cli/src/load-font.ts index 217854f14..c68a7ec08 100644 --- a/packages/cli/src/load-font.ts +++ b/packages/cli/src/load-font.ts @@ -4,7 +4,7 @@ import { log } from './log'; export async function loadFont(font?: string, verbose?: boolean) { if (font) { log(` 🔤 Loading font: ${font} ...`, verbose); - return await Jimp.loadFont(Jimp[font] || font); + return await Jimp.loadFont((Jimp[font] as unknown as string) || font); } return; diff --git a/packages/core/index.d.ts b/packages/core/index.d.ts deleted file mode 100644 index 2b9148248..000000000 --- a/packages/core/index.d.ts +++ /dev/null @@ -1,335 +0,0 @@ -export function addConstants(constants: [string, string | number], jimpInstance?: Jimp): void; -export function addJimpMethods(methods: [string, Function], jimpInstance?: Jimp): void; -export function jimpEvMethod(methodName: string, evName: string, method: Function): void; -export function jimpEvChange(methodName: string, method: Function): void; -export function addType(mime: string, extensions: string[]): void; - -interface BaseJimp { - prototype: Jimp; - // Constants - AUTO: -1; - // blend modes - BLEND_SOURCE_OVER: string; - BLEND_DESTINATION_OVER: string; - BLEND_MULTIPLY: string; - BLEND_SCREEN: string; - BLEND_OVERLAY: string; - BLEND_DARKEN: string; - BLEND_LIGHTEN: string; - BLEND_HARDLIGHT: string; - BLEND_DIFFERENCE: string; - BLEND_EXCLUSION: string; - // Align modes for cover, contain, bit masks - HORIZONTAL_ALIGN_LEFT: 1; - HORIZONTAL_ALIGN_CENTER: 2; - HORIZONTAL_ALIGN_RIGHT: 4; - VERTICAL_ALIGN_TOP: 8; - VERTICAL_ALIGN_MIDDLE: 16; - VERTICAL_ALIGN_BOTTOM: 32; - // Edge Handling - EDGE_EXTEND: 1; - EDGE_WRAP: 2; - EDGE_CROP: 3; - // Properties - bitmap: Bitmap; - _quality: number; - _deflateLevel: number; - _deflateStrategy: number; - _filterType: number; - _rgba: boolean; - _background: number; - _originalMime: string; - // Constructors - new(path: string, cb?: ImageCallback): Jimp; - new(urlOptions: URLOptions, cb?: ImageCallback): Jimp; - new(image: Jimp, cb?: ImageCallback): Jimp; - new(data: Buffer, cb?: ImageCallback): Jimp; - new(data: Bitmap, cb?: ImageCallback): Jimp; - new(w: number, h: number, cb?: ImageCallback): Jimp; - new( - w: number, - h: number, - background?: number | string, - cb?: ImageCallback - ): Jimp; - // For custom constructors when using Jimp.appendConstructorOption - new(...args: any[]): Jimp; - // Methods - on( - event: T, - cb: (data: ListenerData) => any - ): any; - parseBitmap( - data: Buffer, - path: string | null | undefined, - cb?: ImageCallback - ): void; - hasAlpha(): boolean; - getHeight(): number; - getWidth(): number; - inspect(): string; - toString(): string; - getMIME(): string; - getExtension(): string; - distanceFromHash(hash: string): number; - write(path: string, cb?: ImageCallback): this; - writeAsync(path: string): Promise; - deflateLevel(l: number, cb?: ImageCallback): this; - deflateStrategy(s: number, cb?: ImageCallback): this; - colorType(s: number, cb?: ImageCallback): this; - filterType(f: number, cb?: ImageCallback): this; - rgba(bool: boolean, cb?: ImageCallback): this; - quality(n: number, cb?: ImageCallback): this; - getBase64(mime: string, cb: GenericCallback): this; - getBase64Async(mime: string): Promise; - hash(cb?: GenericCallback): string; - hash( - base: number | null | undefined, - cb?: GenericCallback - ): string; - getBuffer(mime: string, cb: GenericCallback): this; - getBufferAsync(mime: string): Promise; - getPixelIndex( - x: number, - y: number, - cb?: GenericCallback - ): number; - getPixelIndex( - x: number, - y: number, - edgeHandling: string, - cb?: GenericCallback - ): number; - getPixelColor( - x: number, - y: number, - cb?: GenericCallback - ): number; - getPixelColour( - x: number, - y: number, - cb?: GenericCallback - ): number; - setPixelColor(hex: number, x: number, y: number, cb?: ImageCallback): this; - setPixelColour(hex: number, x: number, y: number, cb?: ImageCallback): this; - clone(cb?: ImageCallback): this; - cloneQuiet(cb?: ImageCallback): this; - background(hex: number, cb?: ImageCallback): this; - backgroundQuiet(hex: number, cb?: ImageCallback): this; - scan( - x: number, - y: number, - w: number, - h: number, - f: (this: this, x: number, y: number, idx: number) => any, - cb?: ImageCallback - ): this; - scanQuiet( - x: number, - y: number, - w: number, - h: number, - f: (this: this, x: number, y: number, idx: number) => any, - cb?: ImageCallback - ): this; - scanIterator( - x: number, - y: number, - w: number, - h: number - ): IterableIterator<{x: number, y: number, idx: number, image: Jimp}>; - - // Effect methods - composite( - src: Jimp, - x: number, - y: number, - options?: BlendMode, - cb?: ImageCallback - ): this; - - // Functions - appendConstructorOption( - name: string, - test: (...args: T[]) => boolean, - run: ( - this: Jimp, - resolve: (jimp: Jimp) => any, - reject: (reason: Error) => any, - ...args: T[] - ) => any - ): void; - read(path: string): Promise; - read(image: Jimp): Promise; - read(data: Buffer): Promise; - read(w: number, h: number, background?: number | string): Promise; - create(path: string): Promise; - create(image: Jimp): Promise; - create(data: Buffer): Promise; - create(w: number, h: number, background?: number | string): Promise; - rgbaToInt( - r: number, - g: number, - b: number, - a: number, - cb: GenericCallback - ): number; - intToRGBA(i: number, cb?: GenericCallback): RGBA; - cssColorToHex(cssColor: string): number; - limit255(n: number): number; - diff( - img1: Jimp, - img2: Jimp, - threshold?: number - ): { - percent: number; - image: Jimp; - }; - distance(img1: Jimp, img2: Jimp): number; - compareHashes(hash1: string, hash2: string): number; - colorDiff(rgba1: RGB, rgba2: RGB): number; - colorDiff(rgba1: RGBA, rgba2: RGBA): number; -} - -export interface Image { - bitmap: Bitmap; -} - -// This must be exported to fix the "index signature missing" error -export interface IllformedPlugin { - class?: never; - constants?: never; - [classFunc: string]: Function -} - -export type DecoderFn = (data: Buffer) => Bitmap -export type EncoderFn = (image: ImageType) => Buffer - -interface WellFormedPlugin { - mime?: { - [MIME_TYPE: string]: string[]; - }; - hasAlpha?: { - [MIME_SPECIAL: string]: boolean; - }; - constants?: { - // Contants to assign to the Jimp instance - [MIME_SPECIAL: string]: any; - }; - decoders?: { - [MIME_TYPE: string]: DecoderFn; - }; - encoders?: { - // Jimp Image - [MIME_TYPE: string]: EncoderFn; - }; - // Extend the Jimp class with the following constants, etc - class?: any; -} - -type ClassOrConstantPlugin = WellFormedPlugin & ( - Required, 'class'>> | Required, 'constants'>> - ); - -// A Jimp type requires mime, but not class -export type JimpType = WellFormedPlugin & Required, 'mime'>>; - -// Jimp plugin either MUST have class OR constant or be illformed -export type JimpPlugin = ClassOrConstantPlugin | IllformedPlugin; - -export type PluginFunction = () => JimpPlugin; -export type TypeFunction = () => JimpType; - -// This is required as providing type arrays gives a union of all the generic -// types in the array rather than an intersection -type UnionToIntersection = - (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never - -// The values to be extracted from a WellFormedPlugin to put onto the Jimp instance -type WellFormedValues = T['class'] & T['constants']; - -// Jimp generic to be able to put plugins and types into, thus allowing -// `configure` from `@jimp/custom` to have proper typings -export type Jimp = - BaseJimp - & UnionToIntersection> - & UnionToIntersection<(P extends WellFormedPlugin ? WellFormedValues

: P)> - -export type GenericCallback = ( - this: TThis, - err: Error | null, - value: T -) => U; - -export type ImageCallback = ( - this: Jimp, - err: Error | null, - value: Jimp, - coords: { - x: number; - y: number; - } -) => U; - -type BlendMode = { - mode: string; - opacitySource: number; - opacityDest: number; -}; - -type ChangeName = 'background' | 'scan' | 'crop'; - -type ListenableName = - | 'any' - | 'initialized' - | 'before-change' - | 'changed' - | 'before-clone' - | 'cloned' - | ChangeName; - -type ListenerData = T extends 'any' - ? any - : T extends ChangeName - ? { - eventName: 'before-change' | 'changed'; - methodName: T; - [key: string]: any; - } - : { - eventName: T; - methodName: T extends 'initialized' - ? 'constructor' - : T extends 'before-change' | 'changed' - ? ChangeName - : T extends 'before-clone' | 'cloned' ? 'clone' : any; - }; - -type URLOptions = { - url: string; - compression?: boolean; - headers: { - [key: string]: any; - }; -}; - -export interface Bitmap { - data: Buffer; - width: number; - height: number; -} - -export interface RGB { - r: number; - g: number; - b: number; -} - -export interface RGBA { - r: number; - g: number; - b: number; - a: number; -} - -export default Jimp; diff --git a/packages/core/package.json b/packages/core/package.json index 006fafc33..95fdc7e72 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -4,7 +4,7 @@ "description": "Jimp core", "main": "dist/index.js", "module": "es/index.js", - "types": "index.d.ts", + "types": "types/index.d.ts", "files": [ "dist", "es", diff --git a/packages/core/types/etc.d.ts b/packages/core/types/etc.d.ts new file mode 100644 index 000000000..18b20f6e2 --- /dev/null +++ b/packages/core/types/etc.d.ts @@ -0,0 +1,87 @@ +import {Jimp} from './jimp'; + +export interface Image { + bitmap: Bitmap; +} + +export type DecoderFn = (data: Buffer) => Bitmap; +export type EncoderFn = ( + image: ImageType +) => Buffer; + +export type GenericCallback = ( + this: TThis, + err: Error | null, + value: T +) => U; + +export type ImageCallback = ( + this: Jimp, + err: Error | null, + value: Jimp, + coords: { + x: number; + y: number; + } +) => U; + +type BlendMode = { + mode: string; + opacitySource: number; + opacityDest: number; +}; + +type ChangeName = 'background' | 'scan' | 'crop'; + +type ListenableName = + | 'any' + | 'initialized' + | 'before-change' + | 'changed' + | 'before-clone' + | 'cloned' + | ChangeName; + +type ListenerData = T extends 'any' + ? any + : T extends ChangeName + ? { + eventName: 'before-change' | 'changed'; + methodName: T; + [key: string]: any; + } + : { + eventName: T; + methodName: T extends 'initialized' + ? 'constructor' + : T extends 'before-change' | 'changed' + ? ChangeName + : T extends 'before-clone' | 'cloned' ? 'clone' : any; + }; + +type URLOptions = { + url: string; + compression?: boolean; + headers: { + [key: string]: any; + }; +}; + +export interface Bitmap { + data: Buffer; + width: number; + height: number; +} + +export interface RGB { + r: number; + g: number; + b: number; +} + +export interface RGBA { + r: number; + g: number; + b: number; + a: number; +} diff --git a/packages/core/types/functions.d.ts b/packages/core/types/functions.d.ts new file mode 100644 index 000000000..54eaf5715 --- /dev/null +++ b/packages/core/types/functions.d.ts @@ -0,0 +1,17 @@ +import {Jimp} from './jimp'; + +export function addConstants( + constants: [string, string | number], + jimpInstance?: Jimp +): void; +export function addJimpMethods( + methods: [string, Function], + jimpInstance?: Jimp +): void; +export function jimpEvMethod( + methodName: string, + evName: string, + method: Function +): void; +export function jimpEvChange(methodName: string, method: Function): void; +export function addType(mime: string, extensions: string[]): void; diff --git a/packages/core/types/index.d.ts b/packages/core/types/index.d.ts new file mode 100644 index 000000000..c53d3c251 --- /dev/null +++ b/packages/core/types/index.d.ts @@ -0,0 +1,9 @@ +export * from './etc'; +export * from './functions'; +export * from './plugins'; +export * from './utils'; +import {Jimp} from './jimp'; + +export { Jimp }; +declare const defaultExp: Jimp; +export default defaultExp; diff --git a/packages/core/types/jimp.d.ts b/packages/core/types/jimp.d.ts new file mode 100644 index 000000000..715977f22 --- /dev/null +++ b/packages/core/types/jimp.d.ts @@ -0,0 +1,189 @@ +import { + Bitmap, + ImageCallback, + URLOptions, + ListenableName, + ListenerData, + GenericCallback, + BlendMode, + RGBA, + RGB +} from './etc'; + +export declare class Jimp { + // Constructors + constructor(path: string, cb?: ImageCallback); + constructor(urlOptions: URLOptions, cb?: ImageCallback); + constructor(image: Jimp, cb?: ImageCallback); + constructor(data: Buffer, cb?: ImageCallback); + constructor(data: Bitmap, cb?: ImageCallback); + constructor(w: number, h: number, cb?: ImageCallback); + constructor( + w: number, + h: number, + background?: number | string, + cb?: ImageCallback + ); + // For custom constructors when using Jimp.appendConstructorOption + constructor(...args: any[]); + prototype: this; + // Constants + AUTO: -1; + // blend modes + BLEND_SOURCE_OVER: string; + BLEND_DESTINATION_OVER: string; + BLEND_MULTIPLY: string; + BLEND_SCREEN: string; + BLEND_OVERLAY: string; + BLEND_DARKEN: string; + BLEND_LIGHTEN: string; + BLEND_HARDLIGHT: string; + BLEND_DIFFERENCE: string; + BLEND_EXCLUSION: string; + // Align modes for cover, contain, bit masks + HORIZONTAL_ALIGN_LEFT: 1; + HORIZONTAL_ALIGN_CENTER: 2; + HORIZONTAL_ALIGN_RIGHT: 4; + VERTICAL_ALIGN_TOP: 8; + VERTICAL_ALIGN_MIDDLE: 16; + VERTICAL_ALIGN_BOTTOM: 32; + // Edge Handling + EDGE_EXTEND: 1; + EDGE_WRAP: 2; + EDGE_CROP: 3; + // Properties + bitmap: Bitmap; + _rgba: boolean; + _background: number; + _originalMime: string; + // Methods + on( + event: T, + cb: (data: ListenerData) => any + ): any; + parseBitmap( + data: Buffer, + path: string | null | undefined, + cb?: ImageCallback + ): void; + hasAlpha(): boolean; + getHeight(): number; + getWidth(): number; + inspect(): string; + toString(): string; + getMIME(): string; + getExtension(): string; + distanceFromHash(hash: string): number; + write(path: string, cb?: ImageCallback): this; + writeAsync(path: string): Promise; + rgba(bool: boolean, cb?: ImageCallback): this; + getBase64(mime: string, cb: GenericCallback): this; + getBase64Async(mime: string): Promise; + hash(cb?: GenericCallback): string; + hash( + base: number | null | undefined, + cb?: GenericCallback + ): string; + getBuffer(mime: string, cb: GenericCallback): this; + getBufferAsync(mime: string): Promise; + getPixelIndex( + x: number, + y: number, + cb?: GenericCallback + ): number; + getPixelIndex( + x: number, + y: number, + edgeHandling: string, + cb?: GenericCallback + ): number; + getPixelColor( + x: number, + y: number, + cb?: GenericCallback + ): number; + getPixelColour( + x: number, + y: number, + cb?: GenericCallback + ): number; + setPixelColor(hex: number, x: number, y: number, cb?: ImageCallback): this; + setPixelColour(hex: number, x: number, y: number, cb?: ImageCallback): this; + clone(cb?: ImageCallback): this; + cloneQuiet(cb?: ImageCallback): this; + background(hex: number, cb?: ImageCallback): this; + backgroundQuiet(hex: number, cb?: ImageCallback): this; + scan( + x: number, + y: number, + w: number, + h: number, + f: (this: this, x: number, y: number, idx: number) => any, + cb?: ImageCallback + ): this; + scanQuiet( + x: number, + y: number, + w: number, + h: number, + f: (this: this, x: number, y: number, idx: number) => any, + cb?: ImageCallback + ): this; + scanIterator( + x: number, + y: number, + w: number, + h: number + ): IterableIterator<{ x: number; y: number; idx: number; image: Jimp }>; + + // Effect methods + composite( + src: Jimp, + x: number, + y: number, + options?: BlendMode, + cb?: ImageCallback + ): this; + + // Functions + appendConstructorOption( + name: string, + test: (...args: T[]) => boolean, + run: ( + this: Jimp, + resolve: (jimp: Jimp) => any, + reject: (reason: Error) => any, + ...args: T[] + ) => any + ): void; + read(path: string): Promise; + read(image: Jimp): Promise; + read(data: Buffer): Promise; + read(w: number, h: number, background?: number | string): Promise; + create(path: string): Promise; + create(image: Jimp): Promise; + create(data: Buffer): Promise; + create(w: number, h: number, background?: number | string): Promise; + rgbaToInt( + r: number, + g: number, + b: number, + a: number, + cb: GenericCallback + ): number; + intToRGBA(i: number, cb?: GenericCallback): RGBA; + cssColorToHex(cssColor: string): number; + limit255(n: number): number; + diff( + img1: Jimp, + img2: Jimp, + threshold?: number + ): { + percent: number; + image: Jimp; + }; + distance(img1: Jimp, img2: Jimp): number; + compareHashes(hash1: string, hash2: string): number; + colorDiff(rgba1: RGB, rgba2: RGB): number; + colorDiff(rgba1: RGBA, rgba2: RGBA): number; +} diff --git a/packages/core/types/plugins.d.ts b/packages/core/types/plugins.d.ts new file mode 100644 index 000000000..e5867d17c --- /dev/null +++ b/packages/core/types/plugins.d.ts @@ -0,0 +1,57 @@ +/** + * These files pertain to the typings of plugins or types + * + * They're not meant as utils to decode types, but rather + * the type definitons themsleves for plugins and types of various kinds + */ +import { + Image, + EncoderFn, + DecoderFn +} from './etc'; + +import { + Omit +} from './utils'; + +export type IllformedPlugin = Omit & { + class?: never; + constants?: never; +} + +export interface WellFormedPlugin { + mime?: { + [MIME_TYPE: string]: string[]; + }; + hasAlpha?: { + [MIME_SPECIAL: string]: boolean; + }; + constants?: { + // Contants to assign to the Jimp instance + [MIME_SPECIAL: string]: any; + }; + decoders?: { + [MIME_TYPE: string]: DecoderFn; + }; + encoders?: { + // Jimp Image + [MIME_TYPE: string]: EncoderFn; + }; + // Extend the Jimp class with the following constants, etc + class?: any; +} + +type ClassOrConstantPlugin = WellFormedPlugin & + ( + | Required, 'class'>> + | Required, 'constants'>> + ); + +// A Jimp type requires mime, but not class +export type JimpType = WellFormedPlugin & + Required, 'mime'>>; + +// Jimp plugin either MUST have class OR constant or be illformed +export type JimpPlugin = + | ClassOrConstantPlugin + | IllformedPlugin; diff --git a/packages/core/types/utils.d.ts b/packages/core/types/utils.d.ts new file mode 100644 index 000000000..fa773bce1 --- /dev/null +++ b/packages/core/types/utils.d.ts @@ -0,0 +1,54 @@ +import { + WellFormedPlugin, + JimpType, + JimpPlugin, +} from './plugins'; + +// This is required as providing type arrays gives a union of all the generic +// types in the array rather than an intersection +export type UnionToIntersection = + (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never; + +/** + * The values to be extracted from a WellFormedPlugin to put onto the Jimp instance + * Left loose as "any" in order to enable the GetPluginValue to work properly + */ +export type WellFormedValues = + T['class'] & + T['constants']; + +// Util type for the functions that deal with `@jimp/custom` +// Must accept any or no props thanks to typing of the `plugins` intersected function +export type FunctionRet = Array<(...props: any[] | never) => T>; + +/** + * This conditional cannot be flipped. TS assumes that Q is `WellFormed` even + * it does not have the `class` or `constant` props. As a result, it will end + * up `undefined`. Because we're always extending `IllformedPlugin` on the + * plugins, this should work fine + */ +export type GetPluginVal = Q extends Required<{class: any}> | Required<{constant: any}> + ? WellFormedValues + : Q; + +type GetPluginFuncArrValues = + // Given an array of types infer `Q` (Q should be the type value) + PluginFuncArr extends Array<() => infer Q> + ? // Get the plugin value, may be ill-formed or well-formed + GetPluginVal + : // This should never be reached + undefined; + +/** + * A helper type to get the values to be intersected with `Jimp` to give + * the proper typing given an array of functions for plugins and types + */ +export type GetIntersectionFromPlugins< + PluginFuncArr extends FunctionRet +> = UnionToIntersection>; + +/** + * While this was added to TS 3.5, in order to support down to TS 2.8, we need + * to export this and use it in sub-packges that utilize it + */ +export type Omit = Pick>; diff --git a/packages/custom/index.d.ts b/packages/custom/index.d.ts deleted file mode 100644 index 2413bb64a..000000000 --- a/packages/custom/index.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { - Jimp, - JimpPlugin, - JimpType, - TypeFunction, - PluginFunction -} from '@jimp/core'; - -export default function configure(configuration: { - types?: TypeFunction[], - plugins?: PluginFunction[] -}, jimpInstance?: JimpInst): JimpInst & Jimp; diff --git a/packages/custom/package.json b/packages/custom/package.json index d02cf25ab..c359e3928 100644 --- a/packages/custom/package.json +++ b/packages/custom/package.json @@ -4,7 +4,7 @@ "description": "Interface to customize jimp configuration", "main": "dist/index.js", "module": "es/index.js", - "types": "index.d.ts", + "types": "types/index.d.ts", "scripts": { "build": "npm run build:node:production && npm run build:module", "build:watch": "npm run build:node:debug -- -- --watch --verbose", diff --git a/packages/custom/types/index.d.ts b/packages/custom/types/index.d.ts new file mode 100644 index 000000000..5ae06a01b --- /dev/null +++ b/packages/custom/types/index.d.ts @@ -0,0 +1,48 @@ +// TypeScript Version: 3.1 +// See the `jimp` package index.d.ts for why the version is not 2.8 +import { + FunctionRet, + Jimp, + JimpPlugin, + JimpType, + GetIntersectionFromPlugins +} from '@jimp/core'; + +declare function configure< + PluginFuncArr extends FunctionRet, + JimpInstance extends Jimp = Jimp +>( + configuration: { + plugins: PluginFuncArr; + }, + jimpInstance?: JimpInstance +): Exclude & + GetIntersectionFromPlugins; + +declare function configure< + TypesFuncArr extends FunctionRet, + JimpInstance extends Jimp = Jimp +>( + configuration: { + types: TypesFuncArr; + }, + jimpInstance?: JimpInstance +): Exclude & + GetIntersectionFromPlugins; + +declare function configure< + TypesFuncArr extends FunctionRet, + PluginFuncArr extends FunctionRet, + JimpInstance extends Jimp = Jimp +>( + configuration: { + types?: TypesFuncArr; + plugins?: PluginFuncArr; + }, + jimpInstance?: JimpInstance + // Since JimpInstance is required, we want to use the default `Jimp` type +): Exclude & + GetIntersectionFromPlugins & + GetIntersectionFromPlugins; + + export default configure; diff --git a/packages/custom/types/test.ts b/packages/custom/types/test.ts new file mode 100644 index 000000000..3cf91dfe8 --- /dev/null +++ b/packages/custom/types/test.ts @@ -0,0 +1,152 @@ +import configure from '@jimp/custom'; +import gif from '@jimp/gif'; +import png from '@jimp/png'; +import displace from '@jimp/plugin-displace'; +import resize from '@jimp/plugin-resize'; +import scale from '@jimp/plugin-scale'; +import types from '@jimp/types'; +import plugins from '@jimp/plugins'; + +// configure should return a valid Jimp type with addons +const CustomJimp = configure({ + types: [gif, png], + plugins: [displace, resize] +}); + +// Methods from types should be applied +CustomJimp.deflateLevel(4); +// Constants from types should be applied +// $ExpectType 0 +CustomJimp.PNG_FILTER_NONE; + +// Core functions should still work from Jimp +CustomJimp.read('Test'); + +// Constants should be applied from ill-formed plugins +CustomJimp.displace(CustomJimp, 2); + +// Methods should be applied from well-formed plugins +CustomJimp.resize(40, 40) + +// Constants should be applied from well-formed plugins +CustomJimp.RESIZE_NEAREST_NEIGHBOR + +// $ExpectError +CustomJimp.test; + +// $ExpectError +CustomJimp.func(); + +test('can compose', () => { + const OtherCustomJimp = configure({ + plugins: [scale] + }, CustomJimp); + + // Methods from new plugins should be applied + OtherCustomJimp.scale(3); + + // Methods from types should be applied + OtherCustomJimp.filterType(4); + // Constants from types should be applied + // $ExpectType 0 + OtherCustomJimp.PNG_FILTER_NONE; + + // Core functions should still work from Jimp + OtherCustomJimp.read('Test'); + + // Constants should be applied from ill-formed plugins + OtherCustomJimp.displace(OtherCustomJimp, 2); + + // Methods should be applied from well-formed plugins + OtherCustomJimp.resize(40, 40); + + // Constants should be applied from well-formed plugins + OtherCustomJimp.RESIZE_NEAREST_NEIGHBOR; + + // $ExpectError + OtherCustomJimp.test; + + // $ExpectError + OtherCustomJimp.func(); +}); + +test('can handle only plugins', () => { + const PluginsJimp = configure({ + plugins: [plugins] + }); + + // Core functions should still work from Jimp + PluginsJimp.read('Test'); + + // Constants should be applied from ill-formed plugins + PluginsJimp.displace(PluginsJimp, 2); + + // Methods should be applied from well-formed plugins + PluginsJimp.resize(40, 40); + + // Constants should be applied from well-formed plugins + // $ExpectType "nearestNeighbor" + PluginsJimp.RESIZE_NEAREST_NEIGHBOR; + + // $ExpectError + PluginsJimp.test; + + // $ExpectError + PluginsJimp.func(); +}) + +test('can handle only all types', () => { + const TypesJimp = configure({ + types: [types] + }); + + // Methods from types should be applied + TypesJimp.filterType(4); + // Constants from types should be applied + // Commented for complexity errors + // $ExpectType 0 + TypesJimp.PNG_FILTER_NONE; + + // $ExpectError + TypesJimp.test; + + // $ExpectError + TypesJimp.func(); +}); + +test('can handle only one type', () => { + const PngJimp = configure({ + types: [png] + }); + + // Constants from types should be applied + // Commented for complexity errors + // $ExpectType 0 + PngJimp.PNG_FILTER_NONE; + + // $ExpectError + PngJimp.test; + + // $ExpectError + PngJimp.func(); +}); + + +test('can handle only one plugin', () => { + const PngJimp = configure({ + plugins: [resize] + }); + + // Constants from types should be applied + // Commented for complexity errors + // $ExpectType "nearestNeighbor" + PngJimp.RESIZE_NEAREST_NEIGHBOR; + + PngJimp.resize(2, 2); + + // $ExpectError + PngJimp.test; + + // $ExpectError + PngJimp.func(); +}); diff --git a/packages/custom/types/tsconfig.json b/packages/custom/types/tsconfig.json new file mode 100644 index 000000000..dcfe450fd --- /dev/null +++ b/packages/custom/types/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "noEmit": true, + + // If the library is an external module (uses `export`), this allows your test file to import "mylib" instead of "./index". + // If the library is global (cannot be imported via `import` or `require`), leave this out. + "baseUrl": ".", + "paths": { + "mylib": ["."] + } + } +} diff --git a/packages/jimp/index.d.ts b/packages/jimp/index.d.ts deleted file mode 100644 index 6256448a8..000000000 --- a/packages/jimp/index.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { - Jimp as JimpType, - Bitmap, - RGB, - RGBA -} from '@jimp/core'; -import typeFn from '@jimp/types'; -import pluginFn from '@jimp/plugins'; - -type Types = ReturnType; -type Plugins = ReturnType; - -declare const Jimp: JimpType; -export default Jimp; - -export { - Bitmap, - RGB, - RGBA -} - -export { - FontChar, - FontInfo, - FontCommon, - Font -} from '@jimp/plugin-print'; diff --git a/packages/jimp/package.json b/packages/jimp/package.json index a58ae3b71..24b4f4a42 100644 --- a/packages/jimp/package.json +++ b/packages/jimp/package.json @@ -5,7 +5,14 @@ "main": "dist/index.js", "module": "es/index.js", "browser": "browser/lib/jimp.js", - "types": "index.d.ts", + "types": "types/index.d.ts", + "typesVersions": { + ">=3.1.0-0": { + "*": [ + "types/ts3.1/index.d.ts" + ] + } + }, "tonicExampleFilename": "example.js", "files": [ "browser", diff --git a/packages/jimp/types/index.d.ts b/packages/jimp/types/index.d.ts new file mode 100644 index 000000000..74f0dc9da --- /dev/null +++ b/packages/jimp/types/index.d.ts @@ -0,0 +1,590 @@ +// TypeScript Version: 2.8 + +/** + * @deprecated Jimp typings for TS <3.1 are being depreciated. Please upgrade your TypeScript version + */ +declare class Jimp { + // Constructors + constructor(path: string, cb?: ImageCallback); + constructor(urlOptions: URLOptions, cb?: ImageCallback); + constructor(image: Jimp, cb?: ImageCallback); + constructor(data: Buffer | Bitmap, cb?: ImageCallback); + constructor(w: number, h: number, cb?: ImageCallback); + constructor( + w: number, + h: number, + background?: number | string, + cb?: ImageCallback + ); + // For custom constructors when using Jimp.appendConstructorOption + constructor(...args: any[]); + prototype: Jimp; + + // Constants + AUTO: -1; + + // supported mime types + MIME_PNG: 'image/png'; + MIME_TIFF: 'image/tiff'; + MIME_JPEG: 'image/jpeg'; + MIME_JGD: 'image/jgd'; + MIME_BMP: 'image/bmp'; + MIME_X_MS_BMP: 'image/x-ms-bmp'; + MIME_GIF: 'image/gif'; + // PNG filter types + PNG_FILTER_AUTO: -1; + PNG_FILTER_NONE: 0; + PNG_FILTER_SUB: 1; + PNG_FILTER_UP: 2; + PNG_FILTER_AVERAGE: 3; + PNG_FILTER_PATH: 4; + + // resize methods + RESIZE_NEAREST_NEIGHBOR: 'nearestNeighbor'; + RESIZE_BILINEAR: 'bilinearInterpolation'; + RESIZE_BICUBIC: 'bicubicInterpolation'; + RESIZE_HERMITE: 'hermiteInterpolation'; + RESIZE_BEZIER: 'bezierInterpolation'; + + // blend modes + BLEND_SOURCE_OVER: string; + BLEND_DESTINATION_OVER: string; + BLEND_MULTIPLY: string; + BLEND_SCREEN: string; + BLEND_OVERLAY: string; + BLEND_DARKEN: string; + BLEND_LIGHTEN: string; + BLEND_HARDLIGHT: string; + BLEND_DIFFERENCE: string; + BLEND_EXCLUSION: string; + + // Align modes for cover, contain, bit masks + HORIZONTAL_ALIGN_LEFT: 1; + HORIZONTAL_ALIGN_CENTER: 2; + HORIZONTAL_ALIGN_RIGHT: 4; + + VERTICAL_ALIGN_TOP: 8; + VERTICAL_ALIGN_MIDDLE: 16; + VERTICAL_ALIGN_BOTTOM: 32; + + // Font locations + FONT_SANS_8_BLACK: string; + FONT_SANS_10_BLACK: string; + FONT_SANS_12_BLACK: string; + FONT_SANS_14_BLACK: string; + FONT_SANS_16_BLACK: string; + FONT_SANS_32_BLACK: string; + FONT_SANS_64_BLACK: string; + FONT_SANS_128_BLACK: string; + + FONT_SANS_8_WHITE: string; + FONT_SANS_16_WHITE: string; + FONT_SANS_32_WHITE: string; + FONT_SANS_64_WHITE: string; + FONT_SANS_128_WHITE: string; + + // Edge Handling + EDGE_EXTEND: 1; + EDGE_WRAP: 2; + EDGE_CROP: 3; + + // Properties + bitmap: Bitmap; + + _quality: number; + _deflateLevel: number; + _deflateStrategy: number; + _filterType: number; + _rgba: boolean; + _background: number; + _originalMime: string; + + // Methods + on( + event: T, + cb: (data: ListenerData) => any + ): any; + parseBitmap( + data: Buffer, + path: string | null | undefined, + cb?: ImageCallback + ): void; + hasAlpha(): boolean; + getHeight(): number; + getWidth(): number; + inspect(): string; + toString(): string; + getMIME(): string; + getExtension(): string; + distanceFromHash(hash: string): number; + write(path: string, cb?: ImageCallback): this; + writeAsync(path: string): Promise; + deflateLevel(l: number, cb?: ImageCallback): this; + deflateStrategy(s: number, cb?: ImageCallback): this; + colorType(s: number, cb?: ImageCallback): this; + filterType(f: number, cb?: ImageCallback): this; + rgba(bool: boolean, cb?: ImageCallback): this; + quality(n: number, cb?: ImageCallback): this; + getBase64(mime: string, cb: GenericCallback): this; + getBase64Async(mime: string): Promise; + hash(cb?: GenericCallback): string; + hash( + base: number | null | undefined, + cb?: GenericCallback + ): string; + getBuffer(mime: string, cb: GenericCallback): this; + getBufferAsync(mime: string): Promise; + getPixelIndex( + x: number, + y: number, + cb?: GenericCallback + ): number; + getPixelIndex( + x: number, + y: number, + edgeHandling: string, + cb?: GenericCallback + ): number; + getPixelColor( + x: number, + y: number, + cb?: GenericCallback + ): number; + getPixelColour( + x: number, + y: number, + cb?: GenericCallback + ): number; + setPixelColor(hex: number, x: number, y: number, cb?: ImageCallback): this; + setPixelColour(hex: number, x: number, y: number, cb?: ImageCallback): this; + clone(cb?: ImageCallback): this; + cloneQuiet(cb?: ImageCallback): this; + background(hex: number, cb?: ImageCallback): this; + backgroundQuiet(hex: number, cb?: ImageCallback): this; + scan( + x: number, + y: number, + w: number, + h: number, + f: (this: this, x: number, y: number, idx: number) => any, + cb?: ImageCallback + ): this; + scanQuiet( + x: number, + y: number, + w: number, + h: number, + f: (this: this, x: number, y: number, idx: number) => any, + cb?: ImageCallback + ): this; + scanIterator( + x: number, + y: number, + w: number, + h: number + ): IterableIterator<{ x: number; y: number; idx: number; image: Jimp }>; + crop(x: number, y: number, w: number, h: number, cb?: ImageCallback): this; + cropQuiet( + x: number, + y: number, + w: number, + h: number, + cb?: ImageCallback + ): this; + + // Color methods + brightness(val: number, cb?: ImageCallback): this; + contrast(val: number, cb?: ImageCallback): this; + posterize(n: number, cb?: ImageCallback): this; + greyscale(cb?: ImageCallback): this; + grayscale(cb?: ImageCallback): this; + opacity(f: number, cb?: ImageCallback): this; + sepia(cb?: ImageCallback): this; + fade(f: number, cb?: ImageCallback): this; + convolution(kernel: number[][], cb?: ImageCallback): this; + convolution( + kernel: number[][], + edgeHandling: string, + cb?: ImageCallback + ): this; + opaque(cb?: ImageCallback): this; + pixelate(size: number, cb?: ImageCallback): this; + pixelate( + size: number, + x: number, + y: number, + w: number, + h: number, + cb?: ImageCallback + ): this; + convolute(kernel: number[][], cb?: ImageCallback): this; + convolute( + kernel: number[][], + x: number, + y: number, + w: number, + h: number, + cb?: ImageCallback + ): this; + color(actions: ColorAction[], cb?: ImageCallback): this; + colour(actions: ColorAction[], cb?: ImageCallback): this; + + // Shape methods + rotate(deg: number, cb?: ImageCallback): this; + rotate(deg: number, mode: string | boolean, cb?: ImageCallback): this; + flip(horizontal: boolean, vertical: boolean, cb?: ImageCallback): this; + mirror(horizontal: boolean, vertical: boolean, cb?: ImageCallback): this; + resize(w: number, h: number, cb?: ImageCallback): this; + resize(w: number, h: number, mode?: string, cb?: ImageCallback): this; + cover(w: number, h: number, cb?: ImageCallback): this; + cover(w: number, h: number, alignBits?: number, cb?: ImageCallback): this; + cover( + w: number, + h: number, + alignBits?: number, + mode?: string, + cb?: ImageCallback + ): this; + contain(w: number, h: number, cb?: ImageCallback): this; + contain(w: number, h: number, mode?: string, cb?: ImageCallback): this; + contain(w: number, h: number, alignBits?: number, cb?: ImageCallback): this; + contain( + w: number, + h: number, + alignBits?: number, + mode?: string, + cb?: ImageCallback + ): this; + scale(f: number, cb?: ImageCallback): this; + scale(f: number, mode?: string, cb?: ImageCallback): this; + scaleToFit(w: number, h: number, cb?: ImageCallback): this; + scaleToFit(w: number, h: number, mode?: string, cb?: ImageCallback): this; + displace(map: Jimp, offset: number, cb?: ImageCallback): this; + autocrop(tolerance?: number, cb?: ImageCallback): this; + autocrop(cropOnlyFrames?: boolean, cb?: ImageCallback): this; + autocrop( + tolerance?: number, + cropOnlyFrames?: boolean, + cb?: ImageCallback + ): this; + autocrop( + options: { + tolerance?: number; + cropOnlyFrames?: boolean; + cropSymmetric?: boolean; + leaveBorder?: number; + }, + cb?: ImageCallback + ): this; + + // Text methods + print( + font: Font, + x: number, + y: number, + text: PrintableText, + cb?: ImageCallback + ): this; + print( + font: Font, + x: number, + y: number, + text: PrintableText, + maxWidth?: number, + cb?: ImageCallback + ): this; + print( + font: Font, + x: number, + y: number, + text: PrintableText, + maxWidth?: number, + maxHeight?: number, + cb?: ImageCallback + ): this; + + // Effect methods + blur(r: number, cb?: ImageCallback): this; + dither565(cb?: ImageCallback): this; + dither16(cb?: ImageCallback): this; + histogram(): { + r: number[]; + g: number[]; + b: number[]; + }; + normalize(cb?: ImageCallback): this; + invert(cb?: ImageCallback): this; + gaussian(r: number, cb?: ImageCallback): this; + composite( + src: Jimp, + x: number, + y: number, + options?: BlendMode, + cb?: ImageCallback + ): this; + blit(src: Jimp, x: number, y: number, cb?: ImageCallback): this; + blit( + src: Jimp, + x: number, + y: number, + srcx: number, + srcy: number, + srcw: number, + srch: number, + cb?: ImageCallback + ): this; + mask(src: Jimp, x: number, y: number, cb?: ImageCallback): this; + + // Functions + appendConstructorOption( + name: string, + test: (...args: T[]) => boolean, + run: ( + this: Jimp, + resolve: (jimp: Jimp) => any, + reject: (reason: Error) => any, + ...args: T[] + ) => any + ): void; + read(path: string): Promise; + read(image: Jimp): Promise; + read(data: Buffer): Promise; + read(w: number, h: number, background?: number | string): Promise; + create(path: string): Promise; + create(image: Jimp): Promise; + create(data: Buffer): Promise; + create(w: number, h: number, background?: number | string): Promise; + rgbaToInt( + r: number, + g: number, + b: number, + a: number, + cb: GenericCallback + ): number; + intToRGBA(i: number, cb?: GenericCallback): RGBA; + cssColorToHex(cssColor: string): number; + limit255(n: number): number; + diff( + img1: Jimp, + img2: Jimp, + threshold?: number + ): { + percent: number; + image: Jimp; + }; + distance(img1: Jimp, img2: Jimp): number; + compareHashes(hash1: string, hash2: string): number; + colorDiff(rgba1: RGB, rgba2: RGB): number; + colorDiff(rgba1: RGBA, rgba2: RGBA): number; + loadFont(file: string): Promise; + loadFont(file: string, cb: GenericCallback): Promise; + measureText(font: Font, text: PrintableText): number; + measureTextHeight(font: Font, text: PrintableText, maxWidth: number): number; + circle( + options?: { + radius: number; + x: number; + y: number; + }, + cb?: ImageCallback + ): this; + circle(cb?: ImageCallback): this; + fishEye(opts?: { r: number }, cb?: ImageCallback): this; + fishEye(cb?: ImageCallback): this; + shadow( + options?: { + size?: number; + opacity?: number; + x?: number; + y?: number; + }, + cb?: ImageCallback + ): this; + shadow(cb?: ImageCallback): this; + threshold( + opts: { + max: number; + replace?: number; + autoGreyscale?: boolean; + }, + cb?: ImageCallback + ): this; +} + +declare const JimpInst: Jimp; + +export default JimpInst; + +type GenericCallback = ( + this: TThis, + err: Error | null, + value: T +) => U; + +type ImageCallback = ( + this: Jimp, + err: Error | null, + value: Jimp, + coords: { + x: number; + y: number; + } +) => U; + +type ColorActionName = + | 'mix' + | 'tint' + | 'shade' + | 'xor' + | 'red' + | 'green' + | 'blue' + | 'hue'; + +type ColorAction = { + apply: ColorActionName; + params: any; +}; + +type BlendMode = { + mode: string; + opacitySource: number; + opacityDest: number; +}; + +type ChangeName = 'background' | 'scan' | 'crop'; + +type ListenableName = + | 'any' + | 'initialized' + | 'before-change' + | 'changed' + | 'before-clone' + | 'cloned' + | ChangeName; + +type ListenerData = T extends 'any' + ? any + : T extends ChangeName + ? { + eventName: 'before-change' | 'changed'; + methodName: T; + [key: string]: any; + } + : { + eventName: T; + methodName: T extends 'initialized' + ? 'constructor' + : T extends 'before-change' | 'changed' + ? ChangeName + : T extends 'before-clone' | 'cloned' ? 'clone' : any; + }; + +type PrintableText = + | any + | { + text: string; + alignmentX: number; + alignmentY: number; + }; + +type URLOptions = { + url: string; + compression?: boolean; + headers: { + [key: string]: any; + }; +}; + +/** + * @deprecated Jimp typings for TS <3.1 are being depreciated. Please upgrade your TypeScript version + */ +export interface Bitmap { + data: Buffer; + width: number; + height: number; +} +/** + * @deprecated Jimp typings for TS <3.1 are being depreciated. Please upgrade your TypeScript version + */ +export interface RGB { + r: number; + g: number; + b: number; +} + +/** + * @deprecated Jimp typings for TS <3.1 are being depreciated. Please upgrade your TypeScript version + */ +export interface RGBA { + r: number; + g: number; + b: number; + a: number; +} + +/** + * @deprecated Jimp typings for TS <3.1 are being depreciated. Please upgrade your TypeScript version + */ +export interface FontChar { + id: number; + x: number; + y: number; + width: number; + height: number; + xoffset: number; + yoffset: number; + xadvance: number; + page: number; + chnl: number; +} + +/** + * @deprecated Jimp typings for TS <3.1 are being depreciated. Please upgrade your TypeScript version + */ +export interface FontInfo { + face: string; + size: number; + bold: number; + italic: number; + charset: string; + unicode: number; + stretchH: number; + smooth: number; + aa: number; + padding: [number, number, number, number]; + spacing: [number, number]; +} + +/** + * @deprecated Jimp typings for TS <3.1 are being depreciated. Please upgrade your TypeScript version + */ +export interface FontCommon { + lineHeight: number; + base: number; + scaleW: number; + scaleH: number; + pages: number; + packed: number; + alphaChnl: number; + redChnl: number; + greenChnl: number; + blueChnl: number; +} + +/** + * @deprecated Jimp typings for TS <3.1 are being depreciated. Please upgrade your TypeScript version + */ +export interface Font { + chars: { + [char: string]: FontChar; + }; + kernings: { + [firstString: string]: { + [secondString: string]: number; + }; + }; + pages: string[]; + common: FontCommon; + info: FontInfo; +} diff --git a/packages/jimp/types/test.ts b/packages/jimp/types/test.ts new file mode 100644 index 000000000..67220b5c7 --- /dev/null +++ b/packages/jimp/types/test.ts @@ -0,0 +1,14 @@ +import Jimp from 'jimp'; + +// Main Jimp export should already have all of these already applied +Jimp.read('Test'); +Jimp.displace(Jimp, 2); +Jimp.resize(40, 40); +// $ExpectType 0 +Jimp.PNG_FILTER_NONE; + +// $ExpectError +Jimp.test; + +// $ExpectError +Jimp.func(); diff --git a/packages/jimp/types/ts3.1/index.d.ts b/packages/jimp/types/ts3.1/index.d.ts new file mode 100644 index 000000000..8125aeb7b --- /dev/null +++ b/packages/jimp/types/ts3.1/index.d.ts @@ -0,0 +1,29 @@ +/** + * While there is nothing in these typings that prevent it from running in TS 2.8 even, + * due to the complexity of the typings anything lower than TS 3.1 will only see + * Jimp as `any`. In order to test the strict versions of these types in our typing + * test suite, the version has been bumped to 3.1 + */ + +import { + Jimp as JimpType, + Bitmap, + RGB, + RGBA, + WellFormedValues, + UnionToIntersection, + GetPluginVal +} from '@jimp/core'; +import typeFn from '@jimp/types'; +import pluginFn from '@jimp/plugins'; + +type Types = ReturnType; +type Plugins = ReturnType; + +export { Bitmap, RGB, RGBA }; + +export { FontChar, FontInfo, FontCommon, Font } from '@jimp/plugin-print'; + +export type FullJimpType = JimpType & UnionToIntersection> & UnionToIntersection>; +declare const Jimp: FullJimpType; +export default Jimp; diff --git a/packages/jimp/types/ts3.1/test.ts b/packages/jimp/types/ts3.1/test.ts new file mode 100644 index 000000000..67220b5c7 --- /dev/null +++ b/packages/jimp/types/ts3.1/test.ts @@ -0,0 +1,14 @@ +import Jimp from 'jimp'; + +// Main Jimp export should already have all of these already applied +Jimp.read('Test'); +Jimp.displace(Jimp, 2); +Jimp.resize(40, 40); +// $ExpectType 0 +Jimp.PNG_FILTER_NONE; + +// $ExpectError +Jimp.test; + +// $ExpectError +Jimp.func(); diff --git a/packages/jimp/types/ts3.1/tsconfig.json b/packages/jimp/types/ts3.1/tsconfig.json new file mode 100644 index 000000000..6dbbf36d9 --- /dev/null +++ b/packages/jimp/types/ts3.1/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "noEmit": true, + + // If the library is an external module (uses `export`), this allows your test file to import "mylib" instead of "./index". + // If the library is global (cannot be imported via `import` or `require`), leave this out. + "baseUrl": "../test", + "paths": { + "mylib": ["."] + } + } +} diff --git a/packages/jimp/types/tsconfig.json b/packages/jimp/types/tsconfig.json new file mode 100644 index 000000000..6dbbf36d9 --- /dev/null +++ b/packages/jimp/types/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "noEmit": true, + + // If the library is an external module (uses `export`), this allows your test file to import "mylib" instead of "./index". + // If the library is global (cannot be imported via `import` or `require`), leave this out. + "baseUrl": "../test", + "paths": { + "mylib": ["."] + } + } +} diff --git a/packages/plugin-blit/index.d.ts b/packages/plugin-blit/index.d.ts index d62d0c577..583128019 100644 --- a/packages/plugin-blit/index.d.ts +++ b/packages/plugin-blit/index.d.ts @@ -1,6 +1,6 @@ import { Jimp, ImageCallback, IllformedPlugin } from '@jimp/core'; -interface Blit extends IllformedPlugin { +interface Blit { blit(src: Jimp, x: number, y: number, cb?: ImageCallback): this; blit( src: Jimp, diff --git a/packages/plugin-blur/index.d.ts b/packages/plugin-blur/index.d.ts index e8c8b7e74..d40ab0e5a 100644 --- a/packages/plugin-blur/index.d.ts +++ b/packages/plugin-blur/index.d.ts @@ -1,6 +1,6 @@ -import { IllformedPlugin, ImageCallback } from '@jimp/core'; +import { ImageCallback } from '@jimp/core'; -interface Blur extends IllformedPlugin { +interface Blur { blur(r: number, cb?: ImageCallback): this; } diff --git a/packages/plugin-color/index.d.ts b/packages/plugin-color/index.d.ts index b77e925ad..241903a44 100644 --- a/packages/plugin-color/index.d.ts +++ b/packages/plugin-color/index.d.ts @@ -1,4 +1,4 @@ -import { IllformedPlugin, ImageCallback } from '@jimp/core'; +import { ImageCallback } from '@jimp/core'; type ColorActionName = | 'mix' @@ -15,7 +15,7 @@ type ColorAction = { params: any; }; -interface Color extends IllformedPlugin { +interface Color { brightness(val: number, cb?: ImageCallback): this; contrast(val: number, cb?: ImageCallback): this; posterize(n: number, cb?: ImageCallback): this; diff --git a/packages/plugin-contain/index.d.ts b/packages/plugin-contain/index.d.ts index 517e2fa1f..06d9e288a 100644 --- a/packages/plugin-contain/index.d.ts +++ b/packages/plugin-contain/index.d.ts @@ -1,6 +1,6 @@ -import { IllformedPlugin, ImageCallback } from '@jimp/core'; +import { ImageCallback } from '@jimp/core'; -interface Contain extends IllformedPlugin { +interface Contain { contain(w: number, h: number, cb?: ImageCallback): this; contain(w: number, h: number, mode?: string, cb?: ImageCallback): this; contain(w: number, h: number, alignBits?: number, cb?: ImageCallback): this; diff --git a/packages/plugin-cover/index.d.ts b/packages/plugin-cover/index.d.ts index 114c86642..4a50f175a 100644 --- a/packages/plugin-cover/index.d.ts +++ b/packages/plugin-cover/index.d.ts @@ -1,6 +1,6 @@ -import { IllformedPlugin, ImageCallback } from '@jimp/core'; +import { ImageCallback } from '@jimp/core'; -interface Cover extends IllformedPlugin { +interface Cover { cover(w: number, h: number, cb?: ImageCallback): this; cover(w: number, h: number, alignBits?: number, cb?: ImageCallback): this; cover( diff --git a/packages/plugin-displace/index.d.ts b/packages/plugin-displace/index.d.ts index ae8a90e2d..e2634b65d 100644 --- a/packages/plugin-displace/index.d.ts +++ b/packages/plugin-displace/index.d.ts @@ -1,6 +1,6 @@ import { Jimp, ImageCallback, IllformedPlugin } from '@jimp/core'; -interface Displace extends IllformedPlugin { +interface Displace { displace(map: Jimp, offset: number, cb?: ImageCallback): this; } diff --git a/packages/plugin-dither/index.d.ts b/packages/plugin-dither/index.d.ts index 3b03b7413..34d40b0b3 100644 --- a/packages/plugin-dither/index.d.ts +++ b/packages/plugin-dither/index.d.ts @@ -1,6 +1,6 @@ -import { IllformedPlugin, ImageCallback } from '@jimp/core'; +import { ImageCallback } from '@jimp/core'; -interface Dither extends IllformedPlugin { +interface Dither { dither565(cb?: ImageCallback): this; dither16(cb?: ImageCallback): this; } diff --git a/packages/plugin-flip/index.d.ts b/packages/plugin-flip/index.d.ts index 01e072ff9..24eef6765 100644 --- a/packages/plugin-flip/index.d.ts +++ b/packages/plugin-flip/index.d.ts @@ -1,6 +1,6 @@ -import { IllformedPlugin, ImageCallback } from '@jimp/core'; +import { ImageCallback } from '@jimp/core'; -interface Flip extends IllformedPlugin { +interface Flip { flip(horizontal: boolean, vertical: boolean, cb?: ImageCallback): this; mirror(horizontal: boolean, vertical: boolean, cb?: ImageCallback): this; } diff --git a/packages/plugin-gaussian/index.d.ts b/packages/plugin-gaussian/index.d.ts index 011f3eeef..8c91fbbf6 100644 --- a/packages/plugin-gaussian/index.d.ts +++ b/packages/plugin-gaussian/index.d.ts @@ -1,6 +1,6 @@ -import { IllformedPlugin, ImageCallback } from '@jimp/core'; +import { ImageCallback } from '@jimp/core'; -interface Gaussian extends IllformedPlugin { +interface Gaussian { gaussian(r: number, cb?: ImageCallback): this; } diff --git a/packages/plugin-invert/index.d.ts b/packages/plugin-invert/index.d.ts index 57fa40dbc..89423ae40 100644 --- a/packages/plugin-invert/index.d.ts +++ b/packages/plugin-invert/index.d.ts @@ -1,6 +1,6 @@ -import { IllformedPlugin, ImageCallback } from '@jimp/core'; +import { ImageCallback } from '@jimp/core'; -interface Invert extends IllformedPlugin { +interface Invert { invert(cb?: ImageCallback): this; } diff --git a/packages/plugin-mask/index.d.ts b/packages/plugin-mask/index.d.ts index b8d4ea106..fb4360f9c 100644 --- a/packages/plugin-mask/index.d.ts +++ b/packages/plugin-mask/index.d.ts @@ -1,6 +1,6 @@ import { IllformedPlugin, ImageCallback, Jimp } from '@jimp/core'; -interface Mask extends IllformedPlugin { +interface Mask { mask(src: Jimp, x: number, y: number, cb?: ImageCallback): this; } diff --git a/packages/plugin-normalize/index.d.ts b/packages/plugin-normalize/index.d.ts index 105d639be..a140288cf 100644 --- a/packages/plugin-normalize/index.d.ts +++ b/packages/plugin-normalize/index.d.ts @@ -1,6 +1,6 @@ -import { IllformedPlugin, ImageCallback } from '@jimp/core'; +import { ImageCallback } from '@jimp/core'; -interface Normalize extends IllformedPlugin { +interface Normalize { normalize(cb ?: ImageCallback): this; } diff --git a/packages/plugin-rotate/index.d.ts b/packages/plugin-rotate/index.d.ts index 771dabe3b..2528e252c 100644 --- a/packages/plugin-rotate/index.d.ts +++ b/packages/plugin-rotate/index.d.ts @@ -1,6 +1,6 @@ -import { IllformedPlugin, ImageCallback } from '@jimp/core'; +import { ImageCallback } from '@jimp/core'; -interface Rotate extends IllformedPlugin { +interface Rotate { rotate(deg: number, cb?: ImageCallback): this; rotate(deg: number, mode: string | boolean, cb?: ImageCallback): this; } diff --git a/packages/plugin-scale/index.d.ts b/packages/plugin-scale/index.d.ts index ac04589c6..06176a1bf 100644 --- a/packages/plugin-scale/index.d.ts +++ b/packages/plugin-scale/index.d.ts @@ -1,6 +1,6 @@ -import { IllformedPlugin, ImageCallback } from '@jimp/core'; +import { ImageCallback } from '@jimp/core'; -interface Scale extends IllformedPlugin { +interface Scale { scale(f: number, cb?: ImageCallback): this; scale(f: number, mode?: string, cb?: ImageCallback): this; scaleToFit(w: number, h: number, cb?: ImageCallback): this; diff --git a/packages/plugin-threshold/package.json b/packages/plugin-threshold/package.json index 8079db2dd..979b07707 100644 --- a/packages/plugin-threshold/package.json +++ b/packages/plugin-threshold/package.json @@ -25,8 +25,8 @@ }, "peerDependencies": { "@jimp/custom": ">=0.3.5", - "@jimp/plugin-color": "^0.6.3", - "@jimp/plugin-resize": "^0.6.3" + "@jimp/plugin-color": "^0.8.0", + "@jimp/plugin-resize": "^0.8.0" }, "devDependencies": { "@jimp/custom": "^0.8.0", diff --git a/packages/plugins/index.d.ts b/packages/plugins/index.d.ts index 66a8f0928..6dcfab7bd 100644 --- a/packages/plugins/index.d.ts +++ b/packages/plugins/index.d.ts @@ -60,4 +60,4 @@ type Plugins = DitherRet | ContainRet | CoverRet; -export default function(jimpEvChange: any): Plugins; +export default function(): Plugins; diff --git a/packages/utils/index.d.ts b/packages/utils/index.d.ts index f4eb2edcf..79fbeaa46 100644 --- a/packages/utils/index.d.ts +++ b/packages/utils/index.d.ts @@ -1,4 +1,4 @@ -import { Image } from './../../types/src/index.d'; +import { Image, Omit } from '@jimp/core'; import { ThrowStatement } from 'typescript'; export function isNodePattern(cb: Function): true; diff --git a/yarn.lock b/yarn.lock index 4a983c7a1..362b515ad 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1625,9 +1625,15 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-12.6.8.tgz#e469b4bf9d1c9832aee4907ba8a051494357c12c" integrity sha512-aX+gFgA5GHcDi89KG5keey2zf0WfZk/HAQotEamsK2kbey+8yGKcson0hbK8E+v0NArlCJQCqMP161YhV6ZXLg== +"@types/parsimmon@^1.3.0": + version "1.10.0" + resolved "https://registry.yarnpkg.com/@types/parsimmon/-/parsimmon-1.10.0.tgz#ffb81cb023ff435a41d4710a29ab23c561dc9fdf" + integrity sha512-bsTIJFVQv7jnvNiC42ld2pQW2KRI+pAG243L+iATvqzy3X6+NH1obz2itRKDZZ8VVhN3wjwYax/VBGCcXzgTqQ== + "@types/yargs@^11.1.1": - version "11.1.1" - resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-11.1.1.tgz#2e724257167fd6b615dbe4e54301e65fe597433f" + version "11.1.2" + resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-11.1.2.tgz#fd4b676846fe731a5de5c6d2e5ef6a377262fc30" + integrity sha512-zG61PAp2OcoIBjRV44wftJj6AJgzJrOc32LCYOBqk9bdgcdzK5DCJHV9QZJ60+Fu+fOn79g8Ks3Gixm4CfkZ+w== JSONStream@^1.0.3: version "1.3.3" @@ -1893,6 +1899,7 @@ array-slice@^0.2.3: array-union@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/array-union/-/array-union-1.0.2.tgz#9a34410e4f4e3da23dea375be5be70f24778ec39" + integrity sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk= dependencies: array-uniq "^1.0.1" @@ -2005,6 +2012,15 @@ aws4@^1.8.0: version "1.8.0" resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.8.0.tgz#f0e003d9ca9e7f59c7a508945d7b2ef9a04a542f" +babel-code-frame@^6.22.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.26.0.tgz#63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b" + integrity sha1-Y/1D99weO7fONZR9uP42mj9Yx0s= + dependencies: + chalk "^1.1.3" + esutils "^2.0.2" + js-tokens "^3.0.2" + babel-eslint@^9.0.0: version "9.0.0" resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-9.0.0.tgz#7d9445f81ed9f60aff38115f838970df9f2b6220" @@ -2399,7 +2415,7 @@ buffer@^5.0.2, buffer@^5.2.0: base64-js "^1.0.2" ieee754 "^1.1.4" -builtin-modules@^1.0.0: +builtin-modules@^1.0.0, builtin-modules@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f" @@ -2838,6 +2854,11 @@ commander@2.15.1: version "2.15.1" resolved "https://registry.yarnpkg.com/commander/-/commander-2.15.1.tgz#df46e867d0fc2aec66a34662b406a9ccafff5b0f" +commander@^2.12.1, commander@~2.20.0: + version "2.20.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.0.tgz#d58bb2b5c1ee8f87b0d340027e9e94e222c5a422" + integrity sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ== + commander@^2.14.1, commander@^2.8.1, commander@^2.9.0: version "2.16.0" resolved "https://registry.yarnpkg.com/commander/-/commander-2.16.0.tgz#f16390593996ceb4f3eeb020b31d78528f7f8a50" @@ -2846,11 +2867,6 @@ commander@~2.17.1: version "2.17.1" resolved "https://registry.yarnpkg.com/commander/-/commander-2.17.1.tgz#bd77ab7de6de94205ceacc72f1716d29f20a77bf" -commander@~2.20.0: - version "2.20.0" - resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.0.tgz#d58bb2b5c1ee8f87b0d340027e9e94e222c5a422" - integrity sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ== - commondir@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b" @@ -3275,7 +3291,7 @@ decamelize-keys@^1.0.0: decamelize "^1.1.0" map-obj "^1.0.0" -decamelize@^1.0.0, decamelize@^1.1.0, decamelize@^1.1.1, decamelize@^1.1.2: +decamelize@^1.0.0, decamelize@^1.1.0, decamelize@^1.1.1, decamelize@^1.1.2, decamelize@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" @@ -3359,6 +3375,22 @@ defined@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/defined/-/defined-1.0.0.tgz#c98d9bcef75674188e110969151199e39b1fa693" +definitelytyped-header-parser@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/definitelytyped-header-parser/-/definitelytyped-header-parser-1.2.0.tgz#f21374b8a18fabcd3ba4b008a0bcbc9db2b7b4c4" + integrity sha512-xpg8uu/2YD/reaVsZV4oJ4g7UDYFqQGWvT1W9Tsj6q4VtWBSaig38Qgah0ZMnQGF9kAsAim08EXDO1nSi0+Nog== + dependencies: + "@types/parsimmon" "^1.3.0" + parsimmon "^1.2.0" + +definitelytyped-header-parser@^3.7.2: + version "3.7.2" + resolved "https://registry.yarnpkg.com/definitelytyped-header-parser/-/definitelytyped-header-parser-3.7.2.tgz#a5b2ec9521762910e870477b01ce9feca06d9fb7" + integrity sha512-nlkiv+QLlRSc3C3qAbusWPaBiyPLldwRFnrxvoxjdZHvHbIh2+U09qdmzzWV35Rs/I3MMhcoWRcVUi3M1G935Q== + dependencies: + "@types/parsimmon" "^1.3.0" + parsimmon "^1.2.0" + del@^2.0.2: version "2.2.2" resolved "https://registry.yarnpkg.com/del/-/del-2.2.2.tgz#c12c981d067846c84bcaf862cff930d907ffd1a8" @@ -3444,9 +3476,10 @@ di@^0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/di/-/di-0.0.1.tgz#806649326ceaa7caa3306d75d985ea2748ba913c" -diff@3.5.0, diff@^3.1.0: +diff@3.5.0, diff@^3.1.0, diff@^3.2.0: version "3.5.0" resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12" + integrity sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA== diffie-hellman@^5.0.0: version "5.0.3" @@ -3510,6 +3543,34 @@ dotenv@^8.0.0: resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-8.1.0.tgz#d811e178652bfb8a1e593c6dd704ec7e90d85ea2" integrity sha512-GUE3gqcDCaMltj2++g6bRQ5rBJWtkWTmqmD0fo1RnnMuUqHNCt2oTPeDnS9n6fKYvlhn7AeBkb38lymBtWBQdA== +download-file-sync@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/download-file-sync/-/download-file-sync-1.0.4.tgz#d3e3c543f836f41039455b9034c72e355b036019" + integrity sha1-0+PFQ/g29BA5RVuQNMcuNVsDYBk= + +dts-critic@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/dts-critic/-/dts-critic-2.0.0.tgz#9d52943326d57df0691aa0479010a73ccb855a4f" + integrity sha512-oYo69B8NcjUoDhKh8oUl58ljMsgyWnPR0Qf3QKJmKjm5LvkQ21v4SW+QCOleI1Cs0HRN6zEYllvQEORGd45wOQ== + dependencies: + definitelytyped-header-parser "^1.2.0" + download-file-sync "^1.0.4" + semver "^6.2.0" + yargs "^12.0.5" + +dtslint@^0.9.6: + version "0.9.6" + resolved "https://registry.yarnpkg.com/dtslint/-/dtslint-0.9.6.tgz#ccc564f226de14b3021e457127dd07e447c85b60" + integrity sha512-BIPTSnpYyGJxVcToYnw9KPkw3Er7hhK21E/QIBYWbkKkAa065221f8MVHwePB13TkyLOFCNdQOPICNnrQ+rfoA== + dependencies: + definitelytyped-header-parser "^3.7.2" + dts-critic "^2.0.0" + fs-extra "^6.0.1" + request "^2.88.0" + strip-json-comments "^2.0.1" + tslint "5.14.0" + typescript next + duplexer2@^0.1.2, duplexer2@~0.1.0, duplexer2@~0.1.2: version "0.1.4" resolved "https://registry.yarnpkg.com/duplexer2/-/duplexer2-0.1.4.tgz#8b12dab878c0d69e3e7891051662a32fc6bddcc1" @@ -4376,6 +4437,15 @@ fs-access@^1.0.0: dependencies: null-check "^1.0.0" +fs-extra@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-6.0.1.tgz#8abc128f7946e310135ddc93b98bddb410e7a34b" + integrity sha512-GnyIkKhhzXZUWFCaJzvyDLEEgDkPfb4/TPvJCJVuS8MWZgoSsErf++QpiAlDnKFcqhRlm+tIOcencCjyJE6ZCA== + dependencies: + graceful-fs "^4.1.2" + jsonfile "^4.0.0" + universalify "^0.1.0" + fs-extra@^7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-7.0.0.tgz#8cc3f47ce07ef7b3593a11b9fb245f7e34c041d6" @@ -4962,6 +5032,7 @@ ignore@^4.0.2: ignore@^4.0.6: version "4.0.6" resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc" + integrity sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg== import-cwd@^3.0.0: version "3.0.0" @@ -5562,7 +5633,7 @@ js-string-escape@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/js-string-escape/-/js-string-escape-1.0.1.tgz#e2625badbc0d67c7533e9edc1068c587ae4137ef" -js-tokens@^3.0.0: +js-tokens@^3.0.0, js-tokens@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b" @@ -5581,7 +5652,7 @@ js-yaml@^3.12.0, js-yaml@^3.9.0: argparse "^1.0.7" esprima "^4.0.0" -js-yaml@^3.13.0, js-yaml@^3.13.1: +js-yaml@^3.13.0, js-yaml@^3.13.1, js-yaml@^3.7.0: version "3.13.1" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.13.1.tgz#aff151b30bfdfa8e49e05da22e7415e9dfa37847" integrity sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw== @@ -7269,6 +7340,11 @@ parseurl@~1.3.2: version "1.3.2" resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.2.tgz#fc289d4ed8993119460c156253262cdc8de65bf3" +parsimmon@^1.2.0: + version "1.13.0" + resolved "https://registry.yarnpkg.com/parsimmon/-/parsimmon-1.13.0.tgz#6e4ef3dbd45ed6ea6808be600ac4b9c8a44228cf" + integrity sha512-5UIrOCW+gjbILkjKPgTgmq8LKf8TT3Iy7kN2VD7OtQ81facKn8B4gG1X94jWqXYZsxG2KbJhrv/Yq/5H6BQn7A== + pascalcase@^0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/pascalcase/-/pascalcase-0.1.1.tgz#b363e55e8006ca6fe21784d2db22bd15d7917f14" @@ -7925,9 +8001,10 @@ repeating@^2.0.0: dependencies: is-finite "^1.0.0" -request@^2.87.0: +request@^2.87.0, request@^2.88.0: version "2.88.0" resolved "https://registry.yarnpkg.com/request/-/request-2.88.0.tgz#9c2fca4f7d35b592efe57c7f0a55e81052124fef" + integrity sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg== dependencies: aws-sign2 "~0.7.0" aws4 "^1.8.0" @@ -8114,7 +8191,7 @@ semver@^5.6.0: resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.0.tgz#790a7cf6fea5459bac96110b29b60412dc8ff96b" integrity sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA== -semver@^6.0.0: +semver@^6.0.0, semver@^6.2.0: version "6.3.0" resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== @@ -8947,10 +9024,41 @@ ts-node@^7.0.1: source-map-support "^0.5.6" yn "^2.0.0" +tslib@^1.8.0, tslib@^1.8.1: + version "1.10.0" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.10.0.tgz#c3c19f95973fb0a62973fb09d90d961ee43e5c8a" + integrity sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ== + tslib@^1.9.0: version "1.9.3" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286" +tslint@5.14.0: + version "5.14.0" + resolved "https://registry.yarnpkg.com/tslint/-/tslint-5.14.0.tgz#be62637135ac244fc9b37ed6ea5252c9eba1616e" + integrity sha512-IUla/ieHVnB8Le7LdQFRGlVJid2T/gaJe5VkjzRVSRR6pA2ODYrnfR1hmxi+5+au9l50jBwpbBL34txgv4NnTQ== + dependencies: + babel-code-frame "^6.22.0" + builtin-modules "^1.1.1" + chalk "^2.3.0" + commander "^2.12.1" + diff "^3.2.0" + glob "^7.1.1" + js-yaml "^3.7.0" + minimatch "^3.0.4" + mkdirp "^0.5.1" + resolve "^1.3.2" + semver "^5.3.0" + tslib "^1.8.0" + tsutils "^2.29.0" + +tsutils@^2.29.0: + version "2.29.0" + resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.29.0.tgz#32b488501467acbedd4b85498673a0812aca0b99" + integrity sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA== + dependencies: + tslib "^1.8.1" + tty-browserify@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.1.tgz#3f05251ee17904dfd0677546670db9651682b811" @@ -8993,6 +9101,11 @@ typescript@^3.0.3: version "3.0.3" resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.0.3.tgz#4853b3e275ecdaa27f78fda46dc273a7eb7fc1c8" +typescript@next: + version "3.7.0-dev.20190907" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.7.0-dev.20190907.tgz#6952fcfe58ba14ad2fa16749d90f7bb4138aa992" + integrity sha512-zUtlsa6sFacCu4sFMWu8/6CmjRthT+8+8sMUAGQxHWLWO9KDeGoL3MfMygUlffN9l7GnDwqNamu0M9pHgHXlFw== + typical@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/typical/-/typical-4.0.0.tgz#cbeaff3b9d7ae1e2bbfaf5a4e6f11eccfde94fc4" @@ -9149,6 +9262,7 @@ upath@^1.0.5: update-notifier@^2.3.0: version "2.5.0" resolved "https://registry.yarnpkg.com/update-notifier/-/update-notifier-2.5.0.tgz#d0744593e13f161e406acb1d9408b72cad08aff6" + integrity sha512-gwMdhgJHGuj/+wHJJs9e6PcCszpxR1b236igrOkUofGhqJuG+amlIKwApH1IW1WWl7ovZxsX49lMBWLxSdm5Dw== dependencies: boxen "^1.2.1" chalk "^2.0.1" @@ -9526,6 +9640,14 @@ yargs-parser@^10.0.0, yargs-parser@^10.1.0: dependencies: camelcase "^4.1.0" +yargs-parser@^11.1.1: + version "11.1.1" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-11.1.1.tgz#879a0865973bca9f6bab5cbdf3b1c67ec7d3bcf4" + integrity sha512-C6kB/WJDiaxONLJQnF8ccx9SEeoTTLek8RVbaOIsrAUS8VrBEXfmeSnCZxygc+XC2sNMBIwOOnfcxiynjHsVSQ== + dependencies: + camelcase "^5.0.0" + decamelize "^1.2.0" + yargs-parser@^8.1.0: version "8.1.0" resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-8.1.0.tgz#f1376a33b6629a5d063782944da732631e966950" @@ -9606,6 +9728,24 @@ yargs@^12.0.2: y18n "^3.2.1 || ^4.0.0" yargs-parser "^10.1.0" +yargs@^12.0.5: + version "12.0.5" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-12.0.5.tgz#05f5997b609647b64f66b81e3b4b10a368e7ad13" + integrity sha512-Lhz8TLaYnxq/2ObqHDql8dX8CJi97oHxrjUcYtzKbbykPtVW9WB+poxI+NM2UIzsMgNCZTIf0AQwsjK5yMAqZw== + dependencies: + cliui "^4.0.0" + decamelize "^1.2.0" + find-up "^3.0.0" + get-caller-file "^1.0.1" + os-locale "^3.0.0" + require-directory "^2.1.1" + require-main-filename "^1.0.1" + set-blocking "^2.0.0" + string-width "^2.0.0" + which-module "^2.0.0" + y18n "^3.2.1 || ^4.0.0" + yargs-parser "^11.1.1" + yargs@~3.10.0: version "3.10.0" resolved "https://registry.yarnpkg.com/yargs/-/yargs-3.10.0.tgz#f7ee7bd857dd7c1d2d38c0e74efbd681d1431fd1"