@octanejs/three 0.1.55 → 0.1.57
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 +7 -7
- package/src/core/catalogue.ts +6 -1
- package/src/intrinsics.ts +6 -1
- package/src/web/Canvas.tsrx +58 -49
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@octanejs/three",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.57",
|
|
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.
|
|
53
|
+
"octane": "^0.12.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.
|
|
63
|
-
"@octanejs/rspack-plugin": "0.2.
|
|
64
|
-
"@octanejs/vite-plugin": "0.3.
|
|
62
|
+
"@octanejs/rsbuild-plugin": "0.1.63",
|
|
63
|
+
"@octanejs/rspack-plugin": "0.2.2",
|
|
64
|
+
"@octanejs/vite-plugin": "0.3.3",
|
|
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.
|
|
68
|
+
"@tsrx/react": "^0.4.5",
|
|
69
69
|
"@types/three": "0.172.0",
|
|
70
70
|
"esbuild": "^0.28.1",
|
|
71
|
-
"octane": "0.
|
|
71
|
+
"octane": "0.12.0",
|
|
72
72
|
"playwright": "^1.61.1",
|
|
73
73
|
"react": "19.2.7",
|
|
74
74
|
"react-dom": "19.2.7",
|
package/src/core/catalogue.ts
CHANGED
|
@@ -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))
|
|
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
|
}
|
package/src/web/Canvas.tsrx
CHANGED
|
@@ -25,15 +25,13 @@ export type CanvasRef =
|
|
|
25
25
|
| readonly CanvasRef[]
|
|
26
26
|
| null;
|
|
27
27
|
|
|
28
|
-
export interface CanvasProps
|
|
29
|
-
string,
|
|
30
|
-
unknown
|
|
31
|
-
> {
|
|
28
|
+
export interface CanvasProps
|
|
29
|
+
extends Omit<RenderProps<HTMLCanvasElement>, 'size'>, Record<string, unknown> {
|
|
32
30
|
/**
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
|
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
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
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
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
<
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
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
|
-
|
|
315
|
+
/>
|
|
316
|
+
)}
|
|
317
|
+
</div>
|
|
318
|
+
);
|
|
310
319
|
}
|