@harbour-enterprises/superdoc 1.0.0-alpha.64 → 1.0.0-alpha.65

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.
@@ -0,0 +1,4 @@
1
+ var a = null;
2
+ export {
3
+ a as default
4
+ };
@@ -0,0 +1,230 @@
1
+ var A = {
2
+ a: 7,
3
+ c: 6,
4
+ h: 1,
5
+ l: 2,
6
+ m: 2,
7
+ q: 4,
8
+ s: 4,
9
+ t: 2,
10
+ v: 1,
11
+ z: 0
12
+ }, V = /([astvzqmhlc])([^astvzqmhlc]*)/gi, Z = /-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/gi;
13
+ function _(o) {
14
+ const n = o.match(Z);
15
+ return n ? n.map(Number) : [];
16
+ }
17
+ function U(o) {
18
+ const n = [], t = String(o).trim();
19
+ return t[0] !== "M" && t[0] !== "m" || t.replace(V, (l, r, a) => {
20
+ const s = _(a);
21
+ let i = r.toLowerCase(), c = r;
22
+ if (i === "m" && s.length > 2 && (n.push([c, ...s.splice(0, 2)]), i = "l", c = c === "m" ? "l" : "L"), s.length < A[i])
23
+ return "";
24
+ for (n.push([c, ...s.splice(0, A[i])]); s.length >= A[i] && s.length && A[i]; )
25
+ n.push([c, ...s.splice(0, A[i])]);
26
+ return "";
27
+ }), n;
28
+ }
29
+ function B(o, n) {
30
+ const t = o.x * Math.cos(n) - o.y * Math.sin(n), l = o.y * Math.cos(n) + o.x * Math.sin(n);
31
+ o.x = t, o.y = l;
32
+ }
33
+ function j(o, n, t) {
34
+ o.x += n, o.y += t;
35
+ }
36
+ function C(o, n) {
37
+ o.x *= n, o.y *= n;
38
+ }
39
+ var N = class S {
40
+ constructor(n) {
41
+ this.commands = [], n && n instanceof S ? this.commands.push(...n.commands) : n && (this.commands = U(n));
42
+ }
43
+ addPath(n) {
44
+ n && n instanceof S && this.commands.push(...n.commands);
45
+ }
46
+ moveTo(n, t) {
47
+ this.commands.push(["M", n, t]);
48
+ }
49
+ lineTo(n, t) {
50
+ this.commands.push(["L", n, t]);
51
+ }
52
+ arc(n, t, l, r, a, s) {
53
+ this.commands.push(["AC", n, t, l, r, a, !!s]);
54
+ }
55
+ arcTo(n, t, l, r, a) {
56
+ this.commands.push(["AT", n, t, l, r, a]);
57
+ }
58
+ ellipse(n, t, l, r, a, s, i, c) {
59
+ this.commands.push(["E", n, t, l, r, a, s, i, !!c]);
60
+ }
61
+ closePath() {
62
+ this.commands.push(["Z"]);
63
+ }
64
+ bezierCurveTo(n, t, l, r, a, s) {
65
+ this.commands.push(["C", n, t, l, r, a, s]);
66
+ }
67
+ quadraticCurveTo(n, t, l, r) {
68
+ this.commands.push(["Q", n, t, l, r]);
69
+ }
70
+ rect(n, t, l, r) {
71
+ this.commands.push(["R", n, t, l, r]);
72
+ }
73
+ roundRect(n, t, l, r, a) {
74
+ typeof a > "u" ? this.commands.push(["RR", n, t, l, r, 0]) : this.commands.push(["RR", n, t, l, r, a]);
75
+ }
76
+ };
77
+ function F(o, n) {
78
+ let t = 0, l = 0, r, a, s, i, c, u, P, q, L, z, $, G, E, p, f, w, I, b, R, d, Q, m = null, k = null, y = null, T = null, v = null, M = null;
79
+ o.beginPath();
80
+ for (let h = 0; h < n.length; ++h) {
81
+ b = n[h][0], b !== "S" && b !== "s" && b !== "C" && b !== "c" && (m = null, k = null), b !== "T" && b !== "t" && b !== "Q" && b !== "q" && (y = null, T = null);
82
+ let e;
83
+ switch (b) {
84
+ case "m":
85
+ case "M":
86
+ e = n[h], b === "m" ? (t += e[1], l += e[2]) : (t = e[1], l = e[2]), (b === "M" || !v) && (v = { x: t, y: l }), o.moveTo(t, l);
87
+ break;
88
+ case "l":
89
+ e = n[h], t += e[1], l += e[2], o.lineTo(t, l);
90
+ break;
91
+ case "L":
92
+ e = n[h], t = e[1], l = e[2], o.lineTo(t, l);
93
+ break;
94
+ case "H":
95
+ e = n[h], t = e[1], o.lineTo(t, l);
96
+ break;
97
+ case "h":
98
+ e = n[h], t += e[1], o.lineTo(t, l);
99
+ break;
100
+ case "V":
101
+ e = n[h], l = e[1], o.lineTo(t, l);
102
+ break;
103
+ case "v":
104
+ e = n[h], l += e[1], o.lineTo(t, l);
105
+ break;
106
+ case "a":
107
+ case "A":
108
+ if (e = n[h], M === null)
109
+ throw new Error("This should never happen");
110
+ b === "a" ? (t += e[6], l += e[7]) : (t = e[6], l = e[7]), p = e[1], f = e[2], P = e[3] * Math.PI / 180, s = !!e[4], i = !!e[5], c = { x: t, y: l }, u = {
111
+ x: (M.x - c.x) / 2,
112
+ y: (M.y - c.y) / 2
113
+ }, B(u, -P), q = u.x * u.x / (p * p) + u.y * u.y / (f * f), q > 1 && (q = Math.sqrt(q), p *= q, f *= q), R = {
114
+ x: p * u.y / f,
115
+ y: -(f * u.x) / p
116
+ }, L = p * p * f * f, z = p * p * u.y * u.y + f * f * u.x * u.x, i !== s ? C(R, Math.sqrt((L - z) / z) || 0) : C(R, -Math.sqrt((L - z) / z) || 0), a = Math.atan2((u.y - R.y) / f, (u.x - R.x) / p), r = Math.atan2(-(u.y + R.y) / f, -(u.x + R.x) / p), B(R, P), j(R, (c.x + M.x) / 2, (c.y + M.y) / 2), o.save(), o.translate(R.x, R.y), o.rotate(P), o.scale(p, f), o.arc(0, 0, 1, a, r, !i), o.restore();
117
+ break;
118
+ case "C":
119
+ e = n[h], m = e[3], k = e[4], t = e[5], l = e[6], o.bezierCurveTo(e[1], e[2], m, k, t, l);
120
+ break;
121
+ case "c":
122
+ e = n[h], o.bezierCurveTo(e[1] + t, e[2] + l, e[3] + t, e[4] + l, e[5] + t, e[6] + l), m = e[3] + t, k = e[4] + l, t += e[5], l += e[6];
123
+ break;
124
+ case "S":
125
+ e = n[h], (m === null || k === null) && (m = t, k = l), o.bezierCurveTo(2 * t - m, 2 * l - k, e[1], e[2], e[3], e[4]), m = e[1], k = e[2], t = e[3], l = e[4];
126
+ break;
127
+ case "s":
128
+ e = n[h], (m === null || k === null) && (m = t, k = l), o.bezierCurveTo(2 * t - m, 2 * l - k, e[1] + t, e[2] + l, e[3] + t, e[4] + l), m = e[1] + t, k = e[2] + l, t += e[3], l += e[4];
129
+ break;
130
+ case "Q":
131
+ e = n[h], y = e[1], T = e[2], t = e[3], l = e[4], o.quadraticCurveTo(y, T, t, l);
132
+ break;
133
+ case "q":
134
+ e = n[h], y = e[1] + t, T = e[2] + l, t += e[3], l += e[4], o.quadraticCurveTo(y, T, t, l);
135
+ break;
136
+ case "T":
137
+ e = n[h], (y === null || T === null) && (y = t, T = l), y = 2 * t - y, T = 2 * l - T, t = e[1], l = e[2], o.quadraticCurveTo(y, T, t, l);
138
+ break;
139
+ case "t":
140
+ e = n[h], (y === null || T === null) && (y = t, T = l), y = 2 * t - y, T = 2 * l - T, t += e[1], l += e[2], o.quadraticCurveTo(y, T, t, l);
141
+ break;
142
+ case "z":
143
+ case "Z":
144
+ v && (t = v.x, l = v.y), v = null, o.closePath();
145
+ break;
146
+ case "AC":
147
+ e = n[h], t = e[1], l = e[2], E = e[3], a = e[4], r = e[5], d = e[6], o.arc(t, l, E, a, r, d);
148
+ break;
149
+ case "AT":
150
+ e = n[h], $ = e[1], G = e[2], t = e[3], l = e[4], E = e[5], o.arcTo($, G, t, l, E);
151
+ break;
152
+ case "E":
153
+ e = n[h], t = e[1], l = e[2], p = e[3], f = e[4], P = e[5], a = e[6], r = e[7], d = e[8], o.save(), o.translate(t, l), o.rotate(P), o.scale(p, f), o.arc(0, 0, 1, a, r, d), o.restore();
154
+ break;
155
+ case "R":
156
+ e = n[h], t = e[1], l = e[2], w = e[3], I = e[4], v = { x: t, y: l }, o.rect(t, l, w, I);
157
+ break;
158
+ case "RR":
159
+ e = n[h], t = e[1], l = e[2], w = e[3], I = e[4], Q = e[5], v = { x: t, y: l }, o.roundRect(t, l, w, I, Q);
160
+ break;
161
+ default:
162
+ throw new Error(`Invalid path command: ${b}`);
163
+ }
164
+ M ? (M.x = t, M.y = l) : M = { x: t, y: l };
165
+ }
166
+ }
167
+ function H(o, n, t, l, r = 0) {
168
+ if (typeof r == "number" && (r = [r]), Array.isArray(r)) {
169
+ if (r.length === 0 || r.length > 4)
170
+ throw new RangeError(
171
+ `Failed to execute 'roundRect' on '${this.constructor.name}': ${r.length} radii provided. Between one and four radii are necessary.`
172
+ );
173
+ r.forEach((P) => {
174
+ if (P < 0)
175
+ throw new RangeError(
176
+ `Failed to execute 'roundRect' on '${this.constructor.name}': Radius value ${P} is negative.`
177
+ );
178
+ });
179
+ } else
180
+ return;
181
+ if (r.length === 1 && r[0] === 0) {
182
+ this.rect(o, n, t, l);
183
+ return;
184
+ }
185
+ const a = Math.min(t, l) / 2, s = Math.min(a, r[0]);
186
+ let i = s, c = s, u = s;
187
+ r.length === 2 && (i = Math.min(a, r[1]), u = i), r.length === 3 && (i = Math.min(a, r[1]), u = i, c = Math.min(a, r[2])), r.length === 4 && (i = Math.min(a, r[1]), c = Math.min(a, r[2]), u = Math.min(a, r[3])), this.moveTo(o, n + l - u), this.arcTo(o, n, o + s, n, s), this.arcTo(o + t, n, o + t, n + i, i), this.arcTo(o + t, n + l, o + t - c, n + l, c), this.arcTo(o, n + l, o, n + l - u, u), this.moveTo(o, n);
188
+ }
189
+ function J(o) {
190
+ if (!o) return;
191
+ const n = o.prototype.clip, t = o.prototype.fill, l = o.prototype.stroke, r = o.prototype.isPointInPath;
192
+ o.prototype.clip = function(...s) {
193
+ if (s[0] instanceof N) {
194
+ const c = s[0], u = s[1] || "nonzero";
195
+ return F(this, c.commands), n.apply(this, [u]);
196
+ }
197
+ const i = s[0] || "nonzero";
198
+ return n.apply(this, [i]);
199
+ }, o.prototype.fill = function(...s) {
200
+ if (s[0] instanceof N) {
201
+ const c = s[0], u = s[1] || "nonzero";
202
+ return F(this, c.commands), t.apply(this, [u]);
203
+ }
204
+ const i = s[0] || "nonzero";
205
+ return t.apply(this, [i]);
206
+ }, o.prototype.stroke = function(s) {
207
+ s && F(this, s.commands), l.apply(this);
208
+ }, o.prototype.isPointInPath = function(...s) {
209
+ if (s[0] instanceof N) {
210
+ const i = s[0], c = s[1], u = s[2], P = s[3] || "nonzero";
211
+ return F(this, i.commands), r.apply(this, [c, u, P]);
212
+ }
213
+ return r.apply(this, s);
214
+ };
215
+ }
216
+ function K(o) {
217
+ o && !o.prototype.roundRect && (o.prototype.roundRect = H);
218
+ }
219
+ function O(o) {
220
+ o && !o.prototype.roundRect && (o.prototype.roundRect = H);
221
+ }
222
+ export {
223
+ N as Path2D,
224
+ J as applyPath2DToCanvasRenderingContext,
225
+ K as applyRoundRectToCanvasRenderingContext2D,
226
+ O as applyRoundRectToPath2D,
227
+ F as buildPath,
228
+ U as parsePath,
229
+ H as roundRect
230
+ };