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,120 +1,120 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
- const { updateBuildScripts, removeVersionedBuildScripts } = require('../files/buildCodeplay/project-scripts.cjs');
4
- const { syncAndroidR8Rules } = require('../files/buildCodeplay/fix-optimize-builld/restore-android-r8-rules.cjs');
5
-
6
- function migrateAppScripts(projectRoot) {
7
- const root = path.resolve(projectRoot);
8
- const source = path.resolve(root, 'scripts');
9
- const destination = path.resolve(root, 'scripts-common');
10
- if (path.dirname(source) !== root || path.dirname(destination) !== root) throw new Error('Invalid app scripts path.');
11
- if (!fs.existsSync(source)) return;
12
- // Preflight the entire tree before moving anything. Never overwrite a
13
- // different existing file or follow a linked directory.
14
- function check(from, to) {
15
- if (fs.lstatSync(from).isSymbolicLink() || (fs.existsSync(to) && fs.lstatSync(to).isSymbolicLink())) throw new Error('Cannot migrate linked script paths.');
16
- if (!fs.existsSync(to)) return;
17
- if (fs.statSync(from).isDirectory() && fs.statSync(to).isDirectory()) {
18
- for (const name of fs.readdirSync(from)) check(path.join(from, name), path.join(to, name));
19
- } else if (!fs.statSync(from).isFile() || !fs.statSync(to).isFile() || !fs.readFileSync(from).equals(fs.readFileSync(to))) {
20
- throw new Error(`Scripts folder conflict; both files preserved: ${to}`);
21
- }
22
- }
23
- function move(from, to) {
24
- if (!fs.existsSync(to)) { fs.renameSync(from, to); return; }
25
- if (fs.statSync(from).isDirectory()) {
26
- for (const name of fs.readdirSync(from)) move(path.join(from, name), path.join(to, name));
27
- fs.rmdirSync(from);
28
- } else fs.unlinkSync(from); // Identical existing file, verified above.
29
- }
30
- check(source, destination);
31
- move(source, destination);
32
- }
33
-
34
- function migrateAppConfigurator(projectRoot) {
35
- const filePath = path.join(projectRoot, 'scripts-common', 'configure-codeplay-common.js');
36
- if (!fs.existsSync(filePath)) return;
37
- const original = fs.readFileSync(filePath, 'utf8');
38
- let updated = original;
39
- // Preserve app-specific configuration; extend only the known legacy lookups.
40
- for (const [variable, script] of [
41
- ['buildFile', 'codeplayBeforeBuild.js'],
42
- ['packageIdFile', 'packageidBaseModification.js'],
43
- ]) {
44
- updated = updated.replace(
45
- `const ${variable} = fs.readdirSync(buildDir)`,
46
- `const ${variable} = fs.existsSync(path.join(buildDir, '${script}'))\n` +
47
- ` ? '${script}'\n` +
48
- ` : fs.readdirSync(buildDir)`
49
- );
50
- }
51
- updated = updated.replace(
52
- "packageJson.scripts['capacitor:sync:after'] = 'node scripts/run-codeplay-sync-after.js';",
53
- "packageJson.scripts['capacitor:sync:after'] = 'node scripts-common/run-codeplay-sync-after.js';"
54
- );
55
- if (updated !== original) fs.writeFileSync(filePath, updated, 'utf8');
56
- }
57
-
58
- function findProjectRoot() {
59
- // npm may execute a file: dependency's lifecycle in its source directory.
60
- // INIT_CWD identifies the app that invoked npm in that case.
61
- for (const candidate of [process.env.INIT_CWD, path.join(__dirname, '../../..')]) {
62
- if (!candidate) continue;
63
- const root = path.resolve(candidate);
64
- const file = path.join(root, 'package.json');
65
- if (!fs.existsSync(file)) continue;
66
- if (JSON.parse(fs.readFileSync(file, 'utf8')).name !== 'codeplay-common' && fs.existsSync(path.join(root, 'capacitor.config.json'))) return root;
67
- }
68
- return null;
69
- }
70
-
71
- function install(options = {}) {
72
- const resolved = options.projectRoot || findProjectRoot();
73
- if (!resolved) {
74
- console.log('codeplay-common: no consuming Capacitor app found; skipping source-package setup.');
75
- return null;
76
- }
77
- const projectRoot = path.resolve(resolved);
78
- const commonFiles = path.resolve(__dirname, '../files');
79
- const packagePath = path.join(projectRoot, 'package.json');
80
- if (!fs.existsSync(packagePath)) throw new Error('Consuming application package.json was not found.');
81
- const pkg = JSON.parse(fs.readFileSync(packagePath, 'utf8'));
82
- const scripts = updateBuildScripts(pkg.scripts || {});
83
- migrateAppScripts(projectRoot);
84
- // Copy the common templates into each application for local testing.
85
- const buildSource = path.join(commonFiles, 'buildCodeplay');
86
- const buildTarget = path.join(projectRoot, 'buildCodeplay');
87
- fs.mkdirSync(buildTarget, { recursive: true });
88
- for (const name of fs.readdirSync(buildSource)) {
89
- const target = path.join(buildTarget, name);
90
- if ((name === 'release-sync.config.json' || name === 'splashxml') && fs.existsSync(target)) continue;
91
- fs.cpSync(path.join(buildSource, name), target, { recursive: true });
92
- }
93
- fs.copyFileSync(path.join(commonFiles, 'finalrelease'), path.join(projectRoot, 'finalrelease'));
94
- if (options.copyAssets !== false) {
95
- for (const name of fs.readdirSync(commonFiles)) {
96
- if (name === 'buildCodeplay' || name === 'scripts-screenshot') continue;
97
- fs.cpSync(path.join(commonFiles, name), path.join(projectRoot, name), { recursive: true });
98
- }
99
- }
100
- require('../files/buildCodeplay/splash-setup.cjs').syncSplashSetup(projectRoot);
101
- require('../files/buildCodeplay/setup-ruads.cjs').syncRuAdsSetup(projectRoot, {
102
- runtimeRoot: path.resolve(__dirname, '../runtime/vk-ads'),
103
- });
104
- require('../files/buildCodeplay/iap-alias.cjs').syncIapAliases(projectRoot);
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const { updateBuildScripts, removeVersionedBuildScripts } = require('../files/buildCodeplay/project-scripts.cjs');
4
+ const { syncAndroidR8Rules } = require('../files/buildCodeplay/fix-optimize-builld/restore-android-r8-rules.cjs');
5
+
6
+ function migrateAppScripts(projectRoot) {
7
+ const root = path.resolve(projectRoot);
8
+ const source = path.resolve(root, 'scripts');
9
+ const destination = path.resolve(root, 'scripts-common');
10
+ if (path.dirname(source) !== root || path.dirname(destination) !== root) throw new Error('Invalid app scripts path.');
11
+ if (!fs.existsSync(source)) return;
12
+ // Preflight the entire tree before moving anything. Never overwrite a
13
+ // different existing file or follow a linked directory.
14
+ function check(from, to) {
15
+ if (fs.lstatSync(from).isSymbolicLink() || (fs.existsSync(to) && fs.lstatSync(to).isSymbolicLink())) throw new Error('Cannot migrate linked script paths.');
16
+ if (!fs.existsSync(to)) return;
17
+ if (fs.statSync(from).isDirectory() && fs.statSync(to).isDirectory()) {
18
+ for (const name of fs.readdirSync(from)) check(path.join(from, name), path.join(to, name));
19
+ } else if (!fs.statSync(from).isFile() || !fs.statSync(to).isFile() || !fs.readFileSync(from).equals(fs.readFileSync(to))) {
20
+ throw new Error(`Scripts folder conflict; both files preserved: ${to}`);
21
+ }
22
+ }
23
+ function move(from, to) {
24
+ if (!fs.existsSync(to)) { fs.renameSync(from, to); return; }
25
+ if (fs.statSync(from).isDirectory()) {
26
+ for (const name of fs.readdirSync(from)) move(path.join(from, name), path.join(to, name));
27
+ fs.rmdirSync(from);
28
+ } else fs.unlinkSync(from); // Identical existing file, verified above.
29
+ }
30
+ check(source, destination);
31
+ move(source, destination);
32
+ }
33
+
34
+ function migrateAppConfigurator(projectRoot) {
35
+ const filePath = path.join(projectRoot, 'scripts-common', 'configure-codeplay-common.js');
36
+ if (!fs.existsSync(filePath)) return;
37
+ const original = fs.readFileSync(filePath, 'utf8');
38
+ let updated = original;
39
+ // Preserve app-specific configuration; extend only the known legacy lookups.
40
+ for (const [variable, script] of [
41
+ ['buildFile', 'codeplayBeforeBuild.js'],
42
+ ['packageIdFile', 'packageidBaseModification.js'],
43
+ ]) {
44
+ updated = updated.replace(
45
+ `const ${variable} = fs.readdirSync(buildDir)`,
46
+ `const ${variable} = fs.existsSync(path.join(buildDir, '${script}'))\n` +
47
+ ` ? '${script}'\n` +
48
+ ` : fs.readdirSync(buildDir)`
49
+ );
50
+ }
51
+ updated = updated.replace(
52
+ "packageJson.scripts['capacitor:sync:after'] = 'node scripts/run-codeplay-sync-after.js';",
53
+ "packageJson.scripts['capacitor:sync:after'] = 'node scripts-common/run-codeplay-sync-after.js';"
54
+ );
55
+ if (updated !== original) fs.writeFileSync(filePath, updated, 'utf8');
56
+ }
57
+
58
+ function findProjectRoot() {
59
+ // npm may execute a file: dependency's lifecycle in its source directory.
60
+ // INIT_CWD identifies the app that invoked npm in that case.
61
+ for (const candidate of [process.env.INIT_CWD, path.join(__dirname, '../../..')]) {
62
+ if (!candidate) continue;
63
+ const root = path.resolve(candidate);
64
+ const file = path.join(root, 'package.json');
65
+ if (!fs.existsSync(file)) continue;
66
+ if (JSON.parse(fs.readFileSync(file, 'utf8')).name !== 'codeplay-common' && fs.existsSync(path.join(root, 'capacitor.config.json'))) return root;
67
+ }
68
+ return null;
69
+ }
70
+
71
+ function install(options = {}) {
72
+ const resolved = options.projectRoot || findProjectRoot();
73
+ if (!resolved) {
74
+ console.log('codeplay-common: no consuming Capacitor app found; skipping source-package setup.');
75
+ return null;
76
+ }
77
+ const projectRoot = path.resolve(resolved);
78
+ const commonFiles = path.resolve(__dirname, '../files');
79
+ const packagePath = path.join(projectRoot, 'package.json');
80
+ if (!fs.existsSync(packagePath)) throw new Error('Consuming application package.json was not found.');
81
+ const pkg = JSON.parse(fs.readFileSync(packagePath, 'utf8'));
82
+ const scripts = updateBuildScripts(pkg.scripts || {});
83
+ migrateAppScripts(projectRoot);
84
+ // Copy the common templates into each application for local testing.
85
+ const buildSource = path.join(commonFiles, 'buildCodeplay');
86
+ const buildTarget = path.join(projectRoot, 'buildCodeplay');
87
+ fs.mkdirSync(buildTarget, { recursive: true });
88
+ for (const name of fs.readdirSync(buildSource)) {
89
+ const target = path.join(buildTarget, name);
90
+ if ((name === 'release-sync.config.json' || name === 'splashxml') && fs.existsSync(target)) continue;
91
+ fs.cpSync(path.join(buildSource, name), target, { recursive: true });
92
+ }
93
+ fs.copyFileSync(path.join(commonFiles, 'finalrelease'), path.join(projectRoot, 'finalrelease'));
94
+ if (options.copyAssets !== false) {
95
+ for (const name of fs.readdirSync(commonFiles)) {
96
+ if (name === 'buildCodeplay' || name === 'scripts-screenshot') continue;
97
+ fs.cpSync(path.join(commonFiles, name), path.join(projectRoot, name), { recursive: true });
98
+ }
99
+ }
100
+ require('../files/buildCodeplay/splash-setup.cjs').syncSplashSetup(projectRoot);
101
+ require('../files/buildCodeplay/setup-ruads.cjs').syncRuAdsSetup(projectRoot, {
102
+ runtimeRoot: path.resolve(__dirname, '../runtime/vk-ads'),
103
+ });
104
+ require('../files/buildCodeplay/iap-alias.cjs').syncIapAliases(projectRoot);
105
105
  migrateAppConfigurator(projectRoot);
106
- require('../files/buildCodeplay/migrate-system-bars.cjs').migrateSystemBars(projectRoot);
107
- syncAndroidR8Rules(projectRoot, { installGradleHook: true });
108
- pkg.scripts = scripts;
109
- require('../files/buildCodeplay/saf-mediastore-dependency.cjs').syncSafMediastoreDependency(projectRoot);
110
- fs.writeFileSync(packagePath, JSON.stringify(pkg, null, 2) + '\n');
111
- // Cleanup happens only after replacement assets and package commands exist.
112
- removeVersionedBuildScripts(projectRoot);
113
- console.log('codeplay-common: unversioned build scripts copied to app buildCodeplay; app-owned settings preserved.');
114
- // Coupled IAP/AdMob/Home migrations run together during before-build.
115
- return pkg;
116
- }
117
- module.exports = { install, findProjectRoot, migrateAppScripts, migrateAppConfigurator };
118
- if (require.main === module) {
119
- try { install(); } catch (error) { console.error(error.message); process.exitCode = 1; }
120
- }
106
+ require('../files/buildCodeplay/migrate-system-bars.cjs').migrateSystemBars(projectRoot);
107
+ syncAndroidR8Rules(projectRoot, { installGradleHook: true });
108
+ pkg.scripts = scripts;
109
+ require('../files/buildCodeplay/saf-mediastore-dependency.cjs').syncSafMediastoreDependency(projectRoot);
110
+ fs.writeFileSync(packagePath, JSON.stringify(pkg, null, 2) + '\n');
111
+ // Cleanup happens only after replacement assets and package commands exist.
112
+ removeVersionedBuildScripts(projectRoot);
113
+ console.log('codeplay-common: unversioned build scripts copied to app buildCodeplay; app-owned settings preserved.');
114
+ // Coupled IAP/AdMob/Home migrations run together during before-build.
115
+ return pkg;
116
+ }
117
+ module.exports = { install, findProjectRoot, migrateAppScripts, migrateAppConfigurator };
118
+ if (require.main === module) {
119
+ try { install(); } catch (error) { console.error(error.message); process.exitCode = 1; }
120
+ }
@@ -0,0 +1,38 @@
1
+ const { test } = require('node:test');
2
+ const assert = require('node:assert/strict');
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const vm = require('vm');
6
+
7
+ const source = fs.readFileSync(path.join(__dirname, '../files/buildCodeplay/codeplayBeforeBuild.js'), 'utf8');
8
+ const start = source.indexOf('const syncCodeplaySystemBarsPackage =');
9
+ const code = source.slice(start, source.indexOf('\n};', start) + 3);
10
+
11
+ function run({ installed = '1.0.1', latest = '1.0.2', declared = '^1.0.1', offline = false, fail = false } = {}) {
12
+ const commands = [];
13
+ let queries = 0;
14
+ const context = {
15
+ fs: { existsSync: () => true, readFileSync: () => JSON.stringify({ dependencies: { 'capacitor-codeplay-system-bars': declared } }) },
16
+ packageJsonPath: 'package.json',
17
+ CODEPLAY_SYSTEM_BARS_PLUGIN: 'capacitor-codeplay-system-bars',
18
+ getInstalledVersion: () => installed,
19
+ getLatestVersion: () => { queries++; return latest; },
20
+ compareVersionStrings: (a, b) => a.localeCompare(b, undefined, { numeric: true }),
21
+ runNpmCommand: command => { if (fail) throw new Error('install failed'); commands.push(command); },
22
+ skipOnlineVersionChecks: offline,
23
+ console: { log() {}, warn() {} }
24
+ };
25
+ vm.runInNewContext(code + '\nsyncCodeplaySystemBarsPackage();', context);
26
+ return { commands, queries };
27
+ }
28
+
29
+ test('updates an older installed release', () => {
30
+ assert.deepEqual(run(), { commands: ['npm install capacitor-codeplay-system-bars@latest'], queries: 1 });
31
+ });
32
+ test('keeps the latest installed release', () => assert.deepEqual(run({ installed: '1.0.2' }).commands, []));
33
+ test('does not downgrade a newer installed release', () => assert.deepEqual(run({ installed: '1.0.3' }).commands, []));
34
+ test('installs a missing package', () => assert.equal(run({ installed: null }).commands.length, 1));
35
+ test('replaces a local plugin reference', () => assert.equal(run({ declared: 'file:../plugin' }).commands.length, 1));
36
+ test('offline builds skip the registry check', () => assert.deepEqual(run({ offline: true }), { commands: [], queries: 0 }));
37
+ test('registry failure preserves the installed package', () => assert.deepEqual(run({ latest: null }).commands, []));
38
+ test('installation failure stops the build', () => assert.throws(() => run({ fail: true }), /install failed/));
@@ -18,6 +18,22 @@ function fixture() {
18
18
  }
