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 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 18.3+
71
- - Two.js v0.8.21+
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
- export interface SVGProps extends React.PropsWithChildren<{
5
+ type ComponentProps = React.PropsWithChildren<{
6
6
  [K in Extract<GroupProps, keyof Instance>]?: Instance[K];
7
- }>, Partial<EventHandlers> {
8
- src?: string;
9
- content?: string;
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: RefSVG, svg: SVGElement | SVGElement[]) => void;
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<SVGProps & React.RefAttributes<Instance>>;
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, type SVGProps } from './SVG';
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 O } from "react/jsx-runtime";
2
- import P, { createContext as J, useContext as K, useRef as N, useEffect as v, useState as z, useCallback as W, useMemo as w, useImperativeHandle as S } from "react";
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 F = J({
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 = () => K(F), te = (t, f = []) => {
14
- const { two: r } = H(), u = N(t);
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
- }, C = [
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 U(t) {
82
- process.env.NODE_ENV !== "production" && P.Children.forEach(t, (f) => {
83
- if (!P.isValidElement(f))
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 === P.Fragment) {
96
- U(
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 && U(
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 = N(null), n = N(/* @__PURE__ */ new Map()), d = N(/* @__PURE__ */ new Set()), l = N(null), [e, o] = z({
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 !== b;
155
- T && (p = h.width), V && (b = h.height), (T || V) && o((j) => ({ ...j, width: p, height: b }));
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, b = h.height;
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" && U(t.children);
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, m, y) => {
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 A of G) {
171
- const _ = n.current.get(A)?.handlers[m];
172
- if (_) {
173
- const q = $(
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
- A,
176
+ U,
177
177
  I
178
178
  );
179
- if (_(q), q.stopped)
179
+ if (q(_), _.stopped)
180
180
  break;
181
181
  }
182
182
  }
183
183
  }, h = (g) => {
184
- const m = D(g, a), y = x(
184
+ const w = D(g, a), y = x(
185
185
  n.current,
186
- m.x,
187
- m.y
186
+ w.x,
187
+ w.y
188
188
  );
189
189
  y.length > 0 && c(y, "onClick", g);
190
190
  }, p = (g) => {
191
- const m = D(g, a), y = x(
191
+ const w = D(g, a), y = x(
192
192
  n.current,
193
- m.x,
194
- m.y
193
+ w.x,
194
+ w.y
195
195
  );
196
196
  y.length > 0 && c(y, "onContextMenu", g);
197
- }, b = (g) => {
198
- const m = D(g, a), y = x(
197
+ }, P = (g) => {
198
+ const w = D(g, a), y = x(
199
199
  n.current,
200
- m.x,
201
- m.y
200
+ w.x,
201
+ w.y
202
202
  );
203
203
  y.length > 0 && c(y, "onDoubleClick", g);
204
204
  }, T = (g) => {
205
- const m = D(g, a), y = x(
205
+ const w = D(g, a), y = x(
206
206
  n.current,
207
- m.x,
208
- m.y
207
+ w.x,
208
+ w.y
209
209
  );
210
210
  y.length > 0 && c(y, "onWheel", g);
211
211
  }, V = (g) => {
212
- const m = D(g, a), y = x(
212
+ const w = D(g, a), y = x(
213
213
  n.current,
214
- m.x,
215
- m.y
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
- }, j = (g) => {
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 m = D(g, a), y = x(
233
+ const w = D(g, a), y = x(
234
234
  n.current,
235
- m.x,
236
- m.y
235
+ w.x,
236
+ w.y
237
237
  );
238
238
  y.length > 0 ? c(y, "onPointerUp", g) : t.onPointerMissed && t.onPointerMissed(g);
239
- }, L = (g) => {
240
- const m = D(g, a), y = x(
239
+ }, O = (g) => {
240
+ const w = D(g, a), y = x(
241
241
  n.current,
242
- m.x,
243
- m.y
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
- }, R = (g) => {
253
- const m = D(g, a), y = x(
252
+ }, L = (g) => {
253
+ const w = D(g, a), y = x(
254
254
  n.current,
255
- m.x,
256
- m.y
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", b), a.addEventListener("wheel", T), a.addEventListener("pointerdown", V), a.addEventListener("pointerup", j), a.addEventListener("pointermove", L), a.addEventListener("pointercancel", R), () => {
261
- a.removeEventListener("click", h), a.removeEventListener("contextmenu", p), a.removeEventListener("dblclick", b), a.removeEventListener("wheel", T), a.removeEventListener("pointerdown", V), a.removeEventListener("pointerup", j), a.removeEventListener("pointermove", L), a.removeEventListener("pointercancel", R);
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(F.Provider, { value: e, children: /* @__PURE__ */ k("div", { ref: u, children: t.children }) });
269
- }, oe = P.forwardRef(
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 = w(() => new E.Group(), []), { eventHandlers: a, shapeProps: c } = w(() => {
278
+ } = H(), i = m(() => new E.Group(), []), { eventHandlers: a, shapeProps: c } = m(() => {
279
279
  const h = {}, p = {};
280
- for (const b in r)
281
- C.includes(b) ? h[b] = r[
282
- b
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[b] = r[b];
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
- F.Provider,
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 = P.forwardRef(
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(), [p, b] = z(null), { eventHandlers: T, shapeProps: V } = w(() => {
334
- const j = {}, L = {};
335
- for (const R in l)
336
- C.includes(R) ? j[R] = l[
337
- R
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[R] = l[R];
340
- return { eventHandlers: j, shapeProps: L };
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 j = r || u;
351
- if (!j) return;
352
- let L = !0;
357
+ const C = r || u;
358
+ if (!C) return;
359
+ let O = !0;
353
360
  try {
354
- const R = o.load(
355
- j,
356
- (g, m) => {
357
- if (L && (b(g), n))
361
+ o.load(
362
+ C,
363
+ (L, g) => {
364
+ if (O && (P.current?.add(L.children), n))
358
365
  try {
359
- n(g, m);
360
- } catch (y) {
366
+ requestAnimationFrame(() => n(P.current, g));
367
+ } catch (w) {
361
368
  console.error(
362
369
  "[react-two.js] Error in SVG onLoad callback:",
363
- y
370
+ w
364
371
  );
365
372
  }
366
373
  }
367
374
  );
368
- b(R);
369
- } catch (R) {
370
- if (!L) return;
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 (m) {
381
+ } catch (w) {
376
382
  console.error(
377
383
  "[react-two.js] Error in SVG onError callback:",
378
- m
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
- L = !1;
391
+ O = !1, P.current?.remove(P.current.children);
386
392
  };
387
393
  }, [o, r, u, n, d]), v(() => {
388
- if (s && p)
389
- return s.add(p), () => {
390
- s.remove(p);
391
- };
392
- }, [p, s]), v(() => {
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 (p && Object.keys(T).length > 0)
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
- F.Provider,
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 = P.forwardRef(
419
+ ), se = b.forwardRef(
422
420
  ({ manual: t, x: f, y: r, ...u }, n) => {
423
- const { parent: d, registerEventShape: l, unregisterEventShape: e } = H(), o = w(() => new E.Path(), []), { eventHandlers: s, shapeProps: i } = w(() => {
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
- C.includes(h) ? a[h] = u[
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(O, {});
444
+ }, [i, o, f, r, t]), S(n, () => o, [o]), /* @__PURE__ */ k(j, {});
447
445
  }
448
- ), ae = P.forwardRef(
446
+ ), ae = b.forwardRef(
449
447
  ({ x: t, y: f, ...r }, u) => {
450
- const { parent: n, registerEventShape: d, unregisterEventShape: l } = H(), e = w(() => new E.Points(), []), { eventHandlers: o, shapeProps: s } = w(() => {
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
- C.includes(c) ? i[c] = r[
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(O, {});
477
+ ]), S(u, () => e, [e]), /* @__PURE__ */ k(j, {});
480
478
  }
481
- ), ce = P.forwardRef(
479
+ ), ce = b.forwardRef(
482
480
  ({ x: t, y: f, ...r }, u) => {
483
- const { parent: n, registerEventShape: d, unregisterEventShape: l } = H(), e = w(() => new E.Text(), []), { eventHandlers: o, shapeProps: s } = w(() => {
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
- C.includes(c) ? i[c] = r[
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(O, {});
504
+ }, [e, d, l, n, o]), S(u, () => e, [e]), /* @__PURE__ */ k(j, {});
507
505
  }
508
- ), fe = P.forwardRef(
506
+ ), fe = b.forwardRef(
509
507
  ({ x: t, y: f, resolution: r, ...u }, n) => {
510
- const { parent: d, registerEventShape: l, unregisterEventShape: e } = H(), o = w(
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 } = w(() => {
511
+ ), { eventHandlers: s, shapeProps: i } = m(() => {
514
512
  const a = {}, c = {};
515
513
  for (const h in u)
516
- C.includes(h) ? a[h] = u[
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(O, {});
540
+ ]), S(n, () => o, [o]), /* @__PURE__ */ k(j, {});
543
541
  }
544
- ), le = P.forwardRef(
542
+ ), le = b.forwardRef(
545
543
  ({ x: t, y: f, resolution: r, ...u }, n) => {
546
- const { parent: d, registerEventShape: l, unregisterEventShape: e } = H(), o = w(
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 } = w(() => {
547
+ ), { eventHandlers: s, shapeProps: i } = m(() => {
550
548
  const a = {}, c = {};
551
549
  for (const h in u)
552
- C.includes(h) ? a[h] = u[
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(O, {});
576
+ ]), S(n, () => o, [o]), /* @__PURE__ */ k(j, {});
579
577
  }
580
- ), ue = P.forwardRef(
578
+ ), ue = b.forwardRef(
581
579
  ({ x: t, y: f, resolution: r, ...u }, n) => {
582
- const { parent: d, registerEventShape: l, unregisterEventShape: e } = H(), o = w(
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 } = w(() => {
583
+ ), { eventHandlers: s, shapeProps: i } = m(() => {
586
584
  const a = {}, c = {};
587
585
  for (const h in u)
588
- C.includes(h) ? a[h] = u[
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(O, {});
612
+ ]), S(n, () => o, [o]), /* @__PURE__ */ k(j, {});
615
613
  }
616
- ), de = P.forwardRef(
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 = w(() => new E.Image(f), [f]), { eventHandlers: a, shapeProps: c } = w(() => {
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 b in d)
621
- C.includes(b) ? h[b] = d[
622
- b
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[b] = d[b];
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(O, {});
645
+ ]), S(l, () => i, [i]), /* @__PURE__ */ k(j, {});
648
646
  }
649
- ), he = P.forwardRef(
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 = w(() => new E.ImageSequence(t), [t]), { eventHandlers: i, shapeProps: a } = w(() => {
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
- C.includes(p) ? c[p] = n[
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(O, {});
678
+ ]), S(d, () => s, [s]), /* @__PURE__ */ k(j, {});
681
679
  }
682
- ), ve = P.forwardRef(
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 = w(() => new E.Line(), []), { eventHandlers: i, shapeProps: a } = w(() => {
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
- C.includes(p) ? c[p] = n[
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(O, {});
705
+ }, [s, e, o, l, i]), S(d, () => s, [s]), /* @__PURE__ */ k(j, {});
708
706
  }
709
- ), pe = P.forwardRef(
707
+ ), pe = b.forwardRef(
710
708
  ({ x: t, y: f, ...r }, u) => {
711
- const { parent: n, registerEventShape: d, unregisterEventShape: l } = H(), e = w(() => new E.Polygon(), []), { eventHandlers: o, shapeProps: s } = w(() => {
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
- C.includes(c) ? i[c] = r[
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(O, {});
738
+ ]), S(u, () => e, [e]), /* @__PURE__ */ k(j, {});
741
739
  }
742
- ), ge = P.forwardRef(
740
+ ), ge = b.forwardRef(
743
741
  ({ x: t, y: f, ...r }, u) => {
744
- const { parent: n, registerEventShape: d, unregisterEventShape: l } = H(), e = w(() => new E.Rectangle(), []), { eventHandlers: o, shapeProps: s } = w(() => {
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
- C.includes(c) ? i[c] = r[
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(O, {});
771
+ ]), S(u, () => e, [e]), /* @__PURE__ */ k(j, {});
774
772
  }
775
- ), we = P.forwardRef(
773
+ ), me = b.forwardRef(
776
774
  ({ x: t, y: f, ...r }, u) => {
777
- const { parent: n, registerEventShape: d, unregisterEventShape: l } = H(), e = w(() => new E.RoundedRectangle(), []), { eventHandlers: o, shapeProps: s } = w(() => {
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
- C.includes(c) ? i[c] = r[
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(O, {});
810
+ ]), /* @__PURE__ */ k(j, {});
813
811
  }
814
- ), ye = P.forwardRef(
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 = w(() => new E.Sprite(t), [t]), { eventHandlers: i, shapeProps: a } = w(() => {
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
- C.includes(p) ? c[p] = n[
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(O, {});
843
+ ]), S(d, () => s, [s]), /* @__PURE__ */ k(j, {});
846
844
  }
847
- ), me = P.forwardRef(
845
+ ), ye = b.forwardRef(
848
846
  ({ x: t, y: f, ...r }, u) => {
849
- const { parent: n, registerEventShape: d, unregisterEventShape: l } = H(), e = w(() => new E.Star(), []), { eventHandlers: o, shapeProps: s } = w(() => {
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
- C.includes(c) ? i[c] = r[
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(O, {});
870
+ }, [e, d, l, n, o]), S(u, () => e, [e]), /* @__PURE__ */ k(j, {});
873
871
  }
874
- ), Pe = P.forwardRef(
872
+ ), Pe = b.forwardRef(
875
873
  ({ x1: t, y1: f, x2: r, y2: u, ...n }, d) => {
876
- const l = w(() => new E.LinearGradient(), []);
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 = P.forwardRef(
881
+ ), be = b.forwardRef(
884
882
  ({ x: t, y: f, focalX: r, focalY: u, ...n }, d) => {
885
- const l = w(() => new E.RadialGradient(), []);
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 = P.forwardRef(
890
+ ), Ee = b.forwardRef(
893
891
  ({ src: t, ...f }, r) => {
894
- const u = w(() => new E.Texture(t), [t]);
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
- F as Context,
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
- we as RoundedRectangle,
915
+ me as RoundedRectangle,
918
916
  ie as SVG,
919
- ye as Sprite,
920
- me as Star,
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.1",
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
+ }