asarfuckery/electronasar/ptb/browser/api/protocol.js

27 lines
993 B
JavaScript
Raw Normal View History

2019-10-01 13:49:56 +00:00
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const electron_1 = require("electron");
2019-01-17 18:22:05 +00:00
// Global protocol APIs.
2019-10-01 13:49:56 +00:00
const protocol = process.electronBinding('protocol');
2019-01-17 18:22:05 +00:00
// Fallback protocol APIs of default session.
2019-10-01 13:49:56 +00:00
Object.setPrototypeOf(protocol, new Proxy({}, {
get(_target, property) {
if (!electron_1.app.isReady())
return;
const protocol = electron_1.session.defaultSession.protocol;
if (!Object.getPrototypeOf(protocol).hasOwnProperty(property))
return;
// Returning a native function directly would throw error.
return (...args) => protocol[property](...args);
},
ownKeys() {
if (!electron_1.app.isReady())
return [];
return Object.getOwnPropertyNames(Object.getPrototypeOf(electron_1.session.defaultSession.protocol));
},
getOwnPropertyDescriptor() {
return { configurable: true, enumerable: true };
}
}));
exports.default = protocol;