diff --git a/src/assets/data/en/client_log.ts b/src/assets/data/en/client_log.ts
deleted file mode 100644
index 013cf09a..00000000
--- a/src/assets/data/en/client_log.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-const dict = {
- 'channel.system': /^: (?
.+)$/,
- 'channel.trade': /^\$(?:<(?.+?)> )?(?.+?): (?.+)$/,
- 'channel.global': /^#(?:<(?.+?)> )?(?.+?): (?.+)$/,
- 'channel.party': /^%(?:<(?.+?)> )?(?.+?): (?.+)$/,
- 'channel.guild': /^&(?:<(?.+?)> )?(?.+?): (?.+)$/,
- 'channel.whisper.to': /^@To (?.+?): (?.+)$/,
- 'channel.whisper.from': /^@From (?:<(?.+?)> )?(?.+?): (?.+)$/,
- 'trade.gem': /^level (?\d+) (?\d+)% (?.+)$/
-}
-
-export default dict
-
-export type ClientLogDict = typeof dict
diff --git a/src/assets/data/en/client_strings.ts b/src/assets/data/en/client_strings.ts
index 73640707..06e73881 100644
--- a/src/assets/data/en/client_strings.ts
+++ b/src/assets/data/en/client_strings.ts
@@ -82,7 +82,16 @@ const dict = { /* eslint-disable quote-props */
'CORRUPTED_IMPLICIT': 'Corruption Implicit Modifier',
'MODIFIER_INCREASED': /^(.+?)% Increased$/,
'INCURSION_OPEN': 'Open Rooms:',
- 'INCURSION_OBSTRUCTED': 'Obstructed Rooms:'
+ 'INCURSION_OBSTRUCTED': 'Obstructed Rooms:',
+ // ---
+ 'CHAT_SYSTEM': /^: (?.+)$/,
+ 'CHAT_TRADE': /^\$(?:<(?.+?)> )?(?.+?): (?.+)$/,
+ 'CHAT_GLOBAL': /^#(?:<(?.+?)> )?(?.+?): (?.+)$/,
+ 'CHAT_PARTY': /^%(?:<(?.+?)> )?(?.+?): (?.+)$/,
+ 'CHAT_GUILD': /^&(?:<(?.+?)> )?(?.+?): (?.+)$/,
+ 'CHAT_WHISPER_TO': /^@To (?.+?): (?.+)$/,
+ 'CHAT_WHISPER_FROM': /^@From (?:<(?.+?)> )?(?.+?): (?.+)$/,
+ 'CHAT_WEBTRADE_GEM': /^level (?\d+) (?\d+)% (?.+)$/
}
export default dict
diff --git a/src/assets/data/index.ts b/src/assets/data/index.ts
index 7b62a548..b9d28ec2 100644
--- a/src/assets/data/index.ts
+++ b/src/assets/data/index.ts
@@ -1,8 +1,8 @@
/* eslint-disable @typescript-eslint/no-var-requires */
+import fnv1a from '@sindresorhus/fnv1a'
import type { TranslationDict } from '@/assets/data/en/client_strings'
-import type { ClientLogDict } from '@/assets/data/en/client_log'
-import type { BaseType, DropEntry, Stat, StatMatcher, UniqueItem } from './interfaces'
+import type { BaseType, DropEntry, Stat, StatMatcher } from './interfaces'
import { AppConfig } from '@/web/Config'
import { nameToDetailsId } from '@/web/price-check/trends/getDetailsId'
@@ -55,28 +55,19 @@ class MapNDJSON {
export let STAT_BY_MATCH_STR: MapNDJSON
export let STAT_BY_REF: MapNDJSON
-export let BASE_TYPES: Map
-
-export let TRADE_TAGS: Array<[string, string]>
-export let TRADE_TAG_BY_NAME: Map
-
-export let UNIQUES_LIST: UniqueItem[]
-export let UNIQUES: Map
-
-export let MAP_IMGS: Map
+const DELAYED_STAT_VALIDATION = new Set()
export const ITEM_DROP = new Map()
-;(function initData () { /* eslint-disable no-lone-blocks */
+;(async function initData () { /* eslint-disable no-lone-blocks */
const { language } = AppConfig()
{
- CLIENT_STRINGS = (require(`./${language}/client_strings`).default)
- CLIENTLOG_STRINGS = (require(`./${language}/client_log`).default)
+ await loadItems(language)
+ }
- const itemNames: Array<[string, string]> = (require(`./${language}/item-names.json`))
- TRANSLATED_ITEM_NAME_BY_REF = new Map(itemNames)
- ITEM_NAME_REF_BY_TRANSLATED = new Map(itemNames.map(_ => [_[1], _[0]]))
+ {
+ CLIENT_STRINGS = (await import(`./${language}/client_strings.ts`)).default
}
{
@@ -106,25 +97,13 @@ export const ITEM_DROP = new Map()
start = end + 1
}
- }
- {
- const baseTypes: Array<[string, BaseType]> = (require('./base-types.json'))
- BASE_TYPES = new Map(baseTypes)
- }
-
- {
- const tradeTags: Array<[string, string]> = (require('./trade-tags.json'))
- TRADE_TAGS = tradeTags
- TRADE_TAG_BY_NAME = new Map(tradeTags)
- }
-
- {
- const uniques: UniqueItem[] = (require('./uniques.json'))
- UNIQUES_LIST = uniques
- UNIQUES = new Map(
- uniques.map(item => [`${item.name} ${item.basetype}`, item])
- )
+ for (const text of DELAYED_STAT_VALIDATION) {
+ if (!STAT_BY_REF.has(text)) {
+ throw new Error(`Cannot find stat: ${text}`)
+ }
+ }
+ DELAYED_STAT_VALIDATION.clear()
}
{
@@ -138,17 +117,10 @@ export const ITEM_DROP = new Map()
}
}
}
-
- {
- const maps: Array<[string, { img: string }]> = (require('./maps.json'))
- MAP_IMGS = new Map(maps)
- }
})()
// assertion, to avoid regressions in stats.json
export function stat (text: string) {
- if (!STAT_BY_REF.has(text)) {
- throw new Error(`Cannot find stat: ${text}`)
- }
+ DELAYED_STAT_VALIDATION.add(text)
return text
}
diff --git a/src/assets/data/ru/client_log.ts b/src/assets/data/ru/client_log.ts
deleted file mode 100644
index 65ebae61..00000000
--- a/src/assets/data/ru/client_log.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-import type { ClientLogDict } from '../en/client_log'
-
-const dict: ClientLogDict = {
- 'channel.system': /^: (?.+)$/,
- 'channel.trade': /^\$(?:<(?.+?)> )?(?.+?): (?.+)$/,
- 'channel.global': /^#(?:<(?.+?)> )?(?.+?): (?.+)$/,
- 'channel.party': /^%(?:<(?.+?)> )?(?.+?): (?.+)$/,
- 'channel.guild': /^&(?:<(?.+?)> )?(?.+?): (?.+)$/,
- 'channel.whisper.to': /^@Кому (?.+?): (?.+)$/,
- 'channel.whisper.from': /^@От кого (?:<(?.+?)> )?(?.+?): (?.+)$/,
- 'trade.gem': /^уровень (?\d+) (?\d+)% (?.+)$/
-}
-
-export default dict
diff --git a/src/assets/data/ru/client_strings.ts b/src/assets/data/ru/client_strings.ts
index ff4cf9c6..191a608d 100644
--- a/src/assets/data/ru/client_strings.ts
+++ b/src/assets/data/ru/client_strings.ts
@@ -84,7 +84,16 @@ const dict: TranslationDict = { /* eslint-disable quote-props */
'CORRUPTED_IMPLICIT': 'Осквернённое собственное свойство',
'MODIFIER_INCREASED': /^(.+?)% увеличение$/,
'INCURSION_OPEN': 'Открытые комнаты:',
- 'INCURSION_OBSTRUCTED': 'Отделённые комнаты:'
+ 'INCURSION_OBSTRUCTED': 'Отделённые комнаты:',
+ // ---
+ 'CHAT_SYSTEM': /^: (?.+)$/,
+ 'CHAT_TRADE': /^\$(?:<(?.+?)> )?(?.+?): (?.+)$/,
+ 'CHAT_GLOBAL': /^#(?:<(?.+?)> )?(?.+?): (?.+)$/,
+ 'CHAT_PARTY': /^%(?:<(?.+?)> )?(?.+?): (?.+)$/,
+ 'CHAT_GUILD': /^&(?:<(?.+?)> )?(?.+?): (?.+)$/,
+ 'CHAT_WHISPER_TO': /^@Кому (?.+?): (?.+)$/,
+ 'CHAT_WHISPER_FROM': /^@От кого (?:<(?.+?)> )?(?.+?): (?.+)$/,
+ 'CHAT_WEBTRADE_GEM': /^уровень (?\d+) (?\d+)% (?.+)$/
}
export default dict
diff --git a/src/web/client-log/client-log.ts b/src/web/client-log/client-log.ts
index 36117cc2..9c875b13 100644
--- a/src/web/client-log/client-log.ts
+++ b/src/web/client-log/client-log.ts
@@ -1,5 +1,5 @@
/* eslint-disable camelcase */
-import { CLIENTLOG_STRINGS as _$ } from '@/assets/data'
+import { CLIENT_STRINGS as _$ } from '@/assets/data'
import { AppConfig } from '@/web/Config'
const enum MessageChannel {
@@ -41,19 +41,19 @@ export function handleLine (line: string) {
const entry = {} as LogEntry
let match: RegExpMatchArray | null
- if ((match = text.match(_$['channel.global']))) {
+ if ((match = text.match(_$.CHAT_GLOBAL))) {
entry.сhannel = MessageChannel.GLOBAL
- } else if ((match = text.match(_$['channel.trade']))) {
+ } else if ((match = text.match(_$.CHAT_TRADE))) {
entry.сhannel = MessageChannel.TRADE
- } else if ((match = text.match(_$['channel.system']))) {
+ } else if ((match = text.match(_$.CHAT_SYSTEM))) {
entry.сhannel = MessageChannel.SYSTEM
- } else if ((match = text.match(_$['channel.whisper.to']))) {
+ } else if ((match = text.match(_$.CHAT_WHISPER_TO))) {
entry.сhannel = MessageChannel.WHISPER_TO
- } else if ((match = text.match(_$['channel.whisper.from']))) {
+ } else if ((match = text.match(_$.CHAT_WHISPER_FROM))) {
entry.сhannel = MessageChannel.WHISPER_FROM
- } else if ((match = text.match(_$['channel.party']))) {
+ } else if ((match = text.match(_$.CHAT_PARTY))) {
entry.сhannel = MessageChannel.PARTY
- } else if ((match = text.match(_$['channel.guild']))) {
+ } else if ((match = text.match(_$.CHAT_GUILD))) {
entry.сhannel = MessageChannel.GUILD
} else {
return
@@ -69,7 +69,7 @@ export function handleLine (line: string) {
match.groups!.price.split(' ', 1).toString(),
match.groups!.price.split(' ').slice(1).join(' ')
]
- const gemMatch = match.groups!.item.match(_$['trade.gem'])
+ const gemMatch = match.groups!.item.match(_$.CHAT_WEBTRADE_GEM)
if (gemMatch) {
match.groups!.item = gemMatch.groups!.gem_name
}