summaryrefslogtreecommitdiff
path: root/src/jet/dependencies/make-dependencies.ts
diff options
context:
space:
mode:
authorrxliuli <rxliuli@gmail.com>2025-11-04 05:03:50 +0800
committerrxliuli <rxliuli@gmail.com>2025-11-04 05:03:50 +0800
commitbce557cc2dc767628bed6aac87301a1be7c5431b (patch)
treeb51a051228d01fe3306cd7626d4a96768aadb944 /src/jet/dependencies/make-dependencies.ts
init commit
Diffstat (limited to 'src/jet/dependencies/make-dependencies.ts')
-rw-r--r--src/jet/dependencies/make-dependencies.ts45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/jet/dependencies/make-dependencies.ts b/src/jet/dependencies/make-dependencies.ts
new file mode 100644
index 0000000..f03c7ca
--- /dev/null
+++ b/src/jet/dependencies/make-dependencies.ts
@@ -0,0 +1,45 @@
+import type { LoggerFactory as AppLoggerFactory } from '@amp/web-apps-logger';
+
+import { Random } from '@amp/web-apps-common/src/jet/dependencies/random';
+import { Host } from '@amp/web-apps-common/src/jet/dependencies/host';
+import { WebBag } from './bag';
+import { WebClient } from './client';
+import { WebConsole } from './console';
+import { Locale } from './locale';
+import { WebLocalization } from './localization';
+import { makeProperties } from './properties';
+import { WebMetricsIdentifiers } from './metrics-identifiers';
+import { Net, type FeaturesCallbacks } from './net';
+import { WebStorage } from './storage';
+import { makeUnauthenticatedUser } from './user';
+import { SEO } from './seo';
+
+export type Dependencies = ReturnType<typeof makeDependencies>;
+
+export function makeDependencies(
+ loggerFactory: AppLoggerFactory,
+ fetch: typeof window.fetch,
+ featuresCallbacks?: FeaturesCallbacks,
+) {
+ const locale = new Locale(loggerFactory);
+ return {
+ bag: new WebBag(loggerFactory, locale),
+ client: new WebClient(
+ // TODO: set the right `BuildType` based on the environment where the app is running
+ 'production',
+ locale,
+ ),
+ console: new WebConsole(loggerFactory),
+ host: new Host(),
+ localization: new WebLocalization(locale, loggerFactory),
+ locale,
+ metricsIdentifiers: new WebMetricsIdentifiers(),
+ net: new Net(fetch, featuresCallbacks),
+ properties: makeProperties(),
+ random: new Random(),
+ seo: new SEO(locale),
+ storage: new WebStorage(),
+ user: makeUnauthenticatedUser(),
+ URL,
+ };
+}