react-two.js 0.8.22-r.1 → 0.8.22-r.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 +4 -3
- package/dist/Context.d.ts +12 -5
- package/dist/SVG.d.ts +11 -7
- package/dist/main.d.ts +1 -1
- package/dist/react-two-main.es.js +693 -673
- package/package.json +2 -2
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
|
|
71
|
-
- Two.js v0.8.
|
|
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/Context.d.ts
CHANGED
|
@@ -2,14 +2,21 @@ import Two from 'two.js';
|
|
|
2
2
|
import type { Group } from 'two.js/src/group';
|
|
3
3
|
import type { Shape } from 'two.js/src/shape';
|
|
4
4
|
import type { EventHandlers } from './Events';
|
|
5
|
-
export interface
|
|
5
|
+
export interface TwoCoreContextValue {
|
|
6
6
|
two: Two | null;
|
|
7
|
+
registerEventShape: (shape: Shape | Group, handlers: Partial<EventHandlers>, parent?: Group) => void;
|
|
8
|
+
unregisterEventShape: (shape: Shape | Group) => void;
|
|
9
|
+
}
|
|
10
|
+
export interface TwoParentContextValue {
|
|
7
11
|
parent: Group | null;
|
|
12
|
+
}
|
|
13
|
+
export interface TwoSizeContextValue {
|
|
8
14
|
width: number;
|
|
9
15
|
height: number;
|
|
10
|
-
registerEventShape: (shape: Shape | Group, handlers: Partial<EventHandlers>, parent?: Group) => void;
|
|
11
|
-
unregisterEventShape: (shape: Shape | Group) => void;
|
|
12
16
|
}
|
|
13
|
-
export declare const
|
|
14
|
-
export declare const
|
|
17
|
+
export declare const TwoCoreContext: import("react").Context<TwoCoreContextValue>;
|
|
18
|
+
export declare const TwoParentContext: import("react").Context<TwoParentContextValue>;
|
|
19
|
+
export declare const TwoSizeContext: import("react").Context<TwoSizeContextValue>;
|
|
20
|
+
export declare const Context: import("react").Context<TwoCoreContextValue>;
|
|
21
|
+
export declare const useTwo: () => TwoCoreContextValue & TwoParentContextValue & TwoSizeContextValue;
|
|
15
22
|
export declare const useFrame: (callback: (elapsed: number, frameDelta: number) => void, deps?: unknown[]) => void;
|
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
|
-
|
|
5
|
+
type ComponentProps = React.PropsWithChildren<{
|
|
6
6
|
[K in Extract<GroupProps, keyof Instance>]?: Instance[K];
|
|
7
|
-
}
|
|
8
|
-
src
|
|
9
|
-
content?:
|
|
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:
|
|
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<
|
|
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
|
|
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';
|