Bladeren bron

Fix build errors

main
Steve Ruiz 3 jaren geleden
bovenliggende
commit
c92eba9c4e

+ 1
- 1
.eslintrc.js Bestand weergeven

@@ -8,7 +8,7 @@ module.exports = {
8 8
       // enable the rule specifically for TypeScript files
9 9
       files: ['*.ts', '*.tsx'],
10 10
       rules: {
11
-        '@typescript-eslint/explicit-module-boundary-types': [false],
11
+        '@typescript-eslint/explicit-module-boundary-types': [0],
12 12
       },
13 13
     },
14 14
   ],

+ 1
- 1
package.json Bestand weergeven

@@ -19,7 +19,7 @@
19 19
     "test": "jest",
20 20
     "lerna": "lerna",
21 21
     "start": "lerna run dev --stream --parallel",
22
-    "start:www": "lerna run dev --stream --parallel &  cd packages/www && yarn build",
22
+    "start:www": "lerna run dev --stream --parallel & cd packages/www && yarn build",
23 23
     "build": "yarn build:packages && cd packages/www && yarn build",
24 24
     "build:packages": "cd packages/core && yarn build && cd ../tldraw && yarn build"
25 25
   },

+ 257
- 0
packages/core/src/types.d.ts Bestand weergeven

