chore: clean up local dev tooling (#856)

* chore: clean up husky + lint-staged

* chore: format all files with prettier
This commit is contained in:
with-heart 2022-07-28 03:19:53 -04:00 committed by GitHub
parent 0985a2ceff
commit 2e36dadfec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
57 changed files with 326 additions and 441 deletions

View file

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/sh
. "$(dirname "$0")/_/husky.sh" . "$(dirname "$0")/_/husky.sh"
yarn test yarn run pre-commit

4
.husky/pre-push Executable file
View file

@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
yarn run pre-push

View file

@ -1 +1 @@
{"teamId":"team_MjXkk3MAaGtBFaHcssVUiMgd","apiUrl":"https://api.vercel.com"} { "teamId": "team_MjXkk3MAaGtBFaHcssVUiMgd", "apiUrl": "https://api.vercel.com" }

View file

@ -3,9 +3,7 @@
"description": "A tiny little drawing app for your new tab screen.", "description": "A tiny little drawing app for your new tab screen.",
"version": "1.0", "version": "1.0",
"manifest_version": 3, "manifest_version": 3,
"permissions": [ "permissions": ["unlimitedStorage"],
"unlimitedStorage"
],
"default_icon": { "default_icon": {
"16": "16.png", "16": "16.png",
"32": "32.png", "32": "32.png",

View file

@ -16,15 +16,9 @@
"--extensionDevelopmentPath=${workspaceFolder}", "--extensionDevelopmentPath=${workspaceFolder}",
"${workspaceFolder}/src/extension.ts" "${workspaceFolder}/src/extension.ts"
], ],
"outFiles": [ "outFiles": ["${workspaceFolder}/dist/web/**/*.js", "!**/node_modules/**"],
"${workspaceFolder}/dist/web/**/*.js", "skipFiles": ["<node_internals>/**", "**/node_modules/**"],
"!**/node_modules/**" "sourceMaps": true
],
"skipFiles": [
"<node_internals>/**",
"**/node_modules/**"
],
"sourceMaps": true,
} }
] ]
} }

View file

