Delete assets/js/dashboard/stats/locations/countries.ts with huggingface_hub
Browse files
assets/js/dashboard/stats/locations/countries.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
| 1 |
-
import worldJson from 'visionscarto-world-atlas/world/110m.json'
|
| 2 |
-
import countriesMeta from '../../../../data/countries_meta.json'
|
| 3 |
-
import * as topojson from 'topojson-client'
|
| 4 |
-
|
| 5 |
-
// The actual type is more extensive, this is only the part that we care about
|
| 6 |
-
export type WorldJsonCountryData = { properties: { a3: string } }
|
| 7 |
-
|
| 8 |
-
export function parseWorldTopoJsonToGeoJsonFeatures(): Array<WorldJsonCountryData> {
|
| 9 |
-
const collection = topojson.feature(
|
| 10 |
-
// @ts-expect-error strings in worldJson not recongizable as the enum values declared in library
|
| 11 |
-
worldJson,
|
| 12 |
-
worldJson.objects.countries
|
| 13 |
-
)
|
| 14 |
-
// @ts-expect-error topojson.feature return type incorrectly inferred as not a collection
|
| 15 |
-
return collection.features
|
| 16 |
-
}
|
| 17 |
-
|
| 18 |
-
export type CountryEntry = {
|
| 19 |
-
// alpha_3 is null for non-country override entries like "A1" (Anonymous VPN)
|
| 20 |
-
alpha_3: string | null
|
| 21 |
-
flag: string
|
| 22 |
-
}
|
| 23 |
-
|
| 24 |
-
type CountryTwoLetterCode = string
|
| 25 |
-
|
| 26 |
-
export type CountriesLookup = Record<CountryTwoLetterCode, CountryEntry>
|
| 27 |
-
|
| 28 |
-
const remapCountriesMeta = () => {
|
| 29 |
-
const result: CountriesLookup = {}
|
| 30 |
-
for (const [alpha_2, [alpha_3, flag]] of Object.entries(countriesMeta)) {
|
| 31 |
-
// flag is definitely defined in the source file
|
| 32 |
-
const entry: CountryEntry = { alpha_3, flag: flag! }
|
| 33 |
-
Object.assign(result, { [alpha_2]: entry })
|
| 34 |
-
}
|
| 35 |
-
return result
|
| 36 |
-
}
|
| 37 |
-
export const COUNTRIES_BY_TWO_LETTER_CODE = remapCountriesMeta()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|