@difizen/libro-codemirror 0.0.0-snapshot-20241017072317

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 (163) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +0 -0
  3. package/es/auto-complete/closebrackets.d.ts +12 -0
  4. package/es/auto-complete/closebrackets.d.ts.map +1 -0
  5. package/es/auto-complete/closebrackets.js +409 -0
  6. package/es/auto-complete/completion.d.ts +57 -0
  7. package/es/auto-complete/completion.d.ts.map +1 -0
  8. package/es/auto-complete/completion.js +267 -0
  9. package/es/auto-complete/config.d.ts +22 -0
  10. package/es/auto-complete/config.d.ts.map +1 -0
  11. package/es/auto-complete/config.js +44 -0
  12. package/es/auto-complete/filter.d.ts +13 -0
  13. package/es/auto-complete/filter.d.ts.map +1 -0
  14. package/es/auto-complete/filter.js +190 -0
  15. package/es/auto-complete/index.d.ts +17 -0
  16. package/es/auto-complete/index.d.ts.map +1 -0
  17. package/es/auto-complete/index.js +107 -0
  18. package/es/auto-complete/snippet.d.ts +14 -0
  19. package/es/auto-complete/snippet.d.ts.map +1 -0
  20. package/es/auto-complete/snippet.js +445 -0
  21. package/es/auto-complete/state.d.ts +63 -0
  22. package/es/auto-complete/state.d.ts.map +1 -0
  23. package/es/auto-complete/state.js +448 -0
  24. package/es/auto-complete/theme.d.ts +6 -0
  25. package/es/auto-complete/theme.d.ts.map +1 -0
  26. package/es/auto-complete/theme.js +150 -0
  27. package/es/auto-complete/tooltip.d.ts +5 -0
  28. package/es/auto-complete/tooltip.d.ts.map +1 -0
  29. package/es/auto-complete/tooltip.js +365 -0
  30. package/es/auto-complete/view.d.ts +38 -0
  31. package/es/auto-complete/view.d.ts.map +1 -0
  32. package/es/auto-complete/view.js +368 -0
  33. package/es/auto-complete/word.d.ts +3 -0
  34. package/es/auto-complete/word.d.ts.map +1 -0
  35. package/es/auto-complete/word.js +119 -0
  36. package/es/completion.d.ts +6 -0
  37. package/es/completion.d.ts.map +1 -0
  38. package/es/completion.js +84 -0
  39. package/es/config.d.ts +189 -0
  40. package/es/config.d.ts.map +1 -0
  41. package/es/config.js +482 -0
  42. package/es/editor-contribution.d.ts +9 -0
  43. package/es/editor-contribution.d.ts.map +1 -0
  44. package/es/editor-contribution.js +35 -0
  45. package/es/editor.d.ts +397 -0
  46. package/es/editor.d.ts.map +1 -0
  47. package/es/editor.js +1338 -0
  48. package/es/factory.d.ts +4 -0
  49. package/es/factory.d.ts.map +1 -0
  50. package/es/factory.js +24 -0
  51. package/es/hyperlink.d.ts +15 -0
  52. package/es/hyperlink.d.ts.map +1 -0
  53. package/es/hyperlink.js +120 -0
  54. package/es/indent.d.ts +8 -0
  55. package/es/indent.d.ts.map +1 -0
  56. package/es/indent.js +58 -0
  57. package/es/indentation-markers/config.d.ts +17 -0
  58. package/es/indentation-markers/config.d.ts.map +1 -0
  59. package/es/indentation-markers/config.js +10 -0
  60. package/es/indentation-markers/index.d.ts +3 -0
  61. package/es/indentation-markers/index.d.ts.map +1 -0
  62. package/es/indentation-markers/index.js +160 -0
  63. package/es/indentation-markers/map.d.ts +77 -0
  64. package/es/indentation-markers/map.d.ts.map +1 -0
  65. package/es/indentation-markers/map.js +265 -0
  66. package/es/indentation-markers/utils.d.ts +27 -0
  67. package/es/indentation-markers/utils.d.ts.map +1 -0
  68. package/es/indentation-markers/utils.js +91 -0
  69. package/es/index.d.ts +13 -0
  70. package/es/index.d.ts.map +1 -0
  71. package/es/index.js +12 -0
  72. package/es/libro-icon.d.ts +3 -0
  73. package/es/libro-icon.d.ts.map +1 -0
  74. package/es/libro-icon.js +2 -0
  75. package/es/lsp/completion.d.ts +5 -0
  76. package/es/lsp/completion.d.ts.map +1 -0
  77. package/es/lsp/completion.js +245 -0
  78. package/es/lsp/format.d.ts +7 -0
  79. package/es/lsp/format.d.ts.map +1 -0
  80. package/es/lsp/format.js +193 -0
  81. package/es/lsp/index.d.ts +7 -0
  82. package/es/lsp/index.d.ts.map +1 -0
  83. package/es/lsp/index.js +6 -0
  84. package/es/lsp/lint.d.ts +3 -0
  85. package/es/lsp/lint.d.ts.map +1 -0
  86. package/es/lsp/lint.js +113 -0
  87. package/es/lsp/protocol.d.ts +7 -0
  88. package/es/lsp/protocol.d.ts.map +1 -0
  89. package/es/lsp/protocol.js +1 -0
  90. package/es/lsp/tooltip.d.ts +3 -0
  91. package/es/lsp/tooltip.d.ts.map +1 -0
  92. package/es/lsp/tooltip.js +113 -0
  93. package/es/lsp/util.d.ts +15 -0
  94. package/es/lsp/util.d.ts.map +1 -0
  95. package/es/lsp/util.js +57 -0
  96. package/es/mimetype.d.ts +22 -0
  97. package/es/mimetype.d.ts.map +1 -0
  98. package/es/mimetype.js +59 -0
  99. package/es/mode.d.ts +86 -0
  100. package/es/mode.d.ts.map +1 -0
  101. package/es/mode.js +280 -0
  102. package/es/module.d.ts +3 -0
  103. package/es/module.d.ts.map +1 -0
  104. package/es/module.js +4 -0
  105. package/es/monitor.d.ts +32 -0
  106. package/es/monitor.d.ts.map +1 -0
  107. package/es/monitor.js +129 -0
  108. package/es/python-lang.d.ts +3 -0
  109. package/es/python-lang.d.ts.map +1 -0
  110. package/es/python-lang.js +7 -0
  111. package/es/style/base.css +129 -0
  112. package/es/style/theme.css +12 -0
  113. package/es/style/variables.css +405 -0
  114. package/es/theme.d.ts +35 -0
  115. package/es/theme.d.ts.map +1 -0
  116. package/es/theme.js +223 -0
  117. package/es/tooltip.d.ts +10 -0
  118. package/es/tooltip.d.ts.map +1 -0
  119. package/es/tooltip.js +168 -0
  120. package/package.json +74 -0
  121. package/src/auto-complete/README.md +71 -0
  122. package/src/auto-complete/closebrackets.ts +423 -0
  123. package/src/auto-complete/completion.ts +345 -0
  124. package/src/auto-complete/config.ts +101 -0
  125. package/src/auto-complete/filter.ts +214 -0
  126. package/src/auto-complete/index.ts +112 -0
  127. package/src/auto-complete/snippet.ts +392 -0
  128. package/src/auto-complete/state.ts +465 -0
  129. package/src/auto-complete/theme.ts +127 -0
  130. package/src/auto-complete/tooltip.ts +386 -0
  131. package/src/auto-complete/view.ts +339 -0
  132. package/src/auto-complete/word.ts +118 -0
  133. package/src/completion.ts +61 -0
  134. package/src/config.ts +701 -0
  135. package/src/editor-contribution.ts +22 -0
  136. package/src/editor.ts +1287 -0
  137. package/src/factory.ts +31 -0
  138. package/src/hyperlink.ts +95 -0
  139. package/src/indent.ts +69 -0
  140. package/src/indentation-markers/config.ts +31 -0
  141. package/src/indentation-markers/index.ts +192 -0
  142. package/src/indentation-markers/map.ts +273 -0
  143. package/src/indentation-markers/utils.ts +84 -0
  144. package/src/index.spec.ts +12 -0
  145. package/src/index.ts +14 -0
  146. package/src/libro-icon.tsx +4 -0
  147. package/src/lsp/completion.ts +175 -0
  148. package/src/lsp/format.ts +144 -0
  149. package/src/lsp/index.ts +6 -0
  150. package/src/lsp/lint.ts +125 -0
  151. package/src/lsp/protocol.ts +8 -0
  152. package/src/lsp/tooltip.ts +76 -0
  153. package/src/lsp/util.ts +69 -0
  154. package/src/mimetype.ts +49 -0
  155. package/src/mode.ts +265 -0
  156. package/src/module.ts +8 -0
  157. package/src/monitor.ts +105 -0
  158. package/src/python-lang.ts +7 -0
  159. package/src/style/base.css +129 -0
  160. package/src/style/theme.css +12 -0
  161. package/src/style/variables.css +405 -0
  162. package/src/theme.ts +231 -0
  163. package/src/tooltip.ts +143 -0