19
19
  const modern = 'import {SystemBars,SystemBarType} from "@capacitor/core"; SystemBars.setStyle({style:"DARK",bar:SystemBarType.StatusBar});';
20
20
 
21
+ test('copied helper resolves the package-owned parser in a nested npm layout', async () => {
22
+ const { root, write } = fixture();
23
+ write('src/app.js', modern + '\n/* StatusBar.hide(); */');
24
+ write('node_modules/codeplay-common/package.json', JSON.stringify({ name: 'codeplay-common' }));
25
+ const parserPath = require.resolve('terser');
26
+ write('node_modules/codeplay-common/node_modules/terser/index.js',
27
+ `module.exports = require(${JSON.stringify(parserPath)});`);
28
+ const copiedHelper = path.join(root, 'buildCodeplay/migrate-system-bars.cjs');
29
+ write('buildCodeplay/migrate-system-bars.cjs',
30
+ fs.readFileSync(path.join(__dirname, '../files/buildCodeplay/migrate-system-bars.cjs'), 'utf8'));
31
+ const { auditLegacyStatusBar: auditCopiedHelper } = require(copiedHelper);
32
+ assert.equal((await auditCopiedHelper(root)).status, 'unused');
33
+ write('src/app.js', modern + ' StatusBar.hide();');
34
+ assert.equal((await auditCopiedHelper(root)).status, 'retained');
35
+ });
36
+
21
37
  test('legacy dependency is removed only after confirming modern usage; native references are refreshed', async () => {
22
38
  const { root, write } = fixture();
23
39
  write('src/app.js', modern + '\n/* StatusBar.hide(); */');
@@ -1,3 +1,3 @@
1
- // Preserve working app files during preinstall. Postinstall migrates commands
2
- // first, then removes only recognized copied build scripts.
1
+ // Preserve working app files during preinstall. Postinstall migrates commands
2
+ // first, then removes only recognized copied build scripts.
3
3
  console.log('codeplay-common: preserving app files until installation completes.');