1+ "use client" ;
2+
3+ import React , { useEffect , useState } from "react" ;
14import { Container , Flex , Group , Stack , Text } from "@mantine/core" ;
25import classes from "./compatibility.module.css" ;
36import { AvmBlock } from "@/app/compatibility/avm" ;
47import Image from "next/image" ;
5- import React from "react" ;
68import { Title } from "@mantine/core" ;
79import { List , ListItem } from "@mantine/core" ;
810import { WeeklyContributions } from "@/app/compatibility/weekly_contributions" ;
911import {
10- fetchReport ,
1112 getAVM1Progress ,
1213 getWeeklyContributions ,
1314} from "@/app/downloads/github" ;
15+ import { useTranslation , Trans } from "@/app/translate" ;
16+
17+ interface DataPoint {
18+ week : string ;
19+ Commits : number ;
20+ }
21+
22+ export default function Downloads ( ) {
23+ const { t } = useTranslation ( ) ;
24+ const [ data , setData ] = useState < DataPoint [ ] > ( [ ] ) ;
25+ const [ avm1ApiDone , setAvm1ApiDone ] = useState < number > ( 0 ) ;
26+ const [ avm2ApiDone , setAvm2ApiDone ] = useState < number > ( 0 ) ;
27+ const [ avm2ApiStubbed , setAvm2ApiStubbed ] = useState < number > ( 0 ) ;
28+ useEffect ( ( ) => {
29+ const fetchData = async ( ) => {
30+ try {
31+ // Fetch weekly contributions
32+ const contributionsRes = await getWeeklyContributions ( ) ;
33+ const contributionsData = contributionsRes . data . map ( ( item ) => ( {
34+ week : new Date ( item . week * 1000 ) . toISOString ( ) . split ( "T" ) [ 0 ] ,
35+ Commits : item . total ,
36+ } ) ) ;
37+ setData ( contributionsData ) ;
38+
39+ // Fetch AVM1 progress
40+ const avm1ApiRes = await getAVM1Progress ( ) ;
41+ setAvm1ApiDone ( avm1ApiRes ) ;
1442
15- export default async function Downloads ( ) {
16- const contributions = await getWeeklyContributions ( ) ;
17- const data = contributions . data . map ( ( item ) => {
18- return {
19- week : new Date ( item . week * 1000 ) . toISOString ( ) . split ( "T" ) [ 0 ] ,
20- Commits : item . total ,
43+ // Fetch report
44+ const reportReq = await fetch ( "/compatibility/fetch-report" ) ;
45+ const reportRes = await reportReq . json ( ) ;
46+ if ( reportRes ) {
47+ const { summary } = reportRes ;
48+ const maxPoints = summary . max_points ;
49+ const implPoints = summary . impl_points ;
50+ const stubPenalty = summary . stub_penalty ;
51+
52+ const avm2ApiDone = Math . round (
53+ ( ( implPoints - stubPenalty ) / maxPoints ) * 100 ,
54+ ) ;
55+ setAvm2ApiDone ( avm2ApiDone ) ;
56+
57+ const avm2ApiStubbed = Math . round ( ( stubPenalty / maxPoints ) * 100 ) ;
58+ setAvm2ApiStubbed ( avm2ApiStubbed ) ;
59+ }
60+ } catch ( error ) {
61+ console . error ( "Error fetching data" , error ) ;
62+ }
2163 } ;
22- } ) ;
23- const avm1ApiDone = await getAVM1Progress ( ) ;
24- const report = await fetchReport ( ) ;
25- if ( ! report ) {
26- return ;
27- }
28- const summary = report . summary ;
29- const maxPoints = summary . max_points ;
30- const implPoints = summary . impl_points ;
31- const stubPenalty = summary . stub_penalty ;
32- const avm2ApiDone = Math . round (
33- ( ( implPoints - stubPenalty ) / maxPoints ) * 100 ,
34- ) ;
35- const avm2ApiStubbed = Math . round ( ( stubPenalty / maxPoints ) * 100 ) ;
64+
65+ fetchData ( ) ;
66+ } , [ ] ) ;
3667
3768 return (
3869 < Container size = "xl" className = { classes . container } >
@@ -47,27 +78,23 @@ export default async function Downloads() {
4778 className = { classes . actionscriptImage }
4879 />
4980 < Stack className = { classes . actionscriptInfo } >
50- < Title className = { classes . title } > ActionScript Compatibility</ Title >
51- < Text >
52- The biggest factor in content compatibility is ActionScript; the
53- language that powers interactivity in games and applications made
54- with Flash. All Flash content falls in one of two categories,
55- depending on which version of the language was used to create it.
56- </ Text >
57- < Text >
58- We track our progress in each AVM by splitting them up into two
59- different areas:
60- </ Text >
81+ < Title className = { classes . title } > { t ( "compatibility.title" ) } </ Title >
82+ < Text > { t ( "compatibility.description" ) } </ Text >
83+ < Text > { t ( "compatibility.tracking" ) } </ Text >
6184 < List >
6285 < ListItem >
63- The < b > Language</ b > is the underlying virtual machine itself and
64- the language concepts that it understands, like variables and
65- classes and how they all interact together.
86+ < Trans
87+ i18nKey = "compatibility.language-description"
88+ components = { [
89+ < b key = "language" > { t ( "compatibility.language" ) } </ b > ,
90+ ] }
91+ />
6692 </ ListItem >
6793 < ListItem >
68- The < b > API</ b > is the original built-in methods and classes that
69- are available for this AVM, like the ability to interact with
70- objects on the stage or make web requests.
94+ < Trans
95+ i18nKey = "compatibility.api-description"
96+ components = { [ < b key = "api" > { t ( "compatibility.api" ) } </ b > ] }
97+ />
7198 </ ListItem >
7299 </ List >
73100 </ Stack >
@@ -81,53 +108,33 @@ export default async function Downloads() {
81108 className = { classes . avms }
82109 >
83110 < AvmBlock
84- name = "AVM 1: ActionScript 1 & 2 "
111+ name = "compatibility.avm1 "
85112 language = { { done : 95 } }
86113 api = { { done : avm1ApiDone } }
87114 info_link_target = "_blank"
88115 info_link = "https://github.com/ruffle-rs/ruffle/issues/310"
89116 >
90- < Text >
91- AVM 1 is the original ActionScript Virtual Machine. All movies
92- made before Flash Player 9 (June 2006) will be made with AVM 1,
93- and it remained supported & available to authors until the
94- release of Flash Professional CC (2013), after which point content
95- started moving to AVM 2.
96- </ Text >
97- < Text >
98- We believe that most AVM 1 content will work, but we are aware of
99- some graphical inaccuracies and smaller bugs here and there.
100- Please feel free to report any issues you find that are not
101- present in the original Flash Player!
102- </ Text >
117+ < Text > { t ( "compatibility.avm1-description" ) } </ Text >
118+ < Text > { t ( "compatibility.avm1-support" ) } </ Text >
103119 </ AvmBlock >
104120
105121 < AvmBlock
106- name = "AVM 2: ActionScript 3 "
122+ name = "compatibility.avm2 "
107123 language = { { done : 90 } }
108124 api = { { done : avm2ApiDone , stubbed : avm2ApiStubbed } }
109125 info_link = "/compatibility/avm2"
110126 >
111- < Text >
112- AVM 2 was introduced with Flash Player 9 (June 2006), to replace
113- the earlier AVM 1. After the release of Flash Professional CC
114- (2013), authors are required to use ActionScript 3 - making any
115- movie made after that date very likely to fall under this
116- category.
117- </ Text >
118- < Text >
119- Ruffle now has decent support for AVM 2, and it's our
120- experience that most games will work well enough to be played.
121- We're still rapidly improving in this area though, so bug
122- reports about any broken content are always welcome!
123- </ Text >
127+ < Text > { t ( "compatibility.avm2-description" ) } </ Text >
128+ < Text > { t ( "compatibility.avm2-support" ) } </ Text >
124129 </ AvmBlock >
125130 </ Flex >
126131
127- < Stack w = "100%" align = "center" >
128- < Title order = { 2 } > Weekly Contributions</ Title >
129- < WeeklyContributions data = { data } />
130- </ Stack >
132+ { data && (
133+ < Stack w = "100%" align = "center" >
134+ < Title order = { 2 } > { t ( "compatibility.weekly-contributions" ) } </ Title >
135+ < WeeklyContributions data = { data } />
136+ </ Stack >
137+ ) }
131138 </ Stack >
132139 </ Container >
133140 ) ;
0 commit comments