@quran.ws/engine 0.1.0 → 0.3.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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Quran.ws
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -18,7 +18,7 @@ Use it when building Quran applications for mobile or desktop and you need fast,
18
18
  | | |
19
19
  |---|---|
20
20
  | **Package** | `@quran.ws/engine` · `0.1.0` |
21
- | **Whole mushaf** | 38.9 MB brotli |
21
+ | **Whole mushaf** | 26 MB as one bundle · 41.8 MB page by page · 92.6 MB raw |
22
22
  | **Wasm engine** | 311 KB |
23
23
  | **Licence** | MIT (the code) · source bundle terms (the data) |
24
24
 
@@ -26,6 +26,81 @@ Use it when building Quran applications for mobile or desktop and you need fast,
26
26
  # not published — build the wasm, or take it from the release
27
27
  ```
28
28
 
29
+ For a small Canvas-only reader that needs page drawing and word bands, import
30
+ the dependency-free QVP decoder. It loads the original page files directly and
31
+ does not load Wasm:
32
+
33
+ ```js
34
+ import { loadPage } from '@quran.ws/engine/lite'
35
+
36
+ const page = await loadPage('/pages/042.qvp')
37
+ const canvas = document.querySelector('canvas')
38
+ page.draw(canvas.getContext('2d'), page.fit(canvas, 24))
39
+ ```
40
+
41
+ ### Canvas resolution
42
+
43
+ Canvas2D rasterises these unhinted vector outlines. Give the canvas at least two backing
44
+ pixels per CSS pixel. Above that floor, use the display's device-pixel ratio rather than a
45
+ multiple of it. Extra supersampling makes the browser downsample the result and can leave
46
+ thin strokes and diacritics soft or uneven.
47
+
48
+ ```js
49
+ const rect = canvas.getBoundingClientRect()
50
+ const pixelRatio = Math.max(2, window.devicePixelRatio || 1)
51
+ canvas.width = Math.round(rect.width * pixelRatio)
52
+ canvas.height = Math.round(rect.height * pixelRatio)
53
+ canvas.style.width = `${rect.width}px`
54
+ canvas.style.height = `${rect.height}px`
55
+ page.draw(canvas.getContext('2d'), page.fit(canvas, 24 * pixelRatio))
56
+ ```
57
+
58
+ An app may cap the backing dimensions or total pixel count to control memory use. The web
59
+ example uses this rule and caps its ratio at three.
60
+
61
+ Page files are served from `cdn.quran.ws` under immutable, versioned URLs, so a
62
+ browser can load one page without shipping the data — `docs/CDN.md`:
63
+
64
+ ```js
65
+ const page = await loadPage('https://cdn.quran.ws/qvp/v0.4.0/042.qvp')
66
+ ```
67
+
68
+ `cdn.quran.ws` mirrors the signed releases of the stack. This repo publishes two
69
+ kinds of artifact, each on its own version line:
70
+
71
+ | folder | holds |
72
+ |---|---|
73
+ | `qvp/<version>/` | page data, atlas, text sidecars, QVP/SVG/font surah-name assets, the brotli bundle |
74
+ | `engine/wasm/<version>/`, `engine/apple/<version>/`, `engine/android/<version>/` | engine builds |
75
+
76
+ `latest.json` beside each names the current version. Other repositories of the
77
+ stack publish their own folders on the same host — `docs/CDN.md` has the layout.
78
+
79
+ `qvp.quran.ws/<version>/` redirects to `cdn.quran.ws/qvp/<version>/`, so URLs
80
+ published before the move still resolve.
81
+
82
+ Decoded words include their `surah`, `ayah`, `word` and page-coordinate `box`.
83
+ `page.hitTestExact(x, y)` returns the word at a point in those same page coordinates.
84
+ `drawWords(ctx, wordIndices, options)` draws selected words with their dots,
85
+ diacritics and pause marks. `drawDecorations(ctx, options)` draws non-word page
86
+ elements such as ayah markers, surah banners, basmalahs, division and sajdah
87
+ marks, running heads and page numbers. Both accept the same `scale`, `x`, `y`
88
+ and `ink` options as `draw()` and leave clearing and sizing to the caller.
89
+
90
+ For a standalone verse excerpt that wraps to its container without Wasm, import the optional `QvpPassage` from `@quran.ws/engine/lite/passage`. It takes `decodeGeometry()` pages and a complete ayah range, including ranges across pages, and preserves verse medallions and sajdah signs. See [Lite passages](docs/LITE-PASSAGES.md). The base lite import does not load this layout code.
91
+
92
+ Use the main package for full-page layout, exact hit-testing, search, styling, selection,
93
+ masks and animation.
94
+
95
+ On iOS and macOS, add the repository as a Swift package and use its `QvpKit` product:
96
+
97
+ ```swift
98
+ .package(url: "https://github.com/quran-ws/quran-engine.git", from: "0.2.2")
99
+ ```
100
+
101
+ SwiftPM downloads the release XCFramework and verifies its checksum. Page data remains a
102
+ separate app or CDN resource.
103
+
29
104
  ## Where the documentation is
30
105
 
31
106
  Everything about using it lives on the site. This repository is the source.
@@ -48,6 +123,6 @@ Everything about using it lives on the site. This repository is the source.
48
123
  | `web/` | the reference web harness the browser demo runs on |
49
124
  | `conformance/` | the gates that must stay green |
50
125
  | `scripts/` | build and packaging |
51
- | `docs/` | the API, the format, and the measured numbers |
126
+ | `docs/` | `HOW-IT-WORKS.md` (start here), the API, the standards, and the measured numbers |
52
127
 
53
- Issues and pull requests are welcome here. Everything that is not about *changing* this repository is on the site.
128
+ Issues and pull requests are welcome here. `CONTRIBUTING.md` says how; `docs/HOW-IT-WORKS.md` describes the engine's components and data flow. Everything that is not about *changing* this repository is on the site.