feat: include database cache

This commit is contained in:
Lukas Obermann
2023-08-17 17:22:46 +02:00
parent 52d365002f
commit 88d7552f49
9 changed files with 209 additions and 174 deletions
+3
View File
@@ -37,6 +37,9 @@ jobs:
run: npm run js:build
- name: Compile Sass files
run: npm run css:build
- name: Build database cache
run: npm run buildCache
working-directory: ./src/database/contents
- name: Build macOS application
if: runner.os == 'macOS'
run: node ./deploy/build.mjs prerelease
+3
View File
@@ -37,6 +37,9 @@ jobs:
run: npm run js:build
- name: Compile Sass files
run: npm run css:build
- name: Build database cache
run: npm run buildCache
working-directory: ./src/database/contents
- name: Build macOS application
if: runner.os == 'macOS'
run: node ./deploy/build.mjs stable
+8
View File
@@ -55,6 +55,14 @@
"command": "npm run release:pre",
"problemMatcher": []
},
{
"label": "build database cache",
"command": "npm run buildCache",
"options": {
"cwd": "${workspaceFolder}/src/database/contents"
},
"problemMatcher": []
},
{
"label": "create release",
"command": "npm run release:main",
+13 -4
View File
@@ -2,19 +2,28 @@ import Debug from "debug"
import { dirname, join } from "node:path"
import { parentPort } from "node:process"
import { fileURLToPath } from "node:url"
import { getAllValidData } from "optolith-database-schema"
import { getAbsoluteEntityPaths } from "./contents/src/config.js"
import { getAllValidData, getCache } from "optolith-database-schema"
import { getAbsoluteCachePaths, getAbsoluteEntityPaths } from "./contents/src/config.js"
const debug = Debug("util:database")
const root = join(dirname(fileURLToPath(import.meta.url)), "contents")
debug("loading database ...")
getAllValidData(getAbsoluteEntityPaths(root))
const get = async () => {
const raw = await getAllValidData(getAbsoluteEntityPaths(root))
const cache = await getCache(getAbsoluteCachePaths(root))
return { raw, cache }
}
get()
.then(database => {
debug("database loaded")
parentPort.postMessage(database)
})
.catch(() => {})
export type Database = Awaited<ReturnType<typeof getAllValidData>>
export type Database = {
raw: Awaited<ReturnType<typeof getAllValidData>>
cache: Awaited<ReturnType<typeof getCache>>
}
+2 -2
View File
@@ -31,8 +31,8 @@ const runAsync = <T extends any[]>(fn: (...args: T) => Promise<void>) => (...arg
const setMenu = (database: Database) => {
const translate = createTranslate(
Object.fromEntries(database.ui),
Object.fromEntries(database.locales),
Object.fromEntries(database.raw.ui),
Object.fromEntries(database.raw.locales),
getGlobalSettings().locale,
app.getLocale()
)
+2 -2
View File
@@ -171,8 +171,8 @@ ExternalAPI.on("initial-setup", ({ database, globalSettings }) => {
selectedFallbackLocale={globalSettings.fallbackLocale}
selectedLocaleEvents={ExternalAPI}
systemLocale={ExternalAPI.systemLocale}
locales={Object.fromEntries(database.locales)}
ui={Object.fromEntries(database.ui)}
locales={Object.fromEntries(database.raw.locales)}
ui={Object.fromEntries(database.raw.ui)}
>
<Root />
</LocalizationProvider>
+2 -2
View File
@@ -1,8 +1,8 @@
import { createAction } from "@reduxjs/toolkit"
import { ValidResults } from "optolith-database-schema"
import type { Database } from "../database/index.ts"
import { GlobalSettings } from "../shared/settings/GlobalSettings.ts"
export const init = createAction<{
database: ValidResults
database: Database
globalSettings: GlobalSettings
}>("init")
+163 -153
View File
@@ -3,9 +3,12 @@ import { createSlice } from "@reduxjs/toolkit"
import { TypeId, TypeMap } from "optolith-database-schema/config/types"
import { init } from "../init.ts"
import { RootState } from "../store.ts"
import { CacheMap } from "optolith-database-schema/config/cache"
export type DatabaseState = {
[K in keyof TypeMap]: Record<TypeId<K>, TypeMap[K]>
} & {
cache: CacheMap
}
const initialDatabaseState: DatabaseState = {
@@ -42,6 +45,12 @@ const initialDatabaseState: DatabaseState = {
brawlingSpecialAbilities: {},
brews: {},
cantrips: {},
cache: {
newApplicationsAndUses: {
newApplications: {},
uses: {}
}
},
cauldronEnchantments: {},
ceremonialItems: {},
ceremonialItemSpecialAbilities: {},
@@ -171,159 +180,160 @@ const databaseSlice = createSlice({
extraReducers: builder => {
builder
.addCase(init, (state, action) => {
state.advancedCombatSpecialAbilities = Object.fromEntries(action.payload.database.advancedCombatSpecialAbilities)
state.advancedKarmaSpecialAbilities = Object.fromEntries(action.payload.database.advancedKarmaSpecialAbilities)
state.advancedMagicalSpecialAbilities = Object.fromEntries(action.payload.database.advancedMagicalSpecialAbilities)
state.advancedSkillSpecialAbilities = Object.fromEntries(action.payload.database.advancedSkillSpecialAbilities)
state.advantages = Object.fromEntries(action.payload.database.advantages)
state.alchemicae = Object.fromEntries(action.payload.database.alchemicae)
state.ammunition = Object.fromEntries(action.payload.database.ammunition)
state.ancestorGlyphs = Object.fromEntries(action.payload.database.ancestorGlyphs)
state.animalCare = Object.fromEntries(action.payload.database.animalCare)
state.animalDiseases = Object.fromEntries(action.payload.database.animalDiseases)
state.animals = Object.fromEntries(action.payload.database.animals)
state.animalShapePaths = Object.fromEntries(action.payload.database.animalShapePaths)
state.animalShapes = Object.fromEntries(action.payload.database.animalShapes)
state.animalShapeSizes = Object.fromEntries(action.payload.database.animalShapeSizes)
state.animalTypes = Object.fromEntries(action.payload.database.animalTypes)
state.animistPowers = Object.fromEntries(action.payload.database.animistPowers)
state.animistPowerTribes = Object.fromEntries(action.payload.database.animistPowerTribes)
state.arcaneBardTraditions = Object.fromEntries(action.payload.database.arcaneBardTraditions)
state.arcaneDancerTraditions = Object.fromEntries(action.payload.database.arcaneDancerTraditions)
state.arcaneOrbEnchantments = Object.fromEntries(action.payload.database.arcaneOrbEnchantments)
state.armors = Object.fromEntries(action.payload.database.armors)
state.armorTypes = Object.fromEntries(action.payload.database.armorTypes)
state.aspects = Object.fromEntries(action.payload.database.aspects)
state.attireEnchantments = Object.fromEntries(action.payload.database.attireEnchantments)
state.attributes = Object.fromEntries(action.payload.database.attributes)
state.bandagesAndRemedies = Object.fromEntries(action.payload.database.bandagesAndRemedies)
state.blessedTraditions = Object.fromEntries(action.payload.database.blessedTraditions)
state.blessings = Object.fromEntries(action.payload.database.blessings)
state.books = Object.fromEntries(action.payload.database.books)
state.bowlEnchantments = Object.fromEntries(action.payload.database.bowlEnchantments)
state.brawlingSpecialAbilities = Object.fromEntries(action.payload.database.brawlingSpecialAbilities)
state.brews = Object.fromEntries(action.payload.database.brews)
state.cantrips = Object.fromEntries(action.payload.database.cantrips)
state.cauldronEnchantments = Object.fromEntries(action.payload.database.cauldronEnchantments)
state.ceremonialItems = Object.fromEntries(action.payload.database.ceremonialItems)
state.ceremonialItemSpecialAbilities = Object.fromEntries(action.payload.database.ceremonialItemSpecialAbilities)
state.ceremonies = Object.fromEntries(action.payload.database.ceremonies)
state.chronicleEnchantments = Object.fromEntries(action.payload.database.chronicleEnchantments)
state.closeCombatTechniques = Object.fromEntries(action.payload.database.closeCombatTechniques)
state.clothes = Object.fromEntries(action.payload.database.clothes)
state.combatSpecialAbilities = Object.fromEntries(action.payload.database.combatSpecialAbilities)
state.combatStyleSpecialAbilities = Object.fromEntries(action.payload.database.combatStyleSpecialAbilities)
state.commandSpecialAbilities = Object.fromEntries(action.payload.database.commandSpecialAbilities)
state.conditions = Object.fromEntries(action.payload.database.conditions)
state.containers = Object.fromEntries(action.payload.database.containers)
state.continents = Object.fromEntries(action.payload.database.continents)
state.coreRules = Object.fromEntries(action.payload.database.coreRules)
state.cultures = Object.fromEntries(action.payload.database.cultures)
state.curses = Object.fromEntries(action.payload.database.curses)
state.daggerRituals = Object.fromEntries(action.payload.database.daggerRituals)
state.derivedCharacteristics = Object.fromEntries(action.payload.database.derivedCharacteristics)
state.disadvantages = Object.fromEntries(action.payload.database.disadvantages)
state.diseases = Object.fromEntries(action.payload.database.diseases)
state.dominationRituals = Object.fromEntries(action.payload.database.dominationRituals)
state.elements = Object.fromEntries(action.payload.database.elements)
state.elixirs = Object.fromEntries(action.payload.database.elixirs)
state.elvenMagicalSongs = Object.fromEntries(action.payload.database.elvenMagicalSongs)
state.equipmentOfBlessedOnes = Object.fromEntries(action.payload.database.equipmentOfBlessedOnes)
state.equipmentPackages = Object.fromEntries(action.payload.database.equipmentPackages)
state.experienceLevels = Object.fromEntries(action.payload.database.experienceLevels)
state.eyeColors = Object.fromEntries(action.payload.database.eyeColors)
state.familiarSpecialAbilities = Object.fromEntries(action.payload.database.familiarSpecialAbilities)
state.familiarsTricks = Object.fromEntries(action.payload.database.familiarsTricks)
state.fatePointSexSpecialAbilities = Object.fromEntries(action.payload.database.fatePointSexSpecialAbilities)
state.fatePointSpecialAbilities = Object.fromEntries(action.payload.database.fatePointSpecialAbilities)
state.focusRules = Object.fromEntries(action.payload.database.focusRules)
state.focusRuleSubjects = Object.fromEntries(action.payload.database.focusRuleSubjects)
state.foolsHatEnchantments = Object.fromEntries(action.payload.database.foolsHatEnchantments)
state.gemsAndPreciousStones = Object.fromEntries(action.payload.database.gemsAndPreciousStones)
state.generalSpecialAbilities = Object.fromEntries(action.payload.database.generalSpecialAbilities)
state.geodeRituals = Object.fromEntries(action.payload.database.geodeRituals)
state.hairColors = Object.fromEntries(action.payload.database.hairColors)
state.illuminationLightSources = Object.fromEntries(action.payload.database.illuminationLightSources)
state.illuminationRefillsAndSupplies = Object.fromEntries(action.payload.database.illuminationRefillsAndSupplies)
state.instrumentEnchantments = Object.fromEntries(action.payload.database.instrumentEnchantments)
state.jesterTricks = Object.fromEntries(action.payload.database.jesterTricks)
state.jewelry = Object.fromEntries(action.payload.database.jewelry)
state.karmaSpecialAbilities = Object.fromEntries(action.payload.database.karmaSpecialAbilities)
state.kirchenpraegungen = Object.fromEntries(action.payload.database.kirchenpraegungen)
state.krallenkettenzauber = Object.fromEntries(action.payload.database.krallenkettenzauber)
state.languages = Object.fromEntries(action.payload.database.languages)
state.lessonsCurricula = Object.fromEntries(action.payload.database.lessonsCurricula)
state.lessonsGuidelines = Object.fromEntries(action.payload.database.lessonsGuidelines)
state.liebesspielzeug = Object.fromEntries(action.payload.database.liebesspielzeug)
state.liturgicalChants = Object.fromEntries(action.payload.database.liturgicalChants)
state.liturgicalStyleSpecialAbilities = Object.fromEntries(action.payload.database.liturgicalStyleSpecialAbilities)
state.locales = Object.fromEntries(action.payload.database.locales)
state.luxuryGoods = Object.fromEntries(action.payload.database.luxuryGoods)
state.lycantropicGifts = Object.fromEntries(action.payload.database.lycantropicGifts)
state.magicalArtifacts = Object.fromEntries(action.payload.database.magicalArtifacts)
state.magicalDances = Object.fromEntries(action.payload.database.magicalDances)
state.magicalMelodies = Object.fromEntries(action.payload.database.magicalMelodies)
state.magicalRunes = Object.fromEntries(action.payload.database.magicalRunes)
state.magicalSigns = Object.fromEntries(action.payload.database.magicalSigns)
state.magicalSpecialAbilities = Object.fromEntries(action.payload.database.magicalSpecialAbilities)
state.magicalTraditions = Object.fromEntries(action.payload.database.magicalTraditions)
state.magicStyleSpecialAbilities = Object.fromEntries(action.payload.database.magicStyleSpecialAbilities)
state.metaConditions = Object.fromEntries(action.payload.database.metaConditions)
state.musicalInstruments = Object.fromEntries(action.payload.database.musicalInstruments)
state.optionalRules = Object.fromEntries(action.payload.database.optionalRules)
state.orbEnchantments = Object.fromEntries(action.payload.database.orbEnchantments)
state.orienteeringAids = Object.fromEntries(action.payload.database.orienteeringAids)
state.pactCategories = Object.fromEntries(action.payload.database.pactCategories)
state.pactGifts = Object.fromEntries(action.payload.database.pactGifts)
state.patronCategories = Object.fromEntries(action.payload.database.patronCategories)
state.patrons = Object.fromEntries(action.payload.database.patrons)
state.personalityTraits = Object.fromEntries(action.payload.database.personalityTraits)
state.poisons = Object.fromEntries(action.payload.database.poisons)
state.professions = Object.fromEntries(action.payload.database.professions)
state.properties = Object.fromEntries(action.payload.database.properties)
state.protectiveWardingCircleSpecialAbilities = Object.fromEntries(action.payload.database.protectiveWardingCircleSpecialAbilities)
state.publications = Object.fromEntries(action.payload.database.publications)
state.races = Object.fromEntries(action.payload.database.races)
state.rangedCombatTechniques = Object.fromEntries(action.payload.database.rangedCombatTechniques)
state.reaches = Object.fromEntries(action.payload.database.reaches)
state.regions = Object.fromEntries(action.payload.database.regions)
state.ringEnchantments = Object.fromEntries(action.payload.database.ringEnchantments)
state.rituals = Object.fromEntries(action.payload.database.rituals)
state.ropesAndChains = Object.fromEntries(action.payload.database.ropesAndChains)
state.scripts = Object.fromEntries(action.payload.database.scripts)
state.sermons = Object.fromEntries(action.payload.database.sermons)
state.services = Object.fromEntries(action.payload.database.services)
state.sexPractices = Object.fromEntries(action.payload.database.sexPractices)
state.sexSpecialAbilities = Object.fromEntries(action.payload.database.sexSpecialAbilities)
state.sickleRituals = Object.fromEntries(action.payload.database.sickleRituals)
state.sikaryanDrainSpecialAbilities = Object.fromEntries(action.payload.database.sikaryanDrainSpecialAbilities)
state.skillGroups = Object.fromEntries(action.payload.database.skillGroups)
state.skillModificationLevels = Object.fromEntries(action.payload.database.skillModificationLevels)
state.skills = Object.fromEntries(action.payload.database.skills)
state.skillStyleSpecialAbilities = Object.fromEntries(action.payload.database.skillStyleSpecialAbilities)
state.socialStatuses = Object.fromEntries(action.payload.database.socialStatuses)
state.spells = Object.fromEntries(action.payload.database.spells)
state.spellSwordEnchantments = Object.fromEntries(action.payload.database.spellSwordEnchantments)
state.staffEnchantments = Object.fromEntries(action.payload.database.staffEnchantments)
state.states = Object.fromEntries(action.payload.database.states)
state.stationary = Object.fromEntries(action.payload.database.stationary)
state.talismans = Object.fromEntries(action.payload.database.talismans)
state.targetCategories = Object.fromEntries(action.payload.database.targetCategories)
state.thievesTools = Object.fromEntries(action.payload.database.thievesTools)
state.toolsOfTheTrade = Object.fromEntries(action.payload.database.toolsOfTheTrade)
state.toyEnchantments = Object.fromEntries(action.payload.database.toyEnchantments)
state.tradeSecrets = Object.fromEntries(action.payload.database.tradeSecrets)
state.travelGearAndTools = Object.fromEntries(action.payload.database.travelGearAndTools)
state.trinkhornzauber = Object.fromEntries(action.payload.database.trinkhornzauber)
state.ui = Object.fromEntries(action.payload.database.ui)
state.vampiricGifts = Object.fromEntries(action.payload.database.vampiricGifts)
state.vehicles = Object.fromEntries(action.payload.database.vehicles)
state.visions = Object.fromEntries(action.payload.database.visions)
state.wandEnchantments = Object.fromEntries(action.payload.database.wandEnchantments)
state.weaponAccessories = Object.fromEntries(action.payload.database.weaponAccessories)
state.weaponEnchantments = Object.fromEntries(action.payload.database.weaponEnchantments)
state.weapons = Object.fromEntries(action.payload.database.weapons)
state.zibiljaRituals = Object.fromEntries(action.payload.database.zibiljaRituals)
state.advancedCombatSpecialAbilities = Object.fromEntries(action.payload.database.raw.advancedCombatSpecialAbilities)
state.advancedKarmaSpecialAbilities = Object.fromEntries(action.payload.database.raw.advancedKarmaSpecialAbilities)
state.advancedMagicalSpecialAbilities = Object.fromEntries(action.payload.database.raw.advancedMagicalSpecialAbilities)
state.advancedSkillSpecialAbilities = Object.fromEntries(action.payload.database.raw.advancedSkillSpecialAbilities)
state.advantages = Object.fromEntries(action.payload.database.raw.advantages)
state.alchemicae = Object.fromEntries(action.payload.database.raw.alchemicae)
state.ammunition = Object.fromEntries(action.payload.database.raw.ammunition)
state.ancestorGlyphs = Object.fromEntries(action.payload.database.raw.ancestorGlyphs)
state.animalCare = Object.fromEntries(action.payload.database.raw.animalCare)
state.animalDiseases = Object.fromEntries(action.payload.database.raw.animalDiseases)
state.animals = Object.fromEntries(action.payload.database.raw.animals)
state.animalShapePaths = Object.fromEntries(action.payload.database.raw.animalShapePaths)
state.animalShapes = Object.fromEntries(action.payload.database.raw.animalShapes)
state.animalShapeSizes = Object.fromEntries(action.payload.database.raw.animalShapeSizes)
state.animalTypes = Object.fromEntries(action.payload.database.raw.animalTypes)
state.animistPowers = Object.fromEntries(action.payload.database.raw.animistPowers)
state.animistPowerTribes = Object.fromEntries(action.payload.database.raw.animistPowerTribes)
state.arcaneBardTraditions = Object.fromEntries(action.payload.database.raw.arcaneBardTraditions)
state.arcaneDancerTraditions = Object.fromEntries(action.payload.database.raw.arcaneDancerTraditions)
state.arcaneOrbEnchantments = Object.fromEntries(action.payload.database.raw.arcaneOrbEnchantments)
state.armors = Object.fromEntries(action.payload.database.raw.armors)
state.armorTypes = Object.fromEntries(action.payload.database.raw.armorTypes)
state.aspects = Object.fromEntries(action.payload.database.raw.aspects)
state.attireEnchantments = Object.fromEntries(action.payload.database.raw.attireEnchantments)
state.attributes = Object.fromEntries(action.payload.database.raw.attributes)
state.bandagesAndRemedies = Object.fromEntries(action.payload.database.raw.bandagesAndRemedies)
state.blessedTraditions = Object.fromEntries(action.payload.database.raw.blessedTraditions)
state.blessings = Object.fromEntries(action.payload.database.raw.blessings)
state.books = Object.fromEntries(action.payload.database.raw.books)
state.bowlEnchantments = Object.fromEntries(action.payload.database.raw.bowlEnchantments)
state.brawlingSpecialAbilities = Object.fromEntries(action.payload.database.raw.brawlingSpecialAbilities)
state.brews = Object.fromEntries(action.payload.database.raw.brews)
state.cantrips = Object.fromEntries(action.payload.database.raw.cantrips)
state.cache = action.payload.database.cache
state.cauldronEnchantments = Object.fromEntries(action.payload.database.raw.cauldronEnchantments)
state.ceremonialItems = Object.fromEntries(action.payload.database.raw.ceremonialItems)
state.ceremonialItemSpecialAbilities = Object.fromEntries(action.payload.database.raw.ceremonialItemSpecialAbilities)
state.ceremonies = Object.fromEntries(action.payload.database.raw.ceremonies)
state.chronicleEnchantments = Object.fromEntries(action.payload.database.raw.chronicleEnchantments)
state.closeCombatTechniques = Object.fromEntries(action.payload.database.raw.closeCombatTechniques)
state.clothes = Object.fromEntries(action.payload.database.raw.clothes)
state.combatSpecialAbilities = Object.fromEntries(action.payload.database.raw.combatSpecialAbilities)
state.combatStyleSpecialAbilities = Object.fromEntries(action.payload.database.raw.combatStyleSpecialAbilities)
state.commandSpecialAbilities = Object.fromEntries(action.payload.database.raw.commandSpecialAbilities)
state.conditions = Object.fromEntries(action.payload.database.raw.conditions)
state.containers = Object.fromEntries(action.payload.database.raw.containers)
state.continents = Object.fromEntries(action.payload.database.raw.continents)
state.coreRules = Object.fromEntries(action.payload.database.raw.coreRules)
state.cultures = Object.fromEntries(action.payload.database.raw.cultures)
state.curses = Object.fromEntries(action.payload.database.raw.curses)
state.daggerRituals = Object.fromEntries(action.payload.database.raw.daggerRituals)
state.derivedCharacteristics = Object.fromEntries(action.payload.database.raw.derivedCharacteristics)
state.disadvantages = Object.fromEntries(action.payload.database.raw.disadvantages)
state.diseases = Object.fromEntries(action.payload.database.raw.diseases)
state.dominationRituals = Object.fromEntries(action.payload.database.raw.dominationRituals)
state.elements = Object.fromEntries(action.payload.database.raw.elements)
state.elixirs = Object.fromEntries(action.payload.database.raw.elixirs)
state.elvenMagicalSongs = Object.fromEntries(action.payload.database.raw.elvenMagicalSongs)
state.equipmentOfBlessedOnes = Object.fromEntries(action.payload.database.raw.equipmentOfBlessedOnes)
state.equipmentPackages = Object.fromEntries(action.payload.database.raw.equipmentPackages)
state.experienceLevels = Object.fromEntries(action.payload.database.raw.experienceLevels)
state.eyeColors = Object.fromEntries(action.payload.database.raw.eyeColors)
state.familiarSpecialAbilities = Object.fromEntries(action.payload.database.raw.familiarSpecialAbilities)
state.familiarsTricks = Object.fromEntries(action.payload.database.raw.familiarsTricks)
state.fatePointSexSpecialAbilities = Object.fromEntries(action.payload.database.raw.fatePointSexSpecialAbilities)
state.fatePointSpecialAbilities = Object.fromEntries(action.payload.database.raw.fatePointSpecialAbilities)
state.focusRules = Object.fromEntries(action.payload.database.raw.focusRules)
state.focusRuleSubjects = Object.fromEntries(action.payload.database.raw.focusRuleSubjects)
state.foolsHatEnchantments = Object.fromEntries(action.payload.database.raw.foolsHatEnchantments)
state.gemsAndPreciousStones = Object.fromEntries(action.payload.database.raw.gemsAndPreciousStones)
state.generalSpecialAbilities = Object.fromEntries(action.payload.database.raw.generalSpecialAbilities)
state.geodeRituals = Object.fromEntries(action.payload.database.raw.geodeRituals)
state.hairColors = Object.fromEntries(action.payload.database.raw.hairColors)
state.illuminationLightSources = Object.fromEntries(action.payload.database.raw.illuminationLightSources)
state.illuminationRefillsAndSupplies = Object.fromEntries(action.payload.database.raw.illuminationRefillsAndSupplies)
state.instrumentEnchantments = Object.fromEntries(action.payload.database.raw.instrumentEnchantments)
state.jesterTricks = Object.fromEntries(action.payload.database.raw.jesterTricks)
state.jewelry = Object.fromEntries(action.payload.database.raw.jewelry)
state.karmaSpecialAbilities = Object.fromEntries(action.payload.database.raw.karmaSpecialAbilities)
state.kirchenpraegungen = Object.fromEntries(action.payload.database.raw.kirchenpraegungen)
state.krallenkettenzauber = Object.fromEntries(action.payload.database.raw.krallenkettenzauber)
state.languages = Object.fromEntries(action.payload.database.raw.languages)
state.lessonsCurricula = Object.fromEntries(action.payload.database.raw.lessonsCurricula)
state.lessonsGuidelines = Object.fromEntries(action.payload.database.raw.lessonsGuidelines)
state.liebesspielzeug = Object.fromEntries(action.payload.database.raw.liebesspielzeug)
state.liturgicalChants = Object.fromEntries(action.payload.database.raw.liturgicalChants)
state.liturgicalStyleSpecialAbilities = Object.fromEntries(action.payload.database.raw.liturgicalStyleSpecialAbilities)
state.locales = Object.fromEntries(action.payload.database.raw.locales)
state.luxuryGoods = Object.fromEntries(action.payload.database.raw.luxuryGoods)
state.lycantropicGifts = Object.fromEntries(action.payload.database.raw.lycantropicGifts)
state.magicalArtifacts = Object.fromEntries(action.payload.database.raw.magicalArtifacts)
state.magicalDances = Object.fromEntries(action.payload.database.raw.magicalDances)
state.magicalMelodies = Object.fromEntries(action.payload.database.raw.magicalMelodies)
state.magicalRunes = Object.fromEntries(action.payload.database.raw.magicalRunes)
state.magicalSigns = Object.fromEntries(action.payload.database.raw.magicalSigns)
state.magicalSpecialAbilities = Object.fromEntries(action.payload.database.raw.magicalSpecialAbilities)
state.magicalTraditions = Object.fromEntries(action.payload.database.raw.magicalTraditions)
state.magicStyleSpecialAbilities = Object.fromEntries(action.payload.database.raw.magicStyleSpecialAbilities)
state.metaConditions = Object.fromEntries(action.payload.database.raw.metaConditions)
state.musicalInstruments = Object.fromEntries(action.payload.database.raw.musicalInstruments)
state.optionalRules = Object.fromEntries(action.payload.database.raw.optionalRules)
state.orbEnchantments = Object.fromEntries(action.payload.database.raw.orbEnchantments)
state.orienteeringAids = Object.fromEntries(action.payload.database.raw.orienteeringAids)
state.pactCategories = Object.fromEntries(action.payload.database.raw.pactCategories)
state.pactGifts = Object.fromEntries(action.payload.database.raw.pactGifts)
state.patronCategories = Object.fromEntries(action.payload.database.raw.patronCategories)
state.patrons = Object.fromEntries(action.payload.database.raw.patrons)
state.personalityTraits = Object.fromEntries(action.payload.database.raw.personalityTraits)
state.poisons = Object.fromEntries(action.payload.database.raw.poisons)
state.professions = Object.fromEntries(action.payload.database.raw.professions)
state.properties = Object.fromEntries(action.payload.database.raw.properties)
state.protectiveWardingCircleSpecialAbilities = Object.fromEntries(action.payload.database.raw.protectiveWardingCircleSpecialAbilities)
state.publications = Object.fromEntries(action.payload.database.raw.publications)
state.races = Object.fromEntries(action.payload.database.raw.races)
state.rangedCombatTechniques = Object.fromEntries(action.payload.database.raw.rangedCombatTechniques)
state.reaches = Object.fromEntries(action.payload.database.raw.reaches)
state.regions = Object.fromEntries(action.payload.database.raw.regions)
state.ringEnchantments = Object.fromEntries(action.payload.database.raw.ringEnchantments)
state.rituals = Object.fromEntries(action.payload.database.raw.rituals)
state.ropesAndChains = Object.fromEntries(action.payload.database.raw.ropesAndChains)
state.scripts = Object.fromEntries(action.payload.database.raw.scripts)
state.sermons = Object.fromEntries(action.payload.database.raw.sermons)
state.services = Object.fromEntries(action.payload.database.raw.services)
state.sexPractices = Object.fromEntries(action.payload.database.raw.sexPractices)
state.sexSpecialAbilities = Object.fromEntries(action.payload.database.raw.sexSpecialAbilities)
state.sickleRituals = Object.fromEntries(action.payload.database.raw.sickleRituals)
state.sikaryanDrainSpecialAbilities = Object.fromEntries(action.payload.database.raw.sikaryanDrainSpecialAbilities)
state.skillGroups = Object.fromEntries(action.payload.database.raw.skillGroups)
state.skillModificationLevels = Object.fromEntries(action.payload.database.raw.skillModificationLevels)
state.skills = Object.fromEntries(action.payload.database.raw.skills)
state.skillStyleSpecialAbilities = Object.fromEntries(action.payload.database.raw.skillStyleSpecialAbilities)
state.socialStatuses = Object.fromEntries(action.payload.database.raw.socialStatuses)
state.spells = Object.fromEntries(action.payload.database.raw.spells)
state.spellSwordEnchantments = Object.fromEntries(action.payload.database.raw.spellSwordEnchantments)
state.staffEnchantments = Object.fromEntries(action.payload.database.raw.staffEnchantments)
state.states = Object.fromEntries(action.payload.database.raw.states)
state.stationary = Object.fromEntries(action.payload.database.raw.stationary)
state.talismans = Object.fromEntries(action.payload.database.raw.talismans)
state.targetCategories = Object.fromEntries(action.payload.database.raw.targetCategories)
state.thievesTools = Object.fromEntries(action.payload.database.raw.thievesTools)
state.toolsOfTheTrade = Object.fromEntries(action.payload.database.raw.toolsOfTheTrade)
state.toyEnchantments = Object.fromEntries(action.payload.database.raw.toyEnchantments)
state.tradeSecrets = Object.fromEntries(action.payload.database.raw.tradeSecrets)
state.travelGearAndTools = Object.fromEntries(action.payload.database.raw.travelGearAndTools)
state.trinkhornzauber = Object.fromEntries(action.payload.database.raw.trinkhornzauber)
state.ui = Object.fromEntries(action.payload.database.raw.ui)
state.vampiricGifts = Object.fromEntries(action.payload.database.raw.vampiricGifts)
state.vehicles = Object.fromEntries(action.payload.database.raw.vehicles)
state.visions = Object.fromEntries(action.payload.database.raw.visions)
state.wandEnchantments = Object.fromEntries(action.payload.database.raw.wandEnchantments)
state.weaponAccessories = Object.fromEntries(action.payload.database.raw.weaponAccessories)
state.weaponEnchantments = Object.fromEntries(action.payload.database.raw.weaponEnchantments)
state.weapons = Object.fromEntries(action.payload.database.raw.weapons)
state.zibiljaRituals = Object.fromEntries(action.payload.database.raw.zibiljaRituals)
})
},
})
+13 -11
View File
@@ -1,8 +1,11 @@
import { IpcRendererEvent, contextBridge, ipcRenderer } from "electron"
import EventEmitter from "events"
import { ValidResults } from "optolith-database-schema"
import type { Database } from "../database/index.ts"
import { GlobalSettings } from "../shared/settings/GlobalSettings.ts"
import { GlobalSettingsEvents, attachGlobalSettingsEvents } from "../shared/settings/listeningRendererPreload.ts"
import {
GlobalSettingsEvents,
attachGlobalSettingsEvents,
} from "../shared/settings/listeningRendererPreload.ts"
import { TypedEventEmitterForEvent } from "../shared/utils/events.ts"
export type PreloadAPI = {
@@ -24,14 +27,13 @@ export type PreloadAPI = {
setTitle: (title: string) => void
} & Events
type Events =
& TypedEventEmitterForEvent<"initial-setup", [InitialSetupEventMessage]>
& TypedEventEmitterForEvent<"maximize", []>
& TypedEventEmitterForEvent<"unmaximize", []>
& TypedEventEmitterForEvent<"blur", []>
& TypedEventEmitterForEvent<"focus", []>
& TypedEventEmitterForEvent<"new-character", []>
& GlobalSettingsEvents
type Events = TypedEventEmitterForEvent<"initial-setup", [InitialSetupEventMessage]> &
TypedEventEmitterForEvent<"maximize", []> &
TypedEventEmitterForEvent<"unmaximize", []> &
TypedEventEmitterForEvent<"blur", []> &
TypedEventEmitterForEvent<"focus", []> &
TypedEventEmitterForEvent<"new-character", []> &
GlobalSettingsEvents
const events = new EventEmitter() as Events
@@ -60,7 +62,7 @@ const api: PreloadAPI = {
contextBridge.exposeInMainWorld("optolith", api)
export type InitialSetupEventMessage = {
database: ValidResults
database: Database
globalSettings: GlobalSettings
systemLocale: string
}