Skip to content

Commit

Permalink
chore(TS): minor changes to typescript notation to be compatible with…
Browse files Browse the repository at this point in the history
… a 5.3.3
  • Loading branch information
asturur authored Mar 22, 2024
1 parent 7856543 commit f640e2d
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 226 deletions.
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 changes to typescript notation to be compatible with a 5.3.3 [#9725](https://github.com/fabricjs/fabric.js/pull/9725)
- fix(InteractiveObject): "borderOpacityWhenMoving" does not take effect on the child shapes within the group [#9374](https://github.com/fabricjs/fabric.js/issues/9734)
- fix(SVGParser): Consider the transformMatrix of the clipPath owner as part of the clipPath trasnformation [#9750](https://github.com/fabricjs/fabric.js/pull/9750)
- fix(StaticCanvas): setDimensions not requesting a render if options are not passed [#9710](https://github.com/fabricjs/fabric.js/pull/9710)
Expand Down
199 changes: 0 additions & 199 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@
"source-map-support": "^0.5.21",
"testem": "^3.8.0",
"tslib": "^2.4.1",
"typedoc": "^0.25.3",
"typedoc-plugin-markdown": "^3.17.0",
"typescript": "^4.9.4",
"v8-to-istanbul": "^9.1.0"
},
Expand Down
16 changes: 12 additions & 4 deletions src/Pattern/Pattern.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,16 +174,24 @@ export class Pattern {
patternWidth =
repeat === 'repeat-y' || repeat === 'no-repeat'
? 1 + Math.abs(patternOffsetX || 0)
: ifNaN((patternSource.width as number) / width, 0),
: ifNaN(
((patternSource as HTMLImageElement).width as number) / width,
0
),
patternHeight =
repeat === 'repeat-x' || repeat === 'no-repeat'
? 1 + Math.abs(patternOffsetY || 0)
: ifNaN((patternSource.height as number) / height, 0);
: ifNaN(
((patternSource as HTMLImageElement).height as number) / height,
0
);

return [
`<pattern id="SVGID_${id}" x="${patternOffsetX}" y="${patternOffsetY}" width="${patternWidth}" height="${patternHeight}">`,
`<image x="0" y="0" width="${patternSource.width}" height="${
patternSource.height
`<image x="0" y="0" width="${
(patternSource as HTMLImageElement).width
}" height="${
(patternSource as HTMLImageElement).height
}" xlink:href="${this.sourceToString()}"></image>`,
`</pattern>`,
'',
Expand Down
4 changes: 2 additions & 2 deletions src/canvas/StaticCanvas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1230,11 +1230,11 @@ export class StaticCanvas<
filler.offsetY - finalHeight / 2
}" width="${
(repeat === 'repeat-y' || repeat === 'no-repeat') && isPattern(filler)
? filler.source.width
? (filler.source as HTMLImageElement).width
: finalWidth
}" height="${
(repeat === 'repeat-x' || repeat === 'no-repeat') && isPattern(filler)
? filler.source.height
? (filler.source as HTMLImageElement).height
: finalHeight
}" fill="url(#SVGID_${filler.id})"></rect>\n`
);
Expand Down
4 changes: 2 additions & 2 deletions src/filters/WebGLFilterBackend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,8 @@ export class WebGLFilterBackend {
} else {
const texture = this.createTexture(
this.gl,
textureImageSource.width,
textureImageSource.height,
(textureImageSource as HTMLImageElement).width,
(textureImageSource as HTMLImageElement).height,
textureImageSource,
filter
);
Expand Down
3 changes: 2 additions & 1 deletion src/shapes/Image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,8 @@ export class FabricImage<
ctx: CanvasRenderingContext2D
) {
ctx.imageSmoothingEnabled = this.imageSmoothing;
// @ts-expect-error TS doesn't respect this type casting
// cant use ts-expect-error because of ts 5.3 cross check
// @ts-ignore TS doesn't respect this type casting
super.drawCacheOnCanvas(ctx);
}

Expand Down
3 changes: 2 additions & 1 deletion src/shapes/Text/TextSVGExportMixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,8 @@ export class TextSVGExportMixin extends FabricObjectSVGExportMixin {
* @return {String}
*/
getSvgStyles(this: TextSVGExportMixin & FabricText, skipShadow?: boolean) {
// @ts-expect-error TS doesn't respect this type casting
// cant use ts-expect-error because of ts 5.3 cross check
// @ts-ignore TS doesn't respect this type casting
return `${super.getSvgStyles(skipShadow)} white-space: pre;`;
}

Expand Down
Loading

0 comments on commit f640e2d

Please sign in to comment.