codeplay-common 4.11.29 → 4.11.32

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.
Files changed (37) hide show
  1. package/CHANGELOG.md +115 -115
  2. package/LICENSE +21 -21
  3. package/README.md +280 -280
  4. package/RELEASE_NOTES.md +110 -110
  5. package/files/buildCodeplay/add-splash-screen.js +256 -256
  6. package/files/buildCodeplay/apk-store-builder.js +97 -97
  7. package/files/buildCodeplay/codeplayBeforeBuild.js +19 -6
  8. package/files/buildCodeplay/fix-onesignal-plugin.js +96 -96
  9. package/files/buildCodeplay/fix-optimize-builld/android-r8-rules.cjs +31 -31
  10. package/files/buildCodeplay/fix-optimize-builld/ffmpeg-jni-rules.cjs +28 -28
  11. package/files/buildCodeplay/fix-optimize-builld/fix-optimize-build.gradle +9 -9
  12. package/files/buildCodeplay/fix-optimize-builld/restore-android-r8-rules.cjs +30 -30
  13. package/files/buildCodeplay/ios-emi-admob-modification.js +24 -24
  14. package/files/buildCodeplay/manifestModification.js +38 -38
  15. package/files/buildCodeplay/migrate-system-bars.cjs +9 -2
  16. package/files/buildCodeplay/packageidBaseModification.js +528 -528
  17. package/files/buildCodeplay/project-scripts.cjs +69 -69
  18. package/files/buildCodeplay/setSplashAnimation.js +228 -228
  19. package/files/buildCodeplay/splash-setup.cjs +88 -88
  20. package/files/buildCodeplay/splashxml/codeplay_splashScreen.xml +11 -11
  21. package/files/buildCodeplay/sync-admob-nextgen.js +219 -219
  22. package/files/buildCodeplay/versions.json +28 -28
  23. package/files/finalrelease +1365 -1365
  24. package/files/generate-ai-promo-video.js +23 -23
  25. package/files/ionic.config.json +6 -6
  26. package/files/scripts-common/run-codeplay-sync-after.js +21 -21
  27. package/files/scripts-common/screenshot/background-decorations.js +120 -120
  28. package/files/scripts-common/screenshot/frame-samples.js +117 -117
  29. package/files/scripts-common/setup-baseline-profile.js +291 -291
  30. package/files/take-screen-video.js +644 -644
  31. package/package.json +29 -28
  32. package/runtime/splash-ready.mjs +52 -52
  33. package/scripts/splash-setup.test.cjs +142 -142
  34. package/scripts/sync-files.js +119 -119
  35. package/scripts/system-bars-package.test.cjs +38 -0
  36. package/scripts/system-bars.test.cjs +16 -0
  37. package/scripts/uninstall.js +2 -2
