@barefootjs/cli 0.1.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 (45) hide show
  1. package/dist/docs/core/README.md +84 -0
  2. package/dist/docs/core/adapters/adapter-architecture.md +262 -0
  3. package/dist/docs/core/adapters/csr.md +78 -0
  4. package/dist/docs/core/adapters/custom-adapter.md +357 -0
  5. package/dist/docs/core/adapters/go-template-adapter.md +269 -0
  6. package/dist/docs/core/adapters/hono-adapter.md +199 -0
  7. package/dist/docs/core/adapters.md +37 -0
  8. package/dist/docs/core/advanced/code-splitting.md +142 -0
  9. package/dist/docs/core/advanced/compiler-internals.md +331 -0
  10. package/dist/docs/core/advanced/error-codes.md +261 -0
  11. package/dist/docs/core/advanced/ir-schema.md +65 -0
  12. package/dist/docs/core/advanced/performance.md +115 -0
  13. package/dist/docs/core/advanced/xyflow-browser-bundle.md +69 -0
  14. package/dist/docs/core/advanced.md +11 -0
  15. package/dist/docs/core/components/children-slots.md +150 -0
  16. package/dist/docs/core/components/component-authoring.md +207 -0
  17. package/dist/docs/core/components/context-api.md +236 -0
  18. package/dist/docs/core/components/portals.md +192 -0
  19. package/dist/docs/core/components/props-type-safety.md +97 -0
  20. package/dist/docs/core/components/styling.md +37 -0
  21. package/dist/docs/core/components.md +19 -0
  22. package/dist/docs/core/core-concepts/ai-native.md +83 -0
  23. package/dist/docs/core/core-concepts/backend-freedom.md +31 -0
  24. package/dist/docs/core/core-concepts/how-it-works.md +147 -0
  25. package/dist/docs/core/core-concepts/mpa-style.md +36 -0
  26. package/dist/docs/core/core-concepts/reactivity.md +35 -0
  27. package/dist/docs/core/core-concepts.md +28 -0
  28. package/dist/docs/core/introduction.md +87 -0
  29. package/dist/docs/core/llms.txt +53 -0
  30. package/dist/docs/core/quick-start.mdx +160 -0
  31. package/dist/docs/core/reactivity/create-effect.md +125 -0
  32. package/dist/docs/core/reactivity/create-memo.md +91 -0
  33. package/dist/docs/core/reactivity/create-signal.md +128 -0
  34. package/dist/docs/core/reactivity/on-cleanup.md +67 -0
  35. package/dist/docs/core/reactivity/on-mount.md +70 -0
  36. package/dist/docs/core/reactivity/props-reactivity.md +91 -0
  37. package/dist/docs/core/reactivity/untrack.md +69 -0
  38. package/dist/docs/core/reactivity.md +28 -0
  39. package/dist/docs/core/rendering/client-directive.md +82 -0
  40. package/dist/docs/core/rendering/fragment.md +43 -0
  41. package/dist/docs/core/rendering/jsx-compatibility.md +163 -0
  42. package/dist/docs/core/rendering.md +14 -0
  43. package/dist/index.js +25490 -0
  44. package/dist/tokens.json +74 -0
  45. package/package.json +37 -0
