let chain: Promise = Promise.resolve(); /** 序列化 Threads 瀏覽器操作,避免同時開多個 profile 實例。 */ export function withSessionLock(fn: () => Promise): Promise { const run = chain.then(fn); chain = run.then( () => undefined, () => undefined ); return run; }