| 221 | } |
| 222 | |
| 223 | public resolveState( |
| 224 | config: { |
| 225 | value: StateValue; |
| 226 | context?: TContext; |
| 227 | historyValue?: HistoryValue<TContext, TEvent>; |
| 228 | status?: SnapshotStatus; |
| 229 | output?: TOutput; |
| 230 | error?: unknown; |
| 231 | } & (Equals<TContext, MachineContext> extends false |
| 232 | ? { context: unknown } |
| 233 | : {}) |
| 234 | ): MachineSnapshot< |
| 235 | TContext, |
| 236 | TEvent, |
| 237 | TChildren, |
| 238 | TStateValue, |
| 239 | TTag, |
| 240 | TOutput, |
| 241 | TMeta, |
| 242 | TStateSchema |
| 243 | > { |
| 244 | const resolvedStateValue = resolveStateValue(this.root, config.value); |
| 245 | const nodeSet = getAllStateNodes( |
| 246 | getStateNodes(this.root, resolvedStateValue) |
| 247 | ); |
| 248 | |
| 249 | return createMachineSnapshot( |
| 250 | { |
| 251 | _nodes: [...nodeSet], |
| 252 | context: config.context || ({} as TContext), |
| 253 | children: {}, |
| 254 | status: isInFinalState(nodeSet, this.root) |
| 255 | ? 'done' |
| 256 | : config.status || 'active', |
| 257 | output: config.output, |
| 258 | error: config.error, |
| 259 | historyValue: config.historyValue |
| 260 | }, |
| 261 | this |
| 262 | ) as MachineSnapshot< |
| 263 | TContext, |
| 264 | TEvent, |
| 265 | TChildren, |
| 266 | TStateValue, |
| 267 | TTag, |
| 268 | TOutput, |
| 269 | TMeta, |
| 270 | TStateSchema |
| 271 | >; |
| 272 | } |
| 273 | |
| 274 | /** |
| 275 | * Determines the next snapshot given the current `snapshot` and received |