@pi-r/android 0.5.0 → 0.5.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 Wit Studio
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 Vivy
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);
@@ -173,10 +173,14 @@ 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
  }
180
180
  }
181
+ exports.default = finalize;
181
182
 
182
- module.exports = finalize;
183
+ if (exports.default) {
184
+ module.exports = exports.default;
185
+ module.exports.default = exports.default;
186
+ }
@@ -35,7 +35,7 @@ function finalize(instance) {
35
35
  return;
36
36
  }
37
37
  const detect = this.incremental !== 'staging';
38
- let { localUri, source, existing, kotlin } = instance.findTemplate(path.join(this.baseDirectory, config.mainParentDir), "build.gradle" /* GRADLE.FILENAME */, { detect, languageOf: 'gradle' });
38
+ let { localUri, source, existing, kotlin } = instance.findTemplate(path.join(this.baseDirectory, config.mainParentDir), "build.gradle", { detect, languageOf: 'gradle' });
39
39
  if (localUri && source && instance.canWrite(localUri, { ownPermissionOnly: true })) {
40
40
  let { namespace, javaVersion, dependencyScopes } = config, jvmTarget, modified;
41
41
  const upgrade = javaVersion > 0;
@@ -81,16 +81,16 @@ function finalize(instance) {
81
81
  let type = -1;
82
82
  switch (scope) {
83
83
  case 'compile':
84
- type = 0 /* DEPENDENCY_TYPE.IMPLEMENTATION */;
84
+ type = 0;
85
85
  break;
86
86
  case 'provided':
87
- type = 2 /* DEPENDENCY_TYPE.COMPILE_ONLY */;
87
+ type = 2;
88
88
  break;
89
89
  case 'runtime':
90
- type = 3 /* DEPENDENCY_TYPE.RUNTIME_ONLY */;
90
+ type = 4;
91
91
  break;
92
92
  case 'test':
93
- type = 4 /* DEPENDENCY_TYPE.TEST_IMPLEMENTATION */;
93
+ type = 5;
94
94
  break;
95
95
  }
96
96
  if (type !== -1) {
@@ -161,30 +161,45 @@ function finalize(instance) {
161
161
  if (!kotlin && items.some(seg => seg[1].endsWith('-ktx'))) {
162
162
  setModified(Document.updateGradle(source, ['plugins'], "id 'kotlin-android'", { multiple: true }));
163
163
  }
164
- const match = /dependencies\s+\{((?:{[^}]*}|(?![{}])[\S\s])+)\}/.exec(source);
164
+ const match = /dependencies\s+\{((?:{[^{]*{|{[^}]*}|}[^}]*}|\\}*?|[^{}+])+)\}/.exec(source);
165
165
  if (match) {
166
- const pattern = kotlin ? /([ \t]*)(implementation|api|compileOnly|runtimeOnly|(?:test|androidTest)Implementation)\((?:\s*(?:"([^"]+)"|((?:\s*(?:group|name|version)\s*=\s*"[^"]+"\s*,?){3}))\s*\))?/g : /([ \t]*)(implementation|api|compileOnly|runtimeOnly|(?:test|androidTest)Implementation)(?:\s*\(?\s*["']([^"']+)["']\s*\)?|\s+((?:\s*(?:group|name|version)\s*:\s*["'][^"']+["']\s*,?){3}))?/g;
166
+ const pattern = kotlin ? /([ \t]*)(implementation|api|compileOnly(?:Api)?|runtimeOnly|(?:test|androidTest)(?:Implementation|RuntimeOnly|CompileOnly))\((?:\s*(?:"([^"]+)"|((?:\s*(?:group|name|version)\s*=\s*"[^"]+"\s*,?){3}))\s*\))?/g : /([ \t]*)(implementation|api|compileOnly(?:Api)?|runtimeOnly|(?:test|androidTest)(?:Implementation|RuntimeOnly|CompileOnly))(?:\s*\(?\s*["']([^"']+)["']\s*\)?|\s+((?:\s*(?:group|name|version)\s*:\s*["'][^"']+["']\s*,?){3}))?/g;
167
167
  let content = match[1], named = false, indent, method;
