summaryrefslogtreecommitdiff
path: root/node_modules/@jet-app/app-store/tmp/src/foundation/dependencies
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 /node_modules/@jet-app/app-store/tmp/src/foundation/dependencies
init commit
Diffstat (limited to 'node_modules/@jet-app/app-store/tmp/src/foundation/dependencies')
-rw-r--r--node_modules/@jet-app/app-store/tmp/src/foundation/dependencies/active-intent.js121
-rw-r--r--node_modules/@jet-app/app-store/tmp/src/foundation/dependencies/locale/locale-from-bag.js41
-rw-r--r--node_modules/@jet-app/app-store/tmp/src/foundation/dependencies/locale/locale.js3
-rw-r--r--node_modules/@jet-app/app-store/tmp/src/foundation/dependencies/seo.js3
4 files changed, 168 insertions, 0 deletions
diff --git a/node_modules/@jet-app/app-store/tmp/src/foundation/dependencies/active-intent.js b/node_modules/@jet-app/app-store/tmp/src/foundation/dependencies/active-intent.js
new file mode 100644
index 0000000..5270dd4
--- /dev/null
+++ b/node_modules/@jet-app/app-store/tmp/src/foundation/dependencies/active-intent.js
@@ -0,0 +1,121 @@
+import { isSome } from "@jet/environment/types/optional";
+import { makeMetatype } from "@jet/environment/util/metatype";
+import { unreachable } from "../util/errors";
+export const ActiveIntentMetaType = makeMetatype("app-store:active-intent");
+/**
+ * Executes {@linkcode callback} with an {@linkcode AppStoreObjectGraph} that has been prepared with an
+ * {@linkcode ActiveIntent} dependency
+ *
+ * This will allow code running within {@linkcode callback} to access meta-data about the active
+ * {@linkcode Intent} without needing that information to be passed through every layer of the code
+ */
+export function withActiveIntent(objectGraph, intent, callback) {
+ const objectGraphWithActiveIntent = objectGraph.addingActiveIntent({
+ previewPlatform: intent.platform,
+ });
+ return callback(objectGraphWithActiveIntent);
+}
+/**
+ * Ephemeral storage of `Intent`-specific details that need to be accessible
+ * throughout the process of building that `Intent`'s result
+ */
+export class ActiveIntent {
+ constructor(implementation) {
+ this.implementation = implementation;
+ this.inferredPreviewPlatform = undefined;
+ }
+ /**
+ * Explicitly set a {@linkcode PreviewPlatform} for the active intent
+ *
+ * This might be a value derrived from an API response, in cases where the original `Intent`
+ * was not specific about which platform to display
+ */
+ setInferredPreviewPlatform(platform) {
+ this.inferredPreviewPlatform = platform;
+ }
+ /**
+ * The {@linkcode PreviewPlatform} value of the current {@linkcode Intent}
+ */
+ get previewPlatform() {
+ var _a;
+ return (_a = this.inferredPreviewPlatform) !== null && _a !== void 0 ? _a : this.implementation.previewPlatform;
+ }
+ /**
+ * The {@linkcode Platform} equivalent of the active {@linkcode PreviewPlatform}
+ *
+ * This translates the user-facing {@linkcode PreviewPlatform} into the "internal"
+ * Media API {@linkcode Platform}
+ */
+ get platform() {
+ if (isSome(this.previewPlatform)) {
+ switch (this.previewPlatform) {
+ case "ipad":
+ case "iphone":
+ case "mac":
+ case "watch":
+ return this.previewPlatform;
+ case "tv":
+ return "appletv";
+ case "vision":
+ return "realityDevice";
+ default:
+ unreachable(this.previewPlatform);
+ }
+ }
+ return undefined;
+ }
+ /**
+ * The {@linkcode AttributePlatform} equivalent of the active {@linkcode PreviewPlatform}
+ *
+ * This translates the user-facing {@linkcode PreviewPlatform} into the "internal"
+ * {@linkcode AttributePlatform}
+ */
+ get attributePlatform() {
+ if (isSome(this.previewPlatform)) {
+ switch (this.previewPlatform) {
+ case "iphone":
+ case "ipad":
+ return "ios";
+ case "mac":
+ return "osx";
+ case "tv":
+ return "appletvos";
+ case "vision":
+ return "xros";
+ case "watch":
+ return "watch";
+ default:
+ unreachable(this.previewPlatform);
+ }
+ }
+ return undefined;
+ }
+ /**
+ * The {@linkcode AppPlatform} equivalent of the active {@linkcode PreviewPlatform}
+ *
+ * This translates the user-facing {@linkcode PreviewPlatform} into the "internal"
+ * {@linkcode AppPlatform}
+ */
+ get appPlatform() {
+ if (isSome(this.previewPlatform)) {
+ switch (this.previewPlatform) {
+ case "ipad":
+ return "pad";
+ case "iphone":
+ return "phone";
+ case "mac":
+ return "mac";
+ case "tv":
+ return "tv";
+ case "vision":
+ return "vision";
+ case "watch":
+ return "watch";
+ default:
+ unreachable(this.previewPlatform);
+ }
+ }
+ return undefined;
+ }
+}
+//# sourceMappingURL=active-intent.js.map \ No newline at end of file
diff --git a/node_modules/@jet-app/app-store/tmp/src/foundation/dependencies/locale/locale-from-bag.js b/node_modules/@jet-app/app-store/tmp/src/foundation/dependencies/locale/locale-from-bag.js
new file mode 100644
index 0000000..7790008
--- /dev/null
+++ b/node_modules/@jet-app/app-store/tmp/src/foundation/dependencies/locale/locale-from-bag.js
@@ -0,0 +1,41 @@
+export class LocaleFromBag {
+ constructor(objectGraph) {
+ this.objectGraph = objectGraph;
+ }
+ /**
+ * The current {@link NormalizedStorefront | storefront} for the client
+ *
+ * This reads directly from the `Bag`, as that is the source of truth
+ * for locale information in the "native" clients
+ */
+ get activeStorefront() {
+ // The type-cast here reflects the implicit assumption that any values
+ // belonging to the `Bag` have already been normalized
+ return this.objectGraph.bag.mediaCountryCode;
+ }
+ /**
+ * The current {@link NormalizedLanguage | language} for the client
+ *
+ * This reads directly from the `Bag`, as that is the source of truth
+ * for locale information in the "native" clients
+ */
+ get activeLanguage() {
+ // The type-cast here reflects the implicit assumption that any values
+ // belonging to the `Bag` have already been normalized
+ return this.objectGraph.bag.language;
+ }
+ setActiveLocale(_locale) {
+ // Intentional no-op; "native" clients that use the `Bag` as the source
+ // of "locale" information do not allow for mutation of the "locale"
+ }
+ normalize(_unnormalizedLocale) {
+ return {
+ storefront: this.activeStorefront,
+ language: this.activeLanguage,
+ };
+ }
+ deriveLocaleForUrl(locale) {
+ return locale;
+ }
+}
+//# sourceMappingURL=locale-from-bag.js.map \ No newline at end of file
diff --git a/node_modules/@jet-app/app-store/tmp/src/foundation/dependencies/locale/locale.js b/node_modules/@jet-app/app-store/tmp/src/foundation/dependencies/locale/locale.js
new file mode 100644
index 0000000..d00bacc
--- /dev/null
+++ b/node_modules/@jet-app/app-store/tmp/src/foundation/dependencies/locale/locale.js
@@ -0,0 +1,3 @@
+import { makeMetatype } from "@jet/environment/util/metatype";
+export const LocaleMetaType = makeMetatype("app-store:locale");
+//# sourceMappingURL=locale.js.map \ No newline at end of file
diff --git a/node_modules/@jet-app/app-store/tmp/src/foundation/dependencies/seo.js b/node_modules/@jet-app/app-store/tmp/src/foundation/dependencies/seo.js
new file mode 100644
index 0000000..9def945
--- /dev/null
+++ b/node_modules/@jet-app/app-store/tmp/src/foundation/dependencies/seo.js
@@ -0,0 +1,3 @@
+import { makeMetatype } from "@jet/environment/util/metatype";
+export const SEOMetaType = makeMetatype("app-store:seo");
+//# sourceMappingURL=seo.js.map \ No newline at end of file