Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to current Blazor and dotnet versions #8

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 16 additions & 22 deletions src/Blazor.Extensions.XTerm.JS/Blazor.Extensions.XTerm.JS.csproj
Original file line number Diff line number Diff line change
@@ -1,41 +1,35 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<OutputType>Library</OutputType>
<IsPackable>false</IsPackable>
<BlazorLinkOnBuild>false</BlazorLinkOnBuild>
<LangVersion>latest</LangVersion>
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
<TypeScriptToolsVersion>Latest</TypeScriptToolsVersion>
<DefaultItemExcludes>${DefaultItemExcludes};dist\**;node_modules\**</DefaultItemExcludes>
<NoWarn>CS2008</NoWarn>

<!-- VS's FastUpToDateCheck doesn't consider .ts file changes, so it's necessary to disable it to get incremental builds to work correctly (albeit not as fast as if FastUpToDateCheck did work for them) -->
<DisableFastUpToDateCheck>true</DisableFastUpToDateCheck>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<SupportedPlatform Include="browser" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="5.0.4" />
</ItemGroup>

<PropertyGroup>

<!-- VS's FastUpToDateCheck doesn't consider .ts file changes, so it's necessary to disable it to get incremental builds to work correctly (albeit not as fast as if FastUpToDateCheck did work for them) -->
<DisableFastUpToDateCheck>true</DisableFastUpToDateCheck>
</PropertyGroup>

<ItemGroup>
<WebpackInputs Include="**\*.ts" Exclude="dist\**;node_modules\**" />
<WebpackInputs Include="**\*.ts" Exclude="wwwroot\**;node_modules\**" />
</ItemGroup>

<Target Name="EnsureNpmRestored" Condition="!Exists('node_modules')">
<Message Importance="high" Text="Restoring dependencies using 'npm'. This may take several minutes..." />
<Exec Command="npm install" />
</Target>

<Target Name="RunWebpack" AfterTargets="ResolveReferences" Inputs="@(WebpackInputs)" Outputs="dist\blazor.extensions.xterm.js" DependsOnTargets="EnsureNpmRestored">
<RemoveDir Directories="dist" />
<Target Name="RunWebpack" AfterTargets="ResolveReferences" Inputs="@(WebpackInputs)" Outputs="wwwroot\blazor.extensions.xterm.js" DependsOnTargets="EnsureNpmRestored">
<RemoveDir Directories="wwwroot" />
<Exec Command="npm run build" />
</Target>

<ItemGroup>
<EmbeddedResource Include="dist\**\*.js" LogicalName="blazor:js:%(RecursiveDir)%(Filename)%(Extension)" />
<EmbeddedResource Include="dist\**\*.css" LogicalName="blazor:css:%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>
</Project>

24 changes: 12 additions & 12 deletions src/Blazor.Extensions.XTerm.JS/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/Blazor.Extensions.XTerm.JS/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"xterm": "^3.14.5",
"xterm-addon-fit": "^0.1.0",
"xterm-addon-search": "^0.1.0",
"xterm-addon-web-links": "^0.1.0"
"xterm": "^4.11.0",
"xterm-addon-fit": "^0.5.0",
"xterm-addon-search": "^0.8.0",
"xterm-addon-web-links": "^0.4.0"
},
"devDependencies": {
"copy-webpack-plugin": "^5.0.4",
Expand Down
1 change: 1 addition & 0 deletions src/Blazor.Extensions.XTerm.JS/src/TerminalManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export class TerminalManager {
await DotNet.invokeMethodAsync("Blazor.Extensions.XTerm", "OnLineFeed", ref.id);
});
terminal.open(ref);
fitAddon.fit();
terminal.focus();

this._terminals.set(ref.id, terminal);
Expand Down
5 changes: 2 additions & 3 deletions src/Blazor.Extensions.XTerm.JS/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@ module.exports = {
},
plugins: [
new CopyPlugin([
{ from: path.join(__dirname, './node_modules/xterm/dist/xterm.css'), to: path.join(__dirname, "/dist/xterm.css") },
{ from: 'other', to: 'public' },
{ from: path.join(__dirname, './node_modules/xterm/css/xterm.css'), to: path.join(__dirname, "/wwwroot/xterm.css") }
])
],
output: {
path: path.join(__dirname, "/dist"),
path: path.join(__dirname, "/wwwroot"),
filename: "[name].js"
}
};

Large diffs are not rendered by default.

171 changes: 171 additions & 0 deletions src/Blazor.Extensions.XTerm.JS/wwwroot/xterm.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
/**
* Copyright (c) 2014 The xterm.js authors. All rights reserved.
* Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
* https://github.com/chjj/term.js
* @license MIT
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* Originally forked from (with the author's permission):
* Fabrice Bellard's javascript vt100 for jslinux:
* http://bellard.org/jslinux/
* Copyright (c) 2011 Fabrice Bellard
* The original design remains. The terminal itself
* has been extended to include xterm CSI codes, among
* other features.
*/

/**
* Default styles for xterm.js
*/

