@octanejs/three 0.1.55 → 0.1.56

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@octanejs/three",
3
- "version": "0.1.55",
3
+ "version": "0.1.56",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -50,7 +50,7 @@
50
50
  },
51
51
  "peerDependencies": {
52
52
  "@types/three": ">=0.156.0",
53
- "octane": "^0.10.0",
53
+ "octane": "^0.11.0",
54
54
  "three": ">=0.156.0"
55
55
  },
56
56
  "peerDependenciesMeta": {
@@ -59,16 +59,16 @@
59
59
  }
60
60
  },
61
61
  "devDependencies": {
62
- "@octanejs/rsbuild-plugin": "0.1.61",
63
- "@octanejs/rspack-plugin": "0.2.0",
64
- "@octanejs/vite-plugin": "0.3.1",
62
+ "@octanejs/rsbuild-plugin": "0.1.62",
63
+ "@octanejs/rspack-plugin": "0.2.1",
64
+ "@octanejs/vite-plugin": "0.3.2",
65
65
  "@react-three/fiber": "9.6.1",
66
66
  "@rsbuild/core": "^2.1.6",
67
67
  "@rspack/core": "^2.1.4",
68
- "@tsrx/react": "^0.3.7",
68
+ "@tsrx/react": "^0.4.5",
69
69
  "@types/three": "0.172.0",
70
70
  "esbuild": "^0.28.1",
71
- "octane": "0.10.2",
71
+ "octane": "0.11.0",
72
72
  "playwright": "^1.61.1",
73
73
  "react": "19.2.7",
74
74
  "react-dom": "19.2.7",
@@ -49,8 +49,13 @@ export type AttachFnType<T = unknown> = ThreeAttachFunction<T>;
49
49
  export type AttachType<T = unknown> = Attach<T>;
50
50
  export type ThreeKey = string | number | symbol | bigint;
51
51
 
52
+ // A ref array may hold absent entries: composing an authored ref with a spread
53
+ // that carries none leaves `undefined` (or an authored `null`) in its place, and
54
+ // attachment skips them.
52
55
  export type ThreeRef<T> =
53
- ((value: T | null) => void | (() => void)) | { current: T | null } | readonly ThreeRef<T>[];
56
+ | ((value: T | null) => void | (() => void))
57
+ | { current: T | null }
58
+ | readonly (ThreeRef<T> | null | undefined)[];
54
59
 
55
60
  export interface ThreeInstanceProps<T = unknown> {
56
61
  attach?: Attach<T>;
package/src/intrinsics.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ThreeElements as ThreeIntrinsicElements } from './core/catalogue.js';
1
+ import type { ThreeKey, ThreeElements as ThreeIntrinsicElements } from './core/catalogue.js';
2
2
 
3
3
  export type {
4
4
  Args,
@@ -38,4 +38,9 @@ export namespace JSX {
38
38
  export interface ElementChildrenAttribute {
39
39
  children: {};
40
40
  }
41
+ // Every element accepts a key, components included (a keyed `@for` row
42
+ // places its key on the row's root).
43
+ export interface IntrinsicAttributes {
44
+ key?: ThreeKey;
45
+ }
41
46
  }
@@ -25,15 +25,13 @@ export type CanvasRef =
25
25
  | readonly CanvasRef[]
26
26
  | null;
27
27
 
28
- export interface CanvasProps extends Omit<RenderProps<HTMLCanvasElement>, 'size'>, Record<
29
- string,
30
- unknown
31
- > {
28
+ export interface CanvasProps
29
+ extends Omit<RenderProps<HTMLCanvasElement>, 'size'>, Record<string, unknown> {
32
30
  /**
33
- * Authored Three-scene JSX. The compiler lowers the authored children into a
34
- * `RendererRegion` payload at the boundary, so the runtime only ever sees the
35
- * region form; `OctaneNode` keeps the authoring side type-checkable.
36
- */
31
+ * Authored Three-scene JSX. The compiler lowers the authored children into a
32
+ * `RendererRegion` payload at the boundary, so the runtime only ever sees the
33
+ * region form; `OctaneNode` keeps the authoring side type-checkable.
34
+ */
37
35
  children?: RendererRegion | OctaneNode;
38
36
  /** Fallback content rendered as native canvas fallback DOM. */
39
37
  fallback?: unknown;
@@ -48,9 +46,13 @@ export interface CanvasProps extends Omit<RenderProps<HTMLCanvasElement>, 'size'
48
46
  }
49
47
 
50
48
  function sameSize(previous: Size | null, next: Size): boolean {
51
- return previous !== null && previous.width === next.width && previous.height === next.height &&
49
+ return (
50
+ previous !== null &&
51
+ previous.width === next.width &&
52
+ previous.height === next.height &&
52
53
  previous.top === next.top &&
53
- previous.left === next.left;
54
+ previous.left === next.left
55
+ );
54
56
  }
55
57
 
56
58
  function configurationError(error: unknown): Error {
@@ -73,7 +75,7 @@ function resolveEventSource(
73
75
  wrapper: HTMLDivElement | null,
74
76
  ): HTMLElement | null {
75
77
  if (source === undefined) return wrapper;
76
- return 'current' in source ? source.current ?? wrapper : source;
78
+ return 'current' in source ? (source.current ?? wrapper) : source;
77
79
  }
78
80
 
79
81
  function createPrefixCompute(prefix: EventPrefix): ComputeFunction {
@@ -213,31 +215,34 @@ export function Canvas({
213
215
  root = createRoot(canvas);
214
216
  rootRef.current = root;
215
217
  }
216
- void root.configure({
217
- gl,
218
- events,
219
- shadows,
220
- linear,
221
- flat,
222
- legacy,
223
- orthographic,
224
- frameloop,
225
- dpr,
226
- performance,
227
- raycaster,
228
- camera,
229
- scene,
230
- // Both handlers were lazily created during render; the `| null` only
231
- // survives because TS cannot carry the narrowing into this closure.
232
- onPointerMissed: pointerMissedHandlerRef.current ?? undefined,
233
- onCreated: createdHandlerRef.current ?? undefined,
234
- size,
235
- }).then(() => {
236
- if (cancelled) return;
237
- setBoundaryMount(createThreeBoundaryMount(root));
238
- }).catch((reason) => {
239
- if (!cancelled) setError(configurationError(reason));
240
- });
218
+ void root
219
+ .configure({
220
+ gl,
221
+ events,
222
+ shadows,
223
+ linear,
224
+ flat,
225
+ legacy,
226
+ orthographic,
227
+ frameloop,
228
+ dpr,
229
+ performance,
230
+ raycaster,
231
+ camera,
232
+ scene,
233
+ // Both handlers were lazily created during render; the `| null` only
234
+ // survives because TS cannot carry the narrowing into this closure.
235
+ onPointerMissed: pointerMissedHandlerRef.current ?? undefined,
236
+ onCreated: createdHandlerRef.current ?? undefined,
237
+ size,
238
+ })
239
+ .then(() => {
240
+ if (cancelled) return;
241
+ setBoundaryMount(createThreeBoundaryMount(root));
242
+ })
243
+ .catch((reason) => {
244
+ if (!cancelled) setError(configurationError(reason));
245
+ });
241
246
  return () => {
242
247
  cancelled = true;
243
248
  };
@@ -291,20 +296,24 @@ export function Canvas({
291
296
  ...style,
292
297
  };
293
298
 
294
- return <div
295
- ref={wrapperRef}
296
- style={wrapperStyle}
297
- {...domProps as typeof domProps & { ref?: undefined }}
298
- >
299
- <div style={{ width: '100%', height: '100%' }}>
300
- <canvas ref={[canvasRef, ref]} style={{ display: 'block' }}>{fallback}</canvas>
301
- </div>
302
- {renderedBoundaryMount === null
303
- ? null
304
- : <ThreeBoundary
299
+ return (
300
+ <div
301
+ ref={wrapperRef}
302
+ style={wrapperStyle}
303
+ {...(domProps as typeof domProps & { ref?: undefined })}
304
+ >
305
+ <div style={{ width: '100%', height: '100%' }}>
306
+ <canvas ref={[canvasRef, ref]} style={{ display: 'block' }}>
307
+ {fallback}
308
+ </canvas>
309
+ </div>
310
+ {renderedBoundaryMount === null ? null : (
311
+ <ThreeBoundary
305
312
  root={renderedBoundaryMount.root}
306
313
  component={renderedBoundaryMount.component}
307
314
  props={renderedBoundaryMount.props}
308
- />}
309
- </div>;
315
+ />
316
+ )}
317
+ </div>
318
+ );
310
319
  }