@bigbinary/neeto-playwright-commons 4.11.15 → 4.11.17

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 (3) hide show
  1. package/index.d.ts +5 -3
  2. package/index.js +11 -14
  3. package/package.json +2 -3
package/index.d.ts CHANGED
@@ -9691,7 +9691,9 @@ declare const getListCount: ({
9691
9691
  declare const getGlobalUserProps: (page: Page) => Promise<Record<string, string>>;
9692
9692
  /**
9693
9693
  *
9694
- * Fetches the current text content from the system clipboard in the browser context. It first attempts to use the native clipboard API (navigator.clipboard.readText()). If that fails, it falls back to creating a temporary textarea and using keyboard paste to retrieve the clipboard content.
9694
+ * Reads the current text from the system clipboard. Every browser, including WebKit, tries navigator.clipboard.readText() first. When that API is missing or returns null or undefined, the helper inserts a temporary textarea, focuses it, and pastes with ControlOrMeta+v.
9695
+ *
9696
+ * Call grantClipboardPermissions on the page's browser context before reading, so the native Clipboard API is allowed to run.
9695
9697
  *
9696
9698
  * page: The Playwright Page object representing the current browser page.
9697
9699
  *
@@ -9703,13 +9705,13 @@ declare const getGlobalUserProps: (page: Page) => Promise<Record<string, string>
9703
9705
  declare const getClipboardContent: (page: Page) => Promise<string>;
9704
9706
  /**
9705
9707
  *
9706
- * Grants clipboard read and write permissions to the browser context. It takes the following parameters:
9708
+ * Grants the clipboard permissions the current browser accepts. Chromium and Firefox receive clipboard-read and clipboard-write. WebKit receives clipboard-read, because that is the clipboard permission WebKit accepts.
9707
9709
  *
9708
9710
  * context: The Playwright BrowserContext object to grant permissions to.
9709
9711
  *
9710
9712
  * @example
9711
9713
  *
9712
- * await grantClipboardPermissions(context);
9714
+ * await grantClipboardPermissions(context);
9713
9715
  * @endexample
9714
9716
  */
9715
9717
  declare const grantClipboardPermissions: (context: BrowserContext) => Promise<void>;
package/index.js CHANGED
@@ -2359,24 +2359,21 @@ const createTextareaAndEvaluateCopiedText = async (page) => {
2359
2359
  }
2360
2360
  };
2361
2361
  const getClipboardContent = async (page) => {
2362
- const isWebkit = page.context().browser()?.browserType().name() === "webkit";
2363
- if (!isWebkit) {
2364
- // Attempt 1: Native Clipboard API
2365
- const clipboardText = await page.evaluate(async () => {
2366
- if (!navigator.clipboard?.readText)
2367
- return null;
2368
- return await navigator.clipboard.readText();
2369
- });
2370
- if (isNotNil(clipboardText))
2371
- return clipboardText;
2372
- }
2362
+ // Attempt 1: Native Clipboard API
2363
+ const clipboardText = await page.evaluate(async () => {
2364
+ if (!navigator.clipboard?.readText)
2365
+ return null;
2366
+ return await navigator.clipboard.readText();
2367
+ });
2368
+ if (isNotNil(clipboardText))
2369
+ return clipboardText;
2373
2370
  // Attempt 2: Keyboard paste fallback
2374
2371
  return createTextareaAndEvaluateCopiedText(page);
2375
2372
  };
2376
2373
  const grantClipboardPermissions = async (context) => {
2377
- if (context.browser()?.browserType().name() === "webkit")
2378
- return;
2379
- await context.grantPermissions(["clipboard-read", "clipboard-write"]);
2374
+ const isWebkit = context.browser()?.browserType().name() === "webkit";
2375
+ // WebKit supports "clipboard-read" but rejects "clipboard-write".
2376
+ await context.grantPermissions(isWebkit ? ["clipboard-read"] : ["clipboard-read", "clipboard-write"]);
2380
2377
  };
2381
2378
  const getFullUrl = (path) => shouldSkipCustomDomainSetup() ? path : `${process.env.BASE_URL}${path}`;
2382
2379
  const globalShortcuts = (t) => [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigbinary/neeto-playwright-commons",
3
- "version": "4.11.15",
3
+ "version": "4.11.17",
4
4
  "description": "A package encapsulating common playwright code across neeto projects.",
5
5
  "repository": "git@github.com:bigbinary/neeto-playwright-commons.git",
6
6
  "license": "apache-2.0",
@@ -42,7 +42,6 @@
42
42
  "@babel/traverse": "7.29.0",
43
43
  "@babel/types": "7.29.0",
44
44
  "@bigbinary/eslint-plugin-neeto": "1.9.0",
45
- "@bigbinary/neeto-audit-frontend": "2.6.0",
46
45
  "@bigbinary/neeto-cist": "1.0.17",
47
46
  "@eslint/js": "^9.27.0",
48
47
  "@faker-js/faker": "10.5.0",
@@ -90,7 +89,7 @@
90
89
  "ramda": "0.32.0"
91
90
  },
92
91
  "dependencies": {
93
- "@bigbinary/neeto-commons-frontend": "^4.13.120",
92
+ "@bigbinary/neeto-commons-frontend": "4.14.1",
94
93
  "countries-list": "^3.3.0",
95
94
  "dotenv": "17.3.1",
96
95
  "ioredis": "^5.4.1",