Compare commits

...

520 Commits

Author SHA1 Message Date
avivian
1af00a38c7 chore: release 4.26.0 2026-01-13 12:56:35 +00:00
Arthur Vivian
6ab0496025 chore: bump to 2.34.0 2026-01-13 12:51:04 +00:00
bodymovin
37ced47323 chore: release 4.25.3 2026-01-08 04:11:16 +00:00
Hernan Torrisi
79f1a06df0 update rive to 2.33.3 2026-01-07 20:08:29 -08:00
philter
f0d4c3e6d2 chore: release 4.25.2 2026-01-06 23:23:20 +00:00
Phil Chung
0d3300eca4 Bump rive wasm to 2.33.2 2026-01-06 16:19:09 -07:00
philter
7f6ab5ad10 chore: release 4.25.1 2025-12-20 00:04:31 +00:00
Phil Chung
5df93323ed Bump rive wasm to 2.33.1 2025-12-19 16:59:45 -07:00
HayesGordon
e6bfec7c51 chore: release 4.25.0 2025-12-17 22:01:34 +00:00
CI
770858fb00 chore: auto publish false for release-it 2025-12-17 22:59:26 +01:00
CI
5145a6edb3 chore: ensure latest npm 2025-12-17 22:14:13 +01:00
CI
f74cfbc3d0 chore: bump rive web 2.33.0 2025-12-17 21:34:41 +01:00
CI
925de2fc94 chore: update npm publish workflow with OIDC support 2025-12-17 20:10:39 +01:00
Hernan Torrisi
c7d1d92b9e bump rive wasm to 2.32.1 2025-11-10 19:10:59 -08:00
HayesGordon
19f20268ae chore: release 4.24.0 2025-11-10 13:44:07 +00:00
CI
e6e43564b1 chore: bump rive web 2.32.0 2025-11-10 14:42:06 +01:00
bodymovin
efeee472e6 chore: release 4.23.4 2025-09-23 20:40:08 +00:00
Hernan Torrisi
42d502f452 bump rive to 2.31.6 2025-09-23 09:15:53 -07:00
bodymovin
bd483e0ab7 chore: release 4.23.3 2025-09-04 22:53:16 +00:00
Hernan Torrisi
7c361e4c53 chore: bump rive wasm to 2.31.5 2025-09-04 15:49:34 -07:00
HayesGordon
d80df170aa chore: release 4.23.2 2025-09-04 14:29:04 +00:00
CI
a3118d5984 chore: bump rive wasm to 2.31.4 2025-09-04 16:27:08 +02:00
CI
f732a3b044 docs: update README 2025-09-04 16:27:08 +02:00
bodymovin
57ebc37e3f chore: release 4.23.1 2025-08-13 17:19:55 +00:00
Hernan Torrisi
69a356894d bump rive to 2.31.2 2025-08-13 10:09:58 -07:00
Hernan Torrisi
23d9d7f48b add dependency 2025-08-12 12:27:31 -07:00
Hernan Torrisi
788b7ef68e bump rive canvas to 2.31.1 2025-08-12 12:27:31 -07:00
HayesGordon
69658c204a chore: release 4.23.0 2025-08-08 12:09:50 +00:00
CI
7249fa36e7 chore: bump rive wasm 2.31.0 2025-08-08 12:42:01 +02:00
bodymovin
52dd934e43 chore: release 4.22.1 2025-07-18 14:29:38 +00:00
Hernan Torrisi
c151ee37b5 bump rive to 2.30.4 2025-07-18 07:18:56 -07:00
damzobridge
c660a675c2 chore: release 4.22.0 2025-07-15 20:57:21 +00:00
Adam
74e1d5a5f2 feat: add tests for artboard binding 2025-07-15 12:52:34 -07:00
Adam
963ecc43b8 feat: add useViewModelInstanceArtboard hook 2025-07-15 12:52:34 -07:00
bodymovin
85807f2166 chore: release 4.21.6 2025-07-15 04:51:16 +00:00
Hernan Torrisi
9a33504d3a rive_canvas_2.30.3 2025-07-14 21:48:19 -07:00
HayesGordon
1a4d7e7168 chore: release 4.21.5 2025-07-14 16:12:59 +00:00
CI
b3d0fd4339 chore: bump rive wasm 2.30.2 2025-07-14 17:09:31 +01:00
Adam
c4239ab6b2 fix: lint error with revision 2025-07-07 14:23:22 -07:00
Adam
22f8d5a945 feat: add tests for list property 2025-07-07 14:23:22 -07:00
Adam
721ed786dc feat: add useViewModelInstanceList hook 2025-07-07 14:23:22 -07:00
Adam
eef56fb641 feat: add useViewModelInstanceImage hook 2025-07-07 14:23:22 -07:00
bodymovin
4bc0f496f8 chore: release 4.21.4 2025-06-25 13:39:06 +00:00
Maxwell Talbot
10bb4c69ea fix: update how we use release it with github tokens 2025-06-25 06:26:13 -07:00
Hernan Torrisi
c5b6826996 bump rive to 2.30.1 2025-06-25 06:23:15 -07:00
Adam
ec4875933c refactor: change onLoad to onRiveReady 2025-06-23 11:57:58 -07:00
Adam
d808a8bdea feat: add onLoad callback to useRive 2025-06-23 11:57:58 -07:00
Hernan Torrisi
7b174f7f51 cleanup rive on unmount 2025-06-18 16:25:59 -07:00
bodymovin
eecd0d3c5b chore: release 4.21.3 2025-06-08 17:57:17 +00:00
Hernan Torrisi
6c00364e60 rive react 2.29.3 2025-06-08 10:22:55 -07:00
HayesGordon
d310f1c96d chore: release 4.21.2 2025-06-05 20:43:20 +00:00
CI
68e8fbe46d chore: bump Rive wasm 2.29.2 2025-06-05 22:40:54 +02:00
bodymovin
8ff9a844fe chore: release 4.21.1 2025-05-28 16:15:41 +00:00
Hernan Torrisi
a565795452 bump rive to 2.29.0 2025-05-28 08:10:54 -07:00
HayesGordon
b26280ae12 chore: release 4.21.0 2025-05-23 16:44:06 +00:00
CI
a62e89de94 chore: bump rive wasm 2.28.0 2025-05-23 18:20:22 +02:00
HayesGordon
31255f9746 chore: release 4.20.2 2025-05-23 15:24:28 +00:00
CI
3e768533df chore: bump rive wasm 2.27.5 2025-05-22 14:42:31 +02:00
bodymovin
c790e66723 chore: release 4.20.1 2025-05-14 06:46:19 +00:00
Hernan Torrisi
ab89793032 rive canvas 2.27.3 2025-05-13 23:43:41 -07:00
damzobridge
2088c0bf9b chore: release 4.20.0 2025-05-12 22:51:11 +00:00
Adam
81fdf57736 chore: simplify useViewModelInstance 2025-05-12 14:16:00 -07:00
Adam
3a59585207 fix: implement useViewModel feedback 2025-05-12 14:16:00 -07:00
Adam
46e19874a2 feat: add db test 2025-05-12 14:16:00 -07:00
Lance
d4de776a01 Add onTrigger example 2025-05-12 14:16:00 -07:00
Lance
fb4f543077 Add stocks data binding example 2025-05-12 14:16:00 -07:00
Lance
345905f810 Merge storybook 2025-05-12 14:16:00 -07:00
Adam
0d9dabb135 fix: use default view model if none provide in useViewModelInstance and useViewModel 2025-05-12 14:16:00 -07:00
Adam
ad12fe20d1 fix: unify effects in useViewModelInstance 2025-05-12 14:16:00 -07:00
Adam
4e45f74a47 fix: change useViewModel property hook parameters to match conventions 2025-05-12 14:16:00 -07:00
Adam
efd6c4ce82 chore: simplify useViewModel 2025-05-12 14:16:00 -07:00
Adam
37e379091c fix: avoid rebuilding operations unless necessary 2025-05-12 14:16:00 -07:00
Adam
6d76e9f85d fix: hot reload crash 2025-05-12 14:16:00 -07:00
Adam
e7b64201ca chore: update UseViewModelParameters documentation 2025-05-12 14:16:00 -07:00
Adam
5dc8362107 fix: remove viewmodel hooks from initial release 2025-05-12 14:16:00 -07:00
Adam
56bc96fa76 chore: update color setter methods to be more explicit 2025-05-12 14:16:00 -07:00
Adam
01ab78db97 fix: lint issue 2025-05-12 14:16:00 -07:00
Adam
7800cc041f feat: add instance property hooks 2025-05-12 14:16:00 -07:00
Hernan Torrisi
1f9fc84629 hook with generic 2025-05-12 14:16:00 -07:00
Hernan Torrisi
452eb89e72 inital work for data binding hooks 2025-05-12 14:16:00 -07:00
Lance
3109e45724 Remove GH Action that published Stories to GH Pages 2025-05-12 11:38:30 -06:00
avivian
d303e8c96f chore: release 4.19.1 2025-05-08 11:24:05 +00:00
Arthur Vivian
479d5340e8 chore: rive-wasm -> 2.27.2 2025-05-08 12:20:01 +01:00
lancesnider
ff3976d9fe chore: release 4.19.0 2025-04-29 21:20:41 +00:00
Lance
f2a6860292 Fix failing tests 2025-04-29 15:15:57 -06:00
Lance
8213c6ed7e Upgrade testing 2025-04-29 15:15:57 -06:00
Lance
a9a98fece2 Upgrade React and React DOM 2025-04-29 15:15:57 -06:00
Lance
4052b7492b Update contributing docs 2025-04-29 15:15:57 -06:00
Lance
8bb6f1dc58 Add storybook linter 2025-04-29 15:15:57 -06:00
Lance
6d6b68e868 Call storybook from parent 2025-04-29 15:15:57 -06:00
Lance
d3305f8afe General cleanup 2025-04-29 15:15:57 -06:00
Lance
9eb292c2c5 Remove unnecessary react app stuff 2025-04-29 15:15:57 -06:00
Lance
7277ed2f0d Storybookk page reloads when the package in the parent changes 2025-04-29 15:15:57 -06:00
Lance
5354d1f69b Add examples 2025-04-29 15:15:57 -06:00
Lance
86e67d5f11 Remove old storybook and auto docs 2025-04-29 15:15:57 -06:00
philter
e5c751aa54 chore: release 4.18.9 2025-04-23 19:30:29 +00:00
Phil Chung
60b1dda98d chore: bump rive web to 2.27.1 2025-04-23 13:20:21 -06:00
bodymovin
4914770c70 chore: release 4.18.8 2025-04-16 23:37:08 +00:00
Hernan Torrisi
21e457bda4 rive canvas 2.27.0 2025-04-16 16:30:10 -07:00
susan101566
cc0e91689b chore: release 4.18.7 2025-04-09 18:16:01 +00:00
Susan Wang
8244982000 update to 2.26.8 2025-04-09 12:09:58 -06:00
HayesGordon
439b413782 chore: release 4.18.6 2025-04-03 13:02:07 +00:00
CI
9ab4e378fc chore: bump rive web to 2.26.7 2025-04-03 14:58:32 +02:00
bodymovin
9061a93978 chore: release 4.18.5 2025-03-28 05:48:05 +00:00
Hernan Torrisi
88d1bc000c update to 2.26.6 2025-03-27 22:43:52 -07:00
bodymovin
9b1d3825f8 chore: release 4.18.4 2025-03-24 17:11:49 +00:00
Hernan Torrisi
277f4d7db0 update rive canvas to 2.26.5 2025-03-24 10:01:16 -07:00
bodymovin
e68ca963a9 chore: release 4.18.3 2025-02-28 01:37:00 +00:00
Hernan Torrisi
d820cdf6f1 update rive to 2.26.4 2025-02-27 17:31:48 -08:00
HayesGordon
c9a4dc0b5c chore: release 4.18.2 2025-02-17 11:19:33 +00:00
CI
19b58f5eb6 chore: update rive to 2.26.3 2025-02-17 12:14:25 +01:00
bodymovin
6263449898 chore: release 4.18.1 2025-02-15 01:07:50 +00:00
Hernan Torrisi
630f70a81d update rive to 2.26.2 2025-02-14 17:02:23 -08:00
bodymovin
bbd0d08fed chore: release 4.18.0 2025-02-11 20:20:14 +00:00
Hernan Torrisi
ef23793d26 update rive to 2.26.1 2025-02-11 11:49:47 -08:00
Hernan Torrisi
ca10584ed4 cleanup instance if use effect reruns and instance is not loaded 2025-02-04 07:43:18 -08:00
damzobridge
6fe765df84 chore: release 4.17.10 2025-01-27 23:34:24 +00:00
Chukwuma Okere
c62b80af09 chore: add React 19 support to package.json 2025-01-27 14:47:04 -08:00
bodymovin
777337c481 chore: release 4.17.9 2025-01-27 16:22:26 +00:00
Hernan Torrisi
da4b5978e7 update rive to 2.25.7 2025-01-27 08:17:38 -08:00
bodymovin
09c0d1f947 chore: release 4.17.8 2025-01-24 21:08:47 +00:00
Hernan Torrisi
0ca5933c41 update rive to 2.25.6 2025-01-24 13:03:56 -08:00
bodymovin
f272fd92f0 chore: release 4.17.7 2025-01-23 23:46:21 +00:00
CI
192a562764 chore: bump wasm to 2.25.5 2025-01-23 20:43:34 +02:00
bodymovin
224a768737 chore: release 4.17.6 2025-01-14 14:58:56 +00:00
Hernan Torrisi
c085bd5ea3 update rive to 2.25.4 2025-01-13 19:38:53 -08:00
bodymovin
bb13c71982 chore: release 4.17.5 2024-12-24 18:55:30 +00:00
Hernan Torrisi
779e06583c bump rive canvas to 2.25.3 2024-12-24 10:47:44 -08:00
bodymovin
e172e0f210 chore: release 4.17.4 2024-12-17 19:51:56 +00:00
Hernan Torrisi
abbcf14b70 rive canvas 2.25.2 2024-12-17 11:42:28 -08:00
bodymovin
a0885648ce chore: release 4.17.3 2024-12-13 04:18:27 +00:00
Hernan Torrisi
9f768bdd0c rive canvas 2.25.1 2024-12-12 20:09:59 -08:00
bodymovin
94c9a2a60b chore: release 4.17.2 2024-12-11 18:55:36 +00:00
Hernan Torrisi
dfe0d10936 rive canvas 2.25.0 2024-12-11 10:50:36 -08:00
bodymovin
d27eb7254d chore: release 4.17.1 2024-12-11 02:31:56 +00:00
Hernan Torrisi
c0b27bd018 rive canvas 2.24.1 2024-12-10 18:27:53 -08:00
bodymovin
739ac7c370 chore: release 4.17.0 2024-12-10 03:45:43 +00:00
Hernan Torrisi
b1b8040b4f bump rive canvas to 2.24.0 2024-12-09 19:40:57 -08:00
bodymovin
1f6ae83de3 chore: release 4.16.7 2024-11-27 23:26:32 +00:00
Hernan Torrisi
e5ff233c34 bump rive canvas to 2.23.11 2024-11-27 15:16:09 -08:00
lancesnider
64795564d8 chore: release 4.16.6 2024-11-22 16:22:19 +00:00
Lance
f0b32056a4 Bump rive canvas to 2.23.10 2024-11-22 08:12:52 -08:00
bodymovin
b5dc2fa8da chore: release 4.16.5 2024-11-21 15:08:14 +00:00
Hernan Torrisi
0108d425dd update rive canvas version 2024-11-21 07:04:03 -08:00
bodymovin
74a27143b4 chore: release 4.16.4 2024-11-15 20:29:44 +00:00
Hernan Torrisi
2cfb8a4955 bump rive canvas to 2.23.8 2024-11-15 11:53:45 -08:00
bodymovin
af6c3f84c6 chore: release 4.16.3 2024-11-14 17:10:05 +00:00
Hernan Torrisi
351d9966b1 bump rive canvas to 2.23.7 2024-11-14 09:01:19 -08:00
Hernan Torrisi
ba73cb7053 update react to 2.23.6 2024-11-13 10:01:41 -08:00
bodymovin
4a4f8a7151 chore: release 4.16.2 2024-11-12 18:32:33 +00:00
Hernan Torrisi
b5baef5ce7 updated rive canvas 2024-11-12 10:28:46 -08:00
bodymovin
79f80d39cd chore: release 4.16.1 2024-11-05 03:30:22 +00:00
Hernan Torrisi
e1ed8250e3 bump to canvas 2.23.4 2024-11-04 19:26:09 -08:00
HayesGordon
a40ba0dacc chore: release 4.16.0 2024-11-01 20:05:31 +00:00
CI
7ea9c8fbcb chore: bump again to make type check happy 2024-11-01 21:02:28 +01:00
CI
d4cef9a131 chore: bump js runtime again 2024-11-01 21:02:28 +01:00
CI
99489af287 chore: bump js and use public setters 2024-11-01 21:02:28 +01:00
CI
d881bb18c8 chore: bump to canvas 2.23.0 2024-11-01 21:02:28 +01:00
HayesGordon
2e461c66b3 chore: release 4.15.2 2024-10-30 21:24:23 +00:00
CI
bb078296d0 fix: account for scale factor in layout resizing 2024-10-30 22:20:53 +01:00
HayesGordon
f9bad8b62d chore: release 4.15.1 2024-10-30 21:01:51 +00:00
CI
e42f5e32d7 fix: only perform layout resizing if the Layout object exists 2024-10-30 21:58:08 +01:00
CI
83fa6635ec fix: additional layout configuration that react needs 2024-10-30 21:58:08 +01:00
HayesGordon
bdd4c84d8b chore: release 4.15.0 2024-10-30 17:27:37 +00:00
CI
414543d37d feat: responsive layouts! 2024-10-30 18:22:47 +01:00
bodymovin
119f7eea2a chore: release 4.14.6 2024-10-29 10:09:08 +00:00
Hernan Torrisi
92b0342882 rive canvas 2.21.7 2024-10-29 03:03:49 -07:00
bodymovin
38b0a1cc86 chore: release 4.14.5 2024-10-15 18:08:41 +00:00
Hernan Torrisi
2fd87e45e8 rive canvas 2.21.6 2024-10-15 11:00:46 -07:00
bodymovin
dc99fe27cc chore: release 4.14.4 2024-10-02 01:33:25 +00:00
Hernan Torrisi
2358c82626 update rive to 2.21.5 2024-10-01 18:29:22 -07:00
bodymovin
0475d47535 chore: release 4.14.3 2024-10-01 20:11:55 +00:00
Hernan Torrisi
f51e538479 update rive to 2.21.4 2024-10-01 12:38:55 -07:00
bodymovin
29fa6e76fb chore: release 4.14.2 2024-09-23 18:19:49 +00:00
Hernan Torrisi
2459c489bf bump rive canvas to 2.21.3 2024-09-23 11:07:00 -07:00
bodymovin
927dbc6b32 chore: release 4.14.1 2024-09-17 04:42:17 +00:00
Hernan Torrisi
8ebbfb164f bump rive canvas to 2.21.1 2024-09-16 21:38:59 -07:00
HayesGordon
388fd16b5b chore: release 4.14.0 2024-09-13 13:11:57 +00:00
Gordon Hayes
8c87bc0ab7 chore: bump rive canvas to 2.21.0 2024-09-13 14:56:12 +02:00
bodymovin
280b2ec4a4 chore: release 4.13.10 2024-09-12 10:28:35 +00:00
Hernan Torrisi
55a40c7d9f bump rive canvas to 2.20.2 2024-09-12 11:25:21 +01:00
bodymovin
d4e6243dbb chore: release 4.13.9 2024-09-10 13:40:20 +00:00
Hernan Torrisi
dc738d00a6 bump react canvas 2024-09-10 14:36:02 +01:00
Gordon Hayes
2ae22d6c30 docs: update links 2024-08-30 10:57:32 +02:00
bodymovin
4a3fc22261 chore: release 4.13.8 2024-08-21 19:46:57 +00:00
Hernan Torrisi
bdc734b90b update rive canvas 2024-08-21 14:40:37 -05:00
bodymovin
eeda717178 chore: release 4.13.7 2024-08-15 00:12:55 +00:00
Hernan Torrisi
178f04df61 update rive canvas to 2.19.8 2024-08-14 19:08:58 -05:00
bodymovin
ef11079784 chore: release 4.13.6 2024-08-09 17:54:12 +00:00
Hernan Torrisi
11f548b21c update rive canvas to 2.19.7 2024-08-09 12:44:25 -05:00
damzobridge
d0ff23c124 chore: release 4.13.5 2024-07-29 16:11:55 +00:00
Adam
a83f5a275a fix: add webgl2 package to dependencies 2024-07-25 14:00:47 -07:00
HayesGordon
b437230063 chore: release 4.13.4 2024-07-23 12:46:41 +00:00
Gordon Hayes
10912052f2 update rive version to 2.19.4 2024-07-23 13:11:36 +02:00
bodymovin
fe8265cd58 chore: release 4.13.3 2024-07-10 14:03:48 +00:00
Hernan Torrisi
5b458b76e5 update rive version to 2.19.3 2024-07-10 08:59:50 -05:00
bodymovin
1decbc7d85 chore: release 4.13.2 2024-07-05 23:51:13 +00:00
Hernan Torrisi
87627125f5 update rive version to 2.19.2 2024-07-05 18:31:00 -05:00
avivian
e823e9519f chore: release 4.13.1 2024-07-03 20:40:45 +00:00
Arthur Vivian
ac88187118 update rive version to 2.19.1 2024-07-03 21:35:30 +01:00
Adam
1897e823b9 fix: change initialization from play to load event 2024-07-02 10:16:07 -07:00
bodymovin
1a2e57a82c chore: release 4.13.0 2024-06-28 18:02:06 +00:00
Hernan Torrisi
0d16feeec1 update rive version to 2.19.0 2024-06-28 12:45:21 -05:00
damzobridge
ca48907649 chore: release 4.12.1 2024-06-25 23:06:05 +00:00
Adam
9b02c0f1bc fix: catch RiveFile initialization error in hook 2024-06-21 09:14:31 -07:00
HayesGordon
b25c775994 chore: release 4.12.0 2024-06-18 19:21:07 +00:00
Gordon Hayes
17811adac4 chore: bump rive web to 2.18.0 2024-06-18 21:15:11 +02:00
bodymovin
e4fcef529e chore: release 4.11.3 2024-06-08 03:56:42 +00:00
Hernan Torrisi
f51fe6ee2a update rive canvas to 2.17.3 2024-06-07 22:53:12 -05:00
bodymovin
0f558e66e1 chore: release 4.11.2 2024-06-07 01:10:59 +00:00
Hernan Torrisi
7a67fb14f7 bump rive 2024-06-06 20:06:49 -05:00
bodymovin
da3fc317ff chore: release 4.11.1 2024-06-06 18:08:51 +00:00
Hernan Torrisi
9b40a1a02e update rive version 2024-06-06 13:04:18 -05:00
Maxwell Talbot
aa92c01329 chore: release 4.11.0 2024-06-06 15:07:03 +01:00
Gordon Hayes
99a8a42a15 chore: bump web to v2.17.0 2024-06-06 10:24:12 +02:00
HayesGordon
f0ea7add89 chore: release 4.10.0 2024-05-28 08:45:14 +00:00
Hernan Torrisi
ac9f322ccb update comments 2024-05-27 20:19:23 -05:00
Hernan Torrisi
e1c2d108e9 add missing mocked methods 2024-05-27 20:19:23 -05:00
Hernan Torrisi
3aaee0bcf8 update canvas package version 2024-05-27 20:19:23 -05:00
Hernan Torrisi
e3739f1a1f request instance of rive file 2024-05-27 20:19:23 -05:00
Hernan Torrisi
0e0a2bd972 add status handling 2024-05-27 20:19:23 -05:00
Adam
5c47a411f2 test: update useRiveFile tests to check buffer changes 2024-05-27 20:19:23 -05:00
Adam
16dc257b2f feat: create useRiveFile hook 2024-05-27 20:19:23 -05:00
Hernan Torrisi
4678ea9ecf interpret undefined definition for shouldUseIntersectionObserver as true 2024-05-27 18:24:51 -05:00
Hernan Torrisi
d58963e29d edit hook description 2024-05-27 18:24:51 -05:00
Hernan Torrisi
c32433284a fix observer and use single instance 2024-05-27 18:24:51 -05:00
Hernan Torrisi
8bb5652df0 improve tests 2024-05-14 12:02:47 -05:00
Hernan Torrisi
9ecacf37fe fix tests 2024-05-14 12:02:47 -05:00
Hernan Torrisi
f837fbe0d4 WIP 2024-05-14 12:02:47 -05:00
Hernan Torrisi
8e181d6ae2 change hooks lifecycle to account for component reloading 2024-05-14 12:02:47 -05:00
mjtalbot
a3a41dca40 chore: release 4.9.5 2024-05-10 10:00:11 +00:00
Maxwell Talbot
b78c9715d7 bump canvas to 2.15.6 2024-05-10 10:51:08 +01:00
bodymovin
520e5bb51d chore: release 4.9.4 2024-05-09 00:49:46 +00:00
Hernan Torrisi
586ee4c002 bump version to 2.15.5 2024-05-08 19:46:15 -05:00
bodymovin
3d6c7ed499 chore: release 4.9.3 2024-05-08 17:09:41 +00:00
Hernan Torrisi
c3900b7845 bump version to 2.15.4 2024-05-08 12:05:23 -05:00
bodymovin
d369817113 chore: release 4.9.2 2024-04-30 20:06:06 +00:00
Hernan Torrisi
d68302ccb3 bump rive canvas to 2.15.2 2024-04-30 14:51:06 -05:00
bodymovin
bbd4cc7af6 chore: release 4.9.1 2024-04-30 16:46:29 +00:00
Hernan Torrisi
3936277f65 update to version 2.15.1 2024-04-30 11:37:50 -05:00
HayesGordon
aa2a783d1c chore: release 4.9.0 2024-04-24 14:04:19 +00:00
Gordon Hayes
d8d7d64749 chore: bump rive wasm to v2.15.0 2024-04-24 15:57:51 +02:00
mjtalbot
af3edad2c2 chore: release 4.8.10 2024-04-23 09:28:37 +00:00
Maxwell Talbot
5326f800f7 bump rive library dependencies to 2.14.4 2024-04-23 10:20:19 +01:00
mjtalbot
b44f9ad9e1 chore: release 4.8.9 2024-04-18 09:20:12 +00:00
Maxwell Talbot
b2495300b7 Bump rive js libraries to 2.14.3 2024-04-18 10:16:25 +01:00
mjtalbot
eb436263d7 chore: release 4.8.8 2024-04-17 16:24:43 +00:00
Maxwell Talbot
0e6385288e bump canvas and webgl to 2.14.2 2024-04-17 17:17:59 +01:00
bodymovin
78f75434fc chore: release 4.8.7 2024-04-11 19:04:48 +00:00
Hernan Torrisi
a9c2950419 bump react canvas to 2.14.1 2024-04-11 14:00:46 -05:00
avivian
e799f64554 chore: release 4.8.6 2024-04-09 08:54:46 +00:00
Arthur Vivian
95a1daa4ef Bump rive-canvas to 2.13.2 2024-04-09 09:51:08 +01:00
avivian
8a5b88c591 chore: release 4.8.5 2024-04-08 20:01:44 +00:00
Arthur Vivian
d3b29cf7d7 bump version to 2.13.0 2024-04-08 20:52:04 +01:00
bodymovin
611522b3e0 chore: release 4.8.4 2024-03-29 16:02:54 +00:00
Hernan Torrisi
89d35976d4 bump version to 2.12.0 2024-03-29 08:51:31 -07:00
Zach Plata
a7875b26a4 feat: add new webgl2 package for new Rive Renderer 2024-03-23 09:35:04 -06:00
Gordon
4653b8bea1 Update README.md 2024-03-12 09:00:09 +01:00
zplata
0d0688feb6 chore: release 4.8.3 2024-02-26 18:56:04 +00:00
Zach Plata
7a97c14c93 chore: bump rive-wasm to 2.10.3 for text bug fixes 2024-02-26 11:24:59 -06:00
zplata
cff787524d chore: release 4.8.2 2024-02-21 19:14:13 +00:00
Zach Plata
a34a588ee5 chore: bump rive-wasm to 2.10.2 for various dependency fixes 2024-02-21 12:50:24 -06:00
zplata
aa89f2a1ba chore: release 4.8.1 2024-02-09 17:21:53 +00:00
Zach Plata
39d275b3e0 chore: bump rive-wasm to 2.10.1 for text fix at c++ level 2024-02-09 11:12:10 -06:00
zplata
e22acf98ba chore: release 4.8.0 2024-02-06 17:12:52 +00:00
Zach Plata
2e52e35ddc chore: bump rive-wasm dependency to 2.10.0 2024-02-06 09:57:27 -06:00
zplata
f67cb244d2 chore: release 4.7.1 2024-01-09 20:41:52 +00:00
Zach Plata
c2319b8dea feat: add customDevicePixelRatio param from WASM for adjusting canvas size based on dpr 2024-01-09 14:13:01 -06:00
zplata
877e43e354 chore: release 4.7.0 2023-12-21 15:02:57 +00:00
Zach Plata
6a033a99d3 chore: bump rive-wasm to 2.9.0 for iOS check when creating offscreen webgl in c2d renderer 2023-12-21 08:59:58 -06:00
zplata
88f7558ddf chore: release 4.6.2 2023-12-15 23:30:03 +00:00
Zach Plata
cfe3a298fb chore: bump rive-wasm to 2.8.3 to reintroduce cleaning up of image textures 2023-12-15 17:26:22 -06:00
zplata
8e24185f3f chore: release 4.6.1 2023-12-15 19:26:43 +00:00
Zach Plata
5fad06d4bd chore: bump rive-wasm to 2.8.2 for additional proxy gl checks before rendering an image/mesh 2023-12-15 13:14:30 -06:00
zplata
df14bc383b chore: release 4.6.0 2023-12-15 04:33:10 +00:00
Zach Plata
b8dc1e5371 add webgl to 2.8.0 too 2023-12-14 22:27:17 -06:00
Zach Plata
1196dd4c4e chore: bump rive-wasm to 2.8.0 for GL as a proxy solution to checking lost context 2023-12-14 22:27:17 -06:00
zplata
06ceb3cdb0 chore: release 4.5.8 2023-12-15 02:07:25 +00:00
Zach Plata
acaa12f7fc revert wasm build to 2.7.7 for testing intermediate changes before 2.7.8 2023-12-14 20:03:07 -06:00
zplata
0acf384570 chore: release 4.5.7 2023-12-14 23:03:30 +00:00
Zach Plata
97a29acfdc chore: bump rive-wasm to 2.7.8 for texture deletion check 2023-12-14 17:00:15 -06:00
zplata
5eb5ccfdaa chore: release 4.5.6 2023-11-30 19:49:55 +00:00
Zach Plata
edcc2c1320 bump rive-wasm to 2.7.6 2023-11-30 13:47:04 -06:00
zplata
68d8ca44fa chore: release 4.5.5 2023-11-29 22:04:22 +00:00
Zach Plata
ee9b83d764 patch: bump wasm to 2.7.5 2023-11-29 16:01:24 -06:00
zplata
187066c2cb chore: release 4.5.4 2023-11-21 18:10:53 +00:00
Zach Plata
427d74d14f chore: bump rive-wasm to 2.7.4 for bone fixes 2023-11-21 12:07:37 -06:00
zplata
061377432e chore: release 4.5.3 2023-11-09 21:32:54 +00:00
Zach Plata
53d7548b15 patch: bump rive-wasm to 2.7.3 2023-11-09 15:29:14 -06:00
zplata
e1a4ca0058 chore: release 4.5.2 2023-11-08 21:18:12 +00:00
Zach Plata
83ebd6776d Tweak copy 2023-11-08 14:58:32 -06:00
Zach Plata
75dac6fe64 Add a react-canvas-lite package to build setup 2023-11-08 14:58:32 -06:00
zplata
e13c023933 chore: release 4.5.1 2023-11-08 19:43:58 +00:00
Zach Plata
95183ff8d5 Bump WASM dependency to 2.7.2 for nested input patch 2023-11-08 13:28:41 -06:00
HayesGordon
64416e0b4d chore: release 4.5.0 2023-10-26 11:15:57 +00:00
Gordon Hayes
1c6837bf92 chore: bump react to 4.5.0 2023-10-26 13:11:08 +02:00
bodymovin
15330ababe chore: release 4.4.0 2023-10-06 17:43:33 +00:00
Hernan Torrisi
af70b8150d bump rive-app versions to 2.5.0 2023-10-06 12:36:17 -04:00
zplata
a984e007f4 chore: release 4.3.4 2023-10-03 20:13:02 +00:00
Zach Plata
04d8e01f87 patch: bump rive-wasm to 2.4.4 2023-10-03 15:09:07 -05:00
zplata
44e46c5dee chore: release 4.3.3 2023-09-20 21:31:49 +00:00
Zach Plata
323e92e636 chore: bump wasm to 2.4.3 for url sanitization 2023-09-20 16:24:18 -05:00
zplata
a07fa02ed6 chore: release 4.3.2 2023-09-19 16:30:17 +00:00
Zach Plata
d710e1e4b2 chore: bump rive-wasm to 2.4.2 2023-09-19 11:25:50 -05:00
zplata
d35e9b2805 chore: release 4.3.1 2023-09-18 20:12:57 +00:00
Zach Plata
cf44463805 chore: bump rive-wasm to 2.4.1 for event updates 2023-09-18 15:05:39 -05:00
zplata
f59f44692a chore: release 4.3.0 2023-09-13 17:19:22 +00:00
Zach Plata
6ba68fab9e feature: Bump WASM dependency to support Rive Events 2023-09-13 09:49:44 -05:00
zplata
982addf163 chore: release 4.2.1 2023-09-07 01:35:06 +00:00
Zach Plata
dfd89c7691 chore: bump rive-wasm to 2.3.1 for mesh fix 2023-09-06 20:31:28 -05:00
luigi-rosso
0247a46c47 chore: release 4.2.0 2023-09-01 23:49:12 +00:00
Luigi Rosso
44626c7450 Updating rive wasm 2023-09-01 16:44:54 -07:00
zplata
c0eb7d689d chore: release 4.1.6 2023-08-26 02:09:57 +00:00
Zach Plata
ff7a6aa676 chore: bump rive-wasm for follow up solo fix 2023-08-25 21:06:07 -05:00
zplata
dc89439d84 chore: release 4.1.5 2023-08-25 18:27:52 +00:00
Zach Plata
7ebc10a4da chore: bump rive-wasm for follow path constraints on solos 2023-08-25 13:23:56 -05:00
zplata
e8e1a5bc08 chore: release 4.1.4 2023-08-14 14:23:58 +00:00
Zach Plata
1bb8885f22 chore: bump rive-wasm to 2.1.5 for follow path fix 2023-08-14 09:19:08 -05:00
zplata
00d13badcf chore: release 4.1.3 2023-08-10 22:48:49 +00:00
Zach Plata
b9ab7b83d2 chore: bump wasm to 2.1.3 2023-08-10 17:44:56 -05:00
zplata
e0f00174c8 chore: release 4.1.2 2023-08-05 16:29:45 +00:00
Zach Plata
200a86a6ba chore: bump rive-wasm to 2.1.2 2023-08-05 11:24:49 -05:00
zplata
26622596c8 chore: release 4.1.1 2023-08-03 13:44:49 +00:00
Zach Plata
ac789f0855 patch: bump rive-wasm to 2.1.1 2023-08-03 08:38:41 -05:00
zplata
6ecdc05aea chore: release 4.1.0 2023-07-31 19:07:05 +00:00
Slava Khanilo
f8aa50fa49 feature: expose RiveProps type from package 2023-07-31 13:52:14 -05:00
Zach Plata
b59bfdef84 feature: Add ability to get and set text via wasm runtime bump 2023-07-31 13:50:59 -05:00
luigi-rosso
948ded25f7 chore: release 4.0.0 2023-07-26 01:33:54 +00:00
Luigi Rosso
27f7f2b250 Bump to rive wasm 2.0.0 2023-07-25 18:29:22 -07:00
zplata
184ba2e110 chore: release 3.0.57 2023-07-25 20:18:00 +00:00
Zach Plata
f6d8db323b chore: remove dryrun from release it script 2023-07-25 15:11:10 -05:00
Gordon
301e58f390 docs: add awesome-rive 2023-07-25 14:57:42 -05:00
Zach Plata
4cce3067a7 chore: move to manual npm publish workflow 2023-07-25 14:52:52 -05:00
zplata
4496eff598 chore: release 3.0.56 2023-07-24 13:01:14 +00:00
Zach Plata
5e98586354 patch: bump rive-wasm for follow-path patch 2023-07-24 07:58:05 -05:00
zplata
f19295f9a5 chore: release 3.0.55 2023-07-19 14:04:30 +00:00
Zach Plata
70546308b4 feature: add onAdvance callback through wasm bump too 1.2.2 2023-07-19 09:01:24 -05:00
zplata
62a425f30e chore: release 3.0.54 2023-06-26 20:26:51 +00:00
Zach Plata
4a554dd1ad patch: Bump WASM runtimes for interpolation on states 2023-06-26 15:23:29 -05:00
zplata
3e6262f21f chore: release 3.0.53 2023-06-09 15:12:24 +00:00
Zach Plata
e57a99b2d1 Bump wasm to 1.2.0 2023-06-09 10:09:09 -05:00
zplata
8a968ec266 chore: release 3.0.52 2023-06-07 19:44:53 +00:00
Zach Plata
b5f00e5c97 fix: bump WASM to fix iterator over animatables 2023-06-07 14:41:46 -05:00
zplata
22e6dd3494 chore: release 3.0.51 2023-06-02 18:56:31 +00:00
Zach Plata
08b9f9a2aa Also export the container ref current element 2023-06-02 13:53:30 -05:00
Zach Plata
a24b910096 Update prop docs 2023-06-02 13:53:30 -05:00
Zach Plata
33760042d1 fix recursive useEffect call 2023-06-02 13:53:30 -05:00
Zach Plata
2c82fa04e7 Feature: Move canvas sizing logic into useResizeCanvas hook and clean up util hooks 2023-06-02 13:53:30 -05:00
zplata
2b249494d5 chore: release 3.0.50 2023-05-26 19:26:23 +00:00
Zach Plata
b56c17d48c feat: allow for children to be set inside the canvas for fallback content when canvas cannot be shown 2023-05-26 14:22:47 -05:00
zplata
a6fe08ced9 chore: release 3.0.49 2023-05-24 19:36:23 +00:00
Zach Plata
cd1e1410f4 add joystick support 2023-05-24 14:33:00 -05:00
zplata
353fbf8e9d chore: release 3.0.48 2023-05-18 21:37:38 +00:00
Zach Plata
ae05ad4375 feature: bump web runtime to support joysticks 2023-05-18 16:34:36 -05:00
zplata
ff8bbb084c chore: release 3.0.47 2023-05-12 21:16:59 +00:00
Zach Plata
89a6802fa0 patch: bump wasm to 1.1.6 for flicker fix 2023-05-12 16:14:04 -05:00
zplata
91025e6772 chore: release 3.0.46 2023-05-02 18:30:36 +00:00
Zach Plata
d3bc913bcf Add prop to the standalone Rive component 2023-05-02 13:27:38 -05:00
Zach Plata
ce56321e1d patch: bump rive-wasm to allow new parameter for disabling Rive listeners 2023-05-02 13:27:38 -05:00
caudetgit
4b6f5410fd chore: release 3.0.45 2023-04-19 20:21:31 +00:00
Chad Audet
6544874d3d Update add_to_project.yml
apply "triage" label, too
2023-04-19 13:18:24 -07:00
caudetgit
ed90c7f7c9 chore: release 3.0.44 2023-04-19 20:10:23 +00:00
Chad Audet
e06fdd1c8b Create add_to_project.yml
workflow that adds each new issue to the Runtime Issue Board
2023-04-19 13:07:28 -07:00
zplata
b8ffb6b53c chore: release 3.0.43 2023-04-14 15:52:47 +00:00
Zach Plata
2dc925ef70 patch: bump rive-wasm to take path fix 2023-04-14 10:49:40 -05:00
zplata
639de79c9e chore: release 3.0.42 2023-04-13 02:19:19 +00:00
Zach Plata
a9961c821a chore: bump rive-wasm to get solo patch 2023-04-12 21:16:29 -05:00
zplata
fc082d1a03 chore: release 3.0.41 2023-04-06 21:50:50 +00:00
Zach Plata
87fa1ae2a5 patch: bump wasm dependency for blend state enhancements 2023-04-06 16:48:11 -05:00
zplata
62490a50f9 chore: release 3.0.40 2023-04-05 20:47:45 +00:00
Zach Plata
fcc1a16df4 feature: Add support for touch and drag interactions on canvas 2023-04-05 15:44:36 -05:00
zplata
29e0ceb797 chore: release 3.0.39 2023-03-30 18:08:35 +00:00
Zach Plata
3e6a951ca1 fix: bump wasm dependency for clipping issue fix 2023-03-30 13:05:41 -05:00
zplata
04910f78f1 chore: release 3.0.38 2023-03-03 20:43:32 +00:00
Zach Plata
c2977c705c maint: bump wasm dependency for more speed on state updates 2023-03-03 14:40:24 -06:00
zplata
4e2137422b chore: release 3.0.37 2023-03-01 15:54:14 +00:00
Zach Plata
0696417926 maint: bump wasm dependency for more speed on state updates 2023-03-01 09:51:04 -06:00
zplata
f11a433365 chore: release 3.0.36 2023-02-22 19:03:57 +00:00
Zach Plata
48a4726d1f maint: bump wasm to support speed on states feature 2023-02-22 13:01:16 -06:00
Dillon Pentz
c927f24b5a Fix link to blog article 2023-01-18 14:44:57 -06:00
elVengador
3cbbf99fec Fix: matchMedia add event listener for safari 13 and older versions 2023-01-18 10:12:34 -06:00
zplata
03f05f57b7 chore: release 3.0.35 2023-01-17 20:15:23 +00:00
Zach Plata
8b483b807b fix: update rive-wasm to try patching slow burn memory leak 2023-01-17 14:12:39 -06:00
luigi-rosso
816fcfcdbc chore: release 3.0.34 2022-12-16 19:29:15 +00:00
Luigi Rosso
6c28a8795e Bumping rive-app/canvas & webgl versions. 2022-12-16 11:25:51 -08:00
zplata
6a57630ae6 chore: release 3.0.33 2022-11-08 20:15:00 +00:00
Zach Plata
acba24c4ed maint: bump wasm runtime and replace old skills rive file example 2022-11-08 14:10:33 -06:00
luigi-rosso
1e6eb5ec92 chore: release 3.0.32 2022-10-21 20:38:27 +00:00
Luigi Rosso
6871a81ebd Bumping to latest Rive WASM to fix https://2dimensions.slack.com/archives/CLLCU09T6/p1666370141425879 2022-10-21 13:35:28 -07:00
mjtalbot
33053b3b7f chore: release 3.0.31 2022-10-21 13:20:16 +00:00
Maxwell Talbot
4040083d5a bump runtimes to incorporate speed fix for state machines 2022-10-21 14:17:25 +01:00
avivian
2153b81e6b chore: release 3.0.30 2022-10-20 18:34:05 +00:00
Arthur Vivian
6b1500e681 Bump dependencies to fix call to runtime cleanup 2022-10-20 19:31:16 +01:00
avivian
503702cf1f chore: release 3.0.29 2022-10-20 17:06:43 +00:00
Arthur Vivian
7be20b0a87 Call cleanup on unmount 2022-10-20 18:03:30 +01:00
avivian
78491f5819 chore: release 3.0.28 2022-10-20 09:44:48 +00:00
Arthur Vivian
39edb88a19 Bump canvas and webgl dependencies to fix alignment memory leaks 2022-10-20 10:42:06 +01:00
zplata
fd1a1653b1 chore: release 3.0.27 2022-10-04 17:56:49 +00:00
Zach Plata
8d7f0ab28c Fix: Bump wasm to accomodate clipping bug on nested artboards 2022-10-04 12:53:17 -05:00
zplata
2a2e532564 chore: release 3.0.26 2022-09-22 17:15:22 +00:00
Zach Plata
2b1aa01a87 fix: Adjust canvas size if devicePixelRatio changes for any reaason 2022-09-22 12:12:32 -05:00
zplata
06c4e2aea3 chore: release 3.0.25 2022-09-21 14:23:55 +00:00
Zach Plata
819bd51ea9 patch: bump js runtime dependency to address content security policy issue in WASM build 2022-09-21 09:20:55 -05:00
zplata
6b7f113296 chore: release 3.0.24 2022-09-15 15:56:54 +00:00
Zach Plata
a62e9b3a9a add tests 2022-09-15 10:53:36 -05:00
Zach Plata
04685c0bcd fix: make a canvas of size 0 until we calculate the bounds appropriately 2022-09-15 10:53:36 -05:00
avivian
48fd9f9d80 chore: release 3.0.23 2022-08-31 10:27:17 +00:00
Arthur Vivian
3c578b730f Bump runtime version to fix broken version 2022-08-31 11:24:05 +01:00
avivian
7a46886133 chore: release 3.0.22 2022-08-30 17:09:24 +00:00
Arthur Vivian
092049d20f Update @rive-app/canvas and @rive-app/webgl dependencies to support non node builds 2022-08-30 18:06:18 +01:00
mjtalbot
f7aced03cd chore: release 3.0.21 2022-07-22 13:34:00 +00:00
Maxwell Talbot
eb07281415 rev rive-wasm dependencies & update render delay to be 0ms 2022-07-22 14:30:04 +01:00
mjtalbot
156b3bdfb5 chore: release 3.0.20 2022-07-22 12:56:26 +00:00
Maxwell Talbot
24d8e0a907 update tests 2022-07-22 13:52:42 +01:00
Maxwell Talbot
a1a155849a use window.settimeout and clear out some consts 2022-07-22 13:52:42 +01:00
Maxwell Talbot
59e67cec3d update name 2022-07-22 13:52:42 +01:00
Maxwell Talbot
84b18cc3dd ensure we re evaluate state machine inputs when we play is triggered, looks like there maybe additional situations where we are going to need this. 2022-07-22 13:52:42 +01:00
Maxwell Talbot
1092b44947 update resize behaviour to throttle, add parameters to enable switching modes 2022-07-22 13:52:42 +01:00
zplata
efe28aa5f3 chore: release 3.0.19 2022-07-19 23:48:34 +00:00
Zach Plata
16d836c959 fix tests that were automatically calling the rive load callback to be more controlled 2022-07-19 18:44:20 -05:00
Zach Plata
838ed1abf8 Fix: Add check before setting Rive as state variable on Rive instance load 2022-07-19 18:44:20 -05:00
mjtalbot
d010a55cc0 chore: release 3.0.18 2022-07-14 12:26:10 +00:00
Maxwell Talbot
fd1c00a995 update canvas dimensions to use clientWidth and Height as opposed to BoundingClient, to avoid getting scaled information 2022-07-14 13:22:12 +01:00
mjtalbot
45aec2db1c chore: release 3.0.17 2022-07-14 10:28:50 +00:00
Maxwell Talbot
62b3a1d8dc removed polyfill in favour of DIY appraoch to reduce package size 2022-07-14 11:24:55 +01:00
Maxwell Talbot
5be9d2f874 refactored the IE check into useSize 2022-07-14 11:24:55 +01:00
Maxwell Talbot
49a6b1de11 added additional linting 2022-07-14 11:24:55 +01:00
Zach Plata
ec61a6835d Fix useEffects so they're not in conditional statements 2022-07-14 11:24:55 +01:00
Zach Plata
ac29fa30a7 strip out storybook deploy workflow 2022-07-14 11:24:55 +01:00
Maxwell Talbot
e966316971 add resizeObserver to replace window listeners for all but IE 2022-07-14 11:24:55 +01:00
zplata
ae6efc14d4 chore: release 3.0.16 2022-07-12 20:54:19 +00:00
Zach Plata
8ce77f153c Adding more examples 2022-07-12 15:49:58 -05:00
Zach Plata
08638359bb Docs: Condense down README and add CONTRIBUTING guide 2022-07-12 15:49:58 -05:00
Zach Plata
7dbade4589 staged work 2022-07-12 15:49:58 -05:00
zplata
8175c4a4d4 chore: release 3.0.15 2022-06-28 14:41:23 +00:00
Zach Plata
795ee53340 Patch: Bump js runtime dependencies for nested artboard display patch 2022-06-28 09:37:52 -05:00
zplata
04353db432 chore: release 3.0.14 2022-06-28 01:26:01 +00:00
Zach Plata
1f0e511f6e Fix: Bump version because of race condition again 2022-06-27 20:22:16 -05:00
zplata
7aee5cfab4 Deploying to main from @ 3477afdef1 🚀 2022-06-27 23:51:09 +00:00
Zach Plata
3477afdef1 Fix: Intake JS runtime patches for starting animation frames 2022-06-27 18:48:51 -05:00
zplata
8b43a82c5f chore: release 3.0.12 2022-06-22 21:31:48 +00:00
Zach Plata
bd49e6a4ee Fix: Bump cpp to get nested artboard opacity fix and fill rule patch 2022-06-22 16:27:46 -05:00
Chris Dalton
1dbb9cd38d Bump @rive-app/canvas to take the fillRule bug fix
https://github.com/rive-app/rive/issues/3816
2022-06-22 13:37:27 -06:00
zplata
aee7407f79 chore: release 3.0.11 2022-06-22 17:01:51 +00:00
Zach Plata
b48de9db84 Docs: Code snippets update to use new React package structure 2022-06-22 11:58:30 -05:00
avivian
6772f166b7 chore: release 3.0.10 2022-06-20 10:13:49 +00:00
Arthur Vivian
3a0a959383 Maint: fix package version number to allow release 2022-06-20 11:09:52 +01:00
Arthur Vivian
314d7c19cc Maint: roll canvas and webgl dependencies to include updates for rounded corners 2022-06-20 10:54:41 +01:00
zplata
802648eda8 Deploying to main from @ 5ad5a957a6 🚀 2022-06-09 18:00:14 +00:00
Zach Plata
5ad5a957a6 Maint: Update docs for storybook link 2022-06-09 12:57:34 -05:00
zplata
414d6f895a chore: release 3.0.8 2022-06-09 16:00:03 +00:00
Zach Plata
38625a00c3 Maint: Add GH workflow for deploying storybook to Github Pages 2022-06-09 10:55:55 -05:00
zplata
bad688dfa3 chore: release 3.0.7 2022-06-08 14:51:07 +00:00
Zach Plata
ec230faa73 Feat: Move existing examples into Storybook and add documentation 2022-06-08 09:47:41 -05:00
zplata
90c6d1edb1 chore: release 3.0.6 2022-06-06 21:37:22 +00:00
Zach Plata
0480dc92c8 Maint: Roll canvas and webgl dependencies forward to support nested state machines 2022-06-06 16:35:08 -05:00
zplata
de24fa5641 chore: release 3.0.5 2022-05-26 19:54:00 +00:00
Zach Plata
1a49e89c33 Fix: A recent Bunchee patch version kind of breaks npm run build 2022-05-26 14:51:28 -05:00
Zach Plata
805afd5dff Maint: Bump wasm for another listener patch 2022-05-26 11:24:56 -05:00
Zach Plata
84d9730767 Feat: Add stateMachines param to the default Rive component 2022-05-25 10:27:13 -05:00
zplata
9abee34d12 chore: release 3.0.4 2022-05-23 21:24:05 +00:00
Zach Plata
12801b10cc Maint: Bump rive-wasm dependency for listener patches 2022-05-23 16:21:58 -05:00
zplata
da11387558 chore: release 3.0.3 2022-05-17 15:23:15 +00:00
Zach Plata
3902948a2e Feat: Bump wasm and add examples to support touch feature 2022-05-17 10:20:56 -05:00
zplata
21a17ed40e chore: release 3.0.2 2022-05-17 14:10:32 +00:00
Zach Plata
f0e70924ec Maint: Bump wasm dependencies 2022-05-17 09:08:25 -05:00
zplata
f4eccbe2ce chore: release 3.0.1 2022-04-26 19:25:32 +00:00
Zach Plata
83c81b49c5 Maint: Bump rive wasm to include fps counter API and take off major tag 2022-04-26 12:23:17 -07:00
avivian
5de40fad5b chore: release 3.0.0 2022-04-26 15:05:29 +00:00
Arthur Vivian
aab811b975 Fix animation playing with autoplay false when animation name passed 2022-04-26 16:03:06 +01:00
zplata
965507ac34 chore: release 2.0.0 2022-04-22 22:04:35 +00:00
Zach Plata
74b791ffa4 Fix: Authenticate registry before doing npm release dryrun 2022-04-22 15:02:27 -07:00
Zach Plata
2853851d52 Fix: Do npm install instead 2022-04-22 14:54:53 -07:00
Zach Plata
4f37bbdb76 fix up test 2022-04-22 14:48:17 -07:00
Zach Plata
39f1990eac Maint: Bump wasm dependencies and add major flags for the publish script 2022-04-22 14:48:17 -07:00
Zach Plata
bb7d3e4e6c Feat: Setup workflow to npm publish 2 new rive-react packages 2022-04-22 14:48:17 -07:00
Zach Plata
7f2bd76eb3 Fix up test 2022-04-22 14:48:17 -07:00
Zach Plata
5c0b9cd613 Breaking: Spread non-style props onto canvas element instead of containing div 2022-04-22 14:48:17 -07:00
Zach Plata
92dd811948 fix version compare function 2022-04-22 14:48:17 -07:00
Zach Plata
4429be44f2 Change rive-react-* references to be the shortened namespace-named convention 2022-04-22 14:48:17 -07:00
Zach Plata
9398e0d74e Update tests 2022-04-22 14:48:17 -07:00
Zach Plata
563dca3608 Move to using @rive-app/canvas as the backing renderer and update scripts accordingly. 2022-04-22 14:48:17 -07:00
Zach Plata
1da73aac05 Only run the publish job on PR merges to main 2022-04-22 14:48:17 -07:00
Zach Plata
5c4336b84f Update: Adding build scripts to prepare for split of rive-react into 2 package derivatives for canvas and webgl 2022-04-22 14:48:17 -07:00
zplata
6e72ed5271 chore: release 1.0.7 2022-04-20 15:28:24 +00:00
Zach Plata
464fa97c20 Maint: Allow peer dep React to use v18.0+ 2022-04-20 08:27:04 -07:00
zplata
ac01b7ec69 chore: release 1.0.6 2022-04-14 17:00:16 +00:00
Zach Plata
cd9baef250 Maint: Bump webgl dependency up to 1.0.39 2022-04-14 09:58:59 -07:00
zplata
3a2ed32856 chore: release 1.0.5 2022-04-11 17:04:44 +00:00
Zach Plata
d35f5b53c5 update readme 2022-04-11 10:03:36 -07:00
Zach Plata
73b57d0b81 Update readme 2022-04-11 10:03:36 -07:00
Zach Plata
0a18b522cc Feat: Add extra param to useStateMachineInput to set an initial value on the input when its loaded 2022-04-11 10:03:36 -07:00
avivian
5e34e13563 chore: release 1.0.4 2022-04-06 15:58:19 +00:00
Arthur Vivian
c3f138014d Add test for animations change on param update 2022-04-06 16:57:03 +01:00
Arthur Vivian
b13413ba8b Update animations on param change 2022-04-06 16:57:03 +01:00
zplata
881e38fe6a chore: release 1.0.3 2022-03-31 16:55:27 +00:00
Zach Plata
38c85624a7 Maint: Bump rive-cpp to help fix safari and performance issues 2022-03-31 09:54:16 -07:00
zplata
a9732e141e chore: release 1.0.2 2022-03-28 16:42:52 +00:00
Zach Plata
59edf6f67e Patch: Bump rive-cpp to fix DAG issue 2022-03-28 09:41:33 -07:00
zplata
4be496cc15 chore: release 1.0.1 2022-03-24 03:38:43 +00:00
Zach Plata
4c9de18b1c Chore: Bump webgl and remove major flag from release-it command 2022-03-23 20:37:35 -07:00
zplata
c688b9f17a chore: release 1.0.0 2022-03-23 20:13:43 +00:00
Zach Plata
fcfe3cf6cf bump webgl 2022-03-23 13:12:26 -07:00
Zach Plata
8ce856270f Put back the release steps in the publish workflow and add major flag temporarily 2022-03-23 13:12:26 -07:00
Zach Plata
1e1cabd057 Breaking: Switch from using the canvas renderer as default to the webgl renderer 2022-03-23 13:12:26 -07:00
avivian
0be3bc7e93 chore: release 0.0.31 2022-01-18 19:21:22 +00:00
Arthur Vivian
48af4b00ad Update @rive-app/canvas to 1.0.18 to fix playback lag when animations are left idle 2022-01-18 19:19:30 +00:00
avivian
fe44977e47 chore: release 0.0.30 2022-01-10 13:18:41 +00:00
Arthur Vivian
24d9e871d6 Update rive/canvas to with fixes for image clipping 2022-01-10 13:17:13 +00:00
avivian
8b8d6bc44b chore: release 0.0.29 2021-12-16 19:36:04 +00:00
Arthur Vivian
956b76d01c Add offscreencanvas types 2021-12-16 19:34:58 +00:00
Arthur Vivian
2517efaebd Bump rive-app/canvas to 1.0.8 2021-12-16 19:34:58 +00:00
avivian
019cadf5f2 chore: release 0.0.28 2021-12-16 15:16:59 +00:00
Arthur Vivian
e599b1a38c Use @rive-app/canvas directly to fix path issues in downstream libs 2021-12-16 15:15:36 +00:00
avivian
78d3118dcc chore: release 0.0.27 2021-12-16 14:31:01 +00:00
Arthur Vivian
536c8325f2 Fix lint error during build 2021-12-16 14:29:43 +00:00
Arthur Vivian
9e65654274 Update @types/jest 2021-12-16 12:59:11 +00:00
Arthur Vivian
75420d2f1d Remove lock file 2021-12-16 12:59:11 +00:00
Arthur Vivian
e6b036ee17 Use @rive-app/canvas as underlying repo 2021-12-16 12:59:11 +00:00
Arthur Vivian
bfbb8a59ee Update basic example to listen to changes in parent directory 2021-12-15 14:16:46 +00:00
132 changed files with 18635 additions and 19989 deletions

