phirepass-widgets 0.0.41 → 0.0.43

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 (38) hide show
  1. package/dist/cjs/{index-Rxdu9QG2.js → index-DTAHGGCM.js} +111 -44
  2. package/dist/cjs/loader.cjs.js +2 -2
  3. package/dist/cjs/phirepass-sftp-client.cjs.entry.js +225 -3
  4. package/dist/cjs/phirepass-terminal.cjs.entry.js +31 -815
  5. package/dist/cjs/phirepass-widgets.cjs.js +3 -3
  6. package/dist/cjs/protocol-C4R_gGQV.js +801 -0
  7. package/dist/collection/collection-manifest.json +1 -1
  8. package/dist/collection/common/protocol.js +20 -0
  9. package/dist/collection/components/phirepass-sftp-client/phirepass-sftp-client.css +142 -1
  10. package/dist/collection/components/phirepass-sftp-client/phirepass-sftp-client.js +509 -1
  11. package/dist/collection/components/phirepass-sftp-client/phirepass-sftp-client.logo.svg +6 -0
  12. package/dist/collection/components/phirepass-sftp-client/phirepass-sftp-client.max.svg +8 -0
  13. package/dist/collection/components/phirepass-terminal/phirepass-terminal.js +13 -21
  14. package/dist/collection/phirepass-channel_bg.wasm +0 -0
  15. package/dist/components/index.js +1 -1
  16. package/dist/components/p-DgZMmpg7.js +1 -0
  17. package/dist/components/phirepass-sftp-client.js +1 -1
  18. package/dist/components/phirepass-terminal.js +5 -5
  19. package/dist/esm/{index-C8ZFkLEv.js → index-D6RLmr6w.js} +111 -44
  20. package/dist/esm/loader.js +3 -3
  21. package/dist/esm/phirepass-sftp-client.entry.js +225 -3
  22. package/dist/esm/phirepass-terminal.entry.js +10 -793
  23. package/dist/esm/phirepass-widgets.js +4 -4
  24. package/dist/esm/protocol-DgZMmpg7.js +796 -0
  25. package/dist/phirepass-widgets/p-4e32fef4.entry.js +49 -0
  26. package/dist/phirepass-widgets/p-79a71767.entry.js +1 -0
  27. package/dist/phirepass-widgets/p-D6RLmr6w.js +2 -0
  28. package/dist/phirepass-widgets/p-DgZMmpg7.js +1 -0
  29. package/dist/phirepass-widgets/phirepass-channel_bg.wasm +0 -0
  30. package/dist/phirepass-widgets/phirepass-widgets.esm.js +1 -1
  31. package/dist/types/common/protocol.d.ts +17 -0
  32. package/dist/types/components/phirepass-sftp-client/phirepass-sftp-client.d.ts +42 -0
  33. package/dist/types/components/phirepass-terminal/phirepass-terminal.d.ts +1 -6
  34. package/dist/types/components.d.ts +97 -1
  35. package/package.json +5 -5
  36. package/dist/phirepass-widgets/p-2f3f0b69.entry.js +0 -49
  37. package/dist/phirepass-widgets/p-376ef3af.entry.js +0 -1
  38. package/dist/phirepass-widgets/p-C8ZFkLEv.js +0 -2
@@ -1,8 +1,8 @@
1
1
  const NAMESPACE = 'phirepass-widgets';
2
- const BUILD = /* phirepass-widgets */ { hotModuleReplacement: false, hydratedSelectorName: "hydrated", lazyLoad: true, prop: true, propChangeCallback: true, updatable: true};
2
+ const BUILD = /* phirepass-widgets */ { hotModuleReplacement: false, hydratedSelectorName: "hydrated", lazyLoad: true, propChangeCallback: true, state: true, updatable: true};
3
3
 
4
4
  /*
5
- Stencil Client Platform v4.43.3 | MIT Licensed | https://stenciljs.com
5
+ Stencil Client Platform v4.43.4 | MIT Licensed | https://stenciljs.com
6
6
  */
7
7
 
8
8
 
