@valancex/cli 0.0.0-stage → 0.11.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.
Files changed (84) hide show
  1. package/README.md +263 -2
  2. package/bin/vlx.js +4 -0
  3. package/dist/add.d.ts +20 -0
  4. package/dist/add.js +143 -0
  5. package/dist/args.d.ts +20 -0
  6. package/dist/args.js +78 -0
  7. package/dist/author.d.ts +4 -0
  8. package/dist/author.js +30 -0
  9. package/dist/build.d.ts +14 -0
  10. package/dist/build.js +70 -0
  11. package/dist/check.d.ts +8 -0
  12. package/dist/check.js +37 -0
  13. package/dist/cli.d.ts +1 -0
  14. package/dist/cli.js +280 -0
  15. package/dist/compile.d.ts +51 -0
  16. package/dist/compile.js +217 -0
  17. package/dist/config.d.ts +20 -0
  18. package/dist/config.js +99 -0
  19. package/dist/content.d.ts +12 -0
  20. package/dist/content.js +193 -0
  21. package/dist/contract.d.ts +31 -0
  22. package/dist/contract.js +45 -0
  23. package/dist/delegate.d.ts +2 -0
  24. package/dist/delegate.js +23 -0
  25. package/dist/dev.d.ts +21 -0
  26. package/dist/dev.js +250 -0
  27. package/dist/diagnostics.d.ts +16 -0
  28. package/dist/diagnostics.js +16 -0
  29. package/dist/emit.d.ts +13 -0
  30. package/dist/emit.js +107 -0
  31. package/dist/init.d.ts +69 -0
  32. package/dist/init.js +185 -0
  33. package/dist/markdown.d.ts +20 -0
  34. package/dist/markdown.js +185 -0
  35. package/dist/node.d.ts +10 -0
  36. package/dist/node.js +6 -0
  37. package/dist/outline.d.ts +17 -0
  38. package/dist/outline.js +88 -0
  39. package/dist/project.d.ts +8 -0
  40. package/dist/project.js +20 -0
  41. package/dist/targets.d.ts +9 -0
  42. package/dist/targets.js +2 -0
  43. package/dist/tree.d.ts +47 -0
  44. package/dist/tree.js +149 -0
  45. package/dist/tty.d.ts +13 -0
  46. package/dist/tty.js +4 -0
  47. package/dist/ui/Spinner.d.ts +3 -0
  48. package/dist/ui/Spinner.js +16 -0
  49. package/dist/ui/init.d.ts +22 -0
  50. package/dist/ui/init.js +137 -0
  51. package/dist/ui/prompts.d.ts +39 -0
  52. package/dist/ui/prompts.js +98 -0
  53. package/dist/ui/report.d.ts +31 -0
  54. package/dist/ui/report.js +30 -0
  55. package/dist/ui/run.d.ts +15 -0
  56. package/dist/ui/run.js +75 -0
  57. package/dist/vite.d.ts +7 -0
  58. package/dist/vite.js +49 -0
  59. package/dist/wiring.d.ts +108 -0
  60. package/dist/wiring.js +330 -0
  61. package/package.json +69 -3
  62. package/schemas/valance.schema.json +14 -0
  63. package/schemas/valance.web.schema.json +14 -0
  64. package/templates/web/README.md +14 -0
  65. package/templates/web/content/404.md +7 -0
  66. package/templates/web/content/guide/getting-started.md +33 -0
  67. package/templates/web/content/guide/writing-pages.md +21 -0
  68. package/templates/web/content/index.md +16 -0
  69. package/templates/web/gitignore +4 -0
  70. package/templates/web/public/logo.svg +1 -0
  71. package/templates/web/src/layout.mprx +27 -0
  72. package/templates/web/src/main.ts +20 -0
  73. package/templates/web/src/styles.css +28 -0
  74. package/templates/web/src/theme-toggle.mprx +1 -0
  75. package/templates/web/src/theme-toggle.ts +10 -0
  76. package/templates/web/tsconfig.json +18 -0
  77. package/views/block.mprx +3 -0
  78. package/views/blocks.mprx +3 -0
  79. package/views/heading.mprx +3 -0
  80. package/views/inline.mprx +3 -0
  81. package/views/layout.mprx +26 -0
  82. package/views/list-block.mprx +5 -0
  83. package/views/list-items.mprx +3 -0
  84. package/views/runs.mprx +3 -0
