From f4a522516c4f1c766ffd1609b7b13bc11ca33583 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Sat, 24 Nov 2018 07:03:52 -0800 Subject: [PATCH] Remove shared/ folder We changed plans from moving web worker compatible code to shared/ to enforcing layers using core/, common/, ui/ and public/. This change moves files back from the shared/ dir to clean up the codebase. Part of #1507 --- src/AccessibilityManager.ts | 2 +- src/SelectionManager.ts | 2 +- src/Terminal.ts | 2 +- .../utils/Browser.ts => core/Platform.ts} | 0 src/renderer/ColorManager.ts | 3 +-- src/renderer/Types.ts | 18 +++++++++++---- src/renderer/atlas/CharAtlasCache.ts | 2 +- .../atlas/CharAtlasGenerator.ts | 4 ++-- src/renderer/atlas/CharAtlasUtils.ts | 3 +-- src/renderer/atlas/DynamicCharAtlas.ts | 9 ++++---- src/renderer/atlas/NoneCharAtlas.ts | 3 +-- src/renderer/atlas/StaticCharAtlas.ts | 5 ++--- src/renderer/atlas/Types.ts | 18 +++++++++++++++ src/shared/Types.ts | 18 --------------- src/shared/atlas/Types.ts | 22 ------------------- src/utils/TestUtils.test.ts | 2 +- 16 files changed, 48 insertions(+), 65 deletions(-) rename src/{shared/utils/Browser.ts => core/Platform.ts} (100%) rename src/{shared => renderer}/atlas/CharAtlasGenerator.ts (97%) delete mode 100644 src/shared/Types.ts delete mode 100644 src/shared/atlas/Types.ts diff --git a/src/AccessibilityManager.ts b/src/AccessibilityManager.ts index 1a2de1d7..fa0121ad 100644 --- a/src/AccessibilityManager.ts +++ b/src/AccessibilityManager.ts @@ -5,7 +5,7 @@ import * as Strings from './Strings'; import { ITerminal, IBuffer } from './Types'; -import { isMac } from './shared/utils/Browser'; +import { isMac } from './core/Platform'; import { RenderDebouncer } from './ui/RenderDebouncer'; import { addDisposableDomListener } from './ui/Lifecycle'; import { Disposable } from './common/Lifecycle'; diff --git a/src/SelectionManager.ts b/src/SelectionManager.ts index 49e21e2c..3dc50271 100644 --- a/src/SelectionManager.ts +++ b/src/SelectionManager.ts @@ -6,7 +6,7 @@ import { ITerminal, ISelectionManager, IBuffer, CharData, IBufferLine } from './Types'; import { XtermListener } from './common/Types'; import { MouseHelper } from './utils/MouseHelper'; -import * as Browser from './shared/utils/Browser'; +import * as Browser from './core/Platform'; import { CharMeasure } from './ui/CharMeasure'; import { EventEmitter } from './common/EventEmitter'; import { SelectionModel } from './SelectionModel'; diff --git a/src/Terminal.ts b/src/Terminal.ts index 8e89c9ca..e898f816 100644 --- a/src/Terminal.ts +++ b/src/Terminal.ts @@ -36,7 +36,7 @@ import { Renderer } from './renderer/Renderer'; import { Linkifier } from './Linkifier'; import { SelectionManager } from './SelectionManager'; import { CharMeasure } from './ui/CharMeasure'; -import * as Browser from './shared/utils/Browser'; +import * as Browser from './core/Platform'; import { addDisposableDomListener } from './ui/Lifecycle'; import * as Strings from './Strings'; import { MouseHelper } from './utils/MouseHelper'; diff --git a/src/shared/utils/Browser.ts b/src/core/Platform.ts similarity index 100% rename from src/shared/utils/Browser.ts rename to src/core/Platform.ts diff --git a/src/renderer/ColorManager.ts b/src/renderer/ColorManager.ts index d169f266..8a463670 100644 --- a/src/renderer/ColorManager.ts +++ b/src/renderer/ColorManager.ts @@ -3,8 +3,7 @@ * @license MIT */ -import { IColorManager } from './Types'; -import { IColor, IColorSet } from '../shared/Types'; +import { IColorManager, IColor, IColorSet } from './Types'; import { ITheme } from 'xterm'; const DEFAULT_FOREGROUND = fromHex('#ffffff'); diff --git a/src/renderer/Types.ts b/src/renderer/Types.ts index 824304ed..f2271f95 100644 --- a/src/renderer/Types.ts +++ b/src/renderer/Types.ts @@ -5,7 +5,6 @@ import { ITerminal, CharacterJoinerHandler } from '../Types'; import { IEventEmitter, ITheme, IDisposable } from 'xterm'; -import { IColorSet } from '../shared/Types'; /** * Flags used to render terminal text properly. @@ -48,9 +47,6 @@ export interface IColorManager { colors: IColorSet; } -// TODO: We should probably rewrite the imports for IColorSet, but there's a lot of them -export { IColorSet }; - export interface IRenderDimensions { scaledCharWidth: number; scaledCharHeight: number; @@ -134,3 +130,17 @@ export interface ICharacterJoinerRegistry { deregisterCharacterJoiner(joinerId: number): boolean; getJoinedCharacters(row: number): [number, number][]; } + +export interface IColor { + css: string; + rgba: number; // 32-bit int with rgba in each byte +} + +export interface IColorSet { + foreground: IColor; + background: IColor; + cursor: IColor; + cursorAccent: IColor; + selection: IColor; + ansi: IColor[]; +} diff --git a/src/renderer/atlas/CharAtlasCache.ts b/src/renderer/atlas/CharAtlasCache.ts index eee93d6c..3cb0e1cd 100644 --- a/src/renderer/atlas/CharAtlasCache.ts +++ b/src/renderer/atlas/CharAtlasCache.ts @@ -5,12 +5,12 @@ import { ITerminal } from '../../Types'; import { IColorSet } from '../Types'; -import { ICharAtlasConfig } from '../../shared/atlas/Types'; import { generateConfig, configEquals } from './CharAtlasUtils'; import BaseCharAtlas from './BaseCharAtlas'; import DynamicCharAtlas from './DynamicCharAtlas'; import NoneCharAtlas from './NoneCharAtlas'; import StaticCharAtlas from './StaticCharAtlas'; +import { ICharAtlasConfig } from './Types'; const charAtlasImplementations = { 'none': NoneCharAtlas, diff --git a/src/shared/atlas/CharAtlasGenerator.ts b/src/renderer/atlas/CharAtlasGenerator.ts similarity index 97% rename from src/shared/atlas/CharAtlasGenerator.ts rename to src/renderer/atlas/CharAtlasGenerator.ts index f78a6d41..03ab7b95 100644 --- a/src/shared/atlas/CharAtlasGenerator.ts +++ b/src/renderer/atlas/CharAtlasGenerator.ts @@ -4,9 +4,9 @@ */ import { FontWeight } from 'xterm'; -import { CHAR_ATLAS_CELL_SPACING, ICharAtlasConfig } from './Types'; +import { isFirefox, isSafari } from '../../core/Platform'; import { IColor } from '../Types'; -import { isFirefox, isSafari } from '../utils/Browser'; +import { ICharAtlasConfig, CHAR_ATLAS_CELL_SPACING } from './Types'; declare const Promise: any; diff --git a/src/renderer/atlas/CharAtlasUtils.ts b/src/renderer/atlas/CharAtlasUtils.ts index c504f77e..5b1add39 100644 --- a/src/renderer/atlas/CharAtlasUtils.ts +++ b/src/renderer/atlas/CharAtlasUtils.ts @@ -5,8 +5,7 @@ import { ITerminal } from '../../Types'; import { IColorSet } from '../Types'; -import { ICharAtlasConfig } from '../../shared/atlas/Types'; -import { DEFAULT_COLOR } from './Types'; +import { DEFAULT_COLOR, ICharAtlasConfig } from './Types'; export function generateConfig(scaledCharWidth: number, scaledCharHeight: number, terminal: ITerminal, colors: IColorSet): ICharAtlasConfig { // null out some fields that don't matter diff --git a/src/renderer/atlas/DynamicCharAtlas.ts b/src/renderer/atlas/DynamicCharAtlas.ts index b6b323f0..72010768 100644 --- a/src/renderer/atlas/DynamicCharAtlas.ts +++ b/src/renderer/atlas/DynamicCharAtlas.ts @@ -3,14 +3,13 @@ * @license MIT */ -import { DIM_OPACITY, IGlyphIdentifier, INVERTED_DEFAULT_COLOR } from './Types'; -import { ICharAtlasConfig } from '../../shared/atlas/Types'; -import { IColor } from '../../shared/Types'; +import { DIM_OPACITY, IGlyphIdentifier, INVERTED_DEFAULT_COLOR, ICharAtlasConfig } from './Types'; import BaseCharAtlas from './BaseCharAtlas'; import { DEFAULT_ANSI_COLORS } from '../ColorManager'; -import { clearColor } from '../../shared/atlas/CharAtlasGenerator'; +import { clearColor } from './CharAtlasGenerator'; import LRUMap from './LRUMap'; -import { isFirefox, isSafari } from '../../shared/utils/Browser'; +import { isFirefox, isSafari } from '../../core/Platform'; +import { IColor } from '../Types'; // In practice we're probably never going to exhaust a texture this large. For debugging purposes, // however, it can be useful to set this to a really tiny value, to verify that LRU eviction works. diff --git a/src/renderer/atlas/NoneCharAtlas.ts b/src/renderer/atlas/NoneCharAtlas.ts index 1cbc9eea..308e3075 100644 --- a/src/renderer/atlas/NoneCharAtlas.ts +++ b/src/renderer/atlas/NoneCharAtlas.ts @@ -5,8 +5,7 @@ * A dummy CharAtlas implementation that always fails to draw characters. */ -import { IGlyphIdentifier } from './Types'; -import { ICharAtlasConfig } from '../../shared/atlas/Types'; +import { IGlyphIdentifier, ICharAtlasConfig } from './Types'; import BaseCharAtlas from './BaseCharAtlas'; export default class NoneCharAtlas extends BaseCharAtlas { diff --git a/src/renderer/atlas/StaticCharAtlas.ts b/src/renderer/atlas/StaticCharAtlas.ts index 8dc8be74..b54c833e 100644 --- a/src/renderer/atlas/StaticCharAtlas.ts +++ b/src/renderer/atlas/StaticCharAtlas.ts @@ -3,9 +3,8 @@ * @license MIT */ -import { DIM_OPACITY, IGlyphIdentifier, DEFAULT_COLOR } from './Types'; -import { CHAR_ATLAS_CELL_SPACING, ICharAtlasConfig } from '../../shared/atlas/Types'; -import { generateStaticCharAtlasTexture } from '../../shared/atlas/CharAtlasGenerator'; +import { DIM_OPACITY, IGlyphIdentifier, DEFAULT_COLOR, ICharAtlasConfig, CHAR_ATLAS_CELL_SPACING } from './Types'; +import { generateStaticCharAtlasTexture } from './CharAtlasGenerator'; import BaseCharAtlas from './BaseCharAtlas'; import { is256Color } from './CharAtlasUtils'; diff --git a/src/renderer/atlas/Types.ts b/src/renderer/atlas/Types.ts index 76cfd07d..38923b2f 100644 --- a/src/renderer/atlas/Types.ts +++ b/src/renderer/atlas/Types.ts @@ -3,10 +3,15 @@ * @license MIT */ +import { FontWeight } from 'xterm'; +import { IColorSet } from '../Types'; + export const DEFAULT_COLOR = 256; export const INVERTED_DEFAULT_COLOR = 257; export const DIM_OPACITY = 0.5; +export const CHAR_ATLAS_CELL_SPACING = 1; + export interface IGlyphIdentifier { chars: string; code: number; @@ -16,3 +21,16 @@ export interface IGlyphIdentifier { dim: boolean; italic: boolean; } + +export interface ICharAtlasConfig { + type: 'none' | 'static' | 'dynamic'; + devicePixelRatio: number; + fontSize: number; + fontFamily: string; + fontWeight: FontWeight; + fontWeightBold: FontWeight; + scaledCharWidth: number; + scaledCharHeight: number; + allowTransparency: boolean; + colors: IColorSet; +} diff --git a/src/shared/Types.ts b/src/shared/Types.ts deleted file mode 100644 index 0cded8a8..00000000 --- a/src/shared/Types.ts +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Copyright (c) 2017 The xterm.js authors. All rights reserved. - * @license MIT - */ - -export interface IColor { - css: string; - rgba: number; // 32-bit int with rgba in each byte -} - -export interface IColorSet { - foreground: IColor; - background: IColor; - cursor: IColor; - cursorAccent: IColor; - selection: IColor; - ansi: IColor[]; -} diff --git a/src/shared/atlas/Types.ts b/src/shared/atlas/Types.ts deleted file mode 100644 index 25eaa716..00000000 --- a/src/shared/atlas/Types.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright (c) 2017 The xterm.js authors. All rights reserved. - * @license MIT - */ - -import { FontWeight } from 'xterm'; -import { IColorSet } from '../Types'; - -export const CHAR_ATLAS_CELL_SPACING = 1; - -export interface ICharAtlasConfig { - type: 'none' | 'static' | 'dynamic'; - devicePixelRatio: number; - fontSize: number; - fontFamily: string; - fontWeight: FontWeight; - fontWeightBold: FontWeight; - scaledCharWidth: number; - scaledCharHeight: number; - allowTransparency: boolean; - colors: IColorSet; -} diff --git a/src/utils/TestUtils.test.ts b/src/utils/TestUtils.test.ts index a5ef4b9f..10033a33 100644 --- a/src/utils/TestUtils.test.ts +++ b/src/utils/TestUtils.test.ts @@ -7,7 +7,7 @@ import { IColorSet, IRenderer, IRenderDimensions, IColorManager } from '../rende import { IInputHandlingTerminal, IViewport, ICompositionHelper, ITerminal, IBuffer, IBufferSet, IBrowser, ICharMeasure, ISelectionManager, ITerminalOptions, ILinkifier, IMouseHelper, ILinkMatcherOptions, CharacterJoinerHandler, IBufferLine, IBufferStringIterator } from '../Types'; import { ICircularList, XtermListener } from '../common/Types'; import { Buffer } from '../Buffer'; -import * as Browser from '../shared/utils/Browser'; +import * as Browser from '../core/Platform'; import { ITheme, IDisposable, IMarker } from 'xterm'; import { Terminal } from '../Terminal';