@kitschpatrol/tldraw-cli 2.1.1 → 2.2.1
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 +30 -23
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/index.js +12 -5
- package/dist/lib/tldraw-to-image.d.ts +5 -3
- package/package.json +4 -3
- package/readme.md +31 -12
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
export type
|
|
1
|
+
export type TldrawToImageOptions = {
|
|
2
2
|
darkMode?: boolean;
|
|
3
3
|
format?: 'png' | 'svg';
|
|
4
4
|
frames?: boolean | string[];
|
|
5
|
+
name?: string;
|
|
5
6
|
output?: string;
|
|
7
|
+
stripStyle?: boolean;
|
|
6
8
|
transparent?: boolean;
|
|
7
9
|
verbose?: boolean;
|
|
8
10
|
};
|
|
9
|
-
export declare function tldrawToImage(tldrPathOrUrl: string, options?:
|
|
11
|
+
export declare function tldrawToImage(tldrPathOrUrl: string, options?: TldrawToImageOptions & {
|
|
10
12
|
frames?: false | undefined;
|
|
11
13
|
}): Promise<string>;
|
|
12
|
-
export declare function tldrawToImage(tldrPathOrUrl: string, options?:
|
|
14
|
+
export declare function tldrawToImage(tldrPathOrUrl: string, options?: TldrawToImageOptions & {
|
|
13
15
|
frames: string[] | true;
|
|
14
16
|
}): Promise<string[]>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kitschpatrol/tldraw-cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A tiny little CLI tool for rendering tldraw URLs and .tldr files into svg or png images.",
|
|
6
6
|
"repository": {
|
|
@@ -55,7 +55,8 @@
|
|
|
55
55
|
"@types/voca": "^1.4.5",
|
|
56
56
|
"@types/yargs": "^17.0.32",
|
|
57
57
|
"@vitejs/plugin-react-swc": "^3.5.0",
|
|
58
|
-
"bumpp": "^9.
|
|
58
|
+
"bumpp": "^9.3.0",
|
|
59
|
+
"cheerio": "1.0.0-rc.12",
|
|
59
60
|
"esbuild": "^0.19.11",
|
|
60
61
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
61
62
|
"eslint-plugin-react-refresh": "^0.4.5",
|
|
@@ -67,7 +68,7 @@
|
|
|
67
68
|
"typescript": "^5.3.3",
|
|
68
69
|
"untildify": "^5.0.0",
|
|
69
70
|
"vite": "^5.0.11",
|
|
70
|
-
"vitest": "^1.2.
|
|
71
|
+
"vitest": "^1.2.1",
|
|
71
72
|
"voca": "^1.4.1",
|
|
72
73
|
"yargs": "^17.7.2"
|
|
73
74
|
},
|
package/readme.md
CHANGED
|
@@ -42,16 +42,18 @@ tldraw-cli file-or-url {options}
|
|
|
42
42
|
| ------------- | ------------------------------------------------------------------------------------------------------- |
|
|
43
43
|
| `file-or-url` | The sketch to convert to an image — either a path to a local ".tldr" file, or a tldraw\.com sketch URL. |
|
|
44
44
|
|
|
45
|
-
| Option | Alias | Description Value
|
|
46
|
-
| --------------------- | ----- |
|
|
47
|
-
| `--format <svg\|png>` | `-f` | Output image format, one of `svg` or `png`
|
|
48
|
-
| `--dark-mode ` | `-d` | Output a dark theme version of the image
|
|
49
|
-
| `--transparent ` | `-t` | Output an image with a transparent background
|
|
50
|
-
| `--output <string>` | `-o` | Output directory
|
|
51
|
-
| `--
|
|
52
|
-
| `--
|
|
53
|
-
| `--
|
|
54
|
-
| `--
|
|
45
|
+
| Option | Alias | Description Value | Default Value |
|
|
46
|
+
| --------------------- | ----- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------- |
|
|
47
|
+
| `--format <svg\|png>` | `-f` | Output image format, one of `svg` or `png` | `svg` |
|
|
48
|
+
| `--dark-mode ` | `-d` | Output a dark theme version of the image | `false` |
|
|
49
|
+
| `--transparent ` | `-t` | Output an image with a transparent background | `false` |
|
|
50
|
+
| `--output <string>` | `-o` | Output directory | `./` |
|
|
51
|
+
| `--name <string>` | `-n` | Output file name without extension; by default the original file name or URL id is used | |
|
|
52
|
+
| `--frames <array?>` | | Export each sketch "frame" as a separate image, use the option flag alone to export all frames, or pass one or more frame names or IDs | `false` |
|
|
53
|
+
| `--strip-style` | | Remove `<style>` elements from SVG output, useful to lighten the load of embedded fonts or if you are going to provide your own stylesheet for the SVG | `false` |
|
|
54
|
+
| `--help ` | `-h` | Show help | |
|
|
55
|
+
| `--version` | `-v` | Show version number | |
|
|
56
|
+
| `--verbose` | | Enable verbose output | `false` |
|
|
55
57
|
|
|
56
58
|
## Examples
|
|
57
59
|
|
|
@@ -91,13 +93,29 @@ npx @kitschpatrol/tldraw-cli your-drawing.tldr --transparent --format png
|
|
|
91
93
|
npx @kitschpatrol/tldraw-cli your-drawing.tldr --output ~/Desktop
|
|
92
94
|
```
|
|
93
95
|
|
|
96
|
+
Saves to `~/Desktop/your-drawing.svg`
|
|
97
|
+
|
|
98
|
+
### Export to a specific destination and filename
|
|
99
|
+
|
|
100
|
+
```sh
|
|
101
|
+
npx @kitschpatrol/tldraw-cli your-drawing.tldr --output ~/Desktop --name not-your-drawing
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Saves to `~/Desktop/not-your-drawing.svg`
|
|
105
|
+
|
|
94
106
|
### Export all frames from a single tldraw URL
|
|
95
107
|
|
|
96
108
|
```sh
|
|
97
109
|
npx @kitschpatrol/tldraw-cli https://www.tldraw.com/s/v2_c_FI5RYWbdpAtjsy4OIKrKw --frames
|
|
98
110
|
```
|
|
99
111
|
|
|
100
|
-
The saved files will be suffixed with their frame name, e.g.:
|
|
112
|
+
The saved files will be suffixed with their frame name, e.g.:
|
|
113
|
+
|
|
114
|
+
`v2_c_FI5RYWbdpAtjsy4OIKrKw-frame-1.png`
|
|
115
|
+
`v2_c_FI5RYWbdpAtjsy4OIKrKw-frame-2.png`
|
|
116
|
+
`v2_c_FI5RYWbdpAtjsy4OIKrKw-frame-3.png`
|
|
117
|
+
|
|
118
|
+
The frame name will be slugified.
|
|
101
119
|
|
|
102
120
|
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.
|
|
103
121
|
|
|
@@ -121,9 +139,10 @@ The library exports a single async function, `tldrawToImage`, which takes an opt
|
|
|
121
139
|
output?: string
|
|
122
140
|
format?: 'png' | 'svg'
|
|
123
141
|
frames?: boolean | string[]
|
|
142
|
+
stripStyle?: boolean
|
|
124
143
|
transparent?: boolean
|
|
125
144
|
verbose?: boolean
|
|
126
|
-
}): Promise<string>;
|
|
145
|
+
}): Promise<string | string[]>;
|
|
127
146
|
```
|
|
128
147
|
|
|
129
148
|
The function exports the image in the requested format returns the full path to the output image.
|