codeplay-common 4.11.21 → 4.11.23
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 +84 -1
- package/files/buildCodeplay/codeplayBeforeBuild.js +68 -30
- package/files/buildCodeplay/disabled-ads.mjs +45 -0
- package/files/buildCodeplay/iap-alias.cjs +108 -0
- package/files/buildCodeplay/migrate-system-bars.cjs +115 -0
- package/files/buildCodeplay/non-google-billing.pro +3 -0
- package/files/buildCodeplay/project-scripts.cjs +1 -1
- package/files/buildCodeplay/release-sync.config.json +4 -4
- package/files/buildCodeplay/ruads.cjs +111 -0
- package/files/buildCodeplay/setup-ruads.cjs +49 -0
- package/files/buildCodeplay/store-billing.cjs +43 -0
- package/files/buildCodeplay/versions.json +1 -0
- package/files/finalrelease +32 -10
- package/package.json +28 -28
- package/runtime/vk-ads/vk-ad-configuration.json +39 -0
- package/scripts/iap-alias.test.cjs +78 -0
- package/scripts/ruads-install.test.cjs +162 -0
- package/scripts/sync-files.js +6 -1
- package/scripts/system-bars.test.cjs +77 -0
- package/scripts/vite-build-settings.test.cjs +92 -0
package/README.md
CHANGED
|
@@ -1,4 +1,87 @@
|
|
|
1
|
-
# codeplay-common
|
|
1
|
+
# codeplay-common
|
|
2
|
+
|
|
3
|
+
## VK / RuStore builds (4.11.23)
|
|
4
|
+
|
|
5
|
+
Before-build 7.8 preserves the original Vite build settings when adding tree-shaking
|
|
6
|
+
inside the generated store wrapper. It also repairs the exact treeshake-only build
|
|
7
|
+
override created by the earlier migration; custom wrapper build settings are retained.
|
|
8
|
+
|
|
9
|
+
IAP imports use `@iap/<module>.js`. Installation configures the Vite alias; before-build
|
|
10
|
+
automatically migrates versioned IAP import paths without confirmation, after module
|
|
11
|
+
downloads and generators. Static/dynamic imports, re-exports and require calls are
|
|
12
|
+
covered. Comments, plain strings and Framework7 templates are preserved. Vite selects
|
|
13
|
+
the newest installed IAP folder containing IAP-state.js for all callers, so the existing
|
|
14
|
+
VK controller can use IAP 4.8 without a hardcoded 4.9 dependency. Missing imported
|
|
15
|
+
modules stop migration before source changes. No new IAP package is created or downloaded
|
|
16
|
+
by this alias helper; the existing server updater still owns version updates.
|
|
17
|
+
Protected AdMob controllers are excluded from source migration. A Vite resolver
|
|
18
|
+
maps their existing versioned IAP imports to the same installed folder without
|
|
19
|
+
editing or increasing the AdMob version. Existing local AdMob versions are retained.
|
|
20
|
+
|
|
21
|
+
Publish `capacitor-codeplay-rustore-ads` **0.1.1 first**, then this package **4.11.23**.
|
|
22
|
+
The new build preparation upgrades the old VK 0.1.0 banner implementation when
|
|
23
|
+
selected, installs only the selected ad provider, removes Google Billing for
|
|
24
|
+
Android stores 4/10, adds store 10 commands, and configures Vite's store ID and
|
|
25
|
+
provider alias for build and live reload. RuStore release sync sends the store
|
|
26
|
+
name for lookup by the updated Codeplay server. Amazon messages are store-scoped.
|
|
27
|
+
|
|
28
|
+
Each consuming app must use Capacitor 8, the shared `@admob` interface and a
|
|
29
|
+
current `Ads/IAP-x.x/IAP-state.js` integration. Older direct AdMob imports or IAP
|
|
30
|
+
integrations require updating first; this is not a universal migration of old apps.
|
|
31
|
+
Opt in through the app's `capacitor.config.json`:
|
|
32
|
+
|
|
33
|
+
```json
|
|
34
|
+
"RuAds": {
|
|
35
|
+
"VK_ADS_ENABLED": true,
|
|
36
|
+
"STORE_IDS": [4, 10]
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Place this section under `plugins`. Copy the first versioned controller folder
|
|
41
|
+
manually to `src/js/Ads/vk-ads-<version>/vk-ads.js`. This package never creates or
|
|
42
|
+
ships a VK controller. Selecting VK without a complete controller reports an error.
|
|
43
|
+
The resolver selects the highest complete installed numeric folder version.
|
|
44
|
+
Installing/updating this package or running before-build creates only a missing
|
|
45
|
+
`src/js/Ads/vk-ad-configuration.json`. Existing configuration is preserved.
|
|
46
|
+
Fill the app's own HuaweiStore/RuStore publisher IDs; shipped defaults are zero.
|
|
47
|
+
Set `config.isTesting=true` for official demo slots. Finalrelease warns and saves
|
|
48
|
+
it as false before a VK release. Configuration stays outside the versioned folder
|
|
49
|
+
so controller updates preserve each app's IDs.
|
|
50
|
+
|
|
51
|
+
The existing folder updater handles subsequent VK versions. Add this key to the
|
|
52
|
+
server's `https://htmlcodeplay.com/code-play-plugin/versions.json`:
|
|
53
|
+
|
|
54
|
+
```json
|
|
55
|
+
"vk-ads": "1.0"
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Upload `vk-ads-1.0.zip` beside that manifest, with `vk-ads.js` directly at the ZIP
|
|
59
|
+
root, following the existing folder-plugin ZIP format. For the next release,
|
|
60
|
+
upload the new ZIP and raise only the server entry, for example to `"1.1"`.
|
|
61
|
+
Before-build downloads higher advertised versions for existing VK installations,
|
|
62
|
+
updates references using the shared updater, and preserves the app configuration.
|
|
63
|
+
No codeplay-common path/version change is needed. Server deployment is manual.
|
|
64
|
+
|
|
65
|
+
Missing RuAds settings preserve AdMob selection. iOS store 6 keeps AdMob; the VK
|
|
66
|
+
plugin has a separate iOS API but this app adapter enables VK only on Android.
|
|
67
|
+
App-open/native/PiP formats remain disabled for VK. Native package changes need
|
|
68
|
+
a rebuilt install; changing live-reload JavaScript alone cannot replace plugins.
|
|
69
|
+
Explicitly disabled providers use an SDK-free controller, preserve task continuations
|
|
70
|
+
and never grant ad rewards. They do not require the VK adapter or IAP imports.
|
|
71
|
+
|
|
72
|
+
Release credentials are not distributed. Existing consumer release-sync config
|
|
73
|
+
is preserved; new consumers should set `CODEPLAY_RELEASE_SYNC_TOKEN` securely.
|
|
74
|
+
Do not copy publisher IDs or credentials from another app. VK creates app/slot
|
|
75
|
+
names using `<uniqueid>. <app name>`. Real ad serving requires separate publisher
|
|
76
|
+
setup and is not guaranteed by successful SDK integration or demo ads.
|
|
77
|
+
|
|
78
|
+
## Android system bars (4.11.22)
|
|
79
|
+
|
|
80
|
+
Installation and before-build migrate installed `capacitor-codeplay-system-bars` 1.0.1 to avoid calling `Window.setNavigationBarColor` on Android 15+. Existing inset protection views, keyboard handling, icon appearance and older Android compatibility remain intact. Missing plugins are skipped; unexpected native source requires review. Before-build removes `@capacitor/status-bar` only when parsed app sources confirm modern `SystemBars` usage without legacy references. Apps with active legacy calls or unparseable source retain the dependency and report why. The existing app parser is reused; no dependency is added. Run normal Capacitor sync after dependency cleanup. Native changes require a rebuilt install; older Android compatibility code can still trigger Play static warnings.
|
|
81
|
+
|
|
82
|
+
Dependency cleanup also runs `npx --no-install cap update android` when an Android platform exists and removes the standard stale iOS Podfile declaration. It does not build or install an APK. Run normal iOS sync on the supported build system before the next iOS build.
|
|
83
|
+
|
|
84
|
+
This source update is not an npm publication. Existing apps receive future releases through their normal package update process.
|
|
2
85
|
|
|
3
86
|
## Optional IAP configuration (4.11.21)
|
|
4
87
|
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
// Version 7.8: preserve original Vite build settings through the generated store wrapper.
|
|
2
|
+
// Version 7.7: migrate versioned IAP imports to the dynamic @iap Vite alias without prompting.
|
|
3
|
+
// Version 7.6: resolve VK folder versions dynamically and update through the shared server manifest.
|
|
4
|
+
// Version 7.5: exclude transitive Google billing from Huawei and RuStore builds.
|
|
5
|
+
// Version 7.4: install only the current store's advertising provider before building.
|
|
6
|
+
// Version 7.3: select RuAds for Huawei/RuStore and isolate native advertising providers.
|
|
7
|
+
// Version 7.2: migrate Android 15 navigation-bar colors and remove unused legacy StatusBar plugins.
|
|
1
8
|
// Version 7.1: require confirmation before continuing with local versions when the server check fails.
|
|
2
9
|
// Version 7.0: prepare shared splash readiness and migrate the legacy splash theme.
|
|
3
10
|
// Version 6.9: preserve configured notification icons during Android resource shrinking.
|
|
@@ -15,6 +22,7 @@ try {
|
|
|
15
22
|
|
|
16
23
|
const fs = require('fs');
|
|
17
24
|
const path = require('path');
|
|
25
|
+
const ruAdsBuild = require('./ruads.cjs');
|
|
18
26
|
const plist = require('plist');
|
|
19
27
|
|
|
20
28
|
// Edit only build.rollupOptions.treeshake in the exported Vite config.
|
|
@@ -122,7 +130,32 @@ const migrateViteTreeShaking = (content) => {
|
|
|
122
130
|
if (exported >= 0) exported += 4;
|
|
123
131
|
}
|
|
124
132
|
if (exported < 0) throw new Error('No supported Vite config export found; file preserved.');
|
|
125
|
-
const
|
|
133
|
+
const exportedConfig = findConfig(exported);
|
|
134
|
+
// setup-ruads wraps the consumer configuration and spreads it into a new
|
|
135
|
+
// returned object. Edit the original declaration so build options remain
|
|
136
|
+
// inherited instead of adding a replacement build object to that wrapper.
|
|
137
|
+
const original = tokens.findIndex((token, i) => token.value === 'const'
|
|
138
|
+
&& value(i + 1) === 'codeplayOriginalViteConfig' && value(i + 2) === '=');
|
|
139
|
+
const config = original >= 0 ? findConfig(original + 3) : exportedConfig;
|
|
140
|
+
if (original >= 0 && config !== exportedConfig) {
|
|
141
|
+
// Repair only the exact treeshake-only override emitted by the old migration.
|
|
142
|
+
// Preserve any other build customizations made to the generated wrapper.
|
|
143
|
+
const wrapperBuild = properties(exportedConfig).find(property => property.name === 'build');
|
|
144
|
+
if (wrapperBuild && value(wrapperBuild.first) === '{' && pairs.get(wrapperBuild.first) === wrapperBuild.end - 1) {
|
|
145
|
+
const buildProperties = properties(wrapperBuild.first);
|
|
146
|
+
const rollup = buildProperties[0];
|
|
147
|
+
if (buildProperties.length === 1 && rollup.name === 'rollupOptions' && value(rollup.first) === '{'
|
|
148
|
+
&& pairs.get(rollup.first) === rollup.end - 1) {
|
|
149
|
+
const options = properties(rollup.first);
|
|
150
|
+
const treeshake = options[0];
|
|
151
|
+
if (options.length === 1 && treeshake.name === 'treeshake'
|
|
152
|
+
&& value(treeshake.first) === 'true' && treeshake.end === treeshake.first + 1) {
|
|
153
|
+
edits.push({ start: tokens[wrapperBuild.start].start,
|
|
154
|
+
end: wrapperBuild.comma ? tokens[wrapperBuild.end].end : tokens[wrapperBuild.end - 1].end, text: '' });
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
126
159
|
const build = properties(config).filter(property => property.name === 'build').at(-1);
|
|
127
160
|
if (!build) append(config, 'build: { rollupOptions: { treeshake: true } }');
|
|
128
161
|
else {
|
|
@@ -158,7 +191,7 @@ const migrateIapStartup = (content, bootstrapImport) => {
|
|
|
158
191
|
let next = content;
|
|
159
192
|
const bootstrapPattern = /import\s*\{\s*initIAP\s*\}\s*from\s*['"][^'"]*\/IAP-bootstrap\.js['"]\s*;?/;
|
|
160
193
|
if (!bootstrapPattern.test(next)) {
|
|
161
|
-
next = next.replace(/import\s*\{([^}]*)\}\s*from\s*(['"])([^'"]*\/IAP-\d+(?:\.\d+)
|
|
194
|
+
next = next.replace(/import\s*\{([^}]*)\}\s*from\s*(['"])((?:[^'"]*\/IAP-\d+(?:\.\d+)*\/|@iap\/)IAP-check-And-LoadAd\.js)\2\s*;?/g,
|
|
162
195
|
(match, names, quote, source) => {
|
|
163
196
|
const imports = names.split(',').map(name => name.trim()).filter(Boolean);
|
|
164
197
|
if (!imports.includes('initIAP')) return match;
|
|
@@ -1698,6 +1731,7 @@ function getAdMobConfig() {
|
|
|
1698
1731
|
}
|
|
1699
1732
|
|
|
1700
1733
|
const isEnabled =
|
|
1734
|
+
ruAdsBuild.getAdProvider(capacitorConfig, process.env.VITE_STORE_ID, buildPlatform) === 'admob' &&
|
|
1701
1735
|
nextGenAdmobConfig.enabled !== false &&
|
|
1702
1736
|
legacyAdmobConfig.ADMOB_ENABLED !== false;
|
|
1703
1737
|
|
|
@@ -2491,6 +2525,7 @@ if (pluginDef.isFolder) {
|
|
|
2491
2525
|
fs.mkdirSync(stagingRoot, { recursive: true });
|
|
2492
2526
|
const staging = fs.mkdtempSync(path.join(stagingRoot, 'package-'));
|
|
2493
2527
|
await downloadAndExtractZip(url, staging);
|
|
2528
|
+
if (baseName === 'vk-ads' && (!fs.existsSync(path.join(staging, 'vk-ads.js')) || !fs.statSync(path.join(staging, 'vk-ads.js')).isFile() || fs.statSync(path.join(staging, 'vk-ads.js')).size === 0)) throw new Error('Invalid VK archive: vk-ads.js is missing or empty; existing sources preserved.');
|
|
2494
2529
|
if (baseName === 'IAP' && ['IAP-check-And-LoadAd.js', 'IAP-bootstrap.js', 'IAP-state.js', 'IAP-store.js'].some(name => !fs.existsSync(path.join(staging, name)))) throw new Error('Invalid IAP archive');
|
|
2495
2530
|
if (fs.existsSync(newPath)) throw new Error('Replacement folder already exists; existing sources preserved.');
|
|
2496
2531
|
fs.renameSync(staging, newPath);
|
|
@@ -2689,12 +2724,16 @@ function checkPlugins() {
|
|
|
2689
2724
|
|
|
2690
2725
|
for (const dir of subDirs) {
|
|
2691
2726
|
const relativePath = path.relative(searchRoot, dir).replace(/\\/g, '/');
|
|
2727
|
+
if (plugin.name === 'vk-ads') {
|
|
2728
|
+
const latestVk = ruAdsBuild.findLatestVkController(process.cwd());
|
|
2729
|
+
if (latestVk && path.basename(path.dirname(latestVk)) !== relativePath) continue;
|
|
2730
|
+
}
|
|
2692
2731
|
const match = plugin.pattern.exec(relativePath);
|
|
2693
2732
|
|
|
2694
2733
|
if (match) {
|
|
2695
2734
|
const currentVersion = match[1];
|
|
2696
2735
|
|
|
2697
|
-
if (compareVersions(currentVersion, plugin.minVersion) < 0) {
|
|
2736
|
+
if ((plugin.name === 'vk-ads' ? compareVersionStrings(currentVersion, plugin.minVersion) : compareVersions(currentVersion, plugin.minVersion)) < 0) {
|
|
2698
2737
|
outdatedPlugins.push({
|
|
2699
2738
|
name: relativePath,
|
|
2700
2739
|
currentVersion,
|
|
@@ -3130,28 +3169,7 @@ const syncViteTreeShaking = () => {
|
|
|
3130
3169
|
}
|
|
3131
3170
|
};
|
|
3132
3171
|
|
|
3133
|
-
const getLatestIapDir = () =>
|
|
3134
|
-
const adsDir = path.join(process.cwd(), "src", "js", "Ads");
|
|
3135
|
-
|
|
3136
|
-
if (!fs.existsSync(adsDir)) return null;
|
|
3137
|
-
|
|
3138
|
-
const iapDirs = fs.readdirSync(adsDir, { withFileTypes: true })
|
|
3139
|
-
.filter(entry => entry.isDirectory() && /^IAP-\d+(\.\d+)*$/.test(entry.name))
|
|
3140
|
-
.map(entry => entry.name)
|
|
3141
|
-
.sort((a, b) => {
|
|
3142
|
-
const versionA = a.match(/(\d+(?:\.\d+)*)/)[1].split(".").map(Number);
|
|
3143
|
-
const versionB = b.match(/(\d+(?:\.\d+)*)/)[1].split(".").map(Number);
|
|
3144
|
-
|
|
3145
|
-
for (let i = 0; i < Math.max(versionA.length, versionB.length); i++) {
|
|
3146
|
-
const diff = (versionB[i] || 0) - (versionA[i] || 0);
|
|
3147
|
-
if (diff !== 0) return diff;
|
|
3148
|
-
}
|
|
3149
|
-
|
|
3150
|
-
return 0;
|
|
3151
|
-
});
|
|
3152
|
-
|
|
3153
|
-
return iapDirs.length > 0 ? path.join(adsDir, iapDirs[0]) : null;
|
|
3154
|
-
};
|
|
3172
|
+
const getLatestIapDir = () => require('./iap-alias.cjs').findLatestIapDirectory(process.cwd());
|
|
3155
3173
|
|
|
3156
3174
|
const getAnalyticsConfig = () => {
|
|
3157
3175
|
const config = fs.existsSync(configPath)
|
|
@@ -3534,6 +3552,8 @@ const ensureAdmobNextgenFiles = async () => {
|
|
|
3534
3552
|
};
|
|
3535
3553
|
|
|
3536
3554
|
const syncAdmobNextgenMigration = async () => {
|
|
3555
|
+
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
3556
|
+
if (ruAdsBuild.getAdProvider(config, process.env.VITE_STORE_ID, buildPlatform) !== 'admob') return;
|
|
3537
3557
|
syncAdmobNextgenPackage();
|
|
3538
3558
|
await ensureAdmobNextgenFiles();
|
|
3539
3559
|
syncAdmobAliasInViteConfig();
|
|
@@ -4073,9 +4093,11 @@ const syncAmazonFireWebViewDependency = (enabled) => {
|
|
|
4073
4093
|
fs.writeFileSync(androidAppBuildGradlePath, nextContent, "utf8");
|
|
4074
4094
|
}
|
|
4075
4095
|
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
|
|
4096
|
+
if (getCurrentStoreId() === 7) {
|
|
4097
|
+
console.log(enabled
|
|
4098
|
+
? "✅ Amazon Fire WebView compatibility dependency enabled for Store ID 7."
|
|
4099
|
+
: "ℹ️ Amazon Fire WebView compatibility dependency disabled for this store.");
|
|
4100
|
+
}
|
|
4079
4101
|
};
|
|
4080
4102
|
|
|
4081
4103
|
function syncAndroidAdIdPermission() {
|
|
@@ -4190,7 +4212,8 @@ const syncRevenueCatIapSetup = () => {
|
|
|
4190
4212
|
}
|
|
4191
4213
|
|
|
4192
4214
|
if (packageChanged) {
|
|
4193
|
-
|
|
4215
|
+
ruAdsBuild.withNativeAdProvider(process.cwd(), getCurrentStoreId(), buildPlatform,
|
|
4216
|
+
() => runNpmCommand(`npx cap sync ${buildPlatform}`));
|
|
4194
4217
|
}
|
|
4195
4218
|
};
|
|
4196
4219
|
|
|
@@ -4697,7 +4720,8 @@ async function main() {
|
|
|
4697
4720
|
buildPackage.scripts = buildScripts;
|
|
4698
4721
|
fs.writeFileSync(packageJsonPath, JSON.stringify(buildPackage, null, 2) + '\n');
|
|
4699
4722
|
}
|
|
4700
|
-
require('./splash-setup.cjs').syncSplashSetup(process.cwd());
|
|
4723
|
+
require('./splash-setup.cjs').syncSplashSetup(process.cwd());
|
|
4724
|
+
require('./setup-ruads.cjs').syncRuAdsSetup(process.cwd());
|
|
4701
4725
|
validateThemeFolderLocation();
|
|
4702
4726
|
validateAndRestoreSignDetails();
|
|
4703
4727
|
ensureMandatoryCapacitorPlugins();
|
|
@@ -4705,21 +4729,35 @@ async function main() {
|
|
|
4705
4729
|
await loadPluginVersions(); // 🔥 NEW
|
|
4706
4730
|
await syncAgentInstructions();
|
|
4707
4731
|
if (!skipOnlineVersionChecks) await checkPlugins();
|
|
4732
|
+
// Validate only the selected provider after the shared folder updater finishes.
|
|
4733
|
+
ruAdsBuild.controllerPath(JSON.parse(fs.readFileSync(path.join(process.cwd(), 'capacitor.config.json'), 'utf8')),
|
|
4734
|
+
getCurrentStoreId(), buildPlatform, null);
|
|
4708
4735
|
// Downloads may add a newer helper or source files containing legacy imports.
|
|
4709
4736
|
await saveToGalleryAndSaveFileCheck_iOS();
|
|
4710
4737
|
|
|
4738
|
+
const adPackagesChanged = ruAdsBuild.syncAdProviderPackages(process.cwd(), runNpmCommand);
|
|
4711
4739
|
await syncAdmobNextgenMigration();
|
|
4712
4740
|
syncCodeplaySystemBarsPackage();
|
|
4741
|
+
require('./migrate-system-bars.cjs').migrateSystemBars();
|
|
4742
|
+
const legacyStatusBar = await require('./migrate-system-bars.cjs').migrateLegacyStatusBar();
|
|
4743
|
+
if (legacyStatusBar.status === 'retained') console.warn('Legacy StatusBar plugin retained:', legacyStatusBar.references.join(', '));
|
|
4713
4744
|
syncSystemBarsSafeAreaMigration();
|
|
4714
4745
|
ensureIapStartupOnHomePage();
|
|
4715
4746
|
syncRevenueCatIapSetup();
|
|
4716
4747
|
syncFirebaseAnalyticsSetup();
|
|
4717
4748
|
checkAndupdateDropInViteConfig();
|
|
4718
4749
|
syncViteTreeShaking();
|
|
4750
|
+
sourceFileInventory = null;
|
|
4751
|
+
require('./iap-alias.cjs').syncIapAliases(process.cwd(), getSourceFiles());
|
|
4719
4752
|
checkAdmobConfigurationProperty();
|
|
4720
4753
|
syncAndroidAdIdPermission();
|
|
4721
4754
|
syncAndroidBuildOptimization();
|
|
4722
4755
|
syncAndroidCordovaResourceKeep();
|
|
4756
|
+
require('./store-billing.cjs').syncStoreBillingPolicy(process.cwd(), getCurrentStoreId(), buildPlatform);
|
|
4757
|
+
if (adPackagesChanged) {
|
|
4758
|
+
ruAdsBuild.withNativeAdProvider(process.cwd(), getCurrentStoreId(), buildPlatform,
|
|
4759
|
+
() => runNpmCommand(`npx cap sync ${buildPlatform}`));
|
|
4760
|
+
}
|
|
4723
4761
|
}
|
|
4724
4762
|
|
|
4725
4763
|
await main();
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// Shared ad interface for builds with both native providers disabled.
|
|
2
|
+
const ignore = () => {};
|
|
3
|
+
const unavailable = async () => false;
|
|
4
|
+
const hidden = async () => true;
|
|
5
|
+
export const _isVideoLoad = false;
|
|
6
|
+
export const _isRewardInterstitialLoad = false;
|
|
7
|
+
export const _isNativeAdLoaded = false;
|
|
8
|
+
export const _bannerAdHeight = 0;
|
|
9
|
+
export const adjustWebViewForBanner = ignore;
|
|
10
|
+
export const hideGoogleBannerAd = hidden;
|
|
11
|
+
export const showGoogleBannerAd = unavailable;
|
|
12
|
+
export const canRequestAppAds = () => false;
|
|
13
|
+
export const getAdPrivacyOptionsState = () => ({ supported: false, requirementStatus: 'NOT_REQUIRED', loading: false, error: false, canRetry: false });
|
|
14
|
+
export const isAdPrivacyOptionsRequired = () => false;
|
|
15
|
+
export const requestAppAdConsent = unavailable;
|
|
16
|
+
export const adsOnDeviceReady = unavailable;
|
|
17
|
+
export const showAppAdPrivacyOptions = unavailable;
|
|
18
|
+
export const refreshAppAdConsent = showAppAdPrivacyOptions;
|
|
19
|
+
export async function withAdPrivacyChoices(callback) {
|
|
20
|
+
if (typeof callback === 'function') await callback();
|
|
21
|
+
}
|
|
22
|
+
export const disableFor_IAP_Subscription = ignore;
|
|
23
|
+
export const enableFor_IAP_Subscription = ignore;
|
|
24
|
+
export const disableFor_CREDIT_Subscription = ignore;
|
|
25
|
+
export const showRewardVideo = unavailable;
|
|
26
|
+
export async function levelWinInterstitial(callback) {
|
|
27
|
+
if (typeof callback === 'function') await callback();
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
export const runInterstitialTaskTransition = levelWinInterstitial;
|
|
31
|
+
export const disableAppOpenAd = ignore;
|
|
32
|
+
export const enableAppOpenAd = ignore;
|
|
33
|
+
export const noAppOpenShowUntilResume = ignore;
|
|
34
|
+
export const showRewardInterstitial = unavailable;
|
|
35
|
+
export const showNativeAd = unavailable;
|
|
36
|
+
export const showNativeAdInElement = showNativeAd;
|
|
37
|
+
export const hideNativeAd = hidden;
|
|
38
|
+
export const hideNativeAdInElement = hideNativeAd;
|
|
39
|
+
export const loadPictureInPictureAd = unavailable;
|
|
40
|
+
export const showPictureInPictureAd = loadPictureInPictureAd;
|
|
41
|
+
export const hidePictureInPictureAd = hidden;
|
|
42
|
+
export const destroyPictureInPictureAd = hidePictureInPictureAd;
|
|
43
|
+
export const removePictureInPictureAd = destroyPictureInPictureAd;
|
|
44
|
+
export const getPictureInPictureAdState = () => ({ loading: false, loaded: false, showing: false, fullscreen: false, adUnitId: '', error: null });
|
|
45
|
+
export const addPictureInPictureAdListener = () => ({ remove: ignore });
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
function findLatestIapDirectory(projectRoot = process.cwd()) {
|
|
5
|
+
const ads = path.join(projectRoot, 'src/js/Ads');
|
|
6
|
+
if (!fs.existsSync(ads)) return null;
|
|
7
|
+
const folder = fs.readdirSync(ads, { withFileTypes: true })
|
|
8
|
+
.filter(entry => entry.isDirectory() && /^IAP-\d+(?:\.\d+)*$/.test(entry.name)
|
|
9
|
+
&& fs.existsSync(path.join(ads, entry.name, 'IAP-state.js'))
|
|
10
|
+
&& fs.statSync(path.join(ads, entry.name, 'IAP-state.js')).isFile())
|
|
11
|
+
.map(entry => entry.name).sort((a, b) => b.localeCompare(a, undefined, { numeric: true }))[0];
|
|
12
|
+
return folder ? path.join(ads, folder) : null;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Resolve old protected controllers without rewriting their source or version.
|
|
16
|
+
function legacyIapPlugin(projectRoot = process.cwd()) {
|
|
17
|
+
return {
|
|
18
|
+
name: 'codeplay-legacy-iap-imports',
|
|
19
|
+
enforce: 'pre',
|
|
20
|
+
async resolveId(source, importer) {
|
|
21
|
+
const match = /^(?:(?:\.\.?\/)+|@\/|\/src\/)(?:[^?#]*\/)?IAP-\d+(?:\.\d+)*\/([^?#]+)([?#].*)?$/.exec(source);
|
|
22
|
+
if (!match) return null;
|
|
23
|
+
const directory = findLatestIapDirectory(projectRoot);
|
|
24
|
+
if (!directory) throw new Error('Cannot resolve legacy IAP import: no installed IAP-state.js.');
|
|
25
|
+
const target = path.resolve(directory, match[1]);
|
|
26
|
+
if (!target.startsWith(directory + path.sep) || !fs.existsSync(target) || !fs.statSync(target).isFile()) throw new Error(`Missing IAP module: ${source}`);
|
|
27
|
+
return this.resolve(target + (match[2] || ''), importer, { skipSelf: true });
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Reuse the before-build source inventory and gallery migration's import scanner.
|
|
33
|
+
// Only module specifiers are changed; comments, text and F7 markup are preserved.
|
|
34
|
+
function syncIapAliases(projectRoot = process.cwd(), files = []) {
|
|
35
|
+
const directory = findLatestIapDirectory(projectRoot);
|
|
36
|
+
const plans = [];
|
|
37
|
+
for (const file of files) {
|
|
38
|
+
if (file.split(path.sep).some(part => /^admob-nextgen-\d+(?:\.\d+)*$/.test(part)) || /^admob-emi-nextgen-\d+(?:\.\d+)*\.js$/.test(path.basename(file))) continue;
|
|
39
|
+
if (!/\.(?:js|mjs|cjs|ts|tsx|jsx|f7|vue)$/.test(file) || file.endsWith('.min.js')) continue;
|
|
40
|
+
const original = fs.readFileSync(file, 'utf8');
|
|
41
|
+
let script = original;
|
|
42
|
+
if (/\.(f7|vue)$/.test(file)) {
|
|
43
|
+
script = original.replace(/[^\r\n]/g, ' ');
|
|
44
|
+
for (const match of original.matchAll(/<script\b[^>]*>([\s\S]*?)<\/script\s*>/gi)) {
|
|
45
|
+
const start = match.index + match[0].indexOf('>') + 1;
|
|
46
|
+
script = script.slice(0, start) + match[1] + script.slice(start + match[1].length);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const code = script.replace(/\/\/[^\r\n]*|\/\*[\s\S]*?\*\/|(['"`])(?:\\[\s\S]|(?!\1)[^\\])*\1/g,
|
|
50
|
+
(match, quote) => quote ? match : match.replace(/[^\r\n]/g, ' '));
|
|
51
|
+
const imports = /(['"`])(?:\\[\s\S]|(?!\1)[^\\])*\1|\b(?:import\s+(?:[^;'"`]*?\s+from\s*)?|export\s+[^;'"`]*?\s+from\s*|(?:import|require)\s*\(\s*)(['"])([^'"\r\n]+)\2/g;
|
|
52
|
+
const replacements = [];
|
|
53
|
+
for (const match of code.matchAll(imports)) {
|
|
54
|
+
const specifier = match[3];
|
|
55
|
+
if (!specifier) continue;
|
|
56
|
+
const versioned = /^(?:(?:\.\.?\/)+|@\/|\/src\/)(?:[^?#]*\/)?IAP-\d+(?:\.\d+)*\/([^?#]+)([?#].*)?$/.exec(specifier);
|
|
57
|
+
const aliased = /^@iap\/([^?#]+)([?#].*)?$/.exec(specifier);
|
|
58
|
+
if (!versioned && !aliased) continue;
|
|
59
|
+
if (!directory) throw new Error(`Cannot configure @iap: no installed IAP folder with IAP-state.js (${file}).`);
|
|
60
|
+
const module = (versioned || aliased)[1];
|
|
61
|
+
const target = path.resolve(directory, module);
|
|
62
|
+
if (!target.startsWith(directory + path.sep) || !fs.existsSync(target) || !fs.statSync(target).isFile()) throw new Error(`Missing @iap/${module} in ${directory}; update the compatible IAP package first.`);
|
|
63
|
+
if (versioned) {
|
|
64
|
+
const start = match.index + match[0].lastIndexOf(specifier);
|
|
65
|
+
replacements.push({ start, length: specifier.length, value: `@iap/${module}${versioned[2] || ''}` });
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
let updated = original;
|
|
69
|
+
for (const edit of replacements.reverse()) updated = updated.slice(0, edit.start) + edit.value + updated.slice(edit.start + edit.length);
|
|
70
|
+
if (updated !== original) plans.push({ file, updated });
|
|
71
|
+
}
|
|
72
|
+
const vite = ['vite.config.mjs', 'vite.config.js'].map(name => path.join(projectRoot, name)).find(file => fs.existsSync(file));
|
|
73
|
+
if (directory && vite) {
|
|
74
|
+
let original = fs.readFileSync(vite, 'utf8');
|
|
75
|
+
const saved = original;
|
|
76
|
+
if (!original.includes('codeplayIapAliases.findLatestIapDirectory(')) {
|
|
77
|
+
const code = original.replace(/\/\/[^\r\n]*|\/\*[\s\S]*?\*\/|(['"`])(?:\\[\s\S]|(?!\1)[^\\])*\1/g,
|
|
78
|
+
(match, quote) => quote ? match : match.replace(/[^\r\n]/g, ' '));
|
|
79
|
+
const header = /\balias\s*:\s*([\[{])/.exec(code);
|
|
80
|
+
if (!header) throw new Error('Cannot configure @iap: Vite needs a resolve.alias object or array.');
|
|
81
|
+
if (/['"]@iap['"]\s*[:,]/.test(code)) throw new Error('Cannot replace a custom @iap alias automatically; use codeplayIapAliases.findLatestIapDirectory().');
|
|
82
|
+
const entry = header[1] === '{'
|
|
83
|
+
? "'@iap': codeplayIapAliases.findLatestIapDirectory(),"
|
|
84
|
+
: "{ find: '@iap', replacement: codeplayIapAliases.findLatestIapDirectory() },";
|
|
85
|
+
const offset = header.index + header[0].length;
|
|
86
|
+
const newline = original.includes('\r\n') ? '\r\n' : '\n';
|
|
87
|
+
const updated = original.slice(0, offset) + newline + ' ' + entry + original.slice(offset);
|
|
88
|
+
original = `import codeplayIapAliases from './buildCodeplay/iap-alias.cjs';${newline}${updated}`;
|
|
89
|
+
}
|
|
90
|
+
if (!original.includes('codeplayIapAliases.legacyIapPlugin(')) {
|
|
91
|
+
const plugins = /\bplugins\s*:\s*\[/.exec(original);
|
|
92
|
+
if (plugins) {
|
|
93
|
+
const offset = plugins.index + plugins[0].length;
|
|
94
|
+
original = original.slice(0, offset) + '\n codeplayIapAliases.legacyIapPlugin(),' + original.slice(offset);
|
|
95
|
+
} else {
|
|
96
|
+
const resolve = /\bresolve\s*:/.exec(original);
|
|
97
|
+
if (!resolve) throw new Error('Cannot configure legacy IAP resolution: Vite resolve settings missing.');
|
|
98
|
+
original = original.slice(0, resolve.index) + 'plugins: [codeplayIapAliases.legacyIapPlugin()],\n' + original.slice(resolve.index);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (saved !== original) plans.push({ file: vite, updated: original });
|
|
102
|
+
}
|
|
103
|
+
// Validate the complete migration before writing. No confirmation is needed.
|
|
104
|
+
for (const plan of plans) fs.writeFileSync(plan.file, plan.updated);
|
|
105
|
+
return plans.map(plan => path.relative(projectRoot, plan.file));
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
module.exports = { findLatestIapDirectory, legacyIapPlugin, syncIapAliases };
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const { createRequire } = require('module');
|
|
4
|
+
const { execSync } = require('child_process');
|
|
5
|
+
|
|
6
|
+
// Keep legacy color support below Android 15; modern Android uses the existing
|
|
7
|
+
// inset-sized protection views and WindowInsetsController icon appearance.
|
|
8
|
+
function migrateSystemBars(projectRoot = process.cwd()) {
|
|
9
|
+
const pluginPath = path.join(projectRoot, 'node_modules/capacitor-codeplay-system-bars/android/src/main/java/com/codeplay/systembars/CodeplaySystemBarsPlugin.java');
|
|
10
|
+
if (!fs.existsSync(pluginPath)) return false;
|
|
11
|
+
const original = fs.readFileSync(pluginPath, 'utf8');
|
|
12
|
+
const newline = original.includes('\r\n') ? '\r\n' : '\n';
|
|
13
|
+
const marker = '// Codeplay: navigation bar colors are supplied by protection views on Android 15+.';
|
|
14
|
+
if (original.includes(marker)) return false;
|
|
15
|
+
|
|
16
|
+
const oldLine = ' window.setNavigationBarColor(Color.TRANSPARENT);';
|
|
17
|
+
if (original.split(oldLine).length !== 2 || !original.includes('window.getDecorView().post(this::updateNavigationBarProtection);')) {
|
|
18
|
+
throw new Error('System-bars plugin structure changed; review the Android 15 migration before building.');
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const replacement = [
|
|
22
|
+
` ${marker}`,
|
|
23
|
+
' if (Build.VERSION.SDK_INT < Build.VERSION_CODES.VANILLA_ICE_CREAM) {',
|
|
24
|
+
' window.setNavigationBarColor(Color.TRANSPARENT);',
|
|
25
|
+
' }'
|
|
26
|
+
].join(newline);
|
|
27
|
+
fs.writeFileSync(pluginPath, original.replace(oldLine, replacement), 'utf8');
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function sourceFiles(directory, extensions, files = []) {
|
|
32
|
+
if (!fs.existsSync(directory)) return files;
|
|
33
|
+
for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {
|
|
34
|
+
if (entry.isSymbolicLink() || ['node_modules', '.git', 'agent-temp', 'test-results', 'www', 'public', 'Pods', 'build', 'dist'].includes(entry.name)) continue;
|
|
35
|
+
const file = path.join(directory, entry.name);
|
|
36
|
+
if (entry.isDirectory()) sourceFiles(file, extensions, files);
|
|
37
|
+
else if (extensions.test(entry.name)) files.push(file);
|
|
38
|
+
}
|
|
39
|
+
return files;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async function auditLegacyStatusBar(projectRoot = process.cwd()) {
|
|
43
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(projectRoot, 'package.json'), 'utf8'));
|
|
44
|
+
const dependency = '@capacitor/status-bar';
|
|
45
|
+
if (!pkg.dependencies?.[dependency] && !pkg.devDependencies?.[dependency] && !fs.existsSync(path.join(projectRoot, 'node_modules', dependency))) {
|
|
46
|
+
return { status: 'absent', references: [] };
|
|
47
|
+
}
|
|
48
|
+
let minify;
|
|
49
|
+
try {
|
|
50
|
+
({ minify } = createRequire(path.join(projectRoot, 'package.json'))('terser'));
|
|
51
|
+
} catch {
|
|
52
|
+
return { status: 'retained', references: ['JavaScript parser unavailable; cannot prove the plugin is unused.'] };
|
|
53
|
+
}
|
|
54
|
+
const files = sourceFiles(path.join(projectRoot, 'src'), /\.(?:js|cjs|mjs|ts|tsx|jsx|f7|vue|html)$/);
|
|
55
|
+
for (const entry of fs.readdirSync(projectRoot, { withFileTypes: true })) {
|
|
56
|
+
if (entry.isFile() && /\.(?:js|mjs|cjs|ts|tsx|jsx)$/.test(entry.name)) files.push(path.join(projectRoot, entry.name));
|
|
57
|
+
}
|
|
58
|
+
const references = [];
|
|
59
|
+
let modern = false;
|
|
60
|
+
for (const file of files) {
|
|
61
|
+
let code = fs.readFileSync(file, 'utf8');
|
|
62
|
+
if (!/StatusBar|@capacitor\/status-bar|\bSystemBars\b/.test(code)) continue;
|
|
63
|
+
try {
|
|
64
|
+
if (/\.(?:f7|vue|html)$/.test(file)) {
|
|
65
|
+
code = Array.from(code.matchAll(/<script\b[^>]*>([\s\S]*?)<\/script>/gi), match => match[1]).join('\n');
|
|
66
|
+
}
|
|
67
|
+
code = (await minify(code, { compress: false, mangle: false, module: true, format: { comments: false } })).code;
|
|
68
|
+
if (/\bSystemBars\b/.test(code) && /from["']@capacitor\/core["']/.test(code)) modern = true;
|
|
69
|
+
// This is the modern Capacitor enum, not the legacy StatusBar plugin.
|
|
70
|
+
code = code.replace(/\bSystemBarType\.StatusBar\b/g, '');
|
|
71
|
+
if (/\bStatusBar\b|@capacitor\/status-bar/.test(code)) references.push(path.relative(projectRoot, file));
|
|
72
|
+
} catch {
|
|
73
|
+
references.push(`${path.relative(projectRoot, file)} (parse review required)`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
const native = [
|
|
77
|
+
...sourceFiles(path.join(projectRoot, 'android/app/src/main/java'), /\.(?:java|kt)$/),
|
|
78
|
+
...sourceFiles(path.join(projectRoot, 'ios/App/App'), /\.(?:swift|m|mm)$/)
|
|
79
|
+
];
|
|
80
|
+
for (const file of native) {
|
|
81
|
+
if (/StatusBarPlugin|com\.capacitorjs\.plugins\.statusbar|CapacitorStatusBar/.test(fs.readFileSync(file, 'utf8'))) references.push(path.relative(projectRoot, file));
|
|
82
|
+
}
|
|
83
|
+
if (!modern) references.push('Modern Capacitor SystemBars usage not confirmed.');
|
|
84
|
+
return { status: references.length ? 'retained' : 'unused', references };
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
async function migrateLegacyStatusBar(projectRoot = process.cwd(), options = {}) {
|
|
88
|
+
const result = await auditLegacyStatusBar(projectRoot);
|
|
89
|
+
if (result.status !== 'unused') return result;
|
|
90
|
+
const runNpm = options.runNpm || (command => execSync(command, { cwd: projectRoot, stdio: 'pipe' }));
|
|
91
|
+
// Suppress lifecycle hooks: removing this plugin must not reinstall shared
|
|
92
|
+
// templates, run a build, or change app-owned configuration.
|
|
93
|
+
runNpm('npm uninstall @capacitor/status-bar --ignore-scripts --no-audit --no-fund');
|
|
94
|
+
if (fs.existsSync(path.join(projectRoot, 'android/capacitor.settings.gradle'))) {
|
|
95
|
+
runNpm('npx --no-install cap update android');
|
|
96
|
+
}
|
|
97
|
+
const podfile = path.join(projectRoot, 'ios/App/Podfile');
|
|
98
|
+
if (fs.existsSync(podfile)) {
|
|
99
|
+
const original = fs.readFileSync(podfile, 'utf8');
|
|
100
|
+
const updated = original.replace(/^[ \t]*pod ['"]CapacitorStatusBar['"], :path => ['"]\.\.\/\.\.\/node_modules\/@capacitor\/status-bar['"][ \t]*\r?\n/gm, '');
|
|
101
|
+
if (updated !== original) fs.writeFileSync(podfile, updated, 'utf8');
|
|
102
|
+
}
|
|
103
|
+
return { status: 'removed', references: [] };
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
module.exports = { migrateSystemBars, auditLegacyStatusBar, migrateLegacyStatusBar };
|
|
107
|
+
if (require.main === module) {
|
|
108
|
+
migrateSystemBars();
|
|
109
|
+
if (process.argv.includes('--remove-unused')) {
|
|
110
|
+
migrateLegacyStatusBar().then(result => console.log(JSON.stringify(result))).catch(error => {
|
|
111
|
+
console.error(error.message);
|
|
112
|
+
process.exitCode = 1;
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -22,7 +22,7 @@ function updateBuildScripts(scripts) {
|
|
|
22
22
|
}
|
|
23
23
|
if (!next.build) next.build = `${tasks['before-build']} && ${tasks['package-id']} && cross-env NODE_ENV=production vite build --logLevel warn`;
|
|
24
24
|
else if (!next.build.includes(tasks['before-build'])) next.build = `${tasks['before-build']} && ${next.build}`;
|
|
25
|
-
for (const id of [1, 2, 3, 4, 5, 7, 8]) {
|
|
25
|
+
for (const id of [1, 2, 3, 4, 5, 7, 8, 10]) {
|
|
26
26
|
const key = `build:storeid${id}`;
|
|
27
27
|
if (!next[key]) next[key] = `vite build --mode storeid${id}`;
|
|
28
28
|
if (!next[key].includes(tasks['before-build'])) next[key] = `cross-env VITE_STORE_ID=${id} ${tasks['before-build']} && cross-env VITE_STORE_ID=${id} ${next[key]}`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
{
|
|
2
|
-
"url": "https://htmlcodeplay.com/codeplay/api/v1/release/sync",
|
|
3
|
-
"token": "
|
|
4
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"url": "https://htmlcodeplay.com/codeplay/api/v1/release/sync",
|
|
3
|
+
"token": ""
|
|
4
|
+
}
|