Permalink
Browse files

Building jquery.signalR.js from source files:

 - Runs JSHint on each source JS file and fails build if errors found
 - Combines all source JS files into jquery.signalR.js
 - Minifies jquery.signalR.js to jquery.signalR.min.js
 - Sample projects updated to depend on SignalR.Clients.JS project
  • Loading branch information...
1 parent f287274 commit 3a8d61802ae4b5fd95f7c61aae192514957c34cd @DamianEdwards DamianEdwards committed Jul 3, 2012
Showing with 6,238 additions and 18,257 deletions.
  1. +7 −1 SignalR.Client.JS/SignalR.Client.JS.csproj
  2. +40 −0 SignalR.Client.JS/build.ps1
  3. +14 −1 SignalR.Client.JS/jquery.signalR.core.js
  4. +6 −2 SignalR.Client.JS/jquery.signalR.transports.common.js
  5. +4 −1 SignalR.Client.JS/jquery.signalR.transports.foreverFrame.js
  6. +10 −6 SignalR.Client.JS/jquery.signalR.transports.longPolling.js
  7. +4 −1 SignalR.Client.JS/jquery.signalR.transports.serverSentEvents.js
  8. +4 −2 SignalR.Client.JS/jquery.signalR.transports.webSockets.js
  9. +1 −0 SignalR.sln
  10. +0 −6,987 SignalR/Scripts/jquery-1.6.2-vsdoc.js
  11. +0 −8,981 SignalR/Scripts/jquery-1.6.2.js
  12. +0 −1,208 SignalR/Scripts/jquery.signalR.js
  13. +0 −9 SignalR/Scripts/jquery.signalR.min.js
  14. +0 −5 SignalR/SignalR.csproj
  15. +15 −0 SignalR45.sln
  16. +1 −5 samples/SignalR.Hosting.AspNet.Samples/Scripts/hubs.js
  17. +591 −513 samples/SignalR.Hosting.AspNet.Samples/Scripts/jquery.signalR.js
  18. +8 −8 samples/SignalR.Hosting.AspNet.Samples/Scripts/jquery.signalR.min.js
  19. +2 −2 samples/SignalR.Hosting.AspNet.Samples/SignalR.Hosting.AspNet.Samples.csproj
  20. +591 −513 samples/SignalR.Hosting.AspNet45.Samples/Scripts/jquery.signalR.js
  21. +8 −8 samples/SignalR.Hosting.AspNet45.Samples/Scripts/jquery.signalR.min.js
  22. +2 −2 samples/SignalR.Hosting.AspNet45.Samples/SignalR.Hosting.AspNet.Samples.csproj
  23. +2 −2 samples/SignalR.Hosting.Owin.Samples/SignalR.Hosting.Owin.Samples.csproj
  24. +57 −0 tools/jshint/env/jsc.js
  25. +29 −0 tools/jshint/env/jsc.sh
  26. +79 −0 tools/jshint/env/rhino.js
  27. +240 −0 tools/jshint/env/wsh.js
  28. +4,523 −0 tools/jshint/jshint.js
