@difizen/libro-lsp 0.1.2
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/LICENSE +21 -0
- package/README.md +0 -0
- package/es/adapters/adapter.d.ts +255 -0
- package/es/adapters/adapter.d.ts.map +1 -0
- package/es/adapters/adapter.js +647 -0
- package/es/adapters/notebook-adapter.d.ts +150 -0
- package/es/adapters/notebook-adapter.d.ts.map +1 -0
- package/es/adapters/notebook-adapter.js +588 -0
- package/es/adapters/status-message.d.ts +48 -0
- package/es/adapters/status-message.d.ts.map +1 -0
- package/es/adapters/status-message.js +110 -0
- package/es/connection-manager.d.ts +199 -0
- package/es/connection-manager.d.ts.map +1 -0
- package/es/connection-manager.js +685 -0
- package/es/connection.d.ts +149 -0
- package/es/connection.d.ts.map +1 -0
- package/es/connection.js +591 -0
- package/es/extractors/index.d.ts +4 -0
- package/es/extractors/index.d.ts.map +1 -0
- package/es/extractors/index.js +6 -0
- package/es/extractors/manager.d.ts +31 -0
- package/es/extractors/manager.d.ts.map +1 -0
- package/es/extractors/manager.js +90 -0
- package/es/extractors/text-extractor.d.ts +56 -0
- package/es/extractors/text-extractor.d.ts.map +1 -0
- package/es/extractors/text-extractor.js +72 -0
- package/es/extractors/types.d.ts +68 -0
- package/es/extractors/types.d.ts.map +1 -0
- package/es/extractors/types.js +1 -0
- package/es/feature.d.ts +29 -0
- package/es/feature.d.ts.map +1 -0
- package/es/feature.js +85 -0
- package/es/index.d.ts +19 -0
- package/es/index.d.ts.map +1 -0
- package/es/index.js +21 -0
- package/es/lsp-app-contribution.d.ts +19 -0
- package/es/lsp-app-contribution.d.ts.map +1 -0
- package/es/lsp-app-contribution.js +155 -0
- package/es/lsp-protocol.d.ts +10 -0
- package/es/lsp-protocol.d.ts.map +1 -0
- package/es/lsp-protocol.js +1 -0
- package/es/lsp.d.ts +136 -0
- package/es/lsp.d.ts.map +1 -0
- package/es/lsp.js +141 -0
- package/es/manager.d.ts +142 -0
- package/es/manager.d.ts.map +1 -0
- package/es/manager.js +423 -0
- package/es/module.d.ts +3 -0
- package/es/module.d.ts.map +1 -0
- package/es/module.js +21 -0
- package/es/plugin.d.ts +56 -0
- package/es/plugin.d.ts.map +1 -0
- package/es/plugin.js +0 -0
- package/es/positioning.d.ts +66 -0
- package/es/positioning.d.ts.map +1 -0
- package/es/positioning.js +96 -0
- package/es/schema.d.ts +240 -0
- package/es/schema.d.ts.map +1 -0
- package/es/schema.js +0 -0
- package/es/tokens.d.ts +677 -0
- package/es/tokens.d.ts.map +1 -0
- package/es/tokens.js +183 -0
- package/es/utils.d.ts +33 -0
- package/es/utils.d.ts.map +1 -0
- package/es/utils.js +168 -0
- package/es/virtual/document.d.ts +546 -0
- package/es/virtual/document.d.ts.map +1 -0
- package/es/virtual/document.js +1263 -0
- package/es/ws-connection/server-capability-registration.d.ts +19 -0
- package/es/ws-connection/server-capability-registration.d.ts.map +1 -0
- package/es/ws-connection/server-capability-registration.js +51 -0
- package/es/ws-connection/types.d.ts +76 -0
- package/es/ws-connection/types.d.ts.map +1 -0
- package/es/ws-connection/types.js +1 -0
- package/es/ws-connection/ws-connection.d.ts +105 -0
- package/es/ws-connection/ws-connection.d.ts.map +1 -0
- package/es/ws-connection/ws-connection.js +301 -0
- package/package.json +67 -0
- package/src/adapters/adapter.ts +611 -0
- package/src/adapters/notebook-adapter.ts +463 -0
- package/src/adapters/status-message.ts +93 -0
- package/src/connection-manager.ts +626 -0
- package/src/connection.ts +570 -0
- package/src/extractors/index.ts +6 -0
- package/src/extractors/manager.ts +82 -0
- package/src/extractors/text-extractor.ts +94 -0
- package/src/extractors/types.ts +78 -0
- package/src/feature.ts +60 -0
- package/src/index.spec.ts +10 -0
- package/src/index.ts +21 -0
- package/src/lsp-app-contribution.ts +83 -0
- package/src/lsp-protocol.ts +10 -0
- package/src/lsp.ts +160 -0
- package/src/manager.ts +358 -0
- package/src/module.ts +32 -0
- package/src/plugin.ts +62 -0
- package/src/positioning.ts +121 -0
- package/src/schema.ts +249 -0
- package/src/tokens.ts +843 -0
- package/src/utils.ts +109 -0
- package/src/virtual/document.ts +1250 -0
- package/src/ws-connection/server-capability-registration.ts +77 -0
- package/src/ws-connection/types.ts +102 -0
- package/src/ws-connection/ws-connection.ts +320 -0
package/es/tokens.js
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-namespace */
|
|
2
|
+
// Copyright (c) Jupyter Development Team.
|
|
3
|
+
// Distributed under the terms of the Modified BSD License.
|
|
4
|
+
// import type { ServerConnection } from '@jupyterlab/services';
|
|
5
|
+
/**
|
|
6
|
+
* Example server keys==ids that are expected. The list is not exhaustive.
|
|
7
|
+
* Custom server keys are allowed. Constraining the values helps avoid errors,
|
|
8
|
+
* but at runtime any value is allowed.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Type alias for the server ids.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Type of language server configuration, it is a map between server
|
|
15
|
+
* id and its setting.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Type of language server session, it is a map between server
|
|
19
|
+
* id and the associated session.
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Type of language server specs, it is a map between server
|
|
23
|
+
* id and the associated specs.
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* Type alias for language server id, it helps to clarify other types.
|
|
27
|
+
*/
|
|
28
|
+
// export const ILanguageServerManager = Symbol('ILanguageServerManager');
|
|
29
|
+
/**
|
|
30
|
+
* Virtual document namespace
|
|
31
|
+
*/
|
|
32
|
+
export var Document;
|
|
33
|
+
/**
|
|
34
|
+
* LSP endpoint prefix.
|
|
35
|
+
*/
|
|
36
|
+
export var URL_NS = 'lsp';
|
|
37
|
+
export var ILanguageServerManagerFactory = Symbol('ILanguageServerManagerFactory');
|
|
38
|
+
export var ILanguageServerManagerOptions = Symbol('ILanguageServerManagerOptions');
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The argument for getting server session or specs.
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Option to create the websocket connection to the LSP proxy server
|
|
46
|
+
* on the backend.
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @alpha
|
|
51
|
+
*
|
|
52
|
+
* Interface describing the LSP connection state
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
export var ILSPDocumentConnectionManager = Symbol('ILSPDocumentConnectionManager');
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @alpha
|
|
59
|
+
*
|
|
60
|
+
* The LSP connection state manager
|
|
61
|
+
*/
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @alpha
|
|
65
|
+
*
|
|
66
|
+
* Interface describing the client feature
|
|
67
|
+
*/
|
|
68
|
+
|
|
69
|
+
export var ILSPFeatureManager = Symbol('ILSPFeatureManager');
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @alpha
|
|
73
|
+
*
|
|
74
|
+
* The LSP feature manager
|
|
75
|
+
*/
|
|
76
|
+
|
|
77
|
+
export var ILSPCodeExtractorsManager = Symbol('ILSPCodeExtractorsManager');
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* @alpha
|
|
81
|
+
*
|
|
82
|
+
* Manages code transclusion plugins.
|
|
83
|
+
*/
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Argument for creating a connection to the LSP proxy server.
|
|
87
|
+
*/
|
|
88
|
+
/**
|
|
89
|
+
* Method strings are reproduced here because a non-typing import of
|
|
90
|
+
* `vscode-languageserver-protocol` is ridiculously expensive.
|
|
91
|
+
*/
|
|
92
|
+
export var Method;
|
|
93
|
+
(function (_Method) {
|
|
94
|
+
var ServerNotification = /*#__PURE__*/function (ServerNotification) {
|
|
95
|
+
ServerNotification["PUBLISH_DIAGNOSTICS"] = "textDocument/publishDiagnostics";
|
|
96
|
+
ServerNotification["SHOW_MESSAGE"] = "window/showMessage";
|
|
97
|
+
ServerNotification["LOG_TRACE"] = "$/logTrace";
|
|
98
|
+
ServerNotification["LOG_MESSAGE"] = "window/logMessage";
|
|
99
|
+
return ServerNotification;
|
|
100
|
+
}({});
|
|
101
|
+
_Method.ServerNotification = ServerNotification;
|
|
102
|
+
var ClientNotification = /*#__PURE__*/function (ClientNotification) {
|
|
103
|
+
ClientNotification["DID_CHANGE"] = "textDocument/didChange";
|
|
104
|
+
ClientNotification["DID_CHANGE_CONFIGURATION"] = "workspace/didChangeConfiguration";
|
|
105
|
+
ClientNotification["DID_OPEN"] = "textDocument/didOpen";
|
|
106
|
+
ClientNotification["DID_SAVE"] = "textDocument/didSave";
|
|
107
|
+
ClientNotification["INITIALIZED"] = "initialized";
|
|
108
|
+
ClientNotification["SET_TRACE"] = "$/setTrace";
|
|
109
|
+
return ClientNotification;
|
|
110
|
+
}({});
|
|
111
|
+
_Method.ClientNotification = ClientNotification;
|
|
112
|
+
var ServerRequest = /*#__PURE__*/function (ServerRequest) {
|
|
113
|
+
ServerRequest["REGISTER_CAPABILITY"] = "client/registerCapability";
|
|
114
|
+
ServerRequest["SHOW_MESSAGE_REQUEST"] = "window/showMessageRequest";
|
|
115
|
+
ServerRequest["UNREGISTER_CAPABILITY"] = "client/unregisterCapability";
|
|
116
|
+
ServerRequest["WORKSPACE_CONFIGURATION"] = "workspace/configuration";
|
|
117
|
+
return ServerRequest;
|
|
118
|
+
}({});
|
|
119
|
+
_Method.ServerRequest = ServerRequest;
|
|
120
|
+
var ClientRequest = /*#__PURE__*/function (ClientRequest) {
|
|
121
|
+
ClientRequest["COMPLETION"] = "textDocument/completion";
|
|
122
|
+
ClientRequest["COMPLETION_ITEM_RESOLVE"] = "completionItem/resolve";
|
|
123
|
+
ClientRequest["DEFINITION"] = "textDocument/definition";
|
|
124
|
+
ClientRequest["DOCUMENT_HIGHLIGHT"] = "textDocument/documentHighlight";
|
|
125
|
+
ClientRequest["DOCUMENT_SYMBOL"] = "textDocument/documentSymbol";
|
|
126
|
+
ClientRequest["HOVER"] = "textDocument/hover";
|
|
127
|
+
ClientRequest["IMPLEMENTATION"] = "textDocument/implementation";
|
|
128
|
+
ClientRequest["INITIALIZE"] = "initialize";
|
|
129
|
+
ClientRequest["REFERENCES"] = "textDocument/references";
|
|
130
|
+
ClientRequest["RENAME"] = "textDocument/rename";
|
|
131
|
+
ClientRequest["SIGNATURE_HELP"] = "textDocument/signatureHelp";
|
|
132
|
+
ClientRequest["TYPE_DEFINITION"] = "textDocument/typeDefinition";
|
|
133
|
+
ClientRequest["FORMATTING"] = "textDocument/formatting";
|
|
134
|
+
ClientRequest["RANGE_FORMATTING"] = "textDocument/rangeFormatting";
|
|
135
|
+
return ClientRequest;
|
|
136
|
+
}({});
|
|
137
|
+
_Method.ClientRequest = ClientRequest;
|
|
138
|
+
})(Method || (Method = {}));
|
|
139
|
+
/**
|
|
140
|
+
* Interface describing the notifications that come from the server.
|
|
141
|
+
*/
|
|
142
|
+
/**
|
|
143
|
+
* Interface describing the notifications that come from the client.
|
|
144
|
+
*/
|
|
145
|
+
/**
|
|
146
|
+
* Interface describing the requests sent to the server.
|
|
147
|
+
*/
|
|
148
|
+
/**
|
|
149
|
+
* Interface describing the responses received from the server.
|
|
150
|
+
*/
|
|
151
|
+
/**
|
|
152
|
+
* Interface describing the request sent to the client.
|
|
153
|
+
*/
|
|
154
|
+
/**
|
|
155
|
+
* Interface describing the responses received from the client.
|
|
156
|
+
*/
|
|
157
|
+
/**
|
|
158
|
+
* Type of server notification handlers, it is a map between the server
|
|
159
|
+
* notification name and the associated `ISignal`.
|
|
160
|
+
*/
|
|
161
|
+
/**
|
|
162
|
+
* Type of client notification handlers, it is a map between the client
|
|
163
|
+
* notification name and the associated signal.
|
|
164
|
+
*/
|
|
165
|
+
/**
|
|
166
|
+
* Interface describing the client request handler.
|
|
167
|
+
*/
|
|
168
|
+
/**
|
|
169
|
+
* Interface describing the server request handler.
|
|
170
|
+
*/
|
|
171
|
+
/**
|
|
172
|
+
* Type of client request handlers, it is a map between the client
|
|
173
|
+
* request name and the associated handler.
|
|
174
|
+
*/
|
|
175
|
+
/**
|
|
176
|
+
* Type of server request handlers, it is a map between the server
|
|
177
|
+
* request name and the associated handler.
|
|
178
|
+
*/
|
|
179
|
+
/**
|
|
180
|
+
* @alpha
|
|
181
|
+
*
|
|
182
|
+
* Interface describing he connection to the language server.
|
|
183
|
+
*/
|
package/es/utils.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ReadonlyJSONObject, ReadonlyJSONValue } from '@difizen/libro-common';
|
|
2
|
+
/**
|
|
3
|
+
* Helper to wait for timeout.
|
|
4
|
+
*
|
|
5
|
+
* @param timeout - time out in ms
|
|
6
|
+
*/
|
|
7
|
+
export declare function sleep(timeout: number): Promise<void>;
|
|
8
|
+
/**
|
|
9
|
+
* Wait for an event by pooling the `isReady` function.
|
|
10
|
+
*/
|
|
11
|
+
export declare function untilReady(isReady: CallableFunction, maxRetrials?: number, interval?: number, intervalModifier?: (i: number) => number): Promise<CallableFunction>;
|
|
12
|
+
/**
|
|
13
|
+
* Convert dotted path into dictionary.
|
|
14
|
+
*/
|
|
15
|
+
export declare function expandDottedPaths(obj: ReadonlyJSONObject): ReadonlyJSONObject;
|
|
16
|
+
/**
|
|
17
|
+
* The docs for many language servers show settings in the
|
|
18
|
+
* VSCode format, e.g.: "pyls.plugins.pyflakes.enabled"
|
|
19
|
+
*
|
|
20
|
+
* VSCode converts that dot notation to JSON behind the scenes,
|
|
21
|
+
* as the language servers themselves don't accept that syntax.
|
|
22
|
+
*/
|
|
23
|
+
export declare const expandPath: (path: string[], value: ReadonlyJSONValue) => ReadonlyJSONObject;
|
|
24
|
+
/**
|
|
25
|
+
* An extended map which will create value for key on the fly.
|
|
26
|
+
*/
|
|
27
|
+
export declare class DefaultMap<K, V> extends Map<K, V> {
|
|
28
|
+
protected defaultFactory: (...args: any[]) => V;
|
|
29
|
+
constructor(defaultFactory: (...args: any[]) => V, entries?: readonly (readonly [K, V])[] | null);
|
|
30
|
+
get(k: K): V;
|
|
31
|
+
getOrCreate(k: K, ...args: any[]): V;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAGnF;;;;GAIG;AACH,wBAAsB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAM1D;AAED;;GAEG;AACH,wBAAgB,UAAU,CACxB,OAAO,EAAE,gBAAgB,EACzB,WAAW,SAAK,EAChB,QAAQ,SAAK,EACb,gBAAgB,OAAO,MAAM,WAAM,GAClC,OAAO,CAAC,gBAAgB,CAAC,CAa3B;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,kBAAkB,GAAG,kBAAkB,CAO7E;AAED;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,SACf,MAAM,EAAE,SACP,iBAAiB,KACvB,kBAeF,CAAC;AAEF;;GAEG;AACH,qBAAa,UAAU,CAAC,CAAC,EAAE,CAAC,CAAE,SAAQ,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;IAG3C,SAAS,CAAC,cAAc,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC;gBAArC,cAAc,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,EAC/C,OAAO,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI;IAKtC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC;IAIrB,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC;CASrC"}
|
package/es/utils.js
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
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
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
3
|
+
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); } }
|
|
4
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
+
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); }
|
|
7
|
+
function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
|
|
8
|
+
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
|
9
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
10
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
11
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
12
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
13
|
+
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
|
|
14
|
+
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
|
|
15
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
16
|
+
function _isNativeFunction(fn) { try { return Function.toString.call(fn).indexOf("[native code]") !== -1; } catch (e) { return typeof fn === "function"; } }
|
|
17
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
18
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
19
|
+
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; }
|
|
20
|
+
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); } }
|
|
21
|
+
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); }); }; }
|
|
22
|
+
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
23
|
+
/* eslint-disable no-param-reassign */
|
|
24
|
+
// Copyright (c) Jupyter Development Team.
|
|
25
|
+
// Distributed under the terms of the Modified BSD License.
|
|
26
|
+
|
|
27
|
+
import mergeWith from 'lodash.mergewith';
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Helper to wait for timeout.
|
|
31
|
+
*
|
|
32
|
+
* @param timeout - time out in ms
|
|
33
|
+
*/
|
|
34
|
+
export function sleep(_x) {
|
|
35
|
+
return _sleep.apply(this, arguments);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Wait for an event by pooling the `isReady` function.
|
|
40
|
+
*/
|
|
41
|
+
function _sleep() {
|
|
42
|
+
_sleep = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(timeout) {
|
|
43
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
44
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
45
|
+
case 0:
|
|
46
|
+
return _context2.abrupt("return", new Promise(function (resolve) {
|
|
47
|
+
setTimeout(function () {
|
|
48
|
+
resolve();
|
|
49
|
+
}, timeout);
|
|
50
|
+
}));
|
|
51
|
+
case 1:
|
|
52
|
+
case "end":
|
|
53
|
+
return _context2.stop();
|
|
54
|
+
}
|
|
55
|
+
}, _callee2);
|
|
56
|
+
}));
|
|
57
|
+
return _sleep.apply(this, arguments);
|
|
58
|
+
}
|
|
59
|
+
export function untilReady(isReady) {
|
|
60
|
+
var maxRetrials = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 35;
|
|
61
|
+
var interval = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 50;
|
|
62
|
+
var intervalModifier = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : function (i) {
|
|
63
|
+
return i;
|
|
64
|
+
};
|
|
65
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
66
|
+
var i;
|
|
67
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
68
|
+
while (1) switch (_context.prev = _context.next) {
|
|
69
|
+
case 0:
|
|
70
|
+
i = 0;
|
|
71
|
+
case 1:
|
|
72
|
+
if (!(isReady() !== true)) {
|
|
73
|
+
_context.next = 10;
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
i += 1;
|
|
77
|
+
if (!(maxRetrials !== -1 && i > maxRetrials)) {
|
|
78
|
+
_context.next = 5;
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
throw Error('Too many retrials');
|
|
82
|
+
case 5:
|
|
83
|
+
interval = intervalModifier(interval);
|
|
84
|
+
_context.next = 8;
|
|
85
|
+
return sleep(interval);
|
|
86
|
+
case 8:
|
|
87
|
+
_context.next = 1;
|
|
88
|
+
break;
|
|
89
|
+
case 10:
|
|
90
|
+
return _context.abrupt("return", isReady);
|
|
91
|
+
case 11:
|
|
92
|
+
case "end":
|
|
93
|
+
return _context.stop();
|
|
94
|
+
}
|
|
95
|
+
}, _callee);
|
|
96
|
+
}))();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Convert dotted path into dictionary.
|
|
101
|
+
*/
|
|
102
|
+
export function expandDottedPaths(obj) {
|
|
103
|
+
var settings = [];
|
|
104
|
+
for (var key in obj) {
|
|
105
|
+
var parsed = expandPath(key.split('.'), obj[key]);
|
|
106
|
+
settings.push(parsed);
|
|
107
|
+
}
|
|
108
|
+
return mergeWith.apply(void 0, [{}].concat(settings));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* The docs for many language servers show settings in the
|
|
113
|
+
* VSCode format, e.g.: "pyls.plugins.pyflakes.enabled"
|
|
114
|
+
*
|
|
115
|
+
* VSCode converts that dot notation to JSON behind the scenes,
|
|
116
|
+
* as the language servers themselves don't accept that syntax.
|
|
117
|
+
*/
|
|
118
|
+
export var expandPath = function expandPath(path, value) {
|
|
119
|
+
var obj = Object.create(null);
|
|
120
|
+
var curr = obj;
|
|
121
|
+
path.forEach(function (prop, i) {
|
|
122
|
+
curr[prop] = Object.create(null);
|
|
123
|
+
if (i === path.length - 1) {
|
|
124
|
+
curr[prop] = value;
|
|
125
|
+
} else {
|
|
126
|
+
curr = curr[prop];
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
return obj;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* An extended map which will create value for key on the fly.
|
|
134
|
+
*/
|
|
135
|
+
export var DefaultMap = /*#__PURE__*/function (_Map) {
|
|
136
|
+
_inherits(DefaultMap, _Map);
|
|
137
|
+
var _super = _createSuper(DefaultMap);
|
|
138
|
+
function DefaultMap(
|
|
139
|
+
// eslint-disable-next-line @typescript-eslint/parameter-properties, @typescript-eslint/no-parameter-properties
|
|
140
|
+
defaultFactory, entries) {
|
|
141
|
+
var _this;
|
|
142
|
+
_classCallCheck(this, DefaultMap);
|
|
143
|
+
_this = _super.call(this, entries);
|
|
144
|
+
_this.defaultFactory = defaultFactory;
|
|
145
|
+
return _this;
|
|
146
|
+
}
|
|
147
|
+
_createClass(DefaultMap, [{
|
|
148
|
+
key: "get",
|
|
149
|
+
value: function get(k) {
|
|
150
|
+
return this.getOrCreate(k);
|
|
151
|
+
}
|
|
152
|
+
}, {
|
|
153
|
+
key: "getOrCreate",
|
|
154
|
+
value: function getOrCreate(k) {
|
|
155
|
+
if (this.has(k)) {
|
|
156
|
+
return _get(_getPrototypeOf(DefaultMap.prototype), "get", this).call(this, k);
|
|
157
|
+
} else {
|
|
158
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
159
|
+
args[_key - 1] = arguments[_key];
|
|
160
|
+
}
|
|
161
|
+
var v = this.defaultFactory.apply(this, [k].concat(args));
|
|
162
|
+
this.set(k, v);
|
|
163
|
+
return v;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}]);
|
|
167
|
+
return DefaultMap;
|
|
168
|
+
}( /*#__PURE__*/_wrapNativeSuper(Map));
|