@pi-r/android 0.6.7 → 0.7.1

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.
@@ -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
+ const MANIFEST_ATTR = ['package', 'android:sharedUserId', 'android:sharedUserLabel', 'android:sharedUserMaxSdkVersion', 'android:versionCode', 'android:versionName', 'android:installLocation'];
11
12
  module.exports = function finalize(instance) {
12
13
  const config = instance.config;
13
- if (!config.manifest) {
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 { package: manifestPackage, application = {} } = config.manifest;
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,121 @@ module.exports = function finalize(instance) {
37
38
  }
38
39
  });
39
40
  }
40
- else if (manifestPackage || theme || activityName || activity || supportsRtl !== undefined) {
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
- let target = null;
47
- if (manifestPackage && (target = domutils.findOne(elem => elem.tagName === 'manifest', dom, true))) {
48
- target.attribs.package = manifestPackage;
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 (target = domutils.findOne(elem => elem.tagName === 'application', dom, true)) {
52
- if (label) {
53
- target.attribs['android:label'] = '@string/' + label;
54
- modified = true;
55
- }
56
- if (theme) {
57
- target.attribs['android:theme'] = '@style/' + theme;
58
- modified = true;
59
- }
60
- if (supportsRtl !== undefined) {
61
- target.attribs['android:supportsRtl'] = supportsRtl.toString();
62
- modified = true;
63
- }
64
- if (activityName || activity) {
65
- const activities = domutils.getElementsByTagName('activity', target, true);
66
- if (activityName) {
67
- for (const item of activities) {
68
- const intentFilter = domutils.findAll(elem => elem.tagName === 'intent-filter', [item]);
69
- if (intentFilter.length) {
70
- const action = domutils.findOne(elem => elem.tagName === 'action' && elem.attribs['android:name'] === 'android.intent.action.MAIN', intentFilter);
71
- if (action) {
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
- if (activity) {
82
- for (const name in activity) {
83
- const { layout: attribs } = activity[name];
84
- if (attribs) {
85
- let element = domutils.findOne(elem => elem.attribs['android:name'] === name, activities);
86
- if (!element) {
87
- domutils.appendChild(target, element = new domhandler.Element('activity', { 'android:name': name }));
88
- domutils.append(element, new domhandler.Text('\n'));
89
- }
90
- let layout = domutils.findOne(elem => elem.tagName === 'layout', [element]), found = true;
91
- if (!layout) {
92
- domutils.appendChild(element, layout = new domhandler.Element('layout', {}));
93
- domutils.append(layout, new domhandler.Text('\n'));
94
- found = false;
95
- }
96
- for (const attr in attribs) {
97
- switch (attr) {
98
- case 'defaultHeight':
99
- case 'defaultWidth':
100
- case 'minHeight':
101
- case 'minWidth':
102
- case 'gravity': {
103
- const value = attribs[attr];
104
- if (!found || layout.attribs['android:' + attr] !== value) {
105
- layout.attribs['android:' + attr] = value;
106
- modified = true;
107
- }
108
- break;
109
- }
79
+ }
80
+ for (const name in activity) {
81
+ const { layout: attribs } = activity[name];
82
+ if (attribs) {
83
+ let element = domutils.findOne(elem => elem.attribs['android:name'] === name, activities);
84
+ if (!element) {
85
+ domutils.appendChild(target, element = new domhandler.Element('activity', { 'android:name': name }));
86
+ domutils.append(element, new domhandler.Text('\n'));
87
+ }
88
+ let layout = domutils.findOne(elem => elem.tagName === 'layout', [element]), found = true;
89
+ if (!layout) {
90
+ domutils.appendChild(element, layout = new domhandler.Element('layout', {}));
91
+ domutils.append(layout, new domhandler.Text('\n'));
92
+ found = false;
93
+ }
94
+ for (const attr in attribs) {
95
+ switch (attr) {
96
+ case 'defaultHeight':
97
+ case 'defaultWidth':
98
+ case 'minHeight':
99
+ case 'minWidth':
100
+ case 'gravity': {
101
+ const value = attribs[attr];
102
+ if (!found || layout.attribs['android:' + attr] !== value) {
103
+ layout.attribs['android:' + attr] = value;
104
+ modified = true;
110
105
  }
106
+ break;
111
107
  }
112
108
  }
113
109
  }
114
110
  }
115
111
  }
116
- if (profileable !== undefined) {
117
- const attribs = profileable ? { 'android:shell': 'true', 'android:enabled': 'true' } : { 'android:enabled': 'false' };
118
- const element = domutils.findOne(elem => elem.tagName === 'profileable', [target]);
119
- if (element) {
120
- Object.assign(element.attribs, attribs);
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;
112
+ }
113
+ if (profileable !== undefined) {
114
+ const attribs = profileable ? { 'android:shell': 'true', 'android:enabled': 'true' } : { 'android:enabled': 'false' };
115
+ const element = domutils.findOne(elem => elem.tagName === 'profileable', [target]);
116
+ if (element) {
117
+ Object.assign(element.attribs, attribs);
127
118
  }
128
- if (modified) {
129
- source = domserializer.default(dom, { xmlMode: true });
119
+ else if (profileable) {
120
+ domutils.appendChild(target, new domhandler.Element('profileable', attribs));
121
+ domutils.appendChild(target, new domhandler.Text('\n'));
130
122
  }
123
+ modified = true;
124
+ }
125
+ if (modified) {
126
+ source = domserializer.default(dom, { xmlMode: true });
131
127
  }
132
128
  }), { xmlMode: true, decodeEntities: false }).end(source);
133
129
  }
134
130
  if (fontProvider) {
135
131
  metaData.push({ name: 'preloaded_fonts', resource: '@array/' + fontProvider });
136
132
  }
137
- if ((0, types_1.isArray)(metaData)) {
133
+ const keys = Object.keys(manifest).map(attr => MANIFEST_ATTR.includes(attr) ? attr : attr !== 'package' && MANIFEST_ATTR.includes('android:' + attr) ? attr : '').filter(item => item);
134
+ if (keys.length || (0, types_1.isArray)(metaData)) {
138
135
  new Parser(new DomHandler((err, dom) => {
139
136
  if (err) {
140
137
  instance.writeFail(['Unable to parse XML document', "AndroidManifest.xml"], err, 0);
141
138
  return;
142
139
  }
143
- const app = domutils.findOne(elem => elem.tagName === 'application', dom, true);
144
- if (app) {
140
+ let target = null;
141
+ if (keys.length && (target = domutils.findOne(elem => elem.tagName === 'manifest', dom, true))) {
142
+ for (let key of keys) {
143
+ if (!key.startsWith('android:') && key !== 'package') {
144
+ key = 'android:' + key;
145
+ }
146
+ target.attribs[key] = manifest[key]?.toString() || '';
147
+ modified = true;
148
+ }
149
+ }
150
+ if ((0, types_1.isArray)(metaData) && (target = domutils.findOne(elem => elem.tagName === 'application', dom, true))) {
145
151
  for (const { name, resource, value } of metaData) {
146
152
  if (name && (resource || value)) {
147
- let item = domutils.findOne(elem => elem.tagName === 'meta-data' && elem.attribs['android:name'] === name, app.childNodes);
153
+ let item = domutils.findOne(elem => elem.tagName === 'meta-data' && elem.attribs['android:name'] === name, target.childNodes);
148
154
  if (!item) {
149
- domutils.appendChild(app, item = new domhandler.Element('meta-data', { 'android:name': name }));
155
+ domutils.appendChild(target, item = new domhandler.Element('meta-data', { 'android:name': name }));
150
156
  domutils.append(item, new domhandler.Text('\n'));
151
157
  }
152
158
  else if (item.attribs['android:resource'] === resource || item.attribs['android:value'] === value) {
@@ -28,16 +28,14 @@ function isUpgrade(version, pending) {
28
28
  return false;
29
29
  }
30
30
  module.exports = function finalize(instance) {
31
- var _a, _b;
32
- const config = instance.config;
33
- const { profileable, dependencies, dataBinding, versionName, versionCode, namespace } = config;
34
- if (!profileable && !dependencies && !dataBinding && !versionName && !versionCode && !namespace) {
31
+ const { profileable, dependencies, dataBinding, versionName, versionCode, namespace, applicationId, mainParentDir } = instance.config;
32
+ if (!profileable && !dependencies && !dataBinding && !versionName && !versionCode && !namespace && !applicationId) {
35
33
  return;
36
34
  }
37
- const detect = this.incremental !== 'staging';
38
- let { localUri, source, existing, kotlin } = instance.findTemplate(path.join(this.baseDirectory, config.mainParentDir), "build.gradle", { detect, languageOf: 'gradle' });
35
+ const options = { detect: this.incremental !== 'staging', languageOf: 'gradle' };
36
+ let { localUri, source, existing, kotlin } = instance.findTemplate(path.join(this.baseDirectory, mainParentDir), "build.gradle", options);
39
37
  if (localUri && source && instance.canWrite(localUri, { ownPermissionOnly: true })) {
40
- const { javaVersion, dependencyScopes } = config;
38
+ const { javaVersion, dependencyScopes } = instance.config;
41
39
  let jvmTarget, modified;
42
40
  const upgrade = javaVersion > 0;
43
41
  const setModified = (output) => {
@@ -49,15 +47,14 @@ module.exports = function finalize(instance) {
49
47
  if (dependencies) {
50
48
  let data;
51
49
  const hasScope = (value) => (0, types_1.isArray)(dependencyScopes) && dependencyScopes.includes(value) || dependencyScopes === value;
52
- const snapshot = hasScope('snapshot');
53
- const getData = () => data || (data = instance.findData('google-maven' + (snapshot ? '-snapshot' : '') + '.json', 'json'));
50
+ const snapshot = dependencyScopes === 1 || hasScope('snapshot');
51
+ const getData = () => data ||= instance.findData('google-maven' + (snapshot ? '-snapshot' : '') + '.json', 'json');
54
52
  const items = dependencies.map(item => {
55
- var _a;
56
53
  let [groupId, artifactId, version, type] = item.split(':');
57
54
  if (!version || version === 'maven') {
58
55
  const maven = getData();
59
56
  let artifact;
60
- if (maven && (artifact = (_a = maven[groupId]) === null || _a === void 0 ? void 0 : _a.find(child => child.artifactId === artifactId))) {
57
+ if (maven && (artifact = maven[groupId]?.find(child => child.artifactId === artifactId))) {
61
58
  version = artifact.version;
62
59
  }
63
60
  else {
@@ -70,14 +67,14 @@ module.exports = function finalize(instance) {
70
67
  const supplement = [];
71
68
  for (const item of items) {
72
69
  const [gId, id] = item;
73
- const target = (_a = data[gId]) === null || _a === void 0 ? void 0 : _a.find(group => id === group.artifactId);
70
+ const target = data[gId]?.find(group => id === group.artifactId);
74
71
  if (!target) {
75
72
  continue;
76
73
  }
77
74
  if (target.dependencies) {
78
75
  let found;
79
76
  for (const { groupId, artifactId, version, scope } of target.dependencies) {
80
- if (scope && (dependencyScopes === true || hasScope(scope))) {
77
+ if (scope && (dependencyScopes === true || dependencyScopes === 1 || hasScope(scope))) {
81
78
  let type = -1;
82
79
  switch (scope) {
83
80
  case 'compile':
@@ -200,7 +197,7 @@ module.exports = function finalize(instance) {
200
197
  let dependency;
201
198
  if (args || named) {
202
199
  const [group, name, version] = item;
203
- dependency = kotlin ? `(group = "${group}", name = "${name}", version = "${version}")` : ` group: '${group}', name: '${name}', version: '${version}'` + ((args === null || args === void 0 ? void 0 : args.endsWith(',')) ? ',' : '');
200
+ dependency = kotlin ? `(group = "${group}", name = "${name}", version = "${version}")` : ` group: '${group}', name: '${name}', version: '${version}'` + (args?.endsWith(',') ? ',' : '');
204
201
  }
205
202
  else {
206
203
  dependency = item.slice(0, 3).join(':');
@@ -251,7 +248,7 @@ module.exports = function finalize(instance) {
251
248
  }
252
249
  if (items.length) {
253
250
  const newline = process.platform === 'win32' ? '\r\n' : '\n';
254
- indent || (indent = (0, util_1.getIndent)(source));
251
+ indent ||= (0, util_1.getIndent)(source);
255
252
  content = items.reduce((a, b) => a + indent + writeMethod(b) + newline, content);
256
253
  modified = true;
257
254
  }
@@ -266,9 +263,9 @@ module.exports = function finalize(instance) {
266
263
  output = Document.updateGradle(output, ['android', 'buildFeatures'], 'compose = true');
267
264
  }
268
265
  else {
269
- 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")}'` });
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.24")}'` });
270
267
  output = Document.updateGradle(output, ['android', 'buildFeatures'], "compose true");
271
- output = Document.updateGradle(output, ['android', 'composeOptions'], `kotlinCompilerExtensionVersion '${instance.findVersion('kotlinCompilerExtensionVersion', "1.5.11")}'`, true);
268
+ output = Document.updateGradle(output, ['android', 'composeOptions'], `kotlinCompilerExtensionVersion '${instance.findVersion('kotlinCompilerExtensionVersion', "1.5.14")}'`, true);
272
269
  if (upgrade) {
273
270
  output = Document.updateGradle(output, ['android', 'kotlinOptions'], `jvmTarget = '${javaVersion}'`, true);
274
271
  }
@@ -319,7 +316,6 @@ module.exports = function finalize(instance) {
319
316
  output = Document.updateGradle(output, ['android'], kotlin ? `buildToolsVersion = "${version}"` : `buildToolsVersion "${version}"`, true);
320
317
  }
321
318
  }
322
- const applicationId = (_b = config.manifest) === null || _b === void 0 ? void 0 : _b.package;
323
319
  if (applicationId) {
324
320
  output = Document.updateGradle(output, ['android', 'defaultConfig'], (kotlin ? 'applicationId = ' : 'applicationId ') + `"${applicationId}"`, true);
325
321
  }
@@ -333,11 +329,15 @@ module.exports = function finalize(instance) {
333
329
  }
334
330
  if (profileable) {
335
331
  let name, items;
336
- if (Array.isArray(profileable)) {
337
- if (profileable.length && !profileable[0].startsWith('--')) {
338
- name = profileable.shift();
332
+ if ((0, types_1.isArray)(profileable)) {
333
+ name = profileable[0];
334
+ if (typeof name === 'string' && !name.startsWith('--')) {
335
+ items = profileable.slice(1);
336
+ }
337
+ else {
338
+ name = '';
339
+ items = profileable;
339
340
  }
340
- items = profileable;
341
341
  }
342
342
  else if (typeof profileable === 'string') {
343
343
  if (profileable.startsWith('--')) {
@@ -347,7 +347,7 @@ module.exports = function finalize(instance) {
347
347
  name = profileable;
348
348
  }
349
349
  }
350
- name || (name = 'debug');
350
+ name ||= 'debug';
351
351
  setModified(Document.updateGradle(source, ['android', 'buildTypes', kotlin ? 'getByName("release")' : 'release'], 'signingConfig ' + (kotlin ? `= signingConfigs.getByName("${name}")` : 'signingConfigs.' + name), true));
352
352
  if ((0, types_1.isArray)(items)) {
353
353
  const parameters = items.map(value => `"${value}"`).join(', ');
@@ -372,7 +372,7 @@ module.exports = function finalize(instance) {
372
372
  }
373
373
  }
374
374
  if (!existing) {
375
- ({ localUri, source, existing, kotlin } = instance.findTemplate(this.baseDirectory, "build.gradle", { detect, languageOf: 'gradle', subDir: 'static' }));
375
+ ({ localUri, source, existing, kotlin } = instance.findTemplate(this.baseDirectory, "build.gradle", { ...options, subDir: 'static' }));
376
376
  if (localUri && source && instance.canWrite(localUri, { ownPermissionOnly: true })) {
377
377
  try {
378
378
  if (instance.writeFile(localUri, source, { encoding: 'utf-8', ownPermissionOnly: true, throwsPermission: true })) {
@@ -9,7 +9,7 @@ module.exports = function finalize(instance) {
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
- const targetName = projectName === null || projectName === void 0 ? void 0 : projectName.replace(/"/g, '\\"');
12
+ const targetName = projectName?.replace(/"/g, '\\"');
13
13
  let modified;
14
14
  if (existing) {
15
15
  let match;
@@ -7,7 +7,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
9
  module.exports = async function finalize(instance) {
10
- var _a, _b;
11
10
  const commands = instance.config.commands;
12
11
  if (!commands || this.incremental === 'staging') {
13
12
  return;
@@ -21,13 +20,13 @@ module.exports = async function finalize(instance) {
21
20
  taskArgs = [commands];
22
21
  }
23
22
  else {
24
- taskArgs = commands.map(value => typeof value === 'string' ? [value] : value);
23
+ taskArgs = commands.map(value => Array.isArray(value) ? value : [value]);
25
24
  }
26
25
  }
27
26
  else {
28
27
  return;
29
28
  }
30
- const settings = ((_a = instance.settings.extensions) === null || _a === void 0 ? void 0 : _a.task) || {};
29
+ const settings = instance.settings.extensions?.task || {};
31
30
  const exec = settings.exec;
32
31
  let { broadcastId, baseDirectory } = this, command = settings.command, uid, gid, title, filename, altname, foundDir;
33
32
  if (command) {
@@ -35,7 +34,7 @@ module.exports = async function finalize(instance) {
35
34
  title = "maven";
36
35
  }
37
36
  else {
38
- title = ((_b = /([^\\/]+?)(?:\.[a-z]+)?$/i.exec(command)) === null || _b === void 0 ? void 0 : _b[1]) || 'spawn';
37
+ title = /([^\\/]+?)(?:\.[a-z]+)?$/i.exec(command)?.[1] || 'spawn';
39
38
  }
40
39
  if (!/[\\/]/.test(command = path.normalize(command))) {
41
40
  filename = checkWin32(command);
@@ -118,6 +117,6 @@ module.exports = async function finalize(instance) {
118
117
  });
119
118
  }
120
119
  })
121
- .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 }));
122
121
  }
123
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
- await instance.tryFile(buffer, localUri, { format: 'ttf', etag: file.etag }, (err, result) => {
154
- if (err) {
155
- host.deleteFile(localUri);
156
- host.writeFail("Unable to compress file", err, 8);
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;
@@ -165,16 +170,23 @@ class AndroidDocument extends Document {
165
170
  }
166
171
  }
167
172
  findTemplate(baseDir, filename, options) {
168
- var _a;
169
173
  let detect, languageOf, subDir;
170
174
  if (options) {
171
175
  ({ detect, languageOf, subDir } = options);
172
176
  }
173
177
  let kotlin, language;
174
178
  if (languageOf) {
175
- kotlin = (language = (_a = this.settings.language) === null || _a === void 0 ? void 0 : _a[languageOf]) === 'kotlin';
176
- const isKts = this.detectKts(baseDir, filename);
177
- detect = isKts !== null && (kotlin && isKts || !kotlin && !isKts);
179
+ kotlin = (language = this.settings.language?.[languageOf]) === 'kotlin';
180
+ if (detect !== false) {
181
+ const isKts = this.detectKts(baseDir, filename);
182
+ if (isKts && language === 'java') {
183
+ kotlin = true;
184
+ detect = true;
185
+ }
186
+ else {
187
+ detect = typeof isKts === 'boolean' && (kotlin && isKts || !kotlin && !isKts);
188
+ }
189
+ }
178
190
  if (kotlin) {
179
191
  filename += '.kts';
180
192
  }
@@ -228,8 +240,7 @@ class AndroidDocument extends Document {
228
240
  return null;
229
241
  }
230
242
  get settings() {
231
- var _a;
232
- return (_a = this.module).settings || (_a.settings = {});
243
+ return this.module.settings ||= {};
233
244
  }
234
245
  }
235
246
  module.exports = AndroidDocument;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/android",
3
- "version": "0.6.7",
3
+ "version": "0.7.1",
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.8.8",
24
- "@e-mc/types": "^0.8.8",
23
+ "@e-mc/document": "^0.9.2",
24
+ "@e-mc/types": "^0.9.2",
25
25
  "htmlparser2": "^9.1.0",
26
26
  "which": "^2.0.2"
27
27
  }
@@ -1,4 +1,4 @@
1
1
  plugins {
2
- id 'com.android.application' version '8.3.0' apply false
3
- id 'com.android.library' version '8.3.0' apply false
2
+ id 'com.android.application' version '8.4.0' apply false
3
+ id 'com.android.library' version '8.4.0' apply false
4
4
  }
@@ -37,7 +37,7 @@ android {
37
37
  }
38
38
 
39
39
  dependencies {
40
- implementation 'androidx.core:core-ktx:1.12.0'
40
+ implementation 'androidx.core:core-ktx:1.13.1'
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.0' apply false
3
- id 'com.android.library' version '8.3.0' apply false
4
- id 'org.jetbrains.kotlin.android' version '1.9.23' apply false
2
+ id 'com.android.application' version '8.4.0' apply false
3
+ id 'com.android.library' version '8.4.0' apply false
4
+ id 'org.jetbrains.kotlin.android' version '1.9.24' 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.23")
42
- implementation("androidx.core:core-ktx:1.12.0")
41
+ implementation("org.jetbrains.kotlin:kotlin-stdlib:1.9.24")
42
+ implementation("androidx.core:core-ktx:1.13.1")
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.0" apply false
3
- id("com.android.library") version "8.3.0" apply false
4
- id("org.jetbrains.kotlin.android") version "1.9.23" apply false
2
+ id("com.android.application") version "8.4.0" apply false
3
+ id("com.android.library") version "8.4.0" apply false
4
+ id("org.jetbrains.kotlin.android") version "1.9.24" apply false
5
5
  }