View File

@@ -3,7 +3,11 @@ module.exports = {
browser: true,
es2021: true,
},
extends: ['plugin:react/recommended', 'prettier'],
extends: [
'plugin:react/recommended',
'prettier',
'plugin:storybook/recommended',
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
@@ -12,11 +16,23 @@ module.exports = {
ecmaVersion: 12,
sourceType: 'module',
},
plugins: ['@typescript-eslint', 'prettier'],
plugins: ['@typescript-eslint', 'prettier', 'react-hooks'],
rules: {
'@typescript-eslint/no-unused-vars': 'error',
'prefer-const': ['warn', { destructuring: 'all' }],
'prefer-const': [
'warn',
{
destructuring: 'all',
},
],
'no-var': 'error',
eqeqeq: ['error', 'smart'],
'react-hooks/rules-of-hooks': 'error', // Checks rules of Hooks
'react-hooks/exhaustive-deps': 'off', // Checks effect dependencies
},
settings: {
react: {
version: 'detect',
},
},
};

26
.github/workflows/add_to_project.yml vendored Normal file
View File

@@ -0,0 +1,26 @@
name: Adds all new issues to project board
on:
issues:
types:
- opened
jobs:
add-to-project:
name: Add issue to project
runs-on: ubuntu-latest
steps:
- uses: actions/add-to-project@v0.5.0
with:
project-url: https://github.com/orgs/rive-app/projects/12/views/1
github-token: ${{ secrets.ADD_TO_PROJECT_ACTION }}
- uses: actions/github-script@v6
with:
script: |
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ["triage"]
})

