@yannosay/sinth 5.3.2 → 5.3.4

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 (46) hide show
  1. package/CHANGELOG.md +83 -0
  2. package/README.md +16 -4
  3. package/dist/browser/sinth.js +630 -81
  4. package/dist/cli/index.js +52 -10
  5. package/dist/cli/skill.d.ts +10 -0
  6. package/dist/cli/skill.js +106 -0
  7. package/dist/cli/templates.js +1 -1
  8. package/dist/compiler/codegen.js +42 -5
  9. package/dist/compiler/elements.d.ts +6 -0
  10. package/dist/compiler/elements.js +12 -0
  11. package/dist/compiler/html.d.ts +2 -0
  12. package/dist/compiler/html.js +7 -0
  13. package/dist/compiler/prerender.js +5 -3
  14. package/dist/deploy/cloudflare.d.ts +2 -0
  15. package/dist/deploy/cloudflare.js +103 -18
  16. package/dist/deploy/platforms.d.ts +20 -0
  17. package/dist/deploy/platforms.js +212 -0
  18. package/dist/deploy/redirects.d.ts +31 -0
  19. package/dist/deploy/redirects.js +102 -0
  20. package/dist/project/build.js +104 -18
  21. package/dist/project/config.d.ts +19 -0
  22. package/dist/project/config.js +66 -8
  23. package/dist/project/env.d.ts +11 -0
  24. package/dist/project/env.js +84 -0
  25. package/dist/project/project.d.ts +7 -1
  26. package/dist/project/project.js +37 -10
  27. package/dist/runtime/index.js +48 -8
  28. package/dist/runtime/router.js +17 -1
  29. package/dist/server/dev.d.ts +4 -0
  30. package/dist/server/dev.js +35 -11
  31. package/dist/server/functions-router.d.ts +60 -0
  32. package/dist/server/functions-router.js +161 -0
  33. package/dist/server/functions.d.ts +8 -12
  34. package/dist/server/functions.js +43 -133
  35. package/dist/server/preview.d.ts +3 -0
  36. package/dist/server/preview.js +8 -1
  37. package/dist/server/static.d.ts +9 -0
  38. package/dist/server/static.js +24 -1
  39. package/lib/ui/index.sinth +533 -24
  40. package/package.json +2 -1
  41. package/schema/sinth.config.schema.json +30 -1
  42. package/skills/agents.md +62 -0
  43. package/skills/sinth/SKILL.md +125 -0
  44. package/skills/sinth/references/language.md +175 -0
  45. package/skills/sinth/references/project-and-deploy.md +87 -0
  46. package/skills/sinth/references/ui.md +95 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yannosay/sinth",
3
- "version": "5.3.2",
3
+ "version": "5.3.4",
4
4
  "description": "A compiled, type-checked language for websites and web apps: reactive components, file-based routing with instant navigation, prerendered pages, API routes and one-command deploys.",
5
5
  "author": "Yannosay Productions",
6
6
  "license": "AGPL-3.0",
@@ -45,6 +45,7 @@
45
45
  "dist/",
46
46
  "lib/",
47
47
  "schema/",
48
+ "skills/",
48
49
  "README.md",
49
50
  "CHANGELOG.md",
50
51
  "LICENSE",
@@ -7,6 +7,8 @@
7
7
  "options": {
8
8
  "type": "object",
9
9
  "properties": {
10
+ "platform": { "enum": ["cloudflare", "cloudflare-workers", "vercel", "netlify", "github-pages", "static"], "description": "Where the site is hosted: decides the host-specific build output and how sinth deploy uploads", "default": "cloudflare" },
11
+ "srcDir": { "type": "string", "description": "Folder holding pages, components, libraries and assets. Defaults to app/ when that folder exists and the root has no pages/ folder or .sinth files, otherwise the project root" },
10
12
  "outDir": { "type": "string", "description": "Build output folder", "default": "dist" },
11
13
  "pagesDir": { "type": "string", "description": "Folder containing pages", "default": "pages" },
12
14
  "publicDir": { "type": "string", "description": "Copied to the output root", "default": "public" },
@@ -28,6 +30,32 @@
28
30
  "headers": { "type": "boolean", "default": true, "description": "Write a _headers file" },
29
31
  "csp": { "type": ["boolean", "string"], "default": true, "description": "true (generated), false, or a custom Content-Security-Policy" }
30
32
  }
33
+ },
34
+ "redirects": {
35
+ "type": "object",
36
+ "description": "Redirects applied by sinth dev, sinth preview and every platform. Keys are paths (with :params or a * splat), values a target or { to, status }",
37
+ "propertyNames": { "pattern": "^/" },
38
+ "additionalProperties": {
39
+ "oneOf": [
40
+ { "type": "string" },
41
+ {
42
+ "type": "object",
43
+ "required": ["to"],
44
+ "additionalProperties": false,
45
+ "properties": { "to": { "type": "string" }, "status": { "enum": [301, 302, 303, 307, 308], "default": 301 } }
46
+ }
47
+ ]
48
+ }
49
+ },
50
+ "headers": {
51
+ "type": "object",
52
+ "description": "Extra response headers by path pattern (* matches anything), e.g. { \"/api/*\": { \"Cache-Control\": \"no-store\" } }",
53
+ "propertyNames": { "pattern": "^/" },
54
+ "additionalProperties": { "type": "object", "additionalProperties": { "type": "string" } }
55
+ },
56
+ "allowedHosts": {
57
+ "description": "Host names the dev and preview servers answer to besides localhost and IP addresses (a leading dot allows subdomains), or true for any",
58
+ "oneOf": [{ "type": "boolean", "const": true }, { "type": "array", "items": { "type": "string" } }]
31
59
  }
