tcmts.core.analyze

Types

Analysis type
AnalyzeHost type
ProjectAnalysis type
ProjectDef type
WatchRecord type

Server

analyzeFile (file: string, host: AnalyzeHost) => Analysis
Analyze one scratch file: bare expressions are watch expressions.
analyzeProject (files: string[], host: AnalyzeHost, mode?: ExtractMode) => ProjectAnalysis
Analyze files together, as one dependency graph: references between them (including through re-export barrels and workspace packages) become hash references, and import cycles become hash cycles.
analyzeSources (sfs: SourceFile[], checker: Checker, host: AnalyzeHost, mode: ExtractMode, options: CompilerOption…
analyzeWith (files: string[], host: AnalyzeHost, mode: ExtractMode) => Omit<ProjectAnalysis, "packages">
dynamicImportClassifier (file: string, host?: AnalyzeHost | undefined) => (spec: string, at: Node) => ExtRef
`import("pkg")` loads a package lazily; it's as content-addressable as a static import of the same package.
externalModule (spec: string, file: string, at: Node, exportName: string, host?: AnalyzeHost | undefined) => ExtRef
A Node builtin or an npm package (version pinned from node_modules), as imported from `file`.
findPackage (name: string, fromDir: string) => { name: string; version: string; } | undefined
importClassifier (file: string, host: AnalyzeHost) => (d: ImportClause | ImportSpecifier | NamespaceImport, meaning:…
isReactApiFile (spec: string, file: string, host: AnalyzeHost) => boolean
The generated runtime of `#tcm/react`, as cache modules and re-analyzed definitions import it.
isServerHostFile (spec: string, file: string, host: AnalyzeHost) => boolean
The generated runtime of `#tcm/host`, as cache modules and re-analyzed definitions import it.
prefetched (checker: Checker, roots: Node[]) => SymbolLookup
The checker's answers canonicalization needs, asked in batches: every identifier's symbol (and every shorthand property's value) in a few round trips to the compiler process, then every alias's target. Anything not asked ahead is asked when needed. Not a structural name's (`b` in `a.b`, a key, a member): canonicalization doesn't resolve those, and the checker would infer the type of what's left of them to answer. And the modules the files import from (a reference to an import is checked against its module), and what's asked later is kept too: a program's answers don't change.
readPackage (dir: string) => { name: string; version: string; } | undefined
reexportClassifier (checker: Checker, host: AnalyzeHost) => (sf: SourceFile, name: string, at: Node) => ExtRef | undef…
What a project module re-exports from a package under a name: `export { x as name } from "pkg"`, a name of `pkg`'s in `export * from "pkg"`, or the package's namespace in `export * as name from "pkg"`. Using it through the module is using the package's export.
tableOf (site: DefSite, checker: Checker, roleOf?: ((d: ImportSpecifier) => string | undefined) | undefined…
`const users = table<User>("users")` with `table` a codebase definition with the `table` role (`roleOf`: by its hash, as the server library's has), or where the definition was a table (`was`: code analyzed again): the row type is erased at runtime, but it's known here, so its schema (and that schema's hash) travel with the definition.
typedSites (sites: DefSite[], lookup: SymbolLookup, checker: Checker) => { signatures: Map<DefSite, string>; p…
The signatures, and functions' parameter schemas, of `sites`, as `signatureOf` and `paramsOf` work them out, but asked of the compiler a stage at a time for all of them (their types, how each prints, functions' call signatures, their parameters, those parameters' types) in a few round trips rather than a few for each. A site it can't tell (none named, or no symbol) is left to them.

Shared

NAMESPACE_PRAGMA RegExp
SERVER_API "#tcm/server"
tcm's own server API (request context, cookies, sessions): unversioned, like a Node builtin.
SERVER_HOST "#tcm/host"
tcm's server host interface, for a server API library: what needs the process (the call, SQLite, transactions, jobs). Unversioned, like a Node builtin: its version is the host protocol's.
TCM_REACT_GONE "#tcm/react is the react library now: `tcm lib add tcm react` mounts the one tcm ships (at <root>.l…
What an import of `#tcm/react` is told: it was the module tcm generated for React's routes, links and data, which are the react library tcm ships now.
TCM_SERVER_GONE "#tcm/server is the server library now: `tcm lib add tcm server` mounts the one tcm ships (at <root…
What an import of `#tcm/server` is told: it was the module tcm generated for the server API, which is the server library tcm ships now.
buildSource (pieces: Piece[], sf: SourceFile) => { text: string; map: (pos: number) => number; }
defRefsInOrder (ir: IR, out?: number[]) => number[]
indexes WeakMap<SourceFile, Map<number, Node>>
A file's nodes by their index, for turning a checker's NodeHandle into the node it denotes.
nodeIndex (sf: SourceFile) => Map<number, Node>
observed Map<string, string> | undefined
The exact versions packages resolve to during the analysis running now, by pinned module.
paramsOf (site: DefSite, checker: Checker) => ParamsSchema | undefined
saltOf (ir: string) => string | undefined
The lineage salt recorded in a stored definition's IR, if any.
scratchNamespace (text: string) => string | undefined
The target namespace of a scratch file, from a `// tcm: namespace a.b` pragma in its first lines.
signatureOf (site: DefSite, checker: Checker) => string
substDefs (ir: IR, f: (def: number) => IR) => IR
tableOptions (opts: ExpressionBase | undefined, checker: Checker) => Partial<TableSchema>
What a table's options literal says about migration steps, constraints and renames.
tarjan (n: number, succ: (v: number) => Iterable<number>) => number[][]
Tarjan's SCC. Components come out dependencies-first.