@@ -0,0 +1,257 @@
1
+/// <reference types="react" />
2
+export interface TLPage<T extends TLShape> {
3
+    id: string;
4
+    name?: string;
5
+    childIndex?: number;
6
+    shapes: Record<string, T>;
7
+    bindings: Record<string, TLBinding>;
8
+    backgroundColor?: string;
9
+}
10
+export interface TLPageState {
11
+    id: string;
12
+    brush?: TLBounds;
13
+    pointedId?: string;
14
+    hoveredId?: string;
15
+    editingId?: string;
16
+    bindingId?: string;
17
+    boundsRotation?: number;
18
+    currentParentId?: string;
19
+    selectedIds: string[];
20
+    camera: {
21
+        point: number[];
22
+        zoom: number;
23
+    };
24
+}
25
+export interface TLHandle {
26
+    id: string;
27
+    index: number;
28
+    point: number[];
29
+    canBind?: boolean;
30
+    bindingId?: string;
31
+}
32
+export interface TLShape {
33
+    id: string;
34
+    type: string;
35
+    parentId: string;
36
+    childIndex: number;
37
+    name: string;
38
+    point: number[];
39
+    rotation?: number;
40
+    children?: string[];
41
+    handles?: Record<string, TLHandle>;
42
+    isLocked?: boolean;
43
+    isHidden?: boolean;
44
+    isEditing?: boolean;
45
+    isGenerated?: boolean;
46
+    isAspectRatioLocked?: boolean;
47
+}
48
+export declare type TLShapeUtils<T extends TLShape> = Record<string, TLShapeUtil<T>>;
49
+export interface TLRenderInfo<T extends SVGElement | HTMLElement = any> {
50
+    isEditing: boolean;
51
+    isBinding: boolean;
52
+    isDarkMode: boolean;
53
+    isCurrentParent: boolean;
54
+    ref?: React.RefObject<T>;
55
+    onTextChange?: TLCallbacks['onTextChange'];
56
+    onTextBlur?: TLCallbacks['onTextBlur'];
57
+    onTextFocus?: TLCallbacks['onTextFocus'];
58
+    onTextKeyDown?: TLCallbacks['onTextKeyDown'];
59
+    onTextKeyUp?: TLCallbacks['onTextKeyUp'];
60
+}
61
+export interface TLTool {
62
+    id: string;
63
+    name: string;
64
+}
65
+export interface TLBinding {
66
+    id: string;
67
+    type: string;
68
+    toId: string;
69
+    fromId: string;
70
+}
71
+export interface TLSettings {
72
+    isDebugMode: boolean;
73
+    isDarkMode: boolean;
74
+    isPenMode: boolean;
75
+}
76
+export interface TLTheme {
77
+    brushFill?: string;
78
+    brushStroke?: string;
79
+    selectFill?: string;
80
+    selectStroke?: string;
81
+    background?: string;
82
+    foreground?: string;
83
+}
84
+export declare type TLWheelEventHandler = (info: TLPointerInfo<string>, e: React.WheelEvent<Element> | WheelEvent) => void;
85
+export declare type TLPinchEventHandler = (info: TLPointerInfo<string>, e: React.WheelEvent<Element> | WheelEvent | React.TouchEvent<Element> | TouchEvent) => void;
86
+export declare type TLPointerEventHandler = (info: TLPointerInfo<string>, e: React.PointerEvent) => void;
87
+export declare type TLCanvasEventHandler = (info: TLPointerInfo<'canvas'>, e: React.PointerEvent) => void;
88
+export declare type TLBoundsEventHandler = (info: TLPointerInfo<'bounds'>, e: React.PointerEvent) => void;
89
+export declare type TLBoundsHandleEventHandler = (info: TLPointerInfo<TLBoundsCorner | TLBoundsEdge | 'rotate'>, e: React.PointerEvent) => void;
90
+export interface TLCallbacks {
91
+    onChange: (ids: string[]) => void;
92
+    onPinchStart: TLPinchEventHandler;
93
+    onPinchEnd: TLPinchEventHandler;
94
+    onPinch: TLPinchEventHandler;
95
+    onPan: TLWheelEventHandler;
96
+    onZoom: TLWheelEventHandler;
97
+    onPointerMove: TLPointerEventHandler;
98
+    onPointerUp: TLPointerEventHandler;
99
+    onPointerDown: TLPointerEventHandler;
100
+    onPointCanvas: TLCanvasEventHandler;
101
+    onDoubleClickCanvas: TLCanvasEventHandler;
102
+    onRightPointCanvas: TLCanvasEventHandler;
103
+    onDragCanvas: TLCanvasEventHandler;
104
+    onReleaseCanvas: TLCanvasEventHandler;
105
+    onPointShape: TLPointerEventHandler;
106
+    onDoubleClickShape: TLPointerEventHandler;
107
+    onRightPointShape: TLPointerEventHandler;
108
+    onDragShape: TLPointerEventHandler;
109
+    onHoverShape: TLPointerEventHandler;
110
+    onUnhoverShape: TLPointerEventHandler;
111
+    onReleaseShape: TLPointerEventHandler;
112
+    onPointBounds: TLBoundsEventHandler;
113
+    onDoubleClickBounds: TLBoundsEventHandler;
114
+    onRightPointBounds: TLBoundsEventHandler;
115
+    onDragBounds: TLBoundsEventHandler;
116
+    onHoverBounds: TLBoundsEventHandler;
117
+    onUnhoverBounds: TLBoundsEventHandler;
118
+    onReleaseBounds: TLBoundsEventHandler;
119
+    onPointBoundsHandle: TLBoundsHandleEventHandler;
120
+    onDoubleClickBoundsHandle: TLBoundsHandleEventHandler;
121
+    onRightPointBoundsHandle: TLBoundsHandleEventHandler;
122
+    onDragBoundsHandle: TLBoundsHandleEventHandler;
123
+    onHoverBoundsHandle: TLBoundsHandleEventHandler;
124
+    onUnhoverBoundsHandle: TLBoundsHandleEventHandler;
125
+    onReleaseBoundsHandle: TLBoundsHandleEventHandler;
126
+    onPointHandle: TLPointerEventHandler;
127
+    onDoubleClickHandle: TLPointerEventHandler;
128
+    onRightPointHandle: TLPointerEventHandler;
129
+    onDragHandle: TLPointerEventHandler;
130
+    onHoverHandle: TLPointerEventHandler;
131
+    onUnhoverHandle: TLPointerEventHandler;
132
+    onReleaseHandle: TLPointerEventHandler;
133
+    onTextChange: (id: string, text: string) => void;
134
+    onTextBlur: (id: string) => void;
135
+    onTextFocus: (id: string) => void;
136
+    onTextKeyDown: (id: string, key: string) => void;
137
+    onTextKeyUp: (id: string, key: string) => void;
138
+    onBlurEditingShape: () => void;
139
+    onError: (error: Error) => void;
140
+}
141
+export interface TLBounds {
142
+    minX: number;
143
+    minY: number;
144
+    maxX: number;
145
+    maxY: number;
146
+    width: number;
147
+    height: number;
148
+    rotation?: number;
149
+}
150
+export declare type TLIntersection = {
151
+    didIntersect: boolean;
152
+    message: string;
153
+    points: number[][];
154
+};
155
+export declare enum TLBoundsEdge {
156
+    Top = "top_edge",
157
+    Right = "right_edge",
158
+    Bottom = "bottom_edge",
159
+    Left = "left_edge"
160
+}
161
+export declare enum TLBoundsCorner {
162
+    TopLeft = "top_left_corner",
163
+    TopRight = "top_right_corner",
164
+    BottomRight = "bottom_right_corner",
165
+    BottomLeft = "bottom_left_corner"
166
+}
167
+export interface TLPointerInfo<T extends string = string> {
168
+    target: T;
169
+    pointerId: number;
170
+    origin: number[];
171
+    point: number[];
172
+    delta: number[];
173
+    pressure: number;
174
+    shiftKey: boolean;
175
+    ctrlKey: boolean;
176
+    metaKey: boolean;
177
+    altKey: boolean;
178
+}
179
+export interface TLKeyboardInfo {
180
+    origin: number[];
181
+    point: number[];
182
+    key: string;
183
+    keys: string[];
184
+    shiftKey: boolean;
185
+    ctrlKey: boolean;
186
+    metaKey: boolean;
187
+    altKey: boolean;
188
+}
189
+export interface TLTransformInfo<T extends TLShape> {
190
+    type: TLBoundsEdge | TLBoundsCorner;
191
+    initialShape: T;
192
+    scaleX: number;
193
+    scaleY: number;
194
+    transformOrigin: number[];
195
+}
196
+export interface TLBezierCurveSegment {
197
+    start: number[];
198
+    tangentStart: number[];
199
+    normalStart: number[];
200
+    pressureStart: number;
201
+    end: number[];
202
+    tangentEnd: number[];
203
+    normalEnd: number[];
204
+    pressureEnd: number;
205
+}
206
+export declare abstract class TLShapeUtil<T extends TLShape> {
207
+    boundsCache: WeakMap<TLShape, TLBounds>;
208
+    isEditableText: boolean;
209
+    isAspectRatioLocked: boolean;
210
+    canEdit: boolean;
211
+    canBind: boolean;
212
+    abstract type: T['type'];
213
+    abstract defaultProps: T;
214
+    abstract render(shape: T, info: TLRenderInfo): JSX.Element;
215
+    abstract renderIndicator(shape: T): JSX.Element | null;
216
+    abstract getBounds(shape: T): TLBounds;
217
+    abstract getRotatedBounds(shape: T): TLBounds;
218
+    abstract hitTest(shape: T, point: number[]): boolean;
219
+    abstract hitTestBounds(shape: T, bounds: TLBounds): boolean;
220
+    abstract transform(shape: T, bounds: TLBounds, info: TLTransformInfo<T>): Partial<T>;
221
+    transformSingle(shape: T, bounds: TLBounds, info: TLTransformInfo<T>): Partial<T>;
222
+    shouldRender(_prev: T, _next: T): boolean;
223
+    shouldDelete(_shape: T): boolean;
224
+    getCenter(shape: T): number[];
225
+    getBindingPoint(shape: T, point: number[], origin: number[], direction: number[], padding: number, anywhere: boolean): {
226
+        point: number[];
227
+        distance: number;
228
+    } | undefined;
229
+    create(props: Partial<T>): T;
230
+    mutate(shape: T, props: Partial<T>): T;
231
+    updateChildren<K extends TLShape>(_shape: T, _children: K[]): Partial<K>[] | void;
232
+    onChildrenChange(_shape: T, _children: TLShape[]): Partial<T> | void;
233
+    onBindingChange(_shape: T, _binding: TLBinding, _target: TLShape, _targetBounds: TLBounds, _center: number[]): Partial<T> | void;
234
+    onHandleChange(_shape: T, _handle: Partial<T['handles']>, _info: Partial<TLPointerInfo>): Partial<T> | void;
235
+    onRightPointHandle(_shape: T, _handle: Partial<T['handles']>, _info: Partial<TLPointerInfo>): Partial<T> | void;
236
+    onDoubleClickHandle(_shape: T, _handle: Partial<T['handles']>, _info: Partial<TLPointerInfo>): Partial<T> | void;
237
+    onSessionComplete(_shape: T): Partial<T> | void;
238
+    onBoundsReset(_shape: T): Partial<T> | void;
239
+    onStyleChange(_shape: T): Partial<T> | void;
240
+}
241
+export interface IShapeTreeNode {
242
+    shape: TLShape;
243
+    children?: IShapeTreeNode[];
244
+    isEditing: boolean;
245
+    isBinding: boolean;
246
+    isDarkMode: boolean;
247
+    isCurrentParent: boolean;
248
+}
249
+export declare type MappedByType<T extends {
250
+    type: string;
251
+}> = {
252
+    [P in T['type']]: T extends any ? (P extends T['type'] ? T : never) : never;
253
+};
254
+export declare type RequiredKeys<T> = {
255
+    [K in keyof T]-?: Record<string, unknown> extends Pick<T, K> ? never : K;
256
+}[keyof T];
257
+export {};

