tsquare 0.2.0 → 0.3.1

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 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:** 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 runs on a local server with the same renderer as the CLI. In this repo, `npm run playground` runs it from source.
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% | 85% |
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
- icon: z.ZodOptional<z.ZodNullable<z.ZodString>>;
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
- icon: z.ZodOptional<z.ZodNullable<z.ZodString>>;
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
- leading: string;
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
- icon: z.ZodOptional<z.ZodNullable<z.ZodString>>;
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
- icon: z.ZodOptional<z.ZodNullable<z.ZodString>>;
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
- leading: string;
969
- icon: string;
969
+ leadingIcon: string;
970
970
  trailing: string;
971
971
  };
972
972
  };
@@ -1019,3 +1019,19 @@ 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
+ };