@quran.ws/qvp-react-native 0.6.1 → 0.8.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.
@@ -3,20 +3,25 @@ package ws.quran.qvp.rn
3
3
  import android.util.Base64
4
4
  import android.util.Log
5
5
  import com.facebook.react.bridge.Arguments
6
- import com.facebook.react.bridge.WritableMap
7
6
  import com.facebook.react.uimanager.ThemedReactContext
8
- import com.facebook.react.uimanager.UIManagerHelper
9
- import com.facebook.react.uimanager.events.Event
10
7
  import android.widget.FrameLayout
8
+ import java.util.concurrent.ConcurrentHashMap
9
+ import java.util.concurrent.locks.ReentrantReadWriteLock
10
+ import kotlin.concurrent.read
11
+ import kotlin.concurrent.write
11
12
  import ws.quran.qvp.*
12
13
  import ws.quran.qvp.Target
13
- import java.io.File
14
14
 
15
15
  /**
16
16
  * The React Native host of [QvpPageView]. It owns the loaded [QvpPage], loads bytes from the prop-given
17
17
  * URI, and reconciles the declarative props (theme / styles / highlights / mask / reveal) against engine
18
18
  * handles so JS never sees a handle. Every decision (hit-test, layout, style resolution, bands, masks)
19
19
  * is the engine's; this class only marshals and forwards.
20
+ *
21
+ * The module reads the page from its query thread while this view draws on the UI thread (see
22
+ * [read]). Those reads touch only what the page fixed when it loaded, so the two do not meet,
23
+ * except where the page is closed, replaced, or given a words sidecar: each of these holds
24
+ * [lock] for writing, and waits for a query in progress to finish.
20
25
  */
