Use Cache API instead of LocalStorage (#128)

* Use Cache API instead of LocalStorage

* Remove old cached data
This commit is contained in:
Misode
2020-12-30 18:58:54 +01:00
committed by GitHub
parent 847bb43fdd
commit e69559f975
6 changed files with 132 additions and 103 deletions

View File

@@ -1,5 +1,5 @@
import { Errors, Hook, relativePath } from '@mcschema/core'
import { BlockStateRegistry } from '../App'
import { App, BlockStateRegistry } from '../App'
import { getFilterKey } from './getFilterKey'
import { walk } from './walk'
@@ -17,7 +17,7 @@ export const customValidation: Hook<[any, Errors], void> = walk<[Errors]>({
const block = relativePath(path, config.validation.params.id).get()
const errors = path.getModel().errors
const requiredProps = (BlockStateRegistry[block] ?? {}).properties ?? {}
const requiredProps = (App.blockStateRegistry[block] ?? {}).properties ?? {}
const existingKeys = Object.keys(value ?? {})
Object.keys(requiredProps).forEach(p => {
if (!existingKeys.includes(p)) {

View File

@@ -113,7 +113,7 @@ export const renderHtml: Hook<[any, Mounter], [string, string, string]> = {
path.model.set(path.push(key), children.default())
})
let suffix = ''
const blockState = (config.validation?.validator === 'block_state_map' ? BlockStateRegistry[relativePath(path, config.validation.params.id).get()] : null)
const blockState = (config.validation?.validator === 'block_state_map' ? App.blockStateRegistry[relativePath(path, config.validation.params.id).get()] : null)
if (!blockState || blockState.properties) {
const keyRendered = (blockState
? StringNode(null!, { enum: Object.keys(blockState.properties ?? {}) })