orvyn-lang 0.3.0 → 0.4.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/GUIDE.md CHANGED
@@ -103,6 +103,55 @@ Add this button inside `Home`:
103
103
  Button "About", onTap: go(About)
104
104
  ```
105
105
 
106
+ ### How routing works
107
+
108
+ Each `screen` gets an address from its name: `screen About` is `/about`. A file at `src/pages/about/index.orv` containing `screen About` is discovered automatically, included in the app, and pre-rendered by `orvyn build`. The screen name must match the folder name, ignoring capitalization.
109
+
110
+ For screens elsewhere, import them in `src/app.orv`:
111
+
112
+ ```text
113
+ use About from "./pages/about/index"
114
+ screen Home { Text "Home" }
115
+ ```
116
+
117
+ Keep a screen such as `Home` in `app.orv` to choose the home page explicitly. Imported screens are also pre-rendered during `orvyn build`; give each one a `page title:` and `description:` for search results.
118
+
119
+ ### One navbar and footer for every page
120
+
121
+ Write the layout once, with `slot` where each page's content goes. A shared component can `go()` to any screen in the project without importing it:
122
+
123
+ ```text
124
+ src/
125
+ app.orv screen Home
126
+ components/layout/index.orv component Layout
127
+ pages/about/index.orv screen About
128
+ pages/blog/index.orv screen Blog
129
+ ```
130
+
131
+ ```text
132
+ // src/components/layout/index.orv
133
+ component Layout {
134
+ Column {
135
+ Row gap: 16 {
136
+ Button "Home", onTap: go(Home)
137
+ Button "About", onTap: go(About)
138
+ Button "Blog", onTap: go(Blog)
139
+ }
140
+ slot
141
+ Text "© 2026"
142
+ }
143
+ }
144
+
145
+ // src/pages/about/index.orv
146
+ use Layout from "../../components/layout"
147
+ screen About {
148
+ page title: "About me", description: "Who I am"
149
+ Layout { Heading "About" }
150
+ }
151
+ ```
152
+
153
+ To add a page, create its folder and add one button to the layout.
154
+
106
155
  ## 6. Check that it works
107
156
 
108
157
  Add this at the bottom of the file:
package/LANGUAGE.md CHANGED
@@ -34,6 +34,7 @@ orvyn new my-app # creates the app and installs it
34
34
  cd my-app
35
35
 
36
36
  orvyn dev # web → http://localhost:5173, reloads when you save
37
+ orvyn dev --native # web preview using only phone-supported styles (390px)
37
38
  orvyn ios # iPhone simulator, reloads when you save
38
39
  orvyn android # Android emulator or phone, with live reload
39
40
  orvyn test # run the test blocks in your app
@@ -117,6 +118,26 @@ screen Home {
117
118
  Imported state stays reactive. Assigning to an imported fixed value or function
118
119
  reports a runtime error explaining that the declaration must use `state`.
119
120
 
121
+ - **Folder imports:** `use Chip from "./components/chip"` automatically finds `./components/chip/index.orv` when `./components/chip.orv` doesn't exist.
122
+ - **Import cycles:** Two `.orv` files may import each other with `use` (for example `nav.orv` importing screens from `app.orv` while `app.orv` imports `Nav`).
123
+ - **Component children (`slot`):** Put `slot` inside a `component` to place caller children there (for shared layouts):
124
+
125
+ ```orv
126
+ component Layout {
127
+ Column {
128
+ Nav
129
+ slot
130
+ Footer
131
+ }
132
+ }
133
+
134
+ screen Home {
135
+ Layout {
136
+ Heading "Welcome"
137
+ }
138
+ }
139
+ ```
140
+
120
141
  ### State inside a component or screen
121
142
 
122
143
  Put `state` (or `let`) at the top of a `component` or `screen` to give each one
@@ -327,7 +348,10 @@ Other `auth { }` settings: `api: "https://api.example.com"` (a separate API serv
327
348
  | `get(url)` / `post(url, data)` | Get or send data |
328
349
  | `fetch(url, options)` | Full control over a request (`timeout`, `signal`, `headers`, `method`) |
329
350
  | `go(Screen)` / `back(Home?)` | Navigate between screens |
330
- | `sleep(ms)` | Pause inside a function or handler |
351
+ | `openUrl(url)` | Open a screen URL or external `https://`, `mailto:`, `tel:`, `whatsapp:` link |
352
+ | `scrollTo(label, offset)` | Smoothly scroll to the element with that `label:` (`"top"` for the top). `offset` keeps it clear of a sticky header on the web |
353
+ | `platform` | Current platform: `"web"`, `"ios"`, or `"android"` |
354
+ | `sleep(ms)` | Pause inside a function or handler (called `fn`s that sleep are awaited automatically) |
331
355
  | `random(1, 6)` | Random whole number |
