@pi-r/android 0.6.5 → 0.7.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/README.md +3 -6
- package/data/google-maven-snapshot.json +1 -1
- package/data/google-maven.json +1 -1
- package/extensions/app/manifest/index.js +90 -84
- package/extensions/gradle/dependencies/index.js +23 -20
- package/extensions/gradle/settings/index.js +8 -10
- package/extensions/task/index.js +3 -5
- package/index.js +37 -34
- package/package.json +3 -3
- package/template/java/static/build.gradle +2 -2
- package/template/java+kotlin/build.gradle +1 -1
- package/template/java+kotlin/static/build.gradle +3 -3
- package/template/kotlin/build.gradle.kts +2 -2
- package/template/kotlin/static/build.gradle.kts +3 -3
- package/types/squared.d.ts +7 -6
|
@@ -8,15 +8,16 @@ const util_1 = require("@e-mc/document/util");
|
|
|
8
8
|
const types_1 = require("@e-mc/types");
|
|
9
9
|
const Parser = htmlparser2.Parser;
|
|
10
10
|
const DomHandler = domhandler.DomHandler;
|
|
11
|
-
|
|
11
|
+
const MANIFEST_ATTR = ['package', 'android:sharedUserId', 'android:sharedUserLabel', 'android:sharedUserMaxSdkVersion', 'android:versionCode', 'android:versionName', 'android:installLocation'];
|
|
12
|
+
module.exports = function finalize(instance) {
|
|
12
13
|
const config = instance.config;
|
|
13
|
-
|
|
14
|
+
const manifest = config.manifest;
|
|
15
|
+
if (!manifest) {
|
|
14
16
|
return;
|
|
15
17
|
}
|
|
16
18
|
let { localUri, source, existing } = instance.findTemplate(path.join(this.baseDirectory, config.mainParentDir, config.mainSrcDir), "AndroidManifest.xml", { detect: this.incremental !== 'staging' });
|
|
17
19
|
if (localUri && source && instance.canWrite(localUri, { ownPermissionOnly: true })) {
|
|
18
|
-
const {
|
|
19
|
-
const { supportsRtl, label, theme, activity, metaData = [], activityName, fontProvider } = application;
|
|
20
|
+
const { supportsRtl, label, theme, activity, metaData = [], activityName, fontProvider } = manifest.application || {};
|
|
20
21
|
const profileable = config.profileable;
|
|
21
22
|
let modified;
|
|
22
23
|
if (!existing) {
|
|
@@ -37,116 +38,123 @@ function finalize(instance) {
|
|
|
37
38
|
}
|
|
38
39
|
});
|
|
39
40
|
}
|
|
40
|
-
else if (
|
|
41
|
+
else if (theme || activityName || activity || supportsRtl !== undefined) {
|
|
41
42
|
new Parser(new DomHandler((err, dom) => {
|
|
42
43
|
if (err) {
|
|
43
44
|
instance.writeFail(['Unable to parse XML document', "AndroidManifest.xml"], err, 0);
|
|
44
45
|
return;
|
|
45
46
|
}
|
|
46
|
-
|
|
47
|
-
if (
|
|
48
|
-
|
|
47
|
+
const target = domutils.findOne(elem => elem.tagName === 'application', dom, true);
|
|
48
|
+
if (!target) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (label) {
|
|
52
|
+
target.attribs['android:label'] = '@string/' + label;
|
|
49
53
|
modified = true;
|
|
50
54
|
}
|
|
51
|
-
if (
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const attribs = item.attribs;
|
|
73
|
-
attribs['android:name'] = activityName;
|
|
74
|
-
attribs['android:exported'] = 'true';
|
|
75
|
-
modified = true;
|
|
76
|
-
break;
|
|
77
|
-
}
|
|
55
|
+
if (theme) {
|
|
56
|
+
target.attribs['android:theme'] = '@style/' + theme;
|
|
57
|
+
modified = true;
|
|
58
|
+
}
|
|
59
|
+
if (supportsRtl !== undefined) {
|
|
60
|
+
target.attribs['android:supportsRtl'] = supportsRtl.toString();
|
|
61
|
+
modified = true;
|
|
62
|
+
}
|
|
63
|
+
if (activityName || activity) {
|
|
64
|
+
const activities = domutils.getElementsByTagName('activity', target, true);
|
|
65
|
+
if (activityName) {
|
|
66
|
+
for (const item of activities) {
|
|
67
|
+
const intentFilter = domutils.findAll(elem => elem.tagName === 'intent-filter', [item]);
|
|
68
|
+
if (intentFilter.length) {
|
|
69
|
+
const action = domutils.findOne(elem => elem.tagName === 'action' && elem.attribs['android:name'] === 'android.intent.action.MAIN', intentFilter);
|
|
70
|
+
if (action) {
|
|
71
|
+
const attribs = item.attribs;
|
|
72
|
+
attribs['android:name'] = activityName;
|
|
73
|
+
attribs['android:exported'] = 'true';
|
|
74
|
+
modified = true;
|
|
75
|
+
break;
|
|
78
76
|
}
|
|
79
77
|
}
|
|
80
78
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
break;
|
|
79
|
+
}
|
|
80
|
+
if (activity) {
|
|
81
|
+
for (const name in activity) {
|
|
82
|
+
const { layout: attribs } = activity[name];
|
|
83
|
+
if (attribs) {
|
|
84
|
+
let element = domutils.findOne(elem => elem.attribs['android:name'] === name, activities);
|
|
85
|
+
if (!element) {
|
|
86
|
+
domutils.appendChild(target, element = new domhandler.Element('activity', { 'android:name': name }));
|
|
87
|
+
domutils.append(element, new domhandler.Text('\n'));
|
|
88
|
+
}
|
|
89
|
+
let layout = domutils.findOne(elem => elem.tagName === 'layout', [element]), found = true;
|
|
90
|
+
if (!layout) {
|
|
91
|
+
domutils.appendChild(element, layout = new domhandler.Element('layout', {}));
|
|
92
|
+
domutils.append(layout, new domhandler.Text('\n'));
|
|
93
|
+
found = false;
|
|
94
|
+
}
|
|
95
|
+
for (const attr in attribs) {
|
|
96
|
+
switch (attr) {
|
|
97
|
+
case 'defaultHeight':
|
|
98
|
+
case 'defaultWidth':
|
|
99
|
+
case 'minHeight':
|
|
100
|
+
case 'minWidth':
|
|
101
|
+
case 'gravity': {
|
|
102
|
+
const value = attribs[attr];
|
|
103
|
+
if (!found || layout.attribs['android:' + attr] !== value) {
|
|
104
|
+
layout.attribs['android:' + attr] = value;
|
|
105
|
+
modified = true;
|
|
109
106
|
}
|
|
107
|
+
break;
|
|
110
108
|
}
|
|
111
109
|
}
|
|
112
110
|
}
|
|
113
111
|
}
|
|
114
112
|
}
|
|
115
113
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
else if (profileable) {
|
|
123
|
-
domutils.appendChild(target, new domhandler.Element('profileable', attribs));
|
|
124
|
-
domutils.appendChild(target, new domhandler.Text('\n'));
|
|
125
|
-
}
|
|
126
|
-
modified = true;
|
|
114
|
+
}
|
|
115
|
+
if (profileable !== undefined) {
|
|
116
|
+
const attribs = profileable ? { 'android:shell': 'true', 'android:enabled': 'true' } : { 'android:enabled': 'false' };
|
|
117
|
+
const element = domutils.findOne(elem => elem.tagName === 'profileable', [target]);
|
|
118
|
+
if (element) {
|
|
119
|
+
Object.assign(element.attribs, attribs);
|
|
127
120
|
}
|
|
128
|
-
if (
|
|
129
|
-
|
|
121
|
+
else if (profileable) {
|
|
122
|
+
domutils.appendChild(target, new domhandler.Element('profileable', attribs));
|
|
123
|
+
domutils.appendChild(target, new domhandler.Text('\n'));
|
|
130
124
|
}
|
|
125
|
+
modified = true;
|
|
126
|
+
}
|
|
127
|
+
if (modified) {
|
|
128
|
+
source = domserializer.default(dom, { xmlMode: true });
|
|
131
129
|
}
|
|
132
130
|
}), { xmlMode: true, decodeEntities: false }).end(source);
|
|
133
131
|
}
|
|
134
132
|
if (fontProvider) {
|
|
135
133
|
metaData.push({ name: 'preloaded_fonts', resource: '@array/' + fontProvider });
|
|
136
134
|
}
|
|
137
|
-
|
|
135
|
+
const keys = Object.keys(manifest).map(attr => MANIFEST_ATTR.includes(attr) ? attr : attr !== 'package' && MANIFEST_ATTR.includes('android:' + attr) ? attr : '').filter(item => item);
|
|
136
|
+
if (keys.length || (0, types_1.isArray)(metaData)) {
|
|
138
137
|
new Parser(new DomHandler((err, dom) => {
|
|
139
138
|
if (err) {
|
|
140
139
|
instance.writeFail(['Unable to parse XML document', "AndroidManifest.xml"], err, 0);
|
|
141
140
|
return;
|
|
142
141
|
}
|
|
143
|
-
|
|
144
|
-
if (
|
|
142
|
+
let target = null;
|
|
143
|
+
if (keys.length && (target = domutils.findOne(elem => elem.tagName === 'manifest', dom, true))) {
|
|
144
|
+
for (let key of keys) {
|
|
145
|
+
if (!key.startsWith('android:') && key !== 'package') {
|
|
146
|
+
key = 'android:' + key;
|
|
147
|
+
}
|
|
148
|
+
target.attribs[key] = manifest[key]?.toString() || '';
|
|
149
|
+
modified = true;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if ((0, types_1.isArray)(metaData) && (target = domutils.findOne(elem => elem.tagName === 'application', dom, true))) {
|
|
145
153
|
for (const { name, resource, value } of metaData) {
|
|
146
154
|
if (name && (resource || value)) {
|
|
147
|
-
let item = domutils.findOne(elem => elem.tagName === 'meta-data' && elem.attribs['android:name'] === name,
|
|
155
|
+
let item = domutils.findOne(elem => elem.tagName === 'meta-data' && elem.attribs['android:name'] === name, target.childNodes);
|
|
148
156
|
if (!item) {
|
|
149
|
-
domutils.appendChild(
|
|
157
|
+
domutils.appendChild(target, item = new domhandler.Element('meta-data', { 'android:name': name }));
|
|
150
158
|
domutils.append(item, new domhandler.Text('\n'));
|
|
151
159
|
}
|
|
152
160
|
else if (item.attribs['android:resource'] === resource || item.attribs['android:value'] === value) {
|
|
@@ -176,6 +184,4 @@ function finalize(instance) {
|
|
|
176
184
|
}
|
|
177
185
|
}
|
|
178
186
|
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
module.exports = finalize;
|
|
187
|
+
};
|
|
@@ -27,16 +27,17 @@ function isUpgrade(version, pending) {
|
|
|
27
27
|
}
|
|
28
28
|
return false;
|
|
29
29
|
}
|
|
30
|
-
function finalize(instance) {
|
|
30
|
+
module.exports = function finalize(instance) {
|
|
31
31
|
const config = instance.config;
|
|
32
|
-
const { profileable, dependencies, dataBinding, versionName, versionCode } = config;
|
|
33
|
-
if (!profileable && !dependencies && !dataBinding && !versionName && !versionCode && !
|
|
32
|
+
const { profileable, dependencies, dataBinding, versionName, versionCode, namespace, applicationId } = config;
|
|
33
|
+
if (!profileable && !dependencies && !dataBinding && !versionName && !versionCode && !namespace && !applicationId) {
|
|
34
34
|
return;
|
|
35
35
|
}
|
|
36
36
|
const detect = this.incremental !== 'staging';
|
|
37
37
|
let { localUri, source, existing, kotlin } = instance.findTemplate(path.join(this.baseDirectory, config.mainParentDir), "build.gradle", { detect, languageOf: 'gradle' });
|
|
38
38
|
if (localUri && source && instance.canWrite(localUri, { ownPermissionOnly: true })) {
|
|
39
|
-
|
|
39
|
+
const { javaVersion, dependencyScopes } = config;
|
|
40
|
+
let jvmTarget, modified;
|
|
40
41
|
const upgrade = javaVersion > 0;
|
|
41
42
|
const setModified = (output) => {
|
|
42
43
|
if (output !== source) {
|
|
@@ -47,8 +48,8 @@ function finalize(instance) {
|
|
|
47
48
|
if (dependencies) {
|
|
48
49
|
let data;
|
|
49
50
|
const hasScope = (value) => (0, types_1.isArray)(dependencyScopes) && dependencyScopes.includes(value) || dependencyScopes === value;
|
|
50
|
-
const snapshot = hasScope('snapshot');
|
|
51
|
-
const getData = () => data
|
|
51
|
+
const snapshot = dependencyScopes === 1 || hasScope('snapshot');
|
|
52
|
+
const getData = () => data ||= instance.findData('google-maven' + (snapshot ? '-snapshot' : '') + '.json', 'json');
|
|
52
53
|
const items = dependencies.map(item => {
|
|
53
54
|
let [groupId, artifactId, version, type] = item.split(':');
|
|
54
55
|
if (!version || version === 'maven') {
|
|
@@ -74,7 +75,7 @@ function finalize(instance) {
|
|
|
74
75
|
if (target.dependencies) {
|
|
75
76
|
let found;
|
|
76
77
|
for (const { groupId, artifactId, version, scope } of target.dependencies) {
|
|
77
|
-
if (scope && (dependencyScopes === true || hasScope(scope))) {
|
|
78
|
+
if (scope && (dependencyScopes === true || dependencyScopes === 1 || hasScope(scope))) {
|
|
78
79
|
let type = -1;
|
|
79
80
|
switch (scope) {
|
|
80
81
|
case 'compile':
|
|
@@ -248,7 +249,7 @@ function finalize(instance) {
|
|
|
248
249
|
}
|
|
249
250
|
if (items.length) {
|
|
250
251
|
const newline = process.platform === 'win32' ? '\r\n' : '\n';
|
|
251
|
-
indent
|
|
252
|
+
indent ||= (0, util_1.getIndent)(source);
|
|
252
253
|
content = items.reduce((a, b) => a + indent + writeMethod(b) + newline, content);
|
|
253
254
|
modified = true;
|
|
254
255
|
}
|
|
@@ -263,9 +264,9 @@ function finalize(instance) {
|
|
|
263
264
|
output = Document.updateGradle(output, ['android', 'buildFeatures'], 'compose = true');
|
|
264
265
|
}
|
|
265
266
|
else {
|
|
266
|
-
output = Document.updateGradle(output, ['plugins'], "id 'org.jetbrains.kotlin.android'", { upgrade: true, multiple: true, addendum: `version '${instance.findVersion('org.jetbrains.kotlin:kotlin-stdlib', "1.9.
|
|
267
|
+
output = Document.updateGradle(output, ['plugins'], "id 'org.jetbrains.kotlin.android'", { upgrade: true, multiple: true, addendum: `version '${instance.findVersion('org.jetbrains.kotlin:kotlin-stdlib', "1.9.23")}'` });
|
|
267
268
|
output = Document.updateGradle(output, ['android', 'buildFeatures'], "compose true");
|
|
268
|
-
output = Document.updateGradle(output, ['android', 'composeOptions'], `kotlinCompilerExtensionVersion '${instance.findVersion('kotlinCompilerExtensionVersion', "1.5.
|
|
269
|
+
output = Document.updateGradle(output, ['android', 'composeOptions'], `kotlinCompilerExtensionVersion '${instance.findVersion('kotlinCompilerExtensionVersion', "1.5.12")}'`, true);
|
|
269
270
|
if (upgrade) {
|
|
270
271
|
output = Document.updateGradle(output, ['android', 'kotlinOptions'], `jvmTarget = '${javaVersion}'`, true);
|
|
271
272
|
}
|
|
@@ -316,8 +317,8 @@ function finalize(instance) {
|
|
|
316
317
|
output = Document.updateGradle(output, ['android'], kotlin ? `buildToolsVersion = "${version}"` : `buildToolsVersion "${version}"`, true);
|
|
317
318
|
}
|
|
318
319
|
}
|
|
319
|
-
if (
|
|
320
|
-
output = Document.updateGradle(output, ['android', 'defaultConfig'], (kotlin ? 'applicationId = ' : 'applicationId ') + `"${
|
|
320
|
+
if (applicationId) {
|
|
321
|
+
output = Document.updateGradle(output, ['android', 'defaultConfig'], (kotlin ? 'applicationId = ' : 'applicationId ') + `"${applicationId}"`, true);
|
|
321
322
|
}
|
|
322
323
|
setModified(output);
|
|
323
324
|
}
|
|
@@ -329,11 +330,15 @@ function finalize(instance) {
|
|
|
329
330
|
}
|
|
330
331
|
if (profileable) {
|
|
331
332
|
let name, items;
|
|
332
|
-
if (
|
|
333
|
-
|
|
334
|
-
|
|
333
|
+
if ((0, types_1.isArray)(profileable)) {
|
|
334
|
+
name = profileable[0];
|
|
335
|
+
if (typeof name === 'string' && !name.startsWith('--')) {
|
|
336
|
+
items = profileable.slice(1);
|
|
337
|
+
}
|
|
338
|
+
else {
|
|
339
|
+
name = '';
|
|
340
|
+
items = profileable;
|
|
335
341
|
}
|
|
336
|
-
items = profileable;
|
|
337
342
|
}
|
|
338
343
|
else if (typeof profileable === 'string') {
|
|
339
344
|
if (profileable.startsWith('--')) {
|
|
@@ -343,7 +348,7 @@ function finalize(instance) {
|
|
|
343
348
|
name = profileable;
|
|
344
349
|
}
|
|
345
350
|
}
|
|
346
|
-
name
|
|
351
|
+
name ||= 'debug';
|
|
347
352
|
setModified(Document.updateGradle(source, ['android', 'buildTypes', kotlin ? 'getByName("release")' : 'release'], 'signingConfig ' + (kotlin ? `= signingConfigs.getByName("${name}")` : 'signingConfigs.' + name), true));
|
|
348
353
|
if ((0, types_1.isArray)(items)) {
|
|
349
354
|
const parameters = items.map(value => `"${value}"`).join(', ');
|
|
@@ -380,6 +385,4 @@ function finalize(instance) {
|
|
|
380
385
|
}
|
|
381
386
|
}
|
|
382
387
|
}
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
module.exports = finalize;
|
|
388
|
+
};
|
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
const path = require("path");
|
|
3
3
|
const util_1 = require("@e-mc/document/util");
|
|
4
4
|
const parse_1 = require("@e-mc/document/parse");
|
|
5
|
-
function finalize(instance) {
|
|
6
|
-
const { dependencies, projectName,
|
|
5
|
+
module.exports = function finalize(instance) {
|
|
6
|
+
const { dependencies, projectName, mainParentDir } = instance.config;
|
|
7
7
|
if (!dependencies && !projectName) {
|
|
8
8
|
return;
|
|
9
9
|
}
|
|
10
10
|
let { localUri, source, existing, kotlin } = instance.findTemplate(this.baseDirectory, "settings.gradle", { detect: this.incremental !== 'staging', languageOf: 'gradle' });
|
|
11
11
|
if (localUri && source && instance.canWrite(localUri, { ownPermissionOnly: true })) {
|
|
12
|
-
|
|
12
|
+
const targetName = projectName?.replace(/"/g, '\\"');
|
|
13
|
+
let modified;
|
|
13
14
|
if (existing) {
|
|
14
15
|
let match;
|
|
15
16
|
if (dependencies) {
|
|
@@ -49,10 +50,6 @@ function finalize(instance) {
|
|
|
49
50
|
}
|
|
50
51
|
}
|
|
51
52
|
else {
|
|
52
|
-
if (!targetName && (targetName = manifest?.package)) {
|
|
53
|
-
const index = targetName.lastIndexOf('.');
|
|
54
|
-
targetName = index !== -1 ? targetName.substring(index + 1) : '';
|
|
55
|
-
}
|
|
56
53
|
source = (0, util_1.replaceAll)(source, (name) => {
|
|
57
54
|
switch (name) {
|
|
58
55
|
case 'projectName':
|
|
@@ -63,6 +60,9 @@ function finalize(instance) {
|
|
|
63
60
|
return '';
|
|
64
61
|
}
|
|
65
62
|
});
|
|
63
|
+
if (!targetName) {
|
|
64
|
+
source = source.replace(/rootProject\.name = ["']{2}[\r\n]*/, '');
|
|
65
|
+
}
|
|
66
66
|
}
|
|
67
67
|
if (modified || !existing) {
|
|
68
68
|
try {
|
|
@@ -75,6 +75,4 @@ function finalize(instance) {
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
module.exports = finalize;
|
|
78
|
+
};
|
package/extensions/task/index.js
CHANGED
|
@@ -6,7 +6,7 @@ const which = require("which");
|
|
|
6
6
|
const types_1 = require("@e-mc/types");
|
|
7
7
|
const Document = require("@e-mc/document");
|
|
8
8
|
const checkWin32 = (value) => value === "gradlew" && process.platform === 'win32' ? value + '.bat' : value;
|
|
9
|
-
async function finalize(instance) {
|
|
9
|
+
module.exports = async function finalize(instance) {
|
|
10
10
|
const commands = instance.config.commands;
|
|
11
11
|
if (!commands || this.incremental === 'staging') {
|
|
12
12
|
return;
|
|
@@ -117,8 +117,6 @@ async function finalize(instance) {
|
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
119
|
})
|
|
120
|
-
.catch(err => instance.writeFail(["Unable to perform task", command + ' ' + task], err, { type: 4, startTime }));
|
|
120
|
+
.catch((err) => instance.writeFail(["Unable to perform task", command + ' ' + task], err, { type: 4, startTime }));
|
|
121
121
|
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
module.exports = finalize;
|
|
122
|
+
};
|
package/index.js
CHANGED
|
@@ -4,29 +4,6 @@ const path = require("path");
|
|
|
4
4
|
const types_1 = require("@e-mc/types");
|
|
5
5
|
const Document = require('@e-mc/document');
|
|
6
6
|
class AndroidDocument extends Document {
|
|
7
|
-
constructor() {
|
|
8
|
-
super(...arguments);
|
|
9
|
-
this.config = {
|
|
10
|
-
mainParentDir: 'app',
|
|
11
|
-
mainSrcDir: 'src/main',
|
|
12
|
-
mainActivityFile: '',
|
|
13
|
-
javaVersion: 0,
|
|
14
|
-
dataBinding: false,
|
|
15
|
-
projectName: undefined,
|
|
16
|
-
versionName: undefined,
|
|
17
|
-
versionCode: 0,
|
|
18
|
-
manifest: undefined,
|
|
19
|
-
namespace: undefined,
|
|
20
|
-
profileable: undefined,
|
|
21
|
-
dependencies: undefined,
|
|
22
|
-
dependencyScopes: undefined,
|
|
23
|
-
commands: undefined
|
|
24
|
-
};
|
|
25
|
-
this.elements = [];
|
|
26
|
-
this.extensionData = {};
|
|
27
|
-
this._moduleName = 'android';
|
|
28
|
-
this._threadable = true;
|
|
29
|
-
}
|
|
30
7
|
static async finalize(instance) {
|
|
31
8
|
if (instance.aborted) {
|
|
32
9
|
return Promise.reject((0, types_1.createAbortError)());
|
|
@@ -53,9 +30,32 @@ class AndroidDocument extends Document {
|
|
|
53
30
|
}
|
|
54
31
|
return super.finalize.call(this, instance);
|
|
55
32
|
}
|
|
33
|
+
config = {
|
|
34
|
+
mainParentDir: 'app',
|
|
35
|
+
mainSrcDir: 'src/main',
|
|
36
|
+
mainActivityFile: '',
|
|
37
|
+
javaVersion: 0,
|
|
38
|
+
dataBinding: false,
|
|
39
|
+
projectName: undefined,
|
|
40
|
+
versionName: undefined,
|
|
41
|
+
versionCode: 0,
|
|
42
|
+
manifest: undefined,
|
|
43
|
+
namespace: undefined,
|
|
44
|
+
applicationId: undefined,
|
|
45
|
+
profileable: undefined,
|
|
46
|
+
dependencies: undefined,
|
|
47
|
+
dependencyScopes: undefined,
|
|
48
|
+
commands: undefined
|
|
49
|
+
};
|
|
50
|
+
elements = [];
|
|
51
|
+
extensionData = {};
|
|
52
|
+
targetAPI;
|
|
53
|
+
directories;
|
|
54
|
+
_moduleName = 'android';
|
|
55
|
+
_threadable = true;
|
|
56
56
|
init(assets, config) {
|
|
57
57
|
if (config) {
|
|
58
|
-
const { targetAPI, mainParentDir, mainSrcDir, mainActivityFile, javaVersion, projectName, versionName, versionCode = 0, manifest, namespace, profileable, dependencies, dependencyScopes, dataBinding, commands, directories, elements, extensionData } = config;
|
|
58
|
+
const { targetAPI, mainParentDir, mainSrcDir, mainActivityFile, javaVersion, projectName, versionName, versionCode = 0, manifest, namespace, applicationId, profileable, dependencies, dependencyScopes, dataBinding, commands, directories, elements, extensionData } = config;
|
|
59
59
|
const target = this.config;
|
|
60
60
|
if (projectName) {
|
|
61
61
|
target.projectName = projectName;
|
|
@@ -63,6 +63,9 @@ class AndroidDocument extends Document {
|
|
|
63
63
|
if (namespace) {
|
|
64
64
|
target.namespace = namespace;
|
|
65
65
|
}
|
|
66
|
+
if (applicationId) {
|
|
67
|
+
target.applicationId = applicationId;
|
|
68
|
+
}
|
|
66
69
|
if (mainParentDir) {
|
|
67
70
|
target.mainParentDir = mainParentDir;
|
|
68
71
|
}
|
|
@@ -150,14 +153,16 @@ class AndroidDocument extends Document {
|
|
|
150
153
|
const instance = host.loadModule('compress');
|
|
151
154
|
const buffer = host.getBuffer(file);
|
|
152
155
|
if (instance && buffer) {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
else if ((0, types_1.isString)(result)) {
|
|
159
|
-
host.replace(file, result);
|
|
156
|
+
const options = { format: 'ttf', etag: file.etag };
|
|
157
|
+
await instance.tryFile(buffer, localUri, options)
|
|
158
|
+
.then(() => {
|
|
159
|
+
if (options.outFile) {
|
|
160
|
+
host.replace(file, options.outFile);
|
|
160
161
|
}
|
|
162
|
+
})
|
|
163
|
+
.catch((err) => {
|
|
164
|
+
host.deleteFile(localUri);
|
|
165
|
+
host.writeFail("Unable to compress file", err, 8);
|
|
161
166
|
});
|
|
162
167
|
}
|
|
163
168
|
break;
|
|
@@ -227,9 +232,7 @@ class AndroidDocument extends Document {
|
|
|
227
232
|
return null;
|
|
228
233
|
}
|
|
229
234
|
get settings() {
|
|
230
|
-
|
|
231
|
-
return (_a = this.module).settings || (_a.settings = {});
|
|
235
|
+
return this.module.settings ||= {};
|
|
232
236
|
}
|
|
233
237
|
}
|
|
234
|
-
|
|
235
238
|
module.exports = AndroidDocument;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/android",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Android document constructor for E-mc.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"publishConfig": {
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"homepage": "https://github.com/anpham6/pi-r#readme",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@e-mc/document": "^0.
|
|
24
|
-
"@e-mc/types": "^0.
|
|
23
|
+
"@e-mc/document": "^0.9.0",
|
|
24
|
+
"@e-mc/types": "^0.9.0",
|
|
25
25
|
"htmlparser2": "^9.1.0",
|
|
26
26
|
"which": "^2.0.2"
|
|
27
27
|
}
|
|
@@ -37,7 +37,7 @@ android {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
dependencies {
|
|
40
|
-
implementation 'androidx.core:core-ktx:1.
|
|
40
|
+
implementation 'androidx.core:core-ktx:1.13.0'
|
|
41
41
|
testImplementation 'junit:junit:4.13.2'
|
|
42
42
|
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
|
|
43
43
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
plugins {
|
|
2
|
-
id 'com.android.application' version '8.
|
|
3
|
-
id 'com.android.library' version '8.
|
|
4
|
-
id 'org.jetbrains.kotlin.android' version '1.9.
|
|
2
|
+
id 'com.android.application' version '8.3.2' apply false
|
|
3
|
+
id 'com.android.library' version '8.3.2' apply false
|
|
4
|
+
id 'org.jetbrains.kotlin.android' version '1.9.23' apply false
|
|
5
5
|
}
|
|
@@ -38,8 +38,8 @@ java {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
dependencies {
|
|
41
|
-
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.9.
|
|
42
|
-
implementation("androidx.core:core-ktx:1.
|
|
41
|
+
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.9.23")
|
|
42
|
+
implementation("androidx.core:core-ktx:1.13.0")
|
|
43
43
|
testImplementation("junit:junit:4.13.2")
|
|
44
44
|
androidTestImplementation("androidx.test.ext:junit:1.1.5")
|
|
45
45
|
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
plugins {
|
|
2
|
-
id("com.android.application") version "8.
|
|
3
|
-
id("com.android.library") version "8.
|
|
4
|
-
id("org.jetbrains.kotlin.android") version "1.9.
|
|
2
|
+
id("com.android.application") version "8.3.2" apply false
|
|
3
|
+
id("com.android.library") version "8.3.2" apply false
|
|
4
|
+
id("org.jetbrains.kotlin.android") version "1.9.23" apply false
|
|
5
5
|
}
|
package/types/squared.d.ts
CHANGED
|
@@ -3,29 +3,30 @@ import type { FinalizedElement, ControllerSettingsDirectoryUI as IControllerSett
|
|
|
3
3
|
import type { RequestData as IRequestData } from '@e-mc/types/lib/node';
|
|
4
4
|
|
|
5
5
|
export interface DocumentOutput {
|
|
6
|
-
targetAPI?:
|
|
6
|
+
targetAPI?: number | string;
|
|
7
7
|
manifest?: ManifestData;
|
|
8
8
|
namespace?: string;
|
|
9
|
-
|
|
9
|
+
applicationId?: string;
|
|
10
|
+
profileable?: boolean | ArrayOf<string>;
|
|
10
11
|
dependencies?: string[];
|
|
11
|
-
dependencyScopes?: boolean | ArrayOf<DependencyScopes | "snapshot">;
|
|
12
|
+
dependencyScopes?: boolean | 1 | ArrayOf<DependencyScopes | "snapshot">;
|
|
12
13
|
directories?: ControllerSettingsDirectoryUI;
|
|
13
14
|
elements?: FinalizedElement[];
|
|
14
15
|
projectName?: string;
|
|
15
16
|
mainParentDir?: string;
|
|
16
17
|
mainSrcDir?: string;
|
|
17
18
|
mainActivityFile?: string;
|
|
18
|
-
javaVersion?:
|
|
19
|
+
javaVersion?: number | string;
|
|
19
20
|
versionName?: string;
|
|
20
21
|
versionCode?: number;
|
|
21
22
|
dataBinding?: boolean;
|
|
22
|
-
commands?: ArrayOf<
|
|
23
|
+
commands?: ArrayOf<ArrayOf<string>>;
|
|
23
24
|
extensionData?: PlainObject;
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
export interface RequestData extends IRequestData, DocumentOutput {}
|
|
27
28
|
|
|
28
|
-
export interface ManifestData {
|
|
29
|
+
export interface ManifestData extends PlainObject {
|
|
29
30
|
package?: string;
|
|
30
31
|
application?: {
|
|
31
32
|
supportsRtl?: boolean;
|