pusher-fake 1.6.0 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pusher-fake.rb +4 -1
- data/lib/pusher-fake/channel.rb +9 -3
- data/lib/pusher-fake/channel/presence.rb +11 -9
- data/lib/pusher-fake/channel/private.rb +8 -5
- data/lib/pusher-fake/channel/public.rb +13 -14
- data/lib/pusher-fake/configuration.rb +2 -1
- data/lib/pusher-fake/connection.rb +41 -29
- data/lib/pusher-fake/cucumber.rb +2 -1
- data/lib/pusher-fake/server.rb +46 -45
- data/lib/pusher-fake/server/application.rb +89 -50
- data/lib/pusher-fake/support/base.rb +4 -9
- data/lib/pusher-fake/webhook.rb +3 -1
- data/spec/features/api/channels_spec.rb +7 -5
- data/spec/features/api/users_spec.rb +1 -1
- data/spec/features/client/event_spec.rb +6 -4
- data/spec/features/client/subscribe_spec.rb +8 -6
- data/spec/features/server/event_spec.rb +7 -7
- data/spec/features/server/webhooks_spec.rb +16 -4
- data/spec/lib/pusher-fake/channel/presence_spec.rb +57 -49
- data/spec/lib/pusher-fake/channel/private_spec.rb +42 -31
- data/spec/lib/pusher-fake/channel/public_spec.rb +37 -27
- data/spec/lib/pusher-fake/channel_spec.rb +51 -91
- data/spec/lib/pusher-fake/configuration_spec.rb +11 -5
- data/spec/lib/pusher-fake/connection_spec.rb +65 -39
- data/spec/lib/pusher-fake/server/application_spec.rb +219 -94
- data/spec/lib/pusher-fake/server_spec.rb +31 -41
- data/spec/lib/pusher-fake/webhook_spec.rb +29 -18
- data/spec/lib/pusher_fake_spec.rb +17 -15
- data/spec/support/application.rb +21 -19
- data/spec/support/application/public/javascripts/vendor/{pusher-3.1.0.js → pusher-3.2.1.js} +69 -48
- data/spec/support/application/views/index.erb +1 -1
- data/spec/support/capybara.rb +1 -3
- data/spec/support/helpers/connect.rb +1 -3
- data/spec/support/matchers/have_configuration_option.rb +2 -2
- data/spec/support/{pusher-fake.rb → pusher_fake.rb} +2 -1
- data/spec/support/webhooks.rb +5 -3
- metadata +38 -10
@@ -1,7 +1,7 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe PusherFake::Server, ".start" do
|
4
|
-
subject {
|
4
|
+
subject { described_class }
|
5
5
|
|
6
6
|
before do
|
7
7
|
allow(subject).to receive(:start_web_server).and_return(nil)
|
@@ -18,7 +18,7 @@ describe PusherFake::Server, ".start" do
|
|
18
18
|
it "starts the socket web server when run yields" do
|
19
19
|
subject.start
|
20
20
|
|
21
|
-
expect(subject).
|
21
|
+
expect(subject).not_to have_received(:start_web_server)
|
22
22
|
|
23
23
|
allow(EventMachine).to receive(:run).and_yield
|
24
24
|
|
@@ -30,7 +30,7 @@ describe PusherFake::Server, ".start" do
|
|
30
30
|
it "starts the socket server when run yields" do
|
31
31
|
subject.start
|
32
32
|
|
33
|
-
expect(subject).
|
33
|
+
expect(subject).not_to have_received(:start_socket_server)
|
34
34
|
|
35
35
|
allow(EventMachine).to receive(:run).and_yield
|
36
36
|
|
@@ -41,13 +41,24 @@ describe PusherFake::Server, ".start" do
|
|
41
41
|
end
|
42
42
|
|
43
43
|
describe PusherFake::Server, ".start_socket_server" do
|
44
|
-
|
45
|
-
let(:socket) { double(:socket, onopen: nil, onmessage: nil, onclose: nil) }
|
46
|
-
let(:options) { configuration.socket_options }
|
47
|
-
let(:connection) { double(:connection, establish: nil, process: nil) }
|
48
|
-
let(:configuration) { double(:configuration, socket_options: { host: "192.168.0.1", port: 8080 }) }
|
44
|
+
subject { described_class }
|
49
45
|
|
50
|
-
|
46
|
+
let(:data) { double }
|
47
|
+
let(:options) { configuration.socket_options }
|
48
|
+
|
49
|
+
let(:configuration) do
|
50
|
+
instance_double(PusherFake::Configuration,
|
51
|
+
socket_options: { host: "192.168.0.1", port: 8080 })
|
52
|
+
end
|
53
|
+
|
54
|
+
let(:connection) do
|
55
|
+
instance_double(PusherFake::Connection, establish: nil, process: nil)
|
56
|
+
end
|
57
|
+
|
58
|
+
let(:socket) do
|
59
|
+
instance_double(EventMachine::WebSocket::Connection,
|
60
|
+
onopen: nil, onmessage: nil, onclose: nil)
|
61
|
+
end
|
51
62
|
|
52
63
|
before do
|
53
64
|
allow(PusherFake).to receive(:configuration).and_return(configuration)
|
@@ -69,10 +80,6 @@ describe PusherFake::Server, ".start_socket_server" do
|
|
69
80
|
end
|
70
81
|
|
71
82
|
it "creates a connection with the provided socket when onopen yields" do
|
72
|
-
subject.start_socket_server
|
73
|
-
|
74
|
-
expect(PusherFake::Connection).to_not have_received(:new)
|
75
|
-
|
76
83
|
allow(socket).to receive(:onopen).and_yield
|
77
84
|
|
78
85
|
subject.start_socket_server
|
@@ -81,10 +88,6 @@ describe PusherFake::Server, ".start_socket_server" do
|
|
81
88
|
end
|
82
89
|
|
83
90
|
it "establishes the connection when onopen yields" do
|
84
|
-
subject.start_socket_server
|
85
|
-
|
86
|
-
expect(connection).to_not have_received(:establish)
|
87
|
-
|
88
91
|
allow(socket).to receive(:onopen).and_yield
|
89
92
|
|
90
93
|
subject.start_socket_server
|
@@ -93,10 +96,6 @@ describe PusherFake::Server, ".start_socket_server" do
|
|
93
96
|
end
|
94
97
|
|
95
98
|
it "defines a message callback on the socket when onopen yields" do
|
96
|
-
subject.start_socket_server
|
97
|
-
|
98
|
-
expect(socket).to_not have_received(:onmessage)
|
99
|
-
|
100
99
|
allow(socket).to receive(:onopen).and_yield
|
101
100
|
|
102
101
|
subject.start_socket_server
|
@@ -106,11 +105,6 @@ describe PusherFake::Server, ".start_socket_server" do
|
|
106
105
|
|
107
106
|
it "triggers process on the connection when onmessage yields" do
|
108
107
|
allow(socket).to receive(:onopen).and_yield
|
109
|
-
|
110
|
-
subject.start_socket_server
|
111
|
-
|
112
|
-
expect(connection).to_not have_received(:process)
|
113
|
-
|
114
108
|
allow(socket).to receive(:onmessage).and_yield(data)
|
115
109
|
|
116
110
|
subject.start_socket_server
|
@@ -119,10 +113,6 @@ describe PusherFake::Server, ".start_socket_server" do
|
|
119
113
|
end
|
120
114
|
|
121
115
|
it "defines a close callback on the socket when onopen yields" do
|
122
|
-
subject.start_socket_server
|
123
|
-
|
124
|
-
expect(socket).to_not have_received(:onclose)
|
125
|
-
|
126
116
|
allow(socket).to receive(:onopen).and_yield
|
127
117
|
|
128
118
|
subject.start_socket_server
|
@@ -132,11 +122,6 @@ describe PusherFake::Server, ".start_socket_server" do
|
|
132
122
|
|
133
123
|
it "removes the connection from all channels when onclose yields" do
|
134
124
|
allow(socket).to receive(:onopen).and_yield
|
135
|
-
|
136
|
-
subject.start_socket_server
|
137
|
-
|
138
|
-
expect(PusherFake::Channel).to_not have_received(:remove)
|
139
|
-
|
140
125
|
allow(socket).to receive(:onclose).and_yield
|
141
126
|
|
142
127
|
subject.start_socket_server
|
@@ -146,12 +131,16 @@ describe PusherFake::Server, ".start_socket_server" do
|
|
146
131
|
end
|
147
132
|
|
148
133
|
describe PusherFake::Server, ".start_web_server" do
|
149
|
-
|
150
|
-
|
151
|
-
let(:
|
152
|
-
let(:
|
134
|
+
subject { described_class }
|
135
|
+
|
136
|
+
let(:host) { "192.168.0.1" }
|
137
|
+
let(:port) { 8081 }
|
138
|
+
let(:server) { instance_double(Thin::Server, :start! => true, :ssl= => true) }
|
153
139
|
|
154
|
-
|
140
|
+
let(:configuration) do
|
141
|
+
instance_double(PusherFake::Configuration,
|
142
|
+
web_options: { host: host, port: port, ssl: true })
|
143
|
+
end
|
155
144
|
|
156
145
|
before do
|
157
146
|
allow(Thin::Server).to receive(:new).and_return(server)
|
@@ -168,7 +157,8 @@ describe PusherFake::Server, ".start_web_server" do
|
|
168
157
|
it "creates the web server" do
|
169
158
|
subject.start_web_server
|
170
159
|
|
171
|
-
expect(Thin::Server).to have_received(:new)
|
160
|
+
expect(Thin::Server).to have_received(:new)
|
161
|
+
.with(host, port, PusherFake::Server::Application)
|
172
162
|
end
|
173
163
|
|
174
164
|
it "assigns custom options to the server" do
|
@@ -1,16 +1,33 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe PusherFake::Webhook, ".trigger" do
|
4
|
-
subject {
|
4
|
+
subject { described_class }
|
5
5
|
|
6
|
-
let(:data)
|
7
|
-
let(:http)
|
8
|
-
let(:name)
|
9
|
-
let(:digest)
|
10
|
-
let(:
|
11
|
-
let(:
|
12
|
-
|
13
|
-
let(:configuration)
|
6
|
+
let(:data) { { channel: "name" } }
|
7
|
+
let(:http) { instance_double(EventMachine::HttpConnection, post: true) }
|
8
|
+
let(:name) { "channel_occupied" }
|
9
|
+
let(:digest) { instance_double(OpenSSL::Digest::SHA256) }
|
10
|
+
let(:webhooks) { ["url"] }
|
11
|
+
let(:signature) { "signature" }
|
12
|
+
|
13
|
+
let(:configuration) do
|
14
|
+
instance_double(PusherFake::Configuration,
|
15
|
+
key: "key",
|
16
|
+
secret: "secret",
|
17
|
+
webhooks: webhooks)
|
18
|
+
end
|
19
|
+
|
20
|
+
let(:headers) do
|
21
|
+
{
|
22
|
+
"Content-Type" => "application/json",
|
23
|
+
"X-Pusher-Key" => configuration.key,
|
24
|
+
"X-Pusher-Signature" => signature
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
let(:payload) do
|
29
|
+
MultiJson.dump(events: [data.merge(name: name)], time_ms: Time.now.to_i)
|
30
|
+
end
|
14
31
|
|
15
32
|
before do
|
16
33
|
allow(OpenSSL::HMAC).to receive(:hexdigest).and_return(signature)
|
@@ -30,20 +47,14 @@ describe PusherFake::Webhook, ".trigger" do
|
|
30
47
|
it "creates a HTTP request for each webhook URL" do
|
31
48
|
subject.trigger(name, data)
|
32
49
|
|
33
|
-
expect(EventMachine::HttpRequest).to have_received(:new)
|
50
|
+
expect(EventMachine::HttpRequest).to have_received(:new)
|
51
|
+
.with(webhooks.first)
|
34
52
|
end
|
35
53
|
|
36
54
|
it "posts the payload to the webhook URL" do
|
37
55
|
subject.trigger(name, data)
|
38
56
|
|
39
|
-
expect(http).to have_received(:post).with(
|
40
|
-
body: payload,
|
41
|
-
head: {
|
42
|
-
"Content-Type" => "application/json",
|
43
|
-
"X-Pusher-Key" => configuration.key,
|
44
|
-
"X-Pusher-Signature" => signature
|
45
|
-
}
|
46
|
-
)
|
57
|
+
expect(http).to have_received(:post).with(body: payload, head: headers)
|
47
58
|
end
|
48
59
|
|
49
60
|
it "logs sending the hook" do
|
@@ -1,28 +1,28 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe PusherFake, ".configure" do
|
4
|
-
subject {
|
4
|
+
subject { described_class }
|
5
5
|
|
6
6
|
it "yields the configuration" do
|
7
|
-
expect
|
7
|
+
expect do |block|
|
8
8
|
subject.configure(&block)
|
9
|
-
|
9
|
+
end.to yield_with_args(subject.configuration)
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
13
|
describe PusherFake, ".configuration" do
|
14
|
-
|
14
|
+
subject { described_class }
|
15
15
|
|
16
|
-
|
16
|
+
let(:configuration) { double }
|
17
17
|
|
18
18
|
before do
|
19
|
-
|
19
|
+
described_class.instance_variable_set("@configuration", nil)
|
20
20
|
|
21
21
|
allow(PusherFake::Configuration).to receive(:new).and_return(configuration)
|
22
22
|
end
|
23
23
|
|
24
24
|
after do
|
25
|
-
|
25
|
+
described_class.instance_variable_set("@configuration", nil)
|
26
26
|
end
|
27
27
|
|
28
28
|
it "initializes a configuration object" do
|
@@ -43,33 +43,35 @@ describe PusherFake, ".configuration" do
|
|
43
43
|
end
|
44
44
|
|
45
45
|
describe PusherFake, ".javascript" do
|
46
|
-
|
46
|
+
subject { described_class }
|
47
47
|
|
48
|
-
|
48
|
+
let(:configuration) { subject.configuration }
|
49
49
|
|
50
50
|
it "returns JavaScript setting the host and port to the configured options" do
|
51
|
-
arguments = [configuration.key, configuration.to_options].map(&:to_json).join(",")
|
52
51
|
javascript = subject.javascript
|
52
|
+
arguments = [configuration.key, configuration.to_options]
|
53
|
+
.map(&:to_json).join(",")
|
53
54
|
|
54
55
|
expect(javascript).to eq("new Pusher(#{arguments})")
|
55
56
|
end
|
56
57
|
|
57
58
|
it "supports passing custom options" do
|
58
59
|
options = { custom: "option" }
|
59
|
-
arguments = [configuration.key, configuration.to_options(options)].map(&:to_json).join(",")
|
60
60
|
javascript = subject.javascript(options)
|
61
|
+
arguments = [configuration.key, configuration.to_options(options)]
|
62
|
+
.map(&:to_json).join(",")
|
61
63
|
|
62
64
|
expect(javascript).to eq("new Pusher(#{arguments})")
|
63
65
|
end
|
64
66
|
end
|
65
67
|
|
66
68
|
describe PusherFake, ".log" do
|
67
|
-
|
69
|
+
subject { described_class }
|
70
|
+
|
71
|
+
let(:logger) { instance_double(Logger, :<< => "") }
|
68
72
|
let(:message) { "Hello world." }
|
69
73
|
let(:configuration) { subject.configuration }
|
70
74
|
|
71
|
-
subject { PusherFake }
|
72
|
-
|
73
75
|
before do
|
74
76
|
configuration.logger = logger
|
75
77
|
end
|
@@ -87,6 +89,6 @@ describe PusherFake, ".log" do
|
|
87
89
|
|
88
90
|
subject.log(message)
|
89
91
|
|
90
|
-
expect(logger).
|
92
|
+
expect(logger).not_to have_received(:<<)
|
91
93
|
end
|
92
94
|
end
|
data/spec/support/application.rb
CHANGED
@@ -1,31 +1,33 @@
|
|
1
1
|
require "sinatra"
|
2
2
|
require "tilt/erb"
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
module Sinatra
|
5
|
+
class Application
|
6
|
+
set :root, proc { File.join(File.dirname(__FILE__), "application") }
|
7
|
+
set :views, proc { File.join(root, "views") }
|
8
8
|
|
9
|
-
|
9
|
+
disable :logging
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
get "/" do
|
12
|
+
erb :index
|
13
|
+
end
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
post "/pusher/auth" do
|
16
|
+
channel = Pusher[params[:channel_name]]
|
17
|
+
response = channel.authenticate(params[:socket_id], channel_data)
|
18
18
|
|
19
|
-
|
20
|
-
|
19
|
+
MultiJson.dump(response)
|
20
|
+
end
|
21
21
|
|
22
|
-
|
22
|
+
protected
|
23
23
|
|
24
|
-
|
25
|
-
|
24
|
+
def channel_data
|
25
|
+
return unless params[:channel_name] =~ /^presence-/
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
{
|
28
|
+
user_id: params[:socket_id],
|
29
|
+
user_info: { name: "Alan Turing" }
|
30
|
+
}
|
31
|
+
end
|
30
32
|
end
|
31
33
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/*!
|
2
|
-
* Pusher JavaScript Library v3.1
|
2
|
+
* Pusher JavaScript Library v3.2.1
|
3
3
|
* http://pusher.com/
|
4
4
|
*
|
5
5
|
* Copyright 2016, Pusher
|
@@ -154,9 +154,8 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
154
154
|
}
|
155
155
|
};
|
156
156
|
Pusher.log = function (message) {
|
157
|
-
|
158
|
-
|
159
|
-
global.console.log(message);
|
157
|
+
if (Pusher.logToConsole && (window).console && (window).console.log) {
|
158
|
+
(window).console.log(message);
|
160
159
|
}
|
161
160
|
};
|
162
161
|
Pusher.getClientFeatures = function () {
|
@@ -191,6 +190,10 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
191
190
|
this.global_emitter.bind(event_name, callback);
|
192
191
|
return this;
|
193
192
|
};
|
193
|
+
Pusher.prototype.unbind = function (event_name, callback) {
|
194
|
+
this.global_emitter.unbind(event_name, callback);
|
195
|
+
return this;
|
196
|
+
};
|
194
197
|
Pusher.prototype.bind_all = function (callback) {
|
195
198
|
this.global_emitter.bind_all(callback);
|
196
199
|
return this;
|
@@ -298,9 +301,6 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
298
301
|
getProtocol: function () {
|
299
302
|
return this.getDocument().location.protocol;
|
300
303
|
},
|
301
|
-
getGlobal: function () {
|
302
|
-
return window;
|
303
|
-
},
|
304
304
|
getAuthorizers: function () {
|
305
305
|
return { ajax: xhr_auth_1["default"], jsonp: jsonp_auth_1["default"] };
|
306
306
|
},
|
@@ -451,7 +451,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
451
451
|
|
452
452
|
"use strict";
|
453
453
|
var Defaults = {
|
454
|
-
VERSION: "3.1
|
454
|
+
VERSION: "3.2.1",
|
455
455
|
PROTOCOL: 7,
|
456
456
|
host: 'ws.pusherapp.com',
|
457
457
|
ws_port: 80,
|
@@ -601,13 +601,12 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
601
601
|
args[_i - 0] = arguments[_i];
|
602
602
|
}
|
603
603
|
var message = collections_1.stringify.apply(this, arguments);
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
global.console.warn(message);
|
604
|
+
if ((window).console) {
|
605
|
+
if ((window).console.warn) {
|
606
|
+
(window).console.warn(message);
|
608
607
|
}
|
609
|
-
else if (
|
610
|
-
|
608
|
+
else if ((window).console.log) {
|
609
|
+
(window).console.log(message);
|
611
610
|
}
|
612
611
|
}
|
613
612
|
if (pusher_1["default"].log) {
|
@@ -626,7 +625,6 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
626
625
|
"use strict";
|
627
626
|
var base64_1 = __webpack_require__(10);
|
628
627
|
var util_1 = __webpack_require__(11);
|
629
|
-
var global = Function("return this")();
|
630
628
|
function extend(target) {
|
631
629
|
var sources = [];
|
632
630
|
for (var _i = 1; _i < arguments.length; _i++) {
|
@@ -654,7 +652,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
654
652
|
m.push(arguments[i]);
|
655
653
|
}
|
656
654
|
else {
|
657
|
-
m.push(
|
655
|
+
m.push(safeJSONStringify(arguments[i]));
|
658
656
|
}
|
659
657
|
}
|
660
658
|
return m.join(" : ");
|
@@ -702,7 +700,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
702
700
|
exports.values = values;
|
703
701
|
function apply(array, f, context) {
|
704
702
|
for (var i = 0; i < array.length; i++) {
|
705
|
-
f.call(context ||
|
703
|
+
f.call(context || (window), array[i], i, array);
|
706
704
|
}
|
707
705
|
}
|
708
706
|
exports.apply = apply;
|
@@ -772,7 +770,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
772
770
|
function encodeParamsObject(data) {
|
773
771
|
return mapObject(data, function (value) {
|
774
772
|
if (typeof value === "object") {
|
775
|
-
value =
|
773
|
+
value = safeJSONStringify(value);
|
776
774
|
}
|
777
775
|
return encodeURIComponent(base64_1["default"](value.toString()));
|
778
776
|
});
|
@@ -786,29 +784,61 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
786
784
|
return query;
|
787
785
|
}
|
788
786
|
exports.buildQueryString = buildQueryString;
|
789
|
-
function
|
790
|
-
var
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
787
|
+
function decycleObject(object) {
|
788
|
+
var objects = [], paths = [];
|
789
|
+
return (function derez(value, path) {
|
790
|
+
var i, name, nu;
|
791
|
+
switch (typeof value) {
|
792
|
+
case 'object':
|
793
|
+
if (!value) {
|
794
|
+
return null;
|
795
|
+
}
|
796
|
+
for (i = 0; i < objects.length; i += 1) {
|
797
|
+
if (objects[i] === value) {
|
798
|
+
return { $ref: paths[i] };
|
799
|
+
}
|
800
|
+
}
|
801
|
+
objects.push(value);
|
802
|
+
paths.push(path);
|
803
|
+
if (Object.prototype.toString.apply(value) === '[object Array]') {
|
804
|
+
nu = [];
|
805
|
+
for (i = 0; i < value.length; i += 1) {
|
806
|
+
nu[i] = derez(value[i], path + '[' + i + ']');
|
807
|
+
}
|
808
|
+
}
|
809
|
+
else {
|
810
|
+
nu = {};
|
811
|
+
for (name in value) {
|
812
|
+
if (Object.prototype.hasOwnProperty.call(value, name)) {
|
813
|
+
nu[name] = derez(value[name], path + '[' + JSON.stringify(name) + ']');
|
814
|
+
}
|
815
|
+
}
|
816
|
+
}
|
817
|
+
return nu;
|
818
|
+
case 'number':
|
819
|
+
case 'string':
|
820
|
+
case 'boolean':
|
821
|
+
return value;
|
797
822
|
}
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
823
|
+
}(object, '$'));
|
824
|
+
}
|
825
|
+
exports.decycleObject = decycleObject;
|
826
|
+
function safeJSONStringify(source) {
|
827
|
+
try {
|
828
|
+
return JSON.stringify(source);
|
829
|
+
}
|
830
|
+
catch (e) {
|
831
|
+
return JSON.stringify(decycleObject(source));
|
832
|
+
}
|
802
833
|
}
|
803
834
|
exports.safeJSONStringify = safeJSONStringify;
|
804
835
|
|
805
836
|
|
806
837
|
/***/ },
|
807
838
|
/* 10 */
|
808
|
-
/***/ function(module, exports) {
|
839
|
+
/***/ function(module, exports, __webpack_require__) {
|
809
840
|
|
810
841
|
"use strict";
|
811
|
-
var global = Function("return this")();
|
812
842
|
function encode(s) {
|
813
843
|
return btoa(utob(s));
|
814
844
|
}
|
@@ -845,7 +875,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
845
875
|
];
|
846
876
|
return chars.join('');
|
847
877
|
};
|
848
|
-
var btoa =
|
878
|
+
var btoa = (window).btoa || function (b) {
|
849
879
|
return b.replace(/[\s\S]{1,3}/g, cb_encode);
|
850
880
|
};
|
851
881
|
|
@@ -857,9 +887,6 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
857
887
|
"use strict";
|
858
888
|
var timers_1 = __webpack_require__(12);
|
859
889
|
var Util = {
|
860
|
-
getGlobal: function () {
|
861
|
-
return Function("return this")();
|
862
|
-
},
|
863
890
|
now: function () {
|
864
891
|
if (Date.now) {
|
865
892
|
return Date.now();
|
@@ -897,12 +924,11 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
897
924
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
898
925
|
};
|
899
926
|
var abstract_timer_1 = __webpack_require__(13);
|
900
|
-
var global = Function("return this")();
|
901
927
|
function clearTimeout(timer) {
|
902
|
-
|
928
|
+
(window).clearTimeout(timer);
|
903
929
|
}
|
904
930
|
function clearInterval(timer) {
|
905
|
-
|
931
|
+
(window).clearInterval(timer);
|
906
932
|
}
|
907
933
|
var OneOffTimer = (function (_super) {
|
908
934
|
__extends(OneOffTimer, _super);
|
@@ -1458,7 +1484,6 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
1458
1484
|
|
1459
1485
|
"use strict";
|
1460
1486
|
var callback_registry_1 = __webpack_require__(24);
|
1461
|
-
var global = Function("return this")();
|
1462
1487
|
var Dispatcher = (function () {
|
1463
1488
|
function Dispatcher(failThrough) {
|
1464
1489
|
this.callbacks = new callback_registry_1["default"]();
|
@@ -1489,7 +1514,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
1489
1514
|
var callbacks = this.callbacks.get(eventName);
|
1490
1515
|
if (callbacks && callbacks.length > 0) {
|
1491
1516
|
for (i = 0; i < callbacks.length; i++) {
|
1492
|
-
callbacks[i].fn.call(callbacks[i].context ||
|
1517
|
+
callbacks[i].fn.call(callbacks[i].context || (window), data);
|
1493
1518
|
}
|
1494
1519
|
}
|
1495
1520
|
else if (this.failThrough) {
|
@@ -3586,12 +3611,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
3586
3611
|
var onClosed = function () {
|
3587
3612
|
unbindListeners();
|
3588
3613
|
var serializedTransport;
|
3589
|
-
|
3590
|
-
serializedTransport = JSON.stringify(transport);
|
3591
|
-
}
|
3592
|
-
catch (e) {
|
3593
|
-
serializedTransport = Collections.safeJSONStringify(transport);
|
3594
|
-
}
|
3614
|
+
serializedTransport = Collections.safeJSONStringify(transport);
|
3595
3615
|
callback(new Errors.TransportClosed(serializedTransport));
|
3596
3616
|
};
|
3597
3617
|
var unbindListeners = function () {
|
@@ -3816,6 +3836,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
3816
3836
|
var util_1 = __webpack_require__(11);
|
3817
3837
|
var runtime_1 = __webpack_require__(2);
|
3818
3838
|
var sequential_strategy_1 = __webpack_require__(56);
|
3839
|
+
var Collections = __webpack_require__(9);
|
3819
3840
|
var CachedStrategy = (function () {
|
3820
3841
|
function CachedStrategy(strategy, transports, options) {
|
3821
3842
|
this.strategy = strategy;
|
@@ -3900,7 +3921,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
3900
3921
|
var storage = runtime_1["default"].getLocalStorage();
|
3901
3922
|
if (storage) {
|
3902
3923
|
try {
|
3903
|
-
storage[getTransportCacheKey(encrypted)] =
|
3924
|
+
storage[getTransportCacheKey(encrypted)] = Collections.safeJSONStringify({
|
3904
3925
|
timestamp: util_1["default"].now(),
|
3905
3926
|
transport: transport,
|
3906
3927
|
latency: latency
|