From bce557cc2dc767628bed6aac87301a1be7c5431b Mon Sep 17 00:00:00 2001 From: rxliuli Date: Tue, 4 Nov 2025 05:03:50 +0800 Subject: init commit --- .../src/foundation/dependencies/active-intent.js | 121 +++++++++++++++++++++ .../dependencies/locale/locale-from-bag.js | 41 +++++++ .../src/foundation/dependencies/locale/locale.js | 3 + .../tmp/src/foundation/dependencies/seo.js | 3 + 4 files changed, 168 insertions(+) create mode 100644 node_modules/@jet-app/app-store/tmp/src/foundation/dependencies/active-intent.js create mode 100644 node_modules/@jet-app/app-store/tmp/src/foundation/dependencies/locale/locale-from-bag.js create mode 100644 node_modules/@jet-app/app-store/tmp/src/foundation/dependencies/locale/locale.js create mode 100644 node_modules/@jet-app/app-store/tmp/src/foundation/dependencies/seo.js (limited to 'node_modules/@jet-app/app-store/tmp/src/foundation/dependencies') 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 -- cgit v1.2.3