@octanejs/three 0.1.2 → 0.1.4

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,8 +1,9 @@
1
1
  {
2
2
  "name": "@octanejs/three",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
+ "sideEffects": false,
6
7
  "engines": {
7
8
  "node": ">=22"
8
9
  },
@@ -50,7 +51,7 @@
50
51
  "peerDependencies": {
51
52
  "@types/three": ">=0.156.0",
52
53
  "three": ">=0.156.0",
53
- "octane": "0.1.9"
54
+ "octane": "0.1.11"
54
55
  },
55
56
  "peerDependenciesMeta": {
56
57
  "@types/three": {
@@ -61,7 +62,7 @@
61
62
  "@react-three/fiber": "9.6.1",
62
63
  "@rsbuild/core": "^2.1.5",
63
64
  "@rspack/core": "^2.1.3",
64
- "@tsrx/react": "^0.2.37",
65
+ "@tsrx/react": "^0.2.44",
65
66
  "@types/three": "0.172.0",
66
67
  "esbuild": "^0.28.1",
67
68
  "playwright": "^1.61.0",
@@ -71,10 +72,10 @@
71
72
  "typescript": "^5.9.3",
72
73
  "vite": "^8.0.16",
73
74
  "vitest": "^4.1.9",
74
- "@octanejs/rsbuild-plugin": "0.1.4",
75
- "@octanejs/rspack-plugin": "0.1.4",
76
- "@octanejs/vite-plugin": "0.1.9",
77
- "octane": "0.1.9"
75
+ "@octanejs/rsbuild-plugin": "0.1.6",
76
+ "@octanejs/rspack-plugin": "0.1.6",
77
+ "@octanejs/vite-plugin": "0.1.11",
78
+ "octane": "0.1.11"
78
79
  },
79
80
  "scripts": {
80
81
  "test": "pnpm upstream:check && vitest run --root ../.. --project three",
package/src/core/root.ts CHANGED
@@ -15,6 +15,7 @@ import {
15
15
  type UniversalComponent,
16
16
  type UniversalRoot,
17
17
  } from 'octane/universal';
18
+ import type { ThreeElement } from './catalogue.js';
18
19
  import { applyThreeProps } from './props.js';
19
20
  import {
20
21
  createThreeContainer,
@@ -62,9 +63,20 @@ export type GLProps<TCanvas extends CanvasLike = CanvasLike> =
62
63
  | ((defaults: DefaultGLProps<TCanvas>) => Renderer | Promise<Renderer>)
63
64
  | (Partial<THREE.WebGLRendererParameters> & Record<string, unknown>);
64
65
 
65
- export type CameraProps =
66
+ // R3F-shaped (fiber v9 renderer.ts): declarative camera options accept the
67
+ // element-prop forms — math shorthands like `position: [x, y, z]` included —
68
+ // not only fully-constructed THREE property values.
69
+ export type CameraProps = (
66
70
  | Camera
67
- | (Partial<THREE.PerspectiveCamera & THREE.OrthographicCamera> & { manual?: boolean });
71
+ | Partial<
72
+ ThreeElement<typeof THREE.Camera> &
73
+ ThreeElement<typeof THREE.PerspectiveCamera> &
74
+ ThreeElement<typeof THREE.OrthographicCamera>
75
+ >
76
+ ) & {
77
+ /** Flags the camera as manual, putting projection into your own hands. */
78
+ manual?: boolean;
79
+ };
68
80
 
69
81
  export interface RenderProps<TCanvas extends CanvasLike = CanvasLike> {
70
82
  gl?: GLProps<TCanvas>;
@@ -1,4 +1,5 @@
1
1
  import { useInsertionEffect, useLayoutEffect, useRef, useState } from 'octane';
2
+ import type { OctaneNode } from 'octane';
2
3
  import { createUniversalHostBoundary } from 'octane/universal';
3
4
  import type { RendererRegion } from 'octane/universal';
4
5
  import type { ComputeFunction, DomEvent } from '../core/events.js';
@@ -27,8 +28,12 @@ export interface CanvasProps extends Omit<RenderProps<HTMLCanvasElement>, 'size'
27
28
  string,
28
29
  unknown
29
30
  > {
30
- /** Compiler-owned Three renderer region. Application JSX is lowered into this payload. */
31
- children?: RendererRegion;
31
+ /**
32
+ * Authored Three-scene JSX. The compiler lowers the authored children into a
33
+ * `RendererRegion` payload at the boundary, so the runtime only ever sees the
34
+ * region form; `OctaneNode` keeps the authoring side type-checkable.
35
+ */
36
+ children?: RendererRegion | OctaneNode;
32
37
  /** Fallback content rendered as native canvas fallback DOM. */
33
38
  fallback?: unknown;
34
39
  /** DOM measurement options compatible with the R3F Canvas surface. */
@@ -118,7 +123,7 @@ function bindCanvasEvents(
118
123
 
119
124
  /** A measured DOM canvas whose authored children execute in the Three renderer. */
120
125
  export function Canvas({
121
- ref,
126
+ ref = null,
122
127
  children,
123
128
  fallback,
124
129
  resize,
@@ -220,8 +225,10 @@ export function Canvas({
220
225
  raycaster,
221
226
  camera,
222
227
  scene,
223
- onPointerMissed: pointerMissedHandlerRef.current,
224
- onCreated: createdHandlerRef.current,
228
+ // Both handlers were lazily created during render; the `| null` only
229
+ // survives because TS cannot carry the narrowing into this closure.
230
+ onPointerMissed: pointerMissedHandlerRef.current ?? undefined,
231
+ onCreated: createdHandlerRef.current ?? undefined,
225
232
  size,
226
233
  }).then(() => {
227
234
  if (cancelled) return;
@@ -268,7 +275,9 @@ export function Canvas({
268
275
  ? null
269
276
  : {
270
277
  ...boundaryMount,
271
- props: { ...boundaryMount.props, region: children },
278
+ // By this point the compiler has lowered the authored JSX children
279
+ // into the boundary's region payload.
280
+ props: { ...boundaryMount.props, region: children as RendererRegion | undefined },
272
281
  };
273
282
 
274
283
  const wrapperStyle: CanvasStyle = {
@@ -1,3 +1,4 @@
1
+ import type { OctaneNode } from 'octane';
1
2
  import type { RendererRegion } from 'octane/universal';
2
3
  import type { RenderProps } from '../core/root.js';
3
4
  import type { ResizeOptions } from './measure.js';
@@ -11,7 +12,7 @@ export type CanvasRef =
11
12
 
12
13
  export interface CanvasProps
13
14
  extends Omit<RenderProps<HTMLCanvasElement>, 'size'>, Record<string, unknown> {
14
- children?: RendererRegion;
15
+ children?: RendererRegion | OctaneNode;
15
16
  fallback?: unknown;
16
17
  resize?: ResizeOptions;
17
18
  eventSource?: HTMLElement | { current: HTMLElement | null };