tsquare 0.5.0 → 0.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.
package/dist/prompt.d.ts CHANGED
@@ -13,7 +13,7 @@ export declare function componentDocs(): {
13
13
  props: PropDoc[];
14
14
  }[];
15
15
  export declare function componentReference(): string;
16
- export declare const RULES = "## Rules\n1. The top element is a Board. The Board's children are Screens, plus optional Notes beside them.\n2. Each Screen is one view of the product. Use several Screens to show several views or states.\n3. A Screen lays out its children top to bottom. Use Stack (direction row or column) and Grid to arrange content.\n4. NavBar is pinned to the top of its Screen and TabBar to the bottom.\n5. Modal, Drawer and Toast are overlays. They must be direct children of a Screen.\n6. This is a low-fidelity wireframe. Prefer placeholders (Image boxes, Text with lines) over invented copy unless the copy matters.\n7. Only use the components and props listed below. All props are optional unless marked required.\n8. Wireframes are grayscale. The only UI colors: Board accent (one color for primary buttons, checked controls, toggles, active tabs and ghost buttons), Badge tone (success, warning, danger) and Input error. Only add an accent if the request asks for color or a brand.\n9. Any element except Board, Screen and Note can take tooltip=\"text\" to show a tooltip next to it. Select (with options), Input type=date, and Button, ListItem or NavBar (with menu) take open to show their list, calendar or menu over the screen.";
16
+ export declare const RULES = "## Rules\n1. The top element is a Board. The Board's children are Screens, plus optional Notes beside them and Flow lines after them (rule 10).\n2. Each Screen is one view of the product. Use several Screens to show several views or states.\n3. A Screen lays out its children top to bottom. Use Stack (direction row or column) and Grid to arrange content.\n4. NavBar is pinned to the top of its Screen and TabBar to the bottom.\n5. Modal, Drawer and Toast are overlays. They must be direct children of a Screen.\n6. This is a low-fidelity wireframe. Prefer placeholders (Image boxes, Text with lines) over invented copy unless the copy matters.\n7. Only use the components and props listed below. All props are optional unless marked required.\n8. Wireframes are grayscale. The only UI colors: Board accent (one color for primary buttons, checked controls, toggles, active tabs and ghost buttons), Badge tone (success, warning, danger), Input error and Flow color. Only add an accent if the request asks for color or a brand.\n9. Any element except Board, Screen, Note and Flow can take tooltip=\"text\" to show a tooltip next to it. Select (with options), Input type=date, and Button, ListItem or NavBar (with menu) take open to show their list, calendar or menu over the screen.\n10. To show how screens connect, name elements or screens by writing #name after them (button primary \"Sign in\" #signin, screen phone \"Home\" #home), then add board-level lines after the screens: flow signin -> home \"Tap Sign in\".";
17
17
  export declare const TEXT_FORMAT = "## Output format: wireframe text\nOne element per line. Indent children two spaces under their parent. The first line is the board.\n\nA line is the component name in lowercase, followed by arguments separated by spaces:\n- \"a quoted string\" sets the component's main text prop (marked \"main text\" below)\n- a bare word that is one of the component's option values sets that option: phone, desktop, primary, ghost, row, sm, left, bottom, password, \u2026\n- a bare prop name sets that component's yes/no prop to true, only on components that have it (see each component's props below): checked (checkbox, radio), fullWidth (button), muted (text), grow (stack, card, input, list). `off` and `unchecked` set on/checked to false\n- key=value sets any prop. Values: \"string\", number, true/false, bare word, [list, of, values], {key=value key=value}\n\nComments: a line that starts with # is a comment. A comment must be on its own line, never after an element on the same line. Anywhere else, # is ordinary text: [#1001, #1002], \"Order #12345\", accent=#1a73e8.\n\nLists: items are separated by commas, and an item can contain spaces without quotes: [All notes, Pinned, Shared]. To put a comma inside an item, quote the item: [\"$1,200\", \"Smith, J\"]. Inside quotes, write \\\" for a quote character. Numbers in a list of text are fine: [2023, 2024].\n\nIf a bare word could mean more than one prop, write it as key=value.";
18
18
  export declare const EXAMPLE_REQUEST = "Two phone screens for a recipe app: a browse screen with search, category tabs, a grid of recipe cards and a tab bar; and a recipe detail screen with its options sheet open.";
