@pi-r/android 0.2.1 → 0.2.8

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 2023 Mile Square Park
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
4
+
5
+ ## LICENSE
4
6
 
5
7
  MIT
@@ -14,7 +14,7 @@ function finalize(instance) {
14
14
  if (!config.manifest) {
15
15
  return;
16
16
  }
17
- let { localUri, source, existing } = instance.findTemplate(path.join(this.baseDirectory, config.mainParentDir, config.mainSrcDir), "AndroidManifest.xml" /* MANIFEST.FILENAME */, { detect: this.incremental !== 'staging' });
17
+ let { localUri, source, existing } = instance.findTemplate(path.join(this.baseDirectory, config.mainParentDir, config.mainSrcDir), "AndroidManifest.xml", { detect: this.incremental !== 'staging' });
18
18
  if (localUri && source && instance.canWrite(localUri, { ownPermissionOnly: true })) {
19
19
  const { package: manifestPackage, application = {} } = config.manifest;
20
20
  const { supportsRtl, label, theme, activity, metaData = [], activityName, fontProvider } = application;
@@ -41,7 +41,7 @@ function finalize(instance) {
41
41
  else if (manifestPackage || theme || activityName || activity || supportsRtl !== undefined) {
42
42
  new Parser(new DomHandler((err, dom) => {
43
43
  if (err) {
44
- instance.writeFail(['Unable to parse XML document', "AndroidManifest.xml" /* MANIFEST.FILENAME */], err, 0 /* LOG_TYPE.UNKNOWN */);
44
+ instance.writeFail(['Unable to parse XML document', "AndroidManifest.xml"], err, 0);
45
45
  return;
46
46
  }
47
47
  let target = null;
@@ -138,30 +138,31 @@ function finalize(instance) {
138
138
  if ((0, types_1.isArray)(metaData)) {
139
139
  new Parser(new DomHandler((err, dom) => {
140
140
  if (err) {
141
- instance.writeFail(['Unable to parse XML document', "AndroidManifest.xml" /* MANIFEST.FILENAME */], err, 0 /* LOG_TYPE.UNKNOWN */);
141
+ instance.writeFail(['Unable to parse XML document', "AndroidManifest.xml"], err, 0);
142
142
  return;
143
143
  }
144
144
  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;
145
+ if (!app) {
146
+ return;
147
+ }
148
+ for (const { name, resource, value } of metaData) {
149
+ if (name && (resource || value)) {
150
+ let item = domutils.findOne(elem => elem.tagName === 'meta-data' && elem.attribs['android:name'] === name, app.childNodes);
151
+ if (!item) {
152
+ domutils.appendChild(app, item = new domhandler.Element('meta-data', { 'android:name': name }));
153
+ domutils.append(item, new domhandler.Text('\n'));
164
154
  }
155
+ else if (item.attribs['android:resource'] === resource || item.attribs['android:value'] === value) {
156
+ continue;
157
+ }
158
+ if (resource) {
159
+ item.attribs['android:resource'] = resource;
160
+ }
161
+ if (value) {
162
+ item.attribs['android:value'] = value;
163
+ }
164
+ source = domserializer.default(dom, { xmlMode: true });
165
+ modified = true;
165
166
  }
166
167
  }
167
168
  }), { xmlMode: true, decodeEntities: false }).end(source);
@@ -173,10 +174,14 @@ function finalize(instance) {
173
174
  }
174
175
  }
175
176
  catch (err) {
176
- this.writeFail(["Unable to write file" /* ERR_MESSAGE.WRITE_FILE */, path.basename(localUri)], err, 8192 /* LOG_TYPE.PERMISSION */);
177
+ this.writeFail(["Unable to write file", path.basename(localUri)], err, 8192);
177
178
  }
178
179
  }
179
180
  }
180
181
  }
182
+ exports.default = finalize;
181
183
 
182
- module.exports = finalize;
184
+ if (exports.default) {
185
+ module.exports = exports.default;
186
+ module.exports.default = exports.default;
187
+ }
@@ -55,18 +55,15 @@ function finalize(instance) {
55
55
  }
56
56
  if (group && name) {
57
57
  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
- }
58
+ if (version && (index = items.findIndex(seg => seg[0] === group && seg[1] === name)) !== -1) {
59
+ found = 1;
60
+ if (version[0] !== '$' || !kotlin && impl[0].indexOf("'") !== -1) {
61
+ const current = items[index][2].split('.').map(seg => +seg);
62
+ const parts = version.split('.');
63
+ for (let i = 0, value; i < parts.length; ++i) {
64
+ if (isNaN(value = +parts[i]) || +current[i] > value) {
65
+ found = 2;
66
+ break;
70
67
  }
71
68
  }
72
69
  }
@@ -99,9 +96,9 @@ function finalize(instance) {
99
96
  output = Document.updateGradle(output, ['android', 'buildFeatures'], 'compose = true');
100
97
  }
101
98
  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 */)}'` });
99
+ 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
100
  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);
101
+ output = Document.updateGradle(output, ['android', 'composeOptions'], `kotlinCompilerExtensionVersion '${instance.findVersion('kotlinCompilerExtensionVersion', "1.5.9")}'`, true);
105
102
  if (upgrade) {
106
103
  output = Document.updateGradle(output, ['android', 'kotlinOptions'], `jvmTarget = '${javaVersion}'`, true);
107
104
  }
@@ -199,10 +196,14 @@ function finalize(instance) {
199
196
  }
200
197
  }
201
198
  catch (err) {
202
- this.writeFail(["Unable to write file" /* ERR_MESSAGE.WRITE_FILE */, path.basename(localUri)], err, 8192 /* LOG_TYPE.PERMISSION */);
199
+ this.writeFail(["Unable to write file", path.basename(localUri)], err, 8192);
203
200
  }
204
201
  }
205
202
  }
