2022-08-18 16:23:16 +02:00
|
|
|
import { BrowserEnvironmentService } from "../../services/browser-environment.service";
|
|
|
|
|
|
|
|
import { CachedServices, factory, FactoryOptions } from "./factory-options";
|
|
|
|
import { logServiceFactory, LogServiceInitOptions } from "./log-service.factory";
|
|
|
|
import {
|
|
|
|
stateServiceFactory as stateServiceFactory,
|
|
|
|
StateServiceInitOptions,
|
|
|
|
} from "./state-service.factory";
|
|
|
|
|
|
|
|
type EnvironmentServiceFactoryOptions = FactoryOptions;
|
|
|
|
|
|
|
|
export type EnvironmentServiceInitOptions = EnvironmentServiceFactoryOptions &
|
|
|
|
StateServiceInitOptions &
|
|
|
|
LogServiceInitOptions;
|
|
|
|
|
|
|
|
export function environmentServiceFactory(
|
|
|
|
cache: { environmentService?: BrowserEnvironmentService } & CachedServices,
|
|
|
|
opts: EnvironmentServiceInitOptions
|
2022-08-29 20:46:42 +02:00
|
|
|
): Promise<BrowserEnvironmentService> {
|
2022-08-18 16:23:16 +02:00
|
|
|
return factory(
|
|
|
|
cache,
|
|
|
|
"environmentService",
|
|
|
|
opts,
|
2022-08-29 20:46:42 +02:00
|
|
|
async () =>
|
2022-08-18 16:23:16 +02:00
|
|
|
new BrowserEnvironmentService(
|
2022-08-29 20:46:42 +02:00
|
|
|
await stateServiceFactory(cache, opts),
|
|
|
|
await logServiceFactory(cache, opts)
|
2022-08-18 16:23:16 +02:00
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|