@kitschpatrol/tldraw-cli 2.2.3 → 3.1.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 (129) hide show
  1. package/bin/cli.js +22251 -27
  2. package/dist/lib/evaluators/download-tldr.d.ts +9 -0
  3. package/dist/lib/index.js +16822 -9
  4. package/dist/lib/local-tldraw-server.d.ts +9 -0
  5. package/dist/lib/tldraw-controller.d.ts +28 -0
  6. package/dist/lib/tldraw-to-image.d.ts +4 -7
  7. package/dist/tldraw/assets/index-S3CdIkLU.css +1 -0
  8. package/dist/tldraw/assets/index-ehug49np.js +315 -0
  9. package/dist/tldraw/favicon.ico +0 -0
  10. package/dist/tldraw/icons/icon/align-bottom-center.svg +1 -1
  11. package/dist/tldraw/icons/icon/align-bottom-left.svg +1 -1
  12. package/dist/tldraw/icons/icon/align-bottom.svg +1 -1
  13. package/dist/tldraw/icons/icon/align-center-horizontal.svg +1 -1
  14. package/dist/tldraw/icons/icon/align-center-left.svg +1 -1
  15. package/dist/tldraw/icons/icon/align-center-vertical.svg +1 -1
  16. package/dist/tldraw/icons/icon/align-left.svg +1 -1
  17. package/dist/tldraw/icons/icon/align-right.svg +1 -1
  18. package/dist/tldraw/icons/icon/align-top-right.svg +1 -1
  19. package/dist/tldraw/icons/icon/align-top.svg +1 -1
  20. package/dist/tldraw/icons/icon/arrowhead-triangle-inverted.svg +1 -1
  21. package/dist/tldraw/icons/icon/arrowhead-triangle.svg +1 -1
  22. package/dist/tldraw/icons/icon/aspect-ratio.svg +1 -1
  23. package/dist/tldraw/icons/icon/blob.svg +1 -1
  24. package/dist/tldraw/icons/icon/check.svg +1 -1
  25. package/dist/tldraw/icons/icon/checkbox-checked.svg +1 -1
  26. package/dist/tldraw/icons/icon/checkbox-empty.svg +1 -1
  27. package/dist/tldraw/icons/icon/chevron-down.svg +1 -1
  28. package/dist/tldraw/icons/icon/chevron-left.svg +1 -1
  29. package/dist/tldraw/icons/icon/chevron-right.svg +1 -1
  30. package/dist/tldraw/icons/icon/chevron-up.svg +1 -1
  31. package/dist/tldraw/icons/icon/chevrons-sw.svg +1 -1
  32. package/dist/tldraw/icons/icon/clipboard-copied.svg +1 -1
  33. package/dist/tldraw/icons/icon/clipboard-copy.svg +1 -1
  34. package/dist/tldraw/icons/icon/code.svg +1 -1
  35. package/dist/tldraw/icons/icon/collab.svg +1 -1
  36. package/dist/tldraw/icons/icon/comment.svg +1 -1
  37. package/dist/tldraw/icons/icon/cross-2.svg +1 -1
  38. package/dist/tldraw/icons/icon/cross.svg +1 -1
  39. package/dist/tldraw/icons/icon/dash-dashed.svg +1 -1
  40. package/dist/tldraw/icons/icon/dash-dotted.svg +1 -1
  41. package/dist/tldraw/icons/icon/dash-draw.svg +1 -1
  42. package/dist/tldraw/icons/icon/discord.svg +1 -1
  43. package/dist/tldraw/icons/icon/distribute-horizontal.svg +1 -1
  44. package/dist/tldraw/icons/icon/distribute-vertical.svg +1 -1
  45. package/dist/tldraw/icons/icon/dots-horizontal.svg +1 -1
  46. package/dist/tldraw/icons/icon/dots-vertical.svg +1 -1
  47. package/dist/tldraw/icons/icon/drag-handle-dots.svg +1 -1
  48. package/dist/tldraw/icons/icon/duplicate.svg +1 -1
  49. package/dist/tldraw/icons/icon/edit.svg +1 -1
  50. package/dist/tldraw/icons/icon/file.svg +1 -1
  51. package/dist/tldraw/icons/icon/fill-none.svg +1 -1
  52. package/dist/tldraw/icons/icon/fill-pattern.svg +1 -1
  53. package/dist/tldraw/icons/icon/fill-semi.svg +1 -1
  54. package/dist/tldraw/icons/icon/fill-solid.svg +1 -1
  55. package/dist/tldraw/icons/icon/follow.svg +1 -1
  56. package/dist/tldraw/icons/icon/following.svg +1 -1
  57. package/dist/tldraw/icons/icon/font-draw.svg +1 -1
  58. package/dist/tldraw/icons/icon/font-mono.svg +1 -1
  59. package/dist/tldraw/icons/icon/font-sans.svg +1 -1
  60. package/dist/tldraw/icons/icon/font-serif.svg +1 -1
  61. package/dist/tldraw/icons/icon/geo-arrow-down.svg +1 -1
  62. package/dist/tldraw/icons/icon/geo-arrow-left.svg +1 -1
  63. package/dist/tldraw/icons/icon/geo-arrow-right.svg +1 -1
  64. package/dist/tldraw/icons/icon/geo-arrow-up.svg +1 -1
  65. package/dist/tldraw/icons/icon/geo-cloud.svg +1 -1
  66. package/dist/tldraw/icons/icon/geo-hexagon.svg +1 -1
  67. package/dist/tldraw/icons/icon/geo-rhombus-2.svg +1 -1
  68. package/dist/tldraw/icons/icon/geo-rhombus.svg +1 -1
  69. package/dist/tldraw/icons/icon/geo-star.svg +1 -1
  70. package/dist/tldraw/icons/icon/geo-trapezoid.svg +1 -1
  71. package/dist/tldraw/icons/icon/geo-triangle.svg +1 -1
  72. package/dist/tldraw/icons/icon/github.svg +1 -1
  73. package/dist/tldraw/icons/icon/group.svg +1 -1
  74. package/dist/tldraw/icons/icon/hidden.svg +1 -1
  75. package/dist/tldraw/icons/icon/image.svg +1 -1
  76. package/dist/tldraw/icons/icon/info-circle.svg +1 -1
  77. package/dist/tldraw/icons/icon/leading.svg +1 -1
  78. package/dist/tldraw/icons/icon/lock-small.svg +1 -1
  79. package/dist/tldraw/icons/icon/lock.svg +1 -1
  80. package/dist/tldraw/icons/icon/menu.svg +1 -1
  81. package/dist/tldraw/icons/icon/minus.svg +1 -1
  82. package/dist/tldraw/icons/icon/mixed.svg +1 -1
  83. package/dist/tldraw/icons/icon/page.svg +1 -1
  84. package/dist/tldraw/icons/icon/plus.svg +1 -1
  85. package/dist/tldraw/icons/icon/question-mark-circle.svg +1 -1
  86. package/dist/tldraw/icons/icon/question-mark.svg +1 -1
  87. package/dist/tldraw/icons/icon/redo.svg +1 -1
  88. package/dist/tldraw/icons/icon/reset-zoom.svg +1 -1
  89. package/dist/tldraw/icons/icon/rotate-ccw.svg +1 -1
  90. package/dist/tldraw/icons/icon/rotate-cw.svg +1 -1
  91. package/dist/tldraw/icons/icon/ruler.svg +1 -1
  92. package/dist/tldraw/icons/icon/settings-vertical-1.svg +1 -1
  93. package/dist/tldraw/icons/icon/size-extra-large.svg +1 -1
  94. package/dist/tldraw/icons/icon/size-large.svg +1 -1
  95. package/dist/tldraw/icons/icon/size-medium.svg +1 -1
  96. package/dist/tldraw/icons/icon/size-small.svg +1 -1
  97. package/dist/tldraw/icons/icon/status-offline.svg +1 -1
  98. package/dist/tldraw/icons/icon/status-online.svg +1 -1
  99. package/dist/tldraw/icons/icon/stretch-horizontal.svg +1 -1
  100. package/dist/tldraw/icons/icon/stretch-vertical.svg +1 -1
  101. package/dist/tldraw/icons/icon/tool-embed.svg +1 -1
  102. package/dist/tldraw/icons/icon/tool-hand.svg +1 -1
  103. package/dist/tldraw/icons/icon/tool-highlight.svg +1 -1
  104. package/dist/tldraw/icons/icon/tool-laser.svg +1 -1
  105. package/dist/tldraw/icons/icon/tool-media.svg +1 -1
  106. package/dist/tldraw/icons/icon/tool-note.svg +1 -1
  107. package/dist/tldraw/icons/icon/tool-pencil.svg +1 -1
  108. package/dist/tldraw/icons/icon/tool-pointer.svg +1 -1
  109. package/dist/tldraw/icons/icon/tool-text.svg +1 -1
  110. package/dist/tldraw/icons/icon/trash.svg +1 -1
  111. package/dist/tldraw/icons/icon/triangle-down.svg +1 -1
  112. package/dist/tldraw/icons/icon/triangle-up.svg +1 -1
  113. package/dist/tldraw/icons/icon/twitter.svg +1 -1
  114. package/dist/tldraw/icons/icon/undo.svg +1 -1
  115. package/dist/tldraw/icons/icon/ungroup.svg +1 -1
  116. package/dist/tldraw/icons/icon/unlock-small.svg +1 -1
  117. package/dist/tldraw/icons/icon/unlock.svg +1 -1
  118. package/dist/tldraw/icons/icon/visible.svg +1 -1
  119. package/dist/tldraw/icons/icon/warning-triangle.svg +1 -1
  120. package/dist/tldraw/icons/icon/zoom-in.svg +1 -1
  121. package/dist/tldraw/icons/icon/zoom-out.svg +1 -1
  122. package/dist/tldraw/index.html +3 -3
  123. package/dist/tldraw/translations/hu.json +352 -2
  124. package/dist/tldraw/translations/languages.json +1 -1
  125. package/dist/tldraw/translations/tr.json +64 -3
  126. package/package.json +16 -11
  127. package/readme.md +139 -47
  128. package/dist/tldraw/assets/index--JsGxma4.js +0 -315
  129. package/dist/tldraw/assets/index-Go1mR3Ch.css +0 -1
