Skip to content

Commit

Permalink
Merge pull request #86 from geongeorge/feature/ts-exports
Browse files Browse the repository at this point in the history
feature/ts exports
  • Loading branch information
geongeorge authored Sep 21, 2023
2 parents 4d8d385 + edae698 commit 8f8f009
Show file tree
Hide file tree
Showing 5 changed files with 520 additions and 14 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"scripts": {
"dev": "vite serve --config config/vite.config.docs.ts",
"dev:node": "vite-node ./src/node-test.ts",
"build": "tsc && vite build --config config/vite.config.ts",
"build:vite": "tsc && vite build --emptyOutDir --config config/vite.config.ts",
"build": "tsup src/canvas-txt/index.ts --dts --legacy-output",
"build:docs": "tsc && vite build --config config/vite.config.docs.ts",
"prepare": "yarn build"
},
Expand Down Expand Up @@ -44,6 +45,7 @@
"canvas": "^2.11.2",
"element-plus": "^2.2.12",
"lodash": "^4.17.21",
"tsup": "^7.2.0",
"typescript": "^4.7.4",
"unplugin-auto-import": "^0.11.0",
"unplugin-vue-components": "^0.22.0",
Expand Down
4 changes: 2 additions & 2 deletions src/canvas-txt/lib/justify.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
interface Props {
export interface JustifyLineProps {
ctx: CanvasRenderingContext2D
line: string
spaceWidth: number
Expand All @@ -20,7 +20,7 @@ export default function justifyLine({
spaceWidth,
spaceChar,
width,
}: Props) {
}: JustifyLineProps) {
const text = line.trim()
const words = text.split(/\s+/)
const numOfWords = words.length - 1
Expand Down
4 changes: 2 additions & 2 deletions src/canvas-txt/lib/split-text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import justifyLine from './justify'
// Hair space character for precise justification
const SPACE = '\u{200a}'

interface Props {
export interface SplitTextProps {
ctx: CanvasRenderingContext2D
text: string
justify: boolean
Expand All @@ -15,7 +15,7 @@ export default function splitText({
text,
justify,
width,
}: Props): string[] {
}: SplitTextProps): string[] {
const textMap = new Map<string, number>()

const measureText = (text: string): number => {
Expand Down
8 changes: 6 additions & 2 deletions src/canvas-txt/lib/text-height.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
interface Props {
interface GetTextHeightProps {
ctx: CanvasRenderingContext2D
text: string
style: string
}

export default function getTextHeight({ ctx, text, style }: Props) {
export default function getTextHeight({
ctx,
text,
style,
}: GetTextHeightProps) {
const previousTextBaseline = ctx.textBaseline
const previousFont = ctx.font

Expand Down
Loading

1 comment on commit 8f8f009

@vercel
Copy link

@vercel vercel bot commented on 8f8f009 Sep 21, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.