this repo has no description
at main 45 lines 1.7 kB view raw
1import type { LoggerFactory as AppLoggerFactory } from '@amp/web-apps-logger'; 2 3import { Random } from '@amp/web-apps-common/src/jet/dependencies/random'; 4import { Host } from '@amp/web-apps-common/src/jet/dependencies/host'; 5import { WebBag } from './bag'; 6import { WebClient } from './client'; 7import { WebConsole } from './console'; 8import { Locale } from './locale'; 9import { WebLocalization } from './localization'; 10import { makeProperties } from './properties'; 11import { WebMetricsIdentifiers } from './metrics-identifiers'; 12import { Net, type FeaturesCallbacks } from './net'; 13import { WebStorage } from './storage'; 14import { makeUnauthenticatedUser } from './user'; 15import { SEO } from './seo'; 16 17export type Dependencies = ReturnType<typeof makeDependencies>; 18 19export function makeDependencies( 20 loggerFactory: AppLoggerFactory, 21 fetch: typeof window.fetch, 22 featuresCallbacks?: FeaturesCallbacks, 23) { 24 const locale = new Locale(loggerFactory); 25 return { 26 bag: new WebBag(loggerFactory, locale), 27 client: new WebClient( 28 // TODO: set the right `BuildType` based on the environment where the app is running 29 'production', 30 locale, 31 ), 32 console: new WebConsole(loggerFactory), 33 host: new Host(), 34 localization: new WebLocalization(locale, loggerFactory), 35 locale, 36 metricsIdentifiers: new WebMetricsIdentifiers(), 37 net: new Net(fetch, featuresCallbacks), 38 properties: makeProperties(), 39 random: new Random(), 40 seo: new SEO(locale), 41 storage: new WebStorage(), 42 user: makeUnauthenticatedUser(), 43 URL, 44 }; 45}