codeplay-common 1.3.8 → 1.3.9
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.
|
@@ -189,7 +189,7 @@ const routes = [
|
|
|
189
189
|
/*
|
|
190
190
|
For crash issue due to low memory problem, we need to modify the onRenderProcessGone method in BridgeWebViewClient.java.
|
|
191
191
|
*/
|
|
192
|
-
|
|
192
|
+
|
|
193
193
|
|
|
194
194
|
const bridgeWebViewClientFilePath = path.join(process.cwd(), 'node_modules', '@capacitor/android/capacitor/src/main/java/com/getcapacitor', 'BridgeWebViewClient.java');
|
|
195
195
|
|
|
@@ -253,19 +253,49 @@ const newCode = `@Override
|
|
|
253
253
|
return result;
|
|
254
254
|
}`;
|
|
255
255
|
|
|
256
|
-
//
|
|
256
|
+
// Step 1: Update method if needed
|
|
257
|
+
let updated = false;
|
|
258
|
+
|
|
257
259
|
if (fileContent.includes(oldCodeStart)) {
|
|
258
260
|
console.log('✅ Found old onRenderProcessGone method. Replacing it...');
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
console.log('✅ Replacement done.');
|
|
261
|
+
fileContent = fileContent.replace(oldCodeStart, newCode);
|
|
262
|
+
updated = true;
|
|
262
263
|
} else if (fileContent.includes(newCode)) {
|
|
263
|
-
console.log('ℹ️
|
|
264
|
+
console.log('ℹ️ Method already updated. No changes needed in "BridgeWebViewClient.java".');
|
|
264
265
|
} else {
|
|
265
266
|
console.error('❌ Error: Neither old nor new code found. Unexpected content.');
|
|
266
267
|
process.exit(1);
|
|
267
268
|
}
|
|
268
269
|
|
|
270
|
+
// Step 2: Check and add import if missing
|
|
271
|
+
const importToast = 'import android.widget.Toast;';
|
|
272
|
+
if (!fileContent.includes(importToast)) {
|
|
273
|
+
console.log('✅ Adding missing import for Toast...');
|
|
274
|
+
const importRegex = /import\s+[^;]+;/g;
|
|
275
|
+
const matches = [...fileContent.matchAll(importRegex)];
|
|
276
|
+
|
|
277
|
+
if (matches.length > 0) {
|
|
278
|
+
const lastImport = matches[matches.length - 1];
|
|
279
|
+
const insertPosition = lastImport.index + lastImport[0].length;
|
|
280
|
+
fileContent = fileContent.slice(0, insertPosition) + `\n${importToast}` + fileContent.slice(insertPosition);
|
|
281
|
+
updated = true;
|
|
282
|
+
} else {
|
|
283
|
+
console.error('❌ Error: No import section found in file.');
|
|
284
|
+
process.exit(1);
|
|
285
|
+
}
|
|
286
|
+
} else {
|
|
287
|
+
console.log('ℹ️ Import for Toast already exists. No changes needed.');
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// Step 3: Save if updated
|
|
291
|
+
if (updated) {
|
|
292
|
+
fs.writeFileSync(bridgeWebViewClientFilePath, fileContent, 'utf8');
|
|
293
|
+
console.log('✅ File updated successfully.');
|
|
294
|
+
} else {
|
|
295
|
+
console.log('ℹ️ No changes needed.');
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
|
|
269
299
|
|
|
270
300
|
|
|
271
301
|
// Check and change the "BridgeWebViewClient.java" file END
|