@kitschpatrol/tldraw-cli 2.2.2 → 3.0.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 +22209 -27
  2. package/dist/lib/evaluators/download-tldr.d.ts +9 -0
  3. package/dist/lib/index.js +16793 -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 +3 -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 +124 -45
  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.2",
3
+ "version": "3.0.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
@@ -8,61 +8,100 @@
8
8
 
9
9
  This could be useful in the context of a content publishing pipeline where you want to use a `.tldr` file (perhaps under version control) as the "source of truth" for assets to be embedded elsewhere, and you don't want to manage the export of that diagram manually.
10
10
 
11
- _Note: This tool is not a part of the official tldraw project, and it is currently only tested and compatible with tldraw 2.0.0-beta.2._
11
+ _For `.tldr` file import support in Vite projects, please see [@kitschpatrol/vite-plugin-tldraw](https://github.com/kitschpatrol/vite-plugin-tldraw)._
12
12
 
13
13
  ## Installation
14
14
 
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:
22
22
 
23
23
  ```sh
24
- npm --install --save-dev @kitschpatrol/tldraw-cli
24
+ npm install --save-dev @kitschpatrol/tldraw-cli
25
25
  ```
26
26
 
27
27
  ...or install globally:
28
28
 
29
29
  ```sh
30
- npm --install --global @kitschpatrol/tldraw-cli
30
+ npm install --global @kitschpatrol/tldraw-cli
31
31
  ```
32
32
 
33
33
  ## Command line usage
34
34
 
35
35
  ### Invocation
36
36
 
37
+ To leave room for future functionality, `tldraw-cli` exposes functionality under several sub-commands.
38
+
39
+ #### Top-level
40
+
41
+ ```sh
42
+ tldraw-cli <command>
43
+ ```
44
+
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. |
55
+
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 an svg, png image, and other formats.
63
+
64
+ | Argument | Description |
65
+ | --------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
66
+ | `<file-or-url>` | The sketch to convert export an image — 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, 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` |
76
+ | `--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` |
77
+ | `--verbose` | | Enable verbose output. | `false` |
78
+
79
+ #### Command: Open
80
+
37
81
  ```sh
38
- tldraw-cli file-or-url {options}
82
+ tldraw-cli open [file-or-url]
39
83
  ```
40
84
 
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. |
85
+ 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.
86
+
87
+ Sketches opened via URL are copied to the local system, and will not be kept in sync with tldraw.com.
44
88
 
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` |
89
+ "Save as" support is not yet implemented in the local tldraw instance, so it's recommended for viewing purposes only at the moment.
90
+
91
+ | Argument | Description |
92
+ | --------------- | ------------------------------------------------------------------------------------------------------------------------------ |
93
+ | `[file-or-url]` | The .tldr file or tldraw\.com sketch url to open. Omit to open a blank sketch. Prints the url of the local server to `stdout`. |
94
+
95
+ No options.
57
96
 
58
97
  ## Examples
59
98
 
60
- ### Basic .tldr file conversion
99
+ ### Basic .tldr file image export
61
100
 
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.
101
+ 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
102
 
64
103
  ```sh
65
- npx @kitschpatrol/tldraw-cli your-drawing.tldr
104
+ npx @kitschpatrol/tldraw-cli export your-drawing.tldr
66
105
  ```
67
106
 
68
107
  The file will retain its original name, e.g. `your-drawing.svg`
@@ -70,46 +109,62 @@ The file will retain its original name, e.g. `your-drawing.svg`
70
109
  ### Basic tldraw\.com image download
71
110
 
72
111
  ```sh
73
- npx @kitschpatrol/tldraw-cli https://www.tldraw.com/s/v2_c_JsxJk8dag6QsrqExukis4
112
+ npx @kitschpatrol/tldraw-cli export https://www.tldraw.com/s/v2_c_JsxJk8dag6QsrqExukis4
74
113
  ```
75
114
 
76
115
  The tldraw URL's id (e.g. `v2_c_JsxJk8dag6QsrqExukis4`) will be used for the file name.
77
116
 
117
+ This is approximately equivalent to clicking the tldraw\.com "☰ → Edit → Export As → SVG" menu item.
118
+
119
+ ### Export a remote tldraw\.com image to a local .tldr file
120
+
121
+ ```sh
122
+ npx @kitschpatrol/tldraw-cli export https://www.tldraw.com/s/v2_c_JsxJk8dag6QsrqExukis4 --format tldr
123
+ ```
124
+
125
+ This is approximately equivalent to clicking the tldraw\.com "☰ → File → Save a copy" menu item.
126
+
127
+ 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).
128
+
78
129
  ### Export to a specific format
