@readium/navigator 2.4.0-alpha.13 → 2.4.0-alpha.14

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/index.js CHANGED
@@ -3629,7 +3629,7 @@ const _t = class _t extends gt {
3629
3629
  ), Reflect.defineProperty(t.navigator, "epubReadingSystem", {
3630
3630
  value: {
3631
3631
  name: "readium-ts-toolkit",
3632
- version: "2.4.0-alpha.13",
3632
+ version: "2.4.0-alpha.14",
3633
3633
  hasFeature: (n, r = "") => {
3634
3634
  switch (n) {
3635
3635
  case "dom-manipulation":
@@ -9923,12 +9923,28 @@ class un extends qi {
9923
9923
  e(i);
9924
9924
  return;
9925
9925
  }
9926
- const o = t?.locations?.progression;
9926
+ const o = t.locations?.progression;
9927
9927
  o && o > 0 ? i = await new Promise((l, h) => {
9928
9928
  this._cframes[0].msg.send("go_progression", o, (c) => l(c));
9929
9929
  }) : i = !0, e(i);
9930
9930
  }
9931
9931
  go(t, e, i) {
9932
+ if (!t.href) {
9933
+ let o = !1;
9934
+ if (typeof t.locations.position == "number") {
9935
+ const a = this.positions.find((l) => l.locations.position === t.locations.position);
9936
+ a && (t = a.copyWithLocations(t.locations), o = !0);
9937
+ }
9938
+ if (!o && typeof t.locations?.totalProgression == "number") {
9939
+ const a = t.locations.totalProgression;
9940
+ let l = 0, h = 1 / 0;
9941
+ for (let c = 0; c < this.positions.length; c++) {
9942
+ const m = this.positions[c].locations.totalProgression ?? c / this.positions.length, y = Math.abs(m - a);
9943
+ y < h && (h = y, l = c);
9944
+ }
9945
+ t = this.positions[l].copyWithLocations(t.locations);
9946
+ }
9947
+ }
9932
9948
  const n = t.href.split("#")[0];
9933
9949
  let r = this.pub.readingOrder.findWithHref(n);
9934
9950
  if (!r)