function createPolicyProxy({ hook, item, scope, policy }) {
    /**
     * Creates a trap that captures function invocation
     */
    function createAccessTrap(inputPath, currentItem) {
        return !canBeObserved(currentItem) || isBindCallApply(currentItem)
            ? currentItem
            : new Proxy(currentItem, {
                /**
                 * Constructs a new instance of the given target
                 */
                construct(target, argArray, newTarget) {
                    // Don't proceed if the hook says no
                    if (!hook({
                        kind: "__$$_PROXY_CONSTRUCT" /* CONSTRUCT */,
                        policy,
                        newTarget,
                        argArray,
                        target,
                        path: stringifyPath(inputPath)
                    })) {
                        return {};
                    }
                    return Reflect.construct(target, argArray, newTarget);
                },
                /**
                 * A trap for a function call. Used to create new proxies for methods on the retrieved module objects
                 */
                apply(target, thisArg, argArray = []) {
                    // Don't proceed if the hook says no
                    if (!hook({
                        kind: "__$$_PROXY_APPLY" /* APPLY */,
                        policy,
                        thisArg,
                        argArray,
                        target,
                        path: stringifyPath(inputPath)
                    })) {
                        return;
                    }
                    return Reflect.apply(target, thisArg, argArray);
                },
                /**
                 * Gets a trap for 'get' accesses
                 */
                get(target, property, receiver) {
                    const newPath = [...inputPath, property];
                    // Don't proceed if the hook says no
                    if (!hook({
                        kind: "__$$_PROXY_GET" /* GET */,
                        policy,
                        path: stringifyPath(newPath),
                        target
                    })) {
                        return;
                    }
                    const match = Reflect.get(target, property, receiver);
                    const config = Reflect.getOwnPropertyDescriptor(currentItem, property);
                    if (config != null && config.configurable === false && config.writable === false) {
                        return currentItem[property];
                    }
                    return createAccessTrap(newPath, match);
                }
            });
    }
    return !canBeObserved(item) ? item : createAccessTrap([scope], item);
}
/**
 * Creates a proxy with hooks to check the given policy
 */
Creates a proxy with hooks to check the given policy
Creates a proxy with hooks to check the given policy
function createPolicyProxy({ hook, item, scope, policy }) {
    function createAccessTrap(inputPath, currentItem) {
        return !canBeObserved(currentItem) || isBindCallApply(currentItem)
            ? currentItem
            : new Proxy(currentItem, {
                construct(target, argArray, newTarget) {
                    if (!hook({
                        kind: "__$$_PROXY_CONSTRUCT" ,
                        policy,
                        newTarget,
                        argArray,
                        target,
                        path: stringifyPath(inputPath)
                    })) {
                        return {};
                    }
                    return Reflect.construct(target, argArray, newTarget);
                },
                apply(target, thisArg, argArray = []) {
                    if (!hook({
                        kind: "__$$_PROXY_APPLY" ,
                        policy,
                        thisArg,
                        argArray,
                        target,
                        path: stringifyPath(inputPath)
                    })) {
                        return;
                    }
                    return Reflect.apply(target, thisArg, argArray);
                },
                get(target, property, receiver) {
                    const newPath = [...inputPath, property];
                    if (!hook({
                        kind: "__$$_PROXY_GET" ,
                        policy,
                        path: stringifyPath(newPath),
                        target
                    })) {
                        return;
                    }
                    const match = Reflect.get(target, property, receiver);
                    const config = Reflect.getOwnPropertyDescriptor(currentItem, property);
                    if (config != null && config.configurable === false && config.writable === false) {
                        return currentItem[property];
                    }
                    return createAccessTrap(newPath, match);
                }
            });
    }
    return !canBeObserved(item) ? item : createAccessTrap([scope], item);
}
function createPolicyProxy ( { hook , item , scope , policy } ) { function createAccessTrap ( inputPath , currentItem ) { return ! canBeObserved ( currentItem ) || isBindCallApply ( currentItem ) ? currentItem : new Proxy ( currentItem , { construct ( target , argArray , newTarget ) { if ( ! hook ( { kind : "__$$_PROXY_CONSTRUCT" , policy , newTarget , argArray , target , path : stringifyPath ( inputPath ) } ) ) { return { } ; } return Reflect . construct ( target , argArray , newTarget ) ; } , apply ( target , thisArg , argArray = [ ] ) { if ( ! hook ( { kind : "__$$_PROXY_APPLY" , policy , thisArg , argArray , target , path : stringifyPath ( inputPath ) } ) ) { return ; } return Reflect . apply ( target , thisArg , argArray ) ; } , get ( target , property , receiver ) { const newPath = [ ... inputPath , property ] ; if ( ! hook ( { kind : "__$$_PROXY_GET" , policy , path : stringifyPath ( newPath ) , target } ) ) { return ; } const match = Reflect . get ( target , property , receiver ) ; const config = Reflect . getOwnPropertyDescriptor ( currentItem , property ) ; if ( config != null && config . configurable === false && config . writable === false ) { return currentItem [ property ] ; } return createAccessTrap ( newPath , match ) ; } } ) ; } return ! canBeObserved ( item ) ? item : createAccessTrap ( [ scope ] , item ) ; }
Creates a proxy with hooks to check the given policy
Creates a proxy with hooks to check the given policy
/**
     * Creates a trap that captures function invocation
     */ /**
                 * Constructs a new instance of the given target
                 */ // Don't proceed if the hook says no /* CONSTRUCT */ /**
                 * A trap for a function call. Used to create new proxies for methods on the retrieved module objects
                 */ // Don't proceed if the hook says no /* APPLY */ /**
                 * Gets a trap for 'get' accesses
                 */ // Don't proceed if the hook says no /* GET */