@@ -58,7 +58,7 @@ var registerInstance = (lazyInstance, hostRef) => {
58
58
  if (!hostRef) return;
59
59
  lazyInstance.__stencil__getHostRef = () => hostRef;
60
60
  hostRef.$lazyInstance$ = lazyInstance;
61
- if (hostRef.$cmpMeta$.$flags$ & 512 /* hasModernPropertyDecls */ && (BUILD.prop)) {
61
+ if (hostRef.$cmpMeta$.$flags$ & 512 /* hasModernPropertyDecls */ && (BUILD.state)) {
62
62
  reWireGetterSetter(lazyInstance, hostRef);
63
63
  }
64
64
  };
@@ -70,6 +70,9 @@ var registerHost = (hostElement, cmpMeta) => {
70
70
  $instanceValues$: /* @__PURE__ */ new Map(),
71
71
  $serializerValues$: /* @__PURE__ */ new Map()
72
72
  };
73
+ {
74
+ hostRef.$onInstancePromise$ = new Promise((r) => hostRef.$onInstanceResolve$ = r);
75
+ }
73
76
  {
74
77
  hostRef.$onReadyPromise$ = new Promise((r) => hostRef.$onReadyResolve$ = r);
75
78
  hostElement["s-p"] = [];
@@ -380,6 +383,12 @@ var h = (nodeName, vnodeData, ...children) => {
380
383
  if (vnodeData.key) {
381
384
  key = vnodeData.key;
382
385
  }
386
+ {
387
+ const classData = vnodeData.className || vnodeData.class;
388
+ if (classData) {
389
+ vnodeData.class = typeof classData !== "object" ? classData : Object.keys(classData).filter((k) => classData[k]).join(" ");
390
+ }
391
+ }
383
392
  }
384
393
  const vnode = newVNode(nodeName, null);
385
394
  vnode.$attrs$ = vnodeData;
@@ -411,6 +420,31 @@ var newVNode = (tag, text) => {
411
420
  var Host = {};
412
421
  var isHost = (node) => node && node.$tag$ === Host;
413
422
 
423
+ // src/runtime/normalize-watchers.ts
424
+ var normalizeWatchers = (raw) => {
425
+ if (!raw) return void 0;
426
+ const keys = Object.keys(raw);
427
+ if (keys.length === 0) return void 0;
428
+ let hasLegacy = false;
429
+ for (const propName of keys) {
430
+ if (hasLegacy) break;
431
+ for (const h2 of raw[propName]) {
432
+ if (typeof h2 === "string") {
433
+ hasLegacy = true;
434
+ break;
435
+ }
436
+ }
437
+ }
438
+ if (!hasLegacy) return raw;
439
+ const out = {};
440
+ for (const propName of keys) {
441
+ out[propName] = raw[propName].map(
442
+ (h2) => typeof h2 === "string" ? { [h2]: 0 } : h2
443
+ );
444
+ }
445
+ return out;
446
+ };
447
+
414
448
  // src/runtime/parse-property-value.ts
415
449
  var parsePropertyValue = (propValue, propType, isFormAssociated) => {
416
450
  if (propValue != null && !isComplexType(propValue)) {
@@ -458,11 +492,37 @@ var setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialRen
458
492
  return;
459
493
  }
460
494
  let isProp = isMemberInElement(elm, memberName);
461
- memberName.toLowerCase();
462
- if (memberName === "key") ; else if (memberName === "ref") {
495
+ let ln = memberName.toLowerCase();
496
+ if (memberName === "class") {
497
+ const classList = elm.classList;
498
+ const oldClasses = parseClassList(oldValue);
499
+ let newClasses = parseClassList(newValue);
500
+ {
501
+ classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
502
+ classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
503
+ }
504
+ } else if (memberName === "key") ; else if (memberName === "ref") {
463
505
  if (newValue) {
464
506
  queueRefAttachment(newValue, elm);
465
507
  }
508
+ } else if ((!isProp ) && memberName[0] === "o" && memberName[1] === "n") {
509
+ if (memberName[2] === "-") {
510
+ memberName = memberName.slice(3);
511
+ } else if (isMemberInElement(win, ln)) {
512
+ memberName = ln.slice(2);
513
+ } else {
514
+ memberName = ln[2] + memberName.slice(3);
515
+ }
516
+ if (oldValue || newValue) {
517
+ const capture = memberName.endsWith(CAPTURE_EVENT_SUFFIX);
518
+ memberName = memberName.replace(CAPTURE_EVENT_REGEX, "");
519
+ if (oldValue) {
520
+ plt.rel(elm, memberName, oldValue, capture);
521
+ }
522
+ if (newValue) {
523
+ plt.ael(elm, memberName, newValue, capture);
524
+ }
525
+ }
466
526
  } else if (memberName[0] === "a" && memberName.startsWith("attr:")) {
467
527
  const propName = memberName.slice(5);
468
528
  let attrName;
@@ -528,6 +588,18 @@ var setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialRen
528
588
  }
529
589
  }
530
590
  };
591
+ var parseClassListRegex = /\s/;
592
+ var parseClassList = (value) => {
593
+ if (typeof value === "object" && value && "baseVal" in value) {
594
+ value = value.baseVal;
595
+ }
596
+ if (!value || typeof value !== "string") {
597
+ return [];
598
+ }
599
+ return value.split(parseClassListRegex);
600
+ };
601
+ var CAPTURE_EVENT_SUFFIX = "Capture";
602
+ var CAPTURE_EVENT_REGEX = new RegExp(CAPTURE_EVENT_SUFFIX + "$");
531
603
 
532
604
  // src/runtime/vdom/update-element.ts
533
605
  var updateElement = (oldVnode, newVnode, isSvgMode2, isInitialRender) => {
@@ -567,7 +639,6 @@ function sortedAttrNames(attrNames) {
567
639
  );
568
640
  }
569
641
  var hostTagName;
570
- var useNativeShadowDom = false;
571
642
  var isSvgMode = false;
572
643
  var refCallbacksToRemove = [];
573
644
  var refCallbacksToAttach = [];
@@ -576,7 +647,9 @@ var createElm = (oldParentVNode, newParentVNode, childIndex) => {
576
647
  let i2 = 0;
577
648
  let elm;
578
649
  let childNode;
579
- {
650
+ if (newVNode2.$text$ != null) {
651
+ elm = newVNode2.$elm$ = win.document.createTextNode(newVNode2.$text$);
652
+ } else {
580
653
  if (!win.document) {
581
654
  throw new Error("You are trying to render a Stencil component in an environment that doesn't support the DOM.");
582
655
  }
@@ -599,25 +672,6 @@ var createElm = (oldParentVNode, newParentVNode, childIndex) => {
599
672
  elm["s-hn"] = hostTagName;
600
673
  return elm;
601
674
  };
602
- var relocateToHostRoot = (parentElm) => {
603
- plt.$flags$ |= 1 /* isTmpDisconnected */;
604
- const host = parentElm.closest(hostTagName.toLowerCase());
605
- if (host != null) {
606
- const contentRefNode = Array.from(host.__childNodes || host.childNodes).find(
607
- (ref) => ref["s-cr"]
608
- );
609
- const childNodeArray = Array.from(
610
- parentElm.__childNodes || parentElm.childNodes
611
- );
612
- for (const childNode of contentRefNode ? childNodeArray.reverse() : childNodeArray) {
613
- if (childNode["s-sh"] != null) {
614
- insertBefore(host, childNode, contentRefNode != null ? contentRefNode : null);
615
- childNode["s-sh"] = void 0;
616
- }
617
- }
618
- }
619
- plt.$flags$ &= -2 /* isTmpDisconnected */;
620
- };
621
675
  var addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
622
676
  let containerElm = parentElm;
623
677
  let childNode;
@@ -750,20 +804,17 @@ var patch = (oldVNode, newVNode2, isInitialRender = false) => {
750
804
  const elm = newVNode2.$elm$ = oldVNode.$elm$;
751
805
  const oldChildren = oldVNode.$children$;
752
806
  const newChildren = newVNode2.$children$;
753
- const tag = newVNode2.$tag$;
754
- {
807
+ const text = newVNode2.$text$;
808
+ if (text == null) {
755
809
  {
756
- if (tag === "slot" && !useNativeShadowDom) {
757
- if (oldVNode.$name$ !== newVNode2.$name$) {
758
- newVNode2.$elm$["s-sn"] = newVNode2.$name$ || "";
759
- relocateToHostRoot(newVNode2.$elm$.parentElement);
760
- }
761
- }
762
810
  updateElement(oldVNode, newVNode2, isSvgMode);
763
811
  }
764
812
  if (oldChildren !== null && newChildren !== null) {
765
813
  updateChildren(elm, oldChildren, newVNode2, newChildren, isInitialRender);
766
814
  } else if (newChildren !== null) {
815
+ if (oldVNode.$text$ !== null) {
816
+ elm.textContent = "";
817
+ }
767
818
  addVnodes(elm, null, newVNode2, newChildren, 0, newChildren.length - 1);
768
819
  } else if (
769
820
  // don't do this on initial render as it can cause non-hydrated content to be removed
@@ -771,6 +822,8 @@ var patch = (oldVNode, newVNode2, isInitialRender = false) => {
771
822
  ) {
772
823
  removeVnodes(oldChildren, 0, oldChildren.length - 1);
773
824
  } else ;
825
+ } else if (oldVNode.$text$ !== text) {
826
+ elm.data = text;
774
827
  }
775
828
  };
776
829
  var nullifyVNodeRefs = (vNode) => {
@@ -803,7 +856,6 @@ var insertBefore = (parent, newNode, reference, isInitialLoad) => {
803
856
  };
804
857
  var renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
805
858
  const hostElm = hostRef.$hostElement$;
806
- const cmpMeta = hostRef.$cmpMeta$;
807
859
  const oldVNode = hostRef.$vnode$ || newVNode(null, null);
808
860
  const isHostElement = isHost(renderFnResults);
809
861
  const rootVnode = isHostElement ? renderFnResults : h(null, null, renderFnResults);
@@ -819,7 +871,6 @@ var renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
819
871
  rootVnode.$flags$ |= 4 /* isHost */;
820
872
  hostRef.$vnode$ = rootVnode;
821
873
  rootVnode.$elm$ = oldVNode.$elm$ = hostElm.shadowRoot || hostElm ;
822
- useNativeShadowDom = !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) && !(cmpMeta.$flags$ & 128 /* shadowNeedsScopedCss */);
823
874
  patch(oldVNode, rootVnode, isInitialLoad);
824
875
  flushQueuedRefCallbacks();
825
876
  };
@@ -959,6 +1010,9 @@ var postUpdateComponent = (hostRef) => {
959
1010
  safeCall(instance, "componentDidUpdate", void 0, elm);
960
1011
  endPostUpdate();
961
1012
  }
1013
+ {
1014
+ hostRef.$onInstanceResolve$(elm);
1015
+ }
962
1016
  {
963
1017
  if (hostRef.$onRenderResolve$) {
964
1018
  hostRef.$onRenderResolve$();
@@ -1053,7 +1107,7 @@ var proxyComponent = (Cstr, cmpMeta, flags) => {
1053
1107
  if (cmpMeta.$members$ || BUILD.propChangeCallback) {
1054
1108
  {
1055
1109
  if (Cstr.watchers && !cmpMeta.$watchers$) {
1056
- cmpMeta.$watchers$ = Cstr.watchers;
1110
+ cmpMeta.$watchers$ = normalizeWatchers(Cstr.watchers);
1057
1111
  }
1058
1112
  if (Cstr.deserializers && !cmpMeta.$deserializers$) {
1059
1113
  cmpMeta.$deserializers$ = Cstr.deserializers;
@@ -1137,6 +1191,17 @@ var proxyComponent = (Cstr, cmpMeta, flags) => {
1137
1191
  }
1138
1192
  }
1139
1193
  });
1194
+ } else if (flags & 1 /* isElementConstructor */ && memberFlags & 64 /* Method */) {
1195
+ Object.defineProperty(prototype, memberName, {
1196
+ value(...args) {
1197
+ var _a2;
1198
+ const ref = getHostRef(this);
1199
+ return (_a2 = ref == null ? void 0 : ref.$onInstancePromise$) == null ? void 0 : _a2.then(() => {
1200
+ var _a3;
1201
+ return (_a3 = ref.$lazyInstance$) == null ? void 0 : _a3[memberName](...args);
1202
+ });
1203
+ }
1204
+ });
1140
1205
  }
1141
1206
  });
1142
1207
  if ((flags & 1 /* isElementConstructor */)) {
@@ -1168,11 +1233,13 @@ var proxyComponent = (Cstr, cmpMeta, flags) => {
1168
1233
  return;
1169
1234
  }
1170
1235
  const propFlags = members.find(([m]) => m === propName);
1171
- if (propFlags && propFlags[1][0] & 4 /* Boolean */) {
1236
+ const isBooleanTarget = propFlags && propFlags[1][0] & 4 /* Boolean */;
1237
+ const isSpuriousBooleanRemoval = isBooleanTarget && newValue === null && this[propName] === void 0;
1238
+ if (isBooleanTarget) {
1172
1239
  newValue = newValue === null || newValue === "false" ? false : true;
1173
1240
  }
1174
1241
  const propDesc = Object.getOwnPropertyDescriptor(prototype, propName);
1175
- if (newValue != this[propName] && (!propDesc.get || !!propDesc.set)) {
1242
+ if (!isSpuriousBooleanRemoval && newValue != this[propName] && (!propDesc.get || !!propDesc.set)) {
1176
1243
  this[propName] = newValue;
1177
1244
  }
1178
1245
  });
@@ -1213,7 +1280,7 @@ var initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
1213
1280
  }
1214
1281
  if (!Cstr.isProxied) {
1215
1282
  {
1216
- cmpMeta.$watchers$ = Cstr.watchers;
1283
+ cmpMeta.$watchers$ = normalizeWatchers(Cstr.watchers);
1217
1284
  cmpMeta.$serializers$ = Cstr.serializers;
1218
1285
  cmpMeta.$deserializers$ = Cstr.deserializers;
1219
1286
  }
@@ -1366,7 +1433,7 @@ var bootstrapLazy = (lazyBundles, options = {}) => {
1366
1433
  plt.$resourcesUrl$ = new URL(options.resourcesUrl || "./", win.document.baseURI).href;
1367
1434
  lazyBundles.map((lazyBundle) => {
1368
1435
  lazyBundle[1].map((compactMeta) => {
1369
- var _a2, _b, _c;
1436
+ var _a2, _b;
1370
1437
  const cmpMeta = {
1371
1438
  $flags$: compactMeta[0],
1372
1439
  $tagName$: compactMeta[1],
@@ -1377,9 +1444,9 @@ var bootstrapLazy = (lazyBundles, options = {}) => {
1377
1444
  cmpMeta.$members$ = compactMeta[2];
1378
1445
  }
1379
1446
  {
1380
- cmpMeta.$watchers$ = (_a2 = compactMeta[4]) != null ? _a2 : {};
1381
- cmpMeta.$serializers$ = (_b = compactMeta[5]) != null ? _b : {};
1382
- cmpMeta.$deserializers$ = (_c = compactMeta[6]) != null ? _c : {};
1447
+ cmpMeta.$watchers$ = normalizeWatchers(compactMeta[4]);
1448
+ cmpMeta.$serializers$ = (_a2 = compactMeta[5]) != null ? _a2 : {};
1449
+ cmpMeta.$deserializers$ = (_b = compactMeta[6]) != null ? _b : {};
1383
1450
  }
1384
1451
  const tagName = transformTag(cmpMeta.$tagName$);
1385
1452
  const HostElement = class extends HTMLElement {
@@ -1,11 +1,11 @@
1
- import { b as bootstrapLazy } from './index-C8ZFkLEv.js';
2
- export { s as setNonce } from './index-C8ZFkLEv.js';
1
+ import { b as bootstrapLazy } from './index-D6RLmr6w.js';
2
+ export { s as setNonce } from './index-D6RLmr6w.js';
3
3
  import { g as globalScripts } from './app-globals-DQuL1Twl.js';
4
4
 
5
5
  const defineCustomElements = async (win, options) => {
6
6
  if (typeof window === 'undefined') return undefined;
7
7
  await globalScripts();
8
- return bootstrapLazy([["phirepass-sftp-client",[[257,"phirepass-sftp-client"]]],["phirepass-terminal",[[513,"phirepass-terminal",{"terminalOptions":[16],"serverHost":[1,"server-host"],"serverPort":[2,"server-port"],"allowInsecure":[4,"allow-insecure"],"heartbeatInterval":[2,"heartbeat-interval"],"nodeId":[1,"node-id"],"token":[1],"serverId":[1,"server-id"]},null,{"nodeId":[{"onNodeIdChange":0}],"serverId":[{"onServerIdChange":0}]}]]]], options);
8
+ return bootstrapLazy([["phirepass-sftp-client",[[513,"phirepass-sftp-client",{"name":[1],"description":[1],"hideHeader":[4,"hide-header"],"serverHost":[1,"server-host"],"serverPort":[2,"server-port"],"allowInsecure":[4,"allow-insecure"],"heartbeatInterval":[2,"heartbeat-interval"],"nodeId":[1,"node-id"],"token":[1],"serverId":[1,"server-id"],"max":[32],"show_login_screen":[32],"show_login_screen_username":[32],"show_login_screen_password":[32],"maximize":[64],"minimize":[64]},null,{"nodeId":[{"onNodeIdChange":0}],"serverId":[{"onServerIdChange":0}]}]]],["phirepass-terminal",[[513,"phirepass-terminal",{"terminalOptions":[16],"serverHost":[1,"server-host"],"serverPort":[2,"server-port"],"allowInsecure":[4,"allow-insecure"],"heartbeatInterval":[2,"heartbeat-interval"],"nodeId":[1,"node-id"],"token":[1],"serverId":[1,"server-id"]},null,{"nodeId":[{"onNodeIdChange":0}],"serverId":[{"onServerIdChange":0}]}]]]], options);
9
9
  };
10
10
 
11
11
  export { defineCustomElements };
@@ -1,14 +1,236 @@
1
- import { r as registerInstance, h, H as Host } from './index-C8ZFkLEv.js';
1
+ import { r as registerInstance, c as createEvent, h, H as Host } from './index-D6RLmr6w.js';
2
+ import { _ as __wbg_init, C as Channel, a as ConnectionState, P as ProtocolMessageType } from './protocol-DgZMmpg7.js';
2
3
 
3
- const phirepassSftpClientCss = () => `:host{display:block}`;
4
+ const phirepassSftpClientLogoSvg = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoNDYsIDE4NCwgMTM4KSIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiCiAgICBjbGFzcz0ibHVjaWRlIGx1Y2lkZS10ZXJtaW5hbCB3LTMuNSBoLTMuNSB0ZXh0LXByaW1hcnkiPgogICAgPHBvbHlsaW5lIHBvaW50cz0iNCAxNyAxMCAxMSA0IDUiPjwvcG9seWxpbmU+CiAgICA8bGluZSB4MT0iMTIiIHgyPSIyMCIgeTE9IjE5IiB5Mj0iMTkiPjwvbGluZT4KPC9zdmc+Cg==';
5
+
6
+ const phirepassSftpClientMaxSvg = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIgogICAgc3Ryb2tlPSJyZ2IoMTE1LCAxMjMsIDE0MCkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIgogICAgY2xhc3M9Imx1Y2lkZSBsdWNpZGUtbWF4aW1pemUyIHctMyBoLTMiPgogICAgPHBvbHlsaW5lIHBvaW50cz0iMTUgMyAyMSAzIDIxIDkiPjwvcG9seWxpbmU+CiAgICA8cG9seWxpbmUgcG9pbnRzPSI5IDIxIDMgMjEgMyAxNSI+PC9wb2x5bGluZT4KICAgIDxsaW5lIHgxPSIyMSIgeDI9IjE0IiB5MT0iMyIgeTI9IjEwIj48L2xpbmU+CiAgICA8bGluZSB4MT0iMyIgeDI9IjEwIiB5MT0iMjEiIHkyPSIxNCI+PC9saW5lPgo8L3N2Zz4K';
7
+
8
+ const phirepassSftpClientCss = () => `:host{--radius:0.375rem;--card:220 18% 10%;--border:220 15% 18%;--primary:160 60% 45%;--muted-foreground:220 10% 50%;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;.listing{flex:1;display:flex;flex-direction:column;justify-content:space-between;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))}}}}footer{height:25px;background:rgba(28, 31, 38, 0.6);border-top:1px solid hsl(var(--border))}}.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)}.form{display:flex;flex-direction:column;background:hsl(var(--card));width:200px;position:relative;background-color:rgba(21, 24, 30, 0.95);border:1px solid hsl(var(--border));padding:20px;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}}}:host(.max){height:100vh;width:100vw;position:fixed;top:0;left:0;z-index:9999}`;
4
9
 
5
10
  const PhirepassSftpClient = class {
6
11
  constructor(hostRef) {
7
12
  registerInstance(this, hostRef);
13
+ this.maximizeEvent = createEvent(this, "maximize");
14
+ this.connectionStateChanged = createEvent(this, "connectionStateChanged");
15
+ }
16
+ channel;
17
+ domReady = false;
18
+ runtimeReady = false;
19
+ connected = false;
20
+ // private inputMode: InputMode = InputMode.Default;
21
+ // private session_id?: number;
22
+ // private usernameBuffer = "";
23
+ // private passwordBuffer = "";
24
+ name = 'SFTP';
25
+ description = 'Client';
26
+ hideHeader = false;
27
+ serverHost = "phirepass.com";
28
+ serverPort = 443;
29
+ allowInsecure = false;
30
+ heartbeatInterval = 30_000;
31
+ nodeId;
32
+ token;
33
+ onNodeIdChange(newValue, _oldValue) {
34
+ // Handle the change in node_id here
35
+ // console.log(`node_id changed from ${oldValue} to ${newValue}`);
36
+ // Always clear local session state and reset terminal view
37
+ this.reset_session_state();
38
+ // this.terminal.reset();
39
+ // Close existing comms if connected
40
+ if (this.channel && this.channel.is_connected()) {
41
+ this.close_comms();
42
+ }
43
+ // Open new comms for the updated node
44
+ if (newValue) {
45
+ this.open_comms();
46
+ this.channel.connect();
47
+ }
48
+ }
49
+ serverId;
50
+ onServerIdChange(_newValue, _oldValue) {
51
+ this.onNodeIdChange(this.nodeId, this.nodeId);
52
+ }
53
+ maximizeEvent;
54
+ async maximize() {
55
+ this.max = !this.max;
56
+ }
57
+ async minimize() {
58
+ this.max = false;
59
+ }
60
+ connectionStateChanged;
61
+ max = false;
62
+ show_login_screen = false;
63
+ show_login_screen_username = false;
64
+ show_login_screen_password = false;
65
+ toggle_max() {
66
+ this.maximizeEvent?.emit(!this.max);
67
+ }
68
+ async connectedCallback() {
69
+ await __wbg_init();
70
+ // this.setup_terminal();
71
+ this.open_comms();
72
+ this.runtimeReady = true;
73
+ if (!this.nodeId) {
74
+ console.warn('Prop node_id is not set. Cannot connect to terminal.');
75
+ return;
76
+ }
77
+ this.try_connect();
78
+ }
79
+ componentDidLoad() {
80
+ this.domReady = true;
81
+ this.try_connect();
82
+ }
83
+ async disconnectedCallback() {
84
+ // if (this.resizeDebounceHandle) {
85
+ // clearTimeout(this.resizeDebounceHandle);
86
+ // this.resizeDebounceHandle = undefined;
87
+ // }
88
+ //
89
+ // if (this.resizeObserver) {
90
+ // this.resizeObserver.disconnect();
91
+ // }
92
+ this.connected = false;
93
+ this.domReady = false;
94
+ this.runtimeReady = false;
95
+ this.close_comms();
96
+ // this.destroy_terminal();
97
+ }
98
+ connect() {
99
+ this.connected = true;
100
+ this.channel.connect();
101
+ // const container = this.containerEl;
102
+ // console.log('Attempting to connect terminal to container:', container);
103
+ // if (container) {
104
+ // this.terminal.open(container);
105
+ // console.log('Terminal opened in container');
106
+ // this.connected = true;
107
+ // this.fit_terminal_safely();
108
+ // this.terminal.focus();
109
+ // this.terminal.onData(this.handle_terminal_data.bind(this));
110
+ // this.channel.connect();
111
+ // this.setup_resize_observer();
112
+ // console.log('Terminal connected and ready');
113
+ // }
114
+ }
115
+ try_connect() {
116
+ if (this.connected || !this.domReady || !this.runtimeReady) {
117
+ return;
118
+ }
119
+ if (!this.channel) {
120
+ return;
121
+ }
122
+ this.connect();
123
+ }
124
+ create_web_socket_endpoint() {
125
+ const protocol = this.allowInsecure ? 'ws' : 'wss';
126
+ if (!this.allowInsecure && this.serverPort === 443) {
127
+ return `${protocol}://${this.serverHost}`;
128
+ }
129
+ if (this.allowInsecure && this.serverPort === 80) {
130
+ return `${protocol}://${this.serverHost}`;
131
+ }
132
+ return `${protocol}://${this.serverHost}:${this.serverPort}`;
133
+ }
134
+ handle_error(_error_) {
135
+ //
136
+ }
137
+ handle_auth_success(_auth_) {
138
+ this.clear_creds_buffer();
139
+ this.channel.start_heartbeat(this.heartbeatInterval <= 15_000 ? 30_000 : this.heartbeatInterval);
140
+ this.channel.open_sftp_tunnel(this.nodeId);
141
+ }
142
+ handle_tunnel_opened(_web_) {
143
+ // this.session_id = web.sid;
144
+ // this.terminal.reset();
145
+ // this.fit_terminal_safely();
146
+ // this.send_ssh_terminal_resize();
147
+ }
148
+ handle_tunnel_data(_web_) {
149
+ // TODO
150
+ }
151
+ handle_tunnel_closed(_web_) {
152
+ // this.session_id = undefined;
153
+ // this.inputMode = InputMode.Default;
154
+ this.clear_creds_buffer();
155
+ // this.terminal.reset();
156
+ // this.terminal.writeln("Connection closed.");
157
+ this.close_comms();
158
+ }
159
+ open_comms() {
160
+ if (this.serverId) {
161
+ this.channel = new Channel(`${this.create_web_socket_endpoint()}/api/web/ws`, this.nodeId, this.serverId);
162
+ }
163
+ else {
164
+ this.channel = new Channel(`${this.create_web_socket_endpoint()}/api/web/ws`, this.nodeId);
165
+ }
166
+ this.channel.on_connection_open(() => {
167
+ this.connectionStateChanged.emit([ConnectionState.Connected]);
168
+ this.channel.authenticate(this.token, this.nodeId);
169
+ });
170
+ this.channel.on_connection_close(() => {
171
+ this.connectionStateChanged.emit([ConnectionState.Disconnected]);
172
+ // this.terminal.reset();
173
+ });
174
+ this.channel.on_connection_error((err) => {
175
+ this.connectionStateChanged.emit([ConnectionState.Error, err]);
176
+ });
177
+ this.channel.on_connection_message((_raw_) => {
178
+ // console.log('>> raw message received', raw);
179
+ });
180
+ this.channel.on_protocol_message((msg) => {
181
+ const { web } = msg.data;
182
+ switch (web.type) {
183
+ case ProtocolMessageType.Error:
184
+ this.handle_error(web);
185
+ break;
186
+ case ProtocolMessageType.AuthSuccess:
187
+ this.handle_auth_success(web);
188
+ break;
189
+ case ProtocolMessageType.TunnelOpened:
190
+ this.handle_tunnel_opened(web);
191
+ break;
192
+ case ProtocolMessageType.TunnelClosed:
193
+ this.handle_tunnel_closed(web);
194
+ break;
195
+ case ProtocolMessageType.TunnelData:
196
+ this.handle_tunnel_data(web);
197
+ break;
198
+ default:
199
+ console.warn('Unknown protocol message type:', web);
200
+ }
201
+ });
202
+ }
203
+ close_comms() {
204
+ this.channel.stop_heartbeat();
205
+ this.channel.disconnect();
206
+ }
207
+ clear_creds_buffer() {
208
+ // this.usernameBuffer = "";
209
+ // this.passwordBuffer = "";
210
+ }
211
+ reset_session_state() {
212
+ // this.session_id = undefined;
213
+ // this.inputMode = InputMode.Default;
214
+ this.clear_creds_buffer();
8
215
  }
9
216
  render() {
10
- return (h(Host, { key: 'd03ff09e3636f79d699c7462e121abe7d08c6683' }, h("slot", { key: 'bd7285e70384558e4cbf0600b89a57fa4ec3406d' })));
217
+ return (h(Host, { key: 'ac63e2c701cd09a605d0aaa7396eaec16ff9c3bc', class: {
218
+ 'default': !this.max,
219
+ 'max': this.max,
220
+ } }, h("section", { key: '253dfc510c62ee57a96d574af993e8017475a0c2', class: "listing" }, !this.hideHeader &&
221
+ h("header", { key: '215ddf76ba55641892fc9a758077ba8d1f3a6671' }, h("section", { key: '49541a8d31d8c61e2df84c60348f7426fddec67c', class: "title" }, h("img", { key: '1a86ba6b3de92b35cbd5b1bacfdfee2da6fa6766', src: phirepassSftpClientLogoSvg, alt: "SFTP Client" }), h("div", { key: '38d90384978acc8b323ca4c396db7bda54320059', class: "text" }, h("div", { key: 'a94b3fd21025000b620b2bb85aec87198e575bfa', class: "name" }, this.name), h("div", { key: '072c41dc8d05faf77929f8c128bb97b64d8835bf', class: "description" }, this.description))), h("section", { key: '46e575f4ce5f2da0913d2f3aebe025540f1f3688', class: "actions" }, h("div", { key: 'f92d66ab7ab5e9c25a29037c60709c54623194be', class: "action", onClick: () => this.toggle_max() }, h("img", { key: 'e115204a83336fc4b49a30551208b727c3f33be9', src: phirepassSftpClientMaxSvg, alt: "Maximize" })))), h("main", { key: 'c6bf5ab4e5aa46dcba8e50ec1a9c2feb1f55ea02' }), h("footer", { key: 'ac67a3e0966e3f04bee019162f8174aae58cbf1a' })), h("section", { key: '07e83117470f7f226328703b18f836bd4358cfe9', class: {
222
+ 'creds': true,
223
+ 'blurred': this.show_login_screen,
224
+ } }, this.show_login_screen && h("form", { key: '808209eaba50f10a8ef96163972ad36ea9e3d3e2', class: "form" }, h("div", { key: '9e26efeac2f17d6b4168e1a77da6ef61d325f6e3' }, "SFTP Connection"), h("div", { key: 'f9badb92d4434a16916429a2bedb6e38d2ae647c' }, h("div", { key: '9fb267ba7828cd950b327a17e0ee803dc399c80b' }, "Username"), h("input", { key: '65b34c14292b0bde408861e791f3baa99c4c9a02', type: "text", placeholder: "" })), h("div", { key: 'f1f9def8290dfcde9beff0f61092f6020580b72c' }, h("div", { key: '1c89b71c4126299b7e8e421b05761d2b0424d4ed' }, "Password"), h("input", { key: '17364976158ddaacbb55ed17ee09ec242bcbdce7', type: "password", placeholder: "" })), h("div", { key: '9362acdf153ceeba3c8e8cee0518cf2baeec27e0' }, h("button", { key: 'ebf6c205276a7c3ff34c13e148978be61044ff7a' }, "Connect"))))));
11
225
  }
226
+ static get watchers() { return {
227
+ "nodeId": [{
228
+ "onNodeIdChange": 0
229
+ }],
230
+ "serverId": [{
231
+ "onServerIdChange": 0
232
+ }]
233
+ }; }
12
234
  };
13
235
  PhirepassSftpClient.style = phirepassSftpClientCss();
14
236