332
356
  | `len(list)` | Number of items |
333
357
 
@@ -365,8 +389,8 @@ Choose a value: `done ? "Yes" : "No"`.
365
389
 
366
390
  ## Values
367
391
 
368
- `12`, `3.5`, `"text"`, `"Hi {name}"` (interpolation), `true`, `false`, `null`,
369
- `[1, 2, 3]`, `#1e293b` (colors), `a.b`, `list[0]`, `f(x)`.
392
+ `12`, `3.5`, `"text"`, `"Hi {name}"` (interpolation — write `\{` and `\}` for literal braces), `true`, `false`, `null`,
393
+ `[1, 2, 3]`, `#1e293b` (colors), `a.b`, `list[0]`, `f(x)`, `new ClassName(...)`.
370
394
 
371
395
  Operators: `+ - * / %`, `== != < > <= >=`, `&& || !`.
372
396
 
@@ -475,8 +499,8 @@ Style props work the same way across Web, iPhone, and Android:
475
499
 
476
500
  | Category | Props |
477
501
  |---|---|
478
- | Layout & size | `width` (`120` or `"50%"`), `height`, `minWidth`, `maxWidth`, `minHeight`, `maxHeight`, `padding`, `paddingX`, `paddingY`, `margin`, `gap`, `align`, `justify` (`start`, `center`, `end`, `between`, `around`, `evenly`), `center: true`, `wrap: true`, `scroll: true`, `grow` |
479
- | Appearance | `bg`, `color`, `radius`, `border`, `shadow`, `opacity` |
502
+ | Layout & size | `width` (`120`, `"50%"`, or `"1120px"` fixed), `height`, `minWidth`, `maxWidth`, `minHeight`, `maxHeight`, `padding`, `paddingX`, `paddingY`, `margin`, `gap`, `align`, `justify` (`start`, `center`, `end`, `between`, `around`, `evenly`), `center: true`, `wrap: true`, `scroll: true`, `grow`, `show` (`false` or `{ mobile: false, desktop: true }`) |
503
+ | Appearance | `bg`, `color`, `radius`, `border`, `shadow`, `opacity`, `animate: "ease 0.4s"`, `appear: "fade-up"` (see [Animation](#animation)) |
480
504
  | Text & direction | `size`, `weight`, `font` (`sans`, `serif`, `mono`, or font name), `lineHeight`, `textAlign`, `rtl: true` |
481
505
  | States | `disabled: true`, `loading: true`, `error: true` / `"message"`, `pressed: { ... }`, `focus: { ... }` |
482
506
 
@@ -494,9 +518,56 @@ Column padding: lg, gap: md {
494
518
  ```
495
519
 
496
520
  Use `theme.toggle()`, `theme("dark")`, `theme("light")`, `theme("system")`, or `theme({ mode: "dark", primary: "#6366f1" })`. Buttons with `bg:` automatically get readable text colour unless you set `color:`.
497
- Web-only extras (`columns`, `grid`, `position`, `cursor`, `hover`) still work in browsers and warn clearly when used in iOS/Android builds. Try `npm run dev` and open `/lang.html?app=style`.
521
+ Plain number sizes on the web (like `maxWidth: 1120`) scale fluidly with screen width; quote a CSS unit like `maxWidth: "1120px"` for a fixed pixel size. Web-only extras (`columns`, `grid`, `position`, `cursor`, `hover`) still work in browsers and warn in `orvyn check` and iOS/Android builds. Pass `id:` or `class:` to target an element from a web script, and use `orvyn dev --native` (or `/?native=1`) to preview phone layout rules in the browser. Try `npm run dev` and open `/lang.html?app=style`.
522
+
523
+ ### Animation
524
+
525
+ These props work the same on the web, iPhone and Android:
526
+
527
+ - `animate: "ease 0.4s"` smooths every change to that element, such as `opacity`, size or `bg`. Use `ease`, `linear` or `spring`.
528
+ - `appear: "fade-up"` plays once, when the element is first seen. Presets: `fade`, `fade-up`, `fade-down`, `slide-left`, `slide-right`, `scale`. Add a time and a delay: `appear: "fade-up 0.6s 0.2s"`.
529
+ - `marquee: "left 30s"` on a `Row` slides its items in an endless loop (`left` or `right`, and the time one loop takes). Orvyn adds the second copy itself, so there is no gap. Put the row inside a box with `overflow: "hidden"`.
530
+
531
+ ```orv
532
+ state open = false
533
+
534
+ screen Home {
535
+ Heading "Hello", appear: "fade-up"
536
+ Text "Welcome back", appear: "fade-up 0.6s 0.15s"
537
+ Box bg: open ? primary : card, height: open ? 160 : 60, animate: "spring 0.4s", onTap: open = !open {
538
+ Text "Tap me"
539
+ }
540
+ Text "Thanks for reading", appear: "fade", onVisible: print("read to the end")
541
+ }
542
+ ```
543
+
544
+ `appear` waits until the element scrolls into view, on the web, iPhone and Android. `onVisible:` runs at the same moment, for your own effects. For step-by-step effects such as a typewriter, change `state` in a loop with `sleep()`. People who turn on "reduce motion" on their device see no movement.
545
+
546
+ #### Your own animations
547
+
548
+ Make a new `appear` animation with `animation`. Write how the element **starts**; Orvyn moves it from there to how it normally looks:
549
+
550
+ ```orv
551
+ animation pop { opacity: 0, y: 30, scale: 0.8 }
552
+ animation swing { rotate: -8, x: -40, opacity: 0 }
553
+
554
+ screen Home {
555
+ Heading "Hello", appear: "pop 0.6s"
556
+ Text "Welcome back", appear: "swing 0.8s 0.2s"
557
+ }
558
+ ```
559
+
560
+ | Key | What it means | Example |
561
+ |---|---|---|
562
+ | `opacity` | how see-through it starts (0 = invisible, 1 = solid) | `opacity: 0` |
563
+ | `x` | starts this many points to the right (negative = left) | `x: -40` |
564
+ | `y` | starts this many points lower (negative = higher) | `y: 30` |
565
+ | `scale` | starts this size (1 = normal, 0.5 = half) | `scale: 0.8` |
566
+ | `rotate` | starts turned this many degrees | `rotate: -8` |
567
+
568
+ Leave a key out and it doesn't change. Use it like a built-in: name, then an optional time and delay. It works on the web, iPhone and Android. To share animations between files, put them in one file and bring them in with `use pop from "./animations"`. You can't reuse a built-in name like `fade`.
498
569
 
499
- Events: `onTap`, `onChange`, `onSubmit`, `onHover`, `onLeave`. Give a function name,
570
+ Events: `onTap`, `onChange`, `onSubmit`, `onVisible`, `onHover`, `onLeave`. Give a function name,
500
571
  one statement, or a block:
501
572
 
502
573
  ```orv
@@ -529,7 +600,7 @@ screen About {
529
600
  }
530
601
  ```
531
602
 
532
- - `App` (or the first screen in the file) opens first.
603
+ - `App`, `Home`, or the first screen opens first. Files at `src/pages/<name>/index.orv` containing a matching `screen` (for example `src/pages/blog/index.orv` with `screen Blog`) are discovered as routes automatically.
533
604
  - Pass screen arguments with `go(Detail, { id: 5 })` or `go(Detail, 5)`.
534
605
  - **Safe back (`back(Home)`):** `back()` steps back through history, and passing an optional fallback screen like `back(Home)` goes to `Home` instead if the user arrived from a direct link or page refresh (check `canGoBack()` only if you want custom conditional UI).
535
606
  - **URLs & deep links:** On web, navigating updates the URL (e.g. `#/detail?id=5`), so browser Refresh, Back, Forward, and direct links (`/detail/5` or `#/detail?id=5`) work automatically. On phones, `back()` and Android’s Back button / iOS edge swipe step back through history, and deep links like `myapp://detail?id=5` open directly to that screen.
@@ -585,7 +656,7 @@ screen About {
585
656
  }
586
657
  ```
587
658
 
588
- `page` takes `title`, `description`, `image`, `type: "article"`, `author`, `date` and `noindex`. It sets the browser title, link previews, the canonical address and structured data. `Question` shows a question with its answer and marks it up as structured data.
659
+ `page` takes `title`, `description`, `image`, `type` (`"article"`, `"person"`, `"profile"`), `name`, `jobTitle`, `sameAs`, `author`, `date` and `noindex`. It sets the browser title, link previews, the canonical address and structured data (`WebPage`, `Article`, `Person`, or `ProfilePage`). `Question` shows a question with its answer (and accepts `size`, `weight`, `color`, and `layout: row` / `column`) and marks it up as structured data.
589
660
 
590
661
  **Clean addresses.** A site served normally uses `/about` and `/product/5`. Apps opened from a `.html` file keep `#/about`. Old `#/` links still work. Set your host to answer unknown paths with `app.html` (the build makes it): for example `try_files $uri $uri/ /app.html;` in nginx, or `/* /app.html 200` in a Netlify `_redirects` file.
591
662
 
@@ -707,7 +778,7 @@ screen Home {
707
778
  }
708
779
  ```
709
780
 
710
- - Use `wait` with functions that take time: `let data = wait loadThing()`.
781
+ - Use `wait` with functions that take time: `let data = wait loadThing()`, and `new ClassName(...)` for JavaScript classes.
711
782
  - On iPhone and Android only plain JavaScript works: a library that needs the browser page (`document`, `window`) or Node won't run there.
712
783
  - Libraries give you functions and values, not native components or React components.
713
784
  - The iPhone app's engine has no `crypto`, `fetch`, `URL` or other browser extras, so some packages (`nanoid`, for one) fail there while working on the web. `orvyn test` shows this early. Use such packages on the server instead.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orvyn-lang",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Orvyn — one language for web, iPhone and Android. Write .orv files once, get a website and native apps.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/cli/orvyn.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  statSync,
9
9
  writeFileSync
10
10
  } from "node:fs"
11
- import { join, relative } from "node:path"
11
+ import { basename, join, relative, resolve } from "node:path"
12
12
 
13
13
  const cwd = process.cwd()
14
14
 
@@ -169,7 +169,8 @@ async function compileOrv(mode, commandArgs) {
169
169
  const { compile, OrvynSyntaxError } =
170
170
  await import("../lang/index.js")
171
171
 
172
- const source = readFileSync(file, "utf-8")
172
+ const { withPageFiles } = await import("../lang/page-files.js")
173
+ const source = withPageFiles(readFileSync(file, "utf-8"), file)
173
174
 
174
175
  let env
175
176
  try {
@@ -185,10 +186,17 @@ async function compileOrv(mode, commandArgs) {
185
186
  const code = compile(source, { env, tests: mode === "check", resolveImport: readImportFrom(file) })
186
187
 
187
188
  if (mode === "check") {
188
- const { parse } = await import("../lang/parser.js")
189
- const { checkAccessibility } = await import("../lang/a11y.js")
190
- const warnings = checkAccessibility(parse(source))
191
- for (const warning of warnings) log(`⚠ ${file}:${warning.line}:${warning.col} ${warning.message}`)
189
+ const { collectProjectPrograms } = await import("../lang/page-files.js")
190
+ const { checkProjectAccessibility } = await import("../lang/a11y.js")
191
+ const { checkNativeCompatibility } = await import("../lang/native/compatibility.js")
192
+ const { checkStyleProps } = await import("../lang/style-check.js")
193
+ const files = collectProjectPrograms(file)
194
+ const warnings = [
195
+ ...checkProjectAccessibility(files),
196
+ ...files.flatMap(item => checkStyleProps(item.program).map(warning => ({ ...warning, file: item.file }))),
197
+ ...files.flatMap(item => checkNativeCompatibility(item.program).map(warning => ({ ...warning, file: item.file })))
198
+ ]
199
+ for (const warning of warnings) log(`⚠ ${relative(cwd, warning.file) || warning.file}:${warning.line}:${warning.col} ${warning.message}`)
192
200
  log(`✓ ${file} has no errors${warnings.length ? `, ${warnings.length} warning(s)` : ""}`)
193
201
  } else if (outFile) {
194
202
  writeFileSync(outFile, code)
@@ -295,20 +303,21 @@ function newOrvProject(name) {
295
303
  process.exit(1)
296
304
  }
297
305
 
298
- const dir = join(cwd, name)
306
+ const dir = resolve(cwd, name)
299
307
  if (existsSync(dir) && readdirSync(dir).length > 0) {
300
308
  log(`Folder "${name}" already exists and is not empty.`)
301
309
  process.exit(1)
302
310
  }
303
311
 
312
+ const folderName = basename(dir) || "my-app"
304
313
  const orvynRoot = join(new URL(".", import.meta.url).pathname, "..", "..")
305
314
  const orvynPkg = JSON.parse(readFileSync(join(orvynRoot, "package.json"), "utf-8"))
306
315
  const orvynVersion = orvynPkg.version
307
316
  // from the repo (npm link) the package is "orvyn"; from npm it's "orvyn-lang"
308
317
  const fromSource = existsSync(join(orvynRoot, "src", "lang", "index.ts"))
309
318
  const orvynName = orvynPkg.name
310
- const pretty = name.replace(/[-_]+/g, " ").replace(/\b\w/g, c => c.toUpperCase())
311
- const id = name.toLowerCase().replace(/[^a-z0-9]/g, "")
319
+ const pretty = folderName.replace(/[-_]+/g, " ").replace(/\b\w/g, c => c.toUpperCase())
320
+ const id = folderName.toLowerCase().replace(/[^a-z0-9]/g, "")
312
321
 
313
322
  const orvynDep = fromSource
314
323
  ? `file:${relative(dir, orvynRoot) || "."}`
@@ -542,7 +551,10 @@ if (command === "build" && args[0] === "server") {
542
551
  const { doctor, formatChecks } = await import("../lang/doctor.js")
543
552
  log(formatChecks(await doctor(cwd)))
544
553
  } else if (command === "web-dev") {
545
- run(viteBinary(), args)
554
+ const nativePreview = args.includes("--native")
555
+ const devArgs = args.filter(arg => arg !== "--native")
556
+ if (nativePreview && !devArgs.includes("--open")) devArgs.push("--open", "/?native=1")
557
+ run(viteBinary(), devArgs)
546
558
  } else if (command === "web-build") {
547
559
  // dist/web so it never deletes dist/ios or dist/android
548
560
  runSync(viteBinary(), ["build", "--outDir", "dist/web", "--emptyOutDir", ...args])
@@ -552,6 +564,9 @@ if (command === "build" && args[0] === "server") {
552
564
  const { loadEnv } = await import("../lang/env.js")
553
565
  const files = await prerender(cwd, orvEntry, join(cwd, "dist/web"), await loadEnv(cwd, "prod"))
554
566
  log(`[Orvyn] ✓ Ready-made pages for search engines: ${files.join(", ")}`)
567
+ if (!files.includes("sitemap.xml") && !existsSync(join(cwd, "public", "sitemap.xml"))) {
568
+ log('[Orvyn] Tip: set site: "https://your-domain.com" in orvyn.config.js to generate sitemap.xml and canonical links.')
569
+ }
555
570
  } catch (error) {
556
571
  log(`[Orvyn] ✗ Could not make ready-made pages: ${error.message}`)
557
572
  process.exit(1)
package/src/lang/a11y.js CHANGED
@@ -18,10 +18,9 @@ function literal(expr) {
18
18
  if (expr.kind === "String" && expr.parts.length === 1 && typeof expr.parts[0] === "string") return expr.parts[0];
19
19
  return null;
20
20
  }
21
- function rgb(value) {
21
+ function rgb(value, colors, consts = {}) {
22
22
  if (!value) return null;
23
- const colors = theme().colors;
24
- let hex = (colors[value] ?? NAMED[value] ?? value).replace("#", "");
23
+ let hex = (colors[value] ?? consts[value] ?? NAMED[value] ?? value).replace("#", "");
25
24
  if (hex.length === 3) hex = [...hex].map((c) => c + c).join("");
26
25
  return /^[0-9a-fA-F]{6}$/.test(hex) ? [0, 2, 4].map((i) => parseInt(hex.slice(i, i + 2), 16)) : null;
27
26
  }
@@ -30,8 +29,39 @@ function contrast(a, b) {
30
29
  const [high, low] = [light(a), light(b)].sort((x, y) => y - x);
31
30
  return (high + 0.05) / (low + 0.05);
32
31
  }
33
- function checkAccessibility(program) {
32
+ function extractThemePalette(programs) {
33
+ const colors = { ...theme().colors };
34
+ const consts = {};
35
+ const hex = (value) => value && /^#[0-9a-fA-F]{3,6}$/.test(value) ? value : null;
36
+ for (const program of programs) {
37
+ for (const decl of program.body) {
38
+ if (decl.kind === "Const" || decl.kind === "State") {
39
+ const value = hex(literal(decl.init));
40
+ if (value) consts[decl.name] = value;
41
+ }
42
+ }
43
+ }
44
+ for (const program of programs) {
45
+ for (const decl of program.body) {
46
+ if (decl.kind !== "Start" && decl.kind !== "Fn") continue;
47
+ for (const stmt of decl.body) {
48
+ const call = stmt.kind === "ExprStmt" ? stmt.expr : null;
49
+ if (call?.kind !== "Call" || call.callee.kind !== "Ident" || call.callee.name !== "theme") continue;
50
+ const palette = call.args[0];
51
+ if (palette?.kind !== "Object") continue;
52
+ for (const entry of palette.entries) {
53
+ const raw = literal(entry.value);
54
+ const value = hex(raw) ?? (raw ? consts[raw] ?? null : null);
55
+ if (value) colors[entry.key] = value;
56
+ }
57
+ }
58
+ }
59
+ }
60
+ return { colors, consts };
61
+ }
62
+ function checkAccessibility(program, palette = extractThemePalette([program]), options = { checkSeo: true }) {
34
63
  const warnings = [];
64
+ const { colors, consts } = palette;
35
65
  const visit = (node, background) => {
36
66
  if (node.kind === "ViewIf") {
37
67
  node.then.forEach((n) => visit(n, background));
@@ -60,8 +90,8 @@ function checkAccessibility(program) {
60
90
  const color = literal(prop("color"));
61
91
  const onButton = node.name === "Button" && has("bg");
62
92
  if (color && ["Text", "Heading", "Button", "Link", "SubmitButton", "Checkbox", "Switch"].includes(node.name)) {
63
- const front = rgb(color);
64
- const back = rgb(ownBackground);
93
+ const front = rgb(color, colors, consts);
94
+ const back = rgb(ownBackground, colors, consts);
65
95
  const size = Number(literal(prop("size")) ?? (prop("size")?.kind === "Number" ? prop("size").value : 0));
66
96
  const needed = node.name === "Heading" || size >= 24 || onButton ? 3 : 4.5;
67
97
  if (front && back) {
@@ -71,16 +101,26 @@ function checkAccessibility(program) {
71
101
  }
72
102
  node.children.forEach((child) => visit(child, ownBackground));
73
103
  };
74
- const screens = program.body.filter((d) => d.kind === "Screen" && d.type === "screen");
75
- const usesPage = screens.some((s) => s.page);
104
+ if (options.checkSeo !== false) {
105
+ const screens = program.body.filter((d) => d.kind === "Screen" && d.type === "screen").map((screen) => ({ screen }));
106
+ warnings.push(...checkSeo(screens));
107
+ }
108
+ for (const decl of program.body) {
109
+ if (decl.kind === "Screen") decl.body.forEach((node) => visit(node, "bg"));
110
+ }
111
+ return warnings;
112
+ }
113
+ function checkSeo(screens) {
114
+ const warnings = [];
115
+ const usesPage = screens.some((item) => item.screen.page);
76
116
  const titles = /* @__PURE__ */ new Map();
77
- for (const screen of screens) {
117
+ for (const { file, screen } of screens) {
78
118
  if (!usesPage || screen.requiresAuth || ["NotFound", "ErrorPage"].includes(screen.name)) continue;
79
119
  const field = (key) => {
80
120
  const value = screen.page?.find((p) => p.key === key)?.value;
81
121
  return value?.kind === "Expr" ? value.expr : void 0;
82
122
  };
83
- const warn = (message) => warnings.push({ line: screen.line, col: screen.col, message: `SEO: ${message}` });
123
+ const warn = (message) => warnings.push({ ...file ? { file } : {}, line: screen.line, col: screen.col, message: `SEO: ${message}` });
84
124
  for (const key of ["title", "description"]) {
85
125
  if (!field(key)) warn(`screen ${screen.name} has no ${key}. Add: page title: "...", description: "..."`);
86
126
  }
@@ -91,12 +131,22 @@ function checkAccessibility(program) {
91
131
  titles.set(title, screen.name);
92
132
  }
93
133
  }
94
- for (const decl of program.body) {
95
- if (decl.kind === "Screen") decl.body.forEach((node) => visit(node, "bg"));
134
+ return warnings;
135
+ }
136
+ function checkProjectAccessibility(files) {
137
+ const palette = extractThemePalette(files.map((f) => f.program));
138
+ const byScreen = files.flatMap(
139
+ ({ file, program }) => program.body.filter((d) => d.kind === "Screen" && d.type === "screen").map((screen) => ({ file, screen }))
140
+ );
141
+ const warnings = checkSeo(byScreen);
142
+ for (const { file, program } of files) {
143
+ warnings.push(...checkAccessibility(program, palette, { checkSeo: false }).map((w) => ({ ...w, file })));
96
144
  }
97
145
  return warnings;
98
146
  }
99
147
  export {
100
148
  checkAccessibility,
101
- contrast
149
+ checkProjectAccessibility,
150
+ contrast,
151
+ extractThemePalette
102
152
  };