Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function init() {
if (ElectronRpcConfiguration.isElectron) {
ElectronRpcManager.initializeImpl({}, rpcInterfaces);
} else {
const rpcConfig = BentleyCloudRpcManager.initializeImpl({ info: { title: "perf-tests", version: "v1.0" } }, rpcInterfaces);
// create a basic express web server
const port = Number(process.env.CERTA_PORT || 3011) + 2000;
const server = new IModelJsExpressServer(rpcConfig.protocol);
await server.initialize(port);
// tslint:disable-next-line:no-console
console.log("Web backend for perf-tests listening on port " + port);
}
}
async function init() {
if (ElectronRpcConfiguration.isElectron) {
ElectronRpcManager.initializeImpl({}, rpcInterfaces);
} else {
const rpcConfig = BentleyCloudRpcManager.initializeImpl({ info: { title: "integration-test", version: "v1.0" } }, rpcInterfaces);
// create a basic express web server
const port = Number(process.env.CERTA_PORT || 3011) + 2000;
const server = new IModelJsExpressServer(rpcConfig.protocol);
await server.initialize(port);
// tslint:disable-next-line:no-console
console.log("Web backend for integration-tests listening on port " + port);
}
}
});
});
await manager.initialize({
width: 1280,
height: 800,
webPreferences: {
nodeIntegration: true,
experimentalFeatures: true, // Needed for CSS Grid support
},
autoHideMenuBar: true,
show: !maximizeWindow,
});
// Initialize application gateway configuration for the backend
ElectronRpcManager.initializeImpl({}, getRpcInterfaces());
if (manager.mainWindow) {
if (maximizeWindow) {
manager.mainWindow.maximize(); // maximize before showing to avoid resize event on startup
manager.mainWindow.show();
}
if (autoOpenDevTools)
manager.mainWindow.webContents.toggleDevTools();
}
// tslint:disable-next-line:no-var-requires
const configPathname = path.normalize(path.join(__dirname, "../webresources", "config.json"));
const configuration = require(configPathname);
if (configuration.useIModelBank) {
electron.app.on("certificate-error", (event, _webContents, _url, _error, _certificate, callback) => {
// (needed temporarily to use self-signed cert to communicate with iModelBank via https)
export default async function initialize(rpcs: RpcInterfaceDefinition[]) {
// tell ElectronRpcManager which RPC interfaces to handle
// __PUBLISH_EXTRACT_START__ Presentation.Backend.RpcInterface
ElectronRpcManager.initializeImpl({}, rpcs);
// __PUBLISH_EXTRACT_END__
const app = (process.env.NODE_ENV === "development") ? new WebpackDevServerElectronManager() : new IModelJsElectronManager();
return app.initialize();
}
(async () => { // tslint:disable-line:no-floating-promises
const manager = new IModelJsElectronManager(path.join(__dirname, "..", "webresources"));
await manager.initialize({
width: 1280,
height: 800,
webPreferences: {
nodeIntegration: true,
experimentalFeatures: true, // Needed for CSS Grid support
},
autoHideMenuBar: true,
show: !maximizeWindow,
});
// Initialize application gateway configuration for the backend
ElectronRpcManager.initializeImpl({}, getRpcInterfaces());
if (manager.mainWindow) {
if (maximizeWindow) {
manager.mainWindow.maximize(); // maximize before showing to avoid resize event on startup
manager.mainWindow.show();
}
if (autoOpenDevTools)
manager.mainWindow.webContents.toggleDevTools();
}
// tslint:disable-next-line:no-var-requires
const configPathname = path.normalize(path.join(__dirname, "../webresources", "config.json"));
const configuration = require(configPathname);
if (configuration.useIModelBank) {
electron.app.on("certificate-error", (event, _webContents, _url, _error, _certificate, callback) => {
// (needed temporarily to use self-signed cert to communicate with iModelBank via https)
public static initializeRpcBackend() {
if (TestbedConfig.useDirect) {
// N/A -- only for testing code within frontend bundle
} else if (TestbedConfig.useIPC) {
ElectronRpcManager.initializeImpl({}, TestbedConfig.rpcInterfaces);
} else {
TestbedConfig.cloudRpc = BentleyCloudRpcManager.initializeImpl(TestbedConfig.cloudRpcParams, TestbedConfig.rpcInterfaces);
TestbedConfig.initializeBentleyCloudCommon();
}
ElectronRpcManager.initializeImpl({}, [TestRpcInterface3]);
// RPC transport testing
RpcManager.registerImpl(RpcWebTransportTest, RpcTransportTestImpl);
RpcManager.registerImpl(RpcElectronTransportTest, RpcTransportTestImpl);
RpcManager.registerImpl(RpcMobileTransportTest, RpcTransportTestImpl);
BentleyCloudRpcManager.initializeImpl(TestbedConfig.cloudRpcParams, [RpcWebTransportTest]);
ElectronRpcManager.initializeImpl({}, [RpcElectronTransportTest]);
MobileRpcManager.initializeImpl([RpcMobileTransportTest]);
}
(async () => { // tslint:disable-line:no-floating-promises
const manager = new IModelJsElectronManager(path.join(__dirname, "..", "..", "webresources"));
await manager.initialize({
width: 800,
height: 650,
autoHideMenuBar: true,
show: true,
webPreferences: {
nodeIntegration: true,
preload: path.join(__dirname, "preload.js"),
},
});
// tell ElectronRpcManager which RPC interfaces to handle
ElectronRpcManager.initializeImpl({}, rpcs);
const mainWindow = manager.mainWindow!;
assert(!!mainWindow);
if (autoOpenDevTools)
mainWindow.webContents.toggleDevTools();
})();
}
export function initializeRpcImplDesktop(interfaces: RpcInterfaceDefinition[]) {
ElectronRpcManager.initializeImpl({}, interfaces);
}
// __PUBLISH_EXTRACT_END__