tsquare 0.2.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 +20 -6
- package/dist/catalog.d.ts +42 -8
- package/dist/chunks/{chunk-L6GTIZQH.js → chunk-46MGJLGB.js} +256 -159
- package/dist/cli.js +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +17 -1
- package/dist/playground/index.d.ts +12 -1
- package/dist/playground/index.html +180 -356
- package/dist/playground/index.js +100 -10
- package/dist/playground/language-data.d.ts +28 -0
- package/dist/playground/playground.js +47 -0
- package/dist/prompt.d.ts +1 -1
- package/dist/render.d.ts +21 -1
- package/dist/share.d.ts +4 -0
- package/dist/text.d.ts +6 -1
- package/examples/checkout.tsq +15 -0
- package/examples/dashboard.tsq +27 -0
- package/examples/notes-mobile.tsq +9 -9
- package/examples/notes-web.tsq +6 -6
- package/examples/sign-in.tsq +14 -0
- package/examples/states.tsq +16 -0
- package/package.json +9 -1
- package/skill/tsquare/SKILL.md +3 -2
- package/skill/tsquare/reference.md +5 -4
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
|
|
|
@@ -136,7 +150,7 @@ How often models write valid tsquare on the first try, with no repair round:
|
|
|
136
150
|
|
|
137
151
|
| | Sonnet | Haiku |
|
|
138
152
|
|---|---|---|
|
|
139
|
-
| Valid on the first try (20 requests) | 100% |
|
|
153
|
+
| Valid on the first try (20 requests) | 100% | 80% |
|
|
140
154
|
| Median tokens per wireframe (JSON took about 4× as many) | 184 | 210 |
|
|
141
155
|
| Color checks passed (7 requests) | 11/11 | 11/11 |
|
|
142
156
|
|
package/dist/catalog.d.ts
CHANGED
|
@@ -264,7 +264,8 @@ export declare const componentDefinitions: {
|
|
|
264
264
|
md: "md";
|
|
265
265
|
sm: "sm";
|
|
266
266
|
}>>>;
|
|
267
|
-
|
|
267
|
+
leadingIcon: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
268
|
+
trailingIcon: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
268
269
|
fullWidth: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
269
270
|
}, z.core.$strip>;
|
|
270
271
|
slots: never[];
|
|
@@ -425,7 +426,7 @@ export declare const componentDefinitions: {
|
|
|
425
426
|
image: "image";
|
|
426
427
|
none: "none";
|
|
427
428
|
}>>>;
|
|
428
|
-
|
|
429
|
+
leadingIcon: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
429
430
|
trailing: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
430
431
|
badge: "badge";
|
|
431
432
|
chevron: "chevron";
|
|
@@ -442,8 +443,7 @@ export declare const componentDefinitions: {
|
|
|
442
443
|
example: {
|
|
443
444
|
title: string;
|
|
444
445
|
subtitle: string;
|
|
445
|
-
|
|
446
|
-
icon: string;
|
|
446
|
+
leadingIcon: string;
|
|
447
447
|
trailing: string;
|
|
448
448
|
};
|
|
449
449
|
};
|
|
@@ -787,7 +787,8 @@ export declare const catalog: import("@json-render/core").Catalog<{
|
|
|
787
787
|
md: "md";
|
|
788
788
|
sm: "sm";
|
|
789
789
|
}>>>;
|
|
790
|
-
|
|
790
|
+
leadingIcon: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
791
|
+
trailingIcon: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
791
792
|
fullWidth: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
792
793
|
}, z.core.$strip>;
|
|
793
794
|
slots: never[];
|
|
@@ -948,7 +949,7 @@ export declare const catalog: import("@json-render/core").Catalog<{
|
|
|
948
949
|
image: "image";
|
|
949
950
|
none: "none";
|
|
950
951
|
}>>>;
|
|
951
|
-
|
|
952
|
+
leadingIcon: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
952
953
|
trailing: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
953
954
|
badge: "badge";
|
|
954
955
|
chevron: "chevron";
|
|
@@ -965,8 +966,7 @@ export declare const catalog: import("@json-render/core").Catalog<{
|
|
|
965
966
|
example: {
|
|
966
967
|
title: string;
|
|
967
968
|
subtitle: string;
|
|
968
|
-
|
|
969
|
-
icon: string;
|
|
969
|
+
leadingIcon: string;
|
|
970
970
|
trailing: string;
|
|
971
971
|
};
|
|
972
972
|
};
|
|
@@ -1019,3 +1019,37 @@ export declare const catalog: import("@json-render/core").Catalog<{
|
|
|
1019
1019
|
};
|
|
1020
1020
|
}>;
|
|
1021
1021
|
export type ComponentName = keyof typeof componentDefinitions;
|
|
1022
|
+
/**
|
|
1023
|
+
* A ListItem's effective leading and trailing kinds. Setting the value implies
|
|
1024
|
+
* the kind (leadingIcon → leading=icon, trailingIcon → trailing=icon,
|
|
1025
|
+
* trailingText → trailing=text), so writing only the value still shows it.
|
|
1026
|
+
* The renderer and checkSpec both use this, so they can't disagree.
|
|
1027
|
+
*/
|
|
1028
|
+
export declare function listItemEnds(p: {
|
|
1029
|
+
leading?: string | null;
|
|
1030
|
+
leadingIcon?: string | null;
|
|
1031
|
+
trailing?: string | null;
|
|
1032
|
+
trailingIcon?: string | null;
|
|
1033
|
+
trailingText?: string | null;
|
|
1034
|
+
}): {
|
|
1035
|
+
leading: string | undefined;
|
|
1036
|
+
trailing: string | undefined;
|
|
1037
|
+
};
|
|
1038
|
+
/**
|
|
1039
|
+
* Props renamed in 0.3.0, still accepted under their old names so existing
|
|
1040
|
+
* wireframes and render URLs keep working. The prompt, docs and autocomplete
|
|
1041
|
+
* only teach the new names, and `tsquare fmt` rewrites the old ones.
|
|
1042
|
+
*/
|
|
1043
|
+
export declare const RENAMED_PROPS: Record<string, Record<string, string>>;
|
|
1044
|
+
/** Rewrites renamed props to their current names, in place. Safe to call more than once. */
|
|
1045
|
+
export declare function upgradeRenamedProps(spec: {
|
|
1046
|
+
elements: Record<string, {
|
|
1047
|
+
type: string;
|
|
1048
|
+
props?: Record<string, unknown>;
|
|
1049
|
+
}>;
|
|
1050
|
+
}): {
|
|
1051
|
+
elements: Record<string, {
|
|
1052
|
+
type: string;
|
|
1053
|
+
props?: Record<string, unknown>;
|
|
1054
|
+
}>;
|
|
1055
|
+
};
|