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.
- package/README.md +34 -8
- package/assets/mark.png +0 -0
- package/bin/tsquare.js +2 -6
- package/dist/catalog.d.ts +1055 -0
- package/dist/chunks/chunk-46MGJLGB.js +2126 -0
- package/{src/cli.ts → dist/cli.js} +28 -24
- package/dist/colors.d.ts +29 -0
- package/dist/compile.d.ts +24 -0
- package/dist/components.d.ts +83 -0
- package/dist/icons.d.ts +12 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +54 -0
- package/dist/layout.d.ts +66 -0
- package/dist/playground/index.d.ts +38 -0
- package/dist/playground/index.html +325 -0
- package/dist/playground/index.js +466 -0
- package/dist/playground/language-data.d.ts +28 -0
- package/dist/playground/playground.js +47 -0
- package/dist/playground/reference.d.ts +11 -0
- package/dist/print.d.ts +2 -0
- package/dist/prompt-example.d.ts +3 -0
- package/dist/prompt.d.ts +22 -0
- package/dist/render.d.ts +40 -0
- package/dist/schema.d.ts +33 -0
- package/dist/share.d.ts +4 -0
- package/dist/suggest.d.ts +5 -0
- package/dist/text.d.ts +50 -0
- package/examples/checkout.tsq +15 -0
- package/examples/dashboard.tsq +27 -0
- package/examples/notes-mobile.tsq +84 -0
- package/examples/notes-web.tsq +54 -0
- package/examples/sign-in.tsq +14 -0
- package/examples/states.tsq +16 -0
- package/package.json +31 -7
- package/skill/tsquare/SKILL.md +5 -4
- package/skill/tsquare/reference.md +7 -6
- package/src/catalog.ts +0 -329
- package/src/colors.ts +0 -82
- package/src/compile.ts +0 -64
- package/src/components.tsx +0 -1057
- package/src/icons.ts +0 -54
- package/src/index.ts +0 -11
- package/src/layout.ts +0 -63
- package/src/print.ts +0 -73
- package/src/prompt-example.ts +0 -43
- package/src/prompt.ts +0 -121
- package/src/render.ts +0 -178
- package/src/schema.ts +0 -43
- package/src/suggest.ts +0 -34
- 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
|
-
|
|
34
|
+
npx tsquare playground # http://localhost:4321
|
|
33
35
|
```
|
|
34
36
|
|
|
35
|
-
- **Editor:**
|
|
36
|
-
- **
|
|
37
|
-
- **
|
|
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
|
+

|
|
51
|
+
```
|
|
38
52
|
|
|
39
|
-
|
|
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
|
|
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% |
|
|
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
|
|
package/assets/mark.png
ADDED
|
Binary file
|
package/bin/tsquare.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
//
|
|
3
|
-
|
|
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";
|