@kitschpatrol/tldraw-cli 4.5.4 → 4.6.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.
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="30" height="30" fill="none"><path stroke="#1D1D1D" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2 10.118C2 .954 14.025.954 15 8.31c.975-7.355 13-7.355 13 1.81C28 17.955 18.25 20.97 15 27c-3.25-6.03-13-9.044-13-16.882"/></svg>
@@ -64,6 +64,7 @@
64
64
  "geo-cloud",
65
65
  "geo-diamond",
66
66
  "geo-ellipse",
67
+ "geo-heart",
67
68
  "geo-hexagon",
68
69
  "geo-octagon",
69
70
  "geo-oval",
@@ -102,6 +103,8 @@
102
103
  "size-large",
103
104
  "size-medium",
104
105
  "size-small",
106
+ "spline-cubic",
107
+ "spline-line",
105
108
  "stack-horizontal",
106
109
  "stack-vertical",
107
110
  "stretch-horizontal",
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="30" height="30" fill="none"><path stroke="#000" stroke-linecap="round" stroke-width="2" d="M6 6v2c0 5.6 0 8.4 1.09 10.54a10 10 0 0 0 4.37 4.37C13.6 24 16.4 24 22 24h2"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="30" height="30" fill="none"><path stroke="#000" stroke-linecap="round" stroke-width="2" d="M6 6v18h18"/></svg>
@@ -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-DGC_26df.js"></script>
7
+ <script type="module" crossorigin src="/assets/index-Bn7aCEFI.js"></script>
8
8
  <link rel="stylesheet" crossorigin href="/assets/index-BlBRI8VA.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.5.4",
3
+ "version": "4.6.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": {
@@ -20,7 +20,7 @@
20
20
  "license": "MIT",
21
21
  "engines": {
22
22
  "node": ">=18.0.0",
23
- "pnpm": ">=8.0.0"
23
+ "pnpm": ">=9.0.0"
24
24
  },
25
25
  "bin": {
26
26
  "tldraw-cli": "bin/cli.js",
@@ -51,9 +51,9 @@
51
51
  "yargs": "^17.7.2"
52
52
  },
53
53
  "devDependencies": {
54
- "@kitschpatrol/shared-config": "^4.6.6",
54
+ "@kitschpatrol/shared-config": "^4.7.1",
55
55
  "@sindresorhus/slugify": "^2.2.1",
56
- "@tldraw/assets": "2.2.0-canary.ebc892a1a6b8",
56
+ "@tldraw/assets": "2.2.0-canary.e474f51745ec",
57
57
  "@types/express": "^4.17.21",
58
58
  "@types/react": "^18.3.3",
59
59
  "@types/react-dom": "^18.3.0",
@@ -62,7 +62,7 @@
62
62
  "bumpp": "^9.4.1",
63
63
  "chalk": "^5.3.0",
64
64
  "cheerio": "1.0.0-rc.12",
65
- "esbuild": "^0.21.4",
65
+ "esbuild": "^0.21.5",
66
66
  "eslint-plugin-react-hooks": "^4.6.2",
67
67
  "eslint-plugin-react-refresh": "^0.4.7",
68
68
  "get-port": "^7.1.0",
@@ -77,11 +77,11 @@
77
77
  "sharp": "^0.33.4",
78
78
  "sharp-phash": "^2.1.0",
79
79
  "strip-ansi": "^7.1.0",
80
- "tldraw": "2.2.0-canary.ebc892a1a6b8",
81
- "tsx": "^4.11.0",
80
+ "tldraw": "2.2.0-canary.e474f51745ec",
81
+ "tsx": "^4.15.1",
82
82
  "typescript": "^5.4.5",
83
83
  "untildify": "^5.0.0",
84
- "vite": "^5.2.11",
84
+ "vite": "^5.2.13",
85
85
  "vitest": "^1.6.0"
86
86
  },
87
87
  "publishConfig": {
@@ -92,16 +92,16 @@
92
92
  "build:cli": "tsx ./scripts/build-cli.ts",
93
93
  "build:lib": "tsx ./scripts/build-lib.ts && tsc -p tsconfig.lib.json",
94
94
  "build:tldraw": "pnpm run tldraw:copy-assets && vite build",
95
- "clean": "git clean -fdX",
95
+ "clean": "git clean -fdX && rm -f pnpm-lock.yaml",
96
96
  "dev": "pnpm run dev:tldraw",
97
97
  "dev:tldraw": "pnpm run tldraw:copy-assets && vite",
98
98
  "fix": "shared-config --fix",
99
99
  "lint": "shared-config --lint",
100
100
  "preview": "pnpm run preview:tldraw",
101
101
  "preview:tldraw": "vite preview",
102
- "release": "pnpm run build && pnpm bumpp --commit 'Release: %s' && pnpm publish --otp $(op read 'op://Personal/Npmjs/one-time password?attribute=otp')",
103
- "test": "pnpm run test:lib",
104
- "test:lib": "pnpm run build && vitest",
102
+ "release": "pnpm bumpp --commit 'Release: %s' && pnpm build && pnpm publish --otp $(op read 'op://Personal/Npmjs/one-time password?attribute=otp')",
103
+ "test": "vitest --run",
104
+ "test:watch": "pnpm run build && vitest",
105
105
  "tldraw:copy-assets": "rsync -av --include='/*/' --exclude='/*' --exclude='favicon.ico' ./node_modules/@tldraw/assets/ ./src/tldraw/public/"
106
106
  }
107
107
  }
