@everframe/react-native 1.3.0 → 1.4.1

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.
@@ -0,0 +1,72 @@
1
+ // SPDX-License-Identifier: MIT
2
+ // SPDX-FileCopyrightText: 2026 ScriptX
3
+ package dev.everframe.rn
4
+
5
+ import android.view.View
6
+ import dev.everframe.capture.InteractionTargetRegistry
7
+ import java.lang.ref.WeakReference
8
+ import java.util.UUID
9
+
10
+ /** Synchronous ownership cancellation, UI-only host resolution. Never waits for the UI thread. */
11
+ internal class RnInteractionTargetRegistration(
12
+ private val resolve: (Int) -> View?,
13
+ private val dispatch: (() -> Unit) -> Unit,
14
+ ) : AutoCloseable {
15
+ private class Request(val tag: Int, val generation: Long, val annotation: Map<String, Any?>) {
16
+ var view: WeakReference<View>? = null
17
+ }
18
+ private val namespace = UUID.randomUUID().toString() + ":"
19
+ private val requests = mutableMapOf<String, Request>()
20
+ private var destroyed = false
21
+ private val pending = mutableMapOf<String, Request>()
22
+ private fun integer(value: Double, maximum: Double) = value.isFinite() && value >= 0 && value <= maximum && value == value.toLong().toDouble()
23
+
24
+ @Synchronized fun set(tag: Double, id: String, generation: Double, annotation: Map<String, Any?>): Boolean {
25
+ if (destroyed || tag <= 0 || !integer(tag, Int.MAX_VALUE.toDouble()) || !integer(generation, 9007199254740990.0)) return false
26
+ val key = namespace + id
27
+ if (!InteractionTargetRegistry.beginSet(key, generation.toLong())) return false
28
+ val request = Request(tag.toInt(), generation.toLong(), annotation)
29
+ requests[id] = request
30
+ pending[id] = request
31
+ enqueue(id, request)
32
+ return true
33
+ }
34
+ private fun enqueue(id: String, request: Request) {
35
+ try { dispatch {
36
+ synchronized(this) {
37
+ if (!destroyed && requests[id] === request) {
38
+ val view = runCatching { resolve(request.tag) }.getOrNull()
39
+ // A resolved host cannot migrate to a replacement using the same numeric tag.
40
+ if (view != null && (request.view == null || request.view?.get() === view)) {
41
+ pending.remove(id)
42
+ request.view = WeakReference(view)
43
+ InteractionTargetRegistry.completeSet(view, namespace + id, request.generation, request.annotation)
44
+ }
45
+ }
46
+ }
47
+ } } catch (_: Throwable) { InteractionTargetRegistry.clear(namespace + id, request.generation + 1) }
48
+ }
49
+ /** Fabric can deliver the ref before the native mount. Retry only live unresolved owners. */
50
+ @Synchronized fun onMount() {
51
+ if (!destroyed && pending.isNotEmpty()) pending.toList().forEach { (id, request) -> enqueue(id, request) }
52
+ }
53
+
54
+ @Synchronized fun clear(id: String, generation: Double): Boolean {
55
+ if (destroyed || !integer(generation, 9007199254740991.0)) return false
56
+ val current = requests[id]
57
+ if (current == null || generation > current.generation) { requests.remove(id); pending.remove(id) }
58
+ InteractionTargetRegistry.clear(namespace + id, generation.toLong())
59
+ return true
60
+ }
61
+ /** Provider configure may run after child ref attachment. Core start clears its registry. */
62
+ @Synchronized fun onStarted() {
63
+ if (!destroyed) requests.forEach { (id, request) ->
64
+ if (InteractionTargetRegistry.beginSet(namespace + id, request.generation)) { pending[id] = request; enqueue(id, request) }
65
+ }
66
+ }
67
+ @Synchronized override fun close() {
68
+ destroyed = true
69
+ requests.forEach { (id, request) -> InteractionTargetRegistry.clear(namespace + id, request.generation + 1) }
70
+ requests.clear(); pending.clear()
71
+ }
72
+ }
@@ -23,6 +23,8 @@ type Rect = {
23
23
  * Rich variants (e.g., callbacks, function refs) MUST stay on the JS side.
24
24
  */
25
25
  type ConfigOpts = {
26
+ /** Bounded local interaction policy; native validation remains authoritative. */
27
+ interactionsJson?: string;
26
28
  sdkKey?: string;
27
29
  sdkVersion?: string;
28
30
  /**
@@ -148,6 +150,9 @@ type ConfigOpts = {
148
150
  * sends it (the config's `debugBuild`, else `__DEV__`). Absent means the native SDK decides for itself.
149
151
  */
150
152
  debugBuild?: boolean;
153
+ /** Loaded Hermes identity for ordinary reports, independent of release health. */
154
+ jsBundleBuildId?: string;
155
+ jsBundleName?: string;
151
156
  /**
152
157
  * Native foreground monitoring (release health). The JS facade always sends this flag: `true` with a
153
158
  * validated loaded bundle, or `false` to revoke monitoring. A bridge that finds it missing treats it as
@@ -192,6 +197,16 @@ interface Spec extends TurboModule {
192
197
  * Typed `UnsafeObject` at codegen boundary; facade casts to `ReporterResult`.
193
198
  */
194
199
  openReporter(): Promise<UnsafeObject>;
200
+ openReporterWithTrigger(trigger: string): Promise<UnsafeObject>;
201
+ markReporterOpened(trigger: string): Promise<void>;
202
+ markReporterClosed(): Promise<void>;
203
+ setInteractionTarget(viewTag: number, registrationId: string, generation: number, annotation: UnsafeObject): boolean;
204
+ clearInteractionTarget(registrationId: string, generation: number): boolean;
205
+ /** Revocable semantic observation ownership; unrelated to replay controls. */
206
+ getInteractionLease(): string;
207
+ setInteractionObserver(viewTag: number, id: string, generation: number, lease: string, optionsJson: string): boolean;
208
+ clearInteractionObserver(id: string, generation: number): boolean;
209
+ recordInteraction(lease: string, id: string, generation: number, eventJson: string): boolean;
195
210
  registerSensitiveRect(viewTag: number, rect: Rect): void;
196
211
  /**
197
212
  * Set host-supplied free-form metadata for the next report. Single opaque
@@ -342,6 +357,9 @@ interface Spec extends TurboModule {
342
357
  * credential. It groups reports in the dashboard and does nothing else.
343
358
  */
344
359
  setUser(user?: UnsafeObject): void;
360
+ /** Synchronous acknowledgement preserves setState → fatal capture ordering. */
361
+ setStateSync(key: string, valueJson: string): boolean;
362
+ clearStateSync(key: string): boolean;
345
363
  }
346
364
  declare const _default: Spec;
347
365
 
@@ -0,0 +1 @@
1
+ import{a as i,c as s,e as a}from"./chunk-UN3Q4UGZ.js";import{a as t}from"./chunk-XUSV3KOD.js";var n=class extends Error{static{t(this,"EverframeNotMountedError")}name="EverframeNotMountedError";constructor(o){super(o??"EverframeProvider is not mounted; wrap your app root.")}},c="EVERFRAME_REPORTER_DISABLED",p=class extends Error{static{t(this,"EverframeReporterDisabledError")}name="EverframeReporterDisabledError";constructor(o){super(o??"The Everframe reporter is disabled in this session (reporter.disabled).")}};function d(e){return e==="button"||e==="shake"||e==="menu"||e==="companion"}t(d,"isReporterTrigger");var r=null,u={};function R(){return u}t(R,"__getContextEpoch");function f(){try{return r?.getPromiseRejectionStatus()??a("not-mounted","no-mount")}catch{return a("install-failed","hook-install")}}t(f,"getPromiseRejectionStatus");function S(e){r=e,u={}}t(S,"__setCurrentContext");function y(){return r}t(y,"__getCurrentContext");function C(e){let o=r;return o?o.open(e):Promise.reject(new n("EverframeProvider not mounted; wrap your root with <EverframeProvider>."))}t(C,"open");function k(e){r?.setExtra(e)}t(k,"setExtra");function b(e){r?.addBreadcrumb(e)}t(b,"addBreadcrumb");function P(e,o){o!==void 0?r?.recordScreen(e,o):r?.recordScreen(e)}t(P,"recordScreen");function O(e){r?.setUser(e)}t(O,"setUser");function w(e,o){r?.captureException(e,o)}t(w,"captureException");function h(){try{return r?.getErrorCaptureStatus()??s("not-mounted","no-mount")}catch{return s("not-mounted","no-mount")}}t(h,"getErrorCaptureStatus");function j(){let e=r;try{let o=e?.getReportDeliveryStatus();return e===r&&o?o:i("not-mounted","no-mount")}catch{return i("unavailable","native-call-failed")}}t(j,"getReportDeliveryStatus");function _(e,o){r?.setState(e,o)}t(_,"setState");function D(e){r?.clearState(e)}t(D,"clearState");async function T(e){await r?.markReporterOpened(e)}t(T,"markReporterOpened");async function V(){await r?.markReporterClosed()}t(V,"markReporterClosed");export{n as a,c as b,p as c,d,R as e,f,S as g,y as h,C as i,k as j,b as k,P as l,O as m,w as n,h as o,j as p,_ as q,D as r,T as s,V as t};