feat: init
This commit is contained in:
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;
|
||||
Reference in New Issue
Block a user