2025-09-19 09:11:29 +00:00
|
|
|
import { Plugin } from "../plugin"
|
2026-03-21 04:51:35 +00:00
|
|
|
import { Format } from "../format"
|
2025-09-19 09:11:29 +00:00
|
|
|
import { LSP } from "../lsp"
|
2025-10-02 04:18:11 +00:00
|
|
|
import { File } from "../file"
|
2026-03-21 04:51:35 +00:00
|
|
|
import { Snapshot } from "../snapshot"
|
2026-04-16 03:41:34 +00:00
|
|
|
import * as Project from "./project"
|
|
|
|
|
import * as Vcs from "./vcs"
|
2025-11-01 06:14:09 +00:00
|
|
|
import { Bus } from "../bus"
|
|
|
|
|
import { Command } from "../command"
|
|
|
|
|
import { Instance } from "./instance"
|
2026-04-16 03:15:58 +00:00
|
|
|
import { Log } from "@/util"
|
2026-04-12 01:19:12 +00:00
|
|
|
import { FileWatcher } from "@/file/watcher"
|
2026-04-16 03:28:46 +00:00
|
|
|
import { ShareNext } from "@/share"
|
2026-04-13 14:16:40 +00:00
|
|
|
import * as Effect from "effect/Effect"
|
2026-04-16 20:21:47 +00:00
|
|
|
import { Config } from "@/config"
|
2025-09-19 09:11:29 +00:00
|
|
|
|
2026-04-13 14:16:40 +00:00
|
|
|
export const InstanceBootstrap = Effect.gen(function* () {
|
2025-11-09 01:17:46 +00:00
|
|
|
Log.Default.info("bootstrapping", { directory: Instance.directory })
|
2026-04-16 20:21:47 +00:00
|
|
|
// everything depends on config so eager load it for nice traces
|
|
|
|
|
yield* Config.Service.use((svc) => svc.get())
|
|
|
|
|
// Plugin can mutate config so it has to be initialized before anything else.
|
2026-04-16 01:14:39 +00:00
|
|
|
yield* Plugin.Service.use((svc) => svc.init())
|
2026-04-15 03:23:28 +00:00
|
|
|
yield* Effect.all(
|
|
|
|
|
[
|
|
|
|
|
LSP.Service,
|
|
|
|
|
ShareNext.Service,
|
|
|
|
|
Format.Service,
|
|
|
|
|
File.Service,
|
|
|
|
|
FileWatcher.Service,
|
|
|
|
|
Vcs.Service,
|
|
|
|
|
Snapshot.Service,
|
|
|
|
|
].map((s) => Effect.forkDetach(s.use((i) => i.init()))),
|
2026-04-16 06:03:03 +00:00
|
|
|
).pipe(Effect.withSpan("InstanceBootstrap.init"))
|
2025-11-01 06:14:09 +00:00
|
|
|
|
2026-04-13 14:16:40 +00:00
|
|
|
yield* Bus.Service.use((svc) =>
|
|
|
|
|
svc.subscribeCallback(Command.Event.Executed, async (payload) => {
|
|
|
|
|
if (payload.properties.name === Command.Default.INIT) {
|
|
|
|
|
Project.setInitialized(Instance.project.id)
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
)
|
|
|
|
|
}).pipe(Effect.withSpan("InstanceBootstrap"))
|