@ngrx/signals 20.0.1 → 21.0.0-beta.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.
- package/fesm2022/ngrx-signals-entities.mjs.map +1 -1
- package/fesm2022/ngrx-signals-events.mjs +223 -61
- package/fesm2022/ngrx-signals-events.mjs.map +1 -1
- package/fesm2022/ngrx-signals-rxjs-interop.mjs +5 -5
- package/fesm2022/ngrx-signals-rxjs-interop.mjs.map +1 -1
- package/fesm2022/ngrx-signals.mjs +31 -25
- package/fesm2022/ngrx-signals.mjs.map +1 -1
- package/migrations/18_0_0-rc_3-protected-state/index.js +54 -23
- package/migrations/18_0_0-rc_3-protected-state/index.js.map +1 -1
- package/migrations/18_0_0-rc_3-writablestatesource/index.js +45 -12
- package/migrations/18_0_0-rc_3-writablestatesource/index.js.map +1 -1
- package/migrations/19_0_0-rc_0-props/index.js +72 -83
- package/migrations/19_0_0-rc_0-props/index.js.map +1 -1
- package/migrations/21_0_0-beta_0-rename-withEffects-to-withEventHandlers/index.js +103 -0
- package/migrations/21_0_0-beta_0-rename-withEffects-to-withEventHandlers/index.js.map +1 -0
- package/migrations/migration.json +5 -0
- package/package.json +8 -8
- package/schematics/ng-add/index.js +5 -5
- package/schematics/ng-add/index.js.map +1 -1
- package/schematics-core/index.js +1 -1
- package/schematics-core/index.js.map +1 -1
- package/schematics-core/utility/ast-utils.js +198 -240
- package/schematics-core/utility/ast-utils.js.map +1 -1
- package/schematics-core/utility/change.js +68 -85
- package/schematics-core/utility/change.js.map +1 -1
- package/schematics-core/utility/config.js +7 -7
- package/schematics-core/utility/config.js.map +1 -1
- package/schematics-core/utility/find-component.js +20 -20
- package/schematics-core/utility/find-component.js.map +1 -1
- package/schematics-core/utility/find-module.js +21 -21
- package/schematics-core/utility/find-module.js.map +1 -1
- package/schematics-core/utility/json-utilts.js +4 -26
- package/schematics-core/utility/json-utilts.js.map +1 -1
- package/schematics-core/utility/libs-version.js +1 -1
- package/schematics-core/utility/libs-version.js.map +1 -1
- package/schematics-core/utility/ngrx-utils.js +110 -141
- package/schematics-core/utility/ngrx-utils.js.map +1 -1
- package/schematics-core/utility/package.js +2 -3
- package/schematics-core/utility/package.js.map +1 -1
- package/schematics-core/utility/parse-name.js +3 -3
- package/schematics-core/utility/parse-name.js.map +1 -1
- package/schematics-core/utility/project.js +13 -13
- package/schematics-core/utility/project.js.map +1 -1
- package/schematics-core/utility/strings.js +12 -12
- package/schematics-core/utility/strings.js.map +1 -1
- package/schematics-core/utility/update.js +12 -12
- package/schematics-core/utility/update.js.map +1 -1
- package/schematics-core/utility/visitors.js +78 -180
- package/schematics-core/utility/visitors.js.map +1 -1
- package/types/ngrx-signals-entities.d.ts +324 -0
- package/types/ngrx-signals-events.d.ts +360 -0
- package/types/ngrx-signals-rxjs-interop.d.ts +15 -0
- package/{testing/src/unprotected.d.ts → types/ngrx-signals-testing.d.ts} +5 -3
- package/types/ngrx-signals.d.ts +332 -0
- package/entities/index.d.ts +0 -1
- package/entities/src/entity-config.d.ts +0 -17
- package/entities/src/helpers.d.ts +0 -25
- package/entities/src/index.d.ts +0 -18
- package/entities/src/models.d.ts +0 -24
- package/entities/src/updaters/add-entities.d.ts +0 -17
- package/entities/src/updaters/add-entity.d.ts +0 -17
- package/entities/src/updaters/prepend-entities.d.ts +0 -17
- package/entities/src/updaters/prepend-entity.d.ts +0 -17
- package/entities/src/updaters/remove-all-entities.d.ts +0 -6
- package/entities/src/updaters/remove-entities.d.ts +0 -10
- package/entities/src/updaters/remove-entity.d.ts +0 -6
- package/entities/src/updaters/set-all-entities.d.ts +0 -17
- package/entities/src/updaters/set-entities.d.ts +0 -17
- package/entities/src/updaters/set-entity.d.ts +0 -17
- package/entities/src/updaters/update-all-entities.d.ts +0 -17
- package/entities/src/updaters/update-entities.d.ts +0 -56
- package/entities/src/updaters/update-entity.d.ts +0 -29
- package/entities/src/updaters/upsert-entities.d.ts +0 -17
- package/entities/src/updaters/upsert-entity.d.ts +0 -17
- package/entities/src/with-entities.d.ts +0 -22
- package/events/index.d.ts +0 -1
- package/events/src/case-reducer.d.ts +0 -20
- package/events/src/dispatcher.d.ts +0 -33
- package/events/src/event-creator-group.d.ts +0 -33
- package/events/src/event-creator.d.ts +0 -9
- package/events/src/event-instance.d.ts +0 -8
- package/events/src/events-service.d.ts +0 -47
- package/events/src/index.d.ts +0 -9
- package/events/src/inject-dispatch.d.ts +0 -46
- package/events/src/with-effects.d.ts +0 -28
- package/events/src/with-reducer.d.ts +0 -30
- package/index.d.ts +0 -1
- package/rxjs-interop/index.d.ts +0 -1
- package/rxjs-interop/src/index.d.ts +0 -1
- package/rxjs-interop/src/rx-method.d.ts +0 -12
- package/src/deep-computed.d.ts +0 -2
- package/src/deep-signal.d.ts +0 -6
- package/src/index.d.ts +0 -16
- package/src/signal-method.d.ts +0 -7
- package/src/signal-state.d.ts +0 -4
- package/src/signal-store-assertions.d.ts +0 -2
- package/src/signal-store-feature.d.ts +0 -29
- package/src/signal-store-models.d.ts +0 -30
- package/src/signal-store.d.ts +0 -142
- package/src/state-source.d.ts +0 -23
- package/src/ts-helpers.d.ts +0 -11
- package/src/with-computed.d.ts +0 -12
- package/src/with-feature.d.ts +0 -26
- package/src/with-hooks.d.ts +0 -14
- package/src/with-linked-state.d.ts +0 -52
- package/src/with-methods.d.ts +0 -8
- package/src/with-props.d.ts +0 -8
- package/src/with-state.d.ts +0 -11
- package/testing/index.d.ts +0 -1
- package/testing/src/index.d.ts +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { untracked, isSignal, computed, assertInInjectionContext, inject, Injector, effect, DestroyRef, signal, Injectable, linkedSignal } from '@angular/core';
|
|
3
3
|
|
|
4
|
-
const DEEP_SIGNAL = Symbol('DEEP_SIGNAL');
|
|
4
|
+
const DEEP_SIGNAL = Symbol(typeof ngDevMode !== 'undefined' && ngDevMode ? 'DEEP_SIGNAL' : '');
|
|
5
5
|
function toDeepSignal(signal) {
|
|
6
6
|
return new Proxy(signal, {
|
|
7
7
|
has(target, prop) {
|
|
@@ -62,13 +62,13 @@ function deepComputed(computation) {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
function signalMethod(processingFn, config) {
|
|
65
|
-
if (!config?.injector) {
|
|
65
|
+
if (typeof ngDevMode !== 'undefined' && ngDevMode && !config?.injector) {
|
|
66
66
|
assertInInjectionContext(signalMethod);
|
|
67
67
|
}
|
|
68
68
|
const watchers = [];
|
|
69
69
|
const sourceInjector = config?.injector ?? inject(Injector);
|
|
70
70
|
const signalMethodFn = (input, config) => {
|
|
71
|
-
if (
|
|
71
|
+
if (isReactiveComputation(input)) {
|
|
72
72
|
const callerInjector = getCallerInjector();
|
|
73
73
|
if (typeof ngDevMode !== 'undefined' &&
|
|
74
74
|
ngDevMode &&
|
|
@@ -80,7 +80,7 @@ function signalMethod(processingFn, config) {
|
|
|
80
80
|
const watcher = effect(() => {
|
|
81
81
|
const value = input();
|
|
82
82
|
untracked(() => processingFn(value));
|
|
83
|
-
}, { injector: instanceInjector });
|
|
83
|
+
}, { ...(ngDevMode ? { debugName: "watcher" } : {}), injector: instanceInjector });
|
|
84
84
|
watchers.push(watcher);
|
|
85
85
|
instanceInjector.get(DestroyRef).onDestroy(() => {
|
|
86
86
|
const ix = watchers.indexOf(watcher);
|
|
@@ -106,9 +106,12 @@ function getCallerInjector() {
|
|
|
106
106
|
return undefined;
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
|
+
function isReactiveComputation(value) {
|
|
110
|
+
return typeof value === 'function';
|
|
111
|
+
}
|
|
109
112
|
|
|
110
113
|
const STATE_WATCHERS = new WeakMap();
|
|
111
|
-
const STATE_SOURCE = Symbol('STATE_SOURCE');
|
|
114
|
+
const STATE_SOURCE = Symbol(typeof ngDevMode !== 'undefined' && ngDevMode ? 'STATE_SOURCE' : '');
|
|
112
115
|
function isWritableSignal(value) {
|
|
113
116
|
return (isSignal(value) &&
|
|
114
117
|
'set' in value &&
|
|
@@ -154,7 +157,7 @@ function getState(stateSource) {
|
|
|
154
157
|
}, {});
|
|
155
158
|
}
|
|
156
159
|
function watchState(stateSource, watcher, config) {
|
|
157
|
-
if (!config?.injector) {
|
|
160
|
+
if (typeof ngDevMode !== 'undefined' && ngDevMode && !config?.injector) {
|
|
158
161
|
assertInInjectionContext(watchState);
|
|
159
162
|
}
|
|
160
163
|
const injector = config?.injector ?? inject(Injector);
|
|
@@ -190,7 +193,7 @@ function signalState(initialState) {
|
|
|
190
193
|
...signalsDict,
|
|
191
194
|
[key]: signal(initialState[key]),
|
|
192
195
|
}), {});
|
|
193
|
-
const signalState = computed(() => stateKeys.reduce((state, key) => ({ ...state, [key]: stateSource[key]() }), {}));
|
|
196
|
+
const signalState = computed(() => stateKeys.reduce((state, key) => ({ ...state, [key]: stateSource[key]() }), {}), { ...(ngDevMode ? { debugName: "signalState" } : {}) });
|
|
194
197
|
Object.defineProperty(signalState, STATE_SOURCE, {
|
|
195
198
|
value: stateSource,
|
|
196
199
|
});
|
|
@@ -229,10 +232,10 @@ function signalStore(...args) {
|
|
|
229
232
|
inject(DestroyRef).onDestroy(onDestroy);
|
|
230
233
|
}
|
|
231
234
|
}
|
|
232
|
-
/** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
233
|
-
/** @nocollapse */ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
235
|
+
/** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.1", ngImport: i0, type: SignalStore, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
236
|
+
/** @nocollapse */ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.1", ngImport: i0, type: SignalStore, providedIn: config.providedIn || null });
|
|
234
237
|
}
|
|
235
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
238
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.1", ngImport: i0, type: SignalStore, decorators: [{
|
|
236
239
|
type: Injectable,
|
|
237
240
|
args: [{ providedIn: config.providedIn || null }]
|
|
238
241
|
}], ctorParameters: () => [] });
|
|
@@ -257,9 +260,6 @@ function type() {
|
|
|
257
260
|
}
|
|
258
261
|
|
|
259
262
|
function assertUniqueStoreMembers(store, newMemberKeys) {
|
|
260
|
-
if (typeof ngDevMode === 'undefined' || !ngDevMode) {
|
|
261
|
-
return;
|
|
262
|
-
}
|
|
263
263
|
const storeMembers = {
|
|
264
264
|
...store.stateSignals,
|
|
265
265
|
...store.props,
|
|
@@ -279,7 +279,9 @@ function withProps(propsFactory) {
|
|
|
279
279
|
...store.props,
|
|
280
280
|
...store.methods,
|
|
281
281
|
});
|
|
282
|
-
|
|
282
|
+
if (typeof ngDevMode !== 'undefined' && ngDevMode) {
|
|
283
|
+
assertUniqueStoreMembers(store, Reflect.ownKeys(props));
|
|
284
|
+
}
|
|
283
285
|
return {
|
|
284
286
|
...store,
|
|
285
287
|
props: { ...store.props, ...props },
|
|
@@ -329,9 +331,9 @@ function withFeature(featureFactory) {
|
|
|
329
331
|
return (store) => {
|
|
330
332
|
const storeForFactory = {
|
|
331
333
|
[STATE_SOURCE]: store[STATE_SOURCE],
|
|
332
|
-
...store
|
|
333
|
-
...store
|
|
334
|
-
...store
|
|
334
|
+
...store.stateSignals,
|
|
335
|
+
...store.props,
|
|
336
|
+
...store.methods,
|
|
335
337
|
};
|
|
336
338
|
return featureFactory(storeForFactory)(store);
|
|
337
339
|
};
|
|
@@ -348,9 +350,7 @@ function withHooks(hooksOrFactory) {
|
|
|
348
350
|
const hooks = typeof hooksOrFactory === 'function'
|
|
349
351
|
? hooksOrFactory(storeMembers)
|
|
350
352
|
: hooksOrFactory;
|
|
351
|
-
const
|
|
352
|
-
const hook = hooks[name];
|
|
353
|
-
const currentHook = store.hooks[name];
|
|
353
|
+
const mergeHooks = (currentHook, hook) => {
|
|
354
354
|
return hook
|
|
355
355
|
? () => {
|
|
356
356
|
if (currentHook) {
|
|
@@ -363,8 +363,8 @@ function withHooks(hooksOrFactory) {
|
|
|
363
363
|
return {
|
|
364
364
|
...store,
|
|
365
365
|
hooks: {
|
|
366
|
-
onInit:
|
|
367
|
-
onDestroy:
|
|
366
|
+
onInit: mergeHooks(store.hooks.onInit, hooks.onInit),
|
|
367
|
+
onDestroy: mergeHooks(store.hooks.onDestroy, hooks.onDestroy),
|
|
368
368
|
},
|
|
369
369
|
};
|
|
370
370
|
};
|
|
@@ -417,7 +417,9 @@ function withLinkedState(linkedStateFactory) {
|
|
|
417
417
|
...store.props,
|
|
418
418
|
});
|
|
419
419
|
const stateKeys = Reflect.ownKeys(linkedState);
|
|
420
|
-
|
|
420
|
+
if (typeof ngDevMode !== 'undefined' && ngDevMode) {
|
|
421
|
+
assertUniqueStoreMembers(store, stateKeys);
|
|
422
|
+
}
|
|
421
423
|
const stateSource = store[STATE_SOURCE];
|
|
422
424
|
const stateSignals = {};
|
|
423
425
|
for (const key of stateKeys) {
|
|
@@ -442,7 +444,9 @@ function withMethods(methodsFactory) {
|
|
|
442
444
|
...store.props,
|
|
443
445
|
...store.methods,
|
|
444
446
|
});
|
|
445
|
-
|
|
447
|
+
if (typeof ngDevMode !== 'undefined' && ngDevMode) {
|
|
448
|
+
assertUniqueStoreMembers(store, Reflect.ownKeys(methods));
|
|
449
|
+
}
|
|
446
450
|
return {
|
|
447
451
|
...store,
|
|
448
452
|
methods: { ...store.methods, ...methods },
|
|
@@ -454,7 +458,9 @@ function withState(stateOrFactory) {
|
|
|
454
458
|
return (store) => {
|
|
455
459
|
const state = (typeof stateOrFactory === 'function' ? stateOrFactory() : stateOrFactory);
|
|
456
460
|
const stateKeys = Reflect.ownKeys(state);
|
|
457
|
-
|
|
461
|
+
if (typeof ngDevMode !== 'undefined' && ngDevMode) {
|
|
462
|
+
assertUniqueStoreMembers(store, stateKeys);
|
|
463
|
+
}
|
|
458
464
|
const stateSource = store[STATE_SOURCE];
|
|
459
465
|
const stateSignals = {};
|
|
460
466
|
for (const key of stateKeys) {
|