@mytechtoday/augment-extensions 0.5.0 → 0.7.0
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/cli/dist/cli.js +4 -0
- package/cli/dist/cli.js.map +1 -1
- package/cli/dist/commands/show.d.ts +4 -0
- package/cli/dist/commands/show.d.ts.map +1 -1
- package/cli/dist/commands/show.js +456 -23
- package/cli/dist/commands/show.js.map +1 -1
- package/cli/dist/utils/config-system.d.ts +111 -0
- package/cli/dist/utils/config-system.d.ts.map +1 -0
- package/cli/dist/utils/config-system.js +239 -0
- package/cli/dist/utils/config-system.js.map +1 -0
- package/cli/dist/utils/hook-system.d.ts +84 -0
- package/cli/dist/utils/hook-system.d.ts.map +1 -0
- package/cli/dist/utils/hook-system.js +151 -0
- package/cli/dist/utils/hook-system.js.map +1 -0
- package/cli/dist/utils/inspection-cache.d.ts +56 -0
- package/cli/dist/utils/inspection-cache.d.ts.map +1 -0
- package/cli/dist/utils/inspection-cache.js +166 -0
- package/cli/dist/utils/inspection-cache.js.map +1 -0
- package/cli/dist/utils/inspection-handlers.d.ts +75 -0
- package/cli/dist/utils/inspection-handlers.d.ts.map +1 -0
- package/cli/dist/utils/inspection-handlers.js +171 -0
- package/cli/dist/utils/inspection-handlers.js.map +1 -0
- package/cli/dist/utils/module-system.d.ts +1 -0
- package/cli/dist/utils/module-system.d.ts.map +1 -1
- package/cli/dist/utils/module-system.js +8 -3
- package/cli/dist/utils/module-system.js.map +1 -1
- package/cli/dist/utils/plugin-system.d.ts +133 -0
- package/cli/dist/utils/plugin-system.d.ts.map +1 -0
- package/cli/dist/utils/plugin-system.js +210 -0
- package/cli/dist/utils/plugin-system.js.map +1 -0
- package/cli/dist/utils/progress.d.ts +67 -0
- package/cli/dist/utils/progress.d.ts.map +1 -0
- package/cli/dist/utils/progress.js +146 -0
- package/cli/dist/utils/progress.js.map +1 -0
- package/cli/dist/utils/stream-reader.d.ts +34 -0
- package/cli/dist/utils/stream-reader.d.ts.map +1 -0
- package/cli/dist/utils/stream-reader.js +147 -0
- package/cli/dist/utils/stream-reader.js.map +1 -0
- package/cli/dist/utils/vscode-editor.d.ts +45 -0
- package/cli/dist/utils/vscode-editor.d.ts.map +1 -0
- package/cli/dist/utils/vscode-editor.js +171 -0
- package/cli/dist/utils/vscode-editor.js.map +1 -0
- package/cli/dist/utils/vscode-links.d.ts +49 -0
- package/cli/dist/utils/vscode-links.d.ts.map +1 -0
- package/cli/dist/utils/vscode-links.js +167 -0
- package/cli/dist/utils/vscode-links.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Progress Indicator Utility
|
|
4
|
+
*
|
|
5
|
+
* Provides progress bars and spinners for long-running operations.
|
|
6
|
+
* Supports cancellation with Ctrl+C.
|
|
7
|
+
*/
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Spinner = exports.ProgressBar = void 0;
|
|
13
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
14
|
+
class ProgressBar {
|
|
15
|
+
constructor(options = {}) {
|
|
16
|
+
this.current = 0;
|
|
17
|
+
this.lastRender = '';
|
|
18
|
+
this.total = options.total || 100;
|
|
19
|
+
this.width = options.width || 40;
|
|
20
|
+
this.format = options.format || ':bar :percent :current/:total :eta';
|
|
21
|
+
this.clear = options.clear !== false;
|
|
22
|
+
this.startTime = Date.now();
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Update progress
|
|
26
|
+
*/
|
|
27
|
+
update(current, tokens) {
|
|
28
|
+
this.current = current;
|
|
29
|
+
this.render(tokens);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Increment progress
|
|
33
|
+
*/
|
|
34
|
+
tick(delta = 1, tokens) {
|
|
35
|
+
this.current += delta;
|
|
36
|
+
this.render(tokens);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Render progress bar
|
|
40
|
+
*/
|
|
41
|
+
render(tokens) {
|
|
42
|
+
const percent = Math.min(100, Math.max(0, (this.current / this.total) * 100));
|
|
43
|
+
const complete = Math.round((this.width * percent) / 100);
|
|
44
|
+
const incomplete = this.width - complete;
|
|
45
|
+
const elapsed = Date.now() - this.startTime;
|
|
46
|
+
const rate = this.current / (elapsed / 1000);
|
|
47
|
+
const eta = this.current === 0 ? 0 : (this.total - this.current) / rate;
|
|
48
|
+
const bar = chalk_1.default.green('█'.repeat(complete)) + chalk_1.default.gray('░'.repeat(incomplete));
|
|
49
|
+
let output = this.format
|
|
50
|
+
.replace(':bar', bar)
|
|
51
|
+
.replace(':percent', `${percent.toFixed(1)}%`)
|
|
52
|
+
.replace(':current', String(this.current))
|
|
53
|
+
.replace(':total', String(this.total))
|
|
54
|
+
.replace(':eta', this.formatTime(eta))
|
|
55
|
+
.replace(':elapsed', this.formatTime(elapsed / 1000));
|
|
56
|
+
// Replace custom tokens
|
|
57
|
+
if (tokens) {
|
|
58
|
+
for (const [key, value] of Object.entries(tokens)) {
|
|
59
|
+
output = output.replace(`:${key}`, String(value));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// Clear previous line and write new one
|
|
63
|
+
if (this.lastRender) {
|
|
64
|
+
process.stderr.write('\r' + ' '.repeat(this.lastRender.length) + '\r');
|
|
65
|
+
}
|
|
66
|
+
process.stderr.write(output);
|
|
67
|
+
this.lastRender = output;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Complete progress bar
|
|
71
|
+
*/
|
|
72
|
+
complete() {
|
|
73
|
+
this.current = this.total;
|
|
74
|
+
this.render();
|
|
75
|
+
if (this.clear) {
|
|
76
|
+
process.stderr.write('\n');
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Format time in seconds to human-readable string
|
|
81
|
+
*/
|
|
82
|
+
formatTime(seconds) {
|
|
83
|
+
if (!isFinite(seconds) || seconds < 0) {
|
|
84
|
+
return '--:--';
|
|
85
|
+
}
|
|
86
|
+
const mins = Math.floor(seconds / 60);
|
|
87
|
+
const secs = Math.floor(seconds % 60);
|
|
88
|
+
return `${mins}:${secs.toString().padStart(2, '0')}`;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
exports.ProgressBar = ProgressBar;
|
|
92
|
+
class Spinner {
|
|
93
|
+
constructor(text = 'Processing...') {
|
|
94
|
+
this.frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
|
95
|
+
this.currentFrame = 0;
|
|
96
|
+
this.interval = null;
|
|
97
|
+
this.lastRender = '';
|
|
98
|
+
this.text = text;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Start spinner
|
|
102
|
+
*/
|
|
103
|
+
start() {
|
|
104
|
+
this.interval = setInterval(() => {
|
|
105
|
+
this.render();
|
|
106
|
+
this.currentFrame = (this.currentFrame + 1) % this.frames.length;
|
|
107
|
+
}, 80);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Update spinner text
|
|
111
|
+
*/
|
|
112
|
+
setText(text) {
|
|
113
|
+
this.text = text;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Render spinner
|
|
117
|
+
*/
|
|
118
|
+
render() {
|
|
119
|
+
const frame = this.frames[this.currentFrame];
|
|
120
|
+
const output = `${chalk_1.default.cyan(frame)} ${this.text}`;
|
|
121
|
+
// Clear previous line and write new one
|
|
122
|
+
if (this.lastRender) {
|
|
123
|
+
process.stderr.write('\r' + ' '.repeat(this.lastRender.length) + '\r');
|
|
124
|
+
}
|
|
125
|
+
process.stderr.write(output);
|
|
126
|
+
this.lastRender = output;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Stop spinner
|
|
130
|
+
*/
|
|
131
|
+
stop(finalText) {
|
|
132
|
+
if (this.interval) {
|
|
133
|
+
clearInterval(this.interval);
|
|
134
|
+
this.interval = null;
|
|
135
|
+
}
|
|
136
|
+
// Clear spinner line
|
|
137
|
+
if (this.lastRender) {
|
|
138
|
+
process.stderr.write('\r' + ' '.repeat(this.lastRender.length) + '\r');
|
|
139
|
+
}
|
|
140
|
+
if (finalText) {
|
|
141
|
+
process.stderr.write(finalText + '\n');
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
exports.Spinner = Spinner;
|
|
146
|
+
//# sourceMappingURL=progress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.js","sourceRoot":"","sources":["../../src/utils/progress.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;AAEH,kDAA0B;AAS1B,MAAa,WAAW;IAStB,YAAY,UAA2B,EAAE;QARjC,YAAO,GAAW,CAAC,CAAC;QAMpB,eAAU,GAAW,EAAE,CAAC;QAG9B,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,GAAG,CAAC;QAClC,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC;QACjC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,oCAAoC,CAAC;QACrE,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,KAAK,KAAK,CAAC;QACrC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,OAAe,EAAE,MAA4B;QAClD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,IAAI,CAAC,QAAgB,CAAC,EAAE,MAA4B;QAClD,IAAI,CAAC,OAAO,IAAI,KAAK,CAAC;QACtB,IAA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MAAM,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;QACzE,CAAC;QACD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,IAAI,CAAC,SAAkB;QACrB,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC7B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACvB,CAAC;QAED,qBAAqB;QACrB,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;QACzE,CAAC;QAED,IAAI,SAAS,EAAE,CAAC;YACd,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;CACF;AA7DD,0BA6DC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stream Reader Utility
|
|
3
|
+
*
|
|
4
|
+
* Provides streaming file reading for large files to reduce memory usage.
|
|
5
|
+
* Supports chunked content processing and memory-efficient operations.
|
|
6
|
+
*/
|
|
7
|
+
export interface StreamOptions {
|
|
8
|
+
chunkSize?: number;
|
|
9
|
+
encoding?: BufferEncoding;
|
|
10
|
+
highWaterMark?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface StreamStats {
|
|
13
|
+
bytesRead: number;
|
|
14
|
+
linesRead: number;
|
|
15
|
+
chunksProcessed: number;
|
|
16
|
+
memoryUsed: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Read file in chunks using streams
|
|
20
|
+
*/
|
|
21
|
+
export declare function readFileStreaming(filePath: string, onChunk: (chunk: string, stats: StreamStats) => void | Promise<void>, options?: StreamOptions): Promise<StreamStats>;
|
|
22
|
+
/**
|
|
23
|
+
* Read file line by line using streams
|
|
24
|
+
*/
|
|
25
|
+
export declare function readFileLineByLine(filePath: string, onLine: (line: string, lineNumber: number, stats: StreamStats) => void | Promise<void>, options?: StreamOptions): Promise<StreamStats>;
|
|
26
|
+
/**
|
|
27
|
+
* Read file with pagination support (memory-efficient)
|
|
28
|
+
*/
|
|
29
|
+
export declare function readFilePaginated(filePath: string, page?: number, pageSize?: number, options?: StreamOptions): Promise<{
|
|
30
|
+
lines: string[];
|
|
31
|
+
totalLines: number;
|
|
32
|
+
hasMore: boolean;
|
|
33
|
+
}>;
|
|
34
|
+
//# sourceMappingURL=stream-reader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream-reader.d.ts","sourceRoot":"","sources":["../../src/utils/stream-reader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,MAAM,WAAW,aAAa;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EACpE,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,WAAW,CAAC,CAyCtB;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EACtF,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,WAAW,CAAC,CA+CtB;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,MAAM,EAChB,IAAI,GAAE,MAAU,EAChB,QAAQ,GAAE,MAAY,EACtB,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAsBpE"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Stream Reader Utility
|
|
4
|
+
*
|
|
5
|
+
* Provides streaming file reading for large files to reduce memory usage.
|
|
6
|
+
* Supports chunked content processing and memory-efficient operations.
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
+
}) : function(o, v) {
|
|
22
|
+
o["default"] = v;
|
|
23
|
+
});
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.readFileStreaming = readFileStreaming;
|
|
43
|
+
exports.readFileLineByLine = readFileLineByLine;
|
|
44
|
+
exports.readFilePaginated = readFilePaginated;
|
|
45
|
+
const fs = __importStar(require("fs"));
|
|
46
|
+
const readline = __importStar(require("readline"));
|
|
47
|
+
/**
|
|
48
|
+
* Read file in chunks using streams
|
|
49
|
+
*/
|
|
50
|
+
async function readFileStreaming(filePath, onChunk, options = {}) {
|
|
51
|
+
const { encoding = 'utf-8', highWaterMark = 64 * 1024 // 64KB default
|
|
52
|
+
} = options;
|
|
53
|
+
const stats = {
|
|
54
|
+
bytesRead: 0,
|
|
55
|
+
linesRead: 0,
|
|
56
|
+
chunksProcessed: 0,
|
|
57
|
+
memoryUsed: 0
|
|
58
|
+
};
|
|
59
|
+
return new Promise((resolve, reject) => {
|
|
60
|
+
const stream = fs.createReadStream(filePath, {
|
|
61
|
+
encoding,
|
|
62
|
+
highWaterMark
|
|
63
|
+
});
|
|
64
|
+
stream.on('data', async (chunk) => {
|
|
65
|
+
const chunkStr = typeof chunk === 'string' ? chunk : chunk.toString(encoding);
|
|
66
|
+
stats.bytesRead += Buffer.byteLength(chunkStr, encoding);
|
|
67
|
+
stats.chunksProcessed++;
|
|
68
|
+
stats.memoryUsed = process.memoryUsage().heapUsed;
|
|
69
|
+
try {
|
|
70
|
+
await onChunk(chunkStr, stats);
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
stream.destroy();
|
|
74
|
+
reject(error);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
stream.on('end', () => {
|
|
78
|
+
resolve(stats);
|
|
79
|
+
});
|
|
80
|
+
stream.on('error', (error) => {
|
|
81
|
+
reject(error);
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Read file line by line using streams
|
|
87
|
+
*/
|
|
88
|
+
async function readFileLineByLine(filePath, onLine, options = {}) {
|
|
89
|
+
const { encoding = 'utf-8', highWaterMark = 64 * 1024 } = options;
|
|
90
|
+
const stats = {
|
|
91
|
+
bytesRead: 0,
|
|
92
|
+
linesRead: 0,
|
|
93
|
+
chunksProcessed: 0,
|
|
94
|
+
memoryUsed: 0
|
|
95
|
+
};
|
|
96
|
+
return new Promise((resolve, reject) => {
|
|
97
|
+
const stream = fs.createReadStream(filePath, {
|
|
98
|
+
encoding,
|
|
99
|
+
highWaterMark
|
|
100
|
+
});
|
|
101
|
+
const rl = readline.createInterface({
|
|
102
|
+
input: stream,
|
|
103
|
+
crlfDelay: Infinity
|
|
104
|
+
});
|
|
105
|
+
rl.on('line', async (line) => {
|
|
106
|
+
stats.linesRead++;
|
|
107
|
+
stats.bytesRead += Buffer.byteLength(line + '\n', encoding);
|
|
108
|
+
stats.memoryUsed = process.memoryUsage().heapUsed;
|
|
109
|
+
try {
|
|
110
|
+
await onLine(line, stats.linesRead, stats);
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
rl.close();
|
|
114
|
+
stream.destroy();
|
|
115
|
+
reject(error);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
rl.on('close', () => {
|
|
119
|
+
resolve(stats);
|
|
120
|
+
});
|
|
121
|
+
stream.on('error', (error) => {
|
|
122
|
+
rl.close();
|
|
123
|
+
reject(error);
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Read file with pagination support (memory-efficient)
|
|
129
|
+
*/
|
|
130
|
+
async function readFilePaginated(filePath, page = 1, pageSize = 100, options = {}) {
|
|
131
|
+
const startLine = (page - 1) * pageSize;
|
|
132
|
+
const endLine = startLine + pageSize;
|
|
133
|
+
const lines = [];
|
|
134
|
+
let totalLines = 0;
|
|
135
|
+
await readFileLineByLine(filePath, async (line, lineNumber) => {
|
|
136
|
+
totalLines = lineNumber;
|
|
137
|
+
if (lineNumber > startLine && lineNumber <= endLine) {
|
|
138
|
+
lines.push(line);
|
|
139
|
+
}
|
|
140
|
+
}, options);
|
|
141
|
+
return {
|
|
142
|
+
lines,
|
|
143
|
+
totalLines,
|
|
144
|
+
hasMore: totalLines > endLine
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=stream-reader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream-reader.js","sourceRoot":"","sources":["../../src/utils/stream-reader.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBH,8CA6CC;AAKD,gDAmDC;AAKD,8CA2BC;AAxJD,uCAAyB;AACzB,mDAAqC;AAerC;;GAEG;AACI,KAAK,UAAU,iBAAiB,CACrC,QAAgB,EAChB,OAAoE,EACpE,UAAyB,EAAE;IAE3B,MAAM,EACJ,QAAQ,GAAG,OAAO,EAClB,aAAa,GAAG,EAAE,GAAG,IAAI,CAAC,eAAe;MAC1C,GAAG,OAAO,CAAC;IAEZ,MAAM,KAAK,GAAgB;QACzB,SAAS,EAAE,CAAC;QACZ,SAAS,EAAE,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AAE,CAAC,KAAK,EAAE,EAAE;YAC3B,EAAE,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,CAAC,KAAK,CAAC,CAAC;QAChB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,iBAAiB,CACrC,QAAgB,EAChB,OAAe,CAAC,EAChB,WAAmB,GAAG,EACtB,UAAyB,EAAE;IAE3B,MAAM,SAAS,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC;IACxC,MAAM,OAAO,GAAG,SAAS,GAAG,QAAQ,CAAC;IACrC,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,UAAU,GAAG,CAAC,CAAC;IAEnB,MAAM,kBAAkB,CACtB,QAAQ,EACR,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE;QACzB,UAAU,GAAG,UAAU,CAAC;QACxB,IAAI,UAAU,GAAG,SAAS,IAAI,UAAU,IAAI,OAAO,EAAE,CAAC;YACpD,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnB,CAAC;IACH,CAAC,EACD,OAAO,CACR,CAAC;IAEF,OAAO;QACL,KAAK;QACL,UAAU;QACV,OAAO,EAAE,UAAU,GAAG,OAAO;KAC9B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VS Code Editor Integration Utility
|
|
3
|
+
*
|
|
4
|
+
* Provides utilities for opening files in VS Code editor.
|
|
5
|
+
* Supports opening files with line numbers and preview mode.
|
|
6
|
+
*/
|
|
7
|
+
export interface EditorOptions {
|
|
8
|
+
line?: number;
|
|
9
|
+
column?: number;
|
|
10
|
+
preview?: boolean;
|
|
11
|
+
reuse?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Check if VS Code CLI is available
|
|
15
|
+
*/
|
|
16
|
+
export declare function isVSCodeAvailable(): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Open a file in VS Code editor
|
|
19
|
+
*/
|
|
20
|
+
export declare function openInVSCode(filePath: string, options?: EditorOptions): Promise<boolean>;
|
|
21
|
+
/**
|
|
22
|
+
* Open a file in VS Code preview pane
|
|
23
|
+
*/
|
|
24
|
+
export declare function openInPreview(filePath: string, options?: Omit<EditorOptions, 'preview'>): Promise<boolean>;
|
|
25
|
+
/**
|
|
26
|
+
* Open a file in VS Code editor (full tab)
|
|
27
|
+
*/
|
|
28
|
+
export declare function openInEditor(filePath: string, options?: Omit<EditorOptions, 'preview'>): Promise<boolean>;
|
|
29
|
+
/**
|
|
30
|
+
* Focus VS Code window
|
|
31
|
+
*/
|
|
32
|
+
export declare function focusVSCode(): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Get VS Code version
|
|
35
|
+
*/
|
|
36
|
+
export declare function getVSCodeVersion(): string | null;
|
|
37
|
+
/**
|
|
38
|
+
* Check if running inside VS Code integrated terminal
|
|
39
|
+
*/
|
|
40
|
+
export declare function isVSCodeTerminal(): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Get current workspace folder from VS Code environment
|
|
43
|
+
*/
|
|
44
|
+
export declare function getVSCodeWorkspace(): string | undefined;
|
|
45
|
+
//# sourceMappingURL=vscode-editor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vscode-editor.d.ts","sourceRoot":"","sources":["../../src/utils/vscode-editor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAO3C;AAED;;GAEG;AACH,wBAAsB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,OAAO,CAAC,CAgDlG;AAED;;GAEG;AACH,wBAAsB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,IAAI,CAAC,aAAa,EAAE,SAAS,CAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAEpH;AAED;;GAEG;AACH,wBAAsB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,IAAI,CAAC,aAAa,EAAE,SAAS,CAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAEnH;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,OAAO,CAcrC;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,GAAG,IAAI,CAehD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,OAAO,CAE1C;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,GAAG,SAAS,CAEvD"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* VS Code Editor Integration Utility
|
|
4
|
+
*
|
|
5
|
+
* Provides utilities for opening files in VS Code editor.
|
|
6
|
+
* Supports opening files with line numbers and preview mode.
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
+
}) : function(o, v) {
|
|
22
|
+
o["default"] = v;
|
|
23
|
+
});
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.isVSCodeAvailable = isVSCodeAvailable;
|
|
43
|
+
exports.openInVSCode = openInVSCode;
|
|
44
|
+
exports.openInPreview = openInPreview;
|
|
45
|
+
exports.openInEditor = openInEditor;
|
|
46
|
+
exports.focusVSCode = focusVSCode;
|
|
47
|
+
exports.getVSCodeVersion = getVSCodeVersion;
|
|
48
|
+
exports.isVSCodeTerminal = isVSCodeTerminal;
|
|
49
|
+
exports.getVSCodeWorkspace = getVSCodeWorkspace;
|
|
50
|
+
const child_process = __importStar(require("child_process"));
|
|
51
|
+
const path = __importStar(require("path"));
|
|
52
|
+
const fs = __importStar(require("fs"));
|
|
53
|
+
/**
|
|
54
|
+
* Check if VS Code CLI is available
|
|
55
|
+
*/
|
|
56
|
+
function isVSCodeAvailable() {
|
|
57
|
+
try {
|
|
58
|
+
child_process.execSync('code --version', { stdio: 'ignore' });
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Open a file in VS Code editor
|
|
67
|
+
*/
|
|
68
|
+
async function openInVSCode(filePath, options = {}) {
|
|
69
|
+
const { line, column, preview = false, reuse = true } = options;
|
|
70
|
+
if (!isVSCodeAvailable()) {
|
|
71
|
+
throw new Error('VS Code CLI (code) is not available. Please install VS Code and ensure "code" is in your PATH.');
|
|
72
|
+
}
|
|
73
|
+
// Resolve to absolute path
|
|
74
|
+
const absPath = path.isAbsolute(filePath) ? filePath : path.resolve(filePath);
|
|
75
|
+
// Check if file exists
|
|
76
|
+
if (!fs.existsSync(absPath)) {
|
|
77
|
+
throw new Error(`File not found: ${absPath}`);
|
|
78
|
+
}
|
|
79
|
+
// Build command arguments
|
|
80
|
+
const args = [];
|
|
81
|
+
// Reuse window flag
|
|
82
|
+
if (reuse) {
|
|
83
|
+
args.push('-r');
|
|
84
|
+
}
|
|
85
|
+
// Add file path with line/column
|
|
86
|
+
let fileArg = absPath;
|
|
87
|
+
if (line !== undefined) {
|
|
88
|
+
fileArg += `:${line}`;
|
|
89
|
+
if (column !== undefined) {
|
|
90
|
+
fileArg += `:${column}`;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
args.push(fileArg);
|
|
94
|
+
// Preview mode (open in preview tab)
|
|
95
|
+
if (preview) {
|
|
96
|
+
args.push('--preview');
|
|
97
|
+
}
|
|
98
|
+
try {
|
|
99
|
+
// Execute VS Code command
|
|
100
|
+
child_process.execSync(`code ${args.join(' ')}`, {
|
|
101
|
+
stdio: 'ignore',
|
|
102
|
+
windowsHide: true
|
|
103
|
+
});
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
throw new Error(`Failed to open file in VS Code: ${error instanceof Error ? error.message : String(error)}`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Open a file in VS Code preview pane
|
|
112
|
+
*/
|
|
113
|
+
async function openInPreview(filePath, options = {}) {
|
|
114
|
+
return openInVSCode(filePath, { ...options, preview: true });
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Open a file in VS Code editor (full tab)
|
|
118
|
+
*/
|
|
119
|
+
async function openInEditor(filePath, options = {}) {
|
|
120
|
+
return openInVSCode(filePath, { ...options, preview: false });
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Focus VS Code window
|
|
124
|
+
*/
|
|
125
|
+
function focusVSCode() {
|
|
126
|
+
if (!isVSCodeAvailable()) {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
try {
|
|
130
|
+
child_process.execSync('code -r', {
|
|
131
|
+
stdio: 'ignore',
|
|
132
|
+
windowsHide: true
|
|
133
|
+
});
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
catch (error) {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Get VS Code version
|
|
142
|
+
*/
|
|
143
|
+
function getVSCodeVersion() {
|
|
144
|
+
if (!isVSCodeAvailable()) {
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
try {
|
|
148
|
+
const output = child_process.execSync('code --version', {
|
|
149
|
+
encoding: 'utf-8',
|
|
150
|
+
windowsHide: true
|
|
151
|
+
});
|
|
152
|
+
const lines = output.trim().split('\n');
|
|
153
|
+
return lines[0] || null;
|
|
154
|
+
}
|
|
155
|
+
catch (error) {
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Check if running inside VS Code integrated terminal
|
|
161
|
+
*/
|
|
162
|
+
function isVSCodeTerminal() {
|
|
163
|
+
return process.env.TERM_PROGRAM === 'vscode' || process.env.VSCODE_PID !== undefined;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Get current workspace folder from VS Code environment
|
|
167
|
+
*/
|
|
168
|
+
function getVSCodeWorkspace() {
|
|
169
|
+
return process.env.VSCODE_WORKSPACE_FOLDER;
|
|
170
|
+
}
|
|
171
|
+
//# sourceMappingURL=vscode-editor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vscode-editor.js","sourceRoot":"","sources":["../../src/utils/vscode-editor.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBH,8CAOC;AAKD,oCAgDC;AAKD,sCAEC;AAKD,oCAEC;AAKD,kCAcC;AAKD,4CAeC;AAKD,4CAEC;AAKD,gDAEC;AA7ID,6DAA+C;AAC/C,2CAA6B;AAC7B,uCAAyB;AASzB;;GAEG;AACH,SAAgB,iBAAiB;IAC/B,IAAI,CAAC;QACH,aAAa,CAAC,QAAQ,CAAC,gBAAgB,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC9D,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,YAAY,CAAC,QAAgB,EAAE,UAAyB,EAAE;IAC9E,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,GAAG,KAAK,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IAEhE,IAAI,CAAC,iBAAiB,EAAE,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,gGAAgG,CAAC,CAAC;IACpH,CAAC;IAED,2BAA2B;IAC3B,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAE9E,uBAAuB;IACvB,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5B,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;AAC7C,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VS Code Terminal Links Utility
|
|
3
|
+
*
|
|
4
|
+
* Provides utilities for creating clickable file links in VS Code terminal.
|
|
5
|
+
* Supports file paths with line numbers and column numbers.
|
|
6
|
+
*/
|
|
7
|
+
export interface LinkOptions {
|
|
8
|
+
line?: number;
|
|
9
|
+
column?: number;
|
|
10
|
+
absolute?: boolean;
|
|
11
|
+
workspaceRoot?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Format a file path as a clickable VS Code terminal link
|
|
15
|
+
*
|
|
16
|
+
* VS Code recognizes these formats:
|
|
17
|
+
* - file:///absolute/path/to/file.ts
|
|
18
|
+
* - file:///absolute/path/to/file.ts:10
|
|
19
|
+
* - file:///absolute/path/to/file.ts:10:5
|
|
20
|
+
* - ./relative/path/to/file.ts
|
|
21
|
+
* - ./relative/path/to/file.ts:10
|
|
22
|
+
* - ./relative/path/to/file.ts:10:5
|
|
23
|
+
*/
|
|
24
|
+
export declare function formatVSCodeLink(filePath: string, options?: LinkOptions): string;
|
|
25
|
+
/**
|
|
26
|
+
* Format a file path as a file:// URI for VS Code
|
|
27
|
+
*/
|
|
28
|
+
export declare function formatFileUri(filePath: string, options?: LinkOptions): string;
|
|
29
|
+
/**
|
|
30
|
+
* Create a clickable link with custom text
|
|
31
|
+
*/
|
|
32
|
+
export declare function createClickableLink(filePath: string, displayText?: string, options?: LinkOptions): string;
|
|
33
|
+
/**
|
|
34
|
+
* Format a file path with line number for display
|
|
35
|
+
*/
|
|
36
|
+
export declare function formatFilePathWithLine(filePath: string, line?: number, column?: number): string;
|
|
37
|
+
/**
|
|
38
|
+
* Check if running in VS Code terminal
|
|
39
|
+
*/
|
|
40
|
+
export declare function isVSCodeTerminal(): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Get workspace root from environment
|
|
43
|
+
*/
|
|
44
|
+
export declare function getWorkspaceRoot(): string | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Format a file path as a clickable link (auto-detects VS Code)
|
|
47
|
+
*/
|
|
48
|
+
export declare function formatClickablePath(filePath: string, options?: LinkOptions): string;
|
|
49
|
+
//# sourceMappingURL=vscode-links.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vscode-links.d.ts","sourceRoot":"","sources":["../../src/utils/vscode-links.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,MAAM,CA8BpF;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,MAAM,CAkBjF;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,MAAM,CAQ7G;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAW/F;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,OAAO,CAE1C;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,GAAG,SAAS,CAgBrD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,MAAM,CAMvF"}
|