2025-09-01 21:15:49 +00:00
|
|
|
import { Instance } from "../project/instance"
|
2026-05-02 14:56:15 +00:00
|
|
|
import { InstanceStore } from "../project/instance-store"
|
2026-05-02 19:26:30 +00:00
|
|
|
import { getBootstrapRunEffect } from "../effect/app-runtime"
|
2025-06-27 15:29:20 +00:00
|
|
|
|
2025-09-01 21:15:49 +00:00
|
|
|
export async function bootstrap<T>(directory: string, cb: () => Promise<T>) {
|
2025-09-19 09:11:29 +00:00
|
|
|
return Instance.provide({
|
|
|
|
|
directory,
|
2026-05-02 19:26:30 +00:00
|
|
|
init: await getBootstrapRunEffect(),
|
2025-09-19 09:11:29 +00:00
|
|
|
fn: async () => {
|
2025-10-31 04:57:58 +00:00
|
|
|
try {
|
|
|
|
|
const result = await cb()
|
|
|
|
|
return result
|
|
|
|
|
} finally {
|
2026-05-02 15:21:40 +00:00
|
|
|
await InstanceStore.disposeInstance(Instance.current)
|
2025-10-31 04:57:58 +00:00
|
|
|
}
|
2025-09-19 09:11:29 +00:00
|
|
|
},
|
2025-06-27 15:29:20 +00:00
|
|
|
})
|
|
|
|
|
}
|