.xterm {
font-feature-settings: "liga" 0;
position: relative;
user-select: none;
-ms-user-select: none;
-webkit-user-select: none;
}

.xterm.focus,
.xterm:focus {
outline: none;
}

.xterm .xterm-helpers {
position: absolute;
top: 0;
/**
* The z-index of the helpers must be higher than the canvases in order for
* IMEs to appear on top.
*/
z-index: 5;
}

.xterm .xterm-helper-textarea {
padding: 0;
border: 0;
margin: 0;
/* Move textarea out of the screen to the far left, so that the cursor is not visible */
position: absolute;
opacity: 0;
left: -9999em;
top: 0;
width: 0;
height: 0;
z-index: -5;
/** Prevent wrapping so the IME appears against the textarea at the correct position */
white-space: nowrap;
overflow: hidden;
resize: none;
}

.xterm .composition-view {
/* TODO: Composition position got messed up somewhere */
background: #000;
color: #FFF;
display: none;
position: absolute;
white-space: nowrap;
z-index: 1;
}

.xterm .composition-view.active {
display: block;
}

.xterm .xterm-viewport {
/* On OS X this is required in order for the scroll bar to appear fully opaque */
background-color: #000;
overflow-y: scroll;
cursor: default;
position: absolute;
right: 0;
left: 0;
top: 0;
bottom: 0;
}

.xterm .xterm-screen {
position: relative;
}

.xterm .xterm-screen canvas {
position: absolute;
left: 0;
top: 0;
}

.xterm .xterm-scroll-area {
visibility: hidden;
}

.xterm-char-measure-element {
display: inline-block;
visibility: hidden;
position: absolute;
top: 0;
left: -9999em;
line-height: normal;
}

.xterm {
cursor: text;
}

.xterm.enable-mouse-events {
/* When mouse events are enabled (eg. tmux), revert to the standard pointer cursor */
cursor: default;
}

.xterm.xterm-cursor-pointer {
cursor: pointer;
}

.xterm.column-select.focus {
/* Column selection mode */
cursor: crosshair;
}

.xterm .xterm-accessibility,
.xterm .xterm-message {
position: absolute;
left: 0;
top: 0;
bottom: 0;
right: 0;
z-index: 10;
color: transparent;
}

.xterm .live-region {
position: absolute;
left: -9999px;
width: 1px;
height: 1px;
overflow: hidden;
}

.xterm-dim {
opacity: 0.5;
}

.xterm-underline {
text-decoration: underline;
}
12 changes: 4 additions & 8 deletions src/Blazor.Extensions.XTerm/Blazor.Extensions.XTerm.csproj
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<Title>Blazor Extensions XTerm</Title>
<Description>XTermJS wrapper for Blazor.</Description>
</PropertyGroup>

<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>7.3</LangVersion>
<RazorLangVersion>3.0</RazorLangVersion>
<TargetFramework>net5.0</TargetFramework>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);IncludeP2POutput</TargetsForTfmSpecificBuildOutput>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.Browser" Version="3.0.0-preview7.19365.7" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="5.0.5" />
</ItemGroup>

<ItemGroup>
Expand All @@ -27,4 +23,4 @@
<BuildOutputInPackage Include="$(OutputPath)Blazor.Extensions.XTerm.JS.dll" />
</ItemGroup>
</Target>
</Project>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeInspection/CSharpLanguageProject/LanguageLevel/@EntryValue">CSharp80</s:String></wpf:ResourceDictionary>
22 changes: 11 additions & 11 deletions src/Blazor.Extensions.XTerm/TerminalManager.cs
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.JSInterop;

namespace Blazor.Extensions.XTerm
{
public class TerminalManager
{
private static Dictionary<string, XTermComponent> _terminals = new Dictionary<string, XTermComponent>();
private static readonly Dictionary<string, XTerm> Terminals = new Dictionary<string, XTerm>();

public static void RegisterTerminal(string id, XTermComponent terminal)
public static void RegisterTerminal(string id, XTerm terminal)
{
_terminals[id] = terminal;
Terminals[id] = terminal;
}

public static void UnregisterTerminal(string id)
{
if (_terminals.ContainsKey(id))
if (Terminals.ContainsKey(id))
{
_terminals.Remove(id);
Terminals.Remove(id);
}
}

[JSInvokable]
public static async Task OnKey(string id, UIKeyboardEventArgs @event)
public static async Task OnKey(string id, KeyboardEventArgs @event)
{
if (_terminals.ContainsKey(id))
if (Terminals.ContainsKey(id))
{
await _terminals[id]?.OnKey.InvokeAsync(@event);
await Terminals[id]?.OnKey.InvokeAsync(@event);
}
}

[JSInvokable]
public static async Task OnLineFeed(string id)
{
if (_terminals.ContainsKey(id))
if (Terminals.ContainsKey(id))
{
await _terminals[id]?.OnLineFeed.InvokeAsync(string.Empty);
await Terminals[id]?.OnLineFeed.InvokeAsync(string.Empty);
}
}
}
Expand Down
Loading