Write tests, slight tweaks to build / packages
This commit is contained in:
parent
146eb87fb1
commit
183f9cd798
11 changed files with 37 additions and 37 deletions
|
@ -21,7 +21,7 @@
|
|||
"scripts": {
|
||||
"start:pre": "node scripts/pre-dev && yarn types:pre",
|
||||
"start": "node scripts/dev & yarn types:dev",
|
||||
"build": "yarn clean && node scripts/build && yarn types:build",
|
||||
"build": "node scripts/build && yarn types:build",
|
||||
"types:pre": "tsc",
|
||||
"types:dev": "tsc --watch ",
|
||||
"types:build": "tsc --project tsconfig.build.json",
|
||||
|
@ -58,4 +58,4 @@
|
|||
"deepmerge": "^4.2.2",
|
||||
"react-use-gesture": "^9.1.3"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,8 +5,12 @@ const esbuild = require('esbuild')
|
|||
const name = process.env.npm_package_name || ''
|
||||
|
||||
async function main() {
|
||||
if (!fs.existsSync('./dist')) {
|
||||
fs.mkdirSync('./dist')
|
||||
if (fs.existsSync('./dist')) {
|
||||
fs.rmSync('./dist', { recursive: true }, (e) => {
|
||||
if (e) {
|
||||
throw e
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
|
@ -11,12 +11,6 @@ async function main() {
|
|||
})
|
||||
}
|
||||
|
||||
fs.mkdir('./dist', (e) => {
|
||||
if (e) {
|
||||
throw e
|
||||
}
|
||||
})
|
||||
|
||||
esbuild.build({
|
||||
entryPoints: ['./src/index.ts'],
|
||||
outdir: 'dist/cjs',
|
||||
|
|
|
@ -11,10 +11,9 @@
|
|||
"docs"
|
||||
],
|
||||
"compilerOptions": {
|
||||
"composite": false,
|
||||
"incremental": false,
|
||||
"emitDeclarationOnly": true,
|
||||
"declarationMap": false,
|
||||
"sourceMap": false,
|
||||
"outDir": "./dist/types"
|
||||
"sourceMap": false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as React from 'react'
|
||||
import { TLDraw, TLDrawShapeType, TLDrawState } from '@tldraw/tldraw'
|
||||
import { TLDraw, TLDrawState } from '@tldraw/tldraw'
|
||||
|
||||
export default function Editor(): JSX.Element {
|
||||
const rTLDrawState = React.useRef<TLDrawState>()
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
"scripts": {
|
||||
"start:pre": "node scripts/pre-dev && yarn types:pre",
|
||||
"start": "node scripts/dev & yarn types:dev",
|
||||
"build": "yarn clean && node scripts/build && yarn types:build",
|
||||
"build": "node scripts/build && yarn types:build",
|
||||
"types:pre": "tsc",
|
||||
"types:dev": "tsc --watch",
|
||||
"types:build": "tsc --project tsconfig.build.json",
|
||||
|
|
|
@ -5,8 +5,12 @@ const esbuild = require('esbuild')
|
|||
const name = process.env.npm_package_name || ''
|
||||
|
||||
async function main() {
|
||||
if (!fs.existsSync('./dist')) {
|
||||
fs.mkdirSync('./dist')
|
||||
if (fs.existsSync('./dist')) {
|
||||
fs.rmSync('./dist', { recursive: true }, (e) => {
|
||||
if (e) {
|
||||
throw e
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
|
@ -11,12 +11,6 @@ async function main() {
|
|||
})
|
||||
}
|
||||
|
||||
fs.mkdir('./dist', (e) => {
|
||||
if (e) {
|
||||
throw e
|
||||
}
|
||||
})
|
||||
|
||||
esbuild.build({
|
||||
entryPoints: ['./src/index.ts'],
|
||||
outdir: 'dist/cjs',
|
||||
|
|
|
@ -254,13 +254,14 @@ export class Text extends TLDrawShapeUtil<TextShape> {
|
|||
const bounds = Utils.getFromCache(this.boundsCache, shape, () => {
|
||||
if (!melm) {
|
||||
// We're in SSR
|
||||
return { minX: 0, minY: 0, maxX: 10, maxY: 0, width: 0, height: 0 }
|
||||
return { minX: 0, minY: 0, maxX: 10, maxY: 10, width: 10, height: 10 }
|
||||
}
|
||||
|
||||
melm.innerHTML = `${shape.text}‍`
|
||||
melm.style.font = getFontStyle(shape.style)
|
||||
|
||||
const [width, height] = [melm.offsetWidth, melm.offsetHeight]
|
||||
// In tests, offsetWidth and offsetHeight will be 0
|
||||
const [width, height] = [melm.offsetWidth || 1, melm.offsetHeight || 1]
|
||||
|
||||
return {
|
||||
minX: 0,
|
||||
|
|
|
@ -41,18 +41,23 @@ describe('Reset bounds command', () => {
|
|||
|
||||
tlstate.resetBounds(['text1'])
|
||||
|
||||
const newScale = tlstate.getShape('text1').style.scale
|
||||
const newBounds = TLDR.getBounds(tlstate.getShape('text1'))
|
||||
const newCenter = Utils.getBoundsCenter(newBounds)
|
||||
|
||||
console.log(newScale)
|
||||
|
||||
expect(newScale).toBe(1)
|
||||
|
||||
expect(newCenter).toStrictEqual(center) // The centers should be the same
|
||||
// The scale should be back to 1
|
||||
expect(tlstate.getShape('text1').style.scale).toBe(1)
|
||||
// The centers should be the same
|
||||
expect(Utils.getBoundsCenter(TLDR.getBounds(tlstate.getShape('text1')))).toStrictEqual(center)
|
||||
|
||||
tlstate.undo()
|
||||
|
||||
// The scale should be what it was before
|
||||
expect(tlstate.getShape('text1').style.scale).not.toBe(1)
|
||||
// The centers should be the same
|
||||
expect(Utils.getBoundsCenter(TLDR.getBounds(tlstate.getShape('text1')))).toStrictEqual(center)
|
||||
|
||||
tlstate.redo()
|
||||
|
||||
// The scale should be back to 1
|
||||
expect(tlstate.getShape('text1').style.scale).toBe(1)
|
||||
// The centers should be the same
|
||||
expect(Utils.getBoundsCenter(TLDR.getBounds(tlstate.getShape('text1')))).toStrictEqual(center)
|
||||
})
|
||||
})
|
||||
|
|
|
@ -11,10 +11,9 @@
|
|||
"docs"
|
||||
],
|
||||
"compilerOptions": {
|
||||
"composite": false,
|
||||
"incremental": false,
|
||||
"sourceMap": false,
|
||||
"emitDeclarationOnly": true,
|
||||
"declarationMap": false,
|
||||
"outDir": "./dist/types"
|
||||
"sourceMap": false
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue