@@ -12,11 +12,13 @@ import { TextDocument } from 'vscode-languageserver-textdocument'
1212import type { ConfigGenerator } from '../Config.js'
1313import siteConfig from '../Config.js'
1414import { computeIfAbsent , genPath } from '../Utils.js'
15- import type { VanillaMcdocSymbols , VersionMeta } from './DataFetcher.js'
16- import { fetchBlockStates , fetchRegistries , fetchVanillaMcdoc , fetchVersions , getVersionChecksum } from './DataFetcher.js'
15+ import type { VersionMeta } from './DataFetcher.js'
16+ import { fetchBlockStates , fetchRegistries , fetchVersions , fetchWithCache , getVersionChecksum } from './DataFetcher.js'
1717import { IndexedDbFileSystem } from './FileSystem.js'
1818import type { VersionId } from './Versions.js'
1919
20+ const SPYGLASS_API = 'https://api.spyglassmc.com'
21+
2022export const CACHE_URI = 'file:///cache/'
2123export const ROOT_URI = 'file:///root/'
2224export const DEPENDENCY_URI = `${ ROOT_URI } dependency/`
@@ -367,10 +369,10 @@ async function compressBall(files: [string, string][]): Promise<Uint8Array> {
367369const initialize : core . ProjectInitializer = async ( ctx ) => {
368370 const { config, logger, meta, externals, cacheRoot } = ctx
369371
370- const vanillaMcdoc = await fetchVanillaMcdoc ( )
372+ const vanillaMcdocRes = await fetchWithCache ( ` ${ SPYGLASS_API } /vanilla-mcdoc/symbols` )
371373 meta . registerSymbolRegistrar ( 'vanilla-mcdoc' , {
372- checksum : vanillaMcdoc . ref ,
373- registrar : vanillaMcdocRegistrar ( vanillaMcdoc ) ,
374+ checksum : vanillaMcdocRes . headers . get ( 'ETag' ) ?? '' ,
375+ registrar : vanillaMcdocRegistrar ( await vanillaMcdocRes . json ( ) ) ,
374376 } )
375377
376378 meta . registerDependencyProvider ( '@misode-mcdoc' , async ( ) => {
@@ -479,6 +481,10 @@ function registerAttributes(meta: core.MetaRegistry, release: ReleaseVersion, ve
479481
480482const VanillaMcdocUri = 'mcdoc://vanilla-mcdoc/symbols.json'
481483
484+ interface VanillaMcdocSymbols {
485+ mcdoc : Record < string , unknown > ,
486+ 'mcdoc/dispatcher' : Record < string , Record < string , unknown > > ,
487+ }
482488function vanillaMcdocRegistrar ( vanillaMcdoc : VanillaMcdocSymbols ) : core . SymbolRegistrar {
483489 return ( symbols ) => {
484490 const start = performance . now ( )
0 commit comments