codeplay-common 4.11.35 → 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.
Files changed (63) hide show
  1. package/CHANGELOG.md +115 -115
  2. package/LICENSE +21 -21
  3. package/README.md +408 -374
  4. package/RELEASE_NOTES.md +97 -97
  5. package/files/buildCodeplay/HUAWEI-PRIVACY.md +9 -9
  6. package/files/buildCodeplay/add-splash-screen.js +255 -255
  7. package/files/buildCodeplay/apk-store-builder.js +97 -97
  8. package/files/buildCodeplay/codeplayBeforeBuild.js +4793 -4793
  9. package/files/buildCodeplay/disabled-ads.mjs +53 -53
  10. package/files/buildCodeplay/ensure-current-build.cjs +42 -42
  11. package/files/buildCodeplay/fix-onesignal-plugin.js +96 -96
  12. package/files/buildCodeplay/huawei-privacy-entry.js +135 -135
  13. package/files/buildCodeplay/huawei-privacy.cjs +102 -92
  14. package/files/buildCodeplay/huawei-privacy.css +22 -22
  15. package/files/buildCodeplay/iap-alias.cjs +116 -116
  16. package/files/buildCodeplay/ios-ad-consent.cjs +56 -56
  17. package/files/buildCodeplay/ios-emi-admob-modification.js +49 -49
  18. package/files/buildCodeplay/manifestModification.js +38 -38
  19. package/files/buildCodeplay/migrate-system-bars.cjs +122 -122
  20. package/files/buildCodeplay/newly added.txt +89 -89
  21. package/files/buildCodeplay/non-google-billing.pro +3 -3
  22. package/files/buildCodeplay/packageidBaseModification.js +528 -528
  23. package/files/buildCodeplay/project-scripts.cjs +69 -69
  24. package/files/buildCodeplay/release-sync.config.json +4 -4
  25. package/files/buildCodeplay/remove-force-kotlin-disable.js +43 -43
  26. package/files/buildCodeplay/ruads.cjs +220 -211
  27. package/files/buildCodeplay/saf-mediastore-dependency.cjs +21 -21
  28. package/files/buildCodeplay/setSplashAnimation.js +226 -226
  29. package/files/buildCodeplay/setup-ruads.cjs +62 -55
  30. package/files/buildCodeplay/splashxml/codeplay_splashScreen.xml +11 -11
  31. package/files/buildCodeplay/store-billing.cjs +43 -43
  32. package/files/buildCodeplay/sync-admob-nextgen.js +219 -219
  33. package/files/buildCodeplay/tests/huawei-live-reload.test.cjs +60 -0
  34. package/files/buildCodeplay/tests/huawei-multiple-entries.test.cjs +80 -0
  35. package/files/buildCodeplay/tests/huawei-privacy.test.cjs +49 -49
  36. package/files/buildCodeplay/tests/huawei-vite.test.cjs +38 -35
  37. package/files/buildCodeplay/versions.json +28 -28
  38. package/files/finalrelease +1365 -1365
  39. package/files/generate-ai-promo-video.js +23 -23
  40. package/files/ionic.config.json +6 -6
  41. package/files/scripts-common/collect-startup-profile.js +134 -0
  42. package/files/scripts-common/generate-baseline-profile.js +194 -22
  43. package/files/scripts-common/run-codeplay-sync-after.js +21 -21
  44. package/files/scripts-common/screenshot/background-decorations.js +120 -120
  45. package/files/scripts-common/screenshot/frame-samples.js +117 -117
  46. package/files/scripts-common/setup-baseline-profile.js +291 -291
  47. package/files/take-screen-image.js +4414 -4414
  48. package/files/take-screen-video.js +644 -644
  49. package/package.json +29 -29
  50. package/runtime/vk-ads/vk-ad-configuration.json +39 -39
  51. package/scripts/baseline-profile.test.cjs +189 -0
  52. package/scripts/ensure-current-build.test.cjs +76 -76
  53. package/scripts/iap-alias.test.cjs +117 -117
  54. package/scripts/ios-ad-consent.test.cjs +99 -99
  55. package/scripts/ruads-install.test.cjs +197 -180
  56. package/scripts/ruads-policy.test.cjs +174 -174
  57. package/scripts/saf-mediastore-dependency.test.cjs +44 -44
  58. package/scripts/squeezeback-config.test.cjs +78 -78
  59. package/scripts/sync-files.js +120 -120
  60. package/scripts/system-bars-package.test.cjs +38 -38
  61. package/scripts/system-bars.test.cjs +93 -93
  62. package/scripts/uninstall.js +2 -2
  63. package/scripts/vite-build-settings.test.cjs +93 -92
