@kitschpatrol/tldraw-cli 4.1.1 → 4.1.2
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 +1 -2
- package/dist/lib/index.js +1 -2
- package/package.json +3 -3
- package/readme.md +29 -22
package/bin/cli.js
CHANGED
|
@@ -17257,8 +17257,7 @@ var TldrawController = class {
|
|
|
17257
17257
|
if (!this.page)
|
|
17258
17258
|
throw new Error("Controller not started");
|
|
17259
17259
|
log_default.info(`Setting dark mode: ${darkMode}`);
|
|
17260
|
-
|
|
17261
|
-
this.originalDarkMode = await this.getDarkMode();
|
|
17260
|
+
this.originalDarkMode ??= await this.getDarkMode();
|
|
17262
17261
|
await this.page.evaluate(`editor.user.updateUserPreferences({ isDarkMode: ${darkMode}})`);
|
|
17263
17262
|
}
|
|
17264
17263
|
async loadFile(filePath) {
|
package/dist/lib/index.js
CHANGED
|
@@ -17059,8 +17059,7 @@ var TldrawController = class {
|
|
|
17059
17059
|
if (!this.page)
|
|
17060
17060
|
throw new Error("Controller not started");
|
|
17061
17061
|
log_default.info(`Setting dark mode: ${darkMode}`);
|
|
17062
|
-
|
|
17063
|
-
this.originalDarkMode = await this.getDarkMode();
|
|
17062
|
+
this.originalDarkMode ??= await this.getDarkMode();
|
|
17064
17063
|
await this.page.evaluate(`editor.user.updateUserPreferences({ isDarkMode: ${darkMode}})`);
|
|
17065
17064
|
}
|
|
17066
17065
|
async loadFile(filePath) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kitschpatrol/tldraw-cli",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A tiny little CLI tool for exporting tldraw sketches to svg or png images.",
|
|
6
6
|
"repository": {
|
|
@@ -46,12 +46,12 @@
|
|
|
46
46
|
"puppeteer": "^22.2.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@kitschpatrol/shared-config": "^4.4.
|
|
49
|
+
"@kitschpatrol/shared-config": "^4.4.2",
|
|
50
50
|
"@sindresorhus/slugify": "^2.2.1",
|
|
51
51
|
"@tldraw/assets": "2.0.0-canary.e6e4e7f6cbac",
|
|
52
52
|
"@tldraw/tldraw": "2.0.0-canary.e6e4e7f6cbac",
|
|
53
53
|
"@types/express": "^4.17.21",
|
|
54
|
-
"@types/react": "^18.2.
|
|
54
|
+
"@types/react": "^18.2.58",
|
|
55
55
|
"@types/react-dom": "^18.2.19",
|
|
56
56
|
"@types/yargs": "^17.0.32",
|
|
57
57
|
"@vitejs/plugin-react-swc": "^3.6.0",
|
package/readme.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<!--+ Warning: Content
|
|
1
|
+
<!--+ Warning: Content inside HTML comment blocks was generated by mdat and may be overwritten. +-->
|
|
2
2
|
|
|
3
3
|
<!-- header -->
|
|
4
4
|
|
|
@@ -17,12 +17,13 @@
|
|
|
17
17
|
|
|
18
18
|
- [Overview](#overview)
|
|
19
19
|
- [Installation](#installation)
|
|
20
|
-
- [
|
|
21
|
-
- [
|
|
22
|
-
- [API
|
|
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
|
|
|
@@ -56,7 +57,9 @@ npm install --save-dev @kitschpatrol/tldraw-cli
|
|
|
56
57
|
npm install --global @kitschpatrol/tldraw-cli
|
|
57
58
|
```
|
|
58
59
|
|
|
59
|
-
##
|
|
60
|
+
## Usage
|
|
61
|
+
|
|
62
|
+
### CLI
|
|
60
63
|
|
|
61
64
|
<!-- cli-help -->
|
|
62
65
|
|
|
@@ -135,9 +138,9 @@ tldraw-cli open [files-or-urls..]
|
|
|
135
138
|
|
|
136
139
|
<!-- /cli-help -->
|
|
137
140
|
|
|
138
|
-
|
|
141
|
+
#### Examples
|
|
139
142
|
|
|
140
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
|
@@ -341,8 +344,8 @@ On GitHub:
|
|
|
341
344
|
|
|
342
345
|
On Discord:
|
|
343
346
|
|
|
344
|
-
- [@jorisjh in #
|
|
345
|
-
- [@Nitsuj in #
|
|
347
|
+
- [@jorisjh in #ideas_old](https://discord.com/channels/859816885297741824/859816885801713730/1156880056501665802)
|
|
348
|
+
- [@Nitsuj in #ideas_old](https://discord.com/channels/859816885297741824/859816885801713730/1020352607920869406)
|
|
346
349
|
|
|
347
350
|
## Implementation notes
|
|
348
351
|
|
|
@@ -374,6 +377,10 @@ Eventually, I think it would make sense for some kind of CLI tool like this one
|
|
|
374
377
|
|
|
375
378
|
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
379
|
|
|
380
|
+
## Maintainers
|
|
381
|
+
|
|
382
|
+
[@kitschpatrol](https://github.com/kitschpatrol)
|
|
383
|
+
|
|
377
384
|
<!-- footer -->
|
|
378
385
|
|
|
379
386
|
## Contributing
|