@ -1,136 +1,136 @@
{ {
"name": "tldraw-vscode", "name": "tldraw-vscode",
"displayName": "tldraw", "displayName": "tldraw",
"description": "The tldraw Extension for VS Code.", "description": "The tldraw Extension for VS Code.",
"version": "1.19.0", "version": "1.19.0",
"license": "MIT", "license": "MIT",
"publisher": "tldraw-org", "publisher": "tldraw-org",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/tldraw/tldraw" "url": "https://github.com/tldraw/tldraw"
}, },
"engines": { "engines": {
"vscode": "^1.59.0" "vscode": "^1.59.0"
}, },
"keywords": [ "keywords": [
"diagram", "diagram",
"draw", "draw",
"drawing", "drawing",
"sketch", "sketch",
"design", "design",
"documentation", "documentation",
"tldraw" "tldraw"
], ],
"icon": "icon.png", "icon": "icon.png",
"galleryBanner": { "galleryBanner": {
"color": "#1d1d1d", "color": "#1d1d1d",
"theme": "dark" "theme": "dark"
}, },
"categories": [ "categories": [
"Visualization" "Visualization"
], ],
"activationEvents": [ "activationEvents": [
"onCustomEditor:tldraw.tldr", "onCustomEditor:tldraw.tldr",
"onCommand:tldraw.tldr.new" "onCommand:tldraw.tldr.new"
], ],
"browser": "./dist/web/extension.js", "browser": "./dist/web/extension.js",
"main": "./dist/web/extension.js", "main": "./dist/web/extension.js",
"extensionKind": [ "extensionKind": [
"workspace" "workspace"
], ],
"contributes": { "contributes": {
"customEditors": [ "customEditors": [
{ {
"viewType": "tldraw.tldr", "viewType": "tldraw.tldr",
"displayName": "tldraw", "displayName": "tldraw",
"selector": [ "selector": [
{ {
"filenamePattern": "*.tldr" "filenamePattern": "*.tldr"
}, },
{ {
"filenamePattern": "*.tldr.json" "filenamePattern": "*.tldr.json"
} }
] ]
} }
], ],
"keybindings": [ "keybindings": [
{ {
"key": "ctrl+shift+d", "key": "ctrl+shift+d",
"mac": "cmd+shift+d", "mac": "cmd+shift+d",
"title": "Toggle Dark Mode", "title": "Toggle Dark Mode",
"command": "tldraw.tldr.toggleDarkMode", "command": "tldraw.tldr.toggleDarkMode",
"category": "tldraw", "category": "tldraw",
"when": "resourceExtname == .tldr" "when": "resourceExtname == .tldr"
}, },
{ {
"key": "ctrl+numpad_add", "key": "ctrl+numpad_add",
"mac": "cmd+numpad_add", "mac": "cmd+numpad_add",
"title": "Zoom In", "title": "Zoom In",
"command": "tldraw.tldr.zoomIn", "command": "tldraw.tldr.zoomIn",
"category": "tldraw", "category": "tldraw",
"when": "resourceExtname == .tldr" "when": "resourceExtname == .tldr"
}, },
{ {
"key": "ctrl+=", "key": "ctrl+=",
"mac": "cmd+=", "mac": "cmd+=",
"title": "Zoom In", "title": "Zoom In",
"command": "tldraw.tldr.zoomIn", "command": "tldraw.tldr.zoomIn",
"category": "tldraw", "category": "tldraw",
"when": "resourceExtname == .tldr" "when": "resourceExtname == .tldr"
}, },
{ {
"key": "ctrl+numpad_subtract", "key": "ctrl+numpad_subtract",
"mac": "cmd+numpad_subtract", "mac": "cmd+numpad_subtract",
"title": "Zoom Out", "title": "Zoom Out",
"command": "tldraw.tldr.zoomOut", "command": "tldraw.tldr.zoomOut",
"category": "tldraw", "category": "tldraw",
"when": "resourceExtname == .tldr" "when": "resourceExtname == .tldr"
}, },
{ {
"key": "ctrl+-", "key": "ctrl+-",
"mac": "cmd+-", "mac": "cmd+-",
"title": "Zoom Out", "title": "Zoom Out",
"command": "tldraw.tldr.zoomOut", "command": "tldraw.tldr.zoomOut",
"category": "tldraw", "category": "tldraw",
"when": "resourceExtname == .tldr" "when": "resourceExtname == .tldr"
}, },
{ {
"key": "ctrl+numpad0", "key": "ctrl+numpad0",
"mac": "cmd+numpad0", "mac": "cmd+numpad0",
"title": "Reset Zoom", "title": "Reset Zoom",
"command": "tldraw.tldr.resetZoom", "command": "tldraw.tldr.resetZoom",
"category": "tldraw", "category": "tldraw",
"when": "resourceExtname == .tldr" "when": "resourceExtname == .tldr"
} }
], ],
"commands": [ "commands": [
{ {
"command": "tldraw.tldr.new", "command": "tldraw.tldr.new",
"title": "New File", "title": "New File",
"category": "tldraw" "category": "tldraw"
} }
] ]
}, },
"scripts": { "scripts": {
"start:vscode": "node scripts/dev", "start:vscode": "node scripts/dev",
"build:apps": "yarn build", "build:apps": "yarn build",
"build": "yarn package", "build": "yarn package",
"web": "vscode-test-web --browserType=chromium --extensionDevelopmentPath=.", "web": "vscode-test-web --browserType=chromium --extensionDevelopmentPath=.",
"package": "cd ../editor && yarn build && cd ../extension && node scripts/build && node scripts/package", "package": "cd ../editor && yarn build && cd ../extension && node scripts/build && node scripts/package",
"publish": "yarn package && vsce publish", "publish": "yarn package && vsce publish",
"lint": "eslint src --ext ts" "lint": "eslint src --ext ts"
}, },
"devDependencies": { "devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.10.2", "@typescript-eslint/eslint-plugin": "^5.10.2",
"@typescript-eslint/parser": "^5.10.2", "@typescript-eslint/parser": "^5.10.2",
"assert": "^2.0.0", "assert": "^2.0.0",
"eslint": "^8.8.0", "eslint": "^8.8.0",
"mocha": "^9.1.1", "mocha": "^9.1.1",
"process": "^0.11.10", "process": "^0.11.10",
"ts-loader": "^9.2.5", "ts-loader": "^9.2.5",
"tslib": "^2.4.0", "tslib": "^2.4.0",
"typescript": "^4.7.3", "typescript": "^4.7.3",
"vsce": "^2.2.0" "vsce": "^2.2.0"
}, },
"gitHead": "4b1137849ad07da36fc8f0f19cb64e7535a79296" "gitHead": "4b1137849ad07da36fc8f0f19cb64e7535a79296"
} }

View file

@ -16,7 +16,7 @@ export default async function CreateMultiplayerRoom(req: NextApiRequest, res: Ne
Authorization: `Bearer ${process.env.LIVEBLOCKS_SECRET_KEY}`, Authorization: `Bearer ${process.env.LIVEBLOCKS_SECRET_KEY}`,
'Content-Type': 'application/json', 'Content-Type': 'application/json',
}, },
}).then(d => d.json()) }).then((d) => d.json())
// 2. Create the Liveblocks storage JSON // 2. Create the Liveblocks storage JSON

View file