206
203
  }
204
+ exports.default = finalize;
207
205
 
208
- module.exports = finalize;
206
+ if (exports.default) {
207
+ module.exports = exports.default;
208
+ module.exports.default = exports.default;
209
+ }
@@ -69,10 +69,14 @@ function finalize(instance) {
69
69
  }
70
70
  }
71
71
  catch (err) {
72
- this.writeFail(["Unable to write file" /* ERR_MESSAGE.WRITE_FILE */, path.basename(localUri)], err, 8192 /* LOG_TYPE.PERMISSION */);
72
+ this.writeFail(["Unable to write file", path.basename(localUri)], err, 8192);
73
73
  }
74
74
  }
75
75
  }
76
76
  }
77
+ exports.default = finalize;
77
78
 
78
- module.exports = finalize;
79
+ if (exports.default) {
80
+ module.exports = exports.default;
81
+ module.exports.default = exports.default;
82
+ }
@@ -68,9 +68,9 @@ async function finalize(instance) {
68
68
  const startTime = process.hrtime();
69
69
  const task = args.join(' ');
70
70
  await new Promise((resolve, reject) => {
71
- this.formatMessage(4 /* LOG_TYPE.PROCESS */, title, ['Executing task...', task], baseDirectory);
71
+ this.formatMessage(4, title, ['Executing task...', task], baseDirectory);
72
72
  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 })
73
+ 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
74
  .on('exit', code => {
75
75
  if (!code) {
76
76
  instance.addLog(types_1.STATUS_TYPE.INFO, out);
@@ -78,7 +78,7 @@ async function finalize(instance) {
78
78
  resolve();
79
79
  }
80
80
  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));
81
+ reject((0, types_1.errorValue)(message || (!foundCwd && code === 1 ? "Unable to execute file" : "Unknown"), "Error code" + ': ' + code));
82
82
  }
83
83
  })
84
84
  .on('error', err => reject(err));
@@ -99,8 +99,12 @@ async function finalize(instance) {
99
99
  });
100
100
  }
101
101
  })
102
- .catch(err => instance.writeFail(["Unable to perform task" /* ERR_MESSAGE.PERFORM_TASK */, command + ' ' + task], err, { type: 4 /* LOG_TYPE.PROCESS */, startTime }));
102
+ .catch(err => instance.writeFail(["Unable to perform task", command + ' ' + task], err, { type: 4, startTime }));
103
103
  }
104
104
  }
105
+ exports.default = finalize;
105
106
 
106
- module.exports = finalize;
107
+ if (exports.default) {
108
+ module.exports = exports.default;
109
+ module.exports.default = exports.default;
110
+ }
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/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
@@ -4,7 +4,6 @@ const fs = require("fs");
4
4
  const path = require("path");
5
5
  const types_1 = require("@e-mc/types");
6
6
  const Document = require('@e-mc/document');
7
- // @ts-ignore
8
7
  class AndroidDocument extends Document {
9
8
  constructor() {
10
9
  super(...arguments);
@@ -151,7 +150,7 @@ class AndroidDocument extends Document {
151
150
  await instance.tryFile(buffer, localUri, { format: 'ttf', etag: file.etag }, (err, result) => {
152
151
  if (err) {
153
152
  host.deleteFile(localUri);
154
- host.writeFail("Unable to compress file" /* ERR_MESSAGE.COMPRESS_FILE */, err, 8 /* LOG_TYPE.COMPRESS */);
153
+ host.writeFail("Unable to compress file", err, 8);
155
154
  }
156
155
  else if ((0, types_1.isString)(result)) {
157
156
  host.replace(file, result);
@@ -182,12 +181,12 @@ class AndroidDocument extends Document {
182
181
  const paths = language ? [language, filename] : [filename];
183
182
  let uri;
184
183
  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);
184
+ throw (0, types_1.errorValue)("File not found", uri);
186
185
  }
187
186
  return { localUri, source: fs.readFileSync(uri || localUri, 'utf-8'), existing, kotlin, language };
188
187
  }
189
188
  catch (err) {
190
- this.writeFail(["Unable to read file" /* ERR_MESSAGE.READ_FILE */, path.basename(localUri)], err, 32 /* LOG_TYPE.FILE */);
189
+ this.writeFail(["Unable to read file", path.basename(localUri)], err, 32);
191
190
  }
192
191
  return { kotlin, language };
193
192
  }
@@ -210,5 +209,9 @@ class AndroidDocument extends Document {
210
209
  return (_a = this.module).settings || (_a.settings = {});
211
210
  }
212
211
  }
212
+ exports.default = AndroidDocument;
213
213
 
214
- module.exports = AndroidDocument;
214
+ if (exports.default) {
215
+ module.exports = exports.default;
216
+ module.exports.default = exports.default;
217
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/android",
3
- "version": "0.2.1",
3
+ "version": "0.2.8",
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.2",
24
- "@e-mc/types": "^0.5.2",
25
- "htmlparser2": "^8.0.2"
23
+ "@e-mc/document": "^0.5.4",
24
+ "@e-mc/types": "^0.5.4",
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
 
@@ -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'
@@ -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
 
@@ -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
+ 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}}"
18
18
  include("{{name}}")