@@ -12,11 +12,13 @@ import { TextDocument } from 'vscode-languageserver-textdocument'
12
12
import type { ConfigGenerator } from '../Config.js'
13
13
import siteConfig from '../Config.js'
14
14
import { 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'
17
17
import { IndexedDbFileSystem } from './FileSystem.js'
18
18
import type { VersionId } from './Versions.js'
19
19
20
+ const SPYGLASS_API = 'https://api.spyglassmc.com'
21
+
20
22
export const CACHE_URI = 'file:///cache/'
21
23
export const ROOT_URI = 'file:///root/'
22
24
export const DEPENDENCY_URI = `${ ROOT_URI } dependency/`
@@ -367,10 +369,10 @@ async function compressBall(files: [string, string][]): Promise<Uint8Array> {
367
369
const initialize : core . ProjectInitializer = async ( ctx ) => {
368
370
const { config, logger, meta, externals, cacheRoot } = ctx
369
371
370
- const vanillaMcdoc = await fetchVanillaMcdoc ( )
372
+ const vanillaMcdocRes = await fetchWithCache ( ` ${ SPYGLASS_API } /vanilla-mcdoc/symbols` )
371
373
meta . registerSymbolRegistrar ( 'vanilla-mcdoc' , {
372
- checksum : vanillaMcdoc . ref ,
373
- registrar : vanillaMcdocRegistrar ( vanillaMcdoc ) ,
374
+ checksum : vanillaMcdocRes . headers . get ( 'ETag' ) ?? '' ,
375
+ registrar : vanillaMcdocRegistrar ( await vanillaMcdocRes . json ( ) ) ,
374
376
} )
375
377
376
378
meta . registerDependencyProvider ( '@misode-mcdoc' , async ( ) => {
@@ -479,6 +481,10 @@ function registerAttributes(meta: core.MetaRegistry, release: ReleaseVersion, ve
479
481
480
482
const VanillaMcdocUri = 'mcdoc://vanilla-mcdoc/symbols.json'
481
483
484
+ interface VanillaMcdocSymbols {
485
+ mcdoc : Record < string , unknown > ,
486
+ 'mcdoc/dispatcher' : Record < string , Record < string , unknown > > ,
487
+ }
482
488
function vanillaMcdocRegistrar ( vanillaMcdoc : VanillaMcdocSymbols ) : core . SymbolRegistrar {
483
489
return ( symbols ) => {
484
490
const start = performance . now ( )
0 commit comments