pinggy 0.5.3 → 0.5.6

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.
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  TunnelManager
3
- } from "./chunk-DLNUDW6G.js";
3
+ } from "./chunk-PQSLSIDA.js";
4
4
  import "./chunk-UB26QJ4T.js";
5
5
  import {
6
6
  logger
7
- } from "./chunk-7G6SJEEA.js";
7
+ } from "./chunk-P7WNBN7F.js";
8
8
  import "./chunk-GBYF2H4H.js";
9
9
 
10
10
  // src/tui/blessed/TunnelTui.ts
@@ -150,10 +150,21 @@ var asciiArtPinggyLogo = `
150
150
  \u2588\u2588\u2554\u2550\u2550\u2550\u255D \u2588\u2588\u2551\u2588\u2588\u2551\u255A\u2588\u2588\u2557\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551 \u255A\u2588\u2588\u2554\u255D
151
151
  \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2588\u2551\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D \u2588\u2588\u2551
152
152
  \u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D `;
153
+ var asciiArtPinggyLogoCompact = "P I N G G Y";
154
+ var asciiArtPinggyLogoMedium = [
155
+ " ___ ___ _ _ ___ _____ __",
156
+ "| _ \\_ _| \\| |/ __|/ __\\ \\ / /",
157
+ "| _/| || .` | (_ | (_ |\\ V /",
158
+ "|_| |___|_|\\_|\\___|\\___| |_|"
159
+ ].join("\n");
153
160
 
154
161
  // src/tui/blessed/components/UIComponents.ts
155
162
  var MIN_WIDTH_WARNING = 60;
156
163
  var SIMPLE_LAYOUT_THRESHOLD = 80;
164
+ var MEDIUM_LOGO_THRESHOLD = 100;
165
+ var FULL_LOGO_THRESHOLD = 120;
166
+ var MEDIUM_LOGO_HEIGHT_THRESHOLD = 26;
167
+ var FULL_LOGO_HEIGHT_THRESHOLD = 34;
157
168
  function colorizeGradient(text) {
158
169
  const colors = ["red", "yellow", "green", "cyan", "blue", "magenta"];
159
170
  const lines = text.split("\n");
@@ -162,6 +173,54 @@ function colorizeGradient(text) {
162
173
  return `{${color}-fg}${line}{/${color}-fg}`;
163
174
  }).join("\n");
164
175
  }
