@loozo/angular-launch 0.0.1 → 0.0.3

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.
@@ -68,10 +68,10 @@ export function injectClient(groups) {
68
68
  for (const method of group.methods) {
69
69
  let invoke;
70
70
  if (method.input) {
71
- invoke = (input, options) => call(http, group.id, method, input, options);
71
+ invoke = (input, options) => call(http, namespace, method, input, options);
72
72
  }
73
73
  else {
74
- invoke = (options) => call(http, group.id, method, null, options);
74
+ invoke = (options) => call(http, namespace, method, null, options);
75
75
  }
76
76
  methods[method.name] = Object.assign(invoke, {
77
77
  kind: method.kind,
@@ -80,7 +80,7 @@ export function injectClient(groups) {
80
80
  return false;
81
81
  }
82
82
  const owner = errorOwners.get(error);
83
- return owner?.group === group.id && owner.method === method.name;
83
+ return owner?.group === namespace && owner.method === method.name;
84
84
  },
85
85
  });
86
86
  }
@@ -0,0 +1,116 @@
1
+ /** Options for {@link generate} and {@link createGenerationSession}. */
2
+ export interface GenerationOptions {
3
+ /** The application's tsconfig, relative to the workspace. It must enable strict checking. */
4
+ tsconfig: string;
5
+ /** Exactly one route directory, relative to the tsconfig's directory. */
6
+ scanDirectories: string[];
7
+ /** Where the application-wide generated files go, relative to the workspace. */
8
+ outDirectory: string;
9
+ /**
10
+ * Verifies the generated files without writing them, failing when any is changed,
11
+ * missing or stale. Defaults to `false`.
12
+ */
13
+ check?: boolean;
14
+ }
15
+ /**
16
+ * A generation session created by {@link createGenerationSession}, reusing compiler
17
+ * work between calls.
18
+ */
19
+ export interface GenerationSession {
20
+ /**
21
+ * Generates or checks the application's files, like {@link generate} with the
22
+ * session's options.
23
+ *
24
+ * @remarks
25
+ * Calls must be sequential. A failed call doesn't break the session; the next call
26
+ * starts clean.
27
+ *
28
+ * @param options - `check`: verify without writing. Defaults to `false`.
29
+ * @param stopped - Called once just before writing; returning `true` skips writing and
30
+ * resolves. Defaults to never stopping.
31
+ * @returns A promise that resolves when generation finishes.
32
+ * @throws Rejects when the session is disposed, when another call hasn't settled yet,
33
+ * and for the same failures as {@link generate}.
34
+ */
35
+ generate(options?: Pick<GenerationOptions, "check">, stopped?: () => boolean): Promise<void>;
36
+ /**
37
+ * Disposes the session: stops an active call before it writes, waits for it to settle
38
+ * and makes later calls reject.
39
+ *
40
+ * @returns A promise that resolves once any active call has settled.
41
+ */
42
+ dispose(): Promise<void>;
43
+ }
44
+ /**
45
+ * Generates the router's and Launch's files for an application, or checks them.
46
+ *
47
+ * @remarks
48
+ * Node-only. Generation reads your sources without running them. Besides the router's
49
+ * files, it writes an `rpc.generated.ts` beside each route that gets a
50
+ * `route.generated.ts`, and `context.generated.d.ts` and `server.generated.ts` in the
51
+ * output directory. Run it before the Angular build.
52
+ *
53
+ * Everything is validated, including a type check of the generated files with
54
+ * `skipLibCheck: false`, before anything is written, so a failed run changes nothing.
55
+ * Files are then written one at a time without rollback; a write error partway through
56
+ * can leave some files updated, which the next successful run repairs. Generation only
57
+ * replaces or removes files carrying its ownership marker, and removes stale ones.
58
+ *
59
+ * @example
60
+ * ```js
61
+ * import { generate } from "@loozo/angular-launch/generation";
62
+ *
63
+ * await generate(import.meta.dirname, {
64
+ * tsconfig: "tsconfig.app.json",
65
+ * scanDirectories: ["src/routes"],
66
+ * outDirectory: "generated",
67
+ * check: process.argv.includes("--check"),
68
+ * });
69
+ * ```
70
+ *
71
+ * @param workspace - The absolute path of the application directory, which contains
72
+ * its `package.json`. The tsconfig, scanned directory, sources and output directory
73
+ * must all be inside it.
74
+ * @param options - The generation options.
75
+ * @param stopped - Called once just before writing; returning `true` skips writing and
76
+ * resolves. Defaults to never stopping.
77
+ * @returns A promise that resolves when generation finishes.
78
+ * @throws Rejects when a path escapes the workspace, the tsconfig disables strict
79
+ * checking or enables `noCheck`, the application's `package.json` has no `name`, the
80
+ * sources or generated files fail validation, a file to replace lacks the ownership
81
+ * marker, or, with `check`, a generated file is out of date.
82
+ */
83
+ export declare function generate(workspace: string, options: GenerationOptions, stopped?: () => boolean): Promise<void>;
84
+ /**
85
+ * Creates a generation session that reuses compiler work between sequential calls.
86
+ *
87
+ * @remarks
88
+ * Node-only. For long-running tools that regenerate repeatedly, such as after file
89
+ * changes. A session doesn't watch files; you decide when to call `generate`. Edits
90
+ * inside the application are picked up by the next call. Create a new session after
91
+ * moving the application directory or changing dependencies. Don't run two sessions or
92
+ * generators against the same output at once.
93
+ *
94
+ * @example
95
+ * ```js
96
+ * const session = createGenerationSession(workspace, {
97
+ * tsconfig: "tsconfig.app.json",
98
+ * scanDirectories: ["src/routes"],
99
+ * outDirectory: "generated",
100
+ * });
101
+ *
102
+ * try {
103
+ * await session.generate();
104
+ * await session.generate({ check: true });
105
+ * } finally {
106
+ * await session.dispose();
107
+ * }
108
+ * ```
109
+ *
110
+ * @param workspace - The absolute path of the application directory, as for
111
+ * {@link generate}.
112
+ * @param options - The generation options, fixed for the session's lifetime; `check` is
113
+ * passed per call instead.
114
+ * @returns The session. Dispose it when done.
115
+ */
116
+ export declare function createGenerationSession(workspace: string, { tsconfig, scanDirectories, outDirectory }: Omit<GenerationOptions, "check">): GenerationSession;
@@ -79,6 +79,7 @@ async function groupsOf(sources) {
79
79
  }
