@ngrx/signals 19.0.0-beta.0 → 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.
@@ -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 { EntityComputed, EntityId, EntityMap, EntityState, NamedEntityComputed, NamedEntityState, SelectEntityId, } from './models';
13
+ export { EntityId, EntityMap, EntityProps, EntityState, NamedEntityProps, NamedEntityState, SelectEntityId, } from './models';
14
14
  export { withEntities } from './with-entities';
@@ -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 EntityComputed<Entity> = {
11
+ export type EntityProps<Entity> = {
12
12
  entities: Signal<Entity[]>;
13
13
  };
14
- export type NamedEntityComputed<Entity, Collection extends string> = {
15
- [K in keyof EntityComputed<Entity> as `${Collection}${Capitalize<K>}`]: EntityComputed<Entity>[K];
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 { EntityComputed, EntityState, NamedEntityComputed, NamedEntityState } from './models';
2
+ import { EntityProps, EntityState, NamedEntityProps, NamedEntityState } from './models';
3
3
  export declare function withEntities<Entity>(): SignalStoreFeature<EmptyFeatureResult, {
4
4
  state: EntityState<Entity>;
5
- computed: EntityComputed<Entity>;
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
- computed: NamedEntityComputed<Entity, Collection>;
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
- computed: EntityComputed<Entity>;
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;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,MA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BAAkB,CACvB,SAAS,CAAC;QACR,CAAC,YAAY,GAAG,EAAE;QAClB,CAAC,MAAM,GAAG,EAAE;KACb,CAAC,EACF,YAAY,CAAC,CAAC,KAAsC,MAAM;AACxD,QAAA,CAAC,WAAW,GAAG,QAAQ,CAAC,MAAK;AAC3B,YAAA,MAAM,SAAS,GAAG,KAAK,CAAC,YAAY,CAAC,EAAuB;AAC5D,YAAA,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC,EAAgB;AAEzC,YAAA,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,SAAS,CAAC,EAAE,CAAC,CAAC;AACvC,SAAC,CAAC;KACH,CAAC,CAAC,CACJ;AACH;;ACnEA;;AAEG;;;;"}
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 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,G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OAAO,kBAAkB,CACvB,SAAS,CAAC;QACR,CAAC,YAAY,GAAG,EAAE;QAClB,CAAC,MAAM,GAAG,EAAE;KACb,CAAC,EACF,YAAY,CAAC,CAAC,KAAsC,MAAM;AACxD,QAAA,CAAC,WAAW,GAAG,QAAQ,CAAC,MAAK;AAC3B,YAAA,MAAM,SAAS,GAAG,KAAK,CAAC,YAAY,CAAC,EAAuB;AAC5D,YAAA,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC,EAAgB;AAEzC,YAAA,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,SAAS,CAAC,EAAE,CAAC,CAAC;AACvC,SAAC,CAAC;KACH,CAAC,CAAC,CACJ;AACH;;ACnEA;;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,14 +21,75 @@ 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
- return value?.constructor === Object;
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
+
32
93
  function deepFreeze(target) {
33
94
  Object.freeze(target);
34
95
  const targetIsFunction = typeof target === 'function';
@@ -123,8 +184,8 @@ function signalStore(...args) {
123
184
  class SignalStore {
124
185
  constructor() {
125
186
  const innerStore = features.reduce((store, feature) => feature(store), getInitialInnerStore());
126
- const { stateSignals, computedSignals, methods, hooks } = innerStore;
127
- const storeMembers = { ...stateSignals, ...computedSignals, ...methods };
187
+ const { stateSignals, props, methods, hooks } = innerStore;
188
+ const storeMembers = { ...stateSignals, ...props, ...methods };
128
189
  this[STATE_SOURCE] = innerStore[STATE_SOURCE];
129
190
  for (const key in storeMembers) {
130
191
  this[key] = storeMembers[key];
@@ -150,7 +211,7 @@ function getInitialInnerStore() {
150
211
  return {
151
212
  [STATE_SOURCE]: signal({}),
152
213
  stateSignals: {},
153
- computedSignals: {},
214
+ props: {},
154
215
  methods: {},
155
216
  hooks: {},
156
217
  };
@@ -172,7 +233,7 @@ function assertUniqueStoreMembers(store, newMemberKeys) {
172
233
  }
173
234
  const storeMembers = {
174
235
  ...store.stateSignals,
175
- ...store.computedSignals,
236
+ ...store.props,
176
237
  ...store.methods,
177
238
  };
178
239
  const overriddenKeys = Object.keys(storeMembers).filter((memberKey) => newMemberKeys.includes(memberKey));
@@ -181,26 +242,32 @@ function assertUniqueStoreMembers(store, newMemberKeys) {
181
242
  }
182
243
  }
183
244
 
184
- function withComputed(signalsFactory) {
245
+ function withProps(propsFactory) {
185
246
  return (store) => {
186
- const computedSignals = signalsFactory({
247
+ const props = propsFactory({
248
+ [STATE_SOURCE]: store[STATE_SOURCE],
187
249
  ...store.stateSignals,
188
- ...store.computedSignals,
250
+ ...store.props,
251
+ ...store.methods,
189
252
  });
190
- assertUniqueStoreMembers(store, Object.keys(computedSignals));
253
+ assertUniqueStoreMembers(store, Object.keys(props));
191
254
  return {
192
255
  ...store,
193
- computedSignals: { ...store.computedSignals, ...computedSignals },
256
+ props: { ...store.props, ...props },
194
257
  };
195
258
  };
196
259
  }
197
260
 
261
+ function withComputed(signalsFactory) {
262
+ return withProps(signalsFactory);
263
+ }
264
+
198
265
  function withHooks(hooksOrFactory) {
199
266
  return (store) => {
200
267
  const storeMembers = {
201
268
  [STATE_SOURCE]: store[STATE_SOURCE],
202
269
  ...store.stateSignals,
203
- ...store.computedSignals,
270
+ ...store.props,
204
271
  ...store.methods,
205
272
  };
206
273
  const hooks = typeof hooksOrFactory === 'function'
@@ -233,7 +300,7 @@ function withMethods(methodsFactory) {
233
300
  const methods = methodsFactory({
234
301
  [STATE_SOURCE]: store[STATE_SOURCE],
235
302
  ...store.stateSignals,
236
- ...store.computedSignals,
303
+ ...store.props,
237
304
  ...store.methods,
238
305
  });
239
306
  assertUniqueStoreMembers(store, Object.keys(methods));
@@ -268,5 +335,5 @@ function withState(stateOrFactory) {
268
335
  * Generated bundle index. Do not edit.
269
336
  */
270
337
 
271
- 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 };
272
339
  //# sourceMappingURL=ngrx-signals.mjs.map