mirror of
https://github.com/rive-app/rive-react.git
synced 2026-03-13 08:22:30 +08:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fe8265cd58 | ||
|
|
5b458b76e5 | ||
|
|
1decbc7d85 | ||
|
|
87627125f5 | ||
|
|
e823e9519f | ||
|
|
ac88187118 | ||
|
|
1897e823b9 | ||
|
|
1a2e57a82c | ||
|
|
0d16feeec1 | ||
|
|
ca48907649 | ||
|
|
9b02c0f1bc |
36
CHANGELOG.md
36
CHANGELOG.md
@@ -4,8 +4,44 @@ All notable changes to this project will be documented in this file. Dates are d
|
||||
|
||||
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
||||
|
||||
#### [v4.13.3](https://github.com/rive-app/rive-react/compare/v4.13.2...v4.13.3)
|
||||
|
||||
- update rive version to 2.19.3 [`5b458b7`](https://github.com/rive-app/rive-react/commit/5b458b76e5c8ffa4383d3fe89e020f95154f87fe)
|
||||
|
||||
#### [v4.13.2](https://github.com/rive-app/rive-react/compare/v4.13.1...v4.13.2)
|
||||
|
||||
> 5 July 2024
|
||||
|
||||
- chore: release 4.13.2 [`1decbc7`](https://github.com/rive-app/rive-react/commit/1decbc7d85c5f225dc1def8fa09207f8db102632)
|
||||
- update rive version to 2.19.2 [`8762712`](https://github.com/rive-app/rive-react/commit/87627125f571f85a4cd71a8d7c48af1032d32747)
|
||||
|
||||
#### [v4.13.1](https://github.com/rive-app/rive-react/compare/v4.13.0...v4.13.1)
|
||||
|
||||
> 3 July 2024
|
||||
|
||||
- chore: release 4.13.1 [`e823e95`](https://github.com/rive-app/rive-react/commit/e823e9519f9ffa6bb3a1e4fd8bd3b2c98f6143a6)
|
||||
- update rive version to 2.19.1 [`ac88187`](https://github.com/rive-app/rive-react/commit/ac881871189a134b821a86e25029d2db056c2bef)
|
||||
- fix: change initialization from play to load event [`1897e82`](https://github.com/rive-app/rive-react/commit/1897e823b9bd500813c96a1512d90dc3b9bbe976)
|
||||
|
||||
#### [v4.13.0](https://github.com/rive-app/rive-react/compare/v4.12.1...v4.13.0)
|
||||
|
||||
> 28 June 2024
|
||||
|
||||
- chore: release 4.13.0 [`1a2e57a`](https://github.com/rive-app/rive-react/commit/1a2e57a82c391a602e72721945b93c43949ea23b)
|
||||
- update rive version to 2.19.0 [`0d16fee`](https://github.com/rive-app/rive-react/commit/0d16feeec196cb17fd44a875aa132c014aa44243)
|
||||
|
||||
#### [v4.12.1](https://github.com/rive-app/rive-react/compare/v4.12.0...v4.12.1)
|
||||
|
||||
> 25 June 2024
|
||||
|
||||
- fix: catch RiveFile initialization error in hook [`9b02c0f`](https://github.com/rive-app/rive-react/commit/9b02c0f1bc7fb61e17f5d6f51da120c11e82e61a)
|
||||
- chore: release 4.12.1 [`ca48907`](https://github.com/rive-app/rive-react/commit/ca48907649a8dae636947e95afb8931e2299e5c6)
|
||||
|
||||
#### [v4.12.0](https://github.com/rive-app/rive-react/compare/v4.11.3...v4.12.0)
|
||||
|
||||
> 18 June 2024
|
||||
|
||||
- chore: release 4.12.0 [`b25c775`](https://github.com/rive-app/rive-react/commit/b25c7759947b3eaa2b3e62e3304f269235128179)
|
||||
- chore: bump rive web to 2.18.0 [`17811ad`](https://github.com/rive-app/rive-react/commit/17811adac4976b01a797589342d74f42a0972cb8)
|
||||
|
||||
#### [v4.11.3](https://github.com/rive-app/rive-react/compare/v4.11.2...v4.11.3)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@rive-app/react-canvas-lite",
|
||||
"version": "4.12.0",
|
||||
"version": "4.13.3",
|
||||
"description": "React wrapper around the @rive-app/canvas-lite library",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/types/index.d.ts",
|
||||
@@ -18,7 +18,7 @@
|
||||
},
|
||||
"homepage": "https://github.com/rive-app/rive-react#readme",
|
||||
"dependencies": {
|
||||
"@rive-app/canvas-lite": "2.18.0"
|
||||
"@rive-app/canvas-lite": "2.19.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "^16.8.0 || ^17.0.0 || ^18.0.0"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@rive-app/react-canvas",
|
||||
"version": "4.12.0",
|
||||
"version": "4.13.3",
|
||||
"description": "React wrapper around the @rive-app/canvas library",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/types/index.d.ts",
|
||||
@@ -18,7 +18,7 @@
|
||||
},
|
||||
"homepage": "https://github.com/rive-app/rive-react#readme",
|
||||
"dependencies": {
|
||||
"@rive-app/canvas": "2.18.0"
|
||||
"@rive-app/canvas": "2.19.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "^16.8.0 || ^17.0.0 || ^18.0.0"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@rive-app/react-webgl",
|
||||
"version": "4.12.0",
|
||||
"version": "4.13.3",
|
||||
"description": "React wrapper around the @rive-app/webgl library",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/types/index.d.ts",
|
||||
@@ -18,7 +18,7 @@
|
||||
},
|
||||
"homepage": "https://github.com/rive-app/rive-react#readme",
|
||||
"dependencies": {
|
||||
"@rive-app/webgl": "2.18.0"
|
||||
"@rive-app/webgl": "2.19.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "^16.8.0 || ^17.0.0 || ^18.0.0"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@rive-app/react-webgl2",
|
||||
"version": "4.12.0",
|
||||
"version": "4.13.3",
|
||||
"description": "React wrapper around the @rive-app/webgl2 library",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/types/index.d.ts",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "rive-react",
|
||||
"version": "4.12.0",
|
||||
"version": "4.13.3",
|
||||
"description": "React wrapper around the rive-js library",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/types/index.d.ts",
|
||||
@@ -36,9 +36,9 @@
|
||||
},
|
||||
"homepage": "https://github.com/rive-app/rive-react#readme",
|
||||
"dependencies": {
|
||||
"@rive-app/canvas": "2.18.0",
|
||||
"@rive-app/canvas-lite": "2.18.0",
|
||||
"@rive-app/webgl": "2.18.0"
|
||||
"@rive-app/canvas": "2.19.3",
|
||||
"@rive-app/canvas-lite": "2.19.3",
|
||||
"@rive-app/webgl": "2.19.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "^16.8.0 || ^17.0.0 || ^18.0.0"
|
||||
|
||||
@@ -23,20 +23,25 @@ function useRiveFile(params: UseRiveFileParameters): RiveFileState {
|
||||
let file: RiveFile | null = null;
|
||||
|
||||
const loadRiveFile = async () => {
|
||||
setStatus('loading');
|
||||
file = new RiveFile(params);
|
||||
file.init();
|
||||
file.on(EventType.Load, () => {
|
||||
// We request an instance to add +1 to the referencesCount so it doesn't get destroyed
|
||||
// while this hook is active
|
||||
file?.getInstance();
|
||||
try {
|
||||
setStatus('loading');
|
||||
file = new RiveFile(params);
|
||||
file.init();
|
||||
file.on(EventType.Load, () => {
|
||||
// We request an instance to add +1 to the referencesCount so it doesn't get destroyed
|
||||
// while this hook is active
|
||||
file?.getInstance();
|
||||
setRiveFile(file);
|
||||
setStatus('success');
|
||||
});
|
||||
file.on(EventType.LoadError, () => {
|
||||
setStatus('failed');
|
||||
});
|
||||
setRiveFile(file);
|
||||
setStatus('success');
|
||||
});
|
||||
file.on(EventType.LoadError, () => {
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
setStatus('failed');
|
||||
});
|
||||
setRiveFile(file);
|
||||
}
|
||||
};
|
||||
|
||||
loadRiveFile();
|
||||
|
||||
@@ -40,7 +40,7 @@ export default function useStateMachineInput(
|
||||
}
|
||||
setStateMachineInput();
|
||||
if (rive) {
|
||||
rive.on(EventType.Play, () => {
|
||||
rive.on(EventType.Load, () => {
|
||||
// Check if the component/canvas is mounted before setting state to avoid setState
|
||||
// on an unmounted component in some rare cases
|
||||
setStateMachineInput();
|
||||
|
||||
@@ -23,6 +23,8 @@ describe('useRiveFile', () => {
|
||||
mocked(RiveFile).mockClear();
|
||||
});
|
||||
|
||||
|
||||
|
||||
it('initializes RiveFile with provided parameters', async () => {
|
||||
const params = {
|
||||
src: 'file-src',
|
||||
@@ -38,7 +40,7 @@ describe('useRiveFile', () => {
|
||||
it('cleans up RiveFile on unmount', async () => {
|
||||
const params = {
|
||||
src: 'file-src',
|
||||
enableRiveAssetCDN: false
|
||||
enableRiveAssetCDN: false
|
||||
};
|
||||
|
||||
const { result, unmount } = renderHook(() => useRiveFile(params));
|
||||
@@ -54,7 +56,7 @@ describe('useRiveFile', () => {
|
||||
it('does not reinitialize RiveFile if src has not changed', async () => {
|
||||
const params = {
|
||||
src: 'file-src',
|
||||
enableRiveAssetCDN: false
|
||||
enableRiveAssetCDN: false
|
||||
};
|
||||
|
||||
const { rerender } = renderHook(() => useRiveFile(params));
|
||||
@@ -64,7 +66,7 @@ describe('useRiveFile', () => {
|
||||
expect(RiveFile).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('does not reinitialize RiveFile if buffer has not changed', async () => {
|
||||
it('does not reinitialize RiveFile if buffer has not changed', async () => {
|
||||
const params = {
|
||||
buffer: new ArrayBuffer(10),
|
||||
enableRiveAssetCDN: false
|
||||
@@ -112,4 +114,29 @@ describe('useRiveFile', () => {
|
||||
|
||||
expect(RiveFile).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it('handles RiveFile initialization failure gracefully', async () => {
|
||||
|
||||
const consoleSpy = jest.spyOn(console, 'error').mockImplementation(() => { });
|
||||
const error = new Error("Initialization failed");
|
||||
|
||||
mocked(RiveFile).mockImplementation(() => {
|
||||
throw error;
|
||||
});
|
||||
|
||||
const params = {
|
||||
src: 'file-src',
|
||||
enableRiveAssetCDN: false,
|
||||
};
|
||||
|
||||
const { result, rerender } = renderHook(() => useRiveFile(params));
|
||||
|
||||
rerender();
|
||||
|
||||
expect(result.current.status).toBe('failed');
|
||||
expect(result.current.riveFile).toBeNull();
|
||||
expect(consoleSpy).toHaveBeenCalledWith(error);
|
||||
|
||||
consoleSpy.mockRestore();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user