*/
constructor(onEvent: SSEEventHandler) {
this.decoder = new TextDecoder('utf-8');
}
/**
Frontier kind: Code frontier
unlabeled · c_26ace6eee156
20 tests · 3548 LOC · 19 files · introduces 0 tests · 70 LOC · 1 file
The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.
Introduced files, introduced tests, and structurally relevant concept specialization
In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.
Graph controls are ready.
Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.
Every exact file and test below is linked only from the concept that introduces it.
mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/sseParser.test|title=SSEParser handles events with explicit event type (CRLF)|occurrence=1mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/sseParser.test|title=SSEParser handles events with explicit event type|occurrence=1mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/sseParser.test|title=SSEParser handles basic events|occurrence=1mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/sseParser.test|title=SSEParser handles different line endings (CR)|occurrence=1mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/sseParser.test|title=SSEParser handles different line endings (CRLF)|occurrence=1mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/sseParser.test|title=SSEParser handles different line endings (LF)|occurrence=1mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/sseParser.test|title=SSEParser handles events with multiple data fields|occurrence=1mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/sseParser.test|title=SSEParser resets correctly|occurrence=1mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/charCode.test|title=CharCode has good values|occurrence=1mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/path.test|title=Paths (Node Implementation) path|occurrence=1mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/uri.test|title=URI File paths containing apostrophes break URI parsing and cannot be opened #276075|occurrence=1mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/uri.test|title=URI URI#file, win-speciale|occurrence=1Every collected test enters the hierarchy at exactly one concept.
No tests are introduced at this concept. Its intent tests are introduced by other concepts.
Every collected source range enters the hierarchy at exactly one concept.
1 file ranked by introduced lines: 70 introduced LOC across 19 ranges. Expand a file to inspect source; the > gutter marks introduced lines.
*/
constructor(onEvent: SSEEventHandler) {
this.decoder = new TextDecoder('utf-8');
}
/**
*/
public feed(chunk: Uint8Array): void {
return;
}
let offset = 0;
// If the data stream was bifurcated between a CR and LF, avoid processing the CR as an extra newline
if (this.endedOnCR && chunk[0] === Chr.LF) {
offset++;
}
// Process complete lines from the buffer
while (offset < chunk.length) {
const indexCR = chunk.indexOf(Chr.CR, offset);
const indexLF = chunk.indexOf(Chr.LF, offset);
const index = indexCR === -1 ? indexLF : (indexLF === -1 ? indexCR : Math.min(indexCR, indexLF));
if (index === -1) {
break;
}
let str = '';
for (const buf of this.buffer) {
str += this.decoder.decode(buf, { stream: true });
}
this.processLine(str);
this.buffer.length = 0;
offset = index + (chunk[index] === Chr.CR && chunk[index + 1] === Chr.LF ? 2 : 1);
}
if (offset < chunk.length) {
this.buffer.push(chunk.subarray(offset));
this.endedOnCR = chunk[chunk.length - 1] === Chr.CR;
}
}
/**
* Processes a single line from the SSE stream.
*/
private processLine(line: string): void {
this.dispatchEvent();
return;
}
if (line.startsWith(':')) {
return;
}
// Parse the field name and value
let field: string;
let value: string;
const colonIndex = line.indexOf(':');
if (colonIndex === -1) {
// Line with no colon - the entire line is the field name, value is empty
field = line;
value = '';
// Line with a colon - split into field name and value
field = line.substring(0, colonIndex);
}
}
this.processField(field, value);
}
/**
* Processes a field with the given name and value.
*/
private processField(field: string, value: string): void {
case 'event':
this.eventTypeBuffer = value;
break;
case 'data':
// Append the value to the data buffer, followed by a newline
this.dataBuffer += value;
this.dataBuffer += '\n';
break;
case 'id':
// If the field value doesn't contain NULL, set the last event ID buffer
if (!value.includes('\0')) {
}
break;
case 'retry':
// If the field value consists only of ASCII digits, set the reconnection time
if (/^\d+$/.test(value)) {
}
break;
// Ignore any other fields
}
}
/**
* Dispatches the event based on the current buffer states.
*/
private dispatchEvent(): void {
if (this.dataBuffer === '') {
this.dataBuffer = '';
this.eventTypeBuffer = '';
const event: ISSEEvent = {
type: this.eventTypeBuffer || 'message',
};
// Add optional fields if they exist
if (this.currentEventId !== undefined) {
event.id = this.currentEventId;
}