@@ -63,7 +63,7 @@
63
63
  "action.stretch-vertical": "Dikey olarak esnet",
64
64
  "action.stretch-horizontal.short": "Yatay esnet",
65
65
  "action.stretch-vertical.short": "Dikey esnet",
66
- "action.toggle-auto-size": "Otomatik boyuta geçiş yap",
66
+ "action.toggle-auto-size": "Boyutu Uyarla aç/kapat",
67
67
  "action.toggle-dark-mode.menu": "Karanlık mod",
68
68
  "action.toggle-dark-mode": "Karanlık moda geçiş yap",
69
69
  "action.toggle-debug-mode.menu": "Hata ayıklama modu",
@@ -267,9 +267,10 @@
267
267
  "style-panel.mixed": "Karışık",
268
268
  "style-panel.opacity": "Opaklık",
269
269
  "style-panel.size": "Boyut",
270
+ "style-panel.spline": "Eğri",
270
271
  "tool-panel.drawing": "Çizim",
271
272
  "tool-panel.shapes": "Şekiller",
272
- "navigation-zone.toggle-minimap": "Mini haritaya geçiş yap",
273
+ "navigation-zone.toggle-minimap": "Mini haritayı aç/kapat",
273
274
  "navigation-zone.zoom": "Yakınlaştır",
