@pi-r/android 0.3.1 → 0.3.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.
package/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2023 An Pham
1
+ Copyright 2023 Studio Trigger
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 Aina
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,7 +138,7 @@ 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);
@@ -174,10 +174,14 @@ function finalize(instance) {
174
174
  }
175
175
  }
176
176
  catch (err) {
177
- 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);
178
178
  }
179
179
  }
180
180
  }
181
181
  }
182
+ exports.default = finalize;
182
183
 
183
- module.exports = finalize;
184
+ if (exports.default) {
185
+ module.exports = exports.default;
186
+ module.exports.default = exports.default;
187
+ }
@@ -11,7 +11,7 @@ function finalize(instance) {
11
11
  return;
12
12
  }
13
13
  const detect = this.incremental !== 'staging';
14
- let { localUri, source, existing, kotlin } = instance.findTemplate(path.join(this.baseDirectory, config.mainParentDir), "build.gradle" /* GRADLE.FILENAME */, { detect, languageOf: 'gradle' });
14
+ let { localUri, source, existing, kotlin } = instance.findTemplate(path.join(this.baseDirectory, config.mainParentDir), "build.gradle", { detect, languageOf: 'gradle' });
15
15
  if (localUri && source && instance.canWrite(localUri, { ownPermissionOnly: true })) {
16
16
  let { namespace, javaVersion } = config, jvmTarget, modified;
17
17
  const upgrade = javaVersion > 0;
@@ -26,7 +26,7 @@ function finalize(instance) {
26
26
  if (!kotlin && items.some(value => value[1].endsWith('-ktx'))) {
27
27
  setModified(Document.updateGradle(source, ['plugins'], "id 'kotlin-android'", { multiple: true }));
28
28
  }
29
- const match = /dependencies\s+\{((?:{[^}]*}|(?![{}])[\S\s])+)\}/.exec(source);
29
+ const match = /dependencies\s+\{([^}]+)\}/.exec(source);
30
30
  if (match) {
31
31
  const writeImpl = (item) => 'implementation' + (kotlin ? `("${item.join(':')}")` : ` '${item.join(':')}'`);
32
32
  const pattern = kotlin ? /([ \t]*)implementation\((?:\s*"([^"]+)"\s*\))?/g : /([ \t]*)implementation(?:\s*\(?\s*["']([^"']+)["']\s*\)?|\s+((?:\s*(?:group|name|version)\s*:\s*["'][^"']+["']\s*,?){3}))?/g;
@@ -59,25 +59,12 @@ function finalize(instance) {
59
59
  if (version && (index = items.findIndex(seg => seg[0] === group && seg[1] === name)) !== -1) {
60
60
  found = 1;
61
61
  if (version[0] !== '$' || !kotlin && impl[0].indexOf("'") !== -1) {
62
- const semver = /^((\s*,\s*)?[([\]]((\s*,\s*)?\d+\.\d+(\s*,\s*)?)+[)\][])+$/;
63
- const pending = items[index][2];
64
- if (semver.test(pending)) {
65
- found = 2;
66
- }
67
- else if (!semver.test(version)) {
68
- const getArray = (value) => value.split(/[.-]/).map(seg => +seg);
69
- const current = getArray(pending);
70
- const previous = getArray(version);
71
- for (let i = 0; i < previous.length; ++i) {
72
- const a = previous[i];
73
- const b = current[i];
74
- if (isNaN(a) || b > a) {
75
- found = 2;
76
- break;
77
- }
78
- if (isNaN(b) || b < a) {
79
- break;
80
- }
62
+ const current = items[index][2].split('.').map(seg => +seg);
63
+ const parts = version.split('.');
64
+ for (let i = 0, value; i < parts.length; ++i) {
65
+ if (isNaN(value = +parts[i]) || +current[i] > value) {
66
+ found = 2;
67
+ break;
81
68
  }
82
69
  }
83
70
  }
@@ -110,9 +97,9 @@ function finalize(instance) {
110
97
  output = Document.updateGradle(output, ['android', 'buildFeatures'], 'compose = true');
111
98
  }
112
99
  else {
113
- 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.10" /* VERSIONS.KOTLIN_STDLIB */)}'` });
100
+ 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.0")}'` });
114
101
  output = Document.updateGradle(output, ['android', 'buildFeatures'], "compose true");
115
- output = Document.updateGradle(output, ['android', 'composeOptions'], `kotlinCompilerExtensionVersion '${instance.findVersion('kotlinCompilerExtensionVersion', "1.5.5" /* VERSIONS.KOTLIN_COMPILER */)}'`, true);
102
+ output = Document.updateGradle(output, ['android', 'composeOptions'], `kotlinCompilerExtensionVersion '${instance.findVersion('kotlinCompilerExtensionVersion', "1.5.0")}'`, true);
116
103
  if (upgrade) {
117
104
  output = Document.updateGradle(output, ['android', 'kotlinOptions'], `jvmTarget = '${javaVersion}'`, true);
118
105
  }
@@ -210,12 +197,12 @@ function finalize(instance) {
210
197
  }
211
198
  }
212
199
  catch (err) {
213
- this.writeFail(["Unable to write file" /* ERR_MESSAGE.WRITE_FILE */, path.basename(localUri)], err, 8192 /* LOG_TYPE.PERMISSION */);
200
+ this.writeFail(["Unable to write file", path.basename(localUri)], err, 8192);
214
201
  }
215
202
  }
216
203
  }
217
204
  if (!existing) {
218
- ({ localUri, source, existing, kotlin } = instance.findTemplate(this.baseDirectory, "build.gradle" /* GRADLE.FILENAME */, { detect, languageOf: 'gradle', subDir: 'static' }));
205
+ ({ localUri, source, existing, kotlin } = instance.findTemplate(this.baseDirectory, "build.gradle", { detect, languageOf: 'gradle', subDir: 'static' }));
219
206
  if (localUri && source && instance.canWrite(localUri, { ownPermissionOnly: true })) {
220
207
  try {
221
208
  if (instance.writeFile(localUri, source, { encoding: 'utf-8', ownPermissionOnly: true, throwsPermission: true })) {
@@ -223,10 +210,14 @@ function finalize(instance) {
223
210
  }
224
211
  }
225
212
  catch (err) {
226
- this.writeFail(["Unable to write file" /* ERR_MESSAGE.WRITE_FILE */, path.basename(localUri)], err, 8192 /* LOG_TYPE.PERMISSION */);
213
+ this.writeFail(["Unable to write file", path.basename(localUri)], err, 8192);
227
214
  }
228
215
  }
229
216
  }
230
217
  }
218
+ exports.default = finalize;
231
219
 
232
- module.exports = finalize;
220
+ if (exports.default) {
221
+ module.exports = exports.default;
222
+ module.exports.default = exports.default;
223
+ }
@@ -72,10 +72,14 @@ function finalize(instance) {
72
72
  }
73
73
  }
74
74
  catch (err) {
75
- this.writeFail(["Unable to write file" /* ERR_MESSAGE.WRITE_FILE */, path.basename(localUri)], err, 8192 /* LOG_TYPE.PERMISSION */);
75
+ this.writeFail(["Unable to write file", path.basename(localUri)], err, 8192);
76
76
  }
77
77
  }
78
78
  }
