@loozo/angular-launch 0.0.5 → 0.1.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 (92) hide show
  1. package/README.md +1068 -187
  2. package/builders/application.js +32 -3
  3. package/builders/channel-forwarding.d.ts +15 -0
  4. package/builders/channel-forwarding.js +61 -0
  5. package/builders/options.d.ts +6 -2
  6. package/builders/options.js +16 -5
  7. package/builders/serve.js +198 -140
  8. package/channel.d.ts +55 -0
  9. package/channel.js +232 -0
  10. package/client.d.ts +63 -33
  11. package/connect.d.ts +201 -0
  12. package/connect.js +148 -0
  13. package/generation/index.d.ts +2 -123
  14. package/generation/index.js +3 -669
  15. package/generation/redirects.d.ts +14 -0
  16. package/generation/redirects.js +43 -0
  17. package/generation/run.d.ts +168 -0
  18. package/generation/run.js +659 -0
  19. package/index.d.ts +8 -1
  20. package/index.js +3 -0
  21. package/json.d.ts +9 -0
  22. package/json.js +24 -0
  23. package/launch-queries.d.ts +16 -0
  24. package/launch-queries.js +3 -0
  25. package/navigation.d.ts +36 -0
  26. package/navigation.js +47 -0
  27. package/node/index.d.ts +60 -0
  28. package/node/index.js +178 -0
  29. package/node/upgrade-listener-slot.d.ts +1 -0
  30. package/node/upgrade-listener-slot.js +4 -0
  31. package/outcomes.d.ts +71 -0
  32. package/outcomes.js +146 -0
  33. package/package.json +21 -11
  34. package/redirect-translation.d.ts +53 -0
  35. package/redirect-translation.js +141 -0
  36. package/{generated.d.ts → remote-client.d.ts} +1 -1
  37. package/remote-client.js +179 -0
  38. package/route-types.d.ts +130 -0
  39. package/route-types.js +1 -0
  40. package/route.d.ts +45 -0
  41. package/route.js +113 -0
  42. package/schemas/application.json +19 -3
  43. package/schemas/serve.json +3 -3
  44. package/server/application.d.ts +107 -0
  45. package/server/application.js +108 -0
  46. package/server/backend.d.ts +62 -31
  47. package/server/backend.js +149 -55
  48. package/server/channel-messages.d.ts +54 -0
  49. package/server/channel-messages.js +84 -0
  50. package/server/channel-socket.d.ts +67 -0
  51. package/server/channel-socket.js +322 -0
  52. package/server/definitions.d.ts +270 -294
  53. package/server/definitions.js +35 -115
  54. package/server/dispatch.d.ts +121 -66
  55. package/server/dispatch.js +267 -87
  56. package/server/event-stream.d.ts +63 -0
  57. package/server/event-stream.js +173 -0
  58. package/server/generated.d.ts +3 -1
  59. package/server/generated.js +3 -1
  60. package/server/index.d.ts +6 -3
  61. package/server/index.js +3 -2
  62. package/server/outcomes.d.ts +64 -2
  63. package/server/outcomes.js +85 -4
  64. package/server/read-cookies.d.ts +19 -0
  65. package/server/read-cookies.js +39 -0
  66. package/server/response-effects.d.ts +105 -0
  67. package/server/response-effects.js +78 -0
  68. package/server/stages.d.ts +62 -0
  69. package/server/stages.js +51 -0
  70. package/server/upgrade.d.ts +57 -0
  71. package/server/upgrade.js +116 -0
  72. package/source-text.d.ts +1 -0
  73. package/source-text.js +56 -0
  74. package/stream.d.ts +34 -0
  75. package/stream.js +161 -0
  76. package/tanstack-query/README.md +113 -21
  77. package/tanstack-query/create-queries.d.ts +2 -0
  78. package/tanstack-query/{generated.js → create-queries.js} +13 -11
  79. package/tanstack-query/hydration-window.d.ts +11 -0
  80. package/tanstack-query/hydration-window.js +9 -0
  81. package/tanstack-query/hydration.d.ts +4 -14
  82. package/tanstack-query/hydration.js +9 -12
  83. package/tanstack-query/index.d.ts +1 -1
  84. package/tanstack-query/queries.d.ts +50 -33
  85. package/testing/call-procedure.d.ts +154 -0
  86. package/testing/call-procedure.js +97 -0
  87. package/testing/index.d.ts +2 -0
  88. package/testing/index.js +1 -0
  89. package/generated.js +0 -90
  90. package/generation/context-file.d.ts +0 -2
  91. package/generation/context-file.js +0 -3
  92. package/tanstack-query/generated.d.ts +0 -5
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-07/schema",
3
- "$comment": "Generated by scripts/builder-schemas.mjs from the @angular/build 22.2.2 application schema plus the Launch options. Do not edit. The @angular/build schema portions are distributed under this license:\n\nThe MIT License\n\nCopyright (c) 2010-2026 Google LLC. https://angular.dev/license\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.",
3
+ "$comment": "Generated by scripts/builder-schemas.mjs from the @angular/build 22.3.0 application schema plus the Launch options. Do not edit. The @angular/build schema portions are distributed under this license:\n\nThe MIT License\n\nCopyright (c) 2010-2026 Google LLC. https://angular.dev/license\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.",
4
4
  "title": "Application schema for Build Facade.",
