diff --git a/package-lock.json b/package-lock.json index 2dd0c7ec..f8e8342d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,9 +5,9 @@ "requires": true, "dependencies": { "@mcschema/core": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/@mcschema/core/-/core-0.12.0.tgz", - "integrity": "sha512-9QXK9mDbHfW6h6A1CE3gC86sUf/5SmwnzuW5LXN3ByPcXRIKLP+NIY3jz+n6UjPpWkzZ/wBryh9rsb2CgPO/BQ==" + "version": "0.12.2", + "resolved": "https://registry.npmjs.org/@mcschema/core/-/core-0.12.2.tgz", + "integrity": "sha512-zd6mYVzIecAYsDOcZV4YfxnDgJ+m0U4x7mLlBbuMfawA7RMQW9tLpOx/xdsoImBhM4C9hlRrCkkEPQXoi5xc6g==" }, "@mcschema/java-1.15": { "version": "0.2.0", diff --git a/package.json b/package.json index 3c660585..7d7a7dff 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "author": "Misode", "license": "MIT", "dependencies": { - "@mcschema/core": "^0.12.0", + "@mcschema/core": "^0.12.2", "@mcschema/java-1.15": "^0.2.0", "@mcschema/java-1.16": "^0.6.0", "@mcschema/java-1.17": "^0.2.0", diff --git a/src/app/hooks/canFlatten.ts b/src/app/hooks/canFlatten.ts index deb4dabe..3a735bfe 100644 --- a/src/app/hooks/canFlatten.ts +++ b/src/app/hooks/canFlatten.ts @@ -3,12 +3,6 @@ import { getFilterKey } from './getFilterKey' export const canFlatten: Hook<[], boolean> = { base: () => false, - boolean: () => false, - choice: () => false, - list: () => false, - map: () => false, - number: () => false, - string: () => false, object({ node, getActiveFields }, path) { const filterKey = path.modelArr.length === 0 ? null : node.hook(getFilterKey, path, path) const visibleEntries = Object.entries(getActiveFields(path)) diff --git a/src/app/hooks/customValidation.ts b/src/app/hooks/customValidation.ts index 84a0e761..ac5abd5c 100644 --- a/src/app/hooks/customValidation.ts +++ b/src/app/hooks/customValidation.ts @@ -6,12 +6,6 @@ import { walk } from './walk' export const customValidation: Hook<[any, Errors], void> = walk<[Errors]>({ base() {}, - boolean() {}, - - choice() {}, - - list() {}, - map({ config }, path, value) { if (config.validation?.validator === 'block_state_map') { const block = relativePath(path, config.validation.params.id).get() @@ -31,8 +25,6 @@ export const customValidation: Hook<[any, Errors], void> = walk<[Errors]>({ } }, - number() {}, - object({ node, getActiveFields }, path, value) { let activeFields = getActiveFields(path) const filterKey = path.modelArr.length === 0 ? null : node.hook(getFilterKey, path, path) @@ -44,7 +36,5 @@ export const customValidation: Hook<[any, Errors], void> = walk<[Errors]>({ path.push(visibleKeys[0]).set(undefined) } } - }, - - string() {} + } }) diff --git a/src/app/hooks/getFilterKey.ts b/src/app/hooks/getFilterKey.ts index aaaa4c4a..89424e8d 100644 --- a/src/app/hooks/getFilterKey.ts +++ b/src/app/hooks/getFilterKey.ts @@ -2,12 +2,6 @@ import { Hook, ModelPath, relativePath } from '@mcschema/core' export const getFilterKey: Hook<[ModelPath, number?], string | null> = { base: () => null, - boolean: () => null, - choice: () => null, - list: () => null, - map: () => null, - number: () => null, - string: () => null, object({ filter, getActiveFields }, path, origin, depth = 0) { if (depth > 2) return null if (filter) { diff --git a/src/app/hooks/suffixInjector.ts b/src/app/hooks/suffixInjector.ts index bbd295e1..f903c684 100644 --- a/src/app/hooks/suffixInjector.ts +++ b/src/app/hooks/suffixInjector.ts @@ -9,10 +9,6 @@ import { Tracker } from '../Tracker' export const suffixInjector: Hook<[Mounter], string | void> = { base() {}, - boolean() {}, - list() {}, - map() {}, - number() {}, choice({ switchNode }, path, mounter) { return switchNode.hook(this, path, mounter) diff --git a/src/app/hooks/transformOutput.ts b/src/app/hooks/transformOutput.ts index eac78f57..eb5ceba3 100644 --- a/src/app/hooks/transformOutput.ts +++ b/src/app/hooks/transformOutput.ts @@ -5,10 +5,6 @@ export const transformOutput: Hook<[any], any> = { return value }, - boolean({}, _, value) { - return value - }, - choice({ switchNode }, path, value) { return switchNode.hook(this, path, value) }, @@ -29,10 +25,6 @@ export const transformOutput: Hook<[any], any> = { return res; }, - number({}, _, value) { - return value - }, - object({ getActiveFields }, path, value) { if (value === undefined || value === null || typeof value !== 'object') { return value @@ -45,9 +37,5 @@ export const transformOutput: Hook<[any], any> = { res[f] = activeFields[f].hook(this, path.push(f), value[f]) }) return res - }, - - string({}, _, value) { - return value } } diff --git a/src/app/hooks/walk.ts b/src/app/hooks/walk.ts index c6ab67e1..365e5d4b 100644 --- a/src/app/hooks/walk.ts +++ b/src/app/hooks/walk.ts @@ -6,12 +6,12 @@ export const walk = (hook: Hook<[any, ...U], void>): Hook<[any, ...hook, choice(params, path, value, ...args) { - hook.choice(params, path, value, ...args) + (hook.choice ?? hook.base)(params, path, value, ...args) params.switchNode.hook(this, path, value, ...args) }, list(params, path, value, ...args) { - hook.list(params, path, value, ...args) + (hook.list ?? hook.base)(params, path, value, ...args) if (!Array.isArray(value)) return value.forEach((e, i) => params.children.hook(this, path.push(i), e, ...args) @@ -19,7 +19,7 @@ export const walk = (hook: Hook<[any, ...U], void>): Hook<[any, }, map(params, path, value, ...args) { - hook.map(params, path, value, ...args) + (hook.map ?? hook.base)(params, path, value, ...args) if (typeof value !== 'object') return Object.keys(value).forEach(f => params.children.hook(this, path.push(f), value[f], ...args) @@ -27,7 +27,7 @@ export const walk = (hook: Hook<[any, ...U], void>): Hook<[any, }, object(params, path, value, ...args) { - hook.object(params, path, value, ...args) + (hook.object ?? hook.base)(params, path, value, ...args) if (value === null || typeof value !== 'object') return const activeFields = params.getActiveFields(path) Object.keys(activeFields)