warframe-worldstate-data 3.1.12 → 3.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/.commitlintrc.mjs +0 -6
- package/.husky/commit-msg +0 -1
- package/.husky/pre-commit +0 -1
- package/.lintstagedrc.yml +0 -12
- package/.mocharc.yml +0 -7
- package/.nvmrc +0 -1
- package/.nycrc.json +0 -7
- package/babel.config.json +0 -4
- package/biome.json +0 -51
- package/data/arcanes.json +0 -461
- package/data/archonShards.json +0 -224
- package/data/conclaveData.json +0 -425
- package/data/cs/arcanes.json +0 -461
- package/data/cs/archonShards.json +0 -224
- package/data/cs/conclaveData.json +0 -425
- package/data/cs/eventsData.json +0 -27
- package/data/cs/factionsData.json +0 -32
- package/data/cs/fissureModifiers.json +0 -26
- package/data/cs/languages.json +0 -19595
- package/data/cs/missionTypes.json +0 -80
- package/data/cs/operationTypes.json +0 -6
- package/data/cs/persistentEnemyData.json +0 -21
- package/data/cs/solNodes.json +0 -2242
- package/data/cs/sortieData.json +0 -4253
- package/data/cs/steelPath.json +0 -114
- package/data/cs/syndicatesData.json +0 -86
- package/data/cs/synthTargets.json +0 -1262
- package/data/cs/tutorials.json +0 -17
- package/data/cs/upgradeTypes.json +0 -14
- package/data/de/arcanes.json +0 -461
- package/data/de/archonShards.json +0 -224
- package/data/de/conclaveData.json +0 -425
- package/data/de/eventsData.json +0 -27
- package/data/de/factionsData.json +0 -32
- package/data/de/fissureModifiers.json +0 -26
- package/data/de/languages.json +0 -19595
- package/data/de/missionTypes.json +0 -80
- package/data/de/operationTypes.json +0 -6
- package/data/de/persistentEnemyData.json +0 -21
- package/data/de/solNodes.json +0 -2242
- package/data/de/sortieData.json +0 -4253
- package/data/de/steelPath.json +0 -114
- package/data/de/syndicatesData.json +0 -86
- package/data/de/synthTargets.json +0 -1262
- package/data/de/tutorials.json +0 -17
- package/data/de/upgradeTypes.json +0 -14
- package/data/es/arcanes.json +0 -461
- package/data/es/archonShards.json +0 -224
- package/data/es/conclaveData.json +0 -425
- package/data/es/eventsData.json +0 -27
- package/data/es/factionsData.json +0 -32
- package/data/es/fissureModifiers.json +0 -26
- package/data/es/languages.json +0 -19595
- package/data/es/missionTypes.json +0 -80
- package/data/es/operationTypes.json +0 -6
- package/data/es/persistentEnemyData.json +0 -21
- package/data/es/solNodes.json +0 -2242
- package/data/es/sortieData.json +0 -4253
- package/data/es/steelPath.json +0 -114
- package/data/es/syndicatesData.json +0 -86
- package/data/es/synthTargets.json +0 -1262
- package/data/es/tutorials.json +0 -17
- package/data/es/upgradeTypes.json +0 -14
- package/data/eventsData.json +0 -27
- package/data/factionsData.json +0 -32
- package/data/fissureModifiers.json +0 -26
- package/data/fr/arcanes.json +0 -461
- package/data/fr/archonShards.json +0 -224
- package/data/fr/conclaveData.json +0 -425
- package/data/fr/eventsData.json +0 -27
- package/data/fr/factionsData.json +0 -32
- package/data/fr/fissureModifiers.json +0 -26
- package/data/fr/languages.json +0 -19595
- package/data/fr/missionTypes.json +0 -80
- package/data/fr/operationTypes.json +0 -6
- package/data/fr/persistentEnemyData.json +0 -21
- package/data/fr/solNodes.json +0 -2242
- package/data/fr/sortieData.json +0 -4253
- package/data/fr/steelPath.json +0 -114
- package/data/fr/syndicatesData.json +0 -86
- package/data/fr/synthTargets.json +0 -1262
- package/data/fr/tutorials.json +0 -17
- package/data/fr/upgradeTypes.json +0 -14
- package/data/index.html +0 -13
- package/data/it/arcanes.json +0 -461
- package/data/it/archonShards.json +0 -224
- package/data/it/conclaveData.json +0 -425
- package/data/it/eventsData.json +0 -27
- package/data/it/factionsData.json +0 -32
- package/data/it/fissureModifiers.json +0 -26
- package/data/it/languages.json +0 -19595
- package/data/it/missionTypes.json +0 -80
- package/data/it/operationTypes.json +0 -6
- package/data/it/persistentEnemyData.json +0 -21
- package/data/it/solNodes.json +0 -2242
- package/data/it/sortieData.json +0 -4253
- package/data/it/steelPath.json +0 -114
- package/data/it/syndicatesData.json +0 -86
- package/data/it/synthTargets.json +0 -1262
- package/data/it/tutorials.json +0 -17
- package/data/it/upgradeTypes.json +0 -14
- package/data/ko/arcanes.json +0 -461
- package/data/ko/archonShards.json +0 -224
- package/data/ko/conclaveData.json +0 -425
- package/data/ko/eventsData.json +0 -27
- package/data/ko/factionsData.json +0 -32
- package/data/ko/fissureModifiers.json +0 -26
- package/data/ko/languages.json +0 -19595
- package/data/ko/missionTypes.json +0 -80
- package/data/ko/operationTypes.json +0 -6
- package/data/ko/persistentEnemyData.json +0 -21
- package/data/ko/solNodes.json +0 -2242
- package/data/ko/sortieData.json +0 -4253
- package/data/ko/steelPath.json +0 -114
- package/data/ko/syndicatesData.json +0 -86
- package/data/ko/synthTargets.json +0 -1262
- package/data/ko/tutorials.json +0 -17
- package/data/ko/upgradeTypes.json +0 -14
- package/data/languages.json +0 -19595
- package/data/missionTypes.json +0 -80
- package/data/operationTypes.json +0 -6
- package/data/persistentEnemyData.json +0 -21
- package/data/pl/arcanes.json +0 -461
- package/data/pl/archonShards.json +0 -224
- package/data/pl/conclaveData.json +0 -425
- package/data/pl/eventsData.json +0 -27
- package/data/pl/factionsData.json +0 -32
- package/data/pl/fissureModifiers.json +0 -26
- package/data/pl/languages.json +0 -19595
- package/data/pl/missionTypes.json +0 -80
- package/data/pl/operationTypes.json +0 -6
- package/data/pl/persistentEnemyData.json +0 -21
- package/data/pl/solNodes.json +0 -2242
- package/data/pl/sortieData.json +0 -4253
- package/data/pl/steelPath.json +0 -114
- package/data/pl/syndicatesData.json +0 -86
- package/data/pl/synthTargets.json +0 -1262
- package/data/pl/tutorials.json +0 -17
- package/data/pl/upgradeTypes.json +0 -14
- package/data/pt/arcanes.json +0 -461
- package/data/pt/archonShards.json +0 -224
- package/data/pt/conclaveData.json +0 -425
- package/data/pt/eventsData.json +0 -27
- package/data/pt/factionsData.json +0 -32
- package/data/pt/fissureModifiers.json +0 -26
- package/data/pt/languages.json +0 -19595
- package/data/pt/missionTypes.json +0 -80
- package/data/pt/operationTypes.json +0 -6
- package/data/pt/persistentEnemyData.json +0 -21
- package/data/pt/solNodes.json +0 -2242
- package/data/pt/sortieData.json +0 -4253
- package/data/pt/steelPath.json +0 -114
- package/data/pt/syndicatesData.json +0 -86
- package/data/pt/synthTargets.json +0 -1262
- package/data/pt/tutorials.json +0 -17
- package/data/pt/upgradeTypes.json +0 -14
- package/data/ru/arcanes.json +0 -461
- package/data/ru/archonShards.json +0 -224
- package/data/ru/conclaveData.json +0 -425
- package/data/ru/eventsData.json +0 -27
- package/data/ru/factionsData.json +0 -32
- package/data/ru/fissureModifiers.json +0 -26
- package/data/ru/languages.json +0 -19595
- package/data/ru/missionTypes.json +0 -80
- package/data/ru/operationTypes.json +0 -6
- package/data/ru/persistentEnemyData.json +0 -21
- package/data/ru/solNodes.json +0 -2242
- package/data/ru/sortieData.json +0 -4253
- package/data/ru/steelPath.json +0 -114
- package/data/ru/syndicatesData.json +0 -86
- package/data/ru/synthTargets.json +0 -1262
- package/data/ru/tutorials.json +0 -17
- package/data/ru/upgradeTypes.json +0 -14
- package/data/solNodes.json +0 -2242
- package/data/sortieData.json +0 -4253
- package/data/sr/arcanes.json +0 -461
- package/data/sr/archonShards.json +0 -224
- package/data/sr/conclaveData.json +0 -425
- package/data/sr/eventsData.json +0 -27
- package/data/sr/factionsData.json +0 -32
- package/data/sr/fissureModifiers.json +0 -26
- package/data/sr/languages.json +0 -19595
- package/data/sr/missionTypes.json +0 -80
- package/data/sr/operationTypes.json +0 -6
- package/data/sr/persistentEnemyData.json +0 -21
- package/data/sr/solNodes.json +0 -2242
- package/data/sr/sortieData.json +0 -4253
- package/data/sr/steelPath.json +0 -114
- package/data/sr/syndicatesData.json +0 -86
- package/data/sr/synthTargets.json +0 -1262
- package/data/sr/tutorials.json +0 -17
- package/data/sr/upgradeTypes.json +0 -14
- package/data/steelPath.json +0 -33
- package/data/syndicatesData.json +0 -86
- package/data/synthTargets.json +0 -1262
- package/data/tr/arcanes.json +0 -461
- package/data/tr/archonShards.json +0 -224
- package/data/tr/conclaveData.json +0 -425
- package/data/tr/eventsData.json +0 -27
- package/data/tr/factionsData.json +0 -32
- package/data/tr/fissureModifiers.json +0 -26
- package/data/tr/languages.json +0 -19595
- package/data/tr/missionTypes.json +0 -80
- package/data/tr/operationTypes.json +0 -6
- package/data/tr/persistentEnemyData.json +0 -21
- package/data/tr/solNodes.json +0 -2242
- package/data/tr/sortieData.json +0 -4253
- package/data/tr/steelPath.json +0 -114
- package/data/tr/syndicatesData.json +0 -86
- package/data/tr/synthTargets.json +0 -1262
- package/data/tr/tutorials.json +0 -17
- package/data/tr/upgradeTypes.json +0 -14
- package/data/tutorials.json +0 -17
- package/data/uk/arcanes.json +0 -461
- package/data/uk/archonShards.json +0 -224
- package/data/uk/conclaveData.json +0 -425
- package/data/uk/eventsData.json +0 -27
- package/data/uk/factionsData.json +0 -32
- package/data/uk/fissureModifiers.json +0 -26
- package/data/uk/languages.json +0 -19595
- package/data/uk/missionTypes.json +0 -80
- package/data/uk/operationTypes.json +0 -6
- package/data/uk/persistentEnemyData.json +0 -21
- package/data/uk/solNodes.json +0 -2242
- package/data/uk/sortieData.json +0 -4253
- package/data/uk/steelPath.json +0 -114
- package/data/uk/syndicatesData.json +0 -86
- package/data/uk/synthTargets.json +0 -1262
- package/data/uk/tutorials.json +0 -17
- package/data/uk/upgradeTypes.json +0 -14
- package/data/upgradeTypes.json +0 -14
- package/data/zh/arcanes.json +0 -461
- package/data/zh/archonShards.json +0 -224
- package/data/zh/conclaveData.json +0 -425
- package/data/zh/eventsData.json +0 -27
- package/data/zh/factionsData.json +0 -32
- package/data/zh/fissureModifiers.json +0 -26
- package/data/zh/languages.json +0 -19595
- package/data/zh/missionTypes.json +0 -80
- package/data/zh/operationTypes.json +0 -6
- package/data/zh/persistentEnemyData.json +0 -21
- package/data/zh/solNodes.json +0 -2242
- package/data/zh/sortieData.json +0 -4253
- package/data/zh/steelPath.json +0 -114
- package/data/zh/syndicatesData.json +0 -86
- package/data/zh/synthTargets.json +0 -1262
- package/data/zh/tutorials.json +0 -17
- package/data/zh/upgradeTypes.json +0 -14
- package/exports.ts +0 -153
- package/safeImport.ts +0 -24
- package/tools/integrity.ts +0 -16
- package/tools/sortLanguages.ts +0 -44
- package/tools/timeDate.ts +0 -129
- package/tools/translation.ts +0 -430
- package/tools/utilities.ts +0 -5
- package/tsconfig.json +0 -13
- package/tsdown.config.ts +0 -15
- package/types.ts +0 -70
package/data/zh/tutorials.json
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"regex": "focus",
|
|
4
|
-
"name": "专精",
|
|
5
|
-
"url": "https://youtu.be/IMltFZ97oXc"
|
|
6
|
-
},
|
|
7
|
-
{
|
|
8
|
-
"regex": "mods?",
|
|
9
|
-
"name": "Mods",
|
|
10
|
-
"url": "https://youtu.be/ZuYfEJzpR4A"
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
"regex": "dojos?",
|
|
14
|
-
"name": "道场",
|
|
15
|
-
"url": "https://youtu.be/M28grdARKoQ"
|
|
16
|
-
}
|
|
17
|
-
]
|
package/exports.ts
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import { safeImport } from './safeImport';
|
|
2
|
-
import { Arcane, ArchonShard, Conclave, Events, SolNode, SortieData, SteelPath, SynthesisTarget } from './types';
|
|
3
|
-
|
|
4
|
-
export type Locale = 'de' | 'en' | 'es' | 'fr' | 'it' | 'ko' | 'pl' | 'pt' | 'ru' | 'zh' | 'cs' | 'sr' | 'uk';
|
|
5
|
-
|
|
6
|
-
const locales: Locale[] = ['de', 'es', 'fr', 'it', 'ko', 'pl', 'pt', 'ru', 'zh', 'cs', 'sr', 'uk'];
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Bundles all the data for a particular language
|
|
10
|
-
*/
|
|
11
|
-
export interface WorldstateLangBundle {
|
|
12
|
-
/**
|
|
13
|
-
* Deprecated: Array of arcane data
|
|
14
|
-
*/
|
|
15
|
-
arcanes: Arcane[];
|
|
16
|
-
/**
|
|
17
|
-
* Data for Archon shard colors
|
|
18
|
-
*/
|
|
19
|
-
archonShards: Record<string, ArchonShard>;
|
|
20
|
-
/**
|
|
21
|
-
* Data for translating PvP categories and types
|
|
22
|
-
*/
|
|
23
|
-
conclave: Conclave;
|
|
24
|
-
/**
|
|
25
|
-
* Deprecated: Data for converting event tags to useable event data.
|
|
26
|
-
* Deprecated in favor of keeping values in languages.json
|
|
27
|
-
*/
|
|
28
|
-
events: Events;
|
|
29
|
-
/**
|
|
30
|
-
* Faction universal name to plain-usage name
|
|
31
|
-
*/
|
|
32
|
-
factions: Record<string, { value: string }>;
|
|
33
|
-
/**
|
|
34
|
-
* Map of fissures to "Warframeified" tier names and numbers
|
|
35
|
-
*/
|
|
36
|
-
fissureModifiers: Record<string, { value: string; num: number }>;
|
|
37
|
-
/**
|
|
38
|
-
* Map of "internal" Warframe strings to useable language strings
|
|
39
|
-
*/
|
|
40
|
-
languages: Record<string, { value: string; desc: string }>;
|
|
41
|
-
/**
|
|
42
|
-
* Map of Mission Type identifiers to their corresponding values
|
|
43
|
-
*/
|
|
44
|
-
missionTypes: Record<string, { value: string }>;
|
|
45
|
-
/**
|
|
46
|
-
* Global modifiers for applying operations to things like
|
|
47
|
-
* credits, affinity, etc.
|
|
48
|
-
*/
|
|
49
|
-
operationTypes: Record<string, { value: string; symbol: string }>;
|
|
50
|
-
/**
|
|
51
|
-
* Region mapping for indicies to planets
|
|
52
|
-
*/
|
|
53
|
-
persistentEnemy: { regions: string[] };
|
|
54
|
-
/**
|
|
55
|
-
* Nodes in the Sol system, with enemy type and node information
|
|
56
|
-
*/
|
|
57
|
-
solNodes: Record<string, SolNode>;
|
|
58
|
-
/**
|
|
59
|
-
* Sortie-specific mapping for modifier type, description, and boss
|
|
60
|
-
*/
|
|
61
|
-
sortie: SortieData;
|
|
62
|
-
/**
|
|
63
|
-
* Steel Path mission type translations
|
|
64
|
-
*/
|
|
65
|
-
steelPath: SteelPath;
|
|
66
|
-
/**
|
|
67
|
-
* Syndicate data
|
|
68
|
-
*/
|
|
69
|
-
syndicates: Record<string, { name: string }>;
|
|
70
|
-
/**
|
|
71
|
-
* Synthesis target data for optimal locations to find targets.
|
|
72
|
-
*/
|
|
73
|
-
synthTargets: SynthesisTarget[];
|
|
74
|
-
/**
|
|
75
|
-
* Official tutorials.
|
|
76
|
-
* Not many have been released in a long time.
|
|
77
|
-
*/
|
|
78
|
-
tutorials: { regex: string; name: string; url: string }[];
|
|
79
|
-
/**
|
|
80
|
-
* Global upgrade types that are modified by #operationTypes
|
|
81
|
-
*/
|
|
82
|
-
upgradeTypes: Record<string, { value: string }>;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const makeBundle = async () => {
|
|
86
|
-
/**
|
|
87
|
-
* English United States translations bundle,
|
|
88
|
-
* default translations
|
|
89
|
-
* @type {WorldstateLangBundle}
|
|
90
|
-
*/
|
|
91
|
-
const enUS: WorldstateLangBundle = {
|
|
92
|
-
arcanes: await safeImport('./data/arcanes.json'),
|
|
93
|
-
archonShards: await safeImport('./data/archonShards.json'),
|
|
94
|
-
conclave: await safeImport('./data/conclaveData.json'),
|
|
95
|
-
events: await safeImport('./data/eventsData.json'),
|
|
96
|
-
factions: await safeImport('./data/factionsData.json'),
|
|
97
|
-
fissureModifiers: await safeImport('./data/fissureModifiers.json'),
|
|
98
|
-
languages: await safeImport('./data/languages.json'),
|
|
99
|
-
missionTypes: await safeImport('./data/missionTypes.json'),
|
|
100
|
-
operationTypes: await safeImport('./data/operationTypes.json'),
|
|
101
|
-
persistentEnemy: await safeImport('./data/persistentEnemyData.json'),
|
|
102
|
-
solNodes: await safeImport('./data/solNodes.json'),
|
|
103
|
-
sortie: await safeImport('./data/sortieData.json'),
|
|
104
|
-
syndicates: await safeImport('./data/syndicatesData.json'),
|
|
105
|
-
tutorials: await safeImport('./data/tutorials.json'),
|
|
106
|
-
upgradeTypes: await safeImport('./data/upgradeTypes.json'),
|
|
107
|
-
synthTargets: await safeImport('./data/synthTargets.json'),
|
|
108
|
-
steelPath: await safeImport('./data/steelPath.json'),
|
|
109
|
-
};
|
|
110
|
-
/* eslint-enable global-require */
|
|
111
|
-
|
|
112
|
-
type WorldstateData = WorldstateLangBundle & {
|
|
113
|
-
[K in Locale]?: WorldstateLangBundle;
|
|
114
|
-
} & { locales: Locale[] };
|
|
115
|
-
|
|
116
|
-
const bundle: WorldstateData = {
|
|
117
|
-
en: enUS,
|
|
118
|
-
...enUS,
|
|
119
|
-
locales
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
123
|
-
for await (const locale of locales) {
|
|
124
|
-
/**
|
|
125
|
-
* Translations bundle for $locale
|
|
126
|
-
* @type {WorldstateLangBundle}
|
|
127
|
-
*/
|
|
128
|
-
bundle[locale] = {
|
|
129
|
-
arcanes: await safeImport(`./data/${locale}/arcanes.json`, enUS.arcanes),
|
|
130
|
-
archonShards: await safeImport(`./data/${locale}/archonShards.json`, enUS.archonShards),
|
|
131
|
-
conclave: await safeImport(`./data/${locale}/conclaveData.json`, enUS.conclave),
|
|
132
|
-
events: await safeImport(`./data/${locale}/eventsData.json`, enUS.events),
|
|
133
|
-
factions: await safeImport(`./data/${locale}/factionsData.json`, enUS.factions),
|
|
134
|
-
fissureModifiers: await safeImport(`./data/${locale}/fissureModifiers.json`, enUS.fissureModifiers),
|
|
135
|
-
languages: await safeImport(`./data/${locale}/languages.json`, enUS.languages),
|
|
136
|
-
missionTypes: await safeImport(`./data/${locale}/missionTypes.json`, enUS.missionTypes),
|
|
137
|
-
operationTypes: await safeImport(`./data/${locale}/operationTypes.json`, enUS.operationTypes),
|
|
138
|
-
persistentEnemy: await safeImport(`./data/${locale}/persistentEnemyData.json`, enUS.persistentEnemy),
|
|
139
|
-
solNodes: await safeImport(`./data/${locale}/solNodes.json`, enUS.solNodes),
|
|
140
|
-
sortie: await safeImport(`./data/${locale}/sortieData.json`, enUS.sortie),
|
|
141
|
-
syndicates: await safeImport(`./data/${locale}/syndicatesData.json`, enUS.syndicates),
|
|
142
|
-
tutorials: await safeImport(`./data/${locale}/tutorials.json`, enUS.tutorials),
|
|
143
|
-
upgradeTypes: await safeImport(`./data/${locale}/upgradeTypes.json`, enUS.upgradeTypes),
|
|
144
|
-
synthTargets: await safeImport(`./data/${locale}/synthTargets.json`, enUS.synthTargets),
|
|
145
|
-
steelPath: await safeImport(`./data/${locale}/steelPath.json`, enUS.steelPath),
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
locales.push('en');
|
|
150
|
-
return bundle;
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
export default await makeBundle();
|
package/safeImport.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
2
|
-
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Safely require path, fall back to fallback if module cannot load
|
|
6
|
-
* @param {string} path Path to attempt to load
|
|
7
|
-
* @param {Object} fallback fallback response if error or no module
|
|
8
|
-
* @returns {Promise<any>} module or the default object
|
|
9
|
-
*/
|
|
10
|
-
export const safeImport = async <T extends object>(path: string, fallback: T = {} as T): Promise<T> => {
|
|
11
|
-
try {
|
|
12
|
-
const mod: T | { default: T } = path.includes('.json')
|
|
13
|
-
? await import(path, { with: { type: 'json' } })
|
|
14
|
-
: await import(path);
|
|
15
|
-
return 'default' in mod ? (mod as { default: T }).default : (mod as T);
|
|
16
|
-
} catch (error) {
|
|
17
|
-
if ((process.env.LOG_LEVEL || 'ERROR').toUpperCase() === 'DEBUG') {
|
|
18
|
-
console.debug(`Failed to load module at ${path} ... returning fallback`);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return fallback;
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
|
package/tools/integrity.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @description Insist that the provided data has the required properties.
|
|
3
|
-
* @param {Record<string, unknown>} thing to encourage to have data
|
|
4
|
-
* @param {...string} args arguments to ensure
|
|
5
|
-
*/
|
|
6
|
-
export const insist = (thing: Record<string, unknown>, ...args: string[]) => {
|
|
7
|
-
if (!thing || !Object.keys(thing).length) {
|
|
8
|
-
throw new TypeError('No data provided.');
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
args.forEach((arg) => {
|
|
12
|
-
if (!(arg in thing)) {
|
|
13
|
-
throw new TypeError(`Missing required property: '${arg}'.`);
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
};
|
package/tools/sortLanguages.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { readFile, writeFile } from 'node:fs/promises';
|
|
4
|
-
import { dirname, join } from 'node:path';
|
|
5
|
-
import { fileURLToPath } from 'node:url';
|
|
6
|
-
|
|
7
|
-
import yargs from 'yargs/yargs';
|
|
8
|
-
|
|
9
|
-
const options = yargs(process.argv)
|
|
10
|
-
.usage('Usage -c')
|
|
11
|
-
.option('c', { alias: 'check', describe: "Check only, don't write file", type: 'boolean', demandOption: false })
|
|
12
|
-
.parse();
|
|
13
|
-
|
|
14
|
-
const checkOnly = (await options).c;
|
|
15
|
-
|
|
16
|
-
const dirName: string = dirname(fileURLToPath(import.meta.url));
|
|
17
|
-
const sort = (obj: Record<string, { value: string; desc?: string }>) => {
|
|
18
|
-
return Object.keys(obj)
|
|
19
|
-
.sort()
|
|
20
|
-
.reduce(
|
|
21
|
-
function (result, key: string) {
|
|
22
|
-
result[key] = obj[key];
|
|
23
|
-
return result;
|
|
24
|
-
},
|
|
25
|
-
{} as Record<string, { value: string; desc?: string }>
|
|
26
|
-
);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const dataDir = join(dirName, '..', 'data');
|
|
30
|
-
const data = JSON.parse(await readFile(join(dataDir, 'languages.json'), 'utf8'));
|
|
31
|
-
|
|
32
|
-
const sortedData = sort(data);
|
|
33
|
-
|
|
34
|
-
if (JSON.stringify(sortedData, undefined, 2) !== JSON.stringify(data, undefined, 2)) {
|
|
35
|
-
console.error('Data not sorted');
|
|
36
|
-
if (checkOnly) { process.exit(1); }
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (checkOnly) { process.exit(0); }
|
|
40
|
-
|
|
41
|
-
await writeFile(join(dataDir, 'languages.json.bak'), JSON.stringify(data, undefined, 2));
|
|
42
|
-
await writeFile(join(dataDir, 'languages.json'), JSON.stringify(sortedData, undefined, 2));
|
|
43
|
-
|
|
44
|
-
console.log('language.json has been sorted!');
|
package/tools/timeDate.ts
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
const epochZero: ContentTimestamp = {
|
|
2
|
-
$date: {
|
|
3
|
-
$numberLong: 0,
|
|
4
|
-
},
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
export const pieceIsSmoller = (seconds: number, ceiling: number, label: string, timePieces: string[]) => {
|
|
8
|
-
if (seconds >= ceiling) {
|
|
9
|
-
timePieces.push(`${Math.floor(seconds / ceiling)}${label}`);
|
|
10
|
-
seconds = Math.floor(seconds) % ceiling;
|
|
11
|
-
}
|
|
12
|
-
return { seconds, timePieces };
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @param {number} millis The number of milliseconds in the time delta
|
|
17
|
-
* @returns {string} formatted time delta
|
|
18
|
-
*/
|
|
19
|
-
export const timeDeltaToString = (millis: number): string => {
|
|
20
|
-
if (typeof millis !== 'number') {
|
|
21
|
-
throw new TypeError('millis should be a number');
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
let timePieces: string[] = [];
|
|
25
|
-
const prefix = millis < 0 ? '-' : '';
|
|
26
|
-
let seconds = Math.abs(millis / 1000);
|
|
27
|
-
|
|
28
|
-
// Seconds in a day
|
|
29
|
-
({ seconds, timePieces } = pieceIsSmoller(seconds, 86400, 'd', timePieces));
|
|
30
|
-
|
|
31
|
-
// Seconds in an hour
|
|
32
|
-
({ seconds, timePieces } = pieceIsSmoller(seconds, 3600, 'h', timePieces));
|
|
33
|
-
|
|
34
|
-
// Seconds in a minute
|
|
35
|
-
({ seconds, timePieces } = pieceIsSmoller(seconds, 60, 'm', timePieces));
|
|
36
|
-
|
|
37
|
-
/* istanbul ignore else */
|
|
38
|
-
if (seconds >= 0) {
|
|
39
|
-
timePieces.push(`${Math.floor(seconds)}s`);
|
|
40
|
-
}
|
|
41
|
-
return `${prefix}${timePieces.join(' ')}`;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Returns the number of milliseconds between now and a given date
|
|
46
|
-
* @param {Date} d The date from which the current time will be subtracted
|
|
47
|
-
* @param {function} [now] A function that returns the current UNIX time in milliseconds
|
|
48
|
-
* @returns {number} The number of milliseconds after the given date to now
|
|
49
|
-
*/
|
|
50
|
-
export const fromNow = (d: Date, now: () => number = Date.now): number => {
|
|
51
|
-
return d.getTime() - now();
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Returns the number of milliseconds between a given date and now
|
|
56
|
-
* @param {Date} d The date that the current time will be subtracted from
|
|
57
|
-
* @param {function} [now] A function that returns the current UNIX time in milliseconds
|
|
58
|
-
* @returns {number} The number of milliseconds after now to the given date
|
|
59
|
-
*/
|
|
60
|
-
export const toNow = (d: Date, now: () => number = Date.now): number => {
|
|
61
|
-
return now() - d.getTime();
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
export interface ContentTimestamp {
|
|
65
|
-
$date?: { $numberLong: number };
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Returns a new Date constructed from a worldState date object
|
|
70
|
-
* @param {Object} d The worldState date object
|
|
71
|
-
* @returns {Date} parsed date from DE date format
|
|
72
|
-
*/
|
|
73
|
-
export const parseDate = (d?: ContentTimestamp): Date => {
|
|
74
|
-
const safeD = d || epochZero;
|
|
75
|
-
const dt = safeD.$date || epochZero.$date;
|
|
76
|
-
return new Date(safeD.$date ? Number(dt!.$numberLong) : 1000 * (d as { sec: number }).sec);
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Get a weekly reset timestamp
|
|
81
|
-
*/
|
|
82
|
-
export const weeklyReset = (nowFunc = () => new Date()): { activation: Date; expiry: Date } => {
|
|
83
|
-
const now = nowFunc();
|
|
84
|
-
const currentDay = now.getUTCDay();
|
|
85
|
-
const daysUntilNextMonday = currentDay === 0 ? 1 : 8 - currentDay;
|
|
86
|
-
|
|
87
|
-
const expiry = new Date(now.getTime());
|
|
88
|
-
expiry.setUTCDate(now.getUTCDate() + daysUntilNextMonday);
|
|
89
|
-
expiry.setUTCHours(0, 0, 0, 0);
|
|
90
|
-
|
|
91
|
-
const activation = new Date(expiry.getTime());
|
|
92
|
-
activation.setUTCDate(expiry.getUTCDate() - 7);
|
|
93
|
-
|
|
94
|
-
return { activation, expiry };
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Get a daily reset timestamp
|
|
99
|
-
*/
|
|
100
|
-
export const dailyReset = (nowFunc = () => new Date()): { activation: Date; expiry: Date } => {
|
|
101
|
-
const now = nowFunc();
|
|
102
|
-
|
|
103
|
-
const activation = new Date(now.getTime());
|
|
104
|
-
activation.setUTCHours(0, 0, 0, 0);
|
|
105
|
-
|
|
106
|
-
const expiry = new Date(now.getTime());
|
|
107
|
-
expiry.setUTCDate(now.getUTCDate() + 1);
|
|
108
|
-
expiry.setUTCHours(0, 0, 0, 0);
|
|
109
|
-
|
|
110
|
-
return {activation, expiry};
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* An object containing functions to format dates and times
|
|
115
|
-
* @typedef {Record<string, Function>} TimeDateFunctions
|
|
116
|
-
* @property {Function} timeDeltaToString - Converts a time difference to a string
|
|
117
|
-
* @property {Function} fromNow - Returns the number of milliseconds between now and
|
|
118
|
-
* a given date
|
|
119
|
-
* @property {Function} toNow - Returns the number of milliseconds between a given
|
|
120
|
-
* date and now
|
|
121
|
-
*/
|
|
122
|
-
export default {
|
|
123
|
-
timeDeltaToString,
|
|
124
|
-
fromNow,
|
|
125
|
-
toNow,
|
|
126
|
-
parseDate,
|
|
127
|
-
dailyReset,
|
|
128
|
-
weeklyReset,
|
|
129
|
-
};
|