@pi-r/android 0.11.3 → 0.12.0
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/data/google-maven-snapshot.json +1 -1
- package/data/google-maven.json +1 -1
- package/extensions/app/manifest/index.js +27 -25
- package/extensions/gradle/dependencies/index.js +144 -163
- package/extensions/gradle/settings/index.js +15 -15
- package/extensions/task/index.js +13 -11
- package/index.js +22 -14
- package/package.json +3 -3
- package/project/gradle/wrapper/gradle-wrapper.properties +1 -1
- package/template/java/build.gradle +4 -4
- package/template/java/static/build.gradle +2 -2
- package/template/java/static/gradle.properties +1 -0
- package/template/java+kotlin/build.gradle +9 -13
- package/template/java+kotlin/libs.versions.toml +3 -3
- package/template/java+kotlin/settings.gradle +4 -0
- package/template/java+kotlin/static/build.gradle +1 -0
- package/template/java+kotlin/static/gradle.properties +1 -0
- package/template/kotlin/build.gradle.kts +12 -18
- package/template/kotlin/libs.versions.toml +2 -3
- package/template/kotlin/settings.gradle.kts +4 -0
- package/template/kotlin/static/gradle.properties +2 -1
- package/types/index.d.ts +3 -2
- package/types/squared.d.ts +2 -0
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
const domhandler = require(
|
|
5
|
-
const domutils = require(
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const DomHandler = domhandler.DomHandler;
|
|
2
|
+
|
|
3
|
+
const path = require('node:path');
|
|
4
|
+
const domhandler = require('domhandler');
|
|
5
|
+
const domutils = require('domutils');
|
|
6
|
+
const { Parser } = require('htmlparser2');
|
|
7
|
+
const { render } = require('dom-serializer');
|
|
8
|
+
const { isArray, isPlainObject } = require('@e-mc/types');
|
|
9
|
+
const { replaceAll } = require('@e-mc/document/util');
|
|
11
10
|
const MANIFEST_ATTR = [
|
|
12
11
|
'package',
|
|
13
12
|
'android:sharedUserId',
|
|
@@ -107,26 +106,28 @@ const ACTIVITY_ATTR = [
|
|
|
107
106
|
'android:windowSoftInputMode'
|
|
108
107
|
];
|
|
109
108
|
const INVALID_ATTR = [
|
|
110
|
-
[36, ['android:resizableActivity', 'android:minAspectRatio', 'android:maxAspectRatio']]
|
|
109
|
+
[36, ['android:resizableActivity', 'android:minAspectRatio', 'android:maxAspectRatio']],
|
|
110
|
+
[37, [['android:screenOrientation', 'portrait', 'reversePortrait', 'sensorPortrait', 'userPortrait', 'landscape', 'reverseLandscape', 'sensorLandscape', 'userLandscape']]]
|
|
111
111
|
];
|
|
112
112
|
function getValidKeys(instance, data, attrList) {
|
|
113
113
|
const result = [];
|
|
114
114
|
const targetApi = typeof instance.targetAPI === 'number' ? instance.targetAPI : 0;
|
|
115
|
+
const minResolution = Math.min(instance.resolutionScreenWidth || 0, instance.resolutionScreenHeight || 0);
|
|
115
116
|
for (let attr in data) {
|
|
116
|
-
|
|
117
|
-
const messageString = (type) => `${type} attribute: ${attr}="${value || 'null'}"`;
|
|
117
|
+
const value = data[attr];
|
|
118
|
+
const messageString = (type) => `${type} attribute: ${attr}="${value?.toString() || 'null'}"`;
|
|
118
119
|
invalid: {
|
|
119
|
-
if (attrList.includes(attr) || !attr.includes(':') && attrList.includes(attr =
|
|
120
|
-
|
|
121
|
-
if (targetApi >= 36) {
|
|
120
|
+
if (attrList.includes(attr) || !attr.includes(':') && attrList.includes(attr = `android:${attr}`)) {
|
|
121
|
+
const attrValue = Array.isArray(value) ? value.join('|') : value != null ? String(value) : '';
|
|
122
|
+
if (targetApi >= 36 && minResolution >= 600) {
|
|
122
123
|
for (const [api, attrs] of INVALID_ATTR) {
|
|
123
|
-
if (targetApi >= api && attrs.includes(attr)) {
|
|
124
|
+
if (targetApi >= api && attrs.some(item => Array.isArray(item) ? item[0] === attr && item.slice(1).includes(attrValue) : item === attr)) {
|
|
124
125
|
instance.addLog(instance.statusType.WARN, messageString("Invalid config"));
|
|
125
126
|
break invalid;
|
|
126
127
|
}
|
|
127
128
|
}
|
|
128
129
|
}
|
|
129
|
-
result.push([attr,
|
|
130
|
+
result.push([attr, attrValue]);
|
|
130
131
|
}
|
|
131
132
|
else if (value !== undefined) {
|
|
132
133
|
instance.addLog(instance.statusType.INFO, messageString("Unknown"));
|
|
@@ -163,7 +164,7 @@ function finalize(instance) {
|
|
|
163
164
|
const manifestKeys = getValidKeys(instance, config.manifest, MANIFEST_ATTR);
|
|
164
165
|
let modified = false;
|
|
165
166
|
if (!existing) {
|
|
166
|
-
source =
|
|
167
|
+
source = replaceAll(source, (name) => {
|
|
167
168
|
switch (name) {
|
|
168
169
|
case 'supportsRtl':
|
|
169
170
|
return supportsRtl === false ? 'false' : 'true';
|
|
@@ -181,7 +182,7 @@ function finalize(instance) {
|
|
|
181
182
|
});
|
|
182
183
|
}
|
|
183
184
|
if (existing && (theme || activityName || activity || supportsRtl !== undefined) || applicationKeys.length > 0) {
|
|
184
|
-
new Parser(new DomHandler((err, dom) => {
|
|
185
|
+
new Parser(new domhandler.DomHandler((err, dom) => {
|
|
185
186
|
if (err) {
|
|
186
187
|
instance.writeFail(['Unable to parse XML document', "AndroidManifest.xml"], err, 0);
|
|
187
188
|
return;
|
|
@@ -225,7 +226,7 @@ function finalize(instance) {
|
|
|
225
226
|
const attribs = data.layout;
|
|
226
227
|
delete data.layout;
|
|
227
228
|
const activityKeys = getValidKeys(instance, data, ACTIVITY_ATTR);
|
|
228
|
-
if (!
|
|
229
|
+
if (!isPlainObject(attribs) && activityKeys.length === 0) {
|
|
229
230
|
continue;
|
|
230
231
|
}
|
|
231
232
|
let element = domutils.findOne(elem => elem.attribs['android:name'] === name, activities);
|
|
@@ -277,15 +278,15 @@ function finalize(instance) {
|
|
|
277
278
|
modified = true;
|
|
278
279
|
}
|
|
279
280
|
if (modified) {
|
|
280
|
-
source =
|
|
281
|
+
source = render(dom, { xmlMode: true });
|
|
281
282
|
}
|
|
282
283
|
}), { xmlMode: true, decodeEntities: false }).end(source);
|
|
283
284
|
}
|
|
284
285
|
if (fontProvider) {
|
|
285
286
|
metaData.push({ name: 'preloaded_fonts', resource: '@array/' + fontProvider });
|
|
286
287
|
}
|
|
287
|
-
if (manifestKeys.length > 0 ||
|
|
288
|
-
new Parser(new DomHandler((err, dom) => {
|
|
288
|
+
if (manifestKeys.length > 0 || isArray(metaData)) {
|
|
289
|
+
new Parser(new domhandler.DomHandler((err, dom) => {
|
|
289
290
|
if (err) {
|
|
290
291
|
instance.writeFail(['Unable to parse XML document', "AndroidManifest.xml"], err, 0);
|
|
291
292
|
return;
|
|
@@ -294,7 +295,7 @@ function finalize(instance) {
|
|
|
294
295
|
if (manifestKeys.length > 0 && (target = domutils.findOne(elem => elem.tagName === 'manifest', dom, true)) && applyAttributes(target, manifestKeys)) {
|
|
295
296
|
modified = true;
|
|
296
297
|
}
|
|
297
|
-
if (
|
|
298
|
+
if (isArray(metaData) && (target = domutils.findOne(elem => elem.tagName === 'application', dom, true))) {
|
|
298
299
|
for (const { name, resource, value } of metaData) {
|
|
299
300
|
if (name && (resource || value)) {
|
|
300
301
|
let item = domutils.findOne(elem => elem.tagName === 'meta-data' && elem.attribs['android:name'] === name, target.childNodes);
|
|
@@ -311,7 +312,7 @@ function finalize(instance) {
|
|
|
311
312
|
if (value) {
|
|
312
313
|
item.attribs['android:value'] = value;
|
|
313
314
|
}
|
|
314
|
-
source =
|
|
315
|
+
source = render(dom, { xmlMode: true });
|
|
315
316
|
modified = true;
|
|
316
317
|
}
|
|
317
318
|
}
|
|
@@ -330,4 +331,5 @@ function finalize(instance) {
|
|
|
330
331
|
}
|
|
331
332
|
}
|
|
332
333
|
}
|
|
334
|
+
|
|
333
335
|
module.exports = finalize;
|