tcmts.cli.placement

Types

AppPlan type
AppState type
Place type
Placement typeof Placement

Shared

DOM_GLOBALS Set<string>
NODE_GLOBALS Set<string>
TEST_FRAMEWORK RegExp
Packages tests import from their framework: they don't decide where a test runs.
eventHandler (ir: IR, isServerFunction?: (hash: string) => boolean) => string | undefined
An `on…` attribute (`onClick={…}`): an event handler, which only exists in the browser. Not one given a server function (`onRemove={remove}`, `onRemove={remove.bind(null, id)}`, as `isServerFunction` says), which a server component can give a browser component to call.
globalsIn (ir: IR, out?: Set<string>) => Set<string>
The globals `ir`'s code uses as values: what's only named in types (`el: Element`) is erased, and doesn't run.
isClientReactApi (e: { module: string; export: string; }) => boolean
React APIs that only work in a component instance the browser keeps alive: hooks, portals.
isDomGlobal (name: string) => boolean
isMutableState (ir: IR) => boolean
Whether a definition is module-level mutable state: a `const` holding a fresh mutable object (`new Map()`, `[]`, `{}`), as opposed to a function, a primitive, an `as const` value or anything frozen or computed.
namespacedClientApi (ir: IR) => string | undefined
`React.useState(…)` through `import * as React` or `import React`: the same hooks, used as properties.
packageRefKey (ext: ExtRef) => string
A package's export as server components send it by reference, and the browser finds it: `npm:pkg@1/sub#Name`
passedRefs (ir: unknown) => Set<string>
The definitions a definition's code (its stored IR) uses as values: given to something (a prop, an argument, `.bind(…)`), not called, and not rendered as an element's tag. What a server component passes this way, a browser component can call.
usesOf (rec: { spans: { hash?: string | undefined; pos: string; element?: boolean | undefined; }[]; }, sel…
References to a definition other than as a JSX tag: calls, reads, passing it along.

Tests

testPassedRefs () => void
testReactApiThatRendersAnywhere () => void
React's hooks are what make a component render in the browser; the react library's `match` and `<Stylesheet>` render anywhere, placed by their code as any library's are (`testLibrariesTcmShips` sees them so).
testTypesDontPlaceCode () => void
Types are erased: a global named only in them (a parameter's type, `as HTMLElement`, a variable's type, a type argument, `typeof window` in a type, a type or interface declared inside the code) doesn't run, so it doesn't place the code in the browser or on the server, or give it effects. Used as a value (read, called, `new`, `instanceof`, `typeof x` as an expression), it still does.
testWrittenOutCodeIsNotRun () => void
A function whose source code only writes out as text (`${f}`, `f.toString()`, `String(f)`), for something else to run, doesn't place that code with it, or give it its effects: it stays where its own code puts it. Calling the function, or passing it along, still does; and a constant's value, written into text, was computed by its code.