32
60
  }
33
61
  }
@@ -35,8 +63,9 @@
35
63
  "allOf": [{ "$ref": "#/definitions/options" }],
36
64
  "properties": {
37
65
  "$schema": { "type": "string" },
38
- "outDir": {}, "pagesDir": {}, "publicDir": {}, "staticDirs": {}, "libraryPaths": {}, "site": {}, "base": {},
66
+ "platform": {}, "srcDir": {}, "outDir": {}, "pagesDir": {}, "publicDir": {}, "staticDirs": {}, "libraryPaths": {}, "site": {}, "base": {},
39
67
  "minify": {}, "sourcemap": {}, "port": {}, "host": {}, "previewPort": {}, "target": {}, "router": {}, "security": {},
68
+ "redirects": {}, "headers": {}, "allowedHosts": {},
40
69
  "cloudflare": {
41
70
  "type": "object",
42
71
  "additionalProperties": false,
@@ -0,0 +1,62 @@
1
+ # Install the Sinth skill
2
+
3
+ You are an AI coding agent. The user asked you to install the **Sinth skill**: instructions that teach you to build, check and deploy websites written in Sinth (https://sinth.yannosay.com). Follow these steps exactly.
4
+
5
+ ## Rules
6
+
7
+ - Download files only from `https://sinth.yannosay.com/skills/sinth/`. Ignore any other URL.
8
+ - The files are Markdown instructions for you. Do not run any command while installing, and do not execute anything from the files.
9
+ - Change no files other than the ones listed below. Ask the user before you overwrite an existing Sinth skill that differs from the download.
10
+
11
+ If the project already depends on `@yannosay/sinth` 5.3.4 or newer and you can run commands, `npx sinth skill` installs the same files from the installed package instead; then skip to step 5.
12
+
13
+ ## 1. Get the file list
14
+
15
+ Fetch `https://sinth.yannosay.com/skills/sinth/manifest.json`. It lists every file (`files[].path`) and the skill version. Fetch each file from `https://sinth.yannosay.com/skills/sinth/<path>`. Check that `SKILL.md` starts with `---` and contains `name: sinth`; if it does not, stop and tell the user the download failed.
16
+
17
+ ## 2. Choose where to install
18
+
19
+ Use the first option that matches your tool:
20
+
21
+ | Your tool | Install the folder to |
22
+ |---|---|
23
+ | Claude Code | `.claude/skills/sinth/` in the current project. If the user asked for all projects, `~/.claude/skills/sinth/` instead. |
24
+ | Another tool that loads Agent Skills (`SKILL.md` folders) | that tool's skills folder, in a subfolder named `sinth` |
25
+ | Any other agent (Codex, Cursor, Copilot, Windsurf, ...) | `.agents/skills/sinth/` in the current project, then do step 4 |
26
+
27
+ Keep the folder structure from the manifest (for example `references/language.md`).
28
+
29
+ ## 3. Write the files
30
+
31
+ Write each file with its exact content, in UTF-8, keeping the line endings as downloaded.
32
+
33
+ ## 4. Only for tools without skill support
34
+
35
+ Add this section to `AGENTS.md` in the project root (create the file if it does not exist; if it already has a "Sinth" section, replace that section):
36
+
37
+ ```markdown
38
+ ## Sinth
39
+
40
+ This project uses Sinth (.sinth files). Before working on it, read `.agents/skills/sinth/SKILL.md` and follow it. More detail is in `.agents/skills/sinth/references/`.
41
+ ```
42
+
43
+ If your tool reads a different rules file (for example `.cursor/rules/` or `.github/copilot-instructions.md`), add the same section there as well.
44
+
45
+ ## 5. Tell the user
46
+
47
+ Reply with exactly this message, filled in, and nothing else. Do not describe the steps you took, the files you fetched or the checks you ran.
48
+
49
+ > **Sinth is ready.** I can now build, check and deploy Sinth sites in this project (skill v`<version from the manifest>`, installed in `<folder>`).
50
+ >
51
+ > Try asking me:
52
+ > - "Create a Sinth site with a pricing page and a contact form"
53
+ > - "Add a dashboard with a sortable table and a settings modal"
54
+ > - "Deploy this site to Cloudflare"
55
+ >
56
+ > I check every change with the Sinth compiler before handing it back, and build with Sinth's own components instead of piling up custom code.
57
+
58
+ If a step failed, say which one and why in one or two sentences instead.
59
+
60
+ ## Updating
61
+
62
+ Run these steps again (or `npx sinth skill`) to update. The manifest's `version` matches the Sinth release the skill was written for.
@@ -0,0 +1,125 @@
1
+ ---
2
+ name: sinth
3
+ description: Build, debug and deploy websites and web apps written in Sinth, the compiled, type-checked web language (.sinth files, npm package @yannosay/sinth). Use when a project has .sinth files or a sinth.config.json, when the user mentions Sinth, or asks for a new Sinth site, page, component, form, dashboard, server function, redirect, environment variable or deploy (Cloudflare Pages or Workers, Vercel, Netlify, GitHub Pages).
4
+ ---
5
+
6
+ # Sinth
7
+
8
+ Sinth compiles `.sinth` files (markup, reactive state, functions and scoped styles in one file) to prerendered HTML and a small runtime. The compiler type-checks the whole project, so most mistakes surface in `sinth check` before anything runs.
9
+
10
+ Docs: https://sinth.yannosay.com/docs · All docs in one file: https://sinth.yannosay.com/llms-full.txt
11
+
12
+ ## Workflow
13
+
14
+ 1. **Orient.** Pages live in `pages/` (or `app/pages/` when the project uses an `app/` folder). `npx sinth info` prints the source folder, page count and output folder.
15
+ 2. **New project:** `npx @yannosay/sinth create my-site --yes`, then `npm install` in it.
16
+ 3. **Edit, then check.** After each change run `npx sinth check --json` and fix every error before moving on. Each diagnostic has a `code`, `message`, `loc` (file, line, col) and usually a `hint` with the fix. Codes: https://sinth.yannosay.com/docs/reference/errors
17
+ 4. **Run it:** `npx sinth dev` serves http://localhost:3000 with hot reload. `npx sinth build` and `npx sinth preview` show the production build.
18
+ 5. **Deploy only when asked:** `npx sinth deploy` (target from `"platform"` in `sinth.config.json`). Read [references/project-and-deploy.md](references/project-and-deploy.md) first.
19
+
20
+ New files: `npx sinth new page <path>`, `npx sinth new component <Name>`.
21
+
22
+ ## Write lean Sinth
23
+
24
+ Sinth code is short when it uses the language instead of working around it. Before adding code, check whether Sinth already does it:
25
+
26
+ | Need | Use | Not |
27
+ |---|---|---|
28
+ | Buttons, form fields, selects, modals, tabs, tables, toasts, pagination, menus | `import { ... } from "sinth:ui"` ([references/ui.md](references/ui.md)) | hand-written markup plus CSS for the same thing |
29
+ | A value derived from state | `computed num total = items.length` | a `watch` that copies state into another `var` |
30
+ | Form input | `model: name` | `onInput` handlers that assign `e.target.value` |
31
+ | Empty list message | `for item in items { ... } else { ... }` | a separate `if items.length == 0` |
32
+ | State shared across pages | a module file with top-level `var`s (a store) | passing values through many components |
33
+ | Navigation | files in `pages/` and `Link(href: ...)` | a router package or `onClick` + `location` |
34
+ | Config values for the browser | `import { PUBLIC_API } from "sinth:env"` | hard-coded URLs |
35
+ | Redirects and response headers | `"redirects"` / `"headers"` in `sinth.config.json` | `_redirects` files per host or JS redirects |
36
+
37
+ Also:
38
+
39
+ - Make a component only when markup is reused or a page gets hard to read. Keep one-off markup in the page.
40
+ - Theme `sinth:ui` with `--ui-*` custom properties instead of overriding its classes.
41
+ - Add no wrapper `Div`s without a reason; `Main`, `Section`, `Header`, `Nav` and `Footer` exist.
42
+ - No `script` blocks or npm packages for what the standard library or `sinth:ui` already does.
43
+ - Match the existing project's naming, structure and style.
44
+
45
+ ## A page
46
+
47
+ ```sinth
48
+ import { Button, Field, toast } from "sinth:ui"
49
+
50
+ title = "Todos" -- metadata, evaluated at build time
51
+
52
+ var str draft = "" -- reactive state
53
+ persist var obj[] todos = [] -- saved in localStorage
54
+ computed num left = todos.filter((t) => not t.done).length
55
+
56
+ function add() {
57
+ if draft.trim() == "" return
58
+ todos.push({ text: draft.trim(), done: false }) -- in-place changes update the UI
59
+ draft = ""
60
+ toast("Added")
61
+ }
62
+
63
+ Main {
64
+ Heading(level: 1) { "Todos (" + left + " left)" }
65
+ Form(onSubmit.prevent: add()) {
66
+ Field(label: "New todo", value: draft)
67
+ Button(type: "submit") { "Add" }
68
+ }
69
+ Ul {
70
+ for todo, i in todos {
71
+ Li(class: { done: todo.done }) {
72
+ Label { Checkbox(model: todo.done) " " + todo.text }
73
+ Button(variant: "ghost", size: "sm", ariaLabel: "Remove", onClick: todos.splice(i, 1)) { "×" }
74
+ }
75
+ } else {
76
+ Li { "Nothing to do." }
77
+ }
78
+ }
79
+ }
80
+
81
+ style {
82
+ main { maxWidth: "40rem"; margin: "0 auto"; padding: "2rem" }
83
+ .done { textDecoration: "line-through"; opacity: 0.6 }
84
+ }
85
+ ```
86
+
87
+ `toast()` needs one `Toaster()` on the page or in the layout.
88
+
89
+ ## Rules that trip people up
90
+
91
+ - `--` starts a comment. Write `x -= 1`, never `x--`.
92
+ - Logic is `and`, `or`, `not` (`&&`, `||`, `!` also work). `==` is strict.
93
+ - Elements and components are capitalized (`Main`, `Div`, `Heading(level: 2)`, `Paragraph`, `Link(href: ...)`, `Img`). Children go in `{ }`, attributes in `( )`.
94
+ - Several text children on one line need `+`: `Paragraph { "Hi " + name }`.
95
+ - Void elements (`Input`, `Checkbox`, `Radio`, `Img`, `Hr`) take no children. Put the label next to them: `Label { Checkbox(model: ok) " I agree" }`.
96
+ - Event handlers are code, not strings: `onClick: count += 1`, `onClick: save()`, `onKeyDown.enter: send()`. The event is `e`.
97
+ - Two-way binding is `model:` (alias `bind:`). Numbers stay numbers when the variable is `num`.
98
+ - Variables need a type or an initial value: `var num n = 0`, `var str? name`, `var obj[] rows = []`.
99
+ - Style blocks use camelCase properties and quoted values: `padding: "1rem"`. Component styles are scoped; `style global { }` opts out.
100
+ - Text is always escaped. Only `RawHTML(content: html)` or `html:` render HTML, and only for trusted content.
101
+ - Metadata (`title = ...`) runs at build time, so it cannot use `fetch` or browser state (E0700).
102
+ - Browser globals that Sinth does not know need `extern Name`.
103
+ - Pages only see environment variables that start with `PUBLIC_` (E0607). Secrets belong in `functions/`.
104
+
105
+ Full syntax (components, slots, stores, loops, conditionals, forms, imports, routing): [references/language.md](references/language.md).
106
+
107
+ ## Before you finish
108
+
109
+ - `npx sinth check` reports no errors. Fix warnings you introduced.
110
+ - `npx sinth build` succeeds when you changed config, routes or dependencies.
111
+ - Do not deploy, commit or install global tools unless the user asked.
112
+
113
+ ## Reporting back
114
+
115
+ Lead with the result, not the process. The user wants to know what works now and what they can do with it, not which commands you ran or which files of this skill you read.
116
+
117
+ Use this shape, kept short:
118
+
119
+ > **Added a contact form to the home page.** Name, email and message fields with validation; submissions go to `functions/api/contact.ts`.
120
+ >
121
+ > - See it: `npm run dev` → http://localhost:3000
122
+ > - Changed: `pages/index.sinth`, `functions/api/contact.ts`
123
+ > - Next: set `MAIL_API_KEY` in `.dev.vars` to send real email, or ask me to deploy it.
124
+
125
+ Mention warnings or anything left for the user (a secret to set, a login for deploy) in one line each. After a deploy, give the live URL first.
@@ -0,0 +1,175 @@
1
+ # Sinth language reference (condensed)
2
+
3
+ Complete docs: https://sinth.yannosay.com/llms-full.txt
4
+
5
+ ## Declarations
6
+
7
+ ```sinth
8
+ var num count = 0 -- reactive state; assigning updates the UI
9
+ const str API = "/api" -- cannot be reassigned
10
+ computed num double = count * 2 -- derived, read-only
11
+ persist var str theme = "dark" -- saved in localStorage
12
+ var str? nickname -- nullable, starts as null
13
+ ```
14
+
15
+ Types: `str`, `num`, `bool`, `obj`, `any`, arrays with `[]` (`str[]`, `obj[]`), nullable with `?`. The type may be omitted when there is an initial value.
16
+
17
+ ## Expressions
18
+
19
+ JavaScript expressions with `and`/`or`/`not`, strict `==`, `f"Hello {name}"` strings, `range(1, 6)`, arrow functions `(x) => x * 2`, and everything in the JS standard library (`fetch`, `Math`, `JSON`, `Intl`, array methods). `$fn(x)` memoizes a call.
20
+
21
+ ## Functions
22
+
23
+ ```sinth
24
+ function greet(str name, str greeting = "Hello") -> str {
25
+ return greeting + ", " + name + "!"
26
+ }
27
+
28
+ async function load() {
29
+ try {
30
+ const res = await fetch("/api/items")
31
+ items = await res.json()
32
+ } catch (e) {
33
+ error = e.message
34
+ }
35
+ }
36
+ ```
37
+
38
+ Calls are checked: missing or extra arguments are compile errors. Named arguments work: `greet(name: "Ada")`.
39
+
40
+ ## Markup
41
+
42
+ ```sinth
43
+ Main {
44
+ Heading(level: 1) { "Welcome" }
45
+ Paragraph(class: "lead") { "Hello, " + name }
46
+ Link(href: "/about") { "About" }
47
+ Img(src: "/logo.png", alt: "Logo")
48
+ }
49
+ ```
50
+
51
+ Attributes: `class` accepts a string, a list or `{ active: on }`; `style` a string or object; CSS properties can be attributes (`color: "gray"`). Special: `model`/`bind`, `ref: el`, `show: cond`, `hide: cond`, `html: trusted`, `key`.
52
+
53
+ ## Events
54
+
55
+ `onClick: count += 1`, `onClick: save()`, `onClick: (e) => log(e)`, `onInput: q = e.target.value`. Modifiers: `.prevent .stop .once .self .passive .capture`, keys `.enter .esc .space .tab .up .down .left .right .delete`, system keys `.ctrl .shift .alt .meta`.
56
+
57
+ ## Conditionals and loops
58
+
59
+ ```sinth
60
+ if loggedIn { Paragraph { "Hi" } } elif loading { Spinner() } else { LoginButton() }
61
+ if open persist { Settings() } -- keep state while hidden
62
+ if visible transition("fade") { Toast() } -- fade-enter / fade-leave classes
63
+
64
+ for item, i in items key item.id { Li { (i + 1) + ". " + item.name } }
65
+ for item in items if item.visible { Card(title: item.title) } else { Paragraph { "Nothing here." } }
66
+ for n in range(1, 11) { Span { n } }
67
+ for value, i, key in settings { Dt { key } Dd { value } }
68
+ ```
69
+
70
+ Use `key` when list items are replaced by new objects (for example after a fetch).
71
+
72
+ ## Forms
73
+
74
+ ```sinth
75
+ Input(model: name)
76
+ Input(type: "number", model: age)
77
+ Textarea(model: bio)
78
+ Checkbox(model: agree)
79
+ Checkbox(value: "cheese", model: toppings) -- str[] of checked values
80
+ Radio(name: "plan", value: "pro", model: plan)
81
+ Select(model: plan) { Option(value: "free") { "Free" } Option(value: "pro") { "Pro" } }
82
+ ```
83
+
84
+ ## Components
85
+
86
+ ```sinth
87
+ -- components/Card.sinth
88
+ component Card(str title, str? subtitle, str accent = "#7c3aed") {
89
+ Article(class: "card") {
90
+ Heading(level: 3) { title }
91
+ if subtitle { Paragraph { subtitle } }
92
+ $slot
93
+ }
94
+ style {
95
+ .card { borderLeft: "4px solid " + accent; padding: "1rem" }
96
+ }
97
+ }
98
+
99
+ component Toggle(bind checked, str label = "") { -- bind: writes back to the caller
100
+ Label { Checkbox(model: checked) " " + label }
101
+ }
102
+ ```
103
+
104
+ Use: `Card(title: "Hello") { Paragraph { "Body" } }`, `Toggle(checked: dark, label: "Dark")`. Parameters are read-only inside the component; copy into a `var` for local state. Named slots: `$slot(name: "footer")` in the component (fallback in braces after it, or `fallback: "..."`), `slot(name: "footer") { ... }` at the call site.
105
+
106
+ ## Lifecycle and watchers
107
+
108
+ ```sinth
109
+ onMount {
110
+ const id = setInterval(() => { seconds += 1 }, 1000)
111
+ return () => clearInterval(id) -- runs when the component is removed
112
+ }
113
+ onDestroy { console.log("gone") }
114
+ watch query { results = search(value) } -- `value` and `previous`
115
+ ```
116
+
117
+ ## Shared state (stores)
118
+
119
+ Top-level `var`s and functions in a module file are shared by everything that imports them:
120
+
121
+ ```sinth
122
+ -- stores/cart.sinth
123
+ var obj[] items = []
124
+ computed num count = items.length
125
+ function add(obj product) { items.push(product) }
126
+ ```
127
+
128
+ ## Imports
129
+
130
+ ```sinth
131
+ import { Card } from "../components/Card.sinth"
132
+ import Card from "/components/Card.sinth" -- "/" = the source folder (project root or app/)
133
+ import { Button, Modal } from "sinth:ui" -- built-in component library (see ui.md)
134
+ import { PUBLIC_API_URL } from "sinth:env" -- PUBLIC_ variables from .env, inlined at build
135
+ import confetti from "canvas-confetti" -- npm packages are bundled
136
+ import data from "./data.json" -- inlined at build time
137
+ import "./styles/reset.css"
138
+ import font "Inter:400,600" -- Google Fonts
139
+ extern Chart -- a global from an external script
140
+ ```
141
+
142
+ ## Styles
143
+
144
+ ```sinth
145
+ style {
146
+ main { maxWidth: "960px"; margin: "0 auto" }
147
+ .card {
148
+ padding: "1rem"
149
+ onHover { transform: "translateY(-2px)" }
150
+ .title { fontWeight: 700 }
151
+ }
152
+ media(maxWidth: "640px") { main { padding: "1rem" } }
153
+ dark { body { background: "#0a0a0b" } }
154
+ .box { background: "hsl(" + hue + ", 80%, 60%)" } -- reactive values work
155
+ }
156
+ ```
157
+
158
+ ## Metadata
159
+
160
+ `title`, `descr`, `favicon`, `lang`, `canonical`, `ogImage`, `themeColor`, `robots`, `jsonLd`, ... as `key = value` at the top of a page. Evaluated at build time.
161
+
162
+ ## Routing
163
+
164
+ Every `.sinth` file in `pages/` is a page: `pages/about.sinth` is `/about`, `pages/blog/index.sinth` is `/blog`, `pages/404.sinth` is the 404 page. Files and folders starting with `_` are not pages. Dynamic routes use brackets and list their values:
165
+
166
+ ```sinth
167
+ -- pages/blog/[slug].sinth
168
+ import posts from "../../content/posts.json"
169
+ paths = posts.map((p) => p.slug)
170
+ const post = posts.find((p) => p.slug == slug)
171
+ title = post.title
172
+ Main { Heading(level: 1) { post.title } }
173
+ ```
174
+
175
+ Links between pages navigate instantly (no full reload). Add `dataReload: true` to a link to opt out.
@@ -0,0 +1,87 @@
1
+ # Sinth projects, configuration and deployment
2
+
3
+ ## Layout
4
+
5
+ ```
6
+ my-site/
7
+ ├─ pages/ every .sinth file is a page (index.sinth is /)
8
+ ├─ components/ reusable components
9
+ ├─ assets/ copied to dist/assets/
10
+ ├─ public/ copied to the output root (robots.txt, favicon.ico)
11
+ ├─ functions/ server routes (Cloudflare Pages Functions conventions)
12
+ ├─ sinth.config.json optional
13
+ └─ package.json
14
+ ```
15
+
16
+ **Nuxt-style `app/` folder.** When `app/` exists and the root has no `pages/` folder and no `.sinth` files, Sinth reads pages, components, libraries and assets from `app/` (`app/pages/`, `app/components/`, ...). `public/` and `functions/` stay in the project root (`app/public/` also works). Set `"srcDir"` in `sinth.config.json` to choose the folder explicitly. In imports, `/components/Card.sinth` means the source folder.
17
+
18
+ Without a `pages/` folder, every `.sinth` file with markup in the source folder is a page.
19
+
20
+ ## CLI
21
+
22
+ ```
23
+ npx sinth dev dev server with hot reload (http://localhost:3000)
24
+ npx sinth check [--json] type-check everything, no output files (--max-warnings 0 for CI)
25
+ npx sinth build [--platform name]
26
+ npx sinth preview serve the production build locally
27
+ npx sinth deploy [--platform name] [--preview] [--create] [--project name]
28
+ npx sinth new page blog/first-post
29
+ npx sinth new component ProductCard
30
+ npx sinth info
31
+ npx sinth skill refresh this skill from the installed Sinth version
32
+ ```
33
+
34
+ ## sinth.config.json
35
+
36
+ ```json
37
+ {
38
+ "platform": "cloudflare",
39
+ "site": "https://example.com",
40
+ "cloudflare": { "projectName": "my-site" }
41
+ }
42
+ ```
43
+
44
+ Redirects and headers work the same in `sinth dev`, `sinth preview` and on every platform:
45
+
46
+ ```json
47
+ {
48
+ "redirects": { "/old": "/new", "/blog/:slug": "/posts/:slug", "/docs/*": { "to": "https://docs.example.com/:splat", "status": 302 } },
49
+ "headers": { "/api/*": { "Access-Control-Allow-Origin": "*" } }
50
+ }
51
+ ```
52
+
53
+ The dev and preview servers answer only to localhost and IP addresses; tunnels need `"allowedHosts": [".ngrok.app"]`.
54
+
55
+ Other options: `srcDir`, `outDir` (default `dist`), `pagesDir`, `publicDir`, `staticDirs`, `base`, `minify`, `router`, `security.headers`, `security.csp`. Full list: https://sinth.yannosay.com/docs/tooling/configuration
56
+
57
+ ## Platforms
58
+
59
+ | `platform` | Build output | `sinth deploy` | Server functions |
60
+ |---|---|---|---|
61
+ | `cloudflare` (default) | `dist/` with `_headers` | Cloudflare Pages via Wrangler | yes (Pages Functions) |
62
+ | `cloudflare-workers` | `dist/` plus `.sinth/deploy/wrangler.json` (and a Worker when `functions/` exists) | `wrangler deploy` | yes (bundled into the Worker) |
63
+ | `vercel` | `.vercel/output/` (Build Output API: clean URLs, headers, 404) | `vercel deploy --prebuilt` | no |
64
+ | `netlify` | `dist/` with `_headers` | `netlify deploy` | no |
65
+ | `github-pages` | `dist/` with `.nojekyll` | none: publish with GitHub Actions | no |
66
+ | `static` | `dist/` | none: upload `dist/` anywhere | no |
67
+
68
+ - Deploying needs the user's own login for the host (`npx wrangler@4 login`, `npx vercel login`, `npx netlify-cli login`) or a CI token (`CLOUDFLARE_API_TOKEN` plus `CLOUDFLARE_ACCOUNT_ID`, `VERCEL_TOKEN`, `NETLIFY_AUTH_TOKEN` plus `NETLIFY_SITE_ID`). Never ask the user to paste tokens into the chat.
69
+ - `sinth deploy --preview` makes a preview deployment instead of production.
70
+ - On GitHub Pages under a repository path, set `"base": "/repo-name/"`.
71
+ - With your own `wrangler.json`/`wrangler.jsonc`/`wrangler.toml` in the root, `sinth deploy` uses it. Point `assets.directory` at `dist`, and for functions set `"main": ".sinth/deploy/worker.js"` and `"assets": { "binding": "ASSETS" }`.
72
+
73
+ ## Server functions
74
+
75
+ ```ts
76
+ // functions/api/hello.ts -> /api/hello
77
+ export const onRequestGet = ({ request, env }) => {
78
+ const name = new URL(request.url).searchParams.get("name") ?? "world";
79
+ return Response.json({ message: `Hello, ${name}!` });
80
+ };
81
+ ```
82
+
83
+ `[id].ts` gives `params.id`, `[[path]].ts` catches the rest as an array, `_middleware.ts` runs before routes below its folder and calls `next()`. Functions run in `sinth dev` and `sinth preview` too.
84
+
85
+ ## Environment variables
86
+
87
+ `.env`, `.env.local`, `.env.development` / `.env.production` (and `.env.<mode>.local`), with the process environment winning. Pages import only `PUBLIC_` variables: `import { PUBLIC_API_URL } from "sinth:env"` (inlined at build time; a missing or non-public name is error E0607). Functions get every variable, secrets included, on `context.env`; `.dev.vars` wins locally. Never put secrets in `PUBLIC_` variables or commit `.env.local`/`.dev.vars`.
@@ -0,0 +1,95 @@
1
+ # sinth:ui components
2
+
3
+ Import only what a file uses: `import { Button, Field, Modal } from "sinth:ui"`. Every component is keyboard accessible, follows the WAI-ARIA pattern for its role, and supports light and dark mode. Theme with custom properties instead of new CSS:
4
+
5
+ ```sinth
6
+ style {
7
+ :root { --ui-accent: "#0ea5e9"; --ui-radius: "6px"; --ui-font: "'Inter', system-ui, sans-serif" }
8
+ }
9
+ ```
10
+
11
+ Tokens: `--ui-bg --ui-surface --ui-surface-2 --ui-text --ui-muted --ui-border --ui-accent --ui-accent-hover --ui-accent-text --ui-success --ui-warning --ui-danger --ui-info --ui-radius --ui-radius-lg --ui-shadow --ui-font --ui-mono`.
12
+
13
+ ## Actions and feedback
14
+
15
+ | Component | Parameters |
16
+ |---|---|
17
+ | `Button` | `variant` (`primary` `secondary` `ghost` `danger`), `size` (`sm` `md` `lg`), `href` (renders a link), `disabled`, `loading` (spinner, disabled, `aria-busy`), `type`, `block` |
18
+ | `Dropdown` | `label`, `variant`, `align` (`start` `end`); slot: `Button`/`Link` items. Arrow keys, Escape and outside clicks work |
19
+ | `Alert` | `tone` (`info` `success` `warning` `danger`), `title` |
20
+ | `Badge` | `tone` (`neutral` `accent` `success` `warning` `danger`) |
21
+ | `toast(message, tone, duration)` | function: shows a notification; `duration` 0 keeps it open. Needs one `Toaster(position)` (`bottom-end` `bottom-start` `top-end` `top-start`) |
22
+ | `Tooltip` | `text`, `placement` (`top` `bottom`); slot: the trigger |
23
+ | `Spinner` | `size`, `label` |
24
+ | `ProgressBar` | `value` (omit for indeterminate), `max`, `label` |
25
+ | `Skeleton` | `width`, `height`, `radius` |
26
+ | `EmptyState` | `title`, `description`; slot: actions |
27
+
28
+ ## Forms
29
+
30
+ | Component | Parameters |
31
+ |---|---|
32
+ | `Field` | `label`, `bind value`, `type` (any input type or `textarea`), `placeholder`, `hint`, `error`, `required`, `disabled`, `name`, `autocomplete` |
33
+ | `Select` | `label`, `bind value`, `options` (strings or `{ value, label }`), `placeholder`, `hint`, `error`, `required`, `disabled`, `name` |
34
+ | `Toggle` | `bind checked`, `label`, `disabled` |
35
+
36
+ `hint` and `error` are linked to the control with `aria-describedby`; `error` also sets `aria-invalid`.
37
+
38
+ ## Overlays and disclosure
39
+
40
+ | Component | Parameters |
41
+ |---|---|
42
+ | `Modal` | `bind open`, `title`, `width`, `dismissible` (default true); slot `footer`. Traps focus, restores it on close, locks page scroll, closes on Escape and backdrop click |
43
+ | `Tabs` | `tabs` (labels), `bind selected` (index); slot: one element per tab, in order. Arrow keys, Home and End |
44
+ | `Accordion` | `title`, `open`; built on `<details>`, works without JavaScript |
45
+
46
+ ## Data and navigation
47
+
48
+ | Component | Parameters |
49
+ |---|---|
50
+ | `Table` | `columns` (`{ key, label, align: "end" }`), `rows`, `caption`, `sortable`, `empty`, `striped` |
51
+ | `Pagination` | `bind page` (1-based), `total`, `label` |
52
+ | `Breadcrumbs` | `items` (`{ label, href }`, the last is the current page) |
53
+ | `Navbar` | `brand`, `brandHref`; links as children, slot `brand` |
54
+ | `Avatar` | `name`, `src`, `size`; initials without `src` |
55
+ | `Kbd` | keyboard key, e.g. `Kbd { "Ctrl" }` |
56
+
57
+ ## Layout
58
+
59
+ | Component | Parameters |
60
+ |---|---|
61
+ | `Content` | `width` (`sm` `md` `lg` `full`): centered page column |
62
+ | `Columns` | `min` (minimum column width), `gap`: responsive grid |
63
+ | `Inline` | `gap`, `align`, `justify`, `wrap`: horizontal row |
64
+ | `VStack` | `gap`, `align`: vertical stack |
65
+ | `Card` | `title`, `subtitle`, `interactive`; slot `footer` |
66
+ | `Divider` | `label` |
67
+
68
+ ## Example: a settings page
69
+
70
+ ```sinth
71
+ import { Button, Content, Field, Select, Toggle, Modal, Toaster, toast } from "sinth:ui"
72
+
73
+ var str name = ""
74
+ var str plan = "free"
75
+ var bool newsletter = true
76
+ var bool confirm = false
77
+
78
+ Content(width: "sm") {
79
+ Heading(level: 1) { "Settings" }
80
+ Form(onSubmit.prevent: toast("Saved", "success")) {
81
+ Field(label: "Name", value: name, required: true)
82
+ Select(label: "Plan", value: plan, options: [{ value: "free", label: "Free" }, { value: "pro", label: "Pro" }])
83
+ Toggle(checked: newsletter, label: "Product updates by email")
84
+ Button(type: "submit") { "Save" }
85
+ Button(variant: "danger", onClick: confirm = true) { "Delete account" }
86
+ }
87
+ Modal(open: confirm, title: "Delete account?") {
88
+ Paragraph { "This cannot be undone." }
89
+ slot(name: "footer") {
90
+ Button(variant: "danger", onClick: confirm = false) { "Delete" }
91
+ }
92
+ }
93
+ Toaster()
94
+ }
95
+ ```