@thi.ng/hiccup-svg 5.1.2 → 5.2.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/CHANGELOG.md +8 -1
- package/convert.d.ts +3 -0
- package/convert.js +3 -0
- package/group.d.ts +13 -0
- package/group.js +10 -1
- package/package.json +3 -3
- package/svg.d.ts +8 -1
- package/svg.js +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2023-12-
|
|
3
|
+
- **Last updated**: 2023-12-26T14:10:51Z
|
|
4
4
|
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
|
|
5
5
|
|
|
6
6
|
All notable changes to this project will be documented in this file.
|
|
@@ -9,6 +9,13 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
|
|
|
9
9
|
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
10
10
|
and/or version bumps of transitive dependencies.
|
|
11
11
|
|
|
12
|
+
## [5.2.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/hiccup-svg@5.2.0) (2023-12-26)
|
|
13
|
+
|
|
14
|
+
#### 🚀 Features
|
|
15
|
+
|
|
16
|
+
- include Inkscape xmlns in `<svg>` root ([997850b](https://github.com/thi-ng/umbrella/commit/997850b))
|
|
17
|
+
- add `__inkscapeLayer` group attrib handling ([79a3932](https://github.com/thi-ng/umbrella/commit/79a3932))
|
|
18
|
+
|
|
12
19
|
## [5.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/hiccup-svg@5.1.0) (2023-12-18)
|
|
13
20
|
|
|
14
21
|
#### 🚀 Features
|
package/convert.d.ts
CHANGED
|
@@ -12,6 +12,9 @@
|
|
|
12
12
|
* conversions). See {@link setPrecision}. Child shapes (of a group) inherit the
|
|
13
13
|
* precision setting of their parent.
|
|
14
14
|
*
|
|
15
|
+
* Also see {@link group} for handling of the special `__inkscapeLayer` group
|
|
16
|
+
* attrib.
|
|
17
|
+
*
|
|
15
18
|
* To control the formatting precision for colors, use [the relevant function in
|
|
16
19
|
* the thi.ng/color
|
|
17
20
|
* package](https://docs.thi.ng/umbrella/color/functions/setPrecision.html).
|
package/convert.js
CHANGED
|
@@ -4,6 +4,7 @@ import { circle } from "./circle.js";
|
|
|
4
4
|
import { ellipse } from "./ellipse.js";
|
|
5
5
|
import { PRECISION, fattribs, setPrecision } from "./format.js";
|
|
6
6
|
import { linearGradient, radialGradient } from "./gradients.js";
|
|
7
|
+
import { __groupLayerID } from "./group.js";
|
|
7
8
|
import { image } from "./image.js";
|
|
8
9
|
import { hline, line, vline } from "./line.js";
|
|
9
10
|
import { path } from "./path.js";
|
|
@@ -55,6 +56,8 @@ const convertTree = (tree) => {
|
|
|
55
56
|
case "a":
|
|
56
57
|
case "g":
|
|
57
58
|
result = [type, fattribs(attribs)];
|
|
59
|
+
if (tree[0] === "g")
|
|
60
|
+
__groupLayerID(result[1]);
|
|
58
61
|
for (let i = 2, n = tree.length; i < n; i++) {
|
|
59
62
|
const c = convertTree(tree[i]);
|
|
60
63
|
c != null && result.push(c);
|
package/group.d.ts
CHANGED
|
@@ -1,2 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a new SVG group element in hiccup format.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* If the given attribs contain a `__inkscapeLayer` value (layer name), it will
|
|
6
|
+
* be auto-converted into the correct set of attributes to define that group as
|
|
7
|
+
* Inkscape layer.
|
|
8
|
+
*
|
|
9
|
+
* @param attribs
|
|
10
|
+
* @param body
|
|
11
|
+
*/
|
|
1
12
|
export declare const group: (attribs: any, ...body: any[]) => any[];
|
|
13
|
+
/** @internal */
|
|
14
|
+
export declare const __groupLayerID: (attribs: any) => any;
|
|
2
15
|
//# sourceMappingURL=group.d.ts.map
|
package/group.js
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
import { fattribs } from "./format.js";
|
|
2
2
|
const group = (attribs, ...body) => [
|
|
3
3
|
"g",
|
|
4
|
-
fattribs({ ...attribs }),
|
|
4
|
+
__groupLayerID(fattribs({ ...attribs })),
|
|
5
5
|
...body
|
|
6
6
|
];
|
|
7
|
+
const __groupLayerID = (attribs) => {
|
|
8
|
+
if (attribs.__inkscapeLayer) {
|
|
9
|
+
attribs["inkscape:groupmode"] = "layer";
|
|
10
|
+
attribs["inkscape:label"] = attribs.__inkscapeLayer;
|
|
11
|
+
delete attribs.__inkscapeLayer;
|
|
12
|
+
}
|
|
13
|
+
return attribs;
|
|
14
|
+
};
|
|
7
15
|
export {
|
|
16
|
+
__groupLayerID,
|
|
8
17
|
group
|
|
9
18
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/hiccup-svg",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.2.0",
|
|
4
4
|
"description": "SVG element functions for @thi.ng/hiccup & related tooling",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@thi.ng/checks": "^3.4.14",
|
|
39
39
|
"@thi.ng/color": "^5.6.8",
|
|
40
|
-
"@thi.ng/prefixes": "^2.
|
|
40
|
+
"@thi.ng/prefixes": "^2.3.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@microsoft/api-extractor": "^7.38.3",
|
|
@@ -135,5 +135,5 @@
|
|
|
135
135
|
"parent": "@thi.ng/hiccup",
|
|
136
136
|
"year": 2016
|
|
137
137
|
},
|
|
138
|
-
"gitHead": "
|
|
138
|
+
"gitHead": "f156d361a652cce316c36e0b7df7d2ac5c2dbbf8\n"
|
|
139
139
|
}
|
package/svg.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Defines an <svg> root element with default XML namespaces. By default
|
|
3
3
|
* currently still defaults to SVG version to 1.1 to support Safari and other
|
|
4
|
-
* legacy tooling.
|
|
4
|
+
* legacy tooling (can be overridden).
|
|
5
5
|
*
|
|
6
6
|
* @remarks
|
|
7
7
|
* If the `__convert` boolean attrib is enabled, all body elements will be
|
|
@@ -9,6 +9,13 @@
|
|
|
9
9
|
* will be removed afterward and is NOT going to be serialized in the final
|
|
10
10
|
* output.
|
|
11
11
|
*
|
|
12
|
+
* The root `<svg>` element will contain XML namespace declarations for these
|
|
13
|
+
* namespaces:
|
|
14
|
+
*
|
|
15
|
+
* - [svg (default NS)](https://docs.thi.ng/umbrella/prefixes/variables/XML_SVG.html)
|
|
16
|
+
* - [`xmlns:inkscape`](https://docs.thi.ng/umbrella/prefixes/variables/XML_INKSCAPE.html)
|
|
17
|
+
* - [`xmlns:xlink`](https://docs.thi.ng/umbrella/prefixes/variables/XML_XLINK.html)
|
|
18
|
+
*
|
|
12
19
|
* @param attribs - attributes object
|
|
13
20
|
* @param body - shape primitives
|
|
14
21
|
*/
|
package/svg.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { XML_SVG, XML_XLINK } from "@thi.ng/prefixes/xml";
|
|
1
|
+
import { XML_INKSCAPE, XML_SVG, XML_XLINK } from "@thi.ng/prefixes/xml";
|
|
2
2
|
import { convertTree } from "./convert.js";
|
|
3
3
|
import { fattribs } from "./format.js";
|
|
4
4
|
const svg = (attribs, ...body) => {
|
|
@@ -7,6 +7,7 @@ const svg = (attribs, ...body) => {
|
|
|
7
7
|
version: "1.1",
|
|
8
8
|
xmlns: XML_SVG,
|
|
9
9
|
"xmlns:xlink": XML_XLINK,
|
|
10
|
+
"xmlns:inkscape": XML_INKSCAPE,
|
|
10
11
|
...attribs
|
|
11
12
|
},
|
|
12
13
|
"width",
|