@jrichman/ink 6.5.1-beta.7 → 6.6.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/build/colorize.d.ts +0 -1
- package/build/colorize.js +3 -16
- package/build/colorize.js.map +1 -1
- package/build/debug-log.js +2 -3
- package/build/debug-log.js.map +1 -1
- package/build/ink.js +0 -3
- package/build/ink.js.map +1 -1
- package/build/measure-text.js +0 -2
- package/build/measure-text.js.map +1 -1
- package/build/render-node-to-output.js +0 -2
- package/build/render-node-to-output.js.map +1 -1
- package/build/render-scrollbar.js +22 -14
- package/build/render-scrollbar.js.map +1 -1
- package/build/text-wrap.js +1 -3
- package/build/text-wrap.js.map +1 -1
- package/package.json +1 -1
- package/build/render-worker.d.ts +0 -25
- package/build/render-worker.js +0 -370
- package/build/render-worker.js.map +0 -1
- package/build/styled-lines.d.ts +0 -29
- package/build/styled-lines.js +0 -110
- package/build/styled-lines.js.map +0 -1
- package/build/terminal-writer.d.ts +0 -69
- package/build/terminal-writer.js +0 -546
- package/build/terminal-writer.js.map +0 -1
- package/build/web/ansi-to-css.d.ts +0 -16
- package/build/web/ansi-to-css.js +0 -147
- package/build/web/ansi-to-css.js.map +0 -1
- package/build/web/client.d.ts +0 -51
- package/build/web/client.js +0 -315
- package/build/web/client.js.map +0 -1
- package/build/web/server.d.ts +0 -1
- package/build/web/server.js +0 -179
- package/build/web/server.js.map +0 -1
- package/build/worker/dump-replay.d.ts +0 -1
- package/build/worker/dump-replay.js +0 -15
- package/build/worker/dump-replay.js.map +0 -1
- package/build/worker/replay.d.ts +0 -55
- package/build/worker/replay.js +0 -133
- package/build/worker/replay.js.map +0 -1
- package/build/wrap-text.d.ts +0 -6
- package/build/wrap-text.js +0 -120
- package/build/wrap-text.js.map +0 -1
package/build/web/server.js
DELETED
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
import http from 'node:http';
|
|
2
|
-
import fs from 'node:fs/promises';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import process from 'node:process';
|
|
5
|
-
import { fileURLToPath } from 'node:url';
|
|
6
|
-
import { WebSocketServer } from 'ws';
|
|
7
|
-
import ts from 'typescript';
|
|
8
|
-
import { Deserializer } from '../serialization.js';
|
|
9
|
-
import { deserializeReplayUpdate, } from '../replay.js';
|
|
10
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
11
|
-
const __dirname = path.dirname(__filename);
|
|
12
|
-
// Cache latest state to send to new clients
|
|
13
|
-
let lastTree = null;
|
|
14
|
-
const regionStates = new Map();
|
|
15
|
-
const server = http.createServer(async (req, res) => {
|
|
16
|
-
console.log('SERVER REQ:', req.method, req.url);
|
|
17
|
-
if (req.method === 'POST' && req.url === '/update') {
|
|
18
|
-
let body = '';
|
|
19
|
-
req.on('data', (chunk) => {
|
|
20
|
-
body += chunk;
|
|
21
|
-
});
|
|
22
|
-
req.on('end', () => {
|
|
23
|
-
try {
|
|
24
|
-
const data = JSON.parse(body);
|
|
25
|
-
lastTree = data.tree;
|
|
26
|
-
// Deserialize updates
|
|
27
|
-
const parsedUpdates = data.updates.map(u => {
|
|
28
|
-
const update = deserializeReplayUpdate(u);
|
|
29
|
-
const dumpUpdate = { ...update };
|
|
30
|
-
// Sync with region state cache
|
|
31
|
-
const cached = regionStates.get(update.id) ?? { id: update.id };
|
|
32
|
-
const updateEntries = Object.entries(update);
|
|
33
|
-
for (const [key, value] of updateEntries) {
|
|
34
|
-
if (key !== 'lines' && key !== 'id' && key !== 'stickyHeaders') {
|
|
35
|
-
cached[key] = value;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
if (update.lines) {
|
|
39
|
-
const { totalLength } = update.lines;
|
|
40
|
-
const lines = cached['fullLines'] ?? [];
|
|
41
|
-
if (lines.length !== totalLength) {
|
|
42
|
-
lines.length = totalLength;
|
|
43
|
-
}
|
|
44
|
-
dumpUpdate['lines'] = {
|
|
45
|
-
totalLength,
|
|
46
|
-
updates: update.lines.updates.map((chunk) => {
|
|
47
|
-
const deserializer = new Deserializer(chunk.data);
|
|
48
|
-
const chunkLines = deserializer.deserialize();
|
|
49
|
-
for (const [i, chunkLine] of chunkLines.entries()) {
|
|
50
|
-
lines[chunk.start + i] = chunkLine;
|
|
51
|
-
}
|
|
52
|
-
return {
|
|
53
|
-
start: chunk.start,
|
|
54
|
-
end: chunk.end,
|
|
55
|
-
lines: chunkLines,
|
|
56
|
-
};
|
|
57
|
-
}),
|
|
58
|
-
};
|
|
59
|
-
cached['fullLines'] = lines;
|
|
60
|
-
cached['lines'] = {
|
|
61
|
-
totalLength,
|
|
62
|
-
updates: [{ start: 0, end: totalLength, lines }],
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
if (update.stickyHeaders) {
|
|
66
|
-
const headers = update.stickyHeaders.map((h) => ({
|
|
67
|
-
...h,
|
|
68
|
-
node: undefined,
|
|
69
|
-
anchor: undefined,
|
|
70
|
-
}));
|
|
71
|
-
dumpUpdate['stickyHeaders'] = headers;
|
|
72
|
-
cached['stickyHeaders'] = headers;
|
|
73
|
-
}
|
|
74
|
-
regionStates.set(update.id, cached);
|
|
75
|
-
return dumpUpdate;
|
|
76
|
-
});
|
|
77
|
-
const broadcastData = JSON.stringify({
|
|
78
|
-
tree: data.tree,
|
|
79
|
-
updates: parsedUpdates,
|
|
80
|
-
});
|
|
81
|
-
for (const client of wss.clients) {
|
|
82
|
-
if (client.readyState === 1 /* OPEN */) {
|
|
83
|
-
client.send(broadcastData);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
res.writeHead(200);
|
|
87
|
-
res.end('OK');
|
|
88
|
-
}
|
|
89
|
-
catch (error) {
|
|
90
|
-
console.error('Error processing update:', error);
|
|
91
|
-
res.writeHead(400);
|
|
92
|
-
res.end('Bad Request');
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
if (req.method === 'GET' && req.url === '/dump') {
|
|
98
|
-
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
99
|
-
res.end(JSON.stringify({ tree: lastTree, updates: [...regionStates.values()] }));
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
// Serve static files
|
|
103
|
-
const filePath = req.url === '/' ? '/index.html' : req.url;
|
|
104
|
-
try {
|
|
105
|
-
let fullPath = path.join(__dirname, filePath);
|
|
106
|
-
if (fullPath.endsWith('.js')) {
|
|
107
|
-
const tsPath = fullPath.replace(/\.js$/, '.ts');
|
|
108
|
-
try {
|
|
109
|
-
await fs.access(tsPath);
|
|
110
|
-
const tsSource = await fs.readFile(tsPath, 'utf8');
|
|
111
|
-
const result = ts.transpileModule(tsSource, {
|
|
112
|
-
compilerOptions: {
|
|
113
|
-
module: ts.ModuleKind.ESNext,
|
|
114
|
-
target: ts.ScriptTarget.ESNext,
|
|
115
|
-
},
|
|
116
|
-
});
|
|
117
|
-
res.writeHead(200, { 'Content-Type': 'application/javascript' });
|
|
118
|
-
res.end(result.outputText);
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
catch { }
|
|
122
|
-
}
|
|
123
|
-
try {
|
|
124
|
-
await fs.access(fullPath);
|
|
125
|
-
}
|
|
126
|
-
catch {
|
|
127
|
-
if (fullPath.includes('/src/web/')) {
|
|
128
|
-
const buildPath = fullPath.replace('/src/web/', '/build/web/');
|
|
129
|
-
try {
|
|
130
|
-
await fs.access(buildPath);
|
|
131
|
-
fullPath = buildPath;
|
|
132
|
-
}
|
|
133
|
-
catch { }
|
|
134
|
-
}
|
|
135
|
-
else if (fullPath.includes('/build/web/')) {
|
|
136
|
-
const srcPath = fullPath.replace('/build/web/', '/src/web/');
|
|
137
|
-
try {
|
|
138
|
-
await fs.access(srcPath);
|
|
139
|
-
fullPath = srcPath;
|
|
140
|
-
}
|
|
141
|
-
catch { }
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
const ext = path.extname(fullPath);
|
|
145
|
-
const content = await fs.readFile(fullPath);
|
|
146
|
-
const mimeTypes = {
|
|
147
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
148
|
-
'.html': 'text/html',
|
|
149
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
150
|
-
'.js': 'application/javascript',
|
|
151
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
152
|
-
'.css': 'text/css',
|
|
153
|
-
};
|
|
154
|
-
res.writeHead(200, { 'Content-Type': mimeTypes[ext] ?? 'text/plain' });
|
|
155
|
-
res.end(content);
|
|
156
|
-
}
|
|
157
|
-
catch {
|
|
158
|
-
console.error('File not found:', filePath);
|
|
159
|
-
res.writeHead(404);
|
|
160
|
-
res.end('Not Found');
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
const wss = new WebSocketServer({ server });
|
|
164
|
-
wss.on('connection', ws => {
|
|
165
|
-
console.log('Client connected to Web Renderer');
|
|
166
|
-
if (lastTree) {
|
|
167
|
-
ws.send(JSON.stringify({
|
|
168
|
-
tree: lastTree,
|
|
169
|
-
updates: [...regionStates.values()],
|
|
170
|
-
}));
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
const port = process.env['PORT'] ?? 3000;
|
|
174
|
-
server.listen(port, () => {
|
|
175
|
-
const address = server.address();
|
|
176
|
-
const actualPort = typeof address === 'string' ? port : address?.port ?? port;
|
|
177
|
-
console.log(`Ink Web Renderer server listening on http://localhost:${actualPort}`);
|
|
178
|
-
});
|
|
179
|
-
//# sourceMappingURL=server.js.map
|
package/build/web/server.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/web/server.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAC,aAAa,EAAC,MAAM,UAAU,CAAC;AACvC,OAAO,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CAAC,CAAC,OAAO,EAAE,IAAI,IAAI,IAAI,CAAC;IAC9E,OAAO,CAAC,GAAG,CAAC,yDAAyD,UAAU,EAAE,CAAC,CAAC;AACpF,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import process from 'node:process';
|
|
3
|
-
import { loadReplay, createHumanReadableDump } from './replay.js';
|
|
4
|
-
const filename = process.argv[2];
|
|
5
|
-
if (!filename) {
|
|
6
|
-
console.error('Usage: npx tsx dump-replay.ts <replay.json>');
|
|
7
|
-
// eslint-disable-next-line unicorn/no-process-exit
|
|
8
|
-
process.exit(1);
|
|
9
|
-
}
|
|
10
|
-
const replayData = loadReplay(fs.readFileSync(filename, 'utf8'));
|
|
11
|
-
const output = createHumanReadableDump(replayData);
|
|
12
|
-
const outFilename = filename + '.dump.txt';
|
|
13
|
-
fs.writeFileSync(outFilename, output);
|
|
14
|
-
console.log(`Successfully dumped replay to ${outFilename}`);
|
|
15
|
-
//# sourceMappingURL=dump-replay.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dump-replay.js","sourceRoot":"","sources":["../../src/worker/dump-replay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAC,UAAU,EAAE,uBAAuB,EAAC,MAAM,aAAa,CAAC;AAEhE,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACjC,IAAI,CAAC,QAAQ,EAAE,CAAC;IACf,OAAO,CAAC,KAAK,CAAC,6CAA6C,CAAC,CAAC;IAC7D,mDAAmD;IACnD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,GAAG,UAAU,CAAC,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;AACjE,MAAM,MAAM,GAAG,uBAAuB,CAAC,UAAU,CAAC,CAAC;AAEnD,MAAM,WAAW,GAAG,QAAQ,GAAG,WAAW,CAAC;AAC3C,EAAE,CAAC,aAAa,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;AACtC,OAAO,CAAC,GAAG,CAAC,iCAAiC,WAAW,EAAE,CAAC,CAAC"}
|
package/build/worker/replay.d.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { type RegionNode, type RegionUpdate } from '../output.js';
|
|
2
|
-
import { type Serializer } from '../serialization.js';
|
|
3
|
-
import { type StickyHeader } from '../dom.js';
|
|
4
|
-
export type ReplayData = {
|
|
5
|
-
type: 'single' | 'sequence';
|
|
6
|
-
columns: number;
|
|
7
|
-
rows: number;
|
|
8
|
-
frames: ReplayFrame[];
|
|
9
|
-
};
|
|
10
|
-
export type ReplayFrame = {
|
|
11
|
-
tree: RegionNode;
|
|
12
|
-
updates: ReplayRegionUpdate[];
|
|
13
|
-
cursorPosition?: {
|
|
14
|
-
row: number;
|
|
15
|
-
col: number;
|
|
16
|
-
};
|
|
17
|
-
timestamp: number;
|
|
18
|
-
};
|
|
19
|
-
export type ReplayRegionUpdate = Omit<RegionUpdate, 'lines' | 'stickyHeaders'> & {
|
|
20
|
-
lines?: {
|
|
21
|
-
updates: Array<{
|
|
22
|
-
start: number;
|
|
23
|
-
end: number;
|
|
24
|
-
data: string;
|
|
25
|
-
source?: string;
|
|
26
|
-
}>;
|
|
27
|
-
totalLength: number;
|
|
28
|
-
};
|
|
29
|
-
stickyHeaders?: ReplayStickyHeader[];
|
|
30
|
-
};
|
|
31
|
-
export type ReplayStickyHeader = Omit<StickyHeader, 'node' | 'anchor' | 'lines' | 'stuckLines' | 'styledOutput'> & {
|
|
32
|
-
lines: string;
|
|
33
|
-
stuckLines?: string;
|
|
34
|
-
styledOutput: string;
|
|
35
|
-
};
|
|
36
|
-
export declare function serializeReplayUpdate(update: RegionUpdate, serializer: Serializer): ReplayRegionUpdate;
|
|
37
|
-
export declare function deserializeReplayUpdate(update: ReplayRegionUpdate): RegionUpdate;
|
|
38
|
-
export declare function saveReplay(data: ReplayData, filename: string): void;
|
|
39
|
-
export type LoadedReplayData = {
|
|
40
|
-
type: 'single' | 'sequence';
|
|
41
|
-
columns: number;
|
|
42
|
-
rows: number;
|
|
43
|
-
frames: LoadedReplayFrame[];
|
|
44
|
-
};
|
|
45
|
-
export type LoadedReplayFrame = {
|
|
46
|
-
tree: RegionNode;
|
|
47
|
-
updates: RegionUpdate[];
|
|
48
|
-
cursorPosition?: {
|
|
49
|
-
row: number;
|
|
50
|
-
col: number;
|
|
51
|
-
};
|
|
52
|
-
timestamp: number;
|
|
53
|
-
};
|
|
54
|
-
export declare function loadReplay(jsonStr: string): LoadedReplayData;
|
|
55
|
-
export declare function createHumanReadableDump(data: LoadedReplayData): string;
|
package/build/worker/replay.js
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import { Buffer } from 'node:buffer';
|
|
3
|
-
import { Deserializer } from '../serialization.js';
|
|
4
|
-
export function serializeReplayUpdate(update, serializer) {
|
|
5
|
-
const { lines, stickyHeaders, ...rest } = update;
|
|
6
|
-
const result = {
|
|
7
|
-
...rest,
|
|
8
|
-
};
|
|
9
|
-
if (lines) {
|
|
10
|
-
result.lines = {
|
|
11
|
-
totalLength: lines.totalLength,
|
|
12
|
-
updates: lines.updates.map(u => ({
|
|
13
|
-
start: u.start,
|
|
14
|
-
end: u.end,
|
|
15
|
-
data: Buffer.from(u.data).toString('base64'),
|
|
16
|
-
source: u.source ? Buffer.from(u.source).toString('base64') : undefined,
|
|
17
|
-
})),
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
if (stickyHeaders) {
|
|
21
|
-
result.stickyHeaders = stickyHeaders.map(h => ({
|
|
22
|
-
...h,
|
|
23
|
-
node: undefined,
|
|
24
|
-
lines: Buffer.from(serializer.serialize(h.lines ?? [])).toString('base64'),
|
|
25
|
-
stuckLines: h.stuckLines
|
|
26
|
-
? Buffer.from(serializer.serialize(h.stuckLines)).toString('base64')
|
|
27
|
-
: undefined,
|
|
28
|
-
styledOutput: Buffer.from(serializer.serialize(h.styledOutput ?? [])).toString('base64'),
|
|
29
|
-
}));
|
|
30
|
-
}
|
|
31
|
-
return result;
|
|
32
|
-
}
|
|
33
|
-
export function deserializeReplayUpdate(update) {
|
|
34
|
-
const { lines, stickyHeaders, ...rest } = update;
|
|
35
|
-
const result = {
|
|
36
|
-
...rest,
|
|
37
|
-
};
|
|
38
|
-
if (lines) {
|
|
39
|
-
result.lines = {
|
|
40
|
-
totalLength: lines.totalLength,
|
|
41
|
-
updates: lines.updates.map(u => ({
|
|
42
|
-
start: u.start,
|
|
43
|
-
end: u.end,
|
|
44
|
-
data: Buffer.from(u.data, 'base64'),
|
|
45
|
-
source: u.source ? Buffer.from(u.source, 'base64') : undefined,
|
|
46
|
-
})),
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
if (stickyHeaders) {
|
|
50
|
-
result.stickyHeaders = stickyHeaders.map(h => {
|
|
51
|
-
const header = {
|
|
52
|
-
...h,
|
|
53
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
54
|
-
node: undefined,
|
|
55
|
-
lines: new Deserializer(Buffer.from(h.lines, 'base64')).deserialize(),
|
|
56
|
-
stuckLines: h.stuckLines
|
|
57
|
-
? new Deserializer(Buffer.from(h.stuckLines, 'base64')).deserialize()
|
|
58
|
-
: undefined,
|
|
59
|
-
styledOutput: new Deserializer(Buffer.from(h.styledOutput, 'base64')).deserialize(),
|
|
60
|
-
};
|
|
61
|
-
return header;
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
return result;
|
|
65
|
-
}
|
|
66
|
-
export function saveReplay(data, filename) {
|
|
67
|
-
fs.writeFileSync(filename, JSON.stringify(data, null, 2));
|
|
68
|
-
}
|
|
69
|
-
export function loadReplay(jsonStr) {
|
|
70
|
-
const raw = JSON.parse(jsonStr);
|
|
71
|
-
return {
|
|
72
|
-
...raw,
|
|
73
|
-
frames: raw.frames.map(f => ({
|
|
74
|
-
...f,
|
|
75
|
-
updates: f.updates.map(u => deserializeReplayUpdate(u)),
|
|
76
|
-
})),
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
export function createHumanReadableDump(data) {
|
|
80
|
-
const dumpData = {
|
|
81
|
-
type: data.type,
|
|
82
|
-
columns: data.columns,
|
|
83
|
-
rows: data.rows,
|
|
84
|
-
frames: data.frames.map(frame => ({
|
|
85
|
-
tree: frame.tree,
|
|
86
|
-
cursorPosition: frame.cursorPosition,
|
|
87
|
-
updates: frame.updates.map(update => {
|
|
88
|
-
const dumpUpdate = { ...update };
|
|
89
|
-
// Explicitly copy properties that could be undefined if omitted in object spread occasionally
|
|
90
|
-
dumpUpdate['overflowToBackbuffer'] = update.overflowToBackbuffer;
|
|
91
|
-
dumpUpdate['isScrollable'] = update.isScrollable;
|
|
92
|
-
if (update.lines) {
|
|
93
|
-
dumpUpdate['lines'] = {
|
|
94
|
-
totalLength: update.lines.totalLength,
|
|
95
|
-
updates: update.lines.updates.map(u => {
|
|
96
|
-
const deserializer = new Deserializer(Buffer.from(u.data));
|
|
97
|
-
const lines = deserializer.deserialize();
|
|
98
|
-
return {
|
|
99
|
-
start: u.start,
|
|
100
|
-
end: u.end,
|
|
101
|
-
text: lines.map(line => line
|
|
102
|
-
.map(c => c.value)
|
|
103
|
-
.join('')
|
|
104
|
-
.trimEnd()),
|
|
105
|
-
};
|
|
106
|
-
}),
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
if (update.stickyHeaders) {
|
|
110
|
-
dumpUpdate['stickyHeaders'] = update.stickyHeaders.map(h => ({
|
|
111
|
-
...h,
|
|
112
|
-
lines: (h.lines ?? []).map(line => line
|
|
113
|
-
.map(c => c.value)
|
|
114
|
-
.join('')
|
|
115
|
-
.trimEnd()),
|
|
116
|
-
stuckLines: h.stuckLines?.map(line => line
|
|
117
|
-
.map(c => c.value)
|
|
118
|
-
.join('')
|
|
119
|
-
.trimEnd()),
|
|
120
|
-
styledOutput: (h.styledOutput ?? []).map(line => line
|
|
121
|
-
.map(c => c.value)
|
|
122
|
-
.join('')
|
|
123
|
-
.trimEnd()),
|
|
124
|
-
node: undefined,
|
|
125
|
-
}));
|
|
126
|
-
}
|
|
127
|
-
return dumpUpdate;
|
|
128
|
-
}),
|
|
129
|
-
})),
|
|
130
|
-
};
|
|
131
|
-
return JSON.stringify(dumpData, null, 2);
|
|
132
|
-
}
|
|
133
|
-
//# sourceMappingURL=replay.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"replay.js","sourceRoot":"","sources":["../../src/worker/replay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAEnC,OAAO,EAAkB,YAAY,EAAC,MAAM,qBAAqB,CAAC;AA0ClE,MAAM,UAAU,qBAAqB,CACpC,MAAoB,EACpB,UAAsB;IAEtB,MAAM,EAAC,KAAK,EAAE,aAAa,EAAE,GAAG,IAAI,EAAC,GAAG,MAAM,CAAC;IAC/C,MAAM,MAAM,GAAuB;QAClC,GAAG,IAAI;KACP,CAAC;IAEF,IAAI,KAAK,EAAE,CAAC;QACX,MAAM,CAAC,KAAK,GAAG;YACd,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;gBAChC,KAAK,EAAE,CAAC,CAAC,KAAK;gBACd,GAAG,EAAE,CAAC,CAAC,GAAG;gBACV,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;gBAC5C,MAAM,EAAE,CAAC,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K,CAAC;6BACjB,IAAI,CAAC,EAAE,CAAC;6BACR,OAAO,EAAE,CACX;wBACD,IAAI,EAAE,SAAS;qBACf,CAAC,CAAC,CAAC;gBACL,CAAC;gBAED,OAAO,UAAU,CAAC;YACnB,CAAC,CAAC;SACF,CAAC,CAAC;KACH,CAAC;IAEF,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AAC1C,CAAC"}
|
package/build/wrap-text.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { type StyledChar } from '@alcalzone/ansi-tokenize';
|
|
2
|
-
export declare const sliceStyledChars: (styledChars: StyledChar[], begin: number, end?: number) => StyledChar[];
|
|
3
|
-
export declare const truncateStyledChars: (styledChars: StyledChar[], columns: number, options?: {
|
|
4
|
-
position?: "start" | "middle" | "end";
|
|
5
|
-
}) => StyledChar[];
|
|
6
|
-
export declare const wrapStyledChars: (styledChars: StyledChar[], columns: number) => StyledChar[][];
|
package/build/wrap-text.js
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { inkCharacterWidth, styledCharsWidth } from './measure-text.js';
|
|
2
|
-
export const sliceStyledChars = (styledChars, begin, end) => {
|
|
3
|
-
let width = 0;
|
|
4
|
-
const result = [];
|
|
5
|
-
for (const char of styledChars) {
|
|
6
|
-
const charWidth = inkCharacterWidth(char.value);
|
|
7
|
-
const charStart = width;
|
|
8
|
-
const charEnd = width + charWidth;
|
|
9
|
-
if (end !== undefined && charEnd > end) {
|
|
10
|
-
break;
|
|
11
|
-
}
|
|
12
|
-
if (charStart >= begin) {
|
|
13
|
-
result.push(char);
|
|
14
|
-
}
|
|
15
|
-
width += charWidth;
|
|
16
|
-
}
|
|
17
|
-
return result;
|
|
18
|
-
};
|
|
19
|
-
export const truncateStyledChars = (styledChars, columns, options = {}) => {
|
|
20
|
-
const { position = 'end' } = options;
|
|
21
|
-
const truncationCharacter = '…';
|
|
22
|
-
const truncationStyledChar = {
|
|
23
|
-
type: 'char',
|
|
24
|
-
value: truncationCharacter,
|
|
25
|
-
fullWidth: false,
|
|
26
|
-
styles: [],
|
|
27
|
-
};
|
|
28
|
-
if (columns < 1) {
|
|
29
|
-
return [];
|
|
30
|
-
}
|
|
31
|
-
if (columns === 1) {
|
|
32
|
-
return [truncationStyledChar];
|
|
33
|
-
}
|
|
34
|
-
const textWidth = styledCharsWidth(styledChars);
|
|
35
|
-
if (textWidth <= columns) {
|
|
36
|
-
return styledChars;
|
|
37
|
-
}
|
|
38
|
-
const truncationWidth = inkCharacterWidth(truncationCharacter);
|
|
39
|
-
if (position === 'start') {
|
|
40
|
-
const right = sliceStyledChars(styledChars, textWidth - columns + truncationWidth, textWidth);
|
|
41
|
-
return [truncationStyledChar, ...right];
|
|
42
|
-
}
|
|
43
|
-
if (position === 'middle') {
|
|
44
|
-
const leftWidth = Math.ceil(columns / 2);
|
|
45
|
-
const rightWidth = columns - leftWidth;
|
|
46
|
-
const left = sliceStyledChars(styledChars, 0, leftWidth - truncationWidth);
|
|
47
|
-
const right = sliceStyledChars(styledChars, textWidth - rightWidth, textWidth);
|
|
48
|
-
return [...left, truncationStyledChar, ...right];
|
|
49
|
-
}
|
|
50
|
-
const left = sliceStyledChars(styledChars, 0, columns - truncationWidth);
|
|
51
|
-
return [...left, truncationStyledChar];
|
|
52
|
-
};
|
|
53
|
-
const wrapWord = (rows, word, columns) => {
|
|
54
|
-
let currentLine = rows.at(-1);
|
|
55
|
-
let visible = styledCharsWidth(currentLine);
|
|
56
|
-
for (const character of word) {
|
|
57
|
-
const characterLength = inkCharacterWidth(character.value);
|
|
58
|
-
if (visible + characterLength > columns && visible > 0) {
|
|
59
|
-
rows.push([]);
|
|
60
|
-
currentLine = rows.at(-1);
|
|
61
|
-
visible = 0;
|
|
62
|
-
}
|
|
63
|
-
currentLine.push(character);
|
|
64
|
-
visible += characterLength;
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
export const wrapStyledChars = (styledChars, columns) => {
|
|
68
|
-
const rows = [[]];
|
|
69
|
-
const words = [];
|
|
70
|
-
let currentWord = [];
|
|
71
|
-
for (const char of styledChars) {
|
|
72
|
-
if (char.value === ' ') {
|
|
73
|
-
if (currentWord.length > 0) {
|
|
74
|
-
words.push(currentWord);
|
|
75
|
-
}
|
|
76
|
-
currentWord = [];
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
currentWord.push(char);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
if (currentWord.length > 0) {
|
|
83
|
-
words.push(currentWord);
|
|
84
|
-
}
|
|
85
|
-
const space = {
|
|
86
|
-
type: 'char',
|
|
87
|
-
value: ' ',
|
|
88
|
-
fullWidth: false,
|
|
89
|
-
styles: [],
|
|
90
|
-
};
|
|
91
|
-
for (const [index, word] of words.entries()) {
|
|
92
|
-
const wordWidth = styledCharsWidth(word);
|
|
93
|
-
let rowWidth = styledCharsWidth(rows.at(-1));
|
|
94
|
-
if (index > 0) {
|
|
95
|
-
rows.at(-1).push(space);
|
|
96
|
-
rowWidth++;
|
|
97
|
-
}
|
|
98
|
-
if (wordWidth > columns) {
|
|
99
|
-
if (index > 0) {
|
|
100
|
-
rows[rows.length - 1] = rows.at(-1).slice(0, -1);
|
|
101
|
-
if (rows.at(-1).length > 0) {
|
|
102
|
-
rows.push([]);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
wrapWord(rows, word, columns);
|
|
106
|
-
continue;
|
|
107
|
-
}
|
|
108
|
-
if (rowWidth + wordWidth > columns && rowWidth > 0) {
|
|
109
|
-
if (index > 0) {
|
|
110
|
-
rows[rows.length - 1] = rows.at(-1).slice(0, -1);
|
|
111
|
-
}
|
|
112
|
-
rows.push(word);
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
rows.at(-1).push(...word);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
return rows;
|
|
119
|
-
};
|
|
120
|
-
//# sourceMappingURL=wrap-text.js.map
|
package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