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