expo-iap 3.1.17 → 3.1.19
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/CONTRIBUTING.md +1 -1
- package/README.md +1 -1
- package/android/build.gradle +5 -0
- package/bun.lockb +0 -0
- package/coverage/clover.xml +2 -2
- package/coverage/lcov-report/index.html +1 -1
- package/coverage/lcov-report/src/index.html +1 -1
- package/coverage/lcov-report/src/index.ts.html +1 -1
- package/coverage/lcov-report/src/modules/android.ts.html +1 -1
- package/coverage/lcov-report/src/modules/index.html +1 -1
- package/coverage/lcov-report/src/modules/ios.ts.html +1 -1
- package/coverage/lcov-report/src/utils/debug.ts.html +1 -1
- package/coverage/lcov-report/src/utils/errorMapping.ts.html +1 -1
- package/coverage/lcov-report/src/utils/index.html +1 -1
- package/openiap-versions.json +2 -2
- package/package.json +1 -1
- package/plugin/build/withIAP.d.ts +39 -21
- package/plugin/build/withIAP.js +72 -62
- package/plugin/build/withIosAlternativeBilling.d.ts +19 -0
- package/plugin/build/withIosAlternativeBilling.js +70 -0
- package/plugin/build/withLocalOpenIAP.d.ts +4 -1
- package/plugin/build/withLocalOpenIAP.js +58 -57
- package/plugin/src/withIAP.ts +145 -123
- package/plugin/src/withIosAlternativeBilling.ts +133 -0
- package/plugin/src/withLocalOpenIAP.ts +80 -67
- package/plugin/tsconfig.tsbuildinfo +1 -1
- package/scripts/update-types.mjs +1 -1
|
@@ -6,7 +6,10 @@ import {
|
|
|
6
6
|
} from 'expo/config-plugins';
|
|
7
7
|
import * as fs from 'fs';
|
|
8
8
|
import * as path from 'path';
|
|
9
|
-
import
|
|
9
|
+
import {
|
|
10
|
+
withIosAlternativeBilling,
|
|
11
|
+
type IOSAlternativeBillingConfig,
|
|
12
|
+
} from './withIosAlternativeBilling';
|
|
10
13
|
|
|
11
14
|
/**
|
|
12
15
|
* Plugin to add local OpenIAP pod dependency for development
|
|
@@ -14,17 +17,28 @@ import type {IOSAlternativeBillingConfig} from './withIAP';
|
|
|
14
17
|
*/
|
|
15
18
|
type LocalPathOption = string | {ios?: string; android?: string};
|
|
16
19
|
|
|
20
|
+
// Log a message only once per Node process
|
|
21
|
+
const logOnce = (() => {
|
|
22
|
+
const printed = new Set<string>();
|
|
23
|
+
return (msg: string) => {
|
|
24
|
+
if (!printed.has(msg)) {
|
|
25
|
+
console.log(msg);
|
|
26
|
+
printed.add(msg);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
})();
|
|
30
|
+
|
|
17
31
|
const withLocalOpenIAP: ConfigPlugin<
|
|
18
32
|
{
|
|
19
33
|
localPath?: LocalPathOption;
|
|
20
34
|
iosAlternativeBilling?: IOSAlternativeBillingConfig;
|
|
35
|
+
horizonAppId?: string;
|
|
36
|
+
/** Resolved from modules.horizon by withIAP */
|
|
37
|
+
isHorizonEnabled?: boolean;
|
|
21
38
|
} | void
|
|
22
39
|
> = (config, props) => {
|
|
23
40
|
// Import and apply iOS alternative billing configuration if provided
|
|
24
41
|
if (props?.iosAlternativeBilling) {
|
|
25
|
-
// Import withIosAlternativeBilling from withIAP module
|
|
26
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
27
|
-
const {withIosAlternativeBilling} = require('./withIAP');
|
|
28
42
|
config = withIosAlternativeBilling(config, props.iosAlternativeBilling);
|
|
29
43
|
}
|
|
30
44
|
// Helper to resolve Android module path
|
|
@@ -71,7 +85,7 @@ const withLocalOpenIAP: ConfigPlugin<
|
|
|
71
85
|
let podfileContent = fs.readFileSync(podfilePath, 'utf8');
|
|
72
86
|
|
|
73
87
|
if (podfileContent.includes("pod 'openiap',")) {
|
|
74
|
-
|
|
88
|
+
logOnce('✅ Local OpenIAP pod already configured');
|
|
75
89
|
return config;
|
|
76
90
|
}
|
|
77
91
|
|
|
@@ -86,7 +100,7 @@ const withLocalOpenIAP: ConfigPlugin<
|
|
|
86
100
|
pod 'openiap', :path => '${iosPath}'`;
|
|
87
101
|
});
|
|
88
102
|
fs.writeFileSync(podfilePath, podfileContent);
|
|
89
|
-
|
|
103
|
+
logOnce(`✅ Added local OpenIAP pod at: ${iosPath}`);
|
|
90
104
|
} else {
|
|
91
105
|
console.warn('⚠️ Could not find target block in Podfile');
|
|
92
106
|
}
|
|
@@ -185,14 +199,14 @@ const withLocalOpenIAP: ConfigPlugin<
|
|
|
185
199
|
if (!contents.includes(includeLine)) contents += `\n${includeLine}\n`;
|
|
186
200
|
if (!contents.includes(projectDirLine)) contents += `${projectDirLine}\n`;
|
|
187
201
|
settings.contents = contents;
|
|
188
|
-
|
|
202
|
+
logOnce(`✅ Linked local Android module at: ${androidModulePath}`);
|
|
189
203
|
return config;
|
|
190
204
|
});
|
|
191
205
|
|
|
192
206
|
// 2) app/build.gradle: add implementation project(':openiap-google')
|
|
193
207
|
config = withAppBuildGradle(config, (config) => {
|
|
194
|
-
const raw = props?.localPath;
|
|
195
208
|
const projectRoot = (config.modRequest as any).projectRoot as string;
|
|
209
|
+
const raw = props?.localPath;
|
|
196
210
|
const androidInput = typeof raw === 'string' ? undefined : raw?.android;
|
|
197
211
|
const androidModulePath =
|
|
198
212
|
resolveAndroidModulePath(androidInput) ||
|
|
@@ -205,85 +219,84 @@ const withLocalOpenIAP: ConfigPlugin<
|
|
|
205
219
|
|
|
206
220
|
const gradle = config.modResults;
|
|
207
221
|
const dependencyLine = ` implementation project(':openiap-google')`;
|
|
222
|
+
const flavor = props?.isHorizonEnabled ? 'horizon' : 'play';
|
|
223
|
+
const strategyLine = ` missingDimensionStrategy "platform", "${flavor}"`;
|
|
208
224
|
|
|
209
|
-
// Remove any previously added Maven deps for openiap-google to avoid duplicate classes
|
|
210
|
-
const removalPatterns = [
|
|
211
|
-
// Groovy DSL: implementation "io.github.hyochan.openiap:openiap-google:x.y.z" or api "..."
|
|
212
|
-
/^\s*(?:implementation|api)\s+["']io\.github\.hyochan\.openiap:openiap-google:[^"']+["']\s*$/gm,
|
|
213
|
-
// Kotlin DSL: implementation("io.github.hyochan.openiap:openiap-google:x.y.z") or api("...")
|
|
214
|
-
/^\s*(?:implementation|api)\s*\(\s*["']io\.github\.hyochan\.openiap:openiap-google:[^"']+["']\s*\)\s*$/gm,
|
|
215
|
-
];
|
|
216
225
|
let contents = gradle.contents;
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
226
|
+
|
|
227
|
+
// Remove Maven deps (avoid duplicate classes with local module)
|
|
228
|
+
const mavenPattern =
|
|
229
|
+
/^\s*(?:implementation|api)\s*\(?\s*["']io\.github\.hyochan\.openiap:openiap-google:[^"']+["']\s*\)?\s*$/gm;
|
|
230
|
+
if (mavenPattern.test(contents)) {
|
|
231
|
+
contents = contents.replace(mavenPattern, '\n');
|
|
232
|
+
logOnce('🧹 Removed Maven openiap-google (using local module)');
|
|
223
233
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
);
|
|
234
|
+
|
|
235
|
+
// Add missingDimensionStrategy (required for flavored module)
|
|
236
|
+
// Remove any existing platform strategies first to avoid duplicates
|
|
237
|
+
const strategyPattern =
|
|
238
|
+
/^\s*missingDimensionStrategy\s*\(?\s*["']platform["']\s*,\s*["'](play|horizon)["']\s*\)?\s*$/gm;
|
|
239
|
+
if (strategyPattern.test(contents)) {
|
|
240
|
+
contents = contents.replace(strategyPattern, '');
|
|
241
|
+
logOnce('🧹 Removed existing missingDimensionStrategy for platform');
|
|
229
242
|
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
243
|
+
|
|
244
|
+
if (!contents.includes(strategyLine)) {
|
|
245
|
+
const lines = contents.split('\n');
|
|
246
|
+
const idx = lines.findIndex((line) => line.match(/defaultConfig\s*\{/));
|
|
247
|
+
if (idx !== -1) {
|
|
248
|
+
lines.splice(idx + 1, 0, strategyLine);
|
|
249
|
+
contents = lines.join('\n');
|
|
250
|
+
logOnce(
|
|
251
|
+
`🛠️ expo-iap: Added missingDimensionStrategy for ${flavor} flavor`,
|
|
236
252
|
);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// Add project dependency
|
|
257
|
+
if (!contents.includes(dependencyLine)) {
|
|
258
|
+
const anchor = /dependencies\s*\{/m;
|
|
259
|
+
if (anchor.test(contents)) {
|
|
260
|
+
contents = contents.replace(anchor, (m) => `${m}\n${dependencyLine}`);
|
|
237
261
|
} else {
|
|
238
|
-
|
|
262
|
+
contents += `\n\ndependencies {\n${dependencyLine}\n}\n`;
|
|
239
263
|
}
|
|
240
|
-
|
|
264
|
+
logOnce('🛠️ Added dependency on local :openiap-google project');
|
|
241
265
|
}
|
|
266
|
+
|
|
267
|
+
gradle.contents = contents;
|
|
242
268
|
return config;
|
|
243
269
|
});
|
|
244
270
|
|
|
245
|
-
// 3)
|
|
271
|
+
// 3) Set horizonEnabled in gradle.properties
|
|
246
272
|
config = withDangerousMod(config, [
|
|
247
273
|
'android',
|
|
248
274
|
async (config) => {
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
275
|
+
const {platformProjectRoot} = config.modRequest as any;
|
|
276
|
+
const gradlePropertiesPath = path.join(
|
|
277
|
+
platformProjectRoot,
|
|
278
|
+
'gradle.properties',
|
|
279
|
+
);
|
|
280
|
+
|
|
281
|
+
if (fs.existsSync(gradlePropertiesPath)) {
|
|
282
|
+
let contents = fs.readFileSync(gradlePropertiesPath, 'utf8');
|
|
283
|
+
const isHorizon = props?.isHorizonEnabled ?? false;
|
|
284
|
+
|
|
285
|
+
// Update horizonEnabled property
|
|
286
|
+
contents = contents.replace(/^horizonEnabled=.*$/gm, '');
|
|
287
|
+
if (!contents.endsWith('\n')) contents += '\n';
|
|
288
|
+
contents += `horizonEnabled=${isHorizon}\n`;
|
|
289
|
+
|
|
290
|
+
fs.writeFileSync(gradlePropertiesPath, contents);
|
|
291
|
+
logOnce(
|
|
292
|
+
`🛠️ expo-iap: Set horizonEnabled=${isHorizon} in gradle.properties`,
|
|
255
293
|
);
|
|
256
|
-
if (fs.existsSync(appBuildGradle)) {
|
|
257
|
-
let contents = fs.readFileSync(appBuildGradle, 'utf8');
|
|
258
|
-
const patterns = [
|
|
259
|
-
// Groovy DSL
|
|
260
|
-
/^\s*(?:implementation|api)\s+["']io\.github\.hyochan\.openiap:openiap-google:[^"']+["']\s*$/gm,
|
|
261
|
-
// Kotlin DSL
|
|
262
|
-
/^\s*(?:implementation|api)\s*\(\s*["']io\.github\.hyochan\.openiap:openiap-google:[^"']+["']\s*\)\s*$/gm,
|
|
263
|
-
];
|
|
264
|
-
let changed = false;
|
|
265
|
-
for (const p of patterns) {
|
|
266
|
-
if (p.test(contents)) {
|
|
267
|
-
contents = contents.replace(p, '\n');
|
|
268
|
-
changed = true;
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
if (changed) {
|
|
272
|
-
fs.writeFileSync(appBuildGradle, contents);
|
|
273
|
-
console.log(
|
|
274
|
-
'🧹 expo-iap: Cleaned Maven openiap-google for local :openiap-google',
|
|
275
|
-
);
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
} catch (e) {
|
|
279
|
-
console.warn('expo-iap: cleanup step failed:', e);
|
|
280
294
|
}
|
|
295
|
+
|
|
281
296
|
return config;
|
|
282
297
|
},
|
|
283
298
|
]);
|
|
284
299
|
|
|
285
|
-
// (removed) Avoid global root build.gradle mutations; included module should manage its plugins
|
|
286
|
-
|
|
287
300
|
return config;
|
|
288
301
|
};
|
|
289
302
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["./src/expoConfig.augmentation.d.ts","./src/withIAP.ts","./src/withLocalOpenIAP.ts"],"version":"5.9.3"}
|
|
1
|
+
{"root":["./src/expoConfig.augmentation.d.ts","./src/withIAP.ts","./src/withIosAlternativeBilling.ts","./src/withLocalOpenIAP.ts"],"version":"5.9.3"}
|
package/scripts/update-types.mjs
CHANGED
|
@@ -42,7 +42,7 @@ function parseArgs() {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
function getReleaseUrl(tag) {
|
|
45
|
-
return `https://github.com/hyodotdev/openiap
|
|
45
|
+
return `https://github.com/hyodotdev/openiap/releases/download/${tag}/openiap-typescript.zip`;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
function main() {
|