274
275
  "focus-mode.toggle-focus-mode": "Odak modunu değiştir",
275
276
  "toast.close": "Kapat",
@@ -290,5 +291,65 @@
290
291
  "file-system.shared-document-file-open-error.description": "Paylaşılan projelerdeki dosyaların açılmaası desteklenmemektedir.",
291
292
  "vscode.file-open.dont-show-again": "Bir daha sorma",
292
293
  "vscode.file-open.desc": "Bu dosya daha önceki bir tldraw versiyonu ile oluşturulmuştur. Yeni versiyonla çalışmak için güncellemek ister misiniz?",
293
- "context.pages.new-page": "Yeni sayfa"
294
+ "context.pages.new-page": "Yeni sayfa",
295
+ "style-panel.arrowhead-start": "Başlangıç",
296
+ "style-panel.arrowhead-end": "Bitiş",
297
+ "vscode.file-open.open": "Devam",
298
+ "vscode.file-open.backup": "Yedek",
299
+ "vscode.file-open.backup-saved": "Yedek Kaydedildi",
300
+ "vscode.file-open.backup-failed": "Yedekleme başarısız: bu .tldr uzantısına sahip bir dosya değil.",
301
+ "tool-panel.more": "Daha Fazla",
302
+ "debug-panel.more": "Daha Fazla",
303
+ "action.new-project": "Yeni Proje",
304
+ "file-system.confirm-clear.title": "Mevcut projeyi temizle",
305
+ "file-system.confirm-clear.description": "Yeni proje başlatmak, mevcut projedeki herşeyi siler. Devam etmek istiyor musun?",
306
+ "file-system.confirm-clear.cancel": "Vazgeç",
307
+ "file-system.confirm-clear.continue": "Devam",
308
+ "file-system.confirm-clear.dont-show-again": "Bir daha sorma",
309
+ "action.stop-following": "Takibi bırak",
310
+ "people-menu.follow": "Takip et",
311
+ "style-panel.position": "Pozisyon",
312
+ "page-menu.go-to-page": "Sayfaya git",
313
+ "action.insert-embed": "Dışardan çağır",
314
+ "people-menu.following": "Takip ediliyor",
315
+ "people-menu.leading": "Seni takip ediyor",
316
+ "geo-style.check-box": "Onay Kutusu",
317
+ "tool.check-box": "Onay Kutusu",
318
+ "share-menu.create-snapshot-link": "Link ile dışarıya ver",
319
+ "share-menu.save-note": "Projeyi .tldr olarak dışa aktar",
320
+ "share-menu.fork-note": "Linki üzerinden projeyi içe aktar",
321
+ "share-menu.snapshot-link-note": "Link ile sadece görüntülenebilir şekilde dışarıya ver",
322
+ "share-menu.upload-failed": "Proje yüklenirken hata oluştu, lütfen daha sonra tekrar deneyin.",
323
+ "style-panel.vertical-align": "Dikey Hizalama",
324
+ "tool.laser": "Lazer",
325
+ "action.fork-project": "Bu projeyi forkla",
326
+ "action.leave-shared-project": "Paylaşılan Projeyi Kapat",
327
+ "sharing.confirm-leave.title": "Açık Projeyi Kapat",
328
+ "sharing.confirm-leave.description": "Paylaşılan projeden ayrılamak istediğinize emin misiniz?. Daha sonra aynı link ile geri dönebilirsiniz.",
329
+ "sharing.confirm-leave.cancel": "Vazgeç",
330
+ "sharing.confirm-leave.leave": "Ayrıl",
331
+ "sharing.confirm-leave.dont-show-again": "Bir daha sorma",
332
+ "action.toggle-reduce-motion.menu": "Hareketi azalt",
333
+ "action.toggle-reduce-motion": "Hareketi azaltmayı aç/kapat",
334
+ "tool.highlight": "Vurgu",
335
+ "action.toggle-lock": "Kilidi Aç / Kilidi Kapat",
336
+ "share-menu.default-project-name": "Projeyi Paylaş",
337
+ "home-project-dialog.title": "Ana Proje",
338
+ "home-project-dialog.description": "Bu sizin yerel ana projenizdir. Sadece sizin için.",
339
+ "rename-project-dialog.title": "Projeyi yeniden adlandır",
340
+ "rename-project-dialog.cancel": "Vazgeç",
341
+ "rename-project-dialog.rename": "Yeniden Adlandır",
342
+ "home-project-dialog.ok": "Tamam",
343
+ "action.open-cursor-chat": "Sohbet imleci",
344
+ "shortcuts-dialog.collaboration": "İşbirliği",
345
+ "cursor-chat.type-to-chat": "Bir şeyler yaz...",
346
+ "geo-style.cloud": "Bulut",
347
+ "tool.cloud": "Bulut",
348
+ "action.unlock-all": "Tüm Kilitleri Aç",
349
+ "status.offline": "Çevrimdışı",
350
+ "status.online": "Çevrimiçi",
351
+ "action.remove-frame": "Çerçeveyi kaldır",
352
+ "action.fit-frame-to-content": "İçeriği Hizala",
353
+ "action.toggle-edge-scrolling.menu": "Kaydırma çubuğu",
354
+ "action.toggle-edge-scrolling": "Kaydırma çubuğunu aç/kapat"
294
355
  }
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@kitschpatrol/tldraw-cli",
3
- "version": "2.2.3",
3
+ "version": "3.1.0",
4
4
  "type": "module",
