codeplay-common 4.11.22 → 4.11.24

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 CHANGED
@@ -1,5 +1,80 @@
1
1
  # codeplay-common
2
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
+
3
78
  ## Android system bars (4.11.22)
4
79
 
5
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.
@@ -1,4 +1,12 @@
1
- // Version 7.2: migrate Android 15 navigation-bar colors and remove unused legacy StatusBar plugins.
1
+ // Version 8.0: restore AdMob native settings when switching back to an AdMob store.
2
+ // Version 7.9: remove stale AdMob native settings and SDKs for non-AdMob stores.
3
+ // Version 7.8: preserve original Vite build settings through the generated store wrapper.
4
+ // Version 7.7: migrate versioned IAP imports to the dynamic @iap Vite alias without prompting.
5
+ // Version 7.6: resolve VK folder versions dynamically and update through the shared server manifest.
6
+ // Version 7.5: exclude transitive Google billing from Huawei and RuStore builds.
7
+ // Version 7.4: install only the current store's advertising provider before building.
8
+ // Version 7.3: select RuAds for Huawei/RuStore and isolate native advertising providers.
9
+ // Version 7.2: migrate Android 15 navigation-bar colors and remove unused legacy StatusBar plugins.
2
10
  // Version 7.1: require confirmation before continuing with local versions when the server check fails.
3
11
  // Version 7.0: prepare shared splash readiness and migrate the legacy splash theme.
4
12
  // Version 6.9: preserve configured notification icons during Android resource shrinking.
