@kitschpatrol/tldraw-cli 4.3.1 → 4.4.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.
@@ -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-BXtO505R.js"></script>
7
+ <script type="module" crossorigin src="/assets/index-DYBjYoWp.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.1",
3
+ "version": "4.4.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": {
@@ -18,7 +18,7 @@
18
18
  "url": "https://ericmika.com"
19
19
  },
20
20
  "license": "MIT",
21
- "packageManager": "pnpm@8.15.4+sha256.cea6d0bdf2de3a0549582da3983c70c92ffc577ff4410cbf190817ddc35137c2",
21
+ "packageManager": "pnpm@8.15.6",
22
22
  "engines": {
23
23
  "node": ">=18.0.0",
24
24
  "pnpm": ">=8.0.0"
@@ -45,17 +45,17 @@
45
45
  ],
46
46
  "dependencies": {
47
47
  "@fontsource/inter": "^5.0.17",
48
- "express": "^4.18.3",
49
- "puppeteer": "^22.5.0",
48
+ "express": "^4.19.2",
49
+ "puppeteer": "^22.6.3",
50
50
  "uint8array-extras": "^1.1.0"
51
51
  },
52
52
  "devDependencies": {
53
- "@kitschpatrol/shared-config": "^4.5.0",
53
+ "@kitschpatrol/shared-config": "^4.6.1",
54
54
  "@sindresorhus/slugify": "^2.2.1",
55
- "@tldraw/assets": "2.0.1",
55
+ "@tldraw/assets": "^2.0.2",
56
56
  "@types/express": "^4.17.21",
57
- "@types/react": "^18.2.66",
58
- "@types/react-dom": "^18.2.22",
57
+ "@types/react": "^18.2.74",
58
+ "@types/react-dom": "^18.2.24",
59
59
  "@types/yargs": "^17.0.32",
60
60
  "@vitejs/plugin-react-swc": "^3.6.0",
61
61
  "bumpp": "^9.4.0",
@@ -64,7 +64,7 @@
64
64
  "esbuild": "^0.20.2",
65
65
  "eslint-plugin-react-hooks": "^4.6.0",
66
66
  "eslint-plugin-react-refresh": "^0.4.6",
67
- "get-port": "^7.0.0",
67
+ "get-port": "^7.1.0",
68
68
  "nanoid": "^5.0.6",
69
69
  "open": "^10.1.0",
70
70
  "path-type": "^5.0.0",
@@ -72,11 +72,11 @@
72
72
  "pretty-ms": "^9.0.0",
73
73
  "react": "^18.2.0",
74
74
  "react-dom": "^18.2.0",
75
- "tldraw": "2.0.1",
76
- "tsx": "^4.7.1",
77
- "typescript": "^5.4.2",
75
+ "tldraw": "^2.0.2",
76
+ "tsx": "^4.7.2",
77
+ "typescript": "^5.4.4",
78
78
  "untildify": "^5.0.0",
79
- "vite": "^5.1.6",
79
+ "vite": "^5.2.8",
80
80
  "vitest": "^1.4.0",
81
81
  "yargs": "^17.7.2"
82
82
  },
package/readme.md CHANGED
@@ -109,21 +109,22 @@ tldraw-cli export <files-or-urls..>
109
109
  | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
110
110
  | `files-or-urls` | The tldraw sketch to export. May be one or more paths to local `.tldr` files, or tldraw\.com sketch URLs. Accepts a mix of both file paths and URLs, and supports glob matching via your shell. Prints the absolute path(s) to the exported image(s) to `stdout`. _(Required.)_ | `array` |
111
111
 
