@dovetail-v2/refine 0.2.4-alpha.0 → 0.2.5

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 (260) hide show
  1. package/dist/{MonacoYamlDiffEditor-7de94ad2.js → MonacoYamlDiffEditor-e0b05820.js} +24 -1
  2. package/dist/{MonacoYamlEditor-bc70e03e.js → MonacoYamlEditor-96d9a48c.js} +9 -2
  3. package/dist/{index-44cc930a.js → index-d8439125.js} +1919 -273
  4. package/dist/refine.js +257 -247
  5. package/dist/refine.umd.cjs +20793 -0
  6. package/dist/style.css +838 -883
  7. package/{dist → lib}/components/PodShellModal/PodShell.d.ts +5 -3
  8. package/lib/components/PodShellModal/index.d.ts +10 -0
  9. package/{dist → lib}/components/Shell/index.d.ts +5 -1
  10. package/{dist → lib}/components/TableToolbar/index.d.ts +1 -1
  11. package/{dist → lib}/components/index.d.ts +1 -0
  12. package/{dist → lib}/types/resource.d.ts +1 -1
  13. package/{dist → lib}/utils/index.d.ts +1 -0
  14. package/package.json +4 -4
  15. package/dist/MonacoYamlDiffEditor-7a07db88.cjs +0 -59
  16. package/dist/MonacoYamlEditor-bc33cd45.cjs +0 -206
  17. package/dist/PodShell-43c7028e.cjs +0 -216
  18. package/dist/PodShell-ba204cde.js +0 -216
  19. package/dist/common-1eb43414.cjs +0 -982
  20. package/dist/common-feae5742.js +0 -983
  21. package/dist/components/PodShellModal/index.d.ts +0 -10
  22. package/dist/components/Shell/Connecting.d.ts +0 -2
  23. package/dist/components/Shell/common.d.ts +0 -5
  24. package/dist/index-31874f77.cjs +0 -496
  25. package/dist/index-40deb620.js +0 -497
  26. package/dist/index-ee8ac828.cjs +0 -18959
  27. package/dist/refine.cjs +0 -279
  28. package/dist/shell.cjs +0 -17
  29. package/dist/shell.d.ts +0 -2
  30. package/dist/shell.js +0 -17
  31. /package/{dist → lib}/App.d.ts +0 -0
  32. /package/{dist → lib}/Dovetail.d.ts +0 -0
  33. /package/{dist → lib}/components/Breadcrumb/index.d.ts +0 -0
  34. /package/{dist → lib}/components/ConditionsTable/ConditionsTable.d.ts +0 -0
  35. /package/{dist → lib}/components/ConditionsTable/index.d.ts +0 -0
  36. /package/{dist → lib}/components/CreateButton/index.d.ts +0 -0
  37. /package/{dist → lib}/components/CronjobJobsTable/index.d.ts +0 -0
  38. /package/{dist → lib}/components/DeleteButton/index.d.ts +0 -0
  39. /package/{dist → lib}/components/DeleteManyButton/index.d.ts +0 -0
  40. /package/{dist → lib}/components/DrawerShow/DrawerShow.d.ts +0 -0
  41. /package/{dist → lib}/components/DrawerShow/index.d.ts +0 -0
  42. /package/{dist → lib}/components/DropdownMenuItems/EditAnnotationDropdownMenuItem.d.ts +0 -0
  43. /package/{dist → lib}/components/DropdownMenuItems/EditLabelDropdownMenuItem.d.ts +0 -0
  44. /package/{dist → lib}/components/DropdownMenuItems/EditNodeTaintDropdownMenuItem.d.ts +0 -0
  45. /package/{dist → lib}/components/DropdownMenuItems/index.d.ts +0 -0
  46. /package/{dist → lib}/components/Dropdowns/CronJobDropdown/index.d.ts +0 -0
  47. /package/{dist → lib}/components/Dropdowns/K8sDropdown/index.d.ts +0 -0
  48. /package/{dist → lib}/components/Dropdowns/PodDropdown/index.d.ts +0 -0
  49. /package/{dist → lib}/components/Dropdowns/ReplicasDropdown/index.d.ts +0 -0
  50. /package/{dist → lib}/components/Dropdowns/WorkloadDropdown/index.d.ts +0 -0
  51. /package/{dist → lib}/components/DurationTime/index.d.ts +0 -0
  52. /package/{dist → lib}/components/EditButton/index.d.ts +0 -0
  53. /package/{dist → lib}/components/EditField/index.d.ts +0 -0
  54. /package/{dist → lib}/components/EditMetadataForm/EditAnnotationForm.d.ts +0 -0
  55. /package/{dist → lib}/components/EditMetadataForm/EditLabelForm.d.ts +0 -0
  56. /package/{dist → lib}/components/EditMetadataForm/EditNodeTaintForm.d.ts +0 -0
  57. /package/{dist → lib}/components/EditMetadataForm/KeyValueTableForm.d.ts +0 -0
  58. /package/{dist → lib}/components/EditMetadataForm/LabelFormatPopover.d.ts +0 -0
  59. /package/{dist → lib}/components/EditMetadataForm/index.d.ts +0 -0
  60. /package/{dist → lib}/components/ErrorContent/index.d.ts +0 -0
  61. /package/{dist → lib}/components/EventsTable/EventsTable.d.ts +0 -0
  62. /package/{dist → lib}/components/EventsTable/index.d.ts +0 -0
  63. /package/{dist → lib}/components/Form/FormModal.d.ts +0 -0
  64. /package/{dist → lib}/components/Form/FormModeSegmentControl.d.ts +0 -0
  65. /package/{dist → lib}/components/Form/RefineFormContainer.d.ts +0 -0
  66. /package/{dist → lib}/components/Form/RefineFormContent.d.ts +0 -0
  67. /package/{dist → lib}/components/Form/RefineFormPage.d.ts +0 -0
  68. /package/{dist → lib}/components/Form/YamlForm.d.ts +0 -0
  69. /package/{dist → lib}/components/Form/YamlFormContainer.d.ts +0 -0
  70. /package/{dist → lib}/components/Form/index.d.ts +0 -0
  71. /package/{dist → lib}/components/Form/type.d.ts +0 -0
  72. /package/{dist → lib}/components/Form/useFieldsConfig.d.ts +0 -0
  73. /package/{dist → lib}/components/Form/useReactHookForm.d.ts +0 -0
  74. /package/{dist → lib}/components/Form/useRefineForm.d.ts +0 -0
  75. /package/{dist → lib}/components/Form/useYamlForm.d.ts +0 -0
  76. /package/{dist → lib}/components/FormErrorAlert/index.d.ts +0 -0
  77. /package/{dist → lib}/components/FormLayout/index.d.ts +0 -0
  78. /package/{dist → lib}/components/FormWidgets/KeyValueListWidget.d.ts +0 -0
  79. /package/{dist → lib}/components/FormWidgets/MetadataForm.d.ts +0 -0
  80. /package/{dist → lib}/components/FormWidgets/NameInputWidget.d.ts +0 -0
  81. /package/{dist → lib}/components/FormWidgets/NamespaceSelectWidget.d.ts +0 -0
  82. /package/{dist → lib}/components/FormWidgets/index.d.ts +0 -0
  83. /package/{dist → lib}/components/FormWidgets/widget.d.ts +0 -0
  84. /package/{dist → lib}/components/ImageNames/index.d.ts +0 -0
  85. /package/{dist → lib}/components/IngressRulesComponent/index.d.ts +0 -0
  86. /package/{dist → lib}/components/IngressRulesTable/IngressRulesTable.d.ts +0 -0
  87. /package/{dist → lib}/components/IngressRulesTable/index.d.ts +0 -0
  88. /package/{dist → lib}/components/InternalBaseTable/TableWidgets.d.ts +0 -0
  89. /package/{dist → lib}/components/InternalBaseTable/index.d.ts +0 -0
  90. /package/{dist → lib}/components/KeyValue/KeyValue.d.ts +0 -0
  91. /package/{dist → lib}/components/KeyValue/KeyValueAnnotation.d.ts +0 -0
  92. /package/{dist → lib}/components/KeyValue/KeyValueSecret.d.ts +0 -0
  93. /package/{dist → lib}/components/KeyValue/index.d.ts +0 -0
  94. /package/{dist → lib}/components/Layout/index.d.ts +0 -0
  95. /package/{dist → lib}/components/LinkFallback/index.d.ts +0 -0
  96. /package/{dist → lib}/components/ListPage/index.d.ts +0 -0
  97. /package/{dist → lib}/components/Menu/index.d.ts +0 -0
  98. /package/{dist → lib}/components/NamespacesFilter/index.d.ts +0 -0
  99. /package/{dist → lib}/components/NetworkPolicyRulesViewer/NetworkPolicyRulesViewer.d.ts +0 -0
  100. /package/{dist → lib}/components/NetworkPolicyRulesViewer/index.d.ts +0 -0
  101. /package/{dist → lib}/components/NodeTaintsTable/NodeTaintsTable.d.ts +0 -0
  102. /package/{dist → lib}/components/NodeTaintsTable/index.d.ts +0 -0
  103. /package/{dist → lib}/components/PVCDistributeStorage/index.d.ts +0 -0
  104. /package/{dist → lib}/components/PageShow/PageShow.d.ts +0 -0
  105. /package/{dist → lib}/components/PageShow/index.d.ts +0 -0
  106. /package/{dist → lib}/components/PodContainersTable/PodContainersTable.d.ts +0 -0
  107. /package/{dist → lib}/components/PodContainersTable/index.d.ts +0 -0
  108. /package/{dist → lib}/components/PodLog/index.d.ts +0 -0
  109. /package/{dist → lib}/components/PodSelectorTable/index.d.ts +0 -0
  110. /package/{dist → lib}/components/PortsTable/index.d.ts +0 -0
  111. /package/{dist → lib}/components/ReferenceLink/index.d.ts +0 -0
  112. /package/{dist → lib}/components/ResourceCRUD/ResourceCRUD.d.ts +0 -0
  113. /package/{dist → lib}/components/ResourceCRUD/create/index.d.ts +0 -0
  114. /package/{dist → lib}/components/ResourceCRUD/index.d.ts +0 -0
  115. /package/{dist → lib}/components/ResourceCRUD/list/index.d.ts +0 -0
  116. /package/{dist → lib}/components/ResourceCRUD/show/index.d.ts +0 -0
  117. /package/{dist → lib}/components/ResourceFiledDisplays.d.ts +0 -0
  118. /package/{dist → lib}/components/ResourceLink/index.d.ts +0 -0
  119. /package/{dist → lib}/components/ResourceSelect/index.d.ts +0 -0
  120. /package/{dist → lib}/components/ResourceTable/index.d.ts +0 -0
  121. /package/{dist → lib}/components/ResourceUsageBar/index.d.ts +0 -0
  122. /package/{dist → lib}/components/Separator/index.d.ts +0 -0
  123. /package/{dist → lib}/components/ServiceComponents/index.d.ts +0 -0
  124. /package/{dist → lib}/components/Shell/ShellToolbar.d.ts +0 -0
  125. /package/{dist → lib}/components/ShowContent/ShowContent.d.ts +0 -0
  126. /package/{dist → lib}/components/ShowContent/fields.d.ts +0 -0
  127. /package/{dist → lib}/components/ShowContent/groups.d.ts +0 -0
  128. /package/{dist → lib}/components/ShowContent/index.d.ts +0 -0
  129. /package/{dist → lib}/components/ShowContent/tabs.d.ts +0 -0
  130. /package/{dist → lib}/components/StateTag/StateTag.d.ts +0 -0
  131. /package/{dist → lib}/components/StateTag/index.d.ts +0 -0
  132. /package/{dist → lib}/components/Table/index.d.ts +0 -0
  133. /package/{dist → lib}/components/Tabs/index.d.ts +0 -0
  134. /package/{dist → lib}/components/Tags/index.d.ts +0 -0
  135. /package/{dist → lib}/components/TextTags/index.d.ts +0 -0
  136. /package/{dist → lib}/components/Time/index.d.ts +0 -0
  137. /package/{dist → lib}/components/ValueDisplay/index.d.ts +0 -0
  138. /package/{dist → lib}/components/WorkloadPodsTable/WorkloadPodsTable.d.ts +0 -0
  139. /package/{dist → lib}/components/WorkloadPodsTable/index.d.ts +0 -0
  140. /package/{dist → lib}/components/WorkloadReplicas/index.d.ts +0 -0
  141. /package/{dist → lib}/components/YamlEditor/MonacoYamlDiffEditor.d.ts +0 -0
  142. /package/{dist → lib}/components/YamlEditor/MonacoYamlEditor.d.ts +0 -0
  143. /package/{dist → lib}/components/YamlEditor/YamlEditorComponent.d.ts +0 -0
  144. /package/{dist → lib}/components/YamlEditor/index.d.ts +0 -0
  145. /package/{dist → lib}/components/YamlEditor/style.d.ts +0 -0
  146. /package/{dist → lib}/components/YamlEditor/yaml.worker.d.ts +0 -0
  147. /package/{dist → lib}/constants/auth.d.ts +0 -0
  148. /package/{dist → lib}/constants/index.d.ts +0 -0
  149. /package/{dist → lib}/constants/k8s.d.ts +0 -0
  150. /package/{dist → lib}/constants/state.d.ts +0 -0
  151. /package/{dist → lib}/contexts/component.d.ts +0 -0
  152. /package/{dist → lib}/contexts/configs.d.ts +0 -0
  153. /package/{dist → lib}/contexts/constants.d.ts +0 -0
  154. /package/{dist → lib}/contexts/global-store.d.ts +0 -0
  155. /package/{dist → lib}/contexts/index.d.ts +0 -0
  156. /package/{dist → lib}/hooks/index.d.ts +0 -0
  157. /package/{dist → lib}/hooks/useDeleteModal/index.d.ts +0 -0
  158. /package/{dist → lib}/hooks/useDeleteModal/useDeleteManyModal.d.ts +0 -0
  159. /package/{dist → lib}/hooks/useDeleteModal/useDeleteModal.d.ts +0 -0
  160. /package/{dist → lib}/hooks/useDeleteModal/useDeleteModalOnly.d.ts +0 -0
  161. /package/{dist → lib}/hooks/useDeleteModal/useFailedModal.d.ts +0 -0
  162. /package/{dist → lib}/hooks/useDownloadYAML.d.ts +0 -0
  163. /package/{dist → lib}/hooks/useEagleTable/columns.d.ts +0 -0
  164. /package/{dist → lib}/hooks/useEagleTable/index.d.ts +0 -0
  165. /package/{dist → lib}/hooks/useEagleTable/useEagleTable.d.ts +0 -0
  166. /package/{dist → lib}/hooks/useEdit.d.ts +0 -0
  167. /package/{dist → lib}/hooks/useGlobalStore.d.ts +0 -0
  168. /package/{dist → lib}/hooks/useK8sYamlEditor.d.ts +0 -0
  169. /package/{dist → lib}/hooks/useNamespaceRefineFilter.d.ts +0 -0
  170. /package/{dist → lib}/hooks/useOpenForm.d.ts +0 -0
  171. /package/{dist → lib}/hooks/usePathMap.d.ts +0 -0
  172. /package/{dist → lib}/hooks/useSchema.d.ts +0 -0
  173. /package/{dist → lib}/hooks/useSubmitForm.d.ts +0 -0
  174. /package/{dist → lib}/hooks/useTableData.d.ts +0 -0
  175. /package/{dist → lib}/i18n.d.ts +0 -0
  176. /package/{dist → lib}/index.d.ts +0 -0
  177. /package/{dist → lib}/locales/en-US/index.d.ts +0 -0
  178. /package/{dist → lib}/locales/index.d.ts +0 -0
  179. /package/{dist → lib}/locales/zh-CN/index.d.ts +0 -0
  180. /package/{dist → lib}/main.d.ts +0 -0
  181. /package/{dist → lib}/models/cronjob-model.d.ts +0 -0
  182. /package/{dist → lib}/models/daemonset-model.d.ts +0 -0
  183. /package/{dist → lib}/models/deployment-model.d.ts +0 -0
  184. /package/{dist → lib}/models/event-model.d.ts +0 -0
  185. /package/{dist → lib}/models/index.d.ts +0 -0
  186. /package/{dist → lib}/models/ingress-model.d.ts +0 -0
  187. /package/{dist → lib}/models/job-model.d.ts +0 -0
  188. /package/{dist → lib}/models/network-policy-model.d.ts +0 -0
  189. /package/{dist → lib}/models/node-model.d.ts +0 -0
  190. /package/{dist → lib}/models/persistent-volume-claim.d.ts +0 -0
  191. /package/{dist → lib}/models/persistent-volume.d.ts +0 -0
  192. /package/{dist → lib}/models/pod-metrics-model.d.ts +0 -0
  193. /package/{dist → lib}/models/pod-model.d.ts +0 -0
  194. /package/{dist → lib}/models/resource-model.d.ts +0 -0
  195. /package/{dist → lib}/models/service-model.d.ts +0 -0
  196. /package/{dist → lib}/models/statefulset-model.d.ts +0 -0
  197. /package/{dist → lib}/models/storage-class.d.ts +0 -0
  198. /package/{dist → lib}/models/types/index.d.ts +0 -0
  199. /package/{dist → lib}/models/types/metric.d.ts +0 -0
  200. /package/{dist → lib}/models/workload-base-model.d.ts +0 -0
  201. /package/{dist → lib}/models/workload-model.d.ts +0 -0
  202. /package/{dist → lib}/pages/configmaps/index.d.ts +0 -0
  203. /package/{dist → lib}/pages/cronjobs/create/index.d.ts +0 -0
  204. /package/{dist → lib}/pages/cronjobs/index.d.ts +0 -0
  205. /package/{dist → lib}/pages/cronjobs/list/index.d.ts +0 -0
  206. /package/{dist → lib}/pages/cronjobs/show/index.d.ts +0 -0
  207. /package/{dist → lib}/pages/daemonsets/create/index.d.ts +0 -0
  208. /package/{dist → lib}/pages/daemonsets/index.d.ts +0 -0
  209. /package/{dist → lib}/pages/daemonsets/list/index.d.ts +0 -0
  210. /package/{dist → lib}/pages/daemonsets/show/index.d.ts +0 -0
  211. /package/{dist → lib}/pages/deployments/index.d.ts +0 -0
  212. /package/{dist → lib}/pages/deployments/list/index.d.ts +0 -0
  213. /package/{dist → lib}/pages/deployments/show/index.d.ts +0 -0
  214. /package/{dist → lib}/pages/ingresses/index.d.ts +0 -0
  215. /package/{dist → lib}/pages/jobs/index.d.ts +0 -0
  216. /package/{dist → lib}/pages/networkPolicies/index.d.ts +0 -0
  217. /package/{dist → lib}/pages/nodes/index.d.ts +0 -0
  218. /package/{dist → lib}/pages/nodes/list/index.d.ts +0 -0
  219. /package/{dist → lib}/pages/nodes/show/index.d.ts +0 -0
  220. /package/{dist → lib}/pages/persistentvolumeclaims/index.d.ts +0 -0
  221. /package/{dist → lib}/pages/persistentvolumes/index.d.ts +0 -0
  222. /package/{dist → lib}/pages/pods/create/index.d.ts +0 -0
  223. /package/{dist → lib}/pages/pods/index.d.ts +0 -0
  224. /package/{dist → lib}/pages/pods/list/index.d.ts +0 -0
  225. /package/{dist → lib}/pages/pods/show/index.d.ts +0 -0
  226. /package/{dist → lib}/pages/secrets/index.d.ts +0 -0
  227. /package/{dist → lib}/pages/services/index.d.ts +0 -0
  228. /package/{dist → lib}/pages/statefulsets/index.d.ts +0 -0
  229. /package/{dist → lib}/pages/storageclasses/form/index.d.ts +0 -0
  230. /package/{dist → lib}/pages/storageclasses/index.d.ts +0 -0
  231. /package/{dist → lib}/plugins/index.d.ts +0 -0
  232. /package/{dist → lib}/plugins/model-plugin.d.ts +0 -0
  233. /package/{dist → lib}/plugins/relation-plugin.d.ts +0 -0
  234. /package/{dist → lib}/plugins/type.d.ts +0 -0
  235. /package/{dist → lib}/providers/index.d.ts +0 -0
  236. /package/{dist → lib}/providers/router-provider/index.d.ts +0 -0
  237. /package/{dist → lib}/styles/button.d.ts +0 -0
  238. /package/{dist → lib}/styles/modal.d.ts +0 -0
  239. /package/{dist → lib}/styles/tag.d.ts +0 -0
  240. /package/{dist → lib}/types/globalStore.d.ts +0 -0
  241. /package/{dist → lib}/types/index.d.ts +0 -0
  242. /package/{dist → lib}/utils/addId.d.ts +0 -0
  243. /package/{dist → lib}/utils/download.d.ts +0 -0
  244. /package/{dist → lib}/utils/error.d.ts +0 -0
  245. /package/{dist → lib}/utils/form.d.ts +0 -0
  246. /package/{dist → lib}/utils/k8s.d.ts +0 -0
  247. /package/{dist → lib}/utils/labels.d.ts +0 -0
  248. /package/{dist → lib}/utils/match-selector.d.ts +0 -0
  249. /package/{dist → lib}/utils/object.d.ts +0 -0
  250. /package/{dist → lib}/utils/openapi.d.ts +0 -0
  251. /package/{dist → lib}/utils/schema-store.d.ts +0 -0
  252. /package/{dist → lib}/utils/schema.d.ts +0 -0
  253. /package/{dist → lib}/utils/selector.d.ts +0 -0
  254. /package/{dist → lib}/utils/shell.d.ts +0 -0
  255. /package/{dist → lib}/utils/storage.d.ts +0 -0
  256. /package/{dist → lib}/utils/string.d.ts +0 -0
  257. /package/{dist → lib}/utils/time.d.ts +0 -0
  258. /package/{dist → lib}/utils/unit.d.ts +0 -0
  259. /package/{dist → lib}/utils/validation.d.ts +0 -0
  260. /package/{dist → lib}/utils/yaml.d.ts +0 -0
@@ -1,216 +0,0 @@
1
- import { S as SocketStatus, j as jsxRuntimeExports } from "./common-feae5742.js";
2
- import { Select, AntdOption } from "@cloudtower/eagle";
3
- import React__default, { useMemo, useRef, useState, useCallback, useEffect, useImperativeHandle } from "react";
4
- import { S as Shell } from "./index-40deb620.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__default.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
- };