@@ -16,6 +24,7 @@ try {
16
24
 
17
25
  const fs = require('fs');
18
26
  const path = require('path');
27
+ const ruAdsBuild = require('./ruads.cjs');
19
28
  const plist = require('plist');
20
29
 
21
30
  // Edit only build.rollupOptions.treeshake in the exported Vite config.
@@ -123,7 +132,32 @@ const migrateViteTreeShaking = (content) => {
123
132
  if (exported >= 0) exported += 4;
124
133
  }
125
134
  if (exported < 0) throw new Error('No supported Vite config export found; file preserved.');
126
- const config = findConfig(exported);
135
+ const exportedConfig = findConfig(exported);
136
+ // setup-ruads wraps the consumer configuration and spreads it into a new
137
+ // returned object. Edit the original declaration so build options remain
138
+ // inherited instead of adding a replacement build object to that wrapper.
139
+ const original = tokens.findIndex((token, i) => token.value === 'const'
140
+ && value(i + 1) === 'codeplayOriginalViteConfig' && value(i + 2) === '=');
141
+ const config = original >= 0 ? findConfig(original + 3) : exportedConfig;
142
+ if (original >= 0 && config !== exportedConfig) {
143
+ // Repair only the exact treeshake-only override emitted by the old migration.
144
+ // Preserve any other build customizations made to the generated wrapper.
145
+ const wrapperBuild = properties(exportedConfig).find(property => property.name === 'build');
146
+ if (wrapperBuild && value(wrapperBuild.first) === '{' && pairs.get(wrapperBuild.first) === wrapperBuild.end - 1) {
147
+ const buildProperties = properties(wrapperBuild.first);
148
+ const rollup = buildProperties[0];
149
+ if (buildProperties.length === 1 && rollup.name === 'rollupOptions' && value(rollup.first) === '{'
150
+ && pairs.get(rollup.first) === rollup.end - 1) {
151
+ const options = properties(rollup.first);
152
+ const treeshake = options[0];
153
+ if (options.length === 1 && treeshake.name === 'treeshake'
154
+ && value(treeshake.first) === 'true' && treeshake.end === treeshake.first + 1) {
155
+ edits.push({ start: tokens[wrapperBuild.start].start,
156
+ end: wrapperBuild.comma ? tokens[wrapperBuild.end].end : tokens[wrapperBuild.end - 1].end, text: '' });
157
+ }
158
+ }
159
+ }
160
+ }
127
161
  const build = properties(config).filter(property => property.name === 'build').at(-1);
128
162
  if (!build) append(config, 'build: { rollupOptions: { treeshake: true } }');
129
163
  else {
@@ -159,7 +193,7 @@ const migrateIapStartup = (content, bootstrapImport) => {
159
193
  let next = content;
160
194
  const bootstrapPattern = /import\s*\{\s*initIAP\s*\}\s*from\s*['"][^'"]*\/IAP-bootstrap\.js['"]\s*;?/;
161
195
  if (!bootstrapPattern.test(next)) {
162
- next = next.replace(/import\s*\{([^}]*)\}\s*from\s*(['"])([^'"]*\/IAP-\d+(?:\.\d+)*\/IAP-check-And-LoadAd\.js)\2\s*;?/g,
196
+ next = next.replace(/import\s*\{([^}]*)\}\s*from\s*(['"])((?:[^'"]*\/IAP-\d+(?:\.\d+)*\/|@iap\/)IAP-check-And-LoadAd\.js)\2\s*;?/g,
163
197
  (match, names, quote, source) => {
164
198
  const imports = names.split(',').map(name => name.trim()).filter(Boolean);
165
199
  if (!imports.includes('initIAP')) return match;
@@ -1699,6 +1733,7 @@ function getAdMobConfig() {
1699
1733
  }
1700
1734
 
1701
1735
  const isEnabled =
1736
+ ruAdsBuild.getAdProvider(capacitorConfig, process.env.VITE_STORE_ID, buildPlatform) === 'admob' &&
1702
1737
  nextGenAdmobConfig.enabled !== false &&
1703
1738
  legacyAdmobConfig.ADMOB_ENABLED !== false;
1704
1739
 
@@ -2492,6 +2527,7 @@ if (pluginDef.isFolder) {
2492
2527
  fs.mkdirSync(stagingRoot, { recursive: true });
2493
2528
  const staging = fs.mkdtempSync(path.join(stagingRoot, 'package-'));
2494
2529
  await downloadAndExtractZip(url, staging);
2530
+ 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.');
2495
2531
  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');
2496
2532
  if (fs.existsSync(newPath)) throw new Error('Replacement folder already exists; existing sources preserved.');
2497
2533
  fs.renameSync(staging, newPath);
@@ -2690,12 +2726,16 @@ function checkPlugins() {
2690
2726
 
2691
2727
  for (const dir of subDirs) {
2692
2728
  const relativePath = path.relative(searchRoot, dir).replace(/\\/g, '/');
2729
+ if (plugin.name === 'vk-ads') {
2730
+ const latestVk = ruAdsBuild.findLatestVkController(process.cwd());
2731
+ if (latestVk && path.basename(path.dirname(latestVk)) !== relativePath) continue;
2732
+ }
2693
2733
  const match = plugin.pattern.exec(relativePath);
2694
2734
 
2695
2735
  if (match) {
2696
2736
  const currentVersion = match[1];
2697
2737
 
2698
- if (compareVersions(currentVersion, plugin.minVersion) < 0) {
2738
+ if ((plugin.name === 'vk-ads' ? compareVersionStrings(currentVersion, plugin.minVersion) : compareVersions(currentVersion, plugin.minVersion)) < 0) {
2699
2739
  outdatedPlugins.push({
2700
2740
  name: relativePath,
2701
2741
  currentVersion,
@@ -3131,28 +3171,7 @@ const syncViteTreeShaking = () => {
3131
3171
  }
3132
3172
  };
3133
3173
 
3134
- const getLatestIapDir = () => {
3135
- const adsDir = path.join(process.cwd(), "src", "js", "Ads");
3136
-
3137
- if (!fs.existsSync(adsDir)) return null;
3138
-
3139
- const iapDirs = fs.readdirSync(adsDir, { withFileTypes: true })
3140
- .filter(entry => entry.isDirectory() && /^IAP-\d+(\.\d+)*$/.test(entry.name))
3141
- .map(entry => entry.name)
3142
- .sort((a, b) => {
3143
- const versionA = a.match(/(\d+(?:\.\d+)*)/)[1].split(".").map(Number);
3144
- const versionB = b.match(/(\d+(?:\.\d+)*)/)[1].split(".").map(Number);
3145
-
3146
- for (let i = 0; i < Math.max(versionA.length, versionB.length); i++) {
3147
- const diff = (versionB[i] || 0) - (versionA[i] || 0);
3148
- if (diff !== 0) return diff;
3149
- }
3150
-
3151
- return 0;
3152
- });
3153
-
3154
- return iapDirs.length > 0 ? path.join(adsDir, iapDirs[0]) : null;
3155
- };
3174
+ const getLatestIapDir = () => require('./iap-alias.cjs').findLatestIapDirectory(process.cwd());
3156
3175
 
3157
3176
  const getAnalyticsConfig = () => {
3158
3177
  const config = fs.existsSync(configPath)
@@ -3535,6 +3554,8 @@ const ensureAdmobNextgenFiles = async () => {
3535
3554
  };
3536
3555
 
3537
3556
  const syncAdmobNextgenMigration = async () => {
3557
+ const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
3558
+ if (ruAdsBuild.getAdProvider(config, process.env.VITE_STORE_ID, buildPlatform) !== 'admob') return;
3538
3559
  syncAdmobNextgenPackage();
3539
3560
  await ensureAdmobNextgenFiles();
3540
3561
  syncAdmobAliasInViteConfig();
@@ -4074,9 +4095,11 @@ const syncAmazonFireWebViewDependency = (enabled) => {
4074
4095
  fs.writeFileSync(androidAppBuildGradlePath, nextContent, "utf8");
4075
4096
  }
4076
4097
 
4077
- console.log(enabled
4078
- ? "✅ Amazon Fire WebView compatibility dependency enabled for Store ID 7."
4079
- : "ℹ️ Amazon Fire WebView compatibility dependency disabled for this store.");
4098
+ if (getCurrentStoreId() === 7) {
4099
+ console.log(enabled
4100
+ ? "✅ Amazon Fire WebView compatibility dependency enabled for Store ID 7."
4101
+ : "ℹ️ Amazon Fire WebView compatibility dependency disabled for this store.");
4102
+ }
4080
4103
  };
4081
4104
 
4082
4105
  function syncAndroidAdIdPermission() {
@@ -4191,7 +4214,8 @@ const syncRevenueCatIapSetup = () => {
4191
4214
  }
4192
4215
 
4193
4216
  if (packageChanged) {
4194
- runNpmCommand("npx cap sync");
4217
+ ruAdsBuild.withNativeAdProvider(process.cwd(), getCurrentStoreId(), buildPlatform,
4218
+ () => runNpmCommand(`npx cap sync ${buildPlatform}`));
4195
4219
  }
4196
4220
  };
4197
4221
 
@@ -4698,7 +4722,8 @@ async function main() {
4698
4722
  buildPackage.scripts = buildScripts;
4699
4723
  fs.writeFileSync(packageJsonPath, JSON.stringify(buildPackage, null, 2) + '\n');
4700
4724
  }
4701
- require('./splash-setup.cjs').syncSplashSetup(process.cwd());
4725
+ require('./splash-setup.cjs').syncSplashSetup(process.cwd());
4726
+ require('./setup-ruads.cjs').syncRuAdsSetup(process.cwd());
4702
4727
  validateThemeFolderLocation();
4703
4728
  validateAndRestoreSignDetails();
4704
4729
  ensureMandatoryCapacitorPlugins();
@@ -4706,13 +4731,17 @@ async function main() {
4706
4731
  await loadPluginVersions(); // 🔥 NEW
4707
4732
  await syncAgentInstructions();
4708
4733
  if (!skipOnlineVersionChecks) await checkPlugins();
4734
+ // Validate only the selected provider after the shared folder updater finishes.
4735
+ ruAdsBuild.controllerPath(JSON.parse(fs.readFileSync(path.join(process.cwd(), 'capacitor.config.json'), 'utf8')),
4736
+ getCurrentStoreId(), buildPlatform, null);
4709
4737
  // Downloads may add a newer helper or source files containing legacy imports.
4710
4738
  await saveToGalleryAndSaveFileCheck_iOS();
4711
4739
 
4740
+ const adPackagesChanged = ruAdsBuild.syncAdProviderPackages(process.cwd(), runNpmCommand);
4712
4741
  await syncAdmobNextgenMigration();
4713
- syncCodeplaySystemBarsPackage();
4714
- require('./migrate-system-bars.cjs').migrateSystemBars();
4715
- const legacyStatusBar = await require('./migrate-system-bars.cjs').migrateLegacyStatusBar();
4742
+ syncCodeplaySystemBarsPackage();
4743
+ require('./migrate-system-bars.cjs').migrateSystemBars();
4744
+ const legacyStatusBar = await require('./migrate-system-bars.cjs').migrateLegacyStatusBar();
4716
4745
  if (legacyStatusBar.status === 'retained') console.warn('Legacy StatusBar plugin retained:', legacyStatusBar.references.join(', '));
4717
4746
  syncSystemBarsSafeAreaMigration();
4718
4747
  ensureIapStartupOnHomePage();
@@ -4720,10 +4749,18 @@ async function main() {
4720
4749
  syncFirebaseAnalyticsSetup();
4721
4750
  checkAndupdateDropInViteConfig();
4722
4751
  syncViteTreeShaking();
4752
+ sourceFileInventory = null;
4753
+ require('./iap-alias.cjs').syncIapAliases(process.cwd(), getSourceFiles());
4723
4754
  checkAdmobConfigurationProperty();
4724
4755
  syncAndroidAdIdPermission();
4725
4756
  syncAndroidBuildOptimization();
4726
4757
  syncAndroidCordovaResourceKeep();
4758
+ require('./store-billing.cjs').syncStoreBillingPolicy(process.cwd(), getCurrentStoreId(), buildPlatform);
4759
+ if (adPackagesChanged) {
4760
+ ruAdsBuild.withNativeAdProvider(process.cwd(), getCurrentStoreId(), buildPlatform,
4761
+ () => runNpmCommand(`npx cap sync ${buildPlatform}`));
4762
+ }
4763
+ ruAdsBuild.syncAndroidAdmobPolicy(process.cwd(), getCurrentStoreId(), buildPlatform);
4727
4764
  }
4728
4765
 
4729
4766
  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,3 @@
1
+ # MyTracker checks for BillingClient/Purchase classes and disables its Google
2
+ # purchase helper when absent. These optional classes are excluded on stores 4/10.
3
+ -dontwarn com.android.billingclient.**
@@ -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": "b_TiY0Lu7q7Yb0Kx9djVxA6ST8k4CFiwFQNxgci7AAU"
4
- }
1
+ {
2
+ "url": "https://htmlcodeplay.com/codeplay/api/v1/release/sync",
3
+ "token": ""
4
+ }