tcmts.cli.flight

Types

FlightGraph type
A codebase's server code, as `useFlight` loads it: what its server components send by reference, and its modules' members
FlightHooks type

Server

flightPackage (cb: Codebase, jsx: string, also?: ExtRef[]) => string
The Flight package for code written against React `jsx` (`npm:react@19`), installed beside it: at the very version of that React, as Flight's halves are built for one React (each `planApp` keeps them together, through `tcm upgrade react` too). Writes the module the server renders with (`flightServerFile`). Its alias.
flightServerFile (cb: Codebase) => string
The module server components render with (`flightPackage` writes it)
mirrorPackage (cacheDir: string, entry: string) => void
Server code's copy of an installed package (`entry`, its directory under the cache's `node_modules`: pnpm's `.pnpm/<entry>`, or npm's `<name>`, `@scope/<name>`), at that path under the cache's `server_modules`: its files hard-linked (nothing copied), its links to the packages it uses as they are, and (pnpm's, beside it in `.pnpm`) those packages copied too; npm's are found by name in `node_modules`, so `useFlight` makes their copies as they're asked for. Node keeps CommonJS modules by their paths, and remembers what a directory's `require("react")` found: a copy at its own paths gets its own, so server code's React (the react-server condition's) and server rendering's (`tcm dev` loads it with Node) never stand in for each other. Made once.
renderFlight (cb: Codebase, fn: (props: never) => unknown, props: unknown, opts: { write(text: string): void; on…
Render server component `fn` with `props` as Flight does (`useFlight` loads both): its tree, streamed as it's ready (`write`, text). An error inside it goes to `onError`, whose answer is the error's `digest`, what the browser is told of it in production. Done when all of it is written, or `signal` aborts.
useFlight (cb: Codebase, sent: { client(hash: string): boolean; server(hash: string): boolean; chunks?(compon…
Load the codebase's server code (the cache's modules, and the packages they import) as React's server components environment does: with the `react-server` condition, so it gets React's server build (`cache`, no hooks) and Flight's server. A module of browser code a server component renders (a component, a context it provides, a `lazy` one: `sent.client`) loads as Flight client references, by hash, instead of its code: it runs in the browser. A server function server components give the browser (`sent.server`) is registered as a server reference. Packages load from server code's own copies of them (`mirrorPackage`), so server rendering (the page's first paint), which has its own React, never shares one with it. For this process, from now on. `members` sees definitions not saved yet (a scratch file's tests).

Shared

FLIGHT_PACKAGE "react-server-dom-parcel"
React's Flight, the server components wire, as its Parcel build (which loads what a tree names through one function, `parcelRequire`)
flightAlias (jsx: string) => string
The alias of the Flight package beside React `jsx` (`npm:react@19`), as `flightPackage` installs it
packageReferences (source: string, keys: string[], server: string) => string
A module of the server's (as it loads, `source`) with its imports of the packages' browser components it renders (`keys`, by `packageRefKey`) made Flight client references to them instead (`createClientReference` from `server`, the module `flightServerFile` writes): their packages aren't loaded on the server for them, and the browser, which has them, renders them. Declared first, so the module's own top-level code finds them.
sentByReference (plan: AppPlan) => Set<string>
What an app's server components send to the browser by reference (`refsOf`): browser components, the contexts they provide, `lazy` ones

Tests

testMirrorPackageLayouts () => void
testPackageReferences () => void