remove js-base64 dependency

This commit is contained in:
Jörg Breitbart
2026-05-10 16:45:46 +02:00
parent 6ba731d73b
commit c8dddddbbb
4 changed files with 7 additions and 20 deletions
-3
View File
@@ -21,8 +21,5 @@
"package": "../../node_modules/.bin/webpack", "package": "../../node_modules/.bin/webpack",
"prepublishOnly": "npm run package", "prepublishOnly": "npm run package",
"start": "node ../../demo/start" "start": "node ../../demo/start"
},
"dependencies": {
"js-base64": "^3.7.5"
} }
} }
+5 -7
View File
@@ -5,7 +5,6 @@
import type { IDisposable, ITerminalAddon, Terminal } from '@xterm/xterm'; import type { IDisposable, ITerminalAddon, Terminal } from '@xterm/xterm';
import { type IClipboardProvider, ClipboardSelectionType, type IBase64 } from '@xterm/addon-clipboard'; import { type IClipboardProvider, ClipboardSelectionType, type IBase64 } from '@xterm/addon-clipboard';
import { Base64 as JSBase64 } from 'js-base64';
export class ClipboardAddon implements ITerminalAddon { export class ClipboardAddon implements ITerminalAddon {
private _terminal?: Terminal; private _terminal?: Terminal;
@@ -87,13 +86,12 @@ export class BrowserClipboardProvider implements IClipboardProvider {
export class Base64 implements IBase64 { export class Base64 implements IBase64 {
public encodeText(data: string): string { public encodeText(data: string): string {
return JSBase64.encode(data); return btoa(data);
} }
public decodeText(data: string): string { public decodeText(data: string): string {
const text = JSBase64.decode(data); try {
if (!JSBase64.isValid(data) || JSBase64.encode(text) !== data) { return atob(data);
return ''; } catch (e) {}
} return '';
return text;
} }
} }
@@ -20,7 +20,7 @@ test.describe('ClipboardAddon', () => {
test.beforeEach(async ({}, testInfo) => { test.beforeEach(async ({}, testInfo) => {
// DEBT: This test doesn't work since the migration to @playwright/test // DEBT: This test doesn't work since the migration to @playwright/test
if (ctx.browser.browserType().name() !== 'chromium') { if (ctx.browser.browserType().name() === 'webkit') {
testInfo.skip(); testInfo.skip();
return; return;
} }
+1 -9
View File
@@ -64,10 +64,7 @@
"addons/addon-clipboard": { "addons/addon-clipboard": {
"name": "@xterm/addon-clipboard", "name": "@xterm/addon-clipboard",
"version": "0.2.0", "version": "0.2.0",
"license": "MIT", "license": "MIT"
"dependencies": {
"js-base64": "^3.7.5"
}
}, },
"addons/addon-fit": { "addons/addon-fit": {
"name": "@xterm/addon-fit", "name": "@xterm/addon-fit",
@@ -5420,11 +5417,6 @@
"url": "https://github.com/chalk/supports-color?sponsor=1" "url": "https://github.com/chalk/supports-color?sponsor=1"
} }
}, },
"node_modules/js-base64": {
"version": "3.7.8",
"resolved": "https://registry.npmjs.org/js-base64/-/js-base64-3.7.8.tgz",
"integrity": "sha512-hNngCeKxIUQiEUN3GPJOkz4wF/YvdUdbNL9hsBcMQTkKzboD7T/q3OYOuuPZLUE6dBxSGpwhk5mwuDud7JVAow=="
},
"node_modules/js-tokens": { "node_modules/js-tokens": {
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",