@zinejs/core 0.6.0 → 0.7.1
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/bundled-Cp43MIt0.js +100 -0
- package/dist/bundled-Cp43MIt0.js.map +1 -0
- package/dist/{cssRenderer-OzRRoEa4.js → cssRenderer-Deskm2ND.js} +9 -3
- package/dist/{cssRenderer-OzRRoEa4.js.map → cssRenderer-Deskm2ND.js.map} +1 -1
- package/dist/curls.js +133 -0
- package/dist/curls.js.map +1 -0
- package/dist/geometry/curls/bundled.d.ts +16 -0
- package/dist/geometry/curls/index.d.ts +8 -4
- package/dist/geometry/curls/types.d.ts +23 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +227 -296
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +6 -6
- package/dist/index.umd.js.map +1 -1
- package/dist/renderer/types.d.ts +17 -2
- package/dist/types-DEz3mRLI.js +11 -0
- package/dist/types-DEz3mRLI.js.map +1 -0
- package/dist/{webglRenderer-BK-ArG1G.js → webglRenderer-D_XGumQT.js} +44 -250
- package/dist/webglRenderer-D_XGumQT.js.map +1 -0
- package/dist/zine.d.ts +15 -3
- package/options.schema.json +2 -2
- package/package.json +12 -2
- package/dist/engine/zoomTile.d.ts +0 -65
- package/dist/types-CcPVyhOJ.js +0 -13
- package/dist/types-CcPVyhOJ.js.map +0 -1
- package/dist/webglRenderer-BK-ArG1G.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n
|
|
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
|
|
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
|
|
43
|
+
function o(e, t) {
|
|
44
44
|
return e < t;
|
|
45
45
|
}
|
|
46
46
|
//#endregion
|
|
47
47
|
//#region src/engine/virtualizer.ts
|
|
48
|
-
function
|
|
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
|
|
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(
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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
|
|
98
|
-
return
|
|
97
|
+
function d(e, t) {
|
|
98
|
+
return u[e][t] ?? null;
|
|
99
99
|
}
|
|
100
|
-
var
|
|
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 =
|
|
109
|
+
let t = d(this.#e, e);
|
|
110
110
|
return t !== null && (this.#e = t), t;
|
|
111
111
|
}
|
|
112
|
-
},
|
|
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 >
|
|
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
|
|
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
|
|
193
|
+
function g(e, t) {
|
|
194
194
|
return Math.hypot(e.x - t.x, e.y - t.y);
|
|
195
195
|
}
|
|
196
|
-
var
|
|
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 =
|
|
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 ?
|
|
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
|
|
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
|
|
259
|
-
function b() {
|
|
260
|
-
return y ? !1 : (y = !0, !0);
|
|
261
|
-
}
|
|
258
|
+
var y = "page", b = !1;
|
|
262
259
|
function x() {
|
|
263
|
-
|
|
260
|
+
return b ? !1 : (b = !0, !0);
|
|
264
261
|
}
|
|
265
|
-
function S(
|
|
266
|
-
|
|
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
|
|
271
|
+
function w(e, t) {
|
|
272
272
|
let n = new URLSearchParams(e.replace(/^#/, ""));
|
|
273
|
-
return n.set(
|
|
273
|
+
return n.set(y, String(t + 1)), `#${n.toString()}`;
|
|
274
274
|
}
|
|
275
|
-
function
|
|
275
|
+
function T(e, t) {
|
|
276
276
|
let n = null, r = () => {
|
|
277
|
-
let r =
|
|
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 =
|
|
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,127 +291,49 @@ function w(e, t) {
|
|
|
291
291
|
}
|
|
292
292
|
//#endregion
|
|
293
293
|
//#region src/renderer/select.ts
|
|
294
|
-
var
|
|
295
|
-
css: async () => new (await (import("./cssRenderer-
|
|
296
|
-
webgl2: async () => new (await (import("./webglRenderer-
|
|
297
|
-
},
|
|
298
|
-
function D(e) {
|
|
299
|
-
return typeof e == "object" && !!e && !Array.isArray(e) && typeof e.mount == "function";
|
|
300
|
-
}
|
|
294
|
+
var E = {
|
|
295
|
+
css: async () => new (await (import("./cssRenderer-Deskm2ND.js"))).CssRenderer(),
|
|
296
|
+
webgl2: async () => new (await (import("./webglRenderer-D_XGumQT.js"))).WebglRenderer()
|
|
297
|
+
}, D = !0;
|
|
301
298
|
function O(e) {
|
|
302
|
-
return e
|
|
299
|
+
return typeof e == "object" && !!e && !Array.isArray(e) && typeof e.mount == "function";
|
|
303
300
|
}
|
|
304
|
-
function k() {
|
|
305
|
-
return
|
|
301
|
+
function k(e) {
|
|
302
|
+
return e.gpu && D ? ["webgl2", "css"] : ["css"];
|
|
306
303
|
}
|
|
307
304
|
function A() {
|
|
305
|
+
return { gpu: j() };
|
|
306
|
+
}
|
|
307
|
+
function j() {
|
|
308
308
|
try {
|
|
309
309
|
return !!document.createElement("canvas").getContext("webgl2");
|
|
310
310
|
} catch {
|
|
311
311
|
return !1;
|
|
312
312
|
}
|
|
313
313
|
}
|
|
314
|
-
async function
|
|
315
|
-
if (
|
|
316
|
-
let n = Array.isArray(e) ? e : e === "auto" ?
|
|
314
|
+
async function M(e = "auto", t = A()) {
|
|
315
|
+
if (O(e)) return e;
|
|
316
|
+
let n = Array.isArray(e) ? e : e === "auto" ? k(t) : [e];
|
|
317
317
|
for (let e of n) {
|
|
318
318
|
if (e === "webgl2" && !t.gpu) continue;
|
|
319
|
-
let n =
|
|
319
|
+
let n = E[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'.`);
|
|
323
323
|
}
|
|
324
324
|
//#endregion
|
|
325
|
-
//#region src/engine/zoomTile.ts
|
|
326
|
-
function M(e, t) {
|
|
327
|
-
let n = Math.max(e.x, t.x), r = Math.max(e.y, t.y), i = Math.min(e.x + e.width, t.x + t.width), a = Math.min(e.y + e.height, t.y + t.height);
|
|
328
|
-
return i <= n || a <= r ? null : {
|
|
329
|
-
x: n,
|
|
330
|
-
y: r,
|
|
331
|
-
width: i - n,
|
|
332
|
-
height: a - r
|
|
333
|
-
};
|
|
334
|
-
}
|
|
335
|
-
function N(e, t, n) {
|
|
336
|
-
let { scale: r, tx: i, ty: a } = t;
|
|
337
|
-
if (r <= 1) return [];
|
|
338
|
-
let o = {
|
|
339
|
-
x: (n.x - i) / r,
|
|
340
|
-
y: (n.y - a) / r,
|
|
341
|
-
width: n.width / r,
|
|
342
|
-
height: n.height / r
|
|
343
|
-
}, s = [];
|
|
344
|
-
for (let t of e) {
|
|
345
|
-
let e = M(t.rect, o);
|
|
346
|
-
!e || t.rect.width <= 0 || t.rect.height <= 0 || s.push({
|
|
347
|
-
index: t.index,
|
|
348
|
-
request: {
|
|
349
|
-
scale: r,
|
|
350
|
-
region: {
|
|
351
|
-
x: (e.x - t.rect.x) / t.rect.width,
|
|
352
|
-
y: (e.y - t.rect.y) / t.rect.height,
|
|
353
|
-
width: e.width / t.rect.width,
|
|
354
|
-
height: e.height / t.rect.height
|
|
355
|
-
}
|
|
356
|
-
},
|
|
357
|
-
dest: e
|
|
358
|
-
});
|
|
359
|
-
}
|
|
360
|
-
return s;
|
|
361
|
-
}
|
|
362
|
-
function P(e, t) {
|
|
363
|
-
if (e.index !== t.index || e.request.scale !== t.request.scale) return !1;
|
|
364
|
-
let n = e.request.region, r = t.request.region, i = 1e-4;
|
|
365
|
-
return Math.abs(n.x - r.x) < i && Math.abs(n.y - r.y) < i && Math.abs(n.width - r.width) < i && Math.abs(n.height - r.height) < i;
|
|
366
|
-
}
|
|
367
|
-
var F = class {
|
|
368
|
-
#e;
|
|
369
|
-
#t;
|
|
370
|
-
#n = [];
|
|
371
|
-
constructor(e, t) {
|
|
372
|
-
this.#e = e.createElement("canvas"), this.#e.className = "zine-zoom-overlay", this.#e.style.cssText = "position:absolute;inset:0;pointer-events:none;opacity:0;transition:opacity 120ms linear;", t.append(this.#e), this.#t = this.#e.getContext("2d");
|
|
373
|
-
}
|
|
374
|
-
clear() {
|
|
375
|
-
if (this.#n.length === 0) return;
|
|
376
|
-
this.#n = [], this.#e.style.opacity = "0";
|
|
377
|
-
let e = this.#t;
|
|
378
|
-
e && e.clearRect(0, 0, this.#e.width, this.#e.height);
|
|
379
|
-
}
|
|
380
|
-
get shown() {
|
|
381
|
-
return this.#n;
|
|
382
|
-
}
|
|
383
|
-
draw(e, t, n) {
|
|
384
|
-
let r = this.#t;
|
|
385
|
-
if (!r) return;
|
|
386
|
-
if (e.length === 0) {
|
|
387
|
-
this.clear();
|
|
388
|
-
return;
|
|
389
|
-
}
|
|
390
|
-
let i = typeof devicePixelRatio == "number" ? devicePixelRatio : 1, a = Math.max(1, Math.ceil(n.width * i)), o = Math.max(1, Math.ceil(n.height * i));
|
|
391
|
-
(this.#e.width !== a || this.#e.height !== o) && (this.#e.width = a, this.#e.height = o), r.setTransform(i, 0, 0, i, 0, 0), r.clearRect(0, 0, n.width, n.height), r.translate(t.tx, t.ty), r.scale(t.scale, t.scale);
|
|
392
|
-
for (let { plan: t, content: n } of e) {
|
|
393
|
-
let e = t.dest;
|
|
394
|
-
r.drawImage(n, e.x, e.y, e.width, e.height);
|
|
395
|
-
}
|
|
396
|
-
this.#n = e.map((e) => e.plan), this.#e.style.opacity = "1";
|
|
397
|
-
}
|
|
398
|
-
destroy() {
|
|
399
|
-
this.#e.remove(), this.#t = null;
|
|
400
|
-
}
|
|
401
|
-
};
|
|
402
|
-
//#endregion
|
|
403
325
|
//#region src/source/compose.ts
|
|
404
|
-
function
|
|
326
|
+
function N(e, t) {
|
|
405
327
|
let n = typeof t.frontCover == "string", r = typeof t.backCover == "string", i = t.pages != null && Object.keys(t.pages).length > 0;
|
|
406
|
-
return !n && !r && !i ? e : new
|
|
328
|
+
return !n && !r && !i ? e : new F(e, t);
|
|
407
329
|
}
|
|
408
|
-
function
|
|
330
|
+
function P(e) {
|
|
409
331
|
return fetch(e).then((t) => {
|
|
410
332
|
if (!t.ok) throw Error(`zine: could not load image "${e}" (HTTP ${t.status}).`);
|
|
411
333
|
return t.blob();
|
|
412
334
|
}).then((e) => createImageBitmap(e));
|
|
413
335
|
}
|
|
414
|
-
var
|
|
336
|
+
var F = class {
|
|
415
337
|
#e;
|
|
416
338
|
#t;
|
|
417
339
|
#n;
|
|
@@ -479,21 +401,21 @@ var R = class {
|
|
|
479
401
|
}
|
|
480
402
|
#s(e) {
|
|
481
403
|
let t = this.#a.get(e);
|
|
482
|
-
return t === void 0 && (t =
|
|
404
|
+
return t === void 0 && (t = P(e).catch((t) => {
|
|
483
405
|
throw this.#a.delete(e), t;
|
|
484
406
|
}), this.#a.set(e, t)), t;
|
|
485
407
|
}
|
|
486
|
-
},
|
|
487
|
-
function
|
|
488
|
-
let r = Math.max(0, t -
|
|
408
|
+
}, I = .25, L = .0015, R = 6, z = 250, B = 1.55, V = 32, H = 60, U = 2.5, W = 120;
|
|
409
|
+
function G(e, t, n) {
|
|
410
|
+
let r = Math.max(0, t - V), i = Math.min(e.length, t + n + V), a = e.slice(r, i).replace(/\s+/g, " ").trim();
|
|
489
411
|
return `${r > 0 ? "…" : ""}${a}${i < e.length ? "…" : ""}`;
|
|
490
412
|
}
|
|
491
|
-
var
|
|
413
|
+
var K = class {
|
|
492
414
|
#e;
|
|
493
415
|
#t;
|
|
494
|
-
#n = new
|
|
495
|
-
#r = new
|
|
496
|
-
#i = new
|
|
416
|
+
#n = new l();
|
|
417
|
+
#r = new c(2);
|
|
418
|
+
#i = new f();
|
|
497
419
|
#a;
|
|
498
420
|
#o;
|
|
499
421
|
#s;
|
|
@@ -556,7 +478,7 @@ var q = class {
|
|
|
556
478
|
#se = /* @__PURE__ */ new Set();
|
|
557
479
|
#ce;
|
|
558
480
|
#le = null;
|
|
559
|
-
#ue =
|
|
481
|
+
#ue = 1;
|
|
560
482
|
#de = 0;
|
|
561
483
|
#fe = null;
|
|
562
484
|
#pe;
|
|
@@ -564,13 +486,13 @@ var q = class {
|
|
|
564
486
|
this.#z?.setFlipProgress(e, t);
|
|
565
487
|
} };
|
|
566
488
|
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 =
|
|
489
|
+
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 = N(t.source, {
|
|
568
490
|
frontCover: t.frontCover,
|
|
569
491
|
backCover: t.backCover,
|
|
570
492
|
pages: t.pages
|
|
571
493
|
});
|
|
572
494
|
let n = t.direction ?? "ltr";
|
|
573
|
-
this.#a = n, this.#x = (t.deepLink ?? !0) &&
|
|
495
|
+
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
496
|
let r = t.zoom?.doubleClick, i = r === !1 ? [] : [...r ?? [
|
|
575
497
|
1,
|
|
576
498
|
2,
|
|
@@ -578,7 +500,7 @@ var q = class {
|
|
|
578
500
|
]].sort((e, t) => e - t);
|
|
579
501
|
this.#M = i.length > 0 ? i : null, this.#N = t.zoom?.max ?? 4;
|
|
580
502
|
let a = this.#A && this.#M !== null, o = t.zoom?.doubleClickInFlipZone ?? this.#u === "half";
|
|
581
|
-
this.#f = this.#u !== "off" && a && o && t.clickFlipDelay !== 0, this.#p = this.#f ? t.clickFlipDelay ??
|
|
503
|
+
this.#f = this.#u !== "off" && a && o && t.clickFlipDelay !== 0, this.#p = this.#f ? t.clickFlipDelay ?? z : 0, this.#pe = this.#Ve(t.renderer ?? "auto");
|
|
582
504
|
}
|
|
583
505
|
get ready() {
|
|
584
506
|
return this.#pe;
|
|
@@ -608,7 +530,7 @@ var q = class {
|
|
|
608
530
|
return this.#h;
|
|
609
531
|
}
|
|
610
532
|
setSpreadMode(e) {
|
|
611
|
-
e !== this.#o && (this.#o = e, this.#_ = !1, this
|
|
533
|
+
e !== this.#o && (this.#o = e, this.#_ = !1, this.#et(), this.#tt());
|
|
612
534
|
}
|
|
613
535
|
toggleSpreadMode() {
|
|
614
536
|
this.setSpreadMode(this.#o === "single" ? this.#s === "single" ? "double" : this.#s : "single");
|
|
@@ -624,16 +546,16 @@ var q = class {
|
|
|
624
546
|
if (this.#v = e, e) {
|
|
625
547
|
let e = this.#z?.measure().containerWidth;
|
|
626
548
|
if (e === void 0) return;
|
|
627
|
-
this.#_ = !1, this
|
|
549
|
+
this.#_ = !1, this.#$e(e);
|
|
628
550
|
} else {
|
|
629
551
|
if (!this.#_) return;
|
|
630
|
-
this.#_ = !1, this
|
|
552
|
+
this.#_ = !1, this.#et();
|
|
631
553
|
}
|
|
632
|
-
this.#
|
|
554
|
+
this.#tt();
|
|
633
555
|
}
|
|
634
556
|
}
|
|
635
557
|
getPageImage(e) {
|
|
636
|
-
return this.#
|
|
558
|
+
return this.#ft(e);
|
|
637
559
|
}
|
|
638
560
|
canFlipNext() {
|
|
639
561
|
return this.#E + 1 < this.#T.length;
|
|
@@ -717,7 +639,7 @@ var q = class {
|
|
|
717
639
|
let i = t.toLowerCase().indexOf(r);
|
|
718
640
|
i < 0 || a.push({
|
|
719
641
|
page: e,
|
|
720
|
-
excerpt:
|
|
642
|
+
excerpt: G(t, i, r.length)
|
|
721
643
|
});
|
|
722
644
|
}
|
|
723
645
|
return a;
|
|
@@ -732,8 +654,8 @@ var q = class {
|
|
|
732
654
|
this.#he(() => this.#ye(this.#E + e));
|
|
733
655
|
}
|
|
734
656
|
flipTo(e) {
|
|
735
|
-
let t =
|
|
736
|
-
this.#he(() => this.#ye(this.#
|
|
657
|
+
let t = q(e, 0, Math.max(0, this.#t.pageCount - 1));
|
|
658
|
+
this.#he(() => this.#ye(this.#mt(t)));
|
|
737
659
|
}
|
|
738
660
|
#he(e) {
|
|
739
661
|
this.#i.state === "idle" ? e() : this.#J ? (this.#q = null, this.#ge(), e()) : this.#q = e;
|
|
@@ -745,7 +667,7 @@ var q = class {
|
|
|
745
667
|
#_e() {
|
|
746
668
|
let e = this.#q;
|
|
747
669
|
if (!e) {
|
|
748
|
-
this.#
|
|
670
|
+
this.#ct();
|
|
749
671
|
return;
|
|
750
672
|
}
|
|
751
673
|
this.#q = null, e();
|
|
@@ -755,23 +677,32 @@ var q = class {
|
|
|
755
677
|
}
|
|
756
678
|
setZoom(e, t) {
|
|
757
679
|
if (!this.#z || !this.#A) return;
|
|
758
|
-
let n =
|
|
680
|
+
let n = q(e, 1, this.#N), r = this.#z.measure(), i = r.screenAt?.(this.#I), a = t ?? (i ? {
|
|
681
|
+
x: i.x + this.#L + i.width / 2,
|
|
682
|
+
y: i.y + this.#R + i.height / 2
|
|
683
|
+
} : null) ?? {
|
|
759
684
|
x: r.containerWidth / 2,
|
|
760
685
|
y: r.containerHeight / 2
|
|
761
|
-
},
|
|
762
|
-
[
|
|
686
|
+
}, o = this.#I, s = n === 1 ? 0 : a.x - n / o * (a.x - this.#L), c = n === 1 ? 0 : a.y - n / o * (a.y - this.#R);
|
|
687
|
+
[s, c] = this.#ve(s, c, n, r.containerWidth, r.containerHeight), this.#I = n, this.#L = s, this.#R = c, this.#z.setViewTransform(n, s, c), this.#at(), this.#n.emit("zoomChanged", { scale: n });
|
|
763
688
|
}
|
|
764
689
|
resetZoom() {
|
|
765
690
|
this.setZoom(1);
|
|
766
691
|
}
|
|
767
692
|
#ve(e, t, n, r, i) {
|
|
768
|
-
|
|
693
|
+
let a = typeof devicePixelRatio == "number" && devicePixelRatio > 0 ? devicePixelRatio : 1, o = (e) => Math.round(e * a) / a || 0, s = this.#z?.measure().screenAt?.(n) ?? {
|
|
694
|
+
x: 0,
|
|
695
|
+
y: 0,
|
|
696
|
+
width: r * n,
|
|
697
|
+
height: i * n
|
|
698
|
+
}, [c, l] = J(s.x, s.width, r), [u, d] = J(s.y, s.height, i);
|
|
699
|
+
return [o(q(e, c, l)), o(q(t, u, d))];
|
|
769
700
|
}
|
|
770
701
|
on(e, t) {
|
|
771
702
|
return this.#n.on(e, t);
|
|
772
703
|
}
|
|
773
704
|
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 &&
|
|
705
|
+
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.#z?.destroy(), this.#z = null, this.#t.destroy(), this.#n.clear();
|
|
775
706
|
}
|
|
776
707
|
#ye(e) {
|
|
777
708
|
if (e < 0 || e >= this.#T.length || e === this.#E || this.#i.send("flip") === null) return;
|
|
@@ -782,13 +713,13 @@ var q = class {
|
|
|
782
713
|
}), this.#be(e, t, n, ++this.#Y);
|
|
783
714
|
}
|
|
784
715
|
async #be(e, t, n, r) {
|
|
785
|
-
let i = this.#T[e], a = i ? await this.#
|
|
716
|
+
let i = this.#T[e], a = i ? await this.#dt(i) : {
|
|
786
717
|
left: null,
|
|
787
718
|
right: null
|
|
788
719
|
};
|
|
789
720
|
r === this.#Y && (this.#z?.beginFlip(this.#O, a, t, {
|
|
790
721
|
fill: this.#h,
|
|
791
|
-
curl: this.#
|
|
722
|
+
curl: this.#Ze(),
|
|
792
723
|
anchor: { y: this.#l }
|
|
793
724
|
}), this.#xe(0, 1, t, () => this.#Se(e, n, a)));
|
|
794
725
|
}
|
|
@@ -813,7 +744,7 @@ var q = class {
|
|
|
813
744
|
}
|
|
814
745
|
#Se(e, t, n) {
|
|
815
746
|
let r = this.#T[e];
|
|
816
|
-
this.#E = e, this.#D = t, this.#O = n, r && this.#
|
|
747
|
+
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
748
|
}
|
|
818
749
|
#Ce(e) {
|
|
819
750
|
let t = this.#T[e];
|
|
@@ -836,12 +767,12 @@ var q = class {
|
|
|
836
767
|
this.#W = null;
|
|
837
768
|
return;
|
|
838
769
|
}
|
|
839
|
-
let i = Math.min(n.width, n.height) *
|
|
840
|
-
if (
|
|
770
|
+
let i = Math.min(n.width, n.height) * I;
|
|
771
|
+
if (v(r, {
|
|
841
772
|
width: n.width,
|
|
842
773
|
height: n.height
|
|
843
774
|
}, i) !== "corner") return;
|
|
844
|
-
this.#l =
|
|
775
|
+
this.#l = q(r.y / n.height, 0, 1);
|
|
845
776
|
let a = r.x > n.width / 2, o = this.#a === "rtl" ? !a : a, s = this.#E + (o ? 1 : -1);
|
|
846
777
|
s < 0 || s >= this.#T.length || (this.#W = {
|
|
847
778
|
direction: o ? "forward" : "backward",
|
|
@@ -868,13 +799,13 @@ var q = class {
|
|
|
868
799
|
}), this.#Ee(e.targetIndex, e.direction)));
|
|
869
800
|
}
|
|
870
801
|
async #Ee(e, t) {
|
|
871
|
-
let n = this.#T[e], r = n ? await this.#
|
|
802
|
+
let n = this.#T[e], r = n ? await this.#dt(n) : {
|
|
872
803
|
left: null,
|
|
873
804
|
right: null
|
|
874
805
|
};
|
|
875
806
|
this.#U?.targetIndex === e && (this.#U.toContent = r, this.#z?.beginFlip(this.#O, r, t, {
|
|
876
807
|
fill: this.#h,
|
|
877
|
-
curl: this.#
|
|
808
|
+
curl: this.#Ze(),
|
|
878
809
|
anchor: { y: this.#l }
|
|
879
810
|
}), this.#z?.setFlipProgress(this.#U.t, t));
|
|
880
811
|
}
|
|
@@ -883,12 +814,12 @@ var q = class {
|
|
|
883
814
|
if (this.#X) {
|
|
884
815
|
if (!this.#z) return;
|
|
885
816
|
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.#
|
|
817
|
+
this.#L = r, this.#R = i, this.#z.setViewTransform(this.#I, r, i), this.#at();
|
|
887
818
|
return;
|
|
888
819
|
}
|
|
889
|
-
this.#W && Math.hypot(e, t) >
|
|
820
|
+
this.#W && Math.hypot(e, t) > R && this.#Te();
|
|
890
821
|
let n = this.#U;
|
|
891
|
-
n && (n.t =
|
|
822
|
+
n && (n.t = q((n.direction === "forward" ? -e : e) / n.width, 0, 1), this.#z?.setFlipProgress(n.t, n.direction));
|
|
892
823
|
}
|
|
893
824
|
#Oe(e) {
|
|
894
825
|
if (this.#Z) return;
|
|
@@ -906,12 +837,12 @@ var q = class {
|
|
|
906
837
|
t.t >= .5 || n ? this.#xe(t.t, 1, t.direction, () => this.#Se(t.targetIndex, t.toPage, t.toContent)) : this.#xe(t.t, 0, t.direction, () => this.#Pe());
|
|
907
838
|
}
|
|
908
839
|
#ke(e) {
|
|
909
|
-
if (this.#u === "off" || this.#I > 1 || !this.#G || Math.abs(e.dx) >
|
|
840
|
+
if (this.#u === "off" || this.#I > 1 || !this.#G || Math.abs(e.dx) > R || Math.abs(e.dy) > R) return;
|
|
910
841
|
let t = this.#Me(this.#G);
|
|
911
842
|
if (!t) return;
|
|
912
843
|
let n = t === "forward" ? 1 : -1;
|
|
913
844
|
if (this.#E + n < 0 || this.#E + n >= this.#T.length) return;
|
|
914
|
-
this.#l =
|
|
845
|
+
this.#l = q(this.#G.y / this.#Ae().height, 0, 1);
|
|
915
846
|
let r = () => this.#ye(this.#E + n);
|
|
916
847
|
if (this.#Ne(), this.#p <= 0) {
|
|
917
848
|
this.#he(r);
|
|
@@ -949,13 +880,13 @@ var q = class {
|
|
|
949
880
|
}
|
|
950
881
|
#Pe() {
|
|
951
882
|
let e = this.#T[this.#E];
|
|
952
|
-
e && this.#
|
|
883
|
+
e && this.#nt(e, this.#O), this.#i.send("settle"), this.#n.emit("flipEnd", { page: this.#D }), this.#_e();
|
|
953
884
|
}
|
|
954
885
|
#Fe() {
|
|
955
886
|
if (this.#W = null, this.#Ne(), this.#U) {
|
|
956
887
|
this.#U = null, this.#i.send("release"), this.#i.send("settle");
|
|
957
888
|
let e = this.#T[this.#E];
|
|
958
|
-
e && this.#
|
|
889
|
+
e && this.#nt(e, this.#O);
|
|
959
890
|
} else this.#X && (this.#X = null, this.#i.send("panEnd"));
|
|
960
891
|
this.#Z = !0, this.#Q = this.#I;
|
|
961
892
|
}
|
|
@@ -979,7 +910,7 @@ var q = class {
|
|
|
979
910
|
let e = (e) => {
|
|
980
911
|
if (!this.#j || !this.#A || !(e.ctrlKey || e.metaKey)) return;
|
|
981
912
|
e.preventDefault();
|
|
982
|
-
let t = this.#e.getBoundingClientRect(), n = Math.exp(-e.deltaY *
|
|
913
|
+
let t = this.#e.getBoundingClientRect(), n = Math.exp(-e.deltaY * L);
|
|
983
914
|
this.setZoom(this.#I * n, {
|
|
984
915
|
x: e.clientX - t.left,
|
|
985
916
|
y: e.clientY - t.top
|
|
@@ -1005,23 +936,23 @@ var q = class {
|
|
|
1005
936
|
this.#e.addEventListener("dblclick", e), this.#ie = () => this.#e.removeEventListener("dblclick", e);
|
|
1006
937
|
}
|
|
1007
938
|
async #Ve(e) {
|
|
1008
|
-
let t =
|
|
1009
|
-
typeof this.#t.open == "function" && (await this.#t.open(), this.#
|
|
939
|
+
let t = M(e);
|
|
940
|
+
typeof this.#t.open == "function" && (await this.#t.open(), this.#ht()), this.#t.prefetch([this.#D]);
|
|
1010
941
|
let n = await t, r = await this.#He(n);
|
|
1011
|
-
this.#z = r, this.#t.onPageUpdate?.((e) => this.#
|
|
1012
|
-
let i = new
|
|
942
|
+
this.#z = r, this.#t.onPageUpdate?.((e) => this.#it(e)), this.#$e(r.measure().containerWidth);
|
|
943
|
+
let i = new m({
|
|
1013
944
|
onStart: (e) => this.#we(e.x, e.y),
|
|
1014
945
|
onMove: (e) => this.#De(e.dx, e.dy),
|
|
1015
946
|
onEnd: (e) => this.#Oe(e)
|
|
1016
|
-
}), a = new
|
|
947
|
+
}), a = new _({
|
|
1017
948
|
onPinchStart: () => this.#Fe(),
|
|
1018
949
|
onPinchMove: (e) => this.#Ie(e.centerX, e.centerY, e.scale),
|
|
1019
950
|
onPinchEnd: () => this.#Le()
|
|
1020
951
|
});
|
|
1021
|
-
this.#te =
|
|
952
|
+
this.#te = h(this.#e, {
|
|
1022
953
|
pointer: i,
|
|
1023
954
|
pinch: a
|
|
1024
|
-
}), this.#ze(), this.#Be(), this.#Re(), this.#We(), this.#ae = this.#qe(), await this.#
|
|
955
|
+
}), 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
956
|
}
|
|
1026
957
|
async #He(e) {
|
|
1027
958
|
try {
|
|
@@ -1030,7 +961,7 @@ var q = class {
|
|
|
1030
961
|
}), e;
|
|
1031
962
|
} catch {
|
|
1032
963
|
e.destroy();
|
|
1033
|
-
let t = await
|
|
964
|
+
let t = await M("css");
|
|
1034
965
|
return await t.mount(this.#e), this.#B = !0, this.#n.emit("rendererFallback", {
|
|
1035
966
|
from: "webgl2",
|
|
1036
967
|
to: "css"
|
|
@@ -1040,12 +971,12 @@ var q = class {
|
|
|
1040
971
|
async #Ue() {
|
|
1041
972
|
if (this.#B || this.#V) return;
|
|
1042
973
|
this.#B = !0, this.#z?.destroy(), this.#z = null;
|
|
1043
|
-
let e = await
|
|
974
|
+
let e = await M("css");
|
|
1044
975
|
if (this.#V) {
|
|
1045
976
|
e.destroy();
|
|
1046
977
|
return;
|
|
1047
978
|
}
|
|
1048
|
-
await e.mount(this.#e), this.#z = e, this
|
|
979
|
+
await e.mount(this.#e), this.#z = e, this.#$e(e.measure().containerWidth), await this.#tt(), this.#n.emit("rendererFallback", {
|
|
1049
980
|
from: "webgl2",
|
|
1050
981
|
to: "css"
|
|
1051
982
|
});
|
|
@@ -1070,7 +1001,7 @@ var q = class {
|
|
|
1070
1001
|
#Ke() {
|
|
1071
1002
|
if (!this.#x || globalThis.location === void 0) return;
|
|
1072
1003
|
let e = globalThis;
|
|
1073
|
-
this.#C =
|
|
1004
|
+
this.#C = T(e, (e) => {
|
|
1074
1005
|
e !== this.#D && this.flipTo(e);
|
|
1075
1006
|
}), this.#C.push(this.#D), this.#w = this.#n.on("pageChanged", ({ page: e }) => {
|
|
1076
1007
|
this.#C?.push(e);
|
|
@@ -1080,7 +1011,7 @@ var q = class {
|
|
|
1080
1011
|
let t = globalThis.location?.href ?? "";
|
|
1081
1012
|
if (!t) return "";
|
|
1082
1013
|
let n = new URL(t);
|
|
1083
|
-
return n.hash =
|
|
1014
|
+
return n.hash = w(n.hash, q(e, 0, Math.max(0, this.#t.pageCount - 1))), n.toString();
|
|
1084
1015
|
}
|
|
1085
1016
|
#qe() {
|
|
1086
1017
|
let e = this.#e, t = e.ownerDocument;
|
|
@@ -1113,132 +1044,120 @@ var q = class {
|
|
|
1113
1044
|
this.#ee && (this.#ee.textContent = `Page ${this.#D + 1} of ${this.#t.pageCount}`);
|
|
1114
1045
|
}
|
|
1115
1046
|
#Xe() {
|
|
1116
|
-
return this.#$ ?
|
|
1047
|
+
return this.#$ ? W : this.#k * (this.#h ? B : 1);
|
|
1048
|
+
}
|
|
1049
|
+
#Ze() {
|
|
1050
|
+
return this.#$ ? "simple" : this.#c;
|
|
1117
1051
|
}
|
|
1118
1052
|
update() {
|
|
1119
|
-
!this.#z || this.#i.state !== "idle" || (this
|
|
1053
|
+
!this.#z || this.#i.state !== "idle" || (this.#$e(this.#z.measure().containerWidth), this.#tt());
|
|
1120
1054
|
}
|
|
1121
|
-
#
|
|
1055
|
+
#Qe() {
|
|
1122
1056
|
return this.#_ || this.#o === "single" ? "single" : this.#o;
|
|
1123
1057
|
}
|
|
1124
|
-
|
|
1125
|
-
let t = this.#v &&
|
|
1126
|
-
t !== this.#_ && (this.#_ = t, this
|
|
1058
|
+
#$e(e) {
|
|
1059
|
+
let t = this.#v && o(e, this.#m);
|
|
1060
|
+
t !== this.#_ && (this.#_ = t, this.#et());
|
|
1127
1061
|
}
|
|
1128
|
-
|
|
1129
|
-
let e = this.#
|
|
1130
|
-
this.#g = e, this.#h = e === "single", this.#T =
|
|
1062
|
+
#et() {
|
|
1063
|
+
let e = this.#Qe(), t = e !== this.#g;
|
|
1064
|
+
this.#g = e, this.#h = e === "single", this.#T = a(this.#t.pageCount, {
|
|
1131
1065
|
direction: this.#a,
|
|
1132
1066
|
mode: e
|
|
1133
|
-
}), this.#E = this.#
|
|
1067
|
+
}), this.#E = this.#mt(this.#D), t && this.#n.emit("spreadChanged", {
|
|
1134
1068
|
mode: e,
|
|
1135
1069
|
singlePage: this.#h
|
|
1136
1070
|
});
|
|
1137
1071
|
}
|
|
1138
|
-
async #
|
|
1072
|
+
async #tt() {
|
|
1139
1073
|
let e = this.#T[this.#E];
|
|
1140
|
-
!e || !this.#z || (this.#O = await this.#
|
|
1074
|
+
!e || !this.#z || (this.#O = await this.#dt(e), this.#nt(e, this.#O));
|
|
1141
1075
|
}
|
|
1142
|
-
#
|
|
1143
|
-
this.#z?.renderSpread(e, t, { fill: this.#h }), this.#
|
|
1076
|
+
#nt(e, t) {
|
|
1077
|
+
this.#z?.renderSpread(e, t, { fill: this.#h }), this.#rt(), this.#ue = 1, this.#at();
|
|
1144
1078
|
}
|
|
1145
|
-
#
|
|
1079
|
+
#rt() {
|
|
1146
1080
|
let e = this.#z?.measure().book;
|
|
1147
1081
|
if (!e || e.width <= 0 || e.height <= 0) return;
|
|
1148
1082
|
let t = (e.width / e.height).toFixed(4);
|
|
1149
1083
|
t !== this.#y && (this.#y = t, this.#e.style.aspectRatio = t);
|
|
1150
1084
|
}
|
|
1151
|
-
#
|
|
1085
|
+
#it(e) {
|
|
1152
1086
|
if (this.#i.state !== "idle") {
|
|
1153
1087
|
this.#se.add(e);
|
|
1154
1088
|
return;
|
|
1155
1089
|
}
|
|
1156
1090
|
let t = this.#T[this.#E];
|
|
1157
|
-
t && (t.left === e || t.right === e) && this.#
|
|
1158
|
-
}
|
|
1159
|
-
#
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
}, G);
|
|
1167
|
-
}
|
|
1168
|
-
async #at() {
|
|
1169
|
-
let e = this.#z, t = this.#T[this.#E];
|
|
1170
|
-
if (!e || !t || this.#I <= 1) return;
|
|
1171
|
-
let n = e.measure(), r = n.content ?? n.book;
|
|
1172
|
-
if (!r) return;
|
|
1173
|
-
let i = [], a = t.left === null || t.right === null, o = a ? r.width : r.width / 2;
|
|
1174
|
-
t.left !== null && i.push({
|
|
1175
|
-
index: t.left,
|
|
1176
|
-
rect: {
|
|
1177
|
-
...r,
|
|
1178
|
-
width: o
|
|
1091
|
+
t && (t.left === e || t.right === e) && this.#tt();
|
|
1092
|
+
}
|
|
1093
|
+
#at() {
|
|
1094
|
+
this.#fe !== null && clearTimeout(this.#fe);
|
|
1095
|
+
let e = this.#ot();
|
|
1096
|
+
if (e !== this.#ue) {
|
|
1097
|
+
if (e === 1) {
|
|
1098
|
+
this.#de++, this.#ue = 1, this.#tt();
|
|
1099
|
+
return;
|
|
1179
1100
|
}
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1101
|
+
this.#fe = setTimeout(() => {
|
|
1102
|
+
this.#fe = null, this.#st();
|
|
1103
|
+
}, H);
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
#ot() {
|
|
1107
|
+
return this.#I <= 1 ? 1 : Math.min(Math.ceil(this.#I * 2) / 2, U);
|
|
1108
|
+
}
|
|
1109
|
+
async #st() {
|
|
1110
|
+
let e = this.#T[this.#E];
|
|
1111
|
+
if (!this.#z || !e) return;
|
|
1112
|
+
let t = this.#ot();
|
|
1113
|
+
if (t === 1 || t === this.#ue) return;
|
|
1114
|
+
let n = ++this.#de, r = {
|
|
1193
1115
|
x: 0,
|
|
1194
1116
|
y: 0,
|
|
1195
|
-
width:
|
|
1196
|
-
height:
|
|
1197
|
-
},
|
|
1198
|
-
|
|
1199
|
-
let d = ++this.#de, f = await Promise.all(l.map(async (e) => {
|
|
1117
|
+
width: 1,
|
|
1118
|
+
height: 1
|
|
1119
|
+
}, i = await Promise.all([e.left, e.right].map(async (e) => {
|
|
1120
|
+
if (e === null) return null;
|
|
1200
1121
|
try {
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
};
|
|
1122
|
+
return await this.#t.get(e, {
|
|
1123
|
+
scale: t,
|
|
1124
|
+
region: r
|
|
1125
|
+
});
|
|
1206
1126
|
} catch (t) {
|
|
1207
1127
|
return this.#n.emit("sourceError", {
|
|
1208
|
-
index: e
|
|
1128
|
+
index: e,
|
|
1209
1129
|
error: t
|
|
1210
1130
|
}), null;
|
|
1211
1131
|
}
|
|
1212
1132
|
}));
|
|
1213
|
-
if (
|
|
1214
|
-
let
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
return !e || typeof this.#e.append != "function" ? null : new F(e, this.#e);
|
|
1133
|
+
if (n !== this.#de || this.#ot() !== t) return;
|
|
1134
|
+
let a = i[0] ?? null, o = i[1] ?? null;
|
|
1135
|
+
a === this.#O.left && o === this.#O.right || (this.#ue = t, this.#O = {
|
|
1136
|
+
left: a,
|
|
1137
|
+
right: o
|
|
1138
|
+
}, this.#z.renderSpread(e, this.#O, { fill: this.#h }));
|
|
1220
1139
|
}
|
|
1221
|
-
#
|
|
1140
|
+
#ct() {
|
|
1222
1141
|
if (this.#se.size === 0) return;
|
|
1223
1142
|
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.#
|
|
1225
|
-
}
|
|
1226
|
-
#ct() {
|
|
1227
|
-
typeof ResizeObserver > "u" || (this.#P = new ResizeObserver(() => this.#lt()), this.#P.observe(this.#e));
|
|
1143
|
+
this.#se.clear(), t && this.#tt();
|
|
1228
1144
|
}
|
|
1229
1145
|
#lt() {
|
|
1146
|
+
typeof ResizeObserver > "u" || (this.#P = new ResizeObserver(() => this.#ut()), this.#P.observe(this.#e));
|
|
1147
|
+
}
|
|
1148
|
+
#ut() {
|
|
1230
1149
|
this.#F || (this.#F = !0, requestAnimationFrame(() => {
|
|
1231
1150
|
this.#F = !1, this.update();
|
|
1232
1151
|
}));
|
|
1233
1152
|
}
|
|
1234
|
-
async #
|
|
1235
|
-
let [t, n] = await Promise.all([this.#
|
|
1153
|
+
async #dt(e) {
|
|
1154
|
+
let [t, n] = await Promise.all([this.#ft(e.left), this.#ft(e.right)]);
|
|
1236
1155
|
return {
|
|
1237
1156
|
left: t,
|
|
1238
1157
|
right: n
|
|
1239
1158
|
};
|
|
1240
1159
|
}
|
|
1241
|
-
async #
|
|
1160
|
+
async #ft(e) {
|
|
1242
1161
|
if (e === null) return null;
|
|
1243
1162
|
try {
|
|
1244
1163
|
return await this.#t.get(e);
|
|
@@ -1249,7 +1168,7 @@ var q = class {
|
|
|
1249
1168
|
}), null;
|
|
1250
1169
|
}
|
|
1251
1170
|
}
|
|
1252
|
-
#
|
|
1171
|
+
#pt() {
|
|
1253
1172
|
let { toMount: e } = this.#r.update(this.#E, this.#T.length), t = [];
|
|
1254
1173
|
for (let n of e) {
|
|
1255
1174
|
let e = this.#T[n];
|
|
@@ -1257,27 +1176,34 @@ var q = class {
|
|
|
1257
1176
|
}
|
|
1258
1177
|
this.#t.prefetch(t);
|
|
1259
1178
|
}
|
|
1260
|
-
#
|
|
1179
|
+
#mt(e) {
|
|
1261
1180
|
let t = this.#T.findIndex((t) => t.left === e || t.right === e);
|
|
1262
1181
|
return t === -1 ? 0 : t;
|
|
1263
1182
|
}
|
|
1264
|
-
#
|
|
1183
|
+
#ht() {
|
|
1265
1184
|
let e = this.#t.pageCount;
|
|
1266
1185
|
if (!Number.isInteger(e) || e < 1) throw Error(`Zine: source has ${e} pages; a Source must have at least 1 page.`);
|
|
1267
1186
|
let t = this.#b;
|
|
1268
1187
|
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.#
|
|
1270
|
-
this.#h = n === "single", this.#T =
|
|
1188
|
+
let n = this.#Qe();
|
|
1189
|
+
this.#h = n === "single", this.#T = a(e, {
|
|
1271
1190
|
direction: this.#a,
|
|
1272
1191
|
mode: n
|
|
1273
1192
|
});
|
|
1274
|
-
let r = this.#x ?
|
|
1275
|
-
this.#D =
|
|
1193
|
+
let r = this.#x ? C(globalThis.location?.hash ?? "") : null;
|
|
1194
|
+
this.#D = q(r ?? t ?? 0, 0, e - 1), this.#E = this.#mt(this.#D);
|
|
1276
1195
|
}
|
|
1277
1196
|
};
|
|
1278
|
-
function
|
|
1197
|
+
function q(e, t, n) {
|
|
1279
1198
|
return e < t ? t : e > n ? n : e;
|
|
1280
1199
|
}
|
|
1200
|
+
function J(e, t, n) {
|
|
1201
|
+
if (t <= n) {
|
|
1202
|
+
let r = (n - t) / 2 - e;
|
|
1203
|
+
return [r, r];
|
|
1204
|
+
}
|
|
1205
|
+
return [n - (e + t), -e];
|
|
1206
|
+
}
|
|
1281
1207
|
function Y(e) {
|
|
1282
1208
|
return e < .5 ? 2 * e * e : 1 - (-2 * e + 2) ** 2 / 2;
|
|
1283
1209
|
}
|
|
@@ -1287,51 +1213,56 @@ function X(e) {
|
|
|
1287
1213
|
function Z(e) {
|
|
1288
1214
|
return e === null ? "null" : Array.isArray(e) ? "array" : typeof e;
|
|
1289
1215
|
}
|
|
1290
|
-
function Q(
|
|
1291
|
-
if (typeof
|
|
1292
|
-
if (typeof
|
|
1293
|
-
let
|
|
1294
|
-
if (typeof
|
|
1295
|
-
let
|
|
1296
|
-
if (
|
|
1297
|
-
let
|
|
1298
|
-
if (
|
|
1299
|
-
let
|
|
1300
|
-
if (
|
|
1216
|
+
function Q(n, r) {
|
|
1217
|
+
if (typeof n != "object" || !n || typeof n.appendChild != "function" || typeof n.addEventListener != "function") throw Error(`Zine: container must be a DOM element; received ${Z(n)}.`);
|
|
1218
|
+
if (typeof r != "object" || !r) throw Error("Zine: an options object with a `source` is required.");
|
|
1219
|
+
let i = r, a = i.source;
|
|
1220
|
+
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).");
|
|
1221
|
+
let o = i.startPage;
|
|
1222
|
+
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)}.`);
|
|
1223
|
+
let s = i.direction;
|
|
1224
|
+
if (s !== void 0 && s !== "ltr" && s !== "rtl") throw Error(`Zine: direction must be 'ltr' or 'rtl'; got ${JSON.stringify(s)}.`);
|
|
1225
|
+
let c = i.clickToFlip;
|
|
1226
|
+
if (c !== void 0 && ![
|
|
1301
1227
|
"edge",
|
|
1302
1228
|
"half",
|
|
1303
1229
|
"off"
|
|
1304
|
-
].includes(
|
|
1305
|
-
let
|
|
1306
|
-
if (
|
|
1230
|
+
].includes(c)) throw Error(`Zine: clickToFlip must be 'edge', 'half', or 'off'; got ${JSON.stringify(c)}.`);
|
|
1231
|
+
let l = i.curl;
|
|
1232
|
+
if (l !== void 0) {
|
|
1233
|
+
if (typeof l == "object" && l) {
|
|
1234
|
+
if (typeof l.deform != "function") throw Error("Zine: a curl model must have a deform() function.");
|
|
1235
|
+
} 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)}`);
|
|
1236
|
+
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)}.`);
|
|
1237
|
+
}
|
|
1307
1238
|
for (let e of [
|
|
1308
1239
|
"deepLink",
|
|
1309
1240
|
"disableContextMenu",
|
|
1310
1241
|
"responsiveSpread"
|
|
1311
|
-
]) if (
|
|
1312
|
-
let
|
|
1313
|
-
if (
|
|
1314
|
-
let
|
|
1315
|
-
if (
|
|
1242
|
+
]) if (i[e] !== void 0 && typeof i[e] != "boolean") throw Error(`Zine: ${e} must be a boolean; got ${Z(i[e])}.`);
|
|
1243
|
+
let u = i.controls;
|
|
1244
|
+
if (u !== void 0 && typeof u != "boolean" && (typeof u != "object" || !u)) throw Error(`Zine: controls must be a boolean or an options object; got ${Z(u)}.`);
|
|
1245
|
+
let d = u?.position;
|
|
1246
|
+
if (d !== void 0 && ![
|
|
1316
1247
|
"top",
|
|
1317
1248
|
"bottom",
|
|
1318
1249
|
"left",
|
|
1319
1250
|
"right"
|
|
1320
|
-
].includes(
|
|
1321
|
-
let
|
|
1322
|
-
if (
|
|
1251
|
+
].includes(d)) throw Error(`Zine: controls.position must be 'top', 'bottom', 'left', or 'right'; got ${JSON.stringify(d)}.`);
|
|
1252
|
+
let f = i.spreadMode;
|
|
1253
|
+
if (f !== void 0 && ![
|
|
1323
1254
|
"double",
|
|
1324
1255
|
"single",
|
|
1325
1256
|
"cover",
|
|
1326
1257
|
"book"
|
|
1327
|
-
].includes(
|
|
1258
|
+
].includes(f)) throw Error(`Zine: spreadMode must be 'double', 'single', 'cover', or 'book'; got ${JSON.stringify(f)}.`);
|
|
1328
1259
|
for (let e of ["frontCover", "backCover"]) {
|
|
1329
|
-
let t =
|
|
1260
|
+
let t = i[e];
|
|
1330
1261
|
if (t !== void 0 && typeof t != "string") throw Error(`Zine: ${e} must be an image URL string; got ${JSON.stringify(t)}.`);
|
|
1331
1262
|
}
|
|
1332
|
-
let
|
|
1333
|
-
if (
|
|
1334
|
-
$(
|
|
1263
|
+
let p = i.pages;
|
|
1264
|
+
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.");
|
|
1265
|
+
$(i.width, "width", 1), $(i.height, "height", 1), $(i.flipDuration, "flipDuration", 0), $(i.clickZoneSize, "clickZoneSize", 0), $(i.clickFlipDelay, "clickFlipDelay", 0), $(i.singlePageThreshold, "singlePageThreshold", 0), ee(i.zoom), te(i.renderer);
|
|
1335
1266
|
}
|
|
1336
1267
|
function $(e, t, n) {
|
|
1337
1268
|
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)}.`);
|
|
@@ -1401,6 +1332,6 @@ var ne = class {
|
|
|
1401
1332
|
}
|
|
1402
1333
|
};
|
|
1403
1334
|
//#endregion
|
|
1404
|
-
export {
|
|
1335
|
+
export { t as CURL_TYPES, i as DEFAULT_ITEMS, e as IMPORTABLE_CURLS, ne as ImageSource, K as Zine, n as defineControl, r as getControl };
|
|
1405
1336
|
|
|
1406
1337
|
//# sourceMappingURL=index.js.map
|