Line data Source code
1 : import { assert } from '@/base/assert'
2 : import type { ComfyApp } from '@/types/comfy'
3 :
4 2356 : let instance: ComfyApp | undefined
5 :
6 : /**
7 : * Called once by `@/scripts/app` after it constructs the singleton. Modules
8 : * that the app imports cannot import `@/scripts/app` back without a cycle, so
9 : * they reach the instance through `useApp` from `@/scripts/appInstance`.
10 : */
11 2356 : export function registerApp(app: ComfyApp) {
12 2356 : instance = app
13 : }
14 :
15 3034865 : export function useApp(): ComfyApp {
16 3034865 : assert(instance, 'ComfyApp accessed before registerApp')
17 3034865 : return instance
18 : }
|