Skip to content

Commit

Permalink
[exfiltrate] patch defineProperty (hotfix for flux dispatcher not get…
Browse files Browse the repository at this point in the history
…ting found)
  • Loading branch information
ioj4 committed Mar 28, 2024
1 parent 3386f51 commit 2bcd644
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions packages/shelter/src/exfiltrate.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { before } from "spitroast";
const current = new Set<string>();

export default function (prop: string, filter?: (t: any) => boolean) {
Expand All @@ -23,16 +24,23 @@ export default function (prop: string, filter?: (t: any) => boolean) {
enumerable: true,
value: v,
});

if (!filter || filter(this)) {
res(this);
if (!hitProto) delete Object.prototype[prop];
}
},

get() {
return this[protoKey];
},
});

const unpatch = before("defineProperty", Object, (args) => {
if (args[1] === prop) {
queueMicrotask(() => {
if (!filter || filter(args[0])) {
unpatch();
res(args[0]);
if (!hitProto) delete Object.prototype[prop];
}
});
}
});
});
}

0 comments on commit 2bcd644

Please sign in to comment.