@algorisys/yappydraw 0.8.278 → 0.8.284
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/README.md +2 -2
- package/chunks/{AllPackages-DytsA6Gg.js → AllPackages-NXu9X6xl.js} +5 -5
- package/chunks/{BaseConfiguration-B0Un-ANd.js → BaseConfiguration-Cn1Beeg_.js} +3 -3
- package/chunks/{Entities-XwxJEcR3.js → Entities-DNDwR9nR.js} +1 -1
- package/chunks/{Factory-B4kWsy6c.js → Factory-hCmMrRZd.js} +8 -8
- package/chunks/{InputJax-DQpRzuU2.js → InputJax-BnvzjXPP.js} +1 -1
- package/chunks/PrioritizedList-CopFulOu.js +35 -0
- package/chunks/{TeXAtom-COgv6VHH.js → TeXAtom-i5HZ7jSY.js} +25 -25
- package/chunks/__vite-browser-external-BsdCVVos.js +110 -0
- package/chunks/_commonjsHelpers-DaMA6jEr.js +8 -0
- package/chunks/{canva-ai-7n8RQQlp.js → canva-ai-Bn55G-RK.js} +8 -8
- package/chunks/{choice-dialog-state-DzWAU-Fv.js → choice-dialog-state-C3iNX5d9.js} +1 -1
- package/chunks/{design-generator-AHGi1XTI.js → design-generator-DH124WNv.js} +1 -1
- package/chunks/{drawing-engine-DfKBHdTi.js → drawing-engine-BsOJV2hA.js} +1 -1
- package/chunks/{drawings-store-Cyv-1e1L.js → drawings-store-CN5GhfbN.js} +19 -19
- package/chunks/{ds-operations-C9fmILbu.js → ds-operations-DZRV2pe2.js} +1 -1
- package/chunks/{export-game-C1SNNfRf.js → export-game-C-6KMFRu.js} +1 -1
- package/chunks/{game-runtime-ztkqHa3o.js → game-runtime-DYNjw0j0.js} +76 -76
- package/chunks/{html-CEj6ZeJc.js → html-BBKfobGE.js} +56 -55
- package/chunks/html2canvas.esm-BWVIUcAF.js +4802 -0
- package/chunks/{index-vjDu6_KH.js → index-VL9TAaVA.js} +18876 -15818
- package/chunks/index.es-Cmz4JyRm.js +6665 -0
- package/chunks/jspdf.es.min-rJE95jGX.js +9859 -0
- package/chunks/lcms-Car3bVu8.js +949 -0
- package/chunks/lcms-tShoQ1hy.js +4 -0
- package/chunks/{liteAdaptor-BZby1Qz2.js → liteAdaptor-DFCyQb98.js} +2 -2
- package/chunks/{lucide-solid-UJTMB-sy.js → lucide-solid-D0XBq3EO.js} +1 -1
- package/chunks/{markdown-to-slides-CKGVwM_7.js → markdown-to-slides-CRpkf5KS.js} +16 -16
- package/chunks/{mathjax-CnUrFnFS.js → mathjax-BPYOiwki.js} +1 -1
- package/chunks/{mathjax-D6cR72fZ.js → mathjax-BYK64638.js} +2 -2
- package/chunks/{morph-animator-D7JpZIyR.js → morph-animator-DiHl564V.js} +1 -1
- package/chunks/{onboarding-tour-DsN4nEFc.js → onboarding-tour-BInImPzk.js} +32 -32
- package/chunks/pdf-cmyk-CqVZV2FF.js +339 -0
- package/chunks/pdf-vector-DhjM0Hvn.js +200 -0
- package/chunks/pdf-x-DBYFVbAz.js +220 -0
- package/chunks/purify.es-C2Qa7b4C.js +906 -0
- package/chunks/{search-qTCHUaUH.js → search-BwITDpaH.js} +2 -2
- package/chunks/{slide-generator-CoHxujzf.js → slide-generator-Da0DCaYV.js} +8 -8
- package/chunks/{svg-B2urwbCV.js → svg-CGqKTjgw.js} +3 -3
- package/chunks/svg2pdf.es.min-BVaMJ-wC.js +2452 -0
- package/chunks/{tex-BTCIQDRb.js → tex-Cc_XKudY.js} +4 -4
- package/chunks/{turntable-ai-BEZd382K.js → turntable-ai-CIDk9Jmv.js} +1 -1
- package/chunks/{yappy-NspTXSPk.css → yappy-FCQs01wv.css} +1 -1
- package/package.json +1 -1
- package/yappy.js +5 -5
- package/chunks/PrioritizedList-TjDg4i-s.js +0 -39
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { g as R } from "./
|
|
1
|
+
import { g as R } from "./_commonjsHelpers-DaMA6jEr.js";
|
|
2
2
|
import { r as Z } from "./Options-BStFr0zv.js";
|
|
3
|
-
import { r as tt } from "./Entities-
|
|
3
|
+
import { r as tt } from "./Entities-DNDwR9nR.js";
|
|
4
4
|
import { r as et } from "./Styles-DdTYCumM.js";
|
|
5
5
|
function rt(A, O) {
|
|
6
6
|
for (var b = 0; b < O.length; b++) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { U as e, af as o, ag as r, ah as d, ai as t, aj as i, ak as c, al as n, am as h } from "./index-VL9TAaVA.js";
|
|
2
2
|
var s = [["path", {
|
|
3
3
|
d: "m14 12 4 4 4-4",
|
|
4
4
|
key: "buelq4"
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
function
|
|
3
|
-
const o = M[T || "minimalist"] || M.minimalist,
|
|
4
|
-
`),
|
|
1
|
+
import { F as _, G as w, H as C, P as M, I, J as L, K as x } from "./index-VL9TAaVA.js";
|
|
2
|
+
function P(r, T) {
|
|
3
|
+
const o = M[T || "minimalist"] || M.minimalist, c = r.split(`
|
|
4
|
+
`), a = [];
|
|
5
5
|
let t = null, u = [];
|
|
6
6
|
const h = () => {
|
|
7
7
|
t && (u.length > 0 && !t.bullets?.length && !t.body && !t.quoteText && (t.body = u.join(`
|
|
8
|
-
`).trim()), u = [],
|
|
8
|
+
`).trim()), u = [], a.push(t), t = null);
|
|
9
9
|
}, n = (e, s = "content") => {
|
|
10
10
|
h(), t = { title: e, type: s };
|
|
11
11
|
};
|
|
12
|
-
for (let e = 0; e <
|
|
13
|
-
const i =
|
|
12
|
+
for (let e = 0; e < c.length; e++) {
|
|
13
|
+
const i = c[e].trim();
|
|
14
14
|
if (/^---+\s*$/.test(i)) {
|
|
15
15
|
h();
|
|
16
16
|
continue;
|
|
17
17
|
}
|
|
18
18
|
const l = i.match(/^#\s+(.+)$/);
|
|
19
19
|
if (l) {
|
|
20
|
-
|
|
20
|
+
a.length === 0 && !t ? n(l[1], "title") : n(l[1]);
|
|
21
21
|
continue;
|
|
22
22
|
}
|
|
23
23
|
const m = i.match(/^##\s+(.+)$/);
|
|
@@ -33,8 +33,8 @@ function v(r, T) {
|
|
|
33
33
|
const y = i.match(/^>\s*(.+)$/);
|
|
34
34
|
if (y) {
|
|
35
35
|
const E = [y[1]];
|
|
36
|
-
for (; e + 1 <
|
|
37
|
-
e++, E.push(
|
|
36
|
+
for (; e + 1 < c.length && /^>\s*/.test(c[e + 1].trim()); )
|
|
37
|
+
e++, E.push(c[e].trim().replace(/^>\s*/, ""));
|
|
38
38
|
const k = E.join(" ").trim(), b = k.match(/^(.+?)\s*[—–-]{1,2}\s*(.+)$/);
|
|
39
39
|
t && t.type !== "title" && h(), t || (t = { title: "", type: "quote" }), b ? (t.type = "quote", t.quoteText = b[1].trim(), t.quoteAttribution = b[2].trim()) : (t.type = "quote", t.quoteText = k);
|
|
40
40
|
continue;
|
|
@@ -51,14 +51,14 @@ function v(r, T) {
|
|
|
51
51
|
}
|
|
52
52
|
i !== "" && (t || n(""), u.push(d(i)));
|
|
53
53
|
}
|
|
54
|
-
h(),
|
|
54
|
+
h(), a.length === 0 && a.push({ title: "Untitled", type: "content", body: r.trim() });
|
|
55
55
|
const S = 2e3, p = [], g = [];
|
|
56
|
-
return
|
|
56
|
+
return a.forEach((e, s) => {
|
|
57
57
|
const i = s * S;
|
|
58
58
|
let l;
|
|
59
59
|
switch (e.type) {
|
|
60
60
|
case "title":
|
|
61
|
-
l =
|
|
61
|
+
l = I(e.title, e.body || e.bullets?.[0], o);
|
|
62
62
|
break;
|
|
63
63
|
case "quote":
|
|
64
64
|
l = C(e.quoteText || "", e.quoteAttribution, o);
|
|
@@ -70,9 +70,9 @@ function v(r, T) {
|
|
|
70
70
|
l = _(e.title, e.bullets, e.body, o);
|
|
71
71
|
break;
|
|
72
72
|
}
|
|
73
|
-
const m =
|
|
73
|
+
const m = L(l, i, 0);
|
|
74
74
|
p.push(...m), g.push({
|
|
75
|
-
id:
|
|
75
|
+
id: x("slide"),
|
|
76
76
|
name: e.title || `Slide ${s + 1}`,
|
|
77
77
|
spatialPosition: { x: i, y: 0 },
|
|
78
78
|
dimensions: { width: 1920, height: 1080 },
|
|
@@ -92,5 +92,5 @@ function d(r) {
|
|
|
92
92
|
return r.replace(/\*\*(.+?)\*\*/g, "$1").replace(/__(.+?)__/g, "$1").replace(/\*(.+?)\*/g, "$1").replace(/_(.+?)_/g, "$1").replace(/`(.+?)`/g, "$1").replace(/\[(.+?)\]\(.+?\)/g, "$1").trim();
|
|
93
93
|
}
|
|
94
94
|
export {
|
|
95
|
-
|
|
95
|
+
P as parseMarkdownToSlides
|
|
96
96
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as x } from "./PrioritizedList-
|
|
1
|
+
import { r as x } from "./PrioritizedList-CopFulOu.js";
|
|
2
2
|
var y = {}, v = {}, _;
|
|
3
3
|
function L() {
|
|
4
4
|
return _ || (_ = 1, Object.defineProperty(v, "__esModule", { value: !0 }), v.VERSION = void 0, v.VERSION = "3.2.1"), v;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { g as s } from "./
|
|
2
|
-
import { r as i } from "./mathjax-
|
|
1
|
+
import { g as s } from "./_commonjsHelpers-DaMA6jEr.js";
|
|
2
|
+
import { r as i } from "./mathjax-BPYOiwki.js";
|
|
3
3
|
function c(r, n) {
|
|
4
4
|
for (var o = 0; o < n.length; o++) {
|
|
5
5
|
const e = n[o];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Q as T, R as it, S as nt, T as st, U as x, s as V, V as h, W as A, X as S, Y as g, Z as v, _ as at, $ as lt, a0 as C } from "./index-VL9TAaVA.js";
|
|
2
2
|
var ct = /* @__PURE__ */ C("<svg><rect rx=10 fill=black></svg>", !1, !0, !1), ut = /* @__PURE__ */ C("<div class=tour-spotlight-ring>"), dt = /* @__PURE__ */ C('<div class=tour-overlay role=dialog aria-modal=true aria-label="Product tour"><svg class=tour-mask width=100% height=100%><defs><mask id=tour-spotlight><rect width=100% height=100% fill=white></rect></mask></defs><rect width=100% height=100% fill=rgba(0,0,0,0.6) mask=url(#tour-spotlight)></rect></svg><div class=tour-tooltip><div class=tour-tooltip-head><span class=tour-step-count> of </span><button class=tour-skip>Skip tour</button></div><h3 class=tour-title></h3><p class=tour-content></p><div class=tour-nav><button class="tour-btn tour-btn-secondary">Back</button><button class="tour-btn tour-btn-primary"></button></div><div class=tour-dots>'), ht = /* @__PURE__ */ C("<button class=tour-dot>");
|
|
3
|
-
const
|
|
3
|
+
const Z = "yappy:tour:seen", L = [{
|
|
4
4
|
id: "welcome",
|
|
5
5
|
title: "Welcome to YappyDraw 👋",
|
|
6
6
|
content: "A quick tour of the essentials — about a minute. Click Next to explore each area, or Skip anytime. You can replay this later from Help (?).",
|
|
@@ -38,51 +38,51 @@ const Q = "yappy:tour:seen", L = [{
|
|
|
38
38
|
content: "That's the tour! Reopen it anytime from Help (?) → “Take the tour”. Have fun creating.",
|
|
39
39
|
target: ".help-btn",
|
|
40
40
|
position: "bottom"
|
|
41
|
-
}], [w,
|
|
41
|
+
}], [w, j] = T(!1), [f, $] = T(0), ft = w;
|
|
42
42
|
function pt() {
|
|
43
|
-
$(0),
|
|
43
|
+
$(0), j(!0);
|
|
44
44
|
}
|
|
45
|
-
let
|
|
45
|
+
let J = !1;
|
|
46
46
|
function tt() {
|
|
47
|
-
|
|
47
|
+
J = !0;
|
|
48
48
|
try {
|
|
49
|
-
localStorage.setItem(
|
|
49
|
+
localStorage.setItem(Z, "1");
|
|
50
50
|
} catch {
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
function
|
|
54
|
-
|
|
53
|
+
function Q(s = !0) {
|
|
54
|
+
j(!1), s && tt();
|
|
55
55
|
}
|
|
56
|
-
function
|
|
57
|
-
if (
|
|
56
|
+
function X() {
|
|
57
|
+
if (J) return !0;
|
|
58
58
|
try {
|
|
59
|
-
return localStorage.getItem(
|
|
59
|
+
return localStorage.getItem(Z) === "1";
|
|
60
60
|
} catch {
|
|
61
61
|
return !1;
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
function gt() {
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
X() || V.appMode !== "presentation" && setTimeout(() => {
|
|
66
|
+
X() || V.appMode === "presentation" || (tt(), pt());
|
|
67
67
|
}, 900);
|
|
68
68
|
}
|
|
69
69
|
const m = 340, b = 200, p = 16, mt = () => {
|
|
70
70
|
const [s, P] = T(null), [H, R] = T({
|
|
71
71
|
top: 0,
|
|
72
72
|
left: 0
|
|
73
|
-
}),
|
|
74
|
-
M() ?
|
|
73
|
+
}), _ = () => L[f()], D = () => L.length, M = () => f() === D() - 1, O = () => f() === 0, z = () => {
|
|
74
|
+
M() ? Q(!0) : $((e) => e + 1);
|
|
75
75
|
}, I = () => {
|
|
76
76
|
O() || $((e) => e - 1);
|
|
77
|
-
},
|
|
77
|
+
}, Y = () => Q(!0), W = (e, l) => ({
|
|
78
78
|
top: Math.max(p, Math.min(e, window.innerHeight - b - p)),
|
|
79
79
|
left: Math.max(p, Math.min(l, window.innerWidth - m - p))
|
|
80
|
-
}),
|
|
81
|
-
const e =
|
|
80
|
+
}), q = () => {
|
|
81
|
+
const e = _();
|
|
82
82
|
if (!e) return;
|
|
83
83
|
const l = e.target ? document.querySelector(e.target) : null;
|
|
84
84
|
if (!l || e.position === "center") {
|
|
85
|
-
P(l ? l.getBoundingClientRect() : null), R(
|
|
85
|
+
P(l ? l.getBoundingClientRect() : null), R(W(window.innerHeight / 2 - b / 2, window.innerWidth / 2 - m / 2));
|
|
86
86
|
return;
|
|
87
87
|
}
|
|
88
88
|
const r = l.getBoundingClientRect();
|
|
@@ -102,20 +102,20 @@ const m = 340, b = 200, p = 16, mt = () => {
|
|
|
102
102
|
c = r.top + r.height / 2 - b / 2, a = r.right + p;
|
|
103
103
|
break;
|
|
104
104
|
}
|
|
105
|
-
R(
|
|
105
|
+
R(W(c, a));
|
|
106
106
|
};
|
|
107
107
|
it(() => {
|
|
108
|
-
w() && (f(), requestAnimationFrame(() => requestAnimationFrame(
|
|
108
|
+
w() && (f(), requestAnimationFrame(() => requestAnimationFrame(q)));
|
|
109
109
|
});
|
|
110
110
|
const k = () => {
|
|
111
|
-
w() &&
|
|
112
|
-
},
|
|
113
|
-
w() && (e.key === "Escape" ? (e.preventDefault(),
|
|
111
|
+
w() && q();
|
|
112
|
+
}, F = (e) => {
|
|
113
|
+
w() && (e.key === "Escape" ? (e.preventDefault(), Y()) : e.key === "ArrowRight" || e.key === "Enter" ? (e.preventDefault(), z()) : e.key === "ArrowLeft" && (e.preventDefault(), I()));
|
|
114
114
|
};
|
|
115
115
|
return nt(() => {
|
|
116
|
-
window.addEventListener("resize", k), window.addEventListener("scroll", k, !0), document.addEventListener("keydown",
|
|
116
|
+
window.addEventListener("resize", k), window.addEventListener("scroll", k, !0), document.addEventListener("keydown", F);
|
|
117
117
|
}), st(() => {
|
|
118
|
-
window.removeEventListener("resize", k), window.removeEventListener("scroll", k, !0), document.removeEventListener("keydown",
|
|
118
|
+
window.removeEventListener("resize", k), window.removeEventListener("scroll", k, !0), document.removeEventListener("keydown", F);
|
|
119
119
|
}), x(A, {
|
|
120
120
|
get when() {
|
|
121
121
|
return w();
|
|
@@ -123,7 +123,7 @@ const m = 340, b = 200, p = 16, mt = () => {
|
|
|
123
123
|
get children() {
|
|
124
124
|
var e = dt(), l = e.firstChild, r = l.firstChild, c = r.firstChild;
|
|
125
125
|
c.firstChild;
|
|
126
|
-
var a = l.nextSibling, B = a.firstChild, y = B.firstChild, et = y.firstChild, ot = y.nextSibling, G = B.nextSibling, K = G.nextSibling, N = K.nextSibling,
|
|
126
|
+
var a = l.nextSibling, B = a.firstChild, y = B.firstChild, et = y.firstChild, ot = y.nextSibling, G = B.nextSibling, K = G.nextSibling, N = K.nextSibling, E = N.firstChild, U = E.nextSibling, rt = N.nextSibling;
|
|
127
127
|
return h(c, x(A, {
|
|
128
128
|
get when() {
|
|
129
129
|
return s();
|
|
@@ -156,7 +156,7 @@ const m = 340, b = 200, p = 16, mt = () => {
|
|
|
156
156
|
o: void 0
|
|
157
157
|
}), o;
|
|
158
158
|
}
|
|
159
|
-
}), a), h(y, () => f() + 1, et), h(y, D, null), ot.$$click =
|
|
159
|
+
}), a), h(y, () => f() + 1, et), h(y, D, null), ot.$$click = Y, h(G, () => _()?.title), h(K, () => _()?.content), E.$$click = I, U.$$click = z, h(U, () => M() ? "Get started" : "Next"), h(rt, x(at, {
|
|
160
160
|
each: L,
|
|
161
161
|
children: (o, t) => (() => {
|
|
162
162
|
var n = ht();
|
|
@@ -170,7 +170,7 @@ const m = 340, b = 200, p = 16, mt = () => {
|
|
|
170
170
|
})()
|
|
171
171
|
})), S((o) => {
|
|
172
172
|
var t = `${H().top}px`, n = `${H().left}px`, i = O();
|
|
173
|
-
return t !== o.e && v(a, "top", o.e = t), n !== o.t && v(a, "left", o.t = n), i !== o.a && (
|
|
173
|
+
return t !== o.e && v(a, "top", o.e = t), n !== o.t && v(a, "left", o.t = n), i !== o.a && (E.disabled = o.a = i), o;
|
|
174
174
|
}, {
|
|
175
175
|
e: void 0,
|
|
176
176
|
t: void 0,
|
|
@@ -183,8 +183,8 @@ lt(["click"]);
|
|
|
183
183
|
export {
|
|
184
184
|
mt as OnboardingTour,
|
|
185
185
|
mt as default,
|
|
186
|
-
|
|
187
|
-
|
|
186
|
+
Q as endTour,
|
|
187
|
+
X as hasSeenTour,
|
|
188
188
|
ft as isTourActive,
|
|
189
189
|
gt as maybeAutoStartTour,
|
|
190
190
|
pt as startTour,
|
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
import { p as S } from "./__vite-browser-external-BsdCVVos.js";
|
|
2
|
+
const m = (r) => {
|
|
3
|
+
let t = "";
|
|
4
|
+
for (let e = 0; e < r.length; e += 32768) t += String.fromCharCode(...r.subarray(e, e + 32768));
|
|
5
|
+
return t;
|
|
6
|
+
}, w = (r) => {
|
|
7
|
+
const t = new Uint8Array(r.length);
|
|
8
|
+
for (let e = 0; e < r.length; e++) t[e] = r.charCodeAt(e) & 255;
|
|
9
|
+
return t;
|
|
10
|
+
}, F = (r) => {
|
|
11
|
+
const t = new Uint8Array(r.reduce((n, o) => n + o.length, 0));
|
|
12
|
+
let e = 0;
|
|
13
|
+
for (const n of r)
|
|
14
|
+
t.set(n, e), e += n.length;
|
|
15
|
+
return t;
|
|
16
|
+
};
|
|
17
|
+
class z {
|
|
18
|
+
header;
|
|
19
|
+
/** Object bodies in file order: everything from `N 0 obj` through `endobj\n`. */
|
|
20
|
+
bodies = /* @__PURE__ */ new Map();
|
|
21
|
+
order = [];
|
|
22
|
+
trailer;
|
|
23
|
+
size;
|
|
24
|
+
constructor(t) {
|
|
25
|
+
const e = m(t), n = e.lastIndexOf("startxref");
|
|
26
|
+
if (n < 0) throw new Error("PDF: no startxref");
|
|
27
|
+
const o = parseInt(e.slice(n + 9).trim(), 10);
|
|
28
|
+
if (e.slice(o, o + 4) !== "xref") throw new Error("PDF: startxref does not point at a classic xref table");
|
|
29
|
+
const s = /^xref\s+(\d+)\s+(\d+)\s*\r?\n/.exec(e.slice(o));
|
|
30
|
+
if (!s || s[1] !== "0") throw new Error("PDF: unsupported xref layout");
|
|
31
|
+
const a = parseInt(s[2], 10), i = o + s[0].length, c = [];
|
|
32
|
+
for (let l = 1; l < a; l++) {
|
|
33
|
+
const h = e.slice(i + l * 20, i + l * 20 + 18), f = /^(\d{10}) (\d{5}) ([nf])/.exec(h);
|
|
34
|
+
if (!f) throw new Error(`PDF: bad xref entry ${l}`);
|
|
35
|
+
f[3] === "n" && c.push([l, parseInt(f[1], 10)]);
|
|
36
|
+
}
|
|
37
|
+
const d = e.indexOf("trailer", i + a * 20 - 20);
|
|
38
|
+
if (e.indexOf("xref", i) !== -1 && e.indexOf("xref", i) < d) throw new Error("PDF: multiple xref sections");
|
|
39
|
+
this.trailer = e.slice(e.indexOf("<<", d), e.lastIndexOf(">>", n) + 2), this.size = a, c.sort((l, h) => l[1] - h[1]), this.header = t.subarray(0, c[0][1]), c.forEach(([l, h], f) => {
|
|
40
|
+
const p = f + 1 < c.length ? c[f + 1][1] : o;
|
|
41
|
+
if (!e.startsWith(`${l} 0 obj`, h)) throw new Error(`PDF: object ${l} not at its xref offset`);
|
|
42
|
+
this.bodies.set(l, t.subarray(h, p)), this.order.push(l);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
objectNumbers() {
|
|
46
|
+
return [...this.order];
|
|
47
|
+
}
|
|
48
|
+
get(t) {
|
|
49
|
+
const e = this.bodies.get(t);
|
|
50
|
+
if (!e) return null;
|
|
51
|
+
const n = m(e), o = n.indexOf("obj") + 3, s = n.indexOf("stream", o);
|
|
52
|
+
if (s === -1 || n.lastIndexOf("endobj") < s) return { num: t, dict: n.slice(o, n.lastIndexOf("endobj")).trim(), stream: null };
|
|
53
|
+
let a = s + 6;
|
|
54
|
+
n[a] === "\r" && a++, n[a] === `
|
|
55
|
+
` && a++;
|
|
56
|
+
const i = /\/Length (\d+)/.exec(n.slice(o, s)), c = i ? a + parseInt(i[1], 10) : n.lastIndexOf("endstream");
|
|
57
|
+
return { num: t, dict: n.slice(o, s).trim(), stream: e.subarray(a, c) };
|
|
58
|
+
}
|
|
59
|
+
/** Replace an object. `stream` given → `/Length` is set from it (any old one is dropped). */
|
|
60
|
+
set(t, e, n = null) {
|
|
61
|
+
this.bodies.has(t) || this.order.push(t), this.size = Math.max(this.size, t + 1);
|
|
62
|
+
let o = e.trim();
|
|
63
|
+
n ? (o = o.replace(/\/Length \d+\s*/g, ""), o = o.replace(/>>\s*$/, `/Length ${n.length}
|
|
64
|
+
>>`), this.bodies.set(t, F([w(`${t} 0 obj
|
|
65
|
+
${o}
|
|
66
|
+
stream
|
|
67
|
+
`), n, w(`
|
|
68
|
+
endstream
|
|
69
|
+
endobj
|
|
70
|
+
`)]))) : this.bodies.set(t, w(`${t} 0 obj
|
|
71
|
+
${o}
|
|
72
|
+
endobj
|
|
73
|
+
`));
|
|
74
|
+
}
|
|
75
|
+
/** Drop an object; its xref entry becomes free. The caller removes any references to it. */
|
|
76
|
+
remove(t) {
|
|
77
|
+
this.bodies.delete(t), this.order = this.order.filter((e) => e !== t);
|
|
78
|
+
}
|
|
79
|
+
/** Append a new object and return its number. */
|
|
80
|
+
add(t, e = null) {
|
|
81
|
+
const n = this.size;
|
|
82
|
+
return this.set(n, t, e), n;
|
|
83
|
+
}
|
|
84
|
+
/** The trailer dictionary text (`<< /Size … /Root … >>`), editable. */
|
|
85
|
+
getTrailer() {
|
|
86
|
+
return this.trailer;
|
|
87
|
+
}
|
|
88
|
+
setTrailer(t) {
|
|
89
|
+
this.trailer = t;
|
|
90
|
+
}
|
|
91
|
+
/** Replace the `%PDF-x.y` version in the header. */
|
|
92
|
+
setVersion(t) {
|
|
93
|
+
const e = m(this.header).replace(/^%PDF-\d\.\d/, `%PDF-${t}`);
|
|
94
|
+
this.header = w(e);
|
|
95
|
+
}
|
|
96
|
+
/** The object number the trailer's `/Root` (catalog) or `/Info` points at. */
|
|
97
|
+
ref(t) {
|
|
98
|
+
const e = new RegExp(`/${t} (\\d+) 0 R`).exec(this.trailer);
|
|
99
|
+
return e ? parseInt(e[1], 10) : null;
|
|
100
|
+
}
|
|
101
|
+
toBytes() {
|
|
102
|
+
const t = [this.header], e = /* @__PURE__ */ new Map();
|
|
103
|
+
let n = this.header.length;
|
|
104
|
+
for (const a of this.order) {
|
|
105
|
+
const i = this.bodies.get(a);
|
|
106
|
+
e.set(a, n), t.push(i), n += i.length;
|
|
107
|
+
}
|
|
108
|
+
let o = `xref
|
|
109
|
+
0 ${this.size}
|
|
110
|
+
0000000000 65535 f
|
|
111
|
+
`;
|
|
112
|
+
for (let a = 1; a < this.size; a++) {
|
|
113
|
+
const i = e.get(a);
|
|
114
|
+
o += i === void 0 ? `0000000000 65535 f
|
|
115
|
+
` : `${String(i).padStart(10, "0")} 00000 n
|
|
116
|
+
`;
|
|
117
|
+
}
|
|
118
|
+
const s = this.trailer.replace(/\/Size \d+/, `/Size ${this.size}`);
|
|
119
|
+
return t.push(w(`${o}trailer
|
|
120
|
+
${s}
|
|
121
|
+
startxref
|
|
122
|
+
${n}
|
|
123
|
+
%%EOF
|
|
124
|
+
`)), F(t);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
const M = async (r, t) => new Uint8Array(await new Response(new Blob([r]).stream().pipeThrough(t)).arrayBuffer()), T = (r) => M(r, new DecompressionStream("deflate")), C = (r) => M(r, new CompressionStream("deflate")), v = (r) => {
|
|
128
|
+
const t = m(r).replace(/[^0-9a-fA-F]/g, ""), e = new Uint8Array(t.length >> 1);
|
|
129
|
+
for (let n = 0; n < e.length; n++) e[n] = parseInt(t.substr(n * 2, 2), 16);
|
|
130
|
+
return e;
|
|
131
|
+
};
|
|
132
|
+
async function R(r, t) {
|
|
133
|
+
const e = /\/Filter\s*(\[[^\]]*\]|\/\w+)/.exec(r), n = e ? e[1].match(/\/\w+/g) ?? [] : [];
|
|
134
|
+
let o = t;
|
|
135
|
+
for (const s of n)
|
|
136
|
+
if (s === "/FlateDecode") o = await T(o);
|
|
137
|
+
else if (s === "/ASCIIHexDecode") o = v(o);
|
|
138
|
+
else throw new Error(`PDF: unsupported filter ${s}`);
|
|
139
|
+
return o;
|
|
140
|
+
}
|
|
141
|
+
const y = (r) => "#" + r.map((t) => t.toString(16).padStart(2, "0")).join("");
|
|
142
|
+
function U(r) {
|
|
143
|
+
const t = /* @__PURE__ */ new Map();
|
|
144
|
+
for (const e of r) {
|
|
145
|
+
const n = e.cmyk && S(e.color);
|
|
146
|
+
n && !t.has(y(n)) && t.set(y(n), e.cmyk);
|
|
147
|
+
}
|
|
148
|
+
return t;
|
|
149
|
+
}
|
|
150
|
+
const $ = (r, t, e) => t.get(y(e)) ?? r.rgbToCmyk(e);
|
|
151
|
+
function A(r) {
|
|
152
|
+
const t = r.filter((e) => typeof e == "number");
|
|
153
|
+
return r.length >= 4 && typeof r[3] == "number" ? null : typeof r[0] == "string" ? S(r[0]) : t.length >= 3 && typeof r[3] != "number" ? [t[0], t[1], t[2]].map((e) => Math.round(e)) : t.length === 1 ? [t[0], t[0], t[0]].map((e) => Math.round(e)) : null;
|
|
154
|
+
}
|
|
155
|
+
function B(r) {
|
|
156
|
+
const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map();
|
|
157
|
+
for (const n of r) {
|
|
158
|
+
const o = n.spot?.name && n.cmyk ? S(n.color) : null;
|
|
159
|
+
if (!o) continue;
|
|
160
|
+
const s = n.spot.name.trim();
|
|
161
|
+
let a = e.get(s);
|
|
162
|
+
a || (a = { name: s, cmyk: n.cmyk, res: `YDSpot${e.size}` }, e.set(s, a)), t.has(y(o)) || t.set(y(o), a);
|
|
163
|
+
}
|
|
164
|
+
return t;
|
|
165
|
+
}
|
|
166
|
+
function I(r) {
|
|
167
|
+
let t = "";
|
|
168
|
+
for (const e of new TextEncoder().encode(r)) {
|
|
169
|
+
const n = String.fromCharCode(e);
|
|
170
|
+
t += e < 33 || e > 126 || "()<>[]{}/%#".includes(n) ? "#" + e.toString(16).padStart(2, "0") : n;
|
|
171
|
+
}
|
|
172
|
+
return t;
|
|
173
|
+
}
|
|
174
|
+
const j = (r) => `[/Separation /${I(r.name)} /DeviceCMYK << /FunctionType 2 /Domain [0 1] /C0 [0 0 0 0] /C1 [${r.cmyk.map((t) => +(t / 100).toFixed(4)).join(" ")}] /N 1 >>]`;
|
|
175
|
+
function K(r, t, e, n = /* @__PURE__ */ new Map(), o) {
|
|
176
|
+
const s = { setFillColor: "cs 1 scn", setDrawColor: "CS 1 SCN" }, a = r.internal.write;
|
|
177
|
+
for (const i of ["setFillColor", "setDrawColor", "setTextColor"]) {
|
|
178
|
+
const c = r[i].bind(r);
|
|
179
|
+
r[i] = (...d) => {
|
|
180
|
+
const l = A(d);
|
|
181
|
+
if (!l) return c(...d);
|
|
182
|
+
const h = i !== "setTextColor" ? n.get(y(l)) : void 0;
|
|
183
|
+
if (h) {
|
|
184
|
+
o?.add(h);
|
|
185
|
+
const [g, , O] = s[i].split(" ");
|
|
186
|
+
return a(`/${h.res} ${g} 1 ${O}`), r;
|
|
187
|
+
}
|
|
188
|
+
const [f, p, u, b] = $(t, e, l);
|
|
189
|
+
return c(f / 100, p / 100, u / 100, b / 100);
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
const D = [89, 68, 67, 75], x = "YDCMYK", k = /* @__PURE__ */ new Map(), P = (r) => {
|
|
194
|
+
let t = 2166136261;
|
|
195
|
+
for (let e = 0; e < r.length; e++)
|
|
196
|
+
t ^= r.charCodeAt(e), t = Math.imul(t, 16777619);
|
|
197
|
+
return `${(t >>> 0).toString(36)}-${r.length}`;
|
|
198
|
+
}, E = (r) => {
|
|
199
|
+
const t = /^data:[^;,]*(;base64)?,(.*)$/s.exec(r);
|
|
200
|
+
if (!t) return null;
|
|
201
|
+
try {
|
|
202
|
+
return t[1] ? atob(t[2]) : decodeURIComponent(t[2]);
|
|
203
|
+
} catch {
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
async function N(r, t) {
|
|
208
|
+
const e = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set();
|
|
209
|
+
return r.querySelectorAll("image").forEach((o) => {
|
|
210
|
+
const s = o.getAttribute("href") ?? o.getAttributeNS("http://www.w3.org/1999/xlink", "href");
|
|
211
|
+
s && s.startsWith("data:image/") && !s.startsWith("data:image/svg") && n.add(s);
|
|
212
|
+
}), await Promise.all([...n].map(async (o) => {
|
|
213
|
+
const s = E(o);
|
|
214
|
+
if (!s) return;
|
|
215
|
+
const a = P(s);
|
|
216
|
+
if (e.has(a)) return;
|
|
217
|
+
const i = new Image();
|
|
218
|
+
i.src = o, await i.decode();
|
|
219
|
+
const c = document.createElement("canvas");
|
|
220
|
+
c.width = i.naturalWidth, c.height = i.naturalHeight;
|
|
221
|
+
const d = c.getContext("2d");
|
|
222
|
+
if (!d || !c.width || !c.height) return;
|
|
223
|
+
d.drawImage(i, 0, 0);
|
|
224
|
+
const { data: l } = d.getImageData(0, 0, c.width, c.height), { cmyk: h, alpha: f } = t.imageToCmyk(l), p = new Uint8Array(h.length);
|
|
225
|
+
for (let u = 0; u < h.length; u++) p[u] = 255 - h[u];
|
|
226
|
+
e.set(a, {
|
|
227
|
+
width: c.width,
|
|
228
|
+
height: c.height,
|
|
229
|
+
data: m(await C(p)),
|
|
230
|
+
sMask: f ? m(await C(f)) : null
|
|
231
|
+
});
|
|
232
|
+
})), e;
|
|
233
|
+
}
|
|
234
|
+
function Y(r, t, e, n) {
|
|
235
|
+
{
|
|
236
|
+
const s = function(a, i, c) {
|
|
237
|
+
const d = m(a.subarray(D.length)), l = k.get(d);
|
|
238
|
+
if (!l) throw new Error("CMYK image not prepared");
|
|
239
|
+
return {
|
|
240
|
+
alias: c,
|
|
241
|
+
index: i,
|
|
242
|
+
data: l.data,
|
|
243
|
+
width: l.width,
|
|
244
|
+
height: l.height,
|
|
245
|
+
colorSpace: "DeviceCMYK",
|
|
246
|
+
bitsPerComponent: 8,
|
|
247
|
+
// Already deflated: jsPDF strips the document filter for images, so without this
|
|
248
|
+
// every converted bitmap would be stored raw (4 bytes a pixel).
|
|
249
|
+
filter: "FlateDecode",
|
|
250
|
+
// jsPDF writes the SMask's DecodeParms from `predictor` whenever `filter` is set;
|
|
251
|
+
// 1 is "no prediction", which is what the data is.
|
|
252
|
+
predictor: 1,
|
|
253
|
+
...l.sMask ? { sMask: l.sMask } : {}
|
|
254
|
+
};
|
|
255
|
+
};
|
|
256
|
+
t[`process${x}`] = s, r[`process${x}`] = s;
|
|
257
|
+
}
|
|
258
|
+
const o = r.addImage.bind(r);
|
|
259
|
+
r.addImage = (...s) => {
|
|
260
|
+
const a = s[0], i = typeof a == "string" ? E(a) : null, c = i ? P(i) : null, d = c ? e.get(c) : void 0;
|
|
261
|
+
if (!d || !c)
|
|
262
|
+
return n(), o(...s);
|
|
263
|
+
k.set(c, d);
|
|
264
|
+
const l = new Uint8Array([...D, ...w(c)]), [, , h, f, p, u] = s;
|
|
265
|
+
return o(l, x, h, f, p, u, `cmyk-${c}`);
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
async function L(r, t, e, n = []) {
|
|
269
|
+
const o = new z(r);
|
|
270
|
+
let s = W(o, [...n]);
|
|
271
|
+
for (const a of o.objectNumbers()) {
|
|
272
|
+
const i = o.get(a);
|
|
273
|
+
if (!i || i.stream || !/\/ShadingType\s+\d/.test(i.dict) || !/\/ColorSpace\s*\/DeviceRGB/.test(i.dict)) continue;
|
|
274
|
+
const c = /\/Function\s+(\d+)\s+0\s+R/.exec(i.dict), d = c ? o.get(parseInt(c[1], 10)) : null;
|
|
275
|
+
if (!d || !d.stream || !/\/FunctionType\s+0/.test(d.dict)) throw new Error(`PDF: shading ${a} has no sampled function`);
|
|
276
|
+
const l = await R(d.dict, d.stream), h = Math.floor(l.length / 3), f = new Uint8Array(h * 4);
|
|
277
|
+
for (let u = 0; u < h; u++) {
|
|
278
|
+
const b = $(t, e, [l[u * 3], l[u * 3 + 1], l[u * 3 + 2]]);
|
|
279
|
+
for (let g = 0; g < 4; g++) f[u * 4 + g] = Math.round(b[g] * 2.55);
|
|
280
|
+
}
|
|
281
|
+
const p = /\/Size\s*\[[^\]]*\]/.exec(d.dict)?.[0] ?? `/Size [${h}]`;
|
|
282
|
+
o.set(
|
|
283
|
+
d.num,
|
|
284
|
+
`<<
|
|
285
|
+
/FunctionType 0
|
|
286
|
+
/Domain [0.0 1.0]
|
|
287
|
+
${p}
|
|
288
|
+
/BitsPerSample 8
|
|
289
|
+
/Range [0 1 0 1 0 1 0 1]
|
|
290
|
+
/Decode [0 1 0 1 0 1 0 1]
|
|
291
|
+
/Filter /FlateDecode
|
|
292
|
+
>>`,
|
|
293
|
+
await C(f)
|
|
294
|
+
), o.set(a, i.dict.replace(/\/ColorSpace\s*\/DeviceRGB/, "/ColorSpace /DeviceCMYK")), s = !0;
|
|
295
|
+
}
|
|
296
|
+
return s ? o.toBytes() : r;
|
|
297
|
+
}
|
|
298
|
+
function W(r, t) {
|
|
299
|
+
if (t.length === 0) return !1;
|
|
300
|
+
const e = t.map((o) => `/${o.res} ${j(o)}`).join(`
|
|
301
|
+
`);
|
|
302
|
+
let n = 0;
|
|
303
|
+
for (const o of r.objectNumbers()) {
|
|
304
|
+
const s = r.get(o);
|
|
305
|
+
if (!(!s || s.stream || !/^<<\s*\/ProcSet/.test(s.dict))) {
|
|
306
|
+
if (/\/ColorSpace/.test(s.dict)) throw new Error(`PDF: resource dictionary ${o} already has a /ColorSpace`);
|
|
307
|
+
r.set(o, s.dict.replace(/>>\s*$/, `/ColorSpace <<
|
|
308
|
+
${e}
|
|
309
|
+
>>
|
|
310
|
+
>>`)), n++;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
if (n === 0) throw new Error("PDF: no resource dictionary to declare the spot inks in");
|
|
314
|
+
return !0;
|
|
315
|
+
}
|
|
316
|
+
const H = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
317
|
+
__proto__: null,
|
|
318
|
+
cmykFor: $,
|
|
319
|
+
convertShadingsToCmyk: L,
|
|
320
|
+
exactCmykFromSwatches: U,
|
|
321
|
+
installCmykColors: K,
|
|
322
|
+
installCmykImages: Y,
|
|
323
|
+
pdfName: I,
|
|
324
|
+
prepareCmykImages: N,
|
|
325
|
+
rgbFromColorArgs: A,
|
|
326
|
+
separationArray: j,
|
|
327
|
+
spotsFromSwatches: B
|
|
328
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
329
|
+
export {
|
|
330
|
+
z as P,
|
|
331
|
+
Y as a,
|
|
332
|
+
R as b,
|
|
333
|
+
L as c,
|
|
334
|
+
C as d,
|
|
335
|
+
H as e,
|
|
336
|
+
K as i,
|
|
337
|
+
N as p,
|
|
338
|
+
m as t
|
|
339
|
+
};
|