locusing 0.1.2 → 0.1.3
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/dist/chunk-OGXUFTN5.mjs +73 -0
- package/dist/chunk-P4AQB2F4.mjs +636 -0
- package/dist/chunk-VPKI3XSA.mjs +497 -0
- package/dist/diagram-Cp-wb_P8.d.mts +1954 -0
- package/dist/diagram-Cp-wb_P8.d.ts +1954 -0
- package/dist/export.d.mts +1 -1
- package/dist/export.d.ts +1 -1
- package/dist/export.mjs +4 -6
- package/dist/index.d.mts +371 -29
- package/dist/index.d.ts +371 -29
- package/dist/index.global.js +5701 -576
- package/dist/index.js +2449 -1084
- package/dist/index.mjs +2102 -174
- package/dist/mp4-muxer-BX5P3WHC.mjs +1926 -0
- package/dist/transform-CEUZFTMM.mjs +22 -0
- package/package.json +9 -2
|
@@ -0,0 +1,497 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
+
var __spreadValues = (a, b) => {
|
|
11
|
+
for (var prop in b || (b = {}))
|
|
12
|
+
if (__hasOwnProp.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
if (__getOwnPropSymbols)
|
|
15
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
+
if (__propIsEnum.call(b, prop))
|
|
17
|
+
__defNormalProp(a, prop, b[prop]);
|
|
18
|
+
}
|
|
19
|
+
return a;
|
|
20
|
+
};
|
|
21
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
22
|
+
var __objRest = (source, exclude) => {
|
|
23
|
+
var target = {};
|
|
24
|
+
for (var prop in source)
|
|
25
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
26
|
+
target[prop] = source[prop];
|
|
27
|
+
if (source != null && __getOwnPropSymbols)
|
|
28
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
29
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
30
|
+
target[prop] = source[prop];
|
|
31
|
+
}
|
|
32
|
+
return target;
|
|
33
|
+
};
|
|
34
|
+
var __esm = (fn, res) => function __init() {
|
|
35
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
36
|
+
};
|
|
37
|
+
var __export = (target, all) => {
|
|
38
|
+
for (var name in all)
|
|
39
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
40
|
+
};
|
|
41
|
+
var __copyProps = (to, from, except, desc) => {
|
|
42
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
43
|
+
for (let key of __getOwnPropNames(from))
|
|
44
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
45
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
46
|
+
}
|
|
47
|
+
return to;
|
|
48
|
+
};
|
|
49
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
50
|
+
|
|
51
|
+
// src/core/render-svg.ts
|
|
52
|
+
function ensureKatexStyles() {
|
|
53
|
+
if (katexStyleInjected || typeof document === "undefined") return;
|
|
54
|
+
if (document.querySelector('link[href*="katex"]') || document.querySelector("style[data-katex]")) {
|
|
55
|
+
katexStyleInjected = true;
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const link = document.createElement("link");
|
|
59
|
+
link.rel = "stylesheet";
|
|
60
|
+
link.href = "https://cdn.jsdelivr.net/npm/katex@0.16.27/dist/katex.min.css";
|
|
61
|
+
link.crossOrigin = "anonymous";
|
|
62
|
+
document.head.appendChild(link);
|
|
63
|
+
katexStyleInjected = true;
|
|
64
|
+
}
|
|
65
|
+
function renderToSVG(diagram, container, options = {}) {
|
|
66
|
+
const { width = 800, height = 600, background, frame } = options;
|
|
67
|
+
ensureKatexStyles();
|
|
68
|
+
let svg;
|
|
69
|
+
if (container instanceof SVGSVGElement) {
|
|
70
|
+
svg = container;
|
|
71
|
+
} else {
|
|
72
|
+
svg = document.createElementNS(SVG_NS, "svg");
|
|
73
|
+
container.appendChild(svg);
|
|
74
|
+
}
|
|
75
|
+
svg.setAttribute("width", String(width));
|
|
76
|
+
svg.setAttribute("height", String(height));
|
|
77
|
+
while (svg.firstChild) {
|
|
78
|
+
svg.removeChild(svg.firstChild);
|
|
79
|
+
}
|
|
80
|
+
const frameConfig = frame ? typeof frame === "boolean" ? DEFAULT_FRAME : frame : null;
|
|
81
|
+
if (frameConfig) {
|
|
82
|
+
const { width: fw, height: fh } = frameConfig;
|
|
83
|
+
svg.setAttribute("viewBox", `${-fw / 2} ${-fh / 2} ${fw} ${fh}`);
|
|
84
|
+
if (background) {
|
|
85
|
+
const rect = document.createElementNS(SVG_NS, "rect");
|
|
86
|
+
rect.setAttribute("x", String(-fw / 2));
|
|
87
|
+
rect.setAttribute("y", String(-fh / 2));
|
|
88
|
+
rect.setAttribute("width", String(fw));
|
|
89
|
+
rect.setAttribute("height", String(fh));
|
|
90
|
+
rect.setAttribute("fill", background);
|
|
91
|
+
svg.appendChild(rect);
|
|
92
|
+
}
|
|
93
|
+
const defs = document.createElementNS(SVG_NS, "defs");
|
|
94
|
+
svg.appendChild(defs);
|
|
95
|
+
const flipGroup = document.createElementNS(SVG_NS, "g");
|
|
96
|
+
flipGroup.setAttribute("transform", "scale(1, -1)");
|
|
97
|
+
const element = renderShape(diagram.shape, true);
|
|
98
|
+
if (element) {
|
|
99
|
+
flipGroup.appendChild(element);
|
|
100
|
+
}
|
|
101
|
+
svg.appendChild(flipGroup);
|
|
102
|
+
} else {
|
|
103
|
+
svg.setAttribute("viewBox", `0 0 ${width} ${height}`);
|
|
104
|
+
if (background) {
|
|
105
|
+
const rect = document.createElementNS(SVG_NS, "rect");
|
|
106
|
+
rect.setAttribute("width", "100%");
|
|
107
|
+
rect.setAttribute("height", "100%");
|
|
108
|
+
rect.setAttribute("fill", background);
|
|
109
|
+
svg.appendChild(rect);
|
|
110
|
+
}
|
|
111
|
+
const defs = document.createElementNS(SVG_NS, "defs");
|
|
112
|
+
svg.appendChild(defs);
|
|
113
|
+
const element = renderShape(diagram.shape, false);
|
|
114
|
+
if (element) {
|
|
115
|
+
svg.appendChild(element);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return svg;
|
|
119
|
+
}
|
|
120
|
+
function toSVGString(diagram, options = {}) {
|
|
121
|
+
const { width = 800, height = 600, background, frame } = options;
|
|
122
|
+
const frameConfig = frame ? typeof frame === "boolean" ? DEFAULT_FRAME : frame : null;
|
|
123
|
+
if (frameConfig) {
|
|
124
|
+
const { width: fw, height: fh } = frameConfig;
|
|
125
|
+
const viewBox = `${-fw / 2} ${-fh / 2} ${fw} ${fh}`;
|
|
126
|
+
let content2 = "";
|
|
127
|
+
if (background) {
|
|
128
|
+
content2 += `<rect x="${-fw / 2}" y="${-fh / 2}" width="${fw}" height="${fh}" fill="${background}"/>`;
|
|
129
|
+
}
|
|
130
|
+
content2 += `<g transform="scale(1,-1)">${shapeToSVGString(diagram.shape)}</g>`;
|
|
131
|
+
return `<svg xmlns="${SVG_NS}" width="${width}" height="${height}" viewBox="${viewBox}">${content2}</svg>`;
|
|
132
|
+
}
|
|
133
|
+
let content = "";
|
|
134
|
+
if (background) {
|
|
135
|
+
content += `<rect width="100%" height="100%" fill="${background}"/>`;
|
|
136
|
+
}
|
|
137
|
+
content += shapeToSVGString(diagram.shape);
|
|
138
|
+
return `<svg xmlns="${SVG_NS}" width="${width}" height="${height}" viewBox="0 0 ${width} ${height}">${content}</svg>`;
|
|
139
|
+
}
|
|
140
|
+
function renderTexShape(shape, frameMode = false) {
|
|
141
|
+
if (frameMode) {
|
|
142
|
+
const g = document.createElementNS(SVG_NS, "g");
|
|
143
|
+
const matrix = shape.transform;
|
|
144
|
+
const a = matrix[0], c = matrix[1], tx = matrix[2];
|
|
145
|
+
const b = matrix[3], d = matrix[4], ty = matrix[5];
|
|
146
|
+
const fx = a * shape.x + c * shape.y + tx;
|
|
147
|
+
const fy = b * shape.x + d * shape.y + ty;
|
|
148
|
+
const scale = 16 / 800;
|
|
149
|
+
g.setAttribute("transform", `translate(${fx}, ${-fy}) scale(${scale}, ${-scale})`);
|
|
150
|
+
const foreignObject = document.createElementNS(SVG_NS, "foreignObject");
|
|
151
|
+
const pixelWidth = 1e3;
|
|
152
|
+
const pixelHeight = 200;
|
|
153
|
+
foreignObject.setAttribute("x", String(-pixelWidth / 2));
|
|
154
|
+
foreignObject.setAttribute("y", String(-pixelHeight / 2));
|
|
155
|
+
foreignObject.setAttribute("width", String(pixelWidth));
|
|
156
|
+
foreignObject.setAttribute("height", String(pixelHeight));
|
|
157
|
+
foreignObject.setAttribute("overflow", "visible");
|
|
158
|
+
const div = document.createElementNS(XHTML_NS, "div");
|
|
159
|
+
div.setAttribute("xmlns", XHTML_NS);
|
|
160
|
+
div.style.fontSize = `${shape.fontSize}px`;
|
|
161
|
+
div.style.color = shape.color;
|
|
162
|
+
div.style.display = "flex";
|
|
163
|
+
div.style.justifyContent = "center";
|
|
164
|
+
div.style.alignItems = "center";
|
|
165
|
+
div.style.width = `${pixelWidth}px`;
|
|
166
|
+
div.style.height = `${pixelHeight}px`;
|
|
167
|
+
div.style.whiteSpace = "nowrap";
|
|
168
|
+
div.innerHTML = shape.html;
|
|
169
|
+
foreignObject.appendChild(div);
|
|
170
|
+
g.appendChild(foreignObject);
|
|
171
|
+
return g;
|
|
172
|
+
} else {
|
|
173
|
+
const foreignObject = document.createElementNS(SVG_NS, "foreignObject");
|
|
174
|
+
foreignObject.setAttribute("x", String(shape.x));
|
|
175
|
+
foreignObject.setAttribute("y", String(shape.y));
|
|
176
|
+
foreignObject.setAttribute("width", "1000");
|
|
177
|
+
foreignObject.setAttribute("height", "200");
|
|
178
|
+
foreignObject.setAttribute("overflow", "visible");
|
|
179
|
+
const div = document.createElementNS(XHTML_NS, "div");
|
|
180
|
+
div.setAttribute("xmlns", XHTML_NS);
|
|
181
|
+
div.style.fontSize = `${shape.fontSize}px`;
|
|
182
|
+
div.style.color = shape.color;
|
|
183
|
+
div.style.display = "inline-block";
|
|
184
|
+
div.style.whiteSpace = "nowrap";
|
|
185
|
+
div.innerHTML = shape.html;
|
|
186
|
+
foreignObject.appendChild(div);
|
|
187
|
+
return foreignObject;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
function renderShape(shape, frameMode = false) {
|
|
191
|
+
let element = null;
|
|
192
|
+
switch (shape.type) {
|
|
193
|
+
case "rect":
|
|
194
|
+
element = document.createElementNS(SVG_NS, "rect");
|
|
195
|
+
element.setAttribute("x", String(shape.x));
|
|
196
|
+
element.setAttribute("y", String(shape.y));
|
|
197
|
+
element.setAttribute("width", String(shape.width));
|
|
198
|
+
element.setAttribute("height", String(shape.height));
|
|
199
|
+
if (shape.rx) element.setAttribute("rx", String(shape.rx));
|
|
200
|
+
if (shape.ry) element.setAttribute("ry", String(shape.ry));
|
|
201
|
+
break;
|
|
202
|
+
case "circle":
|
|
203
|
+
element = document.createElementNS(SVG_NS, "circle");
|
|
204
|
+
element.setAttribute("cx", String(shape.cx));
|
|
205
|
+
element.setAttribute("cy", String(shape.cy));
|
|
206
|
+
element.setAttribute("r", String(shape.r));
|
|
207
|
+
break;
|
|
208
|
+
case "ellipse":
|
|
209
|
+
element = document.createElementNS(SVG_NS, "ellipse");
|
|
210
|
+
element.setAttribute("cx", String(shape.cx));
|
|
211
|
+
element.setAttribute("cy", String(shape.cy));
|
|
212
|
+
element.setAttribute("rx", String(shape.rx));
|
|
213
|
+
element.setAttribute("ry", String(shape.ry));
|
|
214
|
+
break;
|
|
215
|
+
case "line":
|
|
216
|
+
element = document.createElementNS(SVG_NS, "line");
|
|
217
|
+
element.setAttribute("x1", String(shape.x1));
|
|
218
|
+
element.setAttribute("y1", String(shape.y1));
|
|
219
|
+
element.setAttribute("x2", String(shape.x2));
|
|
220
|
+
element.setAttribute("y2", String(shape.y2));
|
|
221
|
+
break;
|
|
222
|
+
case "polyline":
|
|
223
|
+
element = document.createElementNS(SVG_NS, "polyline");
|
|
224
|
+
element.setAttribute("points", shape.points.map((p) => `${p[0]},${p[1]}`).join(" "));
|
|
225
|
+
break;
|
|
226
|
+
case "polygon":
|
|
227
|
+
element = document.createElementNS(SVG_NS, "polygon");
|
|
228
|
+
element.setAttribute("points", shape.points.map((p) => `${p[0]},${p[1]}`).join(" "));
|
|
229
|
+
break;
|
|
230
|
+
case "path":
|
|
231
|
+
element = document.createElementNS(SVG_NS, "path");
|
|
232
|
+
element.setAttribute("d", commandsToPath(shape.commands, frameMode));
|
|
233
|
+
break;
|
|
234
|
+
case "arc":
|
|
235
|
+
element = document.createElementNS(SVG_NS, "path");
|
|
236
|
+
element.setAttribute("d", arcToPath(shape.cx, shape.cy, shape.r, shape.startAngle, shape.endAngle));
|
|
237
|
+
break;
|
|
238
|
+
case "text":
|
|
239
|
+
element = document.createElementNS(SVG_NS, "text");
|
|
240
|
+
element.setAttribute("x", String(shape.x));
|
|
241
|
+
element.setAttribute("y", String(shape.y));
|
|
242
|
+
element.textContent = shape.content;
|
|
243
|
+
applyTextStyle(element, shape.style);
|
|
244
|
+
if (frameMode) {
|
|
245
|
+
const matrix = shape.transform;
|
|
246
|
+
const a = matrix[0], c = matrix[1], tx = matrix[2];
|
|
247
|
+
const b = matrix[3], d = matrix[4], ty = matrix[5];
|
|
248
|
+
const fx = a * shape.x + c * shape.y + tx;
|
|
249
|
+
const fy = b * shape.x + d * shape.y + ty;
|
|
250
|
+
element.setAttribute(
|
|
251
|
+
"transform",
|
|
252
|
+
`translate(${fx}, ${fy}) scale(1, -1) translate(${-fx}, ${-fy}) matrix(${a},${b},${c},${d},${tx},${ty})`
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
break;
|
|
256
|
+
case "tex":
|
|
257
|
+
element = renderTexShape(shape, frameMode);
|
|
258
|
+
break;
|
|
259
|
+
case "group":
|
|
260
|
+
element = document.createElementNS(SVG_NS, "g");
|
|
261
|
+
for (const child of shape.children) {
|
|
262
|
+
const childElement = renderShape(child, frameMode);
|
|
263
|
+
if (childElement) {
|
|
264
|
+
element.appendChild(childElement);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
break;
|
|
268
|
+
case "svg":
|
|
269
|
+
element = document.createElementNS(SVG_NS, "g");
|
|
270
|
+
const svgShape = shape;
|
|
271
|
+
const parser = new DOMParser();
|
|
272
|
+
const svgDoc = parser.parseFromString(svgShape.content, "image/svg+xml");
|
|
273
|
+
const svgElement = svgDoc.querySelector("svg");
|
|
274
|
+
if (svgElement) {
|
|
275
|
+
const scaleX = shape.width / svgShape.originalWidth;
|
|
276
|
+
const scaleY = shape.height / svgShape.originalHeight;
|
|
277
|
+
element.setAttribute("transform", `scale(${scaleX}, ${scaleY})`);
|
|
278
|
+
for (const child of Array.from(svgElement.childNodes)) {
|
|
279
|
+
element.appendChild(document.importNode(child, true));
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
break;
|
|
283
|
+
case "image":
|
|
284
|
+
element = document.createElementNS(SVG_NS, "image");
|
|
285
|
+
const imgShape = shape;
|
|
286
|
+
element.setAttribute("href", imgShape.src);
|
|
287
|
+
element.setAttribute("x", String(-shape.width / 2));
|
|
288
|
+
element.setAttribute("y", String(-shape.height / 2));
|
|
289
|
+
element.setAttribute("width", String(shape.width));
|
|
290
|
+
element.setAttribute("height", String(shape.height));
|
|
291
|
+
element.setAttribute("preserveAspectRatio", "xMidYMid meet");
|
|
292
|
+
break;
|
|
293
|
+
}
|
|
294
|
+
if (element) {
|
|
295
|
+
element.setAttribute("id", shape.id);
|
|
296
|
+
applyStyle(element, shape.style);
|
|
297
|
+
if (!(frameMode && (shape.type === "text" || shape.type === "tex"))) {
|
|
298
|
+
applyTransform(element, shape.transform);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
return element;
|
|
302
|
+
}
|
|
303
|
+
function shapeToSVGString(shape) {
|
|
304
|
+
const attrs = [`id="${shape.id}"`];
|
|
305
|
+
const style = styleToString(shape.style);
|
|
306
|
+
const transform = transformToString(shape.transform);
|
|
307
|
+
if (style) attrs.push(style);
|
|
308
|
+
if (transform) attrs.push(`transform="${transform}"`);
|
|
309
|
+
switch (shape.type) {
|
|
310
|
+
case "rect":
|
|
311
|
+
attrs.push(`x="${shape.x}" y="${shape.y}" width="${shape.width}" height="${shape.height}"`);
|
|
312
|
+
if (shape.rx) attrs.push(`rx="${shape.rx}"`);
|
|
313
|
+
if (shape.ry) attrs.push(`ry="${shape.ry}"`);
|
|
314
|
+
return `<rect ${attrs.join(" ")}/>`;
|
|
315
|
+
case "circle":
|
|
316
|
+
attrs.push(`cx="${shape.cx}" cy="${shape.cy}" r="${shape.r}"`);
|
|
317
|
+
return `<circle ${attrs.join(" ")}/>`;
|
|
318
|
+
case "ellipse":
|
|
319
|
+
attrs.push(`cx="${shape.cx}" cy="${shape.cy}" rx="${shape.rx}" ry="${shape.ry}"`);
|
|
320
|
+
return `<ellipse ${attrs.join(" ")}/>`;
|
|
321
|
+
case "line":
|
|
322
|
+
attrs.push(`x1="${shape.x1}" y1="${shape.y1}" x2="${shape.x2}" y2="${shape.y2}"`);
|
|
323
|
+
return `<line ${attrs.join(" ")}/>`;
|
|
324
|
+
case "polyline":
|
|
325
|
+
attrs.push(`points="${shape.points.map((p) => `${p[0]},${p[1]}`).join(" ")}"`);
|
|
326
|
+
return `<polyline ${attrs.join(" ")}/>`;
|
|
327
|
+
case "polygon":
|
|
328
|
+
attrs.push(`points="${shape.points.map((p) => `${p[0]},${p[1]}`).join(" ")}"`);
|
|
329
|
+
return `<polygon ${attrs.join(" ")}/>`;
|
|
330
|
+
case "path":
|
|
331
|
+
attrs.push(`d="${commandsToPath(shape.commands)}"`);
|
|
332
|
+
return `<path ${attrs.join(" ")}/>`;
|
|
333
|
+
case "arc":
|
|
334
|
+
attrs.push(`d="${arcToPath(shape.cx, shape.cy, shape.r, shape.startAngle, shape.endAngle)}"`);
|
|
335
|
+
return `<path ${attrs.join(" ")}/>`;
|
|
336
|
+
case "text":
|
|
337
|
+
const textStyle = textStyleToString(shape.style);
|
|
338
|
+
if (textStyle) attrs.push(textStyle);
|
|
339
|
+
attrs.push(`x="${shape.x}" y="${shape.y}"`);
|
|
340
|
+
return `<text ${attrs.join(" ")}>${escapeXML(shape.content)}</text>`;
|
|
341
|
+
case "tex":
|
|
342
|
+
const texShape = shape;
|
|
343
|
+
return `<foreignObject x="${texShape.x}" y="${texShape.y}" width="1000" height="200" overflow="visible"><div xmlns="${XHTML_NS}" style="font-size:${texShape.fontSize}px;color:${texShape.color};display:inline-block;white-space:nowrap">${texShape.html}</div></foreignObject>`;
|
|
344
|
+
case "group":
|
|
345
|
+
const children = shape.children.map(shapeToSVGString).join("");
|
|
346
|
+
return `<g ${attrs.join(" ")}>${children}</g>`;
|
|
347
|
+
case "svg":
|
|
348
|
+
const svgShapeStr = shape;
|
|
349
|
+
const scaleXStr = shape.width / svgShapeStr.originalWidth;
|
|
350
|
+
const scaleYStr = shape.height / svgShapeStr.originalHeight;
|
|
351
|
+
return `<g ${attrs.join(" ")} transform="scale(${scaleXStr}, ${scaleYStr})">${svgShapeStr.content}</g>`;
|
|
352
|
+
case "image":
|
|
353
|
+
const imgShapeStr = shape;
|
|
354
|
+
attrs.push(`href="${imgShapeStr.src}"`);
|
|
355
|
+
attrs.push(`x="${-shape.width / 2}" y="${-shape.height / 2}"`);
|
|
356
|
+
attrs.push(`width="${shape.width}" height="${shape.height}"`);
|
|
357
|
+
attrs.push('preserveAspectRatio="xMidYMid meet"');
|
|
358
|
+
return `<image ${attrs.join(" ")}/>`;
|
|
359
|
+
default:
|
|
360
|
+
return "";
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
function applyStyle(element, style) {
|
|
364
|
+
if (style.fill) element.setAttribute("fill", style.fill);
|
|
365
|
+
if (style.fillOpacity !== void 0) element.setAttribute("fill-opacity", String(style.fillOpacity));
|
|
366
|
+
if (style.stroke) element.setAttribute("stroke", style.stroke);
|
|
367
|
+
if (style.strokeWidth !== void 0) element.setAttribute("stroke-width", String(style.strokeWidth));
|
|
368
|
+
if (style.strokeOpacity !== void 0) element.setAttribute("stroke-opacity", String(style.strokeOpacity));
|
|
369
|
+
if (style.strokeDasharray) element.setAttribute("stroke-dasharray", style.strokeDasharray);
|
|
370
|
+
if (style.strokeLinecap) element.setAttribute("stroke-linecap", style.strokeLinecap);
|
|
371
|
+
if (style.strokeLinejoin) element.setAttribute("stroke-linejoin", style.strokeLinejoin);
|
|
372
|
+
if (style.opacity !== void 0) element.setAttribute("opacity", String(style.opacity));
|
|
373
|
+
}
|
|
374
|
+
function applyTextStyle(element, style) {
|
|
375
|
+
if (style.fontSize) element.setAttribute("font-size", String(style.fontSize));
|
|
376
|
+
if (style.fontFamily) element.setAttribute("font-family", style.fontFamily);
|
|
377
|
+
if (style.fontWeight) element.setAttribute("font-weight", String(style.fontWeight));
|
|
378
|
+
if (style.textAnchor) element.setAttribute("text-anchor", style.textAnchor);
|
|
379
|
+
if (style.dominantBaseline) element.setAttribute("dominant-baseline", style.dominantBaseline);
|
|
380
|
+
}
|
|
381
|
+
function applyTransform(element, matrix) {
|
|
382
|
+
const [a, b, c, d, e, f] = [
|
|
383
|
+
matrix[0],
|
|
384
|
+
matrix[3],
|
|
385
|
+
matrix[1],
|
|
386
|
+
matrix[4],
|
|
387
|
+
matrix[2],
|
|
388
|
+
matrix[5]
|
|
389
|
+
];
|
|
390
|
+
if (a === 1 && b === 0 && c === 0 && d === 1 && e === 0 && f === 0) {
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
element.setAttribute("transform", `matrix(${a},${b},${c},${d},${e},${f})`);
|
|
394
|
+
}
|
|
395
|
+
function styleToString(style) {
|
|
396
|
+
const parts = [];
|
|
397
|
+
if (style.fill) parts.push(`fill="${style.fill}"`);
|
|
398
|
+
if (style.fillOpacity !== void 0) parts.push(`fill-opacity="${style.fillOpacity}"`);
|
|
399
|
+
if (style.stroke) parts.push(`stroke="${style.stroke}"`);
|
|
400
|
+
if (style.strokeWidth !== void 0) parts.push(`stroke-width="${style.strokeWidth}"`);
|
|
401
|
+
if (style.strokeOpacity !== void 0) parts.push(`stroke-opacity="${style.strokeOpacity}"`);
|
|
402
|
+
if (style.strokeDasharray) parts.push(`stroke-dasharray="${style.strokeDasharray}"`);
|
|
403
|
+
if (style.strokeLinecap) parts.push(`stroke-linecap="${style.strokeLinecap}"`);
|
|
404
|
+
if (style.strokeLinejoin) parts.push(`stroke-linejoin="${style.strokeLinejoin}"`);
|
|
405
|
+
if (style.opacity !== void 0) parts.push(`opacity="${style.opacity}"`);
|
|
406
|
+
return parts.join(" ");
|
|
407
|
+
}
|
|
408
|
+
function textStyleToString(style) {
|
|
409
|
+
const parts = [];
|
|
410
|
+
if (style.fontSize) parts.push(`font-size="${style.fontSize}"`);
|
|
411
|
+
if (style.fontFamily) parts.push(`font-family="${style.fontFamily}"`);
|
|
412
|
+
if (style.fontWeight) parts.push(`font-weight="${style.fontWeight}"`);
|
|
413
|
+
if (style.textAnchor) parts.push(`text-anchor="${style.textAnchor}"`);
|
|
414
|
+
if (style.dominantBaseline) parts.push(`dominant-baseline="${style.dominantBaseline}"`);
|
|
415
|
+
return parts.join(" ");
|
|
416
|
+
}
|
|
417
|
+
function transformToString(matrix) {
|
|
418
|
+
const [a, b, c, d, e, f] = [
|
|
419
|
+
matrix[0],
|
|
420
|
+
matrix[3],
|
|
421
|
+
matrix[1],
|
|
422
|
+
matrix[4],
|
|
423
|
+
matrix[2],
|
|
424
|
+
matrix[5]
|
|
425
|
+
];
|
|
426
|
+
if (a === 1 && b === 0 && c === 0 && d === 1 && e === 0 && f === 0) {
|
|
427
|
+
return "";
|
|
428
|
+
}
|
|
429
|
+
return `matrix(${a},${b},${c},${d},${e},${f})`;
|
|
430
|
+
}
|
|
431
|
+
function commandsToPath(commands, _frameMode = false) {
|
|
432
|
+
return commands.map((cmd) => {
|
|
433
|
+
switch (cmd.type) {
|
|
434
|
+
case "M":
|
|
435
|
+
return `M${cmd.x},${cmd.y}`;
|
|
436
|
+
case "L":
|
|
437
|
+
return `L${cmd.x},${cmd.y}`;
|
|
438
|
+
case "H":
|
|
439
|
+
return `H${cmd.x}`;
|
|
440
|
+
case "V":
|
|
441
|
+
return `V${cmd.y}`;
|
|
442
|
+
case "C":
|
|
443
|
+
return `C${cmd.x1},${cmd.y1} ${cmd.x2},${cmd.y2} ${cmd.x},${cmd.y}`;
|
|
444
|
+
case "S":
|
|
445
|
+
return `S${cmd.x2},${cmd.y2} ${cmd.x},${cmd.y}`;
|
|
446
|
+
case "Q":
|
|
447
|
+
return `Q${cmd.x1},${cmd.y1} ${cmd.x},${cmd.y}`;
|
|
448
|
+
case "T":
|
|
449
|
+
return `T${cmd.x},${cmd.y}`;
|
|
450
|
+
case "A": {
|
|
451
|
+
return `A${cmd.rx},${cmd.ry} ${cmd.angle} ${cmd.largeArc ? 1 : 0},${cmd.sweep ? 1 : 0} ${cmd.x},${cmd.y}`;
|
|
452
|
+
}
|
|
453
|
+
case "Z":
|
|
454
|
+
return "Z";
|
|
455
|
+
}
|
|
456
|
+
}).join(" ");
|
|
457
|
+
}
|
|
458
|
+
function arcToPath(cx, cy, r, startAngle, endAngle) {
|
|
459
|
+
const startX = cx + r * Math.cos(startAngle);
|
|
460
|
+
const startY = cy + r * Math.sin(startAngle);
|
|
461
|
+
const endX = cx + r * Math.cos(endAngle);
|
|
462
|
+
const endY = cy + r * Math.sin(endAngle);
|
|
463
|
+
const largeArc = Math.abs(endAngle - startAngle) > Math.PI ? 1 : 0;
|
|
464
|
+
const sweep = endAngle > startAngle ? 1 : 0;
|
|
465
|
+
return `M${startX},${startY} A${r},${r} 0 ${largeArc},${sweep} ${endX},${endY}`;
|
|
466
|
+
}
|
|
467
|
+
function escapeXML(str) {
|
|
468
|
+
if (typeof str !== "string") {
|
|
469
|
+
str = String(str != null ? str : "");
|
|
470
|
+
}
|
|
471
|
+
return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
472
|
+
}
|
|
473
|
+
var DEFAULT_FRAME, XHTML_NS, katexStyleInjected, SVG_NS;
|
|
474
|
+
var init_render_svg = __esm({
|
|
475
|
+
"src/core/render-svg.ts"() {
|
|
476
|
+
"use strict";
|
|
477
|
+
DEFAULT_FRAME = {
|
|
478
|
+
width: 16,
|
|
479
|
+
height: 9
|
|
480
|
+
};
|
|
481
|
+
XHTML_NS = "http://www.w3.org/1999/xhtml";
|
|
482
|
+
katexStyleInjected = false;
|
|
483
|
+
SVG_NS = "http://www.w3.org/2000/svg";
|
|
484
|
+
}
|
|
485
|
+
});
|
|
486
|
+
|
|
487
|
+
export {
|
|
488
|
+
__spreadValues,
|
|
489
|
+
__spreadProps,
|
|
490
|
+
__objRest,
|
|
491
|
+
__esm,
|
|
492
|
+
__export,
|
|
493
|
+
__toCommonJS,
|
|
494
|
+
renderToSVG,
|
|
495
|
+
toSVGString,
|
|
496
|
+
init_render_svg
|
|
497
|
+
};
|