From 199cb4293013fa7f59aa70c55150a8f027470b9a Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Thu, 5 Mar 2026 10:44:04 +0100 Subject: [PATCH 1/5] feat: remove browser support --- .github/workflows/main.yml | 2 -- .github/workflows/publish.yml | 2 -- README.md | 4 +++- package.json | 8 -------- src/browser.ts | 7 ------- tests/browser.test.ts | 21 --------------------- vitest.config.ts | 34 ++++------------------------------ 7 files changed, 7 insertions(+), 71 deletions(-) delete mode 100644 src/browser.ts delete mode 100644 tests/browser.test.ts diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5a35944..e235e00 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -71,8 +71,6 @@ jobs: run: ${{ matrix.install-cmd }} - name: Install Dependencies run: pnpm install - - name: Download Playwright binaries - run: pnpm exec playwright install chromium - name: Build run: pnpm build - name: Test diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 808d51e..fa49b81 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -25,8 +25,6 @@ jobs: run: pnpm build - name: Lint run: pnpm lint - - name: Download Playwright binaries - run: pnpm exec playwright install chromium - name: Test run: xvfb-run -a pnpm test diff --git a/README.md b/README.md index 6a9f12b..6a90ae2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # tinyclip 📋 -A tiny cross-platform clipboard library. Uses native OS clipboard functionality on Node.js, and the [Clipboard API](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard_API) in browsers. +A tiny cross-platform clipboard library. Uses native OS clipboard functionality on Node.js. + +> On the browser, use the [Clipboard API](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard_API) directly! ## Install diff --git a/package.json b/package.json index 56fc86d..1cbe08c 100644 --- a/package.json +++ b/package.json @@ -23,12 +23,6 @@ "author": "Tinylibs Maintainers (https://github.com/tinylibs)", "type": "module", "main": "./dist/index.js", - "exports": { - ".": { - "browser": "./dist/browser.js", - "default": "./dist/index.js" - } - }, "scripts": { "build": "tsgo --build", "test": "vitest run", @@ -39,9 +33,7 @@ "devDependencies": { "@types/node": "^25.3.3", "@typescript/native-preview": "^7.0.0-dev.20260228.1", - "@vitest/browser-playwright": "^4.0.18", "@vitest/coverage-v8": "^4.0.18", - "playwright": "^1.58.2", "prettier": "^3.7.4", "vitest": "^4.0.18" } diff --git a/src/browser.ts b/src/browser.ts deleted file mode 100644 index c4f0d04..0000000 --- a/src/browser.ts +++ /dev/null @@ -1,7 +0,0 @@ -export function readText(): Promise { - return navigator.clipboard.readText(); -} - -export function writeText(text: string): Promise { - return navigator.clipboard.writeText(text); -} diff --git a/tests/browser.test.ts b/tests/browser.test.ts deleted file mode 100644 index 1a212ae..0000000 --- a/tests/browser.test.ts +++ /dev/null @@ -1,21 +0,0 @@ -import {describe, expect, it, beforeEach} from 'vitest'; -import {userEvent} from 'vitest/browser'; -import * as clipboard from '../src/browser.js'; - -describe('clipboard', () => { - beforeEach(async () => { - // Simulate user interaction to satisfy clipboard API security requirements - await userEvent.click(document.body); - }); - - it('should export correct API', () => { - expect(clipboard).toHaveProperty('readText'); - expect(clipboard).toHaveProperty('writeText'); - }); - - it('should copy then read successfully', async () => { - const text = Math.random().toString(); - await clipboard.writeText(text); - expect(await clipboard.readText()).toEqual(text); - }); -}); diff --git a/vitest.config.ts b/vitest.config.ts index e250652..b865fe5 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -1,38 +1,12 @@ import {defineConfig} from 'vitest/config'; -import {playwright} from '@vitest/browser-playwright'; export default defineConfig({ test: { + include: ['tests/*.test.ts'], + environment: 'node', + name: 'node', coverage: { provider: 'v8' - }, - projects: [ - { - extends: './vitest.config.ts', - test: { - include: ['tests/index.test.ts'], - environment: 'node', - name: 'node' - } - }, - { - extends: './vitest.config.ts', - test: { - include: ['tests/browser.test.ts'], - name: 'browser', - browser: { - enabled: true, - provider: playwright({ - contextOptions: { - permissions: ['clipboard-read', 'clipboard-write'] - } - }), - headless: true, - instances: [{browser: 'chromium'}], - screenshotFailures: false - } - } - } - ] + } } }); From ce3c0959ef18a2ae84c84a6bcebd6b84acd5cb15 Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Thu, 5 Mar 2026 10:44:32 +0100 Subject: [PATCH 2/5] deps --- pnpm-lock.yaml | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f5a512a..cdd33fb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -14,15 +14,9 @@ importers: '@typescript/native-preview': specifier: ^7.0.0-dev.20260228.1 version: 7.0.0-dev.20260228.1 - '@vitest/browser-playwright': - specifier: ^4.0.18 - version: 4.0.18(playwright@1.58.2)(vite@7.3.1(@types/node@25.3.3))(vitest@4.0.18) '@vitest/coverage-v8': specifier: ^4.0.18 version: 4.0.18(@vitest/browser@4.0.18(vite@7.3.1(@types/node@25.3.3))(vitest@4.0.18))(vitest@4.0.18) - playwright: - specifier: ^1.58.2 - version: 1.58.2 prettier: specifier: ^3.7.4 version: 3.8.1 @@ -837,7 +831,8 @@ snapshots: '@jridgewell/resolve-uri': 3.1.2 '@jridgewell/sourcemap-codec': 1.5.5 - '@polka/url@1.0.0-next.29': {} + '@polka/url@1.0.0-next.29': + optional: true '@rollup/rollup-android-arm-eabi@4.59.0': optional: true @@ -972,6 +967,7 @@ snapshots: - msw - utf-8-validate - vite + optional: true '@vitest/browser@4.0.18(vite@7.3.1(@types/node@25.3.3))(vitest@4.0.18)': dependencies: @@ -989,6 +985,7 @@ snapshots: - msw - utf-8-validate - vite + optional: true '@vitest/coverage-v8@4.0.18(@vitest/browser@4.0.18(vite@7.3.1(@types/node@25.3.3))(vitest@4.0.18))(vitest@4.0.18)': dependencies: @@ -1135,7 +1132,8 @@ snapshots: dependencies: semver: 7.7.4 - mrmime@2.0.1: {} + mrmime@2.0.1: + optional: true nanoid@3.3.11: {} @@ -1150,16 +1148,20 @@ snapshots: pixelmatch@7.1.0: dependencies: pngjs: 7.0.0 + optional: true - playwright-core@1.58.2: {} + playwright-core@1.58.2: + optional: true playwright@1.58.2: dependencies: playwright-core: 1.58.2 optionalDependencies: fsevents: 2.3.2 + optional: true - pngjs@7.0.0: {} + pngjs@7.0.0: + optional: true postcss@8.5.6: dependencies: @@ -1209,6 +1211,7 @@ snapshots: '@polka/url': 1.0.0-next.29 mrmime: 2.0.1 totalist: 3.0.1 + optional: true source-map-js@1.2.1: {} @@ -1231,7 +1234,8 @@ snapshots: tinyrainbow@3.0.3: {} - totalist@3.0.1: {} + totalist@3.0.1: + optional: true undici-types@7.18.2: {} @@ -1290,4 +1294,5 @@ snapshots: siginfo: 2.0.0 stackback: 0.0.2 - ws@8.19.0: {} + ws@8.19.0: + optional: true From 6f41e3484867b4da678d3cea56b69e0a1280bcd7 Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Thu, 5 Mar 2026 10:49:34 +0100 Subject: [PATCH 3/5] feedback --- vitest.config.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/vitest.config.ts b/vitest.config.ts index b865fe5..a836dd9 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -3,8 +3,6 @@ import {defineConfig} from 'vitest/config'; export default defineConfig({ test: { include: ['tests/*.test.ts'], - environment: 'node', - name: 'node', coverage: { provider: 'v8' } From 685eda5b51224aac87503c42019bf2e440f5e476 Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Thu, 5 Mar 2026 10:50:29 +0100 Subject: [PATCH 4/5] feedback --- package.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/package.json b/package.json index 1cbe08c..b05fe01 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,11 @@ "author": "Tinylibs Maintainers (https://github.com/tinylibs)", "type": "module", "main": "./dist/index.js", + "exports": { + ".": { + "default": "./dist/index.js" + } + }, "scripts": { "build": "tsgo --build", "test": "vitest run", From 1ed048b797485e9fd6533c8d62a45f04dc83b7cd Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Thu, 5 Mar 2026 11:03:06 +0100 Subject: [PATCH 5/5] Update README.md Co-authored-by: James Garbutt <43081j@users.noreply.github.com> --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6a90ae2..7aee25a 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,8 @@ A tiny cross-platform clipboard library. Uses native OS clipboard functionality on Node.js. -> On the browser, use the [Clipboard API](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard_API) directly! +> [!NOTE] +> In the browser, you can use the native [Clipboard API](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard_API) instead of a dependency. ## Install