codeplay-common 4.11.35 → 4.11.37
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 +115 -115
- package/LICENSE +21 -21
- package/README.md +380 -374
- package/RELEASE_NOTES.md +110 -110
- package/files/buildCodeplay/HUAWEI-PRIVACY.md +9 -9
- package/files/buildCodeplay/add-splash-screen.js +256 -256
- package/files/buildCodeplay/apk-store-builder.js +97 -97
- package/files/buildCodeplay/codeplayBeforeBuild.js +4793 -4793
- package/files/buildCodeplay/disabled-ads.mjs +53 -53
- package/files/buildCodeplay/fix-onesignal-plugin.js +96 -96
- 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.cjs +102 -92
- package/files/buildCodeplay/iap-alias.cjs +116 -116
- package/files/buildCodeplay/ios-emi-admob-modification.js +24 -24
- package/files/buildCodeplay/manifestModification.js +38 -38
- package/files/buildCodeplay/migrate-system-bars.cjs +122 -122
- package/files/buildCodeplay/packageidBaseModification.js +528 -528
- package/files/buildCodeplay/project-scripts.cjs +69 -69
- package/files/buildCodeplay/ruads.cjs +10 -1
- package/files/buildCodeplay/setSplashAnimation.js +228 -228
- package/files/buildCodeplay/setup-ruads.cjs +9 -2
- package/files/buildCodeplay/splash-setup.cjs +88 -88
- package/files/buildCodeplay/splashxml/codeplay_splashScreen.xml +11 -11
- package/files/buildCodeplay/sync-admob-nextgen.js +219 -219
- package/files/buildCodeplay/tests/huawei-live-reload.test.cjs +60 -0
- package/files/buildCodeplay/tests/huawei-multiple-entries.test.cjs +80 -0
- package/files/buildCodeplay/tests/huawei-vite.test.cjs +38 -35
- package/files/buildCodeplay/versions.json +28 -28
- package/files/finalrelease +1365 -1365
- package/files/generate-ai-promo-video.js +23 -23
- package/files/ionic.config.json +6 -6
- package/files/scripts-common/run-codeplay-sync-after.js +21 -21
- package/files/scripts-common/screenshot/background-decorations.js +120 -120
- package/files/scripts-common/screenshot/frame-samples.js +117 -117
- package/files/scripts-common/setup-baseline-profile.js +291 -291
- package/files/take-screen-video.js +644 -644
- package/package.json +29 -29
- package/runtime/splash-ready.mjs +52 -52
- package/scripts/iap-alias.test.cjs +117 -117
- package/scripts/ruads-install.test.cjs +20 -3
- package/scripts/splash-setup.test.cjs +142 -142
- package/scripts/squeezeback-config.test.cjs +78 -78
- package/scripts/sync-files.js +119 -119
- package/scripts/system-bars-package.test.cjs +38 -38
- package/scripts/system-bars.test.cjs +93 -93
- package/scripts/uninstall.js +2 -2
- package/scripts/vite-build-settings.test.cjs +1 -0
|
@@ -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
|
+
});
|
|
@@ -1,78 +1,78 @@
|
|
|
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
|
-
const script = fs.readFileSync(path.join(__dirname, '../files/buildCodeplay/codeplayBeforeBuild.js'), 'utf8');
|
|
7
|
-
const defaults = script.slice(script.indexOf('const ADMOB_NEXTGEN_DEFAULTS ='), script.indexOf('function getAdmobJsonPath()'));
|
|
8
|
-
const merge = script.slice(script.indexOf('const mergeObjects ='), script.indexOf('const syncAdmobNextgenPackage ='));
|
|
9
|
-
const context = vm.createContext({ compareVersionStrings: (a, b) => a.localeCompare(b, undefined, { numeric: true }) });
|
|
10
|
-
vm.runInContext(defaults + merge, context);
|
|
11
|
-
const migrate = (template = {}, app = {}, old = {}) => JSON.parse(JSON.stringify(vm.runInContext(
|
|
12
|
-
`buildNextgenAdmobConfigFromOldConfig(${JSON.stringify(template)},${JSON.stringify(app)},${JSON.stringify(old)})`, context)));
|
|
13
|
-
|
|
14
|
-
test('old app configs acquire the new properties and a dedicated test unit', () => {
|
|
15
|
-
const result = migrate({}, { VERSION: '1.8', android: { bannerid: 'app-banner' } });
|
|
16
|
-
assert.equal(result.VERSION, '1.9');
|
|
17
|
-
assert.equal(result.config.setCoarseLocationCollectionEnabled, true);
|
|
18
|
-
assert.equal(result.config.squeezebackEnabled, false);
|
|
19
|
-
assert.equal(result.config.squeezebackRetryIntervalMs, 5000);
|
|
20
|
-
assert.deepEqual(result.config.squeezebackPages, []);
|
|
21
|
-
assert.equal(result.android.squeezebackid, '');
|
|
22
|
-
assert.equal(result.ios.squeezebackid, '');
|
|
23
|
-
assert.equal(result.testid.squeezebackid, 'ca-app-pub-3940256099942544/9983381271');
|
|
24
|
-
assert.equal(result.android.bannerid, 'app-banner');
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
test('migration preserves explicit false, placement lists, custom IDs and newer schemas', () => {
|
|
28
|
-
const app = { VERSION: '2.0', config: { setCoarseLocationCollectionEnabled: false,
|
|
29
|
-
squeezebackEnabled: true, squeezebackPages: ['quizresult'], squeezebackRetryIntervalMs: 9000 },
|
|
30
|
-
android: { squeezebackid: 'app-live' }, testid: { squeezebackid: 'app-test' } };
|
|
31
|
-
const result = migrate({}, app);
|
|
32
|
-
assert.equal(result.VERSION, '2.0');
|
|
33
|
-
for (const [key, value] of Object.entries(app.config)) assert.deepEqual(result.config[key], value);
|
|
34
|
-
assert.equal(result.android.squeezebackid, 'app-live');
|
|
35
|
-
assert.equal(result.testid.squeezebackid, 'app-test');
|
|
36
|
-
assert.deepEqual(migrate({}, result), result);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
test('downloaded templates cannot opt apps into squeezeback or import publisher IDs', () => {
|
|
40
|
-
const template = { config: { squeezebackEnabled: true, squeezebackPages: ['home'],
|
|
41
|
-
setCoarseLocationCollectionEnabled: false }, android: { squeezebackid: 'foreign-live' },
|
|
42
|
-
testid: { squeezebackid: 'foreign-test' } };
|
|
43
|
-
const result = migrate(template);
|
|
44
|
-
assert.equal(result.config.squeezebackEnabled, false);
|
|
45
|
-
assert.deepEqual(result.config.squeezebackPages, []);
|
|
46
|
-
assert.equal(result.config.setCoarseLocationCollectionEnabled, true);
|
|
47
|
-
assert.equal(result.android.squeezebackid, '');
|
|
48
|
-
assert.equal(result.testid.squeezebackid, 'ca-app-pub-3940256099942544/9983381271');
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
test('legacy app settings are retained with current app settings taking priority', () => {
|
|
52
|
-
const result = migrate({}, { android: { squeezebackid: '' } }, {
|
|
53
|
-
android: { squeezebackid: 'old-live' }, config: { squeezebackEnabled: true, setCoarseLocationCollectionEnabled: false }
|
|
54
|
-
});
|
|
55
|
-
assert.equal(result.android.squeezebackid, '');
|
|
56
|
-
assert.equal(result.config.squeezebackEnabled, true);
|
|
57
|
-
assert.equal(result.config.setCoarseLocationCollectionEnabled, false);
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
for (const enabled of [undefined, false, true]) {
|
|
61
|
-
for (const installed of [null, '1.6.0', '1.6.1-beta', '1.7.0']) {
|
|
62
|
-
test(`native plugin: installed=${installed}, squeezebackEnabled=${enabled}`, () => {
|
|
63
|
-
const commands = [];
|
|
64
|
-
const start = script.indexOf('const syncAdmobNextgenPackage =');
|
|
65
|
-
const code = script.slice(start, script.indexOf('const downloadOptionalCodeplayFile', start));
|
|
66
|
-
vm.runInNewContext(code + '\nsyncAdmobNextgenPackage();', {
|
|
67
|
-
fs: { existsSync: () => true }, packageJsonPath: 'package.json',
|
|
68
|
-
isPackageAvailable: () => false, getInstalledVersion: () => installed,
|
|
69
|
-
getAdmobJsonPath: () => 'config.json', readJsonSafe: () => ({ config: { squeezebackEnabled: enabled } }),
|
|
70
|
-
compareVersionStrings: (a, b) => a.localeCompare(b, undefined, { numeric: true }),
|
|
71
|
-
runNpmCommand: command => commands.push(command), console: { log() {}, warn() {} }
|
|
72
|
-
});
|
|
73
|
-
const update = !installed || (enabled === true && installed === '1.6.0');
|
|
74
|
-
assert.deepEqual(commands, update
|
|
75
|
-
? [`npm install capacitor-admob-nextgen${enabled === true ? '@^1.6.1-beta' : ''}`] : []);
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
}
|
|
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
|
+
const script = fs.readFileSync(path.join(__dirname, '../files/buildCodeplay/codeplayBeforeBuild.js'), 'utf8');
|
|
7
|
+
const defaults = script.slice(script.indexOf('const ADMOB_NEXTGEN_DEFAULTS ='), script.indexOf('function getAdmobJsonPath()'));
|
|
8
|
+
const merge = script.slice(script.indexOf('const mergeObjects ='), script.indexOf('const syncAdmobNextgenPackage ='));
|
|
9
|
+
const context = vm.createContext({ compareVersionStrings: (a, b) => a.localeCompare(b, undefined, { numeric: true }) });
|
|
10
|
+
vm.runInContext(defaults + merge, context);
|
|
11
|
+
const migrate = (template = {}, app = {}, old = {}) => JSON.parse(JSON.stringify(vm.runInContext(
|
|
12
|
+
`buildNextgenAdmobConfigFromOldConfig(${JSON.stringify(template)},${JSON.stringify(app)},${JSON.stringify(old)})`, context)));
|
|
13
|
+
|
|
14
|
+
test('old app configs acquire the new properties and a dedicated test unit', () => {
|
|
15
|
+
const result = migrate({}, { VERSION: '1.8', android: { bannerid: 'app-banner' } });
|
|
16
|
+
assert.equal(result.VERSION, '1.9');
|
|
17
|
+
assert.equal(result.config.setCoarseLocationCollectionEnabled, true);
|
|
18
|
+
assert.equal(result.config.squeezebackEnabled, false);
|
|
19
|
+
assert.equal(result.config.squeezebackRetryIntervalMs, 5000);
|
|
20
|
+
assert.deepEqual(result.config.squeezebackPages, []);
|
|
21
|
+
assert.equal(result.android.squeezebackid, '');
|
|
22
|
+
assert.equal(result.ios.squeezebackid, '');
|
|
23
|
+
assert.equal(result.testid.squeezebackid, 'ca-app-pub-3940256099942544/9983381271');
|
|
24
|
+
assert.equal(result.android.bannerid, 'app-banner');
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test('migration preserves explicit false, placement lists, custom IDs and newer schemas', () => {
|
|
28
|
+
const app = { VERSION: '2.0', config: { setCoarseLocationCollectionEnabled: false,
|
|
29
|
+
squeezebackEnabled: true, squeezebackPages: ['quizresult'], squeezebackRetryIntervalMs: 9000 },
|
|
30
|
+
android: { squeezebackid: 'app-live' }, testid: { squeezebackid: 'app-test' } };
|
|
31
|
+
const result = migrate({}, app);
|
|
32
|
+
assert.equal(result.VERSION, '2.0');
|
|
33
|
+
for (const [key, value] of Object.entries(app.config)) assert.deepEqual(result.config[key], value);
|
|
34
|
+
assert.equal(result.android.squeezebackid, 'app-live');
|
|
35
|
+
assert.equal(result.testid.squeezebackid, 'app-test');
|
|
36
|
+
assert.deepEqual(migrate({}, result), result);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test('downloaded templates cannot opt apps into squeezeback or import publisher IDs', () => {
|
|
40
|
+
const template = { config: { squeezebackEnabled: true, squeezebackPages: ['home'],
|
|
41
|
+
setCoarseLocationCollectionEnabled: false }, android: { squeezebackid: 'foreign-live' },
|
|
42
|
+
testid: { squeezebackid: 'foreign-test' } };
|
|
43
|
+
const result = migrate(template);
|
|
44
|
+
assert.equal(result.config.squeezebackEnabled, false);
|
|
45
|
+
assert.deepEqual(result.config.squeezebackPages, []);
|
|
46
|
+
assert.equal(result.config.setCoarseLocationCollectionEnabled, true);
|
|
47
|
+
assert.equal(result.android.squeezebackid, '');
|
|
48
|
+
assert.equal(result.testid.squeezebackid, 'ca-app-pub-3940256099942544/9983381271');
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test('legacy app settings are retained with current app settings taking priority', () => {
|
|
52
|
+
const result = migrate({}, { android: { squeezebackid: '' } }, {
|
|
53
|
+
android: { squeezebackid: 'old-live' }, config: { squeezebackEnabled: true, setCoarseLocationCollectionEnabled: false }
|
|
54
|
+
});
|
|
55
|
+
assert.equal(result.android.squeezebackid, '');
|
|
56
|
+
assert.equal(result.config.squeezebackEnabled, true);
|
|
57
|
+
assert.equal(result.config.setCoarseLocationCollectionEnabled, false);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
for (const enabled of [undefined, false, true]) {
|
|
61
|
+
for (const installed of [null, '1.6.0', '1.6.1-beta', '1.7.0']) {
|
|
62
|
+
test(`native plugin: installed=${installed}, squeezebackEnabled=${enabled}`, () => {
|
|
63
|
+
const commands = [];
|
|
64
|
+
const start = script.indexOf('const syncAdmobNextgenPackage =');
|
|
65
|
+
const code = script.slice(start, script.indexOf('const downloadOptionalCodeplayFile', start));
|
|
66
|
+
vm.runInNewContext(code + '\nsyncAdmobNextgenPackage();', {
|
|
67
|
+
fs: { existsSync: () => true }, packageJsonPath: 'package.json',
|
|
68
|
+
isPackageAvailable: () => false, getInstalledVersion: () => installed,
|
|
69
|
+
getAdmobJsonPath: () => 'config.json', readJsonSafe: () => ({ config: { squeezebackEnabled: enabled } }),
|
|
70
|
+
compareVersionStrings: (a, b) => a.localeCompare(b, undefined, { numeric: true }),
|
|
71
|
+
runNpmCommand: command => commands.push(command), console: { log() {}, warn() {} }
|
|
72
|
+
});
|
|
73
|
+
const update = !installed || (enabled === true && installed === '1.6.0');
|
|
74
|
+
assert.deepEqual(commands, update
|
|
75
|
+
? [`npm install capacitor-admob-nextgen${enabled === true ? '@^1.6.1-beta' : ''}`] : []);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|