UNPKG

@yuebai008/cli

Version:

Command line interface for rapid qg-minigame development

1 lines 587 B
import*as Formatter from"../formatter/formatter.js";export class ScopeTreeCache{#e=new WeakMap;#t=new Map;static#r;static instance(){return ScopeTreeCache.#r||(ScopeTreeCache.#r=new ScopeTreeCache),ScopeTreeCache.#r}async scopeTreeForScript(e){const t=this.#e.get(e);if(void 0!==t)return t;const{content:r}=await e.requestContent();if(null===r)return null;const o=this.#t.get(e);if(o)return o;const n=e.isModule?"module":"script",s=Formatter.FormatterWorkerPool.formatterWorkerPool().javaScriptScopeTree(r,n);this.#t.set(e,s);const c=await s;return this.#t.delete(e),this.#e.set(e,c),c}}