diff --git a/src/app/Main.tsx b/src/app/Main.tsx index c3cb34d3..5e21cdb3 100644 --- a/src/app/Main.tsx +++ b/src/app/Main.tsx @@ -9,7 +9,7 @@ import { Analytics } from './Analytics' import { Header } from './components' import { loadLocale, locale, Locales } from './Locales' import { Changelog, Generator, Home, Sounds, Worldgen } from './pages' -import type { VersionId } from './Schemas' +import type { VersionId } from './services' import { Store } from './Store' import { cleanUrl } from './Utils' diff --git a/src/app/Store.ts b/src/app/Store.ts index b591703f..b8aa4c35 100644 --- a/src/app/Store.ts +++ b/src/app/Store.ts @@ -1,5 +1,5 @@ -import type { VersionId } from './Schemas' -import { VersionIds } from './Schemas' +import type { VersionId } from './services' +import { VersionIds } from './services' export namespace Store { export const ID_LANGUAGE = 'language' diff --git a/src/app/components/Header.tsx b/src/app/components/Header.tsx index df7635d5..4e3f236b 100644 --- a/src/app/components/Header.tsx +++ b/src/app/components/Header.tsx @@ -2,8 +2,8 @@ import { getCurrentUrl, Link, route } from 'preact-router' import { Btn, BtnMenu, Icons, Octicon } from '.' import config from '../../config.json' import { locale } from '../Locales' -import type { VersionId } from '../Schemas' -import { checkVersion } from '../Schemas' +import type { VersionId } from '../services' +import { checkVersion } from '../services' import { cleanUrl, getGenerator } from '../Utils' const Themes: Record = { diff --git a/src/app/components/generator/PreviewPanel.tsx b/src/app/components/generator/PreviewPanel.tsx index 4c0689cf..d22f4bcd 100644 --- a/src/app/components/generator/PreviewPanel.tsx +++ b/src/app/components/generator/PreviewPanel.tsx @@ -2,7 +2,7 @@ import type { DataModel } from '@mcschema/core' import { Path } from '@mcschema/core' import { useState } from 'preact/hooks' import { useModel } from '../../hooks' -import type { VersionId } from '../../Schemas' +import type { VersionId } from '../../services' import { BiomeSourcePreview, DecoratorPreview, NoisePreview, NoiseSettingsPreview } from '../previews' export const HasPreview = ['dimension', 'worldgen/noise', 'worldgen/noise_settings', 'worldgen/configured_feature'] diff --git a/src/app/components/generator/SourcePanel.tsx b/src/app/components/generator/SourcePanel.tsx index d6eb59e1..44d47299 100644 --- a/src/app/components/generator/SourcePanel.tsx +++ b/src/app/components/generator/SourcePanel.tsx @@ -4,7 +4,7 @@ import { Btn, BtnMenu } from '..' import { useModel } from '../../hooks' import { locale } from '../../Locales' import { transformOutput } from '../../schema/transformOutput' -import type { BlockStateRegistry } from '../../Schemas' +import type { BlockStateRegistry } from '../../services' import { Store } from '../../Store' import { message } from '../../Utils' diff --git a/src/app/components/generator/Tree.tsx b/src/app/components/generator/Tree.tsx index 00cba130..fd357a47 100644 --- a/src/app/components/generator/Tree.tsx +++ b/src/app/components/generator/Tree.tsx @@ -2,7 +2,7 @@ import type { DataModel } from '@mcschema/core' import { useErrorBoundary, useState } from 'preact/hooks' import { useModel } from '../../hooks' import { FullNode } from '../../schema/renderHtml' -import type { BlockStateRegistry, VersionId } from '../../Schemas' +import type { BlockStateRegistry, VersionId } from '../../services' type TreePanelProps = { lang: string, diff --git a/src/app/components/previews/NoiseSettingsPreview.tsx b/src/app/components/previews/NoiseSettingsPreview.tsx index 007a1bdc..8c681801 100644 --- a/src/app/components/previews/NoiseSettingsPreview.tsx +++ b/src/app/components/previews/NoiseSettingsPreview.tsx @@ -4,7 +4,7 @@ import { Btn, BtnInput, BtnMenu } from '..' import { useCanvas } from '../../hooks' import { locale } from '../../Locales' import { noiseSettings } from '../../previews' -import { checkVersion } from '../../Schemas' +import { checkVersion } from '../../services' import { randomSeed } from '../../Utils' export const NoiseSettingsPreview = ({ lang, data, shown, version }: PreviewProps) => { diff --git a/src/app/components/previews/index.ts b/src/app/components/previews/index.ts index 4cafa253..22bd54c5 100644 --- a/src/app/components/previews/index.ts +++ b/src/app/components/previews/index.ts @@ -1,5 +1,5 @@ import type { DataModel } from '@mcschema/core' -import type { VersionId } from '../../Schemas' +import type { VersionId } from '../../services' export * from './BiomeSourcePreview' export * from './DecoratorPreview' diff --git a/src/app/components/sounds/SoundConfig.tsx b/src/app/components/sounds/SoundConfig.tsx index 68e7db19..3a4b4c73 100644 --- a/src/app/components/sounds/SoundConfig.tsx +++ b/src/app/components/sounds/SoundConfig.tsx @@ -1,9 +1,9 @@ import { Howl } from 'howler' import { useEffect, useRef, useState } from 'preact/hooks' import { Btn, NumberInput, RangeInput, TextInput } from '..' -import { getResourceUrl } from '../../DataFetcher' import { locale } from '../../Locales' -import type { SoundEvents, VersionAssets } from '../../Manifest' +import type { SoundEvents, VersionAssets } from '../../services' +import { getResourceUrl } from '../../services' export interface SoundConfig { id: string, diff --git a/src/app/pages/Changelog.tsx b/src/app/pages/Changelog.tsx index aa12527c..9a8f14b2 100644 --- a/src/app/pages/Changelog.tsx +++ b/src/app/pages/Changelog.tsx @@ -2,9 +2,8 @@ import marked from 'marked' import { useEffect, useMemo, useState } from 'preact/hooks' import { Ad, Btn, ErrorPanel, Octicon, TextInput } from '../components' import { locale } from '../Locales' -import type { VersionId } from '../Schemas' -import type { ChangelogEntry, ChangelogVersion } from '../services/Changelogs' -import { getChangelogs } from '../services/Changelogs' +import type { ChangelogEntry, ChangelogVersion, VersionId } from '../services' +import { getChangelogs } from '../services' import { hashString } from '../Utils' type ChangelogProps = { diff --git a/src/app/pages/Generator.tsx b/src/app/pages/Generator.tsx index 5da863b5..9fddc54e 100644 --- a/src/app/pages/Generator.tsx +++ b/src/app/pages/Generator.tsx @@ -4,11 +4,10 @@ import { useEffect, useErrorBoundary, useRef, useState } from 'preact/hooks' import config from '../../config.json' import { Analytics } from '../Analytics' import { Ad, Btn, BtnInput, BtnMenu, ErrorPanel, HasPreview, Octicon, PreviewPanel, SourcePanel, Tree } from '../components' -import { fetchPreset } from '../DataFetcher' import { useModel } from '../hooks' import { locale } from '../Locales' -import type { BlockStateRegistry, VersionId } from '../Schemas' -import { checkVersion, getBlockStates, getCollections, getModel } from '../Schemas' +import type { BlockStateRegistry, VersionId } from '../services' +import { checkVersion, fetchPreset, getBlockStates, getCollections, getModel } from '../services' import { getGenerator, message } from '../Utils' type GeneratorProps = { diff --git a/src/app/pages/Sounds.tsx b/src/app/pages/Sounds.tsx index 445cfe22..1d5c5a33 100644 --- a/src/app/pages/Sounds.tsx +++ b/src/app/pages/Sounds.tsx @@ -2,9 +2,8 @@ import { useEffect, useRef, useState } from 'preact/hooks' import config from '../../config.json' import { Ad, Btn, BtnMenu, ErrorPanel, SoundConfig, TextInput } from '../components' import { locale } from '../Locales' -import type { SoundEvents, VersionAssets } from '../Manifest' -import { getAssets, getSounds } from '../Manifest' -import type { VersionId } from '../Schemas' +import type { SoundEvents, VersionAssets, VersionId } from '../services' +import { getAssets, getSounds } from '../services' import { hexId, message } from '../Utils' type SoundsProps = { diff --git a/src/app/previews/BiomeSource.ts b/src/app/previews/BiomeSource.ts index b335defa..7b23fd23 100644 --- a/src/app/previews/BiomeSource.ts +++ b/src/app/previews/BiomeSource.ts @@ -4,8 +4,8 @@ import { FixedBiome, LegacyRandom, NormalNoise, TerrainShaper } from 'deepslate' import init, { biome_parameters, climate_noise, climate_sampler, multi_noise } from 'deepslate-rs' // @ts-expect-error import wasm from 'deepslate-rs/deepslate_rs_bg.wasm?url' -import { fetchPreset } from '../DataFetcher' -import type { VersionId } from '../Schemas' +import type { VersionId } from '../services' +import { fetchPreset } from '../services' import { BiMap, clamp, deepClone, deepEqual, square, stringToColor } from '../Utils' let ready = false diff --git a/src/app/previews/Decorator.ts b/src/app/previews/Decorator.ts index c07307fb..e7fa4644 100644 --- a/src/app/previews/Decorator.ts +++ b/src/app/previews/Decorator.ts @@ -1,7 +1,7 @@ import { DataModel } from '@mcschema/core' import type { Random } from 'deepslate' import { LegacyRandom, PerlinNoise } from 'deepslate' -import type { VersionId } from '../Schemas' +import type { VersionId } from '../services' import { clamp, stringToColor } from '../Utils' type BlockPos = [number, number, number] diff --git a/src/app/previews/NoiseSettings.ts b/src/app/previews/NoiseSettings.ts index 1500ee29..c9aceecb 100644 --- a/src/app/previews/NoiseSettings.ts +++ b/src/app/previews/NoiseSettings.ts @@ -2,8 +2,8 @@ import { DataModel } from '@mcschema/core' import type { BlockPos, BlockState } from 'deepslate' import { Chunk, ChunkPos, FixedBiome, NoiseChunkGenerator, NoiseGeneratorSettings } from 'deepslate' import { getOctaves } from '../components' -import type { VersionId } from '../Schemas' -import { checkVersion } from '../Schemas' +import type { VersionId } from '../services' +import { checkVersion } from '../services' import { deepClone, deepEqual } from '../Utils' import { NoiseChunkGenerator as OldNoiseChunkGenerator } from './noise/NoiseChunkGenerator' diff --git a/src/app/previews/NormalNoise.ts b/src/app/previews/NormalNoise.ts index aedc3e07..dfd20e84 100644 --- a/src/app/previews/NormalNoise.ts +++ b/src/app/previews/NormalNoise.ts @@ -1,6 +1,6 @@ import { DataModel } from '@mcschema/core' import { LegacyRandom, NoiseParameters, NormalNoise } from 'deepslate' -import type { VersionId } from '../Schemas' +import type { VersionId } from '../services' export type NoiseOptions = { offset: [number, number], diff --git a/src/app/schema/renderHtml.tsx b/src/app/schema/renderHtml.tsx index fc3398dd..c621ce9a 100644 --- a/src/app/schema/renderHtml.tsx +++ b/src/app/schema/renderHtml.tsx @@ -3,12 +3,11 @@ import { DataModel, ListNode, MapNode, ModelPath, ObjectNode, Path, relativePath import type { ComponentChildren, JSX } from 'preact' import { memo } from 'preact/compat' import { useState } from 'preact/hooks' -import { Btn } from '../components' -import { Octicon } from '../components/Octicon' +import { Btn, Octicon } from '../components' import { useFocus } from '../hooks' import { locale } from '../Locales' -import type { BlockStateRegistry } from '../Schemas' -import { CachedDecorator, CachedFeature } from '../Schemas' +import type { BlockStateRegistry } from '../services' +import { CachedDecorator, CachedFeature } from '../services' import { deepClone, deepEqual, hexId, isObject, newSeed } from '../Utils' import { ModelWrapper } from './ModelWrapper' diff --git a/src/app/schema/transformOutput.ts b/src/app/schema/transformOutput.ts index 1cc107eb..cca2264e 100644 --- a/src/app/schema/transformOutput.ts +++ b/src/app/schema/transformOutput.ts @@ -1,6 +1,6 @@ import type { Hook } from '@mcschema/core' import { relativePath } from '@mcschema/core' -import type { BlockStateRegistry } from '../Schemas' +import type { BlockStateRegistry } from '../services' export type OutputProps = { blockStates: BlockStateRegistry, diff --git a/src/app/DataFetcher.ts b/src/app/services/DataFetcher.ts similarity index 99% rename from src/app/DataFetcher.ts rename to src/app/services/DataFetcher.ts index fae6f599..c82a2137 100644 --- a/src/app/DataFetcher.ts +++ b/src/app/services/DataFetcher.ts @@ -1,9 +1,9 @@ import type { CollectionRegistry } from '@mcschema/core' -import config from '../config.json' +import config from '../../config.json' +import { message } from '../Utils' import type { VersionAssets, VersionManifest } from './Manifest' import type { BlockStateRegistry, VersionId } from './Schemas' import { checkVersion } from './Schemas' -import { message } from './Utils' ['1.15', '1.16', '1.17'].forEach(v => localStorage.removeItem(`cache_${v}`)) diff --git a/src/app/Manifest.ts b/src/app/services/Manifest.ts similarity index 100% rename from src/app/Manifest.ts rename to src/app/services/Manifest.ts diff --git a/src/app/Schemas.ts b/src/app/services/Schemas.ts similarity index 98% rename from src/app/Schemas.ts rename to src/app/services/Schemas.ts index 69695b08..c13aa0c4 100644 --- a/src/app/Schemas.ts +++ b/src/app/services/Schemas.ts @@ -4,9 +4,9 @@ import * as java15 from '@mcschema/java-1.15' import * as java16 from '@mcschema/java-1.16' import * as java17 from '@mcschema/java-1.17' import * as java18 from '@mcschema/java-1.18' -import config from '../config.json' +import config from '../../config.json' +import { message } from '../Utils' import { fetchData } from './DataFetcher' -import { message } from './Utils' export const VersionIds = ['1.15', '1.16', '1.17', '1.18'] as const export type VersionId = typeof VersionIds[number] diff --git a/src/app/services/index.ts b/src/app/services/index.ts new file mode 100644 index 00000000..13380d71 --- /dev/null +++ b/src/app/services/index.ts @@ -0,0 +1,4 @@ +export * from './Changelogs' +export * from './DataFetcher' +export * from './Manifest' +export * from './Schemas'