likec4 1.26.0 → 1.26.2

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.
@@ -1973,7 +1973,8 @@ declare function readonly<TInput>(): ReadonlyAction<TInput>;
1973
1973
 
1974
1974
  declare const ProjectConfig: ObjectSchema<{
1975
1975
  readonly name: SchemaWithPipe<[StringSchema<undefined>, NonEmptyAction<string, undefined>, DescriptionAction<string, "Project name, must be unique in the workspace">]>;
1976
- readonly exclude: SchemaWithPipe<[ExactOptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>, DescriptionAction<string[], "List of file patterns to exclude from the project, default is [\"node_modules\"]">]>;
1976
+ readonly contactPerson: OptionalSchema<SchemaWithPipe<[StringSchema<undefined>, NonEmptyAction<string, undefined>, DescriptionAction<string, "A person who has been involved in creating or maintaining this project">]>, undefined>;
1977
+ readonly exclude: OptionalSchema<SchemaWithPipe<[ArraySchema<StringSchema<undefined>, undefined>, DescriptionAction<string[], "List of file patterns to exclude from the project, default is [\"node_modules\"]">]>, undefined>;
1977
1978
  }, undefined>;
1978
1979
  type ProjectConfig = InferOutput<typeof ProjectConfig>;
1979
1980
 
@@ -1973,7 +1973,8 @@ declare function readonly<TInput>(): ReadonlyAction<TInput>;
1973
1973
 
1974
1974
  declare const ProjectConfig: ObjectSchema<{
1975
1975
  readonly name: SchemaWithPipe<[StringSchema<undefined>, NonEmptyAction<string, undefined>, DescriptionAction<string, "Project name, must be unique in the workspace">]>;
1976
- readonly exclude: SchemaWithPipe<[ExactOptionalSchema<ArraySchema<StringSchema<undefined>, undefined>, undefined>, DescriptionAction<string[], "List of file patterns to exclude from the project, default is [\"node_modules\"]">]>;
1976
+ readonly contactPerson: OptionalSchema<SchemaWithPipe<[StringSchema<undefined>, NonEmptyAction<string, undefined>, DescriptionAction<string, "A person who has been involved in creating or maintaining this project">]>, undefined>;
1977
+ readonly exclude: OptionalSchema<SchemaWithPipe<[ArraySchema<StringSchema<undefined>, undefined>, DescriptionAction<string[], "List of file patterns to exclude from the project, default is [\"node_modules\"]">]>, undefined>;
1977
1978
  }, undefined>;
1978
1979
  type ProjectConfig = InferOutput<typeof ProjectConfig>;
1979
1980
 
