@ngxs/store 3.7.6-dev.master-2df2f65 → 3.7.6-dev.master-1bdb8c0
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/bundles/ngxs-store-operators.umd.js +11 -11
- package/bundles/ngxs-store-operators.umd.js.map +1 -1
- package/bundles/ngxs-store-operators.umd.min.js.map +1 -1
- package/bundles/ngxs-store.umd.js +238 -75
- package/bundles/ngxs-store.umd.js.map +1 -1
- package/bundles/ngxs-store.umd.min.js +1 -1
- package/bundles/ngxs-store.umd.min.js.map +1 -1
- package/esm2015/index.js +2 -2
- package/esm2015/ngxs-store.js +15 -14
- package/esm2015/operators/append.js +2 -2
- package/esm2015/operators/compose.js +2 -2
- package/esm2015/operators/iif.js +7 -7
- package/esm2015/operators/index.js +1 -1
- package/esm2015/operators/insert-item.js +1 -1
- package/esm2015/operators/patch.js +4 -4
- package/esm2015/operators/remove-item.js +1 -1
- package/esm2015/operators/types.js +5 -0
- package/esm2015/operators/update-item.js +1 -1
- package/esm2015/operators/utils.js +1 -1
- package/esm2015/src/dev-features/ngxs-development.module.js +26 -0
- package/esm2015/src/dev-features/ngxs-unhandled-actions-logger.js +69 -0
- package/esm2015/src/dev-features/symbols.js +24 -0
- package/esm2015/src/internal/state-context-factory.js +2 -2
- package/esm2015/src/internal/state-factory.js +21 -5
- package/esm2015/src/internal/state-operators.js +1 -1
- package/esm2015/src/public_api.js +3 -1
- package/esm2015/src/symbols.js +1 -1
- package/esm5/index.js +2 -2
- package/esm5/ngxs-store.js +15 -14
- package/esm5/operators/append.js +2 -2
- package/esm5/operators/compose.js +2 -2
- package/esm5/operators/iif.js +7 -7
- package/esm5/operators/index.js +1 -1
- package/esm5/operators/insert-item.js +1 -1
- package/esm5/operators/patch.js +4 -4
- package/esm5/operators/remove-item.js +1 -1
- package/esm5/operators/types.js +5 -0
- package/esm5/operators/update-item.js +1 -1
- package/esm5/operators/utils.js +1 -1
- package/esm5/src/dev-features/ngxs-development.module.js +34 -0
- package/esm5/src/dev-features/ngxs-unhandled-actions-logger.js +98 -0
- package/esm5/src/dev-features/symbols.js +24 -0
- package/esm5/src/internal/state-context-factory.js +2 -2
- package/esm5/src/internal/state-factory.js +21 -5
- package/esm5/src/internal/state-operators.js +1 -1
- package/esm5/src/public_api.js +3 -1
- package/esm5/src/symbols.js +1 -1
- package/fesm2015/ngxs-store-operators.js +11 -11
- package/fesm2015/ngxs-store-operators.js.map +1 -1
- package/fesm2015/ngxs-store.js +171 -45
- package/fesm2015/ngxs-store.js.map +1 -1
- package/fesm5/ngxs-store-operators.js +11 -11
- package/fesm5/ngxs-store-operators.js.map +1 -1
- package/fesm5/ngxs-store.js +220 -60
- package/fesm5/ngxs-store.js.map +1 -1
- package/ngxs-store.d.ts +14 -13
- package/ngxs-store.metadata.json +1 -1
- package/operators/append.d.ts +2 -3
- package/operators/compose.d.ts +1 -2
- package/operators/iif.d.ts +3 -4
- package/operators/index.d.ts +2 -1
- package/operators/insert-item.d.ts +2 -3
- package/operators/ngxs-store-operators.metadata.json +1 -1
- package/operators/patch.d.ts +5 -4
- package/operators/remove-item.d.ts +3 -4
- package/operators/types.d.ts +53 -0
- package/operators/update-item.d.ts +3 -4
- package/operators/utils.d.ts +2 -4
- package/package.json +1 -1
- package/src/dev-features/ngxs-development.module.d.ts +5 -0
- package/src/dev-features/ngxs-unhandled-actions-logger.d.ts +14 -0
- package/src/dev-features/symbols.d.ts +8 -0
- package/src/internal/state-operators.d.ts +1 -1
- package/src/public_api.d.ts +3 -0
- package/src/symbols.d.ts +3 -2
- package/esm2015/operators/internals.js +0 -5
- package/esm5/operators/internals.js +0 -5
- package/operators/internals.d.ts +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngxs-store-operators.js","sources":["ng://@ngxs/store/operators/append.ts","ng://@ngxs/store/operators/compose.ts","ng://@ngxs/store/operators/utils.ts","ng://@ngxs/store/operators/iif.ts","ng://@ngxs/store/operators/insert-item.ts","ng://@ngxs/store/operators/patch.ts","ng://@ngxs/store/operators/update-item.ts","ng://@ngxs/store/operators/remove-item.ts"],"sourcesContent":["import { StateOperator } from '@ngxs/store';\nimport { RepairType, NoInfer } from './utils';\n\n/**\n * @param items - Specific items to append to the end of an array\n */\nexport function append<T>(items: NoInfer<T>[]): StateOperator<RepairType<T>[]> {\n return function appendOperator(existing: Readonly<RepairType<T>[]>): RepairType<T>[] {\n // If `items` is `undefined` or `null` or `[]` but `existing` is provided\n // just return `existing`\n const itemsNotProvidedButExistingIs = (!items || !items.length) && existing;\n if (itemsNotProvidedButExistingIs) {\n return existing as RepairType<T>[];\n }\n\n if (Array.isArray(existing)) {\n return existing.concat((items as unknown) as RepairType<T>[]);\n }\n\n // For example if some property is added dynamically\n // and didn't exist before thus it's not `ArrayLike`\n return (items as unknown) as RepairType<T>[];\n };\n}\n","import { StateOperator } from '@ngxs/store';\nimport { NoInfer } from './utils';\n\nexport function compose<T>(...operators: NoInfer<StateOperator<T>[]>): StateOperator<T> {\n return function composeOperator(existing: Readonly<T>): T {\n return operators.reduce((accumulator, operator) => operator(accumulator), existing);\n };\n}\n","import { StateOperator } from '@ngxs/store';\n\nimport { Predicate } from './internals';\n\nexport function isStateOperator<T>(value: T | StateOperator<T>): value is StateOperator<T> {\n return typeof value === 'function';\n}\n\nexport function isUndefined(value: any): value is undefined {\n return typeof value === 'undefined';\n}\n\nexport function isPredicate<T>(value: Predicate<T> | boolean | number): value is Predicate<T> {\n return typeof value === 'function';\n}\n\nexport function isNumber(value: any): value is number {\n return typeof value === 'number';\n}\n\nexport function invalidIndex(index: number): boolean {\n return Number.isNaN(index) || index === -1;\n}\n\nexport function isNil<T>(value: T | null | undefined): value is null | undefined {\n return value === null || isUndefined(value);\n}\n\nexport type RepairType<T> = T extends true ? boolean : T extends false ? boolean : T;\n\nexport type NoInfer<T> = T extends infer S ? S : never;\n","import { StateOperator } from '@ngxs/store';\n\nimport { isStateOperator, isUndefined, isPredicate, RepairType, NoInfer } from './utils';\nimport { Predicate } from './internals';\n\nfunction retrieveValue<T>(\n operatorOrValue: StateOperator<T> | T,\n existing?: Readonly<RepairType<T>>\n): RepairType<T> {\n // If state operator is a function\n // then call it with an original value\n if (isStateOperator(operatorOrValue)) {\n const value = operatorOrValue(existing! as Readonly<T>);\n return value as RepairType<T>;\n }\n\n // If operator or value was not provided\n // e.g. `elseOperatorOrValue` is `undefined`\n // then we just return an original value\n if (isUndefined(operatorOrValue)) {\n return (<any>existing)! as RepairType<T>;\n }\n\n return operatorOrValue as RepairType<T>;\n}\n\n/**\n * @param condition - Condition can be a plain boolean value or a function,\n * that returns boolean, also this function can take a value as an argument\n * to which this state operator applies\n * @param trueOperatorOrValue - Any value or a state operator\n * @param elseOperatorOrValue - Any value or a state operator\n */\nexport function iif<T>(\n condition: NoInfer<Predicate<T>> | boolean,\n trueOperatorOrValue: NoInfer<StateOperator<T>> | T,\n elseOperatorOrValue?: NoInfer<StateOperator<T>> | T\n): StateOperator<RepairType<T>> {\n return function iifOperator(existing: Readonly<RepairType<T>>): RepairType<T> {\n // Convert the value to a boolean\n let result = !!condition;\n // but if it is a function then run it to get the result\n if (isPredicate(condition)) {\n result = condition(existing);\n }\n\n if (result) {\n return retrieveValue<T>(trueOperatorOrValue, existing as RepairType<T>);\n }\n\n return retrieveValue<T>(elseOperatorOrValue!, existing as RepairType<T>);\n };\n}\n","import { StateOperator } from '@ngxs/store';\nimport { isNil, RepairType, NoInfer } from './utils';\n\n/**\n * @param value - Value to insert\n * @param [beforePosition] - Specified index to insert value before, optional\n */\nexport function insertItem<T>(\n value: NoInfer<T>,\n beforePosition?: number\n): StateOperator<RepairType<T>[]> {\n return function insertItemOperator(existing: Readonly<RepairType<T>[]>): RepairType<T>[] {\n // Have to check explicitly for `null` and `undefined`\n // because `value` can be `0`, thus `!value` will return `true`\n if (isNil(value) && existing) {\n return existing as RepairType<T>[];\n }\n\n // Property may be dynamic and might not existed before\n if (!Array.isArray(existing)) {\n return [(value as unknown) as RepairType<T>];\n }\n\n const clone = existing.slice();\n\n let index = 0;\n\n // No need to call `isNumber`\n // as we are checking `> 0` not `>= 0`\n // everything except number will return false here\n if (beforePosition! > 0) {\n index = beforePosition!;\n }\n\n clone.splice(index, 0, (value as unknown) as RepairType<T>);\n return clone;\n };\n}\n","import { StateOperator } from '@ngxs/store';\nimport { isStateOperator, NoInfer } from './utils';\n\nexport type PatchSpec<T> = { [P in keyof T]?: T[P] | StateOperator<NonNullable<T[P]>> };\n\ntype PatchValues<T> = {\n readonly [P in keyof T]?: T[P] extends (...args: any[]) => infer R ? R : T[P];\n};\n\nexport function patch<T>(patchObject: NoInfer<PatchSpec<T>>): StateOperator<NonNullable<T>> {\n return (function patchStateOperator(existing: Readonly<PatchValues<T>>): NonNullable<T> {\n let clone = null;\n for (const k in patchObject) {\n const newValue = patchObject[k];\n const existingPropValue = existing[k as Extract<keyof T, string>];\n const newPropValue = isStateOperator(newValue)\n ? newValue(<any>existingPropValue)\n : newValue;\n if (newPropValue !== existingPropValue) {\n if (!clone) {\n clone = { ...(<any>existing) };\n }\n clone[k] = newPropValue;\n }\n }\n return clone || existing;\n } as unknown) as StateOperator<NonNullable<T>>;\n}\n","import { StateOperator } from '@ngxs/store';\n\nimport {\n isStateOperator,\n isPredicate,\n isNumber,\n invalidIndex,\n RepairType,\n NoInfer\n} from './utils';\nimport { Predicate } from './internals';\n\n/**\n * @param selector - Index of item in the array or a predicate function\n * that can be provided in `Array.prototype.findIndex`\n * @param operatorOrValue - New value under the `selector` index or a\n * function that can be applied to an existing value\n */\nexport function updateItem<T>(\n selector: number | NoInfer<Predicate<T>>,\n operatorOrValue: NoInfer<T> | NoInfer<StateOperator<T>>\n): StateOperator<RepairType<T>[]> {\n return function updateItemOperator(existing: Readonly<RepairType<T>[]>): RepairType<T>[] {\n let index = -1;\n\n if (isPredicate(selector)) {\n index = existing.findIndex(selector as Predicate<T>);\n } else if (isNumber(selector)) {\n index = selector;\n }\n\n if (invalidIndex(index)) {\n return existing as RepairType<T>[];\n }\n\n let value: T = null!;\n // Need to check if the new item value will change the existing item value\n // then, only if it will change it then clone the array and set the item\n const theOperatorOrValue = operatorOrValue as T | StateOperator<T>;\n if (isStateOperator(theOperatorOrValue)) {\n value = theOperatorOrValue(existing[index] as Readonly<T>);\n } else {\n value = theOperatorOrValue;\n }\n\n // If the value hasn't been mutated\n // then we just return `existing` array\n if (value === existing[index]) {\n return existing as RepairType<T>[];\n }\n\n const clone = existing.slice();\n clone[index] = value as RepairType<T>;\n return clone;\n };\n}\n","import { StateOperator } from '@ngxs/store';\nimport { Predicate } from './internals';\nimport { isPredicate, isNumber, invalidIndex, RepairType } from './utils';\n\n/**\n * @param selector - index or predicate to remove an item from an array by\n */\nexport function removeItem<T>(\n selector: number | Predicate<T>\n): StateOperator<RepairType<T>[]> {\n return function removeItemOperator(existing: Readonly<RepairType<T>[]>): RepairType<T>[] {\n let index = -1;\n\n if (isPredicate(selector)) {\n index = existing.findIndex(selector);\n } else if (isNumber(selector)) {\n index = selector;\n }\n\n if (invalidIndex(index)) {\n return existing as RepairType<T>[];\n }\n\n const clone = existing.slice();\n clone.splice(index, 1);\n return clone;\n };\n}\n"],"names":[],"mappings":";;;;;;;;;AAMA,SAAgB,MAAM,CAAI,KAAmB;IAC3C;;;;IAAO,SAAS,cAAc,CAAC,QAAmC;;;;cAG1D,6BAA6B,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,QAAQ;QAC3E,IAAI,6BAA6B,EAAE;YACjC,0BAAO,QAAQ,GAAoB;SACpC;QAED,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;YAC3B,OAAO,QAAQ,CAAC,MAAM,wCAAE,KAAK,MAAgC,CAAC;SAC/D;;;QAID,8CAAQ,KAAK,MAAgC;KAC9C,EAAC;CACH;;;;;;;;;;;ACpBD,SAAgB,OAAO,CAAI,GAAG,SAAsC;IAClE;;;;IAAO,SAAS,eAAe,CAAC,QAAq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K,GAAG,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;SACtC;aAAM,IAAI,QAAQ,CAAC,QAAQ,CAAC,EAAE;YAC7B,KAAK,GAAG,QAAQ,CAAC;SAClB;QAED,IAAI,YAAY,CAAC,KAAK,CAAC,EAAE;YACvB,0BAAO,QAAQ,GAAoB;SACpC;;cAEK,KAAK,GAAG,QAAQ,CAAC,KAAK,EAAE;QAC9B,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QACvB,OAAO,KAAK,CAAC;KACd,EAAC;CACH;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"ngxs-store-operators.js","sources":["ng://@ngxs/store/operators/append.ts","ng://@ngxs/store/operators/compose.ts","ng://@ngxs/store/operators/utils.ts","ng://@ngxs/store/operators/iif.ts","ng://@ngxs/store/operators/insert-item.ts","ng://@ngxs/store/operators/patch.ts","ng://@ngxs/store/operators/update-item.ts","ng://@ngxs/store/operators/remove-item.ts"],"sourcesContent":["import { ExistingState, NoInfer, StateOperator } from './types';\n\n/**\n * @param items - Specific items to append to the end of an array\n */\nexport function append<T>(items: NoInfer<T[]>): StateOperator<T[]> {\n return function appendOperator(existing: ExistingState<T[]>): T[] {\n // If `items` is `undefined` or `null` or `[]` but `existing` is provided\n // just return `existing`\n const itemsNotProvidedButExistingIs = (!items || !items.length) && existing;\n if (itemsNotProvidedButExistingIs) {\n return (existing as unknown) as T[];\n }\n\n if (Array.isArray(existing)) {\n return existing.concat((items as unknown) as ExistingState<T[]>);\n }\n\n // For example if some property is added dynamically\n // and didn't exist before thus it's not `ArrayLike`\n return (items as unknown) as T[];\n };\n}\n","import { ExistingState, NoInfer, StateOperator } from './types';\n\nexport function compose<T>(...operators: NoInfer<StateOperator<T>[]>): StateOperator<T> {\n return function composeOperator(existing: ExistingState<T>): T {\n return operators.reduce(\n (accumulator, operator) => operator(accumulator as ExistingState<T>),\n existing as T\n );\n };\n}\n","import { StateOperator } from './types';\n\nexport type Predicate<T = any> = (value: T | Readonly<T>) => boolean;\n\nexport function isStateOperator<T>(value: T | StateOperator<T>): value is StateOperator<T> {\n return typeof value === 'function';\n}\n\nexport function isUndefined(value: any): value is undefined {\n return typeof value === 'undefined';\n}\n\nexport function isPredicate<T>(value: Predicate<T> | boolean | number): value is Predicate<T> {\n return typeof value === 'function';\n}\n\nexport function isNumber(value: any): value is number {\n return typeof value === 'number';\n}\n\nexport function invalidIndex(index: number): boolean {\n return Number.isNaN(index) || index === -1;\n}\n\nexport function isNil<T>(value: T | null | undefined): value is null | undefined {\n return value === null || isUndefined(value);\n}\n","import { ExistingState, NoInfer, StateOperator } from './types';\n\nimport { isStateOperator, isUndefined, isPredicate, Predicate } from './utils';\n\nfunction retrieveValue<T>(\n operatorOrValue: StateOperator<T> | T,\n existing: ExistingState<T>\n): T {\n // If state operator is a function\n // then call it with an original value\n if (isStateOperator(operatorOrValue)) {\n const value = operatorOrValue(existing);\n return value as T;\n }\n\n // If operator or value was not provided\n // e.g. `elseOperatorOrValue` is `undefined`\n // then we just return an original value\n if (isUndefined(operatorOrValue)) {\n return existing as T;\n }\n\n return operatorOrValue as T;\n}\n\n/**\n * @param condition - Condition can be a plain boolean value or a function,\n * that returns boolean, also this function can take a value as an argument\n * to which this state operator applies\n * @param trueOperatorOrValue - Any value or a state operator\n * @param elseOperatorOrValue - Any value or a state operator\n */\nexport function iif<T>(\n condition: NoInfer<Predicate<T>> | boolean,\n trueOperatorOrValue: NoInfer<StateOperator<T> | T>,\n elseOperatorOrValue?: NoInfer<StateOperator<T> | T>\n): StateOperator<T> {\n return function iifOperator(existing: ExistingState<T>): T {\n // Convert the value to a boolean\n let result = !!condition;\n // but if it is a function then run it to get the result\n if (isPredicate(condition)) {\n result = condition(existing as T);\n }\n\n if (result) {\n return retrieveValue<T>(trueOperatorOrValue as StateOperator<T> | T, existing);\n }\n\n return retrieveValue<T>(elseOperatorOrValue! as StateOperator<T> | T, existing);\n };\n}\n","import { ExistingState, NoInfer, StateOperator } from './types';\nimport { isNil } from './utils';\n\n/**\n * @param value - Value to insert\n * @param [beforePosition] - Specified index to insert value before, optional\n */\nexport function insertItem<T>(value: NoInfer<T>, beforePosition?: number): StateOperator<T[]> {\n return function insertItemOperator(existing: ExistingState<T[]>): T[] {\n // Have to check explicitly for `null` and `undefined`\n // because `value` can be `0`, thus `!value` will return `true`\n if (isNil(value) && existing) {\n return existing as T[];\n }\n\n // Property may be dynamic and might not existed before\n if (!Array.isArray(existing)) {\n return [(value as unknown) as T];\n }\n\n const clone = existing.slice();\n\n let index = 0;\n\n // No need to call `isNumber`\n // as we are checking `> 0` not `>= 0`\n // everything except number will return false here\n if (beforePosition! > 0) {\n index = beforePosition!;\n }\n\n clone.splice(index, 0, (value as unknown) as T);\n return clone;\n };\n}\n","import { ExistingState, NoInfer, StateOperator } from './types';\nimport { isStateOperator } from './utils';\n\ntype NotUndefined<T> = T extends undefined ? never : T;\n\nexport type PatchSpec<T> = { [P in keyof T]?: T[P] | StateOperator<NotUndefined<T[P]>> };\n\nexport function patch<T extends Record<string, any>>(\n patchObject: NoInfer<PatchSpec<T>>\n): StateOperator<T> {\n return function patchStateOperator(existing: ExistingState<T>): T {\n let clone = null;\n for (const k in patchObject) {\n const newValue = patchObject[k];\n const existingPropValue = existing[k];\n const newPropValue = isStateOperator(newValue)\n ? newValue(<any>existingPropValue)\n : newValue;\n if (newPropValue !== existingPropValue) {\n if (!clone) {\n clone = { ...(<any>existing) };\n }\n clone[k] = newPropValue;\n }\n }\n return clone || existing;\n };\n}\n","import { ExistingState, NoInfer, StateOperator } from './types';\n\nimport { isStateOperator, isPredicate, isNumber, invalidIndex, Predicate } from './utils';\n\n/**\n * @param selector - Index of item in the array or a predicate function\n * that can be provided in `Array.prototype.findIndex`\n * @param operatorOrValue - New value under the `selector` index or a\n * function that can be applied to an existing value\n */\nexport function updateItem<T>(\n selector: number | NoInfer<Predicate<T>>,\n operatorOrValue: NoInfer<T> | NoInfer<StateOperator<T>>\n): StateOperator<T[]> {\n return function updateItemOperator(existing: ExistingState<T[]>): T[] {\n let index = -1;\n\n if (isPredicate(selector)) {\n index = existing.findIndex(selector as Predicate<T>);\n } else if (isNumber(selector)) {\n index = selector;\n }\n\n if (invalidIndex(index)) {\n return existing as T[];\n }\n\n let value: T = null!;\n // Need to check if the new item value will change the existing item value\n // then, only if it will change it then clone the array and set the item\n const theOperatorOrValue = operatorOrValue as T | StateOperator<T>;\n if (isStateOperator(theOperatorOrValue)) {\n value = theOperatorOrValue(existing[index] as ExistingState<T>);\n } else {\n value = theOperatorOrValue;\n }\n\n // If the value hasn't been mutated\n // then we just return `existing` array\n if (value === existing[index]) {\n return existing as T[];\n }\n\n const clone = existing.slice();\n clone[index] = value as T;\n return clone;\n };\n}\n","import { ExistingState, NoInfer, StateOperator } from './types';\nimport { isPredicate, isNumber, invalidIndex, Predicate } from './utils';\n\n/**\n * @param selector - index or predicate to remove an item from an array by\n */\nexport function removeItem<T>(selector: number | NoInfer<Predicate<T>>): StateOperator<T[]> {\n return function removeItemOperator(existing: ExistingState<T[]>): T[] {\n let index = -1;\n\n if (isPredicate(selector)) {\n index = existing.findIndex(selector);\n } else if (isNumber(selector)) {\n index = selector;\n }\n\n if (invalidIndex(index)) {\n return existing as T[];\n }\n\n const clone = existing.slice();\n clone.splice(index, 1);\n return clone;\n };\n}\n"],"names":[],"mappings":";;;;;;;;;AAKA,SAAgB,MAAM,CAAI,KAAmB;IAC3C;;;;IAAO,SAAS,cAAc,CAAC,QAA4B;;;;cAGnD,6BAA6B,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,QAAQ;QAC3E,IAAI,6BAA6B,EAAE;YACjC,8CAAQ,QAAQ,MAAoB;SACrC;QAED,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;YAC3B,OAAO,QAAQ,CAAC,MAAM,wCAAE,KAAK,MAAmC,CAAC;SAClE;;;QAID,8CAAQ,KAAK,MAAoB;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;YACzD,KAAK,GAAG,CAAC,CAAC;QAEd,IAAI,WAAW,CAAC,QAAQ,CAAC,EAAE;YACzB,KAAK,GAAG,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;SACtC;aAAM,IAAI,QAAQ,CAAC,QAAQ,CAAC,EAAE;YAC7B,KAAK,GAAG,QAAQ,CAAC;SAClB;QAED,IAAI,YAAY,CAAC,KAAK,CAAC,EAAE;YACvB,0BAAO,QAAQ,GAAQ;SACxB;;cAEK,KAAK,GAAG,QAAQ,CAAC,KAAK,EAAE;QAC9B,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QACvB,OAAO,KAAK,CAAC;KACd,EAAC;CACH;;;;;;;;;;;;;;"}
|
package/fesm2015/ngxs-store.js
CHANGED
|
@@ -2210,7 +2210,7 @@ class StateContextFactory {
|
|
|
2210
2210
|
/** @type {?} */
|
|
2211
2211
|
const local = getState(currentAppState);
|
|
2212
2212
|
/** @type {?} */
|
|
2213
|
-
const newValue = stateOperator(local);
|
|
2213
|
+
const newValue = stateOperator((/** @type {?} */ (local)));
|
|
2214
2214
|
return setStateValue(currentAppState, newValue);
|
|
2215
2215
|
}
|
|
2216
2216
|
/**
|
|
@@ -2360,6 +2360,133 @@ function ensureStateClassIsInjectable(stateClass) {
|
|
|
2360
2360
|
}
|
|
2361
2361
|
}
|
|
2362
2362
|
|
|
2363
|
+
/**
|
|
2364
|
+
* @fileoverview added by tsickle
|
|
2365
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2366
|
+
*/
|
|
2367
|
+
/**
|
|
2368
|
+
* Init action
|
|
2369
|
+
*/
|
|
2370
|
+
class InitState {
|
|
2371
|
+
/**
|
|
2372
|
+
* @return {?}
|
|
2373
|
+
*/
|
|
2374
|
+
static get type() {
|
|
2375
|
+
// NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
|
|
2376
|
+
return '@@INIT';
|
|
2377
|
+
}
|
|
2378
|
+
}
|
|
2379
|
+
/**
|
|
2380
|
+
* Update action
|
|
2381
|
+
*/
|
|
2382
|
+
class UpdateState {
|
|
2383
|
+
/**
|
|
2384
|
+
* @param {?=} addedStates
|
|
2385
|
+
*/
|
|
2386
|
+
constructor(addedStates) {
|
|
2387
|
+
this.addedStates = addedStates;
|
|
2388
|
+
}
|
|
2389
|
+
/**
|
|
2390
|
+
* @return {?}
|
|
2391
|
+
*/
|
|
2392
|
+
static get type() {
|
|
2393
|
+
// NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
|
|
2394
|
+
return '@@UPDATE_STATE';
|
|
2395
|
+
}
|
|
2396
|
+
}
|
|
2397
|
+
if (false) {
|
|
2398
|
+
/** @type {?} */
|
|
2399
|
+
UpdateState.prototype.addedStates;
|
|
2400
|
+
}
|
|
2401
|
+
|
|
2402
|
+
/**
|
|
2403
|
+
* @fileoverview added by tsickle
|
|
2404
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2405
|
+
*/
|
|
2406
|
+
/**
|
|
2407
|
+
* @record
|
|
2408
|
+
*/
|
|
2409
|
+
function NgxsDevelopmentOptions() { }
|
|
2410
|
+
if (false) {
|
|
2411
|
+
/** @type {?} */
|
|
2412
|
+
NgxsDevelopmentOptions.prototype.warnOnUnhandledActions;
|
|
2413
|
+
}
|
|
2414
|
+
/** @type {?} */
|
|
2415
|
+
const NGXS_DEVELOPMENT_OPTIONS = new InjectionToken('NGXS_DEVELOPMENT_OPTIONS', {
|
|
2416
|
+
providedIn: 'root',
|
|
2417
|
+
factory: (/**
|
|
2418
|
+
* @return {?}
|
|
2419
|
+
*/
|
|
2420
|
+
() => ({
|
|
2421
|
+
warnOnUnhandledActions: { ignore: [] }
|
|
2422
|
+
}))
|
|
2423
|
+
});
|
|
2424
|
+
|
|
2425
|
+
/**
|
|
2426
|
+
* @fileoverview added by tsickle
|
|
2427
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2428
|
+
*/
|
|
2429
|
+
class NgxsUnhandledActionsLogger {
|
|
2430
|
+
/**
|
|
2431
|
+
* @param {?} options
|
|
2432
|
+
*/
|
|
2433
|
+
constructor(options) {
|
|
2434
|
+
/**
|
|
2435
|
+
* These actions should be ignored by default; the user can increase this
|
|
2436
|
+
* list in the future via the `ignoreActions` method.
|
|
2437
|
+
*/
|
|
2438
|
+
this._ignoredActions = new Set([InitState.type, UpdateState.type]);
|
|
2439
|
+
this.ignoreActions(...options.warnOnUnhandledActions.ignore);
|
|
2440
|
+
}
|
|
2441
|
+
/**
|
|
2442
|
+
* Adds actions to the internal list of actions that should be ignored.
|
|
2443
|
+
* @param {...?} actions
|
|
2444
|
+
* @return {?}
|
|
2445
|
+
*/
|
|
2446
|
+
ignoreActions(...actions) {
|
|
2447
|
+
for (const action of actions) {
|
|
2448
|
+
this._ignoredActions.add(action.type);
|
|
2449
|
+
}
|
|
2450
|
+
}
|
|
2451
|
+
/**
|
|
2452
|
+
* \@internal
|
|
2453
|
+
* @param {?} action
|
|
2454
|
+
* @return {?}
|
|
2455
|
+
*/
|
|
2456
|
+
warn(action) {
|
|
2457
|
+
/** @type {?} */
|
|
2458
|
+
const actionShouldBeIgnored = Array.from(this._ignoredActions).some((/**
|
|
2459
|
+
* @param {?} type
|
|
2460
|
+
* @return {?}
|
|
2461
|
+
*/
|
|
2462
|
+
type => type === getActionTypeFromInstance(action)));
|
|
2463
|
+
if (actionShouldBeIgnored) {
|
|
2464
|
+
return;
|
|
2465
|
+
}
|
|
2466
|
+
action =
|
|
2467
|
+
action.constructor && action.constructor.name !== 'Object'
|
|
2468
|
+
? action.constructor.name
|
|
2469
|
+
: action.type;
|
|
2470
|
+
console.warn(`The ${action} action has been dispatched but hasn't been handled. This may happen if the state with an action handler for this action is not registered.`);
|
|
2471
|
+
}
|
|
2472
|
+
}
|
|
2473
|
+
NgxsUnhandledActionsLogger.decorators = [
|
|
2474
|
+
{ type: Injectable }
|
|
2475
|
+
];
|
|
2476
|
+
/** @nocollapse */
|
|
2477
|
+
NgxsUnhandledActionsLogger.ctorParameters = () => [
|
|
2478
|
+
{ type: undefined, decorators: [{ type: Inject, args: [NGXS_DEVELOPMENT_OPTIONS,] }] }
|
|
2479
|
+
];
|
|
2480
|
+
if (false) {
|
|
2481
|
+
/**
|
|
2482
|
+
* These actions should be ignored by default; the user can increase this
|
|
2483
|
+
* list in the future via the `ignoreActions` method.
|
|
2484
|
+
* @type {?}
|
|
2485
|
+
* @private
|
|
2486
|
+
*/
|
|
2487
|
+
NgxsUnhandledActionsLogger.prototype._ignoredActions;
|
|
2488
|
+
}
|
|
2489
|
+
|
|
2363
2490
|
/**
|
|
2364
2491
|
* @fileoverview added by tsickle
|
|
2365
2492
|
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
@@ -2489,10 +2616,8 @@ class StateFactory {
|
|
|
2489
2616
|
* @return {?}
|
|
2490
2617
|
*/
|
|
2491
2618
|
ngOnDestroy() {
|
|
2492
|
-
//
|
|
2493
|
-
//
|
|
2494
|
-
// on the `StateFactory` until its initialized :) An it's initialized
|
|
2495
|
-
// for the first time along with the `NgxsRootModule`.
|
|
2619
|
+
// This is being non-null asserted since `_actionsSubscrition` is
|
|
2620
|
+
// initialized within the constructor.
|
|
2496
2621
|
(/** @type {?} */ (this._actionsSubscription)).unsubscribe();
|
|
2497
2622
|
}
|
|
2498
2623
|
/**
|
|
@@ -2620,6 +2745,10 @@ class StateFactory {
|
|
|
2620
2745
|
const type = (/** @type {?} */ (getActionTypeFromInstance(action)));
|
|
2621
2746
|
/** @type {?} */
|
|
2622
2747
|
const results = [];
|
|
2748
|
+
// Determines whether the dispatched action has been handled, this is assigned
|
|
2749
|
+
// to `true` within the below `for` loop if any `actionMetas` has been found.
|
|
2750
|
+
/** @type {?} */
|
|
2751
|
+
let actionHasBeenHandled = false;
|
|
2623
2752
|
for (const metadata of this.states) {
|
|
2624
2753
|
/** @type {?} */
|
|
2625
2754
|
const actionMetas = metadata.actions[type];
|
|
@@ -2668,9 +2797,22 @@ class StateFactory {
|
|
|
2668
2797
|
catch (e) {
|
|
2669
2798
|
results.push(throwError(e));
|
|
2670
2799
|
}
|
|
2800
|
+
actionHasBeenHandled = true;
|
|
2671
2801
|
}
|
|
2672
2802
|
}
|
|
2673
2803
|
}
|
|
2804
|
+
// The `NgxsUnhandledActionsLogger` is a tree-shakable class which functions
|
|
2805
|
+
// only during development.
|
|
2806
|
+
if ((typeof ngDevMode === 'undefined' || ngDevMode) && !actionHasBeenHandled) {
|
|
2807
|
+
/** @type {?} */
|
|
2808
|
+
const unhandledActionsLogger = this._injector.get(NgxsUnhandledActionsLogger, null);
|
|
2809
|
+
// The `NgxsUnhandledActionsLogger` will not be resolved by the injector if the
|
|
2810
|
+
// `NgxsDevelopmentModule` is not provided. It's enough to check whether the `injector.get`
|
|
2811
|
+
// didn't return `null` so we may ensure the module has been imported.
|
|
2812
|
+
if (unhandledActionsLogger) {
|
|
2813
|
+
unhandledActionsLogger.warn(action);
|
|
2814
|
+
}
|
|
2815
|
+
}
|
|
2674
2816
|
if (!results.length) {
|
|
2675
2817
|
results.push(of({}));
|
|
2676
2818
|
}
|
|
@@ -3409,45 +3551,6 @@ if (false) {
|
|
|
3409
3551
|
SelectFactory.config;
|
|
3410
3552
|
}
|
|
3411
3553
|
|
|
3412
|
-
/**
|
|
3413
|
-
* @fileoverview added by tsickle
|
|
3414
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
3415
|
-
*/
|
|
3416
|
-
/**
|
|
3417
|
-
* Init action
|
|
3418
|
-
*/
|
|
3419
|
-
class InitState {
|
|
3420
|
-
/**
|
|
3421
|
-
* @return {?}
|
|
3422
|
-
*/
|
|
3423
|
-
static get type() {
|
|
3424
|
-
// NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
|
|
3425
|
-
return '@@INIT';
|
|
3426
|
-
}
|
|
3427
|
-
}
|
|
3428
|
-
/**
|
|
3429
|
-
* Update action
|
|
3430
|
-
*/
|
|
3431
|
-
class UpdateState {
|
|
3432
|
-
/**
|
|
3433
|
-
* @param {?=} addedStates
|
|
3434
|
-
*/
|
|
3435
|
-
constructor(addedStates) {
|
|
3436
|
-
this.addedStates = addedStates;
|
|
3437
|
-
}
|
|
3438
|
-
/**
|
|
3439
|
-
* @return {?}
|
|
3440
|
-
*/
|
|
3441
|
-
static get type() {
|
|
3442
|
-
// NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
|
|
3443
|
-
return '@@UPDATE_STATE';
|
|
3444
|
-
}
|
|
3445
|
-
}
|
|
3446
|
-
if (false) {
|
|
3447
|
-
/** @type {?} */
|
|
3448
|
-
UpdateState.prototype.addedStates;
|
|
3449
|
-
}
|
|
3450
|
-
|
|
3451
3554
|
/**
|
|
3452
3555
|
* @fileoverview added by tsickle
|
|
3453
3556
|
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
@@ -4094,6 +4197,29 @@ if (false) {
|
|
|
4094
4197
|
StateToken.prototype.name;
|
|
4095
4198
|
}
|
|
4096
4199
|
|
|
4200
|
+
/**
|
|
4201
|
+
* @fileoverview added by tsickle
|
|
4202
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
4203
|
+
*/
|
|
4204
|
+
class NgxsDevelopmentModule {
|
|
4205
|
+
/**
|
|
4206
|
+
* @param {?} options
|
|
4207
|
+
* @return {?}
|
|
4208
|
+
*/
|
|
4209
|
+
static forRoot(options) {
|
|
4210
|
+
return {
|
|
4211
|
+
ngModule: NgxsDevelopmentModule,
|
|
4212
|
+
providers: [
|
|
4213
|
+
NgxsUnhandledActionsLogger,
|
|
4214
|
+
{ provide: NGXS_DEVELOPMENT_OPTIONS, useValue: options }
|
|
4215
|
+
]
|
|
4216
|
+
};
|
|
4217
|
+
}
|
|
4218
|
+
}
|
|
4219
|
+
NgxsDevelopmentModule.decorators = [
|
|
4220
|
+
{ type: NgModule }
|
|
4221
|
+
];
|
|
4222
|
+
|
|
4097
4223
|
/**
|
|
4098
4224
|
* @fileoverview added by tsickle
|
|
4099
4225
|
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
@@ -4114,5 +4240,5 @@ if (false) {
|
|
|
4114
4240
|
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
4115
4241
|
*/
|
|
4116
4242
|
|
|
4117
|
-
export { Action, Actions, InitState, NGXS_PLUGINS, NgxsModule, NgxsSimpleChange, NoopNgxsExecutionStrategy, Select, Selector, SelectorOptions, State, StateStream, StateToken, Store, UpdateState, actionMatcher, createSelector, ensureSelectorMetadata$1 as ensureSelectorMetadata, ensureStoreMetadata$1 as ensureStoreMetadata, getActionTypeFromInstance, getSelectorMetadata$1 as getSelectorMetadata, getStoreMetadata$1 as getStoreMetadata, getValue, ofAction, ofActionCanceled, ofActionCompleted, ofActionDispatched, ofActionErrored, ofActionSuccessful, setValue, OrderedSubject as ɵa, InternalActions as ɵb, ROOT_STATE_TOKEN as ɵc, FEATURE_STATE_TOKEN as ɵd, SELECTOR_META_KEY as ɵe, NgxsConfig as ɵf, mergeDeep as ɵg, USER_PROVIDED_NGXS_EXECUTION_STRATEGY as ɵh, NGXS_EXECUTION_STRATEGY as ɵi,
|
|
4243
|
+
export { Action, Actions, InitState, NGXS_PLUGINS, NgxsDevelopmentModule, NgxsModule, NgxsSimpleChange, NgxsUnhandledActionsLogger, NoopNgxsExecutionStrategy, Select, Selector, SelectorOptions, State, StateStream, StateToken, Store, UpdateState, actionMatcher, createSelector, ensureSelectorMetadata$1 as ensureSelectorMetadata, ensureStoreMetadata$1 as ensureStoreMetadata, getActionTypeFromInstance, getSelectorMetadata$1 as getSelectorMetadata, getStoreMetadata$1 as getStoreMetadata, getValue, ofAction, ofActionCanceled, ofActionCompleted, ofActionDispatched, ofActionErrored, ofActionSuccessful, setValue, OrderedSubject as ɵa, InternalActions as ɵb, NgxsFeatureModule as ɵba, ROOT_STATE_TOKEN as ɵc, FEATURE_STATE_TOKEN as ɵd, SELECTOR_META_KEY as ɵe, NgxsConfig as ɵf, mergeDeep as ɵg, USER_PROVIDED_NGXS_EXECUTION_STRATEGY as ɵh, NGXS_EXECUTION_STRATEGY as ɵi, NGXS_DEVELOPMENT_OPTIONS as ɵj, NgxsRootModule as ɵk, StateFactory as ɵl, InternalDispatchedActionResults as ɵm, InternalDispatcher as ɵn, StateContextFactory as ɵo, InternalStateOperations as ɵp, PluginManager as ɵq, InternalNgxsExecutionStrategy as ɵr, InternalErrorReporter as ɵs, SelectFactory as ɵt, ensureStoreMetadata as ɵv, getStoreMetadata as ɵw, ensureSelectorMetadata as ɵx, getSelectorMetadata as ɵy, LifecycleStateManager as ɵz };
|
|
4118
4244
|
//# sourceMappingURL=ngxs-store.js.map
|