@ -29,7 +29,6 @@
"start:vscode": "code apps/vscode/extension & turbo run start:vscode --parallel; ", "start:vscode": "code apps/vscode/extension & turbo run start:vscode --parallel; ",
"version": "yarn changeset version", "version": "yarn changeset version",
"changeset": "changeset", "changeset": "changeset",
"fix:style": "yarn run prettier ./packages/core/src --write && yarn run prettier ./packages/tldraw/src --write",
"turbo": "turbo", "turbo": "turbo",
"test": "turbo run test --stream", "test": "turbo run test --stream",
"test:ci": "turbo run test:ci --stream", "test:ci": "turbo run test:ci --stream",
@ -37,8 +36,9 @@
"docs": "turbo run docs", "docs": "turbo run docs",
"docs:watch": "turbo run docs --watch", "docs:watch": "turbo run docs --watch",
"postinstall": "husky install", "postinstall": "husky install",
"pretty-quick": "pretty-quick", "clean": "turbo run clean",
"clean": "turbo run clean" "pre-commit": "lint-staged",
"pre-push": "yarn test"
}, },
"devDependencies": { "devDependencies": {
"@swc-node/jest": "^1.4.3", "@swc-node/jest": "^1.4.3",
@ -58,7 +58,6 @@
"lint-staged": "^12.3.3", "lint-staged": "^12.3.3",
"mobx": "^6.3.8", "mobx": "^6.3.8",
"prettier": "^2.5.1", "prettier": "^2.5.1",
"pretty-quick": "^3.1.3",
"resize-observer-polyfill": "^1.5.1", "resize-observer-polyfill": "^1.5.1",
"source-map-loader": "^3.0.1", "source-map-loader": "^3.0.1",
"tslib": "^2.4.0", "tslib": "^2.4.0",
@ -67,11 +66,9 @@
"typescript": "^4.7.3", "typescript": "^4.7.3",
"webpack": "^5.68.0" "webpack": "^5.68.0"
}, },
"husky": { "lint-staged": {
"hooks": { "*": "prettier --ignore-unknown --write",
"pre-commit": "pretty-quick --staged", "*.{ts,tsx}": "eslint --fix"
"pre-push": "fix:style && eslint && test"
}
}, },
"packageManager": "yarn@1.22.17", "packageManager": "yarn@1.22.17",
"dependencies": { "dependencies": {

View file

@ -251,7 +251,7 @@ export function useKeyboardShortcuts(ref: React.RefObject<HTMLDivElement>) {
useHotkeys( useHotkeys(
'⌘+z,ctrl+z', '⌘+z,ctrl+z',
(e) => { (e) => {
e.preventDefault(); e.preventDefault()
if (!canHandleEvent(true)) return if (!canHandleEvent(true)) return
if (app.session) { if (app.session) {

View file

@ -16,10 +16,10 @@
// @license © 2020 Google LLC. Licensed under the Apache License, Version 2.0. // @license © 2020 Google LLC. Licensed under the Apache License, Version 2.0.
const getFileWithHandle = async (handle) => { const getFileWithHandle = async (handle) => {
const file = await handle.getFile(); const file = await handle.getFile()
file.handle = handle; file.handle = handle
return file; return file
}; }
/** /**
* Opens a file from disk using the File System Access API. * Opens a file from disk using the File System Access API.
@ -27,32 +27,32 @@ const getFileWithHandle = async (handle) => {
*/ */
export default async (options = [{}]) => { export default async (options = [{}]) => {
if (!Array.isArray(options)) { if (!Array.isArray(options)) {
options = [options]; options = [options]
} }
const types = []; const types = []
options.forEach((option, i) => { options.forEach((option, i) => {
types[i] = { types[i] = {
description: option.description || '', description: option.description || '',
accept: {}, accept: {},
}; }
if (option.mimeTypes) { if (option.mimeTypes) {
option.mimeTypes.map((mimeType) => { option.mimeTypes.map((mimeType) => {
types[i].accept[mimeType] = option.extensions || []; types[i].accept[mimeType] = option.extensions || []
}); })
} else { } else {
types[i].accept['*/*'] = option.extensions || []; types[i].accept['*/*'] = option.extensions || []
} }
}); })
const handleOrHandles = await window.showOpenFilePicker({ const handleOrHandles = await window.showOpenFilePicker({
id: options[0].id, id: options[0].id,
startIn: options[0].startIn, startIn: options[0].startIn,
types, types,
multiple: options[0].multiple || false, multiple: options[0].multiple || false,
excludeAcceptAllOption: options[0].excludeAcceptAllOption || false, excludeAcceptAllOption: options[0].excludeAcceptAllOption || false,
}); })
const files = await Promise.all(handleOrHandles.map(getFileWithHandle)); const files = await Promise.all(handleOrHandles.map(getFileWithHandle))
if (options[0].multiple) { if (options[0].multiple) {
return files; return files
} }
return files[0]; return files[0]
}; }

View file

@ -26,41 +26,38 @@ export default async (
throwIfExistingHandleNotGood = false throwIfExistingHandleNotGood = false
) => { ) => {
if (!Array.isArray(options)) { if (!Array.isArray(options)) {
options = [options]; options = [options]
} }
options[0].fileName = options[0].fileName || 'Untitled'; options[0].fileName = options[0].fileName || 'Untitled'
const types = []; const types = []
options.forEach((option, i) => { options.forEach((option, i) => {
types[i] = { types[i] = {
description: option.description || '', description: option.description || '',
accept: {}, accept: {},
}; }
if (option.mimeTypes) { if (option.mimeTypes) {
if (i === 0) { if (i === 0) {
if (blobOrResponse.type) { if (blobOrResponse.type) {
option.mimeTypes.push(blobOrResponse.type); option.mimeTypes.push(blobOrResponse.type)
} else if ( } else if (blobOrResponse.headers && blobOrResponse.headers.get('content-type')) {
blobOrResponse.headers && option.mimeTypes.push(blobOrResponse.headers.get('content-type'))
blobOrResponse.headers.get('content-type')
) {
option.mimeTypes.push(blobOrResponse.headers.get('content-type'));
} }
} }
option.mimeTypes.map((mimeType) => { option.mimeTypes.map((mimeType) => {
types[i].accept[mimeType] = option.extensions || []; types[i].accept[mimeType] = option.extensions || []
}); })
} else if (blobOrResponse.type) { } else if (blobOrResponse.type) {
types[i].accept[blobOrResponse.type] = option.extensions || []; types[i].accept[blobOrResponse.type] = option.extensions || []
} }
}); })
if (existingHandle) { if (existingHandle) {
try { try {
// Check if the file still exists. // Check if the file still exists.
await existingHandle.getFile(); await existingHandle.getFile()
} catch (err) { } catch (err) {
existingHandle = null; existingHandle = null
if (throwIfExistingHandleNotGood) { if (throwIfExistingHandleNotGood) {
throw err; throw err
} }
} }
} }
@ -72,20 +69,20 @@ export default async (
startIn: options[0].startIn, startIn: options[0].startIn,
types, types,
excludeAcceptAllOption: options[0].excludeAcceptAllOption || false, excludeAcceptAllOption: options[0].excludeAcceptAllOption || false,
})); }))
const writable = await handle.createWritable(); const writable = await handle.createWritable()
// Use streaming on the `Blob` if the browser supports it. // Use streaming on the `Blob` if the browser supports it.
if ('stream' in blobOrResponse) { if ('stream' in blobOrResponse) {
const stream = blobOrResponse.stream(); const stream = blobOrResponse.stream()
await stream.pipeTo(writable); await stream.pipeTo(writable)
return handle; return handle
// Handle passed `ReadableStream`. // Handle passed `ReadableStream`.
} else if ('body' in blobOrResponse) { } else if ('body' in blobOrResponse) {
await blobOrResponse.body.pipeTo(writable); await blobOrResponse.body.pipeTo(writable)
return handle; return handle
} }
// Default case of `Blob` passed and `Blob.stream()` not supported. // Default case of `Blob` passed and `Blob.stream()` not supported.
await writable.write(blob); await writable.write(blob)
await writable.close(); await writable.close()
return handle; return handle
}; }

View file

@ -22,49 +22,48 @@
*/ */
export default async (options = [{}]) => { export default async (options = [{}]) => {
if (!Array.isArray(options)) { if (!Array.isArray(options)) {
options = [options]; options = [options]
} }
options[0].recursive = options[0].recursive || false; options[0].recursive = options[0].recursive || false
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const input = document.createElement('input'); const input = document.createElement('input')
input.type = 'file'; input.type = 'file'
input.webkitdirectory = true; input.webkitdirectory = true
const _reject = () => cleanupListenersAndMaybeReject(reject); const _reject = () => cleanupListenersAndMaybeReject(reject)
const _resolve = (value) => { const _resolve = (value) => {
if (typeof cleanupListenersAndMaybeReject === 'function') { if (typeof cleanupListenersAndMaybeReject === 'function') {
cleanupListenersAndMaybeReject(); cleanupListenersAndMaybeReject()
} }
resolve(value); resolve(value)
}; }
// ToDo: Remove this workaround once // ToDo: Remove this workaround once
// https://github.com/whatwg/html/issues/6376 is specified and supported. // https://github.com/whatwg/html/issues/6376 is specified and supported.
const cleanupListenersAndMaybeReject = const cleanupListenersAndMaybeReject =
options[0].legacySetup && options[0].legacySetup && options[0].legacySetup(_resolve, _reject, input)
options[0].legacySetup(_resolve, _reject, input);
input.addEventListener('change', () => { input.addEventListener('change', () => {
let files = Array.from(input.files); let files = Array.from(input.files)
if (!options[0].recursive) { if (!options[0].recursive) {
files = files.filter((file) => { files = files.filter((file) => {
return file.webkitRelativePath.split('/').length === 2; return file.webkitRelativePath.split('/').length === 2
}); })
} else if (options[0].recursive && options[0].skipDirectory) { } else if (options[0].recursive && options[0].skipDirectory) {
files = files.filter((file) => { files = files.filter((file) => {
const directoriesName = file.webkitRelativePath.split('/'); const directoriesName = file.webkitRelativePath.split('/')
return directoriesName.every( return directoriesName.every(
(directoryName) => (directoryName) =>
!options[0].skipDirectory({ !options[0].skipDirectory({
name: directoryName, name: directoryName,
kind: 'directory', kind: 'directory',
}) })
); )
}); })
} }
_resolve(files); _resolve(files)
}); })
input.click(); input.click()
}); })
}; }