@@ -0,0 +1,163 @@
1
+ ---
2
+ title: JSX Compatibility
3
+ description: Standard JSX syntax support in BarefootJS, including control flow and common patterns from React and SolidJS.
4
+ ---
5
+
6
+ # JSX Compatibility
7
+
8
+ Standard JSX syntax works. This page covers BarefootJS-specific behavior and limitations.
9
+
10
+
11
+ ## Control Flow
12
+
13
+ ```tsx
14
+ // Ternary
15
+ {count() > 0 ? <p>{count()} items</p> : <p>No items</p>}
16
+
17
+ // Logical AND
18
+ {isLoggedIn() && <Dashboard />}
19
+
20
+ // Conditional return
21
+ if (status === 'empty') {
22
+ return <p>No items yet.</p>
23
+ }
24
+ return <div>...</div>
25
+ ```
26
+
27
+
28
+ ## List Rendering
29
+
30
+ ```tsx
31
+ {todos().map(todo => (
32
+ <TodoItem key={todo.id} todo={todo} />
33
+ ))}
34
+ ```
35
+
36
+ `.filter().map()` chains work when the predicate uses simple expressions or block bodies with `if`/`return`:
37
+
38
+ ```tsx
39
+ // ✅ Simple predicate
40
+ {todos().filter(t => !t.done).map(todo => (
41
+ <TodoItem key={todo.id} todo={todo} />
42
+ ))}
43
+
44
+ // ✅ Block body with simple statements — also works
45
+ {todos().filter(t => {
46
+ const f = filter()
47
+ if (f === 'active') return !t.done
48
+ if (f === 'completed') return t.done
49
+ return true
50
+ }).map(todo => (
51
+ <TodoItem key={todo.id} todo={todo} />
52
+ ))}
53
+ ```
54
+
55
+ `.sort()` and `.toSorted()` can be chained with `.map()` and `.filter()`:
56
+
57
+ ```tsx
58
+ // ✅ Sort then render
59
+ {items().sort((a, b) => a.price - b.price).map(item => (
60
+ <Item key={item.id} item={item} />
61
+ ))}
62
+
63
+ // ✅ Filter, sort, then render
64
+ {items().filter(x => x.active).sort((a, b) => a.name.localeCompare(b.name)).map(item => (
65
+ <Item key={item.id} item={item} />
66
+ ))}
67
+ ```
68
+
69
+ Supported comparator shapes: `(a, b) => a - b`, `(a, b) => a.field - b.field`, `(a, b) => a.localeCompare(b)`, `(a, b) => a.field.localeCompare(b.field)` (reverse the operands for descending order). Other shapes — block bodies, ternary returns, custom helpers — produce a compile error; use `/* @client */` in that case.
70
+
71
+
72
+ ## Event Handling
73
+
74
+ ```tsx
75
+ <button onClick={() => setCount(n => n + 1)}>+1</button>
76
+ <input onInput={(e) => setText((e.target as HTMLInputElement).value)} />
77
+ <input onKeyDown={(e) => e.key === 'Enter' && handleSubmit()} />
78
+ ```
79
+
80
+
81
+ ## Dynamic Attributes
82
+
83
+ ```tsx
84
+ <button disabled={!accepted()}>Submit</button>
85
+ <a className={filter() === 'all' ? 'selected' : ''}>All</a>
86
+ <div style={`background: ${accepted() ? '#4caf50' : '#ccc'}`}>...</div>
87
+ ```
88
+
89
+
90
+ ## Limitations
91
+
92
+ Some JavaScript expressions cannot be translated into marked template syntax. Which expressions error depends on the adapter — non-JS template backends (Go `html/template`, Mojolicious EP) have a narrower expression surface than JS-runtime adapters (Hono, etc.) that can execute JS at SSR time.
93
+
94
+ | Pattern | Hono / JS-runtime adapters | Go / Mojo adapters |
95
+ |---|---|---|
96
+ | `.filter()` with destructured param (`({done}) => done`) | works (runs as JS) | **BF101** |
97
+ | `.filter()` with `function` keyword callback | works | **BF101** |
98
+ | `.reduce()`, `.forEach()`, `.flatMap()` | works | **BF101** |
99
+ | Nested higher-order in filter predicate (`x => x.tags.filter(...).length > 0`) | works | **BF101** |
100
+ | Sort comparator with a block body, ternary return, or other unsupported shape | **BF021** (all adapters) | **BF021** |
101
+ | `typeof` in a filter predicate | **BF021** (all adapters) | **BF021** |
102
+
103
+ `BF021` is raised at the IR layer and applies to every adapter. `BF101` is raised by adapters that can't lower the expression to their template language. Either way, add [`/* @client */`](./client-directive.md) to opt into client-only evaluation and suppress the error.
104
+
105
+ ### Patterns that error on Go / Mojo
106
+
107
+ **Nested higher-order methods:**
108
+
109
+ ```tsx
110
+ // ❌ BF101 on Go/Mojo; works on Hono
111
+ {items().filter(x => x.tags.filter(t => t.active).length > 0).map(...)}
112
+
113
+ // ✅ Add /* @client */ to evaluate on the client
114
+ {/* @client */ items().filter(x => x.tags.filter(t => t.active).length > 0).map(...)}
115
+ ```
116
+
117
+ **`.reduce()` / `.forEach()` / `.flatMap()`:**
118
+
119
+ ```tsx
120
+ // ❌ BF101 on Go/Mojo; works on Hono
121
+ {items().reduce((sum, x) => sum + x.price, 0)}
122
+
123
+ // ✅ Use /* @client */
124
+ {/* @client */ items().reduce((sum, x) => sum + x.price, 0)}
125
+ ```
126
+
127
+ **Destructuring in predicate parameters:**
128
+
129
+ ```tsx
130
+ // ❌ BF101 on Go/Mojo; works on Hono
131
+ {items().filter(({done}) => done).map(...)}
132
+
133
+ // ✅ Use a named parameter for adapter portability
134
+ {items().filter(t => t.done).map(...)}
135
+ ```
136
+
137
+ **Function expressions** (`function` keyword):
138
+
139
+ ```tsx
140
+ // ❌ BF101 on Go/Mojo; works on Hono
141
+ {items().filter(function(x) { return x.done })}
142
+
143
+ // ✅ Use arrow functions for adapter portability
144
+ {items().filter(x => x.done)}
145
+ ```
146
+
147
+ ### Patterns that error on all adapters
148
+
149
+ **Unsupported sort comparators** (block bodies, ternary returns):
150
+
151
+ ```tsx
152
+ // ❌ BF021 (all adapters)
153
+ {items().sort((a, b) => a.name > b.name ? 1 : -1).map(item => (
154
+ <Item key={item.id} item={item} />
155
+ ))}
156
+
157
+ // ✅ Use /* @client */
158
+ {/* @client */ items().sort((a, b) => a.name > b.name ? 1 : -1).map(item => (
159
+ <Item key={item.id} item={item} />
160
+ ))}
161
+ ```
162
+
163
+ See the [TodoApp example](https://github.com/piconic-ai/barefootjs/blob/main/integrations/shared/components/TodoApp.tsx) for a real-world component using `/* @client */`.
@@ -0,0 +1,14 @@
1
+ ---
2
+ title: Templates & Rendering
3
+ description: BarefootJS-specific JSX behavior covering compatibility, fragments, and client directives.
4
+ ---
5
+
6
+ # Templates & Rendering
7
+
8
+ ## Pages
9
+
10
+ | Topic | Description |
11
+ |-------|-------------|
12
+ | [JSX Compatibility](./rendering/jsx-compatibility.md) | What works, what doesn't, and what differs from React |
13
+ | [Fragment](./rendering/fragment.md) | Fragment support and hydration behavior |
14
+ | [`/* @client */` Directive](./rendering/client-directive.md) | Skip server evaluation for client-only expressions |