@@ -66,6 +66,7 @@
<Content Include="jquery.signalR.transports.foreverFrame.js" />
<Content Include="packages.config" />
<Content Include="jquery.signalR.transports.longPolling.js" />
+ <Content Include="build.ps1" />
<None Include="Scripts\jquery-1.6.2-vsdoc.js" />
<Content Include="Scripts\jquery-1.6.2.js" />
<Content Include="Scripts\jquery-1.6.2.min.js">
@@ -106,7 +107,12 @@
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
+ -->
<Target Name="AfterBuild">
+ <!--<Exec Command="&quot;$(SolutionDir)tools\AjaxMin\AjaxMin.exe&quot; &quot;$(ProjectDir)Scripts\jquery.signalR.js&quot; -out &quot;$(ProjectDir)Scripts\jquery.signalR.min.js&quot; -clobber" LogStandardErrorAsError="true" Condition=" '$(OS)' == 'Windows_NT' " />-->
</Target>
- -->
+ <PropertyGroup>
+ <PostBuildEvent>cd $(ProjectDir)
+powershell $(ProjectDir)build.ps1</PostBuildEvent>
+ </PropertyGroup>
</Project>
@@ -0,0 +1,40 @@
+# Files in the order they must be combined
+$files =
+ "jquery.signalR.core.js",
+ "jquery.signalR.transports.common.js",
+ "jquery.signalR.transports.webSockets.js",
+ "jquery.signalR.transports.serverSentEvents.js",
+ "jquery.signalR.transports.foreverFrame.js",
+ "jquery.signalR.transports.longPolling.js"
+
+# Run JSHint against files
+Write-Host "Running JSHint..." -ForegroundColor Yellow
+foreach ($file in $files) {
+ Write-Host "$file... " -NoNewline
+ $output = "build-output.txt"
+ & "cscript.exe" ..\tools\jshint\env\wsh.js "$file" > $output
+ if (Select-String $output -SimpleMatch -Pattern "[$file]" -Quiet) {
+ Write-Host
+ (Get-Content $output) | Select -Skip 4 | Write-Host -ForegroundColor Red
+ Remove-Item $output
+ exit 1
+ }
+ Write-Host "no issues found" -ForegroundColor Green
+}
+
+# Combine all files into jquery.signalR.js
+Write-Host "Building bin\jquery.signalR.js... " -NoNewline -ForegroundColor Yellow
+$filePath = "bin\jquery.signalR.js"
+Remove-Item $filePath -Force
+foreach ($file in $files) {
+ Add-Content -Path $filePath -Value "/* $file */"
+ Get-Content -Path $file | Add-Content -Path $filePath
+}
+Write-Host "done" -ForegroundColor Green
+
+# Minify to jquery.signalR.min.js
+Write-Host "Building bin\jquery.signalR.min.js... " -NoNewline -ForegroundColor Yellow
+& "..\tools\AjaxMin\AjaxMin.exe" bin\jquery.signalR.js -out bin\jquery.signalR.min.js -clobber > $output
+(Get-Content $output)[6] | Write-Host -ForegroundColor Green
+
+Remove-Item $output -Force
@@ -1,4 +1,5 @@
-/*!
+/*global window:false */
+/*!
* SignalR JavaScript Library v0.5.2
* http://signalr.net/
*
@@ -96,6 +97,12 @@
return new signalR.fn.init(url, qs, logging);
};
+
+ signalR.events = events;
+
+ signalR.changeState = changeState;
+
+ signalR.isDisconnecting = isDisconnecting;
signalR.connectionState = {
connecting: 0,
@@ -223,6 +230,12 @@
var transportName = transports[index],
transport = $.type(transportName) === "object" ? transportName : signalR.transports[transportName];
+ if (transportName.indexOf("_") === 0) {
+ // Private member
+ initialize(transports, index + 1);
+ return;
+ }
+
transport.start(connection, function () { // success
connection.transport = transport;
@@ -1,9 +1,13 @@
-/// <reference path="jquery.signalR.core.js" />
+/*global window:false */
+/// <reference path="jquery.signalR.core.js" />
(function ($, window) {
"use strict";
- var signalR = $.signalR;
+ var signalR = $.signalR,
+ events = $.signalR.events;
+
+ signalR.transports = {};
signalR.transports._logic = {
addQs: function (url, connection) {
@@ -1,9 +1,12 @@
-/// <reference path="jquery.signalR.transports.common.js" />
+/*global window:false */
+/// <reference path="jquery.signalR.transports.common.js" />
(function ($, window) {
"use strict";
var signalR = $.signalR,
+ events = $.signalR.events,
+ changeState = $.signalR.changeState,
transportLogic = signalR.transports._logic;
signalR.transports.foreverFrame = {
@@ -1,9 +1,13 @@
-/// <reference path="jquery.signalR.transports.common.js" />
+/*global window:false */
+/// <reference path="jquery.signalR.transports.common.js" />
(function ($, window) {
"use strict";
var signalR = $.signalR,
+ events = $.signalR.events,
+ changeState = $.signalR.changeState,
+ isDisconnecting = $.signalR.isDisconnecting,
transportLogic = signalR.transports._logic;
signalR.transports.longPolling = {
@@ -16,14 +20,14 @@
/// <param name="connection" type="signalR">The SignalR connection to start</param>
var that = this,
initialConnectFired = false;
-
+
if (connection.pollXhr) {
connection.log("Polling xhr requests already exists, aborting.");
connection.stop();
}
-
+
connection.messageId = null;
-
+
window.setTimeout(function () {
(function poll(instance, raiseReconnect) {
$(instance).trigger(events.onSending);
@@ -55,7 +59,7 @@
var delay = 0,
timedOutReceived = false;
- if (initialConnectFired == false) {
+ if (initialConnectFired === false) {
onSuccess();
initialConnectFired = true;
}
@@ -114,7 +118,7 @@
if (reconnectTimeOut) {
// If the request failed then we clear the timeout so that the
// reconnect event doesn't get fired
- clearTimeout(reconnectTimeOut);
+ window.clearTimeout(reconnectTimeOut);
}
$(instance).trigger(events.onError, [data.responseText]);
@@ -1,9 +1,12 @@
-/// <reference path="jquery.signalR.transports.common.js" />
+/*global window:false */
+/// <reference path="jquery.signalR.transports.common.js" />
(function ($, window) {
"use strict";
var signalR = $.signalR,
+ events = $.signalR.events,
+ changeState = $.signalR.changeState,
transportLogic = signalR.transports._logic;
signalR.transports.serverSentEvents = {
@@ -1,9 +1,12 @@
-/// <reference path="jquery.signalR.transports.common.js" />
+/*global window:false */
+/// <reference path="jquery.signalR.transports.common.js" />
(function ($, window) {
"use strict";
var signalR = $.signalR,
+ events = $.signalR.events,
+ changeState = $.signalR.changeState,
transportLogic = signalR.transports._logic;
signalR.transports.webSockets = {
@@ -18,7 +21,6 @@
opened = false,
that = this,
reconnecting = !onSuccess,
- protocol,
$connection = $(connection);
if (window.MozWebSocket) {
View
@@ -35,6 +35,7 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SignalR.Hosting.AspNet.Samples", "samples\SignalR.Hosting.AspNet.Samples\SignalR.Hosting.AspNet.Samples.csproj", "{1EA34A62-E03E-45CF-A9C9-82D2DA0FCD82}"
ProjectSection(ProjectDependencies) = postProject
{12609D9C-B4C9-4553-B364-D2C297F85CE7} = {12609D9C-B4C9-4553-B364-D2C297F85CE7}
+ {69771AF9-1BEE-48E6-98BC-78864231E239} = {69771AF9-1BEE-48E6-98BC-78864231E239}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SignalR.Hosting.Owin.Samples", "samples\SignalR.Hosting.Owin.Samples\SignalR.Hosting.Owin.Samples.csproj", "{8BF43A5B-4C96-4490-A9AF-5A057AC37C24}"
Oops, something went wrong.

0 comments on commit 3a8d618

Please sign in to comment.