@ugfoundation/swaralipi-js 0.7.1 → 0.7.2
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/dist/{batch-6AINAZJS.js → batch-W56YUPJC.js} +4 -4
- package/dist/{batch-6AINAZJS.js.map → batch-W56YUPJC.js.map} +1 -1
- package/dist/{chunk-7QBLGKJC.js → chunk-AAQIY4VS.js} +3 -3
- package/dist/{chunk-7QBLGKJC.js.map → chunk-AAQIY4VS.js.map} +1 -1
- package/dist/{chunk-ZOCFJL5A.js → chunk-RLJQ5UIN.js} +3 -3
- package/dist/{chunk-ZOCFJL5A.js.map → chunk-RLJQ5UIN.js.map} +1 -1
- package/dist/cli.cjs +1 -1
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +2 -2
- package/dist/convert/index.cjs +1 -1
- package/dist/convert/index.cjs.map +1 -1
- package/dist/convert/index.js +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/spec/index.cjs +1 -1
- package/dist/spec/index.cjs.map +1 -1
- package/dist/spec/index.d.cts +1 -1
- package/dist/spec/index.d.ts +1 -1
- package/dist/spec/index.js +1 -1
- package/dist/viewer/index.cjs +17 -6
- package/dist/viewer/index.cjs.map +1 -1
- package/dist/viewer/index.d.cts +3 -1
- package/dist/viewer/index.d.ts +3 -1
- package/dist/viewer/index.js +16 -5
- package/dist/viewer/index.js.map +1 -1
- package/package.json +1 -1
package/dist/viewer/index.d.cts
CHANGED
|
@@ -197,7 +197,9 @@ declare function renderToHtml(doc: Swaralipi, opts?: RenderOptions): string;
|
|
|
197
197
|
* `transform` would scale it too, but would also break print
|
|
198
198
|
* pagination). This is what actually makes the glyphs smaller, so it
|
|
199
199
|
* runs second and stops at `minSize` px — past that the block scrolls
|
|
200
|
-
* inside `.sw-scroll` rather than becoming unreadable.
|
|
200
|
+
* inside `.sw-scroll` rather than becoming unreadable. It also runs the
|
|
201
|
+
* other way: a sheet narrower than its container grows (to 2x) rather
|
|
202
|
+
* than leaving dead space to the right of every row.
|
|
201
203
|
*
|
|
202
204
|
* `zoom` (default 1) multiplies the fit scale so callers can zoom in past
|
|
203
205
|
* fit-to-width, or below the readability floor deliberately; past that point
|
package/dist/viewer/index.d.ts
CHANGED
|
@@ -197,7 +197,9 @@ declare function renderToHtml(doc: Swaralipi, opts?: RenderOptions): string;
|
|
|
197
197
|
* `transform` would scale it too, but would also break print
|
|
198
198
|
* pagination). This is what actually makes the glyphs smaller, so it
|
|
199
199
|
* runs second and stops at `minSize` px — past that the block scrolls
|
|
200
|
-
* inside `.sw-scroll` rather than becoming unreadable.
|
|
200
|
+
* inside `.sw-scroll` rather than becoming unreadable. It also runs the
|
|
201
|
+
* other way: a sheet narrower than its container grows (to 2x) rather
|
|
202
|
+
* than leaving dead space to the right of every row.
|
|
201
203
|
*
|
|
202
204
|
* `zoom` (default 1) multiplies the fit scale so callers can zoom in past
|
|
203
205
|
* fit-to-width, or below the readability floor deliberately; past that point
|
package/dist/viewer/index.js
CHANGED
|
@@ -492,14 +492,22 @@ function fitSwaralipi(root, minScale = 0, zoom = 1, minSpacing = 0.35, minSize =
|
|
|
492
492
|
const available = scroll.clientWidth;
|
|
493
493
|
let natural = block.scrollWidth;
|
|
494
494
|
if (available === 0 || natural === 0) continue;
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
495
|
+
if (natural > available && minSpacing < 1) {
|
|
496
|
+
let loose = minSpacing;
|
|
497
|
+
let tight = 1;
|
|
498
|
+
for (let i = 0; i < 6; i++) {
|
|
499
|
+
const mid = (loose + tight) / 2;
|
|
500
|
+
sheet.style.setProperty("--sw-tight", String(mid));
|
|
501
|
+
if (block.scrollWidth <= available) loose = mid;
|
|
502
|
+
else tight = mid;
|
|
503
|
+
}
|
|
504
|
+
sheet.style.setProperty("--sw-tight", String(loose));
|
|
498
505
|
natural = block.scrollWidth;
|
|
499
506
|
}
|
|
500
507
|
const base = parseFloat(getComputedStyle(sheet).fontSize);
|
|
501
|
-
|
|
502
|
-
|
|
508
|
+
if (!(base > 0)) continue;
|
|
509
|
+
let fit = Math.max(minScale, Math.min((available - 1) / natural, 2));
|
|
510
|
+
if (minSize > 0) fit = Math.max(fit, Math.min(1, minSize / base));
|
|
503
511
|
const scale = fit * zoom;
|
|
504
512
|
if (scale === 1) continue;
|
|
505
513
|
sheet.style.setProperty("--sw-size", `${(base * scale).toFixed(3)}px`);
|
|
@@ -1308,6 +1316,9 @@ function createElementClass() {
|
|
|
1308
1316
|
});
|
|
1309
1317
|
this.#root.innerHTML = this.#styleFallback() + html;
|
|
1310
1318
|
this.#fit();
|
|
1319
|
+
void document.fonts?.ready.then(() => {
|
|
1320
|
+
if (seq === this.#renderSeq) this.fit();
|
|
1321
|
+
});
|
|
1311
1322
|
}
|
|
1312
1323
|
#renderError(message) {
|
|
1313
1324
|
const div = document.createElement("div");
|