feat(farm-leaf): map flat route files and read leaf's hydrate pragma
Merged
KI
11d ago+352+352+012345678901234567890123456789-48-48-01234567890123456789
Problem
Farm's renderer interface gains routes() and hydration (farming-labs/farm.js#3154), and leaf doesn't use them yet: every route is a page.tsx or page.leaf folder file, and a .leaf file can only hydrate through export const hydrate = true.
Change
packages/farm-leaf/src/index.ts:routes()keeps Farm's folders and mapsapp/src/app/guides/as flat files.index.leafis/guides,harvest.leafis/guides/harvest,[crop].leafis dynamic,_layout.leafis the folder's layout, other_files are components, and a.clientname hydrates.hydration.resolve()reads// @hydrate [load|idle|visible|interaction|false]from a.leaffile.app/src/app/guides/: six files that use both, the same ones asexamples/custom-rendererin farm.js.packages/farm-leaf/test/descriptor.test.ts: the rules and the pragma.e2e/custom-renderer.spec.ts: 4 tests (flat pages in the layout, skipped files 404, which pages hydrate, client navigation inside the guides layout).- README: "Its own route files", and step 3 of "Make it yours" says both hooks are optional.
Safety and compatibility
Both hooks ship in Farm 0.1.83, so the app and farm-leaf move to @farm.js/core and @farm.js/cli 0.1.83, and farm-leaf's peer floor rises to >=0.1.83.
Verification
Against @farm.js/core and @farm.js/cli 0.1.83 installed from npm (pnpm install --frozen-lockfile):
pnpm type-check: passes in all three projects.pnpm test: 32 passed (7 new).pnpm test:e2e(production build) andpnpm test:e2e:dev: 17 passed each, with installed Chrome.
Documentation and release
README updated. No package release: farm-leaf is private.