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): Move more utils to TS #8164

Merged
merged 8 commits into from Aug 21, 2022
Merged

chore(TS): Move more utils to TS #8164

merged 8 commits into from Aug 21, 2022

Conversation

asturur
Copy link
Member

@asturur asturur commented Aug 21, 2022

Moving more utils

@github-actions
Copy link
Contributor

github-actions bot commented Aug 21, 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.07 |    74.55 |    84.4 |   80.66 |                                               
 fabric.js |   82.07 |    74.55 |    84.4 |   80.66 | ...,27456,27514,27524-27568,27676,27763,27967 
-----------|---------|----------|---------|---------|-----------------------------------------------

Comment on lines -549 to -571
parsePreserveAspectRatioAttribute: function(attribute) {
var meetOrSlice = 'meet', alignX = 'Mid', alignY = 'Mid',
aspectRatioAttrs = attribute.split(' '), align;

if (aspectRatioAttrs && aspectRatioAttrs.length) {
meetOrSlice = aspectRatioAttrs.pop();
if (meetOrSlice !== 'meet' && meetOrSlice !== 'slice') {
align = meetOrSlice;
meetOrSlice = 'meet';
}
else if (aspectRatioAttrs.length) {
align = aspectRatioAttrs.pop();
}
}
//divide align in alignX and alignY
alignX = align !== 'none' ? align.slice(1, 4) : 'none';
alignY = align !== 'none' ? align.slice(5, 8) : 'none';
return {
meetOrSlice: meetOrSlice,
alignX: alignX,
alignY: alignY
};
},
Copy link
Member Author

Choose a reason for hiding this comment

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

this has been rewrote to be TS friendly and readable.
I had to re-read the spec because i couldn't read anymore what this code was doing.

pc = 'pc',
em = 'em',
}

export type TMat2D = [number, number, number, number, number, number];
Copy link
Contributor

Choose a reason for hiding this comment

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

export type TMat2DBasic = [number,number,number,number];
export type TMat2DAffine = [number,number,number,number,number,number];

export type TMat2D<T> = TMat2DAffine |TMat2DBasic;

export type...

Playground Link

@@ -1,7 +1,6 @@
//@ts-nocheck

import { fabric } from '../../HEADER';
import { toArray } from '../util';
Copy link
Contributor

Choose a reason for hiding this comment

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

why not import directly from the file lang_array and not from the index?
That will solve the circular dep

Copy link
Member Author

Choose a reason for hiding this comment

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

Is what i was doing i removed for now all imports from the main index in util, and where possible i m linking to direct files.
Is probably better to leave the util/index.ts just to create the external facing export for who will use fabric.util

Copy link
Contributor

@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 think src/util/misc/svgParsing.ts should move to parser folder

@github-actions
Copy link
Contributor

github-actions bot commented Aug 21, 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.13 |    74.59 |   84.41 |   80.74 |                                               
 fabric.js |   82.13 |    74.59 |   84.41 |   80.74 | ...,27458,27516,27526-27570,27678,27765,27969 
-----------|---------|----------|---------|---------|-----------------------------------------------

@asturur
Copy link
Member Author

asturur commented Aug 21, 2022

I think src/util/misc/svgParsing.ts should move to parser folder

Yes, and there are also some duplicated functions here and there.
Let me see if i can move it now.

@asturur
Copy link
Member Author

asturur commented Aug 21, 2022

rolling back to before moving svgParsing. can't unbreak what i broke

@github-actions
Copy link
Contributor

github-actions bot commented Aug 21, 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.09 |    74.56 |   84.41 |   80.68 |                                               
 fabric.js |   82.09 |    74.56 |   84.41 |   80.68 | ...,27458,27516,27526-27570,27678,27765,27969 
-----------|---------|----------|---------|---------|-----------------------------------------------

@asturur asturur merged commit 9abc68a into master Aug 21, 2022
@asturur asturur deleted the more-more-more-utils branch September 11, 2022 23:03
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.

None yet

2 participants