xshell 0.0.17 → 0.0.18
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/package.json +4 -2
- package/tsconfig.json +0 -4
- package/extension.d.ts +0 -3
- package/extension.js +0 -68
- package/extension.js.map +0 -1
- package/toaster.d.ts +0 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xshell",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.18",
|
|
4
4
|
"main": "./index.js",
|
|
5
5
|
"bin": {
|
|
6
6
|
"xshell": "./xshell.js"
|
|
@@ -106,6 +106,8 @@
|
|
|
106
106
|
"@types/rimraf": "^3.0.2",
|
|
107
107
|
"@types/stream-buffers": "^3.0.4",
|
|
108
108
|
"@types/tampermonkey": "^4.0.5",
|
|
109
|
-
"@types/vscode": "^1.62.0"
|
|
109
|
+
"@types/vscode": "^1.62.0",
|
|
110
|
+
"source-map-loader": "^3.0.0",
|
|
111
|
+
"ts-loader": "^9.2.6"
|
|
110
112
|
}
|
|
111
113
|
}
|
package/tsconfig.json
CHANGED
package/extension.d.ts
DELETED
package/extension.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.activate = void 0;
|
|
4
|
-
const vscode_1 = require("vscode");
|
|
5
|
-
require("./prototype");
|
|
6
|
-
const net_1 = require("./net");
|
|
7
|
-
const my_commands = [
|
|
8
|
-
{
|
|
9
|
-
func: async function xshell_repl() {
|
|
10
|
-
const editor = vscode_1.window.activeTextEditor;
|
|
11
|
-
const doc = editor.document;
|
|
12
|
-
const languages_map = {
|
|
13
|
-
javascript: ['ts'],
|
|
14
|
-
javascriptreact: ['ts'],
|
|
15
|
-
typescript: ['ts'],
|
|
16
|
-
typescriptreact: ['ts'],
|
|
17
|
-
};
|
|
18
|
-
const language_id = doc.languageId;
|
|
19
|
-
if (!(language_id in languages_map))
|
|
20
|
-
throw new Error(`${language_id} does not support repl`);
|
|
21
|
-
const code = get_text('selection or line');
|
|
22
|
-
await (0, net_1.rpc)('repl_code', [...languages_map[language_id], code], { async: true });
|
|
23
|
-
},
|
|
24
|
-
key: 'ctrl+enter',
|
|
25
|
-
when: 'editorTextFocus'
|
|
26
|
-
},
|
|
27
|
-
];
|
|
28
|
-
/** get text by selector */
|
|
29
|
-
function get_text(selector) {
|
|
30
|
-
const editor = vscode_1.window.activeTextEditor;
|
|
31
|
-
const document = editor.document;
|
|
32
|
-
const selection = editor.selection;
|
|
33
|
-
const text_selection = document.getText(selection);
|
|
34
|
-
if (selector === 'selection')
|
|
35
|
-
return text_selection;
|
|
36
|
-
const text_all = document.getText();
|
|
37
|
-
if (selector === 'all')
|
|
38
|
-
return text_all;
|
|
39
|
-
const text_line = document.lineAt(selection.active.line).text;
|
|
40
|
-
if (selector === 'line')
|
|
41
|
-
return text_line;
|
|
42
|
-
if (selector === 'word')
|
|
43
|
-
return document.getText(document.getWordRangeAtPosition(selection.active));
|
|
44
|
-
if (selector === 'selection or all')
|
|
45
|
-
return text_selection || text_all;
|
|
46
|
-
if (selector === 'selection or line')
|
|
47
|
-
return text_selection || text_line;
|
|
48
|
-
const start = selection.start;
|
|
49
|
-
const end = selection.end;
|
|
50
|
-
const line = document.lineAt(start.line);
|
|
51
|
-
const line_start = new vscode_1.Position(start.line, 0);
|
|
52
|
-
if (selector === 'selection before')
|
|
53
|
-
return document.getText(new vscode_1.Range(line_start, start));
|
|
54
|
-
const line_end = new vscode_1.Position(start.line, line.text.length);
|
|
55
|
-
if (selector === 'selection after')
|
|
56
|
-
return document.getText(new vscode_1.Range(end, line_end));
|
|
57
|
-
const line_text_start = new vscode_1.Position(start.line, line.firstNonWhitespaceCharacterIndex);
|
|
58
|
-
if (selector === 'selection to text start')
|
|
59
|
-
return document.getText(new vscode_1.Range(line_text_start, start));
|
|
60
|
-
}
|
|
61
|
-
function activate(ctx) {
|
|
62
|
-
my_commands.forEach(({ func }) => {
|
|
63
|
-
ctx.subscriptions.push(vscode_1.commands.registerCommand(func.name, func));
|
|
64
|
-
});
|
|
65
|
-
console.log('xshell loaded');
|
|
66
|
-
}
|
|
67
|
-
exports.activate = activate;
|
|
68
|
-
//# sourceMappingURL=extension.js.map
|
package/extension.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extension.js","sourceRoot":"","sources":["extension.ts"],"names":[],"mappings":";;;AAAA,mCAA0D;AAG1D,uBAAoB;AACpB,+BAA2B;AAG3B,MAAM,WAAW,GAAG;IAChB;QACI,IAAI,EAAE,KAAK,UAAU,WAAW;YAC5B,MAAM,MAAM,GAAG,eAAM,CAAC,gBAAgB,CAAA;YACtC,MAAM,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAA;YAE3B,MAAM,aAAa,GAAG;gBAClB,UAAU,EAAE,CAAC,IAAI,CAAC;gBAClB,eAAe,EAAE,CAAC,IAAI,CAAC;gBACvB,UAAU,EAAE,CAAC,IAAI,CAAC;gBAClB,eAAe,EAAE,CAAC,IAAI,CAAC;aAC1B,CAAA;YAED,MAAM,WAAW,GAAG,GAAG,CAAC,UAAU,CAAA;YAElC,IAAI,CAAC,CAAC,WAAW,IAAI,aAAa,CAAC;gBAC/B,MAAM,IAAI,KAAK,CAAC,GAAG,WAAW,wBAAwB,CAAC,CAAA;YAE3D,MAAM,IAAI,GAAG,QAAQ,CAAC,mBAAmB,CAAC,CAAA;YAE1C,MAAM,IAAA,SAAG,EAAC,WAAW,EAAE,CAAC,GAAG,aAAa,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;QAClF,CAAC;QACD,GAAG,EAAE,YAAY;QACjB,IAAI,EAAE,iBAAiB;KAC1B;CACJ,CAAA;AAGD,2BAA2B;AAC3B,SAAS,QAAQ,CAAE,QASE;IAEjB,MAAM,MAA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I,iBAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAE7D,IAAI,QAAQ,KAAK,iBAAiB;QAC9B,OAAO,QAAQ,CAAC,OAAO,CAAE,IAAI,cAAK,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAE,CAAA;IAGvD,MAAM,eAAe,GAAG,IAAI,iBAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,gCAAgC,CAAC,CAAA;IACvF,IAAI,QAAQ,KAAK,yBAAyB;QACtC,OAAO,QAAQ,CAAC,OAAO,CAAC,IAAI,cAAK,CAAC,eAAe,EAAE,KAAK,CAAC,CAAG,CAAA;AACpE,CAAC;AAGD,SAAgB,QAAQ,CAAE,GAAqB;IAC3C,WAAW,CAAC,OAAO,CAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;QAC9B,GAAG,CAAC,aAAa,CAAC,IAAI,CAAC,iBAAQ,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;IACrE,CAAC,CAAC,CAAA;IACF,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA;AAChC,CAAC;AALD,4BAKC","sourcesContent":["import { window, commands, Range, Position } from 'vscode'\nimport type { ExtensionContext } from 'vscode'\n\nimport './prototype'\nimport { rpc } from './net'\n\n\nconst my_commands = [\n {\n func: async function xshell_repl () {\n const editor = window.activeTextEditor\n const doc = editor.document\n \n const languages_map = {\n javascript: ['ts'],\n javascriptreact: ['ts'],\n typescript: ['ts'],\n typescriptreact: ['ts'],\n }\n \n const language_id = doc.languageId\n \n if (!(language_id in languages_map))\n throw new Error(`${language_id} does not support repl`)\n \n const code = get_text('selection or line')\n \n await rpc('repl_code', [...languages_map[language_id], code], { async: true })\n },\n key: 'ctrl+enter',\n when: 'editorTextFocus'\n },\n]\n\n\n/** get text by selector */\nfunction get_text (selector: \n 'all' | \n 'line' | \n 'word' |\n 'selection' | \n 'selection or line' |\n 'selection or all' |\n 'selection before' | \n 'selection to text start' | \n 'selection after'\n) {\n const editor = window.activeTextEditor\n const document = editor.document\n const selection = editor.selection\n \n const text_selection = document.getText(selection)\n \n if (selector === 'selection')\n return text_selection\n \n const text_all = document.getText()\n \n if (selector === 'all')\n return text_all\n \n const text_line = document.lineAt(selection.active.line).text\n \n if (selector === 'line')\n return text_line\n \n if (selector === 'word')\n return document.getText(document.getWordRangeAtPosition(selection.active))\n \n if (selector === 'selection or all')\n return text_selection || text_all\n \n if (selector === 'selection or line')\n return text_selection || text_line\n \n \n \n const start = selection.start\n const end = selection.end\n \n const line = document.lineAt(start.line)\n \n const line_start = new Position(start.line, 0)\n \n if (selector === 'selection before')\n return document.getText( new Range(line_start, start) )\n \n \n const line_end = new Position(start.line, line.text.length)\n \n if (selector === 'selection after')\n return document.getText( new Range(end, line_end) )\n \n \n const line_text_start = new Position(start.line, line.firstNonWhitespaceCharacterIndex)\n if (selector === 'selection to text start')\n return document.getText(new Range(line_text_start, start) )\n}\n\n\nexport function activate (ctx: ExtensionContext) {\n my_commands.forEach( ({ func }) => {\n ctx.subscriptions.push(commands.registerCommand(func.name, func))\n })\n console.log('xshell loaded')\n}\n"]}
|
package/toaster.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import './toaster.sass';
|
|
2
|
-
export declare let toaster: {
|
|
3
|
-
messages: string[];
|
|
4
|
-
state: "IDLE" | "SHOW";
|
|
5
|
-
toast(message: string): Promise<void>;
|
|
6
|
-
show(): Promise<void>;
|
|
7
|
-
};
|
|
8
|
-
export declare const toast: (message: string) => Promise<void>;
|
|
9
|
-
export default toast;
|