Full common split: composite tsconfigs and target-* modules

- Add composite TypeScript projects for common/primitives and common/runtime
- Decouple primitives from runtime (buffer service interfaces, UnicodeProperties, CellTypes, etc.)
- Move Types.ts to runtime; re-export primitive types from runtime/Types
- Rename src/browser -> src/target-browser, src/headless -> src/target-headless
- Update import paths (target-browser/*, target-headless/*) across repo
- Fix esbuild outbase so common/* and target-* resolve under out-esbuild/
- Point unicode addons at primitives for UnicodeTypes/UnicodeProperties
- Update ARCHITECTURE.md and AGENTS.md

Co-authored-by: Daniel Imms <Tyriar@users.noreply.github.com>
This commit is contained in:
Cursor Agent
2026-05-31 00:19:43 +00:00
co-authored by Daniel Imms
parent 9a65429a30
commit c569e5ab19
188 changed files with 879 additions and 729 deletions
+7 -4
View File
@@ -2,10 +2,13 @@
## Architecture Overview
**Core Structure**: xterm.js is a multi-target terminal emulator with three main distributions:
- `src/browser/`: Full-featured browser terminal with DOM rendering
- `src/headless/`: Server-side terminal for Node.js (no DOM)
- `src/common/`: Shared core logic (parsing, buffer management, terminal state)
**Core Structure**: xterm.js is a multi-target terminal emulator with these main source areas:
- `src/common/primitives/`: Building blocks (buffer, parser, input, data, utilities); TypeScript project `src/common/primitives/tsconfig.json`
- `src/common/runtime/`: Services, `CoreTerminal`, `InputHandler`, public API adapters; TypeScript project `src/common/runtime/tsconfig.json`
- `src/target-browser/`: Browser terminal with DOM rendering
- `src/target-headless/`: Node terminal without DOM
See `src/ARCHITECTURE.md` for the dependency graph and import-path conventions (`common/*`, `target-browser/*`, `target-headless/*`).
**Key Classes**:
- `Terminal` (browser/headless): Public API wrapper
+3 -3
View File
@@ -15,8 +15,8 @@
"../../../src/common/runtime/*",
"../../../src/common/*"
],
"browser/*": [
"../../../src/browser/*"
"target-browser/*": [
"../../../src/target-browser/*"
],
"*": [
"./*"
@@ -36,7 +36,7 @@
"path": "../../../src/common"
},
{
"path": "../../../src/browser"
"path": "../../../src/target-browser"
},
{
"path": "../../../test/playwright"
+3 -3
View File
@@ -15,8 +15,8 @@
"../../../node_modules/@types/mocha"
],
"paths": {
"browser/*": [
"../../../src/browser/*"
"target-browser/*": [
"../../../src/target-browser/*"
],
"@xterm/addon-clipboard": [
"../typings/addon-clipboard.d.ts"
@@ -29,7 +29,7 @@
],
"references": [
{
"path": "../../../src/browser"
"path": "../../../src/target-browser"
}
]
}
+3 -3
View File
@@ -15,8 +15,8 @@
"../../../src/common/runtime/*",
"../../../src/common/*"
],
"browser/*": [
"../../../src/browser/*"
"target-browser/*": [
"../../../src/target-browser/*"
],
"*": [
"./*"
@@ -36,7 +36,7 @@
"path": "../../../src/common"
},
{
"path": "../../../src/browser"
"path": "../../../src/target-browser"
},
{
"path": "../../../test/playwright"
+1 -1
View File
@@ -5,7 +5,7 @@
import type { Terminal, ITerminalAddon, IRenderDimensions } from '@xterm/xterm';
import type { FitAddon as IFitApi } from '@xterm/addon-fit';
import { ViewportConstants } from 'browser/shared/Constants';
import { ViewportConstants } from 'target-browser/shared/Constants';
interface ITerminalDimensions {
/**
+3 -3
View File
@@ -15,8 +15,8 @@
"../../../node_modules/@types/mocha"
],
"paths": {
"browser/*": [
"../../../src/browser/*"
"target-browser/*": [
"../../../src/target-browser/*"
],
"@xterm/addon-fit": [
"../typings/addon-fit.d.ts"
@@ -29,7 +29,7 @@
],
"references": [
{
"path": "../../../src/browser"
"path": "../../../src/target-browser"
}
]
}
+3 -3
View File
@@ -15,8 +15,8 @@
"../../../src/common/runtime/*",
"../../../src/common/*"
],
"browser/*": [
"../../../src/browser/*"
"target-browser/*": [
"../../../src/target-browser/*"
],
"*": [
"./*"
@@ -36,7 +36,7 @@
"path": "../../../src/common"
},
{
"path": "../../../src/browser"
"path": "../../../src/target-browser"
},
{
"path": "../../../test/playwright"
+3 -3
View File
@@ -10,9 +10,9 @@ import { Attributes, BgFlags, Content, ExtFlags, UnderlineStyle } from 'common/b
import type { AttributeData } from 'common/buffer/AttributeData';
import type { IParams, IDcsHandler, IOscHandler, IApcHandler, IEscapeSequenceParser } from 'common/parser/Types';
import type { IBufferLine, IExtendedAttrs, IInputHandler } from 'common/Types';
import type { ITerminal, ReadonlyColorSet } from 'browser/Types';
import type { IRenderDimensions } from 'browser/renderer/shared/Types';
import type { ICoreBrowserService, IRenderService, IThemeService } from 'browser/services/Services';
import type { ITerminal, ReadonlyColorSet } from 'target-browser/Types';
import type { IRenderDimensions } from 'target-browser/renderer/shared/Types';
import type { ICoreBrowserService, IRenderService, IThemeService } from 'target-browser/services/Services';
export const enum Cell {
CONTENT = 0, // codepoint and wcwidth information (enum Content)
+2 -2
View File
@@ -12,7 +12,7 @@
"../../../node_modules/@types/mocha"
],
"paths": {
"browser/*": [ "../../../src/browser/*" ],
"target-browser/*": [ "../../../src/target-browser/*" ],
"common/*": [
"../../../src/common/primitives/*",
"../../../src/common/runtime/*",
@@ -27,7 +27,7 @@
"../../../typings/xterm.d.ts"
],
"references": [
{ "path": "../../../src/browser" },
{ "path": "../../../src/target-browser" },
{ "path": "../../../src/common" }
]
}
+3 -3
View File
@@ -15,8 +15,8 @@
"../../../src/common/runtime/*",
"../../../src/common/*"
],
"browser/*": [
"../../../src/browser/*"
"target-browser/*": [
"../../../src/target-browser/*"
],
"*": [
"./*"
@@ -36,7 +36,7 @@
"path": "../../../src/common"
},
{
"path": "../../../src/browser"
"path": "../../../src/target-browser"
},
{
"path": "../../../test/playwright"
+1 -1
View File
@@ -26,7 +26,7 @@ const addon = {
extensions: [ '.js' ],
alias: {
common: path.resolve('../../out/common'),
browser: path.resolve('../../out/browser'),
browser: path.resolve('../../out/target-browser'),
vs: path.resolve('../../out/vs')
}
},
+3 -3
View File
@@ -20,8 +20,8 @@
"../../../src/common/runtime/*",
"../../../src/common/*"
],
"browser/*": [
"../../../src/browser/*"
"target-browser/*": [
"../../../src/target-browser/*"
],
"@xterm/addon-progress": [
"../typings/addon-progress.d.ts"
@@ -34,7 +34,7 @@
],
"references": [
{
"path": "../../../src/browser"
"path": "../../../src/target-browser"
},
{
"path": "../../../src/common"
+3 -3
View File
@@ -15,8 +15,8 @@
"../../../src/common/runtime/*",
"../../../src/common/*"
],
"browser/*": [
"../../../src/browser/*"
"target-browser/*": [
"../../../src/target-browser/*"
],
"*": [
"./*"
@@ -36,7 +36,7 @@
"path": "../../../src/common"
},
{
"path": "../../../src/browser"
"path": "../../../src/target-browser"
},
{
"path": "../../../test/playwright"
+1 -1
View File
@@ -26,7 +26,7 @@ module.exports = {
extensions: [ '.js' ],
alias: {
common: path.resolve('../../out/common'),
browser: path.resolve('../../out/browser'),
browser: path.resolve('../../out/target-browser'),
vs: path.resolve('../../out/vs')
}
},
+1 -1
View File
@@ -5,7 +5,7 @@
import { assert } from 'chai';
import { SearchEngine } from './SearchEngine';
import { SearchLineCache } from './SearchLineCache';
import { Terminal } from 'browser/public/Terminal';
import { Terminal } from 'target-browser/public/Terminal';
import type { ISearchOptions } from '@xterm/addon-search';
import { DisposableStore } from 'common/Lifecycle';
@@ -4,7 +4,7 @@
*/
import { assert } from 'chai';
import { SearchLineCache, LineCacheEntry } from './SearchLineCache';
import { Terminal } from 'browser/public/Terminal';
import { Terminal } from 'target-browser/public/Terminal';
import { timeout } from 'common/Async';
function writeP(terminal: Terminal, data: string): Promise<void> {
+3 -3
View File
@@ -20,8 +20,8 @@
"../../../src/common/runtime/*",
"../../../src/common/*"
],
"browser/*": [
"../../../src/browser/*"
"target-browser/*": [
"../../../src/target-browser/*"
],
"@xterm/addon-search" : [
"../typings/addon-search.d.ts"
@@ -37,7 +37,7 @@
"path": "../../../src/common"
},
{
"path": "../../../src/browser"
"path": "../../../src/target-browser"
}
]
}
+3 -3
View File
@@ -15,8 +15,8 @@
"../../../src/common/runtime/*",
"../../../src/common/*"
],
"browser/*": [
"../../../src/browser/*"
"target-browser/*": [
"../../../src/target-browser/*"
],
"*": [
"./*"
@@ -36,7 +36,7 @@
"path": "../../../src/common"
},
{
"path": "../../../src/browser"
"path": "../../../src/target-browser"
},
{
"path": "../../../test/playwright"
@@ -7,7 +7,7 @@ import { perfContext, before, ThroughputRuntimeCase } from 'xterm-benchmark';
import { spawn } from 'node-pty';
import { Utf8ToUtf32, stringFromCodePoint } from 'common/input/TextDecoder';
import { Terminal } from 'browser/public/Terminal';
import { Terminal } from 'target-browser/public/Terminal';
import { SerializeAddon } from 'SerializeAddon';
class TestTerminal extends Terminal {
@@ -17,7 +17,7 @@
"../../../src/common/runtime/*",
"../../../src/common/*"
],
"browser/*": ["../../../src/browser/*"],
"target-browser/*": ["../../../src/target-browser/*"],
"SerializeAddon": ["../src/SerializeAddon"],
"@xterm/addon-serialize": [
"../typings/addon-serialize.d.ts"
@@ -28,6 +28,6 @@
"exclude": ["../../../**/*test.ts", "../../**/*api.ts"],
"references": [
{ "path": "../../../src/common" },
{ "path": "../../../src/browser" }
{ "path": "../../../src/target-browser" }
]
}
@@ -6,10 +6,10 @@
import jsdom = require('jsdom');
import { assert } from 'chai';
import { SerializeAddon } from './SerializeAddon';
import { Terminal } from 'browser/public/Terminal';
import { SelectionModel } from 'browser/selection/SelectionModel';
import { Terminal } from 'target-browser/public/Terminal';
import { SelectionModel } from 'target-browser/selection/SelectionModel';
import { IBufferService } from 'common/services/Services';
import { ThemeService } from 'browser/services/ThemeService';
import { ThemeService } from 'target-browser/services/ThemeService';
function sgr(...seq: string[]): string {
return `\x1b[${seq.join(';')}m`;
+1 -1
View File
@@ -8,7 +8,7 @@
import type { IBuffer, IBufferCell, IBufferRange, ITerminalAddon, Terminal } from '@xterm/xterm';
import type { IHTMLSerializeOptions, SerializeAddon as ISerializeApi, ISerializeOptions, ISerializeRange } from '@xterm/addon-serialize';
import { IAttributeData, IColor } from 'common/Types';
import { DEFAULT_ANSI_COLORS } from 'browser/Types';
import { DEFAULT_ANSI_COLORS } from 'target-browser/Types';
import { UnderlineStyle } from 'common/buffer/Constants';
function constrain(value: number, low: number, high: number): number {
+3 -3
View File
@@ -16,8 +16,8 @@
"../../../src/common/runtime/*",
"../../../src/common/*"
],
"browser/*": [
"../../../src/browser/*"
"target-browser/*": [
"../../../src/target-browser/*"
],
"@xterm/addon-serialize": [
"../typings/addon-serialize.d.ts"
@@ -38,7 +38,7 @@
"path": "../../../src/common"
},
{
"path": "../../../src/browser"
"path": "../../../src/target-browser"
}
]
}
+3 -3
View File
@@ -15,8 +15,8 @@
"../../../src/common/runtime/*",
"../../../src/common/*"
],
"browser/*": [
"../../../src/browser/*"
"target-browser/*": [
"../../../src/target-browser/*"
]
},
"strict": true,
@@ -33,7 +33,7 @@
"path": "../../../src/common"
},
{
"path": "../../../src/browser"
"path": "../../../src/target-browser"
},
{
"path": "../../../test/playwright"
+1 -1
View File
@@ -26,7 +26,7 @@ module.exports = {
extensions: [ '.js' ],
alias: {
common: path.resolve('../../out/common'),
browser: path.resolve('../../out/browser')
browser: path.resolve('../../out/target-browser')
}
},
output: {
@@ -7,7 +7,7 @@ import { perfContext, before, ThroughputRuntimeCase } from 'xterm-benchmark';
import { spawn } from 'node-pty';
import { Utf8ToUtf32, stringFromCodePoint } from 'common/input/TextDecoder';
import { CoreBrowserTerminal } from 'browser/CoreBrowserTerminal';
import { CoreBrowserTerminal } from 'target-browser/CoreBrowserTerminal';
import { UnicodeGraphemeProvider } from 'UnicodeGraphemeProvider';
@@ -14,7 +14,7 @@
"../../../src/common/runtime/*",
"../../../src/common/*"
],
"browser/*": ["../../../src/browser/*"],
"target-browser/*": ["../../../src/target-browser/*"],
"UnicodeGraphemeProvider": ["../src/UnicodeGraphemeProvider"],
"@xterm/addon-unicode-graphemes": [
"../typings/addon-unicode-graphemes.d.ts"
@@ -25,6 +25,6 @@
"exclude": ["../../../**/*test.ts", "../../**/*api.ts"],
"references": [
{ "path": "../../../src/common" },
{ "path": "../../../src/browser" }
{ "path": "../../../src/target-browser" }
]
}
@@ -4,8 +4,8 @@
*/
import { IUnicodeVersionProvider } from '@xterm/xterm';
import { UnicodeCharProperties, UnicodeCharWidth } from 'common/services/Services';
import { UnicodeService } from 'common/services/UnicodeService';
import { createPropertyValue, extractCharKind, extractWidth } from 'common/input/UnicodeProperties';
import { UnicodeCharProperties, UnicodeCharWidth } from 'common/input/UnicodeTypes';
import * as UC from './third-party/UnicodeProperties';
export class UnicodeGraphemeProvider implements IUnicodeVersionProvider {
@@ -19,7 +19,7 @@ export class UnicodeGraphemeProvider implements IUnicodeVersionProvider {
}
private static readonly _plainNarrowProperties: UnicodeCharProperties
= UnicodeService.createPropertyValue(UC.GRAPHEME_BREAK_Other, 1, false);
= createPropertyValue(UC.GRAPHEME_BREAK_Other, 1, false);
public charProperties(codepoint: number, preceding: UnicodeCharProperties): UnicodeCharProperties {
// Optimize the simple ASCII case, under the condition that
@@ -39,9 +39,9 @@ export class UnicodeGraphemeProvider implements IUnicodeVersionProvider {
w = 1;
}
if (preceding !== 0) {
const oldWidth = UnicodeService.extractWidth(preceding);
const oldWidth = extractWidth(preceding);
if (this.handleGraphemes) {
charInfo = UC.shouldJoin(UnicodeService.extractCharKind(preceding), charInfo);
charInfo = UC.shouldJoin(extractCharKind(preceding), charInfo);
} else {
charInfo = w === 0 ? 1 : 0;
}
@@ -54,7 +54,7 @@ export class UnicodeGraphemeProvider implements IUnicodeVersionProvider {
}
}
}
return UnicodeService.createPropertyValue(charInfo, w, shouldJoin);
return createPropertyValue(charInfo, w, shouldJoin);
}
public wcwidth(codepoint: number): UnicodeCharWidth {
@@ -15,8 +15,8 @@
"../../../src/common/runtime/*",
"../../../src/common/*"
],
"browser/*": [
"../../../src/browser/*"
"target-browser/*": [
"../../../src/target-browser/*"
]
},
"strict": true,
@@ -33,7 +33,7 @@
"path": "../../../src/common"
},
{
"path": "../../../src/browser"
"path": "../../../src/target-browser"
},
{
"path": "../../../test/playwright"
+4 -4
View File
@@ -4,8 +4,8 @@
*/
import { IUnicodeVersionProvider } from '@xterm/xterm';
import { UnicodeCharProperties, UnicodeCharWidth } from 'common/services/Services';
import { UnicodeService } from 'common/services/UnicodeService';
import { createPropertyValue, extractWidth } from 'common/input/UnicodeProperties';
import { UnicodeCharProperties, UnicodeCharWidth } from 'common/input/UnicodeTypes';
const BMP_COMBINING = [
[0x0300, 0x036F], [0x0483, 0x0489], [0x0591, 0x05BD],
@@ -223,13 +223,13 @@ export class UnicodeV11 implements IUnicodeVersionProvider {
let width = this.wcwidth(codepoint);
let shouldJoin = width === 0 && preceding !== 0;
if (shouldJoin) {
const oldWidth = UnicodeService.extractWidth(preceding);
const oldWidth = extractWidth(preceding);
if (oldWidth === 0) {
shouldJoin = false;
} else if (oldWidth > width) {
width = oldWidth;
}
}
return UnicodeService.createPropertyValue(0, width, shouldJoin);
return createPropertyValue(0, width, shouldJoin);
}
}
+3 -3
View File
@@ -15,8 +15,8 @@
"../../../src/common/runtime/*",
"../../../src/common/*"
],
"browser/*": [
"../../../src/browser/*"
"target-browser/*": [
"../../../src/target-browser/*"
],
"*": [
"./*"
@@ -36,7 +36,7 @@
"path": "../../../src/common"
},
{
"path": "../../../src/browser"
"path": "../../../src/target-browser"
},
{
"path": "../../../test/playwright"
+3 -3
View File
@@ -15,8 +15,8 @@
"../../../src/common/runtime/*",
"../../../src/common/*"
],
"browser/*": [
"../../../src/browser/*"
"target-browser/*": [
"../../../src/target-browser/*"
],
"*": [
"./*"
@@ -36,7 +36,7 @@
"path": "../../../src/common"
},
{
"path": "../../../src/browser"
"path": "../../../src/target-browser"
},
{
"path": "../../../test/playwright"
+3 -3
View File
@@ -15,8 +15,8 @@
"../../../src/common/runtime/*",
"../../../src/common/*"
],
"browser/*": [
"../../../src/browser/*"
"target-browser/*": [
"../../../src/target-browser/*"
],
"*": [
"./*"
@@ -36,7 +36,7 @@
"path": "../../../src/common"
},
{
"path": "../../../src/browser"
"path": "../../../src/target-browser"
},
{
"path": "../../../test/playwright"
+4 -4
View File
@@ -1,12 +1,12 @@
import { ISelectionRenderModel } from 'browser/renderer/shared/Types';
import { ICoreBrowserService, IThemeService } from 'browser/services/Services';
import { ReadonlyColorSet } from 'browser/Types';
import { ISelectionRenderModel } from 'target-browser/renderer/shared/Types';
import { ICoreBrowserService, IThemeService } from 'target-browser/services/Services';
import { ReadonlyColorSet } from 'target-browser/Types';
import { Attributes, BgFlags, ExtFlags, FgFlags, NULL_CELL_CODE, UnderlineStyle } from 'common/buffer/Constants';
import { IDecorationService, IOptionsService } from 'common/services/Services';
import { ICellData } from 'common/Types';
import { Terminal } from '@xterm/xterm';
import { rgba } from 'common/Color';
import { treatGlyphAsBackgroundColor } from 'browser/renderer/shared/RendererUtils';
import { treatGlyphAsBackgroundColor } from 'target-browser/renderer/shared/RendererUtils';
import { blockPatternCodepoints } from './customGlyphs/CustomGlyphDefinitions';
// Work variables to avoid garbage collection
+1 -1
View File
@@ -5,7 +5,7 @@
import { TextureAtlas } from './TextureAtlas';
import { ITerminalOptions, Terminal } from '@xterm/xterm';
import { ITerminal, ReadonlyColorSet } from 'browser/Types';
import { ITerminal, ReadonlyColorSet } from 'target-browser/Types';
import { ICharAtlasConfig, ITextureAtlas } from './Types';
import { generateConfig, configEquals } from './CharAtlasUtils';
import type { ILogService } from 'common/services/Services';
+1 -1
View File
@@ -6,7 +6,7 @@
import { ICharAtlasConfig } from './Types';
import { Attributes } from 'common/buffer/Constants';
import { ITerminalOptions } from '@xterm/xterm';
import { IColorSet, ReadonlyColorSet } from 'browser/Types';
import { IColorSet, ReadonlyColorSet } from 'target-browser/Types';
import { NULL_COLOR } from 'common/Color';
export function generateConfig(deviceCellWidth: number, deviceCellHeight: number, deviceCharWidth: number, deviceCharHeight: number, options: Required<ITerminalOptions>, colors: ReadonlyColorSet, devicePixelRatio: number, deviceMaxTextureSize: number, customGlyphs: boolean = true): ICharAtlasConfig {
@@ -3,8 +3,8 @@
* @license MIT
*/
import { RendererConstants } from 'browser/renderer/shared/Constants';
import { ICoreBrowserService } from 'browser/services/Services';
import { RendererConstants } from 'target-browser/renderer/shared/Constants';
import { ICoreBrowserService } from 'target-browser/services/Services';
const enum Constants {
/**
+2 -2
View File
@@ -3,14 +3,14 @@
* @license MIT
*/
import { TextureAtlas } from './TextureAtlas';
import { IRenderDimensions } from 'browser/renderer/shared/Types';
import { IRenderDimensions } from 'target-browser/renderer/shared/Types';
import { NULL_CELL_CODE } from 'common/buffer/Constants';
import { Disposable, toDisposable } from 'common/Lifecycle';
import { Terminal } from '@xterm/xterm';
import { IRenderModel, IWebGL2RenderingContext, IWebGLVertexArrayObject, type IRasterizedGlyph, type ITextureAtlas } from './Types';
import { createProgram, GLTexture, PROJECTION_MATRIX } from './WebglUtils';
import type { ILogService, IOptionsService } from 'common/services/Services';
import { allowRescaling, throwIfFalsy } from 'browser/renderer/shared/RendererUtils';
import { allowRescaling, throwIfFalsy } from 'target-browser/renderer/shared/RendererUtils';
interface IVertices {
attributes: Float32Array;
+4 -4
View File
@@ -3,9 +3,9 @@
* @license MIT
*/
import { IRenderDimensions } from 'browser/renderer/shared/Types';
import { IThemeService } from 'browser/services/Services';
import { ReadonlyColorSet } from 'browser/Types';
import { IRenderDimensions } from 'target-browser/renderer/shared/Types';
import { IThemeService } from 'target-browser/services/Services';
import { ReadonlyColorSet } from 'target-browser/Types';
import { Attributes, FgFlags } from 'common/buffer/Constants';
import { Disposable, toDisposable } from 'common/Lifecycle';
import { IColor } from 'common/Types';
@@ -13,7 +13,7 @@ import { Terminal } from '@xterm/xterm';
import { RenderModelConstants } from './RenderModel';
import { IRenderModel, IWebGL2RenderingContext, IWebGLVertexArrayObject } from './Types';
import { createProgram, expandFloat32Array, PROJECTION_MATRIX } from './WebglUtils';
import { throwIfFalsy } from 'browser/renderer/shared/RendererUtils';
import { throwIfFalsy } from 'target-browser/renderer/shared/RendererUtils';
import type { ILogService } from 'common/services/Services';
const enum VertexAttribLocations {
+2 -2
View File
@@ -4,8 +4,8 @@
*/
import { ICursorRenderModel, IRenderModel } from './Types';
import { ISelectionRenderModel } from 'browser/renderer/shared/Types';
import { createSelectionRenderModel } from 'browser/renderer/shared/SelectionRenderModel';
import { ISelectionRenderModel } from 'target-browser/renderer/shared/Types';
import { createSelectionRenderModel } from 'target-browser/renderer/shared/SelectionRenderModel';
export const enum RenderModelConstants {
INDICIES_PER_CELL = 4,
+2 -2
View File
@@ -3,10 +3,10 @@
* @license MIT
*/
import { IColorContrastCache } from 'browser/Types';
import { IColorContrastCache } from 'target-browser/Types';
import { DIM_OPACITY, TEXT_BASELINE } from './Constants';
import { tryDrawCustomGlyph } from './customGlyphs/CustomGlyphRasterizer';
import { computeNextVariantOffset, treatGlyphAsBackgroundColor, isPowerlineGlyph, isRestrictedPowerlineGlyph, throwIfFalsy } from 'browser/renderer/shared/RendererUtils';
import { computeNextVariantOffset, treatGlyphAsBackgroundColor, isPowerlineGlyph, isRestrictedPowerlineGlyph, throwIfFalsy } from 'target-browser/renderer/shared/RendererUtils';
import { IBoundingBox, ICharAtlasConfig, IRasterizedGlyph, ITextureAtlas } from './Types';
import { NULL_COLOR, channels, color, rgba } from 'common/Color';
import { FourKeyMap } from 'common/MultiKeyMap';
+2 -2
View File
@@ -4,8 +4,8 @@
*/
import { FontWeight } from '@xterm/xterm';
import { IColorSet } from 'browser/Types';
import { ISelectionRenderModel } from 'browser/renderer/shared/Types';
import { IColorSet } from 'target-browser/Types';
import { ISelectionRenderModel } from 'target-browser/renderer/shared/Types';
import { CursorInactiveStyle, CursorStyle, type IDisposable } from 'common/Types';
import type { IEvent } from 'common/Event';
+2 -2
View File
@@ -5,8 +5,8 @@
import type { ITerminalAddon, Terminal } from '@xterm/xterm';
import type { IWebglAddonOptions, WebglAddon as IWebglApi } from '@xterm/addon-webgl';
import { ICharacterJoinerService, ICharSizeService, ICoreBrowserService, IRenderService, IThemeService } from 'browser/services/Services';
import { ITerminal } from 'browser/Types';
import { ICharacterJoinerService, ICharSizeService, ICoreBrowserService, IRenderService, IThemeService } from 'target-browser/services/Services';
import { ITerminal } from 'target-browser/Types';
import { Disposable, toDisposable } from 'common/Lifecycle';
import { getSafariVersion, isSafari } from 'common/Platform';
import { ICoreService, IDecorationService, ILogService, IOptionsService } from 'common/services/Services';
+6 -6
View File
@@ -3,18 +3,18 @@
* @license MIT
*/
import { ITerminal } from 'browser/Types';
import { ITerminal } from 'target-browser/Types';
import { CellColorResolver } from './CellColorResolver';
import { acquireTextureAtlas, removeTerminalFromCache } from './CharAtlasCache';
import { CursorBlinkStateManager } from './CursorBlinkStateManager';
import { observeDevicePixelDimensions } from './DevicePixelObserver';
import { IRenderDimensions, IRenderer, IRequestRedrawEvent } from 'browser/renderer/shared/Types';
import { ICharSizeService, ICharacterJoinerService, ICoreBrowserService, IThemeService } from 'browser/services/Services';
import { IRenderDimensions, IRenderer, IRequestRedrawEvent } from 'target-browser/renderer/shared/Types';
import { ICharSizeService, ICharacterJoinerService, ICoreBrowserService, IThemeService } from 'target-browser/services/Services';
import { CharData, IBufferLine, ICellData } from 'common/Types';
import { AttributeData } from 'common/buffer/AttributeData';
import { CellData } from 'common/buffer/CellData';
import { Attributes, Content, FgFlags, NULL_CELL_CHAR, NULL_CELL_CODE } from 'common/buffer/Constants';
import { TextBlinkStateManager } from 'browser/renderer/shared/TextBlinkStateManager';
import { TextBlinkStateManager } from 'target-browser/renderer/shared/TextBlinkStateManager';
import { ICoreService, IDecorationService, ILogService, IOptionsService } from 'common/services/Services';
import { Terminal } from '@xterm/xterm';
import { GlyphRenderer } from './GlyphRenderer';
@@ -24,9 +24,9 @@ import { IWebGL2RenderingContext, type ITextureAtlas } from './Types';
import { LinkRenderLayer } from './renderLayer/LinkRenderLayer';
import { IRenderLayer } from './renderLayer/Types';
import { Emitter, EventUtils } from 'common/Event';
import { addDisposableListener } from 'browser/Dom';
import { addDisposableListener } from 'target-browser/Dom';
import { combinedDisposable, Disposable, MutableDisposable, toDisposable } from 'common/Lifecycle';
import { createRenderDimensions } from 'browser/renderer/shared/RendererUtils';
import { createRenderDimensions } from 'target-browser/renderer/shared/RendererUtils';
const enum Constants {
MERGE_RETRY_LIMIT = 32
+1 -1
View File
@@ -3,7 +3,7 @@
* @license MIT
*/
import { throwIfFalsy } from 'browser/renderer/shared/RendererUtils';
import { throwIfFalsy } from 'target-browser/renderer/shared/RendererUtils';
import type { ILogService } from 'common/services/Services';
/**
@@ -3,7 +3,7 @@
* @license MIT
*/
import { throwIfFalsy } from 'browser/renderer/shared/RendererUtils';
import { throwIfFalsy } from 'target-browser/renderer/shared/RendererUtils';
import type { ILogService } from 'common/services/Services';
import { customGlyphDefinitions } from './CustomGlyphDefinitions';
import { CustomGlyphDefinitionType, CustomGlyphScaleType, CustomGlyphVectorType, type CustomGlyphDefinitionPart, type CustomGlyphPathDrawFunctionDefinition, type CustomGlyphPatternDefinition, type ICustomGlyphSolidOctantBlockVector, type ICustomGlyphVectorShape } from './Types';
@@ -3,16 +3,16 @@
* @license MIT
*/
import { ReadonlyColorSet } from 'browser/Types';
import { ReadonlyColorSet } from 'target-browser/Types';
import { acquireTextureAtlas } from '../CharAtlasCache';
import { IRenderDimensions } from 'browser/renderer/shared/Types';
import { ICoreBrowserService, IThemeService } from 'browser/services/Services';
import { IRenderDimensions } from 'target-browser/renderer/shared/Types';
import { ICoreBrowserService, IThemeService } from 'target-browser/services/Services';
import { Disposable, toDisposable } from 'common/Lifecycle';
import { CellData } from 'common/buffer/CellData';
import { IOptionsService } from 'common/services/Services';
import { Terminal } from '@xterm/xterm';
import { IRenderLayer } from './Types';
import { throwIfFalsy } from 'browser/renderer/shared/RendererUtils';
import { throwIfFalsy } from 'target-browser/renderer/shared/RendererUtils';
import { TEXT_BASELINE } from '../Constants';
import type { ITextureAtlas } from '../Types';
@@ -4,10 +4,10 @@
*/
import { is256Color } from '../CharAtlasUtils';
import { INVERTED_DEFAULT_COLOR } from 'browser/renderer/shared/Constants';
import { IRenderDimensions } from 'browser/renderer/shared/Types';
import { ICoreBrowserService, IThemeService } from 'browser/services/Services';
import { ILinkifier2, ILinkifierEvent } from 'browser/Types';
import { INVERTED_DEFAULT_COLOR } from 'target-browser/renderer/shared/Constants';
import { IRenderDimensions } from 'target-browser/renderer/shared/Types';
import { ICoreBrowserService, IThemeService } from 'target-browser/services/Services';
import { ILinkifier2, ILinkifierEvent } from 'target-browser/Types';
import { IOptionsService } from 'common/services/Services';
import { Terminal } from '@xterm/xterm';
import { BaseRenderLayer } from './BaseRenderLayer';
+1 -1
View File
@@ -4,7 +4,7 @@
*/
import { IDisposable, Terminal } from '@xterm/xterm';
import { IRenderDimensions } from 'browser/renderer/shared/Types';
import { IRenderDimensions } from 'target-browser/renderer/shared/Types';
export interface IRenderLayer extends IDisposable {
/**
+3 -3
View File
@@ -16,8 +16,8 @@
"../../../src/common/runtime/*",
"../../../src/common/*"
],
"browser/*": [
"../../../src/browser/*"
"target-browser/*": [
"../../../src/target-browser/*"
],
"@xterm/addon-webgl": [
"../typings/addon-webgl.d.ts"
@@ -41,7 +41,7 @@
"path": "../../../src/common"
},
{
"path": "../../../src/browser"
"path": "../../../src/target-browser"
}
]
}
+3 -3
View File
@@ -15,8 +15,8 @@
"../../../src/common/runtime/*",
"../../../src/common/*"
],
"browser/*": [
"../../../src/browser/*"
"target-browser/*": [
"../../../src/target-browser/*"
],
"*": [
"./*"
@@ -37,7 +37,7 @@
"path": "../../../src/common"
},
{
"path": "../../../src/browser"
"path": "../../../src/target-browser"
},
{
"path": "../../../test/playwright"
+1 -1
View File
@@ -26,7 +26,7 @@ module.exports = {
extensions: [ '.js' ],
alias: {
common: path.resolve('../../out/common'),
browser: path.resolve('../../out/browser'),
browser: path.resolve('../../out/target-browser'),
vs: path.resolve('../../out/vs')
}
},
+37 -15
View File
@@ -92,6 +92,9 @@ let outConfig = {
}
let skipOut = false;
/** @type {esbuild.BuildOptions[] | undefined} */
let outBuilds;
/** @type {esbuild.BuildOptions} */
let outTestConfig = {
format: 'cjs',
@@ -171,7 +174,7 @@ if (config.addon) {
} else if (config.isHeadless) {
bundleConfig = {
...bundleConfig,
entryPoints: [`src/headless/public/Terminal.ts`],
entryPoints: [`src/target-headless/public/Terminal.ts`],
outfile: `headless/lib-headless/xterm-headless.mjs`
};
outConfig = {
@@ -183,20 +186,35 @@ if (config.addon) {
} else {
bundleConfig = {
...bundleConfig,
entryPoints: [`src/browser/public/Terminal.ts`],
entryPoints: [`src/target-browser/public/Terminal.ts`],
outfile: `lib/xterm.mjs`
};
outConfig = {
...outConfig,
entryPoints: [
'src/browser/**/*.ts',
'src/common/primitives/**/*.ts',
'src/common/runtime/**/*.ts',
'src/common/*.ts',
'src/headless/**/*.ts'
],
outdir: 'out-esbuild/'
};
outBuilds = [
{
...outConfig,
entryPoints: ['src/common/primitives/**/*.ts'],
outbase: 'src/common/primitives',
outdir: 'out-esbuild/common',
},
{
...outConfig,
entryPoints: ['src/common/runtime/**/*.ts'],
outbase: 'src/common/runtime',
outdir: 'out-esbuild/common',
},
{
...outConfig,
entryPoints: ['src/target-browser/**/*.ts'],
outbase: 'src',
outdir: 'out-esbuild',
},
{
...outConfig,
entryPoints: ['src/target-headless/**/*.ts'],
outbase: 'src',
outdir: 'out-esbuild',
},
];
outTestConfig = {
...outConfig,
entryPoints: ['test/**/*.ts'],
@@ -207,7 +225,9 @@ if (config.addon) {
if (config.isWatch) {
context(bundleConfig).then(e => e.watch());
if (!skipOut) {
context(outConfig).then(e => e.watch());
for (const buildConfig of outBuilds ?? [outConfig]) {
context(buildConfig).then(e => e.watch());
}
}
if (!skipOutTest) {
context(outTestConfig).then(e => e.watch());
@@ -215,7 +235,9 @@ if (config.isWatch) {
} else {
await build(bundleConfig);
if (!skipOut) {
await build(outConfig);
for (const buildConfig of outBuilds ?? [outConfig]) {
await build(buildConfig);
}
}
if (!skipOutTest) {
await build(outTestConfig);
+1 -1
View File
@@ -38,4 +38,4 @@ function findUnusedSymbols(
}
// Example usage
findUnusedSymbols("./src/browser/tsconfig.json");
findUnusedSymbols("./src/target-browser/tsconfig.json");
+38 -47
View File
@@ -1,79 +1,70 @@
# xterm.js source architecture
This document describes how `src/` is organized, with emphasis on the shared core under `src/common/`. The layout follows the refined proposal in [issue #5963](https://github.com/xtermjs/xterm.js/issues/5963): separate **primitives** (building blocks) from **runtime** (services and integration), while **browser** and **headless** remain target-specific entry points.
This document describes how `src/` is organized. The layout follows [issue #5963](https://github.com/xtermjs/xterm.js/issues/5963): **primitives** and **runtime** as separate TypeScript composite projects, with **target-browser** and **target-headless** as platform entry points.
## Layer overview
## Dependency graph
```mermaid
flowchart BT
primitives["common/primitives<br/>building blocks, high test coverage expected"]
primitives["common/primitives<br/>building blocks"]
runtime["common/runtime<br/>services, integration"]
browser["browser<br/>DOM terminal target"]
headless["headless<br/>Node terminal target"]
targetBrowser["target-browser<br/>DOM terminal"]
targetHeadless["target-headless<br/>Node terminal"]
runtime --> primitives
browser --> runtime
headless --> runtime
targetBrowser --> runtime
targetHeadless --> runtime
```
| Layer | Path | Role |
| --- | --- | --- |
| Primitives | `src/common/primitives/` | Low-level, mostly stateless building blocks: buffer, parser, escape/input helpers, static data, and shared utilities. These modules should be easy to unit test in isolation. |
| Runtime | `src/common/runtime/` | Stateful services (DI), `CoreTerminal`, `InputHandler`, public API adapters under `public/`, and other code that wires primitives into a working terminal core. |
| Shared types | `src/common/Types.ts` | Cross-cutting interfaces and types used by both layers (kept at the `common/` root until a stricter module API is introduced). |
| Browser target | `src/browser/` | Browser-only rendering, input, and the public `Terminal` wrapper. |
| Headless target | `src/headless/` | Node-oriented terminal without DOM; same public API shape as the browser build where applicable. |
## TypeScript projects
| Project | `tsconfig` | Output | Role |
| --- | --- | --- | --- |
| Primitives | `src/common/primitives/tsconfig.json` | `out/common/primitives/` | Buffer, parser, input helpers, static data, shared utilities. Must not import from `runtime/`. |
| Runtime | `src/common/runtime/tsconfig.json` | `out/common/runtime/` | Services (DI), `CoreTerminal`, `InputHandler`, public API adapters, `Types.ts`. References primitives. |
| Common (solution) | `src/common/tsconfig.json` | — | Solution root; references primitives + runtime only. |
| Target browser | `src/target-browser/tsconfig.json` | `out/target-browser/` | Browser rendering, input, public `Terminal`. References common. |
| Target headless | `src/target-headless/tsconfig.json` | `out/target-headless/` | Headless terminal. References common. |
Unit test files (`**/*.test.ts`) are excluded from composite library builds; they are compiled via esbuild for `npm run test-unit`.
## `common/primitives/`
| Area | Contents |
| --- | --- |
| Root utilities | `Async`, `CircularList`, `Color`, `Event`, `Lifecycle`, `MultiKeyMap`, `Platform`, `SortedList`, `StringBuilder`, `TaskQueue`, `Version` |
| `buffer/` | Screen buffer, cells, lines, markers, reflow |
| `data/` | Static tables (`Charsets`, `EscapeSequences`) |
| `input/` | UTF decoding, keyboard helpers, write buffer, color parsing |
| `parser/` | Escape-sequence parser (CSI, OSC, DCS, APC) |
| Root utilities | `Async`, `CircularList`, `Color`, `ColorTypes`, `Event`, `KeyboardTypes`, `Lifecycle`, `MultiKeyMap`, `Platform`, `SortedList`, `StringBuilder`, `TaskQueue`, `TerminalOptions`, `Version` |
| `buffer/` | Screen buffer, `CellTypes`, `BufferService` / `BufferOptions` / `BufferLog` interfaces (buffer-layer contracts) |
| `data/` | `Charsets`, `EscapeSequences` |
| `input/` | UTF decoding, keyboard helpers, `UnicodeTypes`, `UnicodeProperties` |
| `parser/` | Escape-sequence parser |
**Goals**
- Prefer comprehensive unit tests here; behavior should be understandable without constructing the full terminal stack.
- Avoid importing from `runtime/` when possible. Some legacy edges still reach into `common/services` (for example buffer logging hooks); tightening that is follow-up work, not a blocker for the folder split.
- Future work may split primitives into finer TypeScript projects (`base`, `encoding`, `buffer`, …) with enforced one-way references.
Primitives depend only on other primitives (and `@xterm/xterm` typings where needed). Buffer code uses `IBufferService` from `common/buffer/BufferService`, not `common/services/Services`.
## `common/runtime/`
| Area | Contents |
| --- | --- |
| `services/` | Dependency-injection services (`BufferService`, `OptionsService`, `CoreService`, …) |
| `public/` | Public API surface adapters (`AddonManager`, buffer/parser API views) |
| Root integration | `CoreTerminal`, `InputHandler`, `WindowsMode`, test helpers (`TestUtils.test.ts`) |
| `services/` | DI implementations (`BufferService`, `OptionsService`, …) |
| `public/` | Public API adapters (`AddonManager`, buffer/parser views) |
| Root | `CoreTerminal`, `InputHandler`, `WindowsMode`, `Types.ts`, `TestUtils.test.ts` |
**Goals**
- Own composition: instantiation, service registry, and the large integration classes (`InputHandler`).
- May depend on `primitives/` and on `common/Types.ts`; must not be depended on by primitives in the steady state (existing cycles are technical debt to remove incrementally).
- Integration and addon-facing behavior is validated by unit tests here and by browser/headless/integration tests at the target layer.
`Types.ts` re-exports primitive types and adds integration types (`IInputHandler`, `ICoreTerminal`, mouse/color helpers, etc.).
## Import paths
Source continues to use the existing `common/...` import prefix (for example `common/buffer/Buffer`, `common/services/Services`). TypeScript `paths` in `tsconfig.json` files map that prefix onto `primitives/`, `runtime/`, and the `common/` root so this restructure did not require mass import rewrites.
Source keeps the `common/...` prefix. Each project's `paths` in `tsconfig.json` map that prefix to the correct layer (primitives first, then runtime, for targets).
## Targets vs core
Platform code uses:
```mermaid
flowchart LR
subgraph core["Shared core"]
primitives
runtime
end
browser --> runtime
headless --> runtime
```
- `target-browser/...` — was `browser/...`
- `target-headless/...` — was `headless/...`
Browser and headless add platform code (renderers, DOM, Node specifics) on top of the same runtime core. Addons and the demo build against the published packages; their tsconfigs use the same `common/*` path mapping.
## Published packages vs source folders
The npm package directory `headless/` (e.g. `headless/lib-headless/`) is unchanged; only the **source** tree uses `src/target-headless/`.
## Related issues
- [#5963](https://github.com/xtermjs/xterm.js/issues/5963) — module split and TypeScript project structure
- [#5896](https://github.com/xtermjs/xterm.js/issues/5896) — relative imports (possible follow-up)
- [#5897](https://github.com/xtermjs/xterm.js/issues/5897) — `import/no-cycle` lint enforcement
- [#5963](https://github.com/xtermjs/xterm.js/issues/5963) — module split
- [#5896](https://github.com/xtermjs/xterm.js/issues/5896) — relative imports
- [#5897](https://github.com/xtermjs/xterm.js/issues/5897) — `import/no-cycle` lint
-29
View File
@@ -1,29 +0,0 @@
{
"extends": "../tsconfig-library-base",
"compilerOptions": {
"lib": [
"dom",
"es2021"
],
"outDir": "../../out",
"types": [
"../../node_modules/@types/mocha"
],
"skipLibCheck": true,
"paths": {
"common/*": [
"./../common/primitives/*",
"./../common/runtime/*",
"./../common/*"
],
"*": [ "./../*" ]
}
},
"include": [
"./**/*",
"../../typings/xterm.d.ts"
],
"references": [
{ "path": "../common" }
]
}
+23 -2
View File
@@ -3,9 +3,30 @@
* @license MIT
*/
import { ICircularList } from 'common/Types';
import { Disposable } from 'common/Lifecycle';
import { Emitter } from 'common/Event';
import { Emitter, type IEvent } from 'common/Event';
export interface ICircularList<T> {
length: number;
maxLength: number;
isFull: boolean;
onDeleteEmitter: Emitter<IDeleteEvent>;
onDelete: IEvent<IDeleteEvent>;
onInsertEmitter: Emitter<IInsertEvent>;
onInsert: IEvent<IInsertEvent>;
onTrimEmitter: Emitter<number>;
onTrim: IEvent<number>;
get(index: number): T | undefined;
set(index: number, value: T): void;
push(value: T): void;
recycle(): T;
pop(): T | undefined;
splice(start: number, deleteCount: number, ...items: T[]): void;
trimStart(count: number): void;
shiftElements(start: number, count: number, offset: number): void;
}
export interface IInsertEvent {
index: number;
+1 -1
View File
@@ -3,7 +3,7 @@
* @license MIT
*/
import { IColor, IColorRGB } from 'common/Types';
import { IColor, IColorRGB } from 'common/ColorTypes';
let $r = 0;
let $g = 0;
+11
View File
@@ -0,0 +1,11 @@
/**
* Copyright (c) 2018 The xterm.js authors. All rights reserved.
* @license MIT
*/
export interface IColor {
readonly css: string;
readonly rgba: number; // 32-bit int with rgba in each byte
}
export type IColorRGB = [red: number, green: number, blue: number];
+29
View File
@@ -0,0 +1,29 @@
/**
* Copyright (c) 2018 The xterm.js authors. All rights reserved.
* @license MIT
*/
export interface IKeyboardEvent {
altKey: boolean;
ctrlKey: boolean;
shiftKey: boolean;
metaKey: boolean;
/** @deprecated See KeyboardEvent.keyCode */
keyCode: number;
key: string;
type: string;
code: string;
}
export const enum KeyboardResultType {
SEND_KEY,
SELECT_ALL,
PAGE_UP,
PAGE_DOWN
}
export interface IKeyboardResult {
type: KeyboardResultType;
cancel: boolean;
key: string | undefined;
}
+2 -2
View File
@@ -4,7 +4,7 @@
*/
import { IdleTaskQueue } from 'common/TaskQueue';
import type { ILogService } from 'common/services/Services';
import type { IBufferLogService } from 'common/buffer/BufferLog';
// Work variables to avoid garbage collection.
let i = 0;
@@ -28,7 +28,7 @@ export class SortedList<T> {
constructor(
private readonly _getKey: (value: T) => number,
logService: ILogService
logService: IBufferLogService
) {
this._flushInsertedTask = new IdleTaskQueue(logService);
this._flushDeletedTask = new IdleTaskQueue(logService);
+4 -4
View File
@@ -3,7 +3,7 @@
* @license MIT
*/
import type { ILogService } from 'common/services/Services';
import type { IBufferLogService } from 'common/buffer/BufferLog';
interface ITaskQueue {
/**
@@ -34,9 +34,9 @@ abstract class TaskQueue implements ITaskQueue {
private _tasks: (() => boolean | void)[] = [];
private _idleCallback?: number;
private _i = 0;
protected readonly _logService: ILogService;
protected readonly _logService: IBufferLogService;
constructor(logService: ILogService) {
constructor(logService: IBufferLogService) {
this._logService = logService;
}
@@ -156,7 +156,7 @@ export const IdleTaskQueue = ('requestIdleCallback' in globalThis) ? IdleTaskQue
export class DebouncedIdleTask {
private _queue: ITaskQueue;
constructor(logService: ILogService) {
constructor(logService: IBufferLogService) {
this._queue = new IdleTaskQueue(logService);
}
+13
View File
@@ -0,0 +1,13 @@
/**
* Copyright (c) 2018 The xterm.js authors. All rights reserved.
* @license MIT
*/
import { ITerminalOptions as IPublicTerminalOptions } from '@xterm/xterm';
// TODO: The options that are not in the public API should be reviewed
export interface ITerminalOptions extends IPublicTerminalOptions {
[key: string]: any;
convertEol?: boolean;
termName?: string;
}
@@ -3,7 +3,7 @@
* @license MIT
*/
import { IAttributeData, IColorRGB, IExtendedAttrs } from 'common/Types';
import { IAttributeData, IColorRGB, IExtendedAttrs } from 'common/buffer/CellTypes';
import { Attributes, FgFlags, BgFlags, UnderlineStyle, ExtFlags } from 'common/buffer/Constants';
export class AttributeData implements IAttributeData {
+7 -5
View File
@@ -6,7 +6,10 @@
import { CircularList, IInsertEvent } from 'common/CircularList';
import { Disposable, toDisposable } from 'common/Lifecycle';
import { IdleTaskQueue } from 'common/TaskQueue';
import { IAttributeData, IBufferLine, ICellData, ICharset } from 'common/Types';
import { IAttributeData, IBufferLine, ICellData } from 'common/buffer/CellTypes';
import { IBufferLogService } from 'common/buffer/BufferLog';
import { IBufferOptionsService } from 'common/buffer/BufferOptions';
import { IBufferService } from 'common/buffer/BufferService';
import { ExtendedAttrs } from 'common/buffer/AttributeData';
import { BufferLine, DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine';
import { BufferLineStringCache } from 'common/buffer/BufferLineStringCache';
@@ -15,8 +18,7 @@ import { CellData } from 'common/buffer/CellData';
import { NULL_CELL_CHAR, NULL_CELL_CODE, NULL_CELL_WIDTH, WHITESPACE_CELL_CHAR, WHITESPACE_CELL_CODE, WHITESPACE_CELL_WIDTH } from 'common/buffer/Constants';
import { Marker } from 'common/buffer/Marker';
import { IBuffer } from 'common/buffer/Types';
import { DEFAULT_CHARSET } from 'common/data/Charsets';
import { IBufferService, ILogService, IOptionsService } from 'common/services/Services';
import { DEFAULT_CHARSET, ICharset } from 'common/data/Charsets';
export const MAX_BUFFER_SIZE = 4294967295; // 2^32 - 1
@@ -56,9 +58,9 @@ export class Buffer extends Disposable implements IBuffer {
constructor(
private _hasScrollback: boolean,
private _optionsService: IOptionsService,
private _optionsService: IBufferOptionsService,
private _bufferService: IBufferService,
private readonly _logService: ILogService
private readonly _logService: IBufferLogService
) {
super();
this._cols = this._bufferService.cols;
@@ -3,10 +3,10 @@
* @license MIT
*/
import { NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE, DEFAULT_ATTR, Content, UnderlineStyle, BgFlags, Attributes, FgFlags } from 'common/buffer/Constants';
import { BufferLine } from 'common/buffer//BufferLine';
import { BufferLine } from 'common/buffer/BufferLine';
import { BufferLineStringCache } from 'common/buffer/BufferLineStringCache';
import { CellData } from 'common/buffer/CellData';
import { CharData, IBufferLine, ICellData } from 'common/Types';
import { CharData, IBufferLine, ICellData } from 'common/buffer/CellTypes';
import { assert } from 'chai';
import { AttributeData } from 'common/buffer/AttributeData';
import { createCellData, NULL_CELL_DATA, extendedAttributes } from 'common/TestUtils.test';
+1 -1
View File
@@ -3,7 +3,7 @@
* @license MIT
*/
import { CharData, IAttributeData, IBufferLine, ICellData, IExtendedAttrs } from 'common/Types';
import { CharData, IAttributeData, IBufferLine, ICellData, IExtendedAttrs } from 'common/buffer/CellTypes';
import { AttributeData } from 'common/buffer/AttributeData';
import { CellData } from 'common/buffer/CellData';
import { Attributes, BgFlags, CHAR_DATA_ATTR_INDEX, CHAR_DATA_CHAR_INDEX, CHAR_DATA_WIDTH_INDEX, Content, NULL_CELL_CHAR, NULL_CELL_CODE, NULL_CELL_WIDTH, WHITESPACE_CELL_CHAR } from 'common/buffer/Constants';
@@ -0,0 +1,8 @@
/**
* Copyright (c) 2022 The xterm.js authors. All rights reserved.
* @license MIT
*/
export interface IBufferLogService {
warn(message: any, ...optionalParams: any[]): void;
}
@@ -0,0 +1,15 @@
/**
* Copyright (c) 2019 The xterm.js authors. All rights reserved.
* @license MIT
*/
import type { IDisposable } from 'common/Lifecycle';
import type { ITerminalOptions } from 'common/TerminalOptions';
/**
* Options surface used by the buffer layer.
*/
export interface IBufferOptionsService {
readonly rawOptions: Required<ITerminalOptions>;
onSpecificOptionChange<K extends keyof ITerminalOptions>(key: K, callback: (value: ITerminalOptions[K]) => void): IDisposable;
}
+1 -1
View File
@@ -5,7 +5,7 @@
import { BufferLine } from 'common/buffer/BufferLine';
import { CircularList } from 'common/CircularList';
import { IBufferLine, ICellData } from 'common/Types';
import { IBufferLine, ICellData } from 'common/buffer/CellTypes';
export interface INewLayoutResult {
layout: number[];
@@ -0,0 +1,31 @@
/**
* Copyright (c) 2019 The xterm.js authors. All rights reserved.
* @license MIT
*/
import type { IEvent } from 'common/Event';
import type { IAttributeData } from 'common/buffer/CellTypes';
import type { IBuffer, IBufferSet } from 'common/buffer/Types';
export interface IBufferResizeEvent {
cols: number;
rows: number;
colsChanged: boolean;
rowsChanged: boolean;
}
export interface IBufferService {
serviceBrand: undefined;
readonly cols: number;
readonly rows: number;
readonly buffer: IBuffer;
readonly buffers: IBufferSet;
isUserScrolling: boolean;
onResize: IEvent<IBufferResizeEvent>;
onScroll: IEvent<number>;
scroll(eraseAttr: IAttributeData, isWrapped?: boolean): void;
scrollLines(disp: number, suppressScrollEvent?: boolean): void;
resize(cols: number, rows: number): void;
reset(): void;
}
+6 -4
View File
@@ -4,10 +4,12 @@
*/
import { Disposable, MutableDisposable } from 'common/Lifecycle';
import { IAttributeData } from 'common/Types';
import { IAttributeData } from 'common/buffer/CellTypes';
import { Buffer } from 'common/buffer/Buffer';
import { IBuffer, IBufferSet } from 'common/buffer/Types';
import { IBufferService, ILogService, IOptionsService } from 'common/services/Services';
import { IBufferLogService } from 'common/buffer/BufferLog';
import { IBufferOptionsService } from 'common/buffer/BufferOptions';
import { IBufferService } from 'common/buffer/BufferService';
import { Emitter } from 'common/Event';
/**
@@ -28,9 +30,9 @@ export class BufferSet extends Disposable implements IBufferSet {
* Create a new BufferSet for the given terminal.
*/
constructor(
private readonly _optionsService: IOptionsService,
private readonly _optionsService: IBufferOptionsService,
private readonly _bufferService: IBufferService,
private readonly _logService: ILogService
private readonly _logService: IBufferLogService
) {
super();
this.reset();
+1 -1
View File
@@ -3,7 +3,7 @@
* @license MIT
*/
import { CharData, ICellData, IExtendedAttrs } from 'common/Types';
import { CharData, ICellData, IExtendedAttrs } from 'common/buffer/CellTypes';
import { stringFromCodePoint } from 'common/input/TextDecoder';
import { CHAR_DATA_CHAR_INDEX, CHAR_DATA_WIDTH_INDEX, CHAR_DATA_ATTR_INDEX, Content } from 'common/buffer/Constants';
import { AttributeData, ExtendedAttrs } from 'common/buffer/AttributeData';
+120
View File
@@ -0,0 +1,120 @@
/**
* Copyright (c) 2018 The xterm.js authors. All rights reserved.
* @license MIT
*/
import type { UnderlineStyle } from 'common/buffer/Constants';
import type { IDisposable } from 'common/Lifecycle';
import type { IEvent } from 'common/Event';
export type { IColorRGB } from 'common/ColorTypes';
export type CharData = [attr: number, char: string, width: number, code: number];
export interface IExtendedAttrs {
ext: number;
underlineStyle: UnderlineStyle;
underlineColor: number;
underlineVariantOffset: number;
urlId: number;
clone(): IExtendedAttrs;
isEmpty(): boolean;
}
/**
* An object that represents all attributes of a cell.
*/
export interface IAttributeData {
fg: number;
bg: number;
extended: IExtendedAttrs;
clone(): IAttributeData;
isInverse(): number;
isBold(): number;
isUnderline(): number;
isBlink(): number;
isInvisible(): number;
isItalic(): number;
isDim(): number;
isStrikethrough(): number;
isProtected(): number;
isOverline(): number;
getFgColorMode(): number;
getBgColorMode(): number;
isFgRGB(): boolean;
isBgRGB(): boolean;
isFgPalette(): boolean;
isBgPalette(): boolean;
isFgDefault(): boolean;
isBgDefault(): boolean;
isAttributeDefault(): boolean;
getFgColor(): number;
getBgColor(): number;
hasExtendedAttrs(): number;
updateExtended(): void;
getUnderlineColor(): number;
getUnderlineColorMode(): number;
isUnderlineColorRGB(): boolean;
isUnderlineColorPalette(): boolean;
isUnderlineColorDefault(): boolean;
getUnderlineStyle(): number;
getUnderlineVariantOffset(): number;
}
/** Cell data */
export interface ICellData extends IAttributeData {
content: number;
combinedData: string;
isCombined(): number;
getWidth(): number;
getChars(): string;
getCode(): number;
setFromCharData(value: CharData): void;
getAsCharData(): CharData;
}
/**
* Interface for a line in the terminal buffer.
*/
export interface IBufferLine {
length: number;
isWrapped: boolean;
get(index: number): CharData;
set(index: number, value: CharData): void;
loadCell(index: number, cell: ICellData): ICellData;
setCell(index: number, cell: ICellData): void;
setCellFromCodepoint(index: number, codePoint: number, width: number, attrs: IAttributeData): void;
addCodepointToCell(index: number, codePoint: number, width: number): void;
insertCells(pos: number, n: number, ch: ICellData): void;
deleteCells(pos: number, n: number, fill: ICellData): void;
replaceCells(start: number, end: number, fill: ICellData, respectProtect?: boolean): void;
resize(cols: number, fill: ICellData): boolean;
cleanupMemory(): number;
fill(fillCellData: ICellData, respectProtect?: boolean): void;
copyFrom(line: IBufferLine): void;
clone(): IBufferLine;
getTrimmedLength(): number;
getNoBgTrimmedLength(): number;
translateToString(trimRight?: boolean, startCol?: number, endCol?: number, outColumns?: number[]): string;
getWidth(index: number): number;
hasWidth(index: number): number;
getFg(index: number): number;
getBg(index: number): number;
hasContent(index: number): number;
getCodePoint(index: number): number;
isCombined(index: number): number;
getString(index: number): string;
}
export interface IMarker extends IDisposable {
readonly id: number;
readonly isDisposed: boolean;
readonly line: number;
onDispose: IEvent<void>;
}
+2 -2
View File
@@ -3,9 +3,9 @@
* @license MIT
*/
import { IDisposable, IMarker } from 'common/Types';
import { dispose, type IDisposable } from 'common/Lifecycle';
import { IMarker } from 'common/buffer/CellTypes';
import { Emitter } from 'common/Event';
import { dispose } from 'common/Lifecycle';
export class Marker implements IMarker {
private static _nextId = 1;
+4 -1
View File
@@ -3,7 +3,10 @@
* @license MIT
*/
import { IAttributeData, ICircularList, IBufferLine, ICellData, IMarker, ICharset, IDisposable } from 'common/Types';
import { IAttributeData, IBufferLine, ICellData, IMarker } from 'common/buffer/CellTypes';
import { ICircularList } from 'common/CircularList';
import { ICharset } from 'common/data/Charsets';
import type { IDisposable } from 'common/Lifecycle';
import type { IEvent } from 'common/Event';
// BufferIndex denotes a position in the buffer: [rowIndex, colIndex]
+3 -1
View File
@@ -3,7 +3,9 @@
* @license MIT
*/
import { ICharset } from 'common/Types';
export interface ICharset {
[key: string]: string | undefined;
}
/**
* The character sets supported by the terminal. These enable several languages
+1 -1
View File
@@ -1,7 +1,7 @@
import { assert } from 'chai';
import { evaluateKeyboardEvent } from 'common/input/Keyboard';
import { IKeyboardResult, IKeyboardEvent } from 'common/Types';
import { IKeyboardResult, IKeyboardEvent } from 'common/KeyboardTypes';
/**
* A helper function for testing which allows passing in a partial event and defaults will be filled
+1 -1
View File
@@ -4,7 +4,7 @@
* @license MIT
*/
import { IKeyboardEvent, IKeyboardResult, KeyboardResultType } from 'common/Types';
import { IKeyboardEvent, IKeyboardResult, KeyboardResultType } from 'common/KeyboardTypes';
import { C0 } from 'common/data/EscapeSequences';
// reg + shift key mappings for digits and special chars
@@ -1,7 +1,7 @@
import { assert } from 'chai';
import { KittyKeyboard, KittyKeyboardEventType, KittyKeyboardFlags } from 'common/input/KittyKeyboard';
import { IKeyboardEvent } from 'common/Types';
import { IKeyboardEvent } from 'common/KeyboardTypes';
function createEvent(partialEvent: Partial<IKeyboardEvent> = {}): IKeyboardEvent {
return {
+1 -1
View File
@@ -6,7 +6,7 @@
* @see https://sw.kovidgoyal.net/kitty/keyboard-protocol/
*/
import { IKeyboardEvent, IKeyboardResult, KeyboardResultType } from 'common/Types';
import { IKeyboardEvent, IKeyboardResult, KeyboardResultType } from 'common/KeyboardTypes';
import { C0 } from 'common/data/EscapeSequences';
/**
@@ -0,0 +1,22 @@
/**
* Copyright (c) 2019 The xterm.js authors. All rights reserved.
* @license MIT
*/
import type { UnicodeCharProperties, UnicodeCharWidth } from 'common/input/UnicodeTypes';
export function extractShouldJoin(value: UnicodeCharProperties): boolean {
return (value & 1) !== 0;
}
export function extractWidth(value: UnicodeCharProperties): UnicodeCharWidth {
return ((value >> 1) & 0x3) as UnicodeCharWidth;
}
export function extractCharKind(value: UnicodeCharProperties): number {
return value >> 3;
}
export function createPropertyValue(state: number, width: number, shouldJoin: boolean = false): UnicodeCharProperties {
return ((state & 0xffffff) << 3) | ((width & 3) << 1) | (shouldJoin ? 1 : 0);
}
@@ -0,0 +1,24 @@
/**
* Copyright (c) 2019 The xterm.js authors. All rights reserved.
* @license MIT
*/
/*
* Width and Grapheme_Cluster_Break properties of a character as a bit mask.
*
* bit 0: shouldJoin - should combine with preceding character.
* bit 1..2: wcwidth - see UnicodeCharWidth.
* bit 3..31: class of character (currently only 4 bits are used).
*/
export type UnicodeCharProperties = number;
/**
* Width in columns of a character.
*/
export type UnicodeCharWidth = 0 | 1 | 2;
export interface IUnicodeVersionProvider {
readonly version: string;
wcwidth(ucs: number): UnicodeCharWidth;
charProperties(codepoint: number, preceding: UnicodeCharProperties): UnicodeCharProperties;
}
+4 -4
View File
@@ -2,8 +2,8 @@
* Copyright (c) 2019 The xterm.js authors. All rights reserved.
* @license MIT
*/
import { IUnicodeVersionProvider, UnicodeCharProperties, UnicodeCharWidth } from 'common/services/Services';
import { UnicodeService } from 'common/services/UnicodeService';
import { createPropertyValue, extractWidth } from 'common/input/UnicodeProperties';
import { IUnicodeVersionProvider, UnicodeCharProperties, UnicodeCharWidth } from 'common/input/UnicodeTypes';
const BMP_COMBINING = [
[0x0300, 0x036F], [0x0483, 0x0486], [0x0488, 0x0489],
@@ -133,13 +133,13 @@ export class UnicodeV6 implements IUnicodeVersionProvider {
let width = this.wcwidth(codepoint);
let shouldJoin = width === 0 && preceding !== 0;
if (shouldJoin) {
const oldWidth = UnicodeService.extractWidth(preceding);
const oldWidth = extractWidth(preceding);
if (oldWidth === 0) {
shouldJoin = false;
} else if (oldWidth > width) {
width = oldWidth;
}
}
return UnicodeService.createPropertyValue(0, width, shouldJoin);
return createPropertyValue(0, width, shouldJoin);
}
}
@@ -5,7 +5,7 @@
import { assert } from 'chai';
import { Win32InputMode, Win32ControlKeyState } from 'common/input/Win32InputMode';
import { IKeyboardEvent, KeyboardResultType } from 'common/Types';
import { IKeyboardEvent, KeyboardResultType } from 'common/KeyboardTypes';
type EventOpts = Partial<IKeyboardEvent>;
const ev = (opts: EventOpts): IKeyboardEvent => ({
@@ -14,7 +14,7 @@
* Rc: Repeat count (usually 1)
*/
import { IKeyboardEvent, IKeyboardResult, KeyboardResultType } from 'common/Types';
import { IKeyboardEvent, IKeyboardResult, KeyboardResultType } from 'common/KeyboardTypes';
import { C0 } from 'common/data/EscapeSequences';
/**
+1 -1
View File
@@ -6,7 +6,7 @@
import { IApcHandler, IHandlerCollection, ApcFallbackHandlerType, IApcParser, ISubParserStackState } from 'common/parser/Types';
import { ParserConstants } from 'common/parser/Constants';
import { utf32ToString } from 'common/input/TextDecoder';
import { IDisposable } from 'common/Types';
import type { IDisposable } from 'common/Lifecycle';
import { LimitedStringBuilder } from 'common/StringBuilder';
const EMPTY_HANDLERS: IApcHandler[] = [];
+1 -1
View File
@@ -3,7 +3,7 @@
* @license MIT
*/
import { IDisposable } from 'common/Types';
import type { IDisposable } from 'common/Lifecycle';
import { IDcsHandler, IParams, IHandlerCollection, IDcsParser, DcsFallbackHandlerType, ISubParserStackState } from 'common/parser/Types';
import { utf32ToString } from 'common/input/TextDecoder';
import { Params } from 'common/parser/Params';
@@ -10,7 +10,7 @@ import { StringToUtf32, stringFromCodePoint, utf32ToString } from 'common/input/
import { ParserState } from 'common/parser/Constants';
import { Params } from 'common/parser/Params';
import { OscHandler } from 'common/parser/OscParser';
import { IDisposable } from 'common/Types';
import type { IDisposable } from 'common/Lifecycle';
import { DcsHandler } from 'common/parser/DcsParser';
import { ApcHandler } from 'common/parser/ApcParser';
@@ -5,8 +5,7 @@
import { IParsingState, IDcsHandler, IEscapeSequenceParser, IParams, IOscHandler, IHandlerCollection, CsiHandlerType, OscFallbackHandlerType, IOscParser, EscHandlerType, IDcsParser, DcsFallbackHandlerType, IFunctionIdentifier, ExecuteFallbackHandlerType, CsiFallbackHandlerType, EscFallbackHandlerType, PrintHandlerType, PrintFallbackHandlerType, ExecuteHandlerType, IParserStackState, ParserStackType, ResumableHandlersType, IApcHandler, IApcParser, ApcFallbackHandlerType } from 'common/parser/Types';
import { ParserState, ParserAction } from 'common/parser/Constants';
import { Disposable, toDisposable } from 'common/Lifecycle';
import { IDisposable } from 'common/Types';
import { Disposable, toDisposable, type IDisposable } from 'common/Lifecycle';
import { Params } from 'common/parser/Params';
import { OscParser } from 'common/parser/OscParser';
import { DcsParser } from 'common/parser/DcsParser';
+1 -1
View File
@@ -6,7 +6,7 @@
import { IOscHandler, IHandlerCollection, OscFallbackHandlerType, IOscParser, ISubParserStackState } from 'common/parser/Types';
import { OscState, ParserConstants } from 'common/parser/Constants';
import { utf32ToString } from 'common/input/TextDecoder';
import { IDisposable } from 'common/Types';
import type { IDisposable } from 'common/Lifecycle';
import { LimitedStringBuilder } from 'common/StringBuilder';
const EMPTY_HANDLERS: IOscHandler[] = [];
+1 -1
View File
@@ -3,7 +3,7 @@
* @license MIT
*/
import { IDisposable } from 'common/Types';
import type { IDisposable } from 'common/Lifecycle';
import { ParserState } from 'common/parser/Constants';
+33
View File
@@ -0,0 +1,33 @@
{
"extends": "../../tsconfig-library-base",
"compilerOptions": {
"lib": [
"es2015",
"es2016.Array.Include",
"es2019.string",
"es2021.weakref"
],
"composite": true,
"rootDir": ".",
"outDir": "../../../out/common/primitives",
"types": [
"../../../node_modules/@types/mocha"
],
"paths": {
"@xterm/xterm": ["../../../typings/xterm.d.ts"],
"common/buffer/*": ["./buffer/*"],
"common/data/*": ["./data/*"],
"common/input/*": ["./input/*"],
"common/parser/*": ["./parser/*"],
"common/*": ["./*"],
"*": ["../../*"]
}
},
"include": [
"./**/*",
"../../../typings/xterm.d.ts"
],
"exclude": [
"**/*.test.ts"
]
}
+26
View File
@@ -0,0 +1,26 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"composite": false,
"noEmit": true,
"paths": {
"@xterm/xterm": ["../../../typings/xterm.d.ts"],
"common/buffer/*": ["./buffer/*"],
"common/data/*": ["./data/*"],
"common/input/*": ["./input/*"],
"common/parser/*": ["./parser/*"],
"common/services/*": ["../runtime/services/*"],
"common/TestUtils.test": ["../runtime/TestUtils.test"],
"common/Types": ["../runtime/Types"],
"common/*": ["./*", "../runtime/*"],
"*": ["../../*"]
}
},
"include": [
"./**/*.test.ts"
],
"references": [
{ "path": "./tsconfig.json" },
{ "path": "../runtime" }
]
}
@@ -3,13 +3,22 @@
* @license MIT
*/
import { IDeleteEvent, IInsertEvent } from 'common/CircularList';
import { UnderlineStyle } from 'common/buffer/Constants';
import { IBufferSet } from 'common/buffer/Types';
import { IParams } from 'common/parser/Types';
import { IMouseStateService, ICoreService, IOptionsService, IUnicodeService } from 'common/services/Services';
import { IFunctionIdentifier, ITerminalOptions as IPublicTerminalOptions } from '@xterm/xterm';
import type { Emitter, IEvent } from 'common/Event';
import { IFunctionIdentifier } from '@xterm/xterm';
import type { IEvent } from 'common/Event';
import type { IDisposable } from 'common/Lifecycle';
import type { ITerminalOptions } from 'common/TerminalOptions';
import type { IColorRGB } from 'common/ColorTypes';
export type { IDeleteEvent, IInsertEvent, ICircularList } from 'common/CircularList';
export type { IDisposable } from 'common/Lifecycle';
export type { ITerminalOptions } from 'common/TerminalOptions';
export * from 'common/KeyboardTypes';
export * from 'common/buffer/CellTypes';
export * from 'common/ColorTypes';
export { ICharset } from 'common/data/Charsets';
export interface ICoreTerminal {
mouseStateService: IMouseStateService;
@@ -25,100 +34,16 @@ export interface ICoreTerminal {
registerApcHandler(id: IFunctionIdentifier, callback: (data: string) => boolean | Promise<boolean>): IDisposable;
}
export interface IDisposable {
dispose(): void;
}
// TODO: The options that are not in the public API should be reviewed
export interface ITerminalOptions extends IPublicTerminalOptions {
[key: string]: any;
convertEol?: boolean;
termName?: string;
}
export type CursorStyle = 'block' | 'underline' | 'bar';
export type CursorInactiveStyle = 'outline' | 'block' | 'bar' | 'underline' | 'none';
export type XtermListener = (...args: any[]) => void;
/**
* A keyboard event interface which does not depend on the DOM, KeyboardEvent implicitly extends
* this event.
*/
export interface IKeyboardEvent {
altKey: boolean;
ctrlKey: boolean;
shiftKey: boolean;
metaKey: boolean;
/** @deprecated See KeyboardEvent.keyCode */
keyCode: number;
key: string;
type: string;
code: string;
}
export interface IScrollEvent {
position: number;
}
export interface ICircularList<T> {
length: number;
maxLength: number;
isFull: boolean;
onDeleteEmitter: Emitter<IDeleteEvent>;
onDelete: IEvent<IDeleteEvent>;
onInsertEmitter: Emitter<IInsertEvent>;
onInsert: IEvent<IInsertEvent>;
onTrimEmitter: Emitter<number>;
onTrim: IEvent<number>;
get(index: number): T | undefined;
set(index: number, value: T): void;
push(value: T): void;
recycle(): T;
pop(): T | undefined;
splice(start: number, deleteCount: number, ...items: T[]): void;
trimStart(count: number): void;
shiftElements(start: number, count: number, offset: number): void;
}
export const enum KeyboardResultType {
SEND_KEY,
SELECT_ALL,
PAGE_UP,
PAGE_DOWN
}
export interface IKeyboardResult {
type: KeyboardResultType;
cancel: boolean;
key: string | undefined;
}
export interface ICharset {
[key: string]: string | undefined;
}
export type CharData = [attr: number, char: string, width: number, code: number];
export interface IColor {
readonly css: string;
readonly rgba: number; // 32-bit int with rgba in each byte
}
export type IColorRGB = [red: number, green: number, blue: number];
export interface IExtendedAttrs {
ext: number;
underlineStyle: UnderlineStyle;
underlineColor: number;
underlineVariantOffset: number;
urlId: number;
clone(): IExtendedAttrs;
isEmpty(): boolean;
}
/**
* Tracks the current hyperlink. Since these are treated as extended attirbutes, these get passed on
* to the linkifier when anything is printed. Doing it this way ensures that even when the cursor
@@ -130,136 +55,6 @@ export interface IOscLinkData {
uri: string;
}
/**
* An object that represents all attributes of a cell.
*/
export interface IAttributeData {
/**
* "fg" is a 32-bit unsigned integer that stores the foreground color of the cell in the 24 least
* significant bits and additional flags in the remaining 8 bits.
*/
fg: number;
/**
* "bg" is a 32-bit unsigned integer that stores the background color of the cell in the 24 least
* significant bits and additional flags in the remaining 8 bits.
*/
bg: number;
/**
* "extended", aka "ext", stores extended attributes beyond those available in fg and bg. This
* data is optional on a cell and encodes less common data.
*/
extended: IExtendedAttrs;
clone(): IAttributeData;
// flags
isInverse(): number;
isBold(): number;
isUnderline(): number;
isBlink(): number;
isInvisible(): number;
isItalic(): number;
isDim(): number;
isStrikethrough(): number;
isProtected(): number;
isOverline(): number;
/**
* The color mode of the foreground color which determines how to decode {@link getFgColor},
* possible values include {@link Attributes.CM_DEFAULT}, {@link Attributes.CM_P16},
* {@link Attributes.CM_P256} and {@link Attributes.CM_RGB}.
*/
getFgColorMode(): number;
/**
* The color mode of the background color which determines how to decode {@link getBgColor},
* possible values include {@link Attributes.CM_DEFAULT}, {@link Attributes.CM_P16},
* {@link Attributes.CM_P256} and {@link Attributes.CM_RGB}.
*/
getBgColorMode(): number;
isFgRGB(): boolean;
isBgRGB(): boolean;
isFgPalette(): boolean;
isBgPalette(): boolean;
isFgDefault(): boolean;
isBgDefault(): boolean;
isAttributeDefault(): boolean;
/**
* Gets an integer representation of the foreground color, how to decode the color depends on the
* color mode {@link getFgColorMode}.
*/
getFgColor(): number;
/**
* Gets an integer representation of the background color, how to decode the color depends on the
* color mode {@link getBgColorMode}.
*/
getBgColor(): number;
// extended attrs
hasExtendedAttrs(): number;
updateExtended(): void;
getUnderlineColor(): number;
getUnderlineColorMode(): number;
isUnderlineColorRGB(): boolean;
isUnderlineColorPalette(): boolean;
isUnderlineColorDefault(): boolean;
getUnderlineStyle(): number;
getUnderlineVariantOffset(): number;
}
/** Cell data */
export interface ICellData extends IAttributeData {
content: number;
combinedData: string;
isCombined(): number;
getWidth(): number;
getChars(): string;
getCode(): number;
setFromCharData(value: CharData): void;
getAsCharData(): CharData;
}
/**
* Interface for a line in the terminal buffer.
*/
export interface IBufferLine {
length: number;
isWrapped: boolean;
get(index: number): CharData;
set(index: number, value: CharData): void;
loadCell(index: number, cell: ICellData): ICellData;
setCell(index: number, cell: ICellData): void;
setCellFromCodepoint(index: number, codePoint: number, width: number, attrs: IAttributeData): void;
addCodepointToCell(index: number, codePoint: number, width: number): void;
insertCells(pos: number, n: number, ch: ICellData): void;
deleteCells(pos: number, n: number, fill: ICellData): void;
replaceCells(start: number, end: number, fill: ICellData, respectProtect?: boolean): void;
resize(cols: number, fill: ICellData): boolean;
cleanupMemory(): number;
fill(fillCellData: ICellData, respectProtect?: boolean): void;
copyFrom(line: IBufferLine): void;
clone(): IBufferLine;
getTrimmedLength(): number;
getNoBgTrimmedLength(): number;
translateToString(trimRight?: boolean, startCol?: number, endCol?: number, outColumns?: number[]): string;
/* direct access to cell attrs */
getWidth(index: number): number;
hasWidth(index: number): number;
getFg(index: number): number;
getBg(index: number): number;
hasContent(index: number): number;
getCodePoint(index: number): number;
isCombined(index: number): number;
getString(index: number): string;
}
export interface IMarker extends IDisposable {
readonly id: number;
readonly isDisposed: boolean;
readonly line: number;
onDispose: IEvent<void>;
}
export interface IModes {
insertMode: boolean;
}
+7 -53
View File
@@ -4,34 +4,15 @@
*/
import type { IDecoration, IDecorationOptions, ILinkHandler, ILogger, IWindowsPty, IOverviewRulerOptions } from '@xterm/xterm';
import { CoreMouseEncoding, CoreMouseEventType, CursorInactiveStyle, CursorStyle, IAttributeData, ICharset, IColor, ICoreMouseEvent, ICoreMouseProtocol, IDecPrivateModes, IDisposable, IKittyKeyboardState, IModes, IOscLinkData, IWindowOptions } from 'common/Types';
import { IBuffer, IBufferSet } from 'common/buffer/Types';
import { CoreMouseEncoding, CoreMouseEventType, CursorInactiveStyle, CursorStyle, ICharset, IColor, ICoreMouseEvent, ICoreMouseProtocol, IDecPrivateModes, IDisposable, IKittyKeyboardState, IModes, IOscLinkData, IWindowOptions } from 'common/Types';
import type { IUnicodeVersionProvider, UnicodeCharProperties, UnicodeCharWidth } from 'common/input/UnicodeTypes';
import { createDecorator } from 'common/services/ServiceRegistry';
import type { Emitter, IEvent } from 'common/Event';
export const IBufferService = createDecorator<IBufferService>('BufferService');
export interface IBufferService {
serviceBrand: undefined;
readonly cols: number;
readonly rows: number;
readonly buffer: IBuffer;
readonly buffers: IBufferSet;
isUserScrolling: boolean;
onResize: IEvent<IBufferResizeEvent>;
onScroll: IEvent<number>;
scroll(eraseAttr: IAttributeData, isWrapped?: boolean): void;
scrollLines(disp: number, suppressScrollEvent?: boolean): void;
resize(cols: number, rows: number): void;
reset(): void;
}
export interface IBufferResizeEvent {
cols: number;
rows: number;
colsChanged: boolean;
rowsChanged: boolean;
}
import type { IBufferService as IBufferServiceModel, IBufferResizeEvent as IBufferResizeEventModel } from 'common/buffer/BufferService';
export type IBufferService = IBufferServiceModel;
export type IBufferResizeEvent = IBufferResizeEventModel;
export const IBufferService = createDecorator<IBufferServiceModel>('BufferService');
export const IMouseStateService = createDecorator<IMouseStateService>('MouseStateService');
export interface IMouseStateService {
@@ -324,28 +305,7 @@ export interface IOscLinkService {
getLinkData(linkId: number): IOscLinkData | undefined;
}
/*
* Width and Grapheme_Cluster_Break properties of a character as a bit mask.
*
* bit 0: shouldJoin - should combine with preceding character.
* bit 1..2: wcwidth - see UnicodeCharWidth.
* bit 3..31: class of character (currently only 4 bits are used).
* This is used to determined grapheme clustering - i.e. which codepoints
* are to be combined into a single compound character.
*
* Use the UnicodeService static function createPropertyValue to create a
* UnicodeCharProperties; use extractShouldJoin, extractWidth, and
* extractCharKind to extract the components.
*/
export type UnicodeCharProperties = number;
/**
* Width in columns of a character.
* In a CJK context, "half-width" characters (such as Latin) are width 1,
* while "full-width" characters (such as Kanji) are 2 columns wide.
* Combining characters (such as accents) are width 0.
*/
export type UnicodeCharWidth = 0 | 1 | 2;
export type { UnicodeCharProperties, UnicodeCharWidth, IUnicodeVersionProvider } from 'common/input/UnicodeTypes';
export const IUnicodeService = createDecorator<IUnicodeService>('UnicodeService');
export interface IUnicodeService {
@@ -372,12 +332,6 @@ export interface IUnicodeService {
charProperties(codepoint: number, preceding: UnicodeCharProperties): UnicodeCharProperties;
}
export interface IUnicodeVersionProvider {
readonly version: string;
wcwidth(ucs: number): UnicodeCharWidth;
charProperties(codepoint: number, preceding: UnicodeCharProperties): UnicodeCharProperties;
}
export const IDecorationService = createDecorator<IDecorationService>('DecorationService');
export interface IDecorationService extends IDisposable {
serviceBrand: undefined;
+5 -12
View File
@@ -4,6 +4,7 @@
*/
import { UnicodeV6 } from 'common/input/UnicodeV6';
import { createPropertyValue, extractCharKind, extractShouldJoin, extractWidth } from 'common/input/UnicodeProperties';
import { IUnicodeService, IUnicodeVersionProvider, UnicodeCharProperties, UnicodeCharWidth } from 'common/services/Services';
import { Emitter } from 'common/Event';
@@ -17,18 +18,10 @@ export class UnicodeService implements IUnicodeService {
private readonly _onChange = new Emitter<string>();
public readonly onChange = this._onChange.event;
public static extractShouldJoin(value: UnicodeCharProperties): boolean {
return (value & 1) !== 0;
}
public static extractWidth(value: UnicodeCharProperties): UnicodeCharWidth {
return ((value >> 1) & 0x3) as UnicodeCharWidth;
}
public static extractCharKind(value: UnicodeCharProperties): number {
return value >> 3;
}
public static createPropertyValue(state: number, width: number, shouldJoin: boolean = false): UnicodeCharProperties {
return ((state & 0xffffff) << 3) | ((width & 3) << 1) | (shouldJoin?1:0);
}
public static extractShouldJoin = extractShouldJoin;
public static extractWidth = extractWidth;
public static extractCharKind = extractCharKind;
public static createPropertyValue = createPropertyValue;
constructor() {
const defaultProvider = new UnicodeV6();
+39
View File
@@ -0,0 +1,39 @@
{
"extends": "../../tsconfig-library-base",
"compilerOptions": {
"lib": [
"es2015",
"es2016.Array.Include",
"es2019.string",
"es2021.weakref"
],
"composite": true,
"rootDir": ".",
"outDir": "../../../out/common/runtime",
"types": [
"../../../node_modules/@types/mocha"
],
"paths": {
"@xterm/xterm": ["../../../typings/xterm.d.ts"],
"common/buffer/*": ["../primitives/buffer/*"],
"common/data/*": ["../primitives/data/*"],
"common/input/*": ["../primitives/input/*"],
"common/parser/*": ["../primitives/parser/*"],
"common/services/*": ["./services/*"],
"common/public/*": ["./public/*"],
"common/Types": ["./Types"],
"common/*": ["../primitives/*", "./*"],
"*": ["../../*"]
}
},
"include": [
"./**/*",
"../../../typings/xterm.d.ts"
],
"exclude": [
"**/*.test.ts"
],
"references": [
{ "path": "../primitives" }
]
}
+4 -25
View File
@@ -1,29 +1,8 @@
{
"extends": "../tsconfig-library-base",
"compilerOptions": {
"lib": [
"es2015",
"es2016.Array.Include",
"es2019.string",
"es2021.weakref"
],
"outDir": "../../out",
"types": [
"../../node_modules/@types/mocha"
],
"paths": {
"common/*": [
"./primitives/*",
"./runtime/*",
"./*"
],
"*": [ "./../*" ]
}
},
"include": [
"./primitives/**/*",
"./runtime/**/*",
"./*.ts",
"../../typings/xterm.d.ts"
"files": [],
"references": [
{ "path": "./primitives" },
{ "path": "./runtime" }
]
}
@@ -3,14 +3,14 @@
* @license MIT
*/
import * as Strings from 'browser/LocalizableStrings';
import { ITerminal, IRenderDebouncer } from 'browser/Types';
import { TimeBasedDebouncer } from 'browser/TimeBasedDebouncer';
import * as Strings from 'target-browser/LocalizableStrings';
import { ITerminal, IRenderDebouncer } from 'target-browser/Types';
import { TimeBasedDebouncer } from 'target-browser/TimeBasedDebouncer';
import { Disposable, toDisposable } from 'common/Lifecycle';
import { ICoreBrowserService, IRenderService } from 'browser/services/Services';
import { ICoreBrowserService, IRenderService } from 'target-browser/services/Services';
import { IBuffer } from 'common/buffer/Types';
import { IInstantiationService } from 'common/services/Services';
import { addDisposableListener } from 'browser/Dom';
import { addDisposableListener } from 'target-browser/Dom';
const enum Constants {
MAX_ROWS_TO_READ = 20

Some files were not shown because too many files have changed in this diff Show More