@thi.ng/imgui 2.2.59 → 2.2.61

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2024-05-08T18:24:32Z
3
+ - **Last updated**: 2024-06-29T09:28:36Z
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
+ ### [2.2.60](https://github.com/thi-ng/umbrella/tree/@thi.ng/imgui@2.2.60) (2024-06-21)
13
+
14
+ #### ♻️ Refactoring
15
+
16
+ - update geom deps, update imports ([afd0b8b](https://github.com/thi-ng/umbrella/commit/afd0b8b))
17
+ - enforce uniform naming convention of internal functions ([56992b2](https://github.com/thi-ng/umbrella/commit/56992b2))
18
+
12
19
  ### [2.2.55](https://github.com/thi-ng/umbrella/tree/@thi.ng/imgui@2.2.55) (2024-04-20)
13
20
 
14
21
  #### ♻️ Refactoring
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 192 standalone projects, maintained as part
10
+ > This is one of 189 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
  >
@@ -261,16 +261,14 @@ Browser ESM import:
261
261
 
262
262
  [JSDelivr documentation](https://www.jsdelivr.com/)
263
263
 
264
- Package sizes (brotli'd, pre-treeshake): ESM: 6.65 KB
264
+ Package sizes (brotli'd, pre-treeshake): ESM: 6.67 KB
265
265
 
266
266
  ## Dependencies
267
267
 
268
268
  - [@thi.ng/api](https://github.com/thi-ng/umbrella/tree/develop/packages/api)
269
269
  - [@thi.ng/checks](https://github.com/thi-ng/umbrella/tree/develop/packages/checks)
270
270
  - [@thi.ng/geom](https://github.com/thi-ng/umbrella/tree/develop/packages/geom)
271
- - [@thi.ng/geom-api](https://github.com/thi-ng/umbrella/tree/develop/packages/geom-api)
272
271
  - [@thi.ng/geom-isec](https://github.com/thi-ng/umbrella/tree/develop/packages/geom-isec)
273
- - [@thi.ng/geom-tessellate](https://github.com/thi-ng/umbrella/tree/develop/packages/geom-tessellate)
274
272
  - [@thi.ng/layout](https://github.com/thi-ng/umbrella/tree/develop/packages/layout)
275
273
  - [@thi.ng/math](https://github.com/thi-ng/umbrella/tree/develop/packages/math)
276
274
  - [@thi.ng/transducers](https://github.com/thi-ng/umbrella/tree/develop/packages/transducers)
@@ -1,4 +1,4 @@
1
- import type { IShape } from "@thi.ng/geom-api";
1
+ import type { IShape } from "@thi.ng/geom";
2
2
  import type { IMGUI } from "../gui.js";
3
3
  export declare const hoverButton: (gui: IMGUI, id: string, shape: IShape, info?: string) => boolean;
4
4
  export declare const handleButtonKeys: (gui: IMGUI) => true | undefined;
@@ -1,5 +1,5 @@
1
1
  import type { FnN4 } from "@thi.ng/api";
2
- import type { IShape } from "@thi.ng/geom-api";
2
+ import type { IShape } from "@thi.ng/geom";
3
3
  import type { Vec } from "@thi.ng/vectors";
4
4
  import type { IMGUI } from "../gui.js";
5
5
  export declare const isHoverSlider: (gui: IMGUI, id: string, shape: IShape, cursor?: string) => boolean;
package/behaviors/text.js CHANGED
@@ -1,22 +1,22 @@
1
1
  import { clamp0 } from "@thi.ng/math/interval";
2
2
  import { Key } from "../api.js";
3
3
  const WS = /\s/;
4
- const nextNonAlpha = (src, i) => {
4
+ const __nextNonAlpha = (src, i) => {
5
5
  const n = src.length;
6
6
  while (i < n && WS.test(src[i])) i++;
7
7
  for (; i < n && !WS.test(src[i]); i++) {
8
8
  }
9
9
  return i;
10
10
  };
11
- const prevNonAlpha = (src, i) => {
11
+ const __prevNonAlpha = (src, i) => {
12
12
  while (i > 0 && WS.test(src[i])) i--;
13
13
  for (; i > 0 && !WS.test(src[i]); i--) {
14
14
  }
15
15
  return i;
16
16
  };
17
- const getNext = (gui, txt, cursor, dir) => {
17
+ const __getNext = (gui, txt, cursor, dir) => {
18
18
  cursor += dir;
19
- return gui.isAltDown() ? (dir < 0 ? prevNonAlpha : nextNonAlpha)(txt, cursor) : cursor;
19
+ return gui.isAltDown() ? (dir < 0 ? __prevNonAlpha : __nextNonAlpha)(txt, cursor) : cursor;
20
20
  };
21
21
  const handleTextfieldKeys = (gui, state, filter, txt, cursor, drawCursor, maxLen) => {
22
22
  const txtLen = txt.length;
@@ -42,26 +42,26 @@ const handleTextfieldKeys = (gui, state, filter, txt, cursor, drawCursor, maxLen
42
42
  return txt;
43
43
  case Key.BACKSPACE:
44
44
  if (cursor > 0) {
45
- const next = getNext(gui, txt, cursor, -1);
45
+ const next = __getNext(gui, txt, cursor, -1);
46
46
  move(next, next - cursor);
47
47
  return txt.substring(0, next) + txt.substring(cursor);
48
48
  }
49
49
  break;
50
50
  case Key.DELETE:
51
51
  if (cursor < txtLen) {
52
- const next = getNext(gui, txt, cursor, 1);
52
+ const next = __getNext(gui, txt, cursor, 1);
53
53
  return txt.substring(0, cursor) + txt.substring(next + 1);
54
54
  }
55
55
  break;
56
56
  case Key.LEFT:
57
57
  if (cursor > 0) {
58
- const next = getNext(gui, txt, cursor, -1);
58
+ const next = __getNext(gui, txt, cursor, -1);
59
59
  move(next, next - cursor);
60
60
  }
61
61
  break;
62
62
  case Key.RIGHT:
63
63
  if (cursor < txtLen) {
64
- const next = getNext(gui, txt, cursor, 1);
64
+ const next = __getNext(gui, txt, cursor, 1);
65
65
  move(next, next - cursor);
66
66
  }
67
67
  break;
@@ -1,4 +1,4 @@
1
- import type { IShape } from "@thi.ng/geom-api";
1
+ import type { IShape } from "@thi.ng/geom";
2
2
  import type { IGridLayout, LayoutBox } from "@thi.ng/layout";
3
3
  import type { Hash } from "../api.js";
4
4
  import type { IMGUI } from "../gui.js";
@@ -5,7 +5,7 @@ import { handleButtonKeys, hoverButton } from "../behaviors/button.js";
5
5
  import { labelHash } from "../hash.js";
6
6
  import { layoutBox } from "../layout.js";
7
7
  import { textLabelRaw, textTransformH, textTransformV } from "./textlabel.js";
8
- const mkLabel = (gui, tx, id, key, x, y, w, h, hover, label) => gui.resource(
8
+ const __mkLabel = (gui, tx, id, key, x, y, w, h, hover, label) => gui.resource(
9
9
  id,
10
10
  labelHash(key, label, gui.disabled),
11
11
  () => textLabelRaw(
@@ -25,10 +25,10 @@ const buttonH = (gui, layout, id, label, labelHover = label, info) => {
25
25
  id,
26
26
  gui.resource(id, key, () => rect([x, y], [w, h])),
27
27
  key,
28
- label ? mkLabel(gui, textTransformH, id, key, x, y, w, h, false, label) : void 0,
28
+ label ? __mkLabel(gui, textTransformH, id, key, x, y, w, h, false, label) : void 0,
29
29
  labelHover ? (
30
30
  // prettier-ignore
31
- mkLabel(gui, textTransformH, id, key, x, y, w, h, true, labelHover)
31
+ __mkLabel(gui, textTransformH, id, key, x, y, w, h, true, labelHover)
32
32
  ) : void 0,
33
33
  info
34
34
  );
@@ -41,10 +41,10 @@ const buttonV = (gui, layout, id, rows, label, labelHover = label, info) => {
41
41
  id,
42
42
  gui.resource(id, key, () => rect([x, y], [w, h])),
43
43
  key,
44
- label ? mkLabel(gui, textTransformV, id, key, x, y, w, h, false, label) : void 0,
44
+ label ? __mkLabel(gui, textTransformV, id, key, x, y, w, h, false, label) : void 0,
45
45
  labelHover ? (
46
46
  // prettier-ignore
47
- mkLabel(gui, textTransformV, id, key, x, y, w, h, true, labelHover)
47
+ __mkLabel(gui, textTransformV, id, key, x, y, w, h, true, labelHover)
48
48
  ) : void 0,
49
49
  info
50
50
  );
@@ -18,7 +18,7 @@ const dropdown = (gui, layout, id, sel, items, title, info) => {
18
18
  if (open) {
19
19
  const bt = buttonH(gui, box, `${id}-title`, title);
20
20
  draw && gui.add(
21
- gui.resource(id, key + 1, () => triangle(gui, tx, ty, true))
21
+ gui.resource(id, key + 1, () => __triangle(gui, tx, ty, true))
22
22
  );
23
23
  if (bt) {
24
24
  gui.setState(id, false);
@@ -35,9 +35,9 @@ const dropdown = (gui, layout, id, sel, items, title, info) => {
35
35
  gui.setState(id, false);
36
36
  break;
37
37
  case Key.UP:
38
- return update(gui, id, clamp0(sel - 1));
38
+ return __update(gui, id, clamp0(sel - 1));
39
39
  case Key.DOWN:
40
- return update(
40
+ return __update(
41
41
  gui,
42
42
  id,
43
43
  Math.min(items.length - 1, sel + 1)
@@ -51,16 +51,16 @@ const dropdown = (gui, layout, id, sel, items, title, info) => {
51
51
  gui.setState(id, true);
52
52
  }
53
53
  draw && gui.add(
54
- gui.resource(id, key + 2, () => triangle(gui, tx, ty, false))
54
+ gui.resource(id, key + 2, () => __triangle(gui, tx, ty, false))
55
55
  );
56
56
  }
57
57
  return res;
58
58
  };
59
- const update = (gui, id, next) => {
59
+ const __update = (gui, id, next) => {
60
60
  gui.focusID = `${id}-${next}`;
61
61
  return next;
62
62
  };
63
- const triangle = (gui, x, y, open) => {
63
+ const __triangle = (gui, x, y, open) => {
64
64
  const s = open ? 2 : -2;
65
65
  return polygon(
66
66
  [
@@ -1,8 +1,10 @@
1
- import { triFan } from "@thi.ng/geom-tessellate/tri-fan";
1
+ import {
2
+ TESSELLATE_TRI_FAN,
3
+ groupFromTessellation,
4
+ tessellate
5
+ } from "@thi.ng/geom";
2
6
  import { centroid } from "@thi.ng/geom/centroid";
3
7
  import { circle } from "@thi.ng/geom/circle";
4
- import { polygon } from "@thi.ng/geom/polygon";
5
- import { vertices } from "@thi.ng/geom/vertices";
6
8
  import { mod } from "@thi.ng/math/prec";
7
9
  import { mapIndexed } from "@thi.ng/transducers/map-indexed";
8
10
  import { add2 } from "@thi.ng/vectors/add";
@@ -15,8 +17,7 @@ const radialMenu = (gui, id, x, y, r, items, info) => {
15
17
  const key = hash([x, y, r, n, ~~gui.disabled]);
16
18
  gui.registerID(id, key);
17
19
  const cells = gui.resource(id, key, () => [
18
- ...mapIndexed((i, pts) => {
19
- const cell = polygon(pts);
20
+ ...mapIndexed((i, cell) => {
20
21
  const p = add2(
21
22
  null,
22
23
  [-gui.textWidth(items[i]) >> 1, gui.theme.baseLine],
@@ -28,7 +29,7 @@ const radialMenu = (gui, id, x, y, r, items, info) => {
28
29
  textLabelRaw(p, gui.textColor(false), items[i]),
29
30
  textLabelRaw(p, gui.textColor(true), items[i])
30
31
  ];
31
- }, triFan(vertices(circle([x, y], r), n)))
32
+ }, groupFromTessellation(tessellate(circle([x, y], r, { __samples: n }), [TESSELLATE_TRI_FAN])))
32
33
  ]);
33
34
  let res;
34
35
  let sel = -1;
@@ -12,8 +12,8 @@ import { dialVal } from "../behaviors/dial.js";
12
12
  import { handleSlider1Keys } from "../behaviors/slider.js";
13
13
  import { dialValueLabel } from "./textlabel.js";
14
14
  import { tooltipRaw } from "./tooltip.js";
15
- const ringHeight = (w, thetaGap) => w / 2 * (1 + Math.sin(HALF_PI + thetaGap / 2));
16
- const arcVerts = (o, r, start, end, thetaRes = 12) => r > 1 ? map(
15
+ const __ringHeight = (w, thetaGap) => w / 2 * (1 + Math.sin(HALF_PI + thetaGap / 2));
16
+ const __arcVerts = (o, r, start, end, thetaRes = 12) => r > 1 ? map(
17
17
  (t) => cartesian2(null, [r, mix(start, end, t)], o),
18
18
  normRange(
19
19
  Math.max(1, Math.abs(end - start) / (PI / thetaRes)) | 0
@@ -23,10 +23,10 @@ const ring = (gui, layout, id, min, max, prec, val, thetaGap, rscale, label, fmt
23
23
  let h;
24
24
  let box;
25
25
  if (isLayout(layout)) {
26
- h = ringHeight(layout.cellW, thetaGap);
26
+ h = __ringHeight(layout.cellW, thetaGap);
27
27
  box = layout.next([1, layout.rowsForHeight(h) + 1]);
28
28
  } else {
29
- h = ringHeight(layout.cw, thetaGap);
29
+ h = __ringHeight(layout.cw, thetaGap);
30
30
  box = layout;
31
31
  }
32
32
  return ringRaw(
@@ -53,7 +53,7 @@ const ringGroup = (gui, layout, id, min, max, prec, horizontal, thetaGap, rscale
53
53
  const n = vals.length;
54
54
  const nested = horizontal ? layout.nest(n, [n, 1]) : layout.nest(1, [
55
55
  1,
56
- (layout.rowsForHeight(ringHeight(layout.cellW, thetaGap)) + 1) * n
56
+ (layout.rowsForHeight(__ringHeight(layout.cellW, thetaGap)) + 1) * n
57
57
  ]);
58
58
  let res;
59
59
  let idx = -1;
@@ -107,8 +107,8 @@ const ringRaw = (gui, id, x, y, w, h, min, max, prec, val, thetaGap, rscale, lx,
107
107
  const numV = fitClamped(r, 15, 80, 12, 30);
108
108
  const shape = (max2) => () => polygon(
109
109
  [
110
- ...arcVerts(pos, r, startTheta, max2, numV),
111
- ...arcVerts(pos, r2, max2, startTheta, numV)
110
+ ...__arcVerts(pos, r, startTheta, max2, numV),
111
+ ...__arcVerts(pos, r2, max2, startTheta, numV)
112
112
  ],
113
113
  {}
114
114
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/imgui",
3
- "version": "2.2.59",
3
+ "version": "2.2.61",
4
4
  "description": "Immediate mode GUI with flexible state handling & data only shape output",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -10,7 +10,7 @@
10
10
  "type": "git",
11
11
  "url": "https://github.com/thi-ng/umbrella.git"
12
12
  },
13
- "homepage": "https://github.com/thi-ng/umbrella/tree/develop/packages/imgui#readme",
13
+ "homepage": "https://thi.ng/imgui",
14
14
  "funding": [
15
15
  {
16
16
  "type": "github",
@@ -36,22 +36,20 @@
36
36
  "tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
37
37
  },
38
38
  "dependencies": {
39
- "@thi.ng/api": "^8.11.2",
40
- "@thi.ng/checks": "^3.6.4",
41
- "@thi.ng/geom": "^7.0.1",
42
- "@thi.ng/geom-api": "^4.0.10",
43
- "@thi.ng/geom-isec": "^3.1.0",
44
- "@thi.ng/geom-tessellate": "^2.1.132",
45
- "@thi.ng/layout": "^3.0.39",
46
- "@thi.ng/math": "^5.10.13",
47
- "@thi.ng/transducers": "^9.0.5",
48
- "@thi.ng/vectors": "^7.10.31"
39
+ "@thi.ng/api": "^8.11.4",
40
+ "@thi.ng/checks": "^3.6.6",
41
+ "@thi.ng/geom": "^8.0.1",
42
+ "@thi.ng/geom-isec": "^4.0.1",
43
+ "@thi.ng/layout": "^3.0.41",
44
+ "@thi.ng/math": "^5.11.1",
45
+ "@thi.ng/transducers": "^9.0.7",
46
+ "@thi.ng/vectors": "^7.11.1"
49
47
  },
50
48
  "devDependencies": {
51
- "@microsoft/api-extractor": "^7.43.2",
52
- "esbuild": "^0.21.1",
49
+ "@microsoft/api-extractor": "^7.47.0",
50
+ "esbuild": "^0.21.5",
53
51
  "typedoc": "^0.25.13",
54
- "typescript": "^5.4.5"
52
+ "typescript": "^5.5.2"
55
53
  },
56
54
  "keywords": [
57
55
  "browser",
@@ -158,5 +156,5 @@
158
156
  ],
159
157
  "year": 2019
160
158
  },
161
- "gitHead": "41bd769068da804eeace622ec7db50e4d48f1dc9\n"
159
+ "gitHead": "7b950c112fba0b2e7c450765b15624c3382f1354\n"
162
160
  }