@cedarjs/structure 0.0.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.
Files changed (138) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +145 -0
  3. package/dist/errors.d.ts +11 -0
  4. package/dist/errors.d.ts.map +1 -0
  5. package/dist/errors.js +19 -0
  6. package/dist/hosts.d.ts +23 -0
  7. package/dist/hosts.d.ts.map +1 -0
  8. package/dist/hosts.js +45 -0
  9. package/dist/ide.d.ts +122 -0
  10. package/dist/ide.d.ts.map +1 -0
  11. package/dist/ide.js +240 -0
  12. package/dist/index.d.ts +12 -0
  13. package/dist/index.d.ts.map +1 -0
  14. package/dist/index.js +79 -0
  15. package/dist/interactive_cli/RedwoodCommandString.d.ts +20 -0
  16. package/dist/interactive_cli/RedwoodCommandString.d.ts.map +1 -0
  17. package/dist/interactive_cli/RedwoodCommandString.js +72 -0
  18. package/dist/interactive_cli/command_builder.d.ts +10 -0
  19. package/dist/interactive_cli/command_builder.d.ts.map +1 -0
  20. package/dist/interactive_cli/command_builder.js +196 -0
  21. package/dist/interactive_cli/dry_run.d.ts +28 -0
  22. package/dist/interactive_cli/dry_run.d.ts.map +1 -0
  23. package/dist/interactive_cli/dry_run.js +101 -0
  24. package/dist/interactive_cli/ui.d.ts +32 -0
  25. package/dist/interactive_cli/ui.d.ts.map +1 -0
  26. package/dist/interactive_cli/ui.js +84 -0
  27. package/dist/language_server/RWLanguageServer.d.ts +30 -0
  28. package/dist/language_server/RWLanguageServer.d.ts.map +1 -0
  29. package/dist/language_server/RWLanguageServer.js +201 -0
  30. package/dist/language_server/commands.d.ts +14 -0
  31. package/dist/language_server/commands.d.ts.map +1 -0
  32. package/dist/language_server/commands.js +122 -0
  33. package/dist/language_server/diagnostics.d.ts +10 -0
  34. package/dist/language_server/diagnostics.d.ts.map +1 -0
  35. package/dist/language_server/diagnostics.js +61 -0
  36. package/dist/language_server/outline.d.ts +7 -0
  37. package/dist/language_server/outline.d.ts.map +1 -0
  38. package/dist/language_server/outline.js +37 -0
  39. package/dist/language_server/start.d.ts +2 -0
  40. package/dist/language_server/start.d.ts.map +1 -0
  41. package/dist/language_server/start.js +4 -0
  42. package/dist/language_server/xmethods.d.ts +11 -0
  43. package/dist/language_server/xmethods.d.ts.map +1 -0
  44. package/dist/language_server/xmethods.js +42 -0
  45. package/dist/model/RWCell.d.ts +22 -0
  46. package/dist/model/RWCell.d.ts.map +1 -0
  47. package/dist/model/RWCell.js +111 -0
  48. package/dist/model/RWComponent.d.ts +11 -0
  49. package/dist/model/RWComponent.d.ts.map +1 -0
  50. package/dist/model/RWComponent.js +42 -0
  51. package/dist/model/RWEnvHelper.d.ts +64 -0
  52. package/dist/model/RWEnvHelper.d.ts.map +1 -0
  53. package/dist/model/RWEnvHelper.js +295 -0
  54. package/dist/model/RWFunction.d.ts +11 -0
  55. package/dist/model/RWFunction.d.ts.map +1 -0
  56. package/dist/model/RWFunction.js +19 -0
  57. package/dist/model/RWLayout.d.ts +11 -0
  58. package/dist/model/RWLayout.d.ts.map +1 -0
  59. package/dist/model/RWLayout.js +19 -0
  60. package/dist/model/RWPage.d.ts +13 -0
  61. package/dist/model/RWPage.d.ts.map +1 -0
  62. package/dist/model/RWPage.js +60 -0
  63. package/dist/model/RWProject.d.ts +61 -0
  64. package/dist/model/RWProject.d.ts.map +1 -0
  65. package/dist/model/RWProject.js +170 -0
  66. package/dist/model/RWRoute.d.ts +58 -0
  67. package/dist/model/RWRoute.d.ts.map +1 -0
  68. package/dist/model/RWRoute.js +416 -0
  69. package/dist/model/RWRouter.d.ts +30 -0
  70. package/dist/model/RWRouter.d.ts.map +1 -0
  71. package/dist/model/RWRouter.js +186 -0
  72. package/dist/model/RWSDL.d.ts +21 -0
  73. package/dist/model/RWSDL.d.ts.map +1 -0
  74. package/dist/model/RWSDL.js +89 -0
  75. package/dist/model/RWSDLField.d.ts +31 -0
  76. package/dist/model/RWSDLField.d.ts.map +1 -0
  77. package/dist/model/RWSDLField.js +132 -0
  78. package/dist/model/RWService.d.ts +26 -0
  79. package/dist/model/RWService.d.ts.map +1 -0
  80. package/dist/model/RWService.js +76 -0
  81. package/dist/model/RWServiceFunction.d.ts +20 -0
  82. package/dist/model/RWServiceFunction.d.ts.map +1 -0
  83. package/dist/model/RWServiceFunction.js +100 -0
  84. package/dist/model/RWTOML.d.ts +12 -0
  85. package/dist/model/RWTOML.d.ts.map +1 -0
  86. package/dist/model/RWTOML.js +56 -0
  87. package/dist/model/index.d.ts +2 -0
  88. package/dist/model/index.d.ts.map +1 -0
  89. package/dist/model/index.js +13 -0
  90. package/dist/model/util/advanced_path_parser.d.ts +12 -0
  91. package/dist/model/util/advanced_path_parser.d.ts.map +1 -0
  92. package/dist/model/util/advanced_path_parser.js +38 -0
  93. package/dist/model/util/process_env.d.ts +23 -0
  94. package/dist/model/util/process_env.d.ts.map +1 -0
  95. package/dist/model/util/process_env.js +76 -0
  96. package/dist/outline/index.d.ts +3 -0
  97. package/dist/outline/index.d.ts.map +1 -0
  98. package/dist/outline/index.js +31 -0
  99. package/dist/outline/outline.d.ts +4 -0
  100. package/dist/outline/outline.d.ts.map +1 -0
  101. package/dist/outline/outline.js +260 -0
  102. package/dist/outline/types.d.ts +88 -0
  103. package/dist/outline/types.d.ts.map +1 -0
  104. package/dist/outline/types.js +73 -0
  105. package/dist/util.d.ts +2 -0
  106. package/dist/util.d.ts.map +1 -0
  107. package/dist/util.js +34 -0
  108. package/dist/x/Array.d.ts +4 -0
  109. package/dist/x/Array.d.ts.map +1 -0
  110. package/dist/x/Array.js +26 -0
  111. package/dist/x/URL.d.ts +15 -0
  112. package/dist/x/URL.d.ts.map +1 -0
  113. package/dist/x/URL.js +99 -0
  114. package/dist/x/child_process.d.ts +15 -0
  115. package/dist/x/child_process.d.ts.map +1 -0
  116. package/dist/x/child_process.js +51 -0
  117. package/dist/x/decorators.d.ts +3 -0
  118. package/dist/x/decorators.d.ts.map +1 -0
  119. package/dist/x/decorators.js +26 -0
  120. package/dist/x/path.d.ts +6 -0
  121. package/dist/x/path.d.ts.map +1 -0
  122. package/dist/x/path.js +53 -0
  123. package/dist/x/prisma.d.ts +19 -0
  124. package/dist/x/prisma.d.ts.map +1 -0
  125. package/dist/x/prisma.js +65 -0
  126. package/dist/x/ts-morph.d.ts +10 -0
  127. package/dist/x/ts-morph.d.ts.map +1 -0
  128. package/dist/x/ts-morph.js +56 -0
  129. package/dist/x/vscode-languageserver-types.d.ts +93 -0
  130. package/dist/x/vscode-languageserver-types.d.ts.map +1 -0
  131. package/dist/x/vscode-languageserver-types.js +421 -0
  132. package/dist/x/vscode-languageserver.d.ts +12 -0
  133. package/dist/x/vscode-languageserver.d.ts.map +1 -0
  134. package/dist/x/vscode-languageserver.js +61 -0
  135. package/dist/x/vscode.d.ts +126 -0
  136. package/dist/x/vscode.d.ts.map +1 -0
  137. package/dist/x/vscode.js +294 -0
  138. package/package.json +67 -0