package/readme.md CHANGED
@@ -88,10 +88,10 @@ Usage:
88
88
  tldraw <command>
89
89
  ```
90
90
 
91
- | Command | Argument | Description |
92
- | -------- | ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
93
- | `export` | `<files-or-urls..>` | Export a local tldraw ".tldr" file or a tldraw\.com URL to an svg, png, json, or tldr file. Prints the absolute path(s) to the exported image(s) to stdout. |
94
- | `open` | `[files-or-urls..]` | Open a tldraw `.tldr` file or tldraw\.com URL in your default browser with either the official tldraw\.com site or a locally-hosted instance of the editor. Call `open` without an argument to open a blank sketch. Sketches opened via URL with the `--local` flag will be temporarily copied to the local system, and will not be kept in sync with tldraw\.com. This process does not exit until the browser is closed. |
91
+ | Command | Argument | Description |
92
+ | -------- | ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
93
+ | `export` | `<files-or-urls..>` | Export a local tldraw ".tldr" file or a tldraw\.com URL to an svg, png, json, or tldr file. Prints the absolute path(s) to the exported image(s) to stdout. |
94
+ | `open` | `[files-or-urls..]` | Open a tldraw `.tldr` file or tldraw\.com URL in your default browser with either the official tldraw\.com site or a locally-hosted instance of the editor. Call `open` without an argument to open a blank sketch. Sketches opened via URL with the `--local` flag will be temporarily copied to the local system, and will not be kept in sync with tldraw\.com. This process does not exit until the browser is closed. Warning: Passing a local .tldr file without the `--local` option will upload and share the sketch on tldraw\.com. |
95
95
 
96
96
  | Option | Alias | Description | Type |
97
97
  | ----------- | ----- | ------------------- | --------- |
@@ -133,7 +133,7 @@ tldraw export <files-or-urls..>
133
133
 
134
134
  #### Subcommand: `tldraw open`
135
135
 
136
- Open a tldraw `.tldr` file or tldraw\.com URL in your default browser with either the official tldraw\.com site or a locally-hosted instance of the editor. Call `open` without an argument to open a blank sketch. Sketches opened via URL with the `--local` flag will be temporarily copied to the local system, and will not be kept in sync with tldraw\.com. This process does not exit until the browser is closed.
136
+ Open a tldraw `.tldr` file or tldraw\.com URL in your default browser with either the official tldraw\.com site or a locally-hosted instance of the editor. Call `open` without an argument to open a blank sketch. Sketches opened via URL with the `--local` flag will be temporarily copied to the local system, and will not be kept in sync with tldraw\.com. This process does not exit until the browser is closed. Warning: Passing a local .tldr file without the `--local` option will upload and share the sketch on tldraw\.com.
137
137
 
138
138
  Usage:
139
139
 
@@ -290,9 +290,15 @@ The remote sketch is copied to a locally-hosted instance of tldraw, which is the
290
290
 
291
291
  ### API
292
292
 
293
- The `export` command's functionality is also provided in module form for use in TypeScript or JavaScript Node projects.
293
+ The `tldraw-cli` command line functionality is also provided in module form for programmatic use in TypeScript or JavaScript Node projects.
294
294
 
295
- 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:
295
+ The library exports two async function, `tldrawToImage`, and `tldrawOpen`.
296
+
297
+ #### `tldrawToImage`
298
+
299
+ This mirrors the `tldraw export` CLI command.
300
+
301
+ It takes an options argument mirroring the arguments available via the command line. The same default values apply:
296
302
 
297
303
  ```ts
