@pi-r/android 0.2.2 → 0.2.9

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/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2023 An Pham
1
+ Copyright 2020-24 Code Geass
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
4
 
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
- ### @pi-r/android
1
+ # @pi-r/android
2
2
 
3
- ### LICENSE
3
+ PEP 402 - Forever Josee + Nunnally
4
+
5
+ ## LICENSE
4
6
 
5
7
  MIT
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
2
  const path = require("path");
4
3
  const htmlparser2 = require("htmlparser2");
5
4
  const domhandler = require("domhandler");
@@ -14,7 +13,7 @@ function finalize(instance) {
14
13
  if (!config.manifest) {
15
14
  return;
16
15
  }
17
- let { localUri, source, existing } = instance.findTemplate(path.join(this.baseDirectory, config.mainParentDir, config.mainSrcDir), "AndroidManifest.xml" /* MANIFEST.FILENAME */, { detect: this.incremental !== 'staging' });
16
+ let { localUri, source, existing } = instance.findTemplate(path.join(this.baseDirectory, config.mainParentDir, config.mainSrcDir), "AndroidManifest.xml", { detect: this.incremental !== 'staging' });
18
17
  if (localUri && source && instance.canWrite(localUri, { ownPermissionOnly: true })) {
19
18
  const { package: manifestPackage, application = {} } = config.manifest;
20
19
  const { supportsRtl, label, theme, activity, metaData = [], activityName, fontProvider } = application;
@@ -41,7 +40,7 @@ function finalize(instance) {
41
40
  else if (manifestPackage || theme || activityName || activity || supportsRtl !== undefined) {
42
41
  new Parser(new DomHandler((err, dom) => {
43
42
  if (err) {
44
- instance.writeFail(['Unable to parse XML document', "AndroidManifest.xml" /* MANIFEST.FILENAME */], err, 0 /* LOG_TYPE.UNKNOWN */);
43
+ instance.writeFail(['Unable to parse XML document', "AndroidManifest.xml"], err, 0);
45
44
  return;
46
45
  }
47
46
  let target = null;
@@ -138,30 +137,31 @@ function finalize(instance) {
138
137
  if ((0, types_1.isArray)(metaData)) {
139
138
  new Parser(new DomHandler((err, dom) => {
140
139
  if (err) {
141
- instance.writeFail(['Unable to parse XML document', "AndroidManifest.xml" /* MANIFEST.FILENAME */], err, 0 /* LOG_TYPE.UNKNOWN */);
140
+ instance.writeFail(['Unable to parse XML document', "AndroidManifest.xml"], err, 0);
142
141
  return;
143
142
  }
144
143
  const app = domutils.findOne(elem => elem.tagName === 'application', dom, true);
145
- if (app) {
146
- for (const { name, resource, value } of metaData) {
147
- if (name && (resource || value)) {
148
- let item = domutils.findOne(elem => elem.tagName === 'meta-data' && elem.attribs['android:name'] === name, app.childNodes);
149
- if (!item) {
150
- domutils.appendChild(app, item = new domhandler.Element('meta-data', { 'android:name': name }));
151
- domutils.append(item, new domhandler.Text('\n'));
152
- }
153
- else if (item.attribs['android:resource'] === resource || item.attribs['android:value'] === value) {
154
- continue;
155
- }
156
- if (resource) {
157
- item.attribs['android:resource'] = resource;
158
- }
159
- if (value) {
160
- item.attribs['android:value'] = value;
161
- }
162
- source = domserializer.default(dom, { xmlMode: true });
163
- modified = true;
144
+ if (!app) {
145
+ return;
146
+ }
147
+ for (const { name, resource, value } of metaData) {
148
+ if (name && (resource || value)) {
149
+ let item = domutils.findOne(elem => elem.tagName === 'meta-data' && elem.attribs['android:name'] === name, app.childNodes);
150
+ if (!item) {
151
+ domutils.appendChild(app, item = new domhandler.Element('meta-data', { 'android:name': name }));
152
+ domutils.append(item, new domhandler.Text('\n'));
164
153
  }
154
+ else if (item.attribs['android:resource'] === resource || item.attribs['android:value'] === value) {
155
+ continue;
156
+ }
157
+ if (resource) {
158
+ item.attribs['android:resource'] = resource;
159
+ }
160
+ if (value) {
161
+ item.attribs['android:value'] = value;
162
+ }
163
+ source = domserializer.default(dom, { xmlMode: true });
164
+ modified = true;
165
165
  }
166
166
  }
167
167
  }), { xmlMode: true, decodeEntities: false }).end(source);
@@ -173,7 +173,7 @@ function finalize(instance) {
173
173
  }
174
174
  }
175
175
  catch (err) {
176
- this.writeFail(["Unable to write file" /* ERR_MESSAGE.WRITE_FILE */, path.basename(localUri)], err, 8192 /* LOG_TYPE.PERMISSION */);
176
+ this.writeFail(["Unable to write file", path.basename(localUri)], err, 8192);
177
177
  }
178
178
  }
179
179
  }
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
2
  const path = require("path");
4
3
  const util_1 = require("@e-mc/document/util");
5
4
  const types_1 = require("@e-mc/types");
@@ -55,18 +54,15 @@ function finalize(instance) {
55
54
  }
56
55
  if (group && name) {
57
56
  let found = 0, index = -1;
58
- if (version) {
59
- index = items.findIndex(seg => seg[0] === group && seg[1] === name);
60
- if (index !== -1) {
61
- found = 1;
62
- if (version[0] !== '$' || !kotlin && impl[0].indexOf("'") !== -1) {
63
- const current = items[index][2].split('.').map(seg => +seg);
64
- const parts = version.split('.');
65
- for (let i = 0, value; i < parts.length; ++i) {
66
- if (isNaN(value = +parts[i]) || +current[i] > value) {
67
- found = 2;
68
- break;
69
- }
57
+ if (version && (index = items.findIndex(seg => seg[0] === group && seg[1] === name)) !== -1) {
58
+ found = 1;
59
+ if (version[0] !== '$' || !kotlin && impl[0].indexOf("'") !== -1) {
60
+ const current = items[index][2].split('.').map(seg => +seg);
61
+ const parts = version.split('.');
62
+ for (let i = 0, value; i < parts.length; ++i) {
63
+ if (isNaN(value = +parts[i]) || +current[i] > value) {
64
+ found = 2;
65
+ break;
70
66
  }
71
67
  }
72
68
  }
@@ -99,9 +95,9 @@ function finalize(instance) {
99
95
  output = Document.updateGradle(output, ['android', 'buildFeatures'], 'compose = true');
100
96
  }
101
97
  else {
102
- output = Document.updateGradle(output, ['plugins'], "id 'org.jetbrains.kotlin.android'", { upgrade: true, multiple: true, addendum: `version '${instance.findVersion('org.jetbrains.kotlin:kotlin-stdlib', "1.8.21" /* VERSIONS.KOTLIN_STDLIB */)}'` });
98
+ 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.22")}'` });
103
99
  output = Document.updateGradle(output, ['android', 'buildFeatures'], "compose true");
104
- output = Document.updateGradle(output, ['android', 'composeOptions'], `kotlinCompilerExtensionVersion '${instance.findVersion('kotlinCompilerExtensionVersion', "1.4.6" /* VERSIONS.KOTLIN_COMPILER */)}'`, true);
100
+ output = Document.updateGradle(output, ['android', 'composeOptions'], `kotlinCompilerExtensionVersion '${instance.findVersion('kotlinCompilerExtensionVersion', "1.5.9")}'`, true);
105
101
  if (upgrade) {
106
102
  output = Document.updateGradle(output, ['android', 'kotlinOptions'], `jvmTarget = '${javaVersion}'`, true);
107
103
  }
@@ -199,7 +195,7 @@ function finalize(instance) {
199
195
  }
200
196
  }
201
197
  catch (err) {
202
- this.writeFail(["Unable to write file" /* ERR_MESSAGE.WRITE_FILE */, path.basename(localUri)], err, 8192 /* LOG_TYPE.PERMISSION */);
198
+ this.writeFail(["Unable to write file", path.basename(localUri)], err, 8192);
203
199
  }
204
200
  }
205
201
  }
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
2
  const path = require("path");
4
3
  const util_1 = require("@e-mc/document/util");
5
4
  const parse_1 = require("@e-mc/document/parse");
@@ -69,7 +68,7 @@ function finalize(instance) {
69
68
  }
70
69
  }
71
70
  catch (err) {
72
- this.writeFail(["Unable to write file" /* ERR_MESSAGE.WRITE_FILE */, path.basename(localUri)], err, 8192 /* LOG_TYPE.PERMISSION */);
71
+ this.writeFail(["Unable to write file", path.basename(localUri)], err, 8192);
73
72
  }
74
73
  }
75
74
  }
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
2
  const path = require("path");
4
3
  const fs = require("fs");
5
4
  const child_process = require("child_process");
@@ -68,9 +67,9 @@ async function finalize(instance) {
68
67
  const startTime = process.hrtime();
69
68
  const task = args.join(' ');
70
69
  await new Promise((resolve, reject) => {
71
- this.formatMessage(4 /* LOG_TYPE.PROCESS */, title, ['Executing task...', task], baseDirectory);
70
+ this.formatMessage(4, title, ['Executing task...', task], baseDirectory);
72
71
  let out = '', message = '';
73
- const { stdout, stderr } = child_process.spawn(command, Document.sanitizeArgs(args), { cwd: baseDirectory, shell: true, stdio: Document.hasLogType(32768 /* LOG_TYPE.STDOUT */) && !broadcastId ? 'inherit' : undefined, signal: instance.signal })
72
+ const { stdout, stderr } = child_process.spawn(command, Document.sanitizeArgs(args), { cwd: baseDirectory, shell: true, stdio: Document.hasLogType(32768) && !broadcastId ? 'inherit' : undefined, signal: instance.signal })
74
73
  .on('exit', code => {
75
74
  if (!code) {
76
75
  instance.addLog(types_1.STATUS_TYPE.INFO, out);
@@ -78,7 +77,7 @@ async function finalize(instance) {
78
77
  resolve();
79
78
  }
80
79
  else {
81
- reject((0, types_1.errorValue)(message || (!foundCwd && code === 1 ? "Unable to execute file" /* ERR_MESSAGE.EXECUTE_FILE */ : "Unknown" /* ERR_MESSAGE.UNKNOWN */), "Error code" /* ERR_MESSAGE.ERROR_CODE */ + ': ' + code));
80
+ reject((0, types_1.errorValue)(message || (!foundCwd && code === 1 ? "Unable to execute file" : "Unknown"), "Error code" + ': ' + code));
82
81
  }
83
82
  })
84
83
  .on('error', err => reject(err));
@@ -99,7 +98,7 @@ async function finalize(instance) {
99
98
  });
100
99
  }
101
100
  })
102
- .catch(err => instance.writeFail(["Unable to perform task" /* ERR_MESSAGE.PERFORM_TASK */, command + ' ' + task], err, { type: 4 /* LOG_TYPE.PROCESS */, startTime }));
101
+ .catch(err => instance.writeFail(["Unable to perform task", command + ' ' + task], err, { type: 4, startTime }));
103
102
  }
104
103
  }
105
104
 
package/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import type { IFileManager } from '@e-mc/types/types/lib';
2
-
3
- import type { AndroidDocumentConstructor, DocumentAsset } from './types';
4
-
5
- declare const Android: AndroidDocumentConstructor<IFileManager<DocumentAsset>>;
6
-
1
+ import type { IFileManager } from '@e-mc/types/lib';
2
+
3
+ import type { AndroidDocumentConstructor, DocumentAsset } from './types';
4
+
5
+ declare const Android: AndroidDocumentConstructor<IFileManager<DocumentAsset>>;
6
+
7
7
  export = Android;
package/index.js CHANGED
@@ -1,10 +1,8 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
2
  const fs = require("fs");
4
3
  const path = require("path");
5
4
  const types_1 = require("@e-mc/types");
6
5
  const Document = require('@e-mc/document');
7
- // @ts-ignore
8
6
  class AndroidDocument extends Document {
9
7
  constructor() {
10
8
  super(...arguments);
@@ -151,7 +149,7 @@ class AndroidDocument extends Document {
151
149
  await instance.tryFile(buffer, localUri, { format: 'ttf', etag: file.etag }, (err, result) => {
152
150
  if (err) {
153
151
  host.deleteFile(localUri);
154
- host.writeFail("Unable to compress file" /* ERR_MESSAGE.COMPRESS_FILE */, err, 8 /* LOG_TYPE.COMPRESS */);
152
+ host.writeFail("Unable to compress file", err, 8);
155
153
  }
156
154
  else if ((0, types_1.isString)(result)) {
157
155
  host.replace(file, result);
@@ -182,12 +180,12 @@ class AndroidDocument extends Document {
182
180
  const paths = language ? [language, filename] : [filename];
183
181
  let uri;
184
182
  if (!existing && !(uri = this.resolveDir('template', ...paths)) && !fs.existsSync(uri = path.join(__dirname, 'template', ...paths))) {
185
- throw (0, types_1.errorValue)("File not found" /* ERR_MESSAGE.NOTFOUND_FILE */, uri);
183
+ throw (0, types_1.errorValue)("File not found", uri);
186
184
  }
187
185
  return { localUri, source: fs.readFileSync(uri || localUri, 'utf-8'), existing, kotlin, language };
188
186
  }
189
187
  catch (err) {
190
- this.writeFail(["Unable to read file" /* ERR_MESSAGE.READ_FILE */, path.basename(localUri)], err, 32 /* LOG_TYPE.FILE */);
188
+ this.writeFail(["Unable to read file", path.basename(localUri)], err, 32);
191
189
  }
192
190
  return { kotlin, language };
193
191
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/android",
3
- "version": "0.2.2",
3
+ "version": "0.2.9",
4
4
  "description": "Android document constructor for E-mc.",
5
5
  "main": "index.js",
6
6
  "publishConfig": {
@@ -8,7 +8,7 @@
8
8
  },
9
9
  "repository": {
10
10
  "type": "git",
11
- "url": "https://github.com/anpham6/pi-r.git",
11
+ "url": "git+https://github.com/anpham6/pi-r.git",
12
12
  "directory": "src/module/android"
13
13
  },
14
14
  "keywords": [
@@ -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.5.3",
24
- "@e-mc/types": "^0.5.3",
23
+ "@e-mc/document": "^0.5.5",
24
+ "@e-mc/types": "^0.5.5",
25
25
  "htmlparser2": "^9.0.0"
26
26
  }
27
27
  }
@@ -4,12 +4,12 @@ plugins {
4
4
 
5
5
  android {
6
6
  namespace ''
7
- compileSdk 33
7
+ compileSdk 34
8
8
 
9
9
  defaultConfig {
10
10
  applicationId ''
11
- minSdk 19
12
- targetSdk 33
11
+ minSdk 21
12
+ targetSdk 34
13
13
  versionCode 1
14
14
  versionName '1.0'
15
15
 
@@ -1,8 +1,8 @@
1
1
  pluginManagement {
2
2
  repositories {
3
- gradlePluginPortal()
4
3
  google()
5
4
  mavenCentral()
5
+ gradlePluginPortal()
6
6
  }
7
7
  }
8
8
 
@@ -5,12 +5,12 @@ plugins {
5
5
 
6
6
  android {
7
7
  namespace ''
8
- compileSdk 33
8
+ compileSdk 34
9
9
 
10
10
  defaultConfig {
11
11
  applicationId ''
12
- minSdk 19
13
- targetSdk 33
12
+ minSdk 21
13
+ targetSdk 34
14
14
  versionCode 1
15
15
  versionName '1.0'
16
16
 
@@ -37,7 +37,7 @@ android {
37
37
  }
38
38
 
39
39
  dependencies {
40
- implementation 'androidx.core:core-ktx:1.10.0'
40
+ implementation 'androidx.core:core-ktx:1.12.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,8 +1,8 @@
1
1
  pluginManagement {
2
2
  repositories {
3
- gradlePluginPortal()
4
3
  google()
5
4
  mavenCentral()
5
+ gradlePluginPortal()
6
6
  }
7
7
  }
8
8
 
@@ -1,23 +1,23 @@
1
1
  plugins {
2
2
  id("com.android.application")
3
- kotlin("android")
3
+ id("org.jetbrains.kotlin.android")
4
4
  }
5
5
 
6
6
  android {
7
7
  namespace = ""
8
- compileSdk(33)
8
+ compileSdk = 34
9
9
 
10
10
  defaultConfig {
11
11
  applicationId = ""
12
- minSdk(19)
13
- targetSdk(33)
12
+ minSdk = 21
13
+ targetSdk = 34
14
14
  versionCode = 1
15
15
  versionName = "1.0"
16
16
 
17
17
  testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
18
18
  }
19
19
  buildTypes {
20
- getByName("release") {
20
+ release {
21
21
  isDebuggable = false
22
22
  isMinifyEnabled = true
23
23
  isShrinkResources = false
@@ -38,8 +38,8 @@ java {
38
38
  }
39
39
 
40
40
  dependencies {
41
- implementation("org.jetbrains.kotlin:kotlin-stdlib:1.8.21")
42
- implementation("androidx.core:core-ktx:1.10.0")
41
+ implementation("org.jetbrains.kotlin:kotlin-stdlib:1.9.22")
42
+ implementation("androidx.core:core-ktx:1.12.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,18 +1,18 @@
1
- pluginManagement {
2
- repositories {
3
- gradlePluginPortal()
4
- google()
5
- mavenCentral()
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}}")