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

chore(TS): Group #8455

Merged
merged 31 commits into from
Nov 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
4b46dd6
init
ShaMan123 Nov 21, 2022
4fc4319
Update collection.mixin.ts
ShaMan123 Nov 21, 2022
84a75de
types
ShaMan123 Nov 21, 2022
339e8c1
Update object_interactivity.mixin.ts
ShaMan123 Nov 21, 2022
76f26d6
Update object.class.ts
ShaMan123 Nov 21, 2022
82ded9b
Update collection.mixin.ts
ShaMan123 Nov 21, 2022
a97d170
Update group.class.ts
ShaMan123 Nov 21, 2022
b4e85c2
Update group.js
ShaMan123 Nov 21, 2022
305e9bd
Update CHANGELOG.md
ShaMan123 Nov 21, 2022
07fbc40
Update group.class.ts
ShaMan123 Nov 21, 2022
9f187cb
Squashed commit of the following:
ShaMan123 Nov 21, 2022
4fe445f
Update group.class.ts
ShaMan123 Nov 21, 2022
c36121d
migrate AS
ShaMan123 Nov 21, 2022
9ac6ec3
Update active_selection.class.ts
ShaMan123 Nov 21, 2022
a77f803
Update activeselection.js
ShaMan123 Nov 21, 2022
69f5c38
Update active_selection.class.ts
ShaMan123 Nov 21, 2022
4e8db1a
remove redundant deep clone
ShaMan123 Nov 21, 2022
2061e5b
Revert "Squashed commit of the following:"
ShaMan123 Nov 21, 2022
3523a0b
rename
ShaMan123 Nov 21, 2022
7510e6c
Update active_selection.class.ts
ShaMan123 Nov 21, 2022
45abc34
TS complaining
ShaMan123 Nov 23, 2022
806b6e7
fix(): `_onAfterObjectsChange`
ShaMan123 Nov 23, 2022
13f6613
port group changes from #7878
ShaMan123 Nov 23, 2022
b3fb13e
Merge branch 'master' into ts-group
ShaMan123 Nov 25, 2022
68d2280
fix merge conflict
ShaMan123 Nov 25, 2022
7b33323
more cleanup
ShaMan123 Nov 25, 2022
971c4d3
cleanup
ShaMan123 Nov 25, 2022
cf82a83
temporary fix
ShaMan123 Nov 25, 2022
e1cb367
checkout patternBrush
ShaMan123 Nov 25, 2022
98c0ae4
Merge branch 'master' into ts-group
asturur Nov 26, 2022
7149280
added comment
asturur Nov 26, 2022
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): migrate Group/ActiveSelection [#8455](https://github.com/fabricjs/fabric.js/pull/8455)
- fix(TS): migration error of itext key mixin (#8421) [#8457](https://github.com/fabricjs/fabric.js/pull/8457)
- chore(TS): migrate text classes/mixins [#8421](https://github.com/fabricjs/fabric.js/pull/8421)
- chore(TS): migrate Image [#8443](https://github.com/fabricjs/fabric.js/pull/8443)
Expand Down
1 change: 0 additions & 1 deletion src/__types__.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@ export type StaticCanvas = Record<string, any> & {
};
getRetinaScaling(): number;
} & Observable;
export type TObject = any;
6 changes: 1 addition & 5 deletions src/brushes/circle_brush.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,11 @@ import { Color } from '../color';
import { Point } from '../point.class';
import { Shadow } from '../shadow.class';
import { Circle } from '../shapes/circle.class';
import { Group } from '../shapes/group.class';
import { getRandomInt } from '../util/internals';
import { Canvas } from '../__types__';
import { BaseBrush } from './base_brush.class';

/**
* @todo remove transient
*/
const { Group } = fabric;

export type CircleBrushPoint = {
x: number;
y: number;
Expand Down
6 changes: 1 addition & 5 deletions src/brushes/spray_brush.class.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import { fabric } from '../../HEADER';
import { Point } from '../point.class';
import { Group } from '../shapes/group.class';
import { Shadow } from '../shadow.class';
import { Rect } from '../shapes/rect.class';
import { getRandomInt } from '../util/internals';
import { Canvas } from '../__types__';
import { BaseBrush } from './base_brush.class';

/**
* @todo remove transient
*/
const { Group } = fabric;

export type SprayBrushPoint = {
x: number;
y: number;
Expand Down
2 changes: 0 additions & 2 deletions src/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export class Cache {
* measurement and so wrong bounding boxes.
* After the font cache is cleared, either change the textObject text content or call
* initDimensions() to trigger a recalculation
* @memberOf fabric.util
* @param {String} [fontFamily] font family to clear
*/
clearFontCache(fontFamily?: string) {
Expand All @@ -62,7 +61,6 @@ export class Cache {
/**
* Given current aspect ratio, determines the max width and height that can
* respect the total allowed area for the cache.
* @memberOf fabric.util
* @param {number} ar aspect ratio
* @return {number[]} Limited dimensions X and Y
*/
Expand Down
10 changes: 7 additions & 3 deletions src/mixins/collection.mixin.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { fabric } from '../../HEADER';
import type { FabricObject } from '../shapes/fabricObject.class';

export function createCollectionMixin(Klass: { new (...args: any[]): any }) {
export function createCollectionMixin<T extends { new (...args: any[]): any }>(
Klass: T
) {
return class Collection extends Klass {
/**
* @type {FabricObject[]}
Expand Down Expand Up @@ -123,7 +125,7 @@ export function createCollectionMixin(Klass: { new (...args: any[]): any }) {
/**
* Returns true if collection contains an object.\
* **Prefer using {@link `FabricObject#isDescendantOf`} for performance reasons**
* instead of a.contains(b) use b.isDescendantOf(a)
* instead of `a.contains(b)` use `b.isDescendantOf(a)`
* @param {Object} object Object to check against
* @param {Boolean} [deep=false] `true` to check all descendants, `false` to check only `_objects`
* @return {Boolean} `true` if collection contains an object
Expand All @@ -133,7 +135,9 @@ export function createCollectionMixin(Klass: { new (...args: any[]): any }) {
return true;
} else if (deep) {
return this._objects.some(
(obj) => obj instanceof Collection && obj.contains(object, true)
(obj) =>
obj instanceof Collection &&
(obj as unknown as Collection).contains(object, true)
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 doesn't manage to cope with this line

);
}
return false;
Expand Down
1 change: 0 additions & 1 deletion src/pattern.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ export class Pattern {
* Constructor
* @param {Object} [options] Options object
* @param {option.source} [source] the pattern source, eventually empty or a drawable
* @return {fabric.Pattern} thisArg
*/
constructor(options: TPatternOptions = {}) {
this.id = FabricObject.__uid++;
Expand Down
Loading