ngssm-navigation 19.2.2 → 19.3.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.
|
@@ -31,10 +31,10 @@ class NavigationLockedGuard {
|
|
|
31
31
|
canDeactivate() {
|
|
32
32
|
return this.store.state$.pipe(take(1), map((s) => !selectNavigationState(s).navigationLocked));
|
|
33
33
|
}
|
|
34
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.
|
|
35
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.
|
|
34
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.5", ngImport: i0, type: NavigationLockedGuard, deps: [{ token: i1.Store }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
35
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.5", ngImport: i0, type: NavigationLockedGuard, providedIn: 'root' }); }
|
|
36
36
|
}
|
|
37
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.
|
|
37
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.5", ngImport: i0, type: NavigationLockedGuard, decorators: [{
|
|
38
38
|
type: Injectable,
|
|
39
39
|
args: [{
|
|
40
40
|
providedIn: 'root'
|
|
@@ -75,10 +75,10 @@ class NavigationReducer {
|
|
|
75
75
|
}
|
|
76
76
|
return state;
|
|
77
77
|
}
|
|
78
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.
|
|
79
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.
|
|
78
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.5", ngImport: i0, type: NavigationReducer, deps: [{ token: NGSSM_NAVIGATION_LOCKING_CONFIG, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
79
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.5", ngImport: i0, type: NavigationReducer }); }
|
|
80
80
|
}
|
|
81
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.
|
|
81
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.5", ngImport: i0, type: NavigationReducer, decorators: [{
|
|
82
82
|
type: Injectable
|
|
83
83
|
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
84
84
|
type: Inject,
|
|
@@ -96,7 +96,13 @@ const routingEffectInitializer = async () => {
|
|
|
96
96
|
const routingAction = action;
|
|
97
97
|
if (routingAction.navigate) {
|
|
98
98
|
logger.information(`[Routing Effect] Processing action ${action.type}`);
|
|
99
|
-
|
|
99
|
+
try {
|
|
100
|
+
untracked(() => routingAction.navigate?.(store.state(), router));
|
|
101
|
+
logger.information(`[Routing Effect] Successfully navigated for action ${action.type}`);
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
logger.error(`[Routing Effect] Error while processing action ${action.type}: ${error}`);
|
|
105
|
+
}
|
|
100
106
|
}
|
|
101
107
|
});
|
|
102
108
|
return true;
|
|
@@ -123,5 +129,5 @@ const provideNgssmNavigation = () => {
|
|
|
123
129
|
* Generated bundle index. Do not edit.
|
|
124
130
|
*/
|
|
125
131
|
|
|
126
|
-
export { NGSSM_NAVIGATION_LOCKING_CONFIG, NavigationActionType, NavigationLockedGuard, NavigationStateSpecification, isNavigationLocked, isNavigationUnLocked, provideNgssmNavigation, selectNavigationState, updateNavigationState };
|
|
132
|
+
export { NGSSM_NAVIGATION_LOCKING_CONFIG, NavigationActionType, NavigationLockedGuard, NavigationStateSpecification, isNavigationLocked, isNavigationUnLocked, provideNgssmNavigation, routingEffectInitializer, selectNavigationState, updateNavigationState };
|
|
127
133
|
//# sourceMappingURL=ngssm-navigation.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngssm-navigation.mjs","sources":["../../../projects/ngssm-navigation/src/lib/state/navigation.state.ts","../../../projects/ngssm-navigation/src/lib/guards/navigation-locked.guard.ts","../../../projects/ngssm-navigation/src/lib/actions/navigation-action-type.ts","../../../projects/ngssm-navigation/src/lib/model/navigation-locking-config.ts","../../../projects/ngssm-navigation/src/lib/reducers/navigation.reducer.ts","../../../projects/ngssm-navigation/src/lib/routing/routing-effect.ts","../../../projects/ngssm-navigation/src/lib/provide-ngssm-navigation.ts","../../../projects/ngssm-navigation/src/public-api.ts","../../../projects/ngssm-navigation/src/ngssm-navigation.ts"],"sourcesContent":["import update, { Spec } from 'immutability-helper';\n\nimport { NgSsmFeatureState, State } from 'ngssm-store';\n\nexport const selectNavigationState = (state: State): NavigationState =>\n state[NavigationStateSpecification.featureStateKey] as NavigationState;\n\nexport const updateNavigationState = (state: State, command: Spec<NavigationState, never>): State =>\n update(state, {\n [NavigationStateSpecification.featureStateKey]: command\n });\n\nexport interface NavigationState {\n navigationLocked: boolean;\n}\n\n@NgSsmFeatureState({\n featureStateKey: NavigationStateSpecification.featureStateKey,\n initialState: NavigationStateSpecification.initialState\n})\nexport class NavigationStateSpecification {\n public static readonly featureStateKey = 'navigation-state';\n public static readonly initialState: NavigationState = {\n navigationLocked: false\n };\n}\n","import { inject, Injectable } from '@angular/core';\nimport { map, Observable, take } from 'rxjs';\n\nimport { Store } from 'ngssm-store';\n\nimport { selectNavigationState } from '../state';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class NavigationLockedGuard {\n constructor(private store: Store) {}\n\n public canDeactivate(): Observable<boolean> {\n return this.store.state$.pipe(\n take(1),\n map((s) => !selectNavigationState(s).navigationLocked)\n );\n }\n}\n\nexport const isNavigationLocked = (store = inject(Store)): Observable<boolean> =>\n store.state$.pipe(\n take(1),\n map((s) => selectNavigationState(s).navigationLocked)\n );\n\nexport const isNavigationUnLocked = (store = inject(Store)): Observable<boolean> =>\n store.state$.pipe(\n take(1),\n map((s) => !selectNavigationState(s).navigationLocked)\n );\n","export enum NavigationActionType {\n lockNavigation = '[NavigationActionType] lockNavigation',\n unLockNavigation = '[NavigationActionType] unLockNavigation'\n}\n","import { InjectionToken } from '@angular/core';\n\nexport interface NavigationLockingConfig {\n actionsLockingNavigation?: string[];\n actionsUnLockingNavigation?: string[];\n}\n\nexport const NGSSM_NAVIGATION_LOCKING_CONFIG = new InjectionToken<NavigationLockingConfig>('NGSSM_NAVIGATION_LOCKING_CONFIG');\n","import { Inject, Injectable, Optional } from '@angular/core';\n\nimport { Reducer, State, Action } from 'ngssm-store';\n\nimport { NavigationActionType } from '../actions';\nimport { NavigationLockingConfig, NGSSM_NAVIGATION_LOCKING_CONFIG } from '../model';\nimport { updateNavigationState } from '../state';\n\n@Injectable()\nexport class NavigationReducer implements Reducer {\n private readonly lockingActions: Set<string>;\n private readonly unlockingActions: Set<string>;\n\n public readonly processedActions: string[] = [];\n\n constructor(\n @Inject(NGSSM_NAVIGATION_LOCKING_CONFIG)\n @Optional()\n configs: NavigationLockingConfig[]\n ) {\n this.lockingActions = new Set<string>([NavigationActionType.lockNavigation]);\n this.unlockingActions = new Set<string>([NavigationActionType.unLockNavigation]);\n\n (configs ?? []).forEach((config) => {\n (config.actionsLockingNavigation ?? []).forEach((command) => this.lockingActions.add(command));\n (config.actionsUnLockingNavigation ?? []).forEach((command) => this.unlockingActions.add(command));\n });\n\n this.processedActions = [...this.lockingActions, ...this.unlockingActions];\n }\n\n public updateState(state: State, action: Action): State {\n if (this.lockingActions.has(action.type)) {\n return updateNavigationState(state, {\n navigationLocked: { $set: true }\n });\n }\n\n if (this.unlockingActions.has(action.type)) {\n return updateNavigationState(state, {\n navigationLocked: { $set: false }\n });\n }\n\n return state;\n }\n}\n","import { effect, inject, untracked } from '@angular/core';\nimport { Router } from '@angular/router';\n\nimport { Logger, Store } from 'ngssm-store';\n\nimport { RoutingAction } from './routing-action';\n\nexport const routingEffectInitializer = async () => {\n const store = inject(Store);\n const router = inject(Router);\n const logger = inject(Logger);\n\n effect(() => {\n const action = store.processedAction();\n const routingAction = action as RoutingAction;\n if (routingAction.navigate) {\n logger.information(`[Routing Effect] Processing action ${action.type}`);\n untracked(() => routingAction.navigate?.(store.state(), router));\n }\n });\n\n return true;\n};\n","import { EnvironmentProviders, makeEnvironmentProviders, inject, provideAppInitializer } from '@angular/core';\nimport { Router } from '@angular/router';\n\nimport { provideReducer } from 'ngssm-store';\n\nimport { isNavigationUnLocked } from './guards';\nimport { NavigationReducer } from './reducers/navigation.reducer';\nimport { routingEffectInitializer } from './routing';\n\nconst initializeNavigation = () => {\n inject(Router).config.forEach((route) => {\n route.canDeactivate = [() => isNavigationUnLocked(), ...(route.canDeactivate ?? [])];\n });\n};\n\nexport const provideNgssmNavigation = (): EnvironmentProviders => {\n return makeEnvironmentProviders([\n provideReducer(NavigationReducer),\n provideAppInitializer(initializeNavigation),\n provideAppInitializer(routingEffectInitializer)\n ]);\n};\n","/*\n * Public API Surface of ngssm-navigation\n */\n\nexport * from './lib/provide-ngssm-navigation';\nexport * from './lib/state';\nexport * from './lib/guards';\nexport * from './lib/actions';\nexport * from './lib/model';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;AAIO,MAAM,qBAAqB,GAAG,CAAC,KAAY,KAChD,KAAK,CAAC,4BAA4B,CAAC,eAAe;AAE7C,MAAM,qBAAqB,GAAG,CAAC,KAAY,EAAE,OAAqC,KACvF,MAAM,CAAC,KAAK,EAAE;AACZ,IAAA,CAAC,4BAA4B,CAAC,eAAe,GAAG;AACjD,CAAA;AAUU,IAAA,4BAA4B,GAAlC,MAAM,4BAA4B,CAAA;aAChB,IAAe,CAAA,eAAA,GAAG,kBAAH,CAAsB;AACrC,IAAA,SAAA,IAAA,CAAA,YAAY,GAAoB;AACrD,QAAA,gBAAgB,EAAE;AACnB,KAFkC,CAEjC;;AAJS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AAE,CAAA,CAAC;AACvE,YAAA,SAAS,CAAC,MAAM,aAAa,CAAC,QAAQ,GAAG,KAAK,CAAC,KAAK,EAAE,EAAE,MAAM,CAAC,CAAC;;AAEpE,KAAC,CAAC;AAEF,IAAA,OAAO,IAAI;AACb,CAAC;;ACbD,MAAM,oBAAoB,GAAG,MAAK;IAChC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,KAAI;AACtC,QAAA,KAAK,CAAC,aAAa,GAAG,CAAC,MAAM,oBAAoB,EAAE,EAAE,IAAI,KAAK,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC;AACtF,KAAC,CAAC;AACJ,CAAC;AAEM,MAAM,sBAAsB,GAAG,MAA2B;AAC/D,IAAA,OAAO,wBAAwB,CAAC;QAC9B,cAAc,CAAC,iBAAiB,CAAC;QACjC,qBAAqB,CAAC,oBAAoB,CAAC;QAC3C,qBAAqB,CAAC,wBAAwB;AAC/C,KAAA,CAAC;AACJ;;ACrBA;;AAEG;;ACFH;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"ngssm-navigation.mjs","sources":["../../../projects/ngssm-navigation/src/lib/state/navigation.state.ts","../../../projects/ngssm-navigation/src/lib/guards/navigation-locked.guard.ts","../../../projects/ngssm-navigation/src/lib/actions/navigation-action-type.ts","../../../projects/ngssm-navigation/src/lib/model/navigation-locking-config.ts","../../../projects/ngssm-navigation/src/lib/reducers/navigation.reducer.ts","../../../projects/ngssm-navigation/src/lib/routing/routing-effect.ts","../../../projects/ngssm-navigation/src/lib/provide-ngssm-navigation.ts","../../../projects/ngssm-navigation/src/public-api.ts","../../../projects/ngssm-navigation/src/ngssm-navigation.ts"],"sourcesContent":["import update, { Spec } from 'immutability-helper';\n\nimport { NgSsmFeatureState, State } from 'ngssm-store';\n\nexport const selectNavigationState = (state: State): NavigationState =>\n state[NavigationStateSpecification.featureStateKey] as NavigationState;\n\nexport const updateNavigationState = (state: State, command: Spec<NavigationState, never>): State =>\n update(state, {\n [NavigationStateSpecification.featureStateKey]: command\n });\n\nexport interface NavigationState {\n navigationLocked: boolean;\n}\n\n@NgSsmFeatureState({\n featureStateKey: NavigationStateSpecification.featureStateKey,\n initialState: NavigationStateSpecification.initialState\n})\nexport class NavigationStateSpecification {\n public static readonly featureStateKey = 'navigation-state';\n public static readonly initialState: NavigationState = {\n navigationLocked: false\n };\n}\n","import { inject, Injectable } from '@angular/core';\nimport { map, Observable, take } from 'rxjs';\n\nimport { Store } from 'ngssm-store';\n\nimport { selectNavigationState } from '../state';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class NavigationLockedGuard {\n constructor(private store: Store) {}\n\n public canDeactivate(): Observable<boolean> {\n return this.store.state$.pipe(\n take(1),\n map((s) => !selectNavigationState(s).navigationLocked)\n );\n }\n}\n\nexport const isNavigationLocked = (store = inject(Store)): Observable<boolean> =>\n store.state$.pipe(\n take(1),\n map((s) => selectNavigationState(s).navigationLocked)\n );\n\nexport const isNavigationUnLocked = (store = inject(Store)): Observable<boolean> =>\n store.state$.pipe(\n take(1),\n map((s) => !selectNavigationState(s).navigationLocked)\n );\n","export enum NavigationActionType {\n lockNavigation = '[NavigationActionType] lockNavigation',\n unLockNavigation = '[NavigationActionType] unLockNavigation'\n}\n","import { InjectionToken } from '@angular/core';\n\nexport interface NavigationLockingConfig {\n actionsLockingNavigation?: string[];\n actionsUnLockingNavigation?: string[];\n}\n\nexport const NGSSM_NAVIGATION_LOCKING_CONFIG = new InjectionToken<NavigationLockingConfig>('NGSSM_NAVIGATION_LOCKING_CONFIG');\n","import { Inject, Injectable, Optional } from '@angular/core';\n\nimport { Reducer, State, Action } from 'ngssm-store';\n\nimport { NavigationActionType } from '../actions';\nimport { NavigationLockingConfig, NGSSM_NAVIGATION_LOCKING_CONFIG } from '../model';\nimport { updateNavigationState } from '../state';\n\n@Injectable()\nexport class NavigationReducer implements Reducer {\n private readonly lockingActions: Set<string>;\n private readonly unlockingActions: Set<string>;\n\n public readonly processedActions: string[] = [];\n\n constructor(\n @Inject(NGSSM_NAVIGATION_LOCKING_CONFIG)\n @Optional()\n configs: NavigationLockingConfig[]\n ) {\n this.lockingActions = new Set<string>([NavigationActionType.lockNavigation]);\n this.unlockingActions = new Set<string>([NavigationActionType.unLockNavigation]);\n\n (configs ?? []).forEach((config) => {\n (config.actionsLockingNavigation ?? []).forEach((command) => this.lockingActions.add(command));\n (config.actionsUnLockingNavigation ?? []).forEach((command) => this.unlockingActions.add(command));\n });\n\n this.processedActions = [...this.lockingActions, ...this.unlockingActions];\n }\n\n public updateState(state: State, action: Action): State {\n if (this.lockingActions.has(action.type)) {\n return updateNavigationState(state, {\n navigationLocked: { $set: true }\n });\n }\n\n if (this.unlockingActions.has(action.type)) {\n return updateNavigationState(state, {\n navigationLocked: { $set: false }\n });\n }\n\n return state;\n }\n}\n","import { effect, inject, untracked } from '@angular/core';\nimport { Router } from '@angular/router';\n\nimport { Logger, Store } from 'ngssm-store';\n\nimport { RoutingAction } from './routing-action';\n\nexport const routingEffectInitializer = async () => {\n const store = inject(Store);\n const router = inject(Router);\n const logger = inject(Logger);\n\n effect(() => {\n const action = store.processedAction();\n const routingAction = action as RoutingAction;\n if (routingAction.navigate) {\n logger.information(`[Routing Effect] Processing action ${action.type}`);\n try {\n untracked(() => routingAction.navigate?.(store.state(), router));\n logger.information(`[Routing Effect] Successfully navigated for action ${action.type}`);\n } catch (error) {\n logger.error(`[Routing Effect] Error while processing action ${action.type}: ${error}`);\n }\n }\n });\n\n return true;\n};\n","import { EnvironmentProviders, makeEnvironmentProviders, inject, provideAppInitializer } from '@angular/core';\nimport { Router } from '@angular/router';\n\nimport { provideReducer } from 'ngssm-store';\n\nimport { isNavigationUnLocked } from './guards';\nimport { NavigationReducer } from './reducers/navigation.reducer';\nimport { routingEffectInitializer } from './routing';\n\nconst initializeNavigation = () => {\n inject(Router).config.forEach((route) => {\n route.canDeactivate = [() => isNavigationUnLocked(), ...(route.canDeactivate ?? [])];\n });\n};\n\nexport const provideNgssmNavigation = (): EnvironmentProviders => {\n return makeEnvironmentProviders([\n provideReducer(NavigationReducer),\n provideAppInitializer(initializeNavigation),\n provideAppInitializer(routingEffectInitializer)\n ]);\n};\n","/*\n * Public API Surface of ngssm-navigation\n */\n\nexport * from './lib/provide-ngssm-navigation';\nexport * from './lib/state';\nexport * from './lib/guards';\nexport * from './lib/actions';\nexport * from './lib/model';\nexport * from './lib/routing';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;AAIO,MAAM,qBAAqB,GAAG,CAAC,KAAY,KAChD,KAAK,CAAC,4BAA4B,CAAC,eAAe;AAE7C,MAAM,qBAAqB,GAAG,CAAC,KAAY,EAAE,OAAqC,KACvF,MAAM,CAAC,KAAK,EAAE;AACZ,IAAA,CAAC,4BAA4B,CAAC,eAAe,GAAG;AACjD,CAAA;AAUU,IAAA,4BAA4B,GAAlC,MAAM,4BAA4B,CAAA;aAChB,IAAe,CAAA,eAAA,GAAG,kBAAH,CAAsB;AACrC,IAAA,SAAA,IAAA,CAAA,YAAY,GAAoB;AACrD,QAAA,gBAAgB,EAAE;AACnB,KAFkC,CAEjC;;AAJS,4BAA4B,GAAA,UAAA,CAAA;AAJxC,IAAA,iBAAiB,CAAC;QACjB,eAAe,EAAE,4BAA4B,CAAC,eAAe;QAC7D,YAAY,EAAE,4BAA4B,CAAC;KAC5C;AACY,CAAA,EAAA,4BAA4B,CAKxC;;MCfY,qBAAqB,CAAA;AAChC,IAAA,WAAA,CAAoB,KAAY,EAAA;QAAZ,IAAK,CAAA,KAAA,GAAL,KAAK;;IAElB,aAAa,GAAA;AAClB,QAAA,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAC3B,IAAI,CAAC,CAAC,CAAC,EACP,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CACvD;;8GAPQ,qBAAqB,EAA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CAAC,OAAO,CAAC,CAAC,KAAK,KAAI;AACtC,QAAA,KAAK,CAAC,aAAa,GAAG,CAAC,MAAM,oBAAoB,EAAE,EAAE,IAAI,KAAK,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC;AACtF,KAAC,CAAC;AACJ,CAAC;AAEM,MAAM,sBAAsB,GAAG,MAA2B;AAC/D,IAAA,OAAO,wBAAwB,CAAC;QAC9B,cAAc,CAAC,iBAAiB,CAAC;QACjC,qBAAqB,CAAC,oBAAoB,CAAC;QAC3C,qBAAqB,CAAC,wBAAwB;AAC/C,KAAA,CAAC;AACJ;;ACrBA;;AAEG;;ACFH;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ngssm-navigation",
|
|
3
|
-
"version": "19.
|
|
3
|
+
"version": "19.3.0",
|
|
4
4
|
"description": "NgSsm - Helpers to control angular navigation.",
|
|
5
5
|
"author": "Lion Marc",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"peerDependencies": {
|
|
8
8
|
"@angular/common": ">=18.0.0",
|
|
9
9
|
"@angular/core": ">=18.0.0",
|
|
10
|
-
"ngssm-store": "19.
|
|
10
|
+
"ngssm-store": "19.3.0"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"tslib": "^2.3.0"
|
package/public-api.d.ts
CHANGED