@player-ui/flow
Advanced tools
Comparing version 0.1.1-next.13 to 0.1.1-next.14
@@ -91,3 +91,3 @@ 'use strict'; | ||
transition(transitionValue, options) { | ||
var _a, _b, _c, _d; | ||
var _a, _b, _c, _d, _e, _f; | ||
if (((_a = this.currentState) == null ? void 0 : _a.value.state_type) === "END") { | ||
@@ -100,2 +100,11 @@ (_b = this.log) == null ? void 0 : _b.warn(`Skipping transition using ${transitionValue}. Already at and END state`); | ||
} | ||
if (options == null ? void 0 : options.force) { | ||
(_c = this.log) == null ? void 0 : _c.debug(`Forced transition. Skipping validation checks`); | ||
} else { | ||
const skipTransition = this.hooks.skipTransition.call(this.currentState); | ||
if (skipTransition) { | ||
(_d = this.log) == null ? void 0 : _d.debug(`Skipping transition from ${this.currentState} b/c hook told us to`); | ||
return; | ||
} | ||
} | ||
const state = this.hooks.beforeTransition.call(this.currentState.value, transitionValue); | ||
@@ -108,10 +117,10 @@ if (!("transitions" in state)) { | ||
if (nextState === void 0) { | ||
(_c = this.log) == null ? void 0 : _c.warn(`No transition from ${this.currentState.name} using ${transitionValue} or *`); | ||
(_e = this.log) == null ? void 0 : _e.warn(`No transition from ${this.currentState.name} using ${transitionValue} or *`); | ||
return; | ||
} | ||
(_d = this.log) == null ? void 0 : _d.debug(`Transitioning from ${this.currentState.name} to ${nextState} using ${transitionValue} `); | ||
(_f = this.log) == null ? void 0 : _f.debug(`Transitioning from ${this.currentState.name} to ${nextState} using ${transitionValue} `); | ||
return this.pushHistory(nextState, options); | ||
} | ||
pushHistory(stateName, options) { | ||
var _a, _b, _c; | ||
var _a; | ||
if (!Object.prototype.hasOwnProperty.call(this.flow, stateName)) { | ||
@@ -126,11 +135,2 @@ throw new Error(`No flow definition for: ${stateName} was found.`); | ||
const prevState = this.currentState; | ||
if (options == null ? void 0 : options.force) { | ||
(_b = this.log) == null ? void 0 : _b.debug(`Forced transition. Skipping validation checks`); | ||
} else { | ||
const skipTransition = this.hooks.skipTransition.call(prevState, stateName); | ||
if (skipTransition) { | ||
(_c = this.log) == null ? void 0 : _c.debug(`Skipping transition to ${stateName} b/c hook told us to`); | ||
return; | ||
} | ||
} | ||
nextState = this.hooks.resolveTransitionNode.call(nextState); | ||
@@ -137,0 +137,0 @@ const newCurrentState = { |
@@ -32,3 +32,3 @@ import * as _player_ui_types from '@player-ui/types'; | ||
/** A hook to intercept and block a transition */ | ||
skipTransition: SyncBailHook<[NamedState | undefined, string], boolean | undefined, Record<string, any>>; | ||
skipTransition: SyncBailHook<[NamedState | undefined], boolean | undefined, Record<string, any>>; | ||
/** A chance to manipulate the flow-node used to calculate the given transition used */ | ||
@@ -35,0 +35,0 @@ beforeTransition: SyncWaterfallHook<[_player_ui_types.NavigationFlowViewState | _player_ui_types.NavigationFlowFlowState | _player_ui_types.NavigationFlowActionState | _player_ui_types.NavigationFlowExternalState, string], Record<string, any>>; |
@@ -83,3 +83,3 @@ import { SyncBailHook, SyncHook, SyncWaterfallHook } from 'tapable-ts'; | ||
transition(transitionValue, options) { | ||
var _a, _b, _c, _d; | ||
var _a, _b, _c, _d, _e, _f; | ||
if (((_a = this.currentState) == null ? void 0 : _a.value.state_type) === "END") { | ||
@@ -92,2 +92,11 @@ (_b = this.log) == null ? void 0 : _b.warn(`Skipping transition using ${transitionValue}. Already at and END state`); | ||
} | ||
if (options == null ? void 0 : options.force) { | ||
(_c = this.log) == null ? void 0 : _c.debug(`Forced transition. Skipping validation checks`); | ||
} else { | ||
const skipTransition = this.hooks.skipTransition.call(this.currentState); | ||
if (skipTransition) { | ||
(_d = this.log) == null ? void 0 : _d.debug(`Skipping transition from ${this.currentState} b/c hook told us to`); | ||
return; | ||
} | ||
} | ||
const state = this.hooks.beforeTransition.call(this.currentState.value, transitionValue); | ||
@@ -100,10 +109,10 @@ if (!("transitions" in state)) { | ||
if (nextState === void 0) { | ||
(_c = this.log) == null ? void 0 : _c.warn(`No transition from ${this.currentState.name} using ${transitionValue} or *`); | ||
(_e = this.log) == null ? void 0 : _e.warn(`No transition from ${this.currentState.name} using ${transitionValue} or *`); | ||
return; | ||
} | ||
(_d = this.log) == null ? void 0 : _d.debug(`Transitioning from ${this.currentState.name} to ${nextState} using ${transitionValue} `); | ||
(_f = this.log) == null ? void 0 : _f.debug(`Transitioning from ${this.currentState.name} to ${nextState} using ${transitionValue} `); | ||
return this.pushHistory(nextState, options); | ||
} | ||
pushHistory(stateName, options) { | ||
var _a, _b, _c; | ||
var _a; | ||
if (!Object.prototype.hasOwnProperty.call(this.flow, stateName)) { | ||
@@ -118,11 +127,2 @@ throw new Error(`No flow definition for: ${stateName} was found.`); | ||
const prevState = this.currentState; | ||
if (options == null ? void 0 : options.force) { | ||
(_b = this.log) == null ? void 0 : _b.debug(`Forced transition. Skipping validation checks`); | ||
} else { | ||
const skipTransition = this.hooks.skipTransition.call(prevState, stateName); | ||
if (skipTransition) { | ||
(_c = this.log) == null ? void 0 : _c.debug(`Skipping transition to ${stateName} b/c hook told us to`); | ||
return; | ||
} | ||
} | ||
nextState = this.hooks.resolveTransitionNode.call(nextState); | ||
@@ -129,0 +129,0 @@ const newCurrentState = { |
{ | ||
"name": "@player-ui/flow", | ||
"version": "0.1.1-next.13", | ||
"version": "0.1.1-next.14", | ||
"private": false, | ||
@@ -10,4 +10,4 @@ "publishConfig": { | ||
"dependencies": { | ||
"@player-ui/logger": "0.1.1-next.13", | ||
"@player-ui/types": "0.1.1-next.13", | ||
"@player-ui/logger": "0.1.1-next.14", | ||
"@player-ui/types": "0.1.1-next.14", | ||
"tapable-ts": "^0.1.0", | ||
@@ -14,0 +14,0 @@ "p-defer": "^3.0.0", |
@@ -47,3 +47,3 @@ import { SyncBailHook, SyncHook, SyncWaterfallHook } from 'tapable-ts'; | ||
skipTransition: new SyncBailHook< | ||
[NamedState | undefined, string], | ||
[NamedState | undefined], | ||
boolean | undefined | ||
@@ -128,2 +128,15 @@ >(), | ||
if (options?.force) { | ||
this.log?.debug(`Forced transition. Skipping validation checks`); | ||
} else { | ||
const skipTransition = this.hooks.skipTransition.call(this.currentState); | ||
if (skipTransition) { | ||
this.log?.debug( | ||
`Skipping transition from ${this.currentState} b/c hook told us to` | ||
); | ||
return; | ||
} | ||
} | ||
const state = this.hooks.beforeTransition.call( | ||
@@ -175,19 +188,2 @@ this.currentState.value, | ||
if (options?.force) { | ||
this.log?.debug(`Forced transition. Skipping validation checks`); | ||
} else { | ||
const skipTransition = this.hooks.skipTransition.call( | ||
prevState, | ||
stateName | ||
); | ||
if (skipTransition) { | ||
this.log?.debug( | ||
`Skipping transition to ${stateName} b/c hook told us to` | ||
); | ||
return; | ||
} | ||
} | ||
nextState = this.hooks.resolveTransitionNode.call(nextState); | ||
@@ -194,0 +190,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29925
759
+ Added@player-ui/logger@0.1.1-next.14(transitive)
+ Added@player-ui/types@0.1.1-next.14(transitive)
- Removed@player-ui/logger@0.1.1-next.13(transitive)
- Removed@player-ui/types@0.1.1-next.13(transitive)