@@ -1,4 +1,4 @@
1
- import{relative as Q}from"node:path";import{f as Z,g as b,T as ee,N as U,i as te,l as y,n as _,j as T,u as m,a as ne,C as ie,b as re,c as O,d as oe,t as se,m as ae,p as de,e as le,L as ce}from"./likec4.C0X7XZt3.mjs";import{sortNaturalByFqn as A,compareNatural as pe}from"@likec4/core";function ue(t){var e,i;if(t){if("astNode"in t)return he(t);if(Array.isArray(t))return t.reduce(J,void 0);{const n=t,r=fe(n)?ge((i=(e=n?.root)===null||e===void 0?void 0:e.astNode)!==null&&i!==void 0?i:n?.astNode):void 0;
1
+ import{relative as Q}from"node:path";import{f as Z,g as b,T as ee,N as U,i as te,l as y,n as _,j as T,u as m,a as ne,C as ie,b as re,c as O,d as oe,t as se,m as ae,p as de,e as le,L as ce}from"./likec4.CdjXfSGc.mjs";import{sortNaturalByFqn as A,compareNatural as pe}from"@likec4/core";function ue(t){var e,i;if(t){if("astNode"in t)return he(t);if(Array.isArray(t))return t.reduce(J,void 0);{const n=t,r=fe(n)?ge((i=(e=n?.root)===null||e===void 0?void 0:e.astNode)!==null&&i!==void 0?i:n?.astNode):void 0;
2
2
  return C(n,r)}}else return}function fe(t){return typeof t<"u"&&"element"in t&&"text"in t}function ge(t){try{return b(t).uri.toString()}catch{return}}function he(t){var e,i;const{astNode:n,property:r,index:s}=t??{},o=(e=n?.$cstNode)!==null&&e!==void 0?e:n?.$textRegion;if(!(n===void 0||o===void 0)){if(r===void 0)return C(o,R(n));{const a=d=>s!==void 0&&s>-1&&Array.isArray(n[r])?s<d.length?d[s]:void 0:d.reduce(J,void 0);if(!((i=o.assignments)===null||i===void 0)&&i[r]){const d=a(o.assignments[r]);return d&&
3
3
  C(d,R(n))}else if(n.$cstNode){const d=a(Z(n.$cstNode,r));return d&&C(d,R(n))}else return}}}function R(t){var e,i,n,r;return t.$cstNode?(i=(e=b(t))===null||e===void 0?void 0:e.uri)===null||i===void 0?void 0:i.toString():t.$textRegion?t.$textRegion.documentURI||((r=(n=new ee(t,s=>s.$container?[s.$container]:[]).find(s=>{var o;return(o=s.$textRegion)===null||o===void 0?void 0:o.documentURI}))===null||n===void 0?void 0:n.$textRegion)===null||r===void 0?void 0:r.documentURI):void 0}function C(t,e){var i,
4
4
  n;const r={offset:t.offset,end:(i=t.end)!==null&&i!==void 0?i:t.offset+t.length,length:(n=t.length)!==null&&n!==void 0?n:t.end-t.offset};return t.range&&(r.range=t.range),e??(e=t.fileURI),e&&(r.fileURI=e),r}function J(t,e){var i,n;if(t){if(!e)return t&&C(t)}else return e&&C(e);const r=(i=t.end)!==null&&i!==void 0?i:t.offset+t.length,s=(n=e.end)!==null&&n!==void 0?n:e.offset+e.length,o=Math.min(t.offset,e.offset),a=Math.max(r,s),d=a-o,c={offset:o,end:a,length:d};if(t.range&&e.range&&(c.range={start:e.
@@ -279,8 +279,6 @@ ${r.join(`
279
279
  }
280
280
 
281
281
  `.append(l,l),k(e)}const it={...j("mmd"),async load({likec4:t,projectId:e,logger:i}){i.info(m.dim(`generating virtual:likec4/mmd/${e}`));const n=await t.views.computedViews(e);return nt(n)}},rt=x("mmd","loadMmdSources"),ot=t=>`
282
- 'use client'
283
-
284
282
  import { createLikeC4Model } from 'likec4/model'
285
283
  import { nano, createHooksForModel } from 'likec4/react'
286
284
 
@@ -1,4 +1,4 @@
1
- import { L as LikeC4LanguageServices } from '../shared/likec4.Y_4a6gTW.mjs';
1
+ import { L as LikeC4LanguageServices } from '../shared/likec4.DGrST4wG.mjs';
2
2
  import '@likec4/core';
3
3
  import 'type-fest';
4
4
 
@@ -1,4 +1,4 @@
1
- import { L as LikeC4LanguageServices } from '../shared/likec4.Y_4a6gTW.js';
1
+ import { L as LikeC4LanguageServices } from '../shared/likec4.DGrST4wG.js';
2
2
  import '@likec4/core';
3
3
  import 'type-fest';
4
4
 
@@ -1,2 +1,2 @@
1
- export{L as LikeC4VitePlugin}from"../shared/likec4.Cz9mPeTQ.mjs";import"node:path";import"../shared/likec4.C0X7XZt3.mjs";import"node:fs";import"node:url";import"tty";import"node:util";import"util";import"path";import"os";import"crypto";import"net";import"url";import"fs";import"child_process";import"@likec4/core";import"@likec4/core/types";import"events";import"buffer";import"@hpcc-js/wasm-graphviz";import"@likec4/core/compute-view";import"@likec4/core/utils";import"node:process";import"boxen";import"node:child_process";
1
+ export{L as LikeC4VitePlugin}from"../shared/likec4.DQwwl5M9.mjs";import"node:path";import"../shared/likec4.CdjXfSGc.mjs";import"node:fs";import"node:url";import"tty";import"node:util";import"util";import"path";import"os";import"crypto";import"net";import"url";import"fs";import"child_process";import"@likec4/core";import"@likec4/core/types";import"events";import"buffer";import"@hpcc-js/wasm-graphviz";import"@likec4/core/compute-view";import"@likec4/core/utils";import"node:process";import"boxen";import"node:child_process";
2
2
  import"node:events";import"node:fs/promises";import"node:stream/promises";import"node:os";import"fs/promises";import"@likec4/core/model";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "likec4",
3
- "version": "1.26.0",
3
+ "version": "1.26.2",
4
4
  "license": "MIT",
5
5
  "homepage": "https://likec4.dev",
6
6
  "author": "Denis Davydkov <denis@davydkov.com>",
@@ -75,13 +75,13 @@
75
75
  "@hpcc-js/wasm-graphviz": "1.7.0",
76
76
  "@vitejs/plugin-react": "4.3.4",
77
77
  "boxen": "^8.0.1",
78
- "playwright": "1.50.1",
78
+ "playwright": "^1.51.1",
79
79
  "react": "~19.0.0",
80
80
  "react-dom": "~19.0.0",
81
81
  "rollup": "4.34.6",
82
82
  "type-fest": "4.34.1",
83
83
  "vite": "^6.2.0",
84
- "@likec4/core": "~1.26.0"
84
+ "@likec4/core": "~1.26.2"
85
85
  },
86
86
  "devDependencies": {
87
87
  "@dagrejs/dagre": "1.1.4",
@@ -163,13 +163,13 @@
163
163
  "vscode-uri": "3.1.0",
164
164
  "which": "^5.0.0",
165
165
  "yargs": "17.7.2",
166
- "@likec4/diagram": "1.26.0",
167
- "@likec4/icons": "1.26.0",
168
- "@likec4/language-server": "1.26.0",
169
- "@likec4/layouts": "1.26.0",
170
- "@likec4/generators": "1.26.0",
171
- "@likec4/log": "1.26.0",
172
- "@likec4/tsconfig": "1.26.0"
166
+ "@likec4/icons": "1.26.2",
167
+ "@likec4/diagram": "1.26.2",
168
+ "@likec4/generators": "1.26.2",
169
+ "@likec4/language-server": "1.26.2",
170
+ "@likec4/layouts": "1.26.2",
171
+ "@likec4/log": "1.26.2",
172
+ "@likec4/tsconfig": "1.26.2"
173
173
  },
174
174
  "scripts": {
175
175
  "turbo-build": "turbo run build --log-prefix=none --log-order=grouped",
@@ -1,495 +0,0 @@
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 q = /* @__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 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 I(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 B(t) {
34
- const e = y(t, "border-left-width"), r = y(t, "border-right-width");
35
- return t.clientWidth + e + r;
36
- }
37
- function j(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 || B(t), n = e.height || j(t);
43
- return { width: r, height: n };
44
- }
45
- function z() {
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 X(t, e = {}) {
59
- return t.toBlob ? new Promise((r) => {
60
- t.toBlob(r, e.type ? e.type : "image/png", e.quality ? e.quality : 1);
61
- }) : new Promise((r) => {
62
- const n = window.atob(t.toDataURL(e.type ? e.type : void 0, e.quality ? e.quality : void 0).split(",")[1]), s = n.length, i = new Uint8Array(s);
63
- for (let c = 0; c < s; c += 1)
64
- i[c] = n.charCodeAt(c);
65
- r(new Blob([i], {
66
- type: e.type ? e.type : "image/png"
67
- }));
68
- });
69
- }
70
- function w(t) {
71
- return new Promise((e, r) => {
72
- const n = new Image();
73
- n.onload = () => {
74
- n.decode().then(() => {
75
- requestAnimationFrame(() => e(n));
76
- });
77
- }, n.onerror = r, n.crossOrigin = "anonymous", n.decoding = "async", n.src = t;
78
- });
79
- }
80
- async function K(t) {
81
- return Promise.resolve().then(() => new XMLSerializer().serializeToString(t)).then(encodeURIComponent).then((e) => `data:image/svg+xml;charset=utf-8,${e}`);
82
- }
83
- async function J(t, e, r) {
84
- const n = "http://www.w3.org/2000/svg", s = document.createElementNS(n, "svg"), i = document.createElementNS(n, "foreignObject");
85
- 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), K(s);
86
- }
87
- const l = (t, e) => {
88
- if (t instanceof e)
89
- return !0;
90
- const r = Object.getPrototypeOf(t);
91
- return r === null ? !1 : r.constructor.name === e.name || l(r, e);
92
- };
93
- function Q(t) {
94
- const e = t.getPropertyValue("content");
95
- return `${t.cssText} content: '${e.replace(/'|"/g, "")}';`;
96
- }
97
- function Y(t, e) {
98
- return I(e).map((r) => {
99
- const n = t.getPropertyValue(r), s = t.getPropertyPriority(r);
100
- return `${r}: ${n}${s ? " !important" : ""};`;
101
- }).join(" ");
102
- }
103
- function Z(t, e, r, n) {
104
- const s = `.${t}:${e}`, i = r.cssText ? Q(r) : Y(r, n);
105
- return document.createTextNode(`${s}{${i}}`);
106
- }
107
- function C(t, e, r, n) {
108
- const s = window.getComputedStyle(t, r), i = s.getPropertyValue("content");
109
- if (i === "" || i === "none")
110
- return;
111
- const c = q();
112
- try {
113
- e.className = `${e.className} ${c}`;
114
- } catch {
115
- return;
116
- }
117
- const a = document.createElement("style");
118
- a.appendChild(Z(c, r, s, n)), e.appendChild(a);
119
- }
120
- function N(t, e, r) {
121
- C(t, e, ":before", r), C(t, e, ":after", r);
122
- }
123
- const P = "application/font-woff", $ = "image/jpeg", tt = {
124
- woff: P,
125
- woff2: P,
126
- ttf: "application/font-truetype",
127
- eot: "application/vnd.ms-fontobject",
128
- png: "image/png",
129
- jpg: $,
130
- jpeg: $,
131
- gif: "image/gif",
132
- tiff: "image/tiff",
133
- svg: "image/svg+xml",
134
- webp: "image/webp"
135
- };
136
- function et(t) {
137
- const e = /\.([^./]*?)$/g.exec(t);
138
- return e ? e[1] : "";
139
- }
140
- function x(t) {
141
- const e = et(t).toLowerCase();
142
- return tt[e] || "";
143
- }
144
- function rt(t) {
145
- return t.split(/,/)[1];
146
- }
147
- function E(t) {
148
- return t.search(/^(data:)/) !== -1;
149
- }
150
- function nt(t, e) {
151
- return `data:${e};base64,${t}`;
152
- }
153
- async function D(t, e, r) {
154
- const n = await fetch(t, e);
155
- if (n.status === 404)
156
- throw new Error(`Resource "${n.url}" not found`);
157
- const s = await n.blob();
158
- return new Promise((i, c) => {
159
- const a = new FileReader();
160
- a.onerror = c, a.onloadend = () => {
161
- try {
162
- i(r({ res: n, result: a.result }));
163
- } catch (o) {
164
- c(o);
165
- }
166
- }, a.readAsDataURL(s);
167
- });
168
- }
169
- const S = {};
170
- function it(t, e, r) {
171
- let n = t.replace(/\?.*/, "");
172
- return r && (n = t), /ttf|otf|eot|woff2?/i.test(n) && (n = n.replace(/.*\//, "")), e ? `[${e}]${n}` : n;
173
- }
174
- async function R(t, e, r) {
175
- const n = it(t, e, r.includeQueryParams);
176
- if (S[n] != null)
177
- return S[n];
178
- r.cacheBust && (t += (/\?/.test(t) ? "&" : "?") + (/* @__PURE__ */ new Date()).getTime());
179
- let s;
180
- try {
181
- const i = await D(t, r.fetchRequestInit, ({ res: c, result: a }) => (e || (e = c.headers.get("Content-Type") || ""), rt(a)));
182
- s = nt(i, e);
183
- } catch (i) {
184
- s = r.imagePlaceholder || "";
185
- let c = `Failed to fetch resource: ${t}`;
186
- i && (c = typeof i == "string" ? i : i.message), c && console.warn(c);
187
- }
188
- return S[n] = s, s;
189
- }
190
- async function st(t) {
191
- const e = t.toDataURL();
192
- return e === "data:," ? t.cloneNode(!1) : w(e);
193
- }
194
- async function ct(t, e) {
195
- if (t.currentSrc) {
196
- const i = document.createElement("canvas"), c = i.getContext("2d");
197
- i.width = t.clientWidth, i.height = t.clientHeight, c?.drawImage(t, 0, 0, i.width, i.height);
198
- const a = i.toDataURL();
199
- return w(a);
200
- }
201
- const r = t.poster, n = x(r), s = await R(r, n, e);
202
- return w(s);
203
- }
204
- async function at(t, e) {
205
- var r;
206
- try {
207
- if (!((r = t?.contentDocument) === null || r === void 0) && r.body)
208
- return await p(t.contentDocument.body, e, !0);
209
- } catch {
210
- }
211
- return t.cloneNode(!1);
212
- }
213
- async function ot(t, e) {
214
- return l(t, HTMLCanvasElement) ? st(t) : l(t, HTMLVideoElement) ? ct(t, e) : l(t, HTMLIFrameElement) ? at(t, e) : t.cloneNode(U(t));
215
- }
216
- const lt = (t) => t.tagName != null && t.tagName.toUpperCase() === "SLOT", U = (t) => t.tagName != null && t.tagName.toUpperCase() === "SVG";
217
- async function ut(t, e, r) {
218
- var n, s;
219
- if (U(e))
220
- return e;
221
- let i = [];
222
- return lt(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) => {
223
- o && e.appendChild(o);
224
- }), Promise.resolve()), e;
225
- }
226
- function ft(t, e, r) {
227
- const n = e.style;
228
- if (!n)
229
- return;
230
- const s = window.getComputedStyle(t);
231
- s.cssText ? (n.cssText = s.cssText, n.transformOrigin = s.transformOrigin) : I(r).forEach((i) => {
232
- let c = s.getPropertyValue(i);
233
- 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));
234
- });
235
- }
236
- function ht(t, e) {
237
- l(t, HTMLTextAreaElement) && (e.innerHTML = t.value), l(t, HTMLInputElement) && e.setAttribute("value", t.value);
238
- }
239
- function mt(t, e) {
240
- if (l(t, HTMLSelectElement)) {
241
- const r = e, n = Array.from(r.children).find((s) => t.value === s.getAttribute("value"));
242
- n && n.setAttribute("selected", "");
243
- }
244
- }
245
- function gt(t, e, r) {
246
- return l(e, Element) && (ft(t, e, r), N(t, e, r), ht(t, e), mt(t, e)), e;
247
- }
248
- async function dt(t, e) {
249
- const r = t.querySelectorAll ? t.querySelectorAll("use") : [];
250
- if (r.length === 0)
251
- return t;
252
- const n = {};
253
- for (let i = 0; i < r.length; i++) {
254
- const a = r[i].getAttribute("xlink:href");
255
- if (a) {
256
- const o = t.querySelector(a), f = document.querySelector(a);
257
- !o && f && !n[a] && (n[a] = await p(f, e, !0));
258
- }
259
- }
260
- const s = Object.values(n);
261
- if (s.length) {
262
- const i = "http://www.w3.org/1999/xhtml", c = document.createElementNS(i, "svg");
263
- c.setAttribute("xmlns", i), c.style.position = "absolute", c.style.width = "0", c.style.height = "0", c.style.overflow = "hidden", c.style.display = "none";
264
- const a = document.createElementNS(i, "defs");
265
- c.appendChild(a);
266
- for (let o = 0; o < s.length; o++)
267
- a.appendChild(s[o]);
268
- t.appendChild(c);
269
- }
270
- return t;
271
- }
272
- async function p(t, e, r) {
273
- return !r && e.filter && !e.filter(t) ? null : Promise.resolve(t).then((n) => ot(n, e)).then((n) => ut(t, n, e)).then((n) => gt(t, n, e)).then((n) => dt(n, e));
274
- }
275
- const v = /url\((['"]?)([^'"]+?)\1\)/g, yt = /url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g, wt = /src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;
276
- function pt(t) {
277
- const e = t.replace(/([.*+?^${}()|\[\]\/\\])/g, "\\$1");
278
- return new RegExp(`(url\\(['"]?)(${e})(['"]?\\))`, "g");
279
- }
280
- function bt(t) {
281
- const e = [];
282
- return t.replace(v, (r, n, s) => (e.push(s), r)), e.filter((r) => !E(r));
283
- }
284
- async function St(t, e, r, n, s) {
285
- try {
286
- const i = r ? W(e, r) : e, c = x(e);
287
- let a;
288
- return s || (a = await R(i, c, n)), t.replace(pt(e), `$1${a}$3`);
289
- } catch {
290
- }
291
- return t;
292
- }
293
- function Et(t, { preferredFontFormat: e }) {
294
- return e ? t.replace(wt, (r) => {
295
- for (; ; ) {
296
- const [n, , s] = yt.exec(r) || [];
297
- if (!s)
298
- return "";
299
- if (s === e)
300
- return `src: ${n};`;
301
- }
302
- }) : t;
303
- }
304
- function H(t) {
305
- return t.search(v) !== -1;
306
- }
307
- async function V(t, e, r) {
308
- if (!H(t))
309
- return t;
310
- const n = Et(t, r);
311
- return bt(n).reduce((i, c) => i.then((a) => St(a, c, e, r)), Promise.resolve(n));
312
- }
313
- async function d(t, e, r) {
314
- var n;
315
- const s = (n = e.style) === null || n === void 0 ? void 0 : n.getPropertyValue(t);
316
- if (s) {
317
- const i = await V(s, null, r);
318
- return e.style.setProperty(t, i, e.style.getPropertyPriority(t)), !0;
319
- }
320
- return !1;
321
- }
322
- async function xt(t, e) {
323
- 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);
324
- }
325
- async function Rt(t, e) {
326
- const r = l(t, HTMLImageElement);
327
- if (!(r && !E(t.src)) && !(l(t, SVGImageElement) && !E(t.href.baseVal)))
328
- return;
329
- const n = r ? t.src : t.href.baseVal, s = await R(n, x(n), e);
330
- await new Promise((i, c) => {
331
- t.onload = i, t.onerror = e.onImageErrorHandler ? (...o) => {
332
- try {
333
- i(e.onImageErrorHandler(...o));
334
- } catch (f) {
335
- c(f);
336
- }
337
- } : c;
338
- const a = t;
339
- a.decode && (a.decode = i), a.loading === "lazy" && (a.loading = "eager"), r ? (t.srcset = "", t.src = s) : t.href.baseVal = s;
340
- });
341
- }
342
- async function Ct(t, e) {
343
- const n = m(t.childNodes).map((s) => M(s, e));
344
- await Promise.all(n).then(() => t);
345
- }
346
- async function M(t, e) {
347
- l(t, Element) && (await xt(t, e), await Rt(t, e), await Ct(t, e));
348
- }
349
- function Pt(t, e) {
350
- const { style: r } = t;
351
- e.backgroundColor && (r.backgroundColor = e.backgroundColor), e.width && (r.width = `${e.width}px`), e.height && (r.height = `${e.height}px`);
352
- const n = e.style;
353
- return n != null && Object.keys(n).forEach((s) => {
354
- r[s] = n[s];
355
- }), t;
356
- }
357
- const T = {};
358
- async function F(t) {
359
- let e = T[t];
360
- if (e != null)
361
- return e;
362
- const n = await (await fetch(t)).text();
363
- return e = { url: t, cssText: n }, T[t] = e, e;
364
- }
365
- async function L(t, e) {
366
- let r = t.cssText;
367
- const n = /url\(["']?([^"')]+)["']?\)/g, i = (r.match(/url\([^)]+\)/g) || []).map(async (c) => {
368
- let a = c.replace(n, "$1");
369
- 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]));
370
- });
371
- return Promise.all(i).then(() => r);
372
- }
373
- function A(t) {
374
- if (t == null)
375
- return [];
376
- const e = [], r = /(\/\*[\s\S]*?\*\/)/gi;
377
- let n = t.replace(r, "");
378
- const s = new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})", "gi");
379
- for (; ; ) {
380
- const o = s.exec(n);
381
- if (o === null)
382
- break;
383
- e.push(o[0]);
384
- }
385
- n = n.replace(s, "");
386
- 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");
387
- for (; ; ) {
388
- let o = i.exec(n);
389
- if (o === null) {
390
- if (o = a.exec(n), o === null)
391
- break;
392
- i.lastIndex = a.lastIndex;
393
- } else
394
- a.lastIndex = i.lastIndex;
395
- e.push(o[0]);
396
- }
397
- return e;
398
- }
399
- async function $t(t, e) {
400
- const r = [], n = [];
401
- return t.forEach((s) => {
402
- if ("cssRules" in s)
403
- try {
404
- m(s.cssRules || []).forEach((i, c) => {
405
- if (i.type === CSSRule.IMPORT_RULE) {
406
- let a = c + 1;
407
- const o = i.href, f = F(o).then((h) => L(h, e)).then((h) => A(h).forEach((b) => {
408
- try {
409
- s.insertRule(b, b.startsWith("@import") ? a += 1 : s.cssRules.length);
410
- } catch (_) {
411
- console.error("Error inserting rule from remote css", {
412
- rule: b,
413
- error: _
414
- });
415
- }
416
- })).catch((h) => {
417
- console.error("Error loading remote css", h.toString());
418
- });
419
- n.push(f);
420
- }
421
- });
422
- } catch (i) {
423
- const c = t.find((a) => a.href == null) || document.styleSheets[0];
424
- s.href != null && n.push(F(s.href).then((a) => L(a, e)).then((a) => A(a).forEach((o) => {
425
- c.insertRule(o, c.cssRules.length);
426
- })).catch((a) => {
427
- console.error("Error loading remote stylesheet", a);
428
- })), console.error("Error inlining remote css file", i);
429
- }
430
- }), Promise.all(n).then(() => (t.forEach((s) => {
431
- if ("cssRules" in s)
432
- try {
433
- m(s.cssRules || []).forEach((i) => {
434
- r.push(i);
435
- });
436
- } catch (i) {
437
- console.error(`Error while reading CSS rules from ${s.href}`, i);
438
- }
439
- }), r));
440
- }
441
- function Tt(t) {
442
- return t.filter((e) => e.type === CSSRule.FONT_FACE_RULE).filter((e) => H(e.style.getPropertyValue("src")));
443
- }
444
- async function Ft(t, e) {
445
- if (t.ownerDocument == null)
446
- throw new Error("Provided element is not within a Document");
447
- const r = m(t.ownerDocument.styleSheets), n = await $t(r, e);
448
- return Tt(n);
449
- }
450
- function O(t) {
451
- return t.trim().replace(/["']/g, "");
452
- }
453
- function Lt(t) {
454
- const e = /* @__PURE__ */ new Set();
455
- function r(n) {
456
- (n.style.fontFamily || getComputedStyle(n).fontFamily).split(",").forEach((i) => {
457
- e.add(O(i));
458
- }), Array.from(n.children).forEach((i) => {
459
- i instanceof HTMLElement && r(i);
460
- });
461
- }
462
- return r(t), e;
463
- }
464
- async function At(t, e) {
465
- const r = await Ft(t, e), n = Lt(t);
466
- return (await Promise.all(r.filter((i) => n.has(O(i.style.fontFamily))).map((i) => {
467
- const c = i.parentStyleSheet ? i.parentStyleSheet.href : null;
468
- return V(i.cssText, c, e);
469
- }))).join(`
470
- `);
471
- }
472
- async function It(t, e) {
473
- const r = e.fontEmbedCSS != null ? e.fontEmbedCSS : e.skipFonts ? null : await At(t, e);
474
- if (r) {
475
- const n = document.createElement("style"), s = document.createTextNode(r);
476
- n.appendChild(s), t.firstChild ? t.insertBefore(n, t.firstChild) : t.appendChild(n);
477
- }
478
- }
479
- async function kt(t, e = {}) {
480
- const { width: r, height: n } = k(t, e), s = await p(t, e, !0);
481
- return await It(s, e), await M(s, e), Pt(s, e), await J(s, r, n);
482
- }
483
- async function Dt(t, e = {}) {
484
- const { width: r, height: n } = k(t, e), s = await kt(t, e), i = await w(s), c = document.createElement("canvas"), a = c.getContext("2d"), o = e.pixelRatio || z(), f = e.canvasWidth || r, h = e.canvasHeight || n;
485
- 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;
486
- }
487
- async function Ut(t, e = {}) {
488
- const r = await Dt(t, e);
489
- return await X(r);
490
- }
491
- export {
492
- Ut as toBlob,
493
- Dt as toCanvas,
494
- kt as toSvg
495
- };