168
168
  const writeMethod = (item, args, prefix = 'implementation') => {
169
169
  switch (parseInt(item[3])) {
170
- case 0 /* DEPENDENCY_TYPE.IMPLEMENTATION */:
170
+ case 0:
171
171
  prefix = 'implementation';
172
172
  break;
173
- case 1 /* DEPENDENCY_TYPE.API */:
173
+ case 1:
174
174
  prefix = 'api';
175
175
  break;
176
- case 2 /* DEPENDENCY_TYPE.COMPILE_ONLY */:
176
+ case 2:
177
177
  prefix = 'compileOnly';
178
178
  break;
179
- case 3 /* DEPENDENCY_TYPE.RUNTIME_ONLY */:
179
+ case 3:
180
+ prefix = 'compileOnlyApi';
181
+ break;
182
+ case 4:
180
183
  prefix = 'runtimeOnly';
181
184
  break;
182
- case 4 /* DEPENDENCY_TYPE.TEST_IMPLEMENTATION */:
185
+ case 5:
183
186
  prefix = 'testImplementation';
184
187
  break;
185
- case 5 /* DEPENDENCY_TYPE.ANDROID_TEST_IMPLEMENTATION */:
188
+ case 6:
189
+ prefix = 'testCompileOnly';
190
+ break;
191
+ case 7:
192
+ prefix = 'testRuntimeOnly';
193
+ break;
194
+ case 8:
186
195
  prefix = 'androidTestImplementation';
187
196
  break;
197
+ case 9:
198
+ prefix = 'androidTestCompileOnly';
199
+ break;
200
+ case 10:
201
+ prefix = 'androidTestRuntimeOnly';
202
+ break;
188
203
  }
189
204
  let dependency;
190
205
  if (args || named) {
@@ -255,9 +270,9 @@ function finalize(instance) {
255
270
  output = Document.updateGradle(output, ['android', 'buildFeatures'], 'compose = true');
256
271
  }
257
272
  else {
258
- 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.21" /* VERSIONS.KOTLIN_STDLIB */)}'` });
273
+ 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")}'` });
259
274
  output = Document.updateGradle(output, ['android', 'buildFeatures'], "compose true");
260
- output = Document.updateGradle(output, ['android', 'composeOptions'], `kotlinCompilerExtensionVersion '${instance.findVersion('kotlinCompilerExtensionVersion', "1.5.6" /* VERSIONS.KOTLIN_COMPILER */)}'`, true);
275
+ output = Document.updateGradle(output, ['android', 'composeOptions'], `kotlinCompilerExtensionVersion '${instance.findVersion('kotlinCompilerExtensionVersion', "1.5.9")}'`, true);
261
276
  if (upgrade) {
262
277
  output = Document.updateGradle(output, ['android', 'kotlinOptions'], `jvmTarget = '${javaVersion}'`, true);
263
278
  }
@@ -355,12 +370,12 @@ function finalize(instance) {
355
370
  }
356
371
  }
357
372
  catch (err) {
358
- this.writeFail(["Unable to write file" /* ERR_MESSAGE.WRITE_FILE */, path.basename(localUri)], err, 8192 /* LOG_TYPE.PERMISSION */);
373
+ this.writeFail(["Unable to write file", path.basename(localUri)], err, 8192);
359
374
  }
360
375
  }
361
376
  }
362
377
  if (!existing) {
363
- ({ localUri, source, existing, kotlin } = instance.findTemplate(this.baseDirectory, "build.gradle" /* GRADLE.FILENAME */, { detect, languageOf: 'gradle', subDir: 'static' }));
378
+ ({ localUri, source, existing, kotlin } = instance.findTemplate(this.baseDirectory, "build.gradle", { detect, languageOf: 'gradle', subDir: 'static' }));
364
379
  if (localUri && source && instance.canWrite(localUri, { ownPermissionOnly: true })) {
365
380
  try {
366
381
  if (instance.writeFile(localUri, source, { encoding: 'utf-8', ownPermissionOnly: true, throwsPermission: true })) {
@@ -368,10 +383,14 @@ function finalize(instance) {
368
383
  }
369
384
  }
370
385
  catch (err) {
371
- this.writeFail(["Unable to write file" /* ERR_MESSAGE.WRITE_FILE */, path.basename(localUri)], err, 8192 /* LOG_TYPE.PERMISSION */);
386
+ this.writeFail(["Unable to write file", path.basename(localUri)], err, 8192);
372
387
  }
373
388
  }
374
389
  }
375
390
  }
