%PDF- <> %âãÏÓ endobj 2 0 obj <> endobj 3 0 obj <>/ExtGState<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/Annots[ 28 0 R 29 0 R] /MediaBox[ 0 0 595.5 842.25] /Contents 4 0 R/Group<>/Tabs/S>> endobj ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<> endobj 2 0 obj<>endobj 2 0 obj<>es 3 0 R>> endobj 2 0 obj<> ox[ 0.000000 0.000000 609.600000 935.600000]/Fi endobj 3 0 obj<> endobj 7 1 obj<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]>>/Subtype/Form>> stream
import path from 'node:path';
import {fileURLToPath} from 'node:url';
import execa 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 execa.sync(xsel, argumentList, options).stdout;
} catch (xselError) {
try {
return execa.sync(xselFallback, argumentList, options).stdout;
} catch (fallbackError) {
throw makeError(xselError, fallbackError);
}
}
};
const clipboard = {
copy: async options => {
await xselWithFallback(copyArguments, options);
},
copySync: options => {
xselWithFallbackSync(copyArguments, options);
},
paste: options => xselWithFallback(pasteArguments, options),
pasteSync: options => xselWithFallbackSync(pasteArguments, options),
};
export default clipboard;