@silver886/mcp-proxy 0.2.2 → 0.2.4
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/package.json +15 -2
- package/scripts/fetch.mjs +87 -0
- package/node_modules/cloudflared/LICENSE +0 -21
- package/node_modules/cloudflared/README.md +0 -156
- package/node_modules/cloudflared/bin/cloudflared +0 -0
- package/node_modules/cloudflared/lib/cloudflared.js +0 -10
- package/node_modules/cloudflared/lib/constants.js +0 -58
- package/node_modules/cloudflared/lib/error.js +0 -32
- package/node_modules/cloudflared/lib/handler.js +0 -117
- package/node_modules/cloudflared/lib/index.js +0 -126
- package/node_modules/cloudflared/lib/install.js +0 -155
- package/node_modules/cloudflared/lib/lib.d.ts +0 -236
- package/node_modules/cloudflared/lib/lib.js +0 -45
- package/node_modules/cloudflared/lib/regex.js +0 -52
- package/node_modules/cloudflared/lib/service.js +0 -229
- package/node_modules/cloudflared/lib/tunnel.js +0 -164
- package/node_modules/cloudflared/lib/types.js +0 -16
- package/node_modules/cloudflared/package.json +0 -59
- package/node_modules/cloudflared/scripts/postinstall.mjs +0 -10
- package/node_modules/eventsource-parser/LICENSE +0 -21
- package/node_modules/eventsource-parser/README.md +0 -126
- package/node_modules/eventsource-parser/dist/index.cjs +0 -166
- package/node_modules/eventsource-parser/dist/index.cjs.map +0 -1
- package/node_modules/eventsource-parser/dist/index.d.cts +0 -146
- package/node_modules/eventsource-parser/dist/index.d.ts +0 -146
- package/node_modules/eventsource-parser/dist/index.js +0 -166
- package/node_modules/eventsource-parser/dist/index.js.map +0 -1
- package/node_modules/eventsource-parser/dist/stream.cjs +0 -28
- package/node_modules/eventsource-parser/dist/stream.cjs.map +0 -1
- package/node_modules/eventsource-parser/dist/stream.d.cts +0 -121
- package/node_modules/eventsource-parser/dist/stream.d.ts +0 -121
- package/node_modules/eventsource-parser/dist/stream.js +0 -29
- package/node_modules/eventsource-parser/dist/stream.js.map +0 -1
- package/node_modules/eventsource-parser/package.json +0 -92
- package/node_modules/eventsource-parser/src/errors.ts +0 -44
- package/node_modules/eventsource-parser/src/index.ts +0 -3
- package/node_modules/eventsource-parser/src/parse.ts +0 -395
- package/node_modules/eventsource-parser/src/stream.ts +0 -88
- package/node_modules/eventsource-parser/src/types.ts +0 -97
- package/node_modules/eventsource-parser/stream.js +0 -2
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/errors.ts","../src/parse.ts"],"sourcesContent":["/**\n * The type of error that occurred.\n * @public\n */\nexport type ErrorType = 'invalid-retry' | 'unknown-field'\n\n/**\n * Error thrown when encountering an issue during parsing.\n *\n * @public\n */\nexport class ParseError extends Error {\n /**\n * The type of error that occurred.\n */\n type: ErrorType\n\n /**\n * In the case of an unknown field encountered in the stream, this will be the field name.\n */\n field?: string | undefined\n\n /**\n * In the case of an unknown field encountered in the stream, this will be the value of the field.\n */\n value?: string | undefined\n\n /**\n * The line that caused the error, if available.\n */\n line?: string | undefined\n\n constructor(\n message: string,\n options: {type: ErrorType; field?: string; value?: string; line?: string},\n ) {\n super(message)\n this.name = 'ParseError'\n this.type = options.type\n this.field = options.field\n this.value = options.value\n this.line = options.line\n }\n}\n","/**\n * EventSource/Server-Sent Events parser\n * @see https://html.spec.whatwg.org/multipage/server-sent-events.html\n */\nimport {ParseError} from './errors.ts'\nimport type {EventSourceParser, ParserCallbacks} from './types.ts'\n\n// ASCII codes used in the hot parsing paths.\nconst LF = 10\nconst CR = 13\nconst SPACE = 32\n\n// oxlint-disable-next-line no-unused-vars\nfunction noop(_arg: unknown) {\n // intentional noop\n}\n\n/**\n * Creates a new EventSource parser.\n *\n * @param callbacks - Callbacks to invoke on different parsing events:\n * - `onEvent` when a new event is parsed\n * - `onError` when an error occurs\n * - `onRetry` when a new reconnection interval has been sent from the server\n * - `onComment` when a comment is encountered in the stream\n *\n * @returns A new EventSource parser, with `parse` and `reset` methods.\n * @public\n */\nexport function createParser(callbacks: ParserCallbacks): EventSourceParser {\n if (typeof callbacks === 'function') {\n throw new TypeError(\n '`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?',\n )\n }\n\n const {onEvent = noop, onError = noop, onRetry = noop, onComment} = callbacks\n\n // Trailing bytes from prior `feed()` calls that did not yet form a complete line.\n // Stored as an array of fragments and only joined when a line terminator arrives.\n // Concatenating per-feed (`prefix + chunk`) is O(N²) when a single SSE line spans\n // many chunks (e.g. a large `data:` payload streamed in tiny slices, or an MCP-style\n // server that emits one giant content block). Buffering as fragments + joining once\n // makes the same workload linear.\n const pendingFragments: string[] = []\n\n let isFirstChunk = true\n let id: string | undefined\n let data = ''\n let dataLines = 0\n let eventType: string | undefined\n\n /**\n * Feeds a chunk of the SSE stream to the parser. Any trailing bytes that do\n * not yet form a complete line are held back and prepended to the next chunk,\n * so callers can pass arbitrary slices of the stream without worrying about\n * line boundaries.\n *\n * Per the SSE spec, a UTF-8 BOM (0xEF 0xBB 0xBF) at the start of the very\n * first chunk is stripped before parsing.\n *\n * @see https://html.spec.whatwg.org/multipage/server-sent-events.html#parsing-an-event-stream\n */\n function feed(chunk: string) {\n if (isFirstChunk) {\n isFirstChunk = false\n // Match and strip UTF-8 BOM from the start of the stream, if present.\n // (Per the spec, this is only valid at the very start of the stream)\n if (\n chunk.charCodeAt(0) === 0xef &&\n chunk.charCodeAt(1) === 0xbb &&\n chunk.charCodeAt(2) === 0xbf\n ) {\n chunk = chunk.slice(3)\n }\n }\n\n // Hot path: no buffered prefix from a prior partial line. Hand the chunk\n // straight to `processLines`, exactly like the original implementation.\n // Zero new work in the common case (every chunk ends with `\\n\\n`).\n if (pendingFragments.length === 0) {\n const trailing = processLines(chunk)\n if (trailing !== '') pendingFragments.push(trailing)\n return\n }\n\n // We have a buffered prefix. If this chunk also has no terminator, append\n // to the buffer without concatenating — that's the O(N²) trap we're\n // avoiding (large single `data:` payload split across many tiny chunks).\n if (chunk.indexOf('\\n') === -1 && chunk.indexOf('\\r') === -1) {\n pendingFragments.push(chunk)\n return\n }\n\n // Terminator arrived. Join the accumulated fragments + this chunk once,\n // process, and buffer any new trailing partial line.\n pendingFragments.push(chunk)\n const input = pendingFragments.join('')\n pendingFragments.length = 0\n const trailing = processLines(input)\n if (trailing !== '') pendingFragments.push(trailing)\n }\n\n /**\n * Splits `chunk` into SSE lines and dispatches each to the appropriate handler.\n * Returns any trailing bytes that did not terminate with a line break, so the\n * caller can prepend them to the next chunk.\n *\n * The SSE spec permits three line terminators: `\\n`, `\\r`, and `\\r\\n`. Real-world\n * streams almost always use plain `\\n`, so we take a fast path when no `\\r` is\n * present in the chunk. The slow path is spec-correct but does more work per line.\n */\n function processLines(chunk: string): string {\n let searchIndex = 0\n\n // Fast path: LF-only chunk (the common case for typical SSE servers).\n // We can scan forward with a single `indexOf('\\n')` per line and inline\n // the hot-path branches for `data:` and `event:` without the CR bookkeeping\n // the slow path needs.\n if (chunk.indexOf('\\r') === -1) {\n let lfIndex = chunk.indexOf('\\n', searchIndex)\n while (lfIndex !== -1) {\n // Blank line: end-of-event marker. Dispatch the accumulated event (if any)\n // and reset the buffered fields. This is hoisted out of `parseLine` because\n // it's the single most common line shape after `data:` lines.\n if (searchIndex === lfIndex) {\n if (dataLines > 0) {\n onEvent({id, event: eventType, data})\n }\n id = undefined\n data = ''\n dataLines = 0\n eventType = undefined\n searchIndex = lfIndex + 1\n lfIndex = chunk.indexOf('\\n', searchIndex)\n continue\n }\n const firstCharCode = chunk.charCodeAt(searchIndex)\n if (isDataPrefix(chunk, searchIndex, firstCharCode)) {\n // `data:` line — append the value to the event's data buffer.\n // 'data:'.length === 5, 'data: '.length === 6\n const valueStart =\n chunk.charCodeAt(searchIndex + 5) === SPACE ? searchIndex + 6 : searchIndex + 5\n const value = chunk.slice(valueStart, lfIndex)\n // Fast path within a fast path: if this is the first data line AND the\n // next char is another LF (i.e. `data:foo\\n\\n`), dispatch immediately\n // without ever writing to the `data` buffer. This is the shape of a\n // typical single-line SSE event (ChatGPT-style streams, etc.) and is\n // hot enough to be worth the duplication.\n if (dataLines === 0 && chunk.charCodeAt(lfIndex + 1) === LF) {\n onEvent({id, event: eventType, data: value})\n id = undefined\n data = ''\n eventType = undefined\n searchIndex = lfIndex + 2\n lfIndex = chunk.indexOf('\\n', searchIndex)\n continue\n }\n // Multi-line data: concatenate with newline separator per spec.\n data = dataLines === 0 ? value : `${data}\\n${value}`\n dataLines++\n } else if (isEventPrefix(chunk, searchIndex, firstCharCode)) {\n // `event:` line — set the event type for the next dispatch. Per spec,\n // an empty value resets `event type` to its default (undefined here).\n // 'event:'.length === 6, 'event: '.length === 7\n eventType =\n chunk.slice(\n chunk.charCodeAt(searchIndex + 6) === SPACE ? searchIndex + 7 : searchIndex + 6,\n lfIndex,\n ) || undefined\n } else {\n // Everything else: `id:`, `retry:`, comment lines (`:` prefix), unknown\n // fields, or malformed lines. These are rarer and go through the full\n // per-line parser, which handles the SSE field grammar in detail.\n parseLine(chunk, searchIndex, lfIndex)\n }\n searchIndex = lfIndex + 1\n lfIndex = chunk.indexOf('\\n', searchIndex)\n }\n return chunk.slice(searchIndex)\n }\n\n // Slow path: the chunk contains at least one `\\r`, so lines may be terminated\n // by `\\r`, `\\n`, or `\\r\\n`. We locate the next terminator by looking at both\n // the nearest `\\r` and `\\n` and picking whichever comes first.\n while (searchIndex < chunk.length) {\n const crIndex = chunk.indexOf('\\r', searchIndex)\n const lfIndex = chunk.indexOf('\\n', searchIndex)\n\n let lineEnd = -1\n if (crIndex !== -1 && lfIndex !== -1) {\n lineEnd = crIndex < lfIndex ? crIndex : lfIndex\n } else if (crIndex !== -1) {\n // A trailing `\\r` at the very end of the chunk is ambiguous: it could be\n // a bare-CR terminator, or the first half of a `\\r\\n` whose `\\n` arrives\n // in the next chunk. Defer until we see more input.\n if (crIndex === chunk.length - 1) {\n lineEnd = -1\n } else {\n lineEnd = crIndex\n }\n } else if (lfIndex !== -1) {\n lineEnd = lfIndex\n }\n\n if (lineEnd === -1) {\n break\n }\n\n parseLine(chunk, searchIndex, lineEnd)\n searchIndex = lineEnd + 1\n // If we just consumed a `\\r` and the next char is `\\n`, skip it so the\n // pair is treated as a single terminator rather than an empty line.\n if (chunk.charCodeAt(searchIndex - 1) === CR && chunk.charCodeAt(searchIndex) === LF) {\n searchIndex++\n }\n }\n\n return chunk.slice(searchIndex)\n }\n\n function parseLine(chunk: string, start: number, end: number) {\n if (start === end) {\n dispatchEvent()\n return\n }\n\n const firstCharCode = chunk.charCodeAt(start)\n\n if (isDataPrefix(chunk, start, firstCharCode)) {\n // 'data:'.length === 5, 'data: '.length === 6\n const valueStart = chunk.charCodeAt(start + 5) === SPACE ? start + 6 : start + 5\n const value = chunk.slice(valueStart, end)\n data = dataLines === 0 ? value : `${data}\\n${value}`\n dataLines++\n return\n }\n\n if (isEventPrefix(chunk, start, firstCharCode)) {\n // 'event:'.length === 6, 'event: '.length === 7\n eventType =\n chunk.slice(chunk.charCodeAt(start + 6) === SPACE ? start + 7 : start + 6, end) || undefined\n return\n }\n\n // Fast path for \"id:\" — 'i' = 105, 'd' = 100, ':' = 58\n if (\n firstCharCode === 105 &&\n chunk.charCodeAt(start + 1) === 100 &&\n chunk.charCodeAt(start + 2) === 58\n ) {\n // 'id:'.length === 3, 'id: '.length === 4\n const value = chunk.slice(chunk.charCodeAt(start + 3) === SPACE ? start + 4 : start + 3, end)\n id = value.includes('\\0') ? undefined : value\n return\n }\n\n // Comment line — ':' = 58\n if (firstCharCode === 58) {\n if (onComment) {\n const line = chunk.slice(start, end)\n // skip ':' (+1), or ': ' (+2) when a space follows\n onComment(line.slice(chunk.charCodeAt(start + 1) === SPACE ? 2 : 1))\n }\n return\n }\n\n const line = chunk.slice(start, end)\n const fieldSeparatorIndex = line.indexOf(':')\n if (fieldSeparatorIndex === -1) {\n processField(line, '', line)\n return\n }\n\n const field = line.slice(0, fieldSeparatorIndex)\n // skip ':' (+1), or ': ' (+2) when a space follows\n const offset = line.charCodeAt(fieldSeparatorIndex + 1) === SPACE ? 2 : 1\n const value = line.slice(fieldSeparatorIndex + offset)\n processField(field, value, line)\n }\n\n function processField(field: string, value: string, line: string) {\n // Field names must be compared literally, with no case folding performed.\n switch (field) {\n case 'event':\n // Set the `event type` buffer to field value\n eventType = value || undefined\n break\n case 'data':\n data = dataLines === 0 ? value : `${data}\\n${value}`\n dataLines++\n break\n case 'id':\n // If the field value does not contain U+0000 NULL, then set the `ID` buffer to\n // the field value. Otherwise, ignore the field.\n id = value.includes('\\0') ? undefined : value\n break\n case 'retry':\n // If the field value consists of only ASCII digits, then interpret the field value as an\n // integer in base ten, and set the event stream's reconnection time to that integer.\n // Otherwise, ignore the field.\n if (/^\\d+$/.test(value)) {\n onRetry(parseInt(value, 10))\n } else {\n onError(\n new ParseError(`Invalid \\`retry\\` value: \"${value}\"`, {\n type: 'invalid-retry',\n value,\n line,\n }),\n )\n }\n break\n default:\n // Otherwise, the field is ignored.\n onError(\n new ParseError(\n `Unknown field \"${field.length > 20 ? `${field.slice(0, 20)}…` : field}\"`,\n {type: 'unknown-field', field, value, line},\n ),\n )\n break\n }\n }\n\n function dispatchEvent() {\n if (dataLines > 0) {\n onEvent({\n id,\n event: eventType,\n data,\n })\n }\n\n id = undefined\n data = ''\n dataLines = 0\n eventType = undefined\n }\n\n function reset(options: {consume?: boolean} = {}) {\n if (options.consume && pendingFragments.length > 0) {\n const incompleteLine = pendingFragments.join('')\n parseLine(incompleteLine, 0, incompleteLine.length)\n }\n\n isFirstChunk = true\n id = undefined\n data = ''\n dataLines = 0\n eventType = undefined\n pendingFragments.length = 0\n }\n\n return {feed, reset}\n}\n\n/**\n * Checks if `chunk` starts with the literal `data:` at index `i`.\n *\n * Equivalent to `chunk.startsWith('data:', i)`, but benchmarks show this\n * hand-unrolled char-code comparison is ~20% faster on common event types.\n * The caller passes `firstCharCode` (the code at `i`) so it can be reused\n * across prefix checks.\n *\n * ASCII: 'd' = 100, 'a' = 97, 't' = 116, 'a' = 97, ':' = 58\n */\nfunction isDataPrefix(chunk: string, i: number, firstCharCode: number): boolean {\n return (\n firstCharCode === 100 &&\n chunk.charCodeAt(i + 1) === 97 &&\n chunk.charCodeAt(i + 2) === 116 &&\n chunk.charCodeAt(i + 3) === 97 &&\n chunk.charCodeAt(i + 4) === 58\n )\n}\n\n/**\n * Checks if `chunk` starts with the literal `event:` at index `i`.\n *\n * See {@link isDataPrefix} for why this is hand-unrolled rather than using\n * `String.prototype.startsWith`.\n *\n * ASCII: 'e' = 101, 'v' = 118, 'e' = 101, 'n' = 110, 't' = 116, ':' = 58\n */\nfunction isEventPrefix(chunk: string, i: number, firstCharCode: number): boolean {\n return (\n firstCharCode === 101 &&\n chunk.charCodeAt(i + 1) === 118 &&\n chunk.charCodeAt(i + 2) === 101 &&\n chunk.charCodeAt(i + 3) === 110 &&\n chunk.charCodeAt(i + 4) === 116 &&\n chunk.charCodeAt(i + 5) === 58\n )\n}\n"],"names":["trailing","value","line"],"mappings":"AAWO,MAAM,mBAAmB,MAAM;AAAA,EAqBpC,YACE,SACA,SACA;AACA,UAAM,OAAO,GACb,KAAK,OAAO,cACZ,KAAK,OAAO,QAAQ,MACpB,KAAK,QAAQ,QAAQ,OACrB,KAAK,QAAQ,QAAQ,OACrB,KAAK,OAAO,QAAQ;AAAA,EACtB;AACF;ACnCA,MAAM,KAAK,IACL,KAAK,IACL,QAAQ;AAGd,SAAS,KAAK,MAAe;AAE7B;AAcO,SAAS,aAAa,WAA+C;AAC1E,MAAI,OAAO,aAAc;AACvB,UAAM,IAAI;AAAA,MACR;AAAA,IAAA;AAIJ,QAAM,EAAC,UAAU,MAAM,UAAU,MAAM,UAAU,MAAM,UAAA,IAAa,WAQ9D,mBAA6B,CAAA;AAEnC,MAAI,eAAe,IACf,IACA,OAAO,IACP,YAAY,GACZ;AAaJ,WAAS,KAAK,OAAe;AAiB3B,QAhBI,iBACF,eAAe,IAIb,MAAM,WAAW,CAAC,MAAM,OACxB,MAAM,WAAW,CAAC,MAAM,OACxB,MAAM,WAAW,CAAC,MAAM,QAExB,QAAQ,MAAM,MAA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AW,IAAI,CAAC,MAAM,OAC5B,MAAM,WAAW,IAAI,CAAC,MAAM,OAC5B,MAAM,WAAW,IAAI,CAAC,MAAM;AAEhC;"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3
|
-
var index = require("./index.cjs");
|
|
4
|
-
class EventSourceParserStream extends TransformStream {
|
|
5
|
-
constructor({ onError, onRetry, onComment } = {}) {
|
|
6
|
-
let parser;
|
|
7
|
-
super({
|
|
8
|
-
start(controller) {
|
|
9
|
-
parser = index.createParser({
|
|
10
|
-
onEvent: (event) => {
|
|
11
|
-
controller.enqueue(event);
|
|
12
|
-
},
|
|
13
|
-
onError(error) {
|
|
14
|
-
onError === "terminate" ? controller.error(error) : typeof onError == "function" && onError(error);
|
|
15
|
-
},
|
|
16
|
-
onRetry,
|
|
17
|
-
onComment
|
|
18
|
-
});
|
|
19
|
-
},
|
|
20
|
-
transform(chunk) {
|
|
21
|
-
parser.feed(chunk);
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
exports.ParseError = index.ParseError;
|
|
27
|
-
exports.EventSourceParserStream = EventSourceParserStream;
|
|
28
|
-
//# sourceMappingURL=stream.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stream.cjs","sources":["../src/stream.ts"],"sourcesContent":["import {createParser} from './parse.ts'\nimport type {EventSourceMessage, EventSourceParser} from './types.ts'\n\n/**\n * Options for the EventSourceParserStream.\n *\n * @public\n */\nexport interface StreamOptions {\n /**\n * Behavior when a parsing error occurs.\n *\n * - A custom function can be provided to handle the error.\n * - `'terminate'` will error the stream and stop parsing.\n * - Any other value will ignore the error and continue parsing.\n *\n * @defaultValue `undefined`\n */\n onError?: ('terminate' | ((error: Error) => void)) | undefined\n\n /**\n * Callback for when a reconnection interval is sent from the server.\n *\n * @param retry - The number of milliseconds to wait before reconnecting.\n */\n onRetry?: ((retry: number) => void) | undefined\n\n /**\n * Callback for when a comment is encountered in the stream.\n *\n * @param comment - The comment encountered in the stream.\n */\n onComment?: ((comment: string) => void) | undefined\n}\n\n/**\n * A TransformStream that ingests a stream of strings and produces a stream of `EventSourceMessage`.\n *\n * @example Basic usage\n * ```\n * const eventStream =\n * response.body\n * .pipeThrough(new TextDecoderStream())\n * .pipeThrough(new EventSourceParserStream())\n * ```\n *\n * @example Terminate stream on parsing errors\n * ```\n * const eventStream =\n * response.body\n * .pipeThrough(new TextDecoderStream())\n * .pipeThrough(new EventSourceParserStream({terminateOnError: true}))\n * ```\n *\n * @public\n */\nexport class EventSourceParserStream extends TransformStream<string, EventSourceMessage> {\n constructor({onError, onRetry, onComment}: StreamOptions = {}) {\n let parser!: EventSourceParser\n\n super({\n start(controller) {\n parser = createParser({\n onEvent: (event) => {\n controller.enqueue(event)\n },\n onError(error) {\n if (onError === 'terminate') {\n controller.error(error)\n } else if (typeof onError === 'function') {\n onError(error)\n }\n\n // Ignore by default\n },\n onRetry,\n onComment,\n })\n },\n transform(chunk) {\n parser.feed(chunk)\n },\n })\n }\n}\n\nexport {type ErrorType, ParseError} from './errors.ts'\nexport type {EventSourceMessage} from './types.ts'\n"],"names":["createParser"],"mappings":";;;AAwDO,MAAM,gCAAgC,gBAA4C;AAAA,EACvF,YAAY,EAAC,SAAS,SAAS,UAAA,IAA4B,CAAA,GAAI;AAC7D,QAAI;AAEJ,UAAM;AAAA,MACJ,MAAM,YAAY;AAChB,iBAASA,MAAAA,aAAa;AAAA,UACpB,SAAS,CAAC,UAAU;AAClB,uBAAW,QAAQ,KAAK;AAAA,UAC1B;AAAA,UACA,QAAQ,OAAO;AACT,wBAAY,cACd,WAAW,MAAM,KAAK,IACb,OAAO,WAAY,cAC5B,QAAQ,KAAK;AAAA,UAIjB;AAAA,UACA;AAAA,UACA;AAAA,QAAA,CACD;AAAA,MACH;AAAA,MACA,UAAU,OAAO;AACf,eAAO,KAAK,KAAK;AAAA,MACnB;AAAA,IAAA,CACD;AAAA,EACH;AACF;;;"}
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The type of error that occurred.
|
|
3
|
-
* @public
|
|
4
|
-
*/
|
|
5
|
-
export declare type ErrorType = "invalid-retry" | "unknown-field";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* A parsed EventSource message event
|
|
9
|
-
*
|
|
10
|
-
* @public
|
|
11
|
-
*/
|
|
12
|
-
export declare interface EventSourceMessage {
|
|
13
|
-
/**
|
|
14
|
-
* The event type sent from the server. Note that this differs from the browser `EventSource`
|
|
15
|
-
* implementation in that browsers will default this to `message`, whereas this parser will
|
|
16
|
-
* leave this as `undefined` if not explicitly declared.
|
|
17
|
-
*/
|
|
18
|
-
event?: string | undefined;
|
|
19
|
-
/**
|
|
20
|
-
* ID of the message, if any was provided by the server. Can be used by clients to keep the
|
|
21
|
-
* last received message ID in sync when reconnecting.
|
|
22
|
-
*/
|
|
23
|
-
id?: string | undefined;
|
|
24
|
-
/**
|
|
25
|
-
* The data received for this message
|
|
26
|
-
*/
|
|
27
|
-
data: string;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* A TransformStream that ingests a stream of strings and produces a stream of `EventSourceMessage`.
|
|
32
|
-
*
|
|
33
|
-
* @example Basic usage
|
|
34
|
-
* ```
|
|
35
|
-
* const eventStream =
|
|
36
|
-
* response.body
|
|
37
|
-
* .pipeThrough(new TextDecoderStream())
|
|
38
|
-
* .pipeThrough(new EventSourceParserStream())
|
|
39
|
-
* ```
|
|
40
|
-
*
|
|
41
|
-
* @example Terminate stream on parsing errors
|
|
42
|
-
* ```
|
|
43
|
-
* const eventStream =
|
|
44
|
-
* response.body
|
|
45
|
-
* .pipeThrough(new TextDecoderStream())
|
|
46
|
-
* .pipeThrough(new EventSourceParserStream({terminateOnError: true}))
|
|
47
|
-
* ```
|
|
48
|
-
*
|
|
49
|
-
* @public
|
|
50
|
-
*/
|
|
51
|
-
export declare class EventSourceParserStream extends TransformStream<
|
|
52
|
-
string,
|
|
53
|
-
EventSourceMessage
|
|
54
|
-
> {
|
|
55
|
-
constructor({ onError, onRetry, onComment }?: StreamOptions);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Error thrown when encountering an issue during parsing.
|
|
60
|
-
*
|
|
61
|
-
* @public
|
|
62
|
-
*/
|
|
63
|
-
export declare class ParseError extends Error {
|
|
64
|
-
/**
|
|
65
|
-
* The type of error that occurred.
|
|
66
|
-
*/
|
|
67
|
-
type: ErrorType;
|
|
68
|
-
/**
|
|
69
|
-
* In the case of an unknown field encountered in the stream, this will be the field name.
|
|
70
|
-
*/
|
|
71
|
-
field?: string | undefined;
|
|
72
|
-
/**
|
|
73
|
-
* In the case of an unknown field encountered in the stream, this will be the value of the field.
|
|
74
|
-
*/
|
|
75
|
-
value?: string | undefined;
|
|
76
|
-
/**
|
|
77
|
-
* The line that caused the error, if available.
|
|
78
|
-
*/
|
|
79
|
-
line?: string | undefined;
|
|
80
|
-
constructor(
|
|
81
|
-
message: string,
|
|
82
|
-
options: {
|
|
83
|
-
type: ErrorType;
|
|
84
|
-
field?: string;
|
|
85
|
-
value?: string;
|
|
86
|
-
line?: string;
|
|
87
|
-
},
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Options for the EventSourceParserStream.
|
|
93
|
-
*
|
|
94
|
-
* @public
|
|
95
|
-
*/
|
|
96
|
-
export declare interface StreamOptions {
|
|
97
|
-
/**
|
|
98
|
-
* Behavior when a parsing error occurs.
|
|
99
|
-
*
|
|
100
|
-
* - A custom function can be provided to handle the error.
|
|
101
|
-
* - `'terminate'` will error the stream and stop parsing.
|
|
102
|
-
* - Any other value will ignore the error and continue parsing.
|
|
103
|
-
*
|
|
104
|
-
* @defaultValue `undefined`
|
|
105
|
-
*/
|
|
106
|
-
onError?: ("terminate" | ((error: Error) => void)) | undefined;
|
|
107
|
-
/**
|
|
108
|
-
* Callback for when a reconnection interval is sent from the server.
|
|
109
|
-
*
|
|
110
|
-
* @param retry - The number of milliseconds to wait before reconnecting.
|
|
111
|
-
*/
|
|
112
|
-
onRetry?: ((retry: number) => void) | undefined;
|
|
113
|
-
/**
|
|
114
|
-
* Callback for when a comment is encountered in the stream.
|
|
115
|
-
*
|
|
116
|
-
* @param comment - The comment encountered in the stream.
|
|
117
|
-
*/
|
|
118
|
-
onComment?: ((comment: string) => void) | undefined;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export {};
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The type of error that occurred.
|
|
3
|
-
* @public
|
|
4
|
-
*/
|
|
5
|
-
export declare type ErrorType = "invalid-retry" | "unknown-field";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* A parsed EventSource message event
|
|
9
|
-
*
|
|
10
|
-
* @public
|
|
11
|
-
*/
|
|
12
|
-
export declare interface EventSourceMessage {
|
|
13
|
-
/**
|
|
14
|
-
* The event type sent from the server. Note that this differs from the browser `EventSource`
|
|
15
|
-
* implementation in that browsers will default this to `message`, whereas this parser will
|
|
16
|
-
* leave this as `undefined` if not explicitly declared.
|
|
17
|
-
*/
|
|
18
|
-
event?: string | undefined;
|
|
19
|
-
/**
|
|
20
|
-
* ID of the message, if any was provided by the server. Can be used by clients to keep the
|
|
21
|
-
* last received message ID in sync when reconnecting.
|
|
22
|
-
*/
|
|
23
|
-
id?: string | undefined;
|
|
24
|
-
/**
|
|
25
|
-
* The data received for this message
|
|
26
|
-
*/
|
|
27
|
-
data: string;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* A TransformStream that ingests a stream of strings and produces a stream of `EventSourceMessage`.
|
|
32
|
-
*
|
|
33
|
-
* @example Basic usage
|
|
34
|
-
* ```
|
|
35
|
-
* const eventStream =
|
|
36
|
-
* response.body
|
|
37
|
-
* .pipeThrough(new TextDecoderStream())
|
|
38
|
-
* .pipeThrough(new EventSourceParserStream())
|
|
39
|
-
* ```
|
|
40
|
-
*
|
|
41
|
-
* @example Terminate stream on parsing errors
|
|
42
|
-
* ```
|
|
43
|
-
* const eventStream =
|
|
44
|
-
* response.body
|
|
45
|
-
* .pipeThrough(new TextDecoderStream())
|
|
46
|
-
* .pipeThrough(new EventSourceParserStream({terminateOnError: true}))
|
|
47
|
-
* ```
|
|
48
|
-
*
|
|
49
|
-
* @public
|
|
50
|
-
*/
|
|
51
|
-
export declare class EventSourceParserStream extends TransformStream<
|
|
52
|
-
string,
|
|
53
|
-
EventSourceMessage
|
|
54
|
-
> {
|
|
55
|
-
constructor({ onError, onRetry, onComment }?: StreamOptions);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Error thrown when encountering an issue during parsing.
|
|
60
|
-
*
|
|
61
|
-
* @public
|
|
62
|
-
*/
|
|
63
|
-
export declare class ParseError extends Error {
|
|
64
|
-
/**
|
|
65
|
-
* The type of error that occurred.
|
|
66
|
-
*/
|
|
67
|
-
type: ErrorType;
|
|
68
|
-
/**
|
|
69
|
-
* In the case of an unknown field encountered in the stream, this will be the field name.
|
|
70
|
-
*/
|
|
71
|
-
field?: string | undefined;
|
|
72
|
-
/**
|
|
73
|
-
* In the case of an unknown field encountered in the stream, this will be the value of the field.
|
|
74
|
-
*/
|
|
75
|
-
value?: string | undefined;
|
|
76
|
-
/**
|
|
77
|
-
* The line that caused the error, if available.
|
|
78
|
-
*/
|
|
79
|
-
line?: string | undefined;
|
|
80
|
-
constructor(
|
|
81
|
-
message: string,
|
|
82
|
-
options: {
|
|
83
|
-
type: ErrorType;
|
|
84
|
-
field?: string;
|
|
85
|
-
value?: string;
|
|
86
|
-
line?: string;
|
|
87
|
-
},
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Options for the EventSourceParserStream.
|
|
93
|
-
*
|
|
94
|
-
* @public
|
|
95
|
-
*/
|
|
96
|
-
export declare interface StreamOptions {
|
|
97
|
-
/**
|
|
98
|
-
* Behavior when a parsing error occurs.
|
|
99
|
-
*
|
|
100
|
-
* - A custom function can be provided to handle the error.
|
|
101
|
-
* - `'terminate'` will error the stream and stop parsing.
|
|
102
|
-
* - Any other value will ignore the error and continue parsing.
|
|
103
|
-
*
|
|
104
|
-
* @defaultValue `undefined`
|
|
105
|
-
*/
|
|
106
|
-
onError?: ("terminate" | ((error: Error) => void)) | undefined;
|
|
107
|
-
/**
|
|
108
|
-
* Callback for when a reconnection interval is sent from the server.
|
|
109
|
-
*
|
|
110
|
-
* @param retry - The number of milliseconds to wait before reconnecting.
|
|
111
|
-
*/
|
|
112
|
-
onRetry?: ((retry: number) => void) | undefined;
|
|
113
|
-
/**
|
|
114
|
-
* Callback for when a comment is encountered in the stream.
|
|
115
|
-
*
|
|
116
|
-
* @param comment - The comment encountered in the stream.
|
|
117
|
-
*/
|
|
118
|
-
onComment?: ((comment: string) => void) | undefined;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export {};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { createParser } from "./index.js";
|
|
2
|
-
import { ParseError } from "./index.js";
|
|
3
|
-
class EventSourceParserStream extends TransformStream {
|
|
4
|
-
constructor({ onError, onRetry, onComment } = {}) {
|
|
5
|
-
let parser;
|
|
6
|
-
super({
|
|
7
|
-
start(controller) {
|
|
8
|
-
parser = createParser({
|
|
9
|
-
onEvent: (event) => {
|
|
10
|
-
controller.enqueue(event);
|
|
11
|
-
},
|
|
12
|
-
onError(error) {
|
|
13
|
-
onError === "terminate" ? controller.error(error) : typeof onError == "function" && onError(error);
|
|
14
|
-
},
|
|
15
|
-
onRetry,
|
|
16
|
-
onComment
|
|
17
|
-
});
|
|
18
|
-
},
|
|
19
|
-
transform(chunk) {
|
|
20
|
-
parser.feed(chunk);
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
export {
|
|
26
|
-
EventSourceParserStream,
|
|
27
|
-
ParseError
|
|
28
|
-
};
|
|
29
|
-
//# sourceMappingURL=stream.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stream.js","sources":["../src/stream.ts"],"sourcesContent":["import {createParser} from './parse.ts'\nimport type {EventSourceMessage, EventSourceParser} from './types.ts'\n\n/**\n * Options for the EventSourceParserStream.\n *\n * @public\n */\nexport interface StreamOptions {\n /**\n * Behavior when a parsing error occurs.\n *\n * - A custom function can be provided to handle the error.\n * - `'terminate'` will error the stream and stop parsing.\n * - Any other value will ignore the error and continue parsing.\n *\n * @defaultValue `undefined`\n */\n onError?: ('terminate' | ((error: Error) => void)) | undefined\n\n /**\n * Callback for when a reconnection interval is sent from the server.\n *\n * @param retry - The number of milliseconds to wait before reconnecting.\n */\n onRetry?: ((retry: number) => void) | undefined\n\n /**\n * Callback for when a comment is encountered in the stream.\n *\n * @param comment - The comment encountered in the stream.\n */\n onComment?: ((comment: string) => void) | undefined\n}\n\n/**\n * A TransformStream that ingests a stream of strings and produces a stream of `EventSourceMessage`.\n *\n * @example Basic usage\n * ```\n * const eventStream =\n * response.body\n * .pipeThrough(new TextDecoderStream())\n * .pipeThrough(new EventSourceParserStream())\n * ```\n *\n * @example Terminate stream on parsing errors\n * ```\n * const eventStream =\n * response.body\n * .pipeThrough(new TextDecoderStream())\n * .pipeThrough(new EventSourceParserStream({terminateOnError: true}))\n * ```\n *\n * @public\n */\nexport class EventSourceParserStream extends TransformStream<string, EventSourceMessage> {\n constructor({onError, onRetry, onComment}: StreamOptions = {}) {\n let parser!: EventSourceParser\n\n super({\n start(controller) {\n parser = createParser({\n onEvent: (event) => {\n controller.enqueue(event)\n },\n onError(error) {\n if (onError === 'terminate') {\n controller.error(error)\n } else if (typeof onError === 'function') {\n onError(error)\n }\n\n // Ignore by default\n },\n onRetry,\n onComment,\n })\n },\n transform(chunk) {\n parser.feed(chunk)\n },\n })\n }\n}\n\nexport {type ErrorType, ParseError} from './errors.ts'\nexport type {EventSourceMessage} from './types.ts'\n"],"names":[],"mappings":";;AAwDO,MAAM,gCAAgC,gBAA4C;AAAA,EACvF,YAAY,EAAC,SAAS,SAAS,UAAA,IAA4B,CAAA,GAAI;AAC7D,QAAI;AAEJ,UAAM;AAAA,MACJ,MAAM,YAAY;AAChB,iBAAS,aAAa;AAAA,UACpB,SAAS,CAAC,UAAU;AAClB,uBAAW,QAAQ,KAAK;AAAA,UAC1B;AAAA,UACA,QAAQ,OAAO;AACT,wBAAY,cACd,WAAW,MAAM,KAAK,IACb,OAAO,WAAY,cAC5B,QAAQ,KAAK;AAAA,UAIjB;AAAA,UACA;AAAA,UACA;AAAA,QAAA,CACD;AAAA,MACH;AAAA,MACA,UAAU,OAAO;AACf,eAAO,KAAK,KAAK;AAAA,MACnB;AAAA,IAAA,CACD;AAAA,EACH;AACF;"}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "eventsource-parser",
|
|
3
|
-
"version": "3.0.8",
|
|
4
|
-
"description": "Streaming, source-agnostic EventSource/Server-Sent Events parser",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"eventsource",
|
|
7
|
-
"server-sent-events",
|
|
8
|
-
"sse"
|
|
9
|
-
],
|
|
10
|
-
"homepage": "https://github.com/rexxars/eventsource-parser#readme",
|
|
11
|
-
"bugs": {
|
|
12
|
-
"url": "https://github.com/rexxars/eventsource-parser/issues"
|
|
13
|
-
},
|
|
14
|
-
"license": "MIT",
|
|
15
|
-
"author": "Espen Hovlandsdal <espen@hovlandsdal.com>",
|
|
16
|
-
"repository": {
|
|
17
|
-
"type": "git",
|
|
18
|
-
"url": "git+ssh://git@github.com/rexxars/eventsource-parser.git"
|
|
19
|
-
},
|
|
20
|
-
"files": [
|
|
21
|
-
"dist",
|
|
22
|
-
"!dist/stats.html",
|
|
23
|
-
"!dist/index.min.js",
|
|
24
|
-
"src",
|
|
25
|
-
"stream.js"
|
|
26
|
-
],
|
|
27
|
-
"type": "module",
|
|
28
|
-
"sideEffects": false,
|
|
29
|
-
"main": "./dist/index.cjs",
|
|
30
|
-
"module": "./dist/index.js",
|
|
31
|
-
"types": "./dist/index.d.ts",
|
|
32
|
-
"exports": {
|
|
33
|
-
".": {
|
|
34
|
-
"source": "./src/index.ts",
|
|
35
|
-
"import": "./dist/index.js",
|
|
36
|
-
"require": "./dist/index.cjs",
|
|
37
|
-
"default": "./dist/index.js"
|
|
38
|
-
},
|
|
39
|
-
"./stream": {
|
|
40
|
-
"source": "./src/stream.ts",
|
|
41
|
-
"import": "./dist/stream.js",
|
|
42
|
-
"require": "./dist/stream.cjs",
|
|
43
|
-
"default": "./dist/stream.js"
|
|
44
|
-
},
|
|
45
|
-
"./package.json": "./package.json"
|
|
46
|
-
},
|
|
47
|
-
"scripts": {
|
|
48
|
-
"build": "pkg-utils build && pkg-utils --strict",
|
|
49
|
-
"clean": "rimraf dist coverage",
|
|
50
|
-
"check": "npm run clean && npm run format && npm run lint && npm run build && vitest run",
|
|
51
|
-
"format": "oxfmt",
|
|
52
|
-
"format:check": "oxfmt --check",
|
|
53
|
-
"bench": "node --expose-gc --experimental-strip-types --no-warnings=ExperimentalWarning bench/parse.bench.ts",
|
|
54
|
-
"bundle-size": "node --experimental-strip-types --no-warnings=ExperimentalWarning scripts/bundle-size.ts",
|
|
55
|
-
"knip": "knip",
|
|
56
|
-
"lint": "oxlint && tsc --noEmit",
|
|
57
|
-
"posttest": "npm run lint",
|
|
58
|
-
"prebuild": "npm run clean",
|
|
59
|
-
"prepublishOnly": "npm run build",
|
|
60
|
-
"test": "npm run test:node",
|
|
61
|
-
"test:bun": "bun test",
|
|
62
|
-
"test:deno": "deno run --allow-write --allow-net --allow-run --allow-sys --allow-ffi --allow-env --allow-read npm:vitest",
|
|
63
|
-
"test:node": "vitest --reporter=verbose"
|
|
64
|
-
},
|
|
65
|
-
"devDependencies": {
|
|
66
|
-
"@sanity/pkg-utils": "^10.4.15",
|
|
67
|
-
"@sanity/semantic-release-preset": "^6.0.0",
|
|
68
|
-
"@sanity/tsconfig": "^2.1.0",
|
|
69
|
-
"@types/node": "^20.19.0",
|
|
70
|
-
"eventsource-encoder": "^1.0.1",
|
|
71
|
-
"knip": "^6.4.1",
|
|
72
|
-
"mitata": "^1.0.34",
|
|
73
|
-
"oxfmt": "^0.45.0",
|
|
74
|
-
"oxlint": "^1.60.0",
|
|
75
|
-
"rimraf": "^6.1.3",
|
|
76
|
-
"rollup-plugin-visualizer": "^6.0.3",
|
|
77
|
-
"semantic-release": "^25.0.3",
|
|
78
|
-
"terser": "^5.46.1",
|
|
79
|
-
"typescript": "^5.9.3",
|
|
80
|
-
"vitest": "^4.1.4"
|
|
81
|
-
},
|
|
82
|
-
"browserslist": [
|
|
83
|
-
"node >= 18",
|
|
84
|
-
"chrome >= 71",
|
|
85
|
-
"safari >= 14.1",
|
|
86
|
-
"firefox >= 105",
|
|
87
|
-
"edge >= 79"
|
|
88
|
-
],
|
|
89
|
-
"engines": {
|
|
90
|
-
"node": ">=18.0.0"
|
|
91
|
-
}
|
|
92
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The type of error that occurred.
|
|
3
|
-
* @public
|
|
4
|
-
*/
|
|
5
|
-
export type ErrorType = 'invalid-retry' | 'unknown-field'
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Error thrown when encountering an issue during parsing.
|
|
9
|
-
*
|
|
10
|
-
* @public
|
|
11
|
-
*/
|
|
12
|
-
export class ParseError extends Error {
|
|
13
|
-
/**
|
|
14
|
-
* The type of error that occurred.
|
|
15
|
-
*/
|
|
16
|
-
type: ErrorType
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* In the case of an unknown field encountered in the stream, this will be the field name.
|
|
20
|
-
*/
|
|
21
|
-
field?: string | undefined
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* In the case of an unknown field encountered in the stream, this will be the value of the field.
|
|
25
|
-
*/
|
|
26
|
-
value?: string | undefined
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* The line that caused the error, if available.
|
|
30
|
-
*/
|
|
31
|
-
line?: string | undefined
|
|
32
|
-
|
|
33
|
-
constructor(
|
|
34
|
-
message: string,
|
|
35
|
-
options: {type: ErrorType; field?: string; value?: string; line?: string},
|
|
36
|
-
) {
|
|
37
|
-
super(message)
|
|
38
|
-
this.name = 'ParseError'
|
|
39
|
-
this.type = options.type
|
|
40
|
-
this.field = options.field
|
|
41
|
-
this.value = options.value
|
|
42
|
-
this.line = options.line
|
|
43
|
-
}
|
|
44
|
-
}
|