@dovetail-v2/refine 0.4.1 → 0.4.2-alpha.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/dist/PodShell-1ab70e6b.js +2084 -0
- package/dist/PodShell-fdd7ac78.cjs +2084 -0
- package/dist/{common-1eb43414.cjs → common-84e75a63.cjs} +42 -9
- package/dist/{common-241b21f8.js → common-b35e289c.js} +50 -17
- package/dist/hooks/useEagleTable/useEagleTable.d.ts +1 -1
- package/dist/{index-ab97826a.js → index-33963e6a.js} +126 -5
- package/dist/{index-31874f77.cjs → index-9c194830.cjs} +124 -3
- package/dist/refine.cjs +15869 -5832
- package/dist/refine.js +15816 -5779
- package/dist/shell.cjs +2 -3
- package/dist/shell.js +2 -3
- package/package.json +65 -33
- package/dist/PodShell-43c7028e.cjs +0 -216
- package/dist/PodShell-76331418.js +0 -216
package/dist/shell.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const index = require("./index-
|
|
4
|
-
const common = require("./common-
|
|
3
|
+
const index = require("./index-9c194830.cjs");
|
|
4
|
+
const common = require("./common-84e75a63.cjs");
|
|
5
5
|
require("@cloudtower/eagle");
|
|
6
6
|
require("@xterm/addon-canvas");
|
|
7
7
|
require("@xterm/addon-fit");
|
|
@@ -9,7 +9,6 @@ require("@xterm/addon-search");
|
|
|
9
9
|
require("@xterm/addon-web-links");
|
|
10
10
|
require("@xterm/addon-webgl");
|
|
11
11
|
require("@xterm/xterm");
|
|
12
|
-
require("copy-to-clipboard");
|
|
13
12
|
require("lodash-es");
|
|
14
13
|
require("react");
|
|
15
14
|
require("@cloudtower/icons-react");
|
package/dist/shell.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S } from "./index-
|
|
2
|
-
import { S as S2 } from "./common-
|
|
1
|
+
import { S } from "./index-33963e6a.js";
|
|
2
|
+
import { S as S2 } from "./common-b35e289c.js";
|
|
3
3
|
import "@cloudtower/eagle";
|
|
4
4
|
import "@xterm/addon-canvas";
|
|
5
5
|
import "@xterm/addon-fit";
|
|
@@ -7,7 +7,6 @@ import "@xterm/addon-search";
|
|
|
7
7
|
import "@xterm/addon-web-links";
|
|
8
8
|
import "@xterm/addon-webgl";
|
|
9
9
|
import "@xterm/xterm";
|
|
10
|
-
import "copy-to-clipboard";
|
|
11
10
|
import "lodash-es";
|
|
12
11
|
import "react";
|
|
13
12
|
import "@cloudtower/icons-react";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dovetail-v2/refine",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2-alpha.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -10,44 +10,18 @@
|
|
|
10
10
|
"module": "./dist/refine.js",
|
|
11
11
|
"types": "./dist/index.d.ts",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@cloudtower/eagle": "^490.0.1",
|
|
14
|
-
"@cloudtower/icons-react": "^490.0.1",
|
|
15
|
-
"@patternfly/react-core": "^5.1.1",
|
|
16
|
-
"@patternfly/react-log-viewer": "^5.2.0",
|
|
17
|
-
"@refinedev/core": "^4.47.2",
|
|
18
|
-
"@refinedev/inferencer": "^4.5.20",
|
|
19
|
-
"@refinedev/react-hook-form": "^4.8.14",
|
|
20
|
-
"@xterm/addon-attach": "^0.11.0",
|
|
21
|
-
"@xterm/addon-canvas": "^0.7.0",
|
|
22
|
-
"@xterm/addon-fit": "^0.10.0",
|
|
23
|
-
"@xterm/addon-search": "^0.15.0",
|
|
24
|
-
"@xterm/addon-web-links": "^0.11.0",
|
|
25
|
-
"@xterm/addon-webgl": "^0.18.0",
|
|
26
|
-
"@xterm/xterm": "^5.5.0",
|
|
27
|
-
"antd": "4.5.0",
|
|
28
13
|
"buffer": "^6.0.3",
|
|
29
14
|
"copy-to-clipboard": "^3.3.3",
|
|
30
|
-
"dayjs": "^1.11.10",
|
|
31
|
-
"i18next": "^23.2.3",
|
|
32
|
-
"js-yaml": "^4.1.0",
|
|
33
|
-
"k8s-api-provider": "^0.0.36",
|
|
34
|
-
"ky": "^0.33.3",
|
|
35
|
-
"lodash-es": "^4.17.21",
|
|
36
15
|
"mitt": "^3.0.1",
|
|
37
|
-
"monaco-editor": "^0.33.0",
|
|
38
|
-
"monaco-yaml": "^4.0.4",
|
|
39
16
|
"qs": "6.11.2",
|
|
40
|
-
"
|
|
41
|
-
"react-dom": "^16.12.0",
|
|
42
|
-
"react-hook-form": "^7.50.1",
|
|
43
|
-
"react-router-dom": "^5.1.2",
|
|
44
|
-
"sunflower-antd": "^1.0.0-beta.3",
|
|
45
|
-
"usehooks-ts": "^2.9.1"
|
|
17
|
+
"sunflower-antd": "^1.0.0-beta.3"
|
|
46
18
|
},
|
|
47
19
|
"devDependencies": {
|
|
48
20
|
"@babel/core": "^7.4.0",
|
|
49
21
|
"@babel/preset-env": "^7.1.6",
|
|
50
22
|
"@babel/preset-typescript": "^7.10.4",
|
|
23
|
+
"@cloudtower/eagle": "^490.0.1",
|
|
24
|
+
"@cloudtower/icons-react": "^490.0.1",
|
|
51
25
|
"@kubernetes/client-node": "^0.20.0",
|
|
52
26
|
"@linaria/babel-preset": "^4.5.4",
|
|
53
27
|
"@linaria/core": "^4.5.4",
|
|
@@ -55,14 +29,22 @@
|
|
|
55
29
|
"@linaria/react": "^4.5.4",
|
|
56
30
|
"@linaria/utils": "^4.5.3",
|
|
57
31
|
"@linaria/vite": "^4.5.4",
|
|
32
|
+
"@patternfly/react-core": "^5.1.1",
|
|
33
|
+
"@patternfly/react-log-viewer": "^5.2.0",
|
|
58
34
|
"@playwright/test": "^1.39.0",
|
|
59
35
|
"@refinedev/cli": "^2.9.0",
|
|
36
|
+
"@refinedev/core": "^4.47.2",
|
|
37
|
+
"@refinedev/inferencer": "^4.5.20",
|
|
38
|
+
"@refinedev/react-hook-form": "^4.8.14",
|
|
60
39
|
"@rollup/pluginutils": "^4.2.1",
|
|
40
|
+
"@tanstack/react-query": "^4.35.3",
|
|
61
41
|
"@testing-library/react-hooks": "7",
|
|
62
42
|
"@types/body-parser": "^1.19.5",
|
|
43
|
+
"@types/history": "^4.7.11",
|
|
63
44
|
"@types/jest": "^29",
|
|
64
45
|
"@types/js-yaml": "^4.0.6",
|
|
65
46
|
"@types/json-schema": "^7.0.13",
|
|
47
|
+
"@types/lodash": "^4.14.198",
|
|
66
48
|
"@types/lodash-es": "^4.17.9",
|
|
67
49
|
"@types/node": "^18.16.2",
|
|
68
50
|
"@types/qs": "^6.9.8",
|
|
@@ -72,28 +54,78 @@
|
|
|
72
54
|
"@typescript-eslint/eslint-plugin": "^6.7.5",
|
|
73
55
|
"@typescript-eslint/parser": "^6.7.5",
|
|
74
56
|
"@vitejs/plugin-react": "^4.0.0",
|
|
57
|
+
"@xterm/addon-attach": "^0.11.0",
|
|
58
|
+
"@xterm/addon-canvas": "^0.7.0",
|
|
59
|
+
"@xterm/addon-fit": "^0.10.0",
|
|
60
|
+
"@xterm/addon-search": "^0.15.0",
|
|
61
|
+
"@xterm/addon-web-links": "^0.11.0",
|
|
62
|
+
"@xterm/addon-webgl": "^0.18.0",
|
|
63
|
+
"@xterm/xterm": "^5.5.0",
|
|
64
|
+
"antd": "4.5.0",
|
|
75
65
|
"body-parser": "^1.20.2",
|
|
66
|
+
"buffer": "^6.0.3",
|
|
67
|
+
"copy-to-clipboard": "^3.3.3",
|
|
68
|
+
"dayjs": "^1.11.10",
|
|
76
69
|
"eslint": "^8.38.0",
|
|
77
70
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
78
71
|
"eslint-plugin-react-refresh": "^0.3.4",
|
|
72
|
+
"history": "^4.10.1",
|
|
73
|
+
"i18next": "^23.2.3",
|
|
79
74
|
"jest": "^29",
|
|
80
75
|
"jest-environment-jsdom": "^30.0.0",
|
|
76
|
+
"js-yaml": "^4.1.0",
|
|
77
|
+
"json-schema": "^0.4.0",
|
|
78
|
+
"k8s-api-provider": "^0.0.36",
|
|
81
79
|
"kubernetes-types": "^1.26.0",
|
|
80
|
+
"ky": "^0.33.3",
|
|
81
|
+
"lodash": "^4.17.21",
|
|
82
|
+
"lodash-es": "^4.17.21",
|
|
83
|
+
"mitt": "^3.0.1",
|
|
84
|
+
"monaco-editor": "^0.33.0",
|
|
85
|
+
"monaco-yaml": "^4.0.4",
|
|
82
86
|
"prettier": "2.8.8",
|
|
87
|
+
"qs": "6.11.2",
|
|
88
|
+
"react": "^16.12.0",
|
|
89
|
+
"react-dom": "^16.12.0",
|
|
90
|
+
"react-hook-form": "^7.50.1",
|
|
91
|
+
"react-router-dom": "^5.1.2",
|
|
83
92
|
"sass": "1.51.0",
|
|
93
|
+
"sunflower-antd": "^1.0.0-beta.3",
|
|
84
94
|
"ts-jest": "^29",
|
|
95
|
+
"usehooks-ts": "^2.9.1",
|
|
85
96
|
"vite": "^4.5.2",
|
|
86
|
-
"vite-plugin-commonjs": "^0.10.0"
|
|
97
|
+
"vite-plugin-commonjs": "^0.10.0",
|
|
98
|
+
"ws": "^8.18.2"
|
|
87
99
|
},
|
|
88
100
|
"peerDependencies": {
|
|
89
101
|
"@cloudtower/eagle": "^490.0.1",
|
|
90
102
|
"@cloudtower/icons-react": "^490.0.1",
|
|
103
|
+
"@patternfly/react-core": "^5.1.1",
|
|
104
|
+
"@patternfly/react-log-viewer": "^5.2.0",
|
|
91
105
|
"@refinedev/core": "^4.47.2",
|
|
106
|
+
"@refinedev/inferencer": "^4.5.20",
|
|
107
|
+
"@refinedev/react-hook-form": "^4.8.14",
|
|
108
|
+
"@xterm/addon-attach": "^0.11.0",
|
|
109
|
+
"@xterm/addon-canvas": "^0.7.0",
|
|
110
|
+
"@xterm/addon-fit": "^0.10.0",
|
|
111
|
+
"@xterm/addon-search": "^0.15.0",
|
|
112
|
+
"@xterm/addon-web-links": "^0.11.0",
|
|
113
|
+
"@xterm/addon-webgl": "^0.18.0",
|
|
114
|
+
"@xterm/xterm": "^5.5.0",
|
|
92
115
|
"antd": "4.5.0",
|
|
116
|
+
"dayjs": "^1.11.10",
|
|
93
117
|
"i18next": "^23.2.3",
|
|
118
|
+
"js-yaml": "^4.1.0",
|
|
119
|
+
"k8s-api-provider": "^0.0.36",
|
|
120
|
+
"ky": "^0.33.3",
|
|
121
|
+
"lodash-es": "^4.17.21",
|
|
122
|
+
"monaco-editor": "^0.33.0",
|
|
123
|
+
"monaco-yaml": "^4.0.4",
|
|
94
124
|
"react": "^16.12.0",
|
|
95
125
|
"react-dom": "^16.12.0",
|
|
96
|
-
"react-
|
|
126
|
+
"react-hook-form": "^7.50.1",
|
|
127
|
+
"react-router-dom": "^5.1.2",
|
|
128
|
+
"usehooks-ts": "^2.9.1"
|
|
97
129
|
},
|
|
98
130
|
"scripts": {
|
|
99
131
|
"dev": "refine dev",
|
|
@@ -103,7 +135,7 @@
|
|
|
103
135
|
"refine": "refine",
|
|
104
136
|
"unit-test": "jest",
|
|
105
137
|
"playwright-test": "npx playwright test --workers 1",
|
|
106
|
-
"test": "
|
|
138
|
+
"test": "pnpm unit-test && pnpm playwright-test",
|
|
107
139
|
"lint": "eslint src --ext .ts,.tsx"
|
|
108
140
|
},
|
|
109
141
|
"browserslist": {
|
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const common = require("./common-1eb43414.cjs");
|
|
4
|
-
const eagle = require("@cloudtower/eagle");
|
|
5
|
-
const React = require("react");
|
|
6
|
-
const index = require("./index-31874f77.cjs");
|
|
7
|
-
const buffer = require("buffer");
|
|
8
|
-
require("@xterm/addon-canvas");
|
|
9
|
-
require("@xterm/addon-fit");
|
|
10
|
-
require("@xterm/addon-search");
|
|
11
|
-
require("@xterm/addon-web-links");
|
|
12
|
-
require("@xterm/addon-webgl");
|
|
13
|
-
require("@xterm/xterm");
|
|
14
|
-
require("copy-to-clipboard");
|
|
15
|
-
require("lodash-es");
|
|
16
|
-
require("@cloudtower/icons-react");
|
|
17
|
-
function addParam(url, key, val) {
|
|
18
|
-
let out = url + (url.includes("?") ? "&" : "?");
|
|
19
|
-
if (!Array.isArray(val)) {
|
|
20
|
-
val = [val];
|
|
21
|
-
}
|
|
22
|
-
out += val.map((v) => {
|
|
23
|
-
if (v === null) {
|
|
24
|
-
return `${encodeURIComponent(key)}`;
|
|
25
|
-
} else {
|
|
26
|
-
return `${encodeURIComponent(key)}=${encodeURIComponent(v)}`;
|
|
27
|
-
}
|
|
28
|
-
}).join("&");
|
|
29
|
-
return out;
|
|
30
|
-
}
|
|
31
|
-
function addParams(url, params) {
|
|
32
|
-
if (params && typeof params === "object") {
|
|
33
|
-
Object.keys(params).forEach((key) => {
|
|
34
|
-
url = addParam(url, key, params[key]);
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
return url;
|
|
38
|
-
}
|
|
39
|
-
function base64Encode(str, alphabet = "normal") {
|
|
40
|
-
let buf;
|
|
41
|
-
if (str === null || typeof str === "undefined") {
|
|
42
|
-
return str;
|
|
43
|
-
}
|
|
44
|
-
if (typeof buffer.Buffer.from === "function" && buffer.Buffer.from !== Uint8Array.from) {
|
|
45
|
-
buf = buffer.Buffer.from(str);
|
|
46
|
-
} else {
|
|
47
|
-
buf = new buffer.Buffer(str);
|
|
48
|
-
}
|
|
49
|
-
if (alphabet === "url") {
|
|
50
|
-
const m = {
|
|
51
|
-
"+": "-",
|
|
52
|
-
"/": "_"
|
|
53
|
-
};
|
|
54
|
-
return buf.toString("base64").replace(/[+/]|=+$/g, (char) => m[char] || "");
|
|
55
|
-
}
|
|
56
|
-
return buf.toString("base64");
|
|
57
|
-
}
|
|
58
|
-
function base64DecodeToBuffer(str) {
|
|
59
|
-
if (str === null || typeof str === "undefined") {
|
|
60
|
-
return str;
|
|
61
|
-
}
|
|
62
|
-
if (typeof buffer.Buffer.from === "function" && buffer.Buffer.from !== Uint8Array.from) {
|
|
63
|
-
return buffer.Buffer.from(str, "base64");
|
|
64
|
-
} else {
|
|
65
|
-
return new buffer.Buffer(str, "base64");
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
function base64Decode(str) {
|
|
69
|
-
return !str ? str : base64DecodeToBuffer(str.replace(/[-_]/g, (char) => char === "-" ? "+" : "/")).toString();
|
|
70
|
-
}
|
|
71
|
-
var OS = /* @__PURE__ */ ((OS2) => {
|
|
72
|
-
OS2["Linux"] = "linux";
|
|
73
|
-
OS2["Windows"] = "windows";
|
|
74
|
-
return OS2;
|
|
75
|
-
})(OS || {});
|
|
76
|
-
const BACKUP_SHELLS = [
|
|
77
|
-
"windows",
|
|
78
|
-
"linux"
|
|
79
|
-
/* Linux */
|
|
80
|
-
];
|
|
81
|
-
const COMMANDS = {
|
|
82
|
-
[
|
|
83
|
-
"linux"
|
|
84
|
-
/* Linux */
|
|
85
|
-
]: [
|
|
86
|
-
"/bin/sh",
|
|
87
|
-
"-c",
|
|
88
|
-
'TERM=xterm-256color; export TERM; [ -x /bin/bash ] && ([ -x /usr/bin/script ] && /usr/bin/script -q -c "/bin/bash" /dev/null || exec /bin/bash) || exec /bin/sh'
|
|
89
|
-
],
|
|
90
|
-
[
|
|
91
|
-
"windows"
|
|
92
|
-
/* Windows */
|
|
93
|
-
]: ["cmd"]
|
|
94
|
-
};
|
|
95
|
-
const PodShell = React.forwardRef(
|
|
96
|
-
function PodShell2(props, ref) {
|
|
97
|
-
const { pod, basePath, onSocketStatusChange } = props;
|
|
98
|
-
const id = pod.id;
|
|
99
|
-
const [namespace, name] = React.useMemo(() => id.split("/"), [id]);
|
|
100
|
-
const shellRef = React.useRef(null);
|
|
101
|
-
const errorMsgRef = React.useRef("");
|
|
102
|
-
const [osIndex, setOsIndex] = React.useState(0);
|
|
103
|
-
const [container, setContainer] = React.useState("");
|
|
104
|
-
const containers = React.useMemo(() => {
|
|
105
|
-
var _a, _b;
|
|
106
|
-
return (((_a = pod == null ? void 0 : pod._rawYaml.status) == null ? void 0 : _a.containerStatuses) || []).concat(((_b = pod == null ? void 0 : pod._rawYaml.status) == null ? void 0 : _b.initContainerStatuses) || []).map((containerStatus) => containerStatus.name);
|
|
107
|
-
}, [pod]);
|
|
108
|
-
const url = React.useMemo(() => {
|
|
109
|
-
const os = BACKUP_SHELLS[osIndex];
|
|
110
|
-
const protocol = location.protocol.includes("https") ? "wss" : "ws";
|
|
111
|
-
const url2 = container && os ? addParams(
|
|
112
|
-
`${protocol}://${location.host}${basePath}/api/v1/namespaces/${namespace}/pods/${name}/exec`,
|
|
113
|
-
{
|
|
114
|
-
container,
|
|
115
|
-
stdout: "true",
|
|
116
|
-
stdin: "true",
|
|
117
|
-
stderr: "true",
|
|
118
|
-
tty: "true",
|
|
119
|
-
command: COMMANDS[
|
|
120
|
-
os || "linux"
|
|
121
|
-
/* Linux */
|
|
122
|
-
]
|
|
123
|
-
}
|
|
124
|
-
) : "";
|
|
125
|
-
return url2;
|
|
126
|
-
}, [container, name, namespace, osIndex, basePath]);
|
|
127
|
-
const onSocketClose = React.useCallback(
|
|
128
|
-
(socket, term) => {
|
|
129
|
-
var _a, _b;
|
|
130
|
-
if (errorMsgRef.current) {
|
|
131
|
-
if (osIndex + 1 < BACKUP_SHELLS.length) {
|
|
132
|
-
setOsIndex(osIndex + 1);
|
|
133
|
-
} else {
|
|
134
|
-
term == null ? void 0 : term.writeln(`\x1B[38;2;255;82;82m${errorMsgRef.current}`);
|
|
135
|
-
(_a = shellRef.current) == null ? void 0 : _a.setSocketStatus(common.SocketStatus.Disconnected);
|
|
136
|
-
errorMsgRef.current = "";
|
|
137
|
-
}
|
|
138
|
-
} else {
|
|
139
|
-
(_b = shellRef.current) == null ? void 0 : _b.setSocketStatus(common.SocketStatus.Disconnected);
|
|
140
|
-
}
|
|
141
|
-
},
|
|
142
|
-
[osIndex]
|
|
143
|
-
);
|
|
144
|
-
const onSocketMessage = React.useCallback(
|
|
145
|
-
(e, socket, term) => {
|
|
146
|
-
const type = e.data.substr(0, 1);
|
|
147
|
-
const msg = base64Decode(e.data.substr(1));
|
|
148
|
-
if (`${type}` === "1") {
|
|
149
|
-
term == null ? void 0 : term.write(msg);
|
|
150
|
-
} else {
|
|
151
|
-
if (`${type}` === "3") {
|
|
152
|
-
errorMsgRef.current = msg;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
},
|
|
156
|
-
[]
|
|
157
|
-
);
|
|
158
|
-
const fit = React.useCallback(({ rows, cols }) => {
|
|
159
|
-
var _a;
|
|
160
|
-
const message = `${"4"}${base64Encode(
|
|
161
|
-
JSON.stringify({
|
|
162
|
-
Width: Math.floor(cols),
|
|
163
|
-
Height: Math.floor(rows)
|
|
164
|
-
})
|
|
165
|
-
)}`;
|
|
166
|
-
(_a = shellRef.current) == null ? void 0 : _a.send(message);
|
|
167
|
-
}, []);
|
|
168
|
-
const encode = React.useCallback((input) => `${"0"}${base64Encode(input)}`, []);
|
|
169
|
-
React.useEffect(() => {
|
|
170
|
-
if (!container && containers.length) {
|
|
171
|
-
setContainer(containers[0]);
|
|
172
|
-
}
|
|
173
|
-
}, [containers, container]);
|
|
174
|
-
React.useImperativeHandle(
|
|
175
|
-
ref,
|
|
176
|
-
() => ({
|
|
177
|
-
getAllTerminalContents: () => {
|
|
178
|
-
var _a;
|
|
179
|
-
return ((_a = shellRef.current) == null ? void 0 : _a.getAllTerminalContents()) || [];
|
|
180
|
-
}
|
|
181
|
-
}),
|
|
182
|
-
[]
|
|
183
|
-
);
|
|
184
|
-
return /* @__PURE__ */ common.jsxRuntimeExports.jsx(
|
|
185
|
-
index.Shell,
|
|
186
|
-
{
|
|
187
|
-
ref: shellRef,
|
|
188
|
-
url,
|
|
189
|
-
protocols: "base64.channel.k8s.io",
|
|
190
|
-
encode,
|
|
191
|
-
fit,
|
|
192
|
-
toolbarLeftSlot: /* @__PURE__ */ common.jsxRuntimeExports.jsx(
|
|
193
|
-
eagle.Select,
|
|
194
|
-
{
|
|
195
|
-
input: {
|
|
196
|
-
value: container,
|
|
197
|
-
onChange(value) {
|
|
198
|
-
setContainer(value);
|
|
199
|
-
}
|
|
200
|
-
},
|
|
201
|
-
style: {
|
|
202
|
-
width: "256px"
|
|
203
|
-
},
|
|
204
|
-
size: "small",
|
|
205
|
-
children: containers.map((containerName) => /* @__PURE__ */ common.jsxRuntimeExports.jsx(eagle.AntdOption, { value: containerName, label: containerName, children: containerName }, containerName))
|
|
206
|
-
}
|
|
207
|
-
),
|
|
208
|
-
onSocketMessage,
|
|
209
|
-
onSocketClose,
|
|
210
|
-
onSocketStatusChange
|
|
211
|
-
}
|
|
212
|
-
);
|
|
213
|
-
}
|
|
214
|
-
);
|
|
215
|
-
exports.OS = OS;
|
|
216
|
-
exports.PodShell = PodShell;
|
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
import { S as SocketStatus, j as jsxRuntimeExports } from "./common-241b21f8.js";
|
|
2
|
-
import { Select, AntdOption } from "@cloudtower/eagle";
|
|
3
|
-
import React, { useMemo, useRef, useState, useCallback, useEffect, useImperativeHandle } from "react";
|
|
4
|
-
import { S as Shell } from "./index-ab97826a.js";
|
|
5
|
-
import { Buffer } from "buffer";
|
|
6
|
-
import "@xterm/addon-canvas";
|
|
7
|
-
import "@xterm/addon-fit";
|
|
8
|
-
import "@xterm/addon-search";
|
|
9
|
-
import "@xterm/addon-web-links";
|
|
10
|
-
import "@xterm/addon-webgl";
|
|
11
|
-
import "@xterm/xterm";
|
|
12
|
-
import "copy-to-clipboard";
|
|
13
|
-
import "lodash-es";
|
|
14
|
-
import "@cloudtower/icons-react";
|
|
15
|
-
function addParam(url, key, val) {
|
|
16
|
-
let out = url + (url.includes("?") ? "&" : "?");
|
|
17
|
-
if (!Array.isArray(val)) {
|
|
18
|
-
val = [val];
|
|
19
|
-
}
|
|
20
|
-
out += val.map((v) => {
|
|
21
|
-
if (v === null) {
|
|
22
|
-
return `${encodeURIComponent(key)}`;
|
|
23
|
-
} else {
|
|
24
|
-
return `${encodeURIComponent(key)}=${encodeURIComponent(v)}`;
|
|
25
|
-
}
|
|
26
|
-
}).join("&");
|
|
27
|
-
return out;
|
|
28
|
-
}
|
|
29
|
-
function addParams(url, params) {
|
|
30
|
-
if (params && typeof params === "object") {
|
|
31
|
-
Object.keys(params).forEach((key) => {
|
|
32
|
-
url = addParam(url, key, params[key]);
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
return url;
|
|
36
|
-
}
|
|
37
|
-
function base64Encode(str, alphabet = "normal") {
|
|
38
|
-
let buf;
|
|
39
|
-
if (str === null || typeof str === "undefined") {
|
|
40
|
-
return str;
|
|
41
|
-
}
|
|
42
|
-
if (typeof Buffer.from === "function" && Buffer.from !== Uint8Array.from) {
|
|
43
|
-
buf = Buffer.from(str);
|
|
44
|
-
} else {
|
|
45
|
-
buf = new Buffer(str);
|
|
46
|
-
}
|
|
47
|
-
if (alphabet === "url") {
|
|
48
|
-
const m = {
|
|
49
|
-
"+": "-",
|
|
50
|
-
"/": "_"
|
|
51
|
-
};
|
|
52
|
-
return buf.toString("base64").replace(/[+/]|=+$/g, (char) => m[char] || "");
|
|
53
|
-
}
|
|
54
|
-
return buf.toString("base64");
|
|
55
|
-
}
|
|
56
|
-
function base64DecodeToBuffer(str) {
|
|
57
|
-
if (str === null || typeof str === "undefined") {
|
|
58
|
-
return str;
|
|
59
|
-
}
|
|
60
|
-
if (typeof Buffer.from === "function" && Buffer.from !== Uint8Array.from) {
|
|
61
|
-
return Buffer.from(str, "base64");
|
|
62
|
-
} else {
|
|
63
|
-
return new Buffer(str, "base64");
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
function base64Decode(str) {
|
|
67
|
-
return !str ? str : base64DecodeToBuffer(str.replace(/[-_]/g, (char) => char === "-" ? "+" : "/")).toString();
|
|
68
|
-
}
|
|
69
|
-
var OS = /* @__PURE__ */ ((OS2) => {
|
|
70
|
-
OS2["Linux"] = "linux";
|
|
71
|
-
OS2["Windows"] = "windows";
|
|
72
|
-
return OS2;
|
|
73
|
-
})(OS || {});
|
|
74
|
-
const BACKUP_SHELLS = [
|
|
75
|
-
"windows",
|
|
76
|
-
"linux"
|
|
77
|
-
/* Linux */
|
|
78
|
-
];
|
|
79
|
-
const COMMANDS = {
|
|
80
|
-
[
|
|
81
|
-
"linux"
|
|
82
|
-
/* Linux */
|
|
83
|
-
]: [
|
|
84
|
-
"/bin/sh",
|
|
85
|
-
"-c",
|
|
86
|
-
'TERM=xterm-256color; export TERM; [ -x /bin/bash ] && ([ -x /usr/bin/script ] && /usr/bin/script -q -c "/bin/bash" /dev/null || exec /bin/bash) || exec /bin/sh'
|
|
87
|
-
],
|
|
88
|
-
[
|
|
89
|
-
"windows"
|
|
90
|
-
/* Windows */
|
|
91
|
-
]: ["cmd"]
|
|
92
|
-
};
|
|
93
|
-
const PodShell = React.forwardRef(
|
|
94
|
-
function PodShell2(props, ref) {
|
|
95
|
-
const { pod, basePath, onSocketStatusChange } = props;
|
|
96
|
-
const id = pod.id;
|
|
97
|
-
const [namespace, name] = useMemo(() => id.split("/"), [id]);
|
|
98
|
-
const shellRef = useRef(null);
|
|
99
|
-
const errorMsgRef = useRef("");
|
|
100
|
-
const [osIndex, setOsIndex] = useState(0);
|
|
101
|
-
const [container, setContainer] = useState("");
|
|
102
|
-
const containers = useMemo(() => {
|
|
103
|
-
var _a, _b;
|
|
104
|
-
return (((_a = pod == null ? void 0 : pod._rawYaml.status) == null ? void 0 : _a.containerStatuses) || []).concat(((_b = pod == null ? void 0 : pod._rawYaml.status) == null ? void 0 : _b.initContainerStatuses) || []).map((containerStatus) => containerStatus.name);
|
|
105
|
-
}, [pod]);
|
|
106
|
-
const url = useMemo(() => {
|
|
107
|
-
const os = BACKUP_SHELLS[osIndex];
|
|
108
|
-
const protocol = location.protocol.includes("https") ? "wss" : "ws";
|
|
109
|
-
const url2 = container && os ? addParams(
|
|
110
|
-
`${protocol}://${location.host}${basePath}/api/v1/namespaces/${namespace}/pods/${name}/exec`,
|
|
111
|
-
{
|
|
112
|
-
container,
|
|
113
|
-
stdout: "true",
|
|
114
|
-
stdin: "true",
|
|
115
|
-
stderr: "true",
|
|
116
|
-
tty: "true",
|
|
117
|
-
command: COMMANDS[
|
|
118
|
-
os || "linux"
|
|
119
|
-
/* Linux */
|
|
120
|
-
]
|
|
121
|
-
}
|
|
122
|
-
) : "";
|
|
123
|
-
return url2;
|
|
124
|
-
}, [container, name, namespace, osIndex, basePath]);
|
|
125
|
-
const onSocketClose = useCallback(
|
|
126
|
-
(socket, term) => {
|
|
127
|
-
var _a, _b;
|
|
128
|
-
if (errorMsgRef.current) {
|
|
129
|
-
if (osIndex + 1 < BACKUP_SHELLS.length) {
|
|
130
|
-
setOsIndex(osIndex + 1);
|
|
131
|
-
} else {
|
|
132
|
-
term == null ? void 0 : term.writeln(`\x1B[38;2;255;82;82m${errorMsgRef.current}`);
|
|
133
|
-
(_a = shellRef.current) == null ? void 0 : _a.setSocketStatus(SocketStatus.Disconnected);
|
|
134
|
-
errorMsgRef.current = "";
|
|
135
|
-
}
|
|
136
|
-
} else {
|
|
137
|
-
(_b = shellRef.current) == null ? void 0 : _b.setSocketStatus(SocketStatus.Disconnected);
|
|
138
|
-
}
|
|
139
|
-
},
|
|
140
|
-
[osIndex]
|
|
141
|
-
);
|
|
142
|
-
const onSocketMessage = useCallback(
|
|
143
|
-
(e, socket, term) => {
|
|
144
|
-
const type = e.data.substr(0, 1);
|
|
145
|
-
const msg = base64Decode(e.data.substr(1));
|
|
146
|
-
if (`${type}` === "1") {
|
|
147
|
-
term == null ? void 0 : term.write(msg);
|
|
148
|
-
} else {
|
|
149
|
-
if (`${type}` === "3") {
|
|
150
|
-
errorMsgRef.current = msg;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
},
|
|
154
|
-
[]
|
|
155
|
-
);
|
|
156
|
-
const fit = useCallback(({ rows, cols }) => {
|
|
157
|
-
var _a;
|
|
158
|
-
const message = `${"4"}${base64Encode(
|
|
159
|
-
JSON.stringify({
|
|
160
|
-
Width: Math.floor(cols),
|
|
161
|
-
Height: Math.floor(rows)
|
|
162
|
-
})
|
|
163
|
-
)}`;
|
|
164
|
-
(_a = shellRef.current) == null ? void 0 : _a.send(message);
|
|
165
|
-
}, []);
|
|
166
|
-
const encode = useCallback((input) => `${"0"}${base64Encode(input)}`, []);
|
|
167
|
-
useEffect(() => {
|
|
168
|
-
if (!container && containers.length) {
|
|
169
|
-
setContainer(containers[0]);
|
|
170
|
-
}
|
|
171
|
-
}, [containers, container]);
|
|
172
|
-
useImperativeHandle(
|
|
173
|
-
ref,
|
|
174
|
-
() => ({
|
|
175
|
-
getAllTerminalContents: () => {
|
|
176
|
-
var _a;
|
|
177
|
-
return ((_a = shellRef.current) == null ? void 0 : _a.getAllTerminalContents()) || [];
|
|
178
|
-
}
|
|
179
|
-
}),
|
|
180
|
-
[]
|
|
181
|
-
);
|
|
182
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
183
|
-
Shell,
|
|
184
|
-
{
|
|
185
|
-
ref: shellRef,
|
|
186
|
-
url,
|
|
187
|
-
protocols: "base64.channel.k8s.io",
|
|
188
|
-
encode,
|
|
189
|
-
fit,
|
|
190
|
-
toolbarLeftSlot: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
191
|
-
Select,
|
|
192
|
-
{
|
|
193
|
-
input: {
|
|
194
|
-
value: container,
|
|
195
|
-
onChange(value) {
|
|
196
|
-
setContainer(value);
|
|
197
|
-
}
|
|
198
|
-
},
|
|
199
|
-
style: {
|
|
200
|
-
width: "256px"
|
|
201
|
-
},
|
|
202
|
-
size: "small",
|
|
203
|
-
children: containers.map((containerName) => /* @__PURE__ */ jsxRuntimeExports.jsx(AntdOption, { value: containerName, label: containerName, children: containerName }, containerName))
|
|
204
|
-
}
|
|
205
|
-
),
|
|
206
|
-
onSocketMessage,
|
|
207
|
-
onSocketClose,
|
|
208
|
-
onSocketStatusChange
|
|
209
|
-
}
|
|
210
|
-
);
|
|
211
|
-
}
|
|
212
|
-
);
|
|
213
|
-
export {
|
|
214
|
-
OS,
|
|
215
|
-
PodShell
|
|
216
|
-
};
|