feat: add typed WRN declarations

This commit is contained in:
2026-07-19 18:44:27 +05:30
parent 0d3ec79ee4
commit 94ae40d8bd
81 changed files with 942 additions and 241 deletions
+26 -8
View File
@@ -151,17 +151,32 @@ layout = "public"
```
props {
start = 0 // default's TYPE drives coercion: start="5" arrives as number 5
label = "Count" // string
disabled = false // boolean
title: string // required: no default
start: number = 0 // start="5" arrives as number 5
disabled: boolean = false
items: Array<Item> = []
}
```
Type annotations use TypeScript syntax. Legacy declarations without an annotation still infer their
runtime type from the default value.
### `types { }` — local TypeScript models
```ts
types {
interface Item { id: string; label: string }
type Status = "idle" | "loading" | "ready"
}
```
These declarations can be referenced by props, state, and function signatures in the same file.
### `state` — ⚠️ one per line
```
state count = start // may reference a prop or earlier state
state total = 0
state count: number = start // may reference a prop or earlier state
state status: Status = "idle"
```
State seeds the reactive scope. On pages, seeds are also evaluated at compile time for SSR baking.
@@ -198,15 +213,18 @@ style {
Multiple `style` blocks accumulate. Use theme tokens (`var(--wire-*)`) so styles restyle on theme
change.
### `functions { }` — shared **serveronly** helpers
### `functions { }` — typed helpers
```
functions {
function slug(s) { return s.toLowerCase().replace(/\s+/g, "-"); }
function slug(value: string): string {
return value.toLowerCase().replace(/\s+/g, "-");
}
}
```
Available to `api`, `ssr`/`client`, and `realtime` bodies.
Component functions are available to events, lifecycle hooks, and watchers in the browser as well as
server rendering. Page helpers are available to `api`, `ssr`/`client`, and `realtime` bodies.
### `api <METHOD> <path> { }` — colocated API route