@tryheliumai/paywall-sdk-react-native 0.1.18 → 0.1.20

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.
@@ -25,4 +25,4 @@ Pod::Spec.new do |s|
25
25
  else
26
26
  s.dependency "React-Core"
27
27
  end
28
- end
28
+ end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryheliumai/paywall-sdk-react-native",
3
- "version": "0.1.18",
3
+ "version": "0.1.20",
4
4
  "description": "Paywall SDK Helium",
5
5
  "source": "./src/index.ts",
6
6
  "main": "./lib/commonjs/index.js",
@@ -43,7 +43,8 @@
43
43
  "!**/__tests__",
44
44
  "!**/__fixtures__",
45
45
  "!**/__mocks__",
46
- "!**/.*"
46
+ "!**/.*",
47
+ "withModularHeaders.js"
47
48
  ],
48
49
  "scripts": {
49
50
  "example": "yarn workspace paywall-sdk-react-native-example",
@@ -86,8 +87,8 @@
86
87
  "eslint-plugin-prettier": "^5.0.1",
87
88
  "jest": "^29.7.0",
88
89
  "prettier": "^3.0.3",
89
- "react": "18.3.1",
90
- "react-native": "0.74.0",
90
+ "react": "^18.2.0",
91
+ "react-native": "^0.74.0",
91
92
  "react-native-builder-bob": "^0.37.0",
92
93
  "release-it": "^17.10.0",
93
94
  "turbo": "^1.10.7",
@@ -197,5 +198,8 @@
197
198
  "type": "legacy-module",
198
199
  "languages": "kotlin-swift",
199
200
  "version": "0.48.1"
201
+ },
202
+ "dependencies": {
203
+ "@expo/config-plugins": "^9.0.17"
200
204
  }
201
205
  }
@@ -0,0 +1,108 @@
1
+ // withModularHeaders.js
2
+ const { withDangerousMod } = require('@expo/config-plugins');
3
+ const { resolve } = require('path');
4
+ const fs = require('fs');
5
+
6
+ const withModularHeadersPods = (config) => {
7
+ return withDangerousMod(config, [
8
+ 'ios',
9
+ async (config) => {
10
+ try {
11
+ const podfilePath = resolve(
12
+ config.modRequest.platformProjectRoot,
13
+ 'Podfile'
14
+ );
15
+
16
+ if (!fs.existsSync(podfilePath)) {
17
+ console.warn('Podfile not found at path:', podfilePath);
18
+ return config;
19
+ }
20
+
21
+ let podfileContent = fs.readFileSync(podfilePath, 'utf8');
22
+
23
+ // Check for existing pod declarations with any quote style
24
+ const heliumRegex =
25
+ /pod\s+(['"])Helium\1\s*,?\s*:modular_headers\s*=>\s*true/;
26
+ const analyticsRegex =
27
+ /pod\s+(['"])Analytics\1\s*,?\s*:modular_headers\s*=>\s*true/;
28
+
29
+ const heliumExists = heliumRegex.test(podfileContent);
30
+ const analyticsExists = analyticsRegex.test(podfileContent);
31
+
32
+ // Remove existing declarations without modular_headers
33
+ if (!heliumExists) {
34
+ const existingHeliumRegex =
35
+ /pod\s+(['"])Helium\1(?!\s*,\s*:modular_headers\s*=>)/;
36
+ if (existingHeliumRegex.test(podfileContent)) {
37
+ podfileContent = podfileContent.replace(
38
+ /pod\s+(['"])Helium\1[^,\n]*(?!:modular_headers)/g,
39
+ "pod 'Helium', :modular_headers => true"
40
+ );
41
+ }
42
+ }
43
+
44
+ if (!analyticsExists) {
45
+ const existingAnalyticsRegex =
46
+ /pod\s+(['"])Analytics\1(?!\s*,\s*:modular_headers\s*=>)/;
47
+ if (existingAnalyticsRegex.test(podfileContent)) {
48
+ podfileContent = podfileContent.replace(
49
+ /pod\s+(['"])Analytics\1[^,\n]*(?!:modular_headers)/g,
50
+ "pod 'Analytics', :modular_headers => true"
51
+ );
52
+ }
53
+ }
54
+
55
+ // If pods don't exist at all, add them
56
+ if (
57
+ (!heliumExists && !podfileContent.includes("pod 'Helium'")) ||
58
+ (!analyticsExists && !podfileContent.includes("pod 'Analytics'"))
59
+ ) {
60
+ const podsToAdd = [];
61
+
62
+ if (!heliumExists && !podfileContent.includes("pod 'Helium'")) {
63
+ podsToAdd.push(" pod 'Helium', :modular_headers => true");
64
+ }
65
+
66
+ if (!analyticsExists && !podfileContent.includes("pod 'Analytics'")) {
67
+ podsToAdd.push(" pod 'Analytics', :modular_headers => true");
68
+ }
69
+
70
+ // Look for the main app target (usually has the app name)
71
+ const appName = config.modRequest.projectName || '';
72
+ const mainTargetRegex = new RegExp(
73
+ `target\\s+(['"])${appName}\\1\\s+do`
74
+ );
75
+ const mainTargetMatch = podfileContent.match(mainTargetRegex);
76
+
77
+ // Fall back to first target if main target not found
78
+ const targetMatch =
79
+ mainTargetMatch || podfileContent.match(/target\s+['"].*['"]\s+do/);
80
+
81
+ if (targetMatch && targetMatch.index !== undefined) {
82
+ // Find the position right after the target line
83
+ const targetPos =
84
+ podfileContent.indexOf('\n', targetMatch.index) + 1;
85
+
86
+ // Insert the new pods after the target line
87
+ podfileContent =
88
+ podfileContent.substring(0, targetPos) +
89
+ podsToAdd.join('\n') +
90
+ '\n' +
91
+ podfileContent.substring(targetPos);
92
+ } else {
93
+ // If no target block found, add at the end
94
+ podfileContent += '\n' + podsToAdd.join('\n') + '\n';
95
+ }
96
+ }
97
+
98
+ fs.writeFileSync(podfilePath, podfileContent);
99
+ } catch (error) {
100
+ console.error('Error in withModularHeadersPods plugin:', error);
101
+ }
102
+
103
+ return config;
104
+ },
105
+ ]);
106
+ };
107
+
108
+ module.exports = withModularHeadersPods;