1
+ "use client" ;
2
+
3
+ import React , { useEffect , useState } from "react" ;
1
4
import { Container , Flex , Group , Stack , Text } from "@mantine/core" ;
2
5
import classes from "./compatibility.module.css" ;
3
6
import { AvmBlock } from "@/app/compatibility/avm" ;
4
7
import Image from "next/image" ;
5
- import React from "react" ;
6
8
import { Title } from "@mantine/core" ;
7
9
import { List , ListItem } from "@mantine/core" ;
8
10
import { WeeklyContributions } from "@/app/compatibility/weekly_contributions" ;
9
11
import {
10
- fetchReport ,
11
12
getAVM1Progress ,
12
13
getWeeklyContributions ,
13
14
} 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 ) ;
14
42
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
+ }
21
63
} ;
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
+ } , [ ] ) ;
36
67
37
68
return (
38
69
< Container size = "xl" className = { classes . container } >
@@ -47,27 +78,23 @@ export default async function Downloads() {
47
78
className = { classes . actionscriptImage }
48
79
/>
49
80
< 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 >
61
84
< List >
62
85
< 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
+ />
66
92
</ ListItem >
67
93
< 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
+ />
71
98
</ ListItem >
72
99
</ List >
73
100
</ Stack >
@@ -81,53 +108,33 @@ export default async function Downloads() {
81
108
className = { classes . avms }
82
109
>
83
110
< AvmBlock
84
- name = "AVM 1: ActionScript 1 & 2 "
111
+ name = "compatibility.avm1 "
85
112
language = { { done : 95 } }
86
113
api = { { done : avm1ApiDone } }
87
114
info_link_target = "_blank"
88
115
info_link = "https://github.com/ruffle-rs/ruffle/issues/310"
89
116
>
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 >
103
119
</ AvmBlock >
104
120
105
121
< AvmBlock
106
- name = "AVM 2: ActionScript 3 "
122
+ name = "compatibility.avm2 "
107
123
language = { { done : 90 } }
108
124
api = { { done : avm2ApiDone , stubbed : avm2ApiStubbed } }
109
125
info_link = "/compatibility/avm2"
110
126
>
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 >
124
129
</ AvmBlock >
125
130
</ Flex >
126
131
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
+ ) }
131
138
</ Stack >
132
139
</ Container >
133
140
) ;
0 commit comments