custom-electron-titlebar 3.2.9 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -203
- package/{build → dist}/browser/browser.d.ts +0 -0
- package/{build → dist}/browser/event.d.ts +0 -0
- package/{build → dist}/browser/iframe.d.ts +0 -0
- package/{build → dist}/browser/keyboardEvent.d.ts +0 -0
- package/{build → dist}/browser/mouseEvent.d.ts +0 -0
- package/{build → dist}/common/arrays.d.ts +0 -0
- package/{build → dist}/common/async.d.ts +0 -0
- package/{build → dist}/common/charCode.d.ts +0 -0
- package/{build → dist}/common/color.d.ts +0 -0
- package/{build → dist}/common/dom.d.ts +0 -0
- package/{build → dist}/common/event.d.ts +0 -0
- package/{build → dist}/common/iterator.d.ts +0 -0
- package/{build → dist}/common/keyCodes.d.ts +0 -0
- package/{build → dist}/common/lifecycle.d.ts +0 -0
- package/{build → dist}/common/linkedList.d.ts +0 -0
- package/{build → dist}/common/platform.d.ts +0 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +1 -0
- package/dist/interfaces.d.ts +95 -0
- package/{build → dist}/menu/menu.d.ts +3 -1
- package/{build → dist}/menu/menuitem.d.ts +3 -4
- package/{build → dist}/menubar.d.ts +1 -24
- package/dist/titlebar.d.ts +77 -0
- package/package.json +23 -16
- package/webpack.config.js +37 -0
- package/.github/ISSUE_TEMPLATE/issue-report.md +0 -29
- package/.vscode/launch.json +0 -49
- package/.vscode/tasks.json +0 -34
- package/build/browser/browser.js +0 -157
- package/build/browser/browser.js.map +0 -1
- package/build/browser/event.js +0 -30
- package/build/browser/event.js.map +0 -1
- package/build/browser/iframe.js +0 -110
- package/build/browser/iframe.js.map +0 -1
- package/build/browser/keyboardEvent.js +0 -226
- package/build/browser/keyboardEvent.js.map +0 -1
- package/build/browser/mouseEvent.js +0 -110
- package/build/browser/mouseEvent.js.map +0 -1
- package/build/common/arrays.js +0 -18
- package/build/common/arrays.js.map +0 -1
- package/build/common/async.js +0 -95
- package/build/common/async.js.map +0 -1
- package/build/common/charCode.js +0 -7
- package/build/common/charCode.js.map +0 -1
- package/build/common/color.js +0 -494
- package/build/common/color.js.map +0 -1
- package/build/common/dom.js +0 -984
- package/build/common/dom.js.map +0 -1
- package/build/common/event.js +0 -611
- package/build/common/event.js.map +0 -1
- package/build/common/iterator.js +0 -164
- package/build/common/iterator.js.map +0 -1
- package/build/common/keyCodes.js +0 -268
- package/build/common/keyCodes.js.map +0 -1
- package/build/common/lifecycle.js +0 -63
- package/build/common/lifecycle.js.map +0 -1
- package/build/common/linkedList.js +0 -139
- package/build/common/linkedList.js.map +0 -1
- package/build/common/platform.js +0 -115
- package/build/common/platform.js.map +0 -1
- package/build/index.d.ts +0 -3
- package/build/index.js +0 -20
- package/build/index.js.map +0 -1
- package/build/menu/menu.js +0 -538
- package/build/menu/menu.js.map +0 -1
- package/build/menu/menuitem.js +0 -339
- package/build/menu/menuitem.js.map +0 -1
- package/build/menubar.js +0 -608
- package/build/menubar.js.map +0 -1
- package/build/themebar.d.ts +0 -20
- package/build/themebar.js +0 -568
- package/build/themebar.js.map +0 -1
- package/build/titlebar.d.ts +0 -135
- package/build/titlebar.js +0 -453
- package/build/titlebar.js.map +0 -1
|
@@ -3,6 +3,7 @@ import { IMenuItem } from "./menuitem";
|
|
|
3
3
|
import { Disposable } from "../common/lifecycle";
|
|
4
4
|
import { Event } from "../common/event";
|
|
5
5
|
import { MenuItem } from "electron";
|
|
6
|
+
import { MenubarOptions } from "../interfaces";
|
|
6
7
|
export declare const MENU_MNEMONIC_REGEX: RegExp;
|
|
7
8
|
export declare const MENU_ESCAPED_MNEMONIC_REGEX: RegExp;
|
|
8
9
|
export interface IMenuOptions {
|
|
@@ -25,13 +26,14 @@ export declare class CETMenu extends Disposable {
|
|
|
25
26
|
private focusedItem?;
|
|
26
27
|
private menuContainer;
|
|
27
28
|
private mnemonics;
|
|
29
|
+
private menubarOptions;
|
|
28
30
|
private options;
|
|
29
31
|
private closeSubMenu;
|
|
30
32
|
private triggerKeys;
|
|
31
33
|
parentData: ISubMenuData;
|
|
32
34
|
private _onDidCancel;
|
|
33
35
|
get onDidCancel(): Event<void>;
|
|
34
|
-
constructor(container: HTMLElement, options?: IMenuOptions, closeSubMenu?: () => void);
|
|
36
|
+
constructor(container: HTMLElement, menubarOptions: MenubarOptions, options?: IMenuOptions, closeSubMenu?: () => void);
|
|
35
37
|
setAriaLabel(label: string): void;
|
|
36
38
|
private isTriggerKeyEvent;
|
|
37
39
|
private updateFocusedItem;
|
|
@@ -3,6 +3,7 @@ import { MenuItem } from "electron";
|
|
|
3
3
|
import { IMenuStyle, IMenuOptions } from "./menu";
|
|
4
4
|
import { KeyCode } from "../common/keyCodes";
|
|
5
5
|
import { Disposable } from "../common/lifecycle";
|
|
6
|
+
import { MenubarOptions } from "../interfaces";
|
|
6
7
|
export interface IMenuItem {
|
|
7
8
|
render(element: HTMLElement): void;
|
|
8
9
|
isEnabled(): boolean;
|
|
@@ -12,6 +13,7 @@ export interface IMenuItem {
|
|
|
12
13
|
dispose(): void;
|
|
13
14
|
}
|
|
14
15
|
export declare class CETMenuItem extends Disposable implements IMenuItem {
|
|
16
|
+
protected menubarOptions: MenubarOptions;
|
|
15
17
|
protected options: IMenuOptions;
|
|
16
18
|
protected menuStyle: IMenuStyle;
|
|
17
19
|
protected container: HTMLElement;
|
|
@@ -19,14 +21,11 @@ export declare class CETMenuItem extends Disposable implements IMenuItem {
|
|
|
19
21
|
private item;
|
|
20
22
|
private radioGroup;
|
|
21
23
|
private labelElement;
|
|
22
|
-
private checkElement;
|
|
23
24
|
private iconElement;
|
|
24
25
|
private mnemonic;
|
|
25
26
|
protected closeSubMenu: () => void;
|
|
26
27
|
protected menuContainer: IMenuItem[];
|
|
27
|
-
|
|
28
|
-
private currentWindow;
|
|
29
|
-
constructor(item: MenuItem, options?: IMenuOptions, closeSubMenu?: () => void, menuContainer?: IMenuItem[]);
|
|
28
|
+
constructor(item: MenuItem, menubarOptions: MenubarOptions, options?: IMenuOptions, closeSubMenu?: () => void, menuContainer?: IMenuItem[]);
|
|
30
29
|
getContainer(): HTMLElement;
|
|
31
30
|
getItem(): MenuItem;
|
|
32
31
|
isEnabled(): boolean;
|
|
@@ -1,30 +1,7 @@
|
|
|
1
|
-
import { Color } from './common/color';
|
|
2
|
-
import { Menu } from 'electron';
|
|
3
1
|
import { IMenuStyle } from './menu/menu';
|
|
4
2
|
import { Disposable } from './common/lifecycle';
|
|
5
3
|
import { Event } from './common/event';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* The menu to show in the title bar.
|
|
9
|
-
* You can use `Menu` or not add this option and the menu created in the main process will be taken.
|
|
10
|
-
* The default menu is taken from the [`Menu.getApplicationMenu()`](https://electronjs.org/docs/api/menu#menugetapplicationmenu)
|
|
11
|
-
*/
|
|
12
|
-
menu?: Menu | null;
|
|
13
|
-
/**
|
|
14
|
-
* The position of menubar on titlebar.
|
|
15
|
-
* *The default is left*
|
|
16
|
-
*/
|
|
17
|
-
menuPosition?: "left" | "bottom";
|
|
18
|
-
/**
|
|
19
|
-
* Enable the mnemonics on menubar and menu items
|
|
20
|
-
* *The default is true*
|
|
21
|
-
*/
|
|
22
|
-
enableMnemonics?: boolean;
|
|
23
|
-
/**
|
|
24
|
-
* The background color when the mouse is over the item.
|
|
25
|
-
*/
|
|
26
|
-
itemBackgroundColor?: Color;
|
|
27
|
-
}
|
|
4
|
+
import { MenubarOptions } from './interfaces';
|
|
28
5
|
export declare class Menubar extends Disposable {
|
|
29
6
|
private container;
|
|
30
7
|
private options?;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Color } from './common/color';
|
|
2
|
+
import { TitlebarOptions } from './interfaces';
|
|
3
|
+
export default class Titlebar {
|
|
4
|
+
private titlebar;
|
|
5
|
+
private dragRegion;
|
|
6
|
+
private windowIcon;
|
|
7
|
+
private title;
|
|
8
|
+
private menubarContainer;
|
|
9
|
+
private windowControls;
|
|
10
|
+
private maxRestoreControl;
|
|
11
|
+
private container;
|
|
12
|
+
private isInactive;
|
|
13
|
+
private menubar;
|
|
14
|
+
private options;
|
|
15
|
+
private resizer;
|
|
16
|
+
private defaultOptions;
|
|
17
|
+
private platformIcons;
|
|
18
|
+
constructor(titlebarOptions?: TitlebarOptions);
|
|
19
|
+
private closeMenu;
|
|
20
|
+
private createTitlebar;
|
|
21
|
+
private onBlur;
|
|
22
|
+
private onFocus;
|
|
23
|
+
private onMenubarVisibilityChanged;
|
|
24
|
+
private onMenubarFocusChanged;
|
|
25
|
+
private onDidChangeMaximized;
|
|
26
|
+
private updateStyles;
|
|
27
|
+
/**
|
|
28
|
+
* Update title bar styles based on focus state.
|
|
29
|
+
* @param hasFocus focus state of the window
|
|
30
|
+
*/
|
|
31
|
+
onWindowFocus(focus: boolean): void;
|
|
32
|
+
/**
|
|
33
|
+
* Update the full screen state and hide or show the title bar.
|
|
34
|
+
* @param fullscreen Fullscreen state of the window
|
|
35
|
+
*/
|
|
36
|
+
onWindowFullScreen(fullscreen: boolean): void;
|
|
37
|
+
/**
|
|
38
|
+
* Update the background color of the title bar
|
|
39
|
+
* @param backgroundColor The color for the background
|
|
40
|
+
*/
|
|
41
|
+
updateBackground(backgroundColor: Color): void;
|
|
42
|
+
/**
|
|
43
|
+
* Update the item background color of the menubar
|
|
44
|
+
* @param itemBGColor The color for the item background
|
|
45
|
+
*/
|
|
46
|
+
updateItemBGColor(itemBGColor: Color): void;
|
|
47
|
+
/**
|
|
48
|
+
* Update the title of the title bar.
|
|
49
|
+
* You can use this method if change the content of `<title>` tag on your html.
|
|
50
|
+
* @param title The title of the title bar and document.
|
|
51
|
+
*/
|
|
52
|
+
updateTitle(title?: string): void;
|
|
53
|
+
/**
|
|
54
|
+
* It method set new icon to title-bar-icon of title-bar.
|
|
55
|
+
* @param path path to icon
|
|
56
|
+
*/
|
|
57
|
+
updateIcon(path: string): void;
|
|
58
|
+
/**
|
|
59
|
+
* Update the default menu or set a new menu.
|
|
60
|
+
* @param menu The menu.
|
|
61
|
+
*/
|
|
62
|
+
updateMenu(menu: Electron.Menu): void;
|
|
63
|
+
/**
|
|
64
|
+
* Update the position of menubar.
|
|
65
|
+
* @param menuPosition The position of the menu `left` or `bottom`.
|
|
66
|
+
*/
|
|
67
|
+
updateMenuPosition(menuPosition: "left" | "bottom"): void;
|
|
68
|
+
/**
|
|
69
|
+
* Horizontal alignment of the title.
|
|
70
|
+
* @param side `left`, `center` or `right`.
|
|
71
|
+
*/
|
|
72
|
+
updateTitleAlignment(side: "left" | "center" | "right"): void;
|
|
73
|
+
/**
|
|
74
|
+
* Remove the titlebar, menubar and all methods.
|
|
75
|
+
*/
|
|
76
|
+
dispose(): void;
|
|
77
|
+
}
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "custom-electron-titlebar",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Custom Electron Titlebar is a library for electron that allows you to configure a fully customizable title bar.",
|
|
5
|
-
"main": "
|
|
6
|
-
"types": "
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"build": "
|
|
9
|
-
"
|
|
10
|
-
"start": "npm run build && npm run
|
|
8
|
+
"build": "webpack --mode=production",
|
|
9
|
+
"example": "electron example/main.js",
|
|
10
|
+
"start": "npm run build && npm run example"
|
|
11
11
|
},
|
|
12
|
-
"author": "
|
|
12
|
+
"author": "AlexTorresSk <alextorressk@gmail.com>",
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"repository": {
|
|
15
15
|
"type": "git",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"keywords": [
|
|
19
19
|
"typescript",
|
|
20
20
|
"electron",
|
|
21
|
-
"
|
|
21
|
+
"title bar",
|
|
22
22
|
"menubar",
|
|
23
23
|
"windows",
|
|
24
24
|
"linux"
|
|
@@ -29,17 +29,24 @@
|
|
|
29
29
|
"homepage": "https://github.com/AlexTorresSk/custom-electron-titlebar#readme",
|
|
30
30
|
"directories": {
|
|
31
31
|
"example": "example",
|
|
32
|
-
"
|
|
32
|
+
"dist": "dist"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"electron": "^
|
|
36
|
-
},
|
|
37
|
-
"dependencies": {
|
|
38
|
-
"@electron/remote": "^1.1.0",
|
|
39
|
-
"@types/node": "^17.0.0"
|
|
35
|
+
"electron": "^16.0.7"
|
|
40
36
|
},
|
|
41
37
|
"devDependencies": {
|
|
42
|
-
"
|
|
43
|
-
"
|
|
38
|
+
"@babel/core": "^7.16.12",
|
|
39
|
+
"@babel/preset-env": "^7.16.11",
|
|
40
|
+
"@types/node": "^17.0.10",
|
|
41
|
+
"babel-loader": "^8.2.3",
|
|
42
|
+
"css-loader": "^6.5.1",
|
|
43
|
+
"electron": "^16.0.7",
|
|
44
|
+
"sass": "^1.49.0",
|
|
45
|
+
"sass-loader": "^12.4.0",
|
|
46
|
+
"style-loader": "^3.3.1",
|
|
47
|
+
"ts-loader": "^9.2.6",
|
|
48
|
+
"typescript": "^4.5.5",
|
|
49
|
+
"webpack": "^5.67.0",
|
|
50
|
+
"webpack-cli": "^4.9.1"
|
|
44
51
|
}
|
|
45
52
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
entry: {
|
|
5
|
+
index: './src/index.ts',
|
|
6
|
+
},
|
|
7
|
+
output: {
|
|
8
|
+
path: path.resolve(__dirname, './dist'),
|
|
9
|
+
filename: 'index.js',
|
|
10
|
+
libraryTarget: 'umd',
|
|
11
|
+
libraryExport: 'default',
|
|
12
|
+
globalObject: 'this',
|
|
13
|
+
},
|
|
14
|
+
resolve: {
|
|
15
|
+
extensions: ['.js', '.ts', '.tsx']
|
|
16
|
+
},
|
|
17
|
+
module: {
|
|
18
|
+
rules: [{
|
|
19
|
+
test: /\.tsx?$/,
|
|
20
|
+
use: "ts-loader",
|
|
21
|
+
exclude: /node_modules/
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
test: /\.scss$/,
|
|
25
|
+
use: [
|
|
26
|
+
{
|
|
27
|
+
loader: "style-loader",
|
|
28
|
+
options: {
|
|
29
|
+
injectType: "lazyStyleTag"
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
"css-loader",
|
|
33
|
+
"sass-loader"
|
|
34
|
+
]
|
|
35
|
+
}]
|
|
36
|
+
}
|
|
37
|
+
};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: Issue report
|
|
3
|
-
about: Create a report to help us improve
|
|
4
|
-
title: ''
|
|
5
|
-
labels: ''
|
|
6
|
-
assignees: ''
|
|
7
|
-
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
**Describe the bug**
|
|
11
|
-
A clear and concise description of what the bug is.
|
|
12
|
-
|
|
13
|
-
**To Reproduce**
|
|
14
|
-
Steps to reproduce the behavior:
|
|
15
|
-
1. Go to '...'
|
|
16
|
-
2. Click on '....'
|
|
17
|
-
3. Scroll down to '....'
|
|
18
|
-
4. See error
|
|
19
|
-
|
|
20
|
-
**Expected behavior**
|
|
21
|
-
A clear and concise description of what you expected to happen.
|
|
22
|
-
|
|
23
|
-
**Screenshots**
|
|
24
|
-
If applicable, add screenshots to help explain your problem.
|
|
25
|
-
|
|
26
|
-
**Desktop (please complete the following information):**
|
|
27
|
-
- OS: [e.g. Windows]
|
|
28
|
-
- Electron version [e.g. 4.0.0]
|
|
29
|
-
- Node Version [e.g. 2.2]
|
package/.vscode/launch.json
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": "0.2.0",
|
|
3
|
-
"configurations": [
|
|
4
|
-
{
|
|
5
|
-
"name": "Electron: Main",
|
|
6
|
-
"type": "node",
|
|
7
|
-
"request": "launch",
|
|
8
|
-
"protocol": "inspector",
|
|
9
|
-
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron",
|
|
10
|
-
"windows": {
|
|
11
|
-
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd"
|
|
12
|
-
},
|
|
13
|
-
"preLaunchTask": "electron-debug",
|
|
14
|
-
"args": ["--remote-debugging-port=9223", "./example/main.js"],
|
|
15
|
-
"outFiles": ["${workspaceFolder}/example/**/*.js"]
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
"name": "Electron: Renderer",
|
|
19
|
-
"type": "chrome",
|
|
20
|
-
"request": "attach",
|
|
21
|
-
"port": 9223,
|
|
22
|
-
"urlFilter": "*index.html",
|
|
23
|
-
// "urlFilter": "http://localhost:*",
|
|
24
|
-
"timeout": 30000,
|
|
25
|
-
"skipFiles": [
|
|
26
|
-
"${workspaceFolder}/node_modules/**/*.js",
|
|
27
|
-
// "${workspaceFolder}/lib/**/*.js",
|
|
28
|
-
"<node_internals>/**/*.js"
|
|
29
|
-
],
|
|
30
|
-
"targetTypes": [
|
|
31
|
-
"page",
|
|
32
|
-
"webview"
|
|
33
|
-
],
|
|
34
|
-
// "trace": true,
|
|
35
|
-
"smartStep": true,
|
|
36
|
-
"showAsyncStacks": true,
|
|
37
|
-
"webRoot": "${workspaceFolder}",
|
|
38
|
-
// "sourceMapPathOverrides": {
|
|
39
|
-
// "webpack:///./src/*": "${webRoot}/*"
|
|
40
|
-
// }
|
|
41
|
-
}
|
|
42
|
-
],
|
|
43
|
-
"compounds": [
|
|
44
|
-
{
|
|
45
|
-
"name": "Electron: All",
|
|
46
|
-
"configurations": ["Electron: Main", "Electron: Renderer"]
|
|
47
|
-
}
|
|
48
|
-
]
|
|
49
|
-
}
|
package/.vscode/tasks.json
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
|
3
|
-
// for the documentation about the tasks.json format
|
|
4
|
-
"version": "2.0.0",
|
|
5
|
-
"tasks": [
|
|
6
|
-
{
|
|
7
|
-
"label": "electron-debug",
|
|
8
|
-
"type": "process",
|
|
9
|
-
"command": "./node_modules/.bin/tsc",
|
|
10
|
-
"windows": {
|
|
11
|
-
"command": "./node_modules/.bin/tsc.cmd"
|
|
12
|
-
},
|
|
13
|
-
"isBackground": true,
|
|
14
|
-
// "args": [],
|
|
15
|
-
"problemMatcher": {
|
|
16
|
-
"owner": "custom",
|
|
17
|
-
"pattern": {
|
|
18
|
-
"regexp": ""
|
|
19
|
-
},
|
|
20
|
-
"background": {
|
|
21
|
-
"beginsPattern": " ",
|
|
22
|
-
"endsPattern": " "
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
"type": "npm",
|
|
28
|
-
"script": "start",
|
|
29
|
-
"problemMatcher": [],
|
|
30
|
-
"label": "npm: start",
|
|
31
|
-
"detail": "npm run build && npm run dev"
|
|
32
|
-
}
|
|
33
|
-
]
|
|
34
|
-
}
|
package/build/browser/browser.js
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*---------------------------------------------------------------------------------------------
|
|
3
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
-
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.hasClipboardSupport = exports.isEdgeWebView = exports.isIPad = exports.isWebkitWebView = exports.isSafari = exports.isChrome = exports.isWebKit = exports.isFirefox = exports.isOpera = exports.isEdgeOrIE = exports.isEdge = exports.isIE = exports.onDidChangeAccessibilitySupport = exports.getAccessibilitySupport = exports.setAccessibilitySupport = exports.onDidChangeFullscreen = exports.isFullscreen = exports.setFullscreen = exports.getPixelRatio = exports.setZoomFactor = exports.getZoomFactor = exports.onDidChangeZoomLevel = exports.getTimeSinceLastZoomLevelChanged = exports.getZoomLevel = exports.setZoomLevel = void 0;
|
|
8
|
-
const event_1 = require("../common/event");
|
|
9
|
-
class WindowManager {
|
|
10
|
-
constructor() {
|
|
11
|
-
// --- Zoom Level
|
|
12
|
-
this._zoomLevel = 0;
|
|
13
|
-
this._lastZoomLevelChangeTime = 0;
|
|
14
|
-
this._onDidChangeZoomLevel = new event_1.Emitter();
|
|
15
|
-
this.onDidChangeZoomLevel = this._onDidChangeZoomLevel.event;
|
|
16
|
-
// --- Zoom Factor
|
|
17
|
-
this._zoomFactor = 0;
|
|
18
|
-
this._onDidChangeFullscreen = new event_1.Emitter();
|
|
19
|
-
this.onDidChangeFullscreen = this._onDidChangeFullscreen.event;
|
|
20
|
-
// --- Accessibility
|
|
21
|
-
this._accessibilitySupport = 0 /* Unknown */;
|
|
22
|
-
this._onDidChangeAccessibilitySupport = new event_1.Emitter();
|
|
23
|
-
this.onDidChangeAccessibilitySupport = this._onDidChangeAccessibilitySupport.event;
|
|
24
|
-
}
|
|
25
|
-
getZoomLevel() {
|
|
26
|
-
return this._zoomLevel;
|
|
27
|
-
}
|
|
28
|
-
getTimeSinceLastZoomLevelChanged() {
|
|
29
|
-
return Date.now() - this._lastZoomLevelChangeTime;
|
|
30
|
-
}
|
|
31
|
-
setZoomLevel(zoomLevel, isTrusted) {
|
|
32
|
-
if (this._zoomLevel === zoomLevel) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
this._zoomLevel = zoomLevel;
|
|
36
|
-
// See https://github.com/Microsoft/vscode/issues/26151
|
|
37
|
-
this._lastZoomLevelChangeTime = isTrusted ? 0 : Date.now();
|
|
38
|
-
this._onDidChangeZoomLevel.fire(this._zoomLevel);
|
|
39
|
-
}
|
|
40
|
-
getZoomFactor() {
|
|
41
|
-
return this._zoomFactor;
|
|
42
|
-
}
|
|
43
|
-
setZoomFactor(zoomFactor) {
|
|
44
|
-
this._zoomFactor = zoomFactor;
|
|
45
|
-
}
|
|
46
|
-
// --- Pixel Ratio
|
|
47
|
-
getPixelRatio() {
|
|
48
|
-
let ctx = document.createElement('canvas').getContext('2d');
|
|
49
|
-
let dpr = window.devicePixelRatio || 1;
|
|
50
|
-
let bsr = ctx.webkitBackingStorePixelRatio ||
|
|
51
|
-
ctx.mozBackingStorePixelRatio ||
|
|
52
|
-
ctx.msBackingStorePixelRatio ||
|
|
53
|
-
ctx.oBackingStorePixelRatio ||
|
|
54
|
-
ctx.backingStorePixelRatio || 1;
|
|
55
|
-
return dpr / bsr;
|
|
56
|
-
}
|
|
57
|
-
setFullscreen(fullscreen) {
|
|
58
|
-
if (this._fullscreen === fullscreen) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
this._fullscreen = fullscreen;
|
|
62
|
-
this._onDidChangeFullscreen.fire();
|
|
63
|
-
}
|
|
64
|
-
isFullscreen() {
|
|
65
|
-
return this._fullscreen;
|
|
66
|
-
}
|
|
67
|
-
setAccessibilitySupport(accessibilitySupport) {
|
|
68
|
-
if (this._accessibilitySupport === accessibilitySupport) {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
this._accessibilitySupport = accessibilitySupport;
|
|
72
|
-
this._onDidChangeAccessibilitySupport.fire();
|
|
73
|
-
}
|
|
74
|
-
getAccessibilitySupport() {
|
|
75
|
-
return this._accessibilitySupport;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
WindowManager.INSTANCE = new WindowManager();
|
|
79
|
-
/** A zoom index, e.g. 1, 2, 3 */
|
|
80
|
-
function setZoomLevel(zoomLevel, isTrusted) {
|
|
81
|
-
WindowManager.INSTANCE.setZoomLevel(zoomLevel, isTrusted);
|
|
82
|
-
}
|
|
83
|
-
exports.setZoomLevel = setZoomLevel;
|
|
84
|
-
function getZoomLevel() {
|
|
85
|
-
return WindowManager.INSTANCE.getZoomLevel();
|
|
86
|
-
}
|
|
87
|
-
exports.getZoomLevel = getZoomLevel;
|
|
88
|
-
/** Returns the time (in ms) since the zoom level was changed */
|
|
89
|
-
function getTimeSinceLastZoomLevelChanged() {
|
|
90
|
-
return WindowManager.INSTANCE.getTimeSinceLastZoomLevelChanged();
|
|
91
|
-
}
|
|
92
|
-
exports.getTimeSinceLastZoomLevelChanged = getTimeSinceLastZoomLevelChanged;
|
|
93
|
-
function onDidChangeZoomLevel(callback) {
|
|
94
|
-
return WindowManager.INSTANCE.onDidChangeZoomLevel(callback);
|
|
95
|
-
}
|
|
96
|
-
exports.onDidChangeZoomLevel = onDidChangeZoomLevel;
|
|
97
|
-
/** The zoom scale for an index, e.g. 1, 1.2, 1.4 */
|
|
98
|
-
function getZoomFactor() {
|
|
99
|
-
return WindowManager.INSTANCE.getZoomFactor();
|
|
100
|
-
}
|
|
101
|
-
exports.getZoomFactor = getZoomFactor;
|
|
102
|
-
function setZoomFactor(zoomFactor) {
|
|
103
|
-
WindowManager.INSTANCE.setZoomFactor(zoomFactor);
|
|
104
|
-
}
|
|
105
|
-
exports.setZoomFactor = setZoomFactor;
|
|
106
|
-
function getPixelRatio() {
|
|
107
|
-
return WindowManager.INSTANCE.getPixelRatio();
|
|
108
|
-
}
|
|
109
|
-
exports.getPixelRatio = getPixelRatio;
|
|
110
|
-
function setFullscreen(fullscreen) {
|
|
111
|
-
WindowManager.INSTANCE.setFullscreen(fullscreen);
|
|
112
|
-
}
|
|
113
|
-
exports.setFullscreen = setFullscreen;
|
|
114
|
-
function isFullscreen() {
|
|
115
|
-
return WindowManager.INSTANCE.isFullscreen();
|
|
116
|
-
}
|
|
117
|
-
exports.isFullscreen = isFullscreen;
|
|
118
|
-
exports.onDidChangeFullscreen = WindowManager.INSTANCE.onDidChangeFullscreen;
|
|
119
|
-
function setAccessibilitySupport(accessibilitySupport) {
|
|
120
|
-
WindowManager.INSTANCE.setAccessibilitySupport(accessibilitySupport);
|
|
121
|
-
}
|
|
122
|
-
exports.setAccessibilitySupport = setAccessibilitySupport;
|
|
123
|
-
function getAccessibilitySupport() {
|
|
124
|
-
return WindowManager.INSTANCE.getAccessibilitySupport();
|
|
125
|
-
}
|
|
126
|
-
exports.getAccessibilitySupport = getAccessibilitySupport;
|
|
127
|
-
function onDidChangeAccessibilitySupport(callback) {
|
|
128
|
-
return WindowManager.INSTANCE.onDidChangeAccessibilitySupport(callback);
|
|
129
|
-
}
|
|
130
|
-
exports.onDidChangeAccessibilitySupport = onDidChangeAccessibilitySupport;
|
|
131
|
-
const userAgent = navigator.userAgent;
|
|
132
|
-
exports.isIE = (userAgent.indexOf('Trident') >= 0);
|
|
133
|
-
exports.isEdge = (userAgent.indexOf('Edge/') >= 0);
|
|
134
|
-
exports.isEdgeOrIE = exports.isIE || exports.isEdge;
|
|
135
|
-
exports.isOpera = (userAgent.indexOf('Opera') >= 0);
|
|
136
|
-
exports.isFirefox = (userAgent.indexOf('Firefox') >= 0);
|
|
137
|
-
exports.isWebKit = (userAgent.indexOf('AppleWebKit') >= 0);
|
|
138
|
-
exports.isChrome = (userAgent.indexOf('Chrome') >= 0);
|
|
139
|
-
exports.isSafari = (!exports.isChrome && (userAgent.indexOf('Safari') >= 0));
|
|
140
|
-
exports.isWebkitWebView = (!exports.isChrome && !exports.isSafari && exports.isWebKit);
|
|
141
|
-
exports.isIPad = (userAgent.indexOf('iPad') >= 0);
|
|
142
|
-
exports.isEdgeWebView = exports.isEdge && (userAgent.indexOf('WebView/') >= 0);
|
|
143
|
-
function hasClipboardSupport() {
|
|
144
|
-
if (exports.isIE) {
|
|
145
|
-
return false;
|
|
146
|
-
}
|
|
147
|
-
if (exports.isEdge) {
|
|
148
|
-
let index = userAgent.indexOf('Edge/');
|
|
149
|
-
let version = parseInt(userAgent.substring(index + 5, userAgent.indexOf('.', index)), 10);
|
|
150
|
-
if (!version || (version >= 12 && version <= 16)) {
|
|
151
|
-
return false;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
return true;
|
|
155
|
-
}
|
|
156
|
-
exports.hasClipboardSupport = hasClipboardSupport;
|
|
157
|
-
//# sourceMappingURL=browser.js.map
|
|
@@ -1 +0,0 @@
|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AK,GAAG,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACvC,IAAI,OAAO,GAAG,QAAQ,CAAC,SAAS,CAAC,SAAS,CAAC,KAAK,GAAG,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAE1F,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,IAAI,EAAE,IAAI,OAAO,IAAI,EAAE,CAAC,EAAE;YAC9C,OAAO,KAAK,CAAC;SAChB;KACJ;IAED,OAAO,IAAI,CAAC;AAChB,CAAC;AAfD,kDAeC"}
|
package/build/browser/event.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*---------------------------------------------------------------------------------------------
|
|
3
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
-
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.stop = exports.domEvent = void 0;
|
|
8
|
-
const event_1 = require("../common/event");
|
|
9
|
-
const domEvent = (element, type, useCapture) => {
|
|
10
|
-
const fn = e => emitter.fire(e);
|
|
11
|
-
const emitter = new event_1.Emitter({
|
|
12
|
-
onFirstListenerAdd: () => {
|
|
13
|
-
element.addEventListener(type, fn, useCapture);
|
|
14
|
-
},
|
|
15
|
-
onLastListenerRemove: () => {
|
|
16
|
-
element.removeEventListener(type, fn, useCapture);
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
return emitter.event;
|
|
20
|
-
};
|
|
21
|
-
exports.domEvent = domEvent;
|
|
22
|
-
function stop(event) {
|
|
23
|
-
return event_1.Event.map(event, e => {
|
|
24
|
-
e.preventDefault();
|
|
25
|
-
e.stopPropagation();
|
|
26
|
-
return e;
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
exports.stop = stop;
|
|
30
|
-
//# sourceMappingURL=event.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"event.js","sourceRoot":"","sources":["../../src/browser/event.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,2CAAiD;AAS1C,MAAM,QAAQ,GAAc,CAAC,OAAqB,EAAE,IAAY,EAAE,UAAoB,EAAE,EAAE;IAC7F,MAAM,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAChC,MAAM,OAAO,GAAG,IAAI,eAAO,CAAM;QAC7B,kBAAkB,EAAE,GAAG,EAAE;YACrB,OAAO,CAAC,gBAAgB,CAAC,IAAI,EAAE,EAAE,EAAE,UAAU,CAAC,CAAC;QACnD,CAAC;QACD,oBAAoB,EAAE,GAAG,EAAE;YACvB,OAAO,CAAC,mBAAmB,CAAC,IAAI,EAAE,EAAE,EAAE,UAAU,CAAC,CAAC;QACtD,CAAC;KACJ,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC,KAAK,CAAC;AACzB,CAAC,CAAC;AAZW,QAAA,QAAQ,YAYnB;AAOF,SAAgB,IAAI,CAA6B,KAAe;IAC5D,OAAO,aAAK,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE;QACxB,CAAC,CAAC,cAAc,EAAE,CAAC;QACnB,CAAC,CAAC,eAAe,EAAE,CAAC;QACpB,OAAO,CAAC,CAAC;IACb,CAAC,CAAC,CAAC;AACP,CAAC;AAND,oBAMC"}
|