@difizen/libro-lsp 0.1.3 → 0.1.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/es/adapters/adapter.d.ts.map +1 -1
- package/es/adapters/adapter.js +4 -3
- package/es/adapters/notebook-adapter.d.ts +10 -4
- package/es/adapters/notebook-adapter.d.ts.map +1 -1
- package/es/adapters/notebook-adapter.js +20 -8
- package/es/connection-manager.d.ts +37 -34
- package/es/connection-manager.d.ts.map +1 -1
- package/es/connection-manager.js +186 -186
- package/es/connection.d.ts +8 -16
- package/es/connection.d.ts.map +1 -1
- package/es/connection.js +26 -12
- package/es/index.d.ts +1 -0
- package/es/index.d.ts.map +1 -1
- package/es/index.js +1 -0
- package/es/lsp-app-contribution.d.ts +2 -0
- package/es/lsp-app-contribution.d.ts.map +1 -1
- package/es/lsp-app-contribution.js +11 -4
- package/es/lsp-protocol.d.ts +15 -0
- package/es/lsp-protocol.d.ts.map +1 -1
- package/es/lsp-protocol.js +9 -1
- package/es/module.d.ts.map +1 -1
- package/es/module.js +54 -2
- package/es/monitor.d.ts +20 -0
- package/es/monitor.d.ts.map +1 -0
- package/es/monitor.js +25 -0
- package/es/tokens.d.ts +4 -1
- package/es/tokens.d.ts.map +1 -1
- package/es/tokens.js +2 -1
- package/es/virtual/document.d.ts +14 -4
- package/es/virtual/document.d.ts.map +1 -1
- package/es/virtual/document.js +48 -24
- package/es/ws-connection/ws-connection.d.ts +2 -1
- package/es/ws-connection/ws-connection.d.ts.map +1 -1
- package/es/ws-connection/ws-connection.js +4 -3
- package/package.json +5 -5
- package/src/adapters/adapter.ts +2 -1
- package/src/adapters/notebook-adapter.ts +17 -7
- package/src/connection-manager.ts +120 -146
- package/src/connection.ts +16 -27
- package/src/index.ts +1 -0
- package/src/lsp-app-contribution.ts +4 -2
- package/src/lsp-protocol.ts +26 -0
- package/src/module.ts +61 -0
- package/src/monitor.ts +28 -0
- package/src/tokens.ts +5 -1
- package/src/virtual/document.ts +32 -8
- package/src/ws-connection/ws-connection.ts +4 -2
package/es/connection-manager.js
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
var _dec, _class;
|
|
2
|
+
var _dec, _dec2, _class, _class2, _descriptor;
|
|
3
3
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
4
4
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
5
5
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
6
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
8
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
9
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
10
7
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
11
8
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
12
9
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
10
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
11
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
12
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
13
|
+
function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
|
|
13
14
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
14
15
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
15
16
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
16
17
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
17
18
|
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
19
|
+
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
|
|
20
|
+
function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
|
|
18
21
|
/* eslint-disable @typescript-eslint/no-shadow */
|
|
19
22
|
/* eslint-disable @typescript-eslint/no-namespace */
|
|
20
23
|
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
@@ -27,7 +30,7 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
|
27
30
|
import { URL } from '@difizen/libro-common';
|
|
28
31
|
import { PageConfig } from '@difizen/libro-kernel';
|
|
29
32
|
import { Emitter, inject, singleton } from '@difizen/mana-app';
|
|
30
|
-
import {
|
|
33
|
+
import { LSPConnectionFactory } from "./connection.js";
|
|
31
34
|
import { ILSPDocumentConnectionManager, ILanguageServerManagerFactory } from "./tokens.js";
|
|
32
35
|
import { expandDottedPaths, sleep, untilReady } from "./utils.js";
|
|
33
36
|
/**
|
|
@@ -37,10 +40,12 @@ import { expandDottedPaths, sleep, untilReady } from "./utils.js";
|
|
|
37
40
|
*/
|
|
38
41
|
export var DocumentConnectionManager = (_dec = singleton({
|
|
39
42
|
token: ILSPDocumentConnectionManager
|
|
40
|
-
}), _dec(_class = /*#__PURE__*/function () {
|
|
43
|
+
}), _dec2 = inject(LSPConnectionFactory), _dec(_class = (_class2 = /*#__PURE__*/function () {
|
|
41
44
|
function DocumentConnectionManager(languageServerManagerFactory) {
|
|
42
45
|
var _this = this;
|
|
43
46
|
_classCallCheck(this, DocumentConnectionManager);
|
|
47
|
+
_initializerDefineProperty(this, "lspConnectionFactory", _descriptor, this);
|
|
48
|
+
this._connections = new Map();
|
|
44
49
|
/**
|
|
45
50
|
* Fired the first time a connection is opened. These _should_ be the only
|
|
46
51
|
* invocation of `.on` (once remaining LSPFeature.connection_handlers are made
|
|
@@ -105,31 +110,86 @@ export var DocumentConnectionManager = (_dec = singleton({
|
|
|
105
110
|
this.adapters = new Map();
|
|
106
111
|
this._ignoredLanguages = new Set();
|
|
107
112
|
this.languageServerManager = languageServerManagerFactory({});
|
|
108
|
-
Private.setLanguageServerManager(this.languageServerManager);
|
|
109
113
|
}
|
|
114
|
+
DocumentConnectionManager = inject(ILanguageServerManagerFactory)(DocumentConnectionManager, undefined, 0) || DocumentConnectionManager;
|
|
115
|
+
_createClass(DocumentConnectionManager, [{
|
|
116
|
+
key: "disconnectServer",
|
|
117
|
+
value: function disconnectServer(languageServerId) {
|
|
118
|
+
var connection = this._connections.get(languageServerId);
|
|
119
|
+
if (connection) {
|
|
120
|
+
connection.close();
|
|
121
|
+
this._connections.delete(languageServerId);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Return (or create and initialize) the WebSocket associated with the language
|
|
127
|
+
*/
|
|
128
|
+
}, {
|
|
129
|
+
key: "connection",
|
|
130
|
+
value: function () {
|
|
131
|
+
var _connection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(language, languageServerId, uris, onCreate, capabilities) {
|
|
132
|
+
var connection, socket, _connection2;
|
|
133
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
134
|
+
while (1) switch (_context.prev = _context.next) {
|
|
135
|
+
case 0:
|
|
136
|
+
connection = this._connections.get(languageServerId);
|
|
137
|
+
if (!connection) {
|
|
138
|
+
socket = new WebSocket(uris.socket);
|
|
139
|
+
_connection2 = this.lspConnectionFactory({
|
|
140
|
+
languageId: language,
|
|
141
|
+
serverUri: uris.server,
|
|
142
|
+
rootUri: uris.base,
|
|
143
|
+
serverIdentifier: languageServerId,
|
|
144
|
+
capabilities: capabilities
|
|
145
|
+
});
|
|
146
|
+
this._connections.set(languageServerId, _connection2);
|
|
147
|
+
_connection2.connect(socket);
|
|
148
|
+
onCreate(_connection2);
|
|
149
|
+
}
|
|
150
|
+
connection = this._connections.get(languageServerId);
|
|
151
|
+
return _context.abrupt("return", connection);
|
|
152
|
+
case 4:
|
|
153
|
+
case "end":
|
|
154
|
+
return _context.stop();
|
|
155
|
+
}
|
|
156
|
+
}, _callee, this);
|
|
157
|
+
}));
|
|
158
|
+
function connection(_x, _x2, _x3, _x4, _x5) {
|
|
159
|
+
return _connection.apply(this, arguments);
|
|
160
|
+
}
|
|
161
|
+
return connection;
|
|
162
|
+
}()
|
|
163
|
+
}, {
|
|
164
|
+
key: "updateServerConfiguration",
|
|
165
|
+
value: function updateServerConfiguration(languageServerId, settings) {
|
|
166
|
+
var connection = this._connections.get(languageServerId);
|
|
167
|
+
if (connection) {
|
|
168
|
+
connection.sendConfigurationChange(settings);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
110
171
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
172
|
+
/**
|
|
173
|
+
* Map between the URI of the virtual document and its connection
|
|
174
|
+
* to the language server
|
|
175
|
+
*/
|
|
115
176
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
177
|
+
/**
|
|
178
|
+
* Map between the path of the document and its adapter
|
|
179
|
+
*/
|
|
119
180
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
181
|
+
/**
|
|
182
|
+
* Map between the URI of the virtual document and the document itself.
|
|
183
|
+
*/
|
|
123
184
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
185
|
+
/**
|
|
186
|
+
* The language server manager plugin.
|
|
187
|
+
*/
|
|
127
188
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
_createClass(DocumentConnectionManager, [{
|
|
189
|
+
/**
|
|
190
|
+
* Initial configuration for the language servers.
|
|
191
|
+
*/
|
|
192
|
+
}, {
|
|
133
193
|
key: "initialized",
|
|
134
194
|
get:
|
|
135
195
|
/**
|
|
@@ -184,7 +244,46 @@ export var DocumentConnectionManager = (_dec = singleton({
|
|
|
184
244
|
}, {
|
|
185
245
|
key: "ready",
|
|
186
246
|
get: function get() {
|
|
187
|
-
return
|
|
247
|
+
return this.languageServerManager.ready;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Generate the URI of a virtual document from input
|
|
252
|
+
*
|
|
253
|
+
* @param virtualDocument - the virtual document
|
|
254
|
+
* @param language - language of the document
|
|
255
|
+
*/
|
|
256
|
+
}, {
|
|
257
|
+
key: "solveUris",
|
|
258
|
+
value: function solveUris(virtualDocument, language) {
|
|
259
|
+
var wsBase = PageConfig.getBaseUrl().replace(/^http/, 'ws');
|
|
260
|
+
var rootUri = PageConfig.getOption('rootUri');
|
|
261
|
+
var virtualDocumentsUri = PageConfig.getOption('virtualDocumentsUri');
|
|
262
|
+
var baseUri = virtualDocument.hasLspSupportedFile ? rootUri : virtualDocumentsUri;
|
|
263
|
+
|
|
264
|
+
// for now take the best match only
|
|
265
|
+
var matchingServers = this.languageServerManager.getMatchingServers({
|
|
266
|
+
language: language
|
|
267
|
+
});
|
|
268
|
+
var languageServerId = matchingServers.length === 0 ? null : matchingServers[0];
|
|
269
|
+
if (languageServerId === null) {
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// workaround url-parse bug(s) (see https://github.com/jupyter-lsp/jupyterlab-lsp/issues/595)
|
|
274
|
+
var documentUri = URL.join(baseUri, virtualDocument.uri);
|
|
275
|
+
if (!documentUri.startsWith('file:///') && documentUri.startsWith('file://')) {
|
|
276
|
+
documentUri = documentUri.replace('file://', 'file:///');
|
|
277
|
+
if (documentUri.startsWith('file:///users/') && baseUri.startsWith('file:///Users/')) {
|
|
278
|
+
documentUri = documentUri.replace('file:///users/', 'file:///Users/');
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
return {
|
|
282
|
+
base: baseUri,
|
|
283
|
+
document: documentUri,
|
|
284
|
+
server: URL.join('ws://jupyter-lsp', language),
|
|
285
|
+
socket: URL.join(wsBase, 'lsp', 'ws', languageServerId)
|
|
286
|
+
};
|
|
188
287
|
}
|
|
189
288
|
|
|
190
289
|
/**
|
|
@@ -304,7 +403,7 @@ export var DocumentConnectionManager = (_dec = singleton({
|
|
|
304
403
|
var serverSettings = {
|
|
305
404
|
settings: parsedSettings
|
|
306
405
|
};
|
|
307
|
-
|
|
406
|
+
this.updateServerConfiguration(languageServerId, serverSettings);
|
|
308
407
|
}
|
|
309
408
|
}
|
|
310
409
|
}, {
|
|
@@ -317,31 +416,31 @@ export var DocumentConnectionManager = (_dec = singleton({
|
|
|
317
416
|
* the socket, triggering the language server on the other end to exit.
|
|
318
417
|
*/
|
|
319
418
|
function () {
|
|
320
|
-
var _retryToConnect = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
419
|
+
var _retryToConnect = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options, reconnectDelay) {
|
|
321
420
|
var retrialsLeft,
|
|
322
421
|
virtualDocument,
|
|
323
422
|
interval,
|
|
324
423
|
success,
|
|
325
|
-
|
|
326
|
-
return _regeneratorRuntime().wrap(function
|
|
327
|
-
while (1) switch (
|
|
424
|
+
_args2 = arguments;
|
|
425
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
426
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
328
427
|
case 0:
|
|
329
|
-
retrialsLeft =
|
|
428
|
+
retrialsLeft = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : -1;
|
|
330
429
|
virtualDocument = options.virtualDocument;
|
|
331
430
|
if (!this._ignoredLanguages.has(virtualDocument.language)) {
|
|
332
|
-
|
|
431
|
+
_context2.next = 4;
|
|
333
432
|
break;
|
|
334
433
|
}
|
|
335
|
-
return
|
|
434
|
+
return _context2.abrupt("return");
|
|
336
435
|
case 4:
|
|
337
436
|
interval = reconnectDelay * 1000;
|
|
338
437
|
success = false;
|
|
339
438
|
case 6:
|
|
340
439
|
if (!(retrialsLeft !== 0 && !success)) {
|
|
341
|
-
|
|
440
|
+
_context2.next = 15;
|
|
342
441
|
break;
|
|
343
442
|
}
|
|
344
|
-
|
|
443
|
+
_context2.next = 9;
|
|
345
444
|
return this.connect(options)
|
|
346
445
|
// eslint-disable-next-line @typescript-eslint/no-loop-func
|
|
347
446
|
.then(function () {
|
|
@@ -352,20 +451,20 @@ export var DocumentConnectionManager = (_dec = singleton({
|
|
|
352
451
|
});
|
|
353
452
|
case 9:
|
|
354
453
|
console.warn('will attempt to re-connect in ' + interval / 1000 + ' seconds');
|
|
355
|
-
|
|
454
|
+
_context2.next = 12;
|
|
356
455
|
return sleep(interval);
|
|
357
456
|
case 12:
|
|
358
457
|
// gradually increase the time delay, up to 5 sec
|
|
359
458
|
interval = interval < 5 * 1000 ? interval + 500 : interval;
|
|
360
|
-
|
|
459
|
+
_context2.next = 6;
|
|
361
460
|
break;
|
|
362
461
|
case 15:
|
|
363
462
|
case "end":
|
|
364
|
-
return
|
|
463
|
+
return _context2.stop();
|
|
365
464
|
}
|
|
366
|
-
},
|
|
465
|
+
}, _callee2, this);
|
|
367
466
|
}));
|
|
368
|
-
function retryToConnect(
|
|
467
|
+
function retryToConnect(_x6, _x7) {
|
|
369
468
|
return _retryToConnect.apply(this, arguments);
|
|
370
469
|
}
|
|
371
470
|
return retryToConnect;
|
|
@@ -377,7 +476,7 @@ export var DocumentConnectionManager = (_dec = singleton({
|
|
|
377
476
|
}, {
|
|
378
477
|
key: "disconnect",
|
|
379
478
|
value: function disconnect(languageId) {
|
|
380
|
-
|
|
479
|
+
this.disconnect(languageId);
|
|
381
480
|
}
|
|
382
481
|
|
|
383
482
|
/**
|
|
@@ -387,70 +486,70 @@ export var DocumentConnectionManager = (_dec = singleton({
|
|
|
387
486
|
}, {
|
|
388
487
|
key: "connect",
|
|
389
488
|
value: function () {
|
|
390
|
-
var _connect = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
489
|
+
var _connect = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(options) {
|
|
391
490
|
var firstTimeoutSeconds,
|
|
392
491
|
secondTimeoutMinutes,
|
|
393
492
|
connection,
|
|
394
493
|
virtualDocument,
|
|
395
|
-
|
|
396
|
-
return _regeneratorRuntime().wrap(function
|
|
397
|
-
while (1) switch (
|
|
494
|
+
_args3 = arguments;
|
|
495
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
496
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
398
497
|
case 0:
|
|
399
|
-
firstTimeoutSeconds =
|
|
400
|
-
secondTimeoutMinutes =
|
|
401
|
-
|
|
498
|
+
firstTimeoutSeconds = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : 30;
|
|
499
|
+
secondTimeoutMinutes = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : 5;
|
|
500
|
+
_context3.next = 4;
|
|
402
501
|
return this._connectSocket(options);
|
|
403
502
|
case 4:
|
|
404
|
-
connection =
|
|
503
|
+
connection = _context3.sent;
|
|
405
504
|
virtualDocument = options.virtualDocument;
|
|
406
505
|
if (connection) {
|
|
407
|
-
|
|
506
|
+
_context3.next = 8;
|
|
408
507
|
break;
|
|
409
508
|
}
|
|
410
|
-
return
|
|
509
|
+
return _context3.abrupt("return");
|
|
411
510
|
case 8:
|
|
412
511
|
if (connection.isReady) {
|
|
413
|
-
|
|
512
|
+
_context3.next = 26;
|
|
414
513
|
break;
|
|
415
514
|
}
|
|
416
|
-
|
|
417
|
-
|
|
515
|
+
_context3.prev = 9;
|
|
516
|
+
_context3.next = 12;
|
|
418
517
|
return untilReady(function () {
|
|
419
518
|
return connection.isReady;
|
|
420
519
|
}, Math.round(firstTimeoutSeconds * 1000 / 150), 150);
|
|
421
520
|
case 12:
|
|
422
|
-
|
|
521
|
+
_context3.next = 26;
|
|
423
522
|
break;
|
|
424
523
|
case 14:
|
|
425
|
-
|
|
426
|
-
|
|
524
|
+
_context3.prev = 14;
|
|
525
|
+
_context3.t0 = _context3["catch"](9);
|
|
427
526
|
console.warn("Connection to ".concat(virtualDocument.uri, " timed out after ").concat(firstTimeoutSeconds, " seconds, will continue retrying for another ").concat(secondTimeoutMinutes, " minutes"));
|
|
428
|
-
|
|
429
|
-
|
|
527
|
+
_context3.prev = 17;
|
|
528
|
+
_context3.next = 20;
|
|
430
529
|
return untilReady(function () {
|
|
431
530
|
return connection.isReady;
|
|
432
531
|
}, 60 * secondTimeoutMinutes, 1000);
|
|
433
532
|
case 20:
|
|
434
|
-
|
|
533
|
+
_context3.next = 26;
|
|
435
534
|
break;
|
|
436
535
|
case 22:
|
|
437
|
-
|
|
438
|
-
|
|
536
|
+
_context3.prev = 22;
|
|
537
|
+
_context3.t1 = _context3["catch"](17);
|
|
439
538
|
console.warn("Connection to ".concat(virtualDocument.uri, " timed out again after ").concat(secondTimeoutMinutes, " minutes, giving up"));
|
|
440
|
-
return
|
|
539
|
+
return _context3.abrupt("return");
|
|
441
540
|
case 26:
|
|
442
541
|
this._connected.fire({
|
|
443
542
|
connection: connection,
|
|
444
543
|
virtualDocument: virtualDocument
|
|
445
544
|
});
|
|
446
|
-
return
|
|
545
|
+
return _context3.abrupt("return", connection);
|
|
447
546
|
case 28:
|
|
448
547
|
case "end":
|
|
449
|
-
return
|
|
548
|
+
return _context3.stop();
|
|
450
549
|
}
|
|
451
|
-
},
|
|
550
|
+
}, _callee3, this, [[9, 14], [17, 22]]);
|
|
452
551
|
}));
|
|
453
|
-
function connect(
|
|
552
|
+
function connect(_x8) {
|
|
454
553
|
return _connect.apply(this, arguments);
|
|
455
554
|
}
|
|
456
555
|
return connect;
|
|
@@ -509,14 +608,14 @@ export var DocumentConnectionManager = (_dec = singleton({
|
|
|
509
608
|
}, {
|
|
510
609
|
key: "_connectSocket",
|
|
511
610
|
value: function () {
|
|
512
|
-
var _connectSocket2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
611
|
+
var _connectSocket2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(options) {
|
|
513
612
|
var language, capabilities, virtualDocument, uris, matchingServers, languageServerId, connection;
|
|
514
|
-
return _regeneratorRuntime().wrap(function
|
|
515
|
-
while (1) switch (
|
|
613
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
614
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
516
615
|
case 0:
|
|
517
616
|
language = options.language, capabilities = options.capabilities, virtualDocument = options.virtualDocument;
|
|
518
617
|
this.connectDocumentSignals(virtualDocument);
|
|
519
|
-
uris =
|
|
618
|
+
uris = this.solveUris(virtualDocument, language);
|
|
520
619
|
matchingServers = this.languageServerManager.getMatchingServers({
|
|
521
620
|
language: language
|
|
522
621
|
}); // for now use only the server with the highest rank.
|
|
@@ -524,26 +623,26 @@ export var DocumentConnectionManager = (_dec = singleton({
|
|
|
524
623
|
// like connection: either already connected or potentially in the process
|
|
525
624
|
// of connecting.
|
|
526
625
|
if (uris) {
|
|
527
|
-
|
|
626
|
+
_context4.next = 7;
|
|
528
627
|
break;
|
|
529
628
|
}
|
|
530
|
-
return
|
|
629
|
+
return _context4.abrupt("return");
|
|
531
630
|
case 7:
|
|
532
|
-
|
|
533
|
-
return
|
|
631
|
+
_context4.next = 9;
|
|
632
|
+
return this.connection(language, languageServerId, uris, this.onNewConnection, capabilities);
|
|
534
633
|
case 9:
|
|
535
|
-
connection =
|
|
634
|
+
connection = _context4.sent;
|
|
536
635
|
// if connecting for the first time, all documents subsequent documents will
|
|
537
636
|
// be re-opened and synced
|
|
538
637
|
this.connections.set(virtualDocument.uri, connection);
|
|
539
|
-
return
|
|
638
|
+
return _context4.abrupt("return", connection);
|
|
540
639
|
case 12:
|
|
541
640
|
case "end":
|
|
542
|
-
return
|
|
641
|
+
return _context4.stop();
|
|
543
642
|
}
|
|
544
|
-
},
|
|
643
|
+
}, _callee4, this);
|
|
545
644
|
}));
|
|
546
|
-
function _connectSocket(
|
|
645
|
+
function _connectSocket(_x9) {
|
|
547
646
|
return _connectSocket2.apply(this, arguments);
|
|
548
647
|
}
|
|
549
648
|
return _connectSocket;
|
|
@@ -578,108 +677,9 @@ export var DocumentConnectionManager = (_dec = singleton({
|
|
|
578
677
|
*/
|
|
579
678
|
}]);
|
|
580
679
|
return DocumentConnectionManager;
|
|
581
|
-
}()
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
* @param language - language of the document
|
|
588
|
-
*/
|
|
589
|
-
function solveUris(virtualDocument, language) {
|
|
590
|
-
var wsBase = PageConfig.getBaseUrl().replace(/^http/, 'ws');
|
|
591
|
-
var rootUri = PageConfig.getOption('rootUri');
|
|
592
|
-
var virtualDocumentsUri = PageConfig.getOption('virtualDocumentsUri');
|
|
593
|
-
var baseUri = virtualDocument.hasLspSupportedFile ? rootUri : virtualDocumentsUri;
|
|
594
|
-
|
|
595
|
-
// for now take the best match only
|
|
596
|
-
var matchingServers = Private.getLanguageServerManager().getMatchingServers({
|
|
597
|
-
language: language
|
|
598
|
-
});
|
|
599
|
-
var languageServerId = matchingServers.length === 0 ? null : matchingServers[0];
|
|
600
|
-
if (languageServerId === null) {
|
|
601
|
-
return;
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
// workaround url-parse bug(s) (see https://github.com/jupyter-lsp/jupyterlab-lsp/issues/595)
|
|
605
|
-
var documentUri = URL.join(baseUri, virtualDocument.uri);
|
|
606
|
-
if (!documentUri.startsWith('file:///') && documentUri.startsWith('file://')) {
|
|
607
|
-
documentUri = documentUri.replace('file://', 'file:///');
|
|
608
|
-
if (documentUri.startsWith('file:///users/') && baseUri.startsWith('file:///Users/')) {
|
|
609
|
-
documentUri = documentUri.replace('file:///users/', 'file:///Users/');
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
return {
|
|
613
|
-
base: baseUri,
|
|
614
|
-
document: documentUri,
|
|
615
|
-
server: URL.join('ws://jupyter-lsp', language),
|
|
616
|
-
socket: URL.join(wsBase, 'lsp', 'ws', languageServerId)
|
|
617
|
-
};
|
|
618
|
-
}
|
|
619
|
-
_DocumentConnectionManager.solveUris = solveUris;
|
|
620
|
-
})(DocumentConnectionManager || (DocumentConnectionManager = {}));
|
|
621
|
-
/**
|
|
622
|
-
* Namespace primarily for language-keyed cache of LSPConnections
|
|
623
|
-
*/
|
|
624
|
-
var Private;
|
|
625
|
-
(function (_Private) {
|
|
626
|
-
var _connections = new Map();
|
|
627
|
-
var _languageServerManager;
|
|
628
|
-
function getLanguageServerManager() {
|
|
629
|
-
return _languageServerManager;
|
|
630
|
-
}
|
|
631
|
-
_Private.getLanguageServerManager = getLanguageServerManager;
|
|
632
|
-
function setLanguageServerManager(languageServerManager) {
|
|
633
|
-
_languageServerManager = languageServerManager;
|
|
634
|
-
}
|
|
635
|
-
_Private.setLanguageServerManager = setLanguageServerManager;
|
|
636
|
-
function disconnect(languageServerId) {
|
|
637
|
-
var connection = _connections.get(languageServerId);
|
|
638
|
-
if (connection) {
|
|
639
|
-
connection.close();
|
|
640
|
-
_connections.delete(languageServerId);
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
_Private.disconnect = disconnect;
|
|
644
|
-
function connection(_x5, _x6, _x7, _x8, _x9) {
|
|
645
|
-
return _connection.apply(this, arguments);
|
|
646
|
-
}
|
|
647
|
-
function _connection() {
|
|
648
|
-
_connection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(language, languageServerId, uris, onCreate, capabilities) {
|
|
649
|
-
var connection, socket, _connection2;
|
|
650
|
-
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
651
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
652
|
-
case 0:
|
|
653
|
-
connection = _connections.get(languageServerId);
|
|
654
|
-
if (!connection) {
|
|
655
|
-
socket = new WebSocket(uris.socket);
|
|
656
|
-
_connection2 = new LSPConnection({
|
|
657
|
-
languageId: language,
|
|
658
|
-
serverUri: uris.server,
|
|
659
|
-
rootUri: uris.base,
|
|
660
|
-
serverIdentifier: languageServerId,
|
|
661
|
-
capabilities: capabilities
|
|
662
|
-
});
|
|
663
|
-
_connections.set(languageServerId, _connection2);
|
|
664
|
-
_connection2.connect(socket);
|
|
665
|
-
onCreate(_connection2);
|
|
666
|
-
}
|
|
667
|
-
connection = _connections.get(languageServerId);
|
|
668
|
-
return _context4.abrupt("return", connection);
|
|
669
|
-
case 4:
|
|
670
|
-
case "end":
|
|
671
|
-
return _context4.stop();
|
|
672
|
-
}
|
|
673
|
-
}, _callee4);
|
|
674
|
-
}));
|
|
675
|
-
return _connection.apply(this, arguments);
|
|
676
|
-
}
|
|
677
|
-
_Private.connection = connection;
|
|
678
|
-
function updateServerConfiguration(languageServerId, settings) {
|
|
679
|
-
var connection = _connections.get(languageServerId);
|
|
680
|
-
if (connection) {
|
|
681
|
-
connection.sendConfigurationChange(settings);
|
|
682
|
-
}
|
|
683
|
-
}
|
|
684
|
-
_Private.updateServerConfiguration = updateServerConfiguration;
|
|
685
|
-
})(Private || (Private = {}));
|
|
680
|
+
}(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "lspConnectionFactory", [_dec2], {
|
|
681
|
+
configurable: true,
|
|
682
|
+
enumerable: true,
|
|
683
|
+
writable: true,
|
|
684
|
+
initializer: null
|
|
685
|
+
})), _class2)) || _class);
|
package/es/connection.d.ts
CHANGED
|
@@ -1,24 +1,17 @@
|
|
|
1
1
|
import type { Event } from '@difizen/mana-app';
|
|
2
2
|
import { Emitter } from '@difizen/mana-app';
|
|
3
3
|
import type * as lsp from 'vscode-languageserver-protocol';
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
4
|
+
import type { IMessageLog } from './lsp-protocol.js';
|
|
5
|
+
import { MessageKind } from './lsp-protocol.js';
|
|
6
|
+
import { LSPMonitor } from './monitor.js';
|
|
7
|
+
import { Method, ILSPOptions } from './tokens.js';
|
|
8
|
+
import type { ClientNotifications, ClientRequests, IDocumentInfo, ILSPConnection, ServerNotifications, ServerRequests } from './tokens.js';
|
|
6
9
|
import { LspWsConnection } from './ws-connection/ws-connection.js';
|
|
7
10
|
export declare const Provider: Record<string, keyof lsp.ServerCapabilities>;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
clientNotifiedServer = 0,
|
|
11
|
-
serverNotifiedClient = 1,
|
|
12
|
-
serverRequested = 2,
|
|
13
|
-
clientRequested = 3,
|
|
14
|
-
resultForClient = 4,
|
|
15
|
-
responseForServer = 5
|
|
16
|
-
}
|
|
17
|
-
interface IMessageLog<T extends AnyMethod = AnyMethod> {
|
|
18
|
-
method: T;
|
|
19
|
-
message: any;
|
|
20
|
-
}
|
|
11
|
+
export declare const LSPConnectionFactory: unique symbol;
|
|
12
|
+
export type LSPConnectionFactory = (options: ILSPOptions) => LSPConnection;
|
|
21
13
|
export declare class LSPConnection extends LspWsConnection implements ILSPConnection {
|
|
14
|
+
lspmonitor: LSPMonitor;
|
|
22
15
|
constructor(options: ILSPOptions);
|
|
23
16
|
/**
|
|
24
17
|
* Identifier of the language server
|
|
@@ -145,5 +138,4 @@ export declare class LSPConnection extends LspWsConnection implements ILSPConnec
|
|
|
145
138
|
*/
|
|
146
139
|
protected _sendChange(changeEvents: lsp.TextDocumentContentChangeEvent[], documentInfo: IDocumentInfo): void;
|
|
147
140
|
}
|
|
148
|
-
export {};
|
|
149
141
|
//# sourceMappingURL=connection.d.ts.map
|