@guanzhu.me/pw-cli 0.0.5 → 0.0.6

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/bin/pw-cli.js +21 -0
  2. package/package.json +1 -1
package/bin/pw-cli.js CHANGED
@@ -716,6 +716,27 @@ async function main() {
716
716
  return;
717
717
  }
718
718
 
719
+ // ── goto: navigate the currently active tab (not always the first one) ───
720
+ if (command === 'goto') {
721
+ const gotoIdx = rawArgv.indexOf('goto');
722
+ const afterGoto = rawArgv.slice(gotoIdx + 1);
723
+ const rawUrl = afterGoto.find(a => !a.startsWith('-'));
724
+ if (rawUrl) {
725
+ const fullUrl = /^https?:\/\//.test(rawUrl) ? rawUrl : `https://${rawUrl}`;
726
+ const navCode = `async (page, context) => {
727
+ const pages = context.pages();
728
+ let target = pages[pages.length - 1] || page;
729
+ for (const p of pages) {
730
+ try { if (!await p.evaluate(() => document.hidden)) { target = p; break; } } catch {}
731
+ }
732
+ await target.goto(${JSON.stringify(fullUrl)}, { waitUntil: 'domcontentloaded', timeout: 0 });
733
+ return target.url();
734
+ }`;
735
+ await handleRunCode(['run-code', navCode]);
736
+ return;
737
+ }
738
+ }
739
+
719
740
  // ── From here on: delegate to playwright-cli (with enhancements) ─────────
720
741
  const cliPath = findPlaywrightCli();
721
742
  if (!cliPath) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guanzhu.me/pw-cli",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "Persistent Playwright browser CLI with headed defaults, profile support, queueing, and script execution",
5
5
  "bin": {
6
6
  "pw-cli": "./bin/pw-cli.js"