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