@nx/angular 21.0.0-beta.3 → 21.0.0-beta.5
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/fesm2022/nx-angular.mjs +0 -352
- package/fesm2022/nx-angular.mjs.map +1 -1
- package/generators.json +2 -2
- package/index.d.ts +1 -1
- package/migrations.json +18 -69
- package/package.json +9 -14
- package/src/builders/dev-server/schema.d.ts +3 -0
- package/src/builders/dev-server/schema.json +1 -1
- package/src/builders/webpack-browser/schema.d.ts +0 -5
- package/src/builders/webpack-browser/webpack-browser.impl.js +3 -4
- package/src/executors/module-federation-dev-server/schema.d.ts +3 -0
- package/src/executors/module-federation-dev-server/schema.json +1 -1
- package/src/generators/add-linting/lib/create-eslint-configuration.d.ts +2 -2
- package/src/generators/add-linting/lib/create-eslint-configuration.js +2 -2
- package/src/generators/application/application.js +6 -0
- package/src/generators/application/files/rspack-ssr/server.ts__tmpl__ +72 -0
- package/src/generators/application/lib/add-e2e.js +0 -7
- package/src/generators/application/schema.d.ts +0 -1
- package/src/generators/application/schema.json +0 -6
- package/src/generators/convert-to-rspack/convert-to-rspack.js +20 -10
- package/src/generators/convert-to-rspack/lib/create-config.js +14 -17
- package/src/generators/convert-to-rspack/lib/get-custom-webpack-config.js +5 -3
- package/src/generators/host/schema.d.ts +0 -1
- package/src/generators/host/schema.json +0 -6
- package/src/generators/library/lib/normalized-schema.d.ts +0 -1
- package/src/generators/library/schema.d.ts +0 -1
- package/src/generators/library/schema.json +0 -6
- package/src/generators/move/move.d.ts +3 -0
- package/src/generators/move/move.js +3 -0
- package/src/generators/ngrx/ngrx.d.ts +3 -0
- package/src/generators/ngrx/ngrx.js +3 -0
- package/src/generators/ngrx/schema.json +1 -1
- package/src/generators/remote/schema.d.ts +0 -1
- package/src/generators/remote/schema.json +0 -6
- package/src/migrations/update-16-2-0/switch-data-persistence-operators-imports-to-ngrx-router-store.js +4 -4
- package/src/migrations/{update-16-1-0/remove-ngcc-invocation.d.ts → update-21-0-0/change-data-persistence-operators-imports-to-ngrx-router-store-data-persistence.d.ts} +1 -1
- package/src/migrations/update-21-0-0/change-data-persistence-operators-imports-to-ngrx-router-store-data-persistence.js +122 -0
- package/src/utils/nx-devkit/ast-utils.d.ts +0 -8
- package/src/utils/nx-devkit/ast-utils.js +7 -12
- package/src/utils/versions.d.ts +1 -1
- package/src/utils/versions.js +1 -1
- package/fesm2022/nx-angular-testing.mjs +0 -45
- package/fesm2022/nx-angular-testing.mjs.map +0 -1
- package/src/migrations/update-16-0-0/remove-karma-defaults.d.ts +0 -2
- package/src/migrations/update-16-0-0/remove-karma-defaults.js +0 -52
- package/src/migrations/update-16-0-0/remove-library-generator-simple-module-name-option.d.ts +0 -2
- package/src/migrations/update-16-0-0/remove-library-generator-simple-module-name-option.js +0 -40
- package/src/migrations/update-16-0-0/remove-protractor-defaults.d.ts +0 -2
- package/src/migrations/update-16-0-0/remove-protractor-defaults.js +0 -52
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +0 -2
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +0 -9
- package/src/migrations/update-16-1-0/extract-standalone-config-from-bootstrap.d.ts +0 -2
- package/src/migrations/update-16-1-0/extract-standalone-config-from-bootstrap.js +0 -127
- package/src/migrations/update-16-1-0/remove-ngcc-invocation.js +0 -22
- package/src/migrations/update-16-1-0/remove-render-module-platform-server-exports.d.ts +0 -2
- package/src/migrations/update-16-1-0/remove-render-module-platform-server-exports.js +0 -62
- package/src/migrations/update-16-1-0/update-angular-cli.d.ts +0 -3
- package/src/migrations/update-16-1-0/update-angular-cli.js +0 -23
- package/src/migrations/update-16-1-0/update-server-executor-config.d.ts +0 -2
- package/src/migrations/update-16-1-0/update-server-executor-config.js +0 -26
- package/src/runtime/nx/data-persistence.d.ts +0 -276
- package/testing/index.d.ts +0 -1
- package/testing/ng-package.json +0 -6
- package/testing/src/testing-utils.d.ts +0 -33
@@ -1,276 +0,0 @@
|
|
1
|
-
import type { Type } from '@angular/core';
|
2
|
-
import type { ActivatedRouteSnapshot } from '@angular/router';
|
3
|
-
import type { Action } from '@ngrx/store';
|
4
|
-
import type { Observable } from 'rxjs';
|
5
|
-
export interface PessimisticUpdateOpts<T extends Array<unknown>, A> {
|
6
|
-
run(a: A, ...slices: [...T]): Observable<Action> | Action | void;
|
7
|
-
onError(a: A, e: any): Observable<any> | any;
|
8
|
-
}
|
9
|
-
export interface OptimisticUpdateOpts<T extends Array<unknown>, A> {
|
10
|
-
run(a: A, ...slices: [...T]): Observable<Action> | Action | void;
|
11
|
-
undoAction(a: A, e: any): Observable<Action> | Action;
|
12
|
-
}
|
13
|
-
export interface FetchOpts<T extends Array<unknown>, A> {
|
14
|
-
id?(a: A, ...slices: [...T]): any;
|
15
|
-
run(a: A, ...slices: [...T]): Observable<Action> | Action | void;
|
16
|
-
onError?(a: A, e: any): Observable<any> | any;
|
17
|
-
}
|
18
|
-
export interface HandleNavigationOpts<T extends Array<unknown>> {
|
19
|
-
run(a: ActivatedRouteSnapshot, ...slices: [...T]): Observable<Action> | Action | void;
|
20
|
-
onError?(a: ActivatedRouteSnapshot, e: any): Observable<any> | any;
|
21
|
-
}
|
22
|
-
export type ActionOrActionWithStates<T extends Array<unknown>, A> = A | [A, ...T];
|
23
|
-
export type ActionOrActionWithState<T, A> = ActionOrActionWithStates<[T], A>;
|
24
|
-
export type ActionStatesStream<T extends Array<unknown>, A> = Observable<ActionOrActionWithStates<T, A>>;
|
25
|
-
export type ActionStateStream<T, A> = Observable<ActionOrActionWithStates<[T], A>>;
|
26
|
-
/**
|
27
|
-
* @whatItDoes Handles pessimistic updates (updating the server first).
|
28
|
-
*
|
29
|
-
* Updating the server, when implemented naively, suffers from race conditions and poor error handling.
|
30
|
-
*
|
31
|
-
* `pessimisticUpdate` addresses these problems. It runs all fetches in order, which removes race conditions
|
32
|
-
* and forces the developer to handle errors.
|
33
|
-
*
|
34
|
-
* ## Example:
|
35
|
-
*
|
36
|
-
* ```typescript
|
37
|
-
* @Injectable()
|
38
|
-
* class TodoEffects {
|
39
|
-
* updateTodo$ = createEffect(() =>
|
40
|
-
* this.actions$.pipe(
|
41
|
-
* ofType('UPDATE_TODO'),
|
42
|
-
* pessimisticUpdate({
|
43
|
-
* // provides an action
|
44
|
-
* run: (action: UpdateTodo) => {
|
45
|
-
* // update the backend first, and then dispatch an action that will
|
46
|
-
* // update the client side
|
47
|
-
* return this.backend.updateTodo(action.todo.id, action.todo).pipe(
|
48
|
-
* map((updated) => ({
|
49
|
-
* type: 'UPDATE_TODO_SUCCESS',
|
50
|
-
* todo: updated,
|
51
|
-
* }))
|
52
|
-
* );
|
53
|
-
* },
|
54
|
-
* onError: (action: UpdateTodo, error: any) => {
|
55
|
-
* // we don't need to undo the changes on the client side.
|
56
|
-
* // we can dispatch an error, or simply log the error here and return `null`
|
57
|
-
* return null;
|
58
|
-
* },
|
59
|
-
* })
|
60
|
-
* )
|
61
|
-
* );
|
62
|
-
*
|
63
|
-
* constructor(private actions$: Actions, private backend: Backend) {}
|
64
|
-
* }
|
65
|
-
* ```
|
66
|
-
*
|
67
|
-
* Note that if you don't return a new action from the run callback, you must set the dispatch property
|
68
|
-
* of the effect to false, like this:
|
69
|
-
*
|
70
|
-
* ```typescript
|
71
|
-
* class TodoEffects {
|
72
|
-
* updateTodo$ = createEffect(() =>
|
73
|
-
* this.actions$.pipe(
|
74
|
-
* //...
|
75
|
-
* ), { dispatch: false }
|
76
|
-
* );
|
77
|
-
* }
|
78
|
-
* ```
|
79
|
-
*
|
80
|
-
* @param opts
|
81
|
-
*
|
82
|
-
* @deprecated This will be removed in Nx v21. Import `pessimisticUpdate` from `@ngrx/router-store/data-persistence` instead.
|
83
|
-
*/
|
84
|
-
export declare function pessimisticUpdate<T extends Array<unknown>, A extends Action>(opts: PessimisticUpdateOpts<T, A>): (source: ActionStatesStream<T, A>) => Observable<Action>;
|
85
|
-
/**
|
86
|
-
* @whatItDoes Handles optimistic updates (updating the client first).
|
87
|
-
*
|
88
|
-
* It runs all fetches in order, which removes race conditions and forces the developer to handle errors.
|
89
|
-
*
|
90
|
-
* When using `optimisticUpdate`, in case of a failure, the developer has already updated the state locally,
|
91
|
-
* so the developer must provide an undo action.
|
92
|
-
*
|
93
|
-
* The error handling must be done in the callback, or by means of the undo action.
|
94
|
-
*
|
95
|
-
* ## Example:
|
96
|
-
*
|
97
|
-
* ```typescript
|
98
|
-
* @Injectable()
|
99
|
-
* class TodoEffects {
|
100
|
-
* updateTodo$ = createEffect(() =>
|
101
|
-
* this.actions$.pipe(
|
102
|
-
* ofType('UPDATE_TODO'),
|
103
|
-
* optimisticUpdate({
|
104
|
-
* // provides an action
|
105
|
-
* run: (action: UpdateTodo) => {
|
106
|
-
* return this.backend.updateTodo(action.todo.id, action.todo).pipe(
|
107
|
-
* mapTo({
|
108
|
-
* type: 'UPDATE_TODO_SUCCESS',
|
109
|
-
* })
|
110
|
-
* );
|
111
|
-
* },
|
112
|
-
* undoAction: (action: UpdateTodo, error: any) => {
|
113
|
-
* // dispatch an undo action to undo the changes in the client state
|
114
|
-
* return {
|
115
|
-
* type: 'UNDO_TODO_UPDATE',
|
116
|
-
* todo: action.todo,
|
117
|
-
* };
|
118
|
-
* },
|
119
|
-
* })
|
120
|
-
* )
|
121
|
-
* );
|
122
|
-
*
|
123
|
-
* constructor(private actions$: Actions, private backend: Backend) {}
|
124
|
-
* }
|
125
|
-
* ```
|
126
|
-
*
|
127
|
-
* Note that if you don't return a new action from the run callback, you must set the dispatch property
|
128
|
-
* of the effect to false, like this:
|
129
|
-
*
|
130
|
-
* ```typescript
|
131
|
-
* class TodoEffects {
|
132
|
-
* updateTodo$ = createEffect(() =>
|
133
|
-
* this.actions$.pipe(
|
134
|
-
* //...
|
135
|
-
* ), { dispatch: false }
|
136
|
-
* );
|
137
|
-
* }
|
138
|
-
* ```
|
139
|
-
*
|
140
|
-
* @param opts
|
141
|
-
*
|
142
|
-
* @deprecated This will be removed in Nx v21. Import `optimisticUpdate` from `@ngrx/router-store/data-persistence` instead.
|
143
|
-
*/
|
144
|
-
export declare function optimisticUpdate<T extends Array<unknown>, A extends Action>(opts: OptimisticUpdateOpts<T, A>): (source: ActionStatesStream<T, A>) => Observable<Action>;
|
145
|
-
/**
|
146
|
-
* @whatItDoes Handles data fetching.
|
147
|
-
*
|
148
|
-
* Data fetching implemented naively suffers from race conditions and poor error handling.
|
149
|
-
*
|
150
|
-
* `fetch` addresses these problems. It runs all fetches in order, which removes race conditions
|
151
|
-
* and forces the developer to handle errors.
|
152
|
-
*
|
153
|
-
* ## Example:
|
154
|
-
*
|
155
|
-
* ```typescript
|
156
|
-
* @Injectable()
|
157
|
-
* class TodoEffects {
|
158
|
-
* loadTodos$ = createEffect(() =>
|
159
|
-
* this.actions$.pipe(
|
160
|
-
* ofType('GET_TODOS'),
|
161
|
-
* fetch({
|
162
|
-
* // provides an action
|
163
|
-
* run: (a: GetTodos) => {
|
164
|
-
* return this.backend.getAll().pipe(
|
165
|
-
* map((response) => ({
|
166
|
-
* type: 'TODOS',
|
167
|
-
* todos: response.todos,
|
168
|
-
* }))
|
169
|
-
* );
|
170
|
-
* },
|
171
|
-
* onError: (action: GetTodos, error: any) => {
|
172
|
-
* // dispatch an undo action to undo the changes in the client state
|
173
|
-
* return null;
|
174
|
-
* },
|
175
|
-
* })
|
176
|
-
* )
|
177
|
-
* );
|
178
|
-
*
|
179
|
-
* constructor(private actions$: Actions, private backend: Backend) {}
|
180
|
-
* }
|
181
|
-
* ```
|
182
|
-
*
|
183
|
-
* This is correct, but because it set the concurrency to 1, it may not be performant.
|
184
|
-
*
|
185
|
-
* To fix that, you can provide the `id` function, like this:
|
186
|
-
*
|
187
|
-
* ```typescript
|
188
|
-
* @Injectable()
|
189
|
-
* class TodoEffects {
|
190
|
-
* loadTodo$ = createEffect(() =>
|
191
|
-
* this.actions$.pipe(
|
192
|
-
* ofType('GET_TODO'),
|
193
|
-
* fetch({
|
194
|
-
* id: (todo: GetTodo) => {
|
195
|
-
* return todo.id;
|
196
|
-
* },
|
197
|
-
* // provides an action
|
198
|
-
* run: (todo: GetTodo) => {
|
199
|
-
* return this.backend.getTodo(todo.id).map((response) => ({
|
200
|
-
* type: 'LOAD_TODO_SUCCESS',
|
201
|
-
* todo: response.todo,
|
202
|
-
* }));
|
203
|
-
* },
|
204
|
-
* onError: (action: GetTodo, error: any) => {
|
205
|
-
* // dispatch an undo action to undo the changes in the client state
|
206
|
-
* return null;
|
207
|
-
* },
|
208
|
-
* })
|
209
|
-
* )
|
210
|
-
* );
|
211
|
-
*
|
212
|
-
* constructor(private actions$: Actions, private backend: Backend) {}
|
213
|
-
* }
|
214
|
-
* ```
|
215
|
-
*
|
216
|
-
* With this setup, the requests for Todo 1 will run concurrently with the requests for Todo 2.
|
217
|
-
*
|
218
|
-
* In addition, if there are multiple requests for Todo 1 scheduled, it will only run the last one.
|
219
|
-
*
|
220
|
-
* @param opts
|
221
|
-
*
|
222
|
-
* @deprecated This will be removed in Nx v21. Import `fetch` from `@ngrx/router-store/data-persistence` instead.
|
223
|
-
*/
|
224
|
-
export declare function fetch<T extends Array<unknown>, A extends Action>(opts: FetchOpts<T, A>): (source: ActionStatesStream<T, A>) => Observable<Action>;
|
225
|
-
/**
|
226
|
-
* @whatItDoes Handles data fetching as part of router navigation.
|
227
|
-
*
|
228
|
-
* Data fetching implemented naively suffers from race conditions and poor error handling.
|
229
|
-
*
|
230
|
-
* `navigation` addresses these problems.
|
231
|
-
*
|
232
|
-
* It checks if an activated router state contains the passed in component type, and, if it does, runs the `run`
|
233
|
-
* callback. It provides the activated snapshot associated with the component and the current state. And it only runs
|
234
|
-
* the last request.
|
235
|
-
*
|
236
|
-
* ## Example:
|
237
|
-
*
|
238
|
-
* ```typescript
|
239
|
-
* @Injectable()
|
240
|
-
* class TodoEffects {
|
241
|
-
* loadTodo$ = createEffect(() =>
|
242
|
-
* this.actions$.pipe(
|
243
|
-
* // listens for the routerNavigation action from @ngrx/router-store
|
244
|
-
* navigation(TodoComponent, {
|
245
|
-
* run: (activatedRouteSnapshot: ActivatedRouteSnapshot) => {
|
246
|
-
* return this.backend
|
247
|
-
* .fetchTodo(activatedRouteSnapshot.params['id'])
|
248
|
-
* .pipe(
|
249
|
-
* map((todo) => ({
|
250
|
-
* type: 'LOAD_TODO_SUCCESS',
|
251
|
-
* todo: todo,
|
252
|
-
* }))
|
253
|
-
* );
|
254
|
-
* },
|
255
|
-
* onError: (
|
256
|
-
* activatedRouteSnapshot: ActivatedRouteSnapshot,
|
257
|
-
* error: any
|
258
|
-
* ) => {
|
259
|
-
* // we can log and error here and return null
|
260
|
-
* // we can also navigate back
|
261
|
-
* return null;
|
262
|
-
* },
|
263
|
-
* })
|
264
|
-
* )
|
265
|
-
* );
|
266
|
-
*
|
267
|
-
* constructor(private actions$: Actions, private backend: Backend) {}
|
268
|
-
* }
|
269
|
-
* ```
|
270
|
-
*
|
271
|
-
* @param component
|
272
|
-
* @param opts
|
273
|
-
*
|
274
|
-
* @deprecated This will be removed in Nx v21. Import `navigation` from `@ngrx/router-store/data-persistence` instead.
|
275
|
-
*/
|
276
|
-
export declare function navigation<T extends Array<unknown>, A extends Action>(component: Type<any>, opts: HandleNavigationOpts<T>): (source: ActionStatesStream<T, A>) => Observable<Action<string>>;
|
package/testing/index.d.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export { readAll, readFirst } from './src/testing-utils';
|
package/testing/ng-package.json
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
import type { Observable } from 'rxjs';
|
2
|
-
/**
|
3
|
-
* @deprecated This will be removed in Nx v21. If using RxJS 7, use `firstValueFrom(obs$.pipe(toArray()))`
|
4
|
-
* or `lastValueFrom(obs$.pipe(toArray()))`. If using RxJS 6, use `obs$.pipe(toArray()).toPromise()`.
|
5
|
-
*
|
6
|
-
* @whatItDoes reads all the values from an observable and returns a promise
|
7
|
-
* with an array of all values. This should be used in combination with async/await.
|
8
|
-
*
|
9
|
-
* ## Example
|
10
|
-
*
|
11
|
-
* ```typescript
|
12
|
-
* const obs = of(1, 2, 3, 4);
|
13
|
-
* const res = await readAll(obs)
|
14
|
-
* expect(res).toEqual([1, 2, 3, 4]);
|
15
|
-
* ```
|
16
|
-
*/
|
17
|
-
export declare function readAll<T>(o: Observable<T>): Promise<T[]>;
|
18
|
-
/**
|
19
|
-
* @deprecated This will be removed in Nx v21. Since RxJS 7, use `firstValueFrom(obs$)`. If using RxJS 6,
|
20
|
-
* use `obs$.pipe(first()).toPromise()`.
|
21
|
-
*
|
22
|
-
* @whatItDoes reads the first value from an observable and returns a promise
|
23
|
-
* with it. This should be used in combination with async/await.
|
24
|
-
*
|
25
|
-
* ## Example
|
26
|
-
*
|
27
|
-
* ```typescript
|
28
|
-
* const obs = of(1, 2, 3, 4);
|
29
|
-
* const res = await readFirst(obs)
|
30
|
-
* expect(res).toEqual(1);
|
31
|
-
* ```
|
32
|
-
*/
|
33
|
-
export declare function readFirst<T>(o: Observable<T>): Promise<T>;
|