@@ -1,92 +1,93 @@
1
- const { test } = require('node:test');
2
- const assert = require('node:assert/strict');
3
- const fs = require('node:fs');
4
- const path = require('node:path');
5
- const vm = require('node:vm');
6
- const { pathToFileURL } = require('node:url');
7
- const { install } = require('./sync-files.js');
8
-
9
- function fixture(configuration) {
10
- const base = path.resolve(process.env.CODEPLAY_TEST_ROOT || path.join(__dirname, '../agent-temp'));
11
- fs.mkdirSync(base, { recursive: true });
12
- const root = fs.mkdtempSync(path.join(base, 'vite-settings-'));
13
- fs.writeFileSync(path.join(root, 'package.json'), JSON.stringify({ name: 'vite-fixture', scripts: {}, dependencies: {} }));
14
- fs.writeFileSync(path.join(root, 'capacitor.config.json'), JSON.stringify({ appId: 'fixture.app', plugins: {
15
- AdMob: { ADMOB_ENABLED: true }, RuAds: { VK_ADS_ENABLED: true, STORE_IDS: [4, 10] },
16
- } }));
17
- fs.mkdirSync(path.join(root, 'src/js/Ads/vk-ads-1.3'), { recursive: true });
18
- fs.writeFileSync(path.join(root, 'src/js/Ads/vk-ads-1.3/vk-ads.js'), '// manually installed VK controller');
19
- fs.writeFileSync(path.join(root, 'vite.config.mjs'), configuration);
20
- install({ projectRoot: root, copyAssets: false });
21
- // Run the real before-build migration after the real installer. Loading the
22
- // full before-build CLI would also install SDKs and change native platforms.
23
- const source = fs.readFileSync(path.join(root, 'buildCodeplay/codeplayBeforeBuild.js'), 'utf8');
24
- const migration = source.slice(source.indexOf('const migrateViteTreeShaking ='), source.indexOf('// BEGIN IAP BUILD MIGRATION'));
25
- const migrate = vm.runInNewContext(migration + '\nmigrateViteTreeShaking;');
26
- return { root, file: path.join(root, 'vite.config.mjs'), migrate };
27
- }
28
-
29
- const alias = "resolve: { alias: { '@admob': '/original-admob.js' } }";
30
- const build = { outDir: '../www', minify: 'terser', sourcemap: true, emptyOutDir: false,
31
- target: 'es2022', rollupOptions: { external: ['preserved-module'], output: { entryFileNames: 'custom-[name].js' } } };
32
-
33
- test('installer and before-build preserve build settings for object/function/defineConfig exports and all ad providers', async () => {
34
- const previous = { cwd: process.cwd(), store: process.env.VITE_STORE_ID, platform: process.env.CODEPLAY_BUILD_PLATFORM };
35
- try {
36
- delete process.env.CODEPLAY_BUILD_PLATFORM;
37
- const config = `{ build: ${JSON.stringify(build)}, ${alias}, define: { custom: 'true' } }`;
38
- for (const source of [`export default ${config};`, `export default async () => (${config});`, `const defineConfig = c => c;\nexport default defineConfig(${config});`]) {
39
- const f = fixture(source);
40
- const updated = f.migrate(fs.readFileSync(f.file, 'utf8'));
41
- assert.equal(f.migrate(updated), updated);
42
- fs.writeFileSync(f.file, updated);
43
- process.chdir(f.root);
44
- const { default: configure } = await import(pathToFileURL(f.file).href);
45
- for (const store of ['1', '4', '10']) {
46
- process.env.VITE_STORE_ID = store;
47
- const resolved = await configure({ mode: 'production' });
48
- assert.deepEqual(resolved.build, { ...build, rollupOptions: { ...build.rollupOptions, treeshake: true } });
49
- assert.equal(resolved.define.custom, 'true');
50
- assert.equal(resolved.define['import.meta.env.VITE_STORE_ID'], JSON.stringify(store));
51
- assert.equal(resolved.resolve.alias['@admob'], store === '1' ? '/original-admob.js' : path.join(f.root, 'src/js/Ads/vk-ads-1.3/vk-ads.js'));
52
- }
53
- }
54
- } finally {
55
- process.chdir(previous.cwd);
56
- for (const [key, value] of [['VITE_STORE_ID', previous.store], ['CODEPLAY_BUILD_PLATFORM', previous.platform]]) {
57
- if (value === undefined) delete process.env[key]; else process.env[key] = value;
58
- }
59
- }
60
- });
61
-
62
- test('migration preserves custom treeshake options and repairs only the previous generated override', async () => {
63
- const custom = { ...build, rollupOptions: { ...build.rollupOptions, treeshake: { moduleSideEffects: false } } };
64
- const f = fixture(`export default { build: ${JSON.stringify(custom)}, ${alias} };`);
65
- let source = fs.readFileSync(f.file, 'utf8');
66
- source = source.replace('return { ...base,', 'return { ...base, build: { rollupOptions: { treeshake: true } },');
67
- const updated = f.migrate(source);
68
- assert.ok(!updated.includes('...base, build:'));
69
- assert.equal(f.migrate(updated), updated);
70
- fs.writeFileSync(f.file, updated);
71
- const previous = process.cwd();
72
- try {
73
- process.chdir(f.root);
74
- const { default: configure } = await import(pathToFileURL(f.file).href);
75
- assert.deepEqual((await configure({})).build, custom);
76
- } finally { process.chdir(previous); }
77
- const customized = source.replace('build: { rollupOptions: { treeshake: true } },', "build: { outDir: '/custom-wrapper', rollupOptions: { treeshake: true } },");
78
- assert.ok(f.migrate(customized).includes("outDir: '/custom-wrapper'"));
79
- });
80
-
81
- test('missing build/rollup settings are added to the original config; unwrapped configs still migrate', () => {
82
- const f = fixture(`export default { ${alias} };`);
83
- const updated = f.migrate(fs.readFileSync(f.file, 'utf8'));
84
- assert.match(updated, /codeplayOriginalViteConfig\s*=\s*\{[\s\S]*build:/);
85
- assert.ok(!updated.includes('...base, build:'));
86
- assert.equal(f.migrate(updated), updated);
87
- const plain = `export default { build: { outDir: '../www', rollupOptions: { treeshake: false, external: ['keep'] } } };`;
88
- const result = f.migrate(plain);
89
- assert.ok(result.includes("outDir: '../www'"));
90
- assert.ok(result.includes("external: ['keep']"));
91
- assert.ok(result.includes('treeshake: true'));
92
- });
1
+ const { test } = require('node:test');
2
+ const assert = require('node:assert/strict');
3
+ const fs = require('node:fs');
4
+ const path = require('node:path');
5
+ const vm = require('node:vm');
6
+ const { pathToFileURL } = require('node:url');
7
+ const { install } = require('./sync-files.js');
8
+
9
+ function fixture(configuration) {
10
+ const base = path.resolve(process.env.CODEPLAY_TEST_ROOT || path.join(__dirname, '../agent-temp'));
11
+ fs.mkdirSync(base, { recursive: true });
12
+ const root = fs.mkdtempSync(path.join(base, 'vite-settings-'));
13
+ fs.writeFileSync(path.join(root, 'package.json'), JSON.stringify({ name: 'vite-fixture', scripts: {}, dependencies: {} }));
14
+ fs.writeFileSync(path.join(root, 'capacitor.config.json'), JSON.stringify({ appId: 'fixture.app', plugins: {
15
+ AdMob: { ADMOB_ENABLED: true }, RuAds: { VK_ADS_ENABLED: true, STORE_IDS: [4, 10] },
16
+ } }));
17
+ fs.mkdirSync(path.join(root, 'src/js/Ads/vk-ads-1.3'), { recursive: true });
18
+ fs.writeFileSync(path.join(root, 'src/js/Ads/vk-ads-1.3/vk-ads.js'), '// manually installed VK controller');
19
+ fs.writeFileSync(path.join(root, 'vite.config.mjs'), configuration);
20
+ install({ projectRoot: root, copyAssets: false });
21
+ // Run the real before-build migration after the real installer. Loading the
22
+ // full before-build CLI would also install SDKs and change native platforms.
23
+ const source = fs.readFileSync(path.join(root, 'buildCodeplay/codeplayBeforeBuild.js'), 'utf8');
24
+ const migration = source.slice(source.indexOf('const migrateViteTreeShaking ='), source.indexOf('// BEGIN IAP BUILD MIGRATION'));
25
+ const migrate = vm.runInNewContext(migration + '\nmigrateViteTreeShaking;');
26
+ return { root, file: path.join(root, 'vite.config.mjs'), migrate };
27
+ }
28
+
29
+ const alias = "resolve: { alias: { '@admob': '/original-admob.js' } }";
30
+ const build = { outDir: '../www', minify: 'terser', sourcemap: true, emptyOutDir: false,
31
+ target: 'es2022', rollupOptions: { external: ['preserved-module'], output: { entryFileNames: 'custom-[name].js' } } };
32
+
33
+ test('installer and before-build preserve build settings for object/function/defineConfig exports and all ad providers', async () => {
34
+ const previous = { cwd: process.cwd(), store: process.env.VITE_STORE_ID, platform: process.env.CODEPLAY_BUILD_PLATFORM };
35
+ try {
36
+ delete process.env.CODEPLAY_BUILD_PLATFORM;
37
+ const config = `{ build: ${JSON.stringify(build)}, ${alias}, define: { custom: 'true' } }`;
38
+ for (const source of [`export default ${config};`, `export default async () => (${config});`, `const defineConfig = c => c;\nexport default defineConfig(${config});`]) {
39
+ const f = fixture(source);
40
+ const updated = f.migrate(fs.readFileSync(f.file, 'utf8'));
41
+ assert.equal(f.migrate(updated), updated);
42
+ fs.writeFileSync(f.file, updated);
43
+ process.chdir(f.root);
44
+ const { default: configure } = await import(pathToFileURL(f.file).href);
45
+ for (const store of ['1', '4', '10']) {
46
+ process.env.VITE_STORE_ID = store;
47
+ const resolved = await configure({ mode: 'production' });
48
+ assert.deepEqual(resolved.build, { ...build, rollupOptions: { ...build.rollupOptions, treeshake: true } });
49
+ assert.equal(resolved.define.custom, 'true');
50
+ assert.equal(resolved.resolve.alias['/buildCodeplay'], path.join(f.root, 'buildCodeplay'));
51
+ assert.equal(resolved.define['import.meta.env.VITE_STORE_ID'], JSON.stringify(store));
52
+ assert.equal(resolved.resolve.alias['@admob'], store === '1' ? '/original-admob.js' : path.join(f.root, 'src/js/Ads/vk-ads-1.3/vk-ads.js'));
53
+ }
54
+ }
55
+ } finally {
56
+ process.chdir(previous.cwd);
57
+ for (const [key, value] of [['VITE_STORE_ID', previous.store], ['CODEPLAY_BUILD_PLATFORM', previous.platform]]) {
58
+ if (value === undefined) delete process.env[key]; else process.env[key] = value;
59
+ }
60
+ }
61
+ });
62
+
63
+ test('migration preserves custom treeshake options and repairs only the previous generated override', async () => {
64
+ const custom = { ...build, rollupOptions: { ...build.rollupOptions, treeshake: { moduleSideEffects: false } } };
65
+ const f = fixture(`export default { build: ${JSON.stringify(custom)}, ${alias} };`);
66
+ let source = fs.readFileSync(f.file, 'utf8');
67
+ source = source.replace('return { ...base,', 'return { ...base, build: { rollupOptions: { treeshake: true } },');
68
+ const updated = f.migrate(source);
69
+ assert.ok(!updated.includes('...base, build:'));
70
+ assert.equal(f.migrate(updated), updated);
71
+ fs.writeFileSync(f.file, updated);
72
+ const previous = process.cwd();
73
+ try {
74
+ process.chdir(f.root);
75
+ const { default: configure } = await import(pathToFileURL(f.file).href);
76
+ assert.deepEqual((await configure({})).build, custom);
77
+ } finally { process.chdir(previous); }
78
+ const customized = source.replace('build: { rollupOptions: { treeshake: true } },', "build: { outDir: '/custom-wrapper', rollupOptions: { treeshake: true } },");
79
+ assert.ok(f.migrate(customized).includes("outDir: '/custom-wrapper'"));
80
+ });
81
+
82
+ test('missing build/rollup settings are added to the original config; unwrapped configs still migrate', () => {
83
+ const f = fixture(`export default { ${alias} };`);
84
+ const updated = f.migrate(fs.readFileSync(f.file, 'utf8'));
85
+ assert.match(updated, /codeplayOriginalViteConfig\s*=\s*\{[\s\S]*build:/);
86
+ assert.ok(!updated.includes('...base, build:'));
87
+ assert.equal(f.migrate(updated), updated);
88
+ const plain = `export default { build: { outDir: '../www', rollupOptions: { treeshake: false, external: ['keep'] } } };`;
89
+ const result = f.migrate(plain);
90
+ assert.ok(result.includes("outDir: '../www'"));
91
+ assert.ok(result.includes("external: ['keep']"));
92
+ assert.ok(result.includes('treeshake: true'));
93
+ });