vscode-jsonrpc
Advanced tools
Comparing version 8.1.0-next.3 to 8.1.0-next.4
@@ -77,2 +77,1 @@ "use strict"; | ||
exports.createMessageConnection = createMessageConnection; | ||
//# sourceMappingURL=main.js.map |
@@ -157,2 +157,1 @@ "use strict"; | ||
exports.default = RIL; | ||
//# sourceMappingURL=ril.js.map |
@@ -79,2 +79,1 @@ "use strict"; | ||
exports.RAL = ral_1.default; | ||
//# sourceMappingURL=api.js.map |
@@ -14,3 +14,3 @@ import { Event } from './events'; | ||
/** | ||
* An [event](#Event) which fires upon cancellation. | ||
* An {@link Event event} which fires upon cancellation. | ||
*/ | ||
@@ -17,0 +17,0 @@ readonly onCancellationRequested: Event<any>; |
@@ -97,2 +97,1 @@ "use strict"; | ||
exports.CancellationTokenSource = CancellationTokenSource; | ||
//# sourceMappingURL=cancellation.js.map |
@@ -950,3 +950,6 @@ "use strict"; | ||
traceSendingNotification(notificationMessage); | ||
return messageWriter.write(notificationMessage).catch(() => logger.error(`Sending notification failed.`)); | ||
return messageWriter.write(notificationMessage).catch((error) => { | ||
logger.error(`Sending notification failed.`); | ||
throw error; | ||
}); | ||
}, | ||
@@ -992,2 +995,4 @@ onNotification: (type, handler) => { | ||
sendProgress: (_type, token, value) => { | ||
// This should not await but simple return to ensure that we don't have another | ||
// async scheduling. Otherwise one send could overtake another send. | ||
return connection.sendNotification(ProgressNotification.type, { token, value }); | ||
@@ -1056,9 +1061,13 @@ }, | ||
} | ||
const result = new Promise((resolve, reject) => { | ||
const requestMessage = { | ||
jsonrpc: version, | ||
id: id, | ||
method: method, | ||
params: messageParams | ||
}; | ||
const requestMessage = { | ||
jsonrpc: version, | ||
id: id, | ||
method: method, | ||
params: messageParams | ||
}; | ||
traceSendingRequest(requestMessage); | ||
if (typeof cancellationStrategy.sender.enableCancellation === 'function') { | ||
cancellationStrategy.sender.enableCancellation(requestMessage); | ||
} | ||
return new Promise(async (resolve, reject) => { | ||
const resolveWithCleanup = (r) => { | ||
@@ -1074,20 +1083,14 @@ resolve(r); | ||
}; | ||
let responsePromise = { method: method, timerStart: Date.now(), resolve: resolveWithCleanup, reject: rejectWithCleanup }; | ||
traceSendingRequest(requestMessage); | ||
const responsePromise = { method: method, timerStart: Date.now(), resolve: resolveWithCleanup, reject: rejectWithCleanup }; | ||
try { | ||
if (typeof cancellationStrategy.sender.enableCancellation === 'function') { | ||
cancellationStrategy.sender.enableCancellation(requestMessage); | ||
} | ||
messageWriter.write(requestMessage).catch(() => logger.error(`Sending request failed.`)); | ||
await messageWriter.write(requestMessage); | ||
responsePromises.set(id, responsePromise); | ||
} | ||
catch (e) { | ||
catch (error) { | ||
logger.error(`Sending request failed.`); | ||
// Writing the message failed. So we need to reject the promise. | ||
responsePromise.reject(new messages_1.ResponseError(messages_1.ErrorCodes.MessageWriteError, e.message ? e.message : 'Unknown reason')); | ||
responsePromise = null; | ||
responsePromise.reject(new messages_1.ResponseError(messages_1.ErrorCodes.MessageWriteError, error.message ? error.message : 'Unknown reason')); | ||
throw error; | ||
} | ||
if (responsePromise) { | ||
responsePromises.set(id, responsePromise); | ||
} | ||
}); | ||
return result; | ||
}, | ||
@@ -1214,2 +1217,1 @@ onRequest: (type, handler) => { | ||
exports.createMessageConnection = createMessageConnection; | ||
//# sourceMappingURL=connection.js.map |
@@ -17,2 +17,1 @@ "use strict"; | ||
})(Disposable = exports.Disposable || (exports.Disposable = {})); | ||
//# sourceMappingURL=disposable.js.map |
@@ -71,2 +71,1 @@ "use strict"; | ||
})(Encodings = exports.Encodings || (exports.Encodings = {})); | ||
//# sourceMappingURL=encoding.js.map |
@@ -129,2 +129,1 @@ "use strict"; | ||
Emitter._noop = function () { }; | ||
//# sourceMappingURL=events.js.map |
@@ -36,2 +36,1 @@ "use strict"; | ||
exports.stringArray = stringArray; | ||
//# sourceMappingURL=is.js.map |
@@ -399,2 +399,1 @@ "use strict"; | ||
exports.LRUCache = LRUCache; | ||
//# sourceMappingURL=linkedMap.js.map |
@@ -14,3 +14,3 @@ import RAL from './ral'; | ||
append(chunk: Uint8Array | string): void; | ||
tryReadHeaders(): Map<string, string> | undefined; | ||
tryReadHeaders(lowerCaseKeys?: boolean): Map<string, string> | undefined; | ||
tryReadBody(length: number): Uint8Array | undefined; | ||
@@ -17,0 +17,0 @@ get numberOfBytes(): number; |
@@ -25,3 +25,3 @@ "use strict"; | ||
} | ||
tryReadHeaders() { | ||
tryReadHeaders(lowerCaseKeys = false) { | ||
if (this._chunks.length === 0) { | ||
@@ -92,3 +92,3 @@ return undefined; | ||
const value = header.substr(index + 1).trim(); | ||
result.set(key, value); | ||
result.set(lowerCaseKeys ? key.toLowerCase() : key, value); | ||
} | ||
@@ -155,2 +155,1 @@ return result; | ||
exports.AbstractMessageBuffer = AbstractMessageBuffer; | ||
//# sourceMappingURL=messageBuffer.js.map |
@@ -69,2 +69,3 @@ import RAL from './ral'; | ||
private _partialMessageTimeout; | ||
private readSemaphore; | ||
constructor(readable: RAL.ReadableStream, options?: RAL.MessageBufferEncoding | MessageReaderOptions); | ||
@@ -71,0 +72,0 @@ set partialMessageTimeout(timeout: number); |
@@ -11,2 +11,3 @@ "use strict"; | ||
const events_1 = require("./events"); | ||
const semaphore_1 = require("./semaphore"); | ||
var MessageReader; | ||
@@ -109,2 +110,3 @@ (function (MessageReader) { | ||
this.messageToken = 0; | ||
this.readSemaphore = new semaphore_1.Semaphore(1); | ||
} | ||
@@ -133,7 +135,7 @@ set partialMessageTimeout(timeout) { | ||
if (this.nextMessageLength === -1) { | ||
const headers = this.buffer.tryReadHeaders(); | ||
const headers = this.buffer.tryReadHeaders(true); | ||
if (!headers) { | ||
return; | ||
} | ||
const contentLength = headers.get('Content-Length'); | ||
const contentLength = headers.get('content-length'); | ||
if (!contentLength) { | ||
@@ -156,16 +158,13 @@ throw new Error('Header must provide a Content-Length property.'); | ||
this.nextMessageLength = -1; | ||
let p; | ||
if (this.options.contentDecoder !== undefined) { | ||
p = this.options.contentDecoder.decode(body); | ||
} | ||
else { | ||
p = Promise.resolve(body); | ||
} | ||
p.then((value) => { | ||
this.options.contentTypeDecoder.decode(value, this.options).then((msg) => { | ||
this.callback(msg); | ||
}, (error) => { | ||
this.fireError(error); | ||
}); | ||
}, (error) => { | ||
// Make sure that we convert one received message after the | ||
// other. Otherwise it could happen that a decoding of a second | ||
// smaller message finished before the decoding of a first larger | ||
// message and then we would deliver the second message first. | ||
this.readSemaphore.lock(async () => { | ||
const bytes = this.options.contentDecoder !== undefined | ||
? await this.options.contentDecoder.decode(body) | ||
: body; | ||
const message = await this.options.contentTypeDecoder.decode(bytes, this.options); | ||
this.callback(message); | ||
}).catch((error) => { | ||
this.fireError(error); | ||
@@ -196,2 +195,1 @@ }); | ||
exports.ReadableStreamMessageReader = ReadableStreamMessageReader; | ||
//# sourceMappingURL=messageReader.js.map |
@@ -307,2 +307,1 @@ "use strict"; | ||
})(Message = exports.Message || (exports.Message = {})); | ||
//# sourceMappingURL=messages.js.map |
@@ -116,2 +116,1 @@ "use strict"; | ||
exports.WriteableStreamMessageWriter = WriteableStreamMessageWriter; | ||
//# sourceMappingURL=messageWriter.js.map |
@@ -14,5 +14,8 @@ import type { Disposable } from './disposable'; | ||
* | ||
* @param lowerCaseKeys Whether the keys should be stored lower case. Doing | ||
* so is recommended since HTTP headers are case insensitive. | ||
* | ||
* @returns the header properties or undefined in not enough data can be read. | ||
*/ | ||
tryReadHeaders(): Map<string, string> | undefined; | ||
tryReadHeaders(lowerCaseKeys?: boolean): Map<string, string> | undefined; | ||
/** | ||
@@ -19,0 +22,0 @@ * Tries to read the body of the given length. |
@@ -24,2 +24,1 @@ "use strict"; | ||
exports.default = RAL; | ||
//# sourceMappingURL=ral.js.map |
@@ -69,2 +69,1 @@ "use strict"; | ||
exports.Semaphore = Semaphore; | ||
//# sourceMappingURL=semaphore.js.map |
@@ -77,2 +77,1 @@ "use strict"; | ||
exports.SharedArrayReceiverStrategy = SharedArrayReceiverStrategy; | ||
//# sourceMappingURL=sharedArrayCancellation.js.map |
@@ -258,2 +258,1 @@ "use strict"; | ||
exports.createMessageConnection = createMessageConnection; | ||
//# sourceMappingURL=main.js.map |
@@ -162,2 +162,1 @@ "use strict"; | ||
exports.default = RIL; | ||
//# sourceMappingURL=ril.js.map |
{ | ||
"name": "vscode-jsonrpc", | ||
"description": "A json rpc implementation over streams", | ||
"version": "8.1.0-next.3", | ||
"version": "8.1.0-next.4", | ||
"author": "Microsoft Corporation", | ||
@@ -28,7 +28,7 @@ "license": "MIT", | ||
"scripts": { | ||
"prepublishOnly": "git clean -xfd . && npm install && npm run clean && npm run compile && npm test", | ||
"postpublish": "node ../build/npm/post-publish.js", | ||
"prepublishOnly": "echo \"⛔ Can only publish from a secure pipeline ⛔\" && node ../build/npm/fail", | ||
"prepack": "npm run all:publish", | ||
"preversion": "npm test", | ||
"compile": "node ../build/bin/tsc -b ./tsconfig.json", | ||
"watch": "node ../build/bin/tsc -b ./tsconfig-watch.json -w", | ||
"watch": "node ../build/bin/tsc -b ./tsconfig.watch.json -w", | ||
"clean": "node ../node_modules/rimraf/bin.js lib && node ../node_modules/rimraf/bin.js dist", | ||
@@ -41,4 +41,7 @@ "lint": "node ../node_modules/eslint/bin/eslint.js --ext ts src", | ||
"webpack:test": "node ../build/bin/webpack --mode none --config ./src/browser/test/webpack.config.js", | ||
"webpack:test:silent": "node ../build/bin/webpack --no-stats --mode none --config ./src/browser/test/webpack.config.js" | ||
"webpack:test:silent": "node ../build/bin/webpack --no-stats --mode none --config ./src/browser/test/webpack.config.js", | ||
"all": "npm run clean && npm run compile && npm run lint && npm run test", | ||
"compile:publish": "node ../build/bin/tsc -b ./tsconfig.publish.json", | ||
"all:publish": "git clean -xfd . && npm install && npm run compile:publish && npm run lint && npm run test" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
207487
4948
2