19
19
  /** The system prompt for writing wireframe text. */
package/dist/render.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { Spec } from "@json-render/core";
2
+ import { type Anchor, type Rect } from "./anchors.js";
2
3
  export declare class SpecError extends Error {
3
4
  issues: string[];
4
5
  constructor(issues: string[]);
@@ -20,33 +21,35 @@ export interface BoardItem {
20
21
  * front) and each screen's and note's box, laid out in rows exactly as the
21
22
  * Board component does.
22
23
  */
23
- export declare function boardLayout(spec: Spec): {
24
+ export declare function boardLayout(spec: Spec, opts?: {
25
+ flows?: boolean;
26
+ }): {
24
27
  width: number;
25
28
  height: number;
26
29
  items: BoardItem[];
30
+ gap: number;
27
31
  };
28
32
  /** The canvas size for a board. */
29
- export declare function boardSize(spec: Spec): {
33
+ export declare function boardSize(spec: Spec, opts?: {
34
+ flows?: boolean;
35
+ }): {
30
36
  width: number;
31
37
  height: number;
32
38
  };
33
39
  export interface RenderWireframeOptions {
34
40
  /** Skip validation (e.g. while a spec is still streaming in). */
35
41
  skipValidation?: boolean;
42
+ /** Draw flow arrows (default true). Off, the board looks exactly as if it had no flow lines. */
43
+ flows?: boolean;
36
44
  }
37
45
  export declare function renderWireframeSvg(spec: Spec, opts?: RenderWireframeOptions): Promise<string>;
38
46
  /**
39
47
  * The measuring pass: the board's anchored elements (and their screens) and their boxes on the
40
48
  * canvas, keyed by element id (`<id>#field` for a field). No render at all when there are none.
41
49
  */
42
- export declare function measureAnchors(spec: Spec): Promise<{
43
- anchors: import("./anchors.js").Anchor[];
44
- boxes: Record<string, {
45
- x: number;
46
- y: number;
47
- w: number;
48
- h: number;
49
- }>;
50
+ export declare function measureAnchors(spec: Spec, extra?: string[]): Promise<{
51
+ anchors: Anchor[];
52
+ boxes: Record<string, Rect>;
50
53
  }>;
51
54
  export declare function renderWireframePng(spec: Spec, opts?: RenderWireframeOptions & {
52
55
  scale?: number;
package/dist/upgrade.d.ts CHANGED
@@ -20,7 +20,7 @@
20
20
  /** Props renamed in 0.3.0. The prompt, docs and autocomplete only teach the new names; `tsquare fmt` rewrites old ones. */
21
21
  export declare const RENAMED_PROPS: Record<string, Record<string, string>>;
22
22
  export interface UpgradeOptions {
23
- /** The text came from a link (share link or render URL), which may predate 0.3.0. */
23
+ /** The text came from a "z" link (share link or render URL, before 0.6.0), which may predate 0.3.0. */
24
24
  fromLink?: boolean;
25
25
  }
26
26
  /** Rewrites older syntax to the current language. Text that's already current comes back unchanged. */
@@ -0,0 +1,26 @@
1
+ board "Sign-up flow" accent=blue
2
+ screen phone "Create account" #signup
3
+ navbar "Create account" leading=back
4
+ input email "Email" value="ana@example.com"
5
+ input password "Password"
6
+ checkbox "I agree to the terms" checked
7
+ spacer
8
+ button primary lg "Continue" fullWidth #continue
9
+ screen phone "Verify email" #verify
10
+ navbar "Verify email" leading=back
11
+ text "We sent a 6-digit code to ana@example.com." muted
12
+ input type=code digits=6 value="4821"
13
+ button ghost "Wrong email?" #wrong
14
+ spacer
15
+ button primary lg "Verify" fullWidth #confirm
16
+ screen phone "Welcome" #welcome
17
+ spacer
18
+ icon circle-check size=48
19
+ heading "You're all set" level=1
20
+ text "Your account is ready." muted
21
+ spacer
22
+ button primary lg "Get started" fullWidth
23
+ flow continue -> verify "Code sent"
24
+ flow confirm -> welcome "Code matches" color=accent
25
+ flow wrong -> signup "Change email" dashed start=dot
26
+ note "The code expires after 10 minutes; show a Resend link after 30 seconds" width=200
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsquare",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Wireframes in plain text: easy for LLMs to write, fast to render as SVG or PNG.",
5
5
  "keywords": [
6
6
  "wireframe",
@@ -43,15 +43,16 @@ Lists: items are separated by commas, and an item can contain spaces without quo
43
43
  If a bare word could mean more than one prop, write it as key=value.
44
44
 
45
45
  ## Rules
46
- 1. The top element is a Board. The Board's children are Screens, plus optional Notes beside them.
46
+ 1. The top element is a Board. The Board's children are Screens, plus optional Notes beside them and Flow lines after them (rule 10).
47
47
  2. Each Screen is one view of the product. Use several Screens to show several views or states.
48
48
  3. A Screen lays out its children top to bottom. Use Stack (direction row or column) and Grid to arrange content.
49
49
  4. NavBar is pinned to the top of its Screen and TabBar to the bottom.
50
50
  5. Modal, Drawer and Toast are overlays. They must be direct children of a Screen.
51
51
  6. This is a low-fidelity wireframe. Prefer placeholders (Image boxes, Text with lines) over invented copy unless the copy matters.
52
52
  7. Only use the components and props listed below. All props are optional unless marked required.
53
- 8. Wireframes are grayscale. The only UI colors: Board accent (one color for primary buttons, checked controls, toggles, active tabs and ghost buttons), Badge tone (success, warning, danger) and Input error. Only add an accent if the request asks for color or a brand.
54
- 9. Any element except Board, Screen and Note can take tooltip="text" to show a tooltip next to it. Select (with options), Input type=date, and Button, ListItem or NavBar (with menu) take open to show their list, calendar or menu over the screen.
53
+ 8. Wireframes are grayscale. The only UI colors: Board accent (one color for primary buttons, checked controls, toggles, active tabs and ghost buttons), Badge tone (success, warning, danger), Input error and Flow color. Only add an accent if the request asks for color or a brand.
54
+ 9. Any element except Board, Screen, Note and Flow can take tooltip="text" to show a tooltip next to it. Select (with options), Input type=date, and Button, ListItem or NavBar (with menu) take open to show their list, calendar or menu over the screen.
55
+ 10. To show how screens connect, name elements or screens by writing #name after them (button primary "Sign in" #signin, screen phone "Home" #home), then add board-level lines after the screens: flow signin -> home "Tap Sign in".
55
56
 
56
57
  ## Example
57
58
 
@@ -3,7 +3,7 @@
3
3
  Every component and its props, generated from the catalog. All props are optional unless marked required. "main text" is the prop a quoted string fills.
4
4
 
5
5
  ### Board
6
- Root canvas (artboard). Holds Screens side by side, plus optional Notes. Must be the root element.
6
+ Root canvas (artboard). Holds Screens side by side, plus optional Notes and Flow lines. Must be the root element.
7
7
  - title: string (main text)
8
8
  - layout: "row" | "grid" — row = all screens side by side; grid = wrap every `columns` screens
9
9
  - columns: number
@@ -27,6 +27,17 @@ Sticky-note annotation. Put it on the Board beside screens, or inside a Screen n
27
27
  - color: "yellow" | "blue" | "pink" | "green"
28
28
  - width: number
29
29
 
30
+ ### Flow
31
+ An arrow between two elements or screens, named with #id. Written at the board level after the screens: flow signin -> home "Tap Sign in".
32
+ - from (required): string — The id where the arrow starts (written before ->)
33
+ - to (required): string — The id it points at (written after ->)
34
+ - label: string (main text)
35
+ - start: "none" | "arrow" | "dot" | "circle" | "bar" — Default none
36
+ - end: "none" | "arrow" | "dot" | "circle" | "bar" — Default arrow
37
+ - line: "rounded" | "hard" | "curved" | "straight" — Default rounded: right angles with rounded corners
38
+ - dashed: boolean
39
+ - color: string — Default gray. blue, indigo, violet, pink, red, orange, green, teal, a hex color, or accent for the board's
40
+
30
41
  ### Stack
31
42
  Flex container. The main layout primitive (rows, columns, sidebars, toolbars).
32
43
  - direction: "row" | "column"