react-two.js 0.8.22-r.1 → 0.8.22-r.2
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 +4 -3
- package/dist/SVG.d.ts +11 -7
- package/dist/main.d.ts +1 -1
- package/dist/react-two-main.es.js +172 -174
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -67,8 +67,8 @@ npm install react-two.js react react-dom two.js
|
|
|
67
67
|
```
|
|
68
68
|
|
|
69
69
|
**Requirements** as peer dependencies:
|
|
70
|
-
- React
|
|
71
|
-
- Two.js v0.8.
|
|
70
|
+
- React 19+
|
|
71
|
+
- Two.js v0.8.22+
|
|
72
72
|
|
|
73
73
|
> [!IMPORTANT]
|
|
74
74
|
> react-two.js is a React renderer, it must pair with a major version of React, like react-dom.
|
|
@@ -158,10 +158,11 @@ function Component() {
|
|
|
158
158
|
const { two, width, height } = useTwo()
|
|
159
159
|
|
|
160
160
|
useEffect(() => {
|
|
161
|
+
if (!two) return;
|
|
161
162
|
two.play();
|
|
162
163
|
console.log('Canvas size:', width, height)
|
|
163
164
|
console.log('Two.js instance:', instance)
|
|
164
|
-
}, [])
|
|
165
|
+
}, [two])
|
|
165
166
|
}
|
|
166
167
|
```
|
|
167
168
|
|
package/dist/SVG.d.ts
CHANGED
|
@@ -2,17 +2,21 @@ import React from 'react';
|
|
|
2
2
|
import type { Group as Instance } from 'two.js/src/group';
|
|
3
3
|
import { ShapeProps, type EventHandlers } from './Properties';
|
|
4
4
|
type GroupProps = ShapeProps | 'fill' | 'stroke' | 'linewidth' | 'cap' | 'join' | 'miter' | 'closed' | 'curved' | 'automatic';
|
|
5
|
-
|
|
5
|
+
type ComponentProps = React.PropsWithChildren<{
|
|
6
6
|
[K in Extract<GroupProps, keyof Instance>]?: Instance[K];
|
|
7
|
-
}
|
|
8
|
-
src
|
|
9
|
-
content?:
|
|
7
|
+
} & ({
|
|
8
|
+
src: string;
|
|
9
|
+
content?: never;
|
|
10
|
+
} | {
|
|
11
|
+
src?: never;
|
|
12
|
+
content: string;
|
|
13
|
+
}) & {
|
|
10
14
|
x?: number;
|
|
11
15
|
y?: number;
|
|
12
|
-
onLoad?: (group:
|
|
16
|
+
onLoad?: (group: Instance, svg: SVGElement | SVGElement[]) => void;
|
|
13
17
|
onError?: (error: Error) => void;
|
|
14
18
|
shallow?: boolean;
|
|
15
|
-
}
|
|
19
|
+
} & Partial<EventHandlers>>;
|
|
16
20
|
export type RefSVG = Instance;
|
|
17
|
-
export declare const SVG: React.ForwardRefExoticComponent<
|
|
21
|
+
export declare const SVG: React.ForwardRefExoticComponent<ComponentProps & React.RefAttributes<Instance>>;
|
|
18
22
|
export {};
|
package/dist/main.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { Provider as Canvas } from './Provider';
|
|
2
2
|
export { Context, useTwo, useFrame } from './Context';
|
|
3
3
|
export { Group, type RefGroup } from './Group';
|
|
4
|
-
export { SVG, type RefSVG
|
|
4
|
+
export { SVG, type RefSVG } from './SVG';
|
|
5
5
|
export { Path, type RefPath } from './Path';
|
|
6
6
|
export { Points, type RefPoints } from './Points';
|
|
7
7
|
export { Text, type RefText } from './Text';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { jsx as k, Fragment as
|
|
2
|
-
import
|
|
1
|
+
import { jsx as k, Fragment as j } from "react/jsx-runtime";
|
|
2
|
+
import b, { createContext as z, useContext as J, useRef as F, useEffect as v, useState as K, useCallback as W, useMemo as m, useImperativeHandle as S } from "react";
|
|
3
3
|
import E from "two.js";
|
|
4
|
-
const
|
|
4
|
+
const N = z({
|
|
5
5
|
two: null,
|
|
6
6
|
parent: null,
|
|
7
7
|
width: 0,
|
|
@@ -10,8 +10,8 @@ const F = J({
|
|
|
10
10
|
},
|
|
11
11
|
unregisterEventShape: () => {
|
|
12
12
|
}
|
|
13
|
-
}), H = () =>
|
|
14
|
-
const { two: r } = H(), u =
|
|
13
|
+
}), H = () => J(N), te = (t, f = []) => {
|
|
14
|
+
const { two: r } = H(), u = F(t);
|
|
15
15
|
v(() => {
|
|
16
16
|
u.current = t;
|
|
17
17
|
}, [t, ...f]), v(() => {
|
|
@@ -23,7 +23,7 @@ const F = J({
|
|
|
23
23
|
n += e / 1e3, u.current?.(n, e);
|
|
24
24
|
}
|
|
25
25
|
}, [r, ...f]);
|
|
26
|
-
},
|
|
26
|
+
}, R = [
|
|
27
27
|
"onClick",
|
|
28
28
|
"onContextMenu",
|
|
29
29
|
"onDoubleClick",
|
|
@@ -78,9 +78,9 @@ function X(t, f) {
|
|
|
78
78
|
}
|
|
79
79
|
return r;
|
|
80
80
|
}
|
|
81
|
-
function
|
|
82
|
-
process.env.NODE_ENV !== "production" &&
|
|
83
|
-
if (!
|
|
81
|
+
function A(t) {
|
|
82
|
+
process.env.NODE_ENV !== "production" && b.Children.forEach(t, (f) => {
|
|
83
|
+
if (!b.isValidElement(f))
|
|
84
84
|
return;
|
|
85
85
|
const r = f.type;
|
|
86
86
|
if (typeof r == "string") {
|
|
@@ -92,19 +92,19 @@ See: https://github.com/jonobr1/react-two.js#usage`
|
|
|
92
92
|
);
|
|
93
93
|
return;
|
|
94
94
|
}
|
|
95
|
-
if (r ===
|
|
96
|
-
|
|
95
|
+
if (r === b.Fragment) {
|
|
96
|
+
A(
|
|
97
97
|
f.props.children
|
|
98
98
|
);
|
|
99
99
|
return;
|
|
100
100
|
}
|
|
101
|
-
typeof r == "function" && f.props.children &&
|
|
101
|
+
typeof r == "function" && f.props.children && A(
|
|
102
102
|
f.props.children
|
|
103
103
|
);
|
|
104
104
|
});
|
|
105
105
|
}
|
|
106
106
|
const re = (t) => {
|
|
107
|
-
const { two: f, parent: r } = H(), u =
|
|
107
|
+
const { two: f, parent: r } = H(), u = F(null), n = F(/* @__PURE__ */ new Map()), d = F(/* @__PURE__ */ new Set()), l = F(null), [e, o] = K({
|
|
108
108
|
two: f,
|
|
109
109
|
parent: r,
|
|
110
110
|
width: 0,
|
|
@@ -151,71 +151,71 @@ const re = (t) => {
|
|
|
151
151
|
}, [f, e.two, t.width, t.height]), v(() => {
|
|
152
152
|
if (!f && e.two) {
|
|
153
153
|
let c = function() {
|
|
154
|
-
const T = h.width !== p, V = h.height !==
|
|
155
|
-
T && (p = h.width), V && (
|
|
154
|
+
const T = h.width !== p, V = h.height !== P;
|
|
155
|
+
T && (p = h.width), V && (P = h.height), (T || V) && o((C) => ({ ...C, width: p, height: P }));
|
|
156
156
|
};
|
|
157
157
|
const h = e.two;
|
|
158
|
-
let p = h.width,
|
|
158
|
+
let p = h.width, P = h.height;
|
|
159
159
|
return (t.fullscreen || t.fitted) && h.bind("update", c), () => {
|
|
160
160
|
h.unbind("update", c);
|
|
161
161
|
};
|
|
162
162
|
}
|
|
163
163
|
}, [f, e.two, t.fullscreen, t.fitted]), v(() => {
|
|
164
|
-
process.env.NODE_ENV !== "production" &&
|
|
164
|
+
process.env.NODE_ENV !== "production" && A(t.children);
|
|
165
165
|
}, [t.children]), v(() => {
|
|
166
166
|
if (!e.two) return;
|
|
167
|
-
const a = e.two.renderer.domElement, c = (g,
|
|
167
|
+
const a = e.two.renderer.domElement, c = (g, w, y) => {
|
|
168
168
|
if (g.length === 0) return;
|
|
169
169
|
const M = g[0], I = B(y, a, e.two), G = X(M, n.current);
|
|
170
|
-
for (const
|
|
171
|
-
const
|
|
172
|
-
if (
|
|
173
|
-
const
|
|
170
|
+
for (const U of G) {
|
|
171
|
+
const q = n.current.get(U)?.handlers[w];
|
|
172
|
+
if (q) {
|
|
173
|
+
const _ = $(
|
|
174
174
|
y,
|
|
175
175
|
M,
|
|
176
|
-
|
|
176
|
+
U,
|
|
177
177
|
I
|
|
178
178
|
);
|
|
179
|
-
if (_
|
|
179
|
+
if (q(_), _.stopped)
|
|
180
180
|
break;
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
183
|
}, h = (g) => {
|
|
184
|
-
const
|
|
184
|
+
const w = D(g, a), y = x(
|
|
185
185
|
n.current,
|
|
186
|
-
|
|
187
|
-
|
|
186
|
+
w.x,
|
|
187
|
+
w.y
|
|
188
188
|
);
|
|
189
189
|
y.length > 0 && c(y, "onClick", g);
|
|
190
190
|
}, p = (g) => {
|
|
191
|
-
const
|
|
191
|
+
const w = D(g, a), y = x(
|
|
192
192
|
n.current,
|
|
193
|
-
|
|
194
|
-
|
|
193
|
+
w.x,
|
|
194
|
+
w.y
|
|
195
195
|
);
|
|
196
196
|
y.length > 0 && c(y, "onContextMenu", g);
|
|
197
|
-
},
|
|
198
|
-
const
|
|
197
|
+
}, P = (g) => {
|
|
198
|
+
const w = D(g, a), y = x(
|
|
199
199
|
n.current,
|
|
200
|
-
|
|
201
|
-
|
|
200
|
+
w.x,
|
|
201
|
+
w.y
|
|
202
202
|
);
|
|
203
203
|
y.length > 0 && c(y, "onDoubleClick", g);
|
|
204
204
|
}, T = (g) => {
|
|
205
|
-
const
|
|
205
|
+
const w = D(g, a), y = x(
|
|
206
206
|
n.current,
|
|
207
|
-
|
|
208
|
-
|
|
207
|
+
w.x,
|
|
208
|
+
w.y
|
|
209
209
|
);
|
|
210
210
|
y.length > 0 && c(y, "onWheel", g);
|
|
211
211
|
}, V = (g) => {
|
|
212
|
-
const
|
|
212
|
+
const w = D(g, a), y = x(
|
|
213
213
|
n.current,
|
|
214
|
-
|
|
215
|
-
|
|
214
|
+
w.x,
|
|
215
|
+
w.y
|
|
216
216
|
);
|
|
217
217
|
y.length > 0 && (c(y, "onPointerDown", g), g.target instanceof Element && g.target.hasPointerCapture?.(g.pointerId) && (l.current = y[0]));
|
|
218
|
-
},
|
|
218
|
+
}, C = (g) => {
|
|
219
219
|
if (l.current) {
|
|
220
220
|
const M = n.current.get(l.current);
|
|
221
221
|
if (M?.handlers.onPointerUp) {
|
|
@@ -230,17 +230,17 @@ const re = (t) => {
|
|
|
230
230
|
l.current = null;
|
|
231
231
|
return;
|
|
232
232
|
}
|
|
233
|
-
const
|
|
233
|
+
const w = D(g, a), y = x(
|
|
234
234
|
n.current,
|
|
235
|
-
|
|
236
|
-
|
|
235
|
+
w.x,
|
|
236
|
+
w.y
|
|
237
237
|
);
|
|
238
238
|
y.length > 0 ? c(y, "onPointerUp", g) : t.onPointerMissed && t.onPointerMissed(g);
|
|
239
|
-
},
|
|
240
|
-
const
|
|
239
|
+
}, O = (g) => {
|
|
240
|
+
const w = D(g, a), y = x(
|
|
241
241
|
n.current,
|
|
242
|
-
|
|
243
|
-
|
|
242
|
+
w.x,
|
|
243
|
+
w.y
|
|
244
244
|
), M = new Set(y);
|
|
245
245
|
y.length > 0 && c(y, "onPointerMove", g);
|
|
246
246
|
const I = d.current;
|
|
@@ -249,24 +249,24 @@ const re = (t) => {
|
|
|
249
249
|
for (const G of I)
|
|
250
250
|
M.has(G) || (c([G], "onPointerLeave", g), c([G], "onPointerOut", g));
|
|
251
251
|
d.current = M;
|
|
252
|
-
},
|
|
253
|
-
const
|
|
252
|
+
}, L = (g) => {
|
|
253
|
+
const w = D(g, a), y = x(
|
|
254
254
|
n.current,
|
|
255
|
-
|
|
256
|
-
|
|
255
|
+
w.x,
|
|
256
|
+
w.y
|
|
257
257
|
);
|
|
258
258
|
y.length > 0 && c(y, "onPointerCancel", g), l.current = null;
|
|
259
259
|
};
|
|
260
|
-
return a.addEventListener("click", h), a.addEventListener("contextmenu", p), a.addEventListener("dblclick",
|
|
261
|
-
a.removeEventListener("click", h), a.removeEventListener("contextmenu", p), a.removeEventListener("dblclick",
|
|
260
|
+
return a.addEventListener("click", h), a.addEventListener("contextmenu", p), a.addEventListener("dblclick", P), a.addEventListener("wheel", T), a.addEventListener("pointerdown", V), a.addEventListener("pointerup", C), a.addEventListener("pointermove", O), a.addEventListener("pointercancel", L), () => {
|
|
261
|
+
a.removeEventListener("click", h), a.removeEventListener("contextmenu", p), a.removeEventListener("dblclick", P), a.removeEventListener("wheel", T), a.removeEventListener("pointerdown", V), a.removeEventListener("pointerup", C), a.removeEventListener("pointermove", O), a.removeEventListener("pointercancel", L);
|
|
262
262
|
};
|
|
263
263
|
}, [
|
|
264
264
|
e.two,
|
|
265
265
|
t.onPointerMissed,
|
|
266
266
|
s,
|
|
267
267
|
i
|
|
268
|
-
]), /* @__PURE__ */ k(
|
|
269
|
-
}, oe =
|
|
268
|
+
]), /* @__PURE__ */ k(N.Provider, { value: e, children: /* @__PURE__ */ k("div", { ref: u, children: t.children }) });
|
|
269
|
+
}, oe = b.forwardRef(
|
|
270
270
|
({ x: t, y: f, ...r }, u) => {
|
|
271
271
|
const {
|
|
272
272
|
two: n,
|
|
@@ -275,13 +275,13 @@ const re = (t) => {
|
|
|
275
275
|
height: e,
|
|
276
276
|
registerEventShape: o,
|
|
277
277
|
unregisterEventShape: s
|
|
278
|
-
} = H(), i =
|
|
278
|
+
} = H(), i = m(() => new E.Group(), []), { eventHandlers: a, shapeProps: c } = m(() => {
|
|
279
279
|
const h = {}, p = {};
|
|
280
|
-
for (const
|
|
281
|
-
|
|
282
|
-
|
|
280
|
+
for (const P in r)
|
|
281
|
+
R.includes(P) ? h[P] = r[
|
|
282
|
+
P
|
|
283
283
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
284
|
-
] : p[
|
|
284
|
+
] : p[P] = r[P];
|
|
285
285
|
return { eventHandlers: h, shapeProps: p };
|
|
286
286
|
}, [r]);
|
|
287
287
|
return v(() => {
|
|
@@ -307,7 +307,7 @@ const re = (t) => {
|
|
|
307
307
|
d,
|
|
308
308
|
a
|
|
309
309
|
]), S(u, () => i, [i]), /* @__PURE__ */ k(
|
|
310
|
-
|
|
310
|
+
N.Provider,
|
|
311
311
|
{
|
|
312
312
|
value: {
|
|
313
313
|
two: n,
|
|
@@ -321,7 +321,7 @@ const re = (t) => {
|
|
|
321
321
|
}
|
|
322
322
|
);
|
|
323
323
|
}
|
|
324
|
-
), ie =
|
|
324
|
+
), ie = b.forwardRef(
|
|
325
325
|
({ x: t, y: f, src: r, content: u, onLoad: n, onError: d, ...l }, e) => {
|
|
326
326
|
const {
|
|
327
327
|
two: o,
|
|
@@ -330,16 +330,23 @@ const re = (t) => {
|
|
|
330
330
|
height: a,
|
|
331
331
|
registerEventShape: c,
|
|
332
332
|
unregisterEventShape: h
|
|
333
|
-
} = H(),
|
|
334
|
-
const
|
|
335
|
-
for (const
|
|
336
|
-
|
|
337
|
-
|
|
333
|
+
} = H(), p = m(() => new E.Group(), []), P = F(null), { eventHandlers: T, shapeProps: V } = m(() => {
|
|
334
|
+
const C = {}, O = {};
|
|
335
|
+
for (const L in l)
|
|
336
|
+
R.includes(L) ? C[L] = l[
|
|
337
|
+
L
|
|
338
338
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
339
|
-
] : L
|
|
340
|
-
return { eventHandlers:
|
|
339
|
+
] : O[L] = l[L];
|
|
340
|
+
return { eventHandlers: C, shapeProps: O };
|
|
341
341
|
}, [l]);
|
|
342
342
|
return v(() => {
|
|
343
|
+
P.current = p;
|
|
344
|
+
}, [p]), v(() => {
|
|
345
|
+
if (s && p)
|
|
346
|
+
return s.add(p), () => {
|
|
347
|
+
s.remove(p);
|
|
348
|
+
};
|
|
349
|
+
}, [p, s]), v(() => {
|
|
343
350
|
!r && !u && console.warn(
|
|
344
351
|
'[react-two.js] SVG component requires either "src" or "content" prop'
|
|
345
352
|
), r && u && console.warn(
|
|
@@ -347,64 +354,55 @@ const re = (t) => {
|
|
|
347
354
|
);
|
|
348
355
|
}, [r, u]), v(() => {
|
|
349
356
|
if (!o) return;
|
|
350
|
-
const
|
|
351
|
-
if (!
|
|
352
|
-
let
|
|
357
|
+
const C = r || u;
|
|
358
|
+
if (!C) return;
|
|
359
|
+
let O = !0;
|
|
353
360
|
try {
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
(
|
|
357
|
-
if (
|
|
361
|
+
o.load(
|
|
362
|
+
C,
|
|
363
|
+
(L, g) => {
|
|
364
|
+
if (O && (P.current?.add(L.children), n))
|
|
358
365
|
try {
|
|
359
|
-
n(
|
|
360
|
-
} catch (
|
|
366
|
+
requestAnimationFrame(() => n(P.current, g));
|
|
367
|
+
} catch (w) {
|
|
361
368
|
console.error(
|
|
362
369
|
"[react-two.js] Error in SVG onLoad callback:",
|
|
363
|
-
|
|
370
|
+
w
|
|
364
371
|
);
|
|
365
372
|
}
|
|
366
373
|
}
|
|
367
374
|
);
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
const g = R instanceof Error ? R : new Error("Failed to load SVG");
|
|
375
|
+
} catch (L) {
|
|
376
|
+
if (!O) return;
|
|
377
|
+
const g = L instanceof Error ? L : new Error("Failed to load SVG");
|
|
372
378
|
if (d)
|
|
373
379
|
try {
|
|
374
380
|
d(g);
|
|
375
|
-
} catch (
|
|
381
|
+
} catch (w) {
|
|
376
382
|
console.error(
|
|
377
383
|
"[react-two.js] Error in SVG onError callback:",
|
|
378
|
-
|
|
384
|
+
w
|
|
379
385
|
);
|
|
380
386
|
}
|
|
381
387
|
else
|
|
382
388
|
console.error("[react-two.js] SVG loading error:", g);
|
|
383
389
|
}
|
|
384
390
|
return () => {
|
|
385
|
-
|
|
391
|
+
O = !1, P.current?.remove(P.current.children);
|
|
386
392
|
};
|
|
387
393
|
}, [o, r, u, n, d]), v(() => {
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
if (p) {
|
|
394
|
-
const j = p;
|
|
395
|
-
typeof t == "number" && (j.translation.x = t), typeof f == "number" && (j.translation.y = f);
|
|
396
|
-
const L = { ...V };
|
|
397
|
-
delete L.children;
|
|
398
|
-
for (const R in L)
|
|
399
|
-
R in j && (j[R] = L[R]);
|
|
400
|
-
}
|
|
394
|
+
typeof t == "number" && (p.translation.x = t), typeof f == "number" && (p.translation.y = f);
|
|
395
|
+
const C = { ...V };
|
|
396
|
+
delete C.children;
|
|
397
|
+
for (const O in C)
|
|
398
|
+
O in p && (p[O] = C[O]);
|
|
401
399
|
}, [p, t, f, V]), v(() => {
|
|
402
|
-
if (
|
|
400
|
+
if (Object.keys(T).length > 0)
|
|
403
401
|
return c(p, T, s ?? void 0), () => {
|
|
404
402
|
h(p);
|
|
405
403
|
};
|
|
406
404
|
}, [p, c, h, s, T]), S(e, () => p, [p]), /* @__PURE__ */ k(
|
|
407
|
-
|
|
405
|
+
N.Provider,
|
|
408
406
|
{
|
|
409
407
|
value: {
|
|
410
408
|
two: o,
|
|
@@ -418,12 +416,12 @@ const re = (t) => {
|
|
|
418
416
|
}
|
|
419
417
|
);
|
|
420
418
|
}
|
|
421
|
-
), se =
|
|
419
|
+
), se = b.forwardRef(
|
|
422
420
|
({ manual: t, x: f, y: r, ...u }, n) => {
|
|
423
|
-
const { parent: d, registerEventShape: l, unregisterEventShape: e } = H(), o =
|
|
421
|
+
const { parent: d, registerEventShape: l, unregisterEventShape: e } = H(), o = m(() => new E.Path(), []), { eventHandlers: s, shapeProps: i } = m(() => {
|
|
424
422
|
const a = {}, c = {};
|
|
425
423
|
for (const h in u)
|
|
426
|
-
|
|
424
|
+
R.includes(h) ? a[h] = u[
|
|
427
425
|
h
|
|
428
426
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
429
427
|
] : c[h] = u[h];
|
|
@@ -443,14 +441,14 @@ const re = (t) => {
|
|
|
443
441
|
typeof f == "number" && (o.translation.x = f), typeof r == "number" && (o.translation.y = r), typeof t < "u" && (o.automatic = !t);
|
|
444
442
|
for (const a in i)
|
|
445
443
|
a in o && (o[a] = i[a]);
|
|
446
|
-
}, [i, o, f, r, t]), S(n, () => o, [o]), /* @__PURE__ */ k(
|
|
444
|
+
}, [i, o, f, r, t]), S(n, () => o, [o]), /* @__PURE__ */ k(j, {});
|
|
447
445
|
}
|
|
448
|
-
), ae =
|
|
446
|
+
), ae = b.forwardRef(
|
|
449
447
|
({ x: t, y: f, ...r }, u) => {
|
|
450
|
-
const { parent: n, registerEventShape: d, unregisterEventShape: l } = H(), e =
|
|
448
|
+
const { parent: n, registerEventShape: d, unregisterEventShape: l } = H(), e = m(() => new E.Points(), []), { eventHandlers: o, shapeProps: s } = m(() => {
|
|
451
449
|
const i = {}, a = {};
|
|
452
450
|
for (const c in r)
|
|
453
|
-
|
|
451
|
+
R.includes(c) ? i[c] = r[
|
|
454
452
|
c
|
|
455
453
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
456
454
|
] : a[c] = r[c];
|
|
@@ -476,14 +474,14 @@ const re = (t) => {
|
|
|
476
474
|
l,
|
|
477
475
|
n,
|
|
478
476
|
o
|
|
479
|
-
]), S(u, () => e, [e]), /* @__PURE__ */ k(
|
|
477
|
+
]), S(u, () => e, [e]), /* @__PURE__ */ k(j, {});
|
|
480
478
|
}
|
|
481
|
-
), ce =
|
|
479
|
+
), ce = b.forwardRef(
|
|
482
480
|
({ x: t, y: f, ...r }, u) => {
|
|
483
|
-
const { parent: n, registerEventShape: d, unregisterEventShape: l } = H(), e =
|
|
481
|
+
const { parent: n, registerEventShape: d, unregisterEventShape: l } = H(), e = m(() => new E.Text(), []), { eventHandlers: o, shapeProps: s } = m(() => {
|
|
484
482
|
const i = {}, a = {};
|
|
485
483
|
for (const c in r)
|
|
486
|
-
|
|
484
|
+
R.includes(c) ? i[c] = r[
|
|
487
485
|
c
|
|
488
486
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
489
487
|
] : a[c] = r[c];
|
|
@@ -503,17 +501,17 @@ const re = (t) => {
|
|
|
503
501
|
return d(e, o, n ?? void 0), () => {
|
|
504
502
|
l(e);
|
|
505
503
|
};
|
|
506
|
-
}, [e, d, l, n, o]), S(u, () => e, [e]), /* @__PURE__ */ k(
|
|
504
|
+
}, [e, d, l, n, o]), S(u, () => e, [e]), /* @__PURE__ */ k(j, {});
|
|
507
505
|
}
|
|
508
|
-
), fe =
|
|
506
|
+
), fe = b.forwardRef(
|
|
509
507
|
({ x: t, y: f, resolution: r, ...u }, n) => {
|
|
510
|
-
const { parent: d, registerEventShape: l, unregisterEventShape: e } = H(), o =
|
|
508
|
+
const { parent: d, registerEventShape: l, unregisterEventShape: e } = H(), o = m(
|
|
511
509
|
() => new E.ArcSegment(0, 0, 0, 0, 0, 0, r),
|
|
512
510
|
[r]
|
|
513
|
-
), { eventHandlers: s, shapeProps: i } =
|
|
511
|
+
), { eventHandlers: s, shapeProps: i } = m(() => {
|
|
514
512
|
const a = {}, c = {};
|
|
515
513
|
for (const h in u)
|
|
516
|
-
|
|
514
|
+
R.includes(h) ? a[h] = u[
|
|
517
515
|
h
|
|
518
516
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
519
517
|
] : c[h] = u[h];
|
|
@@ -539,17 +537,17 @@ const re = (t) => {
|
|
|
539
537
|
e,
|
|
540
538
|
d,
|
|
541
539
|
s
|
|
542
|
-
]), S(n, () => o, [o]), /* @__PURE__ */ k(
|
|
540
|
+
]), S(n, () => o, [o]), /* @__PURE__ */ k(j, {});
|
|
543
541
|
}
|
|
544
|
-
), le =
|
|
542
|
+
), le = b.forwardRef(
|
|
545
543
|
({ x: t, y: f, resolution: r, ...u }, n) => {
|
|
546
|
-
const { parent: d, registerEventShape: l, unregisterEventShape: e } = H(), o =
|
|
544
|
+
const { parent: d, registerEventShape: l, unregisterEventShape: e } = H(), o = m(
|
|
547
545
|
() => new E.Circle(0, 0, 0, r),
|
|
548
546
|
[r]
|
|
549
|
-
), { eventHandlers: s, shapeProps: i } =
|
|
547
|
+
), { eventHandlers: s, shapeProps: i } = m(() => {
|
|
550
548
|
const a = {}, c = {};
|
|
551
549
|
for (const h in u)
|
|
552
|
-
|
|
550
|
+
R.includes(h) ? a[h] = u[
|
|
553
551
|
h
|
|
554
552
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
555
553
|
] : c[h] = u[h];
|
|
@@ -575,17 +573,17 @@ const re = (t) => {
|
|
|
575
573
|
e,
|
|
576
574
|
d,
|
|
577
575
|
s
|
|
578
|
-
]), S(n, () => o, [o]), /* @__PURE__ */ k(
|
|
576
|
+
]), S(n, () => o, [o]), /* @__PURE__ */ k(j, {});
|
|
579
577
|
}
|
|
580
|
-
), ue =
|
|
578
|
+
), ue = b.forwardRef(
|
|
581
579
|
({ x: t, y: f, resolution: r, ...u }, n) => {
|
|
582
|
-
const { parent: d, registerEventShape: l, unregisterEventShape: e } = H(), o =
|
|
580
|
+
const { parent: d, registerEventShape: l, unregisterEventShape: e } = H(), o = m(
|
|
583
581
|
() => new E.Ellipse(0, 0, 0, 0, r),
|
|
584
582
|
[r]
|
|
585
|
-
), { eventHandlers: s, shapeProps: i } =
|
|
583
|
+
), { eventHandlers: s, shapeProps: i } = m(() => {
|
|
586
584
|
const a = {}, c = {};
|
|
587
585
|
for (const h in u)
|
|
588
|
-
|
|
586
|
+
R.includes(h) ? a[h] = u[
|
|
589
587
|
h
|
|
590
588
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
591
589
|
] : c[h] = u[h];
|
|
@@ -611,17 +609,17 @@ const re = (t) => {
|
|
|
611
609
|
e,
|
|
612
610
|
d,
|
|
613
611
|
s
|
|
614
|
-
]), S(n, () => o, [o]), /* @__PURE__ */ k(
|
|
612
|
+
]), S(n, () => o, [o]), /* @__PURE__ */ k(j, {});
|
|
615
613
|
}
|
|
616
|
-
), de =
|
|
614
|
+
), de = b.forwardRef(
|
|
617
615
|
({ mode: t, src: f, texture: r, x: u, y: n, ...d }, l) => {
|
|
618
|
-
const { parent: e, registerEventShape: o, unregisterEventShape: s } = H(), i =
|
|
616
|
+
const { parent: e, registerEventShape: o, unregisterEventShape: s } = H(), i = m(() => new E.Image(f), [f]), { eventHandlers: a, shapeProps: c } = m(() => {
|
|
619
617
|
const h = {}, p = {};
|
|
620
|
-
for (const
|
|
621
|
-
|
|
622
|
-
|
|
618
|
+
for (const P in d)
|
|
619
|
+
R.includes(P) ? h[P] = d[
|
|
620
|
+
P
|
|
623
621
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
624
|
-
] : p[
|
|
622
|
+
] : p[P] = d[P];
|
|
625
623
|
return { eventHandlers: h, shapeProps: p };
|
|
626
624
|
}, [d]);
|
|
627
625
|
return v(() => {
|
|
@@ -644,14 +642,14 @@ const re = (t) => {
|
|
|
644
642
|
s,
|
|
645
643
|
e,
|
|
646
644
|
a
|
|
647
|
-
]), S(l, () => i, [i]), /* @__PURE__ */ k(
|
|
645
|
+
]), S(l, () => i, [i]), /* @__PURE__ */ k(j, {});
|
|
648
646
|
}
|
|
649
|
-
), he =
|
|
647
|
+
), he = b.forwardRef(
|
|
650
648
|
({ src: t, x: f, y: r, autoPlay: u, ...n }, d) => {
|
|
651
|
-
const { parent: l, registerEventShape: e, unregisterEventShape: o } = H(), s =
|
|
649
|
+
const { parent: l, registerEventShape: e, unregisterEventShape: o } = H(), s = m(() => new E.ImageSequence(t), [t]), { eventHandlers: i, shapeProps: a } = m(() => {
|
|
652
650
|
const c = {}, h = {};
|
|
653
651
|
for (const p in n)
|
|
654
|
-
|
|
652
|
+
R.includes(p) ? c[p] = n[
|
|
655
653
|
p
|
|
656
654
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
657
655
|
] : h[p] = n[p];
|
|
@@ -677,14 +675,14 @@ const re = (t) => {
|
|
|
677
675
|
o,
|
|
678
676
|
l,
|
|
679
677
|
i
|
|
680
|
-
]), S(d, () => s, [s]), /* @__PURE__ */ k(
|
|
678
|
+
]), S(d, () => s, [s]), /* @__PURE__ */ k(j, {});
|
|
681
679
|
}
|
|
682
|
-
), ve =
|
|
680
|
+
), ve = b.forwardRef(
|
|
683
681
|
({ x1: t, y1: f, x2: r, y2: u, ...n }, d) => {
|
|
684
|
-
const { parent: l, registerEventShape: e, unregisterEventShape: o } = H(), s =
|
|
682
|
+
const { parent: l, registerEventShape: e, unregisterEventShape: o } = H(), s = m(() => new E.Line(), []), { eventHandlers: i, shapeProps: a } = m(() => {
|
|
685
683
|
const c = {}, h = {};
|
|
686
684
|
for (const p in n)
|
|
687
|
-
|
|
685
|
+
R.includes(p) ? c[p] = n[
|
|
688
686
|
p
|
|
689
687
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
690
688
|
] : h[p] = n[p];
|
|
@@ -704,14 +702,14 @@ const re = (t) => {
|
|
|
704
702
|
return e(s, i, l ?? void 0), () => {
|
|
705
703
|
o(s);
|
|
706
704
|
};
|
|
707
|
-
}, [s, e, o, l, i]), S(d, () => s, [s]), /* @__PURE__ */ k(
|
|
705
|
+
}, [s, e, o, l, i]), S(d, () => s, [s]), /* @__PURE__ */ k(j, {});
|
|
708
706
|
}
|
|
709
|
-
), pe =
|
|
707
|
+
), pe = b.forwardRef(
|
|
710
708
|
({ x: t, y: f, ...r }, u) => {
|
|
711
|
-
const { parent: n, registerEventShape: d, unregisterEventShape: l } = H(), e =
|
|
709
|
+
const { parent: n, registerEventShape: d, unregisterEventShape: l } = H(), e = m(() => new E.Polygon(), []), { eventHandlers: o, shapeProps: s } = m(() => {
|
|
712
710
|
const i = {}, a = {};
|
|
713
711
|
for (const c in r)
|
|
714
|
-
|
|
712
|
+
R.includes(c) ? i[c] = r[
|
|
715
713
|
c
|
|
716
714
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
717
715
|
] : a[c] = r[c];
|
|
@@ -737,14 +735,14 @@ const re = (t) => {
|
|
|
737
735
|
l,
|
|
738
736
|
n,
|
|
739
737
|
o
|
|
740
|
-
]), S(u, () => e, [e]), /* @__PURE__ */ k(
|
|
738
|
+
]), S(u, () => e, [e]), /* @__PURE__ */ k(j, {});
|
|
741
739
|
}
|
|
742
|
-
), ge =
|
|
740
|
+
), ge = b.forwardRef(
|
|
743
741
|
({ x: t, y: f, ...r }, u) => {
|
|
744
|
-
const { parent: n, registerEventShape: d, unregisterEventShape: l } = H(), e =
|
|
742
|
+
const { parent: n, registerEventShape: d, unregisterEventShape: l } = H(), e = m(() => new E.Rectangle(), []), { eventHandlers: o, shapeProps: s } = m(() => {
|
|
745
743
|
const i = {}, a = {};
|
|
746
744
|
for (const c in r)
|
|
747
|
-
|
|
745
|
+
R.includes(c) ? i[c] = r[
|
|
748
746
|
c
|
|
749
747
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
750
748
|
] : a[c] = r[c];
|
|
@@ -770,14 +768,14 @@ const re = (t) => {
|
|
|
770
768
|
l,
|
|
771
769
|
n,
|
|
772
770
|
o
|
|
773
|
-
]), S(u, () => e, [e]), /* @__PURE__ */ k(
|
|
771
|
+
]), S(u, () => e, [e]), /* @__PURE__ */ k(j, {});
|
|
774
772
|
}
|
|
775
|
-
),
|
|
773
|
+
), me = b.forwardRef(
|
|
776
774
|
({ x: t, y: f, ...r }, u) => {
|
|
777
|
-
const { parent: n, registerEventShape: d, unregisterEventShape: l } = H(), e =
|
|
775
|
+
const { parent: n, registerEventShape: d, unregisterEventShape: l } = H(), e = m(() => new E.RoundedRectangle(), []), { eventHandlers: o, shapeProps: s } = m(() => {
|
|
778
776
|
const i = {}, a = {};
|
|
779
777
|
for (const c in r)
|
|
780
|
-
|
|
778
|
+
R.includes(c) ? i[c] = r[
|
|
781
779
|
c
|
|
782
780
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
783
781
|
] : a[c] = r[c];
|
|
@@ -809,14 +807,14 @@ const re = (t) => {
|
|
|
809
807
|
o
|
|
810
808
|
]), S(u, () => e, [
|
|
811
809
|
e
|
|
812
|
-
]), /* @__PURE__ */ k(
|
|
810
|
+
]), /* @__PURE__ */ k(j, {});
|
|
813
811
|
}
|
|
814
|
-
),
|
|
812
|
+
), we = b.forwardRef(
|
|
815
813
|
({ src: t, x: f, y: r, autoPlay: u, ...n }, d) => {
|
|
816
|
-
const { parent: l, registerEventShape: e, unregisterEventShape: o } = H(), s =
|
|
814
|
+
const { parent: l, registerEventShape: e, unregisterEventShape: o } = H(), s = m(() => new E.Sprite(t), [t]), { eventHandlers: i, shapeProps: a } = m(() => {
|
|
817
815
|
const c = {}, h = {};
|
|
818
816
|
for (const p in n)
|
|
819
|
-
|
|
817
|
+
R.includes(p) ? c[p] = n[
|
|
820
818
|
p
|
|
821
819
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
822
820
|
] : h[p] = n[p];
|
|
@@ -842,14 +840,14 @@ const re = (t) => {
|
|
|
842
840
|
o,
|
|
843
841
|
l,
|
|
844
842
|
i
|
|
845
|
-
]), S(d, () => s, [s]), /* @__PURE__ */ k(
|
|
843
|
+
]), S(d, () => s, [s]), /* @__PURE__ */ k(j, {});
|
|
846
844
|
}
|
|
847
|
-
),
|
|
845
|
+
), ye = b.forwardRef(
|
|
848
846
|
({ x: t, y: f, ...r }, u) => {
|
|
849
|
-
const { parent: n, registerEventShape: d, unregisterEventShape: l } = H(), e =
|
|
847
|
+
const { parent: n, registerEventShape: d, unregisterEventShape: l } = H(), e = m(() => new E.Star(), []), { eventHandlers: o, shapeProps: s } = m(() => {
|
|
850
848
|
const i = {}, a = {};
|
|
851
849
|
for (const c in r)
|
|
852
|
-
|
|
850
|
+
R.includes(c) ? i[c] = r[
|
|
853
851
|
c
|
|
854
852
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
855
853
|
] : a[c] = r[c];
|
|
@@ -869,29 +867,29 @@ const re = (t) => {
|
|
|
869
867
|
return d(e, o, n ?? void 0), () => {
|
|
870
868
|
l(e);
|
|
871
869
|
};
|
|
872
|
-
}, [e, d, l, n, o]), S(u, () => e, [e]), /* @__PURE__ */ k(
|
|
870
|
+
}, [e, d, l, n, o]), S(u, () => e, [e]), /* @__PURE__ */ k(j, {});
|
|
873
871
|
}
|
|
874
|
-
), Pe =
|
|
872
|
+
), Pe = b.forwardRef(
|
|
875
873
|
({ x1: t, y1: f, x2: r, y2: u, ...n }, d) => {
|
|
876
|
-
const l =
|
|
874
|
+
const l = m(() => new E.LinearGradient(), []);
|
|
877
875
|
return v(() => {
|
|
878
876
|
typeof t == "number" && (l.left.x = t), typeof f == "number" && (l.left.y = f), typeof r == "number" && (l.right.x = r), typeof u == "number" && (l.right.y = u);
|
|
879
877
|
for (const e in n)
|
|
880
878
|
e in l && (l[e] = n[e]);
|
|
881
879
|
}, [l, t, f, r, u, n]), S(d, () => l, [l]), null;
|
|
882
880
|
}
|
|
883
|
-
), be =
|
|
881
|
+
), be = b.forwardRef(
|
|
884
882
|
({ x: t, y: f, focalX: r, focalY: u, ...n }, d) => {
|
|
885
|
-
const l =
|
|
883
|
+
const l = m(() => new E.RadialGradient(), []);
|
|
886
884
|
return v(() => {
|
|
887
885
|
typeof t == "number" && (l.center.x = t), typeof f == "number" && (l.center.y = f), typeof r == "number" && (l.focal.x = r), typeof u == "number" && (l.focal.y = u);
|
|
888
886
|
for (const e in n)
|
|
889
887
|
e in l && (l[e] = n[e]);
|
|
890
888
|
}, [n, l, t, f, r, u]), S(d, () => l, [l]), null;
|
|
891
889
|
}
|
|
892
|
-
), Ee =
|
|
890
|
+
), Ee = b.forwardRef(
|
|
893
891
|
({ src: t, ...f }, r) => {
|
|
894
|
-
const u =
|
|
892
|
+
const u = m(() => new E.Texture(t), [t]);
|
|
895
893
|
return v(() => {
|
|
896
894
|
for (const n in f)
|
|
897
895
|
n in u && (u[n] = f[n]);
|
|
@@ -902,7 +900,7 @@ export {
|
|
|
902
900
|
fe as ArcSegment,
|
|
903
901
|
re as Canvas,
|
|
904
902
|
le as Circle,
|
|
905
|
-
|
|
903
|
+
N as Context,
|
|
906
904
|
ue as Ellipse,
|
|
907
905
|
oe as Group,
|
|
908
906
|
de as Image,
|
|
@@ -914,10 +912,10 @@ export {
|
|
|
914
912
|
pe as Polygon,
|
|
915
913
|
be as RadialGradient,
|
|
916
914
|
ge as Rectangle,
|
|
917
|
-
|
|
915
|
+
me as RoundedRectangle,
|
|
918
916
|
ie as SVG,
|
|
919
|
-
|
|
920
|
-
|
|
917
|
+
we as Sprite,
|
|
918
|
+
ye as Star,
|
|
921
919
|
ce as Text,
|
|
922
920
|
Ee as Texture,
|
|
923
921
|
te as useFrame,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-two.js",
|
|
3
|
-
"version": "0.8.22-r.
|
|
3
|
+
"version": "0.8.22-r.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A React virtual DOM for Two.js — a renderer agnostic two-dimensional drawing API for the web",
|
|
6
6
|
"main": "./dist/react-two-main.es.js",
|
|
@@ -82,4 +82,4 @@
|
|
|
82
82
|
"react-dom": ">=19",
|
|
83
83
|
"two.js": ">=v0.8.22"
|
|
84
84
|
}
|
|
85
|
-
}
|
|
85
|
+
}
|