semver#major TypeScript Examples
The following examples show how to use
semver#major.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: instance-check.ts From orangehrm-os-mobile with GNU General Public License v3.0 | 6 votes |
checkInstanceCompatibility = (openApiDefinition: any): boolean => {
if (major(openApiDefinition.openapi) === 3) {
if (
gte(openApiDefinition?.info?.version, REQUIRED_MINIMUM_ORANGEHRM_API_VER)
) {
return true;
}
throw new InstanceCheckError('Incompatible OrangeHRM API version.');
}
throw new InstanceCheckError('Incompatible OpenAPI version.');
}
Example #2
Source File: dependency-version-compare.ts From eslint-config-kit with MIT License | 5 votes |
export function getMajor(versionOrRange: string): number {
const version = toVersion(versionOrRange)
return major(version)
}
Example #3
Source File: main.ts From WebCord with MIT License | 4 votes |
// Global `webContents` defaults for hardened security
app.on('web-contents-created', (_event, webContents) => {
const isMainWindow = webContents.session === session.defaultSession;
// Block all permission requests/checks by the default.
if(!isMainWindow){
webContents.session.setPermissionCheckHandler(() => false);
webContents.session.setPermissionRequestHandler((_webContents,_permission,callback) => callback(false));
}
// Block HID request only when Electron supports handling them.
if(major(process.versions.electron) >= 16 || /^(?:14|15)\.1\.\d+.*$/.test(process.versions.electron))
(webContents.session as SessionLatest).setDevicePermissionHandler(() => false);
// Block navigation to the different origin.
webContents.on('will-navigate', (event, url) => {
const originUrl = webContents.getURL();
if (originUrl !== '' && (new URL(originUrl)).origin !== (new URL(url)).origin)
event.preventDefault();
});
// Securely open some urls in external software.
webContents.setWindowOpenHandler((details) => {
const config = new AppConfig().get()
if (!app.isReady()) return { action: 'deny' };
const openUrl = new URL(details.url);
const sameOrigin = new URL(webContents.getURL()).origin === openUrl.origin;
let allowedProtocol = false;
// Check if protocol of `openUrl` is secure.
if (openUrl.protocol.match(trustedProtocolRegExp))
allowedProtocol = true;
/*
* If origins of `openUrl` and current webContents URL are different,
* ask the end user to confirm if the URL is safe enough for him.
* (unless an application user disabled that functionality)
*/
if (allowedProtocol && !sameOrigin && config.redirectionWarning || !isMainWindow) {
const window = BrowserWindow.fromWebContents(webContents);
const strings = (new l10n).client.dialog;
const options: Electron.MessageBoxSyncOptions = {
type: 'warning',
title: strings.common.warning + ': ' + strings.externalApp.title,
message: strings.externalApp.message,
buttons: [strings.common.no, strings.common.yes],
defaultId: 0,
cancelId: 0,
detail: strings.common.source + ':\n' + details.url,
textWidth: 320,
normalizeAccessKeys: true
};
let result: number;
if (window instanceof BrowserWindow)
result = dialog.showMessageBoxSync(window, options);
else
result = dialog.showMessageBoxSync(options);
if (result === 0) return { action: 'deny' };
}
if (allowedProtocol) {
const url = new URL(details.url);
const window = BrowserWindow.fromWebContents(webContents);
if(url.host === knownInstancesList[config.currentInstance][1].host && url.pathname === '/popout')
return {
action: 'allow',
overrideBrowserWindowOptions: {
autoHideMenuBar: true,
...(window ? {BrowserWindow: window} : {}),
fullscreenable: false // not functional with 'children'
}
}
else
shell.openExternal(details.url).catch(commonCatches.print);
}
return { action: 'deny' };
});
// Remove menu from popups
webContents.on("did-create-window", (window) => {
window.removeMenu();
});
});