Skip to content

Conversation

ShaMan123
Copy link
Contributor

@ShaMan123 ShaMan123 commented Sep 5, 2022

Migrate Pattern to TS
I thought it had default values in export, that's why I left it but it doesn't so I migrated it.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 5, 2022

Coverage after merging ts-pattern into master will be

81.06%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
dist
   fabric.js79.42%75.59%84.73%81.06%10056, 10110, 10125, 10181, 10217–10218, 10224, 10228–10229, 10244, 10278, 10309–10310, 10334, 10342, 10429, 10461–10462, 10537–10538, 10541, 10546, 10568, 10568, 10568, 10568, 10568, 10568, 10568–10569, 10571–10572, 10572, 10572–10573, 10578, 10580, 10586, 10586, 10586, 10586, 10586–10587, 10589–10593, 10593, 10593–10595, 10597–10598, 10607, 10618, 10629, 10640, 10650–10653, 10661–10662, 10662, 10662–10663, 10665–10666, 10673, 10677, 1085, 11274, 11279, 11321–11323, 11323, 11323, 11323, 11323, 11323–11324, 11344, 11349–11350, 11390, 11390, 11390, 11390, 11418, 11418, 11418, 11420, 11568–11569, 11580, 116, 1160, 1162–1163, 1165–1166, 1173, 11737–11738, 11745, 1177, 11788, 11795, 11795, 11804–11805, 11816, 1185, 11856, 11864, 11883–11885, 119, 11912–11913, 11916, 11916, 11933–11935, 120, 12038, 121, 12123–12124, 12126–12127, 12134, 12158, 1221, 12223–12224, 12228, 1223, 1223, 1223, 1223, 1223–1224, 12308, 12319, 12324, 12361, 12462, 12462, 12462, 12486–12487, 12595, 12598, 12660, 12666, 12673, 12680, 12686, 12692, 12699, 12706, 12712–12713, 12713, 12713, 12728–12729, 12737, 12746, 12746, 12771–12774, 128, 12813, 12856–12857, 12897–12898, 129, 129, 129, 129, 129, 129, 129–130, 13031–13032, 131, 13177, 13269, 133, 13332, 13335, 13388–13389, 13389, 13389, 13392, 13407, 13421, 13433–13434, 13436, 13448–13449, 13451, 13466, 13481–13482, 13484–13485, 13487–13488, 13498, 13528, 13528, 13528, 13528, 13528, 13528, 13528, 13528, 13553, 13555, 13555–13557, 13610–13612, 13635, 13643, 13649–13650, 13691, 13754–13755, 13789, 13810–13811, 13870, 13870, 13870, 13870, 13870, 13875–13883, 1390, 1390, 1392, 13925, 14051–14052, 14088, 14097, 14118, 14118, 14118–14119, 14119, 14119, 14119, 14119–14120, 14126–14128, 14131–14132, 14145, 14145, 14145–14146, 14146, 14146, 14146, 14146–14147, 14153–14155, 14158–14159, 14172–14173, 14247, 14296, 14300, 1442, 14425, 14455–14456, 14456, 14456–14457, 14457, 14457–14458, 14460, 14460, 14460–14461, 14464, 14471, 14556, 14669, 14718, 14788, 14792, 14862, 14919–14920, 14934, 14984–14985, 14987–14988, 15080, 15140, 15143, 15218, 15221, 15236–15237, 15246, 15288, 15292, 15317–15318, 15352, 15356, 1562, 15622, 15626, 15790, 15793, 15800–15801, 15801, 15801–15803, 15805, 15805, 15805–15807, 15807, 15807–15809, 15899, 15904–15906, 15934–15935, 16002, 16005, 16005, 16005–16006, 16008–16009, 16009, 16009–16010, 16010, 16010, 16012–16013, 16015, 16018, 16045, 16045–16047, 16096, 16096, 16131, 16166, 16166, 16166, 16169–16170, 16172, 16172, 16176, 16179, 16182, 16184–16185, 16194, 16199, 16199–16201, 16201, 16212–16213, 16222, 16222, 16222, 16222, 16222–16223, 16223, 16223–16225, 16225–16226, 16226, 1623, 16243–16244, 16244, 16244, 16266–16267, 16267, 16267, 16267, 16267, 16267, 16279, 16279, 16282–16286, 16286, 16325, 16364, 16396, 16399–16402, 16412, 16425, 16440, 16457, 16466, 16470, 16522, 16524–16526, 16540, 16542–16543, 16559, 16611, 16634, 16767, 16830–16832, 16832–16833, 16833, 16861, 16906–16909, 16916, 16918–16919, 16934–16936, 16946, 16946, 16946, 17009, 17021, 17021, 17068–17069, 17087–17088, 17109, 17150, 17150–17151, 17168–17171, 17171, 17171–17172, 17174, 17174, 17174–17175, 17177–17178, 17178, 17178–17179, 17181, 17181, 17181–17182, 17184–17185, 17189–17190, 17237, 17281, 17350, 17355, 17379–17380, 17389–17393, 17405–17408, 17413, 17422–17423, 17425, 17434, 17434, 17434, 17434, 17434–17435, 17437–17438, 17454–17455, 17457–17458, 17465–17468, 17471, 17474, 17476–17477, 17477, 17477, 17477, 17477, 17477, 17477–17478, 17480, 17482–17483, 17483, 17483–17486, 17488, 17495–17503, 17503, 17503–17505, 17508, 17516–17519, 17525–17526, 17526, 17526–17527, 17529, 17529, 17529–17530, 17532, 17534–17535, 17550, 17552, 17552, 17552–17553, 17555–17556, 17556–17557, 17557, 17563, 17563, 17565, 17565–17566, 17566, 17575–17577, 17577, 17577–17585, 17591, 17591, 17591–17593, 17595, 1760, 17601–17602, 1761, 17616–17622, 17622, 17622–17623, 17626, 17628, 17640, 17640, 17640–17641, 17644–17646, 17656, 17656, 17656–17658, 17670, 17670, 17670–17671, 17673–17674, 17674, 17674–17675, 17677–17678, 17678, 17678–17681, 17681, 17681–17682, 17684, 17684, 17684–17685, 17688–17689, 17692, 17694–17695, 17695, 17695, 17695, 17695–17697, 17711–17713, 17715–17716, 17727, 17729, 17731–17734, 17791, 17857, 17857, 17857–17858, 17858, 17858–17859,

