Major TypeScript module refactoring (#1319)
* Build cjs, esm and umd versions * Split MsgPack into separate module * Split package.jsons up so they can stay clean * Move common dev dependencies to a root package.json
This commit is contained in:
parent
87288822a3
commit
0579f40a7d
|
|
@ -39,7 +39,7 @@ autobahnreports/
|
|||
site.min.css
|
||||
.idea/
|
||||
.vscode/
|
||||
signalr-client/
|
||||
dist/
|
||||
global.json
|
||||
BenchmarkDotNet.Artifacts/
|
||||
.rpt2_cache/
|
||||
24
SignalR.sln
24
SignalR.sln
|
|
@ -39,8 +39,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ChatSample", "samples\ChatS
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SocialWeather", "samples\SocialWeather\SocialWeather.csproj", "{8D789F94-CB74-45FD-ACE7-92AF6E55042E}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.SignalR.Test.Server", "client-ts\Microsoft.AspNetCore.SignalR.Test.Server\Microsoft.AspNetCore.SignalR.Test.Server.csproj", "{A0BF246B-FE7D-4E12-99BF-FFDC131B85D8}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.SignalR.Tests", "test\Microsoft.AspNetCore.SignalR.Tests\Microsoft.AspNetCore.SignalR.Tests.csproj", "{1CE2B3BE-056C-41E3-A5F5-6A1EF1D288BA}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClientSample", "samples\ClientSample\ClientSample.csproj", "{BA99C2A1-48F9-4FA5-B95A-9687A73B7CC9}"
|
||||
|
|
@ -55,12 +53,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Signal
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.SignalR.Client.FunctionalTests", "test\Microsoft.AspNetCore.SignalR.Client.FunctionalTests\Microsoft.AspNetCore.SignalR.Client.FunctionalTests.csproj", "{455B68D2-C5B6-4BF4-A685-964B07AFAAF8}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.SignalR.Client.TS", "client-ts\Microsoft.AspNetCore.SignalR.Client.TS\Microsoft.AspNetCore.SignalR.Client.TS.csproj", "{333526A4-633B-491A-AC45-CC62A0012D1C}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "client-ts", "client-ts", "{3A76C5A2-79ED-49BC-8BDC-6A3A766FFA1B}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
client-ts\package.json = client-ts\package.json
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.SignalR.Microbenchmarks", "benchmarks\Microsoft.AspNetCore.SignalR.Microbenchmarks\Microsoft.AspNetCore.SignalR.Microbenchmarks.csproj", "{96771B3F-4D18-41A7-A75B-FF38E76AAC89}"
|
||||
EndProject
|
||||
|
|
@ -94,6 +87,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNetCore.Signal
|
|||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNetCore.SignalR.Client.MsgPack", "src\Microsoft.AspNetCore.SignalR.Client.MsgPack\Microsoft.AspNetCore.SignalR.Client.MsgPack.csproj", "{4DBF918E-BD37-4309-B448-BA68C935944D}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FunctionalTests", "client-ts\FunctionalTests\FunctionalTests.csproj", "{D0C7B22E-B0B6-4D62-BF7D-79EE4AAF1981}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
|
@ -128,10 +123,6 @@ Global
|
|||
{8D789F94-CB74-45FD-ACE7-92AF6E55042E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{8D789F94-CB74-45FD-ACE7-92AF6E55042E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{8D789F94-CB74-45FD-ACE7-92AF6E55042E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{A0BF246B-FE7D-4E12-99BF-FFDC131B85D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A0BF246B-FE7D-4E12-99BF-FFDC131B85D8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A0BF246B-FE7D-4E12-99BF-FFDC131B85D8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A0BF246B-FE7D-4E12-99BF-FFDC131B85D8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1CE2B3BE-056C-41E3-A5F5-6A1EF1D288BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1CE2B3BE-056C-41E3-A5F5-6A1EF1D288BA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1CE2B3BE-056C-41E3-A5F5-6A1EF1D288BA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
|
|
@ -160,10 +151,6 @@ Global
|
|||
{455B68D2-C5B6-4BF4-A685-964B07AFAAF8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{455B68D2-C5B6-4BF4-A685-964B07AFAAF8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{455B68D2-C5B6-4BF4-A685-964B07AFAAF8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{333526A4-633B-491A-AC45-CC62A0012D1C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{333526A4-633B-491A-AC45-CC62A0012D1C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{333526A4-633B-491A-AC45-CC62A0012D1C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{333526A4-633B-491A-AC45-CC62A0012D1C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{96771B3F-4D18-41A7-A75B-FF38E76AAC89}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{96771B3F-4D18-41A7-A75B-FF38E76AAC89}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{96771B3F-4D18-41A7-A75B-FF38E76AAC89}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
|
|
@ -224,6 +211,10 @@ Global
|
|||
{4DBF918E-BD37-4309-B448-BA68C935944D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4DBF918E-BD37-4309-B448-BA68C935944D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4DBF918E-BD37-4309-B448-BA68C935944D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D0C7B22E-B0B6-4D62-BF7D-79EE4AAF1981}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D0C7B22E-B0B6-4D62-BF7D-79EE4AAF1981}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D0C7B22E-B0B6-4D62-BF7D-79EE4AAF1981}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D0C7B22E-B0B6-4D62-BF7D-79EE4AAF1981}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
@ -236,7 +227,6 @@ Global
|
|||
{59319B72-38BE-4041-8E5C-FF6938874CE8} = {DA69F624-5398-4884-87E4-B816698CDE65}
|
||||
{300979F6-A02E-407A-B8DF-F6200806C18D} = {C4BC9889-B49F-41B6-806B-F84941B2549B}
|
||||
{8D789F94-CB74-45FD-ACE7-92AF6E55042E} = {C4BC9889-B49F-41B6-806B-F84941B2549B}
|
||||
{A0BF246B-FE7D-4E12-99BF-FFDC131B85D8} = {3A76C5A2-79ED-49BC-8BDC-6A3A766FFA1B}
|
||||
{1CE2B3BE-056C-41E3-A5F5-6A1EF1D288BA} = {6A35B453-52EC-48AF-89CA-D4A69800F131}
|
||||
{BA99C2A1-48F9-4FA5-B95A-9687A73B7CC9} = {C4BC9889-B49F-41B6-806B-F84941B2549B}
|
||||
{EE790D50-C632-46B9-A430-06FA2F2FDCD7} = {C4BC9889-B49F-41B6-806B-F84941B2549B}
|
||||
|
|
@ -244,7 +234,6 @@ Global
|
|||
{E37324FF-6BAF-4243-BA80-7C024CF5F29D} = {DA69F624-5398-4884-87E4-B816698CDE65}
|
||||
{354335AB-CEE9-4434-A641-78058F6EFE56} = {DA69F624-5398-4884-87E4-B816698CDE65}
|
||||
{455B68D2-C5B6-4BF4-A685-964B07AFAAF8} = {6A35B453-52EC-48AF-89CA-D4A69800F131}
|
||||
{333526A4-633B-491A-AC45-CC62A0012D1C} = {3A76C5A2-79ED-49BC-8BDC-6A3A766FFA1B}
|
||||
{96771B3F-4D18-41A7-A75B-FF38E76AAC89} = {8A4582C8-DC59-4B61-BCE7-119FBAA99EFB}
|
||||
{75E342F6-5445-4E7E-9143-6D9AE62C2B1E} = {6A35B453-52EC-48AF-89CA-D4A69800F131}
|
||||
{F2E4FBD6-9AEA-4A82-BAC9-3FAACA677DF8} = {DA69F624-5398-4884-87E4-B816698CDE65}
|
||||
|
|
@ -260,6 +249,7 @@ Global
|
|||
{55DB4B6F-12E5-4A27-97F4-E97E135470FF} = {DA69F624-5398-4884-87E4-B816698CDE65}
|
||||
{FDDB4E1F-2FD2-49E8-B0FF-874B0931369A} = {DA69F624-5398-4884-87E4-B816698CDE65}
|
||||
{4DBF918E-BD37-4309-B448-BA68C935944D} = {DA69F624-5398-4884-87E4-B816698CDE65}
|
||||
{D0C7B22E-B0B6-4D62-BF7D-79EE4AAF1981} = {3A76C5A2-79ED-49BC-8BDC-6A3A766FFA1B}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {7945A4E4-ACDB-4F6E-95CA-6AC6E7C2CD59}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,58 @@
|
|||
<Project>
|
||||
<ItemGroup>
|
||||
<NPMPackage Include="$(RepositoryRoot)client-ts/signalr">
|
||||
<TarName>aspnet-signalr</TarName>
|
||||
<PackageId>@aspnet/signalr</PackageId>
|
||||
</NPMPackage>
|
||||
<NPMPackage Include="$(RepositoryRoot)client-ts/signalr-protocol-msgpack">
|
||||
<TarName>aspnet-signalr-protocol-msgpack</TarName>
|
||||
<PackageId>@aspnet/signalr-protocol-msgpack</PackageId>
|
||||
</NPMPackage>
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="RestoreNpm" AfterTargets="Restore" Condition="'$(PreflightRestore)' != 'True'">
|
||||
<Message Text="Restoring NPM modules" Importance="high" />
|
||||
<Exec Command="npm install --no-optional" WorkingDirectory="$(RepositoryRoot)client-ts" />
|
||||
<Exec Command="npm install --no-optional" WorkingDirectory="$(RepositoryRoot)client-ts/FunctionalTests" />
|
||||
<Exec Command="npm install --no-optional" WorkingDirectory="$(RepositoryRoot)client-ts/signalr" />
|
||||
<Exec Command="npm install --no-optional" WorkingDirectory="$(RepositoryRoot)client-ts/signalr-protocol-msgpack" />
|
||||
</Target>
|
||||
|
||||
<Target Name="RunTSClientNodeTests" AfterTargets="Test">
|
||||
<Message Text="Running TypeScript client Node tests" Importance="high" />
|
||||
<Exec Command="npm test" WorkingDirectory="$(RepositoryRoot)client-ts" IgnoreStandardErrorWarningFormat="true" />
|
||||
</Target>
|
||||
|
||||
<PropertyGroup>
|
||||
<PackageDependsOn>$(PackageDependsOn);PublishNPMPackages</PackageDependsOn>
|
||||
</PropertyGroup>
|
||||
<Target Name="PublishNPMPackages" AfterTargets="Package">
|
||||
<ItemGroup>
|
||||
<NPMPackage Update="%(NPMPackage)">
|
||||
<PackageJson>$([System.IO.Path]::Combine(%(NPMPackage.FullPath), 'package.json'))</PackageJson>
|
||||
<OutputTar>$([System.IO.Path]::Combine(%(NPMPackage.FullPath), '%(NPMPackage.TarName)-$(PackageVersion).tgz'))</OutputTar>
|
||||
<ArtifactPath>$([System.IO.Path]::Combine($(BuildDir), '%(NPMPackage.TarName)-$(PackageVersion).tgz'))</ArtifactPath>
|
||||
</NPMPackage>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ArtifactInfo Include="%(NPMPackage.ArtifactPath)">
|
||||
<ArtifactType>NpmPackage</ArtifactType>
|
||||
<PackageId>%(NPMPackage.PackageId)</PackageId>
|
||||
<Version>$(PackageVersion)</Version>
|
||||
</ArtifactInfo>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<FilesToExcludeFromSigning Include="%(NPMPackage.ArtifactPath)" />
|
||||
</ItemGroup>
|
||||
|
||||
<Copy SourceFiles="%(NPMPackage.PackageJson)" DestinationFiles="%(NPMPackage.PackageJson).bak" />
|
||||
<Exec Command="npm --no-git-tag-version --allow-same-version version $(PackageVersion)" WorkingDirectory="%(NPMPackage.FullPath)" />
|
||||
<Exec Command="npm run build" WorkingDirectory="%(NPMPackage.FullPath)" />
|
||||
<Exec Command="npm pack" WorkingDirectory="%(NPMPackage.FullPath)" />
|
||||
<Delete Files="%(NPMPackage.ArtifactPath)" Condition="Exists('%(NPMPackage.ArtifactPath)')" />
|
||||
<Move SourceFiles="%(NPMPackage.OutputTar)" DestinationFiles="%(NPMPackage.ArtifactPath)" />
|
||||
<Move SourceFiles="%(NPMPackage.PackageJson).bak" DestinationFiles="%(NPMPackage.PackageJson)" />
|
||||
</Target>
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -1,3 +0,0 @@
|
|||
*
|
||||
!dist/**/*
|
||||
!README.md
|
||||
|
|
@ -1,10 +1,11 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
|
||||
namespace Microsoft.AspNetCore.SignalR.Test.Server
|
||||
namespace FunctionalTests
|
||||
{
|
||||
[Authorize(JwtBearerDefaults.AuthenticationScheme)]
|
||||
public class HubWithAuthorization : Hub
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.AspNetCore.SignalR.Test.Server
|
||||
namespace FunctionalTests
|
||||
{
|
||||
public class ComplexObject
|
||||
{
|
||||
|
|
@ -12,4 +12,4 @@ namespace Microsoft.AspNetCore.SignalR.Test.Server
|
|||
public byte[] ByteArray { get; set; }
|
||||
public Guid GUID { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,10 +2,9 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.SignalR.Internal;
|
||||
using Microsoft.AspNetCore.Sockets;
|
||||
|
||||
namespace Microsoft.AspNetCore.SignalR.Test.Server
|
||||
namespace FunctionalTests
|
||||
{
|
||||
public class EchoEndPoint : EndPoint
|
||||
{
|
||||
|
|
@ -5,8 +5,8 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.SignalR.MsgPack\Microsoft.AspNetCore.SignalR.MsgPack.csproj" />
|
||||
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.SignalR\Microsoft.AspNetCore.SignalR.csproj" />
|
||||
<ProjectReference Include="..\Microsoft.AspNetCore.SignalR.Client.TS\Microsoft.AspNetCore.SignalR.Client.TS.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
@ -20,8 +20,20 @@
|
|||
<PackageReference Include="System.Reactive.Linq" Version="$(SystemReactiveLinqPackageVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- these targets relies on npm packages being restored when building the TS client -->
|
||||
<Target Name="CopyRequiredArtifacts" BeforeTargets="AfterBuild">
|
||||
<ItemGroup>
|
||||
<Folder Include="wwwroot\js\" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="ClientBuild" BeforeTargets="AfterBuild">
|
||||
<!-- This will result in a double build of the JavaScript modules. Not sure the best way to deal with that right now. -->
|
||||
<Exec Command="npm run build" WorkingDirectory="$(MSBuildThisFileDirectory)/.." />
|
||||
|
||||
<Exec Command="npm run build" />
|
||||
|
||||
<ItemGroup>
|
||||
<MsgPack5Files Include="$(MSBuildThisFileDirectory)../signalr-protocol-msgpack/node_modules/msgpack5/dist/*.js" />
|
||||
</ItemGroup>
|
||||
<Copy SourceFiles="@(MsgPack5Files)" DestinationFolder="$(MSBuildProjectDirectory)/wwwroot/lib/msgpack5" />
|
||||
<ItemGroup>
|
||||
<JasmineFiles Include="$(MSBuildThisFileDirectory)../node_modules/jasmine-core/lib/jasmine-core/*.js" />
|
||||
<JasmineFiles Include="$(MSBuildThisFileDirectory)../node_modules/jasmine-core/lib/jasmine-core/*.css" />
|
||||
|
|
@ -29,9 +41,10 @@
|
|||
<Copy SourceFiles="@(JasmineFiles)" DestinationFolder="$(MSBuildProjectDirectory)/wwwroot/lib/jasmine" />
|
||||
|
||||
<ItemGroup>
|
||||
<SignalRJSClientFiles Include="$(MSBuildThisFileDirectory)..\dist\browser\*" />
|
||||
<SignalRJSClientFiles Include="$(MSBuildThisFileDirectory)../signalr/dist/browser/*" />
|
||||
<SignalRJSClientFiles Include="$(MSBuildThisFileDirectory)../signalr-protocol-msgpack/dist/browser/*" />
|
||||
</ItemGroup>
|
||||
<Copy SourceFiles="@(SignalRJSClientFiles)" DestinationFolder="$(MSBuildThisFileDirectory)wwwroot\lib\signalr" />
|
||||
</Target>
|
||||
<Copy SourceFiles="@(SignalRJSClientFiles)" DestinationFolder="$(MSBuildThisFileDirectory)/wwwroot/lib/signalr" />
|
||||
</Target>
|
||||
|
||||
</Project>
|
||||
|
|
@ -5,7 +5,7 @@ using System.IO;
|
|||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Microsoft.AspNetCore.SignalR.Test.Server
|
||||
namespace FunctionalTests
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
|
|
@ -13,7 +13,7 @@ using Microsoft.Extensions.DependencyInjection;
|
|||
using Microsoft.IdentityModel.Tokens;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
|
||||
namespace Microsoft.AspNetCore.SignalR.Test.Server
|
||||
namespace FunctionalTests
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
|
|
@ -29,7 +29,8 @@ namespace Microsoft.AspNetCore.SignalR.Test.Server
|
|||
// we are running the same tests with JSON and MsgPack protocols and having
|
||||
// consistent casing makes it cleaner to verify results
|
||||
options.PayloadSerializerSettings.ContractResolver = new DefaultContractResolver();
|
||||
});
|
||||
})
|
||||
.AddMessagePackProtocol();
|
||||
|
||||
services.AddAuthorization(options =>
|
||||
{
|
||||
|
|
@ -2,11 +2,11 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Reactive.Disposables;
|
||||
using System.Reactive.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
|
||||
namespace Microsoft.AspNetCore.SignalR.Test.Server
|
||||
namespace FunctionalTests
|
||||
{
|
||||
public class CustomObject
|
||||
{
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
|
||||
namespace Microsoft.AspNetCore.SignalR.Test.Server
|
||||
namespace FunctionalTests
|
||||
{
|
||||
public class UncreatableHub: Hub
|
||||
{
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"name": "functionaltests",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"es6-promise": {
|
||||
"version": "4.2.2",
|
||||
"resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.2.tgz",
|
||||
"integrity": "sha512-LSas5vsuA6Q4nEdf9wokY5/AJYXry98i0IzXsv49rYsgDGDNDPbqAYR1Pe23iFxygfbGZNR/5VrHXBCh2BhvUQ==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"name": "functionaltests",
|
||||
"private": true,
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"es6-promise": "^4.2.2"
|
||||
},
|
||||
"scripts": {
|
||||
"clean": "node ../node_modules/rimraf/bin.js ./wwwroot/dist",
|
||||
"build": "npm run build:tsc && npm run build:rollup",
|
||||
"build:tsc": "node ../node_modules/typescript/bin/tsc --project ./tsconfig.json",
|
||||
"build:rollup": "node ../node_modules/rollup/bin/rollup -c"
|
||||
},
|
||||
"author": "",
|
||||
"license": "Apache-2.0"
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
import path from 'path';
|
||||
|
||||
import sourceMaps from 'rollup-plugin-sourcemaps'
|
||||
import commonjs from 'rollup-plugin-commonjs'
|
||||
import resolve from 'rollup-plugin-node-resolve'
|
||||
|
||||
export default {
|
||||
input: path.join(__dirname, "obj", "js", "index.js"),
|
||||
output: {
|
||||
file: path.join(__dirname, "wwwroot", "dist", "signalr-functional-tests.js"),
|
||||
format: "iife",
|
||||
sourcemap: true,
|
||||
banner: "/* @license\r\n" +
|
||||
" * Copyright (c) .NET Foundation. All rights reserved.\r\n" +
|
||||
" * Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.\r\n" +
|
||||
"*/",
|
||||
globals: {
|
||||
"@aspnet/signalr": "signalR",
|
||||
"@aspnet/signalr-protocol-msgpack": "signalR.protocols.msgpack",
|
||||
},
|
||||
},
|
||||
context: "window",
|
||||
external: [ "@aspnet/signalr", "@aspnet/signalr-protocol-msgpack" ],
|
||||
plugins: [
|
||||
commonjs(),
|
||||
resolve(),
|
||||
sourceMaps()
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
import { TransportType, IHubProtocol, JsonHubProtocol } from "@aspnet/signalr"
|
||||
import { MessagePackHubProtocol } from "@aspnet/signalr-protocol-msgpack"
|
||||
|
||||
export const ECHOENDPOINT_URL = "http://" + document.location.host + "/echo";
|
||||
|
||||
export function getTransportTypes(): TransportType[] {
|
||||
var transportTypes = [];
|
||||
if (typeof WebSocket !== "undefined") {
|
||||
transportTypes.push(TransportType.WebSockets);
|
||||
}
|
||||
if (typeof EventSource !== "undefined") {
|
||||
transportTypes.push(TransportType.ServerSentEvents);
|
||||
}
|
||||
transportTypes.push(TransportType.LongPolling);
|
||||
|
||||
return transportTypes;
|
||||
}
|
||||
|
||||
export function eachTransport(action: (transport: TransportType) => void) {
|
||||
getTransportTypes().forEach(function (t) {
|
||||
return action(t);
|
||||
});
|
||||
}
|
||||
|
||||
export function eachTransportAndProtocol(action: (transport: TransportType, protocol: IHubProtocol) => void) {
|
||||
var protocols : IHubProtocol[] = [new JsonHubProtocol()];
|
||||
// IE9 does not support XmlHttpRequest advanced features so disable for now
|
||||
// This can be enabled if we fix: https://github.com/aspnet/SignalR/issues/742
|
||||
if (typeof new XMLHttpRequest().responseType === "string") {
|
||||
// Because of TypeScript stuff, we can't get "ambient" or "global" declarations to work with the MessagePackHubProtocol module
|
||||
// This is only a limitation of the .d.ts file.
|
||||
// Everything works fine in the module
|
||||
protocols.push(new MessagePackHubProtocol());
|
||||
}
|
||||
getTransportTypes().forEach(function (t) {
|
||||
return protocols.forEach(function (p) {
|
||||
return action(t, p);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
@ -1,13 +1,14 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
"use strict";
|
||||
import { HttpConnection, LogLevel, TransportType } from "@aspnet/signalr"
|
||||
import { eachTransport, ECHOENDPOINT_URL } from "./Common"
|
||||
|
||||
describe('connection', function () {
|
||||
if (typeof WebSocket !== 'undefined') {
|
||||
it("can connect to the server without specifying transport explicitly", function (done) {
|
||||
var message = "Hello World!";
|
||||
var connection = new signalR.HttpConnection(ECHOENDPOINT_URL);
|
||||
var connection = new HttpConnection(ECHOENDPOINT_URL);
|
||||
|
||||
var received = "";
|
||||
connection.onreceive = function (data) {
|
||||
|
|
@ -32,13 +33,13 @@ describe('connection', function () {
|
|||
}
|
||||
|
||||
eachTransport(function (transportType) {
|
||||
it("over " + signalR.TransportType[transportType] + " can send and receive messages", function (done) {
|
||||
it("over " + TransportType[transportType] + " can send and receive messages", function (done) {
|
||||
var message = "Hello World!";
|
||||
// the url should be resolved relative to the document.location.host
|
||||
// and the leading '/' should be automatically added to the url
|
||||
var connection = new signalR.HttpConnection("echo", {
|
||||
var connection = new HttpConnection("echo", {
|
||||
transport: transportType,
|
||||
logging: signalR.LogLevel.Trace
|
||||
logger: LogLevel.Trace
|
||||
});
|
||||
|
||||
var received = "";
|
||||
|
|
@ -1,22 +1,23 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
'use strict';
|
||||
import { TransportType, HubConnection, LogLevel } from "@aspnet/signalr";
|
||||
|
||||
import { eachTransportAndProtocol, eachTransport } from "./Common";
|
||||
|
||||
var TESTHUBENDPOINT_URL = '/testhub';
|
||||
|
||||
describe('hubConnection', function () {
|
||||
eachTransportAndProtocol(function (transportType, protocol) {
|
||||
describe(protocol.name + ' over ' + signalR.TransportType[transportType] + ' transport', function () {
|
||||
describe(protocol.name + ' over ' + TransportType[transportType] + ' transport', function () {
|
||||
it('can invoke server method and receive result', function (done) {
|
||||
var message = '你好,世界!';
|
||||
|
||||
var options = {
|
||||
var hubConnection = new HubConnection(TESTHUBENDPOINT_URL, {
|
||||
transport: transportType,
|
||||
protocol: protocol,
|
||||
logging: signalR.LogLevel.Trace
|
||||
};
|
||||
var hubConnection = new signalR.HubConnection(TESTHUBENDPOINT_URL, options);
|
||||
logger: LogLevel.Trace
|
||||
});
|
||||
hubConnection.onclose(function (error) {
|
||||
expect(error).toBe(undefined);
|
||||
done();
|
||||
|
|
@ -39,12 +40,11 @@ describe('hubConnection', function () {
|
|||
it('can invoke server method non-blocking and not receive result', function (done) {
|
||||
var message = '你好,世界!';
|
||||
|
||||
var options = {
|
||||
var hubConnection = new HubConnection(TESTHUBENDPOINT_URL, {
|
||||
transport: transportType,
|
||||
protocol: protocol,
|
||||
logging: signalR.LogLevel.Trace
|
||||
};
|
||||
var hubConnection = new signalR.HubConnection(TESTHUBENDPOINT_URL, options);
|
||||
logger: LogLevel.Trace
|
||||
});
|
||||
hubConnection.onclose(function (error) {
|
||||
expect(error).toBe(undefined);
|
||||
done();
|
||||
|
|
@ -63,12 +63,11 @@ describe('hubConnection', function () {
|
|||
});
|
||||
|
||||
it('can invoke server method structural object and receive structural result', function (done) {
|
||||
var options = {
|
||||
var hubConnection = new HubConnection(TESTHUBENDPOINT_URL, {
|
||||
transport: transportType,
|
||||
protocol: protocol,
|
||||
logging: signalR.LogLevel.Trace
|
||||
};
|
||||
var hubConnection = new signalR.HubConnection(TESTHUBENDPOINT_URL, options);
|
||||
logger: LogLevel.Trace
|
||||
});
|
||||
|
||||
hubConnection.on('CustomObject', function (customObject) {
|
||||
expect(customObject.Name).toBe('test');
|
||||
|
|
@ -90,12 +89,11 @@ describe('hubConnection', function () {
|
|||
});
|
||||
|
||||
it('can stream server method and receive result', function (done) {
|
||||
var options = {
|
||||
var hubConnection = new HubConnection(TESTHUBENDPOINT_URL, {
|
||||
transport: transportType,
|
||||
protocol: protocol,
|
||||
logging: signalR.LogLevel.Trace
|
||||
};
|
||||
var hubConnection = new signalR.HubConnection(TESTHUBENDPOINT_URL, options);
|
||||
logger: LogLevel.Trace
|
||||
});
|
||||
|
||||
hubConnection.onclose(function (error) {
|
||||
expect(error).toBe(undefined);
|
||||
|
|
@ -125,12 +123,11 @@ describe('hubConnection', function () {
|
|||
|
||||
it('rethrows an exception from the server when invoking', function (done) {
|
||||
var errorMessage = 'An error occurred.';
|
||||
var options = {
|
||||
var hubConnection = new HubConnection(TESTHUBENDPOINT_URL, {
|
||||
transport: transportType,
|
||||
protocol: protocol,
|
||||
logging: signalR.LogLevel.Trace
|
||||
};
|
||||
var hubConnection = new signalR.HubConnection(TESTHUBENDPOINT_URL, options);
|
||||
logger: LogLevel.Trace
|
||||
});
|
||||
|
||||
hubConnection.start().then(function () {
|
||||
hubConnection.invoke('ThrowException', errorMessage).then(function () {
|
||||
|
|
@ -150,12 +147,11 @@ describe('hubConnection', function () {
|
|||
});
|
||||
|
||||
it('throws an exception when invoking streaming method with invoke', function (done) {
|
||||
var options = {
|
||||
var hubConnection = new HubConnection(TESTHUBENDPOINT_URL, {
|
||||
transport: transportType,
|
||||
protocol: protocol,
|
||||
logging: signalR.LogLevel.Trace
|
||||
};
|
||||
var hubConnection = new signalR.HubConnection(TESTHUBENDPOINT_URL, options);
|
||||
logger: LogLevel.Trace
|
||||
});
|
||||
|
||||
hubConnection.start().then(function () {
|
||||
hubConnection.invoke('EmptyStream').then(function () {
|
||||
|
|
@ -175,12 +171,11 @@ describe('hubConnection', function () {
|
|||
});
|
||||
|
||||
it('throws an exception when receiving a streaming result for method called with invoke', function (done) {
|
||||
var options = {
|
||||
var hubConnection = new HubConnection(TESTHUBENDPOINT_URL, {
|
||||
transport: transportType,
|
||||
protocol: protocol,
|
||||
logging: signalR.LogLevel.Trace
|
||||
};
|
||||
var hubConnection = new signalR.HubConnection(TESTHUBENDPOINT_URL, options);
|
||||
logger: LogLevel.Trace
|
||||
});
|
||||
|
||||
hubConnection.start().then(function () {
|
||||
hubConnection.invoke('Stream').then(function () {
|
||||
|
|
@ -201,12 +196,11 @@ describe('hubConnection', function () {
|
|||
|
||||
it('rethrows an exception from the server when streaming', function (done) {
|
||||
var errorMessage = 'An error occurred.';
|
||||
var options = {
|
||||
var hubConnection = new HubConnection(TESTHUBENDPOINT_URL, {
|
||||
transport: transportType,
|
||||
protocol: protocol,
|
||||
logging: signalR.LogLevel.Trace
|
||||
};
|
||||
var hubConnection = new signalR.HubConnection(TESTHUBENDPOINT_URL, options);
|
||||
logger: LogLevel.Trace
|
||||
});
|
||||
|
||||
hubConnection.start().then(function () {
|
||||
hubConnection.stream('StreamThrowException', errorMessage).subscribe({
|
||||
|
|
@ -231,12 +225,11 @@ describe('hubConnection', function () {
|
|||
});
|
||||
|
||||
it('throws an exception when invoking hub method with stream', function (done) {
|
||||
var options = {
|
||||
var hubConnection = new HubConnection(TESTHUBENDPOINT_URL, {
|
||||
transport: transportType,
|
||||
protocol: protocol,
|
||||
logging: signalR.LogLevel.Trace
|
||||
};
|
||||
var hubConnection = new signalR.HubConnection(TESTHUBENDPOINT_URL, options);
|
||||
logger: LogLevel.Trace
|
||||
});
|
||||
|
||||
hubConnection.start().then(function () {
|
||||
hubConnection.stream('Echo', '42').subscribe({
|
||||
|
|
@ -261,12 +254,11 @@ describe('hubConnection', function () {
|
|||
});
|
||||
|
||||
it('can receive server calls', function (done) {
|
||||
var options = {
|
||||
var hubConnection = new HubConnection(TESTHUBENDPOINT_URL, {
|
||||
transport: transportType,
|
||||
protocol: protocol,
|
||||
logging: signalR.LogLevel.Trace
|
||||
};
|
||||
var hubConnection = new signalR.HubConnection(TESTHUBENDPOINT_URL, options);
|
||||
logger: LogLevel.Trace
|
||||
});
|
||||
|
||||
var message = '你好 SignalR!';
|
||||
|
||||
|
|
@ -294,12 +286,11 @@ describe('hubConnection', function () {
|
|||
});
|
||||
|
||||
it('can receive server calls without rebinding handler when restarted', function (done) {
|
||||
var options = {
|
||||
var hubConnection = new HubConnection(TESTHUBENDPOINT_URL, {
|
||||
transport: transportType,
|
||||
protocol: protocol,
|
||||
logging: signalR.LogLevel.Trace
|
||||
};
|
||||
var hubConnection = new signalR.HubConnection(TESTHUBENDPOINT_URL, options);
|
||||
logger: LogLevel.Trace
|
||||
});
|
||||
|
||||
var message = '你好 SignalR!';
|
||||
|
||||
|
|
@ -358,28 +349,25 @@ describe('hubConnection', function () {
|
|||
ServerSentEvents: 'Error occurred'
|
||||
};
|
||||
|
||||
var options = {
|
||||
var hubConnection = new HubConnection('http://' + document.location.host + '/uncreatable', {
|
||||
transport: transportType,
|
||||
protocol: protocol,
|
||||
logging: signalR.LogLevel.Trace
|
||||
};
|
||||
var hubConnection = new signalR.HubConnection('http://' + document.location.host + '/uncreatable', options);
|
||||
logger: LogLevel.Trace
|
||||
});
|
||||
|
||||
hubConnection.onclose(function (error) {
|
||||
expect(error.message).toMatch(errorRegex[signalR.TransportType[transportType]]);
|
||||
expect(error.message).toMatch(errorRegex[TransportType[transportType]]);
|
||||
done();
|
||||
});
|
||||
hubConnection.start();
|
||||
});
|
||||
|
||||
it('can handle different types', function (done) {
|
||||
var options = {
|
||||
var hubConnection = new HubConnection(TESTHUBENDPOINT_URL, {
|
||||
transport: transportType,
|
||||
protocol: protocol,
|
||||
logging: signalR.LogLevel.Trace
|
||||
};
|
||||
|
||||
var hubConnection = new signalR.HubConnection(TESTHUBENDPOINT_URL, options);
|
||||
logger: LogLevel.Trace
|
||||
});
|
||||
hubConnection.onclose(function (error) {
|
||||
expect(error).toBe(undefined);
|
||||
done();
|
||||
|
|
@ -389,8 +377,8 @@ describe('hubConnection', function () {
|
|||
String: 'Hello, World!',
|
||||
IntArray: [0x01, 0x02, 0x03, 0xff],
|
||||
ByteArray: protocol.name === "json"
|
||||
? btoa([0xff, 0x03, 0x02, 0x01])
|
||||
: new Uint8Array([0xff, 0x03, 0x02, 0x01]),
|
||||
? "aGVsbG8="
|
||||
: new Uint8Array([0x68, 0x65, 0x6c, 0x6c, 0x6f]),
|
||||
GUID: protocol.name === "json"
|
||||
? "00010203-0405-0607-0706-050403020100"
|
||||
: new Uint8Array([0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00])
|
||||
|
|
@ -430,12 +418,11 @@ describe('hubConnection', function () {
|
|||
it('can be restarted', function (done) {
|
||||
var message = '你好,世界!';
|
||||
|
||||
var options = {
|
||||
var hubConnection = new HubConnection(TESTHUBENDPOINT_URL, {
|
||||
transport: transportType,
|
||||
protocol: protocol,
|
||||
logging: signalR.LogLevel.Trace
|
||||
};
|
||||
var hubConnection = new signalR.HubConnection(TESTHUBENDPOINT_URL, options);
|
||||
logger: LogLevel.Trace
|
||||
});
|
||||
|
||||
let closeCount = 0;
|
||||
hubConnection.onclose(function (error) {
|
||||
|
|
@ -478,51 +465,45 @@ describe('hubConnection', function () {
|
|||
});
|
||||
|
||||
eachTransport(function (transportType) {
|
||||
describe(' over ' + signalR.TransportType[transportType] + ' transport', function () {
|
||||
describe(' over ' + TransportType[transportType] + ' transport', function () {
|
||||
|
||||
it('can connect to hub with authorization', function (done) {
|
||||
it('can connect to hub with authorization', async function (done) {
|
||||
var message = '你好,世界!';
|
||||
|
||||
var hubConnection;
|
||||
getJwtToken('http://' + document.location.host + '/generateJwtToken', done,
|
||||
function(jwtToken) {
|
||||
var options = {
|
||||
getJwtToken('http://' + document.location.host + '/generateJwtToken')
|
||||
.then(jwtToken => {
|
||||
hubConnection = new HubConnection('/authorizedhub', {
|
||||
transport: transportType,
|
||||
logging: signalR.LogLevel.Trace,
|
||||
accessToken: function () {
|
||||
return jwtToken;
|
||||
}
|
||||
};
|
||||
|
||||
hubConnection = new signalR.HubConnection('/authorizedhub', options);
|
||||
logger: LogLevel.Trace,
|
||||
accessToken: () => jwtToken
|
||||
});
|
||||
hubConnection.onclose(function (error) {
|
||||
expect(error).toBe(undefined);
|
||||
done();
|
||||
});
|
||||
hubConnection.start()
|
||||
.then(function() {
|
||||
return hubConnection.invoke('Echo', message);
|
||||
})
|
||||
.then(function(response) {
|
||||
expect(response).toEqual(message);
|
||||
return hubConnection.stop();
|
||||
})
|
||||
.catch(function(e) {
|
||||
fail(e);
|
||||
done();
|
||||
});
|
||||
return hubConnection.start();
|
||||
})
|
||||
.then(() => {
|
||||
return hubConnection.invoke('Echo', message)
|
||||
})
|
||||
.then(response => {
|
||||
expect(response).toEqual(message);
|
||||
done();
|
||||
})
|
||||
.catch(err => {
|
||||
fail(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
if (transportType != signalR.TransportType.LongPolling) {
|
||||
if (transportType != TransportType.LongPolling) {
|
||||
it("terminates if no messages received within timeout interval", function (done) {
|
||||
var options = {
|
||||
var hubConnection = new HubConnection(TESTHUBENDPOINT_URL, {
|
||||
transport: transportType,
|
||||
logging: signalR.LogLevel.Trace,
|
||||
logger: LogLevel.Trace,
|
||||
timeoutInMilliseconds: 100
|
||||
};
|
||||
|
||||
var hubConnection = new signalR.HubConnection(TESTHUBENDPOINT_URL, options);
|
||||
});
|
||||
|
||||
var timeout = setTimeout(200, function () {
|
||||
fail("Server timeout did not fire within expected interval");
|
||||
|
|
@ -540,25 +521,25 @@ describe('hubConnection', function () {
|
|||
});
|
||||
});
|
||||
|
||||
function getJwtToken(url, done, callback) {
|
||||
let xhr = new XMLHttpRequest();
|
||||
function getJwtToken(url) : Promise<string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
let xhr = new XMLHttpRequest();
|
||||
|
||||
xhr.open('GET', url, true);
|
||||
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
|
||||
xhr.send();
|
||||
xhr.onload = function () {
|
||||
if (xhr.status >= 200 && xhr.status < 300) {
|
||||
callback(xhr.response || xhr.responseText);
|
||||
}
|
||||
else {
|
||||
fail();
|
||||
done();
|
||||
}
|
||||
};
|
||||
xhr.open('GET', url, true);
|
||||
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
|
||||
xhr.send();
|
||||
xhr.onload = () => {
|
||||
if (xhr.status >= 200 && xhr.status < 300) {
|
||||
resolve(xhr.response || xhr.responseText);
|
||||
}
|
||||
else {
|
||||
reject(new Error(xhr.statusText));
|
||||
}
|
||||
};
|
||||
|
||||
xhr.onerror = function() {
|
||||
fail();
|
||||
done();
|
||||
}
|
||||
xhr.onerror = () => {
|
||||
reject(new Error(xhr.statusText));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
'use strict';
|
||||
import { ECHOENDPOINT_URL } from "./Common";
|
||||
|
||||
if (typeof WebSocket !== 'undefined') {
|
||||
describe('WebSockets', function () {
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
import 'es6-promise/dist/es6-promise.auto.js';
|
||||
|
||||
import './ConnectionTests'
|
||||
import './HubConnectionTests'
|
||||
import './WebSocketTests'
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"noImplicitAny": false,
|
||||
"noEmitOnError": true,
|
||||
"removeComments": false,
|
||||
"sourceMap": true,
|
||||
"target": "es5",
|
||||
"module": "es2015",
|
||||
"outDir": "./obj/js",
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@aspnet/signalr": [ "../signalr/dist/esm/index" ],
|
||||
"@aspnet/signalr-protocol-msgpack": [ "../signalr-protocol-msgpack/dist/esm/index" ]
|
||||
},
|
||||
"lib": [ "es2015.promise", "es5", "dom", "es2015.collection" ]
|
||||
},
|
||||
"include": [
|
||||
"./**/*",
|
||||
"../typings/**/*",
|
||||
"../signalr/dist/esm/**/*.d.ts"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"wwwroot",
|
||||
"js"
|
||||
]
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
<!DOCTYPE html>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
|
|
@ -9,6 +9,7 @@
|
|||
<script type="text/javascript" src="lib/jasmine/jasmine.js"></script>
|
||||
<script type="text/javascript" src="lib/jasmine/jasmine-html.js"></script>
|
||||
<script type="text/javascript" src="lib/jasmine/boot.js"></script>
|
||||
<script type="text/javascript" src="lib/msgpack5/msgpack5.js"></script>
|
||||
<script type="text/javascript">
|
||||
function getParameterByName(name, url) {
|
||||
if (!url) {
|
||||
|
|
@ -23,22 +24,12 @@
|
|||
}
|
||||
|
||||
var minified = getParameterByName('release') === 'true' ? '.min' : '';
|
||||
if (typeof Promise === 'undefined') {
|
||||
document.write(
|
||||
'<script type="text/javascript" src="lib/signalr/signalr-clientES5' + minified + '.js"><\/script>' +
|
||||
'<script type="text/javascript" src="lib/signalr/signalr-msgpackprotocolES5' + minified + '.js"><\/script>');
|
||||
}
|
||||
else {
|
||||
document.write(
|
||||
'<script type="text/javascript" src="lib/signalr/signalr-client' + minified + '.js"><\/script>' +
|
||||
'<script type="text/javascript" src="lib/signalr/signalr-msgpackprotocol' + minified + '.js"><\/script>');
|
||||
}
|
||||
document.write(
|
||||
'<script type="text/javascript" src="lib/signalr/signalr' + minified + '.js"><\/script>' +
|
||||
'<script type="text/javascript" src="lib/signalr/signalr-protocol-msgpack' + minified + '.js"><\/script>');
|
||||
</script>
|
||||
|
||||
<script src="js/common.js"></script>
|
||||
<script src="js/webSocketTests.js"></script>
|
||||
<script src="js/connectionTests.js"></script>
|
||||
<script src="js/hubConnectionTests.js"></script>
|
||||
<script src="dist/signalr-functional-tests.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
{
|
||||
"spec_dir": "dist/test",
|
||||
"spec_files": [
|
||||
"./**/*[sS]pec.js"
|
||||
]
|
||||
}
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
import { HttpClient } from "./HttpClient"
|
||||
import { TransportType, ITransport } from "./Transports"
|
||||
import { ILogger, LogLevel } from "./ILogger";
|
||||
|
||||
export interface IHttpConnectionOptions {
|
||||
httpClient?: HttpClient;
|
||||
transport?: TransportType | ITransport;
|
||||
logger?: ILogger | LogLevel;
|
||||
accessToken?: () => string;
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
import { IHttpConnectionOptions } from "./IHttpConnectionOptions"
|
||||
import { IHubProtocol } from "./IHubProtocol"
|
||||
import { ILogger, LogLevel } from "./ILogger"
|
||||
|
||||
export interface IHubConnectionOptions extends IHttpConnectionOptions {
|
||||
protocol?: IHubProtocol;
|
||||
timeoutInMilliseconds?: number;
|
||||
}
|
||||
|
|
@ -1,62 +0,0 @@
|
|||
<Project>
|
||||
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
|
||||
|
||||
<PropertyGroup>
|
||||
<SignalRClientDistFolder>$(MSBuildThisFileDirectory)..\dist\</SignalRClientDistFolder>
|
||||
<OutputFileName>aspnet-signalr-client-$(PackageVersion).tgz</OutputFileName>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Inputs Include="*.ts;" />
|
||||
<Outputs Include="@(Inputs -> '$(SignalRClientDistFolder)src\%(FileName).d.ts')" />
|
||||
<Outputs Include="@(Inputs -> '$(SignalRClientDistFolder)src\%(FileName).js')" />
|
||||
<Outputs Include="$(SignalRClientDistFolder)browser\signalr-client.js" />
|
||||
<Outputs Include="$(SignalRClientDistFolder)browser\third-party-notices.txt" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="tsconfig.json" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- this target relies on npm packages being restored manually or when running full build -->
|
||||
<Target Name="BuildTSClient" Inputs="@(Inputs)" Outputs="@(Outputs)" BeforeTargets="Build">
|
||||
<Exec Command="npm run gulp -- --gulpfile "$(MSBuildThisFileDirectory)gulpfile.js" build-ts-client" />
|
||||
</Target>
|
||||
|
||||
<Target Name="CleanTSClient" AfterTargets="Clean">
|
||||
<RemoveDir Directories="$(SignalRClientDistFolder)" />
|
||||
</Target>
|
||||
|
||||
|
||||
<Target Name="Pack">
|
||||
<Message Text="Creating TypeScript client Node module" Importance="High" />
|
||||
|
||||
<PropertyGroup>
|
||||
<IsGitRepository Condition="EXISTS('$(MSBuildThisFileDirectory)..\..\.git\HEAD')">true</IsGitRepository>
|
||||
<IsGitRepository Condition="'$(IsGitRepository)'==''">false</IsGitRepository>
|
||||
</PropertyGroup>
|
||||
|
||||
<Exec Command="npm version $(PackageVersion) --allow-same-version" WorkingDirectory="$(MSBuildThisFileDirectory)..\" />
|
||||
<Exec Command="npm pack" WorkingDirectory="$(MSBuildThisFileDirectory)..\" />
|
||||
<Exec Command="git checkout HEAD -- "$(MSBuildThisFileDirectory)../package.json"" Condition="$(IsGitRepository)" />
|
||||
<Exec Command="git checkout HEAD -- "$(MSBuildThisFileDirectory)../package-lock.json"" Condition="$(IsGitRepository)" />
|
||||
<Move SourceFiles="$(MSBuildThisFileDirectory)..\$(OutputFileName)" DestinationFolder="$(PackageOutputPath)" />
|
||||
</Target>
|
||||
|
||||
<!-- Provides information to the bill of materials about expected outputs. -->
|
||||
<Target Name="GetNpmArtifactInfo" BeforeTargets="GetArtifactInfo" Returns="@(ArtifactInfo)">
|
||||
<ItemGroup>
|
||||
<ArtifactInfo Include="$(PackageOutputPath)$(OutputFileName)">
|
||||
<ArtifactType>NpmPackage</ArtifactType>
|
||||
<PackageId>@aspnet/signalr-client</PackageId>
|
||||
<Version>$(PackageVersion)</Version>
|
||||
</ArtifactInfo>
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
</Project>
|
||||
|
|
@ -1,77 +0,0 @@
|
|||
const gulp = require('gulp');
|
||||
const browserify = require('browserify');
|
||||
const ts = require('gulp-typescript');
|
||||
const source = require('vinyl-source-stream');
|
||||
const buffer = require('vinyl-buffer');
|
||||
const del = require('del');
|
||||
const rename = require('gulp-rename');
|
||||
const babel = require('gulp-babel');
|
||||
|
||||
const tsProject = ts.createProject('./tsconfig.json');
|
||||
const clientOutDir = tsProject.options.outDir;
|
||||
const browserOutDir = clientOutDir + '/../browser/';
|
||||
|
||||
gulp.task('clean', () => {
|
||||
return del([clientOutDir + '/..'], { force: true });
|
||||
});
|
||||
|
||||
gulp.task('compile-ts-client', () => {
|
||||
return tsProject.src()
|
||||
.pipe(tsProject())
|
||||
.pipe(gulp.dest(clientOutDir));
|
||||
});
|
||||
|
||||
function browserifyModule(sourceFileName, namespace, targetFileName) {
|
||||
|
||||
return browserify(clientOutDir + '/' + sourceFileName, {standalone: namespace})
|
||||
.bundle()
|
||||
.pipe(source(targetFileName))
|
||||
.pipe(gulp.dest(browserOutDir))
|
||||
.pipe(buffer())
|
||||
.pipe(rename({ extname: '.min.js' }))
|
||||
.pipe(babel({presets: ['minify']}))
|
||||
.pipe(gulp.dest(browserOutDir));
|
||||
}
|
||||
|
||||
function browserifyModuleES5(sourceFileName, namespace, targetFileName, hasAsync) {
|
||||
|
||||
let babelOptions = { presets: ['es2015'] };
|
||||
if (hasAsync) {
|
||||
babelOptions.plugins = ['transform-runtime'];
|
||||
}
|
||||
|
||||
return browserify(clientOutDir + '/' + sourceFileName, {standalone: namespace})
|
||||
.transform('babelify', { presets: ['es2015'], plugins: ['transform-runtime'] })
|
||||
.bundle()
|
||||
.pipe(source(targetFileName))
|
||||
.pipe(gulp.dest(browserOutDir))
|
||||
.pipe(buffer())
|
||||
.pipe(rename({ extname: '.min.js' }))
|
||||
.pipe(babel({presets: ['minify']}))
|
||||
.pipe(gulp.dest(browserOutDir));
|
||||
}
|
||||
|
||||
gulp.task('browserify-client', ['compile-ts-client'], () => {
|
||||
return browserifyModule('HubConnection.js', 'signalR', 'signalr-client.js');
|
||||
});
|
||||
|
||||
gulp.task('browserify-msgpackprotocol', ['compile-ts-client'], () => {
|
||||
return browserifyModule('MessagePackHubProtocol.js', 'signalRMsgPack', 'signalr-msgpackprotocol.js');
|
||||
});
|
||||
|
||||
gulp.task('browserify-clientES5', ['compile-ts-client'], () => {
|
||||
return browserifyModuleES5('HubConnection.js', 'signalR', 'signalr-clientES5.js', /*hasAsync*/ true);
|
||||
});
|
||||
|
||||
gulp.task('browserify-msgpackprotocolES5', ['compile-ts-client'], () => {
|
||||
return browserifyModuleES5('MessagePackHubProtocol.js', 'signalRMsgPack', 'signalr-msgpackprotocolES5.js', /*hasAsync*/ false);
|
||||
});
|
||||
|
||||
gulp.task('browserify', [ 'browserify-client', 'browserify-msgpackprotocol', 'browserify-clientES5', 'browserify-msgpackprotocolES5']);
|
||||
|
||||
gulp.task('build-ts-client', ['clean', 'compile-ts-client', 'browserify'], () => {
|
||||
return gulp.src('./third-party-notices.txt')
|
||||
.pipe(gulp.dest(browserOutDir));
|
||||
});
|
||||
|
||||
gulp.task('default', ['build-ts-client']);
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
{
|
||||
"compileOnSave": true,
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"sourceMap": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"removeComments": false,
|
||||
"noImplicitAny": true,
|
||||
"suppressImplicitAnyIndexErrors": true,
|
||||
"outDir": "../dist/src",
|
||||
"declaration": true
|
||||
},
|
||||
"include": [
|
||||
"./**/*",
|
||||
"../typings/*"
|
||||
]
|
||||
}
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
{
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:60249/",
|
||||
"sslPort": 0
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"Microsoft.AspNetCore.SignalR.Test.Server": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"applicationUrl": "http://localhost:5000/"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>SignalR Tests</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>SignalR Tests</h1>
|
||||
<ul>
|
||||
<li><a href="connectionTests.html">Connection Tests</a></li>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
"use strict";
|
||||
|
||||
var ECHOENDPOINT_URL = "http://" + document.location.host + "/echo";
|
||||
|
||||
function getTransportTypes() {
|
||||
var transportTypes = [];
|
||||
if (typeof WebSocket !== "undefined") {
|
||||
transportTypes.push(signalR.TransportType.WebSockets);
|
||||
}
|
||||
if (typeof EventSource !== "undefined") {
|
||||
transportTypes.push(signalR.TransportType.ServerSentEvents);
|
||||
}
|
||||
transportTypes.push(signalR.TransportType.LongPolling);
|
||||
|
||||
return transportTypes;
|
||||
}
|
||||
|
||||
function eachTransport(action) {
|
||||
getTransportTypes().forEach(function (t) {
|
||||
return action(t);
|
||||
});
|
||||
}
|
||||
|
||||
function eachTransportAndProtocol(action) {
|
||||
var protocols = [new signalR.JsonHubProtocol()];
|
||||
// IE9 does not support XmlHttpRequest advanced features so disable for now
|
||||
// This can be enabled if we fix: https://github.com/aspnet/SignalR/issues/742
|
||||
if (typeof new XMLHttpRequest().responseType === "string") {
|
||||
protocols.push(new signalRMsgPack.MessagePackHubProtocol());
|
||||
}
|
||||
getTransportTypes().forEach(function (t) {
|
||||
return protocols.forEach(function (p) {
|
||||
return action(t, p);
|
||||
});
|
||||
});
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,47 +1,24 @@
|
|||
{
|
||||
"name": "@aspnet/signalr-client",
|
||||
"version": "1.0.0-preview1-t000",
|
||||
"description": "ASP.NET Core SignalR",
|
||||
"main": "dist/src/index.js",
|
||||
"typings": "dist/src/index.d.ts",
|
||||
"directories": {
|
||||
"test": "test"
|
||||
},
|
||||
"name": "client-ts",
|
||||
"version": "0.0.0",
|
||||
"description": "Common dev-time dependencies for SignalR NPM packages. NOT FOR PUBLISHING",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"gulp": "gulp",
|
||||
"pretest": "tsc -p Microsoft.AspNetCore.SignalR.Client.TS.Tests",
|
||||
"test": "jasmine JASMINE_CONFIG_PATH=Microsoft.AspNetCore.SignalR.Client.TS.Tests/jasmine.json"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/aspnet/SignalR.git"
|
||||
"build": "cd ./signalr && npm run build && cd ../signalr-protocol-msgpack && npm run build",
|
||||
"test": "cd ./signalr && npm run test && cd ../signalr-protocol-msgpack && npm run test"
|
||||
},
|
||||
"author": "Microsoft",
|
||||
"license": "Apache-2.0",
|
||||
"bugs": {
|
||||
"url": "https://github.com/aspnet/SignalR/issues"
|
||||
},
|
||||
"homepage": "https://github.com/aspnet/SignalR#readme",
|
||||
"devDependencies": {
|
||||
"@types/msgpack5": "^3.4.0",
|
||||
"babel-minify": "^0.2.0",
|
||||
"babel-plugin-transform-runtime": "^6.23.0",
|
||||
"babel-preset-es2015": "^6.24.1",
|
||||
"babelify": "^7.3.0",
|
||||
"browserify": "^13.1.1",
|
||||
"buffer": "^5.0.7",
|
||||
"del": "^2.2.2",
|
||||
"gulp": "^3.9.1",
|
||||
"gulp-babel": "^7.0.0",
|
||||
"gulp-rename": "^1.2.2",
|
||||
"gulp-typescript": "^3.1.3",
|
||||
"@types/jasmine": "^2.8.3",
|
||||
"@types/node": "^8.5.2",
|
||||
"jasmine": "^2.8.0",
|
||||
"lodash": "^4.17.4",
|
||||
"typescript": "^2.0.10",
|
||||
"vinyl-buffer": "^1.0.0",
|
||||
"vinyl-source-stream": "^1.1.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"msgpack5": "^3.6.0"
|
||||
"rimraf": "^2.6.2",
|
||||
"rollup": "^0.53.4",
|
||||
"rollup-plugin-commonjs": "^8.2.6",
|
||||
"rollup-plugin-node-resolve": "^3.0.2",
|
||||
"rollup-plugin-sourcemaps": "^0.4.2",
|
||||
"typescript": "^2.6.2",
|
||||
"uglify-js": "^3.3.5"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,58 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
import path from 'path';
|
||||
|
||||
import resolve from 'rollup-plugin-node-resolve'
|
||||
import sourceMaps from 'rollup-plugin-sourcemaps'
|
||||
import commonjs from 'rollup-plugin-commonjs'
|
||||
|
||||
let polyfills = [ 'es6-promise', 'buffer', 'base64-js', 'ieee754' ];
|
||||
let allowed_externals = [ ];
|
||||
|
||||
export default function(rootDir, moduleGlobals) {
|
||||
let pkg = require(path.join(rootDir, "package.json"));
|
||||
return {
|
||||
input: path.join(rootDir, "dist", "cjs", "browser-index.js"),
|
||||
output: {
|
||||
file: pkg.browser,
|
||||
format: "umd",
|
||||
name: pkg.umd_name,
|
||||
sourcemap: true,
|
||||
banner: "/* @license\r\n" +
|
||||
" * Copyright (c) .NET Foundation. All rights reserved.\r\n" +
|
||||
" * Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.\r\n" +
|
||||
"*/",
|
||||
globals: moduleGlobals,
|
||||
},
|
||||
external: function (m) {
|
||||
let match = m.match(/node_modules/);
|
||||
if (match) {
|
||||
let moduleName = m.substring(match.index + "node_modules".length + 1);
|
||||
let slashIndex = moduleName.indexOf('/');
|
||||
if(slashIndex < 0) {
|
||||
slashIndex = moduleName.indexOf('\\');
|
||||
}
|
||||
moduleName = moduleName.substring(0, slashIndex);
|
||||
|
||||
if(polyfills.indexOf(moduleName) >= 0) {
|
||||
// This is a polyfill
|
||||
console.log(`Importing polyfill: ${m}`);
|
||||
return false;
|
||||
}
|
||||
else if(!allowed_externals.indexOf(moduleName)) {
|
||||
console.log(`WARNING: External module '${m}' in use.`);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
plugins: [
|
||||
commonjs(),
|
||||
resolve({
|
||||
preferBuiltins: false
|
||||
}),
|
||||
sourceMaps()
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
MsgPack support for SignalR for ASP.NET Core
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm install @aspnet/signalr-protocol-msgpack
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### Browser
|
||||
|
||||
To use the client in a browser, copy `*.js` files from the `dist/browser` folder to your script folder include on your page using the `<script>` tag.
|
||||
|
||||
### Example (Browser)
|
||||
|
||||
```JavaScript
|
||||
let connection = new signalR.HubConnection('/chat', {
|
||||
protocol: new signalR.protocol.msgpack.MessagePackHubProtocol()
|
||||
});
|
||||
|
||||
connection.on('send', data => {
|
||||
console.log(data);
|
||||
});
|
||||
|
||||
connection.start()
|
||||
.then(() => connection.invoke('send', 'Hello'));
|
||||
```
|
||||
|
||||
### Example (NodeJS)
|
||||
|
||||
```JavaScript
|
||||
const signalR = require("@aspnet/signalr");
|
||||
const signalRMsgPack = require("@aspnet/signalr-protocol-msgpack");
|
||||
|
||||
let connection = new signalR.HubConnection('/chat', {
|
||||
protocol: new signalRMsgPack.MessagePackHubProtocol()
|
||||
});
|
||||
|
||||
connection.on('send', data => {
|
||||
console.log(data);
|
||||
});
|
||||
|
||||
connection.start()
|
||||
.then(() => connection.invoke('send', 'Hello'));
|
||||
```
|
||||
|
|
@ -0,0 +1,125 @@
|
|||
{
|
||||
"name": "@aspnet/signalr-protocol-msgpack",
|
||||
"version": "1.0.0-preview1-t000",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"@types/bl": {
|
||||
"version": "0.8.31",
|
||||
"resolved": "https://registry.npmjs.org/@types/bl/-/bl-0.8.31.tgz",
|
||||
"integrity": "sha512-EiFdEaD7EQNFl4PDBvlbPlX4hV8rJhEKfFj58jkjqvj1gN6E1lShu24cXeWH/RQ5nf+/ei4WGp70xp2ubBaE5Q==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/node": "8.5.5"
|
||||
}
|
||||
},
|
||||
"@types/msgpack5": {
|
||||
"version": "3.4.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/msgpack5/-/msgpack5-3.4.1.tgz",
|
||||
"integrity": "sha512-E3wILUjTXONukpiI6tmqpLwf7eV3MVTdxpjz56FqNn7koMF/6sSPUh5TxMlwgoOhyeejxwVoNZUiDcdqChKkAw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/bl": "0.8.31"
|
||||
}
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "8.5.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-8.5.5.tgz",
|
||||
"integrity": "sha512-JRnfoh0Ll4ElmIXKxbUfcOodkGvcNHljct6mO1X9hE/mlrMzAx0hYCLAD7sgT53YAY1HdlpzUcV0CkmDqUqTuA==",
|
||||
"dev": true
|
||||
},
|
||||
"base64-js": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.2.1.tgz",
|
||||
"integrity": "sha512-dwVUVIXsBZXwTuwnXI9RK8sBmgq09NDHzyR9SAph9eqk76gKK2JSQmZARC2zRC81JC2QTtxD0ARU5qTS25gIGw==",
|
||||
"dev": true
|
||||
},
|
||||
"bl": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/bl/-/bl-1.2.1.tgz",
|
||||
"integrity": "sha1-ysMo977kVzDUBLaSID/LWQ4XLV4=",
|
||||
"requires": {
|
||||
"readable-stream": "2.3.3"
|
||||
}
|
||||
},
|
||||
"buffer": {
|
||||
"version": "5.0.8",
|
||||
"resolved": "https://registry.npmjs.org/buffer/-/buffer-5.0.8.tgz",
|
||||
"integrity": "sha512-xXvjQhVNz50v2nPeoOsNqWCLGfiv4ji/gXZM28jnVwdLJxH4mFyqgqCKfaK9zf1KUbG6zTkjLOy7ou+jSMarGA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"base64-js": "1.2.1",
|
||||
"ieee754": "1.1.8"
|
||||
}
|
||||
},
|
||||
"core-util-is": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
|
||||
"integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac="
|
||||
},
|
||||
"ieee754": {
|
||||
"version": "1.1.8",
|
||||
"resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.8.tgz",
|
||||
"integrity": "sha1-vjPUCsEO8ZJnAfbwii2G+/0a0+Q=",
|
||||
"dev": true
|
||||
},
|
||||
"inherits": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
|
||||
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
|
||||
},
|
||||
"isarray": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
|
||||
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
|
||||
},
|
||||
"msgpack5": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/msgpack5/-/msgpack5-4.0.1.tgz",
|
||||
"integrity": "sha512-Wx+c6YEE5UMrVrDQuFSIseprjgfeAvMYD35klSKm1xNCvtFI5KICfRmwKMc0Wmu7BknXUA3DUhFWugyCwTsRsg==",
|
||||
"requires": {
|
||||
"bl": "1.2.1",
|
||||
"inherits": "2.0.3",
|
||||
"readable-stream": "2.3.3",
|
||||
"safe-buffer": "5.1.1"
|
||||
}
|
||||
},
|
||||
"process-nextick-args": {
|
||||
"version": "1.0.7",
|
||||
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz",
|
||||
"integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M="
|
||||
},
|
||||
"readable-stream": {
|
||||
"version": "2.3.3",
|
||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz",
|
||||
"integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==",
|
||||
"requires": {
|
||||
"core-util-is": "1.0.2",
|
||||
"inherits": "2.0.3",
|
||||
"isarray": "1.0.0",
|
||||
"process-nextick-args": "1.0.7",
|
||||
"safe-buffer": "5.1.1",
|
||||
"string_decoder": "1.0.3",
|
||||
"util-deprecate": "1.0.2"
|
||||
}
|
||||
},
|
||||
"safe-buffer": {
|
||||
"version": "5.1.1",
|
||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz",
|
||||
"integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg=="
|
||||
},
|
||||
"string_decoder": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz",
|
||||
"integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==",
|
||||
"requires": {
|
||||
"safe-buffer": "5.1.1"
|
||||
}
|
||||
},
|
||||
"util-deprecate": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
|
||||
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
{
|
||||
"name": "@aspnet/signalr-protocol-msgpack",
|
||||
"version": "1.0.0-preview1-t000",
|
||||
"description": "MsgPack Protocol support for ASP.NET Core SignalR",
|
||||
"main": "./dist/cjs/index.js",
|
||||
"browser": "./dist/browser/signalr-protocol-msgpack.js",
|
||||
"module": "./dist/esm/index.js",
|
||||
"typings": "./dist/esm/index.d.ts",
|
||||
"umd_name": "signalR.protocols.msgpack",
|
||||
"directories": {
|
||||
"test": "spec"
|
||||
},
|
||||
"scripts": {
|
||||
"clean": "node ../node_modules/rimraf/bin.js ./dist",
|
||||
"build": "npm run clean && npm run build:esm && npm run build:cjs && npm run build:browser && npm run build:uglify",
|
||||
"build:esm": "node ../node_modules/typescript/bin/tsc --project ./tsconfig.json --module es2015 --outDir ./dist/esm --target ES2015 -d",
|
||||
"build:cjs": "node ../node_modules/typescript/bin/tsc --project ./tsconfig.json --module commonjs --outDir ./dist/cjs --target ES5",
|
||||
"build:browser": "node ../node_modules/rollup/bin/rollup -c",
|
||||
"build:uglify": "node ../node_modules/uglify-js/bin/uglifyjs --source-map \"url='signalr-protocol-msgpack.min.js.map',content='./dist/browser/signalr-protocol-msgpack.js.map'\" --comments -o ./dist/browser/signalr-protocol-msgpack.min.js ./dist/browser/signalr-protocol-msgpack.js",
|
||||
"pretest": "node ../node_modules/rimraf/bin.js ./spec/obj && tsc --project ./spec/tsconfig.json",
|
||||
"test": "node ../node_modules/jasmine/bin/jasmine.js ./spec/obj/signalr-protocol-msgpack/spec/**/*.spec.js"
|
||||
},
|
||||
"keywords": [
|
||||
"signalr",
|
||||
"aspnetcore"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/aspnet/SignalR.git"
|
||||
},
|
||||
"author": "Microsoft",
|
||||
"license": "Apache-2.0",
|
||||
"bugs": {
|
||||
"url": "https://github.com/aspnet/SignalR/issues"
|
||||
},
|
||||
"homepage": "https://github.com/aspnet/SignalR#readme",
|
||||
"files": [
|
||||
"dist/**/*",
|
||||
"src/**/*"
|
||||
],
|
||||
"peerDependencies": {
|
||||
"@aspnet/signalr": "^1.0.0-preview1"
|
||||
},
|
||||
"dependencies": {
|
||||
"msgpack5": "^4.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/msgpack5": "^3.4.1",
|
||||
"buffer": "^5.0.8"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
import baseConfig from "../rollup-base"
|
||||
|
||||
export default baseConfig(__dirname, {
|
||||
msgpack5: "msgpack5"
|
||||
});
|
||||
|
|
@ -1,31 +1,7 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
import { TextMessageFormat, BinaryMessageFormat } from "../Microsoft.AspNetCore.SignalR.Client.TS/Formatters"
|
||||
|
||||
describe("Text Message Formatter", () => {
|
||||
([
|
||||
["\u001e", [""]],
|
||||
["\u001e\u001e", ["", ""]],
|
||||
["Hello\u001e", ["Hello"]],
|
||||
["Hello,\u001eWorld!\u001e", ["Hello,", "World!"]],
|
||||
] as [[string, string[]]]).forEach(([payload, expected_messages]) => {
|
||||
it(`should parse '${payload}' correctly`, () => {
|
||||
let messages = TextMessageFormat.parse(payload);
|
||||
expect(messages).toEqual(expected_messages);
|
||||
})
|
||||
});
|
||||
|
||||
([
|
||||
["", new Error("Message is incomplete.")],
|
||||
["ABC", new Error("Message is incomplete.")],
|
||||
["ABC\u001eXYZ", new Error("Message is incomplete.")],
|
||||
] as [[string, Error]]).forEach(([payload, expected_error]) => {
|
||||
it(`should fail to parse '${payload}'`, () => {
|
||||
expect(() => TextMessageFormat.parse(payload)).toThrow(expected_error);
|
||||
});
|
||||
});
|
||||
});
|
||||
import { BinaryMessageFormat } from "../src/BinaryMessageFormat"
|
||||
|
||||
describe("Binary Message Formatter", () => {
|
||||
([
|
||||
|
|
@ -34,7 +10,7 @@ describe("Binary Message Formatter", () => {
|
|||
[[0x01, 0xff], <Uint8Array[]>[ new Uint8Array([0xff])]],
|
||||
[[0x01, 0xff,
|
||||
0x01, 0x7f], <Uint8Array[]>[ new Uint8Array([0xff]), new Uint8Array([0x7f])]],
|
||||
] as [[number[], Uint8Array[]]]).forEach(([payload, expected_messages]) => {
|
||||
] as [number[], Uint8Array[]][]).forEach(([payload, expected_messages]) => {
|
||||
it(`should parse '${payload}' correctly`, () => {
|
||||
let messages = BinaryMessageFormat.parse(new Uint8Array(payload).buffer);
|
||||
expect(messages).toEqual(expected_messages);
|
||||
|
|
@ -51,7 +27,7 @@ describe("Binary Message Formatter", () => {
|
|||
[[0x80, 0x80, 0x80, 0x80, 0x80], new Error("Messages bigger than 2GB are not supported.")],
|
||||
[[0x02, 0x00], new Error("Incomplete message.")],
|
||||
[[0xff, 0xff, 0xff, 0xff, 0x07], new Error("Incomplete message.")]
|
||||
] as [[number[], Error]]).forEach(([payload, expected_error]) => {
|
||||
] as [number[], Error][]).forEach(([payload, expected_error]) => {
|
||||
it(`should fail to parse '${payload}'`, () => {
|
||||
expect(() => BinaryMessageFormat.parse(new Uint8Array(payload).buffer)).toThrow(expected_error);
|
||||
})
|
||||
|
|
@ -60,7 +36,7 @@ describe("Binary Message Formatter", () => {
|
|||
([
|
||||
[[], [0x00]],
|
||||
[[0x20], [0x01, 0x20]],
|
||||
] as [[number[], number[]]]).forEach(([input, expected_payload]) => {
|
||||
] as [number[], number[]][]).forEach(([input, expected_payload]) => {
|
||||
it(`should write '${input}'`, () => {
|
||||
let actual = new Uint8Array(BinaryMessageFormat.write(new Uint8Array(input)));
|
||||
let expected = new Uint8Array(expected_payload);
|
||||
|
|
@ -80,5 +56,4 @@ describe("Binary Message Formatter", () => {
|
|||
})
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
import { MessagePackHubProtocol } from "../Microsoft.AspNetCore.SignalR.Client.TS/MessagePackHubProtocol"
|
||||
import { MessageType, InvocationMessage, CompletionMessage, ResultMessage } from "../Microsoft.AspNetCore.SignalR.Client.TS/IHubProtocol"
|
||||
import { MessagePackHubProtocol } from "../src/MessagePackHubProtocol"
|
||||
import { MessageType, InvocationMessage, CompletionMessage, ResultMessage } from "@aspnet/signalr"
|
||||
|
||||
describe("MessageHubProtocol", () => {
|
||||
it("can write/read non-blocking Invocation message", () => {
|
||||
|
|
@ -52,7 +52,7 @@ describe("MessageHubProtocol", () => {
|
|||
error: null,
|
||||
result: null
|
||||
} as CompletionMessage]
|
||||
] as [[number[], CompletionMessage]]).forEach(([payload, expected_message]) =>
|
||||
] as [number[], CompletionMessage][]).forEach(([payload, expected_message]) =>
|
||||
it("can read Completion message", () => {
|
||||
let messages = new MessagePackHubProtocol().parseMessages(new Uint8Array(payload).buffer);
|
||||
expect(messages).toEqual([expected_message]);
|
||||
|
|
@ -83,7 +83,7 @@ describe("MessageHubProtocol", () => {
|
|||
[[0x05, 0x94, 0x03, 0xa0, 0x02, 0x00], new Error("Invalid payload for Completion message.")],
|
||||
[[0x04, 0x93, 0x03, 0xa0, 0x01], new Error("Invalid payload for Completion message.")],
|
||||
[[0x04, 0x93, 0x03, 0xa0, 0x03], new Error("Invalid payload for Completion message.")]
|
||||
] as [[number[], Error]]).forEach(([payload, expected_error]) =>
|
||||
] as [number[], Error][]).forEach(([payload, expected_error]) =>
|
||||
it("throws for invalid messages", () => {
|
||||
expect(() => new MessagePackHubProtocol().parseMessages(new Uint8Array(payload).buffer))
|
||||
.toThrow(expected_error);
|
||||
|
|
@ -122,4 +122,4 @@ describe("MessageHubProtocol", () => {
|
|||
}
|
||||
])
|
||||
})
|
||||
});
|
||||
});
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"compileOnSave": false,
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es5",
|
||||
"moduleResolution": "node",
|
||||
"outDir": "./obj",
|
||||
"lib": [ "es2015", "dom" ],
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@aspnet/signalr": [ "../../signalr/src/index" ]
|
||||
}
|
||||
},
|
||||
"include": [
|
||||
"./**/*",
|
||||
"../../typings/**/*"
|
||||
]
|
||||
}
|
||||
|
|
@ -1,31 +1,12 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
export namespace TextMessageFormat {
|
||||
|
||||
const RecordSeparator = String.fromCharCode(0x1e);
|
||||
|
||||
export function write(output: string): string {
|
||||
return `${output}${RecordSeparator}`;
|
||||
}
|
||||
|
||||
export function parse(input: string): string[] {
|
||||
if (input[input.length - 1] != RecordSeparator) {
|
||||
throw new Error("Message is incomplete.");
|
||||
}
|
||||
|
||||
let messages = input.split(RecordSeparator);
|
||||
messages.pop();
|
||||
return messages;
|
||||
}
|
||||
}
|
||||
|
||||
export namespace BinaryMessageFormat {
|
||||
export class BinaryMessageFormat {
|
||||
|
||||
// The length prefix of binary messages is encoded as VarInt. Read the comment in
|
||||
// the BinaryMessageParser.TryParseMessage for details.
|
||||
|
||||
export function write(output: Uint8Array): ArrayBuffer {
|
||||
static write(output: Uint8Array): ArrayBuffer {
|
||||
// msgpack5 uses returns Buffer instead of Uint8Array on IE10 and some other browser
|
||||
// in which case .byteLength does will be undefined
|
||||
let size = output.byteLength || output.length;
|
||||
|
|
@ -51,7 +32,7 @@ export namespace BinaryMessageFormat {
|
|||
return buffer.buffer;
|
||||
}
|
||||
|
||||
export function parse(input: ArrayBuffer): Uint8Array[] {
|
||||
static parse(input: ArrayBuffer): Uint8Array[] {
|
||||
let result: Uint8Array[] = [];
|
||||
let uint8Array = new Uint8Array(input);
|
||||
const maxLengthPrefixSize = 5;
|
||||
|
|
@ -1,9 +1,10 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
import { IHubProtocol, ProtocolType, MessageType, HubMessage, InvocationMessage, ResultMessage, CompletionMessage, StreamInvocationMessage } from "./IHubProtocol";
|
||||
import { BinaryMessageFormat } from "./Formatters"
|
||||
import * as msgpack5 from "msgpack5"
|
||||
import { IHubProtocol, ProtocolType, MessageType, HubMessage, InvocationMessage, ResultMessage, CompletionMessage, StreamInvocationMessage } from "@aspnet/signalr";
|
||||
import { BinaryMessageFormat } from "./BinaryMessageFormat"
|
||||
import { Buffer } from 'buffer';
|
||||
import * as msgpack5 from "msgpack5";
|
||||
|
||||
export class MessagePackHubProtocol implements IHubProtocol {
|
||||
|
||||
|
|
@ -151,4 +152,4 @@ export class MessagePackHubProtocol implements IHubProtocol {
|
|||
|
||||
return BinaryMessageFormat.write(payload.slice());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
// This is where we add any polyfills we'll need for the browser. It is the entry module for browser-specific builds.
|
||||
|
||||
export * from './index'
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
export { MessagePackHubProtocol } from "./MessagePackHubProtocol";
|
||||
|
|
@ -8,6 +8,85 @@ bring it to our attention. Post an issue or email us:
|
|||
|
||||
The attached notices are provided for information only.
|
||||
|
||||
License notice for buffer
|
||||
------------------------------------------------------------------------------
|
||||
"The MIT License (MIT)
|
||||
|
||||
Copyright (c) Feross Aboukhadijeh, and other contributors.
|
||||
|
||||
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."
|
||||
|
||||
License notice for base64-js
|
||||
------------------------------------------------------------------------------
|
||||
"The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014
|
||||
|
||||
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."
|
||||
|
||||
License notice for ieee754
|
||||
------------------------------------------------------------------------------
|
||||
"Copyright (c) 2008, Fair Oaks Labs, Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of Fair Oaks Labs, Inc. nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE."
|
||||
|
||||
|
||||
License notice for msgpack5
|
||||
------------------------------------------------------------------------------
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"extends": "../tsconfig-base.json",
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@aspnet/signalr": [
|
||||
"../signalr"
|
||||
]
|
||||
}
|
||||
},
|
||||
"include": [
|
||||
"./src/**/*",
|
||||
"../typings/**/*"
|
||||
]
|
||||
}
|
||||
|
|
@ -20,7 +20,7 @@ The following polyfills are required to use the client in Node.js applications:
|
|||
- `EventSource` - to use the ServerSentEvents transport
|
||||
- `btoa/atob` - to use binary protocols (e.g. MessagePack) over text transports (ServerSentEvents)
|
||||
|
||||
### Example
|
||||
### Example (Browser)
|
||||
|
||||
```JavaScript
|
||||
let connection = new signalR.HubConnection('/chat');
|
||||
|
|
@ -29,6 +29,21 @@ connection.on('send', data => {
|
|||
console.log(data);
|
||||
});
|
||||
|
||||
connection.start()
|
||||
.then(() => connection.invoke('send', 'Hello'));
|
||||
```
|
||||
|
||||
### Example (NodeJS)
|
||||
|
||||
```JavaScript
|
||||
const signalR = require("@aspnet/signalR");
|
||||
|
||||
let connection = new signalR.HubConnection('/chat');
|
||||
|
||||
connection.on('send', data => {
|
||||
console.log(data);
|
||||
});
|
||||
|
||||
connection.start()
|
||||
.then(() => connection.invoke('send', 'Hello'));
|
||||
```
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
// Edit the index.d.ts file to add the UMD export
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const target = path.resolve(__dirname, "..", "dist", "esm", "index.d.ts");
|
||||
|
||||
let content = fs.readFileSync(target);
|
||||
fs.writeFileSync(target, content + "\r\nexport as namespace signalR;");
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"name": "@aspnet/signalr",
|
||||
"version": "1.0.0-preview1-t000",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"es6-promise": {
|
||||
"version": "4.2.2",
|
||||
"resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.2.tgz",
|
||||
"integrity": "sha512-LSas5vsuA6Q4nEdf9wokY5/AJYXry98i0IzXsv49rYsgDGDNDPbqAYR1Pe23iFxygfbGZNR/5VrHXBCh2BhvUQ==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
{
|
||||
"name": "@aspnet/signalr",
|
||||
"version": "1.0.0-preview1-t000",
|
||||
"description": "ASP.NET Core SignalR Client",
|
||||
"main": "./dist/cjs/index.js",
|
||||
"browser": "./dist/browser/signalr.js",
|
||||
"module": "./dist/esm/index.js",
|
||||
"typings": "./dist/esm/index.d.ts",
|
||||
"umd_name": "signalR",
|
||||
"directories": {
|
||||
"test": "spec"
|
||||
},
|
||||
"scripts": {
|
||||
"clean": "node ../node_modules/rimraf/bin.js ./dist ./.rpt2_cache",
|
||||
"build": "npm run clean && npm run build:esm && npm run build:cjs && npm run build:browser && npm run build:uglify",
|
||||
"build:esm": "node ../node_modules/typescript/bin/tsc --project ./tsconfig.json --module es2015 --outDir ./dist/esm --target ES2015 -d && node ./build/process-dts.js",
|
||||
"build:cjs": "node ../node_modules/typescript/bin/tsc --project ./tsconfig.json --module commonjs --outDir ./dist/cjs --target ES5",
|
||||
"build:browser": "node ../node_modules/rollup/bin/rollup -c",
|
||||
"build:uglify": "node ../node_modules/uglify-js/bin/uglifyjs --source-map \"url='signalr.min.js.map',content='./dist/browser/signalr.js.map'\" --comments -o ./dist/browser/signalr.min.js ./dist/browser/signalr.js",
|
||||
"pretest": "node ../node_modules/rimraf/bin.js ./spec/obj && tsc --project ./spec/tsconfig.json",
|
||||
"test": "node ../node_modules/jasmine/bin/jasmine.js ./spec/obj/spec/**/*.spec.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/aspnet/SignalR.git"
|
||||
},
|
||||
"author": "Microsoft",
|
||||
"license": "Apache-2.0",
|
||||
"bugs": {
|
||||
"url": "https://github.com/aspnet/SignalR/issues"
|
||||
},
|
||||
"homepage": "https://github.com/aspnet/SignalR#readme",
|
||||
"files": [
|
||||
"dist/**/*",
|
||||
"src/**/*"
|
||||
],
|
||||
"devDependencies": {
|
||||
"es6-promise": "^4.2.2"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
import baseConfig from "../rollup-base"
|
||||
|
||||
export default baseConfig(__dirname);
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
import { asyncit as it } from "./Utils";
|
||||
import { AbortController } from "../Microsoft.AspNetCore.SignalR.Client.TS/AbortController";
|
||||
import { AbortController } from "../src/AbortController";
|
||||
|
||||
describe("AbortSignal", () => {
|
||||
describe("aborted", () => {
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
import { Base64EncodedHubProtocol } from "../Microsoft.AspNetCore.SignalR.Client.TS/Base64EncodedHubProtocol"
|
||||
import { IHubProtocol, HubMessage, ProtocolType } from "../Microsoft.AspNetCore.SignalR.Client.TS/IHubProtocol"
|
||||
import { Base64EncodedHubProtocol } from "../src/Base64EncodedHubProtocol"
|
||||
import { IHubProtocol, HubMessage, ProtocolType } from "../src/IHubProtocol"
|
||||
|
||||
class FakeHubProtocol implements IHubProtocol {
|
||||
name: "fakehubprotocol";
|
||||
|
|
@ -36,7 +36,7 @@ describe("Base64EncodedHubProtocol", () => {
|
|||
["1.0:A;", new Error("Invalid length: '1.0'")],
|
||||
["2:A;", new Error("Invalid message size.")],
|
||||
["2:ABC;", new Error("Invalid message size.")],
|
||||
] as [[string, Error]]).forEach(([payload, expected_error]) => {
|
||||
] as [string, Error][]).forEach(([payload, expected_error]) => {
|
||||
it(`should fail to parse '${payload}'`, () => {
|
||||
expect(() => new Base64EncodedHubProtocol(new FakeHubProtocol()).parseMessages(payload)).toThrow(expected_error);
|
||||
});
|
||||
|
|
@ -59,7 +59,7 @@ describe("Base64EncodedHubProtocol", () => {
|
|||
|
||||
([
|
||||
[{}, "2:{};"],
|
||||
] as [[any, string]]).forEach(([message, payload]) => {
|
||||
] as [any, string][]).forEach(([message, payload]) => {
|
||||
it(`should be able to write '${JSON.stringify(message)}'`, () => {
|
||||
|
||||
let globalAny: any = global;
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
import { ITransport, TransportType } from "../Microsoft.AspNetCore.SignalR.Client.TS/Transports"
|
||||
import { ITransport, TransportType } from "../src/Transports"
|
||||
|
||||
export function eachTransport(action: (transport: TransportType) => void) {
|
||||
let transportTypes = [
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
import { asyncit as it } from "./Utils"
|
||||
import { TestHttpClient } from "./TestHttpClient";
|
||||
import { HttpRequest } from "../Microsoft.AspNetCore.SignalR.Client.TS/index";
|
||||
import { HttpRequest } from "../src/index";
|
||||
|
||||
describe("HttpClient", () => {
|
||||
describe("get", () => {
|
||||
|
|
@ -2,12 +2,12 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
import { TestHttpClient } from "./TestHttpClient"
|
||||
import { HttpConnection } from "../Microsoft.AspNetCore.SignalR.Client.TS/HttpConnection"
|
||||
import { IHttpConnectionOptions } from "../Microsoft.AspNetCore.SignalR.Client.TS/IHttpConnectionOptions"
|
||||
import { DataReceived, TransportClosed } from "../Microsoft.AspNetCore.SignalR.Client.TS/Common"
|
||||
import { ITransport, TransportType, TransferMode } from "../Microsoft.AspNetCore.SignalR.Client.TS/Transports"
|
||||
import { HttpConnection } from "../src/HttpConnection"
|
||||
import { IHttpConnectionOptions } from "../src/HttpConnection"
|
||||
import { DataReceived, TransportClosed } from "../src/Common"
|
||||
import { ITransport, TransportType, TransferMode } from "../src/Transports"
|
||||
import { eachTransport, eachEndpointUrl } from "./Common";
|
||||
import { HttpResponse } from "../Microsoft.AspNetCore.SignalR.Client.TS/index";
|
||||
import { HttpResponse } from "../src/index";
|
||||
|
||||
describe("HttpConnection", () => {
|
||||
it("cannot be created with relative url if document object is not present", () => {
|
||||
|
|
@ -1,17 +1,17 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
import { IConnection } from "../Microsoft.AspNetCore.SignalR.Client.TS/IConnection"
|
||||
import { HubConnection } from "../Microsoft.AspNetCore.SignalR.Client.TS/HubConnection"
|
||||
import { DataReceived, ConnectionClosed } from "../Microsoft.AspNetCore.SignalR.Client.TS/Common"
|
||||
import { TransportType, ITransport, TransferMode } from "../Microsoft.AspNetCore.SignalR.Client.TS/Transports"
|
||||
import { Observer } from "../Microsoft.AspNetCore.SignalR.Client.TS/Observable"
|
||||
import { TextMessageFormat } from "../Microsoft.AspNetCore.SignalR.Client.TS/Formatters"
|
||||
import { ILogger, LogLevel } from "../Microsoft.AspNetCore.SignalR.Client.TS/ILogger"
|
||||
import { MessageType } from "../Microsoft.AspNetCore.SignalR.Client.TS/IHubProtocol"
|
||||
import { IConnection } from "../src/IConnection"
|
||||
import { HubConnection } from "../src/HubConnection"
|
||||
import { DataReceived, ConnectionClosed } from "../src/Common"
|
||||
import { TransportType, ITransport, TransferMode } from "../src/Transports"
|
||||
import { Observer } from "../src/Observable"
|
||||
import { TextMessageFormat } from "../src/TextMessageFormat"
|
||||
import { ILogger, LogLevel } from "../src/ILogger"
|
||||
import { MessageType } from "../src/IHubProtocol"
|
||||
|
||||
import { asyncit as it, captureException, delay, PromiseSource } from './Utils';
|
||||
import { IHubConnectionOptions } from "../Microsoft.AspNetCore.SignalR.Client.TS/IHubConnectionOptions";
|
||||
import { IHubConnectionOptions } from "../src/HubConnection";
|
||||
|
||||
describe("HubConnection", () => {
|
||||
|
||||
|
|
@ -150,7 +150,7 @@ describe("HubConnection", () => {
|
|||
it("callback invoked when servers invokes a method on the client", async () => {
|
||||
let connection = new TestConnection();
|
||||
let hubConnection = new HubConnection(connection, { logger: null });
|
||||
let value = 0;
|
||||
let value = "";
|
||||
hubConnection.on("message", v => value = v);
|
||||
|
||||
connection.receive({
|
||||
|
|
@ -539,7 +539,7 @@ class TestConnection implements IConnection {
|
|||
|
||||
onreceive: DataReceived;
|
||||
onclose: ConnectionClosed;
|
||||
sentData: [any];
|
||||
sentData: any[];
|
||||
lastInvocationId: string;
|
||||
};
|
||||
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
import { LoggerFactory } from "../Microsoft.AspNetCore.SignalR.Client.TS/Loggers"
|
||||
import { ILogger, LogLevel } from "../Microsoft.AspNetCore.SignalR.Client.TS/ILogger"
|
||||
import { LoggerFactory } from "../src/Loggers"
|
||||
import { ILogger, LogLevel } from "../src/ILogger"
|
||||
|
||||
describe("LoggerFactory", () => {
|
||||
it("creates ConsoleLogger when no logging specified", () => {
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
import { HttpClient, HttpRequest, HttpResponse } from "../Microsoft.AspNetCore.SignalR.Client.TS/HttpClient"
|
||||
import { HttpClient, HttpRequest, HttpResponse } from "../src/HttpClient"
|
||||
|
||||
type TestHttpHandlerResult = HttpResponse | string;
|
||||
export type TestHttpHandler = (request: HttpRequest, next?: (request: HttpRequest) => Promise<HttpResponse>) => Promise<TestHttpHandlerResult> | TestHttpHandlerResult;
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
import { TextMessageFormat } from "../src/TextMessageFormat"
|
||||
|
||||
describe("Text Message Formatter", () => {
|
||||
([
|
||||
["\u001e", [""]],
|
||||
["\u001e\u001e", ["", ""]],
|
||||
["Hello\u001e", ["Hello"]],
|
||||
["Hello,\u001eWorld!\u001e", ["Hello,", "World!"]],
|
||||
] as [string, string[]][]).forEach(([payload, expected_messages]) => {
|
||||
it(`should parse '${payload}' correctly`, () => {
|
||||
let messages = TextMessageFormat.parse(payload);
|
||||
expect(messages).toEqual(expected_messages);
|
||||
})
|
||||
});
|
||||
|
||||
([
|
||||
["", new Error("Message is incomplete.")],
|
||||
["ABC", new Error("Message is incomplete.")],
|
||||
["ABC\u001eXYZ", new Error("Message is incomplete.")],
|
||||
] as [string, Error][]).forEach(([payload, expected_error]) => {
|
||||
it(`should fail to parse '${payload}'`, () => {
|
||||
expect(() => TextMessageFormat.parse(payload)).toThrow(expected_error);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
import { clearTimeout, setTimeout } from "timers";
|
||||
|
||||
export function asyncit(expectation: string, assertion?: () => Promise<any> | void, timeout?: number): void {
|
||||
let testFunction: (done: DoneFn) => void;
|
||||
if (assertion) {
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"compileOnSave": false,
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es5",
|
||||
"moduleResolution": "node",
|
||||
"outDir": "./obj",
|
||||
"lib": [ "es2015", "dom" ]
|
||||
},
|
||||
"include": [
|
||||
"./**/*",
|
||||
"../../typings/**/*"
|
||||
]
|
||||
}
|
||||
|
|
@ -5,10 +5,16 @@ import { DataReceived, ConnectionClosed } from "./Common"
|
|||
import { IConnection } from "./IConnection"
|
||||
import { ITransport, TransferMode, TransportType, WebSocketTransport, ServerSentEventsTransport, LongPollingTransport } from "./Transports"
|
||||
import { HttpClient, DefaultHttpClient } from "./HttpClient"
|
||||
import { IHttpConnectionOptions } from "./IHttpConnectionOptions"
|
||||
import { ILogger, LogLevel } from "./ILogger"
|
||||
import { LoggerFactory } from "./Loggers"
|
||||
|
||||
export interface IHttpConnectionOptions {
|
||||
httpClient?: HttpClient;
|
||||
transport?: TransportType | ITransport;
|
||||
logger?: ILogger | LogLevel;
|
||||
accessToken?: () => string;
|
||||
}
|
||||
|
||||
const enum ConnectionState {
|
||||
Connecting,
|
||||
Connected,
|
||||
|
|
@ -3,22 +3,22 @@
|
|||
|
||||
import { ConnectionClosed } from "./Common"
|
||||
import { IConnection } from "./IConnection"
|
||||
import { HttpConnection } from "./HttpConnection"
|
||||
import { HttpConnection, IHttpConnectionOptions } from "./HttpConnection"
|
||||
import { TransportType, TransferMode } from "./Transports"
|
||||
import { Subject, Observable } from "./Observable"
|
||||
import { IHubProtocol, ProtocolType, MessageType, HubMessage, CompletionMessage, ResultMessage, InvocationMessage, StreamInvocationMessage, NegotiationMessage, CancelInvocation } from "./IHubProtocol";
|
||||
import { JsonHubProtocol } from "./JsonHubProtocol";
|
||||
import { TextMessageFormat } from "./Formatters"
|
||||
import { TextMessageFormat } from "./TextMessageFormat"
|
||||
import { Base64EncodedHubProtocol } from "./Base64EncodedHubProtocol"
|
||||
import { ILogger, LogLevel } from "./ILogger"
|
||||
import { ConsoleLogger, NullLogger, LoggerFactory } from "./Loggers"
|
||||
import { IHubConnectionOptions } from "./IHubConnectionOptions"
|
||||
|
||||
export { TransportType } from "./Transports"
|
||||
export { HttpConnection } from "./HttpConnection"
|
||||
export { JsonHubProtocol } from "./JsonHubProtocol"
|
||||
export { LogLevel, ILogger } from "./ILogger"
|
||||
export { ConsoleLogger, NullLogger } from "./Loggers"
|
||||
export { JsonHubProtocol }
|
||||
|
||||
export interface IHubConnectionOptions extends IHttpConnectionOptions {
|
||||
protocol?: IHubProtocol;
|
||||
timeoutInMilliseconds?: number;
|
||||
}
|
||||
|
||||
const DEFAULT_TIMEOUT_IN_MS: number = 30 * 1000;
|
||||
|
||||
|
|
@ -1,12 +1,14 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
import { TextMessageFormat } from "./Formatters";
|
||||
import { TextMessageFormat } from "./TextMessageFormat";
|
||||
import { IHubProtocol, ProtocolType, HubMessage } from "./IHubProtocol";
|
||||
|
||||
export const JSON_HUB_PROTOCOL_NAME: string = "json";
|
||||
|
||||
export class JsonHubProtocol implements IHubProtocol {
|
||||
|
||||
readonly name: string = "json";
|
||||
readonly name: string = JSON_HUB_PROTOCOL_NAME;
|
||||
|
||||
readonly type: ProtocolType = ProtocolType.Text;
|
||||
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
export class TextMessageFormat {
|
||||
static RecordSeparator = String.fromCharCode(0x1e);
|
||||
|
||||
static write(output: string): string {
|
||||
return `${output}${TextMessageFormat.RecordSeparator}`;
|
||||
}
|
||||
|
||||
static parse(input: string): string[] {
|
||||
if (input[input.length - 1] != TextMessageFormat.RecordSeparator) {
|
||||
throw new Error("Message is incomplete.");
|
||||
}
|
||||
|
||||
let messages = input.split(TextMessageFormat.RecordSeparator);
|
||||
messages.pop();
|
||||
return messages;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
// This is where we add any polyfills we'll need for the browser. It is the entry module for browser-specific builds.
|
||||
|
||||
import 'es6-promise/dist/es6-promise.auto.js';
|
||||
|
||||
export * from './index'
|
||||
|
|
@ -1,10 +1,15 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
// Everything that users need to access must be exported here. Including interfaces.
|
||||
export * from "./Common"
|
||||
export * from "./HttpConnection"
|
||||
export * from "./Errors"
|
||||
export * from "./HttpClient"
|
||||
export * from "./HttpConnection"
|
||||
export * from "./HubConnection"
|
||||
export * from "./Transports"
|
||||
export * from "./IConnection"
|
||||
export * from "./IHubProtocol"
|
||||
export * from "./ILogger"
|
||||
export * from "./Loggers"
|
||||
export * from "./MessagePackHubProtocol"
|
||||
export * from "./Transports"
|
||||
export * from "./Observable"
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
.NET Core uses third-party libraries or other resources that may be
|
||||
distributed under licenses different than the .NET Core software.
|
||||
|
||||
In the event that we accidentally failed to list a required notice, please
|
||||
bring it to our attention. Post an issue or email us:
|
||||
|
||||
dotnet@microsoft.com
|
||||
|
||||
The attached notices are provided for information only.
|
||||
|
||||
|
||||
License notice for es6-promise
|
||||
------------------------------------------------------------------------------
|
||||
"Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors
|
||||
|
||||
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."
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"extends": "../tsconfig-base.json",
|
||||
"include": [
|
||||
"./src/**/*",
|
||||
"../typings/**/*"
|
||||
]
|
||||
}
|
||||
|
|
@ -1,18 +1,17 @@
|
|||
{
|
||||
"compileOnSave": true,
|
||||
"compileOnSave": false,
|
||||
"compilerOptions": {
|
||||
"module": "umd",
|
||||
"target": "es6",
|
||||
"module": "es2015",
|
||||
"target": "es2016",
|
||||
"sourceMap": true,
|
||||
"moduleResolution": "node",
|
||||
"inlineSources": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"removeComments": false,
|
||||
"noImplicitAny": true,
|
||||
"suppressImplicitAnyIndexErrors": true,
|
||||
"outDir": "../dist/test"
|
||||
},
|
||||
"include": [
|
||||
"./**/*",
|
||||
"../typings/*"
|
||||
]
|
||||
"noEmitOnError": true,
|
||||
"lib": [ "es2016", "dom" ]
|
||||
}
|
||||
}
|
||||
|
|
@ -1,3 +1,9 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
// Hand-written EventSource typings. I couldn't find anything easy-to-consume out there. This is purely based on the API docs.
|
||||
// -anurse
|
||||
|
||||
interface EventSourceOptions {
|
||||
withcredentials: boolean
|
||||
}
|
||||
|
|
@ -1,571 +0,0 @@
|
|||
// Generated by typings
|
||||
// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/c26e1aebf2e08b09778ec4b005f1c446f0635261/jasmine/index.d.ts
|
||||
declare function describe(description: string, specDefinitions: () => void): void;
|
||||
declare function fdescribe(description: string, specDefinitions: () => void): void;
|
||||
declare function xdescribe(description: string, specDefinitions: () => void): void;
|
||||
|
||||
declare function it(expectation: string, assertion?: (done: DoneFn) => void, timeout?: number): void;
|
||||
declare function fit(expectation: string, assertion?: (done: DoneFn) => void, timeout?: number): void;
|
||||
declare function xit(expectation: string, assertion?: (done: DoneFn) => void, timeout?: number): void;
|
||||
|
||||
/** If you call the function pending anywhere in the spec body, no matter the expectations, the spec will be marked pending. */
|
||||
declare function pending(reason?: string): void;
|
||||
|
||||
declare function beforeEach(action: (done: DoneFn) => void, timeout?: number): void;
|
||||
declare function afterEach(action: (done: DoneFn) => void, timeout?: number): void;
|
||||
|
||||
declare function beforeAll(action: (done: DoneFn) => void, timeout?: number): void;
|
||||
declare function afterAll(action: (done: DoneFn) => void, timeout?: number): void;
|
||||
|
||||
declare function expect(spy: Function): jasmine.Matchers;
|
||||
declare function expect(actual: any): jasmine.Matchers;
|
||||
|
||||
declare function fail(e?: any): void;
|
||||
/** Action method that should be called when the async work is complete */
|
||||
interface DoneFn extends Function {
|
||||
(): void;
|
||||
|
||||
/** fails the spec and indicates that it has completed. If the message is an Error, Error.message is used */
|
||||
fail: (message?: Error|string) => void;
|
||||
}
|
||||
|
||||
declare function spyOn(object: any, method: string): jasmine.Spy;
|
||||
|
||||
declare function runs(asyncMethod: Function): void;
|
||||
declare function waitsFor(latchMethod: () => boolean, failureMessage?: string, timeout?: number): void;
|
||||
declare function waits(timeout?: number): void;
|
||||
|
||||
declare namespace jasmine {
|
||||
|
||||
var clock: () => Clock;
|
||||
|
||||
function any(aclass: any): Any;
|
||||
function anything(): Any;
|
||||
function arrayContaining(sample: any[]): ArrayContaining;
|
||||
function objectContaining(sample: any): ObjectContaining;
|
||||
function createSpy(name: string, originalFn?: Function): Spy;
|
||||
function createSpyObj(baseName: string, methodNames: any[]): any;
|
||||
function createSpyObj<T>(baseName: string, methodNames: any[]): T;
|
||||
function pp(value: any): string;
|
||||
function getEnv(): Env;
|
||||
function addCustomEqualityTester(equalityTester: CustomEqualityTester): void;
|
||||
function addMatchers(matchers: CustomMatcherFactories): void;
|
||||
function stringMatching(str: string): Any;
|
||||
function stringMatching(str: RegExp): Any;
|
||||
function formatErrorMsg(domain: string, usage: string) : (msg: string) => string
|
||||
|
||||
interface Any {
|
||||
|
||||
new (expectedClass: any): any;
|
||||
|
||||
jasmineMatches(other: any): boolean;
|
||||
jasmineToString(): string;
|
||||
}
|
||||
|
||||
// taken from TypeScript lib.core.es6.d.ts, applicable to CustomMatchers.contains()
|
||||
interface ArrayLike<T> {
|
||||
length: number;
|
||||
[n: number]: T;
|
||||
}
|
||||
|
||||
interface ArrayContaining {
|
||||
new (sample: any[]): any;
|
||||
|
||||
asymmetricMatch(other: any): boolean;
|
||||
jasmineToString(): string;
|
||||
}
|
||||
|
||||
interface ObjectContaining {
|
||||
new (sample: any): any;
|
||||
|
||||
jasmineMatches(other: any, mismatchKeys: any[], mismatchValues: any[]): boolean;
|
||||
jasmineToString(): string;
|
||||
}
|
||||
|
||||
interface Block {
|
||||
|
||||
new (env: Env, func: SpecFunction, spec: Spec): any;
|
||||
|
||||
execute(onComplete: () => void): void;
|
||||
}
|
||||
|
||||
interface WaitsBlock extends Block {
|
||||
new (env: Env, timeout: number, spec: Spec): any;
|
||||
}
|
||||
|
||||
interface WaitsForBlock extends Block {
|
||||
new (env: Env, timeout: number, latchFunction: SpecFunction, message: string, spec: Spec): any;
|
||||
}
|
||||
|
||||
interface Clock {
|
||||
install(): void;
|
||||
uninstall(): void;
|
||||
/** Calls to any registered callback are triggered when the clock is ticked forward via the jasmine.clock().tick function, which takes a number of milliseconds. */
|
||||
tick(ms: number): void;
|
||||
mockDate(date?: Date): void;
|
||||
withMock(func: () => void): void;
|
||||
}
|
||||
|
||||
interface CustomEqualityTester {
|
||||
(first: any, second: any): boolean;
|
||||
}
|
||||
|
||||
interface CustomMatcher {
|
||||
compare<T>(actual: T, expected: T): CustomMatcherResult;
|
||||
compare(actual: any, expected: any): CustomMatcherResult;
|
||||
}
|
||||
|
||||
interface CustomMatcherFactory {
|
||||
(util: MatchersUtil, customEqualityTesters: Array<CustomEqualityTester>): CustomMatcher;
|
||||
}
|
||||
|
||||
interface CustomMatcherFactories {
|
||||
[index: string]: CustomMatcherFactory;
|
||||
}
|
||||
|
||||
interface CustomMatcherResult {
|
||||
pass: boolean;
|
||||
message?: string;
|
||||
}
|
||||
|
||||
interface MatchersUtil {
|
||||
equals(a: any, b: any, customTesters?: Array<CustomEqualityTester>): boolean;
|
||||
contains<T>(haystack: ArrayLike<T> | string, needle: any, customTesters?: Array<CustomEqualityTester>): boolean;
|
||||
buildFailureMessage(matcherName: string, isNot: boolean, actual: any, ...expected: Array<any>): string;
|
||||
}
|
||||
|
||||
interface Env {
|
||||
setTimeout: any;
|
||||
clearTimeout: void;
|
||||
setInterval: any;
|
||||
clearInterval: void;
|
||||
updateInterval: number;
|
||||
|
||||
currentSpec: Spec;
|
||||
|
||||
matchersClass: Matchers;
|
||||
|
||||
version(): any;
|
||||
versionString(): string;
|
||||
nextSpecId(): number;
|
||||
addReporter(reporter: Reporter): void;
|
||||
addReporter(reporter: CustomReporter): void;
|
||||
execute(): void;
|
||||
describe(description: string, specDefinitions: () => void): Suite;
|
||||
// ddescribe(description: string, specDefinitions: () => void): Suite; Not a part of jasmine. Angular team adds these
|
||||
beforeEach(beforeEachFunction: () => void): void;
|
||||
beforeAll(beforeAllFunction: () => void): void;
|
||||
currentRunner(): Runner;
|
||||
afterEach(afterEachFunction: () => void): void;
|
||||
afterAll(afterAllFunction: () => void): void;
|
||||
xdescribe(desc: string, specDefinitions: () => void): XSuite;
|
||||
it(description: string, func: () => void): Spec;
|
||||
// iit(description: string, func: () => void): Spec; Not a part of jasmine. Angular team adds these
|
||||
xit(desc: string, func: () => void): XSpec;
|
||||
compareRegExps_(a: RegExp, b: RegExp, mismatchKeys: string[], mismatchValues: string[]): boolean;
|
||||
compareObjects_(a: any, b: any, mismatchKeys: string[], mismatchValues: string[]): boolean;
|
||||
equals_(a: any, b: any, mismatchKeys: string[], mismatchValues: string[]): boolean;
|
||||
contains_(haystack: any, needle: any): boolean;
|
||||
addCustomEqualityTester(equalityTester: CustomEqualityTester): void;
|
||||
addMatchers(matchers: CustomMatcherFactories): void;
|
||||
specFilter(spec: Spec): boolean;
|
||||
throwOnExpectationFailure(value: boolean): void;
|
||||
seed(seed: string | number): string | number;
|
||||
provideFallbackReporter(reporter: Reporter): void;
|
||||
throwingExpectationFailures(): boolean;
|
||||
allowRespy(allow: boolean): void;
|
||||
randomTests(): boolean;
|
||||
randomizeTests(b: boolean): void;
|
||||
clearReporters(): void;
|
||||
}
|
||||
|
||||
interface FakeTimer {
|
||||
|
||||
new (): any;
|
||||
|
||||
reset(): void;
|
||||
tick(millis: number): void;
|
||||
runFunctionsWithinRange(oldMillis: number, nowMillis: number): void;
|
||||
scheduleFunction(timeoutKey: any, funcToCall: () => void, millis: number, recurring: boolean): void;
|
||||
}
|
||||
|
||||
interface HtmlReporter {
|
||||
new (): any;
|
||||
}
|
||||
|
||||
interface HtmlSpecFilter {
|
||||
new (): any;
|
||||
}
|
||||
|
||||
interface Result {
|
||||
type: string;
|
||||
}
|
||||
|
||||
interface NestedResults extends Result {
|
||||
description: string;
|
||||
|
||||
totalCount: number;
|
||||
passedCount: number;
|
||||
failedCount: number;
|
||||
|
||||
skipped: boolean;
|
||||
|
||||
rollupCounts(result: NestedResults): void;
|
||||
log(values: any): void;
|
||||
getItems(): Result[];
|
||||
addResult(result: Result): void;
|
||||
passed(): boolean;
|
||||
}
|
||||
|
||||
interface MessageResult extends Result {
|
||||
values: any;
|
||||
trace: Trace;
|
||||
}
|
||||
|
||||
interface ExpectationResult extends Result {
|
||||
matcherName: string;
|
||||
passed(): boolean;
|
||||
expected: any;
|
||||
actual: any;
|
||||
message: string;
|
||||
trace: Trace;
|
||||
}
|
||||
|
||||
interface Order {
|
||||
new (options: {random: boolean, seed: string}): any;
|
||||
random: boolean;
|
||||
seed: string;
|
||||
sort<T>(items: T[]) : T[];
|
||||
}
|
||||
|
||||
namespace errors {
|
||||
class ExpectationFailed extends Error {
|
||||
constructor();
|
||||
stack: any;
|
||||
}
|
||||
}
|
||||
|
||||
interface TreeProcessor {
|
||||
new (attrs: any): any;
|
||||
execute: (done: Function) => void;
|
||||
processTree() : any;
|
||||
}
|
||||
|
||||
interface Trace {
|
||||
name: string;
|
||||
message: string;
|
||||
stack: any;
|
||||
}
|
||||
|
||||
interface PrettyPrinter {
|
||||
|
||||
new (): any;
|
||||
|
||||
format(value: any): void;
|
||||
iterateObject(obj: any, fn: (property: string, isGetter: boolean) => void): void;
|
||||
emitScalar(value: any): void;
|
||||
emitString(value: string): void;
|
||||
emitArray(array: any[]): void;
|
||||
emitObject(obj: any): void;
|
||||
append(value: any): void;
|
||||
}
|
||||
|
||||
interface StringPrettyPrinter extends PrettyPrinter {
|
||||
}
|
||||
|
||||
interface Queue {
|
||||
|
||||
new (env: any): any;
|
||||
|
||||
env: Env;
|
||||
ensured: boolean[];
|
||||
blocks: Block[];
|
||||
running: boolean;
|
||||
index: number;
|
||||
offset: number;
|
||||
abort: boolean;
|
||||
|
||||
addBefore(block: Block, ensure?: boolean): void;
|
||||
add(block: any, ensure?: boolean): void;
|
||||
insertNext(block: any, ensure?: boolean): void;
|
||||
start(onComplete?: () => void): void;
|
||||
isRunning(): boolean;
|
||||
next_(): void;
|
||||
results(): NestedResults;
|
||||
}
|
||||
|
||||
interface Matchers {
|
||||
|
||||
new (env: Env, actual: any, spec: Env, isNot?: boolean): any;
|
||||
|
||||
env: Env;
|
||||
actual: any;
|
||||
spec: Env;
|
||||
isNot?: boolean;
|
||||
message(): any;
|
||||
|
||||
toBe(expected: any, expectationFailOutput?: any): boolean;
|
||||
toEqual(expected: any, expectationFailOutput?: any): boolean;
|
||||
toMatch(expected: string | RegExp, expectationFailOutput?: any): boolean;
|
||||
toBeDefined(expectationFailOutput?: any): boolean;
|
||||
toBeUndefined(expectationFailOutput?: any): boolean;
|
||||
toBeNull(expectationFailOutput?: any): boolean;
|
||||
toBeNaN(): boolean;
|
||||
toBeTruthy(expectationFailOutput?: any): boolean;
|
||||
toBeFalsy(expectationFailOutput?: any): boolean;
|
||||
toHaveBeenCalled(): boolean;
|
||||
toHaveBeenCalledWith(...params: any[]): boolean;
|
||||
toHaveBeenCalledTimes(expected: number): boolean;
|
||||
toContain(expected: any, expectationFailOutput?: any): boolean;
|
||||
toBeLessThan(expected: number, expectationFailOutput?: any): boolean;
|
||||
toBeLessThanOrEqual(expected: number, expectationFailOutput?: any): boolean;
|
||||
toBeGreaterThan(expected: number, expectationFailOutput?: any): boolean;
|
||||
toBeGreaterThanOrEqual(expected: number, expectationFailOutput?: any): boolean;
|
||||
toBeCloseTo(expected: number, precision?: any, expectationFailOutput?: any): boolean;
|
||||
toThrow(expected?: any): boolean;
|
||||
toThrowError(message?: string | RegExp): boolean;
|
||||
toThrowError(expected?: new (...args: any[]) => Error, message?: string | RegExp): boolean;
|
||||
not: Matchers;
|
||||
|
||||
Any: Any;
|
||||
}
|
||||
|
||||
interface Reporter {
|
||||
reportRunnerStarting(runner: Runner): void;
|
||||
reportRunnerResults(runner: Runner): void;
|
||||
reportSuiteResults(suite: Suite): void;
|
||||
reportSpecStarting(spec: Spec): void;
|
||||
reportSpecResults(spec: Spec): void;
|
||||
log(str: string): void;
|
||||
}
|
||||
|
||||
interface MultiReporter extends Reporter {
|
||||
addReporter(reporter: Reporter): void;
|
||||
}
|
||||
|
||||
interface SuiteInfo {
|
||||
totalSpecsDefined: number;
|
||||
}
|
||||
|
||||
interface CustomReportExpectation {
|
||||
matcherName: string;
|
||||
message: string;
|
||||
passed: boolean;
|
||||
stack: string;
|
||||
}
|
||||
|
||||
interface FailedExpectation extends CustomReportExpectation {
|
||||
actual: string;
|
||||
expected: string;
|
||||
}
|
||||
|
||||
interface PassedExpectation extends CustomReportExpectation {
|
||||
|
||||
}
|
||||
|
||||
interface CustomReporterResult {
|
||||
description: string,
|
||||
failedExpectations?: FailedExpectation[],
|
||||
fullName: string,
|
||||
id: string;
|
||||
passedExpectations?: PassedExpectation[],
|
||||
pendingReason?: string;
|
||||
status?: string;
|
||||
}
|
||||
|
||||
interface CustomReporter {
|
||||
jasmineStarted?(suiteInfo: SuiteInfo): void;
|
||||
suiteStarted?(result: CustomReporterResult): void;
|
||||
specStarted?(result: CustomReporterResult): void;
|
||||
specDone?(result: CustomReporterResult): void;
|
||||
suiteDone?(result: CustomReporterResult): void;
|
||||
jasmineDone?(): any;
|
||||
}
|
||||
|
||||
interface Runner {
|
||||
|
||||
new (env: Env): any;
|
||||
|
||||
execute(): void;
|
||||
beforeEach(beforeEachFunction: SpecFunction): void;
|
||||
afterEach(afterEachFunction: SpecFunction): void;
|
||||
beforeAll(beforeAllFunction: SpecFunction): void;
|
||||
afterAll(afterAllFunction: SpecFunction): void;
|
||||
finishCallback(): void;
|
||||
addSuite(suite: Suite): void;
|
||||
add(block: Block): void;
|
||||
specs(): Spec[];
|
||||
suites(): Suite[];
|
||||
topLevelSuites(): Suite[];
|
||||
results(): NestedResults;
|
||||
}
|
||||
|
||||
interface SpecFunction {
|
||||
(spec?: Spec): void;
|
||||
}
|
||||
|
||||
interface SuiteOrSpec {
|
||||
id: number;
|
||||
env: Env;
|
||||
description: string;
|
||||
queue: Queue;
|
||||
}
|
||||
|
||||
interface Spec extends SuiteOrSpec {
|
||||
|
||||
new (env: Env, suite: Suite, description: string): any;
|
||||
|
||||
suite: Suite;
|
||||
|
||||
afterCallbacks: SpecFunction[];
|
||||
spies_: Spy[];
|
||||
|
||||
results_: NestedResults;
|
||||
matchersClass: Matchers;
|
||||
|
||||
getFullName(): string;
|
||||
results(): NestedResults;
|
||||
log(arguments: any): any;
|
||||
runs(func: SpecFunction): Spec;
|
||||
addToQueue(block: Block): void;
|
||||
addMatcherResult(result: Result): void;
|
||||
getResult(): any;
|
||||
expect(actual: any): any;
|
||||
waits(timeout: number): Spec;
|
||||
waitsFor(latchFunction: SpecFunction, timeoutMessage?: string, timeout?: number): Spec;
|
||||
fail(e?: any): void;
|
||||
getMatchersClass_(): Matchers;
|
||||
addMatchers(matchersPrototype: CustomMatcherFactories): void;
|
||||
finishCallback(): void;
|
||||
finish(onComplete?: () => void): void;
|
||||
after(doAfter: SpecFunction): void;
|
||||
execute(onComplete?: () => void, enabled?: boolean): any;
|
||||
addBeforesAndAftersToQueue(): void;
|
||||
explodes(): void;
|
||||
spyOn(obj: any, methodName: string, ignoreMethodDoesntExist: boolean): Spy;
|
||||
removeAllSpies(): void;
|
||||
throwOnExpectationFailure: boolean;
|
||||
}
|
||||
|
||||
interface XSpec {
|
||||
id: number;
|
||||
runs(): void;
|
||||
}
|
||||
|
||||
interface Suite extends SuiteOrSpec {
|
||||
|
||||
new (env: Env, description: string, specDefinitions: () => void, parentSuite: Suite): any;
|
||||
|
||||
parentSuite: Suite;
|
||||
|
||||
getFullName(): string;
|
||||
finish(onComplete?: () => void): void;
|
||||
beforeEach(beforeEachFunction: SpecFunction): void;
|
||||
afterEach(afterEachFunction: SpecFunction): void;
|
||||
beforeAll(beforeAllFunction: SpecFunction): void;
|
||||
afterAll(afterAllFunction: SpecFunction): void;
|
||||
results(): NestedResults;
|
||||
add(suiteOrSpec: SuiteOrSpec): void;
|
||||
specs(): Spec[];
|
||||
suites(): Suite[];
|
||||
children(): any[];
|
||||
execute(onComplete?: () => void): void;
|
||||
}
|
||||
|
||||
interface XSuite {
|
||||
execute(): void;
|
||||
}
|
||||
|
||||
interface Spy {
|
||||
(...params: any[]): any;
|
||||
|
||||
identity: string;
|
||||
and: SpyAnd;
|
||||
calls: Calls;
|
||||
mostRecentCall: { args: any[]; };
|
||||
argsForCall: any[];
|
||||
}
|
||||
|
||||
interface SpyAnd {
|
||||
/** By chaining the spy with and.callThrough, the spy will still track all calls to it but in addition it will delegate to the actual implementation. */
|
||||
callThrough(): Spy;
|
||||
/** By chaining the spy with and.returnValue, all calls to the function will return a specific value. */
|
||||
returnValue(val: any): Spy;
|
||||
/** By chaining the spy with and.returnValues, all calls to the function will return specific values in order until it reaches the end of the return values list. */
|
||||
returnValues(...values: any[]): Spy;
|
||||
/** By chaining the spy with and.callFake, all calls to the spy will delegate to the supplied function. */
|
||||
callFake(fn: Function): Spy;
|
||||
/** By chaining the spy with and.throwError, all calls to the spy will throw the specified value. */
|
||||
throwError(msg: string): Spy;
|
||||
/** When a calling strategy is used for a spy, the original stubbing behavior can be returned at any time with and.stub. */
|
||||
stub(): Spy;
|
||||
}
|
||||
|
||||
interface Calls {
|
||||
/** By chaining the spy with calls.any(), will return false if the spy has not been called at all, and then true once at least one call happens. **/
|
||||
any(): boolean;
|
||||
/** By chaining the spy with calls.count(), will return the number of times the spy was called **/
|
||||
count(): number;
|
||||
/** By chaining the spy with calls.argsFor(), will return the arguments passed to call number index **/
|
||||
argsFor(index: number): any[];
|
||||
/** By chaining the spy with calls.allArgs(), will return the arguments to all calls **/
|
||||
allArgs(): any[];
|
||||
/** By chaining the spy with calls.all(), will return the context (the this) and arguments passed all calls **/
|
||||
all(): CallInfo[];
|
||||
/** By chaining the spy with calls.mostRecent(), will return the context (the this) and arguments for the most recent call **/
|
||||
mostRecent(): CallInfo;
|
||||
/** By chaining the spy with calls.first(), will return the context (the this) and arguments for the first call **/
|
||||
first(): CallInfo;
|
||||
/** By chaining the spy with calls.reset(), will clears all tracking for a spy **/
|
||||
reset(): void;
|
||||
}
|
||||
|
||||
interface CallInfo {
|
||||
/** The context (the this) for the call */
|
||||
object: any;
|
||||
/** All arguments passed to the call */
|
||||
args: any[];
|
||||
/** The return value of the call */
|
||||
returnValue: any;
|
||||
}
|
||||
|
||||
interface Util {
|
||||
inherit(childClass: Function, parentClass: Function): any;
|
||||
formatException(e: any): any;
|
||||
htmlEscape(str: string): string;
|
||||
argsToArray(args: any): any;
|
||||
extend(destination: any, source: any): any;
|
||||
}
|
||||
|
||||
interface JsApiReporter extends Reporter {
|
||||
|
||||
started: boolean;
|
||||
finished: boolean;
|
||||
result: any;
|
||||
messages: any;
|
||||
runDetails: {
|
||||
failedExpectations: ExpectationResult[];
|
||||
order: jasmine.Order
|
||||
}
|
||||
|
||||
new (): any;
|
||||
|
||||
suites(): Suite[];
|
||||
summarize_(suiteOrSpec: SuiteOrSpec): any;
|
||||
results(): any;
|
||||
resultsForSpec(specId: any): any;
|
||||
log(str: any): any;
|
||||
resultsForSpecs(specIds: any): any;
|
||||
summarizeResult_(result: any): any;
|
||||
}
|
||||
|
||||
interface Jasmine {
|
||||
Spec: Spec;
|
||||
clock: Clock;
|
||||
util: Util;
|
||||
}
|
||||
|
||||
export var HtmlReporter: HtmlReporter;
|
||||
export var HtmlSpecFilter: HtmlSpecFilter;
|
||||
export var DEFAULT_TIMEOUT_INTERVAL: number;
|
||||
}
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
{
|
||||
"resolution": "main",
|
||||
"tree": {
|
||||
"src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/c26e1aebf2e08b09778ec4b005f1c446f0635261/jasmine/index.d.ts",
|
||||
"raw": "registry:dt/jasmine#2.5.0+20161228223817",
|
||||
"typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/c26e1aebf2e08b09778ec4b005f1c446f0635261/jasmine/index.d.ts"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
/// <reference path="globals/jasmine/index.d.ts" />
|
||||
/// <reference path="globals/EventSource/EventSource.d.ts" />
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Test Page</title>
|
||||
<style>
|
||||
.test-success {
|
||||
color: green;
|
||||
}
|
||||
.test-failed {
|
||||
color: red;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Test Page</h1>
|
||||
<p>This page validates that the UMD builds of the signalr-client and signalr-protocol-msgpack modules are available in the global scope when in a browser.</p>
|
||||
<h2>Test Results</h2>
|
||||
<ul id="results-list">
|
||||
</ul>
|
||||
<script src="./signalr-protocol-msgpack/node_modules/msgpack5/dist/msgpack5.js"></script>
|
||||
<script type="text/javascript">
|
||||
function getParameterByName(name, url) {
|
||||
if (!url) {
|
||||
url = window.location.href;
|
||||
}
|
||||
name = name.replace(/[\[\]]/g, "\\$&");
|
||||
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
|
||||
results = regex.exec(url);
|
||||
if (!results) return null;
|
||||
if (!results[2]) return '';
|
||||
return decodeURIComponent(results[2].replace(/\+/g, " "));
|
||||
}
|
||||
|
||||
function importSignalR() {
|
||||
var minified = getParameterByName('min') === 'true' ? '.min' : '';
|
||||
document.write('<script type="text/javascript" src="./signalr/dist/browser/signalr' + minified + '.js"><\/script>');
|
||||
document.write('<script type="text/javascript" src="./signalr-protocol-msgpack/dist/browser/signalr-protocol-msgpack' + minified + '.js"><\/script>');
|
||||
}
|
||||
|
||||
var resultsList = document.getElementById("results-list");
|
||||
// Run tests
|
||||
function test(name, impl) {
|
||||
var result = ""
|
||||
var success = false;
|
||||
try {
|
||||
impl();
|
||||
result = "success";
|
||||
success = true;
|
||||
} catch(e) {
|
||||
console.error(e);
|
||||
result = "error: " + e;
|
||||
success = false;
|
||||
}
|
||||
|
||||
var cssClass = success ? "test-success": "test-failed";
|
||||
resultsList.innerHTML += "<li class=\"" + cssClass + "\">" + name + ": " + result + "</li>";
|
||||
}
|
||||
|
||||
test("Promise may not be available before the polyfill", function() {
|
||||
if(!Promise) {
|
||||
throw "Promise is falsey: " + Promise;
|
||||
}
|
||||
});
|
||||
|
||||
test("Buffer is not available before the polyfill", function() {
|
||||
if(typeof Buffer !== "undefined") {
|
||||
throw "Buffer is truthy: " + Buffer;
|
||||
}
|
||||
});
|
||||
|
||||
importSignalR();
|
||||
</script>
|
||||
|
||||
<script>
|
||||
test("Promise is available after the polyfill", function() {
|
||||
if(!Promise) {
|
||||
throw "Promise is falsey: " + Promise;
|
||||
}
|
||||
});
|
||||
|
||||
test("Buffer is not available after the polyfill", function() {
|
||||
if(typeof Buffer !== "undefined") {
|
||||
throw "Buffer is truthy: " + Buffer;
|
||||
}
|
||||
});
|
||||
|
||||
test("signalR is available", function() {
|
||||
if(!window.signalR){
|
||||
throw "window.signalR is falsey: " + window.signalR;
|
||||
}
|
||||
});
|
||||
test("msgpack5 is available", function() {
|
||||
if(!window.msgpack5){
|
||||
throw "window.msgpack5 is falsey: " + window.msgpack5;
|
||||
}
|
||||
});
|
||||
test("signalR.protocols.msgpack.MessagePackHubProtocol is available", function() {
|
||||
if(!window.signalR.protocols.msgpack.MessagePackHubProtocol){
|
||||
throw "signalR.protocols.msgpack is falsey: " + signalR.protocols.msgpack.MessagePackHubProtocol;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1 @@
|
|||
wwwroot/lib/
|
||||
|
|
@ -10,7 +10,6 @@
|
|||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.SignalR\Microsoft.AspNetCore.SignalR.csproj" />
|
||||
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.SignalR.Redis\Microsoft.AspNetCore.SignalR.Redis.csproj" />
|
||||
<ProjectReference Include="..\..\client-ts\Microsoft.AspNetCore.SignalR.Client.TS\Microsoft.AspNetCore.SignalR.Client.TS.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
@ -40,7 +39,11 @@
|
|||
</ItemGroup>
|
||||
|
||||
<Target Name="CopyTSClient" BeforeTargets="AfterBuild">
|
||||
<Copy SourceFiles="$(MSBuildThisFileDirectory)..\..\client-ts\dist\browser\signalr-client.js" DestinationFolder="$(MSBuildThisFileDirectory)wwwroot\lib\signalr-client" />
|
||||
<ItemGroup>
|
||||
<SignalRJSClientFiles Include="$(MSBuildThisFileDirectory)..\..\client-ts\signalr\dist\browser\*" />
|
||||
<SignalRJSClientFiles Include="$(MSBuildThisFileDirectory)..\..\client-ts\signalr-protocol-msgpack\dist\browser\*" />
|
||||
</ItemGroup>
|
||||
<Copy SourceFiles="@(SignalRJSClientFiles)" DestinationFolder="$(MSBuildThisFileDirectory)wwwroot\lib\signalr-client" />
|
||||
</Target>
|
||||
|
||||
<Target Name="BowerInstall" BeforeTargets="PrepareForPublish">
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
@{
|
||||
@{
|
||||
ViewData["Title"] = "Chat";
|
||||
}
|
||||
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
<input type="submit" id="send" value="Send" class="send" />
|
||||
</form>
|
||||
</div>
|
||||
<script src="lib/signalr-client/signalr-client.js"></script>
|
||||
<script src="lib/signalr-client/signalr.js"></script>
|
||||
<script>
|
||||
let transportType = signalR.TransportType[getParameterByName('transport')] || signalR.TransportType.WebSockets;
|
||||
let logger = new signalR.ConsoleLogger(signalR.LogLevel.Information);
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
wwwroot/lib/
|
||||
|
|
@ -10,7 +10,9 @@
|
|||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.SignalR\Microsoft.AspNetCore.SignalR.csproj" />
|
||||
<ProjectReference Include="..\..\client-ts\Microsoft.AspNetCore.SignalR.Client.TS\Microsoft.AspNetCore.SignalR.Client.TS.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="$(MicrosoftAspNetCoreAuthenticationJwtBearerPackageVersion)" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="$(MicrosoftAspNetCoreDiagnosticsPackageVersion)" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="$(MicrosoftAspNetCoreHostingPackageVersion)" />
|
||||
|
|
@ -22,6 +24,10 @@
|
|||
</ItemGroup>
|
||||
|
||||
<Target Name="CopyTSClient" BeforeTargets="AfterBuild">
|
||||
<Copy SourceFiles="$(MSBuildThisFileDirectory)..\..\client-ts\dist\browser\signalr-client.js" DestinationFolder="$(MSBuildThisFileDirectory)wwwroot\lib\signalr-client" />
|
||||
<ItemGroup>
|
||||
<SignalRJSClientFiles Include="$(MSBuildThisFileDirectory)..\..\client-ts\signalr\dist\browser\*" />
|
||||
<SignalRJSClientFiles Include="$(MSBuildThisFileDirectory)..\..\client-ts\signalr-protocol-msgpack\dist\browser\*" />
|
||||
</ItemGroup>
|
||||
<Copy SourceFiles="@(SignalRJSClientFiles)" DestinationFolder="$(MSBuildThisFileDirectory)wwwroot\lib\signalr-client" />
|
||||
</Target>
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
</div>
|
||||
</body>
|
||||
</html>
|
||||
<script type="text/javascript" src="lib/signalr-client/signalr-client.js"></script>
|
||||
<script type="text/javascript" src="lib/signalr-client/signalr.js"></script>
|
||||
<script>
|
||||
|
||||
function createLog(clientId) {
|
||||
|
|
@ -68,7 +68,7 @@
|
|||
.then(function () {
|
||||
var options = {
|
||||
transport: transportType,
|
||||
jwtBearer: function () { return tokens[clientId]; }
|
||||
accessToken: function () { return tokens[clientId]; }
|
||||
};
|
||||
|
||||
connection = new signalR.HubConnection('/broadcast', options);
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
wwwroot/lib/
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:1850/",
|
||||
"applicationUrl": "http://localhost:61694/",
|
||||
"sslPort": 0
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@
|
|||
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.SignalR\Microsoft.AspNetCore.SignalR.csproj" />
|
||||
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Sockets.Http\Microsoft.AspNetCore.Sockets.Http.csproj" />
|
||||
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.SignalR.Redis\Microsoft.AspNetCore.SignalR.Redis.csproj" />
|
||||
<ProjectReference Include="..\..\client-ts\Microsoft.AspNetCore.SignalR.Client.TS\Microsoft.AspNetCore.SignalR.Client.TS.csproj" />
|
||||
|
||||
<PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonPackageVersion)" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="$(MicrosoftAspNetCoreDiagnosticsPackageVersion)" />
|
||||
|
|
@ -27,7 +26,8 @@
|
|||
|
||||
<Target Name="CopyTSClient" BeforeTargets="AfterBuild">
|
||||
<ItemGroup>
|
||||
<SignalRJSClientFiles Include="$(MSBuildThisFileDirectory)..\..\client-ts\dist\browser\*" />
|
||||
<SignalRJSClientFiles Include="$(MSBuildThisFileDirectory)..\..\client-ts\signalr\dist\browser\*" />
|
||||
<SignalRJSClientFiles Include="$(MSBuildThisFileDirectory)..\..\client-ts\signalr-protocol-msgpack\dist\browser\*" />
|
||||
</ItemGroup>
|
||||
<Copy SourceFiles="@(SignalRJSClientFiles)" DestinationFolder="$(MSBuildThisFileDirectory)wwwroot\lib\signalr-client" />
|
||||
</Target>
|
||||
|
|
|
|||
|
|
@ -62,18 +62,7 @@
|
|||
</body>
|
||||
|
||||
</html>
|
||||
<script type="text/javascript">
|
||||
if (typeof Promise === 'undefined') {
|
||||
document.write(
|
||||
'<script type="text/javascript" src="lib/signalr-client/signalr-clientES5.js"><\/script>' +
|
||||
'<script type="text/javascript" src="lib/signalr-client/signalr-msgpackprotocolES5.js"><\/script>');
|
||||
}
|
||||
else {
|
||||
document.write(
|
||||
'<script type="text/javascript" src="lib/signalr-client/signalr-client.js"><\/script>' +
|
||||
'<script type="text/javascript" src="lib/signalr-client/signalr-msgpackprotocol.js"><\/script>');
|
||||
}
|
||||
</script>
|
||||
<script src="lib/signalr-client/signalr.js"></script>
|
||||
<script src="utils.js"></script>
|
||||
<script>
|
||||
var isConnected = false;
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue