-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: convert textkit package to TS (#3077)
- Loading branch information
Showing
269 changed files
with
7,319 additions
and
6,341 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"@react-pdf/fns": patch | ||
"@react-pdf/layout": patch | ||
"@react-pdf/textkit": patch | ||
--- | ||
|
||
refactor: convert textkit package to TS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import runAdvanceWidth from '../run/advanceWidth'; | ||
import { AttributedString, Run } from '../types'; | ||
|
||
/** | ||
* Returns attributed string advancewidth | ||
* | ||
* @param attributedString - Attributed string | ||
* @returns Advance width | ||
*/ | ||
const advanceWidth = (attributedString: AttributedString) => { | ||
const reducer = (acc: number, run: Run) => acc + runAdvanceWidth(run); | ||
return attributedString.runs.reduce(reducer, 0); | ||
}; | ||
|
||
export default advanceWidth; |
19 changes: 10 additions & 9 deletions
19
...c/attributedString/advanceWidthBetween.js → ...c/attributedString/advanceWidthBetween.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import runAscent from '../run/ascent'; | ||
import { AttributedString, Run } from '../types'; | ||
|
||
/** | ||
* Returns attributed string ascent | ||
* | ||
* @param attributedString - Attributed string | ||
* @returns Ascent | ||
*/ | ||
const ascent = (attributedString: AttributedString) => { | ||
const reducer = (acc, run: Run) => Math.max(acc, runAscent(run)); | ||
return attributedString.runs.reduce(reducer, 0); | ||
}; | ||
|
||
export default ascent; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import runDescent from '../run/descent'; | ||
import { AttributedString, Run } from '../types'; | ||
|
||
/** | ||
* Returns attributed string descent | ||
* | ||
* @param attributedString - Attributed string | ||
* @returns Descent | ||
*/ | ||
const descent = (attributedString: AttributedString) => { | ||
const reducer = (acc: number, run: Run) => Math.min(acc, runDescent(run)); | ||
return attributedString.runs.reduce(reducer, 0); | ||
}; | ||
|
||
export default descent; |
11 changes: 4 additions & 7 deletions
11
.../textkit/src/attributedString/dropLast.js → .../textkit/src/attributedString/dropLast.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { AttributedString } from '../types'; | ||
|
||
/** | ||
* Returns empty attributed string | ||
* | ||
* @returns Empty attributed string | ||
*/ | ||
const empty = (): AttributedString => ({ string: '', runs: [] }); | ||
|
||
export default empty; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { last } from '@react-pdf/fns'; | ||
import { AttributedString } from '../types'; | ||
|
||
/** | ||
* Get attributed string end value | ||
* | ||
* @param attributedString - Attributed string | ||
* @returns End | ||
*/ | ||
const end = (attributedString: AttributedString) => { | ||
const { runs } = attributedString; | ||
return runs.length === 0 ? 0 : last(runs).end; | ||
}; | ||
|
||
export default end; |
11 changes: 4 additions & 7 deletions
11
...kit/src/attributedString/fromFragments.js → ...kit/src/attributedString/fromFragments.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.