@zinejs/core 0.6.0 → 0.7.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.
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import { t as e } from "./types-CcPVyhOJ.js";
2
- import { n as t, r as n, t as r } from "./registry-5nuYFMd4.js";
1
+ import { r as e, t } from "./types-DEz3mRLI.js";
2
+ import { n, r, t as i } from "./registry-5nuYFMd4.js";
3
3
  //#region src/engine/spread.ts
4
- function i(e, t = {}) {
4
+ function a(e, t = {}) {
5
5
  let { direction: n = "ltr", mode: r = "cover" } = t;
6
6
  if (e <= 0) return [];
7
7
  let i = (t) => t >= 0 && t < e ? t : null, a = [];
@@ -40,17 +40,17 @@ function i(e, t = {}) {
40
40
  right: e.left
41
41
  })) : a;
42
42
  }
43
- function a(e, t) {
43
+ function o(e, t) {
44
44
  return e < t;
45
45
  }
46
46
  //#endregion
47
47
  //#region src/engine/virtualizer.ts
48
- function o(e, t, n) {
48
+ function s(e, t, n) {
49
49
  let r = [], i = Math.max(0, e - n), a = Math.min(t - 1, e + n);
50
50
  for (let e = i; e <= a; e++) r.push(e);
51
51
  return r;
52
52
  }
53
- var s = class {
53
+ var c = class {
54
54
  #e;
55
55
  #t = /* @__PURE__ */ new Set();
56
56
  constructor(e = 2) {
@@ -60,7 +60,7 @@ var s = class {
60
60
  return [...this.#t].sort((e, t) => e - t);
61
61
  }
62
62
  update(e, t) {
63
- let n = new Set(o(e, t, this.#e)), r = [...n].filter((e) => !this.#t.has(e)).sort((e, t) => e - t), i = [...this.#t].filter((e) => !n.has(e)).sort((e, t) => e - t);
63
+ let n = new Set(s(e, t, this.#e)), r = [...n].filter((e) => !this.#t.has(e)).sort((e, t) => e - t), i = [...this.#t].filter((e) => !n.has(e)).sort((e, t) => e - t);
64
64
  for (let e of i) this.#t.delete(e);
65
65
  for (let e of r) this.#t.add(e);
66
66
  return {
@@ -68,7 +68,7 @@ var s = class {
68
68
  toEvict: i
69
69
  };
70
70
  }
71
- }, c = class {
71
+ }, l = class {
72
72
  #e = /* @__PURE__ */ new Map();
73
73
  on(e, t) {
74
74
  let n = this.#e.get(e);
@@ -84,7 +84,7 @@ var s = class {
84
84
  clear() {
85
85
  this.#e.clear();
86
86
  }
87
- }, l = {
87
+ }, u = {
88
88
  idle: {
89
89
  grab: "dragging",
90
90
  panStart: "zoomed-panning",
@@ -94,10 +94,10 @@ var s = class {
94
94
  animating: { settle: "idle" },
95
95
  "zoomed-panning": { panEnd: "idle" }
96
96
  };
97
- function u(e, t) {
98
- return l[e][t] ?? null;
97
+ function d(e, t) {
98
+ return u[e][t] ?? null;
99
99
  }
100
- var d = class {
100
+ var f = class {
101
101
  #e;
102
102
  constructor(e = "idle") {
103
103
  this.#e = e;
@@ -106,10 +106,10 @@ var d = class {
106
106
  return this.#e;
107
107
  }
108
108
  send(e) {
109
- let t = u(this.#e, e);
109
+ let t = d(this.#e, e);
110
110
  return t !== null && (this.#e = t), t;
111
111
  }
112
- }, f = .3, p = class {
112
+ }, p = .3, m = class {
113
113
  #e;
114
114
  #t = null;
115
115
  #n = null;
@@ -164,7 +164,7 @@ var d = class {
164
164
  dt: r - a.t,
165
165
  vx: l,
166
166
  vy: u,
167
- swipe: !i && d > f,
167
+ swipe: !i && d > p,
168
168
  canceled: i
169
169
  });
170
170
  }
@@ -172,7 +172,7 @@ var d = class {
172
172
  this.#t = null, this.#n = null, this.#r = null, this.#i = null;
173
173
  }
174
174
  };
175
- function m(e, t) {
175
+ function h(e, t) {
176
176
  let { pointer: n, pinch: r } = t, i = (e) => {
177
177
  let t = e;
178
178
  n?.down(t.pointerId, t.clientX, t.clientY, t.timeStamp), r?.down(t.pointerId, t.clientX, t.clientY);
@@ -190,10 +190,10 @@ function m(e, t) {
190
190
  e.removeEventListener("pointerdown", i), e.removeEventListener("pointermove", a), e.removeEventListener("pointerup", o), e.removeEventListener("pointercancel", s);
191
191
  };
192
192
  }
193
- function h(e, t) {
193
+ function g(e, t) {
194
194
  return Math.hypot(e.x - t.x, e.y - t.y);
195
195
  }
196
- var g = class {
196
+ var _ = class {
197
197
  #e;
198
198
  #t = /* @__PURE__ */ new Map();
199
199
  #n = 0;
@@ -210,7 +210,7 @@ var g = class {
210
210
  y: n
211
211
  }), this.#t.size === 2)) {
212
212
  let { a: e, b: t } = this.#a();
213
- this.#n = h(e, t), this.#r = !0, this.#e.onPinchStart?.({
213
+ this.#n = g(e, t), this.#r = !0, this.#e.onPinchStart?.({
214
214
  centerX: (e.x + t.x) / 2,
215
215
  centerY: (e.y + t.y) / 2,
216
216
  distance: this.#n
@@ -224,7 +224,7 @@ var g = class {
224
224
  this.#e.onPinchMove?.({
225
225
  centerX: (i.x + a.x) / 2,
226
226
  centerY: (i.y + a.y) / 2,
227
- scale: this.#n > 0 ? h(i, a) / this.#n : 1
227
+ scale: this.#n > 0 ? g(i, a) / this.#n : 1
228
228
  });
229
229
  }
230
230
  up(e) {
@@ -247,7 +247,7 @@ var g = class {
247
247
  };
248
248
  //#endregion
249
249
  //#region src/geometry/hitTest.ts
250
- function _(e, t, n) {
250
+ function v(e, t, n) {
251
251
  let { width: r, height: i } = t;
252
252
  if (e.x < 0 || e.x > r || e.y < 0 || e.y > i) return "outside";
253
253
  let a = e.x <= n || e.x >= r - n, o = e.y <= n || e.y >= i - n;
@@ -255,33 +255,33 @@ function _(e, t, n) {
255
255
  }
256
256
  //#endregion
257
257
  //#region src/engine/deeplink.ts
258
- var v = "page", y = !1;
259
- function b() {
260
- return y ? !1 : (y = !0, !0);
261
- }
258
+ var y = "page", b = !1;
262
259
  function x() {
263
- y = !1;
260
+ return b ? !1 : (b = !0, !0);
264
261
  }
265
- function S(e) {
266
- let t = new URLSearchParams(e.replace(/^#/, "")).get(v);
262
+ function S() {
263
+ b = !1;
264
+ }
265
+ function C(e) {
266
+ let t = new URLSearchParams(e.replace(/^#/, "")).get(y);
267
267
  if (t === null) return null;
268
268
  let n = Number(t);
269
269
  return Number.isInteger(n) && n >= 1 ? n - 1 : null;
270
270
  }
271
- function C(e, t) {
271
+ function w(e, t) {
272
272
  let n = new URLSearchParams(e.replace(/^#/, ""));
273
- return n.set(v, String(t + 1)), `#${n.toString()}`;
273
+ return n.set(y, String(t + 1)), `#${n.toString()}`;
274
274
  }
275
- function w(e, t) {
275
+ function T(e, t) {
276
276
  let n = null, r = () => {
277
- let r = S(e.location.hash);
277
+ let r = C(e.location.hash);
278
278
  r === null || r === n || (n = r, t(r));
279
279
  };
280
280
  return e.addEventListener("hashchange", r), {
281
281
  push(t) {
282
282
  if (t === n) return;
283
283
  n = t;
284
- let r = C(e.location.hash, t);
284
+ let r = w(e.location.hash, t);
285
285
  r !== e.location.hash && e.history?.replaceState?.(e.history.state, "", r);
286
286
  },
287
287
  stop() {
@@ -291,9 +291,9 @@ function w(e, t) {
291
291
  }
292
292
  //#endregion
293
293
  //#region src/renderer/select.ts
294
- var T = {
294
+ var ee = {
295
295
  css: async () => new (await (import("./cssRenderer-OzRRoEa4.js"))).CssRenderer(),
296
- webgl2: async () => new (await (import("./webglRenderer-BK-ArG1G.js"))).WebglRenderer()
296
+ webgl2: async () => new (await (import("./webglRenderer-BcNhTqG8.js"))).WebglRenderer()
297
297
  }, E = !0;
298
298
  function D(e) {
299
299
  return typeof e == "object" && !!e && !Array.isArray(e) && typeof e.mount == "function";
@@ -316,7 +316,7 @@ async function j(e = "auto", t = k()) {
316
316
  let n = Array.isArray(e) ? e : e === "auto" ? O(t) : [e];
317
317
  for (let e of n) {
318
318
  if (e === "webgl2" && !t.gpu) continue;
319
- let n = T[e];
319
+ let n = ee[e];
320
320
  if (n) return n();
321
321
  }
322
322
  throw n.length === 1 && n[0] === "webgl2" && !t.gpu ? Error("renderer: 'webgl2' was forced but this device has no WebGL2. Use 'css' or 'auto'.") : Error(`renderer: none of [${n.join(", ")}] could be loaded — use 'css' or 'auto'.`);
@@ -483,17 +483,17 @@ var R = class {
483
483
  throw this.#a.delete(e), t;
484
484
  }), this.#a.set(e, t)), t;
485
485
  }
486
- }, z = .25, B = .0015, V = 6, H = 250, U = 1.55, W = 32, G = 120;
487
- function K(e, t, n) {
486
+ }, z = .25, B = .0015, V = 6, H = 250, U = 1.55, W = 32, G = 120, K = 120;
487
+ function q(e, t, n) {
488
488
  let r = Math.max(0, t - W), i = Math.min(e.length, t + n + W), a = e.slice(r, i).replace(/\s+/g, " ").trim();
489
489
  return `${r > 0 ? "…" : ""}${a}${i < e.length ? "…" : ""}`;
490
490
  }
491
- var q = class {
491
+ var J = class {
492
492
  #e;
493
493
  #t;
494
- #n = new c();
495
- #r = new s(2);
496
- #i = new d();
494
+ #n = new l();
495
+ #r = new c(2);
496
+ #i = new f();
497
497
  #a;
498
498
  #o;
499
499
  #s;
@@ -564,13 +564,13 @@ var q = class {
564
564
  this.#z?.setFlipProgress(e, t);
565
565
  } };
566
566
  constructor(e, t) {
567
- Q(e, t), this.#e = e, t.width !== void 0 && (e.style.width = `${t.width}px`), t.height !== void 0 && (e.style.height = `${t.height}px`), this.#t = I(t.source, {
567
+ te(e, t), this.#e = e, t.width !== void 0 && (e.style.width = `${t.width}px`), t.height !== void 0 && (e.style.height = `${t.height}px`), this.#t = I(t.source, {
568
568
  frontCover: t.frontCover,
569
569
  backCover: t.backCover,
570
570
  pages: t.pages
571
571
  });
572
572
  let n = t.direction ?? "ltr";
573
- this.#a = n, this.#x = (t.deepLink ?? !0) && b(), this.#S = t.disableContextMenu ?? !1, this.#o = t.spreadMode ?? "cover", this.#s = this.#o, this.#c = t.curl ?? "cone", this.#u = t.clickToFlip ?? "edge", this.#d = t.clickZoneSize ?? 64, this.#m = t.singlePageThreshold ?? 640, this.#v = t.responsiveSpread ?? !0, this.#ce = t.controls ?? !0, this.#b = t.startPage, typeof this.#t.open != "function" && this.#mt(), this.#k = t.flipDuration ?? 800, this.#A = t.zoom?.enabled ?? !0, this.#j = t.zoom?.wheel ?? !0;
573
+ this.#a = n, this.#x = (t.deepLink ?? !0) && x(), this.#S = t.disableContextMenu ?? !1, this.#o = t.spreadMode ?? "cover", this.#s = this.#o, this.#c = t.curl ?? "cone", this.#u = t.clickToFlip ?? "edge", this.#d = t.clickZoneSize ?? 64, this.#m = t.singlePageThreshold ?? 640, this.#v = t.responsiveSpread ?? !0, this.#ce = t.controls ?? !0, this.#b = t.startPage, typeof this.#t.open != "function" && this.#ht(), this.#k = t.flipDuration ?? 800, this.#A = t.zoom?.enabled ?? !0, this.#j = t.zoom?.wheel ?? !0;
574
574
  let r = t.zoom?.doubleClick, i = r === !1 ? [] : [...r ?? [
575
575
  1,
576
576
  2,
@@ -608,7 +608,7 @@ var q = class {
608
608
  return this.#h;
609
609
  }
610
610
  setSpreadMode(e) {
611
- e !== this.#o && (this.#o = e, this.#_ = !1, this.#$e(), this.#et());
611
+ e !== this.#o && (this.#o = e, this.#_ = !1, this.#et(), this.#tt());
612
612
  }
613
613
  toggleSpreadMode() {
614
614
  this.setSpreadMode(this.#o === "single" ? this.#s === "single" ? "double" : this.#s : "single");
@@ -624,16 +624,16 @@ var q = class {
624
624
  if (this.#v = e, e) {
625
625
  let e = this.#z?.measure().containerWidth;
626
626
  if (e === void 0) return;
627
- this.#_ = !1, this.#Qe(e);
627
+ this.#_ = !1, this.#$e(e);
628
628
  } else {
629
629
  if (!this.#_) return;
630
- this.#_ = !1, this.#$e();
630
+ this.#_ = !1, this.#et();
631
631
  }
632
- this.#et();
632
+ this.#tt();
633
633
  }
634
634
  }
635
635
  getPageImage(e) {
636
- return this.#dt(e);
636
+ return this.#ft(e);
637
637
  }
638
638
  canFlipNext() {
639
639
  return this.#E + 1 < this.#T.length;
@@ -717,7 +717,7 @@ var q = class {
717
717
  let i = t.toLowerCase().indexOf(r);
718
718
  i < 0 || a.push({
719
719
  page: e,
720
- excerpt: K(t, i, r.length)
720
+ excerpt: q(t, i, r.length)
721
721
  });
722
722
  }
723
723
  return a;
@@ -732,8 +732,8 @@ var q = class {
732
732
  this.#he(() => this.#ye(this.#E + e));
733
733
  }
734
734
  flipTo(e) {
735
- let t = J(e, 0, Math.max(0, this.#t.pageCount - 1));
736
- this.#he(() => this.#ye(this.#pt(t)));
735
+ let t = Y(e, 0, Math.max(0, this.#t.pageCount - 1));
736
+ this.#he(() => this.#ye(this.#mt(t)));
737
737
  }
738
738
  #he(e) {
739
739
  this.#i.state === "idle" ? e() : this.#J ? (this.#q = null, this.#ge(), e()) : this.#q = e;
@@ -745,7 +745,7 @@ var q = class {
745
745
  #_e() {
746
746
  let e = this.#q;
747
747
  if (!e) {
748
- this.#st();
748
+ this.#ct();
749
749
  return;
750
750
  }
751
751
  this.#q = null, e();
@@ -755,23 +755,23 @@ var q = class {
755
755
  }
756
756
  setZoom(e, t) {
757
757
  if (!this.#z || !this.#A) return;
758
- let n = J(e, 1, this.#N), r = this.#z.measure(), i = t ?? {
758
+ let n = Y(e, 1, this.#N), r = this.#z.measure(), i = t ?? {
759
759
  x: r.containerWidth / 2,
760
760
  y: r.containerHeight / 2
761
761
  }, a = this.#I, o = n === 1 ? 0 : i.x - n / a * (i.x - this.#L), s = n === 1 ? 0 : i.y - n / a * (i.y - this.#R);
762
- [o, s] = this.#ve(o, s, n, r.containerWidth, r.containerHeight), this.#I = n, this.#L = o, this.#R = s, this.#z.setViewTransform(n, o, s), this.#it(), this.#n.emit("zoomChanged", { scale: n });
762
+ [o, s] = this.#ve(o, s, n, r.containerWidth, r.containerHeight), this.#I = n, this.#L = o, this.#R = s, this.#z.setViewTransform(n, o, s), this.#at(), this.#n.emit("zoomChanged", { scale: n });
763
763
  }
764
764
  resetZoom() {
765
765
  this.setZoom(1);
766
766
  }
767
767
  #ve(e, t, n, r, i) {
768
- return [J(e, r * (1 - n), 0), J(t, i * (1 - n), 0)];
768
+ return [Y(e, r * (1 - n), 0), Y(t, i * (1 - n), 0)];
769
769
  }
770
770
  on(e, t) {
771
771
  return this.#n.on(e, t);
772
772
  }
773
773
  destroy() {
774
- this.#V = !0, this.#H !== null && cancelAnimationFrame(this.#H), this.#J = null, this.#q = null, this.#Ne(), this.#P?.disconnect(), this.#C?.stop(), this.#C = null, this.#w?.(), this.#x && x(), this.#le?.(), this.#ae?.(), this.#ne?.(), this.#ie?.(), this.#re?.(), this.#te?.(), this.#fe !== null && clearTimeout(this.#fe), this.#de++, this.#ue?.destroy(), this.#ue = null, this.#z?.destroy(), this.#z = null, this.#t.destroy(), this.#n.clear();
774
+ this.#V = !0, this.#H !== null && cancelAnimationFrame(this.#H), this.#J = null, this.#q = null, this.#Ne(), this.#P?.disconnect(), this.#C?.stop(), this.#C = null, this.#w?.(), this.#x && S(), this.#le?.(), this.#ae?.(), this.#ne?.(), this.#ie?.(), this.#re?.(), this.#te?.(), this.#fe !== null && clearTimeout(this.#fe), this.#de++, this.#ue?.destroy(), this.#ue = null, this.#z?.destroy(), this.#z = null, this.#t.destroy(), this.#n.clear();
775
775
  }
776
776
  #ye(e) {
777
777
  if (e < 0 || e >= this.#T.length || e === this.#E || this.#i.send("flip") === null) return;
@@ -782,13 +782,13 @@ var q = class {
782
782
  }), this.#be(e, t, n, ++this.#Y);
783
783
  }
784
784
  async #be(e, t, n, r) {
785
- let i = this.#T[e], a = i ? await this.#ut(i) : {
785
+ let i = this.#T[e], a = i ? await this.#dt(i) : {
786
786
  left: null,
787
787
  right: null
788
788
  };
789
789
  r === this.#Y && (this.#z?.beginFlip(this.#O, a, t, {
790
790
  fill: this.#h,
791
- curl: this.#c,
791
+ curl: this.#Ze(),
792
792
  anchor: { y: this.#l }
793
793
  }), this.#xe(0, 1, t, () => this.#Se(e, n, a)));
794
794
  }
@@ -806,14 +806,14 @@ var q = class {
806
806
  this.#J = a;
807
807
  let o = performance.now(), s = (c) => {
808
808
  if (this.#J !== a) return;
809
- let l = Math.min(1, (c - o) / i), u = this.#h ? X(l) : Y(l);
809
+ let l = Math.min(1, (c - o) / i), u = this.#h ? Z(l) : X(l);
810
810
  this.#z?.setFlipProgress(e + (t - e) * u, n), l < 1 ? this.#H = requestAnimationFrame(s) : (this.#H = null, this.#J = null, r());
811
811
  };
812
812
  this.#H = requestAnimationFrame(s);
813
813
  }
814
814
  #Se(e, t, n) {
815
815
  let r = this.#T[e];
816
- this.#E = e, this.#D = t, this.#O = n, r && this.#tt(r, n), this.#ft(), this.#i.send("settle"), this.#Ye(), this.#n.emit("pageChanged", { page: t }), this.#n.emit("flipEnd", { page: t }), this.#_e();
816
+ this.#E = e, this.#D = t, this.#O = n, r && this.#nt(r, n), this.#pt(), this.#i.send("settle"), this.#Ye(), this.#n.emit("pageChanged", { page: t }), this.#n.emit("flipEnd", { page: t }), this.#_e();
817
817
  }
818
818
  #Ce(e) {
819
819
  let t = this.#T[e];
@@ -837,11 +837,11 @@ var q = class {
837
837
  return;
838
838
  }
839
839
  let i = Math.min(n.width, n.height) * z;
840
- if (_(r, {
840
+ if (v(r, {
841
841
  width: n.width,
842
842
  height: n.height
843
843
  }, i) !== "corner") return;
844
- this.#l = J(r.y / n.height, 0, 1);
844
+ this.#l = Y(r.y / n.height, 0, 1);
845
845
  let a = r.x > n.width / 2, o = this.#a === "rtl" ? !a : a, s = this.#E + (o ? 1 : -1);
846
846
  s < 0 || s >= this.#T.length || (this.#W = {
847
847
  direction: o ? "forward" : "backward",
@@ -868,13 +868,13 @@ var q = class {
868
868
  }), this.#Ee(e.targetIndex, e.direction)));
869
869
  }
870
870
  async #Ee(e, t) {
871
- let n = this.#T[e], r = n ? await this.#ut(n) : {
871
+ let n = this.#T[e], r = n ? await this.#dt(n) : {
872
872
  left: null,
873
873
  right: null
874
874
  };
875
875
  this.#U?.targetIndex === e && (this.#U.toContent = r, this.#z?.beginFlip(this.#O, r, t, {
876
876
  fill: this.#h,
877
- curl: this.#c,
877
+ curl: this.#Ze(),
878
878
  anchor: { y: this.#l }
879
879
  }), this.#z?.setFlipProgress(this.#U.t, t));
880
880
  }
@@ -883,12 +883,12 @@ var q = class {
883
883
  if (this.#X) {
884
884
  if (!this.#z) return;
885
885
  let n = this.#z.measure(), [r, i] = this.#ve(this.#X.baseTx + e, this.#X.baseTy + t, this.#I, n.containerWidth, n.containerHeight);
886
- this.#L = r, this.#R = i, this.#z.setViewTransform(this.#I, r, i), this.#it();
886
+ this.#L = r, this.#R = i, this.#z.setViewTransform(this.#I, r, i), this.#at();
887
887
  return;
888
888
  }
889
889
  this.#W && Math.hypot(e, t) > V && this.#Te();
890
890
  let n = this.#U;
891
- n && (n.t = J((n.direction === "forward" ? -e : e) / n.width, 0, 1), this.#z?.setFlipProgress(n.t, n.direction));
891
+ n && (n.t = Y((n.direction === "forward" ? -e : e) / n.width, 0, 1), this.#z?.setFlipProgress(n.t, n.direction));
892
892
  }
893
893
  #Oe(e) {
894
894
  if (this.#Z) return;
@@ -911,7 +911,7 @@ var q = class {
911
911
  if (!t) return;
912
912
  let n = t === "forward" ? 1 : -1;
913
913
  if (this.#E + n < 0 || this.#E + n >= this.#T.length) return;
914
- this.#l = J(this.#G.y / this.#Ae().height, 0, 1);
914
+ this.#l = Y(this.#G.y / this.#Ae().height, 0, 1);
915
915
  let r = () => this.#ye(this.#E + n);
916
916
  if (this.#Ne(), this.#p <= 0) {
917
917
  this.#he(r);
@@ -949,13 +949,13 @@ var q = class {
949
949
  }
950
950
  #Pe() {
951
951
  let e = this.#T[this.#E];
952
- e && this.#tt(e, this.#O), this.#i.send("settle"), this.#n.emit("flipEnd", { page: this.#D }), this.#_e();
952
+ e && this.#nt(e, this.#O), this.#i.send("settle"), this.#n.emit("flipEnd", { page: this.#D }), this.#_e();
953
953
  }
954
954
  #Fe() {
955
955
  if (this.#W = null, this.#Ne(), this.#U) {
956
956
  this.#U = null, this.#i.send("release"), this.#i.send("settle");
957
957
  let e = this.#T[this.#E];
958
- e && this.#tt(e, this.#O);
958
+ e && this.#nt(e, this.#O);
959
959
  } else this.#X && (this.#X = null, this.#i.send("panEnd"));
960
960
  this.#Z = !0, this.#Q = this.#I;
961
961
  }
@@ -1006,22 +1006,22 @@ var q = class {
1006
1006
  }
1007
1007
  async #Ve(e) {
1008
1008
  let t = j(e);
1009
- typeof this.#t.open == "function" && (await this.#t.open(), this.#mt()), this.#t.prefetch([this.#D]);
1009
+ typeof this.#t.open == "function" && (await this.#t.open(), this.#ht()), this.#t.prefetch([this.#D]);
1010
1010
  let n = await t, r = await this.#He(n);
1011
- this.#z = r, this.#t.onPageUpdate?.((e) => this.#rt(e)), this.#Qe(r.measure().containerWidth);
1012
- let i = new p({
1011
+ this.#z = r, this.#t.onPageUpdate?.((e) => this.#it(e)), this.#$e(r.measure().containerWidth);
1012
+ let i = new m({
1013
1013
  onStart: (e) => this.#we(e.x, e.y),
1014
1014
  onMove: (e) => this.#De(e.dx, e.dy),
1015
1015
  onEnd: (e) => this.#Oe(e)
1016
- }), a = new g({
1016
+ }), a = new _({
1017
1017
  onPinchStart: () => this.#Fe(),
1018
1018
  onPinchMove: (e) => this.#Ie(e.centerX, e.centerY, e.scale),
1019
1019
  onPinchEnd: () => this.#Le()
1020
1020
  });
1021
- this.#te = m(this.#e, {
1021
+ this.#te = h(this.#e, {
1022
1022
  pointer: i,
1023
1023
  pinch: a
1024
- }), this.#ze(), this.#Be(), this.#Re(), this.#We(), this.#ae = this.#qe(), await this.#et(), this.#ct(), this.#ft(), this.#Ye(), this.#Ke(), await this.#Ge(), this.#n.emit("ready");
1024
+ }), this.#ze(), this.#Be(), this.#Re(), this.#We(), this.#ae = this.#qe(), await this.#tt(), this.#lt(), this.#pt(), this.#Ye(), this.#Ke(), await this.#Ge(), this.#n.emit("ready");
1025
1025
  }
1026
1026
  async #He(e) {
1027
1027
  try {
@@ -1045,7 +1045,7 @@ var q = class {
1045
1045
  e.destroy();
1046
1046
  return;
1047
1047
  }
1048
- await e.mount(this.#e), this.#z = e, this.#Qe(e.measure().containerWidth), await this.#et(), this.#n.emit("rendererFallback", {
1048
+ await e.mount(this.#e), this.#z = e, this.#$e(e.measure().containerWidth), await this.#tt(), this.#n.emit("rendererFallback", {
1049
1049
  from: "webgl2",
1050
1050
  to: "css"
1051
1051
  });
@@ -1070,7 +1070,7 @@ var q = class {
1070
1070
  #Ke() {
1071
1071
  if (!this.#x || globalThis.location === void 0) return;
1072
1072
  let e = globalThis;
1073
- this.#C = w(e, (e) => {
1073
+ this.#C = T(e, (e) => {
1074
1074
  e !== this.#D && this.flipTo(e);
1075
1075
  }), this.#C.push(this.#D), this.#w = this.#n.on("pageChanged", ({ page: e }) => {
1076
1076
  this.#C?.push(e);
@@ -1080,7 +1080,7 @@ var q = class {
1080
1080
  let t = globalThis.location?.href ?? "";
1081
1081
  if (!t) return "";
1082
1082
  let n = new URL(t);
1083
- return n.hash = C(n.hash, J(e, 0, Math.max(0, this.#t.pageCount - 1))), n.toString();
1083
+ return n.hash = w(n.hash, Y(e, 0, Math.max(0, this.#t.pageCount - 1))), n.toString();
1084
1084
  }
1085
1085
  #qe() {
1086
1086
  let e = this.#e, t = e.ownerDocument;
@@ -1113,59 +1113,62 @@ var q = class {
1113
1113
  this.#ee && (this.#ee.textContent = `Page ${this.#D + 1} of ${this.#t.pageCount}`);
1114
1114
  }
1115
1115
  #Xe() {
1116
- return this.#$ ? 0 : this.#k * (this.#h ? U : 1);
1116
+ return this.#$ ? K : this.#k * (this.#h ? U : 1);
1117
+ }
1118
+ #Ze() {
1119
+ return this.#$ ? "simple" : this.#c;
1117
1120
  }
1118
1121
  update() {
1119
- !this.#z || this.#i.state !== "idle" || (this.#Qe(this.#z.measure().containerWidth), this.#et());
1122
+ !this.#z || this.#i.state !== "idle" || (this.#$e(this.#z.measure().containerWidth), this.#tt());
1120
1123
  }
1121
- #Ze() {
1124
+ #Qe() {
1122
1125
  return this.#_ || this.#o === "single" ? "single" : this.#o;
1123
1126
  }
1124
- #Qe(e) {
1125
- let t = this.#v && a(e, this.#m);
1126
- t !== this.#_ && (this.#_ = t, this.#$e());
1127
+ #$e(e) {
1128
+ let t = this.#v && o(e, this.#m);
1129
+ t !== this.#_ && (this.#_ = t, this.#et());
1127
1130
  }
1128
- #$e() {
1129
- let e = this.#Ze(), t = e !== this.#g;
1130
- this.#g = e, this.#h = e === "single", this.#T = i(this.#t.pageCount, {
1131
+ #et() {
1132
+ let e = this.#Qe(), t = e !== this.#g;
1133
+ this.#g = e, this.#h = e === "single", this.#T = a(this.#t.pageCount, {
1131
1134
  direction: this.#a,
1132
1135
  mode: e
1133
- }), this.#E = this.#pt(this.#D), t && this.#n.emit("spreadChanged", {
1136
+ }), this.#E = this.#mt(this.#D), t && this.#n.emit("spreadChanged", {
1134
1137
  mode: e,
1135
1138
  singlePage: this.#h
1136
1139
  });
1137
1140
  }
1138
- async #et() {
1141
+ async #tt() {
1139
1142
  let e = this.#T[this.#E];
1140
- !e || !this.#z || (this.#O = await this.#ut(e), this.#tt(e, this.#O));
1143
+ !e || !this.#z || (this.#O = await this.#dt(e), this.#nt(e, this.#O));
1141
1144
  }
1142
- #tt(e, t) {
1143
- this.#z?.renderSpread(e, t, { fill: this.#h }), this.#nt(), this.#ue?.clear(), this.#it();
1145
+ #nt(e, t) {
1146
+ this.#z?.renderSpread(e, t, { fill: this.#h }), this.#rt(), this.#ue?.clear(), this.#at();
1144
1147
  }
1145
- #nt() {
1148
+ #rt() {
1146
1149
  let e = this.#z?.measure().book;
1147
1150
  if (!e || e.width <= 0 || e.height <= 0) return;
1148
1151
  let t = (e.width / e.height).toFixed(4);
1149
1152
  t !== this.#y && (this.#y = t, this.#e.style.aspectRatio = t);
1150
1153
  }
1151
- #rt(e) {
1154
+ #it(e) {
1152
1155
  if (this.#i.state !== "idle") {
1153
1156
  this.#se.add(e);
1154
1157
  return;
1155
1158
  }
1156
1159
  let t = this.#T[this.#E];
1157
- t && (t.left === e || t.right === e) && this.#et();
1160
+ t && (t.left === e || t.right === e) && this.#tt();
1158
1161
  }
1159
- #it() {
1162
+ #at() {
1160
1163
  if (this.#fe !== null && clearTimeout(this.#fe), this.#I <= 1) {
1161
1164
  this.#ue?.clear(), this.#de++;
1162
1165
  return;
1163
1166
  }
1164
1167
  this.#fe = setTimeout(() => {
1165
- this.#fe = null, this.#at();
1168
+ this.#fe = null, this.#ot();
1166
1169
  }, G);
1167
1170
  }
1168
- async #at() {
1171
+ async #ot() {
1169
1172
  let e = this.#z, t = this.#T[this.#E];
1170
1173
  if (!e || !t || this.#I <= 1) return;
1171
1174
  let n = e.measure(), r = n.content ?? n.book;
@@ -1212,33 +1215,33 @@ var q = class {
1212
1215
  }));
1213
1216
  if (d !== this.#de || this.#I <= 1) return;
1214
1217
  let p = f.filter((e) => e !== null);
1215
- p.length !== 0 && (this.#ue ??= this.#ot(), this.#ue?.draw(p, s, c));
1218
+ p.length !== 0 && (this.#ue ??= this.#st(), this.#ue?.draw(p, s, c));
1216
1219
  }
1217
- #ot() {
1220
+ #st() {
1218
1221
  let e = this.#e.ownerDocument;
1219
1222
  return !e || typeof this.#e.append != "function" ? null : new F(e, this.#e);
1220
1223
  }
1221
- #st() {
1224
+ #ct() {
1222
1225
  if (this.#se.size === 0) return;
1223
1226
  let e = this.#T[this.#E], t = e !== void 0 && [e.left, e.right].some((e) => e !== null && this.#se.has(e));
1224
- this.#se.clear(), t && this.#et();
1225
- }
1226
- #ct() {
1227
- typeof ResizeObserver > "u" || (this.#P = new ResizeObserver(() => this.#lt()), this.#P.observe(this.#e));
1227
+ this.#se.clear(), t && this.#tt();
1228
1228
  }
1229
1229
  #lt() {
1230
+ typeof ResizeObserver > "u" || (this.#P = new ResizeObserver(() => this.#ut()), this.#P.observe(this.#e));
1231
+ }
1232
+ #ut() {
1230
1233
  this.#F || (this.#F = !0, requestAnimationFrame(() => {
1231
1234
  this.#F = !1, this.update();
1232
1235
  }));
1233
1236
  }
1234
- async #ut(e) {
1235
- let [t, n] = await Promise.all([this.#dt(e.left), this.#dt(e.right)]);
1237
+ async #dt(e) {
1238
+ let [t, n] = await Promise.all([this.#ft(e.left), this.#ft(e.right)]);
1236
1239
  return {
1237
1240
  left: t,
1238
1241
  right: n
1239
1242
  };
1240
1243
  }
1241
- async #dt(e) {
1244
+ async #ft(e) {
1242
1245
  if (e === null) return null;
1243
1246
  try {
1244
1247
  return await this.#t.get(e);
@@ -1249,7 +1252,7 @@ var q = class {
1249
1252
  }), null;
1250
1253
  }
1251
1254
  }
1252
- #ft() {
1255
+ #pt() {
1253
1256
  let { toMount: e } = this.#r.update(this.#E, this.#T.length), t = [];
1254
1257
  for (let n of e) {
1255
1258
  let e = this.#T[n];
@@ -1257,86 +1260,91 @@ var q = class {
1257
1260
  }
1258
1261
  this.#t.prefetch(t);
1259
1262
  }
1260
- #pt(e) {
1263
+ #mt(e) {
1261
1264
  let t = this.#T.findIndex((t) => t.left === e || t.right === e);
1262
1265
  return t === -1 ? 0 : t;
1263
1266
  }
1264
- #mt() {
1267
+ #ht() {
1265
1268
  let e = this.#t.pageCount;
1266
1269
  if (!Number.isInteger(e) || e < 1) throw Error(`Zine: source has ${e} pages; a Source must have at least 1 page.`);
1267
1270
  let t = this.#b;
1268
1271
  if (t !== void 0 && (!Number.isInteger(t) || t < 0 || t >= e)) throw Error(`Zine: startPage ${JSON.stringify(t)} is out of range for a ${e}-page book (valid 0..${e - 1}).`);
1269
- let n = this.#Ze();
1270
- this.#h = n === "single", this.#T = i(e, {
1272
+ let n = this.#Qe();
1273
+ this.#h = n === "single", this.#T = a(e, {
1271
1274
  direction: this.#a,
1272
1275
  mode: n
1273
1276
  });
1274
- let r = this.#x ? S(globalThis.location?.hash ?? "") : null;
1275
- this.#D = J(r ?? t ?? 0, 0, e - 1), this.#E = this.#pt(this.#D);
1277
+ let r = this.#x ? C(globalThis.location?.hash ?? "") : null;
1278
+ this.#D = Y(r ?? t ?? 0, 0, e - 1), this.#E = this.#mt(this.#D);
1276
1279
  }
1277
1280
  };
1278
- function J(e, t, n) {
1281
+ function Y(e, t, n) {
1279
1282
  return e < t ? t : e > n ? n : e;
1280
1283
  }
1281
- function Y(e) {
1282
- return e < .5 ? 2 * e * e : 1 - (-2 * e + 2) ** 2 / 2;
1283
- }
1284
1284
  function X(e) {
1285
- return 1 - (1 - Y(e)) ** 1.3;
1285
+ return e < .5 ? 2 * e * e : 1 - (-2 * e + 2) ** 2 / 2;
1286
1286
  }
1287
1287
  function Z(e) {
1288
+ return 1 - (1 - X(e)) ** 1.3;
1289
+ }
1290
+ function Q(e) {
1288
1291
  return e === null ? "null" : Array.isArray(e) ? "array" : typeof e;
1289
1292
  }
1290
- function Q(t, n) {
1291
- if (typeof t != "object" || !t || typeof t.appendChild != "function" || typeof t.addEventListener != "function") throw Error(`Zine: container must be a DOM element; received ${Z(t)}.`);
1292
- if (typeof n != "object" || !n) throw Error("Zine: an options object with a `source` is required.");
1293
- let r = n, i = r.source;
1294
- if (typeof i != "object" || !i || typeof i.get != "function" || typeof i.pageCount != "number") throw Error("Zine: `source` is required and must be a Source, e.g. new ImageSource(urls).");
1295
- let a = r.startPage;
1296
- if (a !== void 0 && (typeof a != "number" || !Number.isInteger(a) || a < 0)) throw Error(`Zine: startPage must be a non-negative integer; got ${JSON.stringify(a)}.`);
1297
- let o = r.direction;
1298
- if (o !== void 0 && o !== "ltr" && o !== "rtl") throw Error(`Zine: direction must be 'ltr' or 'rtl'; got ${JSON.stringify(o)}.`);
1299
- let s = r.clickToFlip;
1300
- if (s !== void 0 && ![
1293
+ function te(n, r) {
1294
+ if (typeof n != "object" || !n || typeof n.appendChild != "function" || typeof n.addEventListener != "function") throw Error(`Zine: container must be a DOM element; received ${Q(n)}.`);
1295
+ if (typeof r != "object" || !r) throw Error("Zine: an options object with a `source` is required.");
1296
+ let i = r, a = i.source;
1297
+ if (typeof a != "object" || !a || typeof a.get != "function" || typeof a.pageCount != "number") throw Error("Zine: `source` is required and must be a Source, e.g. new ImageSource(urls).");
1298
+ let o = i.startPage;
1299
+ if (o !== void 0 && (typeof o != "number" || !Number.isInteger(o) || o < 0)) throw Error(`Zine: startPage must be a non-negative integer; got ${JSON.stringify(o)}.`);
1300
+ let s = i.direction;
1301
+ if (s !== void 0 && s !== "ltr" && s !== "rtl") throw Error(`Zine: direction must be 'ltr' or 'rtl'; got ${JSON.stringify(s)}.`);
1302
+ let c = i.clickToFlip;
1303
+ if (c !== void 0 && ![
1301
1304
  "edge",
1302
1305
  "half",
1303
1306
  "off"
1304
- ].includes(s)) throw Error(`Zine: clickToFlip must be 'edge', 'half', or 'off'; got ${JSON.stringify(s)}.`);
1305
- let c = r.curl;
1306
- if (c !== void 0 && !e.includes(c)) throw Error(`Zine: curl must be one of ${e.join(", ")}; got ${JSON.stringify(c)}.`);
1307
+ ].includes(c)) throw Error(`Zine: clickToFlip must be 'edge', 'half', or 'off'; got ${JSON.stringify(c)}.`);
1308
+ let l = i.curl;
1309
+ if (l !== void 0) {
1310
+ if (typeof l == "object" && l) {
1311
+ if (typeof l.deform != "function") throw Error("Zine: a curl model must have a deform() function.");
1312
+ } else if (e.includes(l)) throw Error(`Zine: the '${String(l)}' curl is not bundled. Import it and pass the model: import { ${String(l)} } from '@zinejs/core/curls' → curl: ${String(l)}`);
1313
+ else if (!t.includes(l)) throw Error(`Zine: curl must be ${t.join(" or ")}, or a model imported from '@zinejs/core/curls' (${e.join(", ")}); got ${JSON.stringify(l)}.`);
1314
+ }
1307
1315
  for (let e of [
1308
1316
  "deepLink",
1309
1317
  "disableContextMenu",
1310
1318
  "responsiveSpread"
1311
- ]) if (r[e] !== void 0 && typeof r[e] != "boolean") throw Error(`Zine: ${e} must be a boolean; got ${Z(r[e])}.`);
1312
- let l = r.controls;
1313
- if (l !== void 0 && typeof l != "boolean" && (typeof l != "object" || !l)) throw Error(`Zine: controls must be a boolean or an options object; got ${Z(l)}.`);
1314
- let u = l?.position;
1315
- if (u !== void 0 && ![
1319
+ ]) if (i[e] !== void 0 && typeof i[e] != "boolean") throw Error(`Zine: ${e} must be a boolean; got ${Q(i[e])}.`);
1320
+ let u = i.controls;
1321
+ if (u !== void 0 && typeof u != "boolean" && (typeof u != "object" || !u)) throw Error(`Zine: controls must be a boolean or an options object; got ${Q(u)}.`);
1322
+ let d = u?.position;
1323
+ if (d !== void 0 && ![
1316
1324
  "top",
1317
1325
  "bottom",
1318
1326
  "left",
1319
1327
  "right"
1320
- ].includes(u)) throw Error(`Zine: controls.position must be 'top', 'bottom', 'left', or 'right'; got ${JSON.stringify(u)}.`);
1321
- let d = r.spreadMode;
1322
- if (d !== void 0 && ![
1328
+ ].includes(d)) throw Error(`Zine: controls.position must be 'top', 'bottom', 'left', or 'right'; got ${JSON.stringify(d)}.`);
1329
+ let f = i.spreadMode;
1330
+ if (f !== void 0 && ![
1323
1331
  "double",
1324
1332
  "single",
1325
1333
  "cover",
1326
1334
  "book"
1327
- ].includes(d)) throw Error(`Zine: spreadMode must be 'double', 'single', 'cover', or 'book'; got ${JSON.stringify(d)}.`);
1335
+ ].includes(f)) throw Error(`Zine: spreadMode must be 'double', 'single', 'cover', or 'book'; got ${JSON.stringify(f)}.`);
1328
1336
  for (let e of ["frontCover", "backCover"]) {
1329
- let t = r[e];
1337
+ let t = i[e];
1330
1338
  if (t !== void 0 && typeof t != "string") throw Error(`Zine: ${e} must be an image URL string; got ${JSON.stringify(t)}.`);
1331
1339
  }
1332
- let f = r.pages;
1333
- if (f !== void 0 && (typeof f != "object" || !f || Array.isArray(f))) throw Error("Zine: pages must be an object mapping page indices to image URLs.");
1334
- $(r.width, "width", 1), $(r.height, "height", 1), $(r.flipDuration, "flipDuration", 0), $(r.clickZoneSize, "clickZoneSize", 0), $(r.clickFlipDelay, "clickFlipDelay", 0), $(r.singlePageThreshold, "singlePageThreshold", 0), ee(r.zoom), te(r.renderer);
1340
+ let p = i.pages;
1341
+ if (p !== void 0 && (typeof p != "object" || !p || Array.isArray(p))) throw Error("Zine: pages must be an object mapping page indices to image URLs.");
1342
+ $(i.width, "width", 1), $(i.height, "height", 1), $(i.flipDuration, "flipDuration", 0), $(i.clickZoneSize, "clickZoneSize", 0), $(i.clickFlipDelay, "clickFlipDelay", 0), $(i.singlePageThreshold, "singlePageThreshold", 0), ne(i.zoom), re(i.renderer);
1335
1343
  }
1336
1344
  function $(e, t, n) {
1337
1345
  if (e !== void 0 && (typeof e != "number" || !Number.isFinite(e) || e < n)) throw Error(`Zine: ${t} must be a number >= ${n}; got ${JSON.stringify(e)}.`);
1338
1346
  }
1339
- function ee(e) {
1347
+ function ne(e) {
1340
1348
  if (e === void 0) return;
1341
1349
  if (typeof e != "object" || !e || Array.isArray(e)) throw Error("Zine: zoom must be an object, e.g. { max: 4 }.");
1342
1350
  let t = e;
@@ -1349,7 +1357,7 @@ function ee(e) {
1349
1357
  }
1350
1358
  $(t.max, "zoom.max", 1);
1351
1359
  }
1352
- function te(e) {
1360
+ function re(e) {
1353
1361
  if (e !== void 0) {
1354
1362
  if (typeof e == "string") {
1355
1363
  if (e !== "auto" && e !== "css" && e !== "webgl2") throw Error(`Zine: renderer '${e}' is not recognized; use 'auto', 'css', 'webgl2', an array of those, or a custom Renderer.`);
@@ -1364,7 +1372,7 @@ function te(e) {
1364
1372
  }
1365
1373
  //#endregion
1366
1374
  //#region src/source/imageSource.ts
1367
- var ne = class {
1375
+ var ie = class {
1368
1376
  pageCount;
1369
1377
  fit;
1370
1378
  #e;
@@ -1401,6 +1409,6 @@ var ne = class {
1401
1409
  }
1402
1410
  };
1403
1411
  //#endregion
1404
- export { e as CURL_TYPES, r as DEFAULT_ITEMS, ne as ImageSource, q as Zine, t as defineControl, n as getControl };
1412
+ export { t as CURL_TYPES, i as DEFAULT_ITEMS, e as IMPORTABLE_CURLS, ie as ImageSource, J as Zine, n as defineControl, r as getControl };
1405
1413
 
1406
1414
  //# sourceMappingURL=index.js.map