From 2bbffa0010d339fe67bc82c4cdf2b3f3ef0b5fbd Mon Sep 17 00:00:00 2001 From: ShaMan123 Date: Tue, 9 May 2023 09:38:24 +0900 Subject: [PATCH 1/3] checkout --- src/Pattern/Pattern.ts | 2 +- src/Pattern/index.ts | 2 +- src/shapes/Image.ts | 22 ++++++++++------------ 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/Pattern/Pattern.ts b/src/Pattern/Pattern.ts index 8752f9f0c2e..373749c9ab4 100644 --- a/src/Pattern/Pattern.ts +++ b/src/Pattern/Pattern.ts @@ -1,5 +1,5 @@ import { config } from '../config'; -import { Abortable, TCrossOrigin, TMat2D } from '../typedefs'; +import { Abortable, TCrossOrigin, TMat2D, TSize } from '../typedefs'; import { ifNaN } from '../util/internals'; import { uid } from '../util/internals/uid'; import { loadImage } from '../util/misc/objectEnlive'; diff --git a/src/Pattern/index.ts b/src/Pattern/index.ts index 1e59aa67808..a528937132b 100644 --- a/src/Pattern/index.ts +++ b/src/Pattern/index.ts @@ -1,2 +1,2 @@ export { Pattern } from './Pattern'; -export type * from './types'; +export * from './types'; diff --git a/src/shapes/Image.ts b/src/shapes/Image.ts index ee96bcba5ef..423814af55a 100644 --- a/src/shapes/Image.ts +++ b/src/shapes/Image.ts @@ -254,13 +254,14 @@ export class Image< this.removeTexture(this.cacheKey); this.removeTexture(`${this.cacheKey}_filtered`); this._cacheContext = null; - ['_originalElement', '_element', '_filteredEl', '_cacheCanvas'].forEach( - (elementKey) => { - getEnv().dispose(this[elementKey as keyof this] as Element); - // @ts-expect-error disposing - this[elementKey] = undefined; - } - ); + ( + ['_originalElement', '_element', '_filteredEl', '_cacheCanvas'] as const + ).forEach((elementKey) => { + const el = this[elementKey]; + el && getEnv().dispose(el); + // @ts-expect-error disposing + this[elementKey] = undefined; + }); } /** @@ -785,7 +786,7 @@ export class Image< */ static fromObject>( { filters: f, resizeFilter: rf, src, crossOrigin, ...object }: T, - options: { signal: AbortSignal } + options: Abortable = {} ) { return Promise.all([ loadImage(src, { ...options, crossOrigin }), @@ -827,10 +828,7 @@ export class Image< * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal * @param {Function} callback Callback to execute when Image object is created */ - static async fromElement( - element: SVGElement, - options: { signal?: AbortSignal } = {} - ) { + static async fromElement(element: SVGElement, options: Abortable = {}) { const parsedAttributes = parseAttributes(element, this.ATTRIBUTE_NAMES); return this.fromURL(parsedAttributes['xlink:href'], { ...options, From 782e74cd8a748506719666182e8e8ca0d62249e4 Mon Sep 17 00:00:00 2001 From: ShaMan123 Date: Tue, 9 May 2023 10:01:07 +0900 Subject: [PATCH 2/3] Update StaticCanvas.ts --- src/canvas/StaticCanvas.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/canvas/StaticCanvas.ts b/src/canvas/StaticCanvas.ts index ea5a4e0af5b..6947f3dac3e 100644 --- a/src/canvas/StaticCanvas.ts +++ b/src/canvas/StaticCanvas.ts @@ -11,6 +11,7 @@ import type { BaseFabricObject as FabricObject } from '../EventTypeDefs'; import type { TCachedFabricObject } from '../shapes/Object/Object'; import type { Rect } from '../shapes/Rect'; import { + Abortable, Constructor, ImageFormat, TCornerPoint, From 835bdee9e7f2652a56a715763649eea4785a4db3 Mon Sep 17 00:00:00 2001 From: ShaMan123 Date: Tue, 9 May 2023 10:01:48 +0900 Subject: [PATCH 3/3] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 98e74bf4e87..602ed362aa5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## [next] +- chore(TS): minor type/import fixes [#8904](https://github.com/fabricjs/fabric.js/pull/8904) - chore(TS): pattern cleanup + export types [#8875](https://github.com/fabricjs/fabric.js/pull/8875) - fix(): Disable offscreen check for bg and overlay when not needed [#8898](https://github.com/fabricjs/fabric.js/pull/8898) - chore(): cleanup #8888 [#8892](https://github.com/fabricjs/fabric.js/pull/8892)