@@ -0,0 +1,21 @@
1
+ ---
2
+ title: Writing pages
3
+ description: Front matter, headings, links and images.
4
+ order: 2
5
+ ---
6
+
7
+ # Writing pages
8
+
9
+ A page starts with an optional block of settings, then Markdown.
10
+
11
+ ## Front matter
12
+
13
+ `title`, `description` and `order` are the three settings. Without a `title`, the first `#` heading is used.
14
+
15
+ > Anything else in the front matter is an error, so a typo never goes unnoticed.
16
+
17
+ ## Links and images
18
+
19
+ Link to another page by its address, like [Getting started](/guide/getting-started), or by its file, like [the first page](./getting-started.md). A link that leads nowhere fails the build and names the line.
20
+
21
+ Images live in `public/` and are named from the site's root: `![Alt text](/logo.svg)`.
@@ -0,0 +1,16 @@
1
+ ---
2
+ title: {{name}}
3
+ description: A small documentation site, written the way a VALANCE application is written.
4
+ ---
5
+
6
+ # {{name}}
7
+
8
+ ![The {{name}} logo](/logo.svg)
9
+
10
+ This site is a **VALANCE application**. Everything you are reading is a Markdown file in `content/`; the page around it is `src/layout.mprx`; the look is `src/styles.css`.
11
+
12
+ - Pages are Markdown files. Their path is their address.
13
+ - The layout and the components are templates.
14
+ - `vlx dev` serves the site and updates it as you edit.
15
+
16
+ Start with [Getting started](/guide/getting-started), or see [how a page is written](/guide/writing-pages#front-matter).
@@ -0,0 +1,4 @@
1
+ node_modules
2
+ dist
3
+ .valance
4
+ .work*
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64" role="img" aria-label="{{name}}"><rect width="64" height="64" rx="14" fill="#5b3fd6"/><path d="M18 20h28M18 32h28M18 44h18" stroke="#fff" stroke-width="5" stroke-linecap="round"/></svg>
@@ -0,0 +1,27 @@
1
+ <shell class="layout" theme={theme}>
2
+ <header class="bar">
3
+ <link class="brand" href={home} current="false">{site}</link>
4
+ <theme-toggle theme={theme} on.toggle={toggleTheme()} />
5
+ </header>
6
+ <div class="frame">
7
+ <nav class="sidebar" label="Pages">
8
+ {#each sections as s (s.id)}
9
+ <section>
10
+ {#if s.title != ""}<para class="nav-title">{s.title}</para>{/if}
11
+ <list class="nav-list">
12
+ {#each s.items as n (n.id)}
13
+ <item><link class="nav-link" href={n.href} current={n.current}>{n.label}</link></item>
14
+ {/each}
15
+ </list>
16
+ </section>
17
+ {/each}
18
+ </nav>
19
+ <main id="content" tabindex="-1">
20
+ <blocks items={blocks} />
21
+ <nav class="pager" label="Previous and next page">
22
+ {#if prev.href != ""}<link class="pager-link" href={prev.href} current="false">{prev.label}</link>{/if}
23
+ {#if next.href != ""}<link class="pager-link" href={next.href} current="false">{next.label}</link>{/if}
24
+ </nav>
25
+ </main>
26
+ </div>
27
+ </shell>
@@ -0,0 +1,20 @@
1
+ import { component, defineApp, field } from "@valancex/common";
2
+ import { Schema } from "effect";
3
+ import layout from "./layout.mprx";
4
+ import themeToggle from "./theme-toggle.js";
5
+
6
+ // The application, from the top. `layout` is the page's shell; `components` lists the components your templates use, once each: a template uses one by writing its tag. Nothing under src/ is part of
7
+ // the application unless it is imported here and listed. A component states its own interface where it is defined (see theme-toggle.ts).
8
+ export default defineApp({
9
+ layout: component(layout),
10
+ components: [themeToggle],
11
+
12
+ // The application's own state, beyond "which page is shown": each field is its type and its default, together. A field is a name the layout can read (`theme`), and the commands below are
13
+ // names it can run (`toggleTheme()`).
14
+ state: {
15
+ theme: field(Schema.Literal("light", "dark"), "light"),
16
+ },
17
+ commands: (command) => ({
18
+ toggleTheme: command((state) => ({ ...state, theme: state.theme === "light" ? "dark" : "light" })),
19
+ }),
20
+ });
@@ -0,0 +1,28 @@
1
+ :root { --bg: #fff; --fg: #1d2330; --muted: #5c6578; --line: #e3e6ee; --accent: #5b3fd6; --code: #f4f5f9; }
2
+ [data-theme="dark"] { --bg: #12141b; --fg: #e8eaf1; --muted: #9aa3b8; --line: #272b38; --accent: #a78bfa; --code: #1b1e29; }
3
+
4
+ * { box-sizing: border-box; }
5
+ body { margin: 0; font: 16px/1.6 system-ui, sans-serif; background: var(--bg); color: var(--fg); }
6
+ .layout { min-height: 100vh; background: var(--bg); color: var(--fg); }
7
+
8
+ .bar { display: flex; align-items: center; justify-content: space-between; padding: 0.75rem 1.5rem; border-bottom: 1px solid var(--line); }
9
+ .brand { font-weight: 700; color: var(--fg); text-decoration: none; }
10
+ .theme-toggle { font: inherit; padding: 0.25rem 0.75rem; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--fg); cursor: pointer; }
11
+
12
+ .frame { display: grid; grid-template-columns: 14rem 1fr; gap: 2rem; max-width: 60rem; margin: 0 auto; padding: 1.5rem; }
13
+ .sidebar { font-size: 0.95rem; }
14
+ .nav-title { margin: 1rem 0 0.25rem; font-weight: 600; color: var(--muted); text-transform: uppercase; font-size: 0.75rem; letter-spacing: 0.05em; }
15
+ .nav-list { list-style: none; margin: 0; padding: 0; }
16
+ .nav-link { display: block; padding: 0.15rem 0; color: var(--fg); text-decoration: none; }
17
+ .nav-link[aria-current="page"] { color: var(--accent); font-weight: 600; }
18
+
19
+ main { min-width: 0; }
20
+ main h1 { margin-top: 0; }
21
+ a { color: var(--accent); }
22
+ .code { padding: 1rem; overflow-x: auto; background: var(--code); border-radius: 0.5rem; }
23
+ code { font-family: ui-monospace, monospace; font-size: 0.9em; }
24
+ .quote { margin: 1rem 0; padding-left: 1rem; border-left: 3px solid var(--accent); color: var(--muted); }
25
+ .picture { max-width: 100%; }
26
+ .pager { display: flex; justify-content: space-between; margin-top: 3rem; padding-top: 1rem; border-top: 1px solid var(--line); }
27
+
28
+ @media (max-width: 40rem) { .frame { grid-template-columns: 1fr; } }
@@ -0,0 +1 @@
1
+ <button class="theme-toggle" pressed={theme == "dark" ? "true" : "false"} on.click={toggle()}>{theme == "dark" ? "Light" : "Dark"}</button>
@@ -0,0 +1,10 @@
1
+ import { component } from "@valancex/common";
2
+ import { Schema } from "effect";
3
+ import template from "./theme-toggle.mprx";
4
+
5
+ // The interface of `<theme-toggle>`, stated once, where it is defined: what the template reads (`theme`) and what it raises (`toggle`, which carries nothing). Whoever uses it names only that
6
+ // they use it. `.valance/templates.d.ts` gives the template its keys as a type, so a contract that disagrees with the template is an error in the editor.
7
+ export default component(template, {
8
+ props: { theme: Schema.Literal("light", "dark") },
9
+ events: { toggle: Schema.Void },
10
+ });
@@ -0,0 +1,18 @@
1
+ {
2
+ "compilerOptions": {
3
+ "types": ["node"],
4
+ "target": "ES2022",
5
+ "module": "NodeNext",
6
+ "moduleResolution": "NodeNext",
7
+ "lib": ["ES2022", "DOM"],
8
+ "strict": true,
9
+ "noUncheckedIndexedAccess": true,
10
+ "exactOptionalPropertyTypes": true,
11
+ "skipLibCheck": true,
12
+ "isolatedModules": true,
13
+ "noEmit": true,
14
+ "allowArbitraryExtensions": true,
15
+ "rootDirs": ["src", ".valance/types"]
16
+ },
17
+ "include": ["src"]
18
+ }
@@ -0,0 +1,3 @@
1
+ <mesh-fragment>
2
+ {#if b.kind == "heading"}<heading level={b.level} anchor={b.anchor} spans={b.spans} />{:else if b.kind == "list"}<list-block ordered={b.ordered} items={b.items} />{:else if b.kind == "code"}<pre class="code" tabindex="0"><code>{b.text}</code></pre>{:else if b.kind == "quote"}<quote class="quote"><runs spans={b.spans} /></quote>{:else if b.kind == "image"}<image class="picture" src={b.src} alt={b.alt} loading="lazy" />{:else}<para class="prose"><runs spans={b.spans} /></para>{/if}
3
+ </mesh-fragment>
@@ -0,0 +1,3 @@
1
+ <mesh-fragment>
2
+ {#each items as b (b.id)}<block b={b} />{/each}
3
+ </mesh-fragment>
@@ -0,0 +1,3 @@
1
+ <mesh-fragment>
2
+ {#if level == 1}<h1 id={anchor}><runs spans={spans} /></h1>{:else if level == 2}<h2 id={anchor}><runs spans={spans} /></h2>{:else}<h3 id={anchor}><runs spans={spans} /></h3>{/if}
3
+ </mesh-fragment>
@@ -0,0 +1,3 @@
1
+ <mesh-fragment>
2
+ {#if kind == "strong"}<strong>{text}</strong>{:else if kind == "emphasis"}<em>{text}</em>{:else if kind == "code"}<code>{text}</code>{:else if kind == "link"}<a href={href}>{text}</a>{:else}<mesh-fragment>{text}</mesh-fragment>{/if}
3
+ </mesh-fragment>
@@ -0,0 +1,26 @@
1
+ <shell class="layout" theme="light">
2
+ <header class="bar">
3
+ <link class="brand" href={home} current="false">{site}</link>
4
+ </header>
5
+ <div class="frame">
6
+ <nav class="sidebar" label="Pages">
7
+ {#each sections as s (s.id)}
8
+ <section>
9
+ {#if s.title != ""}<para class="nav-title">{s.title}</para>{/if}
10
+ <list class="nav-list">
11
+ {#each s.items as n (n.id)}
12
+ <item><link class="nav-link" href={n.href} current={n.current}>{n.label}</link></item>
13
+ {/each}
14
+ </list>
15
+ </section>
16
+ {/each}
17
+ </nav>
18
+ <main id="content" tabindex="-1">
19
+ <blocks items={blocks} />
20
+ <nav class="pager" label="Previous and next page">
21
+ {#if prev.href != ""}<link class="pager-link" href={prev.href} current="false">{prev.label}</link>{/if}
22
+ {#if next.href != ""}<link class="pager-link" href={next.href} current="false">{next.label}</link>{/if}
23
+ </nav>
24
+ </main>
25
+ </div>
26
+ </shell>
@@ -0,0 +1,5 @@
1
+ <mesh-fragment>
2
+ {#if ordered}
3
+ <olist class="list"><list-items items={items} /></olist>{:else}
4
+ <list class="list"><list-items items={items} /></list>{/if}
5
+ </mesh-fragment>
@@ -0,0 +1,3 @@
1
+ <mesh-fragment>
2
+ {#each items as i (i.id)}<item><runs spans={i.spans} /></item>{/each}
3
+ </mesh-fragment>
@@ -0,0 +1,3 @@
1
+ <mesh-fragment>
2
+ {#each spans as s (s.id)}<inline kind={s.kind} text={s.text} href={s.href} />{/each}
3
+ </mesh-fragment>