5
- "description": "A tiny little CLI tool for rendering tldraw URLs and .tldr files into svg or png images.",
5
+ "description": "A tiny little CLI tool for exporting tldraw sketches to svg or png images.",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "git+https://github.com/kitschpatrol/tldraw-cli.git"
@@ -48,8 +48,8 @@
48
48
  "devDependencies": {
49
49
  "@kitschpatrol/shared-config": "^4.3.3",
50
50
  "@sindresorhus/slugify": "^2.2.1",
51
- "@tldraw/assets": "2.0.0-beta.2",
52
- "@tldraw/tldraw": "2.0.0-beta.2",
51
+ "@tldraw/assets": "2.0.0-canary.ade38247d8a4",
52
+ "@tldraw/tldraw": "2.0.0-canary.ade38247d8a4",
53
53
  "@types/express": "^4.17.21",
54
54
  "@types/react": "^18.2.48",
55
55
  "@types/react-dom": "^18.2.18",
@@ -61,13 +61,15 @@
61
61
  "eslint-plugin-react-hooks": "^4.6.0",
62
62
  "eslint-plugin-react-refresh": "^0.4.5",
63
63
  "get-port": "^7.0.0",
64
+ "nanoid": "^5.0.4",
65
+ "open": "^10.0.3",
64
66
  "path-type": "^5.0.0",
65
67
  "react": "^18.2.0",
66
68
  "react-dom": "^18.2.0",
67
69
  "tsx": "^4.7.0",
68
70
  "typescript": "^5.3.3",
69
71
  "untildify": "^5.0.0",
70
- "vite": "^5.0.11",
72
+ "vite": "^5.0.12",
71
73
  "vitest": "^1.2.1",
72
74
  "yargs": "^17.7.2"
73
75
  },
