codeplay-common 2.1.12 → 2.1.14
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/.gitattributes +2 -2
- package/LICENSE +21 -21
- package/README.md +11 -11
- package/files/buildCodeplay/add-splash-screen-1.6.js +248 -248
- package/files/buildCodeplay/codeplayBeforeBuild-5.1.js +1230 -1230
- package/files/buildCodeplay/ios-emi-admob-modification.js +52 -52
- package/files/buildCodeplay/modify-plugin-xml.js +36 -36
- package/files/buildCodeplay/packageidBaseModification-1.3.js +270 -270
- package/files/buildCodeplay/setSplashAnimation-1.2.js +170 -170
- package/files/buildCodeplay/splashxml/codeplay_splashScreen.xml +11 -11
- package/files/finalrelease +835 -835
- package/files/iap-install-2.js +145 -145
- package/files/ionic.config.json +6 -6
- package/package.json +16 -16
- package/scripts/sync-files.js +86 -86
- package/scripts/uninstall.js +77 -77
|
@@ -1,271 +1,271 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Adds user permissions to AndroidManifest.xml if not already present
|
|
7
|
-
* based on capacitor.config.json appId matching.
|
|
8
|
-
*
|
|
9
|
-
* @param {string} targetAppId - appId you want to match
|
|
10
|
-
* @param {string[]} permissionsToAdd - permission tags to insert
|
|
11
|
-
*/
|
|
12
|
-
function addAndroidPermissions(permissionsToAdd) {
|
|
13
|
-
try {
|
|
14
|
-
// read capacitor.config.json
|
|
15
|
-
const configPath = path.join(process.cwd(), 'capacitor.config.json');
|
|
16
|
-
if (!fs.existsSync(configPath)) {
|
|
17
|
-
console.error(`❌ capacitor.config.json not found at: ${configPath}`);
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const rawData = fs.readFileSync(configPath, 'utf8');
|
|
22
|
-
const config = JSON.parse(rawData);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const androidManifestPath = path.join(
|
|
27
|
-
process.cwd(),
|
|
28
|
-
'android',
|
|
29
|
-
'app',
|
|
30
|
-
'src',
|
|
31
|
-
'main',
|
|
32
|
-
'AndroidManifest.xml'
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
if (!fs.existsSync(androidManifestPath)) {
|
|
36
|
-
console.error(`❌ AndroidManifest.xml not found at: ${androidManifestPath}`);
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
let manifestContent = fs.readFileSync(androidManifestPath, 'utf8');
|
|
41
|
-
let updated = false;
|
|
42
|
-
|
|
43
|
-
permissionsToAdd.forEach(permission => {
|
|
44
|
-
if (!manifestContent.includes(permission)) {
|
|
45
|
-
console.log(`🔧 Adding permission: ${permission}`);
|
|
46
|
-
manifestContent = manifestContent.replace(
|
|
47
|
-
'</manifest>',
|
|
48
|
-
` ${permission}\n</manifest>`
|
|
49
|
-
);
|
|
50
|
-
updated = true;
|
|
51
|
-
} else {
|
|
52
|
-
console.log(`ℹ️ Permission already exists: ${permission}`);
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
if (updated) {
|
|
57
|
-
fs.writeFileSync(androidManifestPath, manifestContent, 'utf8');
|
|
58
|
-
console.log('✅ AndroidManifest.xml updated successfully.');
|
|
59
|
-
} else {
|
|
60
|
-
console.log('✅ All required permissions already present.');
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
} catch (error) {
|
|
64
|
-
console.error(`❌ Error: ${error.message}`);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const addFavIconCode=()=>{
|
|
71
|
-
const htmlFilePath = path.join(process.cwd(), 'src', 'index.html');
|
|
72
|
-
|
|
73
|
-
if (fs.existsSync(htmlFilePath)) {
|
|
74
|
-
let htmlContent = fs.readFileSync(htmlFilePath, 'utf8');
|
|
75
|
-
|
|
76
|
-
const faviconTag = '<link rel="icon" href="data:;base64,iVBORw0KGgo=">';
|
|
77
|
-
|
|
78
|
-
if (!htmlContent.includes(faviconTag)) {
|
|
79
|
-
const headOpenTag = '<head>';
|
|
80
|
-
const headIndex = htmlContent.indexOf(headOpenTag);
|
|
81
|
-
|
|
82
|
-
if (headIndex !== -1) {
|
|
83
|
-
const insertPos = headIndex + headOpenTag.length;
|
|
84
|
-
htmlContent =
|
|
85
|
-
htmlContent.slice(0, insertPos) +
|
|
86
|
-
`\n ${faviconTag}` +
|
|
87
|
-
htmlContent.slice(insertPos);
|
|
88
|
-
|
|
89
|
-
fs.writeFileSync(htmlFilePath, htmlContent, 'utf8');
|
|
90
|
-
console.log(`✅ Favicon link added successfully to index.html`);
|
|
91
|
-
} else {
|
|
92
|
-
console.error('❌ <head> tag not found in index.html');
|
|
93
|
-
}
|
|
94
|
-
} else {
|
|
95
|
-
console.log('ℹ️ Favicon link already exists in index.html');
|
|
96
|
-
}
|
|
97
|
-
} else {
|
|
98
|
-
console.error(`❌ index.html not found at: ${htmlFilePath}`);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
const appJssmallModifications=()=>{
|
|
104
|
-
|
|
105
|
-
const appJsPath = path.join(process.cwd(), 'src', 'js', 'app.js');
|
|
106
|
-
|
|
107
|
-
if (fs.existsSync(appJsPath)) {
|
|
108
|
-
let appJsContent = fs.readFileSync(appJsPath, 'utf8');
|
|
109
|
-
|
|
110
|
-
// 1. ensure iosOverlaysWebView is true
|
|
111
|
-
if (/iosOverlaysWebView\s*:\s*false/.test(appJsContent)) {
|
|
112
|
-
appJsContent = appJsContent.replace(/iosOverlaysWebView\s*:\s*false/, 'iosOverlaysWebView: true');
|
|
113
|
-
console.log('✅ iosOverlaysWebView changed to true');
|
|
114
|
-
} else if (!/iosOverlaysWebView\s*:/.test(appJsContent)) {
|
|
115
|
-
// add if missing
|
|
116
|
-
appJsContent = appJsContent.replace(
|
|
117
|
-
/statusbar\s*:\s*\{/,
|
|
118
|
-
`statusbar: {\n iosOverlaysWebView: true,`
|
|
119
|
-
);
|
|
120
|
-
console.log('✅ iosOverlaysWebView added');
|
|
121
|
-
} else {
|
|
122
|
-
console.log('ℹ️ iosOverlaysWebView already true');
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// 2. ensure androidOverlaysWebView is true
|
|
126
|
-
if (/androidOverlaysWebView\s*:\s*false/.test(appJsContent)) {
|
|
127
|
-
appJsContent = appJsContent.replace(/androidOverlaysWebView\s*:\s*false/, 'androidOverlaysWebView: true');
|
|
128
|
-
console.log('✅ androidOverlaysWebView changed to true');
|
|
129
|
-
} else if (!/androidOverlaysWebView\s*:/.test(appJsContent)) {
|
|
130
|
-
// add if missing
|
|
131
|
-
appJsContent = appJsContent.replace(
|
|
132
|
-
/statusbar\s*:\s*\{/,
|
|
133
|
-
`statusbar: {\n androidOverlaysWebView: true,`
|
|
134
|
-
);
|
|
135
|
-
console.log('✅ androidOverlaysWebView added');
|
|
136
|
-
} else {
|
|
137
|
-
console.log('ℹ️ androidOverlaysWebView already true');
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// 3. change theme
|
|
141
|
-
const themeRegex = /theme\s*:\s*['"]auto['"]/;
|
|
142
|
-
if (themeRegex.test(appJsContent)) {
|
|
143
|
-
appJsContent = appJsContent.replace(themeRegex, `theme: 'md'`);
|
|
144
|
-
console.log('✅ theme changed to md');
|
|
145
|
-
} else {
|
|
146
|
-
console.log('ℹ️ theme: auto not found, no changes made');
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
fs.writeFileSync(appJsPath, appJsContent, 'utf8');
|
|
150
|
-
console.log('✅ app.js updated successfully');
|
|
151
|
-
} else {
|
|
152
|
-
console.error(`❌ src/js/app.js not found at: ${appJsPath}`);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
const replaceKeyboardSet=()=>{
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
const appJsPath = path.join(process.cwd(), 'src', 'js', 'capacitor-app.js');
|
|
161
|
-
|
|
162
|
-
if (fs.existsSync(appJsPath)) {
|
|
163
|
-
let appJsContent = fs.readFileSync(appJsPath, 'utf8');
|
|
164
|
-
|
|
165
|
-
const lines = appJsContent.split(/\r?\n/);
|
|
166
|
-
const newLines = [];
|
|
167
|
-
|
|
168
|
-
const targetKeywords = [
|
|
169
|
-
'Keyboard.setResizeMode',
|
|
170
|
-
'Keyboard.setScroll',
|
|
171
|
-
'Keyboard.setAccessoryBarVisible',
|
|
172
|
-
];
|
|
173
|
-
|
|
174
|
-
let insideIosWrap = false;
|
|
175
|
-
|
|
176
|
-
lines.forEach((line, index) => {
|
|
177
|
-
const trimmed = line.trim();
|
|
178
|
-
|
|
179
|
-
// detect already inside ios check
|
|
180
|
-
if (/if\s*\(\s*Capacitor\.getPlatform\(\)\s*===\s*['"]ios['"]\s*\)/.test(trimmed)) {
|
|
181
|
-
insideIosWrap = true;
|
|
182
|
-
newLines.push(line);
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
// detect closing of a block
|
|
187
|
-
if (insideIosWrap && trimmed === '}') {
|
|
188
|
-
insideIosWrap = false;
|
|
189
|
-
newLines.push(line);
|
|
190
|
-
return;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
const isKeyboardSetCall = targetKeywords.some((kw) => trimmed.startsWith(kw));
|
|
194
|
-
|
|
195
|
-
if (isKeyboardSetCall) {
|
|
196
|
-
if (!insideIosWrap) {
|
|
197
|
-
const indentMatch = line.match(/^(\s*)/);
|
|
198
|
-
const indent = indentMatch ? indentMatch[1] : '';
|
|
199
|
-
newLines.push(`${indent}if (Capacitor.getPlatform() === 'ios') {`);
|
|
200
|
-
newLines.push(`${indent} ${trimmed}`);
|
|
201
|
-
newLines.push(`${indent}}`);
|
|
202
|
-
console.log(`✅ Wrapped line ${index + 1} with ios check`);
|
|
203
|
-
} else {
|
|
204
|
-
// already inside ios wrap, leave alone
|
|
205
|
-
newLines.push(line);
|
|
206
|
-
}
|
|
207
|
-
} else {
|
|
208
|
-
newLines.push(line);
|
|
209
|
-
}
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
fs.writeFileSync(appJsPath, newLines.join('\n'), 'utf8');
|
|
213
|
-
console.log(`✅ All Keyboard.set* lines wrapped safely with ios check`);
|
|
214
|
-
} else {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
const configPath = path.join(process.cwd(), 'capacitor.config.json');
|
|
218
|
-
|
|
219
|
-
const rawData = fs.readFileSync(configPath, 'utf8');
|
|
220
|
-
const config = JSON.parse(rawData);
|
|
221
|
-
|
|
222
|
-
const appUniqueId=config.android.APP_UNIQUE_ID
|
|
223
|
-
|
|
224
|
-
if(appUniqueId!=172)
|
|
225
|
-
console.error(`❌ src/js/capacitor-app.js not found at: ${appJsPath}`);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
addFavIconCode()
|
|
238
|
-
appJssmallModifications();
|
|
239
|
-
replaceKeyboardSet()
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
const configPath = path.join(process.cwd(), 'capacitor.config.json');
|
|
247
|
-
if (!fs.existsSync(configPath)) {
|
|
248
|
-
console.error(`❌ capacitor.config.json not found at: ${configPath}`);
|
|
249
|
-
//return;
|
|
250
|
-
}
|
|
251
|
-
const rawData = fs.readFileSync(configPath, 'utf8');
|
|
252
|
-
const config = JSON.parse(rawData);
|
|
253
|
-
const targetAppId=config.appId
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
//console.log("TARGET APP ID IS : "+ targetAppId)
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
if(targetAppId=='apk.bulk.app.uninstaller' || targetAppId=='apk.extractor.installer')
|
|
262
|
-
{
|
|
263
|
-
const permissions=[
|
|
264
|
-
'<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"/>',
|
|
265
|
-
'<uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES"/>',
|
|
266
|
-
'<uses-permission android:name="android.permission.GET_PACKAGE_SIZE"/>'
|
|
267
|
-
];
|
|
268
|
-
|
|
269
|
-
// EXAMPLE USAGE
|
|
270
|
-
addAndroidPermissions(permissions);
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Adds user permissions to AndroidManifest.xml if not already present
|
|
7
|
+
* based on capacitor.config.json appId matching.
|
|
8
|
+
*
|
|
9
|
+
* @param {string} targetAppId - appId you want to match
|
|
10
|
+
* @param {string[]} permissionsToAdd - permission tags to insert
|
|
11
|
+
*/
|
|
12
|
+
function addAndroidPermissions(permissionsToAdd) {
|
|
13
|
+
try {
|
|
14
|
+
// read capacitor.config.json
|
|
15
|
+
const configPath = path.join(process.cwd(), 'capacitor.config.json');
|
|
16
|
+
if (!fs.existsSync(configPath)) {
|
|
17
|
+
console.error(`❌ capacitor.config.json not found at: ${configPath}`);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const rawData = fs.readFileSync(configPath, 'utf8');
|
|
22
|
+
const config = JSON.parse(rawData);
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
const androidManifestPath = path.join(
|
|
27
|
+
process.cwd(),
|
|
28
|
+
'android',
|
|
29
|
+
'app',
|
|
30
|
+
'src',
|
|
31
|
+
'main',
|
|
32
|
+
'AndroidManifest.xml'
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
if (!fs.existsSync(androidManifestPath)) {
|
|
36
|
+
console.error(`❌ AndroidManifest.xml not found at: ${androidManifestPath}`);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
let manifestContent = fs.readFileSync(androidManifestPath, 'utf8');
|
|
41
|
+
let updated = false;
|
|
42
|
+
|
|
43
|
+
permissionsToAdd.forEach(permission => {
|
|
44
|
+
if (!manifestContent.includes(permission)) {
|
|
45
|
+
console.log(`🔧 Adding permission: ${permission}`);
|
|
46
|
+
manifestContent = manifestContent.replace(
|
|
47
|
+
'</manifest>',
|
|
48
|
+
` ${permission}\n</manifest>`
|
|
49
|
+
);
|
|
50
|
+
updated = true;
|
|
51
|
+
} else {
|
|
52
|
+
console.log(`ℹ️ Permission already exists: ${permission}`);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
if (updated) {
|
|
57
|
+
fs.writeFileSync(androidManifestPath, manifestContent, 'utf8');
|
|
58
|
+
console.log('✅ AndroidManifest.xml updated successfully.');
|
|
59
|
+
} else {
|
|
60
|
+
console.log('✅ All required permissions already present.');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
} catch (error) {
|
|
64
|
+
console.error(`❌ Error: ${error.message}`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
const addFavIconCode=()=>{
|
|
71
|
+
const htmlFilePath = path.join(process.cwd(), 'src', 'index.html');
|
|
72
|
+
|
|
73
|
+
if (fs.existsSync(htmlFilePath)) {
|
|
74
|
+
let htmlContent = fs.readFileSync(htmlFilePath, 'utf8');
|
|
75
|
+
|
|
76
|
+
const faviconTag = '<link rel="icon" href="data:;base64,iVBORw0KGgo=">';
|
|
77
|
+
|
|
78
|
+
if (!htmlContent.includes(faviconTag)) {
|
|
79
|
+
const headOpenTag = '<head>';
|
|
80
|
+
const headIndex = htmlContent.indexOf(headOpenTag);
|
|
81
|
+
|
|
82
|
+
if (headIndex !== -1) {
|
|
83
|
+
const insertPos = headIndex + headOpenTag.length;
|
|
84
|
+
htmlContent =
|
|
85
|
+
htmlContent.slice(0, insertPos) +
|
|
86
|
+
`\n ${faviconTag}` +
|
|
87
|
+
htmlContent.slice(insertPos);
|
|
88
|
+
|
|
89
|
+
fs.writeFileSync(htmlFilePath, htmlContent, 'utf8');
|
|
90
|
+
console.log(`✅ Favicon link added successfully to index.html`);
|
|
91
|
+
} else {
|
|
92
|
+
console.error('❌ <head> tag not found in index.html');
|
|
93
|
+
}
|
|
94
|
+
} else {
|
|
95
|
+
console.log('ℹ️ Favicon link already exists in index.html');
|
|
96
|
+
}
|
|
97
|
+
} else {
|
|
98
|
+
console.error(`❌ index.html not found at: ${htmlFilePath}`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
const appJssmallModifications=()=>{
|
|
104
|
+
|
|
105
|
+
const appJsPath = path.join(process.cwd(), 'src', 'js', 'app.js');
|
|
106
|
+
|
|
107
|
+
if (fs.existsSync(appJsPath)) {
|
|
108
|
+
let appJsContent = fs.readFileSync(appJsPath, 'utf8');
|
|
109
|
+
|
|
110
|
+
// 1. ensure iosOverlaysWebView is true
|
|
111
|
+
if (/iosOverlaysWebView\s*:\s*false/.test(appJsContent)) {
|
|
112
|
+
appJsContent = appJsContent.replace(/iosOverlaysWebView\s*:\s*false/, 'iosOverlaysWebView: true');
|
|
113
|
+
console.log('✅ iosOverlaysWebView changed to true');
|
|
114
|
+
} else if (!/iosOverlaysWebView\s*:/.test(appJsContent)) {
|
|
115
|
+
// add if missing
|
|
116
|
+
appJsContent = appJsContent.replace(
|
|
117
|
+
/statusbar\s*:\s*\{/,
|
|
118
|
+
`statusbar: {\n iosOverlaysWebView: true,`
|
|
119
|
+
);
|
|
120
|
+
console.log('✅ iosOverlaysWebView added');
|
|
121
|
+
} else {
|
|
122
|
+
console.log('ℹ️ iosOverlaysWebView already true');
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// 2. ensure androidOverlaysWebView is true
|
|
126
|
+
if (/androidOverlaysWebView\s*:\s*false/.test(appJsContent)) {
|
|
127
|
+
appJsContent = appJsContent.replace(/androidOverlaysWebView\s*:\s*false/, 'androidOverlaysWebView: true');
|
|
128
|
+
console.log('✅ androidOverlaysWebView changed to true');
|
|
129
|
+
} else if (!/androidOverlaysWebView\s*:/.test(appJsContent)) {
|
|
130
|
+
// add if missing
|
|
131
|
+
appJsContent = appJsContent.replace(
|
|
132
|
+
/statusbar\s*:\s*\{/,
|
|
133
|
+
`statusbar: {\n androidOverlaysWebView: true,`
|
|
134
|
+
);
|
|
135
|
+
console.log('✅ androidOverlaysWebView added');
|
|
136
|
+
} else {
|
|
137
|
+
console.log('ℹ️ androidOverlaysWebView already true');
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// 3. change theme
|
|
141
|
+
const themeRegex = /theme\s*:\s*['"]auto['"]/;
|
|
142
|
+
if (themeRegex.test(appJsContent)) {
|
|
143
|
+
appJsContent = appJsContent.replace(themeRegex, `theme: 'md'`);
|
|
144
|
+
console.log('✅ theme changed to md');
|
|
145
|
+
} else {
|
|
146
|
+
console.log('ℹ️ theme: auto not found, no changes made');
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
fs.writeFileSync(appJsPath, appJsContent, 'utf8');
|
|
150
|
+
console.log('✅ app.js updated successfully');
|
|
151
|
+
} else {
|
|
152
|
+
console.error(`❌ src/js/app.js not found at: ${appJsPath}`);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
const replaceKeyboardSet=()=>{
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
const appJsPath = path.join(process.cwd(), 'src', 'js', 'capacitor-app.js');
|
|
161
|
+
|
|
162
|
+
if (fs.existsSync(appJsPath)) {
|
|
163
|
+
let appJsContent = fs.readFileSync(appJsPath, 'utf8');
|
|
164
|
+
|
|
165
|
+
const lines = appJsContent.split(/\r?\n/);
|
|
166
|
+
const newLines = [];
|
|
167
|
+
|
|
168
|
+
const targetKeywords = [
|
|
169
|
+
'Keyboard.setResizeMode',
|
|
170
|
+
'Keyboard.setScroll',
|
|
171
|
+
'Keyboard.setAccessoryBarVisible',
|
|
172
|
+
];
|
|
173
|
+
|
|
174
|
+
let insideIosWrap = false;
|
|
175
|
+
|
|
176
|
+
lines.forEach((line, index) => {
|
|
177
|
+
const trimmed = line.trim();
|
|
178
|
+
|
|
179
|
+
// detect already inside ios check
|
|
180
|
+
if (/if\s*\(\s*Capacitor\.getPlatform\(\)\s*===\s*['"]ios['"]\s*\)/.test(trimmed)) {
|
|
181
|
+
insideIosWrap = true;
|
|
182
|
+
newLines.push(line);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// detect closing of a block
|
|
187
|
+
if (insideIosWrap && trimmed === '}') {
|
|
188
|
+
insideIosWrap = false;
|
|
189
|
+
newLines.push(line);
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const isKeyboardSetCall = targetKeywords.some((kw) => trimmed.startsWith(kw));
|
|
194
|
+
|
|
195
|
+
if (isKeyboardSetCall) {
|
|
196
|
+
if (!insideIosWrap) {
|
|
197
|
+
const indentMatch = line.match(/^(\s*)/);
|
|
198
|
+
const indent = indentMatch ? indentMatch[1] : '';
|
|
199
|
+
newLines.push(`${indent}if (Capacitor.getPlatform() === 'ios') {`);
|
|
200
|
+
newLines.push(`${indent} ${trimmed}`);
|
|
201
|
+
newLines.push(`${indent}}`);
|
|
202
|
+
console.log(`✅ Wrapped line ${index + 1} with ios check`);
|
|
203
|
+
} else {
|
|
204
|
+
// already inside ios wrap, leave alone
|
|
205
|
+
newLines.push(line);
|
|
206
|
+
}
|
|
207
|
+
} else {
|
|
208
|
+
newLines.push(line);
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
fs.writeFileSync(appJsPath, newLines.join('\n'), 'utf8');
|
|
213
|
+
console.log(`✅ All Keyboard.set* lines wrapped safely with ios check`);
|
|
214
|
+
} else {
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
const configPath = path.join(process.cwd(), 'capacitor.config.json');
|
|
218
|
+
|
|
219
|
+
const rawData = fs.readFileSync(configPath, 'utf8');
|
|
220
|
+
const config = JSON.parse(rawData);
|
|
221
|
+
|
|
222
|
+
const appUniqueId=config.android.APP_UNIQUE_ID
|
|
223
|
+
|
|
224
|
+
if(appUniqueId!=172)
|
|
225
|
+
console.error(`❌ src/js/capacitor-app.js not found at: ${appJsPath}`);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
addFavIconCode()
|
|
238
|
+
appJssmallModifications();
|
|
239
|
+
replaceKeyboardSet()
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
const configPath = path.join(process.cwd(), 'capacitor.config.json');
|
|
247
|
+
if (!fs.existsSync(configPath)) {
|
|
248
|
+
console.error(`❌ capacitor.config.json not found at: ${configPath}`);
|
|
249
|
+
//return;
|
|
250
|
+
}
|
|
251
|
+
const rawData = fs.readFileSync(configPath, 'utf8');
|
|
252
|
+
const config = JSON.parse(rawData);
|
|
253
|
+
const targetAppId=config.appId
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
//console.log("TARGET APP ID IS : "+ targetAppId)
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
if(targetAppId=='apk.bulk.app.uninstaller' || targetAppId=='apk.extractor.installer')
|
|
262
|
+
{
|
|
263
|
+
const permissions=[
|
|
264
|
+
'<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"/>',
|
|
265
|
+
'<uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES"/>',
|
|
266
|
+
'<uses-permission android:name="android.permission.GET_PACKAGE_SIZE"/>'
|
|
267
|
+
];
|
|
268
|
+
|
|
269
|
+
// EXAMPLE USAGE
|
|
270
|
+
addAndroidPermissions(permissions);
|
|
271
271
|
}
|