codeplay-common 4.11.38 → 4.11.40
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/README.md +1 -1
- package/RELEASE_NOTES.md +13 -13
- package/files/buildCodeplay/add-splash-screen.js +1 -1
- package/files/buildCodeplay/codeplayBeforeBuild.js +2 -2
- package/files/buildCodeplay/ensure-current-build.cjs +32 -4
- 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 -135
- package/files/buildCodeplay/huawei-privacy.css +22 -22
- package/files/buildCodeplay/ios-ad-consent.cjs +56 -56
- package/files/buildCodeplay/ios-emi-admob-modification.js +25 -25
- 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 +220 -220
- package/files/buildCodeplay/saf-mediastore-dependency.cjs +21 -21
- package/files/buildCodeplay/setSplashAnimation.js +2 -2
- package/files/buildCodeplay/setup-ruads.cjs +62 -62
- package/files/buildCodeplay/splash-setup.cjs +88 -88
- package/files/buildCodeplay/store-billing.cjs +43 -43
- package/files/buildCodeplay/tests/huawei-live-reload.test.cjs +60 -60
- package/files/buildCodeplay/tests/huawei-privacy.test.cjs +49 -49
- package/files/scripts-common/collect-startup-profile.js +134 -134
- package/files/scripts-common/generate-baseline-profile.js +218 -218
- package/files/take-screen-image.js +4552 -4414
- package/package.json +1 -1
- package/runtime/splash-ready.mjs +52 -52
- package/runtime/vk-ads/vk-ad-configuration.json +39 -39
- package/scripts/baseline-profile.test.cjs +189 -189
- package/scripts/ensure-current-build.test.cjs +128 -28
- package/scripts/ios-ad-consent.test.cjs +99 -99
- package/scripts/ruads-install.test.cjs +197 -197
- 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/vite-build-settings.test.cjs +93 -93
|
@@ -1,88 +1,88 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const crypto = require('crypto');
|
|
4
|
-
const runtimeImport = "import { hideSplashWhenReady } from 'codeplay-common/runtime/splash-ready.mjs';";
|
|
5
|
-
const knownReadyHash = '451fd2e0ca63712e0f771ee0ed03ae5bd3a379f0ca1e75e971cd7acee0802a2b';
|
|
6
|
-
|
|
7
|
-
function readSplashOptions(config) {
|
|
8
|
-
const options = config.plugins?.CodeplaySplashScreen || {};
|
|
9
|
-
const duration = options.exitAnimationDuration ?? 1000;
|
|
10
|
-
const timeout = options.readinessTimeout ?? 8000;
|
|
11
|
-
const imageSelector = options.readyImageSelector ?? '[data-splash-ready], .t-film-art img';
|
|
12
|
-
if (!Number.isInteger(duration) || duration < 0 || duration > 10000) throw new Error('CodeplaySplashScreen.exitAnimationDuration must be an integer from0 to10000.');
|
|
13
|
-
if (!Number.isInteger(timeout) || timeout < 1 || timeout > 60000) throw new Error('CodeplaySplashScreen.readinessTimeout must be an integer from1 to60000.');
|
|
14
|
-
if (typeof imageSelector !== 'string') throw new Error('CodeplaySplashScreen.readyImageSelector must be a string.');
|
|
15
|
-
if (options.migrateLegacyReadiness !== undefined && typeof options.migrateLegacyReadiness !== 'boolean') throw new Error('CodeplaySplashScreen.migrateLegacyReadiness must be boolean.');
|
|
16
|
-
return { duration, timeout, imageSelector, migrateLegacy: options.migrateLegacyReadiness === true };
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function migrateSplashTheme(content) {
|
|
20
|
-
// Repair only the known package default; preserve custom themes and styling.
|
|
21
|
-
return content.replace(/(<item\s+name=["']postSplashScreenTheme["']\s*>\s*)@style\/Theme\.AppCompat\.NoActionBar(\s*<\/item>)/g,
|
|
22
|
-
'$1@style/Theme.AppCompat.DayNight.NoActionBar$2');
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function migrateReadinessSource(source, options) {
|
|
26
|
-
if (!/\b(?:var|let|const)\s+capacitorApp\s*=/.test(source)) return { source, status: 'unsupported' };
|
|
27
|
-
const handler = / handleSplashscreen:\s*function\s*\(\)\s*\{([\s\S]*?)\r?\n \},/;
|
|
28
|
-
const match = source.match(handler);
|
|
29
|
-
if (!match) return { source, status: 'unsupported' };
|
|
30
|
-
const body = match[1].replace(/\s+/g, '');
|
|
31
|
-
const isReady = crypto.createHash('sha256').update(body).digest('hex') === knownReadyHash;
|
|
32
|
-
const isManaged = /^if\(!window\.Capacitor\)return;returnhideSplashWhenReady\(\{f7:capacitorApp\.f7,hide:\(\)=>SplashScreen\.hide\(\),imageSelector:"(?:\\.|[^"\\])*",timeout:\d+\}\);$/.test(body)
|
|
33
|
-
&& source.includes(runtimeImport);
|
|
34
|
-
const isLegacy = body === "if(!window.Capacitor)return;setTimeout(()=>{if(window.Capacitor.Plugins?.SplashScreen)window.Capacitor.Plugins.SplashScreen.hide();},2000);"
|
|
35
|
-
|| body === "if(!window.Capacitor)return;setTimeout(()=>{if(window.Capacitor.Plugins&&window.Capacitor.Plugins.SplashScreen){window.Capacitor.Plugins.SplashScreen.hide();}},2000);";
|
|
36
|
-
if (!isReady && !isManaged && !(isLegacy && options.migrateLegacy)) return { source, status: isLegacy ? 'opt-in-required' : 'custom-preserved' };
|
|
37
|
-
const newline = source.includes('\r\n') ? '\r\n' : '\n';
|
|
38
|
-
const method = [
|
|
39
|
-
' handleSplashscreen: function () {',
|
|
40
|
-
' if (!window.Capacitor) return;',
|
|
41
|
-
' return hideSplashWhenReady({',
|
|
42
|
-
' f7: capacitorApp.f7,',
|
|
43
|
-
' hide: () => SplashScreen.hide(),',
|
|
44
|
-
` imageSelector: ${JSON.stringify(options.imageSelector)},`,
|
|
45
|
-
` timeout: ${options.timeout}`, ' });', ' },'
|
|
46
|
-
].join(newline);
|
|
47
|
-
let updated = source.replace(handler, () => method);
|
|
48
|
-
if (!updated.includes(runtimeImport)) updated = runtimeImport + newline + updated;
|
|
49
|
-
if (!/import\s*\{[^}]*\bSplashScreen\b[^}]*\}\s*from\s*['"]@capacitor\/splash-screen['"]/.test(updated)) {
|
|
50
|
-
updated = "import { SplashScreen } from '@capacitor/splash-screen';" + newline + updated;
|
|
51
|
-
}
|
|
52
|
-
return { source: updated, status: 'managed' };
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function syncSplashSetup(projectRoot, { log = console.log } = {}) {
|
|
56
|
-
const configPath = path.join(projectRoot, 'capacitor.config.json');
|
|
57
|
-
if (!fs.existsSync(configPath)) return;
|
|
58
|
-
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
59
|
-
const options = readSplashOptions(config);
|
|
60
|
-
const theme = path.join(projectRoot, 'buildCodeplay/splashxml/codeplay_splashScreen.xml');
|
|
61
|
-
if (fs.existsSync(theme)) {
|
|
62
|
-
const content = fs.readFileSync(theme, 'utf8');
|
|
63
|
-
const updated = migrateSplashTheme(content);
|
|
64
|
-
if (updated !== content) { fs.writeFileSync(theme, updated); log('codeplay-common: repaired legacy splash DayNight theme template; Android sync applies it.'); }
|
|
65
|
-
}
|
|
66
|
-
const app = path.join(projectRoot, 'src/js/capacitor-app.js');
|
|
67
|
-
if (!fs.existsSync(app)) return;
|
|
68
|
-
const source = fs.readFileSync(app, 'utf8');
|
|
69
|
-
const migrated = migrateReadinessSource(source, options);
|
|
70
|
-
if (migrated.status === 'managed') {
|
|
71
|
-
if (source !== migrated.source) {
|
|
72
|
-
const launch = config.plugins?.SplashScreen;
|
|
73
|
-
if (launch?.launchAutoHide !== true || !(launch.launchShowDuration >= options.timeout)) {
|
|
74
|
-
log('codeplay-common: readiness migration skipped; set SplashScreen.launchAutoHide=true and launchShowDuration>=readinessTimeout for the native fallback.');
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
const dependency = JSON.parse(fs.readFileSync(path.join(projectRoot, 'package.json'), 'utf8'));
|
|
78
|
-
if (!dependency.dependencies?.['@capacitor/splash-screen'] && !dependency.devDependencies?.['@capacitor/splash-screen']) {
|
|
79
|
-
log('codeplay-common: readiness migration skipped; @capacitor/splash-screen must be installed.');
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
fs.writeFileSync(app, migrated.source);
|
|
83
|
-
log('codeplay-common: connected supported startup handler to shared splash readiness.');
|
|
84
|
-
}
|
|
85
|
-
} else log(`codeplay-common: splash readiness ${migrated.status}; app startup preserved. See shared splash setup in README.`);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
module.exports = { readSplashOptions, migrateSplashTheme, migrateReadinessSource, syncSplashSetup };
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const crypto = require('crypto');
|
|
4
|
+
const runtimeImport = "import { hideSplashWhenReady } from 'codeplay-common/runtime/splash-ready.mjs';";
|
|
5
|
+
const knownReadyHash = '451fd2e0ca63712e0f771ee0ed03ae5bd3a379f0ca1e75e971cd7acee0802a2b';
|
|
6
|
+
|
|
7
|
+
function readSplashOptions(config) {
|
|
8
|
+
const options = config.plugins?.CodeplaySplashScreen || {};
|
|
9
|
+
const duration = options.exitAnimationDuration ?? 1000;
|
|
10
|
+
const timeout = options.readinessTimeout ?? 8000;
|
|
11
|
+
const imageSelector = options.readyImageSelector ?? '[data-splash-ready], .t-film-art img';
|
|
12
|
+
if (!Number.isInteger(duration) || duration < 0 || duration > 10000) throw new Error('CodeplaySplashScreen.exitAnimationDuration must be an integer from0 to10000.');
|
|
13
|
+
if (!Number.isInteger(timeout) || timeout < 1 || timeout > 60000) throw new Error('CodeplaySplashScreen.readinessTimeout must be an integer from1 to60000.');
|
|
14
|
+
if (typeof imageSelector !== 'string') throw new Error('CodeplaySplashScreen.readyImageSelector must be a string.');
|
|
15
|
+
if (options.migrateLegacyReadiness !== undefined && typeof options.migrateLegacyReadiness !== 'boolean') throw new Error('CodeplaySplashScreen.migrateLegacyReadiness must be boolean.');
|
|
16
|
+
return { duration, timeout, imageSelector, migrateLegacy: options.migrateLegacyReadiness === true };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function migrateSplashTheme(content) {
|
|
20
|
+
// Repair only the known package default; preserve custom themes and styling.
|
|
21
|
+
return content.replace(/(<item\s+name=["']postSplashScreenTheme["']\s*>\s*)@style\/Theme\.AppCompat\.NoActionBar(\s*<\/item>)/g,
|
|
22
|
+
'$1@style/Theme.AppCompat.DayNight.NoActionBar$2');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function migrateReadinessSource(source, options) {
|
|
26
|
+
if (!/\b(?:var|let|const)\s+capacitorApp\s*=/.test(source)) return { source, status: 'unsupported' };
|
|
27
|
+
const handler = / handleSplashscreen:\s*function\s*\(\)\s*\{([\s\S]*?)\r?\n \},/;
|
|
28
|
+
const match = source.match(handler);
|
|
29
|
+
if (!match) return { source, status: 'unsupported' };
|
|
30
|
+
const body = match[1].replace(/\s+/g, '');
|
|
31
|
+
const isReady = crypto.createHash('sha256').update(body).digest('hex') === knownReadyHash;
|
|
32
|
+
const isManaged = /^if\(!window\.Capacitor\)return;returnhideSplashWhenReady\(\{f7:capacitorApp\.f7,hide:\(\)=>SplashScreen\.hide\(\),imageSelector:"(?:\\.|[^"\\])*",timeout:\d+\}\);$/.test(body)
|
|
33
|
+
&& source.includes(runtimeImport);
|
|
34
|
+
const isLegacy = body === "if(!window.Capacitor)return;setTimeout(()=>{if(window.Capacitor.Plugins?.SplashScreen)window.Capacitor.Plugins.SplashScreen.hide();},2000);"
|
|
35
|
+
|| body === "if(!window.Capacitor)return;setTimeout(()=>{if(window.Capacitor.Plugins&&window.Capacitor.Plugins.SplashScreen){window.Capacitor.Plugins.SplashScreen.hide();}},2000);";
|
|
36
|
+
if (!isReady && !isManaged && !(isLegacy && options.migrateLegacy)) return { source, status: isLegacy ? 'opt-in-required' : 'custom-preserved' };
|
|
37
|
+
const newline = source.includes('\r\n') ? '\r\n' : '\n';
|
|
38
|
+
const method = [
|
|
39
|
+
' handleSplashscreen: function () {',
|
|
40
|
+
' if (!window.Capacitor) return;',
|
|
41
|
+
' return hideSplashWhenReady({',
|
|
42
|
+
' f7: capacitorApp.f7,',
|
|
43
|
+
' hide: () => SplashScreen.hide(),',
|
|
44
|
+
` imageSelector: ${JSON.stringify(options.imageSelector)},`,
|
|
45
|
+
` timeout: ${options.timeout}`, ' });', ' },'
|
|
46
|
+
].join(newline);
|
|
47
|
+
let updated = source.replace(handler, () => method);
|
|
48
|
+
if (!updated.includes(runtimeImport)) updated = runtimeImport + newline + updated;
|
|
49
|
+
if (!/import\s*\{[^}]*\bSplashScreen\b[^}]*\}\s*from\s*['"]@capacitor\/splash-screen['"]/.test(updated)) {
|
|
50
|
+
updated = "import { SplashScreen } from '@capacitor/splash-screen';" + newline + updated;
|
|
51
|
+
}
|
|
52
|
+
return { source: updated, status: 'managed' };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function syncSplashSetup(projectRoot, { log = console.log } = {}) {
|
|
56
|
+
const configPath = path.join(projectRoot, 'capacitor.config.json');
|
|
57
|
+
if (!fs.existsSync(configPath)) return;
|
|
58
|
+
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
59
|
+
const options = readSplashOptions(config);
|
|
60
|
+
const theme = path.join(projectRoot, 'buildCodeplay/splashxml/codeplay_splashScreen.xml');
|
|
61
|
+
if (fs.existsSync(theme)) {
|
|
62
|
+
const content = fs.readFileSync(theme, 'utf8');
|
|
63
|
+
const updated = migrateSplashTheme(content);
|
|
64
|
+
if (updated !== content) { fs.writeFileSync(theme, updated); log('codeplay-common: repaired legacy splash DayNight theme template; Android sync applies it.'); }
|
|
65
|
+
}
|
|
66
|
+
const app = path.join(projectRoot, 'src/js/capacitor-app.js');
|
|
67
|
+
if (!fs.existsSync(app)) return;
|
|
68
|
+
const source = fs.readFileSync(app, 'utf8');
|
|
69
|
+
const migrated = migrateReadinessSource(source, options);
|
|
70
|
+
if (migrated.status === 'managed') {
|
|
71
|
+
if (source !== migrated.source) {
|
|
72
|
+
const launch = config.plugins?.SplashScreen;
|
|
73
|
+
if (launch?.launchAutoHide !== true || !(launch.launchShowDuration >= options.timeout)) {
|
|
74
|
+
log('codeplay-common: readiness migration skipped; set SplashScreen.launchAutoHide=true and launchShowDuration>=readinessTimeout for the native fallback.');
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const dependency = JSON.parse(fs.readFileSync(path.join(projectRoot, 'package.json'), 'utf8'));
|
|
78
|
+
if (!dependency.dependencies?.['@capacitor/splash-screen'] && !dependency.devDependencies?.['@capacitor/splash-screen']) {
|
|
79
|
+
log('codeplay-common: readiness migration skipped; @capacitor/splash-screen must be installed.');
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
fs.writeFileSync(app, migrated.source);
|
|
83
|
+
log('codeplay-common: connected supported startup handler to shared splash readiness.');
|
|
84
|
+
}
|
|
85
|
+
} else log(`codeplay-common: splash readiness ${migrated.status}; app startup preserved. See shared splash setup in README.`);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
module.exports = { readSplashOptions, migrateSplashTheme, migrateReadinessSource, syncSplashSetup };
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
|
|
4
|
-
const start = '// BEGIN CODEPLAY NON-GOOGLE STORE BILLING';
|
|
5
|
-
const end = '// END CODEPLAY NON-GOOGLE STORE BILLING';
|
|
6
|
-
const block = `${start}
|
|
7
|
-
configurations.configureEach {
|
|
8
|
-
exclude group: 'com.android.billingclient'
|
|
9
|
-
}
|
|
10
|
-
android.buildTypes.configureEach {
|
|
11
|
-
proguardFile file('../../buildCodeplay/non-google-billing.pro')
|
|
12
|
-
}
|
|
13
|
-
${end}`;
|
|
14
|
-
|
|
15
|
-
function syncStoreBillingPolicy(projectRoot, storeId, platform = 'android') {
|
|
16
|
-
if (platform !== 'android') return false;
|
|
17
|
-
const excluded = [4, 10].includes(Number(storeId));
|
|
18
|
-
const gradle = path.join(projectRoot, 'android/app/build.gradle');
|
|
19
|
-
if (!fs.existsSync(gradle)) return false;
|
|
20
|
-
const original = fs.readFileSync(gradle, 'utf8');
|
|
21
|
-
const newline = original.includes('\r\n') ? '\r\n' : '\n';
|
|
22
|
-
const clean = original.replace(new RegExp(`${start}[\\s\\S]*?${end}\\r?\\n?`, 'g'), '');
|
|
23
|
-
const updated = excluded
|
|
24
|
-
? `${clean.trimEnd()}${newline}${newline}${block.replaceAll('\n', newline)}${newline}`
|
|
25
|
-
: clean;
|
|
26
|
-
let changed = updated !== original;
|
|
27
|
-
if (changed) fs.writeFileSync(gradle, updated);
|
|
28
|
-
|
|
29
|
-
// The excluded library supplies its own permission. Also remove any explicit
|
|
30
|
-
// app declaration; other permissions and supported-store billing stay intact.
|
|
31
|
-
const manifest = path.join(projectRoot, 'android/app/src/main/AndroidManifest.xml');
|
|
32
|
-
if (excluded && fs.existsSync(manifest)) {
|
|
33
|
-
const current = fs.readFileSync(manifest, 'utf8');
|
|
34
|
-
const next = current.replace(/^[ \t]*<uses-permission\b(?=[^>]*\bandroid:name\s*=\s*(['"])com\.android\.vending\.BILLING\1)[^>]*\/\s*>[ \t]*(?:\r?\n)?/gm, '');
|
|
35
|
-
if (next !== current) {
|
|
36
|
-
fs.writeFileSync(manifest, next);
|
|
37
|
-
changed = true;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return changed;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
module.exports = { syncStoreBillingPolicy };
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
const start = '// BEGIN CODEPLAY NON-GOOGLE STORE BILLING';
|
|
5
|
+
const end = '// END CODEPLAY NON-GOOGLE STORE BILLING';
|
|
6
|
+
const block = `${start}
|
|
7
|
+
configurations.configureEach {
|
|
8
|
+
exclude group: 'com.android.billingclient'
|
|
9
|
+
}
|
|
10
|
+
android.buildTypes.configureEach {
|
|
11
|
+
proguardFile file('../../buildCodeplay/non-google-billing.pro')
|
|
12
|
+
}
|
|
13
|
+
${end}`;
|
|
14
|
+
|
|
15
|
+
function syncStoreBillingPolicy(projectRoot, storeId, platform = 'android') {
|
|
16
|
+
if (platform !== 'android') return false;
|
|
17
|
+
const excluded = [4, 10].includes(Number(storeId));
|
|
18
|
+
const gradle = path.join(projectRoot, 'android/app/build.gradle');
|
|
19
|
+
if (!fs.existsSync(gradle)) return false;
|
|
20
|
+
const original = fs.readFileSync(gradle, 'utf8');
|
|
21
|
+
const newline = original.includes('\r\n') ? '\r\n' : '\n';
|
|
22
|
+
const clean = original.replace(new RegExp(`${start}[\\s\\S]*?${end}\\r?\\n?`, 'g'), '');
|
|
23
|
+
const updated = excluded
|
|
24
|
+
? `${clean.trimEnd()}${newline}${newline}${block.replaceAll('\n', newline)}${newline}`
|
|
25
|
+
: clean;
|
|
26
|
+
let changed = updated !== original;
|
|
27
|
+
if (changed) fs.writeFileSync(gradle, updated);
|
|
28
|
+
|
|
29
|
+
// The excluded library supplies its own permission. Also remove any explicit
|
|
30
|
+
// app declaration; other permissions and supported-store billing stay intact.
|
|
31
|
+
const manifest = path.join(projectRoot, 'android/app/src/main/AndroidManifest.xml');
|
|
32
|
+
if (excluded && fs.existsSync(manifest)) {
|
|
33
|
+
const current = fs.readFileSync(manifest, 'utf8');
|
|
34
|
+
const next = current.replace(/^[ \t]*<uses-permission\b(?=[^>]*\bandroid:name\s*=\s*(['"])com\.android\.vending\.BILLING\1)[^>]*\/\s*>[ \t]*(?:\r?\n)?/gm, '');
|
|
35
|
+
if (next !== current) {
|
|
36
|
+
fs.writeFileSync(manifest, next);
|
|
37
|
+
changed = true;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return changed;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
module.exports = { syncStoreBillingPolicy };
|
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
const assert = require('node:assert/strict');
|
|
2
|
-
const fs = require('node:fs');
|
|
3
|
-
const path = require('node:path');
|
|
4
|
-
const { pathToFileURL } = require('node:url');
|
|
5
|
-
const { syncHuaweiPrivacy } = require('../huawei-privacy.cjs');
|
|
6
|
-
const { syncRuAdsSetup } = require('../setup-ruads.cjs');
|
|
7
|
-
|
|
8
|
-
async function main() {
|
|
9
|
-
const appRoot = path.resolve(process.argv[2] || '');
|
|
10
|
-
const { createServer } = await import(pathToFileURL(path.join(appRoot, 'node_modules/vite/dist/node/index.js')).href);
|
|
11
|
-
const tempRoot = path.join(appRoot, 'agent-temp');
|
|
12
|
-
fs.mkdirSync(tempRoot, { recursive: true });
|
|
13
|
-
const root = fs.mkdtempSync(path.join(tempRoot, 'huawei-live-reload-'));
|
|
14
|
-
const previous = process.cwd();
|
|
15
|
-
let server;
|
|
16
|
-
const write = (file, content) => {
|
|
17
|
-
const target = path.join(root, file);
|
|
18
|
-
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
19
|
-
fs.writeFileSync(target, content);
|
|
20
|
-
};
|
|
21
|
-
try {
|
|
22
|
-
write('package.json', '{"name":"huawei-fixture","type":"module"}');
|
|
23
|
-
write('capacitor.config.json', '{"appName":"Fixture","android":{"APP_UNIQUE_ID":5}}');
|
|
24
|
-
write('android/app/src/main/AndroidManifest.xml', '<manifest><application></application></manifest>');
|
|
25
|
-
write('src/index.html', '<html><body><script type="module" src="./js/app.js"></script></body></html>');
|
|
26
|
-
write('src/js/app.js', 'export const ready = true;');
|
|
27
|
-
write('buildCodeplay/huawei-privacy-entry.js', 'export function startHuaweiPrivacy() {}');
|
|
28
|
-
write('buildCodeplay/ruads.cjs', fs.readFileSync(path.join(__dirname, '../ruads.cjs'), 'utf8'));
|
|
29
|
-
write('vite.config.mjs', 'export default { resolve: { alias: {} } };');
|
|
30
|
-
syncHuaweiPrivacy(root, 4);
|
|
31
|
-
syncRuAdsSetup(root);
|
|
32
|
-
process.chdir(root);
|
|
33
|
-
server = await createServer({
|
|
34
|
-
configFile: path.join(root, 'vite.config.mjs'),
|
|
35
|
-
root: path.join(root, 'src'),
|
|
36
|
-
cacheDir: path.join(root, 'cache'),
|
|
37
|
-
optimizeDeps: { noDiscovery: true, include: [] },
|
|
38
|
-
server: { host: '127.0.0.1', port: 0, open: false },
|
|
39
|
-
});
|
|
40
|
-
await server.listen();
|
|
41
|
-
const origin = 'http://127.0.0.1:' + server.httpServer.address().port;
|
|
42
|
-
const response = await fetch(origin + '/buildCodeplay/huawei-privacy-generated.js');
|
|
43
|
-
assert.equal(response.status, 200);
|
|
44
|
-
const source = await response.text();
|
|
45
|
-
assert.match(source, /startHuaweiPrivacy/);
|
|
46
|
-
assert.doesNotMatch(source, /<html>/);
|
|
47
|
-
const helper = source.match(/from\s+["']([^"']*huawei-privacy-entry\.js[^"']*)["']/)?.[1];
|
|
48
|
-
assert.ok(helper);
|
|
49
|
-
const dependency = await fetch(new URL(helper, origin));
|
|
50
|
-
assert.equal(dependency.status, 200);
|
|
51
|
-
assert.match(await dependency.text(), /export function startHuaweiPrivacy/);
|
|
52
|
-
console.log('Huawei generated module and relative helper load through the package Vite mapping.');
|
|
53
|
-
} finally {
|
|
54
|
-
if (server) await server.close();
|
|
55
|
-
process.chdir(previous);
|
|
56
|
-
assert.equal(path.dirname(path.resolve(root)), path.resolve(tempRoot));
|
|
57
|
-
fs.rmSync(root, { recursive: true, force: true });
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
main().catch(error => { console.error(error); process.exitCode = 1; });
|
|
1
|
+
const assert = require('node:assert/strict');
|
|
2
|
+
const fs = require('node:fs');
|
|
3
|
+
const path = require('node:path');
|
|
4
|
+
const { pathToFileURL } = require('node:url');
|
|
5
|
+
const { syncHuaweiPrivacy } = require('../huawei-privacy.cjs');
|
|
6
|
+
const { syncRuAdsSetup } = require('../setup-ruads.cjs');
|
|
7
|
+
|
|
8
|
+
async function main() {
|
|
9
|
+
const appRoot = path.resolve(process.argv[2] || '');
|
|
10
|
+
const { createServer } = await import(pathToFileURL(path.join(appRoot, 'node_modules/vite/dist/node/index.js')).href);
|
|
11
|
+
const tempRoot = path.join(appRoot, 'agent-temp');
|
|
12
|
+
fs.mkdirSync(tempRoot, { recursive: true });
|
|
13
|
+
const root = fs.mkdtempSync(path.join(tempRoot, 'huawei-live-reload-'));
|
|
14
|
+
const previous = process.cwd();
|
|
15
|
+
let server;
|
|
16
|
+
const write = (file, content) => {
|
|
17
|
+
const target = path.join(root, file);
|
|
18
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
19
|
+
fs.writeFileSync(target, content);
|
|
20
|
+
};
|
|
21
|
+
try {
|
|
22
|
+
write('package.json', '{"name":"huawei-fixture","type":"module"}');
|
|
23
|
+
write('capacitor.config.json', '{"appName":"Fixture","android":{"APP_UNIQUE_ID":5}}');
|
|
24
|
+
write('android/app/src/main/AndroidManifest.xml', '<manifest><application></application></manifest>');
|
|
25
|
+
write('src/index.html', '<html><body><script type="module" src="./js/app.js"></script></body></html>');
|
|
26
|
+
write('src/js/app.js', 'export const ready = true;');
|
|
27
|
+
write('buildCodeplay/huawei-privacy-entry.js', 'export function startHuaweiPrivacy() {}');
|
|
28
|
+
write('buildCodeplay/ruads.cjs', fs.readFileSync(path.join(__dirname, '../ruads.cjs'), 'utf8'));
|
|
29
|
+
write('vite.config.mjs', 'export default { resolve: { alias: {} } };');
|
|
30
|
+
syncHuaweiPrivacy(root, 4);
|
|
31
|
+
syncRuAdsSetup(root);
|
|
32
|
+
process.chdir(root);
|
|
33
|
+
server = await createServer({
|
|
34
|
+
configFile: path.join(root, 'vite.config.mjs'),
|
|
35
|
+
root: path.join(root, 'src'),
|
|
36
|
+
cacheDir: path.join(root, 'cache'),
|
|
37
|
+
optimizeDeps: { noDiscovery: true, include: [] },
|
|
38
|
+
server: { host: '127.0.0.1', port: 0, open: false },
|
|
39
|
+
});
|
|
40
|
+
await server.listen();
|
|
41
|
+
const origin = 'http://127.0.0.1:' + server.httpServer.address().port;
|
|
42
|
+
const response = await fetch(origin + '/buildCodeplay/huawei-privacy-generated.js');
|
|
43
|
+
assert.equal(response.status, 200);
|
|
44
|
+
const source = await response.text();
|
|
45
|
+
assert.match(source, /startHuaweiPrivacy/);
|
|
46
|
+
assert.doesNotMatch(source, /<html>/);
|
|
47
|
+
const helper = source.match(/from\s+["']([^"']*huawei-privacy-entry\.js[^"']*)["']/)?.[1];
|
|
48
|
+
assert.ok(helper);
|
|
49
|
+
const dependency = await fetch(new URL(helper, origin));
|
|
50
|
+
assert.equal(dependency.status, 200);
|
|
51
|
+
assert.match(await dependency.text(), /export function startHuaweiPrivacy/);
|
|
52
|
+
console.log('Huawei generated module and relative helper load through the package Vite mapping.');
|
|
53
|
+
} finally {
|
|
54
|
+
if (server) await server.close();
|
|
55
|
+
process.chdir(previous);
|
|
56
|
+
assert.equal(path.dirname(path.resolve(root)), path.resolve(tempRoot));
|
|
57
|
+
fs.rmSync(root, { recursive: true, force: true });
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
main().catch(error => { console.error(error); process.exitCode = 1; });
|
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
const assert = require('node:assert/strict');
|
|
2
|
-
const fs = require('node:fs');
|
|
3
|
-
const os = require('node:os');
|
|
4
|
-
const path = require('node:path');
|
|
5
|
-
const { syncHuaweiPrivacy } = require('../huawei-privacy.cjs');
|
|
6
|
-
|
|
7
|
-
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'codeplay-huawei-privacy-'));
|
|
8
|
-
const indexPath = path.join(root, 'src/index.html');
|
|
9
|
-
const manifestPath = path.join(root, 'android/app/src/main/AndroidManifest.xml');
|
|
10
|
-
const appEntry = path.join(root, 'src/js/app.js');
|
|
11
|
-
const wrapperPath = path.join(root, 'buildCodeplay/huawei-privacy-generated.js');
|
|
12
|
-
|
|
13
|
-
try {
|
|
14
|
-
for (const file of [indexPath, manifestPath, appEntry, wrapperPath]) fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
15
|
-
const index = '<html><body><div id="app"></div><script type="module" src="./js/app.js"></script></body></html>\n';
|
|
16
|
-
const manifest = '<manifest><application><activity android:name=".MainActivity" /></application></manifest>\n';
|
|
17
|
-
fs.writeFileSync(indexPath, index);
|
|
18
|
-
fs.writeFileSync(manifestPath, manifest);
|
|
19
|
-
fs.writeFileSync(appEntry, 'document.body.dataset.ready = "yes";\n');
|
|
20
|
-
fs.writeFileSync(path.join(root, 'capacitor.config.json'), JSON.stringify({ appName: 'Test App', android: { APP_UNIQUE_ID: 2 } }));
|
|
21
|
-
|
|
22
|
-
syncHuaweiPrivacy(root, 1);
|
|
23
|
-
assert.equal(fs.readFileSync(indexPath, 'utf8'), index);
|
|
24
|
-
assert.equal(fs.readFileSync(manifestPath, 'utf8'), manifest);
|
|
25
|
-
|
|
26
|
-
const existing = '<manifest><application>\n <meta-data android:name="firebase_analytics_collection_enabled" android:value="true" />\n <activity android:name=".MainActivity" /></application></manifest>\n';
|
|
27
|
-
fs.writeFileSync(manifestPath, existing);
|
|
28
|
-
syncHuaweiPrivacy(root, 4);
|
|
29
|
-
assert.match(fs.readFileSync(manifestPath, 'utf8'), /firebase_analytics_collection_enabled" android:value="false"/);
|
|
30
|
-
syncHuaweiPrivacy(root, 1);
|
|
31
|
-
assert.equal(fs.readFileSync(manifestPath, 'utf8'), existing);
|
|
32
|
-
fs.writeFileSync(manifestPath, manifest);
|
|
33
|
-
|
|
34
|
-
syncHuaweiPrivacy(root, 4);
|
|
35
|
-
const huaweiIndex = fs.readFileSync(indexPath, 'utf8');
|
|
36
|
-
const huaweiManifest = fs.readFileSync(manifestPath, 'utf8');
|
|
37
|
-
assert.match(huaweiIndex, /huawei-privacy-generated\.js/);
|
|
38
|
-
assert.match(huaweiManifest, /firebase_analytics_collection_enabled" android:value="false"/);
|
|
39
|
-
assert.match(fs.readFileSync(wrapperPath, 'utf8'), /import\("\.\.\/src\/js\/app\.js"\)/);
|
|
40
|
-
syncHuaweiPrivacy(root, 4);
|
|
41
|
-
assert.equal(fs.readFileSync(indexPath, 'utf8'), huaweiIndex);
|
|
42
|
-
assert.equal(fs.readFileSync(manifestPath, 'utf8'), huaweiManifest);
|
|
43
|
-
|
|
44
|
-
syncHuaweiPrivacy(root, 1);
|
|
45
|
-
assert.equal(fs.readFileSync(indexPath, 'utf8'), index);
|
|
46
|
-
assert.equal(fs.readFileSync(manifestPath, 'utf8'), manifest);
|
|
47
|
-
} finally {
|
|
48
|
-
fs.rmSync(root, { recursive: true, force: true });
|
|
49
|
-
}
|
|
1
|
+
const assert = require('node:assert/strict');
|
|
2
|
+
const fs = require('node:fs');
|
|
3
|
+
const os = require('node:os');
|
|
4
|
+
const path = require('node:path');
|
|
5
|
+
const { syncHuaweiPrivacy } = require('../huawei-privacy.cjs');
|
|
6
|
+
|
|
7
|
+
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'codeplay-huawei-privacy-'));
|
|
8
|
+
const indexPath = path.join(root, 'src/index.html');
|
|
9
|
+
const manifestPath = path.join(root, 'android/app/src/main/AndroidManifest.xml');
|
|
10
|
+
const appEntry = path.join(root, 'src/js/app.js');
|
|
11
|
+
const wrapperPath = path.join(root, 'buildCodeplay/huawei-privacy-generated.js');
|
|
12
|
+
|
|
13
|
+
try {
|
|
14
|
+
for (const file of [indexPath, manifestPath, appEntry, wrapperPath]) fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
15
|
+
const index = '<html><body><div id="app"></div><script type="module" src="./js/app.js"></script></body></html>\n';
|
|
16
|
+
const manifest = '<manifest><application><activity android:name=".MainActivity" /></application></manifest>\n';
|
|
17
|
+
fs.writeFileSync(indexPath, index);
|
|
18
|
+
fs.writeFileSync(manifestPath, manifest);
|
|
19
|
+
fs.writeFileSync(appEntry, 'document.body.dataset.ready = "yes";\n');
|
|
20
|
+
fs.writeFileSync(path.join(root, 'capacitor.config.json'), JSON.stringify({ appName: 'Test App', android: { APP_UNIQUE_ID: 2 } }));
|
|
21
|
+
|
|
22
|
+
syncHuaweiPrivacy(root, 1);
|
|
23
|
+
assert.equal(fs.readFileSync(indexPath, 'utf8'), index);
|
|
24
|
+
assert.equal(fs.readFileSync(manifestPath, 'utf8'), manifest);
|
|
25
|
+
|
|
26
|
+
const existing = '<manifest><application>\n <meta-data android:name="firebase_analytics_collection_enabled" android:value="true" />\n <activity android:name=".MainActivity" /></application></manifest>\n';
|
|
27
|
+
fs.writeFileSync(manifestPath, existing);
|
|
28
|
+
syncHuaweiPrivacy(root, 4);
|
|
29
|
+
assert.match(fs.readFileSync(manifestPath, 'utf8'), /firebase_analytics_collection_enabled" android:value="false"/);
|
|
30
|
+
syncHuaweiPrivacy(root, 1);
|
|
31
|
+
assert.equal(fs.readFileSync(manifestPath, 'utf8'), existing);
|
|
32
|
+
fs.writeFileSync(manifestPath, manifest);
|
|
33
|
+
|
|
34
|
+
syncHuaweiPrivacy(root, 4);
|
|
35
|
+
const huaweiIndex = fs.readFileSync(indexPath, 'utf8');
|
|
36
|
+
const huaweiManifest = fs.readFileSync(manifestPath, 'utf8');
|
|
37
|
+
assert.match(huaweiIndex, /huawei-privacy-generated\.js/);
|
|
38
|
+
assert.match(huaweiManifest, /firebase_analytics_collection_enabled" android:value="false"/);
|
|
39
|
+
assert.match(fs.readFileSync(wrapperPath, 'utf8'), /import\("\.\.\/src\/js\/app\.js"\)/);
|
|
40
|
+
syncHuaweiPrivacy(root, 4);
|
|
41
|
+
assert.equal(fs.readFileSync(indexPath, 'utf8'), huaweiIndex);
|
|
42
|
+
assert.equal(fs.readFileSync(manifestPath, 'utf8'), huaweiManifest);
|
|
43
|
+
|
|
44
|
+
syncHuaweiPrivacy(root, 1);
|
|
45
|
+
assert.equal(fs.readFileSync(indexPath, 'utf8'), index);
|
|
46
|
+
assert.equal(fs.readFileSync(manifestPath, 'utf8'), manifest);
|
|
47
|
+
} finally {
|
|
48
|
+
fs.rmSync(root, { recursive: true, force: true });
|
|
49
|
+
}
|