(unit: any, payload?: any, upsert?: boolean)
| 235 | }): void |
| 236 | export function launch(unit: NodeUnit, payload?: any, upsert?: boolean): void |
| 237 | export function launch(unit: any, payload?: any, upsert?: boolean) { |
| 238 | let pageForLaunch = currentPage |
| 239 | let stackForLaunch = null |
| 240 | let forkPageForLaunch = forkPage |
| 241 | let meta: Record<string, any> | undefined |
| 242 | if (unit.target) { |
| 243 | payload = unit.params |
| 244 | upsert = unit.defer |
| 245 | meta = unit.meta |
| 246 | pageForLaunch = 'page' in unit ? unit.page : pageForLaunch |
| 247 | if (unit.stack) stackForLaunch = unit.stack |
| 248 | forkPageForLaunch = getForkPage(unit) || forkPageForLaunch |
| 249 | unit = unit.target |
| 250 | } |
| 251 | if (forkPageForLaunch && forkPage && forkPageForLaunch !== forkPage) { |
| 252 | forkPage = null |
| 253 | } |
| 254 | if (Array.isArray(unit)) { |
| 255 | for (let i = 0; i < unit.length; i++) { |
| 256 | pushFirstHeapItem( |
| 257 | 'pure', |
| 258 | pageForLaunch, |
| 259 | getGraph(unit[i]), |
| 260 | stackForLaunch, |
| 261 | payload[i], |
| 262 | forkPageForLaunch, |
| 263 | meta, |
| 264 | ) |
| 265 | } |
| 266 | } else { |
| 267 | pushFirstHeapItem( |
| 268 | 'pure', |
| 269 | pageForLaunch, |
| 270 | getGraph(unit), |
| 271 | stackForLaunch, |
| 272 | payload, |
| 273 | forkPageForLaunch, |
| 274 | meta, |
| 275 | ) |
| 276 | } |
| 277 | if (upsert && !isRoot) return |
| 278 | /** main execution code */ |
| 279 | const lastStartedState = { |
| 280 | isRoot, |
| 281 | currentPage, |
| 282 | scope: forkPage, |
| 283 | isWatch, |
| 284 | isPure, |
| 285 | } |
| 286 | isRoot = false |
| 287 | let stop: boolean |
| 288 | let skip: boolean |
| 289 | let node: Node |
| 290 | let value: Layer | undefined |
| 291 | let page: Leaf | null |
| 292 | let reg: Record<string, StateRef> | undefined |
| 293 | kernelLoop: while ((value = deleteMin())) { |
| 294 | const {idx, stack, type} = value |
searching dependent graphs…