diff --git a/CHANGELOG.md b/CHANGELOG.md index cc2e37f115a..ddc26ce2965 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(): Matrix util cleanup [#8894](https://github.com/fabricjs/fabric.js/pull/8894) - 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) 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/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, 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,