80
80
  const groups = [];
81
81
  const owners = new Set();
82
+ const namespaces = new Map();
82
83
  for (const declaration of launch.declarations) {
83
84
  if (declaration.kind !== "defineRpc") {
84
85
  continue;
@@ -104,6 +105,11 @@ async function groupsOf(sources) {
104
105
  if (namespace.text === "__proto__") {
105
106
  fail(namespace, "RPC namespace '__proto__' is reserved");
106
107
  }
108
+ const previous = namespaces.get(namespace.text);
109
+ if (previous) {
110
+ fail(namespace, `Duplicate RPC namespace: ${namespace.text}; also defined in ${previous.file}`);
111
+ }
112
+ namespaces.set(namespace.text, declaration);
107
113
  if (options) {
108
114
  const fields = properties(options, "RPC group options");
109
115
  onlyKeys(fields, ["canActivate"], options);
@@ -145,9 +151,7 @@ async function groupsOf(sources) {
145
151
  call: procedure,
146
152
  });
147
153
  }
148
- const identity = relative(dirname(sources.configFile), declaration.file).split(sep).join("/");
149
- const id = createHash("sha256").update(`launch-v1\0${identity}`).digest("hex").slice(0, 24);
150
- groups.push({ declaration, owner, namespace: namespace.text, id, methods });
154
+ groups.push({ declaration, owner, namespace: namespace.text, methods });
151
155
  }
152
156
  return { context, groups };
153
157
  }
