@ngrx/signals 18.1.1 → 19.0.0-rc.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/entities/src/index.d.ts +1 -1
- package/entities/src/models.d.ts +3 -3
- package/entities/src/with-entities.d.ts +4 -4
- package/fesm2022/ngrx-signals-entities.mjs.map +1 -1
- package/fesm2022/ngrx-signals-rxjs-interop.mjs +5 -6
- package/fesm2022/ngrx-signals-rxjs-interop.mjs.map +1 -1
- package/fesm2022/ngrx-signals.mjs +120 -20
- package/fesm2022/ngrx-signals.mjs.map +1 -1
- package/migrations/18_0_0-rc_3-protected-state/index.js +2 -9
- package/migrations/18_0_0-rc_3-protected-state/index.js.map +1 -1
- package/migrations/19_0_0-rc_0-props/index.js +170 -0
- package/migrations/19_0_0-rc_0-props/index.js.map +1 -0
- package/migrations/migration.json +5 -0
- package/package.json +2 -8
- package/rxjs-interop/src/rx-method.d.ts +5 -2
- package/schematics-core/utility/libs-version.js +1 -1
- package/schematics-core/utility/libs-version.js.map +1 -1
- package/schematics-core/utility/visitors.js +87 -10
- package/schematics-core/utility/visitors.js.map +1 -1
- package/src/deep-freeze.d.ts +2 -0
- package/src/index.d.ts +2 -0
- package/src/signal-method.d.ts +8 -0
- package/src/signal-store-feature.d.ts +1 -1
- package/src/signal-store-models.d.ts +5 -5
- package/src/signal-store.d.ts +1 -1
- package/src/ts-helpers.d.ts +3 -1
- package/src/with-computed.d.ts +2 -2
- package/src/with-hooks.d.ts +2 -2
- package/src/with-methods.d.ts +2 -2
- package/src/with-props.d.ts +8 -0
- package/src/with-state.d.ts +2 -2
- package/esm2022/entities/index.mjs +0 -2
- package/esm2022/entities/ngrx-signals-entities.mjs +0 -5
- package/esm2022/entities/src/entity-config.mjs +0 -4
- package/esm2022/entities/src/helpers.mjs +0 -121
- package/esm2022/entities/src/index.mjs +0 -14
- package/esm2022/entities/src/models.mjs +0 -7
- package/esm2022/entities/src/updaters/add-entities.mjs +0 -11
- package/esm2022/entities/src/updaters/add-entity.mjs +0 -11
- package/esm2022/entities/src/updaters/remove-all-entities.mjs +0 -9
- package/esm2022/entities/src/updaters/remove-entities.mjs +0 -10
- package/esm2022/entities/src/updaters/remove-entity.mjs +0 -10
- package/esm2022/entities/src/updaters/set-all-entities.mjs +0 -14
- package/esm2022/entities/src/updaters/set-entities.mjs +0 -11
- package/esm2022/entities/src/updaters/set-entity.mjs +0 -11
- package/esm2022/entities/src/updaters/update-all-entities.mjs +0 -11
- package/esm2022/entities/src/updaters/update-entities.mjs +0 -12
- package/esm2022/entities/src/updaters/update-entity.mjs +0 -11
- package/esm2022/entities/src/with-entities.mjs +0 -17
- package/esm2022/index.mjs +0 -2
- package/esm2022/ngrx-signals.mjs +0 -5
- package/esm2022/rxjs-interop/index.mjs +0 -2
- package/esm2022/rxjs-interop/ngrx-signals-rxjs-interop.mjs +0 -5
- package/esm2022/rxjs-interop/src/index.mjs +0 -2
- package/esm2022/rxjs-interop/src/rx-method.mjs +0 -49
- package/esm2022/src/deep-computed.mjs +0 -6
- package/esm2022/src/deep-signal.mjs +0 -25
- package/esm2022/src/index.mjs +0 -10
- package/esm2022/src/signal-state.mjs +0 -12
- package/esm2022/src/signal-store-assertions.mjs +0 -15
- package/esm2022/src/signal-store-feature.mjs +0 -10
- package/esm2022/src/signal-store-models.mjs +0 -2
- package/esm2022/src/signal-store.mjs +0 -45
- package/esm2022/src/state-source.mjs +0 -44
- package/esm2022/src/ts-helpers.mjs +0 -2
- package/esm2022/src/with-computed.mjs +0 -15
- package/esm2022/src/with-hooks.mjs +0 -34
- package/esm2022/src/with-methods.mjs +0 -18
- package/esm2022/src/with-state.mjs +0 -24
package/entities/src/index.d.ts
CHANGED
|
@@ -10,5 +10,5 @@ export { updateEntity } from './updaters/update-entity';
|
|
|
10
10
|
export { updateEntities } from './updaters/update-entities';
|
|
11
11
|
export { updateAllEntities } from './updaters/update-all-entities';
|
|
12
12
|
export { entityConfig } from './entity-config';
|
|
13
|
-
export {
|
|
13
|
+
export { EntityId, EntityMap, EntityProps, EntityState, NamedEntityProps, NamedEntityState, SelectEntityId, } from './models';
|
|
14
14
|
export { withEntities } from './with-entities';
|
package/entities/src/models.d.ts
CHANGED
|
@@ -8,11 +8,11 @@ export type EntityState<Entity> = {
|
|
|
8
8
|
export type NamedEntityState<Entity, Collection extends string> = {
|
|
9
9
|
[K in keyof EntityState<Entity> as `${Collection}${Capitalize<K>}`]: EntityState<Entity>[K];
|
|
10
10
|
};
|
|
11
|
-
export type
|
|
11
|
+
export type EntityProps<Entity> = {
|
|
12
12
|
entities: Signal<Entity[]>;
|
|
13
13
|
};
|
|
14
|
-
export type
|
|
15
|
-
[K in keyof
|
|
14
|
+
export type NamedEntityProps<Entity, Collection extends string> = {
|
|
15
|
+
[K in keyof EntityProps<Entity> as `${Collection}${Capitalize<K>}`]: EntityProps<Entity>[K];
|
|
16
16
|
};
|
|
17
17
|
export type SelectEntityId<Entity> = (entity: Entity) => EntityId;
|
|
18
18
|
export type EntityPredicate<Entity> = (entity: Entity) => boolean;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { EmptyFeatureResult, SignalStoreFeature } from '@ngrx/signals';
|
|
2
|
-
import {
|
|
2
|
+
import { EntityProps, EntityState, NamedEntityProps, NamedEntityState } from './models';
|
|
3
3
|
export declare function withEntities<Entity>(): SignalStoreFeature<EmptyFeatureResult, {
|
|
4
4
|
state: EntityState<Entity>;
|
|
5
|
-
|
|
5
|
+
props: EntityProps<Entity>;
|
|
6
6
|
methods: {};
|
|
7
7
|
}>;
|
|
8
8
|
export declare function withEntities<Entity, Collection extends string>(config: {
|
|
@@ -10,13 +10,13 @@ export declare function withEntities<Entity, Collection extends string>(config:
|
|
|
10
10
|
collection: Collection;
|
|
11
11
|
}): SignalStoreFeature<EmptyFeatureResult, {
|
|
12
12
|
state: NamedEntityState<Entity, Collection>;
|
|
13
|
-
|
|
13
|
+
props: NamedEntityProps<Entity, Collection>;
|
|
14
14
|
methods: {};
|
|
15
15
|
}>;
|
|
16
16
|
export declare function withEntities<Entity>(config: {
|
|
17
17
|
entity: Entity;
|
|
18
18
|
}): SignalStoreFeature<EmptyFeatureResult, {
|
|
19
19
|
state: EntityState<Entity>;
|
|
20
|
-
|
|
20
|
+
props: EntityProps<Entity>;
|
|
21
21
|
methods: {};
|
|
22
22
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngrx-signals-entities.mjs","sources":["../../../../modules/signals/entities/src/models.ts","../../../../modules/signals/entities/src/helpers.ts","../../../../modules/signals/entities/src/updaters/add-entity.ts","../../../../modules/signals/entities/src/updaters/add-entities.ts","../../../../modules/signals/entities/src/updaters/remove-entity.ts","../../../../modules/signals/entities/src/updaters/remove-entities.ts","../../../../modules/signals/entities/src/updaters/remove-all-entities.ts","../../../../modules/signals/entities/src/updaters/set-entity.ts","../../../../modules/signals/entities/src/updaters/set-entities.ts","../../../../modules/signals/entities/src/updaters/set-all-entities.ts","../../../../modules/signals/entities/src/updaters/update-entity.ts","../../../../modules/signals/entities/src/updaters/update-entities.ts","../../../../modules/signals/entities/src/updaters/update-all-entities.ts","../../../../modules/signals/entities/src/entity-config.ts","../../../../modules/signals/entities/src/with-entities.ts","../../../../modules/signals/entities/ngrx-signals-entities.ts"],"sourcesContent":["import { Signal } from '@angular/core';\n\nexport type EntityId = string | number;\n\nexport type EntityMap<Entity> = Record<EntityId, Entity>;\n\nexport type EntityState<Entity> = {\n entityMap: EntityMap<Entity>;\n ids: EntityId[];\n};\n\nexport type NamedEntityState<Entity, Collection extends string> = {\n [K in keyof EntityState<Entity> as `${Collection}${Capitalize<K>}`]: EntityState<Entity>[K];\n};\n\nexport type EntityComputed<Entity> = {\n entities: Signal<Entity[]>;\n};\n\nexport type NamedEntityComputed<Entity, Collection extends string> = {\n [K in keyof EntityComputed<Entity> as `${Collection}${Capitalize<K>}`]: EntityComputed<Entity>[K];\n};\n\nexport type SelectEntityId<Entity> = (entity: Entity) => EntityId;\n\nexport type EntityPredicate<Entity> = (entity: Entity) => boolean;\n\nexport type EntityChanges<Entity> =\n | Partial<Entity>\n | ((entity: Entity) => Partial<Entity>);\n\nexport enum DidMutate {\n None,\n Entities,\n Both,\n}\n","import {\n DidMutate,\n EntityChanges,\n EntityId,\n EntityPredicate,\n EntityState,\n SelectEntityId,\n} from './models';\n\ndeclare const ngDevMode: unknown;\nconst defaultSelectId: SelectEntityId<{ id: EntityId }> = (entity) => entity.id;\n\nexport function getEntityIdSelector(config?: {\n selectId?: SelectEntityId<any>;\n}): SelectEntityId<any> {\n return config?.selectId ?? defaultSelectId;\n}\n\nexport function getEntityStateKeys(config?: { collection?: string }): {\n entityMapKey: string;\n idsKey: string;\n entitiesKey: string;\n} {\n const collection = config?.collection;\n const entityMapKey =\n collection === undefined ? 'entityMap' : `${collection}EntityMap`;\n const idsKey = collection === undefined ? 'ids' : `${collection}Ids`;\n const entitiesKey =\n collection === undefined ? 'entities' : `${collection}Entities`;\n\n return { entityMapKey, idsKey, entitiesKey };\n}\n\nexport function cloneEntityState(\n state: Record<string, any>,\n stateKeys: {\n entityMapKey: string;\n idsKey: string;\n }\n): EntityState<any> {\n return {\n entityMap: { ...state[stateKeys.entityMapKey] },\n ids: [...state[stateKeys.idsKey]],\n };\n}\n\nexport function getEntityUpdaterResult(\n state: EntityState<any>,\n stateKeys: {\n entityMapKey: string;\n idsKey: string;\n },\n didMutate: DidMutate\n): Record<string, any> {\n switch (didMutate) {\n case DidMutate.Both: {\n return {\n [stateKeys.entityMapKey]: state.entityMap,\n [stateKeys.idsKey]: state.ids,\n };\n }\n case DidMutate.Entities: {\n return { [stateKeys.entityMapKey]: state.entityMap };\n }\n default: {\n return {};\n }\n }\n}\n\nexport function addEntityMutably(\n state: EntityState<any>,\n entity: any,\n selectId: SelectEntityId<any>\n): DidMutate {\n const id = selectId(entity);\n\n if (state.entityMap[id]) {\n return DidMutate.None;\n }\n\n state.entityMap[id] = entity;\n state.ids.push(id);\n\n return DidMutate.Both;\n}\n\nexport function addEntitiesMutably(\n state: EntityState<any>,\n entities: any[],\n selectId: SelectEntityId<any>\n): DidMutate {\n let didMutate = DidMutate.None;\n\n for (const entity of entities) {\n const result = addEntityMutably(state, entity, selectId);\n\n if (result === DidMutate.Both) {\n didMutate = result;\n }\n }\n\n return didMutate;\n}\n\nexport function setEntityMutably(\n state: EntityState<any>,\n entity: any,\n selectId: SelectEntityId<any>\n): DidMutate {\n const id = selectId(entity);\n\n if (state.entityMap[id]) {\n state.entityMap[id] = entity;\n return DidMutate.Entities;\n }\n\n state.entityMap[id] = entity;\n state.ids.push(id);\n\n return DidMutate.Both;\n}\n\nexport function setEntitiesMutably(\n state: EntityState<any>,\n entities: any[],\n selectId: SelectEntityId<any>\n): DidMutate {\n let didMutate = DidMutate.None;\n\n for (const entity of entities) {\n const result = setEntityMutably(state, entity, selectId);\n\n if (didMutate === DidMutate.Both) {\n continue;\n }\n\n didMutate = result;\n }\n\n return didMutate;\n}\n\nexport function removeEntitiesMutably(\n state: EntityState<any>,\n idsOrPredicate: EntityId[] | EntityPredicate<any>\n): DidMutate {\n const ids = Array.isArray(idsOrPredicate)\n ? idsOrPredicate\n : state.ids.filter((id) => idsOrPredicate(state.entityMap[id]));\n let didMutate = DidMutate.None;\n\n for (const id of ids) {\n if (state.entityMap[id]) {\n delete state.entityMap[id];\n didMutate = DidMutate.Both;\n }\n }\n\n if (didMutate === DidMutate.Both) {\n state.ids = state.ids.filter((id) => id in state.entityMap);\n }\n\n return didMutate;\n}\n\nexport function updateEntitiesMutably(\n state: EntityState<any>,\n idsOrPredicate: EntityId[] | EntityPredicate<any>,\n changes: EntityChanges<any>,\n selectId: SelectEntityId<any>\n): DidMutate {\n const ids = Array.isArray(idsOrPredicate)\n ? idsOrPredicate\n : state.ids.filter((id) => idsOrPredicate(state.entityMap[id]));\n let newIds: Record<EntityId, EntityId> | undefined = undefined;\n let didMutate = DidMutate.None;\n\n for (const id of ids) {\n const entity = state.entityMap[id];\n\n if (entity) {\n const changesRecord =\n typeof changes === 'function' ? changes(entity) : changes;\n state.entityMap[id] = { ...entity, ...changesRecord };\n didMutate = DidMutate.Entities;\n\n const newId = selectId(state.entityMap[id]);\n if (newId !== id) {\n state.entityMap[newId] = state.entityMap[id];\n delete state.entityMap[id];\n\n newIds = newIds || {};\n newIds[id] = newId;\n }\n }\n }\n\n if (newIds) {\n state.ids = state.ids.map((id) => newIds[id] ?? id);\n didMutate = DidMutate.Both;\n }\n\n if (ngDevMode && state.ids.length !== Object.keys(state.entityMap).length) {\n console.warn(\n '@ngrx/signals/entities: Entities with IDs:',\n ids,\n 'are not updated correctly.',\n 'Make sure to apply valid changes when using `updateEntity`,',\n '`updateEntities`, and `updateAllEntities` updaters.'\n );\n }\n\n return didMutate;\n}\n","import { PartialStateUpdater } from '@ngrx/signals';\nimport {\n EntityId,\n EntityState,\n NamedEntityState,\n SelectEntityId,\n} from '../models';\nimport {\n addEntityMutably,\n cloneEntityState,\n getEntityIdSelector,\n getEntityStateKeys,\n getEntityUpdaterResult,\n} from '../helpers';\n\nexport function addEntity<Entity extends { id: EntityId }>(\n entity: Entity\n): PartialStateUpdater<EntityState<Entity>>;\nexport function addEntity<Entity, Collection extends string>(\n entity: Entity,\n config: { collection: Collection; selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<NamedEntityState<Entity, Collection>>;\nexport function addEntity<\n Entity extends { id: EntityId },\n Collection extends string\n>(\n entity: Entity,\n config: { collection: Collection }\n): PartialStateUpdater<NamedEntityState<Entity, Collection>>;\nexport function addEntity<Entity>(\n entity: Entity,\n config: { selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<EntityState<Entity>>;\nexport function addEntity(\n entity: any,\n config?: { collection?: string; selectId?: SelectEntityId<any> }\n): PartialStateUpdater<EntityState<any> | NamedEntityState<any, string>> {\n const selectId = getEntityIdSelector(config);\n const stateKeys = getEntityStateKeys(config);\n\n return (state) => {\n const clonedState = cloneEntityState(state, stateKeys);\n const didMutate = addEntityMutably(clonedState, entity, selectId);\n\n return getEntityUpdaterResult(clonedState, stateKeys, didMutate);\n };\n}\n","import { PartialStateUpdater } from '@ngrx/signals';\nimport {\n EntityId,\n EntityState,\n NamedEntityState,\n SelectEntityId,\n} from '../models';\nimport {\n addEntitiesMutably,\n cloneEntityState,\n getEntityIdSelector,\n getEntityStateKeys,\n getEntityUpdaterResult,\n} from '../helpers';\n\nexport function addEntities<Entity extends { id: EntityId }>(\n entities: Entity[]\n): PartialStateUpdater<EntityState<Entity>>;\nexport function addEntities<Entity, Collection extends string>(\n entities: Entity[],\n config: { collection: Collection; selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<NamedEntityState<Entity, Collection>>;\nexport function addEntities<\n Entity extends { id: EntityId },\n Collection extends string\n>(\n entities: Entity[],\n config: { collection: Collection }\n): PartialStateUpdater<NamedEntityState<Entity, Collection>>;\nexport function addEntities<Entity>(\n entities: Entity[],\n config: { selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<EntityState<Entity>>;\nexport function addEntities(\n entities: any[],\n config?: { collection?: string; selectId?: SelectEntityId<any> }\n): PartialStateUpdater<EntityState<any> | NamedEntityState<any, string>> {\n const selectId = getEntityIdSelector(config);\n const stateKeys = getEntityStateKeys(config);\n\n return (state) => {\n const clonedState = cloneEntityState(state, stateKeys);\n const didMutate = addEntitiesMutably(clonedState, entities, selectId);\n\n return getEntityUpdaterResult(clonedState, stateKeys, didMutate);\n };\n}\n","import { PartialStateUpdater } from '@ngrx/signals';\nimport { EntityId, EntityState, NamedEntityState } from '../models';\nimport {\n cloneEntityState,\n getEntityStateKeys,\n getEntityUpdaterResult,\n removeEntitiesMutably,\n} from '../helpers';\n\nexport function removeEntity(\n id: EntityId\n): PartialStateUpdater<EntityState<any>>;\nexport function removeEntity<Collection extends string>(\n id: EntityId,\n config: { collection: Collection }\n): PartialStateUpdater<NamedEntityState<any, Collection>>;\nexport function removeEntity(\n id: EntityId,\n config?: { collection?: string }\n): PartialStateUpdater<EntityState<any> | NamedEntityState<any, string>> {\n const stateKeys = getEntityStateKeys(config);\n\n return (state) => {\n const clonedState = cloneEntityState(state, stateKeys);\n const didMutate = removeEntitiesMutably(clonedState, [id]);\n\n return getEntityUpdaterResult(clonedState, stateKeys, didMutate);\n };\n}\n","import { PartialStateUpdater } from '@ngrx/signals';\nimport {\n EntityId,\n EntityPredicate,\n EntityState,\n NamedEntityState,\n} from '../models';\nimport {\n cloneEntityState,\n getEntityStateKeys,\n getEntityUpdaterResult,\n removeEntitiesMutably,\n} from '../helpers';\n\nexport function removeEntities(\n ids: EntityId[]\n): PartialStateUpdater<EntityState<any>>;\nexport function removeEntities<Entity>(\n predicate: EntityPredicate<Entity>\n): PartialStateUpdater<EntityState<Entity>>;\nexport function removeEntities<Collection extends string>(\n ids: EntityId[],\n config: { collection: Collection }\n): PartialStateUpdater<NamedEntityState<any, Collection>>;\nexport function removeEntities<\n Collection extends string,\n State extends NamedEntityState<any, Collection>,\n Entity = State extends NamedEntityState<infer E, Collection> ? E : never\n>(\n predicate: EntityPredicate<Entity>,\n config: { collection: Collection }\n): PartialStateUpdater<State>;\nexport function removeEntities(\n idsOrPredicate: EntityId[] | EntityPredicate<any>,\n config?: { collection?: string }\n): PartialStateUpdater<EntityState<any> | NamedEntityState<any, string>> {\n const stateKeys = getEntityStateKeys(config);\n\n return (state) => {\n const clonedState = cloneEntityState(state, stateKeys);\n const didMutate = removeEntitiesMutably(clonedState, idsOrPredicate);\n\n return getEntityUpdaterResult(clonedState, stateKeys, didMutate);\n };\n}\n","import { PartialStateUpdater } from '@ngrx/signals';\nimport { EntityState, NamedEntityState } from '../models';\nimport { getEntityStateKeys } from '../helpers';\n\nexport function removeAllEntities(): PartialStateUpdater<EntityState<any>>;\nexport function removeAllEntities<Collection extends string>(config: {\n collection: Collection;\n}): PartialStateUpdater<NamedEntityState<any, Collection>>;\nexport function removeAllEntities(config?: {\n collection?: string;\n}): PartialStateUpdater<EntityState<any> | NamedEntityState<any, string>> {\n const stateKeys = getEntityStateKeys(config);\n\n return () => ({\n [stateKeys.entityMapKey]: {},\n [stateKeys.idsKey]: [],\n });\n}\n","import { PartialStateUpdater } from '@ngrx/signals';\nimport {\n EntityId,\n EntityState,\n NamedEntityState,\n SelectEntityId,\n} from '../models';\nimport {\n cloneEntityState,\n getEntityIdSelector,\n getEntityStateKeys,\n getEntityUpdaterResult,\n setEntityMutably,\n} from '../helpers';\n\nexport function setEntity<Entity extends { id: EntityId }>(\n entity: Entity\n): PartialStateUpdater<EntityState<Entity>>;\nexport function setEntity<Entity, Collection extends string>(\n entity: Entity,\n config: { collection: Collection; selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<NamedEntityState<Entity, Collection>>;\nexport function setEntity<\n Entity extends { id: EntityId },\n Collection extends string\n>(\n entity: Entity,\n config: { collection: Collection }\n): PartialStateUpdater<NamedEntityState<Entity, Collection>>;\nexport function setEntity<Entity>(\n entity: Entity,\n config: { selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<EntityState<Entity>>;\nexport function setEntity(\n entity: any,\n config?: { collection?: string; selectId?: SelectEntityId<any> }\n): PartialStateUpdater<EntityState<any> | NamedEntityState<any, string>> {\n const selectId = getEntityIdSelector(config);\n const stateKeys = getEntityStateKeys(config);\n\n return (state) => {\n const clonedState = cloneEntityState(state, stateKeys);\n const didMutate = setEntityMutably(clonedState, entity, selectId);\n\n return getEntityUpdaterResult(clonedState, stateKeys, didMutate);\n };\n}\n","import { PartialStateUpdater } from '@ngrx/signals';\nimport {\n EntityId,\n EntityState,\n NamedEntityState,\n SelectEntityId,\n} from '../models';\nimport {\n cloneEntityState,\n getEntityIdSelector,\n getEntityStateKeys,\n getEntityUpdaterResult,\n setEntitiesMutably,\n} from '../helpers';\n\nexport function setEntities<Entity extends { id: EntityId }>(\n entities: Entity[]\n): PartialStateUpdater<EntityState<Entity>>;\nexport function setEntities<Entity, Collection extends string>(\n entities: Entity[],\n config: { collection: Collection; selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<NamedEntityState<Entity, Collection>>;\nexport function setEntities<\n Entity extends { id: EntityId },\n Collection extends string\n>(\n entities: Entity[],\n config: { collection: Collection }\n): PartialStateUpdater<NamedEntityState<Entity, Collection>>;\nexport function setEntities<Entity>(\n entities: Entity[],\n config: { selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<EntityState<Entity>>;\nexport function setEntities(\n entities: any[],\n config?: { collection?: string; selectId?: SelectEntityId<any> }\n): PartialStateUpdater<EntityState<any> | NamedEntityState<any, string>> {\n const selectId = getEntityIdSelector(config);\n const stateKeys = getEntityStateKeys(config);\n\n return (state) => {\n const clonedState = cloneEntityState(state, stateKeys);\n const didMutate = setEntitiesMutably(clonedState, entities, selectId);\n\n return getEntityUpdaterResult(clonedState, stateKeys, didMutate);\n };\n}\n","import { PartialStateUpdater } from '@ngrx/signals';\nimport {\n EntityId,\n EntityState,\n NamedEntityState,\n SelectEntityId,\n} from '../models';\nimport {\n getEntityIdSelector,\n getEntityStateKeys,\n setEntitiesMutably,\n} from '../helpers';\n\nexport function setAllEntities<Entity extends { id: EntityId }>(\n entities: Entity[]\n): PartialStateUpdater<EntityState<Entity>>;\nexport function setAllEntities<Entity, Collection extends string>(\n entities: Entity[],\n config: { collection: Collection; selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<NamedEntityState<Entity, Collection>>;\nexport function setAllEntities<\n Entity extends { id: EntityId },\n Collection extends string\n>(\n entities: Entity[],\n config: { collection: Collection }\n): PartialStateUpdater<NamedEntityState<Entity, Collection>>;\nexport function setAllEntities<Entity>(\n entities: Entity[],\n config: { selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<EntityState<Entity>>;\nexport function setAllEntities(\n entities: any[],\n config?: { collection?: string; selectId?: SelectEntityId<any> }\n): PartialStateUpdater<EntityState<any> | NamedEntityState<any, string>> {\n const selectId = getEntityIdSelector(config);\n const stateKeys = getEntityStateKeys(config);\n\n return () => {\n const state: EntityState<any> = { entityMap: {}, ids: [] };\n setEntitiesMutably(state, entities, selectId);\n\n return {\n [stateKeys.entityMapKey]: state.entityMap,\n [stateKeys.idsKey]: state.ids,\n };\n };\n}\n","import { PartialStateUpdater } from '@ngrx/signals';\nimport {\n EntityChanges,\n EntityId,\n EntityState,\n NamedEntityState,\n SelectEntityId,\n} from '../models';\nimport {\n cloneEntityState,\n getEntityIdSelector,\n getEntityStateKeys,\n getEntityUpdaterResult,\n updateEntitiesMutably,\n} from '../helpers';\n\nexport function updateEntity<\n Collection extends string,\n State extends NamedEntityState<any, Collection>,\n Entity = State extends NamedEntityState<infer E, Collection> ? E : never\n>(\n update: {\n id: EntityId;\n changes: EntityChanges<NoInfer<Entity>>;\n },\n config: {\n collection: Collection;\n selectId: SelectEntityId<NoInfer<Entity>>;\n }\n): PartialStateUpdater<State>;\nexport function updateEntity<\n Collection extends string,\n State extends NamedEntityState<any, Collection>,\n Entity = State extends NamedEntityState<\n infer E extends { id: EntityId },\n Collection\n >\n ? E\n : never\n>(\n update: {\n id: EntityId;\n changes: EntityChanges<NoInfer<Entity>>;\n },\n config: { collection: Collection }\n): PartialStateUpdater<State>;\nexport function updateEntity<Entity>(\n update: {\n id: EntityId;\n changes: EntityChanges<NoInfer<Entity>>;\n },\n config: { selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<EntityState<Entity>>;\nexport function updateEntity<Entity extends { id: EntityId }>(update: {\n id: EntityId;\n changes: EntityChanges<NoInfer<Entity>>;\n}): PartialStateUpdater<EntityState<Entity>>;\nexport function updateEntity(\n update: {\n id: EntityId;\n changes: EntityChanges<any>;\n },\n config?: { collection?: string; selectId?: SelectEntityId<any> }\n): PartialStateUpdater<EntityState<any> | NamedEntityState<any, string>> {\n const selectId = getEntityIdSelector(config);\n const stateKeys = getEntityStateKeys(config);\n\n return (state) => {\n const clonedState = cloneEntityState(state, stateKeys);\n const didMutate = updateEntitiesMutably(\n clonedState,\n [update.id],\n update.changes,\n selectId\n );\n\n return getEntityUpdaterResult(clonedState, stateKeys, didMutate);\n };\n}\n","import { PartialStateUpdater } from '@ngrx/signals';\nimport {\n EntityChanges,\n EntityId,\n EntityPredicate,\n EntityState,\n NamedEntityState,\n SelectEntityId,\n} from '../models';\nimport {\n cloneEntityState,\n getEntityIdSelector,\n getEntityStateKeys,\n getEntityUpdaterResult,\n updateEntitiesMutably,\n} from '../helpers';\n\nexport function updateEntities<\n Collection extends string,\n State extends NamedEntityState<any, Collection>,\n Entity = State extends NamedEntityState<infer E, Collection> ? E : never\n>(\n update: {\n ids: EntityId[];\n changes: EntityChanges<NoInfer<Entity>>;\n },\n config: {\n collection: Collection;\n selectId: SelectEntityId<NoInfer<Entity>>;\n }\n): PartialStateUpdater<State>;\nexport function updateEntities<\n Collection extends string,\n State extends NamedEntityState<any, Collection>,\n Entity = State extends NamedEntityState<infer E, Collection> ? E : never\n>(\n update: {\n predicate: EntityPredicate<Entity>;\n changes: EntityChanges<NoInfer<Entity>>;\n },\n config: {\n collection: Collection;\n selectId: SelectEntityId<NoInfer<Entity>>;\n }\n): PartialStateUpdater<State>;\nexport function updateEntities<\n Collection extends string,\n State extends NamedEntityState<any, Collection>,\n Entity = State extends NamedEntityState<\n infer E extends { id: EntityId },\n Collection\n >\n ? E\n : never\n>(\n update: {\n ids: EntityId[];\n changes: EntityChanges<NoInfer<Entity>>;\n },\n config: { collection: Collection }\n): PartialStateUpdater<State>;\nexport function updateEntities<\n Collection extends string,\n State extends NamedEntityState<any, Collection>,\n Entity = State extends NamedEntityState<\n infer E extends { id: EntityId },\n Collection\n >\n ? E\n : never\n>(\n update: {\n predicate: EntityPredicate<Entity>;\n changes: EntityChanges<NoInfer<Entity>>;\n },\n config: { collection: Collection }\n): PartialStateUpdater<State>;\nexport function updateEntities<Entity>(\n update: {\n ids: EntityId[];\n changes: EntityChanges<NoInfer<Entity>>;\n },\n config: { selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<EntityState<Entity>>;\nexport function updateEntities<Entity>(\n update: {\n predicate: EntityPredicate<Entity>;\n changes: EntityChanges<NoInfer<Entity>>;\n },\n config: { selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<EntityState<Entity>>;\nexport function updateEntities<Entity extends { id: EntityId }>(update: {\n ids: EntityId[];\n changes: EntityChanges<NoInfer<Entity>>;\n}): PartialStateUpdater<EntityState<Entity>>;\nexport function updateEntities<Entity extends { id: EntityId }>(update: {\n predicate: EntityPredicate<Entity>;\n changes: EntityChanges<NoInfer<Entity>>;\n}): PartialStateUpdater<EntityState<Entity>>;\nexport function updateEntities(\n update: ({ ids: EntityId[] } | { predicate: EntityPredicate<any> }) & {\n changes: EntityChanges<any>;\n },\n config?: { collection?: string; selectId?: SelectEntityId<any> }\n): PartialStateUpdater<EntityState<any> | NamedEntityState<any, string>> {\n const selectId = getEntityIdSelector(config);\n const stateKeys = getEntityStateKeys(config);\n const idsOrPredicate = 'ids' in update ? update.ids : update.predicate;\n\n return (state) => {\n const clonedState = cloneEntityState(state, stateKeys);\n const didMutate = updateEntitiesMutably(\n clonedState,\n idsOrPredicate,\n update.changes,\n selectId\n );\n\n return getEntityUpdaterResult(clonedState, stateKeys, didMutate);\n };\n}\n","import { PartialStateUpdater } from '@ngrx/signals';\nimport {\n EntityChanges,\n EntityId,\n EntityState,\n NamedEntityState,\n SelectEntityId,\n} from '../models';\nimport {\n cloneEntityState,\n getEntityIdSelector,\n getEntityStateKeys,\n getEntityUpdaterResult,\n updateEntitiesMutably,\n} from '../helpers';\n\nexport function updateAllEntities<\n Collection extends string,\n State extends NamedEntityState<any, Collection>,\n Entity = State extends NamedEntityState<infer E, Collection> ? E : never\n>(\n changes: EntityChanges<NoInfer<Entity>>,\n config: {\n collection: Collection;\n selectId: SelectEntityId<NoInfer<Entity>>;\n }\n): PartialStateUpdater<State>;\nexport function updateAllEntities<\n Collection extends string,\n State extends NamedEntityState<any, Collection>,\n Entity = State extends NamedEntityState<\n infer E extends { id: EntityId },\n Collection\n >\n ? E\n : never\n>(\n changes: EntityChanges<NoInfer<Entity>>,\n config: { collection: Collection }\n): PartialStateUpdater<State>;\nexport function updateAllEntities<Entity>(\n changes: EntityChanges<NoInfer<Entity>>,\n config: { selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<EntityState<Entity>>;\nexport function updateAllEntities<Entity extends { id: EntityId }>(\n changes: EntityChanges<NoInfer<Entity>>\n): PartialStateUpdater<EntityState<Entity>>;\nexport function updateAllEntities(\n changes: EntityChanges<any>,\n config?: { collection?: string; selectId?: SelectEntityId<any> }\n): PartialStateUpdater<EntityState<any> | NamedEntityState<any, string>> {\n const selectId = getEntityIdSelector(config);\n const stateKeys = getEntityStateKeys(config);\n\n return (state) => {\n const clonedState = cloneEntityState(state, stateKeys);\n const didMutate = updateEntitiesMutably(\n clonedState,\n (state as Record<string, any>)[stateKeys.idsKey],\n changes,\n selectId\n );\n\n return getEntityUpdaterResult(clonedState, stateKeys, didMutate);\n };\n}\n","import { SelectEntityId } from './models';\n\nexport function entityConfig<Entity, Collection extends string>(config: {\n entity: Entity;\n collection: Collection;\n selectId: SelectEntityId<NoInfer<Entity>>;\n}): typeof config;\nexport function entityConfig<Entity>(config: {\n entity: Entity;\n selectId: SelectEntityId<NoInfer<Entity>>;\n}): typeof config;\nexport function entityConfig<Entity, Collection extends string>(config: {\n entity: Entity;\n collection: Collection;\n}): typeof config;\nexport function entityConfig<Entity>(config: { entity: Entity }): typeof config;\nexport function entityConfig<Entity>(config: {\n entity: Entity;\n collection?: string;\n selectId?: SelectEntityId<Entity>;\n}): typeof config {\n return config;\n}\n","import { computed, Signal } from '@angular/core';\nimport {\n EmptyFeatureResult,\n SignalStoreFeature,\n signalStoreFeature,\n withComputed,\n withState,\n} from '@ngrx/signals';\nimport {\n EntityComputed,\n EntityId,\n EntityMap,\n EntityState,\n NamedEntityComputed,\n NamedEntityState,\n} from './models';\nimport { getEntityStateKeys } from './helpers';\n\nexport function withEntities<Entity>(): SignalStoreFeature<\n EmptyFeatureResult,\n {\n state: EntityState<Entity>;\n computed: EntityComputed<Entity>;\n methods: {};\n }\n>;\nexport function withEntities<Entity, Collection extends string>(config: {\n entity: Entity;\n collection: Collection;\n}): SignalStoreFeature<\n EmptyFeatureResult,\n {\n state: NamedEntityState<Entity, Collection>;\n computed: NamedEntityComputed<Entity, Collection>;\n methods: {};\n }\n>;\nexport function withEntities<Entity>(config: {\n entity: Entity;\n}): SignalStoreFeature<\n EmptyFeatureResult,\n {\n state: EntityState<Entity>;\n computed: EntityComputed<Entity>;\n methods: {};\n }\n>;\nexport function withEntities<Entity>(config?: {\n entity: Entity;\n collection?: string;\n}): SignalStoreFeature {\n const { entityMapKey, idsKey, entitiesKey } = getEntityStateKeys(config);\n\n return signalStoreFeature(\n withState({\n [entityMapKey]: {},\n [idsKey]: [],\n }),\n withComputed((store: Record<string, Signal<unknown>>) => ({\n [entitiesKey]: computed(() => {\n const entityMap = store[entityMapKey]() as EntityMap<Entity>;\n const ids = store[idsKey]() as EntityId[];\n\n return ids.map((id) => entityMap[id]);\n }),\n }))\n );\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;AA+BA,IAAY,SAIX,CAAA;AAJD,CAAA,UAAY,SAAS,EAAA;AACnB,IAAA,SAAA,CAAA,SAAA,CAAA,MAAA,CAAA,GAAA,CAAA,CAAA,GAAA,MAAI,CAAA;AACJ,IAAA,SAAA,CAAA,SAAA,CAAA,UAAA,CAAA,GAAA,CAAA,CAAA,GAAA,UAAQ,CAAA;AACR,IAAA,SAAA,CAAA,SAAA,CAAA,MAAA,CAAA,GAAA,CAAA,CAAA,GAAA,MAAI,CAAA;AACN,CAAC,EAJW,SAAS,KAAT,SAAS,GAIpB,EAAA,CAAA,CAAA;;ACzBD,MAAM,eAAe,GAAqC,CAAC,MAAM,KAAK,MAAM,CAAC,EAAE,CAAC;AAE1E,SAAU,mBAAmB,CAAC,MAEnC,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/models.ts","../../../../modules/signals/entities/src/helpers.ts","../../../../modules/signals/entities/src/updaters/add-entity.ts","../../../../modules/signals/entities/src/updaters/add-entities.ts","../../../../modules/signals/entities/src/updaters/remove-entity.ts","../../../../modules/signals/entities/src/updaters/remove-entities.ts","../../../../modules/signals/entities/src/updaters/remove-all-entities.ts","../../../../modules/signals/entities/src/updaters/set-entity.ts","../../../../modules/signals/entities/src/updaters/set-entities.ts","../../../../modules/signals/entities/src/updaters/set-all-entities.ts","../../../../modules/signals/entities/src/updaters/update-entity.ts","../../../../modules/signals/entities/src/updaters/update-entities.ts","../../../../modules/signals/entities/src/updaters/update-all-entities.ts","../../../../modules/signals/entities/src/entity-config.ts","../../../../modules/signals/entities/src/with-entities.ts","../../../../modules/signals/entities/ngrx-signals-entities.ts"],"sourcesContent":["import { Signal } from '@angular/core';\n\nexport type EntityId = string | number;\n\nexport type EntityMap<Entity> = Record<EntityId, Entity>;\n\nexport type EntityState<Entity> = {\n entityMap: EntityMap<Entity>;\n ids: EntityId[];\n};\n\nexport type NamedEntityState<Entity, Collection extends string> = {\n [K in keyof EntityState<Entity> as `${Collection}${Capitalize<K>}`]: EntityState<Entity>[K];\n};\n\nexport type EntityProps<Entity> = {\n entities: Signal<Entity[]>;\n};\n\nexport type NamedEntityProps<Entity, Collection extends string> = {\n [K in keyof EntityProps<Entity> as `${Collection}${Capitalize<K>}`]: EntityProps<Entity>[K];\n};\n\nexport type SelectEntityId<Entity> = (entity: Entity) => EntityId;\n\nexport type EntityPredicate<Entity> = (entity: Entity) => boolean;\n\nexport type EntityChanges<Entity> =\n | Partial<Entity>\n | ((entity: Entity) => Partial<Entity>);\n\nexport enum DidMutate {\n None,\n Entities,\n Both,\n}\n","import {\n DidMutate,\n EntityChanges,\n EntityId,\n EntityPredicate,\n EntityState,\n SelectEntityId,\n} from './models';\n\ndeclare const ngDevMode: unknown;\nconst defaultSelectId: SelectEntityId<{ id: EntityId }> = (entity) => entity.id;\n\nexport function getEntityIdSelector(config?: {\n selectId?: SelectEntityId<any>;\n}): SelectEntityId<any> {\n return config?.selectId ?? defaultSelectId;\n}\n\nexport function getEntityStateKeys(config?: { collection?: string }): {\n entityMapKey: string;\n idsKey: string;\n entitiesKey: string;\n} {\n const collection = config?.collection;\n const entityMapKey =\n collection === undefined ? 'entityMap' : `${collection}EntityMap`;\n const idsKey = collection === undefined ? 'ids' : `${collection}Ids`;\n const entitiesKey =\n collection === undefined ? 'entities' : `${collection}Entities`;\n\n return { entityMapKey, idsKey, entitiesKey };\n}\n\nexport function cloneEntityState(\n state: Record<string, any>,\n stateKeys: {\n entityMapKey: string;\n idsKey: string;\n }\n): EntityState<any> {\n return {\n entityMap: { ...state[stateKeys.entityMapKey] },\n ids: [...state[stateKeys.idsKey]],\n };\n}\n\nexport function getEntityUpdaterResult(\n state: EntityState<any>,\n stateKeys: {\n entityMapKey: string;\n idsKey: string;\n },\n didMutate: DidMutate\n): Record<string, any> {\n switch (didMutate) {\n case DidMutate.Both: {\n return {\n [stateKeys.entityMapKey]: state.entityMap,\n [stateKeys.idsKey]: state.ids,\n };\n }\n case DidMutate.Entities: {\n return { [stateKeys.entityMapKey]: state.entityMap };\n }\n default: {\n return {};\n }\n }\n}\n\nexport function addEntityMutably(\n state: EntityState<any>,\n entity: any,\n selectId: SelectEntityId<any>\n): DidMutate {\n const id = selectId(entity);\n\n if (state.entityMap[id]) {\n return DidMutate.None;\n }\n\n state.entityMap[id] = entity;\n state.ids.push(id);\n\n return DidMutate.Both;\n}\n\nexport function addEntitiesMutably(\n state: EntityState<any>,\n entities: any[],\n selectId: SelectEntityId<any>\n): DidMutate {\n let didMutate = DidMutate.None;\n\n for (const entity of entities) {\n const result = addEntityMutably(state, entity, selectId);\n\n if (result === DidMutate.Both) {\n didMutate = result;\n }\n }\n\n return didMutate;\n}\n\nexport function setEntityMutably(\n state: EntityState<any>,\n entity: any,\n selectId: SelectEntityId<any>\n): DidMutate {\n const id = selectId(entity);\n\n if (state.entityMap[id]) {\n state.entityMap[id] = entity;\n return DidMutate.Entities;\n }\n\n state.entityMap[id] = entity;\n state.ids.push(id);\n\n return DidMutate.Both;\n}\n\nexport function setEntitiesMutably(\n state: EntityState<any>,\n entities: any[],\n selectId: SelectEntityId<any>\n): DidMutate {\n let didMutate = DidMutate.None;\n\n for (const entity of entities) {\n const result = setEntityMutably(state, entity, selectId);\n\n if (didMutate === DidMutate.Both) {\n continue;\n }\n\n didMutate = result;\n }\n\n return didMutate;\n}\n\nexport function removeEntitiesMutably(\n state: EntityState<any>,\n idsOrPredicate: EntityId[] | EntityPredicate<any>\n): DidMutate {\n const ids = Array.isArray(idsOrPredicate)\n ? idsOrPredicate\n : state.ids.filter((id) => idsOrPredicate(state.entityMap[id]));\n let didMutate = DidMutate.None;\n\n for (const id of ids) {\n if (state.entityMap[id]) {\n delete state.entityMap[id];\n didMutate = DidMutate.Both;\n }\n }\n\n if (didMutate === DidMutate.Both) {\n state.ids = state.ids.filter((id) => id in state.entityMap);\n }\n\n return didMutate;\n}\n\nexport function updateEntitiesMutably(\n state: EntityState<any>,\n idsOrPredicate: EntityId[] | EntityPredicate<any>,\n changes: EntityChanges<any>,\n selectId: SelectEntityId<any>\n): DidMutate {\n const ids = Array.isArray(idsOrPredicate)\n ? idsOrPredicate\n : state.ids.filter((id) => idsOrPredicate(state.entityMap[id]));\n let newIds: Record<EntityId, EntityId> | undefined = undefined;\n let didMutate = DidMutate.None;\n\n for (const id of ids) {\n const entity = state.entityMap[id];\n\n if (entity) {\n const changesRecord =\n typeof changes === 'function' ? changes(entity) : changes;\n state.entityMap[id] = { ...entity, ...changesRecord };\n didMutate = DidMutate.Entities;\n\n const newId = selectId(state.entityMap[id]);\n if (newId !== id) {\n state.entityMap[newId] = state.entityMap[id];\n delete state.entityMap[id];\n\n newIds = newIds || {};\n newIds[id] = newId;\n }\n }\n }\n\n if (newIds) {\n state.ids = state.ids.map((id) => newIds[id] ?? id);\n didMutate = DidMutate.Both;\n }\n\n if (ngDevMode && state.ids.length !== Object.keys(state.entityMap).length) {\n console.warn(\n '@ngrx/signals/entities: Entities with IDs:',\n ids,\n 'are not updated correctly.',\n 'Make sure to apply valid changes when using `updateEntity`,',\n '`updateEntities`, and `updateAllEntities` updaters.'\n );\n }\n\n return didMutate;\n}\n","import { PartialStateUpdater } from '@ngrx/signals';\nimport {\n EntityId,\n EntityState,\n NamedEntityState,\n SelectEntityId,\n} from '../models';\nimport {\n addEntityMutably,\n cloneEntityState,\n getEntityIdSelector,\n getEntityStateKeys,\n getEntityUpdaterResult,\n} from '../helpers';\n\nexport function addEntity<Entity extends { id: EntityId }>(\n entity: Entity\n): PartialStateUpdater<EntityState<Entity>>;\nexport function addEntity<Entity, Collection extends string>(\n entity: Entity,\n config: { collection: Collection; selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<NamedEntityState<Entity, Collection>>;\nexport function addEntity<\n Entity extends { id: EntityId },\n Collection extends string\n>(\n entity: Entity,\n config: { collection: Collection }\n): PartialStateUpdater<NamedEntityState<Entity, Collection>>;\nexport function addEntity<Entity>(\n entity: Entity,\n config: { selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<EntityState<Entity>>;\nexport function addEntity(\n entity: any,\n config?: { collection?: string; selectId?: SelectEntityId<any> }\n): PartialStateUpdater<EntityState<any> | NamedEntityState<any, string>> {\n const selectId = getEntityIdSelector(config);\n const stateKeys = getEntityStateKeys(config);\n\n return (state) => {\n const clonedState = cloneEntityState(state, stateKeys);\n const didMutate = addEntityMutably(clonedState, entity, selectId);\n\n return getEntityUpdaterResult(clonedState, stateKeys, didMutate);\n };\n}\n","import { PartialStateUpdater } from '@ngrx/signals';\nimport {\n EntityId,\n EntityState,\n NamedEntityState,\n SelectEntityId,\n} from '../models';\nimport {\n addEntitiesMutably,\n cloneEntityState,\n getEntityIdSelector,\n getEntityStateKeys,\n getEntityUpdaterResult,\n} from '../helpers';\n\nexport function addEntities<Entity extends { id: EntityId }>(\n entities: Entity[]\n): PartialStateUpdater<EntityState<Entity>>;\nexport function addEntities<Entity, Collection extends string>(\n entities: Entity[],\n config: { collection: Collection; selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<NamedEntityState<Entity, Collection>>;\nexport function addEntities<\n Entity extends { id: EntityId },\n Collection extends string\n>(\n entities: Entity[],\n config: { collection: Collection }\n): PartialStateUpdater<NamedEntityState<Entity, Collection>>;\nexport function addEntities<Entity>(\n entities: Entity[],\n config: { selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<EntityState<Entity>>;\nexport function addEntities(\n entities: any[],\n config?: { collection?: string; selectId?: SelectEntityId<any> }\n): PartialStateUpdater<EntityState<any> | NamedEntityState<any, string>> {\n const selectId = getEntityIdSelector(config);\n const stateKeys = getEntityStateKeys(config);\n\n return (state) => {\n const clonedState = cloneEntityState(state, stateKeys);\n const didMutate = addEntitiesMutably(clonedState, entities, selectId);\n\n return getEntityUpdaterResult(clonedState, stateKeys, didMutate);\n };\n}\n","import { PartialStateUpdater } from '@ngrx/signals';\nimport { EntityId, EntityState, NamedEntityState } from '../models';\nimport {\n cloneEntityState,\n getEntityStateKeys,\n getEntityUpdaterResult,\n removeEntitiesMutably,\n} from '../helpers';\n\nexport function removeEntity(\n id: EntityId\n): PartialStateUpdater<EntityState<any>>;\nexport function removeEntity<Collection extends string>(\n id: EntityId,\n config: { collection: Collection }\n): PartialStateUpdater<NamedEntityState<any, Collection>>;\nexport function removeEntity(\n id: EntityId,\n config?: { collection?: string }\n): PartialStateUpdater<EntityState<any> | NamedEntityState<any, string>> {\n const stateKeys = getEntityStateKeys(config);\n\n return (state) => {\n const clonedState = cloneEntityState(state, stateKeys);\n const didMutate = removeEntitiesMutably(clonedState, [id]);\n\n return getEntityUpdaterResult(clonedState, stateKeys, didMutate);\n };\n}\n","import { PartialStateUpdater } from '@ngrx/signals';\nimport {\n EntityId,\n EntityPredicate,\n EntityState,\n NamedEntityState,\n} from '../models';\nimport {\n cloneEntityState,\n getEntityStateKeys,\n getEntityUpdaterResult,\n removeEntitiesMutably,\n} from '../helpers';\n\nexport function removeEntities(\n ids: EntityId[]\n): PartialStateUpdater<EntityState<any>>;\nexport function removeEntities<Entity>(\n predicate: EntityPredicate<Entity>\n): PartialStateUpdater<EntityState<Entity>>;\nexport function removeEntities<Collection extends string>(\n ids: EntityId[],\n config: { collection: Collection }\n): PartialStateUpdater<NamedEntityState<any, Collection>>;\nexport function removeEntities<\n Collection extends string,\n State extends NamedEntityState<any, Collection>,\n Entity = State extends NamedEntityState<infer E, Collection> ? E : never\n>(\n predicate: EntityPredicate<Entity>,\n config: { collection: Collection }\n): PartialStateUpdater<State>;\nexport function removeEntities(\n idsOrPredicate: EntityId[] | EntityPredicate<any>,\n config?: { collection?: string }\n): PartialStateUpdater<EntityState<any> | NamedEntityState<any, string>> {\n const stateKeys = getEntityStateKeys(config);\n\n return (state) => {\n const clonedState = cloneEntityState(state, stateKeys);\n const didMutate = removeEntitiesMutably(clonedState, idsOrPredicate);\n\n return getEntityUpdaterResult(clonedState, stateKeys, didMutate);\n };\n}\n","import { PartialStateUpdater } from '@ngrx/signals';\nimport { EntityState, NamedEntityState } from '../models';\nimport { getEntityStateKeys } from '../helpers';\n\nexport function removeAllEntities(): PartialStateUpdater<EntityState<any>>;\nexport function removeAllEntities<Collection extends string>(config: {\n collection: Collection;\n}): PartialStateUpdater<NamedEntityState<any, Collection>>;\nexport function removeAllEntities(config?: {\n collection?: string;\n}): PartialStateUpdater<EntityState<any> | NamedEntityState<any, string>> {\n const stateKeys = getEntityStateKeys(config);\n\n return () => ({\n [stateKeys.entityMapKey]: {},\n [stateKeys.idsKey]: [],\n });\n}\n","import { PartialStateUpdater } from '@ngrx/signals';\nimport {\n EntityId,\n EntityState,\n NamedEntityState,\n SelectEntityId,\n} from '../models';\nimport {\n cloneEntityState,\n getEntityIdSelector,\n getEntityStateKeys,\n getEntityUpdaterResult,\n setEntityMutably,\n} from '../helpers';\n\nexport function setEntity<Entity extends { id: EntityId }>(\n entity: Entity\n): PartialStateUpdater<EntityState<Entity>>;\nexport function setEntity<Entity, Collection extends string>(\n entity: Entity,\n config: { collection: Collection; selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<NamedEntityState<Entity, Collection>>;\nexport function setEntity<\n Entity extends { id: EntityId },\n Collection extends string\n>(\n entity: Entity,\n config: { collection: Collection }\n): PartialStateUpdater<NamedEntityState<Entity, Collection>>;\nexport function setEntity<Entity>(\n entity: Entity,\n config: { selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<EntityState<Entity>>;\nexport function setEntity(\n entity: any,\n config?: { collection?: string; selectId?: SelectEntityId<any> }\n): PartialStateUpdater<EntityState<any> | NamedEntityState<any, string>> {\n const selectId = getEntityIdSelector(config);\n const stateKeys = getEntityStateKeys(config);\n\n return (state) => {\n const clonedState = cloneEntityState(state, stateKeys);\n const didMutate = setEntityMutably(clonedState, entity, selectId);\n\n return getEntityUpdaterResult(clonedState, stateKeys, didMutate);\n };\n}\n","import { PartialStateUpdater } from '@ngrx/signals';\nimport {\n EntityId,\n EntityState,\n NamedEntityState,\n SelectEntityId,\n} from '../models';\nimport {\n cloneEntityState,\n getEntityIdSelector,\n getEntityStateKeys,\n getEntityUpdaterResult,\n setEntitiesMutably,\n} from '../helpers';\n\nexport function setEntities<Entity extends { id: EntityId }>(\n entities: Entity[]\n): PartialStateUpdater<EntityState<Entity>>;\nexport function setEntities<Entity, Collection extends string>(\n entities: Entity[],\n config: { collection: Collection; selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<NamedEntityState<Entity, Collection>>;\nexport function setEntities<\n Entity extends { id: EntityId },\n Collection extends string\n>(\n entities: Entity[],\n config: { collection: Collection }\n): PartialStateUpdater<NamedEntityState<Entity, Collection>>;\nexport function setEntities<Entity>(\n entities: Entity[],\n config: { selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<EntityState<Entity>>;\nexport function setEntities(\n entities: any[],\n config?: { collection?: string; selectId?: SelectEntityId<any> }\n): PartialStateUpdater<EntityState<any> | NamedEntityState<any, string>> {\n const selectId = getEntityIdSelector(config);\n const stateKeys = getEntityStateKeys(config);\n\n return (state) => {\n const clonedState = cloneEntityState(state, stateKeys);\n const didMutate = setEntitiesMutably(clonedState, entities, selectId);\n\n return getEntityUpdaterResult(clonedState, stateKeys, didMutate);\n };\n}\n","import { PartialStateUpdater } from '@ngrx/signals';\nimport {\n EntityId,\n EntityState,\n NamedEntityState,\n SelectEntityId,\n} from '../models';\nimport {\n getEntityIdSelector,\n getEntityStateKeys,\n setEntitiesMutably,\n} from '../helpers';\n\nexport function setAllEntities<Entity extends { id: EntityId }>(\n entities: Entity[]\n): PartialStateUpdater<EntityState<Entity>>;\nexport function setAllEntities<Entity, Collection extends string>(\n entities: Entity[],\n config: { collection: Collection; selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<NamedEntityState<Entity, Collection>>;\nexport function setAllEntities<\n Entity extends { id: EntityId },\n Collection extends string\n>(\n entities: Entity[],\n config: { collection: Collection }\n): PartialStateUpdater<NamedEntityState<Entity, Collection>>;\nexport function setAllEntities<Entity>(\n entities: Entity[],\n config: { selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<EntityState<Entity>>;\nexport function setAllEntities(\n entities: any[],\n config?: { collection?: string; selectId?: SelectEntityId<any> }\n): PartialStateUpdater<EntityState<any> | NamedEntityState<any, string>> {\n const selectId = getEntityIdSelector(config);\n const stateKeys = getEntityStateKeys(config);\n\n return () => {\n const state: EntityState<any> = { entityMap: {}, ids: [] };\n setEntitiesMutably(state, entities, selectId);\n\n return {\n [stateKeys.entityMapKey]: state.entityMap,\n [stateKeys.idsKey]: state.ids,\n };\n };\n}\n","import { PartialStateUpdater } from '@ngrx/signals';\nimport {\n EntityChanges,\n EntityId,\n EntityState,\n NamedEntityState,\n SelectEntityId,\n} from '../models';\nimport {\n cloneEntityState,\n getEntityIdSelector,\n getEntityStateKeys,\n getEntityUpdaterResult,\n updateEntitiesMutably,\n} from '../helpers';\n\nexport function updateEntity<\n Collection extends string,\n State extends NamedEntityState<any, Collection>,\n Entity = State extends NamedEntityState<infer E, Collection> ? E : never\n>(\n update: {\n id: EntityId;\n changes: EntityChanges<NoInfer<Entity>>;\n },\n config: {\n collection: Collection;\n selectId: SelectEntityId<NoInfer<Entity>>;\n }\n): PartialStateUpdater<State>;\nexport function updateEntity<\n Collection extends string,\n State extends NamedEntityState<any, Collection>,\n Entity = State extends NamedEntityState<\n infer E extends { id: EntityId },\n Collection\n >\n ? E\n : never\n>(\n update: {\n id: EntityId;\n changes: EntityChanges<NoInfer<Entity>>;\n },\n config: { collection: Collection }\n): PartialStateUpdater<State>;\nexport function updateEntity<Entity>(\n update: {\n id: EntityId;\n changes: EntityChanges<NoInfer<Entity>>;\n },\n config: { selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<EntityState<Entity>>;\nexport function updateEntity<Entity extends { id: EntityId }>(update: {\n id: EntityId;\n changes: EntityChanges<NoInfer<Entity>>;\n}): PartialStateUpdater<EntityState<Entity>>;\nexport function updateEntity(\n update: {\n id: EntityId;\n changes: EntityChanges<any>;\n },\n config?: { collection?: string; selectId?: SelectEntityId<any> }\n): PartialStateUpdater<EntityState<any> | NamedEntityState<any, string>> {\n const selectId = getEntityIdSelector(config);\n const stateKeys = getEntityStateKeys(config);\n\n return (state) => {\n const clonedState = cloneEntityState(state, stateKeys);\n const didMutate = updateEntitiesMutably(\n clonedState,\n [update.id],\n update.changes,\n selectId\n );\n\n return getEntityUpdaterResult(clonedState, stateKeys, didMutate);\n };\n}\n","import { PartialStateUpdater } from '@ngrx/signals';\nimport {\n EntityChanges,\n EntityId,\n EntityPredicate,\n EntityState,\n NamedEntityState,\n SelectEntityId,\n} from '../models';\nimport {\n cloneEntityState,\n getEntityIdSelector,\n getEntityStateKeys,\n getEntityUpdaterResult,\n updateEntitiesMutably,\n} from '../helpers';\n\nexport function updateEntities<\n Collection extends string,\n State extends NamedEntityState<any, Collection>,\n Entity = State extends NamedEntityState<infer E, Collection> ? E : never\n>(\n update: {\n ids: EntityId[];\n changes: EntityChanges<NoInfer<Entity>>;\n },\n config: {\n collection: Collection;\n selectId: SelectEntityId<NoInfer<Entity>>;\n }\n): PartialStateUpdater<State>;\nexport function updateEntities<\n Collection extends string,\n State extends NamedEntityState<any, Collection>,\n Entity = State extends NamedEntityState<infer E, Collection> ? E : never\n>(\n update: {\n predicate: EntityPredicate<Entity>;\n changes: EntityChanges<NoInfer<Entity>>;\n },\n config: {\n collection: Collection;\n selectId: SelectEntityId<NoInfer<Entity>>;\n }\n): PartialStateUpdater<State>;\nexport function updateEntities<\n Collection extends string,\n State extends NamedEntityState<any, Collection>,\n Entity = State extends NamedEntityState<\n infer E extends { id: EntityId },\n Collection\n >\n ? E\n : never\n>(\n update: {\n ids: EntityId[];\n changes: EntityChanges<NoInfer<Entity>>;\n },\n config: { collection: Collection }\n): PartialStateUpdater<State>;\nexport function updateEntities<\n Collection extends string,\n State extends NamedEntityState<any, Collection>,\n Entity = State extends NamedEntityState<\n infer E extends { id: EntityId },\n Collection\n >\n ? E\n : never\n>(\n update: {\n predicate: EntityPredicate<Entity>;\n changes: EntityChanges<NoInfer<Entity>>;\n },\n config: { collection: Collection }\n): PartialStateUpdater<State>;\nexport function updateEntities<Entity>(\n update: {\n ids: EntityId[];\n changes: EntityChanges<NoInfer<Entity>>;\n },\n config: { selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<EntityState<Entity>>;\nexport function updateEntities<Entity>(\n update: {\n predicate: EntityPredicate<Entity>;\n changes: EntityChanges<NoInfer<Entity>>;\n },\n config: { selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<EntityState<Entity>>;\nexport function updateEntities<Entity extends { id: EntityId }>(update: {\n ids: EntityId[];\n changes: EntityChanges<NoInfer<Entity>>;\n}): PartialStateUpdater<EntityState<Entity>>;\nexport function updateEntities<Entity extends { id: EntityId }>(update: {\n predicate: EntityPredicate<Entity>;\n changes: EntityChanges<NoInfer<Entity>>;\n}): PartialStateUpdater<EntityState<Entity>>;\nexport function updateEntities(\n update: ({ ids: EntityId[] } | { predicate: EntityPredicate<any> }) & {\n changes: EntityChanges<any>;\n },\n config?: { collection?: string; selectId?: SelectEntityId<any> }\n): PartialStateUpdater<EntityState<any> | NamedEntityState<any, string>> {\n const selectId = getEntityIdSelector(config);\n const stateKeys = getEntityStateKeys(config);\n const idsOrPredicate = 'ids' in update ? update.ids : update.predicate;\n\n return (state) => {\n const clonedState = cloneEntityState(state, stateKeys);\n const didMutate = updateEntitiesMutably(\n clonedState,\n idsOrPredicate,\n update.changes,\n selectId\n );\n\n return getEntityUpdaterResult(clonedState, stateKeys, didMutate);\n };\n}\n","import { PartialStateUpdater } from '@ngrx/signals';\nimport {\n EntityChanges,\n EntityId,\n EntityState,\n NamedEntityState,\n SelectEntityId,\n} from '../models';\nimport {\n cloneEntityState,\n getEntityIdSelector,\n getEntityStateKeys,\n getEntityUpdaterResult,\n updateEntitiesMutably,\n} from '../helpers';\n\nexport function updateAllEntities<\n Collection extends string,\n State extends NamedEntityState<any, Collection>,\n Entity = State extends NamedEntityState<infer E, Collection> ? E : never\n>(\n changes: EntityChanges<NoInfer<Entity>>,\n config: {\n collection: Collection;\n selectId: SelectEntityId<NoInfer<Entity>>;\n }\n): PartialStateUpdater<State>;\nexport function updateAllEntities<\n Collection extends string,\n State extends NamedEntityState<any, Collection>,\n Entity = State extends NamedEntityState<\n infer E extends { id: EntityId },\n Collection\n >\n ? E\n : never\n>(\n changes: EntityChanges<NoInfer<Entity>>,\n config: { collection: Collection }\n): PartialStateUpdater<State>;\nexport function updateAllEntities<Entity>(\n changes: EntityChanges<NoInfer<Entity>>,\n config: { selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<EntityState<Entity>>;\nexport function updateAllEntities<Entity extends { id: EntityId }>(\n changes: EntityChanges<NoInfer<Entity>>\n): PartialStateUpdater<EntityState<Entity>>;\nexport function updateAllEntities(\n changes: EntityChanges<any>,\n config?: { collection?: string; selectId?: SelectEntityId<any> }\n): PartialStateUpdater<EntityState<any> | NamedEntityState<any, string>> {\n const selectId = getEntityIdSelector(config);\n const stateKeys = getEntityStateKeys(config);\n\n return (state) => {\n const clonedState = cloneEntityState(state, stateKeys);\n const didMutate = updateEntitiesMutably(\n clonedState,\n (state as Record<string, any>)[stateKeys.idsKey],\n changes,\n selectId\n );\n\n return getEntityUpdaterResult(clonedState, stateKeys, didMutate);\n };\n}\n","import { SelectEntityId } from './models';\n\nexport function entityConfig<Entity, Collection extends string>(config: {\n entity: Entity;\n collection: Collection;\n selectId: SelectEntityId<NoInfer<Entity>>;\n}): typeof config;\nexport function entityConfig<Entity>(config: {\n entity: Entity;\n selectId: SelectEntityId<NoInfer<Entity>>;\n}): typeof config;\nexport function entityConfig<Entity, Collection extends string>(config: {\n entity: Entity;\n collection: Collection;\n}): typeof config;\nexport function entityConfig<Entity>(config: { entity: Entity }): typeof config;\nexport function entityConfig<Entity>(config: {\n entity: Entity;\n collection?: string;\n selectId?: SelectEntityId<Entity>;\n}): typeof config {\n return config;\n}\n","import { computed, Signal } from '@angular/core';\nimport {\n EmptyFeatureResult,\n SignalStoreFeature,\n signalStoreFeature,\n withComputed,\n withState,\n} from '@ngrx/signals';\nimport {\n EntityProps,\n EntityId,\n EntityMap,\n EntityState,\n NamedEntityProps,\n NamedEntityState,\n} from './models';\nimport { getEntityStateKeys } from './helpers';\n\nexport function withEntities<Entity>(): SignalStoreFeature<\n EmptyFeatureResult,\n {\n state: EntityState<Entity>;\n props: EntityProps<Entity>;\n methods: {};\n }\n>;\nexport function withEntities<Entity, Collection extends string>(config: {\n entity: Entity;\n collection: Collection;\n}): SignalStoreFeature<\n EmptyFeatureResult,\n {\n state: NamedEntityState<Entity, Collection>;\n props: NamedEntityProps<Entity, Collection>;\n methods: {};\n }\n>;\nexport function withEntities<Entity>(config: {\n entity: Entity;\n}): SignalStoreFeature<\n EmptyFeatureResult,\n {\n state: EntityState<Entity>;\n props: EntityProps<Entity>;\n methods: {};\n }\n>;\nexport function withEntities<Entity>(config?: {\n entity: Entity;\n collection?: string;\n}): SignalStoreFeature {\n const { entityMapKey, idsKey, entitiesKey } = getEntityStateKeys(config);\n\n return signalStoreFeature(\n withState({\n [entityMapKey]: {},\n [idsKey]: [],\n }),\n withComputed((store: Record<string, Signal<unknown>>) => ({\n [entitiesKey]: computed(() => {\n const entityMap = store[entityMapKey]() as EntityMap<Entity>;\n const ids = store[idsKey]() as EntityId[];\n\n return ids.map((id) => entityMap[id]);\n }),\n }))\n );\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;AA+BA,IAAY,SAIX;AAJD,CAAA,UAAY,SAAS,EAAA;AACnB,IAAA,SAAA,CAAA,SAAA,CAAA,MAAA,CAAA,GAAA,CAAA,CAAA,GAAA,MAAI;AACJ,IAAA,SAAA,CAAA,SAAA,CAAA,UAAA,CAAA,GAAA,CAAA,CAAA,GAAA,UAAQ;AACR,IAAA,SAAA,CAAA,SAAA,CAAA,MAAA,CAAA,GAAA,CAAA,CAAA,GAAA,MAAI;AACN,CAAC,EAJW,SAAS,KAAT,SAAS,GAIpB,EAAA,CAAA,CAAA;;ACzBD,MAAM,eAAe,GAAqC,CAAC,MAAM,KAAK,MAAM,CAAC,EAAE;AAEzE,SAAU,mBAAmB,CAAC,MAEnC,EAAA;AACC,IAAA,OAAO,MAAM,EAAE,QAAQ,IAAI,eAAe;AAC5C;AAEM,SAAU,kBAAkB,CAAC,MAAgC,EAAA;AAKjE,IAAA,MAAM,UAAU,GAAG,MAAM,EAAE,UAAU;AACrC,IAAA,MAAM,YAAY,GAChB,UAAU,KAAK,SAAS,GAAG,WAAW,GAAG,CAAG,EAAA,UAAU,WAAW;AACnE,IAAA,MAAM,MAAM,GAAG,UAAU,KAAK,SAAS,GAAG,KAAK,GAAG,CAAG,EAAA,UAAU,KAAK;AACpE,IAAA,MAAM,WAA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
12
|
const rxMethodFn = (input, config) => {
|
|
13
13
|
if (isStatic(input)) {
|
|
14
14
|
source$.next(input);
|
|
15
|
-
return {
|
|
15
|
+
return { destroy: noop };
|
|
16
16
|
}
|
|
17
17
|
const instanceInjector = config?.injector ?? getCallerInjector() ?? sourceInjector;
|
|
18
18
|
if (isSignal(input)) {
|
|
@@ -20,9 +20,8 @@ function rxMethod(generator, config) {
|
|
|
20
20
|
const value = input();
|
|
21
21
|
untracked(() => source$.next(value));
|
|
22
22
|
}, { injector: instanceInjector });
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return instanceSub;
|
|
23
|
+
sourceSub.add({ unsubscribe: () => watcher.destroy() });
|
|
24
|
+
return watcher;
|
|
26
25
|
}
|
|
27
26
|
const instanceSub = input.subscribe((value) => source$.next(value));
|
|
28
27
|
sourceSub.add(instanceSub);
|
|
@@ -31,9 +30,9 @@ function rxMethod(generator, config) {
|
|
|
31
30
|
.get(DestroyRef)
|
|
32
31
|
.onDestroy(() => instanceSub.unsubscribe());
|
|
33
32
|
}
|
|
34
|
-
return instanceSub;
|
|
33
|
+
return { destroy: () => instanceSub.unsubscribe() };
|
|
35
34
|
};
|
|
36
|
-
rxMethodFn.
|
|
35
|
+
rxMethodFn.destroy = sourceSub.unsubscribe.bind(sourceSub);
|
|
37
36
|
return rxMethodFn;
|
|
38
37
|
}
|
|
39
38
|
function isStatic(value) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngrx-signals-rxjs-interop.mjs","sources":["../../../../modules/signals/rxjs-interop/src/rx-method.ts","../../../../modules/signals/rxjs-interop/ngrx-signals-rxjs-interop.ts"],"sourcesContent":["import {\n assertInInjectionContext,\n DestroyRef,\n effect,\n inject,\n Injector,\n isSignal,\n Signal,\n untracked,\n} from '@angular/core';\nimport { isObservable, noop, Observable, Subject
|
|
1
|
+
{"version":3,"file":"ngrx-signals-rxjs-interop.mjs","sources":["../../../../modules/signals/rxjs-interop/src/rx-method.ts","../../../../modules/signals/rxjs-interop/ngrx-signals-rxjs-interop.ts"],"sourcesContent":["import {\n assertInInjectionContext,\n DestroyRef,\n effect,\n inject,\n Injector,\n isSignal,\n Signal,\n untracked,\n} from '@angular/core';\nimport { isObservable, noop, Observable, Subject } from 'rxjs';\n\ntype RxMethodRef = {\n destroy: () => void;\n};\n\ntype RxMethod<Input> = ((\n input: Input | Signal<Input> | Observable<Input>,\n config?: { injector?: Injector }\n) => RxMethodRef) &\n RxMethodRef;\n\nexport function rxMethod<Input>(\n generator: (source$: Observable<Input>) => Observable<unknown>,\n config?: { injector?: Injector }\n): RxMethod<Input> {\n if (!config?.injector) {\n assertInInjectionContext(rxMethod);\n }\n\n const sourceInjector = config?.injector ?? inject(Injector);\n const source$ = new Subject<Input>();\n const sourceSub = generator(source$).subscribe();\n sourceInjector.get(DestroyRef).onDestroy(() => sourceSub.unsubscribe());\n\n const rxMethodFn = (\n input: Input | Signal<Input> | Observable<Input>,\n config?: { injector?: Injector }\n ): RxMethodRef => {\n if (isStatic(input)) {\n source$.next(input);\n return { destroy: noop };\n }\n\n const instanceInjector =\n config?.injector ?? getCallerInjector() ?? sourceInjector;\n\n if (isSignal(input)) {\n const watcher = effect(\n () => {\n const value = input();\n untracked(() => source$.next(value));\n },\n { injector: instanceInjector }\n );\n sourceSub.add({ unsubscribe: () => watcher.destroy() });\n\n return watcher;\n }\n\n const instanceSub = input.subscribe((value) => source$.next(value));\n sourceSub.add(instanceSub);\n\n if (instanceInjector !== sourceInjector) {\n instanceInjector\n .get(DestroyRef)\n .onDestroy(() => instanceSub.unsubscribe());\n }\n\n return { destroy: () => instanceSub.unsubscribe() };\n };\n rxMethodFn.destroy = sourceSub.unsubscribe.bind(sourceSub);\n\n return rxMethodFn;\n}\n\nfunction isStatic<T>(value: T | Signal<T> | Observable<T>): value is T {\n return !isSignal(value) && !isObservable(value);\n}\n\nfunction getCallerInjector(): Injector | null {\n try {\n return inject(Injector);\n } catch {\n return null;\n }\n}\n","/**\n * Generated bundle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AAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACnE,QAAA,SAAS,CAAC,GAAG,CAAC,WAAW,CAAC;AAE1B,QAAA,IAAI,gBAAgB,KAAK,cAAc,EAAE;YACvC;iBACG,GAAG,CAAC,UAAU;iBACd,SAAS,CAAC,MAAM,WAAW,CAAC,WAAW,EAAE,CAAC;;QAG/C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC,WAAW,EAAE,EAAE;AACrD,KAAC;IACD,UAAU,CAAC,OAAO,GAAG,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC;AAE1D,IAAA,OAAO,UAAU;AACnB;AAEA,SAAS,QAAQ,CAAI,KAAoC,EAAA;IACvD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC;AACjD;AAEA,SAAS,iBAAiB,GAAA;AACxB,IAAA,IAAI;AACF,QAAA,OAAO,MAAM,CAAC,QAAQ,CAAC;;AACvB,IAAA,MAAM;AACN,QAAA,OAAO,IAAI;;AAEf;;ACtFA;;AAEG;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { untracked, isSignal, computed, assertInInjectionContext, inject, Injector, DestroyRef, signal, Injectable } from '@angular/core';
|
|
2
|
+
import { untracked, isSignal, computed, assertInInjectionContext, inject, Injector, effect, DestroyRef, signal, Injectable } from '@angular/core';
|
|
3
3
|
|
|
4
4
|
function toDeepSignal(signal) {
|
|
5
5
|
const value = untracked(() => signal());
|
|
@@ -21,18 +21,112 @@ function toDeepSignal(signal) {
|
|
|
21
21
|
},
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
|
+
const nonRecords = [
|
|
25
|
+
WeakSet,
|
|
26
|
+
WeakMap,
|
|
27
|
+
Promise,
|
|
28
|
+
Date,
|
|
29
|
+
Error,
|
|
30
|
+
RegExp,
|
|
31
|
+
ArrayBuffer,
|
|
32
|
+
DataView,
|
|
33
|
+
Function,
|
|
34
|
+
];
|
|
24
35
|
function isRecord(value) {
|
|
25
|
-
|
|
36
|
+
if (value === null || typeof value !== 'object' || isIterable(value)) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
let proto = Object.getPrototypeOf(value);
|
|
40
|
+
if (proto === Object.prototype) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
while (proto && proto !== Object.prototype) {
|
|
44
|
+
if (nonRecords.includes(proto.constructor)) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
proto = Object.getPrototypeOf(proto);
|
|
48
|
+
}
|
|
49
|
+
return proto === Object.prototype;
|
|
50
|
+
}
|
|
51
|
+
function isIterable(value) {
|
|
52
|
+
return typeof value?.[Symbol.iterator] === 'function';
|
|
26
53
|
}
|
|
27
54
|
|
|
28
55
|
function deepComputed(computation) {
|
|
29
56
|
return toDeepSignal(computed(computation));
|
|
30
57
|
}
|
|
31
58
|
|
|
59
|
+
function signalMethod(processingFn, config) {
|
|
60
|
+
if (!config?.injector) {
|
|
61
|
+
assertInInjectionContext(signalMethod);
|
|
62
|
+
}
|
|
63
|
+
const watchers = [];
|
|
64
|
+
const sourceInjector = config?.injector ?? inject(Injector);
|
|
65
|
+
const signalMethodFn = (input, config) => {
|
|
66
|
+
if (isSignal(input)) {
|
|
67
|
+
const instanceInjector = config?.injector ?? getCallerInjector() ?? sourceInjector;
|
|
68
|
+
const watcher = effect((onCleanup) => {
|
|
69
|
+
const value = input();
|
|
70
|
+
untracked(() => processingFn(value));
|
|
71
|
+
onCleanup(() => watchers.splice(watchers.indexOf(watcher), 1));
|
|
72
|
+
}, { injector: instanceInjector });
|
|
73
|
+
watchers.push(watcher);
|
|
74
|
+
return watcher;
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
processingFn(input);
|
|
78
|
+
return { destroy: () => void true };
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
signalMethodFn.destroy = () => watchers.forEach((watcher) => watcher.destroy());
|
|
82
|
+
return signalMethodFn;
|
|
83
|
+
}
|
|
84
|
+
function getCallerInjector() {
|
|
85
|
+
try {
|
|
86
|
+
return inject(Injector);
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function deepFreeze(target) {
|
|
94
|
+
Object.freeze(target);
|
|
95
|
+
const targetIsFunction = typeof target === 'function';
|
|
96
|
+
Object.getOwnPropertyNames(target).forEach((prop) => {
|
|
97
|
+
// Ignore Ivy properties, ref: https://github.com/ngrx/platform/issues/2109#issuecomment-582689060
|
|
98
|
+
if (prop.startsWith('ɵ')) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (hasOwnProperty(target, prop) &&
|
|
102
|
+
(targetIsFunction
|
|
103
|
+
? prop !== 'caller' && prop !== 'callee' && prop !== 'arguments'
|
|
104
|
+
: true)) {
|
|
105
|
+
const propValue = target[prop];
|
|
106
|
+
if ((isObjectLike(propValue) || typeof propValue === 'function') &&
|
|
107
|
+
!Object.isFrozen(propValue)) {
|
|
108
|
+
deepFreeze(propValue);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
return target;
|
|
113
|
+
}
|
|
114
|
+
function freezeInDevMode(target) {
|
|
115
|
+
return ngDevMode ? deepFreeze(target) : target;
|
|
116
|
+
}
|
|
117
|
+
function hasOwnProperty(target, propertyName) {
|
|
118
|
+
return isObjectLike(target)
|
|
119
|
+
? Object.prototype.hasOwnProperty.call(target, propertyName)
|
|
120
|
+
: false;
|
|
121
|
+
}
|
|
122
|
+
function isObjectLike(target) {
|
|
123
|
+
return typeof target === 'object' && target !== null;
|
|
124
|
+
}
|
|
125
|
+
|
|
32
126
|
const STATE_WATCHERS = new WeakMap();
|
|
33
127
|
const STATE_SOURCE = Symbol('STATE_SOURCE');
|
|
34
128
|
function patchState(stateSource, ...updaters) {
|
|
35
|
-
stateSource[STATE_SOURCE].update((currentState) => updaters.reduce((nextState, updater) => ({
|
|
129
|
+
stateSource[STATE_SOURCE].update((currentState) => updaters.reduce((nextState, updater) => freezeInDevMode({
|
|
36
130
|
...nextState,
|
|
37
131
|
...(typeof updater === 'function' ? updater(nextState) : updater),
|
|
38
132
|
}), currentState));
|
|
@@ -73,7 +167,7 @@ function removeWatcher(stateSource, watcher) {
|
|
|
73
167
|
}
|
|
74
168
|
|
|
75
169
|
function signalState(initialState) {
|
|
76
|
-
const stateSource = signal(initialState);
|
|
170
|
+
const stateSource = signal(freezeInDevMode(initialState));
|
|
77
171
|
const signalState = toDeepSignal(stateSource.asReadonly());
|
|
78
172
|
Object.defineProperty(signalState, STATE_SOURCE, {
|
|
79
173
|
value: stateSource,
|
|
@@ -90,8 +184,8 @@ function signalStore(...args) {
|
|
|
90
184
|
class SignalStore {
|
|
91
185
|
constructor() {
|
|
92
186
|
const innerStore = features.reduce((store, feature) => feature(store), getInitialInnerStore());
|
|
93
|
-
const { stateSignals,
|
|
94
|
-
const storeMembers = { ...stateSignals, ...
|
|
187
|
+
const { stateSignals, props, methods, hooks } = innerStore;
|
|
188
|
+
const storeMembers = { ...stateSignals, ...props, ...methods };
|
|
95
189
|
this[STATE_SOURCE] = innerStore[STATE_SOURCE];
|
|
96
190
|
for (const key in storeMembers) {
|
|
97
191
|
this[key] = storeMembers[key];
|
|
@@ -104,10 +198,10 @@ function signalStore(...args) {
|
|
|
104
198
|
inject(DestroyRef).onDestroy(onDestroy);
|
|
105
199
|
}
|
|
106
200
|
}
|
|
107
|
-
/** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
108
|
-
/** @nocollapse */ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
201
|
+
/** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: SignalStore, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
202
|
+
/** @nocollapse */ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: SignalStore, providedIn: config.providedIn || null });
|
|
109
203
|
}
|
|
110
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
204
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: SignalStore, decorators: [{
|
|
111
205
|
type: Injectable,
|
|
112
206
|
args: [{ providedIn: config.providedIn || null }]
|
|
113
207
|
}], ctorParameters: () => [] });
|
|
@@ -117,7 +211,7 @@ function getInitialInnerStore() {
|
|
|
117
211
|
return {
|
|
118
212
|
[STATE_SOURCE]: signal({}),
|
|
119
213
|
stateSignals: {},
|
|
120
|
-
|
|
214
|
+
props: {},
|
|
121
215
|
methods: {},
|
|
122
216
|
hooks: {},
|
|
123
217
|
};
|
|
@@ -139,7 +233,7 @@ function assertUniqueStoreMembers(store, newMemberKeys) {
|
|
|
139
233
|
}
|
|
140
234
|
const storeMembers = {
|
|
141
235
|
...store.stateSignals,
|
|
142
|
-
...store.
|
|
236
|
+
...store.props,
|
|
143
237
|
...store.methods,
|
|
144
238
|
};
|
|
145
239
|
const overriddenKeys = Object.keys(storeMembers).filter((memberKey) => newMemberKeys.includes(memberKey));
|
|
@@ -148,26 +242,32 @@ function assertUniqueStoreMembers(store, newMemberKeys) {
|
|
|
148
242
|
}
|
|
149
243
|
}
|
|
150
244
|
|
|
151
|
-
function
|
|
245
|
+
function withProps(propsFactory) {
|
|
152
246
|
return (store) => {
|
|
153
|
-
const
|
|
247
|
+
const props = propsFactory({
|
|
248
|
+
[STATE_SOURCE]: store[STATE_SOURCE],
|
|
154
249
|
...store.stateSignals,
|
|
155
|
-
...store.
|
|
250
|
+
...store.props,
|
|
251
|
+
...store.methods,
|
|
156
252
|
});
|
|
157
|
-
assertUniqueStoreMembers(store, Object.keys(
|
|
253
|
+
assertUniqueStoreMembers(store, Object.keys(props));
|
|
158
254
|
return {
|
|
159
255
|
...store,
|
|
160
|
-
|
|
256
|
+
props: { ...store.props, ...props },
|
|
161
257
|
};
|
|
162
258
|
};
|
|
163
259
|
}
|
|
164
260
|
|
|
261
|
+
function withComputed(signalsFactory) {
|
|
262
|
+
return withProps(signalsFactory);
|
|
263
|
+
}
|
|
264
|
+
|
|
165
265
|
function withHooks(hooksOrFactory) {
|
|
166
266
|
return (store) => {
|
|
167
267
|
const storeMembers = {
|
|
168
268
|
[STATE_SOURCE]: store[STATE_SOURCE],
|
|
169
269
|
...store.stateSignals,
|
|
170
|
-
...store.
|
|
270
|
+
...store.props,
|
|
171
271
|
...store.methods,
|
|
172
272
|
};
|
|
173
273
|
const hooks = typeof hooksOrFactory === 'function'
|
|
@@ -200,7 +300,7 @@ function withMethods(methodsFactory) {
|
|
|
200
300
|
const methods = methodsFactory({
|
|
201
301
|
[STATE_SOURCE]: store[STATE_SOURCE],
|
|
202
302
|
...store.stateSignals,
|
|
203
|
-
...store.
|
|
303
|
+
...store.props,
|
|
204
304
|
...store.methods,
|
|
205
305
|
});
|
|
206
306
|
assertUniqueStoreMembers(store, Object.keys(methods));
|
|
@@ -216,7 +316,7 @@ function withState(stateOrFactory) {
|
|
|
216
316
|
const state = typeof stateOrFactory === 'function' ? stateOrFactory() : stateOrFactory;
|
|
217
317
|
const stateKeys = Object.keys(state);
|
|
218
318
|
assertUniqueStoreMembers(store, stateKeys);
|
|
219
|
-
store[STATE_SOURCE].update((currentState) => ({
|
|
319
|
+
store[STATE_SOURCE].update((currentState) => freezeInDevMode({
|
|
220
320
|
...currentState,
|
|
221
321
|
...state,
|
|
222
322
|
}));
|
|
@@ -235,5 +335,5 @@ function withState(stateOrFactory) {
|
|
|
235
335
|
* Generated bundle index. Do not edit.
|
|
236
336
|
*/
|
|
237
337
|
|
|
238
|
-
export { deepComputed, getState, patchState, signalState, signalStore, signalStoreFeature, type, watchState, withComputed, withHooks, withMethods, withState };
|
|
338
|
+
export { deepComputed, getState, patchState, signalMethod, signalState, signalStore, signalStoreFeature, type, watchState, withComputed, withHooks, withMethods, withProps, withState };
|
|
239
339
|
//# sourceMappingURL=ngrx-signals.mjs.map
|