Fixes https://github.com/xtermjs/xterm.js/issues/5896 TypeScript path mappings for common/*, browser/*, and headless/* were not rewritten in emitted JavaScript, which forced webpack resolve aliases and NODE_PATH workarounds so runtime could resolve modules. That added build complexity and broke tooling such as ESLint import/no-cycle. Changes: - Convert ~750 imports across src/, addons/, and test/ to relative paths - Remove common/browser/headless paths and src catch-all mappings from tsconfigs (keep @xterm/addon-* demo and addon typings paths) - Remove webpack resolve.alias for common, browser, headless, and vs - Drop NODE_PATH from unit tests, benchmarks, and VS Code launch config - Fix addon-image IIPImageStorage to import ./Types after removing catch-all * Verified: npm run build, esbuild, package, package-headless Co-authored-by: Cursor <cursoragent@cursor.com>
54 lines
1.8 KiB
TypeScript
54 lines
1.8 KiB
TypeScript
/**
|
|
* Copyright (c) 2019 The xterm.js authors. All rights reserved.
|
|
* @license MIT
|
|
*/
|
|
|
|
import { assert } from 'chai';
|
|
import { UnicodeService } from './UnicodeService';
|
|
import { IUnicodeVersionProvider } from './Services';
|
|
|
|
class DummyProvider implements IUnicodeVersionProvider {
|
|
public version = '123';
|
|
public wcwidth(n: number): 0 | 1 | 2 {
|
|
return 2;
|
|
}
|
|
public charProperties(codepoint: number): number {
|
|
return UnicodeService.createPropertyValue(0, this.wcwidth(codepoint));
|
|
}
|
|
}
|
|
|
|
describe('unicode provider', () => {
|
|
let us: UnicodeService;
|
|
beforeEach(() => {
|
|
us = new UnicodeService();
|
|
});
|
|
it('default to V6', () => {
|
|
assert.equal(us.activeVersion, '6');
|
|
assert.deepEqual(us.versions, ['6']);
|
|
assert.doesNotThrow(() => { us.activeVersion = '6'; }, `unknown Unicode version "6"`);
|
|
assert.equal(us.getStringCellWidth('hello'), 5);
|
|
});
|
|
it('activate should throw for unknown version', () => {
|
|
assert.throws(() => { us.activeVersion = '55'; }, 'unknown Unicode version "55"');
|
|
});
|
|
it('should notify about version change', () => {
|
|
const notes: string[] = [];
|
|
us.onChange(version => notes.push(version));
|
|
const dummyProvider = new DummyProvider();
|
|
us.register(dummyProvider);
|
|
us.activeVersion = dummyProvider.version;
|
|
assert.deepEqual(notes, [dummyProvider.version]);
|
|
});
|
|
it('correctly changes provider impl', () => {
|
|
assert.equal(us.getStringCellWidth('hello'), 5);
|
|
const dummyProvider = new DummyProvider();
|
|
us.register(dummyProvider);
|
|
us.activeVersion = dummyProvider.version;
|
|
assert.equal(us.getStringCellWidth('hello'), 2 * 5);
|
|
});
|
|
it('wcwidth V6 emoji test', () => {
|
|
const widthV6 = us.getStringCellWidth('🤣🤣🤣🤣🤣🤣🤣🤣🤣🤣');
|
|
assert.equal(widthV6, 10);
|
|
});
|
|
});
|