@pi-r/android 0.7.0 → 0.7.2

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.
@@ -77,35 +77,33 @@ module.exports = function finalize(instance) {
77
77
  }
78
78
  }
79
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;
106
- }
107
- break;
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;
108
105
  }
106
+ break;
109
107
  }
110
108
  }
111
109
  }
@@ -28,15 +28,14 @@ function isUpgrade(version, pending) {
28
28
  return false;
29
29
  }
30
30
  module.exports = function finalize(instance) {
31
- const config = instance.config;
32
- const { profileable, dependencies, dataBinding, versionName, versionCode, namespace, applicationId } = config;
31
+ const { profileable, dependencies, dataBinding, versionName, versionCode, namespace, applicationId, mainParentDir } = instance.config;
33
32
  if (!profileable && !dependencies && !dataBinding && !versionName && !versionCode && !namespace && !applicationId) {
34
33
  return;
35
34
  }
36
- const detect = this.incremental !== 'staging';
37
- 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);
38
37
  if (localUri && source && instance.canWrite(localUri, { ownPermissionOnly: true })) {
39
- const { javaVersion, dependencyScopes } = config;
38
+ const { javaVersion, dependencyScopes } = instance.config;
40
39
  let jvmTarget, modified;
41
40
  const upgrade = javaVersion > 0;
42
41
  const setModified = (output) => {
@@ -264,9 +263,9 @@ module.exports = function finalize(instance) {
264
263
  output = Document.updateGradle(output, ['android', 'buildFeatures'], 'compose = true');
265
264
  }
266
265
  else {
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")}'` });
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")}'` });
268
267
  output = Document.updateGradle(output, ['android', 'buildFeatures'], "compose true");
269
- output = Document.updateGradle(output, ['android', 'composeOptions'], `kotlinCompilerExtensionVersion '${instance.findVersion('kotlinCompilerExtensionVersion', "1.5.12")}'`, true);
268
+ output = Document.updateGradle(output, ['android', 'composeOptions'], `kotlinCompilerExtensionVersion '${instance.findVersion('kotlinCompilerExtensionVersion', "1.5.14")}'`, true);
270
269
  if (upgrade) {
271
270
  output = Document.updateGradle(output, ['android', 'kotlinOptions'], `jvmTarget = '${javaVersion}'`, true);
272
271
  }
@@ -373,7 +372,7 @@ module.exports = function finalize(instance) {
373
372
  }
374
373
  }
375
374
  if (!existing) {
376
- ({ 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' }));
377
376
  if (localUri && source && instance.canWrite(localUri, { ownPermissionOnly: true })) {
378
377
  try {
379
378
  if (instance.writeFile(localUri, source, { encoding: 'utf-8', ownPermissionOnly: true, throwsPermission: true })) {
@@ -20,7 +20,7 @@ module.exports = async function finalize(instance) {
20
20
  taskArgs = [commands];
21
21
  }
22
22
  else {
23
- taskArgs = commands.map(value => typeof value === 'string' ? [value] : value);
23
+ taskArgs = commands.map(value => Array.isArray(value) ? value : [value]);
24
24
  }
25
25
  }
26
26
  else {
@@ -81,7 +81,7 @@ module.exports = async function finalize(instance) {
81
81
  }
82
82
  for (const args of taskArgs) {
83
83
  if (instance.aborted) {
84
- return Promise.reject((0, types_1.createAbortError)());
84
+ return (0, types_1.createAbortError)(true);
85
85
  }
86
86
  const startTime = process.hrtime();
87
87
  const task = args.join(' ');
package/index.js CHANGED
@@ -6,7 +6,7 @@ const Document = require('@e-mc/document');
6
6
  class AndroidDocument extends Document {
7
7
  static async finalize(instance) {
8
8
  if (instance.aborted) {
9
- return Promise.reject((0, types_1.createAbortError)());
9
+ return (0, types_1.createAbortError)(true);
10
10
  }
11
11
  if (instance.extensions.length) {
12
12
  const config = instance.config;
@@ -131,7 +131,7 @@ class AndroidDocument extends Document {
131
131
  }
132
132
  async using(data) {
133
133
  if (this.aborted) {
134
- return Promise.reject((0, types_1.createAbortError)());
134
+ return (0, types_1.createAbortError)(true);
135
135
  }
136
136
  const { host, file } = data;
137
137
  const localUri = file.localUri;
@@ -177,8 +177,16 @@ class AndroidDocument extends Document {
177
177
  let kotlin, language;
178
178
  if (languageOf) {
179
179
  kotlin = (language = this.settings.language?.[languageOf]) === 'kotlin';
180
- const isKts = this.detectKts(baseDir, filename);
181
- detect = isKts !== null && (kotlin && isKts || !kotlin && !isKts);
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
+ }
182
190
  if (kotlin) {
183
191
  filename += '.kts';
184
192
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/android",
3
- "version": "0.7.0",
3
+ "version": "0.7.2",
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.9.0",
24
- "@e-mc/types": "^0.9.0",
23
+ "@e-mc/document": "^0.9.4",
24
+ "@e-mc/types": "^0.9.4",
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.2' apply false
3
- id 'com.android.library' version '8.3.2' 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.13.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.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
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.13.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.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
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
  }