tsquare 0.1.0 → 0.3.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 (50) hide show
  1. package/README.md +34 -8
  2. package/assets/mark.png +0 -0
  3. package/bin/tsquare.js +2 -6
  4. package/dist/catalog.d.ts +1055 -0
  5. package/dist/chunks/chunk-46MGJLGB.js +2126 -0
  6. package/{src/cli.ts → dist/cli.js} +28 -24
  7. package/dist/colors.d.ts +29 -0
  8. package/dist/compile.d.ts +24 -0
  9. package/dist/components.d.ts +83 -0
  10. package/dist/icons.d.ts +12 -0
  11. package/dist/index.d.ts +10 -0
  12. package/dist/index.js +54 -0
  13. package/dist/layout.d.ts +66 -0
  14. package/dist/playground/index.d.ts +38 -0
  15. package/dist/playground/index.html +325 -0
  16. package/dist/playground/index.js +466 -0
  17. package/dist/playground/language-data.d.ts +28 -0
  18. package/dist/playground/playground.js +47 -0
  19. package/dist/playground/reference.d.ts +11 -0
  20. package/dist/print.d.ts +2 -0
  21. package/dist/prompt-example.d.ts +3 -0
  22. package/dist/prompt.d.ts +22 -0
  23. package/dist/render.d.ts +40 -0
  24. package/dist/schema.d.ts +33 -0
  25. package/dist/share.d.ts +4 -0
  26. package/dist/suggest.d.ts +5 -0
  27. package/dist/text.d.ts +50 -0
  28. package/examples/checkout.tsq +15 -0
  29. package/examples/dashboard.tsq +27 -0
  30. package/examples/notes-mobile.tsq +84 -0
  31. package/examples/notes-web.tsq +54 -0
  32. package/examples/sign-in.tsq +14 -0
  33. package/examples/states.tsq +16 -0
  34. package/package.json +31 -7
  35. package/skill/tsquare/SKILL.md +5 -4
  36. package/skill/tsquare/reference.md +7 -6
  37. package/src/catalog.ts +0 -329
  38. package/src/colors.ts +0 -82
  39. package/src/compile.ts +0 -64
  40. package/src/components.tsx +0 -1057
  41. package/src/icons.ts +0 -54
  42. package/src/index.ts +0 -11
  43. package/src/layout.ts +0 -63
  44. package/src/print.ts +0 -73
  45. package/src/prompt-example.ts +0 -43
  46. package/src/prompt.ts +0 -121
  47. package/src/render.ts +0 -178
  48. package/src/schema.ts +0 -43
  49. package/src/suggest.ts +0 -34
  50. package/src/text.ts +0 -333
package/README.md CHANGED
@@ -28,15 +28,29 @@ Requires Node 20 or newer. To work on tsquare itself, clone the repo, run `npm i
28
28
 
29
29
  ## Playground
30
30
 
31
+ Online at [tsquare.dev/playground](https://tsquare.dev/playground), or locally:
32
+
31
33
  ```bash