@@ -78,13 +80,16 @@
78
80
  "build": "pnpm run build:tldraw && pnpm run build:lib && pnpm run build:cli",
79
81
  "build:cli": "tsx ./scripts/build-cli.ts",
80
82
  "build:lib": "tsx ./scripts/build-lib.ts && tsc -p tsconfig.lib.json",
81
- "build:tldraw": "pnpm run tldraw-copy-assets && vite build",
82
- "dev": "pnpm run tldraw-copy-assets && vite",
83
+ "build:tldraw": "pnpm run tldraw:copy-assets && vite build",
84
+ "dev": "pnpm run dev:tldraw",
85
+ "dev:tldraw": "pnpm run tldraw:copy-assets && vite",
83
86
  "fix": "shared-config --fix",
84
87
  "lint": "shared-config --lint",
85
- "preview": "vite preview",
86
- "release": "pnpm build && pnpm bumpp --commit 'Release: %s' && pnpm publish --otp $(op read 'op://Personal/Npmjs/one-time password?attribute=otp')",
87
- "test": "vitest",
88
- "tldraw-copy-assets": "rsync -av --include='/*/' --exclude='/*' ./node_modules/@tldraw/assets/ ./src/tldraw/public/"
88
+ "preview": "pnpm run preview:tldraw",
89
+ "preview:tldraw": "vite preview",
90
+ "release": "pnpm run build && pnpm bumpp --commit 'Release: %s' && pnpm publish --otp $(op read 'op://Personal/Npmjs/one-time password?attribute=otp')",
91
+ "test": "pnpm run test:lib",
92
+ "test:lib": "pnpm run build && vitest",
93
+ "tldraw:copy-assets": "rsync -av --include='/*/' --exclude='/*' --exclude='favicon.ico' ./node_modules/@tldraw/assets/ ./src/tldraw/public/"
89
94
  }
90
95
  }