79
79
  }
80
+ exports.default = finalize;
80
81
 
81
- module.exports = finalize;
82
+ if (exports.default) {
83
+ module.exports = exports.default;
84
+ module.exports.default = exports.default;
85
+ }
@@ -5,7 +5,6 @@ const fs = require("fs");
5
5
  const child_process = require("child_process");
6
6
  const types_1 = require("@e-mc/types");
7
7
  const Document = require("@e-mc/document");
8
- const checkWin32 = (value) => value === "gradlew" /* STRINGS.GRADLEW */ && process.platform === 'win32' ? value + '.bat' : value;
9
8
  async function finalize(instance) {
10
9
  const commands = instance.config.commands;
11
10
  if (!commands || this.incremental === 'staging') {
@@ -28,7 +27,7 @@ async function finalize(instance) {
28
27
  }
29
28
  const settings = instance.settings.extensions?.task || {};
30
29
  const exec = settings.exec;
31
- let { broadcastId, baseDirectory } = this, command = settings.command, uid, gid, title, filename, foundCwd;
30
+ let { broadcastId, baseDirectory } = this, command = settings.command, uid, gid, title, name, foundCwd;
32
31
  if (command) {
33
32
  if (command.indexOf('mvn') !== -1) {
34
33
  title = 'maven';
@@ -37,20 +36,20 @@ async function finalize(instance) {
37
36
  title = /([^\\/]+?)(?:\.[a-z]+)?$/i.exec(command)?.[1] || 'SPAWN';
38
37
  }
39
38
  command = path.normalize(command);
40
- if (!/[\\/]/.test(command = path.normalize(command))) {
41
- filename = checkWin32(command);
39
+ if (!command.includes(path.sep)) {
40
+ name = command;
42
41
  }
43
42
  command = Document.sanitizeCmd(command);
44
43
  }
45
44
  else {
46
- filename = checkWin32("gradlew" /* STRINGS.GRADLEW */);
47
- command = '.' + path.sep + filename;
45
+ name = 'gradlew';
46
+ command = '.' + path.sep + name;
48
47
  title = 'gradle';
49
48
  }
50
- if (filename) {
49
+ if (name) {
51
50
  try {
52
51
  let appDir = baseDirectory;
53
- while (!(foundCwd = fs.existsSync(path.join(appDir, filename)))) {
52
+ while (!(foundCwd = fs.existsSync(path.join(appDir, name)))) {
54
53
  const parent = path.dirname(appDir);
55
54
  if (parent === appDir) {
56
55
  break;
@@ -80,9 +79,9 @@ async function finalize(instance) {
80
79
  const startTime = process.hrtime();
81
80
  const task = args.join(' ');
82
81
  await new Promise((resolve, reject) => {
83
- this.formatMessage(4 /* LOG_TYPE.PROCESS */, title, ['Executing task...', task], baseDirectory);
82
+ this.formatMessage(4, title, ['Executing task...', task], baseDirectory);
84
83
  let out = '', message = '';
85
- 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, uid, gid })
84
+ const { stdout, stderr } = child_process.spawn(command, Document.sanitizeArgs(args), { cwd: baseDirectory, shell: true, stdio: Document.hasLogType(32768) && !broadcastId ? 'inherit' : undefined, signal: instance.signal, uid, gid })
86
85
  .on('exit', code => {
87
86
  if (!code) {
88
87
  instance.addLog(types_1.STATUS_TYPE.INFO, out);
@@ -90,7 +89,7 @@ async function finalize(instance) {
90
89
  resolve();
91
90
  }
92
91
  else {
93
- 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));
92
+ reject((0, types_1.errorValue)(message || (!foundCwd && code === 1 ? "Unable to execute file" : "Unknown"), "Error code" + ': ' + code));
94
93
  }
95
94
  })
96
95
  .on('error', err => reject(err));
@@ -111,8 +110,12 @@ async function finalize(instance) {
111
110
  });
112
111
  }
113
112
  })
114
- .catch(err => instance.writeFail(["Unable to perform task" /* ERR_MESSAGE.PERFORM_TASK */, command + ' ' + task], err, { type: 4 /* LOG_TYPE.PROCESS */, startTime }));
113
+ .catch(err => instance.writeFail(["Unable to perform task", command + ' ' + task], err, { type: 4, startTime }));
115
114
  }
116
115
  }
116
+ exports.default = finalize;
117
117
 
118
- module.exports = finalize;
118
+ if (exports.default) {
119
+ module.exports = exports.default;
120
+ module.exports.default = exports.default;
121
+ }
package/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { IFileManager } from '@e-mc/types/types/lib';
1
+ import type { IFileManager } from '@e-mc/types/lib';
2
2
 
3
3
  import type { AndroidDocumentConstructor, DocumentAsset } from './types';
4
4
 
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);
@@ -189,12 +188,12 @@ class AndroidDocument extends Document {
189
188
  paths.push(filename);
190
189
  let uri;
191
190
  if (!existing && !(uri = this.resolveDir('template', ...paths)) && !fs.existsSync(uri = path.join(__dirname, 'template', ...paths))) {
192
- throw (0, types_1.errorValue)("File not found" /* ERR_MESSAGE.NOTFOUND_FILE */, uri);
191
+ throw (0, types_1.errorValue)("File not found", uri);
193
192
  }
194
193
  return { localUri, source: fs.readFileSync(uri || localUri, 'utf-8'), existing, kotlin, language };
195
194
  }
196
195
  catch (err) {
197
- this.writeFail(["Unable to read file" /* ERR_MESSAGE.READ_FILE */, path.basename(localUri)], err, 32 /* LOG_TYPE.FILE */);
196
+ this.writeFail(["Unable to read file", path.basename(localUri)], err, 32);
198
197
  }
199
198
  return { kotlin, language };
200
199
  }
@@ -217,5 +216,9 @@ class AndroidDocument extends Document {
217
216
  return (_a = this.module).settings || (_a.settings = {});
218
217
  }
219
218
  }
219
+ exports.default = AndroidDocument;
220
220
 
221
- module.exports = AndroidDocument;
221
+ if (exports.default) {
222
+ module.exports = exports.default;
223
+ module.exports.default = exports.default;
224
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/android",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
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.6.0",
24
- "@e-mc/types": "^0.6.0",
23
+ "@e-mc/document": "^0.6.1",
24
+ "@e-mc/types": "^0.6.1",
25
25
  "htmlparser2": "^9.0.0"
26
26
  }
27
27
  }