79
130
 
80
131
  ```sh
81
- npx @kitschpatrol/tldraw-cli your-drawing.tldr --format png
132
+ npx @kitschpatrol/tldraw-cli export your-drawing.tldr --format png
82
133
  ```
83
134
 
135
+ This is approximately equivalent to clicking the tldraw\.com "☰ → Edit → Export As → PNG" menu item.
136
+
84
137
  ### Export with a transparent background
85
138
 
86
139
  ```sh
87
- npx @kitschpatrol/tldraw-cli your-drawing.tldr --transparent --format png
140
+ npx @kitschpatrol/tldraw-cli export your-drawing.tldr --transparent --format png
88
141
  ```
89
142
 
143
+ This is approximately equivalent to checking the tldraw\.com "☰ → Edit → Export As → ☐ Transparent" menu item.
144
+
90
145
  ### Export to a specific destination
91
146
 
92
147
  ```sh
93
- npx @kitschpatrol/tldraw-cli your-drawing.tldr --output ~/Desktop
148
+ npx @kitschpatrol/tldraw-cli export your-drawing.tldr --output ~/Desktop
94
149
  ```
95
150
 
96
- Saves to `~/Desktop/your-drawing.svg`
151
+ Exports to `~/Desktop/your-drawing.svg`
97
152
 
98
153
  ### Export to a specific destination and filename
99
154
 
100
155
  ```sh
101
- npx @kitschpatrol/tldraw-cli your-drawing.tldr --output ~/Desktop --name not-your-drawing
156
+ npx @kitschpatrol/tldraw-cli export your-drawing.tldr --output ~/Desktop --name not-your-drawing
102
157
  ```
103
158
 
104
- Saves to `~/Desktop/not-your-drawing.svg`
159
+ Exports to `~/Desktop/not-your-drawing.svg`
105
160
 
106
- ### Export all frames from a single tldraw URL
161
+ ### Export all frames from a tldraw URL
107
162
 
108
163
  ```sh
109
- npx @kitschpatrol/tldraw-cli https://www.tldraw.com/s/v2_c_FI5RYWbdpAtjsy4OIKrKw --frames
164
+ npx @kitschpatrol/tldraw-cli export https://www.tldraw.com/s/v2_c_FI5RYWbdpAtjsy4OIKrKw --frames
110
165
  ```
111
166
 
112
- The saved files will be suffixed with their frame name, e.g.:
167
+ The exported files will be suffixed with their frame name, e.g.:
113
168
 
114
169
  `v2_c_FI5RYWbdpAtjsy4OIKrKw-frame-1.png`
115
170
  `v2_c_FI5RYWbdpAtjsy4OIKrKw-frame-2.png`
@@ -122,40 +177,61 @@ It's possible in tldraw to give multiple frames in a single sketch the same name
122
177
  ### Export a specific frame from a tldraw URL
123
178
 
124
179
  ```sh
125
- npx @kitschpatrol/tldraw-cli https://www.tldraw.com/s/v2_c_FI5RYWbdpAtjsy4OIKrKw --frames "Frame 1" "Frame 3"
180
+ npx @kitschpatrol/tldraw-cli export https://www.tldraw.com/s/v2_c_FI5RYWbdpAtjsy4OIKrKw --frames "Frame 1" "Frame 3"
126
181
  ```
127
182
 
183
+ ### Export to JSON
184
+
185
+ ```sh
186
+ npx @kitschpatrol/tldraw-cli export https://www.tldraw.com/s/v2_c_FI5RYWbdpAtjsy4OIKrKw --frames "Frame 1" "Frame 3"
187
+ ```
188
+
189
+ 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.
190
+
191
+ I'm not completely clear on the use-case for this format, but since tldr.com supports it, so too shall `tldraw-cli`.
192
+
193
+ ### Open a tldraw URL
194
+
195
+ ```sh
196
+ npx @kitschpatrol/tldraw-cli open https://www.tldraw.com/s/v2_c_FI5RYWbdpAtjsy4OIKrKw
197
+ ```
198
+
199
+ The remote sketch is copied to a locally-hosted instance of tldraw, which is then opened in your default browser.
200
+
128
201
  ## API usage
