codeplay-common 4.9.9 → 4.10.1
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/CHANGELOG.md +33 -17
- package/README.md +24 -10
- package/RELEASE_NOTES.md +31 -15
- package/files/buildCodeplay/{add-splash-screen-1.6.js → add-splash-screen.js} +255 -254
- package/files/buildCodeplay/apk-store-builder.js +97 -97
- package/files/buildCodeplay/{codeplayBeforeBuild-6.5.js → codeplayBeforeBuild.js} +179 -80
- package/files/buildCodeplay/fix-onesignal-plugin.js +96 -96
- package/files/buildCodeplay/ios-emi-admob-modification.js +24 -24
- package/files/buildCodeplay/manifestModification.js +23 -23
- package/files/buildCodeplay/{packageidBaseModification-1.4.js → packageidBaseModification.js} +445 -445
- package/files/buildCodeplay/project-scripts.cjs +56 -0
- package/files/buildCodeplay/{setSplashAnimation-1.4.js → setSplashAnimation.js} +156 -156
- package/files/buildCodeplay/sync-admob-nextgen.js +6 -5
- package/files/buildCodeplay/versions.json +25 -25
- package/files/finalrelease +1222 -1343
- package/files/take-screen-image.js +2 -2
- package/package.json +14 -5
- package/scripts/sync-files.js +80 -112
- package/scripts/uninstall.js +3 -123
- package/.gitattributes +0 -2
- package/files/buildCodeplay/codeplayBeforeBuild-6.4.js +0 -4510
- package/files/iap-install-2.js +0 -145
- /package/files/{scripts → scripts-common}/screenshot/background-decorations.js +0 -0
- /package/files/{scripts → scripts-common}/screenshot/frame-samples.js +0 -0
- /package/files/{scripts → scripts-common}/setup-baseline-profile.js +0 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const tasks = {
|
|
4
|
+
'before-build': 'node buildCodeplay/codeplayBeforeBuild.js',
|
|
5
|
+
'package-id': 'node buildCodeplay/packageidBaseModification.js',
|
|
6
|
+
'splash': 'node buildCodeplay/add-splash-screen.js',
|
|
7
|
+
'splash-animation': 'node buildCodeplay/setSplashAnimation.js',
|
|
8
|
+
'manifest': 'node buildCodeplay/manifestModification.js',
|
|
9
|
+
'admob-sync': 'node buildCodeplay/sync-admob-nextgen.js',
|
|
10
|
+
'apk': 'node buildCodeplay/apk-store-builder.js',
|
|
11
|
+
'final-release': 'node finalrelease',
|
|
12
|
+
};
|
|
13
|
+
const syncAfter = `${tasks.splash} && ${tasks['splash-animation']} && ${tasks.manifest} && node scripts-common/setup-baseline-profile.js`;
|
|
14
|
+
function updateBuildScripts(scripts) {
|
|
15
|
+
const next = { ...scripts };
|
|
16
|
+
for (const key of Object.keys(next)) {
|
|
17
|
+
if (typeof next[key] !== 'string') continue;
|
|
18
|
+
next[key] = next[key].replace(/(^|[\s"'=])(\.\/)?scripts\//g, '$1$2scripts-common/');
|
|
19
|
+
next[key] = next[key].replace(/node\s+node_modules\/codeplay-common\/scripts\/run\.cjs\s+([\w-]+)/g, (match, task) => tasks[task] || (task === 'sync-after' ? syncAfter : match))
|
|
20
|
+
.replace(/buildCodeplay\/(codeplayBeforeBuild|packageidBaseModification|add-splash-screen|setSplashAnimation)-\d+(?:\.\d+)*\.(?:js|mjs)/g, 'buildCodeplay/$1.js')
|
|
21
|
+
.replace(/node\s+iap-install-\d+(?:\.\d+)*\.js/g, tasks['before-build']);
|
|
22
|
+
}
|
|
23
|
+
if (!next.build) next.build = `${tasks['before-build']} && ${tasks['package-id']} && cross-env NODE_ENV=production vite build --logLevel warn`;
|
|
24
|
+
else if (!next.build.includes(tasks['before-build'])) next.build = `${tasks['before-build']} && ${next.build}`;
|
|
25
|
+
for (const id of [1, 2, 3, 4, 5, 7, 8]) {
|
|
26
|
+
const key = `build:storeid${id}`;
|
|
27
|
+
if (!next[key]) next[key] = `vite build --mode storeid${id}`;
|
|
28
|
+
if (!next[key].includes(tasks['before-build'])) next[key] = `cross-env VITE_STORE_ID=${id} ${tasks['before-build']} && cross-env VITE_STORE_ID=${id} ${next[key]}`;
|
|
29
|
+
}
|
|
30
|
+
if (next['build:storeid6'] && !next['build:storeid6'].includes(tasks['before-build'])) next['build:storeid6'] = `cross-env CODEPLAY_BUILD_PLATFORM=ios VITE_STORE_ID=6 ${tasks['before-build']} && cross-env VITE_STORE_ID=6 ${next['build:storeid6']}`;
|
|
31
|
+
next['build:ios'] = next['build:ios'] || 'cross-env CODEPLAY_BUILD_PLATFORM=ios VITE_STORE_ID=6 npm run build';
|
|
32
|
+
if (!/VITE_STORE_ID=6\b/.test(next['build:ios'])) next['build:ios'] = next['build:ios'].replace('CODEPLAY_BUILD_PLATFORM=ios ', 'CODEPLAY_BUILD_PLATFORM=ios VITE_STORE_ID=6 ');
|
|
33
|
+
next['capacitor:sync:after'] = next['capacitor:sync:after'] || syncAfter;
|
|
34
|
+
next['build-capacitor-android'] = next['build-capacitor-android'] || 'npm run build && npx cap copy android';
|
|
35
|
+
next['build-capacitor-ios'] = next['build-capacitor-ios']
|
|
36
|
+
? next['build-capacitor-ios'].replace(/^(?:cross-env\s+NODE_ENV=production\s+)?vite\s+build(?=\s*&&\s*npx\s+cap\s+copy\s+ios\b)/, 'npm run build:ios')
|
|
37
|
+
: 'npm run build:ios && npx cap copy ios';
|
|
38
|
+
next['ionic:build'] = next['ionic:build'] || 'npm run build';
|
|
39
|
+
next['ionic:serve'] = next['ionic:serve'] || 'cross-env NODE_ENV=development vite';
|
|
40
|
+
next['baseline-profile:setup'] = next['baseline-profile:setup'] || 'node scripts-common/setup-baseline-profile.js';
|
|
41
|
+
next['baseline-profile:generate'] = next['baseline-profile:generate'] || 'cd android && gradlew.bat :app:generateBaselineProfile --console=plain';
|
|
42
|
+
next.release = next.release || 'node finalrelease';
|
|
43
|
+
return next;
|
|
44
|
+
}
|
|
45
|
+
function removeVersionedBuildScripts(projectRoot) {
|
|
46
|
+
const directory = path.resolve(projectRoot, 'buildCodeplay');
|
|
47
|
+
if (!fs.existsSync(directory)) return;
|
|
48
|
+
if (fs.lstatSync(directory).isSymbolicLink()) throw new Error('Refusing to clean a linked buildCodeplay directory.');
|
|
49
|
+
for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {
|
|
50
|
+
if (!entry.isFile() || (entry.name !== 'sync-startup.cjs' && !/^(?:codeplayBeforeBuild|packageidBaseModification|add-splash-screen|setSplashAnimation)-\d+(?:\.\d+)*\.(?:js|mjs)$/.test(entry.name))) continue;
|
|
51
|
+
const target = path.resolve(directory, entry.name);
|
|
52
|
+
if (path.dirname(target) !== directory) throw new Error('Invalid legacy build path.');
|
|
53
|
+
fs.unlinkSync(target);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
module.exports = { updateBuildScripts, removeVersionedBuildScripts };
|
|
@@ -1,127 +1,127 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const readline = require('readline');
|
|
3
|
-
const path = require('path');
|
|
4
|
-
|
|
5
|
-
// Define the root directory of the project (adjust if needed)
|
|
6
|
-
const projectRoot = path.join('android/app/src/main');
|
|
7
|
-
|
|
8
|
-
// Animation options
|
|
9
|
-
const animations = [
|
|
10
|
-
{ id: 1, name: 'Ripple Effect', code: `.scaleX(1.2f).scaleY(1.2f).alpha(0.3f)` }, //Okay super
|
|
11
|
-
{ id: 2, name: 'Pop Out', code: `.scaleX(1.2f).scaleY(1.2f).alpha(0f)` }, //Okay super
|
|
12
|
-
{ id: 3, name: 'Super Zoom', code: `.scaleX(1.5f).scaleY(1.5f).alpha(1f)` }, //Okay super
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
{ id: 4, name: 'Flip and Fade', code: `.scaleX(0f).scaleY(0f).rotation(180f).alpha(0f)` }, //Okay
|
|
16
|
-
{ id: 5, name: 'Wipe Away', code: `.translationX(splashScreenView.getWidth()).alpha(0f)` }, //Okay
|
|
17
|
-
{ id: 6, name: 'Bounce in Spiral', code: `.scaleX(0.5f).scaleY(0.5f).alpha(0.5f).rotation(360f)` }, //Okay
|
|
18
|
-
{ id: 7, name: 'Fade and Slide', code: `.alpha(0f).translationY(splashScreenView.getHeight())` }, //Okay
|
|
19
|
-
{ id: 8, name: 'Zoom Out with Bounce', code: `.scaleX(0f).scaleY(0f).alpha(0f).translationY(splashScreenView.getHeight())` }, //Okay
|
|
20
|
-
{ id: 9, name: 'Twist', code: `.rotation(720f).alpha(0f)` }, //Okay
|
|
21
|
-
{ id: 10, name: 'Rotate Back', code: `.rotation(-360f).alpha(1f)` }, //Okay
|
|
22
|
-
{ id: 11, name: 'Stretch In', code: `.scaleX(1.5f).scaleY(1.5f).alpha(1f)` }, //Okay
|
|
23
|
-
{ id: 12, name: 'Fade and Scale', code: `.alpha(0f).scaleX(0f).scaleY(0f)` }, //Okay
|
|
24
|
-
{ id: 13, name: 'Slide Left and Fade', code: `.translationX(-splashScreenView.getWidth()).alpha(0f)` }, //Okay
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
{ id: 14, name: 'Fade Out', code: `.alpha(0f)` },
|
|
28
|
-
{ id: 15, name: 'Slide Down', code: `.translationY(splashScreenView.getHeight())` },
|
|
29
|
-
{ id: 16, name: 'Zoom Out', code: `.scaleX(0f).scaleY(0f).alpha(0f)` },
|
|
30
|
-
{ id: 17, name: 'Rotate Out', code: `.rotation(360f).alpha(0f)` },
|
|
31
|
-
{ id: 18, name: 'Slide Up', code: `.translationY(-splashScreenView.getHeight()).alpha(0f)` },
|
|
32
|
-
{ id: 19, name: 'Bounce Effect', code: `.translationY(splashScreenView.getHeight())` },
|
|
33
|
-
{ id: 20, name: 'Flip Out', code: `.scaleX(0f).alpha(0f)` },
|
|
34
|
-
{ id: 21, name: 'Diagonal Slide and Fade Out', code: `.translationX(splashScreenView.getWidth()).translationY(splashScreenView.getHeight()).alpha(0f)` },
|
|
35
|
-
{ id: 22, name: 'Scale Down with Bounce', code: `.scaleX(0f).scaleY(0f)` },
|
|
36
|
-
{ id: 23, name: 'Slide Left', code: `.translationX(-splashScreenView.getWidth()).alpha(0f)` },
|
|
37
|
-
{ id: 24, name: 'Slide Right', code: `.translationX(splashScreenView.getWidth()).alpha(0f)` },
|
|
38
|
-
{ id: 25, name: 'Scale Up', code: `.scaleX(1f).scaleY(1f).alpha(1f)` },
|
|
39
|
-
{ id: 26, name: 'Rotate In', code: `.rotation(180f).alpha(1f)` },
|
|
40
|
-
{ id: 27, name: 'Bounce Up', code: `.translationY(-100f).setInterpolator(new BounceInterpolator())` },
|
|
41
|
-
{ id: 28, name: 'Flip Horizontal', code: `.scaleX(-1f).alpha(1f)` },
|
|
42
|
-
{ id: 29, name: 'Zoom In', code: `.scaleX(1f).scaleY(1f).alpha(1f)` },
|
|
43
|
-
{ id: 30, name: 'Wobble', code: `.translationX(10f).translationX(-10f).translationX(10f)` },
|
|
44
|
-
{ id: 31, name: 'Vertical Shake', code: `.translationY(10f).translationY(-10f).translationY(10f)` },
|
|
45
|
-
{ id: 32, name: 'Bounce Down', code: `.translationY(100f).setInterpolator(new BounceInterpolator())` },
|
|
46
|
-
{ id: 33, name: 'Swing', code: `.rotation(15f).translationX(-10f).rotation(-15f).translationX(10f)` },
|
|
47
|
-
{ id: 34, name: 'Elastic Bounce', code: `.translationX(30f).translationX(-30f).translationX(15f).translationX(-15f)` },
|
|
48
|
-
{ id: 35, name: 'Pulse', code: `.scaleX(1.1f).scaleY(1.1f).alpha(1f).setRepeatMode(ValueAnimator.REVERSE).setRepeatCount(ValueAnimator.INFINITE)` },
|
|
49
|
-
{ id: 36, name: 'Skew', code: `.setRotationX(30f).setRotationY(30f).alpha(0.5f)` },
|
|
50
|
-
{ id: 37, name: 'Vibrate', code: `.translationX(5f).translationX(-5f).translationX(5f).translationX(-5f)` },
|
|
51
|
-
{ id: 38, name: 'Speed Out', code: `.alpha(0f).setDuration(300)` },
|
|
52
|
-
{ id: 39, name: 'Wave', code: `.translationX(20f).translationX(-20f).translationX(20f).translationX(-20f)` },
|
|
53
|
-
{ id: 40, name: 'Swing Bounce', code: `.rotation(15f).translationX(10f).translationX(-10f)` },
|
|
54
|
-
];
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
// Function to find the package name from capacitor.config.json
|
|
58
|
-
function findPackageName() {
|
|
59
|
-
const configPath = path.join('capacitor.config.json');
|
|
60
|
-
if (!fs.existsSync(configPath)) {
|
|
61
|
-
console.error('capacitor.config.json not found. Ensure this is a valid Capacitor project.');
|
|
62
|
-
process.exit(1);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const configContent = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
66
|
-
return configContent.appId;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// Function to construct the MainActivity.java path
|
|
70
|
-
function constructMainActivityPath(packageName) {
|
|
71
|
-
const packagePath = packageName.replace(/\./g, '/'); // Convert package name to path
|
|
72
|
-
const mainActivityPath = path.join('android', 'app', 'src', 'main', 'java', packagePath, 'MainActivity.java');
|
|
73
|
-
|
|
74
|
-
console.log('MainActivity path:', mainActivityPath); // Output for debugging
|
|
75
|
-
return mainActivityPath;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Find package name and MainActivity.java path
|
|
79
|
-
const packageName = findPackageName();
|
|
80
|
-
if (!packageName) {
|
|
81
|
-
console.error('Failed to extract the package name from capacitor.config.json.');
|
|
82
|
-
process.exit(1);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const mainActivityPath = constructMainActivityPath(packageName);
|
|
86
|
-
|
|
87
|
-
// Display animation options
|
|
88
|
-
/* const rl = readline.createInterface({
|
|
89
|
-
input: process.stdin,
|
|
90
|
-
output: process.stdout,
|
|
91
|
-
}); */
|
|
92
|
-
|
|
93
|
-
console.log('Select an animation type for the splash screen:');
|
|
94
|
-
animations.forEach((animation) => {
|
|
95
|
-
//console.log(`${animation.id}. ${animation.name}`);
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
// Prompt user for animation selection
|
|
99
|
-
//rl.question('Enter the number of the animation type: ', (answer) => {
|
|
100
|
-
|
|
101
|
-
const answer=1;
|
|
102
|
-
|
|
103
|
-
const selectedAnimation = animations.find((anim) => anim.id === parseInt(answer, 10));
|
|
104
|
-
|
|
105
|
-
if (!selectedAnimation) {
|
|
106
|
-
console.log('Invalid selection. Please run the script again.');
|
|
107
|
-
//rl.close();
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
console.log(`Selected: ${selectedAnimation.name}`);
|
|
112
|
-
|
|
113
|
-
// Read the MainActivity.java file
|
|
114
|
-
fs.readFile(mainActivityPath, 'utf8', (err, data) => {
|
|
115
|
-
if (err) {
|
|
116
|
-
console.error(`Error reading MainActivity.java: ${err.message}`);
|
|
117
|
-
//rl.close();
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// New logic for removing existing code and adding new splash screen animation code
|
|
122
|
-
const newMainActivityCode =
|
|
123
|
-
`package ${findPackageName()};
|
|
124
|
-
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const readline = require('readline');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
|
|
5
|
+
// Define the root directory of the project (adjust if needed)
|
|
6
|
+
const projectRoot = path.join('android/app/src/main');
|
|
7
|
+
|
|
8
|
+
// Animation options
|
|
9
|
+
const animations = [
|
|
10
|
+
{ id: 1, name: 'Ripple Effect', code: `.scaleX(1.2f).scaleY(1.2f).alpha(0.3f)` }, //Okay super
|
|
11
|
+
{ id: 2, name: 'Pop Out', code: `.scaleX(1.2f).scaleY(1.2f).alpha(0f)` }, //Okay super
|
|
12
|
+
{ id: 3, name: 'Super Zoom', code: `.scaleX(1.5f).scaleY(1.5f).alpha(1f)` }, //Okay super
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
{ id: 4, name: 'Flip and Fade', code: `.scaleX(0f).scaleY(0f).rotation(180f).alpha(0f)` }, //Okay
|
|
16
|
+
{ id: 5, name: 'Wipe Away', code: `.translationX(splashScreenView.getWidth()).alpha(0f)` }, //Okay
|
|
17
|
+
{ id: 6, name: 'Bounce in Spiral', code: `.scaleX(0.5f).scaleY(0.5f).alpha(0.5f).rotation(360f)` }, //Okay
|
|
18
|
+
{ id: 7, name: 'Fade and Slide', code: `.alpha(0f).translationY(splashScreenView.getHeight())` }, //Okay
|
|
19
|
+
{ id: 8, name: 'Zoom Out with Bounce', code: `.scaleX(0f).scaleY(0f).alpha(0f).translationY(splashScreenView.getHeight())` }, //Okay
|
|
20
|
+
{ id: 9, name: 'Twist', code: `.rotation(720f).alpha(0f)` }, //Okay
|
|
21
|
+
{ id: 10, name: 'Rotate Back', code: `.rotation(-360f).alpha(1f)` }, //Okay
|
|
22
|
+
{ id: 11, name: 'Stretch In', code: `.scaleX(1.5f).scaleY(1.5f).alpha(1f)` }, //Okay
|
|
23
|
+
{ id: 12, name: 'Fade and Scale', code: `.alpha(0f).scaleX(0f).scaleY(0f)` }, //Okay
|
|
24
|
+
{ id: 13, name: 'Slide Left and Fade', code: `.translationX(-splashScreenView.getWidth()).alpha(0f)` }, //Okay
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
{ id: 14, name: 'Fade Out', code: `.alpha(0f)` },
|
|
28
|
+
{ id: 15, name: 'Slide Down', code: `.translationY(splashScreenView.getHeight())` },
|
|
29
|
+
{ id: 16, name: 'Zoom Out', code: `.scaleX(0f).scaleY(0f).alpha(0f)` },
|
|
30
|
+
{ id: 17, name: 'Rotate Out', code: `.rotation(360f).alpha(0f)` },
|
|
31
|
+
{ id: 18, name: 'Slide Up', code: `.translationY(-splashScreenView.getHeight()).alpha(0f)` },
|
|
32
|
+
{ id: 19, name: 'Bounce Effect', code: `.translationY(splashScreenView.getHeight())` },
|
|
33
|
+
{ id: 20, name: 'Flip Out', code: `.scaleX(0f).alpha(0f)` },
|
|
34
|
+
{ id: 21, name: 'Diagonal Slide and Fade Out', code: `.translationX(splashScreenView.getWidth()).translationY(splashScreenView.getHeight()).alpha(0f)` },
|
|
35
|
+
{ id: 22, name: 'Scale Down with Bounce', code: `.scaleX(0f).scaleY(0f)` },
|
|
36
|
+
{ id: 23, name: 'Slide Left', code: `.translationX(-splashScreenView.getWidth()).alpha(0f)` },
|
|
37
|
+
{ id: 24, name: 'Slide Right', code: `.translationX(splashScreenView.getWidth()).alpha(0f)` },
|
|
38
|
+
{ id: 25, name: 'Scale Up', code: `.scaleX(1f).scaleY(1f).alpha(1f)` },
|
|
39
|
+
{ id: 26, name: 'Rotate In', code: `.rotation(180f).alpha(1f)` },
|
|
40
|
+
{ id: 27, name: 'Bounce Up', code: `.translationY(-100f).setInterpolator(new BounceInterpolator())` },
|
|
41
|
+
{ id: 28, name: 'Flip Horizontal', code: `.scaleX(-1f).alpha(1f)` },
|
|
42
|
+
{ id: 29, name: 'Zoom In', code: `.scaleX(1f).scaleY(1f).alpha(1f)` },
|
|
43
|
+
{ id: 30, name: 'Wobble', code: `.translationX(10f).translationX(-10f).translationX(10f)` },
|
|
44
|
+
{ id: 31, name: 'Vertical Shake', code: `.translationY(10f).translationY(-10f).translationY(10f)` },
|
|
45
|
+
{ id: 32, name: 'Bounce Down', code: `.translationY(100f).setInterpolator(new BounceInterpolator())` },
|
|
46
|
+
{ id: 33, name: 'Swing', code: `.rotation(15f).translationX(-10f).rotation(-15f).translationX(10f)` },
|
|
47
|
+
{ id: 34, name: 'Elastic Bounce', code: `.translationX(30f).translationX(-30f).translationX(15f).translationX(-15f)` },
|
|
48
|
+
{ id: 35, name: 'Pulse', code: `.scaleX(1.1f).scaleY(1.1f).alpha(1f).setRepeatMode(ValueAnimator.REVERSE).setRepeatCount(ValueAnimator.INFINITE)` },
|
|
49
|
+
{ id: 36, name: 'Skew', code: `.setRotationX(30f).setRotationY(30f).alpha(0.5f)` },
|
|
50
|
+
{ id: 37, name: 'Vibrate', code: `.translationX(5f).translationX(-5f).translationX(5f).translationX(-5f)` },
|
|
51
|
+
{ id: 38, name: 'Speed Out', code: `.alpha(0f).setDuration(300)` },
|
|
52
|
+
{ id: 39, name: 'Wave', code: `.translationX(20f).translationX(-20f).translationX(20f).translationX(-20f)` },
|
|
53
|
+
{ id: 40, name: 'Swing Bounce', code: `.rotation(15f).translationX(10f).translationX(-10f)` },
|
|
54
|
+
];
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
// Function to find the package name from capacitor.config.json
|
|
58
|
+
function findPackageName() {
|
|
59
|
+
const configPath = path.join('capacitor.config.json');
|
|
60
|
+
if (!fs.existsSync(configPath)) {
|
|
61
|
+
console.error('capacitor.config.json not found. Ensure this is a valid Capacitor project.');
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const configContent = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
66
|
+
return configContent.appId;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Function to construct the MainActivity.java path
|
|
70
|
+
function constructMainActivityPath(packageName) {
|
|
71
|
+
const packagePath = packageName.replace(/\./g, '/'); // Convert package name to path
|
|
72
|
+
const mainActivityPath = path.join('android', 'app', 'src', 'main', 'java', packagePath, 'MainActivity.java');
|
|
73
|
+
|
|
74
|
+
console.log('MainActivity path:', mainActivityPath); // Output for debugging
|
|
75
|
+
return mainActivityPath;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Find package name and MainActivity.java path
|
|
79
|
+
const packageName = findPackageName();
|
|
80
|
+
if (!packageName) {
|
|
81
|
+
console.error('Failed to extract the package name from capacitor.config.json.');
|
|
82
|
+
process.exit(1);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const mainActivityPath = constructMainActivityPath(packageName);
|
|
86
|
+
|
|
87
|
+
// Display animation options
|
|
88
|
+
/* const rl = readline.createInterface({
|
|
89
|
+
input: process.stdin,
|
|
90
|
+
output: process.stdout,
|
|
91
|
+
}); */
|
|
92
|
+
|
|
93
|
+
console.log('Select an animation type for the splash screen:');
|
|
94
|
+
animations.forEach((animation) => {
|
|
95
|
+
//console.log(`${animation.id}. ${animation.name}`);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// Prompt user for animation selection
|
|
99
|
+
//rl.question('Enter the number of the animation type: ', (answer) => {
|
|
100
|
+
|
|
101
|
+
const answer=1;
|
|
102
|
+
|
|
103
|
+
const selectedAnimation = animations.find((anim) => anim.id === parseInt(answer, 10));
|
|
104
|
+
|
|
105
|
+
if (!selectedAnimation) {
|
|
106
|
+
console.log('Invalid selection. Please run the script again.');
|
|
107
|
+
//rl.close();
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
console.log(`Selected: ${selectedAnimation.name}`);
|
|
112
|
+
|
|
113
|
+
// Read the MainActivity.java file
|
|
114
|
+
fs.readFile(mainActivityPath, 'utf8', (err, data) => {
|
|
115
|
+
if (err) {
|
|
116
|
+
console.error(`Error reading MainActivity.java: ${err.message}`);
|
|
117
|
+
//rl.close();
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// New logic for removing existing code and adding new splash screen animation code
|
|
122
|
+
const newMainActivityCode =
|
|
123
|
+
`package ${findPackageName()};
|
|
124
|
+
|
|
125
125
|
import android.os.Build;
|
|
126
126
|
import android.os.Bundle;
|
|
127
127
|
import android.view.View;
|
|
@@ -190,37 +190,37 @@ import androidx.core.view.WindowInsetsCompat;
|
|
|
190
190
|
});
|
|
191
191
|
ViewCompat.requestApplyInsets(decorView);
|
|
192
192
|
}
|
|
193
|
-
|
|
194
|
-
// Handle custom splash screen exit animation
|
|
195
|
-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
|
196
|
-
getSplashScreen().setOnExitAnimationListener(splashScreenView -> {
|
|
197
|
-
// Add your custom animation here (e.g., fade out)
|
|
198
|
-
splashScreenView.setAlpha(1f);
|
|
199
|
-
splashScreenView.animate()
|
|
200
|
-
${selectedAnimation.code} // Apply selected animation
|
|
201
|
-
.setDuration(1000) // Animation duration (1000ms)
|
|
202
|
-
.withEndAction(splashScreenView::remove) // Remove splash screen
|
|
203
|
-
.start();
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
}
|
|
193
|
+
|
|
194
|
+
// Handle custom splash screen exit animation
|
|
195
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
|
196
|
+
getSplashScreen().setOnExitAnimationListener(splashScreenView -> {
|
|
197
|
+
// Add your custom animation here (e.g., fade out)
|
|
198
|
+
splashScreenView.setAlpha(1f);
|
|
199
|
+
splashScreenView.animate()
|
|
200
|
+
${selectedAnimation.code} // Apply selected animation
|
|
201
|
+
.setDuration(1000) // Animation duration (1000ms)
|
|
202
|
+
.withEndAction(splashScreenView::remove) // Remove splash screen
|
|
203
|
+
.start();
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
207
|
}
|
|
208
208
|
`;
|
|
209
|
-
|
|
210
|
-
// Write the new MainActivity.java content
|
|
211
|
-
writeMainActivity(newMainActivityCode);
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
//rl.close();
|
|
215
|
-
//});
|
|
216
|
-
|
|
217
|
-
// Write updated data to MainActivity.java
|
|
218
|
-
function writeMainActivity(updatedData) {
|
|
219
|
-
fs.writeFile(mainActivityPath, updatedData, 'utf8', (err) => {
|
|
220
|
-
if (err) {
|
|
221
|
-
console.error(`Error writing to MainActivity.java: ${err.message}`);
|
|
222
|
-
return;
|
|
223
|
-
}
|
|
224
|
-
console.log('MainActivity.java updated successfully!');
|
|
225
|
-
});
|
|
226
|
-
}
|
|
209
|
+
|
|
210
|
+
// Write the new MainActivity.java content
|
|
211
|
+
writeMainActivity(newMainActivityCode);
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
//rl.close();
|
|
215
|
+
//});
|
|
216
|
+
|
|
217
|
+
// Write updated data to MainActivity.java
|
|
218
|
+
function writeMainActivity(updatedData) {
|
|
219
|
+
fs.writeFile(mainActivityPath, updatedData, 'utf8', (err) => {
|
|
220
|
+
if (err) {
|
|
221
|
+
console.error(`Error writing to MainActivity.java: ${err.message}`);
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
console.log('MainActivity.java updated successfully!');
|
|
225
|
+
});
|
|
226
|
+
}
|
|
@@ -148,8 +148,8 @@ function syncPackageDependencies(projectRoot, packageName) {
|
|
|
148
148
|
const original = fs.readFileSync(controller, 'utf8');
|
|
149
149
|
let next = original.replace(/(['"])\.\.?\/admob-ad-configuration-nextgen\.json\1/g,
|
|
150
150
|
(match, quote) => `${quote}../admob-ad-configuration-nextgen.json${quote}`);
|
|
151
|
-
if (iapFolders.length) next = next.replace(/(['"])\.\.?\/IAP-\d+(?:\.\d+)*\/firebase-analytics\.js\1/g,
|
|
152
|
-
(match, quote) => `${quote}../${iapFolders[0]}
|
|
151
|
+
if (iapFolders.length) next = next.replace(/(['"])\.\.?\/IAP-\d+(?:\.\d+)*\/(?:firebase-analytics|IAP-state)\.js\1/g,
|
|
152
|
+
(match, quote) => `${quote}../${iapFolders[0]}/${match.includes('IAP-state') ? 'IAP-state.js' : 'firebase-analytics.js'}${quote}`);
|
|
153
153
|
if (next !== original) fs.writeFileSync(controller, next, 'utf8');
|
|
154
154
|
}
|
|
155
155
|
|
|
@@ -167,9 +167,9 @@ async function syncAdmobNextgen(options = {}) {
|
|
|
167
167
|
}
|
|
168
168
|
// New manifests use admob-nextgen. Accept the previous key only at folder versions >= 4.0.
|
|
169
169
|
const advertisedVersion = String(versions?.['admob-nextgen'] || versions?.['admob-emi-nextgen'] || '');
|
|
170
|
-
//
|
|
171
|
-
const remoteVersion = /^\d+(?:\.\d+)*$/.test(advertisedVersion) && compareVersions(advertisedVersion, '4.
|
|
172
|
-
? advertisedVersion : '4.
|
|
170
|
+
// IAP 4.6 requires the synchronous ownership gate in AdMob 4.1 or newer.
|
|
171
|
+
const remoteVersion = /^\d+(?:\.\d+)*$/.test(advertisedVersion) && compareVersions(advertisedVersion, '4.1') >= 0
|
|
172
|
+
? advertisedVersion : '4.1';
|
|
173
173
|
const candidates = [];
|
|
174
174
|
if (/^\d+(?:\.\d+)*$/.test(remoteVersion) && compareVersions(remoteVersion, '4.0') >= 0) {
|
|
175
175
|
candidates.push({ version: remoteVersion });
|
|
@@ -195,6 +195,7 @@ async function syncAdmobNextgen(options = {}) {
|
|
|
195
195
|
}
|
|
196
196
|
}
|
|
197
197
|
if (!latest) throw new Error('No complete AdMob folder package is available. Check admob-nextgen in the live versions.json and its ZIP on htmlcodeplay.com; existing files were preserved.');
|
|
198
|
+
if (compareVersions(latest.match(PACKAGE_PATTERN)[1], '4.1') < 0) throw new Error('Deferred IAP startup requires admob-nextgen-4.1 or newer; existing sources were preserved.');
|
|
198
199
|
syncPackageDependencies(projectRoot, latest);
|
|
199
200
|
const changed = syncImports(projectRoot, latest);
|
|
200
201
|
// Remove only this plugin's superseded files after the new imports are in place.
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
{
|
|
2
|
-
"plugins":[
|
|
3
|
-
{"name":"backbutton","pattern":"backbutton-(\\d+\\.\\d+)\\.js$","minVersion":"2.1","baseDir":"js","mandatoryUpdate":true},
|
|
1
|
+
{
|
|
2
|
+
"plugins":[
|
|
3
|
+
{"name":"backbutton","pattern":"backbutton-(\\d+\\.\\d+)\\.js$","minVersion":"2.1","baseDir":"js","mandatoryUpdate":true},
|
|
4
4
|
{"name":"common-js","pattern":"common-(\\d+\\.\\d+)(?:-beta-(\\d+))?\\.js$","minVersion":"6.7","baseDir":"js","mandatoryUpdate":true},
|
|
5
|
-
|
|
6
|
-
{"name":"admob-nextgen","pattern":"admob-nextgen-(\\d+(?:\\.\\d+)*)$","minVersion":"4.
|
|
7
|
-
{"name":"video-player","pattern":"video-player-(\\d+\\.\\d+)\\.js$","minVersion":"1.6","baseDir":"js","mandatoryUpdate":true},
|
|
8
|
-
{"name":"image-cropper","pattern":"image-cropper-(\\d+\\.\\d+)\\.js$","minVersion":"1.1","baseDir":"js","mandatoryUpdate":true},
|
|
9
|
-
{"name":"beautify","pattern":"beautify-(\\d+\\.\\d+)\\.js$","minVersion":"1.1","baseDir":"js","mandatoryUpdate":true},
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
{"name":"localization","pattern":"localization-(\\d+\\.\\d+)$","minVersion":"1.8","baseDir":"js/localization","mandatoryUpdate":true,"isFolder":true},
|
|
13
|
-
{"name": "localization_settings","pattern": "localization_settings-(\\d+\\.\\d+)\\.js$","minVersion": "1.1","required": true,"baseDir": "js/localization","mandatoryUpdate": true},
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
{"name":"editor","pattern":"editor-(\\d+\\.\\d+)$","minVersion":"2.0","baseDir":"js/editor","mandatoryUpdate":true,"isFolder":true},
|
|
17
|
-
{"name":"ffmpeg","pattern":"ffmpeg-(\\d+\\.\\d+)$","minVersion":"1.6","baseDir":"js","mandatoryUpdate":true,"isFolder":true},
|
|
18
|
-
{"name":"theme","pattern":"theme-(\\d+\\.\\d+)$","minVersion":"3.5","baseDir":"theme","destDir":"theme","mandatoryUpdate":true,"isFolder":true},
|
|
19
|
-
{"name":"certificatejs","pattern":"certificatejs-(\\d+\\.\\d+)$","minVersion":"1.9","baseDir":"certificate","destDir":"certificate","mandatoryUpdate":true,"isFolder":true},
|
|
20
|
-
{"name":"IAP","pattern":"IAP-(\\d+\\.\\d+)$","minVersion":"4.
|
|
21
|
-
{"name":"common-less","pattern":"common-(\\d+\\.\\d+)\\.less$","minVersion":"1.8","baseDir":"assets/css","mandatoryUpdate":true},
|
|
22
|
-
{"name":"localNotification_AppSettings","pattern":"localNotification_AppSettings-(\\d+\\.\\d+)\\.js$","minVersion":"1.0","baseDir":"js","mandatoryUpdate":true},
|
|
23
|
-
{"name":"localNotification","pattern":"localNotification-(\\d+\\.\\d+)\\.js$","minVersion":"2.2","baseDir":"js","mandatoryUpdate":true},
|
|
24
|
-
{"name":"onesignal","pattern":"onesignal-(\\d+\\.\\d+)\\.js$","minVersion":"2.4","baseDir":"js","mandatoryUpdate":true},
|
|
25
|
-
{"name":"saveToGalleryAndSaveAnyFile","pattern":"saveToGalleryAndSaveAnyFile-(\\d+\\.\\d+)(-ios)?\\.js$","minVersion":"3.1","baseDir":"js","mandatoryUpdate":true}
|
|
26
|
-
]
|
|
5
|
+
|
|
6
|
+
{"name":"admob-nextgen","pattern":"admob-nextgen-(\\d+(?:\\.\\d+)*)$","minVersion":"4.1","baseDir":"js/Ads","mandatoryUpdate":true,"isFolder":true},
|
|
7
|
+
{"name":"video-player","pattern":"video-player-(\\d+\\.\\d+)\\.js$","minVersion":"1.6","baseDir":"js","mandatoryUpdate":true},
|
|
8
|
+
{"name":"image-cropper","pattern":"image-cropper-(\\d+\\.\\d+)\\.js$","minVersion":"1.1","baseDir":"js","mandatoryUpdate":true},
|
|
9
|
+
{"name":"beautify","pattern":"beautify-(\\d+\\.\\d+)\\.js$","minVersion":"1.1","baseDir":"js","mandatoryUpdate":true},
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
{"name":"localization","pattern":"localization-(\\d+\\.\\d+)$","minVersion":"1.8","baseDir":"js/localization","mandatoryUpdate":true,"isFolder":true},
|
|
13
|
+
{"name": "localization_settings","pattern": "localization_settings-(\\d+\\.\\d+)\\.js$","minVersion": "1.1","required": true,"baseDir": "js/localization","mandatoryUpdate": true},
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
{"name":"editor","pattern":"editor-(\\d+\\.\\d+)$","minVersion":"2.0","baseDir":"js/editor","mandatoryUpdate":true,"isFolder":true},
|
|
17
|
+
{"name":"ffmpeg","pattern":"ffmpeg-(\\d+\\.\\d+)$","minVersion":"1.6","baseDir":"js","mandatoryUpdate":true,"isFolder":true},
|
|
18
|
+
{"name":"theme","pattern":"theme-(\\d+\\.\\d+)$","minVersion":"3.5","baseDir":"theme","destDir":"theme","mandatoryUpdate":true,"isFolder":true},
|
|
19
|
+
{"name":"certificatejs","pattern":"certificatejs-(\\d+\\.\\d+)$","minVersion":"1.9","baseDir":"certificate","destDir":"certificate","mandatoryUpdate":true,"isFolder":true},
|
|
20
|
+
{"name":"IAP","pattern":"IAP-(\\d+\\.\\d+)$","minVersion":"4.6","baseDir":"js/Ads","mandatoryUpdate":true,"isFolder":true},
|
|
21
|
+
{"name":"common-less","pattern":"common-(\\d+\\.\\d+)\\.less$","minVersion":"1.8","baseDir":"assets/css","mandatoryUpdate":true},
|
|
22
|
+
{"name":"localNotification_AppSettings","pattern":"localNotification_AppSettings-(\\d+\\.\\d+)\\.js$","minVersion":"1.0","baseDir":"js","mandatoryUpdate":true},
|
|
23
|
+
{"name":"localNotification","pattern":"localNotification-(\\d+\\.\\d+)\\.js$","minVersion":"2.2","baseDir":"js","mandatoryUpdate":true},
|
|
24
|
+
{"name":"onesignal","pattern":"onesignal-(\\d+\\.\\d+)\\.js$","minVersion":"2.4","baseDir":"js","mandatoryUpdate":true},
|
|
25
|
+
{"name":"saveToGalleryAndSaveAnyFile","pattern":"saveToGalleryAndSaveAnyFile-(\\d+\\.\\d+)(-ios)?\\.js$","minVersion":"3.1","baseDir":"js","mandatoryUpdate":true}
|
|
26
|
+
]
|
|
27
27
|
}
|