package/readme.md CHANGED
@@ -15,7 +15,7 @@ _For `.tldr` file import support in Vite projects, please see [@kitschpatrol/vit
15
15
  Invoke directly:
16
16
 
17
17
  ```sh
18
- npx @kitschpatrol/tldraw-cli some-file.tldr
18
+ npx @kitschpatrol/tldraw-cli export some-file.tldr
19
19
  ```
20
20
 
21
21
  ...or install locally:
@@ -34,35 +34,75 @@ npm install --global @kitschpatrol/tldraw-cli
34
34
 
35
35
  ### Invocation
36
36
 
37
+ `tldraw-cli`'s functionality is organized into several sub-commands.
38
+
39
+ #### Top-level
40
+
37
41
  ```sh
38
- tldraw-cli file-or-url {options}
42
+ tldraw-cli <command>
39
43
  ```
40
44
 
41
- | Argument | Description |
42
- | ------------- | ------------------------------------------------------------------------------------------------------- |
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. |
45
+ The top-level collection of CLI tools for tldraw.
46
+
47
+ | Argument | Description |
48
+ | --------- | ------------------- |
49
+ | `command` | `export` or `open`. |
50
+
51
+ | Option | Alias | Description Value |
52
+ | ----------- | ----- | -------------------- |
53
+ | `--help ` | `-h` | Show help. |
54
+ | `--version` | `-v` | Show version number. |
44
55
 
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, slugified frame names will also match. | `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` |
56
+ #### Command: Export
57
+
58
+ ```sh
59
+ tldraw-cli export <file-or-url>
60
+ ```
61
+
62
+ Export a tldraw `.tldr` file or tldraw\.com URL to SVG, PNG, and other formats.
63
+
64
+ | Argument | Description |
65
+ | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
66
+ | `<file-or-url>` | The sketch to export — either a path to a local `.tldr` file, or a tldraw\.com sketch URL. Prints the absolute path(s) to the exported image(s) to `stdout`. |
67
+
68
+ | Option | Alias | Description Value | Default Value |
69
+ | ------------------- | ----- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- |
70
+ | `--format <string>` | `-f` | Output image format, one of `svg`, `png`, `json`, or `tldr`. | `svg` |
71
+ | `--dark-mode ` | `-d` | Output a dark theme version of the image. | `false` |
72
+ | `--transparent ` | `-t` | Output an image with a transparent background. | `false` |
73
+ | `--output <string>` | `-o` | Output directory. | `./` |
74
+ | `--name <string>` | `-n` | Output file name without extension; by default the original file name or URL id is used. | |
75
+ | `--frames <array?>` | | 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. | `false` |
76
+ | `--strip-style` | | Remove `<style>` elements from SVG output, useful to lighten the load of embedded fonts if you intend to provide your own stylesheets. | `false` |
77
+ | `--print` | `-p` | Print the exported image(s) to stdout instead of saving to a file. Incompatible with --output, and overrides --name. PNGs are printed as base64-encoded strings. | `false` |
78
+ | `--verbose` | | Enable verbose output. | `false` |
79
+
80
+ #### Command: Open
81
+
82
+ ```sh
83
+ tldraw-cli open [file-or-url]
84
+ ```
85
+
86
+ 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.
87
+
88
+ Sketches opened via URL are copied to the local system, and will not be kept in sync with tldraw.com.
89
+
90
+ _"Save as" support is not yet implemented in the local tldraw instance, so the `open` command is only recommended for viewing purposes at the moment._
91
+
92
+ | Argument | Description |
93
+ | --------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
94
+ | `[file-or-url]` | The `.tldr` file or tldraw\.com sketch url to open. Omit the argument to open a blank sketch. Prints the url of the local server to `stdout`. |
95
+
96
+ No options.
57
97
 
58
98
  ## Examples
59
99
 
60
- ### Basic .tldr file conversion
100
+ ### Basic `.tldr` file image export
61
101
 
62
- To convert the file `your-drawing.tldr` to an svg named `your-drawing.svg` saved 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.
102
+ 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.
63
103
 
64
104
  ```sh
65
- npx @kitschpatrol/tldraw-cli your-drawing.tldr
105
+ tldraw-cli export your-drawing.tldr
66
106
  ```
67
107
 
68
108
  The file will retain its original name, e.g. `your-drawing.svg`
@@ -70,46 +110,62 @@ The file will retain its original name, e.g. `your-drawing.svg`
70
110
  ### Basic tldraw\.com image download
71
111
 
72
112
  ```sh
73
- npx @kitschpatrol/tldraw-cli https://www.tldraw.com/s/v2_c_JsxJk8dag6QsrqExukis4
113
+ tldraw-cli export https://www.tldraw.com/s/v2_c_JsxJk8dag6QsrqExukis4
114
+ ```
115
+
116
+ The tldraw.com URL's id (e.g. `v2_c_JsxJk8dag6QsrqExukis4`) will be used for the file name.
117
+
118
+ This is approximately equivalent to clicking the tldraw\.com "☰ → Edit → Export As → SVG" menu item.
119
+
120
+ ### Export a remote tldraw\.com image to a local .tldr file
121
+
122
+ ```sh
123
+ tldraw-cli export https://www.tldraw.com/s/v2_c_JsxJk8dag6QsrqExukis4 --format tldr
74
124
  ```
75
125
 
76
- The tldraw URL's id (e.g. `v2_c_JsxJk8dag6QsrqExukis4`) will be used for the file name.
126
+ This is approximately equivalent to clicking the tldraw\.com "☰ File Save a copy" menu item.
77
127
 
78
- ### Export to a specific format
128
+ 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 rare edge cases where tldraw performs a file format version migration).
129
+
130
+ ### Export to a specific image / file format
79
131
 
80
132
  ```sh
81
- npx @kitschpatrol/tldraw-cli your-drawing.tldr --format png
133
+ tldraw-cli export your-drawing.tldr --format png
82
134
  ```
83
135
 
136
+ This is approximately equivalent to clicking the tldraw\.com "☰ → Edit → Export As → PNG" menu item.
137
+
84
138
  ### Export with a transparent background
85
139
 
