@akanjs/cli 3.0.0-alpha.0 → 3.0.0-alpha.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/.build-stamp +1 -1
- package/{abstractCompactor-rk6twzvj.js → abstractCompactor-e5yq60qz.js} +2 -2
- package/{agent.command-jfz8yfwy.js → agent.command-yv00p0s0.js} +7 -7
- package/{application.command-3smsv7mq.js → application.command-0qsczf4k.js} +5 -5
- package/{applicationBuildRunner-aq7mb3z6.js → applicationBuildRunner-ct2pxyvw.js} +1 -1
- package/{applicationReleasePackager-yrrhbkv3.js → applicationReleasePackager-gg8ccbeh.js} +1 -1
- package/buildBatch.proc.js +2 -2
- package/{capacitorApp-q3mpmkkz.js → capacitorApp-4r9sm3qg.js} +3 -3
- package/{cloud.command-rk4e9vrt.js → cloud.command-dxfv18sa.js} +9 -9
- package/{context.command-ygzyb0xb.js → context.command-8d9e3k6b.js} +15 -15
- package/{guideline.command-1m1ctar3.js → guideline.command-3jbkxzh6.js} +5 -5
- package/guidelines/ssrRule/ssrRule.generate.json +31 -0
- package/guidelines/ssrRule/ssrRule.instruction.md +108 -0
- package/incrementalBuilder.proc.js +2 -2
- package/{index-3pgtw35d.js → index-0cj2zxbm.js} +1 -1
- package/{index-h0bngh79.js → index-1pvex4az.js} +11 -11
- package/{index-csqk9z5j.js → index-2q1f5j9k.js} +3 -3
- package/{index-cn24dcqn.js → index-7c6k4yvg.js} +2 -2
- package/{index-jk9q6pse.js → index-8hsbnyes.js} +1 -1
- package/{index-4yp06pn1.js → index-a00jg8x8.js} +2 -2
- package/{index-hjzr8ja1.js → index-bbkek1bp.js} +1 -1
- package/{index-r4w8cry5.js → index-bekddz9q.js} +4 -4
- package/{index-ev6rjw9n.js → index-e16gnn26.js} +35 -12
- package/{index-fmgbwsr5.js → index-ec09pws3.js} +4 -4
- package/{index-n0z3f2xg.js → index-ej426mcr.js} +4 -4
- package/{index-jtm86byd.js → index-hgna5rjy.js} +1 -1
- package/{index-e3qskyt2.js → index-k95xkh4p.js} +2 -2
- package/{index-b978vs2e.js → index-mr5s7mqd.js} +3 -3
- package/{index-6pz1j0zj.js → index-mxvakhsm.js} +6 -2
- package/{index-f4gqk0dd.js → index-nm6wghb6.js} +6 -6
- package/{index-4zgs8g1w.js → index-rzwcpcc3.js} +1 -1
- package/{index-sggm9qkv.js → index-t3723f99.js} +1 -1
- package/{index-xwgm94zr.js → index-tdbas9r0.js} +1 -1
- package/{index-vhv3xnjz.js → index-yzmhasdb.js} +6 -6
- package/{index-ktprgc5g.js → index-zasydjxd.js} +4 -4
- package/index.js +19 -19
- package/{library.command-pwfx8dx2.js → library.command-ebdj1vnm.js} +4 -4
- package/{localRegistry.command-bxhqmd1d.js → localRegistry.command-gb178ne8.js} +8 -8
- package/{module.command-0t3ewata.js → module.command-9c1bnsx4.js} +8 -8
- package/{package.command-7hmkxvpa.js → package.command-t93p4jkj.js} +4 -4
- package/package.json +2 -2
- package/{page.command-st6r4s0q.js → page.command-k3k0meh2.js} +4 -4
- package/{primitive.command-1qkxpzsn.js → primitive.command-de6nktdt.js} +9 -9
- package/{quality.command-hy5vt1bh.js → quality.command-z5kth2wa.js} +451 -48
- package/{repair.command-nakkq2zp.js → repair.command-ehf2g112.js} +6 -6
- package/{scalar.command-fjq272gs.js → scalar.command-7a2jtv33.js} +7 -7
- package/templates/workspaceRoot/.cursor/rules/client-server-boundaries.mdc.template +1 -0
- package/templates/workspaceRoot/.cursor/rules/ssr-first.mdc.template +59 -0
- package/templates/workspaceRoot/AGENTS.md.template +128 -7
- package/{workflow.command-jswbgk90.js → workflow.command-e0tt0vk2.js} +12 -12
- package/{workspace.command-p9r9nckg.js → workspace.command-fpda0evj.js} +21 -21
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
RepairRunner
|
|
4
|
-
} from "./index-
|
|
5
|
-
import"./index-
|
|
6
|
-
import"./index-
|
|
4
|
+
} from "./index-mr5s7mqd.js";
|
|
5
|
+
import"./index-a00jg8x8.js";
|
|
6
|
+
import"./index-rzwcpcc3.js";
|
|
7
7
|
import {
|
|
8
8
|
Workspace,
|
|
9
9
|
command,
|
|
10
10
|
script
|
|
11
|
-
} from "./index-
|
|
12
|
-
import"./index-
|
|
13
|
-
import"./index-
|
|
11
|
+
} from "./index-8hsbnyes.js";
|
|
12
|
+
import"./index-hgna5rjy.js";
|
|
13
|
+
import"./index-mxvakhsm.js";
|
|
14
14
|
import"./index-xys926f2.js";
|
|
15
15
|
import"./index-67546d0j.js";
|
|
16
16
|
import"./index-r24hmh0q.js";
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
ScalarScript
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-ec09pws3.js";
|
|
5
5
|
import"./index-ss469dec.js";
|
|
6
|
-
import"./index-
|
|
6
|
+
import"./index-0cj2zxbm.js";
|
|
7
7
|
import {
|
|
8
8
|
renderPrimitiveReport
|
|
9
|
-
} from "./index-
|
|
10
|
-
import"./index-
|
|
9
|
+
} from "./index-rzwcpcc3.js";
|
|
10
|
+
import"./index-tdbas9r0.js";
|
|
11
11
|
import {
|
|
12
12
|
Sys,
|
|
13
13
|
command
|
|
14
|
-
} from "./index-
|
|
15
|
-
import"./index-
|
|
16
|
-
import"./index-
|
|
14
|
+
} from "./index-8hsbnyes.js";
|
|
15
|
+
import"./index-hgna5rjy.js";
|
|
16
|
+
import"./index-mxvakhsm.js";
|
|
17
17
|
import"./index-67546d0j.js";
|
|
18
18
|
import"./index-r24hmh0q.js";
|
|
19
19
|
|
|
@@ -15,3 +15,4 @@ alwaysApply: false
|
|
|
15
15
|
- In domain UI the boundary is mechanical, not a judgment call: `Template`, `Zone`, and `Util` are always client components with `"use client"` on line 1; `Unit` and `View` are always server components and never carry the directive. `usePage()` is still legal in server files.
|
|
16
16
|
- Preserve established domain file roles such as `.document.ts`, `.service.ts`, `.store.ts`, `.constant.ts`, and `.client.ts`.
|
|
17
17
|
- When unsure, inspect nearby files in the same app or package before introducing a new boundary pattern.
|
|
18
|
+
- The boundary is only half the rule: how *little* ends up on the client is the other half. See `ssr-first.mdc`.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: SSR-first rendering rules — keep JSX on the server and justify every "use client"
|
|
3
|
+
globs: apps/**/*.tsx,libs/**/*.tsx
|
|
4
|
+
alwaysApply: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# SSR First — Server Rendering Is The Default
|
|
8
|
+
|
|
9
|
+
Akan is SSR-first. A JSX element rendered on the server ships as HTML and costs nothing to hydrate; an element
|
|
10
|
+
behind `"use client"` ships twice — as markup and as bundled JS that re-runs in the browser. The boundary question
|
|
11
|
+
is not which file *may* be client, it is **how little** ends up on the client side.
|
|
12
|
+
|
|
13
|
+
- **The default is server. `"use client"` is a cost you justify per component, not a habit.** A component earns the
|
|
14
|
+
directive only by using a client-only capability: a React hook, a JSX event handler, the store (`st.use.*` /
|
|
15
|
+
`st.do.*`), a browser global, or a client-only third-party package. Rendering markup, mapping over data, reading a
|
|
16
|
+
route param, and calling `l()` are server work — `usePage()` and `l()` never force a boundary.
|
|
17
|
+
- The file role decides *where* the boundary sits (`Template`/`Zone`/`Util` are client, `Unit`/`View` are server);
|
|
18
|
+
it does not decide how much markup sits behind it. A `Zone` that hoards markup is still an SSR regression.
|
|
19
|
+
- Measure with `akan quality ssr` (`--format json` for tooling). It reports the server render share per app and lib.
|
|
20
|
+
Treat **50% server share as the floor** and a falling share as a regression to justify or revert.
|
|
21
|
+
|
|
22
|
+
## What `akan quality ssr` Flags
|
|
23
|
+
|
|
24
|
+
- `akan.ssr.unnecessary-use-client` — the directive is there but nothing in the file needs it. Delete it.
|
|
25
|
+
- `akan.ssr.client-static-component` — a component in a client file renders real markup with zero client-only
|
|
26
|
+
capability: pure server work sitting in the bundle.
|
|
27
|
+
- `akan.ssr.client-static-markup` — a large subtree wraps one or two interactive touches. Split it.
|
|
28
|
+
- `akan.ssr.client-mount-load` — a `useEffect(…, [])` loads server data the page could fetch first.
|
|
29
|
+
- `akan.ssr.module-missing-server-view` — a module renders only from `Template`/`Zone`/`Util`, with no `Unit`/`View`.
|
|
30
|
+
- `akan.ssr.template-client-state` — a `Template` holds form state in `useState` instead of the store.
|
|
31
|
+
|
|
32
|
+
A third-party client package and the `ui/<Folder>/index_.tsx` + `lazy()` boundary both justify the directive and are
|
|
33
|
+
not flagged. Interaction-driven `fetch.*` inside an `onClick` is not flagged either — only mount-time loads are.
|
|
34
|
+
|
|
35
|
+
## Server-Side Implementation Playbook
|
|
36
|
+
|
|
37
|
+
1. **Wrap the interaction, not the UI.** The smallest useful client component adds one behaviour and renders
|
|
38
|
+
`children` untouched, so the markup inside never reaches the bundle:
|
|
39
|
+
`export const ClickWrapper = ({ children, onPick }: ClickWrapperProps) => <div onClick={onPick}>{children}</div>;`
|
|
40
|
+
2. **Split compound components so panels stay on the server.** A tab or accordion needs client state only for
|
|
41
|
+
*which* part is visible. `Tab` / `Tab.Menus` / `Tab.Menu` / `Tab.Panel` from `akanjs/ui` is the shape: only the
|
|
42
|
+
provider and menu hold state, and `<Tab.Panel>` renders children as-is, so a server `Unit`/`View` passed in stays
|
|
43
|
+
server-rendered. Never one client file with a mode `useState` and every panel body inlined.
|
|
44
|
+
3. **Sync state instead of fetching it.** The page calls `fetch.initTaskInTodo()` / `fetch.viewTask(id)` and passes
|
|
45
|
+
the serializable result into a `Zone`; `Load.Units` / `Load.View` hydrate the store from it. Never a
|
|
46
|
+
`useEffect(…, [])` that fetches on mount.
|
|
47
|
+
4. **Push the boundary down to the leaf that needs it.** A store-reading `Zone` holds zero markup and delegates to a
|
|
48
|
+
server `View`: `export const Self = () => <Task.View.General task={st.use.task()} />;`
|
|
49
|
+
5. **Hand the promise across, not the awaited value.** `ClientInit` / `ClientView` are `PromiseOrObject<T>`, so a
|
|
50
|
+
page may pass an unawaited `fetch.initTaskInTodo()` and `Load.*` resolves it behind a skeleton.
|
|
51
|
+
6. **Use named `ReactNode` slots, not just `children`.** `Layout.Navbar` takes `title`, `back`, `left`, `right`, and
|
|
52
|
+
`children`, so a client shell composes server content in five places.
|
|
53
|
+
7. **Let the server do the derived work.** Display and predicate logic lives on `LightTask` (`isNew()`,
|
|
54
|
+
`canWrite(user?)`); enum→class lookups live in a module-scope `as const` map.
|
|
55
|
+
8. **Gate auth on the server.** Check the session in `_layout.tsx` and redirect there, before any HTML is sent.
|
|
56
|
+
9. **Prefer CSS over client state for pure visibility.** A `data-*` attribute plus `group-data-[…]` variants, or
|
|
57
|
+
`<details>`/`<summary>`, keeps both branches server-rendered.
|
|
58
|
+
10. **Keep the heavy island out of the first load.** Put a large client-only widget behind the
|
|
59
|
+
`ui/<Folder>/index_.tsx` + `lazy()` pair.
|
|
@@ -74,11 +74,12 @@ Use the local module shape before adding a new abstraction.
|
|
|
74
74
|
9. Keep page and layout files server-oriented: route-level `usePage`, headers, static layout, and `akanjs/ui` `Tab` composition belong there.
|
|
75
75
|
10. Put interactive loading, submit/import actions, local form state, and `router.push` in client `Util`, `Template`, or `Zone` components.
|
|
76
76
|
11. Prefer `Tab` for static mode selection instead of extra `useState`; render one focused client component inside each `Tab.Panel`.
|
|
77
|
-
12.
|
|
78
|
-
13.
|
|
79
|
-
14.
|
|
80
|
-
15.
|
|
81
|
-
16.
|
|
77
|
+
12. Default to server rendering. Add `"use client"` only for a real client-only capability, and keep markup out of the component that carries it — see **SSR First** below.
|
|
78
|
+
13. Keep server-only logic out of client surfaces and client-only code out of server imports.
|
|
79
|
+
14. Treat `AKAN_PUBLIC_*` env vars as public. Never put secrets in them.
|
|
80
|
+
15. Add or update tests when behavior, contracts, or CLI output changes.
|
|
81
|
+
16. Update `*.abstract.md` when business invariants, workflows, or public behavior change.
|
|
82
|
+
17. Run the smallest relevant verification command after changes. After touching any `.tsx`, that includes `akan quality ssr`.
|
|
82
83
|
|
|
83
84
|
## Common Commands
|
|
84
85
|
|
|
@@ -111,7 +112,11 @@ akan typecheck <%= appName %>
|
|
|
111
112
|
# 3. Test — Run the test code (lib/*/*.signal.test.ts or others)
|
|
112
113
|
akan test <%= appName %>
|
|
113
114
|
|
|
114
|
-
# 4.
|
|
115
|
+
# 4. SSR balance — only after touching .tsx files. Reports the server render share
|
|
116
|
+
# per app/lib and flags client code that should render on the server.
|
|
117
|
+
akan quality ssr
|
|
118
|
+
|
|
119
|
+
# 5. Full production build — bundles the app, runs all type/lint checks combined
|
|
115
120
|
akan build <%= appName %>
|
|
116
121
|
```
|
|
117
122
|
|
|
@@ -128,6 +133,8 @@ akan create-scalar <scalar-name> <%= appName %> # Add a scalar module (
|
|
|
128
133
|
akan create-service <service-name> <%= appName %> # Add a service module (lib/_<service-name>/)
|
|
129
134
|
akan test <%= appName %> # Run the test code (lib/*/*.signal.test.ts or others)
|
|
130
135
|
akan lint <%= appName %> # Lint only (no typecheck)
|
|
136
|
+
akan quality scan # All code-quality warnings + SSR balance
|
|
137
|
+
akan quality ssr # SSR balance and client-boundary warnings only
|
|
131
138
|
```
|
|
132
139
|
|
|
133
140
|
**CLI argument conventions.** Two argument styles, and mixing them up is a common mistake:
|
|
@@ -240,7 +247,7 @@ final fallback when no CLI command covers the change.
|
|
|
240
247
|
| Add a reusable value type (e.g., Address, WorkHistory) | `lib/__scalar/<type>/` → constant, dictionary, abstract | `akan sync <name>` |
|
|
241
248
|
| Create a new URL-visitable page | `page/` → `_index.tsx`, `_layout.tsx`, `[param]/_index.tsx` | Rebuild (akan start auto-detects) |
|
|
242
249
|
| Change the app color theme / design tokens | `apps/<app>/page/styles.css` → override the semantic token values under `:root, [data-theme="dark"]` and `[data-theme="light"]` (`--primary`, `--background`, `--foreground`, …) | akan start hot-reloads |
|
|
243
|
-
| Add a form or reusable UI component | `ui/` → PascalCase `.tsx
|
|
250
|
+
| Add a form or reusable UI component | `ui/` → PascalCase `.tsx`, **no** `"use client"` unless it uses a hook, event handler, store, or browser API | `akan sync <name>` |
|
|
244
251
|
| Add a React hook or browser helper | `webkit/` → camelCase `.ts` with `"use client"` | `akan sync <name>` |
|
|
245
252
|
| Add a server-only guard, middleware, or adaptor | `srvkit/` → PascalCase `.ts` | `akan sync <name>` |
|
|
246
253
|
| Add a pure helper (no DOM, no server API) | `common/` → camelCase `.ts` | `akan sync <name>` |
|
|
@@ -261,6 +268,120 @@ final fallback when no CLI command covers the change.
|
|
|
261
268
|
| Use "use client" or `useState`/`useEffect` in pages/*.tsx, *.Unit.tsx, and *.View.tsx files | Server code cannot use React hooks. Wrap in a separate `"use client"` component. | Move hook logic to `webkit/` or a `"use client"` UI component |
|
|
262
269
|
| Use `<a>` tag for internal navigation between pages | Akan.js uses `<Link>` from `akanjs/ui` for client-side navigation — avoids full page reloads. | `import { Link } from "akanjs/ui"` and use `<Link href="/task">...</Link>` |
|
|
263
270
|
| Name a custom `Endpoint`/`Slice` like a generated CRUD op — `create<Model>`, `update<Model>`, `remove<Model>`, `view<Model>`, `edit<Model>`, `merge<Model>` | These names are already auto-generated. A collision can pass sync/typecheck/build and only fail at runtime. | Pick a distinct verb, e.g. `startTask`/`archiveTask`, never `createTask` for a custom endpoint |
|
|
271
|
+
| Add `"use client"` to a file that renders markup but uses no hook, event handler, store, or browser API | The directive is a cost, not a formality: everything behind it ships twice, as HTML and as JS that re-runs in the browser. | Delete the directive. `akan quality ssr` flags this as `akan.ssr.unnecessary-use-client` |
|
|
272
|
+
| Put a large static subtree inside a client component that only needs one `onClick` | The whole subtree lands in the bundle for the sake of one handler. | Keep the handler in a small client shell and pass the static markup in as `children`, or move it to a `Unit`/`View` |
|
|
273
|
+
| Load server data with `useEffect(() => { void st.do.initTaskInTodo(); }, [])` | The page renders an empty shell, hydrates, then round-trips for data the server already had. | `await fetch.initTaskInTodo()` in the page and pass `init` to the `Zone` |
|
|
274
|
+
|
|
275
|
+
## SSR First — Server Rendering Is The Default
|
|
276
|
+
|
|
277
|
+
Akan is SSR-first. Every JSX element that renders on the server ships as HTML and costs nothing to hydrate; every
|
|
278
|
+
element behind `"use client"` ships twice — as markup and as bundled JS that must re-run in the browser. The
|
|
279
|
+
boundary question is not which file *may* be client, it is **how little** ends up on the client side.
|
|
280
|
+
|
|
281
|
+
**The default is server. `"use client"` is a cost you justify per component, not a habit.** A component earns the
|
|
282
|
+
directive only by using a client-only capability: a React hook, a JSX event handler, the store (`st.use.*` /
|
|
283
|
+
`st.do.*`), a browser global, or a client-only third-party package. Rendering markup, mapping over data, reading a
|
|
284
|
+
route param, and calling `l()` are all server work — `usePage()` and `l()` are legal in server components and never
|
|
285
|
+
force a boundary.
|
|
286
|
+
|
|
287
|
+
The file role decides *where* the boundary sits (`Template`/`Zone`/`Util` are client, `Unit`/`View` are server); it
|
|
288
|
+
does not decide how much markup sits behind it. A `Zone` that hoards markup is still an SSR regression.
|
|
289
|
+
|
|
290
|
+
Measure with `akan quality ssr` (`--format json` for tooling). It reports the server render share per app and lib —
|
|
291
|
+
server-rendered JSX elements over total — plus the warnings below. Treat **50% server share as the floor** and a
|
|
292
|
+
falling share as a regression to justify or revert.
|
|
293
|
+
|
|
294
|
+
| Rule | Means |
|
|
295
|
+
|---|---|
|
|
296
|
+
| `akan.ssr.unnecessary-use-client` | The directive is there but nothing in the file needs it. Delete it. |
|
|
297
|
+
| `akan.ssr.client-static-component` | A component in a client file renders real markup with zero client-only capability — pure server work sitting in the bundle. |
|
|
298
|
+
| `akan.ssr.client-static-markup` | A large subtree wraps one or two interactive touches. Split it: interaction stays client, markup goes server. |
|
|
299
|
+
| `akan.ssr.client-mount-load` | A `useEffect(…, [])` loads server data. The page can fetch it before the first byte. |
|
|
300
|
+
| `akan.ssr.module-missing-server-view` | A module renders only from `Template`/`Zone`/`Util` and has no `Unit`/`View` at all. |
|
|
301
|
+
| `akan.ssr.template-client-state` | A `Template` holds form state in `useState` instead of the store. |
|
|
302
|
+
|
|
303
|
+
A third-party client package and the `ui/<Folder>/index_.tsx` + `lazy()` boundary both justify the directive and are
|
|
304
|
+
not flagged. Interaction-driven `fetch.*` inside an `onClick` is not flagged either — only mount-time loads are,
|
|
305
|
+
because those are the ones the server could have performed.
|
|
306
|
+
|
|
307
|
+
### Server-Side Implementation Playbook
|
|
308
|
+
|
|
309
|
+
**① Wrap the interaction, not the UI.** The smallest useful client component adds one behaviour and renders
|
|
310
|
+
`children` untouched, so the markup inside never reaches the bundle.
|
|
311
|
+
|
|
312
|
+
```tsx
|
|
313
|
+
// apps/<%= appName %>/ui/ClickWrapper.tsx
|
|
314
|
+
"use client";
|
|
315
|
+
export const ClickWrapper = ({ children, onPick }: ClickWrapperProps) => <div onClick={onPick}>{children}</div>;
|
|
316
|
+
|
|
317
|
+
// in a server page — Task.Unit.Card stays server-rendered
|
|
318
|
+
<ClickWrapper onPick={…}>
|
|
319
|
+
<Task.Unit.Card task={task} />
|
|
320
|
+
</ClickWrapper>
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
**② Split compound components so panels stay on the server.** A tab, accordion, or disclosure needs client state
|
|
324
|
+
only for *which* part is visible — never for what the parts contain. `Tab` / `Tab.Menus` / `Tab.Menu` / `Tab.Panel`
|
|
325
|
+
from `akanjs/ui` is the reference shape: only the provider and menu hold state, and `<Tab.Panel>` renders its
|
|
326
|
+
children as-is, so a server `Unit`/`View` passed in stays server-rendered.
|
|
327
|
+
|
|
328
|
+
```tsx
|
|
329
|
+
<Tab defaultMenu="detail">
|
|
330
|
+
<Tab.Menus>
|
|
331
|
+
<Tab.Menu menu="detail">{l("task.detail")}</Tab.Menu>
|
|
332
|
+
<Tab.Menu menu="history">{l("task.history")}</Tab.Menu>
|
|
333
|
+
</Tab.Menus>
|
|
334
|
+
<Tab.Panel menu="detail">
|
|
335
|
+
<Task.View.General task={task} />
|
|
336
|
+
</Tab.Panel>
|
|
337
|
+
</Tab>
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
Never collapse this into one `"use client"` file with a mode `useState` and every panel body inlined.
|
|
341
|
+
|
|
342
|
+
**③ Sync state instead of fetching it.** A server component cannot hold state, so render the initial data on the
|
|
343
|
+
server and hand it across the boundary as a serializable object. That is what `init` / `view` props are: the page
|
|
344
|
+
calls `fetch.initTaskInTodo()` / `fetch.viewTask(id)`, passes the result into a `Zone`, and `Load.Units` /
|
|
345
|
+
`Load.View` hydrate the store from it.
|
|
346
|
+
|
|
347
|
+
```tsx
|
|
348
|
+
export default async function Page() {
|
|
349
|
+
const [{ taskInitInTodo }] = await Promise.all([fetch.initTaskInTodo()]);
|
|
350
|
+
return <Task.Zone.Card init={taskInitInTodo} sliceName="taskInTodo" />;
|
|
351
|
+
}
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
**④ Push the boundary down to the leaf that needs it.** When a `Zone` reads the store, it should hold *zero* markup
|
|
355
|
+
and delegate to a server `View`, so the whole detail surface renders server-side wherever a page uses the `View`
|
|
356
|
+
directly.
|
|
357
|
+
|
|
358
|
+
```tsx
|
|
359
|
+
"use client";
|
|
360
|
+
export const Self = () => <Task.View.General task={st.use.task()} />;
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
**⑤ Hand the promise across, not the awaited value.** `ClientInit` / `ClientView` are `PromiseOrObject<T>`, so a
|
|
364
|
+
page may pass an unawaited `fetch.initTaskInTodo()` and `Load.*` resolves it behind a skeleton. `await` blocks the
|
|
365
|
+
shell for data the page needs immediately; passing the promise streams the rest. Independent fetches still go
|
|
366
|
+
through one `Promise.all`.
|
|
367
|
+
|
|
368
|
+
**⑥ Use named `ReactNode` slots, not just `children`.** A client shell can take several server-rendered subtrees:
|
|
369
|
+
`Layout.Navbar` accepts `title`, `back`, `left`, `right`, and `children`, so it composes server content in five
|
|
370
|
+
places instead of absorbing it.
|
|
371
|
+
|
|
372
|
+
**⑦ Let the server do the derived work.** Display and predicate logic belongs on `LightTask` (`isNew()`,
|
|
373
|
+
`canWrite(user?)`, `formatTimes()`), and enum→class lookups belong in a module-scope `as const` map. Both sides call
|
|
374
|
+
the same method, so a client component that exists only to compute a label is markup in the wrong place.
|
|
375
|
+
|
|
376
|
+
**⑧ Gate auth on the server.** Check the session in `_layout.tsx` and redirect there, before any HTML is sent. A
|
|
377
|
+
client-side auth check costs a hydration round-trip and flashes the wrong UI first.
|
|
378
|
+
|
|
379
|
+
**⑨ Prefer CSS over client state for pure visibility.** A `data-*` attribute plus `group-data-[…]` variants, or
|
|
380
|
+
`<details>`/`<summary>`, keeps both branches server-rendered. Reach for `useState` when the state is real, not when
|
|
381
|
+
a Tailwind variant would do.
|
|
382
|
+
|
|
383
|
+
**⑩ Keep the heavy island out of the first load.** A large client-only widget goes behind the
|
|
384
|
+
`ui/<Folder>/index_.tsx` + `lazy()` pair so the server renders the page around it.
|
|
264
385
|
|
|
265
386
|
## Code Style
|
|
266
387
|
|
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
WorkflowRunner
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-2q1f5j9k.js";
|
|
5
5
|
import {
|
|
6
6
|
PrimitiveScript
|
|
7
|
-
} from "./index-
|
|
7
|
+
} from "./index-bekddz9q.js";
|
|
8
8
|
import {
|
|
9
9
|
ModuleScript
|
|
10
|
-
} from "./index-
|
|
11
|
-
import"./index-
|
|
10
|
+
} from "./index-yzmhasdb.js";
|
|
11
|
+
import"./index-bbkek1bp.js";
|
|
12
12
|
import {
|
|
13
13
|
ScalarScript
|
|
14
|
-
} from "./index-
|
|
14
|
+
} from "./index-ec09pws3.js";
|
|
15
15
|
import"./index-ss469dec.js";
|
|
16
|
-
import"./index-
|
|
17
|
-
import"./index-
|
|
16
|
+
import"./index-0cj2zxbm.js";
|
|
17
|
+
import"./index-a00jg8x8.js";
|
|
18
18
|
import {
|
|
19
19
|
createWorkflowStepRegistry
|
|
20
|
-
} from "./index-
|
|
21
|
-
import"./index-
|
|
20
|
+
} from "./index-rzwcpcc3.js";
|
|
21
|
+
import"./index-tdbas9r0.js";
|
|
22
22
|
import {
|
|
23
23
|
Workspace,
|
|
24
24
|
command,
|
|
25
25
|
script
|
|
26
|
-
} from "./index-
|
|
27
|
-
import"./index-
|
|
28
|
-
import"./index-
|
|
26
|
+
} from "./index-8hsbnyes.js";
|
|
27
|
+
import"./index-hgna5rjy.js";
|
|
28
|
+
import"./index-mxvakhsm.js";
|
|
29
29
|
import"./index-xys926f2.js";
|
|
30
30
|
import"./index-67546d0j.js";
|
|
31
31
|
import"./index-r24hmh0q.js";
|
|
@@ -1,48 +1,48 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
ContextScript
|
|
4
|
-
} from "./index-
|
|
5
|
-
import"./index-
|
|
6
|
-
import"./index-
|
|
7
|
-
import"./index-
|
|
8
|
-
import"./index-
|
|
9
|
-
import"./index-
|
|
4
|
+
} from "./index-1pvex4az.js";
|
|
5
|
+
import"./index-mr5s7mqd.js";
|
|
6
|
+
import"./index-2q1f5j9k.js";
|
|
7
|
+
import"./index-bekddz9q.js";
|
|
8
|
+
import"./index-yzmhasdb.js";
|
|
9
|
+
import"./index-bbkek1bp.js";
|
|
10
10
|
import {
|
|
11
11
|
CloudScript
|
|
12
|
-
} from "./index-
|
|
12
|
+
} from "./index-nm6wghb6.js";
|
|
13
13
|
import {
|
|
14
14
|
getLatestPackageVersion,
|
|
15
15
|
getNpmRegistryUrl
|
|
16
|
-
} from "./index-
|
|
16
|
+
} from "./index-zasydjxd.js";
|
|
17
17
|
import {
|
|
18
18
|
PackageScript
|
|
19
|
-
} from "./index-
|
|
20
|
-
import"./index-
|
|
19
|
+
} from "./index-k95xkh4p.js";
|
|
20
|
+
import"./index-ec09pws3.js";
|
|
21
21
|
import"./index-ss469dec.js";
|
|
22
|
-
import"./index-
|
|
22
|
+
import"./index-t3723f99.js";
|
|
23
23
|
import {
|
|
24
24
|
GlobalConfig
|
|
25
|
-
} from "./index-
|
|
25
|
+
} from "./index-0cj2zxbm.js";
|
|
26
26
|
import {
|
|
27
27
|
AgentScript
|
|
28
|
-
} from "./index-
|
|
29
|
-
import"./index-
|
|
30
|
-
import"./index-
|
|
31
|
-
import"./index-
|
|
28
|
+
} from "./index-ej426mcr.js";
|
|
29
|
+
import"./index-a00jg8x8.js";
|
|
30
|
+
import"./index-rzwcpcc3.js";
|
|
31
|
+
import"./index-tdbas9r0.js";
|
|
32
32
|
import {
|
|
33
33
|
ApplicationScript
|
|
34
|
-
} from "./index-
|
|
34
|
+
} from "./index-e16gnn26.js";
|
|
35
35
|
import"./index-76rn3g2c.js";
|
|
36
36
|
import {
|
|
37
37
|
LibraryScript
|
|
38
|
-
} from "./index-
|
|
38
|
+
} from "./index-7c6k4yvg.js";
|
|
39
39
|
import {
|
|
40
40
|
Exec,
|
|
41
41
|
Workspace,
|
|
42
42
|
command,
|
|
43
43
|
runner,
|
|
44
44
|
script
|
|
45
|
-
} from "./index-
|
|
45
|
+
} from "./index-8hsbnyes.js";
|
|
46
46
|
import"./index-fgc8r6dj.js";
|
|
47
47
|
import {
|
|
48
48
|
ThemeValidator,
|
|
@@ -59,8 +59,8 @@ import {
|
|
|
59
59
|
collectScopeRecipeSources,
|
|
60
60
|
extractAgentBlock,
|
|
61
61
|
renderScopeAgentBlock
|
|
62
|
-
} from "./index-
|
|
63
|
-
import"./index-
|
|
62
|
+
} from "./index-hgna5rjy.js";
|
|
63
|
+
import"./index-mxvakhsm.js";
|
|
64
64
|
import {
|
|
65
65
|
collectRecipeSources,
|
|
66
66
|
scanRecipes
|