tmux-weblink 3.2.0 → 3.2.2
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/dist/assets/apple-touch-icon-180.png +0 -0
- package/dist/assets/icon-192.png +0 -0
- package/dist/assets/icon-512.png +0 -0
- package/dist/assets/icon-maskable-192.png +0 -0
- package/dist/assets/icon-maskable-512.png +0 -0
- package/dist/assets/shell-client.js +13 -13
- package/dist/browser/shell-client.js +12 -12
- package/dist/lib/build-app.js +26 -10
- package/dist/lib/pages/shell.js +41 -12
- package/package.json +3 -3
- package/scripts/generate-icons.mjs +136 -145
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
// Generates PWA icons (
|
|
2
|
-
//
|
|
3
|
-
|
|
1
|
+
// Generates the PWA icons with pure Node (zlib only) — no build tooling needed.
|
|
2
|
+
//
|
|
3
|
+
// Design: a full-bleed square (the OS applies its own mask, so no inner rounded
|
|
4
|
+
// rectangle), a quiet vertical gradient, a soft accent glow behind the glyph and
|
|
5
|
+
// a bold ">_" prompt. The maskable variant keeps the glyph inside the safe zone
|
|
6
|
+
// (80% circle) so Android never crops it.
|
|
7
|
+
import { deflateSync } from "node:zlib";
|
|
4
8
|
import { writeFileSync, mkdirSync } from "node:fs";
|
|
5
9
|
import { join, dirname } from "node:path";
|
|
6
10
|
import { fileURLToPath } from "node:url";
|
|
@@ -8,160 +12,147 @@ import { fileURLToPath } from "node:url";
|
|
|
8
12
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
9
13
|
const ICONS_DIR = join(__dirname, "..", "dist", "assets");
|
|
10
14
|
|
|
15
|
+
const BG_TOP = [16, 22, 31];
|
|
16
|
+
const BG_BOTTOM = [9, 12, 17];
|
|
17
|
+
const ACCENT = [125, 211, 252];
|
|
18
|
+
const SUPERSAMPLE = 4;
|
|
19
|
+
|
|
11
20
|
function crc32(buf) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
21
|
+
let crc = 0xffffffff;
|
|
22
|
+
for (let i = 0; i < buf.length; i++) {
|
|
23
|
+
crc ^= buf[i];
|
|
24
|
+
for (let j = 0; j < 8; j++) crc = (crc >>> 1) ^ (crc & 1 ? 0xedb88320 : 0);
|
|
25
|
+
}
|
|
26
|
+
return (crc ^ 0xffffffff) >>> 0;
|
|
18
27
|
}
|
|
19
28
|
|
|
20
29
|
function pngChunk(type, data) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
30
|
+
const len = Buffer.alloc(4);
|
|
31
|
+
len.writeUInt32BE(data.length);
|
|
32
|
+
const typeB = Buffer.from(type, "ascii");
|
|
33
|
+
const crc = Buffer.alloc(4);
|
|
34
|
+
crc.writeUInt32BE(crc32(Buffer.concat([typeB, data])));
|
|
35
|
+
return Buffer.concat([len, typeB, data, crc]);
|
|
27
36
|
}
|
|
28
37
|
|
|
29
38
|
function createPNG(width, height, getPixel) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
39
|
+
const stride = 1 + width * 4;
|
|
40
|
+
const raw = Buffer.alloc(height * stride);
|
|
41
|
+
for (let y = 0; y < height; y++) {
|
|
42
|
+
raw[y * stride] = 0;
|
|
43
|
+
for (let x = 0; x < width; x++) {
|
|
44
|
+
const [r, g, b, a] = getPixel(x, y);
|
|
45
|
+
const p = y * stride + 1 + x * 4;
|
|
46
|
+
raw[p] = Math.max(0, Math.min(255, Math.round(r)));
|
|
47
|
+
raw[p + 1] = Math.max(0, Math.min(255, Math.round(g)));
|
|
48
|
+
raw[p + 2] = Math.max(0, Math.min(255, Math.round(b)));
|
|
49
|
+
raw[p + 3] = Math.max(0, Math.min(255, Math.round(a)));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
// PNG IDAT must be a zlib stream (raw deflate decodes as a corrupt PNG).
|
|
53
|
+
const compressed = deflateSync(raw, { level: 9 });
|
|
54
|
+
const ihdr = Buffer.alloc(13);
|
|
55
|
+
ihdr.writeUInt32BE(width, 0);
|
|
56
|
+
ihdr.writeUInt32BE(height, 4);
|
|
57
|
+
ihdr[8] = 8;
|
|
58
|
+
ihdr[9] = 6;
|
|
59
|
+
const signature = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]);
|
|
60
|
+
return Buffer.concat([
|
|
61
|
+
signature,
|
|
62
|
+
pngChunk("IHDR", ihdr),
|
|
63
|
+
pngChunk("IDAT", compressed),
|
|
64
|
+
pngChunk("IEND", Buffer.alloc(0)),
|
|
65
|
+
]);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Distance from a point to a line segment with round caps. */
|
|
69
|
+
function segmentDistance(px, py, x1, y1, x2, y2) {
|
|
70
|
+
const dx = x2 - x1;
|
|
71
|
+
const dy = y2 - y1;
|
|
72
|
+
const length2 = dx * dx + dy * dy;
|
|
73
|
+
const t = length2 === 0 ? 0 : Math.max(0, Math.min(1, ((px - x1) * dx + (py - y1) * dy) / length2));
|
|
74
|
+
return Math.hypot(px - (x1 + t * dx), py - (y1 + t * dy));
|
|
52
75
|
}
|
|
53
76
|
|
|
54
|
-
function
|
|
55
|
-
|
|
56
|
-
const t = Math.max(0, Math.min(1, ((px - x1) * dx + (py - y1) * dy) / (dx * dx + dy * dy)));
|
|
57
|
-
return Math.sqrt((px - (x1 + t * dx)) ** 2 + (py - (y1 + t * dy)) ** 2);
|
|
77
|
+
function mix(a, b, t) {
|
|
78
|
+
return [a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t, a[2] + (b[2] - a[2]) * t];
|
|
58
79
|
}
|
|
59
80
|
|
|
60
|
-
function
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
if (d1 < strokeW + strokeGlow || d2 < strokeW + strokeGlow) {
|
|
122
|
-
const t = Math.min(1, Math.max(0, 1 - (Math.min(d1, d2) - strokeW) / strokeGlow));
|
|
123
|
-
r = Math.round(r + (accent[0] - r) * t);
|
|
124
|
-
g = Math.round(g + (accent[1] - g) * t);
|
|
125
|
-
b = Math.round(b + (accent[2] - b) * t);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// "_" cursor to the right
|
|
129
|
-
const cu = 0.32, cv = 0.18;
|
|
130
|
-
const dc = Math.abs(y - cv);
|
|
131
|
-
const hc = Math.abs(x - cu);
|
|
132
|
-
const cw = 0.12, ch = 0.03;
|
|
133
|
-
if (hc < cw && dc < ch) {
|
|
134
|
-
const t = Math.min(1, 1 - (dc - ch * 0.6) / (ch * 0.4));
|
|
135
|
-
const t2 = Math.min(1, 1 - Math.max(0, x - (cu - cw * 0.6)) / (cw * 0.4));
|
|
136
|
-
const t3 = Math.min(1, 1 - Math.max(0, (cu + cw * 0.6) - x) / (cw * 0.4));
|
|
137
|
-
const final = Math.min(t, Math.max(t2, t3));
|
|
138
|
-
r = Math.round(r + (accent[0] - r) * final);
|
|
139
|
-
g = Math.round(g + (accent[1] - g) * final);
|
|
140
|
-
b = Math.round(b + (accent[2] - b) * final);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// Accumulate into output
|
|
144
|
-
const oi = (Math.floor(sy / ss) * size + Math.floor(sx / ss)) * 4;
|
|
145
|
-
accum[oi] += r * alpha;
|
|
146
|
-
accum[oi+1] += g * alpha;
|
|
147
|
-
accum[oi+2] += b * alpha;
|
|
148
|
-
accum[oi+3] += alpha;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
return createPNG(size, size, (x, y) => {
|
|
153
|
-
const i = (y * size + x) * 4;
|
|
154
|
-
const a = accum[i+3];
|
|
155
|
-
if (a === 0) return [0, 0, 0, 0];
|
|
156
|
-
const inv = 1 / (ss * ss);
|
|
157
|
-
return [accum[i] / a, accum[i+1] / a, accum[i+2] / a, Math.round(a * inv * 255)];
|
|
158
|
-
});
|
|
81
|
+
function renderIcon(size, { maskable = false } = {}) {
|
|
82
|
+
// Glyph geometry in unit coordinates; maskable art shrinks toward the centre.
|
|
83
|
+
const scale = maskable ? 0.72 : 1;
|
|
84
|
+
const chevron = [
|
|
85
|
+
[0.30, 0.38, 0.44, 0.5],
|
|
86
|
+
[0.44, 0.5, 0.30, 0.62],
|
|
87
|
+
];
|
|
88
|
+
const cursor = [0.51, 0.62, 0.68, 0.62];
|
|
89
|
+
const stroke = 0.042 * scale;
|
|
90
|
+
const point = ([x1, y1, x2, y2]) => [
|
|
91
|
+
0.5 + (x1 - 0.5) * scale,
|
|
92
|
+
0.5 + (y1 - 0.5) * scale,
|
|
93
|
+
0.5 + (x2 - 0.5) * scale,
|
|
94
|
+
0.5 + (y2 - 0.5) * scale,
|
|
95
|
+
];
|
|
96
|
+
const strokes = [...chevron.map(point), point(cursor)];
|
|
97
|
+
|
|
98
|
+
const ss = SUPERSAMPLE;
|
|
99
|
+
const large = size * ss;
|
|
100
|
+
const accum = new Float64Array(size * size * 4);
|
|
101
|
+
|
|
102
|
+
for (let sy = 0; sy < large; sy++) {
|
|
103
|
+
for (let sx = 0; sx < large; sx++) {
|
|
104
|
+
const x = (sx + 0.5) / large;
|
|
105
|
+
const y = (sy + 0.5) / large;
|
|
106
|
+
|
|
107
|
+
// Background: vertical gradient plus a soft glow behind the glyph.
|
|
108
|
+
let [r, g, b] = mix(BG_TOP, BG_BOTTOM, y);
|
|
109
|
+
const glow = Math.max(0, 1 - Math.hypot(x - 0.46, y - 0.5) / 0.62);
|
|
110
|
+
const glowAmount = glow * glow * 0.16;
|
|
111
|
+
r += (ACCENT[0] - r) * glowAmount;
|
|
112
|
+
g += (ACCENT[1] - g) * glowAmount;
|
|
113
|
+
b += (ACCENT[2] - b) * glowAmount;
|
|
114
|
+
|
|
115
|
+
// Glyph: distance to the nearest stroke, anti-aliased at the edge.
|
|
116
|
+
let distance = Infinity;
|
|
117
|
+
for (const [x1, y1, x2, y2] of strokes) {
|
|
118
|
+
distance = Math.min(distance, segmentDistance(x, y, x1, y1, x2, y2));
|
|
119
|
+
}
|
|
120
|
+
const edge = 1.4 / large;
|
|
121
|
+
const coverage = Math.max(0, Math.min(1, (stroke - distance) / edge + 0.5));
|
|
122
|
+
if (coverage > 0) {
|
|
123
|
+
r += (ACCENT[0] - r) * coverage;
|
|
124
|
+
g += (ACCENT[1] - g) * coverage;
|
|
125
|
+
b += (ACCENT[2] - b) * coverage;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const oi = (Math.floor(sy / ss) * size + Math.floor(sx / ss)) * 4;
|
|
129
|
+
accum[oi] += r;
|
|
130
|
+
accum[oi + 1] += g;
|
|
131
|
+
accum[oi + 2] += b;
|
|
132
|
+
accum[oi + 3] += 255;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const samples = ss * ss;
|
|
137
|
+
return createPNG(size, size, (x, y) => {
|
|
138
|
+
const i = (y * size + x) * 4;
|
|
139
|
+
return [accum[i] / samples, accum[i + 1] / samples, accum[i + 2] / samples, 255];
|
|
140
|
+
});
|
|
159
141
|
}
|
|
160
142
|
|
|
143
|
+
const OUTPUTS = [
|
|
144
|
+
["icon-192.png", 192, {}],
|
|
145
|
+
["icon-512.png", 512, {}],
|
|
146
|
+
["icon-maskable-192.png", 192, { maskable: true }],
|
|
147
|
+
["icon-maskable-512.png", 512, { maskable: true }],
|
|
148
|
+
// iOS ignores the manifest and wants a square, opaque apple-touch-icon.
|
|
149
|
+
["apple-touch-icon-180.png", 180, {}],
|
|
150
|
+
];
|
|
151
|
+
|
|
161
152
|
mkdirSync(ICONS_DIR, { recursive: true });
|
|
162
|
-
for (const size of
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
153
|
+
for (const [name, size, options] of OUTPUTS) {
|
|
154
|
+
const png = renderIcon(size, options);
|
|
155
|
+
const outPath = join(ICONS_DIR, name);
|
|
156
|
+
writeFileSync(outPath, png);
|
|
157
|
+
console.log(`[generate-icons] wrote ${outPath} (${png.length} bytes)`);
|
|
167
158
|
}
|