86
140
  ```sh
87
- npx @kitschpatrol/tldraw-cli your-drawing.tldr --transparent --format png
141
+ tldraw-cli export your-drawing.tldr --transparent --format png
88
142
  ```
89
143
 
144
+ This is approximately equivalent to checking the tldraw\.com "☰ → Edit → Export As → ☐ Transparent" menu item.
145
+
90
146
  ### Export to a specific destination
91
147
 
92
148
  ```sh
93
- npx @kitschpatrol/tldraw-cli your-drawing.tldr --output ~/Desktop
149
+ tldraw-cli export your-drawing.tldr --output ~/Desktop
94
150
  ```
95
151
 
96
- Saves to `~/Desktop/your-drawing.svg`
152
+ Exports to `~/Desktop/your-drawing.svg`
97
153
 
98
154
  ### Export to a specific destination and filename
99
155
 
100
156
  ```sh
101
- npx @kitschpatrol/tldraw-cli your-drawing.tldr --output ~/Desktop --name not-your-drawing
157
+ tldraw-cli export your-drawing.tldr --output ~/Desktop --name not-your-drawing
102
158
  ```
103
159
 
104
- Saves to `~/Desktop/not-your-drawing.svg`
160
+ Exports to `~/Desktop/not-your-drawing.svg`
105
161
 
106
- ### Export all frames from a single tldraw URL
162
+ ### Export all frames from a tldraw.com URL
107
163
 
108
164
  ```sh
109
- npx @kitschpatrol/tldraw-cli https://www.tldraw.com/s/v2_c_FI5RYWbdpAtjsy4OIKrKw --frames
165
+ tldraw-cli export https://www.tldraw.com/s/v2_c_FI5RYWbdpAtjsy4OIKrKw --frames
110
166
  ```
111
167
 
112
- The saved files will be suffixed with their frame name, e.g.:
168
+ The exported files will be suffixed with their frame name, e.g.:
113
169
 
114
170
  `v2_c_FI5RYWbdpAtjsy4OIKrKw-frame-1.png`
115
171
  `v2_c_FI5RYWbdpAtjsy4OIKrKw-frame-2.png`
@@ -119,49 +175,82 @@ The frame name will be slugified.
119
175
 
120
176
  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.
121
177
 
122
- ### Export a specific frame from a tldraw URL
178
+ ### Export a specific frame from a tldraw.com URL
179
+
180
+ ```sh
181
+ tldraw-cli export https://www.tldraw.com/s/v2_c_FI5RYWbdpAtjsy4OIKrKw --frames "Frame 3"
182
+ ```
183
+
184
+ ### Export multiple frames from a tldraw.com URL
123
185
 
124
186
  ```sh
125
- npx @kitschpatrol/tldraw-cli https://www.tldraw.com/s/v2_c_FI5RYWbdpAtjsy4OIKrKw --frames "Frame 1" "Frame 3"
187
+ tldraw-cli export https://www.tldraw.com/s/v2_c_FI5RYWbdpAtjsy4OIKrKw --frames "Frame 1" "Frame 3"
126
188
  ```
127
189
 
190
+ ### Export to JSON
191
+
192
+ ```sh
193
+ tldraw-cli export https://www.tldraw.com/s/v2_c_FI5RYWbdpAtjsy4OIKrKw --format "json"
194
+ ```
195
+
196
+ The `.tldr` file format is also JSON under the covers, but the `--format json` flag will yield a slightly different format than `--format tldr`. `--format json` is equivalent to what's produced via the tldraw\.com "☰ → Edit → Export As → JSON" menu item.
197
+
198
+ I'm not completely clear on the use-case for this format, but since tldr.com supports it, so too shall `tldraw-cli`.
199
+
200
+ ### Write an SVG to stdout
201
+
202
+ ```sh
203
+ tldraw-cli export https://www.tldraw.com/s/v2_c_FI5RYWbdpAtjsy4OIKrKw --print
204
+ ```
205
+
206
+ ### Open a tldraw.com URL
207
+
208
+ ```sh
209
+ tldraw-cli open https://www.tldraw.com/s/v2_c_FI5RYWbdpAtjsy4OIKrKw
210
+ ```
211
+
212
+ The remote sketch is copied to a locally-hosted instance of tldraw, which is then opened in your default browser.
213
+
128
214
  ## API usage
129
215
 
130
- The conversion tool's functionality is also exposed as a module for use in TypeScript or JavaScript Node projects.
216
+ The `export` command's functionality is also provided in module form for use in TypeScript or JavaScript Node projects.
131
217
 
132
218
  The library exports a single async function, `tldrawToImage`, which takes an options argument mirroring the arguments available via the command line. The same default values apply:
