@tsrx/content-mapper 0.1.0 → 0.1.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/README.md +23 -9
- package/dist/mapper-DATqGboo.js +3098 -0
- package/dist/mapper-DATqGboo.js.map +1 -0
- package/dist/mapper.js +3 -0
- package/dist/protocol.js +116 -0
- package/dist/protocol.js.map +1 -0
- package/dist/rpc.js +128 -0
- package/dist/rpc.js.map +1 -0
- package/dist/server.js +2 -3315
- package/dist/server.js.map +1 -1
- package/package.json +7 -7
- package/src/export-stub.js +20 -4
package/dist/protocol.js
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
//#region src/protocol.js
|
|
2
|
+
/**
|
|
3
|
+
* Constants of the TypeScript 7 content-mapper protocol, kept in sync with
|
|
4
|
+
* `tsc/internal/contentmapper` and `tsc/internal/spanmap` in microsoft/TypeScript.
|
|
5
|
+
*/
|
|
6
|
+
/** Span kinds. */
|
|
7
|
+
const SpanMapKind = {
|
|
8
|
+
/** Same length and identical text; the only kind that supports text edits. */
|
|
9
|
+
Verbatim: 0,
|
|
10
|
+
/** Same entity, different text or length. */
|
|
11
|
+
Atom: 1,
|
|
12
|
+
/** Different text; diagnostics covering the whole span exactly show the original text. */
|
|
13
|
+
Alias: 2
|
|
14
|
+
};
|
|
15
|
+
/** Feature bits a span opts into. Diagnostics ignore them. */
|
|
16
|
+
const SpanMapFeature = {
|
|
17
|
+
Hover: 1,
|
|
18
|
+
SignatureHelp: 2,
|
|
19
|
+
Completion: 4,
|
|
20
|
+
Definition: 8,
|
|
21
|
+
TypeDefinition: 16,
|
|
22
|
+
Implementation: 32,
|
|
23
|
+
References: 64,
|
|
24
|
+
DocumentHighlights: 128,
|
|
25
|
+
Rename: 256,
|
|
26
|
+
CallHierarchy: 512,
|
|
27
|
+
CodeActions: 1024,
|
|
28
|
+
Formatting: 2048,
|
|
29
|
+
InlayHints: 4096,
|
|
30
|
+
SemanticTokens: 8192,
|
|
31
|
+
FoldingRanges: 16384,
|
|
32
|
+
SelectionRanges: 32768,
|
|
33
|
+
LinkedEditing: 65536,
|
|
34
|
+
AutoInsert: 1 << 17,
|
|
35
|
+
DocumentSymbols: 1 << 18,
|
|
36
|
+
CodeLens: 1 << 19,
|
|
37
|
+
None: 0,
|
|
38
|
+
All: (1 << 20) - 1
|
|
39
|
+
};
|
|
40
|
+
/** Diagnostic-directive policies (unused by TSRX today; kept for completeness). */
|
|
41
|
+
const DiagnosticDirectivePolicy = {
|
|
42
|
+
Ignore: 0,
|
|
43
|
+
Expect: 1
|
|
44
|
+
};
|
|
45
|
+
/** Prefix for mapper-authored diagnostics: `error tsrx(1000): ...`. */
|
|
46
|
+
const DIAGNOSTIC_SOURCE = "tsrx";
|
|
47
|
+
/** Numeric code for a fatal compile error (the file could not be transformed). */
|
|
48
|
+
const DIAGNOSTIC_CODE_COMPILE_ERROR = 1e3;
|
|
49
|
+
/** Numeric code for a usage error that carries no string code. */
|
|
50
|
+
const DIAGNOSTIC_CODE_USAGE_ERROR = 1001;
|
|
51
|
+
/** Numeric code when no TSRX compiler can be resolved for a file. */
|
|
52
|
+
const DIAGNOSTIC_CODE_NO_COMPILER = 1002;
|
|
53
|
+
/** Numeric code when the project's TSRX configuration is invalid. */
|
|
54
|
+
const DIAGNOSTIC_CODE_INVALID_CONFIG = 1003;
|
|
55
|
+
/**
|
|
56
|
+
* @typedef {[
|
|
57
|
+
* generatedStart: number,
|
|
58
|
+
* generatedLength: number,
|
|
59
|
+
* originalStart: number,
|
|
60
|
+
* originalLength: number,
|
|
61
|
+
* kind: 0 | 1 | 2,
|
|
62
|
+
* features: number,
|
|
63
|
+
* ]} SpanMapping
|
|
64
|
+
*/
|
|
65
|
+
/**
|
|
66
|
+
* @typedef {object} MapperDiagnostic
|
|
67
|
+
* @property {number} start Offset into the original text (UTF-16 code units).
|
|
68
|
+
* @property {number} length
|
|
69
|
+
* @property {number} code
|
|
70
|
+
* @property {string} messageText
|
|
71
|
+
*/
|
|
72
|
+
/**
|
|
73
|
+
* @typedef {object} MappedOutput
|
|
74
|
+
* @property {string} text
|
|
75
|
+
* @property {'.js' | '.jsx' | '.mjs' | '.cjs' | '.ts' | '.tsx' | '.mts' | '.cts' | '.json'} extension
|
|
76
|
+
* @property {SpanMapping[]} mappings
|
|
77
|
+
*/
|
|
78
|
+
/**
|
|
79
|
+
* @typedef {MappedOutput & {
|
|
80
|
+
* diagnostics?: MapperDiagnostic[],
|
|
81
|
+
* supplemental?: MappedOutput[],
|
|
82
|
+
* }} TransformResult
|
|
83
|
+
*/
|
|
84
|
+
/**
|
|
85
|
+
* @typedef {object} InitializeParams
|
|
86
|
+
* @property {string} [locale]
|
|
87
|
+
* @property {Array<'utf-8' | 'utf-16'>} positionEncodings
|
|
88
|
+
*/
|
|
89
|
+
/**
|
|
90
|
+
* @typedef {object} InitializeResult
|
|
91
|
+
* @property {'utf-8' | 'utf-16'} positionEncoding
|
|
92
|
+
* @property {string} diagnosticSource
|
|
93
|
+
*/
|
|
94
|
+
/**
|
|
95
|
+
* @typedef {object} OpenProjectParams
|
|
96
|
+
* @property {string} configFileName Empty for inferred projects.
|
|
97
|
+
* @property {string} projectHandle
|
|
98
|
+
* @property {Record<string, unknown>} [options] The mapper entry's `options` object.
|
|
99
|
+
* @property {Record<string, unknown>} compilerOptions Effective compiler options (wire format).
|
|
100
|
+
*/
|
|
101
|
+
/**
|
|
102
|
+
* @typedef {object} OpenProjectResult
|
|
103
|
+
* @property {string} configIdentity
|
|
104
|
+
* @property {string[]} [watchedFiles]
|
|
105
|
+
* @property {Array<{ path: Array<string | number>, messageText: string, code: number }>} [optionDiagnostics]
|
|
106
|
+
*/
|
|
107
|
+
/**
|
|
108
|
+
* @typedef {object} TransformParams
|
|
109
|
+
* @property {string} fileName
|
|
110
|
+
* @property {string} content
|
|
111
|
+
* @property {string} [projectHandle]
|
|
112
|
+
*/
|
|
113
|
+
|
|
114
|
+
//#endregion
|
|
115
|
+
export { DIAGNOSTIC_CODE_COMPILE_ERROR, DIAGNOSTIC_CODE_INVALID_CONFIG, DIAGNOSTIC_CODE_NO_COMPILER, DIAGNOSTIC_CODE_USAGE_ERROR, DIAGNOSTIC_SOURCE, DiagnosticDirectivePolicy, SpanMapFeature, SpanMapKind };
|
|
116
|
+
//# sourceMappingURL=protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.js","names":[],"sources":["../src/protocol.js"],"sourcesContent":["/**\n * Constants of the TypeScript 7 content-mapper protocol, kept in sync with\n * `tsc/internal/contentmapper` and `tsc/internal/spanmap` in microsoft/TypeScript.\n */\n\n/** Span kinds. */\nexport const SpanMapKind = /** @type {const} */ ({\n\t/** Same length and identical text; the only kind that supports text edits. */\n\tVerbatim: 0,\n\t/** Same entity, different text or length. */\n\tAtom: 1,\n\t/** Different text; diagnostics covering the whole span exactly show the original text. */\n\tAlias: 2,\n});\n\n/** Feature bits a span opts into. Diagnostics ignore them. */\nexport const SpanMapFeature = /** @type {const} */ ({\n\tHover: 1 << 0,\n\tSignatureHelp: 1 << 1,\n\tCompletion: 1 << 2,\n\tDefinition: 1 << 3,\n\tTypeDefinition: 1 << 4,\n\tImplementation: 1 << 5,\n\tReferences: 1 << 6,\n\tDocumentHighlights: 1 << 7,\n\tRename: 1 << 8,\n\tCallHierarchy: 1 << 9,\n\tCodeActions: 1 << 10,\n\tFormatting: 1 << 11,\n\tInlayHints: 1 << 12,\n\tSemanticTokens: 1 << 13,\n\tFoldingRanges: 1 << 14,\n\tSelectionRanges: 1 << 15,\n\tLinkedEditing: 1 << 16,\n\tAutoInsert: 1 << 17,\n\tDocumentSymbols: 1 << 18,\n\tCodeLens: 1 << 19,\n\tNone: 0,\n\tAll: (1 << 20) - 1,\n});\n\n/** Diagnostic-directive policies (unused by TSRX today; kept for completeness). */\nexport const DiagnosticDirectivePolicy = /** @type {const} */ ({ Ignore: 0, Expect: 1 });\n\n/** Prefix for mapper-authored diagnostics: `error tsrx(1000): ...`. */\nexport const DIAGNOSTIC_SOURCE = 'tsrx';\n\n/** Numeric code for a fatal compile error (the file could not be transformed). */\nexport const DIAGNOSTIC_CODE_COMPILE_ERROR = 1000;\n/** Numeric code for a usage error that carries no string code. */\nexport const DIAGNOSTIC_CODE_USAGE_ERROR = 1001;\n/** Numeric code when no TSRX compiler can be resolved for a file. */\nexport const DIAGNOSTIC_CODE_NO_COMPILER = 1002;\n/** Numeric code when the project's TSRX configuration is invalid. */\nexport const DIAGNOSTIC_CODE_INVALID_CONFIG = 1003;\n\n/**\n * @typedef {[\n * \tgeneratedStart: number,\n * \tgeneratedLength: number,\n * \toriginalStart: number,\n * \toriginalLength: number,\n * \tkind: 0 | 1 | 2,\n * \tfeatures: number,\n * ]} SpanMapping\n */\n\n/**\n * @typedef {object} MapperDiagnostic\n * @property {number} start Offset into the original text (UTF-16 code units).\n * @property {number} length\n * @property {number} code\n * @property {string} messageText\n */\n\n/**\n * @typedef {object} MappedOutput\n * @property {string} text\n * @property {'.js' | '.jsx' | '.mjs' | '.cjs' | '.ts' | '.tsx' | '.mts' | '.cts' | '.json'} extension\n * @property {SpanMapping[]} mappings\n */\n\n/**\n * @typedef {MappedOutput & {\n * \tdiagnostics?: MapperDiagnostic[],\n * \tsupplemental?: MappedOutput[],\n * }} TransformResult\n */\n\n/**\n * @typedef {object} InitializeParams\n * @property {string} [locale]\n * @property {Array<'utf-8' | 'utf-16'>} positionEncodings\n */\n\n/**\n * @typedef {object} InitializeResult\n * @property {'utf-8' | 'utf-16'} positionEncoding\n * @property {string} diagnosticSource\n */\n\n/**\n * @typedef {object} OpenProjectParams\n * @property {string} configFileName Empty for inferred projects.\n * @property {string} projectHandle\n * @property {Record<string, unknown>} [options] The mapper entry's `options` object.\n * @property {Record<string, unknown>} compilerOptions Effective compiler options (wire format).\n */\n\n/**\n * @typedef {object} OpenProjectResult\n * @property {string} configIdentity\n * @property {string[]} [watchedFiles]\n * @property {Array<{ path: Array<string | number>, messageText: string, code: number }>} [optionDiagnostics]\n */\n\n/**\n * @typedef {object} TransformParams\n * @property {string} fileName\n * @property {string} content\n * @property {string} [projectHandle]\n */\n"],"mappings":";;;;;;AAMA,MAAa,cAAoC;;CAEhD,UAAU;;CAEV,MAAM;;CAEN,OAAO;AACR;;AAGA,MAAa,iBAAuC;CACnD,OAAO;CACP,eAAe;CACf,YAAY;CACZ,YAAY;CACZ,gBAAgB;CAChB,gBAAgB;CAChB,YAAY;CACZ,oBAAoB;CACpB,QAAQ;CACR,eAAe;CACf,aAAa;CACb,YAAY;CACZ,YAAY;CACZ,gBAAgB;CAChB,eAAe;CACf,iBAAiB;CACjB,eAAe;CACf,YAAY,KAAK;CACjB,iBAAiB,KAAK;CACtB,UAAU,KAAK;CACf,MAAM;CACN,MAAM,KAAK,MAAM;AAClB;;AAGA,MAAa,4BAAkD;CAAE,QAAQ;CAAG,QAAQ;AAAE;;AAGtF,MAAa,oBAAoB;;AAGjC,MAAa,gCAAgC;;AAE7C,MAAa,8BAA8B;;AAE3C,MAAa,8BAA8B;;AAE3C,MAAa,iCAAiC"}
|
package/dist/rpc.js
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
//#region src/rpc.js
|
|
2
|
+
/**
|
|
3
|
+
* Content-mapper transport: `Content-Length`-framed JSON-RPC 2.0 over stdio.
|
|
4
|
+
* TypeScript is the only requester; the mapper never sends requests or
|
|
5
|
+
* notifications. stdout is reserved for protocol messages, so everything
|
|
6
|
+
* else (including `console.log`) goes to stderr.
|
|
7
|
+
*
|
|
8
|
+
* Kept separate from the executable entry (`server.js`) so hosts that bundle
|
|
9
|
+
* the mapper (the VS Code extension ships it for inferred projects) can start
|
|
10
|
+
* it from their own entry file.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* @typedef {{ jsonrpc: '2.0', id?: number | string | null, method: string, params?: unknown }} RequestMessage
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Run the mapper server on the given streams. Installs the stream handlers
|
|
17
|
+
* and returns; the process exits (with `process.exitCode`) once the input
|
|
18
|
+
* stream ends, which is how TypeScript shuts a mapper down.
|
|
19
|
+
* @param {import('./mapper.js').ContentMapper} mapper
|
|
20
|
+
* @param {{ input?: NodeJS.ReadableStream, output?: NodeJS.WritableStream }} [streams]
|
|
21
|
+
*/
|
|
22
|
+
function run_mapper_server(mapper, streams = {}) {
|
|
23
|
+
const input = streams.input ?? process.stdin;
|
|
24
|
+
const output = streams.output ?? process.stdout;
|
|
25
|
+
let buffered = Buffer.alloc(0);
|
|
26
|
+
input.on("data", (chunk) => {
|
|
27
|
+
buffered = Buffer.concat([buffered, typeof chunk === "string" ? Buffer.from(chunk) : chunk]);
|
|
28
|
+
read_messages();
|
|
29
|
+
});
|
|
30
|
+
input.on("error", (error) => {
|
|
31
|
+
console.error(error);
|
|
32
|
+
process.exitCode = 1;
|
|
33
|
+
});
|
|
34
|
+
input.on("end", () => {
|
|
35
|
+
process.exit(process.exitCode ?? 0);
|
|
36
|
+
});
|
|
37
|
+
function read_messages() {
|
|
38
|
+
while (true) {
|
|
39
|
+
const header_end = buffered.indexOf("\r\n\r\n");
|
|
40
|
+
if (header_end < 0) return;
|
|
41
|
+
const header = buffered.subarray(0, header_end).toString("ascii");
|
|
42
|
+
const length_match = /^Content-Length:\s*(\d+)\s*$/im.exec(header);
|
|
43
|
+
if (!length_match) {
|
|
44
|
+
console.error("@tsrx/content-mapper: missing Content-Length header");
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
const content_length = Number(length_match[1]);
|
|
48
|
+
const message_start = header_end + 4;
|
|
49
|
+
const message_end = message_start + content_length;
|
|
50
|
+
if (buffered.length < message_end) return;
|
|
51
|
+
const body = buffered.subarray(message_start, message_end).toString("utf8");
|
|
52
|
+
buffered = buffered.subarray(message_end);
|
|
53
|
+
/** @type {RequestMessage} */
|
|
54
|
+
let message;
|
|
55
|
+
try {
|
|
56
|
+
message = JSON.parse(body);
|
|
57
|
+
} catch (error) {
|
|
58
|
+
console.error("@tsrx/content-mapper: invalid JSON-RPC message", error);
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
handle_message(message);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/** @param {RequestMessage} message */
|
|
65
|
+
function handle_message(message) {
|
|
66
|
+
if (message.id === void 0 || message.id === null) return;
|
|
67
|
+
try {
|
|
68
|
+
/** @type {unknown} */
|
|
69
|
+
let result;
|
|
70
|
+
switch (message.method) {
|
|
71
|
+
case "initialize":
|
|
72
|
+
result = mapper.initialize(message.params);
|
|
73
|
+
break;
|
|
74
|
+
case "openProject":
|
|
75
|
+
result = mapper.openProject(message.params);
|
|
76
|
+
break;
|
|
77
|
+
case "closeProject":
|
|
78
|
+
mapper.closeProject(message.params);
|
|
79
|
+
result = null;
|
|
80
|
+
break;
|
|
81
|
+
case "transform":
|
|
82
|
+
result = mapper.transform(message.params);
|
|
83
|
+
break;
|
|
84
|
+
default:
|
|
85
|
+
write({
|
|
86
|
+
jsonrpc: "2.0",
|
|
87
|
+
id: message.id,
|
|
88
|
+
error: {
|
|
89
|
+
code: -32601,
|
|
90
|
+
message: `Unknown method ${message.method}`
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
write({
|
|
96
|
+
jsonrpc: "2.0",
|
|
97
|
+
id: message.id,
|
|
98
|
+
result
|
|
99
|
+
});
|
|
100
|
+
} catch (error) {
|
|
101
|
+
write({
|
|
102
|
+
jsonrpc: "2.0",
|
|
103
|
+
id: message.id,
|
|
104
|
+
error: {
|
|
105
|
+
code: -32603,
|
|
106
|
+
message: error instanceof Error ? error.stack ?? error.message : String(error)
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/** @param {unknown} message */
|
|
112
|
+
function write(message) {
|
|
113
|
+
const body = Buffer.from(JSON.stringify(message), "utf8");
|
|
114
|
+
output.write(`Content-Length: ${body.length}\r\n\r\n`);
|
|
115
|
+
output.write(body);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Route every console method to stderr so stray logging (from a target
|
|
120
|
+
* compiler, for example) can never corrupt the protocol stream on stdout.
|
|
121
|
+
*/
|
|
122
|
+
function redirect_console_to_stderr() {
|
|
123
|
+
console.log = console.info = console.warn = console.debug = (...args) => console.error(...args);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
//#endregion
|
|
127
|
+
export { redirect_console_to_stderr, run_mapper_server };
|
|
128
|
+
//# sourceMappingURL=rpc.js.map
|
package/dist/rpc.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpc.js","names":[],"sources":["../src/rpc.js"],"sourcesContent":["/**\n * Content-mapper transport: `Content-Length`-framed JSON-RPC 2.0 over stdio.\n * TypeScript is the only requester; the mapper never sends requests or\n * notifications. stdout is reserved for protocol messages, so everything\n * else (including `console.log`) goes to stderr.\n *\n * Kept separate from the executable entry (`server.js`) so hosts that bundle\n * the mapper (the VS Code extension ships it for inferred projects) can start\n * it from their own entry file.\n */\n\n/**\n * @typedef {{ jsonrpc: '2.0', id?: number | string | null, method: string, params?: unknown }} RequestMessage\n */\n\n/**\n * Run the mapper server on the given streams. Installs the stream handlers\n * and returns; the process exits (with `process.exitCode`) once the input\n * stream ends, which is how TypeScript shuts a mapper down.\n * @param {import('./mapper.js').ContentMapper} mapper\n * @param {{ input?: NodeJS.ReadableStream, output?: NodeJS.WritableStream }} [streams]\n */\nexport function run_mapper_server(mapper, streams = {}) {\n\tconst input = streams.input ?? process.stdin;\n\tconst output = streams.output ?? process.stdout;\n\tlet buffered = Buffer.alloc(0);\n\n\tinput.on('data', (chunk) => {\n\t\tbuffered = Buffer.concat([buffered, typeof chunk === 'string' ? Buffer.from(chunk) : chunk]);\n\t\tread_messages();\n\t});\n\tinput.on('error', (error) => {\n\t\tconsole.error(error);\n\t\tprocess.exitCode = 1;\n\t});\n\tinput.on('end', () => {\n\t\tprocess.exit(process.exitCode ?? 0);\n\t});\n\n\tfunction read_messages() {\n\t\twhile (true) {\n\t\t\tconst header_end = buffered.indexOf('\\r\\n\\r\\n');\n\t\t\tif (header_end < 0) return;\n\t\t\tconst header = buffered.subarray(0, header_end).toString('ascii');\n\t\t\tconst length_match = /^Content-Length:\\s*(\\d+)\\s*$/im.exec(header);\n\t\t\tif (!length_match) {\n\t\t\t\tconsole.error('@tsrx/content-mapper: missing Content-Length header');\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\t\t\tconst content_length = Number(length_match[1]);\n\t\t\tconst message_start = header_end + 4;\n\t\t\tconst message_end = message_start + content_length;\n\t\t\tif (buffered.length < message_end) return;\n\t\t\tconst body = buffered.subarray(message_start, message_end).toString('utf8');\n\t\t\tbuffered = buffered.subarray(message_end);\n\t\t\t/** @type {RequestMessage} */\n\t\t\tlet message;\n\t\t\ttry {\n\t\t\t\tmessage = JSON.parse(body);\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error('@tsrx/content-mapper: invalid JSON-RPC message', error);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\thandle_message(message);\n\t\t}\n\t}\n\n\t/** @param {RequestMessage} message */\n\tfunction handle_message(message) {\n\t\tif (message.id === undefined || message.id === null) {\n\t\t\t// Notifications need no response.\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\t/** @type {unknown} */\n\t\t\tlet result;\n\t\t\tswitch (message.method) {\n\t\t\t\tcase 'initialize':\n\t\t\t\t\tresult = mapper.initialize(/** @type {any} */ (message.params));\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'openProject':\n\t\t\t\t\tresult = mapper.openProject(/** @type {any} */ (message.params));\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'closeProject':\n\t\t\t\t\tmapper.closeProject(/** @type {any} */ (message.params));\n\t\t\t\t\tresult = null;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'transform':\n\t\t\t\t\tresult = mapper.transform(/** @type {any} */ (message.params));\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\twrite({\n\t\t\t\t\t\tjsonrpc: '2.0',\n\t\t\t\t\t\tid: message.id,\n\t\t\t\t\t\terror: { code: -32601, message: `Unknown method ${message.method}` },\n\t\t\t\t\t});\n\t\t\t\t\treturn;\n\t\t\t}\n\t\t\twrite({ jsonrpc: '2.0', id: message.id, result });\n\t\t} catch (error) {\n\t\t\twrite({\n\t\t\t\tjsonrpc: '2.0',\n\t\t\t\tid: message.id,\n\t\t\t\terror: {\n\t\t\t\t\tcode: -32603,\n\t\t\t\t\tmessage: error instanceof Error ? (error.stack ?? error.message) : String(error),\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\t}\n\n\t/** @param {unknown} message */\n\tfunction write(message) {\n\t\tconst body = Buffer.from(JSON.stringify(message), 'utf8');\n\t\toutput.write(`Content-Length: ${body.length}\\r\\n\\r\\n`);\n\t\toutput.write(body);\n\t}\n}\n\n/**\n * Route every console method to stderr so stray logging (from a target\n * compiler, for example) can never corrupt the protocol stream on stdout.\n */\nexport function redirect_console_to_stderr() {\n\tconsole.log = console.info = console.warn = console.debug = (...args) => console.error(...args);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAsBA,SAAgB,kBAAkB,QAAQ,UAAU,CAAC,GAAG;CACvD,MAAM,QAAQ,QAAQ,SAAS,QAAQ;CACvC,MAAM,SAAS,QAAQ,UAAU,QAAQ;CACzC,IAAI,WAAW,OAAO,MAAM,CAAC;CAE7B,MAAM,GAAG,SAAS,UAAU;EAC3B,WAAW,OAAO,OAAO,CAAC,UAAU,OAAO,UAAU,WAAW,OAAO,KAAK,KAAK,IAAI,KAAK,CAAC;EAC3F,cAAc;CACf,CAAC;CACD,MAAM,GAAG,UAAU,UAAU;EAC5B,QAAQ,MAAM,KAAK;EACnB,QAAQ,WAAW;CACpB,CAAC;CACD,MAAM,GAAG,aAAa;EACrB,QAAQ,KAAK,QAAQ,YAAY,CAAC;CAC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