@quran.ws/qvp-react-native 0.7.0 → 0.9.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.
Files changed (32) hide show
  1. package/README.md +86 -32
  2. package/android/build.gradle +16 -8
  3. package/android/src/main/java/ws/quran/qvp/rn/Codes.kt +34 -0
  4. package/android/src/main/java/ws/quran/qvp/rn/Marshal.kt +78 -30
  5. package/android/src/main/java/ws/quran/qvp/rn/QvpModule.kt +105 -50
  6. package/android/src/main/java/ws/quran/qvp/rn/QvpPageViewManager.kt +1 -0
  7. package/android/src/main/java/ws/quran/qvp/rn/QvpRnPageView.kt +55 -14
  8. package/android/src/main/java/ws/quran/qvp/rn/QvpRnWords.kt +26 -0
  9. package/ios/QvpModule.m +167 -0
  10. package/ios/QvpModule.swift +508 -0
  11. package/ios/QvpRnBytes.swift +66 -0
  12. package/ios/QvpRnCodes.swift +33 -0
  13. package/ios/QvpRnMarshal.swift +360 -0
  14. package/ios/QvpRnPageView.swift +467 -0
  15. package/ios/QvpRnPassageView.swift +160 -0
  16. package/ios/vendor/QvpEngine.json +4 -0
  17. package/ios/vendor/QvpKit/QvpDress.swift +390 -0
  18. package/ios/vendor/QvpKit/QvpEngine.swift +55 -0
  19. package/ios/vendor/QvpKit/QvpPage.swift +469 -0
  20. package/ios/vendor/QvpKit/QvpPageCache.swift +176 -0
  21. package/ios/vendor/QvpKit/QvpPageCanvas.swift +1031 -0
  22. package/ios/vendor/QvpKit/QvpPageView.swift +711 -0
  23. package/ios/vendor/QvpKit/QvpPassage.swift +240 -0
  24. package/ios/vendor/QvpKit/QvpViewPolicy.swift +26 -0
  25. package/ios/vendor/QvpKit/QvpZoom.swift +200 -0
  26. package/ios/vendor/QvpKit/QvpZoomSpring.swift +22 -0
  27. package/ios/vendor/QvpKit/Types.swift +440 -0
  28. package/ios/vendor-qvpkit.sh +36 -0
  29. package/package.json +10 -3
  30. package/qvp-react-native.podspec +97 -0
  31. package/src/codes.ts +33 -0
  32. package/src/index.tsx +171 -55
