@kitschpatrol/tldraw-cli 4.1.1 → 4.2.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.
Files changed (48) hide show
  1. package/bin/cli.js +161 -136
  2. package/dist/.DS_Store +0 -0
  3. package/dist/lib/TldrawController.d.ts +25 -0
  4. package/dist/lib/index.js +149 -116
  5. package/dist/lib/inline/download-image.d.ts +7 -0
  6. package/dist/lib/inline/download-tldr.d.ts +7 -0
  7. package/dist/lib/inline/get-image-blob.d.ts +13 -0
  8. package/dist/lib/inline/get-image.d.ts +13 -0
  9. package/dist/lib/inline/get-tldr.d.ts +7 -0
  10. package/dist/lib/inline/set-tldr.d.ts +7 -0
  11. package/dist/lib/inline/upload-tldr.d.ts +7 -0
  12. package/dist/lib/tldraw-controller.d.ts +4 -10
  13. package/dist/tldraw/assets/index-BsbCikiv.js +320 -0
  14. package/dist/tldraw/assets/index-CtzsHuLd.css +1 -0
  15. package/dist/tldraw/icons/icon/checkbox-empty.svg +1 -1
  16. package/dist/tldraw/index.html +2 -2
  17. package/dist/tldraw/translations/ar.json +156 -156
  18. package/dist/tldraw/translations/ca.json +156 -156
  19. package/dist/tldraw/translations/cs.json +211 -211
  20. package/dist/tldraw/translations/da.json +94 -94
  21. package/dist/tldraw/translations/de.json +169 -169
  22. package/dist/tldraw/translations/es.json +160 -160
  23. package/dist/tldraw/translations/fa.json +202 -202
  24. package/dist/tldraw/translations/fi.json +172 -172
  25. package/dist/tldraw/translations/fr.json +156 -156
  26. package/dist/tldraw/translations/gl.json +208 -208
  27. package/dist/tldraw/translations/hi-in.json +152 -152
  28. package/dist/tldraw/translations/hr.json +358 -0
  29. package/dist/tldraw/translations/hu.json +220 -217
  30. package/dist/tldraw/translations/it.json +189 -189
  31. package/dist/tldraw/translations/ja.json +210 -210
  32. package/dist/tldraw/translations/ko-kr.json +217 -214
  33. package/dist/tldraw/translations/languages.json +8 -0
  34. package/dist/tldraw/translations/main.json +14 -0
  35. package/dist/tldraw/translations/ne.json +156 -156
  36. package/dist/tldraw/translations/ro.json +210 -210
  37. package/dist/tldraw/translations/ru.json +206 -206
  38. package/dist/tldraw/translations/sl.json +358 -0
  39. package/dist/tldraw/translations/th.json +156 -156
  40. package/dist/tldraw/translations/tr.json +214 -214
  41. package/dist/tldraw/translations/uk.json +206 -206
  42. package/dist/tldraw/translations/vi.json +156 -156
  43. package/dist/tldraw/translations/zh-cn.json +212 -212
  44. package/dist/tldraw/translations/zh-tw.json +176 -176
  45. package/package.json +20 -17
  46. package/readme.md +36 -27
  47. package/dist/tldraw/assets/index-C93mJRxX.js +0 -315
  48. package/dist/tldraw/assets/index-DWCRF5Ys.css +0 -1
package/readme.md CHANGED
@@ -1,4 +1,4 @@
1
- <!--+ Warning: Content in HTML comment blocks generated by mdat on 2024-02-22 +-->
1
+ <!--+ Warning: Content inside HTML comment blocks was generated by mdat and may be overwritten. +-->
2
2
 
3
3
  <!-- header -->
4
4
 
