@pi-r/android 0.10.2 → 0.11.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.
@@ -151,17 +151,16 @@ function applyAttributes(target, keys) {
151
151
  }
152
152
  function finalize(instance) {
153
153
  const config = instance.config;
154
- const manifest = config.manifest;
155
- if (!manifest) {
154
+ if (!config.manifest) {
156
155
  return;
157
156
  }
158
157
  let { localUri, source, existing } = instance.findTemplate(path.join(this.baseDirectory, config.mainParentDir, config.mainSrcDir), "AndroidManifest.xml", { detect: instance.detect(this) });
159
158
  if (localUri && source && instance.canWrite(localUri, { ownPermissionOnly: true })) {
160
- const application = manifest.application || {};
159
+ const application = config.manifest.application || {};
161
160
  const { supportsRtl, label, theme, activity, metaData = [], activityName, fontProvider } = application;
162
161
  const profileable = config.profileable;
163
162
  const applicationKeys = getValidKeys(instance, application, APPLICATION_ATTR);
164
- const manifestKeys = getValidKeys(instance, manifest, MANIFEST_ATTR);
163
+ const manifestKeys = getValidKeys(instance, config.manifest, MANIFEST_ATTR);
165
164
  let modified = false;
166
165
  if (!existing) {
167
166
  source = (0, util_1.replaceAll)(source, (name) => {
@@ -434,7 +434,7 @@ function finalize(instance) {
434
434
  output = Document.updateGradle(output, ['android', 'buildFeatures'], 'compose = true');
435
435
  }
436
436
  else {
437
- const stdLib = instance.findVersion('org.jetbrains.kotlin:kotlin-stdlib', "2.2.0");
437
+ const stdLib = instance.findVersion('org.jetbrains.kotlin:kotlin-stdlib', "2.2.20");
438
438
  output = Document.updateGradle(output, ['plugins'], "id 'org.jetbrains.kotlin.android'", { upgrade: true, multiple: true, addendum: `version '${stdLib}'` });
439
439
  output = Document.updateGradle(output, ['android', 'buildFeatures'], "compose true");
440
440
  if (stdLib.startsWith('1.')) {
@@ -638,13 +638,13 @@ function finalize(instance) {
638
638
  }
639
639
  if (!existing) {
640
640
  const detect = instance.detect(this);
641
+ const projectDir = instance.resolveDir('project');
641
642
  const template = instance.findTemplate(this.baseDirectory, "build.gradle", { detect, languageOf: 'gradle', subDir: 'static' });
642
- instance.writeTemplate(template, this);
643
643
  const properties = instance.findTemplate(this.baseDirectory, "gradle.properties", { detect, subDir: [instance.languageOf('gradle') || 'java', 'static'] });
644
+ instance.writeTemplate(template, this);
644
645
  instance.writeTemplate(properties, this);
645
- try {
646
- const projectDir = instance.resolveDir('project');
647
- if (projectDir) {
646
+ if (projectDir) {
647
+ try {
648
648
  (function recurse(subDir, targetDir) {
649
649
  fs.readdirSync(subDir, { withFileTypes: true }).forEach(item => {
650
650
  const srcName = path.join(subDir, item.name);
@@ -676,9 +676,9 @@ function finalize(instance) {
676
676
  });
677
677
  }).call(this, projectDir, './');
678
678
  }
679
- }
680
- catch (err) {
681
- this.writeFail("Path not found", err, 32);
679
+ catch (err) {
680
+ this.writeFail("Path not found", err, 32);
681
+ }
682
682
  }
683
683
  }
684
684
  }
@@ -15,10 +15,9 @@ function finalize(instance) {
15
15
  if (dependencies) {
16
16
  found: {
17
17
  const pattern = kotlin ? /^\s*include\(((?:\s*"[^"]+"\s*,?\s*)+)\)/gm : /^\s*include\s*((?:(?:"[^"]+"|'[^']+')\s*,?\s*)+)/gm;
18
- let match;
18
+ let match, app;
19
19
  while (match = pattern.exec(source)) {
20
20
  const namespace = /":?([^"]+)"|':?([^']+)'/g;
21
- let app;
22
21
  while (app = namespace.exec(match[1])) {
23
22
  if (app[1] === mainParentDir || app[2] === mainParentDir) {
24
23
  break found;
@@ -100,22 +100,18 @@ async function finalize(instance) {
100
100
  }
101
101
  })
102
102
  .on('error', reject);
103
- if (stdout) {
104
- stdout.setEncoding('utf8').on('data', (value) => {
105
- if (broadcastId) {
106
- this.formatMessage(4, '', value, null, { sessionId: '' });
107
- }
108
- out += value;
109
- });
110
- }
111
- if (stderr) {
112
- stderr.setEncoding('utf8').on('data', (value) => {
113
- if (broadcastId) {
114
- this.formatMessage(2, '', value, null, { sessionId: '' });
115
- }
116
- message += value;
117
- });
118
- }
103
+ stdout?.setEncoding('utf8').on('data', (value) => {
104
+ if (broadcastId) {
105
+ this.formatMessage(4, '', value, null, { sessionId: '' });
106
+ }
107
+ out += value;
108
+ });
109
+ stderr?.setEncoding('utf8').on('data', (value) => {
110
+ if (broadcastId) {
111
+ this.formatMessage(2, '', value, null, { sessionId: '' });
112
+ }
113
+ message += value;
114
+ });
119
115
  })
120
116
  .catch((err) => {
121
117
  instance.writeFail(["Unable to perform task", command + ' ' + task], err, { type: 4, startTime });
package/index.js CHANGED
@@ -4,6 +4,7 @@ const path = require("node:path");
4
4
  const types_1 = require("@e-mc/types");
5
5
  const Document = require('@e-mc/document');
6
6
  const kAndroid = Symbol.for('android:constructor');
7
+ const sanitizePath = (value) => Document.PLATFORM_WIN32 ? value.replace(/^\.?[\\/]+/, '').replace(/[\\/]+$/, '') : value.replace(/^\.?\/+/, '').replace(/\/+$/, '');
7
8
  class AndroidDocument extends Document {
8
9
  static [kAndroid] = true;
9
10
  static async finalize(instance) {
@@ -72,10 +73,10 @@ class AndroidDocument extends Document {
72
73
  target.applicationId = applicationId;
73
74
  }
74
75
  if (mainParentDir) {
75
- target.mainParentDir = mainParentDir;
76
+ target.mainParentDir = sanitizePath(mainParentDir);
76
77
  }
77
78
  if (mainSrcDir) {
78
- target.mainSrcDir = mainSrcDir;
79
+ target.mainSrcDir = sanitizePath(mainSrcDir);
79
80
  }
80
81
  if (mainActivityFile) {
81
82
  target.mainActivityFile = mainActivityFile;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/android",
3
- "version": "0.10.2",
3
+ "version": "0.11.0",
4
4
  "description": "Android document constructor for E-mc.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -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.12.5",
24
- "@e-mc/types": "^0.12.5",
23
+ "@e-mc/document": "^0.13.0",
24
+ "@e-mc/types": "^0.13.0",
25
25
  "dom-serializer": "^2.0.0",
26
26
  "domhandler": "^5.0.3",
27
27
  "domutils": "^3.2.2",
@@ -1,5 +1,5 @@
1
1
  distributionBase=GRADLE_USER_HOME
2
2
  distributionPath=wrapper/dists
3
- distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
3
+ distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.1-bin.zip
4
4
  zipStoreBase=GRADLE_USER_HOME
5
5
  zipStorePath=wrapper/dists
@@ -34,6 +34,6 @@ android {
34
34
 
35
35
  dependencies {
36
36
  testImplementation 'junit:junit:4.13.2'
37
- androidTestImplementation 'androidx.test.ext:junit:1.2.1'
38
- androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
37
+ androidTestImplementation 'androidx.test.ext:junit:1.3.0'
38
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.7.0'
39
39
  }
@@ -1,18 +1,18 @@
1
- pluginManagement {
2
- repositories {
3
- google()
4
- mavenCentral()
5
- gradlePluginPortal()
6
- }
7
- }
8
-
9
- dependencyResolutionManagement {
10
- repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
11
- repositories {
12
- google()
13
- mavenCentral()
14
- }
15
- }
16
-
17
- rootProject.name = '{{projectName}}'
1
+ pluginManagement {
2
+ repositories {
3
+ google()
4
+ mavenCentral()
5
+ gradlePluginPortal()
6
+ }
7
+ }
8
+
9
+ dependencyResolutionManagement {
10
+ repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
11
+ repositories {
12
+ google()
13
+ mavenCentral()
14
+ }
15
+ }
16
+
17
+ rootProject.name = '{{projectName}}'
18
18
  include '{{name}}'
@@ -1,4 +1,4 @@
1
1
  plugins {
2
- id 'com.android.application' version '8.12.0' apply false
3
- id 'com.android.library' version '8.12.0' apply false
2
+ id 'com.android.application' version '8.13.0' apply false
3
+ id 'com.android.library' version '8.13.0' apply false
4
4
  }
@@ -1,10 +1,10 @@
1
1
  [versions]
2
- agp = "8.12.0"
3
- kotlin = "2.2.0"
4
- coreKtx = "1.16.0"
2
+ agp = "8.13.0"
3
+ kotlin = "2.2.20"
4
+ coreKtx = "1.17.0"
5
5
  junit = "4.13.2"
6
- junitVersion = "1.2.1"
7
- espressoCore = "3.6.1"
6
+ junitVersion = "1.3.0"
7
+ espressoCore = "3.7.0"
8
8
 
9
9
  [libraries]
10
10
  androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
@@ -1,12 +1,12 @@
1
1
  [versions]
2
- agp = "8.12.0"
3
- kotlin = "2.2.0"
4
- coreKtx = "1.16.0"
2
+ agp = "8.13.0"
3
+ kotlin = "2.2.20"
4
+ coreKtx = "1.17.0"
5
5
  junit = "4.13.2"
6
- junitVersion = "1.2.1"
7
- espressoCore = "3.6.1"
6
+ junitVersion = "1.3.0"
7
+ espressoCore = "3.7.0"
8
8
  appcompat = "1.7.1"
9
- material = "1.12.0"
9
+ material = "1.13.0"
10
10
  constraintlayout = "2.2.1"
11
11
 
12
12
  [libraries]