codeplay-common 4.11.41-alpha.3 → 4.11.41-alpha.4

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 CHANGED
@@ -15,6 +15,7 @@ Files changed: `package.json`, `runtime/splash-ready.mjs`, `files/buildCodeplay/
15
15
 
16
16
  ## Unreleased
17
17
 
18
+ - Apply the Capacitor 9 launch splash icon and a small XML fallback during installation, Android sync, and before-build. Preserve custom themes and reuse existing app images.
18
19
  - Add a Huawei-only first-launch Simplified Chinese privacy consent gate from shared `buildCodeplay` files. Keep Firebase Analytics off by default in Huawei native builds, restore non-Huawei entries on the next build, and provide a Settings link and withdrawal control. Each app still needs its own published Chinese policy profile before submission.
19
20
  - Add optional camera, autofocus and flash feature declarations after package-specific manifest updates. Warn about Amazon device exclusions for existing required camera features (including manual declarations); Enter or a 5-second timeout changes them to optional, while n/N preserves them. Avoid duplicate features on repeated builds and run package-ID preparation in every Android store build command.
20
21
  - Invalidate the cached source-file inventory after removing replaced plugin folders or versioned files, so post-update validation scans the installed sources instead of deleted theme paths.
package/README.md CHANGED
@@ -29,9 +29,14 @@ patch named for the installed version. Changed Java code stops the build for
29
29
  review. An older installation must first be upgraded to 1.6.0.
30
30
 
31
31
  The migration build helper no longer rewrites Capacitor's `BridgeWebViewClient.java` or
32
- `SystemBars.java`. In Capacitor 9 apps, the installer leaves the old custom splash
33
- scripts uninstalled and uses the notification icon sync helper instead. Inspect
34
- existing scripts and native files as described in the guide before building.
32
+ `SystemBars.java`. In Capacitor 9 apps, installation also updates the standard
33
+ `AppTheme.NoActionBarLaunch` theme to select the app icon explicitly and creates
34
+ a small XML launch-window fallback for older Android and Fire OS. It reuses
35
+ `resources/splash_icon.png` when present, or the existing launcher icon otherwise.
36
+ Installation, Android sync, and before-build all run the idempotent helper. Custom
37
+ launch themes and drawables are preserved and reported for app-specific review.
38
+ Rebuild the APK to receive native splash changes; installation alone cannot
39
+ change an already installed app.
35
40
 
36
41
  Version 4.11.37 adds the `/buildCodeplay` Vite alias during installation and
37
42
  before-build setup, including upgrades of existing generated wrappers. This
package/RELEASE_NOTES.md CHANGED
@@ -15,6 +15,7 @@ Files changed: `package.json`, `runtime/splash-ready.mjs`, `files/buildCodeplay/
15
15
 
16
16
  ## Unreleased
17
17
 
18
+ - Fix blank or default-icon launch splashes in Capacitor 9 apps, including older Fire OS, without adding a bitmap.
18
19
  - Improve Amazon device compatibility by making camera features optional during build preparation. If a camera feature is required, press Enter or wait 5 seconds to make it optional, or press n to keep it required. This also checks manually added declarations and preserves existing camera permissions.
19
20
  - Prevent builds from failing on deleted theme paths immediately after automatic plugin updates.
20
21
  - Repair old save-file imports automatically, including imports in Framework7 pages, and keep the Vite alias aligned with the latest installed Android or iOS helper.
@@ -4385,6 +4385,7 @@ async function main() {
4385
4385
  }
4386
4386
  if (buildPlatform === 'android' && fs.existsSync(androidPlatformPath)) {
4387
4387
  require('./sync-notification-large-icon.cjs').syncNotificationLargeIcon(process.cwd());
4388
+ require('./sync-capacitor9-launch-splash.cjs').syncCapacitor9LaunchSplash(process.cwd());
4388
4389
  }
4389
4390
  require('./setup-ruads.cjs').syncRuAdsSetup(process.cwd());
4390
4391
  validateThemeFolderLocation();
@@ -9,7 +9,8 @@ const tasks = {
9
9
  'apk': 'node buildCodeplay/apk-store-builder.js',
10
10
  'final-release': 'node finalrelease',
11
11
  };
