@real-router/angular 0.23.0 → 0.24.1
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.
- package/README.md +1 -16
- package/dist/fesm2022/real-router-angular-ssr.mjs +228 -311
- package/dist/fesm2022/real-router-angular-ssr.mjs.map +1 -1
- package/dist/fesm2022/real-router-angular.mjs +1712 -2865
- package/dist/fesm2022/real-router-angular.mjs.map +1 -1
- package/dist/package.json +2 -3
- package/dist/types/real-router-angular-ssr.d.ts +55 -45
- package/dist/types/real-router-angular-ssr.d.ts.map +1 -1
- package/dist/types/real-router-angular.d.ts +540 -305
- package/dist/types/real-router-angular.d.ts.map +1 -1
- package/package.json +11 -12
- package/dist/README.md +0 -816
- package/ssr/components/ClientOnly.ts +0 -27
- package/ssr/components/HttpStatusCode.ts +0 -123
- package/ssr/components/ServerOnly.ts +0 -27
- package/ssr/functions/injectDeferred.ts +0 -92
- package/ssr/functions/provideHttpStatusSink.ts +0 -43
- package/ssr/ng-package.json +0 -6
- package/ssr/public_api.ts +0 -35
- package/ssr/utils/createHttpStatusSink.ts +0 -61
package/README.md
CHANGED
|
@@ -760,11 +760,9 @@ export class MyComponent {
|
|
|
760
760
|
}
|
|
761
761
|
```
|
|
762
762
|
|
|
763
|
-
`sourceToSignal` follows the same rule — it calls `inject(DestroyRef)` internally.
|
|
764
|
-
|
|
765
763
|
### DestroyRef for Cleanup
|
|
766
764
|
|
|
767
|
-
|
|
765
|
+
Router subscriptions the adapter creates — in its `inject*` functions, providers and directives — clean up automatically via `DestroyRef.onDestroy`. No manual unsubscribe needed.
|
|
768
766
|
|
|
769
767
|
### Zoneless Compatibility
|
|
770
768
|
|
|
@@ -776,19 +774,6 @@ The adapter is signal-first and does not depend on Zone.js. It works with `provi
|
|
|
776
774
|
|
|
777
775
|
In `RealLink` / `RealLinkActive`, `[routeParams]` is routed through `shallowEqual` content-stabilization before the effect reads it, so an inline-literal binding re-allocated on every change detection only re-creates the source on real content change (see [Object `routeParams`](#object-routeparams--content-stabilized), #988).
|
|
778
776
|
|
|
779
|
-
## Signal Bridge
|
|
780
|
-
|
|
781
|
-
### `sourceToSignal(source)`
|
|
782
|
-
|
|
783
|
-
Bridges any `RouterSource<T>` (from `@real-router/sources`) into an Angular `Signal<T>`. Cleanup wires through `inject(DestroyRef)` — must be called in an injection context. Used internally by `RouterErrorBoundary`; exposed for custom composables that need to bridge router sources into reactive signals.
|
|
784
|
-
|
|
785
|
-
```typescript
|
|
786
|
-
import { sourceToSignal } from "@real-router/angular";
|
|
787
|
-
import { createTransitionSource } from "@real-router/sources";
|
|
788
|
-
|
|
789
|
-
const transitionSignal = sourceToSignal(createTransitionSource(router));
|
|
790
|
-
```
|
|
791
|
-
|
|
792
777
|
## Documentation
|
|
793
778
|
|
|
794
779
|
Full documentation: [Wiki](https://github.com/greydragon888/real-router/wiki) — start with the [Angular Integration guide](https://github.com/greydragon888/real-router/wiki/Angular-Integration) for Angular-specific examples and gotchas.
|
|
@@ -1,342 +1,259 @@
|
|
|
1
|
-
import { NgTemplateOutlet } from
|
|
2
|
-
import * as i0 from
|
|
3
|
-
import {
|
|
4
|
-
import { injectRoute } from
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
import { NgTemplateOutlet } from "@angular/common";
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
import { Component, InjectionToken, afterNextRender, computed, effect, inject, input, isDevMode, makeEnvironmentProviders, signal } from "@angular/core";
|
|
4
|
+
import { injectRoute } from "@real-router/angular";
|
|
5
|
+
var ClientOnly = class ClientOnly {
|
|
6
|
+
fallback = input(...ngDevMode ? [void 0, { debugName: "fallback" }] : /* istanbul ignore next */ []);
|
|
7
|
+
mounted = signal(false, ...ngDevMode ? [{ debugName: "mounted" }] : /* istanbul ignore next */ []);
|
|
8
|
+
constructor() {
|
|
9
|
+
afterNextRender(() => {
|
|
10
|
+
this.mounted.set(true);
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
14
|
+
minVersion: "12.0.0",
|
|
15
|
+
version: "22.2.0",
|
|
16
|
+
ngImport: i0,
|
|
17
|
+
type: ClientOnly,
|
|
18
|
+
deps: [],
|
|
19
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
20
|
+
});
|
|
21
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
22
|
+
minVersion: "17.0.0",
|
|
23
|
+
version: "22.2.0",
|
|
24
|
+
type: ClientOnly,
|
|
25
|
+
isStandalone: true,
|
|
26
|
+
selector: "client-only",
|
|
27
|
+
inputs: { fallback: {
|
|
28
|
+
classPropertyName: "fallback",
|
|
29
|
+
publicName: "fallback",
|
|
30
|
+
isSignal: true,
|
|
31
|
+
isRequired: false,
|
|
32
|
+
transformFunction: null
|
|
33
|
+
} },
|
|
34
|
+
ngImport: i0,
|
|
35
|
+
template: `
|
|
18
36
|
@if (mounted()) {
|
|
19
37
|
<ng-content />
|
|
20
38
|
} @else if (fallback()) {
|
|
21
39
|
<ng-container [ngTemplateOutlet]="fallback() ?? null" />
|
|
22
40
|
}
|
|
23
|
-
`,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
41
|
+
`,
|
|
42
|
+
isInline: true,
|
|
43
|
+
dependencies: [{
|
|
44
|
+
kind: "directive",
|
|
45
|
+
type: NgTemplateOutlet,
|
|
46
|
+
selector: "[ngTemplateOutlet]",
|
|
47
|
+
inputs: [
|
|
48
|
+
"ngTemplateOutletContext",
|
|
49
|
+
"ngTemplateOutlet",
|
|
50
|
+
"ngTemplateOutletInjector"
|
|
51
|
+
]
|
|
52
|
+
}]
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
56
|
+
minVersion: "12.0.0",
|
|
57
|
+
version: "22.2.0",
|
|
58
|
+
ngImport: i0,
|
|
59
|
+
type: ClientOnly,
|
|
60
|
+
decorators: [{
|
|
61
|
+
type: Component,
|
|
62
|
+
args: [{
|
|
63
|
+
selector: "client-only",
|
|
64
|
+
template: `
|
|
30
65
|
@if (mounted()) {
|
|
31
66
|
<ng-content />
|
|
32
67
|
} @else if (fallback()) {
|
|
33
68
|
<ng-container [ngTemplateOutlet]="fallback() ?? null" />
|
|
34
69
|
}
|
|
35
70
|
`,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
71
|
+
imports: [NgTemplateOutlet]
|
|
72
|
+
}]
|
|
73
|
+
}],
|
|
74
|
+
ctorParameters: () => [],
|
|
75
|
+
propDecorators: { fallback: [{
|
|
76
|
+
type: i0.Input,
|
|
77
|
+
args: [{
|
|
78
|
+
isSignal: true,
|
|
79
|
+
alias: "fallback",
|
|
80
|
+
required: false
|
|
81
|
+
}]
|
|
82
|
+
}] }
|
|
83
|
+
});
|
|
84
|
+
var ServerOnly = class ServerOnly {
|
|
85
|
+
fallback = input(...ngDevMode ? [void 0, { debugName: "fallback" }] : /* istanbul ignore next */ []);
|
|
86
|
+
mounted = signal(false, ...ngDevMode ? [{ debugName: "mounted" }] : /* istanbul ignore next */ []);
|
|
87
|
+
constructor() {
|
|
88
|
+
afterNextRender(() => {
|
|
89
|
+
this.mounted.set(true);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
93
|
+
minVersion: "12.0.0",
|
|
94
|
+
version: "22.2.0",
|
|
95
|
+
ngImport: i0,
|
|
96
|
+
type: ServerOnly,
|
|
97
|
+
deps: [],
|
|
98
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
99
|
+
});
|
|
100
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
101
|
+
minVersion: "17.0.0",
|
|
102
|
+
version: "22.2.0",
|
|
103
|
+
type: ServerOnly,
|
|
104
|
+
isStandalone: true,
|
|
105
|
+
selector: "server-only",
|
|
106
|
+
inputs: { fallback: {
|
|
107
|
+
classPropertyName: "fallback",
|
|
108
|
+
publicName: "fallback",
|
|
109
|
+
isSignal: true,
|
|
110
|
+
isRequired: false,
|
|
111
|
+
transformFunction: null
|
|
112
|
+
} },
|
|
113
|
+
ngImport: i0,
|
|
114
|
+
template: `
|
|
52
115
|
@if (!mounted()) {
|
|
53
116
|
<ng-content />
|
|
54
117
|
} @else if (fallback()) {
|
|
55
118
|
<ng-container [ngTemplateOutlet]="fallback() ?? null" />
|
|
56
119
|
}
|
|
57
|
-
`,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
120
|
+
`,
|
|
121
|
+
isInline: true,
|
|
122
|
+
dependencies: [{
|
|
123
|
+
kind: "directive",
|
|
124
|
+
type: NgTemplateOutlet,
|
|
125
|
+
selector: "[ngTemplateOutlet]",
|
|
126
|
+
inputs: [
|
|
127
|
+
"ngTemplateOutletContext",
|
|
128
|
+
"ngTemplateOutlet",
|
|
129
|
+
"ngTemplateOutletInjector"
|
|
130
|
+
]
|
|
131
|
+
}]
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
135
|
+
minVersion: "12.0.0",
|
|
136
|
+
version: "22.2.0",
|
|
137
|
+
ngImport: i0,
|
|
138
|
+
type: ServerOnly,
|
|
139
|
+
decorators: [{
|
|
140
|
+
type: Component,
|
|
141
|
+
args: [{
|
|
142
|
+
selector: "server-only",
|
|
143
|
+
template: `
|
|
64
144
|
@if (!mounted()) {
|
|
65
145
|
<ng-content />
|
|
66
146
|
} @else if (fallback()) {
|
|
67
147
|
<ng-container [ngTemplateOutlet]="fallback() ?? null" />
|
|
68
148
|
}
|
|
69
149
|
`,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
150
|
+
imports: [NgTemplateOutlet]
|
|
151
|
+
}]
|
|
152
|
+
}],
|
|
153
|
+
ctorParameters: () => [],
|
|
154
|
+
propDecorators: { fallback: [{
|
|
155
|
+
type: i0.Input,
|
|
156
|
+
args: [{
|
|
157
|
+
isSignal: true,
|
|
158
|
+
alias: "fallback",
|
|
159
|
+
required: false
|
|
160
|
+
}]
|
|
161
|
+
}] }
|
|
162
|
+
});
|
|
74
163
|
function createHttpStatusSink() {
|
|
75
|
-
|
|
164
|
+
return { code: void 0 };
|
|
76
165
|
}
|
|
77
|
-
/**
|
|
78
|
-
* DI token for the request-scoped HTTP status sink. Application-side wiring:
|
|
79
|
-
*
|
|
80
|
-
* ```ts
|
|
81
|
-
* import { bootstrapApplication } from "@angular/platform-browser";
|
|
82
|
-
* import { provideHttpStatusSink, createHttpStatusSink } from "@real-router/angular/ssr";
|
|
83
|
-
*
|
|
84
|
-
* const sink = createHttpStatusSink();
|
|
85
|
-
*
|
|
86
|
-
* await bootstrapApplication(AppRoot, {
|
|
87
|
-
* providers: [
|
|
88
|
-
* provideRealRouterFactory({ ... }),
|
|
89
|
-
* provideHttpStatusSink(sink),
|
|
90
|
-
* ],
|
|
91
|
-
* });
|
|
92
|
-
*
|
|
93
|
-
* response.status(sink.code ?? 200).send(html);
|
|
94
|
-
* ```
|
|
95
|
-
*/
|
|
96
166
|
const HTTP_STATUS_SINK = new InjectionToken("HTTP_STATUS_SINK");
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
* `input.required<number>()`) because `input.required` trips `NG0950` in
|
|
155
|
-
* JIT/TestBed even after `componentRef.setInput(...)`. `ngOnInit` skips
|
|
156
|
-
* the write when `code()` is `undefined`. AOT (production build) binds
|
|
157
|
-
* the value normally and the skip never fires.
|
|
158
|
-
*
|
|
159
|
-
* **Valid `code` range:** Node's `res.end()` throws `Invalid status code`
|
|
160
|
-
* on `NaN`, `0`, negative values, or values `> 999` — this surfaces as a
|
|
161
|
-
* 5xx / dropped connection, not silent corruption. Pass a real HTTP status
|
|
162
|
-
* integer (commonly 4xx/5xx; 100-999 is what Node accepts).
|
|
163
|
-
*/
|
|
164
|
-
class HttpStatusCode {
|
|
165
|
-
/**
|
|
166
|
-
* HTTP status to apply to the response. Common values: 404, 410, 451, 503.
|
|
167
|
-
*
|
|
168
|
-
* Declared as optional so the signal is safe to read in `ngOnInit` under
|
|
169
|
-
* both AOT (template binding fires before init hooks) and JIT/TestBed
|
|
170
|
-
* (`componentRef.setInput("code", N)` writes the value before the first
|
|
171
|
-
* change detection). `input.required` would trip `NG0950` in the JIT path
|
|
172
|
-
* because the required-flag is asserted independently of the runtime
|
|
173
|
-
* value. Consumers should always pass a value — `undefined` makes
|
|
174
|
-
* `ngOnInit` skip the sink write rather than throw.
|
|
175
|
-
*/
|
|
176
|
-
code = input(/* @ts-ignore */
|
|
177
|
-
...(ngDevMode ? [undefined, { debugName: "code" }] : /* istanbul ignore next */ []));
|
|
178
|
-
// Optional injection — when no `provideHttpStatusSink(...)` is registered
|
|
179
|
-
// (client side) the field is null and `ngOnInit` skips the write.
|
|
180
|
-
sink = inject(HTTP_STATUS_SINK, { optional: true });
|
|
181
|
-
ngOnInit() {
|
|
182
|
-
if (!this.sink) {
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
const value = this.code();
|
|
186
|
-
if (value !== undefined) {
|
|
187
|
-
// Dev-only validation (parity with the other adapters, #1441): Node's
|
|
188
|
-
// res.end() throws `Invalid status code` on NaN / 0 / non-integer / >999.
|
|
189
|
-
// Surface the bad value at the source instead of at the response boundary.
|
|
190
|
-
// Angular uses `isDevMode()` rather than `process.env.NODE_ENV` — ng-packagr
|
|
191
|
-
// does not replace the latter and `process` is undefined in the browser.
|
|
192
|
-
// JIT/TestBed reads `code()` as undefined, so this branch (and the sink
|
|
193
|
-
// write below) is reachable only under AOT — covered by the AOT
|
|
194
|
-
// ssr-examples once an `<http-status-code>` consumer lands there.
|
|
195
|
-
if (isDevMode() &&
|
|
196
|
-
(!Number.isInteger(value) || value < 100 || value > 999)) {
|
|
197
|
-
console.error(`[real-router] <http-status-code [code]="${String(value)}" /> received an invalid HTTP status code. Node's res.end() rejects values that are not an integer in [100, 999] — pass a real HTTP status (commonly 4xx/5xx).`);
|
|
198
|
-
}
|
|
199
|
-
this.sink.code = value;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: HttpStatusCode, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
203
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.1.6", type: HttpStatusCode, isStandalone: true, selector: "http-status-code", inputs: { code: { classPropertyName: "code", publicName: "code", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "", isInline: true });
|
|
204
|
-
}
|
|
205
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: HttpStatusCode, decorators: [{
|
|
206
|
-
type: Component,
|
|
207
|
-
args: [{
|
|
208
|
-
selector: "http-status-code",
|
|
209
|
-
template: "",
|
|
210
|
-
}]
|
|
211
|
-
}], propDecorators: { code: [{ type: i0.Input, args: [{ isSignal: true, alias: "code", required: false }] }] } });
|
|
212
|
-
|
|
213
|
-
const NEVER_PROMISE = new Promise(() => {
|
|
214
|
-
// Intentionally never resolves — settles as `undefined` indefinitely when
|
|
215
|
-
// a key is requested that the loader never declared. Surfaces consumer/
|
|
216
|
-
// loader key drift as a visible "loading" state in the UI.
|
|
167
|
+
var HttpStatusCode = class HttpStatusCode {
|
|
168
|
+
code = input(...ngDevMode ? [void 0, { debugName: "code" }] : /* istanbul ignore next */ []);
|
|
169
|
+
sink = inject(HTTP_STATUS_SINK, { optional: true });
|
|
170
|
+
ngOnInit() {
|
|
171
|
+
if (!this.sink) return;
|
|
172
|
+
const value = this.code();
|
|
173
|
+
if (value !== void 0) {
|
|
174
|
+
if (isDevMode() && (!Number.isInteger(value) || value < 100 || value > 999)) console.error(`[real-router] <http-status-code [code]="${String(value)}" /> received an invalid HTTP status code. Node's res.end() rejects values that are not an integer in [100, 999] — pass a real HTTP status (commonly 4xx/5xx).`);
|
|
175
|
+
this.sink.code = value;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
179
|
+
minVersion: "12.0.0",
|
|
180
|
+
version: "22.2.0",
|
|
181
|
+
ngImport: i0,
|
|
182
|
+
type: HttpStatusCode,
|
|
183
|
+
deps: [],
|
|
184
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
185
|
+
});
|
|
186
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
187
|
+
minVersion: "17.1.0",
|
|
188
|
+
version: "22.2.0",
|
|
189
|
+
type: HttpStatusCode,
|
|
190
|
+
isStandalone: true,
|
|
191
|
+
selector: "http-status-code",
|
|
192
|
+
inputs: { code: {
|
|
193
|
+
classPropertyName: "code",
|
|
194
|
+
publicName: "code",
|
|
195
|
+
isSignal: true,
|
|
196
|
+
isRequired: false,
|
|
197
|
+
transformFunction: null
|
|
198
|
+
} },
|
|
199
|
+
ngImport: i0,
|
|
200
|
+
template: "",
|
|
201
|
+
isInline: true
|
|
202
|
+
});
|
|
203
|
+
};
|
|
204
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
205
|
+
minVersion: "12.0.0",
|
|
206
|
+
version: "22.2.0",
|
|
207
|
+
ngImport: i0,
|
|
208
|
+
type: HttpStatusCode,
|
|
209
|
+
decorators: [{
|
|
210
|
+
type: Component,
|
|
211
|
+
args: [{
|
|
212
|
+
selector: "http-status-code",
|
|
213
|
+
template: ""
|
|
214
|
+
}]
|
|
215
|
+
}],
|
|
216
|
+
propDecorators: { code: [{
|
|
217
|
+
type: i0.Input,
|
|
218
|
+
args: [{
|
|
219
|
+
isSignal: true,
|
|
220
|
+
alias: "code",
|
|
221
|
+
required: false
|
|
222
|
+
}]
|
|
223
|
+
}] }
|
|
217
224
|
});
|
|
218
|
-
|
|
219
|
-
* Read a deferred promise published by `defer({ deferred: { <key>: Promise } })`
|
|
220
|
-
* inside an SSR data loader. Returns an Angular `Signal<T | undefined>` that
|
|
221
|
-
* tracks the active route — re-keying picks up the new state's deferred map.
|
|
222
|
-
*
|
|
223
|
-
* The signal starts `undefined` and updates to the resolved value once the
|
|
224
|
-
* promise settles. Use with native Angular control flow:
|
|
225
|
-
*
|
|
226
|
-
* ```ts
|
|
227
|
-
* @Component({
|
|
228
|
-
* template: `
|
|
229
|
-
* @if (reviews()) {
|
|
230
|
-
* <ul>
|
|
231
|
-
* @for (r of reviews(); track r.id) {
|
|
232
|
-
* <li>{{ r.author }}</li>
|
|
233
|
-
* }
|
|
234
|
-
* </ul>
|
|
235
|
-
* } @else {
|
|
236
|
-
* <p>Loading reviews…</p>
|
|
237
|
-
* }
|
|
238
|
-
* `,
|
|
239
|
-
* })
|
|
240
|
-
* export class Reviews {
|
|
241
|
-
* readonly reviews = injectDeferred<Review[]>("reviews");
|
|
242
|
-
* }
|
|
243
|
-
* ```
|
|
244
|
-
*
|
|
245
|
-
* **Asymmetric Angular** (see `.claude/SSR_FEATURE_GAPS_RU.md` §8): Angular
|
|
246
|
-
* does not ship `<Await>` / `<Streamed>` adapter components — Angular has no
|
|
247
|
-
* direct analogue to React's `use(promise)` or Svelte's `{#await}`. Use
|
|
248
|
-
* `@if (signal()) { … } @else { … }` or the `async` pipe with
|
|
249
|
-
* `from(deferredPromise)` instead.
|
|
250
|
-
*/
|
|
225
|
+
const NEVER_PROMISE = new Promise(() => {});
|
|
251
226
|
function injectDeferred(key) {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
/* v8 ignore next 4 -- @preserve: rejection branch — `effect` swallows
|
|
276
|
-
async errors silently, so leaving the signal as `undefined` is the
|
|
277
|
-
only observable behaviour. Real error surfacing is the loader's
|
|
278
|
-
responsibility (throw → navigation rejects → app error boundary). */
|
|
279
|
-
() => {
|
|
280
|
-
// Intentional swallow — see v8 ignore note above.
|
|
281
|
-
});
|
|
282
|
-
});
|
|
283
|
-
return value.asReadonly();
|
|
227
|
+
const { routeState } = injectRoute();
|
|
228
|
+
const promiseSignal = computed(() => {
|
|
229
|
+
return routeState().route.context.ssrDataDeferred?.[key] ?? NEVER_PROMISE;
|
|
230
|
+
}, ...ngDevMode ? [{ debugName: "promiseSignal" }] : /* istanbul ignore next */ []);
|
|
231
|
+
const value = signal(void 0, ...ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []);
|
|
232
|
+
effect((onCleanup) => {
|
|
233
|
+
const promise = promiseSignal();
|
|
234
|
+
let cancelled = false;
|
|
235
|
+
onCleanup(() => {
|
|
236
|
+
cancelled = true;
|
|
237
|
+
});
|
|
238
|
+
promise.then(
|
|
239
|
+
(resolved) => {
|
|
240
|
+
if (!cancelled) value.set(resolved);
|
|
241
|
+
},
|
|
242
|
+
/* v8 ignore next 4 -- @preserve: rejection branch — `effect` swallows
|
|
243
|
+
async errors silently, so leaving the signal as `undefined` is the
|
|
244
|
+
only observable behaviour. Real error surfacing is the loader's
|
|
245
|
+
responsibility (throw → navigation rejects → app error boundary). */
|
|
246
|
+
() => {}
|
|
247
|
+
);
|
|
248
|
+
});
|
|
249
|
+
return value.asReadonly();
|
|
284
250
|
}
|
|
285
|
-
|
|
286
|
-
/**
|
|
287
|
-
* Environment providers for a request-scoped `HttpStatusSink`. Pair with
|
|
288
|
-
* `createHttpStatusSink()` and read `sink.code` after the SSR render pass
|
|
289
|
-
* completes.
|
|
290
|
-
*
|
|
291
|
-
* Application bootstrap:
|
|
292
|
-
*
|
|
293
|
-
* ```ts
|
|
294
|
-
* const sink = createHttpStatusSink();
|
|
295
|
-
*
|
|
296
|
-
* await bootstrapApplication(AppRoot, {
|
|
297
|
-
* providers: [
|
|
298
|
-
* provideRealRouterFactory({ ... }),
|
|
299
|
-
* provideHttpStatusSink(sink),
|
|
300
|
-
* ],
|
|
301
|
-
* });
|
|
302
|
-
*
|
|
303
|
-
* response.status(sink.code ?? 200).send(html);
|
|
304
|
-
* ```
|
|
305
|
-
*
|
|
306
|
-
* Equivalent to:
|
|
307
|
-
*
|
|
308
|
-
* ```ts
|
|
309
|
-
* { provide: HTTP_STATUS_SINK, useValue: sink }
|
|
310
|
-
* ```
|
|
311
|
-
*
|
|
312
|
-
* Use the explicit `useValue` form when you need to compose with other
|
|
313
|
-
* application providers in a single `providers: [...]` block.
|
|
314
|
-
*/
|
|
315
251
|
function provideHttpStatusSink(sink) {
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
252
|
+
return makeEnvironmentProviders([{
|
|
253
|
+
provide: HTTP_STATUS_SINK,
|
|
254
|
+
useValue: sink
|
|
255
|
+
}]);
|
|
319
256
|
}
|
|
320
|
-
|
|
321
|
-
// SSR-feature entry — Angular 21+
|
|
322
|
-
//
|
|
323
|
-
// Server-side and SSR-aware components/functions. Mirrors the
|
|
324
|
-
// `/ssr` subpath split shipped by every other adapter (#604 + #610).
|
|
325
|
-
// Trigger reached: `<ClientOnly>`, `<ServerOnly>`, `injectDeferred()`
|
|
326
|
-
// — three SSR-feature exports, ≥3 threshold per
|
|
327
|
-
// `.claude/SSR_FEATURE_GAPS_RU.md` §8.
|
|
328
|
-
//
|
|
329
|
-
// Asymmetric Angular note: Angular has no native `<Suspense>` /
|
|
330
|
-
// `use(promise)` analogue, so this entry exposes the signal-based
|
|
331
|
-
// `injectDeferred()` instead of `<Await>` / `<Streamed>` adapter
|
|
332
|
-
// components. Consumers compose with `@if (signal()) { … } @else { … }`,
|
|
333
|
-
// the `async` pipe (`from(deferredPromise)`), or native `@defer`
|
|
334
|
-
// blocks for chunk-level lazy hydration.
|
|
335
|
-
// Components
|
|
336
|
-
|
|
337
|
-
/**
|
|
338
|
-
* Generated bundle index. Do not edit.
|
|
339
|
-
*/
|
|
340
|
-
|
|
341
257
|
export { ClientOnly, HTTP_STATUS_SINK, HttpStatusCode, ServerOnly, createHttpStatusSink, injectDeferred, provideHttpStatusSink };
|
|
342
|
-
|
|
258
|
+
|
|
259
|
+
//# sourceMappingURL=real-router-angular-ssr.mjs.map
|