@mentra/crust 3.3.0-dev.656 → 3.3.0-dev.659
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 +7 -0
- package/android/build.gradle +15 -40
- package/android/src/main/java/com/mentra/crust/jsc/JSCRuntime.kt +13 -4
- package/android/src/test/java/com/mentra/crust/jsc/QuickJsLifecycleTest.kt +87 -0
- package/package.json +2 -2
- package/plugin/build/index.d.ts +2 -0
- package/plugin/build/index.js +2 -0
- package/plugin/build/withAndroid.js +39 -0
- package/android/quickjs-consumer-rules.pro +0 -6
- package/android/scripts/test-quickjs-lifecycle.py +0 -45
- package/android/src/main/cpp/quickjs/CMakeLists.txt +0 -20
- package/android/src/main/cpp/quickjs/LICENSE.quickjs-kt.txt +0 -201
- package/android/src/main/cpp/quickjs/README.md +0 -30
- package/android/src/main/cpp/quickjs/c-vector/LICENSE +0 -21
- package/android/src/main/cpp/quickjs/c-vector/cvector.h +0 -479
- package/android/src/main/cpp/quickjs/common/quickjs_version.c +0 -9
- package/android/src/main/cpp/quickjs/common/quickjs_version.h +0 -9
- package/android/src/main/cpp/quickjs/engine/LICENSE +0 -22
- package/android/src/main/cpp/quickjs/engine/VERSION +0 -1
- package/android/src/main/cpp/quickjs/engine/cutils.c +0 -631
- package/android/src/main/cpp/quickjs/engine/cutils.h +0 -347
- package/android/src/main/cpp/quickjs/engine/libbf.c +0 -8475
- package/android/src/main/cpp/quickjs/engine/libbf.h +0 -535
- package/android/src/main/cpp/quickjs/engine/libregexp-opcode.h +0 -57
- package/android/src/main/cpp/quickjs/engine/libregexp.c +0 -2501
- package/android/src/main/cpp/quickjs/engine/libregexp.h +0 -55
- package/android/src/main/cpp/quickjs/engine/libunicode-table.h +0 -4557
- package/android/src/main/cpp/quickjs/engine/libunicode.c +0 -1910
- package/android/src/main/cpp/quickjs/engine/libunicode.h +0 -182
- package/android/src/main/cpp/quickjs/engine/list.h +0 -99
- package/android/src/main/cpp/quickjs/engine/quickjs-atom.h +0 -273
- package/android/src/main/cpp/quickjs/engine/quickjs-opcode.h +0 -372
- package/android/src/main/cpp/quickjs/engine/quickjs.c +0 -55978
- package/android/src/main/cpp/quickjs/engine/quickjs.h +0 -1087
- package/android/src/main/cpp/quickjs/jni/binding_bridge.c +0 -488
- package/android/src/main/cpp/quickjs/jni/binding_bridge.h +0 -32
- package/android/src/main/cpp/quickjs/jni/exception_util.c +0 -64
- package/android/src/main/cpp/quickjs/jni/exception_util.h +0 -21
- package/android/src/main/cpp/quickjs/jni/jni_globals.c +0 -59
- package/android/src/main/cpp/quickjs/jni/jni_globals.h +0 -12
- package/android/src/main/cpp/quickjs/jni/jni_globals_generated.c +0 -855
- package/android/src/main/cpp/quickjs/jni/jni_globals_generated.h +0 -171
- package/android/src/main/cpp/quickjs/jni/js_value_util.c +0 -213
- package/android/src/main/cpp/quickjs/jni/js_value_util.h +0 -71
- package/android/src/main/cpp/quickjs/jni/log_util.h +0 -15
- package/android/src/main/cpp/quickjs/jni/mapping/jni_types_util.c +0 -27
- package/android/src/main/cpp/quickjs/jni/mapping/jni_types_util.h +0 -15
- package/android/src/main/cpp/quickjs/jni/mapping/jobject_to_js_value.c +0 -620
- package/android/src/main/cpp/quickjs/jni/mapping/jobject_to_js_value.h +0 -13
- package/android/src/main/cpp/quickjs/jni/mapping/js_value_to_jobject.c +0 -421
- package/android/src/main/cpp/quickjs/jni/mapping/js_value_to_jobject.h +0 -12
- package/android/src/main/cpp/quickjs/jni/promise_rejection_handler.c +0 -20
- package/android/src/main/cpp/quickjs/jni/promise_rejection_handler.h +0 -10
- package/android/src/main/cpp/quickjs/jni/quickjs_jni.c +0 -735
- package/android/src/main/cpp/quickjs/jni/quickjs_jni.h +0 -40
- package/android/src/testNative/QuickJsLifecycleTest.kt +0 -56
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
#ifndef QJS_KT_JNI_H
|
|
2
|
-
#define QJS_KT_JNI_H
|
|
3
|
-
|
|
4
|
-
#include <pthread.h>
|
|
5
|
-
#include "cvector.h"
|
|
6
|
-
#include "quickjs.h"
|
|
7
|
-
#include "jni.h"
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Global objects for the wrapped runtime.
|
|
11
|
-
*/
|
|
12
|
-
typedef struct {
|
|
13
|
-
/**
|
|
14
|
-
* Some JS values, used by C functions.
|
|
15
|
-
*/
|
|
16
|
-
cvector_vector_type(JSValue)managed_js_values;
|
|
17
|
-
/**
|
|
18
|
-
* Defined JS objects, keep them to support nested define.
|
|
19
|
-
*/
|
|
20
|
-
cvector_vector_type(JSValue)defined_js_objects;
|
|
21
|
-
/**
|
|
22
|
-
* Promise resolve/reject functions.
|
|
23
|
-
*/
|
|
24
|
-
cvector_vector_type(JSValue)created_js_functions;
|
|
25
|
-
/**
|
|
26
|
-
* Global JNI refs.
|
|
27
|
-
*/
|
|
28
|
-
cvector_vector_type(jobject)global_object_refs;
|
|
29
|
-
/**
|
|
30
|
-
* Result promises of eval calls.
|
|
31
|
-
*/
|
|
32
|
-
JSValue *evaluate_result_promise;
|
|
33
|
-
/**
|
|
34
|
-
* The mutex which is used to protect the JS stack in a multi-threaded environment.
|
|
35
|
-
* Scopes with a JS_UpdateStackTop() call are required to be locked.
|
|
36
|
-
*/
|
|
37
|
-
pthread_mutex_t js_mutex;
|
|
38
|
-
} Globals;
|
|
39
|
-
|
|
40
|
-
#endif //QJS_KT_JNI_H
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
package com.mentra.crust.jsc
|
|
2
|
-
|
|
3
|
-
import com.dokar.quickjs.QuickJs
|
|
4
|
-
import com.dokar.quickjs.binding.function
|
|
5
|
-
import kotlinx.coroutines.Dispatchers
|
|
6
|
-
import kotlinx.coroutines.runBlocking
|
|
7
|
-
import kotlinx.coroutines.withTimeout
|
|
8
|
-
import java.util.concurrent.Executors
|
|
9
|
-
|
|
10
|
-
/** Exercise actual JNI/Kotlin callbacks across independent runtime lifetimes. */
|
|
11
|
-
fun main() = runBlocking {
|
|
12
|
-
var calls = 0
|
|
13
|
-
val survivor = QuickJs.create(Dispatchers.Unconfined)
|
|
14
|
-
survivor.function("hostCallback") { calls++; 42 }
|
|
15
|
-
val other = QuickJs.create(Dispatchers.Unconfined)
|
|
16
|
-
check(survivor.evaluate<Int>("hostCallback()") == 42)
|
|
17
|
-
other.close()
|
|
18
|
-
var failure: Throwable? = null
|
|
19
|
-
try {
|
|
20
|
-
withTimeout(1000) { check(survivor.evaluate<Int>("hostCallback()") == 42) }
|
|
21
|
-
} catch (error: Throwable) {
|
|
22
|
-
failure = error
|
|
23
|
-
}
|
|
24
|
-
check(failure == null) { "Closing another instance broke the survivor: $failure" }
|
|
25
|
-
check(calls == 2)
|
|
26
|
-
repeat(20) {
|
|
27
|
-
val temporary = QuickJs.create(Dispatchers.Unconfined)
|
|
28
|
-
temporary.close()
|
|
29
|
-
check(survivor.evaluate<Int>("hostCallback()") == 42)
|
|
30
|
-
}
|
|
31
|
-
val workers = Executors.newFixedThreadPool(4)
|
|
32
|
-
try {
|
|
33
|
-
val jobs = (1..40).map {
|
|
34
|
-
workers.submit {
|
|
35
|
-
val temporary = QuickJs.create(Dispatchers.Unconfined)
|
|
36
|
-
temporary.close()
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
jobs.forEach { it.get() }
|
|
40
|
-
check(survivor.evaluate<Int>("hostCallback()") == 42)
|
|
41
|
-
} finally {
|
|
42
|
-
workers.shutdownNow()
|
|
43
|
-
}
|
|
44
|
-
survivor.close()
|
|
45
|
-
val fresh = QuickJs.create(Dispatchers.Unconfined)
|
|
46
|
-
fresh.function("hostCallback") { 7 }
|
|
47
|
-
check(fresh.evaluate<Int>("hostCallback()") == 7)
|
|
48
|
-
fresh.close()
|
|
49
|
-
val older = QuickJs.create(Dispatchers.Unconfined)
|
|
50
|
-
val newer = QuickJs.create(Dispatchers.Unconfined)
|
|
51
|
-
newer.function("hostCallback") { 9 }
|
|
52
|
-
older.close()
|
|
53
|
-
check(newer.evaluate<Int>("hostCallback()") == 9)
|
|
54
|
-
newer.close()
|
|
55
|
-
println("PASS: callbacks survive across both close orders, churn, and clean restart")
|
|
56
|
-
}
|