tutuca 0.14.0 → 1.0.0-beta.1
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/CHANGELOG.md +78 -0
- package/LICENSE +1 -1
- package/README.md +64 -170
- package/{dist → deps}/immer.js +674 -249
- package/dist/tutuca.js +2079 -4293
- package/dist/tutuca.min.js +3 -3
- package/package.json +78 -96
- package/src/component.js +62 -0
- package/src/css/classes.js +77 -0
- package/src/dev/formatters.js +389 -0
- package/src/dev/jsonml.js +35 -0
- package/src/dev/panel.js +400 -0
- package/src/dev/summary.js +238 -0
- package/src/dev/vdom-formatters.js +102 -0
- package/src/drag.js +30 -0
- package/src/embed/element.js +111 -0
- package/src/env.js +30 -0
- package/src/events.js +84 -0
- package/src/history/bar.js +194 -0
- package/src/history/index.js +149 -0
- package/src/host.js +311 -0
- package/src/lint/index.js +443 -0
- package/src/meta.js +12 -0
- package/src/optimize.js +67 -0
- package/src/paths.js +151 -0
- package/src/playground/element.js +361 -0
- package/src/playground/index.js +5 -0
- package/src/playground/sources.js +107 -0
- package/src/playground/ui/playground.js +283 -0
- package/src/schema.js +429 -0
- package/src/scope.js +92 -0
- package/src/storybook/index.js +80 -0
- package/src/storybook/runner.js +452 -0
- package/src/storybook/stories.js +191 -0
- package/src/storybook/stress.js +76 -0
- package/src/storybook/ui/common.js +37 -0
- package/src/storybook/ui/link.js +80 -0
- package/src/storybook/ui/panels.js +32 -0
- package/src/storybook/ui/story-panel.js +426 -0
- package/src/storybook/ui/storybook.js +187 -0
- package/src/storybook/ui/stress-panel.js +227 -0
- package/src/sync/automerge.js +159 -0
- package/src/sync/codec.js +206 -0
- package/src/sync/diff.js +153 -0
- package/src/sync/index.js +97 -0
- package/src/sync/migrate.js +184 -0
- package/src/sync/ops.js +160 -0
- package/src/sync/remote.js +206 -0
- package/src/tag.js +24 -0
- package/src/tasks.js +130 -0
- package/src/test/driver.js +128 -0
- package/src/test/pbt.js +589 -0
- package/src/tutuca.js +49 -0
- package/src/vdom.js +318 -0
- package/src/view.js +369 -0
- package/src/walk.js +79 -0
- package/dist/chai.js +0 -4210
- package/dist/tutuca-cli.js +0 -16683
- package/dist/tutuca-components.js +0 -2232
- package/dist/tutuca-dev.ext.js +0 -8802
- package/dist/tutuca-dev.js +0 -13546
- package/dist/tutuca-dev.min.js +0 -5
- package/dist/tutuca-extra.ext.js +0 -4553
- package/dist/tutuca-extra.js +0 -5256
- package/dist/tutuca-extra.min.js +0 -3
- package/dist/tutuca-storybook.js +0 -970
- package/dist/tutuca.ext.js +0 -4459
- package/skill/margaui/SKILL.md +0 -105
- package/skill/margaui/components/accordion.md +0 -127
- package/skill/margaui/components/alert.md +0 -174
- package/skill/margaui/components/aura.md +0 -97
- package/skill/margaui/components/avatar.md +0 -220
- package/skill/margaui/components/badge.md +0 -193
- package/skill/margaui/components/breadcrumbs.md +0 -103
- package/skill/margaui/components/button.md +0 -322
- package/skill/margaui/components/calendar.md +0 -67
- package/skill/margaui/components/card.md +0 -373
- package/skill/margaui/components/carousel.md +0 -387
- package/skill/margaui/components/chat.md +0 -171
- package/skill/margaui/components/checkbox.md +0 -101
- package/skill/margaui/components/collapse.md +0 -172
- package/skill/margaui/components/countdown.md +0 -165
- package/skill/margaui/components/diff.md +0 -53
- package/skill/margaui/components/divider.md +0 -107
- package/skill/margaui/components/dock.md +0 -173
- package/skill/margaui/components/drawer.md +0 -184
- package/skill/margaui/components/dropdown.md +0 -388
- package/skill/margaui/components/fab.md +0 -346
- package/skill/margaui/components/fieldset.md +0 -88
- package/skill/margaui/components/file-input.md +0 -84
- package/skill/margaui/components/filter.md +0 -52
- package/skill/margaui/components/footer.md +0 -583
- package/skill/margaui/components/hero.md +0 -135
- package/skill/margaui/components/hover-3d.md +0 -129
- package/skill/margaui/components/hover-gallery.md +0 -49
- package/skill/margaui/components/indicator.md +0 -265
- package/skill/margaui/components/input.md +0 -389
- package/skill/margaui/components/join.md +0 -100
- package/skill/margaui/components/kbd.md +0 -127
- package/skill/margaui/components/label.md +0 -102
- package/skill/margaui/components/link.md +0 -96
- package/skill/margaui/components/list.md +0 -182
- package/skill/margaui/components/loading.md +0 -105
- package/skill/margaui/components/mask.md +0 -168
- package/skill/margaui/components/megamenu.md +0 -131
- package/skill/margaui/components/menu.md +0 -887
- package/skill/margaui/components/mockup-browser.md +0 -39
- package/skill/margaui/components/mockup-code.md +0 -81
- package/skill/margaui/components/mockup-phone.md +0 -39
- package/skill/margaui/components/mockup-window.md +0 -33
- package/skill/margaui/components/modal.md +0 -196
- package/skill/margaui/components/navbar.md +0 -282
- package/skill/margaui/components/otp.md +0 -171
- package/skill/margaui/components/pagination.md +0 -122
- package/skill/margaui/components/progress.md +0 -135
- package/skill/margaui/components/radial-progress.md +0 -67
- package/skill/margaui/components/radio.md +0 -133
- package/skill/margaui/components/range.md +0 -134
- package/skill/margaui/components/rating.md +0 -170
- package/skill/margaui/components/select.md +0 -225
- package/skill/margaui/components/skeleton.md +0 -64
- package/skill/margaui/components/stack.md +0 -142
- package/skill/margaui/components/stat.md +0 -254
- package/skill/margaui/components/status.md +0 -73
- package/skill/margaui/components/steps.md +0 -138
- package/skill/margaui/components/swap.md +0 -152
- package/skill/margaui/components/tab.md +0 -248
- package/skill/margaui/components/table.md +0 -1018
- package/skill/margaui/components/text-rotate.md +0 -91
- package/skill/margaui/components/textarea.md +0 -85
- package/skill/margaui/components/theme-controller.md +0 -266
- package/skill/margaui/components/timeline.md +0 -1356
- package/skill/margaui/components/toast.md +0 -165
- package/skill/margaui/components/toggle.md +0 -135
- package/skill/margaui/components/tooltip.md +0 -181
- package/skill/margaui/components/validator.md +0 -163
- package/skill/tutuca/SKILL.md +0 -56
- package/skill/tutuca/advanced.md +0 -292
- package/skill/tutuca/cli.md +0 -239
- package/skill/tutuca/component-design.md +0 -168
- package/skill/tutuca/core.md +0 -934
- package/skill/tutuca/iteration.md +0 -207
- package/skill/tutuca/macros.md +0 -86
- package/skill/tutuca/margaui.md +0 -175
- package/skill/tutuca/messages-and-intents.md +0 -416
- package/skill/tutuca/patterns/README.md +0 -48
- package/skill/tutuca/patterns/add-a-story.md +0 -26
- package/skill/tutuca/patterns/bind-text-and-attributes.md +0 -30
- package/skill/tutuca/patterns/conditional-attribute-value.md +0 -29
- package/skill/tutuca/patterns/coordinate-components.md +0 -54
- package/skill/tutuca/patterns/edit-through-a-dynamic-target.md +0 -32
- package/skill/tutuca/patterns/enrich-each-item.md +0 -25
- package/skill/tutuca/patterns/file-input.md +0 -39
- package/skill/tutuca/patterns/filter-a-list.md +0 -25
- package/skill/tutuca/patterns/filter-and-paginate.md +0 -60
- package/skill/tutuca/patterns/handle-events.md +0 -45
- package/skill/tutuca/patterns/iterate-a-list.md +0 -18
- package/skill/tutuca/patterns/paginate-a-list.md +0 -29
- package/skill/tutuca/patterns/render-a-child-component.md +0 -21
- package/skill/tutuca/patterns/reuse-markup-with-macros.md +0 -36
- package/skill/tutuca/patterns/share-state-across-the-tree.md +0 -53
- package/skill/tutuca/patterns/show-or-hide-content.md +0 -23
- package/skill/tutuca/patterns/switch-between-views.md +0 -30
- package/skill/tutuca/patterns/tabbed-interface.md +0 -43
- package/skill/tutuca/semantics.md +0 -210
- package/skill/tutuca/storybook.md +0 -270
- package/skill/tutuca/styles.md +0 -48
- package/skill/tutuca/testing.md +0 -345
- package/skill/tutuca-source/SKILL.md +0 -33
- package/skill/tutuca-source/tutuca.ext.js +0 -4459
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 1.0.0-beta.1
|
|
4
|
+
|
|
5
|
+
Tutuca 1.0 is a rewrite. It keeps the core ideas of 0.x, but the API, the view language and the
|
|
6
|
+
tooling change a lot, so 0.x apps don't run on it without being ported. The 0.x line ends at
|
|
7
|
+
0.15.0.
|
|
8
|
+
|
|
9
|
+
### What stays the same
|
|
10
|
+
|
|
11
|
+
- **One immutable state tree.** The app state is a tree of component instances, and every
|
|
12
|
+
update replaces the root with a new value. Views are functions of that state.
|
|
13
|
+
- **Handlers mutate a draft.** A handler gets an immer draft and changes it in place.
|
|
14
|
+
Returning a value replaces the component. immer is still vendored, so the core has no npm
|
|
15
|
+
dependencies.
|
|
16
|
+
- **Typed fields and named views.** Components declare typed `fields`, a `main` view plus other
|
|
17
|
+
named views, and `methods` that views and handlers can read.
|
|
18
|
+
- **Rendering through paths.** The DOM holds no references to instances. Events are routed
|
|
19
|
+
through the dispatch path recorded at render time, and the update goes back in through the
|
|
20
|
+
path to the value that owns it.
|
|
21
|
+
- **Messages up, down and across.** A component handles its own events, can send messages to
|
|
22
|
+
components found by a selector, and can raise a message that bubbles up to its parents. A
|
|
23
|
+
request with `Ok` / `Error` replies becomes `ask` with `ReplyOk` / `ReplyError`.
|
|
24
|
+
- **Values passed down without threading them through props.** 0.x's `provide` / `lookup` is
|
|
25
|
+
now `provides` / `lookupBind`.
|
|
26
|
+
- **Iteration with filters and loop state** (`each` and loops, which were `@each`, `@when` and
|
|
27
|
+
`@loop-with`), **pushed views** for nested components, and **drag and drop**.
|
|
28
|
+
- **The checks are part of the library**: a linter, tests that run without a browser, and a
|
|
29
|
+
storybook built from the same component definitions.
|
|
30
|
+
|
|
31
|
+
### What changes
|
|
32
|
+
|
|
33
|
+
- **Views are built in JavaScript, not parsed from HTML.** `h(tag, attrs, ...children)`, the
|
|
34
|
+
`tag` / `button` builders and AST helpers (`field`, `send`, `each`, `render`, `$if`,
|
|
35
|
+
`pushView`, `scope`, ...) replace the `html\`...\`` templates, the `@`/`:` directives and the
|
|
36
|
+
value grammar (`.x`, `$x`, `@x`, `^x`, `*x`). Macros are gone; use JavaScript functions that
|
|
37
|
+
return view nodes.
|
|
38
|
+
- **Explicit schemas.** Field types come from `t.*` (`t.number()`, `t.string()`, `t.array()`,
|
|
39
|
+
`t.option()`, `t.enum()`, `t.record()`, `t.oneOf()`, `t.map()`, `t.component()`, ...) rather than being inferred
|
|
40
|
+
from default values. They feed validation, the lint, property-based tests and sync.
|
|
41
|
+
- **Handlers.** `receive` and `intent` merge into one `on` table. A handler is called as
|
|
42
|
+
`handler(next, args, ctx)`, with `next` being the draft, and can declare a contract (`args`,
|
|
43
|
+
`sourceKey`, `pre`, `post`, `emits`). Components can declare `invariants`. Contracts and
|
|
44
|
+
invariants are checked in development and in tests.
|
|
45
|
+
- **The host.** `tutuca("#app")`, `registerComponents` and `app.state.set` are replaced by
|
|
46
|
+
`new Host({ document, rootNode })`, `host.scope.register({...})` and `host.start(instance)`.
|
|
47
|
+
Scopes nest, and they also hold the handlers that answer `ask`.
|
|
48
|
+
- **A controlled world.** Handlers read time and randomness through `ctx.now()`,
|
|
49
|
+
`ctx.random()` and `ctx.uuid()`, so test runs and sync replays repeat.
|
|
50
|
+
- **Styling.** The scoped `style` / `commonStyle` / `globalStyle` CSS is gone. `tutuca/classes`
|
|
51
|
+
lists the class names a view uses, for CSS tools that need them.
|
|
52
|
+
- **Packaging.** The package ships its ES module sources (`src/`) with one export per area
|
|
53
|
+
(`tutuca`, `/vdom`, `/dev`, `/lint`, `/classes`, `/pbt`, `/storybook`, `/element`,
|
|
54
|
+
`/playground`, `/history`, `/sync`, `/sync/remote`, `/automerge`). The CDN bundles are
|
|
55
|
+
`dist/tutuca.js` and `dist/tutuca.min.js`. jsdom, prettier and chai are no longer
|
|
56
|
+
dependencies. `fast-check` and `@automerge/automerge` are optional peers.
|
|
57
|
+
- **Removed:** the `tutuca` CLI (`get`, `list`, `show`, `lint`, `render`, `test`,
|
|
58
|
+
`storybook`, `install-skill`, `agent-context`, ...), the bundled agent skill, the
|
|
59
|
+
`tutuca/components` inspector components, the `getTests()` / `getExamples()` module
|
|
60
|
+
conventions and the `.dev.js` auto-discovery. The linter, tests and storybook are now used
|
|
61
|
+
as libraries.
|
|
62
|
+
|
|
63
|
+
### New
|
|
64
|
+
|
|
65
|
+
- **Property-based testing** (`tutuca/pbt`): arbitraries generated from field schemas and a
|
|
66
|
+
headless `Driver` that runs message sequences and shrinks failures.
|
|
67
|
+
- **Sync** (`tutuca/sync`, `tutuca/sync/remote`, `tutuca/automerge`): a schema-guided diff,
|
|
68
|
+
per-field sync levels and pluggable engines that persist state or share it across tabs and
|
|
69
|
+
devices. State saved by another version of the components is adapted and reported. See
|
|
70
|
+
[`docs/sync.md`](docs/sync.md).
|
|
71
|
+
- **History** (`tutuca/history`, `tutuca/history/bar`): step through states one user action
|
|
72
|
+
at a time. Going back is applied as a change, so storage and peers follow.
|
|
73
|
+
- **Storybook stress tests**, with a log of each run and its shrink attempts.
|
|
74
|
+
- **`<tutuca-app>`** (`tutuca/element`) and **`<tutuca-playground>`**
|
|
75
|
+
(`tutuca/playground`), which edits a book of stories in CodeMirror and runs it live, keeping
|
|
76
|
+
state across edits.
|
|
77
|
+
- **DevTools formatters and an inspector panel** (`tutuca/dev`).
|
|
78
|
+
- **A formal model** of the semantics in PLT Redex (`spec/`), kept in sync with `src/`.
|
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,193 +1,87 @@
|
|
|
1
1
|
# Tutuca
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
- **Single file, no build, no dependencies, no setup** — a script tag is all you need
|
|
6
|
-
- **Batteries included** — state management, side effects, automatic memoization, drag and drop, testing, CLI tooling, LLM skills and more
|
|
7
|
-
- **Fits in your head** (and the context window)
|
|
8
|
-
- **View source friendly** — step through the whole stack
|
|
9
|
-
- **As much HTML as possible, as little JS as needed**
|
|
10
|
-
- ~110KB minified, ~29KB brotli compressed (the core browser bundle; the dev build adds linting and test helpers)
|
|
11
|
-
|
|
12
|
-
## Quick Start
|
|
13
|
-
|
|
14
|
-
For an interactive walk-through with editable examples, see the
|
|
15
|
-
[tutorial](https://marianoguerra.github.io/tutuca/tutorial.html).
|
|
16
|
-
Upgrading an Immutable.js-based app? See the
|
|
17
|
-
[Immer migration guide](./docs/immer-migration.md).
|
|
18
|
-
|
|
19
|
-
### CDN (no install)
|
|
20
|
-
|
|
21
|
-
```html
|
|
22
|
-
<!doctype html>
|
|
23
|
-
<html lang="en">
|
|
24
|
-
<head>
|
|
25
|
-
<meta charset="UTF-8" />
|
|
26
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
27
|
-
<title>Tutuca: Getting Started</title>
|
|
28
|
-
</head>
|
|
29
|
-
<body>
|
|
30
|
-
<div id="app"></div>
|
|
31
|
-
<script type="module">
|
|
32
|
-
import { component, html, tutuca } from "https://cdn.jsdelivr.net/npm/tutuca/+esm";
|
|
33
|
-
|
|
34
|
-
const Counter = component({
|
|
35
|
-
name: "Counter",
|
|
36
|
-
fields: {
|
|
37
|
-
count: 0,
|
|
38
|
-
},
|
|
39
|
-
receive: {
|
|
40
|
-
inc(draft) {
|
|
41
|
-
draft.count++;
|
|
42
|
-
},
|
|
43
|
-
dec(draft) {
|
|
44
|
-
draft.count--;
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
view: html`<div>
|
|
48
|
-
<button @on.click="dec">-</button>
|
|
49
|
-
<div @text=".count"></div>
|
|
50
|
-
<button @on.click="inc">+</button>
|
|
51
|
-
</div>`,
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
function main() {
|
|
55
|
-
const app = tutuca("#app");
|
|
56
|
-
app.state.set(Counter.make({}));
|
|
57
|
-
app.registerComponents([Counter]);
|
|
58
|
-
app.start();
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
main();
|
|
62
|
-
</script>
|
|
63
|
-
</body>
|
|
64
|
-
</html>
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
## Concepts at a Glance
|
|
68
|
-
|
|
69
|
-
Each concept has a tutorial section with editable live examples:
|
|
70
|
-
|
|
71
|
-
- **[Components & state](https://marianoguerra.github.io/tutuca/tutorial.html#basics)** —
|
|
72
|
-
typed `fields`, Immer draft-first handlers, and views as pure functions of a
|
|
73
|
-
single immutable state tree
|
|
74
|
-
([state & updates](https://marianoguerra.github.io/tutuca/tutorial.html#state-and-updates))
|
|
75
|
-
- **[Collections](https://marianoguerra.github.io/tutuca/tutorial.html#collections)** —
|
|
76
|
-
iterate with `@each`, filter with `@when`, paginate with `@loop-with`
|
|
77
|
-
- **[Rendering components](https://marianoguerra.github.io/tutuca/tutorial.html#rendering-components)** —
|
|
78
|
-
compose with `<x render>`, multiple views per component, scoped styles
|
|
79
|
-
- **[Component communication](https://marianoguerra.github.io/tutuca/tutorial.html#component-communication)** —
|
|
80
|
-
send messages to a target, or raise an intent and let a route find whoever
|
|
81
|
-
answers it
|
|
82
|
-
- **[Macros](https://marianoguerra.github.io/tutuca/tutorial.html#macros)** —
|
|
83
|
-
reusable markup fragments with parameters and slots
|
|
84
|
-
- **[Escape hatches](https://marianoguerra.github.io/tutuca/tutorial.html#escape-hatches)** —
|
|
85
|
-
drag and drop, web components, raw HTML
|
|
86
|
-
- **[Testing](https://marianoguerra.github.io/tutuca/tutorial.html#testing)** —
|
|
87
|
-
`getTests()` suites run by the CLI or in the browser, plus a
|
|
88
|
-
[linter](https://marianoguerra.github.io/tutuca/tutorial.html#linter-reference)
|
|
89
|
-
that catches template mistakes before they render blank
|
|
90
|
-
|
|
91
|
-
## CLI
|
|
92
|
-
|
|
93
|
-
Tutuca ships a single-file CLI (`dist/tutuca-cli.js`) for inspecting, linting,
|
|
94
|
-
documenting, and rendering components defined in an ES module. The module just
|
|
95
|
-
needs to export `getComponents()` and, for render-time commands, `getExamples()`
|
|
96
|
-
in the storybook shape `{ title, description?, items: [{ title, description?, value, view? }] }` (a single section, or an array of sections).
|
|
97
|
-
Expose **all** of your app's components through `getComponents()` — components
|
|
98
|
-
left out are invisible to `lint`/`render`/`test` and silently lose coverage.
|
|
99
|
-
|
|
100
|
-
### Setup
|
|
101
|
-
|
|
102
|
-
```sh
|
|
103
|
-
npm install --save-dev tutuca
|
|
104
|
-
```
|
|
3
|
+
A small framework for web apps in the browser, small enough to read in full, for people and for
|
|
4
|
+
coding agents.
|
|
105
5
|
|
|
106
|
-
|
|
6
|
+
Tutuca covers components, typed state, rendering and event handling, and the tools to check them:
|
|
7
|
+
tests that run without a browser, property-based tests generated from your field types, a
|
|
8
|
+
storybook with stress tests, and a linter. State changes can be saved or shared with other tabs
|
|
9
|
+
and devices through sync engines you plug in ([`docs/sync.md`](docs/sync.md)). A formal model of
|
|
10
|
+
the semantics is being written in PLT Redex (`spec/`). The core is about 2,000 lines of
|
|
11
|
+
JavaScript with no npm dependencies (it includes a copy of immer).
|
|
107
12
|
|
|
108
|
-
|
|
13
|
+
- Site: https://marianoguerra.github.io/tutuca/
|
|
14
|
+
- Storybook: https://marianoguerra.github.io/tutuca/storybook.html
|
|
109
15
|
|
|
110
|
-
|
|
111
|
-
tutuca <command> <module-path> [args] [flags]
|
|
112
|
-
tutuca help [command]
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
| Command | What it does |
|
|
116
|
-
|---|---|
|
|
117
|
-
| `get <module>` | Export inventory and counts for the module |
|
|
118
|
-
| `list <module> [name] [--limit n]` | List components and their fields/views (`--limit n` caps, `0` = all) |
|
|
119
|
-
| `examples <module> [--limit n]` | List the examples defined in the module's section (`--limit n` caps, `0` = all) |
|
|
120
|
-
| `show <module> [name]` | Component API docs — all, or one by name |
|
|
121
|
-
| `lint <module> [name]` | Run lint checks — all, or one by name (exit `2` on errors) |
|
|
122
|
-
| `render <module> [name] [--title t] [--view v]` | Render examples to HTML (exit `3` on render crash) |
|
|
123
|
-
| `test <module> [name] [--grep p] [--bail]` | Run `getTests()` (exit `4` on failures) |
|
|
124
|
-
| `storybook [dir]` | Serve a live storybook, auto-discovering co-located `*.dev.js` modules (`--port`, `--out`, `--dry-run`, `--no-margaui`, `--no-check`, `--no-tests`; no module path needed) |
|
|
125
|
-
| `feedback [message]` | Append a feedback note (positional or stdin) to `~/.tutuca/feedback.jsonl` (no module path needed) |
|
|
126
|
-
| `install-skill [--user\|--project] [--margaui-skill\|--all] [--dot-agents] [--dry-run] [--force]` | Install bundled Claude Code skills (no module path needed) |
|
|
127
|
-
| `agent-context` | Print a versioned JSON schema of the entire CLI surface (no module path needed) |
|
|
128
|
-
|
|
129
|
-
Global flags: `--json`, `-f, --format <cli\|md\|json\|html>`, `-o, --output <file>`, `--pretty`, `--module <path>`, `-h, --help`.
|
|
130
|
-
|
|
131
|
-
`storybook` wires [MargaUI](https://github.com/marianoguerra/margaui) — a
|
|
132
|
-
Tailwind v4 / daisyUI-compatible class library — by default; `--no-margaui`
|
|
133
|
-
skips it. For the full flag reference, error codes, and "did you mean"
|
|
134
|
-
behavior, run `tutuca help <command>`, or `tutuca agent-context` for a
|
|
135
|
-
machine-readable schema of the whole surface.
|
|
136
|
-
|
|
137
|
-
### Usage examples
|
|
16
|
+
## Install
|
|
138
17
|
|
|
139
18
|
```sh
|
|
140
|
-
|
|
141
|
-
|
|
19
|
+
npm install tutuca
|
|
20
|
+
```
|
|
142
21
|
|
|
143
|
-
|
|
144
|
-
npx tutuca show ./src/components.js Button --format md -o docs/button.md
|
|
22
|
+
Or from a CDN, without a build step:
|
|
145
23
|
|
|
146
|
-
|
|
147
|
-
|
|
24
|
+
```js
|
|
25
|
+
import { component, h, Host } from "https://cdn.jsdelivr.net/npm/tutuca/dist/tutuca.min.js";
|
|
26
|
+
```
|
|
148
27
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
28
|
+
## Example
|
|
29
|
+
|
|
30
|
+
```js
|
|
31
|
+
import { component, field, h, Host, send, t } from "tutuca";
|
|
32
|
+
|
|
33
|
+
const Counter = component({
|
|
34
|
+
name: "Counter",
|
|
35
|
+
fields: { count: t.number() },
|
|
36
|
+
view: h("button", { "on:click": send("inc") }, "Clicked ", field("count")),
|
|
37
|
+
on: {
|
|
38
|
+
inc(next) {
|
|
39
|
+
next.count += 1;
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const host = new Host({ document, rootNode: document.getElementById("app") });
|
|
45
|
+
host.scope.register({ Counter });
|
|
46
|
+
host.start(host.scope.components.Counter());
|
|
153
47
|
```
|
|
154
48
|
|
|
155
|
-
##
|
|
49
|
+
## Modules
|
|
156
50
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
51
|
+
| Import | What |
|
|
52
|
+
|---|---|
|
|
53
|
+
| `tutuca` | components, views, schemas, the host, the `tag` and `button` element builders |
|
|
54
|
+
| `tutuca/dev` | DevTools formatters |
|
|
55
|
+
| `tutuca/lint` | the linter |
|
|
56
|
+
| `tutuca/classes` | `collectClasses`, `classNamesOf` and `ClassCompiler`, for CSS compilers that need class names listed |
|
|
57
|
+
| `tutuca/pbt` | property-based testing and the headless driver (bring your own `fast-check`) |
|
|
58
|
+
| `tutuca/storybook` | the storybook |
|
|
59
|
+
| `tutuca/playground` | the `<tutuca-playground>` element: edit a book of stories and run it live (bring your own CodeMirror) |
|
|
60
|
+
| `tutuca/element` | the `<tutuca-app>` custom element |
|
|
61
|
+
| `tutuca/vdom` | the virtual DOM |
|
|
62
|
+
| `tutuca/sync` | sync engines: projection, schema-guided diff, ops, `startSynced`, `storageEngine` |
|
|
63
|
+
| `tutuca/sync/remote` | an engine that sends diffs to a remote and applies the ones it sends |
|
|
64
|
+
| `tutuca/automerge` | an engine over an Automerge document (bring your own `@automerge/automerge`) |
|
|
162
65
|
|
|
163
|
-
|
|
164
|
-
# project-scoped: writes ./.claude/skills/tutuca/ (commit it for the team)
|
|
165
|
-
npx tutuca install-skill
|
|
66
|
+
## Docs
|
|
166
67
|
|
|
167
|
-
|
|
168
|
-
|
|
68
|
+
- [`docs/paths.md`](docs/paths.md): how update paths, dispatch paths and selectors route messages.
|
|
69
|
+
- [`docs/sync.md`](docs/sync.md): persisting and syncing state with sync engines.
|
|
70
|
+
- [`spec/README.md`](spec/README.md): the formal semantics in PLT Redex and how it maps to `src/`.
|
|
169
71
|
|
|
170
|
-
|
|
171
|
-
npx tutuca install-skill --margaui-skill
|
|
172
|
-
npx tutuca install-skill --all
|
|
72
|
+
## Development
|
|
173
73
|
|
|
174
|
-
|
|
175
|
-
npx tutuca install-skill --dot-agents
|
|
74
|
+
Tasks are in the `justfile`; `just` lists them.
|
|
176
75
|
|
|
177
|
-
|
|
178
|
-
|
|
76
|
+
```sh
|
|
77
|
+
just install # npm install
|
|
78
|
+
just check # lint, then test
|
|
79
|
+
just storybook # serve the storybook from the repo
|
|
80
|
+
just site # build the landing page and storybook into _site/ and serve it
|
|
81
|
+
just smoke # build dist/ and check what would be published
|
|
82
|
+
just publish # publish to npm as latest
|
|
179
83
|
```
|
|
180
84
|
|
|
181
|
-
The skill content is generated from `docs/skill/`, so the same reference
|
|
182
|
-
runs locally (`tutuca lint <module>` + `tutuca render <module> --title …`)
|
|
183
|
-
and inside Claude.
|
|
184
|
-
|
|
185
|
-
## Links
|
|
186
|
-
|
|
187
|
-
- [Documentation & Playground](https://marianoguerra.github.io/tutuca/)
|
|
188
|
-
- [Tutorial](https://marianoguerra.github.io/tutuca/tutorial.html)
|
|
189
|
-
- [GitHub](https://github.com/marianoguerra/tutuca)
|
|
190
|
-
|
|
191
85
|
## License
|
|
192
86
|
|
|
193
87
|
MIT
|