@nativescript/android 8.9.0-napi-v8.9 → 8.9.0-next.2025-02-20-13440184782

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
- # Node-API Android Runtime for NativeScript
1
+ # 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,15 +77,14 @@ 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 -Pengine=V8
80
+ gradlew
81
81
  ```
82
82
 
83
83
  Mac/Linux:
84
84
 
85
85
  ```Shell
86
- ./gradlew -Pengine=V8
86
+ ./gradlew
87
87
  ```
88
- You can pass in `QUICKJS`, `HERMES`, `JSC` or `V8` to compile the runtime with the respective JS engine.
89
88
 
90
89
  * 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
91
90
  * The result of the build will be in the dist folder.
@@ -77,8 +77,8 @@ def METADATA_JAVA_OUT = "mdg-java-out.txt"
77
77
  def pluginsJarLibraries = new LinkedList<String>()
78
78
  def allJarLibraries = new LinkedList<String>()
79
79
 
80
- def computeCompileSdkVersion = { -> project.hasProperty("compileSdk") ? compileSdk : NS_DEFAULT_COMPILE_SDK_VERSION as int }
81
- def computeTargetSdkVersion = { -> project.hasProperty("targetSdk") ? targetSdk : NS_DEFAULT_COMPILE_SDK_VERSION as int }
80
+ def computeCompileSdkVersion = { -> project.hasProperty("compileSdk") ? compileSdk as int : NS_DEFAULT_COMPILE_SDK_VERSION as int }
81
+ def computeTargetSdkVersion = { -> project.hasProperty("targetSdk") ? targetSdk as int : NS_DEFAULT_COMPILE_SDK_VERSION as int }
82
82
  def computeMinSdkVersion = { -> project.hasProperty("minSdk") ? minSdk : NS_DEFAULT_MIN_SDK_VERSION as int }
83
83
  def computeBuildToolsVersion = { ->
84
84
  project.hasProperty("buildToolsVersion") ? buildToolsVersion : NS_DEFAULT_BUILD_TOOLS_VERSION as String
@@ -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", "$projectDir/src/main/jniLibs"]
242
+ jniLibs.srcDirs = ["$projectDir/libs/jni", "$projectDir/snapshot-build/build/ndk-build/libs"]
243
243
  }
244
244
 
245
245
  signingConfigs {
@@ -260,7 +260,7 @@ android {
260
260
  }
261
261
  buildTypes {
262
262
  release {
263
- signingConfig signingConfigs.debug
263
+ signingConfig signingConfigs.release
264
264
  }
265
265
  }
266
266
 
@@ -333,10 +333,6 @@ 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
-
340
336
  def androidXMaterialVersion = "${ns_default_androidx_material_version}"
341
337
  if (project.hasProperty("androidXMaterial")) {
342
338
  androidXMaterialVersion = androidXMaterial
@@ -1,327 +1,177 @@
1
1
  (function () {
2
- var __decorate =
3
- (this && this.__decorate) ||
4
- function (decorators, target, key, desc) {
5
- var c = arguments.length;
6
- var r =
7
- c < 3
8
- ? target
9
- : desc === null
10
- ? (desc = Object.getOwnPropertyDescriptor(target, key))
11
- : desc,
12
- d;
13
2
 
14
- if (
15
- typeof global.Reflect === "object" &&
16
- typeof global.Reflect.decorate === "function"
17
- ) {
18
- r = global.Reflect.decorate(decorators, target, key, desc);
19
- } else {
20
- for (var i = decorators.length - 1; i >= 0; i--) {
21
- if ((d = decorators[i])) {
22
- r =
23
- (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
24
- }
25
- }
26
- }
27
- return c > 3 && r && Object.defineProperty(target, key, r), r;
28
- };
29
-
30
- // For backward compatibility.
31
- var __native = function (thiz) {
32
- // we are setting the __container__ property to the base class when the super method is called
33
- // if the constructor returns the __native(this) call we will use the old implementation
34
- // copying all the properties to the result
35
- // otherwise if we are using the result from the super() method call we won't need such logic
36
- // as thiz already contains the parent properties
37
- // this way we now support both implementations in typescript generated constructors:
38
- // 1: super(); return __native(this);
39
- // 2: return super() || this;
40
- // if (thiz.__container__) {
41
- // if (__useHostObjects) {
42
- // for (var prop in thiz) {
43
- // if (thiz.hasOwnProperty(prop)) {
44
- // thiz.__proto__[prop] = thiz[prop];
45
- // delete thiz[prop];
46
- // }
47
- // }
48
- // }
49
-
50
- return thiz;
51
- // } else {
52
- // return thiz;
53
- // }
54
- };
55
-
56
- var __extends = function (Child, Parent) {
57
- var extendNativeClass =
58
- !!Parent.extend && Parent.extend.toString().indexOf("[native code]") > -1;
59
- if (!extendNativeClass) {
60
- __extends_ts(Child, Parent);
61
- return;
62
- }
63
- if (Parent.__isPrototypeImplementationObject) {
64
- throw new Error("Can not extend an already extended native object.");
65
- }
66
-
67
- function extend(thiz) {
68
- var child = thiz.__proto__.__child;
69
- if (!child.__extended) {
70
- var parent = thiz.__proto__.__parent;
71
- child.__extended = parent.extend(child.name, child.prototype, true);
72
- // This will deal with "i instanceof child"
73
- child[Symbol.hasInstance] = function (instance) {
74
- return instance instanceof this.__extended;
75
- };
76
- }
77
- return child.__extended;
78
- }
79
-
80
- Parent.__activityExtend = function (parent, name, implementationObject) {
81
- __log("__activityExtend called");
82
- return parent.extend(name, implementationObject);
83
- };
84
-
85
- Parent.call = function (thiz) {
86
- var Extended = extend(thiz);
87
- thiz.__container__ = true;
88
- if (arguments.length > 1) {
89
- if (typeof Extended !== "function") {
90
- thiz = Reflect.construct(
91
- Extended,
92
- Array.prototype.slice.call(arguments, 1)
93
- );
94
- } else {
95
- thiz = new (Function.prototype.bind.apply(
96
- Extended,
97
- [null].concat(Array.prototype.slice.call(arguments, 1))
98
- ))();
99
- }
100
- } else {
101
- thiz = new Extended();
102
- }
103
- return thiz;
104
- };
105
-
106
- Parent.apply = function (thiz, args) {
107
- var Extended = extend(thiz);
108
- thiz.__container__ = true;
109
- if (args && args.length > 0) {
110
- thiz = new (Function.prototype.bind.apply(
111
- Extended,
112
- [null].concat(args)
113
- ))();
114
- } else {
115
- thiz = new Extended();
116
- }
117
- return thiz;
118
- };
119
- __extends_ns(Child, Parent);
120
- Child.__isPrototypeImplementationObject = true;
121
- Child.__proto__ = Parent;
122
- Child.prototype.__parent = Parent;
123
- Child.prototype.__child = Child;
124
- };
125
-
126
- var __extends_ts = function (child, parent) {
127
- extendStaticFunctions(child, parent);
128
- assignPrototypeFromParentToChild(parent, child);
129
- };
130
-
131
- var __extends_ns = function (child, parent) {
132
- if (!parent.extend) {
133
- assignPropertiesFromParentToChild(parent, child);
134
- }
135
-
136
- assignPrototypeFromParentToChild(parent, child);
137
- };
138
-
139
- var extendStaticFunctions =
140
- Object.setPrototypeOf ||
141
- (hasInternalProtoProperty() &&
142
- function (child, parent) {
143
- child.__proto__ = parent;
144
- }) ||
145
- assignPropertiesFromParentToChild;
146
-
147
- function hasInternalProtoProperty() {
148
- return { __proto__: [] } instanceof Array;
149
- }
150
-
151
- function assignPropertiesFromParentToChild(parent, child) {
152
- for (var property in parent) {
153
- if (parent.hasOwnProperty(property)) {
154
- child[property] = parent[property];
155
- }
156
- }
157
- }
158
-
159
- function assignPrototypeFromParentToChild(parent, child) {
160
- function __() {
161
- this.constructor = child;
162
- }
163
-
164
- if (parent === null) {
165
- child.prototype = Object.create(null);
166
- } else {
167
- __.prototype = parent.prototype;
168
- child.prototype = new __();
169
- }
170
- }
171
-
172
- function JavaProxy(className) {
173
- return function (target) {
174
- var extended = target.extend(className, target.prototype);
175
- extended.name = className;
176
- return extended;
177
- };
178
- }
179
-
180
- function Interfaces(interfacesArr) {
181
- return function (target) {
182
- if (interfacesArr instanceof Array) {
183
- // attach interfaces: [] to the object
184
- target.prototype.interfaces = interfacesArr;
185
- }
186
- };
187
- }
188
-
189
- Object.defineProperty(global, "__native", { value: __native });
190
- Object.defineProperty(global, "__extends", { value: __extends });
191
- Object.defineProperty(global, "__decorate", { value: __decorate });
192
-
193
- if (!global.__ns__worker) {
194
- global.JavaProxy = JavaProxy;
195
- }
196
- global.Interfaces = Interfaces;
197
-
198
- if (global.WeakRef && !global.WeakRef.prototype.get) {
199
- global.WeakRef.prototype.get = global.WeakRef.prototype.deref;
200
- }
201
-
202
- global.setNativeArrayProp = (target, prop, value, receiver) => {
203
- if (!isNaN(prop)) {
204
- receiver.setValueAtIndex(parseInt(prop), value);
205
- return true;
206
- }
207
- target[prop] = value;
208
- return true;
209
- };
210
-
211
- global.getNativeArrayProp = (target, prop, receiver) => {
212
- if (!isNaN(prop)) {
213
- return receiver.getValueAtIndex(parseInt(prop));
214
- }
215
-
216
- if (prop === Symbol.iterator) {
217
- let index = 0;
218
- const l = target.length;
219
- return function () {
220
- return {
221
- next: function () {
222
- if (index < l) {
223
- return {
224
- value: receiver.getValueAtIndex(index++),
225
- done: false,
226
- };
227
- } else {
228
- return { done: true };
229
- }
230
- },
231
- };
232
- };
233
- }
234
- if (prop === "map") {
235
- return function (callback) {
236
- const values = receiver.getAllValues();
237
- const result = [];
238
- const l = target.length;
239
- for (let i = 0; i < l; i++) {
240
- result.push(callback(values[i], i, target));
241
- }
242
- return result;
243
- };
244
- }
245
-
246
- if (prop === "toString") {
247
- return function () {
248
- const result = receiver.getAllValues();
249
- return result.join(",");
250
- };
251
- }
252
-
253
- if (prop === "forEach") {
254
- return function (callback) {
255
- const values = receiver.getAllValues();
256
- const l = values.length;
257
- for (let i = 0; i < l; i++) {
258
- callback(values[i], i, target);
259
- }
260
- };
261
- }
262
- return target[prop];
263
- };
264
-
265
- function findInPrototypeChain(obj, prop) {
266
- while (obj) {
267
- if (obj.hasOwnProperty(prop)) {
268
- return Object.getOwnPropertyDescriptor(obj, prop);
269
- }
270
- obj = Object.getPrototypeOf(obj);
271
- }
272
- return undefined;
273
- }
274
-
275
- globalThis.__prepareHostObject = function (hostObject, jsThis) {
276
- // const prototype = Object.getPrototypeOf(jsThis);
277
- // Object.setPrototypeOf(hostObject, prototype);
278
- Object.defineProperty(hostObject, "super", {
279
- get: () => jsThis["super"],
280
- });
281
- };
282
-
283
- const EXTERNAL_PROP = "[[external]]";
284
- const REFERENCE_PROP_JSC = "[[jsc_reference_info]]";
285
-
286
- function __createNativeProxy(object, objectId) {
287
- const proxy = new Proxy(object, {
288
- get: function (target, prop) {
289
- if (prop === EXTERNAL_PROP) return this[EXTERNAL_PROP];
290
- if (prop === REFERENCE_PROP_JSC) return this[REFERENCE_PROP_JSC];
291
- if (target.__is__javaArray) {
292
- return global.getNativeArrayProp(target, prop, target);
293
- }
294
- return target[prop];
295
- },
296
- set: function (target, prop, value) {
297
- if (prop === EXTERNAL_PROP) {
298
- this[EXTERNAL_PROP] = value;
299
- return true;
300
- }
301
-
302
- if (prop === REFERENCE_PROP_JSC) {
303
- this[REFERENCE_PROP_JSC] = value;
304
- }
305
-
306
- if (target.__is__javaArray && !isNaN(prop)) {
307
- target.setValueAtIndex(parseInt(prop), value);
308
- return true;
309
- }
310
-
311
- target[prop] = value;
312
- return true;
313
- },
314
- });
315
- return proxy;
316
- }
317
- globalThis.__createNativeProxy = __createNativeProxy;
318
-
319
- globalThis.getErrorStack = (err) => {
320
- if (err) return err.stack;
321
- const stack = new Error("").stack;
322
- const lines = stack.split("\n");
323
- // Line 2 results in invalid stack if not replaced when doing typescript extend.
324
- lines[2] = " at extend(native)";
325
- return lines.join("\n");
326
- };
327
- })();
3
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
4
+ var c = arguments.length;
5
+ var r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
6
+
7
+ if (typeof global.Reflect === "object" && typeof global.Reflect.decorate === "function") {
8
+ r = global.Reflect.decorate(decorators, target, key, desc);
9
+ }
10
+ else {
11
+ for (var i = decorators.length - 1; i >= 0; i--) {
12
+ if (d = decorators[i]) {
13
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
14
+ }
15
+ }
16
+ }
17
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
18
+ };
19
+
20
+ // For backward compatibility.
21
+ var __native = function (thiz) {
22
+ // we are setting the __container__ property to the base class when the super method is called
23
+ // if the constructor returns the __native(this) call we will use the old implementation
24
+ // copying all the properties to the result
25
+ // otherwise if we are using the result from the super() method call we won't need such logic
26
+ // as thiz already contains the parent properties
27
+ // this way we now support both implementations in typescript generated constructors:
28
+ // 1: super(); return __native(this);
29
+ // 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 {
46
+ return thiz;
47
+ }
48
+ };
49
+
50
+ var __extends = function (Child, Parent) {
51
+ var extendNativeClass = !!Parent.extend && (Parent.extend.toString().indexOf("[native code]") > -1);
52
+ if (!extendNativeClass) {
53
+ __extends_ts(Child, Parent);
54
+ return;
55
+ }
56
+ if (Parent.__isPrototypeImplementationObject) {
57
+ throw new Error("Can not extend an already extended native object.");
58
+ }
59
+
60
+ function extend(thiz) {
61
+ var child = thiz.__proto__.__child;
62
+ if (!child.__extended) {
63
+ var parent = thiz.__proto__.__parent;
64
+ child.__extended = parent.extend(child.name, child.prototype, true);
65
+ // This will deal with "i instanceof child"
66
+ child[Symbol.hasInstance] = function (instance) {
67
+ return instance instanceof this.__extended;
68
+ }
69
+ }
70
+ return child.__extended;
71
+ };
72
+
73
+ Parent.__activityExtend = function (parent, name, implementationObject) {
74
+ __log("__activityExtend called");
75
+ return parent.extend(name, implementationObject);
76
+ };
77
+
78
+ Parent.call = function (thiz) {
79
+ var Extended = extend(thiz);
80
+ thiz.__container__ = true;
81
+ if (arguments.length > 1) {
82
+ thiz.__proto__ = new (Function.prototype.bind.apply(Extended, [null].concat(Array.prototype.slice.call(arguments, 1))));
83
+ }
84
+ else {
85
+ thiz.__proto__ = new Extended()
86
+ }
87
+ return thiz.__proto__;
88
+ };
89
+
90
+ Parent.apply = function (thiz, args) {
91
+ var Extended = extend(thiz);
92
+ thiz.__container__ = true;
93
+ if (args && args.length > 0) {
94
+ thiz.__proto__ = new (Function.prototype.bind.apply(Extended, [null].concat(args)));
95
+ }
96
+ else {
97
+ thiz.__proto__ = new Extended();
98
+ }
99
+ return thiz.__proto__;
100
+ };
101
+ __extends_ns(Child, Parent);
102
+ Child.__isPrototypeImplementationObject = true;
103
+ Child.__proto__ = Parent;
104
+ Child.prototype.__parent = Parent;
105
+ Child.prototype.__child = Child;
106
+ }
107
+
108
+ var __extends_ts = function (child, parent) {
109
+ extendStaticFunctions(child, parent);
110
+ assignPrototypeFromParentToChild(parent, child);
111
+ };
112
+
113
+ var __extends_ns = function (child, parent) {
114
+ if (!parent.extend) {
115
+ assignPropertiesFromParentToChild(parent, child);
116
+ }
117
+
118
+ assignPrototypeFromParentToChild(parent, child);
119
+ };
120
+
121
+ var extendStaticFunctions =
122
+ Object.setPrototypeOf
123
+ || (hasInternalProtoProperty() && function (child, parent) { child.__proto__ = parent; })
124
+ || assignPropertiesFromParentToChild;
125
+
126
+ function hasInternalProtoProperty() {
127
+ return { __proto__: [] } instanceof Array;
128
+ }
129
+
130
+ function assignPropertiesFromParentToChild(parent, child) {
131
+ for (var property in parent) {
132
+ if (parent.hasOwnProperty(property)) {
133
+ child[property] = parent[property];
134
+ }
135
+ }
136
+ }
137
+
138
+ function assignPrototypeFromParentToChild(parent, child) {
139
+ function __() {
140
+ this.constructor = child;
141
+ }
142
+
143
+ if (parent === null) {
144
+ child.prototype = Object.create(null);
145
+ } else {
146
+ __.prototype = parent.prototype;
147
+ child.prototype = new __();
148
+ }
149
+ }
150
+
151
+
152
+ function JavaProxy(className) {
153
+ return function (target) {
154
+ var extended = target.extend(className, target.prototype)
155
+ extended.name = className;
156
+ return extended;
157
+ };
158
+ }
159
+
160
+ function Interfaces(interfacesArr) {
161
+ return function (target) {
162
+ if (interfacesArr instanceof Array) {
163
+ // attach interfaces: [] to the object
164
+ target.prototype.interfaces = interfacesArr;
165
+ }
166
+ }
167
+ }
168
+
169
+ Object.defineProperty(global, "__native", { value: __native });
170
+ Object.defineProperty(global, "__extends", { value: __extends });
171
+ Object.defineProperty(global, "__decorate", { value: __decorate });
172
+
173
+ if (!global.__ns__worker) {
174
+ global.JavaProxy = JavaProxy;
175
+ }
176
+ global.Interfaces = Interfaces;
177
+ })()
@@ -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("Inspector", "To dbg backend: " + message.getTextPayload() + " ThreadId:" + Thread.currentThread().getId());
294
+ Log.d("V8Inspector", "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 = false;
9
+ private boolean enabled;
10
10
 
11
11
  public LogcatLogger(Context context) {
12
12
  this.initLogging(context);
@@ -33,12 +33,13 @@ 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
- if (Util.isPositive(verboseLoggingProp)) {
40
- setEnabled(true);
41
- }
42
- }
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
+ }
43
44
  }
44
45
  }
@@ -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();