@pi-r/android 0.3.1 → 0.3.3

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 Lisa Mishima
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
@@ -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,7 +137,7 @@ 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);
@@ -174,7 +173,7 @@ function finalize(instance) {
174
173
  }
175
174
  }
176
175
  catch (err) {
177
- 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);
178
177
  }
179
178
  }
180
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");
@@ -11,7 +10,7 @@ function finalize(instance) {
11
10
  return;
12
11
  }
13
12
  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' });
13
+ let { localUri, source, existing, kotlin } = instance.findTemplate(path.join(this.baseDirectory, config.mainParentDir), "build.gradle", { detect, languageOf: 'gradle' });
15
14
  if (localUri && source && instance.canWrite(localUri, { ownPermissionOnly: true })) {
16
15
  let { namespace, javaVersion } = config, jvmTarget, modified;
17
16
  const upgrade = javaVersion > 0;
@@ -26,7 +25,7 @@ function finalize(instance) {
26
25
  if (!kotlin && items.some(value => value[1].endsWith('-ktx'))) {
27
26
  setModified(Document.updateGradle(source, ['plugins'], "id 'kotlin-android'", { multiple: true }));
28
27
  }
29
- const match = /dependencies\s+\{((?:{[^}]*}|(?![{}])[\S\s])+)\}/.exec(source);
28
+ const match = /dependencies\s+\{([^}]+)\}/.exec(source);
30
29
  if (match) {
31
30
  const writeImpl = (item) => 'implementation' + (kotlin ? `("${item.join(':')}")` : ` '${item.join(':')}'`);
32
31
  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 +58,12 @@ function finalize(instance) {
59
58
  if (version && (index = items.findIndex(seg => seg[0] === group && seg[1] === name)) !== -1) {
60
59
  found = 1;
61
60
  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
- }
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;
81
67
  }
82
68
  }
83
69
  }
@@ -110,9 +96,9 @@ function finalize(instance) {
110
96
  output = Document.updateGradle(output, ['android', 'buildFeatures'], 'compose = true');
111
97
  }
112
98
  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 */)}'` });
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")}'` });
114
100
  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);
101
+ output = Document.updateGradle(output, ['android', 'composeOptions'], `kotlinCompilerExtensionVersion '${instance.findVersion('kotlinCompilerExtensionVersion', "1.5.9")}'`, true);
116
102
  if (upgrade) {
117
103
  output = Document.updateGradle(output, ['android', 'kotlinOptions'], `jvmTarget = '${javaVersion}'`, true);
118
104
  }
@@ -210,12 +196,12 @@ function finalize(instance) {
210
196
  }
211
197
  }
212
198
  catch (err) {
213
- 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);
214
200
  }
215
201
  }
216
202
  }
217
203
  if (!existing) {
218
- ({ localUri, source, existing, kotlin } = instance.findTemplate(this.baseDirectory, "build.gradle" /* GRADLE.FILENAME */, { detect, languageOf: 'gradle', subDir: 'static' }));
204
+ ({ localUri, source, existing, kotlin } = instance.findTemplate(this.baseDirectory, "build.gradle", { detect, languageOf: 'gradle', subDir: 'static' }));
219
205
  if (localUri && source && instance.canWrite(localUri, { ownPermissionOnly: true })) {
220
206
  try {
221
207
  if (instance.writeFile(localUri, source, { encoding: 'utf-8', ownPermissionOnly: true, throwsPermission: true })) {
@@ -223,7 +209,7 @@ function finalize(instance) {
223
209
  }
224
210
  }
225
211
  catch (err) {
226
- this.writeFail(["Unable to write file" /* ERR_MESSAGE.WRITE_FILE */, path.basename(localUri)], err, 8192 /* LOG_TYPE.PERMISSION */);
212
+ this.writeFail(["Unable to write file", path.basename(localUri)], err, 8192);
227
213
  }
228
214
  }
229
215
  }
@@ -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");
@@ -72,7 +71,7 @@ function finalize(instance) {
72
71
  }
73
72
  }
74
73
  catch (err) {
75
- this.writeFail(["Unable to write file" /* ERR_MESSAGE.WRITE_FILE */, path.basename(localUri)], err, 8192 /* LOG_TYPE.PERMISSION */);
74
+ this.writeFail(["Unable to write file", path.basename(localUri)], err, 8192);
76
75
  }
77
76
  }
78
77
  }
@@ -1,11 +1,9 @@
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");
6
5
  const types_1 = require("@e-mc/types");
7
6
  const Document = require("@e-mc/document");
