feat: init
This commit is contained in:
19
node_modules/clipboardy/browser.js
generated
vendored
Normal file
19
node_modules/clipboardy/browser.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
/* eslint-env browser */
|
||||
|
||||
const clipboard = {};
|
||||
|
||||
clipboard.write = async text => {
|
||||
await navigator.clipboard.writeText(text);
|
||||
};
|
||||
|
||||
clipboard.read = async () => navigator.clipboard.readText();
|
||||
|
||||
clipboard.readSync = () => {
|
||||
throw new Error('`.readSync()` is not supported in browsers!');
|
||||
};
|
||||
|
||||
clipboard.writeSync = () => {
|
||||
throw new Error('`.writeSync()` is not supported in browsers!');
|
||||
};
|
||||
|
||||
export default clipboard;
|
||||
BIN
node_modules/clipboardy/fallbacks/linux/xsel
generated
vendored
Executable file
BIN
node_modules/clipboardy/fallbacks/linux/xsel
generated
vendored
Executable file
Binary file not shown.
BIN
node_modules/clipboardy/fallbacks/windows/clipboard_i686.exe
generated
vendored
Executable file
BIN
node_modules/clipboardy/fallbacks/windows/clipboard_i686.exe
generated
vendored
Executable file
Binary file not shown.
BIN
node_modules/clipboardy/fallbacks/windows/clipboard_x86_64.exe
generated
vendored
Executable file
BIN
node_modules/clipboardy/fallbacks/windows/clipboard_x86_64.exe
generated
vendored
Executable file
Binary file not shown.
71
node_modules/clipboardy/index.d.ts
generated
vendored
Normal file
71
node_modules/clipboardy/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
declare const clipboard: {
|
||||
/**
|
||||
Write (copy) to the clipboard asynchronously.
|
||||
|
||||
@param text - The text to write to the clipboard.
|
||||
|
||||
@example
|
||||
```
|
||||
import clipboard from 'clipboardy';
|
||||
|
||||
await clipboard.write('🦄');
|
||||
|
||||
await clipboard.read();
|
||||
//=> '🦄'
|
||||
```
|
||||
*/
|
||||
write(text: string): Promise<void>;
|
||||
|
||||
/**
|
||||
Read (paste) from the clipboard asynchronously.
|
||||
|
||||
@example
|
||||
```
|
||||
import clipboard from 'clipboardy';
|
||||
|
||||
await clipboard.write('🦄');
|
||||
|
||||
await clipboard.read();
|
||||
//=> '🦄'
|
||||
```
|
||||
*/
|
||||
read(): Promise<string>;
|
||||
|
||||
/**
|
||||
Write (copy) to the clipboard synchronously.
|
||||
|
||||
__Doesn't work in browsers.__
|
||||
|
||||
@param text - The text to write to the clipboard.
|
||||
|
||||
@example
|
||||
```
|
||||
import clipboard from 'clipboardy';
|
||||
|
||||
clipboard.writeSync('🦄');
|
||||
|
||||
clipboard.readSync();
|
||||
//=> '🦄'
|
||||
```
|
||||
*/
|
||||
writeSync(text: string): void;
|
||||
|
||||
/**
|
||||
Read (paste) from the clipboard synchronously.
|
||||
|
||||
__Doesn't work in browsers.__
|
||||
|
||||
@example
|
||||
```
|
||||
import clipboard from 'clipboardy';
|
||||
|
||||
clipboard.writeSync('🦄');
|
||||
|
||||
clipboard.readSync();
|
||||
//=> '🦄'
|
||||
```
|
||||
*/
|
||||
readSync(): string;
|
||||
};
|
||||
|
||||
export default clipboard;
|
||||
59
node_modules/clipboardy/index.js
generated
vendored
Normal file
59
node_modules/clipboardy/index.js
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
import process from 'node:process';
|
||||
import isWSL from 'is-wsl';
|
||||
import termux from './lib/termux.js';
|
||||
import linux from './lib/linux.js';
|
||||
import macos from './lib/macos.js';
|
||||
import windows from './lib/windows.js';
|
||||
|
||||
const platformLib = (() => {
|
||||
switch (process.platform) {
|
||||
case 'darwin': {
|
||||
return macos;
|
||||
}
|
||||
|
||||
case 'win32': {
|
||||
return windows;
|
||||
}
|
||||
|
||||
case 'android': {
|
||||
if (process.env.PREFIX !== '/data/data/com.termux/files/usr') {
|
||||
throw new Error('You need to install Termux for this module to work on Android: https://termux.com');
|
||||
}
|
||||
|
||||
return termux;
|
||||
}
|
||||
|
||||
default: {
|
||||
// `process.platform === 'linux'` for WSL.
|
||||
if (isWSL) {
|
||||
return windows;
|
||||
}
|
||||
|
||||
return linux;
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
const clipboard = {};
|
||||
|
||||
clipboard.write = async text => {
|
||||
if (typeof text !== 'string') {
|
||||
throw new TypeError(`Expected a string, got ${typeof text}`);
|
||||
}
|
||||
|
||||
await platformLib.copy({input: text});
|
||||
};
|
||||
|
||||
clipboard.read = async () => platformLib.paste({stripFinalNewline: false});
|
||||
|
||||
clipboard.writeSync = text => {
|
||||
if (typeof text !== 'string') {
|
||||
throw new TypeError(`Expected a string, got ${typeof text}`);
|
||||
}
|
||||
|
||||
platformLib.copySync({input: text});
|
||||
};
|
||||
|
||||
clipboard.readSync = () => platformLib.pasteSync({stripFinalNewline: false});
|
||||
|
||||
export default clipboard;
|
||||
63
node_modules/clipboardy/lib/linux.js
generated
vendored
Normal file
63
node_modules/clipboardy/lib/linux.js
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
import path from 'node:path';
|
||||
import {fileURLToPath} from 'node:url';
|
||||
import {execa, execaSync} from 'execa';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
const xsel = 'xsel';
|
||||
const xselFallback = path.join(__dirname, '../fallbacks/linux/xsel');
|
||||
|
||||
const copyArguments = ['--clipboard', '--input'];
|
||||
const pasteArguments = ['--clipboard', '--output'];
|
||||
|
||||
const makeError = (xselError, fallbackError) => {
|
||||
let error;
|
||||
if (xselError.code === 'ENOENT') {
|
||||
error = new Error('Couldn\'t find the `xsel` binary and fallback didn\'t work. On Debian/Ubuntu you can install xsel with: sudo apt install xsel');
|
||||
} else {
|
||||
error = new Error('Both xsel and fallback failed');
|
||||
error.xselError = xselError;
|
||||
}
|
||||
|
||||
error.fallbackError = fallbackError;
|
||||
return error;
|
||||
};
|
||||
|
||||
const xselWithFallback = async (argumentList, options) => {
|
||||
try {
|
||||
const {stdout} = await execa(xsel, argumentList, options);
|
||||
return stdout;
|
||||
} catch (xselError) {
|
||||
try {
|
||||
const {stdout} = await execa(xselFallback, argumentList, options);
|
||||
return stdout;
|
||||
} catch (fallbackError) {
|
||||
throw makeError(xselError, fallbackError);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const xselWithFallbackSync = (argumentList, options) => {
|
||||
try {
|
||||
return execaSync(xsel, argumentList, options).stdout;
|
||||
} catch (xselError) {
|
||||
try {
|
||||
return execaSync(xselFallback, argumentList, options).stdout;
|
||||
} catch (fallbackError) {
|
||||
throw makeError(xselError, fallbackError);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const clipboard = {
|
||||
async copy(options) {
|
||||
await xselWithFallback(copyArguments, options);
|
||||
},
|
||||
copySync(options) {
|
||||
xselWithFallbackSync(copyArguments, options);
|
||||
},
|
||||
paste: options => xselWithFallback(pasteArguments, options),
|
||||
pasteSync: options => xselWithFallbackSync(pasteArguments, options),
|
||||
};
|
||||
|
||||
export default clipboard;
|
||||
17
node_modules/clipboardy/lib/macos.js
generated
vendored
Normal file
17
node_modules/clipboardy/lib/macos.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
import {execa, execaSync} from 'execa';
|
||||
|
||||
const env = {
|
||||
LC_CTYPE: 'UTF-8', // eslint-disable-line unicorn/text-encoding-identifier-case
|
||||
};
|
||||
|
||||
const clipboard = {
|
||||
copy: async options => execa('pbcopy', {...options, env}),
|
||||
async paste(options) {
|
||||
const {stdout} = await execa('pbpaste', {...options, env});
|
||||
return stdout;
|
||||
},
|
||||
copySync: options => execaSync('pbcopy', {...options, env}),
|
||||
pasteSync: options => execaSync('pbpaste', {...options, env}).stdout,
|
||||
};
|
||||
|
||||
export default clipboard;
|
||||
43
node_modules/clipboardy/lib/termux.js
generated
vendored
Normal file
43
node_modules/clipboardy/lib/termux.js
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
import {execa, execaSync} from 'execa';
|
||||
|
||||
const handler = error => {
|
||||
if (error.code === 'ENOENT') {
|
||||
throw new Error('Couldn\'t find the termux-api scripts. You can install them with: apt install termux-api');
|
||||
}
|
||||
|
||||
throw error;
|
||||
};
|
||||
|
||||
const clipboard = {
|
||||
async copy(options) {
|
||||
try {
|
||||
await execa('termux-clipboard-set', options);
|
||||
} catch (error) {
|
||||
handler(error);
|
||||
}
|
||||
},
|
||||
async paste(options) {
|
||||
try {
|
||||
const {stdout} = await execa('termux-clipboard-get', options);
|
||||
return stdout;
|
||||
} catch (error) {
|
||||
handler(error);
|
||||
}
|
||||
},
|
||||
copySync(options) {
|
||||
try {
|
||||
execaSync('termux-clipboard-set', options);
|
||||
} catch (error) {
|
||||
handler(error);
|
||||
}
|
||||
},
|
||||
pasteSync(options) {
|
||||
try {
|
||||
return execaSync('termux-clipboard-get', options).stdout;
|
||||
} catch (error) {
|
||||
handler(error);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export default clipboard;
|
||||
23
node_modules/clipboardy/lib/windows.js
generated
vendored
Normal file
23
node_modules/clipboardy/lib/windows.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
import path from 'node:path';
|
||||
import {fileURLToPath} from 'node:url';
|
||||
import {execa, execaSync} from 'execa';
|
||||
import {is64bitSync} from 'is64bit';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
const binarySuffix = is64bitSync() ? 'x86_64' : 'i686';
|
||||
|
||||
// Binaries from: https://github.com/sindresorhus/win-clipboard
|
||||
const windowBinaryPath = path.join(__dirname, `../fallbacks/windows/clipboard_${binarySuffix}.exe`);
|
||||
|
||||
const clipboard = {
|
||||
copy: async options => execa(windowBinaryPath, ['--copy'], options),
|
||||
async paste(options) {
|
||||
const {stdout} = await execa(windowBinaryPath, ['--paste'], options);
|
||||
return stdout;
|
||||
},
|
||||
copySync: options => execaSync(windowBinaryPath, ['--copy'], options),
|
||||
pasteSync: options => execaSync(windowBinaryPath, ['--paste'], options).stdout,
|
||||
};
|
||||
|
||||
export default clipboard;
|
||||
9
node_modules/clipboardy/license
generated
vendored
Normal file
9
node_modules/clipboardy/license
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
59
node_modules/clipboardy/package.json
generated
vendored
Normal file
59
node_modules/clipboardy/package.json
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
{
|
||||
"name": "clipboardy",
|
||||
"version": "4.0.0",
|
||||
"description": "Access the system clipboard (copy/paste)",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/clipboardy",
|
||||
"funding": "https://github.com/sponsors/sindresorhus",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "https://sindresorhus.com"
|
||||
},
|
||||
"type": "module",
|
||||
"exports": {
|
||||
"types": "./index.d.ts",
|
||||
"node": "./index.js",
|
||||
"default": "./browser.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts",
|
||||
"browser.js",
|
||||
"lib",
|
||||
"fallbacks"
|
||||
],
|
||||
"keywords": [
|
||||
"clipboard",
|
||||
"copy",
|
||||
"paste",
|
||||
"copy-paste",
|
||||
"pasteboard",
|
||||
"read",
|
||||
"write",
|
||||
"pbcopy",
|
||||
"clip",
|
||||
"xclip",
|
||||
"xsel"
|
||||
],
|
||||
"dependencies": {
|
||||
"execa": "^8.0.1",
|
||||
"is-wsl": "^3.1.0",
|
||||
"is64bit": "^2.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "^5.3.1",
|
||||
"tsd": "^0.29.0",
|
||||
"xo": "^0.56.0"
|
||||
},
|
||||
"ava": {
|
||||
"serial": true
|
||||
}
|
||||
}
|
||||
75
node_modules/clipboardy/readme.md
generated
vendored
Normal file
75
node_modules/clipboardy/readme.md
generated
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
# clipboardy
|
||||
|
||||
> Access the system clipboard (copy/paste)
|
||||
|
||||
Cross-platform. Supports: macOS, Windows, Linux, OpenBSD, FreeBSD, Android with [Termux](https://termux.com/), and [modern browsers](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard_API#Browser_compatibility).
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install clipboardy
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import clipboard from 'clipboardy';
|
||||
|
||||
clipboard.writeSync('🦄');
|
||||
|
||||
clipboard.readSync();
|
||||
//=> '🦄'
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
In the browser, it requires a [secure context](https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts).
|
||||
|
||||
### clipboard
|
||||
|
||||
#### .write(text)
|
||||
|
||||
Write (copy) to the clipboard asynchronously.
|
||||
|
||||
Returns a `Promise`.
|
||||
|
||||
##### text
|
||||
|
||||
Type: `string`
|
||||
|
||||
The text to write to the clipboard.
|
||||
|
||||
#### .read()
|
||||
|
||||
Read (paste) from the clipboard asynchronously.
|
||||
|
||||
Returns a `Promise`.
|
||||
|
||||
#### .writeSync(text)
|
||||
|
||||
Write (copy) to the clipboard synchronously.
|
||||
|
||||
**Doesn't work in browsers.**
|
||||
|
||||
##### text
|
||||
|
||||
Type: `string`
|
||||
|
||||
The text to write to the clipboard.
|
||||
|
||||
#### .readSync()
|
||||
|
||||
Read (paste) from the clipboard synchronously.
|
||||
|
||||
**Doesn't work in browsers.**
|
||||
|
||||
## FAQ
|
||||
|
||||
#### Where can I find the source of the bundled binaries?
|
||||
|
||||
The [Linux binary](fallbacks/linux/xsel) is just a bundled version of [`xsel`](https://linux.die.net/man/1/xsel). The source for the [Windows binary](fallbacks/windows/clipboard_x86_64.exe) can be found [here](https://github.com/sindresorhus/win-clipboard).
|
||||
|
||||
## Related
|
||||
|
||||
- [clipboard-cli](https://github.com/sindresorhus/clipboard-cli) - CLI for this module
|
||||
- [copy-text-to-clipboard](https://github.com/sindresorhus/copy-text-to-clipboard) - Copy text to the clipboard in the browser
|
||||
Reference in New Issue
Block a user