View File

@@ -1,35 +1,52 @@
name: Publish to NPM
on:
pull_request:
types: [closed]
branches:
- main
workflow_dispatch:
inputs:
major:
description: 'Major'
type: boolean
default: false
minor:
description: 'Minor'
type: boolean
default: false
permissions:
id-token: write # Required for OIDC
contents: read
jobs:
merge_job:
publish_job:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v4
with:
node-version: '12.x'
fetch-depth: 0
token: ${{ secrets.PAT_GITHUB }}
- name: Setup Git config
run: |
git config --local user.email 'hello@rive.app'
git config --local user.name ${{ github.actor }}
- uses: actions/setup-node@v4
with:
node-version: '24'
registry-url: 'https://registry.npmjs.org'
- name: Upgrade npm for OIDC support
run: npm install -g npm@latest
- name: Install Modules
run: npm ci
run: npm install
- name: Run type check
run: npm run types:check
- name: Run Linter
run: npm run lint
- name: Run Tests
run: npm test
- name: Build
run: npm run build
- name: Git config
run: |
git config --local user.email 'hello@rive.app'
git config --local user.name ${{ github.actor }}
- name: Authenticate with registry
run: npm config set //registry.npmjs.org/:_authToken ${{ secrets.NPM_TOKEN }}
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.REPO_TOKEN }}
run: npm run release
- if: ${{ inputs.major == true }}
name: Major Release - Bump version number, update changelog, push and tag
run: npm run release:major
- if: ${{inputs.major == false && inputs.minor == true}}
name: Minor release - Bump version number, update changelog, push and tag
run: npm run release:minor
- if: ${{inputs.major == false && inputs.minor == false}}
name: Patch release - Bump version number, update changelog, push and tag
run: npm run release:patch

