Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(TS): some left overs #8904

Merged
merged 4 commits into from
May 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/Pattern/Pattern.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/Pattern/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { Pattern } from './Pattern';
export type * from './types';
export * from './types';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TS complains.
I see the bundle grew so this might not be good

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and rather annoying

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea why the bundle grows

1 change: 1 addition & 0 deletions src/canvas/StaticCanvas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
22 changes: 10 additions & 12 deletions src/shapes/Image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
}

/**
Expand Down Expand Up @@ -785,7 +786,7 @@ export class Image<
*/
static fromObject<T extends TProps<SerializedImageProps>>(
{ filters: f, resizeFilter: rf, src, crossOrigin, ...object }: T,
options: { signal: AbortSignal }
options: Abortable = {}
) {
return Promise.all([
loadImage(src, { ...options, crossOrigin }),
Expand Down Expand Up @@ -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,
Expand Down