react-two.js 0.2.0 → 0.2.3

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
@@ -293,7 +293,7 @@ function () {
293
293
  - **[Two.js Examples](https://two.js.org/examples/)** — Interactive examples and demos
294
294
  - **[Two.js Repository](https://github.com/jonobr1/two.js)** — Source code and issues
295
295
 
296
- ## Development & Deployment
296
+ ## Development
297
297
 
298
298
  ### Building the Library
299
299
 
@@ -308,37 +308,6 @@ npm run build:docs
308
308
  npm run preview:docs
309
309
  ```
310
310
 
311
- ### Publishing to NPM
312
-
313
- 1. **Increment version** (choose one):
314
- ```bash
315
- npm run version:patch # Bug fixes (0.1.0 → 0.1.1)
316
- npm run version:minor # New features (0.1.0 → 0.2.0)
317
- npm run version:major # Breaking changes (0.1.0 → 1.0.0)
318
- ```
319
-
320
- 2. **Create a GitHub release** with the new version tag. This automatically triggers npm publishing via GitHub Actions.
321
-
322
- Or **publish manually**:
323
- ```bash
324
- npm run publish:npm
325
- ```
326
-
327
- ### GitHub Pages Deployment
328
-
329
- The documentation site automatically deploys to GitHub Pages on every push to `main`. The site will be available at:
330
- - **Live URL**: https://jonobr1.github.io/react-two.js
331
-
332
- #### Manual Setup (if needed):
333
-
334
- 1. **Enable GitHub Pages** in repository settings:
335
- - Go to Settings → Pages
336
- - Source: "GitHub Actions"
337
-
338
- 2. **Set up NPM_TOKEN secret** (for npm publishing):
339
- - Go to Settings → Secrets and variables → Actions
340
- - Add `NPM_TOKEN` with your npm access token
341
-
342
311
  ### Local Development
343
312
 
344
313
  ```bash
@@ -1,22 +1,21 @@
1
1
  import { jsx as g, Fragment as R } from "react/jsx-runtime";
2
- import w, { createContext as G, useContext as L, useRef as I, useEffect as l, useState as b, useImperativeHandle as y, useLayoutEffect as S, useMemo as P } from "react";
2
+ import w, { createContext as G, useContext as L, useRef as E, useEffect as l, useState as b, useImperativeHandle as y, useLayoutEffect as k, useMemo as I } from "react";
3
3
  import m from "two.js";
4
- const C = G({ two: null, parent: null, width: 0, height: 0 }), h = () => L(C), j = (r, o = []) => {
5
- const { two: i } = h(), a = I(r);
4
+ const S = G({ two: null, parent: null, width: 0, height: 0 }), h = () => L(S), j = (r, o = []) => {
5
+ const { two: i } = h(), s = E(r);
6
6
  l(() => {
7
- a.current = r;
7
+ s.current = r;
8
8
  }, [r, ...o]), l(() => {
9
9
  if (!i)
10
10
  return;
11
11
  let c = 0;
12
- return i.bind("update", s), () => i.unbind("update", s);
13
- function s(n, t) {
14
- var e;
15
- c += t / 1e3, (e = a.current) == null || e.call(a, c, t);
12
+ return i.bind("update", a), () => i.unbind("update", a);
13
+ function a(n, t) {
14
+ c += t / 1e3, s.current?.(c, t);
16
15
  }
17
16
  }, [i, ...o]);
18
17
  }, H = (r) => {
19
- const { two: o, parent: i } = h(), a = I(null), [c, s] = b({
18
+ const { two: o, parent: i } = h(), s = E(null), [c, a] = b({
20
19
  two: o,
21
20
  parent: i,
22
21
  width: 0,
@@ -28,16 +27,15 @@ const C = G({ two: null, parent: null, width: 0, height: 0 }), h = () => L(C), j
28
27
  };
29
28
  if (!o) {
30
29
  let f = function() {
31
- const p = d.width !== v, k = !1;
32
- p && (v = d.width), (p || k) && s((T) => ({ ...T, width: v, height: E }));
30
+ const p = d.width !== v, P = !1;
31
+ p && (v = d.width), (p || P) && a((T) => ({ ...T, width: v, height: C }));
33
32
  };
34
33
  const u = { ...r };
35
34
  delete u.children;
36
- const d = new m(u).appendTo(a.current);
37
- let v = d.width, E = d.height;
38
- s({ two: d, parent: d.scene, width: v, height: E }), d.bind("update", f), t = () => {
39
- var k;
40
- (k = d.renderer.domElement.parentElement) == null || k.removeChild(
35
+ const d = new m(u).appendTo(s.current);
36
+ let v = d.width, C = d.height;
37
+ a({ two: d, parent: d.scene, width: v, height: C }), d.bind("update", f), t = () => {
38
+ d.renderer.domElement.parentElement?.removeChild(
41
39
  d.renderer.domElement
42
40
  ), d.unbind("update", f);
43
41
  const p = m.Instances.indexOf(d);
@@ -46,10 +44,10 @@ const C = G({ two: null, parent: null, width: 0, height: 0 }), h = () => L(C), j
46
44
  }
47
45
  return t;
48
46
  }
49
- return /* @__PURE__ */ g(C.Provider, { value: c, children: /* @__PURE__ */ g("div", { ref: a, children: r.children }) });
47
+ return /* @__PURE__ */ g(S.Provider, { value: c, children: /* @__PURE__ */ g("div", { ref: s, children: r.children }) });
50
48
  }, M = w.forwardRef(
51
- ({ x: r, y: o, ...i }, a) => {
52
- const { two: c, parent: s, width: n, height: t } = h(), [e, f] = b(null);
49
+ ({ x: r, y: o, ...i }, s) => {
50
+ const { two: c, parent: a, width: n, height: t } = h(), [e, f] = b(null);
53
51
  return l(() => {
54
52
  if (c) {
55
53
  const u = new m.Group();
@@ -59,11 +57,11 @@ const C = G({ two: null, parent: null, width: 0, height: 0 }), h = () => L(C), j
59
57
  }
60
58
  }, [c]), l(() => {
61
59
  const u = e;
62
- if (s && u)
63
- return s.add(u), () => {
64
- s.remove(u);
60
+ if (a && u)
61
+ return a.add(u), () => {
62
+ a.remove(u);
65
63
  };
66
- }, [e, s]), l(() => {
64
+ }, [e, a]), l(() => {
67
65
  if (e) {
68
66
  const u = e;
69
67
  typeof r == "number" && (u.translation.x = r), typeof o == "number" && (u.translation.y = o);
@@ -72,17 +70,17 @@ const C = G({ two: null, parent: null, width: 0, height: 0 }), h = () => L(C), j
72
70
  for (const v in d)
73
71
  v in u && (u[v] = d[v]);
74
72
  }
75
- }, [e, r, o, i]), y(a, () => e, [e]), /* @__PURE__ */ g(C.Provider, { value: { two: c, parent: e, width: n, height: t }, children: i.children });
73
+ }, [e, r, o, i]), y(s, () => e, [e]), /* @__PURE__ */ g(S.Provider, { value: { two: c, parent: e, width: n, height: t }, children: i.children });
76
74
  }
77
75
  ), O = w.forwardRef(
78
- ({ manual: r, x: o, y: i, ...a }, c) => {
79
- const { two: s, parent: n } = h(), [t, e] = b(null);
76
+ ({ manual: r, x: o, y: i, ...s }, c) => {
77
+ const { two: a, parent: n } = h(), [t, e] = b(null);
80
78
  return l(() => {
81
79
  const f = new m.Path();
82
80
  return e(f), () => {
83
81
  e(null);
84
82
  };
85
- }, [s]), l(() => {
83
+ }, [a]), l(() => {
86
84
  if (n && t)
87
85
  return n.add(t), () => {
88
86
  n.remove(t);
@@ -91,64 +89,64 @@ const C = G({ two: null, parent: null, width: 0, height: 0 }), h = () => L(C), j
91
89
  if (t) {
92
90
  const f = t;
93
91
  typeof o == "number" && (f.translation.x = o), typeof i == "number" && (f.translation.y = i), typeof r < "u" && (f.automatic = !r);
94
- for (const u in a)
95
- u in f && (f[u] = a[u]);
92
+ for (const u in s)
93
+ u in f && (f[u] = s[u]);
96
94
  }
97
- }, [a, t, o, i, r]), y(c, () => t, [t]), /* @__PURE__ */ g(R, {});
95
+ }, [s, t, o, i, r]), y(c, () => t, [t]), /* @__PURE__ */ g(R, {});
98
96
  }
99
97
  ), _ = w.forwardRef(
100
- ({ x: r, y: o, ...i }, a) => {
101
- const { two: c, parent: s } = h(), [n, t] = b(null);
98
+ ({ x: r, y: o, ...i }, s) => {
99
+ const { two: c, parent: a } = h(), [n, t] = b(null);
102
100
  return l(() => {
103
101
  const e = new m.Points();
104
102
  return t(e), () => {
105
103
  t(null);
106
104
  };
107
105
  }, [c, r, o]), l(() => {
108
- if (s && n)
109
- return s.add(n), () => {
110
- s.remove(n);
106
+ if (a && n)
107
+ return a.add(n), () => {
108
+ a.remove(n);
111
109
  };
112
- }, [s, n]), l(() => {
110
+ }, [a, n]), l(() => {
113
111
  if (n) {
114
112
  const e = n;
115
113
  typeof r == "number" && (e.translation.x = r), typeof o == "number" && (e.translation.y = o);
116
114
  for (const f in i)
117
115
  f in e && (e[f] = i[f]);
118
116
  }
119
- }, [i, n, r, o]), y(a, () => n, [n]), /* @__PURE__ */ g(R, {});
117
+ }, [i, n, r, o]), y(s, () => n, [n]), /* @__PURE__ */ g(R, {});
120
118
  }
121
119
  ), z = w.forwardRef(
122
- ({ x: r, y: o, ...i }, a) => {
123
- const { two: c, parent: s } = h(), [n, t] = b(null);
120
+ ({ x: r, y: o, ...i }, s) => {
121
+ const { two: c, parent: a } = h(), [n, t] = b(null);
124
122
  return l(() => {
125
123
  const e = new m.Text();
126
124
  return t(e), () => {
127
125
  t(null);
128
126
  };
129
127
  }, [c]), l(() => {
130
- if (s && n)
131
- return s.add(n), () => {
132
- s.remove(n);
128
+ if (a && n)
129
+ return a.add(n), () => {
130
+ a.remove(n);
133
131
  };
134
- }, [s, n]), l(() => {
132
+ }, [a, n]), l(() => {
135
133
  if (n) {
136
134
  const e = n;
137
135
  typeof r == "number" && (e.translation.x = r), typeof o == "number" && (e.translation.y = o);
138
136
  for (const f in i)
139
137
  f in e && (e[f] = i[f]);
140
138
  }
141
- }, [i, n, r, o]), y(a, () => n, [n]), /* @__PURE__ */ g(R, {});
139
+ }, [i, n, r, o]), y(s, () => n, [n]), /* @__PURE__ */ g(R, {});
142
140
  }
143
141
  ), B = w.forwardRef(
144
- ({ x: r, y: o, resolution: i, ...a }, c) => {
145
- const { two: s, parent: n } = h(), [t, e] = b(null);
142
+ ({ x: r, y: o, resolution: i, ...s }, c) => {
143
+ const { two: a, parent: n } = h(), [t, e] = b(null);
146
144
  return l(() => {
147
145
  const f = new m.ArcSegment(0, 0, 0, 0, 0, 0, i);
148
146
  return e(f), () => {
149
147
  e(null);
150
148
  };
151
- }, [i, s]), l(() => {
149
+ }, [i, a]), l(() => {
152
150
  if (n && t)
153
151
  return n.add(t), () => {
154
152
  n.remove(t);
@@ -157,27 +155,27 @@ const C = G({ two: null, parent: null, width: 0, height: 0 }), h = () => L(C), j
157
155
  if (t) {
158
156
  const f = t;
159
157
  typeof r == "number" && (f.translation.x = r), typeof o == "number" && (f.translation.y = o);
160
- for (const u in a)
161
- u in f && (f[u] = a[u]);
158
+ for (const u in s)
159
+ u in f && (f[u] = s[u]);
162
160
  }
163
- }, [a, t, r, o]), y(c, () => t, [t]), /* @__PURE__ */ g(R, {});
161
+ }, [s, t, r, o]), y(c, () => t, [t]), /* @__PURE__ */ g(R, {});
164
162
  }
165
163
  ), J = w.forwardRef(
166
- ({ x: r, y: o, resolution: i, ...a }, c) => {
167
- const { two: s, parent: n } = h(), [t, e] = b(null);
164
+ ({ x: r, y: o, resolution: i, ...s }, c) => {
165
+ const { two: a, parent: n } = h(), [t, e] = b(null);
168
166
  return l(() => {
169
167
  const f = new m.Circle(0, 0, 0, i);
170
168
  return e(f), () => {
171
169
  e(null);
172
170
  };
173
- }, [i, s]), l(() => {
171
+ }, [i, a]), l(() => {
174
172
  if (t) {
175
173
  const f = t;
176
174
  typeof r == "number" && (f.translation.x = r), typeof o == "number" && (f.translation.y = o);
177
- for (const u in a)
178
- u in f && (f[u] = a[u]);
175
+ for (const u in s)
176
+ u in f && (f[u] = s[u]);
179
177
  }
180
- }, [t, a, r, o]), l(() => {
178
+ }, [t, s, r, o]), l(() => {
181
179
  if (n && t)
182
180
  return n.add(t), () => {
183
181
  n.remove(t);
@@ -185,31 +183,31 @@ const C = G({ two: null, parent: null, width: 0, height: 0 }), h = () => L(C), j
185
183
  }, [n, t]), y(c, () => t, [t]), /* @__PURE__ */ g(R, {});
186
184
  }
187
185
  ), K = w.forwardRef(
188
- ({ x: r, y: o, resolution: i, ...a }, c) => {
189
- const { two: s, parent: n } = h(), [t, e] = b(null);
186
+ ({ x: r, y: o, resolution: i, ...s }, c) => {
187
+ const { two: a, parent: n } = h(), [t, e] = b(null);
190
188
  return l(() => {
191
189
  const f = new m.Ellipse(0, 0, 0, 0, i);
192
190
  return e(f), () => {
193
191
  e(null);
194
192
  };
195
- }, [i, s]), l(() => {
193
+ }, [i, a]), l(() => {
196
194
  if (n && t)
197
195
  return n.add(t), () => {
198
196
  n.remove(t);
199
197
  };
200
- }, [n]), l(() => {
198
+ }, [n, t]), l(() => {
201
199
  if (t) {
202
200
  const f = t;
203
201
  typeof r == "number" && (f.translation.x = r), typeof o == "number" && (f.translation.y = o);
204
- for (const u in a)
205
- u in f && (f[u] = a[u]);
202
+ for (const u in s)
203
+ u in f && (f[u] = s[u]);
206
204
  }
207
- }, [t, r, o, a]), y(c, () => t, [t]), /* @__PURE__ */ g(R, {});
205
+ }, [t, r, o, s]), y(c, () => t, [t]), /* @__PURE__ */ g(R, {});
208
206
  }
209
207
  ), N = w.forwardRef(
210
- ({ mode: r, texture: o, x: i, y: a, ...c }, s) => {
208
+ ({ mode: r, texture: o, x: i, y: s, ...c }, a) => {
211
209
  const { two: n, parent: t } = h(), [e, f] = b(null);
212
- return S(() => {
210
+ return k(() => {
213
211
  const u = new m.Image();
214
212
  return f(u), () => {
215
213
  f(null);
@@ -222,16 +220,16 @@ const C = G({ two: null, parent: null, width: 0, height: 0 }), h = () => L(C), j
222
220
  }, [t, e]), l(() => {
223
221
  if (e) {
224
222
  const u = e;
225
- typeof r < "u" && (u.mode = r), typeof o < "u" && (u.texture = o), typeof i == "number" && (u.translation.x = i), typeof a == "number" && (u.translation.y = a);
223
+ typeof r < "u" && (u.mode = r), typeof o < "u" && (u.texture = o), typeof i == "number" && (u.translation.x = i), typeof s == "number" && (u.translation.y = s);
226
224
  for (const d in c)
227
225
  d in u && (u[d] = c[d]);
228
226
  }
229
- }, [e, c, r, o, i, a]), y(s, () => e, [e]), /* @__PURE__ */ g(R, {});
227
+ }, [e, c, r, o, i, s]), y(a, () => e, [e]), /* @__PURE__ */ g(R, {});
230
228
  }
231
229
  ), Q = w.forwardRef(
232
- ({ paths: r, x: o, y: i, autoPlay: a, ...c }, s) => {
230
+ ({ paths: r, x: o, y: i, autoPlay: s, ...c }, a) => {
233
231
  const { two: n, parent: t } = h(), [e, f] = b(null);
234
- return S(() => {
232
+ return k(() => {
235
233
  const u = new m.ImageSequence(r);
236
234
  return f(u), () => {
237
235
  f(null);
@@ -244,14 +242,14 @@ const C = G({ two: null, parent: null, width: 0, height: 0 }), h = () => L(C), j
244
242
  }, [t, e]), l(() => {
245
243
  if (e) {
246
244
  const u = e;
247
- a ? u.play() : u.pause(), typeof o == "number" && (u.translation.x = o), typeof i == "number" && (u.translation.y = i);
245
+ s ? u.play() : u.pause(), typeof o == "number" && (u.translation.x = o), typeof i == "number" && (u.translation.y = i);
248
246
  for (const d in c)
249
247
  d in u && (u[d] = c[d]);
250
248
  }
251
- }, [c, e, r, o, i, a]), y(s, () => e, [e]), /* @__PURE__ */ g(R, {});
249
+ }, [c, e, r, o, i, s]), y(a, () => e, [e]), /* @__PURE__ */ g(R, {});
252
250
  }
253
251
  ), U = w.forwardRef(
254
- ({ x1: r, y1: o, x2: i, y2: a, ...c }, s) => {
252
+ ({ x1: r, y1: o, x2: i, y2: s, ...c }, a) => {
255
253
  const { two: n, parent: t } = h(), [e, f] = b(null);
256
254
  return l(() => {
257
255
  const u = new m.Line();
@@ -267,82 +265,82 @@ const C = G({ two: null, parent: null, width: 0, height: 0 }), h = () => L(C), j
267
265
  }, [t, e]), l(() => {
268
266
  if (e) {
269
267
  const u = e;
270
- typeof r == "number" && (u.left.x = r), typeof o == "number" && (u.left.y = o), typeof i == "number" && (u.right.x = i), typeof a == "number" && (u.right.y = a);
268
+ typeof r == "number" && (u.left.x = r), typeof o == "number" && (u.left.y = o), typeof i == "number" && (u.right.x = i), typeof s == "number" && (u.right.y = s);
271
269
  for (const d in c)
272
270
  d in u && (u[d] = c[d]);
273
271
  }
274
- }, [c, e, r, o, i, a]), y(s, () => e, [e]), /* @__PURE__ */ g(R, {});
272
+ }, [c, e, r, o, i, s]), y(a, () => e, [e]), /* @__PURE__ */ g(R, {});
275
273
  }
276
274
  ), V = w.forwardRef(
277
- ({ x: r, y: o, ...i }, a) => {
278
- const { two: c, parent: s } = h(), [n, t] = b(null);
275
+ ({ x: r, y: o, ...i }, s) => {
276
+ const { two: c, parent: a } = h(), [n, t] = b(null);
279
277
  return l(() => {
280
278
  const e = new m.Polygon();
281
279
  return t(e), () => {
282
280
  t(null);
283
281
  };
284
282
  }, [c]), l(() => {
285
- if (s && n)
286
- return s.add(n), () => {
287
- s.remove(n);
283
+ if (a && n)
284
+ return a.add(n), () => {
285
+ a.remove(n);
288
286
  };
289
- }, [s, n]), l(() => {
287
+ }, [a, n]), l(() => {
290
288
  if (n) {
291
289
  const e = n;
292
290
  typeof r == "number" && (e.translation.x = r), typeof o == "number" && (e.translation.y = o);
293
291
  for (const f in i)
294
292
  f in e && (e[f] = i[f]);
295
293
  }
296
- }, [i, n, r, o]), y(a, () => n, [n]), /* @__PURE__ */ g(R, {});
294
+ }, [i, n, r, o]), y(s, () => n, [n]), /* @__PURE__ */ g(R, {});
297
295
  }
298
296
  ), W = w.forwardRef(
299
- ({ x: r, y: o, ...i }, a) => {
300
- const { two: c, parent: s } = h(), [n, t] = b(null);
297
+ ({ x: r, y: o, ...i }, s) => {
298
+ const { two: c, parent: a } = h(), [n, t] = b(null);
301
299
  return l(() => {
302
300
  const e = new m.Rectangle();
303
301
  return t(e), () => {
304
302
  t(null);
305
303
  };
306
304
  }, [c]), l(() => {
307
- if (s && n)
308
- return s.add(n), () => {
309
- s.remove(n);
305
+ if (a && n)
306
+ return a.add(n), () => {
307
+ a.remove(n);
310
308
  };
311
- }, [s, n]), l(() => {
309
+ }, [a, n]), l(() => {
312
310
  if (n) {
313
311
  const e = n;
314
312
  typeof r == "number" && (e.translation.x = r), typeof o == "number" && (e.translation.y = o);
315
313
  for (const f in i)
316
314
  f in e && (e[f] = i[f]);
317
315
  }
318
- }, [i, n, r, o]), y(a, () => n, [n]), /* @__PURE__ */ g(R, {});
316
+ }, [i, n, r, o]), y(s, () => n, [n]), /* @__PURE__ */ g(R, {});
319
317
  }
320
318
  ), Z = w.forwardRef(
321
- ({ x: r, y: o, ...i }, a) => {
322
- const { two: c, parent: s } = h(), [n, t] = b(null);
319
+ ({ x: r, y: o, ...i }, s) => {
320
+ const { two: c, parent: a } = h(), [n, t] = b(null);
323
321
  return l(() => {
324
322
  const e = new m.RoundedRectangle();
325
323
  return t(e), () => {
326
324
  t(null);
327
325
  };
328
326
  }, [c]), l(() => {
329
- if (s && n)
330
- return s.add(n), () => {
331
- s.remove(n);
327
+ if (a && n)
328
+ return a.add(n), () => {
329
+ a.remove(n);
332
330
  };
333
- }, [s, n]), l(() => {
331
+ }, [a, n]), l(() => {
334
332
  if (n) {
335
333
  const e = n;
336
334
  typeof r == "number" && (e.translation.x = r), typeof o == "number" && (e.translation.y = o);
337
335
  for (const f in i)
338
336
  f in e && (e[f] = i[f]);
339
337
  }
340
- }, [i, n, r, o]), y(a, () => n, [n]), /* @__PURE__ */ g(R, {});
338
+ }, [i, n, r, o]), y(s, () => n, [n]), /* @__PURE__ */ g(R, {});
341
339
  }
342
340
  ), $ = w.forwardRef(
343
- ({ path: r, x: o, y: i, autoPlay: a, ...c }, s) => {
341
+ ({ path: r, x: o, y: i, autoPlay: s, ...c }, a) => {
344
342
  const { two: n, parent: t } = h(), [e, f] = b(null);
345
- return S(() => {
343
+ return k(() => {
346
344
  const u = new m.Sprite(r);
347
345
  return f(u), () => {
348
346
  f(null);
@@ -352,83 +350,83 @@ const C = G({ two: null, parent: null, width: 0, height: 0 }), h = () => L(C), j
352
350
  return t.add(e), () => {
353
351
  t.remove(e);
354
352
  };
355
- }, [t]), l(() => {
353
+ }, [t, e]), l(() => {
356
354
  if (e) {
357
355
  const u = e;
358
- typeof o == "number" && (u.translation.x = o), typeof i == "number" && (u.translation.y = i), a ? u.play() : u.pause();
356
+ typeof o == "number" && (u.translation.x = o), typeof i == "number" && (u.translation.y = i), s ? u.play() : u.pause();
359
357
  for (const d in c)
360
358
  d in u && (u[d] = c[d]);
361
359
  }
362
- }, [c, e, o, i, a]), y(s, () => e, [e]), /* @__PURE__ */ g(R, {});
360
+ }, [c, e, o, i, s]), y(a, () => e, [e]), /* @__PURE__ */ g(R, {});
363
361
  }
364
362
  ), D = w.forwardRef(
365
- ({ x: r, y: o, ...i }, a) => {
366
- const { two: c, parent: s } = h(), [n, t] = b(null);
363
+ ({ x: r, y: o, ...i }, s) => {
364
+ const { two: c, parent: a } = h(), [n, t] = b(null);
367
365
  return l(() => {
368
366
  const e = new m.Star();
369
367
  return t(e), () => {
370
368
  t(null);
371
369
  };
372
370
  }, [c]), l(() => {
373
- if (s && n)
374
- return s.add(n), () => {
375
- s.remove(n);
371
+ if (a && n)
372
+ return a.add(n), () => {
373
+ a.remove(n);
376
374
  };
377
- }, [s, n]), l(() => {
375
+ }, [a, n]), l(() => {
378
376
  if (n) {
379
377
  const e = n;
380
378
  typeof r == "number" && (e.translation.x = r), typeof o == "number" && (e.translation.y = o);
381
379
  for (const f in i)
382
380
  f in e && (e[f] = i[f]);
383
381
  }
384
- }, [i, n, r, o]), y(a, () => n, [n]), /* @__PURE__ */ g(R, {});
382
+ }, [i, n, r, o]), y(s, () => n, [n]), /* @__PURE__ */ g(R, {});
385
383
  }
386
384
  ), X = w.forwardRef(
387
- ({ x1: r, y1: o, x2: i, y2: a, ...c }, s) => {
388
- const n = P(() => new m.LinearGradient(), []);
385
+ ({ x1: r, y1: o, x2: i, y2: s, ...c }, a) => {
386
+ const n = I(() => new m.LinearGradient(), []);
389
387
  return l(() => {
390
388
  if (n) {
391
389
  const t = n;
392
- typeof r == "number" && (t.left.x = r), typeof o == "number" && (t.left.y = o), typeof i == "number" && (t.right.x = i), typeof a == "number" && (t.right.y = a);
390
+ typeof r == "number" && (t.left.x = r), typeof o == "number" && (t.left.y = o), typeof i == "number" && (t.right.x = i), typeof s == "number" && (t.right.y = s);
393
391
  for (const e in c)
394
392
  e in t && (t[e] = c[e]);
395
393
  }
396
- }, [n, r, o, i, a, c]), y(s, () => n, [n]), null;
394
+ }, [n, r, o, i, s, c]), y(a, () => n, [n]), null;
397
395
  }
398
396
  ), Y = w.forwardRef(
399
- ({ x: r, y: o, focalX: i, focalY: a, ...c }, s) => {
400
- const n = P(() => new m.RadialGradient(), []);
397
+ ({ x: r, y: o, focalX: i, focalY: s, ...c }, a) => {
398
+ const n = I(() => new m.RadialGradient(), []);
401
399
  return l(() => {
402
400
  if (n) {
403
401
  const t = n;
404
- typeof r == "number" && (n.center.x = r), typeof o == "number" && (n.center.y = o), typeof i == "number" && (n.focal.x = i), typeof a == "number" && (n.focal.y = a);
402
+ typeof r == "number" && (n.center.x = r), typeof o == "number" && (n.center.y = o), typeof i == "number" && (n.focal.x = i), typeof s == "number" && (n.focal.y = s);
405
403
  for (const e in c)
406
404
  e in t && (t[e] = c[e]);
407
405
  }
408
- }, [c, n, r, o, i, a]), y(s, () => n, [n]), null;
406
+ }, [c, n, r, o, i, s]), y(a, () => n, [n]), null;
409
407
  }
410
408
  ), x = w.forwardRef(
411
409
  ({ source: r, ...o }, i) => {
412
- const [a, c] = b(null);
410
+ const [s, c] = b(null);
413
411
  return l(() => {
414
- const s = new m.Texture(r);
415
- return c(s), () => {
412
+ const a = new m.Texture(r);
413
+ return c(a), () => {
416
414
  c(null);
417
415
  };
418
416
  }, [r]), l(() => {
419
- if (a) {
420
- const s = a;
417
+ if (s) {
418
+ const a = s;
421
419
  for (const n in o)
422
- n in s && (s[n] = o[n]);
420
+ n in a && (a[n] = o[n]);
423
421
  }
424
- }, [o, a]), y(i, () => a, [a]), null;
422
+ }, [o, s]), y(i, () => s, [s]), null;
425
423
  }
426
424
  );
427
425
  export {
428
426
  B as ArcSegment,
429
427
  H as Canvas,
430
428
  J as Circle,
431
- C as Context,
429
+ S as Context,
432
430
  K as Ellipse,
433
431
  M as Group,
434
432
  N as Image,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-two.js",
3
- "version": "v0.2.0",
3
+ "version": "v0.2.3",
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",
@@ -48,12 +48,7 @@
48
48
  "test": "vitest",
49
49
  "test:watch": "vitest --watch",
50
50
  "test:ui": "vitest --ui",
51
- "test:coverage": "vitest --coverage",
52
- "prepublishOnly": "npm run build:lib",
53
- "publish": "npm publish",
54
- "version:patch": "npm version patch",
55
- "version:minor": "npm version minor",
56
- "version:major": "npm version major"
51
+ "test:coverage": "vitest --coverage"
57
52
  },
58
53
  "devDependencies": {
59
54
  "@eslint/js": "^9.13.0",
@@ -78,13 +73,13 @@
78
73
  "tailwindcss": "^4.1.14",
79
74
  "typescript": "~5.6.2",
80
75
  "typescript-eslint": "^8.11.0",
81
- "vite": "^5.4.10",
76
+ "vite": "^7.1.11",
82
77
  "vite-plugin-dts": "^4.5.0",
83
78
  "vitest": "^3.2.4"
84
79
  },
85
80
  "peerDependencies": {
86
- "react": "^18.3.1",
87
- "react-dom": "^18.3.1",
88
- "two.js": "^v0.8.21"
81
+ "react": ">=19",
82
+ "react-dom": ">=19",
83
+ "two.js": ">=v0.8.21"
89
84
  }
90
85
  }