bingocode 1.1.168 → 1.1.170
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/package.json +1 -1
- package/src/entrypoints/tray-only.ts +8 -62
package/package.json
CHANGED
|
@@ -28,64 +28,8 @@ process.on('exit', () => {
|
|
|
28
28
|
try { fs.unlinkSync(DAEMON_LOCK_FILE); } catch {}
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
-
//
|
|
32
|
-
|
|
33
|
-
function buildGreenDotBase64(): string {
|
|
34
|
-
const W = 16, H = 16;
|
|
35
|
-
const raw: number[] = [];
|
|
36
|
-
for (let y = 0; y < H; y++) {
|
|
37
|
-
raw.push(0); // filter none
|
|
38
|
-
for (let x = 0; x < W; x++) {
|
|
39
|
-
const dx = x - 7.5, dy = y - 7.5;
|
|
40
|
-
const d = Math.sqrt(dx*dx + dy*dy);
|
|
41
|
-
if (d < 5.5) {
|
|
42
|
-
raw.push(0x1a, 0xe8, 0x30, 0xff);
|
|
43
|
-
} else {
|
|
44
|
-
raw.push(0, 0, 0, 0);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
const rgbadata = Buffer.from(raw);
|
|
49
|
-
const compressed = zlib.deflateSync(rgbadata);
|
|
50
|
-
const sig = Buffer.from([137,80,78,71,13,10,26,10]);
|
|
51
|
-
const ihdrData = Buffer.alloc(13);
|
|
52
|
-
ihdrData.writeUInt32BE(W, 0);
|
|
53
|
-
ihdrData.writeUInt32BE(H, 4);
|
|
54
|
-
ihdrData.writeUInt8(8, 8);
|
|
55
|
-
ihdrData.writeUInt8(6, 9);
|
|
56
|
-
const ihdr = makePngChunk('IHDR', ihdrData);
|
|
57
|
-
const idat = makePngChunk('IDAT', compressed);
|
|
58
|
-
const iend = makePngChunk('IEND', Buffer.alloc(0));
|
|
59
|
-
return Buffer.concat([sig, ihdr, idat, iend]).toString('base64');
|
|
60
|
-
}
|
|
61
|
-
function makePngChunk(type: string, data: Buffer): Buffer {
|
|
62
|
-
const t = Buffer.from(type, 'ascii');
|
|
63
|
-
const len = Buffer.alloc(4); len.writeUInt32BE(data.length, 0);
|
|
64
|
-
const crcInput = Buffer.concat([t, data]);
|
|
65
|
-
const crc = crc32(crcInput);
|
|
66
|
-
const trailer = Buffer.alloc(4); trailer.writeUInt32BE(crc, 0);
|
|
67
|
-
return Buffer.concat([len, t, data, trailer]);
|
|
68
|
-
}
|
|
69
|
-
function crc32(buf: Buffer): number {
|
|
70
|
-
let c = 0xffffffff;
|
|
71
|
-
for (let i = 0; i < buf.length; i++) {
|
|
72
|
-
c = crcTable[(c ^ buf[i]) & 0xff] ^ (c >>> 8);
|
|
73
|
-
}
|
|
74
|
-
return (c ^ 0xffffffff) >>> 0;
|
|
75
|
-
}
|
|
76
|
-
const crcTable = (() => {
|
|
77
|
-
const t = new Int32Array(256);
|
|
78
|
-
for (let n = 0; n < 256; n++) {
|
|
79
|
-
let c = n;
|
|
80
|
-
for (let k = 0; k < 8; k++) {
|
|
81
|
-
c = (c & 1) ? (0xedb88320 ^ (c >>> 1)) : (c >>> 1);
|
|
82
|
-
}
|
|
83
|
-
t[n] = c;
|
|
84
|
-
}
|
|
85
|
-
return t;
|
|
86
|
-
})();
|
|
87
|
-
|
|
88
|
-
const iconB64 = buildGreenDotBase64();
|
|
31
|
+
// Tray icon: hexagon black-gold with "B" initial (16x16 RGBA PNG, pre-encoded)
|
|
32
|
+
const iconB64 = 'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAS0lEQVR4nGNgGLRAQUHhPzKmSDPRhiAr/n/AAAXjNQjdJnTN2AxBMQibRnyGEW0AMk2WAfR3AbJB+FxFVGyQFI1US0j4DCFJM10BADtB9/MMO0W9AAAAAElFTkSuQmCC';
|
|
89
33
|
|
|
90
34
|
try {
|
|
91
35
|
const systray = new SysTray({
|
|
@@ -118,12 +62,14 @@ try {
|
|
|
118
62
|
const req = http.request(
|
|
119
63
|
`http://${HOST}:${PORT}/exit`,
|
|
120
64
|
{ method: 'POST', timeout: 5000 },
|
|
121
|
-
() => {
|
|
65
|
+
(res) => {
|
|
66
|
+
res.resume();
|
|
67
|
+
try { systray.kill(false); } catch {}
|
|
68
|
+
process.exit(0);
|
|
69
|
+
},
|
|
122
70
|
);
|
|
123
71
|
req.on('error', () => {
|
|
124
|
-
try {
|
|
125
|
-
systray.kill(false);
|
|
126
|
-
} catch {}
|
|
72
|
+
try { systray.kill(false); } catch {}
|
|
127
73
|
process.exit(0);
|
|
128
74
|
});
|
|
129
75
|
req.end();
|