Disable mcdoc simplified type caching

This commit is contained in:
Misode
2024-11-27 04:42:51 +01:00
parent a86a707232
commit 2bc0fc23d8
4 changed files with 853 additions and 46 deletions

842
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -9,7 +9,8 @@
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview",
"lint": "eslint . --ext .ts,.tsx"
"lint": "eslint . --ext .ts,.tsx",
"postinstall": "patch-package"
},
"keywords": [],
"author": "Misode",
@@ -56,6 +57,7 @@
"@typescript-eslint/parser": "^5.28.0",
"autoprefixer": "^10.4.16",
"eslint": "^8.17.0",
"patch-package": "^8.0.0",
"postcss": "^8.4.31",
"preact": "^10.8.0",
"preact-router": "^3.2.1",

View File

@@ -0,0 +1,44 @@
diff --git a/node_modules/@spyglassmc/mcdoc/lib/runtime/checker/index.js b/node_modules/@spyglassmc/mcdoc/lib/runtime/checker/index.js
index 2d51735..70ac4a0 100644
--- a/node_modules/@spyglassmc/mcdoc/lib/runtime/checker/index.js
+++ b/node_modules/@spyglassmc/mcdoc/lib/runtime/checker/index.js
@@ -545,9 +545,9 @@ function simplifyReference(typeDef, context) {
context.ctx.logger.warn(`Tried to access unknown reference ${typeDef.path}`);
return { typeDef: { kind: 'union', members: [] } };
}
- if (data.simplifiedTypeDef) {
- return { typeDef: data.simplifiedTypeDef };
- }
+ // if (data.simplifiedTypeDef) {
+ // return { typeDef: data.simplifiedTypeDef };
+ // }
const simplifiedResult = simplify(data.typeDef, context);
if (typeDef.attributes?.length) {
simplifiedResult.typeDef = {
@@ -555,16 +555,16 @@ function simplifyReference(typeDef, context) {
attributes: [...typeDef.attributes, ...simplifiedResult.typeDef.attributes ?? []],
};
}
- if (!simplifiedResult.dynamicData) {
- symbol.amend({
- data: {
- data: {
- ...data,
- simplifiedTypeDef: simplifiedResult.typeDef,
- },
- },
- });
- }
+ // if (!simplifiedResult.dynamicData) {
+ // symbol.amend({
+ // data: {
+ // data: {
+ // ...data,
+ // simplifiedTypeDef: simplifiedResult.typeDef,
+ // },
+ // },
+ // });
+ // }
return simplifiedResult;
}
function simplifyDispatcher(typeDef, context) {

View File

@@ -80,6 +80,7 @@ export class SpyglassClient {
}
export class SpyglassService {
private static activeServiceId = 1
private readonly fileWatchers = new Map<string, ((docAndNode: core.DocAndNode) => void)[]>()
private readonly treeWatchers: { prefix: string, handler: (uris: string[]) => void }[] = []
@@ -280,6 +281,8 @@ export class SpyglassService {
}
public static async create(versionId: VersionId, client: SpyglassClient) {
SpyglassService.activeServiceId += 1
const currentServiceId = SpyglassService.activeServiceId
await Promise.allSettled(INITIAL_DIRS.map(async uri => client.externals.fs.mkdir(uri)))
const version = siteConfig.versions.find(v => v.id === versionId)!
const logger = console
@@ -331,7 +334,11 @@ export class SpyglassService {
})
await service.project.ready()
setTimeout(() => {
service.project.cacheService.save()
if (currentServiceId === SpyglassService.activeServiceId) {
service.project.cacheService.save()
} else {
logger.info('[SpyglassService] Skipped saving the cache because another service is active')
}
}, 10_000)
return new SpyglassService(versionId, service, client)
}