@@ -0,0 +1,440 @@
1
+ // Constants, selectors, targets and record types mirroring qvp.h / the Kotlin wrapper
2
+ // (packages/android/qvp/.../Types.kt). Colours everywhere are 0xRRGGBBAA (see QvpColor).
3
+ import Foundation
4
+ import CoreGraphics
5
+ import QvpFFI
6
+
7
+ /// Absent index in the C ABI.
8
+ public let QVP_NONE: UInt32 = 0xFFFF_FFFF
9
+
10
+ /// The path kinds (QVP_KIND_*): what a path draws.
11
+ public enum QvpKind {
12
+ /// The ids by name, as qvp.h numbers them.
13
+ public static let BODY = 0, MARK = 1, AYAH_NUMBER = 2, AYAH_MARK_ORNAMENT = 3, HEADER_INK = 4, ORNAMENT = 5, PAGE_NUMBER = 6, RUNNING_HEAD = 7, OTHER = 255
14
+ }
15
+ /// The mark families (QVP_FAMILY_*) that a theme colours as one.
16
+ public enum QvpFamily {
17
+ /// The ids by name, as qvp.h numbers them.
18
+ public static let NONE = 0, DIACRITIC = 1, TANWIN = 2, DOTS = 3, WAQF = 4, SIFR = 5, SAJDAH = 6, READING_SIGN = 7
19
+ }
20
+ /// The mark categories (QVP_CATEGORY_*). `QvpEngine.markCategory` gives a mark's.
21
+ public enum QvpCategory {
22
+ /// The ids by name, as qvp.h numbers them.
23
+ public static let NONE = 0, HARAKAH = 1, TANWIN = 2, LETTER_DOT = 3, ORTHOGRAPHIC = 4, DABT = 5, WAQF = 6, READING_SIGN = 7, STANDALONE = 8
24
+ }
25
+ /// The decoration kinds (QVP_DECORATION_*): the page's ornaments and furniture.
26
+ public enum QvpDecorationKind {
27
+ /// The ids by name, as qvp.h numbers them.
28
+ public static let AYAH_MARK = 0, SURAH_NAME = 1, BASMALAH = 2, DIVISION_MARK = 3, SAJDAH_MARK = 4, PAGE_NUMBER = 5, RUNNING_HEAD = 6, OTHER = 255
29
+ }
30
+ /// The style layers (QVP_LAYER_*). A rule on a higher layer wins over one below it.
31
+ public enum QvpLayer {
32
+ /// The ids by name, as qvp.h numbers them.
33
+ public static let BASE = 0, THEME = 10, HIGHLIGHT = 50, SELECTION = 60, TOP = 100
34
+ }
35
+
36
+ public enum Form: Int { case rasmUthmani = 0, rasmImlai, qpc, rasm, search }
37
+ public enum SearchMode: Int { case includes = 0, exact, prefix }
38
+ public enum HighlightMode: Int { case ink = 0, band, both }
39
+ public enum BandHeight: Int { case lineSpacing = 0, ink }
40
+ public enum MaskMode: Int { case hide = 0, block, blur }
41
+ public enum Division: Int, CaseIterable { case juz = 0, hizb, nisf, rubuAlHizb }
42
+
43
+ /// The defaults every wrapper shares (QVP_DEFAULT_* in qvp.h; the parity check compares them). Colours 0xRRGGBBAA.
44
+ public enum QvpDefaults {
45
+ /// The ink of a page before any style rule, and the highlight ink and band.
46
+ public static let INK: UInt32 = 0x231f20ff, HIGHLIGHT_INK: UInt32 = 0x1a73e8ff, HIGHLIGHT_BAND: UInt32 = 0xd6a3264d
47
+ /// The padding of a highlight band and the overlap of its seams, in page units.
48
+ public static let HIGHLIGHT_PAD_X: Float = 1.2, HIGHLIGHT_PAD_Y: Float = 0, HIGHLIGHT_SEAM: Float = 0.25
49
+ /// The selection band and its side padding, the share of the gap between two words that
50
+ /// belongs to the preceding word, and how far a tap may land from the ink, in page units.
51
+ public static let SELECTION_BAND: UInt32 = 0x2d6fd640, SELECTION_PAD_X: Float = 0.6, GAP_BIAS: Float = 0.6, TAP_DISTANCE: Float = 6
52
+ /// The line grid this mushaf is designed on, and the content-width bound the examples pass as
53
+ /// `maxAspectSlack`.
54
+ public static let GRID_LINES = 15, ASPECT_SLACK: Float = 1.15
55
+ /// The block colour of a mask, and its padding and corner radius in page units.
56
+ public static let MASK_BLOCK: UInt32 = 0xd9d4c8ff, MASK_PAD: Float = 0.6, MASK_RADIUS: Float = 0.8
57
+ /// How many steps a reveal lights at once and the grey of the rest, and the padding around a
58
+ /// crop in page units.
59
+ public static let REVEAL_LIT = 1, REVEAL_GREY: UInt32 = 0xc9c4b8ff, CROP_PAD: Float = 2
60
+ /// The size of a dressed scanned medallion against the printed ring when `ayahMarkScale` is 0.
61
+ public static let AYAH_MARK_SCALE_SCAN: Float = 1.5
62
+ /// How far a short reflowed row opens towards its neighbours, as a share of the difference, and
63
+ /// how far a reflowed row's gaps may open, in word gaps.
64
+ public static let REFLOW_RELAX: Float = 0.5, REFLOW_MAX_STRETCH: Float = 2
65
+ /// The pinch limits, as multiples of the layout's own scale, and the point at which a page counts
66
+ /// as zoomed in.
67
+ public static let MIN_ZOOM: Float = 0.5, MAX_ZOOM: Float = 12, ZOOMED_THRESHOLD: Float = 1.02
68
+ /// How far past the midpoint between two zoom steps a pinch must reach to commit to the next one,
69
+ /// and the smallest change in reflow zoom that a free pinch asks for.
70
+ public static let ZOOM_SNAP_HYSTERESIS: Float = 0.03, ZOOM_QUANTUM: Float = 0.01
71
+ /// A released drag is a page swipe when it is this much more sideways than up and down, and
72
+ /// either this far (viewport px) or this fast (px per second).
73
+ public static let SWIPE_AXIS_RATIO: Float = 1.5, SWIPE_DISTANCE: Float = 40, SWIPE_VELOCITY: Float = 500
74
+ /// The tallest band of ink a view draws at once, in viewport px: what `QvpPage.layoutInkBand`
75
+ /// holds a band to by default.
76
+ public static let MAX_INK_HEIGHT: Float = 4096
77
+
78
+ /// Every default by its camelCase name, as the decimals the header states, for a host that
79
+ /// reads the table whole (the React Native module's constants). A Float goes through its
80
+ /// shortest decimal string, so 0.6 stays 0.6 as a Double; a colour is unsigned 0xRRGGBBAA.
81
+ /// Member references only: the numbers live above, where the parity check reads them.
82
+ public static let decimal: [String: Double] = {
83
+ let all: [String: Any] = [
84
+ "ink": INK, "highlightInk": HIGHLIGHT_INK, "highlightBand": HIGHLIGHT_BAND,
85
+ "highlightPadX": HIGHLIGHT_PAD_X, "highlightPadY": HIGHLIGHT_PAD_Y, "highlightSeam": HIGHLIGHT_SEAM,
86
+ "selectionBand": SELECTION_BAND, "selectionPadX": SELECTION_PAD_X, "gapBias": GAP_BIAS, "tapDistance": TAP_DISTANCE,
87
+ "gridLines": GRID_LINES, "aspectSlack": ASPECT_SLACK,
88
+ "maskBlock": MASK_BLOCK, "maskPad": MASK_PAD, "maskRadius": MASK_RADIUS,
89
+ "revealLit": REVEAL_LIT, "revealGrey": REVEAL_GREY, "cropPad": CROP_PAD,
90
+ "ayahMarkScaleScan": AYAH_MARK_SCALE_SCAN,
91
+ "minZoom": MIN_ZOOM, "maxZoom": MAX_ZOOM, "zoomedThreshold": ZOOMED_THRESHOLD,
92
+ "swipeAxisRatio": SWIPE_AXIS_RATIO, "swipeDistance": SWIPE_DISTANCE, "swipeVelocity": SWIPE_VELOCITY,
93
+ "zoomSnapHysteresis": ZOOM_SNAP_HYSTERESIS, "zoomQuantum": ZOOM_QUANTUM,
94
+ "reflowRelax": REFLOW_RELAX, "reflowMaxStretch": REFLOW_MAX_STRETCH, "maxInkHeight": MAX_INK_HEIGHT,
95
+ ]
96
+ return all.mapValues { v in
97
+ switch v {
98
+ case let f as Float: return Double("\(f)") ?? Double(f)
99
+ case let u as UInt32: return Double(u)
100
+ case let i as Int: return Double(i)
101
+ default: return 0
102
+ }
103
+ }
104
+ }()
105
+ }
106
+
107
+ /// How a reflowed row fills the width, how the words are broken onto rows, and where the air
108
+ /// between two words comes from.
109
+ public enum QvpFill: Int { case ragged = 0, justified, centred }
110
+ public enum QvpBreaks: Int { case greedy = 0, even, fitted, printed }
111
+ public enum QvpGapMode: Int { case printed = 0, uniform }
112
+
113
+ /// Ask for a reflowed page: the same page width with bigger ink, so fewer words fit a row and
114
+ /// the rest move down. `zoom` is the ink size as a multiple of fit-to-width; 1 is the printed
115
+ /// page. Every other field has a default the engine picked and a reader never needs to change.
116
+ public struct QvpReflowSpec: Equatable {
117
+ public var zoom: Float, fill: QvpFill, breaks: QvpBreaks, gaps: QvpGapMode
118
+ public var wordGap: Float, relax: Float, maxStretch: Float
119
+ public init(zoom: Float, fill: QvpFill = .centred, breaks: QvpBreaks = .fitted, gaps: QvpGapMode = .uniform,
120
+ wordGap: Float = 1, relax: Float = QvpDefaults.REFLOW_RELAX, maxStretch: Float = QvpDefaults.REFLOW_MAX_STRETCH) {
121
+ self.zoom = zoom; self.fill = fill; self.breaks = breaks; self.gaps = gaps
122
+ self.wordGap = wordGap; self.relax = relax; self.maxStretch = maxStretch
123
+ }
124
+ }
125
+
126
+ /// A mark id by its name, from the engine (255 = unknown).
127
+ public func markId(_ name: String) -> Int { QvpEngine.markFromName(name) }
128
+
129
+ /// 0xRRGGBBAA helpers.
130
+ public enum QvpColor {
131
+ /// 0...1 → 0...255, rounded to the nearest step, as in every wrapper. NaN and out-of-range
132
+ /// values clamp first, so a bad alpha is 0 or 255, never a trap.
133
+ public static func alpha8(_ alpha: Float) -> UInt32 { UInt32(((alpha.isNaN ? 0 : min(max(alpha, 0), 1)) * 255).rounded()) }
134
+ /// "#rgb", "#rrggbb" or "#rrggbbaa" → 0xRRGGBBAA (alpha applies to 3/6-digit forms).
135
+ public static func parse(_ hex: String, alpha: Float = 1) -> UInt32 {
136
+ var h = hex.trimmingCharacters(in: .whitespaces)
137
+ if h.hasPrefix("#") { h.removeFirst() }
138
+ if h.count == 3 || h.count == 4 { h = h.map { "\($0)\($0)" }.joined() }
139
+ if h.count == 6 { h += String(format: "%02x", alpha8(alpha)) }
140
+ return UInt32(h, radix: 16) ?? 0
141
+ }
142
+ /// Replace the alpha of a 0xRRGGBBAA colour with `alpha`, 0 to 1.
143
+ public static func withAlpha(_ rgba: UInt32, _ alpha: Float) -> UInt32 {
144
+ (rgba & 0xFFFF_FF00) | alpha8(alpha)
145
+ }
146
+ /// Split a 0xRRGGBBAA colour into its channels, each 0 to 1.
147
+ public static func components(_ rgba: UInt32) -> (r: CGFloat, g: CGFloat, b: CGFloat, a: CGFloat) {
148
+ (CGFloat((rgba >> 24) & 255) / 255, CGFloat((rgba >> 16) & 255) / 255, CGFloat((rgba >> 8) & 255) / 255, CGFloat(rgba & 255) / 255)
149
+ }
150
+ /// Make an sRGB `CGColor` from a 0xRRGGBBAA colour.
151
+ public static func cgColor(_ rgba: UInt32) -> CGColor {
152
+ let c = components(rgba)
153
+ return CGColor(srgbRed: c.r, green: c.g, blue: c.b, alpha: c.a)
154
+ }
155
+ /// CGColor (sRGB / RGB / grey) → 0xRRGGBBAA.
156
+ public static func rgba(_ color: CGColor) -> UInt32 {
157
+ let c = color.converted(to: CGColorSpace(name: CGColorSpace.sRGB)!, intent: .defaultIntent, options: nil) ?? color
158
+ let k = c.components ?? [0, 0, 0, 1]
159
+ let (r, g, b, a) = k.count >= 4 ? (k[0], k[1], k[2], k[3]) : (k[0], k[0], k[0], k.count > 1 ? k[1] : 1)
160
+ func u(_ v: CGFloat) -> UInt32 { UInt32(truncatingIfNeeded: Int((v * 255).rounded()).clamped(0, 255)) }
161
+ return (u(r) << 24) | (u(g) << 16) | (u(b) << 8) | u(a)
162
+ }
163
+ }
164
+
165
+ extension Int { func clamped(_ lo: Int, _ hi: Int) -> Int { Swift.min(Swift.max(self, lo), hi) } }
166
+
167
+ /// What a style rule applies to (mirrors Sel in web/qvp.js and Selector in Kotlin).
168
+ public struct Selector {
169
+ let c: QvpSelector
170
+ init(_ kind: Int, _ a: Int = 0, _ b: Int = 0, _ cc: Int = 0) { c = QvpSelector(selector: UInt8(truncatingIfNeeded: kind), a: UInt32(truncatingIfNeeded: a), b: UInt32(truncatingIfNeeded: b), c: UInt32(truncatingIfNeeded: cc)) }
171
+ /// Every path of the page.
172
+ public static func page() -> Selector { Selector(0) }
173
+ /// One path, by its index on the page.
174
+ public static func path(_ i: Int) -> Selector { Selector(1, i) }
175
+ /// The nth path of a word, counting from 0.
176
+ public static func wordPath(_ w: Int, _ nth: Int) -> Selector { Selector(2, w, nth) }
177
+ /// nth mark of the word (0-based, marks only)
178
+ public static func wordMark(_ w: Int, _ nth: Int) -> Selector { Selector(3, w, nth) }
179
+ /// The nth mark of a word that has this name, counting from 0.
180
+ public static func wordMarkNamed(_ w: Int, _ mark: String, _ nth: Int = 0) -> Selector { Selector(4, w, markId(mark), nth) }
181
+ /// The letters of a word, without its marks.
182
+ public static func wordBody(_ w: Int) -> Selector { Selector(5, w) }
183
+ /// Every mark of a word.
184
+ public static func wordMarks(_ w: Int) -> Selector { Selector(6, w) }
185
+ /// Every path of a word.
186
+ public static func word(_ w: Int) -> Selector { Selector(7, w) }
187
+ /// Every path of the words of an ayah, by surah and ayah number.
188
+ public static func ayah(_ s: Int, _ a: Int) -> Selector { Selector(8, s, a) }
189
+ /// Every path on a printed line, by its number from 1.
190
+ public static func line(_ n: Int) -> Selector { Selector(9, n) }
191
+ /// Every mark of one kind, by its name.
192
+ public static func mark(_ name: String) -> Selector { Selector(10, markId(name)) }
193
+ /// Every mark of one kind, by its id.
194
+ public static func mark(_ id: Int) -> Selector { Selector(10, id) }
195
+ /// Every mark of a category (`QvpCategory`).
196
+ public static func category(_ c: Int) -> Selector { Selector(11, c) }
197
+ /// Every mark of a family (`QvpFamily`).
198
+ public static func family(_ f: Int) -> Selector { Selector(12, f) }
199
+ /// Every path of a kind (`QvpKind`).
200
+ public static func kind(_ k: Int) -> Selector { Selector(13, k) }
201
+ /// Every path of the decorations of a kind (`QvpDecorationKind`).
202
+ public static func decoration(_ k: Int) -> Selector { Selector(14, k) }
203
+ /// Every path of one decoration, by its index on the page.
204
+ public static func decorationIndex(_ i: Int) -> Selector { Selector(15, i) }
205
+ }
206
+
207
+ /// What resolves to a word list (mirrors T in web/qvp.js and Target in Kotlin).
208
+ /// Strings: "page", "2:255", "2:255:3", "2:255-257", "line:7", "surah:2".
209
+ public struct Target {
210
+ let kind: Int; let a: Int; let b: Int; let c: Int; let words: [UInt32]
211
+ init(_ kind: Int, _ a: Int = 0, _ b: Int = 0, _ c: Int = 0, _ words: [UInt32] = []) { self.kind = kind; self.a = a; self.b = b; self.c = c; self.words = words }
212
+ /// Every word of the page.
213
+ public static func page() -> Target { Target(0) }
214
+ /// One word, by its index on the page.
215
+ public static func word(_ i: Int) -> Target { Target(1, i) }
216
+ /// A list of words, by their indices on the page.
217
+ public static func words(_ ws: [Int]) -> Target { Target(2, 0, 0, 0, ws.map { UInt32(truncatingIfNeeded: $0) }) }
218
+ /// The words of an ayah on this page, by surah and ayah number.
219
+ public static func ayah(_ s: Int, _ a: Int) -> Target { Target(3, s, a) }
220
+ /// The words of the ayahs `a` to `b` of a surah on this page.
221
+ public static func ayahRange(_ s: Int, _ a: Int, _ b: Int) -> Target { Target(4, s, a, b) }
222
+ /// The words of a printed line, by its number from 1.
223
+ public static func line(_ n: Int) -> Target { Target(5, n) }
224
+ /// The words of a surah on this page.
225
+ public static func surah(_ s: Int) -> Target { Target(6, s) }
226
+ /// The words from index `a` to index `b`, both included, in either order.
227
+ public static func range(_ a: Int, _ b: Int) -> Target { Target(7, a, b) }
228
+ /// Parse a string key; "s:a:w" word keys need the page to resolve (see QvpPage.target).
229
+ /// The numbers are ASCII digits that fit an Int32, as Kotlin's `Target.parse` reads them.
230
+ /// A key in none of these forms, or with a number out of that range, is a fatal error;
231
+ /// `Target(parsing:page:)` returns nil for one.
232
+ public static func parse(_ s: String, page: QvpPage? = nil) -> Target {
233
+ guard let t = Target(parsing: s, page: page) else { preconditionFailure("bad target \(s)") }
234
+ return t
235
+ }
236
+ /// Parse a string key as `parse` does, or nil when the key is in none of its forms or a
237
+ /// number in it is not ASCII digits that fit an Int32.
238
+ public init?(parsing s: String, page: QvpPage? = nil) {
239
+ guard let t = Target.parsed(s, page: page) else { return nil }
240
+ self = t
241
+ }
242
+ private static func parsed(_ s: String, page: QvpPage?) -> Target? {
243
+ if s == "page" { return Target.page() }
244
+ // The groups of `pattern`, each read as an Int32; nil when the key does not match or a
245
+ // group does not fit. `[0-9]`, not `\d`: `\d` also matches Arabic-Indic digits.
246
+ func nums(_ pattern: String, _ n: Int) -> [Int]? {
247
+ guard let re = try? NSRegularExpression(pattern: pattern), let m = re.firstMatch(in: s, range: NSRange(s.startIndex..., in: s)),
248
+ m.numberOfRanges == n + 1 else { return nil }
249
+ var out: [Int] = []
250
+ for k in 1...n {
251
+ guard let r = Range(m.range(at: k), in: s), let v = Int32(s[r]) else { return nil }
252
+ out.append(Int(v))
253
+ }
254
+ return out
255
+ }
256
+ if let g = nums("^line:([0-9]+)$", 1) { return line(g[0]) }
257
+ if let g = nums("^surah:([0-9]+)$", 1) { return surah(g[0]) }
258
+ if let g = nums("^([0-9]+):([0-9]+)-([0-9]+)$", 3) { return ayahRange(g[0], g[1], g[2]) }
259
+ if let g = nums("^([0-9]+):([0-9]+):([0-9]+)$", 3) { let i = page?.findWord(g[0], g[1], g[2]) ?? -1; return i >= 0 ? word(i) : words([]) }
260
+ if let g = nums("^([0-9]+):([0-9]+)$", 2) { return ayah(g[0], g[1]) }
261
+ return nil
262
+ }
263
+ /// Run `body` with a C QvpTarget whose `words` pointer is valid for the call.
264
+ func withC<R>(_ body: (UnsafePointer<QvpTarget>) -> R) -> R {
265
+ words.withUnsafeBufferPointer { wp in
266
+ var t = QvpTarget(target: UInt8(truncatingIfNeeded: kind), a: UInt32(truncatingIfNeeded: a), b: UInt32(truncatingIfNeeded: b), c: UInt32(truncatingIfNeeded: c), words: wp.baseAddress, n_words: UInt32(truncatingIfNeeded: wp.count))
267
+ return withUnsafePointer(to: &t, body)
268
+ }
269
+ }
270
+ }
271
+
272
+ public struct QvpWord: Equatable {
273
+ public let index: Int, surah: Int, ayah: Int, word: Int, line: Int, ayahIndex: Int, lineIndex: Int
274
+ public let x0: Float, y0: Float, x1: Float, y1: Float
275
+ public let text: String, firstPath: Int, nPaths: Int
276
+ public var wordKey: String { "\(surah):\(ayah):\(word)" }
277
+ public var ayahKey: String { "\(surah):\(ayah)" }
278
+ }
279
+ public struct QvpAyah: Equatable {
280
+ public let index: Int, surah: Int, ayah: Int, fragment: Int, fragments: Int, flags: Int, rubuAlHizb: Int, firstWord: Int, nWords: Int, ayahMarkDecoration: Int
281
+ public let x0: Float, y0: Float, x1: Float, y1: Float
282
+ }
283
+ public struct QvpLine: Equatable {
284
+ public let index: Int, lineNumber: Int, isHeader: Bool, firstWord: Int, nWords: Int
285
+ public let x0: Float, y0: Float, x1: Float, y1: Float, bandY0: Float, bandY1: Float, centre: Float
286
+ }
287
+ public struct QvpDecoration: Equatable {
288
+ public let index: Int, decoration: Int, surah: Int, ayah: Int, line: Int
289
+ public let x0: Float, y0: Float, x1: Float, y1: Float
290
+ public let text: String, firstPath: Int, nPaths: Int
291
+ }
292
+ /// The one hit shape for every hit test; the exact variants report distance 0. `isExact` is true only when the point is inside an outline. Indices are -1 when absent.
293
+ public struct QvpHit: Equatable { public let word: Int, path: Int, decoration: Int, line: Int, distance: Float, isExact: Bool }
294
+ public struct QvpHitOptions: Equatable {
295
+ public var maxDistance: Float, gapBias: Float, preferExact: Bool
296
+ public init(maxDistance: Float = 0, gapBias: Float = QvpDefaults.GAP_BIAS, preferExact: Bool = true) { self.maxDistance = maxDistance; self.gapBias = gapBias; self.preferExact = preferExact }
297
+ }
298
+ public struct QvpBox: Equatable { public let id: Int, line: Int, x0: Float, y0: Float, x1: Float, y1: Float, color: UInt32, radius: Float }
299
+ public struct QvpHitArea: Equatable { public let word: Int, line: Int, x0: Float, y0: Float, x1: Float, y1: Float, inkX0: Float, inkY0: Float, inkX1: Float, inkY1: Float }
300
+ public struct QvpLineBand: Equatable { public let line: Int, lineNumber: Int, y0: Float, y1: Float, mid: Float, inkY0: Float, inkY1: Float }
301
+ /// Spacing only opens up: `lineSpacing` < 1 is clamped by the engine. `gridLines` 0 = the page's own grid.
302
+ public struct QvpLayoutSpec: Equatable {
303
+ public var viewportW: Float, viewportH: Float, padTop: Float, padBottom: Float, padLeft: Float, padRight: Float, lineSpacing: Float, fillHeight: Bool, gridLines: Int
304
+ /// Printed side margins to cut, in page units (0 = keep the print's margins).
305
+ public var cropLeft: Float, cropRight: Float
306
+ /// The content is never wider than `viewportH · pageW / pageH · maxAspectSlack` (0 = no bound).
307
+ public var maxAspectSlack: Float
308
+ /// Break the words onto rows of the page's own width. `nil`, or a zoom of 1 or less, lays
309
+ /// the page out as printed; the other knobs are then what the zoom control reflows it with.
310
+ public var reflow: QvpReflowSpec?
311
+ /// How big a banner — a surah name, a basmalah — may get as the reader zooms in, as a
312
+ /// multiple of its PRINTED size. 0 leaves it uncapped: the drawing grows with the words
313
+ /// around it until it fills the row, which for a surah name is about five times the print.
314
+ /// 1 holds it at the printed size however far the reader zooms — what a host drawing its
315
+ /// own frame around the name wants, since the frame has a shape to keep. Only a reflowed
316
+ /// page grows a banner at all.
317
+ public var bannerZoom: Float
318
+ /// Draw source-native frames around surah names on the printed page. Reflow stays frameless.
319
+ public var surahFrames: Bool
320
+ public init(viewportW: Float, viewportH: Float, padTop: Float = 0, padBottom: Float = 0, padLeft: Float = 0, padRight: Float = 0, lineSpacing: Float = 1, fillHeight: Bool = false, gridLines: Int = 0,
321
+ cropLeft: Float = 0, cropRight: Float = 0, maxAspectSlack: Float = 0, reflow: QvpReflowSpec? = nil, bannerZoom: Float = 0, surahFrames: Bool = true) {
322
+ self.viewportW = viewportW; self.viewportH = viewportH; self.padTop = padTop; self.padBottom = padBottom; self.padLeft = padLeft; self.padRight = padRight
323
+ self.lineSpacing = lineSpacing; self.fillHeight = fillHeight; self.gridLines = gridLines
324
+ self.cropLeft = cropLeft; self.cropRight = cropRight; self.maxAspectSlack = maxAspectSlack; self.reflow = reflow
325
+ self.bannerZoom = bannerZoom; self.surahFrames = surahFrames
326
+ }
327
+ var c: QvpFFI.QvpLayoutSpec {
328
+ // a zoom of 0 is the printed page, and 255 asks the engine for its own default
329
+ let r = reflow
330
+ return QvpFFI.QvpLayoutSpec(viewport_w: viewportW, viewport_h: viewportH, pad_top: padTop, pad_bottom: padBottom, pad_left: padLeft, pad_right: padRight, line_spacing: lineSpacing,
331
+ fill_height: fillHeight ? 1 : 0, grid_lines: UInt32(truncatingIfNeeded: gridLines), crop_left: cropLeft, crop_right: cropRight, max_aspect_slack: maxAspectSlack,
332
+ reflow_zoom: r?.zoom ?? 0,
333
+ reflow_fill: r.map { UInt8(truncatingIfNeeded: $0.fill.rawValue) } ?? 255,
334
+ reflow_breaks: r.map { UInt8(truncatingIfNeeded: $0.breaks.rawValue) } ?? 255,
335
+ reflow_gaps: r.map { UInt8(truncatingIfNeeded: $0.gaps.rawValue) } ?? 1,
336
+ reflow_word_gap: r?.wordGap ?? 1,
337
+ reflow_max_stretch: r?.maxStretch ?? 0,
338
+ reflow_relax: r?.relax ?? -1,
339
+ banner_zoom: bannerZoom,
340
+ surah_frames: surahFrames ? 1 : 0)
341
+ }
342
+ }
343
+ /// The grid a page is laid out inside: the mushaf's line count and the printed line spacing (page units).
344
+ public struct QvpGrid: Equatable { public let lines: Int, lineSpacing: Float }
345
+ /// Page → viewport. On a printed page, viewX = offsetX + x*scale ; viewY = offsetY + (y + lineDy[line])*scale. A reflowed
346
+ /// page (`reflowed`) moves words, not lines, so `lineDy` places no path there: draw through `QvpPage.layoutDrawList` and
347
+ /// `QvpPage.layoutPlacements`, and ask `QvpPage.wordBoundsView` where a word is. Draw at fitX + fitScale*viewX,
348
+ /// fitY + fitScale*viewY, and put the host's pan and zoom on top. The fit shows a box: the content, plus the dress
349
+ /// overflow on each side when the page is dressed (`QvpDressInfo.overflow`). On a printed page `fitScale` shrinks the
350
+ /// box to fit both the viewport width and height (never above 1), and the box is centred. On a reflowed page
351
+ /// `fitScale` is 1 and the host scrolls: the box is centred across the viewport, and its top is at the top of the
352
+ /// viewport. `fitX` and `fitY` place the content's own origin, so the overflow sits to their left and above them.
353
+ public final class QvpLayout {
354
+ /// The page-to-viewport scale and offset, the content size in viewport points, and the line
355
+ /// spacing in page units.
356
+ public let scale: Float, offsetX: Float, offsetY: Float, contentW: Float, contentH: Float, lineSpacing: Float
357
+ /// Per printed line, or per row when the page is reflowed: the shift down in page units, and the
358
+ /// top and bottom of its slot.
359
+ public let lineDy: [Float], slotTop: [Float], slotBottom: [Float]
360
+ /// The view transform for the content plus any dress overflow: shrunk to fit and centred on
361
+ /// a printed page, scale 1 and scrolled on a reflowed one. `fitX` and `fitY` place the
362
+ /// content's own origin (see the type's doc).
363
+ public let fitScale: Float, fitX: Float, fitY: Float
364
+ /// True when this layout broke the words onto rows of its own, and how many rows it made.
365
+ /// A reflowed page places paths by group (`QvpPage.layoutGroups`), not by printed line.
366
+ public let reflowed: Bool, rows: Int
367
+ init(scale: Float, offsetX: Float, offsetY: Float, contentW: Float, contentH: Float, lineSpacing: Float, lineDy: [Float], slotTop: [Float], slotBottom: [Float], fitScale: Float = 1, fitX: Float = 0, fitY: Float = 0, reflowed: Bool = false, rows: Int = 0) {
368
+ self.scale = scale; self.offsetX = offsetX; self.offsetY = offsetY; self.contentW = contentW; self.contentH = contentH; self.lineSpacing = lineSpacing; self.lineDy = lineDy; self.slotTop = slotTop; self.slotBottom = slotBottom
369
+ self.fitScale = fitScale; self.fitX = fitX; self.fitY = fitY
370
+ self.reflowed = reflowed; self.rows = rows
371
+ }
372
+ }
373
+
374
+ /// Where one group of paths is placed on a reflowed page: a point `p` in page units is drawn at
375
+ /// `(kx·p.x + dx, ky·p.y + dy)`, still in page units, before the layout's own scale and offset.
376
+ /// A word is always placed with `kx == ky == 1`: it moves, it is never resized or reshaped.
377
+ public struct QvpPlacement: Equatable {
378
+ public let dx: Float, dy: Float, kx: Float, ky: Float
379
+ public static let identity = QvpPlacement(dx: 0, dy: 0, kx: 1, ky: 1)
380
+ }
381
+
382
+ /// One drawing of one path: the path, and which of `QvpPage.layoutPlacements()` it goes under.
383
+ public struct QvpDraw: Equatable { public let path: Int, placement: Int }
384
+
385
+ /// One more drawing of a decoration's paths, at another placement: the sajdah line uses it when
386
+ /// the words it marks end up on two rows.
387
+ public struct QvpRepeat: Equatable { public let firstPath: Int, nPaths: Int, placement: QvpPlacement }
388
+ public struct QvpHighlightStyle: Equatable {
389
+ public var mode: HighlightMode, ink: UInt32, band: UInt32, height: BandHeight, padX: Float, padY: Float, radius: Float, seam: Float, transitionMs: Int, layer: Int
390
+ public init(mode: HighlightMode = .band, ink: UInt32 = QvpDefaults.HIGHLIGHT_INK, band: UInt32 = QvpDefaults.HIGHLIGHT_BAND, height: BandHeight = .lineSpacing, padX: Float = QvpDefaults.HIGHLIGHT_PAD_X, padY: Float = QvpDefaults.HIGHLIGHT_PAD_Y, radius: Float = 0, seam: Float = QvpDefaults.HIGHLIGHT_SEAM, transitionMs: Int = 0, layer: Int = QvpLayer.HIGHLIGHT) {
391
+ self.mode = mode; self.ink = ink; self.band = band; self.height = height; self.padX = padX; self.padY = padY; self.radius = radius; self.seam = seam; self.transitionMs = transitionMs; self.layer = layer
392
+ }
393
+ var c: QvpFFI.QvpHighlightStyle {
394
+ QvpFFI.QvpHighlightStyle(mode: UInt8(truncatingIfNeeded: mode.rawValue), height: UInt8(truncatingIfNeeded: height.rawValue), ink: ink, band: band, pad_x: padX, pad_y: padY, radius: radius, seam: seam, transition_ms: UInt32(truncatingIfNeeded: transitionMs), layer: Int32(truncatingIfNeeded: layer))
395
+ }
396
+ }
397
+ /// Colours that are nil (or alpha 0) leave that colour alone.
398
+ public struct QvpTheme: Equatable {
399
+ public var ink: UInt32?, diacritics: UInt32?, dots: UInt32?, waqf: UInt32?, sifr: UInt32?, ayahMark: UInt32?, numeral: UInt32?, headers: UInt32?
400
+ public var marks: [String: UInt32], transitionMs: Int
401
+ public init(ink: UInt32? = nil, diacritics: UInt32? = nil, dots: UInt32? = nil, waqf: UInt32? = nil, sifr: UInt32? = nil, ayahMark: UInt32? = nil, numeral: UInt32? = nil, headers: UInt32? = nil, marks: [String: UInt32] = [:], transitionMs: Int = 0) {
402
+ self.ink = ink; self.diacritics = diacritics; self.dots = dots; self.waqf = waqf; self.sifr = sifr; self.ayahMark = ayahMark; self.numeral = numeral; self.headers = headers; self.marks = marks; self.transitionMs = transitionMs
403
+ }
404
+ }
405
+ public struct QvpSurah: Equatable { public let number: Int, ayahCount: Int, hasBanner: Bool, hasBasmalah: Bool, place: String, bannerDecoration: Int, arabic: String, latin: String, english: String }
406
+ public struct QvpDivision: Equatable { public let division: Division, number: Int, surah: Int, ayah: Int, line: Int, ayahIndex: Int }
407
+ public struct QvpAyahMark: Equatable { public let decoration: Int, surah: Int, ayah: Int, line: Int, cx: Float, cy: Float, r: Float, ornamentPath: Int, numeralPath: Int }
408
+ /// `x0 … y1` is the box a surah frame fills, `titleX0 … titleY1` the title ink in it.
409
+ public struct QvpSurahHeader: Equatable { public let decoration: Int, surah: Int, line: Int, x0: Float, y0: Float, x1: Float, y1: Float, titleX0: Float, titleY0: Float, titleX1: Float, titleY1: Float }
410
+ public struct QvpRosette: Equatable { public let decoration: Int, surah: Int, ayah: Int, juz: Int, hizb: Int, nisf: Int, rubuAlHizb: Int, rubuAlHizbInHizb: Int }
411
+ public struct QvpSajdah: Equatable { public let decoration: Int, surah: Int, ayah: Int, signPath: Int }
412
+ public struct QvpMatch: Equatable { public let word: Int, index: Int, isLooseMatch: Bool, wordKey: String, text: String }
413
+ public struct QvpCropBounds: Equatable { public let x0: Float, y0: Float, x1: Float, y1: Float, nWords: Int, ayahMarkDecoration: Int }
414
+ public struct QvpAtlasSurah: Equatable { public let number: Int, page: Int, ayahCount: Int, place: String, arabic: String, latin: String, english: String }
415
+ public struct QvpAtlasRubuAlHizb: Equatable { public let rubuAlHizb: Int, surah: Int, ayah: Int, page: Int; public var ayahKey: String { "\(surah):\(ayah)" } }
416
+
417
+ // ── C interop helpers ──
418
+ extension QvpStr {
419
+ var string: String {
420
+ guard let p = ptr, len > 0 else { return "" }
421
+ return String(decoding: UnsafeBufferPointer(start: p, count: Int(len)), as: UTF8.self)
422
+ }
423
+ }
424
+ func index(_ v: UInt32) -> Int { v == QVP_NONE ? -1 : Int(v) }
425
+ func place(_ p: UInt8) -> String { QvpEngine.placeName(Int(p)) }
426
+ /// Call an `(out, cap) → total` C function, growing the buffer until everything fits.
427
+ func collect<T>(_ initial: Int = 256, _ f: (UnsafeMutablePointer<T>, UInt32) -> UInt32) -> [T] {
428
+ var cap = initial
429
+ while true {
430
+ var total: UInt32 = 0
431
+ let buf = [T](unsafeUninitializedCapacity: cap) { p, n in total = f(p.baseAddress!, UInt32(truncatingIfNeeded: cap)); n = Swift.min(Int(total), cap) }
432
+ if Int(total) <= cap { return buf }
433
+ cap = Int(total)
434
+ }
435
+ }
436
+ func withBytes<R>(_ s: String, _ body: (UnsafePointer<UInt8>, UInt32) -> R) -> R {
437
+ var b = Array(s.utf8); if b.isEmpty { b = [0] }
438
+ let n = UInt32(truncatingIfNeeded: s.utf8.count)
439
+ return b.withUnsafeBufferPointer { body($0.baseAddress!, n) }
440
+ }
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env bash
2
+ # Copy QvpKit into this package, for the pod: the Swift sources, and the release URL and
3
+ # checksum of the XCFramework the root Package.swift names.
4
+ #
5
+ # Usage: ios/vendor-qvpkit.sh (from the package directory, inside the quran-engine repository)
6
+ # Input: ../../ios/QvpKit/Sources/QvpKit/*.swift and ../../../Package.swift
7
+ # Output: ios/vendor/QvpKit/*.swift and ios/vendor/QvpEngine.json (both gitignored)
8
+ #
9
+ # `npm pack` and `npm publish` run it (the prepack script), so the tarball holds the sources.
10
+ # qvp-react-native.podspec runs it at `pod install` inside the repository, so the pod builds
11
+ # the QvpKit sources of this checkout.
12
+ set -euo pipefail
13
+ cd "$(dirname "$0")/.."
14
+
15
+ kit=../../ios/QvpKit/Sources/QvpKit
16
+ manifest=../../../Package.swift
17
+ [ -d "$kit" ] || { echo "error: $kit is missing; run this script inside the quran-engine repository" >&2; exit 1; }
18
+
19
+ rm -rf ios/vendor/QvpKit
20
+ mkdir -p ios/vendor/QvpKit
21
+ cp "$kit"/*.swift ios/vendor/QvpKit/
22
+
23
+ python3 - "$manifest" ios/vendor/QvpEngine.json <<'PY'
24
+ import json
25
+ import pathlib
26
+ import re
27
+ import sys
28
+
29
+ text = pathlib.Path(sys.argv[1]).read_text()
30
+ url = re.search(r'url: "(https://[^"]+/QvpEngine\.xcframework\.zip)"', text)
31
+ checksum = re.search(r'checksum: "([0-9a-f]{64})"', text)
32
+ if not url or not checksum:
33
+ raise SystemExit(f"error: {sys.argv[1]} has no XCFramework URL and checksum")
34
+ pathlib.Path(sys.argv[2]).write_text(json.dumps({"url": url.group(1), "sha256": checksum.group(1)}, indent=2) + "\n")
35
+ PY
36
+ echo "vendored $(find ios/vendor/QvpKit -name '*.swift' | wc -l | tr -d ' ') QvpKit sources and ios/vendor/QvpEngine.json" >&2
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@quran.ws/qvp-react-native",
3
- "version": "0.7.0",
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.",
3
+ "version": "0.9.0",
4
+ "description": "React Native wrapper for the QVP vector mushaf engine, for Android and iOS. Thin marshalling over the Kotlin library (JNI over qvp.h) and the Swift library QvpKit.",
5
5
  "main": "src/index.tsx",
6
6
  "types": "src/index.tsx",
7
7
  "react-native": "src/index.tsx",
@@ -11,12 +11,19 @@
11
11
  "android/build.gradle",
12
12
  "android/src",
13
13
  "!android/src/test",
14
+ "ios/*.swift",
15
+ "ios/*.m",
16
+ "ios/vendor-qvpkit.sh",
17
+ "ios/vendor/QvpKit",
18
+ "ios/vendor/QvpEngine.json",
19
+ "qvp-react-native.podspec",
14
20
  "README.md",
15
21
  "package.json"
16
22
  ],
17
23
  "scripts": {
18
24
  "typecheck": "tsc --noEmit",
19
- "build": "tsc -p tsconfig.build.json"
25
+ "build": "tsc -p tsconfig.build.json",
26
+ "prepack": "bash ios/vendor-qvpkit.sh"
20
27
  },
21
28
  "keywords": [
22
29
  "react-native",
@@ -0,0 +1,97 @@
1
+ # @quran.ws/qvp-react-native, iOS. The pod compiles the native module (ios/*.swift, ios/*.m)
2
+ # together with QvpKit's Swift sources (ios/vendor/QvpKit), and links QvpEngine.xcframework,
3
+ # the engine as a static library.
4
+ #
5
+ # The pod takes QvpKit and the engine in one of three ways. The first that applies wins:
6
+ # 1. Inside the quran-engine repository (the example does this): the pod copies QvpKit's
7
+ # sources from packages/ios/QvpKit at every `pod install`, and takes the XCFramework that
8
+ # scripts/build-engine-ios.sh writes at packages/ios/QvpKit/QvpEngine.xcframework.
9
+ # 2. The environment variable QVP_ENGINE_XCFRAMEWORK names an XCFramework to link. The
10
+ # QvpKit sources come from the package, as in 3.
11
+ # 3. Otherwise, as for an app that installs the package from npm: the QvpKit sources come in
12
+ # the package, and `pod install` downloads the XCFramework that the package's
13
+ # ios/vendor/QvpEngine.json names, the one SwiftPM takes for the same release, and checks
14
+ # its SHA-256 checksum before it unpacks it.
15
+ require "json"
16
+ require "fileutils"
17
+ require "digest"
18
+ require "tmpdir"
19
+
20
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
21
+ root = File.realpath(__dir__)
22
+ vendor = File.join(root, "ios", "vendor")
23
+ engine = File.join(vendor, "QvpEngine.xcframework")
24
+ stamp = File.join(vendor, "QvpEngine.source")
25
+ repo_kit = File.expand_path("../../ios/QvpKit", root)
26
+ in_repo = File.directory?(File.join(repo_kit, "Sources", "QvpKit"))
27
+
28
+ # Copy an XCFramework into the pod, unless the copy in place came from the same source.
29
+ place_engine = lambda do |from, source|
30
+ return if File.directory?(engine) && File.exist?(stamp) && File.read(stamp) == source
31
+ FileUtils.rm_rf(engine)
32
+ FileUtils.mkdir_p(vendor)
33
+ FileUtils.cp_r(from, engine)
34
+ File.write(stamp, source)
35
+ end
36
+
37
+ if in_repo
38
+ system("bash", File.join(root, "ios", "vendor-qvpkit.sh"), exception: true)
39
+ end
40
+ unless File.directory?(File.join(vendor, "QvpKit"))
41
+ raise "qvp-react-native: ios/vendor/QvpKit is missing. Inside the repository, run ios/vendor-qvpkit.sh; outside it, reinstall the package from npm."
42
+ end
43
+
44
+ explicit = ENV["QVP_ENGINE_XCFRAMEWORK"]
45
+ if explicit && !explicit.empty?
46
+ path = File.expand_path(explicit)
47
+ raise "qvp-react-native: QVP_ENGINE_XCFRAMEWORK names #{path}, which is not a directory" unless File.directory?(path)
48
+ # Always a fresh copy: the source is a build the caller may have just made.
49
+ File.delete(stamp) if File.exist?(stamp)
50
+ place_engine.call(path, "path:#{path}")
51
+ elsif in_repo
52
+ built = File.join(repo_kit, "QvpEngine.xcframework")
53
+ raise "qvp-react-native: #{built} is missing; run scripts/build-engine-ios.sh first" unless File.directory?(built)
54
+ # Always a fresh copy: an engine rebuilt after a change under crates/ must reach the app.
55
+ File.delete(stamp) if File.exist?(stamp)
56
+ place_engine.call(built, "repo:#{built}")
57
+ else
58
+ release = JSON.parse(File.read(File.join(vendor, "QvpEngine.json")))
59
+ url, sha256 = release.fetch("url"), release.fetch("sha256")
60
+ unless File.directory?(engine) && File.exist?(stamp) && File.read(stamp) == "release:#{sha256}"
61
+ Dir.mktmpdir do |tmp|
62
+ zip = File.join(tmp, "QvpEngine.xcframework.zip")
63
+ Pod::UI.puts "qvp-react-native: downloading #{url}" if defined?(Pod::UI)
64
+ unless system("curl", "-fsSL", "--retry", "3", "-o", zip, url)
65
+ raise "qvp-react-native: could not download #{url}. Release v#{package["version"]} may not be published yet. " \
66
+ "Set QVP_ENGINE_XCFRAMEWORK to an XCFramework that scripts/build-engine-ios.sh built, or try again later."
67
+ end
68
+ got = Digest::SHA256.file(zip).hexdigest
69
+ raise "qvp-react-native: #{url} has SHA-256 #{got}, the package expects #{sha256}" unless got == sha256
70
+ system("unzip", "-q", zip, "-d", tmp, exception: true)
71
+ place_engine.call(File.join(tmp, "QvpEngine.xcframework"), "release:#{sha256}")
72
+ end
73
+ end
74
+ end
75
+
76
+ Pod::Spec.new do |s|
77
+ s.name = "qvp-react-native"
78
+ s.version = package["version"]
79
+ s.summary = package["description"]
80
+ s.homepage = "https://github.com/quran-ws/quran-engine/tree/main/packages/react-native/qvp-react-native"
81
+ s.license = { :type => package["license"], :file => "LICENSE" }
82
+ s.authors = { "Quran.ws" => "team@quran.ws" }
83
+ s.platforms = { :ios => "15.1" }
84
+ s.source = { :git => "https://github.com/quran-ws/quran-engine.git", :tag => "v#{s.version}" }
85
+ s.source_files = "ios/*.{swift,m}", "ios/vendor/QvpKit/*.swift"
86
+ s.vendored_frameworks = "ios/vendor/QvpEngine.xcframework"
87
+ s.swift_version = "5.9"
88
+ s.pod_target_xcconfig = { "DEFINES_MODULE" => "YES" }
89
+
90
+ # The React Native helper adds React-Core and, under the new architecture, what the interop
91
+ # layer needs. An older React Native has no helper, and React-Core is enough.
92
+ if respond_to?(:install_modules_dependencies, true)
93
+ install_modules_dependencies(s)
94
+ else
95
+ s.dependency "React-Core"
96
+ end
97
+ end
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;