File size: 1,385 Bytes
39371ea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// xterm.js renders text/ANSI; this app does not install Kitty/iTerm image addons.
// Pi's native image module also probes tmux via child_process. Keep that host
// dependency out of the browser and advertise only capabilities we implement.
let capabilities = { images: null, trueColor: true, hyperlinks: true };
let dimensions = { widthPx: 8, heightPx: 16 };
export const getCapabilities = () => capabilities;
export const setCapabilities = value => { capabilities = { ...value, images: null }; };
export const getCellDimensions = () => dimensions;
export const setCellDimensions = value => { dimensions = value; };
export const isImageLine = () => false;
export const getKittyImagePlacement = () => undefined;
export const getKittyImageMetadata = () => undefined;
export const cropKittyImageLine = line => line;
export const deleteKittyImage = () => '';
export const deleteAllKittyImages = () => '';
export const deleteAllKittyPlacements = () => '';
export function hyperlink(text, url) {
  // Generated text may contain arbitrary URLs. Only explicit user clicks open
  // HTTP(S) links, and no terminal control bytes may enter their OSC envelope.
  try {
    const parsed = new URL(url);
    if (!['https:', 'http:'].includes(parsed.protocol) || /[\x00-\x20\x7f-\x9f]/.test(url)) return text;
    return `\x1b]8;;${parsed.href}\x07${text}\x1b]8;;\x07`;
  } catch { return text; }
}