custom-electron-titlebar 4.2.8 → 4.4.1
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 +32 -12
- package/index.d.mts +684 -0
- package/index.d.ts +684 -3
- package/index.js +5207 -175
- package/index.js.map +1 -0
- package/index.mjs +5219 -0
- package/index.mjs.map +1 -0
- package/main/index.d.mts +21 -0
- package/main/index.d.ts +21 -3
- package/main/index.js +793 -175
- package/main/index.js.map +1 -0
- package/main/index.mjs +785 -0
- package/main/index.mjs.map +1 -0
- package/package.json +40 -32
- package/base/browser/browser.d.ts +0 -26
- package/base/browser/browser.js +0 -317
- package/base/browser/event.d.ts +0 -12
- package/base/browser/event.js +0 -215
- package/base/browser/keyboardEvent.d.ts +0 -38
- package/base/browser/keyboardEvent.js +0 -462
- package/base/browser/mouseEvent.d.ts +0 -61
- package/base/browser/mouseEvent.js +0 -327
- package/base/browser/touch.d.ts +0 -39
- package/base/browser/touch.js +0 -454
- package/base/common/arrays.d.ts +0 -10
- package/base/common/arrays.js +0 -210
- package/base/common/async.d.ts +0 -35
- package/base/common/async.js +0 -280
- package/base/common/charCode.d.ts +0 -405
- package/base/common/charCode.js +0 -9
- package/base/common/color.d.ts +0 -159
- package/base/common/color.js +0 -708
- package/base/common/decorators.d.ts +0 -6
- package/base/common/decorators.js +0 -300
- package/base/common/dom.d.ts +0 -221
- package/base/common/dom.js +0 -1476
- package/base/common/event.d.ts +0 -213
- package/base/common/event.js +0 -804
- package/base/common/iterator.d.ts +0 -69
- package/base/common/iterator.js +0 -380
- package/base/common/keyCodes.d.ts +0 -478
- package/base/common/keyCodes.js +0 -477
- package/base/common/lifecycle.d.ts +0 -17
- package/base/common/lifecycle.js +0 -258
- package/base/common/linkedList.d.ts +0 -17
- package/base/common/linkedList.js +0 -319
- package/base/common/platform.d.ts +0 -36
- package/base/common/platform.js +0 -314
- package/base/common/strings.d.ts +0 -23
- package/base/common/strings.js +0 -273
- package/consts.d.ts +0 -58
- package/consts.js +0 -317
- package/main/attach-titlebar-to-window.d.ts +0 -3
- package/main/attach-titlebar-to-window.js +0 -210
- package/main/setup-titlebar.d.ts +0 -2
- package/main/setup-titlebar.js +0 -255
- package/menubar/index.d.ts +0 -86
- package/menubar/index.js +0 -1119
- package/menubar/menu/index.d.ts +0 -46
- package/menubar/menu/index.js +0 -565
- package/menubar/menu/item.d.ts +0 -67
- package/menubar/menu/item.js +0 -575
- package/menubar/menu/separator.d.ts +0 -11
- package/menubar/menu/separator.js +0 -213
- package/menubar/menu/submenu.d.ts +0 -32
- package/menubar/menu/submenu.js +0 -372
- package/menubar/menubar-options.d.ts +0 -47
- package/menubar/menubar-options.js +0 -9
- package/titlebar/index.d.ts +0 -105
- package/titlebar/index.js +0 -703
- package/titlebar/options.d.ts +0 -89
- package/titlebar/options.js +0 -9
- package/titlebar/themebar.d.ts +0 -20
- package/titlebar/themebar.js +0 -267
package/main/index.js
CHANGED
|
@@ -1,202 +1,820 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
11
19
|
};
|
|
12
|
-
|
|
13
|
-
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/main/index.ts
|
|
31
|
+
var main_exports = {};
|
|
32
|
+
__export(main_exports, {
|
|
33
|
+
attachTitlebarToWindow: () => attach_titlebar_to_window_default,
|
|
34
|
+
setupTitlebar: () => setup_titlebar_default,
|
|
35
|
+
setupTitlebarAndAttachToWindow: () => setupTitlebarAndAttachToWindow
|
|
14
36
|
});
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
37
|
+
module.exports = __toCommonJS(main_exports);
|
|
38
|
+
|
|
39
|
+
// src/base/common/color.ts
|
|
40
|
+
function roundFloat(number, decimalPoints) {
|
|
41
|
+
const decimal = Math.pow(10, decimalPoints);
|
|
42
|
+
return Math.round(number * decimal) / decimal;
|
|
43
|
+
}
|
|
44
|
+
var RGBA = class {
|
|
45
|
+
constructor(r, g, b, a = 1) {
|
|
46
|
+
this.r = Math.min(255, Math.max(0, r)) | 0;
|
|
47
|
+
this.g = Math.min(255, Math.max(0, g)) | 0;
|
|
48
|
+
this.b = Math.min(255, Math.max(0, b)) | 0;
|
|
49
|
+
this.a = roundFloat(Math.max(Math.min(1, a), 0), 3);
|
|
50
|
+
}
|
|
51
|
+
static equals(a, b) {
|
|
52
|
+
return a.r === b.r && a.g === b.g && a.b === b.b && a.a === b.a;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
var HSLA = class _HSLA {
|
|
56
|
+
constructor(h, s, l, a) {
|
|
57
|
+
this.h = Math.max(Math.min(360, h), 0) | 0;
|
|
58
|
+
this.s = roundFloat(Math.max(Math.min(1, s), 0), 3);
|
|
59
|
+
this.l = roundFloat(Math.max(Math.min(1, l), 0), 3);
|
|
60
|
+
this.a = roundFloat(Math.max(Math.min(1, a), 0), 3);
|
|
61
|
+
}
|
|
62
|
+
static equals(a, b) {
|
|
63
|
+
return a.h === b.h && a.s === b.s && a.l === b.l && a.a === b.a;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Converts an RGB color value to HSL. Conversion formula
|
|
67
|
+
* adapted from http://en.wikipedia.org/wiki/HSL_color_space.
|
|
68
|
+
* Assumes r, g, and b are contained in the set [0, 255] and
|
|
69
|
+
* returns h in the set [0, 360], s, and l in the set [0, 1].
|
|
70
|
+
*/
|
|
71
|
+
static fromRGBA(rgba) {
|
|
72
|
+
const r = rgba.r / 255;
|
|
73
|
+
const g = rgba.g / 255;
|
|
74
|
+
const b = rgba.b / 255;
|
|
75
|
+
const a = rgba.a;
|
|
76
|
+
const max = Math.max(r, g, b);
|
|
77
|
+
const min = Math.min(r, g, b);
|
|
78
|
+
let h = 0;
|
|
79
|
+
let s = 0;
|
|
80
|
+
const l = (min + max) / 2;
|
|
81
|
+
const chroma = max - min;
|
|
82
|
+
if (chroma > 0) {
|
|
83
|
+
s = Math.min(l <= 0.5 ? chroma / (2 * l) : chroma / (2 - 2 * l), 1);
|
|
84
|
+
switch (max) {
|
|
85
|
+
case r:
|
|
86
|
+
h = (g - b) / chroma + (g < b ? 6 : 0);
|
|
87
|
+
break;
|
|
88
|
+
case g:
|
|
89
|
+
h = (b - r) / chroma + 2;
|
|
90
|
+
break;
|
|
91
|
+
case b:
|
|
92
|
+
h = (r - g) / chroma + 4;
|
|
93
|
+
break;
|
|
29
94
|
}
|
|
30
|
-
|
|
31
|
-
|
|
95
|
+
h *= 60;
|
|
96
|
+
h = Math.round(h);
|
|
32
97
|
}
|
|
98
|
+
return new _HSLA(h, s, l, a);
|
|
33
99
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
function _getRewireModuleId__() {
|
|
38
|
-
if (_RewireModuleId__ === null) {
|
|
39
|
-
let globalVariable = _getGlobalObject();
|
|
40
|
-
if (!globalVariable.__$$GLOBAL_REWIRE_NEXT_MODULE_ID__) {
|
|
41
|
-
globalVariable.__$$GLOBAL_REWIRE_NEXT_MODULE_ID__ = 0;
|
|
100
|
+
static _hue2rgb(p, q, t) {
|
|
101
|
+
if (t < 0) {
|
|
102
|
+
t += 1;
|
|
42
103
|
}
|
|
43
|
-
|
|
104
|
+
if (t > 1) {
|
|
105
|
+
t -= 1;
|
|
106
|
+
}
|
|
107
|
+
if (t < 1 / 6) {
|
|
108
|
+
return p + (q - p) * 6 * t;
|
|
109
|
+
}
|
|
110
|
+
if (t < 1 / 2) {
|
|
111
|
+
return q;
|
|
112
|
+
}
|
|
113
|
+
if (t < 2 / 3) {
|
|
114
|
+
return p + (q - p) * (2 / 3 - t) * 6;
|
|
115
|
+
}
|
|
116
|
+
return p;
|
|
44
117
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
118
|
+
/**
|
|
119
|
+
* Converts an HSL color value to RGB. Conversion formula
|
|
120
|
+
* adapted from http://en.wikipedia.org/wiki/HSL_color_space.
|
|
121
|
+
* Assumes h in the set [0, 360] s, and l are contained in the set [0, 1] and
|
|
122
|
+
* returns r, g, and b in the set [0, 255].
|
|
123
|
+
*/
|
|
124
|
+
static toRGBA(hsla) {
|
|
125
|
+
const h = hsla.h / 360;
|
|
126
|
+
const { s, l, a } = hsla;
|
|
127
|
+
let r, g, b;
|
|
128
|
+
if (s === 0) {
|
|
129
|
+
r = g = b = l;
|
|
130
|
+
} else {
|
|
131
|
+
const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
|
132
|
+
const p = 2 * l - q;
|
|
133
|
+
r = _HSLA._hue2rgb(p, q, h + 1 / 3);
|
|
134
|
+
g = _HSLA._hue2rgb(p, q, h);
|
|
135
|
+
b = _HSLA._hue2rgb(p, q, h - 1 / 3);
|
|
136
|
+
}
|
|
137
|
+
return new RGBA(Math.round(r * 255), Math.round(g * 255), Math.round(b * 255), a);
|
|
51
138
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
return rewireData;
|
|
63
|
-
}
|
|
64
|
-
(function registerResetAll() {
|
|
65
|
-
let theGlobalVariable = _getGlobalObject();
|
|
66
|
-
if (!theGlobalVariable['__rewire_reset_all__']) {
|
|
67
|
-
theGlobalVariable['__rewire_reset_all__'] = function () {
|
|
68
|
-
theGlobalVariable.__$$GLOBAL_REWIRE_REGISTRY__ = Object.create(null);
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
})();
|
|
72
|
-
var INTENTIONAL_UNDEFINED = '__INTENTIONAL_UNDEFINED__';
|
|
73
|
-
let _RewireAPI__ = {};
|
|
74
|
-
(function () {
|
|
75
|
-
function addPropertyToAPIObject(name, value) {
|
|
76
|
-
Object.defineProperty(_RewireAPI__, name, {
|
|
77
|
-
value: value,
|
|
78
|
-
enumerable: false,
|
|
79
|
-
configurable: true
|
|
80
|
-
});
|
|
139
|
+
};
|
|
140
|
+
var HSVA = class _HSVA {
|
|
141
|
+
constructor(h, s, v, a) {
|
|
142
|
+
this.h = Math.max(Math.min(360, h), 0) | 0;
|
|
143
|
+
this.s = roundFloat(Math.max(Math.min(1, s), 0), 3);
|
|
144
|
+
this.v = roundFloat(Math.max(Math.min(1, v), 0), 3);
|
|
145
|
+
this.a = roundFloat(Math.max(Math.min(1, a), 0), 3);
|
|
146
|
+
}
|
|
147
|
+
static equals(a, b) {
|
|
148
|
+
return a.h === b.h && a.s === b.s && a.v === b.v && a.a === b.a;
|
|
81
149
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
if (
|
|
97
|
-
|
|
150
|
+
// from http://www.rapidtables.com/convert/color/rgb-to-hsv.htm
|
|
151
|
+
static fromRGBA(rgba) {
|
|
152
|
+
const r = rgba.r / 255;
|
|
153
|
+
const g = rgba.g / 255;
|
|
154
|
+
const b = rgba.b / 255;
|
|
155
|
+
const cmax = Math.max(r, g, b);
|
|
156
|
+
const cmin = Math.min(r, g, b);
|
|
157
|
+
const delta = cmax - cmin;
|
|
158
|
+
const s = cmax === 0 ? 0 : delta / cmax;
|
|
159
|
+
let m;
|
|
160
|
+
if (delta === 0) {
|
|
161
|
+
m = 0;
|
|
162
|
+
} else if (cmax === r) {
|
|
163
|
+
m = ((g - b) / delta % 6 + 6) % 6;
|
|
164
|
+
} else if (cmax === g) {
|
|
165
|
+
m = (b - r) / delta + 2;
|
|
98
166
|
} else {
|
|
99
|
-
|
|
167
|
+
m = (r - g) / delta + 4;
|
|
168
|
+
}
|
|
169
|
+
return new _HSVA(Math.round(m * 60), s, cmax, rgba.a);
|
|
170
|
+
}
|
|
171
|
+
// from http://www.rapidtables.com/convert/color/hsv-to-rgb.htm
|
|
172
|
+
static toRGBA(hsva) {
|
|
173
|
+
const { h, s, v, a } = hsva;
|
|
174
|
+
const c = v * s;
|
|
175
|
+
const x = c * (1 - Math.abs(h / 60 % 2 - 1));
|
|
176
|
+
const m = v - c;
|
|
177
|
+
let [r, g, b] = [0, 0, 0];
|
|
178
|
+
if (h < 60) {
|
|
179
|
+
r = c;
|
|
180
|
+
g = x;
|
|
181
|
+
} else if (h < 120) {
|
|
182
|
+
r = x;
|
|
183
|
+
g = c;
|
|
184
|
+
} else if (h < 180) {
|
|
185
|
+
g = c;
|
|
186
|
+
b = x;
|
|
187
|
+
} else if (h < 240) {
|
|
188
|
+
g = x;
|
|
189
|
+
b = c;
|
|
190
|
+
} else if (h < 300) {
|
|
191
|
+
r = x;
|
|
192
|
+
b = c;
|
|
193
|
+
} else if (h < 360) {
|
|
194
|
+
r = c;
|
|
195
|
+
b = x;
|
|
196
|
+
}
|
|
197
|
+
r = Math.round((r + m) * 255);
|
|
198
|
+
g = Math.round((g + m) * 255);
|
|
199
|
+
b = Math.round((b + m) * 255);
|
|
200
|
+
return new RGBA(r, g, b, a);
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
var _Color = class _Color {
|
|
204
|
+
static fromHex(hex) {
|
|
205
|
+
return _Color.Format.CSS.parseHex(hex) || _Color.RED;
|
|
206
|
+
}
|
|
207
|
+
get hsla() {
|
|
208
|
+
if (this._hsla) {
|
|
209
|
+
return this._hsla;
|
|
210
|
+
} else {
|
|
211
|
+
return HSLA.fromRGBA(this.rgba);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
get hsva() {
|
|
215
|
+
if (this._hsva) {
|
|
216
|
+
return this._hsva;
|
|
217
|
+
}
|
|
218
|
+
return HSVA.fromRGBA(this.rgba);
|
|
219
|
+
}
|
|
220
|
+
constructor(arg) {
|
|
221
|
+
if (!arg) {
|
|
222
|
+
throw new Error("Color needs a value");
|
|
223
|
+
} else if (arg instanceof RGBA) {
|
|
224
|
+
this.rgba = arg;
|
|
225
|
+
} else if (arg instanceof HSLA) {
|
|
226
|
+
this._hsla = arg;
|
|
227
|
+
this.rgba = HSLA.toRGBA(arg);
|
|
228
|
+
} else if (arg instanceof HSVA) {
|
|
229
|
+
this._hsva = arg;
|
|
230
|
+
this.rgba = HSVA.toRGBA(arg);
|
|
231
|
+
} else {
|
|
232
|
+
throw new Error("Invalid color ctor argument");
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
equals(other) {
|
|
236
|
+
return !!other && RGBA.equals(this.rgba, other.rgba) && HSLA.equals(this.hsla, other.hsla) && HSVA.equals(this.hsva, other.hsva);
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* http://www.w3.org/TR/WCAG20/#relativeluminancedef
|
|
240
|
+
* Returns the number in the set [0, 1]. O => Darkest Black. 1 => Lightest white.
|
|
241
|
+
*/
|
|
242
|
+
getRelativeLuminance() {
|
|
243
|
+
const R = _Color._relativeLuminanceForComponent(this.rgba.r);
|
|
244
|
+
const G = _Color._relativeLuminanceForComponent(this.rgba.g);
|
|
245
|
+
const B = _Color._relativeLuminanceForComponent(this.rgba.b);
|
|
246
|
+
const luminance = 0.2126 * R + 0.7152 * G + 0.0722 * B;
|
|
247
|
+
return roundFloat(luminance, 4);
|
|
248
|
+
}
|
|
249
|
+
static _relativeLuminanceForComponent(color) {
|
|
250
|
+
const c = color / 255;
|
|
251
|
+
return c <= 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* http://www.w3.org/TR/WCAG20/#contrast-ratiodef
|
|
255
|
+
* Returns the contrast ration number in the set [1, 21].
|
|
256
|
+
*/
|
|
257
|
+
getContrastRatio(another) {
|
|
258
|
+
const lum1 = this.getRelativeLuminance();
|
|
259
|
+
const lum2 = another.getRelativeLuminance();
|
|
260
|
+
return lum1 > lum2 ? (lum1 + 0.05) / (lum2 + 0.05) : (lum2 + 0.05) / (lum1 + 0.05);
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* http://24ways.org/2010/calculating-color-contrast
|
|
264
|
+
* Return 'true' if darker color otherwise 'false'
|
|
265
|
+
*/
|
|
266
|
+
isDarker() {
|
|
267
|
+
const yiq = (this.rgba.r * 299 + this.rgba.g * 587 + this.rgba.b * 114) / 1e3;
|
|
268
|
+
return yiq < 128;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* http://24ways.org/2010/calculating-color-contrast
|
|
272
|
+
* Return 'true' if lighter color otherwise 'false'
|
|
273
|
+
*/
|
|
274
|
+
isLighter() {
|
|
275
|
+
const yiq = (this.rgba.r * 299 + this.rgba.g * 587 + this.rgba.b * 114) / 1e3;
|
|
276
|
+
return yiq >= 128;
|
|
277
|
+
}
|
|
278
|
+
isLighterThan(another) {
|
|
279
|
+
const lum1 = this.getRelativeLuminance();
|
|
280
|
+
const lum2 = another.getRelativeLuminance();
|
|
281
|
+
return lum1 > lum2;
|
|
282
|
+
}
|
|
283
|
+
isDarkerThan(another) {
|
|
284
|
+
const lum1 = this.getRelativeLuminance();
|
|
285
|
+
const lum2 = another.getRelativeLuminance();
|
|
286
|
+
return lum1 < lum2;
|
|
287
|
+
}
|
|
288
|
+
lighten(factor) {
|
|
289
|
+
return new _Color(new HSLA(this.hsla.h, this.hsla.s, this.hsla.l + this.hsla.l * factor, this.hsla.a));
|
|
290
|
+
}
|
|
291
|
+
darken(factor) {
|
|
292
|
+
return new _Color(new HSLA(this.hsla.h, this.hsla.s, this.hsla.l - this.hsla.l * factor, this.hsla.a));
|
|
293
|
+
}
|
|
294
|
+
transparent(factor) {
|
|
295
|
+
const { r, g, b, a } = this.rgba;
|
|
296
|
+
return new _Color(new RGBA(r, g, b, a * factor));
|
|
297
|
+
}
|
|
298
|
+
isTransparent() {
|
|
299
|
+
return this.rgba.a === 0;
|
|
300
|
+
}
|
|
301
|
+
isOpaque() {
|
|
302
|
+
return this.rgba.a === 1;
|
|
303
|
+
}
|
|
304
|
+
opposite() {
|
|
305
|
+
return new _Color(new RGBA(255 - this.rgba.r, 255 - this.rgba.g, 255 - this.rgba.b, this.rgba.a));
|
|
306
|
+
}
|
|
307
|
+
blend(c) {
|
|
308
|
+
const rgba = c.rgba;
|
|
309
|
+
const thisA = this.rgba.a;
|
|
310
|
+
const colorA = rgba.a;
|
|
311
|
+
const a = thisA + colorA * (1 - thisA);
|
|
312
|
+
if (a < 1e-6) {
|
|
313
|
+
return _Color.TRANSPARENT;
|
|
314
|
+
}
|
|
315
|
+
const r = this.rgba.r * thisA / a + rgba.r * colorA * (1 - thisA) / a;
|
|
316
|
+
const g = this.rgba.g * thisA / a + rgba.g * colorA * (1 - thisA) / a;
|
|
317
|
+
const b = this.rgba.b * thisA / a + rgba.b * colorA * (1 - thisA) / a;
|
|
318
|
+
return new _Color(new RGBA(r, g, b, a));
|
|
319
|
+
}
|
|
320
|
+
flatten(...backgrounds) {
|
|
321
|
+
const background = backgrounds.reduceRight((accumulator, color) => {
|
|
322
|
+
return _Color._flatten(color, accumulator);
|
|
323
|
+
});
|
|
324
|
+
return _Color._flatten(this, background);
|
|
325
|
+
}
|
|
326
|
+
static _flatten(foreground, background) {
|
|
327
|
+
const backgroundAlpha = 1 - foreground.rgba.a;
|
|
328
|
+
return new _Color(new RGBA(
|
|
329
|
+
backgroundAlpha * background.rgba.r + foreground.rgba.a * foreground.rgba.r,
|
|
330
|
+
backgroundAlpha * background.rgba.g + foreground.rgba.a * foreground.rgba.g,
|
|
331
|
+
backgroundAlpha * background.rgba.b + foreground.rgba.a * foreground.rgba.b
|
|
332
|
+
));
|
|
333
|
+
}
|
|
334
|
+
toString() {
|
|
335
|
+
return "" + _Color.Format.CSS.format(this);
|
|
336
|
+
}
|
|
337
|
+
static getLighterColor(of, relative, factor) {
|
|
338
|
+
if (of.isLighterThan(relative)) {
|
|
339
|
+
return of;
|
|
340
|
+
}
|
|
341
|
+
factor = factor || 0.5;
|
|
342
|
+
const lum1 = of.getRelativeLuminance();
|
|
343
|
+
const lum2 = relative.getRelativeLuminance();
|
|
344
|
+
factor = factor * (lum2 - lum1) / lum2;
|
|
345
|
+
return of.lighten(factor);
|
|
346
|
+
}
|
|
347
|
+
static getDarkerColor(of, relative, factor) {
|
|
348
|
+
if (of.isDarkerThan(relative)) {
|
|
349
|
+
return of;
|
|
100
350
|
}
|
|
351
|
+
factor = factor || 0.5;
|
|
352
|
+
const lum1 = of.getRelativeLuminance();
|
|
353
|
+
const lum2 = relative.getRelativeLuminance();
|
|
354
|
+
factor = factor * (lum1 - lum2) / lum1;
|
|
355
|
+
return of.darken(factor);
|
|
101
356
|
}
|
|
357
|
+
};
|
|
358
|
+
_Color.WHITE = new _Color(new RGBA(255, 255, 255, 1));
|
|
359
|
+
_Color.BLACK = new _Color(new RGBA(0, 0, 0, 1));
|
|
360
|
+
_Color.RED = new _Color(new RGBA(255, 0, 0, 1));
|
|
361
|
+
_Color.BLUE = new _Color(new RGBA(0, 0, 255, 1));
|
|
362
|
+
_Color.GREEN = new _Color(new RGBA(0, 255, 0, 1));
|
|
363
|
+
_Color.CYAN = new _Color(new RGBA(0, 255, 255, 1));
|
|
364
|
+
_Color.LIGHTGREY = new _Color(new RGBA(211, 211, 211, 1));
|
|
365
|
+
_Color.TRANSPARENT = new _Color(new RGBA(0, 0, 0, 0));
|
|
366
|
+
var Color = _Color;
|
|
367
|
+
((Color2) => {
|
|
368
|
+
let Format;
|
|
369
|
+
((Format2) => {
|
|
370
|
+
let CSS;
|
|
371
|
+
((CSS2) => {
|
|
372
|
+
function formatRGB(color) {
|
|
373
|
+
if (color.rgba.a === 1) {
|
|
374
|
+
return `rgb(${color.rgba.r}, ${color.rgba.g}, ${color.rgba.b})`;
|
|
375
|
+
}
|
|
376
|
+
return Color2.Format.CSS.formatRGBA(color);
|
|
377
|
+
}
|
|
378
|
+
CSS2.formatRGB = formatRGB;
|
|
379
|
+
function formatRGBA(color) {
|
|
380
|
+
return `rgba(${color.rgba.r}, ${color.rgba.g}, ${color.rgba.b}, ${+color.rgba.a.toFixed(2)})`;
|
|
381
|
+
}
|
|
382
|
+
CSS2.formatRGBA = formatRGBA;
|
|
383
|
+
function formatHSL(color) {
|
|
384
|
+
if (color.hsla.a === 1) {
|
|
385
|
+
return `hsl(${color.hsla.h}, ${(color.hsla.s * 100).toFixed(2)}%, ${(color.hsla.l * 100).toFixed(2)}%)`;
|
|
386
|
+
}
|
|
387
|
+
return Color2.Format.CSS.formatHSLA(color);
|
|
388
|
+
}
|
|
389
|
+
CSS2.formatHSL = formatHSL;
|
|
390
|
+
function formatHSLA(color) {
|
|
391
|
+
return `hsla(${color.hsla.h}, ${(color.hsla.s * 100).toFixed(2)}%, ${(color.hsla.l * 100).toFixed(2)}%, ${color.hsla.a.toFixed(2)})`;
|
|
392
|
+
}
|
|
393
|
+
CSS2.formatHSLA = formatHSLA;
|
|
394
|
+
function _toTwoDigitHex(n) {
|
|
395
|
+
const r = n.toString(16);
|
|
396
|
+
return r.length !== 2 ? "0" + r : r;
|
|
397
|
+
}
|
|
398
|
+
function formatHex(color) {
|
|
399
|
+
return `#${_toTwoDigitHex(color.rgba.r)}${_toTwoDigitHex(color.rgba.g)}${_toTwoDigitHex(color.rgba.b)}`;
|
|
400
|
+
}
|
|
401
|
+
CSS2.formatHex = formatHex;
|
|
402
|
+
function formatHexA(color, compact = false) {
|
|
403
|
+
if (compact && color.rgba.a === 1) {
|
|
404
|
+
return Color2.Format.CSS.formatHex(color);
|
|
405
|
+
}
|
|
406
|
+
return `#${_toTwoDigitHex(color.rgba.r)}${_toTwoDigitHex(color.rgba.g)}${_toTwoDigitHex(color.rgba.b)}${_toTwoDigitHex(Math.round(color.rgba.a * 255))}`;
|
|
407
|
+
}
|
|
408
|
+
CSS2.formatHexA = formatHexA;
|
|
409
|
+
function format(color) {
|
|
410
|
+
if (!color) {
|
|
411
|
+
return null;
|
|
412
|
+
}
|
|
413
|
+
if (color.isOpaque()) {
|
|
414
|
+
return Color2.Format.CSS.formatHex(color);
|
|
415
|
+
}
|
|
416
|
+
return Color2.Format.CSS.formatRGBA(color);
|
|
417
|
+
}
|
|
418
|
+
CSS2.format = format;
|
|
419
|
+
function parseHex(hex) {
|
|
420
|
+
if (!hex) {
|
|
421
|
+
return null;
|
|
422
|
+
}
|
|
423
|
+
const length = hex.length;
|
|
424
|
+
if (length === 0) {
|
|
425
|
+
return null;
|
|
426
|
+
}
|
|
427
|
+
if (hex.charCodeAt(0) !== 35 /* Hash */) {
|
|
428
|
+
return null;
|
|
429
|
+
}
|
|
430
|
+
if (length === 7) {
|
|
431
|
+
const r = 16 * _parseHexDigit(hex.charCodeAt(1)) + _parseHexDigit(hex.charCodeAt(2));
|
|
432
|
+
const g = 16 * _parseHexDigit(hex.charCodeAt(3)) + _parseHexDigit(hex.charCodeAt(4));
|
|
433
|
+
const b = 16 * _parseHexDigit(hex.charCodeAt(5)) + _parseHexDigit(hex.charCodeAt(6));
|
|
434
|
+
return new Color2(new RGBA(r, g, b, 1));
|
|
435
|
+
}
|
|
436
|
+
if (length === 9) {
|
|
437
|
+
const r = 16 * _parseHexDigit(hex.charCodeAt(1)) + _parseHexDigit(hex.charCodeAt(2));
|
|
438
|
+
const g = 16 * _parseHexDigit(hex.charCodeAt(3)) + _parseHexDigit(hex.charCodeAt(4));
|
|
439
|
+
const b = 16 * _parseHexDigit(hex.charCodeAt(5)) + _parseHexDigit(hex.charCodeAt(6));
|
|
440
|
+
const a = 16 * _parseHexDigit(hex.charCodeAt(7)) + _parseHexDigit(hex.charCodeAt(8));
|
|
441
|
+
return new Color2(new RGBA(r, g, b, a / 255));
|
|
442
|
+
}
|
|
443
|
+
if (length === 4) {
|
|
444
|
+
const r = _parseHexDigit(hex.charCodeAt(1));
|
|
445
|
+
const g = _parseHexDigit(hex.charCodeAt(2));
|
|
446
|
+
const b = _parseHexDigit(hex.charCodeAt(3));
|
|
447
|
+
return new Color2(new RGBA(16 * r + r, 16 * g + g, 16 * b + b));
|
|
448
|
+
}
|
|
449
|
+
if (length === 5) {
|
|
450
|
+
const r = _parseHexDigit(hex.charCodeAt(1));
|
|
451
|
+
const g = _parseHexDigit(hex.charCodeAt(2));
|
|
452
|
+
const b = _parseHexDigit(hex.charCodeAt(3));
|
|
453
|
+
const a = _parseHexDigit(hex.charCodeAt(4));
|
|
454
|
+
return new Color2(new RGBA(16 * r + r, 16 * g + g, 16 * b + b, (16 * a + a) / 255));
|
|
455
|
+
}
|
|
456
|
+
return null;
|
|
457
|
+
}
|
|
458
|
+
CSS2.parseHex = parseHex;
|
|
459
|
+
function _parseHexDigit(charCode) {
|
|
460
|
+
switch (charCode) {
|
|
461
|
+
case 48 /* Digit0 */:
|
|
462
|
+
return 0;
|
|
463
|
+
case 49 /* Digit1 */:
|
|
464
|
+
return 1;
|
|
465
|
+
case 50 /* Digit2 */:
|
|
466
|
+
return 2;
|
|
467
|
+
case 51 /* Digit3 */:
|
|
468
|
+
return 3;
|
|
469
|
+
case 52 /* Digit4 */:
|
|
470
|
+
return 4;
|
|
471
|
+
case 53 /* Digit5 */:
|
|
472
|
+
return 5;
|
|
473
|
+
case 54 /* Digit6 */:
|
|
474
|
+
return 6;
|
|
475
|
+
case 55 /* Digit7 */:
|
|
476
|
+
return 7;
|
|
477
|
+
case 56 /* Digit8 */:
|
|
478
|
+
return 8;
|
|
479
|
+
case 57 /* Digit9 */:
|
|
480
|
+
return 9;
|
|
481
|
+
case 97 /* a */:
|
|
482
|
+
return 10;
|
|
483
|
+
case 65 /* A */:
|
|
484
|
+
return 10;
|
|
485
|
+
case 98 /* b */:
|
|
486
|
+
return 11;
|
|
487
|
+
case 66 /* B */:
|
|
488
|
+
return 11;
|
|
489
|
+
case 99 /* c */:
|
|
490
|
+
return 12;
|
|
491
|
+
case 67 /* C */:
|
|
492
|
+
return 12;
|
|
493
|
+
case 100 /* d */:
|
|
494
|
+
return 13;
|
|
495
|
+
case 68 /* D */:
|
|
496
|
+
return 13;
|
|
497
|
+
case 101 /* e */:
|
|
498
|
+
return 14;
|
|
499
|
+
case 69 /* E */:
|
|
500
|
+
return 14;
|
|
501
|
+
case 102 /* f */:
|
|
502
|
+
return 15;
|
|
503
|
+
case 70 /* F */:
|
|
504
|
+
return 15;
|
|
505
|
+
}
|
|
506
|
+
return 0;
|
|
507
|
+
}
|
|
508
|
+
})(CSS = Format2.CSS || (Format2.CSS = {}));
|
|
509
|
+
})(Format = Color2.Format || (Color2.Format = {}));
|
|
510
|
+
})(Color || (Color = {}));
|
|
511
|
+
|
|
512
|
+
// src/base/common/platform.ts
|
|
513
|
+
var _isWindows = false;
|
|
514
|
+
var _isMacintosh = false;
|
|
515
|
+
var _isLinux = false;
|
|
516
|
+
var _isFreeBSD = false;
|
|
517
|
+
var _isNative = false;
|
|
518
|
+
var _isWeb = false;
|
|
519
|
+
var isElectronRenderer = typeof process !== "undefined" && typeof process.versions !== "undefined" && typeof process.versions.electron !== "undefined" && process.type === "renderer";
|
|
520
|
+
if (typeof navigator === "object" && !isElectronRenderer) {
|
|
521
|
+
const userAgent = navigator.userAgent;
|
|
522
|
+
_isWindows = userAgent.indexOf("Windows") >= 0;
|
|
523
|
+
_isMacintosh = userAgent.indexOf("Macintosh") >= 0;
|
|
524
|
+
_isLinux = userAgent.indexOf("Linux") >= 0;
|
|
525
|
+
_isFreeBSD = userAgent.indexOf("FreeBSD") >= 0;
|
|
526
|
+
_isWeb = true;
|
|
527
|
+
} else if (typeof process === "object") {
|
|
528
|
+
_isWindows = process.platform === "win32";
|
|
529
|
+
_isMacintosh = process.platform === "darwin";
|
|
530
|
+
_isLinux = process.platform === "linux";
|
|
531
|
+
_isFreeBSD = process.platform === "freebsd";
|
|
532
|
+
_isNative = true;
|
|
102
533
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
|
|
534
|
+
var _platform = 0 /* Web */;
|
|
535
|
+
if (_isNative) {
|
|
536
|
+
if (_isMacintosh) {
|
|
537
|
+
_platform = 1 /* Mac */;
|
|
538
|
+
} else if (_isWindows) {
|
|
539
|
+
_platform = 4 /* Windows */;
|
|
540
|
+
} else if (_isLinux) {
|
|
541
|
+
_platform = 2 /* Linux */;
|
|
542
|
+
} else if (_isFreeBSD) {
|
|
543
|
+
_platform = 3 /* FreeBSD */;
|
|
544
|
+
}
|
|
113
545
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
546
|
+
var isMacintosh = _isMacintosh;
|
|
547
|
+
var _wl = _isWindows ? 1 /* Windows */ : 3 /* Linux */ | 4 /* FreeBSD */;
|
|
548
|
+
|
|
549
|
+
// src/consts.ts
|
|
550
|
+
var INACTIVE_FOREGROUND_DARK = Color.fromHex("#222222");
|
|
551
|
+
var ACTIVE_FOREGROUND_DARK = Color.fromHex("#333333");
|
|
552
|
+
var INACTIVE_FOREGROUND = Color.fromHex("#EEEEEE");
|
|
553
|
+
var ACTIVE_FOREGROUND = Color.fromHex("#FFFFFF");
|
|
554
|
+
var DEFAULT_ITEM_SELECTOR = Color.fromHex("#0000001F");
|
|
555
|
+
var IS_MAC_BIGSUR_OR_LATER = isMacintosh && parseInt(process.getSystemVersion().split(".")[0]) >= 11;
|
|
556
|
+
var WINDOW_MIN_WIDTH = 400;
|
|
557
|
+
var WINDOW_MIN_HEIGHT = 270;
|
|
558
|
+
|
|
559
|
+
// src/main/attach-titlebar-to-window.ts
|
|
560
|
+
var attachedWindows = /* @__PURE__ */ new WeakMap();
|
|
561
|
+
var attach_titlebar_to_window_default = (browserWindow, options = {}) => {
|
|
562
|
+
const existingDetach = attachedWindows.get(browserWindow);
|
|
563
|
+
if (existingDetach) {
|
|
564
|
+
return existingDetach;
|
|
120
565
|
}
|
|
566
|
+
const [windowWidth, windowHeight] = browserWindow.getSize();
|
|
567
|
+
const minWidth = Number.isFinite(options.minWidth) ? Math.max(0, Math.floor(options.minWidth)) : Math.max(windowWidth, WINDOW_MIN_WIDTH);
|
|
568
|
+
const minHeight = Number.isFinite(options.minHeight) ? Math.max(0, Math.floor(options.minHeight)) : Math.max(windowHeight, WINDOW_MIN_HEIGHT);
|
|
569
|
+
browserWindow.setMinimumSize(minWidth, minHeight);
|
|
570
|
+
const emit = (channel, value) => {
|
|
571
|
+
if (!browserWindow.isDestroyed()) {
|
|
572
|
+
browserWindow.webContents.send(channel, value);
|
|
573
|
+
}
|
|
574
|
+
};
|
|
575
|
+
const onEnterFullScreen = () => emit("window-fullscreen", true);
|
|
576
|
+
const onLeaveFullScreen = () => emit("window-fullscreen", false);
|
|
577
|
+
const onFocus = () => emit("window-focus", true);
|
|
578
|
+
const onBlur = () => emit("window-focus", false);
|
|
579
|
+
const onMaximize = () => emit("window-maximize", true);
|
|
580
|
+
const onUnmaximize = () => emit("window-maximize", false);
|
|
581
|
+
browserWindow.on("enter-full-screen", onEnterFullScreen);
|
|
582
|
+
browserWindow.on("leave-full-screen", onLeaveFullScreen);
|
|
583
|
+
browserWindow.on("focus", onFocus);
|
|
584
|
+
browserWindow.on("blur", onBlur);
|
|
585
|
+
browserWindow.on("maximize", onMaximize);
|
|
586
|
+
browserWindow.on("unmaximize", onUnmaximize);
|
|
587
|
+
const detach = () => {
|
|
588
|
+
browserWindow.removeListener("enter-full-screen", onEnterFullScreen);
|
|
589
|
+
browserWindow.removeListener("leave-full-screen", onLeaveFullScreen);
|
|
590
|
+
browserWindow.removeListener("focus", onFocus);
|
|
591
|
+
browserWindow.removeListener("blur", onBlur);
|
|
592
|
+
browserWindow.removeListener("maximize", onMaximize);
|
|
593
|
+
browserWindow.removeListener("unmaximize", onUnmaximize);
|
|
594
|
+
attachedWindows.delete(browserWindow);
|
|
595
|
+
};
|
|
596
|
+
attachedWindows.set(browserWindow, detach);
|
|
597
|
+
browserWindow.once("closed", detach);
|
|
598
|
+
return detach;
|
|
599
|
+
};
|
|
600
|
+
|
|
601
|
+
// src/main/setup-titlebar.ts
|
|
602
|
+
var import_electron = require("electron");
|
|
603
|
+
|
|
604
|
+
// src/types/ipc-contract.ts
|
|
605
|
+
var IpcChannels = {
|
|
606
|
+
// Async (invoke/handle)
|
|
607
|
+
GET_WINDOW_MAXIMIZED: "window-event:is-maximized",
|
|
608
|
+
UPDATE_WINDOW_CONTROLS: "update-window-controls",
|
|
609
|
+
REQUEST_MENU_ICON: "menu-icon:request",
|
|
610
|
+
REQUEST_APPLICATION_MENU: "request-application-menu",
|
|
611
|
+
// Fire-and-forget (send/on)
|
|
612
|
+
WINDOW_EVENT: "window-event",
|
|
613
|
+
MENU_EVENT: "menu-event",
|
|
614
|
+
SET_MINIMUM_SIZE: "window-set-minimumSize",
|
|
615
|
+
GET_THEME_CONFIG: "theme-config:get"
|
|
616
|
+
};
|
|
617
|
+
|
|
618
|
+
// src/main/setup-titlebar.ts
|
|
619
|
+
var titlebarSetupDone = false;
|
|
620
|
+
var cachedThemeConfig = null;
|
|
621
|
+
var setup_titlebar_default = () => {
|
|
622
|
+
if (process.type !== "browser") return;
|
|
623
|
+
if (titlebarSetupDone) return;
|
|
624
|
+
titlebarSetupDone = true;
|
|
625
|
+
import_electron.ipcMain.handle(
|
|
626
|
+
IpcChannels.REQUEST_APPLICATION_MENU,
|
|
627
|
+
async () => JSON.parse(
|
|
628
|
+
JSON.stringify(
|
|
629
|
+
import_electron.Menu.getApplicationMenu(),
|
|
630
|
+
(key, value) => key !== "commandsMap" && key !== "menu" ? value : void 0
|
|
631
|
+
)
|
|
632
|
+
)
|
|
633
|
+
);
|
|
634
|
+
import_electron.ipcMain.on(
|
|
635
|
+
IpcChannels.WINDOW_EVENT,
|
|
636
|
+
(event, eventName) => {
|
|
637
|
+
const window = import_electron.BrowserWindow.fromWebContents(event.sender);
|
|
638
|
+
if (!window) return;
|
|
639
|
+
switch (eventName) {
|
|
640
|
+
case "window-minimize":
|
|
641
|
+
window.minimize();
|
|
642
|
+
break;
|
|
643
|
+
case "window-maximize":
|
|
644
|
+
window.isMaximized() ? window.unmaximize() : window.maximize();
|
|
645
|
+
break;
|
|
646
|
+
case "window-close":
|
|
647
|
+
window.close();
|
|
648
|
+
break;
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
);
|
|
652
|
+
import_electron.ipcMain.on(
|
|
653
|
+
IpcChannels.MENU_EVENT,
|
|
654
|
+
(event, commandId) => {
|
|
655
|
+
const item = getMenuItemByCommandId(commandId, import_electron.Menu.getApplicationMenu());
|
|
656
|
+
if (item)
|
|
657
|
+
item.click(
|
|
658
|
+
void 0,
|
|
659
|
+
import_electron.BrowserWindow.fromWebContents(event.sender),
|
|
660
|
+
event.sender
|
|
661
|
+
);
|
|
662
|
+
}
|
|
663
|
+
);
|
|
664
|
+
import_electron.ipcMain.on(
|
|
665
|
+
IpcChannels.SET_MINIMUM_SIZE,
|
|
666
|
+
(event, width, height) => {
|
|
667
|
+
const window = import_electron.BrowserWindow.fromWebContents(event.sender);
|
|
668
|
+
if (!window) return;
|
|
669
|
+
const normalizedWidth = Number.isFinite(width) ? Math.max(0, Math.floor(width)) : 0;
|
|
670
|
+
const normalizedHeight = Number.isFinite(height) ? Math.max(0, Math.floor(height)) : 0;
|
|
671
|
+
window.setMinimumSize(normalizedWidth, normalizedHeight);
|
|
672
|
+
}
|
|
673
|
+
);
|
|
674
|
+
import_electron.ipcMain.handle(
|
|
675
|
+
IpcChannels.REQUEST_MENU_ICON,
|
|
676
|
+
async (event, commandId) => {
|
|
677
|
+
const item = getMenuItemByCommandId(commandId, import_electron.Menu.getApplicationMenu());
|
|
678
|
+
if (item && item.icon && typeof item.icon !== "string") {
|
|
679
|
+
return item.icon.toDataURL();
|
|
680
|
+
}
|
|
681
|
+
return null;
|
|
682
|
+
}
|
|
683
|
+
);
|
|
684
|
+
import_electron.ipcMain.handle(
|
|
685
|
+
IpcChannels.GET_WINDOW_MAXIMIZED,
|
|
686
|
+
(event) => {
|
|
687
|
+
const window = import_electron.BrowserWindow.fromWebContents(event.sender);
|
|
688
|
+
return window ? window.isMaximized() : false;
|
|
689
|
+
}
|
|
690
|
+
);
|
|
691
|
+
import_electron.ipcMain.handle(
|
|
692
|
+
IpcChannels.UPDATE_WINDOW_CONTROLS,
|
|
693
|
+
(event, args) => {
|
|
694
|
+
return updateWindowControls(event, args);
|
|
695
|
+
}
|
|
696
|
+
);
|
|
697
|
+
import_electron.ipcMain.on(
|
|
698
|
+
IpcChannels.UPDATE_WINDOW_CONTROLS,
|
|
699
|
+
(event, args) => {
|
|
700
|
+
event.returnValue = updateWindowControls(event, args);
|
|
701
|
+
}
|
|
702
|
+
);
|
|
703
|
+
import_electron.ipcMain.handle(IpcChannels.GET_THEME_CONFIG, async () => {
|
|
704
|
+
return cachedThemeConfig;
|
|
705
|
+
});
|
|
706
|
+
};
|
|
707
|
+
function setThemeConfig(config) {
|
|
708
|
+
cachedThemeConfig = config;
|
|
121
709
|
}
|
|
122
|
-
function
|
|
123
|
-
|
|
124
|
-
|
|
710
|
+
function updateWindowControls(event, args) {
|
|
711
|
+
const window = import_electron.BrowserWindow.fromWebContents(event.sender);
|
|
712
|
+
try {
|
|
713
|
+
if (window) window.setTitleBarOverlay(args);
|
|
714
|
+
return true;
|
|
715
|
+
} catch (_) {
|
|
716
|
+
return false;
|
|
717
|
+
}
|
|
125
718
|
}
|
|
126
|
-
function
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
719
|
+
function getMenuItemByCommandId(commandId, menu) {
|
|
720
|
+
if (!menu) return void 0;
|
|
721
|
+
for (const item of menu.items) {
|
|
722
|
+
if (item.submenu) {
|
|
723
|
+
const submenuItem = getMenuItemByCommandId(commandId, item.submenu);
|
|
724
|
+
if (submenuItem) return submenuItem;
|
|
725
|
+
} else if (item.commandId === commandId) return item;
|
|
726
|
+
}
|
|
727
|
+
return void 0;
|
|
131
728
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
});
|
|
142
|
-
};
|
|
143
|
-
} else {
|
|
144
|
-
if (value === undefined) {
|
|
145
|
-
rewireData[variableName] = INTENTIONAL_UNDEFINED;
|
|
146
|
-
} else {
|
|
147
|
-
rewireData[variableName] = value;
|
|
148
|
-
}
|
|
149
|
-
return function () {
|
|
150
|
-
_reset__(variableName);
|
|
151
|
-
};
|
|
729
|
+
|
|
730
|
+
// src/main/index.ts
|
|
731
|
+
var fs = __toESM(require("fs/promises"));
|
|
732
|
+
|
|
733
|
+
// src/titlebar/theme-config.ts
|
|
734
|
+
var TITLEBAR_THEME_CONFIG_VERSION = 1;
|
|
735
|
+
function asRecord(input) {
|
|
736
|
+
if (!input || typeof input !== "object" || Array.isArray(input)) {
|
|
737
|
+
return null;
|
|
152
738
|
}
|
|
739
|
+
return input;
|
|
153
740
|
}
|
|
154
|
-
function
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
if (Object.keys(rewireData).length == 0) {
|
|
158
|
-
delete _getRewireRegistry__()[_getRewireModuleId__];
|
|
741
|
+
function asString(input) {
|
|
742
|
+
if (typeof input !== "string") {
|
|
743
|
+
return void 0;
|
|
159
744
|
}
|
|
160
|
-
;
|
|
745
|
+
const value = input.trim();
|
|
746
|
+
return value.length ? value : void 0;
|
|
161
747
|
}
|
|
162
|
-
function
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
var previousValues = {};
|
|
166
|
-
function reset() {
|
|
167
|
-
rewiredVariableNames.forEach(function (variableName) {
|
|
168
|
-
rewireData[variableName] = previousValues[variableName];
|
|
169
|
-
});
|
|
748
|
+
function asFiniteNumber(input) {
|
|
749
|
+
if (typeof input !== "number" || !Number.isFinite(input)) {
|
|
750
|
+
return void 0;
|
|
170
751
|
}
|
|
171
|
-
return
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
752
|
+
return input;
|
|
753
|
+
}
|
|
754
|
+
function sanitizeColors(input) {
|
|
755
|
+
const source = asRecord(input);
|
|
756
|
+
if (!source) {
|
|
757
|
+
return void 0;
|
|
758
|
+
}
|
|
759
|
+
const colors = {
|
|
760
|
+
titlebar: asString(source.titlebar),
|
|
761
|
+
titlebarForeground: asString(source.titlebarForeground),
|
|
762
|
+
menuBar: asString(source.menuBar),
|
|
763
|
+
menuItemSelection: asString(source.menuItemSelection),
|
|
764
|
+
menuSeparator: asString(source.menuSeparator),
|
|
765
|
+
svg: asString(source.svg)
|
|
183
766
|
};
|
|
767
|
+
const hasAnyColor = !!(colors.titlebar || colors.titlebarForeground || colors.menuBar || colors.menuItemSelection || colors.menuSeparator || colors.svg);
|
|
768
|
+
return hasAnyColor ? colors : void 0;
|
|
184
769
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
770
|
+
function normalizeThemeConfig(input) {
|
|
771
|
+
const warnings = [];
|
|
772
|
+
const source = asRecord(input);
|
|
773
|
+
if (!source) {
|
|
774
|
+
return { config: null, warnings: ["Theme config must be a JSON object."] };
|
|
775
|
+
}
|
|
776
|
+
const requestedVersion = asFiniteNumber(source.version);
|
|
777
|
+
if (requestedVersion !== void 0 && requestedVersion !== TITLEBAR_THEME_CONFIG_VERSION) {
|
|
778
|
+
warnings.push(`Theme config version ${requestedVersion} is not fully supported. Falling back to v${TITLEBAR_THEME_CONFIG_VERSION} compatible fields.`);
|
|
779
|
+
}
|
|
780
|
+
const config = {
|
|
781
|
+
fontFamily: asString(source.fontFamily),
|
|
782
|
+
fontSize: asFiniteNumber(source.fontSize),
|
|
783
|
+
colors: sanitizeColors(source.colors)
|
|
784
|
+
};
|
|
785
|
+
const hasConfig = !!(config.fontFamily || config.fontSize !== void 0 || config.colors);
|
|
786
|
+
if (!hasConfig) {
|
|
787
|
+
return { config: null, warnings: warnings.concat("No supported theme fields found in config.") };
|
|
788
|
+
}
|
|
789
|
+
return { config, warnings };
|
|
192
790
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
791
|
+
|
|
792
|
+
// src/main/index.ts
|
|
793
|
+
async function setupTitlebarAndAttachToWindow(browserWindow, options = {}) {
|
|
794
|
+
if (options.setupGlobal !== false) {
|
|
795
|
+
setup_titlebar_default();
|
|
796
|
+
}
|
|
797
|
+
if (options.themeConfigPath) {
|
|
798
|
+
try {
|
|
799
|
+
const raw = await fs.readFile(options.themeConfigPath, "utf8");
|
|
800
|
+
const parsed = JSON.parse(raw);
|
|
801
|
+
const normalized = normalizeThemeConfig(parsed);
|
|
802
|
+
if (normalized.warnings.length) {
|
|
803
|
+
console.warn(`[custom-electron-titlebar] Theme config from ${options.themeConfigPath}:`, normalized.warnings.join("; "));
|
|
804
|
+
}
|
|
805
|
+
if (normalized.config) {
|
|
806
|
+
setThemeConfig(normalized.config);
|
|
807
|
+
}
|
|
808
|
+
} catch (err) {
|
|
809
|
+
console.error(`[custom-electron-titlebar] Failed to load theme config from ${options.themeConfigPath}:`, err);
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
return attach_titlebar_to_window_default(browserWindow, options);
|
|
813
|
+
}
|
|
814
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
815
|
+
0 && (module.exports = {
|
|
816
|
+
attachTitlebarToWindow,
|
|
817
|
+
setupTitlebar,
|
|
818
|
+
setupTitlebarAndAttachToWindow
|
|
819
|
+
});
|
|
820
|
+
//# sourceMappingURL=index.js.map
|