33 lines
1.1 KiB
JavaScript
33 lines
1.1 KiB
JavaScript
import { createCompositionRoot } from "./composition-root.js";
|
|
import { loadReleaseManifest } from "./load-release-manifest.js";
|
|
import { loadRuntimeConfig } from "./load-runtime-config.js";
|
|
import { createRuntimeAdapters } from "./runtime-adapters.js";
|
|
|
|
/**
|
|
* @param {{
|
|
* fetcher?: typeof fetch,
|
|
* host?: Record<string, unknown>
|
|
* }} [dependencies]
|
|
*/
|
|
export function createRuntimeComposition(dependencies = {}) {
|
|
return createCompositionRoot({
|
|
loadConfig: () => loadRuntimeConfig({ fetcher: dependencies.fetcher }),
|
|
loadRelease: (runtime) =>
|
|
loadReleaseManifest(
|
|
/** @type {Awaited<ReturnType<typeof loadRuntimeConfig>>} */ (runtime),
|
|
{ fetcher: dependencies.fetcher },
|
|
),
|
|
createAdapters: ({ config: runtime, release }) =>
|
|
createRuntimeAdapters({
|
|
runtime:
|
|
/** @type {Awaited<ReturnType<typeof loadRuntimeConfig>>} */ (runtime),
|
|
release:
|
|
/** @type {Awaited<ReturnType<typeof loadReleaseManifest>>} */ (
|
|
release
|
|
),
|
|
fetcher: dependencies.fetcher,
|
|
host: dependencies.host,
|
|
}),
|
|
});
|
|
}
|