12
- const syncAfter = `${tasks.splash} && ${tasks.manifest} && node scripts-common/setup-baseline-profile.js`;
12
+ const launchSplash = 'node buildCodeplay/sync-capacitor9-launch-splash.cjs';
13
+ const syncAfter = `${tasks.splash} && ${launchSplash} && ${tasks.manifest} && node scripts-common/setup-baseline-profile.js`;
13
14
  function updateBuildScripts(scripts) {
14
15
  const next = { ...scripts };
15
16
  for (const key of Object.keys(next)) {
@@ -32,6 +33,10 @@ function updateBuildScripts(scripts) {
32
33
  next['build:ios'] = next['build:ios'] || 'cross-env CODEPLAY_BUILD_PLATFORM=ios VITE_STORE_ID=6 npm run build';
33
34
  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 ');
34
35
  next['capacitor:sync:after'] = next['capacitor:sync:after'] || syncAfter;
36
+ if (!next['capacitor:sync:after'].includes(launchSplash) &&
37
+ !next['capacitor:sync:after'].includes('run-codeplay-sync-after.js')) {
38
+ next['capacitor:sync:after'] += ` && ${launchSplash}`;
39
+ }
35
40
  const safDependency = 'node buildCodeplay/saf-mediastore-dependency.cjs';
36
41
  const cap9Prepare = 'node node_modules/codeplay-common/scripts/prepare-capacitor-9.cjs --apply-if-cap9';
37
42
  for (const hook of ['capacitor:sync:before', 'capacitor:update:before']) {
@@ -0,0 +1,59 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+
4
+ function syncCapacitor9LaunchSplash(projectRoot) {
5
+ const packageFile = path.join(projectRoot, 'package.json');
6
+ if (!fs.existsSync(packageFile)) return 'no-package';
7
+ const pkg = JSON.parse(fs.readFileSync(packageFile, 'utf8'));
8
+ const version = pkg.dependencies?.['@capacitor/core'] || pkg.devDependencies?.['@capacitor/core'] || '';
9
+ if (Number(version.match(/\d+/)?.[0]) !== 9) return 'not-capacitor-9';
10
+
11
+ const res = path.join(projectRoot, 'android', 'app', 'src', 'main', 'res');
12
+ const stylesFile = path.join(res, 'values', 'styles.xml');
13
+ if (!fs.existsSync(stylesFile)) return 'no-android-theme';
14
+ const source = fs.readFileSync(stylesFile, 'utf8');
15
+ const style = /<style\s+name="AppTheme\.NoActionBarLaunch"\s+parent="Theme\.SplashScreen"\s*>([\s\S]*?)<\/style>/;
16
+ const match = source.match(style);
17
+ if (!match || !source.includes('name="AppTheme.NoActionBar"')) return 'custom-theme';
18
+
19
+ const iconSource = path.join(projectRoot, 'resources', 'splash_icon.png');
20
+ const iconTarget = path.join(res, 'drawable-nodpi', 'splash_icon.png');
21
+ const icon = fs.existsSync(iconSource) || fs.existsSync(iconTarget)
22
+ ? '@drawable/splash_icon' : '@mipmap/ic_launcher';
23
+ const background = path.join(res, 'drawable', 'launch_background.xml');
24
+ const expected = `<?xml version="1.0" encoding="utf-8"?>\n<layer-list xmlns:android="http://schemas.android.com/apk/res/android">\n <item android:drawable="@android:color/white" />\n <item\n android:drawable="${icon}"\n android:gravity="center"\n android:width="220dp"\n android:height="220dp" />\n</layer-list>\n`;
25
+ const body = match[1];
26
+ const original = /^\s*<item name="android:background">@drawable\/splash<\/item>\s*$/.test(body);
27
+ const managedItems = [
28
+ '<item name="android:background">@drawable/launch_background</item>',
29
+ '<item name="android:windowBackground">@drawable/launch_background</item>',
30
+ '<item name="windowSplashScreenBackground">@android:color/white</item>',
31
+ `<item name="windowSplashScreenAnimatedIcon">${icon}</item>`,
32
+ '<item name="postSplashScreenTheme">@style/AppTheme.NoActionBar</item>',
33
+ ];
34
+ const managed = managedItems.every(item => body.includes(item)) &&
35
+ !body.replace(/<item\b[^>]*>[^<]*<\/item>/g, '').trim();
36
+ if (!original && !managed) return 'custom-theme';
37
+ if (fs.existsSync(background) && fs.readFileSync(background, 'utf8') !== expected) return 'custom-background';
38
+
39
+ const replacement = `<style name="AppTheme.NoActionBarLaunch" parent="Theme.SplashScreen">\n` +
40
+ ` <item name="android:background">@drawable/launch_background</item>\n` +
41
+ ` <item name="android:windowBackground">@drawable/launch_background</item>\n` +
42
+ ` <item name="windowSplashScreenBackground">@android:color/white</item>\n` +
43
+ ` <item name="windowSplashScreenAnimatedIcon">${icon}</item>\n` +
44
+ ` <item name="postSplashScreenTheme">@style/AppTheme.NoActionBar</item>\n` +
45
+ ` </style>`;
46
+ const updated = source.replace(style, replacement);
47
+ if (updated === source && fs.existsSync(background)) return 'unchanged';
48
+ fs.mkdirSync(path.dirname(background), { recursive: true });
49
+ if (!fs.existsSync(background)) fs.writeFileSync(background, expected);
50
+ if (updated !== source) fs.writeFileSync(stylesFile, updated);
51
+ return 'updated';
52
+ }
53
+
54
+ if (require.main === module) {
55
+ const result = syncCapacitor9LaunchSplash(path.resolve(__dirname, '..'));
56
+ console.log(`Capacitor 9 launch splash: ${result}.`);
57
+ }
58
+
59
+ module.exports = { syncCapacitor9LaunchSplash };
@@ -9,6 +9,7 @@ function run(scriptPath) {
9
9
  }
10
10
 
11
11
  run(path.join(buildDir, 'sync-notification-large-icon.cjs'));
12
+ run(path.join(buildDir, 'sync-capacitor9-launch-splash.cjs'));
12
13
 
13
14
  run(path.join(buildDir, 'manifestModification.js'));
14
15
  run(path.join(__dirname, 'setup-baseline-profile.js'));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeplay-common",
3
- "version": "4.11.41-alpha.3",
3
+ "version": "4.11.41-alpha.4",
4
4
  "description": "Common build scripts and files",
5
5
  "scripts": {
6
6
  "postinstall": "node scripts/sync-files.js",
@@ -0,0 +1,47 @@
1
+ const { test } = require('node:test');
2
+ const assert = require('node:assert/strict');
3
+ const fs = require('node:fs');
4
+ const os = require('node:os');
5
+ const path = require('node:path');
6
+ const { syncCapacitor9LaunchSplash } = require('../files/buildCodeplay/sync-capacitor9-launch-splash.cjs');
7
+ const { install } = require('./sync-files.js');
8
+
9
+ function fixture(t, style, withIcon = true) {
10
+ const root = fs.mkdtempSync(path.join(os.tmpdir(), 'codeplay-splash9-'));
11
+ t.after(() => fs.rmSync(root, { recursive: true, force: true }));
12
+ const write = (name, value) => {
13
+ const file = path.join(root, name);
14
+ fs.mkdirSync(path.dirname(file), { recursive: true });
15
+ fs.writeFileSync(file, value);
16
+ return file;
17
+ };
18
+ write('package.json', JSON.stringify({ name: 'splash-fixture', dependencies: { '@capacitor/core': '9.0.0' } }));
19
+ write('capacitor.config.json', JSON.stringify({ appId: 'splash.fixture' }));
20
+ write('android/app/src/main/res/values/styles.xml', `<resources>\n<style name="AppTheme.NoActionBar" parent="Theme.AppCompat.DayNight.NoActionBar"/>\n${style}\n</resources>\n`);
21
+ if (withIcon) write('resources/splash_icon.png', 'existing app icon');
22
+ return { root, write, read: name => fs.readFileSync(path.join(root, name), 'utf8') };
23
+ }
24
+
25
+ const defaultStyle = '<style name="AppTheme.NoActionBarLaunch" parent="Theme.SplashScreen"><item name="android:background">@drawable/splash</item></style>';
26
+
27
+ test('Capacitor 9 installation reuses the app icon and is idempotent', t => {
28
+ const f = fixture(t, defaultStyle);
29
+ install({ projectRoot: f.root, copyAssets: false });
30
+ assert.match(f.read('android/app/src/main/res/values/styles.xml'), /windowSplashScreenAnimatedIcon">@drawable\/splash_icon/);
31
+ assert.match(f.read('android/app/src/main/res/drawable/launch_background.xml'), /android:width="220dp"/);
32
+ assert.ok(fs.existsSync(path.join(f.root, 'buildCodeplay/sync-capacitor9-launch-splash.cjs')));
33
+ assert.match(JSON.parse(f.read('package.json')).scripts['capacitor:sync:after'], /sync-capacitor9-launch-splash\.cjs/);
34
+ assert.equal(syncCapacitor9LaunchSplash(f.root), 'unchanged');
35
+ });
36
+
37
+ test('uses the existing launcher icon when no splash icon exists', t => {
38
+ const f = fixture(t, defaultStyle, false);
39
+ assert.equal(syncCapacitor9LaunchSplash(f.root), 'updated');
40
+ assert.match(f.read('android/app/src/main/res/drawable/launch_background.xml'), /@mipmap\/ic_launcher/);
41
+ });
42
+
43
+ test('preserves custom launch themes and drawables', t => {
44
+ const f = fixture(t, '<style name="AppTheme.NoActionBarLaunch" parent="Theme.SplashScreen"><item name="windowSplashScreenAnimatedIcon">@drawable/brand</item></style>');
45
+ assert.equal(syncCapacitor9LaunchSplash(f.root), 'custom-theme');
46
+ assert.equal(fs.existsSync(path.join(f.root, 'android/app/src/main/res/drawable/launch_background.xml')), false);
47
+ });
@@ -113,6 +113,11 @@ function install(options = {}) {
113
113
  }
114
114
  }
115
115
  if (!capacitor9) require('../files/buildCodeplay/splash-setup.cjs').syncSplashSetup(projectRoot);
116
+ if (capacitor9) {
117
+ require('../files/buildCodeplay/sync-notification-large-icon.cjs').syncNotificationLargeIcon(projectRoot);
118
+ const splash = require('../files/buildCodeplay/sync-capacitor9-launch-splash.cjs').syncCapacitor9LaunchSplash(projectRoot);
119
+ console.log(`codeplay-common: Capacitor 9 launch splash ${splash}.`);
120
+ }
116
121
  require('../files/buildCodeplay/setup-ruads.cjs').syncRuAdsSetup(projectRoot, {
117
122
  runtimeRoot: path.resolve(__dirname, '../runtime/vk-ads'),
118
123
  });