codeplay-common 4.11.14 → 4.11.15

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
@@ -1,17 +1,17 @@
1
1
  # Changelog
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
 
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,3 +1,4 @@
1
+ // Version 7.1: require confirmation before continuing with local versions when the server check fails.
1
2
  // Version 7.0: prepare shared splash readiness and migrate the legacy splash theme.
2
3
  // Version 6.9: preserve configured notification icons during Android resource shrinking.
3
4
  // Version 6.8: preserve Capacitor permission annotations for Love Calculator Android builds.
@@ -2245,17 +2246,28 @@ function updateImports(oldName, newName) {
2245
2246
 
2246
2247
 
2247
2248
  let _serverVersions = null;
2249
+ let _versionsFetchAttempted = false;
2250
+ let _versionsFetchError = '';
2251
+ let skipOnlineVersionChecks = false;
2248
2252
  async function fetchVersions() {
2249
2253
 
2250
- if (_serverVersions) return _serverVersions;
2254
+ if (skipOnlineVersionChecks || _versionsFetchAttempted) return _serverVersions;
2255
+ _versionsFetchAttempted = true;
2251
2256
 
2252
2257
  return new Promise((resolve) => {
2253
2258
 
2254
- https.get(
2259
+ const request = https.get(
2255
2260
  "https://htmlcodeplay.com/code-play-plugin/versions.json",
2256
2261
  { timeout: 5000 },
2257
2262
  res => {
2258
2263
 
2264
+ if (res.statusCode !== 200) {
2265
+ _versionsFetchError = `Server returned HTTP ${res.statusCode}.`;
2266
+ res.resume();
2267
+ resolve(null);
2268
+ return;
2269
+ }
2270
+
2259
2271
  let data = "";
2260
2272
 
2261
2273
  res.on("data", chunk => data += chunk);
@@ -2264,21 +2276,34 @@ async function fetchVersions() {
2264
2276
 
2265
2277
  try {
2266
2278
 
2267
- _serverVersions = JSON.parse(data);
2279
+ const versions = JSON.parse(data);
2280
+ if (!versions || typeof versions !== 'object' || Array.isArray(versions)) {
2281
+ throw new Error('Expected a JSON object in versions.json.');
2282
+ }
2283
+ _serverVersions = versions;
2268
2284
 
2269
2285
  resolve(_serverVersions);
2270
2286
 
2271
- } catch {
2272
-
2287
+ } catch (error) {
2288
+ _versionsFetchError = `Invalid versions.json: ${error.message}`;
2273
2289
  resolve(null);
2274
2290
 
2275
2291
  }
2276
2292
 
2277
2293
  });
2278
2294
 
2295
+ res.on('error', error => {
2296
+ _versionsFetchError = error.message;
2297
+ resolve(null);
2298
+ });
2279
2299
  }
2280
2300
 
2281
- ).on("error", () => resolve(null));
2301
+ );
2302
+ request.on('timeout', () => request.destroy(new Error('versions.json request timed out after 5 seconds.')));
2303
+ request.on('error', error => {
2304
+ _versionsFetchError = error.message;
2305
+ resolve(null);
2306
+ });
2282
2307
 
2283
2308
  });
2284
2309
 
@@ -2338,6 +2363,7 @@ function readInstalledAgentInstructionsVersion(projectRoot) {
2338
2363
  }
2339
2364
 
2340
2365
  async function syncAgentInstructions() {
2366
+ if (skipOnlineVersionChecks) return;
2341
2367
  const projectRoot = process.cwd();
2342
2368
  const targetAgentFile = path.join(projectRoot, AGENT_INSTRUCTIONS_FILE);
2343
2369
  const targetAgentDir = path.join(projectRoot, AGENT_INSTRUCTIONS_DIR);
@@ -2604,8 +2630,26 @@ async function loadPluginVersions() {
2604
2630
 
2605
2631
  const versions = await fetchVersions();
2606
2632
 
2607
- if (!versions || typeof versions !== "object") {
2608
- console.log("⚠️ Server unavailable or invalid versions.json. Falling back to local versions.");
2633
+ if (!versions || !/^\d+(?:\.\d+)*$/.test(String(versions[AGENT_INSTRUCTIONS_VERSION_KEY] || '').trim())) {
2634
+ const details = _versionsFetchError || 'versions.json is missing a valid agent instructions version.';
2635
+ const cancelledMessage = `Build cancelled: online version checks could not be completed. ${details}\nCheck your internet connection and https://htmlcodeplay.com/code-play-plugin/versions.json, then retry. Choose Yes at the confirmation prompt only if you want to use local versions without online checks.`;
2636
+ console.warn(`\n⚠️ Could not check versions.json. There might be an internet connection or server issue.\nDetails: ${details}\nContinuing will use only local plugin versions and agent instructions, without checking for online updates.`);
2637
+ await new Promise((resolve, reject) => {
2638
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
2639
+ rl.on('close', () => reject(new Error(cancelledMessage)));
2640
+ rl.question('\nAre you sure you want to continue with local versions only? (yes/no, default: no): ', answer => {
2641
+ const confirmed = /^(y|yes)$/i.test(answer.trim());
2642
+ if (confirmed) {
2643
+ skipOnlineVersionChecks = true;
2644
+ _serverVersions = null;
2645
+ resolve();
2646
+ } else {
2647
+ reject(new Error(cancelledMessage));
2648
+ }
2649
+ rl.close();
2650
+ });
2651
+ });
2652
+ console.log('✅ Continuing build with local versions only. Online plugin and agent-instruction version checks skipped.');
2609
2653
  return;
2610
2654
  }
2611
2655
 
@@ -4648,7 +4692,7 @@ async function main() {
4648
4692
 
4649
4693
  await loadPluginVersions(); // 🔥 NEW
4650
4694
  await syncAgentInstructions();
4651
- await checkPlugins();
4695
+ if (!skipOnlineVersionChecks) await checkPlugins();
4652
4696
  // Downloads may add a newer helper or source files containing legacy imports.
4653
4697
  await saveToGalleryAndSaveFileCheck_iOS();
4654
4698
 
@@ -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,14 +1,14 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
-
4
- const replaceEmiPluginCode=()=>
5
- {
6
- // path to your .m file
7
- const filePath = path.join(__dirname, '../ios/capacitor-cordova-ios-plugins/sourcesstatic/EmiIndoCordovaPluginAdmob/emiAdmobPlugin.m');
8
- const nextGenPackagePath = path.join(__dirname, '../node_modules/capacitor-admob-nextgen/package.json');
9
-
10
-
11
- if (fs.existsSync(filePath)) {
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+
4
+ const replaceEmiPluginCode=()=>
5
+ {
6
+ // path to your .m file
7
+ const filePath = path.join(__dirname, '../ios/capacitor-cordova-ios-plugins/sourcesstatic/EmiIndoCordovaPluginAdmob/emiAdmobPlugin.m');
8
+ const nextGenPackagePath = path.join(__dirname, '../node_modules/capacitor-admob-nextgen/package.json');
9
+
10
+
11
+ if (fs.existsSync(filePath)) {
12
12
  let fileContent = fs.readFileSync(filePath, 'utf8');
13
13
 
14
14
  // match the hideBannerAd method
@@ -33,17 +33,17 @@ const replaceEmiPluginCode=()=>
33
33
  fileContent.slice(match.index + match[0].length);
34
34
 
35
35
  fs.writeFileSync(filePath, updatedFileContent, 'utf8');
36
- console.log(
37
- '✅ Successfully ensured [self resetWebViewHeight]; is commented only inside hideBannerAd in emiAdmobPlugin.m'
38
- );
39
- } else {
40
- console.log('⚠️ hideBannerAd method not found.');
41
- }
42
- } else if (fs.existsSync(nextGenPackagePath)) {
43
- console.log('ℹ️ Skipping legacy iOS EMI AdMob patch. capacitor-admob-nextgen does not use emiAdmobPlugin.m.');
44
- } else {
45
- console.log('ℹ️ emiAdmobPlugin.m file not found, skipping modification.');
46
- }
47
- }
48
-
49
- replaceEmiPluginCode();
36
+ console.log(
37
+ '✅ Successfully ensured [self resetWebViewHeight]; is commented only inside hideBannerAd in emiAdmobPlugin.m'
38
+ );
39
+ } else {
40
+ console.log('⚠️ hideBannerAd method not found.');
41
+ }
42
+ } else if (fs.existsSync(nextGenPackagePath)) {
43
+ console.log('ℹ️ Skipping legacy iOS EMI AdMob patch. capacitor-admob-nextgen does not use emiAdmobPlugin.m.');
44
+ } else {
45
+ console.log('ℹ️ emiAdmobPlugin.m file not found, skipping modification.');
46
+ }
47
+ }
48
+
49
+ replaceEmiPluginCode();