@@ -0,0 +1,265 @@
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 _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; } } }; }
3
+ 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); }
4
+ 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; }
5
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
+ 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); } }
7
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
8
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
9
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
10
+ import { indentationMarkerConfig } from "./config.js";
11
+ import { getCurrentLine, numColumns } from "./utils.js";
12
+ /**
13
+ * Indentation map for a set of lines.
14
+ *
15
+ * This map will contain the indentation for lines that are not a part of the given set,
16
+ * but this is because calculating the indentation for those lines was necessary to
17
+ * calculate the indentation for the lines provided to the constructor.
18
+ *
19
+ * @see {@link IndentEntry}
20
+ */
21
+ export var IndentationMap = /*#__PURE__*/function () {
22
+ /** The {@link EditorState} indentation is derived from. */
23
+
24
+ /** The set of lines that are used as an entrypoint. */
25
+
26
+ /** The internal mapping of line numbers to {@link IndentEntry} objects. */
27
+
28
+ /** The width of the editor's indent unit. */
29
+
30
+ /** The type of indentation to use (terminate at end of scope vs last non-empty line in scope) */
31
+
32
+ /**
33
+ * @param lines - The set of lines to get the indentation map for.
34
+ * @param state - The {@link EditorState} to derive the indentation map from.
35
+ * @param unitWidth - The width of the editor's indent unit.
36
+ * @param markerType - The type of indentation to use (terminate at end of scope vs last line of code in scope)
37
+ */
38
+ function IndentationMap(lines, state, unitWidth, markerType) {
39
+ _classCallCheck(this, IndentationMap);
40
+ this.lines = lines;
41
+ this.state = state;
42
+ this.map = new Map();
43
+ this.unitWidth = unitWidth;
44
+ this.markerType = markerType;
45
+ var _iterator = _createForOfIteratorHelper(this.lines),
46
+ _step;
47
+ try {
48
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
49
+ var line = _step.value;
50
+ this.add(line);
51
+ }
52
+ } catch (err) {
53
+ _iterator.e(err);
54
+ } finally {
55
+ _iterator.f();
56
+ }
57
+ if (this.state.facet(indentationMarkerConfig).highlightActiveBlock) {
58
+ this.findAndSetActiveLines();
59
+ }
60
+ }
61
+
62
+ /**
63
+ * Checks if the indentation map has an entry for the given line.
64
+ *
65
+ * @param line - The {@link Line} or line number to check for.
66
+ */
67
+ _createClass(IndentationMap, [{
68
+ key: "has",
69
+ value: function has(line) {
70
+ return this.map.has(typeof line === 'number' ? line : line.number);
71
+ }
72
+
73
+ /**
74
+ * Returns the {@link IndentEntry} for the given line.
75
+ *
76
+ * Note that this function will throw an error if the line does not exist in the map.
77
+ *
78
+ * @param line - The {@link Line} or line number to get the entry for.
79
+ */
80
+ }, {
81
+ key: "get",
82
+ value: function get(line) {
83
+ var entry = this.map.get(typeof line === 'number' ? line : line.number);
84
+ if (!entry) {
85
+ throw new Error('Line not found in indentation map');
86
+ }
87
+ return entry;
88
+ }
89
+
90
+ /**
91
+ * Sets the {@link IndentEntry} for the given line.
92
+ *
93
+ * @param line - The {@link Line} to set the entry for.
94
+ * @param col - The visual beginning whitespace width of the line.
95
+ * @param level - The indentation level of the line.
96
+ */
97
+ }, {
98
+ key: "set",
99
+ value: function set(line, col, level) {
100
+ var empty = !line.text.trim().length;
101
+ var entry = {
102
+ line: line,
103
+ col: col,
104
+ level: level,
105
+ empty: empty
106
+ };
107
+ this.map.set(entry.line.number, entry);
108
+ return entry;
109
+ }
110
+
111
+ /**
112
+ * Adds a line to the indentation map.
113
+ *
114
+ * @param line - The {@link Line} to add to the map.
115
+ */
116
+ }, {
117
+ key: "add",
118
+ value: function add(line) {
119
+ if (this.has(line)) {
120
+ return this.get(line);
121
+ }
122
+
123
+ // empty lines continue their indentation from surrounding lines
124
+ if (!line.length || !line.text.trim().length) {
125
+ // the very first line, if empty, is just ignored and set as a 0 indent level
126
+ if (line.number === 1) {
127
+ return this.set(line, 0, 0);
128
+ }
129
+
130
+ // if we're at the end, we'll just use the previous line's indentation
131
+ if (line.number === this.state.doc.lines) {
132
+ var _prev = this.closestNonEmpty(line, -1);
133
+ return this.set(line, 0, _prev.level);
134
+ }
135
+ var prev = this.closestNonEmpty(line, -1);
136
+ var next = this.closestNonEmpty(line, 1);
137
+
138
+ // if the next line ends the block and the marker type is not set to codeOnly,
139
+ // we'll just use the previous line's indentation
140
+ if (prev.level >= next.level && this.markerType !== 'codeOnly') {
141
+ return this.set(line, 0, prev.level);
142
+ }
143
+
144
+ // having an indent marker that starts from an empty line looks weird
145
+ if (prev.empty && prev.level === 0 && next.level !== 0) {
146
+ return this.set(line, 0, 0);
147
+ }
148
+
149
+ // if the next indentation level is greater than the previous,
150
+ // we'll only increment up to the next indentation level. this prevents
151
+ // a weirdly "backwards propagating" indentation.
152
+ if (next.level > prev.level) {
153
+ return this.set(line, 0, prev.level + 1);
154
+ }
155
+
156
+ // else, we default to the next line's indentation
157
+ return this.set(line, 0, next.level);
158
+ }
159
+ var col = numColumns(line.text, this.state.tabSize);
160
+ var level = Math.floor(col / this.unitWidth);
161
+ return this.set(line, col, level);
162
+ }
163
+
164
+ /**
165
+ * Finds the closest non-empty line, starting from the given line.
166
+ *
167
+ * @param from - The {@link Line} to start from.
168
+ * @param dir - The direction to search in. Either `1` or `-1`.
169
+ */
170
+ }, {
171
+ key: "closestNonEmpty",
172
+ value: function closestNonEmpty(from, dir) {
173
+ var lineNo = from.number + dir;
174
+ while (dir === -1 ? lineNo >= 1 : lineNo <= this.state.doc.lines) {
175
+ if (this.has(lineNo)) {
176
+ var entry = this.get(lineNo);
177
+ if (!entry.empty) {
178
+ return entry;
179
+ }
180
+ }
181
+
182
+ // we can check if the line is empty, if it's not, we can
183
+ // just create a new entry for it and return it.
184
+ // this prevents us from hitting the beginning/end of the document unnecessarily.
185
+
186
+ var _line = this.state.doc.line(lineNo);
187
+ if (_line.text.trim().length) {
188
+ var col = numColumns(_line.text, this.state.tabSize);
189
+ var level = Math.floor(col / this.unitWidth);
190
+ return this.set(_line, col, level);
191
+ }
192
+ lineNo += dir;
193
+ }
194
+
195
+ // if we're here, we didn't find anything.
196
+ // that means we're at the beginning/end of the document,
197
+ // and the first/last line is empty.
198
+
199
+ var line = this.state.doc.line(dir === -1 ? 1 : this.state.doc.lines);
200
+ return this.set(line, 0, 0);
201
+ }
202
+
203
+ /**
204
+ * Finds the state's active block (via the current selection) and sets all
205
+ * the active indent level for the lines in the block.
206
+ */
207
+ }, {
208
+ key: "findAndSetActiveLines",
209
+ value: function findAndSetActiveLines() {
210
+ var currentLine = getCurrentLine(this.state);
211
+ if (!this.has(currentLine)) {
212
+ return;
213
+ }
214
+ var current = this.get(currentLine);
215
+
216
+ // check if the current line is starting a new block, if yes, we want to
217
+ // start from inside the block.
218
+ if (this.has(current.line.number + 1)) {
219
+ var next = this.get(current.line.number + 1);
220
+ if (next.level > current.level) {
221
+ current = next;
222
+ }
223
+ }
224
+
225
+ // same, but if the current line is ending a block
226
+ if (this.has(current.line.number - 1)) {
227
+ var prev = this.get(current.line.number - 1);
228
+ if (prev.level > current.level) {
229
+ current = prev;
230
+ }
231
+ }
232
+ if (current.level === 0) {
233
+ return;
234
+ }
235
+ current.active = current.level;
236
+ var start;
237
+ var end;
238
+
239
+ // iterate to the start of the block
240
+ for (start = current.line.number; start > 1; start--) {
241
+ if (!this.has(start - 1)) {
242
+ continue;
243
+ }
244
+ var _prev2 = this.get(start - 1);
245
+ if (_prev2.level < current.level) {
246
+ break;
247
+ }
248
+ _prev2.active = current.level;
249
+ }
250
+
251
+ // iterate to the end of the block
252
+ for (end = current.line.number; end < this.state.doc.lines; end++) {
253
+ if (!this.has(end + 1)) {
254
+ continue;
255
+ }
256
+ var _next = this.get(end + 1);
257
+ if (_next.level < current.level) {
258
+ break;
259
+ }
260
+ _next.active = current.level;
261
+ }
262
+ }
263
+ }]);
264
+ return IndentationMap;
265
+ }();
@@ -0,0 +1,27 @@
1
+ import type { EditorState, Line } from '@codemirror/state';
2
+ import type { EditorView } from '@codemirror/view';
3
+ /**
4
+ * Gets the visible lines in the editor. Lines will not be repeated.
5
+ *
6
+ * @param view - The editor view to get the visible lines from.
7
+ * @param state - The editor state. Defaults to the view's current one.
8
+ */
9
+ export declare function getVisibleLines(view: EditorView, state?: EditorState): Set<Line>;
10
+ /**
11
+ * Gets the line at the position of the primary cursor.
12
+ *
13
+ * @param state - The editor state from which to extract the line.
14
+ */
15
+ export declare function getCurrentLine(state: EditorState): Line;
16
+ /**
17
+ * Returns the number of columns that a string is indented, controlling for
18
+ * tabs. This is useful for determining the indentation level of a line.
19
+ *
20
+ * Note that this only returns the number of _visible_ columns, not the number
21
+ * of whitespace characters at the start of the string.
22
+ *
23
+ * @param str - The string to check.
24
+ * @param tabSize - The size of a tab character. Usually 2 or 4.
25
+ */
26
+ export declare function numColumns(str: string, tabSize: number): number;
27
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/indentation-markers/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,cAAa,aAkBnE;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,WAAW,QAGhD;AAED;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,UAkCtD"}
@@ -0,0 +1,91 @@
1
+ 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; } } }; }
2
+ 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); }
3
+ 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; }
4
+ /**
5
+ * Gets the visible lines in the editor. Lines will not be repeated.
6
+ *
7
+ * @param view - The editor view to get the visible lines from.
8
+ * @param state - The editor state. Defaults to the view's current one.
9
+ */
10
+ export function getVisibleLines(view) {
11
+ var state = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : view.state;
12
+ var lines = new Set();
13
+ var _iterator = _createForOfIteratorHelper(view.visibleRanges),
14
+ _step;
15
+ try {
16
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
17
+ var _step$value = _step.value,
18
+ from = _step$value.from,
19
+ to = _step$value.to;
20
+ var pos = from;
21
+ while (pos <= to) {
22
+ var line = state.doc.lineAt(pos);
23
+ if (!lines.has(line)) {
24
+ lines.add(line);
25
+ }
26
+ pos = line.to + 1;
27
+ }
28
+ }
29
+ } catch (err) {
30
+ _iterator.e(err);
31
+ } finally {
32
+ _iterator.f();
33
+ }
34
+ return lines;
35
+ }
36
+
37
+ /**
38
+ * Gets the line at the position of the primary cursor.
39
+ *
40
+ * @param state - The editor state from which to extract the line.
41
+ */
42
+ export function getCurrentLine(state) {
43
+ var currentPos = state.selection.main.head;
44
+ return state.doc.lineAt(currentPos);
45
+ }
46
+
47
+ /**
48
+ * Returns the number of columns that a string is indented, controlling for
49
+ * tabs. This is useful for determining the indentation level of a line.
50
+ *
51
+ * Note that this only returns the number of _visible_ columns, not the number
52
+ * of whitespace characters at the start of the string.
53
+ *
54
+ * @param str - The string to check.
55
+ * @param tabSize - The size of a tab character. Usually 2 or 4.
56
+ */
57
+ export function numColumns(str, tabSize) {
58
+ // as far as I can tell, this is pretty much the fastest way to do this,
59
+ // at least involving iteration. `str.length - str.trimStart().length` is
60
+ // much faster, but it has some edge cases that are hard to deal with.
61
+
62
+ var col = 0;
63
+
64
+ // eslint-disable-next-line no-restricted-syntax
65
+ loop: for (var i = 0; i < str.length; i++) {
66
+ switch (str[i]) {
67
+ case ' ':
68
+ {
69
+ col += 1;
70
+ continue loop;
71
+ }
72
+ case '\t':
73
+ {
74
+ // if the current column is a multiple of the tab size, we can just
75
+ // add the tab size to the column. otherwise, we need to add the
76
+ // difference between the tab size and the current column.
77
+ col += tabSize - col % tabSize;
78
+ continue loop;
79
+ }
80
+ case '\r':
81
+ {
82
+ continue loop;
83
+ }
84
+ default:
85
+ {
86
+ break loop;
87
+ }
88
+ }
89
+ }
90
+ return col;
91
+ }
package/es/index.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ import './style/base.css';
2
+ import './style/theme.css';
3
+ import './style/variables.css';
4
+ export * from './config.js';
5
+ export * from './editor.js';
6
+ export * from './lsp/index.js';
7
+ export * from './mode.js';
8
+ export * from './module.js';
9
+ export * from './factory.js';
10
+ export * from './monitor.js';
11
+ export * from './theme.js';
12
+ export * from './auto-complete/index.js';
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,mBAAmB,CAAC;AAC3B,OAAO,uBAAuB,CAAC;AAE/B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAE3B,cAAc,0BAA0B,CAAC"}
package/es/index.js ADDED
@@ -0,0 +1,12 @@
1
+ import "./style/base.css";
2
+ import "./style/theme.css";
3
+ import "./style/variables.css";
4
+ export * from "./config.js";
5
+ export * from "./editor.js";
6
+ export * from "./lsp/index.js";
7
+ export * from "./mode.js";
8
+ export * from "./module.js";
9
+ export * from "./factory.js";
10
+ export * from "./monitor.js";
11
+ export * from "./theme.js";
12
+ export * from "./auto-complete/index.js";
@@ -0,0 +1,3 @@
1
+ export declare const FoldIcon = "<svg width=\"8px\" height=\"6px\" viewBox=\"0 0 8 6\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"><title>1.\u901A\u7528/2.Icon\u56FE\u6807/Line/Down</title><g id=\"0424\" stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\"><g id=\"Notebook-cell-\u8272\u9636\" transform=\"translate(-2015.000000, -434.000000)\" fill=\"#A4AECB\"><g id=\"\u7F16\u7EC4-15\" transform=\"translate(2004.000000, 407.000000)\"><g id=\"1.\u901A\u7528/2.Icon\u56FE\u6807/Line/Down\" transform=\"translate(11.250000, 27.500000)\"><path d=\"M7.34387369,0 L6.61145181,0 C6.56164712,0 6.51477212,0.0244140625 6.48547525,0.064453125 L3.71106119,3.88867188 L0.936647123,0.064453125 C0.907350248,0.0244140625 0.860475248,0 0.81067056,0 L0.0782486852,0 C0.0147721227,0 -0.0223372523,0.072265625 0.0147721227,0.124023438 L3.4581315,4.87109375 C3.5831315,5.04296875 3.83899087,5.04296875 3.96301431,4.87109375 L7.40637369,0.124023437 C7.44445962,0.072265625 7.40735025,0 7.34387369,0 Z\" id=\"Down\"></path></g></g></g></g></svg>";
2
+ export declare const UnFoldIcon = "<svg width=\"6px\" height=\"8px\" viewBox=\"0 0 6 8\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"><title>1.\u901A\u7528/2.Icon\u56FE\u6807/Line/Down\u6536\u8D77</title><g id=\"0424\" stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\"><g id=\"Notebook-cell-\u8272\u9636\" transform=\"translate(-2094.000000, -433.000000)\" fill=\"#A4AECB\"><g id=\"\u7F16\u7EC4-15\u5907\u4EFD\" transform=\"translate(2082.000000, 407.000000)\"><g id=\"1.\u901A\u7528/2.Icon\u56FE\u6807/Line/Down\" transform=\"translate(15.000000, 30.039124) rotate(270.000000) translate(-15.000000, -30.039124) translate(11.289124, 27.539124)\"><path d=\"M7.34387369,1.77635684e-15 L6.61145181,1.77635684e-15 C6.56164712,1.77635684e-15 6.51477212,0.0244140625 6.48547525,0.064453125 L3.71106119,3.88867188 L0.936647123,0.064453125 C0.907350248,0.0244140625 0.860475248,1.77635684e-15 0.81067056,1.77635684e-15 L0.0782486852,1.77635684e-15 C0.0147721227,1.77635684e-15 -0.0223372523,0.072265625 0.0147721227,0.124023438 L3.4581315,4.87109375 C3.5831315,5.04296875 3.83899087,5.04296875 3.96301431,4.87109375 L7.40637369,0.124023438 C7.44445962,0.072265625 7.40735025,1.77635684e-15 7.34387369,1.77635684e-15 Z\" id=\"Down\"></path></g></g></g></g></svg>";
3
+ //# sourceMappingURL=libro-icon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"libro-icon.d.ts","sourceRoot":"","sources":["../src/libro-icon.tsx"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ,+iCACq7B,CAAC;AAC38B,eAAO,MAAM,UAAU,ixCACioC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export var FoldIcon = '<svg width="8px" height="6px" viewBox="0 0 8 6" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><title>1.通用/2.Icon图标/Line/Down</title><g id="0424" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><g id="Notebook-cell-色阶" transform="translate(-2015.000000, -434.000000)" fill="#A4AECB"><g id="编组-15" transform="translate(2004.000000, 407.000000)"><g id="1.通用/2.Icon图标/Line/Down" transform="translate(11.250000, 27.500000)"><path d="M7.34387369,0 L6.61145181,0 C6.56164712,0 6.51477212,0.0244140625 6.48547525,0.064453125 L3.71106119,3.88867188 L0.936647123,0.064453125 C0.907350248,0.0244140625 0.860475248,0 0.81067056,0 L0.0782486852,0 C0.0147721227,0 -0.0223372523,0.072265625 0.0147721227,0.124023438 L3.4581315,4.87109375 C3.5831315,5.04296875 3.83899087,5.04296875 3.96301431,4.87109375 L7.40637369,0.124023437 C7.44445962,0.072265625 7.40735025,0 7.34387369,0 Z" id="Down"></path></g></g></g></g></svg>';
2
+ export var UnFoldIcon = '<svg width="6px" height="8px" viewBox="0 0 6 8" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><title>1.通用/2.Icon图标/Line/Down收起</title><g id="0424" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><g id="Notebook-cell-色阶" transform="translate(-2094.000000, -433.000000)" fill="#A4AECB"><g id="编组-15备份" transform="translate(2082.000000, 407.000000)"><g id="1.通用/2.Icon图标/Line/Down" transform="translate(15.000000, 30.039124) rotate(270.000000) translate(-15.000000, -30.039124) translate(11.289124, 27.539124)"><path d="M7.34387369,1.77635684e-15 L6.61145181,1.77635684e-15 C6.56164712,1.77635684e-15 6.51477212,0.0244140625 6.48547525,0.064453125 L3.71106119,3.88867188 L0.936647123,0.064453125 C0.907350248,0.0244140625 0.860475248,1.77635684e-15 0.81067056,1.77635684e-15 L0.0782486852,1.77635684e-15 C0.0147721227,1.77635684e-15 -0.0223372523,0.072265625 0.0147721227,0.124023438 L3.4581315,4.87109375 C3.5831315,5.04296875 3.83899087,5.04296875 3.96301431,4.87109375 L7.40637369,0.124023438 C7.44445962,0.072265625 7.40735025,1.77635684e-15 7.34387369,1.77635684e-15 Z" id="Down"></path></g></g></g></g></svg>';
@@ -0,0 +1,5 @@
1
+ import type { Completion } from '../auto-complete/index.js';
2
+ import type { CMLSPExtension } from './protocol.js';
3
+ export type CompletionItemDetailReolve = (completion: Completion) => Node | null | Promise<Node | null>;
4
+ export declare const lspPythonCompletion: CMLSPExtension;
5
+ //# sourceMappingURL=completion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"completion.d.ts","sourceRoot":"","sources":["../../src/lsp/completion.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAoB,MAAM,2BAA2B,CAAC;AAE9E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAGpD,MAAM,MAAM,0BAA0B,GAAG,CACvC,UAAU,EAAE,UAAU,KACnB,IAAI,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;AAiCxC,eAAO,MAAM,mBAAmB,EAAE,cAmIjC,CAAC"}