@@ -1,4 +1,4 @@
1
1
  plugins {
2
- id 'com.android.application' version '8.2.0' apply false
3
- id 'com.android.library' version '8.2.0' apply false
2
+ id 'com.android.application' version '8.1.0' apply false
3
+ id 'com.android.library' version '8.1.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.10.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.2.0' apply false
3
- id 'com.android.library' version '8.2.0' apply false
4
- id 'org.jetbrains.kotlin.android' version '1.9.10' apply false
2
+ id 'com.android.application' version '8.1.0' apply false
3
+ id 'com.android.library' version '8.1.0' apply false
4
+ id 'org.jetbrains.kotlin.android' version '1.9.0' 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.10")
42
- implementation("androidx.core:core-ktx:1.12.0")
41
+ implementation("org.jetbrains.kotlin:kotlin-stdlib:1.9.0")
42
+ implementation("androidx.core:core-ktx:1.10.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.2.0" apply false
3
- id("com.android.library") version "8.2.0" apply false
4
- id("org.jetbrains.kotlin.android") version "1.9.10" apply false
2
+ id("com.android.application") version "8.1.0" apply false
3
+ id("com.android.library") version "8.1.0" apply false
4
+ id("org.jetbrains.kotlin.android") version "1.9.0" apply false
5
5
  }