summaryrefslogtreecommitdiff
path: root/node_modules/@jet-app/app-store/tmp/src/common/room
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/common/room
init commit
Diffstat (limited to 'node_modules/@jet-app/app-store/tmp/src/common/room')
-rw-r--r--node_modules/@jet-app/app-store/tmp/src/common/room/room-common.js139
-rw-r--r--node_modules/@jet-app/app-store/tmp/src/common/room/room-page.js105
-rw-r--r--node_modules/@jet-app/app-store/tmp/src/common/room/room-request.js48
3 files changed, 292 insertions, 0 deletions
diff --git a/node_modules/@jet-app/app-store/tmp/src/common/room/room-common.js b/node_modules/@jet-app/app-store/tmp/src/common/room/room-common.js
new file mode 100644
index 0000000..d1ab4a0
--- /dev/null
+++ b/node_modules/@jet-app/app-store/tmp/src/common/room/room-common.js
@@ -0,0 +1,139 @@
+import { makeRoomPageIntent } from "../../api/intents/room-page-intent";
+import * as models from "../../api/models";
+import * as mediaDataFetching from "../../foundation/media/data-fetching";
+import { AbstractMediaApiPageBuilder } from "../builders/abstract-media-api-page-builder";
+import * as pagination from "../builders/pagination";
+import * as metricsHelpersLocation from "../metrics/helpers/location";
+import * as metricsHelpersPage from "../metrics/helpers/page";
+import { generateRoutes } from "../util/generate-routes";
+import { defaultAttributesForRoomRequest } from "./room-request";
+import { withAsyncValidationContext } from "../../foundation/util/validation-util";
+import { defaultRoomShelfContentType, roomPageWithContent } from "./room-page";
+export class RoomPageToken {
+ constructor() {
+ /// The store platform data profile to use.
+ this.profile = "lockup";
+ /// The maximum number of ids to fetch per load more request.
+ this.maxPerPage = pagination.suggestedMaxPerPage;
+ }
+}
+export class AbstractRoomBuilder extends AbstractMediaApiPageBuilder {
+ //
+ // Begin Region: Common
+ //
+ defaultAttributes(objectGraph) {
+ return defaultAttributesForRoomRequest(objectGraph);
+ }
+ defaultPlatforms(objectGraph) {
+ return mediaDataFetching.defaultAdditionalPlatformsForClient(objectGraph);
+ }
+ pageType() {
+ return "page";
+ }
+ //
+ // Begin Region: Load More
+ //
+ generatePaginationRequest(objectGraph, url, parameters, token) {
+ const pageToken = token;
+ const mediaApiRequest = new mediaDataFetching.Request(objectGraph, pageToken.remainingContent);
+ return mediaApiRequest;
+ }
+ async renderPaginatedPage(objectGraph, data, token) {
+ const pageToken = token;
+ return await this.pageWithContent(objectGraph, data, pageToken);
+ }
+ //
+ // Begin Region: Internal API
+ //
+ /**
+ * Generates a room page given a list of lockups
+ *
+ * @param {DataContainer} roomContents
+ * @param {RoomPageToken} token The token representing the content to load
+ * @param {boolean} shouldUpdateRemainingContent Whether to update the remaining content in the token,
+ * false when being handled outside of this method
+ * @returns {GenericPage}
+ */
+ async pageWithContent(objectGraph, roomContents, token, shouldUpdateRemainingContent = true) {
+ return await withAsyncValidationContext("pageWithContent", async () => {
+ return roomPageWithContent(objectGraph, roomContents, token, shouldUpdateRemainingContent);
+ });
+ }
+}
+/**
+ * Creates a page that can be used for side-packing see all pages into a room.
+ *
+ * @param objectGraph
+ * @param {string} title The title of the destination page
+ * @param {ShelfContentType} preferredShelfContentType The content type to use for the page
+ * @returns {GenericPage} A GenericPage which will use the parentShelfItems from the see all to render the initial room
+ */
+export function seeAllPage(objectGraph, title, preferredShelfContentType) {
+ const shelf = new models.Shelf(preferredShelfContentType || defaultRoomShelfContentType);
+ shelf.isHorizontal = false;
+ shelf.items = "parentShelfItems";
+ const page = new models.GenericPage([shelf]);
+ page.isIncomplete = true;
+ page.title = title;
+ if (platformPrefersLargeTitles(objectGraph)) {
+ page.presentationOptions = ["prefersLargeTitle"];
+ }
+ return page;
+}
+export function platformPrefersLargeTitles(objectGraph) {
+ return objectGraph.client.isWatch || objectGraph.client.isMac;
+}
+export class AbstractActionRoomBuilder extends AbstractRoomBuilder {
+ async handlePage(objectGraph, url, parameters, matchedRuleIdentifier, referrerData, isIncomingURL) {
+ return this.action();
+ }
+ generatePageRequest(objectGraph, url, parameters) {
+ throw new Error(`generatePageRequest is not supported on: ${this.builderClass}`);
+ }
+ async renderPage(objectGraph, data, parameters, additionalPageRequirements) {
+ throw new Error(`renderPage is not supported on: ${this.builderClass}`);
+ }
+}
+export class AbstractFilteredRoom extends AbstractRoomBuilder {
+ requestWithFilter(objectGraph, type, value) {
+ const mediaApiRequest = new mediaDataFetching.Request(objectGraph)
+ .forType("apps")
+ .includingMacOSCompatibleIOSAppsWhenSupported(true)
+ .withFilter(type, value);
+ return mediaApiRequest;
+ }
+ async renderPage(objectGraph, data, parameters, additionalPageRequirements) {
+ return await withAsyncValidationContext("renderPage", async () => {
+ // Create the token
+ const token = new RoomPageToken();
+ token.url = this.paginationUrl;
+ token.metricsPageInformation = this.pageInformation(objectGraph, data, parameters);
+ token.shouldFilter = false;
+ token.metricsLocationTracker = metricsHelpersLocation.newLocationTracker();
+ const page = await this.pageWithContent(objectGraph, data, token);
+ metricsHelpersPage.addMetricsEventsToPageWithInformation(objectGraph, page, token.metricsPageInformation);
+ return page;
+ });
+ }
+}
+/// MARK: `RoomPageIntentController` Routing
+const { routes: roomPageRoutesWithoutPlatform, makeCanonicalUrl: makeCanonicalRoomPageUrlWithoutPlatform } = generateRoutes(makeRoomPageIntent, "/room/{id}");
+const { routes: roomPageRoutesWithPlatform, makeCanonicalUrl: makeCanonicalRoomPageUrlWithPlatform } = generateRoutes(makeRoomPageIntent, "/{platform}/room/{id}");
+/**
+ * Define the `RouteProvider` routes for the `RoomPageIntentController`
+ */
+export function roomPageRoutes(objectGraph) {
+ return [...roomPageRoutesWithoutPlatform(objectGraph), ...roomPageRoutesWithPlatform(objectGraph)];
+}
+/**
+ * Generate the URL used by the "web" client to route to a {@linkcode RoomPageIntent}
+ */
+export function makeCanonicalRoomPageUrl(objectGraph, intent) {
+ if ("platform" in intent) {
+ return makeCanonicalRoomPageUrlWithPlatform(objectGraph, intent);
+ }
+ else {
+ return makeCanonicalRoomPageUrlWithoutPlatform(objectGraph, intent);
+ }
+}
+//# sourceMappingURL=room-common.js.map \ No newline at end of file
diff --git a/node_modules/@jet-app/app-store/tmp/src/common/room/room-page.js b/node_modules/@jet-app/app-store/tmp/src/common/room/room-page.js
new file mode 100644
index 0000000..a54ca0e
--- /dev/null
+++ b/node_modules/@jet-app/app-store/tmp/src/common/room/room-page.js
@@ -0,0 +1,105 @@
+import { unwrapOptional as unwrap } from "@jet/environment/types/optional";
+import { GenericPage, Shelf } from "../../api/models";
+import { attributeAsBooleanOrFalse, attributeAsString } from "../../foundation/media/attributes";
+import { metricsFromMediaApiObject, dataCollectionFromDataContainer, dataFromDataContainer, } from "../../foundation/media/data-structure";
+import { relationship } from "../../foundation/media/relationships";
+import { addMetricsEventsToPageWithInformation, metricsPageInformationFromMediaApiResponse, } from "../metrics/helpers/page";
+import { addImpressionFields } from "../metrics/helpers/impressions";
+import { pushContentLocation, newLocationTracker } from "../metrics/helpers/location";
+import { lockupsFromData } from "../lockups/lockups";
+import { clientIdentifierForEditorialContextInData } from "../lockups/editorial-context";
+import { artworkUseCaseFromShelfStyle } from "../content/content";
+import { nextDataRange } from "../builders/pagination";
+import { platformPrefersLargeTitles, RoomPageToken } from "./room-common";
+export const defaultRoomShelfContentType = "mediumLockup";
+/**
+ * Provides the shelf content type for featured content kinds that require a particular shelf content type that differs
+ * from the default.
+ *
+ * @param fcKind The featured content ID.
+ * @returns {ShelfContentType} The content type for the shelf.
+ */
+export function preferredShelfStyleForFcKind(fcKind) {
+ if (fcKind === null || fcKind === undefined) {
+ return null;
+ }
+ switch (fcKind) {
+ case 431 /* FeaturedContentID.AppStore_iAPShelf */:
+ return "inAppPurchaseTiledLockup";
+ default:
+ return null;
+ }
+}
+export function renderRoomPage(objectGraph, data) {
+ const roomData = unwrap(dataFromDataContainer(objectGraph, data));
+ const roomContents = unwrap(relationship(roomData, "contents"));
+ const pageInformation = metricsPageInformationFromMediaApiResponse(objectGraph, "Room", roomData.id, data);
+ // Create the token
+ const token = new RoomPageToken();
+ token.remainingContent = roomContents.data;
+ token.shouldFilter = !attributeAsBooleanOrFalse(roomData, "doNotFilter");
+ token.metricsPageInformation = pageInformation;
+ token.metricsLocationTracker = newLocationTracker();
+ const fcKindString = attributeAsString(roomData, "editorialElementKind");
+ token.preferredShelfContentType = preferredShelfStyleForFcKind(Number(fcKindString));
+ token.clientIdentifierOverride = clientIdentifierForEditorialContextInData(objectGraph, roomData);
+ // Render the room
+ token.title = unwrap(attributeAsString(roomData, "title"));
+ const page = roomPageWithContent(objectGraph, roomContents, token);
+ page.title = token.title;
+ if (platformPrefersLargeTitles(objectGraph)) {
+ page.presentationOptions = ["prefersLargeTitle"];
+ }
+ addMetricsEventsToPageWithInformation(objectGraph, page, pageInformation);
+ return page;
+}
+/**
+ * Shared rendering logic for all kinds of "room" pages
+ */
+export function roomPageWithContent(objectGraph, roomContents, token, shouldUpdateRemainingContent = true) {
+ var _a;
+ const shelfStyle = token.preferredShelfContentType || defaultRoomShelfContentType;
+ const shelf = new Shelf(shelfStyle);
+ const shelfMetricsOptions = {
+ id: null,
+ kind: null,
+ softwareType: null,
+ targetType: "swoosh",
+ title: token.title,
+ pageInformation: token.metricsPageInformation,
+ locationTracker: token.metricsLocationTracker,
+ idType: "its_contentId",
+ recoMetricsData: (_a = metricsFromMediaApiObject(roomContents)) !== null && _a !== void 0 ? _a : {},
+ };
+ /// add impression fields
+ addImpressionFields(objectGraph, shelf, shelfMetricsOptions);
+ pushContentLocation(objectGraph, shelfMetricsOptions, token.title);
+ shelf.isHorizontal = false;
+ shelf.shouldFilterApps = token.shouldFilter;
+ const contents = dataCollectionFromDataContainer(roomContents);
+ if (shouldUpdateRemainingContent) {
+ token.remainingContent = [];
+ }
+ shelf.items = lockupsFromData(objectGraph, contents, {
+ contentUnavailable: (index, _dataItem) => {
+ if (shouldUpdateRemainingContent) {
+ token.remainingContent = nextDataRange(objectGraph, contents, index);
+ }
+ return true;
+ },
+ lockupOptions: {
+ metricsOptions: {
+ pageInformation: token.metricsPageInformation,
+ locationTracker: token.metricsLocationTracker,
+ },
+ clientIdentifierOverride: token.clientIdentifierOverride,
+ artworkUseCase: artworkUseCaseFromShelfStyle(objectGraph, shelfStyle),
+ },
+ });
+ const page = new GenericPage([shelf]);
+ if (token.remainingContent.length) {
+ page.nextPage = token;
+ }
+ return page;
+}
+//# sourceMappingURL=room-page.js.map \ No newline at end of file
diff --git a/node_modules/@jet-app/app-store/tmp/src/common/room/room-request.js b/node_modules/@jet-app/app-store/tmp/src/common/room/room-request.js
new file mode 100644
index 0000000..ba0337b
--- /dev/null
+++ b/node_modules/@jet-app/app-store/tmp/src/common/room/room-request.js
@@ -0,0 +1,48 @@
+import { Request, defaultAdditionalPlatformsForClient } from "../../foundation/media/data-fetching";
+import { shouldFetchCustomAttributes } from "../product-page/product-page-variants";
+import { shouldUsePrerenderedIconArtwork } from "../content/content";
+import { setPreviewPlatform } from "../preview-platform";
+export function createRoomRequest(objectGraph, roomId) {
+ const mediaApiRequest = new Request(objectGraph)
+ .withIdOfType(roomId, "rooms")
+ .includingAgeRestrictions()
+ .includingMacOSCompatibleIOSAppsWhenSupported(true);
+ if (objectGraph.client.isWeb) {
+ mediaApiRequest.includingAdditionalPlatforms(defaultAdditionalPlatformsForClient(objectGraph));
+ setPreviewPlatform(objectGraph, mediaApiRequest);
+ }
+ return mediaApiRequest;
+}
+export function prepareRoomRequest(objectGraph, request) {
+ return request
+ .includingAdditionalPlatforms(defaultAdditionalPlatformsForClient(objectGraph))
+ .includingAttributes(defaultAttributesForRoomRequest(objectGraph))
+ .usingCustomAttributes(shouldFetchCustomAttributes(objectGraph))
+ .includingAgeRestrictions()
+ .includingMacOSCompatibleIOSAppsWhenSupported(true);
+}
+export function defaultAttributesForRoomRequest(objectGraph) {
+ const attributes = [
+ "editorialArtwork",
+ "editorialVideo",
+ "isAppleWatchSupported",
+ "requiredCapabilities",
+ ];
+ if (objectGraph.appleSilicon.isSupportEnabled) {
+ attributes.push("macRequiredCapabilities");
+ }
+ if (objectGraph.client.isMac) {
+ attributes.push("hasMacIPAPackage");
+ }
+ if (objectGraph.client.isVision) {
+ attributes.push("compatibilityControllerRequirement");
+ }
+ if (objectGraph.bag.enableUpdatedAgeRatings) {
+ attributes.push("ageRating");
+ }
+ if (shouldUsePrerenderedIconArtwork(objectGraph)) {
+ attributes.push("iconArtwork");
+ }
+ return attributes;
+}
+//# sourceMappingURL=room-request.js.map \ No newline at end of file