show json in resolver source in debug
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
[tools]
|
||||
node = "latest"
|
||||
"npm:vite" = "8.1.3"
|
||||
tinymist = "0.15.0"
|
||||
typst = "0.15.0"
|
||||
|
||||
@@ -157,7 +157,7 @@ export class BlockstateResolver {
|
||||
|
||||
if (!this.pending.has(id)) {
|
||||
const [space, name] = id.split(':');
|
||||
const url = `assets/${space}/blockstates/${name}.json`;
|
||||
const url = `/assets/${space}/blockstates/${name}.json`;
|
||||
|
||||
this.pending.set(id, fetch(url)
|
||||
.then(res => res.json())
|
||||
@@ -165,8 +165,11 @@ export class BlockstateResolver {
|
||||
const source = renderBlockstateResolver(data);
|
||||
|
||||
/** @type {ResolverFunction} */
|
||||
const resolver = new Function(`return function (state, hash) { ${source} } //# sourceURL=${url}`)();
|
||||
|
||||
const resolver = new Function(
|
||||
import.meta.env.DEV
|
||||
? `const raw_data = ${JSON.stringify(data)};\n\nreturn (state, hash) => { ${source} }\n//# sourceURL=${url}`
|
||||
: `return (state, hash) => { ${source} }`
|
||||
)();
|
||||
this.resolvers.set(id, resolver);
|
||||
this.pending.delete(id);
|
||||
|
||||
@@ -178,10 +181,15 @@ export class BlockstateResolver {
|
||||
this.resolvers.set(id, this.resolvers.get(':invalid'));
|
||||
this.pending.delete(id);
|
||||
console.log(`failed to resolve blockstate ${id}: ${reason}`);
|
||||
})
|
||||
);
|
||||
}));
|
||||
}
|
||||
|
||||
return this.resolvers.get(':pending');
|
||||
}
|
||||
|
||||
resolve(id, pos, state) {
|
||||
const resolver = this.getResolver(id);
|
||||
const hash = pos[0] * 3.236 + pos[1] * 4.854 + pos[2] * 8.090;
|
||||
return resolver(state, hash);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user