View file

@ -21,34 +21,33 @@
*/ */
export default async (options = [{}]) => { export default async (options = [{}]) => {
if (!Array.isArray(options)) { if (!Array.isArray(options)) {
options = [options]; options = [options]
} }
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const input = document.createElement('input'); const input = document.createElement('input')
input.type = 'file'; input.type = 'file'
const accept = [ const accept = [
...options.map((option) => option.mimeTypes || []).join(), ...options.map((option) => option.mimeTypes || []).join(),
options.map((option) => option.extensions || []).join(), options.map((option) => option.extensions || []).join(),
].join(); ].join()
input.multiple = options[0].multiple || false; input.multiple = options[0].multiple || false
// Empty string allows everything. // Empty string allows everything.
input.accept = accept || ''; input.accept = accept || ''
const _reject = () => cleanupListenersAndMaybeReject(reject); const _reject = () => cleanupListenersAndMaybeReject(reject)
const _resolve = (value) => { const _resolve = (value) => {
if (typeof cleanupListenersAndMaybeReject === 'function') { if (typeof cleanupListenersAndMaybeReject === 'function') {
cleanupListenersAndMaybeReject(); cleanupListenersAndMaybeReject()
} }
resolve(value); resolve(value)
}; }
// ToDo: Remove this workaround once // ToDo: Remove this workaround once
// https://github.com/whatwg/html/issues/6376 is specified and supported. // https://github.com/whatwg/html/issues/6376 is specified and supported.
const cleanupListenersAndMaybeReject = const cleanupListenersAndMaybeReject =
options[0].legacySetup && options[0].legacySetup && options[0].legacySetup(_resolve, _reject, input)
options[0].legacySetup(_resolve, _reject, input);
input.addEventListener('change', () => { input.addEventListener('change', () => {
_resolve(input.multiple ? Array.from(input.files) : input.files[0]); _resolve(input.multiple ? Array.from(input.files) : input.files[0])
}); })
input.click(); input.click()
}); })
}; }

