@tongfun/ui 0.0.0-alpha.3 → 0.0.1-alpha.10
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 +110 -0
- package/dist/agent-schema/index.d.ts +12 -0
- package/dist/agent-schema/index.js +33 -0
- package/dist/agent-schema/types.d.ts +27 -0
- package/dist/formula/index.d.ts +17 -0
- package/dist/formula/types.d.ts +136 -0
- package/dist/html2canvas.esm-Bfw1xMTR.js +4886 -0
- package/dist/index-C0rb4BPV.js +482 -0
- package/dist/index-Ci3-2oB_.js +323459 -0
- package/dist/index.d.ts +719 -0
- package/dist/index.es-CoCAKfeh.js +5790 -0
- package/dist/index.js +842 -0
- package/dist/jspdf.es.min-B9-wXZ_S.js +10769 -0
- package/dist/lowcode-agent/icons.d.ts +12 -0
- package/dist/lowcode-agent/icons.js +229 -0
- package/dist/lowcode-agent/index.d.ts +27 -0
- package/dist/lowcode-agent/index.js +79577 -0
- package/dist/lowcode-agent/types.d.ts +471 -0
- package/dist/skill/golden-examples/dashboard-workbench.md +224 -0
- package/dist/skill/golden-examples/form-create.md +227 -0
- package/dist/skill/golden-examples/management-list.md +264 -0
- package/dist/skill/golden-examples/new-document.md +748 -0
- package/dist/skill/tongfun-ui-skill.json +470 -0
- package/dist/skill/tongfun-ui-skill.md +297 -0
- package/dist/style.css +10 -0
- package/package.json +113 -38
- package/Button/button-props.d.ts +0 -9
- package/Button/button-variants.d.ts +0 -5
- package/Button/index.d.ts +0 -20
- package/Button/index.js +0 -111
- package/index.css +0 -596
- package/index.d.ts +0 -15
- package/index.js +0 -19
- package/utils/forward-attrs.d.ts +0 -6
- package/utils/install.d.ts +0 -6
- package/utils/utils.d.ts +0 -2
|
@@ -0,0 +1,482 @@
|
|
|
1
|
+
function W(t, e) {
|
|
2
|
+
if (t.match(/^[a-z]+:\/\//i))
|
|
3
|
+
return t;
|
|
4
|
+
if (t.match(/^\/\//))
|
|
5
|
+
return window.location.protocol + t;
|
|
6
|
+
if (t.match(/^[a-z]+:/i))
|
|
7
|
+
return t;
|
|
8
|
+
const r = document.implementation.createHTMLDocument(), n = r.createElement("base"), s = r.createElement("a");
|
|
9
|
+
return r.head.appendChild(n), r.body.appendChild(s), e && (n.href = e), s.href = t, s.href;
|
|
10
|
+
}
|
|
11
|
+
const j = (() => {
|
|
12
|
+
let t = 0;
|
|
13
|
+
const e = () => (
|
|
14
|
+
// eslint-disable-next-line no-bitwise
|
|
15
|
+
`0000${(Math.random() * 36 ** 4 << 0).toString(36)}`.slice(-4)
|
|
16
|
+
);
|
|
17
|
+
return () => (t += 1, `u${e()}${t}`);
|
|
18
|
+
})();
|
|
19
|
+
function m(t) {
|
|
20
|
+
const e = [];
|
|
21
|
+
for (let r = 0, n = t.length; r < n; r++)
|
|
22
|
+
e.push(t[r]);
|
|
23
|
+
return e;
|
|
24
|
+
}
|
|
25
|
+
let g = null;
|
|
26
|
+
function A(t = {}) {
|
|
27
|
+
return g || (t.includeStyleProperties ? (g = t.includeStyleProperties, g) : (g = m(window.getComputedStyle(document.documentElement)), g));
|
|
28
|
+
}
|
|
29
|
+
function y(t, e) {
|
|
30
|
+
const n = (t.ownerDocument.defaultView || window).getComputedStyle(t).getPropertyValue(e);
|
|
31
|
+
return n ? parseFloat(n.replace("px", "")) : 0;
|
|
32
|
+
}
|
|
33
|
+
function q(t) {
|
|
34
|
+
const e = y(t, "border-left-width"), r = y(t, "border-right-width");
|
|
35
|
+
return t.clientWidth + e + r;
|
|
36
|
+
}
|
|
37
|
+
function z(t) {
|
|
38
|
+
const e = y(t, "border-top-width"), r = y(t, "border-bottom-width");
|
|
39
|
+
return t.clientHeight + e + r;
|
|
40
|
+
}
|
|
41
|
+
function k(t, e = {}) {
|
|
42
|
+
const r = e.width || q(t), n = e.height || z(t);
|
|
43
|
+
return { width: r, height: n };
|
|
44
|
+
}
|
|
45
|
+
function B() {
|
|
46
|
+
let t, e;
|
|
47
|
+
try {
|
|
48
|
+
e = process;
|
|
49
|
+
} catch {
|
|
50
|
+
}
|
|
51
|
+
const r = e && e.env ? e.env.devicePixelRatio : null;
|
|
52
|
+
return r && (t = parseInt(r, 10), Number.isNaN(t) && (t = 1)), t || window.devicePixelRatio || 1;
|
|
53
|
+
}
|
|
54
|
+
const u = 16384;
|
|
55
|
+
function G(t) {
|
|
56
|
+
(t.width > u || t.height > u) && (t.width > u && t.height > u ? t.width > t.height ? (t.height *= u / t.width, t.width = u) : (t.width *= u / t.height, t.height = u) : t.width > u ? (t.height *= u / t.width, t.width = u) : (t.width *= u / t.height, t.height = u));
|
|
57
|
+
}
|
|
58
|
+
function w(t) {
|
|
59
|
+
return new Promise((e, r) => {
|
|
60
|
+
const n = new Image();
|
|
61
|
+
n.onload = () => {
|
|
62
|
+
n.decode().then(() => {
|
|
63
|
+
requestAnimationFrame(() => e(n));
|
|
64
|
+
});
|
|
65
|
+
}, n.onerror = r, n.crossOrigin = "anonymous", n.decoding = "async", n.src = t;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
async function X(t) {
|
|
69
|
+
return Promise.resolve().then(() => new XMLSerializer().serializeToString(t)).then(encodeURIComponent).then((e) => `data:image/svg+xml;charset=utf-8,${e}`);
|
|
70
|
+
}
|
|
71
|
+
async function J(t, e, r) {
|
|
72
|
+
const n = "http://www.w3.org/2000/svg", s = document.createElementNS(n, "svg"), i = document.createElementNS(n, "foreignObject");
|
|
73
|
+
return s.setAttribute("width", `${e}`), s.setAttribute("height", `${r}`), s.setAttribute("viewBox", `0 0 ${e} ${r}`), i.setAttribute("width", "100%"), i.setAttribute("height", "100%"), i.setAttribute("x", "0"), i.setAttribute("y", "0"), i.setAttribute("externalResourcesRequired", "true"), s.appendChild(i), i.appendChild(t), X(s);
|
|
74
|
+
}
|
|
75
|
+
const l = (t, e) => {
|
|
76
|
+
if (t instanceof e)
|
|
77
|
+
return !0;
|
|
78
|
+
const r = Object.getPrototypeOf(t);
|
|
79
|
+
return r === null ? !1 : r.constructor.name === e.name || l(r, e);
|
|
80
|
+
};
|
|
81
|
+
function K(t) {
|
|
82
|
+
const e = t.getPropertyValue("content");
|
|
83
|
+
return `${t.cssText} content: '${e.replace(/'|"/g, "")}';`;
|
|
84
|
+
}
|
|
85
|
+
function Q(t, e) {
|
|
86
|
+
return A(e).map((r) => {
|
|
87
|
+
const n = t.getPropertyValue(r), s = t.getPropertyPriority(r);
|
|
88
|
+
return `${r}: ${n}${s ? " !important" : ""};`;
|
|
89
|
+
}).join(" ");
|
|
90
|
+
}
|
|
91
|
+
function Y(t, e, r, n) {
|
|
92
|
+
const s = `.${t}:${e}`, i = r.cssText ? K(r) : Q(r, n);
|
|
93
|
+
return document.createTextNode(`${s}{${i}}`);
|
|
94
|
+
}
|
|
95
|
+
function C(t, e, r, n) {
|
|
96
|
+
const s = window.getComputedStyle(t, r), i = s.getPropertyValue("content");
|
|
97
|
+
if (i === "" || i === "none")
|
|
98
|
+
return;
|
|
99
|
+
const c = j();
|
|
100
|
+
try {
|
|
101
|
+
e.className = `${e.className} ${c}`;
|
|
102
|
+
} catch {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const a = document.createElement("style");
|
|
106
|
+
a.appendChild(Y(c, r, s, n)), e.appendChild(a);
|
|
107
|
+
}
|
|
108
|
+
function Z(t, e, r) {
|
|
109
|
+
C(t, e, ":before", r), C(t, e, ":after", r);
|
|
110
|
+
}
|
|
111
|
+
const P = "application/font-woff", $ = "image/jpeg", N = {
|
|
112
|
+
woff: P,
|
|
113
|
+
woff2: P,
|
|
114
|
+
ttf: "application/font-truetype",
|
|
115
|
+
eot: "application/vnd.ms-fontobject",
|
|
116
|
+
png: "image/png",
|
|
117
|
+
jpg: $,
|
|
118
|
+
jpeg: $,
|
|
119
|
+
gif: "image/gif",
|
|
120
|
+
tiff: "image/tiff",
|
|
121
|
+
svg: "image/svg+xml",
|
|
122
|
+
webp: "image/webp"
|
|
123
|
+
};
|
|
124
|
+
function tt(t) {
|
|
125
|
+
const e = /\.([^./]*?)$/g.exec(t);
|
|
126
|
+
return e ? e[1] : "";
|
|
127
|
+
}
|
|
128
|
+
function x(t) {
|
|
129
|
+
const e = tt(t).toLowerCase();
|
|
130
|
+
return N[e] || "";
|
|
131
|
+
}
|
|
132
|
+
function et(t) {
|
|
133
|
+
return t.split(/,/)[1];
|
|
134
|
+
}
|
|
135
|
+
function E(t) {
|
|
136
|
+
return t.search(/^(data:)/) !== -1;
|
|
137
|
+
}
|
|
138
|
+
function rt(t, e) {
|
|
139
|
+
return `data:${e};base64,${t}`;
|
|
140
|
+
}
|
|
141
|
+
async function D(t, e, r) {
|
|
142
|
+
const n = await fetch(t, e);
|
|
143
|
+
if (n.status === 404)
|
|
144
|
+
throw new Error(`Resource "${n.url}" not found`);
|
|
145
|
+
const s = await n.blob();
|
|
146
|
+
return new Promise((i, c) => {
|
|
147
|
+
const a = new FileReader();
|
|
148
|
+
a.onerror = c, a.onloadend = () => {
|
|
149
|
+
try {
|
|
150
|
+
i(r({ res: n, result: a.result }));
|
|
151
|
+
} catch (o) {
|
|
152
|
+
c(o);
|
|
153
|
+
}
|
|
154
|
+
}, a.readAsDataURL(s);
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
const b = {};
|
|
158
|
+
function nt(t, e, r) {
|
|
159
|
+
let n = t.replace(/\?.*/, "");
|
|
160
|
+
return r && (n = t), /ttf|otf|eot|woff2?/i.test(n) && (n = n.replace(/.*\//, "")), e ? `[${e}]${n}` : n;
|
|
161
|
+
}
|
|
162
|
+
async function R(t, e, r) {
|
|
163
|
+
const n = nt(t, e, r.includeQueryParams);
|
|
164
|
+
if (b[n] != null)
|
|
165
|
+
return b[n];
|
|
166
|
+
r.cacheBust && (t += (/\?/.test(t) ? "&" : "?") + (/* @__PURE__ */ new Date()).getTime());
|
|
167
|
+
let s;
|
|
168
|
+
try {
|
|
169
|
+
const i = await D(t, r.fetchRequestInit, ({ res: c, result: a }) => (e || (e = c.headers.get("Content-Type") || ""), et(a)));
|
|
170
|
+
s = rt(i, e);
|
|
171
|
+
} catch (i) {
|
|
172
|
+
s = r.imagePlaceholder || "";
|
|
173
|
+
let c = `Failed to fetch resource: ${t}`;
|
|
174
|
+
i && (c = typeof i == "string" ? i : i.message), c && console.warn(c);
|
|
175
|
+
}
|
|
176
|
+
return b[n] = s, s;
|
|
177
|
+
}
|
|
178
|
+
async function it(t) {
|
|
179
|
+
const e = t.toDataURL();
|
|
180
|
+
return e === "data:," ? t.cloneNode(!1) : w(e);
|
|
181
|
+
}
|
|
182
|
+
async function st(t, e) {
|
|
183
|
+
if (t.currentSrc) {
|
|
184
|
+
const i = document.createElement("canvas"), c = i.getContext("2d");
|
|
185
|
+
i.width = t.clientWidth, i.height = t.clientHeight, c == null || c.drawImage(t, 0, 0, i.width, i.height);
|
|
186
|
+
const a = i.toDataURL();
|
|
187
|
+
return w(a);
|
|
188
|
+
}
|
|
189
|
+
const r = t.poster, n = x(r), s = await R(r, n, e);
|
|
190
|
+
return w(s);
|
|
191
|
+
}
|
|
192
|
+
async function ct(t, e) {
|
|
193
|
+
var r;
|
|
194
|
+
try {
|
|
195
|
+
if (!((r = t == null ? void 0 : t.contentDocument) === null || r === void 0) && r.body)
|
|
196
|
+
return await p(t.contentDocument.body, e, !0);
|
|
197
|
+
} catch {
|
|
198
|
+
}
|
|
199
|
+
return t.cloneNode(!1);
|
|
200
|
+
}
|
|
201
|
+
async function at(t, e) {
|
|
202
|
+
return l(t, HTMLCanvasElement) ? it(t) : l(t, HTMLVideoElement) ? st(t, e) : l(t, HTMLIFrameElement) ? ct(t, e) : t.cloneNode(v(t));
|
|
203
|
+
}
|
|
204
|
+
const ot = (t) => t.tagName != null && t.tagName.toUpperCase() === "SLOT", v = (t) => t.tagName != null && t.tagName.toUpperCase() === "SVG";
|
|
205
|
+
async function lt(t, e, r) {
|
|
206
|
+
var n, s;
|
|
207
|
+
if (v(e))
|
|
208
|
+
return e;
|
|
209
|
+
let i = [];
|
|
210
|
+
return ot(t) && t.assignedNodes ? i = m(t.assignedNodes()) : l(t, HTMLIFrameElement) && (!((n = t.contentDocument) === null || n === void 0) && n.body) ? i = m(t.contentDocument.body.childNodes) : i = m(((s = t.shadowRoot) !== null && s !== void 0 ? s : t).childNodes), i.length === 0 || l(t, HTMLVideoElement) || await i.reduce((c, a) => c.then(() => p(a, r)).then((o) => {
|
|
211
|
+
o && e.appendChild(o);
|
|
212
|
+
}), Promise.resolve()), e;
|
|
213
|
+
}
|
|
214
|
+
function ut(t, e, r) {
|
|
215
|
+
const n = e.style;
|
|
216
|
+
if (!n)
|
|
217
|
+
return;
|
|
218
|
+
const s = window.getComputedStyle(t);
|
|
219
|
+
s.cssText ? (n.cssText = s.cssText, n.transformOrigin = s.transformOrigin) : A(r).forEach((i) => {
|
|
220
|
+
let c = s.getPropertyValue(i);
|
|
221
|
+
i === "font-size" && c.endsWith("px") && (c = `${Math.floor(parseFloat(c.substring(0, c.length - 2))) - 0.1}px`), l(t, HTMLIFrameElement) && i === "display" && c === "inline" && (c = "block"), i === "d" && e.getAttribute("d") && (c = `path(${e.getAttribute("d")})`), n.setProperty(i, c, s.getPropertyPriority(i));
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
function ft(t, e) {
|
|
225
|
+
l(t, HTMLTextAreaElement) && (e.innerHTML = t.value), l(t, HTMLInputElement) && e.setAttribute("value", t.value);
|
|
226
|
+
}
|
|
227
|
+
function ht(t, e) {
|
|
228
|
+
if (l(t, HTMLSelectElement)) {
|
|
229
|
+
const r = e, n = Array.from(r.children).find((s) => t.value === s.getAttribute("value"));
|
|
230
|
+
n && n.setAttribute("selected", "");
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
function mt(t, e, r) {
|
|
234
|
+
return l(e, Element) && (ut(t, e, r), Z(t, e, r), ft(t, e), ht(t, e)), e;
|
|
235
|
+
}
|
|
236
|
+
async function gt(t, e) {
|
|
237
|
+
const r = t.querySelectorAll ? t.querySelectorAll("use") : [];
|
|
238
|
+
if (r.length === 0)
|
|
239
|
+
return t;
|
|
240
|
+
const n = {};
|
|
241
|
+
for (let i = 0; i < r.length; i++) {
|
|
242
|
+
const a = r[i].getAttribute("xlink:href");
|
|
243
|
+
if (a) {
|
|
244
|
+
const o = t.querySelector(a), f = document.querySelector(a);
|
|
245
|
+
!o && f && !n[a] && (n[a] = await p(f, e, !0));
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
const s = Object.values(n);
|
|
249
|
+
if (s.length) {
|
|
250
|
+
const i = "http://www.w3.org/1999/xhtml", c = document.createElementNS(i, "svg");
|
|
251
|
+
c.setAttribute("xmlns", i), c.style.position = "absolute", c.style.width = "0", c.style.height = "0", c.style.overflow = "hidden", c.style.display = "none";
|
|
252
|
+
const a = document.createElementNS(i, "defs");
|
|
253
|
+
c.appendChild(a);
|
|
254
|
+
for (let o = 0; o < s.length; o++)
|
|
255
|
+
a.appendChild(s[o]);
|
|
256
|
+
t.appendChild(c);
|
|
257
|
+
}
|
|
258
|
+
return t;
|
|
259
|
+
}
|
|
260
|
+
async function p(t, e, r) {
|
|
261
|
+
return !r && e.filter && !e.filter(t) ? null : Promise.resolve(t).then((n) => at(n, e)).then((n) => lt(t, n, e)).then((n) => mt(t, n, e)).then((n) => gt(n, e));
|
|
262
|
+
}
|
|
263
|
+
const U = /url\((['"]?)([^'"]+?)\1\)/g, dt = /url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g, yt = /src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;
|
|
264
|
+
function wt(t) {
|
|
265
|
+
const e = t.replace(/([.*+?^${}()|\[\]\/\\])/g, "\\$1");
|
|
266
|
+
return new RegExp(`(url\\(['"]?)(${e})(['"]?\\))`, "g");
|
|
267
|
+
}
|
|
268
|
+
function pt(t) {
|
|
269
|
+
const e = [];
|
|
270
|
+
return t.replace(U, (r, n, s) => (e.push(s), r)), e.filter((r) => !E(r));
|
|
271
|
+
}
|
|
272
|
+
async function St(t, e, r, n, s) {
|
|
273
|
+
try {
|
|
274
|
+
const i = r ? W(e, r) : e, c = x(e);
|
|
275
|
+
let a;
|
|
276
|
+
return s || (a = await R(i, c, n)), t.replace(wt(e), `$1${a}$3`);
|
|
277
|
+
} catch {
|
|
278
|
+
}
|
|
279
|
+
return t;
|
|
280
|
+
}
|
|
281
|
+
function bt(t, { preferredFontFormat: e }) {
|
|
282
|
+
return e ? t.replace(yt, (r) => {
|
|
283
|
+
for (; ; ) {
|
|
284
|
+
const [n, , s] = dt.exec(r) || [];
|
|
285
|
+
if (!s)
|
|
286
|
+
return "";
|
|
287
|
+
if (s === e)
|
|
288
|
+
return `src: ${n};`;
|
|
289
|
+
}
|
|
290
|
+
}) : t;
|
|
291
|
+
}
|
|
292
|
+
function H(t) {
|
|
293
|
+
return t.search(U) !== -1;
|
|
294
|
+
}
|
|
295
|
+
async function V(t, e, r) {
|
|
296
|
+
if (!H(t))
|
|
297
|
+
return t;
|
|
298
|
+
const n = bt(t, r);
|
|
299
|
+
return pt(n).reduce((i, c) => i.then((a) => St(a, c, e, r)), Promise.resolve(n));
|
|
300
|
+
}
|
|
301
|
+
async function d(t, e, r) {
|
|
302
|
+
var n;
|
|
303
|
+
const s = (n = e.style) === null || n === void 0 ? void 0 : n.getPropertyValue(t);
|
|
304
|
+
if (s) {
|
|
305
|
+
const i = await V(s, null, r);
|
|
306
|
+
return e.style.setProperty(t, i, e.style.getPropertyPriority(t)), !0;
|
|
307
|
+
}
|
|
308
|
+
return !1;
|
|
309
|
+
}
|
|
310
|
+
async function Et(t, e) {
|
|
311
|
+
await d("background", t, e) || await d("background-image", t, e), await d("mask", t, e) || await d("-webkit-mask", t, e) || await d("mask-image", t, e) || await d("-webkit-mask-image", t, e);
|
|
312
|
+
}
|
|
313
|
+
async function xt(t, e) {
|
|
314
|
+
const r = l(t, HTMLImageElement);
|
|
315
|
+
if (!(r && !E(t.src)) && !(l(t, SVGImageElement) && !E(t.href.baseVal)))
|
|
316
|
+
return;
|
|
317
|
+
const n = r ? t.src : t.href.baseVal, s = await R(n, x(n), e);
|
|
318
|
+
await new Promise((i, c) => {
|
|
319
|
+
t.onload = i, t.onerror = e.onImageErrorHandler ? (...o) => {
|
|
320
|
+
try {
|
|
321
|
+
i(e.onImageErrorHandler(...o));
|
|
322
|
+
} catch (f) {
|
|
323
|
+
c(f);
|
|
324
|
+
}
|
|
325
|
+
} : c;
|
|
326
|
+
const a = t;
|
|
327
|
+
a.decode && (a.decode = i), a.loading === "lazy" && (a.loading = "eager"), r ? (t.srcset = "", t.src = s) : t.href.baseVal = s;
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
async function Rt(t, e) {
|
|
331
|
+
const n = m(t.childNodes).map((s) => M(s, e));
|
|
332
|
+
await Promise.all(n).then(() => t);
|
|
333
|
+
}
|
|
334
|
+
async function M(t, e) {
|
|
335
|
+
l(t, Element) && (await Et(t, e), await xt(t, e), await Rt(t, e));
|
|
336
|
+
}
|
|
337
|
+
function Ct(t, e) {
|
|
338
|
+
const { style: r } = t;
|
|
339
|
+
e.backgroundColor && (r.backgroundColor = e.backgroundColor), e.width && (r.width = `${e.width}px`), e.height && (r.height = `${e.height}px`);
|
|
340
|
+
const n = e.style;
|
|
341
|
+
return n != null && Object.keys(n).forEach((s) => {
|
|
342
|
+
r[s] = n[s];
|
|
343
|
+
}), t;
|
|
344
|
+
}
|
|
345
|
+
const T = {};
|
|
346
|
+
async function F(t) {
|
|
347
|
+
let e = T[t];
|
|
348
|
+
if (e != null)
|
|
349
|
+
return e;
|
|
350
|
+
const n = await (await fetch(t)).text();
|
|
351
|
+
return e = { url: t, cssText: n }, T[t] = e, e;
|
|
352
|
+
}
|
|
353
|
+
async function L(t, e) {
|
|
354
|
+
let r = t.cssText;
|
|
355
|
+
const n = /url\(["']?([^"')]+)["']?\)/g, i = (r.match(/url\([^)]+\)/g) || []).map(async (c) => {
|
|
356
|
+
let a = c.replace(n, "$1");
|
|
357
|
+
return a.startsWith("https://") || (a = new URL(a, t.url).href), D(a, e.fetchRequestInit, ({ result: o }) => (r = r.replace(c, `url(${o})`), [c, o]));
|
|
358
|
+
});
|
|
359
|
+
return Promise.all(i).then(() => r);
|
|
360
|
+
}
|
|
361
|
+
function I(t) {
|
|
362
|
+
if (t == null)
|
|
363
|
+
return [];
|
|
364
|
+
const e = [], r = /(\/\*[\s\S]*?\*\/)/gi;
|
|
365
|
+
let n = t.replace(r, "");
|
|
366
|
+
const s = new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})", "gi");
|
|
367
|
+
for (; ; ) {
|
|
368
|
+
const o = s.exec(n);
|
|
369
|
+
if (o === null)
|
|
370
|
+
break;
|
|
371
|
+
e.push(o[0]);
|
|
372
|
+
}
|
|
373
|
+
n = n.replace(s, "");
|
|
374
|
+
const i = /@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi, c = "((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})", a = new RegExp(c, "gi");
|
|
375
|
+
for (; ; ) {
|
|
376
|
+
let o = i.exec(n);
|
|
377
|
+
if (o === null) {
|
|
378
|
+
if (o = a.exec(n), o === null)
|
|
379
|
+
break;
|
|
380
|
+
i.lastIndex = a.lastIndex;
|
|
381
|
+
} else
|
|
382
|
+
a.lastIndex = i.lastIndex;
|
|
383
|
+
e.push(o[0]);
|
|
384
|
+
}
|
|
385
|
+
return e;
|
|
386
|
+
}
|
|
387
|
+
async function Pt(t, e) {
|
|
388
|
+
const r = [], n = [];
|
|
389
|
+
return t.forEach((s) => {
|
|
390
|
+
if ("cssRules" in s)
|
|
391
|
+
try {
|
|
392
|
+
m(s.cssRules || []).forEach((i, c) => {
|
|
393
|
+
if (i.type === CSSRule.IMPORT_RULE) {
|
|
394
|
+
let a = c + 1;
|
|
395
|
+
const o = i.href, f = F(o).then((h) => L(h, e)).then((h) => I(h).forEach((S) => {
|
|
396
|
+
try {
|
|
397
|
+
s.insertRule(S, S.startsWith("@import") ? a += 1 : s.cssRules.length);
|
|
398
|
+
} catch (_) {
|
|
399
|
+
console.error("Error inserting rule from remote css", {
|
|
400
|
+
rule: S,
|
|
401
|
+
error: _
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
})).catch((h) => {
|
|
405
|
+
console.error("Error loading remote css", h.toString());
|
|
406
|
+
});
|
|
407
|
+
n.push(f);
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
} catch (i) {
|
|
411
|
+
const c = t.find((a) => a.href == null) || document.styleSheets[0];
|
|
412
|
+
s.href != null && n.push(F(s.href).then((a) => L(a, e)).then((a) => I(a).forEach((o) => {
|
|
413
|
+
c.insertRule(o, c.cssRules.length);
|
|
414
|
+
})).catch((a) => {
|
|
415
|
+
console.error("Error loading remote stylesheet", a);
|
|
416
|
+
})), console.error("Error inlining remote css file", i);
|
|
417
|
+
}
|
|
418
|
+
}), Promise.all(n).then(() => (t.forEach((s) => {
|
|
419
|
+
if ("cssRules" in s)
|
|
420
|
+
try {
|
|
421
|
+
m(s.cssRules || []).forEach((i) => {
|
|
422
|
+
r.push(i);
|
|
423
|
+
});
|
|
424
|
+
} catch (i) {
|
|
425
|
+
console.error(`Error while reading CSS rules from ${s.href}`, i);
|
|
426
|
+
}
|
|
427
|
+
}), r));
|
|
428
|
+
}
|
|
429
|
+
function $t(t) {
|
|
430
|
+
return t.filter((e) => e.type === CSSRule.FONT_FACE_RULE).filter((e) => H(e.style.getPropertyValue("src")));
|
|
431
|
+
}
|
|
432
|
+
async function Tt(t, e) {
|
|
433
|
+
if (t.ownerDocument == null)
|
|
434
|
+
throw new Error("Provided element is not within a Document");
|
|
435
|
+
const r = m(t.ownerDocument.styleSheets), n = await Pt(r, e);
|
|
436
|
+
return $t(n);
|
|
437
|
+
}
|
|
438
|
+
function O(t) {
|
|
439
|
+
return t.trim().replace(/["']/g, "");
|
|
440
|
+
}
|
|
441
|
+
function Ft(t) {
|
|
442
|
+
const e = /* @__PURE__ */ new Set();
|
|
443
|
+
function r(n) {
|
|
444
|
+
(n.style.fontFamily || getComputedStyle(n).fontFamily).split(",").forEach((i) => {
|
|
445
|
+
e.add(O(i));
|
|
446
|
+
}), Array.from(n.children).forEach((i) => {
|
|
447
|
+
i instanceof HTMLElement && r(i);
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
return r(t), e;
|
|
451
|
+
}
|
|
452
|
+
async function Lt(t, e) {
|
|
453
|
+
const r = await Tt(t, e), n = Ft(t);
|
|
454
|
+
return (await Promise.all(r.filter((i) => n.has(O(i.style.fontFamily))).map((i) => {
|
|
455
|
+
const c = i.parentStyleSheet ? i.parentStyleSheet.href : null;
|
|
456
|
+
return V(i.cssText, c, e);
|
|
457
|
+
}))).join(`
|
|
458
|
+
`);
|
|
459
|
+
}
|
|
460
|
+
async function It(t, e) {
|
|
461
|
+
const r = e.fontEmbedCSS != null ? e.fontEmbedCSS : e.skipFonts ? null : await Lt(t, e);
|
|
462
|
+
if (r) {
|
|
463
|
+
const n = document.createElement("style"), s = document.createTextNode(r);
|
|
464
|
+
n.appendChild(s), t.firstChild ? t.insertBefore(n, t.firstChild) : t.appendChild(n);
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
async function At(t, e = {}) {
|
|
468
|
+
const { width: r, height: n } = k(t, e), s = await p(t, e, !0);
|
|
469
|
+
return await It(s, e), await M(s, e), Ct(s, e), await J(s, r, n);
|
|
470
|
+
}
|
|
471
|
+
async function kt(t, e = {}) {
|
|
472
|
+
const { width: r, height: n } = k(t, e), s = await At(t, e), i = await w(s), c = document.createElement("canvas"), a = c.getContext("2d"), o = e.pixelRatio || B(), f = e.canvasWidth || r, h = e.canvasHeight || n;
|
|
473
|
+
return c.width = f * o, c.height = h * o, e.skipAutoScale || G(c), c.style.width = `${f}`, c.style.height = `${h}`, e.backgroundColor && (a.fillStyle = e.backgroundColor, a.fillRect(0, 0, c.width, c.height)), a.drawImage(i, 0, 0, c.width, c.height), c;
|
|
474
|
+
}
|
|
475
|
+
async function Dt(t, e = {}) {
|
|
476
|
+
return (await kt(t, e)).toDataURL("image/jpeg", e.quality || 1);
|
|
477
|
+
}
|
|
478
|
+
export {
|
|
479
|
+
kt as toCanvas,
|
|
480
|
+
Dt as toJpeg,
|
|
481
|
+
At as toSvg
|
|
482
|
+
};
|