21
26
  class QvpRnPageView(private val ctx: ThemedReactContext) : FrameLayout(ctx) {
22
27
  private val density = ctx.resources.displayMetrics.density
@@ -24,7 +29,22 @@ class QvpRnPageView(private val ctx: ThemedReactContext) : FrameLayout(ctx) {
24
29
  val inner = QvpPageView(ctx).also { addView(it, LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)) }
25
30
  var page: QvpPage?
26
31
  get() = inner.page
27
- set(v) { inner.page = v }
32
+ private set(v) { inner.page = v }
33
+
34
+ /** Read by the module's queries, written where the page closes, changes, or takes a sidecar. */
35
+ private val lock = ReentrantReadWriteLock()
36
+ /** Run [block] on the page in view, held open until the block returns: null when no page is loaded.
37
+ * The block must not wait for the UI thread, which can be waiting for this lock. */
38
+ fun <T> read(block: (QvpPage?) -> T): T = lock.read { block(page) }
39
+ /** Attach a words sidecar. Queries in progress finish first, and the word records built
40
+ * before it are dropped, since the forms they hold have changed. */
41
+ fun attachWords(p: QvpPage, json: String): Int = lock.write { p.attachWords(json).also { dropWords() } }
42
+
43
+ private val wordsLock = Any()
44
+ private var words: QvpRnWords? = null
45
+ /** The word records of [p], built on first use and kept until the page changes or takes a sidecar. */
46
+ fun words(p: QvpPage): QvpRnWords = synchronized(wordsLock) { words?.takeIf { it.page === p } ?: QvpRnWords(p).also { words = it } }
47
+ private fun dropWords() = synchronized(wordsLock) { words = null }
28
48
  var paperColor: Int get() = inner.paperColor; set(v) { inner.paperColor = v; inner.invalidate() }
29
49
  var selectionBand: Int get() = inner.selectionBand; set(v) { inner.selectionBand = v }
30
50
  var selectionEnabled: Boolean get() = inner.selectionEnabled; set(v) { inner.selectionEnabled = v }
@@ -52,6 +72,7 @@ class QvpRnPageView(private val ctx: ThemedReactContext) : FrameLayout(ctx) {
52
72
  var highlightsProp: List<Any?>? = null
53
73
  var maskProp: Map<String, Any?>? = null
54
74
  var revealProp: Map<String, Any?>? = null
75
+ var dressProp: Map<String, Any?>? = null
55
76
  var layoutDirty = true
56
77
 
57
78
  // ── applied state ──
@@ -64,13 +85,14 @@ class QvpRnPageView(private val ctx: ThemedReactContext) : FrameLayout(ctx) {
64
85
  private var appliedMask: Map<String, Any?>? = null
65
86
  private var appliedReveal: Map<String, Any?>? = null // without "at"
66
87
  private var appliedRevealAt: Long? = null
88
+ private var appliedDress: Map<String, Any?>? = null
67
89
  private var appliedInk: Int? = null
68
90
  var revealStepCount = 0; private set
69
91
  var loadMs = 0.0; private set
70
92
  var pageBytes = 0; private set
71
93
 
72
94
  init {
73
- inner.onWordTap = { w, h -> page?.let { p -> emit("onWordTap", mapOf("word" to Marshal.word(p, w), "hit" to Marshal.hit(p, h))) } }
95
+ inner.onWordTap = { w, h -> page?.let { p -> emit("onWordTap", mapOf("word" to words(p).word(w.index), "hit" to Marshal.hit(p, h))) } }
74
96
  inner.onDecorationTap = { d, h -> page?.let { p -> emit("onDecorationTap", mapOf("decoration" to Marshal.decoration(d), "hit" to Marshal.hit(p, h))) } }
75
97
  inner.onEmptyTap = { emit("onEmptyTap", emptyMap()) }
76
98
  // The engine says a flick turns the page and by how many, in reading order. Which page
@@ -83,12 +105,16 @@ class QvpRnPageView(private val ctx: ThemedReactContext) : FrameLayout(ctx) {
83
105
  override fun onAttachedToWindow() { super.onAttachedToWindow(); QvpRegistry.register(this) }
84
106
  override fun onDetachedFromWindow() { QvpRegistry.unregister(this); super.onDetachedFromWindow() }
85
107
 
86
- fun destroy() { QvpRegistry.unregister(this); page?.close(); page = null; loadedKey = null }
108
+ fun destroy() { QvpRegistry.unregister(this); lock.write { page?.close(); page = null; dropWords() }; loadedKey = null }
87
109
 
88
110
  /** Padding props arrive in dp. */
89
111
  fun setPadTopDp(v: Float) { inner.padTop = v * density; layoutDirty = true }
90
112
  fun setPadBottomDp(v: Float) { inner.padBottom = v * density; layoutDirty = true }
91
113
  fun setPadSideDp(v: Float) { inner.padSide = v * density; layoutDirty = true }
114
+ fun setReflowBreaksProp(v: String?) {
115
+ inner.reflowBreaks = QvpBreaks.entries.find { it.name.equals(v, ignoreCase = true) } ?: QvpBreaks.FITTED
116
+ layoutDirty = true
117
+ }
92
118
  fun setLineSpacingProp(v: Float) { inner.lineSpacing = v; layoutDirty = true }
93
119
 
94
120
  // ── the reader's zoom control ──
@@ -116,18 +142,7 @@ class QvpRnPageView(private val ctx: ThemedReactContext) : FrameLayout(ctx) {
116
142
  fun setFillHeightProp(v: Boolean) { inner.fillHeight = v; layoutDirty = true }
117
143
  fun setSurahFramesProp(v: Boolean) { inner.surahFrames = v; layoutDirty = true }
118
144
 
119
- // ── bytes ──
120
- private fun readUri(uri: String): ByteArray {
121
- val u = uri.trim()
122
- return when {
123
- u.startsWith("asset://") -> ctx.assets.open(u.removePrefix("asset://")).use { it.readBytes() }
124
- u.startsWith("asset:") -> ctx.assets.open(u.removePrefix("asset:")).use { it.readBytes() }
125
- u.startsWith("file://") -> File(u.removePrefix("file://")).readBytes()
126
- u.startsWith("/") -> File(u).readBytes()
127
- u.startsWith("base64:") -> Base64.decode(u.removePrefix("base64:"), Base64.DEFAULT)
128
- else -> ctx.assets.open(u).use { it.readBytes() }
129
- }
130
- }
145
+ private fun readUri(uri: String): ByteArray = QvpRnBytes.read(ctx, uri)
131
146
 
132
147
  /** Called by the manager after every prop batch. */
133
148
  fun commit() {
@@ -137,7 +152,11 @@ class QvpRnPageView(private val ctx: ThemedReactContext) : FrameLayout(ctx) {
137
152
  if (p != null) {
138
153
  applyInk(p); applyTheme(p); applyStyles(p); applyHighlights(p); applyMask(p); applyReveal(p)
139
154
  }
140
- if (layoutDirty) { layoutDirty = false; inner.relayout(); resetView() }
155
+ var fit = false
156
+ if (layoutDirty) { layoutDirty = false; inner.relayout(); fit = true }
157
+ // After the layout: the engine places the ornaments on the layout in force.
158
+ if (p != null && applyDress(p)) fit = true
159
+ if (fit) resetView()
141
160
  commitZoom()
142
161
  inner.invalidate()
143
162
  } catch (e: Exception) {
@@ -150,16 +169,28 @@ class QvpRnPageView(private val ctx: ThemedReactContext) : FrameLayout(ctx) {
150
169
  val key = pageBase64?.let { "b64:" + it.hashCode() } ?: pageUri
151
170
  if (key == loadedKey) return
152
171
  // drop everything bound to the old page: handles die with it
153
- themeHandle = 0; appliedTheme = null; styleHandles.clear(); highlightHandles.clear(); appliedMask = null; appliedReveal = null; appliedRevealAt = null; appliedInk = null; revealStepCount = 0
154
- page?.close(); page = null; loadedKey = key
155
- if (key == null) return
156
- val bytes = pageBase64?.let { Base64.decode(it, Base64.DEFAULT) } ?: readUri(pageUri!!)
157
- val t0 = System.nanoTime()
158
- val p = QvpPage(bytes); p.buildPaths()
159
- loadMs = (System.nanoTime() - t0) / 1e6; pageBytes = bytes.size
160
- wordsUri?.let { runCatching { p.attachWords(readUri(it)) }.onFailure { e -> Log.w("QvpRn", "words sidecar: $e") } }
161
- page = p; layoutDirty = true
162
- emit("onPageLoad", Marshal.pageInfo(p) + mapOf("loadMs" to loadMs, "bytes" to pageBytes, "uri" to pageUri))
172
+ themeHandle = 0; appliedTheme = null; styleHandles.clear(); highlightHandles.clear(); appliedMask = null; appliedReveal = null; appliedRevealAt = null; appliedInk = null; appliedDress = null; revealStepCount = 0
173
+ loadedKey = key
174
+ if (key == null) { lock.write { page?.close(); page = null; dropWords() }; return }
175
+ // Load the new page before the swap, so a query sees the old page or the new one and
176
+ // never a view with no page. A load that fails leaves no page, as before.
177
+ val p: QvpPage
178
+ val bytes: ByteArray
179
+ val ms: Double
180
+ try {
181
+ bytes = pageBase64?.let { Base64.decode(it, Base64.DEFAULT) } ?: readUri(pageUri!!)
182
+ val t0 = System.nanoTime()
183
+ p = QvpPage(bytes); p.buildPaths()
184
+ ms = (System.nanoTime() - t0) / 1e6
185
+ // No query sees the page before the swap below, so the sidecar needs no lock.
186
+ wordsUri?.let { runCatching { p.attachWords(readUri(it)) }.onFailure { e -> Log.w("QvpRn", "words sidecar: $e") } }
187
+ } catch (e: Exception) {
188
+ lock.write { page?.close(); page = null; dropWords() }
189
+ throw e
190
+ }
191
+ lock.write { val old = page; page = p; dropWords(); loadMs = ms; pageBytes = bytes.size; old?.close() }
192
+ layoutDirty = true
193
+ emit("onPageLoad", Marshal.pageInfo(p, words(p).forms) + mapOf("loadMs" to loadMs, "bytes" to pageBytes, "uri" to pageUri))
163
194
  }
164
195
 
165
196
  private fun applyInk(p: QvpPage) {
@@ -236,25 +267,40 @@ class QvpRnPageView(private val ctx: ThemedReactContext) : FrameLayout(ctx) {
236
267
  if (at != appliedRevealAt) { appliedRevealAt = at; p.revealGoto(at) }
237
268
  }
238
269
 
239
- // ── events ──
240
- private class QvpEvent(surfaceId: Int, viewTag: Int, private val name: String, private val payload: WritableMap) : Event<QvpEvent>(surfaceId, viewTag) {
241
- override fun getEventName() = name
242
- override fun getEventData(): WritableMap = payload
243
- }
244
- fun emit(name: String, payload: Map<String, Any?>) {
245
- if (id <= 0) return
246
- val dispatcher = UIManagerHelper.getEventDispatcherForReactTag(ctx, id) ?: return
247
- dispatcher.dispatchEvent(QvpEvent(UIManagerHelper.getSurfaceId(this), id, name, Marshal.toMap(payload)))
270
+ /**
271
+ * The `dress` prop: {ornaments: set id, ...spec}. A new object dresses the page again and null
272
+ * undresses it. The hosted [QvpPageView] paints the layer behind the ink (qvp_dress_geometry,
273
+ * through the placements it applies to the ink, rasterised once per dress revision and scale)
274
+ * and fits the content plus the dress overflow. True when the page changed.
275
+ */
276
+ private fun applyDress(p: QvpPage): Boolean {
277
+ if (dressProp == appliedDress) return false
278
+ appliedDress = dressProp
279
+ val d = dressProp
280
+ val set = d?.let { QvpOrnamentSets.get((it["ornaments"] as? Number)?.toInt()) }
281
+ val info = when {
282
+ d == null -> { p.undress(); null }
283
+ set == null -> { p.undress(); emit("onError", mapOf("message" to "dress: no ornament set ${d["ornaments"]}")); null }
284
+ else -> p.dress(set, Marshal.dressSpec(d))
285
+ }
286
+ emit("onDressChanged", mapOf("info" to info?.let { Marshal.dressInfo(it) }))
287
+ return true
248
288
  }
289
+ /** The module's imperative dress: dress, fit the border in, draw. */
290
+ fun dressNow(p: QvpPage, set: QvpOrnaments, spec: QvpDressSpec): QvpDressInfo? = p.dress(set, spec).also { resetView(); inner.invalidate() }
291
+ fun undressNow(p: QvpPage) { p.undress(); resetView(); inner.invalidate() }
292
+
293
+ fun emit(name: String, payload: Map<String, Any?>) = QvpRnEvents.emit(ctx, this, name, payload)
249
294
 
250
295
  fun stats(): Map<String, Any?> = mapOf("loadMs" to loadMs, "bytes" to pageBytes, "baseMs" to inner.lastBaseMs, "overlayMs" to inner.lastOverlayMs, "basePaths" to inner.lastBasePaths, "overlayPaths" to inner.lastOverlayPaths,
251
296
  "bands" to inner.lastBands, "hitUs" to inner.lastHitUs, "animating" to inner.animating, "styleHandles" to (page?.styleHandles()?.size ?: 0), "highlightHandles" to (page?.highlightHandles()?.size ?: 0),
252
297
  "engineVersion" to QvpEngine.version(), "viewScale" to inner.viewScale, "layout" to page?.currentLayout?.let { Marshal.layout(it) })
253
298
  }
254
299
 
255
- /** Views by react tag, so the module can find the page behind a `viewTag` without going through the UIManager. */
300
+ /** Views by react tag, so the module can find the page behind a `viewTag` without going through the
301
+ * UIManager. The UI thread registers views and the module's query thread looks them up. */
256
302
  object QvpRegistry {
257
- private val views = HashMap<Int, QvpRnPageView>()
303
+ private val views = ConcurrentHashMap<Int, QvpRnPageView>()
258
304
  fun register(v: QvpRnPageView) { if (v.id > 0) views[v.id] = v }
259
305
  fun unregister(v: QvpRnPageView) { views.entries.removeAll { it.value === v } }
260
306
  fun get(tag: Int): QvpRnPageView? = views[tag]
@@ -0,0 +1,144 @@
1
+ package ws.quran.qvp.rn
2
+
3
+ import android.graphics.Canvas
4
+ import android.graphics.Paint
5
+ import android.util.Log
6
+ import android.view.View
7
+ import com.facebook.react.uimanager.ThemedReactContext
8
+ import ws.quran.qvp.*
9
+
10
+ /**
11
+ * The React Native host of a passage: a range of complete ayahs, or a surah's basmalah, laid out on
12
+ * rows of this view's width and drawn here. The engine loads, measures and places every word; this
13
+ * class reads the pages the props name, hands the engine a spec in dp, draws the layout and reports
14
+ * it to JS. Nothing is decided here.
15
+ */
16
+ class QvpRnPassageView(private val ctx: ThemedReactContext) : View(ctx) {
17
+ private val density = ctx.resources.displayMetrics.density
18
+ private val paint = Paint(Paint.ANTI_ALIAS_FLAG)
19
+
20
+ // ── desired props (set by the manager) ──
21
+ var pageUris: List<String> = emptyList()
22
+ var surahProp = 0
23
+ var fromProp = 0
24
+ var toProp = 0
25
+ var basmalahProp = false
26
+ /** dp per page unit; [lineHeightProp] wins when it is set. */
27
+ var scaleProp = 1f
28
+ /** dp per printed line: the scale is this over the passage's printed line spacing. */
29
+ var lineHeightProp = 0f
30
+ var lineSpacingProp = 1f
31
+ var paddingProp = 2f
32
+ var alignProp: String? = null
33
+ var maxRowsProp = 0
34
+ var keepAyahMarkProp = false
35
+ var ellipsisWidthProp = 0f
36
+ var maxStretchProp = 0f
37
+ var inkProp: String? = null
38
+ var paperColor = 0
39
+
40
+ // ── applied state ──
41
+ private var loadedKey: String? = null
42
+ private var pages: List<QvpPage> = emptyList()
43
+ private var pagesByNumber: Map<Int, QvpPage> = emptyMap()
44
+ private var passage: QvpPassage? = null
45
+ private var layoutKey: String? = null
46
+ private var layout: QvpPassageLayout? = null
47
+
48
+ fun destroy() {
49
+ passage?.close(); passage = null
50
+ pages.forEach { it.close() }; pages = emptyList(); pagesByNumber = emptyMap()
51
+ loadedKey = null; layoutKey = null; layout = null
52
+ }
53
+
54
+ /** Called by the manager after every prop batch. */
55
+ fun commit() {
56
+ try {
57
+ ensurePassage()
58
+ relayout()
59
+ invalidate()
60
+ } catch (e: Exception) {
61
+ Log.e("QvpRn", "passage commit failed", e)
62
+ emit("onError", mapOf("message" to (e.message ?: e.toString())))
63
+ }
64
+ }
65
+
66
+ override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
67
+ super.onSizeChanged(w, h, oldw, oldh)
68
+ if (w != oldw) commit()
69
+ }
70
+
71
+ private fun ensurePassage() {
72
+ val key = "${pageUris.joinToString("|")}#$surahProp:$fromProp-$toProp:$basmalahProp"
73
+ if (key == loadedKey) return
74
+ destroy()
75
+ loadedKey = key
76
+ if (pageUris.isEmpty() || surahProp <= 0) return
77
+ // The passage copies what it needs, but a draw names a path by its page, so the pages stay
78
+ // open for as long as the passage is drawn. Each page goes into `pages` as it opens, so a
79
+ // URI that fails after it leaves nothing for `destroy` to miss.
80
+ val loaded = ArrayList<QvpPage>(pageUris.size)
81
+ pages = loaded
82
+ for (uri in pageUris) loaded.add(QvpPage(QvpRnBytes.read(ctx, uri)).also { p -> p.buildPaths() })
83
+ pagesByNumber = loaded.associateBy { it.pageNo }
84
+ passage = if (basmalahProp) QvpPassage.basmalah(loaded, surahProp)
85
+ else QvpPassage.load(loaded, surahProp, fromProp, if (toProp > 0) toProp else fromProp)
86
+ }
87
+
88
+ private fun relayout() {
89
+ val p = passage ?: return
90
+ if (width <= 0) return
91
+ val widthDp = width / density
92
+ // dp per page unit: the host's scale, or the dp it wants one printed line to take
93
+ val scale = if (lineHeightProp > 0f && p.lineSpacing > 0f) lineHeightProp / p.lineSpacing else scaleProp
94
+ val align = when (alignProp) {
95
+ "center", "centre" -> QvpPassageAlign.CENTER
96
+ "justified" -> QvpPassageAlign.JUSTIFIED
97
+ else -> QvpPassageAlign.RIGHT
98
+ }
99
+ val maxRows = maxRowsProp.coerceAtLeast(0)
100
+ // The view draws the ellipsis after a cut, so it knows how wide one is: three dots as
101
+ // tall as a row, unless the host reserved a width of its own.
102
+ val ellipsisWidth = if (ellipsisWidthProp > 0f || maxRows == 0) ellipsisWidthProp else {
103
+ paint.textSize = scale * p.lineSpacing
104
+ paint.measureText(ELLIPSIS)
105
+ }
106
+ val spec = QvpPassageSpec(width = widthDp, scale = scale, lineSpacing = lineSpacingProp, padding = paddingProp,
107
+ align = align, maxRows = maxRows, keepAyahMark = keepAyahMarkProp,
108
+ ellipsisWidth = ellipsisWidth, maxStretch = maxStretchProp)
109
+ val key = spec.toString()
110
+ if (key == layoutKey) return
111
+ val l = p.layout(spec)
112
+ layoutKey = key
113
+ layout = l
114
+ if (l == null) {
115
+ emit("onError", mapOf("message" to "the passage spec is out of range: $spec"))
116
+ return
117
+ }
118
+ emit("onPassageLayout", Marshal.passageLayoutMap(l, p))
119
+ }
120
+
121
+ override fun onDraw(canvas: Canvas) {
122
+ val l = layout ?: return
123
+ if (paperColor != 0) { paint.color = paperColor; canvas.drawRect(0f, 0f, width.toFloat(), height.toFloat(), paint) }
124
+ paint.color = Marshal.color(inkProp, QvpDefaults.INK).let { QvpColor.argb(it) }
125
+ canvas.save()
126
+ // the layout is in dp; the canvas is in px
127
+ canvas.scale(density, density)
128
+ l.draw(canvas, pagesByNumber, paint)
129
+ // The engine leaves the ellipsis to the host: three dots in the ink, as tall as the row
130
+ // the cut left room on.
131
+ l.ellipsis?.let { e ->
132
+ paint.textSize = e.height()
133
+ paint.textAlign = Paint.Align.CENTER
134
+ canvas.drawText(ELLIPSIS, e.centerX(), e.bottom, paint)
135
+ }
136
+ canvas.restore()
137
+ }
138
+
139
+ private fun emit(name: String, payload: Map<String, Any?>) = QvpRnEvents.emit(ctx, this, name, payload)
140
+
141
+ private companion object {
142
+ const val ELLIPSIS = "\u2026"
143
+ }
144
+ }
@@ -0,0 +1,26 @@
1
+ package ws.quran.qvp.rn
2
+
3
+ import ws.quran.qvp.Form
4
+ import ws.quran.qvp.QvpPage
5
+
6
+ /**
7
+ * The bridge record of each word of one page, built the first time the word is asked for and
8
+ * kept. A record holds the word's text forms, its label and the names of its paths. The words
9
+ * sidecar is attached once per page, so a record does not change until the next attach, and
10
+ * the view drops this table then. The module's query thread and the UI thread can both call it.
11
+ */
12
+ class QvpRnWords(val page: QvpPage) {
13
+ /** The forms this page has. Each one is a scan of every word in the engine, so read them once. */
14
+ val forms: List<Form> by lazy { Marshal.forms(page) }
15
+ private val records = arrayOfNulls<Map<String, Any?>>(page.nWords)
16
+
17
+ /** The record of word [index], or null when the page has no such word. */
18
+ @Synchronized
19
+ fun word(index: Int): Map<String, Any?>? {
20
+ val w = page.words.getOrNull(index) ?: return null
21
+ return records[index] ?: Marshal.word(page, w, forms).also { records[index] = it }
22
+ }
23
+
24
+ /** Every word's record, in page order. */
25
+ fun all(): List<Map<String, Any?>> = List(page.nWords) { word(it)!! }
26
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quran.ws/qvp-react-native",
3
- "version": "0.6.1",
3
+ "version": "0.8.0",
4
4
  "description": "React Native wrapper for the QVP vector mushaf engine (Android; iOS TODO). Thin marshalling over the Kotlin library, which is JNI over qvp.h.",
5
5
  "main": "src/index.tsx",
6
6
  "types": "src/index.tsx",
@@ -10,6 +10,7 @@
10
10
  "src",
11
11
  "android/build.gradle",
12
12
  "android/src",
13
+ "!android/src/test",
13
14
  "README.md",
14
15
  "package.json"
15
16
  ],
package/src/codes.ts ADDED
@@ -0,0 +1,33 @@
1
+ // Generated by scripts/gen-rn-enums.py from crates/qvp-ffi/include/qvp.h. Do not edit.
2
+
3
+ /** QVP_TARGET_*: the kind of a target, by name. */
4
+ export const TARGET = {
5
+ page: 0,
6
+ word: 1,
7
+ words: 2,
8
+ ayah: 3,
9
+ ayahRange: 4,
10
+ line: 5,
11
+ surah: 6,
12
+ range: 7,
13
+ } as const;
14
+
15
+ /** QVP_SELECTOR_*: the kind of a selector, by name. */
16
+ export const SELECTOR = {
17
+ page: 0,
18
+ path: 1,
19
+ wordPath: 2,
20
+ wordMark: 3,
21
+ wordMarkNamed: 4,
22
+ wordBody: 5,
23
+ wordMarks: 6,
24
+ word: 7,
25
+ ayah: 8,
26
+ line: 9,
27
+ mark: 10,
28
+ category: 11,
29
+ family: 12,
30
+ kind: 13,
31
+ decoration: 14,
32
+ decorationIndex: 15,
33
+ } as const;