@64mb/freelens-power 2.21.6 → 2.21.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/renderer.js CHANGED
@@ -16256,7 +16256,7 @@ function startClusterIconOverlay() {
16256
16256
  const owned = /* @__PURE__ */ new Map();
16257
16257
  const webLinkAvatars = /* @__PURE__ */ new Set();
16258
16258
  const style = document.createElement("style");
16259
- style.textContent = `[data-power-cluster-icon]{position:relative!important;color:transparent!important;background:transparent!important}[data-power-cluster-icon]>:not([data-power-icon-image]){visibility:hidden!important}[data-power-icon-image]{position:absolute;inset:0;width:100%;height:100%;border-radius:inherit;pointer-events:none;object-fit:cover}[data-power-web-link-avatar]>img{width:16px;height:16px;margin:auto;object-fit:contain}`;
16259
+ style.textContent = `[data-power-cluster-icon]{position:relative!important;color:transparent!important;background:transparent!important}[data-power-cluster-icon]>:not([data-power-icon-image]):not([data-power-hotbar-number]){visibility:hidden!important}[data-power-icon-image]{position:absolute;inset:0;width:100%;height:100%;border-radius:inherit;pointer-events:none;object-fit:cover}[data-power-web-link-avatar]>img{width:16px;height:16px;margin:auto;object-fit:contain}`;
16260
16260
  document.head.append(style);
16261
16261
  let stopped = false;
16262
16262
  const update = () => {
@@ -21246,7 +21246,7 @@ function startExtensionUpdateNotifications() {
21246
21246
  };
21247
21247
  const started = () => {
21248
21248
  attempt = {
21249
- version: current?.installedVersion ?? "2.21.6",
21249
+ version: current?.installedVersion ?? "2.21.7",
21250
21250
  startedAt: Date.now()
21251
21251
  };
21252
21252
  try {
@@ -26736,6 +26736,53 @@ function startHostPreferencesStyles() {
26736
26736
  style.remove();
26737
26737
  };
26738
26738
  }
26739
+ // src/renderer/hotbar-frame-shortcuts.ts
26740
+ var channel = "freelens-power:hotbar-shortcut";
26741
+ function rendererOrigin(value, cluster = false) {
26742
+ try {
26743
+ const url = new URL(value);
26744
+ if (url.protocol === "https:" && !url.username && !url.password && (cluster ? /^[a-z0-9-]+\.renderer\.freelens\.app$/.test(url.hostname) : /^(?:[a-z0-9-]+\.)?renderer\.freelens\.app$/.test(url.hostname))) return url.origin;
26745
+ } catch {}
26746
+ }
26747
+ function isShortcut(value) {
26748
+ if (!value || typeof value !== "object") return false;
26749
+ const data = value;
26750
+ return Object.keys(data).length === 4 && data.channel === channel && typeof data.code === "string" && /^Digit[0-9]$/.test(data.code) && typeof data.metaKey === "boolean" && typeof data.ctrlKey === "boolean" && !(data.metaKey && data.ctrlKey) && !(data.code === "Digit0" && (data.metaKey || data.ctrlKey));
26751
+ }
26752
+ function startHotbarFrameShortcuts(onShortcut, context = window) {
26753
+ if (context.parent !== context) return () => {};
26754
+ const listener = (event) => {
26755
+ if (!isShortcut(event.data) || !rendererOrigin(event.origin, true)) return;
26756
+ const frame = Array.from(context.document.querySelectorAll("#lens-views > iframe[id^=\"cluster-frame-\"]")).find((candidate) => candidate.contentWindow === event.source);
26757
+ if (!frame || context.document.activeElement !== frame || rendererOrigin(frame.src, true) !== event.origin) return;
26758
+ for (let node = frame; node; node = node.parentElement) {
26759
+ const style = context.getComputedStyle(node);
26760
+ if (node.hidden || node.classList.contains("hidden") || style.display === "none" || style.visibility === "hidden") return;
26761
+ }
26762
+ const { code, metaKey, ctrlKey } = event.data;
26763
+ onShortcut({
26764
+ code,
26765
+ metaKey,
26766
+ ctrlKey
26767
+ });
26768
+ };
26769
+ context.addEventListener("message", listener);
26770
+ return () => context.removeEventListener("message", listener);
26771
+ }
26772
+ function forwardHotbarShortcut(event, context = window) {
26773
+ if (context.parent === context || !rendererOrigin(context.location.origin, true) || event.defaultPrevented || event.repeat || event.isComposing || event.altKey || event.shiftKey) return false;
26774
+ const data = {
26775
+ channel,
26776
+ code: event.code,
26777
+ metaKey: event.metaKey,
26778
+ ctrlKey: event.ctrlKey
26779
+ };
26780
+ if (!isShortcut(data)) return false;
26781
+ const parentOrigin = rendererOrigin(context.document.referrer || context.location.ancestorOrigins?.[0] || "");
26782
+ if (!parentOrigin) return false;
26783
+ context.parent.postMessage(data, parentOrigin);
26784
+ return true;
26785
+ }
26739
26786
  // src/renderer/hotbar-name.tsx
26740
26787
  function startHotbarName() {
26741
26788
  const preferences = PowerPreferencesStore.getInstanceOrCreate();
@@ -26743,11 +26790,12 @@ function startHotbarName() {
26743
26790
  let count = 0;
26744
26791
  let stopped = false;
26745
26792
  let refreshing = false;
26793
+ const seenSearches = /* @__PURE__ */ new WeakSet();
26746
26794
  const numbers = /* @__PURE__ */ new Map();
26747
26795
  const owned = /* @__PURE__ */ new Map();
26748
26796
  const style = document.createElement("style");
26749
26797
  style.textContent = `[data-power-hotbar-name]{position:relative;z-index:1;flex-shrink:0;width:100%;min-width:0;padding:6px;box-sizing:border-box;text-align:center;color:var(--settingsColor);font-size:10px;line-height:16px}[data-power-hotbar-name] span{display:block;padding:1px 4px;border:1px solid var(--borderColor);border-radius:4px;background:var(--secondaryBackground);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}`;
26750
- style.textContent += "[data-power-hotbar-numbered]{position:relative}[data-power-hotbar-number]{position:absolute;right:1px;top:1px;z-index:3;display:grid;place-items:center;min-width:12px;height:12px;padding:0 2px;box-sizing:border-box;border:1px solid var(--borderColor);border-radius:3px;background:var(--mainBackground);color:var(--textColorAccent);font:500 8px/10px system-ui;pointer-events:none}";
26798
+ style.textContent += "[data-power-hotbar-numbered]{position:relative}[data-power-hotbar-number]{position:absolute;left:100%;top:2px;transform:translateX(-50%);z-index:3;display:flex;align-items:center;justify-content:center;width:14px;height:14px;padding:0;box-sizing:border-box;border:1px solid var(--borderColor);border-radius:3px;background:var(--mainBackground);color:var(--textColorAccent);font:500 9px/1 system-ui;font-variant-numeric:tabular-nums;pointer-events:none}";
26751
26799
  document.head.append(style);
26752
26800
  const remove = (selector) => {
26753
26801
  const entry = owned.get(selector);
@@ -26757,9 +26805,16 @@ function startHotbarName() {
26757
26805
  owned.delete(selector);
26758
26806
  };
26759
26807
  const update = () => {
26760
- const icons = preferences.hotbarItemShortcuts !== false ? Array.from(document.querySelectorAll(".HotbarMenu [id^=\"hotbarIcon-\"]")).slice(0, 9) : [];
26808
+ for (const input of document.querySelectorAll("[data-testid^=\"catalog-list-for-\"] > .header .SearchInput input")) {
26809
+ if (seenSearches.has(input)) continue;
26810
+ seenSearches.add(input);
26811
+ if ((preferences.hotbarShortcuts !== false || preferences.hotbarItemShortcuts !== false) && document.activeElement === input) input.blur();
26812
+ }
26813
+ const allIcons = Array.from(document.querySelectorAll(".HotbarMenu [id^=\"hotbarIcon-\"]"));
26814
+ const icons = preferences.hotbarItemShortcuts !== false ? [...allIcons.slice(0, 9), ...allIcons.length > 9 ? [allIcons[allIcons.length - 1]] : []] : [];
26761
26815
  for (const [icon, badge] of numbers) {
26762
26816
  if (icons.includes(icon)) continue;
26817
+ badge.parentElement?.removeAttribute("data-power-hotbar-numbered");
26763
26818
  badge.remove();
26764
26819
  icon.removeAttribute("data-power-hotbar-numbered");
26765
26820
  numbers.delete(icon);
@@ -26771,11 +26826,15 @@ function startHotbarName() {
26771
26826
  badge.setAttribute("data-power-hotbar-number", "");
26772
26827
  badge.setAttribute("aria-hidden", "true");
26773
26828
  numbers.set(icon, badge);
26774
- icon.setAttribute("data-power-hotbar-numbered", "");
26775
26829
  }
26776
- const label = String(index + 1);
26830
+ const label = index === 9 ? "0" : String(index + 1);
26777
26831
  if (badge.textContent !== label) badge.textContent = label;
26778
- if (badge.parentElement !== icon) icon.append(badge);
26832
+ const wrapper = icon.parentElement?.matches("[class*=\"HotbarIcon\"]") ? icon.parentElement : icon;
26833
+ wrapper.setAttribute("data-power-hotbar-numbered", "");
26834
+ if (badge.parentElement !== wrapper) wrapper.append(badge);
26835
+ const markerBounds = wrapper.querySelector(":scope > .Icon[class*=\"badge\"]")?.getBoundingClientRect();
26836
+ const left = markerBounds?.width ? `${markerBounds.left + markerBounds.width / 2 - wrapper.getBoundingClientRect().left}px` : "100%";
26837
+ if (badge.style.left !== left) badge.style.left = left;
26779
26838
  });
26780
26839
  const targets = /* @__PURE__ */ new Set();
26781
26840
  for (const badge of count > 1 ? document.querySelectorAll(`.HotbarMenu [data-testid^="${prefix}"]`) : []) {
@@ -26825,7 +26884,11 @@ function startHotbarName() {
26825
26884
  childList: true,
26826
26885
  subtree: true,
26827
26886
  attributes: true,
26828
- attributeFilter: ["data-testid"]
26887
+ attributeFilter: [
26888
+ "data-testid",
26889
+ "id",
26890
+ "class"
26891
+ ]
26829
26892
  });
26830
26893
  refreshCount();
26831
26894
  const keydown = (event) => {
@@ -26833,15 +26896,21 @@ function startHotbarName() {
26833
26896
  const itemShortcut = !event.metaKey && !event.ctrlKey;
26834
26897
  if ((itemShortcut ? preferences.hotbarItemShortcuts : preferences.hotbarShortcuts) === false) return;
26835
26898
  if (event.defaultPrevented || event.repeat || event.isComposing || event.altKey || event.shiftKey || !itemShortcut && (mac ? !event.metaKey || event.ctrlKey : !event.ctrlKey || event.metaKey)) return;
26836
- const digit = /^Digit([1-9])$/.exec(event.code);
26837
- if (!digit) return;
26899
+ const digit = /^Digit([0-9])$/.exec(event.code);
26900
+ if (!digit || !itemShortcut && digit[1] === "0") return;
26838
26901
  const editable = "input, textarea, select, [contenteditable]:not([contenteditable=\"false\"]), [role=\"textbox\"], [role=\"combobox\"], .monaco-editor, .xterm, .cm-editor, .CodeMirror";
26839
- if (!(!itemShortcut && event.target instanceof HTMLInputElement && event.target.matches("[data-testid^=\"catalog-list-for-\"] > .header .SearchInput input")) && event.composedPath().some((node) => node instanceof Element && node.closest(editable))) return;
26902
+ if (event.composedPath().some((node) => node instanceof Element && node.closest(editable))) return;
26840
26903
  if (document.querySelector(".Dialog.modal, [aria-modal=\"true\"], .SettingLayout, [class*=\"command-container-module__CommandContainer--\"]")) return;
26904
+ if (itemShortcut && document.querySelector(".Menu.portal, .HotbarMenu .isDragging")) return;
26905
+ if (forwardHotbarShortcut(event)) {
26906
+ event.preventDefault();
26907
+ event.stopPropagation();
26908
+ return;
26909
+ }
26841
26910
  const target = Number(digit[1]);
26842
26911
  if (itemShortcut) {
26843
- if (document.querySelector(".Menu.portal, .HotbarMenu .isDragging")) return;
26844
- const icon = document.querySelectorAll(".HotbarMenu [id^=\"hotbarIcon-\"]")[target - 1];
26912
+ const icons = document.querySelectorAll(".HotbarMenu [id^=\"hotbarIcon-\"]");
26913
+ const icon = icons[target === 0 ? icons.length - 1 : target - 1];
26845
26914
  if (!icon || icon.matches("[aria-disabled=\"true\"], [disabled], [class*=\"disabled\"]")) return;
26846
26915
  event.preventDefault();
26847
26916
  event.stopPropagation();
@@ -26857,15 +26926,24 @@ function startHotbarName() {
26857
26926
  const arrow = arrows[target > current ? 1 : 0];
26858
26927
  for (let step = 0; step < Math.abs(target - current); step++) arrow.click();
26859
26928
  };
26929
+ const stopFrameShortcuts = startHotbarFrameShortcuts((shortcut) => {
26930
+ document.dispatchEvent(new KeyboardEvent("keydown", {
26931
+ ...shortcut,
26932
+ bubbles: true,
26933
+ cancelable: true
26934
+ }));
26935
+ });
26860
26936
  document.addEventListener("keydown", keydown);
26861
26937
  const stopItemPreference = reaction(() => preferences.hotbarItemShortcuts, update, { fireImmediately: true });
26862
26938
  const timer = setInterval(() => void refreshCount(), 2e3);
26863
26939
  return () => {
26864
26940
  stopped = true;
26865
26941
  document.removeEventListener("keydown", keydown);
26942
+ stopFrameShortcuts();
26866
26943
  clearInterval(timer);
26867
26944
  stopItemPreference();
26868
26945
  for (const [icon, badge] of numbers) {
26946
+ badge.parentElement?.removeAttribute("data-power-hotbar-numbered");
26869
26947
  badge.remove();
26870
26948
  icon.removeAttribute("data-power-hotbar-numbered");
26871
26949
  }
@@ -26878,6 +26956,23 @@ function startHotbarName() {
26878
26956
  // src/common/kubeconfig-editor.ts
26879
26957
  var KUBECONFIG_EDITOR_CHANNEL = "freelens-power:kubeconfig-editor";
26880
26958
  // src/renderer/kubeconfig-editor.tsx
26959
+ function actionLabel(label, material) {
26960
+ return /* @__PURE__ */ jsxs("span", {
26961
+ style: {
26962
+ display: "inline-flex",
26963
+ alignItems: "center",
26964
+ gap: 6
26965
+ },
26966
+ children: [/* @__PURE__ */ jsx$1("span", {
26967
+ "aria-hidden": "true",
26968
+ style: { display: "inline-flex" },
26969
+ children: /* @__PURE__ */ jsx$1(Renderer$1.Component.Icon, {
26970
+ material,
26971
+ size: 16
26972
+ })
26973
+ }), label]
26974
+ });
26975
+ }
26881
26976
  var KubeconfigEditor = observer(function KubeconfigEditor({ clusterId, onClose }) {
26882
26977
  const [snapshot, setSnapshot] = useState();
26883
26978
  const [text, setText] = useState("");
@@ -26993,7 +27088,7 @@ var KubeconfigEditor = observer(function KubeconfigEditor({ clusterId, onClose }
26993
27088
  marginTop: 16
26994
27089
  },
26995
27090
  children: [/* @__PURE__ */ jsx$1(Renderer$1.Component.Button, {
26996
- label: "Reload",
27091
+ label: actionLabel("Reload", "refresh"),
26997
27092
  disabled: busy,
26998
27093
  onClick: () => {
26999
27094
  if (dirty) {
@@ -27016,12 +27111,12 @@ var KubeconfigEditor = observer(function KubeconfigEditor({ clusterId, onClose }
27016
27111
  }
27017
27112
  }),
27018
27113
  /* @__PURE__ */ jsx$1(Renderer$1.Component.Button, {
27019
- label: discard ? "Keep editing" : "Close",
27114
+ label: actionLabel(discard ? "Keep editing" : "Close", discard ? "edit" : "close"),
27020
27115
  disabled: busy,
27021
27116
  onClick: close
27022
27117
  }),
27023
27118
  /* @__PURE__ */ jsx$1(Renderer$1.Component.Button, {
27024
- label: "Save",
27119
+ label: actionLabel("Save", "save"),
27025
27120
  primary: true,
27026
27121
  disabled: busy || !!readOnly || !dirty,
27027
27122
  onClick: () => void save()
@@ -41352,7 +41447,7 @@ var OtherPreferences = observer(() => {
41352
41447
  children: "Hotbar item shortcuts"
41353
41448
  }), /* @__PURE__ */ jsx$1("div", {
41354
41449
  className: "power-settings-hint",
41355
- children: "Show number badges and open hotbar items with 1-9 outside input fields."
41450
+ children: "Show number badges and open hotbar items with 1-9 or the last item with 0 outside input fields."
41356
41451
  })] }),
41357
41452
  /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx$1(Renderer$1.Component.Switch, {
41358
41453
  checked: monitoring.resourceSearchEnabled,