@thi.ng/hiccup-svg 5.5.24 → 5.6.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/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  [![Mastodon Follow](https://img.shields.io/mastodon/follow/109331703950160316?domain=https%3A%2F%2Fmastodon.thi.ng&style=social)](https://mastodon.thi.ng/@toxi)
8
8
 
9
9
  > [!NOTE]
10
- > This is one of 213 standalone projects, maintained as part
10
+ > This is one of 214 standalone projects, maintained as part
11
11
  > of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo
12
12
  > and anti-framework.
13
13
  >
package/convert.js CHANGED
@@ -46,7 +46,7 @@ const convertTree = (tree) => {
46
46
  }
47
47
  let attribs = __convertAttribs(tree[1]);
48
48
  if (attribs.__convert === false) return tree;
49
- if (attribs.__prec) {
49
+ if (attribs.__prec != null) {
50
50
  precisionStack.push(PRECISION);
51
51
  setPrecision(attribs.__prec);
52
52
  }
@@ -159,7 +159,7 @@ const convertTree = (tree) => {
159
159
  default:
160
160
  result = tree;
161
161
  }
162
- if (attribs.__prec) {
162
+ if (attribs.__prec != null) {
163
163
  setPrecision(precisionStack.pop());
164
164
  }
165
165
  return result;
package/format.js CHANGED
@@ -25,7 +25,7 @@ const fattribs = (attribs, ...numericIDs) => {
25
25
  let v;
26
26
  (v = attribs.fill) && (res.fill = fcolor(v));
27
27
  (v = attribs.stroke) && (res.stroke = fcolor(v));
28
- return __numericAttribs(attribs, numericIDs);
28
+ return __numericAttribs(res, numericIDs);
29
29
  };
30
30
  const __ftransforms = (attribs) => {
31
31
  let v;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/hiccup-svg",
3
- "version": "5.5.24",
3
+ "version": "5.6.0",
4
4
  "description": "SVG element functions for @thi.ng/hiccup & related tooling",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -8,7 +8,8 @@
8
8
  "sideEffects": false,
9
9
  "repository": {
10
10
  "type": "git",
11
- "url": "https://github.com/thi-ng/umbrella.git"
11
+ "url": "git+https://github.com/thi-ng/umbrella.git",
12
+ "directory": "packages/hiccup-svg"
12
13
  },
13
14
  "homepage": "https://thi.ng/hiccup-svg",
14
15
  "funding": [
@@ -39,10 +40,10 @@
39
40
  "tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
40
41
  },
41
42
  "dependencies": {
42
- "@thi.ng/api": "^8.12.13",
43
- "@thi.ng/checks": "^3.8.3",
44
- "@thi.ng/color": "^5.8.9",
45
- "@thi.ng/prefixes": "^2.3.64"
43
+ "@thi.ng/api": "^8.12.14",
44
+ "@thi.ng/checks": "^3.8.4",
45
+ "@thi.ng/color": "^5.8.10",
46
+ "@thi.ng/prefixes": "^2.3.65"
46
47
  },
47
48
  "devDependencies": {
48
49
  "esbuild": "^0.27.2",
@@ -142,5 +143,5 @@
142
143
  "parent": "@thi.ng/hiccup",
143
144
  "year": 2016
144
145
  },
145
- "gitHead": "828ec2e9ffde7307231b03cff46598c0915b1857\n"
146
+ "gitHead": "952667d049058f7b344fb63a2abcff2a0ac147b5\n"
146
147
  }
package/svg.d.ts CHANGED
@@ -10,6 +10,11 @@ import type { Attribs } from "./api.js";
10
10
  * will be removed afterward and is NOT going to be serialized in the final
11
11
  * output.
12
12
  *
13
+ * Only if `__convert` is true, the `__prec` control attribute can be used (also
14
+ * on a per-shape basis) to control the formatting used for various floating
15
+ * point values (except color conversions). See {@link setPrecision} &
16
+ * {@link convertTree}.
17
+ *
13
18
  * The root `<svg>` element will contain XML namespace declarations for these
14
19
  * namespaces:
15
20
  *
package/svg.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { XML_INKSCAPE, XML_SVG, XML_XLINK } from "@thi.ng/prefixes/xml";
2
2
  import { convertTree } from "./convert.js";
3
- import { fattribs } from "./format.js";
3
+ import { fattribs, PRECISION, setPrecision } from "./format.js";
4
4
  const svg = (attribs, ...body) => {
5
5
  attribs = fattribs(
6
6
  {
@@ -16,7 +16,14 @@ const svg = (attribs, ...body) => {
16
16
  );
17
17
  if (attribs.__convert) {
18
18
  delete attribs.__convert;
19
+ let prec;
20
+ if (attribs.__prec != null) {
21
+ prec = PRECISION;
22
+ setPrecision(attribs.__prec);
23
+ delete attribs.__prec;
24
+ }
19
25
  body = body.map(convertTree);
26
+ if (prec != null) setPrecision(prec);
20
27
  }
21
28
  return ["svg", attribs, ...body];
22
29
  };