129
202
 
130
- The conversion tool's functionality is also exposed as a module for use in TypeScript or JavaScript Node projects.
203
+ The `export` command's functionality is also provided as a module for use in TypeScript or JavaScript Node projects.
131
204
 
132
205
  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
206
 
134
207
  ```ts
135
- tldrawToImage(
208
+ async function tldrawToImage(
136
209
  tldrPathOrUrl: string,
137
210
  {
138
211
  darkMode?: boolean
139
- output?: string
140
- format?: 'png' | 'svg'
212
+ format?: 'svg' | 'png' | 'json' | 'tldr'
141
213
  frames?: boolean | string[]
214
+ name?: string
215
+ output?: string
142
216
  stripStyle?: boolean
143
217
  transparent?: boolean
144
218
  verbose?: boolean
145
- }): Promise<string | string[]>;
219
+ }): Promise<string[]>;
146
220
  ```
147
221
 
148
- The function exports the image in the requested format returns the full path to the output image.
222
+ The function exports the image in the requested format returns an array of the output image(s) or file(s).
223
+
224
+ Generally, a single file is returned — but the `string[]` return type also accommodates invocations with `frame: true` where multiple images will be generated.
149
225
 
150
226
  Assuming you've installed `@kitschpatrol/tldraw-cli` locally in your project, it may be used as follows:
151
227
 
152
228
  ```ts
153
- // tldr-cli-api-test.ts
229
+ // tldraw-cli-api-test.ts
154
230
 
155
231
  import { tldrawToImage } from '@kitschpatrol/tldraw-cli'
156
232
 
157
233
  // Convert a local file to PNG
158
- const imagePath = await tldrawToImage('./some-file.tldr', { format: 'png', output: './' })
234
+ const [imagePath] = await tldrawToImage('./some-file.tldr', { format: 'png', output: './' })
159
235
  console.log(`Wrote image to: "${imagePath}"`)
160
236
 
161
237
  // Convert a remote tldraw URL to SVG
@@ -175,14 +251,14 @@ await tldrawToImage('https://www.tldraw.com/s/v2_c_FI5RYWbdpAtjsy4OIKrKw', {
175
251
  format: 'png',
176
252
  })
177
253
 
178
- // You can also use the frame id instead of name, if you're into that sort of thing
254
+ // You can also use the frame id instead of the frame name, if you're into that sort of thing
179
255
  // It will work with or without the `shape:` prefix
180
256
  await tldrawToImage('https://www.tldraw.com/s/v2_c_FI5RYWbdpAtjsy4OIKrKw', {
181
257
  frames: ['shape:x8z3Qf7Hgw4Qqp2AC-eet'],
182
258
  })
183
259
  ```
184
260
 
185
- _Note that the library provided is ESM only, and requires a Node-compatible runtime. TypeScript type definitions are included._
261
+ _Note that the library provided is ESM-only, and requires a Node-compatible runtime. TypeScript type definitions are included._
186
262
 
187
263
  ## Background
188
264
 
@@ -202,9 +278,11 @@ On Discord:
202
278
 
203
279
  ## Implementation notes
204
280
 
281
+ 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.\_
282
+
205
283
  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 [Puppeteer](https://pptr.dev).
206
284
 
207
- This can be a bit slow, (exporting seems to take a second or two), but in the context of a content pipeline it's not the end of the world.
285
+ 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.
208
286
 
209
287
  In terms of Puppeteer vs. Playwright and other headless browser automation tools, it [looks like](https://www.checklyhq.com/blog/puppeteer-vs-selenium-vs-playwright-speed-comparison/) Puppeteer's performance likely compares favorably. (Though I have not tested and benchmarked the alternatives in the specific context of `tldraw-cli`.)
210
288
 
@@ -214,6 +292,7 @@ The local instance of tldraw includes its assets dependencies, so the tool shoul
214
292
 
215
293
  This is a very minimal implementation. Current plans for future improvements include the following:
216
294
 
295
+ - Add save button to local tldraw
217
296
  - Add CLI tests
218
297
  - Implement the ability to export specific pages as separate image files
219
298
  - Add an option flag to set dpi when exporting to a bitmap format