298
304
  async function tldrawToImage(
@@ -367,7 +373,63 @@ log.verbose = false
367
373
  await tldrawToImage('https://www.tldraw.com/s/v2_c_JsxJk8dag6QsrqExukis4')
368
374
  ```
369
375
 
370
- _Note that the library provided is ESM-only, and requires a Node-compatible runtime. TypeScript type definitions are included._
376
+ #### `tldrawOpen`
377
+
378
+ Mirrors the `tldraw open` CLI command.
379
+
380
+ > \[!CAUTION]
381
+ > Passing a local .tldr file with the `location: 'remote'` option will upload and share your sketch on tldraw\.com.
382
+
383
+ ```tsx
384
+ async function tldrawOpen(
385
+ tldrPathOrUrl?: string,
386
+ options?: Partial<{
387
+ location: 'local' | 'remote'
388
+ }>,
389
+ ): Promise<{
390
+ browserExitPromise: Promise<ChildProcess>
391
+ openedSketchUrl: string
392
+ }>
393
+ ```
394
+
395
+ It's important to note that the returned result includes `browserExitPromise`, which resolves when the user has completely exited the web browser used to open the tldr file or url.
396
+
397
+ You _must_ await the `browserExitPromise` (or somehow keep script's process alive) if you're opening a tldr file with the \`location: 'local'\`. This prevents the local server from closing prematurely, which would interfere with any server-dependent actions in tldraw.
398
+
399
+ Example of opening a local file:
400
+
401
+ ```ts
402
+ import { tldrawOpen } from 'tldraw-cli'
403
+
404
+ const { browserExitPromise } = await tldrawOpen('./sketch.tldr', {
405
+ location: 'local',
406
+ })
407
+
408
+ // Wait for the browser to close to keep
409
+ // the local tldraw instance running!
410
+ await browserExitPromise
411
+ ```
412
+
413
+ While opening the file remotely on tldraw\.com is more casual:
414
+
415
+ ```ts
416
+ import { tldrawOpen } from 'tldraw-cli'
417
+
418
+ await tldrawOpen('./sketch.tldr', {
419
+ location: 'remote',
420
+ })
421
+ ```
422
+
423
+ #### `tldrawToShareUrl`
424
+
425
+ ```ts
426
+ async function tldrawToShareUrl(tldrPathOrUrl: string): Promise<string>
427
+ ```
428
+
429
+ Returns a live "share" url for a given local or remote tldraw sketch URL.
430
+
431
+ > \[!CAUTION]
432
+ > Passing a local .tldr file to this function will upload and share your local file to tldraw\.com.
371
433
 
372
434
  ## Background
373
435