diff --git a/lib/identity.js b/lib/identity.js index cfceae4..e082727 100644 --- a/lib/identity.js +++ b/lib/identity.js @@ -636,10 +636,19 @@ export function installAssembleGuard(prompt, rewriteFn) { return false; } if (typeof original !== "function") return false; + // cordis 每次读 assemble 都新包一层 createShadowMethod。已包装则立刻返回, + // 绝不把这次读到的新代理写进 accessor(#82 / PR #83)。 + if (original._dshPurgeWrapped) { + if (original._dshPurgeSlot) original._dshPurgeSlot.rewrite = rewriteFn; + return true; + } const slot = { rewrite: rewriteFn }; const wrap = (fn) => { if (typeof fn !== "function") return fn; - if (fn._dshPurgeWrapped && fn._dshPurgeSlot === slot) return fn; + if (fn._dshPurgeWrapped) { + if (fn._dshPurgeSlot) fn._dshPurgeSlot.rewrite = slot.rewrite; + return fn; + } const orig = typeof fn.bind === "function" ? fn.bind(prompt) : fn; const wrapped = async function assembleWithPurge(...args) { const assembled = await orig(...args);