@@ -7,7 +7,7 @@
7
7
  [![NPM Package @kitschpatrol/tldraw-cli](https://img.shields.io/npm/v/@kitschpatrol/tldraw-cli.svg)](https://npmjs.com/package/@kitschpatrol/tldraw-cli)
8
8
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
9
9
 
10
- **A tiny little CLI tool for exporting tldraw sketches to svg or png images.**
10
+ **A CLI tool for exporting tldraw sketch URLs and local .tldr files to SVG or PNG images.**
11
11
 
12
12
  <!-- /header -->
13
13
 
@@ -17,12 +17,13 @@
17
17
 
18
18
  - [Overview](#overview)
19
19
  - [Installation](#installation)
20
- - [Command line usage](#command-line-usage)
21
- - [Examples](#examples)
22
- - [API usage](#api-usage)
20
+ - [Usage](#usage)
21
+ - [CLI](#cli)
22
+ - [API](#api)
23
23
  - [Background](#background)
24
24
  - [Implementation notes](#implementation-notes)
25
25
  - [The future](#the-future)
26
+ - [Maintainers](#maintainers)
26
27
  - [Contributing](#contributing)
27
28
  - [License](#license)
28
29
 
@@ -30,7 +31,7 @@
30
31
 
31
32
  ## Overview
32
33
 
33
- A CLI app to automate conversion and export of [tldraw](https://tldraw.dev) URLs and `.tldr` files into SVG or PNG image formats.
34
+ A CLI app to automate conversion and export of [tldraw](https://tldraw.dev) URLs and `.tldr` files into SVG or PNG image formats, exposing a number of options along the way. It also provides commands for opening tldraw files in either local or remote instances of the tldraw editor website.
34
35
 
35
36
  This could be useful in the context of a content publishing pipeline where you want to use a `.tldr` file (perhaps under version control) as the "source of truth" for assets to be embedded elsewhere, and you don't want to manage the export of that diagram manually.
36
37
 
@@ -56,7 +57,9 @@ npm install --save-dev @kitschpatrol/tldraw-cli
56
57
  npm install --global @kitschpatrol/tldraw-cli
57
58
  ```
58
59
 
59
- ## Command line usage
60
+ ## Usage
61
+
62
+ ### CLI
60
63
 
61
64
  <!-- cli-help -->
62
65
 
@@ -72,10 +75,10 @@ Usage:
72
75
  tldraw-cli <command>
73
76
  ```
74
77
 
75
- | Command | Argument | Description |
76
- | -------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
77
- | `export` | `<files-or-urls..>` | 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. |
78
- | `open` | `[files-or-urls..]` | Open a tldraw `.tldr` file or tldraw\.com URL your default browser. Uses a locally-hosted instance of tldraw. Call `open` without an argument to open a blank sketch. Sketches opened via URL are 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. |
78
+ | Command | Argument | Description |
79
+ | -------- | ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
80
+ | `export` | `<files-or-urls..>` | 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. |
81
+ | `open` | `[files-or-urls..]` | 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. |
79
82
 
80
83
  | Option | Alias | Description | Type |
81
84
  | ----------- | ----- | ------------------- | --------- |
@@ -114,7 +117,7 @@ tldraw-cli export <files-or-urls..>
114
117
 
115
118
  #### Subcommand: `tldraw-cli open`
116
119
 
117
- Open a tldraw `.tldr` file or tldraw\.com URL your default browser. Uses a locally-hosted instance of tldraw. Call `open` without an argument to open a blank sketch. Sketches opened via URL are 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.
120
+ 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.
118
121
 
119
122
  Usage:
120
123
 
@@ -135,9 +138,9 @@ tldraw-cli open [files-or-urls..]
135
138
 
136
139
  <!-- /cli-help -->
137
140
 
138
- ### Examples
141
+ #### Examples
139
142
 
140
- #### Basic `.tldr` file image export
143
+ ##### Basic `.tldr` file image export
141
144
 
142
145
  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.
143
146
 
@@ -147,7 +150,7 @@ tldraw-cli export your-drawing.tldr
147
150
 
148
151
  The file will retain its original name, e.g. `your-drawing.svg`
149
152
 
150
- #### Basic tldraw\.com image download
153
+ ##### Basic tldraw\.com image download
151
154
 
152
155
  ```sh
153
156
  tldraw-cli export https://www.tldraw.com/s/v2_c_JsxJk8dag6QsrqExukis4
@@ -157,7 +160,7 @@ The tldraw\.com URL's id (e.g. `v2_c_JsxJk8dag6QsrqExukis4`) will be used for th
157
160
 
158
161
  This is approximately equivalent to clicking the tldraw\.com "☰ → Edit → Export As → SVG" menu item.
159
162
 
160
- #### Export a remote tldraw\.com image to a local .tldr file
163
+ ##### Export a remote tldraw\.com image to a local .tldr file
161
164
 
162
165
  ```sh
163
166
  tldraw-cli export https://www.tldraw.com/s/v2_c_JsxJk8dag6QsrqExukis4 --format tldr
@@ -167,7 +170,7 @@ This is approximately equivalent to clicking the tldraw\.com "☰ → File → S
167
170
 
168
171
  Note that using `--format tldr` with a _file path_ instead of a _URL_ will still send the file through the pipeline, but it's effectively a no-op. (Except perhaps in rare edge cases where tldraw performs a file format version migration).
169
172
 
170
- #### Export to a specific image / file format
173
+ ##### Export to a specific image / file format
171
174
 
172
175
  ```sh
173
176
  tldraw-cli export your-drawing.tldr --format png
@@ -175,7 +178,7 @@ tldraw-cli export your-drawing.tldr --format png
175
178
 
176
179
  This is approximately equivalent to clicking the tldraw\.com "☰ → Edit → Export As → PNG" menu item.
177
180
 
178
- #### Export with a transparent background
181
+ ##### Export with a transparent background
179
182
 
180
183
  ```sh
181
184
  tldraw-cli export your-drawing.tldr --transparent --format png
@@ -183,7 +186,7 @@ tldraw-cli export your-drawing.tldr --transparent --format png
183
186
 
184
187
  This is approximately equivalent to checking the tldraw\.com "☰ → Edit → Export As → ☐ Transparent" menu item.
185
188
 
186
- #### Export to a specific destination
189
+ ##### Export to a specific destination
187
190
 
188
191
  ```sh
189
192
  tldraw-cli export your-drawing.tldr --output ~/Desktop
@@ -191,7 +194,7 @@ tldraw-cli export your-drawing.tldr --output ~/Desktop
191
194
 
192
195
  Exports to `~/Desktop/your-drawing.svg`
193
196
 
194
- #### Export to a specific destination and filename
197
+ ##### Export to a specific destination and filename
195
198
 
196
199
  ```sh
197
200
  tldraw-cli export your-drawing.tldr --output ~/Desktop --name not-your-drawing
@@ -199,7 +202,7 @@ tldraw-cli export your-drawing.tldr --output ~/Desktop --name not-your-drawing
199
202
 
200
203
  Exports to `~/Desktop/not-your-drawing.svg`
201
204
 
202
- #### Export all frames from a tldraw\.com URL
205
+ ##### Export all frames from a tldraw\.com URL
203
206
 
204
207
  ```sh
205
208
  tldraw-cli export https://www.tldraw.com/s/v2_c_FI5RYWbdpAtjsy4OIKrKw --frames
@@ -215,19 +218,19 @@ The frame name will be slugified.
215
218
 
216
219
  It's possible in tldraw to give multiple frames in a single sketch the same name. In these cases, the frame ID is used in addition to the name to ensure unique output file names.
217
220
 
218
- #### Export a specific frame from a tldraw\.com URL
221
+ ##### Export a specific frame from a tldraw\.com URL
219
222
 
220
223
  ```sh
221
224
  tldraw-cli export https://www.tldraw.com/s/v2_c_FI5RYWbdpAtjsy4OIKrKw --frames "Frame 3"
222
225
  ```
223
226
 
224
- #### Export multiple frames from a tldraw\.com URL
227
+ ##### Export multiple frames from a tldraw\.com URL
225
228
 
226
229
  ```sh
227
230
  tldraw-cli export https://www.tldraw.com/s/v2_c_FI5RYWbdpAtjsy4OIKrKw --frames "Frame 1" "Frame 3"
228
231
  ```
229
232
 
230
- #### Export to JSON
233
+ ##### Export to JSON
231
234
 
232
235
  ```sh
233
236
  tldraw-cli export https://www.tldraw.com/s/v2_c_FI5RYWbdpAtjsy4OIKrKw --format "json"
@@ -237,13 +240,13 @@ The `.tldr` file format is also JSON under the covers, but the `--format json` f
237
240
 
238
241
  I'm not completely clear on the use-case for this format, but since tldr.com supports it, so too shall `tldraw-cli`.
239
242
 
240
- #### Write an SVG to stdout
243
+ ##### Write an SVG to stdout
241
244
 
242
245
  ```sh
243
246
  tldraw-cli export https://www.tldraw.com/s/v2_c_FI5RYWbdpAtjsy4OIKrKw --print
244
247
  ```
245
248
 
246
- #### Open a tldraw\.com URL
249
+ ##### Open a tldraw\.com URL
247
250
 
248
251
  ```sh
249
252
  tldraw-cli open https://www.tldraw.com/s/v2_c_FI5RYWbdpAtjsy4OIKrKw
@@ -251,7 +254,7 @@ tldraw-cli open https://www.tldraw.com/s/v2_c_FI5RYWbdpAtjsy4OIKrKw
251
254
 
252
255
  The remote sketch is copied to a locally-hosted instance of tldraw, which is then opened in your default browser.
253
256
 
254
- ## API usage
257
+ ### API
255
258
 
256
259
  The `export` command's functionality is also provided in module form for use in TypeScript or JavaScript Node projects.
257
260
 
@@ -356,6 +359,8 @@ In terms of Puppeteer vs. Playwright and other headless browser automation tools
356
359
 
357
360
  The local instance of tldraw includes its assets dependencies, so the tool should work correctly without internet access.
358
361
 
362
+ Track the [tldraw changelog](https://github.com/tldraw/tldraw/blob/main/CHANGELOG.md).
363
+
359
364
  ## The future
360
365
 
361
366
  Current plans for future improvements include the following:
@@ -374,6 +379,10 @@ Eventually, I think it would make sense for some kind of CLI tool like this one
374
379
 
375
380
  I'm consciously releasing this tool under the `@kitschpatrol` namespace on NPM to leave the `tldraw-cli` package name available to the core tldraw project.
376
381
 
382
+ ## Maintainers
383
+
384
+ [@kitschpatrol](https://github.com/kitschpatrol)
385
+
377
386
  <!-- footer -->
378
387
 
379
388
  ## Contributing