176
+ function colorizeGradientHorizontal(text) {
177
+ const colors = ["red", "yellow", "green", "cyan", "blue", "magenta"];
178
+ let colorIndex = 0;
179
+ return [...text].map((char) => {
180
+ if (char === " ") return char;
181
+ const color = colors[colorIndex % colors.length];
182
+ colorIndex++;
183
+ return `{${color}-fg}${char}{/${color}-fg}`;
184
+ }).join("");
185
+ }
186
+ function selectLogo(width, height) {
187
+ const widthTier = width >= FULL_LOGO_THRESHOLD ? 2 : width >= MEDIUM_LOGO_THRESHOLD ? 1 : 0;
188
+ const heightTier = height >= FULL_LOGO_HEIGHT_THRESHOLD ? 2 : height >= MEDIUM_LOGO_HEIGHT_THRESHOLD ? 1 : 0;
189
+ const tier = Math.min(widthTier, heightTier);
190
+ if (tier === 2) {
191
+ return { content: colorizeGradient(asciiArtPinggyLogo), boxHeight: 7 };
192
+ }
193
+ if (tier === 1) {
194
+ return { content: colorizeGradient(asciiArtPinggyLogoMedium), boxHeight: 5 };
195
+ }
196
+ return {
197
+ content: `{bold}${colorizeGradientHorizontal(asciiArtPinggyLogoCompact)}{/bold}`,
198
+ boxHeight: 1
199
+ };
200
+ }
201
+ function wrapText(text, width) {
202
+ const lines = [];
203
+ let current = "";
204
+ for (const word of text.split(/\s+/).filter(Boolean)) {
205
+ const candidate = current ? `${current} ${word}` : word;
206
+ if (candidate.length <= width) {
207
+ current = candidate;
208
+ continue;
209
+ }
210
+ if (current) {
211
+ lines.push(current);
212
+ current = "";
213
+ }
214
+ let rest = word;
215
+ while (rest.length > width) {
216
+ lines.push(rest.slice(0, width));
217
+ rest = rest.slice(width);
218
+ }
219
+ current = rest;
220
+ }
221
+ if (current) lines.push(current);
222
+ return lines.length ? lines : [""];
223
+ }
165
224
  function createWarningUI(screen) {
166
225
  return blessed.box({
167
226
  parent: screen,
@@ -188,21 +247,26 @@ function createFullUI(screen, urls, greet, tunnelConfig) {
188
247
  height: "100%",
189
248
  padding: 1
190
249
  });
250
+ const { content: logoContent, boxHeight: logoHeight } = selectLogo(
251
+ screen.width,
252
+ screen.height
253
+ );
191
254
  const logoBox = blessed.box({
192
255
  parent: mainContainer,
193
256
  top: 0,
194
257
  left: 0,
195
258
  width: "100%",
196
- height: 7,
197
- content: colorizeGradient(asciiArtPinggyLogo),
259
+ height: logoHeight,
260
+ content: logoContent,
198
261
  tags: true
199
262
  });
263
+ const contentTop = logoHeight + 1;
200
264
  const contentBox = blessed.box({
201
265
  parent: mainContainer,
202
- top: 8,
266
+ top: contentTop,
203
267
  left: 0,
204
268
  width: "100%-2",
205
- height: "100%-10",
269
+ height: `100%-${contentTop + 2}`,
206
270
  padding: 0,
207
271
  border: {
208
272
  type: "line"
@@ -215,20 +279,24 @@ function createFullUI(screen, urls, greet, tunnelConfig) {
215
279
  });
216
280
  let greetHeight = 0;
217
281
  if (greet) {
218
- const greetBox = blessed.box({
282
+ const contentInnerWidth = screen.width - 6;
283
+ const greetWidth = Math.max(20, Math.floor(contentInnerWidth * 0.6));
284
+ const greetLines = wrapText(greet, greetWidth);
285
+ const greetBoxHeight = greetLines.length + 1;
286
+ blessed.box({
219
287
  parent: contentBox,
220
288
  top: 0,
221
289
  left: "center",
222
- width: "60%",
223
- height: 4,
224
- content: `{bold}${greet}{/bold}`,
290
+ width: greetWidth,
291
+ height: greetBoxHeight,
292
+ content: greetLines.map((line) => `{bold}${line}{/bold}`).join("\n"),
225
293
  tags: true,
226
294
  align: "center",
227
295
  style: {
228
296
  fg: "green"
229
297
  }
230
298
  });
231
- greetHeight = 4;
299
+ greetHeight = greetBoxHeight;
232
300
  }
233
301
  const upperSectionTop = greetHeight > 0 ? greetHeight : 0;
234
302
  const upperSection = blessed.box({
@@ -322,21 +390,22 @@ function createSimpleUI(screen, urls, greet) {
322
390
  });
323
391
  let currentTop = 0;
324
392
  if (greet) {
393
+ const greetWidth = Math.max(20, Math.floor((screen.width - 2) * 0.9));
394
+ const greetLines = wrapText(greet, greetWidth);
325
395
  blessed.box({
326
396
  parent: mainContainer,
327
397
  top: currentTop,
328
398
  left: "center",
329
- width: "90%",
330
- height: "shrink",
331
- content: `{bold}${greet}{/bold}`,
399
+ width: greetWidth,
400
+ height: greetLines.length,
401
+ content: greetLines.map((line) => `{bold}${line}{/bold}`).join("\n"),
332
402
  tags: true,
333
403
  align: "center",
334
404
  style: {
335
405
  fg: "green"
336
406
  }
337
407
  });
338
- const lines = Math.ceil(greet.length / (screen.width * 0.9));
339
- currentTop += Math.max(lines, 1) + 1;
408
+ currentTop += greetLines.length + 1;
340
409
  }
341
410
  const urlsBox = blessed.box({
342
411
  parent: mainContainer,