ace-linters
Version:
Ace linters is lsp client for Ace editor. It comes with a large number of preconfigured easy to use in browser servers.
1,543 lines • 3.05 MB
JavaScript
(function(global, factory) {
typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define(["exports"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global));
})(this, function(exports) {
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
//#region \0rolldown/runtime.js
var __create$1 = Object.create;
var __defProp$1 = Object.defineProperty;
var __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor;
var __getOwnPropNames$1 = Object.getOwnPropertyNames;
var __getProtoOf$1 = Object.getPrototypeOf;
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
var __esmMin = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
var __exportAll = (all, no_symbols) => {
let target = {};
for (var name in all) __defProp$1(target, name, {
get: all[name],
enumerable: true
});
if (!no_symbols) __defProp$1(target, Symbol.toStringTag, { value: "Module" });
return target;
};
var __copyProps$1 = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames$1(from), i = 0, n = keys.length, key; i < n; i++) {
key = keys[i];
if (!__hasOwnProp$1.call(to, key) && key !== except) __defProp$1(to, key, {
get: ((k) => from[k]).bind(null, key),
enumerable: !(desc = __getOwnPropDesc$1(from, key)) || desc.enumerable
});
}
return to;
};
var __toESM$1 = (mod, isNodeMode, target) => (target = mod != null ? __create$1(__getProtoOf$1(mod)) : {}, __copyProps$1(isNodeMode || !mod || !mod.__esModule ? __defProp$1(target, "default", {
value: mod,
enumerable: true
}) : target, mod));
var __toCommonJS = (mod) => __hasOwnProp$1.call(mod, "module.exports") ? mod["module.exports"] : __copyProps$1(__defProp$1({}, "__esModule", { value: true }), mod);
//#endregion
//#region ../../node_modules/vscode-jsonrpc/lib/common/is.js
var require_is$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
Object.defineProperty(exports, "__esModule", { value: true });
exports.stringArray = exports.array = exports.func = exports.error = exports.number = exports.string = exports.boolean = void 0;
function boolean(value) {
return value === true || value === false;
}
exports.boolean = boolean;
function string(value) {
return typeof value === "string" || value instanceof String;
}
exports.string = string;
function number(value) {
return typeof value === "number" || value instanceof Number;
}
exports.number = number;
function error(value) {
return value instanceof Error;
}
exports.error = error;
function func(value) {
return typeof value === "function";
}
exports.func = func;
function array(value) {
return Array.isArray(value);
}
exports.array = array;
function stringArray(value) {
return array(value) && value.every((elem) => string(elem));
}
exports.stringArray = stringArray;
}));
//#endregion
//#region ../../node_modules/vscode-jsonrpc/lib/common/messages.js
var require_messages$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
Object.defineProperty(exports, "__esModule", { value: true });
exports.Message = exports.NotificationType9 = exports.NotificationType8 = exports.NotificationType7 = exports.NotificationType6 = exports.NotificationType5 = exports.NotificationType4 = exports.NotificationType3 = exports.NotificationType2 = exports.NotificationType1 = exports.NotificationType0 = exports.NotificationType = exports.RequestType9 = exports.RequestType8 = exports.RequestType7 = exports.RequestType6 = exports.RequestType5 = exports.RequestType4 = exports.RequestType3 = exports.RequestType2 = exports.RequestType1 = exports.RequestType = exports.RequestType0 = exports.AbstractMessageSignature = exports.ParameterStructures = exports.ResponseError = exports.ErrorCodes = void 0;
var is = require_is$1();
/**
* Predefined error codes.
*/
var ErrorCodes;
(function(ErrorCodes) {
ErrorCodes.ParseError = -32700;
ErrorCodes.InvalidRequest = -32600;
ErrorCodes.MethodNotFound = -32601;
ErrorCodes.InvalidParams = -32602;
ErrorCodes.InternalError = -32603;
/**
* This is the start range of JSON RPC reserved error codes.
* It doesn't denote a real error code. No application error codes should
* be defined between the start and end range. For backwards
* compatibility the `ServerNotInitialized` and the `UnknownErrorCode`
* are left in the range.
*
* @since 3.16.0
*/
ErrorCodes.jsonrpcReservedErrorRangeStart = -32099;
/** @deprecated use jsonrpcReservedErrorRangeStart */
ErrorCodes.serverErrorStart = -32099;
/**
* An error occurred when write a message to the transport layer.
*/
ErrorCodes.MessageWriteError = -32099;
/**
* An error occurred when reading a message from the transport layer.
*/
ErrorCodes.MessageReadError = -32098;
/**
* The connection got disposed or lost and all pending responses got
* rejected.
*/
ErrorCodes.PendingResponseRejected = -32097;
/**
* The connection is inactive and a use of it failed.
*/
ErrorCodes.ConnectionInactive = -32096;
/**
* Error code indicating that a server received a notification or
* request before the server has received the `initialize` request.
*/
ErrorCodes.ServerNotInitialized = -32002;
ErrorCodes.UnknownErrorCode = -32001;
/**
* This is the end range of JSON RPC reserved error codes.
* It doesn't denote a real error code.
*
* @since 3.16.0
*/
ErrorCodes.jsonrpcReservedErrorRangeEnd = -32e3;
/** @deprecated use jsonrpcReservedErrorRangeEnd */
ErrorCodes.serverErrorEnd = -32e3;
})(ErrorCodes || (exports.ErrorCodes = ErrorCodes = {}));
exports.ResponseError = class ResponseError extends Error {
constructor(code, message, data) {
super(message);
this.code = is.number(code) ? code : ErrorCodes.UnknownErrorCode;
this.data = data;
Object.setPrototypeOf(this, ResponseError.prototype);
}
toJson() {
const result = {
code: this.code,
message: this.message
};
if (this.data !== void 0) result.data = this.data;
return result;
}
};
var ParameterStructures = class ParameterStructures {
constructor(kind) {
this.kind = kind;
}
static is(value) {
return value === ParameterStructures.auto || value === ParameterStructures.byName || value === ParameterStructures.byPosition;
}
toString() {
return this.kind;
}
};
exports.ParameterStructures = ParameterStructures;
/**
* The parameter structure is automatically inferred on the number of parameters
* and the parameter type in case of a single param.
*/
ParameterStructures.auto = new ParameterStructures("auto");
/**
* Forces `byPosition` parameter structure. This is useful if you have a single
* parameter which has a literal type.
*/
ParameterStructures.byPosition = new ParameterStructures("byPosition");
/**
* Forces `byName` parameter structure. This is only useful when having a single
* parameter. The library will report errors if used with a different number of
* parameters.
*/
ParameterStructures.byName = new ParameterStructures("byName");
/**
* An abstract implementation of a MessageType.
*/
var AbstractMessageSignature = class {
constructor(method, numberOfParams) {
this.method = method;
this.numberOfParams = numberOfParams;
}
get parameterStructures() {
return ParameterStructures.auto;
}
};
exports.AbstractMessageSignature = AbstractMessageSignature;
/**
* Classes to type request response pairs
*/
var RequestType0 = class extends AbstractMessageSignature {
constructor(method) {
super(method, 0);
}
};
exports.RequestType0 = RequestType0;
var RequestType = class extends AbstractMessageSignature {
constructor(method, _parameterStructures = ParameterStructures.auto) {
super(method, 1);
this._parameterStructures = _parameterStructures;
}
get parameterStructures() {
return this._parameterStructures;
}
};
exports.RequestType = RequestType;
var RequestType1 = class extends AbstractMessageSignature {
constructor(method, _parameterStructures = ParameterStructures.auto) {
super(method, 1);
this._parameterStructures = _parameterStructures;
}
get parameterStructures() {
return this._parameterStructures;
}
};
exports.RequestType1 = RequestType1;
var RequestType2 = class extends AbstractMessageSignature {
constructor(method) {
super(method, 2);
}
};
exports.RequestType2 = RequestType2;
var RequestType3 = class extends AbstractMessageSignature {
constructor(method) {
super(method, 3);
}
};
exports.RequestType3 = RequestType3;
var RequestType4 = class extends AbstractMessageSignature {
constructor(method) {
super(method, 4);
}
};
exports.RequestType4 = RequestType4;
var RequestType5 = class extends AbstractMessageSignature {
constructor(method) {
super(method, 5);
}
};
exports.RequestType5 = RequestType5;
var RequestType6 = class extends AbstractMessageSignature {
constructor(method) {
super(method, 6);
}
};
exports.RequestType6 = RequestType6;
var RequestType7 = class extends AbstractMessageSignature {
constructor(method) {
super(method, 7);
}
};
exports.RequestType7 = RequestType7;
var RequestType8 = class extends AbstractMessageSignature {
constructor(method) {
super(method, 8);
}
};
exports.RequestType8 = RequestType8;
var RequestType9 = class extends AbstractMessageSignature {
constructor(method) {
super(method, 9);
}
};
exports.RequestType9 = RequestType9;
var NotificationType = class extends AbstractMessageSignature {
constructor(method, _parameterStructures = ParameterStructures.auto) {
super(method, 1);
this._parameterStructures = _parameterStructures;
}
get parameterStructures() {
return this._parameterStructures;
}
};
exports.NotificationType = NotificationType;
var NotificationType0 = class extends AbstractMessageSignature {
constructor(method) {
super(method, 0);
}
};
exports.NotificationType0 = NotificationType0;
var NotificationType1 = class extends AbstractMessageSignature {
constructor(method, _parameterStructures = ParameterStructures.auto) {
super(method, 1);
this._parameterStructures = _parameterStructures;
}
get parameterStructures() {
return this._parameterStructures;
}
};
exports.NotificationType1 = NotificationType1;
var NotificationType2 = class extends AbstractMessageSignature {
constructor(method) {
super(method, 2);
}
};
exports.NotificationType2 = NotificationType2;
var NotificationType3 = class extends AbstractMessageSignature {
constructor(method) {
super(method, 3);
}
};
exports.NotificationType3 = NotificationType3;
var NotificationType4 = class extends AbstractMessageSignature {
constructor(method) {
super(method, 4);
}
};
exports.NotificationType4 = NotificationType4;
var NotificationType5 = class extends AbstractMessageSignature {
constructor(method) {
super(method, 5);
}
};
exports.NotificationType5 = NotificationType5;
var NotificationType6 = class extends AbstractMessageSignature {
constructor(method) {
super(method, 6);
}
};
exports.NotificationType6 = NotificationType6;
var NotificationType7 = class extends AbstractMessageSignature {
constructor(method) {
super(method, 7);
}
};
exports.NotificationType7 = NotificationType7;
var NotificationType8 = class extends AbstractMessageSignature {
constructor(method) {
super(method, 8);
}
};
exports.NotificationType8 = NotificationType8;
var NotificationType9 = class extends AbstractMessageSignature {
constructor(method) {
super(method, 9);
}
};
exports.NotificationType9 = NotificationType9;
var Message;
(function(Message) {
/**
* Tests if the given message is a request message
*/
function isRequest(message) {
const candidate = message;
return candidate && is.string(candidate.method) && (is.string(candidate.id) || is.number(candidate.id));
}
Message.isRequest = isRequest;
/**
* Tests if the given message is a notification message
*/
function isNotification(message) {
const candidate = message;
return candidate && is.string(candidate.method) && message.id === void 0;
}
Message.isNotification = isNotification;
/**
* Tests if the given message is a response message
*/
function isResponse(message) {
const candidate = message;
return candidate && (candidate.result !== void 0 || !!candidate.error) && (is.string(candidate.id) || is.number(candidate.id) || candidate.id === null);
}
Message.isResponse = isResponse;
})(Message || (exports.Message = Message = {}));
}));
//#endregion
//#region ../../node_modules/vscode-jsonrpc/lib/common/linkedMap.js
var require_linkedMap = /* @__PURE__ */ __commonJSMin(((exports) => {
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
exports.LRUCache = exports.LinkedMap = exports.Touch = void 0;
var Touch;
(function(Touch) {
Touch.None = 0;
Touch.First = 1;
Touch.AsOld = Touch.First;
Touch.Last = 2;
Touch.AsNew = Touch.Last;
})(Touch || (exports.Touch = Touch = {}));
var LinkedMap = class {
constructor() {
this[_a] = "LinkedMap";
this._map = /* @__PURE__ */ new Map();
this._head = void 0;
this._tail = void 0;
this._size = 0;
this._state = 0;
}
clear() {
this._map.clear();
this._head = void 0;
this._tail = void 0;
this._size = 0;
this._state++;
}
isEmpty() {
return !this._head && !this._tail;
}
get size() {
return this._size;
}
get first() {
return this._head?.value;
}
get last() {
return this._tail?.value;
}
has(key) {
return this._map.has(key);
}
get(key, touch = Touch.None) {
const item = this._map.get(key);
if (!item) return;
if (touch !== Touch.None) this.touch(item, touch);
return item.value;
}
set(key, value, touch = Touch.None) {
let item = this._map.get(key);
if (item) {
item.value = value;
if (touch !== Touch.None) this.touch(item, touch);
} else {
item = {
key,
value,
next: void 0,
previous: void 0
};
switch (touch) {
case Touch.None:
this.addItemLast(item);
break;
case Touch.First:
this.addItemFirst(item);
break;
case Touch.Last:
this.addItemLast(item);
break;
default:
this.addItemLast(item);
break;
}
this._map.set(key, item);
this._size++;
}
return this;
}
delete(key) {
return !!this.remove(key);
}
remove(key) {
const item = this._map.get(key);
if (!item) return;
this._map.delete(key);
this.removeItem(item);
this._size--;
return item.value;
}
shift() {
if (!this._head && !this._tail) return;
if (!this._head || !this._tail) throw new Error("Invalid list");
const item = this._head;
this._map.delete(item.key);
this.removeItem(item);
this._size--;
return item.value;
}
forEach(callbackfn, thisArg) {
const state = this._state;
let current = this._head;
while (current) {
if (thisArg) callbackfn.bind(thisArg)(current.value, current.key, this);
else callbackfn(current.value, current.key, this);
if (this._state !== state) throw new Error(`LinkedMap got modified during iteration.`);
current = current.next;
}
}
keys() {
const state = this._state;
let current = this._head;
const iterator = {
[Symbol.iterator]: () => {
return iterator;
},
next: () => {
if (this._state !== state) throw new Error(`LinkedMap got modified during iteration.`);
if (current) {
const result = {
value: current.key,
done: false
};
current = current.next;
return result;
} else return {
value: void 0,
done: true
};
}
};
return iterator;
}
values() {
const state = this._state;
let current = this._head;
const iterator = {
[Symbol.iterator]: () => {
return iterator;
},
next: () => {
if (this._state !== state) throw new Error(`LinkedMap got modified during iteration.`);
if (current) {
const result = {
value: current.value,
done: false
};
current = current.next;
return result;
} else return {
value: void 0,
done: true
};
}
};
return iterator;
}
entries() {
const state = this._state;
let current = this._head;
const iterator = {
[Symbol.iterator]: () => {
return iterator;
},
next: () => {
if (this._state !== state) throw new Error(`LinkedMap got modified during iteration.`);
if (current) {
const result = {
value: [current.key, current.value],
done: false
};
current = current.next;
return result;
} else return {
value: void 0,
done: true
};
}
};
return iterator;
}
[(_a = Symbol.toStringTag, Symbol.iterator)]() {
return this.entries();
}
trimOld(newSize) {
if (newSize >= this.size) return;
if (newSize === 0) {
this.clear();
return;
}
let current = this._head;
let currentSize = this.size;
while (current && currentSize > newSize) {
this._map.delete(current.key);
current = current.next;
currentSize--;
}
this._head = current;
this._size = currentSize;
if (current) current.previous = void 0;
this._state++;
}
addItemFirst(item) {
if (!this._head && !this._tail) this._tail = item;
else if (!this._head) throw new Error("Invalid list");
else {
item.next = this._head;
this._head.previous = item;
}
this._head = item;
this._state++;
}
addItemLast(item) {
if (!this._head && !this._tail) this._head = item;
else if (!this._tail) throw new Error("Invalid list");
else {
item.previous = this._tail;
this._tail.next = item;
}
this._tail = item;
this._state++;
}
removeItem(item) {
if (item === this._head && item === this._tail) {
this._head = void 0;
this._tail = void 0;
} else if (item === this._head) {
if (!item.next) throw new Error("Invalid list");
item.next.previous = void 0;
this._head = item.next;
} else if (item === this._tail) {
if (!item.previous) throw new Error("Invalid list");
item.previous.next = void 0;
this._tail = item.previous;
} else {
const next = item.next;
const previous = item.previous;
if (!next || !previous) throw new Error("Invalid list");
next.previous = previous;
previous.next = next;
}
item.next = void 0;
item.previous = void 0;
this._state++;
}
touch(item, touch) {
if (!this._head || !this._tail) throw new Error("Invalid list");
if (touch !== Touch.First && touch !== Touch.Last) return;
if (touch === Touch.First) {
if (item === this._head) return;
const next = item.next;
const previous = item.previous;
if (item === this._tail) {
previous.next = void 0;
this._tail = previous;
} else {
next.previous = previous;
previous.next = next;
}
item.previous = void 0;
item.next = this._head;
this._head.previous = item;
this._head = item;
this._state++;
} else if (touch === Touch.Last) {
if (item === this._tail) return;
const next = item.next;
const previous = item.previous;
if (item === this._head) {
next.previous = void 0;
this._head = next;
} else {
next.previous = previous;
previous.next = next;
}
item.next = void 0;
item.previous = this._tail;
this._tail.next = item;
this._tail = item;
this._state++;
}
}
toJSON() {
const data = [];
this.forEach((value, key) => {
data.push([key, value]);
});
return data;
}
fromJSON(data) {
this.clear();
for (const [key, value] of data) this.set(key, value);
}
};
exports.LinkedMap = LinkedMap;
var LRUCache = class extends LinkedMap {
constructor(limit, ratio = 1) {
super();
this._limit = limit;
this._ratio = Math.min(Math.max(0, ratio), 1);
}
get limit() {
return this._limit;
}
set limit(limit) {
this._limit = limit;
this.checkTrim();
}
get ratio() {
return this._ratio;
}
set ratio(ratio) {
this._ratio = Math.min(Math.max(0, ratio), 1);
this.checkTrim();
}
get(key, touch = Touch.AsNew) {
return super.get(key, touch);
}
peek(key) {
return super.get(key, Touch.None);
}
set(key, value) {
super.set(key, value, Touch.Last);
this.checkTrim();
return this;
}
checkTrim() {
if (this.size > this._limit) this.trimOld(Math.round(this._limit * this._ratio));
}
};
exports.LRUCache = LRUCache;
}));
//#endregion
//#region ../../node_modules/vscode-jsonrpc/lib/common/disposable.js
var require_disposable = /* @__PURE__ */ __commonJSMin(((exports) => {
Object.defineProperty(exports, "__esModule", { value: true });
exports.Disposable = void 0;
var Disposable;
(function(Disposable) {
function create(func) {
return { dispose: func };
}
Disposable.create = create;
})(Disposable || (exports.Disposable = Disposable = {}));
}));
//#endregion
//#region ../../node_modules/vscode-jsonrpc/lib/common/ral.js
var require_ral = /* @__PURE__ */ __commonJSMin(((exports) => {
Object.defineProperty(exports, "__esModule", { value: true });
var _ral;
function RAL() {
if (_ral === void 0) throw new Error(`No runtime abstraction layer installed`);
return _ral;
}
(function(RAL) {
function install(ral) {
if (ral === void 0) throw new Error(`No runtime abstraction layer provided`);
_ral = ral;
}
RAL.install = install;
})(RAL || (RAL = {}));
exports.default = RAL;
}));
//#endregion
//#region ../../node_modules/vscode-jsonrpc/lib/common/events.js
var require_events = /* @__PURE__ */ __commonJSMin(((exports) => {
Object.defineProperty(exports, "__esModule", { value: true });
exports.Emitter = exports.Event = void 0;
var ral_1 = require_ral();
var Event;
(function(Event) {
const _disposable = { dispose() {} };
Event.None = function() {
return _disposable;
};
})(Event || (exports.Event = Event = {}));
var CallbackList = class {
add(callback, context = null, bucket) {
if (!this._callbacks) {
this._callbacks = [];
this._contexts = [];
}
this._callbacks.push(callback);
this._contexts.push(context);
if (Array.isArray(bucket)) bucket.push({ dispose: () => this.remove(callback, context) });
}
remove(callback, context = null) {
if (!this._callbacks) return;
let foundCallbackWithDifferentContext = false;
for (let i = 0, len = this._callbacks.length; i < len; i++) if (this._callbacks[i] === callback) if (this._contexts[i] === context) {
this._callbacks.splice(i, 1);
this._contexts.splice(i, 1);
return;
} else foundCallbackWithDifferentContext = true;
if (foundCallbackWithDifferentContext) throw new Error("When adding a listener with a context, you should remove it with the same context");
}
invoke(...args) {
if (!this._callbacks) return [];
const ret = [], callbacks = this._callbacks.slice(0), contexts = this._contexts.slice(0);
for (let i = 0, len = callbacks.length; i < len; i++) try {
ret.push(callbacks[i].apply(contexts[i], args));
} catch (e) {
(0, ral_1.default)().console.error(e);
}
return ret;
}
isEmpty() {
return !this._callbacks || this._callbacks.length === 0;
}
dispose() {
this._callbacks = void 0;
this._contexts = void 0;
}
};
var Emitter = class Emitter {
constructor(_options) {
this._options = _options;
}
/**
* For the public to allow to subscribe
* to events from this Emitter
*/
get event() {
if (!this._event) this._event = (listener, thisArgs, disposables) => {
if (!this._callbacks) this._callbacks = new CallbackList();
if (this._options && this._options.onFirstListenerAdd && this._callbacks.isEmpty()) this._options.onFirstListenerAdd(this);
this._callbacks.add(listener, thisArgs);
const result = { dispose: () => {
if (!this._callbacks) return;
this._callbacks.remove(listener, thisArgs);
result.dispose = Emitter._noop;
if (this._options && this._options.onLastListenerRemove && this._callbacks.isEmpty()) this._options.onLastListenerRemove(this);
} };
if (Array.isArray(disposables)) disposables.push(result);
return result;
};
return this._event;
}
/**
* To be kept private to fire an event to
* subscribers
*/
fire(event) {
if (this._callbacks) this._callbacks.invoke.call(this._callbacks, event);
}
dispose() {
if (this._callbacks) {
this._callbacks.dispose();
this._callbacks = void 0;
}
}
};
exports.Emitter = Emitter;
Emitter._noop = function() {};
}));
//#endregion
//#region ../../node_modules/vscode-jsonrpc/lib/common/cancellation.js
var require_cancellation = /* @__PURE__ */ __commonJSMin(((exports) => {
Object.defineProperty(exports, "__esModule", { value: true });
exports.CancellationTokenSource = exports.CancellationToken = void 0;
var ral_1 = require_ral();
var Is = require_is$1();
var events_1 = require_events();
var CancellationToken;
(function(CancellationToken) {
CancellationToken.None = Object.freeze({
isCancellationRequested: false,
onCancellationRequested: events_1.Event.None
});
CancellationToken.Cancelled = Object.freeze({
isCancellationRequested: true,
onCancellationRequested: events_1.Event.None
});
function is(value) {
const candidate = value;
return candidate && (candidate === CancellationToken.None || candidate === CancellationToken.Cancelled || Is.boolean(candidate.isCancellationRequested) && !!candidate.onCancellationRequested);
}
CancellationToken.is = is;
})(CancellationToken || (exports.CancellationToken = CancellationToken = {}));
var shortcutEvent = Object.freeze(function(callback, context) {
const handle = (0, ral_1.default)().timer.setTimeout(callback.bind(context), 0);
return { dispose() {
handle.dispose();
} };
});
var MutableToken = class {
constructor() {
this._isCancelled = false;
}
cancel() {
if (!this._isCancelled) {
this._isCancelled = true;
if (this._emitter) {
this._emitter.fire(void 0);
this.dispose();
}
}
}
get isCancellationRequested() {
return this._isCancelled;
}
get onCancellationRequested() {
if (this._isCancelled) return shortcutEvent;
if (!this._emitter) this._emitter = new events_1.Emitter();
return this._emitter.event;
}
dispose() {
if (this._emitter) {
this._emitter.dispose();
this._emitter = void 0;
}
}
};
var CancellationTokenSource = class {
get token() {
if (!this._token) this._token = new MutableToken();
return this._token;
}
cancel() {
if (!this._token) this._token = CancellationToken.Cancelled;
else this._token.cancel();
}
dispose() {
if (!this._token) this._token = CancellationToken.None;
else if (this._token instanceof MutableToken) this._token.dispose();
}
};
exports.CancellationTokenSource = CancellationTokenSource;
}));
//#endregion
//#region ../../node_modules/vscode-jsonrpc/lib/common/sharedArrayCancellation.js
var require_sharedArrayCancellation = /* @__PURE__ */ __commonJSMin(((exports) => {
Object.defineProperty(exports, "__esModule", { value: true });
exports.SharedArrayReceiverStrategy = exports.SharedArraySenderStrategy = void 0;
var cancellation_1 = require_cancellation();
var CancellationState;
(function(CancellationState) {
CancellationState.Continue = 0;
CancellationState.Cancelled = 1;
})(CancellationState || (CancellationState = {}));
var SharedArraySenderStrategy = class {
constructor() {
this.buffers = /* @__PURE__ */ new Map();
}
enableCancellation(request) {
if (request.id === null) return;
const buffer = new SharedArrayBuffer(4);
const data = new Int32Array(buffer, 0, 1);
data[0] = CancellationState.Continue;
this.buffers.set(request.id, buffer);
request.$cancellationData = buffer;
}
async sendCancellation(_conn, id) {
const buffer = this.buffers.get(id);
if (buffer === void 0) return;
const data = new Int32Array(buffer, 0, 1);
Atomics.store(data, 0, CancellationState.Cancelled);
}
cleanup(id) {
this.buffers.delete(id);
}
dispose() {
this.buffers.clear();
}
};
exports.SharedArraySenderStrategy = SharedArraySenderStrategy;
var SharedArrayBufferCancellationToken = class {
constructor(buffer) {
this.data = new Int32Array(buffer, 0, 1);
}
get isCancellationRequested() {
return Atomics.load(this.data, 0) === CancellationState.Cancelled;
}
get onCancellationRequested() {
throw new Error(`Cancellation over SharedArrayBuffer doesn't support cancellation events`);
}
};
var SharedArrayBufferCancellationTokenSource = class {
constructor(buffer) {
this.token = new SharedArrayBufferCancellationToken(buffer);
}
cancel() {}
dispose() {}
};
var SharedArrayReceiverStrategy = class {
constructor() {
this.kind = "request";
}
createCancellationTokenSource(request) {
const buffer = request.$cancellationData;
if (buffer === void 0) return new cancellation_1.CancellationTokenSource();
return new SharedArrayBufferCancellationTokenSource(buffer);
}
};
exports.SharedArrayReceiverStrategy = SharedArrayReceiverStrategy;
}));
//#endregion
//#region ../../node_modules/vscode-jsonrpc/lib/common/semaphore.js
var require_semaphore = /* @__PURE__ */ __commonJSMin(((exports) => {
Object.defineProperty(exports, "__esModule", { value: true });
exports.Semaphore = void 0;
var ral_1 = require_ral();
var Semaphore = class {
constructor(capacity = 1) {
if (capacity <= 0) throw new Error("Capacity must be greater than 0");
this._capacity = capacity;
this._active = 0;
this._waiting = [];
}
lock(thunk) {
return new Promise((resolve, reject) => {
this._waiting.push({
thunk,
resolve,
reject
});
this.runNext();
});
}
get active() {
return this._active;
}
runNext() {
if (this._waiting.length === 0 || this._active === this._capacity) return;
(0, ral_1.default)().timer.setImmediate(() => this.doRunNext());
}
doRunNext() {
if (this._waiting.length === 0 || this._active === this._capacity) return;
const next = this._waiting.shift();
this._active++;
if (this._active > this._capacity) throw new Error(`To many thunks active`);
try {
const result = next.thunk();
if (result instanceof Promise) result.then((value) => {
this._active--;
next.resolve(value);
this.runNext();
}, (err) => {
this._active--;
next.reject(err);
this.runNext();
});
else {
this._active--;
next.resolve(result);
this.runNext();
}
} catch (err) {
this._active--;
next.reject(err);
this.runNext();
}
}
};
exports.Semaphore = Semaphore;
}));
//#endregion
//#region ../../node_modules/vscode-jsonrpc/lib/common/messageReader.js
var require_messageReader = /* @__PURE__ */ __commonJSMin(((exports) => {
Object.defineProperty(exports, "__esModule", { value: true });
exports.ReadableStreamMessageReader = exports.AbstractMessageReader = exports.MessageReader = void 0;
var ral_1 = require_ral();
var Is = require_is$1();
var events_1 = require_events();
var semaphore_1 = require_semaphore();
var MessageReader;
(function(MessageReader) {
function is(value) {
let candidate = value;
return candidate && Is.func(candidate.listen) && Is.func(candidate.dispose) && Is.func(candidate.onError) && Is.func(candidate.onClose) && Is.func(candidate.onPartialMessage);
}
MessageReader.is = is;
})(MessageReader || (exports.MessageReader = MessageReader = {}));
var AbstractMessageReader = class {
constructor() {
this.errorEmitter = new events_1.Emitter();
this.closeEmitter = new events_1.Emitter();
this.partialMessageEmitter = new events_1.Emitter();
}
dispose() {
this.errorEmitter.dispose();
this.closeEmitter.dispose();
}
get onError() {
return this.errorEmitter.event;
}
fireError(error) {
this.errorEmitter.fire(this.asError(error));
}
get onClose() {
return this.closeEmitter.event;
}
fireClose() {
this.closeEmitter.fire(void 0);
}
get onPartialMessage() {
return this.partialMessageEmitter.event;
}
firePartialMessage(info) {
this.partialMessageEmitter.fire(info);
}
asError(error) {
if (error instanceof Error) return error;
else return /* @__PURE__ */ new Error(`Reader received error. Reason: ${Is.string(error.message) ? error.message : "unknown"}`);
}
};
exports.AbstractMessageReader = AbstractMessageReader;
var ResolvedMessageReaderOptions;
(function(ResolvedMessageReaderOptions) {
function fromOptions(options) {
let charset;
let contentDecoder;
const contentDecoders = /* @__PURE__ */ new Map();
let contentTypeDecoder;
const contentTypeDecoders = /* @__PURE__ */ new Map();
if (options === void 0 || typeof options === "string") charset = options ?? "utf-8";
else {
charset = options.charset ?? "utf-8";
if (options.contentDecoder !== void 0) {
contentDecoder = options.contentDecoder;
contentDecoders.set(contentDecoder.name, contentDecoder);
}
if (options.contentDecoders !== void 0) for (const decoder of options.contentDecoders) contentDecoders.set(decoder.name, decoder);
if (options.contentTypeDecoder !== void 0) {
contentTypeDecoder = options.contentTypeDecoder;
contentTypeDecoders.set(contentTypeDecoder.name, contentTypeDecoder);
}
if (options.contentTypeDecoders !== void 0) for (const decoder of options.contentTypeDecoders) contentTypeDecoders.set(decoder.name, decoder);
}
if (contentTypeDecoder === void 0) {
contentTypeDecoder = (0, ral_1.default)().applicationJson.decoder;
contentTypeDecoders.set(contentTypeDecoder.name, contentTypeDecoder);
}
return {
charset,
contentDecoder,
contentDecoders,
contentTypeDecoder,
contentTypeDecoders
};
}
ResolvedMessageReaderOptions.fromOptions = fromOptions;
})(ResolvedMessageReaderOptions || (ResolvedMessageReaderOptions = {}));
var ReadableStreamMessageReader = class extends AbstractMessageReader {
constructor(readable, options) {
super();
this.readable = readable;
this.options = ResolvedMessageReaderOptions.fromOptions(options);
this.buffer = (0, ral_1.default)().messageBuffer.create(this.options.charset);
this._partialMessageTimeout = 1e4;
this.nextMessageLength = -1;
this.messageToken = 0;
this.readSemaphore = new semaphore_1.Semaphore(1);
}
set partialMessageTimeout(timeout) {
this._partialMessageTimeout = timeout;
}
get partialMessageTimeout() {
return this._partialMessageTimeout;
}
listen(callback) {
this.nextMessageLength = -1;
this.messageToken = 0;
this.partialMessageTimer = void 0;
this.callback = callback;
const result = this.readable.onData((data) => {
this.onData(data);
});
this.readable.onError((error) => this.fireError(error));
this.readable.onClose(() => this.fireClose());
return result;
}
onData(data) {
try {
this.buffer.append(data);
while (true) {
if (this.nextMessageLength === -1) {
const headers = this.buffer.tryReadHeaders(true);
if (!headers) return;
const contentLength = headers.get("content-length");
if (!contentLength) {
this.fireError(/* @__PURE__ */ new Error(`Header must provide a Content-Length property.\n${JSON.stringify(Object.fromEntries(headers))}`));
return;
}
const length = parseInt(contentLength);
if (isNaN(length)) {
this.fireError(/* @__PURE__ */ new Error(`Content-Length value must be a number. Got ${contentLength}`));
return;
}
this.nextMessageLength = length;
}
const body = this.buffer.tryReadBody(this.nextMessageLength);
if (body === void 0) {
/** We haven't received the full message yet. */
this.setPartialMessageTimer();
return;
}
this.clearPartialMessageTimer();
this.nextMessageLength = -1;
this.readSemaphore.lock(async () => {
const bytes = this.options.contentDecoder !== void 0 ? 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);
});
}
} catch (error) {
this.fireError(error);
}
}
clearPartialMessageTimer() {
if (this.partialMessageTimer) {
this.partialMessageTimer.dispose();
this.partialMessageTimer = void 0;
}
}
setPartialMessageTimer() {
this.clearPartialMessageTimer();
if (this._partialMessageTimeout <= 0) return;
this.partialMessageTimer = (0, ral_1.default)().timer.setTimeout((token, timeout) => {
this.partialMessageTimer = void 0;
if (token === this.messageToken) {
this.firePartialMessage({
messageToken: token,
waitingTime: timeout
});
this.setPartialMessageTimer();
}
}, this._partialMessageTimeout, this.messageToken, this._partialMessageTimeout);
}
};
exports.ReadableStreamMessageReader = ReadableStreamMessageReader;
}));
//#endregion
//#region ../../node_modules/vscode-jsonrpc/lib/common/messageWriter.js
var require_messageWriter = /* @__PURE__ */ __commonJSMin(((exports) => {
Object.defineProperty(exports, "__esModule", { value: true });
exports.WriteableStreamMessageWriter = exports.AbstractMessageWriter = exports.MessageWriter = void 0;
var ral_1 = require_ral();
var Is = require_is$1();
var semaphore_1 = require_semaphore();
var events_1 = require_events();
var ContentLength = "Content-Length: ";
var CRLF = "\r\n";
var MessageWriter;
(function(MessageWriter) {
function is(value) {
let candidate = value;
return candidate && Is.func(candidate.dispose) && Is.func(candidate.onClose) && Is.func(candidate.onError) && Is.func(candidate.write);
}
MessageWriter.is = is;
})(MessageWriter || (exports.MessageWriter = MessageWriter = {}));
var AbstractMessageWriter = class {
constructor() {
this.errorEmitter = new events_1.Emitter();
this.closeEmitter = new events_1.Emitter();
}
dispose() {
this.errorEmitter.dispose();
this.closeEmitter.dispose();
}
get onError() {
return this.errorEmitter.event;
}
fireError(error, message, count) {
this.errorEmitter.fire([
this.asError(error),
message,
count
]);
}
get onClose() {
return this.closeEmitter.event;
}
fireClose() {
this.closeEmitter.fire(void 0);
}
asError(error) {
if (error instanceof Error) return error;
else return /* @__PURE__ */ new Error(`Writer received error. Reason: ${Is.string(error.message) ? error.message : "unknown"}`);
}
};
exports.AbstractMessageWriter = AbstractMessageWriter;
var ResolvedMessageWriterOptions;
(function(ResolvedMessageWriterOptions) {
function fromOptions(options) {
if (options === void 0 || typeof options === "string") return {
charset: options ?? "utf-8",
contentTypeEncoder: (0, ral_1.default)().applicationJson.encoder
};
else return {
charset: options.charset ?? "utf-8",
contentEncoder: options.contentEncoder,
contentTypeEncoder: options.contentTypeEncoder ?? (0, ral_1.default)().applicationJson.encoder
};
}
ResolvedMessageWriterOptions.fromOptions = fromOptions;
})(ResolvedMessageWriterOptions || (ResolvedMessageWriterOptions = {}));
var WriteableStreamMessageWriter = class extends AbstractMessageWriter {
constructor(writable, options) {
super();
this.writable = writable;
this.options = ResolvedMessageWriterOptions.fromOptions(options);
this.errorCount = 0;
this.writeSemaphore = new semaphore_1.Semaphore(1);
this.writable.onError((error) => this.fireError(error));
this.writable.onClose(() => this.fireClose());
}
async write(msg) {
return this.writeSemaphore.lock(async () => {
return this.options.contentTypeEncoder.encode(msg, this.options).then((buffer) => {
if (this.options.contentEncoder !== void 0) return this.options.contentEncoder.encode(buffer);
else return buffer;
}).then((buffer) => {
const headers = [];
headers.push(ContentLength, buffer.byteLength.toString(), CRLF);
headers.push(CRLF);
return this.doWrite(msg, headers, buffer);
}, (error) => {
this.fireError(error);
throw error;
});
});
}
async doWrite(msg, headers, data) {
try {
await this.writable.write(headers.join(""), "ascii");
return this.writable.write(data);
} catch (error) {
this.handleError(error, msg);
return Promise.reject(error);
}
}
handleError(error, msg) {
this.errorCount++;
this.fireError(error, msg, this.errorCount);
}
end() {
this.writable.end();
}
};
exports.WriteableStreamMessageWriter = WriteableStreamMessageWriter;
}));
//#endregion
//#region ../../node_modules/vscode-jsonrpc/lib/common/messageBuffer.js
var require_messageBuffer = /* @__PURE__ */ __commonJSMin(((exports) => {
Object.defineProperty(exports, "__esModule", { value: true });
exports.AbstractMessageBuffer = void 0;
var CR = 13;
var LF = 10;
var CRLF = "\r\n";
var AbstractMessageBuffer = class {
constructor(encoding = "utf-8") {
this._encoding = encoding;
this._chunks = [];
this._totalLength = 0;
}
get encoding() {
return this._encoding;
}
append(chunk) {
const toAppend = typeof chunk === "string" ? this.fromString(chunk, this._encoding) : chunk;
this._chunks.push(toAppend);
this._totalLength += toAppend.byteLength;
}
tryReadHeaders(lowerCaseKeys = false) {
if (this._chunks.length === 0) return;
let state = 0;
let chunkIndex = 0;
let offset = 0;
let chunkBytesRead = 0;
row: while (chunkIndex < this._chunks.length) {
const chunk = this._chunks[chunkIndex];
offset = 0;
column: while (offset < chunk.length) {
switch (chunk[offset]) {
case CR:
switch (state) {
case 0:
state = 1;
break;
case 2:
state = 3;
break;
default: state = 0;
}
break;
case LF:
switch (state) {
case 1:
state = 2;
break;
case 3:
state = 4;
offset++;
break row;
default: state = 0;
}
break;
default: state = 0;
}
offset++;
}
chunkBytesRead += chunk.byteLength;
chunkIndex++;
}
if (state !== 4) return;
const buffer = this._read(chunkBytesRead + offset);
const result = /* @__PURE__ */ new Map();
const headers = this.toString(buffer, "ascii").split(CRLF);
if (headers.length < 2) return result;
for (let i = 0; i < headers.length - 2; i++) {
const header = headers[i];
const index = header.indexOf(":");
if (index === -1) throw new Error(`Message header must separate key and value using ':'\n${header}`);
const key = header.substr(0, index);
const value = header.substr(index + 1).trim();
result.set(lowerCaseKeys ? key.toLowerCase() : key, value);
}
return result;
}
tryReadBody(length) {
if (this._totalLength < length) return;
return this._read(length);
}
get numberOfBytes() {
return this._totalLength;
}
_read(byteCount) {
if (byteCount === 0) return this.emptyBuffer();
if (byteCount > this._totalLength) throw new Error(`Cannot read so many bytes!`);
if (this._chunks[0].byteLength === byteCount) {
const chunk = this._chunks[0];
this._chunks.shift();
this._totalLength -= byteCount;
return this.asNative(chunk);
}
if (this._chunks[0].byteLength > byteCount) {
const chunk = this._chunks[0];
const result = this.asNative(chunk, byteCount);
this._chunks[0] = chunk.slice(byteCount);
this._totalLength -= byteCount;
return result;
}
const result = this.allocNative(byteCount);
let resultOffset = 0;
let chunkIndex = 0;
while (byteCount > 0) {
const chunk = this._chunks[chunkIndex];
if (chunk.byteLength > byteCount) {
const chunkPart = chunk.slice(0, byteCount);
result.set(chunkPart, resultOffset);
resultOffset += byteCount;
this._chunks[chunkIndex] = chunk.slice(byteCount);
this._totalLength -= byteCount;
byteCount -= byteCount;
} else {
result.set(chunk, resultOffset);
resultOffset += chunk.byteLength;
this._chunks.shift();
this._totalLength -= chunk.byteLength;
byteCount -= chunk.byteLength;
}
}
return result;
}
};
exports.AbstractMessageBuffer = AbstractMessageBuffer;
}));
//#endregion
//#region ../../node_modules/vscode-jsonrpc/lib/common/connection.js
var require_connection$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
Object.defineProperty(exports, "__esModule", { value: true });
exports.createMessageConnection = exports.ConnectionOptions = exports.MessageStrategy = exports.CancellationStrategy = exports.CancellationSenderStrategy = exports.CancellationReceiverStrategy = exports.RequestCancellationReceiverStrategy = exports.IdCancellationReceiverStrategy = exports.ConnectionStrategy = exports.ConnectionError = exports.ConnectionErrors = exports.LogTraceNotification = exports.SetTraceNotification = exports.TraceFormat = exports.TraceValues = exports.Trace = exports.NullLogger = exports.ProgressType = exports.ProgressToken = void 0;
var ral_1 = require_ral();
var Is = require_is$1();
var messages_1 = require_messages$1();
var linkedMap_1 = require_linkedMap();
var events_1 = require_events();
var cancellation_1 = require_cancellation();
var CancelNotification;
(function(CancelNotification) {
CancelNotification.type = new messages_1.NotificationType("$/cancelRequest");
})(CancelNotification || (CancelNotification = {}));
var ProgressToken;
(function(ProgressToken) {
function is(value) {
return typeof value === "string" || typeof value === "number";
}
ProgressToken.is = is;
})(ProgressToken || (exports.ProgressToken = ProgressToken = {}));
var ProgressNotification;
(function(ProgressNotification) {
ProgressNotification.type = new messages_1.NotificationType("$/progress");
})(ProgressNotification || (ProgressNotification = {}));
var ProgressType = class {
constructor() {}
};
exports.ProgressType = ProgressType;
var StarRequestHandler;
(function(StarRequestHandler) {
function is(value) {
return Is.func(value);
}
StarRequestHandler.is = is;
})(StarRequestHandler || (StarRequestHandler = {}));
exports.NullLogger = Object.freeze({
error: () => {},
warn: () => {},
info: () => {},
log: () => {}
});
var Trace;
(function(Trace) {
Trace[Trace["Off"] = 0] = "Off";
Trace[Trace["Messages"] = 1] = "Messages";
Trace[Trace["Compact"] = 2] = "Compact";
Trace[Trace["Verbose"] = 3] = "Verbose";
})(Trace || (exports.Trace = Trace = {}));
var TraceValues;
(function(TraceValues) {
/**
* Turn tracing off.
*/
TraceValues.Off = "off";
/**
* Trace messages only.
*/
TraceValues.Messages = "messages";
/**
* Compact message tracing.
*/
TraceValues.Compact = "compact";
/**
* Verbose message tracing.
*/
TraceValues.Verbose = "verbose";
})(TraceValues || (exports.TraceValues = TraceValues = {}));
(function(Trace) {
function fromString(value) {
if (!Is.string(value)) return Trace.Off;
value = value.toLowerCase();
switch (value) {
case "off": return Trace.Off;
case "messages": return Trace.Messages;
case "compact": return Trace.Compact;
case "verbose": return Trace.Verbose;
default: return Trace.Off;
}
}
Trace.fromString = fromString;
function toString(value) {
switch (value) {
case Trace.Off: return "off";
case Trace.Messages: return "messages";
case Trace.Compact: return "compact";
case Trace.Verbose: return "verbose";
default: return "off";
}
}
Trace.toString = toString;
})(Trace || (exports.Trace = Trace = {}));
var TraceFormat;
(function(TraceFormat) {
TraceFormat["Text"] = "text";
TraceFormat["JSON"] = "json";
})(TraceFormat || (exports.TraceFormat = TraceFormat = {}));
(function(TraceFormat) {
function fromString(value) {
if (!Is.string(value)) return TraceFormat.Text;
value =