codeplay-common 2.1.38 → 2.1.39
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.
|
@@ -11,6 +11,12 @@ import path from 'path';
|
|
|
11
11
|
*/
|
|
12
12
|
function addAndroidPermissions(permissionsToAdd) {
|
|
13
13
|
try {
|
|
14
|
+
|
|
15
|
+
if (!Array.isArray(permissionsToAdd) || permissionsToAdd.length === 0) {
|
|
16
|
+
console.log("ℹ️ No permissions to add");
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
14
20
|
// read capacitor.config.json
|
|
15
21
|
const configPath = path.join(process.cwd(), 'capacitor.config.json');
|
|
16
22
|
if (!fs.existsSync(configPath)) {
|
|
@@ -157,73 +163,75 @@ const appJssmallModifications=()=>{
|
|
|
157
163
|
const replaceKeyboardSet=()=>{
|
|
158
164
|
|
|
159
165
|
|
|
160
|
-
const appJsPath = path.join(process.cwd(), 'src', 'js', 'capacitor-app.js');
|
|
166
|
+
const appJsPath = path.join(process.cwd(), 'src', 'js', 'capacitor-app.js');
|
|
161
167
|
|
|
162
|
-
if (fs.existsSync(appJsPath)) {
|
|
163
|
-
|
|
168
|
+
if (fs.existsSync(appJsPath)) {
|
|
169
|
+
let appJsContent = fs.readFileSync(appJsPath, 'utf8');
|
|
164
170
|
|
|
165
|
-
|
|
166
|
-
|
|
171
|
+
const lines = appJsContent.split(/\r?\n/);
|
|
172
|
+
const newLines = [];
|
|
167
173
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
174
|
+
const targetKeywords = [
|
|
175
|
+
'Keyboard.setResizeMode',
|
|
176
|
+
'Keyboard.setScroll',
|
|
177
|
+
'Keyboard.setAccessoryBarVisible',
|
|
178
|
+
];
|
|
173
179
|
|
|
174
|
-
|
|
180
|
+
let insideIosWrap = false;
|
|
175
181
|
|
|
176
|
-
|
|
177
|
-
|
|
182
|
+
lines.forEach((line, index) => {
|
|
183
|
+
const trimmed = line.trim();
|
|
178
184
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
+
// detect already inside ios check
|
|
186
|
+
if (/if\s*\(\s*Capacitor\.getPlatform\(\)\s*===\s*['"]ios['"]\s*\)/.test(trimmed)) {
|
|
187
|
+
insideIosWrap = true;
|
|
188
|
+
newLines.push(line);
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
185
191
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
+
// detect closing of a block
|
|
193
|
+
if (insideIosWrap && trimmed === '}') {
|
|
194
|
+
insideIosWrap = false;
|
|
195
|
+
newLines.push(line);
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
192
198
|
|
|
193
|
-
|
|
199
|
+
const isKeyboardSetCall = targetKeywords.some((kw) => trimmed.startsWith(kw));
|
|
194
200
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
201
|
+
if (isKeyboardSetCall) {
|
|
202
|
+
if (!insideIosWrap) {
|
|
203
|
+
const indentMatch = line.match(/^(\s*)/);
|
|
204
|
+
const indent = indentMatch ? indentMatch[1] : '';
|
|
205
|
+
newLines.push(`${indent}if (Capacitor.getPlatform() === 'ios') {`);
|
|
206
|
+
newLines.push(`${indent} ${trimmed}`);
|
|
207
|
+
newLines.push(`${indent}}`);
|
|
208
|
+
console.log(`✅ Wrapped line ${index + 1} with ios check`);
|
|
209
|
+
} else {
|
|
210
|
+
// already inside ios wrap, leave alone
|
|
211
|
+
newLines.push(line);
|
|
212
|
+
}
|
|
203
213
|
} else {
|
|
204
|
-
// already inside ios wrap, leave alone
|
|
205
214
|
newLines.push(line);
|
|
206
215
|
}
|
|
207
|
-
}
|
|
208
|
-
newLines.push(line);
|
|
209
|
-
}
|
|
210
|
-
});
|
|
216
|
+
});
|
|
211
217
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
}
|
|
215
|
-
|
|
218
|
+
fs.writeFileSync(appJsPath, newLines.join('\n'), 'utf8');
|
|
219
|
+
console.log(`✅ All Keyboard.set* lines wrapped safely with ios check`);
|
|
220
|
+
}
|
|
221
|
+
else
|
|
222
|
+
{
|
|
223
|
+
|
|
216
224
|
|
|
217
|
-
|
|
225
|
+
const configPath = path.join(process.cwd(), 'capacitor.config.json');
|
|
218
226
|
|
|
219
|
-
|
|
220
|
-
|
|
227
|
+
const rawData = fs.readFileSync(configPath, 'utf8');
|
|
228
|
+
const config = JSON.parse(rawData);
|
|
221
229
|
|
|
222
|
-
|
|
230
|
+
const appUniqueId=config.android.APP_UNIQUE_ID
|
|
223
231
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
}
|
|
232
|
+
if(appUniqueId!=172)
|
|
233
|
+
console.error(`❌ src/js/capacitor-app.js not found at: ${appJsPath}`);
|
|
234
|
+
}
|
|
227
235
|
|
|
228
236
|
|
|
229
237
|
|