@@ -8,19 +8,27 @@ class Snapshot {
88 get id ( ) : number { return ( this . year - 10 ) * 52 + this . week }
99}
1010
11+ const LATEST = { resource : 7 , data : 7 }
12+
1113const RELEASES : Record < number , VersionName [ ] > = {
1214 1 : [ '1.6.x' , '1.7.x' , '1.8.x' ] ,
1315 2 : [ '1.9.x' , '1.10.x' ] ,
1416 3 : [ '1.11.x' , '1.12.x' ] ,
1517 4 : [ '1.13.x' , '1.14.x' ] ,
1618 5 : [ '1.15.x' , '1.16.0' , '1.16.1' ] ,
1719 6 : [ '1.16.x' ] ,
18- 7 : [ '1.17.x' ] ,
20+ 7 : [ '1.17.x' , '1.18.0' ] ,
21+ }
22+
23+ const SPECIAL : Record < number , string [ ] > = {
24+ 4 : [ 'combat1' , 'combat2' , 'combat3' ] ,
25+ 5 : [ 'combat4' , 'combat5' ] ,
26+ 6 : [ 'combat6' , 'combat7a' , 'combat7b' , 'combat8a' , 'combat8b' , 'combat8c' ] ,
1927}
2028
21- const d = new Date ( )
22- const fauxCurrentSnapshot = ( d . getFullYear ( ) - 2000 ) + 'w' + ( ( d . getMonth ( ) + 1 ) * 5 ) . toString ( ) . padStart ( 2 , '0' ) + 'a' as SnapshotName
23- const START_SNAPSHOTS : Record < SnapshotName | string , Record < PackType , FormatResult > > = {
29+ const d = new Date ( ) , year = d . getFullYear ( ) - 2000 , maxWeek = ( d . getMonth ( ) + 1 ) * 5
30+ const fauxCurrentSnapshot : SnapshotName = ` ${ year } w ${ maxWeek . toString ( ) . padStart ( 2 , '0' ) } a`
31+ const START_SNAPSHOTS : Record < SnapshotName , Record < PackType , FormatResult > > = {
2432 '13w24a' : { resource : 1 , data : undefined } ,
2533 '15w31a' : { resource : 2 , data : undefined } ,
2634 '16w32a' : { resource : 3 , data : undefined } ,
@@ -31,19 +39,23 @@ const START_SNAPSHOTS: Record<SnapshotName | string, Record<PackType, FormatResu
3139 [ fauxCurrentSnapshot ] : { resource : undefined , data : undefined } ,
3240}
3341
34- const LATEST = { resource : 7 , data : 7 }
35-
3642function getPackFormat ( version : string , type : PackType = 'resource' ) : FormatResult {
3743 if ( ! version ) return undefined
3844 version = version . toString ( ) . toLowerCase ( ) . trim ( )
3945
46+ // Special //
47+ for ( const format in SPECIAL ) {
48+ if ( SPECIAL [ format ] . includes ( version ) ) return + format ;
49+ }
50+
4051 // Snapshot //
4152
4253 if ( / ^ \d \d [ w ] \d \d [ a - z ] $ / . test ( version ) ) {
4354 const snapshot = new Snapshot ( version )
4455 let ver : FormatResult
45- for ( let testSnap of Object . keys ( START_SNAPSHOTS ) ) {
56+ for ( const testSnap in START_SNAPSHOTS ) {
4657 if ( snapshot . id >= ( new Snapshot ( testSnap ) ) . id ) {
58+ // @ts -ignore: #45159
4759 ver = START_SNAPSHOTS [ testSnap ] [ type ]
4860 }
4961 }
@@ -58,14 +70,14 @@ function getPackFormat(version: string, type: PackType = 'resource'): FormatResu
5870 if ( version . includes ( '1.16.2-pre' ) ) return 5
5971 else version = version . replace ( / - .+ $ / , '' )
6072 }
61- if ( version . match ( / ^ \d + \. \d + $ / ) ) version += '.0'
73+ if ( / ^ \d + \. \d + $ / . test ( version ) ) version += '.0'
6274
63- for ( let i in RELEASES ) {
64- if ( + i < 4 && type === 'data' ) continue
65- for ( let testVer of RELEASES [ i ] ) {
75+ for ( const format in RELEASES ) {
76+ if ( + format < 4 && type === 'data' ) continue
77+ for ( let testVer of RELEASES [ format ] ) {
6678 const matchExact = testVer === version
6779 const matchMinor = testVer . includes ( 'x' ) && version . includes ( testVer . replace ( '.x' , '' ) )
68- if ( matchExact || matchMinor ) return + i
80+ if ( matchExact || matchMinor ) return + format
6981 }
7082 }
7183
@@ -84,6 +96,7 @@ function getVersions(format: number, type: PackType = 'resource'): VersionsResul
8496
8597 const startSnaps : string [ ] = Object . keys ( START_SNAPSHOTS )
8698 for ( const snap in START_SNAPSHOTS ) {
99+ // @ts -ignore: #45159
87100 if ( START_SNAPSHOTS [ snap ] [ type ] === format ) {
88101 let maxSnap = snap as SnapshotName
89102 let i = 1
0 commit comments