Skip to content

Commit

Permalink
fixup! dont if cant
Browse files Browse the repository at this point in the history
  • Loading branch information
erights committed Jan 27, 2025
1 parent 1c786d8 commit 95526ee
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions packages/non-trapping-shim/shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,25 @@
import { getEnvironmentOption } from '@endo/env-options';
import { ReflectPlus, ObjectPlus, ProxyPlus } from './src/non-trapping-pony.js';

const { isFrozen } = Object;

const nonTrappingShimOption = getEnvironmentOption(
'SES_NON_TRAPPING_SHIM',
'disabled',
['enabled'],
);

if (nonTrappingShimOption === 'enabled') {
// TODO figure this out, either remove directive or change to
// at-ts-expect-error.
// @ts-ignore type of ReflectPlus vs Reflect, I think
globalThis.Reflect = ReflectPlus;
if (![Reflect, Object, Object.prototype, Proxy].some(isFrozen)) {
// TODO figure this out, either remove directive or change to
// at-ts-expect-error.
// @ts-ignore type of ReflectPlus vs Reflect, I think
globalThis.Reflect = ReflectPlus;

globalThis.Object = ObjectPlus;
// eslint-disable-next-line no-extend-native
Object.prototype.constructor = ObjectPlus;
globalThis.Object = ObjectPlus;
// eslint-disable-next-line no-extend-native
Object.prototype.constructor = ObjectPlus;

globalThis.Proxy = ProxyPlus;
globalThis.Proxy = ProxyPlus;
}
}

0 comments on commit 95526ee

Please sign in to comment.