@kitschpatrol/tldraw-cli 4.4.1 → 4.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.js +8 -8
- package/dist/.DS_Store +0 -0
- package/dist/lib/index.js +3 -3
- package/dist/tldraw/assets/{index-DYBjYoWp.js → index-BduUAqI3.js} +49 -49
- package/dist/tldraw/index.html +1 -1
- package/package.json +6 -4
- package/readme.md +28 -23
- package/dist/lib/TldrawController.d.ts +0 -25
- package/dist/lib/evaluators/download-tldr.d.ts +0 -9
- package/dist/lib/inline/download-image.d.ts +0 -7
- package/dist/lib/inline/download-tldr.d.ts +0 -7
- package/dist/lib/inline/get-image-blob.d.ts +0 -13
- package/dist/lib/inline/upload-tldr.d.ts +0 -7
- package/dist/lib/utilities/logger.d.ts +0 -8
package/dist/tldraw/index.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>tldraw via tldraw-cli</title>
|
|
7
|
-
<script type="module" crossorigin src="/assets/index-
|
|
7
|
+
<script type="module" crossorigin src="/assets/index-BduUAqI3.js"></script>
|
|
8
8
|
<link rel="stylesheet" crossorigin href="/assets/index-Dz3yUa4N.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kitschpatrol/tldraw-cli",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A CLI tool for exporting tldraw sketch URLs and local .tldr files to SVG or PNG images.",
|
|
6
6
|
"repository": {
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
"pnpm": ">=8.0.0"
|
|
25
25
|
},
|
|
26
26
|
"bin": {
|
|
27
|
-
"tldraw-cli": "bin/cli.js"
|
|
27
|
+
"tldraw-cli": "bin/cli.js",
|
|
28
|
+
"tldraw": "bin/cli.js"
|
|
28
29
|
},
|
|
29
30
|
"main": "./dist/lib/index.js",
|
|
30
31
|
"module": "./dist/lib/index.js",
|
|
@@ -50,7 +51,7 @@
|
|
|
50
51
|
"uint8array-extras": "^1.1.0"
|
|
51
52
|
},
|
|
52
53
|
"devDependencies": {
|
|
53
|
-
"@kitschpatrol/shared-config": "^4.6.
|
|
54
|
+
"@kitschpatrol/shared-config": "^4.6.2",
|
|
54
55
|
"@sindresorhus/slugify": "^2.2.1",
|
|
55
56
|
"@tldraw/assets": "^2.0.2",
|
|
56
57
|
"@types/express": "^4.17.21",
|
|
@@ -65,7 +66,7 @@
|
|
|
65
66
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
66
67
|
"eslint-plugin-react-refresh": "^0.4.6",
|
|
67
68
|
"get-port": "^7.1.0",
|
|
68
|
-
"nanoid": "^5.0.
|
|
69
|
+
"nanoid": "^5.0.7",
|
|
69
70
|
"open": "^10.1.0",
|
|
70
71
|
"path-type": "^5.0.0",
|
|
71
72
|
"plur": "^5.1.0",
|
|
@@ -88,6 +89,7 @@
|
|
|
88
89
|
"build:cli": "tsx ./scripts/build-cli.ts",
|
|
89
90
|
"build:lib": "tsx ./scripts/build-lib.ts && tsc -p tsconfig.lib.json",
|
|
90
91
|
"build:tldraw": "pnpm run tldraw:copy-assets && vite build",
|
|
92
|
+
"clean": "git clean -fdX",
|
|
91
93
|
"dev": "pnpm run dev:tldraw",
|
|
92
94
|
"dev:tldraw": "pnpm run tldraw:copy-assets && vite",
|
|
93
95
|
"fix": "shared-config --fix",
|
package/readme.md
CHANGED
|
@@ -69,18 +69,23 @@ npm install --global @kitschpatrol/tldraw-cli
|
|
|
69
69
|
|
|
70
70
|
### CLI
|
|
71
71
|
|
|
72
|
+
> \[!NOTE]\
|
|
73
|
+
> As of version 4.5.0, command line functionality is aliased to both `tldraw` and `tldraw-cli`.
|
|
74
|
+
>
|
|
75
|
+
> **The less verbose `tldraw` command is preferred.** The `tldraw-cli` alias is deprecated and will be removed in the next major version.
|
|
76
|
+
|
|
72
77
|
<!-- cli-help -->
|
|
73
78
|
|
|
74
|
-
#### Command: `tldraw
|
|
79
|
+
#### Command: `tldraw`
|
|
75
80
|
|
|
76
81
|
CLI tools for tldraw.
|
|
77
82
|
|
|
78
|
-
This section lists top-level commands for `tldraw
|
|
83
|
+
This section lists top-level commands for `tldraw`.
|
|
79
84
|
|
|
80
85
|
Usage:
|
|
81
86
|
|
|
82
87
|
```txt
|
|
83
|
-
tldraw
|
|
88
|
+
tldraw <command>
|
|
84
89
|
```
|
|
85
90
|
|
|
86
91
|
| Command | Argument | Description |
|
|
@@ -95,14 +100,14 @@ tldraw-cli <command>
|
|
|
95
100
|
|
|
96
101
|
_See the sections below for more information on each subcommand._
|
|
97
102
|
|
|
98
|
-
#### Subcommand: `tldraw
|
|
103
|
+
#### Subcommand: `tldraw export`
|
|
99
104
|
|
|
100
105
|
Export a local tldraw ".tldr" file or a tldraw\.com URL to an svg, png, json, or tldr file. Prints the absolute path(s) to the exported image(s) to stdout.
|
|
101
106
|
|
|
102
107
|
Usage:
|
|
103
108
|
|
|
104
109
|
```txt
|
|
105
|
-
tldraw
|
|
110
|
+
tldraw export <files-or-urls..>
|
|
106
111
|
```
|
|
107
112
|
|
|
108
113
|
| Positional Argument | Description | Type |
|
|
@@ -126,14 +131,14 @@ tldraw-cli export <files-or-urls..>
|
|
|
126
131
|
| `--help` | `-h` | | Show help | `boolean` | |
|
|
127
132
|
| `--version` | `-v` | | Show version number | `boolean` | |
|
|
128
133
|
|
|
129
|
-
#### Subcommand: `tldraw
|
|
134
|
+
#### Subcommand: `tldraw open`
|
|
130
135
|
|
|
131
136
|
Open a tldraw `.tldr` file or tldraw\.com URL in your default browser with either the official tldraw\.com site or a locally-hosted instance of the editor. Call `open` without an argument to open a blank sketch. Sketches opened via URL with the `--local` flag will be temporarily copied to the local system, and will not be kept in sync with tldraw\.com. This process does not exit until the browser is closed.
|
|
132
137
|
|
|
133
138
|
Usage:
|
|
134
139
|
|
|
135
140
|
```txt
|
|
136
|
-
tldraw
|
|
141
|
+
tldraw open [files-or-urls..]
|
|
137
142
|
```
|
|
138
143
|
|
|
139
144
|
| Positional Argument | Description | Type |
|
|
@@ -156,7 +161,7 @@ tldraw-cli open [files-or-urls..]
|
|
|
156
161
|
To export the file `your-drawing.tldr` to an SVG named `your-drawing.svg` in the current working directory, run the following command. Note that the default output format is SVG, and the default export location is the current working directory.
|
|
157
162
|
|
|
158
163
|
```sh
|
|
159
|
-
tldraw
|
|
164
|
+
tldraw export your-drawing.tldr
|
|
160
165
|
```
|
|
161
166
|
|
|
162
167
|
The file will retain its original name, e.g. `your-drawing.svg`
|
|
@@ -164,7 +169,7 @@ The file will retain its original name, e.g. `your-drawing.svg`
|
|
|
164
169
|
##### Basic tldraw\.com image download
|
|
165
170
|
|
|
166
171
|
```sh
|
|
167
|
-
tldraw
|
|
172
|
+
tldraw export https://www.tldraw.com/s/v2_c_JsxJk8dag6QsrqExukis4
|
|
168
173
|
```
|
|
169
174
|
|
|
170
175
|
The tldraw\.com URL's id (e.g. `v2_c_JsxJk8dag6QsrqExukis4`) will be used for the file name.
|
|
@@ -174,7 +179,7 @@ This is approximately equivalent to clicking the tldraw\.com "☰ → Edit → E
|
|
|
174
179
|
##### Export a remote tldraw\.com image to a local .tldr file
|
|
175
180
|
|
|
176
181
|
```sh
|
|
177
|
-
tldraw
|
|
182
|
+
tldraw export https://www.tldraw.com/s/v2_c_JsxJk8dag6QsrqExukis4 --format tldr
|
|
178
183
|
```
|
|
179
184
|
|
|
180
185
|
This is approximately equivalent to clicking the tldraw\.com "☰ → File → Save a copy" menu item.
|
|
@@ -184,7 +189,7 @@ Note that using `--format tldr` with a _file path_ instead of a _URL_ will still
|
|
|
184
189
|
##### Export to a specific image / file format
|
|
185
190
|
|
|
186
191
|
```sh
|
|
187
|
-
tldraw
|
|
192
|
+
tldraw export your-drawing.tldr --format png
|
|
188
193
|
```
|
|
189
194
|
|
|
190
195
|
This is approximately equivalent to clicking the tldraw\.com "☰ → Edit → Export As → PNG" menu item.
|
|
@@ -192,7 +197,7 @@ This is approximately equivalent to clicking the tldraw\.com "☰ → Edit → E
|
|
|
192
197
|
##### Export with a transparent background
|
|
193
198
|
|
|
194
199
|
```sh
|
|
195
|
-
tldraw
|
|
200
|
+
tldraw export your-drawing.tldr --transparent --format png
|
|
196
201
|
```
|
|
197
202
|
|
|
198
203
|
This is approximately equivalent to checking the tldraw\.com "☰ → Edit → Export As → ☐ Transparent" menu item.
|
|
@@ -200,7 +205,7 @@ This is approximately equivalent to checking the tldraw\.com "☰ → Edit → E
|
|
|
200
205
|
##### Export to a specific destination
|
|
201
206
|
|
|
202
207
|
```sh
|
|
203
|
-
tldraw
|
|
208
|
+
tldraw export your-drawing.tldr --output ~/Desktop
|
|
204
209
|
```
|
|
205
210
|
|
|
206
211
|
Exports to `~/Desktop/your-drawing.svg`
|
|
@@ -208,7 +213,7 @@ Exports to `~/Desktop/your-drawing.svg`
|
|
|
208
213
|
##### Export to a specific destination and filename
|
|
209
214
|
|
|
210
215
|
```sh
|
|
211
|
-
tldraw
|
|
216
|
+
tldraw export your-drawing.tldr --output ~/Desktop --name not-your-drawing
|
|
212
217
|
```
|
|
213
218
|
|
|
214
219
|
Exports to `~/Desktop/not-your-drawing.svg`
|
|
@@ -216,7 +221,7 @@ Exports to `~/Desktop/not-your-drawing.svg`
|
|
|
216
221
|
##### Export all frames from a tldraw\.com URL
|
|
217
222
|
|
|
218
223
|
```sh
|
|
219
|
-
tldraw
|
|
224
|
+
tldraw export https://www.tldraw.com/s/v2_c_FI5RYWbdpAtjsy4OIKrKw --frames
|
|
220
225
|
```
|
|
221
226
|
|
|
222
227
|
The exported files will be suffixed with their frame name, e.g.:
|
|
@@ -232,37 +237,37 @@ It's possible in tldraw to give multiple frames in a single sketch the same name
|
|
|
232
237
|
##### Export a specific frame from a tldraw\.com URL
|
|
233
238
|
|
|
234
239
|
```sh
|
|
235
|
-
tldraw
|
|
240
|
+
tldraw export https://www.tldraw.com/s/v2_c_FI5RYWbdpAtjsy4OIKrKw --frames "Frame 3"
|
|
236
241
|
```
|
|
237
242
|
|
|
238
243
|
##### Export multiple frames from a tldraw\.com URL
|
|
239
244
|
|
|
240
245
|
```sh
|
|
241
|
-
tldraw
|
|
246
|
+
tldraw export https://www.tldraw.com/s/v2_c_FI5RYWbdpAtjsy4OIKrKw --frames "Frame 1" "Frame 3"
|
|
242
247
|
```
|
|
243
248
|
|
|
244
249
|
##### Export a specific page by name from a tldraw\.com URL
|
|
245
250
|
|
|
246
251
|
```sh
|
|
247
|
-
tldraw
|
|
252
|
+
tldraw export https://www.tldraw.com/s/v2_c_L_RFQ3mJA_BWHejdH2hlD --pages "Page 3"
|
|
248
253
|
```
|
|
249
254
|
|
|
250
255
|
##### Export a specific pages by index from a tldraw\.com URL
|
|
251
256
|
|
|
252
257
|
```sh
|
|
253
|
-
tldraw
|
|
258
|
+
tldraw export https://www.tldraw.com/s/v2_c_L_RFQ3mJA_BWHejdH2hlD --pages 0 2
|
|
254
259
|
```
|
|
255
260
|
|
|
256
261
|
##### Export each pages as its own SVG from a tldraw\.com URL
|
|
257
262
|
|
|
258
263
|
```sh
|
|
259
|
-
tldraw
|
|
264
|
+
tldraw export https://www.tldraw.com/s/v2_c_L_RFQ3mJA_BWHejdH2hlD --pages
|
|
260
265
|
```
|
|
261
266
|
|
|
262
267
|
##### Export to JSON
|
|
263
268
|
|
|
264
269
|
```sh
|
|
265
|
-
tldraw
|
|
270
|
+
tldraw export https://www.tldraw.com/s/v2_c_FI5RYWbdpAtjsy4OIKrKw --format "json"
|
|
266
271
|
```
|
|
267
272
|
|
|
268
273
|
The `.tldr` file format is also JSON under the covers, but the `--format json` flag will yield a slightly different format than `--format tldr`. `--format json` is equivalent to what's produced via the tldraw\.com "☰ → Edit → Export As → JSON" menu item.
|
|
@@ -272,13 +277,13 @@ I'm not completely clear on the use-case for this format, but since tldr.com sup
|
|
|
272
277
|
##### Write an SVG to stdout
|
|
273
278
|
|
|
274
279
|
```sh
|
|
275
|
-
tldraw
|
|
280
|
+
tldraw export https://www.tldraw.com/s/v2_c_FI5RYWbdpAtjsy4OIKrKw --print
|
|
276
281
|
```
|
|
277
282
|
|
|
278
283
|
##### Open a tldraw\.com URL
|
|
279
284
|
|
|
280
285
|
```sh
|
|
281
|
-
tldraw
|
|
286
|
+
tldraw open https://www.tldraw.com/s/v2_c_FI5RYWbdpAtjsy4OIKrKw
|
|
282
287
|
```
|
|
283
288
|
|
|
284
289
|
The remote sketch is copied to a locally-hosted instance of tldraw, which is then opened in your default browser.
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { TldrawFormat } from './tldraw-to-image';
|
|
2
|
-
export default class TldrawController {
|
|
3
|
-
private readonly href;
|
|
4
|
-
private page?;
|
|
5
|
-
private isEmpty?;
|
|
6
|
-
private browser?;
|
|
7
|
-
private client?;
|
|
8
|
-
constructor(href: string);
|
|
9
|
-
private get isLocal();
|
|
10
|
-
start(): Promise<void>;
|
|
11
|
-
close(): Promise<void>;
|
|
12
|
-
download(output: string, filename: string, format: TldrawFormat, stripStyle: boolean, print: boolean): Promise<string[]>;
|
|
13
|
-
downloadFrame(output: string, filename: string, format: TldrawFormat, stripStyle: boolean, frameNameOrId: string, print: boolean): Promise<string[]>;
|
|
14
|
-
downloadFrames(output: string, filename: string, format: TldrawFormat, stripStyle: boolean, frameNamesOrIds: string[], print: boolean): Promise<string[]>;
|
|
15
|
-
downloadAllFrames(output: string, filename: string, format: TldrawFormat, stripStyle: boolean, print: boolean): Promise<string[]>;
|
|
16
|
-
loadFile(filePath: string): Promise<void>;
|
|
17
|
-
getShareUrl(): Promise<string>;
|
|
18
|
-
private _download;
|
|
19
|
-
private closeMenus;
|
|
20
|
-
private clickButtonTitles;
|
|
21
|
-
private waitForDownloadCompletion;
|
|
22
|
-
private getPageFrameWithNameOrId;
|
|
23
|
-
private getPageFrames;
|
|
24
|
-
private stripStyleElement;
|
|
25
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { type Editor, exportToBlob } from 'tldraw';
|
|
2
|
-
declare global {
|
|
3
|
-
interface Window {
|
|
4
|
-
editor: Editor;
|
|
5
|
-
getImageBlob: (options: {
|
|
6
|
-
background: boolean;
|
|
7
|
-
darkMode: boolean;
|
|
8
|
-
format: Parameters<typeof exportToBlob>[0]['format'];
|
|
9
|
-
padding: number;
|
|
10
|
-
scale: number;
|
|
11
|
-
}) => Promise<string>;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export declare let cli: boolean;
|
|
2
|
-
export declare let verbose: boolean;
|
|
3
|
-
export declare function setCli(value: boolean): void;
|
|
4
|
-
export declare function setVerbose(value: boolean): void;
|
|
5
|
-
export declare function log(...data: unknown[]): void;
|
|
6
|
-
export declare function warn(...data: unknown[]): void;
|
|
7
|
-
export declare function error(...data: unknown[]): void;
|
|
8
|
-
export declare function info(...data: unknown[]): void;
|