Skip to content

Commit 9e2cfa5

Browse files
committed
Restructure Typescript project
Configure TS compile options Update dependencies Update Blazor to 0.5.1 Move JS initialization from global to extension specific namespace Fix name in PR CI build file
1 parent 4194f50 commit 9e2cfa5

18 files changed

+204
-96
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ bld/
2424
[Bb]in/
2525
[Oo]bj/
2626
[Ll]og/
27+
dist/
2728

2829
# Visual Studio 2015 cache/options directory
2930
.vs/

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2018 Blazor Extensions
3+
Copyright (c) 2018 Blazor Extensions Contributors
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

global.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"sdk": {
3+
"version": "2.1.302"
4+
}
5+
}

src/Blazor.Extensions.SignalR.JS/.gitignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

src/Blazor.Extensions.SignalR.JS/Blazor.Extensions.SignalR.JS.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netstandard2.0</TargetFramework>
54
<OutputType>Library</OutputType>
65
<IsPackable>false</IsPackable>
76
<BlazorLinkOnBuild>false</BlazorLinkOnBuild>
8-
<LangVersion>latest</LangVersion>
97
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
108
<TypeScriptToolsVersion>Latest</TypeScriptToolsVersion>
119
<DefaultItemExcludes>${DefaultItemExcludes};dist\**;node_modules\**</DefaultItemExcludes>

src/Blazor.Extensions.SignalR.JS/package-lock.json

Lines changed: 85 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Blazor.Extensions.SignalR.JS/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
},
1010
"devDependencies": {
1111
"@types/emscripten": "0.0.31",
12-
"webpack": "^4.16.0",
13-
"webpack-cli": "^3.0.8",
12+
"ts-loader": "^4.4.2",
1413
"typescript": "^2.9.2",
15-
"ts-loader": "^4.4.2"
14+
"webpack": "^4.16.3",
15+
"webpack-cli": "^3.1.0"
1616
},
1717
"dependencies": {
1818
"@aspnet/signalr": "^1.0.2",

src/Blazor.Extensions.SignalR.JS/src/HubConnectionManager.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ type DotNetReferenceType = {
1212
invokeMethodAsync<T>(methodIdentifier: string, ...args: any[]): Promise<T>
1313
}
1414

15-
const DotNet: DotNetType = window["DotNet"];
16-
1715
export class HubConnectionManager {
1816
private _hubConnections: Map<string, signalR.HubConnection> = new Map<string, signalR.HubConnection>();
1917
private _handles: Map<string, (payload: any) => Promise<void>> = new Map<string, (payload: any) => Promise<void>>();
2018

2119
public CreateConnection = (connectionId: string, httpConnectionOptions: DotNetReferenceType) => {
2220
if (!connectionId) throw new Error('Invalid connectionId.');
2321
if (!httpConnectionOptions) throw new Error('Invalid transport options.');
24-
let url = httpConnectionOptions.invokeMethod<string>('get_Url');
22+
23+
const url = httpConnectionOptions.invokeMethod<string>('get_Url');
24+
2525
if (!url) throw new Error('Invalid hub url.');
2626

2727
let options: any = {
@@ -75,17 +75,21 @@ export class HubConnectionManager {
7575

7676
public InvokeAsync = (connectionId: string, methodName: string, args: any[]): Promise<void> => {
7777
const connection = this.GetConnection(connectionId);
78+
7879
return connection.invoke(methodName, ...args);
7980
}
8081

8182
public InvokeWithResultAsync = (connectionId: string, methodName: string, args: any[]): Promise<any> => {
8283
const connection = this.GetConnection(connectionId);
84+
8385
return connection.invoke(methodName, ...args);
8486
}
8587

8688
private GetConnection = (connectionId: string) => {
8789
if (!connectionId) throw new Error('Invalid connectionId.');
90+
8891
const connection = this._hubConnections.get(connectionId);
92+
8993
if (!connection) throw new Error('Invalid connection.');
9094

9195
return connection;
@@ -94,21 +98,26 @@ export class HubConnectionManager {
9498
public On = (connectionId: string, callback: DotNetReferenceType) => {
9599
const connection = this.GetConnection(connectionId);
96100
const handle = (payload) => callback.invokeMethodAsync<void>('On', JSON.stringify(payload));
101+
97102
this._handles.set(callback.invokeMethod<string>('get_Id'), handle);
103+
98104
connection.on(callback.invokeMethod<string>('get_MethodName'), handle);
99105
}
100106

101107
public Off = (connectionId: string, methodName: string, handleId: string) => {
102108
const connection = this.GetConnection(connectionId);
103109
const handle = this._handles.get(handleId);
110+
104111
if (handle) {
105112
connection.off(methodName, handle);
113+
106114
this._handles.delete(handleId);
107115
}
108116
}
109117

110118
public OnClose = (connectionId: string, onErrorCallback: DotNetReferenceType) => {
111119
const connection = this.GetConnection(connectionId);
120+
112121
connection.onclose(async err => {
113122
onErrorCallback.invokeMethodAsync<void>('OnClose', JSON.stringify(err));
114123
});

src/Blazor.Extensions.SignalR.JS/src/Initialize.ts

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)