112
- | Option | Alias | Argument | Description | Type | Default |
113
- | --------------- | ----- | ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- | ----------------------------------------- |
114
- | `--format` | `-f` | | Output image format. | `string` | `"svg"` |
115
- | `--output` | `-o` | | Output image directory. | `string` | `"./"` |
116
- | `--name` | `-n` | | Output image name (without extension). | `string` | The original file name or URL id is used. |
117
- | `--frames` | | | Export each sketch "frame" as a separate image. Pass one or more frame names or IDs to export specific frames, or skip the arguments to export all frames. | `array` | `false` |
118
- | `--transparent` | `-t` | | Export an image with a transparent background. | `boolean` | `false` |
119
- | `--dark` | `-d` | | Export a dark theme version of the image. | `boolean` | `false` |
120
- | `--padding` | | `[number]` | Set a specific padding amount around the exported image. | | `32` |
121
- | `--scale` | | `[number]` | Set a sampling amount for raster image exports. | | `1` |
122
- | `--strip-style` | | | Remove `<style>` elements from SVG output, useful to lighten the load of embedded fonts if you intend to provide your own stylesheets. Applies to SVG output only. | `boolean` | `false` |
123
- | `--print` | `-p` | | Print the exported image(s) to stdout instead of saving to a file. Incompatible with `--output`, and disregards `--name`. PNGs are printed as base64-encoded strings. | `boolean` | `false` |
124
- | `--verbose` | | | Enable verbose logging. All verbose logs and prefixed with their log level and are printed to `stderr` for ease of redirection. | `boolean` | `false` |
125
- | `--help` | `-h` | | Show help | `boolean` | |
126
- | `--version` | `-v` | | Show version number | `boolean` | |
112
+ | Option | Alias | Argument | Description | Type | Default |
113
+ | --------------- | ----- | ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- | ----------------------------------------- |
114
+ | `--format` | `-f` | | Output image format. | `string` | `"svg"` |
115
+ | `--output` | `-o` | | Output image directory. | `string` | `"./"` |
116
+ | `--name` | `-n` | | Output image name (without extension). | `string` | The original file name or URL id is used. |
117
+ | `--frames` | | | Export each sketch "frame" as a separate image. Pass one or more frame names or IDs to export specific frames, or pass the flag without the arguments to export all frames. By default, the entire first page is exported with all frames. | `array` | `false` |
118
+ | `--pages` | | | Export each sketch "page" as a separate image. Pass one or more page names or IDs to export specific page, or pass one or more page index numbers (from 0), or pass the flag without the arguments to export all pages. By default, only the first page is exported. | `array` | `false` |
119
+ | `--transparent` | `-t` | | Export an image with a transparent background. | `boolean` | `false` |
120
+ | `--dark` | `-d` | | Export a dark theme version of the image. | `boolean` | `false` |
121
+ | `--padding` | | `[number]` | Set a specific padding amount around the exported image. | | `32` |
122
+ | `--scale` | | `[number]` | Set a sampling factor for raster image exports. | | `1` |
123
+ | `--strip-style` | | | Remove `<style>` elements from SVG output, useful to lighten the load of embedded fonts if you intend to provide your own stylesheets. Applies to SVG output only. | `boolean` | `false` |
124
+ | `--print` | `-p` | | Print the exported image(s) to stdout instead of saving to a file. Incompatible with `--output`, and disregards `--name`. PNGs are printed as base64-encoded strings. | `boolean` | `false` |
125
+ | `--verbose` | | | Enable verbose logging. All verbose logs and prefixed with their log level and are printed to `stderr` for ease of redirection. | `boolean` | `false` |
126
+ | `--help` | `-h` | | Show help | `boolean` | |
127
+ | `--version` | `-v` | | Show version number | `boolean` | |
127
128
 
128
129
  #### Subcommand: `tldraw-cli open`
129
130
 
@@ -240,6 +241,24 @@ tldraw-cli export https://www.tldraw.com/s/v2_c_FI5RYWbdpAtjsy4OIKrKw --frames "
240
241
  tldraw-cli export https://www.tldraw.com/s/v2_c_FI5RYWbdpAtjsy4OIKrKw --frames "Frame 1" "Frame 3"
241
242
  ```
242
243
 
244
+ ##### Export a specific page by name from a tldraw\.com URL
245
+
246
+ ```sh
247
+ tldraw-cli export https://www.tldraw.com/s/v2_c_L_RFQ3mJA_BWHejdH2hlD --pages "Page 3"
248
+ ```
249
+
250
+ ##### Export a specific pages by index from a tldraw\.com URL
251
+
252
+ ```sh
253
+ tldraw-cli export https://www.tldraw.com/s/v2_c_L_RFQ3mJA_BWHejdH2hlD --pages 0 2
254
+ ```
255
+
256
+ ##### Export each pages as its own SVG from a tldraw\.com URL
257
+
258
+ ```sh
259
+ tldraw-cli export https://www.tldraw.com/s/v2_c_L_RFQ3mJA_BWHejdH2hlD --pages
260
+ ```
261
+
243
262
  ##### Export to JSON
244
263
 
245
264
  ```sh
@@ -280,6 +299,7 @@ The library exports a single async function, `tldrawToImage`, which takes an opt
280
299
  name?: string
281
300
  output?: string
282
301
  padding?: number
302
+ pages?: boolean | string[] | number[]
283
303
  print?: boolean
284
304
  scale?: number
285
305
  stripStyle?: boolean
@@ -362,9 +382,9 @@ On Discord:
362
382
 
363
383
  ## Implementation notes
364
384
 
365
- This tool is not a part of the official tldraw project, and it is currently only tested and known to be compatible with tldraw 2.0.0-beta.2.\_
385
+ This tool is not a part of the official tldraw project.
366
386
 
367
- Due to the current implementation of tldraw, export depends on functionality provided by a web browser. So, behind the scenes, this app serves a local instance of tldraw, then loads a `.tldr` and invokes the export download via the [Puppeteer](https://pptr.dev) headless browser automation tool.
387
+ Due to the architecture of tldraw, export depends on functionality provided by a web browser. So, behind the scenes, this app serves a local instance of tldraw, then loads a `.tldr` and invokes the export download via the [Puppeteer](https://pptr.dev) headless browser automation tool.
368
388
 
369
389
  This can be a bit slow, (exporting seems to take a second or two), but in the context of a statically-generated content pipeline it's not the end of the world.
370
390