View File

@@ -7,7 +7,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v2
- name: Install Modules
run: npm ci
run: npm install
- name: Run type check
run: npm run types:check
- name: Run Linter

1
.gitignore vendored
View File

@@ -5,3 +5,4 @@ dist
.idea
.vscode
examples/**/package-lock.json
package-lock.json

View File

@@ -1,17 +1,25 @@
{
"git": {
"addUntrackedFiles": true,
"requireCleanWorkingDir": false,
"commitMessage": "chore: release ${version}",
"tagName": "v${version}",
"changelog": "npx auto-changelog --stdout --commit-limit false --unreleased --template https://raw.githubusercontent.com/release-it/release-it/master/templates/changelog-compact.hbs"
},
"npm": {
"publish": true
"publish": false
},
"github": {
"release": true,
"releaseName": "${version}"
},
"hooks": {
"after:bump": ["npx auto-changelog -p", "git add ./CHANGELOG.md"]
"after:version:bump": [
"npm run build",
"npm run setup-builds",
"npm run setup-packages",
"npx auto-changelog -p",
"npm run publish:all"
]
}
}

View File

File diff suppressed because it is too large Load Diff

78
CONTRIBUTING.md Normal file
View File

@@ -0,0 +1,78 @@
# Contributing
We love contributions! If you want to run the project locally to test out changes, run the examples, or just see how things work under the hood, read on below.
## Local development
This runtime consumes specific tied-down versions of the [JS/WASM runtime](https://github.com/rive-app/rive-wasm) to have better control over changes that occur in that downstream runtime.
### Installation
1. Clone the project down
2. Run `npm i` in the shell/terminal at the base of the project to install the dependencies needed for the project
### Local dev server
To start the local dev server to reflect any changes made to the core `src/` files, run the following in a terminal tab:
```
npm run dev
```
### Running the example storybook locally
We use Storybook to deploy our examples out onto a public-facing page for folks to view and see code examples for. It also serves as the place we'll include any example suites. These story files are stored in `/examples`
To run Storybook, run the following command in the terminal:
```
npm run storybook
```
To see changes made to the Rive React runtime reflected in your storyook, run the following command in a separate terminal window:
```
npm run dev
```
### Testing
We also have a suite of unit tests against the high-level component and various hooks exported in the `test/` folder. When adding new components, changing the API, or underlying functionality, make sure to add a test here!
To run the test suite:
```
npm test
```
## Making changes
When you're ready to make changes, push up to a feature branch off of the `main` branch. Create a pull request to this repository in Github. When creating commit messages, please be as descriptive as possible to the changes being made.
For example, if the change is simply a bug fix or patch change:
```
git commit -m "Fix: Fixing a return type from useRive"
```
Or if it's simply a docs change:
```
git commit -m "Docs: Adding a new link for another example page"
```
For minor/major version releases, also ensure you preface commit messages with:
```
git commit -m "Major: Restructuring the useRive API with new parameters"
```
These messages help make the changelog clear as to what changes are made for future devs to see.
When pull requests are merged, the runtime will automatically deploy the next release version. By default, patch versions are published. If you want to set the next version as a minor/major version to be released, you have to manually update the `package.json` file at the root of the project to the verison you want it to.
You can find the deploy scripts in `.github/`
## Bumping the underlying JS/WASM runtime
Many times, fixes to the runtime and feature adds come from the underlying JS/WASM runtime. In these cases, just bump the `@rive-app/canvas` and `@rive-app/webgl` versions to the verison you need to incorporate the fix/feature. Run `npm i` and test out the change locally against the Storybook examples and run the test suite to make sure nothing breaks, and then submit a PR with just the `package.json` change if that's all that's needed.

183
README.md
View File

@@ -4,151 +4,80 @@
# Rive React
React Runtime for [Rive](https://rive.app).
![Rive hero image](https://cdn.rive.app/rive_logo_dark_bg.png)
A wrapper around [Rive.js](https://github.com/rive-app/rive-wasm), providing full control over the js runtime while making it super simple to use in React applications.
[Rive](https://rive.app) combines an interactive design tool, a new stateful graphics format, a lightweight multi-platform runtime, and a blazing-fast vector renderer. This end-to-end pipeline guarantees that what you build in the Rive Editor is exactly what ships in your apps, games, and websites.
Detailed runtime documentation can be found in [Rive's help center](https://help.rive.app/runtimes).
This library is a wrapper around the [JS/Wasm runtime](https://github.com/rive-app/rive-wasm), giving full control over the JS/Wasm runtime while providing components and hooks for React applications.
## Create and ship interactive animations to any platform
For more information, check out the following resources:
[Rive](https://rive.app) is a real-time interactive design and animation tool. Use our collaborative editor to create motion graphics that respond to different states and user inputs. Then load your animations into apps, games, and websites with our lightweight open-source runtimes.
- [Homepage](https://rive.app/)
- [General Docs](https://rive.app/docs/)
- [React Docs](https://rive.app/docs/runtimes/react/react)
- [Rive Community / Support](https://community.rive.app/c/support/)
## Installation
## Table of contents
```
npm i --save rive-react
```
- :star: [Rive Overview](#rive-overview)
- 🚀 [Getting Started & API docs](#getting-started)
- :mag: [Supported Versions](#supported-versions)
- :books: [Examples](#examples)
- :runner: [Migration Guides](#migration-guides)
- 👨‍💻 [Contributing](#contributing)
- :question: [Issues](#issues)
_Note: This library is using React hooks so the minimum version required for both react and react-dom is 16.8.0._
## Rive overview
## Usage
[Rive](https://rive.app) is a real-time interactive design and animation tool that helps teams create and run interactive animations anywhere. Designers and developers use our collaborative editor to create motion graphics that respond to different states and user inputs. Our lightweight open-source runtime libraries allow them to load their animations into apps, games, and websites.
### Component
:house_with_garden: [Homepage](https://rive.app/)
Rive React provides a basic component as it's default import for displaying simple animations.
:blue_book: [General help docs](https://rive.app/community/doc/)
```js
import Rive from 'rive-react';
🛠 [Rive Forums](https://rive.app/community/forums/home)
function Example() {
return <Rive src="loader.riv" />;
}
## Getting started
export default Example;
```
Follow along with the link below for a quick start in getting Rive React integrated into your React apps.
#### Props
- [Getting Started with Rive in React](https://rive.app/community/doc/react/docRfaSQ0eaE)
- [API documentation](https://rive.app/community/doc/parameters-and-return-values/docJlDMNulDh)
- `src`: File path or URL to the .riv file to display.
- `artboard`: _(optional)_ Name to display.
- `animations`: _(optional)_ Name or list of names of animtions to play.
- `layout`: _(optional)_ Layout object to define how animations are displayed on the canvas. See [Rive.js](https://github.com/rive-app/rive-wasm#layout) for more details.
- _All attributes and eventHandlers that can be passed to a `div` element can also be passed to the `Rive` component and used in the same manner._
For more information, see the Runtime sections of the Rive help documentation:
### useRive Hook
- [Animation Playback](https://rive.app/community/doc/animation-playback/docDKKxsr7ko)
- [Layout](https://rive.app/community/doc/layout/docBl81zd1GB)
- [State Machines](https://rive.app/community/doc/state-machines/docxeznG7iiK)
- [Rive Text](https://rive.app/community/doc/text/docn2E6y1lXo)
- [Rive Events](https://rive.app/community/doc/rive-events/docbOnaeffgr)
- [Loading Assets](https://rive.app/community/doc/loading-assets/doct4wVHGPgC)
For more advanced usage, the `useRive` hook is provided. The hook will return a component and a [Rive.js](https://github.com/rive-app/rive-wasm) `Rive` object which gives you control of the current rive file.
## Supported versions
```js
import { useRive } from 'rive-react';
function Example() {
const params = {
src: 'loader.riv',
autoplay: false,
};
const { RiveComponent, rive } = useRive(params);
return (
<RiveComponent
onMouseEnter={() => rive && rive.play()}
onMouseLeave={() => rive && rive.pause()}
/>
);
}
export default Example;
```
#### Parameters
- `riveParams`: Set of parameters that are passed to the Rive.js `Rive` class constructor. `null` and `undefined` can be passed to conditionally display the .riv file.
- `opts`: Rive React specific options.
#### Return Values
- `RiveComponent`: A Component that can be used to display your .riv file. This component accepts the same attributes and event handlers as a `div` element.
- `rive`: A Rive.js `Rive` object. This will return as null until the .riv file has fully loaded.
- `canvas`: HTMLCanvasElement object, on which the .riv file is rendering.
- `setCanvasRef`: A callback ref that can be passed to your own canvas element, if you wish to have control over the rendering of the Canvas element.
- `setContainerRef`: A callback ref that can be passed to a container element that wraps the canvas element, if you which to have control over the rendering of the container element.
_For the vast majority of use cases, you can just the returned `RiveComponent` and don't need to worry about `setCanvasRef` and `setContainerRef`._
#### riveParams
- `src?`: _(optional)_ File path or URL to the .riv file to use. One of `src` or `buffer` must be provided.
- `buffer?`: _(optional)_ ArrayBuffer containing the raw bytes from a .riv file. One of `src` or `buffer` must be provided.
- `artboard?`: _(optional)_ Name of the artboard to use.
- `animations?`: _(optional)_ Name or list of names of animations to play.
- `stateMachines?`: _(optional)_ Name of list of names of state machines to load.
- `layout?`: _(optional)_ Layout object to define how animations are displayed on the canvas. See [Rive.js](https://github.com/rive-app/rive-wasm#layout) for more details.
- `autoplay?`: _(optional)_ If `true`, the animation will automatically start playing when loaded. Defaults to false.
- `onLoad?`: _(optional)_ Callback that get's fired when the .rive file loads .
- `onLoadError?`: _(optional)_ Callback that get's fired when an error occurs loading the .riv file.
- `onPlay?`: _(optional)_ Callback that get's fired when the animation starts playing.
- `onPause?`: _(optional)_ Callback that get's fired when the animation pauses.
- `onStop?`: _(optional)_ Callback that get's fired when the animation stops playing.
- `onLoop?`: _(optional)_ Callback that get's fired when the animation completes a loop.
- `onStateChange?`: _(optional)_ Callback that get's fired when a state change occurs.
#### opts
- `useDevicePixelRatio`: _(optional)_ If `true`, the hook will scale the resolution of the animation based the [devicePixelRatio](https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio). Defaults to `true`. NOTE: Requires the `setContainerRef` ref callback to be passed to a element wrapping a canvas element. If you use the `RiveComponent`, then this will happen automatically.
- `fitCanvasToArtboardHeight`: _(optional)_ If `true`, then the canvas will resize based on the height of the artboard. Defaults to `false`.
### useStateMachineInput Hook
The `useStateMachineInput` hook is provided to make it easier to interact with state machine inputs on a rive file.
```js
import { useRive, useStateMachineInput } from 'rive-react';
function Example() {
const STATE_MACHINE_NAME = 'button';
const INPUT_NAME = 'onClick';
const { RiveComponent, rive } = useRive({
src: 'button.riv',
stateMachines: STATE_MACHINE_NAME,
autoplay: true,
});
const onClickInput = useStateMachineInput(
rive,
STATE_MACHINE_NAME,
INPUT_NAME
);
// This example is using a state machine with a trigger input.
return <RiveComponent onClick={() => onClickInput.fire()} />;
}
export default Example;
```
See our [examples](examples) folder for working examples of [Boolean](examples/state-machine-boolean-input) and [Number](examples/state-machine-number-input) inputs.
#### Parameters
- `rive`: A `Rive` object. This is returned by the `useRive` hook.
- `stateMachineName`: Name of the state machine.
- `inputName`: Name of the state machine input.
#### Return Value
A Rive.js `stateMachineInput` object.
This library supports React versions `^16.8.0` through `^18.0.0`.
## Examples
The [examples](examples) shows a number of different ways to use Rive React. See the instructions for each example to run locally.
Check out our Storybook instance that shows how to use the library in small examples, along with code snippets! This includes examples using the basic component, as well as the convenient hooks exported to take advantage of state machines.
- [Mouse tracking](https://codesandbox.io/s/rive-mouse-track-test-t0y965?file=/src/App.js)
- [Accessibility concerns](https://rive.app/blog/accesible-web-animations-aria-live-regions)
### Awesome Rive
For even more examples and resources on using Rive at runtime or in other tools, checkout the [awesome-rive](https://github.com/rive-app/awesome-rive) repo.
## Migration guides
Using an older version of the runtime and need to learn how to upgrade to the latest version? Check out the migration guides below in our help center that help guide you through version bumps; breaking changes and all!
[Migration guides](https://rive.app/community/doc/migrating-from-v3-to-v4/dociIPXVHKFF)
## Contributing
We love contributions! Check out our [contributing docs](./CONTRIBUTING.md) to get more details into how to run this project, the examples, and more all locally.
## Issues
Have an issue with using the runtime, or want to suggest a feature/API to help make your development life better? Log an issue in our [issues](https://github.com/rive-app/rive-react/issues) tab! You can also browse older issues and discussion threads there to see solutions that may have worked for common problems.

View File

@@ -21,3 +21,5 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
*storybook.log

View File

@@ -0,0 +1,74 @@
import type { StorybookConfig } from '@storybook/react-webpack5';
import path from 'path';
const config: StorybookConfig = {
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
addons: [
'@storybook/addon-essentials',
'@storybook/preset-create-react-app',
'@storybook/addon-interactions',
],
framework: {
name: '@storybook/react-webpack5',
options: {},
},
staticDirs: ['../public'],
webpackFinal: async (config) => {
if (!config.resolve) config.resolve = {};
if (!config.resolve.alias) config.resolve.alias = {};
config.resolve.alias['react'] = path.resolve(
__dirname,
'../../node_modules/react'
);
config.resolve.alias['react-dom'] = path.resolve(
__dirname,
'../../node_modules/react-dom'
);
config.resolve.alias['@rive-app/react-canvas'] = path.resolve(
__dirname,
'../../'
);
config.resolve.alias['@rive-app/react-canvas-lite'] = path.resolve(
__dirname,
'../../'
);
config.resolve.alias['@rive-app/react-webgl'] = path.resolve(
__dirname,
'../../'
);
config.resolve.alias['@rive-app/react-webgl2'] = path.resolve(
__dirname,
'../../'
);
config.module?.rules?.push({
test: /\.(ts|tsx|js|jsx)$/,
include: [
path.resolve(__dirname, '../src'),
path.resolve(__dirname, '../../'),
],
use: {
loader: require.resolve('babel-loader'),
options: {
presets: [
require.resolve('@babel/preset-env'),
require.resolve('@babel/preset-react'),
require.resolve('@babel/preset-typescript'),
],
},
},
});
config.watchOptions = {
ignored: /node_modules/,
poll: 1000,
aggregateTimeout: 300,
};
return config;
},
};
export default config;

View File

@@ -0,0 +1,16 @@
import type { Preview } from '@storybook/react';
import './stories.css';
const preview: Preview = {
parameters: {
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
},
},
};
export default preview;

View File

@@ -0,0 +1,7 @@
html, body {
height: 100%;
}
#storybook-root {
height: 100%;
}

View File

@@ -1,14 +0,0 @@
# Basic Typescript
This is an example app that uses the useRive hook with typescript.
## To Run
This example is created using [Create React App](https://reactjs.org/docs/create-a-new-react-app.html).
To install and run:
```
npm install
npm start
```

View File

@@ -1,44 +0,0 @@
{
"name": "basic-typescript",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.13.0",
"@testing-library/react": "^11.2.7",
"@testing-library/user-event": "^12.8.3",
"@types/jest": "^26.0.23",
"@types/node": "^12.20.14",
"@types/react": "^17.0.9",
"@types/react-dom": "^17.0.6",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3",
"rive-react": "latest",
"typescript": "^4.3.2",
"web-vitals": "^1.1.2"
},
"scripts": {
"start": "SKIP_PREFLIGHT_CHECK=true react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}

View File

@@ -1,17 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<title>React App - Basic Typescript</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
</body>
</html>

View File

Binary file not shown.

View File

@@ -1,19 +0,0 @@
import { useRive, UseRiveParameters } from 'rive-react';
function App() {
const params: UseRiveParameters = {
src: 'poison-loader.riv',
autoplay: true,
};
const { RiveComponent } = useRive(params);
return (
// The animation will fit to the parent element.
<div style={{ height: '500px', width: '500px' }}>
<RiveComponent />
</div>
);
}
export default App;

View File

@@ -1,10 +0,0 @@
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
);

View File

@@ -1 +0,0 @@
/// <reference types="react-scripts" />

View File

@@ -1,14 +0,0 @@
# Basic with hook
This is a very basic example of using the useRive to autoplay a simple looping animation.
## To Run
This example is created using [Create React App](https://reactjs.org/docs/create-a-new-react-app.html).
To install and run:
```
npm install
npm start
```

View File

@@ -1,36 +0,0 @@
{
"name": "basic-with-hook",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.13.0",
"@testing-library/react": "^11.2.7",
"@testing-library/user-event": "^12.8.3",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3",
"rive-react": "latest",
"web-vitals": "^1.1.2"
},
"scripts": {
"start": "SKIP_PREFLIGHT_CHECK=true react-scripts start"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}

View File

@@ -1,17 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<title>Rive React - Basic with Hook</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
</body>
</html>

View File

Binary file not shown.

View File

@@ -1,19 +0,0 @@
import { useRive } from 'rive-react';
function App() {
const params = {
src: 'poison-loader.riv',
autoplay: true,
};
const { RiveComponent } = useRive(params);
return (
// The animation will fit to the parent element.
<div style={{ height: '500px', width: '500px' }}>
<RiveComponent />
</div>
);
}
export default App;

View File

@@ -1,10 +0,0 @@
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
);

View File

@@ -1,14 +0,0 @@
# Basic
This is a very basic example of using the Rive component to autoplay a simple looping animation.
## To Run
This example is created using [Create React App](https://reactjs.org/docs/create-a-new-react-app.html).
To install and run:
```
npm install
npm start
```

View File

@@ -1,36 +0,0 @@
{
"name": "basic-example",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.13.0",
"@testing-library/react": "^11.2.7",
"@testing-library/user-event": "^12.8.3",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3",
"rive-react": "latest",
"web-vitals": "^1.1.2"
},
"scripts": {
"start": "SKIP_PREFLIGHT_CHECK=true react-scripts start"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}

View File

@@ -1,17 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<title>Rive React - Basic</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
</body>
</html>

View File

Binary file not shown.

View File

@@ -1,12 +0,0 @@
import Rive from 'rive-react';
function App() {
return (
// The animation will fit to the parent element.
<div style={{ height: '500px', width: '500px' }}>
<Rive src="poison-loader.riv" autoplay />
</div>
);
}
export default App;

View File

@@ -1,10 +0,0 @@
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
);

56
examples/package.json Normal file
View File

@@ -0,0 +1,56 @@
{
"name": "examples",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/dom": "^10.4.0",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.3.0",
"@testing-library/user-event": "^13.5.0",
"@types/jest": "^27.5.2",
"@types/node": "^16.18.126",
"@types/react": "^19.1.2",
"@types/react-dom": "^19.1.2",
"react-scripts": "5.0.1",
"typescript": "^4.9.5",
"web-vitals": "^2.1.4"
},
"scripts": {
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build",
"test-storybook": "test-storybook"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest",
"plugin:storybook/recommended"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@storybook/addon-essentials": "^8.6.12",
"@storybook/addon-interactions": "^8.6.12",
"@storybook/addon-onboarding": "^8.6.12",
"@storybook/blocks": "^8.6.12",
"@storybook/preset-create-react-app": "^8.6.12",
"@storybook/react": "^8.6.12",
"@storybook/react-webpack5": "^8.6.12",
"@storybook/test": "^8.6.12",
"@storybook/test-runner": "^0.22.0",
"eslint-plugin-storybook": "^0.12.0",
"storybook": "^8.6.12",
"webpack": "^5.99.6"
}
}

View File

@@ -1,14 +0,0 @@
# Play on hover
This provides an example of how to play/pause a Rive animation when the mouse is hovered over it.
## To Run
This example is created using [Create React App](https://reactjs.org/docs/create-a-new-react-app.html).
To install and run:
```
npm install
npm start
```

View File

@@ -1,36 +0,0 @@
{
"name": "play-on-hover",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.13.0",
"@testing-library/react": "^11.2.7",
"@testing-library/user-event": "^12.8.3",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3",
"rive-react": "latest",
"web-vitals": "^1.1.2"
},
"scripts": {
"start": "SKIP_PREFLIGHT_CHECK=true react-scripts start"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}

View File

@@ -1,17 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<title>Rive React - Play on hover</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
</body>
</html>

View File

Binary file not shown.

View File

@@ -1,32 +0,0 @@
import { useRive } from 'rive-react';
function App() {
const params = {
src: 'poison-loader.riv',
autoplay: false,
};
const { RiveComponent, rive } = useRive(params);
function onMouseEnter() {
// `rive` will return as null until the file as fully loaded, so we include this
// guard to prevent any unwanted errors.
if (rive) {
rive.play();
}
}
function onMouseLeave() {
if (rive) {
rive.pause();
}
}
return (
<div style={{ height: '600px', width: '600px' }}>
<RiveComponent onMouseEnter={onMouseEnter} onMouseLeave={onMouseLeave} />
</div>
);
}
export default App;

View File

@@ -1,10 +0,0 @@
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
);

View File

@@ -1,14 +0,0 @@
# Play/Pause Buttons
This example shows how we can play/pause the Rive animation on a button click and update the text of the button based on events happening in the runtime.
## To Run
This example is created using [Create React App](https://reactjs.org/docs/create-a-new-react-app.html).
To install and run:
```
npm install
npm start
```

View File

@@ -1,36 +0,0 @@
{
"name": "play-pause-button",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.13.0",
"@testing-library/react": "^11.2.7",
"@testing-library/user-event": "^12.8.3",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3",
"rive-react": "latest",
"web-vitals": "^1.1.2"
},
"scripts": {
"start": "SKIP_PREFLIGHT_CHECK=true react-scripts start"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}

View File

@@ -1,17 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<title>Rive React - Play/Pause Button</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
</body>
</html>

View File

Binary file not shown.

View File

@@ -1,50 +0,0 @@
import { useEffect, useState } from 'react';
import { useRive } from 'rive-react';
function App() {
const [buttonText, setButtonText] = useState('Pause');
const { RiveComponent, rive } = useRive({
src: 'poison-loader.riv',
autoplay: true,
});
useEffect(() => {
if (rive) {
// "play" event is fired when the animation starts to play, so we update
// button text on this event.
rive.on('play', () => {
setButtonText('Pause');
});
// As above, the "pause" event is fired when the animation pauses.
rive.on('pause', () => {
setButtonText('Play');
});
}
// We listen for changes to the rive object. The rive object will be null
// until the rive file has loaded.
}, [rive]);
function onButtonClick() {
// `rive` will return as null until the file as fully loaded, so we include this
// guard to prevent any unwanted errors.
if (rive) {
if (rive.isPlaying) {
rive.pause();
} else {
rive.play();
}
}
}
return (
// The animation will fit to the parent element, so we set a large height
// and width for this example.
<div style={{ height: '500px', width: '500px' }}>
<RiveComponent />
<button onClick={onButtonClick}>{buttonText}</button>
</div>
);
}
export default App;

View File

@@ -1,10 +0,0 @@
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
);

View File

Binary file not shown.

BIN
examples/public/avatars.riv Normal file
View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

BIN
examples/public/rating.riv Normal file
View File

Binary file not shown.

BIN
examples/public/stocks.riv Normal file
View File

Binary file not shown.

View File

@@ -0,0 +1,17 @@
import type { Meta, StoryObj } from '@storybook/react';
import DataBinding from './DataBinding';
const meta = {
title: 'DataBinding',
component: DataBinding,
parameters: {
layout: 'fullscreen',
},
args: {},
} satisfies Meta<typeof DataBinding>;
export default meta;
type Story = StoryObj<typeof meta>;
export const Default: Story = {};

View File

@@ -0,0 +1,147 @@
import React, { useEffect } from 'react';
import {
useRive,
useViewModel,
useViewModelInstance,
useViewModelInstanceColor,
useViewModelInstanceNumber,
useViewModelInstanceString,
useViewModelInstanceEnum,
useViewModelInstanceTrigger,
} from '@rive-app/react-webgl2';
const randomValue = () => Math.random() * 200 - 100;
const DataBinding = () => {
const { rive, RiveComponent } = useRive({
src: 'stocks.riv',
artboard: 'Main',
stateMachines: 'State Machine 1',
autoplay: true,
autoBind: false,
});
// Get the default instance of the view model
const viewModel = useViewModel(rive, { name: 'Dashboard' });
const viewModelInstance = useViewModelInstance(viewModel, { rive });
// Get the view model instance properties
const { setValue: setTitle } = useViewModelInstanceString(
'title',
viewModelInstance
);
const { setValue: setLogoShape } = useViewModelInstanceEnum(
'logoShape',
viewModelInstance
);
const { setValue: setRootColor } = useViewModelInstanceColor(
'rootColor',
viewModelInstance
);
const { trigger: triggerSpinLogo } = useViewModelInstanceTrigger(
'triggerSpinLogo',
viewModelInstance
);
useViewModelInstanceTrigger('triggerButton', viewModelInstance, {
onTrigger: () => console.log('Button Triggered!'),
});
// Apple Values
const { setValue: setAppleName } = useViewModelInstanceString(
'apple/name',
viewModelInstance
);
const { setValue: setAppleStockChange } = useViewModelInstanceNumber(
'apple/stockChange',
viewModelInstance
);
const { value: appleColor } = useViewModelInstanceColor(
'apple/currentColor',
viewModelInstance
);
// Apple Values
const { setValue: setMicrosoftName } = useViewModelInstanceString(
'microsoft/name',
viewModelInstance
);
const { setValue: setMicrosoftStockChange } = useViewModelInstanceNumber(
'microsoft/stockChange',
viewModelInstance
);
// Tesla Values
const { setValue: setTeslaName } = useViewModelInstanceString(
'tesla/name',
viewModelInstance
);
const { setValue: setTeslaStockChange } = useViewModelInstanceNumber(
'tesla/stockChange',
viewModelInstance
);
useEffect(() => {
// Set initial values for the view model
if (
setTitle &&
setLogoShape &&
setRootColor &&
setAppleName &&
setMicrosoftName &&
setTeslaName
) {
setTitle('Rive Stocks Dashboard');
setLogoShape('triangle');
setRootColor(parseInt('ffc0ffee', 16));
setAppleName('AAPL');
setMicrosoftName('MSFT');
setTeslaName('TSLA');
}
// randomly generate stock values every 2 seconds
const interval = setInterval(() => {
const appleValue = randomValue();
const microsoftValue = randomValue();
const teslaValue = randomValue();
setAppleStockChange(appleValue);
setMicrosoftStockChange(microsoftValue);
setTeslaStockChange(teslaValue);
// If all the stock values are either all positive or all negative, spin the logo
if (
(appleValue > 0 && microsoftValue > 0 && teslaValue > 0) ||
(appleValue < 0 && microsoftValue < 0 && teslaValue < 0)
) {
triggerSpinLogo();
}
}, 2000);
return () => clearInterval(interval);
}, [
setTitle,
setLogoShape,
setRootColor,
setAppleName,
setMicrosoftName,
setTeslaName,
setAppleStockChange,
setMicrosoftStockChange,
setTeslaStockChange,
triggerSpinLogo,
]);
// listen for changes to the AAPL color and log them
useEffect(() => {
if (appleColor) {
console.log('Apple color changed:', appleColor);
}
}, [appleColor]);
return <RiveComponent />;
};
export default DataBinding;

View File

@@ -0,0 +1,527 @@
import React, { useEffect } from 'react';
import type { Meta, StoryObj } from '@storybook/react';
import { within, expect, waitFor, userEvent } from '@storybook/test';
import { StringPropertyTest, NumberPropertyTest, BooleanPropertyTest, ColorPropertyTest, EnumPropertyTest, NestedViewModelTest, TriggerPropertyTest, PersonForm, PersonInstances, ImagePropertyTest, TodoListTest, ArtboardPropertyTest } from './DataBindingTests';
const meta: Meta = {
title: 'Tests/DataBinding',
parameters: {
layout: 'centered',
},
};
export default meta;
export const StringPropertyStory: StoryObj = {
name: 'String Property',
render: () => <StringPropertyTest src="person_databinding_test.riv" />,
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
// Wait for the Rive file to load
await waitFor(() => {
expect(canvas.getByTestId('name-value')).toBeTruthy();
}, { timeout: 3000 });
const nameInput = canvas.getByTestId<HTMLInputElement>('name-input');
await userEvent.clear(nameInput);
// Wait for the input to be cleared
await waitFor(() => {
expect(nameInput.value).toBe('');
}, { timeout: 1000 });
await userEvent.click(nameInput);
await userEvent.paste('Test User');
await waitFor(() => {
expect(nameInput.value).toBe('Test User');
}, { timeout: 2000 });
await waitFor(() => {
expect(canvas.getByTestId('name-value').textContent).toBe('Test User');
}, { timeout: 2000 });
}
};
export const NumberPropertyStory: StoryObj = {
name: 'Number Property',
render: () => <NumberPropertyTest src="person_databinding_test.riv" />,
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
// Wait for the Rive file to load
await waitFor(() => {
expect(canvas.getByTestId('age-value')).toBeTruthy();
}, { timeout: 2000 });
const ageInput = canvas.getByTestId<HTMLInputElement>('age-input');
const currentValue = ageInput.value;
expect(currentValue).toBe('23');
await userEvent.click(ageInput);
await userEvent.clear(ageInput);
await waitFor(() => {
expect(ageInput.value).toBe('0'); // This is a hack to wait for the input to be cleared
}, { timeout: 1000 });
await userEvent.paste('42');
await waitFor(() => {
expect(canvas.getByTestId('age-value').textContent).toBe('42');
}, { timeout: 2000 });
}
};
export const BooleanPropertyStory: StoryObj = {
name: 'Boolean Property',
render: () => <BooleanPropertyTest src="person_databinding_test.riv" />,
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
// Wait for the Rive file to load
await waitFor(() => {
expect(canvas.getByTestId('terms-value')).toBeTruthy();
}, { timeout: 2000 });
const termsCheckbox = canvas.getByTestId<HTMLInputElement>('terms-checkbox');
expect(termsCheckbox.checked).toBe(false);
expect(canvas.getByTestId('terms-value').textContent).toBe('false');
await userEvent.click(termsCheckbox);
// Verify terms update
await waitFor(() => {
expect(canvas.getByTestId('terms-value').textContent).toBe('true');
});
}
};
export const ColorPropertyStory: StoryObj = {
name: 'Color Property',
render: () => <ColorPropertyTest src="person_databinding_test.riv" />,
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
// Wait for the Rive file to load and the component to render
await waitFor(() => {
expect(canvas.getByTestId('color-value')).toBeTruthy();
expect(canvas.getByTestId('set-color-red')).toBeTruthy();
expect(canvas.getByTestId('set-color-blue')).toBeTruthy();
}, { timeout: 5000 });
const numberValueDiv = canvas.getByTestId('number-value');
const hexValueDiv = canvas.getByTestId('hex-value');
// Verify initial state is red
await waitFor(() => {
expect(hexValueDiv.textContent).toContain('Hex value: #ce2323');
expect(numberValueDiv.textContent).toContain('Number value: -3267805');
});
// Change color to Blue ---
const blueButton = canvas.getByTestId('set-color-blue');
await userEvent.click(blueButton);
// Verify Blue State
await waitFor(() => {
expect(numberValueDiv.textContent).toContain('Number value: -16776961');
expect(hexValueDiv.textContent).toContain('Hex value: #0000ff');
});
// Change color back to Red ---
const redButton = canvas.getByTestId('set-color-red');
await userEvent.click(redButton);
// Verify Red State
await waitFor(() => {
expect(numberValueDiv.textContent).toContain('Number value: -65536');
expect(hexValueDiv.textContent).toContain('Hex value: #ff0000');
});
}
};
export const EnumPropertyStory: StoryObj = {
name: 'Enum Property',
render: () => <EnumPropertyTest src="person_databinding_test.riv" />,
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
// Wait for the Rive file to load
await waitFor(() => {
expect(canvas.getByTestId('country-value')).toBeTruthy();
});
// Wait for options to be loaded
await waitFor(() => {
const countrySelect = canvas.getByTestId<HTMLSelectElement>('country-select');
return countrySelect.options.length > 0;
});
const countrySelect = canvas.getByTestId<HTMLSelectElement>('country-select');
// Verify that the dropdown contains usa, japan, and canada
const optionValues = Array.from(countrySelect.options).map(option => option.value);
expect(optionValues).toContain('usa');
expect(optionValues).toContain('japan');
expect(optionValues).toContain('canada');
const currentValue = countrySelect.value;
expect(currentValue).toBe('usa');
let optionToSelect = 'japan';
await userEvent.selectOptions(countrySelect, optionToSelect);
await waitFor(() => {
expect(canvas.getByTestId('country-value').textContent).toBe(optionToSelect);
});
}
};
export const NestedViewModelStory: StoryObj = {
name: 'Nested ViewModel Property',
render: () => <NestedViewModelTest src="person_databinding_test.riv" />,
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
// Wait for the Rive file to load
await waitFor(() => {
expect(canvas.getByTestId('drink-type-value')).toBeTruthy();
});
// Wait for options to be loaded
await waitFor(() => {
const drinkTypeSelect = canvas.getByTestId<HTMLSelectElement>('drink-type-select');
return drinkTypeSelect.options.length > 0;
}, { timeout: 2000 });
const drinkTypeSelect = canvas.getByTestId<HTMLSelectElement>('drink-type-select');
const optionValues = Array.from(drinkTypeSelect.options).map(option => option.value);
expect(optionValues).toContain('Coffee');
expect(optionValues).toContain('Tea');
expect(drinkTypeSelect.value).toBe('Tea');
let optionToSelect = 'Coffee';
await userEvent.selectOptions(drinkTypeSelect, optionToSelect);
await waitFor(() => {
expect(canvas.getByTestId('drink-type-value').textContent).toBe(optionToSelect);
});
}
};
export const TriggerPropertyStory: StoryObj = {
name: 'Trigger Property',
render: () => <TriggerPropertyTest src="person_databinding_test.riv" />,
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
// Wait for the Rive file to load
await waitFor(() => {
expect(canvas.getByTestId('submit-button')).toBeTruthy();
}, { timeout: 2000 });
expect(canvas.getByTestId('callback-triggered').textContent).toContain('none');
// Trigger submit action
await userEvent.click(canvas.getByTestId('submit-button'));
await waitFor(() => {
expect(canvas.getByTestId('callback-triggered').textContent).toContain('submit-callback');
});
await userEvent.click(canvas.getByTestId('reset-button'));
// Verify onTrigger callback works for reset
await waitFor(() => {
expect(canvas.getByTestId('callback-triggered').textContent).toContain('reset-callback');
});
}
};
export const PersonInstancesStory: StoryObj = {
name: 'Person Instances',
render: () => <PersonInstances src="person_databinding_test.riv" />,
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
// Wait for the Rive file to load
await waitFor(() => {
expect(canvas.getByTestId('instance-name')).toBeTruthy();
expect(canvas.getByTestId('select-jane')).toBeTruthy();
expect(canvas.getByTestId('select-default')).toBeTruthy();
}, { timeout: 2000 });
// Initially should show Steve
expect(canvas.getByTestId('instance-name').textContent).toContain('Steve');
// Switch to Jane
const janeButton = canvas.getByTestId('select-jane');
await userEvent.click(janeButton);
// Verify instance changed to Jane
await waitFor(() => {
expect(canvas.getByTestId('instance-name').textContent).toContain('Jane');
});
// Switch to Default instance
const defaultButton = canvas.getByTestId('select-default');
await userEvent.click(defaultButton);
// Verify instance changed to Default
await waitFor(() => {
expect(canvas.getByTestId('instance-name').textContent).toContain('Default');
});
// Switch back to Steve
const steveButton = canvas.getByTestId('select-steve');
await userEvent.click(steveButton);
// Verify instance changed back to Steve
await waitFor(() => {
expect(canvas.getByTestId('instance-name').textContent).toContain('Steve');
});
}
};
// A configurable form story, so we can test all the properties at once
export const PersonFormStory: StoryObj = {
name: 'Complete Person Form',
render: () => <PersonForm src="person_databinding_test.riv" />,
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
// Wait for the Rive file to load
await waitFor(() => {
expect(canvas.getByTestId('name-value')).toBeTruthy();
}, { timeout: 2000 });
// Update name
const nameInput = canvas.getByTestId('name-input');
await userEvent.clear(nameInput);
await userEvent.type(nameInput, 'Test User');
// Update age
const ageInput = canvas.getByTestId('age-input');
await userEvent.clear(ageInput);
await userEvent.type(ageInput, '42');
// Toggle terms agreement
const termsCheckbox = canvas.getByTestId('terms-checkbox');
await userEvent.click(termsCheckbox);
// Change color
const colorButton = canvas.getByTestId('set-color-red');
await userEvent.click(colorButton);
// Change country
const countrySelect = canvas.getByTestId<HTMLSelectElement>('country-select');
await userEvent.selectOptions(countrySelect, 'japan');
// Change drink type
const drinkTypeSelect = canvas.getByTestId<HTMLSelectElement>('drink-type-select');
await userEvent.selectOptions(drinkTypeSelect, 'Coffee');
// Submit the form
const submitButton = canvas.getByTestId('submit-button');
await userEvent.click(submitButton);
}
};
export const ImagePropertyStory: StoryObj = {
name: 'Image Property',
render: () => <ImagePropertyTest src="image_db_test.riv" />,
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
// Wait for the Rive file to load
await waitFor(() => {
expect(canvas.getByTestId('load-random-image')).toBeTruthy();
expect(canvas.getByTestId('clear-image')).toBeTruthy();
}, { timeout: 3000 });
const loadImageButton = canvas.getByTestId('load-random-image');
const clearImageButton = canvas.getByTestId('clear-image');
expect(canvas.queryByTestId('current-image-url')).toBeNull();
// Load a random image
await userEvent.click(loadImageButton);
// Wait for the image to load and URL to appear
await waitFor(() => {
expect(canvas.getByTestId('current-image-url')).toBeTruthy();
}, { timeout: 5000 });
// Verify the image URL is displayed
const imageUrlElement = canvas.getByTestId('current-image-url');
expect(imageUrlElement.textContent).toContain('Current image: https://picsum.photos');
// Clear the image
await userEvent.click(clearImageButton);
// Load another image to test it works multiple times
await userEvent.click(loadImageButton);
// Wait for the new image to load
await waitFor(() => {
expect(canvas.getByTestId('current-image-url')).toBeTruthy();
}, { timeout: 5000 });
}
};
export const TodoListStory: StoryObj = {
name: 'Todo List Property',
render: () => <TodoListTest src="db_list_test.riv" />,
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
// Wait for the Rive file to load
await waitFor(() => {
expect(canvas.getByTestId('list-length')).toBeTruthy();
}, { timeout: 3000 });
const initialLengthText = canvas.getByTestId('list-length').textContent;
const initialCount = parseInt(initialLengthText?.match(/Items: (\d+)/)?.[1] || '0');
// Test 1: addInstance - Add item to end
const addButton = canvas.getByTestId('add-item-button');
await userEvent.click(addButton);
await waitFor(() => {
expect(canvas.getByTestId('list-length').textContent).toContain(`Items: ${initialCount + 1}`);
});
// Test 2: addInstanceAt - Add item at specific index (if we have items)
if (initialCount > 0) {
const addAtButton = canvas.getByTestId('add-item-at-button');
await userEvent.click(addAtButton);
await waitFor(() => {
expect(canvas.getByTestId('list-length').textContent).toContain(`Items: ${initialCount + 2}`);
});
}
// Test 3: getInstanceAt - Interact with specific items
const currentCount = initialCount + (initialCount > 0 ? 2 : 1);
if (currentCount > 0) {
await waitFor(() => {
expect(canvas.getByTestId('todo-item-0')).toBeTruthy();
});
// Edit the first item
const todoText = canvas.getByTestId('todo-text-0');
await userEvent.clear(todoText);
// Wait for the input to be cleared to avoid issues with autocomplete
await waitFor(() => {
expect((todoText as HTMLInputElement).value).toBe('');
}, { timeout: 2000 });
await userEvent.click(todoText);
await userEvent.paste('Test Item');
await waitFor(() => {
expect(canvas.getByTestId('todo-text-value-0').textContent).toContain('Test Item');
}, { timeout: 3000 });
}
// Test 4: swap - Swap first two items
if (currentCount >= 2) {
const firstText = canvas.getByTestId<HTMLInputElement>('todo-text-0').value;
const secondText = canvas.getByTestId<HTMLInputElement>('todo-text-1').value;
const swapButton = canvas.getByTestId('swap-button');
await userEvent.click(swapButton);
await waitFor(() => {
expect(canvas.getByTestId('todo-text-0')).toHaveValue(secondText);
expect(canvas.getByTestId('todo-text-1')).toHaveValue(firstText);
}, { timeout: 3000 });
}
// Test 5: removeInstance - Remove by instance reference
if (currentCount > 0) {
const removeInstanceButton = canvas.getByTestId('remove-instance-button');
await userEvent.click(removeInstanceButton);
await waitFor(() => {
expect(canvas.getByTestId('list-length').textContent).toContain(`Items: ${currentCount - 1}`);
}, { timeout: 3000 });
}
// Test 6: removeInstanceAt - Remove by index
const afterRemoveInstance = currentCount > 0 ? currentCount - 1 : 0;
if (afterRemoveInstance > 0) {
const removeIndexButton = canvas.getByTestId('remove-index-button');
await userEvent.click(removeIndexButton);
await waitFor(() => {
expect(canvas.getByTestId('list-length').textContent).toContain(`Items: ${afterRemoveInstance - 1}`);
}, { timeout: 3000 });
}
}
};
export const ArtboardPropertyStory: StoryObj = {
name: 'Artboard Property',
render: () => <ArtboardPropertyTest src="artboard_db_test.riv" />,
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
// Wait for the Rive file to load
await waitFor(() => {
expect(canvas.getByTestId('set-artboard1-blue')).toBeTruthy();
expect(canvas.getByTestId('set-artboard1-red')).toBeTruthy();
expect(canvas.getByTestId('set-artboard1-green')).toBeTruthy();
}, { timeout: 3000 });
// Initially should show None
expect(canvas.getByTestId('artboard1-current').textContent).toBe('Current: None');
expect(canvas.getByTestId('artboard2-current').textContent).toBe('Current: None');
// Set artboard 1 to blue
await userEvent.click(canvas.getByTestId('set-artboard1-blue'));
await waitFor(() => {
expect(canvas.getByTestId('artboard1-current').textContent).toBe('Current: ArtboardBlue');
});
// Set artboard 2 to red
await userEvent.click(canvas.getByTestId('set-artboard2-red'));
await waitFor(() => {
expect(canvas.getByTestId('artboard2-current').textContent).toBe('Current: ArtboardRed');
});
// Switch artboard 1 to green
await userEvent.click(canvas.getByTestId('set-artboard1-green'));
await waitFor(() => {
expect(canvas.getByTestId('artboard1-current').textContent).toBe('Current: ArtboardGreen');
});
// Switch artboard 2 to blue
await userEvent.click(canvas.getByTestId('set-artboard2-blue'));
await waitFor(() => {
expect(canvas.getByTestId('artboard2-current').textContent).toBe('Current: ArtboardBlue');
});
}
};

View File

@@ -0,0 +1,881 @@
import React, { useEffect, useState } from 'react';
import Rive, {
useRive,
useViewModel,
useViewModelInstance,
useViewModelInstanceBoolean,
useViewModelInstanceString,
useViewModelInstanceNumber,
useViewModelInstanceEnum,
useViewModelInstanceColor,
useViewModelInstanceTrigger,
useViewModelInstanceImage,
decodeImage,
ViewModelInstance,
useViewModelInstanceList,
useViewModelInstanceArtboard
} from '@rive-app/react-webgl2';
export const StringPropertyTest = ({ src }: { src: string }) => {
const { rive, RiveComponent } = useRive({
src,
autoplay: true,
artboard: "Artboard",
autoBind: true,
stateMachines: "State Machine 1",
});
const { value: name, setValue: setName } = useViewModelInstanceString('name', rive?.viewModelInstance);
return (
<div>
<RiveComponent style={{ width: '400px', height: '400px' }} />
{(rive === null) ? <div data-testid="loading-text">Loading</div> : (
<div>
<label>
Name:
<input
data-testid="name-input"
type="text"
value={name || ''}
onChange={(e) => setName(e.target.value)}
autoFocus={false}
/>
</label>
<div data-testid="name-value">{name}</div>
</div>
)}
</div>
);
};
export const NumberPropertyTest = ({ src }: { src: string }) => {
const { rive, RiveComponent } = useRive({
src,
autoplay: true,
artboard: "Artboard",
autoBind: true,
stateMachines: "State Machine 1",
});
const { value: age, setValue: setAge } = useViewModelInstanceNumber('age', rive?.viewModelInstance);
return (
<div>
<RiveComponent style={{ width: '400px', height: '400px' }} />
{(rive === null) ? <div data-testid="loading-text">Loading</div> : (
<div>
<label>
Age:
<input
data-testid="age-input"
type="number"
value={age ?? 0}
onChange={(e) => setAge(Number(e.target.value))}
autoFocus={false}
/>
</label>
<div data-testid="age-value">{age}</div>
</div>
)}
</div>
);
};
export const BooleanPropertyTest = ({ src }: { src: string }) => {
const { rive, RiveComponent } = useRive({
src,
autoplay: true,
artboard: "Artboard",
autoBind: true,
stateMachines: "State Machine 1",
});
const { value: agreedToTerms, setValue: setAgreedToTerms } = useViewModelInstanceBoolean('agreedToTerms', rive?.viewModelInstance);
return (
<div>
<RiveComponent style={{ width: '400px', height: '400px' }} />
{(rive === null) ? <div data-testid="loading-text">Loading</div> : (
<div>
<label>
<input
data-testid="terms-checkbox"
type="checkbox"
checked={agreedToTerms ?? false}
onChange={(e) => setAgreedToTerms(e.target.checked)}
/>
Agree to Terms
</label>
<div data-testid="terms-value">{agreedToTerms ? 'true' : 'false'}</div>
</div>
)}
</div>
);
};
const colorNumberToHexString = (colorNum: number | null) => {
if (colorNum === null) {
return 'N/A';
}
const unsignedInt = colorNum >>> 0;
const r = (unsignedInt >> 16) & 0xff;
const g = (unsignedInt >> 8) & 0xff;
const b = unsignedInt & 0xff;
const toHex = (c: number) => c.toString(16).padStart(2, '0');
return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
};
export const ColorPropertyTest = ({ src }: { src: string }) => {
const { rive, RiveComponent } = useRive({
src,
autoplay: true,
artboard: "Artboard",
autoBind: true,
stateMachines: "State Machine 1",
});
const { value: colorNum, setValue: setColor, setRgb } = useViewModelInstanceColor('favColor', rive?.viewModelInstance);
return (
<div>
<RiveComponent style={{ width: '400px', height: '400px' }} />
{(rive === null) ? <div data-testid="loading-text">Loading</div> : (
<div>
<label>
Favorite Color:
<div data-testid="color-value" style={{
backgroundColor: typeof colorNum === 'string' ? colorNum : colorNumberToHexString(colorNum),
width: '20px',
height: '20px',
display: 'inline-block',
marginLeft: '10px'
}}></div>
<div data-testid="number-value">
Number value: {typeof colorNum === 'number' ? colorNum : 'N/A'}
</div>
<div data-testid="hex-value">
Hex value: {colorNumberToHexString(colorNum)}
</div>
</label>
<button
data-testid="set-color-red"
type="button"
onClick={() => setRgb(255, 0, 0)}
>
Red
</button>
<button
data-testid="set-color-blue"
type="button"
onClick={() => setRgb(0, 0, 255)}
>
Blue
</button>
</div>
)}
</div>
);
};
export const EnumPropertyTest = ({ src }: { src: string }) => {
const { rive, RiveComponent } = useRive({
src,
autoplay: true,
artboard: "Artboard",
autoBind: true,
stateMachines: "State Machine 1",
});
const { value: country, setValue: setCountry, values: countries } = useViewModelInstanceEnum('country', rive?.viewModelInstance);
return (
<div>
<RiveComponent style={{ width: '400px', height: '400px' }} />
{(rive === null) ? <div data-testid="loading-text">Loading</div> : (
<div>
<label>
Country:
<select
data-testid="country-select"
value={country || ''}
onChange={(e) => setCountry(e.target.value)}
>
{countries.map(c => (
<option key={c} value={c}>{c}</option>
))}
</select>
</label>
<div data-testid="country-value">{country}</div>
</div>
)}
</div>
);
};
export const NestedViewModelTest = ({ src }: { src: string }) => {
const { rive, RiveComponent } = useRive({
src,
autoplay: true,
artboard: "Artboard",
autoBind: true,
stateMachines: "State Machine 1",
});
const { value: drinkType, setValue: setDrinkType, values: drinkTypes } = useViewModelInstanceEnum('favDrink/type', rive?.viewModelInstance);
return (
<div>
<RiveComponent style={{ width: '400px', height: '400px' }} />
{(rive === null) ? <div data-testid="loading-text">Loading</div> : (
<div>
<label>
Favorite Drink Type:
<select
data-testid="drink-type-select"
value={drinkType || ''}
onChange={(e) => setDrinkType(e.target.value)}
>
{drinkTypes.map(dt => (
<option key={dt} value={dt}>{dt}</option>
))}
</select>
</label>
<div data-testid="drink-type-value">{drinkType}</div>
</div>
)}
</div>
);
};
export const TriggerPropertyTest = ({ src }: { src: string }) => {
const [callbackTriggered, setCallbackTriggered] = useState('');
const { rive, RiveComponent } = useRive({
src,
autoplay: true,
autoBind: true,
artboard: "Artboard",
stateMachines: "State Machine 1",
});
const { trigger: onFormSubmit } = useViewModelInstanceTrigger('onFormSubmit', rive?.viewModelInstance,
{
onTrigger: () => {
setCallbackTriggered('submit-callback');
}
}
);
const { trigger: onFormReset } = useViewModelInstanceTrigger('onFormReset', rive?.viewModelInstance,
{
onTrigger: () => {
setCallbackTriggered('reset-callback');
}
}
);
const handleSubmit = () => {
onFormSubmit();
};
const handleReset = () => {
onFormReset();
};
return (
<div>
<RiveComponent style={{ width: '400px', height: '400px' }} />
{(rive === null) ? <div data-testid="loading-text">Loading</div> : (
<div>
<button data-testid="submit-button" type="button" onClick={handleSubmit}>Submit</button>
<button data-testid="reset-button" type="button" onClick={handleReset}>Reset</button>
<div data-testid="callback-triggered">
Last callback triggered: {callbackTriggered || 'none'}
</div>
</div>
)}
</div>
);
};
export const PersonForm = ({ src }: { src: string }) => {
const { rive, RiveComponent } = useRive({
src,
autoplay: true,
autoBind: true,
artboard: "Artboard",
stateMachines: "State Machine 1",
});
const { value: name, setValue: setName } = useViewModelInstanceString('name', rive?.viewModelInstance);
const { value: age, setValue: setAge } = useViewModelInstanceNumber('age', rive?.viewModelInstance);
const { value: agreedToTerms, setValue: setAgreedToTerms } = useViewModelInstanceBoolean('agreedToTerms', rive?.viewModelInstance);
const { value: colorNum, setRgb } = useViewModelInstanceColor('favColor', rive?.viewModelInstance);
const { value: country, setValue: setCountry, values: countries } = useViewModelInstanceEnum('country', rive?.viewModelInstance);
const { trigger: onFormSubmit } = useViewModelInstanceTrigger('onFormSubmit', rive?.viewModelInstance);
const { trigger: onFormReset } = useViewModelInstanceTrigger('onFormReset', rive?.viewModelInstance);
// Drink properties (nested viewmodel)
const { value: drinkType, setValue: setDrinkType, values: drinkTypes } = useViewModelInstanceEnum('favDrink/type', rive?.viewModelInstance);
const handleReset = () => {
setName('');
setAge(0);
setAgreedToTerms(false);
setRgb(0, 0, 0);
setCountry(countries[0]);
setDrinkType(drinkTypes[0]);
onFormReset();
};
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
onFormSubmit();
};
return (
<div>
<RiveComponent style={{ width: '400px', height: '400px' }} />
{(rive === null) ? <div data-testid="loading-text">Loading</div> : (
<form onSubmit={handleSubmit}>
<div>
<label>
Name:
<input
data-testid="name-input"
type="text"
value={name || ''}
onChange={(e) => setName(e.target.value)}
/>
</label>
<div data-testid="name-value">{name}</div>
</div>
<div>
<label>
Age:
<input
data-testid="age-input"
type="number"
value={age || 0}
onChange={(e) => setAge(Number(e.target.value))}
/>
</label>
<div data-testid="age-value">{age}</div>
</div>
<div>
<label>
<input
data-testid="terms-checkbox"
type="checkbox"
checked={agreedToTerms || false}
onChange={(e) => setAgreedToTerms(e.target.checked)}
/>
Agree to Terms
</label>
<div data-testid="terms-value">{agreedToTerms ? 'true' : 'false'}</div>
</div>
<div>
<label>
Favorite Color:
<div data-testid="color-value" style={{
backgroundColor: colorNumberToHexString(colorNum),
width: '20px',
height: '20px',
display: 'inline-block',
marginLeft: '10px'
}}></div>
</label>
<button
data-testid="set-color-red"
type="button"
onClick={() => setRgb(255, 0, 0)}
>
Red
</button>
<button
data-testid="set-color-blue"
type="button"
onClick={() => setRgb(0, 0, 255)}
>
Blue
</button>
</div>
<div>
<label>
Country:
<select
data-testid="country-select"
value={country || ''}
onChange={(e) => setCountry(e.target.value)}
>
{countries.map(c => (
<option key={c} value={c}>{c}</option>
))}
</select>
</label>
<div data-testid="country-value">{country}</div>
</div>
<div>
<label>
Favorite Drink Type:
<select
data-testid="drink-type-select"
value={drinkType || ''}
onChange={(e) => setDrinkType(e.target.value)}
>
{drinkTypes.map(dt => (
<option key={dt} value={dt}>{dt}</option>
))}
</select>
</label>
<div data-testid="drink-type-value">{drinkType}</div>
</div>
<div>
<button data-testid="submit-button" type="submit">Submit</button>
<button data-testid="reset-button" type="button" onClick={handleReset}>Reset</button>
</div>
</form>
)}
</div>
);
};
// Component to demonstrate different viewmodel instances
export const PersonInstances = ({ src }: { src: string }) => {
const [activeInstance, setActiveInstance] = useState('Steve');
const [useDefaultInstance, setUseDefaultInstance] = useState(false);
const { rive, RiveComponent } = useRive({
src,
autoplay: true,
artboard: "Artboard",
stateMachines: "State Machine 1",
});
const viewModel = useViewModel(rive, { name: 'PersonViewModel' });
const params = useDefaultInstance ? { useDefault: true, rive } : { name: activeInstance, rive }
const viewModelInstance = useViewModelInstance(viewModel, params);
const { value: name } = useViewModelInstanceString('name', viewModelInstance);
const { value: age } = useViewModelInstanceNumber('age', viewModelInstance);
const { value: country } = useViewModelInstanceEnum('country', viewModelInstance);
const switchToNamedInstance = (instanceName: string) => {
setActiveInstance(instanceName);
setUseDefaultInstance(false);
};
const switchToDefaultInstance = () => {
setUseDefaultInstance(true);
};
return (
<div>
<RiveComponent style={{ width: '400px', height: '400px' }} />
{(rive === null) ? <div data-testid="loading-text">Loading</div> : (
<div>
<button
data-testid="select-steve"
onClick={() => switchToNamedInstance('Steve')}
disabled={!useDefaultInstance && activeInstance === 'Steve'}
>
Steve
</button>
<button
data-testid="select-jane"
onClick={() => switchToNamedInstance('Jane')}
disabled={!useDefaultInstance && activeInstance === 'Jane'}
>
Jane
</button>
<button
data-testid="select-default"
onClick={switchToDefaultInstance}
disabled={useDefaultInstance}
>
Default
</button>
</div>
)}
<div>
<h3 data-testid="instance-name">Instance: {useDefaultInstance ? 'Default' : activeInstance}</h3>
<p data-testid="person-name">Name: {name}</p>
<p data-testid="person-age">Age: {age}</p>
<p data-testid="person-country">Country: {country}</p>
</div>
</div>
);
};
export const ImagePropertyTest = ({ src }: { src: string }) => {
const [currentImageUrl, setCurrentImageUrl] = useState<string>('');
const [isLoading, setIsLoading] = useState<boolean>(false);
const { rive, RiveComponent } = useRive({
src,
artboard: "Artboard",
stateMachines: "State Machine 1",
autoplay: true,
autoBind: false,
});
const viewModel = useViewModel(rive, { name: 'Post' });
const viewModelInstance = useViewModelInstance(viewModel, { rive });
const { setValue: setImage } = useViewModelInstanceImage(
'image',
viewModelInstance
);
const loadRandomImage = async () => {
if (!setImage) return;
setIsLoading(true);
try {
const imageUrl = `https://picsum.photos/400/300?random=${Date.now()}`;
setCurrentImageUrl(imageUrl);
const response = await fetch(imageUrl);
const imageBuffer = await response.arrayBuffer();
const decodedImage = await decodeImage(new Uint8Array(imageBuffer));
setImage(decodedImage);
decodedImage.unref();
} catch (error) {
console.error('Failed to load image:', error);
} finally {
setIsLoading(false);
}
};
const clearImage = () => {
if (setImage) {
setImage(null);
setCurrentImageUrl('');
}
};
return (
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: '20px' }}>
<div style={{ width: '400px', height: '300px', border: '1px solid #ccc' }}>
<RiveComponent />
</div>
{rive === null ? (
<div data-testid="loading-text">Loading</div>
) : (
<div style={{ display: 'flex', gap: '10px', alignItems: 'center' }}>
<button
onClick={loadRandomImage}
disabled={isLoading}
data-testid="load-random-image"
>
{isLoading ? 'Loading...' : 'Load Random Image'}
</button>
<button
onClick={clearImage}
disabled={isLoading}
data-testid="clear-image"
>
Clear Image
</button>
</div>
)}
{currentImageUrl && (
<div style={{ fontSize: '12px', color: '#666' }}>
<span data-testid="current-image-url">Current image: {currentImageUrl}</span>
</div>
)}
</div>
);
};
// List Property Test
const TodoItemComponent = ({
index,
todoItem
}: {
index: number;
todoItem: ViewModelInstance | null;
}) => {
const { value: text, setValue: setText } = useViewModelInstanceString('text', todoItem);
const { value: isDone, setValue: setIsDone } = useViewModelInstanceBoolean('isDone', todoItem);
if (!todoItem) {
return <div data-testid={`todo-item-${index}`}>Item not found</div>;
}
return (
<div data-testid={`todo-item-${index}`} style={{
display: 'flex',
alignItems: 'center',
gap: '10px',
padding: '8px',
border: '1px solid #ccc',
marginBottom: '4px'
}}>
<input
data-testid={`todo-checkbox-${index}`}
type="checkbox"
checked={isDone ?? false}
onChange={(e) => setIsDone(e.target.checked)}
/>
<input
data-testid={`todo-text-${index}`}
type="text"
value={text || ''}
onChange={(e) => setText(e.target.value)}
style={{ flex: 1 }}
/>
<div data-testid={`todo-text-value-${index}`} style={{ fontSize: '12px', color: '#666' }}>
Text: {text}
</div>
<div data-testid={`todo-done-value-${index}`} style={{ fontSize: '12px', color: '#666' }}>
Done: {isDone ? 'true' : 'false'}
</div>
</div>
);
};
export const TodoListTest = ({ src }: { src: string }) => {
const { rive, RiveComponent } = useRive({
src,
autoplay: true,
artboard: "Artboard",
autoBind: false,
stateMachines: "State Machine 1",
});
const viewModel = useViewModel(rive, { name: 'TodoList' });
const viewModelInstance = useViewModelInstance(viewModel, { rive });
const {
length,
addInstance,
addInstanceAt,
removeInstance,
removeInstanceAt,
getInstanceAt,
swap
} = useViewModelInstanceList('items', viewModelInstance);
const handleAddItem = () => {
const todoItemViewModel = rive?.viewModelByName?.('TodoItem');
if (todoItemViewModel) {
const newTodoItem = todoItemViewModel.instance?.();
if (newTodoItem) {
addInstance(newTodoItem);
}
}
};
const handleAddItemAt = () => {
const todoItemViewModel = rive?.viewModelByName?.('TodoItem');
if (todoItemViewModel && length > 0) {
const newTodoItem = todoItemViewModel.instance?.();
if (newTodoItem) {
addInstanceAt(newTodoItem, 1);
}
}
};
const handleRemoveFirstInstance = () => {
const firstInstance = getInstanceAt(0);
if (firstInstance) {
removeInstance(firstInstance);
}
};
const handleRemoveFirstByIndex = () => {
if (length > 0) {
removeInstanceAt(0);
}
};
const handleSwapItems = () => {
if (length >= 2) {
swap(0, 1);
}
};
return (
<div>
<RiveComponent style={{ width: '400px', height: '400px' }} />
{rive === null ? (
<div data-testid="loading-text">Loading</div>
) : (
<div>
<div data-testid="list-length">Items: {length}</div>
<div style={{ marginBottom: '10px', display: 'flex', gap: '8px', flexWrap: 'wrap' }}>
<button
data-testid="add-item-button"
onClick={handleAddItem}
>
Add Item (End)
</button>
<button
data-testid="add-item-at-button"
onClick={handleAddItemAt}
disabled={length === 0}
>
Add Item at Index 1
</button>
<button
data-testid="remove-instance-button"
onClick={handleRemoveFirstInstance}
disabled={length === 0}
>
Remove First (by Instance)
</button>
<button
data-testid="remove-index-button"
onClick={handleRemoveFirstByIndex}
disabled={length === 0}
>
Remove First (by Index)
</button>
<button
data-testid="swap-button"
onClick={handleSwapItems}
disabled={length < 2}
>
Swap First Two
</button>
</div>
<div data-testid="todo-items">
{Array.from({ length }, (_, index) => (
<TodoItemComponent
key={index}
index={index}
todoItem={getInstanceAt(index)}
/>
))}
</div>
</div>
)}
</div>
);
};
export const ArtboardPropertyTest = ({ src }: { src: string }) => {
const [currentArtboard1, setCurrentArtboard1] = useState<string>('None');
const [currentArtboard2, setCurrentArtboard2] = useState<string>('None');
const { rive, RiveComponent } = useRive({
src,
autoplay: true,
artboard: "Main",
autoBind: true,
stateMachines: "State Machine 1",
});
const { setValue: setArtboard1 } = useViewModelInstanceArtboard('artboard_1', rive?.viewModelInstance);
const { setValue: setArtboard2 } = useViewModelInstanceArtboard('artboard_2', rive?.viewModelInstance);
const handleSetArtboard1 = (artboardName: string) => {
if (rive) {
const artboard = rive.getArtboard(artboardName);
setArtboard1(artboard);
setCurrentArtboard1(artboardName);
}
};
const handleSetArtboard2 = (artboardName: string) => {
if (rive) {
const artboard = rive.getArtboard(artboardName);
setArtboard2(artboard);
setCurrentArtboard2(artboardName);
}
};
return (
<div>
<RiveComponent style={{ width: '400px', height: '400px' }} />
{(rive === null) ? <div data-testid="loading-text">Loading</div> : (
<div>
<div style={{ marginBottom: '20px' }}>
<h4>Artboard 1:</h4>
<div style={{ display: 'flex', gap: '10px', marginBottom: '10px' }}>
<button
data-testid="set-artboard1-blue"
onClick={() => handleSetArtboard1('ArtboardBlue')}
>
Set Blue Artboard
</button>
<button
data-testid="set-artboard1-red"
onClick={() => handleSetArtboard1('ArtboardRed')}
>
Set Red Artboard
</button>
<button
data-testid="set-artboard1-green"
onClick={() => handleSetArtboard1('ArtboardGreen')}
>
Set Green Artboard
</button>
</div>
<div data-testid="artboard1-current">Current: {currentArtboard1}</div>
</div>
<div>
<h4>Artboard 2:</h4>
<div style={{ display: 'flex', gap: '10px', marginBottom: '10px' }}>
<button
data-testid="set-artboard2-blue"
onClick={() => handleSetArtboard2('ArtboardBlue')}
>
Set Blue Artboard
</button>
<button
data-testid="set-artboard2-red"
onClick={() => handleSetArtboard2('ArtboardRed')}
>
Set Red Artboard
</button>
<button
data-testid="set-artboard2-green"
onClick={() => handleSetArtboard2('ArtboardGreen')}
>
Set Green Artboard
</button>
</div>
<div data-testid="artboard2-current">Current: {currentArtboard2}</div>
</div>
</div>
)}
</div>
);
};

View File

@@ -0,0 +1,17 @@
import type { Meta, StoryObj } from '@storybook/react';
import Events from './Events';
const meta = {
title: 'Events',
component: Events,
parameters: {
layout: 'fullscreen',
},
args: {},
} satisfies Meta<typeof Events>;
export default meta;
type Story = StoryObj<typeof meta>;
export const Default: Story = {};

View File

@@ -0,0 +1,34 @@
import React, { useEffect } from 'react';
import { useRive, EventType, RiveEventType } from '@rive-app/react-canvas';
const Events = () => {
const { rive, RiveComponent } = useRive({
src: 'rating.riv',
stateMachines: 'State Machine 1',
autoplay: true,
automaticallyHandleEvents: true,
});
const onRiveEventReceived = (riveEvent: any) => {
console.log('Rive event received:', riveEvent);
const eventData = riveEvent.data;
const eventProperties = eventData.properties;
if (eventData.type === RiveEventType.General) {
console.log('Event name', eventData.name);
console.log('Rating', eventProperties.rating);
console.log('Message', eventProperties.message);
}
};
// Wait until the rive object is instantiated before adding the Rive
// event listener
useEffect(() => {
if (rive) {
rive.on(EventType.RiveEvent, onRiveEventReceived);
}
}, [rive]);
return <RiveComponent />;
};
export default Events;

View File

@@ -0,0 +1,17 @@
import type { Meta, StoryObj } from '@storybook/react';
import Http from './Http';
const meta = {
title: 'Http',
component: Http,
parameters: {
layout: 'fullscreen',
},
args: {},
} satisfies Meta<typeof Http>;
export default meta;
type Story = StoryObj<typeof meta>;
export const Default: Story = {};

View File

@@ -0,0 +1,14 @@
import React from 'react';
import { useRive } from '@rive-app/react-canvas';
const Http = () => {
const { RiveComponent } = useRive({
src: 'https://cdn.rive.app/animations/vehicles.riv',
stateMachines: 'bumpy',
autoplay: true,
});
return <RiveComponent />;
};
export default Http;

View File

@@ -0,0 +1,17 @@
import type { Meta, StoryObj } from '@storybook/react';
import ResponsiveLayout from './ResponsiveLayout';
const meta = {
title: 'ResponsiveLayout',
component: ResponsiveLayout,
parameters: {
layout: 'fullscreen',
},
args: {},
} satisfies Meta<typeof ResponsiveLayout>;
export default meta;
type Story = StoryObj<typeof meta>;
export const Default: Story = {};

View File

@@ -0,0 +1,18 @@
import React from 'react';
import { Fit, useRive, Layout } from '@rive-app/react-canvas';
const ResponsiveLayout = () => {
const { RiveComponent } = useRive({
src: 'layout_test.riv',
artboard: 'Artboard',
stateMachines: 'State Machine 1',
autoplay: true,
layout: new Layout({
fit: Fit.Layout,
}),
});
return <RiveComponent />;
};
export default ResponsiveLayout;

View File

@@ -0,0 +1,17 @@
import type { Meta, StoryObj } from '@storybook/react';
import Simple from './Simple';
const meta = {
title: 'Simple',
component: Simple,
parameters: {
layout: 'fullscreen',
},
args: {},
} satisfies Meta<typeof Simple>;
export default meta;
type Story = StoryObj<typeof meta>;
export const Default: Story = {};

View File

@@ -0,0 +1,14 @@
import React from 'react';
import { useRive } from '@rive-app/react-canvas';
const Simple = () => {
const { RiveComponent } = useRive({
src: 'avatars.riv',
artboard: 'Avatar 3',
autoplay: true,
});
return <RiveComponent />;
};
export default Simple;

View File

@@ -1,14 +0,0 @@
# State Machine Boolean Input
This example shows how to interact with a state machine, using various onMouse\* callbacks to trigger transations.
## To Run
This example is created using [Create React App](https://reactjs.org/docs/create-a-new-react-app.html).
To install and run:
```
npm install
npm start
```

View File

@@ -1,36 +0,0 @@
{
"name": "state-machine-boolean-input",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.13.0",
"@testing-library/react": "^11.2.7",
"@testing-library/user-event": "^12.8.3",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3",
"rive-react": "latest",
"web-vitals": "^1.1.2"
},
"scripts": {
"start": "SKIP_PREFLIGHT_CHECK=true react-scripts start"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}

View File

@@ -1,17 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<title>Rive React - State Machine Boolean Input</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
</body>
</html>

View File

Binary file not shown.

View File

@@ -1,58 +0,0 @@
import { useRive, useStateMachineInput } from 'rive-react';
function App() {
const STATE_MACHINE_NAME = 'State Machine 1';
const ON_HOVER_INPUT_NAME = 'Hover';
const ON_PRESSED_INPUT_NAME = 'Pressed';
const { RiveComponent, rive } = useRive({
src: 'like.riv',
stateMachines: STATE_MACHINE_NAME,
artboard: 'New Artboard',
autoplay: true,
});
// Both onHoverInput and onPressedInput are boolean inputs. To transition
// states we need to set the value property to true or false.
const onHoverInput = useStateMachineInput(
rive,
STATE_MACHINE_NAME,
ON_HOVER_INPUT_NAME
);
const onPressedInput = useStateMachineInput(
rive,
STATE_MACHINE_NAME,
ON_PRESSED_INPUT_NAME
);
function onMouseEnter() {
onHoverInput.value = true;
}
function onMouseLeave() {
onHoverInput.value = false;
}
function onMouseDown() {
onPressedInput.value = true;
}
function onMouseUp() {
onPressedInput.value = false;
}
return (
// The animation will fit to the parent element, so we set a large height
// and width for this example.
<div style={{ height: '500px', width: '500px' }}>
<RiveComponent
onMouseEnter={onMouseEnter}
onMouseLeave={onMouseLeave}
onMouseDown={onMouseDown}
onMouseUp={onMouseUp}
/>
</div>
);
}
export default App;

View File

@@ -1,10 +0,0 @@
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
);

View File

@@ -1,14 +0,0 @@
# State Machine Number Input
This example shows how to interact with a state machine with number inputs. We trigger the transistions by changing the value of a number input.
## To Run
This example is created using [Create React App](https://reactjs.org/docs/create-a-new-react-app.html).
To install and run:
```
npm install
npm start
```

View File

@@ -1,36 +0,0 @@
{
"name": "state-machine-number-input",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.13.0",
"@testing-library/react": "^11.2.7",
"@testing-library/user-event": "^12.8.3",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3",
"rive-react": "latest",
"web-vitals": "^1.1.2"
},
"scripts": {
"start": "SKIP_PREFLIGHT_CHECK=true react-scripts start"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}

View File

@@ -1,17 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<title>Rive React - State Machine Number Input</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
</body>
</html>

View File

Binary file not shown.

View File

@@ -1,34 +0,0 @@
import { useRive, useStateMachineInput } from 'rive-react';
function App() {
const STATE_MACHINE_NAME = 'State Machine ';
const INPUT_NAME = 'Level';
const { RiveComponent, rive } = useRive({
src: 'skills.riv',
stateMachines: STATE_MACHINE_NAME,
artboard: 'New Artboard',
autoplay: true,
});
// levelInput is a number state machine input. To transition the state machine,
// we need to set the value to a number. For this state machine input, we need
// to set to 0, 1 or 2 for a state transition to occur.
const levelInput = useStateMachineInput(rive, STATE_MACHINE_NAME, INPUT_NAME);
return (
// The animation will fit to the parent element, so we set a large height
// and width for this example.
<div style={{ height: '500px', width: '500px' }}>
<RiveComponent />
<div>
Level:
<button onClick={() => (levelInput.value = 0)}>0</button>
<button onClick={() => (levelInput.value = 1)}>1</button>
<button onClick={() => (levelInput.value = 2)}>2</button>
</div>
</div>
);
}
export default App;

View File

@@ -1,10 +0,0 @@
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
);

View File

@@ -1,14 +0,0 @@
# State Machine Trigger Input
This example shows how to interact with a state machine with a trigger input. We call the `fire()` function on the state machine input to transition the state when the animation is clicked.
## To Run
This example is created using [Create React App](https://reactjs.org/docs/create-a-new-react-app.html).
To install and run:
```
npm install
npm start
```

View File

@@ -1,36 +0,0 @@
{
"name": "state-machine-trigger-input",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.13.0",
"@testing-library/react": "^11.2.7",
"@testing-library/user-event": "^12.8.3",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3",
"rive-react": "latest",
"web-vitals": "^1.1.2"
},
"scripts": {
"start": "SKIP_PREFLIGHT_CHECK=true react-scripts start"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}

View File

@@ -1,17 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<title>Rive React - State Machine Trigger Input</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
</body>
</html>

View File

@@ -1,31 +0,0 @@
import { useRive, useStateMachineInput } from 'rive-react';
function App() {
const STATE_MACHINE_NAME = 'State Machine 1';
const INPUT_NAME = 'Pressed';
const { RiveComponent, rive } = useRive({
src: 'piggy-bank.riv',
stateMachines: STATE_MACHINE_NAME,
artboard: 'New Artboard',
autoplay: true,
});
// pressedInput in a trigger state machine input. To transition the state
// we need to call the `fire()` method on the input.
const pressedInput = useStateMachineInput(
rive,
STATE_MACHINE_NAME,
INPUT_NAME
);
return (
// The animation will fit to the parent element, so we set a large height
// and width for this example.
<div style={{ height: '500px', width: '500px' }}>
<RiveComponent onClick={() => pressedInput.fire()} />
</div>
);
}
export default App;

View File

@@ -1,10 +0,0 @@
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
);

View File

@@ -6,6 +6,12 @@
"dom.iterable",
"esnext"
],
"paths": {
"@rive-app/react-canvas": ["../"],
"@rive-app/react-webgl": ["../"],
"@rive-app/react-webgl2": ["../"],
"@rive-app/react-canvas-lite": ["../"]
},
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,

12307
examples/yarn.lock Normal file
View File

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,9 @@
# @rive-app/react-canvas-lite
Output for `rive-react` using the backing `@rive-app/canvas-lite` JS runtime.
## Why Lite?
The current `@rive-app/react-canvas` dependency supports all Rive features and contains the necessary backing dependencies to render those graphics. This `lite` version has the same API, but does not compile and build with certain dependencies in order to keep the package size as small as possible.
At this time, this lite version of `@rive-app/react-canvas-lite` will not render Rive Text onto the canvas or play Rive Audio. Note however, that even if your Rive file may include Rive Text components, rendering the graphic should not cause any app errors, or cease to render. The same is true for playing audio.

View File

@@ -0,0 +1,26 @@
{
"name": "@rive-app/react-canvas-lite",
"version": "4.26.0",
"description": "React wrapper around the @rive-app/canvas-lite library",
"main": "dist/index.js",
"typings": "dist/types/index.d.ts",
"files": [
"dist/**"
],
"repository": {
"type": "git",
"url": "git+https://github.com/rive-app/rive-react.git"
},
"author": "",
"license": "MIT",
"bugs": {
"url": "https://github.com/rive-app/rive-react/issues"
},
"homepage": "https://github.com/rive-app/rive-react#readme",
"dependencies": {
"@rive-app/canvas-lite": "2.34.0"
},
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0"
}
}

View File

@@ -0,0 +1,3 @@
# @rive-app/react-canvas
Output for `rive-react` using the backing `@rive-app/canvas` JS runtime

View File

@@ -0,0 +1,26 @@
{
"name": "@rive-app/react-canvas",
"version": "4.26.0",
"description": "React wrapper around the @rive-app/canvas library",
"main": "dist/index.js",
"typings": "dist/types/index.d.ts",
"files": [
"dist/**"
],
"repository": {
"type": "git",
"url": "git+https://github.com/rive-app/rive-react.git"
},
"author": "",
"license": "MIT",
"bugs": {
"url": "https://github.com/rive-app/rive-react/issues"
},
"homepage": "https://github.com/rive-app/rive-react#readme",
"dependencies": {
"@rive-app/canvas": "2.34.0"
},
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0"
}
}

View File

@@ -0,0 +1,3 @@
# @rive-app/react-webgl
Output for `rive-react` using the backing `@rive-app/webgl` JS runtime

View File

@@ -0,0 +1,26 @@
{
"name": "@rive-app/react-webgl",
"version": "4.26.0",
"description": "React wrapper around the @rive-app/webgl library",
"main": "dist/index.js",
"typings": "dist/types/index.d.ts",
"files": [
"dist/**"
],
"repository": {
"type": "git",
"url": "git+https://github.com/rive-app/rive-react.git"
},
"author": "",
"license": "MIT",
"bugs": {
"url": "https://github.com/rive-app/rive-react/issues"
},
"homepage": "https://github.com/rive-app/rive-react#readme",
"dependencies": {
"@rive-app/webgl": "2.34.0"
},
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0"
}
}

View File

View File

@@ -0,0 +1,26 @@
{
"name": "@rive-app/react-webgl2",
"version": "4.26.0",
"description": "React wrapper around the @rive-app/webgl2 library",
"main": "dist/index.js",
"typings": "dist/types/index.d.ts",
"files": [
"dist/**"
],
"repository": {
"type": "git",
"url": "git+https://github.com/rive-app/rive-react.git"
},
"author": "",
"license": "MIT",
"bugs": {
"url": "https://github.com/rive-app/rive-react/issues"
},
"homepage": "https://github.com/rive-app/rive-react#readme",
"dependencies": {
"@rive-app/webgl2": "2.34.0"
},
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0"
}
}

18693
package-lock.json generated
View File

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "rive-react",
"version": "0.0.26",
"version": "4.26.0",
"description": "React wrapper around the rive-js library",
"main": "dist/index.js",
"typings": "dist/types/index.d.ts",
@@ -10,10 +10,19 @@
"scripts": {
"test": "jest",
"build": "bunchee src/index.ts -m --no-sourcemap",
"dev": "watch 'npm run build' src",
"lint": "eslint -c .eslintrc.js 'src/**/*{.ts,.tsx}'",
"format": "prettier --write src",
"types:check": "tsc --noEmit",
"release": "release-it"
"release": "release-it",
"release:patch": "npm run release -- --ci",
"release:minor": "npm run release -- minor --ci",
"release:major": "npm run release -- major --ci",
"setup-builds": "./scripts/build.sh",
"setup-packages": "./scripts/setup_all_packages.sh",
"bump-versions": "./scripts/bump_all_versions.sh $npm_package_version",
"publish:all": "./scripts/publish_all.sh --access public",
"storybook": "yarn --cwd examples storybook"
},
"repository": {
"type": "git",
@@ -26,22 +35,28 @@
},
"homepage": "https://github.com/rive-app/rive-react#readme",
"dependencies": {
"rive-js": "0.7.33"
"@rive-app/canvas": "2.34.0",
"@rive-app/canvas-lite": "2.34.0",
"@rive-app/webgl": "2.34.0",
"@rive-app/webgl2": "2.34.0"
},
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0"
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0"
},
"devDependencies": {
"@babel/core": "^7.18.0",
"@testing-library/jest-dom": "^5.13.0",
"@testing-library/react": "^11.2.7",
"@testing-library/react-hooks": "^7.0.0",
"@types/jest": "^26.0.23",
"@types/react": "^17.0.9",
"@testing-library/react": "^16.3.0",
"@types/jest": "^27.0.3",
"@types/node": "^18.17.0",
"@types/offscreencanvas": "^2019.6.4",
"@types/react": "^18.0.0",
"@types/testing-library__jest-dom": "^5.9.5",
"@typescript-eslint/eslint-plugin": "^4.26.0",
"@typescript-eslint/parser": "^4.26.0",
"@typescript-eslint/eslint-plugin": "^5.7.0",
"@typescript-eslint/parser": "^5.7.0",
"auto-changelog": "^2.3.0",
"bunchee": "^1.6.0",
"babel-loader": "^8.2.5",
"bunchee": "1.8.5",
"eslint": "^7.28.0",
"eslint-config-prettier": "^8.3.0",
"eslint-config-standard": "^16.0.3",
@@ -49,12 +64,16 @@
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-promise": "^5.1.0",
"eslint-plugin-react": "^7.24.0",
"eslint-plugin-react": "^7.27.1",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-storybook": "^0.5.12",
"jest": "^27.0.4",
"prettier": "^2.3.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"release-it": "^14.10.0",
"ts-jest": "^27.0.2"
"ts-jest": "^27.1.1",
"typescript": "^4.5.4",
"watch": "^1.0.2"
}
}

42
scripts/build.sh Executable file
View File

@@ -0,0 +1,42 @@
#!/bin/bash
set -e
# Copy the build to each react-variant build for npm release
cp -r ./dist ./npm/react-webgl
cp -r ./dist ./npm/react-canvas
cp -r ./dist ./npm/react-canvas-lite
cp -r ./dist ./npm/react-webgl2
echo "Replacing the canvas with webgl references in react-webgl"
pushd ./npm/react-webgl/dist
if [[ "$OSTYPE" == "darwin"* ]]; then
find . -type f -name "*.ts" -print0 | xargs -0 sed -i '' -e 's/@rive-app\/canvas/@rive-app\/webgl/g'
find . -type f -name "*.js" -print0 | xargs -0 sed -i '' -e 's/@rive-app\/canvas/@rive-app\/webgl/g'
else
find . -type f -name "*.ts" -print0 | xargs -0 sed -i -e 's/@rive-app\/canvas/@rive-app\/webgl/g'
find . -type f -name "*.js" -print0 | xargs -0 sed -i -e 's/@rive-app\/canvas/@rive-app\/webgl/g'
fi
popd
echo "Replacing the canvas with webgl2 references in react-webgl2"
pushd ./npm/react-webgl2/dist
if [[ "$OSTYPE" == "darwin"* ]]; then
find . -type f -name "*.ts" -print0 | xargs -0 sed -i '' -e 's/@rive-app\/canvas/@rive-app\/webgl2/g'
find . -type f -name "*.js" -print0 | xargs -0 sed -i '' -e 's/@rive-app\/canvas/@rive-app\/webgl2/g'
else
find . -type f -name "*.ts" -print0 | xargs -0 sed -i -e 's/@rive-app\/canvas/@rive-app\/webgl2/g'
find . -type f -name "*.js" -print0 | xargs -0 sed -i -e 's/@rive-app\/canvas/@rive-app\/webgl2/g'
fi
popd
echo "Replacing the canvas with canvas-lite references in react-canvas-lite"
pushd ./npm/react-canvas-lite/dist
if [[ "$OSTYPE" == "darwin"* ]]; then
find . -type f -name "*.ts" -print0 | xargs -0 sed -i '' -e 's/@rive-app\/canvas/@rive-app\/canvas-lite/g'
find . -type f -name "*.js" -print0 | xargs -0 sed -i '' -e 's/@rive-app\/canvas/@rive-app\/canvas-lite/g'
else
find . -type f -name "*.ts" -print0 | xargs -0 sed -i -e 's/@rive-app\/canvas/@rive-app\/canvas-lite/g'
find . -type f -name "*.js" -print0 | xargs -0 sed -i -e 's/@rive-app\/canvas/@rive-app\/canvas-lite/g'
fi
popd

10
scripts/publish_all.sh Executable file
View File

@@ -0,0 +1,10 @@
#!/bin/bash
set -e
# Bump the version number of every npm module in the npm folder.
for dir in ./npm/*; do
pushd $dir > /dev/null
echo Publishing `echo $dir | sed 's:.*/::'`
npm publish $@
popd > /dev/null
done

24
scripts/setup_all_packages.sh Executable file
View File

@@ -0,0 +1,24 @@
#!/bin/bash
set -e
echo "Copying package.json to rive-react npm package folders"
# Bump the version number of every npm module in the npm folder.
for dir in ./npm/*; do
echo $dir
pushd $dir > /dev/null
echo $dir
if [ -f "./package.json" ]; then
echo "Removing existing package.json..."
rm "./package.json"
echo "package.json deleted from $dir"
fi
cp ../../package.json ./
repo_name=`echo $dir | sed 's:.*/::' | sed 's/_/-/g'`
echo Setting package.json on npm packages
echo $repo_name
../../scripts/setup_package.sh $repo_name
echo Finished setting up package.json
popd > /dev/null
done

6
scripts/setup_package.sh Executable file
View File

@@ -0,0 +1,6 @@
#!/bin/bash
set -e
# Setup the package.json for a given npm module
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
node $SCRIPT_DIR/trimPackageJson.js `pwd` "$1"

View File

@@ -0,0 +1,23 @@
const fs = require('fs');
const path = process.argv[2];
const npmPackageSplit = process.argv[3].split('-');
// extracts "webgl" or "canvas-lite" from the npm package name
const renderer = npmPackageSplit.slice(1).join('-');
const package = require(path + '/package.json');
function trimNpmPackage() {
package.name = `@rive-app/react-${renderer}`;
package.description = `React wrapper around the @rive-app/${renderer} library`;
const webDependencyName = `@rive-app/${renderer}`;
const canvasDep = package.dependencies[webDependencyName];
package.dependencies = {
[webDependencyName]: canvasDep,
};
delete package.devDependencies;
delete package.scripts;
fs.writeFileSync(path + '/package.json', JSON.stringify(package, null, 2));
}
if (renderer) {
trimNpmPackage();
}

Some files were not shown because too many files have changed in this diff Show More