8
- const checkWin32 = (value) => value === "gradlew" /* STRINGS.GRADLEW */ && process.platform === 'win32' ? value + '.bat' : value;
9
7
  async function finalize(instance) {
10
8
  const commands = instance.config.commands;
11
9
  if (!commands || this.incremental === 'staging') {
@@ -28,7 +26,7 @@ async function finalize(instance) {
28
26
  }
29
27
  const settings = instance.settings.extensions?.task || {};
30
28
  const exec = settings.exec;
31
- let { broadcastId, baseDirectory } = this, command = settings.command, uid, gid, title, filename, foundCwd;
29
+ let { broadcastId, baseDirectory } = this, command = settings.command, uid, gid, title, name, foundCwd;
32
30
  if (command) {
33
31
  if (command.indexOf('mvn') !== -1) {
34
32
  title = 'maven';
@@ -37,20 +35,20 @@ async function finalize(instance) {
37
35
  title = /([^\\/]+?)(?:\.[a-z]+)?$/i.exec(command)?.[1] || 'SPAWN';
38
36
  }
39
37
  command = path.normalize(command);
40
- if (!/[\\/]/.test(command = path.normalize(command))) {
41
- filename = checkWin32(command);
38
+ if (!command.includes(path.sep)) {
39
+ name = command;
42
40
  }
43
41
  command = Document.sanitizeCmd(command);
44
42
  }
45
43
  else {
46
- filename = checkWin32("gradlew" /* STRINGS.GRADLEW */);
47
- command = '.' + path.sep + filename;
44
+ name = 'gradlew';
45
+ command = '.' + path.sep + name;
48
46
  title = 'gradle';
49
47
  }
50
- if (filename) {
48
+ if (name) {
51
49
  try {
52
50
  let appDir = baseDirectory;
53
- while (!(foundCwd = fs.existsSync(path.join(appDir, filename)))) {
51
+ while (!(foundCwd = fs.existsSync(path.join(appDir, name)))) {
54
52
  const parent = path.dirname(appDir);
55
53
  if (parent === appDir) {
56
54
  break;
@@ -80,9 +78,9 @@ async function finalize(instance) {
80
78
  const startTime = process.hrtime();
81
79
  const task = args.join(' ');
82
80
  await new Promise((resolve, reject) => {
83
- this.formatMessage(4 /* LOG_TYPE.PROCESS */, title, ['Executing task...', task], baseDirectory);
81
+ this.formatMessage(4, title, ['Executing task...', task], baseDirectory);
84
82
  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 })
83
+ 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
84
  .on('exit', code => {
87
85
  if (!code) {
88
86
  instance.addLog(types_1.STATUS_TYPE.INFO, out);
@@ -90,7 +88,7 @@ async function finalize(instance) {
90
88
  resolve();
91
89
  }
92
90
  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));
91
+ reject((0, types_1.errorValue)(message || (!foundCwd && code === 1 ? "Unable to execute file" : "Unknown"), "Error code" + ': ' + code));
94
92
  }
95
93
  })
96
94
  .on('error', err => reject(err));
@@ -111,7 +109,7 @@ async function finalize(instance) {
111
109
  });
112
110
  }
113
111
  })
114
- .catch(err => instance.writeFail(["Unable to perform task" /* ERR_MESSAGE.PERFORM_TASK */, command + ' ' + task], err, { type: 4 /* LOG_TYPE.PROCESS */, startTime }));
112
+ .catch(err => instance.writeFail(["Unable to perform task", command + ' ' + task], err, { type: 4, startTime }));
115
113
  }
116
114
  }
117
115
 
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
@@ -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);
@@ -189,12 +187,12 @@ class AndroidDocument extends Document {
189
187
  paths.push(filename);
190
188
  let uri;
191
189
  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);
190
+ throw (0, types_1.errorValue)("File not found", uri);
193
191
  }
194
192
  return { localUri, source: fs.readFileSync(uri || localUri, 'utf-8'), existing, kotlin, language };
195
193
  }
196
194
  catch (err) {
197
- this.writeFail(["Unable to read file" /* ERR_MESSAGE.READ_FILE */, path.basename(localUri)], err, 32 /* LOG_TYPE.FILE */);
195
+ this.writeFail(["Unable to read file", path.basename(localUri)], err, 32);
198
196
  }
199
197
  return { kotlin, language };
200
198
  }
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.3",
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.2",
24
+ "@e-mc/types": "^0.6.2",
25
25
  "htmlparser2": "^9.0.0"
26
26
  }
27
27
  }
@@ -1,5 +1,5 @@
1
1
  plugins {
2
2
  id 'com.android.application' version '8.2.0' apply false
3
3
  id 'com.android.library' version '8.2.0' apply false
4
- id 'org.jetbrains.kotlin.android' version '1.9.10' apply false
4
+ id 'org.jetbrains.kotlin.android' version '1.9.22' apply false
5
5
  }
@@ -38,7 +38,7 @@ java {
38
38
  }
39
39
 
40
40
  dependencies {
41
- implementation("org.jetbrains.kotlin:kotlin-stdlib:1.9.10")
41
+ implementation("org.jetbrains.kotlin:kotlin-stdlib:1.9.22")
42
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")
@@ -1,5 +1,5 @@
1
1
  plugins {
2
2
  id("com.android.application") version "8.2.0" apply false
3
3
  id("com.android.library") version "8.2.0" apply false
4
- id("org.jetbrains.kotlin.android") version "1.9.10" apply false
4
+ id("org.jetbrains.kotlin.android") version "1.9.22" apply false
5
5
  }