32
- npm run playground # http://localhost:4321
34
+ npx tsquare playground # http://localhost:4321
33
35
  ```
34
36
 
35
- - **Editor:** live render as you type, problems listed by line (click one to jump there), and SVG/PNG export. Paste a whole model reply and it keeps just the code block.
36
- - **Components:** every component with its props and a rendered example you can open in the editor. It's generated from the catalog, so it can't drift from what the renderer accepts.
37
- - **Prompt:** the system prompt for models, with a copy button.
37
+ - **Editor:** syntax highlighting, autocomplete for components, options, props, icons and colors, and problems underlined by line. Paste a whole model reply and it keeps just the code block.
38
+ - **Preview:** renders as you type. Zoom and pan (⌘/Ctrl + scroll or pinch), jump to a single screen, or go full screen.
39
+ - **Links:** copy a share link that reopens the wireframe in the playground, or an image link (SVG, PNG, Markdown, HTML) to embed it anywhere.
40
+ - **Examples** with thumbnails, **light and dark** themes, a resizable split, and SVG/PNG export.
41
+ - **Components:** every component with its props and a rendered example. **Prompt:** the system prompt for models, with a copy button.
42
+
43
+ The local playground uses the same renderer as the CLI; its links point to tsquare.dev. In this repo, `npm run playground` runs it from source.
44
+
45
+ ## Image links
46
+
47
+ A wireframe can be embedded anywhere an image works (Notion, GitHub, docs sites) with a link that contains the wireframe itself:
48
+
49
+ ```markdown
50
+ ![Login](https://tsquare.dev/svg/zNYwxDsIwEAT7vGJ…)
51
+ ```
38
52
 
39
- It renders on a local Node server using the same code as the CLI.
53
+ The playground's **Copy link** menu makes these. The text is compressed into the URL, not encrypted, so anyone with the link can read it; see [privacy](https://tsquare.dev/privacy). `encodeWireframe` and `decodeWireframe` in the library produce and read the same links.
40
54
 
41
55
  ## The language
42
56
 
@@ -51,7 +65,7 @@ One element per line; children are indented two spaces under their parent. The f
51
65
  | `tabs items=[All notes, Pinned]` | lists in `[ ]`, items separated by commas; an item can contain spaces |
52
66
  | `data=[["$1,200", "Smith, J"]]` | quote an item that contains a comma (`\"` for a quote inside quotes) |
53
67
  | `tabbar items=[{label=Home icon=home}]` | objects in `{ }` |
54
- | `# note to self` | comment |
68
+ | `# note to self` | a comment, on its own line only; elsewhere `#` is text (`[#1001, #1002]`) |
55
69
 
56
70
  If a bare word could mean two props (for example `start`, which is both an `align` and a `justify` value), write it as `key=value`. Code fences (```` ``` ````) are ignored, so a model's reply can be rendered as-is.
57
71
 
@@ -95,13 +109,25 @@ tsquare render <file.tsq|-> [-o out.svg|out.png] [--scale 2]
95
109
  tsquare check <file.tsq|-> # problems by line number
96
110
  tsquare fmt <file.tsq|-> [-w] # canonical formatting (drops comments)
97
111
  tsquare prompt # system prompt for models
112
+ tsquare playground [--port 4321] # live editor, component reference, prompt
98
113
  ```
99
114
 
100
115
  Use `-` to read from stdin. In this repo, run them through npm: `npm run check -- file.tsq`. Files use the `.tsq` extension; the CLI reads any text file.
101
116
 
117
+ ## Library
118
+
119
+ ```ts
120
+ import { renderWireframe, compileWireframe, formatIssues } from "tsquare";
121
+
122
+ const { issues } = compileWireframe(source); // problems by line, empty when valid
123
+ const png = await renderWireframe(source, { format: "png", scale: 2 });
124
+ ```
125
+
126
+ `tsquare/playground` exports the playground's request handler, for hosting it inside your own Node server. See [Using it with AI](docs/ai.md) for the prompt and the repair loop.
127
+
102
128
  ## Using it with Claude (skill)
103
129
 
104
- `skill/tsquare/` is a Claude skill: the syntax, the component reference, and a workflow of write → `tsquare check` → `tsquare render` → look at the PNG and fix. Copy it to `~/.claude/skills/tsquare` (all projects) or `<project>/.claude/skills/tsquare`, and make the `tsquare` command available (`npm link` in this repo). Rebuild it after catalog changes with `npm run skill`.
130
+ `skill/tsquare/` is a Claude skill: the syntax, the component reference, and a workflow of write → `tsquare check` → `tsquare render` → look at the PNG and fix. Copy it to `~/.claude/skills/tsquare` (all projects) or `<project>/.claude/skills/tsquare`, and make sure `npx tsquare` runs where Claude works. Rebuild it after catalog changes with `npm run skill`.
105
131
 
106
132
  ## How it works
107
133
 
@@ -124,7 +150,7 @@ How often models write valid tsquare on the first try, with no repair round:
124
150
 
125
151
  | | Sonnet | Haiku |
126
152
  |---|---|---|
127
- | Valid on the first try (20 requests) | 100% | 85% |
153
+ | Valid on the first try (20 requests) | 100% | 80% |
128
154
  | Median tokens per wireframe (JSON took about 4× as many) | 184 | 210 |
129
155
  | Color checks passed (7 requests) | 11/11 | 11/11 |
130
156
 
Binary file
package/bin/tsquare.js CHANGED
@@ -1,7 +1,3 @@
1
1
  #!/usr/bin/env node
2
- // The CLI is TypeScript (with JSX components); tsx loads it at runtime so
3
- // `npm link` and `npx tsquare` work without a build step.
4
- import { register } from "tsx/esm/api";
5
-
6
- register();
7
- await import("../src/cli.ts");
2
+ // Runs the built CLI (npm run build writes dist/).
3
+ import "../dist/cli.js";