Repository URL to install this package:
Version:
2.0.11-7 ▾
|
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const electron_1 = require("electron");
const urlHelpers = require("../shared/urlHelpers");
const path = require("path");
const windowStateKeeper = require("electron-window-state");
const config_1 = require("../config");
const schemeHelpers_1 = require("../shared/schemeHelpers");
const constants_1 = require("../shared/constants");
function getIndexUrl(relativeUrl) {
if (relativeUrl.startsWith("/")) {
relativeUrl = relativeUrl.slice(1);
}
return urlHelpers.format({
pathname: path.resolve(__dirname, "../renderer/index.html"),
protocol: "file:",
slashes: true,
query: {
path: schemeHelpers_1.getSchemeUrl({ httpUrl: config_1.default.baseURL, protocol: config_1.default.protocol }) +
"/" +
relativeUrl,
},
});
}
exports.getIndexUrl = getIndexUrl;
function createWindow(relativeUrl = "") {
const windowState = windowStateKeeper({
defaultWidth: 1320,
defaultHeight: 860,
});
const rect = {
x: windowState.x,
y: windowState.y,
width: windowState.width,
height: windowState.height,
};
const focusedWindow = electron_1.BrowserWindow.getFocusedWindow();
if (focusedWindow) {
const [x, y] = focusedWindow.getPosition();
rect.x = x + 20;
rect.y = y + 20;
const [width, height] = focusedWindow.getSize();
rect.width = width;
rect.height = height;
}
const window = new electron_1.BrowserWindow({
...rect,
show: false,
backgroundColor: "#ffffff",
titleBarStyle: "hiddenInset",
webPreferences: {
preload: path.resolve(__dirname, "../renderer/index.js"),
webviewTag: true,
session: electron_1.session.fromPartition(constants_1.electronSessionPartition),
enableRemoteModule: true,
},
});
window.once("ready-to-show", () => {
window.show();
});
if (focusedWindow) {
if (focusedWindow.isFullScreen()) {
window.setFullScreen(true);
}
}
else {
if (windowState.isFullScreen) {
window.setFullScreen(true);
}
}
window.on("close", () => {
windowState.saveState(window);
});
window.loadURL(getIndexUrl(relativeUrl));
return window;
}
exports.createWindow = createWindow;
//# sourceMappingURL=createWindow.js.map
//notion-enhancer
require('notion-enhancer/pkg/loader.js')(__filename, exports);