[improvement] repo, scripts (#220)

* Fix menu, cleanup package.json

* update changelog
This commit is contained in:
Steve Ruiz 2021-11-05 20:31:20 +00:00 committed by GitHub
parent fb77323ef2
commit ec3dae085c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 344 additions and 171 deletions

View file

@ -1,3 +1,7 @@
## 0.1.3
- Update dependencies
## 0.1.2
- Improve migrations.

View file

@ -2,7 +2,7 @@
"name": "@tldraw/tldraw-example",
"version": "0.1.2",
"private": true,
"description": "A tiny little drawing app example.",
"description": "An example project for @tldraw/tldraw.",
"author": "@steveruizok",
"license": "MIT",
"keywords": [
@ -11,16 +11,10 @@
"esbuild"
],
"scripts": {
"start": "node ./esbuild.config.mjs --dev tsc --watch"
"start": "node scripts/dev.mjs -w",
"build": "node scripts/build.mjs"
},
"files": [
"README.md",
"src"
],
"sideEffects": false,
"devDependencies": {
"react": ">=16.8",
"react-dom": "^16.8 || ^17.0",
"@liveblocks/client": "^0.12.1",
"@liveblocks/react": "^0.12.1",
"@tldraw/tldraw": "^0.1.2",
@ -31,6 +25,9 @@
"concurrently": "6.0.1",
"create-serve": "1.0.1",
"esbuild": "^0.13.8",
"esbuild-serve": "^1.0.1",
"react": ">=16.8",
"react-dom": "^16.8 || ^17.0",
"react-router": "^5.2.1",
"react-router-dom": "^5.3.0",
"rimraf": "3.0.2",

46
example/scripts/build.mjs Normal file
View file

@ -0,0 +1,46 @@
/* eslint-disable */
import fs from 'fs'
import esbuild from 'esbuild'
import { createRequire } from 'module'
const pkg = createRequire(import.meta.url)('../package.json')
async function main() {
if (fs.existsSync('./dist')) {
fs.rmSync('./dist', { recursive: true }, (e) => {
if (e) {
throw e
}
})
}
try {
esbuild.buildSync({
entryPoints: ['./src/index.tsx'],
outdir: 'dist',
minify: true,
bundle: true,
format: 'cjs',
target: 'es6',
jsxFactory: 'React.createElement',
jsxFragment: 'React.Fragment',
tsconfig: './tsconfig.json',
define: {
'process.env.NODE_ENV': '"production"',
},
metafile: false,
sourcemap: false,
})
fs.copyFile('./src/index.html', './dist/index.html', (err) => {
if (err) throw err
})
console.log(`${pkg.name}: Build completed.`)
} catch (e) {
console.log(`× ${pkg.name}: Build failed due to an error.`)
console.log(e)
}
}
main()

45
example/scripts/dev.mjs Normal file
View file

@ -0,0 +1,45 @@
/* eslint-disable no-undef */
import fs from 'fs'
import esbuildServe from 'esbuild-serve'
async function main() {
if (!fs.existsSync('./dist')) {
fs.mkdirSync('./dist')
}
fs.copyFile('./src/index.html', './dist/index.html', (err) => {
if (err) throw err
})
try {
await esbuildServe(
{
entryPoints: ['src/index.tsx'],
bundle: true,
outfile: 'dist/bundle.js',
minify: false,
sourcemap: true,
incremental: true,
target: ['chrome58', 'firefox57', 'safari11', 'edge18'],
define: {
'process.env.NODE_ENV': '"development"',
},
watch: {
onRebuild(err) {
serve.update()
err ? error('❌ Failed') : log('✅ Updated')
},
},
},
{
port: 5000,
root: './dist',
live: true,
}
)
} catch (err) {
process.exit(1)
}
}
main()

View file

@ -6,10 +6,13 @@ import {
SizeStyle,
TLDrawDocument,
TLDrawShapeType,
TLDrawState,
} from '@tldraw/tldraw'
export default function Controlled() {
const rDocument = React.useRef<TLDrawDocument>({
name: 'New Document',
version: TLDrawState.version,
id: 'doc',
pages: {
page1: {

View file

@ -17,11 +17,11 @@
"test": "jest",
"test:watch": "jest --watchAll",
"lerna": "lerna",
"start": "lerna run start:pre && lerna run start --stream --parallel",
"start": "lerna run start --stream --parallel",
"start:www": "yarn build:packages && lerna run start --parallel & cd www && yarn dev",
"build": "yarn build:packages && cd www && yarn build",
"build:packages": "cd packages/tldraw && yarn build",
"publish:patch": "yarn build:packages && lerna publish patch",
"publish:patch": "yarn test && yarn build:packages && lerna publish patch",
"docs": "lerna run docs",
"docs:watch": "lerna run docs:watch"
},

View file

@ -0,0 +1,190 @@
## 0.1.2
- Improve migrations.
## 0.1.1
- Update dependencies
## 0.1.0
- Mark dependencies as external
- Revamp UI
## 0.0.133
- Removed libraries (vec, svg, and intersect) to their own repositories.
## 0.0.133
- Migration for bindings.
## 0.0.132
- Fix bug with bounds handles.
## 0.0.131
### TLCore
- Extracted into its own repository (`tldraw/core`) and open sourced! :clap:
### TLDraw
- Updated with latest `@tldraw/core`, updated ShapeUtils API.
## 0.0.130
### TLCore
- Major change to ShapeUtils API
### TLDraw
- Rewrite utils with new API.
## 0.0.126
### TLDraw
- Swap behavior of command and alt keys in arrow shapes.
## 0.0.125
### TLDraw
- Bug fixes.
## 0.0.124
### TLDraw
- Fix typings.
## 0.0.123
### TLDraw
- Adds bound shape controls.
- Drag a bound shape control to translate shapes in that direction.
- Double click bound shape controls to select shapes in that direction.
- Fix bug in arrow decorations toggle.
## 0.0.122
### TLDraw
- Adds snapping for transforming shapes.
## 0.0.121
### Core
- Adds `snapLines`.
### TLDraw
- Adds shape snapping while translating. Hold Command/Control to disable while dragging.
## 0.0.120
### TLDraw
- Improves rectangle rendering.
- Improves zoom to fit and zoom to selection.
## 0.0.119
### TLDraw
- Fixes bug with bound arrows after undo.
## 0.0.118
### Core
- Improves multiplayer features.
### TLDraw
- Fixes bugs in text, arrows, stickies.
- Adds start binding for new arrows.
- Adds copy painting (alt + shift + drag).
- Adds side clonig.
- Adds clone dragging.
## 0.0.116
### Core
- Improves rendering on Safari.
### TLDraw
- Improves rendering on Safari.
- Minor bug fixes around selection.
- Fixes bug when undoing a newly created shape.
## 0.0.115
### Core
- Adds [side cloning](https://github.com/tldraw/tldraw/pull/149).
- Improves rendering.
### TLDraw
- Adds sticky note [side cloning](https://github.com/tldraw/tldraw/pull/149).
## 0.0.114
### TLDraw
- Improves fills for filled shapes.
## 0.0.113
### TLDraw
- Improves grouping and ungrouping.
## 0.0.112
### TLDraw
- Fixes centering on embedded TLDraw components.
- Removes expensive calls to window.
## 0.0.111
### TLDraw
- Adjust stroke widths and sizes.
- Fixes a bug on very small dashed shapes.
## 0.0.110
### Core
- Adds `user` and `users` props (optional) for multiplayer cursors. This feature is very lightly implemented.
### TLDraw
- Adds multiplayer support.
- Adds `showMenu` and `showPages` props.
- Adds `mergeState`, `updateUsers`, and `removeUser` methods.
## 0.0.109
### TLDraw
- Bumps perfect-freehand
- Fixes dots for small sized draw shapes
## 0.0.108
- Adds CHANGELOG. Only 108 releases late!
### TLDraw
- Fixes a bug with bounding boxes on arrows.

View file

@ -1,21 +0,0 @@
MIT License
Copyright (c) 2021 Stephen Ruiz Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -1,27 +1,29 @@
{
"name": "@tldraw/tldraw",
"version": "0.1.2",
"private": false,
"description": "A tiny little drawing app (editor)",
"author": "@steveruizok",
"repository": {
"type": "git",
"url": "git+https://github.com/tldraw/tldraw.git",
"directory": "packages/tldraw"
"url": "git+https://github.com/tldraw/tldraw.git"
},
"license": "MIT",
"keywords": [],
"keywords": [
"react",
"canvas",
"zoom",
"drawing",
"whiteboard"
],
"files": [
"dist/**/*"
],
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
"types": "./dist/types/index.d.ts",
"typings": "./dist/types/index.d.ts",
"scripts": {
"start": "node scripts/dev & yarn types:dev",
"build": "node scripts/build && yarn types:build && node scripts/copy-readme",
"types:pre": "tsc",
"types:dev": "tsc -w",
"types:build": "tsc -p tsconfig.build.json && tsconfig-replace-paths -p tsconfig.build.json",
"lint": "eslint src/ --ext .ts,.tsx",
@ -32,8 +34,7 @@
},
"peerDependencies": {
"react": ">=16.8",
"react-dom": "^16.8 || ^17.0",
"tslib": "^2.3.1"
"react-dom": "^16.8 || ^17.0"
},
"dependencies": {
"@radix-ui/react-alert-dialog": "^0.1.1",
@ -45,15 +46,16 @@
"@radix-ui/react-radio-group": "^0.1.1",
"@radix-ui/react-tooltip": "^0.1.1",
"@stitches/react": "^1.2.5",
"@tldraw/core": "^0.1.17",
"@tldraw/core": "^0.1.18",
"@tldraw/intersect": "^0.1.3",
"@tldraw/vec": "^0.1.3",
"perfect-freehand": "^1.0.16",
"react-hotkeys-hook": "^3.4.0",
"rko": "^0.6.0"
"rko": "^0.6.0",
"tslib": "^2.3.1"
},
"devDependencies": {
"tsconfig-replace-paths": "^0.0.5"
},
"gitHead": "083b36e167b6911927a6b58cbbb830b11b33f00a"
}
}

View file

@ -2,8 +2,7 @@
const fs = require('fs')
const esbuild = require('esbuild')
const { gzip } = require('zlib')
const name = process.env.npm_package_name || ''
const pkg = require('../package.json')
async function main() {
if (fs.existsSync('./dist')) {
@ -25,24 +24,7 @@ async function main() {
jsxFactory: 'React.createElement',
jsxFragment: 'React.Fragment',
tsconfig: './tsconfig.json',
external: [
'react',
'react-dom',
'tslib',
'@stitches/react',
'@radix-ui/react-alert-dialog',
'@radix-ui/react-checkbox',
'@radix-ui/react-context-menu',
'@radix-ui/react-dropdown-menu',
'@radix-ui/react-icons',
'@radix-ui/react-id',
'@radix-ui/react-radio',
'@radix-ui/react-tooltip',
'perfect-freehand',
'rko',
'react-hotkeys-hook',
'browser-fs-access',
],
external: Object.keys(pkg.dependencies).concat(Object.keys(pkg.peerDependencies)),
metafile: true,
})
@ -56,27 +38,7 @@ async function main() {
tsconfig: './tsconfig.build.json',
jsxFactory: 'React.createElement',
jsxFragment: 'React.Fragment',
external: [
'react',
'react-dom',
'tslib',
'@stitches/react',
'@radix-ui/react-alert-dialog',
'@radix-ui/react-checkbox',
'@radix-ui/react-context-menu',
'@radix-ui/react-dropdown-menu',
'@radix-ui/react-icons',
'@radix-ui/react-id',
'@radix-ui/react-radio',
'@radix-ui/react-tooltip',
'@tldraw/core',
'@tldraw/vec',
'@tldraw/intersect',
'perfect-freehand',
'rko',
'react-hotkeys-hook',
'browser-fs-access',
],
external: Object.keys(pkg.dependencies).concat(Object.keys(pkg.peerDependencies)),
metafile: true,
})
@ -88,14 +50,14 @@ async function main() {
fs.readFile('./dist/esm/index.js', (_err, data) => {
gzip(data, (_err, result) => {
console.log(
`${name}: Built package. ${(esmSize / 1000).toFixed(2)}kb (${(
`${pkg.name}: Built pkg. ${(esmSize / 1000).toFixed(2)}kb (${(
result.length / 1000
).toFixed(2)}kb minified)`
)
})
})
} catch (e) {
console.log(`× ${name}: Build failed due to an error.`)
console.log(`× ${pkg.name}: Build failed due to an error.`)
console.log(e)
}
}

View file

@ -1,7 +1,7 @@
/* eslint-disable */
const fs = require('fs')
const filesToCopy = ['README.md', 'LICENSE.md', 'card-repo.png']
const filesToCopy = ['README.md', 'CHANGELOG.md', 'LICENSE.md', 'card-repo.png']
filesToCopy.forEach((file) => {
fs.copyFile(`../../${file}`, `./${file}`, (err) => {

View file

@ -1,7 +1,6 @@
/* eslint-disable */
const esbuild = require('esbuild')
const name = process.env.npm_package_name || ''
const pkg = require('../package.json')
async function main() {
esbuild.build({
@ -14,36 +13,16 @@ async function main() {
jsxFactory: 'React.createElement',
jsxFragment: 'React.Fragment',
tsconfig: './tsconfig.build.json',
external: [
'react',
'react-dom',
'tslib',
'@stitches/react',
'@radix-ui/react-alert-dialog',
'@radix-ui/react-checkbox',
'@radix-ui/react-context-menu',
'@radix-ui/react-dropdown-menu',
'@radix-ui/react-icons',
'@radix-ui/react-id',
'@radix-ui/react-radio',
'@radix-ui/react-tooltip',
'@tldraw/core',
'@tldraw/vec',
'@tldraw/intersect',
'perfect-freehand',
'rko',
'react-hotkeys-hook',
'browser-fs-access',
],
external: Object.keys(pkg.dependencies).concat(Object.keys(pkg.peerDependencies)),
sourcemap: true,
incremental: true,
watch: {
onRebuild(error) {
if (error) {
console.log(`× ${name}: An error in prevented the rebuild.`)
console.log(`× ${pkg.name}: An error in prevented the rebuild.`)
return
}
console.log(`${name}: Rebuilt.`)
console.log(`${pkg.name}: Rebuilt.`)
},
},
})

View file

@ -1,47 +0,0 @@
/* eslint-disable */
const fs = require('fs')
const esbuild = require('esbuild')
async function main() {
if (fs.existsSync('./dist')) {
fs.rmSync('./dist', { recursive: true }, (e) => {
if (e) {
throw e
}
})
}
esbuild.build({
entryPoints: ['./src/index.ts'],
outdir: 'dist/esm',
minify: false,
bundle: true,
format: 'esm',
target: 'es6',
jsxFactory: 'React.createElement',
jsxFragment: 'React.Fragment',
tsconfig: './tsconfig.build.json',
external: [
'react',
'react-dom',
'tslib',
'@stitches/react',
'@radix-ui/react-alert-dialog',
'@radix-ui/react-checkbox',
'@radix-ui/react-context-menu',
'@radix-ui/react-dropdown-menu',
'@radix-ui/react-icons',
'@radix-ui/react-id',
'@radix-ui/react-radio',
'@radix-ui/react-tooltip',
'@tldraw/core',
'@tldraw/vec',
'@tldraw/intersect',
'perfect-freehand',
'rko',
'react-hotkeys-hook',
],
})
}
main()

View file

@ -121,7 +121,7 @@ export const Menu = React.memo(({ readOnly }: MenuProps) => {
{showSignInOutMenu && (
<>
<DMDivider dir="ltr" />{' '}
{callbacks.onSignIn && <DMItem onSelect={handleSignOut}>Sign In</DMItem>}
{callbacks.onSignIn && <DMItem onSelect={handleSignIn}>Sign In</DMItem>}
{callbacks.onSignOut && (
<DMItem onSelect={handleSignOut}>
Sign Out

View file

@ -42,4 +42,4 @@
"typescript": "^4.4.2"
},
"gitHead": "838fabdbff1a66d4d7ee8aa5c5d117bc55acbff2"
}
}

View file

@ -3014,23 +3014,23 @@
"@babel/runtime" "^7.12.5"
"@testing-library/dom" "^8.0.0"
"@tldraw/core@^0.1.17":
version "0.1.17"
resolved "https://registry.yarnpkg.com/@tldraw/core/-/core-0.1.17.tgz#ff3868ab00f2b28a83259e84bfc534e4fac09bf4"
integrity sha512-nWqQTQYQXgaB5vNI1N8AZlKOfsajVK1xBTnCCpkKzZuOcw+B7w0hTVwE0Mfy6HpONeBGWYoKyCC12ABQvqTV7Q==
"@tldraw/core@^0.1.18":
version "0.1.18"
resolved "https://registry.yarnpkg.com/@tldraw/core/-/core-0.1.18.tgz#b768c759c205038c9b8c7b9c9e018c67c49be0de"
integrity sha512-Oe5cPVb76oENbvJa+QDuZLfW0wXwc1XNntDB0szFq4HUofd6CtG+4P5ZXtnc0pAff61Pyp5ajwozogNy5+sVlA==
dependencies:
"@tldraw/intersect" "^0.1.3"
"@tldraw/vec" "^0.1.3"
"@tldraw/intersect" latest
"@tldraw/vec" latest
"@use-gesture/react" "^10.1.3"
"@tldraw/intersect@^0.1.3":
"@tldraw/intersect@^0.1.3", "@tldraw/intersect@latest":
version "0.1.3"
resolved "https://registry.yarnpkg.com/@tldraw/intersect/-/intersect-0.1.3.tgz#ea784576632084710cebab0ff0a56de9d2cb6fa4"
integrity sha512-8NeLOuVmiqhHTBeqFuMP3ljS8vUirenMteX336O+/2H4IfT3FiJjeN3qZyTT5N5jZvaHJKraHOp4E45wraoNZQ==
dependencies:
"@tldraw/vec" "^0.1.3"
"@tldraw/vec@^0.1.3":
"@tldraw/vec@^0.1.3", "@tldraw/vec@latest":
version "0.1.3"
resolved "https://registry.yarnpkg.com/@tldraw/vec/-/vec-0.1.3.tgz#9c2ea9592058dd1458b49dbd817690a0c74e5473"
integrity sha512-QIQu6xHWqYBarfCR2Cd55pb+HECCEFI3RlU0VEueztzGe2k5Mwcv1EuuIdPTZ1tg5o95Deo7mYgZKeZTcUCIxA==
@ -4802,7 +4802,7 @@ create-hmac@^1.1.0, create-hmac@^1.1.4, create-hmac@^1.1.7:
safe-buffer "^5.0.1"
sha.js "^2.4.8"
create-serve@1.0.1:
create-serve@1.0.1, create-serve@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/create-serve/-/create-serve-1.0.1.tgz#a52ec4cbd2d0f776d3e42338fa1f0dae69080c59"
integrity sha512-cDAmBGhkwolS7ihq7SnPE8KwjYUZl5FaI9Pq5ZBwNelSKvFR9OoAA4/B5BfB/NC+eYaykBpX9RVMfuU4DHtrPw==
@ -5461,6 +5461,14 @@ esbuild-openbsd-64@0.13.12:
resolved "https://registry.yarnpkg.com/esbuild-openbsd-64/-/esbuild-openbsd-64-0.13.12.tgz#adde32f2f1b05dc4bd4fc544d6ea5a4379f9ca4d"
integrity sha512-KuLCmYMb2kh05QuPJ+va60bKIH5wHL8ypDkmpy47lzwmdxNsuySeCMHuTv5o2Af1RUn5KLO5ZxaZeq4GEY7DaQ==
esbuild-serve@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/esbuild-serve/-/esbuild-serve-1.0.1.tgz#c388c8ff184477ec6b6278d615da8d3177e5174f"
integrity sha512-VvYDThNuwg+YAuZC+RqAgw9TpEVGoDdcvm2mTL0lU+TxDXr+QGZfJ+zc6m7cXeJ940qijvdTSZl3mQbRGN4/PA==
dependencies:
create-serve "^1.0.1"
esbuild "^0.9.0"
esbuild-sunos-64@0.13.12:
version "0.13.12"
resolved "https://registry.yarnpkg.com/esbuild-sunos-64/-/esbuild-sunos-64-0.13.12.tgz#a7ecaf52b7364fbee76dc8aa707fa3e1cff3342c"
@ -5504,6 +5512,11 @@ esbuild@^0.13.8:
esbuild-windows-64 "0.13.12"
esbuild-windows-arm64 "0.13.12"
esbuild@^0.9.0:
version "0.9.7"
resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.9.7.tgz#ea0d639cbe4b88ec25fbed4d6ff00c8d788ef70b"
integrity sha512-VtUf6aQ89VTmMLKrWHYG50uByMF4JQlVysb8dmg6cOgW8JnFCipmz7p+HNBl+RR3LLCuBxFGVauAe2wfnF9bLg==
escalade@^3.1.1:
version "3.1.1"
resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40"
@ -11565,7 +11578,7 @@ tslib@^1.0.0, tslib@^1.8.1, tslib@^1.9.0, tslib@^1.9.3:
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"
integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==
tslib@^2.1.0, tslib@^2.3.0:
tslib@^2.1.0, tslib@^2.3.0, tslib@^2.3.1:
version "2.3.1"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.3.1.tgz#e8a335add5ceae51aa261d32a490158ef042ef01"
integrity sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==