@nativescript/android 8.9.0-dev.0 → 8.9.0-napi-hermes.0

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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Android Runtime for NativeScript
1
+ # Node-API Android Runtime for NativeScript
2
2
  [![Build Status](https://travis-ci.org/NativeScript/android-runtime.svg?branch=master)](https://travis-ci.org/NativeScript/android-runtime)
3
3
 
4
4
  Contains the source code for the NativeScript's Android Runtime. [NativeScript](https://www.nativescript.org/) is a framework which enables developers to write truly native mobile applications for Android and iOS using JavaScript and CSS. Each mobile platform has its own ecosystem and offers completely different development tools and language(s) - Java for Android and Objective C (Swift) for iOS. In order to translate JavaScript code to the corresponding native APIs some kind of proxy mechanism is needed. This is exactly what the "Runtime" parts of NativeScript are responsible for. The Android Runtime may be thought of as "The Bridge" between the JavaScript and Android worlds. A NativeScript application for Android is a standard native package (apk) which besides the JavaScript files embed the runtime as well.
@@ -77,14 +77,15 @@ Note: You might need to run the Android Studio from the command line in order to
77
77
  Windows:
78
78
 
79
79
  ```Shell
80
- gradlew
80
+ gradlew -Pengine=V8
81
81
  ```
82
82
 
83
83
  Mac/Linux:
84
84
 
85
85
  ```Shell
86
- ./gradlew
86
+ ./gradlew -Pengine=V8
87
87
  ```
88
+ You can pass in `QUICKJS`, `HERMES`, `JSC` or `V8` to compile the runtime with the respective JS engine.
88
89
 
89
90
  * The build process includes building of the runtime package (both optimized and with unstripped v8 symbol table), as well as all supplementary tools used for the android builds: metadata-generator, binding-generator, metadata-generator, static-binding-generator
90
91
  * The result of the build will be in the dist folder.
@@ -239,7 +239,7 @@ android {
239
239
  }
240
240
 
241
241
  sourceSets.main {
242
- jniLibs.srcDirs = ["$projectDir/libs/jni", "$projectDir/snapshot-build/build/ndk-build/libs"]
242
+ jniLibs.srcDirs = ["$projectDir/libs/jni", "$projectDir/snapshot-build/build/ndk-build/libs", "$projectDir/src/main/jniLibs"]
243
243
  }
244
244
 
245
245
  signingConfigs {
@@ -260,7 +260,7 @@ android {
260
260
  }
261
261
  buildTypes {
262
262
  release {
263
- signingConfig signingConfigs.release
263
+ signingConfig signingConfigs.debug
264
264
  }
265
265
  }
266
266
 
@@ -333,6 +333,10 @@ dependencies {
333
333
  outLogger.withStyle(Style.SuccessHeader).println "\t + using android X library androidx.appcompat:appcompat:$androidXAppCompatVersion"
334
334
  }
335
335
 
336
+ if (ns_engine == "HERMES") {
337
+ implementation 'com.facebook.fbjni:fbjni:0.3.0'
338
+ }
339
+
336
340
  def androidXMaterialVersion = "${ns_default_androidx_material_version}"
337
341
  if (project.hasProperty("androidXMaterial")) {
338
342
  androidXMaterialVersion = androidXMaterial
@@ -1,5 +1,4 @@
1
1
  (function () {
2
-
3
2
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
4
3
  var c = arguments.length;
5
4
  var r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -27,24 +26,24 @@
27
26
  // this way we now support both implementations in typescript generated constructors:
28
27
  // 1: super(); return __native(this);
29
28
  // 2: return super() || this;
30
- if (thiz.__container__) {
31
- var result = thiz.__proto__;
32
-
33
- for (var prop in thiz) {
34
- if (thiz.hasOwnProperty(prop)) {
35
- thiz.__proto__[prop] = thiz[prop];
36
- delete thiz[prop];
37
- }
38
- }
39
-
40
- thiz.constructor = undefined;
41
- thiz.__proto__ = undefined;
42
- Object.freeze(thiz);
43
- Object.preventExtensions(thiz);
44
- return result;
45
- } else {
29
+ // if (thiz.__container__) {
30
+ // var result = thiz.__proto__;
31
+ //
32
+ // for (var prop in thiz) {
33
+ // if (thiz.hasOwnProperty(prop)) {
34
+ // thiz.__proto__[prop] = thiz[prop];
35
+ // delete thiz[prop];
36
+ // }
37
+ // }
38
+ //
39
+ // thiz.constructor = undefined;
40
+ // thiz.__proto__ = undefined;
41
+ // Object.freeze(thiz);
42
+ // Object.preventExtensions(thiz);
43
+ // return result;
44
+ // } else {
46
45
  return thiz;
47
- }
46
+ // }
48
47
  };
49
48
 
50
49
  var __extends = function (Child, Parent) {
@@ -79,12 +78,16 @@
79
78
  var Extended = extend(thiz);
80
79
  thiz.__container__ = true;
81
80
  if (arguments.length > 1) {
82
- thiz.__proto__ = new (Function.prototype.bind.apply(Extended, [null].concat(Array.prototype.slice.call(arguments, 1))));
81
+ if (typeof Extended !== "function") {
82
+ thiz.__proto__ = Reflect.construct(Extended, Array.prototype.slice.call(arguments, 1));
83
+ } else {
84
+ thiz.__proto__ = new (Function.prototype.bind.apply(Extended, [null].concat(Array.prototype.slice.call(arguments, 1))));
85
+ }
83
86
  }
84
87
  else {
85
88
  thiz.__proto__ = new Extended()
86
89
  }
87
- return thiz.__proto__;
90
+ return thiz;
88
91
  };
89
92
 
90
93
  Parent.apply = function (thiz, args) {
@@ -96,7 +99,7 @@
96
99
  else {
97
100
  thiz.__proto__ = new Extended();
98
101
  }
99
- return thiz.__proto__;
102
+ return thiz;
100
103
  };
101
104
  __extends_ns(Child, Parent);
102
105
  Child.__isPrototypeImplementationObject = true;
@@ -174,4 +177,17 @@
174
177
  global.JavaProxy = JavaProxy;
175
178
  }
176
179
  global.Interfaces = Interfaces;
177
- })()
180
+
181
+ if (global.WeakRef && !global.WeakRef.prototype.get) {
182
+ global.WeakRef.prototype.get = global.WeakRef.prototype.deref;
183
+ }
184
+
185
+ })();
186
+ globalThis.getErrorStack = (err) => {
187
+ if (err) return err.stack;
188
+ const stack = new Error("").stack;
189
+ const lines = stack.split("\n");
190
+ // Line 2 results in invalid stack if not replaced when doing typescript extend.
191
+ lines[2] = " at extend(native)";
192
+ return lines.join("\n");
193
+ }
@@ -291,7 +291,7 @@ class AndroidJsV8Inspector {
291
291
  @Override
292
292
  protected void onMessage(final NanoWSD.WebSocketFrame message) {
293
293
  if (currentRuntimeLogger.isEnabled()) {
294
- Log.d("V8Inspector", "To dbg backend: " + message.getTextPayload() + " ThreadId:" + Thread.currentThread().getId());
294
+ Log.d("Inspector", "To dbg backend: " + message.getTextPayload() + " ThreadId:" + Thread.currentThread().getId());
295
295
  }
296
296
 
297
297
  inspectorMessages.offer(message.getTextPayload());
@@ -6,7 +6,7 @@ import android.util.Log;
6
6
  public final class LogcatLogger implements Logger {
7
7
  private final static String DEFAULT_LOG_TAG = "TNS.Java";
8
8
 
9
- private boolean enabled;
9
+ private boolean enabled = false;
10
10
 
11
11
  public LogcatLogger(Context context) {
12
12
  this.initLogging(context);
@@ -33,13 +33,12 @@ public final class LogcatLogger implements Logger {
33
33
  }
34
34
 
35
35
  private void initLogging(Context context) {
36
- boolean isDebuggableApp = Util.isDebuggableApp(context);
37
- if (isDebuggableApp) {
38
- String verboseLoggingProp = Util.readSystemProperty("nativescript.verbose.logging");
39
-
40
- if (Util.isPositive(verboseLoggingProp)) {
41
- setEnabled(true);
42
- }
43
- }
36
+ boolean isDebuggableApp = Util.isDebuggableApp(context);
37
+ if (isDebuggableApp) {
38
+ String verboseLoggingProp = Util.readSystemProperty("nativescript.verbose.logging");
39
+ if (Util.isPositive(verboseLoggingProp)) {
40
+ setEnabled(true);
41
+ }
42
+ }
44
43
  }
45
44
  }
@@ -23,7 +23,7 @@ public final class RuntimeHelper {
23
23
  private RuntimeHelper() {
24
24
  }
25
25
 
26
- private static AndroidJsV8Inspector v8Inspector;
26
+ // private static AndroidJsV8Inspector v8Inspector;
27
27
 
28
28
  // hasErrorIntent tells you if there was an event (with an uncaught
29
29
  // exception) raised from ErrorReport
@@ -151,8 +151,8 @@ public final class RuntimeHelper {
151
151
  runtime = Runtime.initializeRuntimeWithConfiguration(config);
152
152
  if (isDebuggable) {
153
153
  try {
154
- v8Inspector = new AndroidJsV8Inspector(context.getFilesDir().getAbsolutePath(), context.getPackageName());
155
- v8Inspector.start();
154
+ // v8Inspector = new AndroidJsV8Inspector(context.getFilesDir().getAbsolutePath(), context.getPackageName());
155
+ // v8Inspector.start();
156
156
 
157
157
  // the following snippet is used as means to notify the VSCode extension
158
158
  // debugger that the debugger agent has started
@@ -176,7 +176,7 @@ public final class RuntimeHelper {
176
176
  shouldBreak = true;
177
177
  }
178
178
 
179
- v8Inspector.waitForDebugger(shouldBreak);
179
+ // v8Inspector.waitForDebugger(shouldBreak);
180
180
  } catch (IOException e) {
181
181
  if (Util.isDebuggableApp(context)) {
182
182
  e.printStackTrace();