@kitschpatrol/tldraw-cli 4.3.0 → 4.3.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.
@@ -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.0",
3
+ "version": "4.3.2",
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.5",
22
22
  "engines": {
23
23
  "node": ">=18.0.0",
24
24
  "pnpm": ">=8.0.0"
@@ -45,16 +45,16 @@
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.1",
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",
57
+ "@types/react": "^18.2.73",
58
58
  "@types/react-dom": "^18.2.22",
59
59
  "@types/yargs": "^17.0.32",
60
60
  "@vitejs/plugin-react-swc": "^3.6.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",
75
+ "tldraw": "^2.0.2",
76
76
  "tsx": "^4.7.1",
77
- "typescript": "^5.4.2",
77
+ "typescript": "^5.4.3",
78
78
  "untildify": "^5.0.0",
79
- "vite": "^5.1.6",
79
+ "vite": "^5.1.7",
80
80
  "vitest": "^1.4.0",
81
81
  "yargs": "^17.7.2"
82
82
  },
package/readme.md CHANGED
@@ -1,15 +1,23 @@
1
1
  <!--+ Warning: Content inside HTML comment blocks was generated by mdat and may be overwritten. +-->
2
2
 
3
- <!-- header -->
3
+ <!-- title -->
4
4
 
5
5
  # @kitschpatrol/tldraw-cli
6
6
 
7
+ <!-- /title -->
8
+
9
+ <!-- badges -->
10
+
7
11
  [![NPM Package @kitschpatrol/tldraw-cli](https://img.shields.io/npm/v/@kitschpatrol/tldraw-cli.svg)](https://npmjs.com/package/@kitschpatrol/tldraw-cli)
8
12
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
9
13
 
14
+ <!-- /badges -->
15
+
16
+ <!-- description -->
17
+
10
18
  **A CLI tool for exporting tldraw sketch URLs and local .tldr files to SVG or PNG images.**
11
19
 
12
- <!-- /header -->
20
+ <!-- /description -->
13
21
 
14
22
  <!-- table-of-contents { maxDepth: 2 } -->
15
23
 
@@ -101,19 +109,21 @@ tldraw-cli export <files-or-urls..>
101
109
  | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
102
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` |
103
111
 
104
- | Option | Alias | Description | Type | Default |
105
- | --------------- | ----- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- | ----------------------------------------- |
106
- | `--format` | `-f` | Output image format. | `string` | `"svg"` |
107
- | `--output` | `-o` | Output image directory. | `string` | `"./"` |
108
- | `--name` | `-n` | Output image name (without extension). | `string` | The original file name or URL id is used. |
109
- | `--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` |
110
- | `--transparent` | `-t` | Export an image with a transparent background. | `boolean` | `false` |
111
- | `--dark` | `-d` | Export a dark theme version of the image. | `boolean` | `false` |
112
- | `--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` |
113
- | `--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` |
114
- | `--verbose` | | Enable verbose logging. All verbose logs and prefixed with their log level and are printed to `stderr` for ease of redirection. | `boolean` | `false` |
115
- | `--help` | `-h` | Show help | `boolean` | |
116
- | `--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 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` | |
117
127
 
118
128
  #### Subcommand: `tldraw-cli open`
119
129
 
@@ -269,6 +279,9 @@ The library exports a single async function, `tldrawToImage`, which takes an opt
269
279
  frames?: boolean | string[]
270
280
  name?: string
271
281
  output?: string
282
+ padding?: number
283
+ print?: boolean
284
+ scale?: number
272
285
  stripStyle?: boolean
273
286
  transparent?: boolean
274
287
  }): Promise<string[]>;
@@ -363,18 +376,6 @@ Track the [tldraw changelog](https://github.com/tldraw/tldraw/blob/main/CHANGELO
363
376
 
364
377
  ## The future
365
378
 
366
- Current plans for future improvements include the following:
367
-
368
- - Add save button to local tldraw
369
- - Accept globs and optimize batch processing with a single Puppeteer instance
370
- - Add CLI tests
371
- - Implement the ability to export specific pages as separate image files
372
- - Add an option flag to set dpi when exporting to a bitmap format
373
- - There's room for optimization in how tldraw functions are passed to Puppeteer
374
- - There's room for optimization in the `--print` option implementation
375
-
376
- Any other suggestions are welcome.
377
-
378
379
  Eventually, I think it would make sense for some kind of CLI tool like this one to be part of the core tldraw project. (Similar to how [tldraw-vscode](https://github.com/tldraw/tldraw/tree/main/apps/vscode) is currently integrated.)
379
380
 
380
381
  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.