@innovatorved/code-lab 0.4.0 → 0.6.0
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/ARCHITECTURE.md +4 -4
- package/CHANGELOG.md +36 -0
- package/README.md +6 -30
- package/dist/code-lab-sql.esm.js +1 -1
- package/dist/code-lab-sql.umd.js +2 -2
- package/dist/code-lab.css +32 -5818
- package/dist/code-lab.d.ts +1 -1
- package/dist/code-lab.esm.js +4655 -64400
- package/dist/code-lab.js +4540 -64286
- package/dist/code-lab.umd.js +4540 -64286
- package/dist/diagnostics.d.ts +3 -0
- package/dist/extensions/cpp.d.ts +2 -2
- package/dist/extensions/cpp.esm.js +1804 -14725
- package/dist/extensions/cpp.js +1804 -14725
- package/dist/extensions/guided-lab.esm.js +2938 -16127
- package/dist/extensions/guided-lab.js +2938 -16127
- package/dist/extensions/python.d.ts +2 -2
- package/dist/extensions/python.esm.js +1765 -14698
- package/dist/extensions/python.js +1765 -14698
- package/dist/index.d.ts +1 -1
- package/dist/packages/settings/src/configuration-service.d.ts +7 -0
- package/dist/packages/settings/src/index.d.ts +1 -1
- package/dist/packages/ui/src/index.d.ts +2 -2
- package/dist/packages/ui/src/plugin-registry.d.ts +1 -0
- package/dist/packages/ui/src/settings-dialog.d.ts +31 -3
- package/dist/packages/ui/src/themes.d.ts +5 -0
- package/dist/preview-sw.js +4 -188
- package/dist/runtime.esm.js +109 -10284
- package/dist/runtime.js +107 -10284
- package/dist/schemas.d.ts +2 -2
- package/dist/schemas.esm.js +2938 -16127
- package/dist/schemas.js +2941 -16130
- package/dist/scm.d.ts +296 -14
- package/dist/shell.esm.js +811 -9178
- package/dist/shell.js +811 -9178
- package/dist/storage.d.ts +56 -0
- package/dist/terminal.esm.js +20 -1347
- package/dist/terminal.js +20 -1347
- package/dist/workbench/command-palette.d.ts +16 -1
- package/dist/workbench/diff-editor.d.ts +27 -1
- package/dist/workbench/icons.d.ts +6 -2
- package/dist/workbench/index.d.ts +33 -1
- package/dist/workbench/intellisense.d.ts +194 -0
- package/dist/workbench/styles.d.ts +1 -1
- package/dist/workbench/xterm-adapter.d.ts +122 -0
- package/package.json +8 -2
- package/packages/commands/package.json +1 -1
- package/packages/core/package.json +1 -1
- package/packages/editor/package.json +1 -1
- package/packages/fs/package.json +1 -1
- package/packages/preview/package.json +1 -1
- package/packages/runtime/package.json +1 -1
- package/packages/settings/package.json +1 -1
- package/packages/settings/src/builtin-schemas.ts +17 -6
- package/packages/settings/src/configuration-service.ts +72 -6
- package/packages/settings/src/index.ts +1 -0
- package/packages/sql/package.json +1 -1
- package/packages/terminal/package.json +1 -1
- package/packages/ui/package.json +1 -1
- package/packages/ui/src/index.ts +4 -0
- package/packages/ui/src/plugin-registry.ts +17 -2
- package/packages/ui/src/settings-dialog.ts +393 -99
- package/packages/ui/src/themes.ts +183 -24
- package/src/code-lab.css +2763 -444
- package/src/diagnostics.ts +139 -7
- package/src/extensions/cpp.ts +337 -71
- package/src/extensions/python.ts +375 -75
- package/src/index.ts +1 -1
- package/src/runtime.ts +272 -43
- package/src/schemas.ts +2 -2
- package/src/scm.ts +2172 -74
- package/src/shell.ts +1999 -193
- package/src/storage.ts +401 -5
- package/src/terminal.ts +148 -12
- package/src/workbench/command-palette.ts +289 -48
- package/src/workbench/diff-editor.ts +240 -78
- package/src/workbench/icons.ts +250 -46
- package/src/workbench/index.ts +7 -1
- package/src/workbench/intellisense.ts +1859 -0
- package/src/workbench/styles.ts +25 -19
- package/src/workbench/xterm-adapter.ts +1566 -0
- package/src/workbench.ts +13446 -3881
package/src/terminal.ts
CHANGED
|
@@ -48,6 +48,8 @@
|
|
|
48
48
|
2: 'cl-ansi-dim',
|
|
49
49
|
3: 'cl-ansi-italic',
|
|
50
50
|
4: 'cl-ansi-underline',
|
|
51
|
+
7: 'cl-ansi-inverse',
|
|
52
|
+
9: 'cl-ansi-strike',
|
|
51
53
|
30: 'cl-ansi-black',
|
|
52
54
|
31: 'cl-ansi-red',
|
|
53
55
|
32: 'cl-ansi-green',
|
|
@@ -119,10 +121,18 @@
|
|
|
119
121
|
if (!s.includes('\x1b') && !s.includes('\r')) return s;
|
|
120
122
|
|
|
121
123
|
let text = s;
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
124
|
+
// Strip OSC sequences (e.g. window title \x1b]0;...\x07) while preserving OSC-8 link visible labels
|
|
125
|
+
text = text.replace(/\x1b\]8;[^;]*;[^\x07\x1b]*(?:\x07|\x1b\\)([\s\S]*?)\x1b\]8;;(?:\x07|\x1b\\)/g, '$1');
|
|
126
|
+
text = text.replace(/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)/g, '');
|
|
127
|
+
|
|
128
|
+
const clearIdx2 = text.lastIndexOf('\x1b[2J');
|
|
129
|
+
const clearIdx3 = text.lastIndexOf('\x1b[3J');
|
|
130
|
+
const clearRis = text.lastIndexOf('\x1bc');
|
|
131
|
+
const lastClear = Math.max(clearIdx2, clearIdx3, clearRis);
|
|
132
|
+
if (lastClear !== -1) {
|
|
133
|
+
const skipLen = lastClear === clearRis ? 2 : 4;
|
|
134
|
+
text = text.slice(lastClear + skipLen);
|
|
135
|
+
text = text.replace(/^(?:\x1b\[[23]J|\x1b\[(?:\d+;\d+)?H)+/, '');
|
|
126
136
|
}
|
|
127
137
|
|
|
128
138
|
text = text.replace(/\r\n/g, '\n');
|
|
@@ -190,6 +200,8 @@
|
|
|
190
200
|
dim: false,
|
|
191
201
|
italic: false,
|
|
192
202
|
underline: false,
|
|
203
|
+
inverse: false,
|
|
204
|
+
strike: false,
|
|
193
205
|
fgClass: null,
|
|
194
206
|
bgClass: null,
|
|
195
207
|
fgColor: null,
|
|
@@ -201,6 +213,8 @@
|
|
|
201
213
|
state.dim = false;
|
|
202
214
|
state.italic = false;
|
|
203
215
|
state.underline = false;
|
|
216
|
+
state.inverse = false;
|
|
217
|
+
state.strike = false;
|
|
204
218
|
state.fgClass = null;
|
|
205
219
|
state.bgClass = null;
|
|
206
220
|
state.fgColor = null;
|
|
@@ -215,12 +229,20 @@
|
|
|
215
229
|
if (state.dim) classes.push('cl-ansi-dim');
|
|
216
230
|
if (state.italic) classes.push('cl-ansi-italic');
|
|
217
231
|
if (state.underline) classes.push('cl-ansi-underline');
|
|
232
|
+
if (state.inverse) classes.push('cl-ansi-inverse');
|
|
233
|
+
if (state.strike) classes.push('cl-ansi-strike');
|
|
218
234
|
if (state.fgClass) classes.push(state.fgClass);
|
|
219
235
|
if (state.bgClass) classes.push(state.bgClass);
|
|
220
236
|
|
|
221
237
|
const styles = [];
|
|
222
238
|
if (state.fgColor) styles.push(`color:${state.fgColor}`);
|
|
223
239
|
if (state.bgColor) styles.push(`background-color:${state.bgColor}`);
|
|
240
|
+
if (state.inverse && !state.fgClass && !state.bgClass) {
|
|
241
|
+
styles.push('filter:invert(1)');
|
|
242
|
+
}
|
|
243
|
+
if (state.strike) {
|
|
244
|
+
styles.push('text-decoration:line-through');
|
|
245
|
+
}
|
|
224
246
|
|
|
225
247
|
if (classes.length === 0 && styles.length === 0) {
|
|
226
248
|
return escaped;
|
|
@@ -248,6 +270,10 @@
|
|
|
248
270
|
state.italic = true;
|
|
249
271
|
} else if (code === 4) {
|
|
250
272
|
state.underline = true;
|
|
273
|
+
} else if (code === 7) {
|
|
274
|
+
state.inverse = true;
|
|
275
|
+
} else if (code === 9) {
|
|
276
|
+
state.strike = true;
|
|
251
277
|
} else if (code === 22) {
|
|
252
278
|
state.bold = false;
|
|
253
279
|
state.dim = false;
|
|
@@ -255,6 +281,10 @@
|
|
|
255
281
|
state.italic = false;
|
|
256
282
|
} else if (code === 24) {
|
|
257
283
|
state.underline = false;
|
|
284
|
+
} else if (code === 27) {
|
|
285
|
+
state.inverse = false;
|
|
286
|
+
} else if (code === 29) {
|
|
287
|
+
state.strike = false;
|
|
258
288
|
} else if (code === 39) {
|
|
259
289
|
state.fgClass = null;
|
|
260
290
|
state.fgColor = null;
|
|
@@ -403,10 +433,21 @@
|
|
|
403
433
|
while (i < str.length) {
|
|
404
434
|
if (str[i] === '\x1b') {
|
|
405
435
|
const rest = str.slice(i);
|
|
406
|
-
if (/^\x1b
|
|
436
|
+
if (rest === '\x1b' || /^\x1b\[[0-9;?]*$/.test(rest) || /^\x1b\][^\x07]*(?:\x1b)?$/.test(rest)) {
|
|
407
437
|
this._pendingEscape = rest;
|
|
408
438
|
break;
|
|
409
439
|
}
|
|
440
|
+
if (rest.startsWith('\x1bc')) {
|
|
441
|
+
i += 2;
|
|
442
|
+
this.clear();
|
|
443
|
+
modified = false;
|
|
444
|
+
continue;
|
|
445
|
+
}
|
|
446
|
+
const oscMatch = /^\x1b\]([^\x07\x1b]*)(?:\x07|\x1b\\)/.exec(rest);
|
|
447
|
+
if (oscMatch) {
|
|
448
|
+
i += oscMatch[0].length;
|
|
449
|
+
continue;
|
|
450
|
+
}
|
|
410
451
|
|
|
411
452
|
const csiMatch = /^\x1b\[([0-9;?]*)([A-Za-z])/.exec(rest);
|
|
412
453
|
if (csiMatch) {
|
|
@@ -438,11 +479,12 @@
|
|
|
438
479
|
if (targetLine) targetLine.text = '';
|
|
439
480
|
this._activeLineEl = null;
|
|
440
481
|
}
|
|
441
|
-
} else if (cmd === 'G') {
|
|
482
|
+
} else if (cmd === 'G' || cmd === 'H' || cmd === 'f') {
|
|
442
483
|
this._cursorCol = 0;
|
|
443
|
-
this._needsRewrite = true;
|
|
444
|
-
} else if (cmd === 'J' && params === '2') {
|
|
484
|
+
if (cmd === 'G') this._needsRewrite = true;
|
|
485
|
+
} else if (cmd === 'J' && (params === '2' || params === '3')) {
|
|
445
486
|
this.clear();
|
|
487
|
+
modified = false;
|
|
446
488
|
} else if (cmd === 'm') {
|
|
447
489
|
const cur = this._getActiveLine(type);
|
|
448
490
|
cur.text += seq;
|
|
@@ -745,6 +787,14 @@
|
|
|
745
787
|
|
|
746
788
|
if (input) {
|
|
747
789
|
this._addListener(input, 'keydown', (e) => this.handleKeyDown(e));
|
|
790
|
+
this._addListener(input, 'paste', (e) => {
|
|
791
|
+
const clip = e && e.clipboardData && typeof e.clipboardData.getData === 'function'
|
|
792
|
+
? e.clipboardData.getData('text/plain')
|
|
793
|
+
: '';
|
|
794
|
+
if (!clip) return;
|
|
795
|
+
if (e.preventDefault) e.preventDefault();
|
|
796
|
+
this.pasteText(clip);
|
|
797
|
+
});
|
|
748
798
|
this._addListener(input, 'input', () => {
|
|
749
799
|
if (this.isCommandRunning()) {
|
|
750
800
|
input.value = '';
|
|
@@ -789,19 +839,39 @@
|
|
|
789
839
|
}
|
|
790
840
|
|
|
791
841
|
const key = e.key;
|
|
842
|
+
const isCtrlOnly = Boolean(e.ctrlKey && !e.metaKey);
|
|
843
|
+
const isMetaOnly = Boolean(e.metaKey && !e.ctrlKey);
|
|
792
844
|
const isCtrl = Boolean(e.ctrlKey || e.metaKey);
|
|
793
845
|
|
|
794
|
-
|
|
846
|
+
// macOS Cmd+K or Ctrl+L clears terminal
|
|
847
|
+
if ((isCtrl && (key === 'l' || key === 'L')) || (isMetaOnly && (key === 'k' || key === 'K'))) {
|
|
795
848
|
if (e.preventDefault) e.preventDefault();
|
|
796
849
|
this.clear();
|
|
797
850
|
return;
|
|
798
851
|
}
|
|
799
852
|
|
|
800
|
-
|
|
853
|
+
// Allow native clipboard copy on Cmd+C (macOS) or Ctrl+Shift+C, or Ctrl+C when idle with text selected
|
|
854
|
+
if (isMetaOnly && (key === 'c' || key === 'C')) {
|
|
855
|
+
return;
|
|
856
|
+
}
|
|
857
|
+
if (isMetaOnly && (key === 'v' || key === 'V')) {
|
|
858
|
+
return;
|
|
859
|
+
}
|
|
860
|
+
if (isCtrlOnly && (key === 'c' || key === 'C')) {
|
|
861
|
+
if (e.shiftKey) return;
|
|
862
|
+
const hasSelection =
|
|
863
|
+
!this.isBusy &&
|
|
864
|
+
typeof window !== 'undefined' &&
|
|
865
|
+
typeof window.getSelection === 'function' &&
|
|
866
|
+
String(window.getSelection()).length > 0;
|
|
867
|
+
if (hasSelection) return;
|
|
801
868
|
if (e.preventDefault) e.preventDefault();
|
|
802
869
|
const wasBusy = this.isBusy || (this._readLineQueue && this._readLineQueue.length > 0);
|
|
803
870
|
this.isBusy = false;
|
|
804
|
-
this._pushLog({ type: 'system', text: wasBusy ? '^C' : `${this.getPrompt()}${this.buffer}^C` });
|
|
871
|
+
const sigLog = this._pushLog({ type: 'system', text: wasBusy ? '^C' : `${this.getPrompt()}${this.buffer}^C` });
|
|
872
|
+
this._appendDomLine(sigLog);
|
|
873
|
+
this._activeLineCommitted = true;
|
|
874
|
+
this._activeLineEl = null;
|
|
805
875
|
this.buffer = '';
|
|
806
876
|
this.cursor = 0;
|
|
807
877
|
this.historyIdx = -1;
|
|
@@ -812,7 +882,8 @@
|
|
|
812
882
|
if (this.onInterrupt) {
|
|
813
883
|
try { this.onInterrupt(); } catch (err) { _terminalLogger.warn('Terminal onInterrupt callback threw.', err); }
|
|
814
884
|
}
|
|
815
|
-
this.
|
|
885
|
+
this.updateActiveLine();
|
|
886
|
+
this._scrollToBottom();
|
|
816
887
|
return;
|
|
817
888
|
}
|
|
818
889
|
|
|
@@ -886,6 +957,39 @@
|
|
|
886
957
|
this.searchMatchIdx = -1;
|
|
887
958
|
}
|
|
888
959
|
|
|
960
|
+
// Word navigation: Alt+B / Alt+ArrowLeft / Ctrl+ArrowLeft & Alt+F / Alt+ArrowRight / Ctrl+ArrowRight
|
|
961
|
+
if ((e.altKey && (key === 'b' || key === 'B' || key === 'ArrowLeft')) || (isCtrlOnly && key === 'ArrowLeft')) {
|
|
962
|
+
if (e.preventDefault) e.preventDefault();
|
|
963
|
+
let pos = this.cursor;
|
|
964
|
+
while (pos > 0 && /\s/.test(this.buffer[pos - 1])) pos--;
|
|
965
|
+
while (pos > 0 && !/\s/.test(this.buffer[pos - 1])) pos--;
|
|
966
|
+
this.cursor = pos;
|
|
967
|
+
this.updateActiveLine();
|
|
968
|
+
return;
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
if ((e.altKey && (key === 'f' || key === 'F' || key === 'ArrowRight')) || (isCtrlOnly && key === 'ArrowRight')) {
|
|
972
|
+
if (e.preventDefault) e.preventDefault();
|
|
973
|
+
let pos = this.cursor;
|
|
974
|
+
while (pos < this.buffer.length && /\s/.test(this.buffer[pos])) pos++;
|
|
975
|
+
while (pos < this.buffer.length && !/\s/.test(this.buffer[pos])) pos++;
|
|
976
|
+
this.cursor = pos;
|
|
977
|
+
this.updateActiveLine();
|
|
978
|
+
return;
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
// Word delete backward: Ctrl+W or Alt+Backspace
|
|
982
|
+
if ((isCtrlOnly && (key === 'w' || key === 'W')) || (e.altKey && key === 'Backspace')) {
|
|
983
|
+
if (e.preventDefault) e.preventDefault();
|
|
984
|
+
let pos = this.cursor;
|
|
985
|
+
while (pos > 0 && /\s/.test(this.buffer[pos - 1])) pos--;
|
|
986
|
+
while (pos > 0 && !/\s/.test(this.buffer[pos - 1])) pos--;
|
|
987
|
+
this.buffer = this.buffer.slice(0, pos) + this.buffer.slice(this.cursor);
|
|
988
|
+
this.cursor = pos;
|
|
989
|
+
this.updateActiveLine();
|
|
990
|
+
return;
|
|
991
|
+
}
|
|
992
|
+
|
|
889
993
|
if (key === 'ArrowLeft') {
|
|
890
994
|
if (e.preventDefault) e.preventDefault();
|
|
891
995
|
if (this.cursor > 0) {
|
|
@@ -955,6 +1059,11 @@
|
|
|
955
1059
|
if (isCtrl && (key === 'd' || key === 'D')) {
|
|
956
1060
|
if (this.buffer === '') {
|
|
957
1061
|
if (e.preventDefault) e.preventDefault();
|
|
1062
|
+
if (this._readLineQueue && this._readLineQueue.length > 0) {
|
|
1063
|
+
this._drainReadLineQueue(null);
|
|
1064
|
+
this.updateActiveLine();
|
|
1065
|
+
return;
|
|
1066
|
+
}
|
|
958
1067
|
if (this.replMode) {
|
|
959
1068
|
this._pushLog({ type: 'system', text: `${this.getPrompt()}.exit` });
|
|
960
1069
|
this.replMode = false;
|
|
@@ -1016,6 +1125,33 @@
|
|
|
1016
1125
|
}
|
|
1017
1126
|
}
|
|
1018
1127
|
|
|
1128
|
+
async pasteText(rawText) {
|
|
1129
|
+
if (!rawText || this.isCommandRunning()) return;
|
|
1130
|
+
const normalized = String(rawText).replace(/\r\n/g, '\n').replace(/\r/g, '\n');
|
|
1131
|
+
if (!normalized.includes('\n')) {
|
|
1132
|
+
this.buffer = this.buffer.slice(0, this.cursor) + normalized + this.buffer.slice(this.cursor);
|
|
1133
|
+
this.cursor += normalized.length;
|
|
1134
|
+
this.updateActiveLine();
|
|
1135
|
+
return;
|
|
1136
|
+
}
|
|
1137
|
+
const parts = normalized.split('\n');
|
|
1138
|
+
for (let i = 0; i < parts.length; i++) {
|
|
1139
|
+
const seg = parts[i];
|
|
1140
|
+
if (i < parts.length - 1) {
|
|
1141
|
+
this.buffer = this.buffer.slice(0, this.cursor) + seg + this.buffer.slice(this.cursor);
|
|
1142
|
+
this.cursor = this.buffer.length;
|
|
1143
|
+
this.submitLine();
|
|
1144
|
+
while (this.isCommandRunning()) {
|
|
1145
|
+
await new Promise((r) => setTimeout(r, 10));
|
|
1146
|
+
}
|
|
1147
|
+
} else if (seg.length > 0) {
|
|
1148
|
+
this.buffer = seg;
|
|
1149
|
+
this.cursor = seg.length;
|
|
1150
|
+
this.updateActiveLine();
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1019
1155
|
autoComplete() {
|
|
1020
1156
|
if (!this.getCompletions) return;
|
|
1021
1157
|
const res = this.getCompletions(this.buffer, this.cursor);
|