@valbuild/tanstack-build 0.0.1-alpha.0 → 0.135.0

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.
Files changed (33) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/dist/declarations/src/assets.d.ts +34 -0
  3. package/dist/declarations/src/build.d.ts +260 -0
  4. package/dist/declarations/src/buildTarget.d.ts +44 -0
  5. package/dist/declarations/src/contract.d.ts +135 -0
  6. package/dist/declarations/src/gitTree.d.ts +20 -0
  7. package/dist/declarations/src/index.d.ts +33 -0
  8. package/dist/declarations/src/node/cssModules.d.ts +2 -0
  9. package/dist/declarations/src/node/index.d.ts +18 -0
  10. package/dist/declarations/src/node/nodeShims.d.ts +74 -0
  11. package/dist/declarations/src/node/routeSplitter.d.ts +14 -0
  12. package/dist/declarations/src/node/routes.d.ts +29 -0
  13. package/dist/declarations/src/node/vendorLayer.d.ts +175 -0
  14. package/dist/declarations/src/paths.d.ts +4 -0
  15. package/dist/declarations/src/projectPaths.d.ts +14 -0
  16. package/dist/declarations/src/routeSplit.d.ts +29 -0
  17. package/dist/declarations/src/tailwind.d.ts +59 -0
  18. package/dist/declarations/src/tsconfigPaths.d.ts +34 -0
  19. package/dist/declarations/src/wire.d.ts +95 -0
  20. package/dist/slicedToArray-44c37acc.esm.js +303 -0
  21. package/dist/slicedToArray-7afed0af.cjs.prod.js +310 -0
  22. package/dist/slicedToArray-80b0ffd7.cjs.dev.js +310 -0
  23. package/dist/valbuild-tanstack-build.cjs.d.ts +2 -2
  24. package/dist/valbuild-tanstack-build.cjs.dev.js +3431 -0
  25. package/dist/valbuild-tanstack-build.cjs.js +6 -15
  26. package/dist/valbuild-tanstack-build.cjs.prod.js +3431 -0
  27. package/dist/valbuild-tanstack-build.esm.js +3402 -0
  28. package/node/dist/valbuild-tanstack-build-node.cjs.d.ts +2 -2
  29. package/node/dist/valbuild-tanstack-build-node.cjs.dev.js +2204 -0
  30. package/node/dist/valbuild-tanstack-build-node.cjs.js +6 -15
  31. package/node/dist/valbuild-tanstack-build-node.cjs.prod.js +2204 -0
  32. package/node/dist/valbuild-tanstack-build-node.esm.js +2165 -0
  33. package/package.json +3 -3
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Shims that are NOT a re-export of the real builtin.
3
+ *
4
+ * There used to be a long list here: a memory filesystem, a stubbed `os`, and a
5
+ * dozen modules whose every access threw by name. All of it rested on this
6
+ * file's original premise -- that the isolate does not provide these. It does.
7
+ * `/__api/builtins` on the loader asks a Dynamic Worker directly, and at
8
+ * compatibility date 2026-08-20 all 48 candidates import under both spellings,
9
+ * `fs` with 105 exports. The stubs were answering questions the runtime could
10
+ * answer better, and they were answering some of them WRONG: a hand-written
11
+ * `os` grew a member at a time, each discovered as `X is not a function` at
12
+ * runtime.
13
+ *
14
+ * So everything that can be is now a re-export (REEXPORT, below), and this is
15
+ * what is left.
16
+ */
17
+ export declare const NODE_SHIMS: Record<string, string>;
18
+ /**
19
+ * Builtins the isolate provides, re-exported through a bundled module.
20
+ *
21
+ * Not a stub -- these forward to the real thing. The reason they need a module
22
+ * at all is that a package requiring a builtin through CJS (`require("fs")`,
23
+ * which is what the TypeScript compiler does) becomes rolldown's `__require`
24
+ * against an external, and that throws at startup:
25
+ *
26
+ * Calling `require` for "fs" in an environment that doesn't expose the
27
+ * `require` function
28
+ *
29
+ * Routing the specifier to a bundled module turns that CJS require into a
30
+ * static ESM import of `node:fs`, which the isolate answers. That is the whole
31
+ * job: this is a CJS-to-ESM bridge, not a substitute runtime.
32
+ *
33
+ * The export names are ENUMERATED FROM NODE at build time rather than listed by
34
+ * hand. `export * from 'node:crypto'` cannot be checked against an external --
35
+ * rolldown does not know what the isolate's `node:crypto` exports, so a named
36
+ * import of it fails the build with "createPublicKey is not exported". Listing
37
+ * names by hand works and is endless: `fileURLToPath`, then `Module`, then
38
+ * `createPublicKey`, each discovered by a failed build.
39
+ *
40
+ * This CLI runs on Node, so the real module is right there to ask. A name Node
41
+ * has and the isolate does not yields `undefined`, which is what the real
42
+ * module would give.
43
+ *
44
+ * The list is every builtin the platform's dependencies have been seen to
45
+ * import, minus `path` (bundled above) -- NOT every builtin that exists.
46
+ * Importing one here costs a module load in this CLI, and the deprecated and
47
+ * experimental ones (`sys`, `wasi`, `repl`, `domain`, `trace_events`) print
48
+ * warnings for a name nothing emits. Add a name when something emits it; the
49
+ * audit will say so.
50
+ */
51
+ export declare const REEXPORT: string[];
52
+ /** Every shim, hand-written and generated, by builtin name. */
53
+ export declare function nodeShimSources(): Promise<Record<string, string>>;
54
+ /**
55
+ * The resolved-id prefix for a shim module. Exported so a test can ask the
56
+ * resolver what it does with a shim's own imports -- see scripts/shims-test.ts.
57
+ */
58
+ export declare const SHIM_PREFIX = "\0platform-node-shim:";
59
+ /**
60
+ * Routes a builtin specifier to a bundled module that forwards to the real one.
61
+ *
62
+ * Bundled rather than external on purpose, and the reason is the whole point of
63
+ * the file: an external leaves the CJS `require("fs")` as rolldown's
64
+ * `__require`, which an isolate with no `require` cannot answer. A bundled
65
+ * module turns it into an ESM import the isolate can.
66
+ */
67
+ export declare function nodeShims(enabled: boolean): Promise<{
68
+ name: string;
69
+ resolveId(source: string, importer: string | undefined): string | {
70
+ id: string;
71
+ external: boolean;
72
+ } | null;
73
+ load(id: string): string | null;
74
+ }>;
@@ -0,0 +1,14 @@
1
+ import type { RouteSplitter } from "../build.js";
2
+ /**
3
+ * Returns a splitter, or null when `@tanstack/router-plugin` is not installed
4
+ * where `from` can see it.
5
+ *
6
+ * Null rather than throwing: not splitting is a valid outcome, and a project
7
+ * that has not asked for it should not be made to install a build plugin.
8
+ *
9
+ * `from` is a DIRECTORY to resolve the plugin from, and it is the publisher's
10
+ * own -- see `loadCompilers`. A caller that wants the project's copy instead
11
+ * can pass the project directory, but that is a different decision from the
12
+ * one this was written for.
13
+ */
14
+ export declare function routeSplitter(from: string): Promise<RouteSplitter | null>;
@@ -0,0 +1,29 @@
1
+ /** A project is file-based if it has a routes directory. */
2
+ export declare function isFileBased(dir: string): Promise<boolean>;
3
+ /**
4
+ * The one line the platform needs from a file-based project.
5
+ *
6
+ * `src/app.tsx` is the entry the builder looks for, and for a routes-as-data
7
+ * project the user writes it. A file-based project has no such file -- its
8
+ * entry *is* the generated tree -- so this bridges the two contracts. A real
9
+ * integration would emit it rather than ask for it, which is what this is.
10
+ */
11
+ export declare const ENTRY_SHIM = "export { routeTree } from './routeTree.gen'\n";
12
+ /**
13
+ * Generates `routeTree.gen.ts` and returns the file map with it (and the entry
14
+ * shim) added.
15
+ *
16
+ * The generator's only interface is the filesystem, so this does write into the
17
+ * project -- and then puts it back exactly as it was. An earlier version left
18
+ * the file there, on the reasoning that the tree "is normally gitignored and
19
+ * regenerated, so writing it is not a surprise". That is false often enough to
20
+ * matter: `valbuild/template-tanstack-starter` *tracks* its `routeTree.gen.ts`,
21
+ * and running `pnpm report:project` against a checkout of it silently rewrote a
22
+ * committed file with different formatting and no eslint header. Inspecting a
23
+ * project should not modify it, least of all one the caller only pointed at.
24
+ *
25
+ * Only the in-memory copy is used for the build, so nothing needs the file to
26
+ * survive. A developer who wants it on disk runs `tsr generate`, which is the
27
+ * command that is supposed to produce it.
28
+ */
29
+ export declare function generateRouteTree(dir: string, files: Record<string, string>): Promise<Record<string, string>>;
@@ -0,0 +1,175 @@
1
+ import type { BuildTarget } from "../contract.js";
2
+ /**
3
+ * Packages the base layer already provides.
4
+ *
5
+ * A project declares these and must -- `packages/verify` fails a project that
6
+ * does not -- but they are supplied by the platform, so building them into a
7
+ * project layer would be the duplication described above.
8
+ */
9
+ export declare const BASE_PROVIDED: Set<string>;
10
+ /**
11
+ * Chunk filename for a package.
12
+ *
13
+ * `@scope/name` becomes `scope__name`: a flat, filesystem-safe name, since
14
+ * these are module-map keys and URL segments. A package literally named
15
+ * `scope__name` would collide with a scoped one; that is unlikely enough to
16
+ * take, and it would be caught here as a duplicate rather than silently.
17
+ */
18
+ export declare const chunkNameFor: (specifier: string) => string;
19
+ /**
20
+ * The platform a layer is built against, as facts rather than as imports.
21
+ *
22
+ * This module used to read `@valbuild/vendor/externals` and
23
+ * `@valbuild/vendor/resolve` directly, which is what kept it in the same
24
+ * repository as the vendor package -- the same knot `BuildTarget` untied for
25
+ * the browser builder, one level down. The facts have not changed and they are
26
+ * still the platform's; they now ARRIVE.
27
+ *
28
+ * The three are separate because they answer at different times.
29
+ * {@link base} crosses a wire, so it is data. The other two cannot: one
30
+ * resolves against a node_modules that only the platform's own checkout has,
31
+ * and the other is a directory in it. A host that has neither passes
32
+ * `() => null` and `null`, and says so by doing it.
33
+ */
34
+ export interface VendorPlatform {
35
+ /** `BuildTarget.base`: the specifier map and the paths that read it. */
36
+ base: BuildTarget["base"];
37
+ /**
38
+ * Where the PLATFORM's own copy of `specifier` is, as opposed to a project's.
39
+ *
40
+ * Null is the ordinary answer and not a failure: a project depends on plenty
41
+ * the platform has never heard of, and those layer from the project's own
42
+ * node_modules. What it is FOR is the `@tanstack/*` set, which has to agree
43
+ * with the base layer version for version -- see `pinPlatformTanstack`.
44
+ */
45
+ resolvePlatformModule: (specifier: string) => string | null;
46
+ /**
47
+ * Where the built base layer's chunks are, or null when this checkout has
48
+ * not built them.
49
+ *
50
+ * Only the export audit reads it, and only to check a named import against
51
+ * the chunk it will link to. Null means that check is skipped, which is the
52
+ * honest answer rather than a refusal -- see `baseChunkExports`.
53
+ */
54
+ baseLayerDir: string | null;
55
+ }
56
+ export interface VendorLayer {
57
+ rev: string;
58
+ /**
59
+ * Stylesheets a dependency ships, keyed by the specifier that imports them.
60
+ *
61
+ * `import 'react-day-picker/style.css'` is a bare specifier pointing at a
62
+ * file in node_modules, and the browser build has no node_modules. Resolved
63
+ * and read here, where there is one, and carried across with the layer --
64
+ * the same trade as the code, and for the same reason.
65
+ */
66
+ css: Record<string, string>;
67
+ /**
68
+ * Specifiers built for the worker but not the browser.
69
+ *
70
+ * A server-only dependency is not a failure. `@valbuild/tanstack/server`
71
+ * cannot build for a browser -- it reaches TanStack's SSR path, which lands
72
+ * on `node:stream/web` -- and has no business in a client bundle either.
73
+ * Dropping it entirely would mean such a package can never be layered, so it
74
+ * is layered for the side that can use it, and the builder rejects a client
75
+ * import of it by name.
76
+ */
77
+ workerOnly: Array<string>;
78
+ /**
79
+ * Why each `workerOnly` specifier failed its browser build.
80
+ *
81
+ * Reporting only, and deliberately not part of what a publish sends: the
82
+ * builder needs to know a dependency is server-only, not why. But without
83
+ * this the diagnosis stopped at "it could not be built for the browser",
84
+ * which does not tell you whether to move the import or fix the package.
85
+ */
86
+ workerOnlyReasons: Record<string, string>;
87
+ /**
88
+ * Specifiers that could not be built, with the reason.
89
+ *
90
+ * Dropped rather than fatal, because a manifest lists things the app never
91
+ * imports -- build plugins especially. `@tailwindcss/vite` is in the starter
92
+ * template's `dependencies` and pulls a native `.node` binary; failing the
93
+ * whole publish over a Vite plugin the isolate will never load would be
94
+ * wrong. Anything the app *does* import still fails, at the verify gate,
95
+ * naming the specifier.
96
+ */
97
+ skipped: Array<{
98
+ specifier: string;
99
+ reason: string;
100
+ }>;
101
+ /** Specifier -> chunk name, which is what the builder resolves imports with. */
102
+ modules: Record<string, string>;
103
+ /** Module-map entries for the isolate, keyed `pvendor/<file>`. */
104
+ worker: Record<string, string>;
105
+ /** Browser chunks, served under `/_pvendor/<rev>/`. */
106
+ browser: Record<string, string>;
107
+ }
108
+ /**
109
+ * Every import a project chunk emits has to resolve inside the isolate: into
110
+ * the base layer, at a sibling chunk, or at a Node builtin the runtime
111
+ * provides. Anything else is a bare specifier with no module-map entry, and it
112
+ * fails at *startup* rather than at build time -- so it is checked here, where
113
+ * the cause is still in view.
114
+ *
115
+ * Parsed, not matched. This used to scan the emitted text with
116
+ * `/from\s*["']([^"']+)["']/`, which also matches inside string literals -- and
117
+ * TypeScript's diagnostic messages contain
118
+ * `Consider using 'import * as ns from "mod"'`. So bundling the TypeScript
119
+ * compiler was rejected for importing a package called `mod`, which does not
120
+ * exist and which nothing imported. `prettier` was rejected the same way. Both
121
+ * looked exactly like a genuine unresolvable dependency.
122
+ */
123
+ interface AuditableImport {
124
+ /** The specifier, exactly as emitted. */
125
+ source: string;
126
+ /**
127
+ * The names taken from it, as the OTHER module has to export them.
128
+ *
129
+ * `import { a as b }` and `export { a as b } from` both want `a`. A default
130
+ * import wants `default`. A namespace import wants nothing in particular, so
131
+ * it contributes no names -- and `export * from` cannot be checked this way
132
+ * either, which is fine: neither can fail to link.
133
+ */
134
+ names: Array<string>;
135
+ }
136
+ /** Every import and re-export a chunk emits, with the names it takes. */
137
+ export declare function auditableImports(code: string, file: string): Promise<Array<AuditableImport>>;
138
+ export declare function auditableSpecifiers(code: string, file: string): Promise<Array<string>>;
139
+ /** Bare specifiers that point at a stylesheet rather than a module. */
140
+ export declare function cssSpecifiersOf(files: Record<string, string>): string[];
141
+ /** The package a bare specifier belongs to. `@scope/pkg/sub` -> `@scope/pkg`. */
142
+ export declare function packageOf(specifier: string): string;
143
+ /**
144
+ * What the layer has to carry: every specifier the project imports, not every
145
+ * package it declares.
146
+ *
147
+ * Specifiers rather than package names, because a subpath is a different entry
148
+ * point with a different module graph -- the starter template imports
149
+ * `@valbuild/tanstack`, `@valbuild/tanstack/client` *and*
150
+ * `@valbuild/tanstack/server`, and a layer built from package names alone
151
+ * resolves one of the three.
152
+ *
153
+ * Intersected with the manifest, so a typo'd import does not silently become a
154
+ * layer entry and an undeclared dependency still fails the verify gate.
155
+ */
156
+ export declare function layerDepsOf(manifest: {
157
+ dependencies?: Record<string, string>;
158
+ }, files?: Record<string, string>): Array<string>;
159
+ /**
160
+ * Builds the layer, from the dependencies installed in `dir`.
161
+ *
162
+ * Returns `null` when the project declares nothing beyond the base set, which
163
+ * is the same thing as having no layer -- not an empty one, because the head
164
+ * pointer distinguishes "no layer" from "a layer that is missing".
165
+ */
166
+ /**
167
+ * Reads the stylesheets a project imports from its dependencies.
168
+ *
169
+ * Separate from the code build: these are not bundled, they are concatenated
170
+ * into the project's stylesheet by the builder's CSS pass. Resolution is the
171
+ * project's own, so the version matches whatever its lockfile pinned.
172
+ */
173
+ export declare function collectDependencyCss(dir: string, specifiers: Array<string>): Promise<Record<string, string>>;
174
+ export declare function buildVendorLayer(dir: string, deps: Array<string>, css: Record<string, string>, platform: VendorPlatform): Promise<VendorLayer | null>;
175
+ export {};
@@ -0,0 +1,4 @@
1
+ export declare function dirname(path: string): string;
2
+ export declare function resolve(from: string, to: string): string;
3
+ /** Resolve a relative import against the in-memory file set. */
4
+ export declare function resolveInFiles(base: string, files: Record<string, string>): string | null;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Paths the platform's contract fixes, in one place.
3
+ *
4
+ * These are not conventions this package chose -- `src/app.tsx` is the module
5
+ * the builder resolves as its entry, and `src/routeTree.gen.ts` is what
6
+ * TanStack's generator is configured to write. They are here so that a change
7
+ * on either side is one edit rather than a search for string literals.
8
+ */
9
+ /** The module the builder uses as the project's entry. */
10
+ export declare const ENTRY = "src/app.tsx";
11
+ /** Where TanStack's generator writes the route tree. */
12
+ export declare const TREE = "src/routeTree.gen.ts";
13
+ /** Where a file-based project keeps its route files. */
14
+ export declare const ROUTES_DIR = "src/routes";
@@ -0,0 +1,29 @@
1
+ export interface RouteSplitter {
2
+ /**
3
+ * Rewrites a route file to defer its split options.
4
+ *
5
+ * Returns null when the file has nothing to split, which is most of them.
6
+ */
7
+ reference(id: string, code: string): {
8
+ code: string;
9
+ } | null;
10
+ /** Produces the deferred half, containing only `targets`. */
11
+ virtual(id: string, code: string, targets: Array<string>): {
12
+ code: string;
13
+ };
14
+ }
15
+ /** Query Start's splitter emits, e.g. `?tsr-split=component---errorComponent`. */
16
+ export declare const SPLIT_QUERY = "tsr-split";
17
+ /** Is this a route file, i.e. one the splitter should look at? */
18
+ export declare const isRouteFile: (path: string, routesDir?: string) => boolean;
19
+ export interface SplitRequest {
20
+ path: string;
21
+ targets: Array<string>;
22
+ }
23
+ /**
24
+ * Reads `./posts.tsx?tsr-split=component---errorComponent`.
25
+ *
26
+ * Returns null for anything else, including a `?raw` or `?url` query, so the
27
+ * caller can fall through to its other handling.
28
+ */
29
+ export declare function parseSplitRequest(source: string): SplitRequest | null;
@@ -0,0 +1,59 @@
1
+ import { compile } from "tailwindcss";
2
+ /** Does this stylesheet ask for Tailwind at all? */
3
+ export declare const usesTailwind: (css: string) => boolean;
4
+ /**
5
+ * Loads a JS module for `@plugin` / `@config`.
6
+ *
7
+ * Tailwind resolves and *executes* these while compiling CSS, which is the one
8
+ * thing this build cannot do on its own: there is no module resolution here,
9
+ * only a fixed set of externals. So it is a capability the caller supplies --
10
+ * `packages/publish` has a real filesystem and node_modules and passes one; a
11
+ * browser build has neither and does not.
12
+ *
13
+ * Absent, this throws rather than returning an empty plugin. A plugin that
14
+ * silently does nothing leaves a page subtly unstyled, which is much harder to
15
+ * diagnose than a build that stops and names the directive -- and it would make
16
+ * the same project build differently depending on where it was published.
17
+ */
18
+ type CompileOptions = NonNullable<Parameters<typeof compile>[1]>;
19
+ /**
20
+ * Derived from Tailwind's own option rather than restated.
21
+ *
22
+ * It used to be restated -- `(id, base, hint: string) => Promise<{ module:
23
+ * unknown; base: string }>` -- and the restatement was WRONG: Tailwind also
24
+ * wants a `path`, and the loader in the CLI never sent one. Nothing caught it
25
+ * because the package this came from ran under `--experimental-strip-types`,
26
+ * which strips types without checking them, so the mismatch was invisible on
27
+ * both sides of the call.
28
+ *
29
+ * Derived, a Tailwind upgrade that changes the shape is a compile error here
30
+ * -- which is where it can be read -- rather than an `undefined` handed to
31
+ * someone else's code.
32
+ */
33
+ export type CssModuleLoader = NonNullable<CompileOptions["loadModule"]>;
34
+ /** What a `@plugin` / `@config` module has to be, once it is loaded. */
35
+ export type LoadedCssModule = Awaited<ReturnType<CssModuleLoader>>["module"];
36
+ /**
37
+ * Candidates for `build()`, extracted from the project's own source.
38
+ *
39
+ * Every string in every module, not just JSX class attributes: a class name can
40
+ * be built anywhere -- a `cn()` helper, a lookup table, a constant in another
41
+ * file -- and Tailwind's own scanner makes the same choice for the same reason.
42
+ */
43
+ export declare function scanCandidates(files: Record<string, string>): Array<string>;
44
+ export interface TailwindResult {
45
+ css: string;
46
+ /** Directives this build cannot honour, as messages for the caller. */
47
+ warnings: Array<string>;
48
+ candidates: number;
49
+ ms: number;
50
+ }
51
+ /**
52
+ * Runs the project's stylesheet through Tailwind.
53
+ *
54
+ * The input is the *already concatenated* project CSS, so a project's own rules
55
+ * and its `@import "tailwindcss"` are compiled together and the cascade order
56
+ * the CSS pass worked out is preserved.
57
+ */
58
+ export declare function compileTailwind(css: string, files: Record<string, string>, loadModule?: CssModuleLoader): Promise<TailwindResult>;
59
+ export {};
@@ -0,0 +1,34 @@
1
+ /**
2
+ * JSON with comments and trailing commas, which is what tsconfig.json is.
3
+ *
4
+ * Written as a scanner rather than a regex on purpose: `"url": "https://x"`
5
+ * contains `//`, and a regex that strips comments without tracking string state
6
+ * truncates the file there and throws a parse error pointing at the wrong line.
7
+ */
8
+ export declare function parseJsonc(text: string): unknown;
9
+ export interface AliasMap {
10
+ /** Candidate paths for a specifier, best first. Empty when nothing matches. */
11
+ candidates: (specifier: string) => Array<string>;
12
+ /**
13
+ * The `baseUrl` fallback, tried after `candidates` and reported differently.
14
+ *
15
+ * TypeScript resolves a bare specifier against `baseUrl` even with no `paths`
16
+ * entry at all -- `"baseUrl": "src"` makes `import 'components/Button'` work.
17
+ * Verified against ts.resolveModuleName rather than assumed.
18
+ *
19
+ * Kept separate from `candidates` because a miss means something different:
20
+ * an unresolved `paths` match is a typo (PLATFORM405), but an unresolved baseUrl
21
+ * guess is almost always just an npm package that is not in the vendor set,
22
+ * and reporting *that* as a broken alias would be the wrong diagnosis.
23
+ */
24
+ baseUrlCandidate: (specifier: string) => string | null;
25
+ /** The raw pattern list, for reporting a pattern that shadows a vendor package. */
26
+ patterns: Array<string>;
27
+ }
28
+ /**
29
+ * Reads tsconfig.json out of the file record and builds the matcher.
30
+ *
31
+ * Returns null when the project configures no aliases, which is the common
32
+ * case and costs nothing.
33
+ */
34
+ export declare function aliasMap(files: Record<string, string>, warn: (message: string) => void, entry?: string): AliasMap | null;
@@ -0,0 +1,95 @@
1
+ export interface Change {
2
+ what: string;
3
+ why: string;
4
+ }
5
+ export interface WireResult {
6
+ files: Record<string, string>;
7
+ changes: Array<Change>;
8
+ /** Things that will bite later, reported rather than fixed. */
9
+ warnings: Array<string>;
10
+ }
11
+ export interface WireOptions {
12
+ /** The project id the app puts its pending source under, as a fallback. */
13
+ project: string;
14
+ /**
15
+ * The platform's control plane.
16
+ *
17
+ * No longer baked into the generated file -- a save posts to the sentinel
18
+ * host the platform intercepts, because an isolate cannot fetch the loader's
19
+ * real address. Kept because a caller still identifies the platform it is
20
+ * wiring for, and the next thing that needs it will want it here.
21
+ */
22
+ loader: string;
23
+ /**
24
+ * The commit this source was read at, and the branch a publish commits to.
25
+ *
26
+ * Load bearing rather than bookkeeping. Val reads a project's content from
27
+ * the content service AT A COMMIT, so a build wired with the wrong one edits
28
+ * and renders a different version of its files than the code it is running.
29
+ *
30
+ * Absent for a source that came from no commit at all -- a record assembled
31
+ * in a tab, a fixture. Such a build serves its pages and cannot edit, which
32
+ * the generated file decides in one place rather than failing five ways.
33
+ */
34
+ git?: {
35
+ commit: string;
36
+ branch: string;
37
+ };
38
+ }
39
+ /**
40
+ * Where a Val project keeps the module this replaces.
41
+ *
42
+ * Exported because a caller has to be able to rewrite JUST this file. The
43
+ * commit is baked into it (see `BUILT_FROM` in the template), and the files a publish
44
+ * hands over are the `.val.ts` ones it patched -- this is never among them, so a tab
45
+ * that merged a save and rebuilt would compile the NEW content against the OLD
46
+ * commit and read the wrong version of it back.
47
+ */
48
+ export declare const VAL_SERVER_PATH = "src/val/val.server.ts";
49
+ /**
50
+ * The wired `val.server.ts`, on its own.
51
+ *
52
+ * {@link wireUp} does this and eight other things, which is right when a
53
+ * repository arrives and wrong every time a build is about to run: re-deriving
54
+ * a package.json and a route entry to change one baked-in sha would be a lot of
55
+ * machinery to get a one-line difference, and any of it not being idempotent
56
+ * would be a bug that only shows up on the second publish.
57
+ */
58
+ export declare function wiredValServer(options: WireOptions): string;
59
+ /**
60
+ * The commit a wired record was last built at, read back out of the file.
61
+ *
62
+ * The inverse of `BUILT_FROM` in the template, and it lives here so that one place
63
+ * knows the format -- a reader elsewhere would go stale the first time the
64
+ * template's shape changed, and silently, since a failed parse and a build
65
+ * with no commit look identical.
66
+ *
67
+ * There is nowhere else this could come from. A record adopted from the live
68
+ * build IS the published source, and the commit it was published at is a
69
+ * literal inside its own `val.server.ts`.
70
+ */
71
+ export declare function bakedGit(files: Record<string, string>): {
72
+ commit: string;
73
+ branch: string;
74
+ } | undefined;
75
+ /** Is this a Val project at all? */
76
+ export declare function isValProject(files: Record<string, string>): boolean;
77
+ /**
78
+ * Has this record already been wired up?
79
+ *
80
+ * The control host is the marker. It used to be `platform:project-source`,
81
+ * which the generated file imported while Val was in memory mode and no longer
82
+ * does -- the project's source stopped being shipped into the isolate when the
83
+ * content service became what answers for it. The pending-source POST is the
84
+ * thing that cannot be anything but this platform's: no repository posts to a
85
+ * host that resolves
86
+ * nowhere, and every wired file has to, because an isolate cannot build.
87
+ */
88
+ export declare function isWired(files: Record<string, string>): boolean;
89
+ /**
90
+ * Returns the record with the platform's wiring applied, and what it changed.
91
+ *
92
+ * Non-destructive, and that matters more than it looks: the caller's record is
93
+ * what an edit is applied to, and the source that gets published back.
94
+ */
95
+ export declare function wireUp(files: Record<string, string>, options: WireOptions): WireResult;