@mentra/crust 3.2.1 → 3.3.0-beta.1000
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 +27 -0
- package/android/build.gradle +24 -9
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/java/com/mentra/crust/CrustModule.kt +44 -15
- package/android/src/main/java/com/mentra/crust/http/NativeHttpFailure.kt +31 -0
- package/android/src/main/java/com/mentra/crust/http/NativeHttpRequests.kt +86 -0
- package/android/src/main/java/com/mentra/crust/jsc/JSCPolyfillBridge.kt +69 -54
- package/android/src/main/java/com/mentra/crust/jsc/JSCRuntime.kt +65 -8
- package/android/src/main/java/com/mentra/crust/jsc/JSDeliveryDiagnostics.kt +44 -0
- package/android/src/main/java/com/mentra/crust/navigation/NavigationManager.kt +4 -0
- package/android/src/main/java/com/mentra/crust/preview/PixelCopyPreview.kt +76 -0
- package/android/src/test/java/com/mentra/crust/http/NativeHttpFailureTest.kt +44 -0
- package/android/src/test/java/com/mentra/crust/http/NativeHttpRequestsTest.kt +133 -0
- package/android/src/test/java/com/mentra/crust/jsc/FetchBridgeTest.kt +199 -0
- package/android/src/test/java/com/mentra/crust/jsc/JSDeliveryDiagnosticsTest.kt +54 -0
- package/android/src/test/java/com/mentra/crust/jsc/QuickJsLifecycleTest.kt +87 -0
- package/build/Crust.types.d.ts +25 -11
- package/build/Crust.types.d.ts.map +1 -1
- package/build/Crust.types.js.map +1 -1
- package/build/CrustModule.d.ts +9 -2
- package/build/CrustModule.d.ts.map +1 -1
- package/build/CrustModule.js.map +1 -1
- package/build/CrustModule.web.d.ts +3 -1
- package/build/CrustModule.web.d.ts.map +1 -1
- package/build/CrustModule.web.js +20 -8
- package/build/CrustModule.web.js.map +1 -1
- package/build/index.d.ts +1 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -0
- package/build/index.js.map +1 -1
- package/build/nativeHttpRequest.d.ts +13 -0
- package/build/nativeHttpRequest.d.ts.map +1 -0
- package/build/nativeHttpRequest.js +51 -0
- package/build/nativeHttpRequest.js.map +1 -0
- package/build/nativeHttpRequest.test.d.ts +2 -0
- package/build/nativeHttpRequest.test.d.ts.map +1 -0
- package/build/nativeHttpRequest.test.js +88 -0
- package/build/nativeHttpRequest.test.js.map +1 -0
- package/ios/Crust.podspec +1 -1
- package/ios/CrustModule.swift +18 -7
- package/ios/PermissionStatusReceipt.swift +105 -0
- package/ios/Resources/startup.js +154 -68
- package/ios/Source/JSCPolyfillBridge.swift +31 -14
- 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/src/Crust.types.ts +26 -12
- package/src/CrustModule.ts +9 -1
- package/src/CrustModule.web.ts +18 -7
- package/src/index.ts +1 -0
- package/src/nativeHttpRequest.test.ts +94 -0
- package/src/nativeHttpRequest.ts +74 -0
- package/android/src/internal/AndroidManifest.xml +0 -9
- package/android/src/internal/java/com/mentra/crust/receivers/CaptionsTesterIncidentReceiver.kt +0 -46
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
package com.mentra.crust.jsc
|
|
2
|
+
|
|
3
|
+
import java.io.File
|
|
4
|
+
import java.util.concurrent.LinkedBlockingQueue
|
|
5
|
+
import java.util.concurrent.TimeUnit
|
|
6
|
+
import kotlin.math.PI
|
|
7
|
+
import kotlin.math.roundToInt
|
|
8
|
+
import kotlin.math.sin
|
|
9
|
+
import okhttp3.MediaType.Companion.toMediaType
|
|
10
|
+
import okhttp3.Protocol
|
|
11
|
+
import okhttp3.Request
|
|
12
|
+
import okhttp3.Response
|
|
13
|
+
import okhttp3.ResponseBody.Companion.toResponseBody
|
|
14
|
+
import okhttp3.mockwebserver.Dispatcher
|
|
15
|
+
import okhttp3.mockwebserver.MockResponse
|
|
16
|
+
import okhttp3.mockwebserver.MockWebServer
|
|
17
|
+
import okhttp3.mockwebserver.RecordedRequest
|
|
18
|
+
import okio.Buffer
|
|
19
|
+
import okio.ByteString.Companion.decodeBase64
|
|
20
|
+
import org.junit.After
|
|
21
|
+
import org.junit.Assert.*
|
|
22
|
+
import org.junit.Before
|
|
23
|
+
import org.junit.Test
|
|
24
|
+
import org.junit.runner.RunWith
|
|
25
|
+
import org.robolectric.RobolectricTestRunner
|
|
26
|
+
import org.robolectric.RuntimeEnvironment
|
|
27
|
+
import org.robolectric.annotation.Config
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Miniapp `fetch` end to end on Android's real stack: the shipped startup.js
|
|
31
|
+
* polyfill in QuickJS, [JSCRuntime]'s dispatcher and `__deliver` path, this
|
|
32
|
+
* bridge, and OkHttp against a local server. Each miniapp script reports
|
|
33
|
+
* through a `test` dispatch, which the runtime forwards to `onOutbound`.
|
|
34
|
+
*/
|
|
35
|
+
@RunWith(RobolectricTestRunner::class)
|
|
36
|
+
@Config(sdk = [28], manifest = Config.NONE)
|
|
37
|
+
class FetchBridgeTest {
|
|
38
|
+
private val packageName = "com.mentra.fetchtest"
|
|
39
|
+
private val results = LinkedBlockingQueue<Map<*, *>>()
|
|
40
|
+
private lateinit var server: MockWebServer
|
|
41
|
+
private lateinit var runtime: JSCRuntime
|
|
42
|
+
|
|
43
|
+
/** A 24 kHz 16-bit sine followed by every byte value: mostly not valid UTF-8. */
|
|
44
|
+
private val pcm = ByteArray(4800 * 2 + 256).also { out ->
|
|
45
|
+
for (i in 0 until 4800) {
|
|
46
|
+
val sample = (sin(2 * PI * 220 * i / 24000) * 20000).roundToInt()
|
|
47
|
+
out[2 * i] = sample.toByte()
|
|
48
|
+
out[2 * i + 1] = (sample shr 8).toByte()
|
|
49
|
+
}
|
|
50
|
+
for (value in 0 until 256) out[9600 + value] = value.toByte()
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Valid UTF-8 that is still binary data: a BOM, NUL and DEL must all survive. */
|
|
54
|
+
private val utf8Bytes = byteArrayOf(0xEF.toByte(), 0xBB.toByte(), 0xBF.toByte()) +
|
|
55
|
+
"{\"a\":\"é😀\"}".toByteArray(Charsets.UTF_8) + byteArrayOf(0x00, 0x7F)
|
|
56
|
+
|
|
57
|
+
// crust's build.gradle ships this file as the runtime's startup.js asset.
|
|
58
|
+
private val polyfill: String by lazy { File("../../jspolyfill/assets/startup.js").readText() }
|
|
59
|
+
|
|
60
|
+
@Before fun setUp() {
|
|
61
|
+
server = MockWebServer().apply {
|
|
62
|
+
dispatcher = object : Dispatcher() {
|
|
63
|
+
override fun dispatch(request: RecordedRequest): MockResponse = when (request.path) {
|
|
64
|
+
"/reply.pcm" -> response("application/octet-stream").setBody(Buffer().write(pcm))
|
|
65
|
+
"/utf8.bin" -> response("application/octet-stream").setBody(Buffer().write(utf8Bytes))
|
|
66
|
+
"/data.json" -> response("application/json").setBody("{\"message\":\"héllo 😀 中文\"}")
|
|
67
|
+
"/upload" -> response("text/plain").setBody("ok")
|
|
68
|
+
else -> MockResponse().setResponseCode(404)
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
start()
|
|
72
|
+
}
|
|
73
|
+
runtime = JSCRuntime.shared(RuntimeEnvironment.getApplication())
|
|
74
|
+
JSCPolyfillBridge.install(runtime)
|
|
75
|
+
runtime.onOutbound = { message ->
|
|
76
|
+
if (message.payload["iface"] == "test") {
|
|
77
|
+
results.add((message.payload["args"] as List<*>).first() as Map<*, *>)
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
@After fun tearDown() {
|
|
83
|
+
runtime.kill(packageName)
|
|
84
|
+
runtime.onOutbound = null
|
|
85
|
+
server.shutdown()
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
@Test fun `arrayBuffer returns the exact bytes of a binary response`() {
|
|
89
|
+
val result = runMiniapp(
|
|
90
|
+
"""
|
|
91
|
+
const response = await fetch(BASE + "/reply.pcm")
|
|
92
|
+
const bytes = new Uint8Array(await response.arrayBuffer())
|
|
93
|
+
return {status: response.status, type: response.headers.get("content-type"), bytes: Array.from(bytes)}
|
|
94
|
+
""",
|
|
95
|
+
)
|
|
96
|
+
assertEquals(200, result["status"])
|
|
97
|
+
assertEquals("application/octet-stream", result["type"])
|
|
98
|
+
assertArrayEquals(pcm, bytes(result["bytes"]))
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
@Test fun `arrayBuffer returns the exact bytes of a body that is valid UTF-8`() {
|
|
102
|
+
val result = runMiniapp(
|
|
103
|
+
"""
|
|
104
|
+
const response = await fetch(BASE + "/utf8.bin")
|
|
105
|
+
return {bytes: Array.from(new Uint8Array(await response.arrayBuffer()))}
|
|
106
|
+
""",
|
|
107
|
+
)
|
|
108
|
+
assertArrayEquals(utf8Bytes, bytes(result["bytes"]))
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
@Test fun `responses are sent as text only when that text re-encodes to the same bytes`() {
|
|
112
|
+
val text = JSCPolyfillBridge.fetchResult(responseWith(utf8Bytes))
|
|
113
|
+
assertEquals(String(utf8Bytes, Charsets.UTF_8), text.getString("body"))
|
|
114
|
+
assertFalse(text.has("bodyBase64"))
|
|
115
|
+
|
|
116
|
+
val empty = JSCPolyfillBridge.fetchResult(responseWith(ByteArray(0)))
|
|
117
|
+
assertEquals("", empty.getString("body"))
|
|
118
|
+
|
|
119
|
+
// Truncated, overlong, surrogate and out-of-range sequences, then raw PCM.
|
|
120
|
+
for (binary in listOf(byteArrayOf(0x41, 0xE2.toByte(), 0x82.toByte()), byteArrayOf(0xC0.toByte(), 0x80.toByte()),
|
|
121
|
+
byteArrayOf(0xED.toByte(), 0xA0.toByte(), 0x80.toByte()), byteArrayOf(0xF4.toByte(), 0x90.toByte(), 0x80.toByte(), 0x80.toByte()), pcm)) {
|
|
122
|
+
val result = JSCPolyfillBridge.fetchResult(responseWith(binary))
|
|
123
|
+
assertFalse(result.has("body"))
|
|
124
|
+
assertArrayEquals(binary, result.getString("bodyBase64").decodeBase64()!!.toByteArray())
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
@Test fun `text and json decode a UTF-8 response`() {
|
|
129
|
+
val result = runMiniapp(
|
|
130
|
+
"""
|
|
131
|
+
const text = await (await fetch(BASE + "/data.json")).text()
|
|
132
|
+
const json = await (await fetch(BASE + "/data.json")).json()
|
|
133
|
+
return {text, message: json.message}
|
|
134
|
+
""",
|
|
135
|
+
)
|
|
136
|
+
assertEquals("{\"message\":\"héllo 😀 中文\"}", result["text"])
|
|
137
|
+
assertEquals("héllo 😀 中文", result["message"])
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
@Test fun `binary request bodies reach the server byte for byte`() {
|
|
141
|
+
val result = runMiniapp(
|
|
142
|
+
"""
|
|
143
|
+
const backing = Uint8Array.from({length: 600}, (_, i) => (i * 37 + 11) & 255)
|
|
144
|
+
const response = await fetch(BASE + "/upload", {
|
|
145
|
+
method: "POST",
|
|
146
|
+
headers: {"Content-Type": "audio/L16; rate=24000"},
|
|
147
|
+
body: backing.subarray(44),
|
|
148
|
+
})
|
|
149
|
+
return {status: response.status, text: await response.text()}
|
|
150
|
+
""",
|
|
151
|
+
)
|
|
152
|
+
assertEquals(200, result["status"])
|
|
153
|
+
assertEquals("ok", result["text"])
|
|
154
|
+
val upload = server.takeRequest()
|
|
155
|
+
val expected = ByteArray(600) { ((it * 37 + 11) and 255).toByte() }.copyOfRange(44, 600)
|
|
156
|
+
assertArrayEquals(expected, upload.body.readByteArray())
|
|
157
|
+
assertEquals("audio/L16; rate=24000", upload.getHeader("Content-Type"))
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
@Test fun `string request bodies keep their UTF-8 text and content type`() {
|
|
161
|
+
runMiniapp(
|
|
162
|
+
"""
|
|
163
|
+
await fetch(BASE + "/upload", {method: "POST", headers: {"Content-Type": "application/json"}, body: '{"t":"é😀"}'})
|
|
164
|
+
return {}
|
|
165
|
+
""",
|
|
166
|
+
)
|
|
167
|
+
val upload = server.takeRequest()
|
|
168
|
+
assertEquals("{\"t\":\"é😀\"}", upload.body.readUtf8())
|
|
169
|
+
assertEquals("application/json; charset=utf-8", upload.getHeader("Content-Type"))
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
private fun runMiniapp(body: String): Map<*, *> {
|
|
173
|
+
val script =
|
|
174
|
+
"""
|
|
175
|
+
const BASE = "${server.url("/").toString().removeSuffix("/")}"
|
|
176
|
+
const report = (value) => __mentraSendOneShot("test", "result", [value])
|
|
177
|
+
;(async () => {
|
|
178
|
+
$body
|
|
179
|
+
})().then(report, (error) => report({error: String(error && (error.message || error))}))
|
|
180
|
+
""".trimIndent()
|
|
181
|
+
assertTrue("spawn failed", runtime.spawn(packageName, polyfill, script))
|
|
182
|
+
val result = results.poll(15, TimeUnit.SECONDS) ?: throw AssertionError("miniapp did not report a result")
|
|
183
|
+
assertNull("miniapp script threw", result["error"])
|
|
184
|
+
return result
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
private fun bytes(value: Any?): ByteArray =
|
|
188
|
+
(value as List<*>).map { (it as Number).toInt().toByte() }.toByteArray()
|
|
189
|
+
|
|
190
|
+
private fun response(contentType: String) = MockResponse().setHeader("Content-Type", contentType)
|
|
191
|
+
|
|
192
|
+
private fun responseWith(body: ByteArray): Response = Response.Builder()
|
|
193
|
+
.request(Request.Builder().url("https://example.com/body").build())
|
|
194
|
+
.protocol(Protocol.HTTP_1_1)
|
|
195
|
+
.code(200)
|
|
196
|
+
.message("OK")
|
|
197
|
+
.body(body.toResponseBody("application/octet-stream".toMediaType()))
|
|
198
|
+
.build()
|
|
199
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
package com.mentra.crust.jsc
|
|
2
|
+
|
|
3
|
+
import org.junit.Assert.*
|
|
4
|
+
import org.junit.Test
|
|
5
|
+
|
|
6
|
+
class JSDeliveryDiagnosticsTest {
|
|
7
|
+
@Test fun `queue wait and evaluate duration are distinct`() {
|
|
8
|
+
var now = 100L
|
|
9
|
+
val events = mutableListOf<Map<String, Any?>>()
|
|
10
|
+
val diagnostic = JSDeliveryDiagnostics(7, 2, { now }, { events += it })
|
|
11
|
+
diagnostic.entry()
|
|
12
|
+
now = 110
|
|
13
|
+
diagnostic.queued()
|
|
14
|
+
now = 310
|
|
15
|
+
diagnostic.started()
|
|
16
|
+
now = 350
|
|
17
|
+
diagnostic.finished()
|
|
18
|
+
|
|
19
|
+
assertEquals(listOf("native-entry", "queued", "started", "finished"), events.map { it["phase"] })
|
|
20
|
+
assertEquals(200L, events.last()["queueWaitMs"])
|
|
21
|
+
assertEquals(40L, events.last()["evaluateMs"])
|
|
22
|
+
assertEquals(250L, events.last()["elapsedMs"])
|
|
23
|
+
assertEquals(7L, events.last()["deliveryId"])
|
|
24
|
+
assertEquals(2L, events.last()["contextId"])
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@Test fun `failure includes exception identity without payload or message`() {
|
|
28
|
+
val events = mutableListOf<Map<String, Any?>>()
|
|
29
|
+
val diagnostic = JSDeliveryDiagnostics(1, 4, { 0L }, { events += it })
|
|
30
|
+
val error = IllegalStateException("private-token user transcript", IllegalArgumentException("private-source"))
|
|
31
|
+
diagnostic.entry()
|
|
32
|
+
diagnostic.queued()
|
|
33
|
+
diagnostic.started()
|
|
34
|
+
diagnostic.finished(error)
|
|
35
|
+
|
|
36
|
+
assertEquals("evaluate-failed", events.last()["phase"])
|
|
37
|
+
assertEquals("IllegalStateException", events.last()["errorClass"])
|
|
38
|
+
assertEquals("IllegalArgumentException", events.last()["causeClass"])
|
|
39
|
+
assertFalse(events.toString().contains("private-"))
|
|
40
|
+
assertFalse(events.toString().contains("transcript"))
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@Test fun `missing context and rejected executor have explicit terminal events`() {
|
|
44
|
+
for (reason in listOf("context-missing", "executor-rejected")) {
|
|
45
|
+
val events = mutableListOf<Map<String, Any?>>()
|
|
46
|
+
val diagnostic = JSDeliveryDiagnostics(9, null, { 0L }, { events += it })
|
|
47
|
+
diagnostic.entry()
|
|
48
|
+
diagnostic.dropped(reason)
|
|
49
|
+
assertEquals(reason, events.last()["phase"])
|
|
50
|
+
assertNull(events.last()["contextId"])
|
|
51
|
+
assertNull(events.last()["evaluateMs"])
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
package com.mentra.crust.jsc
|
|
2
|
+
|
|
3
|
+
import com.dokar.quickjs.QuickJs
|
|
4
|
+
import com.dokar.quickjs.QuickJsException
|
|
5
|
+
import com.dokar.quickjs.binding.function
|
|
6
|
+
import java.util.concurrent.Executors
|
|
7
|
+
import kotlinx.coroutines.Dispatchers
|
|
8
|
+
import kotlinx.coroutines.runBlocking
|
|
9
|
+
import kotlinx.coroutines.withTimeout
|
|
10
|
+
import org.junit.Assert.*
|
|
11
|
+
import org.junit.Test
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Runs the real QuickJS JNI library (through the desktop JVM artifact, see
|
|
15
|
+
* build.gradle) the way [JSCRuntime] uses it: one instance per miniapp, Kotlin
|
|
16
|
+
* bindings called from JS, and independent close orders.
|
|
17
|
+
*/
|
|
18
|
+
class QuickJsLifecycleTest {
|
|
19
|
+
private fun create() = QuickJs.create(Dispatchers.Unconfined)
|
|
20
|
+
|
|
21
|
+
@Test fun `closing one instance keeps another instance's callbacks working`() = runBlocking {
|
|
22
|
+
var calls = 0
|
|
23
|
+
val survivor = create()
|
|
24
|
+
survivor.function("hostCallback") { calls++; 42 }
|
|
25
|
+
val other = create()
|
|
26
|
+
assertEquals(42, survivor.evaluate<Int>("hostCallback()"))
|
|
27
|
+
other.close()
|
|
28
|
+
withTimeout(1000) { assertEquals(42, survivor.evaluate<Int>("hostCallback()")) }
|
|
29
|
+
assertEquals(2, calls)
|
|
30
|
+
repeat(20) {
|
|
31
|
+
create().close()
|
|
32
|
+
assertEquals(42, survivor.evaluate<Int>("hostCallback()"))
|
|
33
|
+
}
|
|
34
|
+
val workers = Executors.newFixedThreadPool(4)
|
|
35
|
+
try {
|
|
36
|
+
(1..40).map { workers.submit { create().close() } }.forEach { it.get() }
|
|
37
|
+
assertEquals(42, survivor.evaluate<Int>("hostCallback()"))
|
|
38
|
+
} finally {
|
|
39
|
+
workers.shutdownNow()
|
|
40
|
+
}
|
|
41
|
+
survivor.close()
|
|
42
|
+
val fresh = create()
|
|
43
|
+
fresh.function("hostCallback") { 7 }
|
|
44
|
+
assertEquals(7, fresh.evaluate<Int>("hostCallback()"))
|
|
45
|
+
fresh.close()
|
|
46
|
+
val older = create()
|
|
47
|
+
val newer = create()
|
|
48
|
+
newer.function("hostCallback") { 9 }
|
|
49
|
+
older.close()
|
|
50
|
+
assertEquals(9, newer.evaluate<Int>("hostCallback()"))
|
|
51
|
+
newer.close()
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@Test fun `a binding exception is a catchable JS Error carrying the message`() = runBlocking {
|
|
55
|
+
val qjs = create()
|
|
56
|
+
qjs.function("__dispatch") { throw MentraJSDispatchError("INVALID_ARGS", "iface") }
|
|
57
|
+
val caught = qjs.evaluate<String>(
|
|
58
|
+
"try { __dispatch(); 'no throw' } catch (e) { (e instanceof Error) + '|' + e.message }",
|
|
59
|
+
)
|
|
60
|
+
assertEquals("true|INVALID_ARGS: iface", caught)
|
|
61
|
+
qjs.close()
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@Test fun `non-ASCII strings cross the bridge unchanged`() = runBlocking {
|
|
65
|
+
val text = "héllo 😀 中文 \u0000 end"
|
|
66
|
+
var received: String? = null
|
|
67
|
+
val qjs = create()
|
|
68
|
+
qjs.function("hostText") { text }
|
|
69
|
+
qjs.function("hostEcho") { args -> received = args[0] as String; args[0] }
|
|
70
|
+
assertEquals(text, qjs.evaluate<String>("hostEcho(hostText())"))
|
|
71
|
+
assertEquals(text, received)
|
|
72
|
+
qjs.close()
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@Test fun `unusual thrown values fail as exceptions, not crashes`() = runBlocking {
|
|
76
|
+
val qjs = create()
|
|
77
|
+
for (source in listOf("throw undefined", "throw null", "throw new Error('%s%n%s%n')")) {
|
|
78
|
+
try {
|
|
79
|
+
qjs.evaluate<Any?>(source)
|
|
80
|
+
fail("$source did not throw")
|
|
81
|
+
} catch (_: QuickJsException) {
|
|
82
|
+
}
|
|
83
|
+
assertEquals(2, qjs.evaluate<Int>("1 + 1"))
|
|
84
|
+
}
|
|
85
|
+
qjs.close()
|
|
86
|
+
}
|
|
87
|
+
}
|
package/build/Crust.types.d.ts
CHANGED
|
@@ -14,7 +14,6 @@ export type CrustModuleEvents = {
|
|
|
14
14
|
onHeading: (params: HeadingPayload) => void;
|
|
15
15
|
phone_notification: (event: PhoneNotificationEvent) => void;
|
|
16
16
|
phone_notification_dismissed: (event: PhoneNotificationDismissedEvent) => void;
|
|
17
|
-
captions_tester_incident: (event: CaptionsTesterIncidentEvent) => void;
|
|
18
17
|
};
|
|
19
18
|
export type NavOffRoutePayload = {
|
|
20
19
|
/** Approximate perpendicular distance in meters from the route. */
|
|
@@ -107,6 +106,8 @@ export type NavManeuverPayload = {
|
|
|
107
106
|
};
|
|
108
107
|
export type NavErrorPayload = {
|
|
109
108
|
message: string;
|
|
109
|
+
/** True only when native navigation has ended; absent for recoverable reroute errors. */
|
|
110
|
+
terminal?: boolean;
|
|
110
111
|
};
|
|
111
112
|
export type InstalledApp = {
|
|
112
113
|
packageName: string;
|
|
@@ -133,16 +134,6 @@ export type PhoneNotificationDismissedEvent = {
|
|
|
133
134
|
packageName: string;
|
|
134
135
|
notificationId: string;
|
|
135
136
|
};
|
|
136
|
-
export type CaptionsTesterIncidentEvent = {
|
|
137
|
-
action?: string;
|
|
138
|
-
timestamp?: number;
|
|
139
|
-
failure_code?: string;
|
|
140
|
-
failure_message?: string;
|
|
141
|
-
test_run_id?: string;
|
|
142
|
-
scenario_name?: string;
|
|
143
|
-
source?: string;
|
|
144
|
-
[key: string]: unknown;
|
|
145
|
-
};
|
|
146
137
|
export type CrustViewProps = {
|
|
147
138
|
url: string;
|
|
148
139
|
onLoad: (event: {
|
|
@@ -150,4 +141,27 @@ export type CrustViewProps = {
|
|
|
150
141
|
}) => void;
|
|
151
142
|
style?: StyleProp<ViewStyle>;
|
|
152
143
|
};
|
|
144
|
+
/** Passive OS observations for the currently executing Mentra App. */
|
|
145
|
+
export type AppPermissionStatus = {
|
|
146
|
+
rawStatus: string | null;
|
|
147
|
+
status: "granted" | "denied" | "blocked" | "unavailable" | "unknown";
|
|
148
|
+
};
|
|
149
|
+
export type AppPermissionSnapshot = {
|
|
150
|
+
schemaVersion: 1;
|
|
151
|
+
observedAt: string;
|
|
152
|
+
identity: {
|
|
153
|
+
pid: number;
|
|
154
|
+
uid: number;
|
|
155
|
+
bundleId: string;
|
|
156
|
+
bundlePath: string;
|
|
157
|
+
executablePath: string;
|
|
158
|
+
version: string;
|
|
159
|
+
build: string;
|
|
160
|
+
};
|
|
161
|
+
locationServicesEnabled: boolean;
|
|
162
|
+
permissions: Record<"location" | "camera" | "microphone" | "bluetooth" | "localNetwork", AppPermissionStatus>;
|
|
163
|
+
};
|
|
164
|
+
export type AppPermissionReceipt = AppPermissionSnapshot & {
|
|
165
|
+
requestId: string;
|
|
166
|
+
};
|
|
153
167
|
//# sourceMappingURL=Crust.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Crust.types.d.ts","sourceRoot":"","sources":["../src/Crust.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,SAAS,EAAE,SAAS,EAAC,MAAM,cAAc,CAAA;AAEtD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,CAAC,MAAM,EAAE,kBAAkB,KAAK,IAAI,CAAA;IAC9C,aAAa,EAAE,CAAC,MAAM,EAAE,kBAAkB,KAAK,IAAI,CAAA;IACnD,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,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
{"version":3,"file":"Crust.types.js","sourceRoot":"","sources":["../src/Crust.types.ts"],"names":[],"mappings":"","sourcesContent":["import type {StyleProp, ViewStyle} from \"react-native\"\n\nexport type OnLoadEventPayload = {\n url: string\n}\n\nexport type CrustModuleEvents = {\n onChange: (params: ChangeEventPayload) => void\n onNavManeuver: (params: NavManeuverPayload) => void\n onNavRerouting: (params: Record<string, never>) => void\n onNavArrived: (params: Record<string, never>) => void\n onNavError: (params: NavErrorPayload) => void\n onNavLocation: (params: NavLocationPayload) => void\n onNavRoute: (params: NavRoutePayload) => void\n onNavOffRoute: (params: NavOffRoutePayload) => void\n onHeading: (params: HeadingPayload) => void\n phone_notification: (event: PhoneNotificationEvent) => void\n phone_notification_dismissed: (event: PhoneNotificationDismissedEvent) => void\n
|
|
1
|
+
{"version":3,"file":"Crust.types.js","sourceRoot":"","sources":["../src/Crust.types.ts"],"names":[],"mappings":"","sourcesContent":["import type {StyleProp, ViewStyle} from \"react-native\"\n\nexport type OnLoadEventPayload = {\n url: string\n}\n\nexport type CrustModuleEvents = {\n onChange: (params: ChangeEventPayload) => void\n onNavManeuver: (params: NavManeuverPayload) => void\n onNavRerouting: (params: Record<string, never>) => void\n onNavArrived: (params: Record<string, never>) => void\n onNavError: (params: NavErrorPayload) => void\n onNavLocation: (params: NavLocationPayload) => void\n onNavRoute: (params: NavRoutePayload) => void\n onNavOffRoute: (params: NavOffRoutePayload) => void\n onHeading: (params: HeadingPayload) => void\n phone_notification: (event: PhoneNotificationEvent) => void\n phone_notification_dismissed: (event: PhoneNotificationDismissedEvent) => void\n}\n\nexport type NavOffRoutePayload = {\n /** Approximate perpendicular distance in meters from the route. */\n offRouteDistanceMeters: number\n}\n\nexport type HeadingPayload = {\n /** Compass heading in degrees, 0 = north, 90 = east. */\n degrees: number\n}\n\nexport type NavRoutePayload = {\n points: Array<{lat: number; lng: number}>\n /**\n * Ordered step list along the route, when supplied by the host. Each\n * step is one navigable segment — typically one straight stretch of\n * road ending in a maneuver. Optional for back-compat with older\n * hosts that only ship the polyline. The SDK's pivot module consumes\n * this to enrich pivots with `fromRoad` / `toRoad` metadata.\n */\n steps?: NavRouteStepPayload[]\n}\n\nexport type NavRouteStepPayload = {\n /** Coordinate where this step begins (== end of the previous step). */\n lat: number\n lng: number\n /**\n * Index into `NavRoutePayload.points[]` where this step starts.\n * Lets consumers correlate step boundaries with polyline geometry.\n */\n routeIndex: number\n /** Name of the road traversed during this step. Null when the engine has no name. */\n road?: string | null\n /**\n * Categorical maneuver performed at the END of this step (i.e. how\n * the user exits this step). Same vocabulary as `NavManeuverPayload.maneuverType`.\n */\n maneuver: string\n /** Length of this step in meters. */\n distanceMeters: number\n}\n\nexport type NavLocationPayload = {\n lat: number\n lng: number\n /** Horizontal accuracy in meters, if reported by the platform. */\n accuracy: number | null\n /** Unix ms timestamp of the fix. */\n timestamp: number\n}\n\nexport type ChangeEventPayload = {\n value: string\n}\n\nexport type NavManeuverPayload = {\n /**\n * Categorical type of the upcoming maneuver. One of: STRAIGHT,\n * SLIGHT_LEFT, SLIGHT_RIGHT, TURN_LEFT, TURN_RIGHT, SHARP_LEFT,\n * SHARP_RIGHT, U_TURN, ARRIVE.\n */\n maneuverType: string\n /** Distance in meters from the user's current position to that maneuver. -1 if unknown. */\n distanceMeters: number\n /** Road the user is currently on, per the Nav SDK. Null if unavailable. */\n fromRoad?: string | null\n /**\n * Legacy \"next road\" field — historically populated from the same\n * source as `fromRoad` (the current step's road, NOT the road\n * after the upcoming turn). Kept for back-compat. New consumers\n * should read `nextStepRoad` instead.\n */\n toRoad?: string | null\n /**\n * Road the user will be on AFTER the upcoming maneuver, sourced\n * from the Nav SDK's `remainingSteps[0]`. This is the value to\n * show as the \"next street\" headline on the maneuver card. Null\n * when the SDK hasn't surfaced a remaining step yet (final leg,\n * pre-first-NavInfo, etc.).\n */\n nextStepRoad?: string | null\n /** Total remaining distance to final destination, meters. -1 if unknown. */\n distanceToDestinationMeters?: number\n /** Total remaining travel time, seconds. -1 if unknown. */\n timeToDestinationSeconds?: number\n /** Current speed in m/s. Null if unavailable. */\n currentSpeedMps?: number | null\n /** Speed limit on the current road segment in m/s. Null if unknown / not regulated. */\n speedLimitMps?: number | null\n /** Bearing along the route at the user's current position, 0–360. Null if unknown. */\n routeHeadingDeg?: number | null\n}\n\nexport type NavErrorPayload = {\n message: string\n /** True only when native navigation has ended; absent for recoverable reroute errors. */\n terminal?: boolean\n}\n\nexport type InstalledApp = {\n packageName: string\n appName: string\n isBlocked: boolean\n icon: string | null\n}\n\nexport type PhoneNotificationEvent = {\n notificationId: string\n app: string\n title: string\n content: string\n /**\n * Android notification priority: PRIORITY_MIN (-2) through PRIORITY_MAX (2).\n * Derived from the channel importance when the ranking is available, since\n * Notification.priority reads 0 for channel-based notifications.\n */\n priority: number\n timestamp: number\n packageName: string\n}\n\nexport type PhoneNotificationDismissedEvent = {\n notificationKey: string\n packageName: string\n notificationId: string\n}\n\nexport type CrustViewProps = {\n url: string\n onLoad: (event: {nativeEvent: OnLoadEventPayload}) => void\n style?: StyleProp<ViewStyle>\n}\n\n/** Passive OS observations for the currently executing Mentra App. */\nexport type AppPermissionStatus = {\n rawStatus: string | null\n status: \"granted\" | \"denied\" | \"blocked\" | \"unavailable\" | \"unknown\"\n}\n\nexport type AppPermissionSnapshot = {\n schemaVersion: 1\n observedAt: string\n identity: {\n pid: number\n uid: number\n bundleId: string\n bundlePath: string\n executablePath: string\n version: string\n build: string\n }\n locationServicesEnabled: boolean\n permissions: Record<\"location\" | \"camera\" | \"microphone\" | \"bluetooth\" | \"localNetwork\", AppPermissionStatus>\n}\n\nexport type AppPermissionReceipt = AppPermissionSnapshot & {requestId: string}\n"]}
|
package/build/CrustModule.d.ts
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
import { NativeModule } from "expo";
|
|
2
|
-
import { CrustModuleEvents, InstalledApp } from "./Crust.types";
|
|
2
|
+
import { AppPermissionReceipt, AppPermissionSnapshot, CrustModuleEvents, InstalledApp } from "./Crust.types";
|
|
3
3
|
declare class CrustModule extends NativeModule<CrustModuleEvents> {
|
|
4
4
|
/** True for the native iOS app running on an Apple Silicon Mac. */
|
|
5
5
|
readonly isIOSAppOnMac?: boolean;
|
|
6
|
+
/** iOS: passive actual-app authorization status; never requests consent. */
|
|
7
|
+
getPermissionStatus(requestId: null): Promise<AppPermissionSnapshot>;
|
|
8
|
+
/** iOS: a nonce publishes fresh status at the fixed managed-cache path. */
|
|
9
|
+
getPermissionStatus(requestId: string): Promise<AppPermissionReceipt>;
|
|
6
10
|
PI: number;
|
|
7
11
|
hello(): string;
|
|
8
12
|
setValueAsync(value: string): Promise<void>;
|
|
9
|
-
|
|
13
|
+
/** Android: copy the displayed view's window pixels to a temporary JPEG URI. */
|
|
14
|
+
captureMiniappPreview(viewTag: number): Promise<string>;
|
|
15
|
+
nativeHttpRequest(requestId: string, method: string, url: string, headers: Record<string, string>, body?: string | null): Promise<{
|
|
10
16
|
status: number;
|
|
11
17
|
statusText: string;
|
|
12
18
|
headers: Record<string, string>;
|
|
13
19
|
body: string;
|
|
14
20
|
}>;
|
|
21
|
+
cancelNativeHttpRequest(requestId: string): Promise<void>;
|
|
15
22
|
showAVRoutePicker(tintColor?: string | null): void;
|
|
16
23
|
/**
|
|
17
24
|
* iOS: configure `preferredScreenEdgesDeferringSystemGestures`. When an
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CrustModule.d.ts","sourceRoot":"","sources":["../src/CrustModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAsB,MAAM,MAAM,CAAA;AAEtD,OAAO,EAAC,iBAAiB,EAAE,YAAY,EAAC,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"CrustModule.d.ts","sourceRoot":"","sources":["../src/CrustModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAsB,MAAM,MAAM,CAAA;AAEtD,OAAO,EAAC,oBAAoB,EAAE,qBAAqB,EAAE,iBAAiB,EAAE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OAAO,CAAC,IAAI,CAAC;IAChD;;;;;OAKG;IACH,oBAAoB,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAC3F,mBAAmB,CAAC,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAC9E,qEAAqE;IACrE,qBAAqB,IAAI,MAAM,EAAE;IACjC,0DAA0D;IAC1D,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAC3D;;;;;OAKG;IACH,0BAA0B,IAAI,MAAM;CACrC;;AAGD,wBAAwD"}
|
package/build/CrustModule.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CrustModule.js","sourceRoot":"","sources":["../src/CrustModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,mBAAmB,EAAC,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"CrustModule.js","sourceRoot":"","sources":["../src/CrustModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,mBAAmB,EAAC,MAAM,MAAM,CAAA;AAwMtD,yDAAyD;AACzD,eAAe,mBAAmB,CAAc,OAAO,CAAC,CAAA","sourcesContent":["import {NativeModule, requireNativeModule} from \"expo\"\n\nimport {AppPermissionReceipt, AppPermissionSnapshot, CrustModuleEvents, InstalledApp} from \"./Crust.types\"\n\ndeclare class CrustModule extends NativeModule<CrustModuleEvents> {\n /** True for the native iOS app running on an Apple Silicon Mac. */\n readonly isIOSAppOnMac?: boolean\n /** iOS: passive actual-app authorization status; never requests consent. */\n getPermissionStatus(requestId: null): Promise<AppPermissionSnapshot>\n /** iOS: a nonce publishes fresh status at the fixed managed-cache path. */\n getPermissionStatus(requestId: string): Promise<AppPermissionReceipt>\n PI: number\n hello(): string\n setValueAsync(value: string): Promise<void>\n /** Android: copy the displayed view's window pixels to a temporary JPEG URI. */\n captureMiniappPreview(viewTag: number): Promise<string>\n nativeHttpRequest(\n requestId: string,\n method: string,\n url: string,\n headers: Record<string, string>,\n body?: string | null,\n ): Promise<{status: number; statusText: string; headers: Record<string, string>; body: string}>\n cancelNativeHttpRequest(requestId: string): Promise<void>\n showAVRoutePicker(tintColor?: string | null): void\n\n /**\n * iOS: configure `preferredScreenEdgesDeferringSystemGestures`. When an\n * edge is deferred, the first swipe across that edge is consumed by the\n * app and the system gesture (Control Center, Notification Center, Home\n * indicator) only fires on a second swipe — i.e. a two-swipe-to-exit UX.\n *\n * Pass `[]` to restore default behavior. Android: no-op (Android has no\n * per-app equivalent; system gestures are configured at the OS level).\n */\n setDeferredSystemGestures(edges: Array<\"top\" | \"bottom\" | \"left\" | \"right\" | \"all\">): Promise<void>\n\n // MentraOS Notification Commands\n setNotificationConfig(listenerEnabled: boolean, blocklist: string[]): Promise<void>\n getInstalledApps(): Promise<InstalledApp[]>\n getInstalledAppsForNotifications(): Promise<InstalledApp[]>\n hasNotificationListenerPermission(): Promise<boolean>\n refreshNotificationListener(): Promise<boolean>\n openNotificationListenerSettings(): Promise<boolean>\n isBetaBuild(): Promise<boolean>\n // location services commands\n showLocationServicesDialog(): Promise<boolean>\n isLocationServicesEnabled(): Promise<boolean>\n openLocationSettings(): Promise<boolean>\n openAppSettings(): Promise<boolean>\n openBluetoothSettings(): Promise<boolean>\n\n // Image Processing Commands\n processGalleryImage(\n inputPath: string,\n outputPath: string,\n options: {\n lensCorrection?: boolean\n colorCorrection?: boolean\n },\n ): Promise<{\n success: boolean\n outputPath?: string\n processingTimeMs?: number\n error?: string\n }>\n\n mergeHdrBrackets(\n underPath: string,\n normalPath: string,\n overPath: string,\n outputPath: string,\n ): Promise<{\n success: boolean\n outputPath?: string\n processingTimeMs?: number\n error?: string\n }>\n\n stabilizeVideo(\n inputPath: string,\n imuPath: string,\n outputPath: string,\n ): Promise<{\n success: boolean\n outputPath?: string\n processingTimeMs?: number\n error?: string\n }>\n\n // Media Library Commands\n saveToGalleryWithDate(\n filePath: string,\n captureTimeMillis?: number,\n displayName?: string,\n ): Promise<{\n success: boolean\n uri?: string\n identifier?: string\n existing?: boolean\n error?: string\n }>\n\n // Navigation (Android only — iOS stubs return error)\n startNavigation(\n lat: number,\n lng: number,\n options?: {\n simulate?: boolean\n speedMultiplier?: number\n /** Optional multi-stop list. When present takes precedence over lat/lng. Last entry is the final destination. */\n stops?: Array<{lat: number; lng: number}>\n /** \"walking\" | \"driving\" | \"cycling\" | \"two_wheeler\". Defaults driving. */\n mode?: string\n avoid?: {highways?: boolean; tolls?: boolean; ferries?: boolean}\n /** Force a reroute when the user is more than N meters past a pivot they didn't take. */\n missedTurnRerouteMeters?: number\n },\n ): Promise<{ok: boolean; error?: string}>\n stopNavigation(): Promise<{ok: boolean; error?: string}>\n\n /**\n * Show the Google Nav SDK Terms & Conditions dialog if not already\n * accepted. Idempotent — resolves immediately with `{accepted: true}`\n * when the user has already accepted (cached in-process / on-disk /\n * inside the SDK).\n */\n requestNavigationPermission(): Promise<{ok: boolean; accepted: boolean; error?: string}>\n\n /**\n * Dev-only: clear cached T&C acceptance (SDK flag + on-disk pref +\n * in-process flag) so the next requestNavigationPermission() re-shows\n * the dialog. Android only; iOS returns {ok: false, error: \"not\n * supported on iOS\"}.\n */\n resetNavigationPermission(): Promise<{ok: boolean; error?: string}>\n\n /**\n * Dev-only: nudge the simulated user position ~offsetMeters perpendicular\n * to the route so the Nav SDK reroutes. Default 20m. Android only.\n */\n simulateDeviation(offsetMeters?: number): Promise<{ok: boolean; error?: string}>\n\n /**\n * Dev toggle. When enabled, the native NavigationManager shifts every\n * reported location ~8m perpendicular to the route bearing, simulating\n * a pedestrian walking on the wrong sidewalk. Only meaningful in\n * simulate mode; lets us verify the SDK's along-path pivot trigger\n * fires even when the user never crosses the 7m pivot point radius.\n * Android-only today; iOS is a no-op stub.\n */\n setWrongSidewalkOffset(enabled: boolean): Promise<{ok: boolean; error?: string}>\n\n /**\n * Dev toggle. When enabled, the native NavigationManager takes over\n * from the Google simulator and walks the user along a modified\n * polyline that omits crossing micro-steps — reproducing the\n * wrong-sidewalk-then-missed-the-turn scenario. Android-only today;\n * iOS is a no-op stub.\n */\n setSkipCrossings(enabled: boolean): Promise<{ok: boolean; error?: string}>\n\n // Heading / compass (Android only)\n startHeading(): Promise<{ok: boolean; error?: string}>\n stopHeading(): Promise<{ok: boolean; error?: string}>\n\n // MentraJS Runtime — per-miniapp JSContext lifecycle.\n /**\n * Spawn a per-miniapp JS context. Re-spawn is allowed: a live context\n * with the same packageName is killed first. Returns true if the\n * polyfill bundle + miniapp source evaluated without throwing.\n *\n * The polyfill bundle is `mobile/modules/mentrajs-runtime/dist/startup.js`\n * (shipped inside the host binary). It installs window-style globals\n * (console, timers, fetch, localStorage, crypto) atop the JSC runtime.\n */\n mentraJsSpawn(packageName: string, polyfillBundle: string, miniappJs: string): Promise<boolean>\n mentraJsEvaluate(packageName: string, source: string): Promise<unknown>\n mentraJsKill(packageName: string): Promise<void>\n /**\n * Push a `{kind: \"event\"|\"response\", …}` envelope into the named\n * context's globalThis.__deliver. Returns when the underlying\n * evaluateScript completes (the JS handler runs synchronously on the\n * context's queue).\n */\n mentraJsDispatchToJs(packageName: string, envelope: Record<string, unknown>): Promise<void>\n mentraJsSetManifest(packageName: string, permissions: string[]): Promise<void>\n /** Diagnostic — returns the packageNames of every live JSContext. */\n mentraJsAlivePackages(): string[]\n /** Diagnostic — force a GC cycle on the named context. */\n mentraJsDebugForceGC(packageName: string): Promise<boolean>\n /**\n * Read the bundled MentraJS polyfill (startup.js) shipped inside the\n * host binary. Synchronous — host RN code calls this once on app boot\n * and caches the string, then passes it to every mentraJsSpawn so\n * every JSContext starts with the same polyfill ABI.\n */\n mentraJsLoadPolyfillBundle(): string\n}\n\n// This call loads the native module object from the JSI.\nexport default requireNativeModule<CrustModule>(\"Crust\")\n"]}
|
|
@@ -2,8 +2,9 @@ import { NativeModule } from "expo";
|
|
|
2
2
|
import { CrustModuleEvents } from "./Crust.types";
|
|
3
3
|
declare class CrustModule extends NativeModule<CrustModuleEvents> {
|
|
4
4
|
PI: number;
|
|
5
|
+
private readonly httpRequests;
|
|
5
6
|
setValueAsync(value: string): Promise<void>;
|
|
6
|
-
nativeHttpRequest(method: string, url: string, headers: Record<string, string>, body?: string | null): Promise<{
|
|
7
|
+
nativeHttpRequest(requestId: string, method: string, url: string, headers: Record<string, string>, body?: string | null): Promise<{
|
|
7
8
|
status: number;
|
|
8
9
|
statusText: string;
|
|
9
10
|
headers: {
|
|
@@ -11,6 +12,7 @@ declare class CrustModule extends NativeModule<CrustModuleEvents> {
|
|
|
11
12
|
};
|
|
12
13
|
body: string;
|
|
13
14
|
}>;
|
|
15
|
+
cancelNativeHttpRequest(requestId: string): Promise<void>;
|
|
14
16
|
hello(): string;
|
|
15
17
|
showAVRoutePicker(_tintColor?: string | null): void;
|
|
16
18
|
setDeferredSystemGestures(_edges: string[]): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CrustModule.web.d.ts","sourceRoot":"","sources":["../src/CrustModule.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,YAAY,EAAC,MAAM,MAAM,CAAA;AAEpD,OAAO,EAAC,iBAAiB,EAAC,MAAM,eAAe,CAAA;AAE/C,cAAM,WAAY,SAAQ,YAAY,CAAC,iBAAiB,CAAC;IACvD,EAAE,SAAU;
|
|
1
|
+
{"version":3,"file":"CrustModule.web.d.ts","sourceRoot":"","sources":["../src/CrustModule.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,YAAY,EAAC,MAAM,MAAM,CAAA;AAEpD,OAAO,EAAC,iBAAiB,EAAC,MAAM,eAAe,CAAA;AAE/C,cAAM,WAAY,SAAQ,YAAY,CAAC,iBAAiB,CAAC;IACvD,EAAE,SAAU;IACZ,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAqC;IAC5D,aAAa,CAAC,KAAK,EAAE,M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Requests = new Map();
|
|
4
5
|
async setValueAsync(value) {
|
|
5
6
|
this.emit("onChange", { value });
|
|
6
7
|
}
|
|
7
|
-
async nativeHttpRequest(method, url, headers, body) {
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
async nativeHttpRequest(requestId, method, url, headers, body) {
|
|
9
|
+
const controller = new AbortController();
|
|
10
|
+
this.httpRequests.set(requestId, controller);
|
|
11
|
+
try {
|
|
12
|
+
const response = await fetch(url, { method, headers, body, signal: controller.signal });
|
|
13
|
+
return {
|
|
14
|
+
status: response.status,
|
|
15
|
+
statusText: response.statusText,
|
|
16
|
+
headers: Object.fromEntries(response.headers.entries()),
|
|
17
|
+
body: await response.text(),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
finally {
|
|
21
|
+
this.httpRequests.delete(requestId);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
async cancelNativeHttpRequest(requestId) {
|
|
25
|
+
this.httpRequests.get(requestId)?.abort();
|
|
26
|
+
this.httpRequests.delete(requestId);
|
|
15
27
|
}
|
|
16
28
|
hello() {
|
|
17
29
|
return "Hello world! 👋";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CrustModule.web.js","sourceRoot":"","sources":["../src/CrustModule.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAE,YAAY,EAAC,MAAM,MAAM,CAAA;AAIpD,MAAM,WAAY,SAAQ,YAA+B;IACvD,EAAE,GAAG,IAAI,CAAC,EAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"CrustModule.web.js","sourceRoot":"","sources":["../src/CrustModule.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAE,YAAY,EAAC,MAAM,MAAM,CAAA;AAIpD,MAAM,WAAY,SAAQ,YAA+B;IACvD,EAAE,GAAG,IAAI,CAAC,EAAE,CAAA;IACK,YA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,CAAC,gBAAyB,EAAE,UAAoB,IAAkB,CAAC;IAC9F,KAAK,CAAC,gBAAgB;QACpB,OAAO,EAAE,CAAA;IACX,CAAC;IACD,KAAK,CAAC,gCAAgC;QACpC,OAAO,EAAE,CAAA;IACX,CAAC;IACD,KAAK,CAAC,iCAAiC;QACrC,OAAO,KAAK,CAAA;IACd,CAAC;IACD,KAAK,CAAC,2BAA2B;QAC/B,OAAO,KAAK,CAAA;IACd,CAAC;IACD,KAAK,CAAC,gCAAgC;QACpC,OAAO,KAAK,CAAA;IACd,CAAC;IACD,KAAK,CAAC,WAAW;QACf,OAAO,KAAK,CAAA;IACd,CAAC;IACD,KAAK,CAAC,aAAa,CAAC,IAAY,EAAE,SAAiB,EAAE,UAAkB;QACrE,OAAO,KAAK,CAAA;IACd,CAAC;IACD,KAAK,CAAC,gBAAgB,CAAC,IAAY,EAAE,IAAY;QAC/C,OAAO,IAAI,CAAA;IACb,CAAC;IACD,KAAK,CAAC,YAAY,CAAC,IAAY;QAC7B,OAAM;IACR,CAAC;IACD,KAAK,CAAC,oBAAoB,CAAC,IAAY,EAAE,IAA6B;QACpE,OAAM;IACR,CAAC;IACD,KAAK,CAAC,mBAAmB,CAAC,IAAY,EAAE,MAAgB;QACtD,OAAM;IACR,CAAC;IACD,qBAAqB;QACnB,OAAO,EAAE,CAAA;IACX,CAAC;IACD,KAAK,CAAC,oBAAoB,CAAC,IAAY;QACrC,OAAO,KAAK,CAAA;IACd,CAAC;IACD,0BAA0B;QACxB,OAAO,EAAE,CAAA;IACX,CAAC;CACF;AAED,eAAe,iBAAiB,CAAC,WAAW,EAAE,aAAa,CAAC,CAAA","sourcesContent":["import {registerWebModule, NativeModule} from \"expo\"\n\nimport {CrustModuleEvents} from \"./Crust.types\"\n\nclass CrustModule extends NativeModule<CrustModuleEvents> {\n PI = Math.PI\n private readonly httpRequests = new Map<string, AbortController>()\n async setValueAsync(value: string): Promise<void> {\n this.emit(\"onChange\", {value})\n }\n async nativeHttpRequest(requestId: string, method: string, url: string, headers: Record<string, string>, body?: string | null) {\n const controller = new AbortController()\n this.httpRequests.set(requestId, controller)\n try {\n const response = await fetch(url, {method, headers, body, signal: controller.signal})\n return {\n status: response.status,\n statusText: response.statusText,\n headers: Object.fromEntries(response.headers.entries()),\n body: await response.text(),\n }\n } finally {\n this.httpRequests.delete(requestId)\n }\n }\n async cancelNativeHttpRequest(requestId: string): Promise<void> {\n this.httpRequests.get(requestId)?.abort()\n this.httpRequests.delete(requestId)\n }\n hello() {\n return \"Hello world! 👋\"\n }\n showAVRoutePicker(_tintColor?: string | null) {}\n async setDeferredSystemGestures(_edges: string[]): Promise<void> {}\n async setNotificationConfig(_listenerEnabled: boolean, _blocklist: string[]): Promise<void> {}\n async getInstalledApps() {\n return []\n }\n async getInstalledAppsForNotifications() {\n return []\n }\n async hasNotificationListenerPermission() {\n return false\n }\n async refreshNotificationListener() {\n return false\n }\n async openNotificationListenerSettings() {\n return false\n }\n async isBetaBuild() {\n return false\n }\n async mentraJsSpawn(_pkg: string, _polyfill: string, _miniappJs: string) {\n return false\n }\n async mentraJsEvaluate(_pkg: string, _src: string) {\n return null\n }\n async mentraJsKill(_pkg: string) {\n return\n }\n async mentraJsDispatchToJs(_pkg: string, _env: Record<string, unknown>) {\n return\n }\n async mentraJsSetManifest(_pkg: string, _perms: string[]) {\n return\n }\n mentraJsAlivePackages() {\n return []\n }\n async mentraJsDebugForceGC(_pkg: string) {\n return false\n }\n mentraJsLoadPolyfillBundle() {\n return \"\"\n }\n}\n\nexport default registerWebModule(CrustModule, \"CrustModule\")\n"]}
|