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

27 lines
1 KiB
JavaScript
Raw Normal View History

2019-07-01 23:00:17 +00:00
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const electron_1 = require("electron");
2019-06-16 20:19:06 +00:00
// Global protocol APIs.
2019-07-01 23:00:17 +00:00
const protocol = process.electronBinding('protocol');
2019-06-16 20:19:06 +00:00
// Fallback protocol APIs of default session.
2019-07-01 23:00:17 +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;
//# sourceMappingURL=protocol.js.map