391
+ exports.default = finalize;
376
392
 
377
- module.exports = finalize;
393
+ if (exports.default) {
394
+ module.exports = exports.default;
395
+ module.exports.default = exports.default;
396
+ }
@@ -8,7 +8,7 @@ function finalize(instance) {
8
8
  if (!dependencies && !projectName) {
9
9
  return;
10
10
  }
11
- let { localUri, source, existing, kotlin } = instance.findTemplate(this.baseDirectory, "settings.gradle" /* GRADLE.FILENAME */, { detect: this.incremental !== 'staging', languageOf: 'gradle' });
11
+ let { localUri, source, existing, kotlin } = instance.findTemplate(this.baseDirectory, "settings.gradle", { detect: this.incremental !== 'staging', languageOf: 'gradle' });
12
12
  if (localUri && source && instance.canWrite(localUri, { ownPermissionOnly: true })) {
13
13
  let targetName = projectName?.replace(/"/g, '\\"'), modified;
14
14
  if (existing) {
@@ -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
+ }
@@ -6,7 +6,7 @@ const child_process = require("child_process");
6
6
  const which = require("which");
7
7
  const types_1 = require("@e-mc/types");
8
8
  const Document = require("@e-mc/document");
9
- const checkWin32 = (value) => value === "gradlew" /* STRINGS.GRADLEW */ && process.platform === 'win32' ? value + '.bat' : value;
9
+ const checkWin32 = (value) => value === "gradlew" && process.platform === 'win32' ? value + '.bat' : value;
10
10
  async function finalize(instance) {
11
11
  const commands = instance.config.commands;
12
12
  if (!commands || this.incremental === 'staging') {
@@ -32,7 +32,7 @@ async function finalize(instance) {
32
32
  let { broadcastId, baseDirectory } = this, command = settings.command, uid, gid, title, filename, altname, foundDir;
33
33
  if (command) {
34
34
  if (command.indexOf('mvn') !== -1) {
35
- title = "maven" /* STRINGS.MAVEN */;
35
+ title = "maven";
36
36
  }
37
37
  else {
38
38
  title = /([^\\/]+?)(?:\.[a-z]+)?$/i.exec(command)?.[1] || 'spawn';
@@ -43,10 +43,10 @@ async function finalize(instance) {
43
43
  command = Document.sanitizeCmd(command);
44
44
  }
45
45
  else {
46
- filename = checkWin32("gradlew" /* STRINGS.GRADLEW */);
46
+ filename = checkWin32("gradlew");
47
47
  command = '.' + path.sep + filename;
48
- title = "gradle" /* STRINGS.GRADLE */;
49
- altname = "gradle" /* STRINGS.GRADLE */;
48
+ title = "gradle";
49
+ altname = "gradle";
50
50
  }
51
51
  if (filename) {
52
52
  try {
@@ -87,9 +87,9 @@ async function finalize(instance) {
87
87
  const startTime = process.hrtime();
88
88
  const task = args.join(' ');
89
89
  await new Promise((resolve, reject) => {
90
- this.formatMessage(4 /* LOG_TYPE.PROCESS */, title, ['Executing task...', task], baseDirectory);
90
+ this.formatMessage(4, title, ['Executing task...', task], baseDirectory);
91
91
  let out = '', message = '';
92
- 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 })
92
+ 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 })
93
93
  .on('exit', code => {
94
94
  if (!code) {
95
95
  instance.addLog(types_1.STATUS_TYPE.INFO, out);
@@ -97,7 +97,7 @@ async function finalize(instance) {
97
97
  resolve();
98
98
  }
99
99
  else {
100
- reject((0, types_1.errorValue)(message || (!foundDir && code === 1 ? "Unable to execute file" /* ERR_MESSAGE.EXECUTE_FILE */ : "Unknown" /* ERR_MESSAGE.UNKNOWN */), "Error code" /* ERR_MESSAGE.ERROR_CODE */ + ': ' + code));
100
+ reject((0, types_1.errorValue)(message || (!foundDir && code === 1 ? "Unable to execute file" : "Unknown"), "Error code" + ': ' + code));
101
101
  }
102
102
  })
103
103
  .on('error', err => reject(err));
@@ -118,8 +118,12 @@ async function finalize(instance) {
118
118
  });
119
119
  }
120
120
  })
121
- .catch(err => instance.writeFail(["Unable to perform task" /* ERR_MESSAGE.PERFORM_TASK */, command + ' ' + task], err, { type: 4 /* LOG_TYPE.PROCESS */, startTime }));
121
+ .catch(err => instance.writeFail(["Unable to perform task", command + ' ' + task], err, { type: 4, startTime }));
122
122
  }
123
123
  }
124
+ exports.default = finalize;
124
125
 
125
- module.exports = finalize;
126
+ if (exports.default) {
127
+ module.exports = exports.default;
128
+ module.exports.default = exports.default;
129
+ }
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
@@ -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);
@@ -155,7 +154,7 @@ class AndroidDocument extends Document {
155
154
  await instance.tryFile(buffer, localUri, { format: 'ttf', etag: file.etag }, (err, result) => {
156
155
  if (err) {
157
156
  host.deleteFile(localUri);
158
- host.writeFail("Unable to compress file" /* ERR_MESSAGE.COMPRESS_FILE */, err, 8 /* LOG_TYPE.COMPRESS */);
157
+ host.writeFail("Unable to compress file", err, 8);
159
158
  }
160
159
  else if ((0, types_1.isString)(result)) {
161
160
  host.replace(file, result);
@@ -193,12 +192,12 @@ class AndroidDocument extends Document {
193
192
  paths.push(filename);
194
193
  let uri;
195
194
  if (!existing && !(uri = this.resolveDir('template', ...paths)) && !fs.existsSync(uri = path.join(__dirname, 'template', ...paths))) {
196
- throw (0, types_1.errorValue)("File not found" /* ERR_MESSAGE.NOTFOUND_FILE */, uri);
195
+ throw (0, types_1.errorValue)("File not found", uri);
197
196
  }
198
197
  return { localUri, source: fs.readFileSync(uri || localUri, 'utf-8'), existing, kotlin, language };
199
198
  }
200
199
  catch (err) {
201
- this.writeFail(["Unable to read file" /* ERR_MESSAGE.READ_FILE */, path.basename(localUri)], err, 32 /* LOG_TYPE.FILE */);
200
+ this.writeFail(["Unable to read file", path.basename(localUri)], err, 32);
202
201
  }
203
202
  return { kotlin, language };
204
203
  }
@@ -209,7 +208,7 @@ class AndroidDocument extends Document {
209
208
  return this.tryParse(fs.readFileSync(localUri, 'utf-8'), format || path.extname(localUri).substring(1));
210
209
  }
211
210
  catch (err) {
212
- this.writeFail(["Unable to read file" /* ERR_MESSAGE.READ_FILE */, path.basename(localUri)], err, 32 /* LOG_TYPE.FILE */);
211
+ this.writeFail(["Unable to read file", path.basename(localUri)], err, 32);
213
212
  }
214
213
  }
215
214
  return null;
@@ -233,5 +232,9 @@ class AndroidDocument extends Document {
233
232
  return (_a = this.module).settings || (_a.settings = {});
234
233
  }
235
234
  }
235
+ exports.default = AndroidDocument;
236
236
 
237
- module.exports = AndroidDocument;
237
+ if (exports.default) {
238
+ module.exports = exports.default;
239
+ module.exports.default = exports.default;
240
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/android",
3
- "version": "0.5.0",
3
+ "version": "0.5.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.7.0",
24
- "@e-mc/types": "^0.7.0",
23
+ "@e-mc/document": "^0.7.2",
24
+ "@e-mc/types": "^0.7.2",
25
25
  "htmlparser2": "^9.0.0",
26
26
  "which": "^2.0.2"
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.21' 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.21")
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.21" apply false
4
+ id("org.jetbrains.kotlin.android") version "1.9.22" apply false
5
5
  }