feat: compose executable frontend runtime
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
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,
|
||||
}),
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user