pusher-fake 1.12.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/pusher-fake +1 -3
- data/lib/pusher-fake.rb +3 -1
- data/lib/pusher-fake/channel.rb +4 -2
- data/lib/pusher-fake/channel/presence.rb +3 -3
- data/lib/pusher-fake/channel/private.rb +3 -1
- data/lib/pusher-fake/channel/public.rb +2 -0
- data/lib/pusher-fake/configuration.rb +4 -1
- data/lib/pusher-fake/connection.rb +10 -7
- data/lib/pusher-fake/server.rb +2 -0
- data/lib/pusher-fake/server/application.rb +4 -2
- data/lib/pusher-fake/support/base.rb +4 -2
- data/lib/pusher-fake/support/cucumber.rb +2 -0
- data/lib/pusher-fake/support/rspec.rb +2 -0
- data/lib/pusher-fake/webhook.rb +3 -1
- data/spec/features/api/channels_spec.rb +2 -0
- data/spec/features/api/users_spec.rb +2 -0
- data/spec/features/client/connect_spec.rb +2 -0
- data/spec/features/client/event_spec.rb +2 -0
- data/spec/features/client/presence_spec.rb +2 -0
- data/spec/features/client/subscribe_spec.rb +9 -5
- data/spec/features/server/event_spec.rb +2 -0
- data/spec/features/server/webhooks_spec.rb +2 -0
- data/spec/lib/pusher-fake/channel/presence_spec.rb +2 -0
- data/spec/lib/pusher-fake/channel/private_spec.rb +4 -2
- data/spec/lib/pusher-fake/channel/public_spec.rb +2 -0
- data/spec/lib/pusher-fake/channel_spec.rb +2 -0
- data/spec/lib/pusher-fake/configuration_spec.rb +9 -1
- data/spec/lib/pusher-fake/connection_spec.rb +4 -2
- data/spec/lib/pusher-fake/server/application_spec.rb +4 -2
- data/spec/lib/pusher-fake/server_spec.rb +2 -0
- data/spec/lib/pusher-fake/webhook_spec.rb +3 -1
- data/spec/lib/pusher_fake_spec.rb +2 -0
- data/spec/spec_helper.rb +3 -1
- data/spec/support/application.rb +3 -1
- data/spec/support/application/public/javascripts/vendor/polyfill.min.js +1 -0
- data/spec/support/application/public/javascripts/vendor/pusher-7.0.0.js +4565 -0
- data/spec/support/application/views/index.erb +2 -1
- data/spec/support/capybara.rb +4 -7
- data/spec/support/coveralls.rb +2 -0
- data/spec/support/helpers/connect.rb +2 -0
- data/spec/support/helpers/event.rb +2 -0
- data/spec/support/helpers/subscription.rb +2 -0
- data/spec/support/helpers/user.rb +2 -0
- data/spec/support/matchers/have_configuration_option.rb +2 -0
- data/spec/support/pusher_fake.rb +3 -1
- data/spec/support/webhooks.rb +17 -15
- metadata +104 -47
- data/lib/pusher-fake/cucumber.rb +0 -4
- data/spec/support/application/public/javascripts/vendor/pusher-4.2.2.js +0 -4183
@@ -13,7 +13,8 @@
|
|
13
13
|
<ul></ul>
|
14
14
|
</section>
|
15
15
|
|
16
|
-
<script src="/javascripts/vendor/
|
16
|
+
<script src="/javascripts/vendor/polyfill.min.js"></script>
|
17
|
+
<script src="/javascripts/vendor/pusher-7.0.0.js"></script>
|
17
18
|
<script>
|
18
19
|
Pusher.instance = <%= PusherFake.javascript %>;
|
19
20
|
Pusher.instance.connection.bind("state_change", function(states) {
|
data/spec/support/capybara.rb
CHANGED
@@ -1,10 +1,7 @@
|
|
1
|
-
|
2
|
-
require "capybara/rspec"
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
|
-
|
5
|
-
Capybara::Poltergeist::Driver.new(app, url_whitelist: [])
|
6
|
-
end
|
3
|
+
require "capybara/rspec"
|
7
4
|
|
8
5
|
Capybara.app = Sinatra::Application
|
9
|
-
Capybara.server = :
|
10
|
-
Capybara.default_driver = :
|
6
|
+
Capybara.server = :puma, { Silent: true }
|
7
|
+
Capybara.default_driver = :selenium_chrome_headless
|
data/spec/support/coveralls.rb
CHANGED
data/spec/support/pusher_fake.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "thin/server"
|
2
4
|
|
3
5
|
RSpec.configure do |config|
|
@@ -5,7 +7,7 @@ RSpec.configure do |config|
|
|
5
7
|
PusherFake.configuration.reset!
|
6
8
|
PusherFake.configuration.web_options.tap do |options|
|
7
9
|
Pusher.url = "http://PUSHER_API_KEY:PUSHER_API_SECRET@" \
|
8
|
-
|
10
|
+
"#{options[:host]}:#{options[:port]}/apps/PUSHER_APP_ID"
|
9
11
|
end
|
10
12
|
|
11
13
|
@thread = Thread.new { PusherFake::Server.start }
|
data/spec/support/webhooks.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class WebhookHelper
|
2
4
|
def self.events
|
3
5
|
@events ||= []
|
@@ -8,27 +10,27 @@ class WebhookHelper
|
|
8
10
|
end
|
9
11
|
end
|
10
12
|
|
13
|
+
class WebhookEndpoint
|
14
|
+
def self.call(environment)
|
15
|
+
request = Rack::Request.new(environment)
|
16
|
+
webhook = Pusher::WebHook.new(request)
|
17
|
+
|
18
|
+
if webhook.valid?
|
19
|
+
WebhookHelper.mutex.synchronize do
|
20
|
+
WebhookHelper.events.concat(webhook.events)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
Rack::Response.new.finish
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
11
28
|
thread = Thread.new do
|
12
29
|
# Not explicitly requiring Thin::Server occasionally results in
|
13
30
|
# Thin::Server.start not being defined.
|
14
31
|
require "thin"
|
15
32
|
require "thin/server"
|
16
33
|
|
17
|
-
class WebhookEndpoint
|
18
|
-
def self.call(environment)
|
19
|
-
request = Rack::Request.new(environment)
|
20
|
-
webhook = Pusher::WebHook.new(request)
|
21
|
-
|
22
|
-
if webhook.valid?
|
23
|
-
WebhookHelper.mutex.synchronize do
|
24
|
-
WebhookHelper.events.concat(webhook.events)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
Rack::Response.new.finish
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
34
|
EventMachine.run do
|
33
35
|
Thin::Logging.silent = true
|
34
36
|
Thin::Server.start("0.0.0.0", 8082, WebhookEndpoint)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pusher-fake
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tristan Dunn
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: em-http-request
|
@@ -67,117 +67,173 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '1.5'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: capybara
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - '='
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 3.35.3
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - '='
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 3.35.3
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: puma
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 5.4.0
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 5.4.0
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: pusher
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
86
100
|
requirements:
|
87
101
|
- - '='
|
88
102
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
103
|
+
version: 2.0.1
|
90
104
|
type: :development
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
108
|
- - '='
|
95
109
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
110
|
+
version: 2.0.1
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: rake
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
100
114
|
requirements:
|
101
115
|
- - '='
|
102
116
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
117
|
+
version: 13.0.6
|
104
118
|
type: :development
|
105
119
|
prerelease: false
|
106
120
|
version_requirements: !ruby/object:Gem::Requirement
|
107
121
|
requirements:
|
108
122
|
- - '='
|
109
123
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
124
|
+
version: 13.0.6
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
126
|
name: rspec
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
114
128
|
requirements:
|
115
129
|
- - '='
|
116
130
|
- !ruby/object:Gem::Version
|
117
|
-
version: 3.
|
131
|
+
version: 3.10.0
|
118
132
|
type: :development
|
119
133
|
prerelease: false
|
120
134
|
version_requirements: !ruby/object:Gem::Requirement
|
121
135
|
requirements:
|
122
136
|
- - '='
|
123
137
|
- !ruby/object:Gem::Version
|
124
|
-
version: 3.
|
138
|
+
version: 3.10.0
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
140
|
name: rubocop
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
128
142
|
requirements:
|
129
143
|
- - '='
|
130
144
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
145
|
+
version: 1.18.4
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - '='
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 1.18.4
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: rubocop-performance
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - '='
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: 1.11.4
|
132
160
|
type: :development
|
133
161
|
prerelease: false
|
134
162
|
version_requirements: !ruby/object:Gem::Requirement
|
135
163
|
requirements:
|
136
164
|
- - '='
|
137
165
|
- !ruby/object:Gem::Version
|
138
|
-
version:
|
166
|
+
version: 1.11.4
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: rubocop-rake
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - '='
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: 0.6.0
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - '='
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: 0.6.0
|
139
181
|
- !ruby/object:Gem::Dependency
|
140
182
|
name: rubocop-rspec
|
141
183
|
requirement: !ruby/object:Gem::Requirement
|
142
184
|
requirements:
|
143
185
|
- - '='
|
144
186
|
- !ruby/object:Gem::Version
|
145
|
-
version:
|
187
|
+
version: 2.4.0
|
146
188
|
type: :development
|
147
189
|
prerelease: false
|
148
190
|
version_requirements: !ruby/object:Gem::Requirement
|
149
191
|
requirements:
|
150
192
|
- - '='
|
151
193
|
- !ruby/object:Gem::Version
|
152
|
-
version:
|
194
|
+
version: 2.4.0
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: selenium-webdriver
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - '='
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: 3.142.7
|
202
|
+
type: :development
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - '='
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: 3.142.7
|
153
209
|
- !ruby/object:Gem::Dependency
|
154
210
|
name: sinatra
|
155
211
|
requirement: !ruby/object:Gem::Requirement
|
156
212
|
requirements:
|
157
213
|
- - '='
|
158
214
|
- !ruby/object:Gem::Version
|
159
|
-
version: 2.0
|
215
|
+
version: 2.1.0
|
160
216
|
type: :development
|
161
217
|
prerelease: false
|
162
218
|
version_requirements: !ruby/object:Gem::Requirement
|
163
219
|
requirements:
|
164
220
|
- - '='
|
165
221
|
- !ruby/object:Gem::Version
|
166
|
-
version: 2.0
|
222
|
+
version: 2.1.0
|
167
223
|
- !ruby/object:Gem::Dependency
|
168
224
|
name: yard
|
169
225
|
requirement: !ruby/object:Gem::Requirement
|
170
226
|
requirements:
|
171
227
|
- - '='
|
172
228
|
- !ruby/object:Gem::Version
|
173
|
-
version: 0.9.
|
229
|
+
version: 0.9.26
|
174
230
|
type: :development
|
175
231
|
prerelease: false
|
176
232
|
version_requirements: !ruby/object:Gem::Requirement
|
177
233
|
requirements:
|
178
234
|
- - '='
|
179
235
|
- !ruby/object:Gem::Version
|
180
|
-
version: 0.9.
|
236
|
+
version: 0.9.26
|
181
237
|
description: A fake Pusher server for development and testing.
|
182
238
|
email: hello@tristandunn.com
|
183
239
|
executables:
|
@@ -193,7 +249,6 @@ files:
|
|
193
249
|
- lib/pusher-fake/channel/public.rb
|
194
250
|
- lib/pusher-fake/configuration.rb
|
195
251
|
- lib/pusher-fake/connection.rb
|
196
|
-
- lib/pusher-fake/cucumber.rb
|
197
252
|
- lib/pusher-fake/server.rb
|
198
253
|
- lib/pusher-fake/server/application.rb
|
199
254
|
- lib/pusher-fake/support/base.rb
|
@@ -220,7 +275,8 @@ files:
|
|
220
275
|
- spec/lib/pusher_fake_spec.rb
|
221
276
|
- spec/spec_helper.rb
|
222
277
|
- spec/support/application.rb
|
223
|
-
- spec/support/application/public/javascripts/vendor/
|
278
|
+
- spec/support/application/public/javascripts/vendor/polyfill.min.js
|
279
|
+
- spec/support/application/public/javascripts/vendor/pusher-7.0.0.js
|
224
280
|
- spec/support/application/views/index.erb
|
225
281
|
- spec/support/capybara.rb
|
226
282
|
- spec/support/coveralls.rb
|
@@ -235,7 +291,7 @@ homepage: https://github.com/tristandunn/pusher-fake
|
|
235
291
|
licenses:
|
236
292
|
- MIT
|
237
293
|
metadata: {}
|
238
|
-
post_install_message:
|
294
|
+
post_install_message:
|
239
295
|
rdoc_options: []
|
240
296
|
require_paths:
|
241
297
|
- lib
|
@@ -243,46 +299,47 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
243
299
|
requirements:
|
244
300
|
- - ">="
|
245
301
|
- !ruby/object:Gem::Version
|
246
|
-
version: '
|
302
|
+
version: '2.6'
|
247
303
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
248
304
|
requirements:
|
249
305
|
- - ">="
|
250
306
|
- !ruby/object:Gem::Version
|
251
307
|
version: '0'
|
252
308
|
requirements: []
|
253
|
-
rubygems_version: 3.
|
254
|
-
signing_key:
|
309
|
+
rubygems_version: 3.2.22
|
310
|
+
signing_key:
|
255
311
|
specification_version: 4
|
256
312
|
summary: A fake Pusher server for development and testing.
|
257
313
|
test_files:
|
258
|
-
- spec/spec_helper.rb
|
259
|
-
- spec/features/server/event_spec.rb
|
260
|
-
- spec/features/server/webhooks_spec.rb
|
261
314
|
- spec/features/api/channels_spec.rb
|
262
315
|
- spec/features/api/users_spec.rb
|
263
316
|
- spec/features/client/connect_spec.rb
|
264
|
-
- spec/features/client/presence_spec.rb
|
265
317
|
- spec/features/client/event_spec.rb
|
318
|
+
- spec/features/client/presence_spec.rb
|
266
319
|
- spec/features/client/subscribe_spec.rb
|
267
|
-
- spec/
|
268
|
-
- spec/
|
269
|
-
- spec/
|
270
|
-
- spec/
|
271
|
-
- spec/
|
272
|
-
- spec/
|
320
|
+
- spec/features/server/event_spec.rb
|
321
|
+
- spec/features/server/webhooks_spec.rb
|
322
|
+
- spec/lib/pusher-fake/channel/presence_spec.rb
|
323
|
+
- spec/lib/pusher-fake/channel/private_spec.rb
|
324
|
+
- spec/lib/pusher-fake/channel/public_spec.rb
|
325
|
+
- spec/lib/pusher-fake/channel_spec.rb
|
326
|
+
- spec/lib/pusher-fake/configuration_spec.rb
|
327
|
+
- spec/lib/pusher-fake/connection_spec.rb
|
328
|
+
- spec/lib/pusher-fake/server/application_spec.rb
|
329
|
+
- spec/lib/pusher-fake/server_spec.rb
|
330
|
+
- spec/lib/pusher-fake/webhook_spec.rb
|
331
|
+
- spec/lib/pusher_fake_spec.rb
|
332
|
+
- spec/spec_helper.rb
|
333
|
+
- spec/support/application/public/javascripts/vendor/polyfill.min.js
|
334
|
+
- spec/support/application/public/javascripts/vendor/pusher-7.0.0.js
|
273
335
|
- spec/support/application/views/index.erb
|
336
|
+
- spec/support/application.rb
|
337
|
+
- spec/support/capybara.rb
|
274
338
|
- spec/support/coveralls.rb
|
275
339
|
- spec/support/helpers/connect.rb
|
276
|
-
- spec/support/helpers/subscription.rb
|
277
340
|
- spec/support/helpers/event.rb
|
341
|
+
- spec/support/helpers/subscription.rb
|
278
342
|
- spec/support/helpers/user.rb
|
279
|
-
- spec/
|
280
|
-
- spec/
|
281
|
-
- spec/
|
282
|
-
- spec/lib/pusher-fake/configuration_spec.rb
|
283
|
-
- spec/lib/pusher-fake/server/application_spec.rb
|
284
|
-
- spec/lib/pusher-fake/channel/presence_spec.rb
|
285
|
-
- spec/lib/pusher-fake/channel/public_spec.rb
|
286
|
-
- spec/lib/pusher-fake/channel/private_spec.rb
|
287
|
-
- spec/lib/pusher-fake/connection_spec.rb
|
288
|
-
- spec/lib/pusher-fake/channel_spec.rb
|
343
|
+
- spec/support/matchers/have_configuration_option.rb
|
344
|
+
- spec/support/pusher_fake.rb
|
345
|
+
- spec/support/webhooks.rb
|
data/lib/pusher-fake/cucumber.rb
DELETED
@@ -1,4183 +0,0 @@
|
|
1
|
-
/*!
|
2
|
-
* Pusher JavaScript Library v4.2.2
|
3
|
-
* https://pusher.com/
|
4
|
-
*
|
5
|
-
* Copyright 2017, Pusher
|
6
|
-
* Released under the MIT licence.
|
7
|
-
*/
|
8
|
-
|
9
|
-
(function webpackUniversalModuleDefinition(root, factory) {
|
10
|
-
if(typeof exports === 'object' && typeof module === 'object')
|
11
|
-
module.exports = factory();
|
12
|
-
else if(typeof define === 'function' && define.amd)
|
13
|
-
define([], factory);
|
14
|
-
else if(typeof exports === 'object')
|
15
|
-
exports["Pusher"] = factory();
|
16
|
-
else
|
17
|
-
root["Pusher"] = factory();
|
18
|
-
})(this, function() {
|
19
|
-
return /******/ (function(modules) { // webpackBootstrap
|
20
|
-
/******/ // The module cache
|
21
|
-
/******/ var installedModules = {};
|
22
|
-
|
23
|
-
/******/ // The require function
|
24
|
-
/******/ function __webpack_require__(moduleId) {
|
25
|
-
|
26
|
-
/******/ // Check if module is in cache
|
27
|
-
/******/ if(installedModules[moduleId])
|
28
|
-
/******/ return installedModules[moduleId].exports;
|
29
|
-
|
30
|
-
/******/ // Create a new module (and put it into the cache)
|
31
|
-
/******/ var module = installedModules[moduleId] = {
|
32
|
-
/******/ exports: {},
|
33
|
-
/******/ id: moduleId,
|
34
|
-
/******/ loaded: false
|
35
|
-
/******/ };
|
36
|
-
|
37
|
-
/******/ // Execute the module function
|
38
|
-
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
39
|
-
|
40
|
-
/******/ // Flag the module as loaded
|
41
|
-
/******/ module.loaded = true;
|
42
|
-
|
43
|
-
/******/ // Return the exports of the module
|
44
|
-
/******/ return module.exports;
|
45
|
-
/******/ }
|
46
|
-
|
47
|
-
|
48
|
-
/******/ // expose the modules object (__webpack_modules__)
|
49
|
-
/******/ __webpack_require__.m = modules;
|
50
|
-
|
51
|
-
/******/ // expose the module cache
|
52
|
-
/******/ __webpack_require__.c = installedModules;
|
53
|
-
|
54
|
-
/******/ // __webpack_public_path__
|
55
|
-
/******/ __webpack_require__.p = "";
|
56
|
-
|
57
|
-
/******/ // Load entry module and return exports
|
58
|
-
/******/ return __webpack_require__(0);
|
59
|
-
/******/ })
|
60
|
-
/************************************************************************/
|
61
|
-
/******/ ([
|
62
|
-
/* 0 */
|
63
|
-
/***/ (function(module, exports, __webpack_require__) {
|
64
|
-
|
65
|
-
"use strict";
|
66
|
-
var pusher_1 = __webpack_require__(1);
|
67
|
-
module.exports = pusher_1["default"];
|
68
|
-
|
69
|
-
|
70
|
-
/***/ }),
|
71
|
-
/* 1 */
|
72
|
-
/***/ (function(module, exports, __webpack_require__) {
|
73
|
-
|
74
|
-
"use strict";
|
75
|
-
var runtime_1 = __webpack_require__(2);
|
76
|
-
var Collections = __webpack_require__(9);
|
77
|
-
var dispatcher_1 = __webpack_require__(24);
|
78
|
-
var timeline_1 = __webpack_require__(39);
|
79
|
-
var level_1 = __webpack_require__(40);
|
80
|
-
var StrategyBuilder = __webpack_require__(41);
|
81
|
-
var timers_1 = __webpack_require__(12);
|
82
|
-
var defaults_1 = __webpack_require__(5);
|
83
|
-
var DefaultConfig = __webpack_require__(63);
|
84
|
-
var logger_1 = __webpack_require__(8);
|
85
|
-
var factory_1 = __webpack_require__(43);
|
86
|
-
var url_store_1 = __webpack_require__(14);
|
87
|
-
var Pusher = (function () {
|
88
|
-
function Pusher(app_key, options) {
|
89
|
-
var _this = this;
|
90
|
-
checkAppKey(app_key);
|
91
|
-
options = options || {};
|
92
|
-
if (!options.cluster && !(options.wsHost || options.httpHost)) {
|
93
|
-
var suffix = url_store_1["default"].buildLogSuffix("javascriptQuickStart");
|
94
|
-
logger_1["default"].warn("You should always specify a cluster when connecting. " + suffix);
|
95
|
-
}
|
96
|
-
this.key = app_key;
|
97
|
-
this.config = Collections.extend(DefaultConfig.getGlobalConfig(), options.cluster ? DefaultConfig.getClusterConfig(options.cluster) : {}, options);
|
98
|
-
this.channels = factory_1["default"].createChannels();
|
99
|
-
this.global_emitter = new dispatcher_1["default"]();
|
100
|
-
this.sessionID = Math.floor(Math.random() * 1000000000);
|
101
|
-
this.timeline = new timeline_1["default"](this.key, this.sessionID, {
|
102
|
-
cluster: this.config.cluster,
|
103
|
-
features: Pusher.getClientFeatures(),
|
104
|
-
params: this.config.timelineParams || {},
|
105
|
-
limit: 50,
|
106
|
-
level: level_1["default"].INFO,
|
107
|
-
version: defaults_1["default"].VERSION
|
108
|
-
});
|
109
|
-
if (!this.config.disableStats) {
|
110
|
-
this.timelineSender = factory_1["default"].createTimelineSender(this.timeline, {
|
111
|
-
host: this.config.statsHost,
|
112
|
-
path: "/timeline/v2/" + runtime_1["default"].TimelineTransport.name
|
113
|
-
});
|
114
|
-
}
|
115
|
-
var getStrategy = function (options) {
|
116
|
-
var config = Collections.extend({}, _this.config, options);
|
117
|
-
return StrategyBuilder.build(runtime_1["default"].getDefaultStrategy(config), config);
|
118
|
-
};
|
119
|
-
this.connection = factory_1["default"].createConnectionManager(this.key, Collections.extend({ getStrategy: getStrategy,
|
120
|
-
timeline: this.timeline,
|
121
|
-
activityTimeout: this.config.activity_timeout,
|
122
|
-
pongTimeout: this.config.pong_timeout,
|
123
|
-
unavailableTimeout: this.config.unavailable_timeout
|
124
|
-
}, this.config, { encrypted: this.isEncrypted() }));
|
125
|
-
this.connection.bind('connected', function () {
|
126
|
-
_this.subscribeAll();
|
127
|
-
if (_this.timelineSender) {
|
128
|
-
_this.timelineSender.send(_this.connection.isEncrypted());
|
129
|
-
}
|
130
|
-
});
|
131
|
-
this.connection.bind('message', function (params) {
|
132
|
-
var internal = (params.event.indexOf('pusher_internal:') === 0);
|
133
|
-
if (params.channel) {
|
134
|
-
var channel = _this.channel(params.channel);
|
135
|
-
if (channel) {
|
136
|
-
channel.handleEvent(params.event, params.data);
|
137
|
-
}
|
138
|
-
}
|
139
|
-
if (!internal) {
|
140
|
-
_this.global_emitter.emit(params.event, params.data);
|
141
|
-
}
|
142
|
-
});
|
143
|
-
this.connection.bind('connecting', function () {
|
144
|
-
_this.channels.disconnect();
|
145
|
-
});
|
146
|
-
this.connection.bind('disconnected', function () {
|
147
|
-
_this.channels.disconnect();
|
148
|
-
});
|
149
|
-
this.connection.bind('error', function (err) {
|
150
|
-
logger_1["default"].warn('Error', err);
|
151
|
-
});
|
152
|
-
Pusher.instances.push(this);
|
153
|
-
this.timeline.info({ instances: Pusher.instances.length });
|
154
|
-
if (Pusher.isReady) {
|
155
|
-
this.connect();
|
156
|
-
}
|
157
|
-
}
|
158
|
-
Pusher.ready = function () {
|
159
|
-
Pusher.isReady = true;
|
160
|
-
for (var i = 0, l = Pusher.instances.length; i < l; i++) {
|
161
|
-
Pusher.instances[i].connect();
|
162
|
-
}
|
163
|
-
};
|
164
|
-
Pusher.log = function (message) {
|
165
|
-
if (Pusher.logToConsole && (window).console && (window).console.log) {
|
166
|
-
(window).console.log(message);
|
167
|
-
}
|
168
|
-
};
|
169
|
-
Pusher.getClientFeatures = function () {
|
170
|
-
return Collections.keys(Collections.filterObject({ "ws": runtime_1["default"].Transports.ws }, function (t) { return t.isSupported({}); }));
|
171
|
-
};
|
172
|
-
Pusher.prototype.channel = function (name) {
|
173
|
-
return this.channels.find(name);
|
174
|
-
};
|
175
|
-
Pusher.prototype.allChannels = function () {
|
176
|
-
return this.channels.all();
|
177
|
-
};
|
178
|
-
Pusher.prototype.connect = function () {
|
179
|
-
this.connection.connect();
|
180
|
-
if (this.timelineSender) {
|
181
|
-
if (!this.timelineSenderTimer) {
|
182
|
-
var encrypted = this.connection.isEncrypted();
|
183
|
-
var timelineSender = this.timelineSender;
|
184
|
-
this.timelineSenderTimer = new timers_1.PeriodicTimer(60000, function () {
|
185
|
-
timelineSender.send(encrypted);
|
186
|
-
});
|
187
|
-
}
|
188
|
-
}
|
189
|
-
};
|
190
|
-
Pusher.prototype.disconnect = function () {
|
191
|
-
this.connection.disconnect();
|
192
|
-
if (this.timelineSenderTimer) {
|
193
|
-
this.timelineSenderTimer.ensureAborted();
|
194
|
-
this.timelineSenderTimer = null;
|
195
|
-
}
|
196
|
-
};
|
197
|
-
Pusher.prototype.bind = function (event_name, callback, context) {
|
198
|
-
this.global_emitter.bind(event_name, callback, context);
|
199
|
-
return this;
|
200
|
-
};
|
201
|
-
Pusher.prototype.unbind = function (event_name, callback, context) {
|
202
|
-
this.global_emitter.unbind(event_name, callback, context);
|
203
|
-
return this;
|
204
|
-
};
|
205
|
-
Pusher.prototype.bind_global = function (callback) {
|
206
|
-
this.global_emitter.bind_global(callback);
|
207
|
-
return this;
|
208
|
-
};
|
209
|
-
Pusher.prototype.unbind_global = function (callback) {
|
210
|
-
this.global_emitter.unbind_global(callback);
|
211
|
-
return this;
|
212
|
-
};
|
213
|
-
Pusher.prototype.unbind_all = function (callback) {
|
214
|
-
this.global_emitter.unbind_all();
|
215
|
-
return this;
|
216
|
-
};
|
217
|
-
Pusher.prototype.subscribeAll = function () {
|
218
|
-
var channelName;
|
219
|
-
for (channelName in this.channels.channels) {
|
220
|
-
if (this.channels.channels.hasOwnProperty(channelName)) {
|
221
|
-
this.subscribe(channelName);
|
222
|
-
}
|
223
|
-
}
|
224
|
-
};
|
225
|
-
Pusher.prototype.subscribe = function (channel_name) {
|
226
|
-
var channel = this.channels.add(channel_name, this);
|
227
|
-
if (channel.subscriptionPending && channel.subscriptionCancelled) {
|
228
|
-
channel.reinstateSubscription();
|
229
|
-
}
|
230
|
-
else if (!channel.subscriptionPending && this.connection.state === "connected") {
|
231
|
-
channel.subscribe();
|
232
|
-
}
|
233
|
-
return channel;
|
234
|
-
};
|
235
|
-
Pusher.prototype.unsubscribe = function (channel_name) {
|
236
|
-
var channel = this.channels.find(channel_name);
|
237
|
-
if (channel && channel.subscriptionPending) {
|
238
|
-
channel.cancelSubscription();
|
239
|
-
}
|
240
|
-
else {
|
241
|
-
channel = this.channels.remove(channel_name);
|
242
|
-
if (channel && this.connection.state === "connected") {
|
243
|
-
channel.unsubscribe();
|
244
|
-
}
|
245
|
-
}
|
246
|
-
};
|
247
|
-
Pusher.prototype.send_event = function (event_name, data, channel) {
|
248
|
-
return this.connection.send_event(event_name, data, channel);
|
249
|
-
};
|
250
|
-
Pusher.prototype.isEncrypted = function () {
|
251
|
-
if (runtime_1["default"].getProtocol() === "https:") {
|
252
|
-
return true;
|
253
|
-
}
|
254
|
-
else {
|
255
|
-
return Boolean(this.config.encrypted);
|
256
|
-
}
|
257
|
-
};
|
258
|
-
Pusher.instances = [];
|
259
|
-
Pusher.isReady = false;
|
260
|
-
Pusher.logToConsole = false;
|
261
|
-
Pusher.Runtime = runtime_1["default"];
|
262
|
-
Pusher.ScriptReceivers = runtime_1["default"].ScriptReceivers;
|
263
|
-
Pusher.DependenciesReceivers = runtime_1["default"].DependenciesReceivers;
|
264
|
-
Pusher.auth_callbacks = runtime_1["default"].auth_callbacks;
|
265
|
-
return Pusher;
|
266
|
-
}());
|
267
|
-
exports.__esModule = true;
|
268
|
-
exports["default"] = Pusher;
|
269
|
-
function checkAppKey(key) {
|
270
|
-
if (key === null || key === undefined) {
|
271
|
-
throw "You must pass your app key when you instantiate Pusher.";
|
272
|
-
}
|
273
|
-
}
|
274
|
-
runtime_1["default"].setup(Pusher);
|
275
|
-
|
276
|
-
|
277
|
-
/***/ }),
|
278
|
-
/* 2 */
|
279
|
-
/***/ (function(module, exports, __webpack_require__) {
|
280
|
-
|
281
|
-
"use strict";
|
282
|
-
var dependencies_1 = __webpack_require__(3);
|
283
|
-
var xhr_auth_1 = __webpack_require__(7);
|
284
|
-
var jsonp_auth_1 = __webpack_require__(15);
|
285
|
-
var script_request_1 = __webpack_require__(16);
|
286
|
-
var jsonp_request_1 = __webpack_require__(17);
|
287
|
-
var script_receiver_factory_1 = __webpack_require__(4);
|
288
|
-
var jsonp_timeline_1 = __webpack_require__(18);
|
289
|
-
var transports_1 = __webpack_require__(19);
|
290
|
-
var net_info_1 = __webpack_require__(26);
|
291
|
-
var default_strategy_1 = __webpack_require__(27);
|
292
|
-
var transport_connection_initializer_1 = __webpack_require__(28);
|
293
|
-
var http_1 = __webpack_require__(29);
|
294
|
-
var Runtime = {
|
295
|
-
nextAuthCallbackID: 1,
|
296
|
-
auth_callbacks: {},
|
297
|
-
ScriptReceivers: script_receiver_factory_1.ScriptReceivers,
|
298
|
-
DependenciesReceivers: dependencies_1.DependenciesReceivers,
|
299
|
-
getDefaultStrategy: default_strategy_1["default"],
|
300
|
-
Transports: transports_1["default"],
|
301
|
-
transportConnectionInitializer: transport_connection_initializer_1["default"],
|
302
|
-
HTTPFactory: http_1["default"],
|
303
|
-
TimelineTransport: jsonp_timeline_1["default"],
|
304
|
-
getXHRAPI: function () {
|
305
|
-
return window.XMLHttpRequest;
|
306
|
-
},
|
307
|
-
getWebSocketAPI: function () {
|
308
|
-
return window.WebSocket || window.MozWebSocket;
|
309
|
-
},
|
310
|
-
setup: function (PusherClass) {
|
311
|
-
var _this = this;
|
312
|
-
window.Pusher = PusherClass;
|
313
|
-
var initializeOnDocumentBody = function () {
|
314
|
-
_this.onDocumentBody(PusherClass.ready);
|
315
|
-
};
|
316
|
-
if (!window.JSON) {
|
317
|
-
dependencies_1.Dependencies.load("json2", {}, initializeOnDocumentBody);
|
318
|
-
}
|
319
|
-
else {
|
320
|
-
initializeOnDocumentBody();
|
321
|
-
}
|
322
|
-
},
|
323
|
-
getDocument: function () {
|
324
|
-
return document;
|
325
|
-
},
|
326
|
-
getProtocol: function () {
|
327
|
-
return this.getDocument().location.protocol;
|
328
|
-
},
|
329
|
-
getAuthorizers: function () {
|
330
|
-
return { ajax: xhr_auth_1["default"], jsonp: jsonp_auth_1["default"] };
|
331
|
-
},
|
332
|
-
onDocumentBody: function (callback) {
|
333
|
-
var _this = this;
|
334
|
-
if (document.body) {
|
335
|
-
callback();
|
336
|
-
}
|
337
|
-
else {
|
338
|
-
setTimeout(function () {
|
339
|
-
_this.onDocumentBody(callback);
|
340
|
-
}, 0);
|
341
|
-
}
|
342
|
-
},
|
343
|
-
createJSONPRequest: function (url, data) {
|
344
|
-
return new jsonp_request_1["default"](url, data);
|
345
|
-
},
|
346
|
-
createScriptRequest: function (src) {
|
347
|
-
return new script_request_1["default"](src);
|
348
|
-
},
|
349
|
-
getLocalStorage: function () {
|
350
|
-
try {
|
351
|
-
return window.localStorage;
|
352
|
-
}
|
353
|
-
catch (e) {
|
354
|
-
return undefined;
|
355
|
-
}
|
356
|
-
},
|
357
|
-
createXHR: function () {
|
358
|
-
if (this.getXHRAPI()) {
|
359
|
-
return this.createXMLHttpRequest();
|
360
|
-
}
|
361
|
-
else {
|
362
|
-
return this.createMicrosoftXHR();
|
363
|
-
}
|
364
|
-
},
|
365
|
-
createXMLHttpRequest: function () {
|
366
|
-
var Constructor = this.getXHRAPI();
|
367
|
-
return new Constructor();
|
368
|
-
},
|
369
|
-
createMicrosoftXHR: function () {
|
370
|
-
return new ActiveXObject("Microsoft.XMLHTTP");
|
371
|
-
},
|
372
|
-
getNetwork: function () {
|
373
|
-
return net_info_1.Network;
|
374
|
-
},
|
375
|
-
createWebSocket: function (url) {
|
376
|
-
var Constructor = this.getWebSocketAPI();
|
377
|
-
return new Constructor(url);
|
378
|
-
},
|
379
|
-
createSocketRequest: function (method, url) {
|
380
|
-
if (this.isXHRSupported()) {
|
381
|
-
return this.HTTPFactory.createXHR(method, url);
|
382
|
-
}
|
383
|
-
else if (this.isXDRSupported(url.indexOf("https:") === 0)) {
|
384
|
-
return this.HTTPFactory.createXDR(method, url);
|
385
|
-
}
|
386
|
-
else {
|
387
|
-
throw "Cross-origin HTTP requests are not supported";
|
388
|
-
}
|
389
|
-
},
|
390
|
-
isXHRSupported: function () {
|
391
|
-
var Constructor = this.getXHRAPI();
|
392
|
-
return Boolean(Constructor) && (new Constructor()).withCredentials !== undefined;
|
393
|
-
},
|
394
|
-
isXDRSupported: function (encrypted) {
|
395
|
-
var protocol = encrypted ? "https:" : "http:";
|
396
|
-
var documentProtocol = this.getProtocol();
|
397
|
-
return Boolean((window['XDomainRequest'])) && documentProtocol === protocol;
|
398
|
-
},
|
399
|
-
addUnloadListener: function (listener) {
|
400
|
-
if (window.addEventListener !== undefined) {
|
401
|
-
window.addEventListener("unload", listener, false);
|
402
|
-
}
|
403
|
-
else if (window.attachEvent !== undefined) {
|
404
|
-
window.attachEvent("onunload", listener);
|
405
|
-
}
|
406
|
-
},
|
407
|
-
removeUnloadListener: function (listener) {
|
408
|
-
if (window.addEventListener !== undefined) {
|
409
|
-
window.removeEventListener("unload", listener, false);
|
410
|
-
}
|
411
|
-
else if (window.detachEvent !== undefined) {
|
412
|
-
window.detachEvent("onunload", listener);
|
413
|
-
}
|
414
|
-
}
|
415
|
-
};
|
416
|
-
exports.__esModule = true;
|
417
|
-
exports["default"] = Runtime;
|
418
|
-
|
419
|
-
|
420
|
-
/***/ }),
|
421
|
-
/* 3 */
|
422
|
-
/***/ (function(module, exports, __webpack_require__) {
|
423
|
-
|
424
|
-
"use strict";
|
425
|
-
var script_receiver_factory_1 = __webpack_require__(4);
|
426
|
-
var defaults_1 = __webpack_require__(5);
|
427
|
-
var dependency_loader_1 = __webpack_require__(6);
|
428
|
-
exports.DependenciesReceivers = new script_receiver_factory_1.ScriptReceiverFactory("_pusher_dependencies", "Pusher.DependenciesReceivers");
|
429
|
-
exports.Dependencies = new dependency_loader_1["default"]({
|
430
|
-
cdn_http: defaults_1["default"].cdn_http,
|
431
|
-
cdn_https: defaults_1["default"].cdn_https,
|
432
|
-
version: defaults_1["default"].VERSION,
|
433
|
-
suffix: defaults_1["default"].dependency_suffix,
|
434
|
-
receivers: exports.DependenciesReceivers
|
435
|
-
});
|
436
|
-
|
437
|
-
|
438
|
-
/***/ }),
|
439
|
-
/* 4 */
|
440
|
-
/***/ (function(module, exports) {
|
441
|
-
|
442
|
-
"use strict";
|
443
|
-
var ScriptReceiverFactory = (function () {
|
444
|
-
function ScriptReceiverFactory(prefix, name) {
|
445
|
-
this.lastId = 0;
|
446
|
-
this.prefix = prefix;
|
447
|
-
this.name = name;
|
448
|
-
}
|
449
|
-
ScriptReceiverFactory.prototype.create = function (callback) {
|
450
|
-
this.lastId++;
|
451
|
-
var number = this.lastId;
|
452
|
-
var id = this.prefix + number;
|
453
|
-
var name = this.name + "[" + number + "]";
|
454
|
-
var called = false;
|
455
|
-
var callbackWrapper = function () {
|
456
|
-
if (!called) {
|
457
|
-
callback.apply(null, arguments);
|
458
|
-
called = true;
|
459
|
-
}
|
460
|
-
};
|
461
|
-
this[number] = callbackWrapper;
|
462
|
-
return { number: number, id: id, name: name, callback: callbackWrapper };
|
463
|
-
};
|
464
|
-
ScriptReceiverFactory.prototype.remove = function (receiver) {
|
465
|
-
delete this[receiver.number];
|
466
|
-
};
|
467
|
-
return ScriptReceiverFactory;
|
468
|
-
}());
|
469
|
-
exports.ScriptReceiverFactory = ScriptReceiverFactory;
|
470
|
-
exports.ScriptReceivers = new ScriptReceiverFactory("_pusher_script_", "Pusher.ScriptReceivers");
|
471
|
-
|
472
|
-
|
473
|
-
/***/ }),
|
474
|
-
/* 5 */
|
475
|
-
/***/ (function(module, exports) {
|
476
|
-
|
477
|
-
"use strict";
|
478
|
-
var Defaults = {
|
479
|
-
VERSION: "4.2.2",
|
480
|
-
PROTOCOL: 7,
|
481
|
-
host: 'ws.pusherapp.com',
|
482
|
-
ws_port: 80,
|
483
|
-
wss_port: 443,
|
484
|
-
ws_path: '',
|
485
|
-
sockjs_host: 'sockjs.pusher.com',
|
486
|
-
sockjs_http_port: 80,
|
487
|
-
sockjs_https_port: 443,
|
488
|
-
sockjs_path: "/pusher",
|
489
|
-
stats_host: 'stats.pusher.com',
|
490
|
-
channel_auth_endpoint: '/pusher/auth',
|
491
|
-
channel_auth_transport: 'ajax',
|
492
|
-
activity_timeout: 120000,
|
493
|
-
pong_timeout: 30000,
|
494
|
-
unavailable_timeout: 10000,
|
495
|
-
cdn_http: 'http://js.pusher.com',
|
496
|
-
cdn_https: 'https://js.pusher.com',
|
497
|
-
dependency_suffix: ''
|
498
|
-
};
|
499
|
-
exports.__esModule = true;
|
500
|
-
exports["default"] = Defaults;
|
501
|
-
|
502
|
-
|
503
|
-
/***/ }),
|
504
|
-
/* 6 */
|
505
|
-
/***/ (function(module, exports, __webpack_require__) {
|
506
|
-
|
507
|
-
"use strict";
|
508
|
-
var script_receiver_factory_1 = __webpack_require__(4);
|
509
|
-
var runtime_1 = __webpack_require__(2);
|
510
|
-
var DependencyLoader = (function () {
|
511
|
-
function DependencyLoader(options) {
|
512
|
-
this.options = options;
|
513
|
-
this.receivers = options.receivers || script_receiver_factory_1.ScriptReceivers;
|
514
|
-
this.loading = {};
|
515
|
-
}
|
516
|
-
DependencyLoader.prototype.load = function (name, options, callback) {
|
517
|
-
var self = this;
|
518
|
-
if (self.loading[name] && self.loading[name].length > 0) {
|
519
|
-
self.loading[name].push(callback);
|
520
|
-
}
|
521
|
-
else {
|
522
|
-
self.loading[name] = [callback];
|
523
|
-
var request = runtime_1["default"].createScriptRequest(self.getPath(name, options));
|
524
|
-
var receiver = self.receivers.create(function (error) {
|
525
|
-
self.receivers.remove(receiver);
|
526
|
-
if (self.loading[name]) {
|
527
|
-
var callbacks = self.loading[name];
|
528
|
-
delete self.loading[name];
|
529
|
-
var successCallback = function (wasSuccessful) {
|
530
|
-
if (!wasSuccessful) {
|
531
|
-
request.cleanup();
|
532
|
-
}
|
533
|
-
};
|
534
|
-
for (var i = 0; i < callbacks.length; i++) {
|
535
|
-
callbacks[i](error, successCallback);
|
536
|
-
}
|
537
|
-
}
|
538
|
-
});
|
539
|
-
request.send(receiver);
|
540
|
-
}
|
541
|
-
};
|
542
|
-
DependencyLoader.prototype.getRoot = function (options) {
|
543
|
-
var cdn;
|
544
|
-
var protocol = runtime_1["default"].getDocument().location.protocol;
|
545
|
-
if ((options && options.encrypted) || protocol === "https:") {
|
546
|
-
cdn = this.options.cdn_https;
|
547
|
-
}
|
548
|
-
else {
|
549
|
-
cdn = this.options.cdn_http;
|
550
|
-
}
|
551
|
-
return cdn.replace(/\/*$/, "") + "/" + this.options.version;
|
552
|
-
};
|
553
|
-
DependencyLoader.prototype.getPath = function (name, options) {
|
554
|
-
return this.getRoot(options) + '/' + name + this.options.suffix + '.js';
|
555
|
-
};
|
556
|
-
;
|
557
|
-
return DependencyLoader;
|
558
|
-
}());
|
559
|
-
exports.__esModule = true;
|
560
|
-
exports["default"] = DependencyLoader;
|
561
|
-
|
562
|
-
|
563
|
-
/***/ }),
|
564
|
-
/* 7 */
|
565
|
-
/***/ (function(module, exports, __webpack_require__) {
|
566
|
-
|
567
|
-
"use strict";
|
568
|
-
var logger_1 = __webpack_require__(8);
|
569
|
-
var runtime_1 = __webpack_require__(2);
|
570
|
-
var url_store_1 = __webpack_require__(14);
|
571
|
-
var ajax = function (context, socketId, callback) {
|
572
|
-
var self = this, xhr;
|
573
|
-
xhr = runtime_1["default"].createXHR();
|
574
|
-
xhr.open("POST", self.options.authEndpoint, true);
|
575
|
-
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
576
|
-
for (var headerName in this.authOptions.headers) {
|
577
|
-
xhr.setRequestHeader(headerName, this.authOptions.headers[headerName]);
|
578
|
-
}
|
579
|
-
xhr.onreadystatechange = function () {
|
580
|
-
if (xhr.readyState === 4) {
|
581
|
-
if (xhr.status === 200) {
|
582
|
-
var data, parsed = false;
|
583
|
-
try {
|
584
|
-
data = JSON.parse(xhr.responseText);
|
585
|
-
parsed = true;
|
586
|
-
}
|
587
|
-
catch (e) {
|
588
|
-
callback(true, 'JSON returned from webapp was invalid, yet status code was 200. Data was: ' + xhr.responseText);
|
589
|
-
}
|
590
|
-
if (parsed) {
|
591
|
-
callback(false, data);
|
592
|
-
}
|
593
|
-
}
|
594
|
-
else {
|
595
|
-
var suffix = url_store_1["default"].buildLogSuffix("authenticationEndpoint");
|
596
|
-
logger_1["default"].warn(("Couldn't retrieve authentication info. " + xhr.status) +
|
597
|
-
("Clients must be authenticated to join private or presence channels. " + suffix));
|
598
|
-
callback(true, xhr.status);
|
599
|
-
}
|
600
|
-
}
|
601
|
-
};
|
602
|
-
xhr.send(this.composeQuery(socketId));
|
603
|
-
return xhr;
|
604
|
-
};
|
605
|
-
exports.__esModule = true;
|
606
|
-
exports["default"] = ajax;
|
607
|
-
|
608
|
-
|
609
|
-
/***/ }),
|
610
|
-
/* 8 */
|
611
|
-
/***/ (function(module, exports, __webpack_require__) {
|
612
|
-
|
613
|
-
"use strict";
|
614
|
-
var collections_1 = __webpack_require__(9);
|
615
|
-
var pusher_1 = __webpack_require__(1);
|
616
|
-
var Logger = {
|
617
|
-
debug: function () {
|
618
|
-
var args = [];
|
619
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
620
|
-
args[_i - 0] = arguments[_i];
|
621
|
-
}
|
622
|
-
if (!pusher_1["default"].log) {
|
623
|
-
return;
|
624
|
-
}
|
625
|
-
pusher_1["default"].log(collections_1.stringify.apply(this, arguments));
|
626
|
-
},
|
627
|
-
warn: function () {
|
628
|
-
var args = [];
|
629
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
630
|
-
args[_i - 0] = arguments[_i];
|
631
|
-
}
|
632
|
-
var message = collections_1.stringify.apply(this, arguments);
|
633
|
-
if (pusher_1["default"].log) {
|
634
|
-
pusher_1["default"].log(message);
|
635
|
-
}
|
636
|
-
else if ((window).console) {
|
637
|
-
if ((window).console.warn) {
|
638
|
-
(window).console.warn(message);
|
639
|
-
}
|
640
|
-
else if ((window).console.log) {
|
641
|
-
(window).console.log(message);
|
642
|
-
}
|
643
|
-
}
|
644
|
-
}
|
645
|
-
};
|
646
|
-
exports.__esModule = true;
|
647
|
-
exports["default"] = Logger;
|
648
|
-
|
649
|
-
|
650
|
-
/***/ }),
|
651
|
-
/* 9 */
|
652
|
-
/***/ (function(module, exports, __webpack_require__) {
|
653
|
-
|
654
|
-
"use strict";
|
655
|
-
var base64_1 = __webpack_require__(10);
|
656
|
-
var util_1 = __webpack_require__(11);
|
657
|
-
function extend(target) {
|
658
|
-
var sources = [];
|
659
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
660
|
-
sources[_i - 1] = arguments[_i];
|
661
|
-
}
|
662
|
-
for (var i = 0; i < sources.length; i++) {
|
663
|
-
var extensions = sources[i];
|
664
|
-
for (var property in extensions) {
|
665
|
-
if (extensions[property] && extensions[property].constructor &&
|
666
|
-
extensions[property].constructor === Object) {
|
667
|
-
target[property] = extend(target[property] || {}, extensions[property]);
|
668
|
-
}
|
669
|
-
else {
|
670
|
-
target[property] = extensions[property];
|
671
|
-
}
|
672
|
-
}
|
673
|
-
}
|
674
|
-
return target;
|
675
|
-
}
|
676
|
-
exports.extend = extend;
|
677
|
-
function stringify() {
|
678
|
-
var m = ["Pusher"];
|
679
|
-
for (var i = 0; i < arguments.length; i++) {
|
680
|
-
if (typeof arguments[i] === "string") {
|
681
|
-
m.push(arguments[i]);
|
682
|
-
}
|
683
|
-
else {
|
684
|
-
m.push(safeJSONStringify(arguments[i]));
|
685
|
-
}
|
686
|
-
}
|
687
|
-
return m.join(" : ");
|
688
|
-
}
|
689
|
-
exports.stringify = stringify;
|
690
|
-
function arrayIndexOf(array, item) {
|
691
|
-
var nativeIndexOf = Array.prototype.indexOf;
|
692
|
-
if (array === null) {
|
693
|
-
return -1;
|
694
|
-
}
|
695
|
-
if (nativeIndexOf && array.indexOf === nativeIndexOf) {
|
696
|
-
return array.indexOf(item);
|
697
|
-
}
|
698
|
-
for (var i = 0, l = array.length; i < l; i++) {
|
699
|
-
if (array[i] === item) {
|
700
|
-
return i;
|
701
|
-
}
|
702
|
-
}
|
703
|
-
return -1;
|
704
|
-
}
|
705
|
-
exports.arrayIndexOf = arrayIndexOf;
|
706
|
-
function objectApply(object, f) {
|
707
|
-
for (var key in object) {
|
708
|
-
if (Object.prototype.hasOwnProperty.call(object, key)) {
|
709
|
-
f(object[key], key, object);
|
710
|
-
}
|
711
|
-
}
|
712
|
-
}
|
713
|
-
exports.objectApply = objectApply;
|
714
|
-
function keys(object) {
|
715
|
-
var keys = [];
|
716
|
-
objectApply(object, function (_, key) {
|
717
|
-
keys.push(key);
|
718
|
-
});
|
719
|
-
return keys;
|
720
|
-
}
|
721
|
-
exports.keys = keys;
|
722
|
-
function values(object) {
|
723
|
-
var values = [];
|
724
|
-
objectApply(object, function (value) {
|
725
|
-
values.push(value);
|
726
|
-
});
|
727
|
-
return values;
|
728
|
-
}
|
729
|
-
exports.values = values;
|
730
|
-
function apply(array, f, context) {
|
731
|
-
for (var i = 0; i < array.length; i++) {
|
732
|
-
f.call(context || (window), array[i], i, array);
|
733
|
-
}
|
734
|
-
}
|
735
|
-
exports.apply = apply;
|
736
|
-
function map(array, f) {
|
737
|
-
var result = [];
|
738
|
-
for (var i = 0; i < array.length; i++) {
|
739
|
-
result.push(f(array[i], i, array, result));
|
740
|
-
}
|
741
|
-
return result;
|
742
|
-
}
|
743
|
-
exports.map = map;
|
744
|
-
function mapObject(object, f) {
|
745
|
-
var result = {};
|
746
|
-
objectApply(object, function (value, key) {
|
747
|
-
result[key] = f(value);
|
748
|
-
});
|
749
|
-
return result;
|
750
|
-
}
|
751
|
-
exports.mapObject = mapObject;
|
752
|
-
function filter(array, test) {
|
753
|
-
test = test || function (value) { return !!value; };
|
754
|
-
var result = [];
|
755
|
-
for (var i = 0; i < array.length; i++) {
|
756
|
-
if (test(array[i], i, array, result)) {
|
757
|
-
result.push(array[i]);
|
758
|
-
}
|
759
|
-
}
|
760
|
-
return result;
|
761
|
-
}
|
762
|
-
exports.filter = filter;
|
763
|
-
function filterObject(object, test) {
|
764
|
-
var result = {};
|
765
|
-
objectApply(object, function (value, key) {
|
766
|
-
if ((test && test(value, key, object, result)) || Boolean(value)) {
|
767
|
-
result[key] = value;
|
768
|
-
}
|
769
|
-
});
|
770
|
-
return result;
|
771
|
-
}
|
772
|
-
exports.filterObject = filterObject;
|
773
|
-
function flatten(object) {
|
774
|
-
var result = [];
|
775
|
-
objectApply(object, function (value, key) {
|
776
|
-
result.push([key, value]);
|
777
|
-
});
|
778
|
-
return result;
|
779
|
-
}
|
780
|
-
exports.flatten = flatten;
|
781
|
-
function any(array, test) {
|
782
|
-
for (var i = 0; i < array.length; i++) {
|
783
|
-
if (test(array[i], i, array)) {
|
784
|
-
return true;
|
785
|
-
}
|
786
|
-
}
|
787
|
-
return false;
|
788
|
-
}
|
789
|
-
exports.any = any;
|
790
|
-
function all(array, test) {
|
791
|
-
for (var i = 0; i < array.length; i++) {
|
792
|
-
if (!test(array[i], i, array)) {
|
793
|
-
return false;
|
794
|
-
}
|
795
|
-
}
|
796
|
-
return true;
|
797
|
-
}
|
798
|
-
exports.all = all;
|
799
|
-
function encodeParamsObject(data) {
|
800
|
-
return mapObject(data, function (value) {
|
801
|
-
if (typeof value === "object") {
|
802
|
-
value = safeJSONStringify(value);
|
803
|
-
}
|
804
|
-
return encodeURIComponent(base64_1["default"](value.toString()));
|
805
|
-
});
|
806
|
-
}
|
807
|
-
exports.encodeParamsObject = encodeParamsObject;
|
808
|
-
function buildQueryString(data) {
|
809
|
-
var params = filterObject(data, function (value) {
|
810
|
-
return value !== undefined;
|
811
|
-
});
|
812
|
-
var query = map(flatten(encodeParamsObject(params)), util_1["default"].method("join", "=")).join("&");
|
813
|
-
return query;
|
814
|
-
}
|
815
|
-
exports.buildQueryString = buildQueryString;
|
816
|
-
function decycleObject(object) {
|
817
|
-
var objects = [], paths = [];
|
818
|
-
return (function derez(value, path) {
|
819
|
-
var i, name, nu;
|
820
|
-
switch (typeof value) {
|
821
|
-
case 'object':
|
822
|
-
if (!value) {
|
823
|
-
return null;
|
824
|
-
}
|
825
|
-
for (i = 0; i < objects.length; i += 1) {
|
826
|
-
if (objects[i] === value) {
|
827
|
-
return { $ref: paths[i] };
|
828
|
-
}
|
829
|
-
}
|
830
|
-
objects.push(value);
|
831
|
-
paths.push(path);
|
832
|
-
if (Object.prototype.toString.apply(value) === '[object Array]') {
|
833
|
-
nu = [];
|
834
|
-
for (i = 0; i < value.length; i += 1) {
|
835
|
-
nu[i] = derez(value[i], path + '[' + i + ']');
|
836
|
-
}
|
837
|
-
}
|
838
|
-
else {
|
839
|
-
nu = {};
|
840
|
-
for (name in value) {
|
841
|
-
if (Object.prototype.hasOwnProperty.call(value, name)) {
|
842
|
-
nu[name] = derez(value[name], path + '[' + JSON.stringify(name) + ']');
|
843
|
-
}
|
844
|
-
}
|
845
|
-
}
|
846
|
-
return nu;
|
847
|
-
case 'number':
|
848
|
-
case 'string':
|
849
|
-
case 'boolean':
|
850
|
-
return value;
|
851
|
-
}
|
852
|
-
}(object, '$'));
|
853
|
-
}
|
854
|
-
exports.decycleObject = decycleObject;
|
855
|
-
function safeJSONStringify(source) {
|
856
|
-
try {
|
857
|
-
return JSON.stringify(source);
|
858
|
-
}
|
859
|
-
catch (e) {
|
860
|
-
return JSON.stringify(decycleObject(source));
|
861
|
-
}
|
862
|
-
}
|
863
|
-
exports.safeJSONStringify = safeJSONStringify;
|
864
|
-
|
865
|
-
|
866
|
-
/***/ }),
|
867
|
-
/* 10 */
|
868
|
-
/***/ (function(module, exports, __webpack_require__) {
|
869
|
-
|
870
|
-
"use strict";
|
871
|
-
function encode(s) {
|
872
|
-
return btoa(utob(s));
|
873
|
-
}
|
874
|
-
exports.__esModule = true;
|
875
|
-
exports["default"] = encode;
|
876
|
-
var fromCharCode = String.fromCharCode;
|
877
|
-
var b64chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
878
|
-
var b64tab = {};
|
879
|
-
for (var i = 0, l = b64chars.length; i < l; i++) {
|
880
|
-
b64tab[b64chars.charAt(i)] = i;
|
881
|
-
}
|
882
|
-
var cb_utob = function (c) {
|
883
|
-
var cc = c.charCodeAt(0);
|
884
|
-
return cc < 0x80 ? c
|
885
|
-
: cc < 0x800 ? fromCharCode(0xc0 | (cc >>> 6)) +
|
886
|
-
fromCharCode(0x80 | (cc & 0x3f))
|
887
|
-
: fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +
|
888
|
-
fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +
|
889
|
-
fromCharCode(0x80 | (cc & 0x3f));
|
890
|
-
};
|
891
|
-
var utob = function (u) {
|
892
|
-
return u.replace(/[^\x00-\x7F]/g, cb_utob);
|
893
|
-
};
|
894
|
-
var cb_encode = function (ccc) {
|
895
|
-
var padlen = [0, 2, 1][ccc.length % 3];
|
896
|
-
var ord = ccc.charCodeAt(0) << 16
|
897
|
-
| ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8)
|
898
|
-
| ((ccc.length > 2 ? ccc.charCodeAt(2) : 0));
|
899
|
-
var chars = [
|
900
|
-
b64chars.charAt(ord >>> 18),
|
901
|
-
b64chars.charAt((ord >>> 12) & 63),
|
902
|
-
padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),
|
903
|
-
padlen >= 1 ? '=' : b64chars.charAt(ord & 63)
|
904
|
-
];
|
905
|
-
return chars.join('');
|
906
|
-
};
|
907
|
-
var btoa = (window).btoa || function (b) {
|
908
|
-
return b.replace(/[\s\S]{1,3}/g, cb_encode);
|
909
|
-
};
|
910
|
-
|
911
|
-
|
912
|
-
/***/ }),
|
913
|
-
/* 11 */
|
914
|
-
/***/ (function(module, exports, __webpack_require__) {
|
915
|
-
|
916
|
-
"use strict";
|
917
|
-
var timers_1 = __webpack_require__(12);
|
918
|
-
var Util = {
|
919
|
-
now: function () {
|
920
|
-
if (Date.now) {
|
921
|
-
return Date.now();
|
922
|
-
}
|
923
|
-
else {
|
924
|
-
return new Date().valueOf();
|
925
|
-
}
|
926
|
-
},
|
927
|
-
defer: function (callback) {
|
928
|
-
return new timers_1.OneOffTimer(0, callback);
|
929
|
-
},
|
930
|
-
method: function (name) {
|
931
|
-
var args = [];
|
932
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
933
|
-
args[_i - 1] = arguments[_i];
|
934
|
-
}
|
935
|
-
var boundArguments = Array.prototype.slice.call(arguments, 1);
|
936
|
-
return function (object) {
|
937
|
-
return object[name].apply(object, boundArguments.concat(arguments));
|
938
|
-
};
|
939
|
-
}
|
940
|
-
};
|
941
|
-
exports.__esModule = true;
|
942
|
-
exports["default"] = Util;
|
943
|
-
|
944
|
-
|
945
|
-
/***/ }),
|
946
|
-
/* 12 */
|
947
|
-
/***/ (function(module, exports, __webpack_require__) {
|
948
|
-
|
949
|
-
"use strict";
|
950
|
-
var __extends = (this && this.__extends) || function (d, b) {
|
951
|
-
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
952
|
-
function __() { this.constructor = d; }
|
953
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
954
|
-
};
|
955
|
-
var abstract_timer_1 = __webpack_require__(13);
|
956
|
-
function clearTimeout(timer) {
|
957
|
-
(window).clearTimeout(timer);
|
958
|
-
}
|
959
|
-
function clearInterval(timer) {
|
960
|
-
(window).clearInterval(timer);
|
961
|
-
}
|
962
|
-
var OneOffTimer = (function (_super) {
|
963
|
-
__extends(OneOffTimer, _super);
|
964
|
-
function OneOffTimer(delay, callback) {
|
965
|
-
_super.call(this, setTimeout, clearTimeout, delay, function (timer) {
|
966
|
-
callback();
|
967
|
-
return null;
|
968
|
-
});
|
969
|
-
}
|
970
|
-
return OneOffTimer;
|
971
|
-
}(abstract_timer_1["default"]));
|
972
|
-
exports.OneOffTimer = OneOffTimer;
|
973
|
-
var PeriodicTimer = (function (_super) {
|
974
|
-
__extends(PeriodicTimer, _super);
|
975
|
-
function PeriodicTimer(delay, callback) {
|
976
|
-
_super.call(this, setInterval, clearInterval, delay, function (timer) {
|
977
|
-
callback();
|
978
|
-
return timer;
|
979
|
-
});
|
980
|
-
}
|
981
|
-
return PeriodicTimer;
|
982
|
-
}(abstract_timer_1["default"]));
|
983
|
-
exports.PeriodicTimer = PeriodicTimer;
|
984
|
-
|
985
|
-
|
986
|
-
/***/ }),
|
987
|
-
/* 13 */
|
988
|
-
/***/ (function(module, exports) {
|
989
|
-
|
990
|
-
"use strict";
|
991
|
-
var Timer = (function () {
|
992
|
-
function Timer(set, clear, delay, callback) {
|
993
|
-
var _this = this;
|
994
|
-
this.clear = clear;
|
995
|
-
this.timer = set(function () {
|
996
|
-
if (_this.timer) {
|
997
|
-
_this.timer = callback(_this.timer);
|
998
|
-
}
|
999
|
-
}, delay);
|
1000
|
-
}
|
1001
|
-
Timer.prototype.isRunning = function () {
|
1002
|
-
return this.timer !== null;
|
1003
|
-
};
|
1004
|
-
Timer.prototype.ensureAborted = function () {
|
1005
|
-
if (this.timer) {
|
1006
|
-
this.clear(this.timer);
|
1007
|
-
this.timer = null;
|
1008
|
-
}
|
1009
|
-
};
|
1010
|
-
return Timer;
|
1011
|
-
}());
|
1012
|
-
exports.__esModule = true;
|
1013
|
-
exports["default"] = Timer;
|
1014
|
-
|
1015
|
-
|
1016
|
-
/***/ }),
|
1017
|
-
/* 14 */
|
1018
|
-
/***/ (function(module, exports) {
|
1019
|
-
|
1020
|
-
"use strict";
|
1021
|
-
var urlStore = {
|
1022
|
-
baseUrl: "https://pusher.com",
|
1023
|
-
urls: {
|
1024
|
-
authenticationEndpoint: {
|
1025
|
-
path: "/docs/authenticating_users"
|
1026
|
-
},
|
1027
|
-
javascriptQuickStart: {
|
1028
|
-
path: "/docs/javascript_quick_start"
|
1029
|
-
}
|
1030
|
-
}
|
1031
|
-
};
|
1032
|
-
var buildLogSuffix = function (key) {
|
1033
|
-
var urlPrefix = "See:";
|
1034
|
-
var urlObj = urlStore.urls[key];
|
1035
|
-
if (!urlObj)
|
1036
|
-
return "";
|
1037
|
-
var url;
|
1038
|
-
if (urlObj.fullUrl) {
|
1039
|
-
url = urlObj.fullUrl;
|
1040
|
-
}
|
1041
|
-
else if (urlObj.path) {
|
1042
|
-
url = urlStore.baseUrl + urlObj.path;
|
1043
|
-
}
|
1044
|
-
if (!url)
|
1045
|
-
return "";
|
1046
|
-
return urlPrefix + " " + url;
|
1047
|
-
};
|
1048
|
-
exports.__esModule = true;
|
1049
|
-
exports["default"] = { buildLogSuffix: buildLogSuffix };
|
1050
|
-
|
1051
|
-
|
1052
|
-
/***/ }),
|
1053
|
-
/* 15 */
|
1054
|
-
/***/ (function(module, exports, __webpack_require__) {
|
1055
|
-
|
1056
|
-
"use strict";
|
1057
|
-
var logger_1 = __webpack_require__(8);
|
1058
|
-
var jsonp = function (context, socketId, callback) {
|
1059
|
-
if (this.authOptions.headers !== undefined) {
|
1060
|
-
logger_1["default"].warn("Warn", "To send headers with the auth request, you must use AJAX, rather than JSONP.");
|
1061
|
-
}
|
1062
|
-
var callbackName = context.nextAuthCallbackID.toString();
|
1063
|
-
context.nextAuthCallbackID++;
|
1064
|
-
var document = context.getDocument();
|
1065
|
-
var script = document.createElement("script");
|
1066
|
-
context.auth_callbacks[callbackName] = function (data) {
|
1067
|
-
callback(false, data);
|
1068
|
-
};
|
1069
|
-
var callback_name = "Pusher.auth_callbacks['" + callbackName + "']";
|
1070
|
-
script.src = this.options.authEndpoint +
|
1071
|
-
'?callback=' +
|
1072
|
-
encodeURIComponent(callback_name) +
|
1073
|
-
'&' +
|
1074
|
-
this.composeQuery(socketId);
|
1075
|
-
var head = document.getElementsByTagName("head")[0] || document.documentElement;
|
1076
|
-
head.insertBefore(script, head.firstChild);
|
1077
|
-
};
|
1078
|
-
exports.__esModule = true;
|
1079
|
-
exports["default"] = jsonp;
|
1080
|
-
|
1081
|
-
|
1082
|
-
/***/ }),
|
1083
|
-
/* 16 */
|
1084
|
-
/***/ (function(module, exports) {
|
1085
|
-
|
1086
|
-
"use strict";
|
1087
|
-
var ScriptRequest = (function () {
|
1088
|
-
function ScriptRequest(src) {
|
1089
|
-
this.src = src;
|
1090
|
-
}
|
1091
|
-
ScriptRequest.prototype.send = function (receiver) {
|
1092
|
-
var self = this;
|
1093
|
-
var errorString = "Error loading " + self.src;
|
1094
|
-
self.script = document.createElement("script");
|
1095
|
-
self.script.id = receiver.id;
|
1096
|
-
self.script.src = self.src;
|
1097
|
-
self.script.type = "text/javascript";
|
1098
|
-
self.script.charset = "UTF-8";
|
1099
|
-
if (self.script.addEventListener) {
|
1100
|
-
self.script.onerror = function () {
|
1101
|
-
receiver.callback(errorString);
|
1102
|
-
};
|
1103
|
-
self.script.onload = function () {
|
1104
|
-
receiver.callback(null);
|
1105
|
-
};
|
1106
|
-
}
|
1107
|
-
else {
|
1108
|
-
self.script.onreadystatechange = function () {
|
1109
|
-
if (self.script.readyState === 'loaded' ||
|
1110
|
-
self.script.readyState === 'complete') {
|
1111
|
-
receiver.callback(null);
|
1112
|
-
}
|
1113
|
-
};
|
1114
|
-
}
|
1115
|
-
if (self.script.async === undefined && document.attachEvent &&
|
1116
|
-
/opera/i.test(navigator.userAgent)) {
|
1117
|
-
self.errorScript = document.createElement("script");
|
1118
|
-
self.errorScript.id = receiver.id + "_error";
|
1119
|
-
self.errorScript.text = receiver.name + "('" + errorString + "');";
|
1120
|
-
self.script.async = self.errorScript.async = false;
|
1121
|
-
}
|
1122
|
-
else {
|
1123
|
-
self.script.async = true;
|
1124
|
-
}
|
1125
|
-
var head = document.getElementsByTagName('head')[0];
|
1126
|
-
head.insertBefore(self.script, head.firstChild);
|
1127
|
-
if (self.errorScript) {
|
1128
|
-
head.insertBefore(self.errorScript, self.script.nextSibling);
|
1129
|
-
}
|
1130
|
-
};
|
1131
|
-
ScriptRequest.prototype.cleanup = function () {
|
1132
|
-
if (this.script) {
|
1133
|
-
this.script.onload = this.script.onerror = null;
|
1134
|
-
this.script.onreadystatechange = null;
|
1135
|
-
}
|
1136
|
-
if (this.script && this.script.parentNode) {
|
1137
|
-
this.script.parentNode.removeChild(this.script);
|
1138
|
-
}
|
1139
|
-
if (this.errorScript && this.errorScript.parentNode) {
|
1140
|
-
this.errorScript.parentNode.removeChild(this.errorScript);
|
1141
|
-
}
|
1142
|
-
this.script = null;
|
1143
|
-
this.errorScript = null;
|
1144
|
-
};
|
1145
|
-
return ScriptRequest;
|
1146
|
-
}());
|
1147
|
-
exports.__esModule = true;
|
1148
|
-
exports["default"] = ScriptRequest;
|
1149
|
-
|
1150
|
-
|
1151
|
-
/***/ }),
|
1152
|
-
/* 17 */
|
1153
|
-
/***/ (function(module, exports, __webpack_require__) {
|
1154
|
-
|
1155
|
-
"use strict";
|
1156
|
-
var Collections = __webpack_require__(9);
|
1157
|
-
var runtime_1 = __webpack_require__(2);
|
1158
|
-
var JSONPRequest = (function () {
|
1159
|
-
function JSONPRequest(url, data) {
|
1160
|
-
this.url = url;
|
1161
|
-
this.data = data;
|
1162
|
-
}
|
1163
|
-
JSONPRequest.prototype.send = function (receiver) {
|
1164
|
-
if (this.request) {
|
1165
|
-
return;
|
1166
|
-
}
|
1167
|
-
var query = Collections.buildQueryString(this.data);
|
1168
|
-
var url = this.url + "/" + receiver.number + "?" + query;
|
1169
|
-
this.request = runtime_1["default"].createScriptRequest(url);
|
1170
|
-
this.request.send(receiver);
|
1171
|
-
};
|
1172
|
-
JSONPRequest.prototype.cleanup = function () {
|
1173
|
-
if (this.request) {
|
1174
|
-
this.request.cleanup();
|
1175
|
-
}
|
1176
|
-
};
|
1177
|
-
return JSONPRequest;
|
1178
|
-
}());
|
1179
|
-
exports.__esModule = true;
|
1180
|
-
exports["default"] = JSONPRequest;
|
1181
|
-
|
1182
|
-
|
1183
|
-
/***/ }),
|
1184
|
-
/* 18 */
|
1185
|
-
/***/ (function(module, exports, __webpack_require__) {
|
1186
|
-
|
1187
|
-
"use strict";
|
1188
|
-
var runtime_1 = __webpack_require__(2);
|
1189
|
-
var script_receiver_factory_1 = __webpack_require__(4);
|
1190
|
-
var getAgent = function (sender, encrypted) {
|
1191
|
-
return function (data, callback) {
|
1192
|
-
var scheme = "http" + (encrypted ? "s" : "") + "://";
|
1193
|
-
var url = scheme + (sender.host || sender.options.host) + sender.options.path;
|
1194
|
-
var request = runtime_1["default"].createJSONPRequest(url, data);
|
1195
|
-
var receiver = runtime_1["default"].ScriptReceivers.create(function (error, result) {
|
1196
|
-
script_receiver_factory_1.ScriptReceivers.remove(receiver);
|
1197
|
-
request.cleanup();
|
1198
|
-
if (result && result.host) {
|
1199
|
-
sender.host = result.host;
|
1200
|
-
}
|
1201
|
-
if (callback) {
|
1202
|
-
callback(error, result);
|
1203
|
-
}
|
1204
|
-
});
|
1205
|
-
request.send(receiver);
|
1206
|
-
};
|
1207
|
-
};
|
1208
|
-
var jsonp = {
|
1209
|
-
name: 'jsonp',
|
1210
|
-
getAgent: getAgent
|
1211
|
-
};
|
1212
|
-
exports.__esModule = true;
|
1213
|
-
exports["default"] = jsonp;
|
1214
|
-
|
1215
|
-
|
1216
|
-
/***/ }),
|
1217
|
-
/* 19 */
|
1218
|
-
/***/ (function(module, exports, __webpack_require__) {
|
1219
|
-
|
1220
|
-
"use strict";
|
1221
|
-
var transports_1 = __webpack_require__(20);
|
1222
|
-
var transport_1 = __webpack_require__(22);
|
1223
|
-
var URLSchemes = __webpack_require__(21);
|
1224
|
-
var runtime_1 = __webpack_require__(2);
|
1225
|
-
var dependencies_1 = __webpack_require__(3);
|
1226
|
-
var Collections = __webpack_require__(9);
|
1227
|
-
var SockJSTransport = new transport_1["default"]({
|
1228
|
-
file: "sockjs",
|
1229
|
-
urls: URLSchemes.sockjs,
|
1230
|
-
handlesActivityChecks: true,
|
1231
|
-
supportsPing: false,
|
1232
|
-
isSupported: function () {
|
1233
|
-
return true;
|
1234
|
-
},
|
1235
|
-
isInitialized: function () {
|
1236
|
-
return window.SockJS !== undefined;
|
1237
|
-
},
|
1238
|
-
getSocket: function (url, options) {
|
1239
|
-
return new window.SockJS(url, null, {
|
1240
|
-
js_path: dependencies_1.Dependencies.getPath("sockjs", {
|
1241
|
-
encrypted: options.encrypted
|
1242
|
-
}),
|
1243
|
-
ignore_null_origin: options.ignoreNullOrigin
|
1244
|
-
});
|
1245
|
-
},
|
1246
|
-
beforeOpen: function (socket, path) {
|
1247
|
-
socket.send(JSON.stringify({
|
1248
|
-
path: path
|
1249
|
-
}));
|
1250
|
-
}
|
1251
|
-
});
|
1252
|
-
var xdrConfiguration = {
|
1253
|
-
isSupported: function (environment) {
|
1254
|
-
var yes = runtime_1["default"].isXDRSupported(environment.encrypted);
|
1255
|
-
return yes;
|
1256
|
-
}
|
1257
|
-
};
|
1258
|
-
var XDRStreamingTransport = new transport_1["default"](Collections.extend({}, transports_1.streamingConfiguration, xdrConfiguration));
|
1259
|
-
var XDRPollingTransport = new transport_1["default"](Collections.extend({}, transports_1.pollingConfiguration, xdrConfiguration));
|
1260
|
-
transports_1["default"].xdr_streaming = XDRStreamingTransport;
|
1261
|
-
transports_1["default"].xdr_polling = XDRPollingTransport;
|
1262
|
-
transports_1["default"].sockjs = SockJSTransport;
|
1263
|
-
exports.__esModule = true;
|
1264
|
-
exports["default"] = transports_1["default"];
|
1265
|
-
|
1266
|
-
|
1267
|
-
/***/ }),
|
1268
|
-
/* 20 */
|
1269
|
-
/***/ (function(module, exports, __webpack_require__) {
|
1270
|
-
|
1271
|
-
"use strict";
|
1272
|
-
var URLSchemes = __webpack_require__(21);
|
1273
|
-
var transport_1 = __webpack_require__(22);
|
1274
|
-
var Collections = __webpack_require__(9);
|
1275
|
-
var runtime_1 = __webpack_require__(2);
|
1276
|
-
var WSTransport = new transport_1["default"]({
|
1277
|
-
urls: URLSchemes.ws,
|
1278
|
-
handlesActivityChecks: false,
|
1279
|
-
supportsPing: false,
|
1280
|
-
isInitialized: function () {
|
1281
|
-
return Boolean(runtime_1["default"].getWebSocketAPI());
|
1282
|
-
},
|
1283
|
-
isSupported: function () {
|
1284
|
-
return Boolean(runtime_1["default"].getWebSocketAPI());
|
1285
|
-
},
|
1286
|
-
getSocket: function (url) {
|
1287
|
-
return runtime_1["default"].createWebSocket(url);
|
1288
|
-
}
|
1289
|
-
});
|
1290
|
-
var httpConfiguration = {
|
1291
|
-
urls: URLSchemes.http,
|
1292
|
-
handlesActivityChecks: false,
|
1293
|
-
supportsPing: true,
|
1294
|
-
isInitialized: function () {
|
1295
|
-
return true;
|
1296
|
-
}
|
1297
|
-
};
|
1298
|
-
exports.streamingConfiguration = Collections.extend({ getSocket: function (url) {
|
1299
|
-
return runtime_1["default"].HTTPFactory.createStreamingSocket(url);
|
1300
|
-
}
|
1301
|
-
}, httpConfiguration);
|
1302
|
-
exports.pollingConfiguration = Collections.extend({ getSocket: function (url) {
|
1303
|
-
return runtime_1["default"].HTTPFactory.createPollingSocket(url);
|
1304
|
-
}
|
1305
|
-
}, httpConfiguration);
|
1306
|
-
var xhrConfiguration = {
|
1307
|
-
isSupported: function () {
|
1308
|
-
return runtime_1["default"].isXHRSupported();
|
1309
|
-
}
|
1310
|
-
};
|
1311
|
-
var XHRStreamingTransport = new transport_1["default"](Collections.extend({}, exports.streamingConfiguration, xhrConfiguration));
|
1312
|
-
var XHRPollingTransport = new transport_1["default"](Collections.extend({}, exports.pollingConfiguration, xhrConfiguration));
|
1313
|
-
var Transports = {
|
1314
|
-
ws: WSTransport,
|
1315
|
-
xhr_streaming: XHRStreamingTransport,
|
1316
|
-
xhr_polling: XHRPollingTransport
|
1317
|
-
};
|
1318
|
-
exports.__esModule = true;
|
1319
|
-
exports["default"] = Transports;
|
1320
|
-
|
1321
|
-
|
1322
|
-
/***/ }),
|
1323
|
-
/* 21 */
|
1324
|
-
/***/ (function(module, exports, __webpack_require__) {
|
1325
|
-
|
1326
|
-
"use strict";
|
1327
|
-
var defaults_1 = __webpack_require__(5);
|
1328
|
-
function getGenericURL(baseScheme, params, path) {
|
1329
|
-
var scheme = baseScheme + (params.encrypted ? "s" : "");
|
1330
|
-
var host = params.encrypted ? params.hostEncrypted : params.hostUnencrypted;
|
1331
|
-
return scheme + "://" + host + path;
|
1332
|
-
}
|
1333
|
-
function getGenericPath(key, queryString) {
|
1334
|
-
var path = "/app/" + key;
|
1335
|
-
var query = "?protocol=" + defaults_1["default"].PROTOCOL +
|
1336
|
-
"&client=js" +
|
1337
|
-
"&version=" + defaults_1["default"].VERSION +
|
1338
|
-
(queryString ? ("&" + queryString) : "");
|
1339
|
-
return path + query;
|
1340
|
-
}
|
1341
|
-
exports.ws = {
|
1342
|
-
getInitial: function (key, params) {
|
1343
|
-
var path = (params.httpPath || "") + getGenericPath(key, "flash=false");
|
1344
|
-
return getGenericURL("ws", params, path);
|
1345
|
-
}
|
1346
|
-
};
|
1347
|
-
exports.http = {
|
1348
|
-
getInitial: function (key, params) {
|
1349
|
-
var path = (params.httpPath || "/pusher") + getGenericPath(key);
|
1350
|
-
return getGenericURL("http", params, path);
|
1351
|
-
}
|
1352
|
-
};
|
1353
|
-
exports.sockjs = {
|
1354
|
-
getInitial: function (key, params) {
|
1355
|
-
return getGenericURL("http", params, params.httpPath || "/pusher");
|
1356
|
-
},
|
1357
|
-
getPath: function (key, params) {
|
1358
|
-
return getGenericPath(key);
|
1359
|
-
}
|
1360
|
-
};
|
1361
|
-
|
1362
|
-
|
1363
|
-
/***/ }),
|
1364
|
-
/* 22 */
|
1365
|
-
/***/ (function(module, exports, __webpack_require__) {
|
1366
|
-
|
1367
|
-
"use strict";
|
1368
|
-
var transport_connection_1 = __webpack_require__(23);
|
1369
|
-
var Transport = (function () {
|
1370
|
-
function Transport(hooks) {
|
1371
|
-
this.hooks = hooks;
|
1372
|
-
}
|
1373
|
-
Transport.prototype.isSupported = function (environment) {
|
1374
|
-
return this.hooks.isSupported(environment);
|
1375
|
-
};
|
1376
|
-
Transport.prototype.createConnection = function (name, priority, key, options) {
|
1377
|
-
return new transport_connection_1["default"](this.hooks, name, priority, key, options);
|
1378
|
-
};
|
1379
|
-
return Transport;
|
1380
|
-
}());
|
1381
|
-
exports.__esModule = true;
|
1382
|
-
exports["default"] = Transport;
|
1383
|
-
|
1384
|
-
|
1385
|
-
/***/ }),
|
1386
|
-
/* 23 */
|
1387
|
-
/***/ (function(module, exports, __webpack_require__) {
|
1388
|
-
|
1389
|
-
"use strict";
|
1390
|
-
var __extends = (this && this.__extends) || function (d, b) {
|
1391
|
-
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
1392
|
-
function __() { this.constructor = d; }
|
1393
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
1394
|
-
};
|
1395
|
-
var util_1 = __webpack_require__(11);
|
1396
|
-
var Collections = __webpack_require__(9);
|
1397
|
-
var dispatcher_1 = __webpack_require__(24);
|
1398
|
-
var logger_1 = __webpack_require__(8);
|
1399
|
-
var runtime_1 = __webpack_require__(2);
|
1400
|
-
var TransportConnection = (function (_super) {
|
1401
|
-
__extends(TransportConnection, _super);
|
1402
|
-
function TransportConnection(hooks, name, priority, key, options) {
|
1403
|
-
_super.call(this);
|
1404
|
-
this.initialize = runtime_1["default"].transportConnectionInitializer;
|
1405
|
-
this.hooks = hooks;
|
1406
|
-
this.name = name;
|
1407
|
-
this.priority = priority;
|
1408
|
-
this.key = key;
|
1409
|
-
this.options = options;
|
1410
|
-
this.state = "new";
|
1411
|
-
this.timeline = options.timeline;
|
1412
|
-
this.activityTimeout = options.activityTimeout;
|
1413
|
-
this.id = this.timeline.generateUniqueID();
|
1414
|
-
}
|
1415
|
-
TransportConnection.prototype.handlesActivityChecks = function () {
|
1416
|
-
return Boolean(this.hooks.handlesActivityChecks);
|
1417
|
-
};
|
1418
|
-
TransportConnection.prototype.supportsPing = function () {
|
1419
|
-
return Boolean(this.hooks.supportsPing);
|
1420
|
-
};
|
1421
|
-
TransportConnection.prototype.connect = function () {
|
1422
|
-
var _this = this;
|
1423
|
-
if (this.socket || this.state !== "initialized") {
|
1424
|
-
return false;
|
1425
|
-
}
|
1426
|
-
var url = this.hooks.urls.getInitial(this.key, this.options);
|
1427
|
-
try {
|
1428
|
-
this.socket = this.hooks.getSocket(url, this.options);
|
1429
|
-
}
|
1430
|
-
catch (e) {
|
1431
|
-
util_1["default"].defer(function () {
|
1432
|
-
_this.onError(e);
|
1433
|
-
_this.changeState("closed");
|
1434
|
-
});
|
1435
|
-
return false;
|
1436
|
-
}
|
1437
|
-
this.bindListeners();
|
1438
|
-
logger_1["default"].debug("Connecting", { transport: this.name, url: url });
|
1439
|
-
this.changeState("connecting");
|
1440
|
-
return true;
|
1441
|
-
};
|
1442
|
-
TransportConnection.prototype.close = function () {
|
1443
|
-
if (this.socket) {
|
1444
|
-
this.socket.close();
|
1445
|
-
return true;
|
1446
|
-
}
|
1447
|
-
else {
|
1448
|
-
return false;
|
1449
|
-
}
|
1450
|
-
};
|
1451
|
-
TransportConnection.prototype.send = function (data) {
|
1452
|
-
var _this = this;
|
1453
|
-
if (this.state === "open") {
|
1454
|
-
util_1["default"].defer(function () {
|
1455
|
-
if (_this.socket) {
|
1456
|
-
_this.socket.send(data);
|
1457
|
-
}
|
1458
|
-
});
|
1459
|
-
return true;
|
1460
|
-
}
|
1461
|
-
else {
|
1462
|
-
return false;
|
1463
|
-
}
|
1464
|
-
};
|
1465
|
-
TransportConnection.prototype.ping = function () {
|
1466
|
-
if (this.state === "open" && this.supportsPing()) {
|
1467
|
-
this.socket.ping();
|
1468
|
-
}
|
1469
|
-
};
|
1470
|
-
TransportConnection.prototype.onOpen = function () {
|
1471
|
-
if (this.hooks.beforeOpen) {
|
1472
|
-
this.hooks.beforeOpen(this.socket, this.hooks.urls.getPath(this.key, this.options));
|
1473
|
-
}
|
1474
|
-
this.changeState("open");
|
1475
|
-
this.socket.onopen = undefined;
|
1476
|
-
};
|
1477
|
-
TransportConnection.prototype.onError = function (error) {
|
1478
|
-
this.emit("error", { type: 'WebSocketError', error: error });
|
1479
|
-
this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));
|
1480
|
-
};
|
1481
|
-
TransportConnection.prototype.onClose = function (closeEvent) {
|
1482
|
-
if (closeEvent) {
|
1483
|
-
this.changeState("closed", {
|
1484
|
-
code: closeEvent.code,
|
1485
|
-
reason: closeEvent.reason,
|
1486
|
-
wasClean: closeEvent.wasClean
|
1487
|
-
});
|
1488
|
-
}
|
1489
|
-
else {
|
1490
|
-
this.changeState("closed");
|
1491
|
-
}
|
1492
|
-
this.unbindListeners();
|
1493
|
-
this.socket = undefined;
|
1494
|
-
};
|
1495
|
-
TransportConnection.prototype.onMessage = function (message) {
|
1496
|
-
this.emit("message", message);
|
1497
|
-
};
|
1498
|
-
TransportConnection.prototype.onActivity = function () {
|
1499
|
-
this.emit("activity");
|
1500
|
-
};
|
1501
|
-
TransportConnection.prototype.bindListeners = function () {
|
1502
|
-
var _this = this;
|
1503
|
-
this.socket.onopen = function () {
|
1504
|
-
_this.onOpen();
|
1505
|
-
};
|
1506
|
-
this.socket.onerror = function (error) {
|
1507
|
-
_this.onError(error);
|
1508
|
-
};
|
1509
|
-
this.socket.onclose = function (closeEvent) {
|
1510
|
-
_this.onClose(closeEvent);
|
1511
|
-
};
|
1512
|
-
this.socket.onmessage = function (message) {
|
1513
|
-
_this.onMessage(message);
|
1514
|
-
};
|
1515
|
-
if (this.supportsPing()) {
|
1516
|
-
this.socket.onactivity = function () { _this.onActivity(); };
|
1517
|
-
}
|
1518
|
-
};
|
1519
|
-
TransportConnection.prototype.unbindListeners = function () {
|
1520
|
-
if (this.socket) {
|
1521
|
-
this.socket.onopen = undefined;
|
1522
|
-
this.socket.onerror = undefined;
|
1523
|
-
this.socket.onclose = undefined;
|
1524
|
-
this.socket.onmessage = undefined;
|
1525
|
-
if (this.supportsPing()) {
|
1526
|
-
this.socket.onactivity = undefined;
|
1527
|
-
}
|
1528
|
-
}
|
1529
|
-
};
|
1530
|
-
TransportConnection.prototype.changeState = function (state, params) {
|
1531
|
-
this.state = state;
|
1532
|
-
this.timeline.info(this.buildTimelineMessage({
|
1533
|
-
state: state,
|
1534
|
-
params: params
|
1535
|
-
}));
|
1536
|
-
this.emit(state, params);
|
1537
|
-
};
|
1538
|
-
TransportConnection.prototype.buildTimelineMessage = function (message) {
|
1539
|
-
return Collections.extend({ cid: this.id }, message);
|
1540
|
-
};
|
1541
|
-
return TransportConnection;
|
1542
|
-
}(dispatcher_1["default"]));
|
1543
|
-
exports.__esModule = true;
|
1544
|
-
exports["default"] = TransportConnection;
|
1545
|
-
|
1546
|
-
|
1547
|
-
/***/ }),
|
1548
|
-
/* 24 */
|
1549
|
-
/***/ (function(module, exports, __webpack_require__) {
|
1550
|
-
|
1551
|
-
"use strict";
|
1552
|
-
var Collections = __webpack_require__(9);
|
1553
|
-
var callback_registry_1 = __webpack_require__(25);
|
1554
|
-
var Dispatcher = (function () {
|
1555
|
-
function Dispatcher(failThrough) {
|
1556
|
-
this.callbacks = new callback_registry_1["default"]();
|
1557
|
-
this.global_callbacks = [];
|
1558
|
-
this.failThrough = failThrough;
|
1559
|
-
}
|
1560
|
-
Dispatcher.prototype.bind = function (eventName, callback, context) {
|
1561
|
-
this.callbacks.add(eventName, callback, context);
|
1562
|
-
return this;
|
1563
|
-
};
|
1564
|
-
Dispatcher.prototype.bind_global = function (callback) {
|
1565
|
-
this.global_callbacks.push(callback);
|
1566
|
-
return this;
|
1567
|
-
};
|
1568
|
-
Dispatcher.prototype.unbind = function (eventName, callback, context) {
|
1569
|
-
this.callbacks.remove(eventName, callback, context);
|
1570
|
-
return this;
|
1571
|
-
};
|
1572
|
-
Dispatcher.prototype.unbind_global = function (callback) {
|
1573
|
-
if (!callback) {
|
1574
|
-
this.global_callbacks = [];
|
1575
|
-
return this;
|
1576
|
-
}
|
1577
|
-
this.global_callbacks = Collections.filter(this.global_callbacks || [], function (c) { return c !== callback; });
|
1578
|
-
return this;
|
1579
|
-
};
|
1580
|
-
Dispatcher.prototype.unbind_all = function () {
|
1581
|
-
this.unbind();
|
1582
|
-
this.unbind_global();
|
1583
|
-
return this;
|
1584
|
-
};
|
1585
|
-
Dispatcher.prototype.emit = function (eventName, data) {
|
1586
|
-
var i;
|
1587
|
-
for (i = 0; i < this.global_callbacks.length; i++) {
|
1588
|
-
this.global_callbacks[i](eventName, data);
|
1589
|
-
}
|
1590
|
-
var callbacks = this.callbacks.get(eventName);
|
1591
|
-
if (callbacks && callbacks.length > 0) {
|
1592
|
-
for (i = 0; i < callbacks.length; i++) {
|
1593
|
-
callbacks[i].fn.call(callbacks[i].context || (window), data);
|
1594
|
-
}
|
1595
|
-
}
|
1596
|
-
else if (this.failThrough) {
|
1597
|
-
this.failThrough(eventName, data);
|
1598
|
-
}
|
1599
|
-
return this;
|
1600
|
-
};
|
1601
|
-
return Dispatcher;
|
1602
|
-
}());
|
1603
|
-
exports.__esModule = true;
|
1604
|
-
exports["default"] = Dispatcher;
|
1605
|
-
|
1606
|
-
|
1607
|
-
/***/ }),
|
1608
|
-
/* 25 */
|
1609
|
-
/***/ (function(module, exports, __webpack_require__) {
|
1610
|
-
|
1611
|
-
"use strict";
|
1612
|
-
var Collections = __webpack_require__(9);
|
1613
|
-
var CallbackRegistry = (function () {
|
1614
|
-
function CallbackRegistry() {
|
1615
|
-
this._callbacks = {};
|
1616
|
-
}
|
1617
|
-
CallbackRegistry.prototype.get = function (name) {
|
1618
|
-
return this._callbacks[prefix(name)];
|
1619
|
-
};
|
1620
|
-
CallbackRegistry.prototype.add = function (name, callback, context) {
|
1621
|
-
var prefixedEventName = prefix(name);
|
1622
|
-
this._callbacks[prefixedEventName] = this._callbacks[prefixedEventName] || [];
|
1623
|
-
this._callbacks[prefixedEventName].push({
|
1624
|
-
fn: callback,
|
1625
|
-
context: context
|
1626
|
-
});
|
1627
|
-
};
|
1628
|
-
CallbackRegistry.prototype.remove = function (name, callback, context) {
|
1629
|
-
if (!name && !callback && !context) {
|
1630
|
-
this._callbacks = {};
|
1631
|
-
return;
|
1632
|
-
}
|
1633
|
-
var names = name ? [prefix(name)] : Collections.keys(this._callbacks);
|
1634
|
-
if (callback || context) {
|
1635
|
-
this.removeCallback(names, callback, context);
|
1636
|
-
}
|
1637
|
-
else {
|
1638
|
-
this.removeAllCallbacks(names);
|
1639
|
-
}
|
1640
|
-
};
|
1641
|
-
CallbackRegistry.prototype.removeCallback = function (names, callback, context) {
|
1642
|
-
Collections.apply(names, function (name) {
|
1643
|
-
this._callbacks[name] = Collections.filter(this._callbacks[name] || [], function (binding) {
|
1644
|
-
return (callback && callback !== binding.fn) ||
|
1645
|
-
(context && context !== binding.context);
|
1646
|
-
});
|
1647
|
-
if (this._callbacks[name].length === 0) {
|
1648
|
-
delete this._callbacks[name];
|
1649
|
-
}
|
1650
|
-
}, this);
|
1651
|
-
};
|
1652
|
-
CallbackRegistry.prototype.removeAllCallbacks = function (names) {
|
1653
|
-
Collections.apply(names, function (name) {
|
1654
|
-
delete this._callbacks[name];
|
1655
|
-
}, this);
|
1656
|
-
};
|
1657
|
-
return CallbackRegistry;
|
1658
|
-
}());
|
1659
|
-
exports.__esModule = true;
|
1660
|
-
exports["default"] = CallbackRegistry;
|
1661
|
-
function prefix(name) {
|
1662
|
-
return "_" + name;
|
1663
|
-
}
|
1664
|
-
|
1665
|
-
|
1666
|
-
/***/ }),
|
1667
|
-
/* 26 */
|
1668
|
-
/***/ (function(module, exports, __webpack_require__) {
|
1669
|
-
|
1670
|
-
"use strict";
|
1671
|
-
var __extends = (this && this.__extends) || function (d, b) {
|
1672
|
-
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
1673
|
-
function __() { this.constructor = d; }
|
1674
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
1675
|
-
};
|
1676
|
-
var dispatcher_1 = __webpack_require__(24);
|
1677
|
-
var NetInfo = (function (_super) {
|
1678
|
-
__extends(NetInfo, _super);
|
1679
|
-
function NetInfo() {
|
1680
|
-
_super.call(this);
|
1681
|
-
var self = this;
|
1682
|
-
if (window.addEventListener !== undefined) {
|
1683
|
-
window.addEventListener("online", function () {
|
1684
|
-
self.emit('online');
|
1685
|
-
}, false);
|
1686
|
-
window.addEventListener("offline", function () {
|
1687
|
-
self.emit('offline');
|
1688
|
-
}, false);
|
1689
|
-
}
|
1690
|
-
}
|
1691
|
-
NetInfo.prototype.isOnline = function () {
|
1692
|
-
if (window.navigator.onLine === undefined) {
|
1693
|
-
return true;
|
1694
|
-
}
|
1695
|
-
else {
|
1696
|
-
return window.navigator.onLine;
|
1697
|
-
}
|
1698
|
-
};
|
1699
|
-
return NetInfo;
|
1700
|
-
}(dispatcher_1["default"]));
|
1701
|
-
exports.NetInfo = NetInfo;
|
1702
|
-
exports.Network = new NetInfo();
|
1703
|
-
|
1704
|
-
|
1705
|
-
/***/ }),
|
1706
|
-
/* 27 */
|
1707
|
-
/***/ (function(module, exports) {
|
1708
|
-
|
1709
|
-
"use strict";
|
1710
|
-
var getDefaultStrategy = function (config) {
|
1711
|
-
var wsStrategy;
|
1712
|
-
if (config.encrypted) {
|
1713
|
-
wsStrategy = [
|
1714
|
-
":best_connected_ever",
|
1715
|
-
":ws_loop",
|
1716
|
-
[":delayed", 2000, [":http_fallback_loop"]]
|
1717
|
-
];
|
1718
|
-
}
|
1719
|
-
else {
|
1720
|
-
wsStrategy = [
|
1721
|
-
":best_connected_ever",
|
1722
|
-
":ws_loop",
|
1723
|
-
[":delayed", 2000, [":wss_loop"]],
|
1724
|
-
[":delayed", 5000, [":http_fallback_loop"]]
|
1725
|
-
];
|
1726
|
-
}
|
1727
|
-
return [
|
1728
|
-
[":def", "ws_options", {
|
1729
|
-
hostUnencrypted: config.wsHost + ":" + config.wsPort,
|
1730
|
-
hostEncrypted: config.wsHost + ":" + config.wssPort,
|
1731
|
-
httpPath: config.wsPath
|
1732
|
-
}],
|
1733
|
-
[":def", "wss_options", [":extend", ":ws_options", {
|
1734
|
-
encrypted: true
|
1735
|
-
}]],
|
1736
|
-
[":def", "sockjs_options", {
|
1737
|
-
hostUnencrypted: config.httpHost + ":" + config.httpPort,
|
1738
|
-
hostEncrypted: config.httpHost + ":" + config.httpsPort,
|
1739
|
-
httpPath: config.httpPath
|
1740
|
-
}],
|
1741
|
-
[":def", "timeouts", {
|
1742
|
-
loop: true,
|
1743
|
-
timeout: 15000,
|
1744
|
-
timeoutLimit: 60000
|
1745
|
-
}],
|
1746
|
-
[":def", "ws_manager", [":transport_manager", {
|
1747
|
-
lives: 2,
|
1748
|
-
minPingDelay: 10000,
|
1749
|
-
maxPingDelay: config.activity_timeout
|
1750
|
-
}]],
|
1751
|
-
[":def", "streaming_manager", [":transport_manager", {
|
1752
|
-
lives: 2,
|
1753
|
-
minPingDelay: 10000,
|
1754
|
-
maxPingDelay: config.activity_timeout
|
1755
|
-
}]],
|
1756
|
-
[":def_transport", "ws", "ws", 3, ":ws_options", ":ws_manager"],
|
1757
|
-
[":def_transport", "wss", "ws", 3, ":wss_options", ":ws_manager"],
|
1758
|
-
[":def_transport", "sockjs", "sockjs", 1, ":sockjs_options"],
|
1759
|
-
[":def_transport", "xhr_streaming", "xhr_streaming", 1, ":sockjs_options", ":streaming_manager"],
|
1760
|
-
[":def_transport", "xdr_streaming", "xdr_streaming", 1, ":sockjs_options", ":streaming_manager"],
|
1761
|
-
[":def_transport", "xhr_polling", "xhr_polling", 1, ":sockjs_options"],
|
1762
|
-
[":def_transport", "xdr_polling", "xdr_polling", 1, ":sockjs_options"],
|
1763
|
-
[":def", "ws_loop", [":sequential", ":timeouts", ":ws"]],
|
1764
|
-
[":def", "wss_loop", [":sequential", ":timeouts", ":wss"]],
|
1765
|
-
[":def", "sockjs_loop", [":sequential", ":timeouts", ":sockjs"]],
|
1766
|
-
[":def", "streaming_loop", [":sequential", ":timeouts",
|
1767
|
-
[":if", [":is_supported", ":xhr_streaming"],
|
1768
|
-
":xhr_streaming",
|
1769
|
-
":xdr_streaming"
|
1770
|
-
]
|
1771
|
-
]],
|
1772
|
-
[":def", "polling_loop", [":sequential", ":timeouts",
|
1773
|
-
[":if", [":is_supported", ":xhr_polling"],
|
1774
|
-
":xhr_polling",
|
1775
|
-
":xdr_polling"
|
1776
|
-
]
|
1777
|
-
]],
|
1778
|
-
[":def", "http_loop", [":if", [":is_supported", ":streaming_loop"], [
|
1779
|
-
":best_connected_ever",
|
1780
|
-
":streaming_loop",
|
1781
|
-
[":delayed", 4000, [":polling_loop"]]
|
1782
|
-
], [
|
1783
|
-
":polling_loop"
|
1784
|
-
]]],
|
1785
|
-
[":def", "http_fallback_loop",
|
1786
|
-
[":if", [":is_supported", ":http_loop"], [
|
1787
|
-
":http_loop"
|
1788
|
-
], [
|
1789
|
-
":sockjs_loop"
|
1790
|
-
]]
|
1791
|
-
],
|
1792
|
-
[":def", "strategy",
|
1793
|
-
[":cached", 1800000,
|
1794
|
-
[":first_connected",
|
1795
|
-
[":if", [":is_supported", ":ws"],
|
1796
|
-
wsStrategy,
|
1797
|
-
":http_fallback_loop"
|
1798
|
-
]
|
1799
|
-
]
|
1800
|
-
]
|
1801
|
-
]
|
1802
|
-
];
|
1803
|
-
};
|
1804
|
-
exports.__esModule = true;
|
1805
|
-
exports["default"] = getDefaultStrategy;
|
1806
|
-
|
1807
|
-
|
1808
|
-
/***/ }),
|
1809
|
-
/* 28 */
|
1810
|
-
/***/ (function(module, exports, __webpack_require__) {
|
1811
|
-
|
1812
|
-
"use strict";
|
1813
|
-
var dependencies_1 = __webpack_require__(3);
|
1814
|
-
function default_1() {
|
1815
|
-
var self = this;
|
1816
|
-
self.timeline.info(self.buildTimelineMessage({
|
1817
|
-
transport: self.name + (self.options.encrypted ? "s" : "")
|
1818
|
-
}));
|
1819
|
-
if (self.hooks.isInitialized()) {
|
1820
|
-
self.changeState("initialized");
|
1821
|
-
}
|
1822
|
-
else if (self.hooks.file) {
|
1823
|
-
self.changeState("initializing");
|
1824
|
-
dependencies_1.Dependencies.load(self.hooks.file, { encrypted: self.options.encrypted }, function (error, callback) {
|
1825
|
-
if (self.hooks.isInitialized()) {
|
1826
|
-
self.changeState("initialized");
|
1827
|
-
callback(true);
|
1828
|
-
}
|
1829
|
-
else {
|
1830
|
-
if (error) {
|
1831
|
-
self.onError(error);
|
1832
|
-
}
|
1833
|
-
self.onClose();
|
1834
|
-
callback(false);
|
1835
|
-
}
|
1836
|
-
});
|
1837
|
-
}
|
1838
|
-
else {
|
1839
|
-
self.onClose();
|
1840
|
-
}
|
1841
|
-
}
|
1842
|
-
exports.__esModule = true;
|
1843
|
-
exports["default"] = default_1;
|
1844
|
-
|
1845
|
-
|
1846
|
-
/***/ }),
|
1847
|
-
/* 29 */
|
1848
|
-
/***/ (function(module, exports, __webpack_require__) {
|
1849
|
-
|
1850
|
-
"use strict";
|
1851
|
-
var http_xdomain_request_1 = __webpack_require__(30);
|
1852
|
-
var http_1 = __webpack_require__(32);
|
1853
|
-
http_1["default"].createXDR = function (method, url) {
|
1854
|
-
return this.createRequest(http_xdomain_request_1["default"], method, url);
|
1855
|
-
};
|
1856
|
-
exports.__esModule = true;
|
1857
|
-
exports["default"] = http_1["default"];
|
1858
|
-
|
1859
|
-
|
1860
|
-
/***/ }),
|
1861
|
-
/* 30 */
|
1862
|
-
/***/ (function(module, exports, __webpack_require__) {
|
1863
|
-
|
1864
|
-
"use strict";
|
1865
|
-
var Errors = __webpack_require__(31);
|
1866
|
-
var hooks = {
|
1867
|
-
getRequest: function (socket) {
|
1868
|
-
var xdr = new window.XDomainRequest();
|
1869
|
-
xdr.ontimeout = function () {
|
1870
|
-
socket.emit("error", new Errors.RequestTimedOut());
|
1871
|
-
socket.close();
|
1872
|
-
};
|
1873
|
-
xdr.onerror = function (e) {
|
1874
|
-
socket.emit("error", e);
|
1875
|
-
socket.close();
|
1876
|
-
};
|
1877
|
-
xdr.onprogress = function () {
|
1878
|
-
if (xdr.responseText && xdr.responseText.length > 0) {
|
1879
|
-
socket.onChunk(200, xdr.responseText);
|
1880
|
-
}
|
1881
|
-
};
|
1882
|
-
xdr.onload = function () {
|
1883
|
-
if (xdr.responseText && xdr.responseText.length > 0) {
|
1884
|
-
socket.onChunk(200, xdr.responseText);
|
1885
|
-
}
|
1886
|
-
socket.emit("finished", 200);
|
1887
|
-
socket.close();
|
1888
|
-
};
|
1889
|
-
return xdr;
|
1890
|
-
},
|
1891
|
-
abortRequest: function (xdr) {
|
1892
|
-
xdr.ontimeout = xdr.onerror = xdr.onprogress = xdr.onload = null;
|
1893
|
-
xdr.abort();
|
1894
|
-
}
|
1895
|
-
};
|
1896
|
-
exports.__esModule = true;
|
1897
|
-
exports["default"] = hooks;
|
1898
|
-
|
1899
|
-
|
1900
|
-
/***/ }),
|
1901
|
-
/* 31 */
|
1902
|
-
/***/ (function(module, exports) {
|
1903
|
-
|
1904
|
-
"use strict";
|
1905
|
-
var __extends = (this && this.__extends) || function (d, b) {
|
1906
|
-
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
1907
|
-
function __() { this.constructor = d; }
|
1908
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
1909
|
-
};
|
1910
|
-
var BadEventName = (function (_super) {
|
1911
|
-
__extends(BadEventName, _super);
|
1912
|
-
function BadEventName() {
|
1913
|
-
_super.apply(this, arguments);
|
1914
|
-
}
|
1915
|
-
return BadEventName;
|
1916
|
-
}(Error));
|
1917
|
-
exports.BadEventName = BadEventName;
|
1918
|
-
var RequestTimedOut = (function (_super) {
|
1919
|
-
__extends(RequestTimedOut, _super);
|
1920
|
-
function RequestTimedOut() {
|
1921
|
-
_super.apply(this, arguments);
|
1922
|
-
}
|
1923
|
-
return RequestTimedOut;
|
1924
|
-
}(Error));
|
1925
|
-
exports.RequestTimedOut = RequestTimedOut;
|
1926
|
-
var TransportPriorityTooLow = (function (_super) {
|
1927
|
-
__extends(TransportPriorityTooLow, _super);
|
1928
|
-
function TransportPriorityTooLow() {
|
1929
|
-
_super.apply(this, arguments);
|
1930
|
-
}
|
1931
|
-
return TransportPriorityTooLow;
|
1932
|
-
}(Error));
|
1933
|
-
exports.TransportPriorityTooLow = TransportPriorityTooLow;
|
1934
|
-
var TransportClosed = (function (_super) {
|
1935
|
-
__extends(TransportClosed, _super);
|
1936
|
-
function TransportClosed() {
|
1937
|
-
_super.apply(this, arguments);
|
1938
|
-
}
|
1939
|
-
return TransportClosed;
|
1940
|
-
}(Error));
|
1941
|
-
exports.TransportClosed = TransportClosed;
|
1942
|
-
var UnsupportedTransport = (function (_super) {
|
1943
|
-
__extends(UnsupportedTransport, _super);
|
1944
|
-
function UnsupportedTransport() {
|
1945
|
-
_super.apply(this, arguments);
|
1946
|
-
}
|
1947
|
-
return UnsupportedTransport;
|
1948
|
-
}(Error));
|
1949
|
-
exports.UnsupportedTransport = UnsupportedTransport;
|
1950
|
-
var UnsupportedStrategy = (function (_super) {
|
1951
|
-
__extends(UnsupportedStrategy, _super);
|
1952
|
-
function UnsupportedStrategy() {
|
1953
|
-
_super.apply(this, arguments);
|
1954
|
-
}
|
1955
|
-
return UnsupportedStrategy;
|
1956
|
-
}(Error));
|
1957
|
-
exports.UnsupportedStrategy = UnsupportedStrategy;
|
1958
|
-
|
1959
|
-
|
1960
|
-
/***/ }),
|
1961
|
-
/* 32 */
|
1962
|
-
/***/ (function(module, exports, __webpack_require__) {
|
1963
|
-
|
1964
|
-
"use strict";
|
1965
|
-
var http_request_1 = __webpack_require__(33);
|
1966
|
-
var http_socket_1 = __webpack_require__(34);
|
1967
|
-
var http_streaming_socket_1 = __webpack_require__(36);
|
1968
|
-
var http_polling_socket_1 = __webpack_require__(37);
|
1969
|
-
var http_xhr_request_1 = __webpack_require__(38);
|
1970
|
-
var HTTP = {
|
1971
|
-
createStreamingSocket: function (url) {
|
1972
|
-
return this.createSocket(http_streaming_socket_1["default"], url);
|
1973
|
-
},
|
1974
|
-
createPollingSocket: function (url) {
|
1975
|
-
return this.createSocket(http_polling_socket_1["default"], url);
|
1976
|
-
},
|
1977
|
-
createSocket: function (hooks, url) {
|
1978
|
-
return new http_socket_1["default"](hooks, url);
|
1979
|
-
},
|
1980
|
-
createXHR: function (method, url) {
|
1981
|
-
return this.createRequest(http_xhr_request_1["default"], method, url);
|
1982
|
-
},
|
1983
|
-
createRequest: function (hooks, method, url) {
|
1984
|
-
return new http_request_1["default"](hooks, method, url);
|
1985
|
-
}
|
1986
|
-
};
|
1987
|
-
exports.__esModule = true;
|
1988
|
-
exports["default"] = HTTP;
|
1989
|
-
|
1990
|
-
|
1991
|
-
/***/ }),
|
1992
|
-
/* 33 */
|
1993
|
-
/***/ (function(module, exports, __webpack_require__) {
|
1994
|
-
|
1995
|
-
"use strict";
|
1996
|
-
var __extends = (this && this.__extends) || function (d, b) {
|
1997
|
-
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
1998
|
-
function __() { this.constructor = d; }
|
1999
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
2000
|
-
};
|
2001
|
-
var runtime_1 = __webpack_require__(2);
|
2002
|
-
var dispatcher_1 = __webpack_require__(24);
|
2003
|
-
var MAX_BUFFER_LENGTH = 256 * 1024;
|
2004
|
-
var HTTPRequest = (function (_super) {
|
2005
|
-
__extends(HTTPRequest, _super);
|
2006
|
-
function HTTPRequest(hooks, method, url) {
|
2007
|
-
_super.call(this);
|
2008
|
-
this.hooks = hooks;
|
2009
|
-
this.method = method;
|
2010
|
-
this.url = url;
|
2011
|
-
}
|
2012
|
-
HTTPRequest.prototype.start = function (payload) {
|
2013
|
-
var _this = this;
|
2014
|
-
this.position = 0;
|
2015
|
-
this.xhr = this.hooks.getRequest(this);
|
2016
|
-
this.unloader = function () {
|
2017
|
-
_this.close();
|
2018
|
-
};
|
2019
|
-
runtime_1["default"].addUnloadListener(this.unloader);
|
2020
|
-
this.xhr.open(this.method, this.url, true);
|
2021
|
-
if (this.xhr.setRequestHeader) {
|
2022
|
-
this.xhr.setRequestHeader("Content-Type", "application/json");
|
2023
|
-
}
|
2024
|
-
this.xhr.send(payload);
|
2025
|
-
};
|
2026
|
-
HTTPRequest.prototype.close = function () {
|
2027
|
-
if (this.unloader) {
|
2028
|
-
runtime_1["default"].removeUnloadListener(this.unloader);
|
2029
|
-
this.unloader = null;
|
2030
|
-
}
|
2031
|
-
if (this.xhr) {
|
2032
|
-
this.hooks.abortRequest(this.xhr);
|
2033
|
-
this.xhr = null;
|
2034
|
-
}
|
2035
|
-
};
|
2036
|
-
HTTPRequest.prototype.onChunk = function (status, data) {
|
2037
|
-
while (true) {
|
2038
|
-
var chunk = this.advanceBuffer(data);
|
2039
|
-
if (chunk) {
|
2040
|
-
this.emit("chunk", { status: status, data: chunk });
|
2041
|
-
}
|
2042
|
-
else {
|
2043
|
-
break;
|
2044
|
-
}
|
2045
|
-
}
|
2046
|
-
if (this.isBufferTooLong(data)) {
|
2047
|
-
this.emit("buffer_too_long");
|
2048
|
-
}
|
2049
|
-
};
|
2050
|
-
HTTPRequest.prototype.advanceBuffer = function (buffer) {
|
2051
|
-
var unreadData = buffer.slice(this.position);
|
2052
|
-
var endOfLinePosition = unreadData.indexOf("\n");
|
2053
|
-
if (endOfLinePosition !== -1) {
|
2054
|
-
this.position += endOfLinePosition + 1;
|
2055
|
-
return unreadData.slice(0, endOfLinePosition);
|
2056
|
-
}
|
2057
|
-
else {
|
2058
|
-
return null;
|
2059
|
-
}
|
2060
|
-
};
|
2061
|
-
HTTPRequest.prototype.isBufferTooLong = function (buffer) {
|
2062
|
-
return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;
|
2063
|
-
};
|
2064
|
-
return HTTPRequest;
|
2065
|
-
}(dispatcher_1["default"]));
|
2066
|
-
exports.__esModule = true;
|
2067
|
-
exports["default"] = HTTPRequest;
|
2068
|
-
|
2069
|
-
|
2070
|
-
/***/ }),
|
2071
|
-
/* 34 */
|
2072
|
-
/***/ (function(module, exports, __webpack_require__) {
|
2073
|
-
|
2074
|
-
"use strict";
|
2075
|
-
var state_1 = __webpack_require__(35);
|
2076
|
-
var util_1 = __webpack_require__(11);
|
2077
|
-
var runtime_1 = __webpack_require__(2);
|
2078
|
-
var autoIncrement = 1;
|
2079
|
-
var HTTPSocket = (function () {
|
2080
|
-
function HTTPSocket(hooks, url) {
|
2081
|
-
this.hooks = hooks;
|
2082
|
-
this.session = randomNumber(1000) + "/" + randomString(8);
|
2083
|
-
this.location = getLocation(url);
|
2084
|
-
this.readyState = state_1["default"].CONNECTING;
|
2085
|
-
this.openStream();
|
2086
|
-
}
|
2087
|
-
HTTPSocket.prototype.send = function (payload) {
|
2088
|
-
return this.sendRaw(JSON.stringify([payload]));
|
2089
|
-
};
|
2090
|
-
HTTPSocket.prototype.ping = function () {
|
2091
|
-
this.hooks.sendHeartbeat(this);
|
2092
|
-
};
|
2093
|
-
HTTPSocket.prototype.close = function (code, reason) {
|
2094
|
-
this.onClose(code, reason, true);
|
2095
|
-
};
|
2096
|
-
HTTPSocket.prototype.sendRaw = function (payload) {
|
2097
|
-
if (this.readyState === state_1["default"].OPEN) {
|
2098
|
-
try {
|
2099
|
-
runtime_1["default"].createSocketRequest("POST", getUniqueURL(getSendURL(this.location, this.session))).start(payload);
|
2100
|
-
return true;
|
2101
|
-
}
|
2102
|
-
catch (e) {
|
2103
|
-
return false;
|
2104
|
-
}
|
2105
|
-
}
|
2106
|
-
else {
|
2107
|
-
return false;
|
2108
|
-
}
|
2109
|
-
};
|
2110
|
-
HTTPSocket.prototype.reconnect = function () {
|
2111
|
-
this.closeStream();
|
2112
|
-
this.openStream();
|
2113
|
-
};
|
2114
|
-
;
|
2115
|
-
HTTPSocket.prototype.onClose = function (code, reason, wasClean) {
|
2116
|
-
this.closeStream();
|
2117
|
-
this.readyState = state_1["default"].CLOSED;
|
2118
|
-
if (this.onclose) {
|
2119
|
-
this.onclose({
|
2120
|
-
code: code,
|
2121
|
-
reason: reason,
|
2122
|
-
wasClean: wasClean
|
2123
|
-
});
|
2124
|
-
}
|
2125
|
-
};
|
2126
|
-
HTTPSocket.prototype.onChunk = function (chunk) {
|
2127
|
-
if (chunk.status !== 200) {
|
2128
|
-
return;
|
2129
|
-
}
|
2130
|
-
if (this.readyState === state_1["default"].OPEN) {
|
2131
|
-
this.onActivity();
|
2132
|
-
}
|
2133
|
-
var payload;
|
2134
|
-
var type = chunk.data.slice(0, 1);
|
2135
|
-
switch (type) {
|
2136
|
-
case 'o':
|
2137
|
-
payload = JSON.parse(chunk.data.slice(1) || '{}');
|
2138
|
-
this.onOpen(payload);
|
2139
|
-
break;
|
2140
|
-
case 'a':
|
2141
|
-
payload = JSON.parse(chunk.data.slice(1) || '[]');
|
2142
|
-
for (var i = 0; i < payload.length; i++) {
|
2143
|
-
this.onEvent(payload[i]);
|
2144
|
-
}
|
2145
|
-
break;
|
2146
|
-
case 'm':
|
2147
|
-
payload = JSON.parse(chunk.data.slice(1) || 'null');
|
2148
|
-
this.onEvent(payload);
|
2149
|
-
break;
|
2150
|
-
case 'h':
|
2151
|
-
this.hooks.onHeartbeat(this);
|
2152
|
-
break;
|
2153
|
-
case 'c':
|
2154
|
-
payload = JSON.parse(chunk.data.slice(1) || '[]');
|
2155
|
-
this.onClose(payload[0], payload[1], true);
|
2156
|
-
break;
|
2157
|
-
}
|
2158
|
-
};
|
2159
|
-
HTTPSocket.prototype.onOpen = function (options) {
|
2160
|
-
if (this.readyState === state_1["default"].CONNECTING) {
|
2161
|
-
if (options && options.hostname) {
|
2162
|
-
this.location.base = replaceHost(this.location.base, options.hostname);
|
2163
|
-
}
|
2164
|
-
this.readyState = state_1["default"].OPEN;
|
2165
|
-
if (this.onopen) {
|
2166
|
-
this.onopen();
|
2167
|
-
}
|
2168
|
-
}
|
2169
|
-
else {
|
2170
|
-
this.onClose(1006, "Server lost session", true);
|
2171
|
-
}
|
2172
|
-
};
|
2173
|
-
HTTPSocket.prototype.onEvent = function (event) {
|
2174
|
-
if (this.readyState === state_1["default"].OPEN && this.onmessage) {
|
2175
|
-
this.onmessage({ data: event });
|
2176
|
-
}
|
2177
|
-
};
|
2178
|
-
HTTPSocket.prototype.onActivity = function () {
|
2179
|
-
if (this.onactivity) {
|
2180
|
-
this.onactivity();
|
2181
|
-
}
|
2182
|
-
};
|
2183
|
-
HTTPSocket.prototype.onError = function (error) {
|
2184
|
-
if (this.onerror) {
|
2185
|
-
this.onerror(error);
|
2186
|
-
}
|
2187
|
-
};
|
2188
|
-
HTTPSocket.prototype.openStream = function () {
|
2189
|
-
var _this = this;
|
2190
|
-
this.stream = runtime_1["default"].createSocketRequest("POST", getUniqueURL(this.hooks.getReceiveURL(this.location, this.session)));
|
2191
|
-
this.stream.bind("chunk", function (chunk) {
|
2192
|
-
_this.onChunk(chunk);
|
2193
|
-
});
|
2194
|
-
this.stream.bind("finished", function (status) {
|
2195
|
-
_this.hooks.onFinished(_this, status);
|
2196
|
-
});
|
2197
|
-
this.stream.bind("buffer_too_long", function () {
|
2198
|
-
_this.reconnect();
|
2199
|
-
});
|
2200
|
-
try {
|
2201
|
-
this.stream.start();
|
2202
|
-
}
|
2203
|
-
catch (error) {
|
2204
|
-
util_1["default"].defer(function () {
|
2205
|
-
_this.onError(error);
|
2206
|
-
_this.onClose(1006, "Could not start streaming", false);
|
2207
|
-
});
|
2208
|
-
}
|
2209
|
-
};
|
2210
|
-
HTTPSocket.prototype.closeStream = function () {
|
2211
|
-
if (this.stream) {
|
2212
|
-
this.stream.unbind_all();
|
2213
|
-
this.stream.close();
|
2214
|
-
this.stream = null;
|
2215
|
-
}
|
2216
|
-
};
|
2217
|
-
return HTTPSocket;
|
2218
|
-
}());
|
2219
|
-
function getLocation(url) {
|
2220
|
-
var parts = /([^\?]*)\/*(\??.*)/.exec(url);
|
2221
|
-
return {
|
2222
|
-
base: parts[1],
|
2223
|
-
queryString: parts[2]
|
2224
|
-
};
|
2225
|
-
}
|
2226
|
-
function getSendURL(url, session) {
|
2227
|
-
return url.base + "/" + session + "/xhr_send";
|
2228
|
-
}
|
2229
|
-
function getUniqueURL(url) {
|
2230
|
-
var separator = (url.indexOf('?') === -1) ? "?" : "&";
|
2231
|
-
return url + separator + "t=" + (+new Date()) + "&n=" + autoIncrement++;
|
2232
|
-
}
|
2233
|
-
function replaceHost(url, hostname) {
|
2234
|
-
var urlParts = /(https?:\/\/)([^\/:]+)((\/|:)?.*)/.exec(url);
|
2235
|
-
return urlParts[1] + hostname + urlParts[3];
|
2236
|
-
}
|
2237
|
-
function randomNumber(max) {
|
2238
|
-
return Math.floor(Math.random() * max);
|
2239
|
-
}
|
2240
|
-
function randomString(length) {
|
2241
|
-
var result = [];
|
2242
|
-
for (var i = 0; i < length; i++) {
|
2243
|
-
result.push(randomNumber(32).toString(32));
|
2244
|
-
}
|
2245
|
-
return result.join('');
|
2246
|
-
}
|
2247
|
-
exports.__esModule = true;
|
2248
|
-
exports["default"] = HTTPSocket;
|
2249
|
-
|
2250
|
-
|
2251
|
-
/***/ }),
|
2252
|
-
/* 35 */
|
2253
|
-
/***/ (function(module, exports) {
|
2254
|
-
|
2255
|
-
"use strict";
|
2256
|
-
var State;
|
2257
|
-
(function (State) {
|
2258
|
-
State[State["CONNECTING"] = 0] = "CONNECTING";
|
2259
|
-
State[State["OPEN"] = 1] = "OPEN";
|
2260
|
-
State[State["CLOSED"] = 3] = "CLOSED";
|
2261
|
-
})(State || (State = {}));
|
2262
|
-
exports.__esModule = true;
|
2263
|
-
exports["default"] = State;
|
2264
|
-
|
2265
|
-
|
2266
|
-
/***/ }),
|
2267
|
-
/* 36 */
|
2268
|
-
/***/ (function(module, exports) {
|
2269
|
-
|
2270
|
-
"use strict";
|
2271
|
-
var hooks = {
|
2272
|
-
getReceiveURL: function (url, session) {
|
2273
|
-
return url.base + "/" + session + "/xhr_streaming" + url.queryString;
|
2274
|
-
},
|
2275
|
-
onHeartbeat: function (socket) {
|
2276
|
-
socket.sendRaw("[]");
|
2277
|
-
},
|
2278
|
-
sendHeartbeat: function (socket) {
|
2279
|
-
socket.sendRaw("[]");
|
2280
|
-
},
|
2281
|
-
onFinished: function (socket, status) {
|
2282
|
-
socket.onClose(1006, "Connection interrupted (" + status + ")", false);
|
2283
|
-
}
|
2284
|
-
};
|
2285
|
-
exports.__esModule = true;
|
2286
|
-
exports["default"] = hooks;
|
2287
|
-
|
2288
|
-
|
2289
|
-
/***/ }),
|
2290
|
-
/* 37 */
|
2291
|
-
/***/ (function(module, exports) {
|
2292
|
-
|
2293
|
-
"use strict";
|
2294
|
-
var hooks = {
|
2295
|
-
getReceiveURL: function (url, session) {
|
2296
|
-
return url.base + "/" + session + "/xhr" + url.queryString;
|
2297
|
-
},
|
2298
|
-
onHeartbeat: function () {
|
2299
|
-
},
|
2300
|
-
sendHeartbeat: function (socket) {
|
2301
|
-
socket.sendRaw("[]");
|
2302
|
-
},
|
2303
|
-
onFinished: function (socket, status) {
|
2304
|
-
if (status === 200) {
|
2305
|
-
socket.reconnect();
|
2306
|
-
}
|
2307
|
-
else {
|
2308
|
-
socket.onClose(1006, "Connection interrupted (" + status + ")", false);
|
2309
|
-
}
|
2310
|
-
}
|
2311
|
-
};
|
2312
|
-
exports.__esModule = true;
|
2313
|
-
exports["default"] = hooks;
|
2314
|
-
|
2315
|
-
|
2316
|
-
/***/ }),
|
2317
|
-
/* 38 */
|
2318
|
-
/***/ (function(module, exports, __webpack_require__) {
|
2319
|
-
|
2320
|
-
"use strict";
|
2321
|
-
var runtime_1 = __webpack_require__(2);
|
2322
|
-
var hooks = {
|
2323
|
-
getRequest: function (socket) {
|
2324
|
-
var Constructor = runtime_1["default"].getXHRAPI();
|
2325
|
-
var xhr = new Constructor();
|
2326
|
-
xhr.onreadystatechange = xhr.onprogress = function () {
|
2327
|
-
switch (xhr.readyState) {
|
2328
|
-
case 3:
|
2329
|
-
if (xhr.responseText && xhr.responseText.length > 0) {
|
2330
|
-
socket.onChunk(xhr.status, xhr.responseText);
|
2331
|
-
}
|
2332
|
-
break;
|
2333
|
-
case 4:
|
2334
|
-
if (xhr.responseText && xhr.responseText.length > 0) {
|
2335
|
-
socket.onChunk(xhr.status, xhr.responseText);
|
2336
|
-
}
|
2337
|
-
socket.emit("finished", xhr.status);
|
2338
|
-
socket.close();
|
2339
|
-
break;
|
2340
|
-
}
|
2341
|
-
};
|
2342
|
-
return xhr;
|
2343
|
-
},
|
2344
|
-
abortRequest: function (xhr) {
|
2345
|
-
xhr.onreadystatechange = null;
|
2346
|
-
xhr.abort();
|
2347
|
-
}
|
2348
|
-
};
|
2349
|
-
exports.__esModule = true;
|
2350
|
-
exports["default"] = hooks;
|
2351
|
-
|
2352
|
-
|
2353
|
-
/***/ }),
|
2354
|
-
/* 39 */
|
2355
|
-
/***/ (function(module, exports, __webpack_require__) {
|
2356
|
-
|
2357
|
-
"use strict";
|
2358
|
-
var Collections = __webpack_require__(9);
|
2359
|
-
var util_1 = __webpack_require__(11);
|
2360
|
-
var level_1 = __webpack_require__(40);
|
2361
|
-
var Timeline = (function () {
|
2362
|
-
function Timeline(key, session, options) {
|
2363
|
-
this.key = key;
|
2364
|
-
this.session = session;
|
2365
|
-
this.events = [];
|
2366
|
-
this.options = options || {};
|
2367
|
-
this.sent = 0;
|
2368
|
-
this.uniqueID = 0;
|
2369
|
-
}
|
2370
|
-
Timeline.prototype.log = function (level, event) {
|
2371
|
-
if (level <= this.options.level) {
|
2372
|
-
this.events.push(Collections.extend({}, event, { timestamp: util_1["default"].now() }));
|
2373
|
-
if (this.options.limit && this.events.length > this.options.limit) {
|
2374
|
-
this.events.shift();
|
2375
|
-
}
|
2376
|
-
}
|
2377
|
-
};
|
2378
|
-
Timeline.prototype.error = function (event) {
|
2379
|
-
this.log(level_1["default"].ERROR, event);
|
2380
|
-
};
|
2381
|
-
Timeline.prototype.info = function (event) {
|
2382
|
-
this.log(level_1["default"].INFO, event);
|
2383
|
-
};
|
2384
|
-
Timeline.prototype.debug = function (event) {
|
2385
|
-
this.log(level_1["default"].DEBUG, event);
|
2386
|
-
};
|
2387
|
-
Timeline.prototype.isEmpty = function () {
|
2388
|
-
return this.events.length === 0;
|
2389
|
-
};
|
2390
|
-
Timeline.prototype.send = function (sendfn, callback) {
|
2391
|
-
var _this = this;
|
2392
|
-
var data = Collections.extend({
|
2393
|
-
session: this.session,
|
2394
|
-
bundle: this.sent + 1,
|
2395
|
-
key: this.key,
|
2396
|
-
lib: "js",
|
2397
|
-
version: this.options.version,
|
2398
|
-
cluster: this.options.cluster,
|
2399
|
-
features: this.options.features,
|
2400
|
-
timeline: this.events
|
2401
|
-
}, this.options.params);
|
2402
|
-
this.events = [];
|
2403
|
-
sendfn(data, function (error, result) {
|
2404
|
-
if (!error) {
|
2405
|
-
_this.sent++;
|
2406
|
-
}
|
2407
|
-
if (callback) {
|
2408
|
-
callback(error, result);
|
2409
|
-
}
|
2410
|
-
});
|
2411
|
-
return true;
|
2412
|
-
};
|
2413
|
-
Timeline.prototype.generateUniqueID = function () {
|
2414
|
-
this.uniqueID++;
|
2415
|
-
return this.uniqueID;
|
2416
|
-
};
|
2417
|
-
return Timeline;
|
2418
|
-
}());
|
2419
|
-
exports.__esModule = true;
|
2420
|
-
exports["default"] = Timeline;
|
2421
|
-
|
2422
|
-
|
2423
|
-
/***/ }),
|
2424
|
-
/* 40 */
|
2425
|
-
/***/ (function(module, exports) {
|
2426
|
-
|
2427
|
-
"use strict";
|
2428
|
-
var TimelineLevel;
|
2429
|
-
(function (TimelineLevel) {
|
2430
|
-
TimelineLevel[TimelineLevel["ERROR"] = 3] = "ERROR";
|
2431
|
-
TimelineLevel[TimelineLevel["INFO"] = 6] = "INFO";
|
2432
|
-
TimelineLevel[TimelineLevel["DEBUG"] = 7] = "DEBUG";
|
2433
|
-
})(TimelineLevel || (TimelineLevel = {}));
|
2434
|
-
exports.__esModule = true;
|
2435
|
-
exports["default"] = TimelineLevel;
|
2436
|
-
|
2437
|
-
|
2438
|
-
/***/ }),
|
2439
|
-
/* 41 */
|
2440
|
-
/***/ (function(module, exports, __webpack_require__) {
|
2441
|
-
|
2442
|
-
"use strict";
|
2443
|
-
var Collections = __webpack_require__(9);
|
2444
|
-
var util_1 = __webpack_require__(11);
|
2445
|
-
var transport_manager_1 = __webpack_require__(42);
|
2446
|
-
var Errors = __webpack_require__(31);
|
2447
|
-
var transport_strategy_1 = __webpack_require__(56);
|
2448
|
-
var sequential_strategy_1 = __webpack_require__(57);
|
2449
|
-
var best_connected_ever_strategy_1 = __webpack_require__(58);
|
2450
|
-
var cached_strategy_1 = __webpack_require__(59);
|
2451
|
-
var delayed_strategy_1 = __webpack_require__(60);
|
2452
|
-
var if_strategy_1 = __webpack_require__(61);
|
2453
|
-
var first_connected_strategy_1 = __webpack_require__(62);
|
2454
|
-
var runtime_1 = __webpack_require__(2);
|
2455
|
-
var Transports = runtime_1["default"].Transports;
|
2456
|
-
exports.build = function (scheme, options) {
|
2457
|
-
var context = Collections.extend({}, globalContext, options);
|
2458
|
-
return evaluate(scheme, context)[1].strategy;
|
2459
|
-
};
|
2460
|
-
var UnsupportedStrategy = {
|
2461
|
-
isSupported: function () {
|
2462
|
-
return false;
|
2463
|
-
},
|
2464
|
-
connect: function (_, callback) {
|
2465
|
-
var deferred = util_1["default"].defer(function () {
|
2466
|
-
callback(new Errors.UnsupportedStrategy());
|
2467
|
-
});
|
2468
|
-
return {
|
2469
|
-
abort: function () {
|
2470
|
-
deferred.ensureAborted();
|
2471
|
-
},
|
2472
|
-
forceMinPriority: function () { }
|
2473
|
-
};
|
2474
|
-
}
|
2475
|
-
};
|
2476
|
-
function returnWithOriginalContext(f) {
|
2477
|
-
return function (context) {
|
2478
|
-
return [f.apply(this, arguments), context];
|
2479
|
-
};
|
2480
|
-
}
|
2481
|
-
var globalContext = {
|
2482
|
-
extend: function (context, first, second) {
|
2483
|
-
return [Collections.extend({}, first, second), context];
|
2484
|
-
},
|
2485
|
-
def: function (context, name, value) {
|
2486
|
-
if (context[name] !== undefined) {
|
2487
|
-
throw "Redefining symbol " + name;
|
2488
|
-
}
|
2489
|
-
context[name] = value;
|
2490
|
-
return [undefined, context];
|
2491
|
-
},
|
2492
|
-
def_transport: function (context, name, type, priority, options, manager) {
|
2493
|
-
var transportClass = Transports[type];
|
2494
|
-
if (!transportClass) {
|
2495
|
-
throw new Errors.UnsupportedTransport(type);
|
2496
|
-
}
|
2497
|
-
var enabled = (!context.enabledTransports ||
|
2498
|
-
Collections.arrayIndexOf(context.enabledTransports, name) !== -1) &&
|
2499
|
-
(!context.disabledTransports ||
|
2500
|
-
Collections.arrayIndexOf(context.disabledTransports, name) === -1);
|
2501
|
-
var transport;
|
2502
|
-
if (enabled) {
|
2503
|
-
transport = new transport_strategy_1["default"](name, priority, manager ? manager.getAssistant(transportClass) : transportClass, Collections.extend({
|
2504
|
-
key: context.key,
|
2505
|
-
encrypted: context.encrypted,
|
2506
|
-
timeline: context.timeline,
|
2507
|
-
ignoreNullOrigin: context.ignoreNullOrigin
|
2508
|
-
}, options));
|
2509
|
-
}
|
2510
|
-
else {
|
2511
|
-
transport = UnsupportedStrategy;
|
2512
|
-
}
|
2513
|
-
var newContext = context.def(context, name, transport)[1];
|
2514
|
-
newContext.Transports = context.Transports || {};
|
2515
|
-
newContext.Transports[name] = transport;
|
2516
|
-
return [undefined, newContext];
|
2517
|
-
},
|
2518
|
-
transport_manager: returnWithOriginalContext(function (_, options) {
|
2519
|
-
return new transport_manager_1["default"](options);
|
2520
|
-
}),
|
2521
|
-
sequential: returnWithOriginalContext(function (_, options) {
|
2522
|
-
var strategies = Array.prototype.slice.call(arguments, 2);
|
2523
|
-
return new sequential_strategy_1["default"](strategies, options);
|
2524
|
-
}),
|
2525
|
-
cached: returnWithOriginalContext(function (context, ttl, strategy) {
|
2526
|
-
return new cached_strategy_1["default"](strategy, context.Transports, {
|
2527
|
-
ttl: ttl,
|
2528
|
-
timeline: context.timeline,
|
2529
|
-
encrypted: context.encrypted
|
2530
|
-
});
|
2531
|
-
}),
|
2532
|
-
first_connected: returnWithOriginalContext(function (_, strategy) {
|
2533
|
-
return new first_connected_strategy_1["default"](strategy);
|
2534
|
-
}),
|
2535
|
-
best_connected_ever: returnWithOriginalContext(function () {
|
2536
|
-
var strategies = Array.prototype.slice.call(arguments, 1);
|
2537
|
-
return new best_connected_ever_strategy_1["default"](strategies);
|
2538
|
-
}),
|
2539
|
-
delayed: returnWithOriginalContext(function (_, delay, strategy) {
|
2540
|
-
return new delayed_strategy_1["default"](strategy, { delay: delay });
|
2541
|
-
}),
|
2542
|
-
"if": returnWithOriginalContext(function (_, test, trueBranch, falseBranch) {
|
2543
|
-
return new if_strategy_1["default"](test, trueBranch, falseBranch);
|
2544
|
-
}),
|
2545
|
-
is_supported: returnWithOriginalContext(function (_, strategy) {
|
2546
|
-
return function () {
|
2547
|
-
return strategy.isSupported();
|
2548
|
-
};
|
2549
|
-
})
|
2550
|
-
};
|
2551
|
-
function isSymbol(expression) {
|
2552
|
-
return (typeof expression === "string") && expression.charAt(0) === ":";
|
2553
|
-
}
|
2554
|
-
function getSymbolValue(expression, context) {
|
2555
|
-
return context[expression.slice(1)];
|
2556
|
-
}
|
2557
|
-
function evaluateListOfExpressions(expressions, context) {
|
2558
|
-
if (expressions.length === 0) {
|
2559
|
-
return [[], context];
|
2560
|
-
}
|
2561
|
-
var head = evaluate(expressions[0], context);
|
2562
|
-
var tail = evaluateListOfExpressions(expressions.slice(1), head[1]);
|
2563
|
-
return [[head[0]].concat(tail[0]), tail[1]];
|
2564
|
-
}
|
2565
|
-
function evaluateString(expression, context) {
|
2566
|
-
if (!isSymbol(expression)) {
|
2567
|
-
return [expression, context];
|
2568
|
-
}
|
2569
|
-
var value = getSymbolValue(expression, context);
|
2570
|
-
if (value === undefined) {
|
2571
|
-
throw "Undefined symbol " + expression;
|
2572
|
-
}
|
2573
|
-
return [value, context];
|
2574
|
-
}
|
2575
|
-
function evaluateArray(expression, context) {
|
2576
|
-
if (isSymbol(expression[0])) {
|
2577
|
-
var f = getSymbolValue(expression[0], context);
|
2578
|
-
if (expression.length > 1) {
|
2579
|
-
if (typeof f !== "function") {
|
2580
|
-
throw "Calling non-function " + expression[0];
|
2581
|
-
}
|
2582
|
-
var args = [Collections.extend({}, context)].concat(Collections.map(expression.slice(1), function (arg) {
|
2583
|
-
return evaluate(arg, Collections.extend({}, context))[0];
|
2584
|
-
}));
|
2585
|
-
return f.apply(this, args);
|
2586
|
-
}
|
2587
|
-
else {
|
2588
|
-
return [f, context];
|
2589
|
-
}
|
2590
|
-
}
|
2591
|
-
else {
|
2592
|
-
return evaluateListOfExpressions(expression, context);
|
2593
|
-
}
|
2594
|
-
}
|
2595
|
-
function evaluate(expression, context) {
|
2596
|
-
if (typeof expression === "string") {
|
2597
|
-
return evaluateString(expression, context);
|
2598
|
-
}
|
2599
|
-
else if (typeof expression === "object") {
|
2600
|
-
if (expression instanceof Array && expression.length > 0) {
|
2601
|
-
return evaluateArray(expression, context);
|
2602
|
-
}
|
2603
|
-
}
|
2604
|
-
return [expression, context];
|
2605
|
-
}
|
2606
|
-
|
2607
|
-
|
2608
|
-
/***/ }),
|
2609
|
-
/* 42 */
|
2610
|
-
/***/ (function(module, exports, __webpack_require__) {
|
2611
|
-
|
2612
|
-
"use strict";
|
2613
|
-
var factory_1 = __webpack_require__(43);
|
2614
|
-
var TransportManager = (function () {
|
2615
|
-
function TransportManager(options) {
|
2616
|
-
this.options = options || {};
|
2617
|
-
this.livesLeft = this.options.lives || Infinity;
|
2618
|
-
}
|
2619
|
-
TransportManager.prototype.getAssistant = function (transport) {
|
2620
|
-
return factory_1["default"].createAssistantToTheTransportManager(this, transport, {
|
2621
|
-
minPingDelay: this.options.minPingDelay,
|
2622
|
-
maxPingDelay: this.options.maxPingDelay
|
2623
|
-
});
|
2624
|
-
};
|
2625
|
-
TransportManager.prototype.isAlive = function () {
|
2626
|
-
return this.livesLeft > 0;
|
2627
|
-
};
|
2628
|
-
TransportManager.prototype.reportDeath = function () {
|
2629
|
-
this.livesLeft -= 1;
|
2630
|
-
};
|
2631
|
-
return TransportManager;
|
2632
|
-
}());
|
2633
|
-
exports.__esModule = true;
|
2634
|
-
exports["default"] = TransportManager;
|
2635
|
-
|
2636
|
-
|
2637
|
-
/***/ }),
|
2638
|
-
/* 43 */
|
2639
|
-
/***/ (function(module, exports, __webpack_require__) {
|
2640
|
-
|
2641
|
-
"use strict";
|
2642
|
-
var assistant_to_the_transport_manager_1 = __webpack_require__(44);
|
2643
|
-
var handshake_1 = __webpack_require__(45);
|
2644
|
-
var pusher_authorizer_1 = __webpack_require__(48);
|
2645
|
-
var timeline_sender_1 = __webpack_require__(49);
|
2646
|
-
var presence_channel_1 = __webpack_require__(50);
|
2647
|
-
var private_channel_1 = __webpack_require__(51);
|
2648
|
-
var channel_1 = __webpack_require__(52);
|
2649
|
-
var connection_manager_1 = __webpack_require__(54);
|
2650
|
-
var channels_1 = __webpack_require__(55);
|
2651
|
-
var Factory = {
|
2652
|
-
createChannels: function () {
|
2653
|
-
return new channels_1["default"]();
|
2654
|
-
},
|
2655
|
-
createConnectionManager: function (key, options) {
|
2656
|
-
return new connection_manager_1["default"](key, options);
|
2657
|
-
},
|
2658
|
-
createChannel: function (name, pusher) {
|
2659
|
-
return new channel_1["default"](name, pusher);
|
2660
|
-
},
|
2661
|
-
createPrivateChannel: function (name, pusher) {
|
2662
|
-
return new private_channel_1["default"](name, pusher);
|
2663
|
-
},
|
2664
|
-
createPresenceChannel: function (name, pusher) {
|
2665
|
-
return new presence_channel_1["default"](name, pusher);
|
2666
|
-
},
|
2667
|
-
createTimelineSender: function (timeline, options) {
|
2668
|
-
return new timeline_sender_1["default"](timeline, options);
|
2669
|
-
},
|
2670
|
-
createAuthorizer: function (channel, options) {
|
2671
|
-
if (options.authorizer) {
|
2672
|
-
return options.authorizer(channel, options);
|
2673
|
-
}
|
2674
|
-
return new pusher_authorizer_1["default"](channel, options);
|
2675
|
-
},
|
2676
|
-
createHandshake: function (transport, callback) {
|
2677
|
-
return new handshake_1["default"](transport, callback);
|
2678
|
-
},
|
2679
|
-
createAssistantToTheTransportManager: function (manager, transport, options) {
|
2680
|
-
return new assistant_to_the_transport_manager_1["default"](manager, transport, options);
|
2681
|
-
}
|
2682
|
-
};
|
2683
|
-
exports.__esModule = true;
|
2684
|
-
exports["default"] = Factory;
|
2685
|
-
|
2686
|
-
|
2687
|
-
/***/ }),
|
2688
|
-
/* 44 */
|
2689
|
-
/***/ (function(module, exports, __webpack_require__) {
|
2690
|
-
|
2691
|
-
"use strict";
|
2692
|
-
var util_1 = __webpack_require__(11);
|
2693
|
-
var Collections = __webpack_require__(9);
|
2694
|
-
var AssistantToTheTransportManager = (function () {
|
2695
|
-
function AssistantToTheTransportManager(manager, transport, options) {
|
2696
|
-
this.manager = manager;
|
2697
|
-
this.transport = transport;
|
2698
|
-
this.minPingDelay = options.minPingDelay;
|
2699
|
-
this.maxPingDelay = options.maxPingDelay;
|
2700
|
-
this.pingDelay = undefined;
|
2701
|
-
}
|
2702
|
-
AssistantToTheTransportManager.prototype.createConnection = function (name, priority, key, options) {
|
2703
|
-
var _this = this;
|
2704
|
-
options = Collections.extend({}, options, {
|
2705
|
-
activityTimeout: this.pingDelay
|
2706
|
-
});
|
2707
|
-
var connection = this.transport.createConnection(name, priority, key, options);
|
2708
|
-
var openTimestamp = null;
|
2709
|
-
var onOpen = function () {
|
2710
|
-
connection.unbind("open", onOpen);
|
2711
|
-
connection.bind("closed", onClosed);
|
2712
|
-
openTimestamp = util_1["default"].now();
|
2713
|
-
};
|
2714
|
-
var onClosed = function (closeEvent) {
|
2715
|
-
connection.unbind("closed", onClosed);
|
2716
|
-
if (closeEvent.code === 1002 || closeEvent.code === 1003) {
|
2717
|
-
_this.manager.reportDeath();
|
2718
|
-
}
|
2719
|
-
else if (!closeEvent.wasClean && openTimestamp) {
|
2720
|
-
var lifespan = util_1["default"].now() - openTimestamp;
|
2721
|
-
if (lifespan < 2 * _this.maxPingDelay) {
|
2722
|
-
_this.manager.reportDeath();
|
2723
|
-
_this.pingDelay = Math.max(lifespan / 2, _this.minPingDelay);
|
2724
|
-
}
|
2725
|
-
}
|
2726
|
-
};
|
2727
|
-
connection.bind("open", onOpen);
|
2728
|
-
return connection;
|
2729
|
-
};
|
2730
|
-
AssistantToTheTransportManager.prototype.isSupported = function (environment) {
|
2731
|
-
return this.manager.isAlive() && this.transport.isSupported(environment);
|
2732
|
-
};
|
2733
|
-
return AssistantToTheTransportManager;
|
2734
|
-
}());
|
2735
|
-
exports.__esModule = true;
|
2736
|
-
exports["default"] = AssistantToTheTransportManager;
|
2737
|
-
|
2738
|
-
|
2739
|
-
/***/ }),
|
2740
|
-
/* 45 */
|
2741
|
-
/***/ (function(module, exports, __webpack_require__) {
|
2742
|
-
|
2743
|
-
"use strict";
|
2744
|
-
var Collections = __webpack_require__(9);
|
2745
|
-
var Protocol = __webpack_require__(46);
|
2746
|
-
var connection_1 = __webpack_require__(47);
|
2747
|
-
var Handshake = (function () {
|
2748
|
-
function Handshake(transport, callback) {
|
2749
|
-
this.transport = transport;
|
2750
|
-
this.callback = callback;
|
2751
|
-
this.bindListeners();
|
2752
|
-
}
|
2753
|
-
Handshake.prototype.close = function () {
|
2754
|
-
this.unbindListeners();
|
2755
|
-
this.transport.close();
|
2756
|
-
};
|
2757
|
-
Handshake.prototype.bindListeners = function () {
|
2758
|
-
var _this = this;
|
2759
|
-
this.onMessage = function (m) {
|
2760
|
-
_this.unbindListeners();
|
2761
|
-
var result;
|
2762
|
-
try {
|
2763
|
-
result = Protocol.processHandshake(m);
|
2764
|
-
}
|
2765
|
-
catch (e) {
|
2766
|
-
_this.finish("error", { error: e });
|
2767
|
-
_this.transport.close();
|
2768
|
-
return;
|
2769
|
-
}
|
2770
|
-
if (result.action === "connected") {
|
2771
|
-
_this.finish("connected", {
|
2772
|
-
connection: new connection_1["default"](result.id, _this.transport),
|
2773
|
-
activityTimeout: result.activityTimeout
|
2774
|
-
});
|
2775
|
-
}
|
2776
|
-
else {
|
2777
|
-
_this.finish(result.action, { error: result.error });
|
2778
|
-
_this.transport.close();
|
2779
|
-
}
|
2780
|
-
};
|
2781
|
-
this.onClosed = function (closeEvent) {
|
2782
|
-
_this.unbindListeners();
|
2783
|
-
var action = Protocol.getCloseAction(closeEvent) || "backoff";
|
2784
|
-
var error = Protocol.getCloseError(closeEvent);
|
2785
|
-
_this.finish(action, { error: error });
|
2786
|
-
};
|
2787
|
-
this.transport.bind("message", this.onMessage);
|
2788
|
-
this.transport.bind("closed", this.onClosed);
|
2789
|
-
};
|
2790
|
-
Handshake.prototype.unbindListeners = function () {
|
2791
|
-
this.transport.unbind("message", this.onMessage);
|
2792
|
-
this.transport.unbind("closed", this.onClosed);
|
2793
|
-
};
|
2794
|
-
Handshake.prototype.finish = function (action, params) {
|
2795
|
-
this.callback(Collections.extend({ transport: this.transport, action: action }, params));
|
2796
|
-
};
|
2797
|
-
return Handshake;
|
2798
|
-
}());
|
2799
|
-
exports.__esModule = true;
|
2800
|
-
exports["default"] = Handshake;
|
2801
|
-
|
2802
|
-
|
2803
|
-
/***/ }),
|
2804
|
-
/* 46 */
|
2805
|
-
/***/ (function(module, exports) {
|
2806
|
-
|
2807
|
-
"use strict";
|
2808
|
-
exports.decodeMessage = function (message) {
|
2809
|
-
try {
|
2810
|
-
var params = JSON.parse(message.data);
|
2811
|
-
if (typeof params.data === 'string') {
|
2812
|
-
try {
|
2813
|
-
params.data = JSON.parse(params.data);
|
2814
|
-
}
|
2815
|
-
catch (e) {
|
2816
|
-
if (!(e instanceof SyntaxError)) {
|
2817
|
-
throw e;
|
2818
|
-
}
|
2819
|
-
}
|
2820
|
-
}
|
2821
|
-
return params;
|
2822
|
-
}
|
2823
|
-
catch (e) {
|
2824
|
-
throw { type: 'MessageParseError', error: e, data: message.data };
|
2825
|
-
}
|
2826
|
-
};
|
2827
|
-
exports.encodeMessage = function (message) {
|
2828
|
-
return JSON.stringify(message);
|
2829
|
-
};
|
2830
|
-
exports.processHandshake = function (message) {
|
2831
|
-
message = exports.decodeMessage(message);
|
2832
|
-
if (message.event === "pusher:connection_established") {
|
2833
|
-
if (!message.data.activity_timeout) {
|
2834
|
-
throw "No activity timeout specified in handshake";
|
2835
|
-
}
|
2836
|
-
return {
|
2837
|
-
action: "connected",
|
2838
|
-
id: message.data.socket_id,
|
2839
|
-
activityTimeout: message.data.activity_timeout * 1000
|
2840
|
-
};
|
2841
|
-
}
|
2842
|
-
else if (message.event === "pusher:error") {
|
2843
|
-
return {
|
2844
|
-
action: this.getCloseAction(message.data),
|
2845
|
-
error: this.getCloseError(message.data)
|
2846
|
-
};
|
2847
|
-
}
|
2848
|
-
else {
|
2849
|
-
throw "Invalid handshake";
|
2850
|
-
}
|
2851
|
-
};
|
2852
|
-
exports.getCloseAction = function (closeEvent) {
|
2853
|
-
if (closeEvent.code < 4000) {
|
2854
|
-
if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {
|
2855
|
-
return "backoff";
|
2856
|
-
}
|
2857
|
-
else {
|
2858
|
-
return null;
|
2859
|
-
}
|
2860
|
-
}
|
2861
|
-
else if (closeEvent.code === 4000) {
|
2862
|
-
return "ssl_only";
|
2863
|
-
}
|
2864
|
-
else if (closeEvent.code < 4100) {
|
2865
|
-
return "refused";
|
2866
|
-
}
|
2867
|
-
else if (closeEvent.code < 4200) {
|
2868
|
-
return "backoff";
|
2869
|
-
}
|
2870
|
-
else if (closeEvent.code < 4300) {
|
2871
|
-
return "retry";
|
2872
|
-
}
|
2873
|
-
else {
|
2874
|
-
return "refused";
|
2875
|
-
}
|
2876
|
-
};
|
2877
|
-
exports.getCloseError = function (closeEvent) {
|
2878
|
-
if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {
|
2879
|
-
return {
|
2880
|
-
type: 'PusherError',
|
2881
|
-
data: {
|
2882
|
-
code: closeEvent.code,
|
2883
|
-
message: closeEvent.reason || closeEvent.message
|
2884
|
-
}
|
2885
|
-
};
|
2886
|
-
}
|
2887
|
-
else {
|
2888
|
-
return null;
|
2889
|
-
}
|
2890
|
-
};
|
2891
|
-
|
2892
|
-
|
2893
|
-
/***/ }),
|
2894
|
-
/* 47 */
|
2895
|
-
/***/ (function(module, exports, __webpack_require__) {
|
2896
|
-
|
2897
|
-
"use strict";
|
2898
|
-
var __extends = (this && this.__extends) || function (d, b) {
|
2899
|
-
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
2900
|
-
function __() { this.constructor = d; }
|
2901
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
2902
|
-
};
|
2903
|
-
var Collections = __webpack_require__(9);
|
2904
|
-
var dispatcher_1 = __webpack_require__(24);
|
2905
|
-
var Protocol = __webpack_require__(46);
|
2906
|
-
var logger_1 = __webpack_require__(8);
|
2907
|
-
var Connection = (function (_super) {
|
2908
|
-
__extends(Connection, _super);
|
2909
|
-
function Connection(id, transport) {
|
2910
|
-
_super.call(this);
|
2911
|
-
this.id = id;
|
2912
|
-
this.transport = transport;
|
2913
|
-
this.activityTimeout = transport.activityTimeout;
|
2914
|
-
this.bindListeners();
|
2915
|
-
}
|
2916
|
-
Connection.prototype.handlesActivityChecks = function () {
|
2917
|
-
return this.transport.handlesActivityChecks();
|
2918
|
-
};
|
2919
|
-
Connection.prototype.send = function (data) {
|
2920
|
-
return this.transport.send(data);
|
2921
|
-
};
|
2922
|
-
Connection.prototype.send_event = function (name, data, channel) {
|
2923
|
-
var message = { event: name, data: data };
|
2924
|
-
if (channel) {
|
2925
|
-
message.channel = channel;
|
2926
|
-
}
|
2927
|
-
logger_1["default"].debug('Event sent', message);
|
2928
|
-
return this.send(Protocol.encodeMessage(message));
|
2929
|
-
};
|
2930
|
-
Connection.prototype.ping = function () {
|
2931
|
-
if (this.transport.supportsPing()) {
|
2932
|
-
this.transport.ping();
|
2933
|
-
}
|
2934
|
-
else {
|
2935
|
-
this.send_event('pusher:ping', {});
|
2936
|
-
}
|
2937
|
-
};
|
2938
|
-
Connection.prototype.close = function () {
|
2939
|
-
this.transport.close();
|
2940
|
-
};
|
2941
|
-
Connection.prototype.bindListeners = function () {
|
2942
|
-
var _this = this;
|
2943
|
-
var listeners = {
|
2944
|
-
message: function (m) {
|
2945
|
-
var message;
|
2946
|
-
try {
|
2947
|
-
message = Protocol.decodeMessage(m);
|
2948
|
-
}
|
2949
|
-
catch (e) {
|
2950
|
-
_this.emit('error', {
|
2951
|
-
type: 'MessageParseError',
|
2952
|
-
error: e,
|
2953
|
-
data: m.data
|
2954
|
-
});
|
2955
|
-
}
|
2956
|
-
if (message !== undefined) {
|
2957
|
-
logger_1["default"].debug('Event recd', message);
|
2958
|
-
switch (message.event) {
|
2959
|
-
case 'pusher:error':
|
2960
|
-
_this.emit('error', { type: 'PusherError', data: message.data });
|
2961
|
-
break;
|
2962
|
-
case 'pusher:ping':
|
2963
|
-
_this.emit("ping");
|
2964
|
-
break;
|
2965
|
-
case 'pusher:pong':
|
2966
|
-
_this.emit("pong");
|
2967
|
-
break;
|
2968
|
-
}
|
2969
|
-
_this.emit('message', message);
|
2970
|
-
}
|
2971
|
-
},
|
2972
|
-
activity: function () {
|
2973
|
-
_this.emit("activity");
|
2974
|
-
},
|
2975
|
-
error: function (error) {
|
2976
|
-
_this.emit("error", { type: "WebSocketError", error: error });
|
2977
|
-
},
|
2978
|
-
closed: function (closeEvent) {
|
2979
|
-
unbindListeners();
|
2980
|
-
if (closeEvent && closeEvent.code) {
|
2981
|
-
_this.handleCloseEvent(closeEvent);
|
2982
|
-
}
|
2983
|
-
_this.transport = null;
|
2984
|
-
_this.emit("closed");
|
2985
|
-
}
|
2986
|
-
};
|
2987
|
-
var unbindListeners = function () {
|
2988
|
-
Collections.objectApply(listeners, function (listener, event) {
|
2989
|
-
_this.transport.unbind(event, listener);
|
2990
|
-
});
|
2991
|
-
};
|
2992
|
-
Collections.objectApply(listeners, function (listener, event) {
|
2993
|
-
_this.transport.bind(event, listener);
|
2994
|
-
});
|
2995
|
-
};
|
2996
|
-
Connection.prototype.handleCloseEvent = function (closeEvent) {
|
2997
|
-
var action = Protocol.getCloseAction(closeEvent);
|
2998
|
-
var error = Protocol.getCloseError(closeEvent);
|
2999
|
-
if (error) {
|
3000
|
-
this.emit('error', error);
|
3001
|
-
}
|
3002
|
-
if (action) {
|
3003
|
-
this.emit(action);
|
3004
|
-
}
|
3005
|
-
};
|
3006
|
-
return Connection;
|
3007
|
-
}(dispatcher_1["default"]));
|
3008
|
-
exports.__esModule = true;
|
3009
|
-
exports["default"] = Connection;
|
3010
|
-
|
3011
|
-
|
3012
|
-
/***/ }),
|
3013
|
-
/* 48 */
|
3014
|
-
/***/ (function(module, exports, __webpack_require__) {
|
3015
|
-
|
3016
|
-
"use strict";
|
3017
|
-
var runtime_1 = __webpack_require__(2);
|
3018
|
-
var PusherAuthorizer = (function () {
|
3019
|
-
function PusherAuthorizer(channel, options) {
|
3020
|
-
this.channel = channel;
|
3021
|
-
var authTransport = options.authTransport;
|
3022
|
-
if (typeof runtime_1["default"].getAuthorizers()[authTransport] === "undefined") {
|
3023
|
-
throw "'" + authTransport + "' is not a recognized auth transport";
|
3024
|
-
}
|
3025
|
-
this.type = authTransport;
|
3026
|
-
this.options = options;
|
3027
|
-
this.authOptions = (options || {}).auth || {};
|
3028
|
-
}
|
3029
|
-
PusherAuthorizer.prototype.composeQuery = function (socketId) {
|
3030
|
-
var query = 'socket_id=' + encodeURIComponent(socketId) +
|
3031
|
-
'&channel_name=' + encodeURIComponent(this.channel.name);
|
3032
|
-
for (var i in this.authOptions.params) {
|
3033
|
-
query += "&" + encodeURIComponent(i) + "=" + encodeURIComponent(this.authOptions.params[i]);
|
3034
|
-
}
|
3035
|
-
return query;
|
3036
|
-
};
|
3037
|
-
PusherAuthorizer.prototype.authorize = function (socketId, callback) {
|
3038
|
-
PusherAuthorizer.authorizers = PusherAuthorizer.authorizers || runtime_1["default"].getAuthorizers();
|
3039
|
-
return PusherAuthorizer.authorizers[this.type].call(this, runtime_1["default"], socketId, callback);
|
3040
|
-
};
|
3041
|
-
return PusherAuthorizer;
|
3042
|
-
}());
|
3043
|
-
exports.__esModule = true;
|
3044
|
-
exports["default"] = PusherAuthorizer;
|
3045
|
-
|
3046
|
-
|
3047
|
-
/***/ }),
|
3048
|
-
/* 49 */
|
3049
|
-
/***/ (function(module, exports, __webpack_require__) {
|
3050
|
-
|
3051
|
-
"use strict";
|
3052
|
-
var runtime_1 = __webpack_require__(2);
|
3053
|
-
var TimelineSender = (function () {
|
3054
|
-
function TimelineSender(timeline, options) {
|
3055
|
-
this.timeline = timeline;
|
3056
|
-
this.options = options || {};
|
3057
|
-
}
|
3058
|
-
TimelineSender.prototype.send = function (encrypted, callback) {
|
3059
|
-
if (this.timeline.isEmpty()) {
|
3060
|
-
return;
|
3061
|
-
}
|
3062
|
-
this.timeline.send(runtime_1["default"].TimelineTransport.getAgent(this, encrypted), callback);
|
3063
|
-
};
|
3064
|
-
return TimelineSender;
|
3065
|
-
}());
|
3066
|
-
exports.__esModule = true;
|
3067
|
-
exports["default"] = TimelineSender;
|
3068
|
-
|
3069
|
-
|
3070
|
-
/***/ }),
|
3071
|
-
/* 50 */
|
3072
|
-
/***/ (function(module, exports, __webpack_require__) {
|
3073
|
-
|
3074
|
-
"use strict";
|
3075
|
-
var __extends = (this && this.__extends) || function (d, b) {
|
3076
|
-
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
3077
|
-
function __() { this.constructor = d; }
|
3078
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
3079
|
-
};
|
3080
|
-
var private_channel_1 = __webpack_require__(51);
|
3081
|
-
var logger_1 = __webpack_require__(8);
|
3082
|
-
var members_1 = __webpack_require__(53);
|
3083
|
-
var url_store_1 = __webpack_require__(14);
|
3084
|
-
var PresenceChannel = (function (_super) {
|
3085
|
-
__extends(PresenceChannel, _super);
|
3086
|
-
function PresenceChannel(name, pusher) {
|
3087
|
-
_super.call(this, name, pusher);
|
3088
|
-
this.members = new members_1["default"]();
|
3089
|
-
}
|
3090
|
-
PresenceChannel.prototype.authorize = function (socketId, callback) {
|
3091
|
-
var _this = this;
|
3092
|
-
_super.prototype.authorize.call(this, socketId, function (error, authData) {
|
3093
|
-
if (!error) {
|
3094
|
-
if (authData.channel_data === undefined) {
|
3095
|
-
var suffix = url_store_1["default"].buildLogSuffix("authenticationEndpoint");
|
3096
|
-
logger_1["default"].warn(("Invalid auth response for channel '" + _this.name + "',") +
|
3097
|
-
("expected 'channel_data' field. " + suffix));
|
3098
|
-
callback("Invalid auth response");
|
3099
|
-
return;
|
3100
|
-
}
|
3101
|
-
var channelData = JSON.parse(authData.channel_data);
|
3102
|
-
_this.members.setMyID(channelData.user_id);
|
3103
|
-
}
|
3104
|
-
callback(error, authData);
|
3105
|
-
});
|
3106
|
-
};
|
3107
|
-
PresenceChannel.prototype.handleEvent = function (event, data) {
|
3108
|
-
switch (event) {
|
3109
|
-
case "pusher_internal:subscription_succeeded":
|
3110
|
-
this.subscriptionPending = false;
|
3111
|
-
this.subscribed = true;
|
3112
|
-
if (this.subscriptionCancelled) {
|
3113
|
-
this.pusher.unsubscribe(this.name);
|
3114
|
-
}
|
3115
|
-
else {
|
3116
|
-
this.members.onSubscription(data);
|
3117
|
-
this.emit("pusher:subscription_succeeded", this.members);
|
3118
|
-
}
|
3119
|
-
break;
|
3120
|
-
case "pusher_internal:member_added":
|
3121
|
-
var addedMember = this.members.addMember(data);
|
3122
|
-
this.emit('pusher:member_added', addedMember);
|
3123
|
-
break;
|
3124
|
-
case "pusher_internal:member_removed":
|
3125
|
-
var removedMember = this.members.removeMember(data);
|
3126
|
-
if (removedMember) {
|
3127
|
-
this.emit('pusher:member_removed', removedMember);
|
3128
|
-
}
|
3129
|
-
break;
|
3130
|
-
default:
|
3131
|
-
private_channel_1["default"].prototype.handleEvent.call(this, event, data);
|
3132
|
-
}
|
3133
|
-
};
|
3134
|
-
PresenceChannel.prototype.disconnect = function () {
|
3135
|
-
this.members.reset();
|
3136
|
-
_super.prototype.disconnect.call(this);
|
3137
|
-
};
|
3138
|
-
return PresenceChannel;
|
3139
|
-
}(private_channel_1["default"]));
|
3140
|
-
exports.__esModule = true;
|
3141
|
-
exports["default"] = PresenceChannel;
|
3142
|
-
|
3143
|
-
|
3144
|
-
/***/ }),
|
3145
|
-
/* 51 */
|
3146
|
-
/***/ (function(module, exports, __webpack_require__) {
|
3147
|
-
|
3148
|
-
"use strict";
|
3149
|
-
var __extends = (this && this.__extends) || function (d, b) {
|
3150
|
-
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
3151
|
-
function __() { this.constructor = d; }
|
3152
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
3153
|
-
};
|
3154
|
-
var factory_1 = __webpack_require__(43);
|
3155
|
-
var channel_1 = __webpack_require__(52);
|
3156
|
-
var PrivateChannel = (function (_super) {
|
3157
|
-
__extends(PrivateChannel, _super);
|
3158
|
-
function PrivateChannel() {
|
3159
|
-
_super.apply(this, arguments);
|
3160
|
-
}
|
3161
|
-
PrivateChannel.prototype.authorize = function (socketId, callback) {
|
3162
|
-
var authorizer = factory_1["default"].createAuthorizer(this, this.pusher.config);
|
3163
|
-
return authorizer.authorize(socketId, callback);
|
3164
|
-
};
|
3165
|
-
return PrivateChannel;
|
3166
|
-
}(channel_1["default"]));
|
3167
|
-
exports.__esModule = true;
|
3168
|
-
exports["default"] = PrivateChannel;
|
3169
|
-
|
3170
|
-
|
3171
|
-
/***/ }),
|
3172
|
-
/* 52 */
|
3173
|
-
/***/ (function(module, exports, __webpack_require__) {
|
3174
|
-
|
3175
|
-
"use strict";
|
3176
|
-
var __extends = (this && this.__extends) || function (d, b) {
|
3177
|
-
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
3178
|
-
function __() { this.constructor = d; }
|
3179
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
3180
|
-
};
|
3181
|
-
var dispatcher_1 = __webpack_require__(24);
|
3182
|
-
var Errors = __webpack_require__(31);
|
3183
|
-
var logger_1 = __webpack_require__(8);
|
3184
|
-
var Channel = (function (_super) {
|
3185
|
-
__extends(Channel, _super);
|
3186
|
-
function Channel(name, pusher) {
|
3187
|
-
_super.call(this, function (event, data) {
|
3188
|
-
logger_1["default"].debug('No callbacks on ' + name + ' for ' + event);
|
3189
|
-
});
|
3190
|
-
this.name = name;
|
3191
|
-
this.pusher = pusher;
|
3192
|
-
this.subscribed = false;
|
3193
|
-
this.subscriptionPending = false;
|
3194
|
-
this.subscriptionCancelled = false;
|
3195
|
-
}
|
3196
|
-
Channel.prototype.authorize = function (socketId, callback) {
|
3197
|
-
return callback(false, {});
|
3198
|
-
};
|
3199
|
-
Channel.prototype.trigger = function (event, data) {
|
3200
|
-
if (event.indexOf("client-") !== 0) {
|
3201
|
-
throw new Errors.BadEventName("Event '" + event + "' does not start with 'client-'");
|
3202
|
-
}
|
3203
|
-
return this.pusher.send_event(event, data, this.name);
|
3204
|
-
};
|
3205
|
-
Channel.prototype.disconnect = function () {
|
3206
|
-
this.subscribed = false;
|
3207
|
-
this.subscriptionPending = false;
|
3208
|
-
};
|
3209
|
-
Channel.prototype.handleEvent = function (event, data) {
|
3210
|
-
if (event.indexOf("pusher_internal:") === 0) {
|
3211
|
-
if (event === "pusher_internal:subscription_succeeded") {
|
3212
|
-
this.subscriptionPending = false;
|
3213
|
-
this.subscribed = true;
|
3214
|
-
if (this.subscriptionCancelled) {
|
3215
|
-
this.pusher.unsubscribe(this.name);
|
3216
|
-
}
|
3217
|
-
else {
|
3218
|
-
this.emit("pusher:subscription_succeeded", data);
|
3219
|
-
}
|
3220
|
-
}
|
3221
|
-
}
|
3222
|
-
else {
|
3223
|
-
this.emit(event, data);
|
3224
|
-
}
|
3225
|
-
};
|
3226
|
-
Channel.prototype.subscribe = function () {
|
3227
|
-
var _this = this;
|
3228
|
-
if (this.subscribed) {
|
3229
|
-
return;
|
3230
|
-
}
|
3231
|
-
this.subscriptionPending = true;
|
3232
|
-
this.subscriptionCancelled = false;
|
3233
|
-
this.authorize(this.pusher.connection.socket_id, function (error, data) {
|
3234
|
-
if (error) {
|
3235
|
-
_this.handleEvent('pusher:subscription_error', data);
|
3236
|
-
}
|
3237
|
-
else {
|
3238
|
-
_this.pusher.send_event('pusher:subscribe', {
|
3239
|
-
auth: data.auth,
|
3240
|
-
channel_data: data.channel_data,
|
3241
|
-
channel: _this.name
|
3242
|
-
});
|
3243
|
-
}
|
3244
|
-
});
|
3245
|
-
};
|
3246
|
-
Channel.prototype.unsubscribe = function () {
|
3247
|
-
this.subscribed = false;
|
3248
|
-
this.pusher.send_event('pusher:unsubscribe', {
|
3249
|
-
channel: this.name
|
3250
|
-
});
|
3251
|
-
};
|
3252
|
-
Channel.prototype.cancelSubscription = function () {
|
3253
|
-
this.subscriptionCancelled = true;
|
3254
|
-
};
|
3255
|
-
Channel.prototype.reinstateSubscription = function () {
|
3256
|
-
this.subscriptionCancelled = false;
|
3257
|
-
};
|
3258
|
-
return Channel;
|
3259
|
-
}(dispatcher_1["default"]));
|
3260
|
-
exports.__esModule = true;
|
3261
|
-
exports["default"] = Channel;
|
3262
|
-
|
3263
|
-
|
3264
|
-
/***/ }),
|
3265
|
-
/* 53 */
|
3266
|
-
/***/ (function(module, exports, __webpack_require__) {
|
3267
|
-
|
3268
|
-
"use strict";
|
3269
|
-
var Collections = __webpack_require__(9);
|
3270
|
-
var Members = (function () {
|
3271
|
-
function Members() {
|
3272
|
-
this.reset();
|
3273
|
-
}
|
3274
|
-
Members.prototype.get = function (id) {
|
3275
|
-
if (Object.prototype.hasOwnProperty.call(this.members, id)) {
|
3276
|
-
return {
|
3277
|
-
id: id,
|
3278
|
-
info: this.members[id]
|
3279
|
-
};
|
3280
|
-
}
|
3281
|
-
else {
|
3282
|
-
return null;
|
3283
|
-
}
|
3284
|
-
};
|
3285
|
-
Members.prototype.each = function (callback) {
|
3286
|
-
var _this = this;
|
3287
|
-
Collections.objectApply(this.members, function (member, id) {
|
3288
|
-
callback(_this.get(id));
|
3289
|
-
});
|
3290
|
-
};
|
3291
|
-
Members.prototype.setMyID = function (id) {
|
3292
|
-
this.myID = id;
|
3293
|
-
};
|
3294
|
-
Members.prototype.onSubscription = function (subscriptionData) {
|
3295
|
-
this.members = subscriptionData.presence.hash;
|
3296
|
-
this.count = subscriptionData.presence.count;
|
3297
|
-
this.me = this.get(this.myID);
|
3298
|
-
};
|
3299
|
-
Members.prototype.addMember = function (memberData) {
|
3300
|
-
if (this.get(memberData.user_id) === null) {
|
3301
|
-
this.count++;
|
3302
|
-
}
|
3303
|
-
this.members[memberData.user_id] = memberData.user_info;
|
3304
|
-
return this.get(memberData.user_id);
|
3305
|
-
};
|
3306
|
-
Members.prototype.removeMember = function (memberData) {
|
3307
|
-
var member = this.get(memberData.user_id);
|
3308
|
-
if (member) {
|
3309
|
-
delete this.members[memberData.user_id];
|
3310
|
-
this.count--;
|
3311
|
-
}
|
3312
|
-
return member;
|
3313
|
-
};
|
3314
|
-
Members.prototype.reset = function () {
|
3315
|
-
this.members = {};
|
3316
|
-
this.count = 0;
|
3317
|
-
this.myID = null;
|
3318
|
-
this.me = null;
|
3319
|
-
};
|
3320
|
-
return Members;
|
3321
|
-
}());
|
3322
|
-
exports.__esModule = true;
|
3323
|
-
exports["default"] = Members;
|
3324
|
-
|
3325
|
-
|
3326
|
-
/***/ }),
|
3327
|
-
/* 54 */
|
3328
|
-
/***/ (function(module, exports, __webpack_require__) {
|
3329
|
-
|
3330
|
-
"use strict";
|
3331
|
-
var __extends = (this && this.__extends) || function (d, b) {
|
3332
|
-
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
3333
|
-
function __() { this.constructor = d; }
|
3334
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
3335
|
-
};
|
3336
|
-
var dispatcher_1 = __webpack_require__(24);
|
3337
|
-
var timers_1 = __webpack_require__(12);
|
3338
|
-
var logger_1 = __webpack_require__(8);
|
3339
|
-
var Collections = __webpack_require__(9);
|
3340
|
-
var runtime_1 = __webpack_require__(2);
|
3341
|
-
var ConnectionManager = (function (_super) {
|
3342
|
-
__extends(ConnectionManager, _super);
|
3343
|
-
function ConnectionManager(key, options) {
|
3344
|
-
var _this = this;
|
3345
|
-
_super.call(this);
|
3346
|
-
this.key = key;
|
3347
|
-
this.options = options || {};
|
3348
|
-
this.state = "initialized";
|
3349
|
-
this.connection = null;
|
3350
|
-
this.encrypted = !!options.encrypted;
|
3351
|
-
this.timeline = this.options.timeline;
|
3352
|
-
this.connectionCallbacks = this.buildConnectionCallbacks();
|
3353
|
-
this.errorCallbacks = this.buildErrorCallbacks();
|
3354
|
-
this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);
|
3355
|
-
var Network = runtime_1["default"].getNetwork();
|
3356
|
-
Network.bind("online", function () {
|
3357
|
-
_this.timeline.info({ netinfo: "online" });
|
3358
|
-
if (_this.state === "connecting" || _this.state === "unavailable") {
|
3359
|
-
_this.retryIn(0);
|
3360
|
-
}
|
3361
|
-
});
|
3362
|
-
Network.bind("offline", function () {
|
3363
|
-
_this.timeline.info({ netinfo: "offline" });
|
3364
|
-
if (_this.connection) {
|
3365
|
-
_this.sendActivityCheck();
|
3366
|
-
}
|
3367
|
-
});
|
3368
|
-
this.updateStrategy();
|
3369
|
-
}
|
3370
|
-
ConnectionManager.prototype.connect = function () {
|
3371
|
-
if (this.connection || this.runner) {
|
3372
|
-
return;
|
3373
|
-
}
|
3374
|
-
if (!this.strategy.isSupported()) {
|
3375
|
-
this.updateState("failed");
|
3376
|
-
return;
|
3377
|
-
}
|
3378
|
-
this.updateState("connecting");
|
3379
|
-
this.startConnecting();
|
3380
|
-
this.setUnavailableTimer();
|
3381
|
-
};
|
3382
|
-
;
|
3383
|
-
ConnectionManager.prototype.send = function (data) {
|
3384
|
-
if (this.connection) {
|
3385
|
-
return this.connection.send(data);
|
3386
|
-
}
|
3387
|
-
else {
|
3388
|
-
return false;
|
3389
|
-
}
|
3390
|
-
};
|
3391
|
-
;
|
3392
|
-
ConnectionManager.prototype.send_event = function (name, data, channel) {
|
3393
|
-
if (this.connection) {
|
3394
|
-
return this.connection.send_event(name, data, channel);
|
3395
|
-
}
|
3396
|
-
else {
|
3397
|
-
return false;
|
3398
|
-
}
|
3399
|
-
};
|
3400
|
-
;
|
3401
|
-
ConnectionManager.prototype.disconnect = function () {
|
3402
|
-
this.disconnectInternally();
|
3403
|
-
this.updateState("disconnected");
|
3404
|
-
};
|
3405
|
-
;
|
3406
|
-
ConnectionManager.prototype.isEncrypted = function () {
|
3407
|
-
return this.encrypted;
|
3408
|
-
};
|
3409
|
-
;
|
3410
|
-
ConnectionManager.prototype.startConnecting = function () {
|
3411
|
-
var _this = this;
|
3412
|
-
var callback = function (error, handshake) {
|
3413
|
-
if (error) {
|
3414
|
-
_this.runner = _this.strategy.connect(0, callback);
|
3415
|
-
}
|
3416
|
-
else {
|
3417
|
-
if (handshake.action === "error") {
|
3418
|
-
_this.emit("error", { type: "HandshakeError", error: handshake.error });
|
3419
|
-
_this.timeline.error({ handshakeError: handshake.error });
|
3420
|
-
}
|
3421
|
-
else {
|
3422
|
-
_this.abortConnecting();
|
3423
|
-
_this.handshakeCallbacks[handshake.action](handshake);
|
3424
|
-
}
|
3425
|
-
}
|
3426
|
-
};
|
3427
|
-
this.runner = this.strategy.connect(0, callback);
|
3428
|
-
};
|
3429
|
-
;
|
3430
|
-
ConnectionManager.prototype.abortConnecting = function () {
|
3431
|
-
if (this.runner) {
|
3432
|
-
this.runner.abort();
|
3433
|
-
this.runner = null;
|
3434
|
-
}
|
3435
|
-
};
|
3436
|
-
;
|
3437
|
-
ConnectionManager.prototype.disconnectInternally = function () {
|
3438
|
-
this.abortConnecting();
|
3439
|
-
this.clearRetryTimer();
|
3440
|
-
this.clearUnavailableTimer();
|
3441
|
-
if (this.connection) {
|
3442
|
-
var connection = this.abandonConnection();
|
3443
|
-
connection.close();
|
3444
|
-
}
|
3445
|
-
};
|
3446
|
-
;
|
3447
|
-
ConnectionManager.prototype.updateStrategy = function () {
|
3448
|
-
this.strategy = this.options.getStrategy({
|
3449
|
-
key: this.key,
|
3450
|
-
timeline: this.timeline,
|
3451
|
-
encrypted: this.encrypted
|
3452
|
-
});
|
3453
|
-
};
|
3454
|
-
;
|
3455
|
-
ConnectionManager.prototype.retryIn = function (delay) {
|
3456
|
-
var _this = this;
|
3457
|
-
this.timeline.info({ action: "retry", delay: delay });
|
3458
|
-
if (delay > 0) {
|
3459
|
-
this.emit("connecting_in", Math.round(delay / 1000));
|
3460
|
-
}
|
3461
|
-
this.retryTimer = new timers_1.OneOffTimer(delay || 0, function () {
|
3462
|
-
_this.disconnectInternally();
|
3463
|
-
_this.connect();
|
3464
|
-
});
|
3465
|
-
};
|
3466
|
-
;
|
3467
|
-
ConnectionManager.prototype.clearRetryTimer = function () {
|
3468
|
-
if (this.retryTimer) {
|
3469
|
-
this.retryTimer.ensureAborted();
|
3470
|
-
this.retryTimer = null;
|
3471
|
-
}
|
3472
|
-
};
|
3473
|
-
;
|
3474
|
-
ConnectionManager.prototype.setUnavailableTimer = function () {
|
3475
|
-
var _this = this;
|
3476
|
-
this.unavailableTimer = new timers_1.OneOffTimer(this.options.unavailableTimeout, function () {
|
3477
|
-
_this.updateState("unavailable");
|
3478
|
-
});
|
3479
|
-
};
|
3480
|
-
;
|
3481
|
-
ConnectionManager.prototype.clearUnavailableTimer = function () {
|
3482
|
-
if (this.unavailableTimer) {
|
3483
|
-
this.unavailableTimer.ensureAborted();
|
3484
|
-
}
|
3485
|
-
};
|
3486
|
-
;
|
3487
|
-
ConnectionManager.prototype.sendActivityCheck = function () {
|
3488
|
-
var _this = this;
|
3489
|
-
this.stopActivityCheck();
|
3490
|
-
this.connection.ping();
|
3491
|
-
this.activityTimer = new timers_1.OneOffTimer(this.options.pongTimeout, function () {
|
3492
|
-
_this.timeline.error({ pong_timed_out: _this.options.pongTimeout });
|
3493
|
-
_this.retryIn(0);
|
3494
|
-
});
|
3495
|
-
};
|
3496
|
-
;
|
3497
|
-
ConnectionManager.prototype.resetActivityCheck = function () {
|
3498
|
-
var _this = this;
|
3499
|
-
this.stopActivityCheck();
|
3500
|
-
if (this.connection && !this.connection.handlesActivityChecks()) {
|
3501
|
-
this.activityTimer = new timers_1.OneOffTimer(this.activityTimeout, function () {
|
3502
|
-
_this.sendActivityCheck();
|
3503
|
-
});
|
3504
|
-
}
|
3505
|
-
};
|
3506
|
-
;
|
3507
|
-
ConnectionManager.prototype.stopActivityCheck = function () {
|
3508
|
-
if (this.activityTimer) {
|
3509
|
-
this.activityTimer.ensureAborted();
|
3510
|
-
}
|
3511
|
-
};
|
3512
|
-
;
|
3513
|
-
ConnectionManager.prototype.buildConnectionCallbacks = function () {
|
3514
|
-
var _this = this;
|
3515
|
-
return {
|
3516
|
-
message: function (message) {
|
3517
|
-
_this.resetActivityCheck();
|
3518
|
-
_this.emit('message', message);
|
3519
|
-
},
|
3520
|
-
ping: function () {
|
3521
|
-
_this.send_event('pusher:pong', {});
|
3522
|
-
},
|
3523
|
-
activity: function () {
|
3524
|
-
_this.resetActivityCheck();
|
3525
|
-
},
|
3526
|
-
error: function (error) {
|
3527
|
-
_this.emit("error", { type: "WebSocketError", error: error });
|
3528
|
-
},
|
3529
|
-
closed: function () {
|
3530
|
-
_this.abandonConnection();
|
3531
|
-
if (_this.shouldRetry()) {
|
3532
|
-
_this.retryIn(1000);
|
3533
|
-
}
|
3534
|
-
}
|
3535
|
-
};
|
3536
|
-
};
|
3537
|
-
;
|
3538
|
-
ConnectionManager.prototype.buildHandshakeCallbacks = function (errorCallbacks) {
|
3539
|
-
var _this = this;
|
3540
|
-
return Collections.extend({}, errorCallbacks, {
|
3541
|
-
connected: function (handshake) {
|
3542
|
-
_this.activityTimeout = Math.min(_this.options.activityTimeout, handshake.activityTimeout, handshake.connection.activityTimeout || Infinity);
|
3543
|
-
_this.clearUnavailableTimer();
|
3544
|
-
_this.setConnection(handshake.connection);
|
3545
|
-
_this.socket_id = _this.connection.id;
|
3546
|
-
_this.updateState("connected", { socket_id: _this.socket_id });
|
3547
|
-
}
|
3548
|
-
});
|
3549
|
-
};
|
3550
|
-
;
|
3551
|
-
ConnectionManager.prototype.buildErrorCallbacks = function () {
|
3552
|
-
var _this = this;
|
3553
|
-
var withErrorEmitted = function (callback) {
|
3554
|
-
return function (result) {
|
3555
|
-
if (result.error) {
|
3556
|
-
_this.emit("error", { type: "WebSocketError", error: result.error });
|
3557
|
-
}
|
3558
|
-
callback(result);
|
3559
|
-
};
|
3560
|
-
};
|
3561
|
-
return {
|
3562
|
-
ssl_only: withErrorEmitted(function () {
|
3563
|
-
_this.encrypted = true;
|
3564
|
-
_this.updateStrategy();
|
3565
|
-
_this.retryIn(0);
|
3566
|
-
}),
|
3567
|
-
refused: withErrorEmitted(function () {
|
3568
|
-
_this.disconnect();
|
3569
|
-
}),
|
3570
|
-
backoff: withErrorEmitted(function () {
|
3571
|
-
_this.retryIn(1000);
|
3572
|
-
}),
|
3573
|
-
retry: withErrorEmitted(function () {
|
3574
|
-
_this.retryIn(0);
|
3575
|
-
})
|
3576
|
-
};
|
3577
|
-
};
|
3578
|
-
;
|
3579
|
-
ConnectionManager.prototype.setConnection = function (connection) {
|
3580
|
-
this.connection = connection;
|
3581
|
-
for (var event in this.connectionCallbacks) {
|
3582
|
-
this.connection.bind(event, this.connectionCallbacks[event]);
|
3583
|
-
}
|
3584
|
-
this.resetActivityCheck();
|
3585
|
-
};
|
3586
|
-
;
|
3587
|
-
ConnectionManager.prototype.abandonConnection = function () {
|
3588
|
-
if (!this.connection) {
|
3589
|
-
return;
|
3590
|
-
}
|
3591
|
-
this.stopActivityCheck();
|
3592
|
-
for (var event in this.connectionCallbacks) {
|
3593
|
-
this.connection.unbind(event, this.connectionCallbacks[event]);
|
3594
|
-
}
|
3595
|
-
var connection = this.connection;
|
3596
|
-
this.connection = null;
|
3597
|
-
return connection;
|
3598
|
-
};
|
3599
|
-
ConnectionManager.prototype.updateState = function (newState, data) {
|
3600
|
-
var previousState = this.state;
|
3601
|
-
this.state = newState;
|
3602
|
-
if (previousState !== newState) {
|
3603
|
-
var newStateDescription = newState;
|
3604
|
-
if (newStateDescription === "connected") {
|
3605
|
-
newStateDescription += " with new socket ID " + data.socket_id;
|
3606
|
-
}
|
3607
|
-
logger_1["default"].debug('State changed', previousState + ' -> ' + newStateDescription);
|
3608
|
-
this.timeline.info({ state: newState, params: data });
|
3609
|
-
this.emit('state_change', { previous: previousState, current: newState });
|
3610
|
-
this.emit(newState, data);
|
3611
|
-
}
|
3612
|
-
};
|
3613
|
-
ConnectionManager.prototype.shouldRetry = function () {
|
3614
|
-
return this.state === "connecting" || this.state === "connected";
|
3615
|
-
};
|
3616
|
-
return ConnectionManager;
|
3617
|
-
}(dispatcher_1["default"]));
|
3618
|
-
exports.__esModule = true;
|
3619
|
-
exports["default"] = ConnectionManager;
|
3620
|
-
|
3621
|
-
|
3622
|
-
/***/ }),
|
3623
|
-
/* 55 */
|
3624
|
-
/***/ (function(module, exports, __webpack_require__) {
|
3625
|
-
|
3626
|
-
"use strict";
|
3627
|
-
var Collections = __webpack_require__(9);
|
3628
|
-
var factory_1 = __webpack_require__(43);
|
3629
|
-
var Channels = (function () {
|
3630
|
-
function Channels() {
|
3631
|
-
this.channels = {};
|
3632
|
-
}
|
3633
|
-
Channels.prototype.add = function (name, pusher) {
|
3634
|
-
if (!this.channels[name]) {
|
3635
|
-
this.channels[name] = createChannel(name, pusher);
|
3636
|
-
}
|
3637
|
-
return this.channels[name];
|
3638
|
-
};
|
3639
|
-
Channels.prototype.all = function () {
|
3640
|
-
return Collections.values(this.channels);
|
3641
|
-
};
|
3642
|
-
Channels.prototype.find = function (name) {
|
3643
|
-
return this.channels[name];
|
3644
|
-
};
|
3645
|
-
Channels.prototype.remove = function (name) {
|
3646
|
-
var channel = this.channels[name];
|
3647
|
-
delete this.channels[name];
|
3648
|
-
return channel;
|
3649
|
-
};
|
3650
|
-
Channels.prototype.disconnect = function () {
|
3651
|
-
Collections.objectApply(this.channels, function (channel) {
|
3652
|
-
channel.disconnect();
|
3653
|
-
});
|
3654
|
-
};
|
3655
|
-
return Channels;
|
3656
|
-
}());
|
3657
|
-
exports.__esModule = true;
|
3658
|
-
exports["default"] = Channels;
|
3659
|
-
function createChannel(name, pusher) {
|
3660
|
-
if (name.indexOf('private-') === 0) {
|
3661
|
-
return factory_1["default"].createPrivateChannel(name, pusher);
|
3662
|
-
}
|
3663
|
-
else if (name.indexOf('presence-') === 0) {
|
3664
|
-
return factory_1["default"].createPresenceChannel(name, pusher);
|
3665
|
-
}
|
3666
|
-
else {
|
3667
|
-
return factory_1["default"].createChannel(name, pusher);
|
3668
|
-
}
|
3669
|
-
}
|
3670
|
-
|
3671
|
-
|
3672
|
-
/***/ }),
|
3673
|
-
/* 56 */
|
3674
|
-
/***/ (function(module, exports, __webpack_require__) {
|
3675
|
-
|
3676
|
-
"use strict";
|
3677
|
-
var factory_1 = __webpack_require__(43);
|
3678
|
-
var util_1 = __webpack_require__(11);
|
3679
|
-
var Errors = __webpack_require__(31);
|
3680
|
-
var Collections = __webpack_require__(9);
|
3681
|
-
var TransportStrategy = (function () {
|
3682
|
-
function TransportStrategy(name, priority, transport, options) {
|
3683
|
-
this.name = name;
|
3684
|
-
this.priority = priority;
|
3685
|
-
this.transport = transport;
|
3686
|
-
this.options = options || {};
|
3687
|
-
}
|
3688
|
-
TransportStrategy.prototype.isSupported = function () {
|
3689
|
-
return this.transport.isSupported({
|
3690
|
-
encrypted: this.options.encrypted
|
3691
|
-
});
|
3692
|
-
};
|
3693
|
-
TransportStrategy.prototype.connect = function (minPriority, callback) {
|
3694
|
-
var _this = this;
|
3695
|
-
if (!this.isSupported()) {
|
3696
|
-
return failAttempt(new Errors.UnsupportedStrategy(), callback);
|
3697
|
-
}
|
3698
|
-
else if (this.priority < minPriority) {
|
3699
|
-
return failAttempt(new Errors.TransportPriorityTooLow(), callback);
|
3700
|
-
}
|
3701
|
-
var connected = false;
|
3702
|
-
var transport = this.transport.createConnection(this.name, this.priority, this.options.key, this.options);
|
3703
|
-
var handshake = null;
|
3704
|
-
var onInitialized = function () {
|
3705
|
-
transport.unbind("initialized", onInitialized);
|
3706
|
-
transport.connect();
|
3707
|
-
};
|
3708
|
-
var onOpen = function () {
|
3709
|
-
handshake = factory_1["default"].createHandshake(transport, function (result) {
|
3710
|
-
connected = true;
|
3711
|
-
unbindListeners();
|
3712
|
-
callback(null, result);
|
3713
|
-
});
|
3714
|
-
};
|
3715
|
-
var onError = function (error) {
|
3716
|
-
unbindListeners();
|
3717
|
-
callback(error);
|
3718
|
-
};
|
3719
|
-
var onClosed = function () {
|
3720
|
-
unbindListeners();
|
3721
|
-
var serializedTransport;
|
3722
|
-
serializedTransport = Collections.safeJSONStringify(transport);
|
3723
|
-
callback(new Errors.TransportClosed(serializedTransport));
|
3724
|
-
};
|
3725
|
-
var unbindListeners = function () {
|
3726
|
-
transport.unbind("initialized", onInitialized);
|
3727
|
-
transport.unbind("open", onOpen);
|
3728
|
-
transport.unbind("error", onError);
|
3729
|
-
transport.unbind("closed", onClosed);
|
3730
|
-
};
|
3731
|
-
transport.bind("initialized", onInitialized);
|
3732
|
-
transport.bind("open", onOpen);
|
3733
|
-
transport.bind("error", onError);
|
3734
|
-
transport.bind("closed", onClosed);
|
3735
|
-
transport.initialize();
|
3736
|
-
return {
|
3737
|
-
abort: function () {
|
3738
|
-
if (connected) {
|
3739
|
-
return;
|
3740
|
-
}
|
3741
|
-
unbindListeners();
|
3742
|
-
if (handshake) {
|
3743
|
-
handshake.close();
|
3744
|
-
}
|
3745
|
-
else {
|
3746
|
-
transport.close();
|
3747
|
-
}
|
3748
|
-
},
|
3749
|
-
forceMinPriority: function (p) {
|
3750
|
-
if (connected) {
|
3751
|
-
return;
|
3752
|
-
}
|
3753
|
-
if (_this.priority < p) {
|
3754
|
-
if (handshake) {
|
3755
|
-
handshake.close();
|
3756
|
-
}
|
3757
|
-
else {
|
3758
|
-
transport.close();
|
3759
|
-
}
|
3760
|
-
}
|
3761
|
-
}
|
3762
|
-
};
|
3763
|
-
};
|
3764
|
-
return TransportStrategy;
|
3765
|
-
}());
|
3766
|
-
exports.__esModule = true;
|
3767
|
-
exports["default"] = TransportStrategy;
|
3768
|
-
function failAttempt(error, callback) {
|
3769
|
-
util_1["default"].defer(function () {
|
3770
|
-
callback(error);
|
3771
|
-
});
|
3772
|
-
return {
|
3773
|
-
abort: function () { },
|
3774
|
-
forceMinPriority: function () { }
|
3775
|
-
};
|
3776
|
-
}
|
3777
|
-
|
3778
|
-
|
3779
|
-
/***/ }),
|
3780
|
-
/* 57 */
|
3781
|
-
/***/ (function(module, exports, __webpack_require__) {
|
3782
|
-
|
3783
|
-
"use strict";
|
3784
|
-
var Collections = __webpack_require__(9);
|
3785
|
-
var util_1 = __webpack_require__(11);
|
3786
|
-
var timers_1 = __webpack_require__(12);
|
3787
|
-
var SequentialStrategy = (function () {
|
3788
|
-
function SequentialStrategy(strategies, options) {
|
3789
|
-
this.strategies = strategies;
|
3790
|
-
this.loop = Boolean(options.loop);
|
3791
|
-
this.failFast = Boolean(options.failFast);
|
3792
|
-
this.timeout = options.timeout;
|
3793
|
-
this.timeoutLimit = options.timeoutLimit;
|
3794
|
-
}
|
3795
|
-
SequentialStrategy.prototype.isSupported = function () {
|
3796
|
-
return Collections.any(this.strategies, util_1["default"].method("isSupported"));
|
3797
|
-
};
|
3798
|
-
SequentialStrategy.prototype.connect = function (minPriority, callback) {
|
3799
|
-
var _this = this;
|
3800
|
-
var strategies = this.strategies;
|
3801
|
-
var current = 0;
|
3802
|
-
var timeout = this.timeout;
|
3803
|
-
var runner = null;
|
3804
|
-
var tryNextStrategy = function (error, handshake) {
|
3805
|
-
if (handshake) {
|
3806
|
-
callback(null, handshake);
|
3807
|
-
}
|
3808
|
-
else {
|
3809
|
-
current = current + 1;
|
3810
|
-
if (_this.loop) {
|
3811
|
-
current = current % strategies.length;
|
3812
|
-
}
|
3813
|
-
if (current < strategies.length) {
|
3814
|
-
if (timeout) {
|
3815
|
-
timeout = timeout * 2;
|
3816
|
-
if (_this.timeoutLimit) {
|
3817
|
-
timeout = Math.min(timeout, _this.timeoutLimit);
|
3818
|
-
}
|
3819
|
-
}
|
3820
|
-
runner = _this.tryStrategy(strategies[current], minPriority, { timeout: timeout, failFast: _this.failFast }, tryNextStrategy);
|
3821
|
-
}
|
3822
|
-
else {
|
3823
|
-
callback(true);
|
3824
|
-
}
|
3825
|
-
}
|
3826
|
-
};
|
3827
|
-
runner = this.tryStrategy(strategies[current], minPriority, { timeout: timeout, failFast: this.failFast }, tryNextStrategy);
|
3828
|
-
return {
|
3829
|
-
abort: function () {
|
3830
|
-
runner.abort();
|
3831
|
-
},
|
3832
|
-
forceMinPriority: function (p) {
|
3833
|
-
minPriority = p;
|
3834
|
-
if (runner) {
|
3835
|
-
runner.forceMinPriority(p);
|
3836
|
-
}
|
3837
|
-
}
|
3838
|
-
};
|
3839
|
-
};
|
3840
|
-
SequentialStrategy.prototype.tryStrategy = function (strategy, minPriority, options, callback) {
|
3841
|
-
var timer = null;
|
3842
|
-
var runner = null;
|
3843
|
-
if (options.timeout > 0) {
|
3844
|
-
timer = new timers_1.OneOffTimer(options.timeout, function () {
|
3845
|
-
runner.abort();
|
3846
|
-
callback(true);
|
3847
|
-
});
|
3848
|
-
}
|
3849
|
-
runner = strategy.connect(minPriority, function (error, handshake) {
|
3850
|
-
if (error && timer && timer.isRunning() && !options.failFast) {
|
3851
|
-
return;
|
3852
|
-
}
|
3853
|
-
if (timer) {
|
3854
|
-
timer.ensureAborted();
|
3855
|
-
}
|
3856
|
-
callback(error, handshake);
|
3857
|
-
});
|
3858
|
-
return {
|
3859
|
-
abort: function () {
|
3860
|
-
if (timer) {
|
3861
|
-
timer.ensureAborted();
|
3862
|
-
}
|
3863
|
-
runner.abort();
|
3864
|
-
},
|
3865
|
-
forceMinPriority: function (p) {
|
3866
|
-
runner.forceMinPriority(p);
|
3867
|
-
}
|
3868
|
-
};
|
3869
|
-
};
|
3870
|
-
return SequentialStrategy;
|
3871
|
-
}());
|
3872
|
-
exports.__esModule = true;
|
3873
|
-
exports["default"] = SequentialStrategy;
|
3874
|
-
|
3875
|
-
|
3876
|
-
/***/ }),
|
3877
|
-
/* 58 */
|
3878
|
-
/***/ (function(module, exports, __webpack_require__) {
|
3879
|
-
|
3880
|
-
"use strict";
|
3881
|
-
var Collections = __webpack_require__(9);
|
3882
|
-
var util_1 = __webpack_require__(11);
|
3883
|
-
var BestConnectedEverStrategy = (function () {
|
3884
|
-
function BestConnectedEverStrategy(strategies) {
|
3885
|
-
this.strategies = strategies;
|
3886
|
-
}
|
3887
|
-
BestConnectedEverStrategy.prototype.isSupported = function () {
|
3888
|
-
return Collections.any(this.strategies, util_1["default"].method("isSupported"));
|
3889
|
-
};
|
3890
|
-
BestConnectedEverStrategy.prototype.connect = function (minPriority, callback) {
|
3891
|
-
return connect(this.strategies, minPriority, function (i, runners) {
|
3892
|
-
return function (error, handshake) {
|
3893
|
-
runners[i].error = error;
|
3894
|
-
if (error) {
|
3895
|
-
if (allRunnersFailed(runners)) {
|
3896
|
-
callback(true);
|
3897
|
-
}
|
3898
|
-
return;
|
3899
|
-
}
|
3900
|
-
Collections.apply(runners, function (runner) {
|
3901
|
-
runner.forceMinPriority(handshake.transport.priority);
|
3902
|
-
});
|
3903
|
-
callback(null, handshake);
|
3904
|
-
};
|
3905
|
-
});
|
3906
|
-
};
|
3907
|
-
return BestConnectedEverStrategy;
|
3908
|
-
}());
|
3909
|
-
exports.__esModule = true;
|
3910
|
-
exports["default"] = BestConnectedEverStrategy;
|
3911
|
-
function connect(strategies, minPriority, callbackBuilder) {
|
3912
|
-
var runners = Collections.map(strategies, function (strategy, i, _, rs) {
|
3913
|
-
return strategy.connect(minPriority, callbackBuilder(i, rs));
|
3914
|
-
});
|
3915
|
-
return {
|
3916
|
-
abort: function () {
|
3917
|
-
Collections.apply(runners, abortRunner);
|
3918
|
-
},
|
3919
|
-
forceMinPriority: function (p) {
|
3920
|
-
Collections.apply(runners, function (runner) {
|
3921
|
-
runner.forceMinPriority(p);
|
3922
|
-
});
|
3923
|
-
}
|
3924
|
-
};
|
3925
|
-
}
|
3926
|
-
function allRunnersFailed(runners) {
|
3927
|
-
return Collections.all(runners, function (runner) {
|
3928
|
-
return Boolean(runner.error);
|
3929
|
-
});
|
3930
|
-
}
|
3931
|
-
function abortRunner(runner) {
|
3932
|
-
if (!runner.error && !runner.aborted) {
|
3933
|
-
runner.abort();
|
3934
|
-
runner.aborted = true;
|
3935
|
-
}
|
3936
|
-
}
|
3937
|
-
|
3938
|
-
|
3939
|
-
/***/ }),
|
3940
|
-
/* 59 */
|
3941
|
-
/***/ (function(module, exports, __webpack_require__) {
|
3942
|
-
|
3943
|
-
"use strict";
|
3944
|
-
var util_1 = __webpack_require__(11);
|
3945
|
-
var runtime_1 = __webpack_require__(2);
|
3946
|
-
var sequential_strategy_1 = __webpack_require__(57);
|
3947
|
-
var Collections = __webpack_require__(9);
|
3948
|
-
var CachedStrategy = (function () {
|
3949
|
-
function CachedStrategy(strategy, transports, options) {
|
3950
|
-
this.strategy = strategy;
|
3951
|
-
this.transports = transports;
|
3952
|
-
this.ttl = options.ttl || 1800 * 1000;
|
3953
|
-
this.encrypted = options.encrypted;
|
3954
|
-
this.timeline = options.timeline;
|
3955
|
-
}
|
3956
|
-
CachedStrategy.prototype.isSupported = function () {
|
3957
|
-
return this.strategy.isSupported();
|
3958
|
-
};
|
3959
|
-
CachedStrategy.prototype.connect = function (minPriority, callback) {
|
3960
|
-
var encrypted = this.encrypted;
|
3961
|
-
var info = fetchTransportCache(encrypted);
|
3962
|
-
var strategies = [this.strategy];
|
3963
|
-
if (info && info.timestamp + this.ttl >= util_1["default"].now()) {
|
3964
|
-
var transport = this.transports[info.transport];
|
3965
|
-
if (transport) {
|
3966
|
-
this.timeline.info({
|
3967
|
-
cached: true,
|
3968
|
-
transport: info.transport,
|
3969
|
-
latency: info.latency
|
3970
|
-
});
|
3971
|
-
strategies.push(new sequential_strategy_1["default"]([transport], {
|
3972
|
-
timeout: info.latency * 2 + 1000,
|
3973
|
-
failFast: true
|
3974
|
-
}));
|
3975
|
-
}
|
3976
|
-
}
|
3977
|
-
var startTimestamp = util_1["default"].now();
|
3978
|
-
var runner = strategies.pop().connect(minPriority, function cb(error, handshake) {
|
3979
|
-
if (error) {
|
3980
|
-
flushTransportCache(encrypted);
|
3981
|
-
if (strategies.length > 0) {
|
3982
|
-
startTimestamp = util_1["default"].now();
|
3983
|
-
runner = strategies.pop().connect(minPriority, cb);
|
3984
|
-
}
|
3985
|
-
else {
|
3986
|
-
callback(error);
|
3987
|
-
}
|
3988
|
-
}
|
3989
|
-
else {
|
3990
|
-
storeTransportCache(encrypted, handshake.transport.name, util_1["default"].now() - startTimestamp);
|
3991
|
-
callback(null, handshake);
|
3992
|
-
}
|
3993
|
-
});
|
3994
|
-
return {
|
3995
|
-
abort: function () {
|
3996
|
-
runner.abort();
|
3997
|
-
},
|
3998
|
-
forceMinPriority: function (p) {
|
3999
|
-
minPriority = p;
|
4000
|
-
if (runner) {
|
4001
|
-
runner.forceMinPriority(p);
|
4002
|
-
}
|
4003
|
-
}
|
4004
|
-
};
|
4005
|
-
};
|
4006
|
-
return CachedStrategy;
|
4007
|
-
}());
|
4008
|
-
exports.__esModule = true;
|
4009
|
-
exports["default"] = CachedStrategy;
|
4010
|
-
function getTransportCacheKey(encrypted) {
|
4011
|
-
return "pusherTransport" + (encrypted ? "Encrypted" : "Unencrypted");
|
4012
|
-
}
|
4013
|
-
function fetchTransportCache(encrypted) {
|
4014
|
-
var storage = runtime_1["default"].getLocalStorage();
|
4015
|
-
if (storage) {
|
4016
|
-
try {
|
4017
|
-
var serializedCache = storage[getTransportCacheKey(encrypted)];
|
4018
|
-
if (serializedCache) {
|
4019
|
-
return JSON.parse(serializedCache);
|
4020
|
-
}
|
4021
|
-
}
|
4022
|
-
catch (e) {
|
4023
|
-
flushTransportCache(encrypted);
|
4024
|
-
}
|
4025
|
-
}
|
4026
|
-
return null;
|
4027
|
-
}
|
4028
|
-
function storeTransportCache(encrypted, transport, latency) {
|
4029
|
-
var storage = runtime_1["default"].getLocalStorage();
|
4030
|
-
if (storage) {
|
4031
|
-
try {
|
4032
|
-
storage[getTransportCacheKey(encrypted)] = Collections.safeJSONStringify({
|
4033
|
-
timestamp: util_1["default"].now(),
|
4034
|
-
transport: transport,
|
4035
|
-
latency: latency
|
4036
|
-
});
|
4037
|
-
}
|
4038
|
-
catch (e) {
|
4039
|
-
}
|
4040
|
-
}
|
4041
|
-
}
|
4042
|
-
function flushTransportCache(encrypted) {
|
4043
|
-
var storage = runtime_1["default"].getLocalStorage();
|
4044
|
-
if (storage) {
|
4045
|
-
try {
|
4046
|
-
delete storage[getTransportCacheKey(encrypted)];
|
4047
|
-
}
|
4048
|
-
catch (e) {
|
4049
|
-
}
|
4050
|
-
}
|
4051
|
-
}
|
4052
|
-
|
4053
|
-
|
4054
|
-
/***/ }),
|
4055
|
-
/* 60 */
|
4056
|
-
/***/ (function(module, exports, __webpack_require__) {
|
4057
|
-
|
4058
|
-
"use strict";
|
4059
|
-
var timers_1 = __webpack_require__(12);
|
4060
|
-
var DelayedStrategy = (function () {
|
4061
|
-
function DelayedStrategy(strategy, _a) {
|
4062
|
-
var number = _a.delay;
|
4063
|
-
this.strategy = strategy;
|
4064
|
-
this.options = { delay: number };
|
4065
|
-
}
|
4066
|
-
DelayedStrategy.prototype.isSupported = function () {
|
4067
|
-
return this.strategy.isSupported();
|
4068
|
-
};
|
4069
|
-
DelayedStrategy.prototype.connect = function (minPriority, callback) {
|
4070
|
-
var strategy = this.strategy;
|
4071
|
-
var runner;
|
4072
|
-
var timer = new timers_1.OneOffTimer(this.options.delay, function () {
|
4073
|
-
runner = strategy.connect(minPriority, callback);
|
4074
|
-
});
|
4075
|
-
return {
|
4076
|
-
abort: function () {
|
4077
|
-
timer.ensureAborted();
|
4078
|
-
if (runner) {
|
4079
|
-
runner.abort();
|
4080
|
-
}
|
4081
|
-
},
|
4082
|
-
forceMinPriority: function (p) {
|
4083
|
-
minPriority = p;
|
4084
|
-
if (runner) {
|
4085
|
-
runner.forceMinPriority(p);
|
4086
|
-
}
|
4087
|
-
}
|
4088
|
-
};
|
4089
|
-
};
|
4090
|
-
return DelayedStrategy;
|
4091
|
-
}());
|
4092
|
-
exports.__esModule = true;
|
4093
|
-
exports["default"] = DelayedStrategy;
|
4094
|
-
|
4095
|
-
|
4096
|
-
/***/ }),
|
4097
|
-
/* 61 */
|
4098
|
-
/***/ (function(module, exports) {
|
4099
|
-
|
4100
|
-
"use strict";
|
4101
|
-
var IfStrategy = (function () {
|
4102
|
-
function IfStrategy(test, trueBranch, falseBranch) {
|
4103
|
-
this.test = test;
|
4104
|
-
this.trueBranch = trueBranch;
|
4105
|
-
this.falseBranch = falseBranch;
|
4106
|
-
}
|
4107
|
-
IfStrategy.prototype.isSupported = function () {
|
4108
|
-
var branch = this.test() ? this.trueBranch : this.falseBranch;
|
4109
|
-
return branch.isSupported();
|
4110
|
-
};
|
4111
|
-
IfStrategy.prototype.connect = function (minPriority, callback) {
|
4112
|
-
var branch = this.test() ? this.trueBranch : this.falseBranch;
|
4113
|
-
return branch.connect(minPriority, callback);
|
4114
|
-
};
|
4115
|
-
return IfStrategy;
|
4116
|
-
}());
|
4117
|
-
exports.__esModule = true;
|
4118
|
-
exports["default"] = IfStrategy;
|
4119
|
-
|
4120
|
-
|
4121
|
-
/***/ }),
|
4122
|
-
/* 62 */
|
4123
|
-
/***/ (function(module, exports) {
|
4124
|
-
|
4125
|
-
"use strict";
|
4126
|
-
var FirstConnectedStrategy = (function () {
|
4127
|
-
function FirstConnectedStrategy(strategy) {
|
4128
|
-
this.strategy = strategy;
|
4129
|
-
}
|
4130
|
-
FirstConnectedStrategy.prototype.isSupported = function () {
|
4131
|
-
return this.strategy.isSupported();
|
4132
|
-
};
|
4133
|
-
FirstConnectedStrategy.prototype.connect = function (minPriority, callback) {
|
4134
|
-
var runner = this.strategy.connect(minPriority, function (error, handshake) {
|
4135
|
-
if (handshake) {
|
4136
|
-
runner.abort();
|
4137
|
-
}
|
4138
|
-
callback(error, handshake);
|
4139
|
-
});
|
4140
|
-
return runner;
|
4141
|
-
};
|
4142
|
-
return FirstConnectedStrategy;
|
4143
|
-
}());
|
4144
|
-
exports.__esModule = true;
|
4145
|
-
exports["default"] = FirstConnectedStrategy;
|
4146
|
-
|
4147
|
-
|
4148
|
-
/***/ }),
|
4149
|
-
/* 63 */
|
4150
|
-
/***/ (function(module, exports, __webpack_require__) {
|
4151
|
-
|
4152
|
-
"use strict";
|
4153
|
-
var defaults_1 = __webpack_require__(5);
|
4154
|
-
exports.getGlobalConfig = function () {
|
4155
|
-
return {
|
4156
|
-
wsHost: defaults_1["default"].host,
|
4157
|
-
wsPort: defaults_1["default"].ws_port,
|
4158
|
-
wssPort: defaults_1["default"].wss_port,
|
4159
|
-
wsPath: defaults_1["default"].ws_path,
|
4160
|
-
httpHost: defaults_1["default"].sockjs_host,
|
4161
|
-
httpPort: defaults_1["default"].sockjs_http_port,
|
4162
|
-
httpsPort: defaults_1["default"].sockjs_https_port,
|
4163
|
-
httpPath: defaults_1["default"].sockjs_path,
|
4164
|
-
statsHost: defaults_1["default"].stats_host,
|
4165
|
-
authEndpoint: defaults_1["default"].channel_auth_endpoint,
|
4166
|
-
authTransport: defaults_1["default"].channel_auth_transport,
|
4167
|
-
activity_timeout: defaults_1["default"].activity_timeout,
|
4168
|
-
pong_timeout: defaults_1["default"].pong_timeout,
|
4169
|
-
unavailable_timeout: defaults_1["default"].unavailable_timeout
|
4170
|
-
};
|
4171
|
-
};
|
4172
|
-
exports.getClusterConfig = function (clusterName) {
|
4173
|
-
return {
|
4174
|
-
wsHost: "ws-" + clusterName + ".pusher.com",
|
4175
|
-
httpHost: "sockjs-" + clusterName + ".pusher.com"
|
4176
|
-
};
|
4177
|
-
};
|
4178
|
-
|
4179
|
-
|
4180
|
-
/***/ })
|
4181
|
-
/******/ ])
|
4182
|
-
});
|
4183
|
-
;
|