1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
|
import type { Bag as NativeBag, BagKeyDescriptor } from '@jet/environment';
import type { Opt } from '@jet/environment';
import type { Logger, LoggerFactory } from '@amp/web-apps-logger';
import type { Locale } from './locale';
import {
EU_STOREFRONTS,
SUPPORTED_STOREFRONTS_FOR_VISION,
UNSUPPORTED_STOREFRONTS_FOR_ARCADE,
} from '~/constants/storefront';
export type BagRetrievalMethod = Exclude<keyof NativeBag, 'registerBagKeys'>;
export function makeUnimplementedKeyRequestWarning(
method: BagRetrievalMethod,
key: string,
) {
return `requested unimplemented \`${method}\` key \`${key}\``;
}
export class WebBag implements NativeBag {
private readonly log: Logger;
private readonly locale: Locale;
constructor(loggerFactory: LoggerFactory, locale: Locale) {
this.log = loggerFactory.loggerFor('Bag');
this.locale = locale;
}
private provideNoValue(method: BagRetrievalMethod, key: string): null {
this.log.warn(makeUnimplementedKeyRequestWarning(method, key));
return null;
}
registerBagKeys(_keys: BagKeyDescriptor[]): void {
// We hardcode, so registration is a no-op
}
double(key: string): Opt<number> {
switch (key) {
case 'game-controller-recommended-rollout-rate':
return 1.0; // set to 1.0 to enable `learn more` button for game controller capability
case 'icon-artwork-rollout-rate':
return 1.0; // set to 1.0 to enable new icon artwork style
default:
return this.provideNoValue('double', key);
}
}
integer(key: string): Opt<number> {
return this.provideNoValue('integer', key);
}
boolean(key: string): Opt<boolean> {
switch (key) {
case 'enableAppEvents':
return true;
case 'enable-app-accessibility-labels':
return true;
case 'enable-app-store-age-ratings':
return true;
case 'enable-external-purchase':
return true;
case 'enable-privacy-nutrition-labels':
return true;
case 'enable-system-app-reviews':
return true;
case 'enable-vision-platform':
return SUPPORTED_STOREFRONTS_FOR_VISION.has(
this.locale.activeStorefront,
);
case 'arcade-enabled':
return !UNSUPPORTED_STOREFRONTS_FOR_ARCADE.has(
this.locale.activeStorefront,
);
// Enable required `GroupingPage` features
case 'enable-featured-categories-on-groupings':
case 'enable-category-bricks-on-groupings':
return true;
case 'enable-seller-info':
return true;
case 'enable-preview-platform-for-web':
return false;
case 'enableProductPageVariants':
return true;
case 'game-center-extend-supported-features':
return true;
case 'enable-product-page-install-size':
return true;
case 'enable-icon-artwork':
return true;
default:
return this.provideNoValue('boolean', key);
}
}
array(key: string): Opt<unknown> {
switch (key) {
// URL patterns that are opted into the "edge" domains
// https://github.pie.apple.com/app-store/ios-appstore-app/blob/83834eea5dfcad22d902fe395c4d140ec7fa8cea/src/foundation/media/url-builder.ts#L350
case 'apps-media-api-edge-end-points':
return [
// Including a pattern that matches our "search" API endpoint ensures
// that the built URL uses the `apps-media-api-search-edge-host` host
// https://github.pie.apple.com/app-store/ios-appstore-app/blob/83834eea5dfcad22d902fe395c4d140ec7fa8cea/src/foundation/media/url-builder.ts#L352
'/search',
];
case 'enabled-external-purchase-placements':
return ['product-page-banner', 'product-page-info-section'];
case 'tabs/standard':
return [
{
id: 'today',
title: this.locale.i18n.t(
'ASE.Web.AppStore.Navigation.LandingPage.Today',
),
'image-identifier': 'text.rectangle.page',
},
{
id: 'apps',
title: this.locale.i18n.t(
'ASE.Web.AppStore.Navigation.LandingPage.Apps',
),
'image-identifier': 'app.3.stack.3d.fill',
},
{
id: 'apps-and-games',
title: this.locale.i18n.t(
'ASE.Web.AppStore.Navigation.LandingPage.AppsAndGames',
),
'image-identifier': 'rocket.fill',
},
{
id: 'arcade',
title: this.locale.i18n.t(
'ASE.Web.AppStore.Navigation.LandingPage.Arcade',
),
'image-identifier': 'joystickcontroller.fill',
},
{
id: 'create',
title: this.locale.i18n.t(
'ASE.Web.AppStore.Navigation.LandingPage.Create',
),
'image-identifier': 'paintbrush.fill',
},
{
id: 'discover',
title: this.locale.i18n.t(
'ASE.Web.AppStore.Navigation.LandingPage.Discover',
),
'image-identifier': 'star.fill',
},
{
id: 'games',
title: this.locale.i18n.t(
'ASE.Web.AppStore.Navigation.LandingPage.Games',
),
'image-identifier': 'rocket.fill',
},
{
id: 'work',
title: this.locale.i18n.t(
'ASE.Web.AppStore.Navigation.LandingPage.Work',
),
'image-identifier': 'paperplane.fill',
},
{
id: 'play',
title: this.locale.i18n.t(
'ASE.Web.AppStore.Navigation.LandingPage.Play',
),
'image-identifier': 'rocket.fill',
},
{
id: 'develop',
title: this.locale.i18n.t(
'ASE.Web.AppStore.Navigation.LandingPage.Develop',
),
'image-identifier': 'hammer.fill',
},
{
id: 'categories',
title: this.locale.i18n.t(
'ASE.Web.AppStore.Navigation.LandingPage.Categories',
),
'image-identifier': 'square.grid.2x2.fill',
},
{
id: 'search',
title: this.locale.i18n.t(
'ASE.Web.AppStore.Navigation.LandingPage.Search',
),
'image-identifier': 'magnifyingglass',
},
];
default:
return this.provideNoValue('array', key);
}
}
dictionary(key: string): Opt<unknown> {
return this.provideNoValue('dictionary', key);
}
url(key: string): Opt<string> {
switch (key) {
case 'apps-media-api-host':
return 'amp-api-edge.apps.apple.com';
case 'apps-media-api-edge-host':
return 'amp-api-edge.apps.apple.com';
case 'apps-media-api-search-edge-host':
return 'amp-api-search-edge.apps.apple.com';
default:
return this.provideNoValue('url', key);
}
}
string(key: string): Opt<string> {
switch (key) {
case 'countryCode':
return this.locale.activeStorefront;
case 'language-tag':
return this.locale.activeLanguage;
case 'language':
// TODO: rdar://78159789: util for this? What about zh-Hant, etc.
return this.locale.activeLanguage.split('-')[0];
// Some URLs are accessed as strings
// TODO: fix this upstream in `ios-appstore-app` so it uses `.url()` instead
case 'apps-media-api-edge-host':
case 'apps-media-api-search-edge-host':
return this.url(key);
case 'game-controller-learn-more-editorial-item-id':
return '1687769242';
case 'familySubscriptionsLearnMoreEditorialItemId':
return '1563279606';
case 'external-purchase-learn-more-editorial-item-id':
if (this.locale.activeStorefront === 'kr') {
return 'id1727067165';
}
return 'id1760810284';
case 'appPrivacyLearnMoreEditorialItemId':
return 'id1538632801';
case 'ageRatingLearnMoreEditorialItemId':
return '1825160725';
case 'accessibility-learn-more-editorial-item-id':
return '1814164299';
case 'external-purchase-product-page-banner-text-variant':
return '2';
case 'external-purchase-product-page-annotation-variant':
return '4';
case 'transparencyLawEditorialItemId':
if (EU_STOREFRONTS.includes(this.locale.activeStorefront)) {
return 'id1620909697';
}
return null;
case 'appPrivacyDefinitionsEditorialItemId':
return '1539235847';
case 'metrics_topic':
return 'xp_amp_appstore_unidentified';
case 'in-app-purchases-learn-more-editorial-item-id':
return '1436214772';
case 'web-navigation-category-tabs-editorial-item-id':
return '1842456901';
default:
return this.provideNoValue('string', key);
}
}
}
|