From f3f6a91f162c724f70a99b9b93e0873eb09355a0 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 4 Aug 2022 09:57:37 -0700 Subject: [PATCH] Remove node target from ligatures This complicates bundling for sandboxed electron a lot, ideally we would only rely on browser APIs for font access --- addons/xterm-addon-ligatures/src/font.ts | 15 +++------------ addons/xterm-addon-ligatures/src/index.ts | 2 +- addons/xterm-addon-ligatures/webpack.config.js | 17 +---------------- 3 files changed, 5 insertions(+), 29 deletions(-) diff --git a/addons/xterm-addon-ligatures/src/font.ts b/addons/xterm-addon-ligatures/src/font.ts index 5c5f0a6c..ece22367 100644 --- a/addons/xterm-addon-ligatures/src/font.ts +++ b/addons/xterm-addon-ligatures/src/font.ts @@ -3,8 +3,7 @@ * @license MIT */ -import { FontList } from 'font-finder'; -import { Font, loadBuffer, loadFile } from 'font-ligatures'; +import { Font, loadBuffer } from 'font-ligatures'; import parse from './parse'; @@ -24,7 +23,7 @@ interface IFontAccessNavigator { }; } -let fontsPromise: Promise> | undefined = undefined; +let fontsPromise: Promise> | undefined = undefined; /** * Loads the font ligature wrapper for the specified font family if it could be @@ -81,14 +80,6 @@ export default async function load(fontFamily: string, cacheSize: number): Promi console.error(err.name, err.message); } } - // Node environment or no font access API - else { - try { - fontsPromise = (await import('font-finder')).list(); - } catch (err) { - // No-op - } - } if (!fontsPromise) { fontsPromise = Promise.resolve({}); } @@ -110,7 +101,7 @@ export default async function load(fontFamily: string, cacheSize: number): Promi const buffer = await bytes.arrayBuffer(); return loadBuffer(buffer, { cacheSize }); } - return await loadFile(font.path, { cacheSize }); + return undefined; } } diff --git a/addons/xterm-addon-ligatures/src/index.ts b/addons/xterm-addon-ligatures/src/index.ts index 82589e36..82675626 100644 --- a/addons/xterm-addon-ligatures/src/index.ts +++ b/addons/xterm-addon-ligatures/src/index.ts @@ -3,7 +3,7 @@ * @license MIT */ -import { Terminal } from 'xterm'; +import type { Terminal } from 'xterm'; import { Font } from 'font-ligatures'; import load from './font'; diff --git a/addons/xterm-addon-ligatures/webpack.config.js b/addons/xterm-addon-ligatures/webpack.config.js index e8066771..97da1e17 100644 --- a/addons/xterm-addon-ligatures/webpack.config.js +++ b/addons/xterm-addon-ligatures/webpack.config.js @@ -27,20 +27,5 @@ module.exports = { library: addonName, libraryTarget: 'umd' }, - mode: 'production', - externals: { - 'font-finder': 'font-finder', - 'stream': 'stream', - 'os': 'os', - 'util': 'util' - }, - resolve: { - // The ligature modules contains fallbacks for node environments, we never want to browserify them - fallback: { - stream: false, - util: false, - os: false, - path: false - } - } + mode: 'production' };