diff --git a/packages/core/src/browser/widgets/index.ts b/packages/core/src/browser/widgets/index.ts index 52f70e2a216c4..95d023600ce39 100644 --- a/packages/core/src/browser/widgets/index.ts +++ b/packages/core/src/browser/widgets/index.ts @@ -15,7 +15,5 @@ ********************************************************************************/ export * from './widget'; -export * from './virtual-renderer'; -export * from './virtual-widget'; export * from './react-renderer'; export * from './react-widget'; diff --git a/packages/core/src/browser/widgets/virtual-renderer.ts b/packages/core/src/browser/widgets/virtual-renderer.ts deleted file mode 100644 index 18f6cf5bbd8ba..0000000000000 --- a/packages/core/src/browser/widgets/virtual-renderer.ts +++ /dev/null @@ -1,89 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2017 TypeFox and others. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * This Source Code may also be made available under the following Secondary - * Licenses when the conditions for such availability set forth in the Eclipse - * Public License v. 2.0 are satisfied: GNU General Public License, version 2 - * with the GNU Classpath Exception which is available at - * https://www.gnu.org/software/classpath/license.html. - * - * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 - ********************************************************************************/ - -import { h, VirtualNode, VirtualText, VirtualDOM } from '@phosphor/virtualdom'; - -// Phosphor elements can be null, so we need to disable our no-null rule -// tslint:disable:no-null-keyword - -/* - * @deprecated use ReactRenderer instead. VirtualRenderer will be removed with the next major release. - */ -export class VirtualRenderer { - readonly host: HTMLElement; - constructor( - host?: HTMLElement - ) { - this.host = host || document.createElement('div'); - } - - render(): void { - VirtualRenderer.render(this.doRender(), this.host); - } - - protected doRender(): h.Child { - return null; - } -} - -export namespace VirtualRenderer { - /* - * @deprecated use ReactDOM.render instead. VirtualRenderer will be removed with the next major release. - */ - export function render(child: h.Child, host: HTMLElement): void { - const content = toContent(child); - VirtualDOM.render(content, host); - } - export function flatten(children: h.Child[]): h.Child { - return children.reduce((prev, current) => merge(prev, current), null); - } - - export function merge(left: h.Child | undefined, right: h.Child | undefined): h.Child { - if (!right) { - return left || null; - } - if (!left) { - return right; - } - const result = left instanceof Array ? left : [left]; - if (right instanceof Array) { - result.push(...right); - } else { - result.push(right); - } - return result; - } - - export function toContent(children: h.Child): VirtualNode | VirtualNode[] | null { - if (!children) { - return null; - } - if (typeof children === 'string') { - return new VirtualText(children); - } - if (children instanceof Array) { - const nodes: VirtualNode[] = []; - for (const child of children) { - if (child) { - const node = typeof child === 'string' ? new VirtualText(child) : child; - nodes.push(node); - } - } - return nodes; - } - return children; - } -} diff --git a/packages/core/src/browser/widgets/virtual-widget.ts b/packages/core/src/browser/widgets/virtual-widget.ts deleted file mode 100644 index b315f81ff7d59..0000000000000 --- a/packages/core/src/browser/widgets/virtual-widget.ts +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2017 TypeFox and others. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * This Source Code may also be made available under the following Secondary - * Licenses when the conditions for such availability set forth in the Eclipse - * Public License v. 2.0 are satisfied: GNU General Public License, version 2 - * with the GNU Classpath Exception which is available at - * https://www.gnu.org/software/classpath/license.html. - * - * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 - ********************************************************************************/ - -import { injectable } from 'inversify'; -import { h } from '@phosphor/virtualdom'; -import { DisposableCollection } from '../../common'; -import { BaseWidget, Message } from './widget'; -import { VirtualRenderer } from './virtual-renderer'; - -/* - * @deprecated use ReactWidget instead. VirtualWidget will be removed with the next major release. - */ -@injectable() -export class VirtualWidget extends BaseWidget { - - protected readonly onRender = new DisposableCollection(); - protected childContainer?: HTMLElement; - protected scrollOptions = { - suppressScrollX: true - }; - - protected onUpdateRequest(msg: Message): void { - super.onUpdateRequest(msg); - const child = this.render(); - if (!this.childContainer) { - // if we are adding scrolling, we need to wrap the contents in its own div, to not conflict with the virtual dom algo. - if (this.scrollOptions) { - this.childContainer = this.createChildContainer(); - this.node.appendChild(this.childContainer); - } else { - this.childContainer = this.node; - } - } - VirtualRenderer.render(child, this.childContainer); - this.onRender.dispose(); - } - - protected render(): h.Child { - // tslint:disable-next-line:no-null-keyword - return null; - } - - protected createChildContainer(): HTMLElement { - return document.createElement('div'); - } - -}