replicas-cli 0.2.333 → 0.2.335

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 (2) hide show
  1. package/dist/index.mjs +34 -2
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -9537,13 +9537,13 @@ var HOOK_EXEC_MAX_BUFFER_BYTES = 10 * 1024 * 1024;
9537
9537
  var REPLICAS_CONFIG_FILENAMES = ["replicas.json", "replicas.yaml", "replicas.yml"];
9538
9538
 
9539
9539
  // ../shared/src/cli-version.ts
9540
- var CLI_VERSION = "0.2.333";
9540
+ var CLI_VERSION = "0.2.335";
9541
9541
 
9542
9542
  // ../shared/src/engine/environment.ts
9543
9543
  var DESKTOP_NOVNC_PORT = 6080;
9544
9544
  function getDesktopViewerUrl(publicUrl) {
9545
9545
  const url = new URL(`${publicUrl.replace(/\/$/, "")}/`);
9546
- url.searchParams.set("v", "11");
9546
+ url.searchParams.set("v", "12");
9547
9547
  return url.toString();
9548
9548
  }
9549
9549
  var DESKTOP_VIEWER_WIDTH = 1920;
@@ -15743,6 +15743,15 @@ async function computerBrowserCommand(options = {}) {
15743
15743
  pages: pageResults
15744
15744
  }, null, 2));
15745
15745
  }
15746
+ var DESKTOP_POINT_JS = `
15747
+ const desktopPoint = (rect) => {
15748
+ const borderX = Math.max(0, (window.outerWidth - window.innerWidth) / 2);
15749
+ const topChrome = Math.max(0, window.outerHeight - window.innerHeight - borderX);
15750
+ return {
15751
+ x: Math.round(window.screenX + borderX + rect.x + rect.width / 2),
15752
+ y: Math.round(window.screenY + topChrome + rect.y + rect.height / 2),
15753
+ };
15754
+ };`;
15746
15755
  function buildBrowserClickExpression(query, options) {
15747
15756
  return `(() => {
15748
15757
  const query = ${JSON.stringify(query)};
@@ -15755,6 +15764,7 @@ function buildBrowserClickExpression(query, options) {
15755
15764
  return rect.width > 0 && rect.height > 0 && style.visibility !== 'hidden' && style.display !== 'none';
15756
15765
  };
15757
15766
  const label = (el) => normalize(el.innerText || el.value || el.getAttribute('aria-label') || el.getAttribute('title') || el.getAttribute('placeholder') || el.href || el.id || el.name || el.tagName);
15767
+ ${DESKTOP_POINT_JS}
15758
15768
  const matches = (text) => {
15759
15769
  const haystack = text.toLowerCase();
15760
15770
  const needle = query.toLowerCase();
@@ -15789,6 +15799,7 @@ function buildBrowserClickExpression(query, options) {
15789
15799
  type: el.getAttribute('type') || null,
15790
15800
  text,
15791
15801
  href: el.href || null,
15802
+ desktopPoint: desktopPoint(rect),
15792
15803
  rect: {
15793
15804
  x: Math.round(rect.x),
15794
15805
  y: Math.round(rect.y),
@@ -15800,6 +15811,21 @@ function buildBrowserClickExpression(query, options) {
15800
15811
  };
15801
15812
  })()`;
15802
15813
  }
15814
+ function browserActionPoint(result) {
15815
+ if (typeof result !== "object" || result === null) return null;
15816
+ const action = "result" in result ? result.result : result;
15817
+ if (typeof action !== "object" || action === null || !("desktopPoint" in action)) return null;
15818
+ const point = action.desktopPoint;
15819
+ if (typeof point !== "object" || point === null) return null;
15820
+ const x = "x" in point ? point.x : void 0;
15821
+ const y = "y" in point ? point.y : void 0;
15822
+ if (typeof x !== "number" || typeof y !== "number" || !Number.isFinite(x) || !Number.isFinite(y)) return null;
15823
+ const dimensions = getDisplayDimensions();
15824
+ return {
15825
+ x: clamp(Math.round(x), 0, dimensions.width),
15826
+ y: clamp(Math.round(y), 0, dimensions.height)
15827
+ };
15828
+ }
15803
15829
  async function computerBrowserClickCommand(query, options = {}) {
15804
15830
  const page = await selectChromePage(options);
15805
15831
  const index = options.index ? parseCoord(options.index, "--index") : 0;
@@ -15808,6 +15834,8 @@ async function computerBrowserClickCommand(query, options = {}) {
15808
15834
  page.webSocketDebuggerUrl,
15809
15835
  buildBrowserClickExpression(query, { exact: !!options.exact, index })
15810
15836
  );
15837
+ const point = browserActionPoint(result);
15838
+ if (point) logRecordingAction({ type: "click", ...point });
15811
15839
  console.log(JSON.stringify({
15812
15840
  title: page.title ?? "",
15813
15841
  url: page.url ?? "",
@@ -15850,6 +15878,7 @@ function buildBrowserFillExpression(query, value, options) {
15850
15878
  return labels.map(normalize).filter(Boolean);
15851
15879
  };
15852
15880
  const labelText = (el) => labelParts(el).join(' ');
15881
+ ${DESKTOP_POINT_JS}
15853
15882
  const fieldMatches = (el) => {
15854
15883
  const parts = labelParts(el);
15855
15884
  return exact ? parts.some(matches) : matches(parts.join(' '));
@@ -15893,6 +15922,7 @@ function buildBrowserFillExpression(query, value, options) {
15893
15922
  type: el.getAttribute('type') || null,
15894
15923
  text,
15895
15924
  value: el.isContentEditable ? el.textContent : el.value,
15925
+ desktopPoint: desktopPoint(rect),
15896
15926
  rect: {
15897
15927
  x: Math.round(rect.x),
15898
15928
  y: Math.round(rect.y),
@@ -15912,6 +15942,8 @@ async function computerBrowserFillCommand(query, value, options = {}) {
15912
15942
  page.webSocketDebuggerUrl,
15913
15943
  buildBrowserFillExpression(query, value, { exact: !!options.exact, index })
15914
15944
  );
15945
+ const point = browserActionPoint(result);
15946
+ if (point) logRecordingAction({ type: "type", ...point });
15915
15947
  console.log(JSON.stringify({
15916
15948
  title: page.title ?? "",
15917
15949
  url: page.url ?? "",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-cli",
3
- "version": "0.2.333",
3
+ "version": "0.2.335",
4
4
  "description": "CLI for managing Replicas workspaces - SSH into cloud dev environments with automatic port forwarding",
5
5
  "main": "dist/index.mjs",
6
6
  "bin": {