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): config #8194

Merged
merged 22 commits into from Aug 28, 2022
Merged

chore(TS): config #8194

merged 22 commits into from Aug 28, 2022

Conversation

ShaMan123
Copy link
Contributor

@ShaMan123 ShaMan123 commented Aug 26, 2022

@asturur What do you think about this approach?
If you approve I will replace all occurrences of the configured files

Extract config from HEADER to a dedicated class

@github-actions
Copy link
Contributor

github-actions bot commented Aug 26, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |   82.11 |    74.63 |   84.34 |   80.73 |                                               
 fabric.js |   82.11 |    74.63 |   84.34 |   80.73 | ...-27673,27789-27790,27811-27852,27867-28026 
-----------|---------|----------|---------|---------|-----------------------------------------------

@github-actions
Copy link
Contributor

github-actions bot commented Aug 26, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |   82.12 |    74.66 |   84.34 |   80.74 |                                               
 fabric.js |   82.12 |    74.66 |   84.34 |   80.74 | ...-27673,27789-27790,27811-27852,27867-28026 
-----------|---------|----------|---------|---------|-----------------------------------------------

1 similar comment
@github-actions
Copy link
Contributor

github-actions bot commented Aug 26, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |   82.12 |    74.66 |   84.34 |   80.74 |                                               
 fabric.js |   82.12 |    74.66 |   84.34 |   80.74 | ...-27673,27789-27790,27811-27852,27867-28026 
-----------|---------|----------|---------|---------|-----------------------------------------------

src/config.ts Outdated Show resolved Hide resolved
src/config.ts Outdated
*/
forceGLPutImageData = false

NUM_FRACTION_DIGITS = 2
Copy link
Member

Choose a reason for hiding this comment

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

We should leave a note here, that this represent the number of digits when exporting to json. Is a good idea to bump this to 4 or more for designs app, and that is kept to 2 otherwise testing the library is a mess

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 think we should remove this strange const and introduce it in the options object passed to toObject and toSVG
It is really bad IMO, e.g. #8178

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 fix tests accordingly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

bumped to 4

@asturur
Copy link
Member

asturur commented Aug 26, 2022

for me is fine, those things had to go out from header ( probably all header will go away )

@ShaMan123
Copy link
Contributor Author

header go away!

@github-actions
Copy link
Contributor

github-actions bot commented Aug 26, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |   82.05 |    74.69 |   84.44 |   80.67 |                                               
 fabric.js |   82.05 |    74.69 |   84.44 |   80.67 | ...-27584,27700-27701,27722-27763,27778-27937 
-----------|---------|----------|---------|---------|-----------------------------------------------

@github-actions
Copy link
Contributor

github-actions bot commented Aug 27, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |   82.21 |    74.78 |    84.5 |   80.77 |                                               
 fabric.js |   82.21 |    74.78 |    84.5 |   80.77 | ...-27630,27746-27747,27768-27809,27824-27983 
-----------|---------|----------|---------|---------|-----------------------------------------------

@github-actions
Copy link
Contributor

github-actions bot commented Aug 27, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |    82.2 |    74.75 |    84.5 |   80.75 |                                               
 fabric.js |    82.2 |    74.75 |    84.5 |   80.75 | ...-27630,27746-27747,27768-27809,27824-27983 
-----------|---------|----------|---------|---------|-----------------------------------------------

@github-actions
Copy link
Contributor

github-actions bot commented Aug 27, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |   82.21 |    74.69 |    84.4 |   80.77 |                                               
 fabric.js |   82.21 |    74.69 |    84.4 |   80.77 | ...-27644,27760-27761,27782-27823,27838-27997 
-----------|---------|----------|---------|---------|-----------------------------------------------

@github-actions
Copy link
Contributor

github-actions bot commented Aug 27, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |   82.17 |    74.68 |   84.35 |   80.73 |                                               
 fabric.js |   82.17 |    74.68 |   84.35 |   80.73 | ...-27650,27766-27767,27788-27829,27844-28003 
-----------|---------|----------|---------|---------|-----------------------------------------------

@github-actions
Copy link
Contributor

github-actions bot commented Aug 27, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |   82.18 |    74.72 |   84.35 |   80.74 |                                               
 fabric.js |   82.18 |    74.72 |   84.35 |   80.74 | ...-27641,27757-27758,27779-27820,27835-27994 
-----------|---------|----------|---------|---------|-----------------------------------------------

@github-actions
Copy link
Contributor

github-actions bot commented Aug 27, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |   82.18 |    74.72 |   84.35 |   80.74 |                                               
 fabric.js |   82.18 |    74.72 |   84.35 |   80.74 | ...-27641,27757-27758,27779-27820,27835-27994 
-----------|---------|----------|---------|---------|-----------------------------------------------

@github-actions
Copy link
Contributor

github-actions bot commented Aug 27, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |   82.17 |    74.68 |   84.35 |   80.73 |                                               
 fabric.js |   82.17 |    74.68 |   84.35 |   80.73 | ...-27641,27757-27758,27779-27820,27835-27994 
-----------|---------|----------|---------|---------|-----------------------------------------------

@github-actions
Copy link
Contributor

github-actions bot commented Aug 27, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |   82.23 |    74.75 |   84.35 |    80.8 |                                               
 fabric.js |   82.23 |    74.75 |   84.35 |    80.8 | ...-27642,27758-27759,27780-27821,27836-27995 
-----------|---------|----------|---------|---------|-----------------------------------------------

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.

I really dislike NUM_FRATION_DIGITS and think it should be replaced with an option
But for now I am done

*/
fabric.minCacheSideLimit = 256;
config.configure({
devicePixelRatio: fabric.window.devicePixelRatio ||
Copy link
Contributor Author

@ShaMan123 ShaMan123 Aug 27, 2022

Choose a reason for hiding this comment

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

once the window context is exported we should move this logic to config.ts

* Map of font files
* Map<fontFamily, pathToFile> of font files
*/
fontPaths: Record</** fontFamily */ string, /** pathToFile */ string> = {}
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 don't really understand for this is used for
Can it be made a local var in canvas#toSVG?
It's the only place it is used....
I thought exposing registerFonts that will add fonts to fontPaths and call register fonts on node canvas.
??

Copy link
Member

Choose a reason for hiding this comment

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

this can be made local to the svg export function yes. But for this PR we should leave it here i guess.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

only used by canvas.toSVG

@ShaMan123
Copy link
Contributor Author

Most of these values can be localized I guess...

Comment on lines +90 to +91
fabric.window.webkitDevicePixelRatio ||
fabric.window.mozDevicePixelRatio ||
Copy link
Member

Choose a reason for hiding this comment

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

i think we can verify which browser still need those, and we can removed if is something super old.

* @default 1
*/
fabric.browserShadowBlurConstant = 1;
fabric.charWidthsCache = {};
Copy link
Member

Choose a reason for hiding this comment

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

i m going to take care of this later for the charWidthsCache. I want to change it to a Map.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

excellent

but change it in #8198

Comment on lines +145 to +148
this.fontPaths = {
...this.fontPaths,
...paths
};
Copy link
Member

Choose a reason for hiding this comment

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

Object.assign(this.fontPaths, paths) in general seems nicer to me, but i don't care.

Comment on lines +66 to +69
* @todo remove once rollup supports transforming enums... ANNOYING!
* https://github.com/rollup/plugins/issues/463
*/
Copy link
Member

Choose a reason for hiding this comment

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

what is the the output so far? isn't TS that supports enum?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

rollup isn't doing it right and not building an object out of the enum as TS does

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.

None yet

2 participants