@mpgd/target-config 0.6.1 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/effective.js +6 -3
- package/dist/runtime.js +25 -15
- package/package.json +4 -4
- package/targets.json +5 -5
package/dist/effective.js
CHANGED
|
@@ -125,13 +125,13 @@ function effectiveTargetConfigVersion(input) {
|
|
|
125
125
|
return `${input.targetConfig}+catalog.${input.productCatalog}+ads.${input.adPlacements}`;
|
|
126
126
|
}
|
|
127
127
|
function productPlatformId(product, target) {
|
|
128
|
-
if (!
|
|
128
|
+
if (!isProductStoreTarget(target)) {
|
|
129
129
|
return undefined;
|
|
130
130
|
}
|
|
131
131
|
return normalizePlatformId(product.platformProductIds[target]);
|
|
132
132
|
}
|
|
133
133
|
function adPlacementPlatformId(placement, target) {
|
|
134
|
-
if (!
|
|
134
|
+
if (!isAdStoreTarget(target)) {
|
|
135
135
|
return undefined;
|
|
136
136
|
}
|
|
137
137
|
return normalizePlatformId(placement.platformPlacementIds[target]);
|
|
@@ -143,7 +143,10 @@ function normalizePlatformId(platformId) {
|
|
|
143
143
|
const trimmed = platformId.trim();
|
|
144
144
|
return trimmed.length === 0 ? undefined : trimmed;
|
|
145
145
|
}
|
|
146
|
-
function
|
|
146
|
+
function isProductStoreTarget(target) {
|
|
147
|
+
return target === 'android' || target === 'ios' || target === 'ait' || target === 'reddit';
|
|
148
|
+
}
|
|
149
|
+
function isAdStoreTarget(target) {
|
|
147
150
|
return target === 'android' || target === 'ios' || target === 'ait';
|
|
148
151
|
}
|
|
149
152
|
function isRewardedPlacement(placement) {
|
package/dist/runtime.js
CHANGED
|
@@ -130,6 +130,11 @@ export function createTargetRuntimeSnapshot(input) {
|
|
|
130
130
|
};
|
|
131
131
|
}
|
|
132
132
|
export function withTargetAvailability(gateway, config, options = {}) {
|
|
133
|
+
let cachedGatewayCapabilities;
|
|
134
|
+
const getGatewayCapabilities = async () => {
|
|
135
|
+
cachedGatewayCapabilities ??= await gateway.getCapabilities();
|
|
136
|
+
return cachedGatewayCapabilities;
|
|
137
|
+
};
|
|
133
138
|
const configTarget = options.configTarget ?? targetConfigKeyForPlatform(gateway.target);
|
|
134
139
|
const { identity: gatewayIdentity, presentation: gatewayPresentation, sharing: gatewaySharing, notifications: gatewayNotifications, ...gatewayWithoutIntegrations } = gateway;
|
|
135
140
|
const integrations = normalizeTargetIntegrationConfig(options.effectiveConfig?.integrations ?? config.integrations);
|
|
@@ -161,6 +166,7 @@ export function withTargetAvailability(gateway, config, options = {}) {
|
|
|
161
166
|
...(exposeInboundShare ? { readInboundShare } : {}),
|
|
162
167
|
};
|
|
163
168
|
const notifications = notificationsAvailable ? gatewayNotifications : undefined;
|
|
169
|
+
const isIapAvailable = async () => (config.features.iap && (await getGatewayCapabilities()).nativeIap);
|
|
164
170
|
const isAdPlacementAllowed = (placementId, expectedType) => {
|
|
165
171
|
const actualType = options.resolveAdPlacementType?.(placementId);
|
|
166
172
|
if (actualType !== undefined && actualType !== expectedType) {
|
|
@@ -199,35 +205,39 @@ export function withTargetAvailability(gateway, config, options = {}) {
|
|
|
199
205
|
...(options.effectiveConfig === undefined
|
|
200
206
|
? {}
|
|
201
207
|
: { effectiveConfig: options.effectiveConfig }),
|
|
202
|
-
capabilities: applyTargetConfigToCapabilities(await
|
|
208
|
+
capabilities: applyTargetConfigToCapabilities(await getGatewayCapabilities(), config),
|
|
203
209
|
adPlacements: options.adPlacements ?? [],
|
|
204
210
|
gateway,
|
|
205
211
|
});
|
|
206
212
|
},
|
|
207
213
|
async getCapabilities() {
|
|
208
|
-
return applyTargetConfigToCapabilities(await
|
|
214
|
+
return applyTargetConfigToCapabilities(await getGatewayCapabilities(), config);
|
|
209
215
|
},
|
|
210
|
-
commerce:
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
async purchase() {
|
|
216
|
+
commerce: {
|
|
217
|
+
async getProducts() {
|
|
218
|
+
return await isIapAvailable() ? gateway.commerce.getProducts() : [];
|
|
219
|
+
},
|
|
220
|
+
async purchase(input) {
|
|
221
|
+
if (!await isIapAvailable()) {
|
|
217
222
|
return {
|
|
218
223
|
status: 'cancelled',
|
|
219
224
|
entitlementIds: [],
|
|
220
225
|
};
|
|
221
|
-
}
|
|
222
|
-
|
|
226
|
+
}
|
|
227
|
+
return gateway.commerce.purchase(input);
|
|
228
|
+
},
|
|
229
|
+
async restore() {
|
|
230
|
+
if (!await isIapAvailable() || gateway.commerce.restore === undefined) {
|
|
223
231
|
return {
|
|
224
232
|
restoredEntitlements: [],
|
|
225
233
|
};
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
234
|
+
}
|
|
235
|
+
return gateway.commerce.restore();
|
|
236
|
+
},
|
|
237
|
+
async getEntitlements() {
|
|
238
|
+
return await isIapAvailable() ? gateway.commerce.getEntitlements() : [];
|
|
230
239
|
},
|
|
240
|
+
},
|
|
231
241
|
ads: {
|
|
232
242
|
async preload(input) {
|
|
233
243
|
if (canPreloadAdPlacement(input.placementId)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpgd/target-config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Target-specific platform feature availability and effective config helpers for mpgd.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"typia": "13.0.2",
|
|
40
|
-
"@mpgd/catalog": "0.
|
|
41
|
-
"@mpgd/
|
|
42
|
-
"@mpgd/
|
|
40
|
+
"@mpgd/catalog": "0.4.0",
|
|
41
|
+
"@mpgd/platform": "0.6.0",
|
|
42
|
+
"@mpgd/i18n": "0.5.2"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"ttsc": "0.18.4",
|
package/targets.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2026-07-
|
|
2
|
+
"version": "2026-07-15",
|
|
3
3
|
"targets": {
|
|
4
4
|
"web-preview": {
|
|
5
5
|
"runtime": "web-preview",
|
|
@@ -219,10 +219,10 @@
|
|
|
219
219
|
"reddit": {
|
|
220
220
|
"runtime": "devvit-web",
|
|
221
221
|
"features": {
|
|
222
|
-
"iap":
|
|
222
|
+
"iap": true,
|
|
223
223
|
"rewardedAds": false,
|
|
224
224
|
"interstitialAds": false,
|
|
225
|
-
"leaderboard":
|
|
225
|
+
"leaderboard": false,
|
|
226
226
|
"localization": true
|
|
227
227
|
},
|
|
228
228
|
"capabilities": {
|
|
@@ -233,12 +233,12 @@
|
|
|
233
233
|
"fallbackLocale": "en"
|
|
234
234
|
},
|
|
235
235
|
"monetization": {
|
|
236
|
-
"iap":
|
|
236
|
+
"iap": true,
|
|
237
237
|
"rewardedAds": false,
|
|
238
238
|
"interstitialAds": false
|
|
239
239
|
},
|
|
240
240
|
"leaderboard": {
|
|
241
|
-
"native":
|
|
241
|
+
"native": false
|
|
242
242
|
},
|
|
243
243
|
"release": {
|
|
244
244
|
"profile": "devvit"
|