@stacksjs/stx 0.2.470 → 0.2.472
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-06h5b4ae.js +2 -0
- package/dist/{chunk-y42ge4xh.js → chunk-0s3kjdqz.js} +20 -20
- package/dist/{chunk-rdn3egy7.js → chunk-0tv7srqw.js} +1 -1
- package/dist/chunk-1385gt0h.js +2 -0
- package/dist/chunk-1h3xv51f.js +2 -0
- package/dist/{chunk-qf7da9f6.js → chunk-2542vq5p.js} +1 -1
- package/dist/{chunk-9kb3my0w.js → chunk-27kb6nrb.js} +2 -2
- package/dist/{chunk-pz537q62.js → chunk-28s5x7wv.js} +2 -2
- package/dist/{chunk-cxkyt6ht.js → chunk-2cjz23ed.js} +1 -1
- package/dist/chunk-2e0bgme3.js +2 -0
- package/dist/chunk-2j105ssm.js +2 -0
- package/dist/chunk-2njt4vbe.js +2 -0
- package/dist/chunk-2sq74c7t.js +2 -0
- package/dist/chunk-31rx2tgv.js +2 -0
- package/dist/chunk-46zk1sva.js +2 -0
- package/dist/chunk-4aw47rmg.js +2 -0
- package/dist/{chunk-f64rmdvt.js → chunk-4dn8fjv6.js} +2 -2
- package/dist/{chunk-wzeq29c1.js → chunk-5jxxfs61.js} +2 -2
- package/dist/{chunk-hvmtpe7w.js → chunk-62vwxyvr.js} +1 -1
- package/dist/{chunk-y8h823cb.js → chunk-74j18qk0.js} +28 -28
- package/dist/chunk-7tw5m0y7.js +2 -0
- package/dist/{chunk-594tt40e.js → chunk-8adstrk5.js} +2 -2
- package/dist/{chunk-j3z1bfjt.js → chunk-8wfs6753.js} +1 -1
- package/dist/{chunk-xts31rkc.js → chunk-910yr22j.js} +96 -96
- package/dist/{chunk-yv00fy8z.js → chunk-99j03b1k.js} +1 -1
- package/dist/{chunk-scvzv5y2.js → chunk-99kt56fn.js} +2 -2
- package/dist/{chunk-mn6gcvk9.js → chunk-9j5xghg9.js} +4 -4
- package/dist/{chunk-250psr2a.js → chunk-9kzk7zyy.js} +1 -1
- package/dist/{chunk-mx446wgp.js → chunk-9ztdvnkk.js} +2 -2
- package/dist/chunk-bbx35ba3.js +2 -0
- package/dist/chunk-bepnzs0v.js +2 -0
- package/dist/{chunk-564pmmj3.js → chunk-bqx3dqv1.js} +1 -1
- package/dist/chunk-cg8hg6cs.js +3 -0
- package/dist/{chunk-5rx7ptse.js → chunk-cxbp2m66.js} +2 -2
- package/dist/{chunk-71ttf2ne.js → chunk-dhd4fy4d.js} +1 -1
- package/dist/{chunk-rvzx5s72.js → chunk-dts9z53c.js} +1 -1
- package/dist/{chunk-9pjy59d6.js → chunk-ebxkd6t4.js} +65 -65
- package/dist/{chunk-98gxw97n.js → chunk-ecr642nj.js} +1 -1
- package/dist/{chunk-6vstn9dk.js → chunk-gkj42zq7.js} +1 -1
- package/dist/{chunk-2qz5gqqe.js → chunk-grzm54tq.js} +7 -7
- package/dist/{chunk-a6amx427.js → chunk-h5wbt9kn.js} +1 -1
- package/dist/chunk-j338fs8k.js +2 -0
- package/dist/chunk-jcddb0cg.js +2 -0
- package/dist/chunk-jce36k67.js +2 -0
- package/dist/chunk-jkeyh3tk.js +2 -0
- package/dist/chunk-k4yv8d99.js +2 -0
- package/dist/chunk-kq81b4g2.js +2 -0
- package/dist/chunk-m5dgc757.js +2 -0
- package/dist/{chunk-dj3b04tn.js → chunk-m8w4hve0.js} +1 -1
- package/dist/{chunk-6sken7b2.js → chunk-mm82qk7b.js} +1 -1
- package/dist/chunk-mmh37ywa.js +2 -0
- package/dist/{chunk-3jjevm1j.js → chunk-mwr2mfy0.js} +6 -6
- package/dist/chunk-mxb3pcjk.js +2 -0
- package/dist/chunk-mz1mrxeg.js +2 -0
- package/dist/chunk-qkps282f.js +2 -0
- package/dist/{chunk-8v24kvjk.js → chunk-qm9hwar4.js} +1 -1
- package/dist/{chunk-yd7g02v5.js → chunk-s10r6hxp.js} +7 -7
- package/dist/chunk-s545g4mf.js +2 -0
- package/dist/{chunk-3c6v9hp1.js → chunk-sqat6rbj.js} +1 -1
- package/dist/{chunk-9q3dbv0w.js → chunk-sw168dnp.js} +1 -1
- package/dist/{chunk-ktvr45qg.js → chunk-t61vdbje.js} +6 -6
- package/dist/{chunk-aw4jxj6a.js → chunk-t7s0pdtw.js} +2 -2
- package/dist/{chunk-gskjzw5r.js → chunk-tbef3yyk.js} +3 -3
- package/dist/chunk-v81y568k.js +2 -0
- package/dist/chunk-vrs86fxc.js +2 -0
- package/dist/{chunk-tydxqfs6.js → chunk-vvqxq8s1.js} +1 -1
- package/dist/{chunk-nma8b17c.js → chunk-w1fy86aa.js} +22 -5
- package/dist/chunk-wbgmfyd2.js +33 -0
- package/dist/{chunk-3q9hhpvz.js → chunk-x99t4atr.js} +1 -1
- package/dist/{chunk-xc27xdm6.js → chunk-xgw58rzk.js} +1 -1
- package/dist/{chunk-hjhz90kg.js → chunk-xnjcmhs5.js} +2 -2
- package/dist/{chunk-wc6k446y.js → chunk-xweh2gem.js} +3 -3
- package/dist/chunk-y4nk5b2h.js +2 -0
- package/dist/chunk-yr17q3z0.js +2 -0
- package/dist/chunk-zb5p05v4.js +2 -0
- package/dist/{chunk-168dqya1.js → chunk-zkg0rbmp.js} +3 -3
- package/dist/{chunk-r7m8dh2g.js → chunk-zs131awg.js} +5 -5
- package/dist/cli.js +43 -43
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/native/compiler/headwind-to-style.js +28 -0
- package/dist/native/compiler/html-to-ir.js +67 -4
- package/dist/native/compiler/ir.d.ts +15 -1
- package/dist/native/compiler/svg.d.ts +86 -0
- package/dist/native/compiler/svg.js +414 -0
- package/dist/native/prop-names.js +2 -0
- package/dist/native/runtime/native-host.js +22 -9
- package/dist/pwa.js +3 -3
- package/dist/signals.js +22 -5
- package/dist/ssg.js +2 -2
- package/package.json +5 -5
- package/dist/chunk-0q8xacmn.js +0 -2
- package/dist/chunk-2a22ep8p.js +0 -2
- package/dist/chunk-4waxn99v.js +0 -2
- package/dist/chunk-695de40v.js +0 -2
- package/dist/chunk-6a1g18h4.js +0 -2
- package/dist/chunk-94d2t16y.js +0 -2
- package/dist/chunk-b5mfa6w6.js +0 -2
- package/dist/chunk-bprn7crb.js +0 -2
- package/dist/chunk-cxgr65kt.js +0 -33
- package/dist/chunk-ds6eqyq2.js +0 -2
- package/dist/chunk-dy0gm4e4.js +0 -2
- package/dist/chunk-e8ewjcmj.js +0 -2
- package/dist/chunk-fkgdbdqa.js +0 -2
- package/dist/chunk-g9dh9yat.js +0 -2
- package/dist/chunk-gg4hrjrf.js +0 -2
- package/dist/chunk-gna3h2yv.js +0 -2
- package/dist/chunk-gyfb3rj5.js +0 -2
- package/dist/chunk-gzk5ak8f.js +0 -2
- package/dist/chunk-j04s01mf.js +0 -2
- package/dist/chunk-kyda9myt.js +0 -2
- package/dist/chunk-m4sd2ker.js +0 -2
- package/dist/chunk-mhjndjjb.js +0 -2
- package/dist/chunk-nrjevcyh.js +0 -2
- package/dist/chunk-pq9978k5.js +0 -2
- package/dist/chunk-r0gx4p2m.js +0 -2
- package/dist/chunk-rskf20cw.js +0 -2
- package/dist/chunk-sz2cf4w6.js +0 -2
- package/dist/chunk-vbbrtrcg.js +0 -2
- package/dist/chunk-vc24bahj.js +0 -2
- package/dist/chunk-vkgsj6k0.js +0 -2
- package/dist/chunk-y51pb1tc.js +0 -2
- package/dist/chunk-yn2d8x8m.js +0 -3
|
@@ -748,6 +748,32 @@ function parseTextColor(className, style) {
|
|
|
748
748
|
}
|
|
749
749
|
return !1;
|
|
750
750
|
}
|
|
751
|
+
function parseVectorPaint(className, style) {
|
|
752
|
+
for (const property of ["fill", "stroke"]) {
|
|
753
|
+
const prefix = `${property}-`;
|
|
754
|
+
if (!className.startsWith(prefix))
|
|
755
|
+
continue;
|
|
756
|
+
const value = className.slice(prefix.length);
|
|
757
|
+
if (value === "none") {
|
|
758
|
+
style[property] = "none";
|
|
759
|
+
return !0;
|
|
760
|
+
}
|
|
761
|
+
if (property === "stroke" && /^\d+(?:\.\d+)?$/.test(value)) {
|
|
762
|
+
style.strokeWidth = Number.parseFloat(value);
|
|
763
|
+
return !0;
|
|
764
|
+
}
|
|
765
|
+
if (property === "stroke" && /^\[\d+(?:\.\d+)?(?:px)?\]$/.test(value)) {
|
|
766
|
+
style.strokeWidth = Number.parseFloat(value.slice(1));
|
|
767
|
+
return !0;
|
|
768
|
+
}
|
|
769
|
+
const color = resolveColor(value);
|
|
770
|
+
if (color) {
|
|
771
|
+
style[property] = color;
|
|
772
|
+
return !0;
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
return !1;
|
|
776
|
+
}
|
|
751
777
|
function parsePadding(className, style) {
|
|
752
778
|
if (className.startsWith("p-")) {
|
|
753
779
|
const size = resolveSpacing(className.slice(2));
|
|
@@ -1131,6 +1157,8 @@ export function compileHeadwindToStyle(classes, unknown) {
|
|
|
1131
1157
|
}
|
|
1132
1158
|
if (parseBackgroundColor(className, style))
|
|
1133
1159
|
continue;
|
|
1160
|
+
if (parseVectorPaint(className, style))
|
|
1161
|
+
continue;
|
|
1134
1162
|
if (parseTextColor(className, style))
|
|
1135
1163
|
continue;
|
|
1136
1164
|
if (parsePadding(className, style))
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { nativePropName } from "../prop-names.js";
|
|
2
2
|
import { mapToNativeComponent } from "./component-mapping.js";
|
|
3
3
|
import { resolveIconName } from "./icons.js";
|
|
4
|
+
import { parseViewBox, SVG_DROPPED, SVG_NODE_TYPES, SVG_TYPES, svgGeometry } from "./svg.js";
|
|
4
5
|
import { compileClassStyles } from "./headwind-to-style.js";
|
|
5
6
|
import { createDocument, createNode } from "./ir.js";
|
|
6
|
-
const DROP_SUBTREE = new Set(["script", "style", "head", "meta", "link", "title", "base", "noscript"
|
|
7
|
+
const DROP_SUBTREE = new Set(["script", "style", "head", "meta", "link", "title", "base", "noscript"]), UNWRAP = new Set(["template", "body", "html", "main", "fragment"]), BOX_ONLY = new Set, EVENT_NAMES = {
|
|
7
8
|
click: "onPress",
|
|
8
9
|
press: "onPress",
|
|
9
10
|
"press-in": "onPressIn",
|
|
@@ -151,7 +152,10 @@ const STYLE_KEYS = new Set([
|
|
|
151
152
|
"resizeMode",
|
|
152
153
|
"tintColor",
|
|
153
154
|
"transform",
|
|
154
|
-
"overflow"
|
|
155
|
+
"overflow",
|
|
156
|
+
"fill",
|
|
157
|
+
"stroke",
|
|
158
|
+
"strokeWidth"
|
|
155
159
|
]), NUMERIC_STYLE_KEYS = new Set([
|
|
156
160
|
"gridColumns",
|
|
157
161
|
"gridAutoRows",
|
|
@@ -179,7 +183,8 @@ const STYLE_KEYS = new Set([
|
|
|
179
183
|
"elevation",
|
|
180
184
|
"fontSize",
|
|
181
185
|
"lineHeight",
|
|
182
|
-
"letterSpacing"
|
|
186
|
+
"letterSpacing",
|
|
187
|
+
"strokeWidth"
|
|
183
188
|
]), DIMENSION_STYLE_KEYS = new Set([
|
|
184
189
|
"top",
|
|
185
190
|
"right",
|
|
@@ -229,7 +234,8 @@ const STYLE_KEYS = new Set([
|
|
|
229
234
|
"Modal",
|
|
230
235
|
"ActivityIndicator",
|
|
231
236
|
"StatusBar",
|
|
232
|
-
"RefreshControl"
|
|
237
|
+
"RefreshControl",
|
|
238
|
+
...SVG_NODE_TYPES
|
|
233
239
|
]), CONTAINER_TYPES = new Set(["View", "SafeAreaView", "ScrollView", "KeyboardAvoidingView"]), ENTITIES = {
|
|
234
240
|
amp: "&",
|
|
235
241
|
lt: "<",
|
|
@@ -365,6 +371,15 @@ function flattenText(node) {
|
|
|
365
371
|
}
|
|
366
372
|
function settle(frame, diagnostics) {
|
|
367
373
|
const node = frame.node, elements = node.children.filter((child) => typeof child !== "string"), text = node.children.filter((child) => typeof child === "string").join("").trim();
|
|
374
|
+
if (node.type === "Svg" || node.type === "G") {
|
|
375
|
+
node.children = elements;
|
|
376
|
+
return node;
|
|
377
|
+
}
|
|
378
|
+
if (node.type === "SvgText") {
|
|
379
|
+
const flattened = flattenText(node);
|
|
380
|
+
node.children = flattened ? [flattened] : [];
|
|
381
|
+
return node;
|
|
382
|
+
}
|
|
368
383
|
if (CONTAINER_TYPES.has(node.type) && elements.length === 0 && text) {
|
|
369
384
|
node.type = "Text";
|
|
370
385
|
node.children = [text];
|
|
@@ -412,6 +427,9 @@ export async function translateHtmlToIR(html, options = {}) {
|
|
|
412
427
|
}
|
|
413
428
|
}
|
|
414
429
|
function open(tag, attributes) {
|
|
430
|
+
const parentFrame = stack[stack.length - 1];
|
|
431
|
+
if (tag === "svg" || parentFrame?.svg)
|
|
432
|
+
return openSvg(tag, attributes, parentFrame);
|
|
415
433
|
const dropped = DROP_SUBTREE.has(tag) && !BOX_ONLY.has(tag), inheritedDrop = stack[stack.length - 1]?.dropped ?? !1, { props, style, events, bindings, classes, inline } = dropped || inheritedDrop ? { props: {}, style: {}, events: {}, bindings: {}, classes: "", inline: {} } : readAttributes(tag, attributes, diagnostics), declared = props["data-native"];
|
|
416
434
|
let type;
|
|
417
435
|
if (typeof declared === "string" && NATIVE_TYPES.has(declared)) {
|
|
@@ -453,6 +471,51 @@ export async function translateHtmlToIR(html, options = {}) {
|
|
|
453
471
|
unwrap: UNWRAP.has(tag)
|
|
454
472
|
};
|
|
455
473
|
}
|
|
474
|
+
function openSvg(tag, attributes, parent) {
|
|
475
|
+
const inheritedDrop = parent?.dropped ?? !1, type = SVG_TYPES[tag];
|
|
476
|
+
if (inheritedDrop || !type) {
|
|
477
|
+
if (!inheritedDrop && !seenUnmapped.has(`drop:${tag}`)) {
|
|
478
|
+
seenUnmapped.add(`drop:${tag}`);
|
|
479
|
+
diagnostics.push({ kind: SVG_DROPPED.has(tag) ? "dropped-subtree" : "unmapped-tag", tag });
|
|
480
|
+
}
|
|
481
|
+
return { tag, node: createNode("G", {}, {}, {}), svg: !0, dropped: !0, discard: !0, unwrap: !1 };
|
|
482
|
+
}
|
|
483
|
+
const { props, style, events, bindings, classes, inline } = readAttributes(tag, attributes, diagnostics);
|
|
484
|
+
if (type === "Svg") {
|
|
485
|
+
const viewBox = parseViewBox(props.viewBox);
|
|
486
|
+
if (viewBox)
|
|
487
|
+
props.viewBox = viewBox;
|
|
488
|
+
else
|
|
489
|
+
delete props.viewBox;
|
|
490
|
+
for (const axis of ["width", "height"]) {
|
|
491
|
+
if (typeof props[axis] === "number" && style[axis] === void 0)
|
|
492
|
+
style[axis] = props[axis];
|
|
493
|
+
delete props[axis];
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
if (typeof props.strokeDasharray === "string" || typeof props.strokeDasharray === "number") {
|
|
497
|
+
const dashes = String(props.strokeDasharray).split(/[\s,]+/).map(Number).filter(Number.isFinite);
|
|
498
|
+
props.strokeDasharray = dashes;
|
|
499
|
+
}
|
|
500
|
+
const geometry = svgGeometry(type, props);
|
|
501
|
+
if (geometry)
|
|
502
|
+
props.geometry = geometry;
|
|
503
|
+
const node = createNode(type, props, style, events);
|
|
504
|
+
node._inlineStyle = inline;
|
|
505
|
+
const bindingId = props["data-stx-b"];
|
|
506
|
+
if (typeof bindingId === "number" && Number.isInteger(bindingId))
|
|
507
|
+
node.bindingId = bindingId;
|
|
508
|
+
delete props["data-stx-b"];
|
|
509
|
+
if (classes)
|
|
510
|
+
node._classes = classes;
|
|
511
|
+
if (Object.keys(bindings).length > 0)
|
|
512
|
+
node.bindings = bindings;
|
|
513
|
+
if (typeof props.key === "string") {
|
|
514
|
+
node.key = props.key;
|
|
515
|
+
delete props.key;
|
|
516
|
+
}
|
|
517
|
+
return { tag, node, svg: !0, dropped: !1, discard: !1, unwrap: !1 };
|
|
518
|
+
}
|
|
456
519
|
await new HTMLRewriter().on("*", {
|
|
457
520
|
element(element) {
|
|
458
521
|
const tag = element.tagName.toLowerCase(), frame = open(tag, [...element.attributes]);
|
|
@@ -107,6 +107,9 @@ export declare interface STXStyle {
|
|
|
107
107
|
shadowRadius?: number
|
|
108
108
|
elevation?: number
|
|
109
109
|
color?: string
|
|
110
|
+
fill?: string
|
|
111
|
+
stroke?: string
|
|
112
|
+
strokeWidth?: number
|
|
110
113
|
fontSize?: number
|
|
111
114
|
fontWeight?: 'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900'
|
|
112
115
|
fontStyle?: 'normal' | 'italic'
|
|
@@ -209,7 +212,18 @@ export type STXComponentType = | 'View'
|
|
|
209
212
|
| 'ActivityIndicator'
|
|
210
213
|
// Platform specific
|
|
211
214
|
| 'StatusBar'
|
|
212
|
-
| 'RefreshControl'
|
|
215
|
+
| 'RefreshControl'
|
|
216
|
+
// Vector drawing (svg.ts)
|
|
217
|
+
| 'Svg'
|
|
218
|
+
| 'G'
|
|
219
|
+
| 'Path'
|
|
220
|
+
| 'Line'
|
|
221
|
+
| 'Rect'
|
|
222
|
+
| 'Circle'
|
|
223
|
+
| 'Ellipse'
|
|
224
|
+
| 'Polyline'
|
|
225
|
+
| 'Polygon'
|
|
226
|
+
| 'SvgText';
|
|
213
227
|
// ============================================================================
|
|
214
228
|
// Event Types
|
|
215
229
|
// ============================================================================
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/** `"0 0 320 180"` (or with commas) to four numbers, or null. */
|
|
2
|
+
export declare function parseViewBox(value: unknown): [number, number, number, number] | null;
|
|
3
|
+
/** Path data to absolute commands. Unknown or malformed parts end the path, as a browser does. */
|
|
4
|
+
export declare function pathGeometry(d: string): number[];
|
|
5
|
+
/**
|
|
6
|
+
* A shape's outline as absolute commands, from its attributes. Null for a
|
|
7
|
+
* type that has none (`Svg`, `G`, `SvgText`).
|
|
8
|
+
*/
|
|
9
|
+
export declare function svgGeometry(type: string, props: Record<string, unknown>): number[] | null;
|
|
10
|
+
/** Whether changing `attribute` on a `type` node changes its outline. */
|
|
11
|
+
export declare function affectsGeometry(type: string, attribute: string): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Vector drawing for native screens: `<svg>` and the shapes inside it.
|
|
14
|
+
*
|
|
15
|
+
* The translator used to keep an `svg`'s box and drop everything in it, on the
|
|
16
|
+
* grounds that the IR had no way to say "a path". That left every chart, route
|
|
17
|
+
* map and progress ring on a native screen as an empty rectangle - a screen
|
|
18
|
+
* with a fitness chart could not go native at all.
|
|
19
|
+
*
|
|
20
|
+
* The shapes now become IR nodes of their own (`Svg`, `G`, `Path`, `Line`,
|
|
21
|
+
* `Rect`, `Circle`, `Ellipse`, `Polyline`, `Polygon`, `SvgText`), so a `:for`
|
|
22
|
+
* over bars or a `:d` bound to a signal is reactive through the ordinary
|
|
23
|
+
* mutation protocol. What a renderer would otherwise have to understand three
|
|
24
|
+
* times over - path data with its relative commands, smooth curves and
|
|
25
|
+
* elliptical arcs, and the seven shape elements - is reduced here, once, to a
|
|
26
|
+
* single flat list of absolute commands in viewBox units:
|
|
27
|
+
*
|
|
28
|
+
* 0 x y move to
|
|
29
|
+
* 1 x y line to
|
|
30
|
+
* 2 x1 y1 x2 y2 x y cubic curve to
|
|
31
|
+
* 3 x1 y1 x y quadratic curve to
|
|
32
|
+
* 4 close
|
|
33
|
+
*
|
|
34
|
+
* carried as the shape's `geometry` prop. A renderer replays it, scaled from
|
|
35
|
+
* the `Svg`'s viewBox to its frame, and paints it with the fill and stroke the
|
|
36
|
+
* shape inherits down the tree. The compiler sets `geometry` for the
|
|
37
|
+
* attributes a template writes; the native host recomputes it whenever a bound
|
|
38
|
+
* attribute changes.
|
|
39
|
+
*
|
|
40
|
+
* @module native/compiler/svg
|
|
41
|
+
*/
|
|
42
|
+
/** An element inside `<svg>`, by tag, to the IR type that draws it. */
|
|
43
|
+
export declare const SVG_TYPES: {
|
|
44
|
+
svg: 'Svg';
|
|
45
|
+
g: 'G';
|
|
46
|
+
path: 'Path';
|
|
47
|
+
line: 'Line';
|
|
48
|
+
rect: 'Rect';
|
|
49
|
+
circle: 'Circle';
|
|
50
|
+
ellipse: 'Ellipse';
|
|
51
|
+
polyline: 'Polyline';
|
|
52
|
+
polygon: 'Polygon';
|
|
53
|
+
text: 'SvgText';
|
|
54
|
+
tspan: 'SvgText'
|
|
55
|
+
};
|
|
56
|
+
/** Every IR type a vector drawing is made of. */
|
|
57
|
+
export declare const SVG_NODE_TYPES: Set<any>;
|
|
58
|
+
/** The types `geometry` is computed for. */
|
|
59
|
+
export declare const SVG_SHAPE_TYPES: Set<any>;
|
|
60
|
+
/**
|
|
61
|
+
* Elements inside `<svg>` that are not drawn: definitions, metadata, and what
|
|
62
|
+
* the renderers do not implement yet (gradients, masks, clips, markers). Their
|
|
63
|
+
* subtree is dropped and reported, rather than drawn wrong.
|
|
64
|
+
*/
|
|
65
|
+
export declare const SVG_DROPPED: Set<any>;
|
|
66
|
+
/**
|
|
67
|
+
* SVG attribute names in the camel case the renderers read. The HTML parser
|
|
68
|
+
* lowercases `viewBox`, and a template writes `stroke-width`; both arrive as
|
|
69
|
+
* the one spelling.
|
|
70
|
+
*/
|
|
71
|
+
export declare const SVG_PROP_NAMES: readonly ['viewBox', 'preserveAspectRatio', 'strokeWidth', 'strokeDasharray', 'strokeDashoffset', 'strokeLinecap', 'strokeLinejoin', 'strokeMiterlimit', 'strokeOpacity', 'fillOpacity', 'fillRule', 'vectorEffect', 'textAnchor', 'dominantBaseline', 'fontSize', 'fontWeight'];
|
|
72
|
+
/** The attributes `geometry` is read from, per shape. */
|
|
73
|
+
export declare const SVG_GEOMETRY_ATTRIBUTES: {
|
|
74
|
+
Path: readonly ['d'];
|
|
75
|
+
Line: readonly ['x1', 'y1', 'x2', 'y2'];
|
|
76
|
+
Rect: readonly ['x', 'y', 'width', 'height', 'rx', 'ry'];
|
|
77
|
+
Circle: readonly ['cx', 'cy', 'r'];
|
|
78
|
+
Ellipse: readonly ['cx', 'cy', 'rx', 'ry'];
|
|
79
|
+
Polyline: readonly ['points'];
|
|
80
|
+
Polygon: readonly ['points']
|
|
81
|
+
};
|
|
82
|
+
export declare const MOVE: 0;
|
|
83
|
+
export declare const LINE: 1;
|
|
84
|
+
export declare const CUBIC: 2;
|
|
85
|
+
export declare const QUAD: 3;
|
|
86
|
+
export declare const CLOSE: 4;
|
|
@@ -0,0 +1,414 @@
|
|
|
1
|
+
export const SVG_TYPES = {
|
|
2
|
+
svg: "Svg",
|
|
3
|
+
g: "G",
|
|
4
|
+
path: "Path",
|
|
5
|
+
line: "Line",
|
|
6
|
+
rect: "Rect",
|
|
7
|
+
circle: "Circle",
|
|
8
|
+
ellipse: "Ellipse",
|
|
9
|
+
polyline: "Polyline",
|
|
10
|
+
polygon: "Polygon",
|
|
11
|
+
text: "SvgText",
|
|
12
|
+
tspan: "SvgText"
|
|
13
|
+
}, SVG_NODE_TYPES = new Set(Object.values(SVG_TYPES)), SVG_SHAPE_TYPES = new Set(["Path", "Line", "Rect", "Circle", "Ellipse", "Polyline", "Polygon"]), SVG_DROPPED = new Set([
|
|
14
|
+
"defs",
|
|
15
|
+
"title",
|
|
16
|
+
"desc",
|
|
17
|
+
"metadata",
|
|
18
|
+
"style",
|
|
19
|
+
"symbol",
|
|
20
|
+
"use",
|
|
21
|
+
"clippath",
|
|
22
|
+
"mask",
|
|
23
|
+
"lineargradient",
|
|
24
|
+
"radialgradient",
|
|
25
|
+
"stop",
|
|
26
|
+
"pattern",
|
|
27
|
+
"marker",
|
|
28
|
+
"filter",
|
|
29
|
+
"foreignobject"
|
|
30
|
+
]), SVG_PROP_NAMES = [
|
|
31
|
+
"viewBox",
|
|
32
|
+
"preserveAspectRatio",
|
|
33
|
+
"strokeWidth",
|
|
34
|
+
"strokeDasharray",
|
|
35
|
+
"strokeDashoffset",
|
|
36
|
+
"strokeLinecap",
|
|
37
|
+
"strokeLinejoin",
|
|
38
|
+
"strokeMiterlimit",
|
|
39
|
+
"strokeOpacity",
|
|
40
|
+
"fillOpacity",
|
|
41
|
+
"fillRule",
|
|
42
|
+
"vectorEffect",
|
|
43
|
+
"textAnchor",
|
|
44
|
+
"dominantBaseline",
|
|
45
|
+
"fontSize",
|
|
46
|
+
"fontWeight"
|
|
47
|
+
], SVG_GEOMETRY_ATTRIBUTES = {
|
|
48
|
+
Path: ["d"],
|
|
49
|
+
Line: ["x1", "y1", "x2", "y2"],
|
|
50
|
+
Rect: ["x", "y", "width", "height", "rx", "ry"],
|
|
51
|
+
Circle: ["cx", "cy", "r"],
|
|
52
|
+
Ellipse: ["cx", "cy", "rx", "ry"],
|
|
53
|
+
Polyline: ["points"],
|
|
54
|
+
Polygon: ["points"]
|
|
55
|
+
}, MOVE = 0, LINE = 1, CUBIC = 2, QUAD = 3, CLOSE = 4;
|
|
56
|
+
function num(value) {
|
|
57
|
+
const parsed = typeof value === "number" ? value : Number.parseFloat(String(value ?? ""));
|
|
58
|
+
return Number.isFinite(parsed) ? parsed : 0;
|
|
59
|
+
}
|
|
60
|
+
function round(value) {
|
|
61
|
+
return Math.round(value * 1000) / 1000;
|
|
62
|
+
}
|
|
63
|
+
export function parseViewBox(value) {
|
|
64
|
+
if (Array.isArray(value) && value.length === 4 && value.every((item) => Number.isFinite(Number(item))))
|
|
65
|
+
return value.map(Number);
|
|
66
|
+
const parts = String(value ?? "").trim().split(/[\s,]+/).map(Number);
|
|
67
|
+
if (parts.length !== 4 || parts.some((part) => !Number.isFinite(part)) || parts[2] <= 0 || parts[3] <= 0)
|
|
68
|
+
return null;
|
|
69
|
+
return parts;
|
|
70
|
+
}
|
|
71
|
+
function parsePoints(value) {
|
|
72
|
+
const list = String(value ?? "").trim().split(/[\s,]+/).filter(Boolean).map(Number).filter(Number.isFinite);
|
|
73
|
+
return list.length % 2 ? list.slice(0, -1) : list;
|
|
74
|
+
}
|
|
75
|
+
const COMMAND = /[MLHVCSQTAZ]/i, NUMBER = /[+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?/gi;
|
|
76
|
+
function tokenize(d) {
|
|
77
|
+
const commands = [];
|
|
78
|
+
let rest = d, match = COMMAND.exec(rest);
|
|
79
|
+
while (match) {
|
|
80
|
+
const start = match.index;
|
|
81
|
+
rest = rest.slice(start);
|
|
82
|
+
const command = rest[0];
|
|
83
|
+
rest = rest.slice(1);
|
|
84
|
+
const next = COMMAND.exec(rest), body = next ? rest.slice(0, next.index) : rest;
|
|
85
|
+
let args;
|
|
86
|
+
if (command === "A" || command === "a") {
|
|
87
|
+
args = [];
|
|
88
|
+
let i = 0;
|
|
89
|
+
const text = body.trim();
|
|
90
|
+
let position = 0;
|
|
91
|
+
while (position < text.length) {
|
|
92
|
+
const slot = i % 7, remaining = text.slice(position).replace(/^[\s,]+/, "");
|
|
93
|
+
position = text.length - remaining.length;
|
|
94
|
+
if (!remaining)
|
|
95
|
+
break;
|
|
96
|
+
if (slot === 3 || slot === 4) {
|
|
97
|
+
args.push(remaining[0] === "1" ? 1 : 0);
|
|
98
|
+
position += 1;
|
|
99
|
+
} else {
|
|
100
|
+
NUMBER.lastIndex = 0;
|
|
101
|
+
const found = NUMBER.exec(remaining);
|
|
102
|
+
if (!found || found.index !== 0)
|
|
103
|
+
break;
|
|
104
|
+
args.push(Number.parseFloat(found[0]));
|
|
105
|
+
position += found[0].length;
|
|
106
|
+
}
|
|
107
|
+
i++;
|
|
108
|
+
}
|
|
109
|
+
} else
|
|
110
|
+
args = (body.match(NUMBER) || []).map(Number.parseFloat);
|
|
111
|
+
commands.push({ command, args });
|
|
112
|
+
match = next;
|
|
113
|
+
}
|
|
114
|
+
return commands;
|
|
115
|
+
}
|
|
116
|
+
function arcToCubics(x1, y1, rxIn, ryIn, rotation, largeArc, sweep, x2, y2) {
|
|
117
|
+
if (x1 === x2 && y1 === y2)
|
|
118
|
+
return [];
|
|
119
|
+
let rx = Math.abs(rxIn), ry = Math.abs(ryIn);
|
|
120
|
+
if (!rx || !ry)
|
|
121
|
+
return [LINE, x2, y2];
|
|
122
|
+
const phi = rotation * Math.PI / 180, cos = Math.cos(phi), sin = Math.sin(phi), dx = (x1 - x2) / 2, dy = (y1 - y2) / 2, x1p = cos * dx + sin * dy, y1p = -sin * dx + cos * dy, lambda = x1p * x1p / (rx * rx) + y1p * y1p / (ry * ry);
|
|
123
|
+
if (lambda > 1) {
|
|
124
|
+
rx *= Math.sqrt(lambda);
|
|
125
|
+
ry *= Math.sqrt(lambda);
|
|
126
|
+
}
|
|
127
|
+
const numerator = rx * rx * ry * ry - rx * rx * y1p * y1p - ry * ry * x1p * x1p, denominator = rx * rx * y1p * y1p + ry * ry * x1p * x1p;
|
|
128
|
+
let factor = Math.sqrt(Math.max(0, numerator / denominator));
|
|
129
|
+
if (largeArc === sweep)
|
|
130
|
+
factor = -factor;
|
|
131
|
+
const cxp = factor * (rx * y1p) / ry, cyp = factor * -(ry * x1p) / rx, cx = cos * cxp - sin * cyp + (x1 + x2) / 2, cy = sin * cxp + cos * cyp + (y1 + y2) / 2, angle = (ux, uy, vx, vy) => {
|
|
132
|
+
const sign = ux * vy - uy * vx < 0 ? -1 : 1, dot = (ux * vx + uy * vy) / (Math.hypot(ux, uy) * Math.hypot(vx, vy));
|
|
133
|
+
return sign * Math.acos(Math.min(1, Math.max(-1, dot)));
|
|
134
|
+
}, theta1 = angle(1, 0, (x1p - cxp) / rx, (y1p - cyp) / ry);
|
|
135
|
+
let delta = angle((x1p - cxp) / rx, (y1p - cyp) / ry, (-x1p - cxp) / rx, (-y1p - cyp) / ry);
|
|
136
|
+
if (!sweep && delta > 0)
|
|
137
|
+
delta -= 2 * Math.PI;
|
|
138
|
+
if (sweep && delta < 0)
|
|
139
|
+
delta += 2 * Math.PI;
|
|
140
|
+
const segments = Math.max(1, Math.ceil(Math.abs(delta) / (Math.PI / 2))), step = delta / segments, k = 1.3333333333333333 * Math.tan(step / 4), out = [], point = (t) => {
|
|
141
|
+
const ex = rx * Math.cos(t), ey = ry * Math.sin(t);
|
|
142
|
+
return [cos * ex - sin * ey + cx, sin * ex + cos * ey + cy];
|
|
143
|
+
}, derivative = (t) => {
|
|
144
|
+
const ex = -rx * Math.sin(t), ey = ry * Math.cos(t);
|
|
145
|
+
return [cos * ex - sin * ey, sin * ex + cos * ey];
|
|
146
|
+
};
|
|
147
|
+
let t = theta1;
|
|
148
|
+
for (let i = 0;i < segments; i++) {
|
|
149
|
+
const t2 = t + step, [px1, py1] = point(t), [dx1, dy1] = derivative(t), [px2, py2] = point(t2), [dx2, dy2] = derivative(t2);
|
|
150
|
+
out.push(CUBIC, px1 + k * dx1, py1 + k * dy1, px2 - k * dx2, py2 - k * dy2, i === segments - 1 ? x2 : px2, i === segments - 1 ? y2 : py2);
|
|
151
|
+
t = t2;
|
|
152
|
+
}
|
|
153
|
+
return out;
|
|
154
|
+
}
|
|
155
|
+
export function pathGeometry(d) {
|
|
156
|
+
const out = [];
|
|
157
|
+
let x = 0, y = 0, startX = 0, startY = 0, cubicX = 0, cubicY = 0, quadX = 0, quadY = 0, previous = "";
|
|
158
|
+
for (const { command, args } of tokenize(String(d ?? ""))) {
|
|
159
|
+
const relative = command === command.toLowerCase(), upper = command.toUpperCase(), ox = () => relative ? x : 0, oy = () => relative ? y : 0;
|
|
160
|
+
let i = 0;
|
|
161
|
+
const take = (count) => {
|
|
162
|
+
if (i + count > args.length)
|
|
163
|
+
return null;
|
|
164
|
+
const slice = args.slice(i, i + count);
|
|
165
|
+
i += count;
|
|
166
|
+
return slice;
|
|
167
|
+
};
|
|
168
|
+
if (upper === "Z") {
|
|
169
|
+
out.push(CLOSE);
|
|
170
|
+
x = startX;
|
|
171
|
+
y = startY;
|
|
172
|
+
previous = "Z";
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
let first = !0;
|
|
176
|
+
while (i < args.length || first && upper === "Z") {
|
|
177
|
+
switch (upper) {
|
|
178
|
+
case "M": {
|
|
179
|
+
const a = take(2);
|
|
180
|
+
if (!a)
|
|
181
|
+
return out;
|
|
182
|
+
x = a[0] + ox();
|
|
183
|
+
y = a[1] + oy();
|
|
184
|
+
if (first) {
|
|
185
|
+
out.push(MOVE, x, y);
|
|
186
|
+
startX = x;
|
|
187
|
+
startY = y;
|
|
188
|
+
} else
|
|
189
|
+
out.push(LINE, x, y);
|
|
190
|
+
previous = first ? "M" : "L";
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
case "L": {
|
|
194
|
+
const a = take(2);
|
|
195
|
+
if (!a)
|
|
196
|
+
return out;
|
|
197
|
+
x = a[0] + ox();
|
|
198
|
+
y = a[1] + oy();
|
|
199
|
+
out.push(LINE, x, y);
|
|
200
|
+
previous = "L";
|
|
201
|
+
break;
|
|
202
|
+
}
|
|
203
|
+
case "H": {
|
|
204
|
+
const a = take(1);
|
|
205
|
+
if (!a)
|
|
206
|
+
return out;
|
|
207
|
+
x = a[0] + ox();
|
|
208
|
+
out.push(LINE, x, y);
|
|
209
|
+
previous = "L";
|
|
210
|
+
break;
|
|
211
|
+
}
|
|
212
|
+
case "V": {
|
|
213
|
+
const a = take(1);
|
|
214
|
+
if (!a)
|
|
215
|
+
return out;
|
|
216
|
+
y = a[0] + oy();
|
|
217
|
+
out.push(LINE, x, y);
|
|
218
|
+
previous = "L";
|
|
219
|
+
break;
|
|
220
|
+
}
|
|
221
|
+
case "C": {
|
|
222
|
+
const a = take(6);
|
|
223
|
+
if (!a)
|
|
224
|
+
return out;
|
|
225
|
+
const x1 = a[0] + ox(), y1 = a[1] + oy();
|
|
226
|
+
cubicX = a[2] + ox();
|
|
227
|
+
cubicY = a[3] + oy();
|
|
228
|
+
x = a[4] + ox();
|
|
229
|
+
y = a[5] + oy();
|
|
230
|
+
out.push(CUBIC, x1, y1, cubicX, cubicY, x, y);
|
|
231
|
+
previous = "C";
|
|
232
|
+
break;
|
|
233
|
+
}
|
|
234
|
+
case "S": {
|
|
235
|
+
const a = take(4);
|
|
236
|
+
if (!a)
|
|
237
|
+
return out;
|
|
238
|
+
const x1 = previous === "C" ? 2 * x - cubicX : x, y1 = previous === "C" ? 2 * y - cubicY : y;
|
|
239
|
+
cubicX = a[0] + ox();
|
|
240
|
+
cubicY = a[1] + oy();
|
|
241
|
+
x = a[2] + ox();
|
|
242
|
+
y = a[3] + oy();
|
|
243
|
+
out.push(CUBIC, x1, y1, cubicX, cubicY, x, y);
|
|
244
|
+
previous = "C";
|
|
245
|
+
break;
|
|
246
|
+
}
|
|
247
|
+
case "Q": {
|
|
248
|
+
const a = take(4);
|
|
249
|
+
if (!a)
|
|
250
|
+
return out;
|
|
251
|
+
quadX = a[0] + ox();
|
|
252
|
+
quadY = a[1] + oy();
|
|
253
|
+
x = a[2] + ox();
|
|
254
|
+
y = a[3] + oy();
|
|
255
|
+
out.push(QUAD, quadX, quadY, x, y);
|
|
256
|
+
previous = "Q";
|
|
257
|
+
break;
|
|
258
|
+
}
|
|
259
|
+
case "T": {
|
|
260
|
+
const a = take(2);
|
|
261
|
+
if (!a)
|
|
262
|
+
return out;
|
|
263
|
+
quadX = previous === "Q" ? 2 * x - quadX : x;
|
|
264
|
+
quadY = previous === "Q" ? 2 * y - quadY : y;
|
|
265
|
+
x = a[0] + ox();
|
|
266
|
+
y = a[1] + oy();
|
|
267
|
+
out.push(QUAD, quadX, quadY, x, y);
|
|
268
|
+
previous = "Q";
|
|
269
|
+
break;
|
|
270
|
+
}
|
|
271
|
+
case "A": {
|
|
272
|
+
const a = take(7);
|
|
273
|
+
if (!a)
|
|
274
|
+
return out;
|
|
275
|
+
const endX = a[5] + ox(), endY = a[6] + oy();
|
|
276
|
+
out.push(...arcToCubics(x, y, a[0], a[1], a[2], a[3], a[4], endX, endY));
|
|
277
|
+
x = endX;
|
|
278
|
+
y = endY;
|
|
279
|
+
previous = "A";
|
|
280
|
+
break;
|
|
281
|
+
}
|
|
282
|
+
default:
|
|
283
|
+
return out;
|
|
284
|
+
}
|
|
285
|
+
first = !1;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
return out.map((value) => round(value));
|
|
289
|
+
}
|
|
290
|
+
function ellipseGeometry(cx, cy, rx, ry) {
|
|
291
|
+
if (rx <= 0 || ry <= 0)
|
|
292
|
+
return [];
|
|
293
|
+
const k = 0.5522847498;
|
|
294
|
+
return [
|
|
295
|
+
MOVE,
|
|
296
|
+
cx + rx,
|
|
297
|
+
cy,
|
|
298
|
+
CUBIC,
|
|
299
|
+
cx + rx,
|
|
300
|
+
cy + k * ry,
|
|
301
|
+
cx + k * rx,
|
|
302
|
+
cy + ry,
|
|
303
|
+
cx,
|
|
304
|
+
cy + ry,
|
|
305
|
+
CUBIC,
|
|
306
|
+
cx - k * rx,
|
|
307
|
+
cy + ry,
|
|
308
|
+
cx - rx,
|
|
309
|
+
cy + k * ry,
|
|
310
|
+
cx - rx,
|
|
311
|
+
cy,
|
|
312
|
+
CUBIC,
|
|
313
|
+
cx - rx,
|
|
314
|
+
cy - k * ry,
|
|
315
|
+
cx - k * rx,
|
|
316
|
+
cy - ry,
|
|
317
|
+
cx,
|
|
318
|
+
cy - ry,
|
|
319
|
+
CUBIC,
|
|
320
|
+
cx + k * rx,
|
|
321
|
+
cy - ry,
|
|
322
|
+
cx + rx,
|
|
323
|
+
cy - k * ry,
|
|
324
|
+
cx + rx,
|
|
325
|
+
cy,
|
|
326
|
+
CLOSE
|
|
327
|
+
].map(round);
|
|
328
|
+
}
|
|
329
|
+
export function svgGeometry(type, props) {
|
|
330
|
+
switch (type) {
|
|
331
|
+
case "Path":
|
|
332
|
+
return pathGeometry(String(props.d ?? ""));
|
|
333
|
+
case "Line":
|
|
334
|
+
return [MOVE, num(props.x1), num(props.y1), LINE, num(props.x2), num(props.y2)].map(round);
|
|
335
|
+
case "Rect": {
|
|
336
|
+
const x = num(props.x), y = num(props.y), width = num(props.width), height = num(props.height);
|
|
337
|
+
if (width <= 0 || height <= 0)
|
|
338
|
+
return [];
|
|
339
|
+
let rx = props.rx === void 0 ? num(props.ry) : num(props.rx), ry = props.ry === void 0 ? rx : num(props.ry);
|
|
340
|
+
rx = Math.min(Math.max(0, rx), width / 2);
|
|
341
|
+
ry = Math.min(Math.max(0, ry), height / 2);
|
|
342
|
+
if (!rx || !ry)
|
|
343
|
+
return [MOVE, x, y, LINE, x + width, y, LINE, x + width, y + height, LINE, x, y + height, CLOSE].map(round);
|
|
344
|
+
const k = 0.5522847498;
|
|
345
|
+
return [
|
|
346
|
+
MOVE,
|
|
347
|
+
x + rx,
|
|
348
|
+
y,
|
|
349
|
+
LINE,
|
|
350
|
+
x + width - rx,
|
|
351
|
+
y,
|
|
352
|
+
CUBIC,
|
|
353
|
+
x + width - rx + k * rx,
|
|
354
|
+
y,
|
|
355
|
+
x + width,
|
|
356
|
+
y + ry - k * ry,
|
|
357
|
+
x + width,
|
|
358
|
+
y + ry,
|
|
359
|
+
LINE,
|
|
360
|
+
x + width,
|
|
361
|
+
y + height - ry,
|
|
362
|
+
CUBIC,
|
|
363
|
+
x + width,
|
|
364
|
+
y + height - ry + k * ry,
|
|
365
|
+
x + width - rx + k * rx,
|
|
366
|
+
y + height,
|
|
367
|
+
x + width - rx,
|
|
368
|
+
y + height,
|
|
369
|
+
LINE,
|
|
370
|
+
x + rx,
|
|
371
|
+
y + height,
|
|
372
|
+
CUBIC,
|
|
373
|
+
x + rx - k * rx,
|
|
374
|
+
y + height,
|
|
375
|
+
x,
|
|
376
|
+
y + height - ry + k * ry,
|
|
377
|
+
x,
|
|
378
|
+
y + height - ry,
|
|
379
|
+
LINE,
|
|
380
|
+
x,
|
|
381
|
+
y + ry,
|
|
382
|
+
CUBIC,
|
|
383
|
+
x,
|
|
384
|
+
y + ry - k * ry,
|
|
385
|
+
x + rx - k * rx,
|
|
386
|
+
y,
|
|
387
|
+
x + rx,
|
|
388
|
+
y,
|
|
389
|
+
CLOSE
|
|
390
|
+
].map(round);
|
|
391
|
+
}
|
|
392
|
+
case "Circle":
|
|
393
|
+
return ellipseGeometry(num(props.cx), num(props.cy), num(props.r), num(props.r));
|
|
394
|
+
case "Ellipse":
|
|
395
|
+
return ellipseGeometry(num(props.cx), num(props.cy), num(props.rx), num(props.ry));
|
|
396
|
+
case "Polyline":
|
|
397
|
+
case "Polygon": {
|
|
398
|
+
const points = parsePoints(props.points);
|
|
399
|
+
if (points.length < 4)
|
|
400
|
+
return [];
|
|
401
|
+
const out = [MOVE, points[0], points[1]];
|
|
402
|
+
for (let i = 2;i < points.length; i += 2)
|
|
403
|
+
out.push(LINE, points[i], points[i + 1]);
|
|
404
|
+
if (type === "Polygon")
|
|
405
|
+
out.push(CLOSE);
|
|
406
|
+
return out.map(round);
|
|
407
|
+
}
|
|
408
|
+
default:
|
|
409
|
+
return null;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
export function affectsGeometry(type, attribute) {
|
|
413
|
+
return SVG_GEOMETRY_ATTRIBUTES[type]?.includes(attribute) ?? !1;
|
|
414
|
+
}
|