codeplay-common 1.7.1 → 1.7.2
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 +1 -1
- package/README.md +11 -11
- package/files/buildCodeplay/add-splash-screen-1.3.js +113 -113
- package/files/buildCodeplay/codeplayBeforeBuild-3.6.js +699 -699
- package/files/buildCodeplay/ios-emi-admob-modification.js +52 -52
- package/files/buildCodeplay/modify-plugin-xml.js +36 -36
- package/files/buildCodeplay/packageidBaseModification-1.0.js +242 -0
- package/files/buildCodeplay/setSplashAnimation-1.1.js +167 -167
- package/files/buildCodeplay/splashxml/codeplay_splashScreen.xml +11 -11
- package/files/finalrelease20 +685 -685
- 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 +82 -79
- package/scripts/uninstall.js +77 -77
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
/* EMI PLUGIN one line comment START */
|
|
2
|
-
|
|
3
|
-
//Note : Call showBannerAd() method after hideBannerAd(), the inset space are not set properly (The banner ad overlap the content). So hide a line in emiAdmobPlugin.m file "//[self resetWebViewHeight];"
|
|
4
|
-
const fs = require('fs');
|
|
5
|
-
const path = require('path');
|
|
6
|
-
|
|
7
|
-
const replaceEmiPluginCode=()=>
|
|
8
|
-
{
|
|
9
|
-
debugger;
|
|
10
|
-
// path to your .m file
|
|
11
|
-
const filePath = path.join(__dirname, '../ios/capacitor-cordova-ios-plugins/sourcesstatic/EmiIndoCordovaPluginAdmob/emiAdmobPlugin.m');
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
if (fs.existsSync(filePath)) {
|
|
15
|
-
let fileContent = fs.readFileSync(filePath, 'utf8');
|
|
16
|
-
|
|
17
|
-
// match the hideBannerAd method
|
|
18
|
-
const methodRegex = /(- \(void\)hideBannerAd:[\s\S]*?\{)([\s\S]*?)(^\})/m;
|
|
19
|
-
|
|
20
|
-
const match = fileContent.match(methodRegex);
|
|
21
|
-
|
|
22
|
-
if (match) {
|
|
23
|
-
const methodBody = match[2];
|
|
24
|
-
|
|
25
|
-
// replace only if the line is not already commented
|
|
26
|
-
const modifiedMethodBody = methodBody.replace(
|
|
27
|
-
/^(\s*)(?!\/\/)\[self\s+resetWebViewHeight\];/m,
|
|
28
|
-
'$1//[self resetWebViewHeight];'
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
const updatedFileContent =
|
|
32
|
-
fileContent.slice(0, match.index) +
|
|
33
|
-
match[1] +
|
|
34
|
-
modifiedMethodBody +
|
|
35
|
-
match[3] +
|
|
36
|
-
fileContent.slice(match.index + match[0].length);
|
|
37
|
-
|
|
38
|
-
fs.writeFileSync(filePath, updatedFileContent, 'utf8');
|
|
39
|
-
console.log(
|
|
40
|
-
'✅ Successfully ensured [self resetWebViewHeight]; is commented only inside hideBannerAd in emiAdmobPlugin.m'
|
|
41
|
-
);
|
|
42
|
-
} else {
|
|
43
|
-
console.log('⚠️ hideBannerAd method not found.');
|
|
44
|
-
}
|
|
45
|
-
} else {
|
|
46
|
-
console.log('ℹ️ emiAdmobPlugin.m file not found, skipping modification.');
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
replaceEmiPluginCode();
|
|
51
|
-
|
|
52
|
-
/* EMI PLUGIN one line comment END */
|
|
1
|
+
/* EMI PLUGIN one line comment START */
|
|
2
|
+
|
|
3
|
+
//Note : Call showBannerAd() method after hideBannerAd(), the inset space are not set properly (The banner ad overlap the content). So hide a line in emiAdmobPlugin.m file "//[self resetWebViewHeight];"
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
|
|
7
|
+
const replaceEmiPluginCode=()=>
|
|
8
|
+
{
|
|
9
|
+
debugger;
|
|
10
|
+
// path to your .m file
|
|
11
|
+
const filePath = path.join(__dirname, '../ios/capacitor-cordova-ios-plugins/sourcesstatic/EmiIndoCordovaPluginAdmob/emiAdmobPlugin.m');
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
if (fs.existsSync(filePath)) {
|
|
15
|
+
let fileContent = fs.readFileSync(filePath, 'utf8');
|
|
16
|
+
|
|
17
|
+
// match the hideBannerAd method
|
|
18
|
+
const methodRegex = /(- \(void\)hideBannerAd:[\s\S]*?\{)([\s\S]*?)(^\})/m;
|
|
19
|
+
|
|
20
|
+
const match = fileContent.match(methodRegex);
|
|
21
|
+
|
|
22
|
+
if (match) {
|
|
23
|
+
const methodBody = match[2];
|
|
24
|
+
|
|
25
|
+
// replace only if the line is not already commented
|
|
26
|
+
const modifiedMethodBody = methodBody.replace(
|
|
27
|
+
/^(\s*)(?!\/\/)\[self\s+resetWebViewHeight\];/m,
|
|
28
|
+
'$1//[self resetWebViewHeight];'
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
const updatedFileContent =
|
|
32
|
+
fileContent.slice(0, match.index) +
|
|
33
|
+
match[1] +
|
|
34
|
+
modifiedMethodBody +
|
|
35
|
+
match[3] +
|
|
36
|
+
fileContent.slice(match.index + match[0].length);
|
|
37
|
+
|
|
38
|
+
fs.writeFileSync(filePath, updatedFileContent, 'utf8');
|
|
39
|
+
console.log(
|
|
40
|
+
'✅ Successfully ensured [self resetWebViewHeight]; is commented only inside hideBannerAd in emiAdmobPlugin.m'
|
|
41
|
+
);
|
|
42
|
+
} else {
|
|
43
|
+
console.log('⚠️ hideBannerAd method not found.');
|
|
44
|
+
}
|
|
45
|
+
} else {
|
|
46
|
+
console.log('ℹ️ emiAdmobPlugin.m file not found, skipping modification.');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
replaceEmiPluginCode();
|
|
51
|
+
|
|
52
|
+
/* EMI PLUGIN one line comment END */
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
|
|
4
|
-
// Path to the plugin.xml file
|
|
5
|
-
const pluginXmlPath = path.join('node_modules', 'emi-indo-cordova-plugin-admob', 'plugin.xml');
|
|
6
|
-
|
|
7
|
-
// Get the store ID from the environment variable
|
|
8
|
-
const storeId = process.env.VITE_STORE_ID || '1';
|
|
9
|
-
|
|
10
|
-
// Determine the framework to use based on storeId
|
|
11
|
-
const framework = storeId === '7'
|
|
12
|
-
? '<framework src="com.google.android.gms:play-services-ads:$PLAY_SERVICES_VERSION" />'
|
|
13
|
-
: '<framework src="com.google.android.gms:play-services-ads-lite:24.0.0" />';
|
|
14
|
-
|
|
15
|
-
// Read and modify the plugin.xml file
|
|
16
|
-
fs.readFile(pluginXmlPath, 'utf8', (err, data) => {
|
|
17
|
-
if (err) {
|
|
18
|
-
console.error('Error reading plugin.xml:', err);
|
|
19
|
-
process.exit(1);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// Replace the existing framework line with the selected one
|
|
23
|
-
const modifiedData = data.replace(
|
|
24
|
-
/<framework src="com.google.android.gms:play-services-ads.*" \/>\n/,
|
|
25
|
-
`${framework}\n`
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
// Write the modified content back to plugin.xml
|
|
29
|
-
fs.writeFile(pluginXmlPath, modifiedData, 'utf8', (err) => {
|
|
30
|
-
if (err) {
|
|
31
|
-
console.error('Error writing plugin.xml:', err);
|
|
32
|
-
process.exit(1);
|
|
33
|
-
}
|
|
34
|
-
console.log('plugin.xml updated successfully.');
|
|
35
|
-
});
|
|
36
|
-
});
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
// Path to the plugin.xml file
|
|
5
|
+
const pluginXmlPath = path.join('node_modules', 'emi-indo-cordova-plugin-admob', 'plugin.xml');
|
|
6
|
+
|
|
7
|
+
// Get the store ID from the environment variable
|
|
8
|
+
const storeId = process.env.VITE_STORE_ID || '1';
|
|
9
|
+
|
|
10
|
+
// Determine the framework to use based on storeId
|
|
11
|
+
const framework = storeId === '7'
|
|
12
|
+
? '<framework src="com.google.android.gms:play-services-ads:$PLAY_SERVICES_VERSION" />'
|
|
13
|
+
: '<framework src="com.google.android.gms:play-services-ads-lite:24.0.0" />';
|
|
14
|
+
|
|
15
|
+
// Read and modify the plugin.xml file
|
|
16
|
+
fs.readFile(pluginXmlPath, 'utf8', (err, data) => {
|
|
17
|
+
if (err) {
|
|
18
|
+
console.error('Error reading plugin.xml:', err);
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Replace the existing framework line with the selected one
|
|
23
|
+
const modifiedData = data.replace(
|
|
24
|
+
/<framework src="com.google.android.gms:play-services-ads.*" \/>\n/,
|
|
25
|
+
`${framework}\n`
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
// Write the modified content back to plugin.xml
|
|
29
|
+
fs.writeFile(pluginXmlPath, modifiedData, 'utf8', (err) => {
|
|
30
|
+
if (err) {
|
|
31
|
+
console.error('Error writing plugin.xml:', err);
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
console.log('plugin.xml updated successfully.');
|
|
35
|
+
});
|
|
36
|
+
});
|
|
@@ -0,0 +1,242 @@
|
|
|
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
|
+
console.error(`❌ src/js/capacitor-app.js not found at: ${appJsPath}`);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
addFavIconCode()
|
|
228
|
+
appJssmallModifications();
|
|
229
|
+
replaceKeyboardSet()
|
|
230
|
+
|
|
231
|
+
if('apk.bulk.app.uninstaller')
|
|
232
|
+
{
|
|
233
|
+
const permissions=[
|
|
234
|
+
'<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"/>',
|
|
235
|
+
'<uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES"/>',
|
|
236
|
+
'<uses-permission android:name="android.permission.GET_PACKAGE_SIZE"/>'
|
|
237
|
+
];
|
|
238
|
+
|
|
239
|
+
// EXAMPLE USAGE
|
|
240
|
+
addAndroidPermissions(permissions);
|
|
241
|
+
}
|
|
242
|
+
|