codeplay-common 4.11.28 → 4.11.30
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 +1 -0
- package/README.md +89 -89
- package/RELEASE_NOTES.md +13 -13
- package/files/buildCodeplay/HUAWEI-PRIVACY.md +9 -0
- package/files/buildCodeplay/add-splash-screen.js +1 -1
- package/files/buildCodeplay/codeplayBeforeBuild.js +4756 -4755
- package/files/buildCodeplay/disabled-ads.mjs +45 -45
- 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 -0
- package/files/buildCodeplay/huawei-privacy.cjs +92 -0
- package/files/buildCodeplay/huawei-privacy.css +22 -0
- package/files/buildCodeplay/iap-alias.cjs +116 -108
- package/files/buildCodeplay/ios-ad-consent.cjs +56 -56
- package/files/buildCodeplay/ios-emi-admob-modification.js +25 -25
- package/files/buildCodeplay/migrate-system-bars.cjs +115 -115
- 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 +211 -211
- package/files/buildCodeplay/saf-mediastore-dependency.cjs +21 -21
- package/files/buildCodeplay/setSplashAnimation.js +2 -2
- package/files/buildCodeplay/setup-ruads.cjs +55 -55
- package/files/buildCodeplay/splash-setup.cjs +88 -88
- package/files/buildCodeplay/store-billing.cjs +43 -43
- package/files/buildCodeplay/tests/huawei-privacy.test.cjs +49 -0
- package/files/buildCodeplay/tests/huawei-vite.test.cjs +35 -0
- package/files/scripts-common/generate-baseline-profile.js +46 -46
- package/files/take-screen-image.js +4414 -4414
- package/package.json +28 -28
- package/runtime/splash-ready.mjs +52 -52
- package/runtime/vk-ads/vk-ad-configuration.json +39 -39
- package/scripts/ensure-current-build.test.cjs +76 -76
- package/scripts/iap-alias.test.cjs +117 -78
- package/scripts/ios-ad-consent.test.cjs +99 -99
- package/scripts/ruads-install.test.cjs +180 -180
- 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/system-bars.test.cjs +77 -77
- package/scripts/vite-build-settings.test.cjs +92 -92
|
@@ -1,142 +1,142 @@
|
|
|
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 { execFileSync } = require('child_process');
|
|
6
|
-
const { readSplashOptions, migrateSplashTheme, migrateReadinessSource, syncSplashSetup } = require('../files/buildCodeplay/splash-setup.cjs');
|
|
7
|
-
|
|
8
|
-
function fixture(t) {
|
|
9
|
-
const base = path.resolve(process.env.CODEPLAY_TEST_ROOT || path.join(__dirname, '../agent-temp'));
|
|
10
|
-
fs.mkdirSync(base, { recursive: true });
|
|
11
|
-
const root = fs.mkdtempSync(path.join(base, 'splash-'));
|
|
12
|
-
t.after(() => {
|
|
13
|
-
if (path.dirname(path.resolve(root)) !== base) throw new Error('Unsafe fixture cleanup');
|
|
14
|
-
fs.rmSync(root, { recursive: true, force: true });
|
|
15
|
-
});
|
|
16
|
-
return root;
|
|
17
|
-
}
|
|
18
|
-
const legacy = `var capacitorApp = {
|
|
19
|
-
handleSplashscreen: function () {
|
|
20
|
-
if (!window.Capacitor) return;
|
|
21
|
-
setTimeout(() => { if (window.Capacitor.Plugins?.SplashScreen) window.Capacitor.Plugins.SplashScreen.hide(); }, 2000);
|
|
22
|
-
},
|
|
23
|
-
};`;
|
|
24
|
-
const options = readSplashOptions({ plugins: { CodeplaySplashScreen: { migrateLegacyReadiness: true } } });
|
|
25
|
-
|
|
26
|
-
test('duration defaults to1000 and preserves explicit0;invalid values fail', () => {
|
|
27
|
-
assert.equal(readSplashOptions({}).duration, 1000);
|
|
28
|
-
assert.equal(readSplashOptions({ plugins: { CodeplaySplashScreen: { exitAnimationDuration: 0 } } }).duration, 0);
|
|
29
|
-
for (const duration of [-1, '0', 1.5, 10001]) assert.throws(() => readSplashOptions({ plugins: { CodeplaySplashScreen: { exitAnimationDuration: duration } } }));
|
|
30
|
-
});
|
|
31
|
-
test('repair known legacy theme,idempotently preserve app-specific themes', () => {
|
|
32
|
-
const before = '<item name="postSplashScreenTheme">@style/Theme.AppCompat.NoActionBar</item>';
|
|
33
|
-
const after = migrateSplashTheme(before);
|
|
34
|
-
assert.ok(after.includes('Theme.AppCompat.DayNight.NoActionBar'));
|
|
35
|
-
assert.equal(migrateSplashTheme(after), after);
|
|
36
|
-
assert.equal(migrateSplashTheme(before.replace('Theme.AppCompat.NoActionBar', 'MyCustomTheme')), before.replace('Theme.AppCompat.NoActionBar', 'MyCustomTheme'));
|
|
37
|
-
});
|
|
38
|
-
test('legacy handler migration requires opt-in,is idempotent,and preserves custom handlers', () => {
|
|
39
|
-
assert.equal(migrateReadinessSource(legacy, readSplashOptions({})).source, legacy);
|
|
40
|
-
const migrated = migrateReadinessSource(legacy, options);
|
|
41
|
-
assert.equal(migrated.status, 'managed');
|
|
42
|
-
assert.equal(migrateReadinessSource(migrated.source, options).source, migrated.source);
|
|
43
|
-
const custom = migrated.source.replace(' if (!window.Capacitor)', ' customStartup();\n if (!window.Capacitor)');
|
|
44
|
-
assert.equal(migrateReadinessSource(custom, options).source, custom);
|
|
45
|
-
const customAfter = migrated.source.replace(' });', ' });\n customStartup();');
|
|
46
|
-
assert.equal(migrateReadinessSource(customAfter, options).source, customAfter);
|
|
47
|
-
});
|
|
48
|
-
test('migration keeps legacy native-disabled config and custom theme intact', t => {
|
|
49
|
-
const root = fixture(t);
|
|
50
|
-
fs.mkdirSync(path.join(root, 'src/js'), { recursive: true });
|
|
51
|
-
fs.mkdirSync(path.join(root, 'buildCodeplay/splashxml'), { recursive: true });
|
|
52
|
-
fs.writeFileSync(path.join(root, 'src/js/capacitor-app.js'), legacy);
|
|
53
|
-
fs.writeFileSync(path.join(root, 'buildCodeplay/splashxml/codeplay_splashScreen.xml'), '<item name="postSplashScreenTheme">@style/Custom</item>');
|
|
54
|
-
fs.writeFileSync(path.join(root, 'capacitor.config.json'), JSON.stringify({ plugins: { SplashScreen: { launchShowDuration: 0 }, CodeplaySplashScreen: { migrateLegacyReadiness: true } } }));
|
|
55
|
-
const log = [];
|
|
56
|
-
syncSplashSetup(root, { log: value => log.push(value) });
|
|
57
|
-
assert.equal(fs.readFileSync(path.join(root, 'src/js/capacitor-app.js'), 'utf8'), legacy);
|
|
58
|
-
assert.ok(log.some(value => value.includes('native fallback')));
|
|
59
|
-
});
|
|
60
|
-
test('generator emits0ms without changing launchShowDuration', t => {
|
|
61
|
-
const root = fixture(t);
|
|
62
|
-
const java = path.join(root, 'android/app/src/main/java/example/app/MainActivity.java');
|
|
63
|
-
fs.mkdirSync(path.dirname(java), { recursive: true });
|
|
64
|
-
fs.writeFileSync(java, 'package example.app;');
|
|
65
|
-
const config = { appId: 'example.app', plugins: { SplashScreen: { launchShowDuration: 8000 }, CodeplaySplashScreen: { exitAnimationDuration: 0 } } };
|
|
66
|
-
fs.writeFileSync(path.join(root, 'capacitor.config.json'), JSON.stringify(config));
|
|
67
|
-
execFileSync(process.execPath, [path.resolve(__dirname, '../files/buildCodeplay/setSplashAnimation.js')], { cwd: root, stdio: 'pipe' });
|
|
68
|
-
assert.ok(fs.readFileSync(java, 'utf8').includes('.setDuration(0)'));
|
|
69
|
-
assert.deepEqual(JSON.parse(fs.readFileSync(path.join(root, 'capacitor.config.json'))), config);
|
|
70
|
-
});
|
|
71
|
-
test('complete migration requires fallback and plugin dependency;repeat preparation is stable', t => {
|
|
72
|
-
const root = fixture(t);
|
|
73
|
-
fs.mkdirSync(path.join(root, 'src/js'), { recursive: true });
|
|
74
|
-
const app = path.join(root, 'src/js/capacitor-app.js');
|
|
75
|
-
fs.writeFileSync(app, legacy);
|
|
76
|
-
const config = { plugins: { SplashScreen: { launchShowDuration: 8000, launchAutoHide: true }, CodeplaySplashScreen: { migrateLegacyReadiness: true } } };
|
|
77
|
-
fs.writeFileSync(path.join(root, 'capacitor.config.json'), JSON.stringify(config));
|
|
78
|
-
fs.writeFileSync(path.join(root, 'package.json'), JSON.stringify({ dependencies: {} }));
|
|
79
|
-
syncSplashSetup(root, { log() {} });
|
|
80
|
-
assert.equal(fs.readFileSync(app, 'utf8'), legacy);
|
|
81
|
-
fs.writeFileSync(path.join(root, 'package.json'), JSON.stringify({ dependencies: { '@capacitor/splash-screen': '^8.0.0' } }));
|
|
82
|
-
syncSplashSetup(root, { log() {} });
|
|
83
|
-
const result = fs.readFileSync(app, 'utf8');
|
|
84
|
-
assert.ok(result.includes('return hideSplashWhenReady('));
|
|
85
|
-
syncSplashSetup(root, { log() {} });
|
|
86
|
-
assert.equal(fs.readFileSync(app, 'utf8'), result);
|
|
87
|
-
assert.deepEqual(JSON.parse(fs.readFileSync(path.join(root, 'capacitor.config.json'))), config);
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
function framework(image, cached = false) {
|
|
91
|
-
const handlers = new Map();
|
|
92
|
-
const page = { closest: () => true, querySelector: () => image };
|
|
93
|
-
return { page, handlers, f7: { on: (name, fn) => handlers.set(name, fn), off: name => handlers.delete(name), views: { main: { router: { currentPageEl: cached ? page : null } } } } };
|
|
94
|
-
}
|
|
95
|
-
test('wait for main-page image decode,hide once,and detach listeners', async () => {
|
|
96
|
-
const { hideSplashWhenReady } = await import('../runtime/splash-ready.mjs');
|
|
97
|
-
let decoded, count = 0;
|
|
98
|
-
const listeners = new Map();
|
|
99
|
-
const image = { complete: false, naturalWidth: 100, decode: () => new Promise(resolve => { decoded = resolve; }), addEventListener: (name, fn) => listeners.set(name, fn), removeEventListener: name => listeners.delete(name) };
|
|
100
|
-
const { f7, handlers, page } = framework(image);
|
|
101
|
-
const finish = hideSplashWhenReady({ f7, hide: () => { count++; } });
|
|
102
|
-
handlers.get('pageAfterIn')({ el: { closest: () => false } });
|
|
103
|
-
assert.equal(count, 0);
|
|
104
|
-
handlers.get('pageAfterIn')({ el: page });
|
|
105
|
-
listeners.get('load')();
|
|
106
|
-
await Promise.resolve();
|
|
107
|
-
assert.equal(count, 0);
|
|
108
|
-
decoded();
|
|
109
|
-
await new Promise(resolve => setImmediate(resolve));
|
|
110
|
-
finish();
|
|
111
|
-
assert.equal(count, 1);
|
|
112
|
-
assert.equal(handlers.size, 0);
|
|
113
|
-
assert.equal(listeners.size, 0);
|
|
114
|
-
});
|
|
115
|
-
test('cached page without hero hides immediately and repeated setup is safe', async () => {
|
|
116
|
-
const { hideSplashWhenReady } = await import('../runtime/splash-ready.mjs');
|
|
117
|
-
const { f7 } = framework(null, true);
|
|
118
|
-
let count = 0;
|
|
119
|
-
hideSplashWhenReady({ f7, hide: () => { count++; } });
|
|
120
|
-
hideSplashWhenReady({ f7, hide: () => { count++; } });
|
|
121
|
-
assert.equal(count, 1);
|
|
122
|
-
});
|
|
123
|
-
test('broken image and failed decode release splash', async () => {
|
|
124
|
-
const { hideSplashWhenReady } = await import('../runtime/splash-ready.mjs');
|
|
125
|
-
for (const naturalWidth of [0, 100]) {
|
|
126
|
-
let count = 0;
|
|
127
|
-
const image = { complete: true, naturalWidth, decode: () => Promise.reject(new Error('decode failed')), removeEventListener() {} };
|
|
128
|
-
const { f7 } = framework(image, true);
|
|
129
|
-
hideSplashWhenReady({ f7, hide: () => { count++; } });
|
|
130
|
-
await new Promise(resolve => setImmediate(resolve));
|
|
131
|
-
assert.equal(count, 1);
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
test('timeout releases stuck page and consumes native plugin rejection', async () => {
|
|
135
|
-
const { hideSplashWhenReady } = await import('../runtime/splash-ready.mjs');
|
|
136
|
-
const { f7, handlers } = framework(null);
|
|
137
|
-
let count = 0;
|
|
138
|
-
hideSplashWhenReady({ f7, timeout: 10, hide: () => { count++; return Promise.reject(new Error('native unavailable')); } });
|
|
139
|
-
await new Promise(resolve => setTimeout(resolve, 30));
|
|
140
|
-
assert.equal(count, 1);
|
|
141
|
-
assert.equal(handlers.size, 0);
|
|
142
|
-
});
|
|
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 { execFileSync } = require('child_process');
|
|
6
|
+
const { readSplashOptions, migrateSplashTheme, migrateReadinessSource, syncSplashSetup } = require('../files/buildCodeplay/splash-setup.cjs');
|
|
7
|
+
|
|
8
|
+
function fixture(t) {
|
|
9
|
+
const base = path.resolve(process.env.CODEPLAY_TEST_ROOT || path.join(__dirname, '../agent-temp'));
|
|
10
|
+
fs.mkdirSync(base, { recursive: true });
|
|
11
|
+
const root = fs.mkdtempSync(path.join(base, 'splash-'));
|
|
12
|
+
t.after(() => {
|
|
13
|
+
if (path.dirname(path.resolve(root)) !== base) throw new Error('Unsafe fixture cleanup');
|
|
14
|
+
fs.rmSync(root, { recursive: true, force: true });
|
|
15
|
+
});
|
|
16
|
+
return root;
|
|
17
|
+
}
|
|
18
|
+
const legacy = `var capacitorApp = {
|
|
19
|
+
handleSplashscreen: function () {
|
|
20
|
+
if (!window.Capacitor) return;
|
|
21
|
+
setTimeout(() => { if (window.Capacitor.Plugins?.SplashScreen) window.Capacitor.Plugins.SplashScreen.hide(); }, 2000);
|
|
22
|
+
},
|
|
23
|
+
};`;
|
|
24
|
+
const options = readSplashOptions({ plugins: { CodeplaySplashScreen: { migrateLegacyReadiness: true } } });
|
|
25
|
+
|
|
26
|
+
test('duration defaults to1000 and preserves explicit0;invalid values fail', () => {
|
|
27
|
+
assert.equal(readSplashOptions({}).duration, 1000);
|
|
28
|
+
assert.equal(readSplashOptions({ plugins: { CodeplaySplashScreen: { exitAnimationDuration: 0 } } }).duration, 0);
|
|
29
|
+
for (const duration of [-1, '0', 1.5, 10001]) assert.throws(() => readSplashOptions({ plugins: { CodeplaySplashScreen: { exitAnimationDuration: duration } } }));
|
|
30
|
+
});
|
|
31
|
+
test('repair known legacy theme,idempotently preserve app-specific themes', () => {
|
|
32
|
+
const before = '<item name="postSplashScreenTheme">@style/Theme.AppCompat.NoActionBar</item>';
|
|
33
|
+
const after = migrateSplashTheme(before);
|
|
34
|
+
assert.ok(after.includes('Theme.AppCompat.DayNight.NoActionBar'));
|
|
35
|
+
assert.equal(migrateSplashTheme(after), after);
|
|
36
|
+
assert.equal(migrateSplashTheme(before.replace('Theme.AppCompat.NoActionBar', 'MyCustomTheme')), before.replace('Theme.AppCompat.NoActionBar', 'MyCustomTheme'));
|
|
37
|
+
});
|
|
38
|
+
test('legacy handler migration requires opt-in,is idempotent,and preserves custom handlers', () => {
|
|
39
|
+
assert.equal(migrateReadinessSource(legacy, readSplashOptions({})).source, legacy);
|
|
40
|
+
const migrated = migrateReadinessSource(legacy, options);
|
|
41
|
+
assert.equal(migrated.status, 'managed');
|
|
42
|
+
assert.equal(migrateReadinessSource(migrated.source, options).source, migrated.source);
|
|
43
|
+
const custom = migrated.source.replace(' if (!window.Capacitor)', ' customStartup();\n if (!window.Capacitor)');
|
|
44
|
+
assert.equal(migrateReadinessSource(custom, options).source, custom);
|
|
45
|
+
const customAfter = migrated.source.replace(' });', ' });\n customStartup();');
|
|
46
|
+
assert.equal(migrateReadinessSource(customAfter, options).source, customAfter);
|
|
47
|
+
});
|
|
48
|
+
test('migration keeps legacy native-disabled config and custom theme intact', t => {
|
|
49
|
+
const root = fixture(t);
|
|
50
|
+
fs.mkdirSync(path.join(root, 'src/js'), { recursive: true });
|
|
51
|
+
fs.mkdirSync(path.join(root, 'buildCodeplay/splashxml'), { recursive: true });
|
|
52
|
+
fs.writeFileSync(path.join(root, 'src/js/capacitor-app.js'), legacy);
|
|
53
|
+
fs.writeFileSync(path.join(root, 'buildCodeplay/splashxml/codeplay_splashScreen.xml'), '<item name="postSplashScreenTheme">@style/Custom</item>');
|
|
54
|
+
fs.writeFileSync(path.join(root, 'capacitor.config.json'), JSON.stringify({ plugins: { SplashScreen: { launchShowDuration: 0 }, CodeplaySplashScreen: { migrateLegacyReadiness: true } } }));
|
|
55
|
+
const log = [];
|
|
56
|
+
syncSplashSetup(root, { log: value => log.push(value) });
|
|
57
|
+
assert.equal(fs.readFileSync(path.join(root, 'src/js/capacitor-app.js'), 'utf8'), legacy);
|
|
58
|
+
assert.ok(log.some(value => value.includes('native fallback')));
|
|
59
|
+
});
|
|
60
|
+
test('generator emits0ms without changing launchShowDuration', t => {
|
|
61
|
+
const root = fixture(t);
|
|
62
|
+
const java = path.join(root, 'android/app/src/main/java/example/app/MainActivity.java');
|
|
63
|
+
fs.mkdirSync(path.dirname(java), { recursive: true });
|
|
64
|
+
fs.writeFileSync(java, 'package example.app;');
|
|
65
|
+
const config = { appId: 'example.app', plugins: { SplashScreen: { launchShowDuration: 8000 }, CodeplaySplashScreen: { exitAnimationDuration: 0 } } };
|
|
66
|
+
fs.writeFileSync(path.join(root, 'capacitor.config.json'), JSON.stringify(config));
|
|
67
|
+
execFileSync(process.execPath, [path.resolve(__dirname, '../files/buildCodeplay/setSplashAnimation.js')], { cwd: root, stdio: 'pipe' });
|
|
68
|
+
assert.ok(fs.readFileSync(java, 'utf8').includes('.setDuration(0)'));
|
|
69
|
+
assert.deepEqual(JSON.parse(fs.readFileSync(path.join(root, 'capacitor.config.json'))), config);
|
|
70
|
+
});
|
|
71
|
+
test('complete migration requires fallback and plugin dependency;repeat preparation is stable', t => {
|
|
72
|
+
const root = fixture(t);
|
|
73
|
+
fs.mkdirSync(path.join(root, 'src/js'), { recursive: true });
|
|
74
|
+
const app = path.join(root, 'src/js/capacitor-app.js');
|
|
75
|
+
fs.writeFileSync(app, legacy);
|
|
76
|
+
const config = { plugins: { SplashScreen: { launchShowDuration: 8000, launchAutoHide: true }, CodeplaySplashScreen: { migrateLegacyReadiness: true } } };
|
|
77
|
+
fs.writeFileSync(path.join(root, 'capacitor.config.json'), JSON.stringify(config));
|
|
78
|
+
fs.writeFileSync(path.join(root, 'package.json'), JSON.stringify({ dependencies: {} }));
|
|
79
|
+
syncSplashSetup(root, { log() {} });
|
|
80
|
+
assert.equal(fs.readFileSync(app, 'utf8'), legacy);
|
|
81
|
+
fs.writeFileSync(path.join(root, 'package.json'), JSON.stringify({ dependencies: { '@capacitor/splash-screen': '^8.0.0' } }));
|
|
82
|
+
syncSplashSetup(root, { log() {} });
|
|
83
|
+
const result = fs.readFileSync(app, 'utf8');
|
|
84
|
+
assert.ok(result.includes('return hideSplashWhenReady('));
|
|
85
|
+
syncSplashSetup(root, { log() {} });
|
|
86
|
+
assert.equal(fs.readFileSync(app, 'utf8'), result);
|
|
87
|
+
assert.deepEqual(JSON.parse(fs.readFileSync(path.join(root, 'capacitor.config.json'))), config);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
function framework(image, cached = false) {
|
|
91
|
+
const handlers = new Map();
|
|
92
|
+
const page = { closest: () => true, querySelector: () => image };
|
|
93
|
+
return { page, handlers, f7: { on: (name, fn) => handlers.set(name, fn), off: name => handlers.delete(name), views: { main: { router: { currentPageEl: cached ? page : null } } } } };
|
|
94
|
+
}
|
|
95
|
+
test('wait for main-page image decode,hide once,and detach listeners', async () => {
|
|
96
|
+
const { hideSplashWhenReady } = await import('../runtime/splash-ready.mjs');
|
|
97
|
+
let decoded, count = 0;
|
|
98
|
+
const listeners = new Map();
|
|
99
|
+
const image = { complete: false, naturalWidth: 100, decode: () => new Promise(resolve => { decoded = resolve; }), addEventListener: (name, fn) => listeners.set(name, fn), removeEventListener: name => listeners.delete(name) };
|
|
100
|
+
const { f7, handlers, page } = framework(image);
|
|
101
|
+
const finish = hideSplashWhenReady({ f7, hide: () => { count++; } });
|
|
102
|
+
handlers.get('pageAfterIn')({ el: { closest: () => false } });
|
|
103
|
+
assert.equal(count, 0);
|
|
104
|
+
handlers.get('pageAfterIn')({ el: page });
|
|
105
|
+
listeners.get('load')();
|
|
106
|
+
await Promise.resolve();
|
|
107
|
+
assert.equal(count, 0);
|
|
108
|
+
decoded();
|
|
109
|
+
await new Promise(resolve => setImmediate(resolve));
|
|
110
|
+
finish();
|
|
111
|
+
assert.equal(count, 1);
|
|
112
|
+
assert.equal(handlers.size, 0);
|
|
113
|
+
assert.equal(listeners.size, 0);
|
|
114
|
+
});
|
|
115
|
+
test('cached page without hero hides immediately and repeated setup is safe', async () => {
|
|
116
|
+
const { hideSplashWhenReady } = await import('../runtime/splash-ready.mjs');
|
|
117
|
+
const { f7 } = framework(null, true);
|
|
118
|
+
let count = 0;
|
|
119
|
+
hideSplashWhenReady({ f7, hide: () => { count++; } });
|
|
120
|
+
hideSplashWhenReady({ f7, hide: () => { count++; } });
|
|
121
|
+
assert.equal(count, 1);
|
|
122
|
+
});
|
|
123
|
+
test('broken image and failed decode release splash', async () => {
|
|
124
|
+
const { hideSplashWhenReady } = await import('../runtime/splash-ready.mjs');
|
|
125
|
+
for (const naturalWidth of [0, 100]) {
|
|
126
|
+
let count = 0;
|
|
127
|
+
const image = { complete: true, naturalWidth, decode: () => Promise.reject(new Error('decode failed')), removeEventListener() {} };
|
|
128
|
+
const { f7 } = framework(image, true);
|
|
129
|
+
hideSplashWhenReady({ f7, hide: () => { count++; } });
|
|
130
|
+
await new Promise(resolve => setImmediate(resolve));
|
|
131
|
+
assert.equal(count, 1);
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
test('timeout releases stuck page and consumes native plugin rejection', async () => {
|
|
135
|
+
const { hideSplashWhenReady } = await import('../runtime/splash-ready.mjs');
|
|
136
|
+
const { f7, handlers } = framework(null);
|
|
137
|
+
let count = 0;
|
|
138
|
+
hideSplashWhenReady({ f7, timeout: 10, hide: () => { count++; return Promise.reject(new Error('native unavailable')); } });
|
|
139
|
+
await new Promise(resolve => setTimeout(resolve, 30));
|
|
140
|
+
assert.equal(count, 1);
|
|
141
|
+
assert.equal(handlers.size, 0);
|
|
142
|
+
});
|
package/scripts/sync-files.js
CHANGED
|
@@ -102,7 +102,7 @@ function install(options = {}) {
|
|
|
102
102
|
runtimeRoot: path.resolve(__dirname, '../runtime/vk-ads'),
|
|
103
103
|
});
|
|
104
104
|
require('../files/buildCodeplay/iap-alias.cjs').syncIapAliases(projectRoot);
|
|
105
|
-
migrateAppConfigurator(projectRoot);
|
|
105
|
+
migrateAppConfigurator(projectRoot);
|
|
106
106
|
require('../files/buildCodeplay/migrate-system-bars.cjs').migrateSystemBars(projectRoot);
|
|
107
107
|
syncAndroidR8Rules(projectRoot, { installGradleHook: true });
|
|
108
108
|
pkg.scripts = scripts;
|
|
@@ -1,77 +1,77 @@
|
|
|
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 { migrateSystemBars, auditLegacyStatusBar, migrateLegacyStatusBar } = require('../files/buildCodeplay/migrate-system-bars.cjs');
|
|
6
|
-
|
|
7
|
-
function fixture() {
|
|
8
|
-
const base = path.resolve(process.env.CODEPLAY_TEST_ROOT || path.join(__dirname, '../agent-temp'));
|
|
9
|
-
fs.mkdirSync(base, { recursive: true });
|
|
10
|
-
const root = fs.mkdtempSync(path.join(base, 'system-bars-'));
|
|
11
|
-
const write = (relative, content) => {
|
|
12
|
-
const file = path.join(root, relative);
|
|
13
|
-
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
14
|
-
fs.writeFileSync(file, content);
|
|
15
|
-
};
|
|
16
|
-
write('package.json', JSON.stringify({ name: 'fixture', dependencies: { '@capacitor/status-bar': '^8.0.4' } }));
|
|
17
|
-
return { root, write };
|
|
18
|
-
}
|
|
19
|
-
const modern = 'import {SystemBars,SystemBarType} from "@capacitor/core"; SystemBars.setStyle({style:"DARK",bar:SystemBarType.StatusBar});';
|
|
20
|
-
|
|
21
|
-
test('legacy dependency is removed only after confirming modern usage; native references are refreshed', async () => {
|
|
22
|
-
const { root, write } = fixture();
|
|
23
|
-
write('src/app.js', modern + '\n/* StatusBar.hide(); */');
|
|
24
|
-
assert.equal((await auditLegacyStatusBar(root)).status, 'unused');
|
|
25
|
-
write('android/capacitor.settings.gradle', "include ':capacitor-status-bar'\n");
|
|
26
|
-
write('ios/App/Podfile', "# App pods\n pod 'CapacitorStatusBar', :path => '../../node_modules/@capacitor/status-bar'\n pod 'CapacitorApp'\n");
|
|
27
|
-
const commands = [];
|
|
28
|
-
const result = await migrateLegacyStatusBar(root, { runNpm: command => commands.push(command) });
|
|
29
|
-
assert.equal(result.status, 'removed');
|
|
30
|
-
assert.deepEqual(commands, ['npm uninstall @capacitor/status-bar --ignore-scripts --no-audit --no-fund', 'npx --no-install cap update android']);
|
|
31
|
-
assert.equal(fs.readFileSync(path.join(root, 'ios/App/Podfile'), 'utf8'), "# App pods\n pod 'CapacitorApp'\n");
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
for (const [name, code] of [
|
|
35
|
-
['active import', modern + 'import {StatusBar} from "@capacitor/status-bar"; StatusBar.hide();'],
|
|
36
|
-
['URL followed by a legacy call', modern + 'const url="https://localhost"; StatusBar.hide();'],
|
|
37
|
-
['unparseable code', modern + 'const invalid=;'],
|
|
38
|
-
['no confirmed replacement API', 'console.log("app");']
|
|
39
|
-
]) {
|
|
40
|
-
test(`preserves dependency for ${name}`, async () => {
|
|
41
|
-
const { root, write } = fixture();
|
|
42
|
-
write('src/app.js', code);
|
|
43
|
-
const result = await migrateLegacyStatusBar(root, { runNpm: () => assert.fail('must retain the dependency') });
|
|
44
|
-
assert.equal(result.status, 'retained');
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
test('Framework7 script handling ignores old generated diagnostics and retains custom native registration', async () => {
|
|
49
|
-
const { root, write } = fixture();
|
|
50
|
-
write('src/page.f7', `<template><div></div></template><script>${modern}</script>`);
|
|
51
|
-
write('src/agent-temp/old.js', 'StatusBar.hide();');
|
|
52
|
-
assert.equal((await auditLegacyStatusBar(root)).status, 'unused');
|
|
53
|
-
write('android/app/src/main/java/App.java', 'bridge.registerPlugin(StatusBarPlugin.class);');
|
|
54
|
-
assert.equal((await auditLegacyStatusBar(root)).status, 'retained');
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
test('native patch preserves surrounding code, is idempotent, and fails closed for unexpected sources', () => {
|
|
58
|
-
const { root, write } = fixture();
|
|
59
|
-
const relative = 'node_modules/capacitor-codeplay-system-bars/android/src/main/java/com/codeplay/systembars/CodeplaySystemBarsPlugin.java';
|
|
60
|
-
const original = 'controller.setAppearanceLightNavigationBars(useDarkIcons);\r\n window.setNavigationBarColor(Color.TRANSPARENT);\r\nwindow.getDecorView().post(this::updateNavigationBarProtection);\r\n';
|
|
61
|
-
write(relative, original);
|
|
62
|
-
assert.equal(migrateSystemBars(root), true);
|
|
63
|
-
const patched = fs.readFileSync(path.join(root, relative), 'utf8');
|
|
64
|
-
assert(patched.includes('Build.VERSION.SDK_INT < Build.VERSION_CODES.VANILLA_ICE_CREAM'));
|
|
65
|
-
assert(patched.startsWith(original.split('\r\n')[0] + '\r\n'));
|
|
66
|
-
assert(patched.endsWith(original.split('\r\n').slice(-2).join('\r\n')));
|
|
67
|
-
assert.equal(migrateSystemBars(root), false);
|
|
68
|
-
assert.equal(fs.readFileSync(path.join(root, relative), 'utf8'), patched);
|
|
69
|
-
write(relative, 'unexpected implementation');
|
|
70
|
-
assert.throws(() => migrateSystemBars(root), /structure changed/);
|
|
71
|
-
assert.equal(fs.readFileSync(path.join(root, relative), 'utf8'), 'unexpected implementation');
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
test('missing navigation-bar plugin is allowed during installation', () => {
|
|
75
|
-
const { root } = fixture();
|
|
76
|
-
assert.equal(migrateSystemBars(root), false);
|
|
77
|
-
});
|
|
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 { migrateSystemBars, auditLegacyStatusBar, migrateLegacyStatusBar } = require('../files/buildCodeplay/migrate-system-bars.cjs');
|
|
6
|
+
|
|
7
|
+
function fixture() {
|
|
8
|
+
const base = path.resolve(process.env.CODEPLAY_TEST_ROOT || path.join(__dirname, '../agent-temp'));
|
|
9
|
+
fs.mkdirSync(base, { recursive: true });
|
|
10
|
+
const root = fs.mkdtempSync(path.join(base, 'system-bars-'));
|
|
11
|
+
const write = (relative, content) => {
|
|
12
|
+
const file = path.join(root, relative);
|
|
13
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
14
|
+
fs.writeFileSync(file, content);
|
|
15
|
+
};
|
|
16
|
+
write('package.json', JSON.stringify({ name: 'fixture', dependencies: { '@capacitor/status-bar': '^8.0.4' } }));
|
|
17
|
+
return { root, write };
|
|
18
|
+
}
|
|
19
|
+
const modern = 'import {SystemBars,SystemBarType} from "@capacitor/core"; SystemBars.setStyle({style:"DARK",bar:SystemBarType.StatusBar});';
|
|
20
|
+
|
|
21
|
+
test('legacy dependency is removed only after confirming modern usage; native references are refreshed', async () => {
|
|
22
|
+
const { root, write } = fixture();
|
|
23
|
+
write('src/app.js', modern + '\n/* StatusBar.hide(); */');
|
|
24
|
+
assert.equal((await auditLegacyStatusBar(root)).status, 'unused');
|
|
25
|
+
write('android/capacitor.settings.gradle', "include ':capacitor-status-bar'\n");
|
|
26
|
+
write('ios/App/Podfile', "# App pods\n pod 'CapacitorStatusBar', :path => '../../node_modules/@capacitor/status-bar'\n pod 'CapacitorApp'\n");
|
|
27
|
+
const commands = [];
|
|
28
|
+
const result = await migrateLegacyStatusBar(root, { runNpm: command => commands.push(command) });
|
|
29
|
+
assert.equal(result.status, 'removed');
|
|
30
|
+
assert.deepEqual(commands, ['npm uninstall @capacitor/status-bar --ignore-scripts --no-audit --no-fund', 'npx --no-install cap update android']);
|
|
31
|
+
assert.equal(fs.readFileSync(path.join(root, 'ios/App/Podfile'), 'utf8'), "# App pods\n pod 'CapacitorApp'\n");
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
for (const [name, code] of [
|
|
35
|
+
['active import', modern + 'import {StatusBar} from "@capacitor/status-bar"; StatusBar.hide();'],
|
|
36
|
+
['URL followed by a legacy call', modern + 'const url="https://localhost"; StatusBar.hide();'],
|
|
37
|
+
['unparseable code', modern + 'const invalid=;'],
|
|
38
|
+
['no confirmed replacement API', 'console.log("app");']
|
|
39
|
+
]) {
|
|
40
|
+
test(`preserves dependency for ${name}`, async () => {
|
|
41
|
+
const { root, write } = fixture();
|
|
42
|
+
write('src/app.js', code);
|
|
43
|
+
const result = await migrateLegacyStatusBar(root, { runNpm: () => assert.fail('must retain the dependency') });
|
|
44
|
+
assert.equal(result.status, 'retained');
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
test('Framework7 script handling ignores old generated diagnostics and retains custom native registration', async () => {
|
|
49
|
+
const { root, write } = fixture();
|
|
50
|
+
write('src/page.f7', `<template><div></div></template><script>${modern}</script>`);
|
|
51
|
+
write('src/agent-temp/old.js', 'StatusBar.hide();');
|
|
52
|
+
assert.equal((await auditLegacyStatusBar(root)).status, 'unused');
|
|
53
|
+
write('android/app/src/main/java/App.java', 'bridge.registerPlugin(StatusBarPlugin.class);');
|
|
54
|
+
assert.equal((await auditLegacyStatusBar(root)).status, 'retained');
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test('native patch preserves surrounding code, is idempotent, and fails closed for unexpected sources', () => {
|
|
58
|
+
const { root, write } = fixture();
|
|
59
|
+
const relative = 'node_modules/capacitor-codeplay-system-bars/android/src/main/java/com/codeplay/systembars/CodeplaySystemBarsPlugin.java';
|
|
60
|
+
const original = 'controller.setAppearanceLightNavigationBars(useDarkIcons);\r\n window.setNavigationBarColor(Color.TRANSPARENT);\r\nwindow.getDecorView().post(this::updateNavigationBarProtection);\r\n';
|
|
61
|
+
write(relative, original);
|
|
62
|
+
assert.equal(migrateSystemBars(root), true);
|
|
63
|
+
const patched = fs.readFileSync(path.join(root, relative), 'utf8');
|
|
64
|
+
assert(patched.includes('Build.VERSION.SDK_INT < Build.VERSION_CODES.VANILLA_ICE_CREAM'));
|
|
65
|
+
assert(patched.startsWith(original.split('\r\n')[0] + '\r\n'));
|
|
66
|
+
assert(patched.endsWith(original.split('\r\n').slice(-2).join('\r\n')));
|
|
67
|
+
assert.equal(migrateSystemBars(root), false);
|
|
68
|
+
assert.equal(fs.readFileSync(path.join(root, relative), 'utf8'), patched);
|
|
69
|
+
write(relative, 'unexpected implementation');
|
|
70
|
+
assert.throws(() => migrateSystemBars(root), /structure changed/);
|
|
71
|
+
assert.equal(fs.readFileSync(path.join(root, relative), 'utf8'), 'unexpected implementation');
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
test('missing navigation-bar plugin is allowed during installation', () => {
|
|
75
|
+
const { root } = fixture();
|
|
76
|
+
assert.equal(migrateSystemBars(root), false);
|
|
77
|
+
});
|