@ShaMan123 ShaMan123 requested a review from asturur September 5, 2022 17:45
Copy link
Contributor Author

@ShaMan123 ShaMan123 left a comment

Choose a reason for hiding this comment

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

Standard es6/TS, except the commented line which is a cleanup for an old PR

};
})(typeof exports !== 'undefined' ? exports : window);
toSVG({ width, height }: TSize) {
const patternSource = this.source,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This reverts commit 03d94c3.
* @returns true if {@link source} is a <canvas> element
*/
isCanvasSource(): this is TCanvasSource {
return typeof this.source === 'object' && this.source.toDataURL;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this an assertion for a canvas element? Or for a fabric Object? Or both?

Comment on lines +179 to +183
const img = await loadImage(source, {
...options,
crossOrigin: serialized.crossOrigin
})
return new Pattern({ ...serialized, source: img });
Copy link
Member

Choose a reason for hiding this comment

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

everywhere else we use the promise syntax, let's leave that one

@asturur
Copy link
Member

asturur commented Sep 11, 2022

Migrate Pattern to TS I thought it had default values in export, that's why I left it but it doesn't so I migrated it.

it could have them :) but patterns are usually small.

@asturur
Copy link
Member

asturur commented Sep 11, 2022

This is fine for where we are at.
The issue with TS and Classes and that it makes harder to add whatever i want to an object ( shadow, fabricObject, pattern gradient ) and export/import it.

Types makes it hard at dev time, classes makes it hard at runtime.

Now Patterns and Gradients are usually not really where people add businnes logic ( names or special props or special behavior ) so those are fine to be standard classes, with or without the default values issue

@asturur asturur merged commit 18e6416 into master Sep 11, 2022
@asturur asturur deleted the ts-pattern branch November 1, 2022 23:38
frankrousseau pushed a commit to cgwire/fabric.js that referenced this pull request Jan 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants