phirepass-widgets 0.0.112 → 0.0.113

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 (89) hide show
  1. package/README.md +33 -0
  2. package/dist/cjs/{index-B8w6l0VL.js → index-CurErEK7.js} +101 -30
  3. package/dist/cjs/loader.cjs.js +2 -2
  4. package/dist/cjs/phirepass-downloader_3.cjs.entry.js +3696 -0
  5. package/dist/cjs/phirepass-rdp.cjs.entry.js +18 -6
  6. package/dist/cjs/phirepass-terminal.cjs.entry.js +6 -5
  7. package/dist/cjs/phirepass-widgets.cjs.js +3 -3
  8. package/dist/cjs/{protocol-COvteaUJ.js → protocol-DCBMfc2u.js} +557 -360
  9. package/dist/collection/collection-manifest.json +3 -1
  10. package/dist/collection/common/channel.js +21 -1
  11. package/dist/collection/common/fetch.js +40 -0
  12. package/dist/collection/components/phirepass-downloader/form.js +69 -0
  13. package/dist/collection/components/phirepass-downloader/format.js +105 -0
  14. package/dist/collection/components/phirepass-downloader/jobs.js +370 -0
  15. package/dist/collection/components/phirepass-downloader/phirepass-downloader.css +1109 -0
  16. package/dist/collection/components/phirepass-downloader/phirepass-downloader.js +1455 -0
  17. package/dist/collection/components/phirepass-downloader/source.js +106 -0
  18. package/dist/collection/components/phirepass-downloader/views/dialogs.js +34 -0
  19. package/dist/collection/components/phirepass-downloader/views/fetch-form.js +65 -0
  20. package/dist/collection/components/phirepass-downloader/views/icons.js +33 -0
  21. package/dist/collection/components/phirepass-downloader/views/job-row.js +91 -0
  22. package/dist/collection/components/phirepass-downloader/views/notices.js +15 -0
  23. package/dist/collection/components/phirepass-downloader/views/states.js +19 -0
  24. package/dist/collection/components/phirepass-media-player/phirepass-media-player.css +216 -0
  25. package/dist/collection/components/phirepass-media-player/phirepass-media-player.js +473 -0
  26. package/dist/collection/components/phirepass-media-player/player.js +94 -0
  27. package/dist/collection/components/phirepass-rdp/phirepass-rdp.js +36 -13
  28. package/dist/collection/components/phirepass-sftp-client/phirepass-sftp-client.css +122 -0
  29. package/dist/collection/components/phirepass-sftp-client/phirepass-sftp-client.fetch.js +35 -0
  30. package/dist/collection/components/phirepass-sftp-client/phirepass-sftp-client.js +181 -31
  31. package/dist/collection/components/phirepass-terminal/phirepass-terminal.js +2 -2
  32. package/dist/collection/phirepass-channel_bg.wasm +0 -0
  33. package/dist/collection/testing/fixtures.js +219 -0
  34. package/dist/collection/testing/mock-channel.js +410 -0
  35. package/dist/components/index.js +1 -1
  36. package/dist/components/p-C4cmk3bS.js +1 -0
  37. package/dist/components/p-CsYQJXY2.js +1 -0
  38. package/dist/components/p-D6Geq8Rn.js +1 -0
  39. package/dist/components/phirepass-downloader.d.ts +11 -0
  40. package/dist/components/phirepass-downloader.js +1 -0
  41. package/dist/components/phirepass-media-player.d.ts +11 -0
  42. package/dist/components/phirepass-media-player.js +1 -0
  43. package/dist/components/phirepass-rdp.js +1 -1
  44. package/dist/components/phirepass-sftp-client.js +1 -1
  45. package/dist/components/phirepass-terminal.js +2 -2
  46. package/dist/esm/{index-DGq2b7rM.js → index-B9qUl6FW.js} +101 -30
  47. package/dist/esm/loader.js +3 -3
  48. package/dist/esm/phirepass-downloader_3.entry.js +3692 -0
  49. package/dist/esm/phirepass-rdp.entry.js +18 -6
  50. package/dist/esm/phirepass-terminal.entry.js +6 -5
  51. package/dist/esm/phirepass-widgets.js +4 -4
  52. package/dist/esm/{protocol-Dur4cBX7.js → protocol-CsYQJXY2.js} +556 -359
  53. package/dist/phirepass-widgets/p-1b84c526.entry.js +1 -0
  54. package/dist/phirepass-widgets/{p-1fef5b5f.entry.js → p-41dd1ac9.entry.js} +2 -2
  55. package/dist/phirepass-widgets/p-614ab3de.entry.js +1 -0
  56. package/dist/phirepass-widgets/p-B9qUl6FW.js +3 -0
  57. package/dist/phirepass-widgets/p-CsYQJXY2.js +1 -0
  58. package/dist/phirepass-widgets/phirepass-channel_bg.wasm +0 -0
  59. package/dist/phirepass-widgets/phirepass-widgets.esm.js +1 -1
  60. package/dist/types/common/channel.d.ts +30 -0
  61. package/dist/types/common/fetch.d.ts +161 -0
  62. package/dist/types/components/phirepass-downloader/form.d.ts +54 -0
  63. package/dist/types/components/phirepass-downloader/format.d.ts +17 -0
  64. package/dist/types/components/phirepass-downloader/jobs.d.ts +115 -0
  65. package/dist/types/components/phirepass-downloader/phirepass-downloader.d.ts +231 -0
  66. package/dist/types/components/phirepass-downloader/source.d.ts +61 -0
  67. package/dist/types/components/phirepass-downloader/views/dialogs.d.ts +52 -0
  68. package/dist/types/components/phirepass-downloader/views/fetch-form.d.ts +31 -0
  69. package/dist/types/components/phirepass-downloader/views/icons.d.ts +5 -0
  70. package/dist/types/components/phirepass-downloader/views/job-row.d.ts +21 -0
  71. package/dist/types/components/phirepass-downloader/views/notices.d.ts +18 -0
  72. package/dist/types/components/phirepass-downloader/views/states.d.ts +38 -0
  73. package/dist/types/components/phirepass-media-player/phirepass-media-player.d.ts +67 -0
  74. package/dist/types/components/phirepass-media-player/player.d.ts +43 -0
  75. package/dist/types/components/phirepass-rdp/phirepass-rdp.d.ts +10 -0
  76. package/dist/types/components/phirepass-sftp-client/phirepass-sftp-client.d.ts +30 -0
  77. package/dist/types/components/phirepass-sftp-client/phirepass-sftp-client.fetch.d.ts +40 -0
  78. package/dist/types/components.d.ts +426 -34
  79. package/dist/types/stencil-public-runtime.d.ts +1 -1
  80. package/dist/types/testing/fixtures.d.ts +25 -0
  81. package/dist/types/testing/mock-channel.d.ts +132 -0
  82. package/package.json +26 -12
  83. package/dist/cjs/phirepass-sftp-client.cjs.entry.js +0 -1469
  84. package/dist/components/p-Dur4cBX7.js +0 -1
  85. package/dist/esm/phirepass-sftp-client.entry.js +0 -1467
  86. package/dist/phirepass-widgets/p-8eb3ec24.entry.js +0 -1
  87. package/dist/phirepass-widgets/p-9a1f9b9f.entry.js +0 -1
  88. package/dist/phirepass-widgets/p-DGq2b7rM.js +0 -3
  89. package/dist/phirepass-widgets/p-Dur4cBX7.js +0 -1
@@ -1,1469 +0,0 @@
1
- 'use strict';
2
-
3
- var index = require('./index-B8w6l0VL.js');
4
- var protocol = require('./protocol-COvteaUJ.js');
5
-
6
- const phirepassSftpClientLogoSvg = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoNDYsIDE4NCwgMTM4KSIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiCiAgICBjbGFzcz0ibHVjaWRlIGx1Y2lkZS10ZXJtaW5hbCB3LTMuNSBoLTMuNSB0ZXh0LXByaW1hcnkiPgogICAgPHBvbHlsaW5lIHBvaW50cz0iNCAxNyAxMCAxMSA0IDUiPjwvcG9seWxpbmU+CiAgICA8bGluZSB4MT0iMTIiIHgyPSIyMCIgeTE9IjE5IiB5Mj0iMTkiPjwvbGluZT4KPC9zdmc+Cg==';
7
-
8
- const phirepassSftpClientMaxSvg = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoMTE1LCAxMjMsIDE0MCkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIgogICAgY2xhc3M9Imx1Y2lkZSBsdWNpZGUtbWF4aW1pemUyIHctMyBoLTMiPgogICAgPHBvbHlsaW5lIHBvaW50cz0iMTUgMyAyMSAzIDIxIDkiPjwvcG9seWxpbmU+CiAgICA8cG9seWxpbmUgcG9pbnRzPSI5IDIxIDMgMjEgMyAxNSI+PC9wb2x5bGluZT4KICAgIDxsaW5lIHgxPSIyMSIgeDI9IjE0IiB5MT0iMyIgeTI9IjEwIj48L2xpbmU+CiAgICA8bGluZSB4MT0iMyIgeDI9IjEwIiB5MT0iMjEiIHkyPSIxNCI+PC9saW5lPgo8L3N2Zz4K';
9
-
10
- const phirepassSftpClientChevronSvg = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoMTg5LCAyMTksIDIwOSkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIgogICAgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIKICAgIGNsYXNzPSJsdWNpZGUgbHVjaWRlLWNoZXZyb24tcmlnaHQgdy0zIGgtMyB0ZXh0LW11dGVkLWZvcmVncm91bmQvNTAgc2hyaW5rLTAiPgogICAgPHBhdGggZD0ibTkgMTggNi02LTYtNiI+PC9wYXRoPgo8L3N2Zz4K';
11
-
12
- const phirepassSftpClientFolderSvg = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoNDYsIDE4NCwgMTM4KSIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiCiAgICBjbGFzcz0ibHVjaWRlIGx1Y2lkZS1mb2xkZXIgdy0zLjUgaC0zLjUgdGV4dC1wcmltYXJ5IHNocmluay0wIj4KICAgIDxwYXRoCiAgICAgICAgZD0iTTIwIDIwYTIgMiAwIDAgMCAyLTJWOGEyIDIgMCAwIDAtMi0yaC03LjlhMiAyIDAgMCAxLTEuNjktLjlMOS42IDMuOUEyIDIgMCAwIDAgNy45MyAzSDRhMiAyIDAgMCAwLTIgMnYxM2EyIDIgMCAwIDAgMiAyWiI+PC9wYXRoPgo8L3N2Zz4K';
13
-
14
- const phirepassSftpClientFileSvg = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoMTE1LCAxMjMsIDE0MCkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIgogICAgY2xhc3M9Imx1Y2lkZSBsdWNpZGUtZmlsZSB3LTMuNSBoLTMuNSB0ZXh0LW11dGVkLWZvcmVncm91bmQgc2hyaW5rLTAiPgogICAgPHBhdGggZD0iTTE1IDJINmEyIDIgMCAwIDAtMiAydjE2YTIgMiAwIDAgMCAyIDJoMTJhMiAyIDAgMCAwIDItMlY3WiI+PC9wYXRoPgogICAgPHBhdGggZD0iTTE0IDJ2NGEyIDIgMCAwIDAgMiAyaDQiPjwvcGF0aD4KPC9zdmc+Cg==';
15
-
16
- const phirepassSftpClientGoUpSvg = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoMTg5LCAyMTksIDIwOSkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIgogICAgY2xhc3M9Imx1Y2lkZSBsdWNpZGUtYXJyb3ctdXAgdy0zLjUgaC0zLjUiPgogICAgPHBhdGggZD0ibTUgMTIgNy03IDcgNyI+PC9wYXRoPgogICAgPHBhdGggZD0iTTEyIDE5VjUiPjwvcGF0aD4KPC9zdmc+Cg==';
17
-
18
- const phirepassSftpClientRefreshSvg = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoMTg5LCAyMTksIDIwOSkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIgogICAgY2xhc3M9Imx1Y2lkZSBsdWNpZGUtcmVmcmVzaC1jdyB3LTMuNSBoLTMuNSI+CiAgICA8cGF0aCBkPSJNMyAxMmE5IDkgMCAwIDEgOS05IDkuNzUgOS43NSAwIDAgMSA2Ljc0IDIuNzRMMjEgOCI+PC9wYXRoPgogICAgPHBhdGggZD0iTTIxIDN2NWgtNSI+PC9wYXRoPgogICAgPHBhdGggZD0iTTIxIDEyYTkgOSAwIDAgMS05IDkgOS43NSA5Ljc1IDAgMCAxLTYuNzQtMi43NEwzIDE2Ij48L3BhdGg+CiAgICA8cGF0aCBkPSJNOCAxNkgzdjUiPjwvcGF0aD4KPC9zdmc+Cg==';
19
-
20
- const phirepassSftpClientUploadSvg = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoMTg5LCAyMTksIDIwOSkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIgogICAgY2xhc3M9Imx1Y2lkZSBsdWNpZGUtdXBsb2FkIHctMy41IGgtMy41Ij4KICAgIDxwYXRoIGQ9Ik0yMSAxNXY0YTIgMiAwIDAgMS0yIDJINWEyIDIgMCAwIDEtMi0ydi00Ij48L3BhdGg+CiAgICA8cG9seWxpbmUgcG9pbnRzPSIxNyA4IDEyIDMgNyA4Ij48L3BvbHlsaW5lPgogICAgPGxpbmUgeDE9IjEyIiB4Mj0iMTIiIHkxPSIzIiB5Mj0iMTUiPjwvbGluZT4KPC9zdmc+Cg==';
21
-
22
- const phirepassSftpClientCss = () => `:host{--radius:0.375rem;--card:220 18% 10%;--border:220 15% 18%;--primary:160 60% 45%;--radius:0.375rem;--destructive:0 70% 50%;--muted:220 15% 13%;--muted-foreground:220 10% 50%;--primary-foreground:220 20% 7%;--scroll-track:220 16% 12%;--scroll-thumb:220 12% 34%;--scroll-thumb-hover:160 45% 44%;font-family:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, Courier New, monospace;height:100%;width:100%;border:1px solid hsl(var(--border));background-color:hsl(var(--card));border-radius:var(--radius);overflow:hidden;display:flex;flex-direction:column;position:relative;container-type:inline-size;.listing{height:100%;display:flex;flex-direction:column;justify-content:space-between;min-height:0;header{height:30px;background:rgba(28, 31, 38, 0.6);border-bottom:1px solid hsl(var(--border));display:flex;align-items:center;justify-content:space-between;.actions{display:flex;align-items:center;.action{cursor:pointer;padding:4px;display:flex;align-items:center;z-index:1;img{height:14px;padding:4px;border-radius:4px}&:hover{background-color:hsl(var(--border) / 0.6)}}}.title{color:hsl(var(--primary));height:14px;padding:0 12px;display:flex;align-items:center;font-size:0.75rem;line-height:1rem;img{height:14px;margin-right:5px}.text{display:flex;flex-direction:row;justify-content:center;margin-top:2px;.name{margin-right:10px}.description{color:hsl(var(--muted-foreground))}}}}main{flex:1;display:flex;flex-direction:column;position:relative;min-height:0;overflow:hidden;.loader{color:hsl(var(--muted-foreground));font-size:13px;animation:pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;text-align:center;display:flex;align-items:center;justify-content:center;position:absolute;height:100%;width:100%;background:rgba(28, 31, 38, 0);backdrop-filter:blur(4px)}.error{font-size:13px;text-align:center;color:hsl(var(--destructive));height:100%;display:flex;align-items:center;justify-content:center}.navigation{height:25px;padding:10px;font-size:0.75rem;line-height:1rem;background-color:hsl(var(--card));display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid hsl(var(--border));position:sticky;top:0;z-index:3;.breadcrumbs{display:flex;align-items:center;margin-right:10px;.breadcrumb-container{white-space:nowrap;.breadcrumb{color:hsl(var(--primary));margin-right:4px;cursor:pointer;&:after{margin-left:4px}&:hover{color:rgb(189, 219, 209)}&:last-child{margin-right:0;color:rgb(189, 219, 209);cursor:default}}}.arrow{height:12px;width:12px;opacity:0.6;top:2px;margin-right:4px;position:relative}}.actions{display:flex;align-items:center;gap:8px}.filter{height:1.5rem;width:110px;padding:0 6px;font:inherit;font-size:0.68rem;color:rgb(189, 219, 209);background-color:hsl(var(--muted));border:1px solid hsl(var(--border));border-radius:calc(var(--radius) - 2px);outline:none;&::placeholder{color:hsl(var(--muted-foreground))}&:focus{border-color:hsl(var(--primary))}}.action{border:none;background:transparent;color:rgb(189, 219, 209);font-size:1.1rem;line-height:1;padding:2px 4px;border-radius:4px;cursor:pointer;&:hover{background-color:hsl(var(--border) / 0.6)}img{height:14px;width:14px;display:block}}.action.disconnect{color:#ff4d5f;font-size:0.65rem;letter-spacing:0.08em;padding:4px 8px;&:hover{color:#ff6b7a;background-color:hsl(var(--destructive) / 0.12)}}}.content{flex:1;min-height:0;outline:none;overflow:auto;font-size:0.75rem;line-height:1rem;scrollbar-width:thin;scrollbar-color:hsl(var(--scroll-thumb)) hsl(var(--scroll-track));&:focus-visible{box-shadow:inset 0 0 0 1px hsl(var(--primary) / 0.5)}&::-webkit-scrollbar{width:10px;height:10px}&::-webkit-scrollbar-track{background:hsl(var(--scroll-track))}&::-webkit-scrollbar-thumb{background:hsl(var(--scroll-thumb));border-radius:999px;border:2px solid hsl(var(--scroll-track))}&::-webkit-scrollbar-thumb:hover{background:hsl(var(--scroll-thumb-hover))}table{width:100%;border-collapse:separate;border-spacing:0;table-layout:auto;thead{background-color:hsl(var(--muted));border-bottom:1px solid hsl(var(--border));th.sortable{cursor:pointer;user-select:none;&:hover{color:hsl(var(--primary))}}th{padding:8px 10px;text-align:left;color:hsl(var(--muted-foreground));position:sticky;top:0;z-index:2;background-color:hsl(var(--muted));border-bottom:1px solid hsl(var(--border));line-height:0.95rem;&.action-col{width:58px;min-width:58px;padding:0 10px}&:first-child{width:30%;min-width:180px;max-width:195px}&:nth-child(2),&:nth-child(3),&:nth-child(4),&:nth-child(5){white-space:nowrap;width:1%}}}tbody{padding:10px 10px;tr.empty{cursor:default;td{color:hsl(var(--muted-foreground));text-align:center;padding:18px 8px}&:hover{background:transparent}}tr{border-bottom:1px solid hsl(var(--border) / 0.4);td{padding:10px 10px 9px;color:hsl(var(--muted-foreground));&:first-child{min-width:180px;max-width:195px;white-space:nowrap;.name{display:inline-block;max-width:calc(100% - 26px);overflow:hidden;text-overflow:ellipsis;vertical-align:middle}}&:nth-child(2),&:nth-child(3),&:nth-child(4),&:nth-child(5){white-space:nowrap}&.action-col{width:58px;min-width:58px;text-align:center;padding-left:1px;padding-right:1px;.file-actions{display:flex;align-items:center;justify-content:center;gap:8px}.file-action{border:none;background:transparent;color:hsl(var(--muted-foreground));width:16px;height:16px;border-radius:3px;cursor:pointer;opacity:0;visibility:hidden;pointer-events:none;transition:opacity 120ms ease;padding:0;svg{width:12px;height:12px;display:block;margin:0 auto}&:hover{color:hsl(var(--primary))}&.delete:hover{color:hsl(var(--destructive))}}}.name{&.file{color:rgb(189, 219, 209)}&.folder{color:hsl(var(--primary))}}.kind{height:14px;width:14px;margin-right:5px;top:3px;position:relative}}&:hover{cursor:pointer;background-color:hsl(var(--muted) / 0.4);td.action-col .file-action{opacity:1;visibility:visible;pointer-events:auto;color:hsl(var(--primary))}}&.selected{background-color:hsl(var(--primary) / 0.3);td.action-col .file-action{opacity:1;visibility:visible;pointer-events:auto}&:hover{background-color:hsl(var(--primary) / 0.4)}}}}}}}footer{height:25px;background:rgba(28, 31, 38, 0.6);border-top:1px solid hsl(var(--border));font-size:0.75rem;line-height:1rem;display:flex;align-items:center;justify-content:space-between;padding:0 10px;.status{font-size:0.65rem;color:hsl(var(--muted-foreground));.selected-item{margin-left:10px;color:hsl(var(--primary))}}.version{font-size:0.65rem;color:hsl(var(--muted-foreground))}}}.creds{position:absolute;top:0;left:0;height:100%;width:100%;display:flex;justify-content:center;align-items:center;;&.blurred{background:rgba(28, 31, 38, 0);backdrop-filter:blur(4px)}.auth{display:flex;flex-direction:column;background:hsl(var(--card));position:relative;background-color:rgba(21, 24, 30, 0.95);border:1px solid hsl(var(--border));padding:30px;box-shadow:rgba(0, 0, 0, 0) 0px 0px 0px 0px, rgba(0, 0, 0, 0) 0px 0px 0px 0px, rgba(0, 0, 0, 0.5) 0px 25px 50px -12px;border-radius:var(--radius);.title{margin-bottom:12px;color:hsl(var(--primary))}label{font-size:0.75rem;line-height:1rem;margin-bottom:1rem;color:hsl(var(--muted-foreground))}input{font-size:0.875rem;line-height:1.25rem;padding-top:0.5rem;padding-bottom:0.5rem;padding-left:0.75rem;padding-right:0.75rem;background-color:rgb(28, 31, 38);border-color:rgb(39, 44, 53);border-width:1px;border-radius:calc(var(--radius) - 2px);width:100%;margin-bottom:12px;color:rgb(189, 219, 209);box-sizing:border-box;&:focus{outline:none;border-color:hsl(var(--primary));box-shadow:0 0 0 1px hsl(var(--primary))}}button[type='submit']{margin-top:12px;width:100%;background-color:hsl(var(--primary));color:hsl(var(--primary-foreground));letter-spacing:0.05em;font-size:13px;font-weight:500;padding:0.5rem 1rem;border-radius:calc(var(--radius) - 2px);height:2rem;cursor:pointer;border:none;&:hover{background-color:hsl(var(--primary) / 0.9)}}}}.upload-modal,.download-modal,.delete-modal,.prompt-modal{position:absolute;inset:0;display:none;align-items:center;justify-content:center;background:rgba(28, 31, 38, 0);backdrop-filter:blur(4px);z-index:6;&.visible{display:flex}.upload-dialog,.download-dialog,.delete-dialog,.prompt-dialog{width:min(360px, calc(100% - 24px));background-color:rgba(21, 24, 30, 0.96);border:1px solid hsl(var(--border));border-radius:var(--radius);padding:16px;box-shadow:rgba(0, 0, 0, 0) 0px 0px 0px 0px, rgba(0, 0, 0, 0) 0px 0px 0px 0px, rgba(0, 0, 0, 0.5) 0px 25px 50px -12px;.title{color:hsl(var(--primary));font-size:0.8rem;margin-bottom:8px}.file-name{color:rgb(189, 219, 209);font-size:0.72rem;line-height:1rem;margin-bottom:10px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.progress-track{width:100%;height:10px;border-radius:999px;background-color:hsl(var(--muted));overflow:hidden;border:1px solid hsl(var(--border));.progress-fill{height:100%;width:0;background:linear-gradient(90deg, hsl(var(--primary) / 0.7), hsl(var(--primary)));transition:width 140ms ease}}.progress-meta{margin-top:8px;margin-bottom:12px;display:flex;align-items:center;justify-content:space-between;gap:10px}.progress-speed{color:hsl(var(--muted-foreground));font-size:0.75rem;font-variant-numeric:tabular-nums;line-height:1.4;text-align:left}.progress-value{color:hsl(var(--muted-foreground));font-size:0.75rem;font-variant-numeric:tabular-nums;line-height:1.4;text-align:right}.cancel{margin-top:14px;width:100%;height:2rem;border:1px solid hsl(var(--border));border-radius:calc(var(--radius) - 2px);background:hsl(var(--muted));color:rgb(189, 219, 209);font-size:0.75rem;letter-spacing:0.03em;cursor:pointer;&:hover{border-color:hsl(var(--primary));color:hsl(var(--primary))}&.finished{background-color:hsl(var(--primary));border-color:hsl(var(--primary));color:hsl(var(--primary-foreground));&:hover{background-color:hsl(var(--primary) / 0.9);border-color:hsl(var(--primary) / 0.9);color:hsl(var(--primary-foreground))}}}.message{color:rgb(189, 219, 209);font-size:0.74rem;line-height:1rem;margin-bottom:8px}.modal-actions{margin-top:14px;display:grid;grid-template-columns:1fr 1fr;gap:8px;.btn{height:2rem;border:1px solid hsl(var(--border));border-radius:calc(var(--radius) - 2px);font-size:0.75rem;letter-spacing:0.03em;cursor:pointer;&:disabled{opacity:0.65;cursor:not-allowed}}.btn.secondary{background:hsl(var(--muted));color:rgb(189, 219, 209);&:hover{border-color:hsl(var(--primary));color:hsl(var(--primary))}}.btn.destructive{background:hsl(var(--destructive));border-color:hsl(var(--destructive));color:white;&:hover{background:hsl(var(--destructive) / 0.9);border-color:hsl(var(--destructive) / 0.9)}}}.dialog-input{width:100%;box-sizing:border-box;height:2rem;padding:0 8px;font:inherit;font-size:0.75rem;color:rgb(189, 219, 209);background-color:hsl(var(--muted));border:1px solid hsl(var(--border));border-radius:calc(var(--radius) - 2px);outline:none;&:focus{border-color:hsl(var(--primary))}&:disabled{opacity:0.65}}.dialog-error{margin-top:8px;font-size:0.7rem;line-height:0.95rem;color:#ff6b7a}.hint{margin-top:4px;font-size:0.66rem;line-height:0.9rem;color:hsl(var(--muted-foreground))}.checkline{margin-top:8px;display:flex;align-items:center;gap:6px;font-size:0.72rem;color:rgb(189, 219, 209);cursor:pointer;input{accent-color:hsl(var(--primary));margin:0}}.perm-grid{margin-top:10px;width:100%;border-collapse:collapse;font-size:0.68rem;th{color:hsl(var(--muted-foreground));font-weight:normal;text-align:center;padding:2px 0}th[scope='row']{text-align:left;color:rgb(189, 219, 209)}td{text-align:center;padding:2px 0}input{accent-color:hsl(var(--primary));margin:0}}.perm-special{margin-top:4px;display:flex;gap:12px;.checkline{margin-top:4px;font-size:0.66rem}}.perm-octal{margin-top:10px;display:flex;align-items:center;gap:8px;label{font-size:0.68rem;color:hsl(var(--muted-foreground))}.dialog-input{width:4.5rem;text-align:center;letter-spacing:0.1em}.perm-preview{font-size:0.7rem;color:hsl(var(--primary))}}.modal-actions .btn.primary{background:hsl(var(--primary));border-color:hsl(var(--primary));color:hsl(var(--primary-foreground));&:hover:not(:disabled){background:hsl(var(--primary) / 0.9);border-color:hsl(var(--primary) / 0.9)}}.delete-loader{margin-top:4px;display:flex;justify-content:center;.spinner{width:16px;height:16px;border:2px solid hsl(var(--muted-foreground) / 0.35);border-top-color:hsl(var(--primary));border-radius:50%;animation:spin 0.7s linear infinite}}}}.editor-modal{position:absolute;inset:0;display:none;align-items:center;justify-content:center;background:rgba(28, 31, 38, 0);backdrop-filter:blur(4px);z-index:7;&.visible{display:flex}.editor-dialog{width:min(860px, calc(100% - 24px));height:min(620px, calc(100% - 24px));display:flex;flex-direction:column;background-color:rgba(21, 24, 30, 0.98);border:1px solid hsl(var(--border));border-radius:var(--radius);padding:16px;box-shadow:rgba(0, 0, 0, 0.5) 0px 25px 50px -12px;outline:none;.editor-head{display:flex;align-items:center;justify-content:space-between;gap:8px;.title{color:hsl(var(--primary));font-size:0.8rem;margin-bottom:8px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.editor-close{border:none;background:transparent;color:hsl(var(--muted-foreground));font-size:0.85rem;line-height:1;padding:2px 6px;border-radius:4px;cursor:pointer;&:hover:not(:disabled){color:hsl(var(--primary));background-color:hsl(var(--border) / 0.6)}&:disabled{opacity:0.5;cursor:not-allowed}}}.editor-loading{flex:1;display:flex;align-items:center;justify-content:center;font-size:0.75rem;color:hsl(var(--muted-foreground))}.editor-text{flex:1;min-height:0;width:100%;box-sizing:border-box;resize:none;padding:10px;font:inherit;font-size:0.75rem;line-height:1.15rem;tab-size:4;white-space:pre;overflow:auto;color:rgb(189, 219, 209);background-color:hsl(var(--muted));border:1px solid hsl(var(--border));border-radius:calc(var(--radius) - 2px);outline:none;&:focus{border-color:hsl(var(--primary) / 0.6)}&:disabled{opacity:0.65}}.dialog-error{margin-top:8px;font-size:0.7rem;line-height:0.95rem;color:#ff6b7a}.modal-actions{margin-top:14px;display:flex;justify-content:flex-end;gap:8px;.btn{height:2rem;min-width:6rem;border:1px solid hsl(var(--border));border-radius:calc(var(--radius) - 2px);font-size:0.75rem;letter-spacing:0.03em;cursor:pointer;&:disabled{opacity:0.65;cursor:not-allowed}}.btn.secondary{background:hsl(var(--muted));color:rgb(189, 219, 209);&:hover:not(:disabled){border-color:hsl(var(--primary));color:hsl(var(--primary))}}.btn.destructive{background:hsl(var(--destructive));border-color:hsl(var(--destructive));color:white}.btn.primary{background:hsl(var(--primary));border-color:hsl(var(--primary));color:hsl(var(--primary-foreground));&:hover:not(:disabled){background:hsl(var(--primary) / 0.9);border-color:hsl(var(--primary) / 0.9)}}}}}}@keyframes spin{to{transform:rotate(360deg)}}:host(.max){height:100vh;width:100vw;position:fixed;top:0;left:0;z-index:9999}@container (max-width: 699px){:host .listing main .content table thead th:nth-child(4),:host .listing main .content table tbody td:nth-child(4){display:none}}@container (max-width: 635px){:host .listing main .content table thead th:nth-child(3),:host .listing main .content table tbody td:nth-child(3){display:none}}@container (max-width: 530px){:host .listing main .content table thead th:nth-child(5),:host .listing main .content table tbody td:nth-child(5){display:none}:host .listing footer .status{display:none}}@container (max-width: 370px){:host .listing main .content table thead th:nth-child(2),:host .listing main .content table tbody td:nth-child(2){display:none}:host .listing main .content table thead th:first-child,:host .listing main .content table tbody td:first-child{width:100%;min-width:0;max-width:none}:host .listing main .content table tbody td:first-child .name{max-width:100%}}@container (max-width: 295px){:host .listing main .content table tbody td:first-child .name{max-width:120px}}@container (max-width: 635px){:host .listing main .content table tbody tr td.action-col .file-action{opacity:1;visibility:visible;pointer-events:auto;width:36px;height:36px;border-radius:8px}:host .listing main .content table tbody tr td.action-col .file-action svg{width:17px;height:17px}:host .listing main .content table thead th.action-col,:host .listing main .content table tbody td.action-col{width:92px;min-width:92px}:host .listing main .content table tbody td.action-col .file-actions{gap:4px}:host .listing main .content table tbody tr:hover{background-color:transparent}:host .listing main .content table tbody tr.selected:hover{background-color:hsl(var(--primary) / 0.3)}:host .listing main .content table tbody td{padding:13px 10px 12px}:host .listing main .content table thead th{padding:12px 10px}:host .listing main .navigation{height:auto;min-height:44px;padding:6px 8px}:host .listing main .navigation .action{padding:10px;border-radius:8px}:host .listing main .navigation .action img{height:17px;width:17px}:host .listing main .navigation .action.disconnect{padding:10px 12px}:host .listing main .navigation .filter{height:2.25rem;font-size:16px;width:8rem}:host .listing header .actions .action{padding:8px}:host .listing header .actions .action img{height:17px}:host .modal .upload-dialog .cancel,:host .modal .download-dialog .cancel,:host .modal .delete-dialog .cancel,:host .modal .prompt-dialog .cancel,:host .modal .upload-dialog .modal-actions .btn,:host .modal .download-dialog .modal-actions .btn,:host .modal .delete-dialog .modal-actions .btn,:host .modal .prompt-dialog .modal-actions .btn{height:2.75rem}:host .modal .prompt-dialog .dialog-input,:host .auth input{height:2.5rem;font-size:16px}:host .modal .prompt-dialog .perm-grid input,:host .modal .prompt-dialog .perm-special input{width:20px;height:20px}:host .modal .prompt-dialog .perm-grid td,:host .modal .prompt-dialog .perm-grid th{padding:7px 0}}`;
23
-
24
- const PhirepassSftpClient = class {
25
- constructor(hostRef) {
26
- index.registerInstance(this, hostRef);
27
- this.maximizeEvent = index.createEvent(this, "maximize");
28
- this.connectionStateChanged = index.createEvent(this, "connectionStateChanged");
29
- }
30
- channel;
31
- domReady = false;
32
- runtimeReady = false;
33
- connected = false;
34
- uploadInputEl;
35
- msgId = 1;
36
- activeUploadToken = 0;
37
- pendingUploadStarts = new Map();
38
- pendingUploadAcks = new Map();
39
- pendingDownloadStarts = new Map();
40
- activeDownloads = new Map();
41
- activeDownloadMsgId;
42
- pendingOps = new Map();
43
- promptInputEl;
44
- editorPath = '';
45
- editorTextEl;
46
- // private inputMode: InputMode = InputMode.Default;
47
- session_id;
48
- // private usernameBuffer = "";
49
- // private passwordBuffer = "";
50
- name = 'SFTP';
51
- description = 'Client';
52
- hideHeader = false;
53
- serverHost = "phirepass.com";
54
- serverPort = 443;
55
- allowInsecure = false;
56
- heartbeatInterval = 30_000;
57
- nodeId;
58
- serviceId;
59
- token;
60
- onNodeIdChange(newValue, _oldValue) {
61
- // Handle the change in node_id here
62
- // console.log(`node_id changed from ${oldValue} to ${newValue}`);
63
- // Always clear local session state and reset terminal view
64
- this.reset_session_state();
65
- // this.terminal.reset();
66
- // Close existing comms if connected
67
- if (this.channel && this.channel.is_connected()) {
68
- this.close_comms();
69
- }
70
- // Open new comms for the updated node
71
- if (newValue) {
72
- this.open_comms();
73
- this.channel.connect();
74
- this.status = 'Connecting...';
75
- }
76
- }
77
- serverId;
78
- /**
79
- * Supplies the channel instead of a WebSocket to the server — for demos,
80
- * screenshots and tests. A property only (a function cannot be an
81
- * attribute); read once, when the widget connects. See `ChannelFactory`.
82
- */
83
- channelFactory;
84
- onServerIdChange(_newValue, _oldValue) {
85
- this.onNodeIdChange(this.nodeId, this.nodeId);
86
- }
87
- maximizeEvent;
88
- async maximize() {
89
- this.max = !this.max;
90
- }
91
- async minimize() {
92
- this.max = false;
93
- }
94
- connectionStateChanged;
95
- max = false;
96
- show_login_screen = false;
97
- show_login_screen_username = false;
98
- show_error = false;
99
- error_message = '';
100
- show_login_screen_password = false;
101
- show_navigation = false;
102
- breadcrumbs = [];
103
- current_dir = '.';
104
- listing = [];
105
- show_content = false;
106
- show_loader = false;
107
- version = '';
108
- status = 'Disconnected';
109
- selected_item = null;
110
- show_upload_modal = false;
111
- upload_progress = 0;
112
- upload_file_name = '';
113
- upload_speed = '--';
114
- upload_finished = false;
115
- show_download_modal = false;
116
- download_progress = 0;
117
- download_file_name = '';
118
- download_speed = '--';
119
- download_finished = false;
120
- show_delete_modal = false;
121
- delete_file_name = '';
122
- delete_loading = false;
123
- delete_is_dir = false;
124
- delete_recursive = false;
125
- delete_error = '';
126
- /** `mkdir` and `rename` share one dialog: both take a single name. */
127
- prompt_kind = null;
128
- prompt_value = '';
129
- prompt_error = '';
130
- prompt_busy = false;
131
- chmod_target = null;
132
- /** Permission bits under edit, masked to 0o7777. */
133
- chmod_mode = 0;
134
- chmod_error = '';
135
- chmod_busy = false;
136
- show_editor = false;
137
- editor_name = '';
138
- editor_text = '';
139
- /** What is on the remote, so the dialog knows whether it has edits. */
140
- editor_saved_text = '';
141
- editor_busy = '';
142
- editor_error = '';
143
- editor_confirm_discard = false;
144
- /** False until the file's contents are in hand, so a failed open is read-only. */
145
- editor_loaded = false;
146
- filter = '';
147
- sort_key = 'name';
148
- sort_asc = true;
149
- toggle_max() {
150
- this.maximizeEvent?.emit(!this.max);
151
- }
152
- async connectedCallback() {
153
- if (!this.channelFactory) {
154
- await protocol.__wbg_init();
155
- }
156
- // this.setup_terminal();
157
- this.open_comms();
158
- this.runtimeReady = true;
159
- if (!this.nodeId) {
160
- console.warn('Prop node_id is not set. Cannot connect to terminal.');
161
- return;
162
- }
163
- this.try_connect();
164
- }
165
- componentDidLoad() {
166
- this.domReady = true;
167
- this.try_connect();
168
- }
169
- async disconnectedCallback() {
170
- // if (this.resizeDebounceHandle) {
171
- // clearTimeout(this.resizeDebounceHandle);
172
- // this.resizeDebounceHandle = undefined;
173
- // }
174
- //
175
- // if (this.resizeObserver) {
176
- // this.resizeObserver.disconnect();
177
- // }
178
- this.connected = false;
179
- this.domReady = false;
180
- this.runtimeReady = false;
181
- this.cancel_active_upload();
182
- this.cancel_active_download();
183
- this.clear_pending_operations();
184
- this.close_comms();
185
- // this.destroy_terminal();
186
- }
187
- next_msg_id() {
188
- const id = this.msgId;
189
- this.msgId += 1;
190
- return id;
191
- }
192
- clear_pending_operations() {
193
- this.pendingUploadStarts.forEach((pending) => {
194
- window.clearTimeout(pending.timeout);
195
- pending.reject(new Error('Upload start aborted'));
196
- });
197
- this.pendingUploadStarts.clear();
198
- this.pendingUploadAcks.forEach((pending) => {
199
- window.clearTimeout(pending.timeout);
200
- pending.reject(new Error('Upload chunk aborted'));
201
- });
202
- this.pendingUploadAcks.clear();
203
- this.pendingDownloadStarts.forEach((pending) => {
204
- window.clearTimeout(pending.timeout);
205
- pending.reject(new Error('Download start aborted'));
206
- });
207
- this.pendingDownloadStarts.clear();
208
- this.pendingOps.forEach((pending) => {
209
- window.clearTimeout(pending.timeout);
210
- pending.reject(new Error(`Could not ${pending.verb}: the session ended.`));
211
- });
212
- this.pendingOps.clear();
213
- this.activeDownloads.clear();
214
- }
215
- cancel_active_upload() {
216
- this.activeUploadToken += 1;
217
- this.upload_progress = 0;
218
- this.upload_finished = false;
219
- this.upload_speed = '--';
220
- }
221
- cancel_active_download() {
222
- if (this.activeDownloadMsgId !== undefined) {
223
- this.activeDownloads.delete(this.activeDownloadMsgId);
224
- }
225
- this.activeDownloadMsgId = undefined;
226
- this.download_progress = 0;
227
- this.download_finished = false;
228
- this.download_speed = '--';
229
- }
230
- format_duration(seconds) {
231
- if (!Number.isFinite(seconds) || seconds < 0) {
232
- return '--';
233
- }
234
- if (seconds < 60) {
235
- return `${seconds.toFixed(0)}s`;
236
- }
237
- const minutes = Math.floor(seconds / 60);
238
- const remainderSeconds = Math.floor(seconds % 60);
239
- if (minutes < 60) {
240
- return `${minutes}m ${remainderSeconds}s`;
241
- }
242
- const hours = Math.floor(minutes / 60);
243
- const remainderMinutes = minutes % 60;
244
- return `${hours}h ${remainderMinutes}m`;
245
- }
246
- format_percent(value) {
247
- const safe = Number.isFinite(value) ? value : 0;
248
- return `${safe.toFixed(2)}%`;
249
- }
250
- format_transfer_rate(bytesPerSecond) {
251
- if (!Number.isFinite(bytesPerSecond) || bytesPerSecond <= 0) {
252
- return '--';
253
- }
254
- return `${this.format_size(bytesPerSecond)}/s`;
255
- }
256
- update_upload_progress(uploadedBytes, totalBytes, startTime) {
257
- const progress = totalBytes > 0 ? (uploadedBytes / totalBytes) * 100 : 0;
258
- this.upload_progress = Math.max(0, Math.min(100, progress));
259
- if (uploadedBytes >= totalBytes) {
260
- this.upload_finished = true;
261
- this.upload_speed = '--';
262
- return;
263
- }
264
- const elapsedSeconds = (performance.now() - startTime) / 1000;
265
- const speed = elapsedSeconds > 0 ? uploadedBytes / elapsedSeconds : 0;
266
- this.upload_speed = this.format_transfer_rate(speed);
267
- const remaining = totalBytes - uploadedBytes;
268
- const eta = speed > 0 ? remaining / speed : NaN;
269
- this.status = `Uploading ${this.format_size(uploadedBytes)} / ${this.format_size(totalBytes)} (ETA ${this.format_duration(eta)})`;
270
- }
271
- update_download_progress(receivedBytes, totalBytes, startTime) {
272
- const progress = totalBytes > 0 ? (receivedBytes / totalBytes) * 100 : 0;
273
- this.download_progress = Math.max(0, Math.min(100, progress));
274
- if (receivedBytes >= totalBytes) {
275
- this.download_finished = true;
276
- this.download_speed = '--';
277
- return;
278
- }
279
- const elapsedSeconds = (Date.now() - startTime) / 1000;
280
- const speed = elapsedSeconds > 0 ? receivedBytes / elapsedSeconds : 0;
281
- this.download_speed = this.format_transfer_rate(speed);
282
- const remaining = totalBytes - receivedBytes;
283
- const eta = speed > 0 ? remaining / speed : NaN;
284
- this.status = `Downloading ${this.format_size(receivedBytes)} / ${this.format_size(totalBytes)} (ETA ${this.format_duration(eta)})`;
285
- }
286
- connect() {
287
- this.connected = true;
288
- this.channel.connect();
289
- this.status = 'Connecting...';
290
- // const container = this.containerEl;
291
- // console.log('Attempting to connect terminal to container:', container);
292
- // if (container) {
293
- // this.terminal.open(container);
294
- // console.log('Terminal opened in container');
295
- // this.connected = true;
296
- // this.fit_terminal_safely();
297
- // this.terminal.focus();
298
- // this.terminal.onData(this.handle_terminal_data.bind(this));
299
- // this.channel.connect();
300
- // this.setup_resize_observer();
301
- // console.log('Terminal connected and ready');
302
- // }
303
- }
304
- try_connect() {
305
- if (this.connected || !this.domReady || !this.runtimeReady) {
306
- return;
307
- }
308
- if (!this.channel) {
309
- return;
310
- }
311
- this.connect();
312
- }
313
- create_web_socket_endpoint() {
314
- const protocol = this.allowInsecure ? 'ws' : 'wss';
315
- if (!this.allowInsecure && this.serverPort === 443) {
316
- return `${protocol}://${this.serverHost}`;
317
- }
318
- if (this.allowInsecure && this.serverPort === 80) {
319
- return `${protocol}://${this.serverHost}`;
320
- }
321
- return `${protocol}://${this.serverHost}:${this.serverPort}`;
322
- }
323
- handle_error(error) {
324
- if (error.msg_id !== undefined) {
325
- const pendingUploadStart = this.pendingUploadStarts.get(error.msg_id);
326
- if (pendingUploadStart) {
327
- window.clearTimeout(pendingUploadStart.timeout);
328
- pendingUploadStart.reject(new Error(error.message || 'Upload start failed'));
329
- this.pendingUploadStarts.delete(error.msg_id);
330
- }
331
- const pendingDownloadStart = this.pendingDownloadStarts.get(error.msg_id);
332
- if (pendingDownloadStart) {
333
- window.clearTimeout(pendingDownloadStart.timeout);
334
- pendingDownloadStart.reject(new Error(error.message || 'Download start failed'));
335
- this.pendingDownloadStarts.delete(error.msg_id);
336
- }
337
- if (this.activeDownloads.has(error.msg_id)) {
338
- this.activeDownloads.delete(error.msg_id);
339
- if (this.activeDownloadMsgId === error.msg_id) {
340
- this.activeDownloadMsgId = undefined;
341
- }
342
- this.download_finished = false;
343
- }
344
- const pendingOp = this.pendingOps.get(error.msg_id);
345
- if (pendingOp) {
346
- window.clearTimeout(pendingOp.timeout);
347
- this.pendingOps.delete(error.msg_id);
348
- pendingOp.reject(new Error(error.message || `Could not ${pendingOp.verb}.`));
349
- // The caller puts this message in the dialog the user is
350
- // looking at. Raising the page-level banner as well would say
351
- // the same thing twice, in the place they are not looking.
352
- this.show_loader = false;
353
- return;
354
- }
355
- }
356
- switch (error.kind) {
357
- case protocol.ErrorType.Generic:
358
- case protocol.ErrorType.Authentication:
359
- this.error_message = error.message || 'An unknown error occurred.';
360
- this.show_error = true;
361
- break;
362
- case protocol.ErrorType.RequiresUsername:
363
- this.show_login_screen_username = true;
364
- this.show_login_screen_password = false;
365
- this.show_login_screen = true;
366
- break;
367
- case protocol.ErrorType.RequiresPassword:
368
- this.show_login_screen_username = false;
369
- this.show_login_screen_password = true;
370
- this.show_login_screen = true;
371
- break;
372
- case protocol.ErrorType.RequiresUsernamePassword:
373
- this.show_login_screen_username = true;
374
- this.show_login_screen_password = true;
375
- this.show_login_screen = true;
376
- break;
377
- }
378
- setTimeout(() => {
379
- this.show_loader = false;
380
- }, 1_000);
381
- }
382
- handle_auth_success(auth) {
383
- this.clear_creds_buffer();
384
- this.version = auth.version;
385
- this.channel.start_heartbeat(this.heartbeatInterval <= 15_000 ? 30_000 : this.heartbeatInterval);
386
- this.channel.open_sftp_tunnel(this.nodeId, this.serviceId);
387
- this.status = 'Connected';
388
- }
389
- handle_tunnel_opened(web) {
390
- this.session_id = web.sid;
391
- // this.terminal.reset();
392
- // this.fit_terminal_safely();
393
- // this.send_ssh_terminal_resize();
394
- this.channel.send_sftp_list_data(this.nodeId, this.session_id, this.current_dir);
395
- }
396
- handle_sftp_list_items(web) {
397
- setTimeout(() => {
398
- this.show_loader = false;
399
- }, 500);
400
- // A filter is about the directory you typed it in; carrying it into
401
- // the next one hides most of what you just navigated to.
402
- if (web.path !== this.current_dir) {
403
- this.filter = '';
404
- }
405
- this.listing = web.dir.items;
406
- this.current_dir = web.path;
407
- this.breadcrumbs = web.path.split('/').map((path, index, arr) => {
408
- if (path === '' && index === 0) {
409
- return { label: '/', path: '/' };
410
- }
411
- return { label: path, path: arr.slice(0, index + 1).join('/') };
412
- });
413
- this.show_content = true;
414
- this.show_navigation = true;
415
- console.log('Received SFTP list items:', web);
416
- }
417
- handle_upload_start_response(web) {
418
- if (web.msg_id === undefined) {
419
- return;
420
- }
421
- const pending = this.pendingUploadStarts.get(web.msg_id);
422
- if (!pending) {
423
- return;
424
- }
425
- window.clearTimeout(pending.timeout);
426
- pending.resolve(web.response.upload_id);
427
- this.pendingUploadStarts.delete(web.msg_id);
428
- }
429
- handle_upload_chunk_ack(web) {
430
- const key = `${web.upload_id}_${web.chunk_index}`;
431
- const pending = this.pendingUploadAcks.get(key);
432
- if (!pending) {
433
- return;
434
- }
435
- window.clearTimeout(pending.timeout);
436
- pending.resolve();
437
- this.pendingUploadAcks.delete(key);
438
- }
439
- handle_download_start_response(web) {
440
- if (web.msg_id === undefined) {
441
- return;
442
- }
443
- const pending = this.pendingDownloadStarts.get(web.msg_id);
444
- if (!pending) {
445
- return;
446
- }
447
- window.clearTimeout(pending.timeout);
448
- pending.resolve({
449
- download_id: web.response.download_id,
450
- total_size: web.response.total_size,
451
- total_chunks: web.response.total_chunks,
452
- });
453
- this.pendingDownloadStarts.delete(web.msg_id);
454
- }
455
- finalize_download(msgId) {
456
- const download = this.activeDownloads.get(msgId);
457
- if (!download) {
458
- return;
459
- }
460
- const sortedChunks = Array.from(download.chunks.entries())
461
- .sort((a, b) => a[0] - b[0])
462
- .map(([, data]) => data);
463
- // Normalize to fresh ArrayBuffer-backed views for BlobPart compatibility.
464
- const blobParts = sortedChunks.map((chunk) => new Uint8Array(chunk));
465
- const blob = new Blob(blobParts, { type: 'application/octet-stream' });
466
- const objectUrl = URL.createObjectURL(blob);
467
- const anchor = document.createElement('a');
468
- anchor.href = objectUrl;
469
- anchor.download = download.filename;
470
- document.body.appendChild(anchor);
471
- anchor.click();
472
- document.body.removeChild(anchor);
473
- URL.revokeObjectURL(objectUrl);
474
- this.activeDownloads.delete(msgId);
475
- if (this.activeDownloadMsgId === msgId) {
476
- this.activeDownloadMsgId = undefined;
477
- }
478
- this.download_finished = true;
479
- this.status = 'Connected';
480
- }
481
- handle_download_chunk(web) {
482
- if (web.msg_id === undefined) {
483
- return;
484
- }
485
- const download = this.activeDownloads.get(web.msg_id);
486
- if (!download || !this.session_id) {
487
- return;
488
- }
489
- const chunkData = new Uint8Array(web.chunk.data);
490
- download.chunks.set(web.chunk.chunk_index, chunkData);
491
- const receivedBytes = Array.from(download.chunks.values()).reduce((sum, data) => sum + data.length, 0);
492
- this.update_download_progress(receivedBytes, download.total_size, download.startTime);
493
- // Pipeline ACK: advance the agent's sliding window so it can push the next
494
- // batch of chunks without waiting for an explicit per-chunk request.
495
- this.channel.send_sftp_download_ack(this.nodeId, this.session_id, download.download_id, web.chunk.chunk_index);
496
- if (download.chunks.size >= download.total_chunks) {
497
- this.finalize_download(web.msg_id);
498
- }
499
- }
500
- async start_download(item) {
501
- if (!this.session_id) {
502
- return;
503
- }
504
- this.selected_item = item;
505
- this.download_file_name = item.name;
506
- this.download_progress = 0;
507
- this.download_finished = false;
508
- this.download_speed = '--';
509
- this.show_download_modal = true;
510
- this.show_error = false;
511
- const msgId = this.next_msg_id();
512
- this.activeDownloadMsgId = msgId;
513
- this.activeDownloads.set(msgId, {
514
- filename: item.name,
515
- chunks: new Map(),
516
- total_chunks: 0,
517
- total_size: 0,
518
- download_id: 0,
519
- startTime: Date.now(),
520
- });
521
- const downloadStart = new Promise((resolve, reject) => {
522
- const timeout = window.setTimeout(() => {
523
- this.pendingDownloadStarts.delete(msgId);
524
- reject(new Error('Download start timeout'));
525
- }, 10_000);
526
- this.pendingDownloadStarts.set(msgId, {
527
- timeout,
528
- resolve,
529
- reject,
530
- });
531
- });
532
- try {
533
- this.channel.send_sftp_download_start(this.nodeId, this.session_id, item.path, item.name, msgId);
534
- const { download_id, total_chunks, total_size } = await downloadStart;
535
- const download = this.activeDownloads.get(msgId);
536
- if (!download) {
537
- return;
538
- }
539
- download.download_id = download_id;
540
- download.total_chunks = total_chunks;
541
- download.total_size = total_size;
542
- // Pipelined: agent pushes chunks immediately after SFTPDownloadStartResponse;
543
- // no explicit per-chunk request is needed to start the flow.
544
- }
545
- catch (err) {
546
- this.activeDownloads.delete(msgId);
547
- if (this.activeDownloadMsgId === msgId) {
548
- this.activeDownloadMsgId = undefined;
549
- }
550
- this.show_error = true;
551
- this.error_message = err instanceof Error ? err.message : 'Failed to start download';
552
- this.cancel_download();
553
- }
554
- }
555
- async upload_file(fileToUpload) {
556
- if (!this.session_id) {
557
- return;
558
- }
559
- const uploadToken = this.activeUploadToken + 1;
560
- this.activeUploadToken = uploadToken;
561
- this.upload_file_name = fileToUpload.name;
562
- this.upload_progress = 0;
563
- this.upload_finished = false;
564
- this.upload_speed = '--';
565
- this.show_upload_modal = true;
566
- this.show_error = false;
567
- this.status = 'Uploading...';
568
- const chunkSize = 64 * 1024;
569
- const totalChunks = Math.max(1, Math.ceil(fileToUpload.size / chunkSize));
570
- const msgId = this.next_msg_id();
571
- const uploadStart = new Promise((resolve, reject) => {
572
- const timeout = window.setTimeout(() => {
573
- this.pendingUploadStarts.delete(msgId);
574
- reject(new Error('Upload start timeout'));
575
- }, 10_000);
576
- this.pendingUploadStarts.set(msgId, {
577
- timeout,
578
- resolve,
579
- reject,
580
- });
581
- });
582
- try {
583
- this.channel.send_sftp_upload_start(this.nodeId, this.session_id, fileToUpload.name, this.current_dir, totalChunks, BigInt(fileToUpload.size), msgId);
584
- const uploadId = await uploadStart;
585
- let uploadedBytes = 0;
586
- const startedAt = performance.now();
587
- for (let chunkIndex = 0; chunkIndex < totalChunks; chunkIndex += 1) {
588
- if (uploadToken !== this.activeUploadToken) {
589
- throw new Error('Upload cancelled');
590
- }
591
- const start = chunkIndex * chunkSize;
592
- const end = Math.min(start + chunkSize, fileToUpload.size);
593
- const chunkBuffer = new Uint8Array(await fileToUpload.slice(start, end).arrayBuffer());
594
- await new Promise((resolve, reject) => {
595
- const key = `${uploadId}_${chunkIndex}`;
596
- const timeout = window.setTimeout(() => {
597
- this.pendingUploadAcks.delete(key);
598
- reject(new Error(`Upload chunk ${chunkIndex + 1} timed out`));
599
- }, 30_000);
600
- this.pendingUploadAcks.set(key, {
601
- timeout,
602
- resolve,
603
- reject,
604
- });
605
- this.channel.send_sftp_upload_chunk(this.nodeId, this.session_id, uploadId, chunkIndex, chunkBuffer.length, chunkBuffer, null);
606
- });
607
- uploadedBytes += chunkBuffer.length;
608
- this.update_upload_progress(uploadedBytes, fileToUpload.size, startedAt);
609
- }
610
- this.upload_progress = 100;
611
- this.upload_finished = true;
612
- this.status = 'Connected';
613
- this.refresh_directory();
614
- }
615
- catch (err) {
616
- if (err.message !== 'Upload cancelled') {
617
- this.show_error = true;
618
- this.error_message = err instanceof Error ? err.message : 'Upload failed';
619
- }
620
- this.upload_finished = false;
621
- this.status = 'Connected';
622
- }
623
- }
624
- handle_op_result(web) {
625
- if (web.msg_id === undefined) {
626
- return;
627
- }
628
- const pending = this.pendingOps.get(web.msg_id);
629
- if (!pending) {
630
- return;
631
- }
632
- window.clearTimeout(pending.timeout);
633
- this.pendingOps.delete(web.msg_id);
634
- pending.resolve(web.result);
635
- }
636
- /**
637
- * Send one filesystem operation and wait for its single answer.
638
- *
639
- * There are three outcomes: an `SFTPOpResult` resolves it, an `Error` frame
640
- * carrying the same `msg_id` rejects it, and the timeout covers the case
641
- * worth naming — an agent built before these frames existed logs the
642
- * unknown frame and drops it, so silence usually means "too old" rather
643
- * than "slow", and the message says so.
644
- */
645
- run_op(verb, send, timeoutMs = 30_000) {
646
- if (!this.session_id) {
647
- return Promise.reject(new Error('No active SFTP session.'));
648
- }
649
- const msgId = this.next_msg_id();
650
- return new Promise((resolve, reject) => {
651
- const timeout = window.setTimeout(() => {
652
- this.pendingOps.delete(msgId);
653
- reject(new Error(`Timed out trying to ${verb}. This node's agent may be too old to support it.`));
654
- }, timeoutMs);
655
- this.pendingOps.set(msgId, { verb, timeout, resolve, reject });
656
- try {
657
- send(msgId);
658
- }
659
- catch (err) {
660
- window.clearTimeout(timeout);
661
- this.pendingOps.delete(msgId);
662
- reject(err instanceof Error ? err : new Error(String(err)));
663
- }
664
- });
665
- }
666
- error_text(err) {
667
- return err instanceof Error ? err.message : String(err);
668
- }
669
- /**
670
- * A listing entry carries its *parent* directory in `path`, so a full path
671
- * is always the join of the two.
672
- */
673
- item_path(item) {
674
- return this.join_path(item.path, item.name);
675
- }
676
- join_path(dir, name) {
677
- if (!dir || dir === '/') {
678
- return `/${name}`;
679
- }
680
- return dir.endsWith('/') ? `${dir}${name}` : `${dir}/${name}`;
681
- }
682
- /** Names the remote would reject, or that would silently mean something else. */
683
- invalid_name(name) {
684
- if (!name) {
685
- return 'Enter a name.';
686
- }
687
- if (name === '.' || name === '..') {
688
- return 'That name is reserved.';
689
- }
690
- if (name.includes('/')) {
691
- return 'A name cannot contain "/".';
692
- }
693
- if (name.includes('\u0000')) {
694
- return 'A name cannot contain a null byte.';
695
- }
696
- return '';
697
- }
698
- handle_tunnel_data(web) {
699
- console.log('received tunnel data:', web);
700
- }
701
- handle_tunnel_closed(_web_) {
702
- // this.session_id = undefined;
703
- // this.inputMode = InputMode.Default;
704
- this.clear_creds_buffer();
705
- // this.terminal.reset();
706
- // this.terminal.writeln("Connection closed.");
707
- this.close_comms();
708
- }
709
- open_comms() {
710
- const endpoint = `${this.create_web_socket_endpoint()}/api/web/ws`;
711
- if (this.channelFactory) {
712
- this.channel = this.channelFactory(endpoint, this.nodeId, this.serverId || undefined);
713
- }
714
- else if (this.serverId) {
715
- this.channel = new protocol.Channel(endpoint, this.nodeId, this.serverId);
716
- }
717
- else {
718
- this.channel = new protocol.Channel(endpoint, this.nodeId);
719
- }
720
- this.channel.on_connection_open(() => {
721
- this.connectionStateChanged.emit([protocol.ConnectionState.Connected]);
722
- this.channel.authenticate(this.token, this.nodeId);
723
- this.status = 'Authenticating...';
724
- });
725
- this.channel.on_connection_close(() => {
726
- this.connectionStateChanged.emit([protocol.ConnectionState.Disconnected]);
727
- this.status = 'Disconnected';
728
- });
729
- this.channel.on_connection_error((err) => {
730
- this.connectionStateChanged.emit([protocol.ConnectionState.Error, err]);
731
- this.status = 'Error ' + err.message;
732
- });
733
- this.channel.on_connection_message((_raw_) => {
734
- //
735
- });
736
- this.channel.on_protocol_message((msg) => {
737
- const { web } = msg.data;
738
- switch (web.type) {
739
- case protocol.ProtocolMessageType.Error:
740
- this.handle_error(web);
741
- break;
742
- case protocol.ProtocolMessageType.AuthSuccess:
743
- this.handle_auth_success(web);
744
- break;
745
- case protocol.ProtocolMessageType.TunnelOpened:
746
- this.handle_tunnel_opened(web);
747
- break;
748
- case protocol.ProtocolMessageType.TunnelClosed:
749
- this.handle_tunnel_closed(web);
750
- break;
751
- case protocol.ProtocolMessageType.TunnelData:
752
- this.handle_tunnel_data(web);
753
- break;
754
- case protocol.ProtocolMessageType.SFTPListItems:
755
- this.handle_sftp_list_items(web);
756
- break;
757
- case protocol.ProtocolMessageType.SFTPUploadStartResponse:
758
- this.handle_upload_start_response(web);
759
- break;
760
- case protocol.ProtocolMessageType.SFTPUploadChunkAck:
761
- this.handle_upload_chunk_ack(web);
762
- break;
763
- case protocol.ProtocolMessageType.SFTPDownloadStartResponse:
764
- this.handle_download_start_response(web);
765
- break;
766
- case protocol.ProtocolMessageType.SFTPDownloadChunk:
767
- this.handle_download_chunk(web);
768
- break;
769
- case protocol.ProtocolMessageType.SFTPOpResult:
770
- this.handle_op_result(web);
771
- break;
772
- default:
773
- console.warn('Unhandled protocol message type:', web);
774
- }
775
- });
776
- }
777
- close_comms() {
778
- this.cancel_active_upload();
779
- this.cancel_active_download();
780
- this.clear_pending_operations();
781
- if (!this.channel) {
782
- return;
783
- }
784
- this.channel.stop_heartbeat();
785
- this.channel.disconnect();
786
- }
787
- clear_creds_buffer() {
788
- // this.usernameBuffer = "";
789
- // this.passwordBuffer = "";
790
- }
791
- reset_session_state() {
792
- // this.session_id = undefined;
793
- // this.inputMode = InputMode.Default;
794
- this.clear_creds_buffer();
795
- }
796
- list_breadcrumb(path) {
797
- this.show_loader = true;
798
- this.selected_item = null;
799
- this.channel.send_sftp_list_data(this.nodeId, this.session_id, path);
800
- }
801
- go_to_parent_directory() {
802
- if (!this.session_id) {
803
- return;
804
- }
805
- if (this.current_dir === '/') {
806
- return;
807
- }
808
- const parent = this.breadcrumbs[this.breadcrumbs.length - 2]?.path || '/';
809
- this.list_breadcrumb(parent);
810
- }
811
- refresh_directory() {
812
- if (!this.session_id) {
813
- return;
814
- }
815
- this.list_breadcrumb(this.current_dir);
816
- }
817
- disconnect_session() {
818
- this.close_comms();
819
- this.session_id = undefined;
820
- this.show_loader = false;
821
- this.show_content = false;
822
- this.breadcrumbs = [];
823
- this.current_dir = '.';
824
- this.listing = [];
825
- this.show_navigation = false;
826
- this.show_login_screen_username = false;
827
- this.show_login_screen_password = false;
828
- this.show_login_screen = false;
829
- this.show_upload_modal = false;
830
- this.show_download_modal = false;
831
- this.show_delete_modal = false;
832
- this.upload_progress = 0;
833
- this.download_progress = 0;
834
- this.upload_finished = false;
835
- this.download_finished = false;
836
- this.delete_loading = false;
837
- this.delete_file_name = '';
838
- this.delete_error = '';
839
- this.delete_is_dir = false;
840
- this.delete_recursive = false;
841
- this.prompt_kind = null;
842
- this.prompt_value = '';
843
- this.prompt_error = '';
844
- this.prompt_busy = false;
845
- this.chmod_target = null;
846
- this.chmod_error = '';
847
- this.chmod_busy = false;
848
- this.show_editor = false;
849
- this.editor_busy = '';
850
- this.editor_error = '';
851
- this.editor_confirm_discard = false;
852
- this.editor_loaded = false;
853
- this.filter = '';
854
- this.version = '';
855
- this.status = 'Disconnected';
856
- }
857
- on_file_row_action(item, event) {
858
- event.preventDefault();
859
- event.stopPropagation();
860
- if (item.kind !== 'File') {
861
- return;
862
- }
863
- void this.start_download(item);
864
- }
865
- on_file_delete_action(item, event) {
866
- event.preventDefault();
867
- event.stopPropagation();
868
- this.selected_item = item;
869
- this.delete_file_name = item.name;
870
- this.delete_is_dir = item.kind === 'Folder';
871
- this.delete_recursive = false;
872
- this.delete_error = '';
873
- this.delete_loading = false;
874
- this.show_delete_modal = true;
875
- }
876
- cancel_delete() {
877
- if (this.delete_loading) {
878
- return;
879
- }
880
- this.show_delete_modal = false;
881
- this.delete_file_name = '';
882
- this.delete_error = '';
883
- this.delete_is_dir = false;
884
- this.delete_recursive = false;
885
- }
886
- async confirm_delete() {
887
- if (this.delete_loading) {
888
- return;
889
- }
890
- const target = this.selected_item;
891
- if (!this.session_id || !target) {
892
- this.show_delete_modal = false;
893
- return;
894
- }
895
- const path = this.item_path(target);
896
- const recursive = this.delete_is_dir && this.delete_recursive;
897
- this.delete_loading = true;
898
- this.delete_error = '';
899
- this.show_error = false;
900
- this.status = `Deleting ${target.name}...`;
901
- try {
902
- // A recursive delete walks the tree one entry at a time over SSH,
903
- // so it earns a far longer leash than the other operations.
904
- await this.run_op('delete', (msgId) => this.channel.send_sftp_remove(this.nodeId, this.session_id, path, recursive, msgId), recursive ? 300_000 : 30_000);
905
- this.delete_loading = false;
906
- this.show_delete_modal = false;
907
- this.delete_file_name = '';
908
- this.delete_is_dir = false;
909
- this.delete_recursive = false;
910
- this.status = 'Connected';
911
- this.refresh_directory();
912
- }
913
- catch (err) {
914
- this.delete_loading = false;
915
- this.delete_error = this.error_text(err);
916
- this.status = 'Connected';
917
- }
918
- }
919
- open_mkdir() {
920
- if (!this.session_id) {
921
- return;
922
- }
923
- this.prompt_kind = 'mkdir';
924
- this.prompt_value = '';
925
- this.prompt_error = '';
926
- this.prompt_busy = false;
927
- }
928
- on_rename_action(item, event) {
929
- event.preventDefault();
930
- event.stopPropagation();
931
- if (!this.session_id) {
932
- return;
933
- }
934
- this.selected_item = item;
935
- this.prompt_kind = 'rename';
936
- this.prompt_value = item.name;
937
- this.prompt_error = '';
938
- this.prompt_busy = false;
939
- }
940
- close_prompt() {
941
- if (this.prompt_busy) {
942
- return;
943
- }
944
- this.prompt_kind = null;
945
- this.prompt_value = '';
946
- this.prompt_error = '';
947
- this.promptInputEl = undefined;
948
- }
949
- async submit_prompt() {
950
- if (this.prompt_busy || !this.session_id) {
951
- return;
952
- }
953
- const kind = this.prompt_kind;
954
- const name = this.prompt_value.trim();
955
- const invalid = this.invalid_name(name);
956
- if (invalid) {
957
- this.prompt_error = invalid;
958
- return;
959
- }
960
- const target = this.selected_item;
961
- if (kind === 'rename' && target && name === target.name) {
962
- this.close_prompt();
963
- return;
964
- }
965
- this.prompt_busy = true;
966
- this.prompt_error = '';
967
- this.show_error = false;
968
- try {
969
- if (kind === 'mkdir') {
970
- const path = this.join_path(this.current_dir, name);
971
- this.status = `Creating ${name}...`;
972
- await this.run_op('create the folder', (msgId) => this.channel.send_sftp_mkdir(this.nodeId, this.session_id, path, msgId));
973
- }
974
- else if (kind === 'rename' && target) {
975
- // `to` is a full path, so the same call would move the entry if
976
- // the dialog ever offered a destination directory.
977
- const from = this.item_path(target);
978
- const to = this.join_path(target.path, name);
979
- this.status = `Renaming ${target.name}...`;
980
- await this.run_op('rename', (msgId) => this.channel.send_sftp_rename(this.nodeId, this.session_id, from, to, msgId));
981
- }
982
- else {
983
- this.prompt_busy = false;
984
- this.close_prompt();
985
- return;
986
- }
987
- this.prompt_busy = false;
988
- this.prompt_kind = null;
989
- this.prompt_value = '';
990
- this.promptInputEl = undefined;
991
- this.status = 'Connected';
992
- this.refresh_directory();
993
- }
994
- catch (err) {
995
- this.prompt_busy = false;
996
- this.prompt_error = this.error_text(err);
997
- this.status = 'Connected';
998
- }
999
- }
1000
- on_chmod_action(item, event) {
1001
- event.preventDefault();
1002
- event.stopPropagation();
1003
- if (!this.session_id) {
1004
- return;
1005
- }
1006
- this.selected_item = item;
1007
- this.chmod_target = item;
1008
- this.chmod_mode = (item.attributes.permissions ?? 0) & 0o7777;
1009
- this.chmod_error = '';
1010
- this.chmod_busy = false;
1011
- }
1012
- close_chmod() {
1013
- if (this.chmod_busy) {
1014
- return;
1015
- }
1016
- this.chmod_target = null;
1017
- this.chmod_error = '';
1018
- }
1019
- toggle_chmod_bit(bit) {
1020
- if (this.chmod_busy) {
1021
- return;
1022
- }
1023
- this.chmod_mode = (this.chmod_mode ^ bit) & 0o7777;
1024
- }
1025
- on_chmod_octal_input(value) {
1026
- const digits = value.trim();
1027
- if (!/^[0-7]{1,4}$/.test(digits)) {
1028
- this.chmod_error = 'Enter up to four octal digits, 0-7.';
1029
- return;
1030
- }
1031
- this.chmod_error = '';
1032
- this.chmod_mode = parseInt(digits, 8) & 0o7777;
1033
- }
1034
- async submit_chmod() {
1035
- const target = this.chmod_target;
1036
- if (this.chmod_busy || !this.session_id || !target) {
1037
- return;
1038
- }
1039
- const path = this.item_path(target);
1040
- const mode = this.chmod_mode & 0o7777;
1041
- this.chmod_busy = true;
1042
- this.chmod_error = '';
1043
- this.show_error = false;
1044
- this.status = `Setting permissions on ${target.name}...`;
1045
- try {
1046
- await this.run_op('change permissions', (msgId) => this.channel.send_sftp_chmod(this.nodeId, this.session_id, path, mode, msgId));
1047
- this.chmod_busy = false;
1048
- this.chmod_target = null;
1049
- this.status = 'Connected';
1050
- this.refresh_directory();
1051
- }
1052
- catch (err) {
1053
- this.chmod_busy = false;
1054
- this.chmod_error = this.error_text(err);
1055
- this.status = 'Connected';
1056
- }
1057
- }
1058
- async on_edit_action(item, event) {
1059
- event.preventDefault();
1060
- event.stopPropagation();
1061
- if (!this.session_id || item.kind !== 'File') {
1062
- return;
1063
- }
1064
- const path = this.item_path(item);
1065
- this.selected_item = item;
1066
- this.show_editor = true;
1067
- this.editorPath = path;
1068
- this.editor_name = item.name;
1069
- this.editor_text = '';
1070
- this.editor_saved_text = '';
1071
- this.editor_error = '';
1072
- this.editor_confirm_discard = false;
1073
- this.editor_loaded = false;
1074
- this.editor_busy = 'loading';
1075
- this.status = `Opening ${item.name}...`;
1076
- try {
1077
- const answer = await this.run_op('open the file', (msgId) => this.channel.send_sftp_read_file(this.nodeId, this.session_id, path, msgId), 60_000);
1078
- if (answer.result !== 'FileContents') {
1079
- throw new Error('The agent answered without any file contents.');
1080
- }
1081
- const text = this.decode_text(answer.contents instanceof Uint8Array ? answer.contents : new Uint8Array(answer.contents));
1082
- this.editor_text = text;
1083
- this.editor_saved_text = text;
1084
- this.editor_loaded = true;
1085
- this.editor_busy = '';
1086
- this.status = 'Connected';
1087
- }
1088
- catch (err) {
1089
- this.editor_busy = '';
1090
- this.editor_error = this.error_text(err);
1091
- this.status = 'Connected';
1092
- }
1093
- }
1094
- /**
1095
- * Refuse binary rather than mangle it. A lossy decode looks fine on screen
1096
- * and then writes replacement characters over the real bytes on save, so
1097
- * anything that is not valid UTF-8 is sent to the download button instead.
1098
- */
1099
- decode_text(bytes) {
1100
- if (bytes.includes(0)) {
1101
- throw new Error('This looks like a binary file. Download it instead of editing it here.');
1102
- }
1103
- try {
1104
- return new TextDecoder('utf-8', { fatal: true }).decode(bytes);
1105
- }
1106
- catch {
1107
- throw new Error('This file is not valid UTF-8. Download it instead of editing it here.');
1108
- }
1109
- }
1110
- editor_is_dirty() {
1111
- return this.editor_loaded && this.editor_text !== this.editor_saved_text;
1112
- }
1113
- close_editor(force = false) {
1114
- if (this.editor_busy === 'saving') {
1115
- return;
1116
- }
1117
- if (!force && this.editor_is_dirty()) {
1118
- this.editor_confirm_discard = true;
1119
- return;
1120
- }
1121
- this.show_editor = false;
1122
- this.editor_confirm_discard = false;
1123
- this.editor_loaded = false;
1124
- this.editorPath = '';
1125
- this.editor_name = '';
1126
- this.editor_text = '';
1127
- this.editor_saved_text = '';
1128
- this.editor_error = '';
1129
- this.editor_busy = '';
1130
- this.editorTextEl = undefined;
1131
- }
1132
- async save_editor() {
1133
- if (this.editor_busy || !this.session_id || !this.editorPath) {
1134
- return;
1135
- }
1136
- const path = this.editorPath;
1137
- const text = this.editor_text;
1138
- this.editor_busy = 'saving';
1139
- this.editor_error = '';
1140
- this.show_error = false;
1141
- this.status = `Saving ${this.editor_name}...`;
1142
- try {
1143
- await this.run_op('save the file', (msgId) => this.channel.send_sftp_write_file(this.nodeId, this.session_id, path, new TextEncoder().encode(text), msgId), 60_000);
1144
- this.editor_saved_text = text;
1145
- this.editor_busy = '';
1146
- this.status = 'Connected';
1147
- this.refresh_directory();
1148
- }
1149
- catch (err) {
1150
- this.editor_busy = '';
1151
- this.editor_error = this.error_text(err);
1152
- this.status = 'Connected';
1153
- }
1154
- }
1155
- toggle_sort(key) {
1156
- if (this.sort_key === key) {
1157
- this.sort_asc = !this.sort_asc;
1158
- return;
1159
- }
1160
- this.sort_key = key;
1161
- this.sort_asc = true;
1162
- }
1163
- /**
1164
- * Folders stay above files whichever way the sort runs: a listing that
1165
- * scatters directories through the files is harder to scan, not more sorted.
1166
- */
1167
- visible_listing() {
1168
- const needle = this.filter.trim().toLowerCase();
1169
- const rows = needle
1170
- ? this.listing.filter((item) => item.name.toLowerCase().includes(needle))
1171
- : [...this.listing];
1172
- const direction = this.sort_asc ? 1 : -1;
1173
- return rows.sort((a, b) => {
1174
- if (a.kind !== b.kind) {
1175
- return a.kind === 'Folder' ? -1 : 1;
1176
- }
1177
- switch (this.sort_key) {
1178
- case 'size':
1179
- return direction * ((a.attributes.size ?? 0) - (b.attributes.size ?? 0));
1180
- case 'modified':
1181
- return direction * ((a.attributes.modified ?? 0) - (b.attributes.modified ?? 0));
1182
- default:
1183
- return direction * a.name.localeCompare(b.name, undefined, {
1184
- numeric: true,
1185
- sensitivity: 'base',
1186
- });
1187
- }
1188
- });
1189
- }
1190
- sort_indicator(key) {
1191
- if (this.sort_key !== key) {
1192
- return '';
1193
- }
1194
- return this.sort_asc ? ' \u25b2' : ' \u25bc';
1195
- }
1196
- /** Keyboard shortcuts, scoped to the file table so the page keeps its own. */
1197
- on_listing_keydown(event) {
1198
- if (this.prompt_kind || this.chmod_target || this.show_editor || this.show_delete_modal) {
1199
- return;
1200
- }
1201
- const item = this.selected_item;
1202
- switch (event.key) {
1203
- case 'Backspace':
1204
- event.preventDefault();
1205
- this.go_to_parent_directory();
1206
- break;
1207
- case 'F5':
1208
- event.preventDefault();
1209
- this.refresh_directory();
1210
- break;
1211
- case 'F2':
1212
- if (item) {
1213
- event.preventDefault();
1214
- this.on_rename_action(item, event);
1215
- }
1216
- break;
1217
- case 'Delete':
1218
- if (item) {
1219
- event.preventDefault();
1220
- this.on_file_delete_action(item, event);
1221
- }
1222
- break;
1223
- case 'Enter':
1224
- if (item) {
1225
- event.preventDefault();
1226
- this.list_directory(item);
1227
- }
1228
- break;
1229
- }
1230
- }
1231
- on_modal_keydown(event, close) {
1232
- if (event.key === 'Escape') {
1233
- event.preventDefault();
1234
- event.stopPropagation();
1235
- close();
1236
- }
1237
- }
1238
- /** Focus a dialog's field as it appears, without re-focusing on every render. */
1239
- focus_once(el, current, keep) {
1240
- if (!el || el === current) {
1241
- return;
1242
- }
1243
- keep(el);
1244
- requestAnimationFrame(() => el.focus());
1245
- }
1246
- open_upload_picker() {
1247
- this.uploadInputEl?.click();
1248
- }
1249
- on_upload_selected(event) {
1250
- const input = event.target;
1251
- const selectedFile = input.files?.[0];
1252
- if (!selectedFile) {
1253
- return;
1254
- }
1255
- void this.upload_file(selectedFile);
1256
- input.value = '';
1257
- }
1258
- cancel_upload() {
1259
- this.cancel_active_upload();
1260
- this.show_upload_modal = false;
1261
- this.upload_file_name = '';
1262
- this.upload_speed = '--';
1263
- this.status = 'Connected';
1264
- this.refresh_directory();
1265
- }
1266
- cancel_download() {
1267
- this.cancel_active_download();
1268
- this.show_download_modal = false;
1269
- this.download_file_name = '';
1270
- this.download_speed = '--';
1271
- this.status = 'Connected';
1272
- this.refresh_directory();
1273
- }
1274
- is_selected(item) {
1275
- if (!this.selected_item) {
1276
- return false;
1277
- }
1278
- return this.selected_item.path === item.path &&
1279
- this.selected_item.name === item.name;
1280
- }
1281
- list_directory(entry) {
1282
- if (!this.session_id) {
1283
- console.warn('No active session. Cannot list directory.');
1284
- return;
1285
- }
1286
- if (entry.kind === 'File') {
1287
- console.warn('Cannot list directory of a file. Ignoring click.');
1288
- this.selected_item = entry;
1289
- return;
1290
- }
1291
- const path = this.item_path(entry);
1292
- if (path === this.current_dir) {
1293
- console.warn('Already in this directory. Ignoring click.');
1294
- return;
1295
- }
1296
- this.show_loader = true;
1297
- this.selected_item = null;
1298
- this.channel.send_sftp_list_data(this.nodeId, this.session_id, path);
1299
- }
1300
- format_size(size) {
1301
- if (size === undefined || Number.isNaN(size)) {
1302
- return '-';
1303
- }
1304
- if (size < 1024) {
1305
- return `${size} B`;
1306
- }
1307
- const units = ['KB', 'MB', 'GB', 'TB', 'PB'];
1308
- let value = size;
1309
- let unitIndex = -1;
1310
- while (value >= 1024 && unitIndex < units.length - 1) {
1311
- value /= 1024;
1312
- unitIndex += 1;
1313
- }
1314
- const rounded = value >= 10 ? value.toFixed(1) : value.toFixed(2);
1315
- return `${rounded} ${units[unitIndex]}`;
1316
- }
1317
- mode_type_to_char(mode, kind) {
1318
- const S_IFMT = 0o170000;
1319
- const type = mode & S_IFMT;
1320
- switch (type) {
1321
- case 0o140000: return 's';
1322
- case 0o120000: return 'l';
1323
- case 0o100000: return '-';
1324
- case 0o060000: return 'b';
1325
- case 0o040000: return 'd';
1326
- case 0o020000: return 'c';
1327
- case 0o010000: return 'p';
1328
- default:
1329
- return kind === 'Folder' ? 'd' : '-';
1330
- }
1331
- }
1332
- format_permissions(permissions, kind) {
1333
- if (permissions === undefined || permissions === null) {
1334
- return '-';
1335
- }
1336
- if (typeof permissions === 'string') {
1337
- const value = permissions.trim();
1338
- if (/^[bcdlps-][rwxStTs-]{9}$/.test(value)) {
1339
- return value;
1340
- }
1341
- if (/^[0-7]{3,4}$/.test(value)) {
1342
- const mode = parseInt(value, 8);
1343
- return this.format_permissions(mode, kind);
1344
- }
1345
- if (/^\d+$/.test(value)) {
1346
- const mode = parseInt(value, 10);
1347
- return this.format_permissions(mode, kind);
1348
- }
1349
- return value || '-';
1350
- }
1351
- const mode = permissions;
1352
- const typeChar = this.mode_type_to_char(mode, kind);
1353
- const chars = [
1354
- mode & 0o400 ? 'r' : '-',
1355
- mode & 0o200 ? 'w' : '-',
1356
- mode & 0o100 ? 'x' : '-',
1357
- mode & 0o040 ? 'r' : '-',
1358
- mode & 0o020 ? 'w' : '-',
1359
- mode & 0o010 ? 'x' : '-',
1360
- mode & 0o004 ? 'r' : '-',
1361
- mode & 0o002 ? 'w' : '-',
1362
- mode & 0o001 ? 'x' : '-',
1363
- ];
1364
- if (mode & 0o4000) {
1365
- chars[2] = chars[2] === 'x' ? 's' : 'S';
1366
- }
1367
- if (mode & 0o2000) {
1368
- chars[5] = chars[5] === 'x' ? 's' : 'S';
1369
- }
1370
- if (mode & 0o1000) {
1371
- chars[8] = chars[8] === 'x' ? 't' : 'T';
1372
- }
1373
- return `${typeChar}${chars.join('')}`;
1374
- }
1375
- render() {
1376
- return (index.h(index.Host, { key: '9e2edc1a72c3a74b26feea2faa08b9f0a2e37a0c', class: {
1377
- 'default': !this.max,
1378
- 'max': this.max,
1379
- } }, index.h("section", { key: '72fae8227792615a5452f9b01ec8230c2c10e2a9', class: "listing" }, !this.hideHeader &&
1380
- index.h("header", { key: '14632fcb4575678418132892308cfea1903fadab' }, index.h("section", { key: '3ea3fb2cab9d4cdf36af3876235579562a7acbef', class: "title" }, index.h("img", { key: 'fd0badaae9b0d7b426ddece5faf7ea3515e9bbf0', src: phirepassSftpClientLogoSvg, alt: "SFTP Client" }), index.h("div", { key: '4eece24a618c119861f5435eb3f1ae8a5bae4966', class: "text" }, index.h("div", { key: '84b45196e1a1609451413cf8ea369b60cd7f5ec6', class: "name" }, this.name), index.h("div", { key: '45da97e659ecbaa69e74d1789a1b7961b760a753', class: "description" }, this.description))), index.h("section", { key: '9177dcc02b911e95870c5f55fc48f741895a0b75', class: "actions" }, index.h("div", { key: '468f341eebf7569c2a1c4aeea09d56644e5b6161', class: "action", onClick: () => this.toggle_max() }, index.h("img", { key: '203b54e42cddc50bf068a49fa7f88c846ecaa2c9', src: phirepassSftpClientMaxSvg, alt: "Maximize" })))), index.h("main", { key: 'c0f757aaa07734199228e3dc520c98694bc6548d' }, this.show_navigation && index.h("nav", { key: '295440219080af5fa33566300fb1036998da399c', class: "navigation" }, index.h("div", { key: 'c9b63f04de675559d2e2bbb876115c63e00bfbd2', class: "breadcrumbs" }, this.breadcrumbs.map((crumb, index$1, breadcrumbs) => (index.h("span", { key: index$1, class: "breadcrumb-container" }, index.h("span", { key: index$1, onClick: () => this.list_breadcrumb(crumb.path), class: "breadcrumb" }, crumb.label), index$1 < breadcrumbs.length - 1 && index.h("img", { class: "arrow", src: phirepassSftpClientChevronSvg }))))), index.h("section", { key: '325ccd4be07d61df1e16956b5818683feb70c52f', class: "actions", "aria-label": "SFTP actions" }, index.h("input", { key: 'f75b4191b0718bd2234497b7168af9dc13a070d6', class: "filter", type: "search", autocorrect: "off", autocapitalize: "none", autoComplete: "off", placeholder: "Filter", "aria-label": "Filter this directory", value: this.filter, onInput: (event) => this.filter = event.target.value }), index.h("button", { key: 'da64c4a88332d3efab6a6e03e8c16a8a1db96b43', type: "button", class: "action", onClick: () => this.go_to_parent_directory(), title: "Go to parent directory", "aria-label": "Go to parent directory" }, index.h("img", { key: '309e0fdb89aa4d119a5193f1803ebdc117e55105', src: phirepassSftpClientGoUpSvg, alt: "Go up" })), index.h("button", { key: '5f451e50801f10b88a3436515d792b1015bf48bb', type: "button", class: "action", onClick: () => this.refresh_directory(), title: "Refresh", "aria-label": "Refresh" }, index.h("img", { key: 'aa673b81504e65e78043c328f94d3a9dd02f696a', src: phirepassSftpClientRefreshSvg, alt: "Refresh" })), index.h("button", { key: '963f5abf044c207f9e42babe9e029ac052521f36', type: "button", class: "action", onClick: () => this.open_mkdir(), title: "New folder", "aria-label": "New folder" }, index.h("svg", { key: 'd441f67a8b5d2944f95e934d60d680dc22ec7c6c', xmlns: "http://www.w3.org/2000/svg", width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", "aria-hidden": "true" }, index.h("path", { key: '9eec6695289a71b135dee4751217cd4b4810a276', d: "M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z" }), index.h("line", { key: '9a759bd7ac97c4e8ebf75c4d54e8f207999634c2', x1: "12", x2: "12", y1: "10", y2: "16" }), index.h("line", { key: '4591434cdbb6a7d3a1a0212409fe38e21e02a52e', x1: "9", x2: "15", y1: "13", y2: "13" }))), index.h("button", { key: '301d406858c2d9a4656a342b49e663e76a7f1970', type: "button", class: "action", onClick: () => this.open_upload_picker(), title: "Upload", "aria-label": "Upload" }, index.h("img", { key: '36ff8480d3acf65282d6ef648349327eb3432237', src: phirepassSftpClientUploadSvg, alt: "Upload" })), index.h("button", { key: '3fa19d5e17ef2e2a8fc926c8ba6994a4a30a1825', type: "button", class: "action disconnect", onClick: () => this.disconnect_session(), title: "Disconnect", "aria-label": "Disconnect" }, "DISCONNECT"))), index.h("input", { key: 'f5cf6cc13d4b760b538d630467972c8add2df490', type: "file", ref: (el) => this.uploadInputEl = el, onChange: (event) => this.on_upload_selected(event), style: { display: 'none' } }), this.show_content && index.h("div", { key: 'd69a7009192adc292cf3ccf4de6a4f059b46fa0e', class: "content", tabindex: 0, onKeyDown: (event) => this.on_listing_keydown(event) }, index.h("table", { key: '2f00d85024b3e4642925f488a34d228dd056a2ce' }, index.h("thead", { key: '611091a29f97e218f5282e11c7c1accdc1be5732' }, index.h("tr", { key: '5f0d04ff8a5009852af02472f4261b9a95733a3c' }, index.h("th", { key: '6df9558b86b3d3161920d5f94e8df0cf47ee9c80', class: "sortable", onClick: () => this.toggle_sort('name'), title: "Sort by name" }, "Name", this.sort_indicator('name')), index.h("th", { key: '83384582ac59c07f65526cfc5fd1359b5a0cd912', class: "sortable", onClick: () => this.toggle_sort('size'), title: "Sort by size" }, "Size", this.sort_indicator('size')), index.h("th", { key: 'cbc16eafd7fb17c9d79b5612502140bc9a16a3cb' }, "Permissions"), index.h("th", { key: '25d802dd84a6cc3eda222d5a732e05010c405f31' }, "Owner"), index.h("th", { key: 'cf5f9df11baae69f664724c6a79df0a95a5189a8', class: "sortable", onClick: () => this.toggle_sort('modified'), title: "Sort by modified date" }, "Modified", this.sort_indicator('modified')), index.h("th", { key: '9c8b9515c81245656d89ea65ee091a70606c1a93', class: "action-col", "aria-label": "Actions" }))), index.h("tbody", { key: '40f8ec5d38a0601af3520891c4a9d35b2da2c32f' }, this.visible_listing().map((item, index$1) => (index.h("tr", { key: index$1, class: {
1381
- 'selected': this.is_selected(item),
1382
- }, onClick: () => this.list_directory(item) }, index.h("td", null, item.kind === 'Folder' ? index.h("img", { class: "kind", src: phirepassSftpClientFolderSvg, alt: "Folder" }) : index.h("img", { class: "kind", src: phirepassSftpClientFileSvg, alt: "File" }), index.h("span", { class: `name ${item.kind.toLowerCase()}` }, item.name)), index.h("td", null, item.kind === 'Folder' ? '-' : this.format_size(item.attributes.size)), index.h("td", null, this.format_permissions(item.attributes.permissions, item.kind)), index.h("td", null, item.attributes.user ?? '-'), index.h("td", null, new Date(item.attributes.modified * 1000).toLocaleString()), index.h("td", { class: "action-col" }, index.h("div", { class: "file-actions" }, item.kind === 'File' &&
1383
- index.h("button", { type: "button", class: "file-action", onClick: (event) => this.on_edit_action(item, event), title: "Edit", "aria-label": `Edit ${item.name}` }, index.h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", "aria-hidden": "true" }, index.h("path", { d: "M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7" }), index.h("path", { d: "M18.5 2.5a2.12 2.12 0 0 1 3 3L12 15l-4 1 1-4Z" }))), item.kind === 'File' &&
1384
- index.h("button", { type: "button", class: "file-action", onClick: (event) => this.on_file_row_action(item, event), title: "Download", "aria-label": `Download ${item.name}` }, index.h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", "aria-hidden": "true" }, index.h("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }), index.h("polyline", { points: "7 10 12 15 17 10" }), index.h("line", { x1: "12", x2: "12", y1: "15", y2: "3" }))), index.h("button", { type: "button", class: "file-action", onClick: (event) => this.on_rename_action(item, event), title: "Rename", "aria-label": `Rename ${item.name}` }, index.h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", "aria-hidden": "true" }, index.h("path", { d: "M12 20h9" }), index.h("path", { d: "M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z" }))), index.h("button", { type: "button", class: "file-action", onClick: (event) => this.on_chmod_action(item, event), title: "Permissions", "aria-label": `Change permissions on ${item.name}` }, index.h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", "aria-hidden": "true" }, index.h("rect", { width: "18", height: "11", x: "3", y: "11", rx: "2", ry: "2" }), index.h("path", { d: "M7 11V7a5 5 0 0 1 10 0v4" }))), index.h("button", { type: "button", class: "file-action delete", onClick: (event) => this.on_file_delete_action(item, event), title: "Delete", "aria-label": `Delete ${item.name}` }, index.h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", "aria-hidden": "true" }, index.h("polyline", { points: "3 6 5 6 21 6" }), index.h("path", { d: "M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" }), index.h("path", { d: "M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6" }), index.h("line", { x1: "10", x2: "10", y1: "11", y2: "17" }), index.h("line", { x1: "14", x2: "14", y1: "11", y2: "17" })))))))), this.visible_listing().length === 0 &&
1385
- index.h("tr", { key: '46a173ad6542c9ab315da2792ea9830f0086b683', class: "empty" }, index.h("td", { key: '986924de123f9be62f89f869fca02cd195134080', colSpan: 6 }, this.filter ? `Nothing here matches "${this.filter}".` : 'This directory is empty.'))))), this.show_loader && index.h("div", { key: '588f4ff57df18c993f8566711a2627bd69b03881', class: "loader" }, "Loading..."), this.show_error && index.h("div", { key: '816c8ca05f68291d784d4c86509c9478204f3449', class: "error" }, this.error_message)), index.h("footer", { key: '6add74a0d5beb8de15a600d287d96dd69f87a646' }, index.h("section", { key: '39b31ae22b9f6298b8991be47d5641c1de618ab7', class: "status" }, this.status, this.selected_item && index.h("span", { key: '6e3942b5471e240719dfaf66cb01763f162ff3f0', class: "selected-item" }, this.selected_item.name)), index.h("section", { key: 'cc7ab5a9a632da8fae266f9ae73f967083e3589f', class: "version" }, this.version ? `Version: ${this.version}` : ''))), this.show_login_screen &&
1386
- index.h("section", { key: '3e13e8c942f690d2e26c231c2403032af620f735', class: {
1387
- 'creds': true,
1388
- 'blurred': this.show_login_screen,
1389
- } }, index.h("form", { key: '7ddb982159a3470bfad44aea75973a2eb37bebcd', class: "auth", onSubmit: (event) => {
1390
- const formData = new FormData(event.target);
1391
- let username = undefined;
1392
- if (this.show_login_screen_username) {
1393
- username = formData.get('username');
1394
- }
1395
- let password = undefined;
1396
- if (this.show_login_screen_password) {
1397
- password = formData.get('password');
1398
- }
1399
- this.channel.open_sftp_tunnel(this.nodeId, this.serviceId, username, password);
1400
- this.show_login_screen_username = false;
1401
- this.show_login_screen_password = false;
1402
- this.show_login_screen = false;
1403
- this.show_loader = true;
1404
- event.stopPropagation();
1405
- event.preventDefault();
1406
- } }, index.h("div", { key: '036877a02034000a79836c0a0979def9163f8a1a', class: "title" }, "SFTP Connection"), this.show_login_screen_username &&
1407
- index.h("div", { key: '37830ddb769fe0491831700a90f3fc8bf71cf050' }, index.h("label", { key: '0f6e3d70e34baae3342a57fceed657e59c8c05a4', htmlFor: "username" }, "Username"), index.h("input", { key: '3ecb202b3ee015e8719c330edb06889f4f48a433', autocorrect: "off", autocapitalize: "none", autoComplete: "off", id: "username", name: "username", type: "text", placeholder: "" })), this.show_login_screen_password &&
1408
- index.h("div", { key: '092a40a9da1205ec6342069844135aea92b85c5a' }, index.h("label", { key: '19e465136660c9d2c1ecd0bb02bd7f8a559e3e0b', htmlFor: "password" }, "Password"), index.h("input", { key: 'ab9a74273abc594fa9fd51a780c2586fb275b4b4', autocorrect: "off", autocapitalize: "none", autoComplete: "off", id: "password", name: "password", type: "password", placeholder: "" })), index.h("div", { key: 'c1596787c7fea135d203f831cb7432a6e803d488' }, index.h("button", { key: '89314be80add42ba55f96ec01bf22848742ec179', type: "submit" }, "Connect")))), this.show_upload_modal &&
1409
- index.h("section", { key: 'c8b08cf050947d1936c97caf46eacca93175db9f', class: {
1410
- 'upload-modal': true,
1411
- 'visible': this.show_upload_modal,
1412
- } }, index.h("div", { key: 'ccc745354525565cda06b6b6eb8253c557c59009', class: "upload-dialog", role: "dialog", "aria-modal": "true", "aria-label": "Upload progress" }, index.h("div", { key: 'd478b113fa655386998d93862fc53bf516eaf90b', class: "title" }, "Uploading File"), index.h("div", { key: '35c85475b00efcf05097e1feae1313afde0d04af', class: "file-name", title: this.upload_file_name }, this.upload_file_name), index.h("div", { key: 'd5cb7df154d77dacdca48673b2f01e03729846b0', class: "progress-track", role: "progressbar", "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": this.upload_progress }, index.h("div", { key: '4a7c10979b37d06acdda30c0b8d04a2af3cf0e5a', class: "progress-fill", style: { width: `${this.upload_progress}%` } })), index.h("div", { key: 'c69da13c3bc15a9a36867cbb1a8d041780ffecca', class: "progress-meta" }, index.h("div", { key: '000b027205a828e1257263e29b5a595ead0fe54a', class: "progress-speed" }, this.upload_speed), index.h("div", { key: '8eda5c230e39343ffb10aa1bc64f70999d428c57', class: "progress-value" }, this.format_percent(this.upload_progress))), index.h("button", { key: 'b047fe324179b9f77f97f7bcf541c32e0903bad9', type: "button", class: {
1413
- 'cancel': true,
1414
- 'finished': this.upload_finished,
1415
- }, onClick: () => this.cancel_upload() }, this.upload_finished ? 'Close' : 'Cancel'))), this.show_download_modal &&
1416
- index.h("section", { key: 'fff5c3228be15048397b86a1457f63d4562c98f8', class: {
1417
- 'download-modal': true,
1418
- 'visible': this.show_download_modal,
1419
- } }, index.h("div", { key: '8bbf7465cdb2b514b16c4982b3480b04aa5e1a6c', class: "download-dialog", role: "dialog", "aria-modal": "true", "aria-label": "Download progress" }, index.h("div", { key: 'dea4371acce3010cefdb14bbc3873d6cca1e308c', class: "title" }, "Downloading File"), index.h("div", { key: 'cffc4ad6e269108252db2bbb3b3f9678e88aed4b', class: "file-name", title: this.download_file_name }, this.download_file_name), index.h("div", { key: 'ec0fd7bbd72c2c1dcb55dffb39a8e550af9c54a6', class: "progress-track", role: "progressbar", "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": this.download_progress }, index.h("div", { key: 'c899bcf67b523e9de0db76bc9163d192120fd61b', class: "progress-fill", style: { width: `${this.download_progress}%` } })), index.h("div", { key: '14c343bb055ca7300f3b500bb9da06450f9338c8', class: "progress-meta" }, index.h("div", { key: '6b030a95eb9b11d88a070dd8a8dc9f4a2d10302a', class: "progress-speed" }, this.download_speed), index.h("div", { key: '0d8eb9884506e9bb7a31ea1ceedc0f3e3e74f9b8', class: "progress-value" }, this.format_percent(this.download_progress))), index.h("button", { key: '4416377601c6655ba0e9385e6149dd461702439a', type: "button", class: {
1420
- 'cancel': true,
1421
- 'finished': this.download_finished,
1422
- }, onClick: () => this.cancel_download() }, this.download_finished ? 'Close' : 'Cancel'))), this.show_delete_modal &&
1423
- index.h("section", { key: '803d5f9fc2096c44335380132eee7d6ee1c70c1f', class: {
1424
- 'delete-modal': true,
1425
- 'visible': this.show_delete_modal,
1426
- } }, index.h("div", { key: '0f23cb5f9ed35b97accc994277c86eff46de74bd', class: "delete-dialog", role: "dialog", "aria-modal": "true", "aria-label": "Delete confirmation", tabindex: -1, onKeyDown: (event) => this.on_modal_keydown(event, () => this.cancel_delete()) }, index.h("div", { key: '6b64cac5732de2d5c091fea7ef1cd1b903b86c61', class: "title" }, this.delete_is_dir ? 'Delete Folder' : 'Delete File'), index.h("div", { key: 'f1b6592449d9697208c704dcaaeec83d4d40d852', class: "message" }, this.delete_loading
1427
- ? (this.delete_recursive ? 'Deleting the folder and everything in it...' : 'Deleting...')
1428
- : `Are you sure you want to delete this ${this.delete_is_dir ? 'folder' : 'file'}?`), index.h("div", { key: 'a67f8bd35875e0477fcf3bbf9f075b10f9066f07', class: "file-name", title: this.delete_file_name }, this.delete_file_name), this.delete_is_dir &&
1429
- index.h("label", { key: '5e660c03c1df789bcdc4dba7a2adfe4887dd71ca', class: "checkline" }, index.h("input", { key: 'c28122496182d007ae2f99d9de79451c23dadef5', type: "checkbox", checked: this.delete_recursive, disabled: this.delete_loading, onChange: (event) => this.delete_recursive = event.target.checked }), index.h("span", { key: '53539d4803c5358d26e181dc53fcc7f36ad62d6a' }, "Delete everything inside it too")), !this.delete_is_dir || this.delete_recursive ? null :
1430
- index.h("div", { class: "hint" }, "Without this, the remote refuses a folder that is not empty."), this.delete_error && index.h("div", { key: '0773a1e6a26fa8dde7dba0d0ed00107d01782e2f', class: "dialog-error" }, this.delete_error), this.delete_loading &&
1431
- index.h("div", { key: 'b1580f0825ec4f4b37f894fbd714f143a9515fd6', class: "delete-loader", "aria-hidden": "true" }, index.h("span", { key: 'db549d437007182afdaddab37d8caec7b1c4a2c7', class: "spinner" })), index.h("div", { key: '040a4c6730ce5149737211fae9d67a3a290bdc5c', class: "modal-actions" }, index.h("button", { key: 'b742ccd04a3e119c446a2186081835fd6f67022d', type: "button", class: "btn secondary", onClick: () => this.cancel_delete(), disabled: this.delete_loading }, "Cancel"), index.h("button", { key: '4ce414e250ace86f93d24e399ca56014e56c7757', type: "button", class: "btn destructive", onClick: () => this.confirm_delete(), disabled: this.delete_loading }, this.delete_loading ? 'Deleting...' : 'Delete')))), this.prompt_kind &&
1432
- index.h("section", { key: 'd533b9ecb021dbb69766ba92e87d0b4279b047d4', class: "prompt-modal visible" }, index.h("div", { key: 'f7fbe0ee2323439da2c991046d90b1b6397ebee8', class: "prompt-dialog", role: "dialog", "aria-modal": "true", "aria-label": this.prompt_kind === 'mkdir' ? 'New folder' : 'Rename', tabindex: -1, onKeyDown: (event) => this.on_modal_keydown(event, () => this.close_prompt()) }, index.h("div", { key: '36b154bda604336f8bbb7c46d7bb35b6afd6cec2', class: "title" }, this.prompt_kind === 'mkdir' ? 'New Folder' : 'Rename'), index.h("div", { key: '76b8027be289fcdba2867e1b06f05cab8481564d', class: "message" }, this.prompt_kind === 'mkdir'
1433
- ? `Create a folder in ${this.current_dir}`
1434
- : 'Give it a new name. Existing names are not overwritten.'), index.h("form", { key: '8ec6e410dc6572de35ff6b2c81734fa48d74a4a8', onSubmit: (event) => { event.preventDefault(); event.stopPropagation(); void this.submit_prompt(); } }, index.h("input", { key: '0511fa8205057fe088be93781c23e283bc07739e', class: "dialog-input", type: "text", autocorrect: "off", autocapitalize: "none", autoComplete: "off", spellcheck: false, "aria-label": "Name", disabled: this.prompt_busy, value: this.prompt_value, onInput: (event) => this.prompt_value = event.target.value, ref: (el) => this.focus_once(el, this.promptInputEl, (kept) => this.promptInputEl = kept) }), this.prompt_error && index.h("div", { key: '2644600b1e015e02209309e1163e991acabad2e9', class: "dialog-error" }, this.prompt_error), index.h("div", { key: '520937e554f3ff7839aad18fd0ed3c56f8a21680', class: "modal-actions" }, index.h("button", { key: 'e5a037f006c3f97e6227e672cff6cf3dc7282abb', type: "button", class: "btn secondary", onClick: () => this.close_prompt(), disabled: this.prompt_busy }, "Cancel"), index.h("button", { key: 'b7883cc44b152c2c648f133eb5ffd7f5942d0aa4', type: "submit", class: "btn primary", disabled: this.prompt_busy }, this.prompt_busy ? 'Working...' : (this.prompt_kind === 'mkdir' ? 'Create' : 'Rename')))))), this.chmod_target &&
1435
- index.h("section", { key: 'e99ef709477024789821b76e1bbaa6497dcbc474', class: "prompt-modal visible" }, index.h("div", { key: '1cec5818b817d089a9b4cda3b4ee514e7e9201a7', class: "prompt-dialog", role: "dialog", "aria-modal": "true", "aria-label": "Change permissions", tabindex: -1, onKeyDown: (event) => this.on_modal_keydown(event, () => this.close_chmod()) }, index.h("div", { key: '49c35a7228bbc6e9898c499904feb5fb525b2b5c', class: "title" }, "Permissions"), index.h("div", { key: '814edc9c438d956bef13b14bc22733502168c340', class: "file-name", title: this.chmod_target.name }, this.chmod_target.name), index.h("table", { key: 'a4c1b45c1ee830599e7c08a9a44c69df1ac2b201', class: "perm-grid" }, index.h("thead", { key: '99b953b4cf5f3a6aeff766d39b15222e74235a3c' }, index.h("tr", { key: '49d3ae286989915aaca71ba43cb19db357064158' }, index.h("th", { key: '3f3b7fcbeb1b713d29a874a111552f6ff95a811e', "aria-label": "Class" }), index.h("th", { key: '6d18882102b71cb61be8ae93a946f62da7b555bc' }, "Read"), index.h("th", { key: '44aed1177108307db4618680b5e7d28e248cdab6' }, "Write"), index.h("th", { key: 'd6056bed3aab4164768a010c369365c70e67bbbc' }, "Execute"))), index.h("tbody", { key: 'd54ecfe06cade301263977cf1f0a0ba9e3721b5c' }, [
1436
- { label: 'Owner', read: 0o400, write: 0o200, exec: 0o100 },
1437
- { label: 'Group', read: 0o040, write: 0o020, exec: 0o010 },
1438
- { label: 'Other', read: 0o004, write: 0o002, exec: 0o001 },
1439
- ].map((row) => (index.h("tr", { key: row.label }, index.h("th", { scope: "row" }, row.label), [row.read, row.write, row.exec].map((bit) => (index.h("td", { key: bit }, index.h("input", { type: "checkbox", "aria-label": `${row.label} ${bit}`, disabled: this.chmod_busy, checked: (this.chmod_mode & bit) !== 0, onChange: () => this.toggle_chmod_bit(bit) }))))))))), index.h("div", { key: 'a124e9599de6b406d84ba9ffa3a56b3b993179ef', class: "perm-special" }, [
1440
- { label: 'setuid', bit: 0o4000 },
1441
- { label: 'setgid', bit: 0o2000 },
1442
- { label: 'sticky', bit: 0o1000 },
1443
- ].map((special) => (index.h("label", { key: special.label, class: "checkline" }, index.h("input", { type: "checkbox", disabled: this.chmod_busy, checked: (this.chmod_mode & special.bit) !== 0, onChange: () => this.toggle_chmod_bit(special.bit) }), index.h("span", null, special.label))))), index.h("div", { key: '05ab3c8451084b6acdf7ea0e45f71da0f913b08d', class: "perm-octal" }, index.h("label", { key: '5cb748e079c869720361e56c4973eaea82a85bc0', htmlFor: "chmod-octal" }, "Octal"), index.h("input", { key: '652571af51a36c975d8b7432923ef2ab80743480', id: "chmod-octal", class: "dialog-input", type: "text", autocorrect: "off", autocapitalize: "none", autoComplete: "off", spellcheck: false, maxlength: 4, disabled: this.chmod_busy, value: this.chmod_mode.toString(8).padStart(4, '0'), onInput: (event) => this.on_chmod_octal_input(event.target.value) }), index.h("span", { key: '4a789c75be9a941d2adf8de68cfda043c19864cc', class: "perm-preview" }, this.format_permissions(this.chmod_mode, this.chmod_target.kind))), this.chmod_error && index.h("div", { key: 'acb09c9d16146cc0466df1ea6394ff492604c397', class: "dialog-error" }, this.chmod_error), index.h("div", { key: '46c5c4fc154529060b24e335dcd192ed6dc6f75d', class: "modal-actions" }, index.h("button", { key: '2ad9fad876497e4d629c1911fbe29616853a2e59', type: "button", class: "btn secondary", onClick: () => this.close_chmod(), disabled: this.chmod_busy }, "Cancel"), index.h("button", { key: 'c14f7edb08da6d2db078722438e8e06455a076c7', type: "button", class: "btn primary", onClick: () => void this.submit_chmod(), disabled: this.chmod_busy }, this.chmod_busy ? 'Applying...' : 'Apply')))), this.show_editor &&
1444
- index.h("section", { key: 'f040aeca04a6b02af3247c024271fbdc2564a0c4', class: "editor-modal visible" }, index.h("div", { key: '6874ae8a526168be8c2c09ca3f8a1faa52b78027', class: "editor-dialog", role: "dialog", "aria-modal": "true", "aria-label": `Editing ${this.editor_name}`, tabindex: -1, onKeyDown: (event) => {
1445
- if ((event.ctrlKey || event.metaKey) && event.key === 's') {
1446
- event.preventDefault();
1447
- void this.save_editor();
1448
- return;
1449
- }
1450
- this.on_modal_keydown(event, () => this.close_editor());
1451
- } }, index.h("div", { key: '421cbd1bfbde035049ed028c4d05083cc7d8f66f', class: "editor-head" }, index.h("div", { key: '889adcf6e0187963964920b9750531c3fa06cd37', class: "title" }, this.editor_name, this.editor_is_dirty() ? ' *' : ''), index.h("button", { key: 'b14d28ca6a80c9a08277ff20bc0b38fc30ea3869', type: "button", class: "editor-close", onClick: () => this.close_editor(), "aria-label": "Close editor", disabled: this.editor_busy === 'saving' }, "x")), this.editor_busy === 'loading'
1452
- ? index.h("div", { class: "editor-loading" }, "Loading...")
1453
- : index.h("textarea", { class: "editor-text", spellcheck: false, autocorrect: "off", autocapitalize: "none", autoComplete: "off", "aria-label": "File contents", disabled: this.editor_busy === 'saving' || !this.editor_loaded, value: this.editor_text, onInput: (event) => this.editor_text = event.target.value, ref: (el) => this.focus_once(el, this.editorTextEl, (kept) => this.editorTextEl = kept) }), this.editor_error && index.h("div", { key: 'e7c1db037e749fec8970ac2b2be2cb85cfcd85be', class: "dialog-error" }, this.editor_error), this.editor_confirm_discard &&
1454
- index.h("div", { key: '84ca6080e18c4334e87374126b82b816f318cb0d', class: "dialog-error" }, "Unsaved changes. Close anyway?"), index.h("div", { key: '4515e164a418815eccfd9d54d8f96a076616f326', class: "modal-actions" }, this.editor_confirm_discard
1455
- ? index.h("button", { type: "button", class: "btn destructive", onClick: () => this.close_editor(true) }, "Discard")
1456
- : index.h("button", { type: "button", class: "btn secondary", onClick: () => this.close_editor(), disabled: this.editor_busy === 'saving' }, "Close"), index.h("button", { key: 'b1e758ae6fd5de192135d617126c8c6939c62bde', type: "button", class: "btn primary", onClick: () => void this.save_editor(), disabled: !!this.editor_busy || !this.editor_is_dirty() }, this.editor_busy === 'saving' ? 'Saving...' : 'Save'))))));
1457
- }
1458
- static get watchers() { return {
1459
- "nodeId": [{
1460
- "onNodeIdChange": 0
1461
- }],
1462
- "serverId": [{
1463
- "onServerIdChange": 0
1464
- }]
1465
- }; }
1466
- };
1467
- PhirepassSftpClient.style = phirepassSftpClientCss();
1468
-
1469
- exports.phirepass_sftp_client = PhirepassSftpClient;