5
5
  "description": "Application builder target options",
6
6
  "type": "object",
@@ -26,6 +26,10 @@
26
26
  "type": "boolean",
27
27
  "default": false
28
28
  },
29
+ "translateSegments": {
30
+ "type": "boolean",
31
+ "default": false
32
+ },
29
33
  "check": {
30
34
  "type": "boolean",
31
35
  "default": false
@@ -563,7 +567,7 @@
563
567
  },
564
568
  "statsJson": {
565
569
  "type": "boolean",
566
- "description": "Generates a 'stats.json' file which can be analyzed with https://esbuild.github.io/analyze/.",
570
+ "description": "Generates a 'browser-stats.json' file which can be analyzed with https://esbuild.github.io/analyze/. When server-side rendering is enabled, a 'server-stats.json' file is also generated.",
567
571
  "default": false
568
572
  },
569
573
  "budgets": {
@@ -597,7 +601,7 @@
597
601
  "oneOf": [
598
602
  {
599
603
  "type": "boolean",
600
- "description": "Enable prerending of pages of your application during build time."
604
+ "description": "Enable prerendering of pages of your application during build time."
601
605
  },
602
606
  {
603
607
  "type": "object",
@@ -613,6 +617,18 @@
613
617
  }
614
618
  },
615
619
  "additionalProperties": false
620
+ },
621
+ {
622
+ "type": "object",
623
+ "properties": {
624
+ "format": {
625
+ "type": "string",
626
+ "description": "Defines the file layout of prerendered pages. 'directory': '/foo' is written to 'foo/index.html'. 'file': '/foo' is written to 'foo.html', which some hosting services serve for '/foo' without a redirect to '/foo/'. The root route of the application and of each locale is always written to 'index.html'. Only considered when the build does not produce a server.",
627
+ "enum": ["directory", "file"]
628
+ }
629
+ },
630
+ "additionalProperties": false,
631
+ "required": ["format"]
616
632
  }
617
633
  ]
618
634
  },
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-07/schema",
3
- "$comment": "Generated by scripts/builder-schemas.mjs from the @angular/build 22.2.2 dev-server schema plus the Launch options. Do not edit. The @angular/build schema portions are distributed under this license:\n\nThe MIT License\n\nCopyright (c) 2010-2026 Google LLC. https://angular.dev/license\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.",
3
+ "$comment": "Generated by scripts/builder-schemas.mjs from the @angular/build 22.3.0 dev-server schema plus the Launch options. Do not edit. The @angular/build schema portions are distributed under this license:\n\nThe MIT License\n\nCopyright (c) 2010-2026 Google LLC. https://angular.dev/license\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.",
4
4
  "title": "Dev Server Target",
5
5
  "description": "Dev Server target options for Build Facade.",