@@ -0,0 +1,421 @@
1
+ "use strict";
2
+
3
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js/object/define-property");
4
+ require("core-js/modules/esnext.array.group-by.js");
5
+ var _interopRequireWildcard = require("@babel/runtime-corejs3/helpers/interopRequireWildcard").default;
6
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
7
+ _Object$defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ exports.Diagnostic_compare = Diagnostic_compare;
11
+ exports.ExtendedDiagnostic_findRelevantQuickFixes = ExtendedDiagnostic_findRelevantQuickFixes;
12
+ exports.ExtendedDiagnostic_format = ExtendedDiagnostic_format;
13
+ exports.ExtendedDiagnostic_groupByUri = ExtendedDiagnostic_groupByUri;
14
+ exports.ExtendedDiagnostic_is = ExtendedDiagnostic_is;
15
+ exports.FileSet_fromTextDocuments = FileSet_fromTextDocuments;
16
+ exports.LocationLike_toHashLink = LocationLike_toHashLink;
17
+ exports.LocationLike_toLocation = LocationLike_toLocation;
18
+ exports.LocationLike_toTerminalLink = LocationLike_toTerminalLink;
19
+ exports.Location_fromFilePath = Location_fromFilePath;
20
+ exports.Location_fromNode = Location_fromNode;
21
+ exports.Location_overlaps = Location_overlaps;
22
+ exports.Position_compare = Position_compare;
23
+ exports.Position_fromOffset = Position_fromOffset;
24
+ exports.Position_fromOffsetOrFail = Position_fromOffsetOrFail;
25
+ exports.Position_fromTSMorphOffset = Position_fromTSMorphOffset;
26
+ exports.Position_translate = Position_translate;
27
+ exports.Range_contains = Range_contains;
28
+ exports.Range_equals = Range_equals;
29
+ exports.Range_fromNode = Range_fromNode;
30
+ exports.Range_full = Range_full;
31
+ exports.Range_overlaps = Range_overlaps;
32
+ exports.WorkspaceEdit_fromFileSet = WorkspaceEdit_fromFileSet;
33
+ exports.err = err;
34
+ var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/map"));
35
+ var _stringify = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/json/stringify"));
36
+ var _endsWith = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/ends-with"));
37
+ var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/keys"));
38
+ var _keys2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/object/keys"));
39
+ var _lineColumn = _interopRequireDefault(require("line-column"));
40
+ var _lodash = require("lodash");
41
+ var tsm = _interopRequireWildcard(require("ts-morph"));
42
+ var _vscodeLanguageserverTypes = require("vscode-languageserver-types");
43
+ var _URL = require("./URL");
44
+ function Range_contains(range, pos) {
45
+ if (Position_compare(range.start, pos) === 'greater') {
46
+ return false;
47
+ }
48
+ if (Position_compare(range.end, pos) === 'smaller') {
49
+ return false;
50
+ }
51
+ return true;
52
+ }
53
+ function Range_overlaps(range1, range2, consider0000) {
54
+ if (consider0000) {
55
+ if (Range_is0000(range1) || Range_is0000(range2)) {
56
+ return true;
57
+ }
58
+ }
59
+ const {
60
+ start,
61
+ end
62
+ } = range2;
63
+ if (Range_contains(range1, start)) {
64
+ return true;
65
+ }
66
+ if (Range_contains(range2, end)) {
67
+ return true;
68
+ }
69
+ return true;
70
+ }
71
+
72
+ /**
73
+ * p1 is greater|smaller|equal than/to p2
74
+ * @param p1
75
+ * @param p2
76
+ */
77
+ function Position_compare(p1, p2) {
78
+ if (p1.line > p2.line) {
79
+ return 'greater';
80
+ }
81
+ if (p2.line > p1.line) {
82
+ return 'smaller';
83
+ }
84
+ if (p1.character > p2.character) {
85
+ return 'greater';
86
+ }
87
+ if (p2.character > p1.character) {
88
+ return 'smaller';
89
+ }
90
+ return 'equal';
91
+ }
92
+
93
+ /**
94
+ * Create a new position relative to this position.
95
+ *
96
+ * @param lineDelta Delta value for the line value, default is `0`.
97
+ * @param characterDelta Delta value for the character value, default is `0`.
98
+ * @return A position which line and character is the sum of the current line and
99
+ * character and the corresponding deltas.
100
+ */
101
+ function Position_translate(pos, lineDelta = 0, characterDelta = 0) {
102
+ return {
103
+ line: pos.line + lineDelta,
104
+ character: pos.character + characterDelta
105
+ };
106
+ }
107
+ function Range_fromNode(node) {
108
+ const start = Position_fromTSMorphOffset(node.getStart(false), node.getSourceFile());
109
+ const end = Position_fromTSMorphOffset(node.getEnd(), node.getSourceFile());
110
+ return {
111
+ start,
112
+ end
113
+ };
114
+ }
115
+ function Location_fromNode(node) {
116
+ return {
117
+ uri: (0, _URL.URL_file)(node.getSourceFile().getFilePath()),
118
+ range: Range_fromNode(node)
119
+ };
120
+ }
121
+ function Location_fromFilePath(filePath) {
122
+ return {
123
+ uri: (0, _URL.URL_file)(filePath),
124
+ range: _vscodeLanguageserverTypes.Range.create(0, 0, 0, 0)
125
+ };
126
+ }
127
+
128
+ /**
129
+ * returns vscode-terminal-friendly (clickable) link with line/column information
130
+ * ex: "file:///foo.ts:2:3"
131
+ * @param loc
132
+ */
133
+ function LocationLike_toTerminalLink(loc) {
134
+ const {
135
+ uri,
136
+ range: {
137
+ start: {
138
+ line,
139
+ character
140
+ }
141
+ }
142
+ } = LocationLike_toLocation(loc);
143
+ return `${uri}:${line + 1}:${character + 1}`;
144
+ }
145
+
146
+ /**
147
+ * returns vscode-terminal-friendly (clickable) link with line/column information
148
+ * ex: "file:///foo.ts:2:3"
149
+ * @param loc
150
+ */
151
+ function LocationLike_toHashLink(loc) {
152
+ const {
153
+ uri,
154
+ range: {
155
+ start: {
156
+ line,
157
+ character
158
+ }
159
+ }
160
+ } = LocationLike_toLocation(loc);
161
+ return `${uri}#${line + 1}:${character + 1}`;
162
+ }
163
+ function LocationLike_toLocation(x) {
164
+ if (typeof x === 'string') {
165
+ return {
166
+ uri: (0, _URL.URL_file)(x),
167
+ range: _vscodeLanguageserverTypes.Range.create(0, 0, 0, 0)
168
+ };
169
+ }
170
+ if (typeof x === 'object') {
171
+ if (x instanceof tsm.Node) {
172
+ return Location_fromNode(x);
173
+ }
174
+ if (_vscodeLanguageserverTypes.Location.is(x)) {
175
+ return x;
176
+ }
177
+ if (ExtendedDiagnostic_is(x)) {
178
+ return {
179
+ uri: x.uri,
180
+ range: x.diagnostic.range
181
+ };
182
+ }
183
+ }
184
+ throw new Error();
185
+ }
186
+ function Location_overlaps(loc1, loc2, consider0000 = false) {
187
+ if (loc1.uri !== loc2.uri) {
188
+ return false;
189
+ }
190
+ return Range_overlaps(loc1.range, loc2.range, consider0000);
191
+ }
192
+
193
+ /**
194
+ * by convention, the range [0,0,0,0] means the complete document
195
+ * @param range
196
+ */
197
+ function Range_is0000(range) {
198
+ const {
199
+ start,
200
+ end
201
+ } = range;
202
+ return Position_is00(start) && Position_is00(end);
203
+ }
204
+ function Position_is00(pos) {
205
+ return pos.character === 0 && pos.line === 0;
206
+ }
207
+ function ExtendedDiagnostic_is(x) {
208
+ if (typeof x !== 'object') {
209
+ return false;
210
+ }
211
+ if (typeof x === 'undefined') {
212
+ return false;
213
+ }
214
+ if (typeof x.uri !== 'string') {
215
+ return false;
216
+ }
217
+ if (!_vscodeLanguageserverTypes.Diagnostic.is(x.diagnostic)) {
218
+ return false;
219
+ }
220
+ return true;
221
+ }
222
+ function ExtendedDiagnostic_groupByUri(ds) {
223
+ const grouped = (0, _lodash.groupBy)(ds, d => d.uri);
224
+ const dss = (0, _lodash.mapValues)(grouped, xds => {
225
+ const dd = (0, _map.default)(xds).call(xds, xd => xd.diagnostic);
226
+ return (0, _lodash.uniqBy)(dd, _stringify.default); // dedupe
227
+ });
228
+ return dss;
229
+ }
230
+ async function ExtendedDiagnostic_findRelevantQuickFixes(xd, context) {
231
+ // check context to see if any of the context.diagnostics are equivalent
232
+ for (const ctx_d of context.diagnostics) {
233
+ const node_d = xd.diagnostic;
234
+ if (Diagnostic_compare(ctx_d, node_d)) {
235
+ if (xd.quickFix) {
236
+ const a = await xd.quickFix();
237
+ if (a) {
238
+ a.kind = 'quickfix';
239
+ a.diagnostics = [ctx_d];
240
+ return [a];
241
+ }
242
+ }
243
+ }
244
+ }
245
+ return [];
246
+ }
247
+ function Position_fromTSMorphOffset(offset, sf) {
248
+ const {
249
+ line,
250
+ column
251
+ } = sf.getLineAndColumnAtPos(offset);
252
+ return {
253
+ character: column - 1,
254
+ line: line - 1
255
+ };
256
+ }
257
+ function Position_fromOffset(offset, text) {
258
+ const res = (0, _lineColumn.default)(text).fromIndex(offset);
259
+ if (!res) {
260
+ return undefined;
261
+ }
262
+ const {
263
+ line,
264
+ col
265
+ } = res;
266
+ return {
267
+ character: col - 1,
268
+ line: line - 1
269
+ };
270
+ }
271
+ function Position_fromOffsetOrFail(offset, text) {
272
+ const p = Position_fromOffset(offset, text);
273
+ if (!p) {
274
+ throw new Error('Position_fromOffsetOrFail');
275
+ }
276
+ return p;
277
+ }
278
+
279
+ /**
280
+ * The Diagnostic interface defined in vscode-languageserver-types
281
+ * does not include the document URI.
282
+ * This interface adds that, and a few other things.
283
+ */
284
+
285
+ /**
286
+ * Helper method to create diagnostics
287
+ * @param node
288
+ * @param message
289
+ */
290
+ function err(loc, message, code) {
291
+ const {
292
+ uri,
293
+ range
294
+ } = LocationLike_toLocation(loc);
295
+ return {
296
+ uri,
297
+ diagnostic: {
298
+ range,
299
+ message,
300
+ severity: _vscodeLanguageserverTypes.DiagnosticSeverity.Error,
301
+ code
302
+ }
303
+ };
304
+ }
305
+ function Diagnostic_compare(d1, d2) {
306
+ if (d1.code !== d2.code) {
307
+ return false;
308
+ }
309
+ if (d1.message !== d2.message) {
310
+ return false;
311
+ }
312
+ if (!Range_equals(d1.range, d2.range)) {
313
+ return false;
314
+ }
315
+ return true;
316
+ }
317
+ function Range_equals(r1, r2) {
318
+ return toArr(r1).join(',') === toArr(r2).join(',');
319
+ function toArr(r) {
320
+ return [r.start.line, r.start.character, r.end.line, r.end.character];
321
+ }
322
+ }
323
+ function DiagnosticSeverity_getLabel(severity) {
324
+ const {
325
+ Information,
326
+ Error,
327
+ Hint,
328
+ Warning
329
+ } = _vscodeLanguageserverTypes.DiagnosticSeverity;
330
+ const labels = {
331
+ [Information]: 'info',
332
+ [Error]: 'error',
333
+ [Hint]: 'hint',
334
+ [Warning]: 'warning'
335
+ };
336
+ return labels[severity ?? Information];
337
+ }
338
+ /**
339
+ * Returns a string representation of a diagnostic.
340
+ * TSC style single-line errors:
341
+ * ex: "b.ts:1:2: error: this is a message"
342
+ * ex: "/path/to/app/b.ts:1:2: info: this is a message"
343
+ */
344
+ function ExtendedDiagnostic_format(d, opts) {
345
+ const {
346
+ diagnostic: {
347
+ severity,
348
+ message,
349
+ code
350
+ }
351
+ } = d;
352
+ const cwd = opts?.cwd;
353
+ const getSeverityLabel = opts?.getSeverityLabel ?? DiagnosticSeverity_getLabel;
354
+ let base = 'file://';
355
+ if (cwd) {
356
+ base = (0, _URL.URL_file)(cwd);
357
+ }
358
+ if (!(0, _endsWith.default)(base).call(base, '/')) {
359
+ base += '/';
360
+ }
361
+ const file = LocationLike_toTerminalLink(d).substr(base.length);
362
+ const severityLabel = getSeverityLabel(severity);
363
+ const errorCode = code ? ` (${code})` : '';
364
+ const str = `${file}: ${severityLabel}${errorCode}: ${message}`;
365
+ return str;
366
+ }
367
+
368
+ /**
369
+ * a value of "null" means this file needs to be deleted
370
+ */
371
+
372
+ function FileSet_fromTextDocuments(documents) {
373
+ const files = {};
374
+ for (const uri of (0, _keys.default)(documents).call(documents)) {
375
+ files[uri] = documents.get(uri).getText();
376
+ }
377
+ return files;
378
+ }
379
+ function WorkspaceEdit_fromFileSet(files, getExistingFileText) {
380
+ const change = new _vscodeLanguageserverTypes.WorkspaceChange({
381
+ documentChanges: []
382
+ });
383
+ for (const uri of (0, _keys2.default)(files)) {
384
+ const content = files[uri];
385
+ if (typeof content !== 'string') {
386
+ change.deleteFile(uri, {
387
+ ignoreIfNotExists: true
388
+ });
389
+ continue;
390
+ } else {
391
+ const text = getExistingFileText?.(uri);
392
+ if (text) {
393
+ // file exists
394
+ //change.createFile(uri, { overwrite: true })
395
+ change.getTextEditChange({
396
+ uri,
397
+ version: null
398
+ }).replace(Range_full(text), content); // TODO: we could be more granular here
399
+ } else {
400
+ change.createFile(uri);
401
+ change.getTextEditChange({
402
+ uri,
403
+ version: null
404
+ }).insert(_vscodeLanguageserverTypes.Position.create(0, 0), content);
405
+ }
406
+ }
407
+ }
408
+ return change.edit;
409
+ }
410
+ function Range_full(text, cr = '\n') {
411
+ if (text === '') {
412
+ return _vscodeLanguageserverTypes.Range.create(0, 0, 0, 0);
413
+ }
414
+ const lines = text.split(cr);
415
+ if (lines.length === 0) {
416
+ return _vscodeLanguageserverTypes.Range.create(0, 0, 0, 0);
417
+ }
418
+ const start = _vscodeLanguageserverTypes.Position.create(0, 0);
419
+ const end = _vscodeLanguageserverTypes.Position.create(lines.length - 1, lines[lines.length - 1].length);
420
+ return _vscodeLanguageserverTypes.Range.create(start, end);
421
+ }
@@ -0,0 +1,12 @@
1
+ import type { Connection } from 'vscode-languageserver';
2
+ /**
3
+ * will monkey patch the connection object
4
+ * so that any errors thrown by subsequently installed handlers are caught and logged
5
+ * (ex: connection.onHover(() => throw new Error('oops!')))
6
+ * this prevents the LSP client, on the other end, to receive errors
7
+ * which can sometimes cause error messages to pop-up uncontrollably
8
+ *
9
+ * @param conn
10
+ */
11
+ export declare function Connection_suppressErrors<T extends Connection>(conn: T): void;
12
+ //# sourceMappingURL=vscode-languageserver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vscode-languageserver.d.ts","sourceRoot":"","sources":["../../src/x/vscode-languageserver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAEvD;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CAAC,CAAC,SAAS,UAAU,EAAE,IAAI,EAAE,CAAC,QA4BtE"}
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+
3
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js/object/define-property");
4
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
5
+ _Object$defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.Connection_suppressErrors = Connection_suppressErrors;
9
+ var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/object/keys"));
10
+ var _startsWith = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/starts-with"));
11
+ var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/instance/map"));
12
+ var _stringify = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/json/stringify"));
13
+ /**
14
+ * will monkey patch the connection object
15
+ * so that any errors thrown by subsequently installed handlers are caught and logged
16
+ * (ex: connection.onHover(() => throw new Error('oops!')))
17
+ * this prevents the LSP client, on the other end, to receive errors
18
+ * which can sometimes cause error messages to pop-up uncontrollably
19
+ *
20
+ * @param conn
21
+ */
22
+ function Connection_suppressErrors(conn) {
23
+ for (const k of (0, _keys.default)(conn)) {
24
+ if (!(0, _startsWith.default)(k).call(k, 'on')) {
25
+ continue;
26
+ } // only onHover, onCodeLens, etc?
27
+ const v = conn[k];
28
+ if (typeof v !== 'function') {
29
+ continue;
30
+ }
31
+ conn[k] = (...args) => {
32
+ const args2 = (0, _map.default)(args).call(args, arg => typeof arg === 'function' ? with_catch2(arg, (e, fargs) => {
33
+ const data = {
34
+ handler: k,
35
+ handlerInstallParams: args,
36
+ handlerExecParams: fargs,
37
+ error: e + ''
38
+ };
39
+ const dd = (0, _stringify.default)(data, null, 2);
40
+ conn.console.error(dd);
41
+ return null;
42
+ }) : arg);
43
+ return v.apply(conn, args2);
44
+ };
45
+ }
46
+ }
47
+ function with_catch2(f, clause) {
48
+ return (...args) => catch2(() => f(...args), e => clause(e, args));
49
+ function catch2(f, clause2) {
50
+ try {
51
+ const res = f();
52
+ if (typeof res?.then === 'function') {
53
+ // promise
54
+ return res.catch?.(clause2);
55
+ }
56
+ return res;
57
+ } catch (e) {
58
+ return clause2(e);
59
+ }
60
+ }
61
+ }
@@ -0,0 +1,126 @@
1
+ import type * as vscode from 'vscode';
2
+ import type { Connection as LSPConnection } from 'vscode-languageserver';
3
+ import type { Command } from 'vscode-languageserver-types';
4
+ import { Location } from 'vscode-languageserver-types';
5
+ export type VSCodeWindowMethods = Pick<typeof vscode.window, 'showInformationMessage' | 'showQuickPick' | 'showInputBox'> & {
6
+ createTerminal2(props: {
7
+ name: string;
8
+ cwd: string;
9
+ cmd: string;
10
+ }): void;
11
+ } & {
12
+ withProgress(opts: any, task: () => void): void;
13
+ };
14
+ export declare function VSCodeWindowMethods_fromConnection(connection: any): VSCodeWindowMethods;
15
+ export type SerializableTreeItem = ReplacePropTypes<vscode.TreeItem, {
16
+ resourceUri: string;
17
+ collapsibleState: TreeItemCollapsibleState2;
18
+ iconPath: ThemeIcon2;
19
+ command: Command;
20
+ }> & {
21
+ id: string;
22
+ } & {
23
+ menu?: TreeItemMenu;
24
+ };
25
+ /**
26
+ * menus types must be known beforehand.
27
+ * they are set up by the vscode extension in its package.json
28
+ */
29
+ type TreeItemMenu = MenuCLI | MenuRoute | MenuGroup | MenuWithDoc;
30
+ interface MenuCLI {
31
+ kind: 'cli';
32
+ doc?: Command;
33
+ run: Command;
34
+ }
35
+ interface MenuRoute {
36
+ kind: 'route';
37
+ openInBrowser?: Command;
38
+ openComponent?: Command;
39
+ openRoute?: Command;
40
+ }
41
+ interface MenuGroup {
42
+ kind: 'group';
43
+ add?: Command;
44
+ doc?: Command;
45
+ }
46
+ interface MenuWithDoc {
47
+ kind: 'withDoc';
48
+ doc?: Command;
49
+ }
50
+ /**
51
+ * Based on the actual TreeItem interface provided by VSCode.
52
+ * It has a few differences.
53
+ */
54
+ export type TreeItem2 = Partial<SerializableTreeItem> & {
55
+ key?: string;
56
+ children?(): vscode.ProviderResult<TreeItem2[]>;
57
+ };
58
+ export declare class TreeItem2Wrapper {
59
+ item: TreeItem2;
60
+ parent?: TreeItem2Wrapper | undefined;
61
+ indexInParent: number;
62
+ constructor(item: TreeItem2, parent?: TreeItem2Wrapper | undefined, indexInParent?: number);
63
+ get keys(): string[];
64
+ get key(): string;
65
+ get id(): string;
66
+ get collapsibleState(): TreeItemCollapsibleState2;
67
+ children(): Promise<TreeItem2Wrapper[]>;
68
+ findChild(key: string): Promise<TreeItem2Wrapper | undefined>;
69
+ findChildRec(keys: string[]): Promise<TreeItem2Wrapper | undefined>;
70
+ get serializableTreeItem(): SerializableTreeItem;
71
+ }
72
+ /**
73
+ * https://microsoft.github.io/vscode-codicons/dist/codicon.html
74
+ * plust a few extra icons provided by decoupled studio:
75
+ * - redwood
76
+ * - prisma
77
+ * - graphql
78
+ * - netlify
79
+ */
80
+ type ThemeIcon2 = string;
81
+ /**
82
+ * A copy of vscode.TreeItemCollapsibleState
83
+ * we don't want to have a runtime dependency on the vscode package
84
+ */
85
+ export declare enum TreeItemCollapsibleState2 {
86
+ /**
87
+ * Determines an item can be neither collapsed nor expanded. Implies it has no children.
88
+ */
89
+ None = 0,
90
+ /**
91
+ * Determines an item is collapsed
92
+ */
93
+ Collapsed = 1,
94
+ /**
95
+ * Determines an item is expanded
96
+ */
97
+ Expanded = 2
98
+ }
99
+ /**
100
+ * A vscode.TreeDataProvider that uses string IDs as elements
101
+ * and returns a SerializableTreeItem.
102
+ */
103
+ type RemoteTreeDataProvider = ReplacePropTypes<vscode.TreeDataProvider<string>, {
104
+ getTreeItem(id: string): Promise<SerializableTreeItem>;
105
+ }>;
106
+ export declare class RemoteTreeDataProviderImpl implements RemoteTreeDataProvider {
107
+ private getRoot;
108
+ private refreshInterval;
109
+ constructor(getRoot: () => TreeItem2, refreshInterval?: number);
110
+ private root;
111
+ private refresh;
112
+ private lazyInit;
113
+ private listeners;
114
+ onDidChangeTreeData(listener: (e: string | undefined) => void): any;
115
+ getTreeItem(id: string): Promise<SerializableTreeItem>;
116
+ getChildren(id?: string): Promise<string[]>;
117
+ }
118
+ export declare function RemoteTreeDataProvider_publishOverLSPConnection(tdp: RemoteTreeDataProvider, connection: LSPConnection, methodPrefix: string): void;
119
+ export declare function ProviderResult_normalize<T>(x: vscode.ProviderResult<T>): Promise<T | undefined>;
120
+ export declare function Command_open(uriOrLocation: string | Location): Command;
121
+ export declare function Command_cli(cmd: string, title?: string): Command;
122
+ type ReplacePropTypes<T extends object, Replacements extends object> = {
123
+ [K in keyof T]: K extends keyof Replacements ? Replacements[K] : T[K];
124
+ };
125
+ export {};
126
+ //# sourceMappingURL=vscode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vscode.d.ts","sourceRoot":"","sources":["../../src/x/vscode.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,MAAM,QAAQ,CAAA;AACrC,OAAO,KAAK,EAAE,UAAU,IAAI,aAAa,EAAE,MAAM,uBAAuB,CAAA;AACxE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAA;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AAItD,MAAM,MAAM,mBAAmB,GAAG,IAAI,CACpC,OAAO,MAAM,CAAC,MAAM,EACpB,wBAAwB,GAAG,eAAe,GAAG,cAAc,CAC5D,GAAG;IACF,eAAe,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,MA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