View file

@ -21,40 +21,37 @@
*/ */
export default async (blobOrResponse, options = {}) => { export default async (blobOrResponse, options = {}) => {
if (Array.isArray(options)) { if (Array.isArray(options)) {
options = options[0]; options = options[0]
} }
const a = document.createElement('a'); const a = document.createElement('a')
let data = blobOrResponse; let data = blobOrResponse
// Handle the case where input is a `ReadableStream`. // Handle the case where input is a `ReadableStream`.
if ('body' in blobOrResponse) { if ('body' in blobOrResponse) {
data = await streamToBlob( data = await streamToBlob(blobOrResponse.body, blobOrResponse.headers.get('content-type'))
blobOrResponse.body,
blobOrResponse.headers.get('content-type')
);
} }
a.download = options.fileName || 'Untitled'; a.download = options.fileName || 'Untitled'
a.href = URL.createObjectURL(data); a.href = URL.createObjectURL(data)
const _reject = () => cleanupListenersAndMaybeReject(reject); const _reject = () => cleanupListenersAndMaybeReject(reject)
const _resolve = () => { const _resolve = () => {
if (typeof cleanupListenersAndMaybeReject === 'function') { if (typeof cleanupListenersAndMaybeReject === 'function') {
cleanupListenersAndMaybeReject(); cleanupListenersAndMaybeReject()
} }
}; }
// ToDo: Remove this workaround once // ToDo: Remove this workaround once
// https://github.com/whatwg/html/issues/6376 is specified and supported. // https://github.com/whatwg/html/issues/6376 is specified and supported.
const cleanupListenersAndMaybeReject = const cleanupListenersAndMaybeReject =
options.legacySetup && options.legacySetup(_resolve, _reject, a); options.legacySetup && options.legacySetup(_resolve, _reject, a)
a.addEventListener('click', () => { a.addEventListener('click', () => {
// `setTimeout()` due to // `setTimeout()` due to
// https://github.com/LLK/scratch-gui/issues/1783#issuecomment-426286393 // https://github.com/LLK/scratch-gui/issues/1783#issuecomment-426286393
setTimeout(() => URL.revokeObjectURL(a.href), 30 * 1000); setTimeout(() => URL.revokeObjectURL(a.href), 30 * 1000)
_resolve(null); _resolve(null)
}); })
a.click(); a.click()
return null; return null
}; }
/** /**
* Converts a passed `ReadableStream` to a `Blob`. * Converts a passed `ReadableStream` to a `Blob`.
@ -63,10 +60,10 @@ export default async (blobOrResponse, options = {}) => {
* @returns {Promise<Blob>} * @returns {Promise<Blob>}
*/ */
async function streamToBlob(stream, type) { async function streamToBlob(stream, type) {
const reader = stream.getReader(); const reader = stream.getReader()
const pumpedStream = new ReadableStream({ const pumpedStream = new ReadableStream({
start(controller) { start(controller) {
return pump(); return pump()
/** /**
* Recursively pumps data chunks out of the `ReadableStream`. * Recursively pumps data chunks out of the `ReadableStream`.
* @type { () => Promise<void> } * @type { () => Promise<void> }
@ -74,17 +71,17 @@ async function streamToBlob(stream, type) {
async function pump() { async function pump() {
return reader.read().then(({ done, value }) => { return reader.read().then(({ done, value }) => {
if (done) { if (done) {
controller.close(); controller.close()
return; return
} }
controller.enqueue(value); controller.enqueue(value)
return pump(); return pump()
}); })
} }
}, },
}); })
const res = new Response(pumpedStream); const res = new Response(pumpedStream)
reader.releaseLock(); reader.releaseLock()
return new Blob([await res.blob()], { type }); return new Blob([await res.blob()], { type })
} }

View file

@ -36,7 +36,7 @@ export class DrawTool extends BaseTool {
/* ----------------- Event Handlers ----------------- */ /* ----------------- Event Handlers ----------------- */
onPointerDown: TLPointerEventHandler = info => { onPointerDown: TLPointerEventHandler = (info) => {
if (this.status !== Status.Idle) return if (this.status !== Status.Idle) return
if (this.app.readOnly) return if (this.app.readOnly) return
const { const {

View file

@ -521,7 +521,7 @@ export enum TDExportBackground {
Transparent = 'transparent', Transparent = 'transparent',
Auto = 'auto', Auto = 'auto',
Light = 'light', Light = 'light',
Dark = 'dark' Dark = 'dark',
} }
/* -------------------------------------------------- */ /* -------------------------------------------------- */

View file

@ -24,89 +24,47 @@
"cache": false "cache": false
}, },
"docs": { "docs": {
"dependsOn": [ "dependsOn": ["^build"],
"^build" "outputs": ["docs"]
],
"outputs": [
"docs"
]
}, },
"build": { "build": {
"dependsOn": [ "dependsOn": ["^build"],
"^build" "outputs": ["dist/**", ".next/**"]
],
"outputs": [
"dist/**",
".next/**"
]
}, },
"build:packages": { "build:packages": {
"dependsOn": [ "dependsOn": ["^build"],
"^build" "outputs": ["dist/**"]
],
"outputs": [
"dist/**"
]
}, },
"build:core": { "build:core": {
"dependsOn": [ "dependsOn": ["^build"],
"^build" "outputs": ["dist/**"]
],
"outputs": [
"dist/**"
]
}, },
"build:apps": { "build:apps": {
"dependsOn": [ "dependsOn": ["^build"],
"^build" "outputs": ["dist/**", ".next/**"]
],
"outputs": [
"dist/**",
".next/**"
]
}, },
"build:www": { "build:www": {
"dependsOn": [ "dependsOn": ["build:packages", "^build"],
"build:packages", "outputs": ["dist/**", ".next/**"]
"^build"
],
"outputs": [
"dist/**",
".next/**"
]
}, },
"test": { "test": {
"dependsOn": [ "dependsOn": ["build:packages"],
"build:packages"
],
"outputs": [] "outputs": []
}, },
"test:ci": { "test:ci": {
"dependsOn": [ "dependsOn": ["build"],
"build" "outputs": ["coverage/**"]
],
"outputs": [
"coverage/**"
]
}, },
"lint": { "lint": {
"dependsOn": [ "dependsOn": ["build"],
"build"
],
"outputs": [] "outputs": []
}, },
"clean": { "clean": {
"cache": false "cache": false
}, },
"deploy": { "deploy": {
"dependsOn": [ "dependsOn": ["build", "test"],
"build", "outputs": ["dist/**", ".next/**"]
"test"
],
"outputs": [
"dist/**",
".next/**"
]
} }
} }
} }

View file

@ -3374,7 +3374,7 @@
resolved "https://registry.yarnpkg.com/@types/lz-string/-/lz-string-1.3.34.tgz#69bfadde419314b4a374bf2c8e58659c035ed0a5" resolved "https://registry.yarnpkg.com/@types/lz-string/-/lz-string-1.3.34.tgz#69bfadde419314b4a374bf2c8e58659c035ed0a5"
integrity sha512-j6G1e8DULJx3ONf6NdR5JiR2ZY3K3PaaqiEuKYkLQO0Czfi1AzrtjfnfCROyWGeDd5IVMKCwsgSmMip9OWijow== integrity sha512-j6G1e8DULJx3ONf6NdR5JiR2ZY3K3PaaqiEuKYkLQO0Czfi1AzrtjfnfCROyWGeDd5IVMKCwsgSmMip9OWijow==
"@types/minimatch@*", "@types/minimatch@^3.0.3": "@types/minimatch@*":
version "3.0.5" version "3.0.5"
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.5.tgz#1001cc5e6a3704b83c236027e77f2f58ea010f40" resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.5.tgz#1001cc5e6a3704b83c236027e77f2f58ea010f40"
integrity sha512-Klz949h02Gz2uZCMGwDUSDS1YBlTdDDgbWHi+81l29tQALUtvz4rAYi5uoVhE5Lagoq6DeqAUlbrHvW/mXDgdQ== integrity sha512-Klz949h02Gz2uZCMGwDUSDS1YBlTdDDgbWHi+81l29tQALUtvz4rAYi5uoVhE5Lagoq6DeqAUlbrHvW/mXDgdQ==
@ -4066,11 +4066,6 @@ aria-query@^5.0.0:
resolved "https://registry.yarnpkg.com/aria-query/-/aria-query-5.0.0.tgz#210c21aaf469613ee8c9a62c7f86525e058db52c" resolved "https://registry.yarnpkg.com/aria-query/-/aria-query-5.0.0.tgz#210c21aaf469613ee8c9a62c7f86525e058db52c"
integrity sha512-V+SM7AbUwJ+EBnB8+DXs0hPZHO0W6pqBcc0dW90OwtVG02PswOu/teuARoLQjdDOH+t9pJgGnW5/Qmouf3gPJg== integrity sha512-V+SM7AbUwJ+EBnB8+DXs0hPZHO0W6pqBcc0dW90OwtVG02PswOu/teuARoLQjdDOH+t9pJgGnW5/Qmouf3gPJg==
array-differ@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/array-differ/-/array-differ-3.0.0.tgz#3cbb3d0f316810eafcc47624734237d6aee4ae6b"
integrity sha512-THtfYS6KtME/yIAhKjZ2ul7XI96lQGHRputJQHO80LAWQnuGP4iCIN8vdMRboGbIEYBwU33q8Tch1os2+X0kMg==
array-includes@^3.1.3, array-includes@^3.1.4: array-includes@^3.1.3, array-includes@^3.1.4:
version "3.1.4" version "3.1.4"
resolved "https://registry.yarnpkg.com/array-includes/-/array-includes-3.1.4.tgz#f5b493162c760f3539631f005ba2bb46acb45ba9" resolved "https://registry.yarnpkg.com/array-includes/-/array-includes-3.1.4.tgz#f5b493162c760f3539631f005ba2bb46acb45ba9"
@ -4122,11 +4117,6 @@ arrify@^1.0.1:
resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d"
integrity sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0= integrity sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=
arrify@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/arrify/-/arrify-2.0.1.tgz#c9655e9331e0abcd588d2a7cad7e9956f66701fa"
integrity sha512-3duEwti880xqi4eAMN8AyR4a0ByT90zoYdLlevfrvU43vb0YZwZVfxOgxWrLXXXpyugL0hNZc9G6BiB5B3nUug==
asar@^3.0.3: asar@^3.0.3:
version "3.1.0" version "3.1.0"
resolved "https://registry.yarnpkg.com/asar/-/asar-3.1.0.tgz#70b0509449fe3daccc63beb4d3c7d2e24d3c6473" resolved "https://registry.yarnpkg.com/asar/-/asar-3.1.0.tgz#70b0509449fe3daccc63beb4d3c7d2e24d3c6473"
@ -5078,7 +5068,7 @@ cross-spawn@^5.1.0:
shebang-command "^1.2.0" shebang-command "^1.2.0"
which "^1.2.9" which "^1.2.9"
cross-spawn@^7.0.0, cross-spawn@^7.0.1, cross-spawn@^7.0.2, cross-spawn@^7.0.3: cross-spawn@^7.0.1, cross-spawn@^7.0.2, cross-spawn@^7.0.3:
version "7.0.3" version "7.0.3"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6"
integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w== integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==
@ -6514,21 +6504,6 @@ events@^3.2.0:
resolved "https://registry.yarnpkg.com/events/-/events-3.3.0.tgz#31a95ad0a924e2d2c419a813aeb2c4e878ea7400" resolved "https://registry.yarnpkg.com/events/-/events-3.3.0.tgz#31a95ad0a924e2d2c419a813aeb2c4e878ea7400"
integrity sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q== integrity sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==
execa@^4.0.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/execa/-/execa-4.1.0.tgz#4e5491ad1572f2f17a77d388c6c857135b22847a"
integrity sha512-j5W0//W7f8UxAn8hXVnwG8tLwdiUy4FJLcSupCg6maBYZDpyBvTApK7KyuI4bKj8KOh1r2YH+6ucuYtJv1bTZA==
dependencies:
cross-spawn "^7.0.0"
get-stream "^5.0.0"
human-signals "^1.1.1"
is-stream "^2.0.0"
merge-stream "^2.0.0"
npm-run-path "^4.0.0"
onetime "^5.1.0"
signal-exit "^3.0.2"
strip-final-newline "^2.0.0"
execa@^5.0.0, execa@^5.1.1: execa@^5.0.0, execa@^5.1.1:
version "5.1.1" version "5.1.1"
resolved "https://registry.yarnpkg.com/execa/-/execa-5.1.1.tgz#f80ad9cbf4298f7bd1d4c9555c21e93741c411dd" resolved "https://registry.yarnpkg.com/execa/-/execa-5.1.1.tgz#f80ad9cbf4298f7bd1d4c9555c21e93741c411dd"
@ -6954,7 +6929,7 @@ get-stream@^4.1.0:
dependencies: dependencies:
pump "^3.0.0" pump "^3.0.0"
get-stream@^5.0.0, get-stream@^5.1.0: get-stream@^5.1.0:
version "5.2.0" version "5.2.0"
resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-5.2.0.tgz#4966a1795ee5ace65e706c4b7beb71257d6e22d3" resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-5.2.0.tgz#4966a1795ee5ace65e706c4b7beb71257d6e22d3"
integrity sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA== integrity sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==
@ -7313,11 +7288,6 @@ human-id@^1.0.2:
resolved "https://registry.yarnpkg.com/human-id/-/human-id-1.0.2.tgz#e654d4b2b0d8b07e45da9f6020d8af17ec0a5df3" resolved "https://registry.yarnpkg.com/human-id/-/human-id-1.0.2.tgz#e654d4b2b0d8b07e45da9f6020d8af17ec0a5df3"
integrity sha512-UNopramDEhHJD+VR+ehk8rOslwSfByxPIZyJRfV739NDhN5LF1fa1MqnzKm2lGTQRjNrjK19Q5fhkgIfjlVUKw== integrity sha512-UNopramDEhHJD+VR+ehk8rOslwSfByxPIZyJRfV739NDhN5LF1fa1MqnzKm2lGTQRjNrjK19Q5fhkgIfjlVUKw==
human-signals@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-1.1.1.tgz#c5b1cd14f50aeae09ab6c59fe63ba3395fe4dfa3"
integrity sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw==
human-signals@^2.1.0: human-signals@^2.1.0:
version "2.1.0" version "2.1.0"
resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-2.1.0.tgz#dc91fcba42e4d06e4abaed33b3e7a3c02f514ea0" resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-2.1.0.tgz#dc91fcba42e4d06e4abaed33b3e7a3c02f514ea0"
@ -7382,7 +7352,7 @@ ignore@^4.0.6:
resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc" resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc"
integrity sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg== integrity sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==
ignore@^5.1.1, ignore@^5.1.4, ignore@^5.1.8, ignore@^5.2.0: ignore@^5.1.1, ignore@^5.1.8, ignore@^5.2.0:
version "5.2.0" version "5.2.0"
resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.0.tgz#6d3bac8fa7fe0d45d9f9be7bac2fc279577e345a" resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.0.tgz#6d3bac8fa7fe0d45d9f9be7bac2fc279577e345a"
integrity sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ== integrity sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==
@ -9064,11 +9034,6 @@ module-lookup-amd@^7.0.1:
requirejs "^2.3.5" requirejs "^2.3.5"
requirejs-config-file "^4.0.0" requirejs-config-file "^4.0.0"
mri@^1.1.5:
version "1.2.0"
resolved "https://registry.yarnpkg.com/mri/-/mri-1.2.0.tgz#6721480fec2a11a4889861115a48b6cbe7cc8f0b"
integrity sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==
ms@2.0.0: ms@2.0.0:
version "2.0.0" version "2.0.0"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8"
@ -9084,17 +9049,6 @@ ms@2.1.3, ms@^2.1.1:
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2"
integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==
multimatch@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/multimatch/-/multimatch-4.0.0.tgz#8c3c0f6e3e8449ada0af3dd29efb491a375191b3"
integrity sha512-lDmx79y1z6i7RNx0ZGCPq1bzJ6ZoDDKbvh7jxr9SJcWLkShMzXrHbYVpTdnhNM5MXpDUxCQ4DgqVttVXlBgiBQ==
dependencies:
"@types/minimatch" "^3.0.3"
array-differ "^3.0.0"
array-union "^2.1.0"
arrify "^2.0.1"
minimatch "^3.0.4"
mute-stream@~0.0.4: mute-stream@~0.0.4:
version "0.0.8" version "0.0.8"
resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.8.tgz#1630c42b2251ff81e2a283de96a5497ea92e5e0d" resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.8.tgz#1630c42b2251ff81e2a283de96a5497ea92e5e0d"
@ -9286,7 +9240,7 @@ npm-package-arg@^8.1.5:
semver "^7.3.4" semver "^7.3.4"
validate-npm-package-name "^3.0.0" validate-npm-package-name "^3.0.0"
npm-run-path@^4.0.0, npm-run-path@^4.0.1: npm-run-path@^4.0.1:
version "4.0.1" version "4.0.1"
resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-4.0.1.tgz#b7ecd1e5ed53da8e37a55e1c2269e0b97ed748ea" resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-4.0.1.tgz#b7ecd1e5ed53da8e37a55e1c2269e0b97ed748ea"
integrity sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw== integrity sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==
@ -9810,18 +9764,6 @@ pretty-format@^27.0.0, pretty-format@^27.0.2, pretty-format@^27.5.1:
ansi-styles "^5.0.0" ansi-styles "^5.0.0"
react-is "^17.0.1" react-is "^17.0.1"
pretty-quick@^3.1.3:
version "3.1.3"
resolved "https://registry.yarnpkg.com/pretty-quick/-/pretty-quick-3.1.3.tgz#15281108c0ddf446675157ca40240099157b638e"
integrity sha512-kOCi2FJabvuh1as9enxYmrnBC6tVMoVOenMaBqRfsvBHB0cbpYHjdQEpSglpASDFEXVwplpcGR4CLEaisYAFcA==
dependencies:
chalk "^3.0.0"
execa "^4.0.0"
find-up "^4.1.0"
ignore "^5.1.4"
mri "^1.1.5"
multimatch "^4.0.0"
process-nextick-args@~2.0.0: process-nextick-args@~2.0.0:
version "2.0.1" version "2.0.1"
resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2" resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2"