expo-iap 3.0.7 → 3.1.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/CLAUDE.md +14 -2
- package/CONTRIBUTING.md +19 -0
- package/README.md +18 -6
- package/android/build.gradle +24 -1
- package/android/src/main/java/expo/modules/iap/ExpoIapLog.kt +69 -0
- package/android/src/main/java/expo/modules/iap/ExpoIapModule.kt +190 -59
- package/build/index.d.ts +32 -111
- package/build/index.d.ts.map +1 -1
- package/build/index.js +198 -243
- package/build/index.js.map +1 -1
- package/build/modules/android.d.ts +7 -12
- package/build/modules/android.d.ts.map +1 -1
- package/build/modules/android.js +15 -12
- package/build/modules/android.js.map +1 -1
- package/build/modules/ios.d.ts +35 -36
- package/build/modules/ios.d.ts.map +1 -1
- package/build/modules/ios.js +101 -35
- package/build/modules/ios.js.map +1 -1
- package/build/types.d.ts +107 -82
- package/build/types.d.ts.map +1 -1
- package/build/types.js +1 -0
- package/build/types.js.map +1 -1
- package/build/useIAP.d.ts +7 -12
- package/build/useIAP.d.ts.map +1 -1
- package/build/useIAP.js +49 -23
- package/build/useIAP.js.map +1 -1
- package/build/utils/errorMapping.d.ts +32 -23
- package/build/utils/errorMapping.d.ts.map +1 -1
- package/build/utils/errorMapping.js +117 -22
- package/build/utils/errorMapping.js.map +1 -1
- package/ios/ExpoIap.podspec +3 -2
- package/ios/ExpoIapHelper.swift +96 -0
- package/ios/ExpoIapLog.swift +127 -0
- package/ios/ExpoIapModule.swift +218 -340
- package/openiap-versions.json +5 -0
- package/package.json +2 -2
- package/plugin/build/withIAP.js +6 -4
- package/plugin/src/withIAP.ts +14 -4
- package/scripts/update-types.mjs +20 -1
- package/src/index.ts +280 -356
- package/src/modules/android.ts +25 -23
- package/src/modules/ios.ts +138 -48
- package/src/types.ts +139 -91
- package/src/useIAP.ts +91 -58
- package/src/utils/errorMapping.ts +203 -23
- package/.copilot-instructions.md +0 -321
- package/.cursorrules +0 -321
- package/build/purchase-error.d.ts +0 -67
- package/build/purchase-error.d.ts.map +0 -1
- package/build/purchase-error.js +0 -166
- package/build/purchase-error.js.map +0 -1
- package/src/purchase-error.ts +0 -265
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-iap",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "In App Purchase module in Expo",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"docs:build": "cd docs && bun run build",
|
|
28
28
|
"docs:serve": "cd docs && bun run serve",
|
|
29
29
|
"docs:install": "cd docs && bun install",
|
|
30
|
-
"generate:types": "node scripts/update-types.mjs
|
|
30
|
+
"generate:types": "node scripts/update-types.mjs",
|
|
31
31
|
"generate:icon": "npx sharp-cli resize 32 32 -i docs/static/img/icon.png -o docs/static/img/favicon-32x32.png && npx sharp-cli resize 16 16 -i docs/static/img/icon.png -o docs/static/img/favicon-16x16.png && npx sharp-cli resize 180 180 -i docs/static/img/icon.png -o docs/static/img/apple-touch-icon.png && npx sharp-cli resize 192 192 -i docs/static/img/icon.png -o docs/static/img/android-chrome-192x192.png && npx sharp-cli resize 512 512 -i docs/static/img/icon.png -o docs/static/img/android-chrome-512x512.png && npx sharp-cli resize 150 150 -i docs/static/img/icon.png -o docs/static/img/mstile-150x150.png && npx sharp-cli resize 1200 630 -i docs/static/img/icon.png -o docs/static/img/og-image.png && npx sharp-cli resize 1200 600 -i docs/static/img/icon.png -o docs/static/img/twitter-card.png && npx sharp-cli resize 16 16 -i docs/static/img/icon.png -o docs/static/img/favicon.png && cp docs/static/img/favicon-16x16.png docs/static/img/favicon.ico"
|
|
32
32
|
},
|
|
33
33
|
"keywords": [
|
package/plugin/build/withIAP.js
CHANGED
|
@@ -41,6 +41,8 @@ const fs = __importStar(require("fs"));
|
|
|
41
41
|
const path = __importStar(require("path"));
|
|
42
42
|
const withLocalOpenIAP_1 = __importDefault(require("./withLocalOpenIAP"));
|
|
43
43
|
const pkg = require('../../package.json');
|
|
44
|
+
const openiapVersions = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../../openiap-versions.json'), 'utf8'));
|
|
45
|
+
const OPENIAP_ANDROID_VERSION = openiapVersions.google;
|
|
44
46
|
// Log a message only once per Node process
|
|
45
47
|
const logOnce = (() => {
|
|
46
48
|
const printed = new Set();
|
|
@@ -69,7 +71,7 @@ const modifyAppBuildGradle = (gradle, language) => {
|
|
|
69
71
|
const impl = (ga, v) => language === 'kotlin'
|
|
70
72
|
? ` implementation("${ga}:${v}")`
|
|
71
73
|
: ` implementation "${ga}:${v}"`;
|
|
72
|
-
const openiapDep = impl('io.github.hyochan.openiap:openiap-google',
|
|
74
|
+
const openiapDep = impl('io.github.hyochan.openiap:openiap-google', OPENIAP_ANDROID_VERSION);
|
|
73
75
|
// Remove any existing openiap-google lines (any version, groovy/kotlin, implementation/api)
|
|
74
76
|
const openiapAnyLine = /^\s*(?:implementation|api)\s*\(?\s*["']io\.github\.hyochan\.openiap:openiap-google:[^"']+["']\s*\)?\s*$/gm;
|
|
75
77
|
const hadExisting = openiapAnyLine.test(modified);
|
|
@@ -77,12 +79,12 @@ const modifyAppBuildGradle = (gradle, language) => {
|
|
|
77
79
|
modified = modified.replace(openiapAnyLine, '').replace(/\n{3,}/g, '\n\n');
|
|
78
80
|
}
|
|
79
81
|
// Ensure the desired dependency line is present
|
|
80
|
-
if (!new RegExp(String.raw `io\.github\.hyochan\.openiap:openiap-google
|
|
82
|
+
if (!new RegExp(String.raw `io\.github\.hyochan\.openiap:openiap-google:${OPENIAP_ANDROID_VERSION}`).test(modified)) {
|
|
81
83
|
// Insert just after the opening `dependencies {` line
|
|
82
84
|
modified = addLineToGradle(modified, /dependencies\s*{/, openiapDep, 1);
|
|
83
85
|
logOnce(hadExisting
|
|
84
|
-
?
|
|
85
|
-
:
|
|
86
|
+
? `🛠️ expo-iap: Replaced OpenIAP dependency with ${OPENIAP_ANDROID_VERSION}`
|
|
87
|
+
: `🛠️ expo-iap: Added OpenIAP dependency (${OPENIAP_ANDROID_VERSION}) to build.gradle`);
|
|
86
88
|
}
|
|
87
89
|
return modified;
|
|
88
90
|
};
|
package/plugin/src/withIAP.ts
CHANGED
|
@@ -11,6 +11,13 @@ import * as path from 'path';
|
|
|
11
11
|
import withLocalOpenIAP from './withLocalOpenIAP';
|
|
12
12
|
|
|
13
13
|
const pkg = require('../../package.json');
|
|
14
|
+
const openiapVersions = JSON.parse(
|
|
15
|
+
fs.readFileSync(
|
|
16
|
+
path.resolve(__dirname, '../../openiap-versions.json'),
|
|
17
|
+
'utf8',
|
|
18
|
+
),
|
|
19
|
+
);
|
|
20
|
+
const OPENIAP_ANDROID_VERSION = openiapVersions.google;
|
|
14
21
|
|
|
15
22
|
// Log a message only once per Node process
|
|
16
23
|
const logOnce = (() => {
|
|
@@ -54,7 +61,10 @@ const modifyAppBuildGradle = (
|
|
|
54
61
|
language === 'kotlin'
|
|
55
62
|
? ` implementation("${ga}:${v}")`
|
|
56
63
|
: ` implementation "${ga}:${v}"`;
|
|
57
|
-
const openiapDep = impl(
|
|
64
|
+
const openiapDep = impl(
|
|
65
|
+
'io.github.hyochan.openiap:openiap-google',
|
|
66
|
+
OPENIAP_ANDROID_VERSION,
|
|
67
|
+
);
|
|
58
68
|
|
|
59
69
|
// Remove any existing openiap-google lines (any version, groovy/kotlin, implementation/api)
|
|
60
70
|
const openiapAnyLine =
|
|
@@ -67,15 +77,15 @@ const modifyAppBuildGradle = (
|
|
|
67
77
|
// Ensure the desired dependency line is present
|
|
68
78
|
if (
|
|
69
79
|
!new RegExp(
|
|
70
|
-
String.raw`io\.github\.hyochan\.openiap:openiap-google
|
|
80
|
+
String.raw`io\.github\.hyochan\.openiap:openiap-google:${OPENIAP_ANDROID_VERSION}`,
|
|
71
81
|
).test(modified)
|
|
72
82
|
) {
|
|
73
83
|
// Insert just after the opening `dependencies {` line
|
|
74
84
|
modified = addLineToGradle(modified, /dependencies\s*{/, openiapDep, 1);
|
|
75
85
|
logOnce(
|
|
76
86
|
hadExisting
|
|
77
|
-
?
|
|
78
|
-
:
|
|
87
|
+
? `🛠️ expo-iap: Replaced OpenIAP dependency with ${OPENIAP_ANDROID_VERSION}`
|
|
88
|
+
: `🛠️ expo-iap: Added OpenIAP dependency (${OPENIAP_ANDROID_VERSION}) to build.gradle`,
|
|
79
89
|
);
|
|
80
90
|
}
|
|
81
91
|
|
package/scripts/update-types.mjs
CHANGED
|
@@ -3,8 +3,27 @@ import {mkdtempSync, readFileSync, writeFileSync, rmSync} from 'node:fs';
|
|
|
3
3
|
import {join} from 'node:path';
|
|
4
4
|
import {tmpdir} from 'node:os';
|
|
5
5
|
import {execFileSync} from 'node:child_process';
|
|
6
|
+
import {fileURLToPath, URL} from 'node:url';
|
|
7
|
+
|
|
8
|
+
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
|
9
|
+
let versions;
|
|
10
|
+
try {
|
|
11
|
+
versions = JSON.parse(
|
|
12
|
+
readFileSync(join(__dirname, '..', 'openiap-versions.json'), 'utf8'),
|
|
13
|
+
);
|
|
14
|
+
} catch {
|
|
15
|
+
throw new Error(
|
|
16
|
+
'expo-iap: Unable to load openiap-versions.json. Ensure the file exists and is valid JSON.',
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const DEFAULT_TAG = versions?.gql;
|
|
21
|
+
if (typeof DEFAULT_TAG !== 'string' || DEFAULT_TAG.length === 0) {
|
|
22
|
+
throw new Error(
|
|
23
|
+
'expo-iap: "gql" version missing in openiap-versions.json. Specify --tag manually or update the file.',
|
|
24
|
+
);
|
|
25
|
+
}
|
|
6
26
|
|
|
7
|
-
const DEFAULT_TAG = '1.0.1';
|
|
8
27
|
const PROJECT_ROOT = process.cwd();
|
|
9
28
|
|
|
10
29
|
function parseArgs() {
|