@@ -1,88 +1,88 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
- const crypto = require('crypto');
4
- const runtimeImport = "import { hideSplashWhenReady } from 'codeplay-common/runtime/splash-ready.mjs';";
5
- const knownReadyHash = '451fd2e0ca63712e0f771ee0ed03ae5bd3a379f0ca1e75e971cd7acee0802a2b';
6
-
7
- function readSplashOptions(config) {
8
- const options = config.plugins?.CodeplaySplashScreen || {};
9
- const duration = options.exitAnimationDuration ?? 1000;
10
- const timeout = options.readinessTimeout ?? 8000;
11
- const imageSelector = options.readyImageSelector ?? '[data-splash-ready], .t-film-art img';
12
- if (!Number.isInteger(duration) || duration < 0 || duration > 10000) throw new Error('CodeplaySplashScreen.exitAnimationDuration must be an integer from0 to10000.');
13
- if (!Number.isInteger(timeout) || timeout < 1 || timeout > 60000) throw new Error('CodeplaySplashScreen.readinessTimeout must be an integer from1 to60000.');
14
- if (typeof imageSelector !== 'string') throw new Error('CodeplaySplashScreen.readyImageSelector must be a string.');
15
- if (options.migrateLegacyReadiness !== undefined && typeof options.migrateLegacyReadiness !== 'boolean') throw new Error('CodeplaySplashScreen.migrateLegacyReadiness must be boolean.');
16
- return { duration, timeout, imageSelector, migrateLegacy: options.migrateLegacyReadiness === true };
17
- }
18
-
19
- function migrateSplashTheme(content) {
20
- // Repair only the known package default; preserve custom themes and styling.
21
- return content.replace(/(<item\s+name=["']postSplashScreenTheme["']\s*>\s*)@style\/Theme\.AppCompat\.NoActionBar(\s*<\/item>)/g,
22
- '$1@style/Theme.AppCompat.DayNight.NoActionBar$2');
23
- }
24
-
25
- function migrateReadinessSource(source, options) {
26
- if (!/\b(?:var|let|const)\s+capacitorApp\s*=/.test(source)) return { source, status: 'unsupported' };
27
- const handler = / handleSplashscreen:\s*function\s*\(\)\s*\{([\s\S]*?)\r?\n \},/;
28
- const match = source.match(handler);
29
- if (!match) return { source, status: 'unsupported' };
30
- const body = match[1].replace(/\s+/g, '');
31
- const isReady = crypto.createHash('sha256').update(body).digest('hex') === knownReadyHash;
32
- const isManaged = /^if\(!window\.Capacitor\)return;returnhideSplashWhenReady\(\{f7:capacitorApp\.f7,hide:\(\)=>SplashScreen\.hide\(\),imageSelector:"(?:\\.|[^"\\])*",timeout:\d+\}\);$/.test(body)
33
- && source.includes(runtimeImport);
34
- const isLegacy = body === "if(!window.Capacitor)return;setTimeout(()=>{if(window.Capacitor.Plugins?.SplashScreen)window.Capacitor.Plugins.SplashScreen.hide();},2000);"
35
- || body === "if(!window.Capacitor)return;setTimeout(()=>{if(window.Capacitor.Plugins&&window.Capacitor.Plugins.SplashScreen){window.Capacitor.Plugins.SplashScreen.hide();}},2000);";
36
- if (!isReady && !isManaged && !(isLegacy && options.migrateLegacy)) return { source, status: isLegacy ? 'opt-in-required' : 'custom-preserved' };
37
- const newline = source.includes('\r\n') ? '\r\n' : '\n';
38
- const method = [
39
- ' handleSplashscreen: function () {',
40
- ' if (!window.Capacitor) return;',
41
- ' return hideSplashWhenReady({',
42
- ' f7: capacitorApp.f7,',
43
- ' hide: () => SplashScreen.hide(),',
44
- ` imageSelector: ${JSON.stringify(options.imageSelector)},`,
45
- ` timeout: ${options.timeout}`, ' });', ' },'
46
- ].join(newline);
47
- let updated = source.replace(handler, () => method);
48
- if (!updated.includes(runtimeImport)) updated = runtimeImport + newline + updated;
49
- if (!/import\s*\{[^}]*\bSplashScreen\b[^}]*\}\s*from\s*['"]@capacitor\/splash-screen['"]/.test(updated)) {
50
- updated = "import { SplashScreen } from '@capacitor/splash-screen';" + newline + updated;
51
- }
52
- return { source: updated, status: 'managed' };
53
- }
54
-
55
- function syncSplashSetup(projectRoot, { log = console.log } = {}) {
56
- const configPath = path.join(projectRoot, 'capacitor.config.json');
57
- if (!fs.existsSync(configPath)) return;
58
- const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
59
- const options = readSplashOptions(config);
60
- const theme = path.join(projectRoot, 'buildCodeplay/splashxml/codeplay_splashScreen.xml');
61
- if (fs.existsSync(theme)) {
62
- const content = fs.readFileSync(theme, 'utf8');
63
- const updated = migrateSplashTheme(content);
64
- if (updated !== content) { fs.writeFileSync(theme, updated); log('codeplay-common: repaired legacy splash DayNight theme template; Android sync applies it.'); }
65
- }
66
- const app = path.join(projectRoot, 'src/js/capacitor-app.js');
67
- if (!fs.existsSync(app)) return;
68
- const source = fs.readFileSync(app, 'utf8');
69
- const migrated = migrateReadinessSource(source, options);
70
- if (migrated.status === 'managed') {
71
- if (source !== migrated.source) {
72
- const launch = config.plugins?.SplashScreen;
73
- if (launch?.launchAutoHide !== true || !(launch.launchShowDuration >= options.timeout)) {
74
- log('codeplay-common: readiness migration skipped; set SplashScreen.launchAutoHide=true and launchShowDuration>=readinessTimeout for the native fallback.');
75
- return;
76
- }
77
- const dependency = JSON.parse(fs.readFileSync(path.join(projectRoot, 'package.json'), 'utf8'));
78
- if (!dependency.dependencies?.['@capacitor/splash-screen'] && !dependency.devDependencies?.['@capacitor/splash-screen']) {
79
- log('codeplay-common: readiness migration skipped; @capacitor/splash-screen must be installed.');
80
- return;
81
- }
82
- fs.writeFileSync(app, migrated.source);
83
- log('codeplay-common: connected supported startup handler to shared splash readiness.');
84
- }
85
- } else log(`codeplay-common: splash readiness ${migrated.status}; app startup preserved. See shared splash setup in README.`);
86
- }
87
-
88
- module.exports = { readSplashOptions, migrateSplashTheme, migrateReadinessSource, syncSplashSetup };
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const crypto = require('crypto');
4
+ const runtimeImport = "import { hideSplashWhenReady } from 'codeplay-common/runtime/splash-ready.mjs';";
5
+ const knownReadyHash = '451fd2e0ca63712e0f771ee0ed03ae5bd3a379f0ca1e75e971cd7acee0802a2b';
6
+
7
+ function readSplashOptions(config) {
8
+ const options = config.plugins?.CodeplaySplashScreen || {};
9
+ const duration = options.exitAnimationDuration ?? 1000;
10
+ const timeout = options.readinessTimeout ?? 8000;
11
+ const imageSelector = options.readyImageSelector ?? '[data-splash-ready], .t-film-art img';
12
+ if (!Number.isInteger(duration) || duration < 0 || duration > 10000) throw new Error('CodeplaySplashScreen.exitAnimationDuration must be an integer from0 to10000.');
13
+ if (!Number.isInteger(timeout) || timeout < 1 || timeout > 60000) throw new Error('CodeplaySplashScreen.readinessTimeout must be an integer from1 to60000.');
14
+ if (typeof imageSelector !== 'string') throw new Error('CodeplaySplashScreen.readyImageSelector must be a string.');
15
+ if (options.migrateLegacyReadiness !== undefined && typeof options.migrateLegacyReadiness !== 'boolean') throw new Error('CodeplaySplashScreen.migrateLegacyReadiness must be boolean.');
16
+ return { duration, timeout, imageSelector, migrateLegacy: options.migrateLegacyReadiness === true };
17
+ }
18
+
19
+ function migrateSplashTheme(content) {
20
+ // Repair only the known package default; preserve custom themes and styling.
21
+ return content.replace(/(<item\s+name=["']postSplashScreenTheme["']\s*>\s*)@style\/Theme\.AppCompat\.NoActionBar(\s*<\/item>)/g,
22
+ '$1@style/Theme.AppCompat.DayNight.NoActionBar$2');
23
+ }
24
+
25
+ function migrateReadinessSource(source, options) {
26
+ if (!/\b(?:var|let|const)\s+capacitorApp\s*=/.test(source)) return { source, status: 'unsupported' };
27
+ const handler = / handleSplashscreen:\s*function\s*\(\)\s*\{([\s\S]*?)\r?\n \},/;
28
+ const match = source.match(handler);
29
+ if (!match) return { source, status: 'unsupported' };
30
+ const body = match[1].replace(/\s+/g, '');
31
+ const isReady = crypto.createHash('sha256').update(body).digest('hex') === knownReadyHash;
32
+ const isManaged = /^if\(!window\.Capacitor\)return;returnhideSplashWhenReady\(\{f7:capacitorApp\.f7,hide:\(\)=>SplashScreen\.hide\(\),imageSelector:"(?:\\.|[^"\\])*",timeout:\d+\}\);$/.test(body)
33
+ && source.includes(runtimeImport);
34
+ const isLegacy = body === "if(!window.Capacitor)return;setTimeout(()=>{if(window.Capacitor.Plugins?.SplashScreen)window.Capacitor.Plugins.SplashScreen.hide();},2000);"
35
+ || body === "if(!window.Capacitor)return;setTimeout(()=>{if(window.Capacitor.Plugins&&window.Capacitor.Plugins.SplashScreen){window.Capacitor.Plugins.SplashScreen.hide();}},2000);";
36
+ if (!isReady && !isManaged && !(isLegacy && options.migrateLegacy)) return { source, status: isLegacy ? 'opt-in-required' : 'custom-preserved' };
37
+ const newline = source.includes('\r\n') ? '\r\n' : '\n';
38
+ const method = [
39
+ ' handleSplashscreen: function () {',
40
+ ' if (!window.Capacitor) return;',
41
+ ' return hideSplashWhenReady({',
42
+ ' f7: capacitorApp.f7,',
43
+ ' hide: () => SplashScreen.hide(),',
44
+ ` imageSelector: ${JSON.stringify(options.imageSelector)},`,
45
+ ` timeout: ${options.timeout}`, ' });', ' },'
46
+ ].join(newline);
47
+ let updated = source.replace(handler, () => method);
48
+ if (!updated.includes(runtimeImport)) updated = runtimeImport + newline + updated;
49
+ if (!/import\s*\{[^}]*\bSplashScreen\b[^}]*\}\s*from\s*['"]@capacitor\/splash-screen['"]/.test(updated)) {
50
+ updated = "import { SplashScreen } from '@capacitor/splash-screen';" + newline + updated;
51
+ }
52
+ return { source: updated, status: 'managed' };
53
+ }
54
+
55
+ function syncSplashSetup(projectRoot, { log = console.log } = {}) {
56
+ const configPath = path.join(projectRoot, 'capacitor.config.json');
57
+ if (!fs.existsSync(configPath)) return;
58
+ const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
59
+ const options = readSplashOptions(config);
60
+ const theme = path.join(projectRoot, 'buildCodeplay/splashxml/codeplay_splashScreen.xml');
61
+ if (fs.existsSync(theme)) {
62
+ const content = fs.readFileSync(theme, 'utf8');
63
+ const updated = migrateSplashTheme(content);
64
+ if (updated !== content) { fs.writeFileSync(theme, updated); log('codeplay-common: repaired legacy splash DayNight theme template; Android sync applies it.'); }
65
+ }
66
+ const app = path.join(projectRoot, 'src/js/capacitor-app.js');
67
+ if (!fs.existsSync(app)) return;
68
+ const source = fs.readFileSync(app, 'utf8');
69
+ const migrated = migrateReadinessSource(source, options);
70
+ if (migrated.status === 'managed') {
71
+ if (source !== migrated.source) {
72
+ const launch = config.plugins?.SplashScreen;
73
+ if (launch?.launchAutoHide !== true || !(launch.launchShowDuration >= options.timeout)) {
74
+ log('codeplay-common: readiness migration skipped; set SplashScreen.launchAutoHide=true and launchShowDuration>=readinessTimeout for the native fallback.');
75
+ return;
76
+ }
77
+ const dependency = JSON.parse(fs.readFileSync(path.join(projectRoot, 'package.json'), 'utf8'));
78
+ if (!dependency.dependencies?.['@capacitor/splash-screen'] && !dependency.devDependencies?.['@capacitor/splash-screen']) {
79
+ log('codeplay-common: readiness migration skipped; @capacitor/splash-screen must be installed.');
80
+ return;
81
+ }
82
+ fs.writeFileSync(app, migrated.source);
83
+ log('codeplay-common: connected supported startup handler to shared splash readiness.');
84
+ }
85
+ } else log(`codeplay-common: splash readiness ${migrated.status}; app startup preserved. See shared splash setup in README.`);
86
+ }
87
+
88
+ module.exports = { readSplashOptions, migrateSplashTheme, migrateReadinessSource, syncSplashSetup };
@@ -1,11 +1,11 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <resources>
3
- <color name="splashscreen_background">#FFFFFF</color>
4
-
5
- <style name="Theme.Codeplay.SplashScreen" parent="Theme.SplashScreen.IconBackground">
6
- <item name="windowSplashScreenBackground">@color/splashscreen_background</item>
7
- <item name="windowSplashScreenAnimatedIcon">@drawable/splash_icon</item>
8
- <item name="windowSplashScreenAnimationDuration">10000</item>
9
- <item name="postSplashScreenTheme">@style/Theme.AppCompat.DayNight.NoActionBar</item>
10
- </style>
11
- </resources>
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <resources>
3
+ <color name="splashscreen_background">#FFFFFF</color>
4
+
5
+ <style name="Theme.Codeplay.SplashScreen" parent="Theme.SplashScreen.IconBackground">
6
+ <item name="windowSplashScreenBackground">@color/splashscreen_background</item>
7
+ <item name="windowSplashScreenAnimatedIcon">@drawable/splash_icon</item>
8
+ <item name="windowSplashScreenAnimationDuration">10000</item>
9
+ <item name="postSplashScreenTheme">@style/Theme.AppCompat.DayNight.NoActionBar</item>
10
+ </style>
11
+ </resources>