likec4 1.17.1 → 1.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/{dist/__app__ → __app__}/index.html +0 -1
- package/{dist/__app__ → __app__}/react/likec4.tsx +16 -30
- package/__app__/src/chunks/-index-overview-C9eO_hFX.js +309 -0
- package/__app__/src/chunks/-view-lazy-data-CI4xD57c.js +9 -0
- package/__app__/src/chunks/index-KI-kE60c.js +465 -0
- package/__app__/src/chunks/likec4-CusAw_j6.js +6106 -0
- package/__app__/src/chunks/main-DY2KbFcO.js +24136 -0
- package/__app__/src/chunks/mantine-B_6mKFFA.js +13671 -0
- package/__app__/src/chunks/tanstack-router-BBWuTKWO.js +2373 -0
- package/__app__/src/icons.js +9 -0
- package/{dist/__app__ → __app__}/src/main.js +1 -1
- package/{dist/__app__ → __app__}/src/style.css +1 -1
- package/{dist/__app__ → __app__}/webcomponent/webcomponent.js +11351 -10812
- package/dist/chunks/prompt.mjs +35 -35
- package/dist/cli/index.mjs +225 -191
- package/dist/index.d.mts +760 -1787
- package/dist/index.d.ts +760 -1787
- package/dist/index.mjs +1 -1
- package/dist/model/index.d.mts +258 -0
- package/dist/model/index.d.ts +258 -0
- package/dist/model/index.mjs +1 -0
- package/dist/shared/likec4.CbSUX9bc.mjs +1853 -0
- package/dist/shared/likec4.DCwaTTuF.d.mts +1625 -0
- package/dist/shared/likec4.DCwaTTuF.d.ts +1625 -0
- package/dist/shared/likec4.LktBLTET.mjs +9 -0
- package/package.json +75 -73
- package/react/index.d.ts +328 -628
- package/react/index.js +39830 -0
- package/react/style.css +1 -1
- package/dist/__app__/src/chunks/-index-overview-DrCqsLHx.js +0 -309
- package/dist/__app__/src/chunks/-view-lazy-data-WZmbIsHq.js +0 -9
- package/dist/__app__/src/chunks/index-CIsxIzOH.js +0 -465
- package/dist/__app__/src/chunks/likec4-DF_Jsv_p.js +0 -6109
- package/dist/__app__/src/chunks/main-E2hyQKFO.js +0 -23847
- package/dist/__app__/src/chunks/mantine-BzD51ZKm.js +0 -13484
- package/dist/__app__/src/chunks/tanstack-router-CF1kJvtP.js +0 -2373
- package/dist/__app__/src/icons.js +0 -9
- package/dist/shared/likec4.BkLj38-D.mjs +0 -1824
- package/react/index.mjs +0 -40096
- /package/{dist/__app__ → __app__}/favicon.ico +0 -0
- /package/{dist/__app__ → __app__}/favicon.svg +0 -0
- /package/{dist/__app__ → __app__}/robots.txt +0 -0
- /package/{dist/__app__ → __app__}/src/const.js +0 -0
|
@@ -0,0 +1,465 @@
|
|
|
1
|
+
function H(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"), i = r.createElement("a");
|
|
9
|
+
return r.head.appendChild(n), r.body.appendChild(i), e && (n.href = e), i.href = t, i.href;
|
|
10
|
+
}
|
|
11
|
+
const M = /* @__PURE__ */ (() => {
|
|
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 f(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
|
+
function d(t, e) {
|
|
26
|
+
const n = (t.ownerDocument.defaultView || window).getComputedStyle(t).getPropertyValue(e);
|
|
27
|
+
return n ? parseFloat(n.replace("px", "")) : 0;
|
|
28
|
+
}
|
|
29
|
+
function O(t) {
|
|
30
|
+
const e = d(t, "border-left-width"), r = d(t, "border-right-width");
|
|
31
|
+
return t.clientWidth + e + r;
|
|
32
|
+
}
|
|
33
|
+
function _(t) {
|
|
34
|
+
const e = d(t, "border-top-width"), r = d(t, "border-bottom-width");
|
|
35
|
+
return t.clientHeight + e + r;
|
|
36
|
+
}
|
|
37
|
+
function I(t, e = {}) {
|
|
38
|
+
const r = e.width || O(t), n = e.height || _(t);
|
|
39
|
+
return { width: r, height: n };
|
|
40
|
+
}
|
|
41
|
+
function W() {
|
|
42
|
+
let t, e;
|
|
43
|
+
try {
|
|
44
|
+
e = process;
|
|
45
|
+
} catch {
|
|
46
|
+
}
|
|
47
|
+
const r = e && e.env ? e.env.devicePixelRatio : null;
|
|
48
|
+
return r && (t = parseInt(r, 10), Number.isNaN(t) && (t = 1)), t || window.devicePixelRatio || 1;
|
|
49
|
+
}
|
|
50
|
+
const u = 16384;
|
|
51
|
+
function B(t) {
|
|
52
|
+
(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));
|
|
53
|
+
}
|
|
54
|
+
function q(t, e = {}) {
|
|
55
|
+
return t.toBlob ? new Promise((r) => {
|
|
56
|
+
t.toBlob(r, e.type ? e.type : "image/png", e.quality ? e.quality : 1);
|
|
57
|
+
}) : new Promise((r) => {
|
|
58
|
+
const n = window.atob(t.toDataURL(e.type ? e.type : void 0, e.quality ? e.quality : void 0).split(",")[1]), i = n.length, s = new Uint8Array(i);
|
|
59
|
+
for (let c = 0; c < i; c += 1)
|
|
60
|
+
s[c] = n.charCodeAt(c);
|
|
61
|
+
r(new Blob([s], {
|
|
62
|
+
type: e.type ? e.type : "image/png"
|
|
63
|
+
}));
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
function y(t) {
|
|
67
|
+
return new Promise((e, r) => {
|
|
68
|
+
const n = new Image();
|
|
69
|
+
n.decode = () => e(n), n.onload = () => e(n), n.onerror = r, n.crossOrigin = "anonymous", n.decoding = "async", n.src = t;
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
async function j(t) {
|
|
73
|
+
return Promise.resolve().then(() => new XMLSerializer().serializeToString(t)).then(encodeURIComponent).then((e) => `data:image/svg+xml;charset=utf-8,${e}`);
|
|
74
|
+
}
|
|
75
|
+
async function z(t, e, r) {
|
|
76
|
+
const n = "http://www.w3.org/2000/svg", i = document.createElementNS(n, "svg"), s = document.createElementNS(n, "foreignObject");
|
|
77
|
+
return i.setAttribute("width", `${e}`), i.setAttribute("height", `${r}`), i.setAttribute("viewBox", `0 0 ${e} ${r}`), s.setAttribute("width", "100%"), s.setAttribute("height", "100%"), s.setAttribute("x", "0"), s.setAttribute("y", "0"), s.setAttribute("externalResourcesRequired", "true"), i.appendChild(s), s.appendChild(t), j(i);
|
|
78
|
+
}
|
|
79
|
+
const l = (t, e) => {
|
|
80
|
+
if (t instanceof e)
|
|
81
|
+
return !0;
|
|
82
|
+
const r = Object.getPrototypeOf(t);
|
|
83
|
+
return r === null ? !1 : r.constructor.name === e.name || l(r, e);
|
|
84
|
+
};
|
|
85
|
+
function G(t) {
|
|
86
|
+
const e = t.getPropertyValue("content");
|
|
87
|
+
return `${t.cssText} content: '${e.replace(/'|"/g, "")}';`;
|
|
88
|
+
}
|
|
89
|
+
function X(t) {
|
|
90
|
+
return f(t).map((e) => {
|
|
91
|
+
const r = t.getPropertyValue(e), n = t.getPropertyPriority(e);
|
|
92
|
+
return `${e}: ${r}${n ? " !important" : ""};`;
|
|
93
|
+
}).join(" ");
|
|
94
|
+
}
|
|
95
|
+
function K(t, e, r) {
|
|
96
|
+
const n = `.${t}:${e}`, i = r.cssText ? G(r) : X(r);
|
|
97
|
+
return document.createTextNode(`${n}{${i}}`);
|
|
98
|
+
}
|
|
99
|
+
function R(t, e, r) {
|
|
100
|
+
const n = window.getComputedStyle(t, r), i = n.getPropertyValue("content");
|
|
101
|
+
if (i === "" || i === "none")
|
|
102
|
+
return;
|
|
103
|
+
const s = M();
|
|
104
|
+
try {
|
|
105
|
+
e.className = `${e.className} ${s}`;
|
|
106
|
+
} catch {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const c = document.createElement("style");
|
|
110
|
+
c.appendChild(K(s, r, n)), e.appendChild(c);
|
|
111
|
+
}
|
|
112
|
+
function J(t, e) {
|
|
113
|
+
R(t, e, ":before"), R(t, e, ":after");
|
|
114
|
+
}
|
|
115
|
+
const C = "application/font-woff", P = "image/jpeg", Q = {
|
|
116
|
+
woff: C,
|
|
117
|
+
woff2: C,
|
|
118
|
+
ttf: "application/font-truetype",
|
|
119
|
+
eot: "application/vnd.ms-fontobject",
|
|
120
|
+
png: "image/png",
|
|
121
|
+
jpg: P,
|
|
122
|
+
jpeg: P,
|
|
123
|
+
gif: "image/gif",
|
|
124
|
+
tiff: "image/tiff",
|
|
125
|
+
svg: "image/svg+xml",
|
|
126
|
+
webp: "image/webp"
|
|
127
|
+
};
|
|
128
|
+
function Y(t) {
|
|
129
|
+
const e = /\.([^./]*?)$/g.exec(t);
|
|
130
|
+
return e ? e[1] : "";
|
|
131
|
+
}
|
|
132
|
+
function E(t) {
|
|
133
|
+
const e = Y(t).toLowerCase();
|
|
134
|
+
return Q[e] || "";
|
|
135
|
+
}
|
|
136
|
+
function Z(t) {
|
|
137
|
+
return t.split(/,/)[1];
|
|
138
|
+
}
|
|
139
|
+
function S(t) {
|
|
140
|
+
return t.search(/^(data:)/) !== -1;
|
|
141
|
+
}
|
|
142
|
+
function N(t, e) {
|
|
143
|
+
return `data:${e};base64,${t}`;
|
|
144
|
+
}
|
|
145
|
+
async function F(t, e, r) {
|
|
146
|
+
const n = await fetch(t, e);
|
|
147
|
+
if (n.status === 404)
|
|
148
|
+
throw new Error(`Resource "${n.url}" not found`);
|
|
149
|
+
const i = await n.blob();
|
|
150
|
+
return new Promise((s, c) => {
|
|
151
|
+
const a = new FileReader();
|
|
152
|
+
a.onerror = c, a.onloadend = () => {
|
|
153
|
+
try {
|
|
154
|
+
s(r({ res: n, result: a.result }));
|
|
155
|
+
} catch (o) {
|
|
156
|
+
c(o);
|
|
157
|
+
}
|
|
158
|
+
}, a.readAsDataURL(i);
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
const b = {};
|
|
162
|
+
function tt(t, e, r) {
|
|
163
|
+
let n = t.replace(/\?.*/, "");
|
|
164
|
+
return r && (n = t), /ttf|otf|eot|woff2?/i.test(n) && (n = n.replace(/.*\//, "")), e ? `[${e}]${n}` : n;
|
|
165
|
+
}
|
|
166
|
+
async function x(t, e, r) {
|
|
167
|
+
const n = tt(t, e, r.includeQueryParams);
|
|
168
|
+
if (b[n] != null)
|
|
169
|
+
return b[n];
|
|
170
|
+
r.cacheBust && (t += (/\?/.test(t) ? "&" : "?") + (/* @__PURE__ */ new Date()).getTime());
|
|
171
|
+
let i;
|
|
172
|
+
try {
|
|
173
|
+
const s = await F(t, r.fetchRequestInit, ({ res: c, result: a }) => (e || (e = c.headers.get("Content-Type") || ""), Z(a)));
|
|
174
|
+
i = N(s, e);
|
|
175
|
+
} catch (s) {
|
|
176
|
+
i = r.imagePlaceholder || "";
|
|
177
|
+
let c = `Failed to fetch resource: ${t}`;
|
|
178
|
+
s && (c = typeof s == "string" ? s : s.message), c && console.warn(c);
|
|
179
|
+
}
|
|
180
|
+
return b[n] = i, i;
|
|
181
|
+
}
|
|
182
|
+
async function et(t) {
|
|
183
|
+
const e = t.toDataURL();
|
|
184
|
+
return e === "data:," ? t.cloneNode(!1) : y(e);
|
|
185
|
+
}
|
|
186
|
+
async function nt(t, e) {
|
|
187
|
+
if (t.currentSrc) {
|
|
188
|
+
const s = document.createElement("canvas"), c = s.getContext("2d");
|
|
189
|
+
s.width = t.clientWidth, s.height = t.clientHeight, c?.drawImage(t, 0, 0, s.width, s.height);
|
|
190
|
+
const a = s.toDataURL();
|
|
191
|
+
return y(a);
|
|
192
|
+
}
|
|
193
|
+
const r = t.poster, n = E(r), i = await x(r, n, e);
|
|
194
|
+
return y(i);
|
|
195
|
+
}
|
|
196
|
+
async function rt(t) {
|
|
197
|
+
var e;
|
|
198
|
+
try {
|
|
199
|
+
if (!((e = t?.contentDocument) === null || e === void 0) && e.body)
|
|
200
|
+
return await w(t.contentDocument.body, {}, !0);
|
|
201
|
+
} catch {
|
|
202
|
+
}
|
|
203
|
+
return t.cloneNode(!1);
|
|
204
|
+
}
|
|
205
|
+
async function it(t, e) {
|
|
206
|
+
return l(t, HTMLCanvasElement) ? et(t) : l(t, HTMLVideoElement) ? nt(t, e) : l(t, HTMLIFrameElement) ? rt(t) : t.cloneNode(!1);
|
|
207
|
+
}
|
|
208
|
+
const st = (t) => t.tagName != null && t.tagName.toUpperCase() === "SLOT";
|
|
209
|
+
async function ct(t, e, r) {
|
|
210
|
+
var n, i;
|
|
211
|
+
let s = [];
|
|
212
|
+
return st(t) && t.assignedNodes ? s = f(t.assignedNodes()) : l(t, HTMLIFrameElement) && (!((n = t.contentDocument) === null || n === void 0) && n.body) ? s = f(t.contentDocument.body.childNodes) : s = f(((i = t.shadowRoot) !== null && i !== void 0 ? i : t).childNodes), s.length === 0 || l(t, HTMLVideoElement) || await s.reduce((c, a) => c.then(() => w(a, r)).then((o) => {
|
|
213
|
+
o && e.appendChild(o);
|
|
214
|
+
}), Promise.resolve()), e;
|
|
215
|
+
}
|
|
216
|
+
function at(t, e) {
|
|
217
|
+
const r = e.style;
|
|
218
|
+
if (!r)
|
|
219
|
+
return;
|
|
220
|
+
const n = window.getComputedStyle(t);
|
|
221
|
+
n.cssText ? (r.cssText = n.cssText, r.transformOrigin = n.transformOrigin) : f(n).forEach((i) => {
|
|
222
|
+
let s = n.getPropertyValue(i);
|
|
223
|
+
i === "font-size" && s.endsWith("px") && (s = `${Math.floor(parseFloat(s.substring(0, s.length - 2))) - 0.1}px`), l(t, HTMLIFrameElement) && i === "display" && s === "inline" && (s = "block"), i === "d" && e.getAttribute("d") && (s = `path(${e.getAttribute("d")})`), r.setProperty(i, s, n.getPropertyPriority(i));
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
function ot(t, e) {
|
|
227
|
+
l(t, HTMLTextAreaElement) && (e.innerHTML = t.value), l(t, HTMLInputElement) && e.setAttribute("value", t.value);
|
|
228
|
+
}
|
|
229
|
+
function lt(t, e) {
|
|
230
|
+
if (l(t, HTMLSelectElement)) {
|
|
231
|
+
const r = e, n = Array.from(r.children).find((i) => t.value === i.getAttribute("value"));
|
|
232
|
+
n && n.setAttribute("selected", "");
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
function ut(t, e) {
|
|
236
|
+
return l(e, Element) && (at(t, e), J(t, e), ot(t, e), lt(t, e)), e;
|
|
237
|
+
}
|
|
238
|
+
async function ft(t, e) {
|
|
239
|
+
const r = t.querySelectorAll ? t.querySelectorAll("use") : [];
|
|
240
|
+
if (r.length === 0)
|
|
241
|
+
return t;
|
|
242
|
+
const n = {};
|
|
243
|
+
for (let s = 0; s < r.length; s++) {
|
|
244
|
+
const a = r[s].getAttribute("xlink:href");
|
|
245
|
+
if (a) {
|
|
246
|
+
const o = t.querySelector(a), g = document.querySelector(a);
|
|
247
|
+
!o && g && !n[a] && (n[a] = await w(g, e, !0));
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
const i = Object.values(n);
|
|
251
|
+
if (i.length) {
|
|
252
|
+
const s = "http://www.w3.org/1999/xhtml", c = document.createElementNS(s, "svg");
|
|
253
|
+
c.setAttribute("xmlns", s), c.style.position = "absolute", c.style.width = "0", c.style.height = "0", c.style.overflow = "hidden", c.style.display = "none";
|
|
254
|
+
const a = document.createElementNS(s, "defs");
|
|
255
|
+
c.appendChild(a);
|
|
256
|
+
for (let o = 0; o < i.length; o++)
|
|
257
|
+
a.appendChild(i[o]);
|
|
258
|
+
t.appendChild(c);
|
|
259
|
+
}
|
|
260
|
+
return t;
|
|
261
|
+
}
|
|
262
|
+
async function w(t, e, r) {
|
|
263
|
+
return !r && e.filter && !e.filter(t) ? null : Promise.resolve(t).then((n) => it(n, e)).then((n) => ct(t, n, e)).then((n) => ut(t, n)).then((n) => ft(n, e));
|
|
264
|
+
}
|
|
265
|
+
const D = /url\((['"]?)([^'"]+?)\1\)/g, ht = /url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g, gt = /src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;
|
|
266
|
+
function mt(t) {
|
|
267
|
+
const e = t.replace(/([.*+?^${}()|\[\]\/\\])/g, "\\$1");
|
|
268
|
+
return new RegExp(`(url\\(['"]?)(${e})(['"]?\\))`, "g");
|
|
269
|
+
}
|
|
270
|
+
function dt(t) {
|
|
271
|
+
const e = [];
|
|
272
|
+
return t.replace(D, (r, n, i) => (e.push(i), r)), e.filter((r) => !S(r));
|
|
273
|
+
}
|
|
274
|
+
async function yt(t, e, r, n, i) {
|
|
275
|
+
try {
|
|
276
|
+
const s = r ? H(e, r) : e, c = E(e);
|
|
277
|
+
let a;
|
|
278
|
+
return i || (a = await x(s, c, n)), t.replace(mt(e), `$1${a}$3`);
|
|
279
|
+
} catch {
|
|
280
|
+
}
|
|
281
|
+
return t;
|
|
282
|
+
}
|
|
283
|
+
function wt(t, { preferredFontFormat: e }) {
|
|
284
|
+
return e ? t.replace(gt, (r) => {
|
|
285
|
+
for (; ; ) {
|
|
286
|
+
const [n, , i] = ht.exec(r) || [];
|
|
287
|
+
if (!i)
|
|
288
|
+
return "";
|
|
289
|
+
if (i === e)
|
|
290
|
+
return `src: ${n};`;
|
|
291
|
+
}
|
|
292
|
+
}) : t;
|
|
293
|
+
}
|
|
294
|
+
function U(t) {
|
|
295
|
+
return t.search(D) !== -1;
|
|
296
|
+
}
|
|
297
|
+
async function k(t, e, r) {
|
|
298
|
+
if (!U(t))
|
|
299
|
+
return t;
|
|
300
|
+
const n = wt(t, r);
|
|
301
|
+
return dt(n).reduce((s, c) => s.then((a) => yt(a, c, e, r)), Promise.resolve(n));
|
|
302
|
+
}
|
|
303
|
+
async function m(t, e, r) {
|
|
304
|
+
var n;
|
|
305
|
+
const i = (n = e.style) === null || n === void 0 ? void 0 : n.getPropertyValue(t);
|
|
306
|
+
if (i) {
|
|
307
|
+
const s = await k(i, null, r);
|
|
308
|
+
return e.style.setProperty(t, s, e.style.getPropertyPriority(t)), !0;
|
|
309
|
+
}
|
|
310
|
+
return !1;
|
|
311
|
+
}
|
|
312
|
+
async function pt(t, e) {
|
|
313
|
+
await m("background", t, e) || await m("background-image", t, e), await m("mask", t, e) || await m("mask-image", t, e);
|
|
314
|
+
}
|
|
315
|
+
async function bt(t, e) {
|
|
316
|
+
const r = l(t, HTMLImageElement);
|
|
317
|
+
if (!(r && !S(t.src)) && !(l(t, SVGImageElement) && !S(t.href.baseVal)))
|
|
318
|
+
return;
|
|
319
|
+
const n = r ? t.src : t.href.baseVal, i = await x(n, E(n), e);
|
|
320
|
+
await new Promise((s, c) => {
|
|
321
|
+
t.onload = s, t.onerror = c;
|
|
322
|
+
const a = t;
|
|
323
|
+
a.decode && (a.decode = s), a.loading === "lazy" && (a.loading = "eager"), r ? (t.srcset = "", t.src = i) : t.href.baseVal = i;
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
async function St(t, e) {
|
|
327
|
+
const n = f(t.childNodes).map((i) => v(i, e));
|
|
328
|
+
await Promise.all(n).then(() => t);
|
|
329
|
+
}
|
|
330
|
+
async function v(t, e) {
|
|
331
|
+
l(t, Element) && (await pt(t, e), await bt(t, e), await St(t, e));
|
|
332
|
+
}
|
|
333
|
+
function Et(t, e) {
|
|
334
|
+
const { style: r } = t;
|
|
335
|
+
e.backgroundColor && (r.backgroundColor = e.backgroundColor), e.width && (r.width = `${e.width}px`), e.height && (r.height = `${e.height}px`);
|
|
336
|
+
const n = e.style;
|
|
337
|
+
return n != null && Object.keys(n).forEach((i) => {
|
|
338
|
+
r[i] = n[i];
|
|
339
|
+
}), t;
|
|
340
|
+
}
|
|
341
|
+
const $ = {};
|
|
342
|
+
async function T(t) {
|
|
343
|
+
let e = $[t];
|
|
344
|
+
if (e != null)
|
|
345
|
+
return e;
|
|
346
|
+
const n = await (await fetch(t)).text();
|
|
347
|
+
return e = { url: t, cssText: n }, $[t] = e, e;
|
|
348
|
+
}
|
|
349
|
+
async function L(t, e) {
|
|
350
|
+
let r = t.cssText;
|
|
351
|
+
const n = /url\(["']?([^"')]+)["']?\)/g, s = (r.match(/url\([^)]+\)/g) || []).map(async (c) => {
|
|
352
|
+
let a = c.replace(n, "$1");
|
|
353
|
+
return a.startsWith("https://") || (a = new URL(a, t.url).href), F(a, e.fetchRequestInit, ({ result: o }) => (r = r.replace(c, `url(${o})`), [c, o]));
|
|
354
|
+
});
|
|
355
|
+
return Promise.all(s).then(() => r);
|
|
356
|
+
}
|
|
357
|
+
function A(t) {
|
|
358
|
+
if (t == null)
|
|
359
|
+
return [];
|
|
360
|
+
const e = [], r = /(\/\*[\s\S]*?\*\/)/gi;
|
|
361
|
+
let n = t.replace(r, "");
|
|
362
|
+
const i = new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})", "gi");
|
|
363
|
+
for (; ; ) {
|
|
364
|
+
const o = i.exec(n);
|
|
365
|
+
if (o === null)
|
|
366
|
+
break;
|
|
367
|
+
e.push(o[0]);
|
|
368
|
+
}
|
|
369
|
+
n = n.replace(i, "");
|
|
370
|
+
const s = /@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");
|
|
371
|
+
for (; ; ) {
|
|
372
|
+
let o = s.exec(n);
|
|
373
|
+
if (o === null) {
|
|
374
|
+
if (o = a.exec(n), o === null)
|
|
375
|
+
break;
|
|
376
|
+
s.lastIndex = a.lastIndex;
|
|
377
|
+
} else
|
|
378
|
+
a.lastIndex = s.lastIndex;
|
|
379
|
+
e.push(o[0]);
|
|
380
|
+
}
|
|
381
|
+
return e;
|
|
382
|
+
}
|
|
383
|
+
async function xt(t, e) {
|
|
384
|
+
const r = [], n = [];
|
|
385
|
+
return t.forEach((i) => {
|
|
386
|
+
if ("cssRules" in i)
|
|
387
|
+
try {
|
|
388
|
+
f(i.cssRules || []).forEach((s, c) => {
|
|
389
|
+
if (s.type === CSSRule.IMPORT_RULE) {
|
|
390
|
+
let a = c + 1;
|
|
391
|
+
const o = s.href, g = T(o).then((h) => L(h, e)).then((h) => A(h).forEach((p) => {
|
|
392
|
+
try {
|
|
393
|
+
i.insertRule(p, p.startsWith("@import") ? a += 1 : i.cssRules.length);
|
|
394
|
+
} catch (V) {
|
|
395
|
+
console.error("Error inserting rule from remote css", {
|
|
396
|
+
rule: p,
|
|
397
|
+
error: V
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
})).catch((h) => {
|
|
401
|
+
console.error("Error loading remote css", h.toString());
|
|
402
|
+
});
|
|
403
|
+
n.push(g);
|
|
404
|
+
}
|
|
405
|
+
});
|
|
406
|
+
} catch (s) {
|
|
407
|
+
const c = t.find((a) => a.href == null) || document.styleSheets[0];
|
|
408
|
+
i.href != null && n.push(T(i.href).then((a) => L(a, e)).then((a) => A(a).forEach((o) => {
|
|
409
|
+
c.insertRule(o, i.cssRules.length);
|
|
410
|
+
})).catch((a) => {
|
|
411
|
+
console.error("Error loading remote stylesheet", a);
|
|
412
|
+
})), console.error("Error inlining remote css file", s);
|
|
413
|
+
}
|
|
414
|
+
}), Promise.all(n).then(() => (t.forEach((i) => {
|
|
415
|
+
if ("cssRules" in i)
|
|
416
|
+
try {
|
|
417
|
+
f(i.cssRules || []).forEach((s) => {
|
|
418
|
+
r.push(s);
|
|
419
|
+
});
|
|
420
|
+
} catch (s) {
|
|
421
|
+
console.error(`Error while reading CSS rules from ${i.href}`, s);
|
|
422
|
+
}
|
|
423
|
+
}), r));
|
|
424
|
+
}
|
|
425
|
+
function Rt(t) {
|
|
426
|
+
return t.filter((e) => e.type === CSSRule.FONT_FACE_RULE).filter((e) => U(e.style.getPropertyValue("src")));
|
|
427
|
+
}
|
|
428
|
+
async function Ct(t, e) {
|
|
429
|
+
if (t.ownerDocument == null)
|
|
430
|
+
throw new Error("Provided element is not within a Document");
|
|
431
|
+
const r = f(t.ownerDocument.styleSheets), n = await xt(r, e);
|
|
432
|
+
return Rt(n);
|
|
433
|
+
}
|
|
434
|
+
async function Pt(t, e) {
|
|
435
|
+
const r = await Ct(t, e);
|
|
436
|
+
return (await Promise.all(r.map((i) => {
|
|
437
|
+
const s = i.parentStyleSheet ? i.parentStyleSheet.href : null;
|
|
438
|
+
return k(i.cssText, s, e);
|
|
439
|
+
}))).join(`
|
|
440
|
+
`);
|
|
441
|
+
}
|
|
442
|
+
async function $t(t, e) {
|
|
443
|
+
const r = e.fontEmbedCSS != null ? e.fontEmbedCSS : e.skipFonts ? null : await Pt(t, e);
|
|
444
|
+
if (r) {
|
|
445
|
+
const n = document.createElement("style"), i = document.createTextNode(r);
|
|
446
|
+
n.appendChild(i), t.firstChild ? t.insertBefore(n, t.firstChild) : t.appendChild(n);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
async function Tt(t, e = {}) {
|
|
450
|
+
const { width: r, height: n } = I(t, e), i = await w(t, e, !0);
|
|
451
|
+
return await $t(i, e), await v(i, e), Et(i, e), await z(i, r, n);
|
|
452
|
+
}
|
|
453
|
+
async function Lt(t, e = {}) {
|
|
454
|
+
const { width: r, height: n } = I(t, e), i = await Tt(t, e), s = await y(i), c = document.createElement("canvas"), a = c.getContext("2d"), o = e.pixelRatio || W(), g = e.canvasWidth || r, h = e.canvasHeight || n;
|
|
455
|
+
return c.width = g * o, c.height = h * o, e.skipAutoScale || B(c), c.style.width = `${g}`, c.style.height = `${h}`, e.backgroundColor && (a.fillStyle = e.backgroundColor, a.fillRect(0, 0, c.width, c.height)), a.drawImage(s, 0, 0, c.width, c.height), c;
|
|
456
|
+
}
|
|
457
|
+
async function At(t, e = {}) {
|
|
458
|
+
const r = await Lt(t, e);
|
|
459
|
+
return await q(r);
|
|
460
|
+
}
|
|
461
|
+
export {
|
|
462
|
+
At as toBlob,
|
|
463
|
+
Lt as toCanvas,
|
|
464
|
+
Tt as toSvg
|
|
465
|
+
};
|