impact-nova 3.0.0-alpha.22 → 3.0.0-alpha.23
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/_virtual/index.js +4 -4
- package/dist/_virtual/index2.js +4 -4
- package/dist/components/data-display/hex-tilemap/hex-tilemap.js +35 -33
- package/dist/components/data-display/hex-tilemap/hex-tilemap.types.d.ts +2 -0
- package/dist/components/data-display/hex-tilemap/internals/hex-camera.js +30 -28
- package/dist/components/data-display/hex-tilemap/internals/hex-tilemap-context.d.ts +1 -0
- package/dist/components/data-display/hex-tilemap/internals/hex-tilemap-viewport.js +36 -34
- package/dist/components/data-display/hex-tilemap/internals/use-hex-camera.d.ts +2 -1
- package/dist/components/data-display/hex-tilemap/internals/use-hex-camera.js +87 -84
- package/dist/components/flows/iris-chat/iris-chat-chrome.js +203 -185
- package/dist/impact-nova.css +1 -1
- package/dist/lib/primitives/use-field-chrome.js +22 -22
- package/dist/llms/rules/installation.js +1 -1
- package/dist/llms/rules/requirements.js +1 -1
- package/dist/node_modules/hast-util-to-jsx-runtime/lib/index.js +1 -1
- package/dist/node_modules/unified/lib/index.js +1 -1
- package/package.json +1 -1
|
@@ -1,137 +1,140 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { centeredCamera as C, applyCameraViewBox as D, prefersReducedMotion as W, clampZoom as I, zoomCameraAt as
|
|
3
|
-
const
|
|
4
|
-
function
|
|
1
|
+
import * as e from "react";
|
|
2
|
+
import { centeredCamera as C, applyCameraViewBox as D, prefersReducedMotion as W, clampZoom as I, zoomCameraAt as Y, HEX_ZOOM_DEFAULT as O, clientToSvgPoint as T, panCamera as y, HEX_BUTTON_ZOOM_STEP as x, HEX_ZOOM_MIN as q, HEX_ZOOM_MAX as V, interpolateCamera as j, HEX_WHEEL_ZOOM_STEP as z, easeOutCubic as G } from "./hex-camera.js";
|
|
3
|
+
const J = 180;
|
|
4
|
+
function $({
|
|
5
5
|
extents: f,
|
|
6
|
-
zoom:
|
|
7
|
-
onZoomChange:
|
|
6
|
+
zoom: p,
|
|
7
|
+
onZoomChange: P,
|
|
8
8
|
svgRef: l,
|
|
9
|
-
viewportRef:
|
|
9
|
+
viewportRef: Z,
|
|
10
|
+
wheelZoomMode: g
|
|
10
11
|
}) {
|
|
11
|
-
const [
|
|
12
|
+
const [F, H] = e.useState(!1), c = e.useRef(C(f, p)), o = e.useRef(f), E = e.useRef(p), m = e.useRef(null), k = e.useRef(null), u = e.useCallback((t) => {
|
|
12
13
|
c.current = t;
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
}, [l]),
|
|
14
|
+
const r = l.current;
|
|
15
|
+
r && D(r, t);
|
|
16
|
+
}, [l]), A = e.useCallback(
|
|
16
17
|
(t) => {
|
|
17
|
-
const
|
|
18
|
-
|
|
18
|
+
const r = I(t);
|
|
19
|
+
r !== E.current && P(r);
|
|
19
20
|
},
|
|
20
|
-
[
|
|
21
|
-
), d =
|
|
22
|
-
|
|
23
|
-
}, []), i =
|
|
24
|
-
(t,
|
|
21
|
+
[P]
|
|
22
|
+
), d = e.useCallback(() => {
|
|
23
|
+
m.current !== null && (cancelAnimationFrame(m.current), m.current = null);
|
|
24
|
+
}, []), i = e.useCallback(
|
|
25
|
+
(t, r) => {
|
|
25
26
|
d();
|
|
26
27
|
const n = c.current;
|
|
27
|
-
if (
|
|
28
|
-
|
|
28
|
+
if (A(r), W()) {
|
|
29
|
+
u(t);
|
|
29
30
|
return;
|
|
30
31
|
}
|
|
31
|
-
const
|
|
32
|
-
const b = Math.min(1, (X -
|
|
33
|
-
if (
|
|
34
|
-
|
|
32
|
+
const a = performance.now(), s = (X) => {
|
|
33
|
+
const b = Math.min(1, (X - a) / J);
|
|
34
|
+
if (u(j(n, t, G(b))), b < 1) {
|
|
35
|
+
m.current = requestAnimationFrame(s);
|
|
35
36
|
return;
|
|
36
37
|
}
|
|
37
|
-
|
|
38
|
+
m.current = null;
|
|
38
39
|
};
|
|
39
|
-
|
|
40
|
+
m.current = requestAnimationFrame(s);
|
|
40
41
|
},
|
|
41
|
-
[d,
|
|
42
|
-
),
|
|
43
|
-
|
|
44
|
-
o.current = { width:
|
|
45
|
-
}, [_,
|
|
46
|
-
const t = { width:
|
|
42
|
+
[d, A, u]
|
|
43
|
+
), w = f.width, _ = f.height;
|
|
44
|
+
e.useEffect(() => {
|
|
45
|
+
o.current = { width: w, height: _ }, E.current = p;
|
|
46
|
+
}, [_, w, p]), e.useEffect(() => {
|
|
47
|
+
const t = { width: w, height: _ };
|
|
47
48
|
o.current = t;
|
|
48
|
-
const
|
|
49
|
-
c.current =
|
|
49
|
+
const r = C(t, E.current);
|
|
50
|
+
c.current = r;
|
|
50
51
|
const n = l.current;
|
|
51
|
-
n && D(n,
|
|
52
|
-
}, [_,
|
|
52
|
+
n && D(n, r);
|
|
53
|
+
}, [_, w, l]), e.useLayoutEffect(() => {
|
|
53
54
|
const t = l.current;
|
|
54
55
|
t && D(t, c.current);
|
|
55
|
-
}),
|
|
56
|
-
const h =
|
|
57
|
-
(t,
|
|
58
|
-
const
|
|
56
|
+
}), e.useEffect(() => () => d(), [d]);
|
|
57
|
+
const h = e.useCallback(
|
|
58
|
+
(t, r, n = !1) => {
|
|
59
|
+
const a = I(E.current + t), s = Y(c.current, o.current, a, r);
|
|
59
60
|
if (n) {
|
|
60
|
-
d(),
|
|
61
|
+
d(), u(s), A(a);
|
|
61
62
|
return;
|
|
62
63
|
}
|
|
63
|
-
i(s,
|
|
64
|
+
i(s, a);
|
|
64
65
|
},
|
|
65
|
-
[i, d,
|
|
66
|
-
),
|
|
66
|
+
[i, d, A, u]
|
|
67
|
+
), L = e.useCallback(
|
|
67
68
|
(t) => {
|
|
68
|
-
const
|
|
69
|
-
i(
|
|
69
|
+
const r = I(t);
|
|
70
|
+
i(Y(c.current, o.current, r), r);
|
|
70
71
|
},
|
|
71
72
|
[i]
|
|
72
|
-
),
|
|
73
|
-
i(C(o.current,
|
|
74
|
-
}, [i]),
|
|
75
|
-
i(C(o.current,
|
|
76
|
-
}, [i]),
|
|
73
|
+
), M = e.useCallback(() => {
|
|
74
|
+
i(C(o.current, O), O);
|
|
75
|
+
}, [i]), S = e.useCallback(() => {
|
|
76
|
+
i(C(o.current, O), O);
|
|
77
|
+
}, [i]), R = e.useCallback(
|
|
77
78
|
(t) => {
|
|
78
79
|
t.button === 0 && (t.target.closest("[data-hex-tilemap-zoom]") || (k.current = {
|
|
79
80
|
pointerId: t.pointerId,
|
|
80
81
|
lastX: t.clientX,
|
|
81
82
|
lastY: t.clientY
|
|
82
|
-
}, t.currentTarget.setPointerCapture(t.pointerId),
|
|
83
|
+
}, t.currentTarget.setPointerCapture(t.pointerId), H(!0)));
|
|
83
84
|
},
|
|
84
85
|
[]
|
|
85
|
-
),
|
|
86
|
+
), B = e.useCallback(
|
|
86
87
|
(t) => {
|
|
87
|
-
const
|
|
88
|
-
if (!
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
88
|
+
const r = k.current, n = l.current;
|
|
89
|
+
if (!r || r.pointerId !== t.pointerId || !n) return;
|
|
90
|
+
const a = T(n, r.lastX, r.lastY), s = T(n, t.clientX, t.clientY);
|
|
91
|
+
r.lastX = t.clientX, r.lastY = t.clientY, !(!a || !s) && u(
|
|
92
|
+
y(c.current, o.current, s.x - a.x, s.y - a.y)
|
|
92
93
|
);
|
|
93
94
|
},
|
|
94
|
-
[
|
|
95
|
-
),
|
|
96
|
-
t && k.current && k.current.pointerId !== t.pointerId || (k.current = null,
|
|
95
|
+
[u, l]
|
|
96
|
+
), N = e.useCallback((t) => {
|
|
97
|
+
t && k.current && k.current.pointerId !== t.pointerId || (k.current = null, H(!1));
|
|
97
98
|
}, []);
|
|
98
|
-
|
|
99
|
-
const t =
|
|
99
|
+
e.useEffect(() => {
|
|
100
|
+
const t = Z.current;
|
|
100
101
|
if (!t) return;
|
|
101
|
-
const
|
|
102
|
+
const r = (n) => {
|
|
103
|
+
if (g === "pinch-only" && !n.ctrlKey)
|
|
104
|
+
return;
|
|
102
105
|
n.preventDefault();
|
|
103
|
-
const
|
|
106
|
+
const a = l.current, s = n.deltaY < 0 ? 1 : -1, X = n.ctrlKey ? 10 : z, b = a ? T(a, n.clientX, n.clientY) : null;
|
|
104
107
|
h(s * X, b ?? void 0, !0);
|
|
105
108
|
};
|
|
106
|
-
return t.addEventListener("wheel",
|
|
107
|
-
}, [l,
|
|
108
|
-
const
|
|
109
|
+
return t.addEventListener("wheel", r, { passive: !1 }), () => t.removeEventListener("wheel", r);
|
|
110
|
+
}, [l, Z, g, h]);
|
|
111
|
+
const K = e.useCallback(
|
|
109
112
|
(t) => {
|
|
110
|
-
const
|
|
111
|
-
t.key === "+" || t.key === "=" ? (t.preventDefault(), h(
|
|
113
|
+
const r = c.current.width * 0.08;
|
|
114
|
+
t.key === "+" || t.key === "=" ? (t.preventDefault(), h(x)) : t.key === "-" || t.key === "_" ? (t.preventDefault(), h(-x)) : t.key === "ArrowLeft" ? (t.preventDefault(), u(y(c.current, o.current, -r, 0))) : t.key === "ArrowRight" ? (t.preventDefault(), u(y(c.current, o.current, r, 0))) : t.key === "ArrowUp" ? (t.preventDefault(), u(y(c.current, o.current, 0, -r))) : t.key === "ArrowDown" ? (t.preventDefault(), u(y(c.current, o.current, 0, r))) : t.key === "0" && (t.preventDefault(), M());
|
|
112
115
|
},
|
|
113
|
-
[
|
|
114
|
-
), U =
|
|
115
|
-
() => C(f,
|
|
116
|
+
[u, M, h]
|
|
117
|
+
), U = e.useMemo(
|
|
118
|
+
() => C(f, p),
|
|
116
119
|
// Recapture only when the land frame changes so wheel/pan viewBox writes stay on the SVG.
|
|
117
120
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
118
121
|
[f.height, f.width]
|
|
119
122
|
);
|
|
120
123
|
return {
|
|
121
|
-
isPanning:
|
|
122
|
-
handlePointerDown:
|
|
123
|
-
handlePointerMove:
|
|
124
|
-
endPan:
|
|
125
|
-
handleKeyDown:
|
|
124
|
+
isPanning: F,
|
|
125
|
+
handlePointerDown: R,
|
|
126
|
+
handlePointerMove: B,
|
|
127
|
+
endPan: N,
|
|
128
|
+
handleKeyDown: K,
|
|
126
129
|
zoomBy: h,
|
|
127
|
-
zoomTo:
|
|
128
|
-
resetZoom:
|
|
129
|
-
zoomToFit:
|
|
130
|
+
zoomTo: L,
|
|
131
|
+
resetZoom: M,
|
|
132
|
+
zoomToFit: S,
|
|
130
133
|
initialViewBox: U,
|
|
131
|
-
canZoomIn:
|
|
132
|
-
canZoomOut:
|
|
134
|
+
canZoomIn: p < V,
|
|
135
|
+
canZoomOut: p > q
|
|
133
136
|
};
|
|
134
137
|
}
|
|
135
138
|
export {
|
|
136
|
-
|
|
139
|
+
$ as useHexCamera
|
|
137
140
|
};
|