@kispace-io/extension-linuxterminal 0.8.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/package.json +19 -0
- package/src/i18n.json +11 -0
- package/src/index.ts +16 -0
- package/src/k-linuxterminal.ts +83 -0
- package/tsconfig.json +12 -0
package/package.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kispace-io/extension-linuxterminal",
|
|
3
|
+
"version": "0.8.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./src/index.ts",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"import": "./src/index.ts",
|
|
9
|
+
"types": "./src/index.ts"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@kispace-io/core": "*",
|
|
14
|
+
"@xterm/xterm": "^5.5.0"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"typescript": "^5.9.3"
|
|
18
|
+
}
|
|
19
|
+
}
|
package/src/i18n.json
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"namespace": "extensions",
|
|
3
|
+
"en": {
|
|
4
|
+
"EXT_LINUXTERMINAL_NAME": "Linux terminal",
|
|
5
|
+
"EXT_LINUXTERMINAL_DESC": "Linux terminal view"
|
|
6
|
+
},
|
|
7
|
+
"de": {
|
|
8
|
+
"EXT_LINUXTERMINAL_NAME": "Linux-Terminal",
|
|
9
|
+
"EXT_LINUXTERMINAL_DESC": "Linux-Terminalansicht"
|
|
10
|
+
}
|
|
11
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { extensionRegistry, i18nLazy, contributionRegistry, SYSTEM_LANGUAGE_BUNDLES } from '@kispace-io/core';
|
|
2
|
+
import bundle from './i18n.json';
|
|
3
|
+
|
|
4
|
+
contributionRegistry.registerContribution(SYSTEM_LANGUAGE_BUNDLES, bundle as any);
|
|
5
|
+
|
|
6
|
+
const t = i18nLazy('extensions');
|
|
7
|
+
|
|
8
|
+
extensionRegistry.registerExtension({
|
|
9
|
+
id: "system.linuxterminal",
|
|
10
|
+
name: t('EXT_LINUXTERMINAL_NAME'),
|
|
11
|
+
description: t('EXT_LINUXTERMINAL_DESC'),
|
|
12
|
+
loader: () => import("./k-linuxterminal"),
|
|
13
|
+
icon: "terminal",
|
|
14
|
+
experimental: true,
|
|
15
|
+
|
|
16
|
+
});
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import {css, html, unsafeCSS} from 'lit'
|
|
2
|
+
import {customElement} from 'lit/decorators.js'
|
|
3
|
+
import {createRef, ref} from "lit/directives/ref.js";
|
|
4
|
+
import styles from "@xterm/xterm/css/xterm.css?raw";
|
|
5
|
+
import {KElement} from "@kispace-io/core";
|
|
6
|
+
|
|
7
|
+
// @ts-ignore
|
|
8
|
+
const CheerpX = window.CheerpX;
|
|
9
|
+
|
|
10
|
+
@customElement('k-linux-terminal')
|
|
11
|
+
export class KLinuxTerminal extends KElement {
|
|
12
|
+
private consoleRef = createRef()
|
|
13
|
+
|
|
14
|
+
protected async doInitUI() {
|
|
15
|
+
// The read-only disk image from Leaning Technologies' fast cloud backend
|
|
16
|
+
const cloudDevice = await CheerpX.CloudDevice.create(
|
|
17
|
+
"wss://disks.webvm.io/debian_large_20230522_5044875331.ext2"
|
|
18
|
+
);
|
|
19
|
+
// Read-write local storage for disk blocks, it is used both as a cache and as persisteny writable storage
|
|
20
|
+
const idbDevice = await CheerpX.IDBDevice.create("block1");
|
|
21
|
+
// A device to overlay the local changes to the disk with the remote read-only image
|
|
22
|
+
const overlayDevice = await CheerpX.OverlayDevice.create(
|
|
23
|
+
cloudDevice,
|
|
24
|
+
idbDevice
|
|
25
|
+
);
|
|
26
|
+
// Direct acces to files in your HTTP server
|
|
27
|
+
const webDevice = await CheerpX.WebDevice.create("");
|
|
28
|
+
// Convenient access to JavaScript binary data and strings
|
|
29
|
+
const dataDevice = await CheerpX.DataDevice.create();
|
|
30
|
+
|
|
31
|
+
const cx = await CheerpX.Linux.create({
|
|
32
|
+
mounts: [
|
|
33
|
+
{type: "ext2", path: "/", dev: overlayDevice},
|
|
34
|
+
{type: "dir", path: "/app", dev: webDevice},
|
|
35
|
+
{type: "dir", path: "/data", dev: dataDevice},
|
|
36
|
+
{type: "devs", path: "/dev"},
|
|
37
|
+
],
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// Interact with a console
|
|
41
|
+
cx.setConsole(this.consoleRef.value);
|
|
42
|
+
|
|
43
|
+
// Run a full-featured shell in your browser.
|
|
44
|
+
await cx.run("/bin/bash", ["--login"], {
|
|
45
|
+
env: [
|
|
46
|
+
"HOME=/home/user",
|
|
47
|
+
"HOME=/home/user",
|
|
48
|
+
"USER=user",
|
|
49
|
+
"SHELL=/bin/bash",
|
|
50
|
+
"EDITOR=vim",
|
|
51
|
+
"LANG=en_US.UTF-8",
|
|
52
|
+
"LC_ALL=C",
|
|
53
|
+
],
|
|
54
|
+
cwd: "/home/user",
|
|
55
|
+
uid: 1000,
|
|
56
|
+
gid: 1000,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
render() {
|
|
61
|
+
return html`
|
|
62
|
+
<pre class="console" ${ref(this.consoleRef)}></pre>
|
|
63
|
+
`;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
static styles = [unsafeCSS(styles),
|
|
67
|
+
css`
|
|
68
|
+
:host {
|
|
69
|
+
display: flex;
|
|
70
|
+
flex: 1;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
pre.console {
|
|
74
|
+
flex: 1;
|
|
75
|
+
}
|
|
76
|
+
`]
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
declare global {
|
|
80
|
+
interface HTMLElementTagNameMap {
|
|
81
|
+
'k-linux-terminal': KLinuxTerminal
|
|
82
|
+
}
|
|
83
|
+
}
|