@@ -167,12 +171,12 @@ function emitLaunch(sources, desired, context, groups, appId) {
167
171
  const server = [
168
172
  launchMarkers["server.generated.ts"],
169
173
  payloadImport(registry, context.file, "context"),
170
- `import { createRequestScope, handleRpc, provideLaunchServer } from '@loozo/angular-launch/server';`,
174
+ `import { createRequestScope, handleRpc, provideLaunchServer } from '@loozo/angular-launch/_server';`,
171
175
  ];
172
176
  for (let index = 0; index < groups.length; index += 1) {
173
177
  server.push(payloadImport(registry, groups[index].declaration.file, `group${index}`));
174
178
  }
175
- server.push(`export const registry = { ${groups.map((group, index) => `${JSON.stringify(group.id)}: group${index}`).join(", ")} };`, `export const appBinding = { id: ${JSON.stringify(appId)}, context };`, `export const createContext = (request: Request) => createRequestScope(appBinding, request);`, `export const handleRequest = (request: Request) => handleRpc(registry, appBinding, request);`, `export const provideServer = () => provideLaunchServer(registry, appBinding);`, "");
179
+ server.push(`export const registry = { ${groups.map((group, index) => `${JSON.stringify(group.namespace)}: group${index}`).join(", ")} };`, `export const appBinding = { id: ${JSON.stringify(appId)}, context };`, `export const createContext = (request: Request) => createRequestScope(appBinding, request);`, `export const handleRequest = (request: Request) => handleRpc(registry, appBinding, request);`, `export const provideServer = () => provideLaunchServer(registry, appBinding);`, "");
176
180
  add(desired, registry, server.join("\n"));
177
181
  const byOwner = new Map(groups.map((group) => [group.owner, group]));
178
182
  for (const owner of sources.declarations) {
@@ -180,15 +184,10 @@ function emitLaunch(sources, desired, context, groups, appId) {
180
184
  continue;
181
185
  }
182
186
  const available = [];
183
- const namespaces = new Set();
184
187
  let current = owner;
185
188
  while (current) {
186
189
  const group = byOwner.get(current);
187
190
  if (group) {
188
- if (namespaces.has(group.namespace)) {
189
- fail(group.declaration.call, `Duplicate RPC namespace in ancestry: ${group.namespace}`);
190
- }
191
- namespaces.add(group.namespace);
192
191
  available.unshift(group);
193
192
  }
194
193
  current = current.parent;
@@ -204,7 +203,6 @@ function emitLaunch(sources, desired, context, groups, appId) {
204
203
  const group = available[index];
205
204
  lines.push(payloadImport(file, group.declaration.file, `group${index}`, true));
206
205
  metadata[group.namespace] = {
207
- id: group.id,
208
206
  methods: group.methods.map(({ name, input, kind, errors }) => ({
209
207
  name,
210
208
  input,
@@ -425,7 +423,8 @@ function checkGeneratedDomain(sources, validation, generated) {
425
423
  }
426
424
  }
427
425
  async function runGeneration(workspace, options, stopped, compiler) {
428
- const root = fileURLToPath(new URL("../../", import.meta.url));
426
+ // The built package root (dist/ in the workspace, the tarball root when installed).
427
+ const root = fileURLToPath(new URL("../", import.meta.url));
429
428
  const manifest = JSON.parse(await readFile(resolve(root, "package.json"), "utf8"));
430
429
  const typeEntry = await realpath(resolve(root, manifest.exports["./server"].types));
431
430
  const application = await realpath(workspace);
@@ -497,10 +496,80 @@ async function runGeneration(workspace, options, stopped, compiler) {
497
496
  checkGeneratedDomain(sources, validation, desired);
498
497
  publish(plan, options.check === true, stopped, new Map(), new Set());
499
498
  }
499
+ /**
500
+ * Generates the router's and Launch's files for an application, or checks them.
501
+ *
502
+ * @remarks
503
+ * Node-only. Generation reads your sources without running them. Besides the router's
504
+ * files, it writes an `rpc.generated.ts` beside each route that gets a
505
+ * `route.generated.ts`, and `context.generated.d.ts` and `server.generated.ts` in the
506
+ * output directory. Run it before the Angular build.
507
+ *
508
+ * Everything is validated, including a type check of the generated files with
509
+ * `skipLibCheck: false`, before anything is written, so a failed run changes nothing.
510
+ * Files are then written one at a time without rollback; a write error partway through
511
+ * can leave some files updated, which the next successful run repairs. Generation only
512
+ * replaces or removes files carrying its ownership marker, and removes stale ones.
513
+ *
514
+ * @example
515
+ * ```js
516
+ * import { generate } from "@loozo/angular-launch/generation";
517
+ *
518
+ * await generate(import.meta.dirname, {
519
+ * tsconfig: "tsconfig.app.json",
520
+ * scanDirectories: ["src/routes"],
521
+ * outDirectory: "generated",
522
+ * check: process.argv.includes("--check"),
523
+ * });
524
+ * ```
525
+ *
526
+ * @param workspace - The absolute path of the application directory, which contains
527
+ * its `package.json`. The tsconfig, scanned directory, sources and output directory
528
+ * must all be inside it.
529
+ * @param options - The generation options.
530
+ * @param stopped - Called once just before writing; returning `true` skips writing and
531
+ * resolves. Defaults to never stopping.
532
+ * @returns A promise that resolves when generation finishes.
533
+ * @throws Rejects when a path escapes the workspace, the tsconfig disables strict
534
+ * checking or enables `noCheck`, the application's `package.json` has no `name`, the
535
+ * sources or generated files fail validation, a file to replace lacks the ownership
536
+ * marker, or, with `check`, a generated file is out of date.
537
+ */
500
538
  export function generate(workspace, options, stopped = () => false) {
501
539
  return runGeneration(workspace, options, stopped);
502
540
  }
503
- /** Owns compiler reuse for one explicitly sequenced application-generation lifetime. */
541
+ /**
542
+ * Creates a generation session that reuses compiler work between sequential calls.
543
+ *
544
+ * @remarks
545
+ * Node-only. For long-running tools that regenerate repeatedly, such as after file
546
+ * changes. A session doesn't watch files; you decide when to call `generate`. Edits
547
+ * inside the application are picked up by the next call. Create a new session after
548
+ * moving the application directory or changing dependencies. Don't run two sessions or
549
+ * generators against the same output at once.
550
+ *
551
+ * @example
552
+ * ```js
553
+ * const session = createGenerationSession(workspace, {
554
+ * tsconfig: "tsconfig.app.json",
555
+ * scanDirectories: ["src/routes"],
556
+ * outDirectory: "generated",
557
+ * });
558
+ *
559
+ * try {
560
+ * await session.generate();
561
+ * await session.generate({ check: true });
562
+ * } finally {
563
+ * await session.dispose();
564
+ * }
565
+ * ```
566
+ *
567
+ * @param workspace - The absolute path of the application directory, as for
568
+ * {@link generate}.
569
+ * @param options - The generation options, fixed for the session's lifetime; `check` is
570
+ * passed per call instead.
571
+ * @returns The session. Dispose it when done.
572
+ */
504
573
  export function createGenerationSession(workspace, { tsconfig, scanDirectories, outDirectory }) {
505
574
  const application = resolve(workspace);
506
575
  const fixed = { tsconfig, scanDirectories: [...scanDirectories], outDirectory };
package/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { RpcError, frameworkFailures } from "./client.js";
2
+ export type { CallOptions, MutationCallOptions, Client, ClientProcedure, ClientRpcError, FrameworkCode, } from "./client.js";
package/index.js ADDED
@@ -0,0 +1 @@
1
+ export { RpcError, frameworkFailures } from "./client.js";
@@ -1,6 +1,12 @@
1
- export type Json = null | boolean | number | string | readonly Json[] | {
2
- readonly [key: string]: Json;
3
- };
1
+ /**
2
+ * The strict JSON shape of `Value`: `never` wherever `Value` isn't strict JSON.
3
+ *
4
+ * @remarks
5
+ * Procedure inputs, results and error data must satisfy it. Functions become `never`;
6
+ * arrays and objects are checked element by element.
7
+ *
8
+ * @typeParam Value - The type to check.
9
+ */
4
10
  export type JsonShape<Value> = Value extends null | boolean | number | string ? Value : Value extends (...args: never[]) => unknown ? never : Value extends readonly (infer Element)[] ? readonly JsonShape<Element>[] : Value extends object ? {
5
11
  readonly [Key in keyof Value]-?: Key extends string | number ? JsonShape<Value[Key]> : never;
6
12
  } : never;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loozo/angular-launch",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "Typed queries, mutations and declared errors on Angular's native router, HTTP and SSR pipeline.",
5
5
  "bugs": "https://github.com/theo-matzavinos/loozo/issues",
6
6
  "license": "MIT",
@@ -10,27 +10,27 @@
10
10
  "url": "git+https://github.com/theo-matzavinos/loozo.git",
11
11
  "directory": "packages/angular-launch"
12
12
  },
13
- "files": [
14
- "dist",
15
- "README.md"
16
- ],
17
13
  "type": "module",
18
14
  "exports": {
19
15
  ".": {
20
- "types": "./dist/client.d.ts",
21
- "default": "./dist/client.js"
16
+ "types": "./index.d.ts",
17
+ "default": "./index.js"
22
18
  },
23
19
  "./server": {
24
- "types": "./dist/server/index.d.ts",
25
- "default": "./dist/server/index.js"
20
+ "types": "./server/index.d.ts",
21
+ "default": "./server/index.js"
22
+ },
23
+ "./_server": {
24
+ "types": "./server/generated.d.ts",
25
+ "default": "./server/generated.js"
26
26
  },
27
27
  "./_generated": {
28
- "types": "./dist/generated.d.ts",
29
- "default": "./dist/generated.js"
28
+ "types": "./generated.d.ts",
29
+ "default": "./generated.js"
30
30
  },
31
31
  "./generation": {
32
- "types": "./dist/generation/index.d.ts",
33
- "node": "./dist/generation/index.js"
32
+ "types": "./generation/index.d.ts",
33
+ "node": "./generation/index.js"
34
34
  },
35
35
  "./package.json": "./package.json"
36
36
  },
@@ -41,23 +41,10 @@
41
41
  "dependencies": {
42
42
  "typescript": "6.0.3"
43
43
  },
44
- "devDependencies": {
45
- "@angular/common": "22.2.2",
46
- "@angular/compiler": "22.2.2",
47
- "@angular/core": "22.2.2",
48
- "@loozo/angular-router": "0.0.3",
49
- "@types/node": "24.13.3",
50
- "playwright": "1.63.0"
51
- },
52
44
  "peerDependencies": {
53
45
  "@angular/common": "^22.0.0",
54
46
  "@angular/core": "^22.0.0",
55
- "@loozo/angular-router": "0.0.3",
47
+ "@loozo/angular-router": "0.0.5",
56
48
  "rxjs": "^7.8.2"
57
- },
58
- "scripts": {
59
- "build": "rm -rf dist && tsc -p tsconfig.json",
60
- "typecheck": "tsc -p tsconfig.json --noEmit",
61
- "test": "node --test tests/*.test.mjs"
62
49
  }
63
- }
50
+ }
@@ -0,0 +1,58 @@
1
+ import type { ApplicationRef, EnvironmentProviders } from "@angular/core";
2
+ import { type ApplicationBinding, type Registry } from "./dispatch.js";
3
+ /**
4
+ * Provides the server-rendering transport that runs RPC calls in-process with the
5
+ * current request's context.
6
+ *
7
+ * @remarks
8
+ * Internal: exported only from `@loozo/angular-launch/_server` for the generated
9
+ * `provideServer` in `server.generated.ts`; add that to your server application config,
10
+ * after `provideHttpClient()`, instead of calling this.
11
+ *
12
+ * It replaces Angular's `HttpBackend` on the server. Calls from generated clients, and
13
+ * any other request to `/_rpc/` on the current request's origin, are intercepted and
14
+ * run in-process in `"rendering"` mode, so mutations are refused with `FORBIDDEN`. All
15
+ * other requests, including ones to `/_rpc/` on another origin that don't come from a
16
+ * generated client, go to Angular's `FetchBackend`.
17
+ *
18
+ * For intercepted calls, Angular's `REQUEST_CONTEXT` must be the {@link RequestScope}
19
+ * created for Angular's `REQUEST`, or the calls fail with `INTERNAL`. A generated-client
20
+ * call outside `/_rpc/` on the current request's origin fails with `INVALID_INPUT`, as
21
+ * does any intercepted call with a query string, fragment, URL credentials, a method
22
+ * other than `POST`, a non-JSON content type, its own `Authorization`,
23
+ * `Proxy-Authorization` or `Cookie` header, or its own credentials setting.
24
+ *
25
+ * Without a live request, as during prerendering, calls from generated clients and
26
+ * requests to a relative `/_rpc/` path fail and the fault is recorded for
27
+ * {@link finishLaunchRendering}; other requests still go to `FetchBackend`.
28
+ *
29
+ * @param registry - The application's RPC groups.
30
+ * @param application - The application binding.
31
+ * @returns The environment providers for the server application.
32
+ */
33
+ export declare function provideLaunchServer(registry: Registry, application: ApplicationBinding): EnvironmentProviders;
34
+ /**
35
+ * Waits for the server application to become stable and fails the render if an RPC was
36
+ * called without a live request.
37
+ *
38
+ * @remarks
39
+ * Angular's prerendering can swallow resolver errors and still report success. Return
40
+ * this from your server bootstrap so a page that calls an RPC during prerendering fails
41
+ * the build instead of producing a broken page. The application must include the
42
+ * generated `provideServer()`.
43
+ *
44
+ * @example
45
+ * ```ts
46
+ * export default async function bootstrap(context: BootstrapContext) {
47
+ * const app = await bootstrapApplication(App, serverConfig, context);
48
+ *
49
+ * return finishLaunchRendering(app);
50
+ * }
51
+ * ```
52
+ *
53
+ * @param app - The bootstrapped server application.
54
+ * @returns The same application once it is stable.
55
+ * @throws The recorded error when an RPC was called without a live request; the
56
+ * application is destroyed first.
57
+ */
58
+ export declare function finishLaunchRendering(app: ApplicationRef): Promise<ApplicationRef>;
@@ -4,6 +4,36 @@ import { Observable } from "rxjs";
4
4
  import { RPC_CALL } from "../generated.js";
5
5
  import { dispatch, failure, isJsonMediaType, assertBoundScope, } from "./dispatch.js";
6
6
  const renderFaults = new InjectionToken("Launch render faults");
7
+ /**
8
+ * Provides the server-rendering transport that runs RPC calls in-process with the
9
+ * current request's context.
10
+ *
11
+ * @remarks
12
+ * Internal: exported only from `@loozo/angular-launch/_server` for the generated
13
+ * `provideServer` in `server.generated.ts`; add that to your server application config,
14
+ * after `provideHttpClient()`, instead of calling this.
15
+ *
16
+ * It replaces Angular's `HttpBackend` on the server. Calls from generated clients, and
17
+ * any other request to `/_rpc/` on the current request's origin, are intercepted and
18
+ * run in-process in `"rendering"` mode, so mutations are refused with `FORBIDDEN`. All
19
+ * other requests, including ones to `/_rpc/` on another origin that don't come from a
20
+ * generated client, go to Angular's `FetchBackend`.
21
+ *
22
+ * For intercepted calls, Angular's `REQUEST_CONTEXT` must be the {@link RequestScope}
23
+ * created for Angular's `REQUEST`, or the calls fail with `INTERNAL`. A generated-client
24
+ * call outside `/_rpc/` on the current request's origin fails with `INVALID_INPUT`, as
25
+ * does any intercepted call with a query string, fragment, URL credentials, a method
26
+ * other than `POST`, a non-JSON content type, its own `Authorization`,
27
+ * `Proxy-Authorization` or `Cookie` header, or its own credentials setting.
28
+ *
29
+ * Without a live request, as during prerendering, calls from generated clients and
30
+ * requests to a relative `/_rpc/` path fail and the fault is recorded for
31
+ * {@link finishLaunchRendering}; other requests still go to `FetchBackend`.
32
+ *
33
+ * @param registry - The application's RPC groups.
34
+ * @param application - The application binding.
35
+ * @returns The environment providers for the server application.
36
+ */
7
37
  export function provideLaunchServer(registry, application) {
8
38
  return makeEnvironmentProviders([
9
39
  { provide: renderFaults, useFactory: () => ({}) },
@@ -99,6 +129,30 @@ export function provideLaunchServer(registry, application) {
99
129
  },
100
130
  ]);
101
131
  }
132
+ /**
133
+ * Waits for the server application to become stable and fails the render if an RPC was
134
+ * called without a live request.
135
+ *
136
+ * @remarks
137
+ * Angular's prerendering can swallow resolver errors and still report success. Return
138
+ * this from your server bootstrap so a page that calls an RPC during prerendering fails
139
+ * the build instead of producing a broken page. The application must include the
140
+ * generated `provideServer()`.
141
+ *
142
+ * @example
143
+ * ```ts
144
+ * export default async function bootstrap(context: BootstrapContext) {
145
+ * const app = await bootstrapApplication(App, serverConfig, context);
146
+ *
147
+ * return finishLaunchRendering(app);
148
+ * }
149
+ * ```
150
+ *
151
+ * @param app - The bootstrapped server application.
152
+ * @returns The same application once it is stable.
153
+ * @throws The recorded error when an RPC was called without a live request; the
154
+ * application is destroyed first.
155
+ */
102
156
  // Native prerender can swallow resolver errors. Propagate only the unsupported
103
157
  // Launch context fault after native stability, without manufacturing a request.
104
158
  export async function finishLaunchRendering(app) {