codeplay-common 4.11.37 → 4.11.38
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/README.md +28 -0
- package/RELEASE_NOTES.md +13 -13
- package/files/buildCodeplay/add-splash-screen.js +1 -1
- package/files/buildCodeplay/ensure-current-build.cjs +42 -42
- package/files/buildCodeplay/fix-optimize-builld/android-r8-rules.cjs +31 -31
- package/files/buildCodeplay/fix-optimize-builld/ffmpeg-jni-rules.cjs +28 -28
- package/files/buildCodeplay/fix-optimize-builld/fix-optimize-build.gradle +9 -9
- package/files/buildCodeplay/fix-optimize-builld/restore-android-r8-rules.cjs +30 -30
- package/files/buildCodeplay/huawei-privacy-entry.js +135 -135
- package/files/buildCodeplay/huawei-privacy.css +22 -22
- package/files/buildCodeplay/ios-ad-consent.cjs +56 -56
- package/files/buildCodeplay/ios-emi-admob-modification.js +25 -25
- package/files/buildCodeplay/newly added.txt +89 -89
- package/files/buildCodeplay/non-google-billing.pro +3 -3
- package/files/buildCodeplay/release-sync.config.json +4 -4
- package/files/buildCodeplay/remove-force-kotlin-disable.js +43 -43
- package/files/buildCodeplay/ruads.cjs +220 -220
- package/files/buildCodeplay/saf-mediastore-dependency.cjs +21 -21
- package/files/buildCodeplay/setSplashAnimation.js +2 -2
- package/files/buildCodeplay/setup-ruads.cjs +62 -62
- package/files/buildCodeplay/splash-setup.cjs +88 -88
- package/files/buildCodeplay/store-billing.cjs +43 -43
- package/files/buildCodeplay/tests/huawei-live-reload.test.cjs +60 -60
- package/files/buildCodeplay/tests/huawei-privacy.test.cjs +49 -49
- package/files/scripts-common/collect-startup-profile.js +134 -0
- package/files/scripts-common/generate-baseline-profile.js +194 -22
- package/files/take-screen-image.js +4414 -4414
- package/package.json +1 -1
- package/runtime/splash-ready.mjs +52 -52
- package/runtime/vk-ads/vk-ad-configuration.json +39 -39
- package/scripts/baseline-profile.test.cjs +189 -0
- package/scripts/ensure-current-build.test.cjs +76 -76
- package/scripts/ios-ad-consent.test.cjs +99 -99
- package/scripts/ruads-install.test.cjs +197 -197
- package/scripts/ruads-policy.test.cjs +174 -174
- package/scripts/saf-mediastore-dependency.test.cjs +44 -44
- package/scripts/splash-setup.test.cjs +142 -142
- package/scripts/sync-files.js +1 -1
- package/scripts/vite-build-settings.test.cjs +93 -93
package/README.md
CHANGED
|
@@ -11,6 +11,34 @@ sync/update hooks add its missing AndroidX DocumentFile dependency to plugin met
|
|
|
11
11
|
Existing dependency versions are preserved. After upgrading from an affected version,
|
|
12
12
|
run `npx cap sync android` once to regenerate the native dependencies.
|
|
13
13
|
|
|
14
|
+
## Baseline Profile generation
|
|
15
|
+
|
|
16
|
+
Package installation updates `scripts-common/generate-baseline-profile.js` and
|
|
17
|
+
`scripts-common/collect-startup-profile.js` in consuming apps. Generate each app's
|
|
18
|
+
own profiles with `npm run baseline-profile:generate` after its existing Baseline
|
|
19
|
+
Profile setup and production web-asset preparation.
|
|
20
|
+
|
|
21
|
+
The generator temporarily disables the copied Android live-reload URL, profiles
|
|
22
|
+
bundled web assets, and restores the original configuration afterward. It selects
|
|
23
|
+
one online ADB device (`ANDROID_SERIAL` can select it explicitly), reports elapsed
|
|
24
|
+
time, and uses a 20-minute timeout. Set `BASELINE_PROFILE_TIMEOUT_MINUTES` to change
|
|
25
|
+
that limit. A recovery backup is kept under `agent-temp/baseline-profile/` while the
|
|
26
|
+
configuration is temporarily changed.
|
|
27
|
+
|
|
28
|
+
If the device freezes the instrumentation runner, collection switches to Android's
|
|
29
|
+
host-driven ADB workflow, which requires Android 14 or later. To use it directly:
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
npm run baseline-profile:generate -- --host
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Host collection builds and installs the app's `nonMinifiedRelease` profiling APK,
|
|
36
|
+
requires three matching startup captures within 15 iterations, and saves
|
|
37
|
+
`baselineProfiles/baseline-prof.txt` and `baselineProfiles/startup-prof.txt`. Existing
|
|
38
|
+
setup helpers synchronize these into Android's generated profile directory.
|
|
39
|
+
Temporary captures stay under `agent-temp/`. Installation does not generate profiles
|
|
40
|
+
or copy one app's profile into another app; run generation separately in each app.
|
|
41
|
+
|
|
14
42
|
## VK / RuStore builds (4.11.23)
|
|
15
43
|
|
|
16
44
|
Before-build 7.8 preserves the original Vite build settings when adding tree-shaking
|
package/RELEASE_NOTES.md
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
# Release notes
|
|
2
|
-
|
|
3
|
-
## 4.11.13 — 2026-11-04
|
|
4
|
-
|
|
5
|
-
Version name:4.11.13. Version code/build number:not applicable to this npm package.
|
|
6
|
-
|
|
7
|
-
Files changed: `package.json`, `runtime/splash-ready.mjs`, `files/buildCodeplay/splash-setup.cjs`, `files/buildCodeplay/setSplashAnimation.js`, `files/buildCodeplay/add-splash-screen.js`, `files/buildCodeplay/splashxml/codeplay_splashScreen.xml`, `files/buildCodeplay/codeplayBeforeBuild.js`, `scripts/sync-files.js`, `scripts/splash-setup.test.cjs`, `README.md`, `CHANGELOG.md`, `RELEASE_NOTES.md`.
|
|
8
|
-
|
|
9
|
-
- Use a DayNight post-splash theme and migrate only the known legacy default in existing app templates; preserve custom themes.
|
|
10
|
-
- Configure native exit animation duration,including0ms,without editing generated MainActivity;default remains1000ms.
|
|
11
|
-
- Share the existing Framework7 page/image readiness flow with timeout,error handling and listener cleanup.
|
|
12
|
-
- Migrate the known existing readiness handler;offer explicit opt-in for supported legacy timer handlers,with native fallback/plugin checks. Preserve unsupported custom startup code.
|
|
13
|
-
- Run splash preparation during installation,before-build and splash setup;rebuild consuming apps to apply native changes.
|
|
14
|
-
|
|
2
|
+
|
|
3
|
+
## 4.11.13 — 2026-11-04
|
|
4
|
+
|
|
5
|
+
Version name:4.11.13. Version code/build number:not applicable to this npm package.
|
|
6
|
+
|
|
7
|
+
Files changed: `package.json`, `runtime/splash-ready.mjs`, `files/buildCodeplay/splash-setup.cjs`, `files/buildCodeplay/setSplashAnimation.js`, `files/buildCodeplay/add-splash-screen.js`, `files/buildCodeplay/splashxml/codeplay_splashScreen.xml`, `files/buildCodeplay/codeplayBeforeBuild.js`, `scripts/sync-files.js`, `scripts/splash-setup.test.cjs`, `README.md`, `CHANGELOG.md`, `RELEASE_NOTES.md`.
|
|
8
|
+
|
|
9
|
+
- Use a DayNight post-splash theme and migrate only the known legacy default in existing app templates; preserve custom themes.
|
|
10
|
+
- Configure native exit animation duration,including0ms,without editing generated MainActivity;default remains1000ms.
|
|
11
|
+
- Share the existing Framework7 page/image readiness flow with timeout,error handling and listener cleanup.
|
|
12
|
+
- Migrate the known existing readiness handler;offer explicit opt-in for supported legacy timer handlers,with native fallback/plugin checks. Preserve unsupported custom startup code.
|
|
13
|
+
- Run splash preparation during installation,before-build and splash setup;rebuild consuming apps to apply native changes.
|
|
14
|
+
|
|
15
15
|
|
|
16
16
|
## Unreleased
|
|
17
17
|
|
|
@@ -23,7 +23,7 @@ const destinationSplashIcon = path.join(
|
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
const appSplashXML = path.join(projectFolder, "buildCodeplay", "splashxml", "codeplay_splashScreen.xml");
|
|
26
|
-
require('./splash-setup.cjs').syncSplashSetup(projectFolder);
|
|
26
|
+
require('./splash-setup.cjs').syncSplashSetup(projectFolder);
|
|
27
27
|
const sourceSplashXML = fs.existsSync(appSplashXML) ? appSplashXML : path.join(__dirname, "splashxml", "codeplay_splashScreen.xml");
|
|
28
28
|
const destinationSplashXML = path.join(
|
|
29
29
|
projectFolder,
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const { execSync, execFileSync } = require('child_process');
|
|
4
|
-
|
|
5
|
-
function findVersionedBuildFiles(projectRoot) {
|
|
6
|
-
const directory = path.join(projectRoot, 'buildCodeplay');
|
|
7
|
-
if (!fs.existsSync(directory)) return [];
|
|
8
|
-
return fs.readdirSync(directory, { withFileTypes: true })
|
|
9
|
-
.filter(entry => entry.isFile() && /-\d+(?:\.\d+)*(?:-beta-\d+)?\.[^.]+$/i.test(entry.name))
|
|
10
|
-
.map(entry => entry.name);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function ensureCurrentBuild(options = {}) {
|
|
14
|
-
const projectRoot = path.resolve(options.projectRoot || process.cwd());
|
|
15
|
-
const legacyFiles = findVersionedBuildFiles(projectRoot);
|
|
16
|
-
if (!legacyFiles.length) return false;
|
|
17
|
-
|
|
18
|
-
console.log(`Legacy buildCodeplay files found: ${legacyFiles.join(', ')}. Reinstalling codeplay-common before continuing.`);
|
|
19
|
-
const runNpm = options.runNpm || (command => execSync(command, { cwd: projectRoot, stdio: 'inherit' }));
|
|
20
|
-
runNpm('npm uninstall codeplay-common');
|
|
21
|
-
runNpm('npm install codeplay-common');
|
|
22
|
-
|
|
23
|
-
// Postinstall replaces the scripts and removes recognized legacy files.
|
|
24
|
-
// Do not run stale code or retry indefinitely if migration did not finish.
|
|
25
|
-
const remaining = findVersionedBuildFiles(projectRoot);
|
|
26
|
-
if (remaining.length) {
|
|
27
|
-
throw new Error(`Legacy buildCodeplay files remain after reinstall: ${remaining.join(', ')}. Build stopped; migrate these files before retrying.`);
|
|
28
|
-
}
|
|
29
|
-
const entrypoint = path.join(projectRoot, 'buildCodeplay', 'codeplayBeforeBuild.js');
|
|
30
|
-
if (!fs.existsSync(entrypoint)) throw new Error('codeplayBeforeBuild.js is missing after reinstall. Build stopped.');
|
|
31
|
-
|
|
32
|
-
// The current process loaded the old templates. Finish preparation in a fresh
|
|
33
|
-
// process before the caller's remaining build commands are allowed to run.
|
|
34
|
-
const runBeforeBuild = options.runBeforeBuild || (script => execFileSync(process.execPath, [script, ...process.argv.slice(2)], {
|
|
35
|
-
cwd: projectRoot,
|
|
36
|
-
stdio: 'inherit',
|
|
37
|
-
}));
|
|
38
|
-
runBeforeBuild(entrypoint);
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
module.exports = { ensureCurrentBuild, findVersionedBuildFiles };
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const { execSync, execFileSync } = require('child_process');
|
|
4
|
+
|
|
5
|
+
function findVersionedBuildFiles(projectRoot) {
|
|
6
|
+
const directory = path.join(projectRoot, 'buildCodeplay');
|
|
7
|
+
if (!fs.existsSync(directory)) return [];
|
|
8
|
+
return fs.readdirSync(directory, { withFileTypes: true })
|
|
9
|
+
.filter(entry => entry.isFile() && /-\d+(?:\.\d+)*(?:-beta-\d+)?\.[^.]+$/i.test(entry.name))
|
|
10
|
+
.map(entry => entry.name);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function ensureCurrentBuild(options = {}) {
|
|
14
|
+
const projectRoot = path.resolve(options.projectRoot || process.cwd());
|
|
15
|
+
const legacyFiles = findVersionedBuildFiles(projectRoot);
|
|
16
|
+
if (!legacyFiles.length) return false;
|
|
17
|
+
|
|
18
|
+
console.log(`Legacy buildCodeplay files found: ${legacyFiles.join(', ')}. Reinstalling codeplay-common before continuing.`);
|
|
19
|
+
const runNpm = options.runNpm || (command => execSync(command, { cwd: projectRoot, stdio: 'inherit' }));
|
|
20
|
+
runNpm('npm uninstall codeplay-common');
|
|
21
|
+
runNpm('npm install codeplay-common');
|
|
22
|
+
|
|
23
|
+
// Postinstall replaces the scripts and removes recognized legacy files.
|
|
24
|
+
// Do not run stale code or retry indefinitely if migration did not finish.
|
|
25
|
+
const remaining = findVersionedBuildFiles(projectRoot);
|
|
26
|
+
if (remaining.length) {
|
|
27
|
+
throw new Error(`Legacy buildCodeplay files remain after reinstall: ${remaining.join(', ')}. Build stopped; migrate these files before retrying.`);
|
|
28
|
+
}
|
|
29
|
+
const entrypoint = path.join(projectRoot, 'buildCodeplay', 'codeplayBeforeBuild.js');
|
|
30
|
+
if (!fs.existsSync(entrypoint)) throw new Error('codeplayBeforeBuild.js is missing after reinstall. Build stopped.');
|
|
31
|
+
|
|
32
|
+
// The current process loaded the old templates. Finish preparation in a fresh
|
|
33
|
+
// process before the caller's remaining build commands are allowed to run.
|
|
34
|
+
const runBeforeBuild = options.runBeforeBuild || (script => execFileSync(process.execPath, [script, ...process.argv.slice(2)], {
|
|
35
|
+
cwd: projectRoot,
|
|
36
|
+
stdio: 'inherit',
|
|
37
|
+
}));
|
|
38
|
+
runBeforeBuild(entrypoint);
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
module.exports = { ensureCurrentBuild, findVersionedBuildFiles };
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
|
|
4
|
-
function syncCapacitorPermissionRules(projectRoot = path.resolve(__dirname, '../..')) {
|
|
5
|
-
const appPath = path.join(projectRoot, 'android', 'app');
|
|
6
|
-
if (!fs.existsSync(path.join(appPath, 'build.gradle'))) return false;
|
|
7
|
-
|
|
8
|
-
const rulesPath = path.join(appPath, 'proguard-rules.pro');
|
|
9
|
-
const original = fs.existsSync(rulesPath) ? fs.readFileSync(rulesPath, 'utf8') : '';
|
|
10
|
-
const rules = [
|
|
11
|
-
'-keepattributes RuntimeVisibleAnnotations,AnnotationDefault',
|
|
12
|
-
'-keep @interface com.getcapacitor.annotation.CapacitorPlugin { *; }',
|
|
13
|
-
'-keep @interface com.getcapacitor.annotation.Permission { *; }',
|
|
14
|
-
];
|
|
15
|
-
const existing = new Set(original.split(/\r?\n/).map(line => line.trim()));
|
|
16
|
-
const missing = rules.filter(rule => !existing.has(rule));
|
|
17
|
-
if (!missing.length) return false;
|
|
18
|
-
|
|
19
|
-
const newline = original.includes('\r\n') ? '\r\n' : '\n';
|
|
20
|
-
fs.writeFileSync(rulesPath, `${original.trimEnd()}${newline}${newline}`
|
|
21
|
-
+ `# Preserve Capacitor permission metadata used at runtime.${newline}`
|
|
22
|
-
+ `${missing.join(newline)}${newline}`, 'utf8');
|
|
23
|
-
return true;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (require.main === module) {
|
|
27
|
-
const changed = syncCapacitorPermissionRules();
|
|
28
|
-
console.log(changed ? 'Capacitor R8 permission rules restored.' : 'Capacitor R8 permission rules unchanged.');
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
module.exports = { syncCapacitorPermissionRules };
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
function syncCapacitorPermissionRules(projectRoot = path.resolve(__dirname, '../..')) {
|
|
5
|
+
const appPath = path.join(projectRoot, 'android', 'app');
|
|
6
|
+
if (!fs.existsSync(path.join(appPath, 'build.gradle'))) return false;
|
|
7
|
+
|
|
8
|
+
const rulesPath = path.join(appPath, 'proguard-rules.pro');
|
|
9
|
+
const original = fs.existsSync(rulesPath) ? fs.readFileSync(rulesPath, 'utf8') : '';
|
|
10
|
+
const rules = [
|
|
11
|
+
'-keepattributes RuntimeVisibleAnnotations,AnnotationDefault',
|
|
12
|
+
'-keep @interface com.getcapacitor.annotation.CapacitorPlugin { *; }',
|
|
13
|
+
'-keep @interface com.getcapacitor.annotation.Permission { *; }',
|
|
14
|
+
];
|
|
15
|
+
const existing = new Set(original.split(/\r?\n/).map(line => line.trim()));
|
|
16
|
+
const missing = rules.filter(rule => !existing.has(rule));
|
|
17
|
+
if (!missing.length) return false;
|
|
18
|
+
|
|
19
|
+
const newline = original.includes('\r\n') ? '\r\n' : '\n';
|
|
20
|
+
fs.writeFileSync(rulesPath, `${original.trimEnd()}${newline}${newline}`
|
|
21
|
+
+ `# Preserve Capacitor permission metadata used at runtime.${newline}`
|
|
22
|
+
+ `${missing.join(newline)}${newline}`, 'utf8');
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (require.main === module) {
|
|
27
|
+
const changed = syncCapacitorPermissionRules();
|
|
28
|
+
console.log(changed ? 'Capacitor R8 permission rules restored.' : 'Capacitor R8 permission rules unchanged.');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
module.exports = { syncCapacitorPermissionRules };
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
|
|
4
|
-
// FFmpegKit's JNI library looks up these Java members by name at runtime.
|
|
5
|
-
const FFMPEG_JNI_RULES = [
|
|
6
|
-
'-keep class com.antonkarpenko.ffmpegkit.** { *; }',
|
|
7
|
-
'-keep interface com.antonkarpenko.ffmpegkit.** { *; }',
|
|
8
|
-
];
|
|
9
|
-
|
|
10
|
-
function syncFfmpegJniRules(projectRoot) {
|
|
11
|
-
const pluginPath = path.join(projectRoot, 'node_modules', 'codeplay-fmpg', 'plugin.xml');
|
|
12
|
-
const appPath = path.join(projectRoot, 'android', 'app');
|
|
13
|
-
if (!fs.existsSync(pluginPath) || !fs.existsSync(appPath)) return false;
|
|
14
|
-
|
|
15
|
-
const rulesPath = path.join(appPath, 'proguard-rules.pro');
|
|
16
|
-
const original = fs.existsSync(rulesPath) ? fs.readFileSync(rulesPath, 'utf8') : '';
|
|
17
|
-
const existing = new Set(original.split(/\r?\n/).map(line => line.trim()));
|
|
18
|
-
const missing = FFMPEG_JNI_RULES.filter(rule => !existing.has(rule));
|
|
19
|
-
if (!missing.length) return false;
|
|
20
|
-
|
|
21
|
-
const newline = original.includes('\r\n') ? '\r\n' : '\n';
|
|
22
|
-
fs.writeFileSync(rulesPath, `${original.trimEnd()}${newline}${newline}`
|
|
23
|
-
+ `# Preserve FFmpegKit JNI entry points and callbacks.${newline}`
|
|
24
|
-
+ `${missing.join(newline)}${newline}`, 'utf8');
|
|
25
|
-
return true;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
module.exports = { syncFfmpegJniRules };
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
// FFmpegKit's JNI library looks up these Java members by name at runtime.
|
|
5
|
+
const FFMPEG_JNI_RULES = [
|
|
6
|
+
'-keep class com.antonkarpenko.ffmpegkit.** { *; }',
|
|
7
|
+
'-keep interface com.antonkarpenko.ffmpegkit.** { *; }',
|
|
8
|
+
];
|
|
9
|
+
|
|
10
|
+
function syncFfmpegJniRules(projectRoot) {
|
|
11
|
+
const pluginPath = path.join(projectRoot, 'node_modules', 'codeplay-fmpg', 'plugin.xml');
|
|
12
|
+
const appPath = path.join(projectRoot, 'android', 'app');
|
|
13
|
+
if (!fs.existsSync(pluginPath) || !fs.existsSync(appPath)) return false;
|
|
14
|
+
|
|
15
|
+
const rulesPath = path.join(appPath, 'proguard-rules.pro');
|
|
16
|
+
const original = fs.existsSync(rulesPath) ? fs.readFileSync(rulesPath, 'utf8') : '';
|
|
17
|
+
const existing = new Set(original.split(/\r?\n/).map(line => line.trim()));
|
|
18
|
+
const missing = FFMPEG_JNI_RULES.filter(rule => !existing.has(rule));
|
|
19
|
+
if (!missing.length) return false;
|
|
20
|
+
|
|
21
|
+
const newline = original.includes('\r\n') ? '\r\n' : '\n';
|
|
22
|
+
fs.writeFileSync(rulesPath, `${original.trimEnd()}${newline}${newline}`
|
|
23
|
+
+ `# Preserve FFmpegKit JNI entry points and callbacks.${newline}`
|
|
24
|
+
+ `${missing.join(newline)}${newline}`, 'utf8');
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
module.exports = { syncFfmpegJniRules };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
// Restore native metadata before Gradle configures an optimized Android build.
|
|
2
|
-
def codeplayAppRoot = rootProject.projectDir.parentFile
|
|
3
|
-
def codeplayRepairScript = new File(codeplayAppRoot, 'buildCodeplay/fix-optimize-builld/restore-android-r8-rules.cjs')
|
|
4
|
-
def codeplayNodeBinary = project.findProperty('codeplayNodeBinary') ?: 'node'
|
|
5
|
-
|
|
6
|
-
providers.exec {
|
|
7
|
-
workingDir codeplayAppRoot
|
|
8
|
-
commandLine codeplayNodeBinary, codeplayRepairScript.absolutePath
|
|
9
|
-
}.result.get().assertNormalExitValue()
|
|
1
|
+
// Restore native metadata before Gradle configures an optimized Android build.
|
|
2
|
+
def codeplayAppRoot = rootProject.projectDir.parentFile
|
|
3
|
+
def codeplayRepairScript = new File(codeplayAppRoot, 'buildCodeplay/fix-optimize-builld/restore-android-r8-rules.cjs')
|
|
4
|
+
def codeplayNodeBinary = project.findProperty('codeplayNodeBinary') ?: 'node'
|
|
5
|
+
|
|
6
|
+
providers.exec {
|
|
7
|
+
workingDir codeplayAppRoot
|
|
8
|
+
commandLine codeplayNodeBinary, codeplayRepairScript.absolutePath
|
|
9
|
+
}.result.get().assertNormalExitValue()
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const { syncFfmpegJniRules } = require('./ffmpeg-jni-rules.cjs');
|
|
4
|
-
const { syncCapacitorPermissionRules } = require('./android-r8-rules.cjs');
|
|
5
|
-
|
|
6
|
-
function syncAndroidR8Rules(projectRoot = path.resolve(__dirname, '../..'), { installGradleHook = false } = {}) {
|
|
7
|
-
const buildPath = path.join(projectRoot, 'android', 'app', 'build.gradle');
|
|
8
|
-
if (!fs.existsSync(buildPath)) return false;
|
|
9
|
-
const capacitorChanged = syncCapacitorPermissionRules(projectRoot);
|
|
10
|
-
const ffmpegChanged = syncFfmpegJniRules(projectRoot);
|
|
11
|
-
let hookChanged = false;
|
|
12
|
-
if (installGradleHook) {
|
|
13
|
-
const original = fs.readFileSync(buildPath, 'utf8');
|
|
14
|
-
const hook = "apply from: '../../buildCodeplay/fix-optimize-builld/fix-optimize-build.gradle'";
|
|
15
|
-
const existingHook = /^[ \t]*apply\s+from:\s*(['"])\.\.\/\.\.\/buildCodeplay\/fix-optimize-builld\/fix-optimize-build\.gradle\1[ \t]*;?[ \t]*$/m;
|
|
16
|
-
if (!existingHook.test(original)) {
|
|
17
|
-
const newline = original.includes('\r\n') ? '\r\n' : '\n';
|
|
18
|
-
fs.writeFileSync(buildPath, `${original.trimEnd()}${newline}${newline}${hook}${newline}`, 'utf8');
|
|
19
|
-
hookChanged = true;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
return capacitorChanged || ffmpegChanged || hookChanged;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (require.main === module) {
|
|
26
|
-
const changed = syncAndroidR8Rules(undefined, { installGradleHook: process.argv.includes('--install-gradle-hook') });
|
|
27
|
-
console.log(changed ? 'Android R8 keep rules restored.' : 'Android R8 keep rules unchanged; no Android app or rules already present.');
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
module.exports = { syncAndroidR8Rules };
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const { syncFfmpegJniRules } = require('./ffmpeg-jni-rules.cjs');
|
|
4
|
+
const { syncCapacitorPermissionRules } = require('./android-r8-rules.cjs');
|
|
5
|
+
|
|
6
|
+
function syncAndroidR8Rules(projectRoot = path.resolve(__dirname, '../..'), { installGradleHook = false } = {}) {
|
|
7
|
+
const buildPath = path.join(projectRoot, 'android', 'app', 'build.gradle');
|
|
8
|
+
if (!fs.existsSync(buildPath)) return false;
|
|
9
|
+
const capacitorChanged = syncCapacitorPermissionRules(projectRoot);
|
|
10
|
+
const ffmpegChanged = syncFfmpegJniRules(projectRoot);
|
|
11
|
+
let hookChanged = false;
|
|
12
|
+
if (installGradleHook) {
|
|
13
|
+
const original = fs.readFileSync(buildPath, 'utf8');
|
|
14
|
+
const hook = "apply from: '../../buildCodeplay/fix-optimize-builld/fix-optimize-build.gradle'";
|
|
15
|
+
const existingHook = /^[ \t]*apply\s+from:\s*(['"])\.\.\/\.\.\/buildCodeplay\/fix-optimize-builld\/fix-optimize-build\.gradle\1[ \t]*;?[ \t]*$/m;
|
|
16
|
+
if (!existingHook.test(original)) {
|
|
17
|
+
const newline = original.includes('\r\n') ? '\r\n' : '\n';
|
|
18
|
+
fs.writeFileSync(buildPath, `${original.trimEnd()}${newline}${newline}${hook}${newline}`, 'utf8');
|
|
19
|
+
hookChanged = true;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return capacitorChanged || ffmpegChanged || hookChanged;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (require.main === module) {
|
|
26
|
+
const changed = syncAndroidR8Rules(undefined, { installGradleHook: process.argv.includes('--install-gradle-hook') });
|
|
27
|
+
console.log(changed ? 'Android R8 keep rules restored.' : 'Android R8 keep rules unchanged; no Android app or rules already present.');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
module.exports = { syncAndroidR8Rules };
|
|
@@ -1,135 +1,135 @@
|
|
|
1
|
-
import { Capacitor, registerPlugin } from '@capacitor/core';
|
|
2
|
-
import './huawei-privacy.css';
|
|
3
|
-
|
|
4
|
-
const consentKey = 'codeplayHuaweiPrivacyConsentV1';
|
|
5
|
-
const Analytics = registerPlugin('FirebaseAnalytics');
|
|
6
|
-
const Browser = registerPlugin('Browser');
|
|
7
|
-
const NativeApp = registerPlugin('App');
|
|
8
|
-
const RuAds = registerPlugin('CodeplayRuStoreAds');
|
|
9
|
-
|
|
10
|
-
function policyUrl(appId) {
|
|
11
|
-
return `https://htmlcodeplay.com/privacy/ch/${appId}`;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
async function openPolicy(appId) {
|
|
15
|
-
const url = policyUrl(appId);
|
|
16
|
-
if (Capacitor.isNativePlatform() && Capacitor.isPluginAvailable('Browser')) {
|
|
17
|
-
await Browser.open({ url });
|
|
18
|
-
} else {
|
|
19
|
-
window.open(url, '_blank', 'noopener,noreferrer');
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
async function setAnalyticsConsent(enabled) {
|
|
24
|
-
if (!Capacitor.isNativePlatform() || !Capacitor.isPluginAvailable('FirebaseAnalytics')) return;
|
|
25
|
-
try {
|
|
26
|
-
await Analytics.setConsent({ type: 'ANALYTICS_STORAGE', status: enabled ? 'GRANTED' : 'DENIED' });
|
|
27
|
-
await Analytics.setEnabled({ enabled });
|
|
28
|
-
} catch (error) {
|
|
29
|
-
// The manifest still defaults native analytics collection to disabled.
|
|
30
|
-
if (enabled) console.warn('Huawei analytics remains disabled:', error);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function button(label, className, action) {
|
|
35
|
-
const element = document.createElement('button');
|
|
36
|
-
element.type = 'button';
|
|
37
|
-
element.className = className;
|
|
38
|
-
element.textContent = label;
|
|
39
|
-
element.addEventListener('click', action);
|
|
40
|
-
return element;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function showGate({ appId, appName, startApp }) {
|
|
44
|
-
const gate = document.createElement('section');
|
|
45
|
-
gate.className = 'codeplay-huawei-privacy-gate';
|
|
46
|
-
gate.setAttribute('role', 'dialog');
|
|
47
|
-
gate.setAttribute('aria-modal', 'true');
|
|
48
|
-
gate.setAttribute('aria-label', '隐私政策');
|
|
49
|
-
const card = document.createElement('div');
|
|
50
|
-
card.className = 'codeplay-huawei-privacy-card';
|
|
51
|
-
const title = document.createElement('h1');
|
|
52
|
-
title.textContent = '请先阅读隐私政策';
|
|
53
|
-
const message = document.createElement('p');
|
|
54
|
-
message.textContent = `${appName} 会在您同意后启动应用服务。请先阅读简体中文隐私政策,了解个人信息处理、第三方服务及您的权利。`;
|
|
55
|
-
const link = button('阅读隐私政策', 'codeplay-huawei-privacy-policy', async () => {
|
|
56
|
-
try { await openPolicy(appId); }
|
|
57
|
-
catch { status.textContent = '无法打开隐私政策。请检查网络连接后重试。'; }
|
|
58
|
-
});
|
|
59
|
-
const status = document.createElement('p');
|
|
60
|
-
status.className = 'codeplay-huawei-privacy-status';
|
|
61
|
-
status.setAttribute('role', 'status');
|
|
62
|
-
const agree = button('同意并继续', 'codeplay-huawei-privacy-agree', async () => {
|
|
63
|
-
agree.disabled = true;
|
|
64
|
-
try {
|
|
65
|
-
localStorage.setItem(consentKey, 'agreed');
|
|
66
|
-
await setAnalyticsConsent(true);
|
|
67
|
-
gate.remove();
|
|
68
|
-
await startApp();
|
|
69
|
-
installSettingsControls(appId);
|
|
70
|
-
} catch {
|
|
71
|
-
localStorage.removeItem(consentKey);
|
|
72
|
-
status.textContent = '应用暂时无法启动。请重试。';
|
|
73
|
-
agree.disabled = false;
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
const decline = button('不同意并退出', 'codeplay-huawei-privacy-decline', async () => {
|
|
77
|
-
await setAnalyticsConsent(false);
|
|
78
|
-
if (Capacitor.isNativePlatform() && Capacitor.isPluginAvailable('CodeplayRuStoreAds')) {
|
|
79
|
-
await RuAds.setEnabled({ enabled: false }).catch(() => {});
|
|
80
|
-
}
|
|
81
|
-
if (Capacitor.isNativePlatform() && Capacitor.isPluginAvailable('App')) {
|
|
82
|
-
await NativeApp.exitApp();
|
|
83
|
-
} else {
|
|
84
|
-
status.textContent = '您可以关闭此页面。再次打开时仍可选择是否同意。';
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
card.append(title, message, link, status, agree, decline);
|
|
88
|
-
gate.append(card);
|
|
89
|
-
document.body.append(gate);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
function installSettingsControls(appId) {
|
|
93
|
-
function mount() {
|
|
94
|
-
const page = document.querySelector('.page-current[data-name="settings"] .page-content');
|
|
95
|
-
if (!page || page.querySelector('.codeplay-huawei-privacy-settings')) return;
|
|
96
|
-
const container = document.createElement('div');
|
|
97
|
-
container.className = 'codeplay-huawei-privacy-settings block';
|
|
98
|
-
const policy = button('简体中文隐私政策', 'button', async () => {
|
|
99
|
-
try { await openPolicy(appId); }
|
|
100
|
-
catch { policy.textContent = '无法打开,请重试'; }
|
|
101
|
-
});
|
|
102
|
-
const withdraw = button('撤回隐私同意', 'button', async () => {
|
|
103
|
-
const confirmed = window.confirm('撤回同意后,应用会关闭。再次打开时可重新选择。确定撤回吗?');
|
|
104
|
-
if (!confirmed) return;
|
|
105
|
-
localStorage.removeItem(consentKey);
|
|
106
|
-
await setAnalyticsConsent(false);
|
|
107
|
-
if (Capacitor.isNativePlatform() && Capacitor.isPluginAvailable('CodeplayRuStoreAds')) {
|
|
108
|
-
await RuAds.setEnabled({ enabled: false }).catch(() => {});
|
|
109
|
-
}
|
|
110
|
-
if (Capacitor.isNativePlatform() && Capacitor.isPluginAvailable('App')) await NativeApp.exitApp();
|
|
111
|
-
else location.reload();
|
|
112
|
-
});
|
|
113
|
-
container.append(policy, withdraw);
|
|
114
|
-
page.append(container);
|
|
115
|
-
}
|
|
116
|
-
document.addEventListener('page:afterin', mount);
|
|
117
|
-
document.addEventListener('page:init', mount);
|
|
118
|
-
mount();
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export async function startHuaweiPrivacy(options) {
|
|
122
|
-
if (document.readyState === 'loading') {
|
|
123
|
-
await new Promise(resolve => document.addEventListener('DOMContentLoaded', resolve, { once: true }));
|
|
124
|
-
}
|
|
125
|
-
let agreed = false;
|
|
126
|
-
try { agreed = localStorage.getItem(consentKey) === 'agreed'; } catch { /* Ask again. */ }
|
|
127
|
-
if (agreed) {
|
|
128
|
-
await setAnalyticsConsent(true);
|
|
129
|
-
await options.startApp();
|
|
130
|
-
installSettingsControls(options.appId);
|
|
131
|
-
} else {
|
|
132
|
-
await setAnalyticsConsent(false);
|
|
133
|
-
showGate(options);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
1
|
+
import { Capacitor, registerPlugin } from '@capacitor/core';
|
|
2
|
+
import './huawei-privacy.css';
|
|
3
|
+
|
|
4
|
+
const consentKey = 'codeplayHuaweiPrivacyConsentV1';
|
|
5
|
+
const Analytics = registerPlugin('FirebaseAnalytics');
|
|
6
|
+
const Browser = registerPlugin('Browser');
|
|
7
|
+
const NativeApp = registerPlugin('App');
|
|
8
|
+
const RuAds = registerPlugin('CodeplayRuStoreAds');
|
|
9
|
+
|
|
10
|
+
function policyUrl(appId) {
|
|
11
|
+
return `https://htmlcodeplay.com/privacy/ch/${appId}`;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async function openPolicy(appId) {
|
|
15
|
+
const url = policyUrl(appId);
|
|
16
|
+
if (Capacitor.isNativePlatform() && Capacitor.isPluginAvailable('Browser')) {
|
|
17
|
+
await Browser.open({ url });
|
|
18
|
+
} else {
|
|
19
|
+
window.open(url, '_blank', 'noopener,noreferrer');
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async function setAnalyticsConsent(enabled) {
|
|
24
|
+
if (!Capacitor.isNativePlatform() || !Capacitor.isPluginAvailable('FirebaseAnalytics')) return;
|
|
25
|
+
try {
|
|
26
|
+
await Analytics.setConsent({ type: 'ANALYTICS_STORAGE', status: enabled ? 'GRANTED' : 'DENIED' });
|
|
27
|
+
await Analytics.setEnabled({ enabled });
|
|
28
|
+
} catch (error) {
|
|
29
|
+
// The manifest still defaults native analytics collection to disabled.
|
|
30
|
+
if (enabled) console.warn('Huawei analytics remains disabled:', error);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function button(label, className, action) {
|
|
35
|
+
const element = document.createElement('button');
|
|
36
|
+
element.type = 'button';
|
|
37
|
+
element.className = className;
|
|
38
|
+
element.textContent = label;
|
|
39
|
+
element.addEventListener('click', action);
|
|
40
|
+
return element;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function showGate({ appId, appName, startApp }) {
|
|
44
|
+
const gate = document.createElement('section');
|
|
45
|
+
gate.className = 'codeplay-huawei-privacy-gate';
|
|
46
|
+
gate.setAttribute('role', 'dialog');
|
|
47
|
+
gate.setAttribute('aria-modal', 'true');
|
|
48
|
+
gate.setAttribute('aria-label', '隐私政策');
|
|
49
|
+
const card = document.createElement('div');
|
|
50
|
+
card.className = 'codeplay-huawei-privacy-card';
|
|
51
|
+
const title = document.createElement('h1');
|
|
52
|
+
title.textContent = '请先阅读隐私政策';
|
|
53
|
+
const message = document.createElement('p');
|
|
54
|
+
message.textContent = `${appName} 会在您同意后启动应用服务。请先阅读简体中文隐私政策,了解个人信息处理、第三方服务及您的权利。`;
|
|
55
|
+
const link = button('阅读隐私政策', 'codeplay-huawei-privacy-policy', async () => {
|
|
56
|
+
try { await openPolicy(appId); }
|
|
57
|
+
catch { status.textContent = '无法打开隐私政策。请检查网络连接后重试。'; }
|
|
58
|
+
});
|
|
59
|
+
const status = document.createElement('p');
|
|
60
|
+
status.className = 'codeplay-huawei-privacy-status';
|
|
61
|
+
status.setAttribute('role', 'status');
|
|
62
|
+
const agree = button('同意并继续', 'codeplay-huawei-privacy-agree', async () => {
|
|
63
|
+
agree.disabled = true;
|
|
64
|
+
try {
|
|
65
|
+
localStorage.setItem(consentKey, 'agreed');
|
|
66
|
+
await setAnalyticsConsent(true);
|
|
67
|
+
gate.remove();
|
|
68
|
+
await startApp();
|
|
69
|
+
installSettingsControls(appId);
|
|
70
|
+
} catch {
|
|
71
|
+
localStorage.removeItem(consentKey);
|
|
72
|
+
status.textContent = '应用暂时无法启动。请重试。';
|
|
73
|
+
agree.disabled = false;
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
const decline = button('不同意并退出', 'codeplay-huawei-privacy-decline', async () => {
|
|
77
|
+
await setAnalyticsConsent(false);
|
|
78
|
+
if (Capacitor.isNativePlatform() && Capacitor.isPluginAvailable('CodeplayRuStoreAds')) {
|
|
79
|
+
await RuAds.setEnabled({ enabled: false }).catch(() => {});
|
|
80
|
+
}
|
|
81
|
+
if (Capacitor.isNativePlatform() && Capacitor.isPluginAvailable('App')) {
|
|
82
|
+
await NativeApp.exitApp();
|
|
83
|
+
} else {
|
|
84
|
+
status.textContent = '您可以关闭此页面。再次打开时仍可选择是否同意。';
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
card.append(title, message, link, status, agree, decline);
|
|
88
|
+
gate.append(card);
|
|
89
|
+
document.body.append(gate);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function installSettingsControls(appId) {
|
|
93
|
+
function mount() {
|
|
94
|
+
const page = document.querySelector('.page-current[data-name="settings"] .page-content');
|
|
95
|
+
if (!page || page.querySelector('.codeplay-huawei-privacy-settings')) return;
|
|
96
|
+
const container = document.createElement('div');
|
|
97
|
+
container.className = 'codeplay-huawei-privacy-settings block';
|
|
98
|
+
const policy = button('简体中文隐私政策', 'button', async () => {
|
|
99
|
+
try { await openPolicy(appId); }
|
|
100
|
+
catch { policy.textContent = '无法打开,请重试'; }
|
|
101
|
+
});
|
|
102
|
+
const withdraw = button('撤回隐私同意', 'button', async () => {
|
|
103
|
+
const confirmed = window.confirm('撤回同意后,应用会关闭。再次打开时可重新选择。确定撤回吗?');
|
|
104
|
+
if (!confirmed) return;
|
|
105
|
+
localStorage.removeItem(consentKey);
|
|
106
|
+
await setAnalyticsConsent(false);
|
|
107
|
+
if (Capacitor.isNativePlatform() && Capacitor.isPluginAvailable('CodeplayRuStoreAds')) {
|
|
108
|
+
await RuAds.setEnabled({ enabled: false }).catch(() => {});
|
|
109
|
+
}
|
|
110
|
+
if (Capacitor.isNativePlatform() && Capacitor.isPluginAvailable('App')) await NativeApp.exitApp();
|
|
111
|
+
else location.reload();
|
|
112
|
+
});
|
|
113
|
+
container.append(policy, withdraw);
|
|
114
|
+
page.append(container);
|
|
115
|
+
}
|
|
116
|
+
document.addEventListener('page:afterin', mount);
|
|
117
|
+
document.addEventListener('page:init', mount);
|
|
118
|
+
mount();
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export async function startHuaweiPrivacy(options) {
|
|
122
|
+
if (document.readyState === 'loading') {
|
|
123
|
+
await new Promise(resolve => document.addEventListener('DOMContentLoaded', resolve, { once: true }));
|
|
124
|
+
}
|
|
125
|
+
let agreed = false;
|
|
126
|
+
try { agreed = localStorage.getItem(consentKey) === 'agreed'; } catch { /* Ask again. */ }
|
|
127
|
+
if (agreed) {
|
|
128
|
+
await setAnalyticsConsent(true);
|
|
129
|
+
await options.startApp();
|
|
130
|
+
installSettingsControls(options.appId);
|
|
131
|
+
} else {
|
|
132
|
+
await setAnalyticsConsent(false);
|
|
133
|
+
showGate(options);
|
|
134
|
+
}
|
|
135
|
+
}
|