From 56498f0c3f7709043b0d23608d80452f6a85c5d0 Mon Sep 17 00:00:00 2001 From: John Pinkster Date: Tue, 7 Jan 2020 19:23:25 -0500 Subject: [PATCH 1/3] Updating Types There are two missing types that I am requesting to add. `jpg` support and on the NodeCanvasRenderingContext2D --- types/index.d.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/types/index.d.ts b/types/index.d.ts index 21b6adb97..3a10a1a85 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -78,7 +78,7 @@ export class Canvas { /** Constant used in PNG encoding methods. */ readonly PNG_FILTER_PAETH: number - constructor(width: number, height: number, type?: 'pdf'|'svg') + constructor(width: number, height: number, type?: 'pdf'|'svg'|'jpg') getContext(contextId: '2d', contextAttributes?: NodeCanvasRenderingContext2DSettings): NodeCanvasRenderingContext2D @@ -212,6 +212,10 @@ declare class NodeCanvasRenderingContext2D extends CanvasRenderingContext2D { createPattern(...args: any[]): NodeCanvasCanvasPattern createLinearGradient(x0: number, y0: number, x1: number, y1: number): NodeCanvasCanvasGradient; createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): NodeCanvasCanvasGradient; + /** + * An additional method .addPage() is then available to create multiple page PDFs + */ + addPage(width?: number, height?: number): void } export { NodeCanvasRenderingContext2D as CanvasRenderingContext2D } From cf8153d8b81f03056da7d7240d010a307ab45bce Mon Sep 17 00:00:00 2001 From: John Pinkster Date: Tue, 7 Jan 2020 19:25:45 -0500 Subject: [PATCH 2/3] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 13b9cd861..a185cd64e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ project adheres to [Semantic Versioning](http://semver.org/). ### Added ### Fixed * Fix BMP issues. (#1497) +* Update typings to support jpg and addPage on NodeCanvasRenderingContext2D (#1509) 2.6.1 ================== From 0a22f37f88451409860ec1bd186fbc5cc0df1ed1 Mon Sep 17 00:00:00 2001 From: John Pinkster Date: Thu, 9 Jan 2020 11:14:35 -0500 Subject: [PATCH 3/3] fix(typings): Updating available types on construction, update addPage comments --- types/index.d.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/types/index.d.ts b/types/index.d.ts index 3a10a1a85..f44516667 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -78,7 +78,7 @@ export class Canvas { /** Constant used in PNG encoding methods. */ readonly PNG_FILTER_PAETH: number - constructor(width: number, height: number, type?: 'pdf'|'svg'|'jpg') + constructor(width: number, height: number, type?: 'image'|'pdf'|'svg') getContext(contextId: '2d', contextAttributes?: NodeCanvasRenderingContext2DSettings): NodeCanvasRenderingContext2D @@ -126,12 +126,6 @@ export class Canvas { toDataURL(mimeType: 'image/jpeg', config: JpegConfig, cb: (err: Error|null, result: string) => void): void /** _Non-standard._ */ toDataURL(mimeType: 'image/jpeg', quality: number, cb: (err: Error|null, result: string) => void): void - - /** - * For PDF canvases, adds another page. If width and/or height are omitted, - * the canvas's initial size is used. - */ - addPage(width?: number, height?: number): void } declare class NodeCanvasRenderingContext2D extends CanvasRenderingContext2D { @@ -212,8 +206,10 @@ declare class NodeCanvasRenderingContext2D extends CanvasRenderingContext2D { createPattern(...args: any[]): NodeCanvasCanvasPattern createLinearGradient(x0: number, y0: number, x1: number, y1: number): NodeCanvasCanvasGradient; createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): NodeCanvasCanvasGradient; + /** - * An additional method .addPage() is then available to create multiple page PDFs + * For PDF canvases, adds another page. If width and/or height are omitted, + * the canvas's initial size is used. */ addPage(width?: number, height?: number): void }