+ 1
- 0
packages/core/tsconfig.json Bestand weergeven

@@ -3,6 +3,7 @@
3 3
   "include": ["src"],
4 4
   "exclude": ["node_modules", "**/*.test.ts", "dist"],
5 5
   "compilerOptions": {
6
+    "baseUrl": "src",
6 7
     "jsx": "preserve",
7 8
     "lib": ["dom", "esnext"],
8 9
     "module": "esnext",

+ 5
- 6
packages/dev/package.json Bestand weergeven

@@ -1,10 +1,9 @@
1 1
 {
2
-  "name": "react-esbuild-starter",
3
-  "version": "2.1.0",
4
-  "private": true,
5
-  "description": "Starter template for React + Typescript, powered by Esbuild",
6
-  "repository": "https://github.com/belaczek/react-esbuild-starter.git",
7
-  "author": "Tomas Belada <tomas@belada.net>",
2
+  "name": "@tldraw/dev",
3
+  "version": "0.0.41",
4
+  "private": false,
5
+  "description": "A tiny little drawing app (core).",
6
+  "author": "@steveruizok",
8 7
   "license": "MIT",
9 8
   "keywords": [
10 9
     "react",

+ 1
- 0
packages/tldraw/package.json Bestand weergeven

@@ -17,6 +17,7 @@
17 17
   ],
18 18
   "main": "./dist/cjs/index.js",
19 19
   "types": "./dist/types/index.d.ts",
20
+  "typings": "./dist/types/index.d.ts",
20 21
   "scripts": {
21 22
     "dev": "node scripts/dev & tsc --watch --incremental --emitDeclarationOnly --outDir dist/types",
22 23
     "build": "yarn clean && node scripts/build && tsc --emitDeclarationOnly --outDir dist/types",

+ 1
- 1
packages/tldraw/src/shape/shape-types.ts Bestand weergeven

@@ -1,4 +1,4 @@
1
-import type { TLBinding } from './../../../core/src/types'
1
+import type { TLBinding } from '@tldraw/core'
2 2
 import { TLShape, TLShapeUtil, TLHandle } from '@tldraw/core'
3 3
 
4 4
 export enum TLDrawToolType {

+ 1
- 1
packages/tldraw/src/state/command/flip/flip.command.ts Bestand weergeven

@@ -1,4 +1,4 @@
1
-import { FlipType } from './../../../types'
1
+import { FlipType } from '../../../types'
2 2
 import { TLBoundsCorner, Utils } from '@tldraw/core'
3 3
 import type { Data, Command } from '../../state-types'
4 4
 import { TLDR } from '../../tldr'

+ 9
- 25
packages/tldraw/src/state/command/toggle/toggle.command.spec.ts Bestand weergeven

@@ -1,4 +1,4 @@
1
-import type { RectangleShape } from './../../../shape/shape-types'
1
+import type { RectangleShape } from '../../../shape/shape-types'
2 2
 import { TLDrawState } from '../../tlstate'
3 3
 import { mockDocument } from '../../test-helpers'
4 4
 
@@ -27,33 +27,17 @@ describe('Toggle command', () => {
27 27
   it('toggles on before off when mixed values', () => {
28 28
     tlstate.loadDocument(mockDocument)
29 29
     tlstate.setSelectedIds(['rect2'])
30
-    expect(tlstate.getShape<RectangleShape>('rect1').isAspectRatioLocked).toBe(
31
-      undefined
32
-    )
33
-    expect(tlstate.getShape<RectangleShape>('rect2').isAspectRatioLocked).toBe(
34
-      undefined
35
-    )
30
+    expect(tlstate.getShape<RectangleShape>('rect1').isAspectRatioLocked).toBe(undefined)
31
+    expect(tlstate.getShape<RectangleShape>('rect2').isAspectRatioLocked).toBe(undefined)
36 32
     tlstate.toggleAspectRatioLocked()
37
-    expect(tlstate.getShape<RectangleShape>('rect1').isAspectRatioLocked).toBe(
38
-      undefined
39
-    )
40
-    expect(tlstate.getShape<RectangleShape>('rect2').isAspectRatioLocked).toBe(
41
-      true
42
-    )
33
+    expect(tlstate.getShape<RectangleShape>('rect1').isAspectRatioLocked).toBe(undefined)
34
+    expect(tlstate.getShape<RectangleShape>('rect2').isAspectRatioLocked).toBe(true)
43 35
     tlstate.selectAll()
44 36
     tlstate.toggleAspectRatioLocked()
45
-    expect(tlstate.getShape<RectangleShape>('rect1').isAspectRatioLocked).toBe(
46
-      true
47
-    )
48
-    expect(tlstate.getShape<RectangleShape>('rect1').isAspectRatioLocked).toBe(
49
-      true
50
-    )
37
+    expect(tlstate.getShape<RectangleShape>('rect1').isAspectRatioLocked).toBe(true)
38
+    expect(tlstate.getShape<RectangleShape>('rect1').isAspectRatioLocked).toBe(true)
51 39
     tlstate.toggleAspectRatioLocked()
52
-    expect(tlstate.getShape<RectangleShape>('rect1').isAspectRatioLocked).toBe(
53
-      false
54
-    )
55
-    expect(tlstate.getShape<RectangleShape>('rect1').isAspectRatioLocked).toBe(
56
-      false
57
-    )
40
+    expect(tlstate.getShape<RectangleShape>('rect1').isAspectRatioLocked).toBe(false)
41
+    expect(tlstate.getShape<RectangleShape>('rect1').isAspectRatioLocked).toBe(false)
58 42
   })
59 43
 })

+ 0
- 1
packages/tldraw/src/state/session/sessions/handle/handle.session.ts Bestand weergeven

@@ -1,4 +1,3 @@
1
-import { ArrowBinding } from './../../../../shape/shape-types'
2 1
 import { Vec } from '@tldraw/core'
3 2
 import type { TLDrawShape } from '../../../../shape'
4 3
 import type { Session } from '../../../state-types'

+ 1
- 1
packages/tldraw/src/state/session/sessions/translate/translate.session.ts Bestand weergeven

@@ -1,5 +1,5 @@
1 1
 import { Utils, Vec } from '@tldraw/core'
2
-import type { TLBinding } from 'packages/core/src/types'
2
+import type { TLBinding } from '@tldraw/core'
3 3
 import type { TLDrawShape } from '../../../../shape'
4 4
 import type { Session } from '../../../state-types'
5 5
 import type { Data } from '../../../state-types'

+ 2
- 4
packages/tldraw/tsconfig.json Bestand weergeven

@@ -3,12 +3,10 @@
3 3
   "include": ["src"],
4 4
   "exclude": ["node_modules", "**/*.test.ts", "dist"],
5 5
   "compilerOptions": {
6
+    "rootDir": "src",
6 7
     "jsx": "preserve",
7 8
     "lib": ["dom", "esnext"],
8 9
     "module": "esnext",
9
-    "outDir": "./dist/types",
10
-    "paths": {
11
-      "@tldraw/core": ["packages/core/dist"]
12
-    }
10
+    "outDir": "./dist/types"
13 11
   }
14 12
 }

+ 1
- 0
packages/tldraw/tsconfig.tsbuildinfo
Diff onderdrukt omdat het te groot bestand
Bestand weergeven


+ 3
- 0
packages/www/next-env.d.ts Bestand weergeven

@@ -1,3 +1,6 @@
1 1
 /// <reference types="next" />
2 2
 /// <reference types="next/types/global" />
3 3
 /// <reference types="next/image-types/global" />
4
+
5
+// NOTE: This file should not be edited
6
+// see https://nextjs.org/docs/basic-features/typescript for more information.

+ 1
- 1
packages/www/package.json Bestand weergeven

@@ -36,4 +36,4 @@
36 36
     "eslint-config-next": "11.0.1",
37 37
     "typescript": "^4.3.5"
38 38
   }
39
-}
39
+}