133
219
 
134
220
  ```ts
135
- tldrawToImage(
221
+ async function tldrawToImage(
136
222
  tldrPathOrUrl: string,
137
223
  {
138
224
  darkMode?: boolean
139
- output?: string
140
- format?: 'png' | 'svg'
225
+ format?: 'svg' | 'png' | 'json' | 'tldr'
141
226
  frames?: boolean | string[]
227
+ name?: string
228
+ output?: string
142
229
  stripStyle?: boolean
143
230
  transparent?: boolean
144
231
  verbose?: boolean
145
- }): Promise<string | string[]>;
232
+ }): Promise<string[]>;
146
233
  ```
147
234
 
148
- The function exports the image in the requested format returns the full path to the output image.
235
+ The function exports the image in the requested format returns an array of the output image(s) or file(s).
236
+
237
+ Generally, a single file is returned — but the `string[]` return type also accommodates invocations with `frame: true` where multiple images will be generated.
149
238
 
150
239
  Assuming you've installed `@kitschpatrol/tldraw-cli` locally in your project, it may be used as follows:
151
240
 
152
241
  ```ts
153
- // tldr-cli-api-test.ts
242
+ // tldraw-cli-api-test.ts
154
243
 
155
244
  import { tldrawToImage } from '@kitschpatrol/tldraw-cli'
156
245
 
157
246
  // Convert a local file to PNG
158
- const imagePath = await tldrawToImage('./some-file.tldr', { format: 'png', output: './' })
247
+ const [imagePath] = await tldrawToImage('./some-file.tldr', { format: 'png', output: './' })
159
248
  console.log(`Wrote image to: "${imagePath}"`)
160
249
 
161
- // Convert a remote tldraw URL to SVG
250
+ // Convert a remote tldraw.com URL to SVG
162
251
  await tldrawToImage('https://www.tldraw.com/s/v2_c_JsxJk8dag6QsrqExukis4')
163
252
 
164
- // Convert all frames from a single tldraw URL to separate SVGs
253
+ // Convert all frames from a single tldraw.com URL to separate SVGs
165
254
  // When the `frames` option is set, the function returns an array
166
255
  // of resulting file paths, instead of a solitary string
167
256
  const framePathsArray = await tldrawToImage('https://www.tldraw.com/s/v2_c_FI5RYWbdpAtjsy4OIKrKw', {
@@ -169,20 +258,20 @@ const framePathsArray = await tldrawToImage('https://www.tldraw.com/s/v2_c_FI5RY
169
258
  })
170
259
  console.log(`Wrote frames to: "${framePathsArray}"`)
171
260
 
172
- // Convert a specific frame from a tldraw URL to a PNG
261
+ // Convert a specific frame from a tldraw.com URL to a PNG
173
262
  await tldrawToImage('https://www.tldraw.com/s/v2_c_FI5RYWbdpAtjsy4OIKrKw', {
174
263
  frames: ['Frame 3'],
175
264
  format: 'png',
176
265
  })
177
266
 
178
- // You can also use the frame id instead of name, if you're into that sort of thing
267
+ // You can also use the frame id instead of the frame name, if you're into that sort of thing
179
268
  // It will work with or without the `shape:` prefix
180
269
  await tldrawToImage('https://www.tldraw.com/s/v2_c_FI5RYWbdpAtjsy4OIKrKw', {
181
270
  frames: ['shape:x8z3Qf7Hgw4Qqp2AC-eet'],
182
271
  })
183
272
  ```
184
273
 
185
- _Note that the library provided is ESM only, and requires a Node-compatible runtime. TypeScript type definitions are included._
274
+ _Note that the library provided is ESM-only, and requires a Node-compatible runtime. TypeScript type definitions are included._
186
275
 
187
276
  ## Background
188
277
 
@@ -216,10 +305,13 @@ The local instance of tldraw includes its assets dependencies, so the tool shoul
216
305
 
217
306
  This is a very minimal implementation. Current plans for future improvements include the following:
218
307
 
308
+ - Add save button to local tldraw
219
309
  - Add CLI tests
220
310
  - Implement the ability to export specific pages as separate image files
221
311
  - Add an option flag to set dpi when exporting to a bitmap format
222
312
  - Additional commands beyond sketch conversion / export?
313
+ - There's room for optimization in how tldraw functions are passed to Puppeteer
314
+ - There's room for optimization in the `--print` option implementation
223
315
 
224
316
  Any other suggestions are welcome.
225
317