6
6
  "type": "object",
@@ -12,7 +12,7 @@
12
12
  },
13
13
  "port": {
14
14
  "type": "number",
15
- "description": "Port to listen on.",
15
+ "description": "Port to listen on. The `PORT` environment variable, when set, takes precedence over this option.",
16
16
  "default": 4200
17
17
  },
18
18
  "host": {
@@ -92,7 +92,7 @@
92
92
  },
93
93
  "hmr": {
94
94
  "type": "boolean",
95
- "description": "Enable hot module replacement. Defaults to the value of 'liveReload'. Currently, only global and component stylesheets are supported."
95
+ "description": "Enable hot module replacement. Defaults to the value of 'liveReload'. Currently, global stylesheets, component stylesheets, and component templates are supported."
96
96
  },
97
97
  "watch": {
98
98
  "type": "boolean",
@@ -0,0 +1,107 @@
1
+ import { type AnyRoute, type ContributionRecord } from "@loozo/angular-router/_core";
2
+ import { type ErrorDefinitions, type ProcedureKind, type Schema } from "./definitions.js";
3
+ import { declaredFailures, type DeclaredFailure } from "./errors.js";
4
+ import type { Stage } from "./stages.js";
5
+ /**
6
+ * A registered procedure, as the server dispatches it.
7
+ *
8
+ * @remarks
9
+ * Internal; not exported from a public entry point.
10
+ */
11
+ export interface RuntimeProcedure {
12
+ readonly kind: ProcedureKind;
13
+ readonly input: Schema | undefined;
14
+ readonly message: Schema | undefined;
15
+ readonly errors: ErrorDefinitions;
16
+ readonly use: readonly ChainMiddleware[];
17
+ readonly [declaredFailures]?: WeakMap<object, DeclaredFailure>;
18
+ readonly handler: (args: object) => unknown;
19
+ }
20
+ /**
21
+ * The runtime view of a middleware, a `middleware()` definition or a bare function; the
22
+ * dispatcher checks what it returns.
23
+ *
24
+ * @remarks
25
+ * Internal; not exported from a public entry point.
26
+ */
27
+ export type ChainMiddleware = {
28
+ readonly run: (args: never) => Promise<unknown>;
29
+ } | ((args: never) => Promise<unknown>);
30
+ /**
31
+ * One namespace of a route's `.remote()`, bound to the route that declared it.
32
+ *
33
+ * @remarks
34
+ * Internal; not exported from a public entry point.
35
+ */
36
+ export interface BoundNamespace {
37
+ /** The namespace's procedures, keyed by name. */
38
+ readonly procedures: Readonly<Record<string, RuntimeProcedure>>;
39
+ /** The declaring route's `.use()` middleware. */
40
+ readonly use: readonly ChainMiddleware[];
41
+ /** The stages from the root to the declaring route, root first. */
42
+ readonly stages: readonly Stage[];
43
+ }
44
+ /**
45
+ * The application requests are bound to: its identity and its namespaces.
46
+ *
47
+ * @remarks
48
+ * Internal; not exported from a public entry point. Generation writes it as `application`
49
+ * in `server.generated.ts`.
50
+ */
51
+ export interface ApplicationBinding {
52
+ /** The generated application identity. */
53
+ readonly id: string;
54
+ /** Every route's `.remote()` namespaces, keyed by namespace. */
55
+ readonly namespaces: Readonly<Record<string, BoundNamespace>>;
56
+ /**
57
+ * Whether the application was generated with `translateSegments`: its redirect frames then
58
+ * list their static word positions.
59
+ */
60
+ readonly translateSegments?: true;
61
+ }
62
+ /**
63
+ * A route's Launch contribution chain: the own records of its ancestors that used a Launch
64
+ * step, then its own, root first.
65
+ *
66
+ * @remarks
67
+ * Internal; not exported from a public entry point.
68
+ *
69
+ * @param route - Any route.
70
+ * @returns The chain, or `undefined` for a route Launch's `defineRoute` didn't make and
71
+ * that has no Launch ancestor.
72
+ */
73
+ export declare function launchChain(route: AnyRoute): readonly ContributionRecord[] | undefined;
74
+ /**
75
+ * Binds each namespace of a route's `.remote()` to the route's `.use()` middleware and to
76
+ * `stages`.
77
+ *
78
+ * @remarks
79
+ * Internal; not exported from a public entry point.
80
+ *
81
+ * @param own - The declaring route's own record, which has a `.remote()` callback.
82
+ * @param stages - The stages a call to one of the namespaces runs, root first.
83
+ * @returns The route's namespaces, keyed by namespace.
84
+ */
85
+ export declare function bindNamespaces(own: ContributionRecord, stages: readonly Stage[]): Record<string, BoundNamespace>;
86
+ /**
87
+ * Binds an application's authored routes into the {@link ApplicationBinding} the server
88
+ * dispatches with.
89
+ *
90
+ * @remarks
91
+ * Internal: exported only from `@loozo/angular-launch/_server` for the generated
92
+ * `server.generated.ts`. Each namespace's owner is fixed here, from the route that declared
93
+ * it: a call runs that route's stages and `.use()` middleware, whichever page called it.
94
+ * Every route with a stage that a listed route's chain holds must be listed too, so the
95
+ * stage carries its route's file. Generation lists every route with a server-only step and
96
+ * enforces namespace uniqueness.
97
+ *
98
+ * @param id - The generated application identity.
99
+ * @param routes - Each authored route with a server-only step, with its workspace-relative file.
100
+ * @param options - `translateSegments`: generation wrote the app with translated segments.
101
+ * @returns The application binding.
102
+ * @throws TypeError for a route Launch's `defineRoute` didn't make, or a stage whose route
103
+ * isn't listed.
104
+ */
105
+ export declare function bindApplication(id: string, routes: readonly (readonly [route: AnyRoute, file: string])[], options?: {
106
+ readonly translateSegments?: true;
107
+ }): ApplicationBinding;
@@ -0,0 +1,108 @@
1
+ import { routeContributions, } from "@loozo/angular-router/_core";
2
+ import { defineRoute } from "../route.js";
3
+ import { builder } from "./definitions.js";
4
+ import { declaredFailures } from "./errors.js";
5
+ /**
6
+ * A route's Launch contribution chain: the own records of its ancestors that used a Launch
7
+ * step, then its own, root first.
8
+ *
9
+ * @remarks
10
+ * Internal; not exported from a public entry point.
11
+ *
12
+ * @param route - Any route.
13
+ * @returns The chain, or `undefined` for a route Launch's `defineRoute` didn't make and
14
+ * that has no Launch ancestor.
15
+ */
16
+ export function launchChain(route) {
17
+ // `routeContributions` takes any extension's factory; a spec's step tuple isn't
18
+ // assignable to the general one, so name Launch's factory by the general type.
19
+ const factory = defineRoute;
20
+ return routeContributions(factory, route);
21
+ }
22
+ /**
23
+ * Binds each namespace of a route's `.remote()` to the route's `.use()` middleware and to
24
+ * `stages`.
25
+ *
26
+ * @remarks
27
+ * Internal; not exported from a public entry point.
28
+ *
29
+ * @param own - The declaring route's own record, which has a `.remote()` callback.
30
+ * @param stages - The stages a call to one of the namespaces runs, root first.
31
+ * @returns The route's namespaces, keyed by namespace.
32
+ */
33
+ export function bindNamespaces(own, stages) {
34
+ const build = own.remote;
35
+ const use = (own.use ?? []);
36
+ const namespaces = Object.create(null);
37
+ for (const [namespace, procedures] of Object.entries(build(builder))) {
38
+ namespaces[namespace] = {
39
+ procedures: procedures,
40
+ use,
41
+ stages,
42
+ };
43
+ }
44
+ return namespaces;
45
+ }
46
+ /**
47
+ * Binds an application's authored routes into the {@link ApplicationBinding} the server
48
+ * dispatches with.
49
+ *
50
+ * @remarks
51
+ * Internal: exported only from `@loozo/angular-launch/_server` for the generated
52
+ * `server.generated.ts`. Each namespace's owner is fixed here, from the route that declared
53
+ * it: a call runs that route's stages and `.use()` middleware, whichever page called it.
54
+ * Every route with a stage that a listed route's chain holds must be listed too, so the
55
+ * stage carries its route's file. Generation lists every route with a server-only step and
56
+ * enforces namespace uniqueness.
57
+ *
58
+ * @param id - The generated application identity.
59
+ * @param routes - Each authored route with a server-only step, with its workspace-relative file.
60
+ * @param options - `translateSegments`: generation wrote the app with translated segments.
61
+ * @returns The application binding.
62
+ * @throws TypeError for a route Launch's `defineRoute` didn't make, or a stage whose route
63
+ * isn't listed.
64
+ */
65
+ export function bindApplication(id, routes, options = {}) {
66
+ const chains = [];
67
+ // Keyed by each route's own record, which its descendants' chains share.
68
+ const labels = new Map();
69
+ const stages = new Map();
70
+ const namespaces = Object.create(null);
71
+ for (const [route, file] of routes) {
72
+ const chain = launchChain(route);
73
+ if (!chain || chain.length === 0) {
74
+ throw new TypeError(`Launch route has no server steps: ${file}`);
75
+ }
76
+ chains.push(chain);
77
+ labels.set(chain[chain.length - 1], file);
78
+ }
79
+ function stageOf(record) {
80
+ let stage = stages.get(record);
81
+ if (!stage) {
82
+ const route = labels.get(record);
83
+ if (route === undefined) {
84
+ throw new TypeError("Launch stage belongs to a route the application doesn't list");
85
+ }
86
+ stage = { run: record.context, route };
87
+ stages.set(record, stage);
88
+ }
89
+ return stage;
90
+ }
91
+ for (const chain of chains) {
92
+ const own = chain[chain.length - 1];
93
+ if (typeof own.remote !== "function") {
94
+ continue;
95
+ }
96
+ const owned = [];
97
+ for (const record of chain) {
98
+ if (typeof record.context === "function") {
99
+ owned.push(stageOf(record));
100
+ }
101
+ }
102
+ Object.assign(namespaces, bindNamespaces(own, owned));
103
+ }
104
+ if (options.translateSegments) {
105
+ return { id, namespaces, translateSegments: true };
106
+ }
107
+ return { id, namespaces };
108
+ }
@@ -1,8 +1,8 @@
1
1
  import type { ApplicationRef, EnvironmentProviders } from "@angular/core";
2
- import { type ApplicationBinding, type Registry } from "./dispatch.js";
2
+ import type { ApplicationBinding } from "./application.js";
3
3
  /**
4
- * Provides the server-rendering transport that runs RPC calls in-process with the
5
- * current request's context.
4
+ * Provides the server-rendering transport that runs RPC calls in-process in the current
5
+ * request's scope.
6
6
  *
7
7
  * @remarks
8
8
  * Internal: exported only from `@loozo/angular-launch/_server` for the generated
@@ -10,36 +10,66 @@ import { type ApplicationBinding, type Registry } from "./dispatch.js";
10
10
  * after `provideHttpClient()`, instead of calling this.
11
11
  *
12
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` with no
21
- * issues, as does any intercepted call with a query string, fragment, URL credentials, a
22
- * method 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.
13
+ * any other request to `/_rpc/` on the page's origin, are intercepted and run in-process
14
+ * in `"rendering"` mode, so mutations and streams are refused with `FORBIDDEN`. All other
15
+ * requests, including ones to `/_rpc/` on another origin that don't come from a generated
16
+ * client, go to Angular's `FetchBackend`.
17
+ *
18
+ * For intercepted calls during server rendering, Angular's `REQUEST_CONTEXT` must be the
19
+ * {@link RequestScope} created for Angular's `REQUEST`, or the calls fail with `INTERNAL`.
20
+ * They run in the copy of the package that created the scope, with the application binding
21
+ * it was created for, usually the server entry's: Angular bundles the server entry apart
22
+ * from the server application, and running there gives a page the same stages, handlers
23
+ * and module state as the server's RPCs.
24
+ * A generated-client call outside `/_rpc/` on the page's origin fails with
25
+ * `INVALID_INPUT` with no issues, as does any intercepted call with a query string,
26
+ * fragment, URL credentials, a method other than `POST`, a non-JSON content type, its own
27
+ * `Authorization`, `Proxy-Authorization` or `Cookie` header, or its own credentials
28
+ * setting.
29
+ *
30
+ * Cookies an intercepted call sets are appended to `RESPONSE_INIT`'s headers when the
31
+ * call settles, whatever its outcome, so they reach the page response; its other headers
32
+ * are dropped. Angular copies those headers into the page response once the app is first
33
+ * stable, so cookies from a call that settles later, such as one awaited in a
34
+ * `BEFORE_APP_SERIALIZED` hook, are lost. Without `RESPONSE_INIT`, a call that set cookies
35
+ * fails with `INTERNAL`.
36
+ *
37
+ * Without `REQUEST`, as when Angular prerenders a page, the first intercepted call creates
38
+ * the render's request scope from a cookie-less `GET` of the page's URL, and every call in
39
+ * the render shares it and runs in this copy, with `application`. Its signal aborts when
40
+ * the application is destroyed. A call that doesn't answer 200, or sets a cookie, records a
41
+ * fault for {@link finishLaunchRendering}, as does a context stage that throws, named by
42
+ * its route.
43
+ * Only faults recorded before the app is first stable fail the build.
44
+ *
45
+ * @param application - The application binding: a live scope must belong to it, and
46
+ * prerendering runs its calls with it.
31
47
  * @returns The environment providers for the server application.
32
48
  */
33
- export declare function provideLaunchServer(registry: Registry, application: ApplicationBinding): EnvironmentProviders;
49
+ export declare function provideLaunchServer(application: ApplicationBinding): EnvironmentProviders;
34
50
  /**
35
- * Waits for the server application to become stable and fails the render if an RPC was
36
- * called without a live request.
51
+ * Waits for the server application to become stable and fails the render if a Launch call
52
+ * failed while Angular prerendered the page.
37
53
  *
38
54
  * @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()`.
55
+ * A prerendered page is written once and served to every visitor, so each Launch call it
56
+ * makes must answer 200 without setting a cookie; a mutation or stream is refused with
57
+ * `FORBIDDEN`, so it fails too. Angular's prerendering can swallow resolver errors and still
58
+ * report success, and a failed `injectQuery` only renders its error state, so return this
59
+ * from your server bootstrap to fail the build instead of producing a broken page. The
60
+ * application must include the generated `provideServer()`. Server-rendered pages are
61
+ * unaffected: their failures reach the caller as usual.
62
+ *
63
+ * It checks once the app is first stable, which covers calls from guards, resolvers and
64
+ * rendering. Angular runs `BEFORE_APP_SERIALIZED` hooks afterwards and only logs their
65
+ * errors, so a call made in one isn't checked and the page is still written; don't make
66
+ * Launch calls there.
67
+ *
68
+ * During Angular's route discovery, which boots the app without its root component, it
69
+ * returns the application at once, without waiting or checking: discovery releases a
70
+ * blocking initial navigation (`withEnabledBlockingInitialNavigation`) only after the
71
+ * bootstrap returns, and waits for stability itself. Calls made then run with the anonymous
72
+ * context, and Angular only logs their failures.
43
73
  *
44
74
  * @example
45
75
  * ```ts
@@ -51,8 +81,9 @@ export declare function provideLaunchServer(registry: Registry, application: App
51
81
  * ```
52
82
  *
53
83
  * @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.
84
+ * @returns The same application once it is stable, or at once during route discovery.
85
+ * @throws The first recorded fault, naming the call and its reply, the cookie or the
86
+ * context stage that threw, with its error as the cause; the application is destroyed
87
+ * first.
57
88
  */
58
89
  export declare function finishLaunchRendering(app: ApplicationRef): Promise<ApplicationRef>;