+ 1
- 1
packages/www/pages/_app.tsx Bestand weergeven

@@ -1,4 +1,4 @@
1
-import { AppProps } from 'next/app'
1
+import type { AppProps } from 'next/app'
2 2
 import useGtag from '../hooks/useGtag'
3 3
 import Head from 'next/head'
4 4
 import './styles.css'

+ 1
- 1
packages/www/pages/r/[id].tsx Bestand weergeven

@@ -1,4 +1,4 @@
1
-import { GetServerSideProps } from 'next'
1
+import type { GetServerSideProps } from 'next'
2 2
 import * as React from 'react'
3 3
 
4 4
 export default function Room(): JSX.Element {

+ 1
- 1
packages/www/tsconfig.json Bestand weergeven

@@ -15,7 +15,7 @@
15 15
     "isolatedModules": true,
16 16
     "jsx": "preserve",
17 17
     "paths": {
18
-      "@tldraw/tldraw": ["../tldraw"]
18
+      "@tldraw/tldraw": ["packages/tldraw/dist"]
19 19
     }
20 20
   },
21 21
   "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],

+ 2
- 1
tsconfig.json Bestand weergeven

@@ -29,7 +29,8 @@
29 29
     "typeRoots": ["node_modules/@types", "node_modules/jest"],
30 30
     "types": ["node", "jest"],
31 31
     "paths": {
32
-      "@tldraw/*": ["./packages/*"]
32
+      "@tldraw/tldraw": ["./packages/tldraw/dist"],
33
+      "@tldraw/core": ["./packages/core/dist"]
33 34
     }
34 35
   }
35 36
 }

Laden…
Annuleren
Opslaan