@mpgd/target-config 0.8.0 → 0.9.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.d.ts +1 -0
- package/dist/effective.js +36 -17
- package/dist/runtime.js +25 -14
- package/package.json +1 -1
- package/targets.json +2 -2
package/dist/effective.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export type EffectiveAvailabilityReason = FeatureAvailabilityReason | 'missing-p
|
|
|
4
4
|
export interface EffectivePlatformTargetMetadata {
|
|
5
5
|
readonly kind: string;
|
|
6
6
|
readonly adapter: string;
|
|
7
|
+
readonly authoritativeGameServices?: boolean;
|
|
7
8
|
readonly artifact?: string;
|
|
8
9
|
readonly output?: string;
|
|
9
10
|
readonly webDir?: string;
|
package/dist/effective.js
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { normalizeTargetIntegrationConfig, } from './runtime.js';
|
|
2
2
|
export const defaultLeaderboardId = 'default';
|
|
3
|
+
const disabledAuthoritativeMonetization = {
|
|
4
|
+
iap: false,
|
|
5
|
+
rewardedAds: false,
|
|
6
|
+
interstitialAds: false,
|
|
7
|
+
};
|
|
3
8
|
export function createEffectiveTargetConfig(input) {
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
9
|
+
const config = resolveAuthoritativeGameServicesConfig(input.config, input.platformTarget);
|
|
10
|
+
const products = input.catalog.products.map((product) => createEffectiveProductConfig(input.target, config, product));
|
|
11
|
+
const placements = input.adPlacements.placements.map((placement) => createEffectiveAdPlacementConfig(input.target, config, placement));
|
|
12
|
+
const leaderboardEnabled = config.features.leaderboard;
|
|
7
13
|
const integrations = normalizeTargetIntegrationConfig({
|
|
8
|
-
...
|
|
14
|
+
...config.integrations,
|
|
9
15
|
...input.platformTarget?.integrations,
|
|
10
16
|
});
|
|
11
17
|
return {
|
|
@@ -15,12 +21,12 @@ export function createEffectiveTargetConfig(input) {
|
|
|
15
21
|
adPlacements: input.adPlacements.version,
|
|
16
22
|
}),
|
|
17
23
|
target: input.target,
|
|
18
|
-
runtime:
|
|
19
|
-
release:
|
|
20
|
-
features:
|
|
21
|
-
capabilities:
|
|
24
|
+
runtime: config.runtime,
|
|
25
|
+
release: config.release,
|
|
26
|
+
features: config.features,
|
|
27
|
+
capabilities: config.capabilities,
|
|
22
28
|
integrations,
|
|
23
|
-
policy:
|
|
29
|
+
policy: config.policy,
|
|
24
30
|
sources: {
|
|
25
31
|
targetConfig: input.targetConfigVersion,
|
|
26
32
|
productCatalog: input.catalog.version,
|
|
@@ -33,30 +39,43 @@ export function createEffectiveTargetConfig(input) {
|
|
|
33
39
|
}),
|
|
34
40
|
},
|
|
35
41
|
monetization: {
|
|
36
|
-
iap:
|
|
42
|
+
iap: config.monetization.iap,
|
|
37
43
|
products,
|
|
38
44
|
},
|
|
39
45
|
ads: {
|
|
40
|
-
rewardedAds:
|
|
41
|
-
interstitialAds:
|
|
46
|
+
rewardedAds: config.monetization.rewardedAds,
|
|
47
|
+
interstitialAds: config.monetization.interstitialAds,
|
|
42
48
|
placements,
|
|
43
49
|
},
|
|
44
50
|
leaderboard: {
|
|
45
|
-
native:
|
|
51
|
+
native: config.leaderboard.native,
|
|
46
52
|
enabled: leaderboardEnabled,
|
|
47
53
|
reason: leaderboardEnabled ? 'available' : 'target-disabled',
|
|
48
54
|
...(leaderboardEnabled ? { defaultLeaderboardId } : {}),
|
|
49
55
|
},
|
|
50
56
|
storage: {
|
|
51
|
-
support:
|
|
52
|
-
enabled:
|
|
57
|
+
support: config.capabilities.storage,
|
|
58
|
+
enabled: config.capabilities.storage !== 'none',
|
|
53
59
|
},
|
|
54
60
|
localization: {
|
|
55
|
-
enabled:
|
|
56
|
-
fallbackLocale:
|
|
61
|
+
enabled: config.capabilities.localization,
|
|
62
|
+
fallbackLocale: config.localization.fallbackLocale,
|
|
57
63
|
},
|
|
58
64
|
};
|
|
59
65
|
}
|
|
66
|
+
function resolveAuthoritativeGameServicesConfig(config, platformTarget) {
|
|
67
|
+
if (platformTarget?.authoritativeGameServices !== false) {
|
|
68
|
+
return config;
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
...config,
|
|
72
|
+
features: {
|
|
73
|
+
...config.features,
|
|
74
|
+
...disabledAuthoritativeMonetization,
|
|
75
|
+
},
|
|
76
|
+
monetization: disabledAuthoritativeMonetization,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
60
79
|
export function createEffectiveTargetConfigMatrix(input) {
|
|
61
80
|
const targets = Object.fromEntries(Object.entries(input.configMatrix.targets).map(([target, config]) => {
|
|
62
81
|
const platformTarget = input.platformTargets?.[target];
|
package/dist/runtime.js
CHANGED
|
@@ -95,12 +95,13 @@ export function getIntegrationAvailability(integration, config, gateway) {
|
|
|
95
95
|
}
|
|
96
96
|
export function createTargetRuntimeSnapshot(input) {
|
|
97
97
|
const configTarget = input.configTarget ?? targetConfigKeyForPlatform(input.target);
|
|
98
|
+
const availabilityConfig = resolveAvailabilityConfig(input.config, input.effectiveConfig);
|
|
98
99
|
const features = {
|
|
99
|
-
iap: getFeatureAvailability('iap',
|
|
100
|
-
rewardedAds: getFeatureAvailability('rewardedAds',
|
|
101
|
-
interstitialAds: getFeatureAvailability('interstitialAds',
|
|
102
|
-
leaderboard: getFeatureAvailability('leaderboard',
|
|
103
|
-
localization: getFeatureAvailability('localization',
|
|
100
|
+
iap: getFeatureAvailability('iap', availabilityConfig, input.capabilities),
|
|
101
|
+
rewardedAds: getFeatureAvailability('rewardedAds', availabilityConfig, input.capabilities),
|
|
102
|
+
interstitialAds: getFeatureAvailability('interstitialAds', availabilityConfig, input.capabilities),
|
|
103
|
+
leaderboard: getFeatureAvailability('leaderboard', availabilityConfig, input.capabilities),
|
|
104
|
+
localization: getFeatureAvailability('localization', availabilityConfig, input.capabilities),
|
|
104
105
|
};
|
|
105
106
|
const integrationConfig = normalizeTargetIntegrationConfig(input.effectiveConfig?.integrations ?? input.config.integrations);
|
|
106
107
|
const integrationEntries = targetIntegrations.map((integration) => {
|
|
@@ -130,6 +131,7 @@ export function createTargetRuntimeSnapshot(input) {
|
|
|
130
131
|
};
|
|
131
132
|
}
|
|
132
133
|
export function withTargetAvailability(gateway, config, options = {}) {
|
|
134
|
+
const availabilityConfig = resolveAvailabilityConfig(config, options.effectiveConfig);
|
|
133
135
|
const getGatewayCapabilities = () => (gateway.getCapabilities());
|
|
134
136
|
const configTarget = options.configTarget ?? targetConfigKeyForPlatform(gateway.target);
|
|
135
137
|
const { identity: gatewayIdentity, presentation: gatewayPresentation, sharing: gatewaySharing, notifications: gatewayNotifications, ...gatewayWithoutIntegrations } = gateway;
|
|
@@ -162,25 +164,26 @@ export function withTargetAvailability(gateway, config, options = {}) {
|
|
|
162
164
|
...(exposeInboundShare ? { readInboundShare } : {}),
|
|
163
165
|
};
|
|
164
166
|
const notifications = notificationsAvailable ? gatewayNotifications : undefined;
|
|
165
|
-
const isIapAvailable = async () => (
|
|
167
|
+
const isIapAvailable = async () => (availabilityConfig.features.iap && (await getGatewayCapabilities()).nativeIap);
|
|
166
168
|
const isAdPlacementAllowed = (placementId, expectedType) => {
|
|
167
169
|
const actualType = options.resolveAdPlacementType?.(placementId);
|
|
168
170
|
if (actualType !== undefined && actualType !== expectedType) {
|
|
169
171
|
return false;
|
|
170
172
|
}
|
|
171
173
|
return expectedType === 'rewarded'
|
|
172
|
-
?
|
|
173
|
-
:
|
|
174
|
+
? availabilityConfig.features.rewardedAds
|
|
175
|
+
: availabilityConfig.features.interstitialAds;
|
|
174
176
|
};
|
|
175
177
|
const canPreloadAdPlacement = (placementId) => {
|
|
176
178
|
const actualType = options.resolveAdPlacementType?.(placementId);
|
|
177
179
|
if (actualType === 'rewarded') {
|
|
178
|
-
return
|
|
180
|
+
return availabilityConfig.features.rewardedAds;
|
|
179
181
|
}
|
|
180
182
|
if (actualType === 'interstitial') {
|
|
181
|
-
return
|
|
183
|
+
return availabilityConfig.features.interstitialAds;
|
|
182
184
|
}
|
|
183
|
-
return
|
|
185
|
+
return (availabilityConfig.features.rewardedAds ||
|
|
186
|
+
availabilityConfig.features.interstitialAds);
|
|
184
187
|
};
|
|
185
188
|
return {
|
|
186
189
|
...gatewayWithoutIntegrations,
|
|
@@ -201,13 +204,13 @@ export function withTargetAvailability(gateway, config, options = {}) {
|
|
|
201
204
|
...(options.effectiveConfig === undefined
|
|
202
205
|
? {}
|
|
203
206
|
: { effectiveConfig: options.effectiveConfig }),
|
|
204
|
-
capabilities: applyTargetConfigToCapabilities(await getGatewayCapabilities(),
|
|
207
|
+
capabilities: applyTargetConfigToCapabilities(await getGatewayCapabilities(), availabilityConfig),
|
|
205
208
|
adPlacements: options.adPlacements ?? [],
|
|
206
209
|
gateway,
|
|
207
210
|
});
|
|
208
211
|
},
|
|
209
212
|
async getCapabilities() {
|
|
210
|
-
return applyTargetConfigToCapabilities(await getGatewayCapabilities(),
|
|
213
|
+
return applyTargetConfigToCapabilities(await getGatewayCapabilities(), availabilityConfig);
|
|
211
214
|
},
|
|
212
215
|
commerce: {
|
|
213
216
|
async getProducts() {
|
|
@@ -259,7 +262,7 @@ export function withTargetAvailability(gateway, config, options = {}) {
|
|
|
259
262
|
return gateway.ads.showInterstitial(input);
|
|
260
263
|
},
|
|
261
264
|
},
|
|
262
|
-
leaderboard:
|
|
265
|
+
leaderboard: availabilityConfig.features.leaderboard
|
|
263
266
|
? gateway.leaderboard
|
|
264
267
|
: {
|
|
265
268
|
async submitScore() {
|
|
@@ -271,6 +274,14 @@ export function withTargetAvailability(gateway, config, options = {}) {
|
|
|
271
274
|
},
|
|
272
275
|
};
|
|
273
276
|
}
|
|
277
|
+
function resolveAvailabilityConfig(config, effectiveConfig) {
|
|
278
|
+
return effectiveConfig === undefined
|
|
279
|
+
? config
|
|
280
|
+
: {
|
|
281
|
+
...config,
|
|
282
|
+
features: effectiveConfig.features,
|
|
283
|
+
};
|
|
284
|
+
}
|
|
274
285
|
export function isTargetConfiguredGateway(gateway) {
|
|
275
286
|
return typeof gateway.getTargetRuntime === 'function';
|
|
276
287
|
}
|
package/package.json
CHANGED
package/targets.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2026-07-
|
|
2
|
+
"version": "2026-07-19.1",
|
|
3
3
|
"targets": {
|
|
4
4
|
"web-preview": {
|
|
5
5
|
"runtime": "web-preview",
|
|
@@ -226,7 +226,7 @@
|
|
|
226
226
|
"localization": true
|
|
227
227
|
},
|
|
228
228
|
"capabilities": {
|
|
229
|
-
"storage": "
|
|
229
|
+
"storage": "native",
|
|
230
230
|
"localization": true
|
|
231
231
|
},
|
|
232
232
|
"localization": {
|